func_code_string: #include <bits/stdc++.h>   using namespace std;   long long Ins, Del, Rep, Exc;   string A;   string B;   int lenA, lenB;   long long DP[4001][4001];   int posA[4001][26];   int posB[4001][26];   int main() {     ios::sync_with_stdio(false);     while (cin >> Ins >> Del >> Rep >> Exc) {       cin >> A >> B;       A =  .  + A;       B =  .  + B;       lenA = A.length() - 1;       lenB = B.length() - 1;       memset(posA, 0xff, sizeof(posA));       memset(posB, 0xff, sizeof(posB));       for (int i = 0; i < 26; i++) {         for (int j = 1; j <= lenB; j++)           if (B[j] == i +  a )             posB[j][i] = j;           else             posB[j][i] = posB[j - 1][i];         for (int j = 1; j <= lenA; j++)           if (A[j] == i +  a )             posA[j][i] = j;           else             posA[j][i] = posA[j - 1][i];       }       DP[0][0] = 0;       for (int i = 0; i <= lenA; i++)         for (int j = 0; j <= lenB; j++)           if (i + j > 0) {             DP[i][j] = 1000000000000000000LL;             if (A[i] == B[j]) DP[i][j] = DP[i - 1][j - 1];             if (i >= 1 && j >= 1)               DP[i][j] = min(DP[i][j], DP[i - 1][j - 1] + Rep);             if (i >= 1) DP[i][j] = min(DP[i][j], DP[i - 1][j] + Del);             if (j >= 1) DP[i][j] = min(DP[i][j], DP[i][j - 1] + Ins);             int u = posA[i][B[j] -  a ];             int v = posB[j][A[i] -  a ];             if (u > 0 && v > 0 && u < i && v < j)               DP[i][j] = min(DP[i][j], DP[u - 1][v - 1] + Exc +                                            Ins * (j - v - 1) + Del * (i - u - 1));           }       cout << DP[lenA][lenB] << endl;     }     return 0;   }   