output_description: Print the value: "the sum of the happiness Takahashi earns in the end" minus
  "the sum of the happiness Aoki earns in the end".
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 B_1
      :
      A_N B_N
attempt: import sys
  import heapq
  import re
  from heapq import heapify, heappop, heappush
  from itertools import permutations
  from bisect import bisect_left, bisect_right
  from collections import Counter, deque
  from fractions import gcd
  from math import factorial, sqrt, ceil
  from functools import lru_cache, reduce
  
  INF = 1 << 60
  MOD = 1000000007
  sys.setrecursionlimit(10**7)
  
  
  # UnionFind
  class UnionFind:
      def __init__(self, n):
          self.n = n
          self.parents = [-1] * n
  
      def find(self, x):
          if self.parents[x] < 0:
              return x
          else:
              self.parents[x] = self.find(self.parents[x])
              return self.parents[x]
  
      def union(self, x, y):
          x = self.find(x)
          y = self.find(y)
  
          if x == y:
              return
  
          if self.parents[x] > self.parents[y]:
              x, y = y, x
  
          self.parents[x] += self.parents[y]
          self.parents[y] = x
  
      def size(self, x):
          return -self.parents[self.find(x)]
  
      def same(self, x, y):
          return self.find(x) == self.find(y)
  
      def members(self, x):
          root = self.find(x)
          return [i for i in range(self.n) if self.find(i) == root]
  
      def roots(self):
          return [i for i, x in enumerate(self.parents) if x < 0]
  
      def group_count(self):
          return len(self.roots())
  
      def all_group_members(self):
          return {r: self.members(r) for r in self.roots()}
  
      def __str__(self):
          return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())
  
  
  # ダイクストラ
  def dijkstra_heap(s, edge, n):
      # 始点sから各頂点への最短距離
      d = [10**20] * n
      used = [True] * n  # True:未確定
      d[s] = 0
      used[s] = False
      edgelist = []
      for a, b in edge[s]:
          heapq.heappush(edgelist, a * (10**6) + b)
      while len(edgelist):
          minedge = heapq.heappop(edgelist)
          # まだ使われてない頂点の中から最小の距離のものを探す
          if not used[minedge % (10**6)]:
              continue
          v = minedge % (10**6)
          d[v] = minedge // (10**6)
          used[v] = False
          for e in edge[v]:
              if used[e[1]]:
                  heapq.heappush(edgelist, (e[0] + d[v]) * (10**6) + e[1])
      return d
  
  
  # 素因数分解
  def factorization(n):
      arr = []
      temp = n
      for i in range(2, int(-(-(n**0.5) // 1)) + 1):
          if temp % i == 0:
              cnt = 0
              while temp % i == 0:
                  cnt += 1
                  temp //= i
              arr.append([i, cnt])
  
      if temp != 1:
          arr.append([temp, 1])
  
      if arr == []:
          arr.append([n, 1])
  
      return arr
  
  
  # 2数の最小公倍数
  def lcm(x, y):
      return (x * y) // gcd(x, y)
  
  
  # リストの要素の最小公倍数
  def lcm_list(numbers):
      return reduce(lcm, numbers, 1)
  
  
  # リストの要素の最大公約数
  def gcd_list(numbers):
      return reduce(gcd, numbers)
  
  
  # 素数判定
  def is_prime(n):
      if n <= 1:
          return False
      p = 2
      while True:
          if p**2 > n:
              break
          if n % p == 0:
              return False
          p += 1
      return True
  
  
  # limit以下の素数を列挙
  def eratosthenes(limit):
      A = [i for i in range(2, limit + 1)]
      P = []
  
      while True:
          prime = min(A)
  
          if prime > sqrt(limit):
              break
  
          P.append(prime)
  
          i = 0
          while i < len(A):
              if A[i] % prime == 0:
                  A.pop(i)
                  continue
              i += 1
  
      for a in A:
          P.append(a)
  
      return P
  
  
  # 同じものを含む順列
  def permutation_with_duplicates(L):
  
      if L == []:
          return [[]]
  
      else:
          ret = []
  
          # set（集合）型で重複を削除、ソート
          S = sorted(set(L))
  
          for i in S:
  
              data = L[:]
              data.remove(i)
  
              for j in permutation_with_duplicates(data):
                  ret.append([i] + j)
  
          return ret
  
  
  # ここから書き始める
  n = int(input())
  a = [0 for i in range(n)]
  b = [0 for i in range(n)]
  x = [[] for i in range(n)]
  y = [[] for i in range(n)]
  for i in range(n):
      a[i], b[i] = map(int, input().split())
      x[i] = [a[i] + b[i], a[i], i]
      y[i] = [b[i] + a[i], b[i], i]
  x.sort(reverse=True, key=lambda i: (i[0], i[1]))
  y.sort(reverse=True, key=lambda i: (i[0], i[1]))
  # print("x =", x)
  # print("y =", y)
  ans = 0
  used = [0 for i in range(n)]
  takahashi = True
  t_cnt = 0
  a_cnt = 0
  cnt = 0
  while cnt < n:
      if takahashi and t_cnt < n:
          if used[x[t_cnt][2]] == 0:
              ans += x[t_cnt][1]
              takahashi = False
              cnt += 1
              used[x[t_cnt][2]] = 1
          t_cnt += 1
      elif (not takahashi) and a_cnt < n:
          if used[y[a_cnt][2]] == 0:
              ans -= y[a_cnt][1]
              takahashi = True
              cnt += 1
              used[y[a_cnt][2]] = 1
          a_cnt += 1
      # print(ans)
  print(ans)
  
problem_description: Statement
  
  There are N dishes of cuisine placed in front of Takahashi and Aoki. For
  convenience, we call these dishes Dish 1, Dish 2, ..., Dish N.
  
  When Takahashi eats Dish i, he earns A_i points of _happiness_ ; when Aoki
  eats Dish i, she earns B_i points of happiness.
  
  Starting from Takahashi, they alternately choose one dish and eat it, until
  there is no more dish to eat. Here, both of them choose dishes so that the
  following value is maximized: "the sum of the happiness he/she will earn in
  the end" minus "the sum of the happiness the other person will earn in the
  end".
  
  Find the value: "the sum of the happiness Takahashi earns in the end" minus
  "the sum of the happiness Aoki earns in the end".
samples: [{"input": "3\n    10 10\n    20 20\n    30 30", "output": "20\n    \n\nIn this sample, both of them earns 10 points of happiness by eating Dish 1, 20\npoints by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since Takahashi and Aoki have the same \"taste\", each time they\nwill choose the dish with which they can earn the greatest happiness. Thus,\nfirst Takahashi will choose Dish 3, then Aoki will choose Dish 2, and finally\nTakahashi will choose Dish 1, so the answer is (30 + 10) - 20 = 20.\n\n* * *"}, {"input": "3\n    20 10\n    20 20\n    20 30", "output": "20\n    \n\nIn this sample, Takahashi earns 20 points of happiness by eating any one of\nthe dishes 1, 2 and 3, but Aoki earns 10 points of happiness by eating Dish 1,\n20 points by eating Dish 2, and 30 points by eating Dish 3.\n\nIn this case, since only Aoki has likes and dislikes, each time they will\nchoose the dish with which Aoki can earn the greatest happiness. Thus, first\nTakahashi will choose Dish 3, then Aoki will choose Dish 2, and finally\nTakahashi will choose Dish 1, so the answer is (20 + 20) - 20 = 20.\n\n* * *"}, {"input": "6\n    1 1000000000\n    1 1000000000\n    1 1000000000\n    1 1000000000\n    1 1000000000\n    1 1000000000", "output": "-2999999997\n    \n\nNote that the answer may not fit into a 32-bit integer."}]