malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 5, inf = 1e9 + 7;   long long n, k;   string s, t;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long i, j, a, b, ans = 0;     cin >> n >> k >> s >> t;     ans = n;     i = 0;     while (i < n && s[i] == t[i]) i++;     long long t1 = 0, t2 = 0, a1 = 1, a2 = 1;     k--;     if (i < n && k) {       ans += n - i;       k--;       i++;     }     for (; i < n; i++) {       if (s[i] ==  a ) {         ans += min(k, t1 + 1) * (n - i);         k -= min(k, t1 + 1);         t1 = t1 * 2 + 1;       } else {         ans += min(k, t1) * (n - i);         k -= min(k, t1);         t1 *= 2;       }       if (t[i] ==  a ) {         ans += min(k, t2) * (n - i);         k -= min(k, t2);         t2 *= 2;       } else {         ans += min(k, t2 + 1) * (n - i);         k -= min(k, t2 + 1);         t2 = t2 * 2 + 1;       }       if (!k) break;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   vector<vector<pair<int, int> > > v2;   long long costs[(int)1e5 + 5];   int parent[(int)1e5 + 5];   vector<int> answer;   void dikstra() {     priority_queue<pair<long long, int>, vector<pair<long long, int> >,                    greater<pair<long long, int> > >         pq;     pq.push({0, 1});     parent[1] = -1;     costs[1] = 0;     while (!pq.empty()) {       int node = pq.top().second;       long long cost = pq.top().first;       pq.pop();       for (auto I : v2[node]) {         if (costs[I.second] > cost + I.first) {           costs[I.second] = cost + I.first;           parent[I.second] = node;           pq.push({costs[I.second], I.second});         }       }     }   }   int main() {     string s;     cin >> s;     cin >> n;     for (int i = 0; i < n; i++) {       s.push_back( ! );     }     int mx = 0;     for (int i = 0; i < s.size(); i++) {       for (int j = i + 1; j < s.size(); j++) {         int l = 0;         for (int k = i; k < i + ((j - i + 1) / 2); k++) {           if (s[k] ==  !  || s[k + (j - i + 1) / 2] ==  ! ) {             l++;           } else if (s[k] == s[k + (j - i + 1) / 2]) {             l++;           } else             break;         }         mx = max(mx, l * 2);       }     }     cout << mx << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long mpow(long long a, long long b) {     long long c = 1;     while (b) {       if (b & 1) c = c * a % 998244353;       a = a * a % 998244353;       b /= 2;     }     return c;   }   long long minv(long long a) { return mpow(a, 998244353 - 2); }   int n;   long long ans;   vector<int> g[500010];   long long f(int u, int p) {     long long prob = 1;     for (int v : g[u])       if (v != p) {         prob *= 1 - f(v, u) * ((998244353 + 1) / 2) % 998244353;         prob %= 998244353;       }     ans += 1 - prob;     ans %= 998244353;     return prob;   }   int main() {     scanf( %d , &n);     for (int i = 1, u, v; i < n; i++) {       scanf( %d %d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     f(1, 0);     printf( %I64d n , (ans + 998244353) * mpow(2, n) % 998244353);   }
#include <bits/stdc++.h>   using namespace std;   int n;   struct hh {     int t, nxt;   } edge[1000020 << 1];   int head[1000020], ecnt;   void make_edge(int f, int t) {     edge[++ecnt] = (hh){t, head[f]};     head[f] = ecnt;     edge[++ecnt] = (hh){f, head[t]};     head[t] = ecnt;   }   int dep[1000020], size[1000020], son[1000020], fa[1000020];   void dfs1(int x, int fa) {     dep[x] = dep[fa] + 1;     size[x] = 1;     for (int i = head[x]; i; i = edge[i].nxt)       if (edge[i].t != fa) {         dfs1(edge[i].t, x);         size[x] += size[edge[i].t];         if (size[edge[i].t] > size[son[x]]) son[x] = edge[i].t;       }   }   map<string, int> S[1000020];   int sum[1000020];   string a[1000020];   bool s[1000020];   void add(string s, int d, int t) {     if (!S[d][s]) ++sum[d];     S[d][s] += t;     if (!S[d][s]) --sum[d];   }   void add(int x, int fa, int t) {     add(a[x], dep[x], t);     for (int i = head[x]; i; i = edge[i].nxt)       if (edge[i].t != fa && !s[edge[i].t]) add(edge[i].t, x, t);   }   vector<pair<int, int> > q[1000020];   int ans[1000020];   void dfs2(int x, int fa, bool keep) {     for (int i = head[x]; i; i = edge[i].nxt)       if (edge[i].t != fa && edge[i].t != son[x]) dfs2(edge[i].t, x, 0);     s[son[x]] = 1;     if (son[x]) dfs2(son[x], x, 1);     add(x, fa, 1);     for (int i = 0; i < (int)q[x].size(); i++)       ans[q[x][i].first] = sum[q[x][i].second];     s[son[x]] = 0;     if (!keep) add(x, fa, -1);   }   int main() {     ios::sync_with_stdio(false);     int i, x, y, m;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i] >> fa[i];       if (fa[i]) make_edge(fa[i], i);     }     for (i = 1; i <= n; i++)       if (!fa[i]) dfs1(i, 0);     cin >> m;     for (i = 1; i <= m; i++) {       cin >> x >> y;       q[x].push_back(make_pair(i, dep[x] + y));     }     for (i = 1; i <= n; i++)       if (!fa[i]) dfs2(i, 0, 0);     for (i = 1; i <= m; i++) printf( %d n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)5e5 + 5;   int n, m, k, dp[1 << 15][110], nxt[N][16];   vector<int> a;   map<string, int> mp;   void update(int &x, int y) {     if (x == -1 || x > y) x = y;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; ++i) {       string s;       cin >> s;       mp[s] = i;     }     cin >> m;     int idx = 0, cnt = 0, lmt = n * (n - 1) / 2;     for (int i = 1; i <= m; ++i) {       cin >> k;       string s;       a.clear();       for (int j = 1; j <= k; ++j) {         cin >> s;         if (mp.find(s) != mp.end())           a.push_back(mp[s]);         else           a.push_back(0);       }       for (int j = 1; j <= n; ++j) nxt[k + 1][j] = k + 1;       for (int j = k; j >= 1; --j) {         for (int x = 1; x <= n; ++x) {           if (a[j - 1] == x)             nxt[j][x] = j;           else             nxt[j][x] = nxt[j + 1][x];         }       }       memset(dp, -1, sizeof(dp));       dp[0][0] = 0;       for (int x = 0; x < (1 << n) - 1; ++x) {         for (int y = 0; y <= lmt; ++y)           if (dp[x][y] != -1) {             int tmp = 0;             for (int z = n - 1; z >= 0; --z) {               if ((x >> z) & 1)                 ++tmp;               else {                 int pos = nxt[dp[x][y] + 1][z + 1];                 if (pos <= k && y + tmp <= lmt)                   update(dp[x | (1 << z)][y + tmp], pos);               }             }           }       }       for (int y = 0; y <= lmt; ++y)         if (dp[(1 << n) - 1][y] != -1) {           if (lmt - y + 1 > cnt) idx = i, cnt = lmt - y + 1;           break;         }     }     if (!idx) return puts( Brand new problem! ), 0;     printf( %d n[: , idx);     for (int i = 1; i <= cnt; ++i) printf( | );     printf( :] );     return 0;   }
#include <bits/stdc++.h>   int main() {     char old_h[1001][21], new_h[1001][21];     int q, i, j;     char temp[21];     scanf( %d , &q);     for (i = 0; i < q; i++) {       scanf( %s %s , old_h[i], new_h[i]);     }     for (i = 0; i < q; i++) {       for (j = i + 1; j < q; j++) {         if (strcmp(new_h[i], old_h[j]) == 0) {           strcpy(temp, new_h[i]);           strcpy(new_h[i], new_h[j]);           strcpy(new_h[j], temp);         }       }     }     int count = 0;     for (i = 0; i < q; i++) {       if (strcmp(old_h[i], new_h[i]) != 0) count++;     }     printf( %d n , count);     for (i = 0; i < q; i++) {       if (strcmp(old_h[i], new_h[i]) != 0) {         printf( %s %s n , old_h[i], new_h[i]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, d, ans = 0;   vector<long long> a;   int main() {     ios::sync_with_stdio(false);     cin >> n >> d;     while (n--) {       long long temp;       cin >> temp;       a.push_back(temp);     }     for (long long i = 0; i < a.size(); i++) {       long long idx = upper_bound(a.begin(), a.end(), a[i] + d) - a.begin();       idx--;       if (idx > i + 1) ans += ((idx - i) * (idx - i - 1)) / 2;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   int getbit(T s, int i) {     return (s >> i) & 1;   }   template <class T>   T onbit(T s, int i) {     return s | (T(1) << i);   }   template <class T>   T offbit(T s, int i) {     return s & (~(T(1) << i));   }   template <class T>   int cntbit(T s) {     return __builtin_popcount(s);   }   template <class T>   T gcd(T a, T b) {     T r;     while (b != 0) {       r = a % b;       a = b;       b = r;     }     return a;   }   template <class T>   T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   int n;   string s;   long long u[2000005], d[2000005];   long long nu[2000005], nd[2000005];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> s;     memset(nu, 0, sizeof(nu));     memset(nd, 0, sizeof(nd));     memset(u, 0, sizeof(u));     memset(d, 0, sizeof(d));     for (int i = (1); i <= (n); ++i) {       char ch = s[i - 1];       nu[i] = nu[i - 1];       nd[i] = nd[i - 1];       if (ch ==  U ) {         nu[i]++;         u[nu[i]] = u[nu[i] - 1] + i;       } else {         nd[i]++;         d[nd[i]] = d[nd[i] - 1] + i;       }     }     for (int i = (1); i <= (n); ++i) {       char ch = s[i - 1];       long long res = 0;       if (ch ==  U ) {         long long numd = nd[n] - nd[i];         long long numu = nu[i];         if (numd < numu) {           res += (d[nd[i] + numd] - d[nd[i]]) * 2 + n + 1;           res -= (u[nu[i]] - u[nu[i] - numd - 1]) * 2 - i;         } else {           res += (d[nd[i] + numu] - d[nd[i]]) * 2;           res -= (u[nu[i]]) * 2 - i;         }       } else {         long long numd = nd[n] - nd[i - 1];         long long numu = nu[i];         if (numd <= numu) {           res += (d[nd[i - 1] + numd] - d[nd[i - 1]]) * 2 + n + 1 - i;           res -= (u[nu[i]] - u[nu[i] - numd]) * 2;         } else {           res += (d[nd[i] + numu] - d[nd[i - 1]]) * 2 - i;           res -= (u[nu[i]]) * 2;         }       }       cout << res <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {1, 0, -1, 0, -1, 1, -1, 1};   int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};   const double eps = 1e-6;   const int N = 1e9;   void moha() {}   bool vis[1505][1505];   int comp[1505][1505][2];   char x[1505][1505];   int n, m;   int row(int x) { return (x + n * 1500) % n; }   int col(int y) { return (y + m * 1500) % m; }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     int a, b;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         cin >> x[i][j];         if (x[i][j] ==  S ) {           a = i;           b = j;         }       }     queue<pair<int, int> > q;     q.push({a, b});     vis[a][b] = 1;     comp[row(a)][col(b)][0] = a;     comp[row(a)][col(b)][1] = b;     while (!q.empty()) {       pair<int, int> p = q.front();       q.pop();       for (int i = 0; i < 4; i++) {         int xx = p.first + dx[i];         int yy = p.second + dy[i];         if (x[row(xx)][col(yy)] ==  # ) continue;         if (vis[row(xx)][col(yy)]) {           if (comp[row(xx)][col(yy)][0] != xx ||               comp[row(xx)][col(yy)][1] != yy) {             cout <<  Yes  << endl;             return 0;           }           continue;         }         q.push({xx, yy});         vis[row(xx)][col(yy)] = 1;         comp[row(xx)][col(yy)][0] = xx;         comp[row(xx)][col(yy)][1] = yy;       }     }     cout <<  No  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int a[101];   signed main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + 1 + n);     int ans = 0;     for (int i = 1; i <= n; i++) {       if (!a[i]) continue;       ans++;       for (int j = i + 1; j <= n; j++) {         if (a[j]) {           if (a[j] % a[i] == 0) a[j] = 0;         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   long long tt, x, y, z, sum, n, i, j, h, k, t, d, m, l, ll, rr, r, a[1000006],       b[1000006], f[1000006];   using namespace std;   long long xl(long long i) {     long long res = 0;     for (j = 1; j <= d; j++) b[j] = a[j];     l = 1;     r = i;     tt = 1;     z = b[1];     x = 1;     while (r <= n) {       if (b[x] > i) {         l += b[x] - b[x] % i - i;         r += b[x] - b[x] % i - i;         b[x] -= (b[x] - b[x] % i - i);       }       y = 0;       t = (l + r) / 2;       while (z < t) tt++, z += a[tt];       while (y < i) {         if (b[x] > i - y) {           res += (i - y) * abs(f[x] - f[tt]);           b[x] -= (i - y);           y = i;         } else {           res += b[x] * abs(f[x] - f[tt]);           y += b[x];           x++;         }       }       l += i;       r += i;     }     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n;     for (i = 1; i <= n; i++) {       cin >> j;       sum += j;       if (j > 0) d++, a[d] = j, f[d] = i;     }     if (sum == 1)       cout << -1;     else {       n = sum;       i = 2;       m = 1e18;       while (i <= sqrt(sum)) {         if (sum % i == 0) m = min(m, xl(i));         while (sum % i == 0) sum /= i;         i++;       }       if (sum > 1) m = min(m, xl(sum));       cout << m;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = LLONG_MAX;   const int inf = INT_MAX;   const int mod = 1e9 + 7;   const int pi = acos(-1);   const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};   const int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};   const int N = 2e5 + 5;   const int MAXN = 1e5 + 1;   int a[N], dp[N][6], p[N][6];   vector<int> v;   void ans(int n, int val) {     v.push_back(val);     if (n == 1) {       reverse(v.begin(), v.end());       for (int i = 0; i < (int)v.size(); i++) {         cout << v[i] <<    ;       }       exit(0);     }     int to = p[n][val];     ans(n - 1, to);   }   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= 5; i++) {       dp[1][i] = 1;     }     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= 5; j++) {         int w = INT_MIN;         for (int k = 1; k <= 5; k++) {           if (k == j) continue;           if (a[i] > a[i - 1]) {             if (j > k) w = max(w, dp[i - 1][k]);           }           if (a[i] < a[i - 1]) {             if (j < k) w = max(w, dp[i - 1][k]);           }           if (a[i] == a[i - 1]) {             w = max(w, dp[i - 1][k]);           }         }         if (w == 1) {           dp[i][j] = 1;           int ans;           for (int k = 1; k <= 5; k++) {             if (k == j) continue;             if (a[i] > a[i - 1]) {               if (j > k) {                 if (dp[i - 1][k] == 1) {                   ans = k;                   break;                 }               }             } else if (a[i] < a[i - 1]) {               if (j < k) {                 if (dp[i - 1][k] == 1) {                   ans = k;                   break;                 }               }             } else {               if (dp[i - 1][k] == 1) {                 ans = k;                 break;               }             }           }           p[i][j] = ans;         } else {           dp[i][j] = INT_MIN;         }       }     }     for (int i = 1; i <= 5; i++) {       if (dp[n][i] == 1) {         ans(n, i);         return 0;       }     }     cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 8;   const int mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       long long n, m;       cin >> n >> m;       long long arr[n][m];       long long x = 0;       for (long long i = 0; i < (n); i++) {         for (long long j = 0; j < (m); j++) {           cin >> arr[i][j];           if (arr[i][j] < 0) {             x++;           }         }       }       long long ans = 0;       long long minval = 101;       for (long long i = 0; i < (n); i++) {         for (long long j = 0; j < (m); j++) {           ans += abs(arr[i][j]);           minval = min(minval, abs(arr[i][j]));         }       }       if (x % 2 != 0) {         ans -= 2 * minval;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, colour[105], p[105];     memset(colour, -1, sizeof colour);     bool flag = 0;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> p[i];       colour[p[i]] = 2;     }     for (int i = 0; i < 101; i++) {       if (colour[i] == 2) {         colour[i] = flag;         flag = !flag;       }     }     for (int i = 0; i < n; i++) {       if (i) cout <<    ;       cout << colour[p[i]];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<vector<long long int>> grid(51, vector<long long int>(51, 0));     vector<pair<long long int, long long int>> a;     int t1 = 4 * n + 1;     while (t1--) {       int u, v;       cin >> u >> v;       a.push_back({u, v});       grid[u][v] = 1;     }     t1 = 4 * n + 1;     for (int stx = 0; stx < 50; stx++) {       for (int enx = stx + 1; enx < 51; enx++) {         for (int sty = 0; sty < 50; sty++) {           for (int eny = sty + 1; eny < 51; eny++) {             long long int cnt = 0, c1 = 0, c2 = 0, c3 = 0, c4 = 0;             for (int j = sty; j <= eny; j++) {               if (grid[stx][j] == 1) {                 cnt++;                 c1++;                 if (j == sty) {                   c2++;                 }                 if (j == eny) {                   c4++;                 }               }               if (grid[enx][j] == 1) {                 cnt++;                 c3++;                 if (j == sty) {                   c2++;                 }                 if (j == eny) {                   c4++;                 }               }             }             for (int j = stx + 1; j <= enx - 1; j++) {               if (grid[j][sty] == 1) {                 cnt++;                 c2++;               }               if (grid[j][eny] == 1) {                 cnt++;                 c4++;               }             }             if (cnt == 4 * n && c1 >= n && c2 >= n && c3 >= n && c4 >= n) {               for (int i = 0; i < a.size(); i++) {                 if (a[i].first != stx && a[i].first != enx &&                     a[i].second != sty && a[i].second != eny) {                   cout << a[i].first <<     << a[i].second;                   return 0;                 }                 if (a[i].first == stx || a[i].first == enx) {                   if (a[i].second < sty || a[i].second > eny) {                     cout << a[i].first <<     << a[i].second;                     return 0;                   }                 }                 if (a[i].second == sty || a[i].second == eny) {                   if (a[i].first < stx || a[i].first > enx) {                     cout << a[i].first <<     << a[i].second;                     return 0;                   }                 }               }             }           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, dp[3005][3005], a[1000005];   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , a + i);     if (n <= m) {       dp[1][a[1] % m] = 1;       for (int i = 2; i <= n; ++i) {         for (int j = 0; j < m; ++j) {           a[i] = (a[i] % m);           dp[i][j] = (dp[i - 1][j] | dp[i - 1][(j - a[i] + m) % m]);         }         dp[i][a[i] % m] = 1;       }       if (dp[n][0])         return !printf( YES n );       else         return !printf( NO n );     } else       printf( YES n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     cin >> n >> m;     if (m == 0) {       cout << 1 << endl;       return 0;     }     if (m <= n / 2) {       cout << m << endl;     } else {       long long res = n - m;       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long oo = 1e18;   const long long MAXN = 110;   long long N;   vector<string> query(long long a, long long b) {     cout <<  ?           <<     << a <<     << b <<   n ;     fflush(stdout);     long long sz = b - a + 1;     vector<string> vect;     for (long long i = 0; i < sz * (sz + 1) / 2; i++) {       string cad;       cin >> cad;       vect.push_back(cad);     }     return vect;   }   void res(string cad) {     cout <<  !           <<     << cad <<   n ;     fflush(stdout);   }   struct edge {     long long nodo;     char a, b;   };   vector<edge> L[MAXN];   char xx, yy;   void solve(vector<string> vect, long long des) {     vector<string> arr[MAXN];     long long sz = 0;     for (long long i = 0; i < vect.size(); i++) {       arr[vect[i].size()].push_back(vect[i]);       sz = max(sz, (long long)vect[i].size());     }     map<char, long long> cont;     for (long long i = 0; i < sz; i++) {       cont[arr[sz][0][i]]++;     }     vector<edge> vv;     for (long long i = 2; i <= sz / 2 + 1; i++) {       map<char, long long> mp;       map<char, long long> temp;       for (auto x : cont) {         temp[x.first] = x.second * i;       }       for (long long i = 0; i < vv.size(); i++) {         temp[vv[i].a] += i + 1;         temp[vv[i].b] += i + 1;       }       for (auto cad : arr[i]) {         for (long long x = 0; x < i; x++) {           mp[cad[x]]++;         }       }       char a, b;       for (auto x : temp) {         if (x.second > mp[x.first]) {           a = x.first;           break;         }       }       temp[a]--;       for (auto x : temp) {         if (x.second > mp[x.first]) {           b = x.first;           break;         }       }       cont[a]--;       cont[b]--;       vv.push_back({0, a, b});       L[i - 1 + des].push_back({sz - i + 2 + des, a, b});       L[sz - i + 2 + des].push_back({i - 1 + des, a, b});       if (i == 2 && des == 0) {         xx = a;         yy = b;       }     }   }   char ss[MAXN];   void DFS(long long nodo, long long padre, char c) {     ss[nodo] = c;     for (auto v : L[nodo]) {       if (v.nodo != padre) {         char temp;         if (v.a == c)           temp = v.b;         else           temp = v.a;         DFS(v.nodo, nodo, temp);       }     }   }   int32_t main() {     cin >> N;     vector<string> vect = query(1, N);     if (N == 1) {       res(vect[0]);       return 0;     }     solve(vect, 0);     vect = query(2, N);     solve(vect, 1);     if (xx != yy) {       vect = query(1, 1);       DFS(1, -1, vect[0][0]);       string st;       for (long long i = 1; i <= N; i++) st += ss[i];       res(st);     } else {       DFS(1, -1, xx);       string st;       for (long long i = 1; i <= N; i++) st += ss[i];       for (long long i = 0; i < N; i++) {         if (st[i] != st[N - i - 1]) {           vect = query(i + 1, i + 1);           char cc = vect[0][0];           if (st[i] != cc) {             reverse(st.begin(), st.end());           }           break;         }       }       res(st);     }     return 0;   }