n = $stdin.readline.to_i
res = 0
d = Array.new(n) { $stdin.readline.chomp.split.map(&:to_i) }

d.sort_by! {|a, b| - a - b }
n.times do |i|
  a, b = d[i]
  if i.even?
    res += a
  else
    res -= b
  end
end
puts res
