func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline bool upmin(T &x, T y) {     return y < x ? x = y, 1 : 0;   }   template <typename T>   inline bool upmax(T &x, T y) {     return x < y ? x = y, 1 : 0;   }   const long double eps = 1e-11;   const long double pi = acos(-1);   const int oo = 1 << 30;   const long long loo = 1ll << 62;   const int MAXN = 5005;   const int mods = 998244353;   const int INF = 0x3f3f3f3f;   inline int read() {     int f = 1, x = 0;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x << 3) + (x << 1) + (c ^ 48);       c = getchar();     }     return x * f;   }   int f[MAXN][MAXN][2], g[MAXN][2], cnt[MAXN], num = 0, n;   vector<int> e[MAXN];   void tree_dp(int x, int father) {     int flag = 0;     for (auto v : e[x])       if (v != father) flag = 1, tree_dp(v, x);     if (!flag)       f[x][0][0] = f[x][1][1] = 0, cnt[x] = 1;     else       f[x][0][0] = f[x][0][1] = cnt[x] = 0;     for (auto v : e[x])       if (v != father) {         cnt[x] += cnt[v];         for (int i = cnt[x]; i >= 0; i--) {           g[i][0] = INF, g[i][1] = INF;           for (int j = min(cnt[v], i); j >= 0; j--) {             upmin(g[i][0], min(f[x][i - j][0] + f[v][j][0],                                f[x][i - j][0] + f[v][j][1] + 1));             upmin(g[i][1], min(f[x][i - j][1] + f[v][j][0] + 1,                                f[x][i - j][1] + f[v][j][1]));           }           f[x][i][0] = g[i][0], f[x][i][1] = g[i][1];         }       }   }   signed main() {     n = read();     for (int i = 1, u, v; i < n; i++)       u = read(), v = read(), e[u].push_back(v), e[v].push_back(u);     for (int i = 0; i <= n; i++)       for (int j = 0; j <= n; j++) f[i][j][0] = f[i][j][1] = INF;     for (int i = 1; i <= n; i++)       if (e[i].size() > 1) {         tree_dp(i, 0);         printf( %d n , min(f[i][cnt[i] / 2][0], f[i][cnt[i] / 2][1]));         return 0;       }     puts( 1 );     return 0;   }   