func_code_string: #include <bits/stdc++.h>   using namespace std;   int INT_MAX_VAL = (int)0x3F3F3F3F;   int INT_MIN_VAL = (int)-0x3F3F3F3F;   long long LONG_MAX_VAL = (long long)0x3F3F3F3F3F3F3F3F;   long long LONG_MIN_VAL = (long long)-0x3F3F3F3F3F3F3F3F;   vector<long long> G[5005];   long long n;   int W;   int cnt[5005];   int dp[2][5005][5005];   int dfs2(int v, int p) {     if (G[v].size() == 1) {       cnt[v] = 1;       return 1;     }     int res = 0;     for (auto &w : G[v])       if (w != p) res += dfs2(w, v);     cnt[v] = res;     return res;   }   void dfs(int v, int p) {     dp[1][v][0] = 0;     if (G[v].size() == 1) {       dp[0][v][1] = 0;       return;     }     dp[0][v][0] = 0;     dp[1][v][0] = 0;     for (auto &w : G[v]) {       if (w == p) continue;       dfs(w, v);       for (int i = W; i >= 0; --i) {         int d0 = INT_MAX_VAL;         int d1 = INT_MAX_VAL;         for (int j = min(i, cnt[w]); j >= 0; --j) {           d0 = min(d0, dp[0][w][j] + dp[0][v][i - j]);           d0 = min(d0, dp[1][w][j] + dp[0][v][i - j] + 1);           d1 = min(d1, dp[1][w][j] + dp[1][v][i - j]);           d1 = min(d1, dp[0][w][j] + dp[1][v][i - j] + 1);         }         dp[0][v][i] = d0;         dp[1][v][i] = d1;       }     }   }   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     memset(dp, 0x3F, 2 * 5005 * 5005 * sizeof(int));     cin >> n;     for (long long(i) = 0LL; (i) < (n - 1); (i)++) {       long long a, b;       cin >> a >> b;       --a, --b;       G[a].push_back(b);       G[b].push_back(a);     }     if (n == 2) {       cout << 1 <<   n ;       return 0;     }     int i = 0;     while (G[i].size() == 1) ++i;     W = dfs2(i, -1) / 2;     dfs(i, -1);     cout << dp[0][i][W] <<   n ;     return 0;   }   