malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int t, n, m, k, a[105][105], h, a1, a2, cnt, ans[105][105], pos, ch;   char c[105][105];   string s;   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(0);     cin >> t;     while (t--) {       h = 0;       pos = 0;       cin >> n >> m >> k;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           cin >> c[i][j];           if (c[i][j] ==  R ) {             a[i][j] = 1;             h++;           } else {             a[i][j] = 0;           }         }       }       a1 = h % k;       a2 = k - h % k;       cnt = 0;       ch = 0;       for (int i = 0; i < n; i++) {         if (i % 2 == 0) {           for (int j = 0; j < m; j++) {             if (ch) {               if (a[i][j] == 0) {                 ans[i][j] = pos;               } else {                 pos++;                 ans[i][j] = pos;                 cnt++;                 ch = 0;               }               if (a1 == 0) {                 if (cnt == h / k) {                   ch = 1;                   cnt = 0;                 }               }             } else {               if (a[i][j]) {                 cnt++;               }               ans[i][j] = pos;               if (a1 > 0) {                 if (cnt == h / k + 1) {                   cnt = 0;                   ch = 1;                   a1--;                 }               } else {                 if (cnt == h / k) {                   cnt = 0;                   ch = 1;                 }               }             }           }         } else {           for (int j = m - 1; j >= 0; j--) {             if (ch) {               if (a[i][j] == 0) {                 ans[i][j] = pos;               } else {                 pos++;                 ans[i][j] = pos;                 cnt++;                 ch = 0;               }               if (a1 == 0) {                 if (cnt == h / k) {                   ch = 1;                   cnt = 0;                 }               }             } else {               if (a[i][j]) {                 cnt++;               }               ans[i][j] = pos;               if (a1 > 0) {                 if (cnt == h / k + 1) {                   cnt = 0;                   a1--;                   ch = 1;                 }               } else {                 if (cnt == h / k) {                   cnt = 0;                   ch = 1;                 }               }             }           }         }       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (ans[i][j] <= 9) {             cout << ans[i][j];           } else if (ans[i][j] <= 35) {             char cc = ans[i][j] - 10 +  a ;             cout << cc;           } else {             char cc = ans[i][j] - 36 +  A ;             cout << cc;           }         }         cout <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t, f, h = 0, z = 0, x = 0;     char a[100];     cin >> t;     for (int i = 0; i < t; i++) {       cin >> a[i];     }     while (t > 0) {       z++;       t = t - z;     }     for (int y = 0; y < z; y++) {       h = h + y;       cout << a[h];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxval = 2e6 + 6;   int b[maxval];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int a;       scanf( %d , &a);       b[a] = a;     }     for (int i = 0; i < maxval; i++)       if (!b[i]) b[i] = b[i - 1];     int ans = 0;     for (int i = 2; i < maxval / 2; i++) {       if (b[i] == i) {         for (int j = i - 1; j < maxval; j += i) {           if (j < maxval && i <= b[j] && ans < b[j] % i) ans = b[j] % i;         }       }     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, i, m, j, x;     cin >> n >> m;     long long a[n][m], lowR[n][m], highR[n][m], lowC[n][m], highC[n][m];     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) cin >> a[i][j];     }     for (i = 0; i < n; i++) {       vector<long long> v, v1;       for (j = 0; j < m; j++) {         v.push_back(a[i][j]);       }       sort(v.begin(), v.end());       v1.push_back(v[0]);       for (j = 1; j < v.size(); j++) {         if (v[j] != v[j - 1]) v1.push_back(v[j]);       }       for (j = 0; j < m; j++) {         lowR[i][j] = lower_bound(v1.begin(), v1.end(), a[i][j]) - v1.begin();         highR[i][j] = v1.size() - lowR[i][j] - 1;       }     }     for (i = 0; i < m; i++) {       vector<long long> v, v1;       for (j = 0; j < n; j++) {         v.push_back(a[j][i]);       }       sort(v.begin(), v.end());       v1.push_back(v[0]);       for (j = 1; j < v.size(); j++) {         if (v[j] != v[j - 1]) v1.push_back(v[j]);       }       for (j = 0; j < n; j++) {         lowC[j][i] = lower_bound(v1.begin(), v1.end(), a[j][i]) - v1.begin();         highC[j][i] = v1.size() - lowC[j][i] - 1;       }     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++)         cout << max(lowR[i][j], lowC[i][j]) + max(highR[i][j], highC[i][j]) + 1              <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 310;   int mod[3];   int n;   string s[maxn];   long long ha[maxn][3];   int prel[maxn];   int main() {     ios::sync_with_stdio(false);     mod[0] = 1e9 + 7;     mod[1] = 1e9 + 9;     mod[2] = 19260817;     cin >> n;     int ans = 0;     for (int i = 1; i <= n; i++) {       cin >> s[i];       int l = s[i].size();       for (int j = l - 1; j >= 0; j--) {         for (int k = 0; k < 3; k++) {           ha[i][k] = (ha[i][k] * 131 + s[i][j]) % mod[k];         }       }       prel[i] = prel[i - 1] + l;     }     ans = prel[n] + n - 1;     int res = 0;     for (int i = 1; i <= n; i++) {       for (int j = i; j <= n; j++) {         int len = j - i + 1, cnt = 0;         for (int k = j + 1; k + len - 1 <= n; k++) {           bool f = 1;           for (int l = 0; l < len; l++) {             if (ha[i + l][0] != ha[k + l][0] || ha[i + l][1] != ha[k + l][1] ||                 ha[i + l][2] != ha[k + l][2]) {               f = 0;               break;             }           }           if (f) cnt++, k += len - 1;         }         if (cnt == 0) continue;         res = max(res, (cnt + 1) * (prel[j] - prel[i - 1] - 1));       }     }     cout << ans - res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x = 0, o = 0, h = 0, v = 0, d = 0;     char r;     char ar[3][3];     for (int i = 0; i < 3; ++i) {       for (int j = 0; j < 3; ++j) {         cin >> ar[i][j];         if (ar[i][j] ==  X )           x++;         else if (ar[i][j] ==  0 )           o++;       }     }     if (x - o > 1 || x - o < 0) {       cout <<  illegal ;       return 0;     }     for (int i = 0; i < 3; ++i) {       if (ar[i][0] == ar[i][1] && ar[i][1] == ar[i][2] && ar[i][0] !=  . ) {         h++;         r = ar[i][0];       }       if (ar[0][i] == ar[1][i] && ar[1][i] == ar[2][i] && ar[0][i] !=  . ) {         v++;         r = ar[0][i];       }     }     if (ar[0][0] == ar[1][1] && ar[1][1] == ar[2][2] && ar[0][0] !=  . ) {       d = 1;       r = ar[0][0];     }     if (ar[0][2] == ar[1][1] && ar[1][1] == ar[2][0] && ar[2][0] !=  . ) {       d = 1;       r = ar[0][2];     }     if (h == 1 || d == 1 || v == 1) {       if (r ==  X  && x - o == 1)         cout <<  the first player won ;       else if (r ==  0  && x == o)         cout <<  the second player won ;       else         cout <<  illegal ;       return 0;     }     if (v > 1 || h > 1) {       cout <<  illegal ;       return 0;     }     if (x + o == 9) {       cout <<  draw ;       return 0;     }     cout << (x == o ?  first  :  second );   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, v, x;   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> m >> v;     if ((((n - 1) * (n - 2) / 2) + 1 < m) || (m < (n - 1)))       return cout << -1 <<   n , 0;     for (int i = 1; i <= n; i++)       if (i != v) cout << v <<     << i <<   n , x = i;     m -= (n - 1);     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (!m) return 0;         if (i != x && j != x && i != v && j != v)           cout << i <<     << j <<   n , m--;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 6;   struct Edge {     int next, en;   } edge[maxn];   int head[maxn], cnt;   void init() {     memset(head, -1, sizeof(head));     cnt = 0;   }   void add(int x, int y) {     edge[cnt].en = y;     edge[cnt].next = head[x];     head[x] = cnt++;   }   int ans[maxn], siz[maxn], fa[maxn], maxsiz[maxn];   void dfs(int x) {     siz[x] = maxsiz[x] = 1;     ans[x] = x;     for (int i = head[x]; i + 1; i = edge[i].next) {       int v = edge[i].en;       fa[v] = x;       dfs(v);       siz[x] += siz[v];       maxsiz[x] = max(maxsiz[x], siz[v]);     }     for (int i = head[x]; i + 1; i = edge[i].next) {       int v = edge[i].en;       int p = ans[v];       while (p != x) {         if (maxsiz[p] * 2 <= siz[x] && (siz[x] - siz[p]) * 2 <= siz[x]) {           ans[x] = p;           break;         }         p = fa[p];       }     }   }   int main() {     int n, q, d;     scanf( %d%d , &n, &q);     init();     for (int i = 2; i <= n; i++) {       scanf( %d , &d);       add(d, i);     }     dfs(1);     while (q--) {       scanf( %d , &d);       printf( %d n , ans[d]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 152;   const int MAX2 = 11300;   const int INF = 1e9 + 10;   int a[MAX];   int r[MAX][MAX2];   int t[MAX][MAX2];   int main() {     int n, k, s;     cin >> n >> k >> s;     s = min(s, MAX2 - 1);     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 0; i <= n; i++) {       for (int p = 1; p <= s; p++) {         r[i][p] = INF;       }     }     for (int q = 1; q <= k; q++) {       for (int i = 0; i <= n; i++) {         for (int p = 0; p <= s; p++) {           t[i][p] = INF;         }       }       for (int i = q; i <= n; i++) {         for (int p = 0; p <= s; p++) {           if (p >= i - q)             t[i][p] = min(r[i - 1][p - (i - q)] + a[i], t[i - 1][p]);           else             t[i][p] = t[i - 1][p];         }       }       for (int i = 0; i <= n; i++) {         for (int p = 0; p <= s; p++) {           r[i][p] = t[i][p];         }       }     }     int res = INF;     for (int p = 0; p <= s; p++) {       res = min(res, r[n][p]);     }     cout << res <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   char s[1000010];   bool f[1000010];   int main() {     int i, l, ans = 0, ans2 = 0, j, sta;     scanf( %s , &s);     l = strlen(s);     sta = 0;     while (s[sta] == s[(sta + 1) % l]) {       sta = (sta + 1) % l;     }     ++sta;     memset(f, false, sizeof(bool) * l);     i = sta;     while (!f[i]) {       f[i] = true;       i = (i + l - 1) % l;       while (s[(i + l - 1) % l] == s[i]) {         f[i] = true;         i = (i + l - 1) % l;       }       f[i] = true;       i = (i + l - 1) % l;       ++ans;     }     memset(f, false, sizeof(bool) * l);     i = sta;     while (!f[i]) {       f[i] = true;       while (s[(i + 1) % l] == s[i]) {         i = (i + 1) % l;         f[i] = true;       }       f[(i + 1) % l] = true;       i = (i + 2) % l;       ++ans2;     }     printf( %d n , ans < ans2 ? ans : ans2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = (int)1e9 + 7;   const int N_ = (int)2e6 + 2;   long long n;   char a[N_], b[N_];   double res;   long long T;   int main() {     scanf( %lld , &n);     scanf( %s , a + 1);     scanf( %s , b + 1);     for (char cur =  A ; cur <=  Z ; cur++) {       long long S = 0;       for (int i = 1; i <= n; i++) {         if (a[i] == cur) S += i;         if (b[i] == cur) res += S * (n - i + 1);       }       S = 0;       for (int i = 0; i <= n; i++) {         if (a[i] == cur) res += S * (n - i + 1);         if (b[i] == cur) S += i;       }     }     for (int i = 1; i <= n; i++) T += (n - i + 1) * (n - i + 1);     printf( %.9lf , res / T);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct pnt {     int x, y;   };   struct pr {     int d, q;     pr() {}     pr(int d, int q) : d(d), q(q) {}     friend bool operator<(pr a, pr b) {       if (a.d != b.d) return a.d < b.d;       return a.q < b.q;     }   };   const int N = 200000 + 20;   bool ok[N];   int t[4 * N];   void build(int v, int tl, int tr) {     if (tl == tr) {       t[v] = -1;       return;     }     int tm = (tl + tr) / 2;     build(2 * v, tl, tm);     build(2 * v + 1, tm + 1, tr);     t[v] = -1;   }   void upd(int v, int tl, int tr, int wh, int vl) {     while (tl < tr) {       int tm = (tl + tr) / 2;       if (wh <= tm) {         tr = tm;         v = 2 * v;       } else {         tl = tm + 1;         v = 2 * v + 1;       }     }     t[v] = vl;     v /= 2;     while (v >= 1) {       t[v] = min(t[2 * v], t[2 * v + 1]);       v >>= 1;     }   }   const int INF = 1e9 + 7;   int mn(int v, int tl, int tr, int l, int r) {     if (l > r) return INF;     if (tl == l && r == tr) return t[v];     int tm = (tl + tr) / 2;     return min(mn(2 * v, tl, tm, l, min(tm, r)),                mn(2 * v + 1, tm + 1, tr, max(tm + 1, l), r));   }   int main() {     int n, m, k, q;     scanf( %d %d %d %d , &n, &m, &k, &q);     swap(n, m);     vector<pnt> lad(k);     for (int i = 0; i < k; ++i) {       scanf( %d %d , &lad[i].x, &lad[i].y);       --lad[i].x;       --lad[i].y;     }     vector<pr> r(q), d(q);     vector<int> x1(q), x2(q), y1(q), y2(q);     for (int i = 0; i < q; ++i) {       scanf( %d %d %d %d , &x1[i], &y1[i], &x2[i], &y2[i]);       --y1[i];       --y2[i];       --x1[i];       --x2[i];       r[i].d = x2[i];       r[i].q = i;       d[i].d = y2[i];       d[i].q = i;     }     for (int i = 0; i < k; ++i) {       r.push_back(pr(lad[i].x, -i - 1));       d.push_back(pr(lad[i].y, -i - 1));     }     sort(r.begin(), r.end());     sort(d.begin(), d.end());     build(1, 0, n - 1);     for (int i = 0; i < r.size(); ++i) {       if (r[i].q < 0)         upd(1, 0, n - 1, lad[-r[i].q - 1].y, r[i].d);       else {         int t = mn(1, 0, n - 1, y1[r[i].q], y2[r[i].q]);         if (t >= x1[r[i].q]) ok[r[i].q] = true;       }     }     build(1, 0, m - 1);     for (int i = 0; i < d.size(); ++i) {       if (d[i].q < 0)         upd(1, 0, m - 1, lad[-d[i].q - 1].x, d[i].d);       else {         int t = mn(1, 0, m - 1, x1[d[i].q], x2[d[i].q]);         if (t >= y1[d[i].q]) ok[d[i].q] = true;       }     }     for (int i = 0; i < q; ++i) printf((ok[i] ?  YES n  :  NO n ));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s[1001], d[1001], i, a, S;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> s[i] >> d[i];     }     S = s[1];     for (i = 2; i <= n; i++) {       if (s[i] <= S) {         int x = ((S - s[i]) / d[i]) + 1;         S = s[i] + d[i] * x;       } else         S = s[i];     }     cout << S;   }
#include <bits/stdc++.h>   using namespace std;   void boost() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   const int N = 1e6;   const long long inf = 1e9;   int n;   vector<string> s;   string ans, cur;   vector<int> g[200];   bool was[N];   map<string, bool> wass;   void dfs(int v) {     was[v] = 1;     bool flag = 0;     bool flag2 = ((int)cur.find(s[v]) > -1);     if (!flag2) {       for (int i = s[v].size(); i > 0; i--) {         string t1 = s[v].substr(0, i);         string t2 = s[v].substr(i, s[v].size() - i);         if ((int)cur.find(t1) > -1) {           cur += t2;           flag = 1;           break;         }       }     }     if (!flag && !flag2) {       for (int i = 1; i <= s[v].size(); i++) {         string t1 = s[v].substr(0, i);         string t2 = s[v].substr(i, s[v].size() - i);         if ((int)cur.find(t2) > -1) {           cur = t1 + cur;           break;         }       }     }     for (int i = 0; i < g[v].size(); i++) {       if (!was[g[v][i]]) {         dfs(g[v][i]);       }     }   }   bool cmp(string a, string b) { return a.size() > b.size(); }   int main() {     boost();     cin >> n;     s.push_back( 0 );     for (int i = 1; i <= n; i++) {       string x;       cin >> x;       if (!wass.count(x)) {         s.push_back(x);       }       wass[x] = 1;     }     n = s.size() - 1;     sort(s.begin() + 1, s.end(), cmp);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i != j) {           for (int k = 0; k < s[j].size(); k++) {             if ((int)s[i].find(s[j][k]) > -1) {               g[i].push_back(j);               g[j].push_back(i);               break;             }           }         }       }     }     for (int i = 1; i <= n; i++) {       if (!was[i]) {         cur =   ;         dfs(i);         ans += cur;       }     }     for (int i = 0; i < ans.size(); i++) {       for (int j = 0; j < ans.size(); j++) {         if (ans[i] == ans[j] && i != j) {           cout << i <<     << j << endl;         }       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5;   const int inf = 1e9 + 7;   long long n, m, k, w;   long long dp1[maxn];   long long dp2[maxn];   int d1[maxn];   int d2[maxn];   long long a, b;   inline int low_bit(int x) { return x & (-x); }   inline void upd1(int p, int x) {     while (p <= n) {       dp1[p] += x;       p += low_bit(p);     }     return;   }   inline void upd2(int p, int x) {     while (p <= n) {       dp2[p] += x;       p += low_bit(p);     }     return;   }   inline int query1(int p) {     int sum = 0;     while (p > 0) {       sum += dp1[p];       p -= low_bit(p);     }     return sum;   }   inline int query2(int p) {     int sum = 0;     while (p > 0) {       sum += dp2[p];       p -= low_bit(p);     }     return sum;   }   inline int query(int p) {     return query1(p - 1) + query2(n) - query2(p + k - 1);   }   int main() {     long long ans = 0;     cin >> n >> k >> a >> b >> m;     for (int i = 1; i <= m; i++) {       int op;       scanf( %d , &op);       if (op == 1) {         int x, y;         scanf( %d%d , &x, &y);         int p1 = d1[x];         int p2 = d2[x];         int to1 = 0, to2 = 0;         to1 = b - p1;         to2 = a - p2;         upd1(x, y > to1 ? to1 : y);         upd2(x, y > to2 ? to2 : y);         d1[x] += y > to1 ? to1 : y;         d2[x] += y > to2 ? to2 : y;       } else {         int x;         scanf( %d , &x);         cout << query(x) << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 305;   int a[maxn][maxn], b[maxn][maxn];   int main(int argc, char const *argv[]) {     int t;     scanf( %d , &t);     while (t--) {       int n, m;       scanf( %d %d , &n, &m);       for (int i = 1; i <= n; ++i) {         for (int j = 1; j <= m; ++j) {           scanf( %d , &a[i][j]);         }       }       bool good = 1;       b[1][1] = b[1][m] = b[n][1] = b[n][m] = 2;       if (a[1][1] > 2 or a[1][m] > 2 or a[n][1] > 2 or a[n][m] > 2) {         printf( NO n );         continue;       }       for (int i = 2; i < m; ++i) {         if (a[1][i] > 3 or a[n][i] > 3) {           good = 0;         }         b[1][i] = b[n][i] = 3;       }       for (int i = 2; i < n; ++i) {         if (a[i][1] > 3 or a[i][m] > 3) {           good = 0;         }         b[i][1] = b[i][m] = 3;       }       if (!good) {         printf( NO n );         continue;       }       for (int i = 2; i < n; ++i) {         for (int j = 2; j < m; ++j) {           if (a[i][j] > 4) {             good = 0;           }           b[i][j] = 4;         }       }       if (!good) {         printf( NO n );       } else {         printf( YES n );         for (int i = 1; i <= n; ++i) {           for (int j = 1; j <= m; ++j) {             printf( %d  , b[i][j]);           }           printf(  n );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void JIZZ(string output =   ) {     cout << output;     exit(0);   }   const long double PI = 3.14159265358979323846264338327950288;   const long double eps = 1e-10;   const long long mod = 1e9 + 7;   void solve() {     string s, t;     cin >> s >> t;     for (int st = 0; st < (int)s.size(); ++st) {       string cur;       for (int ri = st; ri < (int)s.size(); ++ri) {         cur += s[ri];         if (cur == t) {           cout <<  YES  << endl;           return;         }         string cc = cur;         for (int i = ri - 1; i >= 0 && cur.size() < t.size(); --i) {           cc += s[i];           if (cc.size() == t.size()) {             if (cc == t) {               cout <<  YES  << endl;               return;             }             break;           }         }       }     }     cout <<  NO  <<   n ;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   const int mod = 1000000007;   long long fastpow(long long a, long long b) {     if (b == 0)       return 1;     else if (b % 2 == 0)       return fastpow(a * a, b / 2);     else if (b % 2 != 0)       return a * fastpow(a * a, (b - 1) / 2);   }   const long long inf = 2e18;   signed main() {     long long k;     cin >> k;     long long x = 0;     long long i;     for (i = 5; i <= k; i++) {       if (k % i == 0) {         if (i >= 5 && k / i >= 5) {           x++;           break;         }       }     }     if (x == 0) {       cout <<  -1  <<   n ;       return 0;     }     long long n = i;     long long m = k / i;     char A[n][m];     for (long long i = 0; i < m; i++) {       for (long long j = 0; j < n; j++) A[j][i] =  g ;     }     A[0][0] =  a , A[1][0] =  e , A[2][0] =  i , A[3][0] =  o , A[4][0] =  u ;     A[0][1] =  u , A[1][1] =  a , A[2][1] =  e , A[3][1] =  i , A[4][1] =  o ;     A[0][2] =  o , A[1][2] =  u , A[2][2] =  a , A[3][2] =  e , A[4][2] =  i ;     A[0][3] =  i , A[1][3] =  o , A[2][3] =  u , A[3][3] =  a , A[4][3] =  e ;     A[0][4] =  e , A[1][4] =  i , A[2][4] =  o , A[3][4] =  u , A[4][4] =  a ;     for (long long i = 5; i < n; i++) {       A[i][0] =  a , A[i][1] =  e , A[i][2] =  i , A[i][3] =  o , A[i][4] =  u ;     }     for (long long i = 5; i < m; i++) {       A[0][i] =  a , A[1][i] =  e , A[2][i] =  i , A[3][i] =  o , A[4][i] =  u ;     }     for (long long i = 0; i < m; i++) {       for (long long j = 0; j < n; j++) cout << A[j][i];     }     return 0;   }
#include <bits/stdc++.h>   char map[55][55];   int cov[55][55];   int fx[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};   int ok, sx, sy;   int steps[55][55];   int n, m;   int in(int x, int y) {     if (x >= 1 && x <= n && y >= 1 && y <= m) return 1;     return 0;   }   void dfs(int x, int y, int step) {     steps[x][y] = step;     if (ok) return;     for (int i = 0; i < 4; i++) {       int xx = x + fx[i][0];       int yy = y + fx[i][1];       if (in(xx, yy) && map[xx][yy] == map[sx][sy]) {         if (cov[xx][yy]) {           if (step - steps[xx][yy] >= 3) {             ok = 1;             return;           }           continue;         }         cov[xx][yy] = 1;         dfs(xx, yy, step + 1);       }     }   }   int main() {     while (~scanf( %d%d , &n, &m)) {       for (int i = 1; i <= n; i++) {         scanf( %s , map[i] + 1);       }       ok = 0;       memset(cov, 0, sizeof(cov));       memset(steps, 0, sizeof(steps));       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++) {           if (cov[i][j]) continue;           ok = 0;           sx = i;           sy = j;           steps[i][j] = 1;           cov[i][j] = 1;           dfs(i, j, 1);           if (ok) break;         }         if (ok) break;       }       if (ok)         printf( Yes n );       else         printf( No n );     }     return 0;   }