malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> v[205];   vector<int> h(205, 0);   void doit(int s, int par) {     if (par != -1) {       h[s] = 1 + h[par];     }     for (int i = 0; i < v[s].size(); i++) {       if (v[s][i] == par) continue;       doit(v[s][i], s);     }   }   string pre(string s) {     string tmp;     for (int i = 0; i < s.length(); i++) {       if (s[i] >=  A  && s[i] <=  Z ) {         tmp.push_back((char)((97 + s[i] -  A )));       } else {         tmp.push_back(s[i]);       }     }     return tmp;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     map<string, int> p;     int k = 0;     vector<string> tmp[n];     for (int i = 0; i < n; i++) {       string s1, s2, s3;       cin >> s1 >> s2 >> s3;       s1 = pre(s1);       s2 = pre(s2);       s3 = pre(s3);       if (p.find(s3) == p.end()) {         p.insert(make_pair(s3, k));         k++;       }       if (p.find(s1) == p.end()) {         p.insert(make_pair(s1, k));         k++;       }       tmp[i].push_back(s1);       tmp[i].push_back(s3);     }     for (int i = 0; i < n; i++) {       string s1 = tmp[i][0];       string s2 = tmp[i][1];       int x = p[s1];       int y = p[s2];       v[x].push_back(y);       v[y].push_back(x);     }     h[0] = 1;     doit(0, -1);     int ans = INT_MIN;     for (int i = 0; i < 205; i++) ans = max(ans, h[i]);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int Begin[N], Next[N], to[N], cost[N], e;   void Add(int u, int v, int w) {     to[++e] = v, Next[e] = Begin[u], Begin[u] = e, cost[e] = w;   }   int n, m;   long long dis[N];   bool vis[N];   struct Vertex {     int o;     long long d;     bool operator<(const Vertex& A) const { return d > A.d; }   };   void Dijkstra() {     priority_queue<Vertex> q;     memset(dis, 0x3f, sizeof dis);     q.push((Vertex){1, 0}), dis[1] = 0;     while (!q.empty()) {       Vertex v = q.top();       q.pop();       int o = v.o;       if (vis[o]) continue;       vis[o] = true;       for (int i = Begin[o]; i; i = Next[i]) {         int u = to[i];         if (dis[u] > dis[o] + cost[i]) {           dis[u] = dis[o] + cost[i];           q.push((Vertex){u, dis[u]});         }       }     }   }   int delt[N];   queue<int> que[N];   void Work(int s) {     for (int i = 1; i <= n; i++) delt[i] = 1e9, vis[i] = false;     que[0].push(1), delt[1] = 0;     for (int i = 0; i <= s; i++)       while (!que[i].empty()) {         int o = que[i].front();         que[i].pop();         if (vis[o]) continue;         vis[o] = true;         for (int j = Begin[o]; j; j = Next[j]) {           int u = to[j];           int new_delt = dis[o] + delt[o] + cost[j] - dis[u];           if (delt[u] > new_delt) {             delt[u] = new_delt;             if (delt[u] <= s) que[delt[u]].push(u);           }         }       }     for (int i = 1; i <= n; i++) dis[i] += delt[i];   };   int q;   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= m; i++) {       int u, v, c;       scanf( %d%d%d , &u, &v, &c);       Add(u, v, c);     }     Dijkstra();     while (q--) {       int ty, s;       scanf( %d%d , &ty, &s);       if (ty == 1)         printf( %I64d n , dis[s] > 1e17 ? -1 : dis[s]);       else {         for (int i = 1; i <= s; i++) {           int u;           scanf( %d , &u);           ++cost[u];         }         Work(min(s, n));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string mat[24];   int n, m;   bool che(int i, int j) {     map<string, bool> mp;     for (int ii = 1; ii <= n; ii += i) {       for (int jj = 1; jj <= m; jj += j) {         string s2 =   ;         for (int k = ii; k < ii + i; k++) {           for (int l = jj; l < jj + j; l++) {             s2 += mat[k - 1][l - 1];           }         }         if (mp[s2]) return false;         mp[s2] = 1;         reverse(s2.begin(), s2.end());         mp[s2] = 1;         string s3 =   ;         if (i == j) {           for (int l = jj; l < jj + j; l++) {             for (int k = ii + i - 1; k >= ii; k--) {               s3 += mat[k - 1][l - 1];             }           }           mp[s3] = 1;           reverse(s3.begin(), s3.end());           mp[s3] = 1;         }       }     }     return true;   }   int main() {     cin >> n >> m;     long long ans = 0, mi = INT_MAX, mx = INT_MAX, my = INT_MAX;     for (int i = 0; i < n; i++) {       cin >> mat[i];     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (n % i == 0 && m % j == 0) {           if (che(i, j)) {             ans++;             if (i * j < mi || (i * j == mi && i < mx)) {               mi = i * j;               mx = i;               my = j;             }           }         }       }     }     cout << ans <<   n ;     cout << mx <<     << my <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     long long int num, num_backup;     long long int a[2], j = 0;     cin >> num;     num_backup = num;     for (long long int i = 2; i * i <= num; i++) {       if (num % i == 0) {         a[j++] = i;         if (j == 2) break;         num /= i;         i--;       }     }     if (j == 0)       cout << 1 << endl << 0 << endl;     else if (a[0] * a[1] == num_backup || j == 1)       cout << 2 << endl;     else       cout << 1 << endl << a[0] * a[1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, n, m;     cin >> a >> b >> n >> m;     if (max((3 * a) / 10, a - (a / 250) * n) >         max((3 * b) / 10, b - (b / 250) * m))       cout <<  Misha ;     if (max((3 * a) / 10, a - (a / 250) * n) <         max((3 * b) / 10, b - (b / 250) * m))       cout <<  Vasya ;     if (max((3 * a) / 10, a - (a / 250) * n) ==         max((3 * b) / 10, b - (b / 250) * m))       cout <<  Tie ;   }
#include <bits/stdc++.h>   using namespace std;   long long res, mx, r1, r2;   int main() {     long long h, w, p, q;     cin >> h >> w;     p = 1;     while (p <= h) {       if (p > h) break;       q = (long long)(p / 4.0 * 5.0);       if (q > w) q = w;       if ((long long)(q / 4.0 * 5.0) < p) break;       if (p * q > mx) {         mx = p * q;         r1 = p;         r2 = q;       }       p *= 2;     }     q = 1;     while (q <= w) {       if (q > w) break;       p = (long long)(q / 4.0 * 5.0);       if (p > h) p = h;       if ((long long)(p / 4.0 * 5.0) < q) break;       if (p * q > mx) {         mx = p * q;         r1 = p;         r2 = q;       }       q *= 2;     }     if (r1 <= w && r2 <= h) {       if (r1 < r2) {         int temp = r1;         r1 = r2;         r2 = temp;       }     }     cout << r1 <<     << r2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Pair {     long long f, s;     Pair() { f = s = 0; }     Pair(long long f, long long s) {       this->f = f;       this->s = s;     }   };   const int maxn = 36 + 100;   Pair d[maxn][maxn];   int pr[maxn][maxn];   long long _10(int);   void print(int, int);   int main() {     int n;     string str;     cin >> n >> str;     for (int i = 0; i <= n; i++)       for (int j = 0; j <= n; j++) {         if (i) {           pr[i][j] = 1;           d[i][j].f = d[i - 1][j].f + _10(n - i) * (str[i + j - 1] -  0 );           d[i][j].s = d[i - 1][j].s;         }         if (j) {           if (d[i][j].f + d[i][j].s < d[i][j - 1].f + d[i][j - 1].s +                                           _10(n - j) * (str[i + j - 1] -  0 )) {             pr[i][j] = 0;             d[i][j].f = d[i][j - 1].f;             d[i][j].s = d[i][j - 1].s + _10(n - j) * (str[i + j - 1] -  0 );           }         }       }     print(n, n);     cout << endl;   }   long long _10(int k) {     long long res = 1;     while (k--) res *= 10;     return res;   }   void print(int i, int j) {     if (!i && !j) return;     if (pr[i][j]) {       print(i - 1, j);       cout <<  H ;       return;     }     print(i, j - 1);     cout <<  M ;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> vec;   int main(void) {     long long n1, n2, i, j, k, n, d;     cin >> n >> d;     for (i = 0; i < n; i++) vec.push_back(i + 1);     long long Min, Max = 0, sum;     do {       sum = 0;       for (i = 0; i < n; i++) {         for (j = i; j < n; j++) {           Min = vec[i];           for (k = i; k <= j; k++) Min = min(vec[k], Min);           sum += Min;         }       }       Max = max(Max, sum);     } while (std::next_permutation(vec.begin(), vec.end()));     long long count = 0;     sort(vec.begin(), vec.end());     do {       sum = 0;       for (i = 0; i < n; i++) {         for (j = i; j < n; j++) {           Min = vec[i];           for (k = i; k <= j; k++) Min = min(vec[k], Min);           sum += Min;         }       }       if (sum == Max) {         count++;         if (count == d) break;       }     } while (std::next_permutation(vec.begin(), vec.end()));     for (i = 0; i < n; i++) cout << vec[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   int n, m;   struct node {     int from, to, w;   } edge[maxn];   int in[maxn];   vector<int> e[maxn];   int top[maxn];   bool topsort(int mid) {     memset(in, 0, sizeof(in));     int cnt = 0;     queue<int> q;     for (int i = 1; i <= n; ++i) e[i].clear();     for (int i = 1; i <= m; ++i) {       if (edge[i].w > mid)         e[edge[i].from].push_back(edge[i].to), in[edge[i].to]++;     }     for (int i = 1; i <= n; ++i) {       if (!in[i]) {         q.push(i);         top[i] = ++cnt;       }     }     while (!q.empty()) {       int u = q.front();       q.pop();       for (auto it : e[u]) {         int v = it;         in[v]--;         if (!in[v]) {           q.push(v);           top[v] = ++cnt;         }       }     }     for (int i = 1; i <= n; ++i) {       if (in[i]) return false;     }     return true;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = 1; i <= m; ++i) {       cin >> edge[i].from >> edge[i].to >> edge[i].w;     }     int l = 0, r = 0x3f3f3f3f;     int ret = 0;     while (l <= r) {       int mid = (l + r) >> 1;       if (topsort(mid)) {         ret = mid;         r = mid - 1;       } else         l = mid + 1;     }     topsort(ret);     vector<int> ans;     for (int i = 1; i <= m; ++i) {       if (edge[i].w <= ret && top[edge[i].from] > top[edge[i].to]) {         ans.push_back(i);       }     }     cout << ret <<     << ans.size() << endl;     for (int i = 0; i < ans.size(); ++i) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3)   #pragma GCC optimize( inline )   using namespace std;   long long n;   double ans;   struct dt {     double x;     double y;   } a[1 << 11];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (register long long i = 1; (i - 1 ^ n); i++) cin >> a[i].x >> a[i].y;     for (register long long i = 1; (i - 1) ^ n; i++) {       ans += a[i].y;     }     ans /= n;     ans += 5;     cout << fixed << setprecision(3) << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int min(int a, int b) {     if (a < b)       return a;     else       return b;   }   int main() {     int n, pos, l, r;     scanf( %d %d %d %d , &n, &pos, &l, &r);     if (l == 1 && r == n)       printf( 0 n );     else if (l == 1)       printf( %d n , abs(pos - r) + 1);     else if (r == n)       printf( %d n , abs(pos - l) + 1);     else       printf( %d n , min(abs(pos - r), abs(pos - l)) + abs(r - l) + 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const char nl =   n ;   const long long inf = 1e9 + 10;   const long long inf2 = 1e18 + 99LL;   const long double inf3 = 1e17;   const long long mod = 1e9 + 7, mod2 = 998244353;   const long double eps = 1e-9;   const bool local = false;   const int logn = 17, maxn = 1000001, maxm = 200001, maxn2 = 3;   int p[maxn], s[maxn];   int find(int v) {     if (p[v] != v) p[v] = find(p[v]);     return p[v];   }   void f(int a, int b) {     a = find(a);     b = find(b);     if (a == b) return;     if (s[a] < s[b]) swap(a, b);     p[b] = a;     s[a] += s[b];   }   vector<int> b[maxn];   int c[maxn];   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ;     int n, q;     cin >> n >> q;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) {       int j = 2;       int ta = a[i];       while (j * j <= ta) {         if (ta % j == 0) {           b[j].push_back(i);           while (ta % j == 0) ta /= j;         }         j++;       }       if (ta > 1) b[ta].push_back(i);     }     for (int i = 0; i < n; i++) {       s[i] = 1;       p[i] = i;     }     for (int i = 0; i < maxn; i++) {       for (int j = 0; j + 1 < (int)((b[i]).size()); j++) {         f(b[i][j], b[i][j + 1]);       }     }     for (int i = 0; i < maxn; i++) {       if ((int)((b[i]).size())) {         c[i] = find(b[i][0]);       } else {         c[i] = -1;       }     }     set<pair<int, int>> st;     for (int i = 0; i < n; i++) {       int j = 2;       int ta = a[i] + 1;       vector<int> d;       while (j * j <= ta) {         if (ta % j == 0) {           d.push_back(j);           while (ta % j == 0) ta /= j;         }         j++;       }       if (ta > 1) d.push_back(ta);       vector<int> e = {find(i)};       for (int x : d) {         if (c[x] == -1) continue;         e.push_back(c[x]);       }       for (j = 0; j < (int)((e).size()); j++) {         for (int k = j + 1; k < (int)((e).size()); k++) {           int x = e[j], y = e[k];           if (x == y) continue;           if (x > y) swap(x, y);           st.emplace(x, y);         }       }     }     while (q--) {       int ts, t;       cin >> ts >> t;       ts--;       t--;       int x = find(ts), y = find(t);       if (x > y) swap(x, y);       if (x == y) {         cout << 0 << nl;       } else if (st.count({x, y})) {         cout << 1 << nl;       } else {         cout << 2 << nl;       }     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1108864220 )   using namespace std;   const int MOD = 1000000007;   const int INF = 1000000000;   const double EPS = 1e-9;   const int HASH_POW = 29;   const long double PI = acos(-1.0);   mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());   long long nextLong(long long l, long long r) {     uniform_int_distribution<long long> foo(l, r);     return foo(rnd);   }   double nextDouble(double l, double r) {     uniform_real_distribution<double> foo(l, r);     return foo(rnd);   }   double workTime() { return double(clock()) / CLOCKS_PER_SEC; }   void myReturn(int code = 0) { exit(code); }   int n, p[100010], depth[100010];   vector<int> G[100010];   vector<int> order, oper;   bool compare(int u, int v) { return depth[u] < depth[v]; }   void dfs(int v) {     depth[v] = 0;     for (auto to : G[v]) {       dfs(to);       depth[v] = max(depth[v], depth[to] + 1);     }     sort(G[v].begin(), G[v].end(), compare);   }   void getOrder(int v) {     order.push_back(v);     for (auto to : G[v]) {       getOrder(to);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       scanf( %d , &p[i]);       G[p[i]].push_back(i);     }     dfs(0);     getOrder(0);     for (int i = 1; i < n; ++i) {       int v = order[i], par = order[i - 1];       while (par != p[v]) {         oper.push_back(v);         par = p[par];       }     }     for (auto i : order) {       printf( %d  , i);     }     printf(  n%d n , oper.size());     for (auto i : oper) {       printf( %d  , i);     }     myReturn();   }
#include <bits/stdc++.h>   using namespace std;   string to_string(string s) { return     + s +    ; }   string to_string(char c) { return      + string(1, c) +     ; }   string to_string(const char *s) { return to_string((string)s); }   string to_string(bool b) { return (b ?  true  :  false ); }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto &x : v) {       if (!first) res +=  ,  ;       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << to_string(H);     debug_out(T...);   }   string to_str(const int &n) {     ostringstream stm;     stm << n;     return stm.str();   }   string to_str(const long long &n) {     ostringstream stm;     stm << n;     return stm.str();   }   template <class T>   string tostring(T x, int len = 0) {     stringstream ss;     ss << x;     string r = ss.str();     if (int((r).size()) < len) r = string(len - int((r).size()),  0 ) + r;     return r;   }   template <class T>   void convert(string x, T &r) {     stringstream ss(x);     ss >> r;   }   long long powmod(long long a, long long b) {     long long res = 1;     a %= 1000000007;     for (; b; b >>= 1) {       if (b & 1) res = res * a % 1000000007;       a = a * a % 1000000007;     }     return res;   }   long long modinv(long long a) { return powmod(a, 1000000007 - 2); }   long long modinv(long long a, long long m) { return powmod(a, m - 2); }   long long nCkMp(long long n, long long k) {     long long numerator = 1, denominator = 1;     for (int i = 0; i < k; i++) numerator = (numerator * (n - i)) % 1000000007;     for (int i = 1; i <= k; i++) denominator = (denominator * i) % 1000000007;     return (numerator * modinv(denominator)) % 1000000007;   }   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 * (b / gcd(a, b)); }   int TT = 1, tt;   clock_t t1;   void solve() {     t1 = clock();     int n, m, c, q, res = 0;     vector<int> x(105), y;     (cin >> (n));     (cin >> (m));     for (auto i = (0); i < (m); i++) {       (cin >> (q));       x[q]++;     }     for (auto i = (105 - 1); i >= (1); i--) {       c = 0;       for (auto j = (0); j < (105); j++) c += x[j] / i;       if (c >= n) {         res = i;         break;       }     }     (cout << (res) << endl);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     for (tt = 0; tt < TT; tt++) solve();     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   using namespace chrono;   template <class T>   void show(vector<vector<T>> &a) {     for (auto &i : a) {       for (T &j : i) cout << j <<    ;       cout << endl;     }   }   template <class T>   void show(vector<T> &a) {     for (T i : a) cout << i <<    ;     cout << endl;   }   template <class T>   void show(vector<pair<T, T>> &a) {     for (auto &i : a) {       cout << i.first <<     << i.second << endl;     }   }   template <class T>   void show(pair<T, T> p) {     cout << p.first <<     << p.second << endl;   }   void show(vector<string> &a) {     for (auto &i : a) cout << i << endl;   }   template <class T>   void take(vector<T> &a) {     for (auto &i : a) cin >> i;   }   long long digits(long long n) {     long long k = 0;     while (n) k++, n /= 10;     return k;   }   bool isprime(long long n) {     long long i;     if (n == 1) return 0;     if (n == 2) return 1;     if (n % 2 == 0) return 0;     for (i = 3; i * i <= n; i += 2) {       if (n % i == 0) return 0;     }     return 1;   }   long long power(long long x, long long y, long long MOD) {     long long ans = 1;     x %= MOD;     while (y > 0) {       if (y % 2 == 1) ans = (ans * x) % MOD;       y /= 2;       x = (x * x) % MOD;     }     return ans;   }   void sieve(vector<bool> &a, long long n) {     long long i, j;     a[1] = 0;     a[0] = 0;     long long h = sqrt(n + 1);     for (i = 2; i < h; i++) {       if (!a[i]) continue;       for (j = 2 * i; j < n + 1; j += i) a[j] = 0;     }   }   void load(unordered_map<long long, long long> &g) { g.max_load_factor(0.25); }   vector<long long> bits(long long n) {     vector<long long> a;     long long i;     for (i = 0; i < 33; i++) {       a.push_back(n % 2);       n /= 2;     }     reverse(a.begin(), a.end());     return a;   }   void sub() {}   const long long N = 1e9 + 7;   const long long M = 998244353;   void solve() {     long long i, j, n, m;     cin >> n;     vector<long long> a(n);     take(a);     long long ans = 0;     for (i = 0; i < n; i++)       if (a[i] == 1) ans++;     ans = (power(2, ans, M) - 1 + M) % M;     vector<long long> b(n + 3), c(n + 3);     for (i = 0; i < n; i++) {       if (a[i] == 0) b[0] = (2 * b[0] + 1) % M;       if (a[i] == 1) b[1] = (2 * b[1] + b[0]) % M;       if (a[i] > 1) b[a[i]] = (2 * b[a[i]] + b[a[i] - 1]) % M;       if (a[i] > 1) c[a[i] - 1] = (2 * c[a[i] - 1] + b[a[i] - 2]) % M;       c[a[i] + 1] = (2 * c[a[i] + 1]) % M;     }     for (i = 0; i < n + 1; i++) {       ans = (ans + b[i] + c[i]) % M;     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     sub();     auto start1 = high_resolution_clock::now();     long long t = 1, s;     cin >> t;     for (s = 1; s < t + 1; s++) {       solve();     }     auto stop1 = high_resolution_clock::now();     auto duration = duration_cast<microseconds>(stop1 - start1);     cerr <<  Time:   << (double)duration.count() / 1000 <<   ms  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> a[10], b[10];   int main() {     for (int i = 1; i <= 3; i++) scanf( %d %d , &a[i].first, &a[i].second);     for (int i = 0; i < 8; i++) {       for (int j = 1; j <= 3; j++) b[j] = a[j];       for (int j = 1; j <= 3; j++)         if (i >> (j - 1) & 1) swap(b[j].first, b[j].second);       if (b[1].first >= b[2].first + b[3].first &&           b[1].second >= max(b[2].second, b[3].second))         puts( YES ), exit(0);       if (b[1].second >= b[2].second + b[3].second &&           b[1].first >= max(b[2].first, b[3].first))         puts( YES ), exit(0);     }     puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   const int maxn = 505, maxm = 1005;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long powermod(long long a, long long b, long long c) {     a = a % c;     long long ans = 1;     while (b) {       if (b % 2) ans = (ans * a) % c;       b = b / 2;       a = (a * a) % c;     }     return ans;   }   long long a[100005];   long long sum[100005];   int main() {     {       long long n, m, i, j, k;       scanf( %lld , &n);       long long cnt = 0, cnt1 = 0;       for (i = 1; i <= n; i++) {         scanf( %lld , &a[i]);         sum[a[i]]++;         if (sum[a[i]] % 2 == 0) cnt++;         if (sum[a[i]] % 4 == 0) cnt1++;       }       long long q, x;       char s[10];       scanf( %lld , &q);       while (q--) {         scanf( %s%lld , s, &x);         if (s[0] ==  + ) {           sum[x]++;           if (sum[x] % 2 == 0) cnt++;           if (sum[x] % 4 == 0) cnt1++;           if (cnt >= 4 && cnt1 >= 1)             printf( YES n );           else             printf( NO n );         } else {           sum[x]--;           if (sum[x] % 2 == 1) cnt--;           if (sum[x] % 4 == 3) cnt1--;           if (cnt >= 4 && cnt1 >= 1)             printf( YES n );           else             printf( NO n );         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       bool sym = false;       for (int i = 0; i < n; i++) {         int a, b, c, d;         cin >> a >> b >> c >> d;         if (b == c) sym = true;       }       cout << (!(m & 1) && sym ?  YES  :  NO ) <<   n ;     }   }