malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int v[6][4];     for (int i = 0; i < 6; i++) {       for (int j = 0; j < 4; j++) cin >> v[i][j];     }     int cnt1 = 0, cnt2 = 0, cnt3 = 0;     for (int i = 0; i < 3; i++)       if (v[0][i] == v[0][i + 1] && v[2][i] == v[2][i + 1]) cnt1++;     for (int i = 0; i < 3; i++)       if (v[1][i] == v[1][i + 1] && v[5][i] == v[5][i + 1]) cnt2++;     for (int i = 0; i < 3; i++)       if (v[3][i] == v[3][i + 1] && v[4][i] == v[4][i + 1]) cnt3++;     vector<int> a;     a.push_back(0);     for (int i = 0; i < 6; i++) {       for (int j = 0; j < 4; j++) a.push_back(v[i][j]);     }     if (cnt1 == 3 && cnt2 != 3 && cnt3 != 3) {       if (a[5] == a[6] && a[7] == a[8] && a[17] == a[18] && a[19] == a[20] &&           a[21] == a[22] && a[23] == a[24] && a[13] == a[14] && a[15] == a[16]) {         if (a[5] == a[15]) {           if (a[13] == a[23] && a[21] == a[19] && a[17] == a[7])             cout <<  YES ;           else             cout <<  NO ;         } else if (a[5] == a[19]) {           if (a[13] == a[7] && a[17] == a[23] && a[21] == a[15])             cout <<  YES ;           else             cout <<  NO ;         } else           cout <<  NO ;       } else         cout <<  NO ;     } else if (cnt1 != 3 && cnt2 == 3 && cnt3 != 3) {       if (a[1] == a[2] && a[3] == a[4] && a[18] == a[20] && a[17] == a[19] &&           a[11] == a[12] && a[9] == a[10] && a[15] == a[13] && a[16] == a[14]) {         if (a[1] == a[17]) {           if (a[18] == a[9] && a[11] == a[16] && a[15] == a[3])             cout <<  YES ;           else             cout <<  NO ;         } else if (a[1] == a[16]) {           if (a[18] == a[3] && a[11] == a[17] && a[15] == a[9])             cout <<  YES ;           else             cout <<  NO ;         } else           cout <<  NO ;       } else         cout <<  NO ;     } else if (cnt1 != 3 && cnt2 != 3 && cnt3 == 3) {       if (a[1] == a[3] && a[2] == a[4] && a[5] == a[7] && a[6] == a[8] &&           a[9] == a[11] && a[10] == a[12] && a[24] == a[22] && a[23] == a[21]) {         if (a[1] == a[6]) {           if (a[5] == a[10] && a[9] == a[23] && a[24] == a[2])             cout <<  YES ;           else             cout <<  NO ;         } else if (a[1] == a[23]) {           if (a[5] == a[2] && a[9] == a[6] && a[24] == a[10])             cout <<  YES ;           else             cout <<  NO ;         } else           cout <<  NO ;       } else         cout <<  NO ;     } else       cout <<  NO ;     return 0;   }
#include<bits/stdc++.h>   #define pb push_back   #define all(v) v.begin(),v.end()   #define allr(v) v.rbegin(),v.rend()   #define SORT(v) sort(all(v))   #define int long long   #define ff first   #define ss second   #define mod 1000000007      using namespace std;      void oj()   {     ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);     #ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);     #endif   }      void solve()   {     int n, k; cin>>n>>k;     vector<int>h(n);     vector<pair<int,int>>val;        for(int i = 0; i<n; i++)       cin>>h[i];        int mini = h[0];     int maxi = h[0] + k;        for(int i = 1; i<n - 1; i++){          if(h[i] + 2*k - 1 <= mini || h[i] >= maxi)       {         cout<< NO <<endl;          return;       }             maxi = min(maxi + k - 1LL, h[i] + 2 * k - 1LL);       mini = max(mini - k + 1LL, h[i] );        }        if(h[n-1] + k <= mini || h[n-1] >= maxi)     {       cout<< NO <<endl;         return;     }     cout<< YES <<endl;            }   signed main()   {     oj();     int t; cin>>t;     while(t--)       solve();        return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 2020;   vector<int> Gph[2][NMAX];   int N, A, B, K;   int st[2][NMAX], dr[2][NMAX], edges[2][NMAX];   int val[2][NMAX][NMAX];   int dp[NMAX / 2];   void dfs(int node) {     if (node != 1) edges[K][node] = 1;     for (int i = 0; i < Gph[K][node].size(); i++) {       int v = Gph[K][node][i];       dfs(v);       st[K][node] = min(st[K][node], st[K][v]);       dr[K][node] = max(dr[K][node], dr[K][v]);       edges[K][node] += edges[K][v];     }     val[K][st[K][node]][dr[K][node]] =         max(val[K][st[K][node]][dr[K][node]], edges[K][node]);   }   int main() {     scanf( %d%d , &N, &A);     int x;     K = 0;     st[K][1] = A + 1;     dr[K][1] = 0;     for (int i = 2; i <= A; i++) {       st[K][i] = A + 1;       dr[K][i] = 0;       scanf( %d , &x);       Gph[K][x].push_back(i);     }     for (int i = 1; i <= N; i++) {       scanf( %d , &x);       st[K][x] = dr[K][x] = i;     }     dfs(1);     scanf( %d , &B);     K = 1;     st[K][1] = B + 1;     dr[K][1] = 0;     for (int i = 2; i <= B; i++) {       st[K][i] = B + 1;       dr[K][i] = 0;       scanf( %d , &x);       Gph[K][x].push_back(i);     }     for (int i = 1; i <= N; i++) {       scanf( %d , &x);       st[K][x] = dr[K][x] = i;     }     dfs(1);     for (int i = 1; i <= N; i++)       for (int j = i; j <= N; j++)         dp[j] = max(dp[j], dp[i - 1] + max(val[0][i][j], val[1][i][j]));     printf( %d , dp[N]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long LIM = 1e18;   long long root(long long x) {     long long L = 0LL, R = 1e9 + 7;     while (L < R - 1) {       long long mid = (L + R) >> 1LL;       if (mid * mid <= x)         L = mid;       else         R = mid;     }     return L;   }   int main() {     set<long long> s;     for (long long i = 2; i <= 1e6; i++) {       for (long long j = i * i * i; j <= LIM; j *= i) {         long long val = sqrt(j);         if (val * val != j) s.insert(j);         if (j > LIM / i) break;       }     }     vector<long long> v(s.begin(), s.end());     int t;     scanf( %d , &t);     while (t--) {       long long L, R;       scanf( %lld %lld , &L, &R);       long long ans =           upper_bound(v.begin(), v.end(), R) - lower_bound(v.begin(), v.end(), L);       ans += root(R) - root(L - 1);       printf( %lld n , ans);     }     return 0;   }
#include <iostream>   #include <bits/stdc++.h>      using namespace std;      int main () {    int t;    cin >> t;    for (int k=0; k<t;k++){     int n;     cin >> n;     int a[n];     for (int i=0; i<n; i++){      cin >> a[i];     }     for (int j=n-1; j>=0; j--){      if(a[j]+j < n){       a[j] = a[j]+a[a[j]+j];      }     }     int max=0;     for (int i=0; i<n; i++){      if(a[i]>max){       max=a[i];      }     }     cout << max << endl;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ncr_2(long long n, long long k) {     if (k > n) return 0;     if (k * 2 > n) k = n - k;     if (k == 0) return 1;     long long result = n;     for (long long i = 2; i <= k; ++i) {       result = result * (n - i + 1);       result /= i;     }     return result;   }   long long pow(int x, unsigned int y, int p) {     int res = 1;     x = x % p;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long _pow(int a, int b) {     if (!b) return 1;     int temp = _pow(a, b / 2);     temp = (temp * temp);     if (b % 2) return (a * temp);     return temp;   }   int invmod(int a, int m) { return pow(a, m - 2, m); }   long long feelthepower(long long x, long long y) {     long long res = 1LL;     while (y) {       if (y & 1) {         res = (res * 1LL * x) % 1000000007;       }       x = (x * 1LL * x) % 1000000007;       y /= 2;     }     return res;   }   vector<int> Adj[100001], A;   int cnt = 0;   vector<bool> vis(100001, false);   void dfs(int s) {     if (vis[s]) return;     vis[s] = true;     A.push_back(s);     cnt++;     for (auto v : Adj[s]) {       if (!vis[v]) {         dfs(v);       }     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     ;     int tc = 1;     for (long long ti = 0; ti < tc; ti++) {       int n;       cin >> n;       vector<int> V(n);       map<int, int> mp;       for (long long i = 0; i < n; i++) {         cin >> V[i];         mp[V[i]] = i + 1;       }       vector<int> vec(V);       sort(vec.begin(), vec.end());       for (long long i = 0; i < n; i++) {         Adj[mp[vec[i]]].push_back(i + 1);         Adj[i + 1].push_back(mp[vec[i]]);       }       vector<int> Store[100001];       int j = 0, cnt1 = 0;       for (int i = 1; i <= n; i++) {         if (!vis[i]) {           cnt = 0;           dfs(i);           Store[j].push_back(cnt);           for (auto x : A) {             Store[j].push_back(x);           }           A.clear();           j++;         }       }       cout << j << endl;       for (long long i = 0; i < j; i++) {         for (long long k = 0; k < Store[i].size(); k++) {           cout << Store[i][k] <<    ;         }         cout << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;      typedef long long ll;   typedef pair<ll,ll> pi;   typedef vector <ll> vi;   typedef vector <pi> vpi;   typedef pair<pi,ll> pii;   typedef set <ll> si;   typedef long double ld;   #define f first   #define s second   #define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)   #define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)   #define pb push_back   #define all(x) (x).begin(), (x).end()   #define lbd(x, y) lower_bound(all(x), y)   #define ubd(x, y) upper_bound(all(x), y)   #define aFOR(i,x) for (auto i: x)   #define mem(x,i) memset(x,i,sizeof x)   #define fast ios_base::sync_with_stdio(false),cin.tie(0)      int N,Q,a,b;   string S,F;   struct node{    int s,e,m, val, lazy = 0, sz;    node *l,*r;    node (int ss,int ee){     s = ss; e = ee; m = (s+e) / 2; sz = e - s + 1;     if (s != e){      l = new node(s,m); r = new node(m+1,e);     }    }        void prop(){     if (lazy == 0 || s == e) return;     l->lazy = r->lazy = lazy;     l->val = lazy * l->sz; r->val = lazy * r->sz;     lazy = 0;    }        void upd(int a,int b,int c){     prop();     if (a <= s && e <= b){      lazy = c;      val = c * sz;     }else if (a > e || s > b) return;     else{      l->upd(a,b,c); r->upd(a,b,c);      val = l->val + r->val;     }    }        int qry(int a,int b){     prop();     if (a <= s && e <= b) return val;     else if (a > e || s > b) return 0;     else return l->qry(a,b) + r->qry(a,b);    }   }*root;      void solve(){    cin >> N >> Q >> S >> F;    swap(S,F);    root = new node(1,N);       FOR(i,0,N-1) root->upd(i + 1,i + 1, (S[i] ==  0  ? -1 : 1));        vpi v;    FOR(i,1,Q){     cin >> a >> b;     v.pb(pi(a,b));    }    reverse(all(v));    aFOR(i,v){     a = i.f, b = i.s;          int x = root->qry(a,b);     if (x == 0){      cout <<  NO n ; return;     }else if (x < 0) root->upd(a,b,-1);     else root->upd(a,b,1);    }    FOR(i,0,N-1){     if (root->qry(i+1,i+1) != (F[i] ==  0  ? -1 : 1)){      cout <<  NO n ; return;     }    }    cout <<  YES n ;   }   int main(){    fast;    int TC;    cin >> TC;    while (TC--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N;     cin >> N;     int black = 0, white = 1000000001;     cout << 0 <<     << 0 << endl;     cout << flush;     string S;     cin >> S;     if (S ==  white ) swap(white, black);     for (int i = 1; i < N; i++) {       int mid = (white + black) / 2;       cout << mid <<     << 0 << endl;       cout << flush;       cin >> S;       if (S ==  black ) {         black = mid;       } else {         white = mid;       }     }     if (black + 1 < white || white + 1 < black)       cout << (black + white) / 2 <<     << 1 <<     << (black + white) / 2 <<                << 2 << endl;     else {       if (black < white) {         if (black > 0)           cout << black <<     << 1 <<     << black - 1 <<     << 3 << endl;         else           cout << black + 1 <<     << 1 <<     << black + 2 <<     << 3 << endl;       } else {         if (white > 0)           cout << white <<     << 1 <<     << white - 1 <<     << 3 << endl;         else           cout << white + 1 <<     << 1 <<     << white + 2 <<     << 3 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   int main(void) {     int n, m, c1 = 0, c2 = 0, c3 = 0, c4 = 0, count = 0, i, j;     scanf( %d%d n , &n, &m);     char s[n + 1][m + 1];     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) scanf( %c n , &s[i][j]);     }     for (i = 0; i < n - 1; i++) {       for (j = 0; j < m - 1; j++) {         if (s[i][j] ==  f )           c1++;         else if (s[i][j] ==  a )           c2++;         else if (s[i][j] ==  c )           c3++;         else if (s[i][j] ==  e )           c4++;         if (s[i][j + 1] ==  f )           c1++;         else if (s[i][j + 1] ==  a )           c2++;         else if (s[i][j + 1] ==  c )           c3++;         else if (s[i][j + 1] ==  e )           c4++;         if (s[i + 1][j] ==  f )           c1++;         else if (s[i + 1][j] ==  a )           c2++;         else if (s[i + 1][j] ==  c )           c3++;         else if (s[i + 1][j] ==  e )           c4++;         if (s[i + 1][j + 1] ==  f )           c1++;         else if (s[i + 1][j + 1] ==  a )           c2++;         else if (s[i + 1][j + 1] ==  c )           c3++;         else if (s[i + 1][j + 1] ==  e )           c4++;         if (c1 == 1 && c2 == 1 && c3 == 1 && c4 == 1) count++;         c1 = c2 = c3 = c4 = 0;       }     }     printf( %d n , count);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long modPow(long long a, long long b);   long long modInv(long long a);   void solve() {     long long n;     cin >> n;     long long a[n];     for (long long i = 0; i < n; i++) cin >> a[i];     long long dp[n + 1][n + 1];     memset(dp, 0, sizeof(dp));     long long ans = 0;     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < i - 1; j++) {         dp[a[j]][a[i - 1]]++;       }       for (long long j = i + 1; j < n; j++) {         ans += dp[a[i]][a[j]];       }     }     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long test = 1;     cin >> test;     while (test--) solve();   }   long long modPow(long long a, long long b) {     if (b == 0) return 1;     if (b % 2 == 0) {       long long x = a * a;       x %= 1000000007;       return modPow(x, b / 2);     }     return (a * modPow(a, b - 1)) % 1000000007;   }   long long modInv(long long a) { return modPow(a, 1000000007 - 2); }
#include <bits/stdc++.h>   using namespace std;   char grid[2010][2010];   bool vis[2010][2010];   int dx[] = {0, 0, 1, -1};   int dy[] = {-1, 1, 0, 0};   bool valid(int x, int y, int n, int m) {     if (x == n || y == m || x == -1 || y == -1 || vis[x][y] ||         grid[x][y] ==  * ) {       return 0;     }     return 1;   }   int main() {     int n, m;     int sr, sc;     int x, y;     scanf( %d%d%d%d%d%d , &n, &m, &sr, &sc, &x, &y);     sr--, sc--;     for (int i = 0; i < n; i++) {       scanf( %s , grid[i]);     }     int ans = 0;     queue<pair<pair<int, int>, pair<int, int> > > q[2];     int curQ = 0, nxtQ = 1;     q[curQ].push(make_pair(make_pair(sr, sc), make_pair(x, y)));     while (q[curQ].size()) {       while (q[curQ].size()) {         pair<pair<int, int>, pair<int, int> > cur = q[curQ].front();         q[curQ].pop();         int curX = cur.first.first;         int curY = cur.first.second;         int rem[] = {cur.second.first, cur.second.second};         if (valid(curX, curY, n, m) == 0) {           continue;         }         ans++;         vis[curX][curY] = 1;         for (int i = 0; i < 4; i++) {           if (i < 2) {             if (rem[i] == 0) continue;             rem[i]--;             q[nxtQ].push(make_pair(make_pair(curX + dx[i], curY + dy[i]),                                    make_pair(rem[0], rem[1])));             rem[i]++;           } else {             q[curQ].push(make_pair(make_pair(curX + dx[i], curY + dy[i]),                                    make_pair(rem[0], rem[1])));           }         }       }       curQ = !curQ;       nxtQ = !nxtQ;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int MOD = 1e9 + 7;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, i;     cin >> n;     while (n--) {       long long int k, t;       cin >> k >> t;       cout << t + (k - 1) * 9 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mxn = 5e5 + 123;   const int inf = 1e9;   const int mod = 1e9 + 7;   int a[mxn], n;   vector<int> v;   int main() {     long long s;     cin >> s;     for (long long i = 1; i <= s; i++) {       long long n;       cin >> n;       long long sum = 0;       while (n > 0) {         if (n % 2 == 1) sum++;         n /= 2;       }       cout << (1ll << sum) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300000 + 10;   long long num[maxn], dp[maxn][15];   void Solve() {     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++) scanf( %lld , &num[i]);     long long ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (j == 1)           dp[i][j] = max(dp[i - 1][m] + num[i] - k, num[i] - k);         else {           if (i < j) break;           dp[i][j] = dp[i - 1][j - 1] + num[i];         }         ans = max(ans, dp[i][j]);       }     }     printf( %lld n , ans);   }   int main() {     Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long c;   int last, l, r;   int q[200010];   long long a[400010], ans[200010];   int main() {     scanf( %d%lld , &n, &c);     for (int i = 1; i < 2 * n; i++) scanf( %lld , &a[i]), a[i] += a[i - 1];     for (int i = 1; i <= n; i++) {       while (last < i && a[2 * i - 1] - a[2 * last] >= c) last++;       while (l <= r && a[2 * i - 1] - a[2 * q[l]] >= c) l++;       if (last) ans[i] = ans[last - 1] + c;       if (l <= r) ans[i] = max(ans[i], a[2 * i - 1] + ans[q[l]] - a[2 * q[l]]);       while (l <= r && ans[i] - a[2 * i] >= ans[q[r]] - a[2 * q[r]]) r--;       q[++r] = i;     }     printf( %lld n , ans[n]);   }
#include <bits/stdc++.h>   using namespace std;   long long H[200005];   int a[200005];   long long c[200005 << 2];   long long s[200005 << 2];   long long lz[200005 << 2];   vector<int> v[200005];   int u;   int yl, yr;   void build(int o, int l, int r) {     if (l == r) {       lz[o] = l;       c[o] = l;       s[o] = l;       return;     }     int mid = (l + r) >> 1;     build(o * 2, l, mid);     build(o * 2 + 1, mid + 1, r);     lz[o] = -1;     c[o] = c[o * 2] + c[o * 2 + 1];     s[o] = min(s[o * 2], s[o * 2 + 1]);   }   void pushdown(int o, int l, int r) {     if (l == r) return;     if (lz[o] == -1) return;     lz[o * 2] = lz[o];     lz[o * 2 + 1] = lz[o];     s[o * 2] = lz[o];     s[o * 2 + 1] = lz[o];     int mid = (l + r) >> 1;     c[o * 2] = lz[o] * (mid - l + 1);     c[o * 2 + 1] = lz[o] * (r - mid);     lz[o] = -1;   }   void update(int o, int l, int r) {     if (yl <= l && yr >= r) {       c[o] = 1LL * u * (r - l + 1);       s[o] = u;       lz[o] = u;       return;     }     pushdown(o, l, r);     int mid = (l + r) >> 1;     if (yl <= mid) update(o * 2, l, mid);     if (yr > mid) update(o * 2 + 1, mid + 1, r);     c[o] = c[o * 2] + c[o * 2 + 1];     s[o] = min(s[o * 2], s[o * 2 + 1]);     if (lz[o * 2] == lz[o * 2 + 1] && lz[o * 2] >= 0) lz[o] = lz[o * 2];   }   int query(int o, int l, int r) {     if (l == r && c[o] < u) return l;     if (l == r && c[o] >= u) return 0;     if (lz[o] != -1 && lz[o] < u) return r;     if (lz[o] != -1 && lz[o] >= u) return 0;     int mid = (l + r) >> 1;     if (s[o * 2 + 1] < u)       return query(o * 2 + 1, mid + 1, r);     else       return query(o * 2, l, mid);   }   int main() {     int n;     scanf( %d , &n);     int mx = -1;     memset(a, 0, sizeof(a));     for (int i = 1; i < n + 1; ++i) {       int tmp;       scanf( %d , &tmp);       a[tmp] = i;       mx = max(mx, tmp);     }     for (int i = 1; i <= mx; ++i) {       for (int j = 1; j * i <= mx; ++j) {         if (a[j * i]) v[i].push_back(a[j * i]);       }     }     for (int i = 0; i <= mx; ++i) sort(v[i].begin(), v[i].end());     long long sum = 1LL * n * (n + 1);     build(1, 1, n);     for (int i = mx; i >= 0; --i) {       H[i] = sum - c[1];       int k = v[i].size();       if (k < 2) {         continue;       }       u = n + 1;       yl = v[i][1] + 1;       yr = n;       if (yl <= yr) update(1, 1, n);       u = v[i][k - 1];       int pos = query(1, 1, n);       pos = min(pos, v[i][1]);       if (pos > v[i][0] && pos <= v[i][1]) {         yl = v[i][0] + 1;         yr = pos;         update(1, 1, n);       }       u = v[i][k - 2];       pos = query(1, 1, n);       pos = min(pos, v[i][0]);       if (pos >= 1 && pos <= v[i][0]) {         yl = 1;         yr = pos;         update(1, 1, n);       }     }     long long ans = 0;     for (int i = 1; i <= mx; ++i) {       ans += 1LL * i * (H[i] - H[i - 1]);     }     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int MM = 1e9 + 7;   const double eps = 1e-8;   const int MAXN = 2e6 + 10;   int n, m;   int a[MAXN], Q[MAXN], cnt[MAXN], ans[MAXN];   int f[MAXN];   void prework() {}   void read() {}   int gao(int k) {     if (f[k] != -1) return f[k];     int ret = 0;     int now = 0;     for (int i = 1; i <= n; i++) {       if (cnt[a[i]] == 0) {         if (now == k) {           ret++;           while (now) {             cnt[Q[now--]] = 0;           }           now = 1;           Q[now] = a[i];           cnt[a[i]] = 1;         } else {           Q[++now] = a[i];           cnt[a[i]] = 1;         }       } else {         ;       }     }     ret += (now > 0);     while (now) {       cnt[Q[now--]] = 0;     }     return f[k] = ret;   }   void work(int l, int r) {     if (l >= r || gao(l) == gao(r)) {       for (int i = l; i <= r; i++) ans[i] = gao(l);       return;     }     m = (l + r) >> 1;     work(l, m);     work(m + 1, r);   }   void solve(int casi) {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     for (int i = 0; i <= n; i++) f[i] = -1;     work(1, n);     for (int i = 1; i <= n; i++) printf( %d%c , ans[i],    n [i == n]);   }   void printans() {}   int main() {     prework();     int T = 1;     for (int i = 1; i <= T; i++) {       read();       solve(i);       printans();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, l, m, sol;   int a[10];   bool r[333][333];   bool ok;   int main() {     cin >> n;     for (int(i) = (0); (i) < (n); ++(i)) cin >> a[i];     if (n == 1) {       if (a[0] == 0)         cout <<  BitAryo  << endl;       else         cout <<  BitLGM  << endl;       return 0;     }     if (n == 2) {       r[0][0] = false;       for (int(i) = (0); (i) < (a[0] + 1); ++(i))         for (int(j) = (0); (j) < (a[1] + 1); ++(j)) {           if (i + j == 0) continue;           ok = false;           m = min(i, j);           while (m > 0) {             ok |= (r[i - m][j - m] == 0);             m--;           }           m = i;           while (m > 0) {             ok |= (r[i - m][j] == 0);             m--;           }           m = j;           while (m > 0) {             ok |= (r[i][j - m] == 0);             m--;           }           r[i][j] = ok;         }       if (r[a[0]][a[1]])         cout <<  BitLGM  << endl;       else         cout <<  BitAryo  << endl;       return 0;     }     if (a[0] ^ a[1] ^ a[2])       cout <<  BitLGM  << endl;     else       cout <<  BitAryo  << endl;     return 0;   }