#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
template <class X, class Y>
    bool maximize(X &x, Y y) {
        if (x < y) return x = y, true;
        else return false;
    }
template <class X, class Y>
    bool minimize(X &x, Y y) {
        if (x > y) return x = y, true;
        else return false;
    }
template <class T>
    void compress(T &v) {
        sort(v.begin(),v.end());
        v.resize(unique(v.begin() , v.end()) - v.begin());
    }
template <class T1, class T2>
    int Find(const vector <T1> &v, T2 x) {
        return upper_bound(v.begin(),v.end(), x) - v.begin();
    }
#define sz(x) (int)(x).size()
#define debug(x) cout << #x << " = " << (x) << endl;
/*
···········································································································································································································································
:                                                                                                                                                                                                                                         :
:      _ ___                                     _              _ _      _                             _              _     _                         _       _                               _                                          :
:     | |/ / |__   ___  _ __   __ _   ___  ___   | | _____    __| (_) ___| |__    _ __ ___   __ _ _ __ | |__       ___| |__ (_)  ___  ___    _ __ ___ (_)_ __ | |__     __ _ _   _  __ _    __| | __ _ _ __   __ _    ___ __ _ _ __       :
:     | ' /| '_ \ / _ \| '_ \ / _` | / __|/ _ \  | |/ / _ \  / _` | |/ __| '_ \  | '_ ` _ \ / _` | '_ \| '_ \     / __| '_ \| | / __|/ _ \  | '_ ` _ \| | '_ \| '_ \   / _` | | | |/ _` |  / _` |/ _` | '_ \ / _` |  / __/ _` | '_ \      :
:     | . \| | | | (_) | | | | (_| | \__ \ (_) | |   <  __/ | (_| | | (__| | | | | | | | | | (_| | | | | | | |_  | (__| | | | | \__ \ (_) | | | | | | | | | | | | | | | (_| | |_| | (_| | | (_| | (_| | | | | (_| | | (_| (_| | |_) |     :
:     |_|\_\_| |_|\___/|_| |_|\__, | |___/\___/  |_|\_\___|  \__,_|_|\___|_| |_| |_| |_| |_|\__,_|_| |_|_| |_( )  \___|_| |_|_| |___/\___/  |_| |_| |_|_|_| |_|_| |_|  \__, |\__,_|\__,_|  \__,_|\__,_|_| |_|\__, |  \___\__,_| .__/      :
:                             |___/                                                                          |/                                                           |_|                                |___/            |_|         :
:                                                                                                                                                                                                                                         :
···········································································································································································································································
*/
const int N = (int) 3e5;
int x[N + 2] , y[N + 2];
int n;
map<int,int> dem1,dem2;
map<pair<int,int>,int> cnt;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    vector<pair<int,int>> v;
    for(int i = 1; i <= n; ++i){
        cin >> x[i] >> y[i];
        v.push_back({x[i] , y[i]});
        
        dem1[x[i]]++ , dem2[y[i]]++;
        cnt[{x[i] , y[i]}]++;
    }
    compress(v);
    LL ans = 0;
    for(auto& x : v) {
        pair<int,int> t = x;
        ans += (dem1[x.first] - cnt[x]) * (dem2[x.second] - cnt[x]) * cnt[x];
    }
    cout << ans;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |