n = gets.to_i
dish = Array.new(n).map{Array.new(2, 0)}
tk = Array.new(n).map{Array.new(2, 0)}
ao = Array.new(n).map{Array.new(2, 0)}
for i in 0..n-1
  dish[i] = gets.split.map(&:to_i)
  tk[i] = [dish[i][0],dish[i][1]-dish[i][0],i]
  ao[i] = [dish[i][1],dish[i][0]-dish[i][1],i]
end
eat = Array.new(n,0)
tk.sort!
ao.sort!
t = 0
a = 0
for i in 1..n-1
  while eat[tk[-1][2]] == 1
    tk.delete_at(-1)
  end
  while eat[ao[-1][2]] == 1
    ao.delete_at(-1)
  end
  if i % 2 == 1
    if tk[-1][2] == ao[-1][2] || (tk[-1][0] - ao[-1][0]) < (dish[ao[-1][2]][0] - ao[-2][0])
      t += dish[ao[-1][2]][0]
      eat[ao[-1][2]] = 1
    else
      t += tk[-1][0]
      eat[tk[-1][2]] = 1
    end
  else
    if ao[-1][2] == tk[-1][2] || (ao[-1][0] - tk[-1][0]) < (dish[tk[-1][2]][1] - tk[-2][0])
      a += dish[tk[-1][2]][1]
      eat[tk[-1][2]] = 1
    else
      a += ao[-1][0]
      eat[ao[-1][2]] = 1
    end
  end
end

while eat[tk[-1][2]] == 1
  tk.delete_at(-1)
end
while eat[ao[-1][2]] == 1
  ao.delete_at(-1)
end
if n % 2 == 1
  t += tk[-1][0]
else
  a += ao[-1][0]
end
puts t - a
