n = gets.to_i
Dish = Struct.new(:a, :b)
dishes = []

n.times do
  a, b = gets.split.map(&:to_i)
  dishes << Dish.new(a, b)
end

dishes.sort_by! {|d| [-d.b, -d.a]}

ans = 0
dishes.each_with_index do |d, i|
  if (i % 2) == 0
    ans += d.a
  else
    ans -= d.b
  end
end

p ans
