func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[1000006], n, v[1000006], t[1000006];   void uma(int x) {     int i;     for (i = 0; i < n; i++) v[i] = i;     for (; x; x >>= 1) {       if (x & 1) {         for (i = 0; i < n; i++) v[i] = a[v[i]];       }       for (i = 0; i < n; i++) t[i] = a[a[i]];       for (i = 0; i < n; i++) a[i] = t[i];     }     for (i = 0; i < n; i++) a[i] = v[i];   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int m, i, d, k, j, l, p;     string s, os;     cin >> s >> m;     os = s;     n = s.size();     for (i = 0; i < m; i++) {       cin >> k >> d;       p = 0;       for (j = 0; j < d; j++)         for (l = j; l < k; l += d) a[p++] = l;       for (j = 0; j < k - 1; j++) a[j] = a[j + 1];       for (j = k - 1; j < n - 1; j++) a[j] = j + 1;       a[j] = 0;       uma(n - k + 1);       for (j = 0; a[j]; j++) {       }       p = 0;       for (; j < n; j++) os[p++] = s[a[j]];       for (j = 0; a[j]; j++) os[p++] = s[a[j]];       s = os;       cout << s <<   n ;     }   }   