malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   #pragma GCC optimize( unroll-loops )   using namespace std;   const long double eps = 1e-7;   const int inf = 1000000010;   const long long INF = 10000000000000010LL;   const int mod = 1000000007;   const int MAXN = 200010, LOG = 20;   struct DSU {     int par[MAXN];     int rank[MAXN];     stack<pair<int*, int>> stk;     DSU() {       for (int i = 1; i < MAXN; i++) par[i] = i;     }     int get(int x) {       if (par[x] == x) return x;       return get(par[x]);     }     int join(int x, int y) {       x = get(x);       y = get(y);       if (x == y) return 0;       if (rank[x] > rank[y]) swap(x, y);       stk.push({&par[x], par[x]});       stk.push({&rank[y], rank[y]});       par[x] = y;       rank[y] += (rank[x] == rank[y]);       return 1;     }     void undo(int cnt = 1) {       cnt <<= 1;       while (cnt--) {         auto it = stk.top();         stk.pop();         *it.first = it.second;       }     }   } dsu;   int n, m, k, u, v, x, y, a, b, last;   int T[MAXN], X[MAXN], Y[MAXN];   map<pair<int, int>, vector<int>> mp;   vector<pair<int, int>> seg[MAXN << 2];   set<pair<int, int>> edge;   string out;   int f(int x) {     if (x == n) return 1;     return x + 1;   }   pair<int, int> ff(int x, int y) {     if (x > y) swap(x, y);     return {x, y};   }   void Add(int id, int tl, int tr, int l, int r, pair<int, int> p) {     if (r <= tl || tr <= l) return;     if (l <= tl && tr <= r) {       seg[id].push_back(p);       return;     }     int mid = (tl + tr) >> 1;     Add(id << 1, tl, mid, l, r, p);     Add(id << 1 | 1, mid, tr, l, r, p);   }   void handle(int i) {     if (T[i] == 2) return;     if (last) X[i] = f(X[i]), Y[i] = f(Y[i]);     pair<int, int> p = ff(X[i], Y[i]);     if (edge.count(p))       edge.erase(p);     else       edge.insert(p);   }   void dfs(int id, int tl, int tr) {     int cnt = 0;     for (pair<int, int> p : seg[id])       if (edge.count(p)) cnt += dsu.join(p.first, p.second);     if (tr - tl == 1) {       if (T[tl] == 1)         ;       else {         int i = tl;         if (last) X[i] = f(X[i]), Y[i] = f(Y[i]);         out +=  0  + (last = (dsu.get(X[i]) == dsu.get(Y[i])));       }     } else {       int mid = (tl + tr) >> 1;       dfs(id << 1, tl, mid);       handle(mid);       dfs(id << 1 | 1, mid, tr);     }     dsu.undo(cnt);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= m; i++) {       cin >> T[i] >> X[i] >> Y[i];       mp[ff(X[i], Y[i])].push_back(i);       mp[ff(f(X[i]), f(Y[i]))].push_back(i);     }     for (auto it : mp) {       it.second.push_back(m + 1);       for (int i = 0; i < it.second.size() - 1; i++)         Add(1, 1, m + 1, it.second[i], it.second[i + 1], it.first);     }     handle(1);     dfs(1, 1, m + 1);     cout << out <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dat[1500][1500], vst[1500][1500], lx[1500][1500], ly[1500][1500],       step[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};   char str[1600];   int n, m, sx, sy;   bool dfs(int x, int y) {     int nx = ((x % n) + n) % n;     int ny = ((y % m) + m) % m;     if (!dat[nx][ny]) return false;     if (!vst[nx][ny]) {       vst[nx][ny] = 1;       lx[nx][ny] = x;       ly[nx][ny] = y;     } else if ((lx[nx][ny] != x) || (ly[nx][ny] != y))       return true;     else       return false;     for (int i = 0; i < 4; ++i)       if (dfs(x + step[i][0], y + step[i][1])) return true;     return false;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) {       scanf( %s , str);       for (int j = 0; j < m; ++j) {         dat[i][j] = (str[j] !=  # );         if (str[j] ==  S ) {           sx = i;           sy = j;         }       }     }     memset(lx, 0, sizeof(lx));     memset(ly, 0, sizeof(ly));     if (dfs(sx, sy))       printf( Yes n );     else       printf( No n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const long long int mod = 1e9 + 7;   long double dp[111][11111], ans;   long long int a[111], n, k, x;   int main(void) {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int i, j, k;     cin >> n >> x;     dp[0][0] = 1;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= n; i++)       for (j = i - 1; j >= 0; j--)         for (k = 0; k <= 10000; k++)           dp[j + 1][k + a[i]] += dp[j][k] * (j + 1) / (n - j);     for (i = 1; i <= n; i++)       for (j = 1; j <= 10000; j++)         ans += min((1.0 * n / i + 1) * x / 2, 1.0 * j / i) * dp[i][j];     cout << fixed << setprecision(15) << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxN = 3e1 + 17, N = 5e1 + 17, inf = 1e9 + 7, MOD = 1e9 + 7,                   Mod = 1e9 + 6;   long long n, m, y, t, d[maxN][maxN][N], help, mini, x;   int main() {     for (long long i = 0; i <= 30; i++) {       for (long long j = 0; j <= 30; j++) {         for (long long k = 0; k <= 50; k++) d[i][j][k] = inf;         if (i && j) d[i][j][0] = 0;       }     }     for (long long i = 1; i <= 30; i++) {       for (long long j = 1; j <= 30; j++) {         mini = min((i * j), (long long)50);         for (long long k = 1; k <= mini; k++) {           if (i < 2 || j < 2) d[i][j][k] = 1;           if (k == i * j) d[i][j][k] = 0;           for (long long z = 0; z <= i; z++) {             for (long long e = 0; e <= k; e++)               d[i][j][k] =                   min(d[i][j][k], d[i - z][j][e] + d[z][j][k - e] + (j * j));           }           for (long long z = 0; z <= j; z++) {             for (long long e = 0; e <= k; e++)               d[i][j][k] =                   min(d[i][j][k], d[i][j - z][e] + d[i][z][k - e] + (i * i));           }         }       }     }     cin >> t;     for (long long i = 1; i <= t; i++) {       cin >> n >> m >> y;       cout << d[n][m][y] <<   n ;     }     return cout <<   n , 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename t>   void read(t &x) {     char ch = getchar();     x = 0;     t f = 1;     while (ch <  0  || ch >  9 ) f = (ch ==  -  ? -1 : f), ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     x *= f;   }   long long dp[1000][100];   int main() {     int n, m;     read(n), read(m);     m *= 2;     ;     for (int i = 1; i <= n; i++) dp[1][i] = 1;     for (int i = 2; i <= m; i++)       for (int j = n; j > 0; j--)         dp[i][j] = (dp[i][j + 1] + dp[i - 1][j]) % 1000000007;     long long ans = 0;     for (int i = 1; i <= n; i++) ans = (ans + dp[m][i]) % 1000000007;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300010;   int w[N];   vector<pair<int, int> > v[N], g[N];   int a[N];   int rnk(int x) {     while (a[x] != x) a[x] = a[a[x]], x = a[x];     return x;   }   struct eg {     int x, y, id;   } e[N];   bool cmp(eg a, eg b) { return w[a.id] < w[b.id]; }   bool vis[N], taken[N];   int ans = 0;   int dp[N][20], mx[N][20], l[N];   int lca(int x, int y) {     int res = 0;     if (l[x] > l[y]) swap(x, y);     for (int i = 19; i >= 0; i--)       if ((l[y] - l[x]) & (1 << i)) res = max(res, mx[y][i]), y = dp[y][i];     if (y == x) return res;     for (int i = 19; i >= 0; i--)       if (dp[x][i] != dp[y][i])         res = max(res, max(mx[x][i], mx[y][i])), x = dp[x][i], y = dp[y][i];     return max(res, max(mx[x][0], mx[y][0]));   }   void dfs(int x, int val = 0, int p = 0) {     if (vis[x]) return;     vis[x] = 1;     l[x] = l[p] + 1;     dp[x][0] = p;     mx[x][0] = val;     for (int i = 1; i < 20; i++)       dp[x][i] = dp[dp[x][i - 1]][i - 1],       mx[x][i] = max(mx[x][i - 1], mx[dp[x][i - 1]][i - 1]);     for (auto it : v[x]) {       int y = it.first, z = it.second;       if (!taken[z] && vis[y] && y != p) {         int lc = lca(x, y);         assert(lc <= w[z]);         if (lc == w[z]) ans++;       }     }     for (auto it : g[x]) {       if (!vis[it.first]) dfs(it.first, w[it.second], x);     }   }   int main() {     int n, m, x, y, z;     cin >> n >> m;     for (int i = 1; i <= m; i++) {       scanf( %d %d %d , &x, &y, &z);       v[x].push_back({y, i});       v[y].push_back({x, i});       w[i] = z;       e[i] = {x, y, i};     }     sort(e + 1, e + m + 1, cmp);     for (int i = 1; i <= n; i++) a[i] = i;     for (int i = 1; i <= m; i++) {       if (rnk(e[i].x) != rnk(e[i].y)) {         a[rnk(e[i].x)] = rnk(e[i].y);         g[e[i].x].push_back({e[i].y, e[i].id});         g[e[i].y].push_back({e[i].x, e[i].id});         taken[e[i].id] = 1;       }     }     dfs(1, 0);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 1e5 + 6;   int n, t[MX];   int ID(int x, int jump) {     int st = 1, en = x, ret = 1e6;     while (st <= en) {       int mid = (st + en) / 2;       if (t[x] - jump <= t[mid]) {         ret = min(ret, mid);         en = mid - 1;       } else         st = mid + 1;     }     return ret;   }   int dp[MX];   int solve(int x) {     if (x < 1) return 0;     if (dp[x] != -1) return dp[x];     int ans = 1e8;     int id = ID(x, 1439);     if (id < x) ans = min(ans, 120 + solve(id - 1));     id = ID(x, 89);     if (id < x) ans = min(ans, 50 + solve(id - 1));     ans = min(ans, 20 + solve(x - 1));     return dp[x] = ans;   }   int main() {     cin >> n;     memset(dp, -1, sizeof dp);     long long ans = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , t + i);       cout << solve(i) - ans << endl;       ans = solve(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n, m, x1, y1, x2, y2, count = 0;     cin >> n >> m;     vector<char> v[n];     for (long long int i = 0; i < n; i++) {       for (long long int j = 0; j < m; j++) {         char x;         cin >> x;         v[i].push_back(x);         if (count == 0 && x ==  B ) {           x1 = i + 1, y1 = j + 1;           count++;         }         if (count > 0 && x ==  B ) {           x2 = i + 1, y2 = j + 1;         }       }     }     cout << (x1 + x2) / 2 <<     << (y1 + y2) / 2;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     long long n = s.size();     for (long long i = 0; i < n; i++) {       if (s[i] ==  r ) {         cout << i + 1 <<   n ;       }     }     for (long long i = n - 1; i >= 0; i--) {       if (s[i] ==  l ) {         cout << i + 1 <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   const long long int MOD = 998244353;   class Combination {     long long int ppow(long long int i, long long int j) {       long long int res = 1LL;       while (j) {         if ((j & 1LL)) {           res *= i;           if (res >= MOD) {             res %= MOD;           }         }         j >>= 1;         i *= i;         if (i >= MOD) {           i %= MOD;         }       }       return res;     }       public:     vector<long long int> k;     vector<long long int> r;     void resize(int N) {       k.resize(N + 2);       r.resize(N + 2);       k[0] = 1;       for (int i = 1; i < N + 2; i++) {         k[i] = k[i - 1];         k[i] *= i;         if (k[i] >= MOD) k[i] %= MOD;       }       long long int al = k[k.size() - 1];       long long int iv = ppow(k[k.size() - 1], MOD - 2);       r[k.size() - 1] = iv;       for (int i = (int)(r.size()) - 2; i >= 0; i--) {         r[i] = r[i + 1] * (i + 1);         if (r[i] >= MOD) {           r[i] %= MOD;         }       }     }     long long int C(int a, int b) {       if (a < b) return 0;       long long int up = k[a];       long long int dw = r[b] * r[a - b];       dw %= MOD;       up *= dw;       up %= MOD;       return up;     }     long long int H(int a, int b) { return C(a + b - 1, b); }     long long int catalan_number(int n) {       return (C(2 * n, n) + MOD - C(2 * n, n - 1)) % MOD;     }   } c;   int main() {     cin >> n;     c.resize(2000000);     long long int subt = 0;     for (int i = 1; i < n; i++) {       long long int way = c.C(n, i);       way *= c.k[n - i];       way %= MOD;       subt += way;       if (subt >= MOD) subt %= MOD;     }     long long int whole = c.k[n];     whole *= n;     whole %= MOD;     whole += MOD;     whole %= MOD;     whole += MOD - subt;     whole %= MOD;     printf( %lld n , whole);     return 0;   }
#include<bits/stdc++.h>   using namespace std;      int t,n;       char a[300005],b[300005],c[300005];      void solve(char *x,char *y,int tmp) {   // for(int i=1;i<=n*2;i++) cout<<x[i];   // for(int j=1;j<=n*2;j++) cout<<y[j];   // cout<< ! <<endl;   // cout<<tmp<<endl;    int l1=1,l2=1;    for(int i=1;i<=n*3;i++) {     if(l1>n*2 && l2>n*2) cout<< 0 ;     else if(l1>n*2) cout<<y[l2],l2++;     else if(l2>n*2) cout<<x[l1],l1++;     else if(x[l1]==y[l2]) cout<<x[l1],l1++,l2++;     else {   //   cout<<x[l1]<<   <<y[l2]<<endl;      if(x[l1]==tmp+ 0 ) cout<<y[l2],l2++;      else cout<<x[l1],l1++;     }    }    cout<<endl;   // exit(0);   }      int main(){    cin>>t;    while(t--) {     cin>>n>>a+1>>b+1>>c+1;     int a1=0,a2=0,a3=0,b1=0,b2=0,b3=0;     for(int i=1;i<=n*2;i++) {      if(a[i]== 1 ) a1++;      else b1++;      if(b[i]== 1 ) a2++;      else b2++;      if(c[i]== 1 ) a3++;      else b3++;        }     if(a1>=n && a2>=n) solve(a,b,1);     else if(a1>=n && a3>=n) solve(a,c,1);     else if(a2>=n && a3>=n) solve(b,c,1);     else if(b1>=n && b2>=n) solve(a,b,0);     else if(b1>=n && b3>=n) solve(a,c,0);     else if(b2>=n && b3>=n) solve(b,c,0);    }               }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, x, y;   long long b[100005], c[100005];   int a[100005], l[100005], r[100005], d[100005];   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= m; i++) cin >> l[i] >> r[i] >> d[i];     for (int i = 1; i <= k; i++) {       cin >> x >> y;       c[x]++;       c[y + 1]--;     }     for (int i = 1; i <= m; i++) c[i] += c[i - 1];     for (int i = 1; i <= m; i++) {       b[l[i]] += d[i] * c[i];       b[r[i] + 1] -= d[i] * c[i];     }     for (int i = 1; i <= n; i++) {       b[i] += b[i - 1];       cout << a[i] + b[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int v[100000], c[100000], l[100000], r[100000];   vector<int> g[300001];   int d[200001] = {};   vector<int> p[200001], pp[200001], px[200001];   vector<int> t;   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < (int)(n); ++i) cin >> v[i] >> c[i] >> l[i] >> r[i];     for (int i = 0; i < (int)(n); ++i) g[c[i] + l[i] + r[i]].push_back(i);     int ans = 0;     for (int i = 0; i < (int)(200001); ++i)       if (!g[i].empty()) {         for (int x : g[i])           if ((!l[x] || d[l[x]]) && d[l[x] + c[x]] < d[l[x]] + v[x]) {             d[l[x] + c[x]] = d[l[x]] + v[x];             p[l[x] + c[x]].push_back(l[x]);             pp[l[x] + c[x]].push_back((int)p[l[x]].size() - 1);             px[l[x] + c[x]].push_back(x);           }         int ind = i;         if (d[ind] > ans) {           int pind = (int)p[ind].size() - 1;           ans = d[ind];           t.clear();           while (ind) {             t.push_back(px[ind][pind]);             int nind = p[ind][pind];             pind = pp[ind][pind];             ind = nind;           }         }         for (int x : g[i]) {           int pos = l[x] + c[x];           d[pos] = 0;           p[pos].clear();           pp[pos].clear();           px[pos].clear();         }       }     cout << (int)t.size() <<   n ;     for (int i = (int)t.size() - 1; i >= 0; --i) cout << t[i] + 1 <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<long long> mod;   int main() {     long long n, k;     scanf( %I64d%I64d , &n, &k);     bool result = true;     for (long long i = 1LL; i <= k; i++) {       long long x = n % i;       if (mod.find(x) != mod.end()) {         result = false;         break;       }       mod.insert(x);     }     printf( %s n , result ?  Yes  :  No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long lim;   long long n, mod;   int m;   inline long long F(long long a, long long d, long long want, long long n) {     if (want == 0 or lim < a) {       return 0;     }     if (n == want) {       n = min(n, (lim - a) / d + 1);       long long z = 2 * a + (n - 1) * d;       ((z & 1) ? n : z) >>= 1;       return (n % mod) * (z % mod) % mod;     }     long long mid = (n + 1) >> 1;     if (want <= mid) {       return F(a, d << 1, want, mid);     }     return (F(a, d << 1, mid, mid) + F(a + d, d << 1, want - mid, n - mid)) % mod;   }   inline long long cal(long long r, long long v) {     lim = min(v, n);     return F(1, 1, r, n);   }   int main() {     scanf( %I64d %d %I64d , &n, &m, &mod);     for (; m-- > 0;) {       long long l, r, u, v;       scanf( %I64d %I64d %I64d %I64d , &l, &r, &u, &v);       l--, u--;       printf( %I64d n ,              (((cal(r, v) - cal(l, v)) - (cal(r, u) - cal(l, u))) % mod + mod) %                  mod);     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300000 + 100;   int p[maxn << 2];   void pushdown(int L, int R, int u) {     if (L != R) {       if (p[u] != -1) {         p[u << 1] = p[u];         p[u << 1 | 1] = p[u];         p[u] = -1;       }     }   }   void update(int cL, int cR, int val, int L, int R, int u) {     pushdown(L, R, u);     if (cL <= L && R <= cR) {       p[u] = val;     } else {       int m = (L + R) / 2;       if (cR <= m)         update(cL, cR, val, L, m, u << 1);       else if (cL > m)         update(cL, cR, val, m + 1, R, u << 1 | 1);       else {         update(cL, cR, val, L, m, u << 1);         update(cL, cR, val, m + 1, R, u << 1 | 1);         update(cL, cR, val, m + 1, R, u << 1 | 1);       }     }   }   int query(int x, int L, int R, int u) {     pushdown(L, R, u);     if (L == R)       return p[u];     else {       int m = (L + R) / 2;       if (x <= m)         return query(x, L, m, u << 1);       else         return query(x, m + 1, R, u << 1 | 1);     }   }   vector<int> G[maxn];   int res[maxn];   int sum[maxn];   int n;   void dfs(int u) {     sum[u]++;     int Max = 0;     for (int i = 0; i < G[u].size(); ++i) {       int v = G[u][i];       dfs(v);       sum[u] += sum[v];       Max = max(Max, sum[v]);     }     update(Max, sum[u], u, 0, n, 1);     res[u] = query(sum[u] / 2, 0, n, 1);   }   int main() {     int q;     scanf( %d %d , &n, &q);     for (int i = 2; i <= n; ++i) {       int t;       scanf( %d , &t);       G[t].push_back(i);     }     memset(p, -1, sizeof(p));     memset(sum, 0, sizeof(sum));     dfs(1);     while (q--) {       int t;       scanf( %d , &t);       printf( %d n , res[t]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;      int main()   {       ios_base::sync_with_stdio(0); cin.tie(0);       long long cases, no_points, xcoord, ycoord;       cin >> cases;       for (int i = 0; i < cases; i++)       {           vector <long long> xpoints;           vector <long long> ypoints;                      long long choicesx,choicesy = 1;                     cin >> no_points;           for (int x = 0; x < no_points; x++)           {               cin >> xcoord >> ycoord;               xpoints.push_back(xcoord);               ypoints.push_back(ycoord);           }           if(no_points % 2 == 1){               cout << 1 <<   n ;           }              else{               sort(xpoints.begin(), xpoints.end());               sort(ypoints.begin(), ypoints.end());               choicesx = xpoints[(no_points/2)] - xpoints[(no_points/2) - 1] + 1;               choicesy = ypoints[(no_points/2)] - ypoints[(no_points/2) - 1] + 1;               cout << choicesx * choicesy <<   n ;           }                                        }              return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[4];   int check(int a, int b, int c, int d) {     int avg = a + b + c + d;     int med = b + c;     if (avg % 4 != 0 || med % 2 != 0) return 0;     if (avg / 4 == d - a && med / 2 == d - a) return 1;     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i <= n - 1; i++) cin >> a[i];     sort(a, a + n);     if (n == 0) {       cout <<  YES  << endl;       cout << 1 << endl << 1 << endl << 3 << endl << 3;       return 0;     }     if (n == 1) {       cout <<  YES  << endl;       cout << 3 * a[0] << endl;       cout << 2 * a[0] << endl;       cout << 2 * a[0];       return 0;     }     if (n <= 2) {       if (a[1] <= 3 * a[0]) {         cout <<  YES  << endl;         cout << 4 * a[0] - a[1] << endl;         cout << 3 * a[0];         return 0;       }       cout <<  NO ;       return 0;     }     if (n == 3) {       for (int i = 1; i <= 1000000; i++) {         int b[4] = {a[0], a[1], a[2], i};         sort(b, b + 4);         if (check(b[0], b[1], b[2], b[3]) == 1) {           cout <<  YES  << endl;           cout << i;           return 0;         }       }       cout <<  NO ;       return 0;     }     if (check(a[0], a[1], a[2], a[3]) == 0)       cout <<  NO ;     else       cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3fffffff;   const int maxn = 110;   char a[20];   int k;   int main() {     scanf( %s , a);     cin >> k;     int len = strlen(a);     for (int i = 0; i < len; ++i) {       int p = i;       for (int j = 1; j <= k && j + i < len; ++j)         if (a[i + j] > a[p]) p = i + j;       if (a[p] == a[i]) continue;       for (int j = p; j > i; --j) swap(a[j], a[j - 1]);       k -= p - i;       if (k <= 0) break;     }     printf( %s n , a);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, tt[40], qq[10];   long long int m[10][41];   vector<int> ss[10];   int check(int c, long long int s) {     if (c == k) return (s == 0) || ((s + (s & (-s))) == (1LL << n));     int i, z = ss[c].size() - qq[c] - __builtin_popcountll(s & m[c][0]);     s &= ~m[c][0], s |= m[c][z];     for (i = 0; i <= qq[c]; i++) {       if (!check(c + 1, s)) return 0;       if (i < qq[c]) s ^= (1LL << ss[c][z + i]);     }     return 1;   }   int main() {     int i, j;     int q;     cin >> n >> k;     for (i = 0; i < n; i++) tt[i] = -1;     for (i = 0; i < k; i++) {       cin >> q;       ss[i].resize(q);       for (j = 0; j < q; j++) {         cin >> ss[i][j], ss[i][j]--;         if (tt[ss[i][j]] == -1) tt[ss[i][j]] = i;       }     }     if (n == 1) {       cout <<  ACCEPTED  << endl;       return 0;     }     for (i = 0; i < n; i++) {       if (tt[i] == -1) {         cout <<  REJECTED  << endl;         return 0;       } else         qq[tt[i]]++;     }     for (i = 0; i < k; i++) {       long long int a = 0;       for (j = 0; j < ss[i].size(); j++) a |= (1LL << ss[i][j]);       for (j = 0; j <= ss[i].size(); j++) {         m[i][j] = a;         if (j < ss[i].size()) a ^= (1LL << ss[i][j]);       }     }     if (check(0, 0))       cout <<  ACCEPTED  << endl;     else       cout <<  REJECTED  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, num[100001], mxn, contador;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> num[i];     }     if (n == 1) {       cout << 1;       return 0;     }     for (int i = 2; i < n; i++) {       if (num[i] == num[i - 1] + num[i - 2])         contador++;       else {         mxn = max(mxn, contador);         contador = 0;       }     }     if (contador < mxn)       cout << mxn + 2;     else       cout << contador + 2;   }