function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);

    var A = [];
    var B = [];
    var abs = [];

    var both_cook;

    for(var i = 1; i <= N; i++) {
        both_cook =  args[i].split(' ');
        A[i - 1] = parseInt(both_cook[0], 10);
        B[i- 1] = parseInt(both_cook[1], 10);
        abs[i -1] = B[i -1] - A[i - 1];
    }

    var ans_kofuku = 0;
    var eat_max = Math.ceil(N);
    var best_oishi_value = 0;
    var worst_oishi_value = Math.min.apply(null, abs);
    var best_oishi;
    var is_a_turn = true;


    for(var i = 0; i < eat_max; i++) {
        // 配列の要素番号に
        best_oishi_value =  Math.max.apply(null, abs);
        if(best_oishi_value <= worst_oishi_value) {
            if (is_a_turn) {
                best_oishi = B.indexOf(Math.max.apply(null, B));
            } else {
                best_oishi = A.indexOf(Math.max.apply(null, A));
            }
        } else {
            best_oishi = abs.indexOf(best_oishi_value);
        }
        if(is_a_turn) {
            ans_kofuku += A[best_oishi];
            is_a_turn = false;
        } else {
            ans_kofuku -= B[best_oishi];
            is_a_turn = true;
        }
        abs[best_oishi] = worst_oishi_value;
        A[best_oishi] = worst_oishi_value;
        B[best_oishi] = worst_oishi_value;
        // console.log(A);
        // console.log(B);
        // console.log(abs)
        // splive使うとタイムオーバーになるので色々工夫
        // abs.splice(best_oishi, 1);
        // A.splice(best_oishi, 1);
        // B.splice(best_oishi, 1);
    }

    console.log(ans_kofuku);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
