malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n;   int cnt = 0;   void rec(vector<bool> mask, int i, int ops) {     if (cnt == n) return;     if (i == n) {       for (int j = 0; j < n; j++) cout << char( (  + mask[j]);       for (int j = 0; j < n; j++) {         if (ops > 0) {           cout <<  ) ;           ops--;         } else {           cout <<  ( ;           ops++;         }       }       cout << endl;       cnt++;     } else {       mask[i] = 0;       rec(mask, i + 1, ops + 1);       if (ops > 0) {         mask[i] = 1;         rec(mask, i + 1, ops - 1);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int T;     cin >> T;     while (T--) {       cin >> n;       cnt = 0;       vector<bool> t(n, 0);       rec(t, 0, 0);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (int)1e4 + 22;   int n, m;   void solve() {     int l, r;     cin >> n >> m;     int val = INT_MAX;     for (int i = 0; i < m; i++) {       cin >> l >> r;       val = min(val, r - l + 1);     }     cout << val <<   n ;     for (int i = 0; i < n; i++) cout << i % val <<    ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> x;   int modulo_sum(int a, int b) {     return ((a % 1000000007) + (b % 1000000007)) % 1000000007;   }   int modulo_subtract(int a, int b) {     return ((a % 1000000007) - (b % 1000000007)) % 1000000007;   }   int modulo_mult(int a, int b) { return ((long long)a * b) % 1000000007; }   int power(int n) {     int ini = 2;     int ret = 1;     while (n >= 1) {       if (n % 2 == 1) ret = modulo_mult(ret, ini);       ini = modulo_mult(ini, ini);       n /= 2;     }     return ret;   }   int powerr[300005];   int main() {     int n;     cin >> n;     powerr[0] = 1;     for (int i = 1; i <= n; i++) {       powerr[i] = modulo_sum(powerr[i - 1], powerr[i - 1]);       int apl;       cin >> apl;       x.push_back(apl);     }     x.push_back(0);     sort(x.begin(), x.end());     int ans = 0;     for (int i = 1; i <= n; i++) {       ans = modulo_sum(           ans,           modulo_mult(modulo_sum(powerr[i - 1], (-1) * powerr[n - i]), x[i]));     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     for (int i = n + 1; i <= m; i++) {       int count = 0;       for (int j = 2; j < i; j++) {         if (i % j == 0) count++;       }       if (count == 0) {         if (m == i) {           cout <<  YES  << endl;           return 0;         } else           break;       }     }     cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, S, top, pos[2005], id[2005];   struct point {     long long x, y;   } a[2005];   struct line {     long long x, y;     double k;   } b[4000005];   inline bool cmp1(point A, point B) {     return A.x != B.x ? A.x < B.x : A.y < B.y;   }   inline bool cmp2(line A, line B) { return A.k < B.k; }   inline long long cross(point A, point B) {     return abs((A.x * B.y) - (B.x * A.y));   }   inline point operator-(point A, point B) {     return (point){A.x - B.x, A.y - B.y};   }   inline long long getS(point A, point B, point C) {     return abs(cross(B - A, C - A));   }   inline long long read() {     long long ret = 0, ff = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) ff = -1;       ch = getchar();     }     while (isdigit(ch)) {       ret = (ret << 3) + (ret << 1) + (ch ^ 48);       ch = getchar();     }     return ret * ff;   }   signed main() {     n = read();     S = read() * 2;     for (long long i = 1; i <= n; i++) {       a[i].x = read();       a[i].y = read();       pos[i] = id[i] = i;     }     sort(a + 1, a + n + 1, cmp1);     for (long long i = 1; i <= n; i++)       for (long long j = i + 1; j <= n; j++)         b[++top] =             (line){i, j, atan2((double)(a[j] - a[i]).y, (double)(a[j] - a[i]).x)};     sort(b + 1, b + top + 1, cmp2);     for (long long i = 1; i <= top; i++) {       long long x = b[i].x, y = b[i].y;       if (pos[x] > pos[y]) swap(x, y);       long long l, r, t;       l = 1, r = pos[x] - 1;       while (l <= r) {         long long mid = (l + r) >> 1;         if (getS(a[id[mid]], a[x], a[y]) >= S)           l = mid + 1, t = mid;         else           r = mid - 1;       }       if (getS(a[id[t]], a[x], a[y]) == S) {         puts( Yes );         printf( %lld %lld n , a[id[t]].x, a[id[t]].y);         printf( %lld %lld n , a[x].x, a[x].y);         printf( %lld %lld n , a[y].x, a[y].y);         return 0;       }       l = pos[y] + 1, r = n;       while (l <= r) {         long long mid = (l + r) >> 1;         if (getS(a[id[mid]], a[x], a[y]) >= S)           r = mid - 1, t = mid;         else           l = mid + 1;       }       if (getS(a[id[t]], a[x], a[y]) == S) {         puts( Yes );         printf( %lld %lld n , a[id[t]].x, a[id[t]].y);         printf( %lld %lld n , a[x].x, a[x].y);         printf( %lld %lld n , a[y].x, a[y].y);         return 0;       }       swap(pos[x], pos[y]);       swap(id[pos[x]], id[pos[y]]);     }     printf( No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e6;   int a[maxn], ans;   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     while (n--) {       int tmp;       cin >> tmp;       a[tmp]++;     }     for (int i = 0; i < maxn; i++) {       a[i + 1] += a[i] / 2;       ans += a[i] % 2;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, S[2];   int num[1505][1505][2];   bool s[1505][1505];   int p[4][2] = {0, -1, 1, 0, 0, 1, -1, 0};   void dfs(int x, int y) {     if (num[x % n][y % m][0] == -1 && num[x % n][y % m][1] == -1) {       num[x % n][y % m][0] = x;       num[x % n][y % m][1] = y;     } else if (num[x % n][y % m][0] != x || num[x % n][y % m][1] != y) {       printf( Yes n );       exit(0);     } else       return;     for (int i = 0; i < 4; i++) {       if (s[(x + p[i][0]) % n][(y + p[i][1]) % m]) dfs(x + p[i][0], y + p[i][1]);     }   }   int main() {     scanf( %d %d , &n, &m);     char ch;     getchar();     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         ch = getchar();         if (ch ==  . ) s[i][j] = true;         if (ch ==  S ) {           s[i][j] = true;           S[0] = i + n * m;           S[1] = j + n * m;         }       }       getchar();     }     memset(num, -1, sizeof(num));     dfs(S[0], S[1]);     printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100100, SQRT = 320, MAXM = 13;   int N, M, Q;   pair<int, int> up[MAXN][MAXM];   pair<int, int> jump[MAXN][MAXM];   char grid[MAXN][MAXM];   bool bounded(int x, int y) { return 1 <= x && x <= N && 1 <= y && y <= M; }   bool bounded(pair<int, int> p) { return bounded(p.first, p.second); }   pair<int, int> getup(int x, int y) {     pair<int, int> &ref = up[x][y];     if (ref.first != -2) {       return ref;     }     if (!bounded(x, y)) {       return ref = pair<int, int>(x, y);     }     if (grid[x][y] ==  ^ ) {       return ref = pair<int, int>(x - 1, y);     } else if (grid[x][y] ==  < ) {       return ref = (grid[x][y - 1] ==  >  ? pair<int, int>(-1, -1)                                           : getup(x, y - 1));     } else {       return ref = (grid[x][y + 1] ==  <  ? pair<int, int>(-1, -1)                                           : getup(x, y + 1));     }   }   void calcjump(int i) {     if (i % SQRT == 1) {       copy_n(up[i] + 1, M, jump[i] + 1);     } else {       for (int j = 1; j <= M; j++) {         pair<int, int> p = up[i][j];         jump[i][j] = bounded(p) ? jump[p.first][p.second] : p;       }     }   }   int main() {     if (fopen( input.txt ,  r )) {       freopen( input.txt ,  r , stdin);     }     ios_base::sync_with_stdio(false);     scanf( %d %d %d n , &N, &M, &Q);     for (int i = 1; i <= N; i++) {       gets(grid[i] + 1);       fill_n(up[i], M + 2, pair<int, int>(-2, -2));     }     for (int i = 0; i <= N; i++) {       for (int j = 0; j <= M + 1; j++) {         getup(i, j);       }     }     for (int i = 1; i <= N; i++) {       calcjump(i);     }     char ch;     for (int x, y; Q--;) {       scanf( %c %d %d , &ch, &x, &y);       if (ch ==  A ) {         pair<int, int> p(x, y);         while (bounded(p)) {           p = jump[p.first][p.second];         }         printf( %d %d n , p.first, p.second);       } else {         scanf(  %c , &ch);         grid[x][y] = ch;         fill_n(up[x] + 1, M, pair<int, int>(-2, -2));         for (int j = 1; j <= M; j++) {           getup(x, j);         }         for (calcjump(x++); x <= N && x % SQRT != 1; x++) {           calcjump(x);         }       }       getchar();     }   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int>> tree;   int res = 0;   int dfs(int node, int parent) {     int left = 2;     for (int child : tree[node]) {       if (child == parent) {         continue;       }       int x = dfs(child, node);       if (x == 1 && left > 0) {         ++res;         --left;       }     }     return left > 0;   }   int main() {     int n, x, y;     cin >> n >> x >> y;     vector<int> degs(n, 0);     tree.resize(n);     for (int i = 0; i < n - 1; ++i) {       int a, b;       cin >> a >> b;       --a;       --b;       tree[a].push_back(b);       tree[b].push_back(a);       ++degs[a];       ++degs[b];     }     if (x < y) {       dfs(0, -1);       cout << res * (long long)x + (n - res - 1) * (long long)y <<   n ;     } else {       if (*max_element(degs.begin(), degs.end()) == n - 1) {         cout << (long long)(n - 2) * y + x <<   n ;       } else {         cout << (long long)(n - 1) * y <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> a, b;   int f[100005];   int main() {     int n, tmp, i;     scanf( %d , &n);     a.clear();     b.clear();     for (i = 0; i < n; i++) {       scanf( %d , &tmp);       a.insert(make_pair(tmp, i));     }     for (i = 0; i < n; i++) {       scanf( %d , &tmp);       b.insert(make_pair(tmp, i));     }     for (i = 0; i < n; i++) f[b[i + 1]] = a[i + 1];     for (i = 0; i < n - 1; i++) printf( %d  , f[i] + 1);     printf( %d n , f[n - 1] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int64_t n;   vector<int64_t> adj[100001];   int64_t ss[100001];   void dfs(int64_t no, int64_t par = -1) {     ss[no] = 1;     for (auto j : adj[no]) {       if (j == par) {         continue;       }       dfs(j, no);       ss[no] += ss[j];     }   }   vector<int64_t> ord;   int64_t dfs2(int64_t no, int64_t par = -1) {     for (auto j : adj[no]) {       if (j == par) {         continue;       }       if (ss[j] > n / 2) {         return dfs2(j, no);       }     }     return no;   }   int64_t ans = 0;   void dfs3(int64_t no, int64_t par = -1, int64_t levv = 0) {     ord.push_back(no);     ans += levv * 2;     for (auto j : adj[no]) {       if (j == par) {         continue;       }       dfs3(j, no, levv + 1);     }   }   int64_t ans2[100001];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int64_t i = 0; i < n - 1; i++) {       int64_t aa, bb;       cin >> aa >> bb;       aa--;       bb--;       adj[aa].push_back(bb);       adj[bb].push_back(aa);     }     dfs(0);     int64_t cen = dfs2(0);     dfs3(cen);     for (int64_t i = 0; i < n; i++) {       ord.push_back(ord[i]);     }     int64_t x = (n / 2);     cout << ans << endl;     for (int64_t i = 0; i < n; i++) {       ans2[ord[i]] = ord[i + x] + 1;     }     for (int64_t i = 0; i < n; i++) {       cout << ans2[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 400005;   multiset<int> S;   int x, y, n, m, k;   map<pair<int, int>, int> flag;   struct Tree {     int l, r, num, flag;   } T[N * 4];   void build(int x, int l, int r) {     T[x].l = l;     T[x].r = r;     if (l == r) {       T[x].num = l - 1;       return;     }     int mid = (l + r) / 2;     build(x * 2, l, mid);     build(x * 2 + 1, mid + 1, r);     T[x].num = max(T[x * 2].num, T[x * 2 + 1].num);   }   void down(int x) {     T[x * 2].num += T[x].flag;     T[x * 2 + 1].num += T[x].flag;     T[x * 2].flag += T[x].flag;     T[x * 2 + 1].flag += T[x].flag;     T[x].flag = 0;   }   void insert(int x, int l, int r, int z) {     if (T[x].l > r || l > T[x].r) return;     if (T[x].l >= l && T[x].r <= r) {       T[x].num += z;       T[x].flag += z;       return;     }     down(x);     insert(x * 2, l, r, z);     insert(x * 2 + 1, l, r, z);     T[x].num = max(T[x * 2].num, T[x * 2 + 1].num);   }   int find(int x, int l, int r) {     if (T[x].l > r || l > T[x].r) return 0;     if (T[x].l >= l && T[x].r <= r) return T[x].num;     down(x);     return max(find(x * 2, l, r), find(x * 2 + 1, l, r));   }   int main() {     scanf( %d%d%d , &n, &k, &m);     build(1, 1, n + n);     S.insert(n + 1);     while (m--) {       scanf( %d%d , &x, &y);       if (flag[make_pair(x, y)]) {         S.erase(S.find(y + abs(x - k)));         flag[make_pair(x, y)] = 0;         insert(1, 1, y + abs(x - k), -1);       } else {         S.insert(y + abs(x - k));         flag[make_pair(x, y)] = 1;         insert(1, 1, y + abs(x - k), 1);       }       printf( %d n , find(1, 1, *S.rbegin()) - n);     }   }
#include <bits/stdc++.h>   int main(int argc, const char* argv[]) {     int n, k;     int a[100000 + 1];     scanf( %d%d , &n, &k);     int i;     int count = 0;     int is_ukn = scanf( %d , a) != 1;     for (i = !is_ukn; i <= n; i++)       scanf( %d , a + i) != 1 && getchar() && count++;     int is_man_move = (n + 1 - count) & 1;     int is_man_end = n & 1;     if (k == 0) {       puts((is_ukn && is_man_move) || (!is_ukn && a[0] == 0) ?  Yes  :  No );       return 0;     }     int some_ukn = is_ukn || count;     if (some_ukn) {       puts(is_man_end ?  Yes  :  No );       return 0;     }     int sum2 = 0;     for (i = 0; i <= n && sum2 % k == 0; i++) {       sum2 /= k;       sum2 += a[i];     }     if (i == n + 1) {       if (k != 1 && k != -1)         while (sum2 != 0 && sum2 % k == 0) sum2 /= k;       if (sum2 == 0) {         puts( Yes );         return 0;       }     }     puts( No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   inline int f(int a) {     int n1 = n;     bool y = 0;     while (n1 != 0) {       int h = a;       int u = n1 % 10;       n1 = n1 / 10;       while (h != 0) {         int j = h % 10;         h = h / 10;         if (u == j) {           y = 1;           break;         }       }     }     return y;   }   int main() {     cin >> n;     int ans = 0;     for (int i = 1; i * i <= n; i++) {       if (n % i == 0) {         int i2 = n / i;         if (f(i) == 1) ans++;         if (f(i2) == 1 && i2 != i) ans++;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, d = 1;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m;     while (n > d) {       for (int i = 1; i < (m + 1); i++) {         cout << d <<     << i <<   n ;         cout << n <<     << m + 1 - i <<   n ;       }       n--;       d++;     }     if (n == d) {       for (int i = 0; i < (m / 2); i++) {         cout << d <<     << 1 + i <<   n ;         cout << d <<     << m - i <<   n ;       }       if (m & 1) cout << d <<     << (m + 1) / 2 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int MOD = 1e9 + 7;   const int INF = 0x3f3f3f3f;   pair<long long, long long> ans1[N], ans2[N];   long long x;   long long cal(long long n) {     n--;     long long tmp = n * (n + 1) * (2 * n + 1) / 6;     n++;     tmp -= (n * n * n - n * n) / 2;     if (2 * (x - tmp) % (n * n + n)) return -1;     long long m = 2 * (x - tmp) / (n * n + n);     return m;   }   void solve() {     int cnt = 0, tot = 0;     for (int i = 1; i < 1500000; i++) {       long long m = cal((long long)i);       if (m == -1) continue;       if (m < i) break;       ans1[tot++] = make_pair(i, m);       if (m == i) break;       ans2[cnt++] = make_pair(m, i);     }     printf( %d n , tot + cnt);     for (int i = 0; i < tot; i++)       printf( %I64d %I64d n , ans1[i].first, ans1[i].second);     for (int i = cnt - 1; i >= 0; i--)       printf( %I64d %I64d n , ans2[i].first, ans2[i].second);   }   int main() {     scanf( %I64d , &x);     solve();     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, m;     int left, right;     int i;     int count = 0;     scanf( %d %d , &n, &m);     while (n--) {       for (i = 0; i < m; i++) {         scanf( %d %d , &left, &right);         if (left == 1 || right == 1) {           count++;         }       }     }     printf( %d n , count);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n == 1) {       cout << 0 << endl;       return 0;     }     if (n == 2) {       cout << 3 << endl;       return 0;     }     long long a, b, c;     a = 0;     b = 3;     c = 6;     for (int i = 3; i <= n; i++) {       c = ((a * 3) % 1000000007 + (b * 2) % 1000000007) % 1000000007;       a = b;       b = c;     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char str1[50], str2[50];     int n, c, k, cnt, flag;     cin >> n;     while (n--) {       flag = cnt = 0;       cin >> str1;       k = strlen(str1);       str1[k] =  : ;       str1[k + 1] =   0 ;       for (int i = 0; i <= k; ++i) {         if (str1[i] !=  : )           flag = 1;         else if (flag == 1) {           cnt++;           flag = 0;         }       }       for (int i = 0; i <= 38; ++i) {         if (i == 4 || i == 9 || i == 14 || i == 19 || i == 24 || i == 29 ||             i == 34)           str2[i] =  : ;         else           str2[i] =  0 ;       }       c = 0;       int j = 38;       for (int i = k - 1; i >= 0; i--) {         if (str1[i] !=  : ) {           c++;           str2[j--] = str1[i];         }         if (str1[i] ==  : ) {           if (c == 4) j--;           if (c == 3) j -= 2;           if (c == 2) j -= 3;           if (c == 1) j -= 4;           c = 0;         }         if (str1[i] ==  :  && str1[i - 1] ==  : ) {           j -= (8 - cnt) * 5;           i--;         }       }       for (int i = 0; i <= 37; ++i) cout << str2[i];       cout << str2[38] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   struct P {     int t, id;     bool operator<(const P &tmp) const {       if (t != tmp.t) return t < tmp.t;       return id < tmp.id;     }   } p[N];   priority_queue<int, vector<int>, greater<int> > qu;   queue<int> q;   set<int> s;   long long ans[N];   int n, t;   long long now = 0, ed = -1, nid = 0;   void gao() {     if (qu.empty()) return;     int x = qu.top();     if (!s.empty() && (*s.begin()) < x) return;     if (q.empty()) ed += t;     qu.pop();     q.push(x);     s.insert(x);   }   int main() {     scanf( %d%d , &n, &t);     for (int i = 0; i < n; i++) scanf( %d , &p[i].t), p[i].id = i;     sort(p, p + n);     while (true) {       if (nid < n && (ed >= p[nid].t || q.empty())) {         now = p[nid].t;         if (!s.empty() && (*s.begin()) < p[nid].id)           qu.push(p[nid].id);         else if (ed == p[nid].t)           qu.push(p[nid].id);         else {           if (q.empty()) ed = now + t;           q.push(p[nid].id);           s.insert(p[nid].id);         }         nid++;       } else if (!q.empty()) {         int x = q.front();         q.pop();         now = max(now, ed);         s.erase(x);         ans[x] = ed;         if (!q.empty()) ed += t;         gao();       } else         break;     }     for (int i = 0; i < n; i++) printf( %lld  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string b[1 << 15];   int x[100], y[100], n;   map<string, int> mp;   int main() {     scanf( %d , &n);     for (int i = 0, z; i < n; i++) {       scanf( %d , &z);       x[i] = z & ((1 << 15) - 1);       y[i] = z >> 15;     }     for (int B = 0; B < (1 << 15); B++) {       for (int i = 1, j = __builtin_popcount(B ^ y[0]); i < n; i++) {         b[B].push_back(__builtin_popcount(B ^ y[i]) - j);       }       if (!mp.count(b[B])) mp[b[B]] = B;     }     for (int B = 0; B < 1 << 15; B++) {       string tmp;       for (int i = 1, j = __builtin_popcount(B ^ x[0]); i < n; i++) {         tmp.push_back(j - __builtin_popcount(B ^ x[i]));       }       if (mp.count(tmp)) {         printf( %d n , B + (mp[tmp] << 15));         return 0;       }     }     puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int ni() {     int a;     scanf( %d , &a);     return a;   }   const int max_n = 5000;   char s1[max_n + 1], s2[max_n + 1], res[max_n + 1];   int digits[26], minuses[26];   bool check(int from, int code, int n, int m) {     bool ok = true, founded = false;     digits[code]--;     memset(minuses, 0, sizeof(minuses));     for (int i = from; i < m; i++) {       int next = -1, need = s2[i] -  a ;       for (int j = 25; j >= 0; j--) {         if (j >= need && digits[j] > 0) {           next = j;           break;         }       }       if (next == -1) {         ok = false;         break;       } else if (next > need) {         founded = true;         break;       } else {         digits[next]--;         minuses[next]++;       }     }     for (int i = 0; i < int(26); i++) digits[i] += minuses[i];     digits[code]++;     if (n <= m && !founded) ok = false;     return ok;   }   int main() {     scanf( %s , s1);     scanf( %s , s2);     int n = strlen(s1), m = strlen(s2);     bool found = true, before = false;     for (int i = 0; i < int(n); i++) digits[s1[i] -  a ]++;     for (int i = 0; i < int(n); i++) {       if (i >= m || before) {         int code = -1;         for (int j = 0; j < int(26); j++) {           if (digits[j] > 0) {             code = j;             break;           }         }         res[i] =  a  + code;         digits[code]--;       } else {         int same = s2[i] -  a , next = -1;         for (int j = 0; j < int(26); j++) {           if (j > same && digits[j] > 0) {             next = j;             break;           }         }         if (digits[same] > 0 && check(i + 1, same, n, m)) {           digits[same]--;           res[i] =  a  + same;         } else if (next != -1) {           digits[next]--;           res[i] =  a  + next;           before = true;         } else {           found = false;           break;         }       }     }     if (found) {       res[n] =   0 ;       printf( %s n , res);     } else {       printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int intersection = n * m;     int turn = 0;     while (n > 1 && m > 1) {       intersection -= (n + m - 1);       n--;       m--;       turn++;     }     if (n == 1 && m == 1 && turn % 2 == 0) {       cout <<  Akshat  << endl;     } else if (n == 1 && m == 1 && turn % 2 != 0) {       cout <<  Malvika  << endl;     } else if ((n != 1 || m != 1) && turn % 2 == 0) {       cout <<  Akshat  << endl;     } else {       cout <<  Malvika  << endl;     }     return 0;   }