func_code_string: #include <bits/stdc++.h>   using namespace std;   const int M = 2e5 + 5;   vector<int> G[M];   int n, A[M], num, ok, res, ans[2][M], C;   bool mark[M];   void ma(int a, int b) {     if (a == b || mark[a] && mark[b]) return;     printf( %d %d n , a, b);     ans[0][C] = a;     ans[1][C] = b;     C++;     mark[a] = mark[b] = 1;     ma(A[a], A[b]);   }   int main() {     scanf( %d , &n);     res = -1;     for (int i = 1; i <= n; i++) scanf( %d , A + i);     for (int i = 1; i <= n; i++) {       int nw = A[i], has = 0;       while (!mark[nw]) {         has = 1;         mark[nw] = 1;         G[num].push_back(nw);         nw = A[nw];       }       if (G[num].size() == 1) ok = A[i];       if (G[num].size() == 2) res = num;       if (has) num++;     }     memset(mark, 0, sizeof(mark));     if (ok) {       puts( YES );       for (int i = 1; i <= n; i++)         if (i != ok) printf( %d %d n , ok, i);     } else if (~res) {       for (int i = 0; i < num; i++)         if (G[i].size() & 1) {           puts( NO );           return 0;         }       puts( YES );       printf( %d %d n , G[res][0], A[G[res][0]]);       for (int i = 0; i < num; i++)         if (res != i) ma(G[res][0], G[i][0]);     } else       puts( NO );     return 0;   }   