func_code_string: #include <bits/stdc++.h>   using namespace std;   set<int> Tmp, Trans;   int dp[(500 + 5)][(500 + 5)], n, m, A[(500 + 5)], B[(500 + 5)];   int from[(500 + 5)][(500 + 5)][2], rkA[(500 + 5)], rkB[(500 + 5)];   int trans[(500 + 5)][(500 + 5)];   int getrk(int x) {     int TP = 0;     for (set<int>::iterator i = Trans.begin(); i != Trans.end(); ++i) {       ++TP;       if (*i == x) return TP;     }     return -1;   }   void output(int x, int y) {     if (y == 0 || x == 0) return;     output(from[x][y][0], from[x][y][1]);     cout << B[y] <<    ;   }   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> A[i];       Tmp.insert(A[i]);     }     cin >> m;     for (int i = 1; i <= m; ++i) {       cin >> B[i];       if (Tmp.find(B[i]) != Tmp.end()) Trans.insert(B[i]);     }     for (int i = 1; i <= n; ++i) {       if (Trans.find(A[i]) != Trans.end())         rkA[i] = getrk(A[i]);       else         rkA[i] = 0;     }     for (int i = 1; i <= m; ++i) {       if (Trans.find(B[i]) != Trans.end())         rkB[i] = getrk(B[i]);       else         rkB[i] = 0;     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= (int)Trans.size(); ++j) {         trans[i][j] = max(trans[i - 1][j], (rkA[i] == j) * i);       }     }     for (int x = 1; x <= n; ++x) {       for (int i = 1; i <= m; ++i) {         if (A[x] != B[i]) continue;         for (int k = 0; k < i; ++k) {           if (rkB[k] >= rkB[i]) continue;           if (dp[trans[x - 1][rkB[k]]][k] + 1 > dp[x][i]) {             dp[x][i] = dp[trans[x - 1][rkB[k]]][k] + 1;             from[x][i][0] = trans[x - 1][rkB[k]];             from[x][i][1] = k;           }         }       }     }     int Ans = 0, x, y, z;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (A[i] == B[j] && dp[i][j] > Ans) {           Ans = dp[i][j];           x = i, y = j;         }       }     }     cout << Ans << endl;     if (Ans != 0) output(x, y);   }   