func_code_string: #include <bits/stdc++.h>   using namespace std;   int root, n;   vector<int> mp[200605];   int Dfs(int u, int from) {     set<int> s;     for (int i = 0; i < mp[u].size(); i++) {       int v = mp[u][i];       if (v == from) continue;       int tmp = Dfs(v, u);       if (tmp == -1) return -1;       s.insert(tmp + 1);     }     if (s.size() == 0) return 0;     if (s.size() == 1) return *s.begin();     if (s.size() == 2) {       if (from == -1) {         int sum = 0;         for (set<int>::iterator it = s.begin(); it != s.end(); it++) {           sum += *it;         }         return sum;       } else {         root = u;         return -1;       }     }     return -1;   }   int main() {     while (~scanf( %d , &n)) {       for (int i = 1; i <= n; i++) mp[i].clear();       for (int i = 1; i <= n - 1; i++) {         int x, y;         scanf( %d%d , &x, &y);         mp[x].push_back(y);         mp[y].push_back(x);       }       root = 1;       int ans = Dfs(root, -1);       if (ans == -1 && root != 1) ans = Dfs(root, -1);       while (ans % 2 == 0) ans /= 2;       printf( %d n , ans);     }   }   