func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int max(long long int a, long long int b) {     if (a > b)       return a;     else       return b;   }   long long int min(long long int a, long long int b) {     if (a < b)       return a;     else       return b;   }   const int dx[4] = {-1, 1, 0, 0};   const int dy[4] = {0, 0, -1, 1};   int XX[] = {-1, -1, -1, 0, 0, 1, 1, 1};   int YY[] = {-1, 0, 1, -1, 1, -1, 0, 1};   vector<pair<long long int, long long int> > edges;   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long int n, m, i, j, k, l, r, ind, c, d, x;     cin >> n >> k;     j = k + 1;     long long int z = n / k;     long long int count = 0, ans = 2 * z;     j = 2;     vector<long long int> vec, vec2;     for (i = 1; i <= k; i++) {       count = 0;       while (count < z && j <= n) {         if (count == 0)           edges.push_back(make_pair(1, j));         else           edges.push_back(make_pair(j - 1, j));         j++;         count++;       }       vec2.push_back(count);       vec.push_back(j - 1);     }     if (j == n + 1) {       sort(vec2.begin(), vec2.end());       long long int sum = vec2[vec2.size() - 1];       if (vec2.size() >= 2) sum += vec2[vec2.size() - 2];       cout << sum <<   n ;       for (i = 0; i < edges.size(); i++) {         cout << edges[i].first <<     << edges[i].second <<   n ;       }       return 0;     }     long long int flag = 0;     for (i = 0; i < vec.size(); i++) {       if (j == n + 1) break;       edges.push_back(make_pair(vec[i], j));       j++;       flag++;     }     if (flag == 1)       ans++;     else if (flag > 1)       ans += 2;     cout << ans <<   n ;     for (i = 0; i < edges.size(); i++) {       cout << edges[i].first <<     << edges[i].second <<   n ;     }   }   