func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   void maxtt(T& t1, T t2) {     t1 = max(t1, t2);   }   template <typename T>   void mintt(T& t1, T t2) {     t1 = min(t1, t2);   }   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  URDL ;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int& x, int y, int mod = 998244353) {     assert(y >= 0);     x += y;     if (x >= mod) x -= mod;     assert(x >= 0 && x < mod);   }   void et(int x = -1) {     printf( %d n , x);     exit(0);   }   long long fastPow(long long x, long long y, int mod = 998244353) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }   vector<int> mp[200135];   int d[200135], tar;   vector<int> dp[200135];   pair<int, int> tmp;   void dfs(int x, int pa) {     d[x] = d[pa] + 1;     dp[x].clear();     for (int c : mp[x])       if (c != pa) {         dfs(c, x);         int v = dp[c][0];         if (dp[x].size() <= 1) {           dp[x].push_back(v);           if (dp[x].size() == 2 && d[dp[x][0]] < d[dp[x][1]]) {             swap(dp[x][0], dp[x][1]);           }         } else if (d[v] > d[dp[x][0]]) {           dp[x][1] = dp[x][0];           dp[x][0] = v;         } else if (d[v] > d[dp[x][1]]) {           dp[x][1] = v;         }       }     if (dp[x].empty()) dp[x].push_back(x);     if (dp[x].size() == 2) {       pair<int, int> key = {d[x], d[dp[x][0]] + d[dp[x][1]]};       if (key > tmp) {         tmp = key;         tar = x;       }     }   }   void fmain(int tid) {     scanf( %d , &n);     for (int i = 0, u, v; i < n - 1; i++) {       scanf( %d%d , &u, &v);       mp[u].push_back(v);       mp[v].push_back(u);     };     tmp = {-1, -1};     dfs(1, 0);     vector<int> ans(4);     ans[0] = dp[tar][0];     ans[2] = dp[tar][1];     tmp = {-1, -1};     dfs(tar, 0);     ans[1] = dp[tar][0];     ans[3] = dp[tar][1];     for (int(i) = 0; (i) < (int)(4); (i)++) printf( %d  , ans[i]);   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }   