n = gets.to_i
table = []

n.times do
  a = gets.chomp.split(" ").map(&:to_i)
  table << [a[0] - a[1], a[0], a[1]]
end

table.sort_by!{|k| k[0]}
total = 0
for i in 0..table.length-1
  if i.even?
    total += table[i][1]
  else
    total -= table[i][2]
  end
end

puts total