func_code_string: #include <bits/stdc++.h>   using namespace std;   const int inf = 2e9;   const long long INF = 8e18;   const int maxn = 1e5 + 5;   int n;   int cnt[maxn], val[maxn];   long long S, SUM;   vector<pair<int, int> > e[maxn];   inline void dfs(int u, int pre) {     if (u != 1 && e[u].size() == 1) {       cnt[u] = 1;     }     for (auto &x : e[u]) {       int v = x.first, w = x.second;       if (v == pre) {         continue;       }       val[v] = w;       dfs(v, u);       cnt[u] += cnt[v];     }   }   inline void init() {     for (int i = 0; i < n + 5; ++i) {       e[i].clear();       cnt[i] = 0;     }     SUM = 0;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int T;     cin >> T;     while (T--) {       cin >> n >> S;       for (int i = 1; i <= n - 1; ++i) {         int u, v, w;         cin >> u >> v >> w;         e[u].push_back({v, w});         e[v].push_back({u, w});       }       dfs(1, 1);       priority_queue<pair<long long, int> > pq;       for (int i = 2; i <= n; ++i) {         SUM += 1ll * val[i] * cnt[i];         pq.push({1ll * (val[i] - (val[i] >> 1)) * cnt[i], i});         val[i] >>= 1;       }       int ans = 0;       while (SUM > S) {         ++ans;         auto now = pq.top();         pq.pop();         long long w = now.first, id = now.second;         SUM -= w;         pq.push({1ll * (val[id] - (val[id] >> 1)) * cnt[id], id});         val[id] >>= 1;       }       cout << ans <<   n ;       init();     }     return 0;   }   