malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include<bits/stdc++.h>   #define ll long long   #define all(v) v.begin(),v.end()   #define rall(v) v.rbegin(),v.rend()   #define sz(x) (int)(x).size()   #define PB push_back   #define PI 3.1415926535897932384626433832795   #define what(x) cout<<#x<<  is  <<x<<endl;   using namespace std;      #ifdef LOCAL//ONLINE_JUDGE   #include  D: c_c++ template.h    #else   #define debug(...) 42   #endif      ll powmod(ll a,ll b,ll mod) {       ll res=1;a%=mod;       for(;b;b>>=1){           if(b&1)res=res*a%mod;      a=a*a%mod;       }       return res;   }      void solve(){    ll n,k;    cin>>n>>k;    if(k>=n){     cout<<k/n+((k%n)?1:0)<<  n ;    }else{     ll f = (n/k)*k;     if(f<n)f+=k;     cout<<f/n+((f%n)?1:0)<<  n ;         }   }         int main(){       ios::sync_with_stdio(false);       cin.tie(0);   //    #ifdef LOCAL   //    freopen( input.txt ,  r , stdin);   //    freopen( output.txt ,  w , stdout);   //    #endif       int tc=1;        cin>>tc;       while(tc--)solve();   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const long double PI = 4 * atan((long double)1);   long long power(long long a, long long n) {     long long res = 1;     while (n) {       if (n % 2) res *= a;       a *= a;       n /= 2;     }     return res;   }   string bits(long long int n) {     long long int m = n;     string s;     while (m != 0) {       char x = (m % 2) +  0 ;       s = s + x;       m = m / 2;     }     reverse(s.begin(), s.end());     return s;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     string s;     cin >> s;     int e = 0;     long long int ans = 0;     for (int i = s.size() - 1; i > 0; i--) {       if (s[i] ==  1 ) {         if (e == 0) {           ans += 2;           e = 1;         } else           ans += 1;       } else {         if (e == 0)           ans += 1;         else           ans += 2;       }     }     if (e == 1) ans += 1;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   struct Matching {     int n;     vector<int> matchL, matchR, dist;     vector<bool> seen;     vector<vector<int>> ke;     Matching(int n)         : n(n),           matchL(n + 1),           matchR(n + 1),           dist(n + 1),           seen(n + 1, false),           ke(n + 1) {}     void addEdge(int u, int v) { ke[u].push_back(v); }     bool bfs() {       queue<int> qu;       for (int u = 1; u <= n; ++u)         if (!matchL[u]) {           dist[u] = 0;           qu.push(u);         } else           dist[u] = inf;       dist[0] = inf;       while (!qu.empty()) {         int u = qu.front();         qu.pop();         for (__typeof(ke[u].begin()) v = ke[u].begin(); v != ke[u].end(); ++v) {           if (dist[matchR[*v]] == inf) {             dist[matchR[*v]] = dist[u] + 1;             qu.push(matchR[*v]);           }         }       }       return dist[0] != inf;     }     bool dfs(int u) {       if (u) {         for (__typeof(ke[u].begin()) v = ke[u].begin(); v != ke[u].end(); ++v)           if (dist[matchR[*v]] == dist[u] + 1 && dfs(matchR[*v])) {             matchL[u] = *v;             matchR[*v] = u;             return true;           }         dist[u] = inf;         return false;       }       return true;     }     int match() {       int res = 0;       while (bfs()) {         for (int u = 1; u <= n; ++u)           if (!matchL[u])             if (dfs(u)) ++res;       }       return res;     }   };   const int M = 1e5 + 5;   pair<int, pair<int, int>> edge[M];   int m, n;   bool check(int max_weight) {     Matching matching(n);     for (auto e : edge) {       if (e.first > max_weight) break;       matching.addEdge(e.second.first, e.second.second);     }     return matching.match() == n;   }   int solve() {     int edge_num_needed = m;     for (int shift = floor(log2(m)); shift >= 0; --shift) {       if ((1 << shift) > edge_num_needed) continue;       if (check(edge[edge_num_needed - (1 << shift) - 1].first)) {         edge_num_needed -= (1 << shift);       }     }     if (!check(edge[edge_num_needed - 1].first)) {       return -1;     }     return edge[edge_num_needed - 1].first;   }   int main() {     cin >> n >> m;     for (int i = 0; i < m; ++i) {       int u, v, d;       cin >> u >> v >> d;       edge[i] = {d, {u, v}};     }     sort(edge, edge + m);     cout << solve();   }
#include <bits/stdc++.h>   using namespace std;   struct st {     int o;     int e;   } arr[101];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, b;     cin >> n >> b;     vector<long long> vec;     int v;     arr[0].o = 0;     arr[0].e = 0;     for (int i = 0; i < n; i++) {       cin >> v;       vec.push_back(v);       arr[i + 1] = arr[i];       if (v & 1) {         arr[i + 1].o++;       } else {         arr[i + 1].e++;       }     }     vector<long long> vv;     for (int i = 1; i < n; i++) {       if (arr[i].o == arr[i].e) {         vv.push_back(abs(vec[i] - vec[i - 1]));       }     }     int t = 0;     int ans = 0;     sort(vv.begin(), vv.end());     for (int i = 0; i < (int)vv.size(); i++) {       t += vv[i];       if (t > b) {         break;       }       ans++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long ans = 0, now, a[14], b[14];     for (int i = 0; i < 14; i++) cin >> a[i];     for (int i = 0; i < 14; i++) {       if (a[i] != 0) {         for (int j = 0; j < 14; j++) b[j] = a[j];         int r = b[i] % 14, q = b[i] / 14;         b[i] = 0;         for (int j = 0; j < 14; j++) b[j] += q;         for (int j = 1; j <= r; j++) b[(i + j) % 14]++;         now = 0;         for (int j = 0; j < 14; j++)           if (b[j] % 2 == 0) now += b[j];         ans = max(ans, now);       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 9;   const long long mod1 = 1000000;   ostringstream convert;   long long n, m, cur, dp[100][300];   long long res;   long long nbb = 0, nss = 0, ncc = 0, wmin, wmax;   long long nb, ns, nc, pb, ps, pc, mx = 0;   string s, s2;   string a[1000];   long long vis[10000] = {0}, wpers[10000];   vector<string> v, vnode;   map<string, long long> mp;   set<long long> st;   stack<double> stk;   long long dx[] = {0, 1, -1, 0};   long long dy[] = {1, 0, 0, -1};   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     long long i, j = 1, k = 0, d, p, q, l, r, pos, idx = -1, nbx, sumf = 0, test;     long long sum2 = 0, lg = 1, op;     long long x, lastx = 0, val1 = 0;     long long y = 1, z = 0;     char c;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i];     }     for (k = 0; k <= 100; k++)       for (i = 1; i <= n; i++) {         s = a[i];         j = 1;         if (!vis[i])           for (j = 1; j <= n; j++) {             s2 = a[j];             if (!vis[i] && !vis[j] && !strstr(s2.c_str(), s.c_str())) break;           }         if (j == n + 1) {           v.push_back(s);           vis[i] = 1;         }       }     if (v.size() == n) {       cout <<  YES n ;       for (i = 0; i < v.size(); i++) cout << v[i] << endl;     } else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n + n - 1);     int sum = 0;     for (int i = 0; i < n + n - 1; i++) {       cin >> a[i];       sum += a[i];     }     sort(a.begin(), a.end());     for (int i = 0; i < n + n - 2; i += 2) {       if (a[i] < 0 && a[i + 1] < 0) {         sum -= a[i] + a[i];         sum -= a[i + 1] + a[i + 1];         a[i] = -a[i];         a[i + 1] = -a[i + 1];       } else if (a[i] < 0) {         if (-a[i] > a[i + 1]) {           sum -= a[i] + a[i];           sum -= a[i + 1] + a[i + 1];           a[i] = -a[i];           a[i + 1] = -a[i + 1];         }       } else {         break;       }     }     if (n % 2) {       sort(a.begin(), a.end());       if (a[0] < 0) {         sum -= a[0] + a[0];       }     }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps(1e-8);   const double pi(3.14159265358979);   const int K = 33, mod = 1000000007;   struct matrix {     long long a[K][K];   } t[K] = {}, ans = {{}}, pre[K] = {}, suf[K] = {};   long long n;   int k;   inline void multi(const matrix &m1, const matrix &m2, matrix &to) {     static matrix tmp = {{}};     for (int i = 0; i <= k; ++i)       for (int j = 0; j <= k; ++j) {         tmp.a[i][j] = 0;         for (int p = 0; p <= k; ++p)           (tmp.a[i][j] += m1.a[i][p] * m2.a[p][j]) %= mod;       }     to = tmp;   }   void init() {     cin >> n >> k;     for (int i = 0; i <= k; ++i)       for (int j = 0; j <= k; ++j) ans.a[i][j] = i == j;     for (int p = 0; p < k; ++p)       for (int i = 0; i <= k; ++i)         for (int j = 0; j <= k; ++j) t[p].a[i][j] = i == j || i == p;   }   void work() {     vector<int> bit;     for (; n; n /= k) bit.push_back(n % k);     bit.push_back(0);     partial_sum(bit.rbegin(), bit.rend(), bit.rbegin());     for (auto p = 0u; p < bit.size() - 1; ++p) {       for (int i = bit[p] - 1; i >= bit[p + 1]; --i) multi(t[i % k], ans, ans);       pre[0] = t[0];       for (int i = 1; i < k; ++i) multi(pre[i - 1], t[i], pre[i]);       suf[k - 1] = t[k - 1];       for (int i = k - 2; i >= 0; --i) multi(t[i], suf[i + 1], suf[i]);       t[0] = suf[0];       for (int i = 1; i < k; ++i) multi(suf[i], pre[i - 1], t[i]);     }     long long sum = 0;     for (int i = 0; i <= k; ++i) sum += ans.a[i][k];     cout << sum % mod << endl;   }   int main() {     init();     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int b, g;     cin >> b;     int i;     int B[n];     for (i = 0; i < n; i++) {       B[i] = 0;     }     int bb[b];     for (i = 0; i < b; i++) {       cin >> bb[i];       B[bb[i]] = 1;     }     cin >> g;     int G[m];     for (i = 0; i < m; i++) {       G[i] = 0;     }     int gg[g];     for (i = 0; i < g; i++) {       cin >> gg[i];       G[gg[i]] = 1;     }     for (i = 0; i < 10000; i++) {       if (B[i % n] == 1) {         G[i % m] = 1;       }       if (G[i % m] == 1) {         B[i % n] = 1;       }     }     i = 0;     while (i < n) {       if (B[i] == 0) {         cout <<  No ;         return 0;       }       if (B[i] == 1) {         i++;       }     }     i = 0;     while (i < m) {       if (G[i] == 0) {         cout <<  No ;         return 0;       }       if (G[i] == 1) {         i++;       }     }     cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     int tp;     string s1, s2;   } a[200000];   struct node {     int n, next;   } b[200000];   int n, l, st[200000];   map<string, int> p;   int main() {     cin >> n;     scanf(  n );     int m = 0;     for (int i = 0; i < n; i++) {       string s;       getline(cin, s);       bool y = false;       string cd =   ;       for (int j = 0; j < s.length(); j++) {         if (s[j] ==     && !y) continue;         cd += s[j];         if (s[j] ==    ) y = !y;       }       if (cd.length() == 0) {         a[i].tp = -1;         continue;       }       if (cd[1] ==  r ) {         a[i].tp = 0;         st[++m] = i;       } else if (cd[1] ==  h ) {         a[i].tp = 1;         int j = 6;         a[i].s1 =   ;         while (cd[j] !=  ) ) a[i].s1 += cd[j++];       } else {         a[i].tp = 2;         int j = 6;         a[i].s1 =   ;         while (cd[j] !=  , ) a[i].s1 += cd[j++];         j += 2;         a[i].s2 =   ;         while (cd[j] !=    ) a[i].s2 += cd[j++];         a[st[m]].s2 = a[i].s2;         a[st[m--]].s1 = a[i].s1;       }     }     l = 1;     for (int i = 0; i < n; i++)       if (a[i].tp != -1) {         if (a[i].tp == 0) {           l++;           b[l].n = i;           if (p.count(a[i].s1) > 0) {             b[l].next = p[a[i].s1];             p[a[i].s1] = l;           } else {             b[l].next = 0;             p[a[i].s1] = l;           }         } else if (a[i].tp == 1) {           if (p.count(a[i].s1)) {             if (p[a[i].s1] != 0) {               cout << a[b[p[a[i].s1]].n].s2;               return 0;             }           }         } else if (a[i].tp == 2) {           if (p.count(a[i].s1)) {             p[a[i].s1] = b[p[a[i].s1]].next;           }         }       }     cout <<  Unhandled Exception ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 500;   const int M = 1e6 + 500;   const int INF = 0x3f3f3f3f;   const int MOD = 1e9 + 7;   const int LOG = 20;   const int OFF = (1 << 20);   const double EPS = 1e-9;   const double PI = 3.1415926535;   set<int> st;   int n, x, l, r;   char s[10];   long long sol = 1;   int main() {     st.insert(-INF);     st.insert(INF);     sol = 1;     l = -INF;     r = INF;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %s , s);       scanf( %d , &x);       if (s[1] ==  D ) {         st.insert(x);       } else {         st.erase(x);         if (l <= x && x <= r) {           if (x != l && x != r) sol = (2LL * sol) % (long long)MOD;           l = *(--st.upper_bound(x));           r = *st.upper_bound(x);         } else {           sol = 0;         }       }     }     int cnt = 0;     for (int x : st) {       if (l <= x && x <= r) cnt++;     }     sol = (sol * (cnt - 1)) % (long long)MOD;     printf( %d n , (int)sol);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[2000006];   int main() {     int n, i, w;     long long ans;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &w), cnt[w]++;     for (i = 0; i < 2000005; i++) {       cnt[i + 1] += cnt[i] / 2;       cnt[i] %= 2;     }     ans = 0;     for (i = 0; i < 2000006; i++) ans += cnt[i];     printf(          %I64d            n ,         ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * f;   }   const long long maxn = 4e5 + 1e2;   struct Node {     long long pos, val;   };   long long l[maxn], r[maxn];   long long n, m;   long long a[maxn];   Node s[maxn];   long long top;   long long ans;   long long pos[maxn];   bool in(long long x, long long l, long long r) { return (x >= l) && (x <= r); }   signed main() {     n = read();     for (long long i = 1; i <= n; i++) a[i] = read(), pos[a[i]] = i;     l[1] = 1;     top = 1;     s[1].val = a[1];     s[1].pos = 1;     for (long long i = 2; i <= n; i++) {       while (top >= 1 && s[top].val <= a[i]) top--;       if (!top)         l[i] = 1;       else         l[i] = s[top].pos + 1;       s[++top].val = a[i];       s[top].pos = i;     }     r[n] = n;     top = 1;     s[1].val = a[n];     s[1].pos = n;     for (long long i = n - 1; i >= 1; i--) {       while (top >= 1 && s[top].val < a[i]) top--;       if (!top)         r[i] = n;       else         r[i] = s[top].pos - 1;       s[++top].val = a[i];       s[top].pos = i;     }     for (long long i = 1; i <= n; i++) {       long long mx = a[i];       if (i - l[i] < r[i] - i) {         for (long long j = l[i]; j < i; j++) {           if (in(pos[mx - a[j]], i, r[i])) ans++;         }       } else {         for (long long j = i + 1; j <= r[i]; j++) {           if (in(pos[mx - a[j]], l[i], i)) ans++;         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[105];     int b[105];     int t, flag, flag1, i, n, c, sum1, sum2;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);       b[a[i]] = 1;     }     int count = 0;     int sum = 0;     flag = 1;     int d = -1;     c = 0;     for (i = 1; i <= 100; i++) {       if (b[i] == 1) {         count++;         sum += i;         if (c == 0)           c = i;         else {           if (d == -1) {             d = i - c;             c = i;           } else {             if (d != i - c) {               flag = 0;               break;             }             c = i;           }         }       }     }     if (flag == 0) {       printf( -1 n );     } else if (count == 1) {       printf( 0 n );     } else if (count == 2) {       if (sum % 2 == 0) {         sum = sum / 2;         printf( %d n , c - sum);       } else {         sum1 = sum - c;         sum1 = c - sum1;         sum2 = 2 * c - sum;         if (sum1 > sum2) {           sum1 = sum2;         }         printf( %d , sum1);       }     } else if (count == 3) {       sum = sum / count;       printf( %d n , c - sum);     } else {       printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Maxflow {     static const int oo = 100000005;     static const int maxn = 5555 * 2;     static const int maxm = 5555 * 4;     int T, S;     struct node {       int to, nxt, cap;     } ed[maxm * 2];     int head[maxn], cur[maxn], cnt, ans, ndnum;     int h[maxn];     void addedge(int u, int v, int cap) {       ed[cnt].to = v, ed[cnt].cap = cap, ed[cnt].nxt = head[u], head[u] = cnt++;       ed[cnt].to = u, ed[cnt].cap = 0, ed[cnt].nxt = head[v], head[v] = cnt++;     }     bool bfs() {       memset(h, -1, sizeof(h));       queue<int> q;       h[S] = 0, q.push(S);       while (!q.empty()) {         int now = q.front();         q.pop();         for (int i = head[now]; ~i; i = ed[i].nxt) {           if (ed[i].cap && h[ed[i].to] == -1) {             h[ed[i].to] = h[now] + 1;             q.push(ed[i].to);           }         }       }       return h[T] != -1;     }     int dfs(int x, int f) {       if (x == T || f == 0) return f;       int w, used = 0;       for (int i = cur[x]; ~i; i = ed[i].nxt) {         if (h[ed[i].to] == h[x] + 1) {           w = f - used;           w = dfs(ed[i].to, min(w, ed[i].cap));           ed[i].cap -= w;           ed[i ^ 1].cap += w;           if (ed[i].cap) cur[x] = i;           used += w;           if (used == f) return f;         }       }       if (!used) h[x] = -1;       return used;     }     void dinic() {       while (bfs()) {         for (int i = 1; i <= ndnum; i++) {           cur[i] = head[i];         }         ans += dfs(S, oo);       }     }     void init(int s, int t, int num) {       for (int i = 1; i <= num; i++) head[i] = -1;       ans = cnt = 0;       T = t;       S = s;       ndnum = num;     }   } flow;   int n, m;   int a[5111], b[5111];   bool isok(int x) {     flow.init(n + m + 1, n + m + 3, n + m + 3);     int s = n + m + 1, t = n + m + 2, T = n + m + 3;     for (int i = 1; i <= m; i++) {       flow.addedge(i, m + a[i], 1);       flow.addedge(i, m + b[i], 1);     }     for (int i = 1; i <= m; i++) flow.addedge(s, i, 1);     for (int i = 1; i <= n; i++) flow.addedge(m + i, t, x);     flow.addedge(t, T, m);     flow.dinic();     return flow.ans == m;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) scanf( %d%d , &a[i], &b[i]);     int l = 0, r = m, ans = m;     while (l <= r) {       int mid = l + r >> 1;       if (isok(mid)) {         ans = mid;         r = mid - 1;       } else         l = mid + 1;     }     printf( %d n , ans);     isok(ans);     for (int i = 0; i < 4 * m; i += 4) {       if (flow.ed[i].cap == 1)         printf( %d %d n , b[i / 4 + 1], a[i / 4 + 1]);       else         printf( %d %d n , a[i / 4 + 1], b[i / 4 + 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long valabs(long long x) {     if (x < 0) return -x;     return x;   }   inline long long max2(long long a, long long b) { return (a > b ? a : b); }   int main() {     long long x, y, xx, yy;     cin >> x >> y >> xx >> yy;     cout << max2(valabs(x - xx), valabs(y - yy)) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   const int inf = 0x3f3f3f3f;   int deep[maxn], fa[maxn][32];   vector<int> edge[maxn];   int flag[maxn];   void dfs(int u) {     flag[u] = 1;     for (auto i : edge[u]) {       int t = i;       if (flag[t]) continue;       deep[t] = deep[u] + 1;       fa[t][0] = u;       dfs(t);     }   }   int lca(int x, int y) {     if (deep[x] > deep[y]) swap(x, y);     for (int i = 30; i >= 0; i--)       if (deep[fa[y][i]] >= deep[x]) y = fa[y][i];     if (x == y) return x;     for (int i = 30; i >= 0; i--)       if (fa[x][i] != fa[y][i]) {         x = fa[x][i], y = fa[y][i];       }     return fa[x][0];   }   void init(int n) {     deep[1] = 1;     fa[1][0] = 1;     dfs(1);     for (int i = (1); i < (30); i++)       for (int j = (1); j < (n + 1); j++) fa[j][i] = fa[fa[j][i - 1]][i - 1];   }   int dis(int a, int b) { return deep[a] + deep[b] - 2 * deep[lca(a, b)]; }   int main() {     int n, q;     cin >> n >> q;     for (int i = (1); i < (n); i++) {       int p;       cin >> p;       edge[p].push_back(i + 1);       edge[i + 1].push_back(p);     }     init(n);     while (q--) {       int aans = 0;       int ii[3];       cin >> ii[0] >> ii[1] >> ii[2];       for (int i = (0); i < (3); i++)         aans = max(dis(ii[i], ii[(i + 1) % 3]) + dis(ii[i], ii[(i + 2) % 3]) -                            dis(ii[(i + 1) % 3], ii[(i + 2) % 3]) >>                        1,                    aans);       cout << aans + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int mh, currx = 1, level[110], l = 0;   char sc[110];   char mas[4 * 110][4 * 110];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> sc[i];       if (sc[i] ==  [ ) {         l++;         level[i] = l;       } else {         level[i] = l;         l--;       }       mh = max(l, mh);     }     mh = 3 + (mh - 1) * 2;     currx = 1;     for (int i = 1; i <= n; i++) {       if (sc[i] ==  ]  && sc[i - 1] ==  [ ) currx += 3;       l = level[i];       for (int j = l; j <= mh - l + 1; j++) {         mas[j][currx] =  | ;       }       mas[l][currx] =  + ;       mas[mh - l + 1][currx] =  + ;       if (sc[i] ==  [ ) {         mas[l][currx + 1] =  - ;         mas[mh - l + 1][currx + 1] =  - ;       }       if (sc[i] ==  ] ) {         mas[l][currx - 1] =  - ;         mas[mh - l + 1][currx - 1] =  - ;       }       currx++;     }     for (int i = 1; i <= mh; i++) {       for (int j = 1; j < currx; j++) {         if (mas[i][j] !=  |  && mas[i][j] !=  -  && mas[i][j] !=  + )           cout <<    ;         else           cout << mas[i][j];       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string rep(string s, int x) {     string res;     while (x--) res += s;     return res;   }   int ask(string str) {     cout << str <<   n ;     fflush(stdout);     int x;     cin >> x;     return x;   }   int main() {     int a = ask( a );     if (a == 0) return 0;     int len = a + 1;     if (len > 300) {       ask(rep( b , len - 1));       return 0;     }     string s = rep( a , len);     int curres = ask(s);     if (curres == len) {       ask(rep( b , len - 1));       return 0;     }     for (int i = 0; i < len - 1; i++) {       s[i] =  b ;       int nxt = ask(s);       if (nxt == 0) return 0;       if (nxt < curres) {         curres = nxt;       } else {         s[i] =  a ;       }     }     s[len - 1] =  b ;     ask(s);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b, c;     bool yes = true;     int length, i;     cin >> a >> b;     length = a.length();     for (i = 0; i < length; i++) {       if (a[i] < b[i]) {         yes = false;         break;       }     }     if (yes == false) {       cout << -1 << endl;     } else {       cout << b << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int n = s.length();     int m;     cin >> m;     int a[m];     for (int i = 0; i < m; i++) {       cin >> a[i];     }     sort(a, a + m);     for (int i = 0; i * 2 < s.size(); i++) {       int pos = upper_bound(a, a + m, i + 1) - a;       if (pos % 2) {         swap(s[i], s[s.size() - 1 - i]);       }     }     for (int i = 0; i < s.size(); i++) {       cout << s[i];     }   }