#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main(){
int n; cin>>n;
map<ll, pair<ll, ll>> mp;
ll a[n+1], b[n+1];
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
ll x=a[i], y=b[i];
if(!mp.count(x)) mp[x].first=1, mp[x].second=0;
else mp[x].first++;
if(!mp.count(y)) mp[y].first=0, mp[y].second=1;
else mp[y].second++;
}
ll ans=0;
for(int i=1;i<=n;i++){
ll x=a[i], y=b[i];
ll xx=mp[y].second-1, yy=mp[x].first-1;
ans+=xx*yy;
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |