malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const int N = 500;   using namespace std;   int n, yh, yhuo = 0, huo = 0, yu, x = 0, y;   char pd;   int main() {     y = 1023;     x = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       cin >> pd >> yh;       if (pd ==  & ) x &= yh, y &= yh;       if (pd ==  | ) x |= yh, y |= yh;       if (pd ==  ^ ) x ^= yh, y ^= yh;     }     huo = 0;     yhuo = 0;     for (int i = 0; i <= 9; i++) {       int a = x & (1 << i), b = y & (1 << i);       if (a && b == 0) yhuo |= (1 << i);       if (a == 0 && b == 0) huo |= (1 << i), yhuo |= (1 << i);       if (a && b) huo |= (1 << i);     }     printf( 2 n );     printf( | %d n^ %d n , huo, yhuo);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     string ss, tt;     cin >> ss >> tt;     int l = ss.size();     vector<int> s(30);     vector<int> t(30);     for (int i = 0; i < l; i++) {       s[ss[i] -  a ]++;       t[tt[i] -  a ]++;     }     bool ok = false;     for (int i = 0; i < s.size(); i++) {       if (s[i] && t[i]) {         ok = true;       }     }     cout << (ok ?  YES n  :  NO n );     return;   }   int main() {     int q;     cin >> q;     while (q--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000;   int pre[maxn];   int countlen(int i) {     int ans = 0, p;     for (p = i; p != -2; p = pre[p]) ans++;     return ans;   }   int main() {     int i, n;     cin >> n;     for (i = 0; i < n; i++) cin >> pre[i], pre[i]--;     int ans = 0;     for (i = 0; i < n; i++) ans = max(ans, countlen(i));     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100004;   long long int a[MAXN];   long long int k, n;   vector<long long int> b(MAXN, 0);   long long int f(double num) {     long long int res = 0;     for (int i = 0; i < n; i++) {       if (num > a[i] + 0.25) {         b[i] = 0;         continue;       }       double tem = sqrt(12 * (a[i] - num) - 3);       b[i] = (long long int)(tem / 6 + 0.5);       if (b[i] > a[i]) b[i] = a[i];       res += b[i];     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     double mid;     double lo = -3e18, hi = 1e9;     for (int i = 0; i < 200; i++) {       mid = (lo + hi) / 2;       if (f(mid) >= k)         lo = mid;       else         hi = mid;     }     long long int tot = 0;     priority_queue<pair<long long int, int>, vector<pair<long long int, int> >,                    greater<pair<long long int, int> > >         pq;     priority_queue<pair<long long int, int> > pq1;     for (int i = 0; i < n; i++) {       double tem = sqrt(12 * (a[i] - lo) - 3);       b[i] = min((long long int)(tem / 6 + 0.5), a[i]);       tot += b[i];       if (b[i]) pq.push({a[i] - 3 * b[i] * b[i] + 3 * b[i] - 1, i});       if (b[i] != a[i]) pq1.push({a[i] - 3 * b[i] * b[i] - 3 * b[i] - 1, i});     }     while (tot - k > 0) {       pair<long long int, int> tem = pq.top();       pq.pop();       int i = tem.second;       b[i]--;       tem.first = a[i] - 3 * b[i] * b[i] + 3 * b[i] - 1;       pq.push(tem);       tot--;     }     for (int i = 0; i < n; i++) {       int bu = b[i];       printf( %d  , bu);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int bl = 400, sz = 4e5 + 10;   int pr[sz], bor[sz][26], cnt[sz], an[sz], q = 1;   char prsy[sz];   vector<pair<int, int> > sp[sz];   vector<int> sv[sz];   void dfs(int v) {     int u = v, s = 0;     for (int a = 0; (a < bl and u != 0 and s != -1); a++) {       s = bor[s][prsy[u] -  a ];       if (s != -1) cnt[s]++;       u = pr[u];     }     for (int a = 0; a < sp[v].size(); a++) {       int s = sp[v][a].first, nu = sp[v][a].second;       an[nu] = cnt[s];     }     for (int a = 0; a < sv[v].size(); a++) {       dfs(sv[v][a]);     }     u = v, s = 0;     for (int a = 0; (a < bl and u != 0 and s != -1); a++) {       s = bor[s][prsy[u] -  a ];       if (s != -1) cnt[s]--;       u = pr[u];     }   }   int f(string &s, int le) {     int n = s.size(), re = 0;     int zf[n], l = 0, r = -1;     zf[0] = 0;     for (int a = 1; a < n; a++) {       zf[a] = 0;       if (r >= a) zf[a] = min(zf[a - l], r - a + 1);       while (a + zf[a] < n) {         if (s[zf[a]] == s[a + zf[a]])           zf[a]++;         else           break;       }       if (a + zf[a] - 1 > r) l = a, r = a + zf[a] - 1;       if (zf[a] == le) re++;     }     return re;   }   int main() {     int n;     cin >> n;     for (int a = 1; a <= n; a++) {       int ty;       scanf( %d , &ty);       if (ty == 2) scanf( %d , &pr[a]);       scanf( %s , prsy + a);       sv[pr[a]].push_back(a);     }     int m;     cin >> m;     for (int a = 0; a < 26; a++) bor[0][a] = -1;     for (int a = 0; a < m; a++) {       int v;       scanf( %d , &v);       string st;       cin >> st;       reverse(st.begin(), st.end());       if (st.size() < bl) {         int s = 0;         for (int b = 0; b < st.size(); b++) {           int ne = st[b] -  a ;           if (bor[s][ne] == -1) {             bor[s][ne] = q++;             for (int i = 0; i < 26; i++) bor[q - 1][i] = -1;           }           s = bor[s][ne];         }         sp[v].push_back({s, a});       } else {         int l = st.size();         st.push_back( # );         while (v) {           st.push_back(prsy[v]), v = pr[v];         }         an[a] = f(st, l);       }     }     dfs(0);     for (int a = 0; a < m; a++) printf( %d n , an[a]);   }
#include <bits/stdc++.h>   using namespace std;   bool vis[101];   vector<int> a[101];   void dfs(int x) {     vis[x] = true;     for (int i = 0; i < a[x].size(); i++)       if (!vis[a[x][i]]) dfs(a[x][i]);   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       a[x].push_back(y);       a[y].push_back(x);     }     dfs(1);     if (*min_element(vis + 1, vis + n + 1) && m == n)       cout <<  FHTAGN! ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   const int MOD = 1000000007;   const int Inv2 = 500000004;   inline int mul(int x, int y) { return (long long)x * (long long)y % MOD; }   inline int add(int x, int y) {     int r = x + y;     if (r >= MOD) r -= MOD;     return r;   }   inline int qpow(int a, int p) {     int x = a, ans = 1;     while (p) {       if (p & 1) ans = mul(ans, x);       x = mul(x, x);       p >>= 1;     }     return ans;   }   using namespace std;   template <typename T>   inline void read(T &x) {     char ch;     while ((ch = getchar()), (ch <  0  || ch >  9 ))       ;     x = ch -  0 ;     while ((ch = getchar()), (ch >=  0  && ch <=  9 )) x = x * 10 + (ch -  0 );   }   inline int readbin(int *str) {     char ch;     int len = 1;     while ((ch = getchar()), (ch <  0  || ch >  1 ))       ;     *(str++) = ch -  0 ;     while ((ch = getchar()), (ch >=  0  && ch <=  1 )) *(str++) = ch -  0 , len++;     return len;   }   void fwt(int A[], int n) {     int i, h, k, A0, A1;     for (h = 2; h <= n; h <<= 1) {       for (i = 0; i < n; i += h) {         for (k = i; k < i + (h / 2); k++) {           A0 = A[k];           A1 = A[k + (h / 2)];           A[k] = (A0 + A1) % MOD;           A[k + (h / 2)] = (A0 - A1) % MOD;         }       }     }   }   void ifwt(int A[], int n) {     int i, h, k, A0, A1;     for (h = 2; h <= n; h <<= 1) {       for (i = 0; i < n; i += h) {         for (k = i; k < i + (h / 2); k++) {           A0 = A[k];           A1 = A[k + (h / 2)];           A[k] = mul(Inv2, A0 + A1);           A[k + (h / 2)] = mul(Inv2, A0 - A1);         }       }     }   }   const int MAXN = 5 + (1 << 20);   int A[MAXN], P[MAXN];   int N, NB;   int main() {     int i;     read(NB);     N = readbin(A);     fwt(A, N);     for (i = 0; i < N; i++) P[i] = mul(A[i], A[i]);     ifwt(P, N);     int Ans = 0;     for (i = 0; i < N; i++)       Ans = add(Ans, mul(P[i], 1 << (NB - __builtin_popcount(i))));     Ans = mul(Ans, 3);     printf( %d , Ans);   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t, n, m, i, j, k, sum = 0;     long long int p, w, d;     cin >> n >> p >> w >> d;     long long int l = 0;     long long int r = n;     for (i = 0; i <= w; i++) {       long long int temp = p - i * d;       if (temp < 0) break;       if ((temp) % w != 0) continue;       long long int q = temp / w;       if (i + q <= n) {         cout << q <<     << i <<     << n - q - i <<   n ;         return 0;       }     }     cout << -1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   int main() {     int q;     int a[510][2];     int m = 0;     int l1, r1, l2, r2;     int flag;     scanf( %d , &q);     for (int i = 0; i < q; i++) {       scanf( %d%d%d%d , &l1, &r1, &l2, &r2);       flag = 0;       for (int j = l1; j <= r1; j++) {         a[m][0] = j;         for (int k = l2; k <= r2; k++) {           if (j != k) {             flag = 1;             a[m][1] = k;             break;           }         }         if (flag == 1) {           m++;           break;         }       }     }     for (int i = 0; i < q; i++) printf( %d %d n , a[i][0], a[i][1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long modpow(long long a, long long b,                    long long mod = (long long)(1e9 + 7)) {     if (!b) return 1;     a %= mod;     return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int mxn = 1e6 + 4, mxk = 20;   int n, q;   int d[mxn], parent[mxn][mxk];   void add(int i, int p) {     parent[i][0] = p;     d[i] = d[p] + 1;     for (int j = 0; j < mxk; j++)       if (j) parent[i][j] = parent[parent[i][j - 1]][j - 1];   }   int lca(int i, int j) {     if (d[i] > d[j]) swap(i, j);     int diff = d[j] - d[i];     for (int k = mxk - 1; k >= 0; k--)       if (diff & (1 << k)) j = parent[j][k];     if (i == j) return i;     for (int k = mxk - 1; k >= 0; k--)       if (parent[i][k] != parent[j][k]) i = parent[i][k], j = parent[j][k];     return parent[i][0];   }   int dist(int i, int j) { return d[i] + d[j] - 2 * d[lca(i, j)]; }   void solve() {     for (int j = 0; j < mxk; j++) parent[0][j] = 0;     d[0] = 0;     add(1, 0);     add(2, 0);     add(3, 0);     scanf( %d , &q);     n = 4;     stringstream ss;     int a = 1, b = 2;     int best = dist(a, b);     for (int _ = 0; _ < q; _++) {       int x;       scanf( %d , &x);       x--;       add(n++, x);       add(n++, x);       int d1 = dist(a, n - 1), d2 = dist(b, n - 1);       if (max(d1, d2) > best) {         best = max(d1, d2);         if (d1 > d2)           b = n - 1;         else           a = n - 1;       }       ss << best << endl;     }     cout << ss.str();   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int k;       string s;       cin >> k >> s;       s +=  A ;       vector<int> a;       for (int i = 0; i < s.size(); i++) {         if (s[i] ==  A ) a.push_back(i);       }       int ans = 0;       for (int i = 0; i + 1 < a.size(); i++) {         ans = max(ans, a[i + 1] - a[i] - 1);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1e9 + 7;   long long x, k;   long long qow(long long a, long long b) {     long long ans = 1;     a = a % mod;     while (b) {       if (b % 2 == 1) {         ans = (ans * a) % mod;       }       a = (a * a) % mod;       b /= 2;     }     return ans;   }   int main() {     while (~scanf( %lld %lld , &x, &k)) {       if (x == 0) {         printf( 0 n );         continue;       }       x = x % mod;       cout << (((2 * x - 1) * qow(2, k) + mod) % mod + 1 + mod) % mod << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   struct node {     long long x, y;   } s, t, dist[100005];   int dx[4] = {0, 0, -1, 1};   int dy[4] = {1, -1, 0, 0};   char wind[100005];   string mov =  UDLR ;   long long pos, l, r, mid;   bool check(long long mid) {     long long zq = mid / n, sy = mid % n;     long long x = s.x + zq * dist[n].x + dist[sy].x;     long long y = s.y + zq * dist[n].y + dist[sy].y;     long long dis = abs(t.x - x) + abs(t.y - y);     return dis <= mid;   }   int main() {     cin >> s.x >> s.y >> t.x >> t.y;     cin >> n >> wind;     for (int i = 0; i < n; i++) {       pos = -1;       for (int j = 0; j < 4; j++) {         if (wind[i] == mov[j]) pos = j;       }       dist[i + 1].x = dist[i].x + dx[pos];       dist[i + 1].y = dist[i].y + dy[pos];     }     l = 0, r = 1e15;     while (l <= r) {       mid = (l + r) >> 1;       if (check(mid)) {         r = mid - 1;       } else {         l = mid + 1;       }     }     if (l > 1e15)       cout << -1 << endl;     else       cout << l << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     char c = getchar();     bool flag = false;     while (!isdigit(c)) {       if (c ==  - ) flag = true;       c = getchar();     }     while (isdigit(c)) {       x = (x << 1) + (x << 3) + (c ^ 48);       c = getchar();     }     if (flag) x = -x;   }   int n, lenth, las = 1, root = 1, tot = 1;   long long ans;   int ch[1000010][26], fa[1000010], len[1000010], siz[1000010][15], l[1000010],       r[1000010];   char s[1000010], str[1000010];   struct edge {     int to, nxt;   } e[1000010];   int head[1000010], edge_cnt;   void add(int from, int to) {     e[++edge_cnt] = (edge){to, head[from]};     head[from] = edge_cnt;   }   void insert(int c, int id) {     int p = las, np = las = ++tot;     len[np] = len[p] + 1, siz[np][id] = 1;     while (p && !ch[p][c]) ch[p][c] = np, p = fa[p];     if (!p)       fa[np] = root;     else {       int q = ch[p][c];       if (len[q] == len[p] + 1)         fa[np] = q;       else {         int nq = ++tot;         memcpy(ch[nq], ch[q], sizeof(ch[q]));         len[nq] = len[p] + 1, fa[nq] = fa[q], fa[q] = fa[np] = nq;         while (ch[p][c] == q) ch[p][c] = nq, p = fa[p];       }     }   }   void dfs(int x) {     for (int i = head[x]; i; i = e[i].nxt) {       int y = e[i].to;       dfs(y);       for (int j = 0; j <= n; ++j) siz[x][j] += siz[y][j];     }   }   void calc(int x) {     if (!siz[x][0]) return;     for (int i = 1; i <= n; ++i)       if (siz[x][i] < l[i] || siz[x][i] > r[i]) return;     ans += len[x] - len[fa[x]];   }   int main() {     scanf( %s , str + 1), lenth = strlen(str + 1);     for (int i = 1; i <= lenth; ++i) insert(str[i] -  a , 0);     read(n);     for (int i = 1; i <= n; ++i) {       las = 1, scanf( %s , s + 1), lenth = strlen(s + 1), read(l[i]), read(r[i]);       for (int j = 1; j <= lenth; ++j) insert(s[j] -  a , i);     }     for (int i = 2; i <= tot; ++i) add(fa[i], i);     dfs(root);     for (int i = 2; i <= tot; ++i) calc(i);     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e5 + 69;   const long long Inf = 1e13;   long long n, newa[maxn], ans[maxn], newb[maxn];   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (long long i = 2; i <= n; i += 2) cin >> ans[i];     for (long long i = 2; i <= n; i += 2) {       long long found = 0;       for (long long j = sqrt(ans[i]); j >= 1; j--)         if (ans[i] % j == 0) {           long long newj = ans[i] / j;           if (!((j + newj) & 1)) {             newa[i] = (newj + j) / 2;             newb[i] = (newj - j) / 2;             if (newb[i] <= newa[i - 2]) continue;             found = 1;             break;           }         }       if (!found) return cout <<  No , 0;     }     for (long long i = 1; i <= n; i++) {       if (i & 1) {         ans[i] = (newb[i + 1] - newa[i - 1]) * (newb[i + 1] + newa[i - 1]);         if (ans[i] > Inf) return cout <<  No , 0;       }     }     cout <<  Yes  <<   n ;     for (long long i = 1; i <= n; i++) cout << ans[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int la, lb;   int a[2000000];   int b[2000000];   int bpos[1000001];   void deb(int* x, int xlow, int xhigh) {     cout <<  [ ;     for (int i = xlow; i < xhigh; i++) {       cout <<     << x[i];     }     cout <<   ] ;   }   int seen[1000001];   int solve() {     fill(bpos, bpos + 1000001, -1);     for (int i = 0; i < lb; i++) {       bpos[b[i]] = i;     }     int res = 0;     for (int i = la; i < la * 2; i++) {       a[i] = a[i - la];     }     int alow = -1;     int ahigh = alow + la;     int blow = -1;     int last = -1;     int len = 0;     fill(seen, seen + 1000001, 0);     int steps = 0;     for (int i = 0; i < la; i++) {       alow++;       ahigh++;       len = max(len - 1, 0);       if (len == 0) {         if (bpos[a[alow]] != -1) {           blow = bpos[a[alow]];         } else {           blow += lb - 1;           if (blow >= lb) {             blow -= lb;           }         }         last = -1;       } else {         blow = bpos[a[alow]];       }       while (len < la) {         int y = bpos[a[alow + len]];         bool good = false;         if ((y != -1) && (last != -1)) {           if (y < blow) {             if (last < blow) {               good = (y > last);             } else {               good = (y > last - lb);             }           } else {             if (last >= blow) {               good = (y > last);             } else {               good = (y - lb > last);             }           }         } else if (y != -1) {           good = true;         }         if (good) {           seen[a[alow + len]]++;           assert(seen[a[alow + len]] <= 2);           last = y;           steps++;           assert(steps < 4000000);           len++;         } else {           break;         }       }       res = std::max(res, len);     }     return res;   }   inline void init() {}   int main() {     init();     ios_base::sync_with_stdio(0);     bool prev = false;     while (cin >> la >> lb) {       if (prev) {         cout << endl;       }       prev = true;       for (int i = 0; i < la; i++) {         cin >> a[i];       }       for (int i = 0; i < lb; i++) {         cin >> b[i];       }       cout << solve() << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct data {     string name;     int score;     data() {}     data(string name, int score) : name(name), score(score) {}     const bool operator<(const data& other) const {       if (score != other.score) return score > other.score;       return name < other.name;     }     const bool operator==(const data& other) const { return name == other.name; }   };   data vasya;   int n, m, b[100005];   int best(vector<data> v) {     sort(b, b + m);     reverse(b, b + m);     v.erase(find(v.begin(), v.end(), vasya));     sort(v.rbegin(), v.rend());     v.insert(v.begin(), vasya);     for (int i = 0; i < m; i++) v[i].score += b[i];     sort(v.begin(), v.end());     return find(v.begin(), v.end(), vasya) - v.begin() + 1;   }   int worst(vector<data> v) {     multiset<int> S;     multiset<int>::iterator it;     int idx;     for (int i = 0; i < m; i++) S.insert(b[i]);     idx = find(v.begin(), v.end(), vasya) - v.begin();     if (m == n) v[idx].score += *S.begin(), S.erase(S.begin());     sort(v.begin(), v.end());     idx = find(v.begin(), v.end(), vasya) - v.begin();     for (int i = idx + 1; i < (int)v.size() && S.size(); i++) {       int add;       if (v[i].name < vasya.name)         add = v[idx].score - v[i].score;       else         add = v[idx].score - v[i].score + 1;       it = S.lower_bound(add);       if (it == S.end()) continue;       v[i].score += *it;       S.erase(it);     }     sort(v.begin(), v.end());     return find(v.begin(), v.end(), vasya) - v.begin() + 1;   }   int main() {     cin >> n;     vector<data> v(n);     for (int i = 0; i < n; i++) cin >> v[i].name >> v[i].score;     cin >> m;     for (int i = 0; i < m; i++) cin >> b[i];     cin >> vasya.name;     vasya.score = v[find(v.begin(), v.end(), vasya) - v.begin()].score;     int place1 = best(v);     int place2 = worst(v);     cout << place1 <<     << place2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   vector<vector<vector<int> > > dp;   vector<vector<int> > tmp;   vector<vector<int> > base;   int get_dig(int pos, int k) {     return (pos < k) ? pos : (get_dig(pos / k, k) + pos % k) % k;   }   inline int get_val(const vector<vector<int> > &a, int i, int j, int shift,                      int k) {     if (i == k && j < k) {       return a[k][(j + k - shift) % k];     }     return a[(i + k - shift) % k][(j + k - shift) % k];   }   vector<vector<int> > shift(const vector<vector<int> > &a, int shift) {     int k = int(a.size()) - 1;     vector<vector<int> > res = a;     for (int i = 0; i <= k; ++i) {       for (int j = 0; j < k; ++j) {         res[i][j] = get_val(a, i, j, shift, k);       }     }     return res;   }   vector<vector<int> > operator*(const vector<vector<int> > &a,                                  const vector<vector<int> > &b) {     int n = int(a.size()), k = int(a[0].size()), m = int(b[0].size());     vector<vector<int> > res(n, vector<int>(m, 0));     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         for (int l = 0; l < k; ++l) {           res[i][j] = (res[i][j] + 1ll * a[i][l] * b[l][j]) % MOD;         }       }     }     return res;   }   int main() {     long long n;     int k;     cin >> n >> k;     int max_depth = 0;     {       long long tmp = n;       while (tmp != 0) {         ++max_depth;         tmp /= k;       }     }     dp.resize(max_depth);     {       dp[0].assign(k + 1, vector<int>(k + 1, 0));       for (int i = 0; i <= k; ++i) {         for (int j = 0; j <= k; ++j) {           dp[0][i][j] = (i == j || j == 0);         }       }       vector<vector<int> > e(k + 1, vector<int>(k + 1, 0));       for (int i = 0; i <= k; ++i) {         e[i][i] = 1;       }       for (int depth = 1; depth < max_depth; ++depth) {         dp[depth] = e;         vector<vector<int> > bs = dp[depth - 1];         vector<vector<int> > &res = dp[depth];         int curx = k;         for (int i = 0; (1 << i) <= curx; ++i) {           if (curx & (1 << i)) {             res = bs * shift(res, (1 << i));             curx ^= (1 << i);           }           bs = bs * shift(bs, (1 << i));         }       }     }     base.assign(1, vector<int>(k + 1, 0));     base[0][k] = 1;     int sl = 0;     long long x = n;     vector<int> vec;     while (x != 0) {       vec.push_back(x % k);       x /= k;     }     int len = int(vec.size());     for (int cur_depth = len - 1; cur_depth >= 0; --cur_depth) {       int rest = vec[cur_depth];       for (int it = 0; it < rest; ++it, sl = (sl + 1) % k) {         base = base * shift(dp[cur_depth], sl);       }     }     {       int res = 0;       for (int i = 0; i <= k; ++i) {         res = (res + base[0][i]) % MOD;       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 10001;   long long a[MAXN];   int f[MAXN];   long long c[MAXN], b[MAXN];   int n;   int main() {     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 0; i < n; ++i) {       long long X = a[i], cnt = 0;       while (!(X & 1)) {         ++cnt;         X >>= 1;       }       b[i] = X;       c[i] = cnt;     }     int ans = 0;     for (int i = 0; i < n; ++i) {       f[i] = 1;       for (int j = 0; j < i; ++j) {         if (a[j] % a[i] == 0 && a[i] % 2 == 1) f[i] = max(f[i], f[j] + 1);         if (a[i] % 2 == 0) {           long long t1 = b[j], t2 = b[i];           if (t1 % t2 == 0) {             if (c[i] - c[j] == i - j || c[i] <= i - j - 1)               f[i] = max(f[i], f[j] + 1);           }         }       }       if (f[i] > ans) ans = f[i];     }     cout << n - ans;     return 0;   }