func_code_string: #include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const int INF = 1 << 30;   const long long LINF = 1ll << 60;   const int BUFFER_SZ = 1 << 15;   const int MOD = 1000 * 1000 * 1000 + 7;   char BUFFER[BUFFER_SZ];   int gi() {     int x;     scanf( %d , &x);     return x;   }   double gd() {     double x;     scanf( %lf , &x);     return x;   }   long long gll() {     long long x;     cin >> x;     return x;   }   vector<int> gvi(int n) {     vector<int> a;     while (n-- > 0) a.push_back(gi());     return a;   }   string gs() {     scanf( %s , BUFFER);     return string(BUFFER);   }   template <class T>   void print(vector<T> &x, string format) {     format +=  %c ;     for (int i = 0; i < x.size(); ++i)       printf(format.c_str(), x[i], i + 1 == x.size() ?   n  :    );   }   int c_ins, c_del, c_rep, c_swp;   int dp[4444][4444];   int main() {     int c_ins = gi();     int c_del = gi();     int c_rep = gi();     int c_swp = gi();     string a = gs();     string b = gs();     int prev[256];     memset((prev), (0), sizeof(prev));     for (int i = 0; i <= a.size(); ++i) {       int last = 0;       for (int j = 0; j <= b.size(); ++j) {         if (!i)           dp[i][j] = j * c_ins;         else if (!j)           dp[i][j] = i * c_del;         else {           dp[i][j] = 1 << 30;           int ii = j > 0 ? prev[b[j - 1]] : 0;           int jj = last;           if (a[i - 1] == b[j - 1]) {             dp[i][j] = dp[i - 1][j - 1];             last = j;           }           int v = min(min(dp[i - 1][j] + c_del, dp[i][j - 1] + c_ins),                       dp[i - 1][j - 1] + c_rep);           if (i && j && ii && jj) {             v = min(v, dp[ii - 1][jj - 1] + c_swp + c_del * (i - ii - 1) +                            c_ins * (j - jj - 1));           }           dp[i][j] = min(dp[i][j], v);         }       }       if (i > 0) {         prev[a[i - 1]] = i;       }     }     printf( %d n , dp[a.size()][b.size()]);     return 0;   }   