import sys

from operator import itemgetter

read = sys.stdin.read



N, *AB = list(map(int, read().split()))

A = AB[::2]

B = AB[1::2]

ab = [a + b for a, b in zip(A, B)]

ab, A, B = list(zip(*sorted(zip(ab, A, B), key=itemgetter(0), reverse=True)))

print((sum(A[::2]) - sum(B[1::2])))
import sys

from operator import itemgetter

read = sys.stdin.read





def main():

    N, *AB = list(map(int, read().split()))

    A = AB[::2]

    B = AB[1::2]

    ab = [a + b for a, b in zip(A, B)]

    ab, A, B = list(zip(*sorted(zip(ab, A, B), key=itemgetter(0), reverse=True)))



    print((sum(A[::2]) - sum(B[1::2])))





if __name__ == '__main__':

    main()
import sys
from operator import itemgetter

read = sys.stdin.read
N, *AB = list(map(int, read().split()))
A = AB[::2]
B = AB[1::2]
ab = [a + b for a, b in zip(A, B)]
ab, A, B = list(zip(*sorted(zip(ab, A, B), key=itemgetter(0), reverse=True)))
print((sum(A[::2]) - sum(B[1::2])))

import sys
from operator import itemgetter

read = sys.stdin.read


def main():
    N, *AB = list(map(int, read().split()))
    A = AB[::2]
    B = AB[1::2]
    ab = [a + b for a, b in zip(A, B)]
    ab, A, B = list(zip(*sorted(zip(ab, A, B), key=itemgetter(0), reverse=True)))
    print((sum(A[::2]) - sum(B[1::2])))


if __name__ == "__main__":
    main()

-N, *AB = list(map(int, read().split())) -A = AB[::2] -B = AB[1::2] -ab = [a + b for a, b in zip(A, B)] -ab, A, B = list(zip(*sorted(zip(ab, A, B), key=itemgetter(0), reverse=True))) -print((sum(A[::2]) - sum(B[1::2]))) + + +def main(): +    N, *AB = list(map(int, read().split())) +    A = AB[::2] +    B = AB[1::2] +    ab = [a + b for a, b in zip(A, B)] +    ab, A, B = list(zip(*sorted(zip(ab, A, B), key=itemgetter(0), reverse=True))) +    print((sum(A[::2]) - sum(B[1::2]))) + + +if __name__ == "__main__": +    main()