#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
const int MAX = 3e5 + 2;
pair<int, int> a[MAX];
int n;
void solve() {
cin >> n;
map<int, int> mp1, mp2;
for (int i = 1; i <= n; i++) {
cin >> a[i].first >> a[i].second;
mp1[a[i].first]++;
mp2[a[i].second]++;
}
ll res = 0;
for (int i = 1; i <= n; i++) {
res += 1LL * (mp1[a[i].first] - 1) * (mp2[a[i].second] - 1);
}
cout << res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |