malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:268435456 )   using namespace std;   template <typename T1, typename T2>   istream& operator>>(istream& in, pair<T1, T2>& t) {     return in >> t.first >> t.second;   }   template <typename T1, typename T2>   ostream& operator<<(ostream& out, pair<T1, T2>& t) {     return out << t.first <<     << t.second << endl;   }   template <typename T>   istream& operator>>(istream& in, vector<T>& t) {     for (long long i = 0; i < t.size(); i++) in >> t[i];     return in;   }   template <typename T>   ostream& operator<<(ostream& out, vector<T>& t) {     for (long long i = 0; i < t.size(); i++) out << t[i] <<    ;     return out;   }   long long n, d, k;   vector<vector<long long> > g;   long long in = 1;   void printg(long long x, long long p = -1) {     for (long long to : g[x]) {       cout << x + 1 <<     << to + 1 << endl;       printg(to, x);     }   }   void con(long long x) {     g[x].push_back(in++);     if (in >= n) {       puts( YES );       printg(0);       exit(0);     }   }   void add(long long h) {     long long t = 0;     for (long long i = 1; i <= h; ++i) {       con(t);       t = in - 1;     }   }   void build(long long x, long long p, long long h, long long curh = 1) {     if (curh >= h) return;     for (long long i : g[x]) {       build(i, x, h, curh + 1);     }     while (g[x].size() < k - 1) {       con(x);       build(in - 1, x, h, curh + 1);     }   }   signed main() {     long long rrrr = 1e5;     cin >> n >> d >> k;     d++;     if (n < d) return puts( NO ), 0;     if (k == 1) {       if (n == d && n == 2) {         cout <<  YES  << endl;         for (long long i = 0; i < n - 1; ++i) {           cout << i + 1 <<     << i + 2 << endl;         }         return 0;       } else         return puts( NO ), 0;     }     --d;     g.resize(n);     add(d / 2);     add((d + 1) / 2);     build(g[0][0], 0, d / 2);     build(g[0][1], 0, (d + 1) / 2);     for (long long i = 2; i < k; ++i) {       if (d / 2 == 0) continue;       con(0);       build(in - 1, 0, d / 2);     }     cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,unroll-loops )   using namespace std;   const int maxn = 15e4 + 7, blo = 255, mo = 998244353;   int n, q, cl = 0, p[maxn], sz[maxn], lb[maxn], rb[maxn];   int_fast64_t inv, one = 0, rec[maxn], dat[maxn];   vector<int> vt, g[maxn];   vector<vector<int>> hsz;   inline int qp(int_fast64_t x, int t = mo - 2) {     int_fast64_t re = 1;     while (t) {       if (t & 1) re = re * x % mo;       x = x * x % mo, t >>= 1;     }     return re;   }   inline void add(int i, int x) {     for (; i <= cl + 1; i += i & -i) {       dat[i] += x;       if (dat[i] >= mo) dat[i] -= mo;     }   }   inline int sum(int i) {     int_fast64_t re = 0;     for (; i > 0; i -= i & -i) {       re += dat[i];     }     re += one;     return re % mo;   }   void dfs(int u, int f) {     lb[u] = cl++;     sz[u] = 1;     p[u] = f;     for (register int i = (0); i < (g[u].size()); ++i) {       int& v = g[u][i];       if (v == f) continue;       dfs(v, u);       sz[u] += sz[v];     }     rb[u] = cl;   }   void gsz(int u, int f, int k) {     hsz.back()[u] = k;     for (register int i = (0); i < (g[u].size()); ++i) {       int& v = g[u][i];       if (v == f) continue;       gsz(v, u, k);     }   }   int main() {     cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false);     cin >> n >> q;     inv = qp(n);     for (register int i = (1); i < (n); ++i) {       int u, v;       cin >> u >> v, --u, --v;       g[u].emplace_back(v), g[v].emplace_back(u);     }     dfs(0, -1);     for (register int i = (0); i < (n); ++i) {       if (g[i].size() > blo) {         vt.emplace_back(i);         hsz.emplace_back(*new vector<int>);         hsz.back().reserve(n);         int s = 0;         for (register int j = (0); j < (g[i].size()); ++j) {           int& v = g[i][j];           if (v == p[i]) continue;           gsz(v, i, sz[v]);           s += sz[v];         }         if (p[i] >= 0) gsz(p[i], i, n - s - 1);         hsz.back()[i] = 0;       }     }     while (q--) {       int_fast64_t t, v, d, di;       cin >> t >> v, --v;       if (t == 1) {         cin >> d;         if (g[v].size() > blo) {           rec[v] += d;           if (rec[v] >= mo) rec[v] -= mo;         } else {           di = d * inv % mo;           for (register int i = (0); i < (g[v].size()); ++i) {             int& u = g[v][i];             int x = di * (n - sz[u]) % mo;             if (u == p[v]) continue;             add(lb[u] + 1, x);             add(rb[u] + 1, mo - x);           }           int x = di * sz[v] % mo;           one += x;           add(lb[v] + 1, d < x ? mo + d - x : d - x);           add(rb[v] + 1, x);           add(lb[v] + 2, mo - d);         }       } else {         int_fast64_t res = 0;         for (register int i = (0); i < (vt.size()); ++i) {           res += rec[vt[i]] * (n - hsz[i][v]) % mo;         }         cout << (res % mo * inv + sum(lb[v] + 1)) % mo <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 10;   const int base = 31337;   const int mod = 1e9 + 7;   const int inf = 0x3f3f3f3f;   const int logo = 20;   const int off = 1 << logo;   const int treesiz = off << 1;   int n;   char niz[maxn];   int his[maxn];   int main() {     scanf( %d%s , &n, niz);     long long sol = 0;     long long tren = 0;     memset(his, -1, sizeof his);     for (int i = 0; i < n; i++) {       if (niz[i] ==  0 )         sol += tren;       else {         int ptr = i;         while (ptr + 1 < n && niz[ptr + 1] ==  1 ) ptr++;         int cnt = 1;         for (int j = i; j <= ptr; j++) {           tren += j - his[cnt];           his[cnt] = ptr - cnt + 1;           sol += tren;           cnt++;         }         i = ptr;       }     }     printf( %lld n , sol);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, z;     cin >> x >> y >> z;     if (x > y + z)       cout <<  +  << endl;     else if (y > x + z)       cout <<  -  << endl;     else if (x == y && z == 0)       cout <<  0  << endl;     else       cout <<  ?  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int ampow(int k, int p) {     long long int ans = 1;     for (int i = 0; i < p; i++) {       ans *= k;     }     return ans;   }   int main() {     std::ios::sync_with_stdio(false);     long long int k, b, n, t, z, i;     cin >> k >> b >> n >> t;     if (k == 1) {       z = 1 + (n * b);       if (t >= z)         i = 0;       else         i = ceil(((double)z - t) / b);     } else {       double c = (double)b / (k - 1);       if (log(t + c) - (n * log(k) + log(c + 1)) >= 0)         i = 0;       else if (abs(log(t + c) - (n * log(k) + log(c + 1))) <= 0.0000000001)         i = 0;       else {         double num = n * log(k) + log(c + 1) - log(t + c);         double den = log((double)k);         i = ceil(num / den);         if (i - (num / den) >= 0.9999999999) i--;       }     }     cout << i << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool f(int a, string s) {     vector<char> v;     int tmp;     int ss = (s.size() - 1);     while (a) {       tmp = a % 10;       if (tmp == 7) v.push_back( 7 );       if (tmp == 4) v.push_back( 4 );       a /= 10;     }     if (v.size() != s.size()) return false;     for (int i = 0; i < s.size(); i++) {       if (s[i] != v[s.size() - i - 1]) return false;     }     return true;   }   int main() {     int a;     string s;     cin >> a >> s;     for (int i = (a + 1); i <= 100000000; i++) {       if (f(i, s)) {         cout << i << endl;         return 0;       }     }   }
#include <bits/stdc++.h>   int main() {     int n, a, b;     scanf( %d%d%d , &n, &a, &b);     for (int i = 1; i <= n; i++) {       long long x;       scanf( %I64d , &x);       x = ((x * a) % b) / a;       printf( %I64d  , x);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     long long p(1);     cin >> a >> b;     while (b--) p = (p << 1ll) % 1000000009ll;     long long ans(1);     while (a--) {       p--;       if (p < 0) p += 1000000009ll;       ans *= p;       ans %= 1000000009ll;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   const int MAXN = 500000;   int A[MAXN + 10];   int main() {     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &A[i]);     A[n + 1] = INT_MAX;     A[0] = INT_MIN;     sort(A + 1, A + n + 1);     int l = 1, r = n;     for (l = 2; l <= n && A[l] == A[l - 1]; l++)       ;     l--;     int days = k;     while (l <= n) {       long long d = l * (long long)(A[l + 1] - A[l]);       if (d <= days) {         days -= d;         A[l] = A[l + 1];         while (l <= n && A[l] == A[l + 1]) l++;       } else {         long long m = days / l, M = days % l, v = A[l] + m;         for (int i = 1; i <= l; i++) A[i] = v;         for (int i = 0; i < M; i++) A[l - i] = v + 1LL;         break;       }     }     for (r = n - 1; r > 0 && A[r] == A[r + 1]; r--)       ;     r++;     days = k;     while (r > 0) {       long long d = (n - r + 1) * ((long long)A[r] - (long long)A[r - 1]);       if (d <= days) {         days -= d;         A[r] = A[r - 1];         while (r > 0 && A[r] == A[r - 1]) r--;       } else {         long long m = days / (n - r + 1), M = days % (n - r + 1), v = A[r] - m;         for (int i = r; i <= n; i++) A[i] = v;         for (int i = 0; i < M; i++) A[r + i] = v - 1LL;         break;       }     }     printf( %d n , A[n] - A[1]);     return 0;   }
#include <bits/stdc++.h>   const int INF_INT = 0x3f3f3f3f;   const long long INF_LL = 0x7f7f7f7f;   const int MOD = 1e9 + 7;   const double eps = 1e-10;   const double pi = acos(-1);   using namespace std;   const int N = 200010;   long long n, k;   long long fac[N], inv[N];   long long ksm(long long a, long long x, long long mod) {     if (x == 0) return 1;     long long ret = ksm(a, x / 2, mod);     ret = ret * ret % mod;     if (x & 1) ret = ret * a % mod;     return ret;   }   void init() {     fac[0] = 1;     inv[0] = 1;     for (long long i = 1; i < N; i++) {       fac[i] = fac[i - 1] * i % MOD;       inv[i] = ksm(fac[i], MOD - 2, MOD);     }   }   map<int, int> mp;   long long C(long long n, long long k) {     long long ret = fac[n] * inv[k] % MOD;     ret = ret * inv[n - k] % MOD;     return ret;   }   int main(int argc, char const *argv[]) {     init();     while (cin >> n >> k) {       mp.clear();       for (int i = 1; i <= n; i++) {         int l, r;         scanf( %d%d , &l, &r);         mp[l]++;         mp[r + 1]--;       }       int last = mp.begin()->first;       int tmp = 0;       long long ans = 0;       for (auto it = mp.begin(); it != mp.end(); it++) {         long long num = it->first - last;         if (tmp >= k) ans += C(tmp, k) * num % MOD;         ans %= MOD;         tmp += it->second;         last = it->first;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int P = 1e9 + 7, N = 17, M = 16389, O = 131;   int qp(int a, int b) {     int r = 1;     for (; b; b >>= 1, a = a * 1ll * a % P)       if (b & 1) r = r * 1ll * a % P;     return r;   }   int a[N], e[N][N], p[M], n, ll[O][O], lr[O][O], rl[O][O], rr[O][O];   int g(int x, int y) {     int i, j, s = 1;     for (i = 0; i < n; ++i)       if (x >> i & 1)         for (j = 0; j < n; ++j)           if (y >> j & 1) s = s * 1ll * e[i][j] % P;     return s;   }   int h(int x, int y) {     return ll[x & 127][y & 127] * 1ll * lr[x & 127][y >> 7] % P *            rl[x >> 7][y & 127] % P * rr[x >> 7][y >> 7] % P;   }   int main() {     int m, i, j, w = 0;     scanf( %d , &n);     for (i = 0; i < n; ++i) scanf( %d , a + i);     for (i = 0; i < n; ++i)       for (j = 0; j < n; ++j) e[i][j] = a[i] * 1ll * qp(a[i] + a[j], P - 2) % P;     for (i = 0; i < O; ++i)       for (j = 0; j < O; ++j) ll[i][j] = lr[i][j] = rl[i][j] = rr[i][j] = 1;     for (i = 0, m = 1 << min(n, 7); i < m; ++i)       for (j = 0; j < m; ++j)         if (!(i & j)) ll[i][j] = g(i, j);     if (n > 7) {       for (i = 0, m = 1 << n - 7; i < 128; ++i)         for (j = 0; j < m; ++j) lr[i][j] = g(i, j << 7);       for (i = 0; i < m; ++i)         for (j = 0; j < 128; ++j) rl[i][j] = g(i << 7, j);       for (i = 0; i < m; ++i)         for (j = 0; j < m; ++j)           if (!(i & j)) rr[i][j] = g(i << 7, j << 7);     }     for (i = 1, m = 1 << n; i < m;          w = (w + p[i] * 1ll * h(i, m - 1 ^ i) % P * __builtin_popcount(i)) % P,         ++i)       for (p[i] = 1, j = i & i - 1; j; j = j - 1 & i)         p[i] = (p[i] - p[j] * 1ll * h(j, i ^ j)) % P;     printf( %d , (w + P) % P);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v[3005];   long long f[20][3005], ans;   int n, k;   void solve(int l, int r, int d) {     if (l == r) {       for (int i = (int)(0); i <= (int)(v[l].size() - 1); i++)         if (i + 1 <= k) ans = max(ans, v[l][i] + f[d][k - i - 1]);       return;     }     int mid = (l + r) / 2;     memcpy(f[d + 1], f[d], sizeof(f[d]));     for (int i = (int)(mid + 1); i <= (int)(r); i++) {       long long v1 = v[i].size(), v2 = v[i][v1 - 1];       for (int j = (int)(k - v1); j >= (int)(0); j--)         f[d + 1][j + v1] = max(f[d + 1][j + v1], f[d + 1][j] + v2);     }     solve(l, mid, d + 1);     memcpy(f[d + 1], f[d], sizeof(f[d]));     for (int i = (int)(l); i <= (int)(mid); i++) {       long long v1 = v[i].size(), v2 = v[i][v1 - 1];       for (int j = (int)(k - v1); j >= (int)(0); j--)         f[d + 1][j + v1] = max(f[d + 1][j + v1], f[d + 1][j] + v2);     }     solve(mid + 1, r, d + 1);   }   int main() {     scanf( %d%d , &n, &k);     for (int i = (int)(1); i <= (int)(n); i++) {       int t;       scanf( %d , &t);       v[i].resize(t);       for (int j = (int)(0); j <= (int)(t - 1); j++) scanf( %lld , &v[i][j]);       for (int j = (int)(1); j <= (int)(t - 1); j++) v[i][j] += v[i][j - 1];     }     solve(1, n, 0);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   string s, t, k;   string str(string a) {     if (a[1] ==  X )       swap(a[1], a[3]);     else if (a[2] ==  X )       swap(a[2], a[3]);     else if (a[0] ==  X )       swap(a[0], a[2]), swap(a[2], a[3]);     string b = a.substr(0, 3);     return b;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> s >> k;     s += k;     s = str(s);     cin >> t >> k;     t += k;     t = str(t);     if (s == t) {       cout <<  YES n ;       return 0;     }     swap(s[0], s[2]);     swap(s[1], s[2]);     if (s == t) {       cout <<  YES n ;       return 0;     }     swap(s[0], s[2]);     swap(s[1], s[2]);     if (s == t) {       cout <<  YES n ;       return 0;     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 15;   const int K = 500;   int a[N][N];   const int INF = 1e9 + 7;   int calc(int x, int y, int h, int w) {     int cnt = 0;     for (int i = x; i < x + h; i++) {       for (int j = y; j < y + w; j++) {         cnt += a[i][j];       }     }     return cnt;   }   int main() {     int r, c;     int n, k;     cin >> r >> c >> n >> k;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       x--;       y--;       a[x][y] = 1;     }     int ans = 0;     for (int d = 1; d <= r; d++) {       for (int w = 1; w <= c; w++) {         for (int i = 0; i + d - 1 < r; i++) {           for (int j = 0; j + w - 1 < c; j++) {             if (calc(i, j, d, w) >= k) ans++;           }         }       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long pow2[61];   vector<long long> ans;   int main() {     std::ios_base::sync_with_stdio(false);     pow2[0] = 1;     pow2[1] = 2;     for (int i = 2; i <= 60; i++) pow2[i] = pow2[i - 1] * 2;     long long X, d;     scanf( %lld %lld , &X, &d);     while (X > 1) {       long long k = 0;       while (pow2[k] - 1 < X) k++;       k--;       long long j = 1;       if (ans.size()) {         j = ans.back() + d;       }       for (int i = 1; i <= k; i++) ans.push_back(j);       X -= pow2[k] - 1;     }     if (X == 1) {       if (ans.size())         ans.push_back(ans.back() + d);       else         ans.push_back(1);     }     if (ans.size() > 10000)       printf( -1 n );     else {       printf( %lu n , ans.size());       for (int i = 0; i < ans.size(); i++)         if (ans[i] >= 1e18) return 0 * printf( -1 n );       for (int i = 0; i < ans.size(); i++) printf( %lld  , ans[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef long long int ll;         ll sum(ll n)   {       ll s=0;       while(n>0)       {           s+= n%10;           n=n/10;          }       return s;   }         ll gcd(ll n, ll m )   {       ll k = n%m;       while(k!=0)       {           n=m;           m=k;           k= n%m;       }          return m;   }      ll gcdSum(ll n)   {       ll x = sum(n);       ll num =gcd(n,x);       while(num ==1)       {           n++;           if (n%10 !=0)           {               x++;           }           else           {               x-= 8;           }           num = gcd(n,x);              //cout<<n<<   <<x<<   <<num<<endl;          }          return n;   }            int main() {       #ifndef ONLINE_JUDGE       // for getting input from input.txt       freopen( input.txt ,  r , stdin);       // for writing output to output.txt       freopen( output.txt ,  w , stdout);   #endif    //code    int t;       cin >> t;       while(t>0)       {           ll n,w;           cin >> n>>w;              map<ll,int> mp;           for(ll i=0;i<n;i++)           {               ll wi ;               cin >> wi;               mp[wi]++;           }           // for(auto x : mp)           // {           //     cout<< x.first<<   <<x.second<<endl;           // }              ll h=0;                      map<ll,int>  :: iterator it;           while(!mp.empty())           {               h++;               it = mp.end();               it--;               ll wirem =w;               //cout<< hi <<endl;                              while(!mp.empty() && wirem>= mp.begin()->first  )               {                   if(wirem - it->first >=0)                   {                       wirem -= it->first;                       it->second--;                       if(it->second==0)                       {                           mp.erase(it->first);                           if(mp.empty())                           {                               break;                           }                           it= mp.end();                           it--;                                                                                                        }                                             }                   else                   {                       it--;                   }                     }               // for(auto x : mp)               // {               //     cout<< x.first<<   <<x.second<<endl;               // }                                                 // cout<<         <<h<<endl;           }              cout<<h<<endl;           t--;       }                     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   int l[100005], r[100005], fr[100005], to[100005];   int f[100005];   vector<int> v[600000];   int fa[100005], it[100005];   int getfa(int x) { return (x == fa[x]) ? x : (fa[x] = getfa(fa[x])); }   void merge(int x, int y) {     if (x == y) return;     x = getfa(x);     y = getfa(y);     if (x == y) return;     l[x] = min(l[x], l[y]);     r[x] = max(r[x], r[y]);     fa[y] = x;   }   void update(int x, int l, int r, int tl, int tr, int p) {     if (l > tr || tl > r) return;     if (l >= tl && r <= tr) {       v[x].emplace_back(p);       return;     }     int mid = (l + r) >> 1;     update(x << 1, l, mid, tl, tr, p);     update((x << 1) | 1, mid + 1, r, tl, tr, p);   }   void get(int x, int l, int r, int p, int id) {     bool f = v[x].empty();     for (auto u : v[x]) merge(u, id);     v[x].clear();     if (!f) v[x].emplace_back(id);     if (l == r) return;     int mid = (l + r) >> 1;     if (p <= mid)       get(x << 1, l, mid, p, id);     else       get((x << 1) | 1, mid + 1, r, p, id);   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     vector<int> v;     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> f[i];       if (f[i] == 1) {         cin >> l[i] >> r[i];         v.emplace_back(l[i]);         v.emplace_back(r[i]);       } else {         cin >> fr[i] >> to[i];       }     }     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     for (int i = 1; i <= n; i++) {       if (f[i] == 2) continue;       l[i] = lower_bound(v.begin(), v.end(), l[i]) - v.begin() + 1;       r[i] = lower_bound(v.begin(), v.end(), r[i]) - v.begin() + 1;     }     int len = v.size(), cnt = 0;     for (int i = 1; i <= n; i++) {       if (f[i] == 1) {         fa[i] = i;         it[++cnt] = i;         if (l[i] < r[i] - 1) update(1, 1, len, l[i] + 1, r[i] - 1, i);         get(1, 1, len, l[i], i);         get(1, 1, len, r[i], i);       } else {         int t1 = getfa(it[fr[i]]), t2 = getfa(it[to[i]]);         if (l[t1] > l[t2] && l[t1] < r[t2] || r[t1] > l[t2] && r[t1] < r[t2] ||             t1 == t2) {           cout <<  YES n ;         } else           cout <<  NO n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int n, x;     while (cin >> n) {       map<int, int> a;       for (int i = 0; i < n; i++) {         cin >> x;         if (x != 0) a[x]++;       }       int ans = 0, ans1 = 0, ans2 = 0;       for (map<int, int>::iterator it = a.begin(); it != a.end(); it++) {         if (it->second == 2)           ans++;         else if (it->second < 2)           ans1++;         else           ans2++;       }       if (ans2 == 0 && ans > 0)         cout << ans << endl;       else if (ans2 == 0 && ans == 0)         cout << 0 << endl;       else         cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int z[10000], ans[10000], size[10000], v[10000];   long long a[10004];   int vis[10004];   int root(int i) {     while (z[i] != i) i = z[i];     return i;   }   void union1(int i, int j) {     i = root(i);     j = root(j);     if (i != j) {       if (size[i] > size[j]) {         size[i] += size[j];         z[j] = i;       } else {         size[j] += size[i];         z[i] = j;       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       size[i] = 1;       z[i] = i;     }     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (a[i] == 0 || a[j] == 0) continue;         long long w = a[i] * a[j];         if (w >= 0) {           double w1 = sqrt(w);           long long w2 = w1;           w2 = w2 * w2;           if (w2 == w) union1(i, j);         }       }     }     for (int i = 1; i <= n; i++) {       if (a[i] != 0) v[i] = root(i);     }     for (int i = 1; i <= n; i++) {       int cnt = 0;       for (int j = 1; j <= n; j++) vis[j] = 0;       if (a[i] == 0) {         cnt = 0;         ans[1]++;       } else {         vis[v[i]] = 1;         cnt = 1;         ans[cnt]++;       }       for (int j = i + 1; j <= n; j++) {         if (a[j] != 0) {           if (vis[v[j]] == 0) {             vis[v[j]] = 1;             cnt++;           }         }         if (cnt != 0)           ans[cnt]++;         else           ans[1]++;       }     }     for (int i = 1; i <= n; i++) cout << ans[i] <<    ;     cout <<   n ;   }