malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int in() {     int32_t x;     scanf( %d , &x);     return x;   }   inline long long lin() {     long long x;     scanf( %lld , &x);     return x;   }   inline string get() {     char ch[2000010];     scanf( %s , ch);     return ch;   }   const int MAX_LG = 21;   const int maxn = 2e3 + 10;   const int maxm = 1e5 + 10;   const int base = 29;   const int mod = 1e9 + 7;   const int INF = 1e9 + 100;   const int SQ = 317;   int Cmp;   int mark[maxn];   int v[maxm], u[maxm], deg[maxn], has[maxn][maxn], e[maxm];   int vc[5];   inline void dfs(int node, int id) {     int edgeid = has[node][vc[id]] - 1;     if (edgeid < 0) return;     int nxt = v[edgeid] == node ? u[edgeid] : v[edgeid];     has[node][vc[id]] = 0;     has[nxt][vc[id]] = 0;     dfs(nxt, id ^ 1);     has[node][vc[id ^ 1]] = edgeid + 1;     has[nxt][vc[id ^ 1]] = edgeid + 1;     e[edgeid] = vc[id ^ 1];   }   int res;   int32_t main() {     int a = in(), b = in(), m = in();     for (int i = 0; i < m; i++) {       v[i] = in(), u[i] = in() + a;       deg[v[i]]++;       deg[u[i]]++;       res = max(res, max(deg[v[i]], deg[u[i]]));     }     for (int i = 0; i < m; i++) {       bool fl = false;       for (int col = 1; col <= res; col++) {         if (has[v[i]][col] == 0 && has[u[i]][col] == 0 && col <= res) {           has[v[i]][col] = has[u[i]][col] = i + 1;           e[i] = col;           fl = true;           break;         }       }       if (!fl) {         Cmp++;         for (int col = 1; col <= res; col++) {           if (has[v[i]][col] && !has[u[i]][col]) vc[0] = col;           if (has[v[i]][col] == 0 && has[u[i]][col]) vc[1] = col;         }         dfs(v[i], 0);         has[v[i]][vc[0]] = has[u[i]][vc[0]] = i + 1;         e[i] = vc[0];       }     }     cout << res <<   n ;     for (int i = 0; i < m; i++) cout << e[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int f[100005], b[100005], fn[100005], bn[100005], fm, bm;   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) {       scanf( %d , f + i);       ++fn[f[i]];       fm = max(fm, f[i]);     }     for (int i = 0; i < m; ++i) {       scanf( %d , b + i);       ++bn[b[i]];       bm = max(bm, b[i]);     }     if (fm < bm) {       printf( Impossible n );     } else {       bool ans = true;       bool chong = false;       for (int i = 1; i <= bm; ++i) {         if (bn[i] > 0) {           if (fn[i] == 0) {             ans = false;           } else if (fn[i] > 1) {             chong = true;           }         }       }       if (!ans) {         printf( Impossible n );       } else {         if (chong) {           printf( Ambiguity n );         } else {           printf( Possible n );           for (int i = 0; i < n; ++i) {             fn[f[i]] = i + 1;           }           for (int i = 0; i < m; ++i) {             printf( %d  , fn[b[i]]);           }           printf(  n );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int k;   int n[3], t[3];   multiset<int> f[3];   int main() {     cin >> k;     cin >> n[0] >> n[1] >> n[2];     cin >> t[0] >> t[1] >> t[2];     for (int i = 0; i < 3; i++)       for (int j = 0; j < n[i]; j++) f[i].insert(0);     int ans = 0;     for (int i = 0; i < k; i++) {       int go[3];       for (int j = 0; j < 3; j++) {         go[j] = *f[j].begin();         f[j].erase(f[j].begin());       }       go[1] -= t[0];       go[2] -= t[0] + t[1];       int w = max(go[0], max(go[1], go[2]));       ans = w + t[0] + t[1] + t[2];       f[0].insert(w + t[0]);       f[1].insert(w + t[0] + t[1]);       f[2].insert(ans);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n < 3) {       cout << -1;       return 0;     }     if (n == 3) {       cout << 210;       return 0;     }     int A[] = {50, 80, 170, 20, 200, 110};     int nA[] = {2, 2, 3, 2, 3, 3};     int j = 0;     for (int i = 4; i <= n; i++) {       if (j == 6) j = 0;       if (i == n) {         cout << 1;         for (int k = 1; k < n - nA[j]; k++) {           cout <<  0 ;         }         cout << A[j];       }       j++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[100100], sir[100100];   int viz[100100], mi, ma, t, n, freq[100100], fre[100100];   int prim(int x) {     for (int i = 2; i <= x; ++i) {       if (i * i > x) return 1;       if (x % i == 0) return 0;     }     return 1;   }   int main() {     cin >> (s + 1);     n = strlen(s + 1);     for (int i = 2; i <= n; ++i) {       if (prim(i)) {         mi = ++t;         for (int j = 1; j <= n; ++j) {           if (i * j > n) break;           if (viz[i * j]) mi = min(mi, viz[i * j]);         }         if (mi != t) --t;         for (int j = 1; j <= n; ++j) {           if (i * j > n) break;           viz[i * j] = mi;         }       }     }     for (int i = 1; i <= n; ++i) freq[viz[i]]++;     for (int i = 1; i <= n; ++i) fre[s[i]]++;     for (int i = 1; i <= t; ++i) {       ma = 0;       for (int j =  a ; j <=  z ; ++j)         if (fre[j] > fre[ma]) {           ma = j;         }       if (fre[ma] >= freq[i]) {         fre[ma] -= freq[i];         for (int j = 1; j <= n; ++j)           if (viz[j] == i) s[j] = ma;       } else {         cout <<  NO ;         return 0;       }     }     t = 0;     for (int j =  a ; j <=  z ; ++j)       while (fre[j]) {         --fre[j];         sir[++t] = j;       }     for (int i = 1; i <= n; ++i)       if (!viz[i]) {         s[i] = sir[t--];       }     cout <<  YES n ;     cout << (s + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n;     cin >> n;     long long int a[n];     long long int q = 0, p = 0, z = 0;     for (int i = 0; i < n; ++i) {       cin >> a[i];       if (a[i] < 0)         q++;       else if (a[i] > 0)         p++;       else         z++;     }     long long int m1, m2, m3, m4, m5;     sort(a, a + n);     m1 = a[n - 1] * a[n - 2] * a[n - 3] * a[n - 4] * a[n - 5];     m2 = a[n - 1] * a[n - 2] * a[n - 3] * a[0] * a[1];     m3 = a[n - 1] * a[0] * a[1] * a[2] * a[3];     long long int ans = max(m1, max(m2, m3));     cout << ans <<   n ;   }   int main() {     ;     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     int t;     cin >> t;     for (int i = 1; i <= t; ++i) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 10, inf = 1e9;   int r[N], c[N], dist[N];   bool seen[N] = {0};   int main() {     int row, col, k;     cin >> row >> col >> k;     for (int i = 1; i <= k; i++) {       cin >> r[i] >> c[i];       dist[i] = inf;       if (r[i] == 1 and c[i] == 1) dist[i] = 0;     }     dist[0] = inf;     while (1) {       int cur = 0;       for (int i = 1; i <= k; i++) {         if (!seen[i] and dist[cur] > dist[i]) {           cur = i;         }       }       if (!cur) break;       seen[cur] = 1;       for (int i = 1; i <= k; i++) {         if (seen[i]) continue;         if (abs(r[i] - r[cur]) > 2 and abs(c[i] - c[cur]) > 2) continue;         int temp = 1;         if ((abs(r[i] - r[cur]) + abs(c[i] - c[cur])) == 1) temp = 0;         if (dist[cur] + temp < dist[i]) dist[i] = temp + dist[cur];       }     }     int ans = inf;     for (int i = 1; i <= k; i++) {       if (r[i] == row and c[i] == col)         ans = min(ans, dist[i]);       else if (r[i] >= row - 1 or c[i] >= col - 1)         ans = min(ans, dist[i] + 1);     }     if (ans == inf)       cout << -1;     else       cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long int _sieve_size;   bitset<10000010> bs;   vector<int> primes;   void sieve(long long int upperbound) {     _sieve_size = upperbound + 1;     bs.set();     bs[0] = bs[1] = 0;     for (long long int i = 2; i <= _sieve_size; i++)       if (bs[i]) {         for (long long int j = i * i; j <= _sieve_size; j += i) bs[j] = 0;         primes.push_back((int)i);       }   }   bool isPrime(long long int N) {     if (N <= _sieve_size) return bs[N];     for (int i = 0; i < (int)primes.size(); i++)       if (N % primes[i] == 0) return false;     return true;   }   int main() {     int h1, m1, h2, m2, oh, om;     char tmp;     cin >> h1 >> tmp >> m1;     cin >> h2 >> tmp >> m2;     om = m1 - m2;     if (om < 0) {       om += 60;       h1 -= 1;     }     oh = h1 - h2;     if (oh < 0) {       oh += 24;     }     if (oh < 10) {       cout << 0 << oh;     } else       cout << oh;     cout << tmp;     if (om < 10) {       cout << 0 << om;     } else       cout << om;     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4786)   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   char str[1000005];   int Z[1000005], n;   void Zfunction() {     int L, R, r, i, j, k;     L = 0;     R = 0;     Z[0] = 0;     for (i = 1; i < n; i++) {       if (i > R) {         L = i;         R = i;         while (R < n && str[R - L] == str[R]) R++;         Z[i] = R - L;         R--;       } else {         r = i - L;         if (Z[r] < R - i + 1)           Z[i] = Z[r];         else {           L = i;           while (R < n && str[R - L] == str[R]) R++;           Z[i] = R - L;           R--;         }       }     }   }   int max(int a, int b) {     if (a > b) return a;     return b;   }   int main() {     int i, j, k, maxr, res;     while (scanf( %s , str) != EOF) {       n = strlen(str);       maxr = 0;       res = 0;       Zfunction();       for (i = 0; i < n; i++) {         if (Z[i] == n - i) {           if (maxr >= n - i) {             res = n - i;             break;           }         }         maxr = max(maxr, Z[i]);       }       if (res == 0 || n <= 2)         printf( Just a legend n );       else {         for (i = 0; i < res; i++) printf( %c , str[i]);         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 1, M = 100;   int n, q;   bitset<N> sq[M];   vector<int> on[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> q;     for (int x = 0, qwerty = M; x < qwerty; x++) sq[x][0] = 1;     for (int x = 0, qwerty = q; x < qwerty; x++) {       int l, r, v;       cin >> l >> r >> v;       l--;       r--;       if (l / M == r / M) {         for (int i = l; i <= r; i++) on[i].push_back(v);         continue;       }       for (int i = (l / M) + 1; i < r / M; i++) {         sq[i] |= (sq[i] << v);       }       for (int i = l; i < M * ((l / M) + 1); i++) on[i].push_back(v);       for (int i = M * (r / M); i <= r; i++) on[i].push_back(v);     }     bitset<N> ans;     for (int x = 0, qwerty = n; x < qwerty; x++) {       int pos = x / M;       bitset<N> tmp = sq[pos];       for (int v : on[x]) tmp |= tmp << v;       ans |= tmp;     }     vector<int> aa;     for (int x = 1, qwerty = n + 1; x < qwerty; x++)       if (ans[x]) aa.push_back(x);     cout << ((int)(aa).size()) <<   n ;     for (int x = 0, qwerty = ((int)(aa).size()); x < qwerty; x++)       cout << aa[x] <<    n [x + 1 == ((int)(aa).size())];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<string> v;     string a;     while (n--) {       cin >> a;       v.push_back(a);     }     int cot = 0;     bool p = 1;     int ans = 1000000;     string c;     for (int j = 0; j < v.size(); j++) {       c = v[j];       cot = 0;       for (int i = 0; i < v.size(); i++) {         if (c == v[i] || i == j)           continue;         else {           int ncot = 0;           string b = v[i];           while (c != b) {             ncot++;             char d = b[0];             b.erase(b.begin());             b.push_back(d);             if (ncot > b.length()) {               p = 0;               break;             }           }           if (p == 0)             break;           else             cot += ncot;         }       }       if (p == 0) break;       if (cot < ans) {         ans = cot;       }     }     if (p)       cout << ans << endl;     else       cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline bool equal(double _x, double _y) {     return _x > _y - 1e-9 && _x < _y + 1e-9;   }   char s[300];   int mx, cnt, sum, ans;   bool OK(char c) {     if (c >=  a  && c <=  z  || c >=  A  && c <=  Z ) return 1;     return 0;   }   int main() {     int n;     scanf( %d , &n);     scanf( %s , s);     for (int l = 0, r = 0; l < n; l = r) {       if (s[l] ==  ( ) {         while (s[r] !=  ) ) r++;         for (int i = l + 1; i < r; i++) {           if (OK(s[i]) && !OK(s[i - 1])) {             cnt++;           }         }         for (int i = l + 1; i < r; i++) s[i] =  _ ;       }       r++;     }     for (int i = 0; i < n; i++) {       if (OK(s[i]))         sum++;       else         sum = 0;       ans = max(ans, sum);     }     printf( %d %d n , ans, cnt);   }
#include <bits/stdc++.h>   int ss[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};   int n, a[200], f[120][(1 << 16) + 10], b[100], g[120][(1 << 16) + 10];   void outit(int x, int y) {     if (y == 0) return;     outit(x & ~b[g[y][x]], y - 1);     printf( %d , g[y][x]);     if (y == n)       printf(  n );     else       printf(   );   }   int main() {     int x, i, j, k, ans;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     memset(b, 0, sizeof(b));     for (i = 1; i <= 58; i++)       for (j = 0; j < 16; j++)         if (i % ss[j] == 0) b[i] |= 1 << j;     for (i = 1; i <= n; i++)       for (j = 0; j < 1 << 16; j++) f[i][j] = 1000000000;     for (i = 1; i <= n; i++) {       for (j = 0; j < 1 << 16; j++) {         for (k = 1; k <= 58; k++)           if ((j & b[k]) == 0)             if (f[i][j | b[k]] > f[i - 1][j] + fabs(a[i] - k)) {               f[i][j | b[k]] = f[i - 1][j] + fabs(a[i] - k);               g[i][j | b[k]] = k;             }       }     }     ans = 1000000000;     for (i = 0; i < 1 << 16; i++)       if (f[n][i] < ans) {         ans = f[n][i];         x = i;       }     outit(x, n);     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long a, long long b) {     if (b == 0) return 1;     if (b % 2 == 0) return power(a * a % 1000000007, b / 2);     return a * power(a, b - 1) % 1000000007;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long a[100000];   int main() {     long long n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     long long ans = 0;     for (int i = 0; i < n / 2; i++) {       ans += a[i] * a[n - i - 1] * 2;       ans %= 10007;     }     if (n % 2) ans += a[n / 2] * a[n / 2];     ans %= 10007;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 101;   short dp[N][N][N * N], a[N], ans;   int n;   short calc(int u, int k, int sum) {     if (u == N) return !sum && !k;     short &ref = dp[u][k][sum];     if (ref != -1) return ref;     ref = 0;     for (short i = 0; i <= a[u] && sum - u * i >= 0 && i <= k; i++)       ref += calc(u + 1, k - i, sum - u * i);     return ref = min(ref, (short)2);   }   int main() {     scanf( %d , &n);     memset(dp, -1, sizeof dp);     int freq = 0;     for (int i = 0, a; i < n; i++) {       scanf( %d , &a);       if (!::a[a]) freq++;       ::a[a]++;     }     for (short i = 1; i < N; i++)       for (short j = 1; j <= a[i]; j++)         if (calc(1, j, i * j) == 1) {           ans = max(ans, j);           if (j == a[i] && freq == 2) ans = n;         }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300 * 1000 + 5, SQ = 373;   int a[N];   long long dp[2 * N];   pair<pair<int, int>, int> t[N];   long long finans[N];   int main() {     ios ::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     int q;     cin >> q;     for (int i = 1; i <= q; i++) {       cin >> t[i].first.second >> t[i].first.first;       t[i].second = i;     }     sort(t + 1, t + q + 1);     for (int i = 1; i <= q; i++) {       int x = t[i].first.first, y = t[i].first.second;       if (x < SQ) {         if (x != t[i - 1].first.first) {           for (int j = n; j > 0; j--) {             dp[j] = dp[j + x] + a[j];           }         }         finans[t[i].second] = dp[y];       } else {         long long ans = 0;         for (int j = y; j <= n; j += x) {           ans += a[j];         }         finans[t[i].second] = ans;       }     }     for (int i = 1; i <= q; i++) {       cout << finans[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = (long long)(1e9 + 7);   const long long inv = (long long)(5e8 + 4);   int main() {     long long n, m;     cin >> n >> m;     long long ans = (n % mod) * (m % mod) % mod;     long long l = 1, r = 1;     while (l <= min(n, m)) {       long long a = n / l;       r = min(m, n / a);       long long x1, x2, x3, x4;       x1 = (n / r) % mod;       x2 = (l + r) % mod;       x3 = (x1 * x2) % mod;       x4 = (r - l + 1) % mod;       long long temp = ((x3 * x4) % mod) * inv % mod;       ans = ((ans + mod) - temp) % mod;       l = r + 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long Mx = 512;   long long D[Mx][Mx];   int32_t main() {     long long n, m, mod, a = 0, b = 0;     cin >> n >> m >> mod;     vector<long long> C(n);     for (long long i = 0; i < m; i++)       for (long long j = 0; j < n; j++) {         char c;         cin >> c;         if (c ==  1 ) C[j]++;       }     for (long long i = 0; i < n; i++)       if (C[i] == 0)         a++;       else if (C[i] == 1)         b++;     D[0][0] = 1;     for (long long d = 1; d <= a + b; d++) {       for (long long i = 0; i <= d; i++) {         long long j = d - i;         D[i][j] =             (((i >= 2) ? ((i * (i - 1) / 2 % mod) * D[i - 2][j + 2] % mod) : 0) +              ((i >= 1) ? ((i * j % mod) * D[i - 1][j] % mod) : 0) +              ((j >= 2) ? ((j * (j - 1) / 2 % mod) * D[i][j - 2] % mod) : 0)) %             mod;       }     }     cout << D[a][b];   }
#include <bits/stdc++.h>   int n, a[200005];   bool check1(int x) {     for (int i = x + 1; i <= n; i++)       if (a[i] >= a[i - 1]) return 0;     return 1;   }   bool check2(int x) {     for (int i = x + 1; i <= n; i++)       if (a[i] <= a[i - 1]) return 0;     return 1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     if (check1(1) || check2(1)) {       printf( YES );       return 0;     }     for (int i = 2; i <= n; i++) {       if (a[i] <= a[i - 1]) {         if (check1(i))           printf( YES );         else           printf( NO );         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[105], p[105];   long long g[105];   long long d[105][105][105];   bool ok[105][105];   char c[105];   void read(int& x) {     char c = getchar();     x = 0;     while (!isdigit(c)) c = getchar();     while (isdigit(c)) {       x = x * 10 + c -  0 ;       c = getchar();     }   }   long long dp(int l, int r, int k) {     if (ok[l][r]) return d[l][r][k] = g[r - l + k + 1];     if (d[l][r][k]) return d[l][r][k];     for (int i = l; i < r; i++) {       d[l][r][k] = max(d[l][r][k], dp(l, i, 0) + dp(i + 1, r, k));     }     for (int i = l; i < p[r]; i++) {       if (c[i] == c[r] && c[i + 1] != c[r]) {         d[l][r][k] =             max(d[l][r][k], dp(l, i, k + r - p[r] + 1) + dp(i + 1, p[r] - 1, 0));       }     }     return d[l][r][k];   }   int main() {     read(n);     scanf( %s , c + 1);     for (int i = 1; i <= n; i++) {       read(a[i]);       g[i] = a[i];     }     for (int i = 1; i <= n; i++) {       for (int j = i; j >= 1; j--) {         if (c[j] == c[i]) {           p[i] = j;           ok[j][i] = 1;         } else           break;       }     }     for (int i = 2; i <= n; i++)       for (int j = 1; j < i; j++) g[i] = max(g[i], g[j] + a[i - j]);     printf( %lld n , dp(1, n, 0));   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   const long long INF = LLONG_MAX / 2;   const long long N = 2e5 + 1;   struct event {     long long sa;     long long ea;     long long sb;     long long eb;   };   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     {       long long n;       cin >> n;       vector<event> a(n);       for (long long i = 0; i < n; i++)         cin >> a[i].sa >> a[i].ea >> a[i].sb >> a[i].eb;       vector<pair<double, double> > p;       multiset<pair<double, double> > s1;       multiset<pair<double, double> > s2;       bool ans = 1;       for (long long i = 0; i < n; i++) {         p.push_back({a[i].sa, i});         p.push_back({a[i].ea + 0.5, i});       }       sort(p.begin(), p.end());       for (auto i : p) {         pair<double, double> c = {a[i.second].sb, a[i.second].eb};         if (s1.count(c)) {           s1.erase(s1.find(c));           s2.erase(s2.find({c.second, c.first}));         } else {           if (s1.empty() || (*s1.rbegin()).first <= c.second &&                                 (*s2.begin()).first >= c.first) {             s1.insert(c);             s2.insert({c.second, c.first});           } else {             ans = 0;             break;           }         }       }       s1.clear();       s2.clear();       p = vector<pair<double, double> >(0);       for (long long i = 0; i < n; i++) {         p.push_back({a[i].sb, i});         p.push_back({a[i].eb + 0.5, i});       }       sort(p.begin(), p.end());       for (auto i : p) {         pair<double, double> c = {a[i.second].sa, a[i.second].ea};         if (s1.count(c)) {           s1.erase(s1.find(c));           s2.erase(s2.find({c.second, c.first}));         } else {           if (s1.empty() || (*s1.rbegin()).first <= c.second &&                                 (*s2.begin()).first >= c.first) {             s1.insert(c);             s2.insert({c.second, c.first});           } else {             ans = 0;             break;           }         }       }       if (ans)         cout <<  YES ;       else         cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, arr[300010], lft[300010], rgt[300010], mx = 0, cnt = 0;   stack<long long> s1, s2;   set<long long> st;   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> arr[i];     for (int i = 0; i < n; i++) lft[i] = -1, rgt[i] = n;     for (int i = 0; i < n; i++) {       while (!s1.empty() && (arr[i] % arr[s1.top()])) rgt[s1.top()] = i, s1.pop();       s1.push(i);     }     for (int i = n - 1; i >= 0; i--) {       while (!s2.empty() && (arr[i] % arr[s2.top()])) lft[s2.top()] = i, s2.pop();       s2.push(i);     }     for (int i = 0; i < n; i++) mx = max(mx, rgt[i] - lft[i] - 2);     for (int i = 0; i < n; i++)       if (rgt[i] - lft[i] - 2 == mx) st.insert(lft[i] + 2);     cout << st.size() <<     << mx <<   n ;     for (auto u : st) cout << u <<    ;     return 0;   }