func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = (int)1e9 + 7;   template <class X, class Y>   void minimize(X &x, const Y &y) {     if (x > y) x = y;   }   template <class X, class Y>   void maximize(X &x, const Y &y) {     if (x < y) x = y;   }   vector<int> adj[5050];   int nLeaf[5050];   int f[5050][5050][2];   int tmp[5050][2];   int n;   void loadTree(void) {     scanf( %d , &n);     for (int love = 0, _n = (n - 1); love < _n; love = love + 1) {       int u, v;       scanf( %d%d , &u, &v);       adj[u].push_back(v);       adj[v].push_back(u);     }     if (n == 2) {       printf( 1 n );       exit(0);     }     memset(f, 0x3f, sizeof f);   }   void dfs(int u, int p) {     bool leaf = true;     for (__typeof((adj[u]).begin()) it = (adj[u]).begin(); it != (adj[u]).end();          it++)       if (*it != p) {         int v = *it;         dfs(v, u);         leaf = false;       }     if (leaf) {       nLeaf[u] = 1;       for (int i = 0, _n = (2); i < _n; i = i + 1) f[u][i][i] = 0;       return;     }     for (int i = 0, _n = (2); i < _n; i = i + 1) f[u][0][i] = 0;     for (__typeof((adj[u]).begin()) it = (adj[u]).begin(); it != (adj[u]).end();          it++)       if (*it != p) {         int v = *it;         for (int i = 0, _n = (nLeaf[u] + 1); i < _n; i = i + 1)           for (int j = 0, _n = (2); j < _n; j = j + 1) {             tmp[i][j] = f[u][i][j];             f[u][i][j] = INF;           }         for (int i = 0, _n = (nLeaf[u] + 1); i < _n; i = i + 1)           for (int j = 0, _n = (2); j < _n; j = j + 1)             for (int k = 0, _n = (nLeaf[v] + 1); k < _n; k = k + 1)               for (int l = 0, _n = (2); l < _n; l = l + 1)                 minimize(f[u][i + k][j], tmp[i][j] + f[v][k][l] + (j != l));         nLeaf[u] += nLeaf[v];       }   }   void process(void) {     for (int i = (1), _b = (n); i <= _b; i = i + 1)       if (adj[i].size() > 1) {         dfs(i, -1);         printf( %d n , min(f[i][nLeaf[i] / 2][0], f[i][nLeaf[i] / 2][1]));         return;       }     assert(false);   }   int main(void) {     loadTree();     process();     return 0;   }   