malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const int N = 200000;   int f[N + 5];   namespace segt {   const int S = (N << 2);   struct type {     int mn, lm, rm, m, s;     friend type operator+(const type &a, const type &b) {       type c;       c.mn = std::min(a.mn, b.mn), c.m = std::max(a.m, b.m);       if (a.mn < b.mn) {         c.lm = a.lm, c.rm = std::max(a.rm, b.m), c.s = a.s;       } else if (a.mn > b.mn) {         c.lm = std::max(a.m, b.lm), c.rm = b.rm, c.s = b.s;       } else {         c.lm = a.lm, c.rm = b.rm, c.s = a.s + b.s + std::max(a.rm, b.lm);       }       return c;     }   } t[S + 5];   int le[S + 5], ri[S + 5], tag[S + 5];   void addtag(int x, int k) { tag[x] += k, t[x].mn += k; }   void pushup(int x) { t[x] = t[(x << 1)] + t[(x << 1 | 1)]; }   void pushdown(int x) {     if (tag[x])       addtag((x << 1), tag[x]), addtag((x << 1 | 1), tag[x]), tag[x] = 0;   }   void build(int x, int l, int r) {     le[x] = l, ri[x] = r, t[x] = (type){0, 0, 0, 0, 0};     if (l == r) return;     int m = (l + r) >> 1;     build((x << 1), l, m), build((x << 1 | 1), m + 1, r);   }   void add(int x, int l, int r, int d) {     if (r < le[x] || l > ri[x]) return;     if (l <= le[x] && ri[x] <= r) {       addtag(x, d);       return;     }     pushdown(x), add((x << 1), l, r, d), add((x << 1 | 1), l, r, d), pushup(x);   }   void update(int x, int p) {     if (le[x] == ri[x]) {       t[x].lm = f[p], t[x].rm = f[p + 1], t[x].m = std::max(f[p], f[p + 1]);       return;     }     int m = (le[x] + ri[x]) >> 1;     pushdown(x), update(p <= m ? (x << 1) : (x << 1 | 1), p), pushup(x);   }   }  // namespace segt   std::set<int> st[N + 5];   int a[N + 5], n, q;   void clear(int x) {     if (st[x].empty()) return;     int lc = *st[x].begin();     segt::add(1, lc, (*st[x].rbegin()) - 1, -1);     f[lc] = 0, segt::update(1, lc - 1), segt::update(1, lc);   }   void calc(int x) {     if (st[x].empty()) return;     int lc = *st[x].begin();     segt::add(1, lc, (*st[x].rbegin()) - 1, 1);     f[lc] = (int)st[x].size(), segt::update(1, lc - 1), segt::update(1, lc);   }   void erase(int i) {     int x = a[i];     clear(x), st[x].erase(i), calc(x);   }   void insert(int i) {     int x = a[i];     clear(x), st[x].insert(i), calc(x);   }   int main() {     scanf( %d%d , &n, &q);     segt::build(1, 0, n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), insert(i);     printf( %d n , n - segt::t[1].s);     for (int t = 1, i, x; t <= q; t++) {       scanf( %d%d , &i, &x);       erase(i), a[i] = x, insert(i);       printf( %d n , n - segt::t[1].s);     }   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 0;     char ch = getchar();     while (!isdigit(ch)) f |= ch ==  - , ch = getchar();     while (isdigit(ch)) x = 10 * x + ch -  0 , ch = getchar();     return f ? -x : x;   }   inline long long llread() {     long long x = 0, f = 0;     char ch = getchar();     while (!isdigit(ch)) f |= ch ==  - , ch = getchar();     while (isdigit(ch)) x = 10 * x + ch -  0 , ch = getchar();     return f ? -x : x;   }   int n;   char s[25][400010];   int l[25], rest[25];   vector<int> v[25][400010];   int dp[(1 << 20) + 10][2], g[(1 << 20) + 10];   signed main() {     n = read();     for (int i = (1); i <= (n); i++) scanf( %s , s[i] + 1);     for (int i = (1); i <= (n); i++) l[i] = strlen(s[i] + 1);     for (int i = (1); i <= (n); i++) {       int top = 0;       for (int j = (1); j <= (l[i]); j++) {         if (s[i][j] ==  ( )           top++;         else           top--;         if (top <= 0) v[i][-top].push_back(j);       }       rest[i] = top;     }     for (int i = (1); i <= ((1 << n) - 1); i++) dp[i][0] = dp[i][1] = -0x3f3f3f3f;     dp[0][0] = dp[0][1] = g[0] = 0;     for (int mask = (1); mask <= ((1 << n) - 1); mask++) {       for (int i = (1); i <= (n); i++) {         if (mask & (1 << (i - 1))) {           int S = mask ^ (1 << (i - 1));           if (dp[mask][0] < dp[S][0]) {             dp[mask][0] = dp[S][0];           };           if (g[S] >= 0) {             int x;             if (v[i][g[S] + 1].size() == 0)               x = l[i] + 1;             else               x = v[i][g[S] + 1][0];             int y = lower_bound(v[i][g[S]].begin(), v[i][g[S]].end(), x) -                     v[i][g[S]].begin();             if (x == l[i] + 1) {               if (dp[mask][1] < dp[S][1] + y) {                 dp[mask][1] = dp[S][1] + y;               };             }             if (dp[mask][0] < dp[S][1] + y) {               dp[mask][0] = dp[S][1] + y;             };           }           g[mask] = g[S] + rest[i];         }       }     }     printf( %d n , max(dp[(1 << n) - 1][0], dp[(1 << n) - 1][1]));     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, m;     int b[200];     int t[200];     int tmp;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) t[i] = 1;     for (int i = 0; i < m; ++i) {       scanf( %d , &tmp);       for (int j = tmp; j <= n; ++j) {         if (t[j] == 1) {           b[j] = tmp;           t[j] = 0;         }       }     }     for (int i = 1; i <= n; ++i) printf( %d  , b[i]);   }
#include <bits/stdc++.h>   using namespace std;   void read (int &x) {       char ch = getchar(); int f = 0; x = 0;       while (!isdigit(ch)) { if (ch ==  - ) f = 1; ch = getchar(); }       while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();       if (f) x = -x;   } const int N = 3e5 + 5;   int n, a[N], f[N], fr[N], d[N], k[N], lg[N];   #define cmax(x, y) (x = x > y ? x : y)   struct ans { int v, w; } ;   struct st {       int c[N][19];       void pre () {           for (int i = 0; i <= n; ++i) c[i][0] = a[i] + i;           for (int i = 1; (1 << i) <= n; ++i)               for (int j = 1; j + (1 << i) - 1 <= n; ++j)                   c[j][i] = max (c[j][i - 1], c[j + (1 << i - 1)][i - 1]);       }       int query (int l, int r) {           if (l > r) return 0; int t = lg[r - l + 1];           // printf ( %d %d %d n , l, r, max (c[l][t], c[r - (1 << t) + 1][t]));           return max (c[l][t], c[r - (1 << t) + 1][t]);       }   } A;   signed main() {       int T; read (T); lg[0] = -1;       for (int i = 1; i <= 300002; ++i) lg[i] = lg[i >> 1] + 1;       while (T--) {           read (n); a[++n] = 0;           for (int i = 1; i < n; ++i) read (a[i]); A.pre ();           for (int i = 0; i <= n; ++i) f[i] = k[i] = fr[i] = 0;           for (int i = 1, l, r, m, j, mx = -1, w = 0; i <= n; ++i) {               l = 0, r = i - 1, j = -1;               while (l <= r) {                   m = l + r >> 1;                   if (f[m] + 1 >= i - a[i]) j = m, r = m - 1;                   else l = m + 1;               }               if (j >= 0) f[i] = max (A.query (j + 1, i - 1), i - 1), fr[i] = j;               if (f[i - 1] >= i && f[i] < i + a[i]) f[i] = i + a[i], fr[i] = i - 1, k[i] = 1;               if (mx > f[i]) f[i] = mx, fr[i] = w; else mx = f[i], w = i;               // printf ( 666 %d %d %d %d n , j, i, f[i], fr[i]);           }           if (f[n] >= n - 1) {               puts ( YES );               for (int i = n; i >= 1; i = fr[i]) {                   for (int j = fr[i] + 1; j < i; ++j) d[j] = 1; d[i] = k[i];               }               for (int i = 1; i < n; ++i) putchar (d[i] ?  R  :  L ); puts (  );           } else puts ( NO );       }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d%d , &n, &m);     bool ch = 0;     bool arr[n + 1];     vector<int> vec, vec1;     for (int i = 0; i < m; i++) {       int a, b;       scanf( %d%d , &a, &b);       if (b > a) swap(a, b);       vec.push_back(a);       vec1.push_back(b);     }     if (!m)       cout << n - 1;     else {       sort(vec.begin(), vec.end());       sort(vec1.begin(), vec1.end());       cout << max(0, vec[0] - vec1[vec1.size() - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     bool p = 1;     cin >> a;     int A[a];     for (int i = 0; i < a; i++) {       cin >> A[i];       if (A[i] == 1) {         p = 0;       }     }     if (p) {       cout <<  EASY ;     } else {       cout <<  HARD ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) { return (a > b) ? a : b; }   long long min(long long a, long long b) { return (a < b) ? a : b; }   vector<long long> ar[100010];   long long vis[100010], dist[10001];   long long solve() { return 0; }   long long cc;   double pi = 3.141592653589793238;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       n = 2 * n;       double ans = 1 / tan(pi / n);       cout << fixed << setprecision(11) << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, c, a;     cin >> n >> c;     vector<int> arr;     for (int i = 0; i < n; i++) {       cin >> a;       arr.push_back(a);     }     int maxx = 0;     for (int i = 0; i < n - 1; i++) {       maxx = max(maxx, arr[i] - arr[i + 1] - c);     }     cout << maxx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100001;   long long h, c, temp;   long double f(long long m) {     long double r = 1.0 * (m * h + (m)*c) / (2 * m);     return (abs(r - temp));   }   long double f12(long long m) {     long double r = 1.0 * (m * h + (m - 1) * c) / (2 * m - 1);     return (abs(r - temp));   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     t = 1;     cin >> t;     while (t--) {       long long i, j, k;       cin >> h >> c >> temp;       long long l = 1;       long long r = 1000000000;       while (r - l > 2) {         long long m1 = (l * 2 + r) / 3;         long long m2 = (l + 2 * r) / 3;         if (f(m1) > f(m2))           l = m1;         else           r = m2;       }       long double ans = f(2);       j = 2;       for (i = l; i <= r; i++) {         if (f(i) < ans) {           j = 2 * i;           ans = f(i);         }       }       l = 1;       r = 1000000000;       while (r - l > 2) {         long long m1 = (l * 2 + r) / 3;         long long m2 = (l + 2 * r) / 3;         if (f12(m1) > f12(m2))           l = m1;         else           r = m2;       }       for (i = l; i <= r; i++) {         if (f12(i) < ans) {           j = 2 * i - 1;           ans = f12(i);         }       }       cout << j <<   n ;     }   }
#include <bits/stdc++.h>   int n, p[4005], f[4005][4005], w[4005], tl;   void solve() {     scanf( %d , &n);     n <<= 1;     for (int i = 1; i <= n; ++i) scanf( %d , &p[i]);     tl = 0;     int pre = 1;     w[++tl] = 1;     for (int i = 2; i <= n; ++i) {       if (p[i] < p[pre])         w[tl]++;       else {         pre = i;         w[++tl] = 1;       }     }     for (int i = 0; i <= n; ++i)       for (int j = 0; j <= n; ++j) f[i][j] = 0;     f[0][0] = 1;     for (int i = 1; i <= tl; ++i)       for (int j = 0; j <= n; ++j)         f[i][j] = f[i - 1][j] | (j - w[i] >= 0 ? f[i - 1][j - w[i]] : 0);     if (f[tl][n / 2])       puts( YES );     else       puts( NO );   }   int main() {     int t;     scanf( %d , &t);     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   long long m, d;   long long a[1000][1000];   long long me[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> m >> d;     long long cnt = 1, cnt1 = 0;     long long pr = 0;     long long ok = 0;     for (long long i = 1; i <= 1000; i++) {       if (ok == 0) {         for (long long j = d; j <= 7; j++) {           a[i][j] = cnt;           cnt++;           if (cnt - 1 == me[m - 1]) {             cout << i;             return 0;           }         }         ok = 1;       } else {         for (long long j = 1; j <= 7; j++) {           a[i][j] = cnt;           cnt++;           if (cnt - 1 == me[m - 1]) {             cout << i;             return 0;           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 4e18;   const int inf = 2e9;   const double eps = 1e-13;   const int N = 1e5 + 5;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int lcm(int a, int b) { return a / gcd(a, b) * b; }   int mod;   int a[N];   int b[N];   void norm(int &x) {     x %= mod;     if (x < 0) x += mod;   }   int main(void) {     int i, j, n, m;     scanf( %d %d %d , &n, &m, &mod);     for (i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (i = 1; i <= m; ++i) {       scanf( %d , &b[i]);       b[i] += b[i - 1];     }     for (i = 1; i <= n; ++i) {       int l = max(1, m - n + i);       int r = min(m, i);       a[i] += b[r] - b[l - 1];       norm(a[i]);       printf( %d  , a[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   template <class _T>   bool maximize(_T &a, _T b) {     return a < b ? a = b, 1 : 0;   }   template <class _T>   bool minimize(_T &a, _T b) {     return a > b ? a = b, 1 : 0;   }   const int ooit = 2e9;   const long long ooll = 1e15;   using namespace std;   int n, q, a[200005];   void enter() {     cin >> n >> q;     for (int i = 1; i <= n; i++) {       char c;       cin >> c;       a[i] = (int)c;     }   }   set<int> pos[256];   struct BIT {     int val[200005];     void update(int i, int x, int n) {       for (; i <= n; i += i & -i) val[i] += x;     }     int get(int i) {       int res = 0;       for (; i > 0; i -= i & -i) res += val[i];       return res;     }   } tree;   void prepare() {     for (int i = 1; i <= n; i++) pos[a[i]].insert(i), tree.update(i, 1, n);   }   int tfind(int x) {     int l = 1, r = n, res = -1;     while (l <= r) {       int mid = (l + r) / 2;       if (tree.get(mid) >= x)         r = mid - 1, res = mid;       else         l = mid + 1;     }     return res;   }   bool is_remove[200005];   void update(int l, int r, int x) {     auto it_down = pos[x].lower_bound(l);     if (it_down == pos[x].end()) return;     auto it_up = pos[x].upper_bound(r);     vector<int> must_remove;     for (; it_down != it_up; it_down++) must_remove.push_back(*it_down);     for (auto i : must_remove) {       pos[x].erase(i);       tree.update(i, -1, n);       is_remove[i] = true;     }   }   void process() {     prepare();     for (int i = 1; i <= q; i++) {       int l, r, cx;       char c;       cin >> l >> r >> c;       cx = (int)c;       int tl = tfind(l), tr = tfind(r);       update(tl, tr, cx);     }     for (int i = 1; i <= n; i++)       if (!is_remove[i]) cout << (char)a[i];     cout << endl;   }   int main() {     enter();     process();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INFint = 2147483647;   const long long INF = 9223372036854775807ll;   const long long MOD = 1000000007ll;   const long double EPS = 1e-9;   vector<int> p;   vector<int> used;   vector<vector<int> > g;   long long ans = 0;   void dfs(int v) {     used[v] = 1;     for (int i = 0; i < g[v].size(); i++) {       int to = g[v][i];       if (used[to]) {         if (p[to] == p[v]) {           ans++;         }       } else {         p[to] = !p[v];         dfs(to);       }     }   }   int main() {     ios_base::sync_with_stdio(0);     int n, m;     cin >> n >> m;     p.resize(n);     g.resize(n);     used.resize(n);     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       x--, y--;       g[x].push_back(y);       g[y].push_back(x);     }     for (int i = 0; i < n; i++) {       if (!used[i]) {         p[i] = 0;         dfs(i);       }     }     ans /= 2;     if ((n - ans) & 1) ans++;     cout << ans << endl;     fprintf(stderr,   nTIME = %lf n , 1.0 * clock() / CLOCKS_PER_SEC);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2 * 1000 * 100 + 10, Z = 26, P = 2, mod = 1e9 + 9;   int pw[N], wp[N], n, m, tar[Z], hsh[N][Z];   string s, t;   long long Pow(long long a, long long b) {     return b ? (b & 1 ? a : 1) % mod * Pow(a * a % mod, b >> 1) % mod : 1;   }   int add(int a, int b) {     a += b;     a += (a < 0) * mod;     a -= (a >= mod) * mod;     return a;   }   int mul(int a, int b) { return 1LL * a * b % mod; }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     pw[0] = 1;     for (int i = 1; i < N; i++) pw[i] = mul(pw[i - 1], P);     wp[N - 1] = Pow(pw[N - 1], mod - 2);     for (int i = N - 2; i >= 0; i--) wp[i] = mul(wp[i + 1], P);     cin >> n >> m >> s >> t;     for (int i = 0; i < m; i++)       for (int j = 0; j < Z; j++)         tar[j] = add(tar[j], mul(pw[i], t[i] -  a  == j));     vector<pair<int, int>> targ;     for (int i = 0; i < Z; i++) targ.push_back({tar[i], i});     sort(targ.begin(), targ.end());     for (int i = 1; i <= n; i++)       for (int j = 0; j < Z; j++)         hsh[i][j] = add(hsh[i - 1][j], mul(pw[i - 1], s[i - 1] -  a  == j));     vector<int> o;     for (int i = 0; i + m <= n; i++) {       bool res = true;       vector<pair<int, int>> me;       for (int j = 0; j < Z; j++) {         int val = mul(add(hsh[i + m][j], -hsh[i][j]), wp[i]);         me.push_back({val, j});       }       sort(me.begin(), me.end());       for (int i = 0; i < Z; i++) res &= me[i].first == targ[i].first;       set<pair<int, int>> st;       set<int> NO;       for (int i = 0; i < Z; i++) {         if (me[i].first == 0) continue;         if (me[i].second != targ[i].second)           if (me[i].second < targ[i].second)             st.insert({me[i].second, targ[i].second});           else             st.insert({targ[i].second, me[i].second});         else           NO.insert(me[i].second);       }       set<int> F, S;       for (auto it : st) F.insert(it.first), S.insert(it.second);       res &= (int)(F.size()) == (int)(st.size());       res &= (int)(S.size()) == (int)(st.size());       for (auto it : st) S.insert(it.first);       res &= (int)(S.size()) == ((int)(st.size()) * 2);       for (auto it : S) res &= !NO.count(it);       if (res) o.push_back(i + 1);     }     cout << (int)(o.size()) <<   n ;     for (auto i : o) cout << i <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1001;   bool used[N][N];   bool best[N][N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     vector<pair<int, int>> points(3);     for (auto& [x, y] : points) {       cin >> x >> y;     }     int x, y, cnt;     auto update_x = [&](int a) {       while (x != a) {         if (x > a) {           --x;         } else {           ++x;         }         if (!used[x][y]) {           used[x][y] = true;           ++cnt;         }       }     };     auto update_y = [&](int a) {       while (y != a) {         if (y > a) {           --y;         } else {           ++y;         }         if (!used[x][y]) {           used[x][y] = true;           ++cnt;         }       }     };     int ans = 1e9;     vector<int> perm = {0, 1, 2};     do {       for (int dir1 = 0; dir1 < 2; ++dir1) {         for (int dir2 = 0; dir2 < 2; ++dir2) {           memset(used, false, sizeof used);           x = points[perm[0]].first;           y = points[perm[0]].second;           used[x][y] = true;           cnt = 1;           if (dir1 == 0) {             update_x(points[perm[1]].first);             update_y(points[perm[1]].second);           } else {             update_y(points[perm[1]].second);             update_x(points[perm[1]].first);           }           if (dir2 == 0) {             update_x(points[perm[2]].first);             update_y(points[perm[2]].second);           } else {             update_y(points[perm[2]].second);             update_x(points[perm[2]].first);           }           if (cnt < ans) {             ans = cnt;             memcpy(best, used, sizeof used);           }         }       }     } while (next_permutation(perm.begin(), perm.end()));     cout << ans <<   n ;     for (int i = 0; i <= 1000; ++i) {       for (int j = 0; j <= 1000; ++j) {         if (best[i][j]) {           cout << i <<     << j <<   n ;         }       }     }   }
#include <bits/stdc++.h>   int main() {     long int a, i, s;     scanf( %ld , &a);     s = a;     if (a != 1) {       for (i = 2;; i++) {         s = s + 1 + i * (a - i);         if ((a - i) == 0) {           break;         }       }       printf( %ld , s);     } else {       printf( 1 );     }   }
#include <bits/stdc++.h>   using namespace std;   int A[] = {2, 3, 5, 7, 11, 13, 17, 19}, n, B[5005], vmax;   priority_queue<int> Q;   set<int> S;   inline int sol(int i) {     int j, k, t, first, second;     B[0] = 1;     for (j = 1; j <= n; j++) {       first = B[j - 1] * A[0];       for (t = 0; t < j; t++)         for (k = 0; k < i; k++)           if (B[t] * A[k] > B[j - 1]) first = min(first, B[t] * A[k]);       B[j] = first;       if (first > vmax) return 0;     }     for (j = 0; j < i; j++) {       first = 0;       for (k = 1; k <= n; k++)         if (B[k] % A[j] == 0) first++;       if (first < (n + 1) / 2) {         S.clear();         for (k = 1; k <= n; k++) S.insert(B[k]);         first = (n + 1) / 2 - first;         for (k = 1; k <= n && first; k++)           if (B[k] % A[j] != 0) {             second = B[k] * A[j];             while (S.find(second) != S.end()) {               second *= A[j];               if (second > vmax) return 0;             }             if (second > vmax) return 0;             S.erase(B[k]);             B[k] = second;             S.insert(B[k]);             first--;           }         sort(B + 1, B + n + 1);       }     }     for (j = 0; j < i; j++) {       first = 0;       for (k = 1; k <= n; k++)         if (B[k] % A[j] == 0) first++;       if (first < (n + 1) / 2) return 0;     }     return 1;   }   int main() {     cin >> n;     vmax = 2 * n * n;     int i;     for (i = 1; i <= 8; i++)       if (sol(i)) break;     printf( %d , B[1]);     for (i = 2; i <= n; i++) printf(  %d , B[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int teamA, teamB, y1, y2, y;     cin >> teamA >> teamB >> y1 >> y2 >> y;     int min = y - (teamA * (y1 - 1) + teamB * (y2 - 1));     if (min < 0) {       cout << 0 <<    ;     } else {       cout << min <<    ;     }     int max = y - teamA * y1 - teamB * y2;     if (max < 0) {       if (y2 < y1) {         max = y - teamB * y2;         if (max < 0) {           cout << y / y2 << endl;           return 0;         } else if (max == 0) {           cout << teamB << endl;           return 0;         }         cout << teamB + max / y1 << endl;         return 0;       } else {         max = y - teamA * y1;         if (max < 0) {           cout << y / y1 << endl;           return 0;         } else if (max == 0) {           cout << teamA << endl;           return 0;         }         cout << teamA + max / y2 << endl;         return 0;       }     } else {       cout << teamA + teamB << endl;     }     return 0;   }