malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   char str[25][25];   int cost[25][25];   const int maxc = 1 << 20;   int dp[maxc];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , str + i);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) scanf( %d , &cost[i][j]);     }     int total = (1 << n) - 1;     memset(dp, -1, sizeof(dp));     dp[0] = 0;     for (int i = 0; i < total; i++) {       if (dp[i] == -1) continue;       int j = 0;       while (((i >> j) & 1) == 1) j++;       for (int k = 0; k < m; k++) {         int cnt = 0, sumc = 0, maxc = 0, tmp = 0;         for (int z = 0; z < n; z++) {           if (str[z][k] == str[j][k]) {             cnt++;             sumc += cost[z][k];             maxc = max(maxc, cost[z][k]);             tmp |= (1 << z);           }         }         if (cnt == 1) {           if (dp[i | (1 << j)] == -1)             dp[i | (1 << j)] = dp[i];           else             dp[i | (1 << j)] = min(dp[i | (1 << j)], dp[i]);         } else {           if (dp[i | (1 << j)] == -1)             dp[i | (1 << j)] = dp[i] + cost[j][k];           else             dp[i | (1 << j)] = min(dp[i | (1 << j)], dp[i] + cost[j][k]);           if (dp[i | tmp] == -1)             dp[i | tmp] = dp[i] + sumc - maxc;           else             dp[i | tmp] = min(dp[i | tmp], dp[i] + sumc - maxc);         }       }     }     printf( %d n , dp[total]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2505;   int n, a[N][N];   struct node {     int x, y, v;     node() {}     node(int _x, int _y, int _v) : x(_x), y(_y), v(_v) {}     bool operator<(const node k) const { return v < k.v; }   };   vector<node> p;   bitset<N> r[N], c[N], t;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) scanf( %d , &a[i][j]);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (a[i][j] != a[j][i]) {           puts( NOT MAGIC );           return 0;         }         if (i == j && a[i][j]) {           puts( NOT MAGIC );           return 0;         }         p.push_back(node(i, j, a[i][j]));       }     }     sort(p.begin(), p.end());     for (int i = 0, j; i < p.size(); i = j) {       j = i;       while (j < p.size() && p[j].v == p[i].v) j++;       for (int k = i; k < j; k++) {         int x = p[k].x, y = p[k].y;         t = r[x] & c[y];         if (t.count()) {           puts( NOT MAGIC );           return 0;         }       }       for (int k = i; k < j; k++) {         int x = p[k].x, y = p[k].y;         r[x][y] = c[y][x] = 1;       }     }     puts( MAGIC );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     vector<long long int> v(n);     for (long long int i = 0; i < n; i++) cin >> v[i];     sort(v.begin(), v.end());     long long int i = 0, j = 0, ans = 0, curr = v[0];     while (i < n && j < n) {       ans = max((j - i + 1), ans);       if (v[j + 1] <= curr + 5)         j++;       else {         i++;         j++;       }       curr = v[i];     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void inc(T& a, const T& b) {     if (a < b) a = b;   }   template <class T>   void dec(T& a, const T& b) {     if (a > b) a = b;   }   const int N = 100010;   int n;   int a[N];   struct node {     int lf, len;     bool operator<(const node& rhs) const {       if (len != rhs.len) return len < rhs.len;       return lf < rhs.lf;     }   } c[N * 10];   int cn;   map<int, vector<int> > g;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , a + i);       if (g.find(a[i]) == g.end()) g[a[i]] = vector<int>();       g[a[i]].push_back(i);     }     for (map<int, vector<int> >::iterator it = (g).begin(); it != (g).end();          ++it) {       vector<int>& t = it->second;       int sz = t.size();       for (int i = 0; i < sz; i++) {         for (int j = i + 1; j < sz; j++) {           if (t[j] - t[i] + t[j] > n) break;           c[cn].lf = t[i];           c[cn].len = t[j] - t[i];           cn++;         }       }     }     sort(c, c + cn);     int p = 0;     for (int i = 0; i < cn; i++) {       int& lf = c[i].lf;       int rt = lf + c[i].len;       if (lf < p) continue;       bool flag = true;       for (int j = 1; j < c[i].len; j++) {         if (a[lf + j] != a[rt + j]) {           flag = false;           break;         }       }       if (flag) {         p = rt;       }     }     printf( %d n , n - p);     for (int i = p; i < n; ++i) {       printf( %d , a[i]);       putchar(i + 1 < n ? 32 : 10);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug;   const int inf = 1e9 + 5;   const int nax = 3005;   vector<int> w[nax];   int d[nax][nax];   int main(int argc, char *argv[]) {     debug = argc > 1;     int n, m;     scanf( %d%d , &n, &m);     for (int _ = 0; _ <= (m)-1; ++_) {       int a, b;       scanf( %d%d , &a, &b);       w[a].push_back(b);       w[b].push_back(a);     }     for (int i = 1; i <= (n); ++i) {       for (int j = 1; j <= (n); ++j) d[i][j] = inf;       d[i][i] = 0;       queue<int> q;       q.push(i);       while (!q.empty()) {         int a = q.front();         q.pop();         for (int b : w[a])           if (d[i][b] == inf) {             d[i][b] = d[i][a] + 1;             q.push(b);           }       }     }     int a[2], b[2], lim[2];     for (int r = 0; r <= (2) - 1; ++r) scanf( %d%d%d , &a[r], &b[r], &lim[r]);     int res = inf;     for (int i = 1; i <= (n); ++i)       for (int j = 1; j <= (n); ++j)         for (int _ = 0; _ <= (2) - 1; ++_) {           int dist[2];           for (int r = 0; r <= (2) - 1; ++r)             dist[r] = d[a[r]][i] + d[i][j] + d[j][b[r]];           if (dist[0] <= lim[0] && dist[1] <= lim[1])             res = min(res, dist[0] + dist[1] - d[i][j]);           swap(a[0], b[0]);         }     int dist[2];     for (int r = 0; r <= (2) - 1; ++r) dist[r] = d[a[r]][b[r]];     if (dist[0] <= lim[0] && dist[1] <= lim[1]) res = min(res, dist[0] + dist[1]);     printf( %d n , res == inf ? -1 : m - res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);   }   int main() {     fast();     double n;     cin >> n;     vector<double> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     double sum = 0;     for (int i = 0; i < n; i++) sum += v[i] / 100.0;     double res = (sum / n) * 100.0;     cout << fixed << setprecision(12) << res << endl;     cin.ignore();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 100005;   long long T, ans, res;   long long Ans[N], p[N], a, b, c;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline void solve(long long dep, long long a, long long x, long long b,                     long long y) {     if (x == 0 || y == 0) return;     if (x == y) {       p[dep] = x, ans = dep;       for (long long i = 0; i <= dep; i++) Ans[i] = p[i];       res++;     }     long long c = y % b;     p[dep] = c;     if (c % a != x % a) return;     solve(dep + 1, a, (x - c) / a, b, (y - c) / b);   }   signed main() {     a = read(), b = read(), c = read();     if (a == 1 && b == 1 && c == 1) {       printf( inf n );       return 0;     }     if (a == b && b != c) {       printf( 0 n );       return 0;     }     res = 0;     solve(0, a, b, b, c);     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, pos, ans;   string s;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> t;     while (t--) {       cin >> s;       ans = pos = 0;       s +=  R ;       for (int i = 0; i < s.size(); i++) {         if (s[i] ==  R ) {           ans = max(ans, (i + 1) - pos);           pos = (i + 1);         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   template <typename T>   inline void Add(T &x, T y) {     x += y;     if (x >= mod) x -= mod;   }   template <typename T>   inline void Mul(T &x, T y) {     (x *= y) %= mod;   }   inline int read() {     int x = 0;     char ch = getchar();     bool f = 0;     for (; ch <  0  || ch >  9 ; ch = getchar())       if (ch ==  - ) f = 1;     for (; ch >=  0  && ch <=  9 ; ch = getchar())       x = (x << 3) + (x << 1) + (ch ^ 48);     return f ? -x : x;   }   struct matrix {     long long a[2][2];     matrix() { memset(a, 0, sizeof(a)); }     inline bool isI() {       return a[0][0] == 1 && a[1][1] == 1 && a[0][1] == 0 && a[1][0] == 0;     }     friend inline matrix operator*(const matrix &A, const matrix &B) {       matrix C;       for (int i = (0), end_i = (1); i <= end_i; i++)         for (int j = (0), end_i = (1); j <= end_i; j++)           for (int k = (0), end_i = (1); k <= end_i; k++)             Add(C.a[i][j], A.a[i][k] * B.a[k][j] % mod);       return C;     }     friend inline matrix operator+(const matrix &A, const matrix &B) {       matrix C;       for (int i = (0), end_i = (1); i <= end_i; i++)         for (int j = (0), end_i = (1); j <= end_i; j++)           C.a[i][j] = (A.a[i][j] + B.a[i][j]) % mod;       return C;     }   } I, F;   inline matrix Pow(matrix A, long long n) {     matrix B = I;     for (; n; n >>= 1, A = A * A)       if (n & 1) B = B * A;     return B;   }   int n;   matrix sum[200010 << 2], tag[200010 << 2];   inline void pushdown(int u) {     if (tag[u].isI()) return;     sum[u << 1] = sum[u << 1] * tag[u];     sum[u << 1 | 1] = sum[u << 1 | 1] * tag[u];     tag[u << 1] = tag[u << 1] * tag[u];     tag[u << 1 | 1] = tag[u << 1 | 1] * tag[u];     tag[u] = I;   }   inline void pushup(int u) { sum[u] = sum[u << 1] + sum[u << 1 | 1]; }   void add(int L, int R, const matrix &C, int u = 1, int l = 1, int r = n) {     if (L <= l && r <= R) {       tag[u] = tag[u] * C, sum[u] = sum[u] * C;       return;     }     int mid = l + r >> 1;     pushdown(u);     if (L <= mid) add(L, R, C, u << 1, l, mid);     if (mid < R) add(L, R, C, u << 1 | 1, mid + 1, r);     pushup(u);   }   matrix ask(int L, int R, int u = 1, int l = 1, int r = n) {     if (L <= l && r <= R) return sum[u];     pushdown(u);     int mid = l + r >> 1;     matrix ans;     if (L <= mid) ans = ans + ask(L, R, u << 1, l, mid);     if (mid < R) ans = ans + ask(L, R, u << 1 | 1, mid + 1, r);     return ans;   }   int m;   int main() {     I.a[0][0] = I.a[1][1] = 1;     F.a[0][0] = 1, F.a[0][1] = 1;     F.a[1][0] = 1;     F.a[1][1] = 0;     n = read();     m = read();     for (int i = (1), end_i = (n << 2); i <= end_i; i++) tag[i] = I, sum[i] = I;     int opt, l, r, x;     matrix B;     for (int i = (1), end_i = (n); i <= end_i; i++)       B = Pow(F, read() - 1), add(i, i, B);     for (int _ = (1), end_i = (m); _ <= end_i; _++) {       opt = read(), l = read(), r = read();       if (opt == 1)         add(l, r, Pow(F, read()));       else         printf( %d n , ask(l, r).a[0][0]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   char s[33];   int num[33];   char mp[3][14];   int main() {     while (scanf( %s , s + 1) != EOF) {       memset(num, 0, sizeof(num));       int id;       for (int i = 1; i <= 27; i++) {         num[s[i] -  A ]++;         if (num[s[i] -  A ] == 2) {           id = s[i] -  A ;         }       }       int st = -1, ed = -1;       for (int i = 1; i <= 27; i++) {         int x = s[i] -  A ;         if (x == id) {           if (st == -1)             st = i;           else             ed = i;         }       }       if (ed - st == 1) {         printf( Impossible n );         continue;       }       int len = ed - st - 1;       int L = st - 1, R = len / 2, cnt = 1;       if (L + R + 1 <= 13) {         for (int i = 13 - R - 1 - L + 1; i <= 13 - R - 1; i++) {           mp[1][i] = s[cnt++];         }         mp[1][13 - R] = s[cnt++];         for (int i = 13 - R + 1; i <= 13; i++) mp[1][i] = s[cnt++];         int now = 13;         for (int i = len - R; i >= 1; i--) mp[2][now--] = s[cnt++];         cnt++;         for (int i = now; i >= 1; i--) mp[2][i] = s[cnt++];         now = 1;         for (int i = cnt; i <= 27; i++) mp[1][now++] = s[i];       } else {         int lef = L + R + 1 - 13;         for (int i = lef; i >= 1; i--) {           mp[2][i] = s[cnt++];         }         for (int i = 1; i <= L - lef; i++) mp[1][i] = s[cnt++];         mp[1][L - lef + 1] = s[cnt++];         int now = L - lef + 2;         for (int i = 1; i <= R; i++) mp[1][now++] = s[cnt++];         now = 13;         for (int i = len - R; i >= 1; i--) mp[2][now--] = s[cnt++];         cnt++;         for (int i = cnt; i <= 27; i++) mp[2][now--] = s[i];       }       for (int i = 1; i <= 2; i++) {         for (int j = 1; j <= 13; j++) printf( %c , mp[i][j]);         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1100], b[1100];   int main() {     int i, j, n, k, x;     cin >> n >> k >> x;     int arr[n];     for (i = 0; i < n; i++) {       cin >> arr[i];       a[arr[i]]++;     }     for (j = 0; j < k; j++) {       int sum = 0;       for (i = 0; i < 1100; i++) {         if (a[i] > 0) {           if (a[i] % 2 == 0) {             int l = (i ^ x);             b[l] += a[i] / 2;             b[i] += a[i] / 2;           } else {             if (sum % 2 == 0) {               int l = (i ^ x);               b[l] += a[i] / 2 + 1;               b[i] += a[i] / 2;             } else {               int l = (i ^ x);               b[l] += a[i] / 2;               b[i] += a[i] / 2 + 1;             }           }           sum += a[i];         }       }       for (i = 0; i < 1100; i++) {         a[i] = b[i];         b[i] = 0;       }     }     int Min = INT_MAX;     int Max = INT_MIN;     for (i = 0; i < 1100; i++) {       if (a[i] > 0) {         Min = min(i, Min);         Max = max(Max, i);       }     }     cout << Max <<     << Min << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool comp(pair<long long int, long long int> v1,             pair<long long int, long long int> v2) {     if (v1.first == v2.first) {       return v1.second > v2.second;     }     return v1.first > v2.first;   }   int main() {     long long int n, i, j, k, flag;     string s;     cin >> s;     map<long long int, long long int> mp;     for (i = 1; i <= 26; i++) {       mp[i] = 0;     }     for (i = 0; i < s.length(); i++) {       k = (s[i] -  a ) + 1;       mp[k] = 1;       for (j = 1; j <= k; j++) {         if (mp[j] == 0) {           cout <<  NO ;           return 0;         }       }     }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, a[100001][11], x[100001], cnt[11], u, v;   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , &a[i][j]);     for (int i = 1; i <= k && scanf( %d%d , &u, &v); i++) x[u]++, cnt[v]++;     for (int i = 1; i <= n; i++) {       int y = 0;       for (int j = 1; j <= m; j++)         if (a[i][j]) y += cnt[j];       printf( %d  , y - x[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     string s;     cin >> s;     vector<string> v(10);     for (int i = 0; i < 10; i++) {       cin >> v[i];     }     string res =   ;     for (int i = 0; i <= 70; i += 10) {       string find = s.substr(i, 10);       for (int j = 0; j < 10; j++) {         if (v[j] == find) {           res.push_back(j +  0 );           break;         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int a, b, c;     cin >> a >> b >> c;     if (min(a, b) != max(a, b))       cout << (2 * min(a, b) + 1 + 2 * c);     else       cout << (a + b + 2 * c);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sc1() {     int x;     scanf( %d , &x);     return x;   }   long long sc2() {     long long x;     scanf( %lld , &x);     return x;   }   int bs;   int n, q;   int arr[100007];   int cnt[100007];   int ans = 0;   int answer[100007];   struct A {     int l, r, id;   } node[100007];   bool cmp(A a, A b) {     int x = a.l / bs;     int y = b.l / bs;     if (x != y) return x < y;     return a.r < b.r;   }   void add(int x) {     if (x <= n) {       if (cnt[x] == x) ans--;       cnt[x]++;       if (cnt[x] == x) ans++;     }   }   void rmv(int x) {     if (x <= n) {       if (cnt[x] == x) ans--;       cnt[x]--;       if (cnt[x] == x) ans++;     }   }   int main() {     n = sc1(), q = sc1();     bs = sqrt(n);     for (int i = 0; i < n; i++) arr[i] = sc1();     for (int i = 0; i < q; i++) {       int a = sc1(), b = sc1();       node[i].l = --a;       node[i].r = --b;       node[i].id = i;     }     sort(node, node + q, cmp);     int mo_left = 0, mo_right = -1;     for (int i = 0; i < q; i++) {       int left = node[i].l;       int right = node[i].r;       while (mo_right < right) {         mo_right++;         add(arr[mo_right]);       }       while (mo_right > right) {         rmv(arr[mo_right]);         mo_right--;       }       while (mo_left < left) {         rmv(arr[mo_left]);         mo_left++;       }       while (mo_left > left) {         mo_left--;         add(arr[mo_left]);       }       answer[node[i].id] = ans;     }     for (int i = 0; i < q; i++) {       cout << answer[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   vector<vector<int> > graph, trees, chains;   vector<int> head, sub, mxs, mp, idx;   int dfs(int ind = 0) {     sub[ind] = 1;     mxs[ind] = 0;     for (auto u : graph[ind]) {       sub[ind] += dfs(u);       mxs[ind] = max(mxs[ind], sub[u]);     }     return sub[ind];   }   void HLD(int ind = 0, int chain = 0) {     pair<int, int> mx = {INT_MIN, INT_MIN};     if (chains[chain].empty()) head[chain] = ind;     chains[chain].push_back(ind);     mp[ind] = chain;     idx[ind] = chains[chain].size() - 1;     for (auto u : graph[ind]) {       mx = max(mx, make_pair(sub[u], u));     }     if (mx.first >= 0) {       HLD(mx.second, chain);       for (auto u : graph[ind]) {         if (u == mx.second) continue;         chains.push_back(vector<int>());         head.push_back(0);         HLD(u, chains.size() - 1);       }     }   }   int x;   void build(int n = 0, int l = 0, int r = chains[x].size() - 1) {     if (l == r) {       trees[x][n] = mxs[chains[x][l]];       return;     }     int md = (l + r) >> 1;     build(2 * n + 1, l, md);     build(2 * n + 2, md + 1, r);     trees[x][n] = min(trees[x][2 * n + 1], trees[x][2 * n + 2]);   }   int K, ind;   pair<bool, int> qry(int n = 0, int l = 0, int r = chains[x].size() - 1) {     if (l == r) {       return {K >= trees[x][n], chains[x][l]};     }     int md = (l + r) >> 1;     if (ind <= md && trees[x][2 * n + 1] <= K) {       return qry(2 * n + 1, l, md);     } else if (ind <= r && trees[x][2 * n + 2] <= K)       return qry(2 * n + 2, md + 1, r);     else       return {false, -1};   }   void s(int &x) {     register int c = getchar();     x = 0;     for (; (c < 48 || c > 57); c = getchar())       ;     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }   }   int main() {     int N, Q, u, v;     s(N), s(Q);     graph.resize(N);     mxs.resize(N);     sub.resize(N);     mp.resize(N);     idx.resize(N);     for (int i = 1; i < N; i++) {       v = i;       s(u);       u--;       graph[u].push_back(v);     }     dfs();     chains.push_back(vector<int>());     head.push_back(0);     HLD();     trees.resize(chains.size());     for (x = 0; x < (int)chains.size(); x++) {       trees[x].resize(4 * chains[x].size());       build();     }     while (Q--) {       s(v);       v--;       x = mp[v];       K = sub[v] / 2;       printf( %d n , qry().second + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     cin >> str;     if ((int)str.size() == 1) {       cout << 1 << endl;       return 0;     }     str +=  8 ;     int cnt = 1, ans = 0;     for (int i = 1; i < (int)str.size(); i++) {       if (str[i] == str[i - 1])         cnt++;       else {         ans += ceil(cnt * 1.0 / 5.0);         cnt = 1;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   int ar[100000];   using namespace std;   int main() {     int n;     cin >> n;     int c = 0, ans = 0;     int r;     for (int i = 0; i < 2 * n; i++) {       cin >> r;       if (ar[r]) {         ar[r] = 0;         c--;       } else {         c++;         ar[r] = 1;       }       if (ans < c) ans = c;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline char nc() {     static char buf[600000], *p1, *p2;     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 600000, stdin), p1 == p2)                ? EOF                : *p1++;   }   long long rd() {     long long x = 0;     char ch = nc();     while (ch <  0  || ch >  9 ) ch = nc();     while (ch >=  0  && ch <=  9 ) x = (x << 3) + (x << 1) + ch -  0 , ch = nc();     return x;   }   const long long MAX_N = 5e5 + 25;   long long n, m, q;   long long cnt[MAX_N];   long long ans[MAX_N];   set<pair<long long, long long> > city;   set<pair<long long, long long> >::iterator it;   long long Fen[MAX_N];   long long num;   long long Min;   set<pair<long long, long long> > Q;   void add(long long tmp) {     tmp++;     for (; tmp < MAX_N; tmp += tmp & -tmp) Fen[tmp]++;   }   long long get(long long tmp) {     long long res = 0;     long long id = 0;     for (long long i = 20; ~i; i--)       if (id + (1 << i) < MAX_N && ((id >> i) & 1) == 0)         if (res + Fen[id + (1 << i)] < tmp) {           res += Fen[id + (1 << i)];           id += (1 << i);         }     return id;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0);     n = rd();     m = rd();     q = rd();     for (long long i = 0; i < n; i++) {       long long tmp;       tmp = rd();       tmp--;       cnt[tmp]++;     }     for (long long i = 0; i < q; i++) {       long long t;       t = rd();       t -= n;       Q.insert({t, i});     }     for (long long i = 0; i < m; i++) city.insert({cnt[i], i});     num = 1;     it = city.begin();     add(it->second);     Min = it->first;     city.erase(it);     while (city.size() && city.begin()->first == Min) {       num++;       it = city.begin();       add(it->second);       city.erase(it);     }     long long Y = 0;     while (num != m) {       while (Q.size() && Q.begin()->first <= Y + num) {         it = Q.begin();         ans[it->second] = get(it->first - Y);         Q.erase(it);       }       if (!Q.size()) break;       Y += num;       Min++;       while (city.size() && city.begin()->first == Min) {         num++;         it = city.begin();         add(it->second);         city.erase(it);       }     }     while (Q.size()) {       it = Q.begin();       ans[it->second] = (((it->first - Y) % m - 1) + m) % m;       Q.erase(it);     }     for (long long i = 0; i < q; i++) printf( %lld  , ans[i] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000 * 100 + 20;   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       if (k % 2 == n % 2 && (k * k) <= n)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b;   long long f(long long a, long long b) {     if (b == 0) return 0;     return a / b + f(b, a % b);   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     cin >> a >> b;     cout << f(a, b) << endl;   }