func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 3010;   int n;   struct edge {     int ne, to;     edge(int N = 0, int T = 0) : ne(N), to(T) {}   } e[MAXN << 1];   int fir[MAXN], num = 0;   inline void join(int a, int b) {     e[++num] = edge(fir[a], b);     fir[a] = num;   }   int pa[MAXN][MAXN], siz[MAXN][MAXN];   void pre(int u, int fa, const int rt) {     siz[rt][u] = 1;     pa[rt][u] = fa;     for (int i = fir[u]; i; i = e[i].ne) {       int v = e[i].to;       if (v == fa) continue;       pre(v, u, rt);       siz[rt][u] += siz[rt][v];     }   }   long long f[MAXN][MAXN];   long long dfs(int u, int v) {     if (u == v) return 0ll;     if (f[u][v]) return f[u][v];     return f[u][v] = max(dfs(u, pa[u][v]), dfs(pa[v][u], v)) +                      1ll * siz[v][u] * siz[u][v];   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       join(u, v);       join(v, u);     }     for (int i = 1; i <= n; i++) pre(i, 0, i);     long long ans = 0;     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++) ans = max(ans, dfs(i, j));     printf( %lld n , ans);     return 0;   }   