let rv f p q = f q p;;
Scanf.(Array.(scanf " %d" @@ fun n ->
  let a,b = make n 0,make n 0 in
  init n (fun i -> scanf " %d %d" @@ fun u v -> a.(i) <- u; b.(i) <- v);
  let c = init n (fun i -> a.(i)+b.(i),i) in
  sort (rv compare) c;
  print_int @@ fst @@
    fold_left (fun (sum,j) (_,i) ->
      (sum + if j mod 2 = 0 then a.(i) else -b.(i)),j+1
    ) (0,0) c))