#include <stdio.h>
#include <vector>
#include <algorithm>
 
int main() {
    int n;
    scanf("%d", &n);
     
    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &a[i], &b[i]);
    }
     
    std::vector<int> queue1(n), queue2(n);
     
    for (int i = 0; i < n; ++i) {
        queue1[i] = i;
        queue2[i] = i;
    }
     
    std::sort(queue1.begin(), queue1.end(), [&](const int i, const int j) {
        return a[i] > a[j] || (a[i] == a[j] && b[i] > b[j]);
    });
     
    std::sort(queue2.begin(), queue2.end(), [&](const int i, const int j) {
        return b[i] > b[j] || (b[i] == b[j] && a[i] > a[j]);
    });
     
    std::vector<bool> actual(n, true);
     
    int sum1 = 0, sum2 = 0, pos1 = 0, pos2 = 0;
    while (true) {
        while (pos1 < n && actual[pos1] == false) ++pos1;
        if (pos1 == n) break;
        sum1 += a[pos1];
        actual[pos1] = false;
        while (pos2 < n && actual[pos2] == false) ++pos2;
        if (pos2 == n) break;
        sum2 += b[pos2];
        actual[pos2] = false;
    }
    printf("%d", sum1-sum2);
    return 0;
}