malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline bool chkmin(T &a, const T &b) {     return a > b ? a = b, 1 : 0;   }   template <typename T>   inline bool chkmax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   template <typename T>   inline bool smin(T &a, const T &b) {     return a > b ? a = b : a;   }   template <typename T>   inline bool smax(T &a, const T &b) {     return a < b ? a = b : a;   }   const int N = (int)1 << 15, mod = (int)998244353;   int a[N], b[N], dp[N];   int pw(int a, int b) {     return b != 0 ? (long long)pw((long long)a * a % mod, b >> 1) *                         (b & 1 ? a : 1) % mod                   : 1;   }   void NTT(int a[], int lg, bool inverse) {     int N = 1 << lg;     for (int i = 0; i < N; ++i) {       int rev = 0;       for (int j = 0; j < lg; ++j)         if (i >> j & 1) rev |= 1 << (lg - j - 1);       if (rev > i) swap(a[rev], a[i]);     }     for (int len = 2; len <= N; len <<= 1) {       int wn = pw(3, (mod - 1) / len);       if (inverse) wn = pw(wn, mod - 2);       for (int j = 0; j < N; j += len) {         int w = 1;         for (int first = j, second = j + len / 2; second < j + len;              ++first, ++second) {           int u = a[first], v = (long long)a[second] * w % mod;           a[first] = u + v;           a[second] = u - v + mod;           while (a[first] >= mod) a[first] -= mod;           while (a[second] >= mod) a[second] -= mod;           w = (long long)w * wn % mod;         }       }     }     if (inverse) {       int div = pw(N, mod - 2);       for (int i = 0; i < N; ++i) a[i] = (long long)a[i] * div % mod;     }   }   int res[17][N], tmpa[17][N], tmpb[17][N];   void solve(int b, int e, int a[N], int d = 0) {     if (b + 1 == e) {       res[d][0] = 1;       res[d][1] = a[b];       return;     }     int m = b + e >> 1;     solve(b, m, a, d + 1);     for (int j = 0; j <= (m - b); ++j)       tmpa[d][j] = res[d + 1][j], res[d + 1][j] = 0;     solve(m, e, a, d + 1);     for (int j = 0; j <= (e - m); ++j)       tmpb[d][j] = res[d + 1][j], res[d + 1][j] = 0;     int lg = 0;     while ((1 << lg) <= e - b) ++lg;     NTT(tmpa[d], lg, false);     NTT(tmpb[d], lg, false);     for (int j = 0; j < (1 << lg); ++j)       res[d][j] = (long long)tmpa[d][j] * tmpb[d][j] % mod,       tmpa[d][j] = tmpb[d][j] = 0;     NTT(res[d], lg, true);   }   int32_t main() {     int n, k;     cin >> n >> k;     for (int j = 0; j < n; ++j) cin >> a[j];     int qm;     cin >> qm;     while (qm--) {       int c;       cin >> c;       if (c == 1) {         int q, p, d;         cin >> q >> p >> d;         --p;         for (int j = 0; j < n; ++j) b[j] = q - a[j];         b[p] = q - d;       } else {         int q, l, r, d;         cin >> q >> l >> r >> d;         --l;         for (int j = 0; j < n; ++j) b[j] = q - a[j];         for (int j = l; j < r; ++j) b[j] -= d;       }       for (int j = 0; j < n; ++j) b[j] = (b[j] % mod + mod) % mod;       memset(res, 0, sizeof res);       solve(0, n, b);       cout << res[0][k] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 25;   int main() {     int n, m, l, r, t, c;     cin >> n >> m;     pair<int, int> s[n + 1];     for (int i = (1), _b = (n + 1); i < (_b); ++i) s[i] = make_pair(0, 0);     for (int i = (0), _b = (m); i < (_b); ++i) {       cin >> l >> r >> t >> c;       for (int j = (l), _b = (r + 1); j < (_b); ++j) {         if (!s[j].second)           s[j] = make_pair(t, c);         else {           if (t < s[j].first) {             s[j] = make_pair(t, c);           }         }       }     }     int ret = 0;     for (int i = (1), _b = (n + 1); i < (_b); ++i) {       ret += s[i].second;     }     cout << ret << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, A, B, scc[75], tot[75], fa[75], ans[75], f[75][1 << 16];   int c, To[405], nxt[405], cst[405], Head[75];   bool vis[75][1 << 16];   inline int Read() {     int x = 0, f = 1;     char ch = getchar();     while (ch < 48 || ch > 57) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch > 47 && ch < 58) {       x = (x << 3) + (x << 1) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   inline void Write(int x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) Write(x / 10);     putchar(48 + x % 10);   }   void ad_ed(int u, int v, int ct) {     nxt[++c] = Head[u];     To[c] = v;     cst[c] = ct;     Head[u] = c;   }   int Find(int x) {     if (fa[x] != x) fa[x] = Find(fa[x]);     return fa[x];   }   void Merge(int x, int y) {     int rx = Find(x), ry = Find(y);     if (rx != ry) fa[ry] = rx, tot[rx] += tot[ry];   }   struct info {     int id, dis, st;     friend bool operator<(info a, info b) { return a.dis > b.dis; }   };   priority_queue<info> q;   int main() {     n = Read();     m = Read();     A = Read();     B = Read();     if (A > B) swap(A, B);     for (int i = 1; i <= n; i++) fa[i] = i, tot[i] = 1, ans[i] = 0x3f3f3f3f;     memset(f, 0x3f, sizeof(f));     for (int i = 1; i <= m; i++) {       int u = Read(), v = Read(), ct = Read();       ad_ed(u, v, ct);       ad_ed(v, u, ct);       if (ct == A) Merge(u, v);     }     int idx = 0;     for (int i = 1; i <= n; i++)       if (!scc[i] && tot[Find(i)] > 3) {         idx++;         for (int j = 1; j <= n; j++)           if (Find(j) == Find(i)) scc[j] = idx;       }     int beg_st = (!scc[1] ? 0 : 1 << scc[1]);     f[1][beg_st] = 0;     q.push(info{1, 0, beg_st});     while (!q.empty()) {       info x = q.top();       q.pop();       if (vis[x.id][x.st]) continue;       vis[x.id][x.st] = 1;       ans[x.id] = min(ans[x.id], x.dis);       for (int i = Head[x.id]; i; i = nxt[i]) {         int v = To[i], ct = cst[i];         if (ct == A) {           if (f[x.id][x.st] + ct < f[v][x.st]) {             f[v][x.st] = f[x.id][x.st] + ct;             q.push(info{v, f[v][x.st], x.st});           }         } else if (ct == B) {           if (Find(x.id) == Find(v)) continue;           if (scc[v] && ((x.st >> scc[v]) & 1)) continue;           int net = x.st | (1 << scc[v]);           if (f[x.id][x.st] + ct < f[v][net]) {             f[v][net] = f[x.id][x.st] + ct;             q.push(info{v, f[v][net], net});           }         }       }     }     for (int i = 1; i <= n; i++) Write(ans[i]), putchar(   );     return 0;   }
#include <bits/stdc++.h>   const long long INF = (1 << 30) - 1;   const int MAXN = 100001;   struct Node {     int l, r;     long long num;     long long num2;     long long delta;   };   int n, m;   long long t[MAXN];   int l[MAXN], r[MAXN];   long long q[MAXN];   Node tree[MAXN << 2];   void build(int cur, int l, int r) {     tree[cur].l = l;     tree[cur].r = r;     tree[cur].delta = tree[cur].num = tree[cur].num2 = 0;     if (l + 1 != r) {       tree[cur].delta = 0;       build((cur << 1) + 1, l, (l + r) >> 1);       build((cur << 1) + 2, (l + r) >> 1, r);     }   }   void update(int cur) {     tree[(cur << 1) + 1].delta |= tree[cur].delta;     tree[(cur << 1) + 2].delta |= tree[cur].delta;     tree[(cur << 1) + 1].num |= tree[cur].delta;     tree[(cur << 1) + 2].num |= tree[cur].delta;     tree[(cur << 1) + 1].num2 |= tree[cur].delta;     tree[(cur << 1) + 2].num2 |= tree[cur].delta;     tree[cur].delta = 0;   }   void change(int cur, int l, int r, int delta) {     if (l <= tree[cur].l && tree[cur].r <= r) {       tree[cur].delta |= delta;       tree[cur].num |= delta;       tree[cur].num2 |= delta;     } else {       if (tree[cur].delta != 0) update(cur);       int mid = (tree[cur].l + tree[cur].r) >> 1;       if (l < mid) change((cur << 1) + 1, l, r, delta);       if (r > mid) change((cur << 1) + 2, l, r, delta);       tree[cur].num = tree[(cur << 1) + 1].num | tree[(cur << 1) + 2].num;       tree[cur].num = tree[(cur << 1) + 1].num & tree[(cur << 1) + 2].num;     }   }   long long query(int cur, int l, int r) {     if (l <= tree[cur].l && tree[cur].r <= r) {       return tree[cur].num2;     } else {       if (tree[cur].delta != 0) update(cur);       int mid = (tree[cur].l + tree[cur].r) >> 1;       long long ans = INF;       if (l < mid) ans &= query((cur << 1) + 1, l, r);       if (r > mid) ans &= query((cur << 1) + 2, l, r);       return ans;     }   }   int main() {     scanf( %d%d , &n, &m);     memset(t, 0LL, sizeof(t));     build(0, 1, n + 1);     for (int i = 1; i <= m; i++) {       scanf( %d%d%I64d , &l[i], &r[i], &q[i]);       change(0, l[i], r[i] + 1, q[i]);     }     bool ok = true;     for (int i = 1; i <= m; i++) {       long long te = query(0, l[i], r[i] + 1);       if (te != q[i]) {         ok = false;         break;       }     }     if (ok) {       printf( YES n );       for (int i = 1; i <= n; i++) {         printf( %I64d  , query(0, i, i + 1));       }       printf(  n );     } else {       printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   struct Node {     Node(int v = 1, int pos = 1e9) { min = (v == 1 ? int(1e9) : pos); }     Node(Node l, Node r) { min = std::min(l.min, r.min); }     int min;   };   template <class i_t, class e_t>   class SegmentTree {    public:     void init(std::vector<e_t> base) {       n = base.size();       tree.resize(2 * n);       for (int i = 0; i < n; i++) {         tree[i + n] = i_t(base[i], i);       }       for (int i = n - 1; i > 0; i--) {         tree[i] = i_t(tree[i + i], tree[i + i + 1]);       }     }     i_t qry(int l, int r) {       i_t lp, rp;       for (l += n, r += n; l < r; l /= 2, r /= 2) {         if (l & 1) lp = i_t(lp, tree[l++]);         if (r & 1) rp = i_t(tree[--r], rp);       }       return i_t(lp, rp);     }     void upd(int x, e_t v) {       x += n;       tree[x] = i_t(v, x - n);       build(x);     }       private:     int n;     std::vector<i_t> tree;     void build(int x) {       for (x /= 2; x > 0; x /= 2) {         tree[x] = i_t(tree[x + x + 1], tree[x + x]);       }     }   };   struct Bucket {     int n;     SegmentTree<Node, int> tree;     void init(int n) {       this->n = n;       tree.init(std::vector<int>(n, 0));     }     void erase(int pos) { tree.upd(pos, 0); }     int insert(int pos) {       int x = tree.qry(pos, n).min;       int ans = 0;       if (x >= n) {         x = tree.qry(0, pos).min;         ans += n - pos + x;       } else {         ans += x - pos;       }       tree.upd(x, 1);       return ans;     }   };   int main() {     int h, m, n;     std::cin >> h >> m >> n;     int size = 1;     for (int i = 2; i <= h; i++) {       if (h % i == 0 && m % i == 0) {         size = i;       }     }     std::vector<Bucket> buckets(size);     std::vector<int> hashBucket(h, 0);     std::vector<int> posBucket(h, 0);     std::map<int, std::pair<int, int> > idBucket;     for (int i = 0; i < size; i++) {       for (int j = 0, pos = i; j < h / size; j++, pos = (pos + m) % h) {         posBucket[pos] = j;         hashBucket[pos] = i;       }       buckets[i].init(h / size);     }     long long ans = 0;     for (int i = 0; i < n; i++) {       char t;       int id;       scanf(  %c %d , &t, &id);       if (t ==  + ) {         int hash;         scanf( %d , &hash);         int got = buckets[hashBucket[hash]].insert(posBucket[hash]);         idBucket[id] = std::pair<int, int>(hashBucket[hash],                                            (posBucket[hash] + got) % (h / size));         ans += got;       } else {         auto it = idBucket.find(id);         buckets[it->second.first].erase(it->second.second);         idBucket.erase(it);       }     }     std::cout << ans << std::endl;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   vector<long long> fact(10005);   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long power(long long x, long long y) {     long long temp;     if (y == 0) return 1;     temp = power(x, y / 2);     if (y % 2 == 0)       return temp * temp;     else       return x * temp * temp;   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long modInv(long long n, long long p) { return power(n, p - 2, p); }   long long ncr(long long n, long long r) {     return (n >= r ? (fact[n] * modInv(fact[r], mod)) % mod *                          modInv(fact[n - r], mod) % mod                    : 0);   }   long long add(long long a, long long b) {     long long z = a + b;     if (z >= mod) z -= mod;     return z;   }   long long mul(long long a, long long b) { return (a * b) % mod; }   long long sub(long long a, long long b) { return (a - b + mod) % mod; }   int main() {     long long t = 1, n, i, j, m, cnt, f, ff;     cin >> t;     while (t--) {       cin >> n >> mod;       long long z = log2(n) - 1;       long long ans = (n - (1 << (z + 1)) + 2) % mod;       for (i = 0; i <= z; i++) {         ans = mul(ans, (1 << i) + 1);       }       if (ans == 0)         cout << mod - 1 <<   n ;       else         cout << ans - 1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   vector<int> gr[(ll)(1e5 + 4)];   set<int> g[(ll)(1e5 + 4)];   bool vis[(ll)(1e5 + 4)];   int par[(ll)(1e5 + 4)], si[(ll)(1e5 + 4)];   int find(int no) {     if (par[no] != no) {       par[no] = find(par[no]);     }     return par[no];   }   void join(int a, int b) {     if (find(a) == find(b)) {       return;     }     int pa = par[a], pb = par[b];     if (si[pa] < si[pb]) {       swap(pa, pb);     }     si[pa] += si[pb];     si[pb] = 0;     par[pb] = pa;   }   void dfs(int node) {     cout << node <<    ;     vis[node] = 1;     for (int x : gr[node]) {       if (!vis[x]) {         dfs(x);       }     }   }   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int ar[n][3];       for (int i = 0; i < n - 2; i++) {         for (int j = 0; j < 3; j++) {           cin >> ar[i][j];           int a = ar[i][j];           g[a].insert(i);         }       }       set<pair<int, int>> sp;       for (int i = 1; i <= n; i++) {         par[i] = i, si[i] = 1;         sp.insert(make_pair(g[i].size(), i));       }       vector<int> qp;       while (sp.size()) {         auto p = *sp.begin();         sp.erase(sp.begin());         int ind = *g[p.second].begin();         qp.push_back(ind + 1);         for (int j = 0; j < 3; j++) {           int u = p.second;           int v = ar[ind][j];           if (find(u) != find(v)) {             gr[u].push_back(v);             gr[v].push_back(u);           }           join(u, v);           g[v].erase(ind);           if (g[v].size()) {             sp.insert(make_pair(g[v].size(), v));           }         }         while (sp.size() && sp.begin()->first > g[sp.begin()->second].size()) {           sp.erase(sp.begin());         }       }       for (int i = 1; i <= n; i++) {         if (gr[i].size() == 1 && vis[i] == 0) {           dfs(i);           cout <<   n ;         }       }       for (int i = 0; i < qp.size(); i++) {         cout << qp[i] <<    ;       }       cout <<   n ;       for (int i = 0; i <= n; i++) {         vis[i] = 0, gr[i].clear(), g[i].clear();       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, fwt[262144];   vector<int> a1, b1, c1, d1, e1, ans;   void add(int x, int k) {     for (; x < 262144; x += x & -x) {       fwt[x] += k;     }   }   int sum(int x) {     int res = 0;     for (; x; x -= x & -x) {       res += fwt[x];     }     return res;   }   int findSidx(int sum) {     int x = 0;     for (int j = 262144 / 2; j; j /= 2) {       if (sum >= fwt[x + j]) {         sum -= fwt[x + j];         x += j;       }     }     return x;   }   vector<int> deB(vector<int>& a) {     memset(fwt, 0, sizeof fwt);     vector<int> res;     for (int i = 0; i < n; ++i) {       add(i + 1, 1);     }     for (int i = 0; i < n; ++i) {       add(a[i] + 1, -1);       res.push_back(sum(a[i] + 1));     }     return res;   }   void makeA() {     memset(fwt, 0, sizeof fwt);     ans.resize(n, 0);     for (int i = 0; i < n; ++i) {       add(i + 1, 1);     }     for (int i = 0; i < n; ++i) {       ans[i] = findSidx(e1[i]);       add(ans[i] + 1, -1);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     a1.resize(n);     b1.resize(n);     e1.resize(n, 0);     for (int i = 0; i < n; ++i) {       cin >> a1[i];     }     for (int j = 0; j < n; ++j) {       cin >> b1[j];     }     c1 = deB(a1), d1 = deB(b1);     for (int i = n - 1; i >= 0; --i) {       e1[i] += c1[i] + d1[i];       if (i) {         e1[i - 1] += e1[i] / (n - i);       }       e1[i] %= (n - i);     }     makeA();     for (int i = 0; i < n; ++i) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, temp, i, x = 0, arr[100] = {0};     map<long long, long long> inx;     cin >> n;     for (i = 0; i < n; i++) {       cin >> temp;       inx[temp] = i;     }     for (map<long long int, long long int>::iterator it = inx.begin();          it != inx.end(); ++it) {       arr[it->second] = it->first;     }     cout << inx.size() << endl;     for (i = 0; i < n; i++) {       if (arr[i] != 0) cout << arr[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, ans;   string str;   long long solve() {     cin >> n;     long long v[1001];     for (long long i = 0; i <= n - 1; ++i) {       long long t;       cin >> t;       v[i + 1] = t;     }     for (long long i = 1; i <= n; ++i) {       long long a[n + 1];       for (long long i = 0; i <= n; ++i) a[i] = 0;       a[i]++;       long long t = i;       while (1) {         t = v[t];         a[t]++;         if (a[t] == 2) {           cout << t <<    ;           break;         }       }     }     return 0;   }   signed main() {     ios::sync_with_stdio(0);     long long t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t, i;     scanf( %d %d , &n, &t);     if (n == 1 && t == 10) {       printf( -1 n );     } else {       if (t == 10) {         t = 1;       }       printf( %d , t);       for (i = 0; i < n - 1; i++) {         printf( 0 );       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[500001], t[500001];   long long nt[10000001], n, k, m;   long long c[2];   void kmp(long long x, char a[]) {     int i, j;     for (nt[0] = j = -1, i = 1; i < x; nt[i++] = j) {       while (~j && a[j + 1] != a[i]) j = nt[j];       if (a[j + 1] == a[i]) j++;     }   }   int main() {     scanf( %s , s);     scanf( %s , t);     n = strlen(t);     kmp(n, t);     k = nt[n - 1];     m = strlen(s);     for (int i = 0; i < m; i++) c[s[i] -  0 ]++;     for (int i = 0, j = 0; i < m; i++) {       if (c[0] == 0)         printf( 1 );       else if (c[1] == 0)         printf( 0 );       else {         printf( %c , t[j]);         c[t[j] -  0 ]--;         if (j == n - 1) j = nt[j];         j++;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, k, x, m, s;   vector<int> f, t, f1;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> x >> m;       f.push_back(x);       t.push_back(m);     }     for (int i = 0; i < n; i++) {       if (t[i] < k) {         f1.push_back(f[i]);       } else {         s = f[i] - (t[i] - k);         f1.push_back(s);       }     }     sort(f1.begin(), f1.end());     cout << f1.back();   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, k, a[205], b[205];     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int j = 1; j <= k; j++) cin >> b[j];     if (k >= 2) {       cout <<  Yes  << endl;       return 0;     }     if (a[1] == 0) a[1] = b[1];     for (int i = 2; i <= n; i++) {       if (a[i] == 0) a[i] = b[1];       if (a[i] <= a[i - 1]) {         cout <<  Yes  << endl;         return 0;       }     }     cout <<  No  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void dbg(T a) {}   template <typename T, typename... Arg>   void dbg(T a, Arg... arg) {}   const int maxn = (1e6) + 7;   const int inf = (1e9) + 7;   const long long LLinf = (1e18) + 7;   const long double eps = 1e-9;   const long long mod = 1e9 + 7;   int ile(vector<int> V) {     int res = 0;     while (((int)(V).size()) && V.back() == 0) {       V.pop_back();       res++;     }     if (((int)(V).size()) == 0) return 10000;     return res;   }   int rob(vector<int> V, int a, int b) {     int cnt = 0;     for (int i = 0; i < ((int)(V).size()); i++)       if (V[i] == a) {         for (int j = i - 1; j >= 0; j--) {           swap(V[j], V[j + 1]);           cnt++;         }         break;       }     for (int i = 1; i < ((int)(V).size()); i++)       if (V[i] == b) {         for (int j = i - 1; j > 0; j--) {           swap(V[j], V[j + 1]);           cnt++;         }         break;       }     if (V[0] == a && V[1] == b)       return cnt + ile(V);     else       return 1000;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     vector<int> V;     while (n > 0) {       V.push_back(n % 10);       n /= 10LL;     }     int res = 1000;     res = min(res, rob(V, 0, 0));     res = min(res, rob(V, 5, 2));     res = min(res, rob(V, 0, 5));     res = min(res, rob(V, 5, 7));     if (res < 100)       cout << res;     else       cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, k, l, r, m, s, t, n, a[11236], b[123456], z, c[168456],       zam[17456], za[1234];   bool p[40000000];   long long xx, yy, x, y;   int main() {     cin >> n >> k;     if (n == 2) {       if (k == 1)         cout <<  01 ;       else         cout << -1;       return 0;     }     if (n == 3) {       if (k == 1)         cout <<  001 ;       else if (k == 2)         cout <<  010 ;       else         cout << -1;       return 0;     }     k++;     if (n % 2 == 0) {       m = n / 2;       l = 1;       for (i = 0; i < m; i++) l = l * 2;       if (k > l / 2 * (l / 2 + 1)) {         cout << -1;         return 0;       }       x = l - 1;       while (l < k) {         k -= l;         l -= 2;         r = t;         s = 0;         for (i = 0; i < m; i++) {           s = s * 2 + r % 2;           r = r / 2;         }         p[x - s] = 1;         p[s] = 1;         t++;       }       j = t;       for (i = 0; i < m; i++) {         a[i] = t % 2;         t /= 2;       }       for (i = m - 1; i >= 0; i--) cout << a[i];       t = 0;       while (k > 0) {         if (p[t] == 0) {           k--;         }         if (k == 0) break;         t++;       }       for (i = 0; i < m; i++) {         a[i] = t % 2;         t /= 2;       }       for (i = m - 1; i >= 0; i--) cout << a[i];     } else {       long long ss = (1 << n) - 1;       m = n / 2;       l = 1;       for (i = 0; i <= m; i++) l = l * 2;       if (k > l * (l + 2) / 8) {         cout << -1;         return 0;       }       y = l / 2;       z = y - 1;       l--;       x = l;       t = 0;       while (l < k) {         k -= l;         l -= 4;         r = t;         s = 0;         for (i = 0; i < m; i++) {           s = s * 2 + r % 2;           r = r / 2;         }         p[z - s] = 1;         p[s] = 1;         p[z - s + y] = 1;         p[s + y] = 1;         t++;       }       j = t;       r = t;       s = 0;       for (i = 0; i < m; i++) {         s = s * 2 + r % 2;         r = r / 2;       }       s = z - s;       for (i = 0; i < m; i++) {         a[i] = t % 2;         t /= 2;       }       for (i = m - 1; i >= 0; i--) cout << a[i];       t = 0;       while (k > 0) {         if (p[t] == 0) {           if (t == s) {             p[t + y] = 1;           }           k--;         }         if (k == 0) break;         t++;       }       for (i = 0; i <= m; i++) {         a[i] = t % 2;         t /= 2;       }       for (i = m; i >= 0; i--) cout << a[i];     }     return 0;   }