malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   void io() {}   long long fast_exp(long long base, int exp, int m) {     long long res = 1;     while (exp > 0) {       if (exp % 2 == 1) {         res = (res * base) % m;       }       base = (base * base) % m;       exp /= 2;     }     return res % m;   }   vector<pair<long long, string> > v[10001];   long long dp[2001][4];   int main() {     io();     ios ::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     while (n--) {       string s;       long long r, p;       cin >> s >> r >> p;       v[r].push_back(make_pair(p, s));     }     for (int i = 1; i <= int(m); ++i) {       sort(v[i].begin(), v[i].end());       int siz = v[i].size();       if (siz == 2) {         cout << v[i][siz - 1].second <<     << v[i][siz - 2].second <<   n ;       } else if ((v[i][siz - 2].first == v[i][siz - 3].first)) {         cout <<  ?  <<   n ;       } else {         cout << v[i][siz - 1].second <<     << v[i][siz - 2].second <<   n ;       }     }   }
#include <bits/stdc++.h>   struct oficinas {     int valor;     int sig;   };   int v[200002], vaux[200002];   int buscar(int buscado);   int main() {     int n, q, type, x, y, i, A, B, aux;     scanf( %d %d , &n, &q);     for (i = 1; i <= n; i++) {       v[i] = i;       vaux[i] = i + 1;     }     for (i = 0; i < q; i++) {       scanf( %d %d %d , &type, &x, &y);       switch (type) {         case 1:           v[buscar(x)] = buscar(y);           break;         case 2:           while (x < y) {             v[buscar(x)] = buscar(y);             aux = vaux[x];             vaux[x] = vaux[y];             x = aux;           }           break;         case 3:           printf( %s n , buscar(x) == buscar(y) ?  YES  :  NO );           break;       }     }     return 0;   }   int buscar(int buscado) {     return v[buscado] = v[buscado] == buscado ? buscado : buscar(v[buscado]);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100 + 10;   int a[maxn], chk[maxn];   string str;   int main() {     int n, k = 0;     cin >> n >> str;     if (str.size() < n) {       cout <<  NO ;       return 0;     }     for (int i = 0; i < str.size(); i++) {       if (a[str[i] -  0 ] == 0) k++;       a[str[i] -  0 ] = 1;     }     if (k < n) {       cout <<  NO ;       return 0;     }     cout <<  YES  << endl;     for (int i = 0; i < str.size(); i++) {       if (chk[str[i] -  0 ] == 0 && n > 1 && i != 0) {         cout << endl;         n--;       }       cout << str[i];       chk[str[i] -  0 ] = 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> v;     for (int i = 0; i < n; i++) {       int num;       cin >> num;       v.push_back(num);     }     vector<pair<int, int> > vp;     int x, y;     for (int i = 0; i < n; i++) {       if (i == 0) {         x = v[i + 1] - v[i];         y = v[n - 1] - v[i];       } else if (i == n - 1) {         x = v[i] - v[i - 1];         y = v[i] - v[0];       } else {         x = min(v[i] - v[i - 1], v[i + 1] - v[i]);         y = max(v[i] - v[0], v[n - 1] - v[i]);       }       vp.push_back(make_pair(x, y));     }     for (auto &i : vp) {       cout << i.first <<     << i.second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   long long INF = 1e18;   bool isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   long long nCr(long long n, long long r) {     long long res = 1;     if (n < r) return -1;     r = min(r, n - r);     for (long long i = 0; i < r; i++) {       res *= (n - i);       res /= (i + 1);     }     return res;   }   long long nPr(long long n, long long r) {     long long res = 1;     if (n < r) return -1;     for (long long i = 0; i < r; i++) res *= (n - i);     return res;   }   long long modexp(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x) % mod;       x = (x * x) % mod;       y = y >> 1;     }     return res;   }   void solve() {     long long a, b, c;     cin >> a >> b >> c;     long long d, e, f;     f = sqrt(c * a / b);     d = sqrt(a * b / c);     e = sqrt(b * c / a);     cout << 4 * (d + e + f);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long BIG = 1000000007;   const double PI = 3.141592653589793238;   template <typename T, typename Q>   T max(T a, Q b) {     if (a < b) return b;     return a;   }   template <typename T, typename Q>   T min(T a, Q b) {     if (a > b) return b;     return a;   }   long gcd(long a, long b) {     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   bool check(char arr[8][8], int i) {     for (int j = 0; j < 8; j++) {       if (arr[i][j] ==  W ) return false;     }     return true;   }   bool check1(char arr[8][8], int i) {     for (int j = 0; j < 8; j++) {       if (arr[j][i] ==  W ) return false;     }     return true;   }   void solve() {     char arr[8][8];     int ans = 0;     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         cin >> arr[i][j];         if (arr[i][j] ==  B ) ans++;       }     }     if (ans == 64) {       cout <<  8             <<   n ;       ;       return;     }     ans = 0;     for (int i = 0; i < 8; i++) {       if (check(arr, i)) ans++;     }     for (int i = 0; i < 8; i++) {       if (check1(arr, i)) ans++;     }     cout << ans <<   n ;     ;   }   int main() {     int t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = (1e-8);   int dcmp(double a, double b) {     if (fabs(a - b) <= eps) return 0;     return a < b ? -1 : 1;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n, m;     double w;     cin >> n >> w >> m;     double how = n * w / (m * 1.0);     vector<vector<pair<int, double> > > res(m);     vector<double> bottles;     vector<int> cnt(n, 0);     for (int i = 0; i < n; i++) bottles.push_back(w);     cout << fixed << setprecision(6);     for (int i = 0; i < m; i++) {       double temp = how;       for (int j = 0; j < n; j++) {         if (dcmp(bottles[j], 0) == 0) continue;         if (dcmp(temp, 0) == 0) break;         if (bottles[j] > temp) {           res[i].push_back({j, temp});           bottles[j] -= temp;           temp = 0;           cnt[j]++;           break;         } else {           res[i].push_back({j, bottles[j]});           temp -= bottles[j];           bottles[j] = 0;           cnt[j]++;         }       }       if (dcmp(temp, 0) != 0) return cout <<  NO  << endl, 0;     }     for (int i = 0; i < n; i++) {       if (cnt[i] > 2 || dcmp(bottles[i], 0) != 0) return cout <<  NO  << endl, 0;     }     cout <<  YES  << endl;     for (int i = 0; i < m; i++) {       for (auto p : res[i]) {         cout << p.first + 1 <<     << p.second <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v;   int main() {     v.push_back(0);     for (int i = 0; i < int(30); i++) v.push_back(1 << i);     while (1) {       int hi, lo;       int test;       string s;       cin >> s;       if (s ==  mistake  || s ==  end ) return 0;       bool found = 0;       for (int i = 0; i < int(30); i++) {         cout <<  ?   << v[i] <<     << v[i + 1] << endl;         fflush(stdout);         char c;         cin >> c;         if (c ==  e ) return 0;         if (c ==  x ) {           found = 1;           lo = v[i] + 1;           hi = v[i + 1];           test = v[i];           break;         }       }       if (!found) {         lo = v[v.size() - 1] + 1;         hi = 1000000000;         test = v[v.size() - 1];       }       while (hi - lo > 1) {         int mid = (lo + hi) / 2;         cout <<  ?   << test <<     << mid << endl;         fflush(stdout);         char c;         cin >> c;         if (c ==  e ) return 0;         if (c ==  x )           hi = mid;         else           lo = mid + 1;       }       cout <<  ?   << test <<     << lo << endl;       fflush(stdout);       char c;       cin >> c;       if (c ==  e ) return 0;       if (c ==  x )         cout <<  !   << lo << endl;       else         cout <<  !   << hi << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1073741824;   const int N = 200005;   const double PI = 4 * atan(1);   set<char> vowel = { A ,  O ,  Y ,  E ,  U ,  I ,  a ,  o ,  e ,  u ,  y ,  i };   int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};   int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};   long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }   long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }   bool issquare(long long w) { return trunc(sqrt(w)) * trunc(sqrt(w)) == w; }   bool isprime(long long u) {     for (long long i = 2; i <= (int)sqrt(u); i++) {       if (u % i == 0) return 0;     }     return 1;   }   long long mod(long long to_mod) {     to_mod %= MOD;     while (to_mod < 0) to_mod += MOD;     return to_mod % MOD;   }   long long moduloMultiplication(long long a, long long b, long long mod) {     long long res = 0;     a %= mod;     while (b) {       if (b & 1) res = (res + a) % mod;       a = (2 * a) % mod;       b >>= 1;     }     return res;   }   long long power(long long x, long long y) {     long long res = 1;     x = x;     while (y > 0) {       if (y & 1) res = (res * x);       y = y >> 1;       x = (x * x);     }     return res;   }   long long n, m, k, q, res, x, y, ans;   string ch, sh, d;   bool ok(string ss, long long len) {     string second =   ;     for (int i = 1; i <= max(n / len, m / len); i++) {       second += ss;       if (i == n / len) {         if (ch != second) return 0;       }       if (i == m / len) {         if (sh != second) return 0;       }     }     return 1;   }   int main() {     cin >> ch;     cin >> sh;     n = ch.size();     m = sh.size();     k = min(n, m);     long long i = 0;     d =   ;     ans = 0;     x = 0;     while (i < k && ch[i] == sh[i]) {       d += ch[i];       x++;       if (n % x == 0 && m % x == 0) {         if (ok(d, x)) ans++;       }       i++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long r = 0, mod = 1e9 + 7, a, b, i, z, x, y;     cin >> a >> b;     for (i = 1; i < b; ++i) {       r += i * a + b * i % mod * (a * (a + 1) / 2 % mod);       r %= mod;     }     cout << r << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int x = 0, y = 0, i, j, count = 0, n;     cin >> n;     string s1;     cin >> s1;     for (i = 0; i < n - 1; i++) {       x = 0;       y = 0;       for (j = i; j < s1.size(); j++) {         switch (s1[j]) {           case  U :             ++y;             break;           case  D :             --y;             break;           case  L :             --x;             break;           case  R :             ++x;             break;         }         if (x == 0 && y == 0) ++count;       }     }     cout << count;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     int m;     cin >> m;     vector<int> b(m);     for (int i = 0; i < m; ++i) {       cin >> b[i];     }     int M = -1, cur = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (b[j] % a[i]) continue;         int x = b[j] / a[i];         if (x > M) {           M = x;           cur = 1;         } else if (x == M)           ++cur;       }     }     cout << cur;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d%d , &n, &m);     if (m == 3 && n > 4) return puts( -1 ), 0;     for (int i = 1; i <= m; i++) printf( %d %d n , i, i * i + 300000);     for (int i = 1; i <= n - m; i++) printf( %d %d n , i, -i * i - 300000);   }
#include <bits/stdc++.h>   using namespace std;   int R;   vector<int> hv, use;   vector<char> ans;   int req[1000005];   int fr[1000005];   int main() {     int n;     scanf( %d , &n);     if (n >= 1389)       R = 4;     else if (n >= 232)       R = 3;     else if (n >= 199)       R = 2;     else if (n >= 2)       R = 1;     else {       printf( a a n );       return 0;     }     for (int i = 0; i < R; i++) hv.push_back(0);     hv.push_back(1);     for (int i = R + 1;; i++) {       hv.push_back(hv.back() * i / (i - R));       if (hv.back() > n) break;     }     for (int &u : hv) u--;     for (int i = 0; i < 2 * R; i++) hv[i] = 0;     for (int i = 1; i <= n; i++) req[i] = 10000005;     for (int i = 0; i <= n; i++) fr[i] = -1;     for (int i = 1; i <= n; i++)       for (unsigned j = 0; j < hv.size(); j++)         if (hv[j] <= i) {           if (req[i - hv[j]] + j < req[i]) {             req[i] = req[i - hv[j]] + j;             fr[i] = j;           }         } else           break;     n--;     for (int i = n; i; i -= hv[fr[i]]) use.push_back(fr[i]);     for (unsigned i = 0; i < use.size(); i++)       for (int j = 0; j < R; j++) printf( %c ,  a  + i);     for (int i = use.size() - 1; i >= 0; i--)       for (int j = 2 * R; j < use[i]; j++) printf( %c ,  a  + i);     for (unsigned i = 0; i < use.size(); i++)       for (int j = 0; j < R; j++) printf( %c ,  a  + i);     printf(   );     for (unsigned i = 0; i < use.size(); i++)       for (int j = 0; j < R; j++) printf( %c ,  a  + i);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000000;   long long cost[N][10], step[N][10], n;   int getMax(int x) {     int ret = 0;     while (x) {       ret = max(ret, int(x % 10));       x /= 10;     }     return ret;   }   void init() {     for (int i = 0; i < N; i++) {       int c = getMax(i);       for (int j = 0; j < 10; j++) {         int v = max(j, c);         if (i < v) {           step[i][j] = 1;           cost[i][j] = v;         } else {           step[i][j] = step[i - v][j] + 1;           cost[i][j] = cost[i - v][j] + v;         }       }     }   }   int main() {     init();     scanf( %lld , &n);     long long ans = 0;     while (n >= N) {       int j = getMax(n / N);       ans += step[n % N][j];       n -= cost[n % N][j];     }     while (n > 0) {       int j = getMax(n);       ans += 1;       n -= j;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > v;   vector<vector<int> > vv;   vector<vector<long long int> > dp;   void merg(int x) {     if (v[x].size() == 1) return;     if (v[x].size() == 2) {       vector<int> v1;       v1.push_back(0);       for (int i = 0; i < v[x * 2].size(); i++) {         v1.push_back(v[x * 2][i] + v[x][1]);       }       v[x] = v1;       return;     }     vector<int> v1 = v[x * 2];     vector<int> v2 = v[x * 2 + 1];     for (int i = 0; i < v1.size(); i++) v1[i] += v[x][1];     for (int i = 0; i < v2.size(); i++) v2[i] += v[x][2];     v[x].resize(1);     int idx1 = 0;     int idx2 = 0;     while (idx1 < v1.size() && idx2 < v2.size()) {       if (v1[idx1] < v2[idx2]) {         v[x].push_back(v1[idx1]);         idx1++;       } else {         v[x].push_back(v2[idx2]);         idx2++;       }     }     while (idx1 != v1.size()) v[x].push_back(v1[idx1++]);     while (idx2 != v2.size()) v[x].push_back(v2[idx2++]);   }   int bs(int a, int h, int l, int r) {     if (l == r) return l;     int mid = (l + r) / 2;     if (v[a][mid] > h) return bs(a, h, l, mid);     if (v[a][mid + 1] > h) return mid;     return bs(a, h, mid + 1, r);   }   long long int cal(int a, long long int h) {     if (h < 0) return 0;     long long int ans = 0;     int x = bs(a, h, 0, v[a].size() - 1);     ans = h * ((long long int)(x + 1)) - dp[a][x];     return ans;   }   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     int n, m;     cin >> n >> m;     v.resize(n + 3);     vv.resize(n + 3);     dp.resize(n + 3);     for (int i = 1; i <= n; i++) v[i].push_back(0);     int x;     for (int i = 1; i <= n - 1; i++) {       cin >> x;       v[(i + 1) / 2].push_back(x);       vv[(i + 1) / 2].push_back(x);     }     for (int i = n; i >= 1; i--) merg(i);     for (int i = 1; i <= n; i++) {       dp[i].push_back(v[i][0]);       for (int j = 1; j < v[i].size(); j++) {         dp[i].push_back(((long long int)(v[i][j])) + dp[i][j - 1]);       }     }     for (int i = 0; i < m; i++) {       int a, h;       cin >> a >> h;       long long int ans = 0;       ans += cal(a, h);       while (a != 1) {         if (a % 2 == 0) {           a /= 2;           if (h - vv[a][0] <= 0) break;           ans += h - vv[a][0];           if (vv[a].size() == 2) {             h = h - vv[a][0] - vv[a][1];             a = a * 2 + 1;             ans += cal(a, h);             a /= 2;             h += vv[a][1];           } else {             h -= vv[a][0];           }         } else {           a /= 2;           if (h - vv[a][1] <= 0) break;           ans += h - vv[a][1];           h = h - vv[a][0] - vv[a][1];           a = a * 2;           ans += cal(a, h);           a /= 2;           h += vv[a][0];         }       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, m, rb, cb, rd, cd;       int count = 0;       cin >> n >> m >> rb >> cb >> rd >> cd;       if (rb <= rd && cb <= cd)         cout << min(rd - rb, cd - cb) << endl;       else if (rb <= rd && cb > cd)         cout << min(rd - rb, 2 * m - cb - cd) << endl;       else if (cb <= cd && rb > rd)         cout << min(cd - cb, 2 * n - rb - rd) << endl;       else         cout << min(2 * n - rb - rd, 2 * m - cb - cd) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, q, a[3000000 + 5], m[3000000 + 5], dp[3000000 + 5];   inline long long read() {     long long q = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = 0;       ch = getchar();     }     while (isdigit(ch)) q = (q << 3) + (q << 1) + (ch ^ 48), ch = getchar();     return f ? q : -q;   }   inline void print(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) print(x / 10);     putchar(x % 10 + 48);   }   signed main() {     n = read();     for (register long long i = 1; i <= n; ++i) a[i] = read(), ++m[a[i]];     for (register long long i = 1; i <= 3000000; ++i)       if (m[i])         for (register long long j = i; j <= 3000000; j += i)           dp[j] += m[i] * ((i ^ (j / i)) ? m[j / i] : m[i] - 1);     for (register long long i = 1; i <= 3000000; ++i) dp[i] += dp[i - 1];     q = read();     while (q--) {       long long x = read();       print(n * (n - 1) - dp[x - 1]), putchar(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long s = 0, w = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) w = -1;     for (; isdigit(ch); ch = getchar()) s = (s << 1) + (s << 3) + (ch ^ 48);     return s * w;   }   inline void print(long long x, int op = 10) {     if (!x) {       putchar( 0 );       if (op) putchar(op);       return;     }     char F[40];     long long tmp = x > 0 ? x : -x;     if (x < 0) putchar( - );     int cnt = 0;     while (tmp > 0) {       F[cnt++] = tmp % 10 +  0 ;       tmp /= 10;     }     while (cnt > 0) putchar(F[--cnt]);     if (op) putchar(op);   }   inline long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }   long long qpow(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans *= a;       b >>= 1;       a *= a;     }     return ans;   }   long long qpow(long long a, long long b, long long mod) {     long long ans = 1;     while (b) {       if (b & 1) (ans *= a) %= mod;       b >>= 1;       (a *= a) %= mod;     }     return ans % mod;   }   const int dir[][2] = {{0, 1}, {1, 0},  {0, -1}, {-1, 0},                         {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};   const int MOD = 1e9 + 7;   const int INF = 0x3f3f3f3f;   const long long INF64 = 0x3f3f3f3f3f3f3f3f;   const int N = 1e6 + 7;   struct Node {     long long val;     int id;     bool operator<(const Node& opt) const { return val < opt.val; }   };   long long n, m;   set<int> st;   int p[20];   int solve() {     n = read();     int cnt = 0;     for (int i = 1; i <= n; ++i) p[i] = read(), cnt += p[i] == 0;     st.clear();     st.insert(0);     for (int i = 1; i <= n; ++i) {       set<int> tmp = st;       for (auto& it : st) {         int x1 = it - p[i];         int x2 = it + p[i];         cnt += x1 == 0;         cnt += x2 == 0;         tmp.insert(x1), tmp.insert(x2);       }       st = tmp;     }     return cnt;   }   int main() {     int T = read();     for (int _ = 1; _ <= T; ++_) {       cout << (solve() ?  YES  :  NO ) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   ostream& operator<<(ostream& _s, vector<T> _t) {     for (int i = 0; i < (int)(_t.size()); i++) _s << (i ?     :   ) << _t[i];     return _s;   }   template <typename T>   istream& operator>>(istream& _s, vector<T>& _t) {     for (int i = 0; i < (int)(_t.size()); i++) _s >> _t[i];     return _s;   }   template <typename T, typename U>   ostream& operator<<(ostream& _s, pair<T, U> _t) {     _s <<  (  << _t.first <<  ,  << _t.second <<  ) ;     return _s;   }   template <typename T, typename U>   istream& operator>>(istream& _s, pair<T, U>& _t) {     _s >> _t.first >> _t.second;     return _s;   }   int find(const vector<int>& v, int value, int fr, int to) {     for (int i = fr; i < (int)(to + 1); i++) {       if (v[i] == value) {         return i;       }     }     assert(false);   }   vector<int> invert(const vector<int>& v) {     vector<int> res(v.size());     for (int i = 0; i < (int)(v.size()); i++) {       res[v[i]] = i;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     vector<int> p(n);     cin >> p;     for (int i = 0; i < (int)(n); i++) p[i]--;     bool is_id = true;     for (int i = 0; i < (int)(n); i++) {       if (p[i] != i) is_id = false;     }     string base_s;     for (int j = 0; j < (int)(n); j++) base_s +=  . ;     vector<string> res(n);     for (int i = 0; i < (int)(n); i++) res[i] = base_s;     if (is_id) {       cout << n << endl;       for (int i = 0; i < (int)(n); i++) {         cout << base_s << endl;       }       return 0;     }     p = invert(p);     int fr = 0, to = n - 1;     for (int row = 0; row < (int)(n); row++) {       if (row == 0) {         int mid = n / 2;         int pos = find(p, mid, fr, to);         for (int i = fr; i < (int)(pos + 1); i++) {           res[row][i] =     ;         }         for (int i = (pos)-1; i >= (int)(fr); i--) {           p[i + 1] = p[i];         }         p[fr] = -1;       } else {         bool left = row % 2 == 1;         int free_pos = left ? fr : to;         assert(p[free_pos] == -1);         int pos = find(p, free_pos, fr, to);         if (left) {           res[row][fr] =  / ;           for (int i = pos; i < (int)(to + 1); i++) {             res[row][i] =  / ;           }           for (int i = pos; i < (int)(to); i++) {             p[i] = p[i + 1];           }           p[to] = -1;           fr++;         } else {           res[row][to] =     ;           for (int i = fr; i < (int)(pos + 1); i++) {             res[row][i] =     ;           }           for (int i = (pos)-1; i >= (int)(fr); i--) {             p[i + 1] = p[i];           }           p[fr] = -1;           to--;         }       }     }     cout << (n - 1) << endl;     for (int i = 0; i < (int)(n); i++) {       cout << res[i] << endl;     }   }