func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   int head[N], nxt[N << 1], ver[N << 1], tot;   int n, d[N], out[N], f[N], ji[N], ou[N];   vector<int> v[N];   bool flag;   void add(int x, int y) {     ver[++tot] = y;     nxt[tot] = head[x], head[x] = tot;     out[x]++;   }   void dfs(int x, int fa) {     d[x] = d[fa] + 1;     f[x] = fa;     for (int i = head[x]; i; i = nxt[i]) {       int y = ver[i];       if (y == fa) continue;       dfs(y, x);     }   }   void dfs2(int x, int fa) {     for (int i = head[x]; i; i = nxt[i]) {       int y = ver[i];       if (y == fa) continue;       dfs2(y, x);       if (ou[y]) ji[x] = 1;       if (ji[y]) ou[x] = 1;     }     if (ou[x] && ji[x]) flag = true;   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       add(x, y), add(y, x);     }     int root = 0, minn = 0, maxx = n - 1;     for (int i = 1; i <= n; i++)       if (out[i] >= 2) {         root = i;         break;       }     for (int i = 1; i <= n; i++)       if (out[i] == 1) ou[i] = 1;     dfs2(root, 0);     minn = (flag ? 3 : 1);     dfs(root, 0);     for (int i = 1; i <= n; i++) v[f[i]].push_back(i);     for (int i = 1; i <= n; i++) {       int siz = v[i].size(), cnt = 0;       if (!siz) continue;       for (int j = 0; j < siz; j++) {         int tt = v[i][j];         if (out[tt] == 1) cnt++;       }       if (cnt) maxx -= cnt - 1;     }     printf( %d %d n , minn, maxx);     return 0;   }   