malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   template <typename T>   bool ckmax(T& a, const T& b) {     return b > a ? a = b, 1 : 0;   }   template <typename T>   bool ckmin(T& a, const T& b) {     return b < a ? a = b, 1 : 0;   }   const int MV = 1e5 + 10;   const int MM = 1e5 + 10;   const int MG = 450;   const int INF = 0x3f3f3f3f;   struct DSU {     int p[MM], t[MM];     char r[MM];     void init(int M) {       memset(p, -1, M * sizeof *p);       memset(r, 0, M * sizeof *r);       std::iota(t, t + M, 0);     }     int find(int v) { return ~p[v] ? p[v] = find(p[v]) : v; }     bool merge(int a, int b) {       a = find(a), b = find(b);       if (a == b) return 0;       t[a] = t[b];       if (r[a] < r[b]) std::swap(a, b);       r[a] += r[a] == r[b];       p[a] = b;     }   } dsu;   int M, v[MM], maxv[MM], dp[MM][2], ub[MV];   bool ok[MM];   int solve() {     scanf( %d , &M);     for (int i = 0; i < M; ++i) {       scanf( %d , v + i);       assert(v[i] > 0);     }     for (int i = 0, j = 0; i < MV; ++i) {       while (j < M && v[j] == i) ++j;       ub[i] = j;     }     memset(maxv, 0x3f, sizeof maxv);     std::fill(ok, ok + M, 1);     int f = 0;     bool c = 0;     for (int i = 0; f == i; ++i, c ^= 1) {       dsu.init(M + 1);       for (int j = M - 1; j >= 0; --j) {         if (ok[j] &= (maxv[j] > 0)) ckmax(f, i + 1);         dp[j][c] = v[j] * 2 - maxv[j];         ckmax(dp[j][c], 0);         ckmin(dp[j][c], v[j] - 1);         if (i) {           ckmax(dp[j][c], dp[j][!c]);           int x = ub[dp[j][!c]], y = ub[dp[j][c]];           for (int g = dsu.find(x), t; (t = dsu.t[g]) < y;) {             maxv[t] = v[j];             dsu.merge(g, t + 1);             g = dsu.find(g);           }         }       }       memset(maxv, 0, sizeof maxv);     }     return f;   }   int main() {     int N, f = 0;     scanf( %d , &N);     for (int i = 0; i < N; ++i) f ^= solve();     if (f)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 2e5 + 10;   long long int x[mx], y[mx];   int ord[mx];   int hs[mx], h = 0;   vector<int> g[mx];   int ans[mx];   int cross(int a, int o, int b) {     long long int l = (x[o] - x[a]) * (y[o] - y[b]) * y[a] * x[b];     long long int r = (y[o] - y[a]) * (x[o] - x[b]) * x[a] * y[b];     if (l == r) return 0;     if (l < r) return -1;     return 1;   }   bool cmp1(int i, int j) {     if (x[i] != x[j]) return x[i] < x[j];     if (y[i] != y[j]) return y[i] < y[j];     return i < j;   }   bool cmp(int i, int j) {     int c = cross(i, ord[0], j);     if (c == 0) {       if (x[j] != x[i]) return x[j] < x[i];       return i < j;     }     return c > 0;   }   inline bool ccw(int a, int o, int b) { return (-cross(a, o, b)) >= 0; }   int main() {     int n, xi, yi;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d %d , &xi, &yi);       x[i] = xi, y[i] = yi, ord[i] = i;     }     sort(ord, ord + n, cmp1);     int c = 0;     int il = 0, id = 0;     for (int i = 0; i < n;) {       int ii = ord[i];       int xi = x[ii], yi = y[ii];       while (i < n && x[ord[i]] == xi && y[ord[i]] == yi) {         g[ii].push_back(ord[i]);         i++;       }       int j = ord[il];       if (xi > x[j] || (xi == x[j] && yi > y[j])) il = c;       j = ord[id];       if (yi > y[j] || (yi == y[j] && xi > x[j])) id = c;       ord[c++] = ii;     }     int dwn = ord[id];     swap(ord[0], ord[il]);     sort(ord + 1, ord + c, cmp);     for (int i = 0; i < c; i++) {       while (h >= 2 && !ccw(hs[h - 2], hs[h - 1], ord[i])) h--;       hs[h++] = ord[i];       if (ord[i] == dwn) break;     }     c = 0;     for (int i = 0; i < h; i++) {       int u = hs[i];       for (int j = 0; j < int(g[u].size()); j++) {         ans[c++] = 1 + g[u][j];       }     }     sort(ans, ans + c);     printf( %d , ans[0]);     for (int i = 1; i < c; i++) printf(  %d , ans[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int mod = 1e9 + 7;     string S;     cin >> S;     bool flag = false;     long ans = 0;     long plus = 0;     for (int i = 0; i < S.size(); i++) {       if (S[i] ==  a ) {         if (flag) {           ans = (2 * ans + 1) % mod;         } else {           ans = ans + 1 + plus;           ans = ans % mod;         }         flag = false;       } else if (S[i] ==  b ) {         plus = ans;         flag = true;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int temp;     int a[6] = {0};     int i = 0;     while (n > 0) {       a[i] = n % 2;       n = n / 2;       i++;     }     temp = a[0];     a[0] = a[4];     a[4] = temp;     temp = a[2];     a[2] = a[3];     a[3] = temp;     int count = 1;     int sum = 0;     for (int i = 0; i < 6; i++) {       sum = sum + a[i] * count;       count = count * 2;     }     cout << sum;   }
#include <bits/stdc++.h>   using namespace std;   const int OO = 1e9;   const double EPS = 1e-9;   template <class T>   void _db(const char* dbStr, T e) {     cout << dbStr <<   =   << e << endl;   }   template <class T, class... L>   void _db(const char* dbStr, T e, L... r) {     while (*dbStr !=  , ) cout << *dbStr++;     cout <<   =   << e <<  , ;     _db(dbStr + 1, r...);   }   template <class S, class T>   ostream& operator<<(ostream& o, const map<S, T>& v) {     o <<  [ ;     int i = 0;     for (const pair<S, T>& pr : v)       o << (!i++ ?    :  ,  ) <<  {  << pr.first <<   :   << pr.second <<  } ;     return o <<  ] ;   }   template <template <class, class...> class S, class T, class... L>   ostream& operator<<(ostream& o, const S<T, L...>& v) {     o <<  [ ;     int i = 0;     for (const auto& e : v) o << (!i++ ?    :  ,  ) << e;     return o <<  ] ;   }   template <class S, class T>   ostream& operator<<(ostream& o, const pair<S, T>& pr) {     return o <<  (  << pr.first <<  ,   << pr.second <<  ) ;   }   ostream& operator<<(ostream& o, const string& s) {     for (const char& c : s) o << c;     return o;   }   template <class T>   using V = vector<T>;   template <class T>   using VV = V<V<T>>;   template <class T>   using VVV = VV<V<T>>;   using ll = long long;   using pii = pair<int, int>;   using vi = V<int>;   using vii = V<pii>;   using vvi = VV<int>;   using mii = map<int, int>;   using umii = unordered_map<int, int>;   using si = set<int>;   using usi = unordered_set<int>;   vii monoStFunc(vi a) {     int n = int(a.size());     vii b(n);     stack<pii> st;     st.push(make_pair(INT_MAX, -1));     for (int i = 0; i < n; ++i) {       while (st.top().first < a[i]) st.pop();       b[i].first = st.top().second;       st.push(make_pair(a[i], i));     }     while (!st.empty()) st.pop();     st.push(make_pair(INT_MAX, n));     for (int i = n - 1; i >= 0; --i) {       while (st.top().first <= a[i]) st.pop();       b[i].second = st.top().second;       st.push(make_pair(a[i], i));     }     return b;   }   int n, q;   vi a, d;   int main() {     ios::sync_with_stdio(false);     cout.precision(10);     cin.tie(0);     cin >> n >> q;     a.assign(n, 0);     for (int i = 0; i < n; ++i) cin >> a[i];     d.assign(n - 1, 0);     for (int i = 0; i < n - 1; ++i) d[i] = abs(a[i + 1] - a[i]);     true;     for (int qq = 0; qq < q; ++qq) {       int l, r;       cin >> l >> r;       --l, --r;       vi v;       for (int i = l; i < r; ++i) v.push_back(d[i]);       vii LR = monoStFunc(v);       ll ans = 0;       for (int i = 0; i < int(v.size()); ++i)         ans += v[i] * 1LL * ((i - LR[i].first) * 1LL * (LR[i].second - i));       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gi() {     char cc = getchar();     int cn = 0, flus = 1;     while (cc <  0  || cc >  9 ) {       if (cc ==  - ) flus = -flus;       cc = getchar();     }     while (cc >=  0  && cc <=  9 ) cn = cn * 10 + cc -  0 , cc = getchar();     return cn * flus;   }   const int N = 3e5 + 5;   int n, q, a[N], g[20], f[N][20];   signed main() {     n = gi(), q = gi();     for (register int i = (1); i <= (n); ++i) a[i] = gi();     for (register int i = (0); i <= (19); ++i) g[i] = n + 1;     memset(f, 63, sizeof(f));     for (register int i = n; i >= 1; --i) {       for (register int j = (0); j <= (19); ++j)         if ((1 << j) & a[i]) f[i][j] = i;       for (register int j = (0); j <= (19); ++j)         if ((1 << j) & a[i])           for (register int k = (0); k <= (19); ++k)             f[i][k] = min(f[i][k], f[g[j]][k]);       for (register int j = (0); j <= (19); ++j)         if ((1 << j) & a[i]) g[j] = i;     }     while (q--) {       int x = gi(), y = gi();       int flag = 0;       for (register int j = (0); j <= (19); ++j)         if ((1 << j) & a[y]) flag |= (f[x][j] <= y);       (flag) ? puts( Shi ) : puts( Fou );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2147483647;   const long long LLINF = 9223372036854775807;   int main() {     int n;     cin >> n;     long long mod = 1000000009;     if (n == 2) cout << 10, exit(0);     long long b = 5, g = 1, r = 6;     long long fb = 2, fg = 2, t = 4;     for (int i = 0; i < n / 2 - 2; ++i) {       b = r + 3 * g * (t + 1);       g = (g * (1 + t)) % mod;       r = (b + g) % mod;       fb = (t + fg * 2) % mod;       fg = (fg * 2) % mod;       t = (fg + fb) % mod;     }     long long ans = ((r * r + 1) * 2) % mod;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = int(500 * 1000 + 7);   long long n, k;   vector<pair<long long, long long> > adj[N];   long long dp[N][2];   void dfs(int v, int p = -1) {     vector<long long> x;     long long curr = 0;     for (auto it : adj[v]) {       long long to = it.first;       long long w = it.second;       if (to == p) continue;       dfs(to, v);       curr += dp[to][0];       x.push_back(dp[to][1] + w - dp[to][0]);     }     sort(x.begin(), x.end(), greater<long long>());     for (long long i = 0; i < min((long long)x.size(), k); i++) {       if (x[i] > 0) curr += x[i];     }     dp[v][0] = dp[v][1] = curr;     if (k <= (long long)x.size() && x[k - 1] > 0) dp[v][1] -= x[k - 1];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long q;     cin >> q;     while (q--) {       cin >> n >> k;       for (long long i = 0; i < n; i++) adj[i].clear();       for (long long i = 0; i < n - 1; i++) {         long long u, v, w;         cin >> u >> v >> w;         u--;         v--;         adj[u].push_back({v, w});         adj[v].push_back({u, w});       }       dfs(0, -1);       cout << dp[0][0] << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int MAX_N = (int)1e5 + 123;   const double eps = 1e-6;   const int inf = (int)1e9 + 123;   using namespace std;   int n, k;   int mini = inf;   string second;   int sum[MAX_N];   int main() {     cin >> n >> k >> second;     for (int i = 0; i < int((second).size()); i++)       sum[i] = (i > 0 ? sum[i - 1] : 0) + (second[i] ==  0 );     vector<int> q;     for (int i = 0; i < int((second).size()); i++)       if (second[i] ==  0 ) q.push_back(i);     for (int i = 0; i < int((second).size()); i++) {       if (sum[int((second).size()) - 1] - (i > 0 ? sum[i - 1] : 0) < k + 1) break;       int l = i, r = int((second).size()) - 1, mid = -1, ans = -1;       while (l <= r) {         mid = (l + r) / 2;         if (sum[mid] - (i > 0 ? sum[i - 1] : 0) >= k + 1) {           ans = mid;           r = mid - 1;         } else           l = mid + 1;       }       assert(ans != -1);       int now = ans - i;       if ((ans - i + 1) % 2 == 1) {         int mid = (ans + i) / 2;         auto it = lower_bound(q.begin(), q.end(), mid);         if (it != q.end()) now = min(now, max(*it - i, ans - *it));         if (it != q.begin()) {           it--;           now = min(now, max(*it - i, ans - *it));         }       } else {         int mid = (ans + i) / 2 + 1;         auto it = lower_bound(q.begin(), q.end(), mid);         if (it != q.end()) now = min(now, max(*it - i, ans - *it));         mid--;         it = lower_bound(q.begin(), q.end(), mid);         if (it != q.end()) now = min(now, max(*it - i, ans - *it));         if (it != q.begin()) {           it--;           now = min(now, max(*it - i, ans - *it));         }       }       mini = min(mini, now);     }     cout << mini;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n, m, sum = 0;       cin >> n >> m;       long long int a[5] = {0};       if (n == 1)         cout <<  0  << endl;       else if (n == 2)         cout << m << endl;       else         cout << (2 * m) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   int n;   vector<int> adj[N];   vector<pair<int, int> > r;   int color[N];   bool vis[N];   void solve(int x) {     vis[x] = true;     for (auto w : adj[x]) {       if (!vis[w]) {         color[w] = (color[x]) ^ 1;         solve(w);       }     }   }   int32_t main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       x--, y--;       adj[x].push_back(y);       adj[y].push_back(x);       int k = 2 * i;       int kk = 2 * i + 1;       k %= 2 * n;       kk %= 2 * n;       adj[k].push_back(kk);       adj[kk].push_back(k);       r.push_back(pair<int, int>(x, y));     }     for (int i = 0; i < 2 * n; i++) {       if (!vis[i]) {         solve(i);       }     }     for (auto w : r) {       cout << color[w.first] + 1 <<     << color[w.second] + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long mod;   long long lgput(long long a, long long b) {     if (b == 0) return 1;     if (b == 1) return a % mod;     long long c = lgput(a, b / 2);     c = c * c % mod;     if (b & 1) c = c * a % mod;     return c;   }   map<long long, int> hh;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, k;     cin >> n >> mod >> k;     int i, j, z;     for (i = 0; i < n; i++) {       cin >> z;       hh[(lgput(z, 4) - 1LL * k * z % mod + mod) % mod]++;     }     long long ans = 0;     for (pair<int, int> cur : hh) ans += 1LL * cur.second * (cur.second - 1) / 2;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   const int N = 1e5 + 5;   const long double pi = 3.141592653;   const long long MOD = 1e9 + 7;   const long long mod = 998244353;   const long long INF = 9223372036854775807LL;   using namespace std;   int dx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0};   int dy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T = 1;     while (T--) {       string s;       long long i, j, ans = 1, n;       cin >> s;       n = (long long)s.size();       bool ok = true;       for (i = 0; i < n; i++) {         if (s[i] ==  w  || s[i] ==  m ) ok = false;       }       if (!ok)         ans = 0;       else {         long long dp[N];         dp[0] = 0;         dp[1] = 1;         dp[2] = 2;         for (i = 3; i < N; i++) dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;         for (i = 0; i < n; i++) {           if (s[i] ==  u  || s[i] ==  n ) {             j = i;             while (j < n && s[j] == s[i]) j++;             ans = (ans * dp[j - i]) % MOD;             i = j - 1;           }         }       }       cout << ans;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 200005;   map<int, int> Map;   struct Node {     int au, sub;   } node[MAX];   int n, temp, m;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       scanf( %d , &temp);       Map[temp]++;     }     int m;     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       scanf( %d , &node[i].au);     }     int Max1, Max2;     Max1 = Max2 = 0;     int id = 1;     for (int i = 1; i <= m; i++) {       scanf( %d , &node[i].sub);       if (Map[node[i].au] > Max1 ||           (Map[node[i].au] == Max1 && Map[node[i].sub] > Max2)) {         Max1 = Map[node[i].au];         Max2 = Map[node[i].sub];         id = i;       }     }     cout << id << endl;     return 0;   }
#include <bits/stdc++.h>   long long get2(long long, long long);   long long get1(long long n, long long x) {     if (x & 1)       return (x + 1) / 2;     else if (n & 1)       return get2(n / 2, x / 2) + (n + 1) / 2;     else       return get1(n / 2, x / 2) + n / 2;   }   long long get2(long long n, long long x) { return get1(n, x == 1 ? n : x - 1); }   int main() {     long long n;     int q;     std::cin >> n >> q;     while (q--) {       long long x;       std::cin >> x;       std::cout << get1(n, x) << std::endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   string s[N];   int n, k, fa[N], len[N], ch[N][26], root = 1, last = 1, tot = 1, times[N];   void insert(int x) {     int now = ++tot, pre = last;     last = now, len[now] = len[pre] + 1;     for (; pre && !ch[pre][x]; pre = fa[pre]) ch[pre][x] = now;     if (!pre)       fa[now] = root;     else {       int q = ch[pre][x];       if (len[q] == len[pre] + 1)         fa[now] = q;       else {         int nows = ++tot;         len[nows] = len[pre] + 1;         memcpy(ch[nows], ch[q], sizeof(ch[q]));         fa[nows] = fa[q], fa[q] = fa[now] = nows;         for (; pre && ch[pre][x] == q; pre = fa[pre]) ch[pre][x] = nows;       }     }   }   long long vis[N], sum[N];   void getcnt() {     for (int i = 1; i <= n; i++) {       int now = root;       for (int j = 0; j < s[i].length(); j++) {         now = ch[now][s[i][j] -  a ];         int t = now;         while (t && vis[t] != i) vis[t] = i, times[t]++, t = fa[t];       }     }   }   void dfs(int x) {     if (x == root || vis[x]) return;     vis[x] = 1;     dfs(fa[x]);     sum[x] += sum[fa[x]];   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> s[i];     for (int i = 1; i <= n; i++) {       last = 1;       for (int j = 0; j < s[i].length(); j++) insert(s[i][j] -  a );     }     getcnt();     for (int i = 1; i <= tot; i++)       sum[i] = (times[i] >= k) * (len[i] - len[fa[i]]);     memset(vis, 0, sizeof(vis));     for (int i = 1; i <= tot; i++) dfs(i);     for (int i = 1; i <= n; i++) {       long long ans = 0, now = root;       for (int j = 0; j < s[i].length(); j++)         now = ch[now][s[i][j] -  a ], ans += sum[now];       printf( %lld  , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     int sum;     int a[1000];     cin >> n;     sum = n;     for (i = 1; i <= n; i++) cin >> a[i];     sort(a + 1, a + 1 + n);     for (i = 1; i <= n; i++) {       if (a[i] != 0) {         for (int j = i + 1; j <= n; j++)           if (a[j] % a[i] == 0 && a[j] != 0) {             a[j] = 0;             sum--;           }       }     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   const int MX = 123456;   const int mod = (int)1e9 + 7;   const int base = 1023456789;   const unsigned long long BS1 = 10000019ULL;   const int INF = (1 << 29);   template <class T>   inline void fastScan(T &x) {     register char c = getchar();     int neg = 0;     x = 0;     for (; (c < 48 || c > 57) && (c !=  - ); c = getchar())       ;     if (c ==  - ) {       neg = 1;       c = getchar();     }     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }     if (neg) x = -x;   }   int n, m, q;   int W[15];   int kunt[(1 << 12) + 10];   char str[15];   long long dp[(1 << 12) + 5][105];   bool Check(int nn, int pos) { return (bool)(nn & (1 << pos)); }   int P(int a, int b) {     int x = 0;     for (int i = 0; i < n; i++) {       if (Check(a, i) == Check(b, i)) {         x += W[i];       }     }     return x;   }   int main() {     fastScan(n);     fastScan(m);     fastScan(q);     for (int i = 0; i < n; i++) {       fastScan(W[i]);     }     for (int i = 0; i < m; i++) {       scanf( %s , str);       int x = 0;       for (int j = 0; str[j]; j++) {         if (str[j] ==  1 ) {           x += (1 << j);         }       }       kunt[x]++;     }     for (int i = 0; i <= (1 << 12); i++) {       int x = 0;       for (int j = 0; j <= (1 << 12); j++) {         if (kunt[j] >= 0) {           x = P(i, j);           if (x <= 100) dp[i][x] += kunt[j];         }       }     }     for (int i = 0; i <= (1 << 12); i++) {       for (int k = 1; k <= 101; k++) dp[i][k] += dp[i][k - 1];     }     for (int i = 0; i < q; i++) {       int x = 0, k = 0;       scanf( %s %d , str, &k);       for (int j = 0; j < n; j++) {         if (str[j] ==  1 ) x += (1 << j);       }       printf( %d n , dp[x][k]);     }   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007, ans = 1, n, ert, dp[1000002];   int main() {     ios_base::sync_with_stdio(false);     cin >> n, ert = n;     dp[0] = 1, dp[1] = 1;     for (int i = 2; i <= n; i++) {       dp[i] = ((i - 1) * dp[i - 2] + dp[i - 1]) % mod;     }     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       if (x == 2) ans *= ert, ans %= mod, ert--;     }     cout << ans * dp[ert] % mod <<   n ;     return 0;   }
#include <bits/stdc++.h>   #define arr(i,n) for(ll i=0;i<n;i++)   #define ARR(i,n) for(ll i=n-1;i>=0;i--)   #define f(i,a,b)  for(ll i=a;i<b;i++)   #define F(i,a,b)  for(ll i=b-1;i>=a;i--)   #define float double   #define PI 3.14159265358979323846   #define pb push_back   #define mp make_pair   #define vi vector<ll>   #define ceil(a) (ll) ceil(a)   #define floor(a) (ll) floor(a)   #define pow(a,b) (ll) pow(a,b)   #define fixed(x) cout<<fixed<<setprecision(6)<<x;   #define vpii vector< pair<ll,ll> >   #define debug(x) cout<<(#x)<<  is  <<(x)<<endl   #define dbg(x,y)  cout<<#x<< =  <<x<<   and   <<#y<< = <<y<<endl   #define gcd(a,b) __gcd(a,b)   #define lcm(a,b) (a*(b/gcd(a,b)))   #define all(v) v.begin(),v.end()   #define array(a,n) arr(i,n) cout<<a[i]<<   ;   #define array2D(a,n,m) arr(i,n) {arr(j,m) cout<<a[i][j]<<   ; cout<<endl;}   #define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)   typedef long long ll;   using namespace std;   const ll  mod = 1000000000 + 7;   void solve()   {       //code start here       ll n;       cin>>n;       n=2*n;       ll a[n];       arr(i,n) cin>>a[i];       sort(a,a+n);       ll start=0,end=n-1;       arr(i,n)       {           if(i%2==0) {cout<<a[start]; start++;}           else {cout<<a[end]; end--; }           cout<<   ;       }       cout<<endl;   }   int main()   {       IOS;       int t; cin>>t;       while(t--)  solve();       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     cin >> t;     while (t--) {       long long int n, i, j, x, y, a[100005], v[100005];       map<long long int, long long int> ma;       cin >> n;       for (i = 1; i <= n; i++) {         cin >> a[i];         ma[a[i]] = i;         v[i] = 0;       }       long long int fl = 0, p = -1;       for (i = 1; i <= n; i++) {         if (!v[ma[i]]) {           for (j = ma[i]; j <= n; j++) {             if (v[j] == 1 || j == n + 1) {               break;             }             if (a[j] != j - ma[i] + i) {               fl = 1;               break;             }             v[j] = 1;           }         }       }       if (fl) {         cout <<  No n ;       } else {         cout <<  Yes n ;       }     }     return 0;   }
#include<iostream>   #include<string>   using namespace std;   int  main()   {    int t;    cin>>t;    for(int i=0;i<t;i++)    {     int n;     string r,b;     cin>>n;     cin>>r>>b;     int counter1=0,counter2=0;     for(int i=0;i<n;i++)     {      if(r[i]>b[i])       counter1++;      else if(r[i]<b[i])       counter2++;     }     if(counter1>counter2)      cout<< RED <<endl;     else if(counter1==counter2)      cout<< EQUAL <<endl;     else       cout<< BLUE <<endl;    }    return 0;   }