func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 512345, lgN = 20, rootN = 1123;   const double eps = 1e-11;   vector<int> cities;   int root = -1;   int dp[N];   bool visited[N], rem[N];   vector<int> adj[N];   void dfsTree(int v) {     int sum = 0;     auto it = lower_bound(cities.begin(), cities.end(), v);     if (it < cities.end() && *it == v) ++sum;     for (int i = 0; i < adj[v].size(); ++i) {       int u = adj[v][i];       if (visited[u]) continue;       visited[u] = true;       dfsTree(u);       sum += dp[u];     }     if (sum == 0)       rem[v] = true;     else if (sum == cities.size() && root == -1)       root = v;     else if (sum == cities.size())       rem[v] = true;     dp[v] = sum;   }   pair<int, int> bfsDistance(int src) {     memset(visited, false, sizeof visited);     queue<pair<int, int> > q;     q.push(make_pair(src, 0));     visited[src] = true;     pair<int, int> ret = make_pair(src, 0);     while (!q.empty()) {       int v = q.front().first, dist = q.front().second;       q.pop();       if (dist > ret.second || (dist == ret.second && v < ret.first))         ret = make_pair(v, dist);       for (int i = 0; i < adj[v].size(); ++i) {         int u = adj[v][i];         if (visited[u] || rem[u]) continue;         visited[u] = true;         q.push(make_pair(u, dist + 1));       }     }     return ret;   }   int main() {     int n, c;     scanf( %d %d , &n, &c);     int u, v;     for (int i = 1; i < n; ++i) {       scanf( %d %d , &u, &v);       adj[u].push_back(v), adj[v].push_back(u);     }     cities.resize(c);     for (int i = 0; i < cities.size(); ++i) scanf( %d , &cities[i]);     sort(cities.begin(), cities.end());     visited[1] = true;     dfsTree(1);     pair<int, int> x = bfsDistance(root);     pair<int, int> y = bfsDistance(x.first);     printf( %d n , min(x.first, y.first));     int ct = 0;     for (int i = 1; i <= n; ++i)       if (!rem[i]) ++ct;     int ans = 2 * (ct - 1) - y.second;     printf( %d n , ans);     return 0;   }   