func_code_string: #include <bits/stdc++.h>   using namespace std;   int u, v;   const int maxn = 5e3 + 10;   vector<long long> G[maxn];   bool visited[maxn];   long long dp[maxn];   vector<long long> vc[maxn];   bool mark[maxn];   long long n;   vector<long long> ans;   void dfs(int x) {     visited[x] = 1;     for (int i = 0; i != G[x].size(); i++) {       if (visited[G[x][i]] == 0) {         dfs(G[x][i]);         dp[x] += 1 + dp[G[x][i]];       }     }   }   void main_dfs(int x) {     visited[x] = 1;     memset(mark, 0, sizeof(mark));     for (int i = 0; i < G[x].size(); i++) {       if (visited[G[x][i]] == 0) {         int g = vc[x].size();         for (int j = 0; j < g; j++) {           if (vc[x][j] + dp[G[x][i]] + 1 != n - 1 &&               mark[vc[x][j] + dp[G[x][i]] + 1] == 0) {             vc[x].push_back(vc[x][j] + dp[G[x][i]] + 1);             mark[vc[x][j] + dp[G[x][i]] + 1] = 1;           }         }         if (dp[G[x][i]] + 1 != n - 1 && mark[dp[G[x][i]] + 1] == 0) {           vc[x].push_back(dp[G[x][i]] + 1);           mark[dp[G[x][i]] + 1] = 1;         }       } else {         int g = vc[x].size();         for (int j = 0; j < g; j++) {           if (mark[vc[x][j] + n - 1 - dp[x]] == 0)             if (vc[x][j] + n - 1 - dp[x] != 0 &&                 vc[x][j] + n - 1 - dp[x] != n - 1) {               vc[x].push_back(vc[x][j] + n - dp[x] - 1);               mark[vc[x][j] + n - dp[x] - 1] = 1;             }         }         if (mark[n - dp[x] - 1] == 0)           if (n - dp[x] - 1 != 0 && n - dp[x] - 1 != n - 1) {             vc[x].push_back(n - dp[x] - 1);             mark[n - dp[x] - 1] = 1;           }       }     }     for (int i = 0; i != G[x].size(); i++) {       if (visited[G[x][i]] == 0) main_dfs(G[x][i]);     }   }   bool mk[maxn];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n;     for (int i = 0; i != n - 1; i++) {       cin >> u >> v;       G[u].push_back(v);       G[v].push_back(u);     }     dfs(1);     fill(visited, visited + maxn, 0);     main_dfs(1);     for (int i = 1; i != n + 1; i++) {       for (int j = 0; j != vc[i].size(); j++) {         if (find(ans.begin(), ans.end(), vc[i][j]) == ans.end()) {           ans.push_back(vc[i][j]);           if (n - 1 - vc[i][j] != vc[i][j]) ans.push_back(n - 1 - vc[i][j]);         }       }     }     sort(ans.begin(), ans.end());     cout << ans.size() << endl;     for (int i = 0; i != ans.size(); i++) {       cout << ans[i] <<     << n - 1 - ans[i] << endl;     }   }   