#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>
struct Pair {
int a, b;
};
int main() {
int n;
scanf("%d", &n);
std::vector<Pair> pairs(n);
for (auto& it : pairs) {
scanf("%d %d", &it.a, &it.b);
}
std::stable_sort(pairs.begin(), pairs.end(), [](const Pair& lhs, const Pair& rhs) {
return lhs.a + lhs.b > rhs.a + rhs.b;
});
long long sum = 0;
for (int i = 0; i < n; ++i) {
sum += (i % 2 == 0) ? (pairs[i].a) : (-pairs[i].b);
}
std::cout << sum;
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxpb3N0cmVhbT4KCnN0cnVjdCBQYWlyIHsKICAgIGludCBhLCBiOwp9OwoKaW50IG1haW4oKSB7CiAgICBpbnQgbjsKICAgIHNjYW5mKCIlZCIsICZuKTsKICAgICAKICAgIHN0ZDo6dmVjdG9yPFBhaXI+IHBhaXJzKG4pOwogICAgZm9yIChhdXRvJiBpdCA6IHBhaXJzKSB7CiAgICAgICAgc2NhbmYoIiVkICVkIiwgJml0LmEsICZpdC5iKTsKICAgIH0KICAgIAogICAgc3RkOjpzdGFibGVfc29ydChwYWlycy5iZWdpbigpLCBwYWlycy5lbmQoKSwgW10oY29uc3QgUGFpciYgbGhzLCBjb25zdCBQYWlyJiByaHMpIHsKICAgICAgICByZXR1cm4gbGhzLmEgKyBsaHMuYiA+IHJocy5hICsgcmhzLmI7CiAgICB9KTsKCiAgICBsb25nIGxvbmcgc3VtID0gMDsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7CiAgICAgICAgc3VtICs9IChpICUgMiA9PSAwKSA/IChwYWlyc1tpXS5hKSA6ICgtcGFpcnNbaV0uYik7CiAgICB9CiAgICBzdGQ6OmNvdXQgPDwgc3VtOwogICAgcmV0dXJuIDA7Cn0=