func_code_string: #include <bits/stdc++.h>   using namespace std;   const int SQ = 350;   const int MAX_N = 100000;   deque<int> a[MAX_N / SQ + 10];   int num[MAX_N / SQ + 10][MAX_N + 10];   int N, Q, lastans = 0;   void print() {     for (int i = 0; i <= N / SQ; i++) {       for (int j = 0; j < a[i].size(); j++) {         cout << a[i][j] <<    ;       }     }     cout << endl;     return;   }   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) {       int x = i / SQ, k;       scanf( %d , &k);       a[x].push_back(k);       num[x][k]++;     }     scanf( %d , &Q);     for (int i = 0; i < Q; i++) {       int type, l, r, k;       scanf( %d , &type);       if (type == 1) {         scanf( %d %d , &l, &r);         l = (l + lastans - 1) % N;         r = (r + lastans - 1) % N;         if (l > r) swap(l, r);         int lx = l / SQ, ly = l % SQ, rx = r / SQ, ry = r % SQ;         if (lx == rx) {           int f = a[rx][ry];           a[rx].erase(a[rx].begin() + ry);           a[rx].insert(a[rx].begin() + ly, f);         } else {           int f = a[rx][ry];           a[rx].erase(a[rx].begin() + ry);           num[rx][f]--;           for (int j = lx; j < rx; j++) {             int b = a[j].back();             a[j].pop_back();             a[j + 1].push_front(b);             num[j][b]--;             num[j + 1][b]++;           }           a[lx].insert(a[lx].begin() + ly, f);           num[lx][f]++;         }       } else {         scanf( %d %d %d , &l, &r, &k);         l = (l + lastans - 1) % N;         r = (r + lastans - 1) % N;         k = (k + lastans - 1) % N + 1;         if (l > r) swap(l, r);         int lx = l / SQ, ly = l % SQ, rx = r / SQ, ry = r % SQ;         int ans = 0;         if (lx == rx) {           for (int j = ly; j <= ry; j++)             if (a[lx][j] == k) ans++;         } else {           for (int j = ly; j < SQ; j++)             if (a[lx][j] == k) ans++;           for (int j = lx + 1; j < rx; j++) ans += num[j][k];           for (int j = 0; j <= ry; j++)             if (a[rx][j] == k) ans++;         }         lastans = ans;         printf( %d n , ans);       }     }     return 0;   }   