func_code_string: #include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-8;   const int MAXN = 10005;   const int INF = 1111111111;   struct Node {     int id, val;     bool operator<(const Node& a) const {       if (a.val == val) return a.id < id;       return a.val < val;     }   };   int du[100];   int n, p, tot, fg;   priority_queue<Node> q;   int main() {     int ca;     scanf( %d , &ca);     while (ca--) {       while (!q.empty()) q.pop();       memset(du, 0, sizeof(du));       scanf( %d%d , &n, &p);       tot = (2 * n + p) * 2;       fg = tot % n;       tot /= n;       Node ft;       for (int i = 1; i < n; i++) {         ft.id = i + 1;         ft.val = 0;         q.push(ft);       }       int cnt = 0;       for (int i = 1; i <= n; i++) {         while (1) {           if (cnt == 2 * n + p) break;           ft = q.top();           while (ft.id <= i) {             q.pop();             ft = q.top();           }           if (fg && du[i] == tot + 1) {             fg--;             break;           } else if (fg == 0 && du[i] == tot)             break;           q.pop();           du[i]++, du[ft.id]++;           ft.val++;           q.push(ft);           printf( %d %d n , i, ft.id);           cnt++;         }       }     }     return 0;   }   