malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const double eps = 3e-5;   double x, h, l;   int main() {     cin >> x;     for (double h = 1.0; h <= (10.0 + eps); h += 1.0) {       if (h + eps < x) continue;       l = h / (sqrt((h * h) / (x * x) - 1)) * 2.0;       for (double q = 1.0; q <= (10.0 + eps); q += 1.0) {         if (l - q < eps && q - l < eps) {           printf( %d %d n , (int)q, (int)h);           return 0;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve();   void precalc();   int main() {     string s =  change me please ;     int t = 1;     while (t--) solve();     return 0;   }   void solve() {     int n;     cin >> n;     vector<int> a(n), h(n);     for (int i = 0; i < n; ++i) cin >> a[i] >> h[i];     int ans = 0;     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j)         if (a[i] == h[j]) ++ans;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string A;     cin >> A;     if (A.size() > 1 and A.size() % 2 == 0) {       int x = (A.size() / 2) - 1;       cout << A[x];       for (int i = 1; i <= x; i++) {         cout << A[x + i] << A[x - i];       }       cout << A[2 * x + 1];     } else if (A.size() % 2 != 0 and A.size() > 1) {       int x = (A.size() / 2);       cout << A[x];       for (int i = 1; i <= x; i++) {         cout << A[x + i] << A[x - i];       }     } else {       cout << A[0];     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 3;   const long long INF = 4e18 + 3;   vector<long long> v[3];   int r[3];   long long ans;   auto iter1 = v[0].begin();   auto iter2 = v[1].begin();   long long X, Y;   void rob(int a, int b, int c) {     for (auto it : v[b]) {       if (it < v[a][0] || it > v[c].back()) continue;       iter1 = upper_bound(v[a].begin(), v[a].end(), it);       iter1--;       iter2 = lower_bound(v[c].begin(), v[c].end(), it);       X = *iter1;       Y = *iter2;       ans =           min(ans, (X - Y) * (X - Y) + (X - it) * (X - it) + (Y - it) * (Y - it));     }   }   int main() {     int z;     long long x;     scanf( %d , &z);     while (z--) {       ans = INF;       for (int i = 0; i < 3; i++) v[i].clear();       for (int i = 0; i < 3; i++) scanf( %d , &r[i]);       for (int i = 0; i < 3; i++) {         for (int j = 1; j <= r[i]; j++) {           scanf( %lld , &x);           v[i].push_back(x);         }       }       for (int i = 0; i < 3; i++) sort(v[i].begin(), v[i].end());       rob(0, 1, 2);       rob(0, 2, 1);       rob(1, 0, 2);       rob(1, 2, 0);       rob(2, 0, 1);       rob(2, 1, 0);       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int t = 1;     while (t--) {       long long int n;       cin >> n;       vector<long long int> v(n);       for (long long int i = 0; i < n; i++) cin >> v[i];       long long int maxi = 1;       long long int l = 1;       for (long long int i = 1; i < n; i++) {         if (v[i] <= 2 * v[i - 1])           l++;         else           l = 1;         maxi = max(maxi, l);       }       cout << maxi << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-11;   const int mod = 1e7 + 9;   const int oo = (1 << 31) - 1;   template <class T>   inline void readInt(T &n) {     n = 0;     T ch = getchar();     int sign = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) sign = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       n = (n << 3) + (n << 1) + ch -  0 , ch = getchar();     n = n * sign;   }   const int maxn = 100005;   int n, m, q, x, y, a[505][505], b[505];   int main() {     cin >> n >> m >> q;     for (int i = ((int)(0)); i < ((int)(n)); i++) b[i] = 0;     for (int i = ((int)(0)); i < ((int)(n)); i++)       for (int j = ((int)(0)); j < ((int)(m)); j++) cin >> a[i][j];     for (int i = ((int)(0)); i < ((int)(n)); i++) {       int c = a[i][0];       for (int j = ((int)(1)); j < ((int)(m)); j++) {         if (a[i][j] == 0) {           if (a[i][j - 1] == 1) b[i] = max(b[i], c);           c = 0;           continue;         }         if (a[i][j - 1] == 0)           c = 1;         else           c++;       }       b[i] = max(b[i], c);     }     for (int i = ((int)(0)); i < ((int)(q)); i++) {       cin >> x >> y;       --x;       --y;       a[x][y] = 1 - a[x][y];       int res = 0, c = a[x][0];       for (int j = ((int)(1)); j < ((int)(m)); j++) {         if (a[x][j] == 0) {           if (a[x][j - 1] == 1) res = max(res, c);           c = 0;           continue;         }         if (a[x][j - 1] == 0)           c = 1;         else           c++;       }       res = max(res, c);       b[x] = res;       res = 0;       for (int j = ((int)(0)); j < ((int)(n)); j++)         if (b[j] > res) res = b[j];       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   namespace fdd {   int n, m1, m2;   std::priority_queue<int> q[1010];   std::vector<int> v1, v2;   void solve() {     std::cin >> n;     for (int i = 3; i < n; i++) {       scanf( %d%d , &m1, &m2);       if (m1 > m2) std::swap(m1, m2);       q[m1].push(m2);     }     for (int i = 2; i <= n; i++) {       while (!q[i].empty()) {         m1 = q[i].top();         q[i].pop();         v1.push_back(i);         v1.push_back(m1);       }     }     for (int i = 3; i < n; i++) {       scanf( %d%d , &m1, &m2);       if (m1 > m2) std::swap(m1, m2);       q[m1].push(m2);     }     for (int i = 2; i <= n; i++) {       while (!q[i].empty()) {         m1 = q[i].top();         q[i].pop();         if (q[i].empty())           m2 = i + 1;         else           m2 = q[i].top();         v2.push_back(1);         v2.push_back(m2);       }     }     printf( %d n , (v1.size() + v2.size()) >> 1);     int l = v1.size();     for (int i = 0; i < l; i += 2) printf( %d %d n , v1[i], v1[i + 1]);     l = v2.size();     for (int i = l - 1; i >= 0; i -= 2) printf( %d %d n , v2[i - 1], v2[i]);   }   }  // namespace fdd   int main() {     fdd::solve();     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target(         sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native )   #pragma GCC optimize( Ofast,O3,unroll-loops )   using namespace std;   struct cplx {     long double a, b;     cplx(long double a = 0, long double b = 0) : a(a), b(b) {}     const cplx operator+(const cplx &c) const { return cplx(a + c.a, b + c.b); }     const cplx operator-(const cplx &c) const { return cplx(a - c.a, b - c.b); }     const cplx operator*(const cplx &c) const {       return cplx(a * c.a - b * c.b, a * c.b + b * c.a);     }     const cplx operator/(const long double &x) const {       return cplx(a / x, b / x);     }     const cplx conj() const { return cplx(a, -b); }   };   const long double PI = acosl(-1);   const int N = (1 << 20) + 5;   int rev[N];   cplx w[N];   void prepare(int &n) {     int sz = __builtin_ctz(n);     for (int i = 1; i < n; ++i)       rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (sz - 1));     w[0] = 0, w[1] = 1, sz = 1;     while (1 << sz < n) {       cplx w_n =           cplx(cosl(2 * PI / (1 << (sz + 1))), sinl(2 * PI / (1 << (sz + 1))));       for (int i = 1 << (sz - 1); i < (1 << sz); ++i) {         w[i << 1] = w[i], w[i << 1 | 1] = w[i] * w_n;       }       ++sz;     }   }   void fft(cplx *a, int n) {     for (int i = 1; i < n - 1; ++i) {       if (i < rev[i]) swap(a[i], a[rev[i]]);     }     for (int h = 1; h < n; h <<= 1) {       for (int s = 0; s < n; s += h << 1) {         for (int i = 0; i < h; ++i) {           cplx &u = a[s + i], &v = a[s + i + h], t = v * w[h + i];           v = u - t, u = u + t;         }       }     }   }   static cplx f[N];   vector<long long> multiply(vector<long long> a, vector<long long> b) {     int n = a.size(), m = b.size(), sz = 1;     while (sz < n + m - 1) sz <<= 1;     prepare(sz);     for (int i = 0; i < sz; ++i) f[i] = cplx(i < n ? a[i] : 0, i < m ? b[i] : 0);     fft(f, sz);     for (int i = 0; i <= (sz >> 1); ++i) {       int j = (sz - i) & (sz - 1);       cplx x = (f[i] * f[i] - (f[j] * f[j]).conj()) * cplx(0, -0.25);       f[j] = x, f[i] = x.conj();     }     fft(f, sz);     vector<long long> c(n + m - 1);     for (int i = 0; i < n + m - 1; ++i) c[i] = f[i].a / sz + 0.3;     return c;   }   int main() {     long long a, b, c, d;     cin >> a >> b >> c >> d;     long long ans = (b - a + 1) * (c - b + 1) * (d - c + 1);     std::vector<long long> A(b + 1);     std::vector<long long> B(c + 1);     for (int i = a; i <= b; i++) A[i] = 1;     for (int i = b; i <= c; i++) B[i] = 1;     std::vector<long long> C = multiply(A, B);     long long prev = 0;     for (int i = 0; i <= d; i++) {       if (i < C.size()) prev += C[i];       if (i >= c) {         ans -= prev;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ans[60];   int main() {     long long t, a, n, m, b, v, xmin, xmax, act, sum, i, vmi;     cin >> t;     while (t--) {       cin >> a >> b >> m;       if (a == b) {         cout <<  1   << a <<   n ;         continue;       }       for (n = 2; n <= 50; n++) {         v = ((1ll) << (n - 2));         xmin = v * a + v;         xmax = v * a + v * m;         if (xmin > b) {           n = 51;           break;         }         if (b <= xmax) {           act = xmax;           ans[1] = a;           sum = ans[1];           for (i = 2; i <= n; i++) {             v = ((1ll) << (max(n - i - 1, 0ll)));             vmi = m - (act - b) / v;             vmi = max(vmi, 1ll);             ans[i] = sum + vmi;             sum = sum + ans[i];             act -= (m - vmi) * v;           }           if (i <= n || ans[n] != b) continue;           cout << n <<    ;           for (i = 1; i <= n; i++) cout << ans[i] <<    ;           cout <<   n ;           break;         }       }       if (n == 51) {         cout << -1 <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 110;   int n, m, k, ans, a;   vector<int> adj[N], lan[N];   bool mark[N];   void input() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> k;       if (k == 0) a++;       while (k--) {         int v;         cin >> v;         lan[v].push_back(i);       }     }   }   void aa_adj() {     for (int i = 1; i <= m; i++) {       if (lan[i].size() == 0) continue;       for (int j = 0; j < lan[i].size() - 1; j++) {         adj[lan[i][j]].push_back(lan[i][j + 1]),             adj[lan[i][j + 1]].push_back(lan[i][j]);       }     }   }   void dfs(int v) {     mark[v] = true;     for (int u : adj[v])       if (!mark[u]) dfs(u);   }   void find_ans() {     for (int i = 1; i <= n; i++) {       if (!mark[i]) {         dfs(i), ans++;       }     }     if (a == n)       cout << ans << endl;     else       cout << ans - 1 << endl;   }   int main() {     input();     aa_adj();     find_ans();   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:167177216 )   using namespace std;   const int MAXN = 9;   int main() {     long long n, A;     scanf( %I64d %I64d , &n, &A);     long long sum = 0;     vector<int> d(n);     for (int i = 0; i < n; i++) {       scanf( %d , &d[i]);       sum += d[i];     }     for (int i = 0; i < n; i++) {       long long without = sum - d[i];       long long need = A - without;       if (need <= 0) {         long long need = A - (n - 1);         if (d[i] <= need)           cout << 0 <<    ;         else {           cout << d[i] - need <<    ;         }       } else {         long long ans = need - 1;         long long razn = d[i] - need;         if (without - (n - 1) < razn) ans += (razn - without + (n - 1));         cout << ans <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double EPS = 1e-6;   const int MOD = 1e9 + 7;   const int MAXN = 110;   const double PI = acos(-1.0);   int ipt[MAXN][MAXN];   int main() {     int n, m, k;     while (~scanf( %d%d%d , &n, &m, &k)) {       int ans = INF, all = 1 << m;       for (int i = 0; i < (n); ++i)         for (int j = 0; j < (m); ++j) scanf( %d , &ipt[i][j]);       if (n < m) {         for (int i = 0; i < (n); ++i)           for (int j = (i + 1); j < (m); ++j) swap(ipt[i][j], ipt[j][i]);         swap(n, m);       }       if (n > k) {         for (int i = 0; i < (n); ++i) {           int tans = 0;           for (int j = 0; j < (n); ++j) {             int cnt = 0;             for (int k = 0; k < (m); ++k) cnt += ipt[i][k] ^ ipt[j][k];             tans += min(cnt, m - cnt);           }           ans = min(ans, tans);         }       } else {         for (int mask = 0; mask < all; mask++) {           int tans = 0;           for (int i = 0; i < (n); ++i) {             int cnt = 0;             for (int j = 0; j < (m); ++j) cnt += ipt[i][j] ^ (mask >> j & 1);             tans += min(cnt, m - cnt);           }           ans = min(ans, tans);         }       }       printf( %d n , ans <= k ? ans : -1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   int t, n;   int cnt, num, maxx;   int a[maxn];   int vis[maxn];   int m1[maxn];   int m2[maxn];   void init() {     num = 0;     maxx = 0;     memset(vis, 0, sizeof(vis));   }   int main() {     scanf( %d , &t);     while (t--) {       cnt = 0;       scanf( %d , &n);       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       for (int i = 1; i <= n; i++) m1[i] = 0, m2[i] = 0;       init();       for (int i = 1; i <= n; i++) {         maxx = max(maxx, a[i]);         if (!vis[a[i]]) {           num++;           vis[a[i]] = 1;         } else           break;         if (num == maxx)           m1[i] = 1;         else           m1[i] = 0;       }       init();       for (int i = n; i >= 1; i--) {         maxx = max(maxx, a[i]);         if (!vis[a[i]]) {           num++;           vis[a[i]] = 1;         } else           break;         if (num == maxx) {           m2[i] = 1;           if (i > 1 && m1[i - 1]) cnt++;         } else           m2[i] = 0;       }       printf( %d n , cnt);       for (int i = 1; i < n; i++)         if (m1[i] && m2[i + 1]) printf( %d %d n , i, n - i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100, M = 10000;   int n, m, a[N + 9], ca;   double x, ans;   void into() {     scanf( %d%lf , &n, &x);     int p = 0;     for (int i = 1; i <= n; ++i) {       int t;       scanf( %d , &t);       t << 1 <= x ? ans += t : m += a[++ca] = t;     }     x /= 2;   }   double dp[N + 9][M + 9];   void Get_dp() {     dp[0][0] = 1;     for (int i = 1; i <= ca; ++i)       for (int j = i; j >= 1; --j)         for (int k = m; k >= a[i]; --k)           dp[j][k] += dp[j - 1][k - a[i]] * j / (ca - j + 1);   }   void Get_ans() {     for (int i = 1; i <= ca; ++i)       for (int j = 0; j <= m; ++j)         ans += dp[i][j] * min((1.0 * n / i + 1) * x, 1.0 * j / i);   }   void work() {     Get_dp();     Get_ans();   }   void outo() { printf( %.12lf n , ans); }   int main() {     into();     work();     outo();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using PII = pair<int, int>;   using PLL = pair<long long, long long>;   using VLL = vector<long long>;   using VI = vector<int>;   inline void fastio() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fL;   const int mod1 = 998244353;   const int mod2 = 1e9 + 7;   void solve() {     int n, m, k;     cin >> n >> m >> k;     if (k <= 1) {       cout <<  NO  << endl;       return;     }     if (m < n - 1) {       cout <<  NO  << endl;       return;     }     long long cnt = 1ll * n * (n - 1) / 2;     if (m > cnt) {       cout <<  NO  << endl;       return;     }     if (k == 2 && n > 1) {       cout <<  NO  << endl;       return;     }     if (k >= 2 && n == 1) {       cout <<  YES  << endl;       return;     }     if (k > 3) {       cout <<  YES  << endl;       return;     }     if (m == cnt) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }   signed main() {     fastio();     int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool prime[100000 + 5];   int ans[100000 + 5];   int main() {     long long int n;     cin >> n;     for (int i = 0; i <= n; i++) prime[i] = true;     long long int k = 1;     for (int p = 2; p * p <= n; p++) {       if (prime[p] == true) {         ans[p] = k;         for (int i = p * p; i <= n; i += p) {           if (i <= n) {             prime[i] = false;             ans[i] = k;           }         }         prime[p] = false;         k++;       }     }     for (int p = 2; p <= n; p++) {       if (prime[p] == true) {         for (int i = p; i <= n; i += p) {           if (i <= n) {             prime[i] = false;             ans[i] = k;           }         }         k++;       }     }     for (int p = 2; p <= n; p++) cout << ans[p] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     string s;     cin >> n >> k;     cin >> s;     int isThere[26];     for (int i = 0; i < 26; i++) isThere[i] = 0;     bool ok = true;     for (int i = 0; i < n; i++) {       isThere[s[i] -  a ]++;       if (isThere[s[i] -  a ] > k) {         ok = false;         break;       }     }     if (ok)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXD = 60 + 5;   const int MAXN = 2e3 * 60 + 5;   const int mod = 1e9 + 7;   inline long long pw(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % mod;       a = a * a % mod;       b >>= 1;     }     return res;   }   inline int get_lb(long long x) {     int res = 0;     while (x >> res) ++res;     return res - 1;   }   int d;   long long a[MAXN];   int b[MAXN];   long long pt[MAXN];   int pcnt = 0, must[MAXN], dp[MAXN][5];   int f[MAXD];   inline int get(long long u) {     int pos = lower_bound(pt + 1, pt + pcnt + 1, u) - pt;     if (pos > pcnt || pt[pos] != u) return -1;     return pos;   }   inline vector<int> get_dp(long long u) {     int id = get(u);     if (id != -1)       return vector<int>(dp[id], dp[id] + 3);     else       return vector<int>(3, f[d - get_lb(u)]);   }   int main(void) {     int n;     scanf( %d%d , &d, &n);     for (int i = 1; i <= n; ++i) {       static char t[100];       scanf( %lld%s , &a[i], t + 1);       b[i] = t[1] ==  w  || t[1] ==  y  ? 1 : t[1] ==  g  || t[1] ==  b  ? 2 : 3;     }     f[1] = 1;     for (int i = 2; i <= d; ++i) f[i] = 4ll * f[i - 1] * f[i - 1] % mod;     pt[++pcnt] = 1;     for (int i = 1; i <= n; ++i) {       long long u = a[i];       while (u) {         pt[++pcnt] = u;         u >>= 1;       }     }     sort(pt + 1, pt + pcnt + 1);     pcnt = unique(pt + 1, pt + pcnt + 1) - pt - 1;     for (int i = 1; i <= n; ++i) must[get(a[i])] = b[i];     for (int i = pcnt; i >= 1; --i) {       if (pt[i] >= (1ll << (d - 1))) {         if (!must[i])           dp[i][0] = dp[i][1] = dp[i][2] = 1;         else           dp[i][must[i] - 1] = 1;         continue;       }       long long u = pt[i];       vector<int> ls = get_dp(u << 1);       vector<int> rs = get_dp(u << 1 | 1);       for (int x = 0; x < 3; ++x) {         if (must[i] && x != must[i] - 1) continue;         for (int y = 0; y < 3; ++y)           if (y != x)             for (int z = 0; z < 3; ++z)               if (z != x) dp[i][x] = (dp[i][x] + (long long)ls[y] * rs[z]) % mod;       }     }     int ans = 0;     for (int i = 0; i < 3; ++i) ans = (ans + dp[1][i]) % mod;     ans = ans * pw(2, (1ll << d) - 1 - n) % mod;     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> ans;   bool check(string s, int L, int R) {     if (s[L] ==  0 ) {       if (R == L + 1) {         return true;       }       return false;     }     int n = 0;     for (int i = L; i < R; i++) {       n *= 10;       n += s[i] -  0 ;     }     return (n >= 0 && n < 256);   }   void func(string s) {     int N = s.length();     for (int i = 1; i <= 3; i++) {       for (int j = i + 1; j <= i + 3; j++) {         for (int k = j + 1; k <= j + 3; k++) {           if (N - k >= 1 && N - k <= 3) {             if (check(s, 0, i) && check(s, i, j) && check(s, j, k) &&                 check(s, k, N)) {               string final;               final = s.substr(0, i) +  .  + s.substr(i, j - i) +  .  +                       s.substr(j, k - j) +  .  + s.substr(k, N - k);               ans.push_back(final);             }           }         }       }     }   }   void dfs(int L, string s, int mask, int pos, int used) {     if (pos == L) {       if (used == mask) {         func(s);         return;       }     }     int pos2 = L - 1 - pos;     if (pos2 < pos) {       if (mask != used) {         return;       }       char c = s[pos2];       dfs(L, s + c, mask, pos + 1, used);     } else {       char c;       for (int i = 0; i < 10; i++) {         if (mask & (1 << i)) {           c = i +  0 ;           dfs(L, s + c, mask, pos + 1, (used | (1 << i)));         }       }     }   }   int main() {     int n;     int a[11];     cin >> n;     int mask = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];       mask |= (1 << a[i]);     }     if (n <= 6) {       for (int i = 4; i <= 12; i++) {         dfs(i,   , mask, 0, 0);       }     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++) {       cout << ans[i].c_str() << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     long long int a;     long long int b;   };   node p[100005];   bool comp(node x, node y) {     if (x.b < y.b) return true;     return false;   }   int main() {     long long int n, r, avg;     cin >> n >> r >> avg;     long long int s = 0;     for (int i = (0); i < (n); ++i) {       cin >> p[i].a >> p[i].b;       s += p[i].a;     }     long long int cc = avg * n;     if (s >= cc)       cout << 0 << endl;     else {       long long int to = avg * n;       long long int add = to - s;       long long int count = 0;       sort(p, p + n, comp);       for (int j = (0); j < (n); ++j) {         if (add == 0) break;         long long int maxim = r - p[j].a;         if (r < p[j].a) continue;         if (add > maxim) {           add = add - maxim;           count += p[j].b * maxim;         } else {           count += add * p[j].b;           add = 0;         }       }       cout << count << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int columns[n + 1];     memset(columns, 0, sizeof(columns));     for (int i = 0; i < m; i++) {       int tmp;       cin >> tmp;       columns[tmp]++;     }     int ans = 1001;     for (int i = 1; i <= n; i++) {       ans = min(ans, columns[i]);     }     cout << ans << endl;     return 0;   }