n = gets.to_i
foods = n.times.map.with_index{ |i| gets.split.map(&:to_i) + [i] }
foods_a = foods.sort{ |a, b| b[0] <=> a[0] }.map{ |a| a[2] }
foods_b = foods.sort{ |a, b| b[1] <=> a[1] }.map{ |a| a[2] }

idx = 0
hash_a = {}
foods_a.each do |i|
  hash_a[i] = idx
  idx += 1
end

idx = 0
hash_b = {}
foods_b.each do |i|
  hash_b[i] = idx
  idx += 1
end

score_a = 0
score_b = 0
n.times do |i|
  max_a, b, idx_a = foods[foods_a[0]]
  a, max_b, idx_b = foods[foods_b[0]]
  if max_a - b >= max_b - a && i.even? || max_a - b < max_b - a && i.odd?
    foods_a.shift
    foods_b.delete_at(hash_b[idx_a])
    if i.even?
      score_a += max_a
    else
      score_b += b
    end
  else
    foods_b.shift
    foods_a.delete_at(hash_a[idx_b])
    if i.odd?
      score_b += max_b
    else
      score_a += a
    end
  end
end
puts score_a - score_b
