func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5050;   const int inf = 0x3f3f3f3f;   int to[N * 2], nxt[N * 2], pre[N * 2], cnt, n, tot[N], dp[N][N][2];   void makeedge(int x, int y) {     to[cnt] = x;     nxt[cnt] = pre[y];     pre[y] = cnt++;     to[cnt] = y;     nxt[cnt] = pre[x];     pre[x] = cnt++;   }   int dfs(int x, int fa) {     int son = 0;     if (tot[x] == 1) {       son = 1;       dp[x][0][1] = 0;       dp[x][1][0] = 0;     } else {       dp[x][0][1] = 0;       dp[x][0][0] = 0;     }     for (int p = pre[x]; p != -1; p = nxt[p]) {       int y = to[p];       if (y == fa) continue;       int tmp = dfs(y, x);       for (int j = son; j >= 0; j--) {         for (int k = tmp; k >= 1; k--) {           dp[x][j + k][0] =               min(dp[x][j + k][0],                   min(dp[x][j][0] + dp[y][k][1] + 1, dp[x][j][0] + dp[y][k][0]));           dp[x][j + k][1] =               min(dp[x][j + k][1],                   min(dp[x][j][1] + dp[y][k][0] + 1, dp[x][j][1] + dp[y][k][1]));         }         dp[x][j][0] = min(inf, dp[x][j][0] + min(dp[y][0][1] + 1, dp[y][0][0]));         dp[x][j][1] = min(inf, dp[x][j][1] + min(dp[y][0][0] + 1, dp[y][0][1]));       }       son += tmp;     }     return son;   }   int main() {     scanf( %d , &n);     memset(pre, -1, sizeof(pre));     memset(dp, inf, sizeof(dp));     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       tot[x]++;       tot[y]++;       makeedge(x, y);     }     if (n == 2) {       printf( 1 n );       return 0;     }     int son = 0, S;     for (int i = 1; i <= n; i++) {       if (tot[i] != 1)         S = i;       else         son++;     }     dfs(S, 0);     printf( %d n , min(dp[S][son / 2][0], dp[S][son / 2][1]));   }   