func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3009;   int box[N], kk;   struct node {     int t, next;   } e[N << 1];   int n;   void add(int s, int t) {     e[kk].t = t, e[kk].next = box[s];     box[s] = kk++;   }   int tot;   void pre_dfs(int r, int fa) {     for (int i = box[r]; i + 1; i = e[i].next)       if (e[i].t != fa) {         pre_dfs(e[i].t, r);         tot += i & 1;       }   }   int cut;   void dfs(int r, int fa, int now) {     cut = max(now, cut);     for (int i = box[r]; i + 1; i = e[i].next)       if (e[i].t != fa) {         if (i & 1)           dfs(e[i].t, r, now + 1);         else           dfs(e[i].t, r, max(now - 1, 0));       }   }   int main() {     memset(box, -1, sizeof(box));     cin >> n;     for (int i = 1; i < n; i++) {       int s, t;       cin >> s >> t;       add(s, t);       add(t, s);     }     int ans = N;     for (int i = 1; i <= n; i++) {       tot = 0;       pre_dfs(i, i);       cut = 0;       dfs(i, i, 0);       ans = min(tot - cut, ans);     }     cout << ans << endl;     return 0;   }   