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
sum = 0
turn = 1
n.times do |i|
    max = 0
    max_diff = -1
    max_i = -1
    dishes.each_with_index do |d,ix|
        if turn == 1
            dish = d[0]
            diff = d[1]-d[0]
        else
            dish = d[1]
            diff = d[0]-d[1]
        end
        if (dish > max) || (dish == max && diff > max_diff)
            max = dish
            max_diff = diff
            max_i = ix
        end
    end
    dishes.delete_at(max_i)
    sum += max * turn
    turn *= -1
end
puts sum