N = int(eval(input()))

Takahashi = [None] * N

Aoki = [None] * N

Used = [False] * N

for i in range(N):

    a, b = list(map(int, input().split()))

    Takahashi[i] = (-a-b, -a, i)

    Aoki[i] = (-b-a, -b, i)

Takahashi.sort()

Aoki.sort()

TotalPoint = 0



usedDish = 0

tnum, anum = 0, 0

while usedDish < N:

    if usedDish % 2 == 0:

        while Used[Takahashi[tnum][2]]:

            tnum += 1

        TotalPoint -= Takahashi[tnum][1]

        Used[Takahashi[tnum][2]] = True

        usedDish += 1

    else:

        while Used[Aoki[anum][2]]:

            anum += 1

        TotalPoint += Aoki[anum][1] 

        Used[Aoki[anum][2]] = True

        usedDish += 1

print(TotalPoint)



import sys



def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    T, A = [None] * N, [None] * N

    used = [False] * N

    for i in range(N):

        a, b = list(map(int, input().split()))

        T[i] = (a + b, a, i)

        A[i] = (a + b, b, i)

    T.sort(reverse = True)

    A.sort(reverse = True)

    hapiness = 0

    ti, ai = 0, 0

    for i in range(N):

        if i % 2 == 0:

            while used[T[ti][2]]: ti += 1

            hapiness += T[ti][1]

            used[T[ti][2]] = True

            ti += 1           

        else:

            while used[A[ai][2]]: ai += 1

            hapiness -= A[ai][1]

            used[A[ai][2]] = True

            ai += 1

    print(hapiness)

   

    return 0



if __name__ == "__main__":

    solve()
N = int(eval(input()))
Takahashi = [None] * N
Aoki = [None] * N
Used = [False] * N
for i in range(N):
    a, b = list(map(int, input().split()))
    Takahashi[i] = (-a - b, -a, i)
    Aoki[i] = (-b - a, -b, i)
Takahashi.sort()
Aoki.sort()
TotalPoint = 0
usedDish = 0
tnum, anum = 0, 0
while usedDish < N:
    if usedDish % 2 == 0:
        while Used[Takahashi[tnum][2]]:
            tnum += 1
        TotalPoint -= Takahashi[tnum][1]
        Used[Takahashi[tnum][2]] = True
        usedDish += 1
    else:
        while Used[Aoki[anum][2]]:
            anum += 1
        TotalPoint += Aoki[anum][1]
        Used[Aoki[anum][2]] = True
        usedDish += 1
print(TotalPoint)

import sys


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    T, A = [None] * N, [None] * N
    used = [False] * N
    for i in range(N):
        a, b = list(map(int, input().split()))
        T[i] = (a + b, a, i)
        A[i] = (a + b, b, i)
    T.sort(reverse=True)
    A.sort(reverse=True)
    hapiness = 0
    ti, ai = 0, 0
    for i in range(N):
        if i % 2 == 0:
            while used[T[ti][2]]:
                ti += 1
            hapiness += T[ti][1]
            used[T[ti][2]] = True
            ti += 1
        else:
            while used[A[ai][2]]:
                ai += 1
            hapiness -= A[ai][1]
            used[A[ai][2]] = True
            ai += 1
    print(hapiness)
    return 0


if __name__ == "__main__":
    solve()

-N = int(eval(input())) -Takahashi = [None] * N -Aoki = [None] * N -Used = [False] * N -for i in range(N): -    a, b = list(map(int, input().split())) -    Takahashi[i] = (-a - b, -a, i) -    Aoki[i] = (-b - a, -b, i) -Takahashi.sort() -Aoki.sort() -TotalPoint = 0 -usedDish = 0 -tnum, anum = 0, 0 -while usedDish < N: -    if usedDish % 2 == 0: -        while Used[Takahashi[tnum][2]]: -            tnum += 1 -        TotalPoint -= Takahashi[tnum][1] -        Used[Takahashi[tnum][2]] = True -        usedDish += 1 -    else: -        while Used[Aoki[anum][2]]: -            anum += 1 -        TotalPoint += Aoki[anum][1] -        Used[Aoki[anum][2]] = True -        usedDish += 1 -print(TotalPoint) +import sys + + +def solve(): +    input = sys.stdin.readline +    N = int(eval(input())) +    T, A = [None] * N, [None] * N +    used = [False] * N +    for i in range(N): +        a, b = list(map(int, input().split())) +        T[i] = (a + b, a, i) +        A[i] = (a + b, b, i) +    T.sort(reverse=True) +    A.sort(reverse=True) +    hapiness = 0 +    ti, ai = 0, 0 +    for i in range(N): +        if i % 2 == 0: +            while used[T[ti][2]]: +                ti += 1 +            hapiness += T[ti][1] +            used[T[ti][2]] = True +            ti += 1 +        else: +            while used[A[ai][2]]: +                ai += 1 +            hapiness -= A[ai][1] +            used[A[ai][2]] = True +            ai += 1 +    print(hapiness) +    return 0 + + +if __name__ == "__main__": +    solve()