func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const long long L = 1e9;   int n, m, p, r, par[N];   long long size[N];   vector<int> adj[N];   vector<pair<long long, int> > ans;   priority_queue<pair<long long, int> > q;   int find_par(int v) { return par[v] == v ? v : par[v] = find_par(par[v]); }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> p >> r;     if (!m && r == n) {       cout << (p ?  NO  :  YES ) <<   n ;       return 0;     }     for (int i = 0; i < n; i++) par[i] = i, size[i] = 0;     for (int i = 0; i < m; i++) {       int u, v, l;       cin >> u >> v >> l;       u = find_par(--u), v = find_par(--v);       if (u != v) par[u] = v, size[v] += size[u];       size[v] += l;     }     for (int i = 0; i < n; i++)       if (par[i] == i) q.push(pair<long long, int>(-size[i], i));     while (p && q.size() > r) {       p--;       pair<long long, int> a, b;       a = q.top(), q.pop();       b = q.top(), q.pop();       long long l = min(L, -a.first + -b.first + 1);       q.push(pair<long long, int>(a.first + b.first - l, a.second));       ans.push_back(pair<long long, int>(a.second + 1, b.second + 1));       par[b.second] = a.second;     }     if (q.size() != r)       cout <<  NO n ;     else {       cout <<  YES n ;       for (int i = 0; i < ans.size(); i++)         cout << ans[i].first <<     << ans[i].second <<   n ;       for (int v = 0; v < n; v++)         if (par[v] != v) {           while (p--) cout << v + 1 <<     << par[v] + 1 <<   n ;           break;         }     }     return 0;   }   