malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct hash {     int head[8592637], next[8592637], t;     unsigned long long lk[8592637];     double x[8592637];     double find(unsigned long long s) {       for (int i = head[s % 8592637]; i; i = next[i])         if (lk[i] == s) return x[i];       return -1;     }     void ins(unsigned long long s, double f) {       if (find(s) > -1) return;       lk[++t] = s, x[t] = f, next[t] = head[s % 8592637], head[s % 8592637] = t;     }   } H;   int N, a[105], F[256], b[105];   inline int G(int x) { return !!x; }   inline void get(int x, int* a) {     a[0] = (x >> 4) & 3, a[1] = (x >> 2) & 3, a[2] = x & 3;   }   inline int BG(int a, int b, int c) {     if (a > c) swap(a, c);     return (((a << 2) + b) << 2) + c;   }   void init() {     scanf( %d , &N), F[ G ] = 1, F[ B ] = 2, F[ R ] = 3;     char s[4];     for (int i = 1; i <= N; i++)       scanf( %s , s), a[i] = BG(F[s[0]], F[s[1]], F[s[2]]);   }   unsigned long long Hash(int n) {     unsigned long long s = 0;     for (int i = 1; i <= n; i++) b[i] = a[i];     sort(b + 1, b + n);     for (int i = 1; i <= n; i++) (s *= 31415927) += b[i];     return s;   }   double dfs(int n) {     unsigned long long s = Hash(n);     double f = H.find(s), c[4] = {0, 1e9, 1e9, 1e9};     if (f > -1) return f;     for (int i = 1; i < n; i++) {       int x[3], y[3], nn = n, ai = a[i], an = a[n];       get(ai, x), get(an, y);       if (G(x[0]) + G(x[1]) + G(x[2]) == 1) continue;       if (y[0] && y[1] && y[2]) nn++, y[0] = y[1] = y[2] = 0;       for (int j = 0; j < 3; j++)         if (x[j]) {           int t = x[j];           if (G(x[0]) + G(x[1]) + G(x[2]) == 2 && j == 1) continue;           if (G(x[0]) + G(x[1]) + G(x[2]) == 2 && !x[1]) break;           x[j] = 0, a[i] = BG(x[0], x[1], x[2]);           if (G(x[0]) + G(x[1]) + G(x[2]) == 1 || !x[1]) a[i] = 0;           x[j] = t;           for (int k = 0; k < 3; k++)             if (!y[k])               y[k] = t, a[nn] = BG(y[0], y[1], y[2]), y[k] = 0,               c[t] = min(c[t], dfs(nn));         }       a[i] = ai, a[n] = an;     }     if (c[1] == 1e9 && c[2] == 1e9 && c[3] == 1e9) return H.ins(s, 0), 0;     double t = 1.0 / 6;     if (c[1] == 1e9) t += 1.0 / 3, c[1] = 0;     if (c[2] == 1e9) t += 1.0 / 3, c[2] = 0;     if (c[3] == 1e9) t += 1.0 / 6, c[3] = 0;     f = (c[1] / 3 + c[2] / 3 + c[3] / 6 + 1) / (1 - t), H.ins(s, f);     return f;   }   int main() {     init();     printf( %.6lf n , dfs(N));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, k;   int a[N];   void solve(int l, int r) {     if (k <= 0) {       return;     }     if (l == r - 1) {       return;     }     int mid = (l + r) / 2;     swap(a[mid - 1], a[mid]);     --k;     --k;     solve(l, mid);     solve(mid, r);   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) a[i] = i + 1;     if (k % 2 == 0) {       puts( -1 );       return 0;     }     if (k > ((n)*2 - 1)) {       puts( -1 );       exit(0);     }     --k;     solve(0, n);     for (int i = 0; i < n; i++) printf( %d  , a[i]);   }
#include <bits/stdc++.h>   using namespace std;   long long int scs(long long int a) {     long long int u = 0;     while (a) {       u++;       a /= 10;     }     return u;   }   long long int mul(long long int a, long long int b, long long int m) {     if (b == 1) return a % m;     if (b == 0) return 1 % m;     a %= m;     b %= m;     long long int q = mul(a, b / 2, m);     if (b % 2 == 0)       return (q + q) % m;     else       return (q + q + a) % m;   }   long long int mu(long long int a, long long int n, long long int m) {     if (n == 0) return 1 % m;     long long int q = mu(a, n / 2, m);     if (n % 2 == 0)       return mul(q, q, m);     else       return mul(mul(q, q, m), a, m);   }   long long int mu5[20];   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     long long int t;     cin >> t;     mu5[0] = 1;     for (int i = 1; i <= 19; i++) mu5[i] = mu5[i - 1] * 5;     for (int z = 1; z <= t; z++) {       long long int a;       cin >> a;       long long int n = scs(a);       long long int v = 0, m = 0;       for (int mmm = 0; mmm <= 6; mmm++) {         m = mmm;         long long int b = (-a) % (1LL << (m + n)) * mu5[m] % (1LL << (m + n)) *                           (1LL << m) % (1LL << (m + n));         b %= (1LL << (m + n));         if (b < 0) b += (1LL << (m + n));         bool q = 0;         while (b < mu5[m] * (1LL << m)) {           v = (b + mu5[m] * (1LL << m) * a) / (1LL << (m + n));           if (v % 5 != 0) {             q = 1;             break;           }           b += (1LL << (m + n));         }         if (q == 1) {           break;         }       }       v %= mu5[m + n];       long long int mm[4] = {1, 2, 4, 3};       long long int res = 0;       for (int i = 0; i <= 3; i++) {         if (mm[i] == v % 5) res = i;       }       for (int i = 2; i <= m + n; i++) {         long long int r = res;         for (int u = 0; u <= 4; u++) {           if (mu(2, r + u * 4 * mu5[i - 2], mu5[i]) == v % mu5[i]) {             res = r + u * 4 * mu5[i - 2];             break;           }         }       }       res += m + n;       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isPowerOfTwo(long long n) {     if (n == 0) return false;     return (ceil(log2(n)) == floor(log2(n)));   }   long long power(long long x, unsigned long long y) {     if (y == 0)       return 1;     else if (y % 2 == 0)       return power(x, y / 2) * power(x, y / 2);     else       return x * power(x, y / 2) * power(x, y / 2);   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   signed main() {     long long n;     cin >> n;     priority_queue<long long> a, b, c, d;     for (long long i = 0; i < n; i++) {       string s;       long long x;       cin >> s >> x;       if (s ==  11 ) a.push(x);       if (s ==  10 ) b.push(x);       if (s ==  01 ) c.push(x);       if (s ==  00 ) d.push(x);     }     long long ans = 0;     long long x = 0, y = 0, z = 0;     ;     while (!a.empty()) {       ans += a.top();       x++;       y++;       a.pop();       z++;     }     while (!b.empty() && !c.empty()) {       ans += b.top();       ans += c.top();       x++;       y++;       z += 2;       b.pop();       c.pop();     }     long long p = 2 * x - z;     if (b.empty() == true) {       while (!c.empty()) {         d.push(c.top());         c.pop();       }     } else {       while (!b.empty()) {         d.push(b.top());         b.pop();       }     }     while (p > 0 && !d.empty()) {       p--;       ans += d.top();       d.pop();     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxx = 1000 + 50;   long long DP[maxx];   int main() {     int n, m;     cin >> n >> m;     int t = abs(n - m);     DP[1] = 1;     DP[2] = 3;     for (int i = 3; i <= 1000; i++) DP[i] = DP[i - 1] + i;     int ans = 0;     ans = 2 * DP[(t / 2)];     if (t % 2 == 1) ans += (t / 2) + 1;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f, maxn = 10;   int Pow(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = (long long)ans * a % 1000000007;       a = (long long)a * a % 1000000007;       b >>= 1;     }     return ans;   }   int main() {     int n, k;     while (~scanf( %d%d , &n, &k)) {       int ans = (long long)Pow(k, k - 1) * Pow(n - k, n - k) % 1000000007;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long powmod(long long p, long long n) {     if (n == 0) return 1;     if (n % 2 == 1) return (p * powmod(p, n - 1)) % 1000000007;     long long z = powmod(p, n / 2);     return (z * z) % 1000000007;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long x, n;     cin >> x >> n;     set<long long> P;     for (long long i = 2; i < 100000 && x > 1; ++i) {       while (x % i == 0) {         P.insert(i);         x /= i;       }     }     if (x > 1) P.insert(x);     long long ans = 1;     for (long long p : P) {       long long a = 0;       long long b = n;       while (b) {         b /= p;         a += b;         a %= (1000000007 - 1);       }       ans *= powmod(p, a);       ans %= 1000000007;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, n, m;   long long a[1 << 20], b[1 << 20];   int g[21][100001];   void FWT(long long *P, int opt) {     for (int i = 2; i <= N; i <<= 1)       for (int p = i >> 1, j = 0; j < N; j += i)         for (int k = j; k < j + p; ++k) {           long long x = P[k], y = P[k + p];           P[k] = x + y;           P[k + p] = x - y;           if (opt == -1) P[k] /= 2, P[k + p] /= 2;         }   }   int main() {     cin >> n >> m;     N = 1 << n;     char ch[100001];     for (int i = 1; i <= n; ++i) {       scanf( %s , ch + 1);       for (int j = 1; j <= m; ++j) g[i][j] = ch[j] - 48;     }     for (int i = 1; i <= m; ++i) {       int x = 0;       for (int j = 1; j <= n; ++j) x = (x << 1) | g[j][i];       a[x]++;     }     for (int i = 0; i < N; ++i) b[i] = b[i >> 1] + (i & 1);     for (int i = 0; i < N; ++i) b[i] = min(b[i], n - b[i]);     FWT(a, 1);     FWT(b, 1);     for (int i = 0; i < N; ++i) a[i] *= b[i];     FWT(a, -1);     long long ans = n * m;     for (int i = 0; i < N; ++i) ans = min(ans, a[i]);     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const double eps = 1e-6;   inline long long lgput(long long a, long long b, long long mod) {     long long ret = 1;     while (b) {       if (b & 1) ret = (ret * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return (ret % mod);   }   inline long long inv(long long x, long long MOD) {     return lgput(x, MOD - 2, MOD);   }   inline bool exist(double nr) { return (nr < -eps) || (nr > eps); }   long long big_rand() { return rand() * RAND_MAX + rand(); }   map<int, int> gr[100100];   map<int, int> vec[100100];   vector<int> ap[100100];   int dad[100100];   int superdad(int a) {     if (dad[a] != a) {       dad[a] = superdad(dad[a]);     }     return dad[a];   }   void bag(int a, int b) {     for (auto &x : ap[dad[a]]) {       vec[x][dad[b]] = 1;       ap[dad[b]].push_back(x);     }     ap[dad[a]].clear();     dad[dad[a]] = dad[b];   }   void unite(int a, int b) {     superdad(a);     superdad(b);     if (dad[a] == dad[b]) {       return;     }     if (ap[dad[a]].size() < ap[dad[b]].size()) {       bag(a, b);     } else {       bag(b, a);     }   }   void edge(int x, int y, int val) {     if (gr[x][val]) {       unite(y, gr[x][val]);     }     if (gr[y][val]) {       unite(x, gr[y][val]);     }     gr[x][val] = y;     gr[y][val] = x;     superdad(x);     superdad(y);     vec[y][dad[x]] = 1;     vec[x][dad[y]] = 1;     ap[dad[x]].push_back(y);     ap[dad[y]].push_back(x);   }   bool verif(int x, int y) {     superdad(x);     superdad(y);     if (dad[x] == dad[y]) {       return 1;     }     if (vec[y][dad[x]]) {       return 1;     }     return 0;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cout << setprecision(10) << fixed;     mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());     srand(time(nullptr));     int n, m, c, q;     cin >> n >> m >> c >> q;     for (int i = 1; i <= n; i++) {       dad[i] = i;     }     for (int i = 1; i <= m; i++) {       int x, y, val;       cin >> x >> y >> val;       edge(x, y, val);     }     while (q--) {       char ch;       cin >> ch;       if (ch ==  + ) {         int x, y, val;         cin >> x >> y >> val;         edge(x, y, val);       } else {         int x, y;         cin >> x >> y;         if (verif(x, y)) {           cout <<  Yes  <<   n ;         } else {           cout <<  No  <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   pair<pair<int, int>, int> a[100100];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       a[i].first.first = x;     }     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       a[i].first.second = x;       a[i].second = i;     }     sort(a + 1, a + n + 1);     reverse(a + 1, a + n + 1);     cout << (n / 2) + 1 << endl;     cout << a[1].second <<    ;     for (int i = 2; i <= n; i += 2) {       if (i == n)         cout << a[i].second;       else {         int x = a[i].second;         if (a[i + 1].first.second > a[i].first.second) x = a[i + 1].second;         cout << x <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     cin >> a;     for (int i = 0; i < a; i++) {       long long x = 0;       long long a;       long long b;       long long k;       cin >> a >> b >> k;       if (k % 2 == 1) {         x = (a - b) * (k / 2);         x = x + a;       } else {         x = (a - b) * (k / 2);       }       cout << x << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     long long i, x;     vector<long long> v;     for (i = 0; i < n; i++) {       cin >> x;       v.push_back(x);     }     long long ans = 0;     for (long long i = 0; i < n; i++) {       long long sum = 0;       for (long long j = i; j < n; j++) {         sum += v[j];         if (sum > 100 * (j - i + 1)) ans = max(ans, j - i + 1);       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 5;   const long long mod = 998244353;   set<long long> pre, cur;   string s, mn, mx;   long long zmin[2 * N];   long long zmax[2 * N];   long long dmin[N];   long long dmax[N];   long long dp[N];   long long n;   void init() {     long long n, m, l, r;     string str;     n = s.size();     m = mn.size();     l = r = 0;     str = mn +  #  + s;     for (long long i = 1; i <= n + m; i++) {       long long &x = zmin[i];       if (i <= r) x = min(zmin[i - l], r - i);       while (i + x <= n + m && str[x] == str[i + x]) x++;       if (i + x >= r) {         l = i;         r = i + x;       }       if (i > m) dmin[i - m] = i - m + x;     }     n = s.size();     m = mx.size();     l = r = 0;     str = mx +  #  + s;     for (long long i = 1; i <= n + m; i++) {       long long &x = zmax[i];       if (i <= r) x = min(zmax[i - l], r - i);       while (i + x <= n + m && str[x] == str[i + x]) x++;       if (i + x >= r) {         l = i;         r = i + x;       }       if (i > m) dmax[i - m] = i - m + x;     }   }   bool ok(long long l, long long r) {     if (r - l + 1 > mx.size()) return false;     if (r - l + 1 == mx.size()) {       long long mid = dmax[l];       if (mid <= r && s[mid] > mx[mid - l]) return false;     }     if (r - l + 1 < mn.size()) return false;     if (r - l + 1 == mn.size()) {       long long mid = dmin[l];       if (mid <= r && s[mid] < mn[mid - l]) return false;     }     return true;   }   void add(long long &a, long long b) {     a += b;     if (a >= mod) a -= mod;   }   void sub(long long &a, long long b) {     a -= b;     if (a < 0) a += mod;   }   void solve() {     long long sum = 0;     dp[0] = 1;     for (long long i = 1; i <= n; i++) {       dp[i] = 0;       while (pre.size()) {         long long pos = *pre.begin();         if (ok(pos, i)) {           cur.insert(pos);           pre.erase(pos);           add(sum, dp[pos - 1]);         } else           break;       }       while (cur.size()) {         long long pos = *cur.begin();         if (!ok(pos, i)) {           cur.erase(pos);           sub(sum, dp[pos - 1]);         } else           break;       }       dp[i] = sum;       if (ok(i, i)) {         add(dp[i], dp[i - 1]);         if (s[i] !=  0 ) {           cur.insert(i);           add(sum, dp[i - 1]);         }       } else if (s[i] !=  0 )         pre.insert(i);     }     cout << dp[n] <<   n ;   }   void brute() {     dp[0] = 1;     for (long long i = 1; i <= n; i++) {       dp[i] = 0;       for (long long j = 0; j < i; j++) {         if (ok(j + 1, i) && !(j + 1 != i && s[j + 1] ==  0 )) add(dp[i], dp[j]);       }     }     cout << dp[n] <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> s >> mn >> mx;     init();     n = s.size();     s =     + s;     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int modularPower(long long int x, unsigned long long int y,                              long long int mod) {     long long int res = 1;     x %= mod;     while (y > 0) {       if (y & 1) res = (res * x) % mod;       y >>= 1;       x = (x * x) % mod;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cerr.tie(NULL);     cout.tie(NULL);     ;     int height;     cin >> height;     vector<int> v(height + 5);     vector<int> sum(height + 5);     int posOfChange = 0;     for (int i = 0; i <= height; ++i) {       int foo;       cin >> foo;       v[i] = foo;     }     while (posOfChange < height and            (v[posOfChange] == 1 or v[posOfChange + 1] == 1))       posOfChange++;     if (posOfChange == height) {       cout <<  perfect ;       return 0;     }     sum[0] = 1;     for (int i = 1; i < v.size(); ++i) {       sum[i] = sum[i - 1] + v[i - 1];     }     cout <<  ambiguous           <<   n ;     cout << 0 <<    ;     for (int i = 1; i <= height; ++i) {       for (int j = 0; j < v[i]; ++j) {         cout << sum[i - 1] <<    ;       }     }     cout <<   n  << 0 <<    ;     for (int i = 1; i <= height; ++i) {       if (i == posOfChange + 1) {         cout << sum[i - 1] + 1 <<    ;         for (int j = 1; j < v[i]; ++j) {           cout << sum[i - 1] <<    ;         }       } else {         for (int j = 0; j < v[i]; ++j) {           cout << sum[i - 1] <<    ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const long long infLL = 0x3f3f3f3f3f3f3f3fLL;   const int maxn = 5000 + 5;   const int mod = 1000000007;   int n, m;   int s[maxn];   int f[maxn], h[maxn];   map<pair<int, int>, int> cows;   int l[maxn], r[maxn];   int pre[maxn], suf[maxn];   int cnt[maxn][4];   void sweep() {     for (int i = (1); i <= (n); ++i) {       auto it = cows.find(pair<int, int>(s[i], ++pre[s[i]]));       if (it != cows.end()) l[it->second] = i;     }     for (int i = n; i >= 1; --i) {       auto it = cows.find(pair<int, int>(s[i], ++suf[s[i]]));       if (it != cows.end()) r[it->second] = i;     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = (1); i <= (n); ++i) scanf( %d , &s[i]);     for (int i = 0; i < (m); ++i) {       scanf( %d%d , &f[i], &h[i]);       cows[pair<int, int>(f[i], h[i])] = i;       l[i] = inf, r[i] = -inf;     }     sweep();     int X = 0, Y = 1;     for (int i = 0; i < (m); ++i)       if (r[i] > 0) ++cnt[f[i]][2];     for (int t = (1); t <= (n); ++t)       if (cnt[t][2]) ++X, Y = (long long)Y * cnt[t][2] % mod;     for (int i = 0; i < (m); ++i)       if (l[i] <= n) {         int x = 1, y = 1;         memset(cnt, 0, sizeof(cnt));         for (int j = 0; j < (m); ++j)           if (j != i) {             int mask = 0;             if (f[j] != f[i] && l[j] < l[i]) mask |= 1;             if (r[j] > l[i]) mask |= 2;             ++cnt[f[j]][mask];           }         for (int t = (1); t <= (n); ++t) {           int c = ((cnt[t][1] + cnt[t][3]) * (cnt[t][2] + cnt[t][3]) - cnt[t][3]);           if (c) {             x += 2, y = (long long)y * c % mod;             continue;           }           c = cnt[t][1] + cnt[t][2] + cnt[t][3] * 2;           if (c) ++x, y = (long long)y * c % mod;         }         if (x > X)           X = x, Y = y;         else if (x == X)           Y = (Y + y) % mod;       }     printf( %d %d n , X, Y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long a[n + 1][3];     map<long long, long long> m;     for (long long i = 1; i <= n; i++) {       cin >> a[i][0] >> a[i][1] >> a[i][2];     }     vector<pair<double, pair<long long, long long> > > v;     for (long long i = 1; i < n; i++) {       for (long long j = i + 1; j <= n; j++) {         double d =             sqrt(pow(abs(a[i][0] - a[j][0]), 2) + pow(abs(a[i][1] - a[j][1]), 2) +                  pow(abs(a[i][2] - a[j][2]), 2));         v.push_back({d, {i, j}});       }     }     sort(v.begin(), v.end());     long long c = 0;     for (long long i = 0; i < v.size(); i++) {       if (m[(v[i].second).second] == 0 && m[(v[i].second).first] == 0) {         cout << (v[i].second).second <<     << (v[i].second).first << endl;         m[(v[i].second).second]++;         m[(v[i].second).first]++;         c++;       }       if (c == n / 2) break;     }   }
#include <bits/stdc++.h>   const int maxn = 5e5 + 5;   using namespace std;   char s[maxn];   int main() {     scanf( %s , s);     int k = strlen(s);     char y = s[0];     for (int i = 0; i < k; i++) {       if (s[i] > y) {         cout <<  Ann  << endl;       } else {         y = s[i];         cout <<  Mike  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string s;   bool es[100001];   string ans;   void wk() {     int i;     cin >> n;     cin >> s;     for (i = 0; i <= n; i++) es[i] = false;     int fstone = n;     for (i = 0; i < n; i++)       if (s[i] ==  1 ) {         fstone = i;         break;       }     bool zero = false;     for (i = n - 1; i >= 0; i--) {       if (s[i] ==  0  && zero && fstone < i) es[i] = true;       if (s[i] ==  1  && zero) es[i] = true;       if (s[i] ==  0 ) zero = true;     }     ans =   ;     for (i = 0; i < n; i++)       if (!es[i]) ans += s[i];     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     int i;     cin >> t;     for (i = 1; i <= t; i++) wk();     return 0;   }
#include <bits/stdc++.h>   const char nl =   n ;   const int mod = (int)1e9 + 7;   int main() {     std::cin.tie(0)->std::ios::sync_with_stdio(0);     std::cin.exceptions(std::cin.failbit);     int t;     std::cin >> t;     while (t--) {       int n;       std::string s;       std::cin >> n >> s;       int l = -1, r = -1;       for (int i = 0; i < n - 1; i++) {         if ((s[i] ==  a  && s[i + 1] ==  b ) ||             (s[i] ==  b  && s[i + 1] ==  a )) {           l = i + 1;           r = i + 2;           break;         }       }       std::cout << l <<     << r << nl;     }   }
#include <bits/stdc++.h>   using namespace std;   const bool DEBUG = false;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     bool puede = true;     int N, M;     cin >> N >> M;     unordered_set<int> conj;     vector<string> cad(N);     vector<int> index(M);     for (int i = 0; i < N; i++) {       cin >> cad[i];       conj.insert(i);     }     for (int i = 0; i < M; i++) {       cin >> index[i];       index[i]--;       conj.erase(index[i]);     }     for (int i = 0; i < M - 1; i++) {       if (cad[index[i]].size() != cad[index[i + 1]].size()) puede = false;     }     if (!puede) {       cout <<  No n ;       return 0;     }     bool band;     string patron =   ;     int sz = cad[index[0]].size();     if (DEBUG) {       cout << cad[index[0]] << endl;       cout <<  SZ:   << sz << endl;     }     for (int i = 0; i < sz; i++) {       band = true;       for (int j = 0; j < M - 1; j++) {         if (cad[index[j]][i] != cad[index[j + 1]][i]) {           patron +=  ? ;           band = false;         }         if (!band) break;       }       if (band) patron += cad[index[0]][i];     }     for (auto &it : conj) {       band = true;       if (cad[it].size() != patron.size()) continue;       for (int i = 0; i < patron.size(); i++) {         if (patron[i] ==  ? ) continue;         if (patron[i] == cad[it][i]) continue;         band = false;         break;       }       if (band) {         cout <<  No n ;         return 0;       }     }     cout <<  Yes n  << patron <<   n ;     return 0;   }