malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long dx[] = {-1, 0, 1, 0};   long long dy[] = {0, -1, 0, 1};   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long b, q, l, m;     cin >> b >> q >> l >> m;     if (abs(b) > l) {       cout << 0 <<   n ;       return 0;     }     set<long long> st;     for (long long i = 0; i < m; i++) {       long long x;       cin >> x;       st.insert(x);     }     if (b == 0 || q == 0) {       if (0 <= l && st.find(0) == st.end()) {         cout <<  inf n ;         return 0;       } else if (abs(b) <= l && st.find(b) == st.end()) {         cout << 1 <<   n ;         return 0;       } else         cout << 0;       return 0;     }     if (q == 1) {       if (abs(b) <= l && st.find(b) == st.end()) {         cout <<  inf n ;       } else         cout << 0 <<   n ;       return 0;     } else if (q == -1) {       if (abs(b) <= l && (st.find(b) == st.end() || st.find(-b) == st.end())) {         cout <<  inf n ;       } else         cout << 0 <<   n ;       return 0;     }     vector<long long> v;     while (abs(b) <= l) {       if (st.find(b) == st.end()) v.push_back(b);       b = b * q;     }     cout << v.size() <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, i;     cin >> k;     int a[12];     for (i = 0; i < 12; i++) cin >> a[i];     sort(a, a + 12);     int sum = 0, c = 0;     while (sum < k && i > 0) {       i--;       sum = sum + a[i];       c++;     }     if (sum >= k)       cout << c;     else       cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int to, nxt, v;   } e[1000005];   queue<int> que;   int n, m, head[1000005], cnt, l, r, vis[1000005], pre[1000005], tot;   int sum, ans[1000005], ppp, minn = 1023456789, dfn[1000005], id[1000005];   inline void add(int from, int to, int v) {     e[++cnt].nxt = head[from];     head[from] = cnt;     e[cnt].to = to;     e[cnt].v = v;   }   inline int dfs(int p, int val, int fa) {     pre[p] = tot;     vis[p] = 1;     for (int i = head[p]; i; i = e[i].nxt) {       if (e[i].v > val) {         if (pre[e[i].to] == tot && !vis[e[i].to]) {           continue;         }         if ((pre[e[i].to] == tot && vis[e[i].to]) || dfs(e[i].to, val, fa))           return 1;       }     }     vis[p] = 0;     return 0;   }   inline void work(int val) {     for (int i = 1; i <= m; i++)       if (e[i].v > val) dfn[e[i].to]++;     for (int i = 1; i <= n; i++)       if (!dfn[i]) que.push(i);     while (!que.empty()) {       int u = que.front();       que.pop();       id[u] = ++sum;       for (int i = head[u]; i; i = e[i].nxt) {         if (e[i].v > val) {           dfn[e[i].to]--;           if (!dfn[e[i].to]) que.push(e[i].to);         }       }     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       add(x, y, z);       r = max(r, z);     }     l = 0;     int fl;     while (l < r) {       fl = 0;       tot++;       sum = 0;       int mid = (l + r) >> 1;       for (int i = 1; i <= n; i++) {         if (pre[i] != tot && dfs(i, mid, i)) {           fl = 1;           break;         }       }       if (!fl) {         r = mid;       } else {         l = mid + 1;       }     }     printf( %d  , r);     sum = 0;     work(r);     for (int i = 1; i <= n; i++) {       for (int j = head[i]; j; j = e[j].nxt) {         if (e[j].v <= r) {           if (id[e[j].to] < id[i]) {             ans[++ppp] = j;           }         }       }     }     printf( %d n , ppp);     sort(ans + 1, ans + ppp + 1);     for (int i = 1; i <= ppp; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void exec() {     int n, k;     cin >> n >> k;     map<int, int> es;     for (int i = 1; i <= k + 1; i++) {       string query =  ? ;       for (int j = 1; j <= k + 1; j++) {         if (j == i) {           continue;         }         query +=     + to_string(j);       }       cout << query << endl;       int pos, a;       cin >> pos >> a;       es[a] += 1;     }     int mmax = -1;     int m = 0;     for (auto i = es.begin(); i != es.end(); ++i) {       if (mmax < i->first) {         mmax = i->first;         m = i->second;       }     }     cout.flush();     cout << ( !   + to_string(m)) << endl;   }   void solve() {     int t = 1;     for (int i = 0; i < t; i++) {       exec();     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 105000;   int a[maxn], ans[maxn];   int n, p, res1, res2;   bool judge1(int k) {     int sum = 0;     for (int i = 1; i <= n; i++) {       if (a[i] <= k)         sum++;       else {         int tmp = a[i] - k;         sum -= tmp;         if (sum < 0) return 0;         k += tmp;         sum++;       }     }     return 1;   }   bool judge2(int k) {     int sum = 0;     for (int i = 1; i <= n; i++) {       if (a[i] <= k) {         sum++;         if (sum >= p) return 0;       } else {         int tmp = a[i] - k;         sum -= tmp;         k += tmp;         sum++;       }     }     return 1;   }   void solve() {     scanf( %d %d , &n, &p);     int max_v = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       max_v = max(max_v, a[i]);     }     sort(a + 1, a + n + 1);     int l = 1, r = max_v;     while (l <= r) {       int mid = l + r >> 1;       if (judge1(mid))         r = mid - 1;       else         l = mid + 1;     }     res1 = l;     r = max_v;     while (l <= r) {       int mid = l + r >> 1;       if (judge2(mid))         l = mid + 1;       else         r = mid - 1;     }     res2 = r;     printf( %d n , res2 - res1 + 1);     for (int i = res1; i <= res2; i++) printf( %d  , i);     printf(  n );   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int b[1100000], a[1100000], pre[1100000];   int main() {     int n, m, k, i, j, s, cnt, len = 0, max = 0;     long long ans = 0;     scanf( %d%d%d , &n, &m, &k);     for (i = 1; i <= m; ++i) {       scanf( %d , &s);       b[s] = 1;     }     b[n] = 1;     for (i = 1; i < n; ++i)       if (b[i])         pre[i] = pre[i - 1];       else         pre[i] = i;     for (i = 1; i < n; ++i) {       if (b[i])         ++len;       else         len = 0;       if (len > max) max = len;     }     for (i = 1; i <= k; ++i) scanf( %d , &a[i]);     if (max == 0)       max = 1;     else       ++max;     for (i = max; i <= k; ++i) {       cnt = 0;       j = 0;       if (b[j]) continue;       while (j < n) {         ++cnt;         if (!b[j])           j = j + i;         else           j = pre[j] + i;       }       if (ans == 0)         ans = (long long)cnt * a[i];       else if ((long long)cnt * a[i] < ans)         ans = (long long)cnt * a[i];     }     if (ans > 0)       printf( %I64d , ans);     else       printf( -1 );     return 0;   }
#include <bits/stdc++.h>   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(nullptr);     int32_t n, m, k;     std::cin >> n >> m >> k;     if (n % 2 == 0) {       std::cout <<  Marsel n ;     } else {       bool avail = k == 1;       for (int32_t i = 2; i * i <= m; ++i) {         if (m % i == 0) {           avail |= m / i >= k;           break;         }       }       if (m >= k * 2 && avail) {         std::cout <<  Timur n ;       } else {         std::cout <<  Marsel n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1 << 19;   const double PI = acos(-1);   int n, x;   int a[N];   vector<long long> f, g, h;   long long res[N];   int rev[N];   void calc_rev(int n, int logn) {     for (int i = 0; i < n; ++i) {       rev[i] = 0;       for (int j = 0; j < logn; ++j)         if (i >> j & 1) {           rev[i] |= 1 << logn - j - 1;         }     }   }   void fft(complex<double> a[], int n, bool invert) {     for (int i = 0; i < n; ++i)       if (i < rev[i]) {         swap(a[i], a[rev[i]]);       }     for (int len = 2; len <= n; len <<= 1) {       double alpha = 2 * PI / len * (invert ? -1 : 1);       complex<double> wl = complex<double>(cos(alpha), sin(alpha));       for (int i = 0; i < n; i += len) {         complex<double> w = complex<double>(1);         for (int j = 0; j < (len >> 1); ++j) {           complex<double> u = a[i + j], v = a[i + j + (len >> 1)] * w;           a[i + j] = u + v;           a[i + j + (len >> 1)] = u - v;           w *= wl;         }       }     }     if (invert)       for (int i = 0; i < n; ++i) a[i] /= n;   }   vector<long long> mult(vector<long long> a, vector<long long> b) {     static complex<double> fa[N], fb[N], fc[N];     int na = a.size(), nb = b.size();     int n = 1, logn = 0;     while (n < max(na, nb)) n <<= 1, logn++;     n <<= 1, logn++;     calc_rev(n, logn);     for (int i = 0; i < n; ++i) fa[i] = fb[i] = complex<double>(0);     for (int i = 0; i < na; ++i) fa[i] = complex<double>(a[i]);     for (int i = 0; i < nb; ++i) fb[i] = complex<double>(b[i]);     fft(fa, n, false);     fft(fb, n, false);     for (int i = 0; i < n; ++i) fc[i] = fa[i] * fb[i];     fft(fc, n, true);     vector<long long> res;     for (int i = 0; i < na + nb - 1; ++i)       res.push_back((long long)(fc[i].real() + 0.5));     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> x;     f.assign(n + 1, 0), g.assign(n + 1, 0);     f[0] = g[n] = 1;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       a[i] = a[i - 1] + (a[i] < x);       f[a[i]]++, g[n - a[i]]++;     }     h = mult(f, g);     for (int i = 0; i <= n; ++i) res[0] += f[i] * (f[i] - 1) / 2;     for (int i = 1; i <= n; ++i) res[i] = h[i + n];     for (int i = 0; i <= n; ++i) cout << res[i] <<    ;     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, cla[30], a[200 + 5], hd[2 * 200 + 5], len = 0;   char s[30];   struct Edge {     int v, net;   } e[2 * 160000 + 5];   void addi(int u, int v) {     e[len] = (Edge){v, hd[u]};     hd[u] = len++;   }   void add(int u, int v) {     addi(u, v);     addi(v <= n ? n + v : v - n, u <= n ? n + u : u - n);   }   template <class T>   void read(T &x) {     char ch;     bool ok;     for (ok = 0, ch = getchar(); !isdigit(ch); ch = getchar())       if (ch ==  - ) ok = 1;     for (x = 0; isdigit(ch); x = x * 10 + ch -  0 , ch = getchar())       ;     if (ok) x = -x;   }   int col[200 + 5], col_cpy[200 + 5];   bool dfs(int u, int ty) {     if (col_cpy[u] != -1) return col_cpy[u] == ty;     col_cpy[u] = ty;     for (int i = hd[ty * n + u]; ~i; i = e[i].net) {       int v = e[i].v;       if (!(v > n ? dfs(v - n, 1) : dfs(v, 0))) return 0;     }     return 1;   }   int fl = 0, mx[2];   bool chk(int x, int ty) {     if (fl || ty) return 1;     for (int i = (x), en = (n); i <= en; ++i) {       if (col_cpy[i] == -1) {         if (mx[!cla[a[i]]] > a[i]) return 1;         continue;       }       if (mx[col_cpy[i]] > a[i]) return 1;       if (mx[col_cpy[i]] < a[i]) return 0;     }     return 1;   }   bool chk(int x, int ty, int tty) {     memcpy(col_cpy, col, sizeof col);     if (dfs(x, ty) && chk(x + 1, tty)) {       memcpy(col, col_cpy, sizeof col_cpy);       return 1;     }     return 0;   }   int as[200 + 5];   int main() {     memset(hd, -1, sizeof hd);     scanf( %s , s + 1);     k = strlen(s + 1);     int mn = 0;     for (int i = (1), en = (k); i <= en; ++i) {       cla[i] = s[i] ==  C ;       if (cla[i] != cla[1] && !mn) mn = i;       mx[cla[i]] = max(mx[cla[i]], i);     }     read(n);     read(m);     for (int i = (1), en = (m); i <= en; ++i) {       int x, y, xx, yy;       char c;       read(x);       cin >> c;       y = c ==  C ;       read(xx);       cin >> c;       yy = c ==  C ;       add(x + n * y, xx + n * yy);       if (y != yy && !mx[yy]) {         puts( -1 );         return 0;       }     }     memset(col, -1, sizeof col);     for (int i = (1), en = (n); i <= en; ++i) {       char c;       cin >> c;       a[i] = c -  a  + 1;     }     for (int i = (1), en = (n); i <= en; ++i) {       if (fl) {         if (chk(i, cla[1], 1))           as[i] = 1;         else if (chk(i, !cla[1], 1))           as[i] = mn;         else {           puts( -1 );           return 0;         }       } else {         int tem = 0, tem1 = 0;         for (int j = (a[i] + 1), en = (k); j <= en; ++j) {           if (cla[j] != cla[a[i]]) {             if (!tem) tem = j;           } else {             if (!tem1) tem1 = j;           }         }         if (chk(i, cla[a[i]], 0))           as[i] = a[i];         else {           if (tem > tem1) swap(tem, tem1);           if (tem && chk(i, cla[tem], 1))             as[i] = tem;           else if (tem1 && chk(i, cla[tem1], 1))             as[i] = tem1;           else {             puts( -1 );             return 0;           }         }       }       fl |= as[i] > a[i];     }     for (int i = (1), en = (n); i <= en; ++i) putchar( a  + as[i] - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Exam {     int s, d, c, id;     bool operator<(const Exam &e1) const { return d < e1.d; }   };   const int N = 105;   int n, m, to[N];   Exam e[N];   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) {       cin >> e[i].s >> e[i].d >> e[i].c;       e[i].id = i;       to[e[i].d] = m + 1;     }     sort(e + 1, e + m + 1);     for (int i = 1; i <= m; i++) {       int cnt = 0;       for (int j = e[i].s; j < e[i].d; j++) {         if (to[j] == 0) {           to[j] = e[i].id;           if (++cnt == e[i].c) break;         }       }       if (cnt < e[i].c) {         cout << -1 << endl;         return 0;       }     }     for (int i = 1; i <= n; i++) cout << to[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long INFF = 0x3f3f3f3f3f3f3f3fll;   const long long M = 1e9 + 7;   const long long maxn = 5007;   const double eps = 0.00000001;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   template <typename T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   template <typename T>   inline T powMM(T a, T b) {     T ret = 1;     for (; b; b >>= 1ll, a = a * a % M) ret = 1ll * ret * a % M;     return ret;   }   vector<int> edge[maxn];   vector<long long> dp1[maxn], dp2[maxn];   long long now1[maxn], now2[maxn];   long long a[maxn], b[maxn], m;   int num[maxn], ans;   void dfs(int x) {     num[x] = 1;     dp1[x].resize(maxn, INFF);     dp2[x].resize(maxn, INFF);     dp1[x][1] = a[x];     dp1[x][0] = 0;     dp2[x][1] = a[x] - b[x];     dp2[x][0] = INFF;     int i, j;     for (int v : edge[x]) {       dfs(v);       for (i = 0; i <= num[x]; i++) now1[i] = dp1[x][i], now2[i] = dp2[x][i];       for (i = 0; i <= num[x]; i++)         for (j = 1; j <= num[v]; j++) {           dp1[x][i + j] = min(dp1[x][i + j], now1[i] + dp1[v][j]);           dp2[x][i + j] = min(dp2[x][i + j], now2[i] + min(dp1[v][j], dp2[v][j]));         }       vector<long long>().swap(dp1[v]);       vector<long long>().swap(dp2[v]);       num[x] += num[v];     }   }   int n;   int i, j, k;   int main() {     scanf( %d%I64d , &n, &m);     for (i = 1; i <= n; i++) {       scanf( %I64d%I64d , &a[i], &b[i]);       if (i != 1) {         int v;         scanf( %d , &v);         edge[v].push_back(i);       };     }     dfs(1);     ans = 0;     for (i = 1; i <= n; i++)       if (dp1[1][i] <= m || dp2[1][i] <= m) ans = max(ans, i);     printf( %d , ans);   }
#include <bits/stdc++.h>   const double PI = acos(-1);   using namespace std;   template <class T>   ostream& operator<<(ostream& out, vector<T> v) {     out << v.size() <<   n ;     for (auto e : v) out << e <<   n ;     return out;   }   struct point {     long long x, y;     point() {}     point(const point& a) { x = a.x, y = a.y; }     point(long long _x, long long _y) {       x = _x;       y = _y;     }     point operator-(point a) { return point(x - a.x, y - a.y); }     point operator+(point a) { return point(x + a.x, y + a.y); }   };   ostream& operator<<(ostream& out, point p) {     return out <<  (  << p.x <<     << p.y <<  ) ;   }   long double dist(point a, point b) {     long double X = a.x - b.x;     long double Y = a.y - b.y;     return sqrt(X * X + Y * Y);   }   istream& operator>>(istream& in, point& p) { return in >> p.x >> p.y; }   long double area(point a, point b, point c) {     return a.x * b.y + b.x * c.y + c.x * a.y - a.y * b.x - b.y * c.x - c.y * a.x;   }   const long long N = 100100;   point p1, p2, p[N];   long long n, k, use[N];   vector<pair<long long, long long> > v[5];   long long lg(long long a) {     if (a % 2 == 1) a++;     a /= 2;     return max(1LL, a);   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> k;     for (long long i = 1; i <= n; i++) {       cin >> p1 >> p2;       p[i] = p1 + p2;     }     for (long long i = 1; i <= n; i++) {       v[0].push_back({p[i].x, i});       v[1].push_back({p[i].x, i});     }     for (long long i = 1; i <= n; i++) {       v[2].push_back({p[i].y, i});       v[3].push_back({p[i].y, i});     }     sort(v[0].begin(), v[0].end());     sort(v[1].begin(), v[1].end(), greater<pair<long long, long long> >());     sort(v[2].begin(), v[2].end());     sort(v[3].begin(), v[3].end(), greater<pair<long long, long long> >());     long long ans = 1e18 + 100;     for (long long i = 0; i < (1 << (2 * k)); i++) {       long long order[12], msk = i, used[12];       for (long long j = 1; j <= k; j++) {         order[j] = msk % 4;         msk /= 4;       }       long long d[] = {v[0][0].first, v[1][0].first, v[2][0].first,                        v[3][0].first};       for (long long j = 1; j <= k; j++) {         long long p = order[j], ind = 0;         while (use[v[order[j]][ind].second]) ind++;         use[v[p][ind].second] = 1;         used[j] = v[p][ind].second;       }       for (int j = 0; j < 4; j++) {         int ind = 0;         while (use[v[j][ind].second]) ind++;         d[j] = v[j][ind].first;       }       ans = min(ans, lg(d[1] - d[0]) * lg(d[3] - d[2]));       for (long long j = 1; j <= k; j++) use[used[j]] = 0;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   string s[51];   int n, m;   bool check(int i, int j) {     for (int k = 1; k <= n; ++k)       if (s[k][j] ==  #  && s[k] != s[i]) return false;     return true;   }   signed main() {     ios::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= n; ++i) cin >> s[i];     for (int i = 1; i <= n; ++i)       for (int j = 0; j <= m - 1; ++j)         if (s[i][j] ==  # )           if (!check(i, j)) {             cout <<  No ;             return 0;           }     cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T a, T b) {     while (a > 0 && b > 0) {       if (a > b)         a %= b;       else         b %= a;     }     return a + b;   }   void YES_NO(bool YES_NO, bool isExit = true) {     if (YES_NO)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     if (isExit) {       exit(0);     }   }   void Yes_No(bool Yes_No, bool isExit = true) {     if (Yes_No)       cout <<  Yes  << endl;     else       cout <<  No  << endl;     if (isExit) {       exit(0);     }   }   void yes_no(bool yes_no, bool isExit = true) {     if (yes_no)       cout <<  yes  << endl;     else       cout <<  no  << endl;     if (isExit) {       exit(0);     }   }   int main() {     string s, t;     cin >> s;     cin >> t;     int cnt = 0;     for (int i = 0; i < s.size(); ++i) {       if (s[i] != t[i]) {         ++cnt;       }     }     if (cnt % 2 == 1) {       cout <<  impossible  << endl;       return 0;     }     cnt /= 2;     string ans = s;     for (int i = 0; i < s.size(); ++i) {       if (s[i] != t[i] && cnt) {         ans[i] = t[i];         --cnt;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int r, g, b;   int mins;   int total;   int tour;   int cycles;   int main() {     scanf( %d %d %d , &r, &g, &b);     if (r >= 2) {       r -= 2;     } else if (r == 1) {       r -= 1;     }     mins = 30;     tour = 1;     total = r + g + b;     while (total > 0) {       if (tour == 1) {         if (g >= 2) {           g -= 2;         } else if (g == 1) {           g -= 1;         }         tour = 2;       } else if (tour == 2) {         if (b >= 2) {           b -= 2;         } else if (b == 1) {           b -= 1;         }         tour = 0;       } else if (tour == 0) {         if (r >= 2) {           r -= 2;         } else if (r == 1) {           r -= 1;         }         tour = 1;       }       total = r + g + b;       cycles++;     }     mins += cycles;     printf( %d , mins);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   const long long LINF = 1e18;   int n, m, k;   bool noted[13];   bool connected[13][13];   int cnt = 0;   set<long long> st;   set<set<int>> sets;   vector<int> vec[13];   long long pw[13];   bool visitedd[13];   map<long long, bool> visiteddd[13][13];   void bruteforce_string(int u, int v, int d, long long code) {     if (d == n / 2) {       if (!connected[u][v]) return;       cnt++;       st.insert(code);       return;     }     for (int x : vec[u])       for (int y : vec[v]) {         if (x == y) continue;         if (visitedd[x] || visitedd[y]) continue;         long long nx = min(x, y);         long long ny = max(x, y);         long long ncode = code + (ny << (4LL * nx));         if (!visiteddd[nx][ny][ncode]) {           visiteddd[nx][ny][ncode] = 1;           visitedd[x] = 1;           visitedd[y] = 1;           bruteforce_string(nx, ny, d + 1, ncode);           visitedd[x] = 0;           visitedd[y] = 0;         }       }   }   int cnt2 = 0;   map<set<int>, bool> visited;   void bruteforce_striling(set<int> st) {     visited[st] = 1;     if (st.size() == 1) return;     for (auto it = st.begin(); it != st.end(); it++) {       auto jt = it;       ++jt;       for (; jt != st.end(); jt++) {         set<int> nt = st;         nt.erase(*it);         nt.erase(*jt);         nt.insert(*it + *jt);         if (!visited[nt]) bruteforce_striling(nt);       }     }   }   long long P(int n, int k) {     long long res = 1;     for (int i = 0; i < k; i++) res = (res * (n - i));     return res;   }   int main() {     pw[0] = 1;     for (int i = 1; i <= 12; i++) pw[i] = pw[i - 1] * 13;     scanf( %d %d %d n , &n, &m, &k);     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d %d , &u, &v);       vec[u].push_back(v);       vec[v].push_back(u);       connected[u][v] = connected[v][u] = 1;     }     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         visitedd[i] = 1;         visitedd[j] = 1;         bruteforce_string(i, j, 1, ((1LL * j) << (4 * i)));         visitedd[i] = 0;         visitedd[j] = 0;       }     }     for (auto it : st) {       set<int> temp;       for (int i = 1; i <= 12; i++) {         int u = i;         int v = ((it >> (4LL * i)) & 15);         if (v) temp.insert((1 << u) + (1 << v));       }       sets.insert(temp);     }     for (auto it : sets) {       if (!visited[it]) bruteforce_striling(it);     }     long long res = 0;     for (auto it : visited) {       res += P(k, it.first.size());     }     printf( %lld n , res);   }
#include <bits/stdc++.h>   using namespace std;   char s[2000005], str[2000005];   int pre[2000005];   int find(int x) { return x == pre[x] ? x : pre[x] = find(pre[x]); }   int main() {     int n, q, x;     while (scanf( %d , &n) != EOF) {       for (int i = 1; i < 2000005; i++) pre[i] = i;       int maxx = 0;       while (n--) {         scanf( %s%d , str, &q);         int len = strlen(str);         while (q--) {           scanf( %d , &x);           maxx = max(maxx, x + len);           for (int i = find(x); i < x + len; i = pre[i] = find(i + 1))             s[i] = str[i - x];         }       }       for (int i = 1; i < maxx; i++) {         if (s[i] ==   0 ) s[i] =  a ;       }       printf( %s , s + 1);     }     return 0;   }