func_code_string: #include <bits/stdc++.h>   unsigned *G[222222], Ga[222222], Gi[222222];   void add(unsigned i, unsigned j) {     if (Ga[i] == Gi[i]) {       if (!Ga[i])         G[i] = (unsigned *)calloc(Ga[i] = 1, sizeof(unsigned));       else         G[i] = (unsigned *)realloc(G[i], (Ga[i] <<= 1) * sizeof(unsigned));     }     G[i][Gi[i]++] = j;     return;   }   unsigned P[222222], D[222222], IL[222222], mi, ma;   void F(unsigned n, unsigned p, unsigned d) {     if (!d) {       mi = -1;       ma = 0;     }     unsigned i, j;     P[n] = p;     D[n] = d;     if (IL[n]) {       if (mi > d) mi = d;       if (ma < d) ma = d;     }     for (i = Gi[n]; i--;)       if ((j = G[n][i]) != p) F(j, n, d + 1);     return;   }   unsigned L[222222], Li, Q[9], Qi;   int main() {     unsigned n, i, j, k, x;     scanf( %u , &n);     for (k = n; --k;) {       scanf( %u%u , &i, &j);       add(i, j);       add(j, i);     }     for (i = 0; ++i <= n;)       if (Gi[i] == 1) IL[L[Li++] = i] = 1;     F(L[0], 0, 0);     for (i = j = k = 0; ++i <= n;)       if (D[i] > k) k = D[j = i];     F(j, 0, 0);     for (i = j = k = 0; ++i <= n;)       if (D[i] > k) k = D[j = i];     for (i = k >> 1; i--;) j = P[j];     if (k & 1) {       F(i = P[j], j, 0);       if (mi != ma) goto NO;       F(j, i, 0);       if (mi != ma) goto NO;     } else {       for (i = Gi[j]; i--;) {         F(G[j][i], j, 0);         if (mi != ma) goto NO;         for (x = -1; ++x < Qi;)           if (Q[x] == mi) goto tebak;         Q[Qi++] = mi;         if (Qi > 2) goto NO;       tebak:;       }       for (k = 0, x = -1; ++x < Qi;) k += Q[x] + 1;     }     while (!(k & 1)) k >>= 1;     printf( %u n , k);     return 0;   NO:;     printf( -1 n );     return 0;   }   