malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;        #define FASTIO           ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);   #define TEST             ll Test ; cin >> Test; while   #define TEST2            int Test = 1; while   #define READ             freopen( input.txt ,  r , stdin); freopen( output.txt ,  w , stdout);   #define INP(a, n)        for(ll i=0;i<(ll)n;i++) cin>>a[i] ;   #define INPA(a, n)       ll a[n]; for(ll i=0;i<(ll)n;i++) cin>>a[i] ;   #define INPV(a, n)       ll TrT; for(int i=0;i<(ll)n;i++){cin>>TrT; a.push_back(TrT);}   #define OUT(a, n)        for(ll i=0;i<(ll)n;i++)cout<<a[i]<<   ;   #define forp(i,a,b)      for(ll i=a;i<(ll)b;i++)   #define fore(i,a,b)      for(ll i=a;i<=(ll)b;i++)   #define fora(x)          for(auto &it: x)   #define INF              LLONG_MAX   #define sz               size()   #define len              length()   #define beg              begin()   #define en               end()   #define all(x)           x.beg,x.en   #define ff               first   #define ss               second   #define pb               push_back   #define pp               pop_back   #define lb               lower_bound   #define ub               upper_bound   #define N                  n    #define YES(n)           cout << ((n) ?  YES  :  NO ) <<   n  ;   #define Yes(n)           cout << ((n) ?  Yes  :  No ) <<   n  ;   #define fix(f,n)         fixed << setprecision(n) << f    #define M                1000000007   #define MM               998244353      #define TRACE      #ifdef TRACE       #define d(...) __f(#__VA_ARGS__, __VA_ARGS__)       template <typename Arg1>           void __f(const char* name, Arg1&& arg1) { cout << name <<   =   << arg1 << endl; }       template <typename Arg1, typename... Args>           void __f( const char* names, Arg1&& arg1, Args&&... args) {const char* comma = strchr(names + 1,  , ); cout.write(names, comma - names) <<   =   << arg1 <<    ; __f(comma + 1, args...); }   #else       #define d(...)   #endif       typedef long long int ll;   typedef long double ld;   typedef unsigned long long ull;   typedef vector<int> vi;   typedef vector<ll> vll;   typedef vector<vector<int>> vvi;   typedef vector<vector<ll>> vvll;   typedef vector<vector<ld>> vvld;   typedef pair<ll, ll> pll;   typedef vector<int> vi ;   typedef vector<pair<int, int>> vpi;   typedef vector<pair<ll,ll> > vpll;            void solve() {       ll p, a, b, c, temp, ans = INF;       cin >> p;       ll v[3];       forp(i, 0, 3) cin >> v[i];       forp(i, 0, 3) {           temp = p/v[i];           if(p % v[i] != 0) temp++;           ll x = temp * v[i];           // d(x);           ans = min(x - p, ans);       }       cout << ans << N;   }      int main() { FASTIO        #ifndef ONLINE_JUDGE           // READ       #endif        TEST(Test--)       {            solve();       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long fac[300011], inv[300011];   int F, W, H;   long long fastpower(long long v, long long p) {     long long ret = 1;     while (p > 0) {       if (p % 2 == 1) {         ret = ret * v;         ret %= mod;         p--;       } else {         v = v * v;         v %= mod;         p /= 2;       }     }     return ret;   }   void init() {     fac[0] = inv[0] = 1;     for (int i = 1; i < 300011; ++i) {       fac[i] = fac[i - 1] * i;       inv[i] = inv[i - 1] * fastpower(i, mod - 2);       fac[i] %= mod;       inv[i] %= mod;     }   }   long long C(int n, int k) {     if (n < k) return 0;     return ((fac[n] * inv[k]) % mod * inv[n - k]) % mod;   }   long long add(long long v, long long u) { return (v + u) % mod; }   long long cost(long long n, long long k, long long low) {     n = n - k * low;     if (n < 0) return 0;     return C(n + k - 1, n);   }   long long calc(int num, int limit) {     long long v1 = cost(F, num, 1) * cost(W, num, limit) * 2;     long long v2 = cost(F, num, 1) * cost(W, num + 1, limit);     long long v3 = cost(F, num, 1) * cost(W, num - 1, limit);     return add(add(v1, v2), v3);   }   int main() {     init();     scanf( %d%d%d , &F, &W, &H);     H++;     if (W == 0) {       printf( 1 n );       return 0;     }     if (W < H) {       printf( 0 n );       return 0;     }     if (W == 0) {       printf( 1 n );       return 0;     }     if (F == 0) {       printf( 1 n );       return 0;     }     long long ans = 0;     for (int i = 1; i <= F; ++i) {       ans += calc(i, H);       ans %= mod;     }     ans = ans + mod;     ans %= mod;     ans = ans * fastpower(C(W + F, W), mod - 2);     ans = ans % mod;     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int m, p, l, q = 0, r, t = 0;     long long int n, k = 0, i, j = 0;     string s;     getline(cin, s);     j = 0;     for (i = 0; i < s.size(); i++) {       if (s[i] ==  a  || s[i] ==  e  || s[i] ==  i  || s[i] ==  o  || s[i] ==  u )         j++;     }     if (j == 5) k++;     j = 0;     string s1;     getline(cin, s1);     j = 0;     for (i = 0; i < s1.size(); i++) {       if (s1[i] ==  a  || s1[i] ==  e  || s1[i] ==  i  || s1[i] ==  o  ||           s1[i] ==  u )         j++;     }     if (j == 7) k++;     j = 0;     string s2;     getline(cin, s2);     j = 0;     for (i = 0; i < s2.size(); i++) {       if (s2[i] ==  a  || s2[i] ==  e  || s2[i] ==  i  || s2[i] ==  o  ||           s2[i] ==  u )         j++;     }     if (j == 5) k++;     if (k == 3)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   set<int> smax, smin;   int ox[100000], oy[100000];   map<pair<int, int>, int> pnts;   inline int eval(int x, int y) {     if (pnts.count({x, y})) {       return pnts.count({x, y - 1}) + pnts.count({x - 1, y - 1}) +              pnts.count({x + 1, y - 1});     }     return 3;   }   inline bool isOk(int x, int y) {     return (eval(x, y + 1) > 1) && (eval(x - 1, y + 1) > 1) &&            (eval(x + 1, y + 1) > 1);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cerr <<  -.- ;     int m;     cin >> m;     for (int i = 0; i < m; ++i) {       cin >> ox[i] >> oy[i];       pnts.insert({{ox[i], oy[i]}, i});     }     for (int i = 0; i < m; ++i) {       if (isOk(ox[i], oy[i])) {         smax.insert(-i), smin.insert(i);       }     }     int turn = 0;     vector<int> path;     int dd[] = {0, -1, 1, -2, 2};     while (((int)(smax).size())) {       int i = (turn == 0) ? -(*smax.begin()) : (*smin.begin());       smin.erase(i), smax.erase(-i);       path.push_back(i), pnts.erase({ox[i], oy[i]});       for (int d = 1; d < 5; ++d) {         auto it = pnts.find({ox[i] + dd[d], oy[i]});         if (it != pnts.end()) {           int j = it->second;           if (!isOk(ox[j], oy[j])) {             smax.erase(-j), smin.erase(j);           }         }       }       for (int d = 0; d < 3; ++d) {         auto it = pnts.find({ox[i] + dd[d], oy[i] - 1});         if (it != pnts.end()) {           int j = it->second;           if (isOk(ox[j], oy[j])) {             smax.insert(-j), smin.insert(j);           }         }       }       turn ^= 1;     }     int ans = 0;     for (int i = 0; i < ((int)(path).size()); ++i) {       ans = ((1ll * ans * m) + path[i]) % 1000000009;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using LL = int64_t;   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(nullptr);     int n;     std::cin >> n;     std::vector<int> a(n);     for (int &i : a) std::cin >> i;     std::sort(a.begin(), a.end());     int maxa = a.back();     std::vector<std::vector<int>> mx(maxa + 1);     for (auto &i : mx) i.assign(2, -1);     std::vector<int> cnt(maxa + 1);     for (int i : a) ++cnt[i];     for (int i = 1; i <= maxa; ++i) {       if (cnt[i] >= 2)         mx[i][0] = mx[i][1] = i;       else if (cnt[i] == 1) {         mx[i][0] = i;         mx[i][1] = mx[i - 1][0];       } else         mx[i] = mx[i - 1];       cnt[i] += cnt[i - 1];     }     LL ans = 0;     for (int y = 2; y <= maxa; ++y) {       int more[] = {-1, -1};       LL cnty = 0;       for (int k = 1; k <= maxa / y; ++k)         cnty += (LL)k * (cnt[std::min((k + 1) * y - 1, maxa)] - cnt[k * y - 1]);       for (int k = maxa / y; k >= 0; --k) {         more[1] =             std::max(more[1], mx[std::min((k + 1) * y - 1, maxa)][0] - k * y);         if (more[0] < more[1]) std::swap(more[0], more[1]);         more[1] =             std::max(more[1], mx[std::min((k + 1) * y - 1, maxa)][1] - k * y);         int x = std::min((LL)(k * y + more[0]) / 2, cnty - k);         if (x >= 2) ans = std::max(ans, LL(x) * y);         if (more[1] != -1) {           x = std::min((LL)k * y + more[1], cnty - 2 * k);           if (x >= 2) ans = std::max(ans, LL(x) * y);         }         if (n - cnt[std::max(0, k * y + more[0] - 1)] >= 2) {           x = std::min((LL)k * y + more[0], cnty - 2 * k - 1);           if (x >= 2) ans = std::max(ans, LL(x) * y);         }       }     }     std::cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using VI = vector<int>;   using PII = pair<int, int>;   const int N = 1005, INF = 1e9;   vector<PII> adj[N];   int dis[N][N];   int main() {     int n, m, k;     cin >> n >> m >> k;     vector<tuple<int, int, int>> edges;     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       adj[u].emplace_back(v, w);       adj[v].emplace_back(u, w);       edges.emplace_back(u, v, w);     }     vector<PII> paths(k);     for (auto &[u, v] : paths) cin >> u >> v;     for (int s = 1; s <= n; s++) {       for (int u = 1; u <= n; u++) {         dis[s][u] = s == u ? 0 : INF;       }       priority_queue<PII> heap;       heap.emplace(0, s);       while (!heap.empty()) {         int u = heap.top().second;         heap.pop();         for (auto [v, w] : adj[u]) {           if (dis[s][v] > dis[s][u] + w) {             dis[s][v] = dis[s][u] + w;             heap.emplace(-dis[s][v], v);           }         }       }     }     ll ans = 1e18;     for (auto [u, v, w] : edges) {       ll cur = 0;       for (auto [x, y] : paths) {         cur += min({dis[x][y], dis[x][u] + dis[v][y], dis[x][v] + dis[u][y]});       }       ans = min(ans, cur);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     register int x = 0, f = 1, ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   int n;   int a[1010];   int b[1010];   int main() {     n = read();     for (int i = 1; i <= n; i++) {       a[i] = read();     }     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; i++) {       if (i & 1)         printf( %d  , a[(i + 1) / 2]);       else         printf( %d  , a[n - i / 2 + 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[201000], l[201000], r[201000];   int n;   int a[201000], s[201000];   int top;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     top = 0;     s[top] = 0;     a[0] = 0;     for (int i = 1; i <= n; i++) {       while (a[s[top]] >= a[i]) top--;       l[i] = s[top] + 1;       top++;       s[top] = i;     }     top = 0;     s[top] = n + 1;     a[n + 1] = 0;     for (int i = n; i >= 1; i--) {       while (a[s[top]] >= a[i]) top--;       r[i] = s[top] - 1;       top++;       s[top] = i;     }     for (int i = 1; i <= n; i++)       f[r[i] - l[i] + 1] = max(f[r[i] - l[i] + 1], a[i]);     for (int i = n; i >= 1; i--) f[i] = max(f[i], f[i + 1]);     for (int i = 1; i <= n; i++) cout << f[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int64_t dfs(int64_t idx, int64_t p, vector<vector<int64_t>>& g,               vector<int64_t>& parents, int64_t& c1, int64_t& c2) {     int64_t n = g.size() - 1;     parents[idx] = p;     int64_t res = 1;     int64_t mx = 0;     for (auto& x : g[idx]) {       if (x != p) {         int64_t a = dfs(x, idx, g, parents, c1, c2);         res += a;         mx = max(mx, a);       }     }     mx = max(mx, n - res);     if (mx <= n / 2) {       if (c1 == -1) {         c1 = idx;       } else {         c2 = idx;       }     }     return res;   }   int64_t leaf(int64_t idx, int64_t p, vector<vector<int64_t>>& g) {     if (g[idx].size() == 1) {       return idx;     } else {       auto res = -1;       for (auto& e : g[idx]) {         if (e != p) {           res = leaf(e, idx, g);           if (res != -1) {             return res;           }         }       }     }     return -1;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int64_t tc;     cin >> tc;     while (tc--) {       int64_t n;       cin >> n;       vector<vector<int64_t>> g(n + 1);       for (int64_t i = 0; i < n - 1; i++) {         int64_t a;         int64_t b;         cin >> a >> b;         g[a].push_back(b);         g[b].push_back(a);       }       int64_t c1 = -1;       int64_t c2 = -1;       vector<int64_t> p(n + 1);       dfs(1, 0, g, p, c1, c2);       if (c2 == -1) {         int64_t rm = g[c1][0];         cout << c1 <<     << rm << endl;         cout << c1 <<     << rm << endl;       } else {         if (p[c2] != c1) {           swap(c1, c2);         }         int64_t rm = leaf(c2, c1, g);         cout << rm <<     << p[rm] << endl;         cout << rm <<     << c1 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   #define int long long   #define INF (1e15 + 7)   #define pii pair<int, int>      using namespace std;      struct Node {       int x, y;       Node(int _x = 0, int _y = 0) : x(_x), y(_y) {}       bool operator<(const Node &u)const {           if (x < u.x) return true;           if (x > u.x) return false;           return y > u.y;       }   };      const int MAX_N = 2e5 + 7;   Node in[MAX_N], de[MAX_N];   vector<pii> ab, ba;   int a[MAX_N], b[MAX_N];   int n, mx, dis, top;      inline int low_bound(vector<pii> &s, int x) {       while (top && s[top - 1].first > x) {           --top;       }       if (!top) return -1;       return s[top - 1].second;   }         signed main() {       // freopen( in.txt ,  r , stdin);       scanf( %lld , &n);       for (int i = 1; i <= n; ++i) scanf( %lld , a + i);       for (int i = 1; i <= n; ++i) scanf( %lld , b + i);       int n1 = 0, n2 = 0;       for (int i = 1; i <= n; ++i) {           if (a[i] < b[i]) in[++n1] = Node(a[i], b[i]);           else if (a[i] > b[i]) de[++n2] = Node(b[i], a[i]);           dis += abs(a[i] - b[i]);       }       sort(in + 1, in + 1 + n1);       sort(de + 1, de + 1 + n2);       int len1 = 0, len2 = 0;       for (int i = 1; i <= n1; ++i) {           if (!len1 || in[i].y > ab[len1 - 1].second) {               ab.push_back(pii(in[i].x, in[i].y));               ++len1;           }       }       for (int i = 1; i <= n2; ++i) {           if (!len2 || de[i].y > ba[len2 -1].second) {               ba.push_back(pii(de[i].x, de[i].y));               ++len2;           }       }       top = len2;       for (int i = len1 - 1; i >= 0; --i) {           int y = low_bound(ba, ab[i].first);           if (~y) mx = max(mx, min(y, ab[i].second) - ab[i].first);       }       top = len1;       for (int i = len2 - 1; i >= 0; --i) {           int y = low_bound(ab, ba[i].first);           if (~y) mx = max(mx, min(y, ba[i].second) - ba[i].first);       }       printf( %lld n , dis - mx * 2);       return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dp[2][605];   int main() {     int n, k;     scanf( %d%d , &n, &k);     int pre = 0, cur = 1;     for (int i = 0; i < n; ++i) {       memset(dp[cur], 0, sizeof dp[cur]);       for (int j = 1; j < 600; ++j)         dp[cur][j] += (1. * j / k / (j + 1) + (k - 1.) / k) * dp[pre][j] +                       1. * (dp[pre][j + 1] + j) / ((j + 1.) * k) + 1. * j / 2 / k;       swap(pre, cur);     }     printf( %.15f n , k * dp[pre][1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long tree[1000001];   int n;   void update(int x, long long val) {     for (int i = x; i <= n; i += i & (-i)) {       tree[i] += val;     }   }   long long query(int x) {     long long sum = 0;     while (x > 0) {       sum += tree[x];       x -= x & (-x);     }     return sum;   }   int main() {     int m, i, j = 2, k;     long long l = 1;     cin >> n >> k;     m = 0;     int count = 0;     i = 1;     while (count < n) {       j = (i + k) % n;       if (!j) j = n;       m = i % n;       if (!m) m = n;       if (m > j) {         l += min(query(j - 1) + query(n) - query(m), query(m - 1) - query(j)) +              (long long)1;       } else {         l += min(query(j) - query(m), query(m - 1) + query(n) - query(j)) +              (long long)1;       }       cout << l <<    ;       update(m, 1);       update(j, 1);       count++;       i = j;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   long long my_pow(long long a, long long n) {     long long res = 1;     while (n) {       if (n & 1) res *= a;       a *= a;       n >>= 1;     }     return res;   }   const int mn = 10010;   vector<int> v[mn];   vector<int> s(mn, 0);   void dfs(int vert, int c) {     s[vert] = c;     for (auto it : v[vert]) dfs(it, c);   }   int main() {     int n, k;     cin >> n;     int c[n + 10];     for (int i = 2; i <= n; i++) {       scanf( %d , &k);       v[k].push_back(i);     }     for (int i = 1; i <= n; i++) scanf( %d , &c[i]);     int ans = 0;     for (int i = 1; i <= n; i++) {       if (s[i] != c[i]) {         dfs(i, c[i]);         ans++;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   const int N = 100010;   const int M = 30;   std::map<std::string, int> Hash;   int fa[N << 1], n, m, q;   char s[M];   int find(int u) { return fa[u] == u ? u : fa[u] = find(fa[u]); }   void unite(int u, int v) {     int _u = find(u), _v = find(v);     fa[_u] = _v;     find(u);   }   int main() {     for (int i = 0; i < N << 1; ++i) {       fa[i] = i;     }     scanf( %d%d%d , &n, &m, &q);     for (int i = 0; i < n; ++i) {       scanf( %s , s);       std::string str = s;       Hash[str] = i;     }     for (int i = 0, type; i < m; ++i) {       scanf( %d%s , &type, s);       std::string str = s;       int u = Hash[str];       scanf( %s , s);       str = s;       int v = Hash[str];       find(u), find(v), find(v + n), find(u + n);       if (type == 1) {         if (fa[u] == fa[v + n] || fa[v] == fa[u + n]) {           printf( NO n );           continue;         }         printf( YES n );         unite(u, v);         unite(u + n, v + n);         continue;       }       if (type == 2) {         if (fa[u] == fa[v] || fa[u + n] == fa[v + n]) {           printf( NO n );           continue;         }         printf( YES n );         unite(u, v + n);         unite(u + n, v);       }     }     for (int i = 0; i < q; ++i) {       scanf( %s , s);       std::string str = s;       int u = Hash[str];       scanf( %s , s);       str = s;       int v = Hash[str];       find(u), find(v), find(u + n), find(v + n);       if (fa[u] == fa[v] || fa[u + n] == fa[v + n]) {         printf( 1 n );       } else if (fa[u] == fa[v + n] || fa[u + n] == fa[v]) {         printf( 2 n );       } else {         printf( 3 n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int bst(int a[], int lw, int hi, int n) {     int mid = (lw + hi) / 2;     if (lw > hi) return -1;     if (a[mid] > n)       bst(a, lw, mid - 1, n);     else if (a[mid] < n)       bst(a, mid + 1, hi, n);     else       return mid;   }   long long pw(long long a, long long b, long long p) {     if (b == 0) return 1;     long long t = pw(a, b / 2, p);     if (b % 2)       return (((a * t) % p) * t) % p;     else       return ((t * t) % p);   }   void solve() {     string s;     long long ct1 = 0, ct2 = 0, V = 0, H = 0;     cin >> s;     if (s.size() == 1) {       cout << 2 << endl;       return;     }     vector<long long> v1, v2;     v1.push_back(0);     v2.push_back(0);     long long i = 0, k = 0, t = 0;     while (i < s.size()) {       if (s[i] ==  W ) {         v1.push_back(++ct1);       } else if (s[i] ==  S ) {         v1.push_back(--ct1);       } else if (s[i] ==  D ) {         v2.push_back(++ct2);       } else {         v2.push_back(--ct2);       }       i++;     }     if (v1.size() == 2) {       V = 1;     }     if (v2.size() == 2) {       H = 1;     }     long long lw1 = *min_element(v1.begin(), v1.end()),               hi1 = *max_element(v1.begin(), v1.end());     long long lw2 = *min_element(v2.begin(), v2.end()),               hi2 = *max_element(v2.begin(), v2.end());     vector<long long> min1_pos, min2_pos, max1_pos, max2_pos;     for (i = 0; i < v1.size(); i++) {       if (v1[i] == lw1) min1_pos.push_back(i);       if (v1[i] == hi1) max1_pos.push_back(i);     }     for (i = 0; i < v2.size(); i++) {       if (v2[i] == lw2) min2_pos.push_back(i);       if (v2[i] == hi2) max2_pos.push_back(i);     }     bool v, h;     long long a, b, c, d;     a = min1_pos.back();     b = min1_pos.front();     c = max1_pos.back();     d = max1_pos.front();     if ((c < a && c < b) || (d > a && d > b))       v = true;     else       v = false;     a = min2_pos.back();     b = min2_pos.front();     c = max2_pos.back();     d = max2_pos.front();     if ((c < a && c < b) || (d > a && d > b))       h = true;     else       h = false;     if (V && H) {       cout << 4 << endl;     } else if (V) {       if (h)         cout << 2 * (hi2 - lw2) << endl;       else         cout << 2 * (hi2 - lw2 + 1) << endl;     } else if (H) {       if (v)         cout << 2 * (hi1 - lw1) << endl;       else         cout << 2 * (hi1 - lw1 + 1) << endl;     } else {       if (v && h)         cout << min((hi1 - lw1 + 1) * (hi2 - lw2), (hi1 - lw1) * (hi2 - lw2 + 1))              << endl;       else if (v)         cout << (hi1 - lw1) * (hi2 - lw2 + 1) << endl;       else if (h)         cout << (hi1 - lw1 + 1) * (hi2 - lw2) << endl;       else         cout << (hi1 - lw1 + 1) * (hi2 - lw2 + 1) << endl;     }   }   int main() {     long long t = 1;     cin >> t;     while (t--) solve();     return 0;   }