lines = readlines
n = lines.shift.chomp.to_i
ab = lines.map{|line| line.chomp.split(' ').map{|x| x.to_i}}

taka = 0
aoki = 0
(0...n).each do |i|
	if i % 2 == 0
      ab.sort_by!{|x| [-x[0], -x[1]]}
      s = ab.shift
      taka += s[0]
    else
      ab.sort_by!{|x| [-x[1], -x[0]]}
      s = ab.shift
      aoki += s[1]
    end
end

puts taka - aoki
