malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long a[100005];   long long req = 1e18;   long long steps(long long n) {     long long c = 1;     if (n == 1) return 1e6;     while (req > 1) {       req /= n;       c++;     }     req = 1e18;     return c;   }   long long pow_exp(long long a, long long n) {     long long res = 1;     while (n) {       if (n % 2) res = (res * a);       a = (a * a);       n /= 2ll;     }     return res;   }   int main() {     long long t = 1;     while (t--) {       long long n;       cin >> n;       long long ans = 0;       for (long long i = 0; i < n; i++) cin >> a[i], ans += (a[i] - 1ll);       sort(a, a + n);       if (n == 1) {         cout << a[0] - 1ll << endl;         continue;       }       long long st = 2;       while (steps(st) >= n - 1) {         long long sol = 0;         for (long long i = 0; i < n; i++) {           long long u = pow_exp(st, i);           sol += abs(u - a[i]);         }         ans = min(ans, sol);         if (pow_exp(st, n - 1) > a[n - 1]) break;         st++;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   struct matrix {     long long a[100][100];     void init() { memset(a, 0, sizeof(a)); }     friend matrix operator*(matrix x, matrix y) {       matrix ans;       ans.init();       for (int i = 0; i < 100; i++)         for (int j = 0; j < 100; j++) {           for (int k = 0; k < 100; k++)             ans.a[i][j] += (x.a[i][k] * y.a[k][j]) % 1000000007;           ans.a[i][j] %= 1000000007;         }       return ans;     }     friend matrix operator^(matrix x, long long y) {       matrix ans;       if (y == 0) {         memset(ans.a, 0, sizeof(ans.a));         for (int i = 0; i < 100; i++) ans.a[i][i] = 1;         return ans;       } else         while ((y & 1) == 0) y >>= 1, x = x * x;       ans = x;       y >>= 1;       for (; y != 0; y >>= 1) {         x = x * x;         if ((y & 1) != 0) ans = ans * x;       }       return ans;     }   } x;   int n, m, Mod, a[1000010];   int main() {     x.init();     matrix h, t;     h.init();     t.init();     scanf( %d%d%d , &n, &m, &Mod);     for (int i = 1; i <= n; i++) {       int v;       scanf( %d , &v);       h.a[0][v % Mod]++;     }     for (int i = 1; i <= n; i++) {       int v;       scanf( %d , &v);       a[i] = v;       for (int j = 0; j < Mod; j++) x.a[j][(j + v) % Mod]++;     }     matrix ans = h * (x ^ (m - 2));     for (int i = 1; i <= n; i++) {       int v;       scanf( %d , &v);       int d = (Mod - (v + a[i]) % Mod) % Mod;       t.a[d][0]++;     }     ans = ans * t;     printf( %I64d n , ans.a[0][0]);   }
#include <bits/stdc++.h>   using namespace std;   int N;   bool indegree[200010];   int a[200010];   bool visited[200010];   vector<pair<int, int> > ans;   int main() {     int i, j, k;     scanf( %d , &N);     for (i = (0); i < (N); i++) scanf( %d , a + i);     for (i = (0); i < (N); i++) a[i]--;     memset((visited), 0, sizeof(visited));     ;     memset((indegree), 0, sizeof(indegree));     ;     for (i = (0); i < (N); i++) indegree[a[i]] = true;     bool f = false;     for (i = (0); i < (N); i++) {       if (indegree[i]) continue;       f = true;       int x = i;       while (!visited[x]) {         visited[x] = true;         indegree[x] = true;         x = a[x];       }       ans.push_back(make_pair(i, x));     }     for (i = (0); i < (N); i++) {       if (visited[i]) continue;       int x = i;       while (!visited[x]) {         visited[x] = true;         x = a[x];       }       ans.push_back(make_pair(i, i));     }     if (!f && ans.size() < 2) {       printf( 0 n );       return 0;     }     ans.push_back(ans[0]);     printf( %d n , ans.size() - 1);     for (i = (0); i < (ans.size() - 1); i++)       printf( %d %d n , ans[i].second + 1, ans[i + 1].first + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string base, s;     cin >> base >> s;     int n = base.size(), m = s.size();     base =  *  + base;     s =  *  + s;     int f[m + 2][n + 2];     memset(f, 0, sizeof(f));     for (int i = m; i >= 1; i--)       for (int j = n; j >= 1; j--)         if (s[i] == base[j]) f[i][j] = f[i + 1][j + 1] + 1;     int g[m + 2][n + 2];     memset(g, 0, sizeof(g));     for (int i = m; i >= 1; i--)       for (int j = 1; j <= n; j++)         if (s[i] == base[j]) g[i][j] = g[i + 1][j - 1] + 1;     vector<pair<int, int>> ans;     for (int i = 1; i <= m;) {       int l1 = max_element(f[i] + 1, f[i] + n + 1) - f[i];       int l2 = max_element(g[i] + 1, g[i] + n + 1) - g[i];       if (!f[i][l1] && !g[i][l2]) {         cout << -1;         return 0;       }       if (f[i][l1] >= g[i][l2])         ans.push_back({l1, l1 + f[i][l1] - 1});       else         ans.push_back({l2, l2 - g[i][l2] + 1});       i += max(f[i][l1], g[i][l2]);     }     cout << ans.size() <<   n ;     for (auto p : ans) cout << p.first <<     << p.second <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int color[30];   int colornow[30];   int op0[10][10] = {{2, 4, 6, 8, 10, 12, 23, 21},                      {3, 4, 17, 19, 10, 9, 16, 14},                      {13, 14, 5, 6, 17, 18, 21, 22}};   int op1[10][10] = {{6, 8, 10, 12, 23, 21, 2, 4},                      {17, 19, 10, 9, 16, 14, 3, 4},                      {5, 6, 17, 18, 21, 22, 13, 14}};   int op2[10][10] = {{23, 21, 2, 4, 6, 8, 10, 12},                      {16, 14, 3, 4, 17, 19, 10, 9},                      {21, 22, 13, 14, 5, 6, 17, 18}};   int vis[30];   int isok() {     int ret = 0;     for (int i = 1; i <= 24; i += 4) {       if (colornow[i] == colornow[i + 1] && colornow[i + 1] == colornow[i + 2] &&           colornow[i + 2] == colornow[i + 3]) {         ret++;       }     }     if (ret == 6) return 1;     return 0;   }   int main() {     for (int i = 1; i <= 24; i++) scanf( %d , &color[i]);     int flag = 0;     for (int i = 0; i < 3; i++) {       memset(vis, 0, sizeof(vis));       for (int j = 0; j < 8; j++) {         colornow[op0[i][j]] = color[op1[i][j]];         vis[op0[i][j]] = 1;       }       for (int j = 1; j <= 24; j++) {         if (!vis[j]) colornow[j] = color[j];       }       if (isok()) flag = 1;       memset(vis, 0, sizeof(vis));       for (int j = 0; j < 8; j++) {         colornow[op0[i][j]] = color[op2[i][j]];         vis[op0[i][j]] = 1;       }       for (int j = 1; j <= 24; j++) {         if (!vis[j]) colornow[j] = color[j];       }       if (isok()) flag = 1;     }     if (flag)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, q;     scanf( %lld %lld , &n, &q);     while (q--) {       long long x;       scanf( %lld , &x);       while (x % 2 == 0) {         x += (n - x / 2);       }       printf( %lld n , x / 2 + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, x;     while (cin >> n >> k) {       long long sum = 0;       x = n * (k - 1) / k - 10;       if (x <= 0) {         x = 1;       }       long long c = x;       sum = x;       while (sum < n) {         c /= k;         sum += c;         if (sum >= n) {           break;         }         if (c / k == 0 && sum < n) {           x++;           c = x;           sum = c;         }       }       cout << x << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005, inf = 1e9 + 7;   int fa[maxn];   long long n, m, dp[maxn];   int sz[maxn], costs[maxn];   vector<int> fas;   bool vis[maxn];   int findfa(int x) {     if (fa[x] == x)       return x;     else       return fa[x] = findfa(fa[x]);   }   void bag(int wei, int val) {     for (int i = n; i >= wei; i--) {       dp[i] = min(dp[i], dp[i - wei] + val);     }   }   bool check(int xx) {     while (xx) {       if ((xx % 10) != 4 && (xx % 10) != 7) {         return 0;       }       if (xx < 10) break;       xx /= 10;     }     return 1;   }   int main() {     memset(dp, 1e9 + 7, sizeof(dp));     cin >> n >> m;     for (int i = 1; i <= n; i++) fa[i] = i;     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       fa[findfa(x)] = findfa(y);     }     for (int i = 1; i <= n; i++) {       sz[findfa(i)]++;     }     for (int i = 1; i <= n; i++) {       costs[sz[i]]++;     }     dp[0] = 0;     for (int i = 1; i <= n; i++) {       if (costs[i]) {         for (int j = 1; j <= costs[i]; j <<= 1) {           bag(j * i, j);           costs[i] -= j;         }         bag(costs[i] * i, costs[i]);       }     }     long long ans = 1e9 + 7;     for (int i = 1; i <= n; i++) {       if (check(i)) ans = min(ans, dp[i]);     }     if (ans == 1e9 + 7)       cout <<  -1  << endl;     else       cout << ans - 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e6 + 10;   const int INF = 1e9 + 7;   int prime[MAX];   int main() {     int x2;     scanf( %d , &x2);     for (int i = 2; i <= x2; i++) {       if (!prime[i]) {         for (int j = i * 2; j <= x2; j += i) prime[j] = i;       }     }     int ans = INF;     for (int i = x2 - prime[x2] + 1; i <= x2; i++) {       if (prime[i] == 0) continue;       ans = min(ans, i - prime[i] + 1);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x;   long long n, f = 1;   int main() {     cin >> n;     if (n < 0) {       f = -1;       n = -n;     }     x = (n % 360) * f * (-1);     long long a0 = x, a1 = x + 90, a2 = x + 180, a3 = x + 270;     a0 = min(abs(a0), (360 + a0) % 360);     if (a0 > 180) a0 = 360 - a0;     a1 = min(abs(a1), (360 + a1) % 360);     if (a1 > 180) a1 = 360 - a1;     a2 = min(abs(a2), (360 + a2) % 360);     if (a2 > 180) a2 = 360 - a2;     a3 = min(abs(a3), (360 + a3) % 360);     if (a3 > 180) a3 = 360 - a3;     if (a0 <= a1 && a0 <= a2 && a0 <= a3) {       cout << 0 << endl;       return 0;     }     if (a1 <= a0 && a1 <= a2 && a1 <= a3) {       cout << 1 << endl;       return 0;     }     if (a2 <= a1 && a2 <= a0 && a2 <= a3) {       cout << 2 << endl;       return 0;     }     cout << 3 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> A(n);     vector<int> B(n, 1);     for (int i = 0; i < n; i++) {       cin >> A[i];     }     int max1 = B[0];     for (int i = 1; i < n; i++) {       if (A[i] >= A[i - 1]) {         B[i] = B[i - 1] + 1;       }       max1 = max(max1, B[i]);     }     cout << max1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000100], b[5010];   string second[10];   int main() {     int n, sm = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a + 1, a + n);     for (;;) {       if (a[0] <= a[n - 1]) {         a[n - 1]--;         a[0]++;         sm++;       }       sort(a + 1, a + n);       if (a[0] > a[n - 1]) {         cout << sm;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename tp>   inline void read(tp &x) {     x = 0;     char c = getchar();     int f = 0;     for (; c <  0  || c >  9 ; f |= c ==  - , c = getchar())       ;     for (; c >=  0  && c <=  9 ; x = (x << 3) + (x << 1) + c -  0 , c = getchar())       ;     if (f) x = -x;   }   namespace {   const int mo = 1e9 + 7;   inline int add(int x, int y) {     x += y;     return x >= mo ? x - mo : x;   }   inline int sub(int x, int y) {     x -= y;     return x < 0 ? x + mo : x;   }   inline int mul(int x, int y) { return (long long)x * y % mo; }   inline int power(int a, int k = mo - 2) {     int ans = 1;     for (; k; k >>= 1, a = mul(a, a))       if (k & 1) ans = mul(ans, a);     return ans;   }   inline void U(int &x, int y) { x = add(x, y); }   }  // namespace   const int N = 1e5 + 233;   int n, m, coefa, coefb, P, T;   int fac[N], ifac[N], p[N], sump[N];   inline int C(int n, int m) {     return n < m ? 0 : mul(fac[n], mul(ifac[m], ifac[n - m]));   }   int main(void) {     read(n);     read(m);     read(coefa);     read(coefb);     P = mul(coefa, power(coefb));     fac[0] = 1;     for (register int i = 1; i <= (N - 1); i++) fac[i] = mul(fac[i - 1], i);     for (register int i = 0; i < (int)N; i++) ifac[i] = power(fac[i]);     read(T);     for (register int i = 0; i < (int)m + 1; i++) {       if (i <= T)         p[i + 1] = mul(C(T, i), mul(power(P, i), power(1 + mo - P, T - i)));     }     for (register int i = 0; i < (int)m + 1; i++)       sump[i] = add(i ? sump[i - 1] : 0, p[i]);     vector<int> h(m + 2, 0);     h[m] = 1;     for (register int i = 1; i <= (n); i++) {       vector<int> new_h(m + 2, 0);       vector<int> f(m + 2, 0), g(m + 2, 0);       for (int r = 1; r <= m; r++) {         f[r] = add(f[r - 1], h[r]);         g[r] = add(g[r - 1], mul(f[r - 1], p[r]));       }       for (int r = 1; r <= m; r++) {         int rr = m - r + 1;         new_h[r] = sub(mul(sump[r], mul(p[rr], f[m])),                        add(mul(p[rr], g[r]), mul(mul(p[rr], f[m - r]), sump[r])));       }       swap(h, new_h);     }     int ans = 0;     for (auto i : h) U(ans, i);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int color[10010], c[10010], d[10010], f[10010], N, t, x;   int main() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) {       scanf( %d , color + i);       if (!f[color[i]]) f[color[i]] = i;     }     int m, col;     for (int i = 1; i <= N; i++) {       m = 1;       col = color[i];       d[col]++;       for (int j = 1; j <= N; j++) {         c[j] = 0;       }       c[color[i]]++;       for (int j = i + 1; j <= N; j++) {         c[color[j]]++;         if ((c[color[j]] > m) || (c[color[j]] == m && color[j] < col)) {           m = c[color[j]];           col = color[j];         }         d[col]++;       }     }     for (int i = 1; i < N; i++) printf( %d  , d[i]);     printf( %d n , d[N]);   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 2e5 + 10, inf = 4e18, mod = 1e9 + 7;   const long double pi = 3.14159265359, eps = 1e-9;   long long n, m;   vector<long long> g[maxn], jj[3];   long long mk[maxn];   bool dfs(long long v, long long p = -1, long long dep = 1) {     mk[v] = dep;     vector<long long> be, sn;     for (auto u : g[v]) {       if (mk[u] != 0 && mk[u] < mk[v]) {         if (u != p) be.push_back(u);         continue;       }       if (mk[u] == 0 && dfs(u, v, dep + 1)) sn.push_back(u);     }     while (be.size() > 1) {       jj[0].push_back(be.back());       be.pop_back();       jj[1].push_back(v);       jj[2].push_back(be.back());       be.pop_back();     }     while (sn.size() > 1) {       jj[0].push_back(sn.back());       sn.pop_back();       jj[1].push_back(v);       jj[2].push_back(sn.back());       sn.pop_back();     }     long long add = 0;     if (be.size()) {       if (sn.size()) {         jj[0].push_back(sn.back());         sn.pop_back();         jj[1].push_back(v);         jj[2].push_back(be.back());         be.pop_back();         return 1;       }       add = be.back();     } else if (sn.size()) {       add = sn.back();     }     if (!add) return 1;     if (p != -1) {       jj[0].push_back(add);       jj[1].push_back(v);       jj[2].push_back(p);     }     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     long long v, u;     while (m--) {       cin >> v >> u;       g[v].push_back(u);       g[u].push_back(v);     }     for (int i = 1; i <= n; i++) {       if (!mk[i]) dfs(i);     }     cout << jj[0].size() << endl;     for (int i = 0; i < jj[0].size(); i++) {       cout << jj[0][i] <<     << jj[1][i] <<     << jj[2][i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> s[222222], ss[222222];   int n, m, cnt, cnt2, h;   int up[222222][22], fa[222222], deep[211111], q[211111], dfn[211111],       low[211111];   void tarjan(int x) {     int c, i, y;     dfn[x] = low[x] = ++cnt;     q[h] = x;     h++;     c = s[x].size();     for (i = 0; i < c; i++) {       y = s[x][i];       if (dfn[y] == 0) {         tarjan(y);         low[x] = min(low[x], low[y]);         if (low[y] >= dfn[x]) {           cnt2++;           while (h > 0) {             h--;             ss[cnt2].push_back(q[h]);             ss[q[h]].push_back(cnt2);             if (q[h] == y) break;           }           ss[cnt2].push_back(x);           ss[x].push_back(cnt2);         }       } else         low[x] = min(low[x], dfn[y]);     }   }   void make_yfs() {     int i;     cnt = 0, h = 0, cnt2 = n;     tarjan(1);   }   void dfs(int x) {     int c, i, y;     c = ss[x].size();     for (i = 0; i < c; i++) {       y = ss[x][i];       if (fa[x] == y) continue;       fa[y] = up[y][0] = x;       deep[y] = deep[x] + 1;       dfs(y);     }   }   int lca(int x, int y) {     int tmp = 20;     if (deep[x] < deep[y]) swap(x, y);     while (1) {       if ((1 << tmp) <= deep[x] - deep[y]) x = up[x][tmp];       tmp--;       if (tmp < 0) break;     }     if (x == y) return x;     tmp = 20;     while (1) {       if (up[x][tmp] != up[y][tmp]) x = up[x][tmp], y = up[y][tmp];       tmp--;       if (tmp < 0) break;     }     return fa[x];   }   int getdis(int x, int y) {     int L;     L = lca(x, y);     return deep[x] - deep[L] + deep[y] - deep[L];   }   int main() {     int i, m, x, y, q, ans;     scanf( %d%d%d , &n, &m, &q);     for (i = 1; i <= m; i++) {       scanf( %d%d , &x, &y);       s[x].push_back(y);       s[y].push_back(x);     }     make_yfs();     dfs(1);     for (int j = 1; j <= 20; j++)       for (i = 1; i <= cnt2; i++) up[i][j] = up[up[i][j - 1]][j - 1];     while (q--) {       scanf( %d%d , &x, &y);       ans = getdis(x, y) / 2;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, x;       cin >> n >> x;       int arr[n + 5], brr[n + 5];       for (int i = 0; i < n; i++) {         cin >> arr[i];       }       for (int i = 0; i < n; i++) {         cin >> brr[i];       }       sort(arr, arr + n);       sort(brr, brr + n, greater<int>());       int f = 1;       for (int i = 0; i < n; i++) {         if (arr[i] + brr[i] > x) {           f = 0;           break;         }       }       if (f == 1) {         cout <<  YES  << endl;       } else {         cout <<  NO  << endl;       }       if (t != 0) {         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> st;   long long n, q;   vector<int> swp(20, false);   vector<long long> arr;   void build(long long ind, long long l, long long r) {     if (l == r) {       st[ind] = arr[l];       return;     }     long long mid = (l + r) >> 1;     build(2 * ind, l, mid);     build(2 * ind + 1, mid + 1, r);     st[ind] = st[2 * ind] + st[2 * ind + 1];   }   void update(long long ind, long long l, long long r, long long req,               long long level) {     if (req < l || req > r) return;     if (l == r) {       st[ind] = arr[req];       return;     }     long long mid = (l + r) >> 1;     if (swp[level - 1]) {       update(2 * ind + 1, l, mid, req, level - 1);       update(2 * ind, mid + 1, r, req, level - 1);     } else {       update(2 * ind, l, mid, req, level - 1);       update(2 * ind + 1, mid + 1, r, req, level - 1);     }     st[ind] = st[2 * ind + 1] + st[2 * ind];   }   long long query(long long ind, long long l, long long r, long long ql,                   long long qr, long long level) {     if (l > qr || r < ql) return 0;     if (ql <= l && r <= qr) return st[ind];     long long mid = (l + r) / 2;     if (swp[level - 1])       return query(2 * ind + 1, l, mid, ql, qr, level - 1) +              query(2 * ind, mid + 1, r, ql, qr, level - 1);     else       return query(2 * ind, l, mid, ql, qr, level - 1) +              query(2 * ind + 1, mid + 1, r, ql, qr, level - 1);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> q;     long long len = 1 << n;     arr.resize(len);     st.assign(4 * len, 0);     for (long long i = 0; i < len; i++) cin >> arr[i];     build(1, 0, len - 1);     while (q--) {       long long type;       cin >> type;       if (type == 1) {         long long ind, val;         cin >> ind >> val;         ind--;         arr[ind] = val;         update(1, 0, len - 1, ind, n);       } else if (type == 2) {         long long k;         cin >> k;         for (long long i = 0; i < k; i++) swp[i] ^= true;       } else if (type == 3) {         long long k;         cin >> k;         swp[k] ^= true;       } else {         long long l, r;         cin >> l >> r;         l--;         r--;         cout << query(1, 0, len - 1, l, r, n) <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   inline long long read() {     long long x = 0, f = 1;     char c = getchar();     for (; c >  9  || c <  0 ; c = getchar()) {       if (c ==  - ) f = -1;     }     for (; c >=  0  && c <=  9 ; c = getchar()) {       x = x * 10 + c -  0 ;     }     return x * f;   }   int a[100005];   std::vector<int> vec[200005];   inline long long q_pow(long long x, int t) {     long long s = 1;     for (; t; t >>= 1) {       if (t & 1) s *= x;       x *= x;     }     return s;   }   inline void divide(int x) {     for (int i = 2; i * i <= x; i++) {       if (x % i != 0) {         vec[i].emplace_back(0);         continue;       }       int cnt = 0;       for (; x % i == 0; x /= i) cnt++;       vec[i].emplace_back(cnt);     }     if (x != 1) vec[x].emplace_back(1);   }   inline void work() {     int n = read();     long long ans = 1;     for (int i = 1; i <= n; i++) {       a[i] = read();       divide(a[i]);     }     for (int i = 1; i <= 200000; i++) {       std::sort(vec[i].begin(), vec[i].end());       if (vec[i].size() < n - 2)         continue;       else if (vec[i].size() == n - 1 && !vec[i].empty())         ans *= q_pow(i, vec[i][0]);       else if (vec[i].size() == n && vec[i].size() >= 2)         ans *= q_pow(i, vec[i][1]);       else if (vec[i].size() == n && !vec[i].empty())         ans *= i;     }     printf( %lld n , ans);   }   int main() {     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 100005;   const int mod = 1e9 + 9;   const int pp = 31;   const int ppp = 56;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int i, j, k, n;     string s, t;     cin >> s >> t >> k;     n = s.length();     vector<int> a(n), p(n);     for (i = 0; i < n; ++i) {       a[i] = t[s[i] -  a ] -  0 ;     }     p[0] = a[0];     for (i = 1; i < n; i++) p[i] = p[i - 1] + a[i];     set<pair<long long, long long>> sz;     vector<long long> p_pow(n + 1), pp_pow(n + 1);     p_pow[0] = 1;     pp_pow[0] = 1;     for (i = 1; i <= n; i++) {       p_pow[i] = (p_pow[i - 1] * pp) % mod;       pp_pow[i] = (pp_pow[i - 1] * ppp) % mod;     }     vector<long long> hsh(n + 1, 0), hshh(n + 1, 0);     for (i = 0; i < n; i++) {       hsh[i + 1] = (hsh[i] + p_pow[i] * (s[i] -  a  + 1)) % mod;       hshh[i + 1] = (hshh[i] + pp_pow[i] * (s[i] -  a  + 1)) % mod;     }     for (i = 1; i <= n; i++) {       for (j = 0; j < n - i + 1; ++j) {         long long cur_h_1 = (hsh[j + i] + mod - hsh[j]) % mod;         long long cur_h_2 = (hshh[j + i] + mod - hshh[j]) % mod;         if (j > 0 && (i - p[j + i - 1] + p[j - 1]) <= k)           sz.insert({cur_h_1 * p_pow[n - j - 1] % mod,                      cur_h_2 * pp_pow[n - j - 1] % mod});         else if (j == 0 && (i - p[j + i - 1]) <= k) {           sz.insert({cur_h_1 * p_pow[n - j - 1] % mod,                      cur_h_2 * pp_pow[n - j - 1] % mod});         }       }     }     cout << sz.size();   }