malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1e9 + 7;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   vector<long long int> v[2];   const long long int N = 3e5 + 5;   long long int x[N];   char ch[N];   signed main() {     ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long int n;     cin >> n;     long long int idx = 0;     long long int ans = 0;     long long int min1 = 1e12, max1 = 0, min2 = 1e12, max2 = 0;     for (long long int i = 1; i <= n; i++) {       cin >> x[i] >> ch[i];       if (ch[i] ==  G ) {         idx = i;       }       if (ch[i] ==  R ) {         min1 = min(min1, x[i]);         max1 = max(max1, x[i]);       }       if (ch[i] ==  B ) {         min2 = min(min2, x[i]);         max2 = max(max2, x[i]);       }     }     if (!idx) {       long long int ans = 0;       if (max2 >= min2) ans += max2 - min2;       if (max1 >= min1) ans += max1 - min1;       cout << ans;       return 0;     }     idx = 0;     for (long long int i = 1; i <= n; i++) {       if (ch[i] ==  G ) {         if (idx) {           v[0].clear();           v[1].clear();           long long int tot = x[i] - x[idx];           for (long long int j = idx; j <= i; j++) {             if (ch[j] ==  R  || ch[j] ==  G ) v[0].push_back(x[j]);             if (ch[j] ==  B  || ch[j] ==  G ) v[1].push_back(x[j]);           }           long long int sz = v[0].size();           long long int max1 = 0, max2 = 0;           for (long long int j = 0; j <= sz - 2; j++) {             max1 = max(max1, v[0][j + 1] - v[0][j]);           }           sz = v[1].size();           for (long long int j = 0; j <= sz - 2; j++) {             max2 = max(max2, v[1][j + 1] - v[1][j]);           }           tot += 2 * (x[i] - x[idx]) - max1 - max2;           tot = min(tot, 2 * (x[i] - x[idx]));           ans += tot;         } else {           for (long long int j = 1; j <= i - 1; j++) {             if (ch[j] ==  B ) {               ans += x[i] - x[j];               break;             }           }           for (long long int j = 1; j <= i - 1; j++) {             if (ch[j] ==  R ) {               ans += x[i] - x[j];               break;             }           }         }         idx = i;       }     }     for (long long int j = n; j > idx; j--) {       if (ch[j] ==  R ) {         ans += x[j] - x[idx];         break;       }     }     for (long long int j = n; j > idx; j--) {       if (ch[j] ==  B ) {         ans += x[j] - x[idx];         break;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   namespace FASTIO {   char buf[1 << 21];   char *p1, *p2;   template <typename T>   inline void wt(T x, char c =   n ) {     if (x < 0) {       x = -x;       putchar( - );     }     static char sta[sizeof(T) * 8];     T top = 0;     do {       sta[top++] = x % 10;       x /= 10;     } while (x);     while (top) putchar(sta[--top] +  0 );     putchar(c);   }   template <typename T>   inline T rd() {     T sum = 0, fl = 1;     char ch =         (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)              ? EOF              : *p1++);     for (; ch <  0  || ch >  9 ;          ch = (p1 == p2 &&                        (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)                    ? EOF                    : *p1++))       if (ch ==  - )         fl = -1;       else if (ch == EOF)         exit(0);     for (;  0  <= ch && ch <=  9 ;          ch = (p1 == p2 &&                        (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)                    ? EOF                    : *p1++))       sum = sum * 10 + ch -  0 ;     return sum * fl;   }   }  // namespace FASTIO   using namespace FASTIO;   int n, m;   int k;   int len;   std::vector<int> a;   struct node {     node *son[2];     int cnt;     node() {       son[0] = NULL;       son[1] = NULL;       cnt = 0;     }     ~node() {       delete son[0];       delete son[1];     }   } root;   inline void insert(int x) {     node *p = &root;     for (int i = len; i >= 0; i--) {       p->cnt++;       const bool $ = (x & 1 << i) != 0;       if (!p->son[$]) p->son[$] = new node();       p = p->son[$];     }     p->cnt++;     return;   }   inline int query() {     const node *p = &root;     int ans = 0;     for (int i = len; p && i >= 0; i--) {       const bool $ = (k & 1 << i) != 0;       if (!p->son[$] || p->son[$]->cnt < 1 << i)         p = p->son[$];       else {         p = p->son[!$];         ans |= 1 << i;       }     }     return ans;   }   int main() {     n = rd<int>();     m = rd<int>();     a.resize(n);     for (int &ele : a) ele = rd<int>();     std::sort(a.begin(), a.end());     a.erase(std::unique(a.begin(), a.end()), a.end());     len = a.back();     len = len ? log2(len) + 2 : 2;     for (const int &A : a) insert(A);     while (m--) {       k ^= rd<int>();       wt(query());     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int N, A, B, C;     char Error = 0;     scanf( %d , &N);     while (N) {       A = N % 10;       B = N % 100;       C = N % 1000;       if (A == 1) {         N /= 10;       } else if (B == 14) {         N /= 100;       } else if (C == 144) {         N /= 1000;       } else {         Error = 1;         break;       }     }     puts(Error ?  NO  :  YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 1;   const int M = 1e9 + 7;   int n;   vector<int> d;   vector<pair<int, int> > construct(int cur, vector<int> d) {     if (((int)d.size()) == 0) return vector<pair<int, int> >();     vector<pair<int, int> > tmp;     for (int i = 0; i < (d[0]); i++) {       for (int j = cur + i + 1; j <= cur + d.back(); j++)         tmp.push_back(make_pair(cur + i, j));     }     cur += d[0];     for (int i = 1; i < ((int)d.size()); i++) d[i] -= d[0];     d.erase(d.begin());     if (((int)d.size())) d.pop_back();     auto t = construct(cur, d);     for (auto x : t) tmp.push_back(x);     return tmp;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     d.resize(n);     for (int i = 0; i < (n); i++) cin >> d[i];     auto ans = construct(0, d);     cout << ((int)ans.size()) << endl;     for (auto x : ans) cout << x.first + 1 <<     << x.second + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[110], s[110][110];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       for (int j = 1; j <= a[i]; j++) s[i][j % m + 1]++;     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         for (int k = 1; k <= m; k++)           if (abs(s[i][k] - s[j][k]) > 1) {             printf( NO n );             return 0;           }     printf( YES n );     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= a[i]; j++) printf( %d  , j % m + 1);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   char s[maxn];   int un[maxn], ln[maxn];   int main() {     int i, j, k;     int ans = INT_MAX, tmp;     scanf( %s , s + 1);     un[0] = ln[0] = 0;     for (i = 1; s[i]; ++i) {       if (islower(s[i])) {         ln[i] = ln[i - 1] + 1;         un[i] = un[i - 1];       } else {         ln[i] = ln[i - 1];         un[i] = un[i - 1] + 1;       }     }     int len = i - 1;     for (i = 1; i <= len; ++i) {       tmp = ln[i - 1] + un[len] - un[i];       ans = min(ans, tmp);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   int sg[100010], f[100010], pre[100010];   int used[100010];   int n;   int cal(int n) {     for (int m = 2;; m++) {       int tot = m * (m - 1) / 2;       if (tot > n) break;       tot = n - tot;       if (tot % m) continue;       int s = tot / m;       int t = s + m - 1;       int v = sg[t] ^ sg[s - 1];       used[v] = n;       if (v == 0 && pre[n] == 0) pre[n] = m;     }     int ret = 0;     for (; used[ret] == n; ret++)       ;     return ret;   }   int main() {     int i, j, k;     scanf( %d , &n);     for (i = 3; i <= n; i++) {       f[i] = cal(i);       sg[i] = sg[i - 1] ^ f[i];     }     if (f[n])       printf( %d n , pre[n]);     else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, j;   string a, b;   int main() {     cin >> n;     cin >> a >> b;     sort(a.begin(), a.end());     sort(b.begin(), b.end());     j = n - 1;     for (int i = n - 1; i >= 0; i--) {       if (a[i] <= b[j]) j--;     }     cout << j + 1 <<   n ;     j = 0;     for (int i = 0; i < n; i++) {       if (b[i] > a[j]) j++;     }     cout << j;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   ifstream fin( A.in );   ofstream fout( A.out );   int n, m, i, j, a, b, y, minv = 1000000000, t = 0, ok, nr;   char cor[256], s[1001][1001];   int wh[1001][1001];   int viz[1001 * 1001], pred[1001 * 1001], best[1001 * 1001], good[1001 * 1001],       st[1001 * 1001];   queue<int> q;   vector<int> G[1001 * 1001];   char c[4] = { D ,  I ,  M ,  A };   void dfs(int x) {     viz[x] = 1;     st[x] = 1;     for (vector<int>::iterator it = G[x].begin(); it != G[x].end(); ++it) {       if (!viz[*it])         dfs(*it);       else if (st[*it])         ok = 1;     }     st[x] = 0;   }   int main() {     cin >> n >> m;     cor[ D ] =  I ;     cor[ I ] =  M ;     cor[ M ] =  A ;     cor[ A ] =  D ;     for (int i = 1; i <= n; ++i) {       cin >> s[i];       for (int j = 0; j < m; ++j) {         wh[i][j] = ++t;         if (s[i][j] ==  D ) {           good[wh[i][j]] = 1;         }       }     }     for (int k = 0; k < 4; ++k) {       for (int i = 1; i <= n; ++i) {         for (int j = 0; j < m; ++j) {           if (s[i][j] == c[k] && good[wh[i][j]]) {             if (i > 1) {               if (s[i - 1][j] == cor[s[i][j]]) {                 G[wh[i][j]].push_back(wh[i - 1][j]);                 pred[wh[i - 1][j]]++;                 good[wh[i - 1][j]] = 1;               }             }             if (j > 0) {               if (s[i][j - 1] == cor[s[i][j]]) {                 G[wh[i][j]].push_back(wh[i][j - 1]);                 pred[wh[i][j - 1]]++;                 good[wh[i][j - 1]] = 1;               }             }             if (i < n) {               if (s[i + 1][j] == cor[s[i][j]]) {                 G[wh[i][j]].push_back(wh[i + 1][j]);                 pred[wh[i + 1][j]]++;                 good[wh[i + 1][j]] = 1;               }             }             if (j < m - 1) {               if (s[i][j + 1] == cor[s[i][j]]) {                 G[wh[i][j]].push_back(wh[i][j + 1]);                 pred[wh[i][j + 1]]++;                 good[wh[i][j + 1]] = 1;               }             }           }         }       }     }     for (int i = 1; i <= t; ++i) {       if (good[i] && !viz[i]) {         dfs(i);       }     }     if (ok) {       cout <<  Poor Inna! ;       return 0;     }     for (int i = 1; i <= t; ++i) {       if (pred[i] == 0 && good[i]) q.push(i);       best[i] = 1;     }     while (!q.empty()) {       int x = q.front();       for (vector<int>::iterator it = G[x].begin(); it != G[x].end(); ++it) {         --pred[*it];         if (pred[*it] == 0) q.push(*it);         best[*it] = max(best[*it], best[x] + 1);       }       q.pop();     }     int maxv = 0;     for (int i = 1; i <= t; ++i) {       maxv = max(best[i], maxv);     }     if (maxv / 4 == 0) {       cout <<  Poor Dima! ;     } else       cout << maxv / 4;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int32_t M = 1e9 + 7;   const int32_t MM = 998244353;   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long exetended_euclid(long long a, long long b, long long &x,                              long long &y) {     if (a == 0) {       x = 0;       y = 1;       return b;     }     long long x1, y1;     long long m = exetended_euclid(b % a, a, x1, y1);     x = y1 - (b / a) * x1;     y = x1;     return m;   }   void solve() {     long long n, m;     cin >> n >> m;     if (n > 1 && m == 0) {       cout <<  No solution n ;     } else {       string s =   ;       s += to_string(m);       n--;       while (n--) {         s +=  0 ;       }       cout << s <<   n ;     }   }   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   int main() {     long n(0);     scanf( %ld , &n);     long currentDiv = 2, total = 1;     while (n > 1) {       if (currentDiv * currentDiv > n) {         total += n;         break;       } else if (n % currentDiv == 0) {         total += n;         n /= currentDiv;       } else {         ++currentDiv;       }     }     printf( %ld n , total);     return 0;   }
#include<iostream>   #include<iomanip>   #include<queue>   #include<stack>   #include<numeric>   #include<cstring>   #include<vector>   #include<algorithm>   #include<set>   #include<map>   #include<unordered_map>   #include<unordered_set>   #include<climits>   #include<cmath>      using namespace std;   #define int long long   #define pp pair<int,int>   #define ppl pair<ll,ll>    #define mod 1000000007      int32_t main()   {    ios_base::sync_with_stdio(false);    cin.tie(NULL);    cout.tie(NULL);        int t;    cin>>t;       while(t--)    {     int num;     cin >> num;        if ((num % 111) == 0)      cout <<  YES n ;        else     {      while (num > 0)      {       if ((num % 11) == 0)        break;          num -= 111;      }         if (num >= 0)       cout <<  YES n ;         else       cout <<  NO n ;     }    }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e4 + 5;   map<int, int> mp[N];   int arr[N];   int main() {     int n, m, a, b;     cin >> n >> m;     while (m--) {       cin >> a >> b;       mp[a][b]++;     }     arr[1] = 1;     for (int i = 2; i <= n; i++) {       int j = i;       arr[j] = j;       while (j > 1 && mp[arr[j - 1]][arr[j]] == 1) {         swap(arr[j], arr[j - 1]);         j--;       }     }     for (int i = 1; i <= n; i++) {       cout << arr[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9;   struct node {     int i, j, bal;     char scoba;     node() {}     node(long long _i, long long _j, long long _k, char _scoba)         : i(_i), j(_j), bal(_k), scoba(_scoba) {}   };   node p[210][210][410];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string s, t;     cin >> s >> t;     long long n = s.size(), m = t.size();     vector<vector<vector<long long> > > dp(         n + 1, vector<vector<long long> >(m + 1, vector<long long>(410, inf)));     dp[0][0][0] = 0;     for (long long i = 0; i <= n; ++i) {       for (long long j = 0; j <= m; ++j) {         for (long long k = 0; k <= 410; ++k) {           if (dp[i][j][k] == inf) continue;           long long nxti = i + (i < n && s[i] ==  ( ),                     nxtj = j + (j < m && t[j] ==  ( );           if (k + 1 < 410 && dp[nxti][nxtj][k + 1] > dp[i][j][k] + 1) {             dp[nxti][nxtj][k + 1] = dp[i][j][k] + 1;             p[nxti][nxtj][k + 1] = node(i, j, k,  ( );           }           nxti = i + (i < n && s[i] ==  ) ), nxtj = j + (j < m && t[j] ==  ) );           if (k > 0 && dp[nxti][nxtj][k - 1] > dp[i][j][k] + 1) {             dp[nxti][nxtj][k - 1] = dp[i][j][k] + 1;             p[nxti][nxtj][k - 1] = node(i, j, k,  ) );           }         }       }     }     long long curi = n, curj = m, cur_balance = 0;     for (long long i = 0; i < 410; ++i) {       if (dp[n][m][cur_balance] + cur_balance > dp[n][m][i] + i &&           dp[n][m][i] != inf) {         cur_balance = i;       }     }     string ans =   ;     long long temp = cur_balance;     while (curi > 0 || curj > 0 || cur_balance) {       node a = p[curi][curj][cur_balance];       long long ni = a.i;       long long nj = a.j;       long long nbal = a.bal;       ans += a.scoba;       curi = a.i;       curj = a.j;       cur_balance = a.bal;     }     while (temp--) ans =  )  + ans;     reverse(ans.begin(), ans.end());     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, y, z, f[1000000], k, ans = 0, a, b, c, t;   vector<long long> v;   map<long long, long long> m;   int main() {     cin >> n >> a >> b >> c >> t;     for (int i = 0; i < n; i++) cin >> f[i];     sort(f, f + n);     for (int i = 0; i < n; i++) {       x = a;       k = (t - f[i]) * c;       k -= (t - f[i]) * b;       k += a;       x = max(x, k);       ans += x;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const int size = 60;   const int ssize = 20;   const int lsize = 20 * 1000;   char field[size][size];   int n, m;   int cnt[1 << ssize];   double ans[1 << ssize];   int clr[size][size];   int hmas[lsize];   int bc(int msk) {     int c = 0;     while (msk > 0) {       c += msk & 1;       msk /= 2;     }     return c;   }   int h[size];   int ch[size];   void rec(int ps, int msk) {     if (ps == m) {       cnt[msk] = 0;       for (int i = 0; i < n; i++) ch[i] = 0;       for (int i = 0; i < n; i++) {         if (ch[clr[ps][i]] > 0) {           cnt[msk]++;         }         ch[clr[ps][i]]++;         if (ch[clr[ps][i]] == 2) cnt[msk]++;       }       return;     }     for (int i = 0; i < n; i++) clr[ps + 1][i] = clr[ps][i];     rec(ps + 1, msk);     for (int i = 0; i < n; i++) {       clr[ps + 1][i] = clr[ps][i] * 200 + (int)field[i][ps];       hmas[clr[ps + 1][i]] = -1;     }     int cc = 0;     for (int i = 0; i < n; i++) {       if (hmas[clr[ps + 1][i]] == -1) {         hmas[clr[ps + 1][i]] = cc++;       }       clr[ps + 1][i] = hmas[clr[ps + 1][i]];     }     rec(ps + 1, msk | (1 << ps));   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %s , field[i]);     }     m = strlen(field[0]);     for (int i = 0; i < n; i++) clr[0][i] = 0;     rec(0, 0);     for (int i = (1 << m) - 1; i >= 0; i--) {       if (cnt[i] == 0)         ans[i] = 0.0;       else {         ans[i] = 0.0;         double p = 1.0 / (m - bc(i));         for (int j = 0; j < m; j++)           if (!((i >> j) & 1)) {             int tg = i | (1 << j);             double g = (cnt[i] - cnt[tg] + 0.0) / cnt[i];             ans[i] += p * (g + (1 - g) * (ans[tg] + 1));           }       }     }     cout.precision(20);     cout << ans[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long conv(char c) { return c -  a ; }   vector<long long> get_sa(const char *s, long long n) {     vector<long long> sa(n);     long long m = 26;     vector<long long> cnt(max(n, m)), x(n), y(n);     for (long long i = 0; i < (long long)(n); ++i) cnt[x[i] = conv(s[i])]++;     for (long long i = 0; i < (long long)(m - 1); ++i) cnt[i + 1] += cnt[i];     for (long long i = n - 1; i >= 0; --i) sa[--cnt[x[i]]] = i;     for (long long len = 1, p = 0; p + 1 < n; len <<= 1, m = p + 1) {       p = 0;       for (long long i = n - len; i < n; ++i) y[p++] = i;       for (long long i = 0; i < (long long)(n); ++i)         if (sa[i] >= len) y[p++] = sa[i] - len;       for (long long i = 0; i < (long long)(m); ++i) cnt[i] = 0;       for (long long i = 0; i < (long long)(n); ++i) cnt[x[i]]++;       for (long long i = 0; i < (long long)(m - 1); ++i) cnt[i + 1] += cnt[i];       for (long long i = n - 1; i >= 0; --i) sa[--cnt[x[y[i]]]] = y[i];       y = x;       p = 0;       x[sa[0]] = 0;       for (long long i = 0; i < (long long)(n - 1); ++i)         x[sa[i + 1]] = sa[i] + len < n && sa[i + 1] + len < n &&                                y[sa[i]] == y[sa[i + 1]] &&                                y[sa[i] + len] == y[sa[i + 1] + len]                            ? p                            : ++p;     }     return sa;   }   vector<long long> get_lcp(const char *s, long long n, vector<long long> &sa) {     vector<long long> lcp(n), rank(n);     for (long long i = 0; i < (long long)(n); ++i) rank[sa[i]] = i;     long long k = 0, j;     for (long long i = 0; i < n; lcp[rank[i++]] = k) {       if (rank[i] - 1 >= 0)         for (k ? k-- : 0, j = sa[rank[i] - 1]; s[i + k] == s[j + k]; ++k)           ;     }     return lcp;   }   char S[5050];   long long dp[5050];   void solve() {     memset(dp, 0, sizeof dp);     long long n;     cin >> n;     cin >> S;     vector<long long> sa = get_sa(S, n);     vector<long long> lcp = get_lcp(S, n, sa);     for (long long i = 0; i < n; ++i) {       dp[i] = n - sa[i];       long long commonbaby = 1e9;       for (long long j = i - 1; j >= 0; --j) {         commonbaby = min(commonbaby, lcp[j + 1]);         if (sa[j] < sa[i]) {           dp[i] = max(dp[i], dp[j] + n - sa[i] - commonbaby);         }       }     }     cout << *max_element(dp, dp + n) <<   n ;   }   signed main(void) {     cin.tie(0)->sync_with_stdio(false);     long long T;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 69;   const int MOD = 1000000007;   void solve() {     int r, c;     cin >> r >> c;     char grid[MAX][MAX];     int rows[r], cols[c], aCount = 0;     for (int i = 0; i < r; i++) {       rows[i] = 0;     }     for (int i = 0; i < c; i++) {       cols[i] = 0;     }     char q;     bool two = false;     for (int i = 0; i < r; i++) {       for (int j = 0; j < c; j++) {         cin >> q;         if (q ==  A ) {           rows[i]++;           cols[j]++;           aCount++;         }         if (((i == 0 || i == r - 1) && (j == 0 || j == c - 1)) && q ==  A ) {           two = true;         }         grid[i][j] = q;       }     }     int rMax = -1, cMax = -1;     for (int i = 0; i < r; i++) {       rMax = max(rMax, rows[i]);     }     for (int i = 0; i < c; i++) {       cMax = max(cMax, cols[i]);     }     if (aCount == 0) {       cout <<  MORTAL ;     } else if (aCount == r * c) {       cout << 0;     } else if (rows[0] == c || cols[0] == r || rows[r - 1] == c ||                cols[c - 1] == r) {       cout << 1;     } else if (two || rMax == c || cMax == r) {       cout << 2;     } else if (rows[0] || cols[0] || rows[r - 1] || cols[c - 1]) {       cout << 3;     } else {       cout << 4;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int tt;     cin >> tt;     for (int i = 1; i <= tt; i++) {       solve();       cout << endl;     }   }
#include <bits/stdc++.h>   const int maxn = 60;   int mtx[maxn][maxn];   int n, m;   bool col_ok(int a, int b) {     for (int i = 0; i < n; i++) {       if (mtx[i][a] != mtx[i][b]) return 0;     }     return 1;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) scanf(  %c , &mtx[i][j]);     for (int i = 0; i < n; i++) {       int cmp = -1;       for (int j = 0; j < m; j++) {         if (mtx[i][j] ==  # ) {           if (cmp == -1) {             cmp = j;           } else {             if (!col_ok(cmp, j)) {               printf( No n );               return 0;             }           }         }       }     }     printf( Yes n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     string x;     cin >> x;     string y = x;     for (int i = 0; i < x.length(); i++) {       if (x[i] ==  a ) continue;       for (int j = i; j < x.length(); j++) {         if (x[j] ==  a ) break;         x[j] = char(int(x[j]) - 1);       }       break;     }     if (y == x) {       x[x.length() - 1] =  z ;     }     cout << x <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100005], ans = 0;   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i < n; i++) {       int j;       for (j = 0;; j++)         if (i + (1 << j) > n) break;       j--;       ans += a[i];       a[i + (1 << j)] += a[i];       cout << ans << endl;     }     return 0;   }