n = gets.chomp!.to_i

takahashi = []
aoki = []
tokuten = []

n.times do |i|
  a, b = gets.chomp!.split(" ").map(&:to_i)
  takahashi << a
  aoki << b
  tokuten << { idx: i, point: a + b }
end

takahashi_points = takahashi.values_at(*(tokuten.sort{ |t| t[:point] }.select.with_index{ |_, idx| idx.even? }.map{ |t| t[:idx] })).inject(:+)

aoki_points = aoki.values_at(*(tokuten.sort{ |t| t[:point] }.select.with_index{ |_, idx| idx.odd? }.map{ |t| t[:idx] })).inject(:+)

puts takahashi_points - aoki_points
