malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1000 * 300 + 100;   vector<pair<int, int> > v[N], e;   pair<int, int> dir[N];   bool mark[N], mark2[N], use[N];   void sfd(int p) {     mark2[p] = true;     for (int i = 0; i < v[p].size(); i++) {       int id = v[p][i].second, q = v[p][i].first;       if (use[id] == false && mark2[q] == false) {         use[id] = true;         dir[id].first = q;         dir[id].second = p;         sfd(q);       } else if (dir[id].first == q && mark2[q] == false) {         sfd(q);       }     }   }   void dfs(int p) {     mark[p] = true;     for (int i = 0; i < v[p].size(); i++) {       int id = v[p][i].second, q = v[p][i].first;       if (mark[q] == false) {         dir[id].first = p;         dir[id].second = q;         use[id] = true;         dfs(q);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       v[a].push_back(make_pair(b, i));       v[b].push_back(make_pair(a, i));       e.push_back(make_pair(a, b));     }     dfs(1);     sfd(1);     for (int i = 1; i <= n; i++)       if (mark[i] == false || mark2[i] == false) {         cout << 0;         return 0;       }     for (int i = 0; i < m; i++) {       if (use[i])         cout << dir[i].first <<     << dir[i].second <<   n ;       else         cout << e[i].first <<     << e[i].second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[110][110];   bool equal_row(int i, int k) {     for (int j = 0; j < m; j++)       if (a[i][j] != a[k][j]) return false;     return true;   }   bool can(int from, int mid, int end) {     int i = mid - 1, k = mid;     while (i >= 0 && k < end) {       if (!equal_row(i, k)) return false;       i--, k++;     }     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> a[i][j];     if (n & 1)       cout << n <<   n ;     else {       int ans = n;       int end = n;       while (ans % 2 == 0) {         int mid = ans / 2;         if (!can(0, mid, end) || mid == 0) break;         ans = mid;         end = mid;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T, n, m, sum, tot;   struct P {     int val, x, y;   } a[500];   struct R {     int x, y;   } b[10];   bool cmp1(const P& a, const P& b) { return a.val > b.val; }   bool cmp2(const R& a, const R& b) { return a.y > b.y; }   bool Judge(int i, int j, int k, int u) {     int num[5], tmp = 1;     memset(num, 0, sizeof(num));     b[1].x = a[i].x, b[1].y = a[i].y;     b[2].x = a[j].x, b[2].y = a[j].y;     b[3].x = a[k].x, b[3].y = a[k].y;     b[4].x = a[u].x, b[4].y = a[u].y;     sort(b + 1, b + 4 + 1, cmp2);     num[1]++;     for (int l = 2; l <= 4; l++)       if (b[l].y == b[l - 1].y)         num[tmp]++;       else         num[tmp + 1]++, tmp++;     if (num[1] > num[2]) swap(num[1], num[2]);     if (tmp != 2 || num[1] == 1 && num[2] == 3) return true;     int t1 = abs(b[1].x - b[2].x), t2 = abs(b[3].x - b[4].x);     if (t1 < t2) swap(t1, t2);     if (t1 == 3 && t2 == 2 || t1 == 2 && t2 == 1) return false;     return true;   }   int main() {     scanf( %d , &T);     while (T--) {       sum = tot = 0;       scanf( %d%d , &n, &m);       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) {           scanf( %d , &a[++tot].val);           a[tot].x = i;           a[tot].y = j;         }       sort(a + 1, a + tot + 1, cmp1);       if (n <= 3 || n == 4 && m == 1) {         for (int i = 1; i <= n; i++) sum += a[i].val;         printf( %d n , sum);         continue;       }       for (int i = 1; i <= 8; i++)         for (int j = i + 1; j <= 8; j++)           for (int k = j + 1; k <= 8; k++)             for (int u = k + 1; u <= 8; u++)               if (Judge(i, j, k, u))                 sum = max(sum, a[i].val + a[j].val + a[k].val + a[u].val);       printf( %d n , sum);     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a(201), b(201);   int n, m;   int dp[201][2000];   int fun(int ind, int val) {     if (ind >= n) return val;     if (dp[ind][val] != (-1)) return dp[ind][val];     int i, temp = INT_MAX, j;     for (i = 0; i < m; i++) {       j = fun(ind + 1, ((a[ind] & b[i]) | val));       temp = min(temp, j);     }     return dp[ind][val] = temp;   }   int main() {     int i, j;     cin >> n >> m;     for (i = 0; i < n; i++) cin >> a[i];     for (i = 0; i < m; i++) cin >> b[i];     for (i = 0; i < n; i++)       for (j = 0; j < 2000; j++) dp[i][j] = (-1);     cout << fun(0, 0);     return 0;   }
#include <bits/stdc++.h>   char c[301][301];   int n, m, k;   int v[5][2] = {{0, 0}, {-1, 0}, {1, 0}, {0, -1}, {0, 1}};   void read() {     scanf( %d %d %d , &n, &m, &k);     for (int i = 0; i < n; i++) scanf( %s , &c[i]);   }   void print(int i, int j, int r) {     for (int z = 0; z < 5; z++)       printf( %d %d n , i + v[z][0] * r + 1, j + v[z][1] * r + 1);   }   int process() {     bool ok;     int i, j, x, y, z, tot = 0;     for (int r = 1; (r < 2 * n) && (r < 2 * m); r++) {       for (i = r; i < n - r; i++) {         for (j = r; j < m - r; j++) {           ok = true;           for (z = 0; z < 5 && ok; z++) {             if (c[i + (v[z][0] * r)][j + (v[z][1] * r)] ==  . ) ok = false;           }           if (ok) tot++;           if (tot == k) {             print(i, j, r);             return 0;           }         }       }     }     return 1;   }   int main() {     read();     if (process()) printf( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300020;   inline int read() {     int s = 0, w = 1;     char ch = getchar();     while (ch >  9  || ch <  0 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) s = s * 10 + ch -  0 , ch = getchar();     return s * w;   }   int T, n;   char x[N];   int main() {     T = read();     while (T--) {       n = read();       scanf( %s , x);       int c1 = 0, c2 = 0, c3 = 0;       for (int i = 0; i < n; i++) {         if (x[i] ==  > ) c1++;         if (x[i] ==  < ) c2++;         if (x[i] ==  -  || x[(i + 1) % n] ==  - ) c3++;       }       if (c1 != 0 && c2 != 0)         printf( %d n , c3);       else         printf( %d n , n);     }     return 0;   }
#include<cstdio>   #include<cstring>   #include<algorithm>   using namespace std;   int t,n,m,f[100005];   int main()   {    scanf( %d ,&t);    while(t--)    {     memset(f,0,sizeof(f));     scanf( %d%d ,&n,&m);     for(int i=1;i<=n;i++)      for(int j=1;j<=m;j++)      {       int x;       scanf( %d ,&x);       f[i+j]^=x;      }     int fl=0;     for(int i=1;i<=n+m;i++)      if(f[i]) fl=1;     if(fl) printf( Ashish n );     else printf( Jeel n );    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 2005;   int n, m;   char B[Maxn][Maxn];   bool U[Maxn][Maxn], D[Maxn][Maxn], L[Maxn][Maxn], R[Maxn][Maxn];   long long res;   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , B[i]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         U[i][j] = (i == 0 || U[i - 1][j]) && B[i][j] ==  . ;         L[i][j] = (j == 0 || L[i][j - 1]) && B[i][j] ==  . ;       }     for (int i = n - 1; i >= 0; i--)       for (int j = m - 1; j >= 0; j--) {         D[i][j] = (i == n - 1 || D[i + 1][j]) && B[i][j] ==  . ;         R[i][j] = (j == m - 1 || R[i][j + 1]) && B[i][j] ==  . ;       }     for (int i = 1; i + 1 < n; i++) res += L[i][m - 1];     for (int j = 1; j + 1 < m; j++) res += U[n - 1][j];     for (int i = 1; i + 1 < n; i++)       for (int j = 1; j + 1 < m; j++)         res += int(U[i][j] && L[i][j]) + int(U[i][j] && R[i][j]) +                int(D[i][j] && L[i][j]) + int(D[i][j] && R[i][j]);     for (int i = 1; i + 1 < n; i++) {       int ft = 0, fb = 0, fts = 0, fbs = 0;       for (int j = 1; j + 1 < m; j++) {         if (U[i][j]) res += fb + fts;         if (D[i][j]) res += ft + fbs;         if (B[i][j] ==  . ) {           ft += U[i][j];           fb += D[i][j];           if (j - 1 > 0) {             fts += U[i][j - 1];             fbs += D[i][j - 1];           }         } else           ft = fb = fts = fbs = 0;       }     }     for (int j = 1; j + 1 < m; j++) {       int fl = 0, fr = 0, fls = 0, frs = 0;       for (int i = 1; i + 1 < n; i++) {         if (L[i][j]) res += fr + fls;         if (R[i][j]) res += fl + frs;         if (B[i][j] ==  . ) {           fl += L[i][j];           fr += R[i][j];           if (i - 1 > 0) {             fls += L[i - 1][j];             frs += R[i - 1][j];           }         } else           fl = fr = fls = frs = 0;       }     }     printf( %I64d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v[70];   int n;   long long ans[100010], cur = 0;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       long long x;       cin >> x;       for (int j = 60; j >= 0; j--)         if ((x >> j) & 1) {           v[j].push_back(x);           break;         }     }     for (int i = 1; i <= n; i++) {       bool flag = 0;       for (int j = 0; j <= 60; j++)         if (!(cur & (1ll << j)) && !v[j].empty()) {           cur ^= (ans[i] = v[j].back());           v[j].pop_back();           flag = 1;           break;         }       if (!flag) {         cout <<  No  << endl;         return 0;       }     }     cout <<  Yes  << endl;     for (int i = 1; i <= n; i++) cout << ans[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     long long int n, ans, c = 1, i;     cin >> t;     while (t--) {       cin >> n;       c = 1, ans = 0, i = 1;       while (n > 0) {         if (n <= 4) {           if (i % 2 != 0) {             ans = ans + max(c, n - 1);           } else             ans += n - max(c, n - 1);           break;         } else if (n > 4 && (n % 2 != 0 || n % 4 == 0)) {           if (i % 2 != 0) ans = ans + 1;           i++;           n--;         } else {           if (i % 2 != 0) {             ans = ans + n / 2;           }           i++;           n = n / 2;         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[200001];   int deg[200001];   bool vis[200001];   void dfs(int s) {     vis[s] = 1;     deg[s] = 1;     for (auto i : v[s]) {       if (vis[i]) continue;       dfs(i);       deg[s] += deg[i];     }   }   void solve(int s) {     for (auto i : v[s])       if (deg[i] % 2 == 0) solve(i);     cout << s <<   n ;     for (auto i : v[s])       if (deg[i] % 2 == 1) solve(i);   }   int main() {     int n;     cin >> n;     if (n % 2 == 0) {       cout <<  NO n ;       return 0;     }     cout <<  YES n ;     int rt;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       if (x == 0)         rt = i;       else         v[x].push_back(i);     }     dfs(rt);     solve(rt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, h;     cin >> n >> h;     vector<int> v(n);     for (auto &a : v) cin >> a;     int res = 0;     for (int i = 0; i < n; i++) {       if (v[i] <= h)         res++;       else         res += 2;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int c[n + 1], e[n - 1][2];     for (int i = 0; i < n - 1; ++i) {       cin >> e[i][0] >> e[i][1];     }     for (int i = 1; i <= n; ++i) {       cin >> c[i];     }     vector<int> e1;     vector<int> e2;     for (int i = 0; i < n - 1; ++i) {       if (c[e[i][1]] != c[e[i][0]]) {         e1.push_back(e[i][1]);         e2.push_back(e[i][0]);       }     }     bool k = true;     int v = 1;     if (n > 2 && e1.size() > 1) {       if (e1[0] == e1[1] || e1[0] == e2[1]) {         v = e1[0];       } else if (e2[0] == e1[1] || e2[0] == e2[1]) {         v = e2[0];       } else {         k = false;       }       for (int i = 1; i < e1.size(); ++i) {         if (e1[i] != v && e2[i] != v) {           k = false;           break;         }       }     }     if (e1.size() == 1) v = e1[0];     if (k || n < 3)       cout <<  YES             <<   n             << v;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void rip() {     cout << -1;     exit(0);   }   set<int> st;   set<int> seen;   vector<int> ans;   int main() {     int N;     cin >> N;     for (int i = 1; i <= N; i++) {       int x;       cin >> x;       if (x > 0) {         if (!seen.insert(x).second) rip();         st.insert(x);       } else {         if (st.find(-x) == st.end()) rip();         st.erase(-x);       }       if (st.empty()) {         ans.push_back(i);         seen.clear();       }     }     if (ans.empty() || ans.back() != N) rip();     assert(st.empty());     cout << ans.size() <<   n ;     for (int i = 0; i < ans.size(); i++)       cout << ans[i] - (i == 0 ? 0 : ans[i - 1]) <<    ;   }
#include <bits/stdc++.h>   using namespace std;   long long c[100005], a[100005], b[100005], cur[100005];   int n, m;   void update(int x, long long y) {     while (x <= m) {       c[x] += y;       if (c[x] >= 1000000007) c[x] -= 1000000007;       x += x & (-x);     }   }   long long query(int x) {     long long sum = 0;     while (x > 0) {       sum += c[x];       if (sum >= 1000000007) sum -= 1000000007;       x -= x & (-x);     }     return sum % 1000000007;   }   int main() {     int i, j;     while (~scanf( %d , &n)) {       for (i = 0; i < n; i++) scanf( %I64d , &a[i]), b[i] = a[i];       sort(b, b + n);       m = unique(b, b + n) - b;       memset(c, 0, sizeof(c));       memset(cur, 0, sizeof(cur));       for (i = 0; i < n; i++) {         j = lower_bound(b, b + m, a[i]) - b + 1;         long long t = query(j), t1 = cur[j];         cur[j] = (t * a[i] + a[i]) % 1000000007;         t = cur[j] - t1;         if (t < 0) t += 1000000007;         update(j, t);       }       long long sum = 0;       for (i = 1; i <= m; i++) sum += cur[i];       sum %= 1000000007;       if (sum < 0) sum += 1000000007;       printf( %I64d n , sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e3 + 10, INF = 0x3f3f3f3f;   struct edge {     int x;     int y;   } e[maxn];   int w[maxn][maxn];   int num[maxn];   vector<int> vec[maxn];   int depth[maxn];   int fa[maxn];   void dfs(int cur, int p, int dep) {     fa[cur] = p;     depth[cur] = dep;     for (int x : vec[cur]) {       if (x != p) {         dfs(x, cur, dep + 1);       }     }     num[cur] = INF;   }   bool lca_modify(int x, int y, int k) {     int minn = INF;     if (depth[x] < depth[y]) swap(x, y);     while (depth[x] != depth[y]) {       if (num[x] == INF) {         num[x] = k;         w[x][fa[x]] = w[fa[x]][x] = k;       }       minn = min(minn, num[x]);       x = fa[x];     }     while (x != y) {       if (num[x] == INF) {         num[x] = k;         w[x][fa[x]] = w[fa[x]][x] = k;       }       minn = min(minn, num[x]);       x = fa[x];       if (num[y] == INF) {         num[y] = k;         w[y][fa[y]] = w[fa[y]][y] = k;       }       minn = min(minn, num[y]);       y = fa[y];     }     return minn == k;   }   const int maxm = 5e3 + 10;   struct query {     int x, y, len;   } q[maxm];   bool cmp(query a, query b) { return a.len > b.len; }   int main() {     int n, m;     cin >> n;     for (int i = 0; i < n - 1; i++) {       int x, y;       cin >> x >> y;       e[i].x = x, e[i].y = y;       vec[x].push_back(y);       vec[y].push_back(x);     }     dfs(1, 0, 1);     cin >> m;     int x, y, len;     for (int i = 1; i <= m; i++) {       cin >> x >> y >> len;       q[i].x = x, q[i].y = y, q[i].len = len;     }     sort(q + 1, q + 1 + m, cmp);     int flag = 1;     for (int i = 1; i <= m; i++) {       x = q[i].x, y = q[i].y, len = q[i].len;       if (lca_modify(x, y, len) == false) {         flag = 0;         break;       }     }     if (!flag) {       cout << -1 << endl;     } else {       for (int i = 0; i < n - 1; i++) {         x = e[i].x, y = e[i].y;         if (x > y) swap(x, y);         if (w[x][y] == 0)           cout << 1000000;         else           cout << w[x][y];         if (i != n - 2)           cout <<    ;         else           cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int L = 20, N = 1e6 + 5;   const long long MOD = 1e9 + 7;   int dp[1 << L], n;   long long pow2[N];   int main() {     scanf( %d , &n);     int a;     for (int i = (int)1; i <= n; i++) {       scanf( %d , &a);       dp[a]++;     }     pow2[0] = 1;     for (int i = (int)1; i <= N - 1; i++) pow2[i] = pow2[i - 1] * 2 % MOD;     for (int i = (int)0; i <= L - 1; i++)       for (int msk = (int)0; msk <= (1 << L) - 1; msk++)         if (msk >> i & 1 ^ 1) dp[msk] += dp[msk ^ (1 << i)];     for (int msk = (int)0; msk <= (1 << L) - 1; msk++) {     }     long long ans = (pow2[dp[0]] - 1 + MOD) % MOD;     for (int msk = (int)1; msk <= (1 << L) - 1; msk++) {       if (dp[msk] == 0) continue;       if (__builtin_popcount(msk) % 2) {         ans = (ans - pow2[dp[msk]] + 1 + MOD) % MOD;       } else {         ans = (ans + pow2[dp[msk]] - 1 + MOD) % MOD;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const int INF = 107374182;   using namespace std;   int n, k;   int ans[100005][2];   struct sa {     int ma, mi;   } segTree[1000000];   void build(int l, int r, int root) {     if (l == r) {       if (l != n + 1) {         scanf( %d , &segTree[root].ma);         segTree[root].mi = segTree[root].ma;       } else {         segTree[root].ma = 0;         segTree[root].mi = INF;       }       return;     }     int mid = (l + r) >> 1;     build(l, mid, root << 1);     build(mid + 1, r, (root << 1) | 1);     segTree[root].ma = max(segTree[root << 1].ma, segTree[(root << 1) | 1].ma);     segTree[root].mi = min(segTree[root << 1].mi, segTree[(root << 1) | 1].mi);   }   sa query(int L, int R, int l, int r, int root) {     if (L <= l && r <= R) {       return segTree[root];     }     sa ans, temp;     if (l == r) {       temp.ma = 0;       temp.mi = INF;       return temp;     }     int mid = (l + r) >> 1;     ans.ma = 0;     ans.mi = INF;     if (L <= mid) {       temp = query(L, R, l, mid, root << 1);       ans.ma = max(ans.ma, temp.ma);       ans.mi = min(ans.mi, temp.mi);     }     if (R > mid) {       temp = query(L, R, mid + 1, r, (root << 1) | 1);       ans.ma = max(ans.ma, temp.ma);       ans.mi = min(ans.mi, temp.mi);     }     return ans;   }   int main() {     scanf( %d%d , &n, &k);     {       build(1, n, 1);       int maxlength = 0, cnt = 0;       sa tempx, tempy;       for (int i = 1; i <= n; i++) {         int l = i, r = n + 1;         while (r > l + 1) {           int mid = (l + r) >> 1;           tempx = query(i, mid + 1, 1, n, 1);           if (tempx.ma - tempx.mi > k)             r = mid;           else             l = mid;         }         tempx = query(i, l, 1, n, 1);         tempy = query(i, r, 1, n, 1);         if (tempx.ma - tempx.mi <= tempy.ma - tempy.mi &&             tempy.ma - tempy.mi <= k && l < n)           l++;         if (maxlength < l - i + 1) {           maxlength = l - i + 1;           ans[0][0] = i;           ans[0][1] = l;           cnt = 1;         } else if (maxlength == l - i + 1) {           ans[cnt][0] = i;           ans[cnt++][1] = l;         }       }       printf( %d %d n , maxlength, cnt);       for (int i = 0; i < cnt; i++) {         printf( %d %d n , ans[i][0], ans[i][1]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct two {     long long int f, s;   };   signed main() {     long long int n;     cin >> n;     map<string, set<string> > mp;     while (n--) {       string str;       cin >> str;       for (long long int i = 0; i < str.size(); i++) {         string tmp =   ;         for (long long int j = i; j < str.size(); j++) {           tmp += str[j];           mp[tmp].insert(str);         }       }     }     long long int q;     cin >> q;     while (q--) {       string str;       cin >> str;       if (mp.find(str) != mp.end())         cout << mp[str].size() <<     << *mp[str].begin() << endl;       else         cout << 0 <<     <<  -  << endl;     }   }
#include <bits/stdc++.h>   inline long long read() {     long long x = 0, f = 1;     char c = getchar();     for (; c >  9  || c <  0 ; c = getchar()) {       if (c ==  - ) f = -1;     }     for (; c >=  0  && c <=  9 ; c = getchar()) {       x = x * 10 + c -  0 ;     }     return x * f;   }   int cnt[27][105];   char s[105], s1[105];   std::string sss, halfans, halfans2;   std::vector<char> ans;   std::map<std::string, int> H1[105], H2[105];   inline char getA(std::string a, std::string b) {     int c[30];     memset(c, 0, sizeof c);     for (int i = 0; i < a.size(); i++) c[a[i] -  a ]++;     for (int i = 0; i < b.size(); i++) c[b[i] -  a ]--;     for (int i = 0; i < 26; i++) {       if (c[i] > 0) return i +  a ;     }     return  a ;   }   inline std::string solve(int n) {     printf( ? 1 %d n , n);     fflush(stdout);     for (int i = 1; i <= n * (n + 1) >> 1; i++) {       scanf( %s , s);       sss = std::string(s);       std::sort(sss.begin(), sss.end());       H1[sss.size()][sss]++;     }     printf( ? 2 %d n , n);     fflush(stdout);     for (int i = 1; i <= n * (n - 1) >> 1; i++) {       scanf( %s , s);       sss = std::string(s);       std::sort(sss.begin(), sss.end());       H2[sss.size()][sss]++;     }     for (int i = 1; i <= n; i++) {       for (auto p : H2[i]) {         H1[i][p.first] -= H2[i][p.first];       }       for (auto p : H1[i]) {         if (p.second > 0) {           std::string new1 = (  );           for (int j = 0; j < ans.size(); j++) new1 += ans[j];           ans.push_back(getA(p.first, new1));         }       }     }     std::string new1 = (  );     for (int j = 0; j < ans.size(); j++) new1 += ans[j];     return new1;   }   inline void work() {     int n = read();     if (n == 1) {       puts( ? 1 1 );       fflush(stdout);       scanf( %s , s);       printf( ! %s n , s);       fflush(stdout);     } else if (n == 2) {       puts( ? 1 1 );       fflush(stdout);       scanf( %s , s);       puts( ? 2 2 );       fflush(stdout);       scanf( %s , s1);       printf( ! %s%s n , s, s1);       fflush(stdout);     } else {       halfans = solve(n + 1 >> 1);       printf( ? 1 %d n , n);       fflush(stdout);       for (int i = 1; i <= n * (n + 1) >> 1; i++) {         scanf( %s , s);         sss = std::string(s);         for (int j = 0; j < sss.size(); j++) {           cnt[sss[j] -  a ][sss.size()]++;         }       }       halfans2 = std::string(  );       for (int i = 1; i <= n >> 1; i++) {         for (int j = 0; j < 26; j++) {           int num = cnt[j][1] - (cnt[j][i + 1] - cnt[j][i]);           for (int k = 0; k < i; k++) {             if (halfans[k] -  a  == j) {               num--;             }           }           for (int k = 0; k < halfans2.size(); k++) {             if (halfans2[k] -  a  == j) {               num--;             }           }           if (num > 0) {             halfans2 += ( a  + j);             break;           }         }       }       for (int i = halfans2.size() - 1; ~i; i--) halfans += halfans2[i];       printf( ! %s n , halfans.c_str());       fflush(stdout);     }   }   int main() {     work();     return 0;   }