malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long modpow(long long a, long long p, long long mod) {     long long ret = 1;     while (p) {       if (p & 1) ret = (ret * a) % mod;       a = (a * a) % mod;       p /= 2;     }     return ret;   }   long long power(long long a, long long p) {     long long ret = 1;     while (p) {       if (p & 1) ret = (ret * a);       a = (a * a);       p /= 2;     }     return ret;   }   int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }   int main() {     int i, j, k, tmp;     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int n, m;     cin >> n >> m;     vector<pair<int, int> > f(n);     vector<int> b(m);     vector<int> f1(n);     int fch[100010] = {0};     int fin[100010] = {0};     for (i = 0; i < n; i++) {       cin >> j;       f[i] = make_pair(j, i);       f1[i] = j;       fch[j] += 1;       fin[j] = i;     }     for (i = 0; i < m; i++) {       cin >> b[i];     }     vector<int> a(m);     int flam = 0;     int flim = 0;     for (i = 0; i < m; i++) {       if (fch[b[i]] == 0) {         flim = 1;       }       if (fch[b[i]] > 1) {         flam = 1;       }       a[i] = fin[b[i]] + 1;     }     if (flim == 1) {       cout <<  Impossible  << endl;       return 0;     }     if (flam == 1) {       cout <<  Ambiguity  << endl;       return 0;     }     cout <<  Possible  << endl;     for (i = 0; i < m; i++) cout << a[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 501010;   int n, k;   int a[maxn], b[maxn];   long long s;   int cnt;   priority_queue<pair<int, int> > q;   void Check(int d) {     s = 0;     cnt = 0;     for (int i = 1; i <= n; ++i) {       q.push(make_pair(d - a[i], 0));       int tmp = b[i] - q.top().first;       if (tmp < 0) {         s += tmp;         if (!q.top().second) ++cnt;         q.pop();         q.push(make_pair(b[i], 1));       }     }     while (q.size()) q.pop();   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; ++i) scanf( %d , a + i);     for (int i = 1; i <= n; ++i) scanf( %d , b + i);     long long l = 0, r = 2e9, mid;     while (l < r) {       mid = (l + r) >> 1;       Check(mid);       if (cnt < k)         l = mid + 1;       else         r = mid;     }     Check(l);     printf( %lld n , s + 1ll * l * k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y / 2;       x = (x * x) % p;     }     return res;   }   void solve() {     long long int n, m, l, h, i;     cin >> n >> m;     l = 0;     h = n * m - 1;     while (l < h) {       cout << l / m + 1 <<     << l % m + 1 <<   n ;       cout << h / m + 1 <<     << h % m + 1 <<   n ;       ++l, --h;     }     if (l == h) cout << l / m + 1 <<     << l % m + 1 <<   n ;   }   int main() {     long long int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void read_file(bool outToFile = true) {}   int n, m;   bool vis[500 + 9][500 + 9];   string s;   int l;   int x, y;   int ans[100000 + 1 + 9];   string alpha =  *URDL ;   int dij[5][2] = {{0, 0}, {-1, 0}, {0, +1}, {+1, 0}, {0, -1}};   bool valid(int i, int j) { return 0 <= i && i < n && 0 <= j && j < m; }   int main() {     read_file();     while (scanf( %d%d , &n, &m) != EOF) {       scanf( %d%d , &x, &y);       x--, y--;       memset(vis, 0, sizeof vis);       cin >> s;       s =  *  + s;       l = s.length();       for (int i = 0; i < l - 1; i++) {         int nx, ny;         nx = x + dij[alpha.find(s[i])][0];         ny = y + dij[alpha.find(s[i])][1];         if (!valid(nx, ny)) {           ans[i] = 0;           continue;         }         x = nx, y = ny;         if (!vis[x][y]) {           vis[x][y] = 1;           ans[i] = 1;         } else           ans[i] = 0;       }       int cnt = n * m;       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++) cnt -= vis[i][j];       ans[l - 1] = cnt;       for (int i = 0; i < l; i++) printf( %d%c , ans[i],    n [i == l - 1]);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (scanf( %d , &n) == 1) {       if (n == 1)         printf( -1 n );       else if (n == 2) {         printf( 2 2 n );       } else if (n == 4)         printf( 4 2 n );       else {         int a, b;         if (n % 2 == 0) {           a = n - 2;           b = 2;         } else {           a = n - 1;           b = 2;         }         printf( %d %d n , a, b);       }     }     return 0;   }
#include <bits/stdc++.h>   template <typename T>   inline void read(T& x) {     T res = 0, flag = 1;     char ch;     ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) flag = -1;       ch = getchar();     }     while (isdigit(ch)) {       res = res * 10 + ch - 48;       ch = getchar();     }     x = res * flag;   }   const long long INF = 1LL << 32;   int l;   long long ans, x;   char buf[10];   std::stack<long long> s;   int main() {     read(l);     s.push(1);     for (int i = 1; i <= l; ++i) {       scanf( %s , buf);       if (buf[0] ==  a )         ans += s.top();       else if (buf[0] ==  e )         s.pop();       else {         read(x);         s.push(std::min(INF, x * s.top()));       }     }     if (ans >= INF)       puts( OVERFLOW!!! );     else       printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int n, x;   vector<int> v[1005], a[1005];   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> x;       a[x].push_back(i);       v[i].resize(n + 1, 0);     }     int st = -1;     for (int i = n; i >= 1; --i) {       for (int k : a[i]) {         st++;         int cur = st;         for (int j = 1; j <= i; ++j) {           v[k][cur] = 1;           cur++;           cur %= (n + 1);         }       }     }     cout << n + 1 <<   n ;     for (int i = 0; i < n + 1; ++i) {       for (int j = 1; j <= n; ++j) cout << v[j][i];       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class solution {    public:     void solve() {       int n;       cin >> n;       int i = 1;       int prev = 0;       vector<int> sol;       while (n != 0) {         if (n > prev) {           prev++;           sol.push_back(prev);           n = n - prev;         } else {           sol[prev - 1] = sol[prev - 1] + n;           n = 0;         }       }       cout << sol.size() <<   n ;       for (auto it : sol) {         cout << it <<    ;       }     }   };   int main() {     ios::sync_with_stdio(0), cout.tie(0), cin.tie(0);     long long i = 0;     solution second;     second.solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 10;   const long long mod = 1e9 + 7;   long long n, m;   long long fac[maxn];   long long ksm(long long a, long long b) {     long long ans = 1, base = a % mod;     while (b) {       if (b & 1) ans = ans * base % mod;       base = base * base % mod;       b >>= 1;     }     return ans % mod;   }   long long C(int x, int y) {     return fac[x] * ksm(fac[y] * fac[x - y] % mod, mod - 2) % mod;   }   int main() {     cin >> n >> m;     fac[0] = 1;     for (int i = 1; i <= m * 2 + n + 1; ++i) fac[i] = fac[i - 1] * i % mod;     cout << C(n + m * 2 - 1, n - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char *argv[]) {     int n;     unsigned int a[200];     unsigned int ans;     scanf( %d , &n);     ans = 0;     for (int i = 0; i < n; i++) scanf( %u , &a[i]);     for (int i = 0; i < n; i++) {       unsigned int temp = a[i];       if (temp > ans) ans = temp;       for (int j = i + 1; j < n; j++) {         temp = temp ^ a[j];         if (temp > ans) ans = temp;       }     }     printf( %u n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void result() {}   string resultstr() {     string ans;     return ans;   }   int resultint() {     int ans;     return ans;   }   long long resultlong(long long n) {     long long c5;     return c5;   }   bool checkValidity(long long a, long long b, long long c) {     if (a + b <= c || a + c <= b || b + c <= a)       return false;     else       return true;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t;     cin >> t;     while (t--) {       long long cnt = 0;       string s;       vector<long long> v;       cin >> s;       for (int i = 0; i < s.length(); i++) {         if (s.at(i) ==  1 ) {           cnt++;         } else if (s.at(i) ==  0 ) {           v.push_back(cnt);           cnt = 0;         }       }       v.push_back(cnt);       sort(v.begin(), v.end(), greater<int>());       ;       long long sum = 0;       for (int i = 0; i < v.size(); i = i + 2) {         sum += v[i];       }       cout << sum <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int C = 500001;   vector<vector<int> > gr(C), E(C);   int ij[C], ji[C], a, b, n, m;   int s[C], sE[C], low[C], pre[C], nV[C], nE[C], par[C], cor[C], corn;   bool ch[C], chE[C];   int main() {     int i, j, is = 1, iE = 0, iV = 1, ip = 2, k, e, vn, en;     scanf( %d %d , &n, &m);     for (int z = 0; z < m; z++)       scanf( %d %d , &a, &b), gr[a].push_back(b), gr[b].push_back(a),           E[a].push_back(z), E[b].push_back(z), ij[a]++, ij[b]++;     for (i = 1; i <= n; i++) ji[i] = ij[i];     for (j = 1; j <= n; j++) {       if (ch[j] == 0) {         s[0] = j, ch[j] = 1;         low[j] = pre[j] = 1, iV = 1, iE = 0, ip = 2, is = 1;         while (is > 0) {           a = s[is - 1];           if (ij[a] > 0) k = gr[a][ij[a] - 1], e = E[a][ij[a] - 1];           if (ij[a] > 0 && ch[gr[a][ij[a] - 1]] == 1) {             if (chE[e] == 0) {               chE[e] = 1;               sE[iE] = e, iE++;             }             if (k != par[a]) low[a] = min(low[a], pre[k]);             ij[a]--;           } else if (ij[a] > 0 && ch[gr[a][ij[a] - 1]] == 0) {             ch[k] = 1, chE[e] = 1;             par[k] = a;             nV[k] = iV, nE[k] = iE, iV++;             sE[iE] = e, iE++;             s[is] = k, low[k] = pre[k] = ip, is++, ip++;             ij[a]--;           } else {             if (low[par[a]] > low[a]) low[par[a]] = low[a];             if (low[a] >= pre[par[a]]) {               vn = iV - nV[a] + 1, en = iE - nE[a];               if (en == vn) {                 for (i = nE[a]; i < iE; i++) cor[sE[i]] = 1, corn++;               }               iV = nV[a], iE = nE[a];             }             is--;           }         }       }     }     printf( %d n , corn);     for (i = 0; i < m; i++)       if (cor[i] == 1) printf( %d  , i + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200005;   bool r[MAXN];   int main() {     int n;     vector<pair<int, pair<int, int>>> v;     cin >> n;     for (int i = 0; i < n; ++i) {       int l, r;       cin >> l >> r;       v.emplace_back(l, make_pair(1, i));       v.emplace_back(r + 1, make_pair(0, i));     }     sort(v.begin(), v.end());     set<int> s;     for (int i = 0; i < v.size(); ++i) {       while (i < v.size()) {         if (v[i].second.first == 1) s.insert(v[i].second.second);         if (v[i].second.first == 0) s.erase(s.find(v[i].second.second));         if (v[i].first == v[i + 1].first)           i++;         else           break;       }       if (s.size() == 1) r[*s.begin()] = 1;     }     for (int i = 0; i < n; ++i) {       if (r[i] == 0) {         cout << i + 1 << endl;         return 0;       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int qp(int a, long long b) {     int ans = 1;     do {       if (b & 1) ans = 1ll * ans * a % 1000000007;       a = 1ll * a * a % 1000000007;     } while (b >>= 1);     return ans;   }   int ans[222222], atot = 0;   char s[222222], t[222222];   long long ct[26];   int n, m;   long long cs[26];   int sd = 10007;   map<pair<long long, long long>, int> ma;   long long ps[222222];   int test() {     ma.clear();     for (int i = 0; i < 26; i++) {       if (cs[i] == ct[i]) continue;       if (ma[make_pair(ct[i], cs[i])])         ma[make_pair(ct[i], cs[i])]--;       else         ma[make_pair(cs[i], ct[i])]++;     }     for (map<pair<long long, long long>, int>::iterator it = ma.begin();          it != ma.end(); it++) {       if (it->second) return 0;     }     return 1;   }   int main() {     ps[0] = 1;     for (int i = 1; i <= 211111; i++) ps[i] = ps[i - 1] * sd;     scanf( %d%d , &n, &m);     scanf( %s , s + 1);     scanf( %s , t + 1);     for (int i = 1; i <= m; i++) ct[t[i] -  a ] += ps[m - i + 1];     for (int i = 1; i <= m; i++) cs[s[i] -  a ] += ps[m - i + 1];     for (int i = 1; i + m - 1 <= n; i++) {       if (test()) ans[++atot] = i;       cs[s[i] -  a ] -= ps[m];       for (int j = 0; j < 26; j++) cs[j] *= sd;       cs[s[i + m] -  a ] += ps[1];     }     printf( %d n , atot);     for (int i = 1; i <= atot; i++) printf( %d  , ans[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool chmax(T &a, const T &b) {     return b > a ? a = b, true : false;   }   template <class T>   inline bool chmin(T &a, const T &b) {     return b < a ? a = b, true : false;   }   template <class T>   using MaxHeap = priority_queue<T>;   template <class T>   using MinHeap = priority_queue<T, vector<T>, greater<T>>;   template <class T, class F = less<T>>   void sort_uniq(vector<T> &v, F f = F()) {     sort(begin(v), end(v), f);     v.resize(unique(begin(v), end(v)) - begin(v));   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int tt;     cin >> tt;     while (tt--) {       int n;       cin >> n;       vector<int> a(n);       for (int i = 0; i < (int)(n); i++) cin >> a[i];       int last = a[0], alice = a[0], bob = 0;       int i = 1, j = n - 1, turn = 1, moves = 1;       while (i <= j) {         int cnt = 0;         if (turn) {           while (i <= j && cnt <= last) {             cnt += a[j--];           }           bob += cnt;         } else {           while (i <= j && cnt <= last) {             cnt += a[i++];           }           alice += cnt;         }         last = cnt;         moves++;         turn ^= 1;       }       cout << moves <<     << alice <<     << bob <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[2 * 100000 + 5];   int k, n;   long long dp[2][2 * 100000 + 5];   int mark[2 * 100000 + 5];   inline long long solve(int i, int lst) {     if (i == 0) {       if (lst == 1)         return 1ll;       else         return 0ll;     }     long long &ret = dp[lst][i];     if (ret != -1ll) return ret;     ret = 0ll;     if (lst == 0)       ret = (((k - 1) * 1ll) * solve(i - 1, 1)) % 998244353;     else {       long long tem = (k - 2) * 1ll;       tem = (tem * solve(i - 1, 1)) % 998244353;       tem = (tem + solve(i - 1, 0)) % 998244353;       ret = tem;     }     return ret;   }   inline int getNext(int i) {     for (int j = i + 2;; j += 2) {       if (a[j] != -1) return j;     }   }   inline long long pwr(int x, int p) {     if (p == 0) return 1ll;     if (p & 1) return ((1ll * x) * pwr(x, p - 1)) % 998244353;     long long ret = pwr(x, p / 2);     return (ret * ret) % 998244353;   }   int main() {     scanf( %d %d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     a[n] = 10000000;     a[n + 1] = 10000000;     for (int i = 0; i < n; i++) {       if (a[i] == a[i + 2] && a[i] != -1) {         printf( 0 n );         return 0;       }     }     memset((dp), (-1), sizeof((dp)));     ;     long long ans = 1ll;     for (int i = 0; i < n; i++) {       if (a[i] == -1) {         if (i == 0 || i == 1) {           int nxt = getNext(i);           int pl = (nxt - i) / 2;           if (nxt >= n) {             ans = (ans * ((pwr(k - 1, pl - 1)) % 998244353)) % 998244353;             ans = (ans * (k * 1ll)) % 998244353;             continue;           }           ans = (ans * ((pwr(k - 1, pl)) % 998244353)) % 998244353;           continue;         }         if (a[i - 2] == -1) continue;         int nxt = getNext(i);         if (nxt >= n) {           int pl = (nxt - i) / 2;           ans = (ans * pwr(k - 1, pl)) % 998244353;         } else {           if (a[i - 2] == a[nxt]) {             int pl = (nxt - i) / 2;             ans = (ans * (k - 1ll)) % 998244353;             ans = (ans * solve(pl - 1, 1)) % 998244353;           } else {             int pl = (nxt - i) / 2;             long long tem;             tem = (k - 2ll) % 998244353;             tem = (tem * solve(pl - 1, 1)) % 998244353;             tem = (tem + (solve(pl - 1, 0))) % 998244353;             ans = (tem * ans) % 998244353;           }         }       }     }     printf( %lld n , ans);     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int tree[300000];   int ar[100005];   int make(int l, int r, int ind) {     if (l >= r) {       tree[ind] = ar[r];       return tree[ind];     }     int mid = (l + r) / 2;     tree[ind] = make(l, mid, 2 * ind + 1) + make(mid + 1, r, 2 * ind + 2);     return tree[ind];   }   int query(int ql, int qr, int l, int r, int ind) {     if (ql <= l && qr >= r) {       return tree[ind];     }     if (qr < l || ql > r) return 0;     int mid = (l + r) / 2;     return query(ql, qr, l, mid, 2 * ind + 1) +            query(ql, qr, mid + 1, r, 2 * ind + 2);   }   int main() {     int n, i, q, l, r;     cin >> n;     for (i = 0; i < n; i++) {       cin >> ar[i];     }     make(0, n - 1, 0);     cin >> q;     while (q--) {       cin >> l >> r;       cout << query((l - 1), (r - 1), 0, n - 1, 0) / 10 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   void dout() { cerr << endl; }   template <typename Head, typename... Tail>   void dout(Head H, Tail... T) {     cerr << H <<    ;     dout(T...);   }   mt19937 rnd(time(0));   struct Node {     Node* left = nullptr;     Node* right = nullptr;     int prior;     int size = 1;     double val;     double sleft;     double sright;     double sum;     double mss;     Node(double v)         : prior(rnd()),           val(v),           sleft(max(0.0, v)),           sright(max(0.0, v)),           sum(v),           mss(max(0.0, v)) {}   };   int _size(Node* n) { return n ? n->size : 0; }   double _sleft(Node* n) { return n ? n->sleft : 0; }   double _sright(Node* n) { return n ? n->sright : 0; }   double _sum(Node* n) { return n ? n->sum : 0; }   double _mss(Node* n) { return n ? n->mss : 0; }   void update(Node* n) {     n->size = _size(n->left) + _size(n->right) + 1;     n->sum = _sum(n->left) + _sum(n->right) + n->val;     n->sleft = max(_sleft(n->left), _sum(n->left) + n->val + _sleft(n->right));     n->sright =         max(_sright(n->right), _sum(n->right) + n->val + _sright(n->left));     n->mss = max({_mss(n->left), _mss(n->right),                   _sright(n->left) + n->val + _sleft(n->right)});   }   struct Treap {     Node* root = nullptr;     pair<Node*, Node*> split(Node* n, int index) {       if (!n) return make_pair(nullptr, nullptr);       int sz = _size(n->left) + 1;       if (index < sz) {         auto [l, r] = split(n->left, index);         n->left = r;         update(n);         return make_pair(l, n);       } else {         auto [l, r] = split(n->right, index - sz);         n->right = l;         update(n);         return make_pair(n, r);       }     }     Node* merge(Node* l, Node* r) {       if (!l || !r) return l ? l : r;       if (l->prior > r->prior) {         l->right = merge(l->right, r);         update(l);         return l;       } else {         r->left = merge(l, r->left);         update(r);         return r;       }     }     void push_back(double v) { root = merge(root, new Node(v)); }     double max_subarray_sum(int left, int right) {       auto [x, r] = split(root, right);       auto [l, m] = split(x, left);       double ans = _mss(m);       root = merge(l, merge(m, r));       return ans;     }   };   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int n, m, c;     cin >> n >> m >> c;     vector<double> x(n);     for (int i = 0; i < n; i++) {       cin >> x[i];     }     vector<double> p(n);     for (int i = 1; i < n; i++) {       cin >> p[i];       p[i] /= 100.0;     }     Treap treap;     treap.push_back(0);     for (int i = 1; i < n; i++) {       treap.push_back((x[i] - x[i - 1]) * 0.5 - p[i] * c);     }     double ans = 0.0;     for (int i = 0; i < m; i++) {       int l, r;       cin >> l >> r;       ans += treap.max_subarray_sum(l, r);     }     cout << fixed << setprecision(9) << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-10;   const int inf = 0x3f3f3f3f;   const long long INF = 1e18;   const int maxn = 200000 + 10;   const int maxm = 1000000000 + 7;   const int mod = 1000000000 + 7;   int gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   inline long long read() {     char ch = getchar();     long long x = 0, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n, m;   long long a[maxn];   long long num[maxn];   int main() {     int T = read();     while (T--) {       n = read();       for (int i = 1; i <= n; ++i) a[i] = read(), num[i] = 0;       m = read();       for (int i = 1; i <= m; ++i) {         long long x = read(), y = read();         num[y] = max(num[y], x);       }       for (int i = n - 1; i >= 1; --i) {         num[i] = max(num[i], num[i + 1]);       }       bool ok = true;       int ans = 1;       int pos = 1;       long long maxx = 0;       for (int i = 1; i <= n; ++i) {         maxx = max(maxx, a[i]);         int len = i - pos + 1;         if (num[len] < maxx) {           ans++;           pos = i;           maxx = a[i];         }         if (num[1] < a[i]) ok = false;       }       if (ok)         printf( %d n , ans);       else         puts( -1 );     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[5005];   long long dp[5005], mod = 998244353, bnd[5005], fac[5005], inv[5005];   long long qpow(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % mod;       b >>= 1;       a = a * a % mod;     }     return ans;   }   int main() {     int T = 1;     while (T--) {       int n;       cin >> n;       fac[0] = inv[0] = 1;       for (int i = 1; i <= n; i++)         scanf( %lld , &a[i]), fac[i] = fac[i - 1] * i % mod,                               inv[i] = qpow(fac[i], mod - 2);       sort(a + 1, a + n + 1);       if (a[n - 1] * 2LL > a[n]) {         puts( 0 );         continue;       }       for (int i = 1; i <= n; i++)         for (int j = 1; j < i; j++)           if (a[j] * 2 <= a[i]) bnd[i]++;       for (int i = 1; i <= n; i++)         for (int j = 0; j <= bnd[i]; j++) {           if (j == 0)             dp[i] += fac[n - 1] * inv[n - 1 - bnd[i]] % mod;           else             dp[i] += dp[j] * fac[n - bnd[j] - 2] % mod *                      inv[n - bnd[j] - 2 - (bnd[i] - bnd[j] - 1)] % mod,                 dp[i] %= mod;         }       printf( %lld n , dp[n]);     }     return 0;   }
#include <bits/stdc++.h>   bool debug = 1;   const long long MOD = 1000000007;   const double PI = acos(-1.0);   const double eps = 1e-9;   using namespace std;   int main() {     int n, m;     int c[100100], a[100100];     cin >> n >> m;     for (int i = 0; i < n; i++) {       scanf( %d , &c[i]);     }     for (int i = 0; i < m; i++) {       scanf( %d , &a[i]);     }     int j = 0;     for (int i = 0; i < n; i++) {       if (j < m and c[i] <= a[j]) j++;     }     cout << j << endl;     return 0;   }