N=gets.to_i
A=Array.new(N,0),B=Array.new(N,0),ind=Array.new(N,0)
for i in 0..N-1
	ta,tb=gets.split(" ").map(&:to_i)
	A[i]=ta
	B[i]=tb
	ind[i]=i
end

ind=ind.sort {|x,y|(A[y]+B[y])<=>(A[x]+B[x])}
sgn=1
sum=0
for i in 0..N-1
	sum+=(sgn==1)? A[ind[i]] : -B[ind[i]]
	sgn*=-1
end
puts sum