malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long n, tim;   string st;   long lpos, calc1, calc2;   long need, ans, calc;   long l, r, has, bad;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> tim;     cin >> st;     lpos = -1;     for (int i = 0; i < st.size(); i++) {       if (st[i] ==  H ) ++calc1;       if (st[i] ==  H ) lpos = i;       if (st[i] ==  S ) ++calc2;     }     if (tim <= lpos) {       cout << -1 << endl;       return 0;     }     l = 0;     r = 1e6;     if (calc1 > calc2) l = calc1 - calc2;     while (l < r) {       long mid = l + r;       mid /= 2;       calc = 0;       has = mid;       bad = 1e9;       need = 0;       long oscore = 1e9;       long tt = mid;       long epos = 0;       for (int i = 0; i < st.size(); i++) {         if (tt < calc1) epos = i;         if (st[i] ==  S ) ++tt;       }       if (epos < lpos) epos = lpos;       for (long i = 0; i < st.size(); i++) {         ++calc;         if (bad < 1e7)           oscore = min(oscore, epos - i + calc + (epos - bad) * (bad < 1e7));         if (st[i] ==  H ) {           if (has == 0) {             bad = min(bad, i);             need++;           } else {             --has;           }         }         if (st[i] ==  S ) {           ++has;           if (has >= need && i >= lpos) {             if (need) calc += i - bad;             break;           }           if (has >= need && need > 0) {             calc += 2 * (i - bad);             bad = 1e9;             has -= need;             need = 0;           }         }         if (i >= lpos && has >= need) {           if (need) calc += i - bad;           break;         }       }       calc = min(calc, oscore);       if (calc > tim)         l = mid + 1;       else         r = mid;     }     cout << l << endl;     cin.get();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n % 2 == 0)       cout <<  NO  << endl;     else {       cout <<  YES  << endl;       cout << 1 <<    ;       for (int i = 4; i < 2 * n; i += 4) cout << i <<     << i + 1 <<    ;       for (int i = 2; i < 2 * n; i += 4) cout << i <<     << i + 1 <<    ;       cout << 2 * n << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, SF, FS;     SF = FS = 0;     string flights;     cin >> n >> flights;     for (int i = 0; i < flights.size() - 1; i++) {       if (flights[i] ==  S  && flights[i + 1] ==  F ) {         SF++;       } else if (flights[i] ==  F  && flights[i + 1] ==  S ) {         FS++;       }     }     if (SF > FS) {       cout <<  YES ;     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 100;   struct Node {     int id, w;   };   vector<int> g[maxn];   vector<Node> gg;   bool vis[maxn];   int dfs(int u) {     vis[u] = 1;     for (int i : g[u]) {       if (!vis[i]) {         return dfs(i);       }     }     return u;   }   int main(int argc, const char* argv[]) {     ios::sync_with_stdio(false);     int n, a, b;     Node tmp;     cin >> n;     for (int i = 0; i < n - 1; ++i) {       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     int t = 0;     for (int i = 1; i <= n; ++i) {       int tt = g[i].size();       tmp.id = i;       tmp.w = tt;       gg.push_back(tmp);       if (tt > 2) {         ++t;       }       if (t >= 2) {         break;       }     }     if (t >= 2) {       cout <<  No  << endl;     } else {       cout <<  Yes  << endl;       sort(gg.begin(), gg.end(), [&](Node a, Node b) { return a.w > b.w; });       if (t)         tmp = gg[0];       else         tmp = gg[n - 1];       vis[tmp.id] = 1;       cout << tmp.w << endl;       for (int i : g[tmp.id]) {         cout << tmp.id <<     << dfs(i) << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   int a[200007];   long long fac[200007];   long long inv[200007];   long long pw2[200007];   long long free_pw[200007];   long long fastpow(long long x, long long st) {     long long ret = 1;     while (st > 0) {       if ((st & 1) != 0) {         ret = (ret * x) % 998244353;         --st;       } else {         x = (x * x) % 998244353;         st >>= 1;       }     }     return ret;   }   long long get_comb(long long x, long long y) {     if (x < y) {       return 0;     }     long long ret = fac[x];     ret = (ret * inv[y]) % 998244353;     ret = (ret * inv[x - y]) % 998244353;     return ret;   }   void input() {     scanf( %I64d%I64d , &n, &k);     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);     }     a[n + 1] = a[1];     fac[0] = pw2[0] = free_pw[0] = 1;     for (int i = 1; i <= n; ++i) {       fac[i] = (fac[i - 1] * i) % 998244353;       pw2[i] = (pw2[i - 1] * 2) % 998244353;       free_pw[i] = (free_pw[i - 1] * (k - 2)) % 998244353;     }     inv[n] = fastpow(fac[n], 998244353 - 2);     for (int i = n - 1; i >= 0; --i) {       inv[i] = (inv[i + 1] * (i + 1)) % 998244353;     }   }   void solve() {     int free = 0;     long long aux = 1;     for (int i = 1; i <= n; ++i) {       if (a[i] == a[i + 1]) {         ++free, aux = (aux * k) % 998244353;       }     }     long long ans = 0;     for (int i = 0; i < n - free; ++i) {       long long w = (get_comb(n - free, i) * free_pw[i]) % 998244353;       int lft = n - free - i;       long long coef = pw2[lft];       if ((lft & 1) == 0) {         coef = (coef - get_comb(lft, lft / 2) + 998244353) % 998244353;       }       coef = (coef * inv[2]) % 998244353;       ans = (ans + (w * coef) % 998244353) % 998244353;     }     printf( %I64d n , (aux * ans) % 998244353);   }   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ans = 0;     cin >> n;     n -= 10;     if (n == 11) {       ans += 4;       n -= 11;     }     if (n == 10) {       ans = (4 * 4) - 1;       n -= 10;     }     for (int i = 9; i >= 1; --i) {       if (n == i) {         ans += 4;         n -= i;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dist[5001][5001];   double x[5001], y[5001], z[5001];   int n;   double sqr(double x) { return x * x; }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> z[i];     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         dist[i][j] = sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]) + sqr(z[i] - z[j]));         dist[j][i] = dist[i][j];       }     }     double distance = 100000;     for (int i = 2; i <= n; i++) {       double minn = 100000;       for (int j = 2; j <= n; j++) {         if (i != j) {           if (dist[1][j] + dist[j][i] < minn) minn = dist[1][j] + dist[j][i];         }       }       if (dist[1][i] + (minn - dist[1][i]) / 2 < distance)         distance = dist[1][i] + (minn - dist[1][i]) / 2;     }     cout.precision(20);     cout << distance;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int n, m;     cin >> n >> m;     string s, t;     cin >> s >> t;     int mincnt = n + 1;     int nin = -1;     for (int i = 0; i <= m - n; i++) {       int cnt = 0;       for (int j = 0; j < n; j++) {         if (s[j] != t[i + j]) cnt++;       }       if (mincnt > cnt) {         mincnt = cnt;         nin = i;       }     }     vector<long long> a;     int i = nin;     for (int k = i; k <= n + i - 1; k++)       if (s[k - i] != t[k]) a.push_back(k - i);     cout << a.size() <<   n ;     for (int i = 0; i < mincnt; i++) cout << a[i] + 1 <<    ;   }
#include <bits/stdc++.h>   int days(int y) {     if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) {       return 366;     } else {       return 365;     }   }   int main() {     int year, i, d, di, dii;     unsigned long long int count = 0;     scanf( %d , &year);     d = days(year);     di = d;     for (i = year;; i++) {       dii = days(i + 1);       count += di;       if (count % 7 == 0 && d == dii) {         printf( %d n , i + 1);         return 0;       }       di = dii;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int ar[n], a, b, sum = 0;     for (int i = 0; i < n - 1; i++) cin >> ar[i];     cin >> a >> b;     a--;     b--;     for (int i = a; i < b; i++) sum += ar[i];     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1 << 28;   const double INF = 1e12, EPS = 1e-9;   int n, m, c[101];   void run() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       for (; a <= b; a++) c[a]++;     }     for (int i = 1; i <= n; i++)       if (c[i] != 1) {         cout << i <<     << c[i] << endl;         return;       }     cout <<  OK  << endl;   }   int main() { run(); }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[1501];   int calcinv() {     int j;     int rez = 0;     for (int i = 1; i <= n; i++)       for (j = i + 1; j <= n; j++)         if (a[i] > a[j]) rez++;     return rez;   }   int main() {     int i, nri, j, m, l, r, lg;     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     nri = calcinv() % 2;     cin >> m;     for (i = 1; i <= m; i++) {       cin >> l >> r;       lg = r - l;       lg = lg * (lg + 1) / 2;       nri = (nri + lg) % 2;       if (nri == 0)         cout <<  even ;       else         cout <<  odd ;       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   void swap(int &a, int &b) {     int temp = a;     a = b;     b = temp;   }   int main() {     int n;     cin >> n;     int x[n], y[n], min_x = INT_MAX, max_y = INT_MIN;     for (int i = 0; i < n; i++) {       cin >> x[i] >> y[i];       if (x[i] < min_x) min_x = x[i];       if (y[i] > max_y) max_y = y[i];     }     int k = 0, res = -1;     while (k < n) {       if (x[k] == min_x) {         if (y[k] == max_y) {           res = k + 1;           break;         }       }       k++;     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   char s[1000010], t[1000010];   int ls, lt;   int sum[1000010][3][3];   int main() {     scanf( %s%s , s + 1, t + 1);     ls = strlen(s + 1);     lt = strlen(t + 1);     if (ls > lt) {       swap(ls, lt);       swap(s, t);     }     for (int i = 1; i <= ls; ++i) {       if (s[i] ==  R ) s[i] = 0;       if (s[i] ==  G ) s[i] = 1;       if (s[i] ==  B ) s[i] = 2;     }     for (int i = 1; i <= lt; ++i) {       if (t[i] ==  R ) t[i] = 0;       if (t[i] ==  G ) t[i] = 1;       if (t[i] ==  B ) t[i] = 2;     }     long long ans = 0;     int l = 1, r = 1;     while (r < lt && t[r] != s[1]) {       ++r;       for (int j1 = 0; j1 < 3; ++j1)         for (int j2 = 0; j2 < 3; ++j2) sum[r][j1][j2] = sum[r - 1][j1][j2];       ++sum[r][t[r - 1]][t[r]];     }     for (int i = 1; i <= ls; ++i) {       while (r < lt && t[r] != s[i]) {         ++r;         for (int j1 = 0; j1 < 3; ++j1)           for (int j2 = 0; j2 < 3; ++j2) sum[r][j1][j2] = sum[r - 1][j1][j2];         ++sum[r][t[r - 1]][t[r]];       }       ans += r - l + 1;       if (s[i] != s[i - 1])         ans -= sum[r][s[i]][s[i - 1]] - sum[l - 1][s[i]][s[i - 1]];       if (s[i] == t[l]) ++l;       if (r < lt) {         ++r;         for (int j1 = 0; j1 < 3; ++j1)           for (int j2 = 0; j2 < 3; ++j2) sum[r][j1][j2] = sum[r - 1][j1][j2];         ++sum[r][t[r - 1]][t[r]];       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   void no() {     cout <<  NO n ;     exit(0);   }   int main() {     int n;     cin >> n;     vector<int> arr(n);     for (int i = 0; i < n; ++i) cin >> arr[i];     sort(arr.begin(), arr.end());     for (int i = n - 1; i >= 0; --i) {       arr[i] -= arr[0];       if (arr[i] >= n) no();     }     vector<int> cnt(n);     for (int i = 0; i < n; ++i) cnt[arr[i]]++;     int mx = arr[n - 1];     for (int i = 1; i < mx; ++i) {       if (cnt[i] < 2) no();       cnt[i] -= 2;     }     cnt[0]--;     cnt[mx]--;     for (int i = 0; i <= mx; ++i) {       while (cnt[i] > 0) {         if (cnt[i + 1] == 0) no();         cnt[i]--;         cnt[i + 1]--;       }     }     cout <<  YES n ;   }
#include <bits/stdc++.h>   using namespace std;   const int B = 12;   const int D = 64;   const int MASK = 1030;   int q, b;   long long f[B][D][MASK];   long long sum[B][D];   long long call(int base, int rem, int mask) {     if (rem <= 0) return mask == 0;     long long &ret = f[base][rem][mask];     if (ret != -1) return ret;     ret = 0;     for (int i = 0; i < base; ++i) {       ret += call(base, rem - 1, mask ^ 1 << i);     }     return ret;   }   long long solve(long long x) {     if (x == 0) return 0;     vector<int> v;     while (x) {       v.push_back(x % b);       x /= b;     }     reverse(v.begin(), v.end());     int mask = 0, sz = v.size();     long long ans = 0;     for (int i = 0; i < sz; ++i) {       mask ^= 1 << v[i];       if (i + 1 < sz) {         for (int j = 0; j < v[i + 1]; ++j) {           ans += call(b, sz - 2 - i, mask ^ 1 << j);         }       } else {         ans += (mask == 0);       }     }     for (int i = 1; i < v[0]; ++i) {       ans += call(b, sz - 1, 1 << i);     }     for (int i = 1; i < sz; ++i) {       for (int j = 1; j < b; ++j) {         ans += call(b, sz - 1 - i, 1 << j);       }     }     return ans;   }   int main() {     memset(f, -1, sizeof f);     memset(sum, -1, sizeof sum);     scanf( %d , &q);     while (q--) {       long long l, r;       scanf( %d %lld %lld , &b, &l, &r);       printf( %lld n , solve(r) - solve(l - 1));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, a, b, c, result = 0, i, x, y, j = 0;     cin >> n >> a >> b >> c;     for (i = 0; i <= min(n, a / 2); i++) {       x = min(c, (n - i) / 2);       y = min(i + b, n);       if (y - (n - x * 2) / 2 >= 0) {         if (y >= n - x * 2) result += (y - (n - x * 2)) / 2 + 1;       }     }     cout << result;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T BM(T p, T e, T M) {     long long int ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % M;       p = (p * p) % M;     }     return (T)ret;   }   template <class T>   inline T gcd(T a, T b) {     if (b == 0) return a;     return gcd(b, a % b);   }   template <class T>   inline T mdINV(T a, T M) {     return BM(a, M - 2, M);   }   template <class T>   inline T PW(T p, T e) {     long long int ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p);       p = (p * p);     }     return (T)ret;   }   template <class T>   string NTS(T Number) {     stringstream ss;     ss << Number;     return ss.str();   }   template <class T>   T stringtonumber(const string &Text) {     istringstream ss(Text);     T result;     return ss >> result ? result : 0;   }   template <class T>   bool ISLEFT(T a, T b, T c) {     if (((a.first.first - b.first.first) * (b.second.second - c.second.second) -          (b.first.first - c.first.first) * (a.second.second - b.second.second)) <         0.0)       return 1;     else       return 0;   }   int n, k;   vector<int> v[300ll + 2];   long long int dp[102][44];   void go(int u, int p) {     dp[u][0] = 1;     dp[u][k + 1] = 1;     for (int i = 0; i < v[u].size(); i++) {       int first = v[u][i];       if (first == p) continue;       go(first, u);       long long int kop[44];       memset(kop, 0, sizeof kop);       for (int j = 0; j <= k * 2; j++) {         for (int l = 0; l <= k * 2; l++) {           if (j + l <= k * 2) {             kop[min(j, l + 1)] =                 (kop[min(j, l + 1)] + dp[u][j] * dp[first][l]) % 1000000007;           } else {             kop[max(j, l + 1)] =                 (kop[max(j, l + 1)] + dp[u][j] * dp[first][l]) % 1000000007;           }         }       }       for (int j = 0; j <= k * 2; j++) dp[u][j] = kop[j];     }   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n - 1; i++) {       int first, second;       scanf( %d%d , &first, &second);       v[first].push_back(second);       v[second].push_back(first);     }     go(1, -1);     int ans = 0;     for (int i = 0; i <= k; i++) {       ans += dp[1][i];       if (ans >= 1000000007) ans -= 1000000007;     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cf[45], nc[45];   vector<int> ppf[45];   bool canadd(int i, int m) {     for (int p : ppf[m]) {       if (nc[p] && cf[p] != i % p) return false;     }     return true;   }   void add(int i, int m) {     for (int p : ppf[m]) {       if (nc[p] == 0) cf[p] = i % p;       nc[p]++;     }   }   void rem(int m) {     for (int p : ppf[m]) {       nc[p]--;     }   }   vector<pair<int, int> > loc[100005];   int k[100005];   int n, m;   int main() {     for (int i = (2); i < (45); i++) {       int x = i;       for (int j = (2); j < (45); j++) {         int fct = 1;         while (x % j == 0) {           fct *= j;           ppf[i].push_back(fct);           x /= j;         }       }     }     scanf( %d %d , &n, &m);     for (int i = (0); i < (n); i++) {       scanf( %d , k + i);       for (int j = (0); j < (k[i]); j++) {         int x;         scanf( %d , &x);         loc[x].push_back(make_pair(i, j));       }     }     for (int x = (1); x < (m + 1); x++) {       queue<pair<int, int> > cq;       int prv = -1, ans = 0;       for (auto l : loc[x]) {         int i, j;         tie(i, j) = l;         if (i != prv + 1) {           while (int(cq.size())) {             int fi, fj;             tie(fi, fj) = cq.front();             cq.pop();             rem(k[fi]);           }         }         while (!canadd(j, k[i])) {           int fi, fj;           tie(fi, fj) = cq.front();           cq.pop();           rem(k[fi]);         }         add(j, k[i]);         cq.emplace(i, j);         prv = i;         ans = max(ans, int(cq.size()));       }       while (int(cq.size())) {         int fi, fj;         tie(fi, fj) = cq.front();         cq.pop();         rem(k[fi]);       }       printf( %d n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t, n, num;     cin >> t;     while (t--) {       cin >> n;       bool flag = false;       unordered_map<int, vector<int>> m;       for (int i = 0; i < n; ++i) {         cin >> num;         m[num].push_back(i);       }       for (auto& k : m) {         if (k.second.back() - k.second.front() >= 2) {           flag = true;           break;         }       }       if (flag)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct arr {     int i;     double s;   } e[1506];   int n, m, x[1506], y[1506], w[1506], f[1506][1506], v[1506][2];   double ans, s[1506];   inline bool cmp(arr x, arr y) { return x.s > y.s; }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++)       scanf( %d%d%d , &x[i], &y[i], &w[i]),           e[i].s = 1.0 * w[i] * w[i] * acos(-1.0), e[i].i = i;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         double t = sqrt(1.0 * (x[i] - x[j]) * (x[i] - x[j]) +                         1.0 * (y[i] - y[j]) * (y[i] - y[j]));         if (1.0 * w[i] >= 1.0 * w[j] + t) f[i][j] = 1;       }     sort(e + 1, e + n + 1, cmp);     for (int i = 1; i <= n; i++) {       if (!v[e[i].i][0]) {         ans += e[i].s;         for (int j = 1; j <= n; j++)           if (f[e[i].i][j]) v[j][0] = 1;       } else if (!v[e[i].i][1]) {         ans += e[i].s;         for (int j = 1; j <= n; j++)           if (f[e[i].i][j]) v[j][1] = 1;       } else {         ans -= e[i].s;         for (int j = 1; j <= n; j++)           if (f[e[i].i][j]) v[j][0] = 0;       }     }     printf( %.12lf n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 61 * 30 + 5;   pair<int, int> C[62];   int M, A[32], cc;   bool dp[32][62][maxn], D[62][62];   short int fr[32][62][maxn];   int main() {     scanf( %d , &M);     for (int i = 1; i <= M; ++i) scanf( %d , A + i);     sort(A + 1, A + M + 1);     dp[0][0][0] = true;     for (int i = 1; i <= M; ++i)       for (int j = i; j <= 61; ++j)         for (int k = (j * (j - 1)) >> 1; k < maxn; ++k) {           for (int m = 1; m <= j; ++m)             if (k >= m * A[i] && dp[i - 1][j - m][k - m * A[i]]) {               dp[i][j][k] = true;               fr[i][j][k] = m;               break;             }         }     int N = M;     while (!dp[M][N][(N * (N - 1)) >> 1]) ++N;     printf( %d n , N);     for (int i = M, j = N, k = (N * (N - 1)) >> 1; i; --i) {       int c = fr[i][j][k];       j -= c;       k -= c * A[i];       for (int j = 0; j < c; ++j) {         ++cc;         C[cc] = make_pair(A[i], cc);       }     }     for (int i = 1; i <= N; ++i) {       sort(C + 1, C + cc + 1);       for (int j = i + 1; j <= i + C[i].first; ++j)         D[C[i].second][C[j].second] = true;       for (int j = i + C[i].first + 1; j <= N; ++j)         D[C[j].second][C[i].second] = true, --C[j].first;       C[i].first = -1;     }     for (int i = 1; i <= N; ++i) {       for (int j = 1; j <= N; ++j) printf( %d , D[i][j] ? 1 : 0);       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   const char *par =  () ;   const int pm[] = {1, -1};   int n;   int mn, res, fir;   string s;   vector<int> v, w;   map<int, int> mp;   int init(string s) {     v = vector<int>(n);     for (int i = 0, pre = 0; i < n; ++i) {       v[i] = (pre += pm[strchr(par, s[i]) - par]);       mp[v[i]]++;     }     if (v.back() != 0) return 0;     res = mp.begin()->second;     mn = mp.begin()->first;     for (int i = 0; i < n; ++i)       if (v[i] == mn) {         fir = (i + 1) % n;         return res;       }   }   int count(int l, int r) {     int cur = v[(l - 1 + n) % n];     s[l] =  ) ;     for (int i = l; i != r; i = (i + 1) % n) {       cur += pm[strchr(par, s[i]) - par];       if (!--mp[v[i]]) mp.erase(v[i]);       mp[cur]++;     }     int ret = mp.begin()->second;     cur = v[(l - 1 + n) % n];     for (int i = l; i != r; i = (i + 1) % n) {       cur += pm[strchr(par, s[i]) - par];       if (!--mp[cur]) mp.erase(cur);       mp[v[i]]++;     }     s[l] =  ( ;     return ret;   }   int main() {     cin >> n >> s;     if (!init(s)) {       cout <<  0 n1 1 n ;       return 0;     }     stack<int> st;     int i = fir;     w = vector<int>(n);     do {       if (s[i] ==  ( ) st.push(i);       if (s[i] ==  ) ) {         w[i] = st.top();         w[w[i]] = i;         st.pop();       }     } while ((i = (i + 1) % n) != fir);     int ans[3] = {res};     for (int i = 0; i < n; ++i)       if (s[i] ==  (  && v[i] <= mn + 2) {         int ret = count(i, w[i]);         if (ret > ans[0]) ans[0] = ret, ans[1] = i, ans[2] = w[i];       }     cout << ans[0] << endl << ans[1] + 1 <<     << ans[2] + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline bool cmp(const pair<int, int> &a, const pair<int, int> &b) {     if (a.first != b.first) return a.first > b.first;     return a.second < b.second;   }   int a[1000005], b[1000005];   char s[1000005], r[1000005];   int test;   int main() {     int t, n, m, k, l, x, y, z, flag = 0, count, d, mx, mn;     long long int sum, prod;     scanf( %s%s , s, r);     count = sum = 0;     n = strlen(s), m = strlen(r);     int j = 0;     for (int i = 0; i < m; i++) {       if (r[i] == s[j]) j++;       if (j == n) break;     }     printf( %d , j + 1);     return 0;   }