n = gets.to_i
dish = Array.new(n).map{Array.new(2, 0)}
for i in 0..n-1
  dish[i] = gets.split.map(&:to_i)
end
tkhs = Array.new(n).map{Array.new(3, 0)}
aok = Array.new(n).map{Array.new(3, 0)}
for i in 0..n-1
  tkhs[i] = [dish[i][0], i]
  aok[i] = [dish[i][1], i]
end
tkhs.sort!
aok.sort!
t_p = 0
a_p = 0
eat = Array.new(n, 0)
for i in 1..n
  if i % 2 == 1
    while eat[tkhs[-1][1]] == 1
      tkhs.delete_at(-1)
    end
    if  tkhs[-1][1] == aok[-1][1] || (tkhs[-1][0] - aok[-1][0]) < (dish[aok[-1][1]][0] - aok[-2][0])
      t_p += dish[aok[-1][1]][0]
      eat[aok[-1][1]] = 1
      aok.delete_at(-1)
    else
      t_p += tkhs[-1][0]
      eat[tkhs[-1][1]] = 1
      tkhs.delete_at(-1)
     end
  else
    while eat[aok[-1][1]] == 1
      aok.delete_at(-1)
    end
    if  aok[-1][1] == tkhs[-1][1] || (aok[-1][0] - tkhs[-1][0]) < (dish[tkhs[-1][1]][0] - tkhs[-2][0])
      a_p += dish[tkhs[-1][1]][0]
      eat[tkhs[-1][1]] = 1
      tkhs.delete_at(-1)
    else
      a_p += aok[-1][0]
      eat[aok[-1][1]] = 1
      aok.delete_at(-1)
     end
  end
end
puts t_p - a_p
