func_code_string: #include <bits/stdc++.h>   using namespace std;   const double eps = 1e-5;   const int inf = (1 << 31) - 1;   const int hinf = 1000000000;   const int mod = 1000000007;   const int N = 3030;   int dp[3030][3030];   int n;   int head[3030];   int weizhi;   struct node {     int u, v, w, next;   } point[3030 << 1];   void add(int u, int v, int w) {     point[weizhi].u = u;     point[weizhi].v = v;     point[weizhi].w = w;     point[weizhi].next = head[u];     head[u] = weizhi++;   }   void dfs(int now, int par, int dp[N]) {     dp[now] = 0;     for (int k = head[now]; k != -1; k = point[k].next) {       int i = point[k].v;       if (i == par) continue;       dfs(i, now, dp);       dp[now] += dp[i] + point[k].w;     }   }   void DFS(int now, int p, int a, int& ret) {     ret = min(ret, dp[now][now] - dp[now][a]);     for (int k = head[now]; k != -1; k = point[k].next) {       int i = point[k].v;       if (i == p) continue;       DFS(i, now, a, ret);     }   }   int main() {     scanf( %d , &n);     int a, b;     memset((head), -1, sizeof(head));     weizhi = 0;     for (int i = 1; i < n; i++) {       scanf( %d%d , &a, &b);       add(a, b, 0);       add(b, a, 1);     }     memset(dp, 0, sizeof(dp));     if (n == 1) {       cout << 0 << endl;       return 0;     }     for (int i = 1; i <= n; i++) {       dfs(i, -1, dp[i]);     }     int ans = inf;     for (int u = 1; u <= n; u++) {       for (int k = head[u]; k != -1; k = point[k].next) {         int i = point[k].v;         int w = point[k].w;         if (w) continue;         int ret1 = inf;         int ret2 = inf;         DFS(i, u, u, ret1);         DFS(u, i, i, ret2);         ans = min(ans, ret1 + ret2 - 1);       }     }     printf( %d n , ans);   }   