#include <bits/stdc++.h>   using namespace std;   int a[2005], b[2005];   int main() {     int n, i, j, x, y, k;     long long s;     cin >> n;     for (i = 0; i < n; i++) {       cin >> x >> y;       a[x + y]++;       b[1001 + x - y]++;     }     s = 0;     for (i = 0; i < 2003; i++) {       k = a[i];       s += (k - 1) * k / 2;       k = b[i];       s += (k - 1) * k / 2;     }     cout << s << endl;     return 0;   }   