malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void upd_min(T& dest, const T& src) {     if (src < dest) dest = src;   }   template <typename T>   inline void upd_max(T& dest, const T& src) {     if (dest < src) dest = src;   }   template <typename T, int n>   struct Queue {     T q[n];     int qf, qr;     Queue() : qf(0), qr(0) {}     inline void clear() { qf = qr = 0; }     inline bool empty() { return qf == qr; }     inline void push(const T& data) {       q[qr] = data;       if (++qr == n) qr = 0;     }     inline void pop() {       if (++qf == n) qf = 0;     }     inline T& front() { return q[qf]; }   };   template <int maxN>   struct Disjoint {     int N;     int p[maxN];     inline void init(int n) {       N = n;       for (int i = 0; i < N; ++i) p[i] = i;     }     inline int root(int i) {       for (; i != p[i]; i = p[i]) p[i] = p[p[i]];       return i;     }     inline void unite(int a, int b) { p[root(b)] = root(a); }     inline bool query(int a, int b) { return root(a) == root(b); }   };   template <typename T, int N>   struct Stack {     T s[N];     int index;     Stack() : index(0) {}     inline void clear() { index = 0; }     inline T& top() { return s[index]; }     inline void pop() { --index; }     inline bool empty() { return index == 0; }     inline void push(T data) { s[++index] = data; }   };   int nextInt() {     int ret;     char c;     while (c = getchar(), c <  0  || c >  9 )       ;     ret = c -  0 ;     while (c = getchar(), c >=  0  && c <=  9 ) ret = ret * 10 + c -  0 ;     return ret;   }   const int inf = 0x7f7f7f7f;   int N;   char c[255];   int main() {     N = nextInt();     for (int t = 1; t <= N; t++) {       scanf( %s , c);       int ll = strlen(c);       int sf(0);       for (int i = 0; i < ll; i++)         if (c[i] ==  : ) sf++;       if (sf == 2 && ll == 2) {         printf( 0000:0000:0000:0000:0000:0000:0000:0000 n );       } else {         int ind(1), k(1);         for (int i = 1; i < ll; i++) {           if (c[i] !=  : )             ind++;           else {             if (c[i - 1] ==  : ) {               if (i == 1) sf--;               for (int j = 1; j <= 8 - sf; j++) {                 if (k != 1) printf( : );                 printf( 0000 );                 k++;               }             } else {               if (k != 1) printf( : );               k++;               for (int j = 1; j <= 4 - ind; j++) printf( 0 );               for (int j = 1; j <= ind; j++) printf( %c , c[i - ind - 1 + j]);             }             ind = 0;           }         }         if (k == 8) {           printf( : );           for (int j = 1; j <= 4 - ind; j++) printf( 0 );           for (int j = 1; j <= ind; j++) printf( %c , c[ll - ind - 1 + j]);         }         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Max = 2e5 + 10;   int n, k;   int v, u;   vector<int> stl[Max];   struct node {     long long cou;     long long huo;     node() { cou = huo = 0; }   } point[Max];   int vis[Max];   long long tot = 0;   void dfs(int idex, int cou) {     vis[idex] = 1;     point[idex].cou = cou;     int flag = 0;     for (int i = 0; i < stl[idex].size(); i++) {       if (vis[stl[idex][i]] == 0) {         dfs(stl[idex][i], cou + 1);         flag = 1;       }     }     if (!flag) {       point[idex].huo = 1;       return;     }     for (int i = 0; i < stl[idex].size(); i++)       point[idex].huo += point[stl[idex][i]].huo;     point[idex].huo++;   }   long long ans[Max];   int main() {     cin >> n >> k;     int flag = 1;     for (int i = 1; i <= n - 1; i++) {       cin >> v >> u;       stl[v].push_back(u);       stl[u].push_back(v);     }     dfs(1, 1);     for (int i = 1; i <= n; i++) {       ans[i] = point[i].cou - point[i].huo;     }     sort(ans + 1, ans + n + 1);     for (int i = n; i > n - k; i--) {       tot += ans[i];     }     cout << tot << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   string s;   int a[4][100];   vector<int> seq;   vector<pair<int, int> > poseq;   bool check() {     for (int i = 0; i < n; i++) {       if (a[1][i] != 0 || a[2][i] != 0) {         return true;       }     }     return false;   }   pair<int, int> next(pair<int, int> pos) {     if (pos.first == 1) {       if (pos.second != 0) {         pos.second -= 1;       } else {         pos.first = 2;       }     } else {       if (pos.second < n - 1) {         pos.second += 1;       } else {         pos.first = 1;       }     }     return pos;   }   void rotate() {     int r, c;     for (int i = 0; i < n; i++) {       if (a[1][i] == 0) {         r = 1;         c = i;       }       if (a[2][i] == 0) {         r = 2;         c = i;       }     }     pair<int, int> init = make_pair(r, c), prev = init, curr = next(init);     while (init != curr) {       if (a[curr.first][curr.second] != 0) {         a[prev.first][prev.second] = a[curr.first][curr.second];         seq.push_back(a[curr.first][curr.second]);         a[curr.first][curr.second] = 0;         poseq.push_back(prev);       }       prev = curr;       curr = next(prev);     }   }   void park() {     for (int i = 0; i < n; i++) {       if (a[1][i] > 0 && a[1][i] == a[0][i]) {         seq.push_back(a[1][i]);         poseq.push_back(make_pair(0, i));         a[1][i] = 0;       }       if (a[2][i] > 0 && a[2][i] == a[3][i]) {         seq.push_back(a[2][i]);         poseq.push_back(make_pair(3, i));         a[2][i] = 0;       }     }   }   void run() {     cin >> n >> k;     for (int i = 0; i < 4; i++) {       for (int j = 0; j < n; j++) {         cin >> a[i][j];       }     }     if (k == 2 * n) {       bool allfull = true;       for (int i = 0; i < n; i++) {         if (a[1][i] == a[0][i] || a[2][i] == a[3][i]) {           allfull = false;           break;         }       }       if (allfull) {         cout << setprecision(30) << -1 << endl;         return;         ;       }     }     park();     while (check()) {       rotate();       park();     }     cout << setprecision(30) << seq.size() << endl;     ;     for (int i = 0; i < (int)seq.size(); i++) {       cout << setprecision(30) << seq[i] <<    ;       ;       cout << setprecision(30) << poseq[i].first + 1 <<    ;       ;       cout << setprecision(30) << poseq[i].second + 1 << endl;       ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int tests = 1;     for (int i = 1; i <= tests; i++) run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, l, r, m;     cin >> n >> k;     deque<pair<int, int>> bfs;     vector<int> lines;     vector<int> ans(n);     --k;     bfs.push_back({0, n});     while (!bfs.empty()) {       l = bfs[0].first;       r = bfs[0].second;       m = (l + r) / 2;       bfs.pop_front();       if (k > 0 && r - l > 1) {         k -= 2;         lines.push_back(m);         bfs.push_back({l, m});         bfs.push_back({m, r});       }     }     if (k != 0) {       cout << -1;       return 0;     } else {       int num = 1;       lines.push_back(0);       lines.push_back(n);       sort(lines.begin(), lines.end());       for (int i = lines.size() - 2; i >= 0; --i) {         for (int j = lines[i]; j != lines[i + 1]; ++j) {           ans[j] = num;           ++num;         }       }     }     for (int i = 0; i != n; ++i) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000010, mod = 1e9 + 7, INF = 0x3f3f3f3f;   const double eps = 1e-6;   int n, m;   int id[N];   vector<int> v[N];   bool st[N];   bool check() {     int cnt = 0;     for (int i = 1; i <= n; i++)       if (!id[i]) {         cnt++;         id[i] = cnt;         int s = 0;         if (cnt > 3) return false;         for (auto x : v[i]) st[x] = 1, s++;         st[i] = 1;         for (int j = 1; j <= n; j++)           if (!st[j]) {             if (id[j]) return false;             id[j] = cnt;             int sum = 0;             for (auto x : v[j]) {               if (!st[x]) return false;               sum++;             }             if (sum != s) return false;           }         for (auto x : v[i]) st[x] = 0;         st[i] = 0;       }     if (cnt < 3) return false;     for (int i = 1; i <= n; i++) printf( %d  , id[i]);     puts(  );     return true;   }   int main() {     scanf( %d%d , &n, &m);     while (m--) {       int a, b;       scanf( %d%d , &a, &b);       v[a].push_back(b);       v[b].push_back(a);     }     if (!check()) puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 1010;   const int inf = 1 << 23;   int ch[Maxn << 1][3], siz[Maxn << 1], maxs[Maxn << 1], alls, core;   bool vis[Maxn << 1];   int n, tot, T;   void dfs(int x, int fa) {     siz[x] = 1;     maxs[x] = 0;     for (int i = 0; i < 3; i++) {       int y = ch[x][i];       if (y == fa || !y || vis[y]) continue;       dfs(y, x);       if (maxs[x] < siz[y]) maxs[x] = siz[y];       siz[x] += siz[y];     }     if (maxs[x] < alls - siz[x]) maxs[x] = alls - siz[x];     if (maxs[x] < maxs[core] || (maxs[x] == maxs[core] && x > core)) core = x;   }   void dfs2(int x, int fa) {     siz[x] = 1;     for (int i = 0; i < 3; i++) {       int y = ch[x][i];       if (y == fa || !y || vis[y]) continue;       dfs(y, x);       siz[x] += siz[y];     }   }   int getl(int x) { return x <= n ? x : getl(ch[x][1]); }   void solve(int x) {     vis[x] = true;     if (x <= n) {       tot++;       int fa = ch[x][0];       if (ch[fa][1] == x)         ch[fa][1] = tot;       else         ch[fa][2] = tot;       ch[tot][0] = fa;       ch[x][0] = tot;       ch[tot][1] = x;       ch[tot][2] = T;       ch[T][0] = tot;       return;     }     int l1 = getl(ch[x][1]), l2 = getl(ch[x][2]);     cout << l1 <<     << l2 <<     << T << endl;     char c;     cin >> c;     if (c ==  X ) {       if (vis[ch[x][0]] || !ch[x][0]) {         tot++;         int fa = ch[x][0];         if (fa) {           if (ch[fa][1] == x)             ch[fa][1] = tot;           else             ch[fa][2] = tot;         }         ch[tot][0] = fa;         ch[x][0] = tot;         ch[tot][1] = x;         ch[tot][2] = T;         ch[T][0] = tot;         return;       }       dfs2(ch[x][0], x);       alls = siz[ch[x][0]];       core = 0;       dfs(ch[x][0], x);       solve(core);     } else if (c ==  Y ) {       if (vis[ch[x][2]]) {         tot++;         ch[tot][0] = x;         ch[tot][1] = ch[x][2];         ch[tot][2] = T;         ch[ch[x][2]][0] = tot;         ch[x][2] = tot;         ch[T][0] = tot;         return;       }       dfs2(ch[x][2], x);       alls = siz[ch[x][2]];       core = 0;       dfs(ch[x][2], x);       solve(core);     } else {       if (vis[ch[x][1]]) {         tot++;         ch[tot][0] = x;         ch[tot][1] = ch[x][1];         ch[tot][2] = T;         ch[ch[x][1]][0] = tot;         ch[x][1] = tot;         ch[T][0] = tot;         return;       }       dfs2(ch[x][1], x);       alls = siz[ch[x][1]];       core = 0;       dfs(ch[x][1], x);       solve(core);     }   }   int main() {     int i, j, k;     cin >> n;     tot = n;     ch[1][0] = ch[2][0] = ++tot;     ch[tot][1] = 1;     ch[tot][2] = 2;     maxs[0] = inf;     for (T = 3; T <= n; T++) {       memset(vis, false, sizeof(vis));       alls = 2 * T - 3;       core = 0;       dfs(1, 0);       solve(core);     }     cout <<  -1  << endl;     for (i = 1; i <= tot; i++) {       if (!ch[i][0])         cout <<  -1  ;       else         cout << ch[i][0] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int to[2000];   char used[2000];   int a[2000];   int s;   char res[3000];   int calc(int x, char &f) {     f = 0;     int cnt = 1;     if (x == s) f = 1;     while (to[x] != -1) {       ++cnt;       x = to[x];       if (x == s) {         f = 1;         cnt = 1;       }     }     return cnt;   }   int main() {     int n, x;     cin >> n >> x;     --x;     s = x;     for (int i = 0; i < n; ++i) to[i] = -1;     for (int i = 0; i < n; ++i) {       cin >> to[i];       --to[i];       if (to[i] >= 0) used[to[i]] = 1;     }     int sl = -1;     int q = 0;     for (int i = 0; i < n; ++i)       if (!used[i]) {         char f;         int len = calc(i, f);         if (f)           sl = len;         else           a[q++] = len;       }     assert(sl != -1);     res[sl] = 1;     for (int i = 0; i < q; ++i) {       for (int j = n; j >= 0; --j)         if (res[j]) res[j + a[i]] = 1;     }     for (int i = 0; i <= n; ++i)       if (res[i]) cout << i <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const int SIZE = 1000005;   char sa[SIZE], sb[SIZE];   char rab[SIZE * 2], ba[SIZE * 2];   int f1[SIZE * 2];   int f2[SIZE * 2];   int main() {     while (gets(sa) && gets(sb)) {       int l1 = strlen(sa);       int l2 = strlen(sb);       if (l1 != l2) {         printf( -1 -1 n );         continue;       }       strcpy(rab, sa);       reverse(rab, rab + l1);       strcat(rab,  # );       strcat(rab, sb);       rab[l1] =   0 ;       strcpy(ba, sb);       strcat(ba,  # );       strcat(ba, sa);       ba[l1] =   0 ;       int n = l1;       f1[0] = 0;       for (int i = 1; i <= 2 * n; i++) {         f1[i] = f1[i - 1];         while (f1[i] > 0 && rab[f1[i]] != rab[i]) f1[i] = f1[f1[i] - 1];         if (rab[f1[i]] == rab[i]) f1[i]++;       }       f2[0] = 0;       for (int i = 1, l = 0, r = 0; i <= 2 * n; i++) {         f2[i] = 0;         if (i <= r) f2[i] = min(f2[i - l], r - i + 1);         while (i + f2[i] <= 2 * n && ba[f2[i]] == ba[i + f2[i]]) f2[i]++;         if (i + f2[i] - 1 > r) {           l = i;           r = i + f2[i] - 1;         }       }       int r1 = -1, r2 = -1;       for (int i = 0; i < n - 1; i++) {         if (sa[i] != sb[n - i - 1]) break;         int len = f1[2 * n - i - 1];         if (f2[n + 1 + i + 1] >= n - i - len - 1) {           r1 = i;           r2 = n - len;         }       }       printf( %d %d n , r1, r2);     }   }
#include <bits/stdc++.h>   using namespace std;   int CeilIndex(int A[], int l, int r, int key) {     int m;     while (r - l > 1) {       m = l + (r - l) / 2;       (A[m] <= key ? l : r) = m;     }     return r;   }   int LongestIncreasingSubsequenceLength(int A[], int size) {     int *tailTable = new int[size];     int len;     memset(tailTable, 0, sizeof(tailTable[0]) * size);     tailTable[0] = A[0];     len = 1;     for (int i = 1; i < size; i++) {       if (A[i] < tailTable[0])         tailTable[0] = A[i];       else if (A[i] >= tailTable[len - 1])         tailTable[len++] = A[i];       else         tailTable[CeilIndex(tailTable, -1, len - 1, A[i])] = A[i];     }     delete[] tailTable;     return len;   }   int main() {     int n, a[100009], c[100009];     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       c[i] = 0;     }     int ans = 0;     ans = LongestIncreasingSubsequenceLength(a, n);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int weight(char c) {     if (c ==  Q  || c ==  q ) return 9;     if (c ==  R  || c ==  r ) return 5;     if (c ==  B  || c ==  b ) return 3;     if (c ==  N  || c ==  n ) return 3;     if (c ==  P  || c ==  p ) return 1;     return 0;   }   int main() {     int white = 0, black = 0;     string board[8];     for (int i = 0; i < 8; i++) {       cin >> board[i];       for (int j = 0; j < 8; j++) {         if (board[i][j] >=  A  && board[i][j] <=  Z )           white += weight(board[i][j]);         else if (board[i][j] >=  a  && board[i][j] <=  z )           black += weight(board[i][j]);       }     }     if (white > black)       cout <<  White ;     else if (white < black)       cout <<  Black ;     else       cout <<  Draw ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200 * 1000 + 10;   struct edge {     int u, v, w;     edge() {}     edge(int u, int v, int w) : u(u), v(v), w(w) {}   } e[N];   vector<int> vec[N];   int n, m, root[N], mx[35][N], par[35][N], h[N], ans[N];   bool mst[N], mark[N];   multiset<int> add[N], rem[N];   bool cmp(int i, int j) { return e[i].w < e[j].w; }   int dfs(int v) {     mark[v] = true;     for (int ind : vec[v]) {       int u = e[ind].u + e[ind].v - v;       if (mst[ind]) {         if (!mark[u]) {           h[u] = h[v] + 1;           par[0][u] = v;           mx[0][u] = e[ind].w;           ans[ind] = dfs(u);           if ((int)add[u].size() > (int)add[v].size()) swap(add[u], add[v]);           for (int x : add[u]) add[v].insert(x);         }       }     }     for (int x : rem[v]) add[v].erase(add[v].find(x));     if (add[v].empty()) return -1;     return *add[v].begin() - 1;   }   void fill_par() {     for (int i = 0; i < n; i++) mark[i] = false;     for (int i = 0; i < 31; i++)       for (int j = 0; j < n; j++) par[i][j] = -1;     dfs(0);     for (int i = 1; i < 31; i++)       for (int j = 0; j < n; j++)         if (par[i - 1][j] != -1) {           mx[i][j] = max(mx[i - 1][j], mx[i - 1][par[i - 1][j]]);           par[i][j] = par[i - 1][par[i - 1][j]];         }   }   int get_root(int v) {     if (v == root[v]) return v;     return root[v] = get_root(root[v]);   }   pair<int, int> get_lca(int u, int v) {     if (h[u] < h[v]) swap(u, v);     int mxe = 0;     for (int i = 30; i >= 0; i--)       if ((h[u] - h[v]) & (1 << i)) {         mxe = max(mxe, mx[i][u]);         u = par[i][u];       }     for (int i = 30; i >= 0; i--)       if (par[i][u] != par[i][v]) {         mxe = max(mxe, mx[i][v]), mxe = max(mxe, mx[i][u]);         u = par[i][u], v = par[i][v];       }     if (u != v) {       mxe = max(mxe, mx[0][v]), mxe = max(mxe, mx[0][u]);       u = par[0][u];     }     return {u, mxe};   }   void merge(int ind, int ty) {     int u = e[ind].u, v = e[ind].v;     int pu = get_root(u), pv = get_root(v);     if (pu != pv) {       mst[ind] = true;       root[pu] = pv;     }     if (pu != pv || !ty) return;     ans[ind] = (get_lca(u, v)).second - 1;   }   void merge() {     for (int i = 0; i < n; i++) root[i] = i;     vector<int> temp(m);     iota(temp.begin(), temp.end(), 0);     sort(temp.begin(), temp.end(), cmp);     for (int i = 0; i < m; i++) merge(temp[i], 0);     fill_par();     for (int i = 0; i < m; i++)       if (!mst[i]) {         int u = e[i].u, v = e[i].v;         int lca = get_lca(u, v).first;         add[u].insert(e[i].w);         add[v].insert(e[i].w);         rem[lca].insert(e[i].w);         rem[lca].insert(e[i].w);       }     fill_par();     for (int i = 0; i < n; i++) root[i] = i;     for (int i = 0; i < m; i++) merge(temp[i], 1);   }   int main() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       u--, v--;       e[i] = edge(u, v, w);       vec[u].push_back(i);       vec[v].push_back(i);     }     merge();     for (int i = 0; i < m; i++) cout << ans[i] <<    n [i == m - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double a, b, m, vx, vy, vz;     cin >> a >> b >> m >> vx >> vy >> vz;     double X = a / 2 - m / vy * vx;     double Z = -m / vy * vz;     while (X < 0 || X > a)       if (X > a)         X = 2 * a - X;       else         X = -X;     while (Z < 0 || Z > b)       if (Z > b)         Z = 2 * b - Z;       else         Z = -Z;     printf( %.9lf %.9lf , X, Z);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char table[500 + 10][500 + 10];   int vis[500 + 10][500 + 10];   int n, m;   int dirr[4] = {1, -1, 0, 0};   int dirc[4] = {0, 0, 1, -1};   vector<tuple<int, int, int> > ans;   int dfs(int i, int j, int depth) {     if (i < 0 || i >= n || j < 0 || j >= m) return 0;     if (vis[i][j] || table[i][j] ==  # ) return 0;     vis[i][j] = 1;     ans.push_back(make_tuple(0, i + 1, j + 1));     for (int d = 0; d < 4; d++) {       dfs(i + dirr[d], j + dirc[d], depth + 1);     }     if (depth > 0) {       ans.push_back(make_tuple(1, i + 1, j + 1));       ans.push_back(make_tuple(2, i + 1, j + 1));     }     return 0;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> table[i][j];       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (table[i][j] ==  # ) continue;         if (vis[i][j] == 0) {           dfs(i, j, 0);         }       }     }     printf( %d n , ans.size());     int a, b, c;     for (tuple<int, int, int> t : ans) {       tie(a, b, c) = t;       if (a == 0) {         printf( B %d %d n , b, c);       } else if (a == 1) {         printf( D %d %d n , b, c);       } else {         printf( R %d %d n , b, c);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     int t;     cin >> t;     while (t--) {       int b[8];       for (int i = 1; i <= 7; ++i) cin >> b[i];       int first = b[7] - b[6];       int last = b[7] - b[5];       cout << first <<     << b[7] - (first + last) <<     << last << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     x = 0;     int 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();     }     x *= f;   }   inline void judge() {     freopen( in.txt ,  r , stdin);     freopen( out.txt ,  w , stdout);   }   const int maxn = 100005;   int fac[maxn], facinv[maxn];   const int mod = 1e9 + 7;   inline int powmod(int a, int b) {     int res = 1;     for (; b; b >>= 1) {       if (b & 1) res = 1ll * res * a % mod;       a = 1ll * a * a % mod;     }     return res;   }   inline void prprpr() {     fac[0] = 1;     for (int i = (1); i <= (100000); i++) fac[i] = 1ll * fac[i - 1] * i % mod;     for (int i = (0); i <= (100000); i++) facinv[i] = powmod(fac[i], mod - 2);   }   inline int C(int n, int m) {     return 1ll * fac[n] * facinv[m] % mod * facinv[n - m] % mod;   }   inline int Gans(int x, int n, int *a) {     if (n < x) return 0;     return a[n - x + 1] * 1ll * powmod(26, n) % mod;   }   inline void calc(int x, int *&a) {     a = (int *)malloc(140005 * sizeof(int));     int inv = powmod(26, mod - 2);     int v1 = powmod(inv, x), v2 = 1;     for (int i = (x); i <= (100000); i++) {       a[i - x + 1] = 1ll * C(i - 1, x - 1) * v2 % mod * v1 % mod;       v1 = 1ll * v1 * inv % mod;       v2 = 1ll * v2 * (26 - 1) % mod;       a[i - x + 1] = (a[i - x + 1] + a[i - x]) % mod;     }   }   char s[maxn];   int nowlen;   map<int, int *> zball;   int main() {     prprpr();     int m;     read(m);     scanf( %s , s + 1);     nowlen = strlen(s + 1);     calc(nowlen, zball[nowlen]);     for (int i = (1); i <= (m); i++) {       int x;       read(x);       if (x == 2) {         int v;         read(v);         printf( %d n , Gans(nowlen, v, zball[nowlen]));       } else {         scanf( %s , s + 1);         nowlen = strlen(s + 1);         if (!zball.count(nowlen)) calc(nowlen, zball[nowlen]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string arr[11] = { ABSINTH ,  BEER ,     BRANDY ,  CHAMPAGNE ,  GIN ,  RUM ,                        SAKE ,     TEQUILA ,  VODKA ,   WHISKEY ,    WINE };     int n;     cin >> n;     int counter = 0;     string str;     int num_convert;     for (int i = 0; i < n; i++) {       str =   ;       cin >> str;       if (isdigit(str.at(0))) {         num_convert = stoi(str, nullptr, 10);         if (num_convert < 18) {           counter++;         }       } else {         for (int i = 0; i < 11; i++) {           if (str == arr[i]) {             counter++;           }         }       }     }     cout << counter;   }