malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, m, l, r, p, span, t, lwr, upr;   long pr[200000];   vector<long> vec[200000];   long calc[200000];   long long res, nmoves[200000];   long long check[200000];   long long temp;   long long answ;   long long gcd(long long a, long long b) {     while (a && b) a > b ? a %= b : b %= a;     return a + b;   }   long long solve1(long long x, long long lim) {     long long res = 0;     for (int mask = 0; mask < (1 << (vec[x].size())); mask++) {       temp = 1;       for (int j = 0; j < vec[x].size(); j++)         if (mask & (1 << j)) temp *= vec[x][j];       if (calc[mask] % 2)         res -= lim / temp;       else         res += lim / temp;     }     return res;   }   long long solve(long long x, long long lim) {     long long res = 0;     long long ts = 0;     long long q, qsum;     for (int mask = 0; mask < (1 << (vec[x].size())); mask++) {       temp = 1;       for (int j = 0; j < vec[x].size(); j++)         if (mask & (1 << j)) temp *= vec[x][j];       q = lim / temp;       qsum = q * (q + 1) / 2;       qsum *= temp;       if (calc[mask] % 2)         res -= qsum;       else         res += qsum;     }     return res;   }   long long gett(long long g, long long x, long long lim) {     if (lim <= 0) return 0;     long long tsum = (g + 1) * solve1(x, lim);     tsum -= solve(x, lim);     return tsum;   }   int main() {     ios_base::sync_with_stdio(0);     pr[1] = 1;     for (int i = 2; i <= 100000; i++)       if (pr[i] == 0)         for (int j = i * 2; j <= 100000; j += i) {           pr[j] = 1;           vec[j].push_back(i);         }     for (int i = 2; i <= 100000; i++)       if (pr[i] == 0) vec[i].push_back(i);     calc[0] = 0;     for (int i = 1; i <= (1 << 15); i++) {       t = i;       for (int j = 0; j < 15; j++)         if (t & (1 << j)) ++calc[i];     }     long long a, b;     cin >> n >> m;     cin >> l >> r >> p;     l *= l;     r *= r;     for (long long span = 2; span <= 100000 && span <= n; span++) {       if (span * span > r) continue;       t = l - span * span;       if (t <= 0)         lwr = 0;       else         lwr = sqrt(t - 0.5) + 1;       t = r - span * span;       upr = sqrt(t + 0.5);       if (upr >= span) upr = span - 1;       if (upr > m) upr = m;       if (upr < lwr) continue;       res = (gett(m, span, upr) - gett(m, span, lwr - 1)) * (n - span + 1) * 2;       answ = answ + res;       answ %= p;     }     swap(n, m);     for (long long span = 2; span <= 100000 && span <= n; span++) {       if (span * span > r) continue;       t = l - span * span;       if (t <= 0)         lwr = 0;       else         lwr = sqrt(t - 0.5) + 1;       t = r - span * span;       upr = sqrt(t + 0.5);       if (upr >= span) upr = span - 1;       if (upr > m) upr = m;       if (upr < lwr) continue;       res = (gett(m, span, upr) - gett(m, span, lwr - 1)) * (n - span + 1) * 2;       answ = answ + res;       answ %= p;     }     if (1 >= l && 1 <= r) answ += n * (m + 1), answ += m * (n + 1);     if (2 >= l && 2 <= r) answ += 2 * n * m;     cout << answ % p << endl;     cin.get();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string p( / ), t;     while (n--) {       string foo;       cin >> foo;       if (foo ==  pwd ) {         cout << p << endl;       } else {         string dir;         cin >> dir;         dir +=  / ;         for (int i = 0; i < dir.length(); i++) {           t += dir[i];           if (dir[i] ==  / ) {             if (t ==  / )               p = t;             else if (t ==  ../ ) {               for (int j = p.length() - 1; j > 0 && p[j - 1] !=  / ; j--) {                 p.resize(j - 1);               }             } else               p += t;             t =   ;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());   mt19937 rnf(2106);   const int N = 300005;   int n;   int a[N];   vector<int> v[N];   int ans[N];   void solv() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 1; i <= n; ++i) v[i].clear();     for (int i = 1; i <= n; ++i) {       v[a[i]].push_back(i);     }     for (int i = 1; i <= n; ++i) ans[i] = N;     for (int i = 1; i <= n; ++i) {       if (v[i].empty()) continue;       int maxu = v[i][0] - 1;       for (int j = 0; j < ((int)(v[i]).size()) - 1; ++j)         maxu = max(maxu, v[i][j + 1] - v[i][j] - 1);       maxu = max(maxu, n - v[i].back());       ans[maxu + 1] = min(ans[maxu + 1], i);     }     for (int i = 2; i <= n; ++i) ans[i] = min(ans[i], ans[i - 1]);     for (int i = 1; i <= n; ++i) {       if (ans[i] == N)         printf( -1  );       else         printf( %d  , ans[i]);     }     printf(  n );   }   int main() {     int tt;     scanf( %d , &tt);     while (tt--) solv();     return 0;   }
#include <bits/stdc++.h>   const int offs = 350;   int n, d, f[30005][705], gem[30005];   int main() {     scanf( %d%d , &n, &d);     for (int i = 0, t; i < n; i++) scanf( %d , &t), gem[t]++;     memset(f, -1, sizeof(f));     f[d][offs] = gem[d];     for (int i = d + 1, t; i < 30005; i++)       for (int j = 0; j < 705 - 1; j++)         if ((t = d + j - offs) > 0 && (i - t >= 0)) {           if (t - 1 > 0 && ~f[i - t][j - 1])             f[i][j] = std::max(f[i][j], f[i - t][j - 1]);           if (~f[i - t][j]) f[i][j] = std::max(f[i][j], f[i - t][j]);           if (~f[i - t][j + 1]) f[i][j] = std::max(f[i][j], f[i - t][j + 1]);           if (~f[i][j]) f[i][j] += gem[i];         }     int ans = 0;     for (int i = 0; i < 30005; i++)       for (int j = 0; j < 705; j++) ans = std::max(ans, f[i][j]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1000000000000000000LL;   const double EPS = 1e-9;   const long long mod = 1000000007ll;   const int maxn = 500500;   int longestP[1000500];   char pat[1000500];   void KMP() {     for (int i = 1, k = 0; pat[i]; i++) {       while (k > 0 && pat[i] != pat[k]) k = longestP[k - 1];       if (pat[i] == pat[k])         longestP[i] = ++k;       else         longestP[i] = k;     }   }   int main() {     scanf( %s , pat);     int n = strlen(pat);     KMP();     if (longestP[n - 1] == 0) {       puts( Just a legend );       return 0;     }     for (int i = 0; i + 1 < n; i++)       if (longestP[n - 1] == longestP[i]) {         for (int j = 0; j < longestP[i]; j++) putchar(pat[j]);         return 0;       }     if (longestP[longestP[n - 1] - 1] == 0) {       puts( Just a legend );       return 0;     }     for (int j = 0; j < longestP[longestP[n - 1] - 1]; j++) putchar(pat[j]);   }
#include <bits/stdc++.h>   using namespace std;   int n, ans = 0;   int a[1000 + 10], pre[9][1000 + 10], kr[9][1000 + 10], cnt[10];   int f[1000 + 10][1 << 8];   int g[9] = {0, 1, 2, 4, 8, 16, 32, 64, 128};   int read() {     int x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   int find(int t, int p) {     int l = 1, r = n, tmp;     while (l <= r) {       int mid = l + r >> 1;       pre[t][mid] > p || pre[t][mid] == 0 ? r = mid - 1                                           : (l = mid + 1, tmp = mid);     }     return tmp;   }   bool check(int st) {     memset(f, -1, sizeof(f));     int tmp = -1;     for (int i = 1; i <= n; i++) {       f[i][0] = 0;       for (int j = 0; j < (1 << 8); j++) {         if (j != (1 << 8) - 1) {           for (int k = 1; k <= 8; k++)             if (!(j & g[k]) && f[i][j] != -1) {               int p = pre[k][i - (a[i] == k)];               if (st == 0) tmp = max(tmp, f[i][j]);               if (kr[k][p + st] != 0)                 f[kr[k][p + st]][j | g[k]] =                     max(f[kr[k][p + st]][j | g[k]], f[i][j] + st);               if (kr[k][p + st + 1] != 0)                 f[kr[k][p + st + 1]][j | g[k]] =                     max(f[kr[k][p + st + 1]][j | g[k]], f[i][j] + st + 1);             }         } else if (f[i][j] != -1)           tmp = max(tmp, f[i][j]);       }     }     if (tmp != -1) {       ans = max(ans, tmp);       return true;     } else       return false;   }   int main() {     n = read();     for (int i = 1; i <= n; i++) {       a[i] = read();       for (int j = 1; j <= 8; j++) pre[j][i] = pre[j][i - 1] + (a[i] == j);       kr[a[i]][++cnt[a[i]]] = i;     }     int l = 0, r = n;     while (l <= r) {       int mid = l + r >> 1;       check(mid) ? l = mid + 1 : r = mid - 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[25] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29,                31, 37, 41, 43, 47, 4,  9,  25, 49};   int main() {     string s;     int num = 0;     for (int i = 0; i < 19; i++) {       printf( %d n , a[i]);       fflush(stdout);       cin >> s;       if (s ==  yes ) num++;     }     if (num <= 1)       printf( prime n );     else       printf( composite n );     fflush(stdout);   }
#include <bits/stdc++.h>   using namespace std;   const char IO_MODE = 3;   inline long long ReadInt() {     long long x = 0, s = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) s = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     return s * x;   }   inline void WriteInt(long long x) {     char c[20];     if (!x) {       putchar( 0 );       return;     }     if (x < 0) putchar( - ), x = -x;     int i = 0;     while (x > 0) c[++i] = x % 10, x /= 10;     while (i) putchar(c[i--] + 48);   }   template <typename T>   inline void out(T x) {     if (IO_MODE & 1)       WriteInt(x);     else if (typeid(x) == typeid(int))       printf( %i , x);     else       printf( %lld , (long long)x);   }   template <typename T, typename... Args>   inline void out(T x, Args... args) {     out(x);     putc(   , stdout);     out(args...);   }   template <typename T>   inline void in(T &x) {     if (IO_MODE & 2)       x = ReadInt();     else if (typeid(x) == typeid(int))       scanf( %i , &x);     else if (typeid(x) == typeid(long long))       scanf( %lld , &x);   }   template <typename T, typename... Args>   inline void in(T &x, Args &...args) {     in(x);     in(args...);   }   int tc;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c *x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug &operator<<(const c &) {       return *this;     }   };   vector<char *> tokenizer(const char *args) {     char *token = new char[111];     strcpy(token, args);     token = strtok(token,  ,  );     vector<char *> v({token});     while (token = strtok(NULL,  ,  )) v.push_back(token);     return reverse(v.begin(), v.end()), v;   }   void debugg(vector<char *> args) { cerr <<   b b  ; }   template <typename Head, typename... Tail>   void debugg(vector<char *> args, Head H, Tail... T) {     debug() <<   [  << args.back() <<  :   << H <<  ]  ;     args.pop_back();     debugg(args, T...);   }   long long n, A[100200];   long long check(long long x) {     if (!x) return 0;     for (long long i = 0; i < n; i++)       if (A[i] % x > A[i] / x) return 0;     return 1;   }   int32_t main() {     in(n);     for (long long i = 0; i < n; i++) in(A[i]);     sort(A, A + n);     long long x = A[0];     long long mx = 1;     for (long long i = 1; i * i <= x; i++) {       long long m = x / i;       if (x % i == 0) {         if (check(i - 1)) mx = max(mx, i - 1);         if (check(m - 1)) mx = max(mx, m - 1);         if (check(i)) mx = max(mx, i);         if (check(m)) mx = max(mx, m);       } else {         if (check(i)) mx = max(mx, i);         if (check(m)) mx = max(mx, m);       }     }     long long ans = 0;     for (long long i = 0; i < n; i++) ans += (A[i] + mx) / (mx + 1);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int i, t;   double a, b;   int main() {     cin >> t;     for (i = 0; i < t; i++) {       cin >> a >> b;       if (b == 0) {         cout << 1 << endl;         continue;       }       b *= 4;       if (a > b) {         cout << 1.0 - b / (4.0 * a) << endl;         continue;       }       cout << (a / 2.0 + b) / (2.0 * b) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t, n, k;     cin >> t;     while (t--) {       cin >> n;       int arr[n];       int c1 = 0;       for (int i = 0; i < n; i++) {         cin >> arr[i];         if (arr[i] == 1) c1++;       }       if (n - c1 >= c1) {         cout << n - c1 << endl;         for (int i = 0; i < n - c1; i++) {           cout <<  0  ;         }         cout << endl;       } else {         if (c1 % 2 == 0) {           cout << c1 << endl;           for (int i = 0; i < c1; i++) {             cout <<  1  ;           }           cout << endl;         } else {           cout << c1 - 1 << endl;           for (int i = 0; i < c1 - 1; i++) {             cout <<  1  ;           }           cout << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   long long a[N], n, seg[20][N];   void build(int xl = 0, int xr = n, int ind = 0) {     if (xr - xl == 1) {       seg[ind][xl] = a[xr] - a[xl];       return;     }     int xm = (xl + xr) / 2;     build(xl, xm, ind + 1);     build(xm, xr, ind + 1);     for (int i = xl; i < xm; i++) seg[ind][i] = a[xm] - a[i];     for (int i = xm; i < xr; i++) seg[ind][i] = a[i + 1] - a[xm];     sort(&seg[ind][xl], &seg[ind][xm]);     sort(&seg[ind][xm], &seg[ind][xr]);   }   inline long long GreaterThan(long long x, int xl = 0, int xr = n, int k = 1,                                int ind = 0) {     if (xr - xl == 1) return (seg[ind][xl] > x);     int xm = (xl + xr) / 2;     long long GreaterChild = GreaterThan(x, xl, xm, 2 * k, ind + 1) +                              GreaterThan(x, xm, xr, 2 * k + 1, ind + 1);     long long GreaterMid = 0;     int j = xr;     for (int i = xl; i < xm; i++) {       while (j > xm && seg[ind][j - 1] + seg[ind][i] > x) j--;       GreaterMid += xr - j;     }     return GreaterChild + GreaterMid;   }   int main() {     ios::sync_with_stdio(0);     long long k;     scanf( %lld %lld , &n, &k);     for (int i = 0; i < n; i++) scanf( %lld , &a[i + 1]);     for (int i = 1; i < n; i++) a[i + 1] += a[i];     build();     long long l = -1e14 - 7, r = 1e14 + 7;     while (r - l > 1) {       long long m = (l + r) / 2;       long long ans = GreaterThan(m);       if (ans >= k)         l = m;       else         r = m;     }     printf( %lld n , r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 500 + 10;   int R, C;   char pic[maxn][maxn];   bool vis[maxn][maxn];   int sr, sc, er, ec;   const int dr[] = {-1, 0, 1, 0};   const int dc[] = {0, 1, 0, -1};   bool ok(int r, int c) { return r >= 1 && r <= R && c >= 1 && c <= C; }   struct Node {     int r, c;     Node(int r = 0, int c = 0) : r(r), c(c) {}   };   bool bfs() {     memset(vis, 0, sizeof(vis));     queue<Node> Q;     Q.push(Node(sr, sc));     while (!Q.empty()) {       Node now = Q.front();       Q.pop();       int r = now.r, c = now.c;       pic[r][c] =  X ;       for (int i = 0; i < 4; ++i) {         int tr = r + dr[i];         int tc = c + dc[i];         if (tr == er && tc == ec) {           if (pic[tr][tc] ==  X ) return true;           for (int i = 0; i < 4; ++i) {             int ttr = tr + dr[i], ttc = tc + dc[i];             if (ok(ttr, ttc) && pic[ttr][ttc] ==  . ) return true;           }         }         if (ok(tr, tc) && !vis[tr][tc] && pic[tr][tc] ==  . ) {           vis[tr][tc] = 1;           Q.push(Node(tr, tc));         }       }     }     return false;   }   int main() {     scanf( %d %d , &R, &C);     for (int i = 1; i <= R; ++i) scanf( %s , pic[i] + 1);     scanf( %d %d %d %d , &sr, &sc, &er, &ec);     if (bfs())       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double majk;   double dp[8005][1005];   int visdp[8005][1005];   double solve(int n, int k) {     if (n == 0 && k == 0) return 1;     if (n == 0) return 0;     double sol = 0;     if (visdp[n][k]) return dp[n][k];     if (k) {       sol += solve(n - 1, k - 1) * ((double)k / majk);     }     sol += solve(n - 1, k) * ((double)(majk - k) / majk);     visdp[n][k] = 1;     return dp[n][k] = sol;   }   int main() {     int k, q;     cin >> k >> q;     majk = k;     solve(8000, k);     while (q--) {       double x;       double e = 1e-7;       cin >> x;       double lhs = (x - e) / 2000.0;       for (int i = k; i <= 8000; i++) {         if (solve(i, k) > lhs) {           cout << i <<   n ;           break;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long maxm = 0;   long long nmbr = INT_MAX;   map<long long, bool> vstd;   class graph {    public:     map<long long, list<pair<long long, long long>>> adj;     void input(long long n) {       long long x, y, z;       for (long long i = 1; i < n; i++) {         cin >> x >> y >> z;         adj[x].push_back(make_pair(y, z));         adj[y].push_back(make_pair(x, z));       }     }     void dfs(long long a, long long sum) {       vstd[a] = true;       for (auto j : adj[a]) {         long long nghbr = j.first;         long long wt = j.second;         if (!vstd[nghbr]) {           dfs(nghbr, sum + wt);         }       }       maxm = max(maxm, sum);     }   };   int main() {     graph g;     long long n;     cin >> n;     g.input(n);     g.dfs(0, 0);     cout << maxm;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     cin.sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     cin >> t;     while (t--) {       long long n, s;       cin >> n >> s;       long long half = n / 2;       half++;       cout << s / half << endl;     }     return 0;   }
#include <bits/stdc++.h>   int ff[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};   long long dp[16][9 + 1];   void solve(int *bb, int l) {     int k, d, i, e, j;     memset(dp, 0, sizeof dp);     k = ((l) < (bb[0]) ? (l) : (bb[0]));     for (i = 0; i <= k; i++) dp[0][i] = 1;     for (d = 0; d < 16 - 1; d++)       for (i = 0; i < l; i++)         if (dp[d][i] > 0)           for (e = d + 1; e < 16; e++) {             k = ((l) < (i + bb[e]) ? (l) : (i + bb[e]));             for (j = i + 1; j <= k; j++)               dp[e][j] += dp[d][i] * (ff[j] / ff[i] / ff[j - i]);           }   }   int main() {     static int bb[16];     static char cc[9 + 1];     int k, t, l, i, d, d_;     long long cnt;     scanf( %d%d , &k, &t);     for (i = 0; i < 16; i++) bb[i] = t;     l = 9;     solve(bb, l);     for (i = 1; i <= l; i++) {       cnt = 0;       for (d = 0; d < 16; d++) cnt += dp[d][i];       cnt = cnt / 16 * 15;       if (k > cnt)         k -= cnt;       else {         l = i;         break;       }     }     for (i = 1; i <= l; i++)       for (d_ = i == 1 ? 1 : 0; d_ < 16; d_++)         if (bb[d_] > 0) {           bb[d_]--;           solve(bb, l - i);           cnt = 0;           for (d = 0; d < 16; d++) cnt += dp[d][l - i];           if (k > cnt)             k -= cnt;           else {             cc[i - 1] = d_ < 10 ?  0  + d_ :  a  + d_ - 10;             break;           }           bb[d_]++;         }     printf( %s n , cc);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100001;   const long long mod = 1e9 + 7;   int main() {     int N, M;     scanf( %d %d , &N, &M);     int arr[M][2], nums[N];     for (int i = 0; i < N; i++) {       scanf( %d , &nums[i]);     }     for (int i = 0; i < M; i++) {       scanf( %d %d , &arr[i][0], &arr[i][1]);       arr[i][0]--;       arr[i][1]--;     }     int a = 0, b = 0;     int res, ans = 0;     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) {         res = 0;         for (int k = 0; k < M; k++) {           if (arr[k][0] <= i && arr[k][1] >= i &&               !(arr[k][0] <= j && arr[k][1] >= j)) {             res++;           }         }         if (res + nums[j] - nums[i] > ans) {           a = i;           b = j;         }         ans = max(ans, res + nums[j] - nums[i]);       }     }     printf( %d n , ans);     vector<int> ans2;     for (int k = 0; k < M; k++) {       if (arr[k][0] <= a && arr[k][1] >= a &&           !(arr[k][0] <= b && arr[k][1] >= b)) {         ans2.push_back(k + 1);       }     }     printf( %d n , ans2.size());     for (int i : ans2) {       printf( %d  , i);     }   }
#include <bits/stdc++.h>   using namespace std;   set<int> s;   map<long long, int> m1, m2;   int main() {     int n, n2, k;     cin >> n >> n2 >> k;     for (int i = 0; i < n; i++) {       int q;       cin >> q;       m1[q]++;       s.insert(q);     }     for (int i = 0; i < n2; i++) {       int q;       cin >> q;       m2[q]++;       s.insert(q);     }     vector<int> difs;     while (!s.empty()) {       int q = *s.begin();       difs.push_back(m1[q] - m2[q]);       s.erase(s.begin());     }     int sum = 0;     for (int i = difs.size() - 1; i >= 0; i--) {       sum += difs[i];       if (sum > 0) return 0 * bool(cout <<  YES  << endl);     }     cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 2e5 + 10;   long long n, T, fac[MAXN], a[MAXN], inv[MAXN], b[MAXN], ans, mod = 1e9 + 7;   long long read() {     long long sss = 0, fff = 1;     char ccc;     ccc = getchar();     while (ccc <  0  || ccc >  9 ) {       if (ccc ==  - ) fff = -1;       ccc = getchar();     }     while (ccc >=  0  && ccc <=  9 )       sss = (sss << 1) + (sss << 3) + (ccc ^  0 ), ccc = getchar();     return sss * fff;   }   long long ksm(long long base, long long k) {     long long sum = 1;     while (k) {       if (k & 1) sum = sum * base % mod;       base = base * base % mod;       k >>= 1;     }     return sum;   }   long long C(long long n, long long m) {     if (n < m) return 0;     return fac[n] * inv[n - m] % mod * inv[m] % mod;   }   int main() {     n = read();     T = read();     for (long long i = 1; i <= n; i++) a[i] = read();     b[n] = ksm(2, n);     b[n] = ksm(b[n], mod - 2);     for (long long i = n - 1; i >= 0; i--) b[i] = b[i + 1] * 2 % mod;     fac[0] = 1;     for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;     inv[n] = ksm(fac[n], mod - 2);     for (int i = n - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;     long long now = 0;     bool flag = true;     long long TT, sum = 0, CCC;     while (now <= n && T >= a[now + 1]) {       now++, T -= a[now];       if (now <= T)         ans = (ans + 1) % mod;       else {         if (flag) {           TT = T;           CCC = now;           for (long long i = 0; i <= TT; i++) sum = (sum + C(now, i)) % mod;         } else           sum = (sum * 2 % mod - C(now - 1, TT) + mod) % mod;         flag = false;         while (TT > T) {           sum = (sum - C(now, TT) + mod) % mod;           TT--;         }         ans = (ans + sum * b[now] % mod) % mod;       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, i, flag, ans, index, j;     int a[4000], b[4000];     cin >> n >> m;     for (i = 0; i < n; i++) cin >> a[i];     for (i = 0; i < m; i++) cin >> b[i];     ans = 0;     for (i = n; i >= 0; i--) {       flag = 0;       for (j = m; j >= 0; j--) {         if (a[i] <= b[j]) {           flag = 1;           b[j] = 0;           break;         }       }       if (flag == 0) ans = ans + 1;     }     cout << ans;     return 0;   }