#include <bits/stdc++.h>
#define fi first
#define sd second
using namespace std;
priority_queue<pair<int,int> > q;
int t,x,y,f=0;
long long ret[3];
int main() {
freopen("nit.in","r",stdin);
freopen("nit.out","w",stdout);
cin>>t;
while (t--)
{
scanf("%d%d",&x,&y);
q.push({x-y,y});
}
while (!q.empty())
{
pair<int,int> t=q.top();q.pop();
if (t.fi>=0)
{
ret[f]+=t.fi+t.sd,ret[f^1]+=t.sd;
}
else
{
ret[0]+=t.fi+t.sd,ret[1]+=t.sd;
}
f^=1;
}
cout<<ret[0]-ret[1];
}