input1 = gets
num1 = input1.to_i - 1

ary1 = Array.new(num1)
for num in 0..num1 do
  ary1[num] = gets
end 
numa = 0
numb = 0
while ary1.length > 0  do
  max1 = 0
  max2 = 0
  for num in 0..ary1.length-1 do
    str = ary1[num].split(" ")
    if max1 < str[0].to_i then
      idx1 = num
      max1 = str[0].to_i
      max2 = str[1].to_i
    elsif max1 == str[0].to_i then
      if  str[1].to_i > max2 then
        idx1 = num
        max2 = str[1].to_i
      end
    end
  end 
  #puts idx1.to_s + " max1:" + max1.to_s

  numa += max1
  ary1.delete_at(idx1)

  if ary1.length == 0 then
    break
  end

  max2 = 0
  max1 = 0
  for num in 0..ary1.length-1 do
    str = ary1[num].split(" ")
    if max2 < str[1].to_i then
      idx2 = num
      max1 = str[0].to_i
      max2 = str[1].to_i
    elsif max2 == str[1].to_i then
      if  str[0].to_i > max1 then
        idx2 = num
        max1 = str[0].to_i
      end
    end
  end 
  #puts idx2.to_s + " max2:" + max2.to_s

  numb += max2
  ary1.delete_at(idx2)
end

puts (numa - numb).to_s
