require 'ostruct'
require 'set'

n = gets.to_i

a = Array.new(n).map{OpenStruct.new}
b = Array.new(n).map{OpenStruct.new}
for i in 0...n
    a[i].val, b[i].val = gets.split.map(&:to_i)
    a[i].idx = i
    b[i].idx = i
    a[i].point = a[i].val + b[i].val
    b[i].point = a[i].val + b[i].val
end

a = a.sort_by do |x|
    [x.val, x.point]
end

b = b.sort_by do |x|
    [x.point, x.val]
end

used = Set.new()

suma = 0
sumb = 0
while a.size > 0 && b.size > 0
    # p a
    # p b
    # p "#{suma} #{sumb}"
    while a.size > 0
        x = a.pop
        if used.add?(x.idx)
            suma += x.val
            break
        end
    end

    while b.size > 0
        x = b.pop
        if used.add?(x.idx)
            sumb += x.val
            break
        end
    end
end

puts suma - sumb