func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 3) + (x << 1) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   int n, f[5010][5010][2], out[5010], siz[5010], size, rt = 1;   struct node {     int u, v, nxt;   } e[5010 << 1];   int head[5010], js;   void add(int u, int v) {     e[++js] = (node){u, v, head[u]};     head[u] = js;   }   void dfs1(int u, int pre) {     for (int i = head[u]; i; i = e[i].nxt) {       int v = e[i].v;       out[u]++;       if (v == pre) continue;       dfs1(v, u);     }     size += out[u] == 1;   }   void dfs2(int u, int pre) {     if (out[u] == 1) {       siz[u] = 1;       f[u][0][0] = f[u][1][1] = 0;       return;     } else       f[u][0][0] = f[u][0][1] = 0;     for (int i = head[u]; i; i = e[i].nxt) {       int v = e[i].v;       if (v == pre) continue;       dfs2(v, u);       siz[u] += siz[v];       for (int j = siz[u]; j >= 0; j--) {         int tmp0 = 0x7fffffff, tmp1 = 0x7fffffff;         for (int k = 0; k <= siz[v]; k++)           if (k <= j) {             tmp0 = min(tmp0, f[u][j - k][0] + min(f[v][k][0], f[v][k][1] + 1));             tmp1 = min(tmp1, f[u][j - k][1] + min(f[v][k][1], f[v][k][0] + 1));           }         f[u][j][0] = tmp0;         f[u][j][1] = tmp1;       }     }   }   int main() {     n = read();     memset(f, 63, sizeof f);     for (int i = 1; i < n; i++) {       int x = read(), y = read();       add(x, y), add(y, x);     }     dfs1(1, 0);     while (out[rt] == 1) rt++;     dfs2(rt, 0);     printf( %d , min(f[rt][size >> 1][0], f[rt][size >> 1][1]));     return 0;   }   