malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void rd(T &x) {     x = 0;     char c = getchar();     int f = 1;     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) x = x * 10 -  0  + c, c = getchar();     x *= f;   }   void FAIL() {     printf( 0 );     exit(0);   }   const int N = 5e5 + 10, mod = 1e9 + 7;   int In[N], Out[N], To[N], vis[N], n;   int sol(vector<int> &G, vector<pair<int, int> > &E) {     G.push_back(0), G.push_back(n + 1);     for (int i = 0; i < E.size(); ++i)       Out[E[i].first]++, In[E[i].second]++, To[E[i].first] = E[i].second;     for (int i = 0; i < G.size(); ++i)       if (In[G[i]] > 1 || Out[G[i]] > 1) FAIL();     for (int i = 0; i < G.size(); ++i)       if (!vis[G[i]]) {         int cur = G[i];         vis[cur] = 1;         while (~To[cur] && !vis[To[cur]]) cur = To[cur], vis[cur] = 1;         if (To[cur] == G[i]) FAIL();       }     int cur = 0;     while (~To[cur]) cur = To[cur];     if (cur == n + 1 && (int)G.size() - (int)E.size() > 1) FAIL();     for (int i = 0; i < G.size(); ++i)       In[G[i]] = Out[G[i]] = vis[G[i]] = 0, To[G[i]] = -1;     return max((int)G.size() - (int)E.size() - 2, 0);   }   vector<int> G[N];   vector<pair<int, int> > E[N];   int fa[N], dep[N];   void dfs1(int u, int last) {     fa[u] = last, dep[u] = dep[last] + 1;     for (int i = 0; i < G[u].size(); ++i) {       int v = G[u][i];       if (v == last) continue;       dfs1(v, u);     }   }   vector<int> P, Q;   void getpath(int x, int y) {     P.clear(), Q.clear();     int flg = 0;     if (dep[x] < dep[y]) swap(x, y), flg = 1;     P.push_back(x);     while (dep[x] > dep[y]) x = fa[x], P.push_back(x);     if (x == y) {       if (flg) reverse(P.begin(), P.end());       return;     }     Q.push_back(y);     while (fa[x] != fa[y]) x = fa[x], y = fa[y], P.push_back(x), Q.push_back(y);     P.push_back(fa[x]);     for (int i = (int)Q.size() - 1; i >= 0; --i) P.push_back(Q[i]);     if (flg) reverse(P.begin(), P.end());   }   int tot;   int a[N];   int fac[N];   int main() {     rd(n);     for (int i = 1, x, y; i < n; ++i)       rd(x), rd(y), G[x].push_back(y), G[y].push_back(x);     dfs1(1, 0);     for (int i = 1; i <= n; ++i) rd(a[i]);     for (int i = 1; i <= n; ++i)       if (a[i]) {         if (a[i] == i) FAIL();         getpath(a[i], i);         if ((tot += (int)P.size() - 1) > 2 * n - 2) FAIL();         int m = (int)P.size() - 1;         E[P[0]].push_back(make_pair(0, P[1]));         E[P[m]].push_back(make_pair(P[m - 1], n + 1));         for (int i = 1; i < m; ++i)           E[P[i]].push_back(make_pair(P[i - 1], P[i + 1]));       }     memset(To, -1, sizeof(To));     int ans = 1;     fac[0] = 1;     for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * (long long)i % mod;     for (int i = 1; i <= n; ++i)       ans = ans * (long long)fac[sol(G[i], E[i])] % mod;     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void rot(vector<string>& a) {     int n = (int)(a).size();     int m = (int)(a[0]).size();     vector<string> b(m);     for (int j = 0; j < m; ++j) {       b[j] =   ;       for (int i = n - 1; i >= 0; --i) {         b[j] += a[i][j];       }     }     a.swap(b);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int a, b;     cin >> a >> b;     vector<string> q(a);     for (int i = 0; i < a; ++i) {       cin >> q[i];     }     int cnt = 0;     int optx = -1, opty;     for (int x = 1; x <= a; ++x) {       for (int y = 1; y <= b; ++y) {         if (a % x || b % y) {           continue;         }         set<vector<string> > setik;         bool valid = true;         for (int i = 0; i < a / x; ++i) {           for (int j = 0; j < b / y; ++j) {             vector<string> vct;             for (int u = i * x; u < (i + 1) * x; ++u) {               string s =   ;               for (int v = j * y; v < (j + 1) * y; ++v) {                 s += q[u][v];               }               vct.push_back(s);             }             if (setik.count(vct)) {               valid = false;             }             for (int t = 0; t < 3; ++t) {               rot(vct);               if (setik.count(vct)) {                 valid = false;               }             }             for (int t = 0; t < 4; ++t) {               rot(vct);               setik.insert(vct);             }           }         }         if (valid) {           ++cnt;           if (optx == -1 || optx * opty > x * y ||               (optx * opty == x * y && optx > x)) {             optx = x, opty = y;           }         }       }     }     cout << cnt <<   n ;     cout << optx <<     << opty <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int onexor = 0;     bool ok = true;     long long s, x;     cin >> s >> x;     for (int i = 40; i >= 0; i--) {       if (s & (1LL << i)) {         if (x & (1LL << i)) {           continue;         } else {           bool foun = false;           for (int j = i - 1; j >= 0; j--) {             if (!(x & (1LL << j))) {               foun = true;               i = j + 1;               break;             }             if (s & (1LL << (j))) {               ok = false;               break;             }           }           if (!foun) {             ok = false;             break;           }         }       } else if (x & (1LL << i)) {         ok = false;       }     }     long long ans = 1LL;     for (int i = 40; i >= 0; i--) {       if (x & (1LL << i)) {         ans = ans * 2LL;       }     }     if (x == s) ans -= 2LL;     if (ok) {       cout << ans << endl;     } else       cout << 0 << endl;     cin >> s;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2;     cin >> s1 >> s2;     if (s2.size() > s1.size()) swap(s1, s2);     int x = s1.size() - s2.size();     for (int i = 0; i < s1.size() && i < s2.size(); ++i) {       if (s1[s1.size() - i - 1] != s2[s2.size() - i - 1]) {         x = s1.size() - i + s2.size() - i;         break;       }     }     cout << x << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MaxN = 1e5;   int n, q;   int all;   int pre[2 * MaxN + 5], last[MaxN + 5], other[2 * MaxN + 5];   int node[MaxN + 5];   int father[MaxN + 5];   int gcd(int x, int y) {     if (y == 0)       return x;     else       return gcd(y, x % y);   }   void build(int x, int y) {     pre[++all] = last[x];     last[x] = all;     other[all] = y;   }   void Dfs(int x, int fa) {     father[x] = fa;     int ed = last[x], dr;     while (ed != -1) {       dr = other[ed];       if (dr != fa) {         Dfs(dr, x);       }       ed = pre[ed];     }   }   int main() {     while (scanf( %d %d , &n, &q) != EOF) {       all = -1;       memset(last, -1, sizeof(last));       for (int i = 1; i <= n; i++) scanf( %d , &node[i]);       for (int i = 1; i < n; i++) {         int u, v;         scanf( %d %d , &u, &v);         build(u, v);         build(v, u);       }       Dfs(1, 0);       for (int i = 1; i <= q; i++) {         int op;         scanf( %d , &op);         if (op == 1) {           int v;           int ans = -1;           scanf( %d , &v);           int now = v;           while (father[v] != 0) {             v = father[v];             if (gcd(node[v], node[now]) > 1) {               ans = v;               break;             }           }           printf( %d n , ans);         } else {           int v, w;           scanf( %d %d , &v, &w);           node[v] = w;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void read(int &x) {     x = 0;     int f = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) f = -f;     for (; isdigit(ch); ch = getchar()) x = x * 10 + ch -  0 ;     x *= f;   }   void print(int x) {     if (x < 0) putchar( - ), x = -x;     if (!x) return;     print(x / 10), putchar(x % 10 + 48);   }   void write(int x) {     if (!x)       putchar( 0 );     else       print(x);     putchar(  n );   }   const int maxn = 1e6 + 10;   const int inf = 1e9;   const double eps = 1e-8;   const int mod = 1e9 + 7;   int v[maxn];   map<pair<int, int>, int> s;   int n, t, z[maxn], ans[maxn];   int query(int x, int y) {     if (x > y) swap(x, y);     if (s[make_pair(x, y)]) return s[make_pair(x, y)];     printf( ? %d %d n , x, y);     fflush(stdout);     int a;     read(a);     assert(a != -1);     return s[make_pair(x, y)] = a;   }   int get(int x) {     int a = (1 << t) - 1;     for (int i = 0; i < t; i++)       if (x != z[i])         a &= query(z[i], x);       else if ((a >> i) & 1)         a ^= 1 << i;     return a;   }   int main() {     srand(time(0));     read(n);     for (int i = 1; i < n; i <<= 1) t++;     while (1) {       int x = rand() % n + 1, y = rand() % n + 1, bo = 1;       for (int i = 0; i < t; i++)         if (!z[i]) bo = 0;       if (bo) break;       if (x == y) continue;       int a = query(x, y);       for (int i = 0; i < t; i++)         if (!((a >> i) & 1)) z[i] = x;     }     int a = get(1), pre = 1;     for (int i = 2; i <= n; i++)       if (query(pre, i) == a) a = get(i), pre = i;     for (int i = 1; i <= n; i++)       if (i != pre) ans[i] = query(pre, i);     printf( !  );     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios_base::sync_with_stdio(false);     long long k, n, m, x = 10;     int i = 1;     cin >> k;     k -= 9;     if (k <= 0) {       k = k + 9;       cout << k;       exit(0);     }     while (++i) {       k -= 9 * i * x;       if (k <= 0) {         k += 9 * i * x;         n = k / i;         m = k % i;         n = x + n;         if (m == 0) n -= 1;         ostringstream s;         s << n;         string s1 = s.str();         if (m == 0)           cout << s1[i - 1];         else           cout << s1[m - 1];         exit(0);       }       x = x * 10;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, a, b, c, val;   vector<vector<long long>> F1;   vector<vector<long long>> getNewMat() {     vector<vector<long long>> ans;     ans.resize(3 + 1);     for (auto &it : ans) it.resize(3 + 1);     return ans;   }   vector<vector<long long>> mult(vector<vector<long long>> A,                                  vector<vector<long long>> B) {     vector<vector<long long>> C;     C.resize(3 + 1);     for (long long i = 1; i <= 3; i++) C[i].resize(3 + 1);     for (long long i = 1; i <= 3; i++) {       for (long long j = 1; j <= 3; j++) {         for (long long k = 1; k <= 3; k++) {           C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % (1000000007 - 1);         }       }     }     return C;   }   vector<vector<long long>> _pow(vector<vector<long long>> mat, long long x) {     if (x == 1) return mat;     vector<vector<long long>> ansM = _pow(mult(mat, mat), x / 2);     if (x % 2) return mult(ansM, mat);     return ansM;   }   long long __pow(long long a, long long b) {     if (b == 0) return 1LL;     if (b == 1) return a;     if (b % 2) return __pow(a * a % 1000000007, b / 2) * a % 1000000007;     return __pow(a * a % 1000000007, b / 2) % 1000000007;   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> a >> b >> c >> val;     F1 = getNewMat();     F1[1][1] = F1[1][2] = F1[1][3] = F1[2][1] = F1[3][2] = 1;     if (n < 4) {       if (n == 1) cout << a <<   n ;       if (n == 2) cout << b <<   n ;       if (n == 3) cout << c <<   n ;       return 0;     }     long long ans = 1;     F1 = _pow(F1, n - 3);     a = a * val % 1000000007;     b = b * __pow(val, 2) % 1000000007;     c = c * __pow(val, 3) % 1000000007;     ans = __pow(a, (F1[1][3])) * __pow(b, (F1[1][2])) % 1000000007;     ans = ans * __pow(c, (F1[1][1])) % 1000000007;     val = __pow(val, n);     val = __pow(val, 1000000007 - 2);     ans = ans * val % 1000000007;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   int n, m;   int graph[21][21];   int deg[21];   int odd_cnt;   int odd[21];   int check[21];   int min1, sum;   void dfs(int u, int v, int len) {     int i, j;     if (len > min1) return;     for (i = 0; i < odd_cnt; i++) {       if (check[i] == 0) break;     }     if (i == odd_cnt) {       if (min1 > len) min1 = len;       return;     }     for (j = i + 1; j < odd_cnt; j++) {       if (!check[j]) {         check[i] = check[j] = 1;         dfs(i, j, len + graph[odd[i]][odd[j]]);         check[i] = check[j] = 0;       }     }   }   int chinese_postman() {     int i, j, k;     for (k = 1; k <= n; k++) {       for (i = 1; i <= n; i++) {         for (j = 1; j <= n; j++) {           graph[i][j] = ((graph[i][j]) > (graph[i][k] + graph[k][j])                              ? (graph[i][k] + graph[k][j])                              : (graph[i][j]));         }       }     }     for (i = 1; i <= n; i++) {       if (graph[1][i] == 999999999 && deg[i] > 0) return -1;     }     memset(odd, 0, sizeof(odd));     odd_cnt = 0;     for (i = 1; i <= n; i++) {       if (deg[i] & 1) {         odd[odd_cnt++] = i;       }     }     memset(check, 0, sizeof(check));     if (odd_cnt)       min1 = 999999999;     else       min1 = 0;     for (i = 1; i < odd_cnt; i++) {       check[0] = check[i] = 1;       dfs(0, i, graph[odd[0]][odd[i]]);       check[0] = check[i] = 0;     }     return min1 + sum;   }   int main() {     int i, j, a, b, c, res;     while (scanf( %d%d , &n, &m) == 2) {       memset(deg, 0, sizeof(deg));       for (i = 1; i <= n; i++) {         for (j = 1; j <= n; j++) graph[i][j] = 999999999;         graph[i][j] = 0;       }       sum = 0;       for (i = 0; i < m; i++) {         scanf( %d%d%d , &a, &b, &c);         sum += c;         graph[a][b] = graph[b][a] = ((graph[a][b]) > (c) ? (c) : (graph[a][b]));         deg[a]++;         deg[b]++;       }       res = chinese_postman();       printf( %d n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   const int N = 5005;   int t[N], cnt[N], ans[N];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &t[i]);     for (int i = 0; i < n; i++) {       memset(cnt, 0, sizeof(cnt));       int mx = 0, mxi = 1;       for (int j = i; j < n; j++) {         cnt[t[j]]++;         if (cnt[t[j]] > mx) {           mx = cnt[t[j]];           mxi = t[j];         } else if (cnt[t[j]] == mx) {           mxi = min(mxi, t[j]);         }         ans[mxi]++;       }     }     for (int i = 1; i <= n; i++) cout << ans[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e2 + 10;   const int inf = 0x3f3f3f3f;   int main() {     int n, a, b, c, d, start, len;     cin >> n >> a >> b >> c >> d >> start >> len;     vector<int> t(n), q(n);     for (int i = 0; i < n; i++) scanf( %d%d , &t[i], &q[i]);     int j = 0;     long long df = 0, mn = 0, ac = start;     vector<int> T;     T.push_back(-1);     for (int i = 0; i < n; i++) T.push_back(t[i]);     for (int i = 0; i < n; i++) {       while (j < n && t[j] - t[i] < len) {         df += (q[j] ? c : -d);         mn = min(mn, df);         j++;       }       if (ac + mn >= 0) {         cout << T[i] + 1 << endl;         return 0;       }       df -= (q[i] ? c : -d);       mn -= (q[i] ? c : -d);       ac += (q[i] ? a : -b);       if (ac < 0) {         puts( -1 );         return 0;       }     }     cout << T[n] + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200010;   int n, m;   long long dis[N];   bool vis[N];   vector<pair<int, int> > g[N];   map<pair<int, long long>, long long> M;   struct node {     long long dist;     int u;     inline bool operator<(const node &p) const { return dist > p.dist; }   };   long long Solve(void) {     fill(vis + 1, vis + 1 + n, 0);     fill(dis + 1, dis + 1 + n, -1);     priority_queue<node> q;     dis[1] = M[make_pair(1, 0)];     q.push((node){0LL, 1});     while (!q.empty()) {       node now = q.top();       q.pop();       int x = now.u;       if (vis[x]) continue;       vis[x] = 1;       for (int i = 0; i < (int)g[x].size(); ++i) {         int y = g[x][i].first, d = g[x][i].second;         long long tmp = M[make_pair(y, dis[x] + d)];         if (tmp == 0 || y == n) tmp = dis[x] + d;         if (dis[y] == -1 || dis[y] > tmp) dis[y] = tmp, q.push((node){tmp, y});       }     }     return dis[n];   }   int main(void) {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       g[x].push_back(make_pair(y, z));       g[y].push_back(make_pair(x, z));     }     for (int x = 1; x <= n; ++x) {       int num, t[N], p = 1;       scanf( %d , &num);       for (int i = 1; i <= num; ++i) {         scanf( %d , t + i);         if (i > 1 && t[i] - t[i - 1] > 1) {           for (int j = p; j < i; ++j) M[make_pair(x, t[j])] = t[i - 1] + 1;           p = i;         }       }       for (int i = p; i <= num; ++i) M[make_pair(x, t[i])] = t[num] + 1;     }     printf( %lld n , Solve());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX_SZ = 105;   struct request {     int type;     int r;     int x, y, val;     request(int type0, int r0) {       type = type0;       r = r0;     }     request(int type0, int x0, int y0, int val0) {       type = type0;       x = x0;       y = y0;       val = val0;     }   };   int main() {     ios_base::sync_with_stdio(false);     int n, m, q;     cin >> n >> m >> q;     int a[MX_SZ][MX_SZ];     memset(a, 0, sizeof(a));     vector<request> v;     for (int i = 0; i < q; i++) {       int type;       cin >> type;       if (type != 3) {         int r;         cin >> r;         v.push_back(request(type, r));       } else {         int x, y, val;         cin >> x >> y >> val;         v.push_back(request(type, x, y, val));       }     }     reverse(v.begin(), v.end());     int tmp[MX_SZ];     for (int i = 0; i < q; i++) {       if (v[i].type == 1) {         for (int j = 1; j <= m; j++) {           if (j == m) {             tmp[1] = a[v[i].r][j];           } else {             tmp[j + 1] = a[v[i].r][j];           }         }         for (int j = 1; j <= m; j++) {           a[v[i].r][j] = tmp[j];         }       }       if (v[i].type == 2) {         for (int j = 1; j <= n; j++) {           if (j == n) {             tmp[1] = a[j][v[i].r];           } else {             tmp[j + 1] = a[j][v[i].r];           }         }         for (int j = 1; j <= n; j++) {           a[j][v[i].r] = tmp[j];         }       }       if (v[i].type == 3) {         a[v[i].x][v[i].y] = v[i].val;       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cout << a[i][j] <<    ;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string val;     cin >> val;     int cngIn1 = -1;     int lDigit = int(val[val.length() - 1] -  0 );     for (int i = val.length() - 2; i >= 0; i--) {       int dig = int(val[i] -  0 );       if ((dig % 2 == 0) && (dig < lDigit)) {         cngIn1 = i;       }     }     string sNewVal1 = val;     if (cngIn1 != -1) {       sNewVal1[sNewVal1.length() - 1] = val[cngIn1];       sNewVal1[cngIn1] = val[sNewVal1.length() - 1];     }     int cngIn2 = -1;     for (int i = val.length() - 2; i >= 0; i--) {       int dig = int(val[i] -  0 );       if ((dig % 2 == 0) && (dig > lDigit)) {         cngIn2 = i;         break;       }     }     string sNewVal2 = val;     if (cngIn2 != -1) {       sNewVal2[sNewVal2.length() - 1] = val[cngIn2];       sNewVal2[cngIn2] = val[sNewVal2.length() - 1];     }     if ((sNewVal1 == val) && (sNewVal2 == val)) {       cout << -1;     } else if (sNewVal1 == val) {       cout << sNewVal2;     } else if (sNewVal2 == val) {       cout << sNewVal1;     } else {       cout << sNewVal1;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m[100005], a[100005];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       m[i] = a[i] + 1;     }     long long ans = 0;     for (int i = n - 1; i >= 1; --i) m[i] = max(m[i], m[i + 1] - 1);     for (int i = 1; i <= n; ++i) m[i] = max(m[i], m[i - 1]);     for (int i = 1; i <= n; ++i) ans += (m[i] - a[i] - 1);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void in(T &a) {     for (auto &x : a) cin >> x;   }   template <class T>   void out(T &a, string sep =    ) {     for (auto x : a) cout << x << sep;     cout <<   n ;   }   template <class T>   void err(T &a, string sep =    ) {     for (auto x : a) cerr << x << sep;     cerr <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int l;     cin >> l;     string a;     cin >> a;     int i = ((int)(a).size()) - 1;     while (i >= 0 && a[i] ==  9 ) {       a[i] =  0 ;       i--;     }     if (i >= 0) a[i]++;     if (i < 0 || ((int)(a).size()) % l) {       for (int i = 0; i <= ((int)(a).size()) / l; i++) {         cout <<  1 ;         for (int j = 1; j < l; j++) cout <<  0 ;       }       cout <<   n ;       return 0;     }     int in = 0;     for (int i = l; i < ((int)(a).size()); i++) {       if (a[i] < a[i % l]) {         break;       }       if (a[i] > a[i % l]) {         in = 1;         break;       }     }     if (in) {       int i = l - 1;       while (a[i] ==  9 ) {         a[i] =  0 ;         i--;       }       a[i]++;     }     for (int i = 0; i < ((int)(a).size()) / l; i++) cout << a.substr(0, l);     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, x, y, lev;     cin >> a >> y >> x;     a *= 2;     x *= 2;     y *= 2;     if (x % a == 0) {       cout << -1;       return 0;     } else       lev = (x / a) + 1;     if (lev == 1)       if (abs(y) >= a / 2) {         cout << -1;         return 0;       } else {         cout << 1;         return 0;       }     else if (lev % 2 == 0)       if (abs(y) >= a / 2) {         cout << -1;         return 0;       } else {         cout << (3 * lev) / 2 - 1;         return 0;       }     else if (abs(y) >= a || y == 0) {       cout << -1;       return 0;     } else if (y < 0) {       cout << (3 * (lev - 1)) / 2;       return 0;     } else {       cout << (3 * (lev - 1)) / 2 + 1;       return 0;     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   int main(void) {     char s[30], t[30], s1[30], s2[30];     scanf( %s %s , s, t);     int i = 0, c1 = 0, c2 = 0, c3 = 0;     while (s[i] !=  | ) {       s1[c1++] = s[i];       i++;     }     i++;     while (s[i] !=   0 ) {       s2[c2++] = s[i];       i++;     }     i = 0;     while (t[i++] !=   0 ) c3++;     if ((c1 + c2 + c3) % 2 == 1)       printf( Impossible );     else {       i = 0;       while (t[i] !=   0 ) {         if (c1 > c2) {           s2[c2++] = t[i++];         }         if (c1 <= c2 && t[i] !=   0 ) s1[c1++] = t[i++];       }       if (c1 != c2)         printf( Impossible );       else {         s1[c1] =   0 ;         s2[c2] =   0 ;         printf( %s|%s , s1, s2);       }     }     return 0;   }