func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > ans;   int deg[400001];   int tot;   int flag;   int n, d, k;   int name() {     flag++;     return flag;   }   void f(int x, int curr) {     if (tot <= 0 or x == 0) return;     while (deg[curr] < k and tot > 0) {       if (tot <= 0) return;       int t = name();       ans.push_back({curr, t});       deg[t]++;       deg[curr]++;       tot--;       f(x - 1, t);     }   }   int main() {     cin >> n >> d >> k;     tot = n - 1;     if (k == 1) {       if (n == 2 and d == 1) {         printf( YES n );         printf( 1 2 n );       } else if (n == 1 and d == 0) {         printf( YES n );       } else {         printf( NO n );       }       return 0;     }     if (n < d + 1) {       printf( NO n );       return 0;     }     if (k == 2) {       if (n == d + 1) {         printf( YES n );         for (int i = 0; i < n - 1; ++i) {           printf( %d %d n , i + 1, i + 2);         }       } else         printf( NO n );       return 0;     }     for (int i = 0; i < d; ++i) {       ans.push_back({i + 1, i + 2});       deg[i + 1]++;       deg[i + 2]++;       tot--;     }     flag = d + 1;     for (int i = 2; i <= d; ++i) {       int temp = min(i - 1, d + 1 - i);       f(temp, i);     }     if (tot > 0) {       printf( NO n );       return 0;     }     printf( YES n );     for (auto i : ans) {       printf( %d %d n , i.first, i.second);     }     return 0;   }   