"use strict";
function Main(input) {
    var lines = input.split("\n");
    var N = lines.shift() - 0;
    var ryo = new Array(N);
    for (var n = 0; n < N; n++) {
        var nums = lines[n].split(" ");
        ryo[n] = {
            taka : nums[0] - 0,
            aoki : nums[1] - 0,
        };
    }
    ryo.sort(function(a, b) { if (b.taka > a.taka) return b.taka - a.taka; else return b.aoki - a.aoki; });
    var aoki = ryo.map(function(value, index) { return {val: value.aoki, idx: index}; });
    aoki.sort(function(a, b) { return b.val - a.val; });
    var koufuku = 0, c = 0;
    for (var n = 0; n < N; n++) {
        if (n % 2 == 0) {
            koufuku += ryo[c].taka;
            ryo[c].taka = 0;
        } else {
            koufuku -= aoki[c].val;
            ryo[aoki[c].idx].aoki = 0;
        }
        c++;
    }
    console.log(koufuku);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
