malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100110;   const int maxm = 100010;   char s[maxn][5];   long long sum[maxm * 4][5][11];   int n;   void init() {     for (int i = 1; i < maxn; i++)       for (int z = 2; z <= 6; z++) {         int tp = i % (2 * (z - 1));         if (tp == 0)           s[i][z - 2] = 2;         else if (tp <= z)           s[i][z - 2] = tp;         else           s[i][z - 2] = 2 * z - tp;       }   }   void build(int pos, int l, int r) {     for (int i = 2; i <= 6; i++)       for (int j = 0; j <= 10; j++) sum[pos][i - 2][j] = 0;     if (l == r) return;     int mid = (l + r) >> 1;     build((pos << 1), l, mid);     build(((pos << 1) | 1), mid + 1, r);   }   void insert(int pos, int l, int r, int i, int a) {     if (i < l || i > r) return;     if (l == r) {       for (int z = 2; z <= 6; z++)         for (int j = 0; j <= 10; j++)           sum[pos][z - 2][j] = (long long)s[i + j][z - 2] * a;       return;     }     int mid = (l + r) >> 1;     insert((pos << 1), l, mid, i, a);     insert(((pos << 1) | 1), mid + 1, r, i, a);     for (int z = 2; z <= 6; z++)       for (int j = 0; j <= 10; j++)         sum[pos][z - 2][j] =             sum[(pos << 1)][z - 2][j] + sum[((pos << 1) | 1)][z - 2][j];   }   long long search(int pos, int l, int r, int x, int y, int z, int offset) {     if (y < l || r < x) return 0;     if (x <= l && r <= y) return sum[pos][z - 2][offset];     int mid = (l + r) >> 1;     return search((pos << 1), l, mid, x, y, z, offset) +            search(((pos << 1) | 1), mid + 1, r, x, y, z, offset);   }   int main() {     init();     while (~scanf( %d , &n)) {       build(1, 1, n);       for (int i = 1; i <= n; i++) {         int a;         scanf( %d , &a);         insert(1, 1, n, i, a);       }       int m;       scanf( %d , &m);       while (m-- > 0) {         int t, p, v, l, r, z;         scanf( %d , &t);         if (t == 1) {           scanf( %d%d , &p, &v);           insert(1, 1, n, p, v);         } else {           scanf( %d%d%d , &l, &r, &z);           int offset = 0;           if (s[l][z - 2] <= s[l + 1][z - 2]) {             if (s[l][z - 2] == 1)               offset = 0;             else               offset = z - s[l][z - 2] + z - 1;           } else {             offset = s[l][z - 2] - 1;           }           cout << search(1, 1, n, l, r, z, offset) << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     string s;     cin >> n;     getline(cin, s);     for (int i = 0; i < n; ++i) {       getline(cin, s);       int len = s.length();       if (len < 5)         cout <<  OMG>.< I don t know!  << endl;       else {         string prefix(s.substr(0, 5));         string suffix(s.substr(len - 5, 5));         if (prefix ==  miao.  && suffix ==  lala. )           cout <<  OMG>.< I don t know!  << endl;         else if (prefix ==  miao. )           cout <<  Rainbow s  << endl;         else if (suffix ==  lala. )           cout <<  Freda s  << endl;         else           cout <<  OMG>.< I don t know!  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int inf = 2e9 + 5;   const int N = 1e5;   int cost[26];   map<long long, long long> m[26];   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     for (int i = 0; i < 26; i++) cin >> cost[i];     string s;     cin >> s;     long long n = s.length(), sum = 0;     long long ans = 0;     for (int i = 0; i < n; i++) {       ans += m[s[i] -  a ][sum];       sum += cost[s[i] -  a ];       m[s[i] -  a ][sum] += 1;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void prv(vector<int> v) {     int n = v.size();     for (int i = 0; i < n; i++) cout << v[i] <<    ;   }   void swap(long long int &a, long long int &b) {     int tm = a;     a = b;     b = tm;   }   bool comp(const pair<int, int> &p1, const pair<int, int> &p2) {     if (p1.first > p2.first)       return 1;     else       return 0;   }   const int N = 3e5 + 5;   void findPrefix(string pattern, int m, int prefArray[]) {     int length = 0;     prefArray[0] = 0;     for (int i = 1; i < m; i++) {       if (pattern[i] == pattern[length]) {         length++;         prefArray[i] = length;       } else {         if (length != 0) {           length = prefArray[length - 1];           i--;         } else           prefArray[i] = 0;       }     }   }   int kmpPattSearch(string mainString, string pattern) {     int n, m, i = 0, j = 0, fr = 0;     n = mainString.size();     m = pattern.size();     int prefixArray[m];     findPrefix(pattern, m, prefixArray);     while (i < n) {       if (mainString[i] == pattern[j]) {         i++;         j++;       }       if (j == m) {         fr++;         j = prefixArray[j - 1];       } else if (i < n && pattern[j] != mainString[i]) {         if (j != 0)           j = prefixArray[j - 1];         else           i++;       }     }     return fr;   }   string crts(int d, int m, int y) {     string t;     t.clear();     while (y != 0) {       t.push_back(y % 10 +  0 );       y = y / 10;     }     t.push_back( - );     while (m != 0) {       t.push_back(m % 10 +  0 );       m = m / 10;     }     if (t.size() == 6) t.push_back( 0 );     t.push_back( - );     while (d != 0) {       t.push_back(d % 10 +  0 );       d = d / 10;     }     if (t.size() == 9) t.push_back( 0 );     reverse((t).begin(), (t).end());     return t;   }   void solve() {     string s, ans;     cin >> s;     int mx = 0;     for (int i = 2013; i < 2016; ++i) {       for (int j = 1; j <= 12; j++) {         int k;         if (j == 2)           k = 28;         else if (j == 1 || j == 3 || j == 5 || j == 7 || j == 8 || j == 10 ||                  j == 12)           k = 31;         else           k = 30;         for (int l = 1; l <= k; l++) {           string t;           int frq;           t = crts(l, j, i);           frq = kmpPattSearch(s, t);           if (frq > mx) {             mx = frq;             ans = t;           }         }       }     }     cout << ans;   }   signed int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       solve();       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   template <class T>   T SQR(const T &a) {     return a * a;   }   void run() {     char str[1000100];     scanf( %s , str);     int n = strlen(str);     int m;     cin >> m;     int A[10001];     int B[10001];     map<int, int> res;     char pat[100];     for (int i = (0), ei = (m); i < ei; i++) {       scanf(  %s , pat);       int mask = 0;       for (int j = (0), ej = (strlen(pat)); j < ej; j++)         mask |= 1 << (pat[j] -  a );       B[i] = A[i] = mask;     }     sort(B, B + m);     int Pos[26] = {0};     for (int i = (0), ei = (26); i < ei; i++) Pos[i] = -1;     int mask = 0, curr;     pair<int, int> P[26];     str[n] =  z  + 1;     for (int i = (0), ei = (n); i < ei; i++) {       mask |= 1 << (str[i] -  a );       Pos[str[i] -  a ] = i;       for (int j = (0), ej = (26); j < ej; j++) {         P[j].first = Pos[j];         P[j].second = j;       }       sort(P, P + 26);       curr = mask;       int next = 1 << (str[i + 1] -  a );       if (binary_search(B, B + m, mask) && (mask & next) == 0) res[mask]++;       for (int j = (0), ej = (25); j < ej; j++)         if (P[j].first != -1) {           curr &= ~(1 << P[j].second);           if (binary_search(B, B + m, curr) && (curr & next) == 0) res[curr]++;         }     }     for (int i = (0), ei = (m); i < ei; i++) printf( %d n , res[A[i]]);   }   int main() {     run();     return 0;   }
#include <bits/stdc++.h>       #define st first   #define nd second   #define pb push_back   #define BOOST ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);   #define PI 3.14159265359       using namespace std;       typedef long long ll;   constexpr ll MOD = 1000000007, sup = 29;   constexpr ll MOD_1 = 1234567891, sup_1 = 1009;   constexpr ll MOD_2 = 1000000009, sup_2 = 107;   constexpr int MXN = 200000+10, CZAPA = (1<<18), INF = 1000000000;      int n, m;      struct tree{    pair<int, int> tab[2*CZAPA+10];       void add(int leaf, int x){     int v = leaf + CZAPA;     tab[v] = {x, x};     v /= 2;     while(v >= 1){      tab[v].st = min(tab[2*v].st, tab[2*v+1].st);      tab[v].nd = max(tab[2*v].nd, tab[2*v+1].nd);      v /= 2;     }    }       pair<int, int> query(int a, int b, int v, int p, int q){     if(q < a || b < p)      return {INF, -INF};     if(p >= a && q <= b)      return tab[v];     int mid = (p+q)/2;     pair<int, int> x = query(a, b, 2*v, p, mid), y = query(a, b, 2*v+1, mid+1, q);     return {min(x.st, y.st), max(x.nd, y.nd)};    }       pair<int, int> query(int a, int b){     return query(a+CZAPA, b+CZAPA, 1, CZAPA, 2*CZAPA-1);    }   };      tree T;      int tab[MXN];         int main(){    BOOST;       int t;    cin>> t;    T.add(0, 0);    while(t--){     string s;      cin>> n >> m >> s;     for(int i=1; i<=n; i++){      tab[i] = tab[i-1];      if(s[i-1] ==  - )       tab[i]--;      else       tab[i]++;      T.add(i, tab[i]);      //cout<< tab[i] <<    ;     }     //cout<<   n ;     while(m--){      int a, b;      cin>> a >> b;      pair<int, int> x = T.query(0, a-1);      int sum = tab[b] - tab[a-1];      pair<int, int> y = T.query(b+1, n);      if(y.st == INF){       cout<< abs(x.st-x.nd)+1 <<   n ;       continue;      }      y.st -= sum;      y.nd -= sum;      pair<int, int> ans = {min(x.st, y.st), max(x.nd, y.nd)};      cout<< abs(ans.st-ans.nd)+1 <<   n ;      //cout<< x.st <<   ~   << x.nd <<  ,   << y.st <<   ~   << y.nd <<   n ;     }    }               return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fLL;   const double PI = acos(-1.0);   const double EPS = 1e-8;   const int MOD = 998244353;   template <typename T>   void cmin(T &x, T y) {     if (y < x) x = y;   }   template <typename T>   void cmax(T &x, T y) {     if (y > x) x = y;   }   long long qpow(long long x, long long n, long long mod = MOD) {     long long res = 1;     while (n) {       if (n & 1) res = res * x % mod;       x = x * x % mod;       n >>= 1;     }     return res;   }   namespace Solver {   void InitOnce() {}   int n, m, k;   int u[200005];   int v[200005];   int deg[200005];   vector<pair<int, int> > G[200005];   void Read() {     int res = scanf( %d%d%d , &n, &m, &k);     if (res == -1) exit(0);     for (int i = 1; i <= n; ++i) G[i].clear();     for (int i = 1; i <= m; ++i) {       scanf( %d%d , &u[i], &v[i]);       G[u[i]].emplace_back(v[i], i);       G[v[i]].emplace_back(u[i], i);     }     for (int i = 1; i <= n; ++i) deg[i] = G[i].size();   }   bool vis[200005];   int ans[200005];   bool inQ[200005];   queue<int> Q;   void delEdge(int u, int v, int id) {     if (vis[id]) return;     vis[id] = 1;     --deg[u];     --deg[v];     if (inQ[v] == 0 && deg[v] < k) {       Q.push(v);       inQ[v] = 1;     }   }   void delEdge2(int u, int v, int id) {     if (vis[id]) return;     vis[id] = 1;     --deg[u];     --deg[v];     if (inQ[u] == 0 && deg[u] < k) {       Q.push(u);       inQ[u] = 1;     }     if (inQ[v] == 0 && deg[v] < k) {       Q.push(v);       inQ[v] = 1;     }   }   void Solve() {     memset(vis, 0, sizeof(vis));     memset(ans, 0, sizeof(ans));     memset(inQ, 0, sizeof(inQ));     for (int i = 1; i <= n; ++i) {       if (deg[i] < k) {         Q.push(i);         inQ[i] = 1;       }     }     int cur = n;     while (!Q.empty()) {       int u = Q.front();       Q.pop();       --cur;       for (pair<int, int> &p : G[u]) {         int v = p.first, id = p.second;         delEdge(u, v, id);       }     }     for (int i = 1; i <= n; ++i) {       if (deg[i]) assert(deg[i] >= k);     }     ans[m] = cur;     for (int i = m - 1; i >= 0; --i) {       int de = i + 1;       delEdge2(u[de], v[de], de);       while (!Q.empty()) {         int u = Q.front();         Q.pop();         --cur;         for (pair<int, int> &p : G[u]) {           int v = p.first, id = p.second;           delEdge(u, v, id);         }       }       ans[i] = cur;     }     for (int i = 1; i <= n; ++i) {       assert(deg[i] == 0);       assert(inQ[i] == 1);     }     for (int i = 1; i <= m; ++i) assert(vis[i] == 1);     for (int i = 1; i <= m; ++i) printf( %d n , ans[i]);     return;   }   }  // namespace Solver   int main() {     Solver::InitOnce();     while (true) {       Solver::Read();       Solver::Solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long INF = 1e18;   const string nl =   n ;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(nullptr);     long long n, k;     cin >> n >> k;     vector<long long> a(n);     for (auto& i : a) {       cin >> i;     }     vector<long long> pref(n);     long long sum = 0, ans = 0;     bool ok = 0;     map<long long, long long> cnt;     cnt[0] = 1;     for (long long i = 0; i < n; ++i) {       if (a[i] > k) {         ++sum;       } else if (a[i] < k) {         --sum;       }       if (a[i] == k) {         ok = 1;       }       if (ok) {         ans += cnt[sum] + cnt[sum - 1];       } else {         ++cnt[sum];       }     }     cout << ans << nl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, cc = 0;     cin >> a >> b >> c;     if (a < 0 || b < 2 || c < 4)       cout << 0 << endl;     else {       while (a >= 1 && b >= 2 && c >= 4) {         cc++;         a--;         b -= 2;         c -= 4;       }       cout << cc * 7 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v[100001];   int main() {     int n;     cin >> n;     for (long long i = 1; i < n; i++) {       long long a, b;       cin >> a >> b;       v[a].push_back(b);       v[b].push_back(a);     }     for (long long i = 1; i <= n; i++) {       if (v[i].size() == 2) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( -Ofast )   #pragma GCC optimize( trapv )   #pragma GCC target(         sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native )   #pragma GCC optimize( -ffast-math )   #pragma GCC optimize( -funroll-loops )   #pragma GCC optimize( -funroll-all-loops,-fpeel-loops,-funswitch-loops )   const int N = 1e3 + 40;   const int MAXK = 12;   const long long int INF = 1000000000000000000;   const int RANDOM =       chrono::high_resolution_clock::now().time_since_epoch().count();   long long int expo_pow(long long int x, long long int y) {     if (y == 0) return 1;     y = y % ((1000000007) - 1);     x %= (1000000007);     if (y == 0) y = (1000000007) - 1;     long long int res = 1;     while (y) {       if (y & 1) res = (res * x) % (1000000007);       x = (x * x) % (1000000007);       y >>= 1;     }     return res;   }   long long int modInverse(long long int a, long long int m = (1000000007)) {     return expo_pow(a, m - 2);   }   void solve() {     int n;     cin >> n;     vector<vector<long long int>> cnt(n + 2);     map<int, int> ones;     map<int, int> t;     for (long long int i = (1); i < (n + 1); i++) {       int tp, w;       cin >> tp >> w;       if (w) ones[tp]++;       t[tp]++;     }     for (auto x : t) {       cnt[x.second].push_back(ones[x.first]);     }     priority_queue<pair<long long int, long long int>> pq;     long long int ans = 0;     long long int fo = 0;     set<long long int> second;     for (long long int i = (1); i < (n + 1); i++) {       if (1) second.insert(i);       for (long long int j = (0); j < (cnt[i].size()); j++) {         pq.push(make_pair(cnt[i][j], i));       }     }     while (second.size()) {       if (pq.empty()) break;       int x = pq.top().second;       auto it = second.upper_bound(x);       if (it == second.begin()) {         pq.pop();         continue;       }       it--;       ans += *it;       fo += min(*it, pq.top().first);       pq.pop();       second.erase(*it);     }     cout << ans <<     << fo <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     cin >> T;     while (T--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long n, k, iters, p[10000], q[1000], rp[1000], ar[200000], ar1[20000];   long ans;   bool not_same() {     for (int i = 1; i <= n; i++)       if (ar[i] != q[i]) return true;     return false;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> p[i];     for (int i = 1; i <= n; i++) cin >> q[i];     for (int i = 1; i <= n; i++) rp[p[i]] = i;     long tf = 0;     for (int i = 1; i <= n; i++)       if (rp[i] != p[i]) tf = 1;     ans = 0;     for (int i = 1; i <= n; i++) ar[i] = i;     iters = 0;     while (not_same()) {       ++iters;       for (int i = 1; i <= n; i++) ar1[i] = ar[p[i]];       for (int i = 1; i <= n; i++) ar[i] = ar1[i];       if (iters > k) break;     }     if (iters <= k && iters % 2 == k % 2) ans = 1;     for (int i = 1; i <= n; i++) ar[i] = i;     iters = 0;     while (not_same()) {       ++iters;       for (int i = 1; i <= n; i++) ar1[i] = ar[rp[i]];       for (int i = 1; i <= n; i++) ar[i] = ar1[i];       if (iters > k) break;     }     if (iters <= k && iters % 2 == k % 2) ans = 1;     long fl = 0;     for (int i = 1; i <= n; i++)       if (q[i] != i) fl = 1;     if (fl == 0) ans = 0;     if (tf == 0 && k > 1) ans = 0;     if (ans)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     cin.get();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b, ans = 6;   int len[15], last[15];   void dfs(int x, int va) {     if (x == 7) {       ans = min(ans, va);       return;     }     for (int i = 1; i <= va; i++) {       if (last[i] >= len[x]) {         last[i] -= len[x];         dfs(x + 1, va);         last[i] += len[x];       }     }     last[va + 1] = n - len[x];     dfs(x + 1, va + 1);   }   int main() {     scanf( %d%d%d , &n, &a, &b);     for (int i = 1; i <= 4; i++) len[i] = a;     for (int i = 5; i <= 6; i++) len[i] = b;     dfs(1, 0);     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<string> s;     set<string> ss;     string a, b, res;     int n, cnt_a = 0, cnt_b = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a;       ss.insert(a);       s.push_back(a);     }     if (ss.size() == 1)       cout << s[0] << endl;     else {       sort(s.begin(), s.end());       a = s[0];       b = s[n - 1];       for (int i = 0; i < n; i++) {         if (s[i].compare(a) == 0)           cnt_a++;         else           cnt_b++;       }       res = (cnt_a > cnt_b) ? a : b;       cout << res << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     int x, y;     while (t--) {       cin >> x >> y;       if (y <= sqrt(x)) {         if (x % 2 == 0 && y % 2 == 0)           cout <<  YES  << endl;         else if (x % 2 == 1 && y % 2 == 1)           cout <<  YES  << endl;         else           cout <<  NO  << endl;       } else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000003;   long double pi = 3.1415926536;   const int mx = 1000003;   long long gcd(long long x, long long y) {     if (y == 0) return x;     return gcd(y, x % y);   }   long long bp(long long a, long long b) {     long long ans = 1;     while (b > 0) {       if (b & 1) ans = (ans * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return ans;   }   long long p(long long n) {     for (long long i = 2; i * i <= n; i++) {       if (n % i == 0) {         return n / i;       }     }     return 1;   }   void solve() {     long long a, d, x, i = 1;     cin >> a >> d;     x = a++;     while ((a % i) <= d) {       x = (a - (a % i));       i *= 10;     }     cout << x - 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, b;     cin >> a >> b;     if (a == 0 && b == 0) {       cout << 1;     }     if (a == 0 && b != 0) {       for (int i = b + 1; i > 0; i--) {         cout << i <<    ;       }     }     if (b == 0 && a != 0) {       for (int i = 1; i <= a + 1; i++) {         cout << i <<    ;       }     }     int z = a + b + 1;     if (a != 0 && b != 0) {       a++;       b++;       int m = 0;       int n = 0;       while (a--) {         m = z - a;         cout << m <<    ;       }       while (b > 1) {         b--;         cout << b <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long qitaceruts(long long num) {     long long n = 0, d, p = 1;     while (num > 0) {       d = num % 10;       num = num / 10;       if (d != 0) {         n = (d * p) + n;         p *= 10;       }     }     return n;   }   int main() {     long long a, b, c1, c2;     cin >> a >> b;     c1 = a + b;     a = qitaceruts(a);     b = qitaceruts(b);     c1 = qitaceruts(c1);     if (a + b == c1) {       cout <<  YES n ;     } else {       cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s1, s2;   int main() {     int n, i, j;     scanf( %d , &n);     cin >> s1 >> s2;     int ans = 0;     for (i = 0; i < (n / 2); i++) {       j = n - i - 1;       map<char, int> mp;       mp[s1[i]]++;       mp[s1[j]]++;       mp[s2[i]]++;       mp[s2[j]]++;       int len = mp.size();       if (len == 4)         ans += 2;       else if (len == 3)         ans += 1 + (s1[i] == s1[j]);       else if (len == 2)         ans += (mp[s1[i]] != 2);     }     if ((n % 2) && (s1[n / 2] != s2[n / 2])) ans++;     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cout.tie(0);     int n;     cin >> n;     vector<bool> in(n + 1);     for (int i = 0; i < n; i++) {       int a;       cin >> a;       in[a] = true;     }     vector<int> b(n);     for (int i = 0; i < n; i++) {       cin >> b[i];     }     int ind = 0;     int next_ = 1;     vector<int> c = b;     for (; next_ <= n; ind++) {       int t = ind - n - 1;       if (t >= 0 && t < n) {         in[b[ind - n - 1]] = true;       }       if (c[ind % n] == next_) {         next_++;         c[ind % n] = -1;         continue;       }       if (c[ind % n] == -1 && in[next_]) {         next_++;         continue;       }       c[ind % n] = -1;       if (ind - next_ + 1 < n) {         next_ = 1;       }     }     cout << ind - n << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int INF = 0x3f3f3f3f;   const int MAXN = 3e6 + 3;   bool appear[MAXN];   int ans[MAXN];   signed main() {     int cnt = 1;     int n, x;     scanf( %d%d , &n, &x);     int now = 0;     appear[0] = true;     appear[x] = true;     for (int i = 1; i < (1 << n); ++i) {       if (appear[i]) continue;       appear[i ^ x] = true;       ans[cnt++] = i;     }     printf( %d n , cnt - 1);     for (int i = 1; i < cnt; ++i) printf( %d  , ans[i] ^ ans[i - 1]);   }