#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<pair<int,int>>v(n);
for(int i=0; i<n; i++){
int j,k;
cin>>j>>k;
pair<int,int>p={j,k};
v[i]=p;
}
long long ans=0;
sort(v.begin(),v.end());
for(int i=0; i<v.size(); i++){
for(int j=0; j<v.size(); j++){
if(v[j].first==v[i].first && j!=i){
for(int t=0; t<v.size(); t++){
if(t!=i && t!=j){
if(v[t].second==v[i].second ){
ans++;
}
if(v[t].second==v[j].second)ans++;
}
}
}
}
}
cout<<ans/2<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |