func_code_string: #include <bits/stdc++.h>   using namespace std;   int B[1 << 17];   int R[1 << 17];   vector<int> Add(const vector<int>& a, const vector<int>& b) {     vector<int> res = a;     int i;     for (i = (0); i < (int((b).size())); ++i) res.push_back(b[i]);     return res;   }   int main() {     int n;     scanf( %d , &n);     int i, j;     for (i = (0); i < (n); ++i) {       int a;       scanf( %d , &a);       --a;       R[a] = i;     }     memset(B, 0, sizeof(B));     vector<vector<int> > ret;     vector<vector<int> > ret2;     vector<vector<int> > A[8];     for (i = (0); i < (n); ++i)       if (B[i] == 0) {         int pos = i;         vector<int> v;         while (B[pos] == 0) {           B[pos] = 1;           v.push_back(pos);           pos = R[pos];         }         pos = 0;         int len = int((v).size());         while (len - pos > 4) {           vector<int> r;           for (j = (0); j < (5); ++j) r.push_back(v[pos + j]);           ret.push_back(r);           rotate(r.begin(), r.end() - 1, r.end());           ret2.push_back(r);           pos += 4;         }         if (len - pos > 1) {           vector<int> w;           for (j = (pos); j < (len); ++j) w.push_back(v[j]);           A[len - pos].push_back(w);         }       }     int L[8];     int C[8];     memset(L, 0, sizeof(L));     memset(C, 0, sizeof(C));     for (i = (0); i < (8); ++i) L[i] = int((A[i]).size());     for (i = (0); i < (L[4]); ++i) {       vector<int> r = A[4][i];       ret.push_back(r);       rotate(r.begin(), r.end() - 1, r.end());       ret2.push_back(r);     }     while (C[2] + C[3] != L[2] + L[3]) {       if (C[2] != L[2]) {         vector<int> r = A[2][C[2]];         ++C[2];         vector<int> r2;         if (C[3] != L[3]) {           r2 = A[3][C[3]];           ++C[3];         } else if (C[2] != L[2]) {           r2 = A[2][C[2]];           ++C[2];         }         ret.push_back(Add(r, r2));         rotate(r.begin(), r.end() - 1, r.end());         if (!r2.empty()) rotate(r2.begin(), r2.end() - 1, r2.end());         ret2.push_back(Add(r, r2));         continue;       }       vector<int> r = A[3][C[3]];       ++C[3];       vector<int> r2;       if (C[3] != L[3]) {         r2 = A[3][C[3]];         r2.erase(r2.end() - 1);         ++C[3];       }       ret.push_back(Add(r, r2));       rotate(r.begin(), r.end() - 1, r.end());       if (!r2.empty()) rotate(r2.begin(), r2.end() - 1, r2.end());       ret2.push_back(Add(r, r2));       if (!r2.empty()) {         vector<int> t;         t.push_back(A[3][C[3] - 1][1]);         t.push_back(A[3][C[3] - 1][2]);         A[2].push_back(t);         ++L[2];       }     }     printf( %d n , int((ret).size()));     for (i = (0); i < (int((ret).size())); ++i) {       printf( %d n , int((ret[i]).size()));       for (j = (0); j < (int((ret[i]).size())); ++j)         printf( %d%c , ret[i][j] + 1, j == int((ret[i]).size()) - 1 ?   n  :    );       for (j = (0); j < (int((ret2[i]).size())); ++j)         printf( %d%c , ret2[i][j] + 1,                j == int((ret2[i]).size()) - 1 ?   n  :    );     }     return 0;   };   