n = gets.chomp.to_i
dishes = Array.new(n).map{Array.new(2,0)}
n.times do |i|
    dishes[i][0], dishes[i][1] = gets.chomp.split.map(&:to_i)
end
dishes.sort_by! do |d|
    d[0]-d[1]
end
sum = 0
turn = 1
dishes.each do |d|
    if turn == 1
        dish = d[0]
    else
        dish = d[1]
    end
    sum += dish * turn
    turn *= -1
end
puts sum