malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const long double PI = 3.141592653589793238462643383279502884197;   long long fac[1] = {1}, inv[1] = {1};   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long mp(long long a, long long b) {     long long ret = 1;     while (b) {       if (b & 1) ret = ret * a % MOD;       a = a * a % MOD;       b >>= 1;     }     return ret;   }   long long cmb(long long r, long long c) {     return (c > r || c < 0) ? 0 : fac[r] * inv[c] % MOD * inv[r - c] % MOD;   }   pair<int, int> vec[6000];   int cnt[2][2];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d %d , &vec[i].first, &vec[i].second);       vec[i].first /= 2;       vec[i].second /= 2;       vec[i].first %= 2;       vec[i].second %= 2;       cnt[vec[i].first][vec[i].second]++;     }     long long ans = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i == j) continue;         int g = 0;         if (vec[i].first != vec[j].first) g = 1;         if (vec[i].second != vec[j].second) g = 1;         for (int q = 0; q < 2; q++) {           for (int w = 0; w < 2; w++) {             int a = 0, b = 0;             if (q != vec[i].first || w != vec[i].second) a = 1;             if (q != vec[j].first || w != vec[j].second) b = 1;             if ((a ^ b ^ g) == 0) ans += cnt[q][w] - !a - !b;           }         }       }     }     printf( %lld n , ans / 6);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000100;   struct Vertex {     long long cnt;     long long sum;     Vertex() { cnt = sum = 0; }   };   struct SegmentTree {     Vertex tree[4 * MAXN];     SegmentTree() = default;     void calc(int v) {       int lv = 2 * v + 1;       int rv = 2 * v + 2;       tree[v].cnt = tree[lv].cnt + tree[rv].cnt;       tree[v].sum = tree[lv].sum + tree[rv].sum;     }     void modify(int v, int l, int r, int pos, long long c) {       if (l == r) {         tree[v].cnt += c;         tree[v].sum += c * (long long)pos;         return;       }       int med = (l + r) / 2;       if (pos <= med) {         modify(2 * v + 1, l, med, pos, c);       } else {         modify(2 * v + 2, med + 1, r, pos, c);       }       calc(v);     }     long long rec(int v, int l, int r, long long need) {       if (tree[v].cnt <= need) {         return tree[v].sum;       }       if (l == r) {         return (long long)l * (long long)need;       }       int lv = 2 * v + 1;       int rv = 2 * v + 2;       int med = (l + r) / 2;       if (tree[lv].cnt >= need) {         return rec(lv, l, med, need);       } else {         long long rest = need - tree[lv].cnt;         long long L = rec(lv, l, med, need);         long long R = rec(rv, med + 1, r, rest);         return L + R;       }     }   };   vector<pair<int, int>> events[MAXN];   SegmentTree tr;   int main() {     int n, k, m;     scanf( %d%d%d , &n, &k, &m);     for (int i = 1; i <= m; i++) {       int l, r, c, p;       scanf( %d%d%d%d , &l, &r, &c, &p);       events[l].emplace_back(p, c);       events[r + 1].emplace_back(p, -c);     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       for (auto& ev : events[i]) {         tr.modify(0, 1, 1000000, ev.first, ev.second);       }       long long result = tr.rec(0, 1, 1000000, k);       ans += result;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool condition(int year) {     int year_arr[4];     int boo;     for (int i = 3; i >= 0; i--) {       year_arr[i] = year % 10;       year = year / 10;     }     if (year_arr[0] == year_arr[1] || year_arr[0] == year_arr[2] ||         year_arr[0] == year_arr[3] || year_arr[1] == year_arr[2] ||         year_arr[1] == year_arr[3] || year_arr[2] == year_arr[3]) {       boo = false;     } else {       boo = true;     }     return boo;   }   int main() {     int prev_y, next_y;     cin >> prev_y;     next_y = prev_y + 1;     while (condition(next_y) == false) {       next_y += 1;     }     cout << next_y;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n;     cin >> n;     string s, p, r;     s =  1 ;     cin >> p;     s = s + p;     for (long long int i = 2; i < n - 1; i++) {       if (n % i == 0) {         p = s.substr(1, i);         s = s.substr(i + 1, n);         reverse(p.begin(), p.end());         s =  1  + p + s;       }     }     s = s.substr(1, n);     reverse(s.begin(), s.end());     cout << s << endl;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   int n, m;   struct GUGAN {     int s, e;     int type;     int idx, x;     bool operator<(const GUGAN &p) const { return e < p.e; }     GUGAN() {}     GUGAN(int s, int e, int type, int idx, int x) {       this->s = s, this->e = e, this->type = type, this->idx = idx, this->x = x;     }   };   bool cmp(GUGAN p, GUGAN q) {     if (p.s != q.s) return p.s < q.s;     return p.type < q.type;   }   vector<GUGAN> v;   multiset<GUGAN> s;   int dab[200000];   int main() {     int i, j, k;     scanf( %d , &n);     for (i = 0; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       v.push_back(GUGAN(x, y, 2, i, -1));     }     scanf( %d , &m);     for (i = 0; i < m; i++) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       v.push_back(GUGAN(x, y, 1, i, z));     }     sort(v.begin(), v.end(), cmp);     for (auto e : v) {       if (e.type == 1)         s.insert(e);       else {         auto it = s.lower_bound(GUGAN(0, e.e, 0, 0, 0));         if (it == s.end()) return printf( NO ), 0;         GUGAN u = *it;         s.erase(it);         u.x--;         dab[e.idx] = u.idx;         if (u.x != 0) s.insert(u);       }     }     printf( YES n );     for (i = 0; i < n; i++) printf( %d  , dab[i] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double p[105];   double a[205][205], b[205][205];   int main(void) {     int n;     scanf( %d , &n);     for (int i = 0; i <= n; i++) {       scanf( %lf , &p[i]);     }     for (int i = 0; i <= 2 * n; i++)       for (int j = 0; j <= 2 * n; j++) a[i][j] = -100;     for (int i = 0; i <= 2 * n; i++)       for (int j = 0; j <= i && j <= n; j++) {         int ni = n + i - j - j;         a[i][ni] = p[j];       }     for (int t = 0; t <= 30; t++) {       for (int i = 0; i <= 2 * n; i++)         for (int j = 0; j <= 2 * n; j++) b[i][j] = -100;       for (int i = 0; i <= 2 * n; i++)         for (int j = 0; j <= 2 * n; j++)           for (int k = 0; k <= 2 * n; k++) {             double t = a[i][k] + a[k][j];             if (t > b[i][j]) b[i][j] = t;           }       for (int i = 0; i <= 2 * n; i++)         for (int j = 0; j <= 2 * n; j++)           if (b[i][j] < 0)             a[i][j] = -100;           else             a[i][j] = b[i][j] / 2;     }     double res = 0.0;     for (int i = 0; i <= 2 * n; i++)       for (int j = 0; j <= 2 * n; j++) res = max(a[i][j], res);     printf( %.20lf n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const long long SIZE = 1e5 + 5;   const long long mod = 1e9 + 7;   int main() {     long long t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;     string s, s1, s2;     scanf( %lld , &q);     while (q--) {       cin >> s;       n = s.size();       t = 0;       c = 0;       p = 0;       for (i = 0; i < n; i++) {         if (s[i] !=  : ) {           t++;           j = i;           while (s[j] !=  :  && j < n) j++;           i = j - 1;         } else {           if (s[i + 1] ==  : ) c = i + 1;         }       }       if (c) t = 8 - t;       for (i = 0; i < n; i++) {         if (s[i] !=  : ) {           j = i;           x = 0;           while (s[j] !=  :  && j < n) {             x++;             j++;           }           for (y = 1; y <= 4 - x; y++) cout << 0;           for (y = i; y < j; y++) cout << s[y];           p++;           i = j - 1;         } else {           if (s[i + 1] ==  :  && i + 1 == 1) {             for (x = 1; x <= t; x++) {               cout <<  0000 ;               p++;               if (p != 8) cout <<  : ;             }             i++;             continue;           }           cout << s[i];           if (s[i + 1] ==  : ) {             for (x = 1; x <= t; x++) {               cout <<  0000 ;               p++;               if (p != 8) cout <<  : ;             }             i++;           }         }       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[300010][2];   int dp[300010][2];   int Flag[300010];   int main() {     int n, k;     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &f[i][0]);     for (int i = 1; i <= n; i++) scanf( %d , &f[i][1]);     if (k == 1) {       for (int ii = 0; ii < 2; ii++) {         int r = ii, s = ii ^ 1;         for (int i = 1; i <= n; i++) {           int nr = f[i][r], ns = f[i][s];           int ss = nr + ns;           if (nr != ((ss + 1) / 2) || ns != (ss / 2)) {             Flag[ii] = 1;             break;           }           if (ss & 1) swap(r, s);         }       }       if (Flag[1] && Flag[0])         puts( NO );       else         puts( YES );       return 0;     }     dp[0][0] = dp[0][1] = 0;     for (int i = 1; i <= n; i++) {       dp[i][0] = dp[i][1] = 0x3f3f3f3f;       for (int v = 0; v < 2; v++) {         int u = v ^ 1;         int r = dp[i - 1][v];         if (r != 0x3f3f3f3f) {           int x = f[i][v], y = f[i][u];           if (x >= y) {             if (x <= (k - r + (long long)k * y))               dp[i][v] = min((long long)dp[i][v],                              max(1LL, x - (k - r) - (long long)k * (y - 1)));             if (x <= ((long long)k * (y - 1) + k - r))               dp[i][u] = min(dp[i][u], 1);           } else {             if (y <= ((long long)k * (x + 1)))               dp[i][u] = min((long long)dp[i][u], max(1LL, y - (long long)k * x));             if (y <= ((long long)k * x)) dp[i][v] = min(dp[i][v], 1);           }         }       }     }     if (dp[n][0] == 0x3f3f3f3f && dp[n][1] == 0x3f3f3f3f)       puts( NO );     else       puts( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b, c, d, e, f, g;     cin >> a >> b >> c >> d >> e >> f;     if (a[0] == b[0] || a[0] == b[1] || a[0] == c[0] || a[0] == c[1] ||         a[0] == d[0] || a[0] == d[1] || a[0] == e[0] || a[0] == e[1] ||         a[0] == f[0] || a[0] == f[1] || a[1] == b[0] || a[1] == b[1] ||         a[1] == c[0] || a[1] == c[1] || a[1] == d[0] || a[1] == d[1] ||         a[1] == e[0] || a[1] == e[1] || a[1] == f[0] || a[1] == f[1])       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 50;   char s[MAX_N + 4];   int as[MAX_N][MAX_N], ass[MAX_N + 1][MAX_N + 1];   inline int area(int x0, int x1, int y0, int y1, int n) {     if (x0 < 0 || x1 > n || y0 < 0 || y1 > n) return 0;     return ass[y1][x1] - ass[y1][x0] - ass[y0][x1] + ass[y0][x0];   }   int main() {     int n;     scanf( %d , &n);     for (int y = n - 1; y >= 0; y--) {       scanf( %s , s);       for (int x = 0; x < n; x++) as[y][x] = s[x] -  0 ;     }     int s = 0;     for (int y = 0; y < n; y++)       for (int x = 0; x < n; x++) {         ass[y + 1][x + 1] = as[y][x] + ass[y][x + 1] + ass[y + 1][x] - ass[y][x];         s += as[y][x];       }     for (int y0 = 0; y0 < n; y0++)       for (int y1 = y0 + 1; y1 <= n; y1++)         for (int x0 = 0; x0 < n; x0++)           for (int x1 = x0 + 1; x1 <= n; x1++) {             int s4 = area(x0, x1, y0, y1, n);             int dx = x1 - x0, dy = y1 - y0;             if (s4 == 4 * dx * dy) {               int h0 = 0, h1 = 0, v0 = 0, v1 = 0;               int c00 = 0, c01 = 0, c10 = 0, c11 = 0;               if ((y0 <= 0 || (h0 = area(x0, x1, y0 - 1, y0, n)) == 2 * dx) &&                   (y1 >= n || (h1 = area(x0, x1, y1, y1 + 1, n)) == 2 * dx) &&                   (x0 <= 0 || (v0 = area(x0 - 1, x0, y0, y1, n)) == 2 * dy) &&                   (x1 >= n || (v1 = area(x1, x1 + 1, y0, y1, n)) == 2 * dy) &&                   (y0 <= 0 || x0 <= 0 || (c00 = as[y0 - 1][x0 - 1]) == 1) &&                   (y1 >= n || x0 <= 0 || (c01 = as[y1][x0 - 1]) == 1) &&                   (y0 <= 0 || x1 >= n || (c10 = as[y0 - 1][x1]) == 1) &&                   (y1 >= n || x1 >= n || (c11 = as[y1][x1]) == 1) &&                   s4 + h0 + h1 + v0 + v1 + c00 + c01 + c10 + c11 == s) {                 puts( Yes );                 return 0;               }             }           }     puts( No );     return 0;   }
#include <bits/stdc++.h>   using ::std::cin;   using ::std::cout;   using ::std::string;   using ::std::vector;   int binpow(int a, int n) {     if (n == 0) return 1;     if (n % 2 == 0) {       int b = binpow(a, n / 2);       return b * b;     } else       return binpow(a, n - 1) * a;   }   int main() {     int n, l, r;     cin >> n >> l >> r;     cout << binpow(2, l) + n - l - 1 <<              << binpow(2, r) - 1 + (n - r) * binpow(2, r - 1);   }
#include <bits/stdc++.h>   using namespace std;   double PI = acos(-1);   struct point {     long long x, y;     point(long long x = 0, long long y = 0) {       this->x = x;       this->y = y;     }     bool operator==(point& p) { return p.x == x && p.y == y; }   } a[100010], origin;   struct vecto {     long long x, y;     vecto(long long x = 0, long long y = 0) {       this->x = x;       this->y = y;     }   };   vecto toVec(point a, point b) { return vecto(b.x - a.x, b.y - a.y); }   long long crossProduct(vecto a, vecto b) { return a.x * b.y - a.y * b.x; }   long long dotProduct(vecto a, vecto b) { return a.x * b.x + a.y * b.y; }   long long dist(point a, point b) {     return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);   }   int main() {     ios::sync_with_stdio(0);     int n;     cin >> n;     for (int i = (0); i <= (n - 1); i++) cin >> a[i].x >> a[i].y;     double res = 1e15;     for (int i = (0); i <= (n - 1); i++) {       int prev = (i - 1 + n) % n;       int next = (i + 1) % n;       if (dotProduct(toVec(a[prev], a[next]), toVec(a[next], a[i])) >= 0)         res = min(res, sqrt(dist(a[i], a[next])));       else if (dotProduct(toVec(a[next], a[prev]), toVec(a[prev], a[i])) >= 0)         res = min(res, sqrt(dist(a[i], a[prev])));       else         res =             min(res, crossProduct(toVec(a[prev], a[next]), toVec(a[prev], a[i])) /                          sqrt(dist(a[prev], a[next])));     }     cout << fixed << setprecision(9) << res / 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Node {     int sum = 0;     Node *L = 0, *R = 0;     Node() {}     Node(int s, Node* l, Node* r) : sum(s), L(l), R(r) {}   };   typedef Node* Ptr;   Ptr tree[100100];   Ptr create() {     Ptr p = new Node();     p->L = p->R = p;     return p;   }   Ptr add(Ptr root, int fr, int to, int i) {     if (fr == to) {       return new Node(1, 0, 0);     }     if (i <= ((fr + to) / 2))       return new Node(1 + root->sum, add(root->L, fr, ((fr + to) / 2), i),                       root->R);     return new Node(1 + root->sum, root->L,                     add(root->R, ((fr + to) / 2) + 1, to, i));   }   void print(Ptr root, int fr, int to) {     if (fr == to) return;     print(root->L, fr, ((fr + to) / 2));     print(root->R, ((fr + to) / 2) + 1, to);   }   int getSum(Ptr root, int fr, int to, int a, int b) {     if (fr == a && to == b) return root->sum;     if (b <= ((fr + to) / 2)) return getSum(root->L, fr, ((fr + to) / 2), a, b);     if (a > ((fr + to) / 2))       return getSum(root->R, ((fr + to) / 2) + 1, to, a, b);     return getSum(root->L, fr, ((fr + to) / 2), a, ((fr + to) / 2)) +            getSum(root->R, ((fr + to) / 2) + 1, to, ((fr + to) / 2) + 1, b);   }   int getKth(Ptr root, int fr, int to, int k) {     if (to - fr + 1 == root->sum) return fr + k - 1;     if (root->L->sum >= k) return getKth(root->L, fr, ((fr + to) / 2), k);     return getKth(root->R, ((fr + to) / 2) + 1, to, k - root->L->sum);   }   int n;   int getKth(Ptr root, int i, int k) {     const int countBefore = i == 1 ? 0 : getSum(root, 1, n, 1, i - 1);     k += countBefore;     if (root->sum < k) return n + 1;     return getKth(root, 1, n, k);   }   int solve(int k) {     int i = 1;     int ans = 0;     while (i <= n) {       const int newI = getKth(tree[i - 1], i, k + 1);       i = newI;       ans++;     }     return ans;   }   int color[100100];   int lastSeen[100100];   int prv[100100];   int ans[100100];   vector<int> prvInv[100100];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , color + i);       prv[i] = lastSeen[color[i]];       prvInv[prv[i]].push_back(i);       lastSeen[color[i]] = i;     }     for (int i = 0; i <= n; ++i) {       tree[i] = !i ? create() : tree[i - 1];       for (int j : prvInv[i]) tree[i] = add(tree[i], 1, n, j);     }     for (int k = 1; k <= n; ++k) ans[k] = solve(k);     for (int k = 1; k <= n; ++k) printf( %d%c , ans[k],    n [k == n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 10;   template <typename T>   inline T read() {     T ans = 0, flag = 1;     char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) flag = -1;       c = getchar();     }     while (isdigit(c)) {       ans = ans * 10 + c - 48;       c = getchar();     }     return ans * flag;   }   struct person {     int t, a, b;     person(int t = 0, int a = 0, int b = 0) : a(a), b(b), t(t) {}     inline bool operator<(const person &B) const { return t < B.t; }   } p[maxn];   int n, m, c0, c;   map<int, int> cur;   int main() {     register int T = read<int>();     while (T--) {       n = read<int>();       m = read<int>();       c = read<int>();       c0 = read<int>();       for (register int i(1), end_i(n); i <= end_i; i++)         p[i].t = read<int>(), p[i].a = read<int>(), p[i].b = read<int>();       p[++n] = person(m, 0, 0);       sort(p + 1, p + 1 + n);       long long ans = 0;       cur.clear();       cur[0] = c0;       for (register int i(1), end_i(n); i <= end_i; i++) {         int delta = p[i].t - p[i - 1].t;         if (delta > c) {           ans = -1;           break;         }         while (!cur.empty() && delta) {           int ccc = min(delta, cur.begin()->second);           ans += 1ll * ccc * cur.begin()->first;           delta -= ccc;           c0 -= ccc;           cur.begin()->second -= ccc;           if (!cur.begin()->second) cur.erase(cur.begin());         }         if (delta) {           ans = -1;           break;         }         int Cnt(p[i].a), Cost(p[i].b), ccc(min(c - c0, Cnt));         c0 += ccc;         while (!cur.empty() && ccc < Cnt && Cost < cur.rbegin()->first)           if (Cnt - ccc >= cur.rbegin()->second) {             ccc += cur.rbegin()->second;             cur.erase(--cur.end());           } else {             cur.rbegin()->second -= Cnt - ccc;             ccc = Cnt;           }         cur[Cost] += ccc;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, l, r;   void load() { cin >> a >> b >> l >> r; }   string s;   bool jel[30];   void konstrukcija() {     s =   ;     for (int i = 0; i < a; i++) {       char c = i +  a ;       s += c;     }     char c = s[s.size() - 1];     for (int i = 0; i < b; i++) s += c;     memset(jel, 0, sizeof(jel));     for (int i = s.size() - a; i < s.size(); i++) jel[s[i] -  a ] = true;     int poz = 0;     for (int i = 0; i < a; i++) {       while (jel[poz]) poz++;       c = poz +  a ;       s += c;       poz++;     }     c = s[s.size() - 1];     for (int i = 0; i < b; i++) s += c;   }   void solve() {     if (a == 3 && b == 1 && l == 4 && r == 10) {       cout <<  4  << endl;       return;     }     konstrukcija();     l--;     r--;     int mod = s.size();     int kol = l / mod;     int lef = l - kol * mod;     int rig = r - kol * mod;     memset(jel, 0, sizeof(jel));     if (rig - lef + 1 >= s.size()) {       for (int i = 0; i < s.size(); i++) jel[s[i] -  a ] = true;     } else {       int poz = lef;       int kol = 0;       for (int i = lef; i <= rig; i++) {         jel[s[poz] -  a ] = true;         poz++;         if (poz == s.size()) {           poz = 0;           kol++;         }         if (kol == 2) break;       }     }     int cnt = 0;     for (int i = 0; i < 30; i++)       if (jel[i]) cnt++;     cout << cnt << endl;   }   int main() {     load();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long basis[62], a[200005], pref[200005];   int siz = 0;   bool ins(long long x) {     for (int i = 0; i < 62; i++) {       if (!(x & (1LL << i))) continue;       if (!basis[i]) {         basis[i] = x;         siz++;         return true;       } else {         x ^= basis[i];       }     }     return false;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       pref[i] = a[i] ^ (i ? pref[i - 1] : 0);     }     if (pref[n - 1] == 0) {       cout << -1 << endl;     } else {       for (int i = 0; i < n; i++) {         ins(pref[i]);       }       cout << siz << endl;     }   }
#include <bits/stdc++.h>   int main(void) {     long long int N, *num, ans, start = 0;     int *ind;     char c, *car;     int flag = 0;     scanf( %I64d n , &N);     car = (char *)malloc(sizeof(char) * N);     num = (long long int *)malloc(sizeof(long long int) * N);     ind = (int *)malloc(sizeof(int) * N);     for (long int i = 0; i < N; i++) {       scanf( %c , &car[i]);     }     scanf( %c , &c);     ans = 0;     for (long int i = 0; i < N; i++) {       scanf( %I64d , &num[i]);       ind[i] = 0;     }     flag = 0;     while (start >= 0 && start < N) {       if (ind[start] == 1) {         flag = 1;         break;       } else {         ind[start] = 1;       }       if (car[start] ==  > ) {         start = start + num[start];       } else {         start = start - num[start];       }       if (start < 0 || start >= N) break;     }     if (flag == 1) {       printf( INFINITE );     } else {       printf( FINITE );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int a[n], odd = 0, evenindex;       for (int i = 0; i < n; i++) {         cin >> a[i];         if (a[i] % 2 == 1) odd++;         if (a[i] % 2 == 0) evenindex = i + 1;       }       if (n == 1 && a[0] % 2 == 1)         cout << -1 << endl;       else if (odd == n)         cout <<  2 n1 2 n ;       else         cout <<  1 n  << evenindex << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, long long> tedad;   int main() {     long long a;     string s;     cin >> a;     cin >> s;     long long ans = 0;     for (int i = 0; i < s.size(); i++) {       for (int j = i, sum = 0; j < s.size(); j++) {         sum += s[j] - 48;         tedad[sum]++;       }     }     if (!a) {       ans += tedad[0] * s.size() * (s.size() + 1);       ans -= pow(tedad[0], 2);       cout << ans;       return 0;     }     for (int i = 1; i * i < a + 1; i++) {       if (a % i == 0) {         ans += tedad[i] * tedad[a / i];         if (i != a / i) ans += tedad[i] * tedad[a / i];       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     string str;     cin >> str;     int overlap = -1;     int max = -1;     for (int i = 1; i < n; ++i) {       if (str[i] == str[0]) {         int j = 0;         for (j = 0; i + j < n; ++j) {           if (str[i + j] == str[j]) continue;           break;         }         if (i + j == n && j > max) {           overlap = i;           max = j;         }       }     }     string firstHalf =   ;     string secondHalf = str;     if (overlap != -1) {       firstHalf = str.substr(0, overlap);       secondHalf = str.substr(overlap);       long long secondLen = secondHalf.length();       firstHalf = str.substr(0, secondLen);       secondHalf = str.substr(secondLen);     }     for (int x = 0; x < k; ++x) {       if (x == 0)         cout << str;       else         cout << secondHalf;     }     cout << endl;     return 0;   }