malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, xa, ya;   int i, j, viz[501][501], light[501][501], d[501][501];   string ans;   void paint(int x, int y) {     viz[x][y] = 1;     if (light[x][y] == 0) light[x][y] = 1, ans +=  1 ;     int up, down, right, left;     up = down = right = left = 0;     for (j = 1; j < y; j++)       if (light[x][j]) left = 1;     for (j = y + 1; j <= n; j++)       if (light[x][j]) right = 1;     for (i = 1; i < x; i++)       if (light[i][y]) up = 1;     for (i = x + 1; i <= n; i++)       if (light[i][y]) down = 1;     if (up && !viz[x - 1][y]) ans +=  U , paint(x - 1, y), ans +=  D ;     if (down && !viz[x + 1][y]) ans +=  D , paint(x + 1, y), ans +=  U ;     if (left && !viz[x][y - 1]) ans +=  L , paint(x, y - 1), ans +=  R ;     if (right && !viz[x][y + 1]) ans +=  R , paint(x, y + 1), ans +=  L ;   };   void bfs() {     queue<pair<int, int> > q;     q.push(make_pair(xa, ya));     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++) viz[i][j] = 0, d[i][j] = -1;     d[xa][ya] = 0;     while (!q.empty()) {       pair<int, int> k = q.front();       q.pop();       if (light[k.first + 1][k.second] && d[k.first + 1][k.second] == -1) {         d[k.first + 1][k.second] = d[k.first][k.second] + 1;         q.push(make_pair(k.first + 1, k.second));       };       if (light[k.first - 1][k.second] && d[k.first - 1][k.second] == -1) {         d[k.first - 1][k.second] = d[k.first][k.second] + 1;         q.push(make_pair(k.first - 1, k.second));       };       if (light[k.first][k.second + 1] && d[k.first][k.second + 1] == -1) {         d[k.first][k.second + 1] = d[k.first][k.second] + 1;         q.push(make_pair(k.first, k.second + 1));       };       if (light[k.first][k.second - 1] && d[k.first][k.second - 1] == -1) {         d[k.first][k.second - 1] = d[k.first][k.second] + 1;         q.push(make_pair(k.first, k.second - 1));       };     };   };   void repaint(int x, int y) {     viz[x][y] = 1;     if (light[x - 1][y] && !viz[x - 1][y] && d[x - 1][y] > d[x][y])       ans +=  U , repaint(x - 1, y), ans +=  D ;     if (light[x + 1][y] && !viz[x + 1][y] && d[x + 1][y] > d[x][y])       ans +=  D , repaint(x + 1, y), ans +=  U ;     if (light[x][y - 1] && !viz[x][y - 1] && d[x][y - 1] > d[x][y])       ans +=  L , repaint(x, y - 1), ans +=  R ;     if (light[x][y + 1] && !viz[x][y + 1] && d[x][y + 1] > d[x][y])       ans +=  R , repaint(x, y + 1), ans +=  L ;     if (light[x][y] == 1) light[x][y] = 0, ans +=  2 ;   };   int main() {     cin >> n >> xa >> ya;     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++) cin >> light[i][j];     paint(xa, ya);     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++)         if (viz[i][j] == 0 && light[i][j] == 1) {           cout <<  NO ;           return 0;         };     cout <<  YES  << endl;     bfs();     repaint(xa, ya);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   const int mod = 998244353;   const int inv = 332748118;   int n;   long long ans, js[N], ni[N];   inline long long C(int x, int y) {     if (x < 0 || y < 0 || x < y) return 0;     return js[x] * ni[y] % mod * ni[x - y] % mod;   }   inline long long qpow(long long x, long long y, long long ans = 1) {     for (; y; y >>= 1, x = x * x % mod)       if (y & 1) ans = ans * x % mod;     return ans;   }   int main() {     cin >> n;     for (int i = js[0] = 1; i <= n; ++i) js[i] = js[i - 1] * i % mod;     for (int i = (ni[n] = qpow(js[n], mod - 2), n); i; --i)       ni[i - 1] = ni[i] * i % mod;     for (int i = 0; i <= n; ++i) {       long long f;       if (!i)         f = qpow(qpow(3, n) - 3, n);       else         f = ((i & 1) ? -1 : 1) * C(n, i) *             (3 * qpow(qpow(3, n - i) - 1, n) % mod +              (qpow(3, i) - 3) * qpow(3, 1ll * (n - i) * n) % mod) %             mod;       (ans += f) %= mod;     }     cout << ((qpow(3, 1ll * n * n % (mod - 1)) - ans) % mod + mod) % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool f[501][501];   long long P[501];   int main(int argc, char *argv[]) {     int N, M, i, u, v, k, l;     cin >> N >> M;     for (i = 1; i <= N; i++) cin >> P[i];     for (i = 1; i <= N; i++)       for (k = 1; k <= N; k++) f[i][k] = false;     for (i = 1; i <= M; i++) {       cin >> u >> v;       f[u][v] = true;       f[v][u] = true;     }     long long mini = (1 << 29);     long long sum;     for (int i = 1; i <= N - 2; i++) {       for (int j = i + 1; j <= N - 1; j++) {         for (int k = j + 1; k <= N; k++) {           if (f[i][j] && f[j][k] && f[k][i]) {             sum = P[i] + P[j] + P[k];             if (sum < mini) mini = sum;           }         }       }     }     if (mini != (1 << 29))       cout << mini << endl;     else       cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class ST {     long long int tree[10000000];     long long int lazy[10000000];       public:     void build(int a, int b, int node) {       tree[node] = 0;       lazy[node] = 0;       if (a == b) return;       int mid = (a + b + 4000000) / 2 - 2000000;       build(a, mid, 2 * node);       build(mid + 1, b, 2 * node + 1);     }     void propagate(int a, int b, int node) {       tree[node] += lazy[node];       if (a != b) {         lazy[2 * node] += lazy[node];         lazy[2 * node + 1] += lazy[node];       }       lazy[node] = 0;     }     void update(int a, int b, int node, int x, int y, long long int val) {       propagate(a, b, node);       if (b < x || y < a) return;       if (x <= a && b <= y) {         lazy[node] += val;         propagate(a, b, node);         return;       }       int mid = (a + b + 4000000) / 2 - 2000000;       update(a, mid, 2 * node, x, y, val);       update(mid + 1, b, 2 * node + 1, x, y, val);       tree[node] = max(tree[2 * node], tree[2 * node + 1]);     }     long long int query() { return tree[1]; }   };   int main() {     int n;     long long int r;     scanf( %d %lld , &n, &r);     vector<pair<long long int, long long int> > V;     for (int i = 0; i < n; i++) {       long long int a, b;       scanf( %lld %lld , &a, &b);       V.push_back(pair<long long int, long long int>(a + b, a - b));     }     ST *S = new ST();     S->build(-2000000, 2000000, 1);     sort(V.begin(), V.end());     int ptr = 0;     long long int ans = 0;     for (int i = 0; i < n; i++) {       while (V[ptr].first < V[i].first - 2 * r) {         S->update(-2000000, 2000000, 1, V[ptr].second - 2 * r, V[ptr].second, -1);         ptr++;       }       S->update(-2000000, 2000000, 1, V[i].second - 2 * r, V[i].second, 1);       ans = max(ans, S->query());     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, amount(0);     scanf( %d , &n);     bool b[3001] = {false};     int pfactors[3001] = {0};     for (int i = 2; i <= n; ++i) {       if (!b[i]) {         for (int j = i + i; j <= n; j += i) {           b[j] = true;           pfactors[j] += 1;         }       }       if (pfactors[i] == 2) {         amount += 1;       }     }     printf( %d n , amount);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   const int mod = 1e9 + 7;   inline void MOD(int &x) {     if (x >= mod) x -= mod;   }   int n, m, k;   int dp[2][N][N][N], C[N][N], r;   int ans;   int main() {     for (int i = 0; i <= 100; i++) {       C[i][0] = 1;       for (int j = 1; j <= i; j++)         C[i][j] = min(C[i - 1][j - 1] + C[i - 1][j], 101);     }     scanf( %d%d%d , &n, &m, &k);     r = 0;     for (int j = 2; j <= n + 1; j++) dp[r][j][j - 1][1] = 1;     for (int i = 1; i <= m; i++) {       for (int j = 1 + i; j <= n + 1; j++)         for (int q = 1; q <= k; q++)           ans = ((long long)dp[r][j][0][q] * (m - i + 1) + ans) % (long long)mod,           dp[r][j][0][q] = 0;       if (i == m) break;       for (int j = 1 + i; j <= n + 1; j++)         for (int p = 1; p < j; p++)           for (int q = 1; q <= k; q++)             if (dp[r][j][p][q]) {               for (int t = p; j + t <= n + 1 && q * C[t - 1][p - 1] <= k; t++)                 MOD(dp[r ^ 1][j + t][t - p][q * C[t - 1][p - 1]] +=                     dp[r][j][p][q]);               dp[r][j][p][q] = 0;             }       r ^= 1;     }     printf( %d n , ans);     return 0;   }
#include<bits/stdc++.h>      using namespace std;      /* User Template   @Shaurya Gautam   CP.cpp */      /*****************************************/      #define ll long long   #define vb vector<bool>   #define vi vector<int>   #define vl vector<long>   #define vll vector<long long>   #define vpii vector<pair<int, int>>   #define vc vector<char>   #define pii pair<int, int>   #define mp make_pair   #define F(i,L,R) for (int i = L; i < R; i++)   #define FE(i,L,R) for (int i = L; i <= R; i++)   #define FR(i,L,R) for (int i = L; i > R; i--)   #define FRE(i,L,R) for (int i = L; i >= R; i--)   #define pb push_back   #define ppb pop_back   #define endl   n       class my_compare{       public:           bool operator()(pii &p1, pii &p2){               return p1.second < p2.second;           }   };         /*************************************************/   void solve(){       int n;       cin >> n;          vi arr(n + 1);       FE(i, 1, n){           cin >> arr[i];       }          int ans{0};          FE(i, 1, n){           if(arr[i] > 2*i - 1) continue;                      int j = (arr[i] > i) ? 1 : (i/arr[i]) + 1;           while(j*arr[i] <= 2*i - 1){               if(arr[j*arr[i] - i] == j) ans++;               j++;           }       }          cout << ans << endl;   }      int main(){       ios_base::sync_with_stdio(false);       cin.tie(NULL);       cout.tie(NULL);             bool test_case{1}, fileop{0};          if(fileop){           freopen( input.txt , r ,stdin);           freopen( output.txt , w ,stdout);       }          int t;       if(test_case){           cin >> t;           F(i, 0, t){               solve();           }       }       else solve();   }      /*    Some Learnings-        -Don t focus on ratings or standings        -See problem from new perspective and forget current thoughts         -Accuracy is important, be sure that you think right        -Speed builds up once accuracy does... solve as many questions as possible         -Editorial is last resort... don t jump to it        -BE CONSISTENT        -My two brothers - Hard Work and Perseverance        -Never leave a contest, no matter how tough it might be   */
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> g[100005];   int c[100005];   double r[100005];   void dfs(int x) {     c[x] = 1;     for (int i = 0; i < g[x].size(); ++i) {       int y = g[x][i];       dfs(y);       c[x] += c[y];     }   }   void calc(int x) {     for (int i = 0; i < g[x].size(); ++i) {       int y = g[x][i];       r[y] = r[x] + 1 + (c[x] - c[y] - 1) / 2.;       calc(y);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       int p;       scanf( %d , &p);       p--;       g[p].push_back(i);     }     dfs(0);     r[0] = 1;     calc(0);     printf( 1.0 );     for (int i = 1; i < n; ++i) printf(  %.1lf , r[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, a, b, c, d, x, y, v, ans = 0;     cin >> n >> a >> b >> c >> d;     for (long long i = 1; i <= n; i++) {       x = a - d + i;       v = b - c + i;       y = a + b - c - d + i;       if ((x > 0 && x <= n) && (y > 0 && y <= n) && (v > 0 && v <= n)) ans += n;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f, mod = 1000000007;   const long long INF = 0x3f3f3f3f3f3f3f3fLL;   const double pi = acosl(-1.), eps = 1e-9;   inline int power(int a, int b, int m = mod, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   int que(vector<int> a, vector<int> b) {     printf( %d %d  , a.size(), b.size());     for (auto r : a) cout << r <<    ;     for (auto r : b) cout << r <<    ;     fflush(stdout);     int ans;     cin >> ans;     return ans;   }   int main() {     int T;     cin >> T;     while (T--) {       int n;       scanf( %d , &n);       vector<int> a, b;       a.push_back(1);       for (int i = 2; i <= n; i++) b.push_back(i);       int t = que(a, b);       int st = 1, ed = n;       while (st + 1 < ed) {         int md = st + ed >> 1;         b.clear();         for (int i = 2; i <= md; i++) b.push_back(i);         if (que(a, b) == t)           ed = md;         else           st = md;       }       a.clear();       b.clear();       a.push_back(ed);       for (int i = 1; i <= n; i++)         if (ed != i) b.push_back(i);       t = que(a, b);       printf( -1 %d n , t);       fflush(stdout);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100010], ar[100010];   int main() {     int n, track = -100002, i;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i];       ar[a[i]] = ar[a[i] - 1] + 1;       track = max(ar[a[i]], track);     }     cout << n - track << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool compare(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }   int main() {     float r1, r2, c1, c2, d1, d2;     cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;     float a = c1 / 2 + (d1 + r1 - d2 - r2) / 4;     float c = c1 / 2 - (d1 + r1 - d2 - r2) / 4;     float b = c2 / 2 + (r1 + d2 - r2 - d1) / 4;     float d = c2 / 2 - (r1 + d2 - r2 - d1) / 4;     if (a > 9 || a < 1) {       cout << -1;       return 0;     }     if (b > 9 || b < 1) {       cout << -1;       return 0;     }     if (c > 9 || c < 1) {       cout << -1;       return 0;     }     if (d > 9 || d < 1) {       cout << -1;       return 0;     }     if (a + b != r1) {       cout << -1;       return 0;     }     if (d + c != r2) {       cout << -1;       return 0;     }     if (a + c != c1) {       cout << -1;       return 0;     }     if (d + b != c2) {       cout << -1;       return 0;     }     if (a + d != d1) {       cout << -1;       return 0;     }     if (c + b != d2) {       cout << -1;       return 0;     }     if (a == b || a == c || a == d || b == c || b == d || c == d) {       cout << -1;       return 0;     }     cout << (int)a <<     << (int)b << endl << (int)c <<     << (int)d;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long Fib[100];   long long Path[100];   pair<long long, long long> get(long long N, long long X, bool f) {     assert(Fib[N] >= X);     if (N <= 0) {       return {0, 0};     }     if (N == 1) {       if (X == 1) {         return {0, 1};       } else {         return {1, 0};       }     }     pair<long long, long long> res = {};     if (X <= Fib[N - 1]) {       res = get(N - 1, X, true);       res.second = min(res.first, res.second) + 1ll + Path[N - 2];       if (f) {         res.second = min(res.second, res.first + 2ll);         res.first = min(res.first, res.second + 2ll);       }     } else {       res = get(N - 2, X - Fib[N - 1], false);       res.first++;       if (f) {         res.second = min(res.second, res.first + 2ll);         res.first = min(res.first, res.second + 2ll);       }     }     return res;   }   long long solve(long long N, long long X, long long Y) {     int f = 0;     if (N > 90) {       N = 90;       f = 1;     }     assert(Fib[N] >= X && Fib[N] >= Y);     if (X > Y) swap(X, Y);     while (true) {       if (Y <= Fib[N - 1]) {         f = 1;         N--;       } else if (X > Fib[N - 1]) {         if (f) {           f++;         }         X -= Fib[N - 1];         Y -= Fib[N - 1];         N -= 2;       } else {         break;       }     }     if (N == 1) {       return 1;     }     auto res1 = get(N - 1, X, true);     auto res2 = get(N - 2, Y - Fib[N - 1], false);     long long res = res2.first + 1ll + min(res1.first, res1.second);     if (f) {       res = min(res, res2.second + 2ll + res1.first + f - 1ll);     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     Fib[0] = 1;     Path[0] = 0;     Fib[1] = 2;     Path[1] = 1;     for (int i = 2; i < 100; i++) {       Fib[i] = Fib[i - 1] + Fib[i - 2];       Path[i] = Path[i - 2] + 1;     }     long long T, N, X, Y;     cin >> T >> N;     while (T--) {       cin >> X >> Y;       cout << solve(N, X, Y) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace {   const double PI = acos(-1.0);   }   struct Data {     int n;     int c;     vector<int> t;     Data() : c(0) {}     bool operator<(const Data& d) const { return c < d.c; }   };   int main() {     int n;     while (cin >> n) {       n *= 2;       Data d[101];       for (int i = 0; i < n; ++i) {         int x;         cin >> x;         d[x].n = x;         ++d[x].c;         d[x].t.push_back(i);       }       sort(d, d + 101);       bool f = 0;       vector<int> ans[2];       set<int> s[2];       int z[101] = {0};       for (int i = 0; i < 101; ++i) {         for (int j = 0; j < d[i].c; ++j) {           ans[f].push_back(d[i].n);           s[f].insert(d[i].n);           z[d[i].t[j]] = f;           f = !f;         }       }       cout << s[0].size() * s[1].size() << endl;       for (int i = 0; i < n; ++i) {         if (i) cout <<    ;         cout << z[i] + 1;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long max(long long a, long long b) { return (a > b) ? a : b; }   inline long long min(long long a, long long b) { return (a < b) ? a : b; }   inline long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   vector<vector<long long> > graph;   vector<long long> color, initial;   long long cnt = 0;   void bfs(long long source, long long n, long long colour) {     queue<long long> q;     q.push(source);     bool visited[n + 1];     fill(visited, visited + n + 1, false);     visited[source] = true;     while (!q.empty()) {       long long u = q.front();       q.pop();       for (auto c : graph[u]) {         if (visited[c] == false) {           q.push(c);           visited[c] = true;           initial[c] = colour;         }       }     }   }   int main() {     ;     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     graph.resize(n + 1);     for (long long i = 2; i <= n; i++) {       long long a;       cin >> a;       graph[a].push_back(i);     }     initial.resize(n + 1, -1);     color.resize(n + 1, 0);     for (long long i = 1; i <= n; i++) {       cin >> color[i];       if (initial[i] == color[i]) continue;       cnt++;       initial[i] = color[i];       bfs(i, n, color[i]);     }     cout << cnt;     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long int prime[1000010] = {0};   vector<long long int> pr;   void sieve() {     prime[0] = 1;     prime[1] = 1;     for (long long int i = 2; i <= sqrt(1000010); i++) {       if (prime[i] == 0) {         for (long long int j = i * i; j < 1000010; j += i) {           prime[j] = 1;         }       }     }     for (long long int i = 2; i < 1000010; i++) {       if (!prime[i]) pr.push_back(i);     }     return;   }   double pi = 3.141592653589;   long long int a[200100];   long long int pre[200100] = {0};   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int n, w;     cin >> n >> w;     for (long long int i = 1; i <= n; i += 1) {       cin >> a[i];       pre[i] = pre[i - 1] + a[i];     }     long long int mi = 0, ma = 0;     for (long long int i = 1; i <= n; i += 1) {       mi = min(mi, pre[i]);       ma = max(ma, pre[i]);     }     long long int ans = (w - ma) + (mi + 1);     if (ans > w + 1 || ans < 0)       cout << 0 << endl;     else       cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long arr[n];       for (long long i = 0; i < n; i++) cin >> arr[i];       sort(arr, arr + n);       bool f = 1;       for (long long i = 1; i < n; i++) {         if (arr[i] - arr[i - 1] > 1) f = 0;       }       if (f)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   int flag[1000001] = {0}, a[1000051][21], ss[100001];   long long qsm(int n, int p) {     if (p == 0) return 1;     if (p == 1) return n;     long long ans = qsm(n, p / 2);     if (p % 2)       ans = n * ans % 1000000007 * ans % 1000000007;     else       ans = (ans * ans) % 1000000007;     return ans;   }   int main() {     flag[1] = 1;     int i, j, T, x, y;     long long ans = 0;     for (i = 2; i <= 500000; i++) {       if (flag[i]) continue;       for (j = 2 * i; j <= 1000000; j += i) flag[j] = 1;     }     ss[0] = 0;     for (i = 2; i <= 1000000; i++)       if (!flag[i]) {         ss[++ss[0]] = i;       }     for (i = 0; i <= 1000050; i++) {       a[i][0] = 1;       a[0][i] = 1;     }     for (i = 1; i <= 1000050; i++)       for (j = 1; j <= 20 && j <= i; j++) {         if (i == j) {           a[i][j] = 1;           continue;         }         a[i][j] = a[i - 1][j - 1] + a[i - 1][j];         a[i][j] %= 1000000007;       }     scanf( %d , &T);     while (T--) {       scanf( %d%d , &x, &y);       i = 1;       ans = 1;       while (x != 1) {         if (!flag[x]) {           ans *= y;           ans %= 1000000007;           x = 1;           continue;         }         for (; i <= ss[0]; i++) {           if (x % ss[i] == 0) {             int k = 0;             while (x % ss[i] == 0) {               k++;               x /= ss[i];             }             ans *= a[y + k - 1][k];             ans %= 1000000007;             i++;             break;           }         }       }       int p = qsm(2, y - 1);       ans *= p;       ans %= 1000000007;       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     string digit[10] = {  ,      one ,  two ,    three ,  four ,                          five ,  six ,  seven ,  eight ,  nine };     string tenth[10] = {  ,       ten ,    twenty ,   thirty ,  forty ,                          fifty ,  sixty ,  seventy ,  eighty ,  ninety };     string tenx[10] = { ten ,      eleven ,   twelve ,     thirteen ,  fourteen ,                         fifteen ,  sixteen ,  seventeen ,  eighteen ,  nineteen };     cin >> n;     switch (n / 10) {       case 0:         cout << digit[n % 10] << endl;         break;       case 1:         cout << tenx[n % 10] << endl;         break;       default:         if (digit[n % 10] ==   )           cout << tenth[n / 10] << endl;         else           cout << tenth[n / 10] <<  -  << digit[n % 10] << endl;         break;     }     if (n == 0) printf( zero );     return (0);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int x, n, i;       cin >> n >> x;       long long s = 0, an1 = (-1), an2 = (-1);       int a[n];       for (i = 0; i < n; i++) {         cin >> a[i];       }       for (i = 0; i < n; i++) {         s += a[i];         if (s % x != 0) {           an1 = i + 1;         }       }       s = 0;       for (i = n - 1; i >= 0; i--) {         s += a[i];         if (s % x != 0) {           an2 = n - i;         }       }       if (an2 >= an1)         cout << an2 <<   n ;       else         cout << an1 <<   n ;     }     return (0);   }