malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n + 1];     vector<int> g[n + 1];     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     set<pair<int, int> > last;     int k = 0;     for (int i = 1; i <= n; i++) {       set<pair<int, int> >::iterator it = last.lower_bound(make_pair(a[i], 1));       if (it == last.begin()) {         g[++k].push_back(a[i]);         last.insert(make_pair(a[i], k));       } else {         --it;         g[it->second].push_back(a[i]);         last.erase(it);         last.insert(make_pair(a[i], it->second));       }     }     for (int i = 1; i <= k; i++) {       for (int j : g[i]) {         cout << j <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 33333;   const int mod = 998244353, G = 3;   int n, k, T, a[MAXN], W, rev[MAXN], gen[MAXN];   vector<int> vec[MAXN];   inline int qpow(int a, int b) {     int re = 1;     for (; b; b >>= 1, a = 1ll * a * a % mod)       if (b & 1) re = 1ll * re * a % mod;     return re;   }   inline int pls(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }   inline void add(int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; }   void NTT(vector<int> &arr, int len, int flg) {     for (int i = 0; i < len; ++i)       if (i < rev[i]) swap(arr[i], arr[rev[i]]);     for (int v, i = 2, B = W >> 1; i <= len; i <<= 1, B >>= 1)       for (int j = 0; j < len; j += i)         for (int k = j, x = 0; k < j + i / 2; ++k, x += B)           arr[k + i / 2] = pls(               arr[k],               mod - (v = 1ll * arr[k + i / 2] * gen[flg == 1 ? x : W - x] % mod)),                       add(arr[k], v);     if (flg == -1) {       int iv = qpow(len, mod - 2);       for (int i = 0; i < len; ++i) arr[i] = 1ll * arr[i] * iv % mod;     }   }   vector<int> solve(int l, int r) {     if (l == r) return vec[l];     int mid = (l + r) >> 1;     vector<int> L = solve(l, mid), R = solve(mid + 1, r);     int len = 1;     while (len <= r - l + 1) len <<= 1;     for (int i = 1; i < len; ++i)       rev[i] = (rev[i >> 1] >> 1) | ((i & 1) * (len >> 1));     L.resize(len), R.resize(len);     NTT(L, len, 1), NTT(R, len, 1);     for (int i = 0; i < len; ++i) L[i] = 1ll * L[i] * R[i] % mod;     NTT(L, len, -1);     L.resize(r - l + 2);     return L;   }   int main() {     scanf( %d%d , &n, &k);     for (W = 1; W <= n; W <<= 1)       ;     gen[0] = 1, gen[1] = qpow(G, (mod - 1) / W);     for (int i = 2; i <= W; ++i) gen[i] = 1ll * gen[i - 1] * gen[1] % mod;     for (int i = 1; i <= n; ++i)       scanf( %d , &a[i]), vec[i].resize(2), vec[i][0] = 1;     int op, q, x, y, d;     for (scanf( %d , &T); T--;) {       scanf( %d%d%d , &op, &q, &x);       if (op == 2)         scanf( %d , &y);       else         y = x;       scanf( %d , &d);       for (int i = 1; i <= n; ++i)         vec[i][1] =             ((q - ((x <= i && i <= y) ? (op == 1 ? d : a[i] + d) : a[i])) % mod +              mod) %             mod;       vector<int> ans = solve(1, n);       printf( %d n , ans[k]);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     map<int, int> m;     int u = 0;     long long powers[32];     powers[0] = 1;     for (int i = 1; i < 32; i++) powers[i] = 2 * powers[i - 1];     for (int i = 0; i < n; i++) {       cin >> a[i];       m[a[i]]++;     }     bool flag = false;     for (int i = 0; i < n; i++) {       flag = false;       for (int j = 0; j < 32; j++) {         long long x = powers[j] - a[i];         if (m[x] > 1 || (m[x] == 1 && x != a[i])) {           flag = true;           break;         }       }       if (!flag) u++;     }     cout << u << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[500010];   int d1[500010];   int d2[500010];   int main() {     int n;     cin >> n;     for (int i = (0); i < (int)(n); i++) cin >> arr[i];     int last2left = 0;     for (int i = (1); i < (int)(n - 1); i++) {       if (arr[i] == arr[i - 1]) {         last2left = i;         d1[i] = i;       } else {         d1[i] = last2left;       }     }     last2left = n - 1;     for (int i = (n - 1 - 1); i >= (int)(1); i--) {       if (arr[i] == arr[i + 1]) {         last2left = i;         d2[i] = i;       } else {         d2[i] = last2left;       }     }     int res = 0;     for (int i = (1); i < (int)(n - 1); i++)       res = max(res, min(i - d1[i], d2[i] - i));     cout << res << endl;     cout << arr[0] <<    ;     for (int i = (1); i < (int)(n - 1); i++)       cout << ((i - d1[i] < d2[i] - i) ? arr[d1[i]] : arr[d2[i]]) <<    ;     cout << arr[n - 1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   string ANSWER[2] = { NO n ,  YES n };   int v[2009], s1[2009], s2[2009];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &v[i]);       s1[i] = s1[i - 1] + (v[i] == 1);       s2[i] = s2[i - 1] + (v[i] == 2);     }     int ans = 0;     for (int i = 1; i <= n; i++) {       int a = 0, b = 0;       for (int j = i; j <= n; j++) {         if (v[j] == 1) b++;         if (v[j] == 2) a++;         if (a > b) b = a;         ans = max(ans, s1[i - 1] + b + s2[n] - s2[j]);       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x, y, n, d, x_i, y_i;   vector<pair<int, int> > v;   double dist(double x1, double y1) { return sqrt(pow(x1, 2) + pow(y1, 2)); }   int a[605][605];   int f(int _x, int _y) {     if (a[200 + _x][200 + _y] == -1) {       int tmp = 1;       if (dist(_x, _y) <= d) {         for (auto _i : v) {           if (f(_x + _i.first, _y + _i.second)) {             tmp = 0;             break;           }         }       } else {         tmp = 0;       }       a[200 + _x][200 + _y] = tmp;     }     return a[200 + _x][200 + _y];   }   int main() {     ios::sync_with_stdio(0);     cin >> x >> y >> n >> d;     (memset(a, -1, sizeof(a)));     for (int(i) = (0); (i) < (n); (i)++) {       cin >> x_i >> y_i;       v.push_back({x_i, y_i});     }     cout << (!f(x, y) ?  Anton  :  Dasha ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, i, n;     int edges[int(2e5 + 1)][2], weights[int(2e5 + 1)], freq[int(2e5 + 1)];     cin >> n;     for (i = 1; i <= n; i++) freq[i] = 0;     for (i = 0; i < n; i++) {       weights[i] = -1;       cin >> edges[i][0] >> edges[i][1];       freq[edges[i][0]]++;       freq[edges[i][1]]++;     }     int maxindex = 1, k = 0;     for (i = 1; i <= n; i++)       if (freq[i] > freq[maxindex]) maxindex = i;     for (i = 0; i < n; i++)       if (edges[i][0] == maxindex or edges[i][1] == maxindex) weights[i] = k++;     for (i = 0; i < n; i++)       if (weights[i] == -1) weights[i] = k++;     for (i = 0; i < n - 1; i++) cout << weights[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void debug() { cout << endl; }   template <typename T, typename... E>   void debug(T t, E... e) {     cout << t << (sizeof...(e) ?     :   );     debug(e...);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int a, b, c, d;     cin >> a >> b >> c >> d;     double p1 = double(a) / b;     double p2 = double(c) / d;     double ans = p1 / (1 - (1 - p1) * (1 - p2));     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   inline int in() {     int32_t x;     scanf( %d , &x);     return x;   }   inline long long lin() {     long long x;     scanf( %lld , &x);     return x;   }   const int maxn = 2e5 + 10;   const int mod = 1e9 + 7;   const long long infll = 1e18;   const int inf = 1e9;   int lcp[40][40];   string s[maxn];   int32_t main() {     int n = in(), k = in();     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         int where = 0;         while (where < s[i].size() && where < s[j].size() &&                s[i][where] == s[j][where])           where++;         lcp[i][j] = where;       }     }     int res = 0;     for (int mask = 0; mask < (1 << n); mask++) {       if (__builtin_popcount(mask) - k) continue;       vector<int> Ids;       for (int i = 0; i < n; i++)         if (mask >> i & 1) Ids.push_back(i);       int tot = 0;       for (int i = 0; i < Ids.size(); i++)         for (int j = i + 1; j < Ids.size(); j++) tot += lcp[Ids[i]][Ids[j]];       res = max(res, tot);     }     cout << res << endl;   }
#include <bits/stdc++.h>   const int N = 4005;   const int M = 80;   const int MOD = 998244353;   int m, jc[M], ny[M];   struct Tree {     int n, cnt, last[N], f[M][N], g[M][N], size[N], ans[M], w[N], tot, a[N], sum,         root;     bool vis[N];     struct edge {       int to, next;     } e[N * 2];     void addedge(int u, int v) {       e[++cnt].to = v;       e[cnt].next = last[u];       last[u] = cnt;       e[++cnt].to = u;       e[cnt].next = last[v];       last[v] = cnt;     }     void get_root(int x, int fa) {       size[x] = 1;       w[x] = 0;       for (int i = last[x]; i; i = e[i].next) {         if (e[i].to == fa || vis[e[i].to]) continue;         get_root(e[i].to, x);         size[x] += size[e[i].to];         w[x] = std::max(w[x], size[e[i].to]);       }       w[x] = std::max(w[x], sum - size[x]);       if (!root || w[x] < w[root]) root = x;     }     void get(int x, int fa) {       a[++tot] = x;       size[x] = 1;       for (int i = last[x]; i; i = e[i].next)         if (e[i].to != fa && !vis[e[i].to])           get(e[i].to, x), size[x] += size[e[i].to];     }     void calc(int x) {       tot = 0;       get(x, 0);       f[0][x] = g[0][x] = 1;       for (int i = 1; i <= m; i++)         for (int j = 1; j <= tot; j++) {           int y = a[j];           f[i][y] = g[i][y] = 0;           for (int k = last[y]; k; k = e[k].next) {             if (vis[e[k].to]) continue;             (g[i][y] += g[i - 1][e[k].to]) %= MOD;             if (y != x) (f[i][y] += f[i - 1][e[k].to]) %= MOD;           }         }       for (int i = 1; i <= tot; i++) {         int y = a[i];         if (y == x) {           for (int j = 0; j <= m; j++) (ans[j] += g[j][x]) %= MOD;           continue;         }         for (int j = 0; j <= m; j++)           for (int k = 0; j + k <= m; k++)             (ans[j + k] += (long long)f[j][y] * g[k][y] % MOD) %= MOD;       }       vis[x] = 1;       for (int i = last[x]; i; i = e[i].next) {         if (vis[e[i].to]) continue;         root = 0;         sum = size[e[i].to];         get_root(e[i].to, x);         calc(root);       }     }     void solve() {       sum = n;       root = 0;       get_root(1, 0);       calc(root);     }   } t1, t2;   int C(int n, int m) { return (long long)jc[n] * ny[m] % MOD * ny[n - m] % MOD; }   int main() {     scanf( %d%d%d , &t1.n, &t2.n, &m);     jc[0] = jc[1] = ny[0] = ny[1] = 1;     for (int i = 2; i <= m; i++)       jc[i] = (long long)jc[i - 1] * i % MOD,       ny[i] = (long long)(MOD - MOD / i) * ny[MOD % i] % MOD;     for (int i = 2; i <= m; i++) ny[i] = (long long)ny[i - 1] * ny[i] % MOD;     for (int i = 1; i < t1.n; i++) {       int x, y;       scanf( %d%d , &x, &y);       t1.addedge(x, y);     }     for (int i = 1; i < t2.n; i++) {       int x, y;       scanf( %d%d , &x, &y);       t2.addedge(x, y);     }     t1.solve();     t2.solve();     int s = 0;     for (int i = 0; i <= m; i++)       (s += (long long)t1.ans[i] * t2.ans[m - i] % MOD * C(m, i) % MOD) %= MOD;     printf( %d , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   const long long mod2 = 998244353;   long long fpow(long long x, long long y, long long p = 1000000007) {     x = x % p;     long long sum = 1;     while (y) {       if (y & 1) sum = sum * x;       sum %= p;       y = y >> 1;       x = x * x;       x %= p;     }     return sum;   }   long long inv(long long a, long long m = 1000000007) {     long long c = m;     long long y = 0, x = 1;     if (m == 1) return 0;     while (a > 1) {       long long q = a / m;       long long t = m;       m = a % m, a = t;       t = y;       y = x - q * y;       x = t;     }     if (x < 0) x += c;     return x;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t, n;     cin >> t;     while (t--) {       cin >> n;       long long tmp = 0;       vector<long long> v(n);       for (int i = 0; i < n; i++) {         cin >> v[i];         tmp ^= v[i];       }       if (tmp == 0) {         cout <<  DRAW n ;         continue;       }       for (long long j = 40; j >= 0; j--) {         if ((tmp >> j) & 1) {           long long cnt0 = 0, cnt1 = 0;           for (int i = 0; i < n; i++) {             if ((v[i] >> j) & 1)               cnt1++;             else               cnt0++;           }           if (cnt0 % 2 == 0 && cnt1 % 4 == 3) {             cout <<  LOSE n ;           } else {             cout <<  WIN n ;           }           break;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   struct Node {     int num, cnt;     friend bool operator<(const Node &n1, const Node &n2) {       if (n1.cnt != n2.cnt)         return n1.cnt < n2.cnt;       else         return n1.num < n2.num;     }   };   set<Node> cur, tmp;   vector<int> xx, num;   map<int, int> mp;   int main() {     int n, x;     scanf( %d%d , &n, &x);     if (x == 0 && n == 2) {       puts( NO );       return 0;     }     while (x > 0) {       xx.push_back(x % 2);       x /= 2;     }     int sz = xx.size();     int pre = 0;     cur.insert({0, n});     int idx = 0;     while (true) {       int need;       if (idx < sz) {         need = xx[idx];       } else         need = 0;       tmp.clear();       int tar = need, now = 0;       for (auto o : cur) {         int zc = o.num * 2, cc = o.cnt;         if (cc / 2 > 0) tmp.insert({zc + 1, cc / 2});         if ((cc + 1) / 2 > 0) tmp.insert({zc, (cc + 1) / 2});         now ^= ((cc / 2) % 2);       }       if (tar != now) {         for (auto o : cur) {           int zc = o.num * 2, cc = o.cnt;           if (cc == 1) {             tmp.erase({zc, (cc + 1) / 2});             tmp.insert({zc + 1, cc / 2 + 1});           } else {             tmp.erase({zc, (cc + 1) / 2});             tmp.erase({zc + 1, cc / 2});             if ((cc + 1) / 2 > 1) tmp.insert({zc, (cc + 1) / 2 - 1});             tmp.insert({zc + 1, cc / 2 + 1});           }           break;         }       }       cur.clear();       for (auto o : tmp) {         cur.insert(o);       }       idx++;       int siz = cur.size();       if (siz == n && idx >= sz) break;     }     vector<int> ans;     bool ok = true;     for (auto o : cur) {       int t = o.num, res = 0;       for (int i = 1; i <= idx; i++) {         int now = t % 2;         res = res * 2 + now;         t /= 2;       }       ans.push_back(res);       if (res > 1000000) {         ok = false;         break;       }     }     if (!ok) {       puts( NO );     } else {       int ord = 0;       puts( YES );       for (auto o : ans) {         if (ord != 0) putchar(   );         printf( %d , o);         ord++;       }       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[33], ans;   map<long long, long long> us;   int main() {     cin >> n;     for (long long i = 1; i <= n; ++i) cin >> a[i];     sort(a + 1, a + 1 + n);     for (long long i = 1; i <= n; ++i) {       while (us[a[i]] && a[i] > 0) a[i]--;       ans += a[i];       us[a[i]] = 1;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int digit[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2};     string n;     cin >> n;     int a = digit[(n[1] - 48)];     int b = digit[(n[0] - 48)];     cout << a * b;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> t;   int get(int a) {     if (t[a] == a) {       return a;     } else {       return t[a] = get(t[a]);     }   }   struct kek {     int a;     int b;     int c;   };   bool operator<(kek a, kek b) { return a.c < b.c; }   void uni(int a, int b) {     a = get(a);     b = get(b);     if (a != b) t[a] = b;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= n + 1; i++) t.push_back(i - 1);     m--;     vector<kek> e(m);     int a, b, c;     cin >> a >> b >> c;     for (int i = 0; i < m; i++) cin >> e[i].a >> e[i].b >> e[i].c;     sort(e.begin(), e.end());     int sol = 0;     if (m == 0) {       sol = (int)1e9;     }     for (int i = 0; i < m; i++) {       auto it = e[i];       int x = it.a;       int y = it.b;       int z = it.c;       if (get(a) != get(b)) sol = max(sol, e[i].c);       uni(x, y);       int urm;       if (i + 1 == m)         urm = (int)1e9;       else         urm = max(e[i].c, e[i + 1].c - 1);       if (get(a) != get(b)) sol = max(sol, urm);     }     cout << sol <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   long long pwr(long long a, long long b, long long mod) {     if (b == 0) return 1;     long long temp = pwr(a, b / 2, mod);     temp = (temp * temp) % mod;     if (b & 1) temp = (temp * a) % mod;     return temp;   }   long long pwr(long long a, long long b) {     if (b == 0) return 1;     long long temp = pwr(a, b / 2);     temp = (temp * temp);     if (b & 1) temp = (temp * a);     return temp;   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   long long modularInverse(long long a, long long m) { return pwr(a, m - 2, m); }   bool *isPrime;   void generatePrimeSieve(const int lim) {     isPrime = (bool *)malloc(lim + 1);     memset(isPrime, true, lim + 1);     isPrime[0] = false;     isPrime[1] = false;     for (int i = 2; i <= lim; ++i)       if (isPrime[i])         for (int j = i + i; j <= lim; j += i) isPrime[j] = false;   }   vector<vector<int> > identityMatrix;   vector<vector<int> > mul(const vector<vector<int> > &a,                            const vector<vector<int> > &b) {     int n = a.size();     vector<vector<int> > ans(n, vector<int>(n));     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         for (int k = 0; k < n; ++k) {           ans[i][j] += ((long long)a[i][k] * b[k][j]) % mod;           ans[i][j] %= mod;         }       }     }     return ans;   }   vector<vector<int> > pwr(const vector<vector<int> > &a, long long n) {     if (n == 0) {       assert(false);       return identityMatrix;     }     if (n == 1) return a;     vector<vector<int> > tmp = pwr(a, n / 2);     tmp = mul(tmp, tmp);     if (n & 1) tmp = mul(a, tmp);     return tmp;   }   string str[435];   bool isRemoved[3123];   int main() {     std::ios::sync_with_stdio(false);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; ++i) cin >> str[i];     int ans = 0;     while (true) {       bool encountered = false;       for (int i = 0; i < n - 1; ++i) {         if (str[i] > str[i + 1]) {           encountered = true;           for (int j = 0; j < m; ++j) {             if (str[i][j] > str[i + 1][j]) {               for (int k = 0; k < n; ++k) str[k][j] =  * ;               break;             }           }           break;         }       }       if (!encountered) break;     }     int removed = count(str[0].begin(), str[0].end(),  * );     cout << removed;   }
#include <bits/stdc++.h>   using namespace std;   long long f(int d) {     long long res = 0;     long long dp[100];     memset(dp, 0ll, sizeof(dp));     for (int k = 1; k < d; k++)       if (d % k == 0) {         res += ((1ll << (k - 1)) - dp[k]);         int nk = k * 2;         for (; nk <= d; nk += k) dp[nk] += ((1ll << (k - 1)) - dp[k]);       }     return res;   }   bool periodic(long long N, int d) {     for (int i = 0; i < d; i++)       if ((d + 1) % (i + 1) == 0) {         long long num = 0;         for (int j = 0; j <= d; j++)           if (N & (1ll << (d - j % (i + 1)))) num ^= (1ll << (d - j));         if (num == N) return true;       }     return false;   }   bool differs(long long a, long long b, int bt, int nb) {     for (int i = nb; i > bt; i--)       if ((a & (1ll << i)) != (b & (1ll << i))) return false;     return (a & (1ll << bt)) < (b & (1ll << bt));   }   long long F(long long N) {     if (!N) return 0;     int nd = 0;     for (; (1ll << nd) <= N; nd++)       ;     nd--;     long long ans = periodic(N, nd);     for (int d = 2; d <= nd; d++) ans += f(d);     long long dp[100];     for (int i = nd - 1; i >= 0; i--) {       memset(dp, 0ll, sizeof(dp));       if (N & (1ll << i)) {         memset(dp, 0ll, sizeof(dp));         for (int j = 0; j < (nd - i); j++)           if ((j + 1) < (nd + 1) && (nd + 1) % (j + 1) == 0) {             long long num = 0;             for (int k = 0; k <= nd; k++)               if (N & (1ll << (nd - k % (j + 1)))) num ^= (1ll << (nd - k));             if (num < N && differs(num, N, i, nd)) {               ans++;               for (int k = (j + 1) * 2; k <= (nd + 1); k += (j + 1)) dp[k - 1]++;             }           }         for (int j = (nd - i); j <= nd; j++) {           if ((j + 1) < (nd + 1) && (nd + 1) % (j + 1) == 0) {             ans += (1ll << (j - (nd - i))) - dp[j];             for (int k = (j + 1) * 2; k <= (nd + 1); k += (j + 1))               dp[k - 1] += (1ll << (j - (nd - i))) - dp[j];           }         }       }     }     return ans;   }   int main() {     long long L, R;     cin >> L >> R;     cout << F(R) - F(L - 1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXM = 500005;   const int MAXN = 15;   const int N = 12;   int w[MAXN];   char query[MAXN];   char s[MAXN];   int n, m, q;   int transform(char* s) {     int ans = 0;     for (int i = 0; i < n; i++) {       ans = 2 * ans + (s[i] -  0 );     }     return ans;   }   int cnt_set[(1 << N)];   int dif[(1 << N)][(1 << N)];   int get_dif(int a, int b) {     int ans = 0;     for (int i = 0; i < n; i++) {       if ((a & 1) == (b & 1)) ans += w[i];       a >>= 1;       b >>= 1;     }     return ans;   }   vector<pair<int, int>> cnt_queries[(1 << N)];   int sol[MAXM];   const int MAXK = 101;   int main() {     scanf( %d %d %d , &n, &m, &q);     for (int i = n - 1; i >= 0; i--) scanf( %d , &w[i]);     for (int i = 1; i <= m; i++) {       scanf( %s , s);       int val = transform(s);       cnt_set[val]++;     }     for (int i = 0; i < (1 << n); i++) {       for (int j = 0; j < (1 << n); j++) {         dif[i][j] = get_dif(i, j);       }     }     for (int i = 1; i <= q; i++) {       scanf( %s , query);       int p = transform(query);       int k;       scanf( %d , &k);       cnt_queries[p].push_back({k, i});     }     for (int i = 0; i < (1 << n); i++) {       vector<int> current(MAXK);       for (int i = 0; i < MAXK; i++) current[i] = 0;       for (int j = 0; j < (1 << n); j++) {         if (dif[i][j] < MAXK) {           current[dif[i][j]] += cnt_set[j];         }       }       for (int i = 1; i < MAXK; i++) current[i] += current[i - 1];       for (auto p : cnt_queries[i]) {         sol[p.second] = current[p.first];       }     }     for (int i = 1; i <= q; i++) printf( %d n , sol[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> a(n);       for (int i = 0; i < n; ++i) cin >> a[i];       int m = a[n - 1], ans = 0;       for (int i = n - 1; i >= 0; --i) {         if (a[i] > m) ++ans;         m = min(m, a[i]);       }       cout << ans <<   n ;     }     return 0;   }