malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     long long r;     while (b) {       r = a % b;       a = b;       b = r;     }     return a;   }   long long power(long long x, long long y) {     if (y == 0)       return 1;     else if (y % 2 == 0)       return power(x, y / 2) * power(x, y / 2);     else       return x * power(x, y / 2) * power(x, y / 2);   }   long long fpow(long long n, long long k, long long p = 1000000007) {     long long r = 1;     for (; k; k >>= 1) {       if (k & 1) r = r * n % p;       n = n * n % p;     }     return r;   }   long long inv(long long a, long long p = 1000000007) {     return fpow(a, p - 2, p);   }   bool pr[1000007];   void sieve() {     pr[0] = 1;     pr[1] = 1;     for (int i = 2; i < sqrt(1000007); i++) {       for (int j = 2 * i; j <= 1000007; j += i) {         pr[j] = 1;       }     }   }   long long differ(long long a, long long b) {     a = a - 65;     b = b - 65;     long long d = min(abs(a - b), min(a, b) + (25 - max(a, b)) + 1);     return d;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t, a, b, c;     string q, r, s;     vector<long long> m, p;     cin >> t;     char d;     int arr[4];     arr[0] = (int)( A );     arr[1] = (int)( C );     arr[2] = (int)( T );     arr[3] = (int)( G );     vector<char> v;     a = 1000000007;     long long n = t;     while (n--) {       cin >> d;       v.push_back(d);     }     for (long long i = 0; (i + 3) < t; i++) {       b = 0;       for (int j = int(0); j <= int(3); j++) {         b += differ((int)(arr[j]), (int)v[i + j]);       }       a = min(a, b);     }     cout << a;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout << fixed;     int a, b, c, d, e, f;     cin >> a >> b >> c >> d >> e >> f;     int cost = 0;     if (e > f) {       int suits = min(a, d);       cost += e * suits;       a -= suits;       d -= suits;       if (d != 0) {         suits = min({b, c, d});         cost += f * suits;       }     } else {       int suits = min({b, c, d});       cost += f * suits;       b -= suits;       c -= suits;       d -= suits;       if (d != 0) {         suits = min(a, d);         cost += e * suits;       }     }     cout << cost <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   char a;   int r, c;   bool side(int x) {     if (x == 1 or x == 8) return true;     return false;   }   int type(int x, int y) {     if (side(x) and side(y)) return 1;     if (side(x) or side(y)) return 2;     return 3;   }   int main() {     scanf(  %c%d , &a, &r);     c = a -  a  + 1;     int ty = type(r, c);     if (ty == 1)       printf( 3 );     else if (ty == 2)       printf( 5 );     else       printf( 8 );     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:251700000 )   using namespace std;   const int INF = 2e9;   const double eps = 1e-6;   const int M = 1e5 + 5;   int n;   string s[M];   bool us[M];   char SS[M];   string get_s() {     scanf(  %s , &SS);     return string(SS);   }   int main() {     scanf( %d , &n);     vector<int> c(27);     vector<int> dd(27, -1);     for (int q = 0; q < n; ++q) {       s[q] = get_s();       for (int i = 0; i < 27; ++i) c[i] = 0;       for (int j = 0; j < s[q].size(); ++j) ++c[s[q][j] -  a ];       for (int i = 0; i < 27; ++i)         if (c[i] > 1) cout <<  NO , exit(0);       for (int i = 0; i < 27; ++i) {         if (dd[i] == -1 || !c[i] || us[dd[i]]) continue;         int l, r, l1, r1;         for (int j = 0; j < s[q].size(); ++j)           if (s[q][j] -  a  == i) l = j;         for (int j = 0; j < s[dd[i]].size(); ++j)           if (s[dd[i]][j] -  a  == i) r = j;         l1 = l, r1 = r;         while (l >= 0 && r >= 0) {           if (s[q][l] != s[dd[i]][r]) cout <<  NO , exit(0);           --l, --r;         }         if (r >= 0) s[q] = s[dd[i]].substr(0, r + 1) + s[q], l1 += r + 1;         l = l1, r = r1;         while (l < s[q].size() && r < s[dd[i]].size()) {           if (s[q][l] != s[dd[i]][r]) cout <<  NO , exit(0);           ++l, ++r;         }         while (r < s[dd[i]].size()) {           s[q] += s[dd[i]][r];           ++r;         }         us[dd[i]] = 1;       }       for (int i = 0; i < 27; ++i) c[i] = 0;       for (int j = 0; j < s[q].size(); ++j)         ++c[s[q][j] -  a ], dd[s[q][j] -  a ] = q;       for (int i = 0; i < 27; ++i)         if (c[i] > 1) cout <<  NO , exit(0);     }     vector<string> ab;     for (int i = 0; i < n; ++i)       if (!us[i]) ab.push_back(s[i]);     sort((ab).begin(), (ab).end());     for (int i = 0; i < ab.size(); ++i) cout << ab[i];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int c, d, n, m, k, needed;     cin >> c >> d >> n >> m >> k;     needed = n * m - k;     cout << ((needed <= 0)                  ? 0                  : min(needed * d, min(needed / n * c + needed % n * d,                                        (int)(ceil((double)needed / n) * c))));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = 1e9 + 7;   const int N = 1e5 + 5;   int n;   long long x, y, ans;   bool comp[N];   vector<long long> primes;   long long add(long long a, long long b) { return (a + b) % MOD; }   long long mul(long long a, long long b) { return (a * b) % MOD; }   long long fastexp(long long a, long long b) {     if (b == 0) return 1;     long long x = fastexp(a, b >> 1);     x = mul(x, x);     if (b & 1) x = mul(x, a);     return x;   }   int main() {     scanf( %lld%lld , &x, &y);     if (y % x != 0) {       printf( 0 n );       return 0;     }     y /= x;     comp[1] = 1;     for (int i = 2; i * i <= N; i++) {       if (comp[i]) continue;       for (int j = i * i; j < N; j += i) {         comp[j] = i;       }     }     long long z = y;     for (int i = 2; i < N; i++) {       if (comp[i]) continue;       if (z % i) continue;       while (z % i == 0) {         z /= i;       }       primes.push_back(i);     }     if (z > 1) primes.push_back(z);     z = primes.size();     for (int i = 0; i < (1 << z); i++) {       long long a = 1, b = 0;       for (int j = 0; j < z; j++) {         if ((i >> j) & 1) {           b++;           a *= primes[j];         }       }       a = y / a;       if (b & 1) {         ans = add(ans, MOD - fastexp(2, a - 1));       } else {         ans = add(ans, fastexp(2, a - 1));       }     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 300010;   pair<pair<int, int>, pair<int, int> > allNums[MAXN * 2];   set<pair<int, int> > startTimes;   pair<int, int> v[MAXN];   int main() {     int N;     scanf( %d , &N);     for (int i = 0; i < N; ++i) {       scanf( %d%d , &v[i].first, &v[i].second);       int L = v[i].second - v[i].first;       allNums[2 * i] = make_pair(make_pair(v[i].first, 0), make_pair(L, i));       allNums[2 * i + 1] = make_pair(make_pair(v[i].second, 1), make_pair(L, i));     }     sort(allNums, allNums + 2 * N);     for (int i = 0; i < 2 * N; ++i) {       if (allNums[i].first.second == 0) {         startTimes.insert(             make_pair(allNums[i].first.first, allNums[i].second.second));         continue;       }       int idx = allNums[i].second.second;       int st = v[idx].first;       set<pair<int, int> >::iterator it = startTimes.find(make_pair(st, idx));       set<pair<int, int> >::iterator snd = startTimes.begin();       if (it == snd) ++snd;       if (snd != startTimes.end() && snd->first <= it->first) {         printf( %d %d n , idx + 1, snd->second + 1);         return 0;       }       startTimes.erase(it);     }     puts( -1 -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MaxN = 5e5;   const int Inf = 1 << 30;   int mpx[MaxN + 5];   vector<int> s, t[MaxN + 5];   bool cmp(int x, int y) { return x > y; }   int main() {     int n, m, x, u, v, ans, S, p;     while (~scanf( %d %d , &n, &m)) {       ans = 0;       for (int i = 1; i <= n; i++) {         scanf( %d , &x);         mpx[x] = i;         t[i].clear();       }       for (int i = 1; i <= m; i++) {         scanf( %d %d , &u, &v);         t[mpx[u]].push_back(mpx[v]);       }       for (int i = 1; i <= n; i++) sort(t[i].begin(), t[i].end(), cmp);       s.clear();       s.push_back(n);       p = 1;       for (int i = n - 1; i >= 1; i--) {         x = 0;         S = t[i].size();         for (int j = 0; j < S; j++) {           if (s[x] == t[i][j]) {             if (++x == p) {               ans++;               break;             }           } else if (s[x] > t[i][j])             break;         }         if (x != p) {           p++;           s.push_back(i);         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   int N, K;   int use[8];   int per[8];   int level[8];   int A;   double res;   void dfs(int depth, int st) {     int i, j, sum, all, dame;     double p, ok, tmp;     if (depth == K) {       tmp = 0;       for (i = 0; i < 1 << N; i++) {         p = 1;         sum = all = dame = 0;         for (j = 0; j < N; j++) {           all += 1;           if (i & 1 << j)             sum += 1;           else             dame += level[j];           ok = (per[j] + use[j] * 10) / 100.0;           if (ok > 1) ok = 1;           if (i & 1 << j)             p *= ok;           else             p *= 1 - ok;         }         if (all < 2 * sum)           tmp += p;         else           tmp += p * A / (A + dame);       }       if (res < tmp) res = tmp;       return;     }     for (i = st; i < N; i++) {       use[i]++;       dfs(depth + 1, i);       use[i]--;     }   }   int main() {     int i, j, l, m;     int sum;     while (scanf( %d%d%d , &N, &K, &A) == 3) {       for (i = 0; i < N; i++) scanf( %d%d , level + i, per + i);       res = 0;       dfs(0, 0);       printf( %.10lf n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void jizz() {     cout << -1 << endl;     exit(0);   }   int s[200005], l[200005], r[200005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> s[i] >> l[i];       r[i] = s[i] + l[i];       l[i] = s[i];     }     int nl = -9, nr = 3000006;     for (int i = 1; i <= n; ++i) {       --nl, ++nr;       nl = l[i] = max(l[i], nl);       nr = r[i] = min(r[i], nr);       if (l[i] > r[i]) jizz();     }     nl = -9, nr = 3000006;     for (int i = n; i >= 1; --i) {       --nl, ++nr;       nl = l[i] = max(l[i], nl);       nr = r[i] = min(r[i], nr);       if (l[i] > r[i]) jizz();     }     long long tot = 0;     for (int i = 1; i <= n; ++i) {       tot += r[i] - s[i];     }     cout << tot << endl;     for (int i = 1; i <= n; ++i) cout << r[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   template <class T, class U>   void mod_partial_sum(const T& v, U* out, ll mod) {     auto it = begin(v);     ll val = 0;     for (auto& x : *out) x = (val += *(it++)) %= mod;   }   int main() {     cout << fixed << setprecision(10);     int a, b;     int rest;     cin >> a >> b;     if (a > b) {       cout << b;       rest = a - b;     } else {       cout << a;       rest = b - a;     }     cout <<    ;     cout << rest / 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 110;   int a, b, c, ar[maxn], al[maxn];   bool gg = false;   int main() {     cin >> a >> b >> c;     for (int i = 0; i < b; i++) cin >> ar[i];     for (int j = 0; j < c; j++) cin >> al[j];     for (int i = 1; i <= a; i++) {       for (int j = 0; j < b; j++) {         if (ar[j] == i) gg = true;       }       gg ? cout << 1 <<     : cout << 2 <<    ;       gg = false;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     long double a, b, c, p, q, r;     cin >> a >> b >> c;     p = b * b - 4 * a * c;     if (a == 0 && b == 0 && c == 0)       cout << -1 << endl;     else if (a == 0 && b == 0 && c != 0)       cout << 0 << endl;     else if (p < 0)       cout << 0 << endl;     else if (a == 0) {       q = -c / b;       cout << 1 << endl;       cout << fixed << setprecision(6) << q;     } else if (p == 0) {       q = -b / (2 * a);       cout << 1 << endl;       cout << fixed << setprecision(6) << q;     } else {       q = (-b - sqrt(p)) / (2 * a);       r = (-b + sqrt(p)) / (2 * a);       if (q < r) {         cout << 2 <<   n  << fixed << setprecision(6) << q << endl;         cout << fixed << setprecision(6) << r << endl;       } else {         cout << 2 <<   n  << fixed << setprecision(6) << r << endl;         cout << fixed << setprecision(6) << q << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     long long int t, i = 0;     long long ans = 0;     scanf( %lld , &t);     for (i = 0; i < t; i++) {       long long int n;       scanf( %lld , &n);       ans = ans + i * (n - 1) + n;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, k, ans = 0;     cin >> x >> k;     while (x--) {       int a, b;       cin >> a >> b;       ans += abs(a - b) + 1;     }     int ans2 = 0;     while (true) {       if (ans % k == 0) {         cout << ans2;         break;       } else {         ans2++;         ans++;       }     }   }
#include <bits/stdc++.h>   #pragma GCC optimize  03    using namespace std;   const long long int inf = 1e15;   const long long int MOD = 1e9 + 7;   const long long int N = 2e5 + 5;   struct SegTree {     struct data {       long long int val;       data() : val(0){};       template <typename T>       void apply(T v) {         val = v;       }     };     long long int N;     vector<data> st;     SegTree() {}     SegTree(long long int _N) : N(_N) { st.resize(4 * N + 5); }     inline void merge(data &cur, const data &l, const data &r,                       long long int flag) {       if (flag == 1)         cur.val = l.val | r.val;       else         cur.val = l.val ^ r.val;     }     template <typename T>     long long int build(long long int node, long long int l, long long int r,                         vector<T> &v) {       if (l == r) {         if (l < (long long int)v.size())           st[node].apply(v[l]);         else           st[node].apply(0);         return 1;       }       long long int mid = (l + r) / 2;       long long int f = build(node * 2, l, mid, v);       build(node * 2 + 1, mid + 1, r, v);       merge(st[node], st[node * 2], st[node * 2 + 1], f);       return !f;     }     long long int pupdate(long long int node, long long int l, long long int r,                           long long int pos, long long int val) {       if (l == r) {         st[node].val = val;         return 1;       }       long long int mid = (l + r) / 2;       long long int f;       if (pos <= mid)         f = pupdate(node * 2, l, mid, pos, val);       else         f = pupdate(node * 2 + 1, mid + 1, r, pos, val);       merge(st[node], st[node * 2], st[node * 2 + 1], f);       return !f;     }     template <typename T>     void build(vector<T> &v) {       build(1, 1, N, v);     }     void update(long long int pos, long long int val) {       pupdate(1, 1, N, pos, val);     }   };   signed main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ;     long long int n, q;     cin >> n >> q;     vector<long long int> v((1 << n) + 1);     for (long long int i = 1; i <= (1 << n); i++) {       cin >> v[i];     }     SegTree st(1 << 17);     st.build(v);     ;     while (q--) {       long long int a, b;       cin >> a >> b;       st.update(a, b);       cout << st.st[1].val <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[2][200005];   int dp[2][200005][19];   void gao(int c) {     for (int i = 1; i <= n; ++i) dp[c][i][0] = a[c][i];     for (int j = 1; (1 << j) <= n; ++j) {       for (int i = 1; i + (1 << (j - 1)) <= n; ++i) {         if (c == 0)           dp[c][i][j] = max(dp[c][i][j - 1], dp[c][i + (1 << (j - 1))][j - 1]);         if (c == 1)           dp[c][i][j] = min(dp[c][i][j - 1], dp[c][i + (1 << (j - 1))][j - 1]);       }     }   }   int rmq(int l, int r, int c) {     int k = (int)(log(r - l + 1) / log(2));     if (c == 0) return max(dp[c][l][k], dp[c][r - (1 << k) + 1][k]);     return min(dp[c][l][k], dp[c][r - (1 << k) + 1][k]);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[0][i]);     for (int i = 1; i <= n; ++i) scanf( %d , &a[1][i]);     gao(0), gao(1);     long long ans = 0;     for (int i = 1; i <= n; ++i) {       int l = i, r = n, x, y;       while (l < r) {         int m = (l + r) >> 1;         if (rmq(i, m, 0) < rmq(i, m, 1))           l = m + 1;         else           r = m;       }       x = l;       l = i, r = n;       while (l < r) {         int m = (l + r + 1) >> 1;         if (rmq(i, m, 0) > rmq(i, m, 1))           r = m - 1;         else           l = m;       }       y = l;       if (x == y)         ans += rmq(i, x, 0) == rmq(i, y, 1) ? 1 : 0;       else         ans += max(0, y - x + 1);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   int n, m, k;   char s[2505][2505];   long long a[2505][2505];   inline long long sum(int r1, int c1, int r2, int c2) {     return a[r2][c2] - a[r1 - 1][c2] - a[r2][c1 - 1] + a[r1 - 1][c1 - 1];   }   inline long long go(int r1, int c1, int r2, int c2) {     if (r1 == r2 && c1 == c2) return sum(r1, c1, r2, c2) == k;     if (r2 - r1 > c2 - c1) {       long long cnt = 0;       int m = r1 + r2 >> 1;       int up[k + 1], dw[k + 1];       for (int i = c1; i <= c2; i++) {         for (int x = 0; x <= k; x++) up[x] = m - r1 + 1, dw[x] = r2 - m;         for (int j = i; j <= c2; j++) {           for (int x = 0; x <= k; x++) {             while (up[x] && sum(m - up[x] + 1, i, m, j) > x) up[x]--;             while (dw[x] && sum(m + 1, i, m + dw[x], j) > x) dw[x]--;           }           for (int x = 0; x <= k; x++) {             cnt += (long long)(up[x] - (x ? up[x - 1] : 0)) *                    (dw[k - x] - (k - x ? dw[k - x - 1] : 0));           }         }       }       return cnt + go(r1, c1, m, c2) + go(m + 1, c1, r2, c2);     } else {       long long cnt = 0;       int m = c1 + c2 >> 1;       int up[k + 1], dw[k + 1];       for (int i = r1; i <= r2; i++) {         for (int x = 0; x <= k; x++) up[x] = m - c1 + 1, dw[x] = c2 - m;         for (int j = i; j <= r2; j++) {           for (int x = 0; x <= k; x++) {             while (up[x] && sum(i, m - up[x] + 1, j, m) > x) up[x]--;             while (dw[x] && sum(i, m + 1, j, m + dw[x]) > x) dw[x]--;           }           for (int x = 0; x <= k; x++) {             cnt += (long long)(up[x] - (x ? up[x - 1] : 0)) *                    (dw[k - x] - (k - x ? dw[k - x - 1] : 0));           }         }       }       return cnt + go(r1, c1, r2, m) + go(r1, m + 1, r2, c2);     }   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++) scanf( %s , &s[i][1]);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + s[i][j] -  0 ;       }     }     printf( %I64d n , go(1, 1, n, m));   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, l;     cin >> n >> l;     deque<int> v;     while (n--) {       int m;       cin >> m;       v.push_back(m);     }     sort(v.begin(), v.end());     int a = v[0];     int b = v[v.size() - 1];     v.push_front(a * (-1));     v.push_back(2 * l - b);     int maxi = 0;     for (int i = 1; i < v.size(); i++) {       maxi = max(maxi, v[i] - v[i - 1]);     }     float maxi2 = maxi;     cout << fixed << setprecision(10) << maxi2 / 2;   }
#include <bits/stdc++.h>   using namespace std;   int n = 8;   struct point {     int x;     int y;   };   bool f(point a, point b) {     if (a.x != b.x) return a.x > b.x;     return a.y > b.y;   }   int main() {     point a[8];     for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].y;     int t1 = 0, t2 = 0;     for (int i = 0; i < n; i += 2) {       if (a[i].x == a[i + 1].x) {         t1++;       } else if (a[i].y == a[i + 1].y)         t2++;       else {         cout <<  NO  << endl;         return 0;       }     }     if (t1 != 2 || t2 != 2) {       cout <<  NO  << endl;       return 0;     }     int t = 0;     sort(a, a + n, f);     if (a[1].x == a[2].x && a[1].y == a[2].y ||         a[3].x == a[4].x && a[3].y == a[4].y ||         a[5].x == a[6].x && a[5].y == a[6].y) {       cout <<  NO  << endl;       return 0;     }     for (int i = 0; i < n; i += 2) {       if (a[i].x == a[i + 1].x && a[i].y == a[i + 1].y)         t++;       else {         cout <<  NO  << endl;         return 0;       }     }     if (t == 4)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long md = 1e9 + 7;   long long fe(long long e) {     if (e == 0) return 1;     long long ans = fe(e / 2);     ans = (ans * ans) % md;     if (e % 2) ans *= 2;     return (ans % md);   }   int main() {     long long x, y;     cin >> x >> y;     if (y % x) {       cout << 0 << endl;       return 0;     }     long long k = y / x;     vector<int> pp;     long long kk = k;     for (long long p = 2; p < 1e5; p++) {       if (kk % p == 0) {         pp.push_back(p);         while (kk % p == 0) kk /= p;       }     }     if (kk > 1) pp.push_back(kk);     long long ans = fe(k - 1);     int mx = 1 << (int)pp.size();     for (int i = 1; i < mx; i++) {       long long p = 1, sgn = 1;       for (int j = 0; 1 << j <= i; j++) {         if (1 << j & i) {           p *= pp[j];           sgn *= -1;         }       }       ans += sgn * fe(k / p - 1);       ans %= md;       while (ans < 0) ans += md;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   signed main() {     std::ios::sync_with_stdio(false);     string str;     cin >> str;     long long int n = str.size();     string prf =   ;     vector<long long int> v(n, 0);     for (long long int i = 0; i < n - 1; i++)       if (str[i] != str[i + 1]) v[i] = 1;     if (str[n - 1] ==  a ) v[n - 1] = 1;     for (long long int i = 0; i < n; i++) cout << v[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   long long u[11];   int main() {     long long x, y, n, i, j, k = 0, l, arr[200009];     cin >> n;     for (i = 0; i < n; i++) {       cin >> arr[i];     }     sort(arr, arr + n);     for (i = 0, j = 1; i < n; i++) {       if (arr[i] >= j) {         k++;         j++;       }     }     cout << k << endl;   }