func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 25;   string str[maxn];   int a[maxn][maxn];   long long dp[1 << 20];   int mask[26], tot[26], big[26], cnt[26], candi[26];   int Min[maxn];   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> str[i];     }     memset(Min, 0x3f, sizeof(Min));     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> a[i][j];         Min[i] = min(Min[i], a[i][j]);       }     }     for (int i = 0; i < (1 << n); i++) {       int tmp = 0;       for (int j = 0; j < n; j++) {         if (i >> j & 1) tmp += Min[j + 1];       }       dp[i] = tmp;     }     for (int i = 1; i <= m; i++) {       memset(mask, 0, sizeof(mask));       memset(tot, 0, sizeof(tot));       memset(big, 0, sizeof(big));       memset(cnt, 0, sizeof(cnt));       for (int j = 1; j <= n; j++) {         int c = str[j][i - 1] -  a ;         cnt[c]++;         mask[c] |= (1 << (j - 1));         tot[c] += a[j][i];         big[c] = max(big[c], a[j][i]);       }       int idx = 0;       for (int j = 0; j < 26; j++) {         if (cnt[j]) candi[idx++] = j;       }       for (int j = 0; j < (1 << n); j++) {         for (int k = 0; k < idx; k++) {           int u = candi[k];           dp[j | mask[u]] = min(dp[j | mask[u]], dp[j] + (tot[u] - big[u]));         }       }     }     cout << dp[(1 << n) - 1] << endl;     return 0;   }   