n = gets.to_i
abs = []

n.times do
  ab = gets.split.map(&:to_i)
  abs << ab
end

abs.sort! { |a, b| b[0] + b[1] <=> a[0] + a[1] }

t = 0
a = 0
abs.each_with_index do |v, i|
  if i.even?
    t += v[0]
  else
    a += v[1]
  end
end

puts t - a
