malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1000 * 100 + 10;   int n, d[N], par[N];   pair<int, int> tr[N * 4];   pair<long long, int> a[N], b[N];   void add(int val, int p, int b = 0, int e = n, int ind = 1) {     tr[ind] = max(tr[ind], make_pair(val, p));     if (b + 1 == e) return;     int mid = (b + e) / 2;     if (p < mid)       add(val, p, b, mid, ind * 2);     else       add(val, p, mid, e, ind * 2 + 1);     return;   }   pair<int, int> get(int l, int r, int b = 0, int e = n, int ind = 1) {     if (l <= b && e <= r) return tr[ind];     int mid = (b + e) / 2;     pair<int, int> ret = make_pair(0, 0);     if (l < mid) ret = get(l, r, b, mid, ind * 2);     if (r > mid) ret = max(get(l, r, mid, e, ind * 2 + 1), ret);     return ret;   }   void pp(int v) {     if (d[v] == 1) {       cout << v + 1 <<    ;       return;     }     pp(par[v]);     cout << v + 1 <<    ;     return;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long k;     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> a[i].first;       b[i].first = a[i].first;       b[i].second = i;     }     sort(b, b + n);     for (int i = 0; i < n; i++) a[b[i].second].second = i;     d[0] = 1;     add(1, a[0].second);     for (int i = 1; i < n; i++) {       int l = upper_bound(b, b + n, make_pair(a[i].first - k, n)) - b;       int r = lower_bound(b, b + n, make_pair(a[i].first + k, 0)) - b;       if (l) {         pair<int, int> temp = get(0, l);         d[i] = temp.first + 1;         par[i] = b[temp.second].second;       }       if (r < n) {         pair<int, int> temp = get(r, n);         if (temp.first >= d[i]) {           d[i] = temp.first + 1;           par[i] = b[temp.second].second;         }       }       add(d[i], a[i].second);     }     long long maxx = 0, maxind;     for (int i = 0; i < n; i++) {       if (d[i] > maxx) {         maxx = d[i];         maxind = i;       }     }     cout << maxx << endl;     pp(maxind);   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:267386880 )   using namespace std;   int n;   char g[72][72];   struct pos {     int data[3];   };   const int MAXQ = 400000;   bool used[72][72][72];   pos prv[72][72][72];   pos q[MAXQ];   int head, tail;   pair<int, int> getDiff(pos &a, pos &b) {     int diffA(-1);     for (int i(0); i <= ((long long)(3) - 1); ++i) {       bool ok(true);       for (int j(0); j <= ((long long)(3) - 1); ++j)         if (b.data[j] == a.data[i]) ok = false;       if (ok) {         diffA = a.data[i];         break;       }     }     int sm1(accumulate(a.data, a.data + 3, 0));     int sm2(accumulate(b.data, b.data + 3, 0));     int diffB = -(sm1 - sm2 - diffA);     return make_pair(diffA, diffB);   }   void printAns() {     pos tmp = {{0, 1, 2}};     pos &now = tmp;     pos &from = prv[0][1][2];     vector<pair<int, int> > ans;     while (from.data[0] != -1) {       pair<int, int> rs(getDiff(from, now));       ans.push_back(rs);       now = from;       from = prv[now.data[0]][now.data[1]][now.data[2]];     }     reverse((ans).begin(), (ans).end());     printf( %d n , ((int)ans.size()));     for (int i(0); i <= ((long long)(((int)ans.size())) - 1); ++i)       printf( %d %d n , ans[i].first + 1, ans[i].second + 1);     exit(0);   }   void addPos(int a, int b, int c, pos from) {     pos p = {{a, b, c}};     sort(p.data, p.data + 3);     if (used[p.data[0]][p.data[1]][p.data[2]]) return;     used[p.data[0]][p.data[1]][p.data[2]] = true;     prv[p.data[0]][p.data[1]][p.data[2]] = from;     q[tail++] = p;     if (tail == MAXQ) tail = 0;     if (p.data[0] == 0 && p.data[1] == 1 && p.data[2] == 2) printAns();   }   bool can(int from, int to, int a, int b) { return g[a][b] == g[from][to]; }   void process() {     pos &cur = q[head++];     if (head == MAXQ) head = 0;     for (int i(0); i <= ((long long)(3) - 1); ++i) {       int from(cur.data[i]);       int a(cur.data[(i + 1) % 3]), b(cur.data[(i + 2) % 3]);       for (int to(0); to <= ((long long)(n)-1); ++to) {         if (to == a || to == b || to == from) continue;         if (can(from, to, a, b)) addPos(to, a, b, cur);       }     }   }   void solve() {     scanf( %d , &n);     int a, b, c;     scanf( %d%d%d n , &a, &b, &c);     for (int i(0); i <= ((long long)(n)-1); ++i) gets(g[i]);     pos fict = {{-1, -1, -1}};     addPos(--a, --b, --c, fict);     while (head != tail) process();     printf( -1 n );   }   void bruteforce() {}   int main() {     solve();     bruteforce();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n, q;       cin >> n >> q;       string s;       cin >> s;       int pref[n + 1];       memset(pref, 0, sizeof(pref));       set<int> arr[2 * n + 5];       for (int i = 0; i < 2 * n + 5; i++) {         set<int> ss;         arr[i] = ss;       }       for (int i = 1; i <= n; i++) {         if (s[i - 1] ==  + ) {           if (i % 2 == 1) {             pref[i] = pref[i - 1] + 1;           } else {             pref[i] = pref[i - 1] - 1;           }         } else {           if (i % 2 == 1) {             pref[i] = pref[i - 1] - 1;           } else {             pref[i] = pref[i - 1] + 1;           }         }         arr[pref[i] + n].insert(i);       }       for (int i = 0; i < q; i++) {         int l, r;         cin >> l >> r;         int val = pref[r] - pref[l - 1];         if (val == 0) {           cout << 0 << endl;         } else {           if (abs(val) % 2 == 1) {             if (val < 0) {               val--;             } else {               val++;             }             int half = pref[l - 1] + val / 2;             half += n;             auto it = arr[half].lower_bound(l);             int res = *it;             cout << 1 << endl;             cout << res << endl;           } else {             int diff = pref[r] - pref[r - 1];             val -= diff;             if (val < 0) {               val--;             } else {               val++;             }             int half = pref[l - 1] + val / 2;             half += n;             auto it = arr[half].lower_bound(l);             int res = *it;             cout << 2 << endl;             cout << res <<     << r << endl;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int him(long long int a, long long int n) {     long long int ans = 1;     while (n) {       if (n % 2 != 0) {         ans = ((ans) * (a));       }       a = ((a) * (a));       n = n / 2;     }     return ans;   }   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       if (n == 1 || n == 2)         cout << 0 << endl;       else         cout << n - 2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int Max = 1e6 + 5;   int lst[Max];   int main() {     int t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       long long sum = 0;       while (n > 0) {         if (n % k == 0) {           n /= k;           sum++;         } else {           sum += n % k;           n -= n % k;         }       }       cout << sum << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<string> split_string(string);   bool isDiverse(string &s) {     int len = s.length();     sort(s.begin(), s.end());     for (int i = 0; i < len - 1; i++) {       if (s[i] == s[i + 1]) {         return false;       } else if (s[i + 1] != s[i] + 1) {         return false;       }     }     return true;   }   int main() {     ios::sync_with_stdio(false);     int N;     string s;     cin >> N;     for (int i = 0; i < N; i++) {       cin >> s;       if (isDiverse(s)) {         cout <<  Yes n ;       } else {         cout <<  No n ;       }     }   }   vector<string> split_string(string input_string) {     vector<string> splits;     stringstream ss(input_string);     string item;     while (getline(ss, item,    )) {       splits.push_back(item);     }     return splits;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 405;   const int oo = 10005;   int N, M, T, K, Q;   vector<pair<int, int> > G[MAXN];   int dp[MAXN][MAXN][MAXN];   int par[MAXN];   int indPar[MAXN];   void DFS(int u, int p) {     par[u] = p;     for (int i = 0; i < G[u].size(); i++) {       int v = G[u][i].first;       if (v != p) {         indPar[v] = G[u][i].second;         DFS(v, u);       }     }     return;   }   int solve(int i, int cnt, int curK) {     if (curK == 0) return 0;     if (G[i].size() == 1 && i != 1) return (curK == 1) ? 0 : oo;     if (cnt >= G[i].size()) return (curK == 1) ? 0 : oo;     if (dp[i][cnt][curK] != -1) return dp[i][cnt][curK];     int res = oo;     int v = G[i][cnt].first;     if (v == par[i]) return dp[i][cnt][curK] = solve(i, cnt + 1, curK);     res = min(res, solve(i, cnt + 1, curK) + 1);     for (int k = 1; k < curK; k++)       res = min(res, solve(v, 0, k) + solve(i, cnt + 1, curK - k));     return dp[i][cnt][curK] = res;   }   void TRACE(int i, int cnt, int curK) {     if (curK == 0) return;     if (G[i].size() == 1 && i != 1) return;     if (cnt >= G[i].size()) return;     int res = solve(i, cnt, curK);     int v = G[i][cnt].first;     if (v == par[i]) {       TRACE(i, cnt + 1, curK);       return;     }     if (res == solve(i, cnt + 1, curK) + 1) {       cout << G[i][cnt].second <<    ;       TRACE(i, cnt + 1, curK);       return;     }     for (int k = 1; k < curK; k++)       if (res == solve(v, 0, k) + solve(i, cnt + 1, curK - k)) {         TRACE(v, 0, k);         TRACE(i, cnt + 1, curK - k);         return;       }     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (fopen( 440D                 .inp ,                r )) {       freopen(            440D             .inp ,            r , stdin);       freopen(            440D             .out ,            w , stdout);     }     cin >> N >> K;     int u, v;     for (int i = 1; i <= N - 1; i++) {       cin >> u >> v;       G[u].push_back({v, i});       G[v].push_back({u, i});     }     DFS(1, 0);     memset(dp, -1, sizeof(dp));     int ANS = solve(1, 0, K);     int Root = 1;     for (int i = 2; i <= N; i++) {       if (ANS > solve(i, 0, K) + 1) {         ANS = solve(i, 0, K) + 1;         Root = i;       }     }     if (Root == 1) {       cout << solve(1, 0, K) <<   n ;       TRACE(1, 0, K);       return 0;     }     cout << solve(Root, 0, K) + 1 <<   n ;     cout << indPar[Root] <<   n ;     TRACE(Root, 0, K);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n;     string s = to_string(n);     k = s.size() - 1;     if (k > 0) {       long long a = rint(pow(10, k));       long long z = rint(n / a);       long long m = (z + 1) * a;       cout << m - n;     } else       cout << 1;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long   ll gcd(ll a, ll b){    return b?gcd(b,a%b):a;   }   ll a[200005],b[200005],c,d;   int main(){    ll n,m;    scanf( %lld%lld ,&n,&m);    ll d=0;    cin>>a[1];    for(ll i=2;i<=n;i++){      //从a[2]-a[1]开始      scanf( %lld ,&a[i]);     d=gcd(d,a[i]-a[i-1]);  //gcd(0,a)=a    }    for(ll i=1;i<=m;i++){     scanf( %lld ,&b[i]);     ll dd=abs(gcd(d,a[1]+b[i]));     printf( %lld  ,dd);    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[10005], sum1 = 0, sum2 = 0;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] < 0)         sum2++;       else {         if (a[i] == 0)           sum1++;         else           cout << a[i] <<    ;       }     }     sort(a + 1, a + n + 1);     if (sum2 % 2 == 0) {       for (int i = 1; i <= sum2; i++) {         cout << a[i] <<    ;       }     } else {       for (int i = 1; i <= sum2 - 1; i++) {         cout << a[i] <<    ;       }     }     if (n == 1 && a[1] <= 0) {       cout << a[1];       return 0;     }     if (sum1 == n) cout << 0;     if (sum1 + sum2 == n && sum2 == 1) cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2147483647;   const long long LLINF = 9223372036854775807LL;   const int maxn = 30010;   int a[maxn] = {};   int used[maxn] = {};   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     vector<int> ans1, ans2;     if (n == 2) {       ans1.push_back(a[0]);       ans2.push_back(a[1]);       goto ooo;     }     if (n == 3) {       ans1.push_back(a[0]);       ans1.push_back(a[1]);       ans2.push_back(a[2]);       goto ooo;     }     if (n == 4) {       ans1.push_back(a[0]);       ans1.push_back(a[1]);       ans2.push_back(a[2]);       ans2.push_back(a[3]);       goto ooo;     }     for (int i = 0; i < 5; ++i)       for (int j = i + 1; j < 5; ++j)         for (int k = j + 1; k < 5; ++k) {           if (a[j] - a[i] == a[k] - a[j]) {             memset(used, 0, sizeof(used));             used[i] = 1;             used[j] = 1;             used[k] = 1;             int d = a[j] - a[i];             int cur = a[k] + d;             int cused = 3;             int lused = k;             for (int t = k + 1; t < n; ++t) {               if (a[t] == cur) {                 used[t] = 1;                 lused = t;                 cused++;                 cur += d;               }             }             int pppp = 2;             while (pppp--) {               if (pppp == 0) used[lused] = 0;               bool ok = true;               int p1 = -1;               int p2 = -1;               int curd = 0;               for (int t = 0; t < n; ++t) {                 if (used[t]) continue;                 int ccc = a[i];                 if (curd == 0) {                   if (p2 == -1) {                     p2 = p1;                     p1 = t;                     if (p2 != -1) {                       curd = a[p1] - a[p2];                     }                   }                 } else {                   if (a[t] - a[p1] != curd) {                     ok = false;                     break;                   } else {                     p1 = t;                   }                 }               }               if (ok) {                 if (cused == n) used[0] = 0;                 for (int t = 0; t < n; ++t) {                   if (used[t])                     ans1.push_back(a[t]);                   else                     ans2.push_back(a[t]);                 }                 goto ooo;               }             }           }         }     printf( No solution );     return 0;   ooo:     for (int i = 0; i < ans1.size(); ++i) printf( %d  , ans1[i]);     printf(  n );     for (int i = 0; i < ans2.size(); ++i) printf( %d  , ans2[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC target( avx2 )   #pragma GCC optimization( unroll-loops )   #pragma GCC optimize( O2 )   constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};   constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};   constexpr long long INF = 1999999999999999997;   constexpr int inf = INT_MAX;   constexpr int MAXSIZE = int(1e6) + 5;   constexpr auto PI = 3.14159265358979323846L;   constexpr auto oo = numeric_limits<int>::max() / 2 - 2;   constexpr auto eps = 1e-6;   constexpr auto mod = 1000000007;   constexpr auto MOD = 1000000007;   constexpr auto MOD9 = 1000000009;   constexpr auto maxn = 100006;   void fastio() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   int n, m, k;   int fre;   char a[502][502];   int x = -1, y = -1;   bool visited[502][502];   int l;   void dfs(int x, int y) {     if (l == 0) return;     if (x + 1 < n && a[x + 1][y] ==  .  && !visited[x + 1][y] && l > 0) {       visited[x + 1][y] = 1;       l--;       dfs(x + 1, y);     }     if (l == 0) return;     if (y + 1 < m && a[x][y + 1] ==  .  && !visited[x][y + 1] && l > 0) {       visited[x][y + 1] = 1;       l--;       dfs(x, y + 1);     }     if (l == 0) return;     if (x - 1 >= 0 && a[x - 1][y] ==  .  && !visited[x - 1][y] && l > 0) {       visited[x - 1][y] = 1;       l--;       dfs(x - 1, y);     }     if (l == 0) return;     if (y - 1 < n && a[x][y - 1] ==  .  && !visited[x][y - 1] && l > 0) {       visited[x][y - 1] = 1;       l--;       dfs(x, y - 1);     }     if (l == 0) return;   }   int main() {     fastio();     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];         if (a[i][j] ==  . ) {           fre++;           if (x == -1) {             x = i, y = j;           }         }       }     }     l = fre - k;     int c = k;     dfs(x, y);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i][j] ==  .  && !visited[i][j] && c > 0) {           a[i][j] =  X ;           c--;         }         cout << a[i][j];       }       cout <<   n ;     }   }
#include <bits/stdc++.h>      #define fi first   #define se second   #define db double   #define U unsigned   #define P std::pair<int,int>   #define LL long long   #define pb push_back   #define MP std::make_pair   #define all(x) x.begin(),x.end()   #define CLR(i,a) memset(i,a,sizeof(i))   #define FOR(i,a,b) for(int i = a;i <= b;++i)   #define ROF(i,a,b) for(int i = a;i >= b;--i)   #define DEBUG(x) std::cerr << #x <<  =  << x << std::endl      const int MAXN = 500+5;   int n,k;   int mn[26];   std::string f[MAXN],str;      inline std::string ctos(char x){       return std::string(1,x);   }      inline void Solve(){       std::cin >> n >> k >> str;str =  0 +str;       mn[0] = 0;FOR(i,1,k-2) mn[i] = i-1;mn[k-1] = 0;       f[0].clear();FOR(i,1,n) f[i] =  { ;       FOR(i,0,n-1){           f[i+1] = std::min(f[i+1],f[i]+ctos( a +mn[str[i+1]- a ]));           if(i) f[i+1] = std::min(f[i+1],f[i].substr(0,i-1)+ctos(str[i+1])+f[i].back());           if(i != n-1) f[i+2] = std::min(f[i+2],f[i]+ctos( a +mn[str[i+2]- a ])+ctos(str[i+1]));           if(i && i != n-1) f[i+2] = std::min(f[i+2],f[i].substr(0,i-1)+ctos(str[i+2])+f[i].back()+ctos(str[i+1]));       }       std::cout << f[n] << std::endl;   }      int main(){       std::ios::sync_with_stdio(false);       int T;std::cin >> T;       while(T--) Solve();       return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimization( O3 )   using namespace std;   template <typename T>   inline void Cin(T& first) {     char c;     T sign = 1;     first = 0;     for (c = getchar(); c <  0  || c >  9 ; c = getchar())       if (c ==  - ) sign = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) first = first * 10 + c -  0 ;     first *= sign;   }   template <typename T>   inline void Out(T first) {     if (first > 9) Out(first / 10);     putchar(first % 10 +  0 );   }   template <typename T>   inline void Cout(T first, char c) {     if (first < 0) putchar( - );     first = abs(first);     Out(first);     putchar(c);   }   template <typename T, typename... Args>   inline void Cin(T& a, Args&... args) {     Cin(a);     Cin(args...);   }   template <typename T, typename... Args>   inline void Cout(T a, char c, Args... args) {     Cout(a, c);     Cout(args...);   }   const int mod = int(1e9) + 7;   const int N = 2050;   int f[N][N], a[N], n, k, nState;   void Enter() {     cin >> n >> k;     for (int i = 1; i <= n; ++i) cin >> a[i];   }   void add(int& first, int second) {     if ((first += second) >= mod) first -= mod;   }   void Solve() {     nState = 1 << k, f[0][0] = 1;     for (int i = 1; i <= n; ++i) {       for (int bit = 0; bit <= nState; ++bit) {         if (!f[i - 1][bit]) continue;         if (a[i] == 2 || a[i] == 0) {           if (bit + 2 >= nState)             add(f[i][nState], f[i - 1][bit]);           else             add(f[i][bit + 2], f[i - 1][bit]);         }         if (a[i] == 4 || a[i] == 0) {           if ((bit >> 1) & 1)             add(f[i][4], f[i - 1][bit]);           else {             if (bit + 4 >= nState)               add(f[i][nState], f[i - 1][bit]);             else               add(f[i][bit + 4], f[i - 1][bit]);           }         }       }     }     cout << f[n][nState];   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (fopen( test                 .inp ,                r )) {       freopen(            test             .inp ,            r , stdin);       freopen(            test             .out ,            w , stdout);     }     Enter(), Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const double pi = acos(-1.0);   int a[32][101111], n, m, d[32][111111], b[111111], t[400111];   pair<pair<int, int>, int> p[111111];   int bit(int mask, int i) { return (mask & (1 << i)) > 0; }   void build(int v, int tl, int tr) {     if (tl == tr)       t[v] = b[tl];     else {       int tm = (tl + tr) / 2;       build(v * 2, tl, tm);       build(v * 2 + 1, tm + 1, tr);       t[v] = (t[v * 2] & t[v * 2 + 1]);     }   }   int get(int v, int tl, int tr, int l, int r) {     if (l > r) return (1 << 30) - 1;     if (l == tl && r == tr) return t[v];     int tm = (tl + tr) / 2;     return get(v * 2, tl, tm, l, min(r, tm)) &            get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);   }   int main() {     scanf( %d%d , &n, &m);     int len = (int)sqrt(n + .0) + 1;     for (int cs = 0; cs < m; ++cs) {       int l, r, q;       scanf( %d%d%d , &l, &r, &q);       p[cs] = make_pair(make_pair(l, r), q);       for (int j = 0; j < 30; ++j) {         int w = bit(q, j);         if (w == 0) continue;         a[j][l]++;         a[j][r + 1]--;       }     }     for (int i = 0; i < 30; ++i) {       int second = 0;       for (int j = 1; j <= n; ++j) {         second += a[i][j];         a[i][j] = a[i][j - 1] + second;       }     }     for (int i = 1; i <= n; ++i) {       int ans = 0;       for (int j = 0; j < 30; ++j) ans += (1 << j) * (a[j][i] - a[j][i - 1] > 0);       b[i] = ans;     }     build(1, 1, n);     for (int i = 0; i < m; ++i) {       int l = p[i].first.first, r = p[i].first.second, q = p[i].second;       if (get(1, 1, n, l, r) != q) {         puts( NO );         return 0;       }     }     puts( YES );     for (int i = 1; i <= n; ++i) printf( %d  , b[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fll;   map<int, int> memo;   int solve(int mask) {     if (!mask) return 0;     if (memo.find(mask) != memo.end()) return memo[mask];     map<int, bool> canreach;     for (int i = 0; i < 32; i++) {       int aux = ((1 << i) - 1) & mask;       int ns = aux | ((mask - aux) >> (i + 1));       if (ns == mask) continue;       canreach[solve(ns)] = true;     }     int mex = 0;     for (int i = 0; i < 100; i++)       if (!canreach[i]) {         mex = i;         break;       }     return memo[mask] = mex;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     map<int, int> mps;     for (int j = 0; j < n; j++) {       int val, aux;       cin >> val;       aux = val;       for (int i = 2; i * i <= val; i++) {         int cnt = 0;         while (aux % i == 0) {           aux /= i;           cnt++;         }         if (cnt) mps[i] |= (1 << (cnt - 1));       }       if (aux != 1) mps[aux] |= 1;     }     int grundy = 0;     for (auto u : mps) grundy ^= solve(u.second);     cout << (grundy ?  Mojtaba  :  Arpa ) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n;   int a[1000005];   vector<int> x;   void solve() {     int sum = 0, ans;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       sum += a[i];     }     int l = 1, r = 1e7;     while (l <= r) {       int mid = (l + r) >> 1;       if (mid * n >= sum) {         r = mid - 1;         ans = mid;       } else {         l = mid + 1;       }     }     x.push_back(ans);   }   int main() {     cin >> t;     while (t--) solve();     for (int i = 0; i < x.size(); i++) {       cout << x[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int T;     cin >> T;     while (T--) {       long long a, b, n;       cin >> a >> b >> n;       if (a < b) swap(a, b);       int ans = 0;       while (a <= n) {         b += a;         if (a < b) swap(a, b);         ans++;       }       cout << ans <<   n ;     }     return 0;   }