Untitled

 avatar
user_5668965
c_cpp
15 days ago
544 B
1
Indexable
Never
#include<bits/stdc++.h>
#define int long long
using namespace std;

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n, answer = 0; cin >> n;

    map<int,int>a, b;

    for(int i = 0 ; i < n; i++)
    {
        int x, y; cin >> x >> y;
        a[x + y]++; b[y - x]++;
    }

    for(auto i : a) answer += i.second * (i.second - 1) / 2;
    for(auto i : b) answer += i.second * (i.second - 1) / 2;

    cout << answer << "\n";
}
Leave a Comment