func_code_string: #include <bits/stdc++.h>   const int maxn = 1e6 + 5;   const int maxm = 1e5 + 5;   using namespace std;   int rd() {     int x = 0;     char c = getchar();     while (!isdigit(c)) c = getchar();     while (isdigit(c)) x = (x << 3) + (x << 1) + c -  0 , c = getchar();     return x;   }   int n, head[maxn], tot, a, b, c, d, cnt, Node, rk[maxn], len, lst[maxn], top;   int lena, lenb, lenc, lend, mx;   vector<int> vec[maxn];   bitset<maxm> res;   struct node {     int v, nxt;   } e[maxn << 1];   void add(int u, int v) {     e[++tot].v = v;     e[tot].nxt = head[u];     head[u] = tot;   }   void dfs(int u, int y) {     bool flag = true;     for (int i = head[u]; i; i = e[i].nxt) {       int v = e[i].v;       if (v == y) continue;       if (u == 1) ++cnt;       flag = false;       dfs(v, u);     }     if (flag) vec[cnt].push_back(u), rk[u] = cnt;   }   bool check() {     lena = ((int)vec[rk[a]].size());     lenb = ((int)vec[rk[b]].size());     lenc = ((int)vec[rk[c]].size());     lend = ((int)vec[rk[d]].size());     for (int i = max(0, len - lena - lenb); i <= len - 2; i++) {       if (lenc <= i && res[i - lenc]) return true;       if (lend <= i && res[i - lend]) return true;     }     for (int i = max(0, len - lenc - lend); i <= len - 2; i++) {       if (lena <= i && res[i - lena]) return true;       if (lenb <= i && res[i - lenb]) return true;     }     return false;   }   int main() {     n = rd();     a = rd();     b = rd();     c = rd();     d = rd();     for (int i = 2, u; i <= n; i++) {       u = rd();       add(u, i);       add(i, u);     }     dfs(1, 0);     for (int i = 1; i <= cnt; i++) {       Node += ((int)vec[i].size());       if (i != rk[a] && i != rk[b] && i != rk[c] && i != rk[d])         lst[++top] = ((int)vec[i].size()), mx = max(mx, ((int)vec[i].size()));     }     if (Node & 1) {       puts( No );       return 0;     }     len = Node / 2 + 1;     if (rk[a] == rk[b]) {       puts( No );       return 0;     }     if (rk[c] == rk[d]) {       puts( No );       return 0;     }     if (((int)vec[rk[a]].size()) > Node - len ||         ((int)vec[rk[b]].size()) > Node - len ||         ((int)vec[rk[c]].size()) > Node - len ||         ((int)vec[rk[d]].size()) > Node - len || mx > Node - len) {       puts( No );       return 0;     }     res.set(0);     for (int i = 1; i <= top; i++) res |= res << lst[i];     puts(check() ?  Yes  :  No );     return 0;   }   