func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   vector<int> tree[3005];   int p[3005][3005];   long long sz[3005][3005];   long long dfs(int root, int cur) {     sz[root][cur] = 1;     for (int nxt : tree[cur]) {       if (!sz[root][nxt]) {         sz[root][cur] += dfs(root, nxt);         p[root][nxt] = cur;       }     }     return sz[root][cur];   }   long long dp[3005][3005];   long long f(int a, int b) {     long long& ret = dp[a][b];     if (~ret) return ret;     ret = 0;     if (a == b) return ret;     return ret = sz[b][a] * sz[a][b] + max(f(a, p[a][b]), f(p[b][a], b));   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     memset(dp, -1, sizeof(dp));     cin >> n;     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       tree[a].push_back(b);       tree[b].push_back(a);     }     for (int i = 1; i <= n; i++) dfs(i, i);     long long ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) ans = max(ans, f(i, j));     }     cout << ans;   }   