malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct edge {     int to, next;   } e[400005];   int n, k, num, head[200005], a[200005], f[200005], g[200005], h[200005],       g_node[200005], ans, maxa, size[200005];   bool ok[200005];   inline void insert(int u, int v) {     e[++num].to = v;     e[num].next = head[u];     head[u] = num;     e[++num].to = u;     e[num].next = head[v];     head[v] = num;   }   void dfs(int now, int fa) {     size[now] = 1;     int s = 0, maxc = 0, secc = 0, id = 0;     for (int i = head[now]; i; i = e[i].next)       if (e[i].to != fa) {         dfs(e[i].to, now);         size[now] += size[e[i].to];         if (ok[e[i].to]) {           int ch = f[e[i].to] + g[e[i].to] + 1;           if (ch == size[e[i].to])             s += ch;           else if (ch > maxc)             secc = maxc, maxc = ch, id = e[i].to;           else if (ch > secc)             secc = ch;         }       }     if (ok[now]) {       f[now] = s;       g[now] = maxc;       h[now] = secc;       g_node[now] = id;     }   }   void work(int now, int fa, int out) {     if (ok[now]) {       if (out == n - size[now])         f[now] += out;       else {         if (out > g[now])           h[now] = g[now], g[now] = out, g_node[now] = fa;         else if (out > h[now])           h[now] = out;       }       num = max(num, f[now] + g[now] + 1);       if (num >= k) return;     }     for (int i = head[now]; i; i = e[i].next)       if (e[i].to != fa) {         if (!ok[now])           work(e[i].to, now, 0);         else {           if (ok[e[i].to] && f[e[i].to] + g[e[i].to] + 1 == size[e[i].to])             work(e[i].to, now, f[now] - size[e[i].to] + g[now] + 1);           else if (e[i].to == g_node[now])             work(e[i].to, now, f[now] + h[now] + 1);           else             work(e[i].to, now, f[now] + g[now] + 1);         }       }   }   inline bool check(int x) {     for (int i = 1; i <= n; i++) ok[i] = a[i] >= x;     memset(f, 0, sizeof(f));     memset(g, 0, sizeof(g));     memset(h, 0, sizeof(h));     dfs(1, 0);     num = 0;     work(1, 0, 0);     return num >= k;   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       maxa = max(maxa, a[i]);     }     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       insert(u, v);     }     int l = 1, r = maxa;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid))         ans = mid, l = mid + 1;       else         r = mid - 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 6;   int n, k;   int Pow10[10], F[10];   long long f[N];   long long cal(int n) {     int t = 0;     long long s = 0;     while (n > 0) {       int x = n % 10;       if (x % 3 == 0) s += 1LL * F[t] * x / 3;       n /= 10;       t++;     }     return s;   }   int main() {     ios ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (fopen( main.in ,  r )) freopen( main.in ,  r , stdin);     cin >> k;     Pow10[0] = 1;     for (int i = 0; i < 6; i++) {       cin >> F[i];       if (i) Pow10[i] = Pow10[i - 1] * 10;     }     int _, n;     cin >> _ >> n;     for (int i = 0; i <= n; i++) f[i] = -1e15;     f[0] = 0;     for (int t = 0; t < 6; t++) {       int s = 0, p = 1;       while (s + p <= 3 * (k - 1)) {         s += p;         for (int i = n; i >= 3LL * p * Pow10[t]; i--)           f[i] = max(f[i], f[i - 3 * p * Pow10[t]] + 1LL * p * F[t]);         p *= 2;       }       s = 3 * (k - 1) - s;       for (int i = n; i >= 3LL * s * Pow10[t]; i--)         f[i] = max(f[i], f[i - 3 * s * Pow10[t]] + 1LL * s * F[t]);     }     long long res = 0;     for (int i = 0; i <= n; i++) {       res = max(res, cal(n - i) + f[i]);     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   int a, b, c;   int t, x = 0;   int ans = 0;   void find(int x) {     for (t = x; t <= c + x; t++)       if (b * x + (b - a) * (t - x) < 0) {         x++;         ans++;         find(x);         break;       }   }   int main() {     scanf( %d%d%d , &a, &b, &c);     find(x);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     sort(a.begin(), a.end());     bool ok = true;     int cur = -1;     int q = 0;     for (int i = 0; i < n; ++i) {       if (q == 0) {         if (cur != -1 && a[i] != a[i - 1]) {           ok = false;           break;         }         q = 1;         cur = a[i];       } else {         if (cur == a[i]) {           ++q;         } else {           if (cur == a[i] - 1) {             --q;           } else {             ok = false;             break;           }         }       }     }     ok &= q == 0;     if (ok) {       cout <<  YES n ;     } else {       cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, f, m, k, l, g, i, h, a, b, j, a1, b1, c1, c, x, y, q, w, e, r, t, d[15];   int main() {     cin >> n;     d[0] = 2;     d[1] = 7;     d[2] = 2;     d[3] = 3;     d[4] = 3;     d[5] = 4;     d[6] = 2;     d[7] = 5;     d[8] = 1;     d[9] = 2;     a = n / 10;     b = n % 10;     cout << d[a] * d[b];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x;     cin >> x;     x = abs(x);     int pos = 0;     int i;     for (i = 1; pos < x; i++) pos += i;     int diff = pos - x;     if (diff % 2 == 0)       cout << (i - 1) << endl;     else {       if (i % 2 != 0)         cout << i << endl;       else         cout << i + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int node[101], h[101], perm[101], fav[101];   int getP(int c) {     int p = node[c];     if (p < 0) return c;     while (node[p] > 0) p = node[p];     return node[c] = p;   }   void join(int a, int b) {     if (0) printf( join %d %d n , a, b);     int pa = getP(a), pb = getP(b);     if (pa == pb) {       return;     }     if (h[pa] < h[pb]) {       node[pa] = pb;       h[pb] += h[pa];     } else {       node[pb] = pa;       h[pa] += h[pb];     }   }   void getNum() {     int i;     for (i = 0; i <= n; i++) {       node[i] = -1;       h[i] = 1;     }     for (i = 1; i <= n; i++) {       if (i + fav[i] <= n) join(i, i + fav[i]);       if (i - fav[i] > 0) join(i, i - fav[i]);     }     for (i = 1; i <= n; i++)       if (getP(i) != getP(perm[i])) {         if (0) printf( %d != %d n , i, perm[i]);         printf( NO );         return;       }     printf( YES );     return;   }   int main() {     int a, b, c;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &perm[i]);     }     for (int i = 1; i <= n; i++) scanf( %d , &fav[i]);     getNum();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int k = 0;       string a, b, c;       cin >> a >> b >> c;       for (int i = 0; i < a.size(); i++) {         if (a[i] == c[i] || b[i] == c[i])           k++;         else {           k = -1;           break;         }       }       if (k == a.size())         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     long long x, q, b;     for (int i = k - 1; i >= 1; i--) {       x = n / i * k + i;       q = x % k;       b = x / k;       if (q * b == n) return cout << x, 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> vec(n);     for (int i = 0; i < n; ++i) cin >> vec[i];     int sum = accumulate(vec.begin(), vec.end(), 0);     if ((sum / 100) % 2 != 0) {       cout <<  NO n ;       return 0;     }     sum /= 2;     int num_one = count(vec.begin(), vec.end(), 100);     int num_two = count(vec.begin(), vec.end(), 200);     int curr = 0;     while (curr <= sum && num_two > 0) {       curr += 200;       num_two--;     }     if (curr == sum) {       cout <<  YES n ;       return 0;     }     if (curr > sum) curr -= 200;     while (curr != sum && num_one > 0) {       curr += 100;       num_one--;     }     if (curr == sum)       cout <<  YES n ;     else       cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   const int size = 3111;   long long mod = 200000007;   double p;   int x, k, tmpx, a, m, b;   double dp[2][1 << 9][2][255];   int main() {     cin >> x >> k >> p;     tmpx = x;     p /= 100;     int cur, nxt;     m = (1 << 9) - 1;     int res = (x & m);     x >>= 9;     if (x & 1) {       a = 0;       while (x & 1) {         a++;         x >>= 1;       }       dp[0][res][1][a] = 1;     } else {       a = 0;       while (x > 0 && !(x & 1)) {         a++;         x >>= 1;       }       dp[0][res][0][a] = 1;     }     x = tmpx;     for (int i = 0; i < k; i++) {       cur = i % 2;       nxt = (i + 1) % 2;       for (int i = 0; i < (1 << 9); i++) {         if (i + 1 <= m) {           for (int k = 0; k < 250; k++) {             dp[nxt][i + 1][0][k] += (1 - p) * dp[cur][i][0][k];             dp[nxt][i + 1][1][k] += (1 - p) * dp[cur][i][1][k];           }         } else {           for (int k = 0; k < 250; k++) {             dp[nxt][0][1][1] += (1 - p) * dp[cur][i][0][k];             dp[nxt][0][0][k] += (1 - p) * dp[cur][i][1][k];           }         }         if (i * 2 <= m) {           for (int k = 0; k < 250; k++) {             dp[nxt][i * 2][0][1] += p * dp[cur][i][1][k];             dp[nxt][i * 2][0][k + 1] += p * dp[cur][i][0][k];           }         } else {           a = i * 2;           a &= m;           for (int k = 0; k < 250; k++) {             dp[nxt][a][1][1] += p * dp[cur][i][0][k];             dp[nxt][a][1][k + 1] += p * dp[cur][i][1][k];           }         }       }       for (int i = 0; i <= m; i++)         for (int k = 0; k < 250; k++) dp[cur][i][0][k] = dp[cur][i][1][k] = 0;     }     double ans = 0;     for (int i = 1; i <= m; i++) {       a = 0;       b = i;       while (!(b & 1)) {         b >>= 1;         a++;       }       for (int k = 0; k < 250; k++)         ans += (dp[nxt][i][0][k] + dp[nxt][i][1][k]) * a;     }     for (int k = 0; k < 250; k++) {       ans += dp[nxt][0][0][k] * (k + 9);       ans += dp[nxt][0][1][k] * 9;     }     printf( %.8lf n , ans);   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   template <typename T>   inline void umax(T &a, T b) {     a = max(a, b);   }   template <typename T>   inline void umin(T &a, T b) {     a = min(a, b);   }   const long long N = 1e5 + 10;   const long long INF = 1e16 + 10;   const pair<long long, long long> NINF = make_pair(INF, INF);   const long double EPS = 1e-6;   const long long II = 1e9;   const long long MOD = 1e9 + 7;   long long dp[1 << 22];   long long cnt[50][50];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     string second;     cin >> second;     for (long long i = 0; i < (n - 1); i++) {       cnt[second[i] -  a ][second[i + 1] -  a ]++;       cnt[second[i + 1] -  a ][second[i] -  a ]++;     }     for (long long i = 0; i < (1 << m); i++) dp[i] = INF;     for (long long i = 0; i < (m); i++) dp[1 << i] = 0;     for (long long msk = 0; msk < (1 << m); msk++) {       long long cur = dp[msk];       for (long long i = 0; i < (m); i++)         if (msk & (1 << i))           for (long long j = 0; j < (m); j++)             if ((msk & (1 << j)) == 0) cur += cnt[i][j];       for (long long j = 0; j < (m); j++)         if ((msk & (1 << j)) == 0) umin(dp[msk | (1 << j)], cur);     }     cout << dp[(1 << m) - 1];   }
#include <bits/stdc++.h>   using namespace std;   bool myfunction(int i, int j) { return (i < j); }   istream &in = cin;   int n;   bool adj[1501][1501];   int vtx[1501];   vector<bool> chk;   vector<pair<pair<int, int>, int> > points;   vector<pair<int, int> > res;   int dfs(int node) {     int cnt = 0;     chk[node] = true;     for (int i = 1; i <= n; ++i)       if (!chk[i] && adj[node][i]) cnt += dfs(i);     vtx[node] = cnt + 1;     return vtx[node];   }   void go(int root, vector<pair<pair<int, int>, int> > ps) {     int min_y = INT_MAX, min_i = -1;     for (int i = 1; i <= ps.size() - 1; ++i)       if (ps[i].first.second < min_y) {         min_y = ps[i].first.second;         min_i = i;       }     res.push_back(make_pair(ps[min_i].second, root));     vector<pair<long double, int> > tps(1);     for (int i = 1; i <= ps.size() - 1; ++i)       if (i != min_i)         tps.push_back(             make_pair(atan2l(ps[i].first.first - ps[min_i].first.first,                              ps[i].first.second - ps[min_i].first.second),                       i));     sort(tps.begin() + 1, tps.end());     int s = 1;     for (int i = 1; i <= n; ++i)       if (adj[root][i]) {         vector<pair<pair<int, int>, int> > nps(1);         while (nps.size() < vtx[i] + 1) {           nps.push_back(ps[tps[s].second]);           ++s;         }         adj[i][root] = false;         go(i, nps);       }   }   int main() {     in >> n;     for (int i = (0); i < (n + 1); ++i)       for (int j = (0); j < (n + 1); ++j) adj[i][j] = false;     points.resize(n + 1);     chk.resize(n + 1, false);     memset(vtx, 0, sizeof(vtx));     for (int i = (0); i < (n - 1); ++i) {       int a, b;       in >> a >> b;       adj[a][b] = adj[b][a] = true;     }     for (int i = (0); i < (n); ++i) {       int x, y;       in >> x >> y;       points[i + 1] = make_pair(make_pair(x, y), i + 1);     }     dfs(1);     sort(points.begin() + 1, points.end());     for (int i = (0); i < (n + 1); ++i) chk[i] = false;     go(1, points);     sort(res.begin(), res.end());     for (int i = 0; i < res.size(); ++i) cout << res[i].second <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e3 + 500;   const double eps = 1e-8;   int sgn(double x) {     if (fabs(x) < eps) return 0;     if (x < 0)       return -1;     else       return 1;   }   struct Point {     double x, y;     Point() {}     Point(double _x, double _y) : x(_x), y(_y) {}     void input() { scanf( %lf%lf , &x, &y); }     void output() { printf( %.0lf %.0lf n , x, y); }     Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); }     bool operator==(const Point &b) const {       return sgn(x - b.x) == 0 && sgn(y - b.y) == 0;     }     bool operator<(const Point &b) const {       return sgn(x - b.x) == 0 ? sgn(y - b.y) < 0 : x < b.x;     }     double operator^(const Point &b) const { return x * b.y - y * b.x; }     double operator*(const Point &b) const { return x * b.x + y * b.y; }     double distance(Point b) { return hypot(x - b.x, y - b.y); }   };   struct polygon {     int n;     Point p[maxn], p1, p2, p3;     void input(int _n) {       n = _n;       for (int i = 0; i < n; ++i) p[i].input();     }     struct cmp {       Point p;       cmp(const Point &p0) { p = p0; }       bool operator()(const Point &aa, const Point &bb) {         Point a = aa, b = bb;         int d = sgn((a - p) ^ (b - p));         if (d == 0) return sgn(a.distance(p) - b.distance(p)) < 0;         return d > 0;       }     };     void norm() {       Point mi = p[0];       for (int i = 1; i < n; ++i) mi = min(mi, p[i]);       sort(p, p + n, cmp(mi));     }     void Graham(polygon &convex) {       norm();       int &top = convex.n;       top = 0;       if (n == 1) {         top = 1;         convex.p[0] = p[0];         return;       }       if (n == 2) {         top = 2;         convex.p[0] = p[0];         convex.p[1] = p[1];         if (convex.p[0] == convex.p[1]) top--;         return;       }       convex.p[0] = p[0];       convex.p[1] = p[1];       top = 2;       for (int i = 2; i < n; ++i) {         while (top > 1 && sgn((convex.p[top - 1] - convex.p[top - 2]) ^                               (p[i] - convex.p[top - 2])) <= 0)           top--;         convex.p[top++] = p[i];       }       if (convex.n == 2 && (convex.p[0] == convex.p[1])) convex.n--;     }     void rotating_calipers() {       double ans = 0;       for (int i = 0; i < n; ++i) {         int k = i + 1;         for (int j = i + 1; j < n; ++j) {           while (sgn(fabs((p[j] - p[i]) ^ (p[(k + 1) % n] - p[i])) -                      fabs((p[j] - p[i]) ^ (p[k] - p[i]))) > 0)             k = (k + 1) % n;           if (ans < 0.5 * fabs((p[j] - p[i]) ^ (p[k] - p[i]))) {             p1 = p[i];             p2 = p[j];             p3 = p[k];             ans = 0.5 * fabs((p[j] - p[i]) ^ (p[k] - p[i]));           }         }       }     }   } A, B;   int n;   long long s;   int main() {     scanf( %d%lld , &n, &s);     A.input(n);     A.Graham(B);     B.rotating_calipers();     printf( %.0lf %.0lf n , B.p1.x + B.p2.x - B.p3.x, B.p1.y + B.p2.y - B.p3.y);     printf( %.0lf %.0lf n , B.p1.x + B.p3.x - B.p2.x, B.p1.y + B.p3.y - B.p2.y);     printf( %.0lf %.0lf n , B.p3.x + B.p2.x - B.p1.x, B.p3.y + B.p2.y - B.p1.y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int A[(1 << 17)];   int A0[(1 << 17)];   int A1[(1 << 17)];   int C[(1 << 17)];   int RMQ[2 << 20];   int I[32];   void Add(int a, int b) {     int i;     for (i = (0); i < (20); ++i) RMQ[I[i] + (a >> i)] += b;   }   int Sum(int a) {     int res = 0;     int i;     for (i = (0); i < (20); ++i) {       if (a & 1) res += RMQ[I[i] + a - 1];       a >>= 1;     }     return res;   }   int main() {     int N, M;     scanf( %d%d , &N, &M);     vector<int> v;     int i;     for (i = (0); i < (M); ++i) {       scanf( %d , &A[i]);       if (A[i] == 0)         scanf( %d%d , &A0[i], &A1[i]);       else         v.push_back(A[i]);     }     sort((v).begin(), (v).end());     v.resize(unique((v).begin(), (v).end()) - v.begin());     for (i = (0); i < (M); ++i)       if (A[i] != 0)         A[i] = int(lower_bound((v).begin(), (v).end(), A[i]) - v.begin()) + 1;     set<pair<int, int> > bl, lb;     bl.insert(pair<int, int>(-1, -N));     lb.insert(pair<int, int>(-N, -1));     v.clear();     memset(C, -1, sizeof(C));     for (i = (0); i < (M); ++i)       if (A[i] != 0)         if (C[A[i]] == -1) {           pair<int, int> t = *lb.begin();           lb.erase(lb.begin());           bl.erase(pair<int, int>(t.second, t.first));           int l = -t.second;           int r = -t.second - t.first;           int m = (l + r) / 2;           bl.insert(pair<int, int>(-l, l - m));           lb.insert(pair<int, int>(l - m, -l));           bl.insert(pair<int, int>(-(m + 1), (m + 1) - r));           lb.insert(pair<int, int>((m + 1) - r, -(m + 1)));           A0[i] = m;           C[A[i]] = m;           v.push_back(m);         } else {           pair<int, int> t(-C[A[i]], 0);           set<pair<int, int> >::iterator it0 = bl.lower_bound(t);           set<pair<int, int> >::iterator it1 = it0;           --it1;           pair<int, int> r = *it1;           pair<int, int> l = *it0;           bl.erase(l);           bl.erase(r);           lb.erase(pair<int, int>(l.second, l.first));           lb.erase(pair<int, int>(r.second, r.first));           l.second += r.second - 1;           bl.insert(l);           lb.insert(pair<int, int>(l.second, l.first));           A0[i] = -C[A[i]];           C[A[i]] = -1;         }     for (i = (0); i < (M); ++i)       if (A[i] == 0) {         ++A1[i];         v.push_back(A0[i]);         v.push_back(A1[i]);       }     sort((v).begin(), (v).end());     v.resize(unique((v).begin(), (v).end()) - v.begin());     memset(RMQ, 0, sizeof(RMQ));     I[0] = 0;     for (i = (1); i < (20); ++i) I[i] = I[i - 1] + (1 << (21 - i));     for (i = (0); i < (M); ++i)       if (A[i] == 0) {         A0[i] = lower_bound((v).begin(), (v).end(), A0[i]) - v.begin();         A1[i] = lower_bound((v).begin(), (v).end(), A1[i]) - v.begin();         printf( %d n , Sum(A1[i]) - Sum(A0[i]));       } else if (A0[i] < 0) {         A0[i] = lower_bound((v).begin(), (v).end(), -A0[i]) - v.begin();         Add(A0[i], -1);       } else {         A0[i] = lower_bound((v).begin(), (v).end(), A0[i]) - v.begin();         Add(A0[i], 1);       }     return 0;   };
#include <bits/stdc++.h>   using namespace std;   int n;   queue<int> q;   vector<int> v[1999];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 2; i <= n; i++) {       int a;       cin >> a;       v[a].push_back(i);     }     q.push(1);     int ok = 1;     while (!q.empty()) {       int cou = 0, sep = 0;       int k = q.front();       q.pop();       for (auto x : v[k]) {         sep = 1;         if (v[x].empty()) {           cou++;         }         q.push(x);       }       if (sep) {         if (cou < 3) {           ok = 0;           break;         }       }     }     if (ok) {       cout <<  YES ;     } else {       cout <<  NO ;     }   }
#include <bits/stdc++.h>   using namespace std;   int ans = -1;   map<pair<int, int>, bool> visited, mp;   void bfs(int x1, int y1, int x2, int y2) {     queue<pair<pair<int, int>, int>> q;     q.push({{x1, y1}, 0});     while (!q.empty()) {       auto z = q.front();       q.pop();       visited[z.first] = 1;       if (z.first.first == x2 && z.first.second == y2) {         ans = z.second;         break;       }       int x = z.first.first, y = z.first.second;       if (x - 1 >= 1 && !visited[{x - 1, y}] && mp[{x - 1, y}]) {         visited[{x - 1, y}] = true;         q.push({{x - 1, y}, z.second + 1});       }       if (x + 1 <= 1e9 && !visited[{x + 1, y}] && mp[{x + 1, y}]) {         visited[{x + 1, y}] = true;         q.push({{x + 1, y}, z.second + 1});       }       if (y - 1 >= 1 && !visited[{x, y - 1}] && mp[{x, y - 1}]) {         visited[{x, y - 1}] = true;         q.push({{x, y - 1}, z.second + 1});       }       if (y + 1 <= 1e9 && !visited[{x, y + 1}] && mp[{x, y + 1}]) {         visited[{x, y + 1}] = true;         q.push({{x, y + 1}, z.second + 1});       }       if (x + 1 <= 1e9 && y + 1 <= 1e9 && !visited[{x + 1, y + 1}] &&           mp[{x + 1, y + 1}]) {         visited[{x + 1, y + 1}] = true;         q.push({{x + 1, y + 1}, z.second + 1});       }       if (x + 1 <= 1e9 && y - 1 >= 1 && !visited[{x + 1, y - 1}] &&           mp[{x + 1, y - 1}]) {         visited[{x + 1, y - 1}] = true;         q.push({{x + 1, y - 1}, z.second + 1});       }       if (x - 1 >= 1 && y + 1 <= 1e9 && !visited[{x - 1, y + 1}] &&           mp[{x - 1, y + 1}]) {         visited[{x - 1, y + 1}] = true;         q.push({{x - 1, y + 1}, z.second + 1});       }       if (x - 1 >= 1 && y - 1 >= 1 && !visited[{x - 1, y - 1}] &&           mp[{x - 1, y - 1}]) {         visited[{x - 1, y - 1}] = true;         q.push({{x - 1, y - 1}, z.second + 1});       }     }   }   int main() {     ;     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int x1, y1, x2, y2;     cin >> x1 >> y1 >> x2 >> y2;     int n;     cin >> n;     set<pair<int, pair<int, int>>> s;     for (int i = 0; i < n; i++) {       int r, a, b;       cin >> r >> a >> b;       s.insert({r, {a, b}});     }     for (auto it : s) {       for (int i = it.second.first; i <= it.second.second; i++) {         mp[{it.first, i}] = true;       }     }     mp[{x1, y1}] = true;     mp[{x2, y2}] = true;     bfs(x1, y1, x2, y2);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Solve() {     long long n;     cin >> n;     vector<int> arr(n);     for (int i = 0; i < n; i++) cin >> arr[i];     reverse(arr.begin(), arr.end());     for (int i = 0; i < n; i++) cout << arr[i] <<    ;     cout <<   n ;   }   int main() {     long long t;     cin >> t;     while (t--) Solve();     return 0;   }