func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   queue<int> q;   vector<int> v[1999];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 2; i <= n; i++) {       int a;       cin >> a;       v[a].push_back(i);     }     q.push(1);     int ok = 1;     while (!q.empty()) {       int cou = 0, sep = 0;       int k = q.front();       q.pop();       for (auto x : v[k]) {         sep = 1;         if (v[x].empty()) {           cou++;         }         q.push(x);       }       if (sep) {         if (cou < 3) {           ok = 0;           break;         }       }     }     if (ok) {       cout <<  YES ;     } else {       cout <<  NO ;     }   }   