n = gets.to_i
a,b = 2.times.map{Array.new(n){|i|[0,i]}}
n.times{|i|a[i][0],b[i][0] = gets.split.map(&:to_i)}
a.sort.reverse!
b.sort.reverse!
used = Array.new(n,false)
ans = 0
i = j = 0
c = 0
while c < n
    if c%2 == 0
        while used[b[i][1]]
            i += 1
        end
        ans += b[i][0]
        used[b[i][1]] = true
    else
        while used[a[j][1]]
            j += 1
        end
        ans -= a[j][0]
        used[a[j][1]] = true
    end
    c += 1
end
for i in 0..n-1
    ans += a[i][0]-b[i][0]
end
puts ans