Untitled
user_5668965
c_cpp
a year ago
544 B
20
Indexable
#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";
}Editor is loading...
Leave a Comment