import Data.List
import Data.Traversable
main = do
  n <- (read :: String -> Int) <$> getLine
  ps <- for [1..n] $ \x ->
    (\xs -> (xs!!0 , xs!!1)) . map read . words <$> getLine
  putStrLn . show $ solve ps
solve :: [(Integer,Integer)] -> Integer
solve ps =
  let sorted = reverse . (sortBy (\(a1,a2) (b1,b2) -> compare (a1+a2) (b1+b2) )) $ ps
  in addEveryOther sorted



addEveryOther :: [(Integer,Integer)] -> Integer
addEveryOther [] = 0
addEveryOther ((a1,a2):[]) = a1
addEveryOther ((a1,a2):(b1,b2):xs) = a1 - b2 + (addEveryOther xs)
