n = gets.to_i

happiness = []

left   = n
pointT = 0
pointA = 0

n.times do |i|
  a, b = gets.split.map(&:to_i)
  happiness << [a, b, a + b, i]
end

happiness = happiness.sort_by{|ary| ary[2]}.reverse

loop do
  if left > 0
    pointT += happiness.shift[0]
    left -= 1
  else
    break
  end

  if left > 0
    pointA += happiness.shift[1]
    left -= 1
  else
    break
  end
end

puts pointT - pointA
