import sys



n=int(sys.stdin.readline())

M = []

for i in range(n):

    a,b = list(map(int,sys.stdin.readline().split()))

    M.append([a,b])



M = sorted(M,key=lambda x:sum(x), reverse=True)

cnt = 0

for i in range(n):

    if i%2==0:

        cnt += M[i][0]

    else:

        cnt -= M[i][1]

print(cnt)

import sys

from collections import deque





n=int(sys.stdin.readline())

M = deque(maxlen=n)

for i in range(n):

    a,b = list(map(int,sys.stdin.readline().split()))

    M.append([a,b])



M = sorted(M,key=lambda x:sum(x))

cnt = 0

for i in range(n):

    if i%2==0:

        cnt += M.pop()[0]

    else:

        cnt -= M.pop()[1]

print(cnt)

import sys

n = int(sys.stdin.readline())
M = []
for i in range(n):
    a, b = list(map(int, sys.stdin.readline().split()))
    M.append([a, b])
M = sorted(M, key=lambda x: sum(x), reverse=True)
cnt = 0
for i in range(n):
    if i % 2 == 0:
        cnt += M[i][0]
    else:
        cnt -= M[i][1]
print(cnt)

import sys
from collections import deque

n = int(sys.stdin.readline())
M = deque(maxlen=n)
for i in range(n):
    a, b = list(map(int, sys.stdin.readline().split()))
    M.append([a, b])
M = sorted(M, key=lambda x: sum(x))
cnt = 0
for i in range(n):
    if i % 2 == 0:
        cnt += M.pop()[0]
    else:
        cnt -= M.pop()[1]
print(cnt)

+from collections import deque -M = [] +M = deque(maxlen=n) -M = sorted(M, key=lambda x: sum(x), reverse=True) +M = sorted(M, key=lambda x: sum(x)) -        cnt += M[i][0] +        cnt += M.pop()[0] -        cnt -= M[i][1] +        cnt -= M.pop()[1]