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

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

takahashi = dishes.sort_by {|d| [-d.b, -d.a]}
aoki = dishes.sort_by {|d| [-d.a, -d.b]}

# p takahashi, aoki

hash = {}

ans = 0
n.times do |i|
  # takahashi
  if (i % 2) == 0
    t = takahashi.shift
    while hash[t.id]
      t = takahashi.shift
    end
    ans += t.a
    hash[t.id] = true
  else
    t = aoki.shift
    while hash[t.id]
      t = aoki.shift
    end
    ans -= t.b
    hash[t.id] = true
  end
end

puts ans
