malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<long long int> g[200001];   vector<long long int> g1[200001];   vector<long long int> vec;   bool vis[200001];   void fun(long long int u) {     vis[u] = 1;     for (long long int i = 0; i < g[u].size(); i++) {       long long int v = g[u][i];       if (!vis[v]) {         fun(v);       }     }     vec.push_back(u);   }   bool st[200001];   bool foo = 1;   bool check(long long int u) {     if (!foo) return false;     st[u] = 1;     vis[u] = 1;     for (long long int i = 0; i < g[u].size(); i++) {       long long int v = g[u][i];       if (st[v]) {         foo = 0;         return false;       }       if (!vis[v]) check(v);     }     st[u] = 0;     return true;   }   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n, m;       cin >> n >> m;       for (long long int i = 1; i <= n; i++) {         g[i].clear();         g1[i].clear();       }       vec.clear();       memset(vis, false, sizeof(vis));       memset(st, 0, sizeof(st));       for (long long int i = 1; i <= m; i++) {         long long int k, u, v;         cin >> k >> u >> v;         if (k == 1) {           g[u].push_back(v);         } else {           g1[u].push_back(v);           g1[v].push_back(u);         }       }       bool ans = 1;       foo = 1;       for (long long int i = 1; i <= n; i++) {         if (!vis[i]) {           check(i);           if (!foo) {             ans = 0;             break;           }         }       }       if (!ans) {         cout <<  NO n ;         continue;       }       memset(vis, 0, sizeof(vis));       for (long long int i = 1; i <= n; i++) {         if (!vis[i]) fun(i);       }       reverse(vec.begin(), vec.end());       map<pair<long long int, long long int>, bool> done;       for (long long int i = 0; i < vec.size(); i++) {         long long int u = vec[i];         for (long long int j = 0; j < g1[u].size(); j++) {           long long int v = g1[u][j];           long long int u1 = min(u, v), v1 = max(u, v);           if (!done[{u1, v1}]) {             done[{u1, v1}] = 1;             g[u].push_back(v);           }         }       }       cout <<  YES n ;       for (long long int i = 1; i <= n; i++) {         for (long long int j = 0; j < g[i].size(); j++) {           cout << i <<     << g[i][j] <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   int ans[maxn];   vector<int> xs[maxn], ys[maxn];   struct query {     int l, r, d, u, id;     query(int aa, int bb, int cc, int dd, int ee) {       l = aa;       r = bb;       d = cc;       u = dd;       id = ee;     }     query() {}   };   query qry[maxn];   vector<int> xq[maxn], yq[maxn];   struct SegmentTree {     SegmentTree *lc, *rc;     static SegmentTree mem[2000000];     static SegmentTree *ptr;     int pos;     SegmentTree() {}     ~SegmentTree() {}     SegmentTree(int L, int R) {       lc = rc = nullptr;       pos = 0;       if (L == R) return;       lc = new (ptr++) SegmentTree(L, ((L + R) >> 1));       rc = new SegmentTree(((L + R) >> 1) + 1, R);     }     void pull() { pos = min(lc->pos, rc->pos); }     void modify(int L, int R, int x, int v) {       if (L == R) {         pos = v;         return;       }       if (x <= ((L + R) >> 1))         lc->modify(L, ((L + R) >> 1), x, v);       else         rc->modify(((L + R) >> 1) + 1, R, x, v);       pull();     }     int ask(int L, int R, int l, int r) {       if (L > r || l > R) return maxn;       if (L >= l && R <= r) return pos;       return min(lc->ask(L, ((L + R) >> 1), l, r),                  rc->ask(((L + R) >> 1) + 1, R, l, r));     }   } * stx, *sty;   SegmentTree SegmentTree::mem[2000000];   SegmentTree *SegmentTree::ptr = mem;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m, k, q;     cin >> n >> m >> k >> q;     for (int i = 0; i < k; ++i) {       int x, y;       cin >> x >> y;       xs[x].push_back(y);       ys[y].push_back(x);     }     for (int i = 0; i < q; ++i) {       int x1, y1, x2, y2;       cin >> x1 >> y1 >> x2 >> y2;       qry[i] = query(x1, x2, y1, y2, i);       xq[x2].push_back(i);       yq[y2].push_back(i);     }     stx = new (SegmentTree::ptr++) SegmentTree(0, maxn - 1);     sty = new (SegmentTree::ptr++) SegmentTree(0, maxn - 1);     for (int i = 0; i < maxn; ++i)       if (xs[i].size() || xq[i].size()) {         for (int j : xs[i]) stx->modify(0, maxn - 1, j, i);         for (int j : xq[i]) {           if (stx->ask(0, maxn - 1, qry[j].d, qry[j].u) < qry[j].l) ++ans[j];         }       }     for (int i = 0; i < maxn; ++i)       if (ys[i].size() || yq[i].size()) {         for (int j : ys[i]) sty->modify(0, maxn - 1, j, i);         for (int j : yq[i]) {           if (sty->ask(0, maxn - 1, qry[j].l, qry[j].r) < qry[j].d) ++ans[j];         }       }     for (int i = 0; i < q; ++i) {       if (ans[i] == 2)         cout <<  NO  << endl;       else         cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     scanf( %d %d , &n, &k);     if (n == 5 && k == 2) {       puts( YES );       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           if (i & 1)             printf( L );           else             printf( S );         }         puts(  );       }       return 0;     }     vector<string> ans(n,   );     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         int sum = (i + j) & 1;         if (sum == 0 && k > 0) {           ans[i] +=  L ;           k--;         } else {           ans[i] +=  S ;         }       }     }     if (k == 0) {       puts( YES );       for (int i = 0; i < n; i++) puts(ans[i].c_str());     } else {       puts( NO );     }   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int t;     cin >> t;     while (t--) {       long long n, p, k;       cin >> n >> p >> k;       long long ans = 0, pre = 0;       vector<long long> a(n, -1);       for (long long i = 0; i < n; ++i) {         cin >> a[i];       }       sort(a.begin(), a.end());       for (long long i = 0; i <= k; ++i) {         long long sum = pre;         if (sum > p) break;         long long ct = i;         for (long long j = i + k - 1; j < n; j += k) {           if (sum + a[j] <= p) {             ct += k;             sum += a[j];           } else             break;         }         pre += a[i];         ans = max(ans, ct);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   int main() {     fast();     long long i, j, n, t, su = 0, k;     cin >> t;     vector<long long> v[t], s[t];     vector<pair<long long, pair<long long, long long>>> p;     for (i = 0; i < t; i++) {       cin >> n;       su = 0;       for (j = 0; j < n; j++) {         cin >> k;         v[i].push_back(k);         su += k;       }       for (j = 0; j < n; j++) {         p.push_back(make_pair(su - v[i][j], make_pair(i + 1, j + 1)));       }     }     sort(p.begin(), p.end());     for (i = 0; i < p.size() - 1; i++) {       if ((p[i].first == p[i + 1].first) &&           p[i].second.first != p[i + 1].second.first) {         cout <<  YES  << endl;         cout << p[i].second.first <<     << p[i].second.second << endl;         cout << p[i + 1].second.first <<     << p[i + 1].second.second << endl;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned int dp[(int)1e3 + 7], mn[(int)1e3 + 7], n;   int a[(int)1e3 + 7], b[26], ml = 0;   char aa[(int)1e3 + 7];   void dpi() {     dp[0] = 1;     mn[0] = 1;     ml = 1;     for (int i = 1; i < n; i++) {       int mm = a[i];       dp[i] = dp[i - 1];       mn[i] = mn[i - 1] + 1;       for (int j = i - 1; j > 0; j--) {         mm = min(a[j], mm);         if (mm >= i - j + 1) {           dp[i] += dp[j - 1];           dp[i] %= (int)1e9 + 7;           mn[i] = min(mn[j - 1] + 1, mn[i]);           ml = max(ml, i - j + 1);         }       }       mm = min(a[0], mm);       if (mm >= i + 1) {         dp[i]++;         mn[i] = 1;         ml = max(ml, i + 1);       }     }   }   int main() {     scanf( %d , &n);     scanf( %s , aa);     for (int i = 0; i < 26; i++) scanf( %d , &b[i]);     for (int i = 0; i < n; i++) a[i] = b[aa[i] -  a ];     dpi();     printf( %d n%d n%d , dp[n - 1], ml, mn[n - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double l[10], b[10];   vector<int> kk(10, -1);   vector<vector<int> > v;   int k, n;   void abc(int i, int sum) {     if (i == 0 && sum == 0) {       v.push_back(kk);       return;     }     if (i == 0) {       return;     }     for (int j = 0; j <= k; j++) {       if (sum - j < 0) break;       kk[i - 1] = j;       abc(i - 1, sum - j);     }   }   double A;   double ans = 0.0;   void solve(vector<int>& v) {     double sum = 0.0;     for (int i = 0; i < (1 << n); i++) {       double cur = 1.0;       int ed = 0;       double B = 0.0;       for (int j = 0; j < n; j++) {         double z = (l[j] + v[j] * 10) * 0.01;         z = min(z, 1.0);         if (i & (1 << j)) {           cur *= z;           ed++;         } else {           cur *= 1.0 - z;           B += b[j];         }       }       if (ed <= n / 2) cur *= A / (A + B);       sum += cur;     }     ans = max(ans, sum);   }   int main() {     cin >> n >> k >> A;     abc(n, k);     for (int i = 0; i < n; i++) {       cin >> b[i] >> l[i];     }     for (int i = 0; i < v.size(); i++) {       solve(v[i]);     }     printf( %.9f , ans);   }
#include <bits/stdc++.h>   template <class T>   T abs(T x) {     return (x > 0) ? x : (-x);   }   template <class T>   T ceil(T a, T b) {     return a / b + (a % b != 0);   }   int n, t[125][5], cnt[5], l, r, mid;   int a[6] = {1, 2, 4, 8, 16, 32};   std::set<int> s;   int score(int x, int y) {     int s = y / x, i;     for (i = 0; i < 6 && s >= a[i]; ++i)       ;     return 500 * i;   }   bool cal(int m) {     int x = 0, y = 0;     for (int i = 0, j; i < 5; ++i) {       if (t[0][i] >= 0 && t[1][i] < 0)         x += score(cnt[i], n + m) / 250 * (250 - t[0][i]);       else if (t[0][i] >= 0 && t[1][i] >= 0) {         if (t[0][i] < t[1][i])           j = score(cnt[i], n + m);         else           j = score(cnt[i] + m, n + m);         x += j / 250 * (250 - t[0][i]), y += j / 250 * (250 - t[1][i]);       } else if (t[0][i] < 0 && t[1][i] >= 0)         y += score(cnt[i], n + m) / 250 * (250 - t[1][i]);     }     return x > y;   }   int main() {     scanf( %d n , &n);     for (int i = 0; i < n; ++i) {       for (int j = 0; j < 5; ++j) {         scanf( %d , &t[i][j]);         if (t[i][j] >= 0) ++cnt[j];       }     }     s.insert(0);     s.insert(1000000007 + 1);     for (int i = 0; i < 5; ++i)       if (t[0][i] < 0 && t[1][i] >= 0)         for (int j = 0; j < 6; ++j) s.insert(std::max(0, cnt[i] * a[j] - n));     for (std::set<int>::iterator it = s.begin(); it != s.end();) {       for (l = *it, r = *(++it); l < r;) {         mid = (l + r) >> 1;         if (cal(mid))           r = mid;         else           l = mid + 1;       }       if (l < *it) break;     }     if (l <= 1000000007)       printf( %d n , l);     else       printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     long long n, k;     cin >> n >> k;     long long r = max(n - 2 * k, 0LL);     cout << n * (n - 1) / 2 - r * (r - 1) / 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int r, b, y;     cin >> y >> b >> r;     int ans = min(y, b - 1);     ans = min(ans, r - 2);     ans = ans * 3 + 3;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10, mod = 998244353, M = 3e3 + 10;   int ksm(int x, int y) {     int ans = 1;     while (y) {       if (y & 1) ans = (long long)ans * x % mod;       x = (long long)x * x % mod;       y >>= 1;     }     return ans;   }   int a[N], w[N], f[M][M], g[M][M], inv[M << 1], sum[3];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= n; i++) {       scanf( %d , w + i);       sum[a[i]] += w[i];       sum[2] += w[i];     }     for (int i = 0; i <= 2 * m; i++) inv[i] = ksm(sum[2] + i - m, mod - 2);     for (int i = m; i >= 0; i--) {       f[i][m - i] = g[i][m - i] = 1;       for (int j = m - i - 1; j >= 0; j--) {         f[i][j] = (1LL * (sum[1] + i + 1) * f[i + 1][j] +                    1LL * (sum[0] - j) * f[i][j + 1]) %                   mod * inv[i - j + m] % mod;         g[i][j] = (1LL * (sum[1] + i) * g[i + 1][j] +                    1LL * (sum[0] - j - 1) * g[i][j + 1]) %                   mod * inv[i - j + m] % mod;       }     }     for (int i = 1; i <= n; i++) {       if (a[i])         printf( %I64d n , 1LL * w[i] * f[0][0] % mod);       else         printf( %I64d n , 1LL * w[i] * g[0][0] % mod);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string n;     cin >> n;     if (n[0] !=  - ) {       cout << n;     } else {       char max =  0 ;       int mem;       for (int i = n.length() - 2; i < n.length(); ++i) {         if (n[i] >= max) {           max = n[i];           mem = i;         }       }       string merge = n.substr(0, mem) + n.substr(mem + 1, n.length());       int result = atoi(merge.c_str());       cout << result;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long inv[100010], fac[100010], p[100010], t[100010][20];   int n, l, r, P, tot, Phi;   int phi(int k) {     int i, s;     s = k;     for (i = 2; i * i <= k; i++) {       if (k % i == 0) s = s / i * (i - 1);       while (k % i == 0) k /= i;     }     if (k > 1) s = s / k * (k - 1);     return s;   }   long long qpow(long long a, long long b, long long mod) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % mod;       b >>= 1;       a = a * a % mod;     }     return res;   }   void init() {     long long x = P;     Phi = phi(P);     for (int i = 2; (long long)i * i <= x; i++) {       if (x % i) continue;       while (x % i == 0) x /= i;       p[++tot] = i;     }     if (x > 1) p[++tot] = x;     inv[0] = inv[1] = 1;     fac[0] = fac[1] = 1;     for (int i = 2; i < 100010; i++) {       x = i;       for (int j = 1; j <= tot; j++) {         t[i][j] = t[i - 1][j];         if (x % p[j]) continue;         while (x % p[j] == 0) x /= p[j], t[i][j]++;       }       fac[i] = fac[i - 1] * x % P;       inv[i] = qpow(fac[i], Phi - 1, P);     }   }   long long C(int n, int m) {     long long res = 0;     if (n < m || n < 0) return 0;     res = fac[n] * inv[m] % P * inv[n - m] % P;     for (int i = 1; i <= tot; i++)       res = res * qpow(p[i], t[n][i] - t[m][i] - t[n - m][i], P) % P;     return res;   }   int main() {     scanf( %d%d%d%d , &n, &P, &l, &r);     init();     long long ans = 0;     for (int i = 0; i <= n; i++) {       int m = n - i;       ans = (ans + C(n, i) *                        (-C(m, (m + min(r, m) >> 1) + 1) + C(m, m + l + 1 >> 1)) %                        P) %             P;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100100;   int n;   long long a[maxn];   map<long long, long long> mp;   long long mul(long long x, long long n) {     long long ret = 1;     while (n) {       if (n & 1) ret *= x;       x *= x;       n >>= 1;     }     return ret;   }   int main() {     while (~scanf( %d , &n)) {       mp.clear();       for (int i = (1); i < (n + 1); i++) {         cin >> a[i];         mp[a[i]]++;       }       long long ret = 0;       for (int i = (1); i < (n + 1); i++) {         for (int j = 0; j < (31); j++) {           long long cur = mul(2, j);           if (mp.find(cur - a[i]) != mp.end()) {             if (mp[cur - a[i]] == 1 && cur - a[i] == a[i])               continue;             else if (mp[cur - a[i]] > 1 && cur - a[i] == a[i])               ret += mp[cur - a[i]] - 1;             else               ret += mp[cur - a[i]];           }         }       }       cout << ret / 2 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     multiset<long long> heros;     for (int i = 0; i < n; i++) {       long long temp;       cin >> temp;       heros.insert(temp);     }     long long sum = accumulate(heros.begin(), heros.end(), 0LL);     int m;     cin >> m;     for (int i = 0; i < m; i++) {       long long def, atk;       cin >> def >> atk;       long long min_gold = numeric_limits<long long>::max();       auto it = heros.lower_bound(def);       if (it != heros.end()) {         min_gold = min(min_gold, max(0LL, atk - (sum - *it)));       }       if (it != heros.begin()) {         it--;         min_gold = min(min_gold, max(0LL, atk - (sum - *it)) + (def - *it));       }       cout << min_gold <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int base(int a, int b) {     int ret = 0;     vector<int> v;     while (a > 0) {       v.push_back(a % b);       a /= b;     }     for (int i = 0; i < v.size(); i++) {       ret += v[i];     }     return ret;   }   int main() {     long long int a;     cin >> a;     long long int ans = 0;     long long int k = 0;     for (long long int i = 2; i < a; i++) {       ans += base(a, i);     }     k = a - 2;     for (int i = 2; i < k; i++) {       while (ans % i == 0 && k % i == 0) {         ans /= i;         k /= i;       }     }     cout << ans <<  /  << k;   }
#include <bits/stdc++.h>   using namespace std;   long long lmin(long long a, long long b) {     if (a < b) return a;     return b;   }   long long lmax(long long a, long long b) {     if (a > b) return a;     return b;   }   int main() {     long long t1, t2, x1, x2, t0;     scanf(  %lld %lld %lld %lld %lld , &t1, &t2, &x1, &x2, &t0);     long long mint = 100000000000LL, mint2 = 10000000000000000LL;     double min = 10000000000000.000;     if (t2 == t0 && t1 != t0) {       printf( 0 %lld n , x2);       return 0;     } else if (t2 == t0 && t1 == t0) {       printf( %lld %lld n , x1, x2);       return 0;     }     for (long long i = 1; i <= x1; i++) {       double temp = (double)((t0 - t1) * i);       temp /= (double)(t2 - t0);       long long temp2 = (long long)temp;       double t = ((double)t1 * (double)i + (double)t2 * (double)temp2) /                  (double)(i + temp2);       if (temp > x2) continue;       long long temp3 = temp2 * (t2 - t0) - i * (t0 - t1);       if (temp3 >= 0) {         if (t <= min) {           min = t;           mint = temp2;           mint2 = i;         }       } else {         t = ((double)t1 * (double)i + (double)t2 * (double)(temp2 + 1)) /             (double)(i + temp2 + 1);         if (temp2 + 1 > x2) continue;         if (t <= min) {           min = t;           mint = temp2 + 1;           mint2 = i;         }       }     }     long long i = 1;     for (i = 1; mint2 * i <= x1 && mint * i <= x2; i++)       ;     if (mint2 * i > x1 || mint * i > x2) i--;     if (i == 0) {       mint2 = 0;       mint = x2;       i = 1;     }     printf( %lld %lld n , mint2 * i, mint * i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, z;     cin >> x >> y >> z;     if (abs(x - y) > z) {       if (x > y) {         cout <<  + n ;       } else {         cout <<  - n ;       }     } else {       if (abs(x - y) == 0 && z == 0) {         cout <<  0 n ;       } else {         cout <<  ? n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MN = 1e4 + 5;   int N, K, i, x, y, sz[MN], mx[MN], ct, c[MN], dp[MN];   vector<int> adj[MN], elem[2];   vector<pair<int, int> > ans;   int dfs(int n, int p) {     sz[n] = 1;     mx[n] = 0;     for (auto v : adj[n]) {       if (v == p || c[v]) continue;       sz[n] += dfs(v, n);       mx[n] = max(mx[n], sz[v]);     }     return sz[n];   }   void dfs2(int n, int p, int tot) {     if (2 * mx[n] <= tot && 2 * (tot - sz[n]) <= tot) ct = n;     for (auto v : adj[n]) {       if (v == p || c[v]) continue;       dfs2(v, n, tot);     }   }   void op(int n, int p, int r) {     if (r ^ p) ans.push_back({n, r});     for (auto v : adj[n]) {       if (v == p || c[v]) continue;       op(v, n, r);     }   }   void op2(int n, int p, int d) {     elem[d].push_back(n);     for (auto v : adj[n]) {       if (v == p || c[v]) continue;       op2(v, n, d ^ 1);     }   }   void solve(int n) {     dfs2(n, 0, dfs(n, 0));     int cur = ct;     c[cur] = 1;     dfs(cur, 0);     pair<int, int> big(-1, -1);     for (auto v : adj[cur]) {       if (c[v]) continue;       if (sz[v] > big.first) big = {sz[v], v};     }     for (int i = 0; i < 2; i++) elem[i].clear();     for (auto v : adj[cur]) {       if (c[v]) continue;       if (v == big.second)         op2(v, cur, 0);       else         op(v, cur, cur);     }     int idx = 0;     if (elem[1].size() < elem[0].size()) idx = 1;     for (auto v : elem[idx])       if (v != big.second) ans.push_back({cur, v});     for (auto v : adj[cur]) {       if (c[v]) continue;       solve(v);     }   }   int main() {     scanf( %d%d , &N, &K);     for (i = 1; i < N; i++) {       scanf( %d%d , &x, &y);       adj[x].push_back(y);       adj[y].push_back(x);     }     solve(1);     assert(10 * N >= ans.size());     printf( %d n , (int)ans.size());     for (auto v : ans) printf( %d %d n , v.first, v.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long n;     cin >> n;     long long int ans = 0, ans1, k, a1, a2, x, y, m, s = 0;     vector<pair<long, pair<long, long>>> r;     for (int i = 0; i < n; ++i) {       cin >> k;       s += k;       cin >> a1 >> x >> y >> m;       ans1 = 0;       r.push_back(make_pair(0, make_pair(a1, i + 1)));       for (int j = 1; j < k; ++j) {         a2 = ((a1 * x) % m + y % m) % m;         if (a2 < a1) ans1++;         a1 = a2;         if (r.size() <= 200000)           r.push_back(make_pair(ans1, (make_pair(a2, i + 1))));       }       ans = max(ans, ans1);     }     cout << ans <<   n ;     sort(r.begin(), r.end());     if (s <= 200000)       for (int i = 0; i < s; ++i)         cout << r[i].second.first <<     << r[i].second.second <<   n ;     return 0;   }
#include<bits/stdc++.h>      using namespace std;   typedef long long ll;   const int N=2e5+10,mod=1e9+7;   ll a[N];   #define PII pair<int,int>   #define x first   #define y second   #define PB push_back   void solve()   {    int n;       cin>>n;       int sum=0;       map<ll,int> mp;       for(int i=1;i<=n;i++){           cin>>a[i];       }       bool flag=1;       if(n==2){           if(a[1]==a[2]){               cout<< YES <<endl;           }           else cout<< NO <<endl;           return;       }       ll ans=0;       for(int i=1;i<=n;i++){           ans=(ans^a[i]);       }       if(ans==0){           cout<< YES <<endl;return;       }       int cnt=0;       ll ans1=0;          for(int i=1;i<=n;i++){           ans1=(ans1^a[i]);           if(ans1==ans){cnt++;ans1=0;}           if(cnt==2){               cout<< YES <<endl;return;           }           }       cout<< NO <<endl;   }   int main()   {    ios::sync_with_stdio(false);    cin.tie(0);    cout.tie(0);    int t;    cin >> t;    while (t--)     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a;     scanf( %d%d , &n, &m);     if (n == 1)       a = 1;     else if (m == 1)       a = 2;     else if (m == n)       a = n - 1;     else if (m - 1 < n - m)       a = m + 1;     else       a = m - 1;     printf( %d , a);     return 0;   }