func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   vector<pair<int, int> > edges;   vector<int> conn[201];   bool v1[201], v2[201];   int mx = 0;   void setEdge(int a, int b, int v) {     for (int s = 0; s < conn[a].size(); s++) {       if (conn[a][s] == b || conn[a][s] == -1) conn[a][s] = (v == 1 ? b : -1);     }     for (int s = 0; s < conn[b].size(); s++) {       if (conn[b][s] == a || conn[b][s] == -1) conn[b][s] = (v == 1 ? a : -1);     }   }   int getHeight(int i) {     v2[i] = 1;     int ret = 0;     for (int j = 0; j < conn[i].size(); j++) {       if (conn[i][j] != -1 && !v2[conn[i][j]]) {         ret = max(ret, 1 + getHeight(conn[i][j]));       }     }     v2[i] = 0;     return ret;   }   int longestPath(int i) {     v1[i] = 1;     int ret = 0;     int cnt = 0;     for (int j = 0; j < conn[i].size(); j++) {       if (conn[i][j] != -1 && !v1[conn[i][j]]) {         ret = max(ret, longestPath(conn[i][j]));         cnt++;       }     }     if (cnt == 0) ret = max(ret, getHeight(i));     v1[i] = 0;     return ret;   }   int main() {     cin >> n;     memset(v1, 0, sizeof v1);     memset(v2, 0, sizeof v2);     int a, b;     for (int i = 0; i < n - 1; i++) {       cin >> a >> b;       edges.push_back(make_pair(a - 1, b - 1));       conn[a - 1].push_back(b - 1);       conn[b - 1].push_back(a - 1);     }     for (int i = 0; i < edges.size(); i++) {       a = edges[i].first;       b = edges[i].second;       setEdge(a, b, 0);       mx = max(mx, longestPath(a) * longestPath(b));       setEdge(a, b, 1);     }     cout << mx << endl;   }   