func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, l, n, k, d, max = 0, gen, e = 0;     long long p;     scanf( %d %d , &n, &k);     vector<vector<int> > v(n);     for (i = 0; i < n; i++) {       scanf( %d , &d);       v[d].push_back(i);       if (d > max) max = d;     }     p = 1;     for (i = 0; i <= max; i++) {       gen = v[i].size();       if (i > 0) e += gen;       if (gen > p || gen <= 0) break;       p = gen;       if (i == 0)         p = k;       else         p = p * (k - 1);     }     if (i <= max)       printf( -1 n );     else {       printf( %d n , e);       for (i = 0; i < max; i++) {         gen = 0;         if (i == 0)           e = k;         else           e = k - 1;         for (j = 0; j < (int)(v[i].size()); j++) {           for (l = gen; l < gen + e && l < (int)(v[i + 1].size()); l++) {             printf( %d %d n , v[i][j] + 1, v[i + 1][l] + 1);           }           gen += e;           if (gen >= v[i + 1].size()) break;         }       }     }     return 0;   }   