malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 100010, C = 1000000000;   int n, num;   int kd[N], t[N], x[N], fr[N], nxt[N], ans[N];   map<int, int> S;   int lc[N * 40], rc[N * 40], s[N * 40];   void change(int &i, int l, int r, int k, int d) {     if (i == 0) i = ++num;     s[i] += d;     if (l == r) return;     int mid = (l + r) >> 1;     if (k <= mid) change(lc[i], l, mid, k, d);     if (k > mid) change(rc[i], mid + 1, r, k, d);   }   int query(int i, int l, int r, int rr) {     if (i == 0) return 0;     if (r <= rr) return s[i];     int mid = (l + r) >> 1, res = 0;     res += query(lc[i], l, mid, rr);     if (mid < rr) res += query(rc[i], mid + 1, r, rr);     return res;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d%d , &kd[i], &t[i], &x[i]);       fr[i] = 1;       if (S.count(x[i])) {         nxt[S[x[i]]] = i;         fr[i] = 0;       }       S[x[i]] = i;     }     for (int i = 1; i <= n; i++)       if (fr[i]) {         for (int j = 1; j <= num; j++) lc[j] = rc[j] = s[j] = 0;         num = 1;         int rt = 1;         for (int j = i; j; j = nxt[j]) {           if (kd[j] == 1) change(rt, 1, C, t[j], 1);           if (kd[j] == 2) change(rt, 1, C, t[j], -1);           if (kd[j] == 3) ans[j] = query(1, 1, C, t[j]);         }       }     for (int i = 1; i <= n; i++)       if (kd[i] == 3) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long in() {     long long a;     scanf( %lld , &a);     return a;   }   bool isprime(long long n) {     if (n == 1) return 0;     if (n == 2) return 1;     if (n % 2) return 0;     for (int i = 2; i <= sqrt(n) + 2; i++)       if (n % i == 0) return 0;     return 1;   }   long long dao(long long n) {     for (int i = 2; i <= (sqrt(n)); i++)       if (n % i == 0) return i;   }   int main() {     long long a = in(), b = in();     if (a == b) cout << -1 << endl, exit(0);     if (a == 2) {       if (b & 1)         cout << b << endl;       else         cout << --b << endl;       exit(0);     }     for (long long i = b; i >= a; i--) {       if (dao(i) > a || isprime(i)) cout << i << endl, exit(0);     }     cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long mod, n, m, a[200005], b[200005], kq, vt1, vt2, l, r, mid, mn[200005];   map<int, bool> mp;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     mod = 998244353;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       mp[a[i]] = true;     }     for (int i = 1; i <= m; ++i) {       cin >> b[i];       if (!mp[b[i]]) {         cout << 0;         return 0;       }     }     for (int i = 1; i <= n; ++i) {       if (a[i] < b[1]) {         cout << 0;         return 0;       }       if (a[i] == b[m]) vt1 = i;     }     for (int i = n; i > vt1; --i)       if (a[i] < b[m]) {         cout << 0;         return 0;       }     mn[n] = a[n];     for (int i = n - 1; i > 0; --i) mn[i] = min(a[i], mn[i + 1]);     kq = 1;     for (int i = 1; i < m; ++i) {       l = 1;       r = n - 1;       while (l <= r) {         mid = (l + r) / 2;         if (mn[mid + 1] >= b[i + 1]) {           vt1 = mid;           r = mid - 1;         } else           l = mid + 1;       }       l = 1;       r = n - 1;       while (l <= r) {         mid = (l + r) / 2;         if (mn[mid + 1] > b[i + 1])           r = mid - 1;         else {           vt2 = mid;           l = mid + 1;         }       }       kq = kq * max(0LL, vt2 - vt1 + 1) % mod;       ;     }     cout << kq;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, r, x, s = 0;     cin >> n >> r >> x;     int a[r + 1];     for (int i = 1; i <= r; i++) {       a[i] = 10000000;     }     while (n--) {       int l, m;       cin >> l >> m;       a[l] = min(a[l], m);     }     for (int i = 1; i <= r; i++) {       s += a[i];     }     cout << min(s, x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   __int128 read() {     __int128 s = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       s = (s << 3) + (s << 1) + ch -  0 , ch = getchar();     return f * s;   }   struct node {     __int128 x, y;   } a[200];   int n;   __int128 abs(__int128 a) { return a > 0 ? a : -a; }   int main() {     a[0].x = read(), a[0].y = read();     __int128 ax = read(), ay = read(), bx = read(), by = read();     for (; a[n].x + a[n].y <= 1e18; n++)       a[n + 1].x = a[n].x * ax + bx, a[n + 1].y = a[n].y * ay + by;     __int128 xs = read(), ys = read(), t = read();     int ans = 0;     for (int s = 0, i; s <= n; s++) {       __int128 d = 0, x = xs, y = ys;       for (i = s; ~i && d <= t; i--) {         d += abs(x - a[i].x) + abs(y - a[i].y), x = a[i].x, y = a[i].y;       }       ans = max(ans, d <= t ? s - i : s - i - 1);       d = 0, x = xs, y = ys;       for (i = s; i <= n && d <= t; i++) {         d += abs(x - a[i].x) + abs(y - a[i].y), x = a[i].x, y = a[i].y;       }       ans = max(ans, d <= t ? i - s : i - s - 1);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, a[11];   int main() {     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       int day = 0;       for (int i = 0; i < 7; i++) scanf( %d , a + i), day += a[i];       int week = (n - 1) / day, best = 7, left = n - week * day;       for (int i = 0; i < 7; i++) {         int tot = 0, cur = 7;         for (int j = 0; j < 7; j++)           if (a[j] && ++tot == left) {             cur = j;             break;           }         best = min(best, cur + 1);         rotate(a, a + 1, a + 7);       }       printf( %d n , week * 7 + best);     }   }
#include <bits/stdc++.h>   using namespace std;   vector<char> ch1;   int main() {     string s, str =   ;     getline(cin, s);     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  . ) {         ch1.push_back( - );         i = i + 2;         continue;       }       if (s[i] ==     && s[i + 1] >=  0  && s[i + 1] <=  9  &&           ch1.back() >=  0  && ch1.back() <=  9 ) {         ch1.push_back( / );       }       if (s[i] !=    ) ch1.push_back(s[i]);     }     for (int i = 0; i < ch1.size(); i++) {       if (ch1[i] ==  -  && ch1[i + 1] !=  - )         str = str +  ... ;       else if (ch1[i] ==  -  && ch1[i + 1] ==  - )         str = str +  ...  +    ;       else if (ch1[i] ==  , )         str = str + ch1[i] +    ;       else if (ch1[i] ==  / )         str = str +    ;       else if (ch1[i] >=  0  && ch1[i] <=  9  && ch1[i + 1] ==  - )         str = str + ch1[i] +    ;       else         str = str + ch1[i];     }     if (str.back() ==    ) str.erase(str.length() - 1, 1);     cout << str;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t;     cin >> n >> t;     int f = 0;     int x;     int sum = 1;     for (int i = 1; i < n; i++) {       cin >> x;       if (i == sum) sum += x;       if (sum == t) f = 1;     }     if (f == 1)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int xuli(long long l, long long r, long long d) {     if (l > d || r < d)       return d;     else       return (r / d + 1) * d;   }   int main() {     long long n;     cin >> n;     long long i, l, r, d;     for (i = 1; i <= n; i++) {       cin >> l >> r >> d;       cout << xuli(l, r, d) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long Set(long long N, long long pos) { return N = N | (1 << pos); }   long long reset(long long N, long long pos) { return N = N & ~(1 << pos); }   bool check(long long N, long long pos) { return (bool)(N & (1 << pos)); }   void CI(long long &_x) { scanf( %d , &_x); }   void CO(long long &_x) { cout << _x; }   template <typename T>   void getarray(T a[], long long n) {     for (long long i = 0; i < n; i++) cin >> a[i];   }   template <typename T>   void prLLIarray(T a[], long long n) {     for (long long i = 0; i < n - 1; i++) cout << a[i] <<    ;     cout << a[n - 1] << endl;   }   const double EPS = 1e-9;   const long long INF = 0x7f7f7f7f;   long long dr8[8] = {1, -1, 0, 0, 1, -1, -1, 1};   long long dc8[8] = {0, 0, -1, 1, 1, 1, -1, -1};   long long dr4[4] = {0, 0, 1, -1};   long long dc4[4] = {-1, 1, 0, 0};   long long kn8r[8] = {1, 2, 2, 1, -1, -2, -2, -1};   long long kn8c[8] = {2, 1, -1, -2, -2, -1, 1, 2};   long long pow(long long a, long long b) {     long long ans = 1;     for (long long i = 0; i < b; i++) ans *= a;     return ans;   }   int main() {     long long a, b, n;     cin >> a >> b >> n;     if (b == 0) {       cout <<  0 n ;       return 0;     }     if (a == 0) {       puts( No solution );       return 0;     }     long long y = b / a;     long long low = -(1001), hi = (1001);     for (int i = 1; i <= 1000; i++) {       long long kk = 0, temp = abs(y);       while (temp % i == 0 && kk < n) {         temp = temp / i;         kk++;       }       if (kk == n && temp == 1) {         if (y < 0) i *= -1;         cout << i <<   n ;         return 0;       }     }     puts( No solution );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       int cnt = 0;       while (n > 1) {         if (n % 5 == 0) {           n = (4 * n) / 5;           cnt++;           continue;         } else if (n % 3 == 0) {           n = (2 * n) / 3;           cnt++;           continue;         } else if (n % 2 == 0) {           n = (n) / 2;           cnt++;           continue;         } else {           cnt = -1;           break;         }       }       cout << cnt << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 103;   using pi = pair<int, int>;   inline int rd() {     int x = 0, f = 1, c;     while (!isdigit(c = getchar()))       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     return f * x;   }   int n, m, k;   char p[N][N];   inline void solve() {     n = rd(), m = rd(), k = rd();     int cntr = 0;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> p[i][j], cntr += p[i][j] ==  R ;     vector<int> sz;     for (int i = 1; i <= cntr - cntr / k * k; i++) sz.push_back(cntr / k + 1);     while (sz.size() < k) sz.push_back(cntr / k);     vector<char> ch;     for (int i = 0; i < 26; i++) ch.push_back( A  + i), ch.push_back( a  + i);     for (char i =  0 ; i <=  9 ; i++) ch.push_back(i);     for (int r = 1, cr = 0; r <= n; r++) {       if (r & 1)         for (int c = 1; c <= m; c++) {           if (p[r][c] ==  R ) cr++;           p[r][c] = ch.back();           if (cr == sz.back()) {             sz.pop_back();             cr = 0;             if (sz.size()) ch.pop_back();           }         }       else         for (int c = m; c; c--) {           if (p[r][c] ==  R ) cr++;           p[r][c] = ch.back();           if (cr == sz.back()) {             sz.pop_back();             cr = 0;             if (sz.size()) ch.pop_back();           }         }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) cout << p[i][j];       cout << endl;     }   }   int main() {     for (int T = rd(); T--; solve())       ;   }
#include <bits/stdc++.h>   using namespace std;   struct dd {     int k1;     char k2;   } a[25000];   bool cmp(struct dd q, struct dd b) { return q.k1 > b.k1; }   int main() {     int i, j, m, n, sum;     char b[1000];     gets(b);     sum = 0;     char k =  a ;     scanf( %d , &m);     for (i = 0; i < 26; i++) {       scanf( %d , &a[i].k1);       a[i].k2 = k;       k++;     }     int len1 = strlen(b);     for (i = 0; i < len1; i++) {       sum += a[(int)b[i] - 97].k1 * (i + 1);     }     sort(a, a + 26, cmp);     for (i = len1; i < len1 + m; i++) {       sum += a[0].k1 * (i + 1);     }     printf( %d n , sum);   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T abs(T a) {     return (a >= 0 ? a : -a);   }   int main() {     int k, no[12];     cin >> k;     for (int i = 0; i < 12; i++) cin >> no[i];     sort(no, no + 12);     int res = 0, i = 11;     while (k > 0 && i >= 0) {       res++;       k -= no[i];       i--;     }     if (k <= 0)       cout << res;     else       cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 1e6 + 5;   const long long int INF = 1e18;   const long long int MOD = 1e9 + 7;   int a[N], has[N], hol[N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long int n, m, k, u, v;     cin >> n >> m >> k;     a[1] = 1;     long long int last;     for (long long int i = 1; i <= m; i++) {       cin >> hol[i];       has[hol[i]] = 1;     }     for (long long int i = 1; i <= k; i++) {       cin >> u >> v;       if (has[u] && a[u]) {         cout << u << endl;         exit(0);       }       if (has[v] && a[v]) {         cout << v << endl;         exit(0);       }       swap(a[u], a[v]);       if (has[u] && a[u]) {         cout << u << endl;         exit(0);       }       if (has[v] && a[v]) {         cout << v << endl;         exit(0);       }     }     for (long long int i = 1; i <= n; i++) {       if (a[i]) {         cout << i << endl;         exit(0);       }     }   }
#include <bits/stdc++.h>   int main() {     int a, b, i, d, c = 0, m = 0, j;     scanf( %d %d , &a, &b);     d = b;     while (d != 0) {       c++;       d = d / 10;     }     for (j = 1, i = 1; j < c; j++) {       i = i * 10;     }     while (b != 0) {       m = m + (b % 10) * i;       b = b / 10;       i = i / 10;     }     printf( %d n , a + m);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:256000000 )   template <class T>   T sqr(T a) {     return a * a;   }   int n, m, b;   long long a[1 << 20];   int was[1 << 20];   struct dr {     int mon, pl, zad;     int mask;     const bool operator<(dr a) const {       if (mon < a.mon)         return true;       else         return false;     }   };   dr fr[100];   void init() {     scanf( %d%D%D , &n, &m, &b);     for (int i = 0; i < n; ++i) {       scanf( %d%d%D , &fr[i].pl, &fr[i].mon, &fr[i].zad);       for (int j = 0; j < fr[i].zad; ++j) {         int t;         scanf( %D , &t);         t--;         fr[i].mask |= 1 << t;       }     }     sort(fr, fr + n);   }   int q = 0;   long long ot = -1, ma = 1e18, co;   void solve() {     was[0] = 1;     for (int i = 0; i < (1 << m); ++i) a[i] = 1e18;     a[0] = 0;     for (int i = 0; i < n; ++i) {       co = fr[i].mon;       int t = fr[i].mask;       for (int j = (1 << m) - 1; j >= 0; --j) {         if (!was[j]) continue;         was[j | t] = 1;         a[j | t] = min(a[j | t], a[j] + fr[i].pl);       }       if (!was[(1 << m) - 1]) continue;       if (ot == -1)         ot = a[(1 << m) - 1] + co * (long long)b;       else         ot = min(ot, a[(1 << m) - 1] + co * (long long)b);     }     cout << ot;   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace ::std;   int a[110], n, c, i, j, o, m;   int main() {     cin >> n >> c;     cin >> a[0];     for (i = 1; i < n; i++) {       cin >> a[i];       m = max(a[i - 1] - a[i] - c, m);     }     cout << m;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, x, y;     cin >> n >> m >> x >> y;     int vis[105][105];     int i, j;     for (i = 0; i < 105; i++)       for (j = 0; j < 105; j++) vis[i][j] = 0;     vis[x][y] = 1;     cout << x <<     << y << endl;     cout << x <<     << m << endl;     for (i = x - 1; i >= 1; i--) cout << i <<     << m << endl;     for (i = x + 1; i <= n; i++) cout << i <<     << m << endl;     int flag = 1;     for (i = m - 1; i >= 1; i--) {       if (flag) {         for (j = n; j >= 1; j--) {           if (vis[j][i] == 0) {             cout << j <<     << i << endl;             vis[j][i] = 1;           }         }         flag = !flag;       } else {         for (j = 1; j <= n; j++) {           if (vis[j][i] == 0) {             cout << j <<     << i << endl;             vis[j][i] = 1;           }         }         flag = !flag;       }     }   }
#include <bits/stdc++.h>   using namespace std;   map<string, int> mp;   int n, m, cc;   char s[1010];   int a[1010], cnt[1010];   void getcc(string s) {     if (mp.find(s) == mp.end()) mp[s] = cc++;     cnt[mp[s]]++;   }   int main() {     int i, j, k;     while (scanf( %d%d , &n, &m) > 0) {       for (i = 0; i < n; i++) scanf( %d , &a[i]);       sort(a, a + n);       mp.clear();       cc = 0;       memset(cnt, 0, sizeof(cnt));       for (i = 0; i < m; i++) {         scanf( %s , s);         getcc(s);       }       sort(cnt, cnt + cc);       int ma = 0, mi = 0;       for (i = 0; i < cc; i++) {         mi += a[i] * cnt[cc - 1 - i];         ma += a[n - 1 - i] * cnt[cc - 1 - i];       }       printf( %d %d n , mi, ma);     }     return 0;   }
#include <bits/stdc++.h>   const int MAXINT = 2147483640;   const long long MAXLL = 9223372036854775800LL;   const long long MAXN = 1000000;   using namespace std;   int l[MAXN], r[MAXN];   int n;   int ans[MAXN];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int T;     cin >> T;     while (T--) {       cin >> n;       for (int i = 1; i <= n; ++i) ans[i] = 0;       for (int i = 1; i <= n; ++i) cin >> l[i] >> r[i];       int t = l[1];       ans[1] = t;       for (int i = 2; i <= n; ++i) {         if (r[i] <= t)           ans[i] = 0;         else {           ans[i] = max(l[i], t + 1);           t = ans[i];         }       }       for (int i = 1; i <= n; ++i) cout << ans[i] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int t;     cin >> t;     while (t--) {       long long n, g, b;       cin >> n >> g >> b;       long long t = (n + 1) / 2;       long long r = t / g * (g + b);       if (t % g == 0) {         r -= b;       } else {         r += t % g;       }       cout << max(r, n) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[10];   long long ans = 0;   void DFS(long long n, long long u, long long r[10]) {     if (n == 10) {       long long sum = 1;       for (long long i = 2; i <= u; i++) sum *= i;       for (long long i = 1; i < 10; i++)         for (long long j = 2; j <= r[i]; j++) sum /= j;       long long b = 0;       for (long long i = 1; i <= a[0]; i++) {         long long d = 1, f = 1;         for (long long j = 0; j < i; j++) {           d *= u + j;           f *= j + 1;         }         b += d / f;       }       if (a[0] == 0) b = 1;       ans += b * sum;       return;     }     if (a[n] == 0) {       r[n] = 0;       DFS(n + 1, u, r);       return;     }     for (long long i = 1; i <= a[n]; i++) {       r[n] = i;       DFS(n + 1, u + i, r);     }   }   int main() {     long long d[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};     long long s;     cin >> s;     while (s) {       a[s % 10]++;       s /= 10;     }     DFS(1, 0, d);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const long long MOD = 1e9 + 7;   const int inf = 1e9;   const int N = 3e5 + 5;   bool flag;   template <typename T>   istream& operator>>(istream& is, vector<T>& v) {     for (auto& i : v) is >> i;     return is;   }   template <typename T>   void mul(T& a, T b) {     a += b;     if (b < (T)0) a += MOD;     if (a >= (T)MOD) a -= MOD;   }   void solve() {     int n, a, b;     cin >> n >> a >> b;     if (abs(a - b) > 1 or a + b + 2 > n) {       cout << -1;       return;     }     if (a == 0 and b == 0) {       for (int i = 1; i <= n; i++) cout << i <<    ;       return;     }     vector<int> ans;     int l = 1, r = n;     if (a > b) {       ans.push_back(l++);       for (int i = 1; i <= a + b; i++) {         if (i % 2)           ans.push_back(r--);         else           ans.push_back(l++);       }       for (int i = a + b + 1; i < n; i++) ans.push_back(r--);     } else {       ans.push_back(r--);       for (int i = 1; i <= a + b; i++) {         if (i % 2 == 0)           ans.push_back(r--);         else           ans.push_back(l++);       }       for (int i = a + b + 1; i < n; i++) ans.push_back(a == b ? r-- : l++);     }     for (auto now : ans) cout << now <<    ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << fixed << setprecision(12);     int tt = 1;     cin >> tt;     while (tt--) {       flag = 0;       solve();       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void debug(T a, T b) {     ;   }   template <class T>   void chmin(T& a, const T& b) {     if (a > b) a = b;   }   template <class T>   void chmax(T& a, const T& b) {     if (a < b) a = b;   }   namespace std {   template <class S, class T>   ostream& operator<<(ostream& out, const pair<S, T>& a) {     out <<  (  << a.first <<  ,  << a.second <<  ) ;     return out;   }   }  // namespace std   long long int readL() {     long long int res;     scanf( %I64d , &res);     return res;   }   void printL(long long int res) { printf( %I64d , res); }   int n, S;   struct pack {     int in, out, w, s, v;   };   pack par[505];   bool cmp(const pack& a, const pack& b) {     return make_pair(a.in, -a.out) < make_pair(b.in, -b.out);   }   int tmp[1005][1005];   int dp[505][1005];   void renew(int i, int base) {     int lim = min(S, par[base].w + par[base].s);     for (int j = 0; j < (lim); ++j) {       chmax(tmp[i][j + 1], tmp[i][j]);     }   }   void update(pack p, int id, int base) {     int l = p.in, r = p.out;     renew(l, base);     int lim = min(S, par[base].w + par[base].s);     for (int i = (par[base].w); i < (lim + 1); ++i)       if (tmp[l][i] >= 0 && dp[id][i - par[base].w] >= 0) {         chmax(tmp[r][i], tmp[l][i] + dp[id][i - par[base].w]);       }   }   void bring(int i, int base) {     renew(i, base);     int lim = min(S, par[base].w + par[base].s);     for (int j = 0; j < (lim + 1); ++j) {       chmax(tmp[i + 1][j], tmp[i][j]);     }   }   int main() {     cin >> n >> S;     for (int i = 0; i < (n); ++i) {       cin >> par[i].in >> par[i].out >> par[i].w >> par[i].s >> par[i].v;     }     par[n] = (pack){0, 2 * n, 0, S + 1, 0};     ++n;     sort(par, par + n, cmp);     memset(dp, -1, sizeof(dp));     int res = 0;     for (int i = n - 1; i >= 0; --i) {       pack p = par[i];       int l = par[i].in, r = par[i].out;       for (int j = (l); j < (r + 1); ++j)         for (int k = 0; k < (S + 1); ++k) tmp[j][k] = -1;       tmp[l][p.w] = p.v;       renew(l, i);       int cur = l;       for (int j = (i + 1); j < (n); ++j) {         if (l <= par[j].in && par[j].out <= r) {           while (cur < par[j].in) {             bring(cur, i);             ++cur;           }           update(par[j], j, i);         }       }       while (cur < r) {         bring(cur, i);         ++cur;       }       renew(r, i);       int lim = min(S, p.w + p.s);       for (int j = 0; j < (lim + 1); ++j) {         dp[i][j] = tmp[r][j];         chmax(res, tmp[r][j]);       }       for (int j = 0; j < (S); ++j) chmax(dp[i][j + 1], dp[i][j]);     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double DP[202][202][202];   long double P[202];   int A[202];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, l, k;     cin >> n >> l >> k;     k = min(k, n);     for (int i = 1; i <= n; i++) cin >> P[i], P[i] /= 100.0;     for (int i = 1; i <= n; i++) cin >> A[i];     DP[1][0][k] = 1;     for (int i = 1; i <= n; i++)       for (int j = 0; j < i; j++)         for (int z = k; z <= n; z++) {           DP[i + 1][j][z] += DP[i][j][z] * (1.0 - P[i]);           if (A[i] == -1)             DP[i + 1][j + 1][z] += DP[i][j][z] * P[i];           else             DP[i + 1][j + 1][min(n, z + A[i] + 1)] += DP[i][j][z] * P[i];         }     long double ats = 0;     for (int j = l; j <= n; j++)       for (int z = max(k, j); z <= n; z++) ats += DP[n + 1][j][z];     cout << setprecision(13) << fixed << ats;   }