func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 3000;   vector<int> E[MAXN];   long long dp[MAXN][MAXN];   int P[MAXN][MAXN];   int T[MAXN][MAXN];   int n;   bool cmp(int a, int b) { return dp[a] > dp[b]; }   void dfs(int x, int p, int r) {     P[r][x] = p;     int d = 1;     for (int i = 0; i < E[x].size(); ++i) {       int v = E[x][i];       if (v != p) {         dfs(v, x, r);         d += T[r][v];       }     }     T[r][x] = d;   }   long long dp_get(int u, int v) {     if (u == v || dp[u][v] != 0) return dp[u][v];     long long d =         max(dp_get(u, P[u][v]), dp_get(v, P[v][u])) + T[u][v] * 1LL * T[v][u];     dp[u][v] = d;     dp[v][u] = d;     return d;   }   void solve() {     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       int x, y;       scanf( %d%d , &x, &y);       --x, --y;       E[x].push_back(y);       E[y].push_back(x);     }     for (int i = 0; i < n; ++i) dfs(i, -1, i);     long long bestres = 0;     for (int i = 0; i < n; ++i)       for (int j = 0; j < i; ++j) bestres = max(bestres, dp_get(i, j));     printf( %I64d n , bestres);   }   int main() {     solve();     return 0;   }   