malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5;   const int oo = 1e9 + 5;   struct seg {     seg(int a, int x, int y) : A(a), first(x), second(y) {}     int A;     int first;     int second;   };   bool operator<(const seg &M, const seg &N) { return M.A < N.A; }   set<seg> segs;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int N, Q;     scanf( %d %d n , &N, &Q);     segs.insert(seg(0, 0, 0));     for (int i = 0; i < Q; ++i) {       int x, y;       char c;       scanf( %d %d %c n , &x, &y, &c);       set<seg>::iterator it = segs.upper_bound(seg(x, 0, 0));       --it;       if (x == it->A) {         printf( 0 n );         continue;       }       int fa = it->A;       int fy = it->second;       int fx = it->first;       if (c ==  U ) {         printf( %d n , y - it->second);         segs.insert(seg(x, x, fy));       } else {         printf( %d n , x - it->first);         segs.erase(it);         segs.insert(seg(fa, fx, y));         segs.insert(seg(x, fx, fy));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie();     cout.tie();     int n;     cin >> n;     int arr[5001] = {0};     int ans = 0;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       arr[x]++;     }     for (int i = 1; i <= n; i++) {       if (arr[i] >= 2) ans += arr[i] - 1;     }     for (int i = n + 1; i <= 5000; i++) ans += arr[i];     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, x, l, j, k, i;     cin >> n >> x;     long long a[x + 1];     for (i = 1; i <= x; i++) {       a[i] = 0;     }     for (i = 0; i < n; i++) {       cin >> l;       for (j = 0; j < l; j++) {         cin >> k;         a[k]++;       }     }     int t = 1;     for (i = 1; i <= x; i++) {       if (a[i] == 0) {         t = 0;       }     }     if (t == 1) {       cout <<  YES ;     } else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     string s;     cin >> s;     long long x = 1;     long long zero = 0;     set<char> q;     bool h = 0, mn = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  ? ) {         if (h)           zero++;         else {           x = x * 9;           h = 1;         }       } else if (s[i] >=  0  && s[i] <=  9 ) {         if (s[i] >  0 ) h = 1;       } else {         if (h)           q.insert(s[i]);         else {           q.insert(s[i]);           mn = 1;           h = 1;         }       }     }     for (long long t = 10; t > 10 - q.size(); t--) {       if (mn == 1 && t == 10)         x = x * 9;       else         x = x * t;     }     cout << x;     for (int i = 0; i < zero; i++) cout << 0;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fun(long long int n) {     int count = 0;     while (n) {       if (n % 10 == 7 || n % 10 == 4) count++;       n = n / 10;     }     if (count == 0) {       cout <<  NO ;       return;     }     while (count) {       int r = count % 10;       if (r != 7 && r != 4) {         cout <<  NO ;         return;       }       count = count / 10;     }     cout <<  YES ;     return;   }   int main() {     long long int n;     cin >> n;     fun(n);     return 0;   }
#include <bits/stdc++.h>   int arr1[500005];   using namespace std;   int main() {     int t;     cin >> t;     for (int i = 1; i <= t; i++) {       int a;       cin >> a;       arr1[a] = i;     }     long long int sum = 0;     for (int i = 1; i < t; i++) {       sum += abs(arr1[i] - arr1[i + 1]);     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n_Cases = 1;     for (long long case_i = 1; case_i <= n_Cases; case_i++) {       long long up, down;       cin >> up >> down;       long long n = up + down + 1;       for (long long i = 1; i <= up; i++) cout << i <<    ;       cout << n <<    ;       for (long long j = n - 1; j >= n - down; j--) cout << j <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   int a[N], b[N];   int main() {     int i, j, n, m, k, t, x, y, p;     long long ax, ay, tx, ty;     while (~scanf( %d , &n)) {       for (i = 0; i < n; i++) scanf( %d , &a[i]);       scanf( %d , &m);       for (i = 0; i < m; i++) scanf( %d , &b[i]);       sort(a, a + n);       sort(b, b + m);       ax = n * 2, ay = m * 2;       for (i = 0; i < n; i++) {         tx = (n - i) * 3 + i * 2;         p = lower_bound(b, b + m, a[i]) - b;         ty = (m - p) * 3 + p * 2;         if (tx - ty > ax - ay || (tx - ty) == (ax - ay) && tx > ax)           ax = tx, ay = ty;       }       printf( %I64d:%I64d n , ax, ay);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int n = s.size();     queue<int> pos;     int arr[n];     arr[0] = 0;     int lastb = -1;     for (int i = 0; i < n; i++) {       if (s[i] ==  b ) {         if (i + 3 < n) {           if (s.substr(i, 4) ==  bear ) {             pos.push(i);             lastb = i;           }         }       }       if (i > 0) {         arr[i] = arr[i - 1];       }       if (s[i] ==  r ) {         if (lastb != -1 && i - lastb <= 3) {           arr[i] = arr[i - 1] + 1;         }       }     }     int k = 0;     int ans = 0;     for (int i = 0; i < n; i++) {       if (!pos.empty() && i > pos.front()) {         k++;         pos.pop();       }       for (int j = i + 1; j < n; j++) {         if (arr[j] - k > 0) {           ans++;         }       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long p(long long b, long long e) {     if (e == 0) return 1;     if (e == 1) return b;     if (e & 1) {       return ((b % 998244353) * p((b * b) % 998244353, e / 2)) % 998244353;     }     return (p((b * b) % 998244353, e / 2)) % 998244353;   }   int32_t main() {     long long n, m;     cin >> n >> m;     cout << p(2, (m + n));   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long mod = 1000000007;   int main() {     int x, y;     unsigned long long n = 0;     cin >> x >> y;     unsigned long long t = 0;     int power = 2;     for (int p = 0; p < 2200; p++) {       if (power > y) break;       t += y + 1 - power;       power += 2;     }     for (int i = 1; i < x; i++) {       y = min(i, x - i);       n += y;     }     n *= t;     cout << n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 200020;   const long long MOD = (int)1e9 + 7;   const int INF = 1e9;   const long long LLINF = 0x3f3f3f3f3f3f3f3f;   const long double EPS = 1e-7;   void get_sub(string s, int size, set<string>& sub) {     int n = s.size();     for (int l = 0, r = size - 1; r < n; l++, r++) {       string t = s.substr(l, size);       sub.insert(t);     }   }   set<string> merge(set<string> a, set<string> b) {     set<string> res = a;     for (auto s : b) {       res.insert(s);     }     return res;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int n, m;     cin >> n;     vector<string> pre(301, string()), suf(301, string());     vector<vector<set<string>>> sub(301, vector<set<string>>(10, set<string>()));     for (int i = 1; i <= n; i++) {       string s;       cin >> s;       int sz = s.size();       pre[i] = s.substr(0, min(9, sz));       suf[i] = s.substr(max(0, sz - 9), min(9, sz));       for (int k = 1; k <= 9; k++) {         get_sub(s, k, sub[i][k]);       }     }     cin >> m;     for (int i = 1; i <= m; i++) {       int a, b;       cin >> a >> b;       string t = suf[a] + pre[b];       int sz = t.size();       string p = pre[a] + pre[b];       sz = p.size();       pre[n + i] = p.substr(0, min(9, sz));       string s = suf[a] + suf[b];       sz = s.size();       suf[n + i] = s.substr(max(0, sz - 9), min(9, sz));       for (int k = 1; k <= 9; k++) {         sub[n + i][k] = merge(sub[a][k], sub[b][k]);         get_sub(t, k, sub[n + i][k]);       }       int res = 0;       for (int k = 1; k <= 9; k++) {         if ((int)sub[n + i][k].size() == (1 << k)) res = k;       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   template <class T>   void print(vector<T>& v, bool spaced = true) {     int n = v.size();     string space = (spaced ?     :   );     for (int i = 0; i < n; ++i) {       cout << v[i] << space;     }     cout <<   n ;   }   template <class T>   void printendl(vector<T>& v) {     int n = v.size();     for (int i = 0; i < n; ++i) {       cout << v[i] <<   n ;     }   }   template <class T>   T gcd(T a, T b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   template <class T>   T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   template <class T>   T extended_gcd(T a, T b, T& x, T& y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     T x1, y1;     T g = extended_gcd(b, a % b, x1, y1);     x = y1;     y = x1 - (a / b) * y1;     return g;   }   template <class T>   T diophantine_eq(T a, T b, T c, T& x, T& y, T& g) {     g = extended_gcd(abs(a), abs(b), x, y);     if (c % g) return false;     x *= (c / g);     y *= (c / g);     if (a < 0) x *= -1;     if (b < 0) y *= -1;     return true;   }   template <class T>   T euler_phi(T n) {     T result = n;     for (int i = 2; i * i <= n; ++i) {       if (n % i == 0) {         while (n % i == 0) {           n /= i;         }         result -= result / i;       }     }     if (n > 1) result -= result / n;     return result;   }   vector<ll> ranged_euler_phi(ll n) {     vector<ll> phi(n + 1);     phi[0] = 0;     phi[1] = 1;     for (int i = 2; i <= n; ++i) phi[i] = i;     for (int i = 2; i <= n; ++i) {       if (phi[i] == i) {         for (int j = i; j <= n; j += i) {           phi[j] -= phi[j] / i;         }       }     }     return phi;   }   bool check(int n) {     int count = 0;     for (int i = 2; i * i <= n; ++i) {       if (n % i == 0) {         count++;         while (n % i == 0) {           n /= i;         }       }     }     if (n > 1) count++;     return count == 2;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     ll n, x;     cin >> n >> x;     ll ans = 0;     for (int i = 1; i <= n; ++i) {       if (x % i == 0 && x / i <= n) ans++;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int mod1 = 1000000007;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long int t;     t = 1;     for (long long int f = 0; f < t; f++) {       int n;       cin >> n;       string A;       cin >> A;       int i;       int x = n - 11;       int in = -1, c = 0;       int y = 0;       int r = ceil(x / 2.0);       x = x / 2;       for (i = 0; i < n; i++) {         if (in == -1 && A[i] ==  8 ) in = i + 1;         if (A[i] ==  8 ) c++;         if (c == x + 1 && y == 0) y = i + 1;       }       if (in - 1 > r) {         cout <<  NO  << endl;         continue;       }       if (c <= x) {         cout <<  NO  << endl;         continue;       } else {         y = y - x;         y--;         if (y <= r) {           cout <<  YES  << endl;           continue;         }         cout <<  NO  << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int g[25][25], n, p, i, T, j, k;   bool FLAG;   int main() {     scanf( %d , &T);     while (T--) {       for (i = 1; i <= 24; i++)         for (j = 1; j <= 24; j++) g[i][j] = 0;       scanf( %d%d , &n, &p);       for (i = 1; i <= 5; i++)         for (j = i + 1; j <= 5; j++) g[i][j] = g[j][i] = 1;       for (i = 6; i <= n; i++) g[i][1] = g[i][2] = g[1][i] = g[2][i] = 1;       for (i = 1; i <= p; i++) {         FLAG = false;         for (j = 1; !FLAG && j <= n; j++)           for (k = j + 1; !FLAG && k <= n; k++)             if (!g[j][k]) {               g[j][k] = g[k][j] = 1;               FLAG = true;             }       }       for (i = 1; i <= n; i++) {         for (j = i + 1; j <= n; j++)           if (g[i][j]) cout << i <<     << j << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int a, long long int n, long long int m);   long long int power(long long int a, long long int n, long long int m) {     if (n == 0) return 1;     long long int x = power(a, n / 2, m);     if (n % 2 != 0)       return (((a * x) % m) * (x) % m) % m;     else       return (x * x) % m;   }   double PI = 3.14159265357;   int32_t main() {     long long int n, i, j, x, y, m, k, t, sum, count, cnt, b, c, d, j1, z, a,         temp;     ios::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     cin >> t;     while (t--) {       cin >> n;       long long int arr[n];       long long int e = 0, o = 0;       for (i = 0; i < n; i++) {         cin >> arr[i];         if (arr[i] % 2 == 0)           e++;         else           o++;       }       if (e - o != (n) % 2) {         cout <<  -1 n ;         continue;       }       cnt = 0;       for (i = 0; i < n; i++)         if (arr[i] % 2 != i % 2) cnt++;       cout << cnt / 2 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     char ch;     while (!isdigit(ch = getchar()))       ;     do {       x = 10 * x + ch -  0 ;     } while (isdigit(ch = getchar()));   }   const int N = 3e6 + 111;   const int INF = 1e9;   int n, q, D[N], res;   long long A[N], F[N];   bool vst[N];   template <typename T>   inline bool mini(T &x, T y) {     if (x > y)       x = y;     else       return 0;     return 1;   }   template <typename T>   inline bool maxi(T &x, T y) {     if (x < y)       x = y;     else       return 0;     return 1;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     read(n);     read(q);     for (int i = 1; i <= n; i++) {       read(A[i]);     }     for (int i = n + 1; i <= 3 * n; i++) {       A[i] = A[i - n];     }     for (int i = 1; i <= 3 * n; i++) {       F[i] = F[i - 1] + A[i];     }     while (q--) {       long long x;       read(x);       int j = 0;       for (int i = 1; i <= 3 * n; i++) {         while (F[i] - F[j] > x) j++;         D[i] = i - j;       }       int k = INF;       int p;       for (int i = 2 * n + 1; i <= 3 * n; i++) {         if (mini(k, D[i])) {           p = i;         }       }       if (k >= n) {         cout << 1 <<   n ;         continue;       }       res = INF;       for (int r = p - D[p]; r <= p; r++) {         int l = r - n + 1;         int i = r;         int cnt = 0;         while (i >= l) {           cnt++;           i -= D[i];         }         mini(res, cnt);       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d, e, f;     scanf( %d%d%d%d%d%d , &a, &b, &c, &d, &e, &f);     if (d == 0) {       printf( Hermione );       return 0;     }     if (c == 0) {       printf( Ron );       return 0;     }     if (b == 0) {       printf( Hermione );       return 0;     }     if (a == 0) {       printf( Ron );       return 0;     }     if (f == 0) {       printf( Hermione );       return 0;     }     if (e == 0) {       printf( Ron );       return 0;     }     if (b * d * f > a * c * e)       printf( Ron );     else       printf( Hermione );     return 0;   }
#include <bits/stdc++.h>   using namespace std;      int n, m;      vector<int> a1, a2;   vector<int> b1, b2;      int subsolve(vector<int>& box, vector<int>& spec) {       int N = (int) box.size();       int M = (int) spec.size();          vector<int> good (M+5, 0);       int cumulate = 0;       for (int i=M-1; i>=0; i--) {           int& sp = spec[i];           if (binary_search(box.begin(), box.end(), sp)) cumulate++;           good[i] = cumulate;       }                 int ans=good[0];       for (int i=0; i<M; i++) {           int boxcnt = (int)(upper_bound(box.begin(), box.end(), spec[i]) - box.begin());           // _ * _ _ _ * _ _ *           //   # # # # # # # #           // [spec[i] - boxcnt + 1, spec[i] + 1)           int left_spec = (int)(lower_bound(spec.begin(), spec.end(), spec[i] - boxcnt + 1) - spec.begin());           ans = max(ans, (i-left_spec+1) + good[i+1]);       }       return ans;   }      void solve() {       a1.clear(); a2.clear(); b1.clear(); b2.clear();       cin >> n >> m;       for (int i=0; i<n; i++) {           int tmp; scanf( %d , &tmp);           if (tmp > 0) a1.push_back(tmp);           else a2.push_back(-tmp);       }       for (int i=0; i<m; i++) {           int tmp; scanf( %d , &tmp);           if (tmp > 0) b1.push_back(tmp);           else b2.push_back(-tmp);       }       sort(a1.begin(), a1.end());       sort(a2.begin(), a2.end());       sort(b1.begin(), b1.end());       sort(b2.begin(), b2.end());          printf( %d n , subsolve(a1, b1) + subsolve(a2, b2));   }      int main() {       int t; cin >> t;       while (t--)           solve();   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n;     cin >> n;     long long int a[n + 1][n + 1];     long long int s = 0;     for (int i = 1; i < n + 1; i++)       for (int j = 1; j < n + 1; j++) {         cin >> a[i][j];         if (i == j) s += a[i][j];       }     s %= 2;     long long int q;     cin >> q;     while (q--) {       long long int x;       cin >> x;       if (x == 1 || x == 2) {         long long int t;         cin >> t;         s ^= 1;       } else         cout << s;     }     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t;     t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   bool fine(int v) {     int z = 0, s = 0;     while ((v & 1) == 0) {       z++;       v >>= 1;     }     while ((v & 1) == 1) {       s++;       v >>= 1;     }     return v == 0 && z == s - 1;   }   int main() {     int n;     scanf( %d , &n);     for (int i = n; i >= 1; i--) {       if (n % i == 0 && fine(i)) {         printf( %d , i);         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool umin(T &x, T y) {     return y < x ? x = y, 1 : 0;   }   template <class T>   bool umax(T &x, T y) {     return y > x ? x = y, 1 : 0;   }   const int N = 505;   int n, m, g[N][N][2];   bitset<N> dp[100][2][N], ok, tmp;   signed main() {     cin >> n >> m;     for (int i = 1, u, v, w; i <= m; ++i) {       cin >> u >> v >> w;       dp[0][w][u][v] = 1;     }     for (int i = 1; i <= 60; ++i) {       for (int u = 1; u <= n; ++u) {         for (int k = 1; k <= n; ++k) {           if (dp[i - 1][0][u][k]) dp[i][0][u] |= dp[i - 1][1][k];           if (dp[i - 1][1][u][k]) dp[i][1][u] |= dp[i - 1][0][k];         }       }     }     for (int i = 1; i <= n; ++i)       if (dp[60][0][i].count()) {         puts( -1 );         return 0;       }     long long ans = 0;     ok[1] = 1;     int cur = 0;     for (int i = 59; i >= 0; --i) {       tmp = 0;       for (int u = 1; u <= n; ++u)         if (ok[u]) tmp |= dp[i][cur][u];       if (tmp.count()) {         for (int u = 1; u <= n; ++u) ok[u] = tmp[u];         ans |= (1ll << i);         if (ans > 1e18) {           ans = -1;           break;         }         cur ^= 1;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   /*   #include <ext/pb_ds/assoc_container.hpp>    #include <ext/pb_ds/tree_policy.hpp>    using namespace __gnu_pbds;    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>    */   typedef long long ll;   typedef long double ld;   typedef unsigned long long ull;   #define rep(i,a,b) for(ll i=a;i<=b;++i)   #define rrep(i,a,b) for(ll i=a;i>=b;--i)   #define FOR(i,n)  for(ll i=0;i<n;i++)   #define pb push_back   #define mp make_pair   #define PI 3.14159265358979323846   #define fi first   #define se second   #define all(x)  x.begin(),x.end()   #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);      const ll INF = 1e18+10;   const ll mod = 1e9+7;   const ll MAXN = 2e5+10;      ll poww(ll a, ll b) {           if(b<0) return 0LL;       ll ans = 1;       while (b) {           if (b & 1)ans = ans * a;           a = a * a;           b >>= 1;       }          return ans;   }   ll binpow(ll a, ll b)   {       if (b < 0) return 0LL;       if (a <= 0)return 0LL;       a %= mod;              ll ans = 1LL;       while (b) {           if (b & 1)ans = ans * a % mod;           a = a * a % mod;           b >>= 1;       }       return ans;   }   ll modinv(ll n) {       return binpow(n, mod - 2);   }      void solve() {         ll n; cin>>n;       vector<ll> x;       ll a[n]; FOR(i,n) { cin>>a[i]; x.pb(a[i]); }       sort(all(x));       vector<ll> s(n,0); s[0] = x[0];       ll j = 0;       vector<ll> inv(n,1);       for(ll i=1; i<n; i++) {            if(x[i]>s[i-1]) {               for(ll k=i-1; k>=j; k--) {                   inv[k] = 0;               }               j = i;           }           s[i] = s[i-1] + x[i];       }       map<ll,ll> mt;       FOR(i,n) {           if(inv[i]==1) mt[x[i]] = 1;       }       vector<ll> ans;       FOR(i,n) {           if(mt[a[i]]==1) ans.pb(i+1);       }       cout<<ans.size()<<  n ;       FOR(i,ans.size()) cout<<ans[i]<<   ;       cout<<  n ;   }         int main() {       IOS;        #ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);           freopen( output.txt ,  w , stdout);       #endif              ll no_of_test_cases; cin>>no_of_test_cases;        //ll no_of_test_cases = 1;       //cout<<fixed<<setprecision(10);              for(ll i=1; i<=no_of_test_cases; i++) {           solve();       }        return 0;    }
#include <bits/stdc++.h>   using namespace std;   int n, arr[101], color, maxi, mini = 101;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> color;     for (int i = 0; i < n; i++) {       cin >> arr[i];       mini = min(mini, arr[i]);       maxi = max(maxi, arr[i]);     }     if (maxi - mini > color) {       cout <<  NO n ;       return 0;     }     cout <<  YES n ;     for (int i = 0; i < n; i++) {       int j = 1;       while (arr[i]--) {         cout << j <<    ;         if (j == color) j = 0;         j++;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string S;   struct State {     char p[2][13];   };   int dx[5] = {1, 0, -1, 0, 1}, dy[8] = {0, 1, 0, -1, 1};   bool OK = false;   int solve(State &E, int r1, int r2, int depth) {     if (OK == true) return 1;     if (depth == 27) {       for (int i = 0; i < 26; i++) {         cout << E.p[i / 13][i % 13];         if (i % 13 == 12) cout << endl;       }       OK = true;       return 1;     }     for (int i = 0; i < 5; i++) {       int cx = r1 + dx[i], cy = r2 + dy[i];       if (cx < 0 || cx >= 2 || cy < 0 || cy >= 13) continue;       if (E.p[cx][cy] !=  $  && E.p[cx][cy] != S[depth]) continue;       char F = E.p[cx][cy];       E.p[cx][cy] = S[depth];       solve(E, cx, cy, depth + 1);       E.p[cx][cy] = F;     }     return 0;   }   int main() {     cin >> S;     for (int i = 0; i < 2; i++) {       for (int j = 0; j < 13; j++) {         State Y;         for (int k = 0; k < 26; k++) Y.p[k / 13][k % 13] =  $ ;         Y.p[i][j] = S[0];         solve(Y, i, j, 1);       }     }     if (OK == false) cout <<  Impossible  << endl;     return 0;   }