func_code_string: #include <bits/stdc++.h>   const int N = 1010, M = 2010;   int las[M], nxt[M], to[M], cnt;   int l[M], r[M], siz[M], mx[N][N], f[N];   inline void add(int u, int v) {     cnt++;     to[cnt] = v;     nxt[cnt] = las[u];     las[u] = cnt;   }   int n, m;   inline void fmin(int &a, int b) {     if (a > b) a = b;   }   inline void fmax(int &a, int b) {     if (a < b) a = b;   }   void dfs(int now) {     int i;     siz[now] = now != 1;     if (las[now]) l[now] = n, r[now] = 0;     for (i = las[now]; i; i = nxt[i])       dfs(to[i]), siz[now] += siz[to[i]], fmin(l[now], l[to[i]]),           fmax(r[now], r[to[i]]);     fmax(mx[l[now]][r[now]], siz[now]);   }   int main() {     int i, j, x;     scanf( %d , &n);     scanf( %d , &m);     for (i = 2; i <= m; i++) scanf( %d , &x), add(x, i);     for (i = 1; i <= n; i++) scanf( %d , &x), l[x] = r[x] = i;     dfs(1);     cnt = 0;     memset(las, 0, sizeof las);     scanf( %d , &m);     for (i = 2; i <= m; i++) scanf( %d , &x), add(x, i);     for (i = 1; i <= n; i++) scanf( %d , &x), l[x] = r[x] = i;     dfs(1);     for (i = 1; i <= n; i++)       for (j = 1; j <= i; j++)         if (mx[j][i]) fmax(f[i], f[j - 1] + mx[j][i]);     printf( %d n , f[n]);     return 0;   }   