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][1], dish[i][0], i]
  aok[i] = [dish[i][0], 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
     for j in 1..tkhs.length
       if eat[tkhs[-1][2]] == 0
         t_p += tkhs[-1][1]
         eat[tkhs[-1][2]] = 1
         tkhs.delete_at(-1)
         break
       else
         tkhs.delete_at(-1)
       end
     end
   else
     for j in 1..aok.length
       if eat[aok[-1][2]] == 0
         a_p += aok[-1][1]
         eat[aok[-1][2]] = 1
         aok.delete_at(-1)
         break
       else
         aok.delete_at(-1)
       end
     end
   end
end
puts t_p - a_p
