func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, one, two[2], tmp, num, a[N];   bool flag, f[N];   int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     return x * f;   }   int main() {     n = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= n; i++) {       if (f[i]) continue;       f[i] = true;       if (a[i] == i) {         one = i;         continue;       }       if (a[a[i]] == i) {         two[0] = i;         two[1] = a[i];         f[a[i]] = true;         continue;       }       tmp = a[i];       num = 1;       while (!f[tmp]) {         f[tmp] = true;         num++;         tmp = a[tmp];       }       if (num & 1) flag = true;     }     if (one) {       printf( YES n );       for (int i = 1; i <= n; i++)         if (i != one) printf( %d %d n , one, i);       return 0;     }     if (flag || !two[0]) {       printf( NO );       return 0;     }     printf( YES n%d %d n , two[0], two[1]);     memset(f, 0, sizeof(f));     for (int i = 1; i <= n; i++) {       if (f[i] || i == two[0] || i == two[1]) continue;       tmp = i;       num = 0;       while (!f[tmp]) {         printf( %d %d n , two[num & 1], a[tmp]);         num++;         f[tmp] = true;         tmp = a[tmp];       }     }     return 0;   }   