malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e4 + 100;   int a[25];   int ans[25];   map<int, int> mp;   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       ans[i] = a[i];     }     sort(ans, ans + n);     for (int i = 0; i < n; i++) {       if (i == 0)         mp[ans[i]] = ans[n - 1];       else         mp[ans[i]] = ans[i - 1];     }     for (int i = 0; i < n; i++) printf( %d  , mp[a[i]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a;     cin >> n >> a;     vector<int> vi(n);     for (int i = 0; i < n; ++i) cin >> vi[i];     sort((vi).begin(), (vi).end());     if (n == 1)       cout << 0;     else if (a <= vi[0])       cout << llabs(vi[n - 2] - a);     else if (a >= vi[n - 1])       cout << llabs(vi[1] - a);     else {       long long ans1, ans2, ans3, ans4;       ans1 = llabs(vi[0] - a) + llabs(vi[0] - vi[n - 2]);       ans2 = llabs(vi[1] - a) + llabs(vi[1] - vi[n - 1]);       ans3 = llabs(vi[n - 1] - a) + llabs(vi[n - 1] - vi[1]);       ans4 = llabs(vi[n - 2] - a) + llabs(vi[n - 2] - vi[0]);       cout << min(min(ans1, ans2), min(ans3, ans4));     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int m[11];   int dig(int i) {     while (i) {       if (m[i % 10]) return 1;       i /= 10;     }     return 0;   }   int main() {     int n, i, s(0);     cin >> n;     int temp = n;     for (int i = 0; i < 11; i++) m[i] = 0;     while (temp) {       m[temp % 10] = 1;       temp /= 10;     }     for (int i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         s += dig(i);         if (i != sqrt(n)) s += dig(n / i);       }     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, a, b, ans;     cin >> n >> a >> b;     if (b > 0) {       ans = (a + b) % n;       if (ans == 0) ans = n;     } else if (b < 0) {       if (a > abs(b)) {         ans = a - abs(b);       } else {         ans = n - abs(a + b) % n;       }     } else       ans = a;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     map<char, int> ma;     int p;     char a, k[1000];     cin >> p;     for (int i = 0; i < p; i++) {       cin >> k[i];       a = tolower(k[i]);       ma[a]++;     }     if (ma.size() == 26)       cout <<  YES  << endl;     else       cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long oo = 3e18, M = 54;   long long q, n, k;   string F =        What are you doing at the end of the world? Are you busy? Will you save          us? ;   string X =  What are you doing while sending   ;   string Y =   ? Are you busy? Will you send   ;   string Z =   ? ;   long long length(int n) {     if (n >= M) {       return oo;     }     long long tot = X.size() + Y.size() + Z.size();     long long len = ((1LL << n) - 1) * tot + (1LL << n) * F.size();     return len;   }   char solve(long long i, long long k) {     if (i == 0) {       return k > F.size() ?  .  : F[k - 1];     }     long long len = length(i - 1);     if (X.size() + len + Y.size() + len + Z.size() < k) {       return  . ;     } else if (X.size() + len + Y.size() + len < k) {       k -= X.size() + len + Y.size() + len;       return Z[k - 1];     } else if (X.size() + len + Y.size() < k) {       k -= X.size() + len + Y.size();       return solve(i - 1, k);     } else if (X.size() + len < k) {       k -= X.size() + len;       return Y[k - 1];     } else if (X.size() < k) {       k -= X.size();       return solve(i - 1, k);     } else {       return X[k - 1];     }   }   int main() {     cin >> q;     while (q--) {       cin >> n >> k;       cout << solve(n, k);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 7;   const double eps = 1e-9;   int a[maxn];   int main() {     std::ios::sync_with_stdio(false);     int n, sum = 0;     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];     sort(a, a + n);     int ans = 0;     while (fabs(round(1.0 * sum / n) - 5.0) > eps) {       sum += 5 - a[0];       ++ans;       a[0] = 5;       sort(a, a + n);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( unroll-loops )   using namespace std;   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long n, m, p;     cin >> n >> m >> p;     vector<long long> a(n);     for (long long i = 0; i < n; ++i) cin >> a[i];     vector<long long> b(m);     for (long long i = 0; i < m; ++i) cin >> b[i];     for (long long i = 0; i < n; ++i) {       bool flag = false;       if (a[i] % p != 0) {         for (long long j = 0; j < m; ++j) {           if (b[j] % p != 0) {             flag = true;             cout << i + j;             break;           }         }         if (flag) {           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using std::ios;   constexpr int MOD = 1e9 + 7;   constexpr int mod = 998244353;   template <typename T>   T power(T a, T b) {     T r = 1;     while (b) {       if (b & 1) r *= a;       b /= 2;       a *= a;     }     return r;   }   int d[100005];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int tt = 1;     while (tt--) {       int n;       cin >> n;       vector<int> b(n), d(n);       map<int, int> ans;       for (int i = 0; i < n; i++) {         cin >> b[i] >> d[i];         ans[b[i]]++;         ans[d[i]]--;       }       int mx = 0, id = 0;       int sum = 0;       for (auto i : ans) {         i.second += sum;         sum = i.second;         if (i.second > mx) {           mx = i.second;           id = i.first;         }       }       cout << id <<     << mx;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int i = 0; i < t; i++) {       int n;       string s;       cin >> n;       cin >> s;       int flag = 0;       int p = n / 2;       p = p - 1;       for (int i = 0; i <= p; i++) {         if ((abs(s[i] - s[n - 1 - i]) != 2) && (s[i] != s[n - 1 - i])) {           cout <<  NO  << endl;           flag = 1;           break;         }       }       if (flag == 1) {         continue;       }       cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int o[100100];   int ans[6000100];   int main() {     int i, j, n;     int e = 0;     long long x, y;     long long m, tmp, st, ed, mid;     scanf( %d %I64d , &n, &m);     for (i = 1; i <= n; i++) scanf( %d , &o[i]);     sort(o + 1, o + n + 1);     o[0] = 0;     o[n + 1] = 1000000001;     for (i = 0; i <= n; i++) {       x = o[i] + 1;       y = o[i + 1] - 1;       if (x <= y) {         tmp = ((x + y) * (y - x + 1)) >> 1;         if (m - tmp >= 0) {           m -= tmp;           for (j = x; j <= y; j++) ans[e++] = j;         } else {           st = x;           ed = y;           while (st < ed) {             mid = (st + ed) >> 1;             tmp = ((x + mid) * (mid - x + 1)) >> 1;             if (tmp <= m)               st = mid + 1;             else               ed = mid;           }           st--;           tmp = 0;           if (x <= st) {             tmp = ((x + st) * (st - x + 1)) >> 1;             m -= tmp;             for (j = x; j <= st; j++) ans[e++] = j;           }         }       }     }     printf( %d n , e);     for (i = 0; i < e; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 110;   int n, m, x, y, c[maxn];   int lowbit(int x) { return x & -x; }   void add(int x, int k) {     for (; x <= n; x += lowbit(x)) {       c[x] += k;     }   }   int Query(int x) {     int ans = 0;     for (; x; x -= lowbit(x)) {       ans += c[x];     }     return ans;   }   int main() {     scanf( %d%d , &n, &m);     while (m--) {       scanf( %d%d , &x, &y);       add(x, 1), add(y + 1, -1);     }     for (int i = 1; i <= n; ++i) {       if (Query(i) != 1) {         printf( %d %d , i, Query(i));         return 0;       }     }     puts( OK );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 10;   int n, m, q, v[maxn], lp[maxn];   vector<int> e[maxn], t[maxn];   vector<long long> ps[maxn];   int mx, argmx;   void dfs(int id, int p, int d, int cpn) {     if (cpn) v[id] = cpn;     lp[id] = max(lp[id], d);     if (d > mx) {       mx = d;       argmx = id;     }     if (cpn) t[cpn].push_back(lp[id]);     for (int i = 0; i < e[id].size(); i++)       if (e[id][i] != p) dfs(e[id][i], id, d + 1, cpn);   }   int main() {     scanf( %d %d %d , &n, &m, &q);     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d %d , &x, &y);       e[x].push_back(y);       e[y].push_back(x);     }     int cpn = 0;     for (int i = 1; i <= n; i++)       if (!v[i]) {         mx = -1;         dfs(i, 0, 0, 0);         mx = -1;         dfs(argmx, 0, 0, 0);         mx = -1;         dfs(argmx, 0, 0, ++cpn);         sort(t[cpn].begin(), t[cpn].end());         ps[cpn].push_back(0);         for (int j = 0; j < t[cpn].size(); j++)           ps[cpn].push_back(ps[cpn].back() + t[cpn][j]);       }     map<pair<int, int>, double> res;     for (int i = 0; i < q; i++) {       int x, y;       scanf( %d %d , &x, &y);       x = v[x];       y = v[y];       if (x == y)         printf( -1 n );       else {         if (t[x].size() > t[y].size()) swap(x, y);         if (!res.count({x, y})) {           auto ans = 0LL;           int mxd = max(t[x].back(), t[y].back());           for (int j = 0; j < t[x].size(); j++) {             int l = lower_bound(t[y].begin(), t[y].end(), mxd - 1 - t[x][j]) -                     t[y].begin();             ans += 1LL * l * mxd + 1LL * (t[y].size() - l) * (t[x][j] + 1) +                    ps[y].back() - ps[y][l];           }           res.insert({{x, y}, ans * 1.0 / t[x].size() / t[y].size()});         }         printf( %.10lf n , res[{x, y}]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1, ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline void write(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10) write(x / 10);     putchar(x % 10 +  0 );   }   inline void writeln(long long x) {     write(x);     puts(  );   }   const long long N = 5e5 + 5;   long long q, sum[N], a[N], cnt;   inline double f(long long x) {     return (double)a[cnt] - (sum[x] + a[cnt]) / (double)(x + 1);   }   signed main() {     q = read();     for (long long i = 1; i <= q; i++) {       long long l, r, opt = read();       if (opt == 1) {         a[++cnt] = read();         sum[cnt] = sum[cnt - 1] + a[cnt];       } else {         l = 1, r = cnt - 1;         while (l < r - 2) {           long long k = (r - l) / 3;           long long lmid = l + k, rmid = r - k;           if (f(lmid) > f(rmid)) {             r = rmid;           } else {             if (f(lmid) < f(rmid)) {               l = lmid;             } else {               l = lmid;               r = rmid;             }           }         }         double ans = 0;         for (long long j = l; j <= r; j++) ans = max(ans, f(j));         printf( %.8lf n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   struct PP {     int l, r, k;     int rank, ans;     bool operator<(const PP& b) const {       if (r == b.r) return l < b.l;       return r < b.r;     }   } a[MAXN], b[MAXN];   struct Point {     int l, r, rank;     bool operator<(const Point& b) const {       if (l == b.l) {         if (r == b.r) return rank < b.rank;         return r < b.r;       }       return l < b.l;     }   };   int n, m;   int res[MAXN];   void input() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i].l >> a[i].r;       a[i].rank = i;     }     cin >> m;     for (int i = 0; i < m; i++) {       cin >> b[i].l >> b[i].r >> b[i].k;       b[i].rank = i;     }   }   bool cmp(const PP& a, const PP& b) { return a.rank < b.rank; }   void solve() {     sort(a, a + n);     sort(b, b + m);     set<Point> s;     int cnt = n;     for (int i = 0, j = 0; i < m; i++) {       while (j < n && a[j].r <= b[i].r) {         s.insert((Point){a[j].l, a[j].r, j});         j++;       }       for (int z = 0; z < b[i].k; z++) {         auto it = s.lower_bound((Point){b[i].l, 0, 0});         if (it == s.end()) break;         a[it->rank].ans = b[i].rank + 1;         s.erase(it);         cnt--;       }     }     if (s.size() != 0 || cnt != 0) {       cout <<  NO  << endl;       return;     }     sort(a, a + n, cmp);     cout <<  YES  << endl;     cout << a[0].ans;     for (int i = 1; i < n; i++) cout <<     << a[i].ans;     cout << endl;   }   int main() {     ios::sync_with_stdio(false);     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     string s;     cin >> s;     int i, j, res = 0;     for (i = 0; i < n; i++) {       if (s[i] ==  . ) {         res++;       } else if (s[i] ==  L ) {         res = 0;       } else {         for (j = i + 1; j < n; j++) {           if (s[j] ==  L ) {             break;           }         }         if (j >= n) {           break;         }         res += (j - i - 1) % 2;         i = j;       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   int n, m, p;   int a[200004], b[200004];   int sol[200004];   int ns = 0;   int main() {     scanf( %d%d%d , &n, &m, &p);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 1; i <= m; ++i) scanf( %d , &b[i]);     int num = m;     for (int i = 1; i <= p && i + (m - 1) * 1ll * p <= n; ++i) {       mp.clear();       num = m;       for (int j = 1; j <= m; ++j) mp[b[j]]++;       for (int j = i, cc = 0; j <= n; j += p) {         ++cc;         mp[a[j]]--;         if (mp[a[j]] == 0) mp.erase(a[j]);         if (mp.empty()) sol[ns++] = j - (m - 1) * p;         if (cc == m) {           --cc;           int x = a[j - cc * p];           mp[x]++;           if (mp[x] == 0) mp.erase(x);         }       }     }     sort(sol, sol + ns);     cout << ns << endl;     for (int i = 0; i < ns; ++i) printf( %d  , sol[i]);   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 65 + 5, maxk = (1 << 15) + 5, mod = 1e9 + 7,                   inf = 0x3f3f3f3f;   long long n, m, Q, K, T, S;   long long read() {     long long x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     return x * f;   }   long long a[maxn], jc[maxn], inv[maxn], du[maxn], ST[maxn];   long long q[maxn], top, cont[maxk], val[maxn];   long long cnt, tot, dp[maxn][maxk];   long long ans = 1;   long long kpow(long long x, long long k) {     long long ans = 1, now = x;     while (k) {       if (k & 1) ans = 1ll * ans * now % mod;       now = 1ll * now * now % mod, k >>= 1;     }     return ans;   }   bool cmp(long long x, long long y) { return x > y; }   long long C(long long a, long long b) {     if (a < b) return 0;     return 1ll * jc[a] * inv[b] % mod * inv[a - b] % mod;   }   void dfs(long long x, long long st) {     if (ST[x]) return;     ++tot, ST[x] = st;     for (long long i = (1); i <= (n); ++i)       if ((a[i] % a[x] == 0) || (a[x] % a[i] == 0)) dfs(i, st);   }   void clear() {     top = 0;     tot = 0;     memset(cont, 0, sizeof(cont));     memset(dp, 0, sizeof(dp));   }   signed main() {     n = read();     jc[0] = inv[0] = 1;     for (long long i = (1); i <= (n); ++i)       jc[i] = 1ll * jc[i - 1] * i % mod, inv[i] = kpow(jc[i], mod - 2);     for (long long i = (1); i <= (n); ++i) a[i] = read();     sort(a + 1, a + 1 + n);     for (long long i = (1); i <= (n); ++i)       for (long long j = (i + 1); j <= (n); ++j)         if (!(a[j] % a[i])) ++du[j];     for (long long T = (1); T <= (n); ++T) {       if (ST[T]) continue;       clear();       dfs(T, T);       for (long long i = (1); i <= (n); ++i)         if (!du[i] && ST[i] == T) q[++top] = a[i];       if (tot - top <= 1) continue;       for (long long i = (1); i <= (n); ++i) {         if (!du[i] || ST[i] != T) continue;         for (long long j = (1); j <= (top); ++j)           if (!(a[i] % q[j])) val[i] |= (1 << (j - 1));       }       S = (1 << top) - 1;       for (long long s = (0); s <= (S); ++s)         for (long long j = (1); j <= (n); ++j)           if (ST[j] == T && du[j] && ((s & val[j]) == val[j])) ++cont[s];       for (long long i = (1); i <= (n); ++i)         if (ST[i] == T && du[i]) ++dp[1][val[i]];       for (long long i = (1); i <= (tot - top - 1); ++i)         for (long long s = (0); s <= (S); ++s) {           if (!dp[i][s]) continue;           if (cont[s] > i)             dp[i + 1][s] =                 (dp[i + 1][s] + 1ll * dp[i][s] * (cont[s] - i) % mod) % mod;           for (long long j = (1); j <= (n); ++j)             if (ST[j] == T && du[j] && (s & val[j]) && ((s & val[j]) != val[j]))               dp[i + 1][s | val[j]] = (dp[i + 1][s | val[j]] + dp[i][s]) % mod;         }       long long res = 0;       tot -= top;       for (long long s = (0); s <= (S); ++s) res = (res + dp[tot][s]) % mod;       ans = 1ll * ans * res % mod * C(cnt + tot - 1, tot - 1) % mod;       cnt += tot - 1;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     while (cin >> n) {       long long g[200000] = {0};       long long a[200000] = {0}, i;       long long sum = 0;       for (i = 1; i <= n; i++) cin >> a[i];       long long ans = 0;       long long m1 = 0, m2 = 0;       while (sum < n) {         long long p = 0;         for (int i = 1; i <= n; i++) {           while (g[i] == 0) {             g[i] = 1;             i = a[i];             p++;           }           if (p) {             sum += p;             ans += p * p;             if (p >= m1) {               m2 = m1;               m1 = p;             } else if (p > m2)               m2 = p;             break;           }         }       }       ans += 2 * m1 * m2;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, t;   int a[25][25];   int vis[25];   int dfs(int x, int sum, int limit) {     if (sum > limit) return 0;     if (x == n + 1) return 1;     int ans = dfs(x + 1, sum, limit);     for (int i = 1; i <= n; i++)       if (vis[i] == 0 && a[x][i])         vis[i] = 1, ans += dfs(x + 1, sum + a[x][i], limit), vis[i] = 0;     return ans;   }   int check(int x) { return dfs(1, 0, x) >= t; }   int main() {     scanf( %d%d%d , &n, &k, &t);     for (int i = 1; i <= k; i++) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       a[x][y] = z;     }     int l = 0, r = 2e5;     int ans = -1;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid))         r = mid - 1, ans = mid;       else         l = mid + 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, c, a, b;     scanf( %d %d %d %d , &n, &c, &a, &b);     a--;     b--;     int ca = a % c, cb = b % c;     if (ca == 0) {       if ((cb == (c - 1)) or b == (n - 1))         printf( 1 n );       else if (b / c == a / c)         printf( 1 n );       else         printf( 2 n );     } else if (cb == (c - 1)) {       if (b / c == a / c)         printf( 1 n );       else         printf( 2 n );     } else if (a / c == b / c)       printf( 1 n );     else if (b / c == a / c + 1)       printf( 2 n );     else if (b == (n - 1))       printf( 2 n );     else if (b % c == (a % c) - 1)       printf( 2 n );     else       printf( 3 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool checkThree(char cc, char lc, char nc) { return (cc != lc && cc != nc); }   int main() {     int t;     cin >> t;     while (t--) {       string s, t;       cin >> s >> t;       for (int i = 0; i < s.length(); i++) {         int x = t.find(s[i]);         if (x < t.length()) {           cout <<  YES  << endl;           goto label;         }       }       cout <<  NO  << endl;     label:;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:100000000000000 )   using namespace std;   int n, m;   vector<pair<int, int> > ans;   int main() {     ios_base::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       ans.clear();       cin >> n >> m;       int k = 0;       for (int i = 0; i < n; i++)         for (int j = i + 1; j < n; j++) {           if (k == (2 * n + m)) {             i = n;             break;           }           k++;           ans.push_back(make_pair(i + 1, j + 1));         }       for (int i = 0; i < ans.size(); i++)         cout << ans[i].first <<     << ans[i].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   signed main(void) {     vector<long long> in(101, 0);     long long sum = 0;     for (long long i = 0; i < (5); i++) {       long long a;       cin >> a;       in[a]++;       sum += a;     }     long long ans = sum;     for (long long i = 0; i < (101); i++)       if (in[i] > 1) ans = min(ans, sum - min(in[i], 3LL) * i);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a1, a2, b1, b2;       cin >> a1 >> a2;       cin >> b1 >> b2;       if ((a2 == b2 && (a1 + b1 == a2)) || (a1 == b1 && (a2 + b2 == a1)) ||           (a2 == b1 && (a1 + b2 == a2)) || (a1 == b2 && (a2 + b1 == a1))) {         cout <<  Yes  << endl;       } else {         cout <<  No  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000 + 5], b[1000 + 5];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= m; i++) scanf( %d , &b[i]);     int ans = 0;     for (int i = 1, j = 1; i <= n; i++) {       if (b[j] >= a[i]) {         j++;         ans++;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[300010], po[300010], ans;   int n, p = 1e9 + 7;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]);     sort(a + 1, a + n + 1);     po[0] = 1;     for (int i = 1; i <= n; i++) po[i] = po[i - 1] * 2 % p;     for (int i = 1; i <= n; i++)       (ans += a[i] * (p + po[i - 1] - po[n - i]) % p) %= p;     printf( %I64d n , ans);     return 0;   }