func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> l[100010], r[100010], chosenl[100010], chosenr[100010];   vector<bool> badl[100010], badr[100010];   bool monst[100010];   int ans[100010];   vector<pair<int, int> > edges[100010];   int cnt[100010], toFather[100010], fromFather[100010];   void longPathChild(int v, int f) {     if (monst[v])       ans[v] = 0;     else       ans[v] = -1000000000;     for (int i = 0; i < edges[v].size(); i++) {       if (edges[v][i].first != f) {         longPathChild(edges[v][i].first, v);         ans[v] = max(ans[v], ans[edges[v][i].first] + edges[v][i].second);       }     }   }   int longPathFather(int v, int f, int u) {     for (int i = 0; i <= edges[v].size(); i++) {       l[v].push_back(0);       badl[v].push_back(true);       chosenl[v].push_back(-1);       r[v].push_back(0);       badr[v].push_back(true);       chosenr[v].push_back(-1);     }     l[v][0] = r[v][edges[v].size()] = -1000000000;     if (monst[v]) l[v][0] = 0;     for (int i = 0; i < edges[v].size(); i++) {       int t;       if (edges[v][i].first != f)         t = ans[edges[v][i].first] + edges[v][i].second;       else         t = u;       if (t > l[v][i]) {         l[v][i + 1] = t;         badl[v][i + 1] = false;         chosenl[v][i + 1] = edges[v][i].first;       } else if (t == l[v][i]) {         l[v][i + 1] = l[v][i];         badl[v][i + 1] = true;         chosenl[v][i + 1] = edges[v][i].first;       } else {         l[v][i + 1] = l[v][i];         badl[v][i + 1] = badl[v][i];         chosenl[v][i + 1] = chosenl[v][i];       }     }     for (int i = edges[v].size() - 1; i >= 0; i--) {       int t;       if (edges[v][i].first != f)         t = ans[edges[v][i].first] + edges[v][i].second;       else         t = u;       if (t > r[v][i + 1]) {         r[v][i] = t;         badr[v][i] = false;         chosenr[v][i] = edges[v][i].first;       } else if (t == r[v][i + 1]) {         r[v][i] = r[v][i + 1];         badr[v][i] = true;         chosenr[v][i] = edges[v][i].first;       } else {         r[v][i] = r[v][i + 1];         badr[v][i] = badr[v][i + 1];         chosenr[v][i] = chosenr[v][i + 1];       }     }     int ret = 0;     for (int i = 0; i < edges[v].size(); i++)       if (edges[v][i].first != f) {         int t = longPathFather(edges[v][i].first, v,                                max(l[v][i], r[v][i + 1]) + edges[v][i].second);         if (l[v][i] > r[v][i + 1] && l[v][i] == u && !badl[v][i]) ret += t;         if (r[v][i + 1] > l[v][i] && r[v][i + 1] == u && !badr[v][i + 1])           ret += t;         cnt[v] += t;       }     if (monst[v] && l[v][edges[v].size()] == u && !badl[v][edges[v].size()])       ret++;     return (toFather[v] = ret);   }   void fillFromFather(int v, int f) {     cnt[v] += fromFather[v];     for (int i = 0; i < edges[v].size(); i++) {       if (max(l[v][i], r[v][i + 1]) < 0) continue;       if (edges[v][i].first != f) {         if (l[v][i] > r[v][i + 1] && !badl[v][i] && chosenl[v][i] != f)           fromFather[chosenl[v][i]] += toFather[edges[v][i].first];         if (r[v][i + 1] > l[v][i] && !badr[v][i + 1] && chosenr[v][i + 1] != f)           fromFather[chosenr[v][i + 1]] += toFather[edges[v][i].first];       } else {         if (l[v][i] > r[v][i + 1] && !badl[v][i] && chosenl[v][i] != f)           fromFather[chosenl[v][i]] += fromFather[v];         if (r[v][i + 1] > l[v][i] && !badr[v][i + 1] && chosenr[v][i + 1] != f)           fromFather[chosenr[v][i + 1]] += fromFather[v];       }     }     if (monst[v] && !badl[v][edges[v].size()] && chosenl[v][edges[v].size()] != f)       fromFather[chosenl[v][edges[v].size()]]++;     for (int i = 0; i < edges[v].size(); i++)       if (edges[v][i].first != f) fillFromFather(edges[v][i].first, v);   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a;       cin >> a;       monst[a] = true;     }     for (int i = 0; i < n - 1; i++) {       int a, b, c;       cin >> a >> b >> c;       edges[a].push_back(pair<int, int>(b, c));       edges[b].push_back(pair<int, int>(a, c));     }     longPathChild(1, -1);     longPathFather(1, -1, -1000000000);     fillFromFather(1, -1);     int best = 0, bestcnt = 0;     for (int i = 1; i <= n; i++) {       if (monst[i]) continue;       if (cnt[i] > best) {         best = cnt[i];         bestcnt = 1;       } else if (cnt[i] == best)         bestcnt++;     }     cout << best <<     << bestcnt << endl;   }   