func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5 * 100 + 10;   int n, dp1[N][N], dp2[N][N], k, par[N][N];   string s;   void printpath(int i, int j) {     if (j == 0) return;     printpath(i - par[i][j], j - 1);     if (j > 1) cout <<  + ;     if (par[i][j] == 1)       cout << s[i - 1];     else {       for (int l = i - par[i][j]; l <= i - (((par[i][j] + 1) / 2) + 1); l++)         cout << s[l];       if (par[i][j] % 2 == 1) cout << s[i - (((par[i][j] + 1) / 2) + 1) + 1];       for (int l = i - (((par[i][j] + 1) / 2) + 1); l >= i - par[i][j]; l--)         cout << s[l];     }   }   int main() {     cin >> s >> k;     n = s.size();     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++)         for (int l = i; l <= ((j - i) / 2) + i; l++)           if (s[l] != s[j - l + i]) dp1[i][j]++;     for (int i = 0; i < N; i++) fill(dp2[i], dp2[i] + N, INT_MAX);     dp2[0][0] = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < k; j++)         for (int len = 1; len <= n; len++)           if (dp2[i][j] != INT_MAX)             if (dp2[i + len][j + 1] >= dp2[i][j] + dp1[i][i + len - 1])               dp2[i + len][j + 1] = dp2[i][j] + dp1[i][i + len - 1],                                par[i + len][j + 1] = len;     int ans = INT_MAX, r;     for (int i = 1; i <= k; i++)       if (dp2[n][i] < ans) ans = dp2[n][i], r = i;     cout << ans << endl;     printpath(n, r);     return 0;   }   