func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[200001][22];   int p[200001];   int d[200001];   int lca(int u, int v) {     if (d[u] < d[v]) swap(u, v);     int k = d[u] - d[v];     while (k > 0) {       int t = log2(k);       k -= (1 << t);       u = a[u][t];     }     if (u == v) return v;     for (int i = 20; i >= 0; i--) {       if (a[u][i] != a[v][i]) u = a[u][i], v = a[v][i];     }     return p[v];   }   int orobitiasvla(int x, int v) {     while (x > 0) {       int t = log2(x);       v = a[v][t];       x -= (1 << t);     }     return v;   }   int main() {     int n;     cin >> n;     int cnt = 2;     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= 20; j++) a[i][j] = -1;     }     d[1] = 0;     int d1 = 1, d2 = 1;     int mx = 0;     n--;     while (n--) {       int k;       cin >> k;       a[cnt][0] = k;       p[cnt] = k;       d[cnt] = d[k] + 1;       for (int i = 1; i <= 20; i++)         if (d[cnt] >= (1 << i)) a[cnt][i] = orobitiasvla((1 << i) - 1, k);       int y = lca(cnt, d1);       int cost = d[cnt] - d[y] + d[d1] - d[y];       y = lca(cnt, d2);       int cost1 = d[cnt] - d[y] + d[d2] - d[y];       if (cost1 > mx || cost > mx) {         if (cost > cost1)           d2 = cnt;         else           d1 = cnt;         mx = max(cost, cost1);       }       cout << mx <<    ;       cnt++;     }     return 0;   }   