func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18 + 1e17;   const long long mod = 1e9 + 7;   long long modInverse(long long a, long long m) {     long long m0 = m;     long long y = 0, x = 1;     if (m == 1) return 0;     while (a > 1) {       long long q = a / m;       long long t = m;       m = a % m, a = t;       t = y;       y = x - q * y;       x = t;     }     if (x < 0) x += m0;     return x;   }   long long powm(long long a, long long b) {     a = a % mod;     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return (res % mod);   }   const long long N = 3e5 + 6;   struct st {     long long a, b, c, d;   };   bool comp(st x, st y) { return x.a < y.a; }   long long arr[N][2];   long long n, m;   vector<pair<long long, long long> > graph[N];   bool vis[N];   long long ans = 0;   void dijk(long long pos, long long par, long long f) {     for (pair<long long, long long> i : graph[pos])       if (i.first != par) {         arr[i.first][f] = arr[pos][f] + i.second;         dijk(i.first, pos, f);       }   }   void sol() {     vector<st> v;     multiset<long long> s;     for (long long i = 0; i < n; i++) {       v.push_back({arr[i][0] - arr[i][1], arr[i][0], arr[i][1], i});       s.insert(arr[i][1]);     }     sort(v.begin(), v.end(), comp);     for (long long i = 0; i < n - 1; i++) {       s.erase(s.find(v[i].c));       vector<long long> va;       for (pair<long long, long long> j : graph[v[i].d]) {         if (s.find(arr[j.first][1]) != s.end()) {           s.erase(s.find(arr[j.first][1]));           va.push_back(arr[j.first][1]);         }       }       if (s.size() != 0) ans = max(v[i].b + (*s.rbegin()), ans);       for (long long j : va) s.insert(j);     }   }   void solve() {     cin >> n >> m;     for (long long i = 0; i < n; i++) {       arr[i][0] = inf;       arr[i][1] = inf;     }     for (long long i = 0; i < n - 1; i++) {       long long aa, bb, cc;       cin >> aa >> bb >> cc;       aa--;       bb--;       graph[aa].push_back(make_pair(bb, cc));       graph[bb].push_back(make_pair(aa, cc));     }     memset(vis, 0, sizeof(vis));     arr[0][0] = 0;     arr[n - 1][1] = 0;     dijk(0, -1, 0);     dijk(n - 1, -1, 1);     sol();     for (long long i = 0; i < m; i++) {       long long x;       cin >> x;       cout << (min(arr[0][1], ans + x)) <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     for (long long i = 1; i <= t; i++) {       solve();     }   }   