malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   int main() {     int n;     cin >> n;     int a[100005];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     int inter = a[1] - a[0];     for (int i = 2; i < n; i++) {       inter = gcd(inter, a[i] - a[i - 1]);     }     int cnt = 0;     for (int i = 1; i < n; i++) {       cnt += (a[i] - a[i - 1]) / inter - 1;     }     printf( %d n , cnt);   }
#include <bits/stdc++.h>   using namespace std;   struct Meth {     int hud, ten;     void init(int hud, int ten) { this->hud = hud, this->ten = ten; }     bool operator==(const class Meth &ans) const {       return hud == ans.hud && ten == ans.ten;     }   };   bool cmpC(const struct Meth &ans1, const struct Meth &ans2) {     return ans1.hud > ans2.hud;   }   bool cmpH(const struct Meth &ans1, const struct Meth &ans2) {     return ans1.ten > ans2.ten;   }   struct Comb {     Meth ci, ha;     int chud, cten;     void init(Meth a, Meth b) {       ci.init(a.hud, a.ten), ha.init(b.hud, b.ten);       chud = ci.hud + ha.hud, cten = ci.ten + ha.ten;     }     bool operator<(const class Comb &ans) const {       return (cmpC(ci, ans.ci) || (ci == ans.ci && cmpH(ha, ans.ha)));     }   };   Meth mat[3];   Comb comb[9];   int cnt, cnthud, cntten;   void Prepare() {     for (int i = 0; i < 3; i++) mat[i].init(i, 22 - i * 10);     cnt = 0;     for (int i = 0; i < 3; i++)       for (int j = 0; j < 3; j++) comb[cnt++].init(mat[i], mat[j]);     sort(comb, comb + cnt);   }   int main() {     Prepare();     while (scanf( %d%d , &cnthud, &cntten) != EOF) {       for (int i = 0; i < cnt; i++) {         if (cnthud >= comb[i].chud && cntten >= comb[i].cten) {           int a = cntten / comb[i].cten;           if (comb[i].chud != 0) a = min(a, cnthud / comb[i].chud);           cnthud -= a * comb[i].chud, cntten -= a * comb[i].cten;         }       }       if (cnthud * 100 + cntten * 10 >= 220 && cntten >= 2) {         printf( Ciel n );       } else {         printf( Hanako n );       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   using namespace std;   const long long MOD = 1000000007;   const long long mod = 1000000007;   const int Nmax = 2000006;   long long gcd(long long a, long long b) {     if (a == 0) {       return b;     }     return gcd(b % a, a);   }   int lcm(int a, int b) { return (a * b) / gcd(a, b); }   bool isPrime(long long n) {     for (int i = 2; i <= sqrt(n); i++)       if (n % i == 0) return 0;     return 1;   }   void binaryRepresentation(int x) {     for (int i = 31; i >= 0; i--) {       if (x & (1 << i))         cout <<  1 ;       else         cout <<  0 ;     }   }   long long combination(long long n, long long r) {     if (r == n || r == 0) {       return 1LL;     }     return combination(n - 1, r - 1) + combination(n - 1, r);   }   bool isPowerOfTwo(long long n) {     if (n == 0) return false;     return (ceil(log2(n)) == floor(log2(n)));   }   long long power(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % MOD;       b /= 2;       a = (a * a) % MOD;     }     return ans % MOD;   }   long long inverse(long long i) {     if (i == 1) return 1;     return (MOD - ((MOD / i) * inverse(MOD % i)) % MOD + MOD) % MOD;   }   bool cmp(const pair<long long, long long> &a,            const pair<long long, long long> &b) {     if (a.first == b.first) return a.second < b.second;     return a.first < b.first;   }   string toString(long long a) {     ostringstream temp;     temp << a;     return temp.str();   }   int main() {     long long n, k;     cin >> n >> k;     long long ct = 1;     if (k == 1) {       cout << n;       return 0;     }     while (ct <= n) {       ct = ct * 2;     }     cout << ct - 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     scanf( %d%d , &n, &k);     char a[4][n];     for (int i = 0; i < 4; i++)       for (int j = 0; j < n; j++) a[i][j] =  . ;     if (!k) {       printf( YES n );       for (int i = 0; i < 4; i++) {         for (int j = 0; j < n; j++) printf( . );         printf(  n );       }       return 0;     }     if (k == 2 * (n - 2)) {       printf( YES n );       for (int i = 0; i < 4; i++) {         for (int j = 0; j < n; j++) {           if (i == 0 || i == 3 || j == 0 || j == n - 1)             printf( . );           else             printf( # );         }         printf(  n );       }       return 0;     }     if (k > 2 * (n - 2)) {       printf( NO n );       return 0;     } else       printf( YES n );     if (k % 2 == 0) {       for (int i = 1; i < 3 && k > 0; i++)         for (int j = 1; j < n / 2 && k > 0; j++) {           a[i][j] = a[i][n - j - 1] =  # ;           k -= 2;         }     } else {       for (int i = 1; i < 3 && k > 1; i++)         for (int j = 1; j < n / 2 && k > 1; j++) {           a[i][j] = a[i][n - j - 1] =  # ;           k -= 2;         }       a[1][n / 2] =  # ;     }     for (int i = 0; i < 4; i++) {       for (int j = 0; j < n; j++) printf( %c , a[i][j]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   int n;   struct camel {     int x, d;     inline bool operator<(const camel& a) const { return x < a.x; }   } c[105];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d%d , &c[i].x, &c[i].d);     std::sort(c, c + n);     for (int i = 0; i < n; i++)       for (int j = i; j < n; j++)         if ((c[i].x + c[i].d == c[j].x) && (c[j].x + c[j].d == c[i].x)) {           puts( YES );           return 0;         }     puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.);   const double eps = 1e-6;   int n, d;   int main() {     scanf( %d%d , &n, &d);     if (n == 1)       printf( %d n , d);     else {       if (d == 0) {         puts( No solution );       } else {         printf( %d , 1);         for (int i = 0; i < n - 2; i++) printf( %d , 0);         printf( %d n , d - 1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<pair<int, int> > ans;   int a[1000000];   int b[1000000];   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       cin >> b[i];     }     for (int i = 0; i < n; i++) {       if (b[i] == a[i])         continue;       else {         for (int j = i + 1; j < n; j++) {           if (b[j] == a[i]) {             for (int k = j; k > i; k--) {               swap(b[k], b[k - 1]);               ans.push_back(make_pair(k - 1, k));             }             break;           }         }       }     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) {       cout << ++ans[i].first <<     << ++ans[i].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int n;     cin >> n;     int a[n];     int sum = 0, ans = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     for (int i = 0; i < n; i++)       if (!((sum - a[i]) % 2)) ans++;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     ~debug() { cerr << endl; }     template <class c>     typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {       cerr << boolalpha << i;       return *this;     }     template <class c>     typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {       return *this << range(begin(i), end(i));     }     template <class c, class b>     debug& operator<<(pair<b, c> d) {       return *this <<  (  << d.first <<  ,   << d.second <<  ) ;     }     template <class c>     debug& operator<<(rge<c> d) {       *this <<  [ ;       for (auto it = d.b; it != d.e; ++it) *this <<  ,   + 2 * (it == d.b) << *it;       return *this <<  ] ;     }   };   const long long p = 1e9 + 7;   long long factmod(long long n) {     long long res = 1;     while (n > 1) {       res = (res * ((n / p) % 2 ? p - 1 : 1)) % p;       for (long long i = 2; i <= n % p; ++i) res = (res * i) % p;       n /= p;     }     return res % p;   }   long long binpow(long long a, long long b, long long m) {     a %= m;     long long res = 1;     while (b > 0) {       if (b & 1) res = res * a % m;       a = a * a % m;       b >>= 1;     }     return res;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n;     cin >> n;     cout << (factmod(n) + p - binpow(2, n - 1, p)) % p << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long iHateGeometry[100001];   int main() {     int N;     scanf( %d , &N);     long long maxi = -1, sum = 0;     for (int i = 0; i < N; i++) {       scanf( %lld , &iHateGeometry[i]);       sum += iHateGeometry[i];       maxi = max(maxi, iHateGeometry[i]);     }     printf( %lld n , 2 * maxi - sum + 1);   }
#include <bits/stdc++.h>   using namespace std;   long long a[3000005], has[3000005], visited[2000005], dist[1000005];   long long pr[3000010];   long long addmod(long long n, long long m) {     return ((n % 1000000007) + (m % 1000000007)) % 1000000007;   }   long long multmod(long long n, long long m) {     return ((n % 1000000007) * (m % 1000000007)) % 1000000007;   }   long long submod(long long n, long long m) {     return ((n % 1000000007) - (m % 1000000007) + 1000000007) % 1000000007;   }   void prime() {     pr[0] = 1;     pr[1] = 1;     for (long long i = 2; i <= sqrt(3000010); i++) {       for (long long j = 2 * i; j <= 3000010; j += i) {         pr[j] = 1;       }     }   }   long long cntDiv(long long n) {     long long cnt = 0;     for (long long i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         if (n / i == i)           cnt++;         else           cnt += 2;       }     }     return cnt;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long has1[3000011], b[1000005], temp1[1000005];   vector<long long> mat[10001];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long x, y, z, w;     cin >> x >> y >> z >> w;     if (x + y == z + w || x + z == y + w || x + w == y + z || x == y + z + w ||         y == x + z + w || z == x + y + w || w == x + y + z)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   using namespace std;   template <class T>   inline bool setmin(T &a, T b) {     if (a > b) return a = b, 1;     return 0;   }   template <class T>   inline bool setmax(T &a, T b) {     if (a < b) return a = b, 1;     return 0;   }   template <class T>   inline T fast(T a, T b, T mod) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   template <class T>   istream &operator>>(istream &os, vector<T> &container) {     for (auto &u : container) os >> u;     return os;   }   template <class T>   ostream &operator<<(ostream &os, const vector<T> &container) {     for (auto &u : container) os << u <<    ;     return os;   }   template <class T>   inline T gcd(T a, T b) {     while (b) swap(a %= b, b);     return a;   }   const long long INF = 1e9 + 7;   const long long mod = 100000007;   const long long BIG_INF = 1e18 + 7;   const long long N = 1e6 + 7;   const long long T = 1 << 20;   const long double inf = 1e18;   long long n, m, k, q;   int tree[T * 2];   int tree2[T * 2];   int ros[N];   int mal[N];   void add1(int pocz, int kon) {     pocz += T - 1;     kon += T + 1;     while (pocz / 2 != kon / 2) {       if (pocz % 2 == 0) tree[pocz + 1]++;       if (kon & 1) tree[kon - 1]++;       pocz /= 2;       kon /= 2;     }   }   int ask1(int poz) {     poz += T;     int ret = 0;     while (poz) {       ret += tree[poz];       poz /= 2;     }     return ret;   }   int ask2(int pocz, int kon) {     pocz += T - 1;     kon += T + 1;     int ret = 0;     while (pocz / 2 != kon / 2) {       if (pocz % 2 == 0) ret = max(ret, tree2[pocz + 1]);       if (kon & 1) ret = max(ret, tree2[kon - 1]);       pocz /= 2;       kon /= 2;     }     return ret;   }   void add2(int poz, int val) {     poz += T;     tree2[poz] = val;     poz /= 2;     while (poz) {       tree2[poz] = max(tree2[poz + poz], tree2[poz + poz + 1]);       poz /= 2;     }   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     add1(1, m);     for (int i = 0; i < (n); i++) {       int a, b;       cin >> a >> b;       add1(a, b);     }     for (int i = 1; i <= m; i++) {       ros[i] = ask2(1, ask1(i)) + 1;       add2(ask1(i), ros[i]);     }     for (int i = 0; i < (T * 2); i++) tree2[i] = 0;     int ans = 0;     for (int i = m; i >= 1; i--) {       mal[i] = ask2(1, ask1(i)) + 1;       add2(ask1(i), mal[i]);       ans = max(ans, ros[i] + mal[i] - 1);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int mod = 1e9 + 7;   const int sz = 1e5 + 10;   int main() {     ll k, b, n, t, z, ans, zz;     while (cin >> k >> b >> n >> t) {       z = 1;       ans = n;       for (int i = 0; i < n && z < t; i++) {         z = z * k + b;         ans--;       }       if (z > t) ans++;       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     char ch = getchar();     long long res = 0, pd = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) pd = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       res = (res << 1) + (res << 3) + ch -  0 ;       ch = getchar();     }     return res * pd;   }   inline void write(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) write(x / 10);     putchar(x % 10 |  0 );   }   inline void wlk(long long x) {     write(x);     putchar(32);   }   inline void wln(long long x) {     write(x);     putchar(10);   }   const long long maxn = 100003;   long long a[maxn];   signed main() {     long long n = read(), flag = 1;     for (long long i = 1; i <= n; ++i) a[i] = read();     for (long long i = 2; i <= n; ++i)       if (a[i] % a[1] != 0) flag = 0;     if (!flag) return puts( -1 ), 0;     wln(2 * n);     for (long long i = 1; i <= n; ++i) {       wlk(a[1]), wlk(a[i]);     }     return puts(  ), 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n;     cin >> n;     string s;     cin >> s;     long long int mid = n / 2;     long long int check = 0;     for (long long int i = 0; i < n; i++) {       if (s[i] ==  0 ) {         check = 1;         if (i >= mid) {           cout << 1 <<     << i + 1 <<     << 1 <<     << i << endl;           return;         } else {           cout << i + 2 <<     << n <<     << i + 1 <<     << n << endl;           return;         }       }     }     if (check == 0) {       cout << 1 <<     << n - 1 <<     << 2 <<     << n << endl;     }   }   int32_t main() {     long long int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void sol_problem(const long *, long);   int main() {     long n, t, *matriz;     cin >> n >> t;     matriz = new long[n - 1];     for (int i = 0; i < n - 1; i++) cin >> matriz[i];     sol_problem(matriz, t);     return 0;   }   void sol_problem(const long *matriz, long t) {     long ind = 1 + matriz[0];     while (ind <= t) {       if (ind == t) {         cout <<  YES ;         break;       }       ind += matriz[ind - 1];     }     if (ind > t) cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   long long mod = (1e9 + 7);   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }   bool is_vowel(char c) {     if (c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u ) return 1;     return 0;   }   double getDistance(double x1, double y1, double x2, double y2) {     return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));   }   long long extended_euclidean(long long a, long long b, long long &x,                                long long &y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     long long g = extended_euclidean(b, a % b, y, x);     y -= (a / b) * x;     return g;   }   long long power(long long base, long long p) {     if (p == 1) return base;     if (!p) return 1ll;     long long ret = power(base, p / 2);     ret *= ret;     ret %= mod;     if (p & 1) ret *= base;     return ret % mod;   }   vector<int> v;   map<int, int> mp;   int n;   int solve(long long sum, long long a, long long b, long long c) {     v.clear();     int mn = n, A = 0, B = 0, C = 0;     for (int i = (0); i <= (n); ++i) {       long long cur = sum - a * i;       int cost = min(i, mp[a]);       long long mx = c * (n - i);       int taken2 = n - i;       int taken1 = 0;       if (mx > cur) {         long long delta = mx - cur;         taken2 -= delta;         taken1 += delta;         mx = cur;       }       if (mx == cur && taken1 + taken2 == n - i && taken1 >= 0 && taken2 >= 0) {         cost += min(mp[b], taken1);         cost += min(mp[c], taken2);         mn = min(mn, cost);         if (mn == cost) {           A = i;           B = taken1;           C = taken2;         }       }     }     while (A--) v.push_back(a);     while (B--) v.push_back(b);     while (C--) v.push_back(c);     return mn;   }   int main() {     scanf( %d , &n);     set<long long> st;     long long sum = 0;     vector<int> z;     for (int i = (0); i <= (n - 1); ++i) {       int a;       scanf( %d , &a);       st.insert(a);       mp[a]++;       sum += a;       z.push_back(a);     }     vector<long long> x(st.begin(), st.end());     long long mn = *(st.begin());     long long mx = *(--st.end());     int sol = n;     if (abs(mn - mx) < 2) {       cout << n << endl;       for (int i = (0); i <= (n - 1); ++i) {         cout << z[i] <<    ;       }       return 0;     }     sol = solve(sum, mn, mn + 1, mn + 2);     cout << sol << endl;     for (int i = (0); i <= (n - 1); ++i) cout << v[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fail(string s) {     cout << s;     exit(0);   }   void fail(int s) {     cout << s;     exit(0);   }   int n;   int x[5005], y[5005];   int d[5005];   vector<int> v[5005];   int len(int a, int b) { return abs(x[a] - x[b]) + abs(y[a] - y[b]); }   int ok = 0;   void dfs(int u, int dep, int mid) {     d[u] = dep;     for (int i = (0); i < (n); i++)       if (len(u, i) > mid) {         if (!d[i])           dfs(i, dep + 1, mid);         else if (d[i] > 0) {           if ((d[i] - d[u]) % 2 == 0) ok = 1;         }       }     d[u] = -1;   }   int chk(int num) {     ok = 0;     for (int i = (0); i < (n); i++) d[i] = 0;     int ans = 1;     for (int i = (0); i < (n); i++) {       if (!d[i]) {         ans = ans * 2 % 1000000007;         dfs(i, 1, num);         if (ok) return 0;       }     }     return ans;   }   signed main() {     cin >> n;     for (int i = (0); i < (n); i++) {       cin >> x[i] >> y[i];     }     int ans = -1, can = 0;     int l = 0, r = 1000000, mid;     while (l < r) {       int mid = (l + r) / 2;       int p = chk(mid);       if (p)         ans = mid, can = p, r = mid;       else         l = mid + 1;     }     cout << ans <<   n  << can <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool ask(int a, int b, int c, int d) {     cout <<  ?   << a <<     << b <<     << c <<     << d << endl;     fflush(stdout);     string response;     cin >> response;     if (response ==  BAD ) {       exit(0);     } else if (response ==  YES )       return true;     else       return false;   }   int main() {     int n;     cin >> n;     int x = 1, y = 1;     string ans1 =   , ans2 =   ;     for (int i = 0; i < n - 1; ++i) {       if (ask(x + 1, y, n, n)) {         x++;         ans1.push_back( D );       } else {         y++;         ans1.push_back( R );       }     }     x = n, y = n;     for (int i = 0; i < n - 1; ++i) {       if (ask(1, 1, x, y - 1)) {         y--;         ans2.push_back( R );       } else {         x--;         ans2.push_back( D );       }     }     reverse((ans2).begin(), (ans2).end());     string finalans = ans1 + ans2;     cout <<  !   << finalans << endl;     fflush(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     scanf( %d , &a);     string ans =  NO ;     for (int i = 0; i < a; i++) {       string name;       int bef, aft;       cin >> name;       scanf( %d %d , &bef, &aft);       if (bef >= 2400 && aft > bef) {         ans =  YES ;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, t1, p;   int b[200000], h[200000];   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> b[i];       if (!b[i]) {         --i;         --n;       }     }     for (int i = 0; i < n; i++) {       cin >> h[i];       if (h[i] == b[0]) p = i;       if (!h[i]) --i;     }     for (int i = 0; i < n; i++) {       if (b[i] != h[(p + i) % (n)]) {         cout <<  NO  << endl;         exit(0);       }     }     cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-11;   double memo[105][105][105];   double dp(int R, int S, int P) {     if (R == 0) return 0;     if (S + P == 0) return 1;     double& ret = memo[R][S][P];     if (memo[R][S][P] >= 0) return ret;     ret = 0;     if (R && S) ret += dp(R, S - 1, P) * R * S;     if (S && P) ret += dp(R, S, P - 1) * S * P;     if (R && P) ret += dp(R - 1, S, P) * R * P;     ret /= (R * S + S * P + R * P);     return ret;   }   int main() {     std::ios_base::sync_with_stdio(0);     int x, y, z;     for (int x = 0; x < 105; x++)       for (int y = 0; y < 105; y++)         for (int i = 0; i < 105; i++) memo[x][y][i] = -1;     cin >> x >> y >> z;     cout << fixed;     cout << setprecision(10);     cout << dp(x, y, z) <<     << dp(y, z, x) <<     << dp(z, x, y) << endl;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 500000 + 10;   int n;   vector<int> li;   struct node {     int x, y;   } p[maxn];   bool cmp1(node a, node b) { return a.x < b.x; }   bool cmp2(node a, node b) { return a.y < b.y; }   long long vis[maxn], ans;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &p[i].x, &p[i].y);       li.push_back(p[i].x), li.push_back(p[i].y);     }     sort(li.begin(), li.end());     li.erase(unique(li.begin(), li.end()), li.end());     for (int i = 1; i <= n; i++) {       p[i].x = lower_bound(li.begin(), li.end(), p[i].x) - li.begin();       p[i].y = lower_bound(li.begin(), li.end(), p[i].y) - li.begin();     }     sort(p + 1, p + n + 1, cmp1);     int st = 1, ed = 1;     long long num = 0ll;     for (; ed <= n; ed++) {       if (p[ed].x == p[st].x) {         vis[p[ed].y]++, num++;       } else {         ans += ((num - 1) * num / 2ll);         for (int i = st; i < ed; i++) {           if (vis[p[i].y]) {             ans -= ((vis[p[i].y] - 1) * vis[p[i].y] / 2ll), vis[p[i].y] = 0;           }         }         st = ed, num = 1ll;         vis[p[ed].y] = 1;       }     }     if (num) {       ans += ((num - 1) * num / 2ll);       for (int i = st; i <= n; i++) {         if (vis[p[i].y]) {           ans -= ((vis[p[i].y] - 1) * vis[p[i].y] / 2ll), vis[p[i].y] = 0;         }       }     }     sort(p + 1, p + n + 1, cmp2);     st = 1, ed = 1, num = 0ll;     for (; ed <= n; ed++) {       if (p[ed].y == p[st].y)         num++;       else {         ans += ((num - 1) * num / 2ll);         st = ed, num = 1ll;       }     }     if (num) ans += ((num - 1) * num / 2ll);     printf( %I64d n , ans);     return 0;   }