malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000 * 1000 * 1000 + 7;   const double PI = acos(-1.0);   long long gcd(long long a, long long b) {     long long m;     while (b) {       m = a % b;       a = b;       b = m;     }     return a;   }   int solve() {     string s;     cin >> s;     long long total = 0;     int n = s.size();     for (int i = 0; i < n; ++i) {       if (s[i] >=  0  && s[i] <=  9 ) {         int j = i;         long long u = 0;         int dot = -1;         while (s[j] >=  0  && s[j] <=  9  || s[j] ==  . ) {           if (s[j] ==  . )             dot = j;           else             u = u * 10 + (s[j] -  0 );           ++j;         }         if (dot == -1 || j - dot != 3) u = u * 100;         total += u;         i = j - 1;       }     }     s.clear();     if (total % 100 != 0) {       s += total % 10 +  0 ;       total /= 10;       s += total % 10 +  0 ;       total /= 10;       s +=  . ;     } else {       total /= 100;     }     int j = 0;     do {       ++j;       s += total % 10 +  0 ;       if (j == 3) s +=  . , j = 0;     } while (total /= 10);     if (s.back() ==  . ) s.pop_back();     reverse(s.begin(), s.end());     cout << s << endl;     return 0;   }   int main() { solve(); }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     string s;     cin >> s;     int x = 0, y = 0;     for (int i = 0; i < s.size(); i++) s[i] ==  x  ? x++ : y++;     if (x > y)       for (int i = 0; i < x - y; i++) cout <<  x ;     else       for (int i = 0; i < y - x; i++) cout <<  y ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, req = 1;     scanf( %d , &n);     map<int, int> index;     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       if (x == req) {         index[x] = i + 1 + 2000;         req++;       }     }     int cnt = 0;     for (int i = 1; index[i] != 0; i++) {       cnt++;     }     printf( %d n , cnt);     if (cnt) printf( %d , index[1]);     for (int i = 2; index[i] != 0; i++) {       printf(  %d , index[i]);     }     if (cnt) printf(  n );     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   int n, m;   char a[2000000], b[2000000];   int main() {     int i, j, k;     scanf( %s%s , a, b);     n = strlen(a), m = strlen(b);     int now = 0;     for (i = 0; i < m; i++) {       if (b[i] == a[now]) {         now++;         if (now == n) break;       }     }     int c1, c2;     c1 = i;     now = n - 1;     for (i = m - 1; i >= 0; i--) {       if (b[i] == a[now]) {         now--;         if (now == -1) break;       }     }     c2 = i;     printf( %d , max(0, c2 - c1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int u[n + 1];     int a[n + 1][n + 1];     int maxx[n + 1];     int dom[n + 1];     for (int i = 1; i <= n; i++) {       cin >> u[i];       for (int j = 1; j <= n; j++) {         a[i][j] = 0;       }       maxx[i] = u[i];       dom[i] = 0;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= i; j++) {         a[u[i]][j]++;         if (maxx[j] != u[i]) {           if (a[u[i]][j] > a[maxx[j]][j]) {             maxx[j] = u[i];             dom[u[i]]++;           } else if (a[u[i]][j] == a[maxx[j]][j]) {             if (u[i] < maxx[j]) {               maxx[j] = u[i];               dom[u[i]]++;             } else {               dom[maxx[j]]++;             }           } else if (a[u[i]][j] < a[maxx[j]][j]) {             dom[maxx[j]]++;           }         } else {           dom[u[i]]++;         }       }     }     for (int i = 1; i <= n; i++) {       cout << dom[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma )   #pragma GCC optimize( unroll-loops )   using namespace std;   long long MOD = 998244353;   double eps = 1e-12;   void solve() {     long long n;     cin >> n;     for (long long i = 0; i <= n; i++) {       for (long long j = 0; j <= n; j++) {         for (long long k = 0; k <= n; k++) {           if ((i * 3 + j * 5 + k * 7) == n) {             cout << i <<     << j <<     << k <<   n ;             return;           }         }       }     }     cout << -1 <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     for (int it = 1; it <= t; it++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   int main() {     int T;     cin >> T;     while (T--) {       long long n, m;       cin >> n >> m;       long long d = n / m;       long long w = m % 10;       long long sm = 0;       for (int i = 0; i < 10; i++) {         sm += (i * w) % 10;       }       long long fsm = 0;       for (int i = 1; i <= d % 10; i++) {         fsm += (i * w) % 10;       }       cout << sm * (d / 10) + fsm <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5000 + 10;   int n, T;   double p[MAXN];   int t[MAXN];   double dp[MAXN][MAXN];   int main() {     scanf( %d%d , &n, &T);     for (int i = 1; i <= n; ++i) {       scanf( %lf%d , &p[i], &t[i]);       p[i] *= 0.01;     }     double ans = 0.0;     dp[0][0] = 1.0;     for (int i = 1; i <= n; ++i) {       double sum = 0.0;       double npn = pow(1.0 - p[i], t[i]);       for (int j = 1; j <= T; ++j) {         sum += dp[i - 1][j - 1];         if (j > t[i]) {           sum -= dp[i - 1][j - t[i] - 1] * npn;         }         dp[i][j] += sum * p[i];         if (j >= t[i]) {           dp[i][j] += dp[i - 1][j - t[i]] * npn;         }         sum *= 1.0 - p[i];         ans += dp[i][j];       }     }     printf( %.8f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, max = -1;     cin >> n;     long long int a[n], b[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = n - 1; i >= 0; i--) {       if (max < a[i]) {         max = a[i];         b[n - i] = 0;       } else {         b[n - i] = max + 1 - a[i];       }     }     for (int i = n; i > 0; i--) {       cout << b[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   inline int in() {     int x;     scanf( %d , &x);     return x;   }   inline long long lin() {     long long x;     scanf( %I64d , &x);     return x;   }   vector<int> G[N + N];   pair<int, int> edg[N + N];   int n, k, start;   int inp[N + N];   int st[N + N], T = 1;   long long res, f[N + N];   void dfs(int u, int par) {     st[u] = T++;     if (inp[u] == 1) f[u]++;     for (int i = 0; i < (int)G[u].size(); i++) {       int v = G[u][i];       if (v != par) {         dfs(v, u);         f[u] += f[v];         res += min(f[v], 2LL * k - f[v]);       }     }   }   int main() {     n = in();     k = in();     for (int i = 1; i <= k + k; i++) {       int x = in();       inp[x] = 1;     }     for (int i = 1; i <= n - 1; i++) {       int u = in(), v = in();       G[u].push_back(v);       G[v].push_back(u);       edg[i] = make_pair(u, v);     }     res = 0;     dfs(1, -1);     printf( %I64d n , res);   }
#include <bits/stdc++.h>   using namespace std;   bool test(long long, long long, long long);   int main(void) {     long long n, m;     cin >> n >> m;     long long first, last;     first = 0;     last = sqrt(2 * n) + 1;     if (m >= n) {       cout << n;       return 0;     }     while (test(first, n, m) == 0) {       long long med;       med = (first + last) / 2;       if (test(med, n, m) == 1)         last = med;       else         first = med;       if (last - first == 1 && test(first, n, m) == 0) first = last;     }     cout << first + m;     return 0;   }   bool test(long long day, long long n, long long m) {     if (day % 2 == 0) {       if ((day / 2) * (day + 1) >= (n - m)) return 1;     } else {       if (day * ((day + 1) / 2) >= (n - m)) return 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[50005];   map<string, int> st;   int sq = 300;   vector<int> p[500100];   vector<int> h;   string s1[500100];   int res[1010][1010];   void pro(int x1, int y1) {     int x = h[x1];     int y = h[y1];     int pri = -1, prj = -1;     int mn = 1e9;     int r;     for (int i = 0, j = 0; i < p[x].size() || j < p[y].size();) {       if (i < p[x].size() && j < p[y].size()) {         r = max(p[x][i] + s1[x].size(), p[y][j] + s1[y].size()) -             min(p[x][i], p[y][j]);         mn = min(mn, r);       }       if (i >= p[x].size())         prj = p[y][j], j++;       else if (j >= p[y].size())         pri = p[x][i], i++;       else if (p[x][i] < p[y][j])         pri = p[x][i], i++;       else         prj = p[x][j], j++;     }     res[x1][y1] = mn;     res[y1][x1] = mn;   }   int main() {     scanf( %s , s);     int n = strlen(s);     int k = 0;     for (int i = 0; i < n; i++) {       string t =   ;       for (int j = 0; j < 4 && j + i < n; j++) {         t.push_back(s[j + i]);         if (st.count(t) == 0) {           s1[k] = t;           st[t] = k++;         }         p[st[t]].push_back(i);       }     }     for (int i = 0; i < k; i++) {       if (p[i].size() > sq) {         h.push_back(i);       }     }     for (int i = 0; i < h.size(); i++) {       res[i][i] = s1[h[i]].size();       for (int j = i + 1; j < h.size(); j++) {         pro(i, j);       }     }     int q;     cin >> q;     char s2[10];     char s3[10];     vector<int>::iterator it, it1;     while (q--) {       scanf( %s , s2);       scanf( %s , s3);       if (st.count(s2) == 0 || st.count(s3) == 0) {         printf( -1 n );         continue;       }       int x = st[s2];       int y = st[s3];       it = lower_bound(h.begin(), h.end(), x);       it1 = lower_bound(h.begin(), h.end(), y);       int mn = 1e9, r;       if (it != h.end() && *it == x && it1 != h.end() && *it1 == y) {         printf( %d n , res[it - h.begin()][it1 - h.begin()]);         continue;       } else if (it == h.end() || *it != x) {         for (int i = 0; i < p[x].size(); i++) {           it = lower_bound(p[y].begin(), p[y].end(), p[x][i]);           if (it != p[y].end()) {             r = max(p[x][i] + s1[x].size(), *it + s1[y].size());             r -= min(p[x][i], *it);             mn = min(mn, r);           }           if (it != p[y].begin()) {             it--;             r = max(p[x][i] + s1[x].size(), *it + s1[y].size());             r -= min(p[x][i], *it);             mn = min(mn, r);           }         }       } else {         for (int i = 0; i < p[y].size(); i++) {           it = lower_bound(p[x].begin(), p[x].end(), p[y][i]);           if (it != p[x].end()) {             r = max(p[y][i] + s1[y].size(), *it + s1[x].size());             r -= min(p[y][i], *it);             mn = min(mn, r);           }           if (it != p[x].begin()) {             it--;             r = max(p[y][i] + s1[y].size(), *it + s1[x].size());             r -= min(p[y][i], *it);             mn = min(mn, r);           }         }       }       printf( %d n , mn);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, a[1000500];   map<pair<int, long long>, bool> dp;   bool found = false;   void solve(int idx, long long sum, bool take) {     if (found) return;     if (take && sum % m == 0) {       found = true;       return;     }     if (idx >= n) return;     bool &ret = dp[{idx, sum}];     if (ret) return;     ret = true;     solve(idx + 1, sum + a[idx], take + 1);     if (found) return;     solve(idx + 1, sum, take);     if (found) return;   }   int main() {     scanf( %lld%lld , &n, &m);     bool z = false;     for (int i = 0; i < n; ++i) scanf( %lld , &a[i]), z |= (a[i] == 0);     solve(0, 0, 0);     if (z || found) return puts( YES );     puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char c = getchar();     int x = 0, f = 1;     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     return x * f;   }   const int MAXN = 8e3 + 5;   int nxt[MAXN], p[MAXN][MAXN], dp[MAXN];   int N, len;   char s[MAXN], S[MAXN];   inline int calc(int x) {     int ret = 0;     while (x) x /= 10, ret++;     return ret;   }   inline void KMP(int st) {     len = N - st + 1;     for (int i = 1; i <= len; i++) s[i] = S[st + i - 1];     int j = 0;     for (int i = 2; i <= len; i++) {       while (j && s[i] != s[j + 1]) j = nxt[j];       if (s[i] == s[j + 1]) j++;       nxt[i] = j;     }     for (int i = 1; i <= len; i++) {       int tmp = i - nxt[i];       if (i % tmp) tmp = i;       p[st][st + i - 1] = tmp + calc(i / tmp);     }   }   int main() {     scanf( %s , S + 1);     N = strlen(S + 1);     for (int i = 1; i <= N; i++) KMP(i);     memset(dp, 0x3f, sizeof(dp));     dp[0] = 0;     for (int i = 1; i <= N; i++)       for (int j = 0; j < i; j++) dp[i] = min(dp[i], dp[j] + p[j + 1][i]);     printf( %d n , dp[N]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void maxtt(T& t1, T t2) {     t1 = max(t1, t2);   }   template <typename T>   void mintt(T& t1, T t2) {     t1 = min(t1, t2);   }   bool debug = 0;   int n, m, k;   string direc =  URDL ;   const long long MOD2 = (long long)1000000007 * (long long)1000000007;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int& x, int y, int mod = 1000000007) {     x += y;     if (x >= mod) x -= mod;     if (x < 0) x += mod;     assert(x >= 0 && x < mod);   }   void et(int x = -1) {     printf( %d n , x);     exit(0);   }   long long fastPow(long long x, long long y, int mod = 1000000007) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }   int p[1000035], q[1000035];   void fmain(int tid) {     scanf( %d%lld , &n, &lk);     for (int(i) = 1; (i) <= (int)(n); (i)++) {       p[i] = q[i] = i;     }     long long mi = (long long)(n + 1) * n / 2;     int hf = n / 2;     long long mx = (long long)(n - hf + 1 + n) * hf;     if (n & 1) mx += n / 2 + 1;     if (lk < mi) et();     mintt(lk, mx);     long long tar = lk - mi;     for (int(i) = 1; (i) <= (int)(hf); (i)++) {       int bg = n + 1 - i;       if (bg - i <= tar) {         swap(q[i], q[bg]);         tar -= bg - i;       } else {         swap(q[i], q[i + tar]);         break;       }     }     printf( %lld n , lk);     for (int(i) = 1; (i) <= (int)(n); (i)++) printf( %d  , p[i]);     puts(  );     for (int(i) = 1; (i) <= (int)(n); (i)++) printf( %d  , q[i]);     puts(  );   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct abc {     int p, q, idx;   };   bool compareTwoStudents(abc a, abc b) {     if (a.p != b.p) return a.p < b.p;     return (a.q < b.q);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int i, j, k, m, n, t, u, v, w, p = 0, q, flag = 0;     long long int x, y, z;     string s, s1, s2;     vector<int> abc;     vector<int>::iterator it;     priority_queue<int> pq;     map<int, int> make_pair;     cin >> t;     while (t--) {       std::cin >> n;       std::cout << n <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void out(T x) {     cout << x << endl;     exit(0);   }   const int maxn = 2000 + 7;   int n;   long double p;   int t;   long double dp[maxn][maxn];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> p >> t;     dp[0][0] = 1.0;     for (int i = 0; i < t; i++) {       for (int j = 0; j < n; j++) {         dp[i + 1][j] += (1.0 - p) * dp[i][j];         dp[i + 1][j + 1] += p * dp[i][j];       }       dp[i + 1][n] += dp[i][n];     }     long double ans = 0.0;     for (int i = 1; i <= n; i++) {       ans += 1.0 * i * dp[t][i];     }     cout << fixed << setprecision(12) << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3,  Ofast ,  inline )   #pragma GCC target( avx )   using namespace std;   template <class t>   inline t read(t &x) {     char c = getchar();     bool f = 0;     x = 0;     while (!isdigit(c)) f |= c ==  - , c = getchar();     while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();     if (f) x = -x;     return x;   }   template <class t>   inline void write(t x) {     if (x < 0)       putchar( - ), write(-x);     else {       if (x > 9) write(x / 10);       putchar( 0  + x % 10);     }   }   const int mod = 1e9 + 7, N = 705;   int ans, n, dig[N], f[N][N][10][2];   char s[N];   signed main() {     scanf( %s , s + 1);     n = strlen(s + 1);     for (int i = 1; i <= n; i++) dig[i] = s[i] ^ 48;     for (int i = 0; i <= 9; i++) f[0][0][i][0] = 1;     for (int i = 0; i < n; i++)       for (int j = 0; j <= i; j++)         for (int k = 1; k <= 9; k++)           for (int lim = 0; lim <= 1; lim++)             for (int x = 0; x <= (lim ? 9 : dig[i + 1]); x++)               (f[i + 1][j + (x >= k)][k][lim | (x < dig[i + 1])] +=                f[i][j][k][lim]) %= mod;     for (int k = 1; k <= 9; k++)       for (int i = 1, mul = 1; i <= n; i++)         ans = (ans + 1ll * mul * (f[n][i][k][0] + f[n][i][k][1]) % mod) % mod,         mul = (1ll * mul * 10 + 1) % mod;     write(ans);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 100;   int a[N];   int per[N];   int main() {     int n;     cin >> n;     for (int i = 0; i < n - 1; i++) {       scanf( %d , &a[i]);     }     int ls = a[0];     set<int> st;     for (int i = 1; i <= n; i++) {       st.insert(i);     }     for (int i = 0; i < n - 1; i++) {       if (per[a[i]]) {         ls = *(--st.end());         st.erase(--st.end());         per[ls] = a[i];       } else {         st.erase(a[i]);         per[a[i]] = per[ls];         per[ls] = a[i];         if (i == 0) i--;       }     }     printf( %d n , a[0]);     for (int i = 1; i <= n; i++) {       if (per[i] == i) continue;       printf( %d %d n , i, per[i]);     }     return 0;   }
#include <bits/stdc++.h>   int a, b, c;   long long int MOD;   long long int Comb[110][110];   long long int comb(int a, int b) {     if (a == b) return 1;     if (b == 0) return 1;     if (Comb[a][b] != -1) return Comb[a][b];     return Comb[a][b] = (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;   }   int check[110][110];   std::vector<long long int> ans[110][110];   void func(int k, int h) {     if (check[k][h]) return;     if (k == 0) {       ans[k][h].push_back(1 % MOD);       check[k][h] = 1;       return;     }     int start = 0;     if (h == b) start++;     for (int i = 0; i <= k - 1; i++) {       func(i, h + 1);       func(k - i - 1, h + 1);       while (ans[k][h].size() <=              start + ans[i][h + 1].size() + ans[k - i - 1][h + 1].size() - 2)         ans[k][h].push_back(0);       for (int j1 = 0; j1 < ans[i][h + 1].size(); j1++) {         for (int j2 = 0; j2 < ans[k - i - 1][h + 1].size(); j2++) {           long long int t = ans[i][h + 1][j1] * ans[k - i - 1][h + 1][j2];           t %= MOD;           t *= comb(k - 1, i), t %= MOD;           ans[k][h][start + j1 + j2] += t, ans[k][h][start + j1 + j2] %= MOD;         }       }     }     check[k][h] = 1;   }   int main() {     scanf( %d%d%d%lld , &a, &b, &c, &MOD);     for (int i = 0; i <= a; i++)       for (int j = 0; j <= a; j++) Comb[i][j] = -1;     func(a, 1);     if (ans[a][1].size() >= c + 1)       printf( %lld , ans[a][1][c] % MOD);     else       printf( 0 );   }
#include <bits/stdc++.h>   const long long INF = 2 * 1e9;   const long long MOD = 1000000007;   using namespace std;   void solve() {     long long n, k, m;     cin >> n >> k >> m;     vector<long long> a(n);     vector<pair<long long, long long> > c;     long long x;     cin >> x;     c.push_back({x, 1});     long long cnt = 0;     for (long long i = 1; i < n; i++) {       long long x;       cin >> x;       if (c.size() == 0) {         c.push_back({x, 1});         continue;       }       if (x == c.back().first) {         c[(long long)(c).size() - 1].second++;         cnt += c[(long long)(c).size() - 1].second / k * k;         c[(long long)(c).size() - 1].second %= k;         if (c[(long long)(c).size() - 1].second == 0) c.pop_back();       } else {         c.push_back({x, 1});       }     }     if ((long long)(c).size() == 0) {       cout << 0 <<   n ;       return;     }     long long i = 0, j = (long long)(c).size() - 1;     auto tmp = c;     long long cnt1 = 0;     while (1) {       if (tmp[i].first == tmp[j].first) {         if (i == j) break;         cnt1 += (tmp[i].second + tmp[j].second) / k * k;         if ((tmp[i].second + tmp[j].second) % k == 0) {           i++;           j--;         } else           break;       } else {         break;       }     }     long long ans = 0;     if (i == j && tmp[i].first == tmp[j].first) {       long long cur = tmp[i].second * m;       long long cnt2 = (cur / k) * k;       cur %= k;       ans += cnt * m + cnt1 * (m - 1) + cnt2;       if (cur == 0) {         i--;         j++;         while (i >= 0 && j < tmp.size()) {           if (tmp[i].first == tmp[j].first) {             ans += (tmp[i].second + tmp[j].second) / k * k;             if ((tmp[i].second + tmp[j].second) % k == 0) {               i--;               j++;             } else               break;           } else             break;         }       }     } else {       ans += cnt * m + (cnt1) * (m - 1);     }     cout << n * m - ans <<   n ;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.fixed;     cout.precision(12);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n;     cin >> n;     long long int ans = 0;     if (n == 1 || n == 2) {       cout << n << endl;       return 0;     }     for (long long int i = 1; i <= (sqrt(n)); i++) {       if (n % i == 0) ans += 2;       if (i * i == n) ans = ans - 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     map<int, int> m;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       m[a[i]]++;     }     int chek[32];     chek[0] = 2;     for (int i = 1; i < 32; i++) {       chek[i] = chek[i - 1] * 2;     }     int sm = 0, coun = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < 32; j++) {         int h = chek[j] - a[i];         if (m.find(h) != m.end()) {           if (h == a[i] && m[a[i]] > 1) {             coun++;             break;           }           if (h != a[i]) {             coun++;             break;           }         }       }     }     cout << n - coun << endl;     return 0;   }
#include <bits/stdc++.h>   #define testCase int T; cin>>T; while(T--)   #define int long long   #define Endl endl      using namespace std;      /*    */   const int N = 1e5+13, LMAX  = 3e18 + 13, IMAX = 1e9 + 5, mod  = 1e9 + 7; //998244353;      int32_t main() {       ios_base::sync_with_stdio(false);       cin.tie(nullptr);          testCase {           int mn = 101;           int n, x;           cin >> n;           for (int i = 0; i < n; ++i) {               cin >> x;               mn = min(mn, x);           }           if (mn < 0) cout <<  NO n ;           else {               cout <<  YES n ;               cout <<  101 n ;               for (int i = 0; i <=100; ++i) {                   cout << i <<    ;               }cout <<   n ;           }       }       return 0;   }