n = $stdin.readline.to_i
res =  0
s = 0
d = []
n.times do
  x, y = $stdin.readline.chomp.split.map(&:to_i)
  d << [x, y]
  s -= y
end

d.sort_by! {|a, b| a + b }
res = s
n.times do |i|
  a, b = d[n - 1 - i]
  if (n - 1 - i) % 2 == 0
    res += a + b
  end
end
puts res