malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   int a[52], b[52];   int main() {     int x, max, k, n, m, i, j, c1;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     scanf( %d , &m);     for (i = 0; i < m; i++) {       scanf( %d , &b[i]);     }     max = 0;     for (i = 0; i < m; i++) {       for (j = 0; j < n; j++) {         if ((b[i] % a[j]) == 0) {           k = (b[i] / a[j]);           if (k >= max) {             max = k;           }         }       }     }     c1 = 0;     x = 0;     for (i = 0; i < m; i++) {       for (j = 0; j < n; j++) {         x = (b[i] / a[j]);         if (x == max && (b[i] % a[j] == 0)) c1++;       }     }     printf( %d , c1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> a[2001];   int f[2000], ok, n, px, ok2;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i].first;       a[i].second = i;       f[a[i].first]++;       if (f[a[i].first] == 2) ok++;       if (f[a[i].first] == 3) ok2++;     }     if (ok < 2 && ok2 == 0)       cout <<  NO ;     else {       cout <<  YES n ;       sort(a + 1, a + 1 + n);       for (int i = 1; i <= n; i++) {         cout << a[i].second <<    ;         if (f[a[i].first] >= 2) {           px = i;         }       }       cout <<   n ;       swap(a[px], a[px - 1]);       for (int i = 1; i <= n; i++) {         cout << a[i].second <<    ;       }       for (int i = 1; i <= n; i++) {         if (f[a[i].first] >= 2) {           px = i;           break;         }       }       cout <<   n ;       swap(a[px], a[px + 1]);       for (int i = 1; i <= n; i++) {         cout << a[i].second <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   ifstream f( dima1.in );   ofstream g( dima1.out );   int n, a[200005], b[200005], b2[200005], k, ap[200005], ap2[200005], ok, m, p,       spos[200005], sol = 0;   vector<int> r[200005];   vector<int> ps[200005];   int Cbin(int x) {     int i, j, st = 1, dr = k, mid;     while (st < dr) {       mid = (st + dr) / 2;       if (x < b2[mid])         dr = mid - 1;       else if (x > b2[mid])         st = mid + 1;       else if (x == b2[mid])         return mid;     }     mid = (st + dr) / 2;     if (b2[mid] == x)       return mid;     else       return 0;   }   int main() {     int i, j, pos, ok;     cin >> n >> m >> p;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= m; i++) cin >> b[i];     sort(b + 1, b + m + 1);     b2[1] = b[1];     k = 1;     ap[1] = 1;     for (i = 2; i <= m; i++) {       if (b[i] == b2[k])         ap[k]++;       else {         k++;         b2[k] = b[i];         ap[k] = 1;       }     }     for (i = 1; i <= n; i++) {       pos = Cbin(a[i]);       a[i] = pos;     }     for (i = 1; i <= n; i++) {       if (r[i % p].size() == 0) {         r[i % p].push_back(0);         ps[i % p].push_back(0);       }       r[i % p].push_back(a[i]);       ps[i % p].push_back(i);     }     for (i = 0; i < p; i++)       if ((r[i].size() - 1) >= m) {         ok = 0;         for (j = 1; j < r[i].size(); j++) {           if (r[i][j] != 0) {             if (ap2[r[i][j]] == ap[r[i][j]])               ok--;             else if (ap2[r[i][j]] + 1 == ap[r[i][j]])               ok++;             ap2[r[i][j]]++;           }           if (j > m) {             if (r[i][j - m] != 0) {               if (ap2[r[i][j - m]] == ap[r[i][j - m]])                 ok--;               else if (ap2[r[i][j - m]] - 1 == ap[r[i][j - m]])                 ok++;               ap2[r[i][j - m]]--;             }           }           if (j >= m && ok == k) {             sol++;             spos[sol] = ps[i][j - m + 1];           }         }         for (j = r[i].size() - 1; j >= 1; j--) ap2[r[i][j]] = 0;       }     sort(spos + 1, spos + sol + 1);     cout << sol <<   n ;     for (i = 1; i <= sol; i++) cout << spos[i] <<    ;     return 0;   }
#include<bits/stdc++.h>   #define fre(x) freopen(#x .in , r ,stdin);freopen(#x .out , w ,stdout)   #define ll long long   using namespace std;   inline int read(){    int x=0,f=1;char c=getchar();    while(c< 0 ||c> 9 ) { if(c== - ) f=-1;c=getchar(); }    while(c>= 0 &&c<= 9 ) x=(x<<3)+(x<<1)+(c^ 0 ),c=getchar();    return x*f;   }   const int N=1e5+5;   int n,l[N],r[N];   ll f[N][2];   vector<int>e[N];   void dfs(int x,int fa){    f[x][0]=f[x][1]=0;    for(auto y:e[x]) if(y^fa){     dfs(y,x);     f[x][0]+=max(f[y][0]+abs(l[x]-l[y]),f[y][1]+abs(l[x]-r[y]));     f[x][1]+=max(f[y][0]+abs(r[x]-l[y]),f[y][1]+abs(r[x]-r[y]));    }   }   inline void solve(){    n=read();    for(int i=1;i<=n;i++) l[i]=read(),r[i]=read(),e[i].clear();    for(int i=1;i<n;i++){     int x=read(),y=read();     e[x].push_back(y);     e[y].push_back(x);    }    dfs(1,0);    printf( %lld n ,max(f[1][0],f[1][1]));   }   int main(){    int T=read();    while(T--) solve();    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   int d[100015];   char baca[100015];   int main() {     scanf( %d %d , &n, &k);     scanf( %s , baca);     for (int i = (int)1; i <= (int)n; ++i) d[i] = (int)(baca[i - 1] -  0 );     d[0] = d[n + 1] = 0;     for (int i = (int)1; i <= (int)n; ++i) {       if (!k) break;       if (d[i] == 4 && d[i + 1] == 7) {         if (i % 2 == 1) {           if (d[i + 2] == 7) {             if (k % 2 == 0)               break;             else {               d[i + 1] = 4;               break;             }           } else             d[i + 1] = 4;         } else {           if (d[i - 1] == 4) {             if (k % 2 == 0)               break;             else {               d[i] = 7;               break;             }           } else             d[i] = 7;         }         k--;       }     }     for (int i = (int)1; i <= (int)n; ++i) printf( %d , d[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000005;   int v[N], c[N];   int n, k;   vector<int> z;   void input() {     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &v[i]);     for (int i = 1; i <= n; i++) scanf( %d , &c[i]);     z.push_back(min(100 * v[n], c[n]));     for (int i = n - 1; i >= 1; i--) {       int larger = max(z.back(), v[i] * 100);       int smaller = min(larger, c[i]);       z.push_back(min(larger, smaller));     }   }   void pro() {     sort(z.begin(), z.end());     double ans = 0;     double chance = 1;     for (int i = 0; i < k; i++) {       ans += z[i] * chance * k / (n - i);       chance *= 1. * (n - k - i) / (n - i);     }     cout << fixed << setprecision(10) << ans << endl;   }   int main() {     input();     pro();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     cin >> n >> m >> k;     vector<int> v(n, 0);     for (int i = 0; i < n; i++) {       cin >> v[i];     }     m--;     int p = -1;     for (int i = m + 1; i < n; i++) {       if (v[i] != 0 && v[i] <= k) {         if (p == -1 || abs(m - i) < abs(m - p)) {           p = i;         }       }     }     for (int i = m - 1; i >= 0; i--) {       if (v[i] != 0 && v[i] <= k) {         if (p == -1 || abs(m - i) < abs(m - p)) {           p = i;         }       }     }     cout << abs(m - p) * 10 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a;   int gcd(int a, int b) {     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   void solve() {     int temp, sum = 0, m, i;     for (i = 2; i < a; i++) {       temp = a;       while (temp) {         sum += temp % i;         temp = temp / i;       }     }     m = gcd(sum, a - 2);     printf( %d/%d n , sum / m, (a - 2) / m);   }   int main() {     while (scanf( %d , &a) == 1) {       solve();     }     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   long long res1, res2, f[5][5];   string s;   int main() {     std::ios::sync_with_stdio(false);     cin >> s;     n = s.size();     for (int i = 0; i < (n); i++) {       f[s[i] -  a ][i % 2]++;       res1 += f[s[i] -  a ][1 - (i % 2)];       res2 += f[s[i] -  a ][i % 2];     }     cout << res1 <<     << res2 << endl;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mxn = 3e5 + 5;   const long long MOD = 1e9 + 7;   const int BASE = 100000000;   const int INF = 1e9 + 8;   long long g[mxn], cnt[mxn], a[mxn];   void up_g(int x, const long long &val) {     while (x < mxn) {       g[x] += val;       x += x & (-x);     }   }   void update_g(int l, int r, const long long &val) {     up_g(l, val);     up_g(r + 1, -val);   }   long long get_g(int x) {     long long res = 0;     while (x) {       res += g[x];       x -= x & (-x);     }     return res;   }   void update_cnt(int x) {     while (x < mxn) {       cnt[x] += 1LL;       x += x & (-x);     }   }   long long get(int x) {     long long res = 0;     while (x) {       res += cnt[x];       x -= x & (-x);     }     return res;   }   long long get_cnt(int l, int r) { return (get(r) - get(l - 1)); }   signed main() {     int n;     cin >> n;     for (int i = (1); i <= (n); ++i) cin >> a[i];     long long cur = 0, sum = 0;     for (int i = (1); i <= (n); ++i) {       cur += (long long)(i - 1) * a[i] - get_g(a[i]);       cur += sum;       int x = (int)(a[i]);       while (x < mxn) {         long long k = min(x + (int)(a[i]) - 1, (int)(mxn - 5));         cur -= (long long)(x)*get_cnt(x, k);         update_g(x, k, x);         x += a[i];       }       update_cnt(a[i]);       sum += a[i];       cout << cur <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, i, j;     cin >> n >> m;     for (i = 1; i <= n; i++) {       for (j = 0; j < m; j++) {         if (i % 4 == 0) {           if (j == 0)             cout <<  # ;           else             cout <<  . ;         } else if (i % 4 == 2) {           if (j == m - 1)             cout <<  # ;           else             cout <<  . ;         } else {           cout <<  # ;         }       }       cout << endl;     }   }
#include <bits/stdc++.h>   int main() {     int c, input[100010];     int i = -1, j, k;     while ((c = getchar()) !=   n ) {       if (i < 0 || input[i] != c)         input[++i] = c;       else         i--;     }     if (i < 0)       printf( Yes n );     else       printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int SIZE = 1 << 10;   int pointer = SIZE;   char buffer[SIZE];   char Advance() {     if (pointer == SIZE) {       fread(buffer, 1, SIZE, stdin);       pointer = 0;     }     return buffer[pointer++];   }   int Read() {     int answer = 0;     char ch = Advance();     while (!isdigit(ch)) ch = Advance();     while (isdigit(ch)) {       answer = answer * 10 + ch -  0 ;       ch = Advance();     }     return answer;   }   const int MAXN = 5000;   const long long MOD = 1000000007;   void Add(int &x, int y) {     x += y;     if (x >= MOD) x -= MOD;   }   void Subtract(int &x, int y) {     x -= y;     if (x < 0) x += MOD;   }   int factorial[1 + MAXN], inverse[1 + MAXN];   int RaiseToPower(int base, int power) {     int answer = 1;     while (power) {       if (power % 2) answer = (1LL * answer * base) % MOD;       base = (1LL * base * base) % MOD;       power /= 2;     }     return answer;   }   int Combinations2(int n) {     if (n % 2 == 0)       return (1LL * (n / 2) * (n - 1)) % MOD;     else       return (1LL * n * ((n - 1) / 2)) % MOD;   }   int children[1 + MAXN], depth[1 + MAXN];   int answer[1 + 2 * MAXN], chains[1 + 2 * MAXN];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i < n; i++) scanf( %d , &children[i]);     depth[1] = 1;     for (int i = 2; i <= n; i++)       depth[i] = (1LL * depth[i - 1] * children[i - 1]) % MOD;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         chains[i + j] = (1LL * depth[i] * depth[j] + chains[i + j]) % MOD;     int multiplier = 1;     for (int i = 1; i < n; i++) {       int divide = RaiseToPower(children[i], MOD - 2);       for (int j = i + 1; j <= n; j++) {         int add = (1LL * multiplier * depth[j]) % MOD;         Add(answer[j - i], add);         Subtract(chains[j - i + 2], (2LL * depth[j] * depth[i]) % MOD);         depth[j] = (1LL * depth[j] * divide) % MOD;       }       divide = (1LL * divide * divide) % MOD;       for (int j = 2; j <= 2 * (n - i); j++) {         chains[j] = (1LL * chains[j + 2] * divide) % MOD;         int add = (1LL * chains[j] * Combinations2(children[i])) % MOD;         add = (1LL * add * multiplier) % MOD;         Add(answer[j], add);       }       multiplier = (1LL * multiplier * children[i]) % MOD;     }     for (int i = 1; i <= 2 * n - 2; i++) printf( %d  , answer[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int a[200010], b[200010];   int nxt[200010];   void make_next() {     int i = 0, j = -1;     nxt[0] = -1;     while (i < m) {       if (j == -1 || b[i] == b[j]) {         i++;         j++;         if (b[i] == b[j])           nxt[i] = nxt[j];         else           nxt[i] = j;       } else         j = nxt[j];     }   }   int kmp() {     int i = 0, j = 0;     int cnt = 0;     while (i < n) {       if (a[i] == b[j]) {         i++;         j++;         if (j == m) {           cnt++;         }       } else {         j = nxt[j];         if (j == -1) {           i++;           j = 0;         }       }     }     return cnt;   }   int main() {     int i, j;     while (cin >> n >> m) {       for (i = 0; i < n; i++) cin >> a[i];       for (i = 0; i < m; i++) cin >> b[i];       if (n < m) {         cout <<  0 n ;         continue;       } else if (m == 1) {         cout << n << endl;         continue;       }       for (i = 0; i < n - 1; i++) a[i] = a[i + 1] - a[i];       for (i = 0; i < m - 1; i++) b[i] = b[i + 1] - b[i];       m--;       n--;       make_next();       cout << kmp() << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int SIZE = 1e5 + 5;   long long n, m, s;   vector<pair<long long, long long> > bug;   vector<pair<long long, long long> > stud;   vector<long long> pass;   long long allot[SIZE];   struct cmp {     bool operator()(pair<long long, long long> const& lhs,                     pair<long long, long long> const& rhs) {       return lhs.first < rhs.first;     }   };   long long ok(long long val) {     long long i = 0;     long long j = 0;     long long temp = s;     priority_queue<pair<long long, long long>,                    vector<pair<long long, long long> >,                    greater<pair<long long, long long> > >         pq;     while (i < bug.size()) {       while (stud[j].first >= bug[i].first && j < stud.size()) {         pq.push(make_pair(pass[stud[j].second], stud[j].second));         j++;       }       if (pq.size() == 0) return 0;       pair<long long, long long> cheap = pq.top();       pq.pop();       if (temp < cheap.first) return 0;       temp -= cheap.first;       long long days = 0;       while (i < bug.size() && days < val) {         allot[bug[i].second] = cheap.second;         i++;         days++;       }     }     return 1;   }   long long lowerbound(long long l, long long h) {     long long mid = (l + h) / 2;     if (l == h) return mid;     if (ok(mid)) {       return lowerbound(l, mid);     } else       return lowerbound(mid + 1, h);   }   int main() {     cin.sync_with_stdio(0);     cin >> n >> m >> s;     for (int i = 0; i <= m - 1; i++) {       long long a;       cin >> a;       bug.push_back(make_pair(a, i));     }     sort(bug.begin(), bug.end());     reverse(bug.begin(), bug.end());     for (int i = 0; i <= n - 1; i++) {       long long a;       cin >> a;       stud.push_back(make_pair(a, i));     }     sort(stud.begin(), stud.end());     reverse(stud.begin(), stud.end());     for (int i = 0; i <= n - 1; i++) {       long long a;       cin >> a;       pass.push_back(a);     }     long long l = 0;     long long h = bug.size();     long long temp = lowerbound(l, h);     if (ok(temp)) {       cout <<  YES n ;       for (int i = 0; i <= m - 1; i++) cout << allot[i] + 1 <<    ;     } else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mat[100001], mat2[100001];   long long k, suma, a, b, s, c;   int n;   map<int, int> mapa;   long long ct;   int main() {     cin >> n >> k;     for (int i = 0; i < n; ++i) {       cin >> mat[i];       mapa[mat[i]]++;     }     sort(mat, mat + n);     suma = 1;     c = 1;     for (int i = 0; i < n; i++) {       if (i == 0) {       } else if (mat[i] == mat[i - 1]) {         suma += n;         continue;       }       ct = mapa[mat[i]];       if (suma + ct * n > k) {         a = mat[i];         s = k - suma;         b = mat[(int)(s / ct)];         break;       }       suma += n;     }     cout << a <<     << b << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxm = 1e5 + 5;   vector<int> g[maxm];   int n, q;   int sz[maxm];   int d[maxm];   int f[maxm][25];   const int maxd = 20;   void dfs(int x, int fa) {     sz[x] = 1;     for (int j = 1; j <= maxd; j++) {       f[x][j] = f[f[x][j - 1]][j - 1];     }     for (int v : g[x]) {       if (v == fa) continue;       d[v] = d[x] + 1;       f[v][0] = x;       dfs(v, x);       sz[x] += sz[v];     }   }   int lca(int a, int b) {     if (d[a] < d[b]) swap(a, b);     for (int i = maxd; i >= 0; i--) {       if (d[f[a][i]] >= d[b]) {         a = f[a][i];       }     }     if (a == b) return a;     for (int i = maxd; i >= 0; i--) {       if (f[a][i] != f[b][i]) {         a = f[a][i];         b = f[b][i];       }     }     return f[a][0];   }   signed main() {     ios::sync_with_stdio(0);     cin >> n;     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     d[1] = 1;     f[1][0] = 1;     dfs(1, 1);     cin >> q;     while (q--) {       int a, b;       cin >> a >> b;       if (a == b) {         cout << n << endl;         continue;       }       int lc = lca(a, b);       int dab = d[a] + d[b] - 2 * d[lc];       if (dab % 2) {         cout << 0 << endl;         continue;       }       if (d[a] < d[b]) swap(a, b);       int dist = dab / 2;       for (int i = maxd; i >= 0; i--) {         if (dist - (1 << i) > 0) {           a = f[a][i];           b = f[b][i];           dist -= (1 << i);         }       }       if (d[a] == d[b]) {         cout << n - sz[a] - sz[b] << endl;         continue;       }       cout << sz[f[a][0]] - sz[a] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC optimize( no-stack-protector )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native )   #pragma GCC optimize( fast-math )   const long long N = 1e6 + 5;   const long double EPS = 1e-12;   const long long INF = 2e18 + 5;   const long long MOD = 1e9 + 7;   const long double PI = 3.14159265358979323;   vector<set<long long> > g;   vector<pair<long long, long long> > a;   vector<long long> ans, u;   void dfs(long long v) {     u[v] = 1;     for (auto &i : g[v])       if (!u[i]) dfs(i);     ans.push_back(v);   }   void topsort(long long n) {     ans.clear();     for (long long i = 0; i < n; i++) {       if (!u[i]) dfs(i);     }     reverse(ans.begin(), ans.end());   }   bool bin(long long n, long long m) {     for (long long i = 0; i < n; i++) {       g[i].clear();       u[i] = 0;     }     for (long long i = 0; i < m; i++) {       g[a[i].first].insert(a[i].second);     }     topsort(n);     for (long long i = 0; i + 1 < ans.size(); i++) {       if (g[ans[i]].find(ans[i + 1]) == g[ans[i]].end()) return 0;     }     return 1;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long ttt = 1;     for (; ttt; --ttt) {       long long n, m;       cin >> n >> m;       a.resize(m);       g.resize(n);       u.resize(n);       for (long long i = 0; i < m; i++) {         cin >> a[i].first >> a[i].second;         a[i].first--;         a[i].second--;       }       if (!bin(n, m)) {         return cout <<  -1 n , 0;       }       long long l = 1, r = m;       while (r - l > 1) {         long long mid = (l + r) / 2;         if (mid <= m && bin(n, mid))           r = mid;         else           l = mid;       }       if (bin(n, l))         cout << l <<   n ;       else         cout << r <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, *a, *b, times, i, day;     while (cin >> n >> m) {       a = new int[m];       b = new int[m];       times = 1;       for (i = 0; i < m; i++) cin >> a[i] >> b[i];       for (i = 0; i < m - 1; i++) {         if (b[i] != a[i + 1] - 1) break;       }       if (i + 1 == m && b[i] == n)         cout <<  OK  << endl;       else {         if (a[0] != 1) {           day = 1;           times--;         } else if (b[i] == a[i + 1]) {           day = b[i];           while (b[i] == a[i + 1] && b[i] == day) {             times++;             i++;           }         } else {           day = b[i] + 1;           times--;         }         cout << day <<     << times << endl;       }       delete[] a;       delete[] b;     }     return 0;   }
#include <bits/stdc++.h>   const int a[] = {4,   22,  27,  58,  85,  94,   121,  166, 202, 265, 274,                    319, 346, 355, 378, 382, 391,  438,  454, 483, 517, 526,                    535, 562, 576, 588, 627, 634,  636,  645, 648, 654, 663,                    666, 690, 706, 728, 729, 762,  778,  825, 852, 861, 895,                    913, 915, 922, 958, 985, 1086, 1111, 1165};   int main(int n) {     scanf( %d , &n);     printf( %d , a[n - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     char m[11], digit[10] = { 0 }, digitcount(0);     scanf( %d%s , &n, &m);     while (n != 0) {       digit[digitcount++] =  0  + n % 10;       n /= 10;     }     sort(digit, digit + digitcount);     if (digit[0] ==  0 ) {       for (int i = 1; i < digitcount; ++i) {         if (digit[i] !=  0 ) {           digit[0] = digit[i];           digit[i] =  0 ;           break;         }       }     }     if (strcmp(m, digit) == 0)       cout <<  OK  << endl;     else       cout <<  WRONG_ANSWER  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 1000 + 10;   int n, flag, a[maxN], i, j, m;   int main() {     cin >> n;     for (i = 2; i <= n; i++) {       for (j = 2; j * j <= i; j++) {         if (i != j && i % j == 0) flag = 1;       }       j = i;       while (flag == 0 && j <= n) {         a[m++] = j;         j *= i;       }       flag = 0;     }     cout << m << endl;     for (int k = 0; k < m; k++) cout << a[k] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (a < 0) a = -a;     if (b < 0) b = -b;     return b == 0 ? a : gcd(b, a % b);   }   template <typename T>   void read(T &res) {     bool flag = false;     char ch;     while (!isdigit(ch = getchar())) (ch ==  - ) && (flag = true);     for (res = ch - 48; isdigit(ch = getchar());          res = (res << 1) + (res << 3) + ch - 48)       ;     flag && (res = -res);   }   long long lcm(long long a, long long b) { return a * b / gcd(a, b); }   long long qp(long long a, long long b, long long mod) {     long long ans = 1;     if (b == 0) {       return ans % mod;     }     while (b) {       if (b % 2 == 1) {         b--;         ans = ans * a % mod;       }       a = a * a % mod;       b = b / 2;     }     return ans % mod;   }   long long qpn(long long a, long long b, long long p) {     long long ans = 1;     a %= p;     while (b) {       if (b & 1) {         ans = (ans * a) % p;         --b;       }       a = (a * a) % p;       b >>= 1;     }     return ans % p;   }   set<long long> s;   signed main() {     long long t;     read(t);     while (t--) {       long long n;       read(n);       long long po = 0;       s.insert(po);       for (long long i = 1; i * i <= n; i++) {         s.insert(n / i);         s.insert(n / (n / i));       }       printf( %d n , s.size());       for (auto x : s) {         printf( %lld  , x);       }       s.clear();       printf(  n );     }   }