func_code_string: #include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (a < b) swap(a, b);     if (b == 0) return a;     return gcd(b, a % b);   }   vector<string> getWords(string s) {     string cur =   ;     vector<string> vec;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==    ) {         vec.push_back(cur);         cur =   ;       } else         cur += s[i];     }     vec.push_back(cur);     return vec;   }   int dist[213456], sz[213456];   vector<vector<int> > vec;   void dfs(int n, int p) {     sz[n] = 1;     for (auto x : vec[n]) {       if (x != p) {         dist[x] = dist[n] + 1;         dfs(x, n);         sz[n] += sz[x];       }     }   }   int main() {     int n, k;     cin >> n >> k;     vec.resize(n + 1);     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       vec[u].push_back(v);       vec[v].push_back(u);     }     dfs(1, 0);     vector<long long> vec1;     for (int i = 2; i <= n; i++) {       int val = dist[i] - (sz[i] - 1);       vec1.push_back(val);     }     sort(vec1.begin(), vec1.end());     reverse(vec1.begin(), vec1.end());     long long ans = 0;     for (int i = 0; i < k; i++) ans += vec1[i];     cout << ans;   }   