func_code_string: #include <bits/stdc++.h>   using namespace std;   struct node {     int x, id;     friend bool operator<(node a, node b) {       if (a.x == b.x) return a.id < b.id;       return a.x < b.x;     }   } a[200005];   priority_queue<node> Q;   struct edge {     int s, e;   } ans[2000005];   int id;   int main() {     int n, s;     while (scanf( %d %d , &n, &s) != EOF) {       int i, j, k;       for (i = 1; i <= n; ++i) {         scanf( %d , &a[i].x);         a[i].id = i;         Q.push(a[i]);       }       node x;       id = 0;       while (!Q.empty()) {         x = Q.top();         Q.pop();         j = 0;         for (i = 0; i < x.x && (!Q.empty()); ++i) {           a[j] = Q.top();           Q.pop();           ans[id].s = x.id;           ans[id].e = a[j].id;           a[j].x--;           j++;           id++;         }         if (i == x.x) {           --j;           while (j >= 0) {             if (a[j].x) {               Q.push(a[j]);             }             j--;           }         } else {           s = 0;           break;         }       }       if (s == 0) {         puts( No );       } else {         puts( Yes );         printf( %d n , id);         for (i = 0; i < id; ++i) {           printf( %d %d n , ans[i].s, ans[i].e);         }       }     }     return 0;   }   