#include <bits/stdc++.h>   using namespace std;   map<long long, long long> mp1, mp2;   long long n, x, yy, c;   vector<pair<int, int>> v;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x >> yy;       v.push_back({x, yy});       mp1[x + yy]++;       mp2[x - yy]++;     }     for (int i = 0; i < n; i++) {       x = v[i].first;       yy = v[i].second;       c += mp1[x + yy];       c += mp2[x - yy];       c -= 2;     }     cout << c / 2 << endl;     return 0;   }   