func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 3;   vector<int> adj[MAXN];   int sz[MAXN], rt = -1, ok[MAXN], k;   int dfs1(int u, int p) {     for (int i = 0; i < adj[u].size(); i++)       if (adj[u][i] != p) sz[u] += dfs1(adj[u][i], u);     return sz[u];   }   pair<int, int> dfs2(int u, int p) {     vector<pair<int, int> > ans;     pair<int, int> ret;     ans.push_back(make_pair(sz[u], u));     for (int i = 0; i < adj[u].size(); i++)       if (adj[u][i] != p) {         if (sz[adj[u][i]] >= k) {           ans.push_back(make_pair(sz[adj[u][i]], adj[u][i]));           ans.push_back(dfs2(adj[u][i], u));         }       }     sort(ans.begin(), ans.end());     for (int i = 0; i < ans.size(); i++) {       if (ans[i].first >= k && (rt == -1 || sz[rt] > ans[i].first))         rt = ans[i].second, ret = ans[i];     }     return ret;   }   long long dfs3(int u, int p, int dep) {     long long ret = 0;     if (ok[u]) ret += dep;     for (int i = 0; i < adj[u].size(); i++)       if (adj[u][i] != p) ret += dfs3(adj[u][i], u, dep + 1);     return ret;   }   int main() {     int n, x;     scanf( %d%d , &n, &k);     for (int i = 0; i < 2 * k; i++) scanf( %d , &x), ok[x] = sz[x] = 1;     for (int i = 0; i < n - 1; i++) {       int a, b;       scanf( %d%d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     dfs1(1, -1);     dfs2(1, -1);     printf( %I64d n , dfs3(rt, -1, 0));   }   