malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int i, n, t, p = INT_MAX, j = 0, x, a = 0, b, l = 0, r = 0, k = 0,                            e, w = 0;     long long sum = 0;     string s, m;     cin >> n;     int ara[n];     int ar[n];     int arr[n];     for (i = 0; i < n; i++) {       cin >> ara[i];       ar[j++] = ara[i];     }     for (i = 0; i < n; i++) {       p = ara[i];       ar[i] = ara[i];       for (j = i + 1; j < n; j++) {         if (ara[j] > p) {           ar[j] = p;         } else {           p = ara[j];           ar[j] = ara[j];         }       }       p = ara[i];       for (k = i - 1; k >= 0; k--) {         if (ara[k] > p) {           ar[k] = p;         } else {           p = ara[k];           ar[k] = ara[k];         }       }       for (int y = 0; y < n; y++) {         sum += ar[y];       }       if (w <= sum) {         w = sum;         for (int g = 0; g < n; g++) {           arr[g] = ar[g];         }       }       sum = 0;     }     for (i = 0; i < n; i++) {       cout << arr[i] <<    ;     }     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   const int Win = 3, Loop = 2, Lose = 1;   int n, dp[7001][3], ne[3], a[7001][3], k[3], sum[7001][3];   bool b[7001][3];   inline int max(int x, int y) { return x > y ? x : y; }   void dfs(int x, int y) {     if (b[x][y]) return;     b[x][y] = 1;     int t = ne[y];     for (int i = 1; i <= k[t]; i++) {       int xt = x - a[i][t];       if (xt <= 0) xt += n;       if (xt == 1) continue;       dp[xt][t] = max(dp[xt][t], 4 - dp[x][y]);       if (++sum[xt][t] == k[t] || dp[xt][t] == Win) dfs(xt, t);     }   }   int main() {     scanf( %d , &n);     scanf( %d , &k[1]);     for (int i = 1; i <= k[1]; i++) scanf( %d , &a[i][1]);     scanf( %d , &k[2]);     for (int i = 1; i <= k[2]; i++) scanf( %d , &a[i][2]);     dp[1][1] = dp[1][2] = Lose;     ne[1] = 2;     ne[2] = 1;     dfs(1, 1);     dfs(1, 2);     for (int j = 1; j <= 2; j++) {       for (int i = 2; i <= n; i++) {         if (!b[i][j]) dp[i][j] = Loop;         printf(dp[i][j] == Win ?  Win   : dp[i][j] == Loop ?  Loop   :  Lose  );       }       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y, long long m) {     if (y == 0) return 1;     long long p = power(x, y / 2, m) % m;     p = (p * p) % m;     return (y % 2 == 0) ? p : (x * p) % m;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long modInverse(long long a, long long m) {     long long g = gcd(a, m);     if (g != 1)       return -1;     else       return power(a, m - 2, m);   }   int main() {     long long a, b, p, x;     cin >> a >> b >> p >> x;     long long pow = 1;     long long cnt(0);     for (long long j = 1; j < p; ++j) {       pow = (pow * a) % p;       long long invPow = modInverse(pow, p);       if (invPow == -1) continue;       long long y = (b * invPow) % p;       long long mn, d;       mn = ((j - y + p) % p) * (p - 1) + j;       if (mn > x) continue;       cnt += (x - mn) / (p * (p - 1)) + 1;     }     cout << cnt;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   long long n, m;   string p, s;   vector<int> pos;   long long exp(long long a, long long x) {     if (x == 0) return 1;     long long tmp = exp(a, x / 2);     tmp *= tmp;     tmp %= MOD;     if (x % 2) tmp *= a;     tmp %= MOD;     return tmp;   }   bool z(string str) {     int n = (int)str.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 && str[z[i]] == str[i + z[i]]) ++z[i];       if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;     }     for (int i = 0; i < pos.size(); ++i) {       if (z[pos[i] + p.size() + 1] != p.size()) return false;     }     return true;   }   int main() {     cin >> n >> m >> p;     pos.assign(m, 0);     for (int i = 0; i < m; ++i) {       cin >> pos[i];       pos[i]--;     }     sort(pos.begin(), pos.end());     for (int i = 0; i < m; ++i) {       while (s.size() < pos[i]) s +=  . ;       int stp = s.size();       for (int j = stp - pos[i]; j < p.size(); ++j) {         s += p[j];       }     }     while (s.size() < n) s +=  . ;     s = p +  #  + s;     if (z(s)) {       int cnt = 0;       for (auto i : s) cnt += i ==  . ;       cout << exp(26, cnt);     } else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double EPS = 1e-9;   long long INF = 1000000000000000005ll;   double PI = acos(-1);   inline string IntToString(long long int a) {     char x[100];     sprintf(x,  %lld , a);     string s = x;     return s;   }   inline long long int StringToInt(string a) {     char x[100];     long long int res;     strcpy(x, a.c_str());     sscanf(x,  %lld , &res);     return res;   }   inline string uppercase(string s) {     int n = (int)s.size();     for (long long int i = 0; i < n; i++)       if (s[i] >=  a  && s[i] <=  z ) s[i] = s[i] -  a  +  A ;     return s;   }   inline string lowercase(string s) {     int n = (int)s.size();     for (long long int i = 0; i < n; i++)       if (s[i] >=  A  && s[i] <=  Z ) s[i] = s[i] -  A  +  a ;     return s;   }   bool sortcol(const vector<long long int>& v1, const vector<long long int>& v2) {     return v1[0] > v2[0];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t;     cin >> t;     while (t-- > 0) {       long long int n;       cin >> n;       n *= 2;       long long int a[n];       for (long long int i = 0; i < n; i++) cin >> a[i];       sort(a, a + n);       cout << a[n / 2] - a[n / 2 - 1] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, i, j, k, l, t;     cin >> t;     while (t--) {       cin >> n;       vector<int> a(n);       for (i = 0; i < n; i++) {         cin >> a[i];       }       k = 1;       long long total = 0;       for (i = 0; i < n; i++) {         if (k % 2 != 0) {           total += a[i];           if (a[i + 1] == 0) {             while (i + 1 < n && a[i + 1] == 0) {               i++;             }           }         } else {           if (a[i + 1] == 1) i++;         }         k++;       }       cout << total << endl;     }   }
#include <bits/stdc++.h>   const long long INF = (1e9 + 12312), MOD = 1e9 + 7;   const long double EPS = 0.0000000001;   using namespace std;   bool ask(long long first, long long second) {     cout << first <<     << second << endl;     string s;     cin >> s;     if (s ==  Bad ) {       exit(1);     }     return s ==  Yes ;   }   signed main() {     ios_base::sync_with_stdio(false);     srand(time(0));     long long n, k;     cin >> n >> k;     long long now = 0;     long long first = 1, second = n;     long long lastl = 1, lastr = n;     for (int i = 0; i < 4500; i++) {       if (now >= 7) {         first = max(lastl - 8 * k, 1LL);         second = min(lastr + 8 * k, n);         lastl = -1;         now = 0;       }       long long askl = first, askr = second;       if (second - first == 0) {         if (ask(first, first)) {           return 0;         }         first = 1, second = n;         continue;       }       if (second - first + 1 <= 50) {         if (lastl == -1) {           lastr = second;           lastl = first;         }         now++;         long long askl = first + rand() % (second - first + 1);         if (ask(askl, askl)) {           return 0;         }         continue;       } else {         now = 0;         lastl = -1;         lastr = -1;         if (rand() % 2) {           askl = first + (second - first + 1) / 2;         } else {           askr = second - (second - first + 1) / 2;         }       }       if (ask(askl, askr)) {         first = max(askl - k, 1LL);         second = min(askr + k, n);       } else {         if (askl != first) {           first -= k;           first = max(first, 1LL);           second = min(askl + k, n);         } else {           first = max(askr - k, 1LL);           second += k;           second = min(second, n);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c *x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug &operator<<(const c &) {       return *this;     }   };   long long __pow(long long x, long long y, long long M) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x) % M;       y >>= 1;       x = (x * x) % M;     }     return res % M;   }   long long __pow(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x);       y >>= 1;       x = (x * x);     }     return res;   }   long long mi(long long x, long long M) { return __pow(x, M - 2, M); }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long add(long long a, long long b, long long M) { return (a + b) % M; }   long long mul(long long a, long long b, long long M) { return (a * b) % M; }   long long sub(long long a, long long b, long long M) { return (a - b + M) % M; }   long long div(long long a, long long b, long long M) {     return (a * mi(b, M)) % M;   }   void umax(long long &a, long long b) { a = max(a, b); }   void umin(long long &a, long long b) { a = min(a, b); }   const long long N = 3e5 + 2, inf = 1e18, M = 998244353;   long long Test, n, m, k, query;   bool ok = 1;   void test_case() {     cin >> n >> k;     string s;     cin >> s;     s =  $  + s;     vector<long long> last(26);     vector<vector<long long>> dp(n + 1, vector<long long>(n + 1));     dp[0][0] = 1;     for (long long i = 1; i <= n; i++) {       dp[i][0] = 1;       for (long long j = 1; j <= n; j++) {         dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];         if (last[s[i] -  a ]) dp[i][j] -= dp[last[s[i] -  a ] - 1][j - 1];       }       last[s[i] -  a ] = i;     }     long long ans = 0;     for (long long i = n; i >= 0 && k; i--) {       ans += min(k, dp[n][i]) * (n - i), k -= min(k, dp[n][i]);       debug() <<   [                <<  ans                    :                 << (ans)               <<  ]                      [                <<  k                    :                 << (k) <<  ]  ;     }     if (k)       cout << -1 << endl;     else       cout << ans << endl;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     Test = 1;     while (Test--) test_case();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5100;   int N, M;   vector<int> edge[MAXN];   int cdist[MAXN][MAXN];   int loc[3];   int target[3];   int eloc;   void play(bool finish) {     cout << loc[0] + 1 <<     << loc[1] + 1 <<     << loc[2] + 1 <<   n ;     cout << flush;     if (!finish) {       cin >> eloc;       eloc--;     }   }   void bfs(int cloc) {     vector<int> q;     q.push_back(cloc);     cdist[cloc][cloc] = 0;     for (int nq = 0; nq < q.size(); nq++) {       int ccur = q[nq];       for (int neigh : edge[ccur]) {         if (cdist[cloc][neigh] > cdist[cloc][ccur] + 1) {           cdist[cloc][neigh] = cdist[cloc][ccur] + 1;           q.push_back(neigh);         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     srand(time(NULL));     for (int i = 0; i < MAXN; i++)       for (int j = 0; j < MAXN; j++) cdist[i][j] = MAXN;     cin >> N >> M;     for (int i = 0; i < M; i++) {       int x, y;       cin >> x >> y;       x--, y--;       edge[x].push_back(y);       edge[y].push_back(x);     }     for (int i = 0; i < N; i++) {       for (int j = 0; j < edge[i].size(); j++)         swap(edge[i][j], edge[i][rand() % (j + 1)]);     }     for (int i = 0; i < N; i++) bfs(i);     for (int i = 0; i < 3; i++) {       while (true) {         loc[i] = rand() % N;         bool bad = false;         for (int j = 0; j < i; j++)           if (loc[j] == loc[i]) bad = true;         if (!bad) break;       }     }     play(false);     for (int run = 0; run < N; run++) {       if (eloc == loc[0] || eloc == loc[1] || eloc == loc[2]) break;       vector<pair<int, pair<int, int> > > v;       for (int i = 0; i < 3; i++)         for (int j = 0; j < edge[eloc].size(); j++) {           v.push_back(make_pair(cdist[i][j], make_pair(i, j)));         }       sort(v.begin(), v.end());       for (int i = 0; i < 3; i++) target[i] = -1;       for (auto ppp : v) {         int ci = ppp.second.first, cv = ppp.second.second;         bool bad = false;         for (int i = 0; i < 3; i++)           if (target[i] == cv) bad = true;         if (target[ci] == -1 && !bad) target[ci] = cv;       }       for (int i = 0; i < 3; i++)         if (target[i] == -1) target[i] = 0;       bool done = false;       for (int i = 0; i < 3; i++) {         if (cdist[loc[i]][eloc] == 1) {           done = true;           loc[i] = eloc;           break;         } else {           vector<int> choice;           int nneigh = edge[eloc][target[i]];           for (int neigh : edge[loc[i]])             if (cdist[neigh][nneigh] < cdist[loc[i]][nneigh]) {               choice.push_back(neigh);             }           loc[i] = choice[rand() % choice.size()];         }       }       play(done);     }   }
#include <bits/stdc++.h>   using namespace std;   map<string, int> m;   int main() {     int n;     cin >> n;     string x, y;     for (int i = 0; i < n; i++) {       cin >> x >> y;       m[y]++;     }     int t1, t2, temp, temp1;     t1 = m[ hard ];     t2 = m[ soft ];     if (t1 > t2) {       temp = t1;       t1 = t2;       t2 = temp;     }     for (int i = 1; i < 100; i++) {       temp = i * i;       temp1 = temp / 2;       temp -= temp1;       if (temp1 >= t1 && temp >= t2) {         cout << i << endl;         return 0;       }     }   }
#include <bits/stdc++.h>   #pragma GCC target( avx2 )   using namespace std;   const int N = 1e3 + 7;   const int SZ = 1e6 * 14;   int val[SZ];   pair<int, int> ans;   int A[N], X[N], vis[N], maxind;   void solve(int need, int pos, int mask = 0, int sum = 0) {     if (pos > maxind) {       if (need != 0) return;       if (val[sum])         ans = {val[sum], mask};       else         val[sum] = mask;       return;     }     solve(need - 1, pos + 1, (mask << 1) + 1, sum + A[pos]);     solve(need, pos + 1, (mask << 1), sum);   }   void solve() {     int n;     cin >> n;     maxind = min(26, n);     int cnt[2] = {0, 0};     for (int i = 1; i <= n; ++i) {       cin >> A[i];       cnt[A[i] & 1]++;     }     if (n == 2) {       if (A[1] == A[2])         cout <<  YES n0   << A[1] <<   n ;       else         cout <<  NO n ;       return;     }     if (cnt[0] >= 3 || (cnt[0] && cnt[1] >= 2)) {       vector<int> V;       if (cnt[0] >= 3) {         for (int i = 1; i <= n; ++i) {           if (A[i] & 1) continue;           V.push_back(A[i]);           vis[i] = 1;           if (V.size() == 3) break;         }       } else {         for (int i = 1; i <= n; ++i) {           if (!(A[i] & 1)) {             V.push_back(A[i]);             vis[i] = 1;             break;           }         }         for (int i = 1; i <= n; ++i) {           if (A[i] & 1) V.push_back(A[i]), vis[i] = 1;           if (V.size() == 3) break;         }       }       assert(V.size() == 3);       X[1] = (V[0] + V[2] - V[1]) >> 1;       X[2] = V[0] - X[1];       X[3] = V[2] - X[1];       int ptr = 4;       for (int i = 1; i <= n; ++i) {         if (vis[i]) continue;         X[ptr++] = A[i] - X[1];       }       cout <<  YES n ;       for (int i = 1; i <= n; ++i) cout << X[i] <<    ;       cout <<   n ;       return;     }     for (int s = 1; s <= (n >> 1); ++s) {       solve(s, 1);       if (ans == pair<int, int>{0, 0}) {         memset(val, 0, sizeof(val));         continue;       }       vector<int> V1, V2;       for (int i = 1; i <= maxind; ++i) {         if ((1 << (maxind - i)) & ans.first) V1.push_back(A[i]), vis[i] = 1;         if ((1 << (maxind - i)) & ans.second) V2.push_back(A[i]), vis[i] = 1;       }       vector<int> V;       for (int i = 0; i < s; ++i) {         V.push_back(V1[i]);         V.push_back(V2[i]);       }       X[1] = 0;       for (int i = 2; i <= (s << 1); ++i) {         X[i] = V[i - 2] - X[i - 1];       }       assert(X[1] + X[s << 1] == V[(s << 1) - 1]);       int ptr = s * 2 + 1;       for (int i = 1; i <= n; ++i) {         if (vis[i]) continue;         X[ptr++] = A[i] - X[1];       }       cout <<  YES n ;       for (int i = 1; i <= n; ++i) cout << X[i] <<    ;       cout <<   n ;       return;     }     cout <<  NO n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int tc, w, h, flag = 0, a, b;     cin >> tc;     for (int i = 1; i <= tc; i++) {       cin >> w >> h;       if (w > h) swap(h, w);       if (i > 1) {         if (b < h && b >= w) {           int t = w;           w = h;           h = t;         } else if (b < w && b < h) {           flag = 1;         }       }       a = w, b = h;     }     if (flag == 1)       puts( NO );     else       puts( YES );   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[555][555], e[555][555], s, ans = -1e9;   int sum(int x, int y, int xx, int yy) {     return e[xx + 1][yy + 1] - e[x][yy + 1] - e[xx + 1][y] + e[x][y];   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) scanf( %d , &a[i][j]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         e[i + 1][j + 1] = e[i][j + 1] + e[i + 1][j] - e[i][j] + a[i][j];     for (int i = 1; i < n - 1; i++)       for (int j = 1; j < m - 1; j++) {         s = sum(i - 1, j - 1, i + 1, j + 1) - a[i][j] - a[i][j - 1];         ans = max(ans, s);         for (int k = 2;; k++) {           if (i - k < 0 || j - k < 0 || i + k >= n || j + k >= m) break;           s = sum(i - k, j - k, i + k, j + k) - s - a[i - k + 1][j - k];           ans = max(ans, s);         }       }     cout << (ans) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int f = 1, x = 0;     char ch;     do {       ch = getchar();       if (ch ==  - ) f = -1;     } while (ch <  0  || ch >  9 );     do {       x = (x << 3) + (x << 1) + ch -  0 ;       ch = getchar();     } while (ch >=  0  && ch <=  9 );     return f * x;   }   int r, x, y, px, py;   int main() {     scanf( %d%d%d%d%d , &r, &x, &y, &px, &py);     double dis = sqrt(1.0 * (x - px) * (x - px) + 1.0 * (y - py) * (y - py));     printf( %d n , (int)(ceil(1.0 * dis / (2.0 * r))));   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   const int maxm = 2000005;   const int inf = 0x3f3f3f3f;   const int mod = 1000000000 + 7;   void init() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   };   int n, m;   vector<int> v[100005];   vector<int> vv[100005];   int sum[100005];   int to[100005];   int cnt = 0;   bool cmp(int x, int y) { return x > y; }   int main() {     init();     cin >> n >> m;     int mx = 0;     int top = 0;     for (int i = 1; i <= n; i++) {       int id, score;       cin >> id >> score;       if (sum[id] == 0) to[++cnt] = id;       v[id].push_back(score);       sum[id]++;       mx = max(mx, sum[id]);     }     for (int kk = 1; kk <= cnt; kk++) {       int i = to[kk];       sort(v[i].begin(), v[i].end(), cmp);       if (v[i].size()) vv[i].push_back(v[i][0]);       for (int j = 1; j < v[i].size(); j++) {         int k = vv[i][j - 1];         if (k <= 0) break;         vv[i].push_back(k + v[i][j]);       }     }     int ans = 0;     for (int i = 1; i <= mx; i++) {       int tmp = 0;       for (int k = 1; k <= cnt; k++) {         int j = to[k];         if (sum[j] < i) continue;         if (i > vv[j].size()) continue;         if (vv[j][i - 1] < 0) continue;         tmp += vv[j][i - 1];       }       ans = max(ans, tmp);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   char buffer[1048576];   int main() {     scanf( %s , buffer);     string dat(buffer);     int n = dat.length();     int Q;     scanf( %d , &Q);     int lgstep = 1;     while ((1 << lgstep) <= n) lgstep++;     while (Q--) {       int k, d;       scanf( %d%d , &k, &d);       vector<int> invpi(k);       {         int lastval = 0;         int grp = 0;         for (int i = 1; i < k; i++) {           lastval += d;           if (lastval >= k) {             grp++;             lastval = grp;           }           invpi[i] = lastval;         }       }       vector<int> from(k);       vector<vector<int>> logfrom(lgstep, vector<int>(k));       for (int i = 0; i < k; i++) {         from[i] = invpi[i] + 1;         logfrom[0][i] = from[i];       }       for (int i = 1; i < lgstep; i++) {         for (int j = 0; j < k; j++) {           int p = logfrom[i - 1][j];           int p2 = (p != k) ? logfrom[i - 1][p] : (k);           logfrom[i][j] = p2;         }       }       string answer(n, 0);       for (int i = 0; i < n; i++) {         int base = min(i, n - k);         int fpos = i - base;         int tracepos = fpos;         int steps = 0;         {           int remain = base + 1;           for (int l = lgstep - 1; l >= 0; l--) {             if (remain >= (1 << l)) {               if (logfrom[l][tracepos] != k) {                 remain -= (1 << l);                 steps += (1 << l);                 tracepos = logfrom[l][tracepos];               }             }           }           if (remain) {             tracepos = logfrom[0][tracepos];             remain--;             steps++;           }         }         answer[i] = dat[base + tracepos - steps];       }       dat = move(answer);       puts(dat.c_str());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<string> a;     vector<string> z;     string s;     while (cin >> s) {       a.push_back(s);     }     int ans = 0;     sort(a.begin(), a.end());     for (int r = 0; r < 720; r++) {       if (a[0].length() + a[5].length() == a[3].length() + 1 &&           a[1].length() + a[4].length() == a[2].length() + 1 &&           a[2][a[1].length() - 1] == a[3][a[0].length() - 1]) {         if (a[0][0] == a[1][0] &&             a[5][a[5].length() - 1] == a[4][a[4].length() - 1] &&             a[3][0] == a[1][a[1].length() - 1] &&             a[2][0] == a[0][a[0].length() - 1] &&             a[2][a[2].length() - 1] == a[5][0] &&             a[3][a[3].length() - 1] == a[4][0]) {           string t =   ;           t = t + a[0];           for (int i = 0; i < a[3].length() - a[0].length(); i++) {             t = t +  . ;           }           t = t +   n ;           for (int i = 1; i < a[1].length() - 1; i++) {             t = t + a[1][i];             for (int j = 0; j < a[0].length() - 2; j++) {               t = t +  . ;             }             t = t + a[2][i];             for (int j = 0; j < a[3].length() - a[0].length(); j++) {               t = t +  . ;             }             t = t +   n ;           }           t = t + a[3];           t = t +   n ;           for (int i = 0; i < a[2].length() - a[1].length() - 1; i++) {             for (int j = 0; j < a[3].length() - a[5].length(); j++) {               t = t +  . ;             }             t = t + a[2][a[1].length() + i];             for (int j = 0; j < a[5].length() - 2; j++) {               t = t +  . ;             }             t = t + a[4][i + 1];             t = t +   n ;           }           for (int j = 0; j < a[3].length() - a[5].length(); j++) {             t = t +  . ;           }           t = t + a[5] +   n ;           ans = 1;           z.push_back(t);         }       }       next_permutation(a.begin(), a.end());     }     if (ans == 0)       cout <<  Impossible  << endl;     else {       sort(z.begin(), z.end());       cout << z[0] << endl;     }     return 0;   }