func_code_string: #include <bits/stdc++.h>   using namespace std;   const int nax = 1e2 + 5;   string s;   int n, k;   int bonus[26][26];   const int inf = 1e9;   long long int cnt = 0;   int dp[nax][26][nax];   int solve(int i, int prev, int changes) {     if (i >= s.length()) return 0;     if (dp[i][prev][changes] != -inf) return dp[i][prev][changes];     int ans = -inf;     if (changes < k) {       for (int c = 0; c < 26; c++) {         ans = max(ans,                   bonus[prev][c] +                       solve(i + 1, c, changes + ((c == (s[i] -  a )) ? 0 : 1)));       }     } else       ans =           max(ans, bonus[prev][s[i] -  a ] + solve(i + 1, (s[i] -  a ), changes));     return dp[i][prev][changes] = ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> s >> k >> n;     for (int i = 0; i < nax; i++) {       for (int c = 0; c < 26; c++) {         for (int j = 0; j < nax; j++) {           dp[i][c][j] = -inf;         }       }     }     memset(bonus, 0, sizeof(bonus));     for (int i = 0; i < n; i++) {       char x, y;       int b;       cin >> x >> y >> b;       bonus[x -  a ][y -  a ] = b;     }     int ans = -inf;     if (k > 0) {       for (int c = 0; c < 26; c++) {         ans = max(ans, solve(1, c, ((c == (s[0] -  a )) ? 0 : 1)));       }     } else       ans = max(ans, solve(1, s[0] -  a , 0));     cout << ans <<   n ;   }   