malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T sqr(const T& a) {     return a * a;   }   template <typename T>   inline int sign(const T& a) {     return a < 0 ? -1 : a > 0;   }   void task();   int main() {     task();     return 0;   }   vector<int> z_function(string s) {     int n = (int)s.length();     vector<int> z(n);     for (int i = 1, l = 0, r = 0; i < n; ++i) {       if (i <= r) z[i] = min(r - i + 1, z[i - l]);       while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];       if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;     }     return z;   }   int n, k;   string s;   int ans[int(2e6) + 10];   int add[int(2e6) + 10];   int sub[int(2e6) + 10];   void task() {     ios_base::sync_with_stdio(0);     cin >> n >> k;     cin >> s;     auto z = z_function(s);     z[0] = s.length();     (void(1));     for (int len = 1; len <= n; ++len) {       for (int i = 0, step = 0; i < n; i += len, ++step) {         if (z[i] < len) break;         if (step == k - 1) {           (void(1));           add[i + len - 1]++;           sub[i + len - 1 + min(len, z[i + len])]++;           break;         }       }     }     int cur = 0;     for (int i = 0; i < n; ++i) {       cur += add[i];       ans[i] = cur > 0;       cur -= sub[i];     }     for (int i = 0; i < n; ++i) cout << ans[i];   }
#include <bits/stdc++.h>   using namespace std;   ifstream fi(        easy         .inp );   ofstream fo(        easy         .out );   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     vector<string> s;     for (int i = 0; i < n; i++) {       string x;       cin >> x;       s.push_back(x);     }     vector<string> a(n);     for (int i = 0; i < n; i++) {       string tmp =   ;       for (int j = 0; j < m; j++) {         tmp += (j & 1 ? ( Z  - s[i][j]) : (s[i][j] -  A )) +  A ;       }       a[i] = tmp;     }     vector<pair<string, int>> mp;     for (int i = 0; i < n; i++) {       mp.push_back({a[i], i});     }     sort((mp).begin(), (mp).end());     for (int i = 0; i < n; i++) {       cout << mp[i].second + 1 <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 300000 + 10;   long long n;   long long ans[maxn], tot, vis[maxn], last;   int main() {     while (scanf( %lld , &n) != EOF) {       memset(vis, 0, sizeof(vis));       memset(ans, 0, sizeof(ans));       for (int i = 0; i < n; i++) scanf( %lld , &ans[i]);       last = n;       tot = 0;       printf( 1 );       for (int i = 0; i < n; i++) {         vis[ans[i]] = 1;         tot++;         while (vis[last] > 0) {           tot--;           last--;         }         printf(  %lld , tot + 1);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( sse4,avx )   int getNimb(int c, int64_t forbidden_mask,               std::map<std::pair<int, int64_t>, int>& map) {     auto it = map.find(std::pair<int, int64_t>{c, forbidden_mask});     if (it != map.end()) {       return it->second;     }     if (c == 0) {       return 0;     }     std::vector<int> other;     for (int i = 1; i <= c; i++) {       if ((forbidden_mask & (1 << i)) == 0) {         other.push_back(getNimb(c - i, forbidden_mask + (1 << i), map));       }     }     std::sort(other.begin(), other.end());     if (other.empty()) {       return 0;     }     int j = 0;     for (size_t i = 0; i < other.size(); i++) {       if (j >= other.size() || other[j] != i) {         map[std::pair<int, int64_t>(c, forbidden_mask)] = i;         return i;       }       while (j < other.size() && other[j] == i) j++;     }     map[std::pair<int, int64_t>(c, forbidden_mask)] = other.size();     return other.size();   }   int data[] = {0, 1, 1, 2, 2, 2, 3, 3,  3,  3,  4,  4,  4, 4, 4, 5,                 5, 5, 5, 5, 5, 6, 6, 6,  6,  6,  6,  6,  7, 7, 7, 7,                 7, 7, 7, 7, 8, 8, 8, 8,  8,  8,  8,  8,  8, 9, 9, 9,                 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10};   void run(std::istream& in, std::ostream& out) {     int n;     in >> n;     int res = 0;     for (int i = 0; i < n; i++) {       int x;       in >> x;       res ^= data[x];     }     if (res == 0) {       out <<  YES  << std::endl;     } else {       out <<  NO  << std::endl;     }   }   int main() {     std::cin.sync_with_stdio(false);     std::cin.tie(nullptr);     run(std::cin, std::cout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int z[100001];   int main() {     string s;     int T, a, b;     cin >> s;     for (a = 1; a < s.size(); a++) {       z[a] = z[a - 1] + (s[a] == s[a - 1]);     }     for (cin >> T; T--; cout << z[b - 1] - z[a - 1] << endl) cin >> a >> b;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     bool taken[n + 1];     for (int i = 0; i < n + 1; i++) taken[i] = 0;     int cc = 0;     for (int i = 1; i < n + 1; i++) {       for (int j = 1; j <= n; j++) {         int a;         cin >> a;         if (a == 2 && !taken[j]) taken[j] = 1, cc++;         if (a == 3) {           if (!taken[i]) taken[i] = 1, cc++;           if (!taken[j]) taken[j] = 1, cc++;         }       }     }     cout << n - cc << endl;     for (int i = 1; i < n + 1; i++)       if (!taken[i]) cout << i <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MXN = 100 + 10;   const long long Mod = 1e9 + 7;   void mkay(long long &x) {     if (x >= Mod) x -= Mod;   }   long long n, k;   long long sub[MXN], DP[MXN];   long long dp[MXN][MXN][2], pd[MXN][2];   vector<long long> adj[MXN];   vector<pair<long long, long long>> A, B;   void DFS(long long u, long long par) {     sub[u] = dp[u][k][0] = dp[u][0][1] = 1;     for (auto v : adj[u]) {       if (v == par) continue;       DFS(v, u);       A.clear(), B.clear();       for (int i = 0; i < sub[u]; i++) A.emplace_back(i, 1);       for (int i = 0; i < sub[v]; i++) B.emplace_back(i, 1);       for (long long i = max(0ll, k - sub[u]); i <= k; i++) A.emplace_back(i, 0);       for (long long i = max(0ll, k - sub[v]); i <= k; i++) B.emplace_back(i, 0);       for (auto Pr0 : A) {         long long x, a, f, s;         tie(x, a) = Pr0;         for (auto Pr1 : B) {           long long y, b;           tie(y, b) = Pr1;           if (a == 0 && b == 0) {             f = max(x, y - 1), s = 0;           } else if (a == 0 && b == 1) {             if (x - 1 >= y)               f = x, s = 0;             else               f = y + 1, s = 1;           } else if (a == 1 && b == 0) {             if (y - 1 >= x)               f = y - 1, s = 0;             else               f = x, s = 1;           } else {             f = max(x, y + 1), s = 1;           }           mkay(pd[f][s] += dp[u][x][a] * dp[v][y][b] % Mod);         }       }       sub[u] += sub[v];       for (int f = 0; f <= sub[u]; f++) dp[u][f][1] = pd[f][1], pd[f][1] = 0;       for (int f = max(0ll, k - sub[u]); f <= k; f++)         dp[u][f][0] = pd[f][0], pd[f][0] = 0;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (int i = 1; i < n; i++) {       long long u, v;       cin >> u >> v;       adj[u].push_back(v), adj[v].push_back(u);     }     DFS(1, 0);     for (int f = 0; f <= k; f++) {       mkay(DP[k] += dp[1][f][0]);     }     cout << DP[k] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, p[200100], c[200100], ans = 100100;   bool hamin[200100];   vector<vector<long long> > cycle;   bool same_color(long long ind, long long start, long long dist) {     long long asdf = (start + dist) % cycle[ind].size();     while (asdf != start) {       if (c[cycle[ind][start]] != c[cycle[ind][asdf]]) return false;       asdf = (asdf + dist) % cycle[ind].size();     }     return true;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cin >> t;     while (t--) {       ans = 100000000;       cycle.clear();       cin >> n;       for (int i = 1; i <= n; i++) hamin[i] = false;       for (int i = 1; i <= n; i++) cin >> p[i];       for (int i = 1; i <= n; i++) cin >> c[i];       for (int i = 1; i <= n; i++) {         if (hamin[i]) continue;         long long start = i;         vector<long long> fuck;         fuck.push_back(start);         hamin[start] = true;         while (p[start] != fuck[0]) {           start = p[start];           fuck.push_back(start);           hamin[start] = true;         }         cycle.push_back(fuck);       }       for (long long i = 0; i < cycle.size(); i++) {         for (long long j = 1; j <= cycle[i].size(); j++) {           if (cycle[i].size() % j) continue;           for (long long z = 0; z < j; z++)             if (same_color(i, z, j)) ans = min(ans, j);         }       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   bool comprobarNum(vector<int> aux, int num) {     for (int i = 0; i < aux.size(); i++) {       if (aux[i] == num) {         return true;       }     }     return false;   }   int main() {     int n, aux;     cin >> n;     vector<int> s;     vector<int> numR;     int contador = 1;     while (n--) {       cin >> aux;       if (comprobarNum(s, aux)) {         numR.push_back(aux);       } else {         s.push_back(aux);       }     }     int max = 1;     for (int i = 0; i < numR.size(); i++) {       for (int j = 0; j < numR.size(); j++) {         if (numR[j] == numR[i]) {           contador++;         }       }       if (contador > max) max = contador;       contador = 1;     }     cout << max <<     << s.size();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     double n, R, r;     cin >> n >> R >> r;     if (r > R) return cout <<  NO , 0;     if (2 * r == R) {       if (n <= 2)         return cout <<  YES , 0;       else         return cout <<  NO , 0;     }     if (2 * r > R) {       if (n <= 1)         return cout <<  YES , 0;       else         return cout <<  NO , 0;     }     if (2 * r < R) {       double h = R - r;       double t = atan2(r, (double)sqrt(h * h - r * r));       if (t * n - PI > 0.0000000000000001)         cout <<  NO ;       else         cout <<  YES ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, j, m, n, rev_dig[25], cnt, non_zero, anscnt;   long long x, ans1[100005], ans2[100005], ans3[100005];   long long getinv(long long a, long long p) {     if (a == 1) return 1;     long long k = a - getinv(p % a, a);     return (k * p + 1) / a;   }   void answer(long long a, long long b, int ty) {     anscnt++;     ans1[anscnt] = a;     ans2[anscnt] = b;     ans3[anscnt] = ty;   }   void getmul(int t, long long x) {     long long temp = 1;     long long xx = x;     while (temp < t) {       answer(xx, xx, 1);       xx <<= 1;       temp <<= 1;     }     temp = 1;     long long now = 0;     while (temp <= t) {       if (temp & t) {         if (now > 0) {           answer(temp * x, now, 1);           now += temp * x;         } else {           now = temp * x;         }       }       temp <<= 1;     }   }   int main() {     anscnt = 0;     scanf( %lld , &x);     if (x % 4 == 1) {       answer(x, x, 1);       answer(x, x * 2, 1);       x *= 3;     }     cnt = 0;     long long xx = x;     while (xx > 0) {       cnt++;       rev_dig[cnt] = xx & 1;       xx >>= 1;     }     non_zero = 0;     for (i = 1; i <= cnt; i++) {       if (rev_dig[i] == 0) {         non_zero = i;         break;       }     }     if (non_zero == 0) {       cnt++;       rev_dig[cnt] = 0;       non_zero = cnt;     }     long long xinv = getinv(x, 1 << cnt);     long long r1 = x - 1;     long long t1 = r1 * xinv % (1 << cnt);     getmul(t1, x);     long long b = t1 * x;     answer(b, x, 2);     long long c = b ^ x;     answer(x, c, 1);     long long d = (x + c);     answer(b, d, 2);     long long e = b ^ d;     if (e != 2) {       long long r2 = x - 2;       long long t2 = r2 * xinv % (1 << cnt);       getmul(t2, x);       long long b2 = t2 * x;       answer(b2, x, 2);       long long c2 = b2 ^ x;       answer(x, c2, 1);       long long d2 = (x + c2);       answer(b2, d2, 2);       long long e2 = b2 ^ d2;       answer(e, e2, 2);     }     e = 2;     while (e <= x) {       answer(e, e, 1);       if (e & x) {         answer(e, x, 2);         x = e ^ x;       }       e <<= 1;     }     printf( %d n , anscnt);     for (i = 1; i <= anscnt; i++) {       if (ans3[i] == 1) {         printf( %lld + %lld n , ans1[i], ans2[i]);       } else {         printf( %lld ^ %lld n , ans1[i], ans2[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ROW[] = {+1, -1, +0, +0};   int COL[] = {+0, +0, +1, -1};   int X[] = {+0, +0, +1, -1, -1, +1, -1, +1};   int Y[] = {-1, +1, +0, +0, +1, +1, -1, -1};   int KX[] = {-2, -2, -1, -1, 1, 1, 2, 2};   int KY[] = {-1, 1, -2, 2, -2, 2, -1, 1};   int basePrime[] = {1009, 1013, 1019, 1021, 1031, 1223, 1229, 1231, 1237, 1249,                      1289, 1291, 1297, 1301, 1303, 353,  359,  367,  373,  379,                      859,  863,  877,  881,  883,  1931, 1933, 1949, 1951, 1973,                      401,  409,  419,  421,  431,  1709, 1721, 1723, 1733, 1741,                      3499, 3511, 3517, 3527, 3529, 929,  937,  941,  947,  953};   template <class XXX>   XXX GCD(XXX a, XXX b) {     return b == 0 ? a : GCD(b, a % b);   }   template <class XXX>   XXX LCM(XXX a, XXX b) {     return a * (b / GCD(a, b));   }   template <class XXX, class YYY>   bool CMP(XXX a, YYY b) {     return a > b;   }   template <class XXX>   void fastread(XXX &number) {     bool negative = false;     register XXX c;     number = 0;     c = getchar();     if (c ==  - ) {       negative = true;       c = getchar();     }     for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;     if (negative) number *= -1;   }   void OPFILE() {}   int main() {     OPFILE();     long long int ans[600000];     ans[1] = 0LL;     long long int cnt = 1;     for (int i = 3; i <= 500000; i += 2) {       ans[i] = ans[i - 2] + 8LL * cnt * cnt;       cnt++;     }     int n;     cin >> n;     while (cin >> n) cout << ans[n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char* argv[]) {     cin.sync_with_stdio(0);     cout.sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, r[100], b[100], sumr, sumb, ans = 1, check = 1;     cin >> n;     for (int i = 0; i < n; i++) cin >> r[i];     for (int i = 0; i < n; i++) cin >> b[i];     sumr = accumulate(r, r + n, 0);     sumb = accumulate(b, b + n, 0);     if ((sumr == sumb && sumb == 0) || (sumr == sumb && sumb == n)) {       cout << -1;       return 0;     }     if (sumr > sumb) {       cout << 1;       return 0;     }     for (int i = 0; i < n; i++)       if (r[i] && !b[i]) {         check = 0;         break;       }     if (check) {       cout << -1;       return 0;     }   RELOOP:;     ans++;     for (int i = 0; i < n; i++)       if (r[i] && !b[i]) sumr++;     if (sumr <= sumb) goto RELOOP;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, r;   long long A[1000005], sum;   int main() {     scanf( %d %d , &n, &r);     for (int i = (0); i < (1 << n); i++) scanf( %lld , &A[i]), sum += A[i];     printf( %.12lf n , 1.0 * sum / (1 << n));     for (int i = (0); i < (r); i++) {       int x;       long long y;       scanf( %d %lld , &x, &y);       sum += y - A[x];       A[x] = y;       printf( %.12lf n , 1.0 * sum / (1 << n));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     vector<int> a;     int n, t;     cin >> n;     a.reserve(n);     while (n--) {       cin >> t;       if (t != 0) {         a.push_back(t);       }     }     sort(a.begin(), a.end());     cout << unique(a.begin(), a.end()) - a.begin();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = int(2e5);   int g[N];   int ans = 0;   int n;   bool used[N];   void bfs(int start) {     queue<int> q;     q.push(start);     used[start] = true;     while (!q.empty()) {       int from = q.front();       q.pop();       int to = g[from];       if (!used[to]) {         used[to] = true;         q.push(to);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> g[i];       g[i]--;     }     int c = 0;     for (int i = 0, t; i < n; ++i) {       cin >> t;       c += t;     }     ans += !(bool(c & 1));     int cnt = 0;     for (int i = 0; i < n; ++i) {       if (!used[i]) {         cnt++;         bfs(i);       }     }     ans += (cnt == 1 ? 0 : cnt);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, ans;     int d;     char c;     cin >> n >> c;     m = n - 1;     if (c ==  f ) {       d = 1;     }     if (c ==  e ) {       d = 2;     }     if (c ==  d ) {       d = 3;     }     if (c ==  a ) {       d = 4;     }     if (c ==  b ) {       d = 5;     }     if (c ==  c ) {       d = 6;     }     if (m % 4 == 0 || m % 4 == 2)       ans = (m / 4) * 16 + d;     else       ans = (m / 4) * 16 + 7 + d;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cnt[10];   long long w, ans;   void dfs(int pos, long long c) {     long long rec;     if (pos > 8) {       ans = max(ans, w - c);       return;     }     rec = min(cnt[pos], c / pos);     for (long long i = rec; i >= max(rec - 8, 0LL); i--)       dfs(pos + 1, c - i * pos);   }   int main() {     cin >> w;     for (int i = 1; i <= 8; i++) cin >> cnt[i];     ans = 0;     dfs(1, w);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 300000;   vector<int> g[MAX_N];   int sz[MAX_N];   int x[MAX_N];   int p[MAX_N];   int N;   int dfs(int v) {     sz[v] = 1;     p[v] = N;     x[N++] = v;     for (int i = 0; i < g[v].size(); i++) {       sz[v] += dfs(g[v][i]);     }     return sz[v];   }   int main() {     int n, q, a, b;     cin >> n >> q;     for (int i = 1; i < n; i++) {       cin >> a;       g[a - 1].push_back(i);     }     for (int i = 0; i < n; i++) sort(g[i].begin(), g[i].end());     N = 0;     dfs(0);     for (int i = 0; i < q; i++) {       cin >> a >> b;       a--;       if (sz[a] < b)         cout << -1 << endl;       else         cout << x[p[a] + b - 1] + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   long long pr[300005], cr[300005];   long long nr[300005][2], fr[300005][2];   bool visit[300005], visit1[300005];   char str[300005];   vector<long long> vr[300005], br[300005];   void pre(), dfs(long long, long long);   long long uni(long long, long long), ccon(long long), ffind(long long);   int main() {     pre();     for (int i = 1; i < k + 1; i++)       if (!visit[i]) dfs(i, 0);     long long ans = 0;     for (int idx = 1; idx < n + 1; idx++) {       if (br[idx].size() == 1) {         long long v1 = br[idx][0];         ans -= ccon(v1);         if (str[idx] ==  0 ) {           fr[ffind(v1)][cr[v1]] = 1;         } else {           fr[ffind(v1)][!cr[v1]] = 1;         }         ans += ccon(v1);       } else if (br[idx].size() == 2) {         long long v1 = br[idx][0], v2 = br[idx][1];         if (ffind(v1) != ffind(v2)) {           ans -= ccon(v1) + ccon(v2);           long long p = uni(ffind(v1), ffind(v2));           ans += ccon(p);         }       }       cout << ans <<   n ;     }   }   long long ffind(long long idx) {     if (pr[idx] != idx) return pr[idx] = ffind(pr[idx]);     return idx;   }   long long uni(long long x, long long y) {     if (x == y) return x;     if (nr[x][0] + nr[x][1] < nr[y][0] + nr[y][1]) swap(x, y);     pr[y] = x;     nr[x][0] += nr[y][0];     nr[x][1] += nr[y][1];     fr[x][0] += fr[y][0];     fr[x][1] += fr[y][1];     return x;   }   long long ccon(long long idx) {     long long c = cr[idx];     long long p = ffind(idx);     if (fr[p][0]) return nr[p][0];     if (fr[p][1]) return nr[p][1];     return min(nr[p][0], nr[p][1]);   }   void pre() {     cin >> n >> k;     cin >> str + 1;     for (int i = 1; i < k + 1; i++) {       long long s;       cin >> s;       for (int j = 0; j < s; j++) {         long long x;         cin >> x;         vr[i].push_back(x);         br[x].push_back(i);       }     }   }   void dfs(long long idx, long long t) {     if (visit[idx]) return;     visit[idx] = true;     nr[idx][t] = 1;     cr[idx] = t;     pr[idx] = idx;     for (int i = 0; i < vr[idx].size(); i++) {       long long v = vr[idx][i];       for (int j = 0; j < br[v].size(); j++) {         long long node = br[v][j];         dfs(node, str[v] ==  1  ? t : !t);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<string> s;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     s.resize(n);     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = n - 1; i > 0; i--) {       int l = 1, r = min(s[i].length(), s[i - 1].length());       if (s[i - 1].compare(s[i]) < 0) continue;       while (l < r) {         int mid = l + r + 1 >> 1;         if (s[i - 1].compare(0, mid, s[i]) <= 0)           l = mid;         else           r = mid - 1;       }       s[i - 1] = s[i - 1].substr(0, l);     }     for (int i = 0; i < n; i++) cout << s[i] << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline char gc() {     static char buf[100000], *p1 = buf, *p2 = buf;     return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)                ? EOF                : *p1++;   }   inline long long read() {     long long x = 0;     char ch = getchar();     bool positive = 1;     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) positive = 0;     for (; isdigit(ch); ch = getchar()) x = x * 10 + ch -  0 ;     return positive ? x : -x;   }   inline void write(long long a) {     if (a < 0) {       a = -a;       putchar( - );     }     if (a >= 10) write(a / 10);     putchar( 0  + a % 10);   }   inline void writeln(long long a) {     write(a);     puts(  );   }   inline void wri(long long a) {     write(a);     putchar(   );   }   const int N = 205;   const long long inf = 4e18;   int n, m;   long long f[N][N], k, g[N][N];   string F[N];   long long sol(string x) {     int len = x.length();     x =     + x;     int p = 0;     memset(f, 0, sizeof(f));     for (int i = 1; i <= len; i++) x[i] -=  0 ;     f[0][x[1]] = 1;     for (int i = 1; i <= len; i++) {       if (i > 1) p = f[p][x[i]];       if (i < len && x[i + 1] == 0)         f[i][0] = i + 1;       else         f[i][0] = f[p][0];       if (i < len && x[i + 1] == 1)         f[i][1] = i + 1;       else         f[i][1] = f[p][1];     }     for (int i = 0; i <= len; i++) {       g[i][0] = f[i][0] == len;       g[i][1] = f[i][1] == len;     }     for (int i = 2; i <= n; i++) {       for (int j = 0; j <= len; j++) {         f[j][i] = f[f[j][i - 2]][i - 1];         g[j][i] = min(inf, g[j][i - 2] + g[f[j][i - 2]][i - 1]);       }     }     return g[0][n];   }   int main() {     n = read();     k = read();     m = read();     string s =   ;     F[0] =  0 ;     F[1] =  1 ;     for (int i = 2; i <= n; i++) {       F[i] = F[i - 2] + F[i - 1];       if (F[i].length() > m) F[i] = F[i].substr(F[i].length() - m, m);     }     m = min(m, (int)F[n].length());     for (int i = 1; i <= m; i++) {       if (s.length() &&           F[n].substr(F[n].length() - s.length(), s.length()) == s) {         if (--k == 0) {           cout << s << endl;           return 0;         }       }       s +=  0 ;       long long t = sol(s);       if (t < k) {         k -= t;         s.pop_back();         s +=  1 ;       }     }     cout << s << endl;   }