func_code_string: #include <bits/stdc++.h>   using namespace std;   queue<int> q;   vector<int> v[200001];   set<pair<int, int> > se;   int mdis, node;   void dfs(int x, int l, int p) {     if (l > mdis) {       mdis = l;       node = x;     }     for (int y : v[x]) {       if (y == p) continue;       dfs(y, l + 1, x);     }   }   int main() {     int p, n, k, i, j, x, y, a, b, c;     scanf( %d %d , &n, &k);     p = k + 1;     for (i = 1; i <= k; ++i) {       se.insert(make_pair(p, i));       q.push(i);     }     for (i = k + 2; i <= n; ++i) {       x = q.front();       q.pop();       se.erase(make_pair(p, x));       se.insert(make_pair(p, i));       se.insert(make_pair(i, x));       q.push(i);     }     for (auto it : se) {       x = it.first;       y = it.second;       v[x].push_back(y);       v[y].push_back(x);     }     dfs(p, 0, 0);     mdis = 0;     dfs(node, 0, 0);     printf( %d n , mdis);     for (auto it : se) {       printf( %d %d n , it.first, it.second);     }     return 0;   }   