malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n, div = 1, ans = 0;       cin >> n;       long long int tt = log2(n);       vector<long long int> w;       if (log2(n) != tt) tt++;       for (long long int i = 0; i < n; i++) w.push_back(i + 1);       for (long long int j = 0; j < tt; j++) {         vector<long long int> v, u;         for (long long int i = 0; i < n;) {           for (long long int j = i; j < i + div; j++) {             if (j >= n) break;             v.push_back(w[j]);           }           i += div;           for (long long int j = i; j < i + div; j++) {             if (j >= n) break;             u.push_back(w[j]);           }           i += div;         }         cout << v.size() <<     << u.size() <<    ;         for (long long int i = 0; i < v.size(); i++) cout << v[i] <<    ;         for (long long int i = 0; i < u.size(); i++) cout << u[i] <<    ;         cout <<   n ;         long long int xxx;         cin >> xxx;         ans = max(xxx, ans);         div *= 2;         if (xxx == -1) {           cout << ans;           exit(0);         }       }       cout <<  -1   << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200200;   int n, k;   int a[maxn];   vector<int> g[maxn];   int sz[maxn];   int dpd[maxn], dpu[maxn];   int mxd[maxn], mxu[maxn];   int mark[maxn], cnt[maxn];   int mxc[maxn], N;   int ans;   void dfs(int v, int par = -1) {     sz[v] = 1;     cnt[v] = mark[v];     int c = 0;     for (int u : g[v])       if (u != par) {         dfs(u, v);         cnt[v] += cnt[u];         sz[v] += sz[u];         if (!cnt[u]) {           dpd[v] += dpd[u];           mxd[v] += dpd[u];         } else           c = max(c, mxd[u]);       }     if (mark[v])       dpd[v] = 0, mxd[v] = 0;     else       dpd[v]++, mxd[v] += c + 1;   }   void gfs(int v, int par = -1) {     if (cnt[v] == N) dpu[v] = n - sz[v];     if (!mark[v]) {       mxu[v] += mxc[v];       int d, c;       if (cnt[v] == N)         d = dpu[v] + 1, c = 0;       else         d = 1, c = mxu[v];       for (int u : g[v])         if (u != par) {           mxu[u] += d;           mxc[u] = max(mxc[u], c);           if (!cnt[u])             d += dpd[u];           else             c = max(c, mxd[u]);         }       reverse(g[v].begin(), g[v].end());       d = 0, c = 0;       for (int u : g[v])         if (u != par) {           mxu[u] += d;           mxc[u] = max(mxc[u], c);           if (!cnt[u])             d += dpd[u];           else             c = max(c, mxd[u]);         }     } else       dpu[v] = mxu[v] = 0;     for (int u : g[v])       if (u != par) gfs(u, v);   }   bool check(int x) {     N = 0;     memset(sz, 0, sizeof sz);     memset(dpd, 0, sizeof dpd);     memset(dpu, 0, sizeof dpu);     memset(mxc, 0, sizeof mxc);     memset(mxd, 0, sizeof mxd);     memset(mxu, 0, sizeof mxu);     for (int i = 0; i < n; i++) mark[i] = (a[i] < x);     for (int i = 0; i < n; i++) N += mark[i];     dfs(0);     gfs(0);     for (int i = 0; i < n; i++)       if (!mark[i])         if (mxd[i] + dpu[i] >= k or mxu[i] + dpd[i] >= k) return true;     return false;   }   void solve() {     int l = 1, r = 1000001;     int mid;     while (l != r - 1) {       mid = (l + r) >> 1;       if (check(mid))         l = mid;       else         r = mid;     }     ans = l;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     for (int v, u, i = 0; i < n - 1; i++) {       cin >> v >> u;       v--, u--;       g[v].push_back(u);       g[u].push_back(v);     }     solve();     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:256000000 )   using namespace std;   const int INF = (int)1e9 + 7;   const long long LINF = (long long)9e18 + 7;   const long long P1 = 353251;   const long long P2 = 239017;   const long long MOD = 1e9 + 7;   const long long MOD1 = 1e9 + 7;   const long long MOD2 = 1e9 + 9;   int n, m;   long long ans = 0;   pair<long long, long long> a[107];   long long t[107];   const bool is_testing = 0;   int main() {     srand( D  +  E  +  N  +  I  +  S  +  S  +  O  +  N  + time(NULL));     if (is_testing) {       freopen( input.txt ,  r , stdin);       freopen( output.txt ,  w , stdout);     } else {     }     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first;     cin >> m;     for (int i = 0; i < m; i++) cin >> t[i];     long long sum = t[0];     for (int i = 1; i < m; i++) {       t[i] -= sum;       sum += t[i];     }     t[m] = LINF;     sort(a, a + n);     int uk = 0;     for (int i = 0; i < n; i++) {       long long now = a[i].second;       while (now) {         if (now < t[uk]) {           ans += now * a[i].first * (uk + 1);           t[uk] -= now;           now = 0;         } else {           now -= t[uk];           ans += t[uk] * a[i].first * (uk + 1);           uk++;         }       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long int dp[105][105][105];   long long int opti[105][105][105];   long long int lps[105];   string s, s1, s2, ans;   long long int n, m, o;   long long int rec(long long int i, long long int j, long long int k) {     if (k >= o) return -1e16;     if (i >= n || j >= m) return 0;     if (dp[i][j][k] != -1) return dp[i][j][k];     long long int an = -1e16, x = 0;     if (s[i] == s1[j]) {       long long int y = k;       if (s2[k] != s[i]) {         y--;         y = max(y, 0ll);         y = lps[y];         while (y > 0) {           if (s2[y] == s[i]) {             y++;             break;           }           y = lps[y - 1];         }         if (y == 0 && s2[y] == s[i]) y++;       } else         y++;       x = rec(i + 1, j + 1, y) + 1;       if (x > an) {         opti[i][j][k] = 1;         an = x;       }     }     x = rec(i + 1, j, k);     if (x > an) {       opti[i][j][k] = 2;       an = x;     }     x = rec(i, j + 1, k);     if (x > an) {       opti[i][j][k] = 3;       an = x;     }     return dp[i][j][k] = an;   }   void computeLPSArray() {     int len = 0;     lps[0] = 0;     int i = 1;     while (i < o) {       if (s2[i] == s2[len]) {         len++;         lps[i] = len;         i++;       } else {         if (len != 0) {           len = lps[len - 1];         } else {           lps[i] = 0;           i++;         }       }     }   }   int main() {     for (int i = 0; i <= 104; i++)       for (int j = 0; j <= 104; j++)         for (int k = 0; k <= 104; k++) {           dp[i][j][k] = -1;           opti[i][j][k] = -1;         }     cin >> s >> s1 >> s2;     n = s.length();     m = s1.length();     o = s2.length();     computeLPSArray();     long long int an = rec(0, 0, 0);     if (an <= 0) return cout <<  0  <<   n , 0;     long long int i = 0, j = 0, k = 0;     ans =   ;     while (opti[i][j][k] != -1) {       if (opti[i][j][k] == 1) {         ans.push_back(s[i]);         long long int y = k;         if (s2[k] != s[i]) {           y--;           y = max(y, 0ll);           y = lps[y];           while (y > 0) {             if (s2[y] == s[i]) {               y++;               break;             }             y = lps[y - 1];           }           if (y == 0 && s2[y] == s[i]) y++;         } else           y++;         k = y;         i++, j++;       } else if (opti[i][j][k] == 2)         i++;       else         j++;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char A[5] = { a ,  e ,  i ,  o ,  u };   int main() {     int k;     cin >> k;     int rol = 0, col = 0;     for (int i = 5; i <= sqrt(k); ++i) {       if ((k % i == 0) && (k / i >= 5)) {         rol = i;         col = k / i;         break;       }     }     if (rol == 0) {       cout << -1;     } else {       for (int i = 1; i <= rol; ++i) {         for (int j = 0; j < col; ++j) {           cout << A[(i + j) % 5];         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   const int maxn = 105;   int n;   long long a[maxn], k;   struct Matrix {     long long val[maxn][maxn];     Matrix() { memset(val, 0, sizeof val); }     Matrix operator*(const Matrix B) {       Matrix C;       for (int i = 1; i <= n; ++i) {         for (int j = 1; j <= n; ++j) {           for (int k = 1; k <= n; ++k) {             C.val[i][j] = (C.val[i][j] + val[i][k] * B.val[k][j]) % 1000000007;           }         }       }       return C;     }   };   Matrix Mu(Matrix A, long long b) {     Matrix C;     for (int i = 1; i <= n; ++i) C.val[i][i] = 1;     for (; b; b /= 2, A = A * A) {       if (b % 2) C = C * A;     }     return C;   }   void Solve(int Test) {     cin >> n >> k;     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     Matrix T;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         long long x = a[i] ^ a[j];         if (__builtin_popcountll(x) % 3 == 0) T.val[i][j] = 1;       }     }     Matrix B = Mu(T, k - 1);     long long res = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         res = (res + B.val[i][j]) % 1000000007;       }     }     cout << res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     if (fopen( CF                 .inp ,                r )) {       freopen(            CF             .inp ,            r , stdin);       freopen(            CF             .out ,            w , stdout);     }     int test = 1;     for (int i = 1; i <= test; ++i) {       Solve(i);     }   }
#include <bits/stdc++.h>   int main(void) {     int n;     std::cin >> n;     std::vector<std::string> a(n);     for (int i = 0; i < n; ++i) {       std::cin >> a[i];     }     std::set<std::string> used;     for (int i = n - 1; i >= 0; --i) {       if (used.find(a[i]) == used.end()) {         used.insert(a[i]);         std::cout << a[i] << std::endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, l, r;     cin >> s;     long long a, b, n;     cin >> a >> b;     n = s.size();     long long ar[n];     long long br[n];     ar[n - 1] = -1;     br[0] = -1;     ar[0] = (s[0] -  0 ) % a;     br[n - 1] = (s[n - 1] -  0 ) % b;     for (int i = 1; i < n - 1; i++) {       ar[i] = ((ar[i - 1] * 10) % a + (s[i] -  0 )) % a;     }     long long x = 10;     for (int i = n - 2; i >= 1; i--) {       br[i] = (br[i + 1] + ((s[i] -  0 ) * x)) % b;       x = (x * 10) % b;     }     int d = -1;     for (int i = 0; i < n; i++) {       if (s[i + 1] ==  0 ) continue;       if (ar[i] == 0 && br[i + 1] == 0) {         cout <<  YES  <<   n ;         d = i;         break;       }     }     if (d == -1) {       cout <<  NO ;       return 0;     }     cout << s.substr(0, d + 1) <<   n  << s.substr(d + 1, n - d + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q, w, e, r, t;     char a[51];     cin >> a;     if (a[0] ==  h ) {       cout <<  http:// ;       w = 4;     } else {       cout <<  ftp:// ;       w = 3;     }     cout << a[w];     w++;     while ((a[w] !=  r ) || (a[w + 1] !=  u )) {       cout << a[w];       w++;     }     cout <<  .ru ;     w += 2;     if (a[w]) {       cout <<  / ;       while (a[w]) {         cout << a[w];         w++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 3e+5;   bool vis[MAX_N] = {0};   char t =  . ;   int main() {     int n, m, ans = 0, cnt = 0;     string str;     cin >> n >> m >> str;     for (int i = 0; i < n; i++) {       if (str[i] == t) {         ans++;         if (i == 0 || str[i - 1] != t) cnt++;         vis[i + 1] = 1;       }     }     while (m--) {       int i;       char ch;       cin >> i >> ch;       bool a = vis[i], b = ch == t;       if (a != b) {         if (a)           ans--;         else           ans++;         if (vis[i - 1] && vis[i + 1] && !b)           cnt++;         else if (vis[i - 1] && vis[i + 1] && b)           cnt--;         else if (!vis[i - 1] && !vis[i + 1] && !b)           cnt--;         else if (!vis[i - 1] && !vis[i + 1] && b)           cnt++;       }       vis[i] = b;       cout << ans - cnt << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     string lan1, lan2;     map<string, string> link;     for (int i = 0; i < m; ++i) {       cin >> lan1 >> lan2;       link[lan1] = lan2;     }     for (int j = 0; j < n; ++j) {       cin >> lan1;       if (lan1.size() <= link[lan1].size())         cout << lan1 <<    ;       else         cout << link[lan1] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Mo = (int)1e9 + 7;   vector<int> v[100005];   void add(int x, int y) { v[x].push_back(y); }   int i, n, x, y, f[100005][2], A, B, g[2][2];   int inc(int x, int y) {     x += y;     while (x >= Mo) x -= Mo;     while (x < 0) x += Mo;     return x;   }   void dfs(int x) {     int i;     for (i = 0; i < v[x].size(); ++i) dfs(v[x][i]);     f[x][1] = 1;     f[x][0] = 0;     memset(g, 0, sizeof(g));     g[0][0] = g[0][1] = 1;     if (v[x].size() == 0) return;     for (i = 0; i < v[x].size(); ++i) {       int u = v[x][i];       A = inc(1ll * f[x][1] * f[u][1] % Mo, 1ll * f[x][0] * f[u][0] % Mo);       B = inc(1ll * f[x][1] * f[u][0] % Mo, 1ll * f[x][0] * f[u][1] % Mo);       f[x][0] = inc(f[x][0], A);       f[x][1] = inc(f[x][1], B);     }     f[x][0] = inc(f[x][0], f[x][0]);     f[x][1] = inc(f[x][1], f[x][1]);     for (i = 0; i < v[x].size(); ++i) {       int u = v[x][i];       A = inc(g[0][0], 1LL * f[u][0] * g[1][0] % Mo);       B = inc(g[1][0], 1ll * f[u][0] * g[0][0] % Mo);       g[0][0] = A;       g[1][0] = B;       A = inc(g[0][1], 1ll * f[u][1] * g[1][1] % Mo);       B = inc(g[1][1], 1ll * f[u][1] * g[0][1] % Mo);       g[0][1] = A;       g[1][1] = B;     }     f[x][1] = inc(f[x][1], inc(-g[0][0], -g[1][0]));     f[x][0] = inc(f[x][0], -g[1][1]);   }   int main() {     scanf( %d , &n);     for (i = 2; i <= n; ++i) scanf( %d , &x), add(x, i);     dfs(1);     printf( %d n , (f[1][0] + f[1][1]) % Mo);   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int T;     cin >> T;     while (T--) {       int n, k;       cin >> n >> k;       string N = to_string(n);       string ans =  99999999999999 ;       set<char> S;       for (auto c : N) {         S.insert(c);       }       if ((int)S.size() <= k) {         cout << N <<   n ;         continue;       }       for (int d = 0; d < (int)N.size(); d++) {         string base = N.substr(0, d);         for (int v = N[d] -  0  + 1; v <= 9; v++) {           string s = base + to_string(v);           set<char> have;           for (int i = 0; i < d; i++) {             have.insert(N[i]);           }           have.insert((char)(v +  0 ));           if ((int)have.size() > k) {             continue;           }           if ((int)have.size() < k) {             have.insert( 0 );           }           while (s.size() < N.size()) {             s += *have.begin();           }           assert(s >= N);           ans = min(ans, s);         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = (long long)1e15 + 88;   const int maxn = (int)1e6 + 88;   const int mod = 1000000007;   long long a[maxn];   long long b[maxn];   long long myabs(long long a) {     if (a > 0)       return a;     else       return -a;   }   int main() {     long long n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 1; i <= m; i++) {       cin >> b[i];     }     sort(b + 1, b + m + 1);     b[0] = -inf;     b[m + 1] = inf;     long long dd;     long long Max = 0;     for (int i = 0; i < n; i++) {       long long l = 0, r = m + 2;       while (l <= r) {         long long mid = (l + r) / 2;         if (a[i] == b[mid]) {           l = mid;           break;         } else if (b[mid] < a[i])           l = mid + 1;         else           r = mid - 1;       }       dd = min(myabs(b[l] - a[i]), myabs(b[l - 1] - a[i]));       Max = max(Max, dd);     }     cout << Max;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   int n, w, h;   struct Point {     int d, p, id;     bool operator<(const Point& r) const { return p < r.p; }   };   vector<Point> px[N], py[N];   int ansx[N], ansy[N], tmpx[N], tmpy[N];   int main() {     scanf( %d%d%d , &n, &w, &h);     for (int i = 0; i < n; ++i) {       int g, p, t;       scanf( %d%d%d , &g, &p, &t);       if (g == 1)         px[p - t + 100000].push_back({0, p, i});       else         py[p - t + 100000].push_back({1, p, i});     }     for (int i = 0; i < N; ++i) sort(px[i].begin(), px[i].end());     for (int i = 0; i < N; ++i) sort(py[i].begin(), py[i].end());     for (int i = 0; i < N; ++i) {       int cur = 0;       for (int j = 0; j < px[i].size(); ++j)         tmpx[cur] = px[i][j].p, tmpy[cur] = h, ++cur;       for (int j = (int)py[i].size() - 1; j >= 0; --j)         tmpx[cur] = w, tmpy[cur] = py[i][j].p, ++cur;       cur = 0;       for (int j = (int)py[i].size() - 1; j >= 0; --j)         ansx[py[i][j].id] = tmpx[cur], ansy[py[i][j].id] = tmpy[cur], ++cur;       for (int j = 0; j < px[i].size(); ++j)         ansx[px[i][j].id] = tmpx[cur], ansy[px[i][j].id] = tmpy[cur], ++cur;     }     for (int i = 0; i < n; ++i) printf( %d %d n , ansx[i], ansy[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t;     cin >> t;     while (t--) {       int count = 0;       int ans;       cin >> n;       for (int i = 1; i <= 1666; i++) {         if ((i % 10 != 3) && i % 3 != 0) {           count++;         }         if (count == n) {           ans = i;           break;         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> Arr;   int main() {     int N, K;     cin >> N >> K;     int Num, Acum;     int i, j;     for (i = 0; i < N; i++) {       cin >> Num;       Arr.push_back(Num);     }     sort(Arr.begin(), Arr.end());     j = 0;     Acum = 0;     for (i = 0; i < K; i++) {       if (j >= Arr.size()) {         cout << 0 <<   n ;         continue;       }       Arr[j] -= Acum;       cout << Arr[j] <<   n ;       Acum += Arr[j];       Arr[j] = 0;       while (Arr[j] <= Acum && j < Arr.size()) j += 1;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, P, S;   int s, t;   vector<int> res1, res2;   struct node {     int to;     int cap;     int opp;     int cost;   };   vector<node> v[3500];   int d[3500];   bool in[3500];   int pre[3500], wh[3500];   void add(int x, int y, int cap, int cost) {     node tmp;     tmp.to = y;     tmp.cap = cap;     tmp.cost = cost;     tmp.opp = v[y].size();     v[x].push_back(tmp);     tmp.to = x;     tmp.cap = 0;     tmp.cost = -cost;     tmp.opp = v[x].size() - 1;     v[y].push_back(tmp);   }   bool spfa() {     memset(in, 0, sizeof(in));     for (int i = s; i <= t; i++) d[i] = -199912310;     queue<int> q;     q.push(s);     d[s] = 0;     while (!q.empty()) {       int x = q.front();       q.pop();       in[x] = false;       for (int i = 0; i < (int)v[x].size(); i++) {         if (v[x][i].cap <= 0) continue;         if (d[v[x][i].to] < d[x] + v[x][i].cost) {           d[v[x][i].to] = d[x] + v[x][i].cost;           pre[v[x][i].to] = x;           wh[v[x][i].to] = i;           if (!in[v[x][i].to]) {             in[v[x][i].to] = true;             q.push(v[x][i].to);           }         }       }     }     return d[t] != -199912310;   }   long long max_flow() {     long long ret = 0;     while (spfa()) {       int flow = 199912310;       for (int i = t; i; i = pre[i]) {         flow = min(flow, v[pre[i]][wh[i]].cap);       }       ret += 1ll * flow * d[t];       for (int i = t; i; i = pre[i]) {         v[pre[i]][wh[i]].cap -= flow;         v[i][v[pre[i]][wh[i]].opp].cap += flow;       }     }     return ret;   }   int main() {     scanf( %d , &n);     scanf( %d%d , &P, &S);     s = 0;     t = n + 3;     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       add(i, n + 1, 1, x);     }     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       add(i, n + 2, 1, x);       add(0, i, 1, 0);     }     add(n + 1, t, P, 0);     add(n + 2, t, S, 0);     printf( %d n , max_flow());     for (int i = 1; i <= n; i++) {       for (int j = 0; j < (int)v[i].size(); j++) {         if (v[i][j].to == n + 1 && v[i][j].cap == 0) {           res1.push_back(i);         }         if (v[i][j].to == n + 2 && v[i][j].cap == 0) {           res2.push_back(i);         }       }     }     for (int i = 0; i < (int)res1.size(); i++) printf( %I64d  , res1[i]);     puts(  );     for (int i = 0; i < (int)res2.size(); i++) printf( %d  , res2[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b;     cin >> a;     cin >> b;     sort(a.begin(), a.end());     for (int i = 0; i < a.size(); i++) {       if (a[i] !=  0  && a[0] ==  0 ) {         swap(a[i], a[0]);         break;       }     }     if (a == b)       cout <<  OK  << endl;     else       cout <<  WRONG_ANSWER  << endl;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n, x;     cin >> n >> x;     long long int a[n];     set<long long int> s;     long long int sum = 0;     for (long long int i = 0; i < n; i++) {       cin >> a[i];       s.insert(a[i]);       sum += a[i];     }     long long int y = *(s.begin());     if (s.size() == 1 && y == x) {       cout << 0 <<   n ;       return;     }     if (s.find(x) != s.end()) {       cout << 1 <<   n ;       return;     }     if (sum == n * x) {       cout << 1 <<   n ;       return;     }     cout << 2 <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     cout.precision(20);     long long int t = 1;     cin >> t;     for (long long int i = 1; i <= t; i++) {       if (0) cout <<  Case #  << i <<  :  ;       solve();     }   }