malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, U b) {     if (a < b) a = b;   }   template <class T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T>   inline void print(T first) {     if (first < 0) {       putchar( - );       return print(-first);     }     if (first < 10) {       putchar( 0  + first);       return;     }     print(first / 10);     putchar(first % 10 +  0 );   }   template <class T, class T1>   inline void gn(T &first, T1 &second) {     gn(first);     gn(second);   }   template <class T, class T1, class T2>   inline void gn(T &first, T1 &second, T2 &z) {     gn(first);     gn(second);     gn(z);   }   template <class T>   inline void println(T first) {     print(first);     putchar(  n );   }   template <class T>   inline void printsp(T first) {     print(first);     putchar(   );   }   template <class T1, class T2>   inline void print(T1 x1, T2 x2) {     printsp(x1), println(x2);   }   template <class T1, class T2, class T3>   inline void print(T1 x1, T2 x2, T3 x3) {     printsp(x1), printsp(x2), println(x3);   }   template <class T1, class T2, class T3, class T4>   inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {     printsp(x1), printsp(x2), printsp(x3), println(x4);   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   int main() {     int n, first;     cin >> n >> first;     if (n == 5 and first == 5) {       puts( >...v );       puts( v.<.. );       puts( ..^.. );       puts( >.... );       puts( ..^.< );       puts( 1 1 );       return 0;     }     if (n == 3 and first == 2) {       puts( >vv );       puts( ^<. );       puts( ^.< );       puts( 1 3 );       return 0;     }     for (int i = 1; i <= n; i += 2) {       putchar( v );       for (int j = 2; j <= n / 2; j++) {         if (j & 1)           putchar( . );         else           putchar( < );       }       for (int j = n / 2 + 1; j <= n; j++) {         putchar( < );       }       puts(  );       for (int j = 1; j <= n / 2; j++) putchar( > );       for (int j = n / 2 + 1; j < n; j++) {         if (j & 1)           putchar( . );         else           putchar( > );       }       puts( ^ );     }     print(1, 1);     return 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void rc(char &a) {     a = 0;     register int x = getchar_unlocked();     while (x <  a  || x >  z ) {       if (x ==   n ) {         a =  0 ;         return;       }       x = getchar_unlocked();     }     a = x;   }   const int maxn = 100100;   int key;   int main() {     ios_base::sync_with_stdio(0);     string ans =   ;     char cur;     while (true) {       rc(cur);       if (cur ==  0 ) break;       if (cur ==  a ) {         if (key == 0)           ans +=  a ;         else if (key == 1) {           ans +=  a ;           key = 2;         } else {           ans +=  a ;         }       } else {         if (key == 1)           ans += (cur - 1);         else if (key == 0) {           ans += (cur - 1);           key = 1;         } else {           ans += cur;         }       }     }     if (key == 0) {       ans = ans.substr(0, ans.size() - 1) +  z ;       cout << ans <<   n ;       return 0;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline string tostring(const T &x) {     ostringstream os;     os << x;     return os.str();   }   inline int toint(const string &s) {     istringstream is(s);     int x;     is >> x;     return x;   }   inline int todecimal(string s) {     int a = 0;     for (int i = 0; i < s.size(); i++) a = 2 * a + (s[i] -  0 );     return a;   }   inline string tobinary(int a) {     string s;     while (a != 0) {       s = (char)(a % 2 +  0 ) + s;       a >>= 1;     }     return s;   }   template <typename T>   inline T sqr(T x) {     return x * x;   }   template <typename T>   T gcd(T a, T b) {     return (b == 0) ? abs(a) : gcd(b, a % b);   }   inline int isvowel(char c) {     if (c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u ) return 1;     return 0;   }   inline int isprime(int a) {     for (int i = 2; i * i <= a; i++)       if (!(a % i)) return 0;     return 1;   }   inline void inp(int &n) {     n = 0;     int ch = getchar();     int sign = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) sign = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       n = (n << 3) + (n << 1) + ch -  0 , ch = getchar();     n = n * sign;   }   const int dx4[4] = {0, 0, 1, -1};   const int dy4[4] = {1, -1, 0, 0};   const int dx8[8] = {0, 0, 1, 1, 1, -1, -1, -1};   const int dy8[8] = {1, -1, 0, 1, -1, 1, 0, -1};   class node {    public:     int x, y, z;     node(int a, int b, int c) {       x = a;       y = b;       z = c;     }   };   bool operator<(const node &a, const node &b) { return a.x > b.x; }   bool compare(const node &a, const node &b) { return a.x < b.x; }   int n, m;   void solve() {     cout << n + m - 1 << endl;     for (int i = 0; i < m; i++) {       cout << 1 <<     << i + 1 << endl;     }     for (int i = 0; i < n - 1; i++) {       cout << i + 2 <<     << 1 << endl;     }   }   void input() { cin >> n >> m; }   int main() {     int testcase = 1;     for (int i = 0; i < testcase; i++) {       input();       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x, d, v;   vector<long long> res;   void solve() {     cin >> x >> d;     res.clear();     v = 1;     for (int j = 0; j <= 30; j++) {       if ((1 << j) & x) {         for (int k = 1; k <= j; k++) res.push_back(v);         v += d + 1;         res.push_back(v);         v += d + 1;       }     }     cout << res.size() <<   n ;     for (int i = 0; i < res.size(); i++) cout << res[i] <<    ;     cout <<   n ;   }   int main() {     std::ios::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, big, small, counter = 0, y, b = 0;     cin >> x;     int a[x];     for (int i = 0; i < x; i++) {       cin >> y;       a[i] = y;     }     big = max_element(a, a + x) - a;     for (int i = 0; i < big; i++) {       swap(a[big - i], a[big - 1 - i]);       counter++;     }     small = min_element(a, a + x) - a;     for (int i = 0; i < x; i++) {       if (a[i] == a[small]) small = i;     }     for (int i = x - 1; i > small; i--, b++) {       swap(a[small + b], a[small + 1 + b]);       counter++;     }     cout << counter;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   int main() {     long long m, n, i;     while (cin >> n >> m) {       long long a[n + 1], b;       a[0] = 0;       for (i = 0; i < n; i++) {         cin >> a[i + 1];         a[i + 1] += a[i];       }       for (i = 0; i < m; i++) {         cin >> b;         auto j = lower_bound(a, a + n, b) - a;         cout << j <<     << b - a[j - 1] <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b) {       return a;     } else {       return b;     }   }   long long min(long long a, long long b) {     if (a < b) {       return a;     } else {       return b;     }   }   long long n, m, p;   int a[200003], b[200003];   int main() {     multiset<int> st;     scanf( %I64d%I64d%I64d , &n, &m, &p);     int k = 0;     for (int i = (1); i <= (n); i++) {       scanf( %d , &a[i]);     }     for (int i = (1); i <= (m); i++) {       scanf( %d , &b[i]);     }     int ans[200001], anscnt = 0;     for (int i = (1); i <= (p); i++) {       int q = i;       st.clear();       multiset<int>::iterator it;       if (q + (m - 1) * p <= n) {         for (int j = (1); j <= (m); j++) st.insert(b[j]);         for (int j = (0); j <= (m - 2); j++) {           it = st.find(a[j * p + q]);           if (it != st.end()) {             st.erase(it);           } else {             st.insert(-1 * a[j * p + q]);           }         }       }       while (q + (m - 1) * p <= n) {         it = st.find(a[(m - 1) * p + q]);         if (it != st.end()) {           st.erase(it);         } else {           st.insert(-1 * a[(m - 1) * p + q]);         }         if (st.empty()) ans[++anscnt] = q;         it = st.find(a[q] * -1);         if (it != st.end()) {           st.erase(it);         } else {           st.insert(a[q]);         }         q += p;       }     }     sort(ans + 1, ans + anscnt + 1);     printf( %d n , anscnt);     for (int i = (1); i <= (anscnt); i++) printf( %d  , ans[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   template <class T, class U>   inline void Max(T &a, U b) {     if (a < b) a = b;   }   template <class T, class U>   inline void Min(T &a, U b) {     if (a > b) a = b;   }   inline void add(int &a, int b) {     a += b;     while (a >= 1000000007) a -= 1000000007;   }   int pow(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = ans * (long long)a % 1000000007;       a = (long long)a * a % 1000000007;       b >>= 1;     }     return ans;   }   char s[5010];   int dp[5010][5010], ne[5010][26], f[5010], inv[5010], sum[5010];   int C(int a, int b) {     return 1LL * f[a] * inv[a - b] % 1000000007 * inv[b] % 1000000007;   }   int main() {     int T, i, j, k, ca = 0, m, K = 0, n;     scanf( %d%s , &n, s);     f[0] = 1;     for (int i = 1; i < n + 1; i++) f[i] = f[i - 1] * (long long)i % 1000000007;     inv[n] = pow(f[n], 1000000007 - 2);     for (int i = n - 1; i >= 0; i--)       inv[i] = inv[i + 1] * (long long)(i + 1) % 1000000007;     int last[26] = {0};     memset(last, -1, sizeof(last));     sum[0] = 1;     for (int i = 1; i < n + 1; i++) {       int c = s[i - 1] -  a ;       for (int j = i + 1 - 1; j >= 1; j--) {         if (last[c] != -1) {           dp[i][j] = (sum[j - 1] - dp[last[c]][j - 1] + 1000000007) % 1000000007;           sum[j] = (0LL + sum[j] + dp[i][j] - dp[last[c]][j] + 1000000007) %                    1000000007;         } else {           dp[i][j] = sum[j - 1];           add(sum[j], dp[i][j]);         }       }       last[c] = i;     }     int ans = 0;     for (int i = 1; i < n + 1; i++)       if (sum[i]) {         add(ans, 1LL * sum[i] * C(n - 1, i - 1) % 1000000007);       }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( Ofast )   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     int a[n], ans = 0;     for (int i = (0); i < (n); ++i) cin >> a[i];     for (int l = (0); l < (n); ++l) {       long long k = 2LL << (int)log2(a[l]), sum = 0;       for (int r = (l + 2); r < (n); ++r) {         sum += a[r - 1];         if (sum >= k) break;         if ((a[l] >= a[r]) and (a[l] ^ a[r]) == sum) ++ans;       }     }     for (int r = (n)-1; r >= (0); --r) {       long long k = 2LL << (int)log2(a[r]), sum = 0;       for (int l = (r - 1) - 1; l >= (0); --l) {         sum += a[l + 1];         if (sum >= k) break;         if ((a[l] < a[r]) and (a[r] ^ a[l]) == sum) ++ans;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a = 1;     cin >> n;     for (int i = 0; i < n; i++) {       if (a <= 2) {         cout <<  a ;         a++;       } else if (a > 2 && a <= 4) {         cout <<  b ;         a++;       } else {         cout <<  a ;         a = 2;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimize( unroll-loops )   using namespace std;   template <typename T>   bool mycomp(T x, T y) {     return (x == y);   }   bool paircomp(const pair<long long int, long long int> &x,                 const pair<long long int, long long int> &y) {     return x.second < y.second;   }   void solve() {     long long int n, m;     cin >> n >> m;     string s[n];     for (long long int i = 0; i < n; i++) cin >> s[i];     long long int labx, laby;     for (long long int i = 0; i < n; i++) {       for (long long int j = 0; j < m; j++) {         if (s[i][j] ==  L ) labx = i, laby = j;       }     }     bool vis[n][m];     memset(vis, false, sizeof(vis));     queue<pair<long long int, long long int> > qe;     qe.push({labx, laby});     vis[labx][laby] = true;     while (!qe.empty()) {       long long int x = qe.front().first, y = qe.front().second;       qe.pop();       if (s[x][y] !=  L ) {         long long int no = 0;         if (x && s[x - 1][y] ==  . ) no++;         if (x < n - 1 && s[x + 1][y] ==  . ) no++;         if (y && s[x][y - 1] ==  . ) no++;         if (y < m - 1 && s[x][y + 1] ==  . ) no++;         if (no <= 1)           s[x][y] =  + , vis[x][y] = true;         else           continue;       }       if (x && !vis[x - 1][y] && s[x - 1][y] !=  # ) qe.push({x - 1, y});       if (x < n - 1 && !vis[x + 1][y] && s[x + 1][y] !=  # ) qe.push({x + 1, y});       if (y && !vis[x][y - 1] && s[x][y - 1] !=  # ) qe.push({x, y - 1});       if (y < m - 1 && !vis[x][y + 1] && s[x][y + 1] !=  # ) qe.push({x, y + 1});     }     for (long long int i = 0; i < n; i++) {       cout << s[i] <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t = 1;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int fx[] = {1, -1, 0, 0};   int fy[] = {0, 0, 1, -1};   int main() {     long long n;     cin >> n;     if (n == 1)       cout << 1;     else if (n == 2)       cout << 3;     else {       n += 3;       long long a = 0, b = 1;       for (int i = 2; i <= n; i++) {         long long c = (a + b) % 1000000007;         a = b % 1000000007;         b = c % 1000000007;       }       cout << (b - 2 + 1000000007) % 1000000007 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 301;   string s[N][N];   vector<pair<pair<int, int>, pair<int, int> > > f(int n, int k) {     vector<pair<pair<int, int>, pair<int, int> > > ans;     pair<int, int> f0 = {1, 0}, f1 = {0, 1};     int i, j, l;     for (i = 0; i < s[0][0].size(); ++i)       if (s[0][0][i] ==  0 )         ans.push_back({{0, 0}, f0});       else         ans.push_back({{0, 0}, f1});     for (i = 1; i < k; ++i)       for (l = 0; l < s[0][i].size(); ++l) {         ans.push_back({{0, i}, {0, 0}});         if (s[0][i][l] ==  0 )           ans.push_back({{0, 0}, f0});         else           ans.push_back({{0, 0}, f1});       }     for (i = 1; i < n; ++i)       for (l = 0; l < s[i][0].size(); ++l) {         ans.push_back({{i, 0}, {0, 0}});         if (s[i][0][l] ==  0 )           ans.push_back({{0, 0}, f0});         else           ans.push_back({{0, 0}, f1});       }     for (i = 1; i < n; ++i)       for (j = 1; j < k; ++j)         for (l = 0; l < s[i][j].size(); ++l)           if (s[i][j][l] ==  0 ) {             ans.push_back({{i, j}, {i, 0}});             if (i != 1) ans.push_back({{i, 0}, f0});           } else {             ans.push_back({{i, j}, {0, j}});             if (j != 1) ans.push_back({{0, j}, f1});           }     return ans;   }   int main() {     int i, j, k, n, p, l;     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (i = 0; i < n; ++i)       for (j = 0; j < k; ++j) {         cin >> s[i][j];         for (l = 0; l < s[i][j].size() / 2; ++l)           swap(s[i][j][l], s[i][j][s[i][j].size() - l - 1]);       }     vector<pair<pair<int, int>, pair<int, int> > > ans1, ans2;     ans1 = f(n, k);     for (i = 0; i < n; ++i)       for (j = 0; j < k; ++j) cin >> s[i][j];     ans2 = f(n, k);     cout << ans1.size() + ans2.size() << endl;     for (i = 0; i < ans1.size(); ++i)       cout << ans1[i].first.first + 1 <<     << ans1[i].first.second + 1 <<                << ans1[i].second.first + 1 <<     << ans1[i].second.second + 1            <<   n ;     for (i = ans2.size() - 1; i >= 0; --i)       cout << ans2[i].second.first + 1 <<     << ans2[i].second.second + 1 <<                << ans2[i].first.first + 1 <<     << ans2[i].first.second + 1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long mod = 1e9 + 7;   unsigned long long ncr(long long int n, long long int k) {     unsigned long long res = 1;     if (k > n - k) k = n - k;     for (int i = 0; i < k; ++i) {       res *= (n - i);       res /= (i + 1);       res = res;     }     return res;   }   bool prime(unsigned long long num) {     bool flag = true;     for (unsigned long long i = 2; i * i <= num; i++) {       if (num % i == 0) {         flag = false;         break;       }     }     return flag;   }   long long ipow(long long base, long long exp) {     long long result = 1;     for (;;) {       if (exp & 1) {         result *= base;         result = result % mod;       }       exp >>= 1;       if (!exp) break;       base *= base;       base = base % mod;     }     return result % mod;   }   long long abs(long long a, long long b) {     if ((a - b) > 0)       return (a - b);     else       return (b - a);   }   long long MOD = 998244353;   long long add(long long a, long long b) {     a += b;     if (a >= mod) a -= mod;     if (a < 0) a += mod;     return a;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long der(int k) {     long long res = 0;     long long fact = 1;     for (int i = 2; i <= k; i++) fact *= i;     int s = 1;     long long j = 1;     for (int i = 2; i <= k; i++) {       j = j * i;       long long first = (fact / j) * s;       res += first;       s = s * -1;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s;     cin >> s;     set<int> one, z;     int len = s.length();     for (int i = 0; i < len; i++) {       if (s[i] ==  0 )         z.insert(i + 1);       else         one.insert(i + 1);     }     vector<vector<int>> subs;     vector<int> sub;     while (true) {       if (z.empty()) break;       auto it = z.begin();       sub.push_back(*it);       int val = *it;       z.erase(it);       while (!z.empty()) {         auto it1 = one.lower_bound(val);         if (it1 == one.end()) break;         it = z.lower_bound(*it1);         if (it == z.end()) break;         int val1 = *it1;         val = *it;         sub.push_back(val1);         one.erase(it1);         sub.push_back(val);         z.erase(it);       }       subs.push_back(sub);       sub.clear();     }     if (!one.empty()) {       cout <<  -1 ;       return 0;     } else {       cout << subs.size() << endl;       for (int i = 0; i < subs.size(); i++) {         cout << subs[i].size() <<    ;         for (int j = 0; j < subs[i].size(); j++) {           cout << subs[i][j] <<    ;         }         cout << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int h;   const int mx = 2e5 + 5;   vector<int> a(mx);   void eval1() {     cout << 0;     int x = 1, y = 1;     for (int i = 1; i <= h; i++) {       for (int j = 0; j < a[i]; j++) {         cout <<     << x;         y++;       }       x = y;     }     cout << endl;   }   void eval2() {     cout << 0;     int x = 1, y = 1, z = 1;     for (int i = 1; i <= h; i++) {       int p = a[i] / 2, q = a[i] - p;       vector<int> cand;       if (p) {         for (int j = 0; j < p; j++) {           cout <<     << x;           z++;           cand.push_back(z);         }         x = cand[0];       }       if (q) {         cand.clear();         for (int j = 0; j < q; j++) {           cout <<     << y;           z++;           cand.push_back(z);         }         if (p == 0) x = cand[0];         y = cand[0];       }     }     cout << endl;   }   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(0);     cin >> h;     for (int i = 0; i <= h; i++) cin >> a[i];     int vio = -1;     for (int i = 0; i < h; i++)       if (a[i] > 1 && a[i + 1] > 1) {         vio = i;         break;       }     if (vio == -1) {       cout <<  perfect  << endl;       return 0;     }     cout <<  ambiguous  << endl;     eval1();     eval2();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 10;   set<int> s[M];   int n, p[M];   bool check(int x) {     vector<int> b;     while (x) {       b.push_back(x % 10);       x /= 10;     }     if (b.size() > n) return false;     for (int i = 0; i < b.size(); i++)       if (s[p[i]].find(b[i]) == s[p[i]].end()) return false;     return true;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       p[i] = i;       for (int j = 0; j < 6; j++) {         int x;         cin >> x;         s[i].insert(x);       }     }     for (int x = 1;; x++) {       int fnd = false;       for (int i = 0; i < n; i++) p[i] = i;       do {         if (check(x)) fnd = true;       } while (next_permutation(p, p + n));       if (!fnd) return cout << x - 1 << endl, 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[220000];   int s[220000];   int g[220000];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d%d , s + i, g + i);       a[i] = s[i] + g[i];     }     for (int i = 0; i < n - 1; ++i) a[i + 1] = min(a[i + 1], a[i] + 1);     for (int i = n - 1; i > 0; --i) a[i - 1] = min(a[i - 1], a[i] + 1);     long long ans = 0;     for (int i = 0; i < n; ++i) {       if (a[i] < s[i]) {         printf( -1 n );         return 0;       }       ans += a[i] - s[i];     }     printf( %lld n , ans);     for (int i = 0; i < n; ++i) printf( %d  , a[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     vector<int> a(n), b(n);     for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];     int maxCap = b[0], curCap = b[0];     for (int i = 1; i < n; ++i) {       curCap = curCap - a[i] + b[i];       maxCap = max(maxCap, curCap);     }     cout << maxCap <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Tp>   inline void read(Tp &x) {     static char c;     static bool neg;     x = 0, c = getchar(), neg = false;     for (; !isdigit(c); c = getchar()) {       if (c ==  - ) {         neg = true;       }     }     for (; isdigit(c); c = getchar()) {       x = x * 10 + c -  0 ;     }     if (neg) {       x = -x;     }   }   const int N = 100 + 5;   int k, n = 0;   int mp[N][N];   inline int C(int n, int m) {     if (m == 2) {       return n * (n - 1) / 2;     } else if (m == 3) {       return n * (n - 1) * (n - 2) / 6;     } else {       return -1;     }   }   int main() {     read(k);     for (; C(n, 3) <= k; ++n)       ;     --n;     for (int i = 1; i <= n; ++i) {       for (int j = i + 1; j <= n; ++j) {         mp[i][j] = mp[j][i] = 1;       }     }     k -= C(n, 3);     while (k > 0) {       int t = 0;       for (; C(t, 2) <= k; ++t)         ;       --t;       ++n;       for (int i = 1; i <= t; ++i) {         mp[n][i] = mp[i][n] = 1;       }       k -= C(t, 2);     }     printf( %d n , n);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         putchar( 0  + mp[i][j]);       }       puts(  );     }   }