func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = (int)(1e6);   char S[N + 1], T[N + 1];   vector<int> multiply(vector<int> a, vector<int> b) {     int n = (int)a.size();     vector<int> ret;     for (int i = 0; i < n; i++) ret.push_back(a[b[i]]);     return ret;   }   vector<int> pow(vector<int> a, int b) {     int n = (int)a.size();     vector<int> ret;     if (b == 0) {       for (int i = 0; i < n; i++) ret.push_back(i);       return ret;     }     if (b % 2 == 1) return multiply(pow(a, b - 1), a);     ret = pow(a, b / 2);     return multiply(ret, ret);   }   void solve(int k, int d, int n) {     vector<int> P, vet, ret;     for (int i = 0; i < d; i++)       for (int j = i; j < k; j += d)         if (j > 0) P.push_back(j);     P.push_back(0);     for (int i = 0; i < k; i++) vet.push_back(i);     for (int i = 0, x = 0; i + k <= n; i++) {       ret.push_back(vet[x]);       vet[x] = i + k;       x = P[x];     }     vector<int> aux = pow(P, n - k + 1);     for (int i = 0; i < k - 1; i++) ret.push_back(vet[aux[i]]);     for (int i = 0; i < n; i++) T[i] = S[i];     for (int i = 0; i < n; i++) S[i] = T[ret[i]];     printf( %s n , S);   }   int main() {     scanf( %s , S);     int t;     scanf( %d , &t);     while (t-- > 0) {       int k, d;       scanf( %d %d , &k, &d);       solve(k, d, strlen(S));     }     return 0;   }   