func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXK = 21;   long long dp[(1 << MAXK)];   int n, m;   string s;   long long d[MAXK][MAXK];   long long solve(int mask) {     if (mask == ((1 << m) - 1)) return 0ll;     long long &ret = dp[mask];     if (ret != -1) return ret;     ret = 1e10;     long long cost = __builtin_popcount(mask);     for (int i = 0; i < m; ++i) {       if ((mask & (1 << i))) continue;       long long now = solve(mask | (1 << i));       for (int j = 0; j < m; ++j) {         if (i == j) continue;         if ((mask & (1 << j)))           now += cost * d[i][j];         else           now -= cost * d[i][j];       }       ret = min(ret, now);     }     return ret;   }   int main() {     memset(dp, -1, sizeof(dp));     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n >> m;     cin >> s;     for (int i = 0; i < n - 1; ++i) {       int a = s[i] -  a ;       int b = s[i + 1] -  a ;       d[a][b]++;       if (a != b) d[b][a]++;     }     return cout << solve(0) <<   n , 0;   }   