func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 50;   const int INF = 0x3f3f3f3f;   struct node {     int to, next;   } edge[maxn * 3];   struct Node {     int id;     long long val;     bool operator<(const Node& a) const { return val < a.val; }   };   int head[maxn], cnt, d[maxn], depth[maxn], ans[maxn];   int s[maxn];   void add(int u, int v) {     edge[cnt].to = v;     edge[cnt].next = head[u];     head[u] = cnt++;   }   void dfs(int k, int fa) {     for (int i = head[k]; i != -1; i = edge[i].next) {       int to = edge[i].to;       if (to == fa) continue;       depth[to] = depth[k] + 1;       dfs(to, k);       s[k] += s[to] + 1;     }   }   int main() {     int n, k;     cnt = 0;     memset(head, -1, sizeof(head));     memset(depth, -1, sizeof(depth));     memset(s, 0, sizeof(s));     scanf( %d%d , &n, &k);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       add(u, v);       add(v, u);       d[u]++;       d[v]++;     }     depth[1] = 0;     dfs(1, 1);     priority_queue<Node> q;     for (int i = 1; i <= n; i++)       if (d[i] == 1 && i != 1) q.push({i, depth[i]});     long long sum = 0;     while (k && !q.empty()) {       Node top = q.top();       sum += top.val;       q.pop();       k--;       for (int i = head[top.id]; i != -1; i = edge[i].next) {         int to = edge[i].to;         if (depth[to] < depth[top.id]) {           d[to]--;           if (d[to] == 1) q.push({to, depth[to] - s[to]});           break;         }       }     }     printf( %lld n , sum);   }   