malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int solve(vector<int> &v, int pow) {     if (pow == 20) {       for (int j : v) {         if (j) return 40;       }       return 0;     }     bool fnd = false;     for (int i = 0; i < v.size(); i++) {       if (v[i] % (1 << (pow + 1))) {         fnd = true;       }     }     if (!fnd)       return solve(v, pow + 1);     else {       vector<int> v2(v);       for (int i = 0; i < v.size(); i++) {         if (v[i] % (1 << (pow + 1))) {           v2[i] += (1 << pow);         }       }       sort(v2.begin(), v2.end());       v2.erase(unique(v2.begin(), v2.end()), v2.end());       int tmp = 1 + solve(v2, pow + 1);       v2.clear();       for (int i = 0; i < v.size(); i++) {         v2.push_back(v[i]);       }       for (int i = 0; i < v.size(); i++) {         if (v[i] % (1 << (pow + 1))) {           v2[i] -= (1 << pow);         }       }       sort(v2.begin(), v2.end());       v2.erase(unique(v2.begin(), v2.end()), v2.end());       return min(tmp, 1 + solve(v2, pow + 1));     }   }   int main() {     int N;     cin >> N;     vector<int> v(N);     for (int i = 0; i < N; i++) {       cin >> v[i];     }     int ans = solve(v, 0);     cout << ans << endl;     vector<int> lvl(v);     int rank = 0;     while (rank != 20) {       bool fnd = false;       for (int i = 0; i < v.size(); i++) {         if (v[i] % (1 << (rank + 1))) {           fnd = true;         }       }       if (!fnd) {         rank++;       } else {         vector<int> v2(v);         vector<int> v3(v);         for (int i = 0; i < v.size(); i++) {           if (v[i] % (1 << (rank + 1))) {             v2[i] += (1 << rank);           }         }         sort(v2.begin(), v2.end());         v2.erase(unique(v2.begin(), v2.end()), v2.end());         int tmp = 1 + solve(v2, rank + 1);         for (int i = 0; i < v.size(); i++) {           if (v[i] % (1 << (rank + 1))) {             v3[i] -= (1 << rank);           }         }         sort(v3.begin(), v3.end());         v3.erase(unique(v3.begin(), v3.end()), v3.end());         int tmp2 = 1 + solve(v3, rank + 1);         if (tmp < tmp2) {           cout << -(1 << rank) <<    ;           v = v2;         } else {           cout << (1 << rank) <<    ;           v = v3;         }         rank++;       }     }     cout << endl;   }
#include <bits/stdc++.h>      using namespace std;   using ll = long long;      const ll maxc = 1000000, sz = maxc + 5, modint = 998244353;   ll arrleq2[sz] = {}, arr1[sz] = {}, arr2[sz] = {}, arr3[sz] = {};      int main() {       //ios_base::sync_with_stdio(0); cin.tie(0);       arrleq2[0] = 1;       ll sum = 0;       for (int i = 1; i <= maxc; i++) {           arrleq2[i] = arrleq2[i - 1] * (sum + 1) + arrleq2[i - 1] * (arrleq2[i - 1] + 1) / 2;           arrleq2[i] %= modint;           arr3[i] = arrleq2[i - 1] * (arrleq2[i - 1] + 1) / 2 % modint * (arrleq2[i - 1] + 2) % modint;           while (arr3[i] % 3) arr3[i] += modint;           arr3[i] /= 3;           arr3[i] += arrleq2[i - 1] * (arrleq2[i - 1] + 1) / 2 % modint * sum % modint;           arr3[i] += sum * (sum + 1) / 2 % modint * arrleq2[i - 1];           arr3[i] %= modint;           sum += arrleq2[i - 1];           sum %= modint;       }       arr1[0] = 0; arr2[0] = 0;       for (int i = 1; i <= maxc; i++) {           arr1[i] = arrleq2[i - 1];           arr2[i] = (arrleq2[i] - arr1[i] + modint) % modint;       }       //for (int i = 1; i <= 20; i++) cout << arrleq2[i] <<    ; cout <<   n ;       //f//or (int i = 1; i <= 20; i++) cout << arr1[i] <<    ; cout <<   n ;       //for (int i = 1; i <= 20; i++) cout << arr2[i] <<    ; cout <<   n ;       //for (int i = 1; i <= 20; i++) cout << arr3[i] <<    ; cout <<   n ;          int n;       cin >> n;       ll res = arr3[n] * 2 % modint;       for (int i = 0; i <= n; i++) {           if (i == 0) res += arrleq2[n];           else res += arr1[n - i] * arr2[i];           res %= modint;       }       res = (res + arr2[n]) % modint;       cout << res;       return(0);   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char** argv) {     int t;     cin >> t;     while (t--) {       long long int n, k;       cin >> n >> k;       long long int q = k / (n - 1);       long long int r = k % (n - 1);       if (r == 0) {         cout << n * q - 1 <<   n ;       } else {         cout << n * q + r <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string res, s[100005], temp, given;   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, pos;     bool valid = false;     temp =  <3 ;     cin >> n;     res =   ;     res += temp;     for (int i = 0; i < n; i++) {       cin >> s[i];       res += s[i];       res += temp;     }     pos = 0;     cin >> given;     for (int i = 0; i < given.length(); i++) {       if (given[i] == res[pos]) pos++;       if (pos == res.length()) {         valid = true;         break;       }     }     if (valid)       cout <<  yes n ;     else       cout <<  no n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ans, flag, a[20][300010], n, i, x, anx[20], as[20];   void dfs(int x, int y) {     if (y >= ans) return;     if (x < 2) {       anx[1] = 0;       if (a[x][0]) {         y++;         anx[1] = -1;       }       if (a[x][2]) {         y++;         anx[1] = 1;       }       if (y < ans) {         ans = y;         for (int i = 1; i <= 18; i++) as[i] = anx[i];       }       return;     }     int flag = 0;     for (int i = 0; i <= 1 << x - 1; i++) a[x - 1][i] = 0;     for (int i = 0; i <= 1 << x; i++)       if (a[x][i]) {         if (i & 1) flag = 1;         a[x - 1][i >> 1] = 1;       }     anx[x] = flag;     dfs(x - 1, y + flag);     if (flag) {       for (int i = 0; i <= 1 << x - 1; i++) a[x - 1][i] = 0;       for (int i = 0; i <= 1 << x; i++)         if (a[x][i]) a[x - 1][i + 1 >> 1] = 1;       anx[x] = -flag;       dfs(x - 1, y + flag);     }   }   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &x), a[18][x + (1 << 17)] = 1;     ans = 20;     dfs(18, 0);     printf( %d n , ans);     for (i = 18; i >= 1; i--)       if (as[i]) printf( %d  , as[i] * (1 << 18 - i));   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     const long long inf = 1e9;     long long n;     cin >> n;     vector<pair<long long, long long> > m(n);     for (int i = 0; i < n; i++) cin >> m[i].first >> m[i].second;     long long maxy = -inf, miny = inf, maxx = -inf, minx = inf;     long long maxyp, maxxp, minxp, minyp;     for (int i = 0; i < n; i++) {       if (maxy < m[i].second) maxyp = i;       if (maxx < m[i].first) maxxp = i;       if (miny > m[i].second) minyp = i;       if (minx > m[i].first) minxp = i;       maxy = max(maxy, m[i].second);       miny = min(miny, m[i].second);       maxx = max(maxx, m[i].first);       minx = min(minx, m[i].first);     }     long long maxans = -inf;     for (int i = 0; i < n; i++) {       maxans = max((maxx - min(m[maxyp].first, m[i].first) + maxy -                     min(m[maxxp].second, m[i].second)) *                        2,                    maxans);       maxans = max((maxx - min(m[minyp].first, m[i].first) +                     max(m[maxxp].second, m[i].second) - miny) *                        2,                    maxans);       maxans = max((max(m[minyp].first, m[i].first) - minx +                     max(m[minxp].second, m[i].second) - miny) *                        2,                    maxans);       maxans = max((max(m[maxyp].first, m[i].first) - minx + maxy -                     min(m[minxp].second, m[i].second)) *                        2,                    maxans);     }     cout << maxans <<    ;     for (int i = 4; i <= n; i++) {       cout << (maxy - miny + maxx - minx) * 2 <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int get() {     char ch;     while (ch = getchar(), (ch <  0  || ch >  9 ) && ch !=  - )       ;     if (ch ==  - ) {       int s = 0;       while (ch = getchar(), ch >=  0  && ch <=  9 ) s = s * 10 + ch -  0 ;       return -s;     }     int s = ch -  0 ;     while (ch = getchar(), ch >=  0  && ch <=  9 ) s = s * 10 + ch -  0 ;     return s;   }   const int N = 100005;   const int L = 262144;   int n, a[N];   int d[20][N];   int ans[40];   int key[40];   void dfs(int x) {     if (d[x - 1][0] == 1) {       if (d[x - 1][1] != 0) return;       if (key[0] < ans[0]) {         ans[0] = key[0];         for (int i = 1; i <= key[0]; i++) ans[i] = key[i];       }       return;     }     int mv = 1 << 19;     for (int i = 1; i <= d[x - 1][0]; i++) {       int v = abs(d[x - 1][i]);       if ((v & -v) > 0) mv = min(mv, v & -v);     }     if (mv == (1 << 19)) return;     key[++key[0]] = mv;     d[x][0] = 0;     for (int i = 1; i <= d[x - 1][0]; i++) {       if ((d[x - 1][i] & mv) > 0)         d[x][++d[x][0]] = d[x - 1][i] - mv;       else         d[x][++d[x][0]] = d[x - 1][i];     }     sort(d[x] + 1, d[x] + 1 + d[x][0]);     int k = 1;     for (int i = 2; i <= d[x][0]; i++)       if (d[x][i] != d[x][i - 1]) d[x][++k] = d[x][i];     d[x][0] = k;     dfs(x + 1);     key[key[0]] = -mv;     d[x][0] = 0;     for (int i = 1; i <= d[x - 1][0]; i++) {       if ((d[x - 1][i] & mv) > 0)         d[x][++d[x][0]] = d[x - 1][i] + mv;       else         d[x][++d[x][0]] = d[x - 1][i];     }     sort(d[x] + 1, d[x] + 1 + d[x][0]);     k = 1;     for (int i = 2; i <= d[x][0]; i++)       if (d[x][i] != d[x][i - 1]) d[x][++k] = d[x][i];     d[x][0] = k;     dfs(x + 1);     key[0]--;   }   int main() {     n = get();     for (int i = 1; i <= n; i++) a[i] = get();     ans[0] = 100;     a[++n] = 0;     sort(a + 1, a + 1 + n);     int n_ = 1;     for (int i = 2; i <= n; i++)       if (a[i] != a[i - 1]) a[++n_] = a[i];     n = n_;     for (int i = 1; i <= n; i++) d[0][i] = a[i];     d[0][0] = n;     dfs(1);     printf( %d n , ans[0]);     for (int i = 1; i <= ans[0]; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2097155;   int n, mS;   char s[MAXN], t[MAXN];   long long a[MAXN], b[MAXN], bt[MAXN];   inline void FWT_or(long long *F, int len, int typ) {     for (int i = 0; i < n; ++i) {       for (int S = 0; S < len; ++S) {         if (S >> i & 1) {           F[S] = F[S] + typ * F[S ^ (1 << i)];         }       }     }     return;   }   inline int popcount(int x) {     int cnt = 0;     while (x) {       x -= (x & (-x));       cnt++;     }     return cnt;   }   inline void init() {     bt[0] = 1;     for (int i = 1; i <= n; ++i) bt[i] = bt[i - 1] * 4ll;     return;   }   int main() {     scanf( %d , &n);     scanf( %s , s);     scanf( %s , t);     mS = (1 << n);     init();     for (int i = 0; i < mS; ++i) {       a[i] = (15ll & s[i]) << (popcount(i) << 1);     }     for (int i = 0; i < mS; ++i) {       b[i] = (15ll & t[i]) << (popcount(i) << 1);     }     FWT_or(a, mS, 1);     FWT_or(b, mS, 1);     for (int i = 0; i < mS; ++i) {       a[i] = a[i] * b[i];     }     FWT_or(a, mS, -1);     for (int i = 0; i < mS; ++i) printf( %lld , (a[i] >> (popcount(i) << 1) & 3));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   long long aa[maxn];   long long bb[maxn];   vector<long long> gou;   int in[maxn << 2];   long long Z[maxn << 2];   set<long long> ans;   int main() {     int n;     long long m;     scanf( %d%lld , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %lld , &aa[i]);     bb[1] = ((aa[1] - aa[n]) + m) % m;     for (int i = 2; i <= n; ++i) bb[i] = ((aa[i] - aa[i - 1]) % m + m) % m;     for (int i = n; i; --i) {       gou.push_back(bb[i]);       in[gou.size() - 1] = i;     }     gou.push_back(-1LL);     for (int i = 1; i <= n; ++i) {       gou.push_back(bb[i]);       in[gou.size() - 1] = i;     }     for (int i = 1; i <= n; ++i) {       gou.push_back(bb[i]);       in[gou.size() - 1] = i;     }     Z[0] = gou.size();     for (int i = 1, j = 1, k; i < (int)gou.size(); i = k) {       j = max(j, i);       while (gou[j] == gou[j - i]) ++j;       Z[i] = j - i;       k = i + 1;       while (k + Z[k - i] < j) {         Z[k] = Z[k - i];         ++k;       }     }     for (int i = 1; i < (int)gou.size(); ++i)       if (Z[i] >= n) ans.insert((aa[in[i] - 1 ? in[i] - 1 : n] + aa[n]) % m);     printf( %d n , (int)ans.size());     for (auto it = ans.begin(); it != ans.end(); ++it) printf( %lld  , *it);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 * 100 + 5;   const long long inf = 9223372036854775807;   int n, q, cnt, mark[3][maxn];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n >> q;     for (int i = 1; i <= q; i++) {       int x, y;       cin >> x >> y;       if (mark[x][y] == 0) {         mark[x][y] = 1;         if (mark[3 - x][y] == 1) cnt++;         if (mark[3 - x][y - 1] == 1) cnt++;         if (mark[3 - x][y + 1] == 1) cnt++;       } else {         mark[x][y] = 0;         if (mark[3 - x][y] == 1) cnt--;         if (mark[3 - x][y - 1] == 1) cnt--;         if (mark[3 - x][y + 1] == 1) cnt--;       }       if (cnt > 0)         cout <<  No ;       else         cout <<  Yes ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char* argv[]) {     int n;     scanf( %d , &n);     int c1 = 0, c2 = 0;     for (int i = 0; i < n; ++i) {       int a;       scanf( %d , &a);       if (a == 1)         ++c1;       else         ++c2;     }     int ans = min(c2, c1);     c1 -= ans;     if (c1 > 0) ans += c1 / 3;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long read() {     long long num = 0;     int fix = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) fix = -1;       ch = getchar();     }     while (isdigit(ch)) {       num = num * 10 + ch -  0 ;       ch = getchar();     }     return num * fix;   }   const int mod = 1e9 + 7;   const int MAXN = 50;   int N, K;   int W[MAXN + 1];   long long fact[MAXN + 1], inv[MAXN + 1];   struct data {     int x, y, pos;   };   long long power(long long x, long long y) {     long long res = 1;     while (y) {       if (y & 1) res = res * x % mod;       x = x * x % mod;       y >>= 1;     }     return res;   }   void initial() {     fact[0] = 1;     for (int i = 1; i <= MAXN; i++) {       fact[i] = fact[i - 1] * i % mod;     }     inv[MAXN] = power(fact[MAXN], mod - 2);     for (int i = MAXN - 1; i >= 0; i--) {       inv[i] = inv[i + 1] * (i + 1) % mod;     }   }   int flag = -1;   int dp[MAXN + 1][MAXN + 1][2];   long long num[MAXN + 1][MAXN + 1][2];   long long C(int x, int y) { return fact[y] * inv[x] % mod * inv[y - x] % mod; }   void BFS(int a, int b) {     memset(dp, -1, sizeof(dp));     dp[a][b][0] = 0, num[a][b][0] = 1;     queue<data> que;     que.push((data){a, b, 0});     while (!que.empty()) {       if (flag != -1 && que.front().pos == flag) break;       data cur = que.front();       que.pop();       int x, y, fix;       if (cur.pos)         x = a - cur.x, y = b - cur.y, fix = 1;       else         x = cur.x, y = cur.y, fix = -1;       for (int i = 0; i <= x; i++) {         for (int j = 0; j <= y; j++) {           if (i + j == 0) continue;           if (i * 50 + j * 100 > K) continue;           int newx = cur.x + i * fix, newy = cur.y + j * fix;           if (dp[newx][newy][cur.pos ^ 1] != -1) {             if (dp[newx][newy][cur.pos ^ 1] == dp[cur.x][cur.y][cur.pos] + 1) {               (num[newx][newy][cur.pos ^ 1] +=                num[cur.x][cur.y][cur.pos] * C(i, x) % mod * C(j, y) % mod) %= mod;             }             continue;           }           dp[newx][newy][cur.pos ^ 1] = dp[cur.x][cur.y][cur.pos] + 1;           num[newx][newy][cur.pos ^ 1] =               num[cur.x][cur.y][cur.pos] * C(i, x) % mod * C(j, y) % mod;           if (newx + newy == 0) {             flag = !cur.pos;           }           que.push((data){newx, newy, cur.pos ^ 1});         }       }     }   }   void solve() {     int cnt50 = 0, cnt100 = 0;     for (int i = 1; i <= N; i++) {       if (W[i] == 50) cnt50++;       if (W[i] == 100) cnt100++;     }     BFS(cnt50, cnt100);     if (flag == -1) {       puts( -1 );       puts( 0 );       return;     }     printf( %d n , dp[0][0][flag]);     printf( %lld n , num[0][0][flag]);   }   int main() {     initial();     N = read(), K = read();     for (int i = 1; i <= N; i++) {       W[i] = read();     }     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char b[101];   char a[101][101];   int mark[101];   int main() {     int n, m, s = 0;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> a[i][j];         if (a[i][j] > b[j]) {           b[j] = a[i][j];         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (a[i][j] == b[j]) {           if (mark[i] == 0) {             s++;             mark[i]++;           }         }       }     }     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const int INF = 0x3f3f3f3f;   const double eps = 1e-8;   const int MAXN = 50 + 10;   const int MOD = 29;   const int dir[][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};   int cases = 0;   int vis[MAXN][MAXN], row, col;   char mp[MAXN][MAXN];   bool DFS(int x, int y, char color, int step) {     for (int i = 0; i < 4; i++) {       int xx = x + dir[i][0], yy = y + dir[i][1];       if (xx < 0 || xx >= row || yy < 0 || yy >= col) continue;       if (mp[xx][yy] != color) continue;       if (vis[xx][yy]) {         if (mp[xx][yy] != color || step - vis[xx][yy] == 1) continue;         return true;       }       vis[xx][yy] = step + 1;       if (DFS(xx, yy, color, step + 1)) return true;     }     return false;   }   int main() {     scanf( %d%d , &row, &col);     for (int i = 0; i < row; i++) scanf( %s , mp[i]);     bool flag = false;     for (int i = 0; i < row; i++)       for (int j = 0; j < col; j++) {         if (!vis[i][j]) {           vis[i][j] = 1;           flag = DFS(i, j, mp[i][j], 1);         }         if (flag) {           puts( Yes );           return 0;         }       }     puts( No );     return 0;   }
#include <bits/stdc++.h>   const int MAX_N = 20;   int n, k, t;   int e[MAX_N + 1][MAX_N + 1];   int choosen[MAX_N + 1];   int mid;   int cnt;   void dfs(int x, int now_cost_sum) {     if (x > n) {       cnt++;       return;     }     dfs(x + 1, now_cost_sum);     for (int y = 1; y <= n && cnt < t; y++) {       if (!choosen[y] && e[x][y] && now_cost_sum + e[x][y] <= mid) {         choosen[y] = 1;         dfs(x + 1, now_cost_sum + e[x][y]);         choosen[y] = 0;       }     }   }   int main() {     scanf( %d%d%d , &n, &k, &t);     for (int i = 1; i <= k; i++) {       int h, w, r;       scanf( %d%d%d , &h, &w, &r);       e[h][w] = r;     }     int low = 0, high = 1000 * n;     while (low < high) {       mid = (low + high) >> 1;       cnt = 0;       dfs(1, 0);       if (cnt >= t)         high = mid;       else         low = mid + 1;     }     printf( %d n , low);   }
#include <bits/stdc++.h>   using namespace std;   map<string, long long> mp;   string S[1006];   long long cost[1006];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int N, i, j, k;     cin >> N;     mp[ A ] = 1e9;     mp[ B ] = 1e9;     mp[ C ] = 1e9;     mp[ AB ] = 1e9;     mp[ AC ] = 1e9;     mp[ BC ] = 1e9;     mp[ ABC ] = 1e9;     for (i = 1; i <= N; i++) {       cin >> cost[i] >> S[i];       sort(S[i].begin(), S[i].end());       mp[S[i]] = min(mp[S[i]], cost[i]);     }     mp[ AB ] = min(mp[ AB ], mp[ A ] + mp[ B ]);     mp[ AC ] = min(mp[ AC ], mp[ A ] + mp[ C ]);     mp[ BC ] = min(mp[ BC ], mp[ B ] + mp[ C ]);     mp[ ABC ] = min(mp[ ABC ], mp[ AB ] + mp[ C ]);     mp[ ABC ] = min(mp[ ABC ], mp[ A ] + mp[ BC ]);     mp[ ABC ] = min(mp[ ABC ], mp[ AC ] + mp[ B ]);     mp[ ABC ] = min(mp[ ABC ], mp[ AB ] + mp[ BC ]);     mp[ ABC ] = min(mp[ ABC ], mp[ AC ] + mp[ BC ]);     mp[ ABC ] = min(mp[ ABC ], mp[ AB ] + mp[ AC ]);     mp[ ABC ] = min(mp[ ABC ], mp[ A ] + mp[ B ] + mp[ C ]);     if (mp[ ABC ] >= (long long)1e9)       printf( -1 n );     else       printf( %d n , mp[ ABC ]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   const int MOD = 1e9 + 7;   int n, m;   vector<int> tmp;   vector<int> g[N];   int cnt1[N];   int marked[N];   int f[N];   map<vector<int>, int> cnt;   int product(int a, int b) { return (1ll * a * b) % MOD; }   void mult(int &a, int b) { a = (1ll * a * b) % MOD; }   int main() {     f[0] = 1;     for (int i = 1; i < N; i++) f[i] = product(f[i - 1], i);     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       int k;       scanf( %d , &k);       for (int j = 0; j < k; j++) {         int x;         scanf( %d , &x);         g[x].push_back(i);       }     }     for (int i = 1; i <= m; i++) cnt[g[i]]++;     int ans = 1;     for (auto p : cnt) {       mult(ans, f[p.second]);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:1000000000 )   static long long m1[70][70];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     m1[0][0] = 1;     for (int i = 1; i <= 30; ++i) {       m1[i][0] = 1;       for (int j = 1; j <= 30; ++j) m1[i][j] = m1[i - 1][j - 1] + m1[i - 1][j];     }     long long n, m, t, r = 0;     cin >> n >> m >> t;     for (int i = 4; i < t; ++i)       if (t - i >= 0) r += m1[n][i] * m1[m][t - i];     cout << r << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   char in[2010][2010];   int deg[2010][2010];   pair<int, int> Q[4000010];   int QL, QR, FREE;   int sft[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};   int get(int x, int y) {     if (x < 0 || x >= N || y < 0 || y >= M) return  * ;     return in[x][y];   }   void say_no() {     puts( Not unique );     exit(0);   }   void put(pair<int, int> a, pair<int, int> b) {     if (a > b) swap(a, b);     if (a.first == b.first)       in[a.first][a.second] =  < , in[b.first][b.second] =  > ;     else       in[a.first][a.second] =  ^ , in[b.first][b.second] =  v ;   }   int main() {     scanf( %d%d , &N, &M);     for (int i = 0; i < N; ++i) scanf( %s , &in[i]);     for (int i = 0; i < N; ++i)       for (int j = 0; j < M; ++j) {         if (in[i][j] ==  * )           deg[i][j] = -1;         else           for (int p = 0; p < 4; ++p)             if (get(i + sft[p][0], j + sft[p][1]) ==  . ) ++deg[i][j];         if (deg[i][j] == 1) Q[QR++] = make_pair(i, j);         if (deg[i][j] >= 0) ++FREE;       }     while (QL < QR) {       pair<int, int> a = Q[QL++];       if (deg[a.first][a.second] != 1) continue;       pair<int, int> b(-1, -1);       for (int p = 0; p < 4; ++p)         if (get(a.first + sft[p][0], a.second + sft[p][1]) ==  . )           b = make_pair(a.first + sft[p][0], a.second + sft[p][1]);       if (b.first < 0) say_no();       deg[a.first][a.second] = -1;       deg[b.first][b.second] = -1;       put(a, b);       FREE -= 2;       for (int p = 0; p < 4; ++p)         if (get(a.first + sft[p][0], a.second + sft[p][1]) ==  . ) {           int x = a.first + sft[p][0];           int y = a.second + sft[p][1];           --deg[x][y];           if (deg[x][y] == 1) Q[QR++] = make_pair(x, y);         }       for (int p = 0; p < 4; ++p)         if (get(b.first + sft[p][0], b.second + sft[p][1]) ==  . ) {           int x = b.first + sft[p][0];           int y = b.second + sft[p][1];           --deg[x][y];           if (deg[x][y] == 1) Q[QR++] = make_pair(x, y);         }     }     if (FREE != 0) say_no();     for (int i = 0; i < N; ++i) {       for (int j = 0; j < M; ++j) printf( %c , in[i][j]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, a[1111], x, n, s, y, f1, f2;   int main() {     cin >> n;     for (i = 0; i < n; i++) {       cin >> x;       if (x == 0 || x == 100)         a[++s] = x;       else if (x < 10 && f1 == 0)         a[++s] = x, f1 = 1;       else if (x % 10 == 0 && f2 == 0)         a[++s] = x, f2 = 1;       else         y = x;     }     if (f1 == 0 && f2 == 0 && y != 0) a[++s] = y;     cout << s <<   n ;     for (i = 1; i <= s; i++) cout << a[i] <<    ;     return 0;   }