n = gets.to_i
dishes = []
n.times do
  dishes.push(gets.chomp.split(" "))
end
dishes.sort! {|a, b| b[0]+b[1] <=> a[0]+a[1]}
takahashi = 0
aoki = 0
while dishes.length > 0 do
  tmp = dishes.shift
  takahashi += tmp[0].to_i
  if dishes.length > 0 then
    tmp = dishes.shift
    aoki += tmp[1].to_i
  end
end
puts takahashi - aoki
