#pragma GCC optimize("Ofast")
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <stack>
using namespace std;
// #define int long long
#define ll long long
#define pb push_back
#define popb pop_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define sc second
const int mod = 1e9 + 7;
const int inf = 1e7;
const int MAXN = 2 * 1e5;
void solve() {
int n;
cin >> n;
vector<pii> vec;
map<int, int> mp1;
map<int, int> mp2;
while(n--) {
int x, y;
cin >> x >> y;
vec.pb({x, y});
mp1[x]++;
mp2[y]++;
}
int ans = 0;
for(int i = 0; i < vec.size(); i++) {
ans += (mp1[vec[i].ff] - 1) * (mp2[vec[i].sc] - 1);
}
cout << ans;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int t = 1;
//cin >> t;
while(t--) {
solve();
cout << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |