malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool mark[1234][1234];   char a[1234][1234];   int n, m, com;   int id[1234][1234];   vector<pair<int, int> > node;   int mX[10] = {-1, -1, -1, 0, 0, 1, 1, 1};   int mY[10] = {-1, 0, 1, -1, 1, -1, 0, 1};   inline void dfs(int x, int y) {     mark[x][y] = true;     if (x == n || y == m) {       node.push_back(pair<int, int>(-1, -1));       return;     }     for (int i = 0; i < 8; i++) {       int X = x + mX[i];       int Y = y + mY[i];       if (a[X][Y] ==  1  && id[X][Y] != com) {         id[X][Y] = com;         node.push_back(pair<int, int>(X, Y));       } else if (!mark[X][Y] && a[X][Y] ==  0 ) {         dfs(X, Y);       }     }   }   inline int dfs2(int x, int y) {     id[x][y] = -1;     int ret = 1;     if (id[x - 1][y] == com) ret += dfs2(x - 1, y);     if (id[x + 1][y] == com) ret += dfs2(x + 1, y);     if (id[x][y - 1] == com) ret += dfs2(x, y - 1);     if (id[x][y + 1] == com) ret += dfs2(x, y + 1);     return ret;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf(  %c , &a[i][j]);     int res = 0;     for (int i = 1; i < n; i++)       for (int j = 1; j < m; j++)         if (a[i][j] ==  1  && a[i + 1][j] ==  1  && a[i][j + 1] ==  1  &&             a[i + 1][j + 1] ==  1 )           res = 4;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++)         if (!mark[i][j] && a[i][j] ==  0 ) {           com++;           node.clear();           dfs(i, j);           if (node.size() < 5) continue;           bool wr = false;           for (int z = 0; z < (int)node.size(); z++) {             int x = node[z].first;             int y = node[z].second;             if (x == -1 || y == -1) {               wr = true;               break;             }             int deg = (id[x - 1][y] == id[x][y]) + (id[x + 1][y] == id[x][y]) +                       (id[x][y - 1] == id[x][y]) + (id[x][y + 1] == id[x][y]);             if (deg != 2) {               wr = true;               break;             }           }           if (!wr) {             int p = dfs2(node[0].first, node[0].second);             if (p == (int)node.size()) res = max(res, (int)node.size());           }         }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f(vector<int>& a, int x) {     if (a[x] == x) return x;     a[x] = f(a, a[x]);     return a[x];   }   bool mer(vector<int>& a, int x, int y) {     if (f(a, x) == f(a, y))       return true;     else       return false;   }   void uni(vector<int>& a, int x, int y) {     if (mer(a, x, y))       return;     else       a[f(a, y)] = f(a, x);   }   bool s[100005];   int main() {     int n, ma, mb, x, y;     cin >> n >> ma >> mb;     vector<int> a(n + 1), b(n + 1);     for (int i = 0; i <= n; i++) a[i] = b[i] = i;     for (int i = 0; i < ma; i++) {       cin >> x >> y;       uni(a, x, y);     }     for (int i = 0; i < mb; i++) {       cin >> x >> y;       uni(b, x, y);     }     vector<pair<int, int>> c;     vector<int> e, f;     for (int i = 1; i <= n; i++) {       if (!mer(a, 1, i) && !mer(b, 1, i)) {         c.push_back(pair<int, int>(1, i));         uni(a, 1, i);         uni(b, 1, i);       }     }     int i, j;     i = j = 2;     while (1) {       while (i <= n && mer(a, 1, i)) i++;       if (i > n) break;       while (j <= n && mer(b, 1, j)) j++;       if (j > n) break;       uni(a, i, j);       uni(b, i, j);       c.push_back(pair<int, int>(i, j));       i++;       j++;     }     cout << c.size() << endl;     for (int i = 0; i < c.size(); i++) {       cout << c[i].first <<     << c[i].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5010;   const int inf = 1e9;   const int mo = 1e9 + 7;   int s[N], num[N][N], ans[N], gra[N][N];   int main() {     int n, m;     cin >> n >> m;     for (auto i = (1); i <= (n); ++i) {       cin >> s[i];     }     memset(num, 0, sizeof(num));     memset(gra, 0, sizeof(gra));     memset(ans, -1, sizeof(ans));     for (auto i = (1); i <= (n); ++i) {       for (auto j = (i); j <= (n); ++j) {         gra[s[i]][j]++;       }     }     for (auto i = (1); i <= (m); ++i) {       int f, h;       cin >> f >> h;       for (auto j = (h); j <= (n); ++j) {         num[f][j]++;       }     }     for (auto i = (0); i <= (n); ++i) {       int cntl = gra[s[i]][i], cntr = gra[s[i]][n] - gra[s[i]][i];       if (i && !(num[s[i]][cntl] - num[s[i]][cntl - 1])) continue;       long long cur = 0, tmp = 1;       if (i) cur++;       int sr = num[s[i]][cntr];       if (cntr >= cntl) sr--;       if (sr >= 1) {         cur++;         tmp *= sr;       }       for (auto j = (1); j <= (n); ++j) {         if (j == s[i]) continue;         int cntl = gra[j][i - 1], cntr = gra[j][n] - gra[j][i];         int sl = num[j][cntl], sr = num[j][cntr];         if (!sr && !sl)           continue;         else if (!sl) {           tmp = (tmp * sr) % mo;           cur++;         } else if (!sr) {           tmp = (tmp * sl) % mo;           cur++;         } else if (sl == 1 && sr == 1) {           cur += 1;           tmp = tmp * 2 % mo;         } else {           cur += 2;           tmp = (tmp * (sl * sr - min(sl, sr))) % mo;         }       }       if (ans[cur] == -1) ans[cur] = 0;       ans[cur] = (ans[cur] + tmp) % mo;     }     ans[0] = 1;     for (auto i = (n); i >= (0); --i) {       if (ans[i] != -1) {         cout << i <<     << ans[i];         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[2000];   vector<int> w[2000];   vector<int> z;   int f[2000];   int c[2000];   void dfs(int x) {     f[x] = 1;     for (int i = 0; i < v[x].size(); i++) {       if (f[v[x][i]] == 0) dfs(v[x][i]);     }     z.push_back(x);   }   void dfs2(int x, int k) {     f[x] = 1;     c[x] = k;     for (int i = 0; i < w[x].size(); i++) {       if (f[w[x][i]] == 0) dfs2(w[x][i], k);     }   }   int scc(int n) {     int k = 0;     for (int i = 0; i < n; i++) f[i] = 0;     z.clear();     for (int i = 0; i < n; i++) {       if (f[i] == 0) dfs(i);     }     for (int i = 0; i < n; i++) f[i] = 0;     for (int i = z.size() - 1; i >= 0; i--) {       if (f[z[i]] == 0) dfs2(z[i], k++);     }     return k;   }   int main() {     int n, i, j;     scanf( %d , &n);     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++) {         int x;         scanf( %d , &x);         if (x > 0) {           v[i].push_back(j);           w[j].push_back(i);         }       }     }     if (scc(n) == 1) {       puts( YES );     } else {       puts( NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5;   int n;   long long x, m, ans;   long long f() {     long long a, b, q;     q = (x - 1) % 4;     a = q == 0 ? x - 1 : q == 1 ? 1 : q == 2 ? x : 0;     q = (x + m - 1) % 4;     b = q == 0 ? x + m - 1 : q == 1 ? 1 : q == 2 ? x + m : 0;     return a ^ b;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %lld %lld , &x, &m);       ans ^= f();     }     if (ans)       puts( tolik );     else       puts( bolik );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   struct node {     long long int u, v, w;   } edge[N];   bool cmp(node a, node b) { return a.w < b.w; }   long long int n, m, k, v, ans = 0;   bool special[N];   long long int root[N];   long long int find_root(long long int x) {     if (root[x] == x) return x;     return root[x] = find_root(root[x]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     for (long long int i = 0; i <= k - 1; ++i) {       cin >> v;       special[v] = true;     }     for (long long int i = 0; i <= m - 1; ++i) {       cin >> edge[i].u >> edge[i].v >> edge[i].w;     }     sort(edge, edge + m, cmp);     for (long long int i = 1; i <= n; ++i) root[i] = i;     for (long long int i = 0; i <= m - 1; ++i) {       long long int root_u = find_root(edge[i].u);       long long int root_v = find_root(edge[i].v);       if (root_u != root_v) {         if (special[root_u] && special[root_v]) {           ans = max(ans, edge[i].w);         }         if (special[root_u])           root[root_v] = root_u;         else           root[root_u] = root_v;       }     }     for (long long int j = 1; j <= n; ++j) {       if (special[j]) cout << ans <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int p = 1e9 + 7;   int main() {     int t;     cin >> t;     while (t--) {       int x;       cin >> x;       string s;       cin >> s;       int inl = s.length();       int i = 0;       while (s.length() < x) {         int l1 = s.length();         for (int j = 0; j < (s[i] -  1 ); j++)           s.append(s.substr(i + 1, l1 - i - 1));         i++;       }       s = s.substr(0, x);       long long int prod = 1, temp = 0;       for (int i = x - 1; i >= 0; i--) {         prod = (prod * (s[i] -  0 )) % p;         temp = (temp - prod + p) % p;       }       prod = (prod * inl) % p;       temp = (temp + x + prod) % p;       cout << temp << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     int n, k;     cin >> n >> k;     vector<int> a(n);     for (int &x : a) cin >> x;     bool can = true;     for (int i = k; i < n; ++i) {       if (a[i] != a[k - 1]) {         can = false;         break;       }     }     if (can) {       int head = k - 2;       while (head >= 0 && a[head] == a[k - 1]) head--;       cout << head + 1;     } else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dp[53][53][53];   int n;   pair<int, int> a[53];   bool check(double x) {     for (int i = 0; i <= n + 1; i++) {       for (int j = 0; j <= n + 1; j++) {         for (int k = 0; k <= n + 1; k++) {           dp[i][j][k] = 1e17;         }       }     }     dp[0][0][0] = 0;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= i; j++) {         for (int k = 0; k <= i; k++) {           if (a[i].first < a[i - 1].first) {             if (j - k + 1 >= 0)               dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j - k + 1][k]);             if (j - k >= 0)               dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j - k][k] + a[i].first -                                                  x * a[i].second);           } else if (k - 1 >= 0)             dp[i][j][k] = min(dp[i - 1][j + 1][k],                               dp[i - 1][j][k - 1] + a[i].first - x * a[i].second);           else             dp[i][j][k] = dp[i - 1][j + 1][k];         }       }     }     for (int j = 0; j <= n; j++)       for (int k = 0; k <= n - j; k++)         if (dp[n][j][k] <= 0) return 1;     return 0;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i].first);     for (int i = 1; i <= n; i++) scanf( %d , &a[i].second);     sort(a + 1, a + n + 1, greater<pair<int, int> >());     a[0].first = -1050000000;     double l = 0, r = 5e9, mid;     while (fabs(r - l) > 1e-7) {       mid = (l + r) / 2;       if (check(mid))         r = mid;       else         l = mid;     }     double ans = mid * 1000;     cout << (ans - (long long)ans < 1e-4 ? (long long)ans : (long long)ans + 1)          << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, ans;   int f[1000];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         if (i + j - 1 <= n) {           for (int k = j; k <= i + j - 1; k++) f[k]++;         }       }     for (int i = 1; i <= n; i++) ans = max(ans, f[i]);     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string a, b;   char s[200000], p[50];   int ans = 0;   bool check(int l, int r) {     int j = 1;     for (int i = l; i <= r; ++i) {       if (s[i] != p[j]) {         return false;       }       j++;     }     return true;   }   int main() {     std::ios::sync_with_stdio(false);     cin >> a >> b;     int n = (int)a.size();     int m = (int)b.size();     for (int i = 1; i <= n; ++i) s[i] = a[i - 1];     for (int i = 1; i <= m; ++i) p[i] = b[i - 1];     for (int i = 1; i <= n - m + 1; ++i) {       if (check(i, i + m - 1)) {         s[i + m - 1] =  # ;         ans++;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fib[50010];   int main() {     long long n;     cin >> n;     fib[0] = 1;     fib[1] = 2;     if (n == 1) {       cout << 0;       return 0;     } else if (n == 2) {       cout << 1;       return 0;     }     int i = 1;     while (fib[i] <= n) {       ++i;       fib[i] = fib[i - 2] + fib[i - 1];     }     --i;     cout << i;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 100 + 20;   vector<pair<int, int> > edge, adj[2 * MAX_N];   vector<int> topol;   int mark[2 * MAX_N], node[2 * MAX_N];   int comp;   int ans[2 * MAX_N];   string s;   int n, m;   void readInput() {     cin >> n >> m;     for (int i(0); i < int(m); i++) {       int v, u;       cin >> v >> u;       --v, u--;       edge.push_back(make_pair(v, u));     }   }   int possib(int v, int u, int x) { return (min(v, u) < x & max(v, u) > x); }   inline int f(int x) { return x > 0 ? (x << 1) : ((-x) << 1) + 1; }   void addEdge(int x, int y) {     adj[f(-x)].push_back(make_pair(f(y), 1));     adj[f(y)].push_back(make_pair(f(-x), 0));     adj[f(-y)].push_back(make_pair(f(x), 1));     adj[f(x)].push_back(make_pair(f(-y), 0));   }   void makeGraph() {     for (int i(0); i < int(edge.size()); i++) {       int v = edge[i].first, u = edge[i].second;       for (int j(0); j < int(edge.size()); j++)         if (i != j && min(v, u) < min(edge[j].first, edge[j].second)) {           int x = edge[j].first, y = edge[j].second;           if (min(v, u) == min(x, y) || max(v, u) == max(x, y)) continue;           if (possib(v, u, min(x, y)) && !possib(v, u, max(x, y))) {             addEdge(i + 1, j + 1);             addEdge(-(i + 1), -(j + 1));           }         }     }   }   void tSort(int v) {     if (node[v]) return;     node[v] = 1;     for (int i(0); i < int(adj[v].size()); i++)       if (adj[v][i].second) tSort(adj[v][i].first);     topol.push_back(v);   }   void dfs(int v, int c) {     mark[v] = c;     for (int i(0); i < int(adj[v].size()); i++) {       int u = adj[v][i].first, type = adj[v][i].second;       if (type || mark[u]) continue;       dfs(u, c);     }   }   void judge(int v, int u) {     if (ans[v] == -1 && ans[u] == -1) {       ans[v] = 1;       ans[u] = 0;       if (u > v) swap(ans[v], ans[u]);     } else if (ans[v] != -1)       ans[u] = ans[v] ^ 1;     else       ans[v] = ans[u] ^ 1;   }   int solve() {     for (int i(1); i < int(m + 1); i++) {       tSort(f(i));       tSort(f(-i));     }     reverse(topol.begin(), topol.end());     for (int i(0); i < int(topol.size()); i++) {       int v = topol[i];       if (!mark[v]) dfs(v, ++comp);     }     for (int i(1); i < int(m + 1); i++)       if (mark[f(i)] == mark[f(-i)]) return 0;     for (int i(1); i < int(comp + 1); i++) ans[i] = -1;     for (int i(1); i < int(m + 1); i++) judge(mark[f(i)], mark[f(-i)]);     for (int i(1); i < int(m + 1); i++) s += (ans[mark[f(i)]] == 1 ?  i  :  o );     return 1;   }   int main() {     ios::sync_with_stdio(false);     readInput();     makeGraph();     cout << (solve() == 1 ? s :  Impossible ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T read() {     T x = 0, w = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) w = -w;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     return x * w;   }   template <class T>   inline T read(T& x) {     return x = read<T>();   }   const int P = 1e9 + 7;   inline int add(int a, int b) { return (a += b) >= P ? a - P : a; }   inline int mul(int a, int b) { return (long long)a * b % P; }   inline int fpow(int a, int b) {     int ans = 1;     for (; b; b >>= 1, a = mul(a, a))       if (b & 1) ans = mul(ans, a);     return ans;   }   inline void chkadd(int& a, int b) { (a += b) >= P ? a -= P : 0; }   char S[1002], X[52], Y[52];   int ch[25000][10], fa[25000], val[25000], tot;   int F[51][25000][2][2];   int main() {     scanf( %s , S + 1);     int n = strlen(S + 1);     scanf( %s%s , X + 1, Y + 1);     int d = strlen(X + 1);     if (n < d / 2) {       puts( 0 );       return 0;     }     for (int i = 1; i + d / 2 - 1 <= n; ++i) {       int x = 0;       for (int j = i; j <= i + d / 2 - 1; ++j) {         int c = S[j] -  0 ;         if (!ch[x][c]) ch[x][c] = ++tot;         x = ch[x][c];       }       val[x] = 1;     }     deque<int> Q;     for (int c = 0; c <= 9; ++c)       if (ch[0][c]) Q.push_back(ch[0][c]);     while (Q.size()) {       int x = Q.front();       Q.pop_front();       for (int c = 0; c <= 9; ++c) {         if (!ch[x][c])           ch[x][c] = ch[fa[x]][c];         else           fa[ch[x][c]] = ch[fa[x]][c], Q.push_back(ch[x][c]);       }     }     for (int x = 0; x <= tot; ++x)       if (val[x]) fill(ch[x], ch[x] + 10, x);     F[0][0][1][1] = 1;     for (int i = 1; i <= d; ++i)       for (int x = 0; x <= tot; ++x)         for (int l = 0; l <= 1; ++l)           for (int r = 0; r <= 1; ++r) {             if (!F[i - 1][x][l][r]) continue;             for (int c = 0; c <= 9; ++c) {               if (l and c < X[i] -  0 ) continue;               if (r and c > Y[i] -  0 ) continue;               chkadd(F[i][ch[x][c]][l and c == X[i] -  0 ][r and c == Y[i] -  0 ],                      F[i - 1][x][l][r]);             }           }     int ans = 0;     for (int x = 0; x <= tot; ++x)       if (val[x])         for (int l = 0; l <= 1; ++l)           for (int r = 0; r <= 1; ++r) chkadd(ans, F[d][x][l][r]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( -O2 )   using namespace std;   void err(istream_iterator<string> it) {}   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a << endl;     err(++it, args...);   }   const int LIM = 1e5 + 5, MOD = 1e9 + 7;   int t, n, m, k, x, y;   map<int, int> M;   int solve(int m) {     if (m < k) return 0;     if (M.find(m) != M.end()) return M[m];     vector<int> a(3000, 0);     for (int i = 1; i < (int)1e5; i++) {       if (i * i > m) break;       if (m % i == 0) {         if (i > 1 && i & 1 && m / i >= k)           a[solve(m / i)] |= 1;         else if (m / i >= k && i > 1)           a[0] |= 1;         if (m / i > 1 && (m / i) & 1 && i >= k)           a[solve(i)] |= 1;         else if (i >= k && m / i > 1)           a[0] |= 1;       }     }     int ans = 0;     while (a[ans]) ans++;     return M[m] = ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     if (n & 1) {       int ans = solve(m);       if (ans)         cout <<  Timur n ;       else         cout <<  Marsel n ;     } else       cout <<  Marsel n ;     return 0;   }
#include <bits/stdc++.h>   const int maxn = 100005;   const int mod = 1000000007;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   using namespace std;   char s[10];   int n, h;   int main() {     while (~scanf( %s , s + 1)) {       scanf( %d%d , &n, &h);       if (s[1] ==  B ) {         printf( %d n , n);         continue;       }       double ans = n;       double mi = 1;       for (int i = 1; i <= h; i++) {         mi *= 2;         double t = 1;         for (int j = 1; j <= n; j++) {           ans += (n - j) * 1.0 / (mi * mi) * t *                  (mi - mi / 2.0 * (1.0 + (j - 1) / (mi - 1)));           t *= (1.0 - 1.0 / mi);         }       }       printf( %.9lf n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const double eps = 1e-12;   const int inf = 2000000000;   const long long int infLL = (long long int)2e18;   long long int MOD = 998244353;   int MOD1 = 1000000007;   int MOD2 = 1000000009;   inline bool checkBit(long long int n, long long int i) {     return n & (1LL << i);   }   inline long long int setBit(long long int n, long long int i) {     return n | (1LL << i);     ;   }   inline long long int resetBit(long long int n, long long int i) {     return n & (~(1LL << i));   }   int dx[] = {0, 0, +1, -1};   int dy[] = {+1, -1, 0, 0};   inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }   inline bool isLeapYear(long long int year) {     return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);   }   inline void normal(long long int &a) {     a %= MOD;     (a < 0) && (a += MOD);   }   inline long long int modMul(long long int a, long long int b) {     a %= MOD, b %= MOD;     normal(a), normal(b);     return (a * b) % MOD;   }   inline long long int modAdd(long long int a, long long int b) {     a %= MOD, b %= MOD;     normal(a), normal(b);     return (a + b) % MOD;   }   inline long long int modSub(long long int a, long long int b) {     a %= MOD, b %= MOD;     normal(a), normal(b);     a -= b;     normal(a);     return a;   }   inline long long int modPow(long long int b, long long int p) {     long long int r = 1LL;     while (p) {       if (p & 1) r = modMul(r, b);       b = modMul(b, b);       p >>= 1LL;     }     return r;   }   inline long long int modDiv(long long int a, long long int b) {     return modMul(a, modPow(b, MOD - 2));   }   bool comp(const pair<long long int, pair<long long int, long long int> > &p1,             const pair<long long int, pair<long long int, long long int> > &p2) {     return p1.first > p2.first;   }   bool comp1(const pair<long long int, long long int> &p1,              const pair<long long int, long long int> &p2) {     if (p1.first == p2.first) {       return p1.second > p2.second;     }     return p1.first < p2.first;   }   long long int converter(string a) {     long long int i, mul = 1, r, t, ans = 0LL;     if (a.length() == 0) return 0;     for (i = a.length() - 1; i >= 0; i--) {       t = a[i] -  0 ;       r = t % 10;       ans += (mul * r);       mul = mul * 10;     }     return ans;   }   int msb(unsigned x) {     union {       double a;       int b[2];     };     a = x;     return (b[1] >> 20) - 1023;   }   const int MAX = (int)1e5 + 5;   int n, m, a[MAX], tp[MAX], b[MAX];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int i, j, k;     cin >> n >> m;     for (i = 1; i <= m; ++i) {       cin >> a[i];       tp[a[i]]++;     }     int tot = 0;     for (i = 1; i <= m; ++i) {       if (tp[a[i]] > 0) b[++tot] = tp[a[i]], tp[a[i]] = 0;     }     for (i = 1000; i >= 1; --i) {       long long int xx = 0LL;       for (j = 1; j <= tot; ++j) {         xx += (b[j] / i);       }       if (xx >= n) {         cout << i <<   n ;         return 0;       }     }     cout << 0 <<   n ;     return 0;   }