malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char 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 wrote(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10) wrote(x / 10);     putchar(x % 10 +  0 );   }   inline void writeln(long long x) {     wrote(x);     puts(  );   }   const long long maxn = 111;   double p[maxn], win, tim;   long long n, a[maxn];   int main() {     n = read();     win = 1;     for (long long i = 1; i <= n; ++i) {       p[i] = (a[i] = read()) * 0.01;       win *= p[i];     }     tim = n;     for (long long it = 0; ((1 - win) > 1e-10) && (it <= 500000); it++) {       tim += 1 - win;       long long cho = 0;       double cho_v = 0;       for (long long i = 1; i <= n; ++i) {         double now_v = (1 - p[i]) * a[i] * 0.01 / p[i];         if (now_v > cho_v) cho_v = now_v, cho = i;       }       win = 1;       p[cho] += (1 - p[cho]) * a[cho] * 0.01;       for (long long i = 1; i <= n; ++i) win = win * p[i];     }     printf( %lf n , tim);   }
#include <bits/stdc++.h>   using namespace std;   char g[8][8];   int calc(int x, int y, int a, int d) {     int res = 0;     while (x != d) {       x += a;       ++res;       if (g[x][y] !=  . ) return 2e9;     }     return res;   }   int main() {     for (int i = 0; i < 8; ++i) scanf( %s , g[i]);     int a = 2e9, b = 2e9;     for (int i = 0; i < 8; ++i)       for (int j = 0; j < 8; ++j) {         if (g[i][j] ==  W ) a = min(a, calc(i, j, -1, 0));         if (g[i][j] ==  B ) b = min(b, calc(i, j, 1, 7));       }     if (a <= b)       puts( A );     else       puts( B );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     long long n, d;     cin >> n >> d;     long long a[105] = {0};     long long pref[105] = {0};     for (long long i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] % 2 != 0) pref[i]++;       if (i != 1) pref[i] += pref[i - 1];     }     long long z = 0;     long long b[105] = {0};     for (long long i = 2; i < n; i++) {       if (i - pref[i] == pref[i]) {         z++;         b[z] = abs(a[i] - a[i + 1]);       }     }     sort(b + 1, b + 1 + z);     long long v = 1;     while (d >= 0) {       if (v > z) break;       if (d - b[v] >= 0) {         d -= b[v];         v++;       } else         break;     }     cout << v - 1;   }
#include<bits/stdc++.h>   #define ll long long int   #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);      using namespace std;   int main(){               ll t;               cin>>t;               while(t--){                           ll n,k1,k2,w,b;                           cin>>n>>k1>>k2;                           cin>>w>>b;                                                      int m=(k1+k2)/2;                           int c=((n*2)-(k1+k2))/2;                                                     if(m>=w && c>=b){                                       cout<< YES <<  n ;                           }else{                                       cout<< NO <<  n ;                           }               }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, U b) {     if (a < b) a = b;   }   template <typename T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T, class T1>   inline void gn(T &first, T1 &second) {     gn(first);     gn(second);   }   template <class T, class T1, class T2>   inline void gn(T &first, T1 &second, T2 &z) {     gn(first);     gn(second);     gn(z);   }   template <typename T>   inline void print(T first) {     if (first < 0) {       putchar( - );       return print(-first);     }     if (first < 10) {       putchar( 0  + first);       return;     }     print(first / 10);     putchar(first % 10 +  0 );   }   template <typename T>   inline void println(T first) {     print(first), putchar(  n );   }   template <typename T>   inline void printsp(T first) {     print(first), putchar(   );   }   template <class T, class T1>   inline void print(T first, T1 second) {     printsp(first), println(second);   }   template <class T, class T1, class T2>   inline void print(T first, T1 second, T2 z) {     printsp(first), printsp(second), println(z);   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   int first[1555], second[1555];   int ans[1555], sz[1555];   vector<int> adj[1555];   void dfs(int u, int fa = -1) {     sz[u] = 1;     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i];       if (v == fa) continue;       dfs(v, u);       sz[u] += sz[v];     }   }   long double alp[1555][1555];   int id0;   bool cmp(int u, int v) { return alp[u][id0] + 1e-14 < alp[v][id0]; }   int id[1555];   void solve(int u, int fa, int *id, int n) {     if (n == 1) {       ans[id[0]] = u;       return;     }     for (int i = 1; i < n; i++) {       if (second[id[i]] < second[id[0]]) swap(id[0], id[i]);     }     ans[id[0]] = u;     id0 = id[0];     sort(id + 1, id + n, cmp);     int st = 1;     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i];       if (v == fa) continue;       solve(v, u, id + st, sz[v]);       st += sz[v];     }   }   int main() {     srand(time(NULL));     int n;     gn(n);     for (int i = 1; i < n; i++) {       int u, v;       gn(u, v);       u--;       v--;       adj[u].push_back(v);       adj[v].push_back(u);     }     int u = rand() % n;     dfs(u);     for (int i = 0; i < n; i++) gn(first[i], second[i]);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++)         if (i != j)           alp[i][j] = atan2l(second[j] - second[i], first[j] - first[i]);     }     for (int i = 0; i < n; i++) id[i] = i;     solve(u, -1, id, n);     for (int i = 0; i < n; i++) printsp(ans[i] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[3005][3005];   string s, t;   int n, m;   inline long long solve(int l, int r) {     int id = r - l + 1;     if (r >= n) return 0ll;     if (l == 0) {       for (int i = r + 1; i < m; i++) {         if (t[i] != s[id]) return 0ll;         id++;       }       return 1ll * (n - id + 1ll);     }     long long &ret = dp[l][r];     if (ret != -1ll) return ret;     ret = 0ll;     if (r + 1 < m) {       if (s[id] == t[r + 1]) ret = (ret + solve(l, r + 1)) % 998244353;     } else       ret = (ret + solve(l, r + 1)) % 998244353;     if (l - 1 < m) {       if (s[id] == t[l - 1]) ret = (ret + solve(l - 1, r)) % 998244353;     } else       ret = (ret + solve(l - 1, r)) % 998244353;     return ret;   }   int main() {     memset((dp), (-1), sizeof((dp)));     ;     cin >> s >> t;     n = s.length();     m = t.length();     long long ans = 0ll;     for (int i = 0; i < n; i++) {       if (i < m && t[i] == s[0]) {         ans = (ans + 2 * solve(i, i)) % 998244353;       } else if (i >= m) {         ans = (ans + 2 * solve(i, i)) % 998244353;       }     }     printf( %lld n , ans);     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long read() {     long long sign = 1, x = 0;     char s = getchar();     while (s >  9  || s <  0 ) {       if (s ==  - ) sign = -1;       s = getchar();     }     while (s >=  0  && s <=  9 ) {       x = (x << 3) + (x << 1) + s -  0 ;       s = getchar();     }     return x * sign;   }   void write(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x / 10) write(x / 10);     putchar(x % 10 +  0 );   }   int n, k;   int a[(100 + 5)];   int main() {     int kase;     cin >> kase;     while (kase--) {       cin >> n;       if (n == 1 || n == 2) {         cout << 1 << endl;         continue;       }       int ans = (n + 1) / 2;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200000];   int s[200000];   int n, p, k;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int tc;     cin >> tc;     while (tc--) {       cin >> n >> p >> k;       for (int i = 0; i < n; ++i) cin >> a[i];       sort(a, a + n);       int mx;       if (a[0] <= p) {         mx = 1;       } else {         cout <<  0 n ;         continue;       }       s[0] = a[0];       for (int i = 1; i <= k - 2; ++i) {         s[i] = s[i - 1] + a[i];         if (s[i] <= p) mx = i + 1;       }       for (int i = 0; i <= k - 1; i++) {         int z = 0;         int y = 0;         for (int j = i + k - 1; j < n; j += k) {           if (z + a[j] > p) break;           z += a[j];           y++;         }         if (i > 0) {           int add = upper_bound(s, s + i, p - z) - s - 1;           if (add >= 0 && p - z >= s[add]) mx = max(mx, y * k + add + 1);         } else           mx = max(mx, y * k);       }       cout << mx <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[101], nxt, l, h;   int main(int argc, const char* argv[]) {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     int mn = 10001;     for (int i = 0; i < n; i++) {       nxt = i + 1;       nxt %= n;       if (mn > abs(a[i] - a[nxt])) {         mn = abs(a[i] - a[nxt]);         l = i;         h = nxt;       }     }     printf( %d %d n , l + 1, h + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, t;   int main() {     cin >> n >> t;     if (n == 8 && t == 10) {       cout << 11111110;       return 0;     }     if (n == 18 & t == 10) {       cout << 111111111111111110;       return 0;     }     if (n == 1 && t == 10) {       cout << -1;       return 0;     }     if (t == 10) {       for (int i = 0; i < n - 1; i++) {         cout << 1;       }       cout << 0;       return 0;     }     cout << t;     for (int i = 0; i < n - 1; i++) {       cout << 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, n, s, p, b, c;     cin >> k >> n >> s >> p;     float a = (n * 1.0) / s;     b = ceil(a);     c = b * k;     float d = (c * 1.0) / p;     int t = ceil(d);     cout << t;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, cur_div;   vector<long long> cnt;   bool check(long long x) {     long long tot = 0;     for (long long i = 0; i < 26; i++) {       tot += cnt[i] / x;       if (tot >= cur_div) {         return true;       }     }     return false;   }   void solve() {     string second;     cin >> n >> k;     cin >> second;     if (n == k) {       cout << n <<   n ;       return;     }     vector<long long> divs;     for (long long i = 1; i * i <= k; i++) {       if (k % i) continue;       long long div0 = i, div1 = k / i;       divs.push_back(div0);       if (div0 != div1) {         divs.push_back(div1);       }     }     cnt.assign(26, 0);     for (char &c : second) {       cnt[c -  a ]++;     }     long long ans = 1;     for (long long i = 0; i < divs.size(); i++) {       cur_div = divs[i];       long long l = 1, r = n / cur_div;       while (l <= r) {         long long mid = (l + r) >> 1;         if (check(mid)) {           ans = max(ans, mid * cur_div);           l = mid + 1;         } else {           r = mid - 1;         }       }     }     cout << ans <<   n ;   }   signed main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   void __print(int x) { cout << x; }   void __print(long x) { cout << x; }   void __print(long long x) { cout << x; }   void __print(unsigned x) { cout << x; }   void __print(unsigned long x) { cout << x; }   void __print(unsigned long long x) { cout << x; }   void __print(float x) { cout << x; }   void __print(double x) { cout << x; }   void __print(long double x) { cout << x; }   void __print(char x) { cout <<      << x <<     ; }   void __print(const char *x) { cout <<     << x <<    ; }   void __print(const string &x) { cout <<     << x <<    ; }   void __print(bool x) { cout << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cout <<  { ;     __print(x.first);     cout <<  , ;     __print(x.second);     cout <<  } ;   }   template <typename T>   void __print(const T &x) {     int first = 0;     cout <<  { ;     for (auto &i : x) cout << (first++ ?  ,  :   ), __print(i);     cout <<  } ;   }   void _print() { cout <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cout <<  ,  ;     _print(v...);   }   template <class T>   void remdup(vector<T> &v) {     sort((v).begin(), (v).end());     v.erase(unique((v).begin(), (v).end()), end(v));   }   template <typename T>   struct cmp {     bool operator()(const T &p1, const T &p2) {}   };   const long long N = 1e5 + 100;   const long long mod = 1e9 + 7;   const long long X = 2e5 + 100;   long long dp[205][205][205], n, kk;   string s, t;   long long solve(long long nn, long long k, long long a) {     if (nn == n) return 0;     if (dp[nn][k][a] != -1) return dp[nn][k][a];     long long a1 = 0;     long long a2 = 0;     if (t[0] == s[nn]) a1++;     if (t[1] == s[nn]) a2 = a;     long long ans = a2 + solve(nn + 1, k, a + a1);     for (long long i = (0); i < (2); ++i) {       if (k == 0) break;       a1 = 0, a2 = 0;       if (t[i] == t[0]) a1++;       if (t[i] == t[1]) a2 = a;       ans = max(ans, a2 + solve(nn + 1, k - 1, a + a1));     }     return dp[nn][k][a] = ans;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     ;     memset(dp, -1, sizeof(dp));     cin >> n >> kk;     cin >> s >> t;     cout << solve(0, kk, 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     char b, c;     int n, m;     int l, r;     cin >> n >> m;     cin >> s;     for (int j = 1; j <= m; j++) {       cin >> l >> r >> b >> c;       for (int i = l - 1; i < r; i++) {         if (s[i] == b) {           s[i] = c;         }       }     }     for (int i = 0; i < n; i++) cout << s[i];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long r;     vector<long long> a;     cin >> r;     for (int i = 0; i < r; i++) {       long long aux;       cin >> aux;       a.push_back(aux);     }     a.push_back(a[0]);     long long n = 0, m = 1;     long long min = abs(a[0] - a[1]);     for (int i = 1; i < r; i++) {       if (abs(a[i] - a[i + 1]) < min) {         n = i % r;         m = (i + 1) % r;         min = abs(a[i] - a[i + 1]);       }     }     cout << n + 1 <<     << m + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   uint64_t l, r, s;   set<uint64_t> S;   void f(uint64_t x) {     S.insert(x);     if (x < r) f(x * 10 + 4), f(x * 10 + 7);   }   int main() {     cin >> l >> r;     for (f(0); l <= r;) {       auto it = S.lower_bound(l);       s += (min(r, *it) - l + 1) * *it;       l = *it + 1;     }     cout << s <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long ab(long long x) { return x > 0LL ? x : -x; }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, k, sum = 0, x;     cin >> n >> k;     vector<long long> v;     for (long long i = 0; i < n; i++) {       cin >> x;       sum += x;       v.push_back(x);     }     long long ans = -1;     for (long long i = 0; i < k; i++) {       long long sum2 = 0;       for (long long j = i; j < n; j += k) sum2 += v[j];       ans = max(ans, ab(sum - sum2));     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[10010];   char b[10010], c[1010], d[1010];   int main() {     while (scanf( %s%s , a, b) != EOF) {       int len = strlen(a);       sort(a, a + len);       int flag = 0;       for (int i = 0; i < len; i++) {         if (a[i] !=  0 ) {           flag = i;           char t = a[i];           a[i] = a[0];           a[0] = t;           break;         }       }       if (strcmp(a, b) == 0) {         printf( OK n );       } else {         printf( WRONG_ANSWER n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long INF = LLONG_MAX;   void solve() {     long long k;     cin >> k;     string s;     cin >> s;     long long test[10] = {0};     long long sum = 0;     for (long long i = 0; i < s.size(); i++) {       int digit = s[i] -  0 ;       test[digit]++;       sum = sum + digit;     }     long long ans = 0;     for (int i = 0; i < 9; i++) {       for (long long j = 0; j < test[i]; j++) {         if (sum < k) {           ans++;           sum = sum + 9 - i;         }       }     }     cout << ans << endl;   }   int main() {     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   vector<int> adj[N], nodesAtDepth[N];   int degree[N], Dist[N];   bool isDiam[N];   int n;   int bfs(int start) {     queue<pair<int, int>> q;     q.push({start, start});     Dist[start] = 0;     int mxDist = -1;     int mxNode = -1;     while (!q.empty()) {       int node = q.front().first;       int prev = q.front().second;       q.pop();       if (mxDist < Dist[node]) {         mxDist = Dist[node];         mxNode = node;       }       for (int to : adj[node]) {         if (to == prev) continue;         q.push({to, node});         Dist[to] = 1 + Dist[node];       }     }     assert(mxNode != -1);     return mxNode;   }   void dfs(int node, int par, int Depth) {     nodesAtDepth[Depth].push_back(node);     for (int child : adj[node]) {       if (child == par) continue;       dfs(child, node, Depth + 1);     }   }   void solve(int root) {     for (int d = 0; d < n + 3; ++d) {       nodesAtDepth[d].clear();     }     dfs(root, root, 0);     for (int d = 0; d < n + 3; ++d) {       int firstNode = -1;       for (int node : nodesAtDepth[d]) {         if (firstNode == -1) {           firstNode = node;           continue;         }         if (degree[firstNode] != degree[node]) {           return;         }       }     }     cout << root;     exit(0);   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     if (n == 1) {       cout << 1;       return 0;     }     for (int i = 0; i < n - 1; ++i) {       int u, v;       cin >> u >> v;       ++degree[u];       ++degree[v];       adj[u].push_back(v);       adj[v].push_back(u);     }     int end1 = bfs(1);     int end2 = bfs(end1);     int curr = end2;     vector<int> diam;     while (curr != end1) {       diam.push_back(curr);       for (int to : adj[curr]) {         if (Dist[to] == -1 + Dist[curr]) {           curr = to;           break;         }       }     }     diam.push_back(end1);     solve(end1);     solve(end2);     solve(diam[diam.size() / 2]);     queue<pair<int, int>> q;     q.push({diam[diam.size() / 2], diam[diam.size() / 2]});     while (!q.empty()) {       int node = q.front().first;       int par = q.front().second;       q.pop();       if (degree[node] == 1) {         solve(node);         cout << -1;         return 0;       }       for (int child : adj[node]) {         if (child == par) continue;         if (degree[child] > 2) continue;         q.push({child, node});       }     }     cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   int h[4] = {0, 0, 1, -1};   int v[4] = {1, -1, 0, 0};   vector<vector<int> > adj;   bool *visited;   int num[501][501];   bool done = false;   int sourceR, sourceC, destR, destC;   void DFS(int vertix) {     if (!done) {       visited[vertix] = true;       for (int i = 0; i < adj[vertix].size(); i++) {         if (!done && visited[adj[vertix][i]] &&             adj[vertix][i] == num[destR - 1][destC - 1]) {           if (visited[vertix]) {             done = true;             cout <<  YES  << endl;             return;           }         }         if (!done && !visited[adj[vertix][i]]) {           DFS(adj[vertix][i]);         }       }     }   }   int main() {     int n, m;     cin >> n >> m;     visited = new bool[n * m];     vector<int> temp;     int cnt = 0;     char a[501][501];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         adj.push_back(temp);         cin >> a[i][j];         visited[cnt] = false;         num[i][j] = cnt++;       }     }     cin >> sourceR >> sourceC >> destR >> destC;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i][j] ==  X ) {           visited[num[i][j]] = true;         }         for (int k = 0; k < 4; k++) {           if (i + h[k] >= 0 && i + h[k] < n && j + v[k] >= 0 && j + v[k] < m) {             adj[num[i][j]].push_back(num[i + h[k]][j + v[k]]);           }         }       }     }     DFS(num[sourceR - 1][sourceC - 1]);     if (!done) {       cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> v;     int max = 0;     int mi = 0;     for (int i = 0; i < n; ++i) {       int temp;       cin >> temp;       v.push_back(temp);       if (temp > max) {         max = temp;         mi = i;       }     }     for (int i = 0; i < mi; ++i) {       if (v[i + 1] <= v[i]) {         if (v[i] == v[i + 1] && v[i + 1] == max) continue;         cout <<  NO ;         return 0;       }     }     for (int i = n - 1; i > mi; i--) {       if (v[i] >= v[i - 1]) {         if (v[i] == v[i - 1] && v[i - 1] == max) continue;         cout <<  NO ;         return 0;       }     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   const double PI = 3.1415926;   const int KL = 1e6;   using namespace std;   long long q, x, y, z, n, m, p[KL], mn = 1e9, mx = -1e9, ans;   string t;   vector<int> vec[KL];   set<int> s;   map<int, int> M;   int pr[KL], sz[KL];   int prfind(int node) {     if (pr[node] == node)       return node;     else       return pr[node] = prfind(pr[node]);   }   void make_group(int node1, int node2) {     int fa1 = prfind(node1);     int fa2 = prfind(node2);     if (fa1 == fa2) return;     if (sz[fa1] >= sz[fa2]) {       pr[fa2] = fa1;       sz[fa1] += sz[fa2];     } else {       pr[fa1] = fa2;       sz[fa2] += sz[fa1];     }   }   int main() {     scanf( %d , &n);     scanf( %d , &m);     for (int i = 0; i < m; i++) {       scanf( %d , &x);       for (int j = 0; j < x; j++) {         scanf( %d , &y);         vec[i].push_back(y);       }     }     for (int i = 1; i <= n; i++) {       pr[i] = i;       sz[i] = 1;     }     for (int i = 0; i < m; i++) {       for (int j = 1; j < vec[i].size(); j++) {         make_group(vec[i][j], vec[i][j - 1]);       }     }     for (int i = 1; i <= n; i++) {       cout << sz[prfind(i)] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, tmp;     cin >> n;     multiset<int> a;     for (int i = 0; i < n; i++) {       cin >> tmp;       a.insert(tmp);     }     int ans = 0;     while (!a.empty()) {       int h = 0;       while (a.lower_bound(h) != a.end()) {         a.erase(a.lower_bound(h));         h++;       }       if (h) ans++;     }     cout << ans << endl;     return 0;   }