func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 3452;   vector<int> G[maxn];   pair<int, int> snd[maxn][maxn];   int size[maxn][maxn];   long long f[maxn][maxn];   int n, cur, nxt;   void dfs(int p, int fl = -1) {     if (fl == cur) {       nxt = p;     }     size[cur][p] = 1;     snd[cur][p] = make_pair(nxt, fl);     for (auto t : G[p]) {       if (t == fl) {         continue;       }       dfs(t, p);       size[cur][p] += size[cur][t];     }   }   long long dp(int x, int y) {     if (x == y) {       return 0;     }     pair<int, int> path = snd[x][y];     long long sum = (long long)size[x][y] * size[y][x];     long long &v = f[x][y];     if (v != -1) {       return v;     }     long long l = dp(path.first, y) + sum;     long long r = dp(x, path.second) + sum;     return v = max(l, r);   }   int main() {     cin >> n;     for (int i = 1; i < (n); i++) {       int x, y;       cin >> x >> y;       G[x].push_back(y);       G[y].push_back(x);     }     for (int i = 1; i <= (n); i++) {       cur = i;       nxt = -1;       dfs(i);     }     memset(f, -1, sizeof(f));     long long ans = 0;     for (int i = 1; i <= (n); i++) {       for (int j = 1; j < (i); j++) {         ans = max(ans, dp(i, j));       }     }     cout << ans << endl;     return 0;   }   