
import Data.List
import Control.Monad
solver::[(Integer,Integer)]->Integer
solver ls = let l = (zip [1..] (sortBy (\ (a,b) -> \ (c,d)-> compare (a+b) (c+d)) ls)) in ((sum.(map (fst.snd)).(filter (\(i,_)->mod i 2 == 1))) l) - ((sum.(map (snd.snd)).(filter (\(i,_)->mod i 2 == 0))) l)

main::IO()
main=do
  n<-(return.read)=<<getLine
  dat<-forM [1..n] (\_->return.(\(a:b:_)->(a,b)).(map read).words=<<getLine)
  print (solver dat)