def main()
  n = gets.chomp.to_i
  a = []
  b = []
  a_sum = 0
  b_sum = 0
  for i in 0..(n-1) do
    a[i], b[i] = gets.chomp.strip.split(' ').map(&:to_i)
  end

  while true do
    break if a.size == 0
    memo = 1
    memo_index = 0
    a.each_with_index do |value, index|
      if value == a.max
        if (memo < b[index])
          memo = b[index]
          memo_index = index
        end
      end
    end
    a_sum += a[memo_index]
    a.delete_at(memo_index)
    b.delete_at(memo_index)

    break if b.size == 0
    memo = 1
    memo_index = 0
    b.each_with_index do |value, index|
      if value == b.max
        if (memo < a[index])
          memo = a[index]
          memo_index = index
        end
      end
    end
    b_sum += b[memo_index]
    a.delete_at(memo_index)
    b.delete_at(memo_index)
  end
  a_sum += a[0] if (a.size == 1)
  b_sum += b[0] if (b.size == 1)
  
  puts "#{a_sum - b_sum}"
end
main