malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   #pragma GCC diagnostic ignored  -Wmissing-declarations    inline int safe_mul(const int x, const int y)       __attribute__((warn_unused_result));   int const mod = 998244353;   inline int safe_mul(const int x, const int y) {     return x * static_cast<long long>(y) % mod;   }   inline void safe_add(int& x, const int y) {     x += y;     if (x >= mod) x -= mod;   }   inline int safe_pow(int x, int y) {     int res = 1;     for (; y > 0; y >>= 1) {       if (y & 1) res = safe_mul(x, res);       x = safe_mul(x, x);     }     return res;   }   const int root_pw = 1 << 21;   int root;   int root_1;   void fft(vector<int>& a, bool invert) {     int n = (int)a.size();     for (int i = 1, j = 0; i < n; ++i) {       int bit = n >> 1;       for (; j >= bit; bit >>= 1) j -= bit;       j += bit;       if (i < j) swap(a[i], a[j]);     }     for (int len = 2; len <= n; len <<= 1) {       int wlen = invert ? root_1 : root;       for (int i = len; i < root_pw; i <<= 1) wlen = safe_mul(wlen, wlen);       for (int i = 0; i < n; i += len) {         int w = 1;         for (int j = 0; j < len / 2; ++j) {           int u = a[i + j], v = safe_mul(a[i + j + len / 2], w);           a[i + j] = u + v < mod ? u + v : u + v - mod;           a[i + j + len / 2] = u - v >= 0 ? u - v : u - v + mod;           w = safe_mul(w, wlen);         }       }     }     if (invert) {       int nrev = safe_pow(n, mod - 2);       for (int i = 0; i < n; ++i) a[i] = safe_mul(a[i], nrev);     }   }   int need;   vector<int> multiply(vector<int> a, vector<int> b) {     size_t n = 1;     while (n < max(a.size(), b.size())) n <<= 1;     n <<= 1;     a.resize(n, 0), b.resize(n, 0);     fft(a, false), fft(b, false);     for (size_t i = 0; i < n; ++i) a[i] = safe_mul(a[i], b[i]);     fft(a, true);     while (!a.empty() && (a.back() == 0 || a.size() > need + 1)) a.pop_back();     return a;   }   int solve(map<int, int> primes) {     auto comp = [](const vector<int>& l, const vector<int>& r) {       return l.size() < r.size();     };     multiset<vector<int>, decltype(comp)> polys(comp);     for (auto pa : primes) polys.insert(vector<int>(pa.second + 1, 1));     while (polys.size() > 1) {       auto vec = multiply(*polys.begin(), *next(polys.begin()));       polys.erase(polys.begin());       polys.erase(polys.begin());       polys.insert(move(vec));     }     return polys.begin()->operator[](need);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     for (int i = 1; i < mod; ++i) {       if (safe_pow(i, root_pw) == 1 && safe_pow(i, root_pw >> 1) != 1) {         root = i;         root_1 = safe_pow(root, mod - 2);         break;       }     }     int n;     cin >> n;     need = n / 2;     map<int, int> cnt;     while (n--) {       int p;       cin >> p;       ++cnt[p];     }     cout << solve(cnt) << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool isprime(int n) {     if (n < 2) return false;     for (int i = 2; i * i <= n; i++)       if (n % i == 0) return false;     return true;   }   int main() {     int n;     cin >> n;     if (isprime(n))       cout <<  1  << endl;     else if (n % 2 == 0)       cout <<  2  << endl;     else if (isprime(n - 2))       cout <<  2  << endl;     else       cout <<  3  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mmax, sum, n, t;   int main() {     cin >> n;     sum = 0;     mmax = 0;     for (int i = 0; i < n; i++) {       cin >> t;       sum += t;       mmax = max(t, mmax);     }     cout << mmax - (sum - mmax) + 1;   }
#include <bits/stdc++.h>   using namespace std;   long long int fact[2000005], ifact[2000005];   long long int ppow(long long int b, int p) {     long long int ret = 1;     for (; p; p /= 2) {       if (p & 1) ret = (ret * b) % 1000000007;       b = (b * b) % 1000000007;     }     return ret;   }   void init_fact() {     fact[0] = 1;     for (int i = 1; i < 2000005; i++) fact[i] = (fact[i - 1] * i) % 1000000007;     ifact[2000005 - 1] = ppow(fact[2000005 - 1], 1000000007 - 2);     for (int i = 2000005 - 2; i >= 0; i--)       ifact[i] = (ifact[i + 1] * (i + 1)) % 1000000007;   }   int main() {     init_fact();     int n, m, g;     scanf( %d%d%d , &n, &m, &g);     long long int ans = 0;     if (n == 0) {       if (m == 1 and g == 1)         ans = 1;       else if (m > 1 and g == 0)         ans = 1;     } else if (m == 0) {       if (n == 1 and g == 0)         ans = 1;       else if (n > 1) {         if (n % 2 == 0 and g == 1)           ans = 1;         else if (n % 2 == 1 and g == 0)           ans = 1;       }     } else {       for (int start = 1; start <= n + 1; start++) {         if (start == n + 1 and m == 1) {           if (g == 0 and (n + m) % 2 == 0)             ans++;           else if (g == 1 and (n + m) % 2 == 1)             ans++;           continue;         }         if ((start + g) & 1) {           long long int val = fact[m - 1 + n - start + 1];           val = (val * ifact[m - 1]) % 1000000007;           val = (val * ifact[n - start + 1]) % 1000000007;           ans = (ans + val) % 1000000007;         }       }     }     cout << ans % 1000000007 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   long long power(long long a, long long b) {     if (b == 0)       return 1;     else if (b == 1) {       return a;     } else if (b & 1) {       return (a % mod * power((a % mod * a % mod) % mod, b / 2)) % mod;     } else {       return (power((a % mod * a % mod) % mod, b / 2)) % mod;     }   }   void solve() {     int n, m, a, b;     cin >> n >> m;     vector<int> adj[n + 1];     vector<int> deg(n + 1, 0), ans, dis(n + 1, 0), odd, even;     for (long long i = 0; i < m; i++) {       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);       deg[a]++;       deg[b]++;     }     queue<pair<int, int> > q;     vector<bool> vis(n + 1, false);     q.push({1, 0});     vis[1] = 1;     while (!q.empty()) {       auto it = q.front();       q.pop();       dis[it.first] = it.second;       for (int j : adj[it.first]) {         if (!vis[j]) {           vis[j] = 1;           q.push({j, dis[it.first] + 1});         }       }     }     for (int i = 1; i <= n; i++) {       if (dis[i] & 1) {         odd.push_back(i);       } else {         even.push_back(i);       }     }     if (odd.size() > even.size()) {       cout << even.size() << endl;       for (int i = 0; i < even.size(); i++) {         cout << even[i] <<    ;       }       cout << endl;     } else {       cout << odd.size() << endl;       for (int i = 0; i < odd.size(); i++) {         cout << odd[i] <<    ;       }       cout << endl;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100000;   int a, b, m, n, C[MAXN], I[MAXN];   queue<int> Q;   vector<int> A, B, E[MAXN];   int main() {     cin >> n >> m;     while (m--) {       cin >> a >> b;       --a;       --b;       E[a].push_back(b);       E[b].push_back(a);       I[a] = I[b] = 1;     }     for (int i = 0; i < n; ++i) {       C[i] = -1;     }     for (int i = 0; i < n; ++i) {       if (C[i] > -1 || !I[i]) {         continue;       }       C[i] = 1;       Q.push(i);       while (!Q.empty()) {         a = Q.front();         Q.pop();         for (auto j : E[a]) {           if (C[j] == -1) {             C[j] = !C[a];             Q.push(j);           } else if (C[j] == C[a]) {             cout << -1 << endl;             return 0;           }         }       }     }     for (int i = 0; i < n; ++i) {       if (C[i] == 0) {         A.push_back(i);       } else if (C[i] == 1) {         B.push_back(i);       }     }     cout << A.size() << endl;     for (auto i : A) {       cout << i + 1 <<    ;     }     cout << endl;     cout << B.size() << endl;     for (auto i : B) {       cout << i + 1 <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e7 + 5;   const int maxm = 2e5 + 5;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const double eps = 1e-9;   const double pi = acos(-1);   int m, n, w, k;   void init() {}   bool judge(int now) {}   long long quickpow(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % mod;       a = a * a % mod;       b >>= 1;     }     return ans;   }   char c[1005];   int main() {     int t;     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       scanf( %s , c);       int first = -1, second = -1;       for (int i = 0; i < n; i++)         if (c[i] ==  1 ) {           first = i + 1;           break;         }       for (int i = n - 1; i >= 0; i--)         if (c[i] ==  1 ) {           second = i + 1;           break;         }       if (first == -1)         printf( %d n , n);       else         printf( %d n , 2 * max(second, n - first + 1));     }   }
#include <bits/stdc++.h>   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;   }   using namespace std;   const int MAXN = 2e5 + 100;   const int MOD = 1e9 + 7;   const double eps = 1e-12;   const long long INF = 1e16;   inline string toStr(long long x) {     string tmp =   ;     do tmp = char(x % 10 +  0 ) + tmp;     while (x /= 10);     return tmp;   }   inline long long toInt(string s) {     long long res = 0;     for (auto x : s) res = res * 10 + x -  0 ;     return res;   }   int main() {     int n, x, mmax = 0;     cin >> n;     for (int i = 0, _a = (n); i < _a; ++i) cin >> x, mmax = max(mmax, x);     cout << (mmax ^ x);   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)(1e6);   char S[N + 1], T[N + 1];   vector<int> multiply(vector<int> a, vector<int> b) {     int n = (int)a.size();     vector<int> ret;     for (int i = 0; i < n; i++) ret.push_back(a[b[i]]);     return ret;   }   vector<int> pow(vector<int> a, int b) {     int n = (int)a.size();     vector<int> ret;     if (b == 0) {       for (int i = 0; i < n; i++) ret.push_back(i);       return ret;     }     if (b % 2 == 1) return multiply(pow(a, b - 1), a);     ret = pow(a, b / 2);     return multiply(ret, ret);   }   void solve(int k, int d, int n) {     vector<int> P, vet, ret;     for (int i = 0; i < d; i++)       for (int j = i; j < k; j += d)         if (j > 0) P.push_back(j);     P.push_back(0);     for (int i = 0; i < k; i++) vet.push_back(i);     for (int i = 0, x = 0; i + k <= n; i++) {       ret.push_back(vet[x]);       vet[x] = i + k;       x = P[x];     }     vector<int> aux = pow(P, n - k + 1);     for (int i = 0; i < k - 1; i++) ret.push_back(vet[aux[i]]);     for (int i = 0; i < n; i++) T[i] = S[i];     for (int i = 0; i < n; i++) S[i] = T[ret[i]];     printf( %s n , S);   }   int main() {     scanf( %s , S);     int t;     scanf( %d , &t);     while (t-- > 0) {       int k, d;       scanf( %d %d , &k, &d);       solve(k, d, strlen(S));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (a > b) swap(a, b);     if (a == 0) return b;     return gcd(b % a, a);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t, i;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long arr[n];       for (i = 0; i < n; i++) {         cin >> arr[i];       }       long long sum = 0;       for (i = 0; i < n; i++) {         if (i % 2 && arr[i] > 0)           arr[i] *= -1;         else if (i % 2 == 0 && arr[i] < 0)           arr[i] *= -1;       }       for (i = 0; i < n; i++) {         cout << arr[i] <<    ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cas = 1;   long long dxx[] = {-1, -1, -1, 0, 0, 1, 1, 1};   long long dyy[] = {-1, 0, 1, -1, 1, -1, 0, 1};   long long dx[] = {-1, 0, 0, 1};   long long dy[] = {0, -1, 1, 0};   struct info {     long long mi, pro, cnt;   } tre[100005 * 3];   long long ai[100005], ans = 0;   void update(long long n, long long be, long long en, long long i, long long j,               long long v) {     if (i > en || j < be) return;     if (be >= i && en <= j) {       tre[n].cnt++;       tre[n].pro += v + (be - i);       return;     }     long long m, l, r;     m = (be + en) / 2;     l = n * 2;     r = l + 1;     if (tre[n].pro >= 1) {       tre[l].pro += tre[n].pro;       tre[l].cnt += tre[n].cnt;       tre[r].pro += tre[n].pro + tre[n].cnt * ((m + 1 - be));       tre[r].cnt += tre[n].cnt;       tre[n].pro = 0;       tre[n].cnt = 0;     }     update(l, be, m, i, j, v);     update(r, m + 1, en, i, j, v);   }   long long query(long long n, long long be, long long en, long long i) {     if (ans != -1) return ans;     if (be == i && en == i) {       tre[n].cnt++;       ans = tre[n].pro;       return tre[n].pro;     }     long long m, l, r;     m = (be + en) / 2;     l = n * 2;     r = l + 1;     long long a, b;     if (tre[n].pro >= 1) {       tre[l].pro += tre[n].pro;       tre[l].cnt += tre[n].cnt;       tre[r].pro += tre[n].pro + tre[n].cnt * ((m - be + 1));       tre[r].cnt += tre[n].cnt;       tre[n].pro = 0;       tre[n].cnt = 0;     }     if (be <= i && m >= i) return query(l, be, m, i);     return query(r, m + 1, en, i);   }   int main() {     memset(tre, 0, sizeof(tre));     long long n, m, q, i, k, j, v;     scanf( %lld%lld%lld , &n, &m, &q);     for (k = 0; k < m; k++) {       scanf( %lld%lld%lld , &i, &j, &v);       update(1, 1, n, i, j, v);     }     long long a1 = 0;     for (i = 1; i <= q; i++) {       scanf( %d , &k);       ans = -1;       ans = query(1, 1, n, k);       a1 += ans;     }     printf( %lld n , a1);   }
#include <bits/stdc++.h>   using namespace std;   int *a = new int[2000000];   int m, n;   void add(int x, int l);   void sub(int x, int l);   int query(int x, int y, int x0, int y0, int t);   int main() {     int h, i, j, dir = 1, r, l, o, x, y, len, mid;     cin >> n >> m;     for (i = 0; i < 2000000; i++) a[i] = 0;     for (i = 1; i <= n; i++) add(i, 1);     l = 1;     r = n;     for (i = 0; i < m; i++) {       cin >> o;       if (o == 2) {         cin >> x >> y;         x++;         if (dir == 1) {           x += l - 1;           y += l - 1;           cout << query(1, n, x, y, 1) << endl;         } else if (dir == 2) {           x = r - x + 1;           y = r - y + 1;           cout << query(1, n, y, x, 1) << endl;         }       } else {         cin >> len;         if (len <= (r - l + 1) / 2) {           if (dir == 1) {             mid = l + len;             for (j = 1; j <= len; j++) {               x = mid - j;               y = mid + j - 1;               h = query(1, n, x, x, 1);               add(y, h);             }             l += len;           } else if (dir == 2) {             mid = r - len;             for (j = 1; j <= len; j++) {               x = mid + j;               y = mid - j + 1;               h = query(1, n, x, x, 1);               add(y, h);             }             r -= len;           }         } else {           len = r - l + 1 - len;           if (dir == 2) {             mid = l + len;             for (j = 1; j <= len; j++) {               x = mid - j;               y = mid + j - 1;               h = query(1, n, x, x, 1);               add(y, h);             }             l += len;           } else if (dir == 1) {             mid = r - len;             for (j = 1; j <= len; j++) {               x = mid + j;               y = mid - j + 1;               h = query(1, n, x, x, 1);               add(y, h);             }             r -= len;           }           if (dir == 1)             dir = 2;           else             dir = 1;         }       }     }     delete[] a;     return 0;   }   void add(int x0, int l) {     int x = 1, y = n, mid, t = 1;     while (1) {       a[t] += l;       mid = (x + y) / 2;       if (x == y) break;       if (x0 <= mid) {         y = mid;         t = t * 2;       } else {         x = mid + 1;         t = t * 2 + 1;       }     }   }   void sub(int x0, int l) {     int x = 1, y = n, mid, t = 1;     while (1) {       a[t] -= l;       mid = (x + y) / 2;       if (x == y) break;       if (x0 <= mid) {         y = mid;         t = t * 2;       } else {         x = mid + 1;         t = t * 2 + 1;       }     }   }   int query(int x, int y, int x0, int y0, int t) {     int mid;     if (y0 < x) return 0;     if (y < x0) return 0;     if (x0 <= x && y <= y0) {       return a[t];     }     mid = (x + y) / 2;     return query(x, mid, x0, y0, t * 2) + query(mid + 1, y, x0, y0, t * 2 + 1);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     const int MAX_N = 100001;     int n, x;     vector<long long int> dp(MAX_N, 0);     vector<long long int> c(MAX_N, 0);     cin >> n;     while (n--) {       cin >> x;       c[x]++;     }     dp[0] = 0;     dp[1] = c[1];     for (int i = 2; i < MAX_N; i++) {       dp[i] = max(dp[i - 1], dp[i - 2] + i * c[i]);     }     cout << dp[MAX_N - 1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     int rem = a % b;     while (rem != 0) {       a = b;       b = rem;       rem = a % b;     }     return b;   }   int main() {     int a, b, c, d;     cin >> a >> b >> c >> d;     int mul1 = 0, mul2 = 0;     int res1 = 0, res2 = 0;     int ans = 0;     mul1 = a * d;     mul2 = c * b;     if (mul1 <= mul2) {       res1 = mul2 - mul1;       res2 = mul2;     } else {       res1 = mul1 - mul2;       res2 = mul1;     }     ans = gcd(res1, res2);     if (gcd((res1 / ans), (res2 / ans)) == 1) {       cout << (res1 / ans) <<  /  << (res2 / ans) << endl;     } else {       return -1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     cin >> t;     while (t--) {       long long int n, x, y;       cin >> n >> x >> y;       vector<long long int> ar(n);       vector<long long int> arr(n + 2, 0);       vector<long long int> l[n + 2];       vector<long long int> ind(n + 2, 0);       for (long long int(i) = (0); (i) < (n); (i)++) {         cin >> ar[i];         arr[ar[i]] += 1;         l[ar[i]].push_back(i);       }       priority_queue<pair<long long int, long long int>> pq;       long long int k = -1;       for (long long int(i) = (1); (i) < (n + 2); (i)++) {         if (k == -1 && arr[i] == 0) {           k = i;         }         if (arr[i] != 0) {           pq.push({arr[i], i});         }       }       vector<long long int> arr2(n, -1);       for (long long int(i) = (0); (i) < (x); (i)++) {         pair<long long int, long long int> p1;         p1 = pq.top();         pq.pop();         arr2[l[p1.second][ind[p1.second]]] = p1.second;         ind[p1.second] += 1;         p1.first -= 1;         if (p1.first != 0) pq.push(p1);       }       vector<long long int> temp;       for (long long int(i) = (0); (i) < (n); (i)++) {         if (arr2[i] == -1) {           temp.push_back(ar[i]);         }       }       long long int d = (n - x) / 2;       vector<long long int> temp2 = temp;       sort((temp2).begin(), (temp2).end());       map<long long int, long long int> m1;       for (long long int(i) = (0); (i) < (temp2.size()); (i)++) {         m1[i] = l[temp2[i]][ind[temp2[i]]];         ind[temp2[i]] += 1;       }       for (long long int(i) = (0); (i) < (temp2.size()); (i)++) {         long long int j = (i + d) % temp2.size();         arr2[m1[j]] = temp2[i];       }       long long int c = 0;       for (long long int(i) = (0); (i) < (n); (i)++) {         if (arr2[i] == ar[i]) {           x--;           if (x < 0) {             c++;             arr2[i] = k;           }         }       }       if (c < n - y) {         for (long long int(i) = (0); (i) < (n); (i)++) {           if (arr2[i] != k && arr2[i] != ar[i]) {             c++;             arr2[i] = k;           }           if (c < n - y)             continue;           else             break;         }       }       if (c > n - y) {         cout <<  NO n ;       } else {         cout <<  YES n ;         for (long long int(i) = (0); (i) < (n); (i)++) {           cout << arr2[i] <<    ;         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 310;   const int mod = 1e9 + 7;   long long C[maxn][maxn], Fact[maxn];   void init() {     C[0][0] = 1, Fact[0] = 1;     for (int i = 1; i < maxn; i++) {       C[i][0] = 1, Fact[i] = Fact[i - 1] * i % mod;       for (int j = 1; j <= i; j++)         C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;     }   }   long long num[maxn], emp[maxn], dp[maxn][maxn];   int main() {     init();     int n;     scanf( %d , &n);     int tot = 0;     for (int i = 1; i <= n; i++) {       long long tmp;       scanf( %lld , &tmp);       int key = 1;       for (int j = 1; j <= tot; j++) {         long long x = (sqrt(tmp * emp[j]) + 0.5);         if (x * x == tmp * emp[j]) key = 0, num[j]++;       }       if (key) ++tot, num[tot] = 1, emp[tot] = tmp;     }     dp[0][0] = 1;     int m = 0;     for (int i = 1; i <= tot; i++) {       for (int j = 0; j <= n - 1 && j <= m + 1; j++) {         if (dp[i - 1][j] == 0) continue;         for (int k = 1; k <= num[i]; k++) {           long long tmp = dp[i - 1][j] * C[num[i] - 1][k - 1] % mod;           for (int p = 0; p <= k && p <= j + num[i] - k; p++) {             long long temp = tmp * C[j][p] % mod;             dp[i][j + num[i] - k - p] =                 (dp[i][j + num[i] - k - p] + temp * C[m + 1 - j][k - p] % mod) %                 mod;           }         }       }       m += num[i];     }     long long ans = dp[tot][0];     for (int i = 1; i <= tot; i++) ans = ans * Fact[num[i]] % mod;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, a, b, p, q, maxx, max_cost, minn, min_cost, t, nok, a1, b1;     cin >> n >> a >> b >> p >> q;     if (p > q) {       max_cost = p;       maxx = a;       minn = b;       min_cost = q;     } else {       max_cost = q;       maxx = b;       minn = a;       min_cost = p;     }     a1 = maxx;     b1 = minn;     while (b1 > 0) {       t = b1;       b1 = a1 % b1;       a1 = t;     }     nok = a * b / a1;     cout << ((n / maxx) * max_cost + (n / minn - n / nok) * min_cost);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class A, class B>   A cvt(B x) {     stringstream ss;     ss << x;     A y;     ss >> y;     return y;   }   int n, a, b, t;   string s;   int solve() {     int tb = 0;     vector<int> tm;     for (int k = n; k >= 1; k--) {       tb += a;       if (s[k - 1] !=  h ) tb += b;       tb += 1;       tm.push_back(tb);     }     int best = 0;     int t1 = 0;     for (int k = 1; k <= n; k++) {       if (k != 1) t1 += a;       if (s[k - 1] !=  h ) t1 += b;       t1 += 1;       if (t1 > t) break;       int t2 = t - t1 - (k - 1) * a;       int l = lower_bound(tm.begin(), tm.end(), t2 + 1) - tm.begin();       best = max(best, min(k + l, n));     }     return best;   }   int main() {     cin >> n >> a >> b >> t >> s;     int s1 = solve();     reverse(s.begin() + 1, s.end());     int s2 = solve();     cout << max(s1, s2) << endl;     return 0;   }