malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   string c =  abacaba ;   int f(string str) {     int cnt = 0;     for (int i = 0; i < str.size(); i++) {       if (c.size() > str.size() - i) {         break;       }       if (c == str.substr(i, c.size())) cnt++;     }     return cnt;   }   bool f1(string str) {     for (int i = 0; i < str.size(); i++) {       if (str[i] != c[i] && str[i] !=  ? ) return 0;     }     return 1;   }   int main() {     int t;     cin >> t;     while (t--) {       int n;       string s;       cin >> n >> s;       if (f(s) > 1) {         cout <<  No n ;         continue;       }       int cnt = 0;       string ans =   ;       for (int i = 0; i < s.size(); i++) {         if (c.size() > s.size() - i) {           break;         }         if (f1(s.substr(i, c.size()))) {           string temp = s.substr(0, i) + c + s.substr(i + c.size());           if (f(temp) == 1) {             ans = s.substr(0, i) + c + s.substr(i + c.size());             break;           }         }       }       if (ans ==   ) {         cout <<  No n ;       } else {         cout <<  Yes n ;         for (int i = 0; i < ans.size(); i++) {           if (ans[i] ==  ? ) ans[i] =  z ;           cout << ans[i];         }         cout <<   n ;       }     }   }
#include <bits/stdc++.h>   long long n;   int main() {     scanf( %lld , &n);     printf( %lld n , n - n / 2 - n / 3 - n / 5 - n / 7 + n / 6 + n / 10 + n / 14 +                          n / 15 + n / 21 + n / 35 - n / 30 - n / 42 - n / 70 -                          n / 105 + n / 210);   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   std::pair<T, U> operator+(const std::pair<T, U>& l, const std::pair<T, U>& r) {     return {l.first + r.first, l.second + r.second};   }   typedef void (*callback_function)(void);   const long long ZERO = 0LL;   const long long INF64 = 1e18;   const long long INF32 = 1e9;   const long long MOD = 1e9 + 7;   const long double PI = acos(-1.0L);   const long double EPS = static_cast<long double>(1e-9);   inline long long Pow(long long a, long long k) {     long long s = 1;     for (; k; k >>= 1) {       k& 1 ? s = 1LL * s * a % MOD : 0;       a = 1LL * a * a % MOD;     }     return s;   }   const long long N = 1e6 + 7;   void input() {}   void output() {}   void preprocess() {}   void debug() {     if (true) {     }   }   void solve() {     preprocess();     long long n;     cin >> n;     long long a[n];     for (long long i = (0); i < (n); i++) {       cin >> a[i];     }     long long L = 0, R = n - 1, res = 0;     while (L < R) {       while (L < R and a[L] < a[L + 1]) {         L++;       }       while (L < R and a[R] < a[R - 1]) {         R--;       }       if (L == R) {         break;       }       if (a[L] < a[R]) {         long long b = a[L] + 1;         res += b - a[L + 1];         a[L + 1] = b;       } else {         long long b = a[R] + 1;         res += b - a[R - 1];         a[R - 1] = b;       }     }     cout << res << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie();     {       input();       solve();       output();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   const int N = 505;   int fac[N], inv_fac[N];   int mod_pow(int b, int p) {     int ans = 1;     while (p) {       if (p & 1) {         ans = (1ll * ans * b) % mod;         p--;       }       b = (1ll * b * b) % mod;       p /= 2;     }     return ans;   }   void calc_fac() {     fac[0] = 1;     inv_fac[0] = 1;     for (int i = 1; i < N; i++) {       fac[i] = (1ll * fac[i - 1] * i) % mod;       inv_fac[i] = mod_pow(fac[i], mod - 2);     }   }   int nCr(int n, int r) {     if (r > n) {       return 0;     }     return 1ll * fac[n] * inv_fac[n - r] % mod * inv_fac[r] % mod;   }   void solve() {     int n, k;     cin >> n >> k;     vector<vector<int>> POW(k + 5, vector<int>(n + 5));     for (int i = 1; i < k + 5; i++) {       POW[i][0] = 1;       for (int j = 1; j < n + 5; j++) {         POW[i][j] = 1ll * POW[i][j - 1] * i % mod;       }     }     vector<vector<int>> dp(n + 5, vector<int>(k + 5));     for (int initial_alive = 2; initial_alive < n + 5; initial_alive++) {       for (int limit = 1; limit < k + 5; limit++) {         if (limit < initial_alive) {           dp[initial_alive][limit] = POW[limit][initial_alive];         } else {           dp[initial_alive][limit] = POW[initial_alive - 1][initial_alive];           for (int alive = 1; alive <= initial_alive; alive++) {             int killed = initial_alive - alive;             dp[initial_alive][limit] =                 (0ll + dp[initial_alive][limit] +                  1ll * dp[alive][limit - (initial_alive - 1)] *                      nCr(initial_alive, killed) % mod *                      POW[initial_alive - 1][killed] % mod) %                 mod;           }         }       }     }     cout << dp[n][k] <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     calc_fac();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1100;   long long x, y;   int n;   int main() {     std::ios::sync_with_stdio(false);     while (cin >> n) {       long long x1, x2, y1, y2;       x1 = y1 = 1000000000;       x2 = y2 = -1000000000;       for (int i = 0; i < n; ++i) {         cin >> x >> y;         if (x < x1) x1 = x;         if (y < y1) y1 = y;         if (x > x2) x2 = x;         if (y > y2) y2 = y;       }       unsigned long long s = max(abs(x2 - x1), abs(y2 - y1));       cout << s * s << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 40;   const int inf = 0x3fffffff;   void read(int &x) {     char ch;     bool flag = 0;     for (ch = getchar(); !isdigit(ch) && ((flag |= (ch ==  - )) || 1);          ch = getchar())       ;     for (x = 0; isdigit(ch); x = (x << 1) + (x << 3) + ch - 48, ch = getchar())       ;     x *= 1 - 2 * flag;   }   char mp[4][105];   int n, m;   bool ans = 1;   bool check(int time, int x, int y) {     y += 2 * time;     if (y >= n || mp[x][y] ==  . ) return true;     return false;   }   int vis[5][105];   void dfs(int x, int y) {     if (vis[x][y]) return;     vis[x][y] = 1;     if (y == n - 1) {       ans = 0;       return;     }     if (!check(y, x, y + 1)) return;     for (int i = x - 1; i <= x + 1; i++) {       if (i < 0 || i >= 3) continue;       if (check(y, i, y + 1) && check(y + 1, i, y + 1)) dfs(i, y + 1);     }   }   int main() {     int t;     read(t);     while (t--) {       ans = 1;       memset(vis, 0, sizeof(vis));       read(n), read(m);       int st = -1;       ans = 1;       for (int i = 0; i < 3; i++) {         cin >> mp[i];         for (int j = 0; j < m; j++) {           if (mp[i][j] ==  s ) {             st = i;           }         }       }       mp[st][0] =  . ;       dfs(st, 0);       if (ans)         puts( NO );       else         puts( YES );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d, h;   struct edge {     int n1;     int n2;   };   edge vertices[100000];   int main() {     cin >> n >> d >> h;     if (d > 2 * h || (h == 1 && d == 1 && n > 2))       cout <<  -1  << endl;     else {       int idx = 0;       int usedNode = 1;       for (int i = 0; i < h; i++) {         vertices[idx++] = edge{usedNode - 1, usedNode++};       }       if (d > h) {         vertices[idx++] = edge{0, usedNode++};         for (int i = 1; i < (d - h); i++) {           vertices[idx++] = edge{usedNode - 1, usedNode++};         }       }       int start = (h > 1) ? 1 : 0;       for (int i = h + (d - h); i < n - 1; i++) {         vertices[idx++] = edge{start, usedNode++};       }       for (int i = 0; i < n - 1; i++) {         cout << vertices[i].n1 + 1 <<     << vertices[i].n2 + 1 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   stack<char> st;   string s, ans =   ;   char mn[111111];   long long n;   int main() {     cin >> s;     n = s.size();     mn[n - 1] = s[n - 1];     for (int i = n - 2; i >= 0; i--) {       mn[i] = min(mn[i + 1], s[i]);     }     for (int i = 0; i < n;) {       if (st.empty()) {         st.push(s[i]);         i++;       } else if (st.top() <= mn[i]) {         ans += st.top();         st.pop();       } else {         st.push(s[i]);         i++;       }     }     while (!st.empty()) {       ans += st.top();       st.pop();     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long full, n, k, x, i, ans, a[100001], b[100001];   void f(long long l, long long r, long long d) {     if (l > r) return;     if (l == 0)       ans += r / d + 1;     else       ans += (r / d) - (l - 1) / d;   }   int main() {     cin >> n >> k;     for (i = 1; i <= n / k; i++) {       cin >> a[i];     }     x = 1;     for (i = 1; i < k; i++) x *= 10;     for (i = 1; i <= n / k; i++) {       cin >> b[i];     }     full = 1;     for (i = 1; i <= n / k; i++) {       ans = 0;       f(0, b[i] * x - 1, a[i]);       f((b[i] + 1) * x, 10 * x - 1, a[i]);       full = ans * full % 1000000007;     }     cout << full;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n, m;     cin >> n >> m;     bool aOk = true, bOk = true;     vector<vector<int>> a(n, vector<int>(m)), b(n, vector<int>(m));     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> b[i][j];         int t1 = a[i][j], t2 = b[i][j];         a[i][j] = min(t1, t2);         b[i][j] = max(t1, t2);         if ((i - 1) >= 0) {           if (b[i][j] <= b[i - 1][j]) bOk = false;           if (a[i][j] <= a[i - 1][j]) aOk = false;         }         if ((j - 1) >= 0) {           if (b[i][j] <= b[i][j - 1]) bOk = false;           if (a[i][j] <= a[i][j - 1]) aOk = false;         }       }     }     if (aOk and bOk)       cout <<  Possible n ;     else       cout <<  Impossible n ;   }
#include <bits/stdc++.h>   using namespace std;   int dp[111111];   int main() {     int n, m;     cin >> n >> m;     vector<int> a;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       a.push_back(x);     }     reverse(a.begin(), a.end());     set<int> b;     for (int i = 0; i < n; i++) {       if (b.find(a[i]) == b.end()) dp[n - i - 1]++;       if (i == n - 1) break;       dp[n - i - 2] = dp[n - i - 1];       b.insert(a[i]);     }     for (int i = 0; i < m; i++) {       int x;       cin >> x;       cout << dp[x - 1] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long n;     while (scanf( %ld , &n) != EOF) {       int a, b, c1 = 0, c2 = 0, s1 = 0, s2 = 0, i, r;       long x = 100000000;       for (i = 0; i < n; i++) {         scanf( %d%d , &a, &b);         if (a == 0)           c1++;         else           c2++;         if (b == 0)           s1++;         else           s2++;       }       r = c2;       r = r + s1;       if (r < x) x = r;       r = c1;       r = r + s2;       if (r < x) x = r;       r = c2 + s2;       if (r < x) x = r;       r = c1 + s1;       if (r < x) x = r;       printf( %ld n , x);     }     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996 4018)   using namespace std;   int n, mod = 1000000007;   long long arr[1001], cost[1001];   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> arr[i];     long long ans = 0;     for (int i = 1; i <= n; i++) {       for (int e = arr[i]; e != i; e++) cost[i] = (cost[i] + cost[e]) % mod;       cost[i] = (cost[i] + 2) % mod;       ans = (ans + cost[i]) % mod;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<double, double> p[100100];   double d[100100];   double dist(pair<double, double> x, pair<double, double> y) {     double val = pow((x.first - y.first) * (x.first - y.first) +                          (x.second - y.second) * (x.second - y.second),                      0.5);     return val;   }   int main() {     pair<double, double> a, b, t;     cin >> a.first >> a.second >> b.first >> b.second >> t.first >> t.second;     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;     double ans = 0.0;     for (int i = 0; i < n; i++) {       d[i] = dist(t, p[i]);       ans += d[i];     }     double val = 100000000000000000;     double ma1 = 0, ma2 = 0, mb1 = 0, mb2 = 0;     int ia1 = -1, ia2 = -1, ib1 = -1, ib2 = -1;     for (int i = 0; i < n; i++) {       val = min(val, 2 * ans + dist(a, p[i]) - d[i]);       if (ma2 < d[i] - dist(a, p[i])) ma2 = d[i] - dist(a, p[i]), ia2 = i;       if (ma1 < ma2) swap(ma1, ma2), swap(ia1, ia2);     }     for (int i = 0; i < n; i++) {       val = min(val, 2 * ans + dist(b, p[i]) - d[i]);       if (mb2 < d[i] - dist(b, p[i])) mb2 = d[i] - dist(b, p[i]), ib2 = i;       if (mb1 < mb2) swap(mb1, mb2), swap(ib1, ib2);     }     if (ia1 != ib1 && ia1 != -1 && ib1 != -1) val = min(val, 2 * ans - ma1 - mb1);     if (ia1 != ib2 && ia1 != -1 && ib2 != -1) val = min(val, 2 * ans - ma1 - mb2);     if (ia2 != ib1 && ia2 != -1 && ib1 != -1) val = min(val, 2 * ans - ma2 - mb1);     if (ia2 != ib2 && ia2 != -1 && ib2 != -1) val = min(val, 2 * ans - ma2 - mb2);     printf( %0.14lf , val);   }
#include <bits/stdc++.h>   using namespace std;   int n, p, p1, p2;   char s[201];   int pd(char c) {     if ((c >=  0  && c <=  9 ) || (c >=  A  && c <=  Z ) ||         (c >=  a  && c <=  z ) || (c ==  _ ))       return 1;     return 0;   }   int main() {     cin >> s;     n = strlen(s);     if (n > 70) {       cout <<  NO  << endl;       return 0;     }     while (p < n && s[p] !=  @ ) p++;     if (p == n) {       cout <<  NO  << endl;       return 0;     }     if (p < 1 || p > 16) {       cout <<  NO  << endl;       return 0;     }     for (int i = 0; i < p; i++) {       if (!pd(s[i])) {         cout <<  NO  << endl;         return 0;       }     }     p1 = p + 1;     while (p < n && s[p] !=  / ) p++;     if (p - p1 < 1 || p - p1 > 32) {       cout <<  NO  << endl;       return 0;     }     for (int i = p1; i < p; i++) {       if (s[i] ==  . ) {         if (p2 < 1 || p2 > 16) {           cout <<  NO  << endl;           return 0;         }         p2 = 0;       } else {         if (!pd(s[i])) {           cout <<  NO  << endl;           return 0;         }         p2++;       }     }     if (p2 < 1 || p2 > 16) {       cout <<  NO  << endl;       return 0;     }     if (p < n) {       p2 = 0;       for (int i = p + 1; i < n; i++) {         if (s[i] ==  / ) {           if (p2 < 1 || p2 > 16) {             cout <<  NO  << endl;             return 0;           }           p2 = 0;         } else {           if (!pd(s[i])) {             cout <<  NO  << endl;             return 0;           }           p2++;         }       }       if (p2 < 1 || p2 > 16) {         cout <<  NO  << endl;         return 0;       }     }     cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long first[60];   void do_it(long long n2, long long k2, long long x) {     if (n2 == 1) {       cout << x + 1;       return;     }     if (n2 == 2) {       if (k2 == 1)         cout << x + 2 <<     << x + 1;       else         cout << x + 1 <<     << x + 2;       return;     }     if (k2 < first[n2 - 1]) {       cout << x + 1 <<    ;       do_it(n2 - 1, k2, x + 1);     } else {       k2 -= first[n2 - 1];       cout << x + 2 <<     << x + 1 <<    ;       do_it(n2 - 2, k2, x + 2);     }   }   long long n, k;   int main() {     first[0] = 1, first[1] = 1;     for (long long i = (2); i < (60); i++) first[i] = first[i - 1] + first[i - 2];     cin >> n >> k;     k--;     do_it(n, k, 0);   }
#include <bits/stdc++.h>   using namespace std;   struct E {     int a, b, c;   };   struct unionfind {     vector<int> p, s;     int c;     unionfind(int n) : p(n, -1), s(n, 1), c(n) {}     int find(int a) { return p[a] == -1 ? a : find(p[a]); }     vector<pair<int *, int>> buf;     void save(int &a) { buf.emplace_back(&a, a); }     int snapshot() { return buf.size(); }     void rollback(int w) {       while (buf.size() > w) {         int *a, b;         tie(a, b) = buf.back();         buf.pop_back();         *a = b;       }     }     bool unite(int a, int b) {       a = find(a);       b = find(b);       if (a == b) return false;       if (s[a] < s[b]) swap(a, b);       save(p[b]);       save(s[a]);       p[b] = a;       s[a] += s[b];       return true;     }     bool same(int a, int b) { return find(a) == find(b); }     int sz(int a) { return s[find(a)]; }   };   int main() {     cin.tie(0);     ios::sync_with_stdio(0);     int n, m;     cin >> n >> m;     vector<E> raw(m);     map<int, vector<pair<int, int>>> es;     for (int i = 0; i < m; ++i) {       int a, b, c;       cin >> a >> b >> c;       a--;       b--;       es[c].push_back({a, b});       raw[i] = {a, b, c};     }     map<int, vector<pair<int, vector<int>>>> qs;     int q;     cin >> q;     vector<int> ans(q, 1);     for (int i = 0; i < q; ++i) {       int k;       cin >> k;       vector<int> idx(k);       for (int j = 0; j < k; ++j) {         cin >> idx[j];         idx[j]--;       }       sort(idx.begin(), idx.end(),            [&](int a, int b) { return raw[a].c < raw[b].c; });       for (int j = 0; j < k;) {         vector<int> w;         int r = j;         while (r < k && raw[idx[r]].c == raw[idx[j]].c) {           w.push_back(idx[r++]);         }         qs[raw[idx[j]].c].emplace_back(i, w);         j = r;       }     }     unionfind uf(n);     for (auto kv : es) {       for (auto z : qs[kv.first]) {         int s = uf.snapshot();         for (auto i : z.second) {           if (!uf.unite(raw[i].a, raw[i].b)) {             ans[z.first] = 0;           }         }         uf.rollback(s);       }       for (auto e : kv.second) {         uf.unite(e.first, e.second);       }     }     for (int i = 0; i < q; ++i) {       if (ans[i])         cout <<  YES               <<   n ;       else         cout <<  NO               <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, o, z, t;     o = z = t = 0;     cin >> n;     string s;     cin >> s;     for (int i = 0; i < n; i++) {       if (s[i] ==  0 )         z++;       else if (s[i] ==  1 )         o++;       else         t++;     }     for (int i = 0; i < n && z < n / 3; i++) {       if (s[i] ==  1  && o > n / 3) {         s[i] =  0 ;         z++;         o--;       } else if (s[i] ==  2  && t > n / 3) {         s[i] =  0 ;         z++;         t--;       }     }     for (int i = 0; i < n && o < n / 3; i++) {       if (s[i] ==  2  && t > n / 3) {         s[i] =  1 ;         o++;         t--;       }     }     for (int i = n - 1; i >= 0 && t < n / 3; i--) {       if (s[i] ==  0  && z > n / 3) {         s[i] =  2 ;         t++;         z--;       } else if (s[i] ==  1  && o > n / 3) {         s[i] =  2 ;         t++;         o--;       }     }     for (int i = n - 1; i >= 0 && o < n / 3; i--) {       if (s[i] ==  0  && z > n / 3) {         s[i] =  1 ;         o++;         z--;       }     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std::chrono;   long long MOD = 1000000007;   struct mi {     long long v;     explicit operator long long() const { return v; }     mi() { v = 0; }     mi(long long _v) {       v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;       if (v < 0) v += MOD;     }     friend bool operator==(const mi &a, const mi &b) { return a.v == b.v; }     friend bool operator!=(const mi &a, const mi &b) { return !(a == b); }     friend bool operator<(const mi &a, const mi &b) { return a.v < b.v; }     mi &operator+=(const mi &m) {       if ((v += m.v) >= MOD) v -= MOD;       return *this;     }     mi &operator-=(const mi &m) {       if ((v -= m.v) < 0) v += MOD;       return *this;     }     mi &operator*=(const mi &m) {       v = v * m.v % MOD;       return *this;     }     mi &operator/=(const mi &m) { return (*this) *= inv(m); }     friend mi pow(mi a, long long p) {       mi ans = 1;       assert(p >= 0);       for (; p; p /= 2, a *= a)         if (p & 1) ans *= a;       return ans;     }     friend mi inv(const mi &a) {       assert(a.v != 0);       return pow(a, MOD - 2);     }     mi operator-() const { return mi(-v); }     mi &operator++() { return *this += 1; }     mi &operator--() { return *this -= 1; }     mi operator++(int) {       mi temp;       temp.v = v++;       return temp;     }     mi operator--(int) {       mi temp;       temp.v = v--;       return temp;     }     friend mi operator+(mi a, const mi &b) { return a += b; }     friend mi operator-(mi a, const mi &b) { return a -= b; }     friend mi operator*(mi a, const mi &b) { return a *= b; }     friend mi operator/(mi a, const mi &b) { return a /= b; }     friend ostream &operator<<(ostream &os, const mi &m) {       os << m.v;       return os;     }     friend istream &operator>>(istream &is, mi &m) {       long long x;       is >> x;       m.v = x;       return is;     }   };   void solve() {     long long n;     cin >> n;     long long m;     cin >> m;     MOD = m;     vector<mi> dp(n + 1, 0);     vector<mi> suffix(n + 2, 0);     dp[n] = 1;     suffix[n] = 1;     mi sum = 0;     for (long long i = (n)-1; i >= 1; i--) {       sum = sum + dp[i + 1];       dp[i] = sum;       for (long long j = 2; j < (n + 1); j++) {         if (i * j > n)           break;         else {           mi sf = suffix[i * j] - suffix[min(i * j + j, n + 1)];           dp[i] = dp[i] + sf;         }       }       suffix[i] = suffix[i + 1] + dp[i];     }     cout << dp[1] << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, m, k;       cin >> n >> m >> k;       vector<int> lx(n), ly(m);       vector<int> x(k), y(k);       for (int& i : lx) cin >> i;       for (int& i : ly) cin >> i;       for (int i = 0; i < k; i++) {         cin >> x[i] >> y[i];       }       sort(lx.begin(), lx.end()), sort(ly.begin(), ly.end());       vector<int> ind(k);       iota(ind.begin(), ind.end(), 0);       auto solve = [&](vector<int>& lx, vector<int>& y, vector<int>& x) {         long long ans = 0;         for (int i = 0, j = 0; i + 1 < lx.size(); i++) {           int c = 0;           map<int, int> com;           int l = lx[i], r = lx[i + 1];           while (j < k && x[ind[j]] <= l) j++;           while (j < k && x[ind[j]] < r) {             ans += c++;             ans -= com[y[ind[j]]]++;             j++;           }         }         return ans;       };       sort(ind.begin(), ind.end(), [&](int i, int j) { return x[i] < x[j]; });       long long ans = solve(lx, y, x);       sort(ind.begin(), ind.end(), [&](int i, int j) { return y[i] < y[j]; });       ans += solve(ly, x, y);       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, c, i, j = 1;     cin >> n;     cin >> c;     int arr[n];     for (i = 0; i < n; i++) {       cin >> arr[i];     }     for (i = 0; i < n - 1; i++) {       if (arr[i + 1] - arr[i] <= c)         j = j + 1;       else if (arr[i + 1] - arr[i] != c && i <= n - 2)         j = 1;       else         j = 0;     }     cout << j;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n;   int main() {     cin >> n;     long long int s(0);     long long int i = 1;     while (true) {       s += i;       if (s >= n) {         break;       }       i++;     }     long long int sk = s - n;     if (sk != 0) {       cout << i - 1 <<   n ;     } else {       cout << i <<   n ;     }     for (long long int I = 1; I <= i; I++) {       if (I == sk) {         continue;       }       cout << I <<    ;     }     cout <<   n ;     return 0;   }