func_code_string: #include <bits/stdc++.h>   bool QQQQ;   const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};   const int dy[] = {0, 0, -1, 1, 1, -1, 1, -1};   using namespace std;   int ttt = 1;   int n, k, res = 100256, z, cnt;   string s, t, ans;   void solve() {     cin >> n >> k >> s;     ans = s;     for (int i = 0; i < n; i++) ans[i] =  9 ;     for (int i = 0; i < 10; i++) {       t = s;       z = k;       cnt = 0;       for (int j = 0; j < 10; j++) {         for (int l = 0; l < n; l++)           if (z && t[l] -  0  == i + j) {             z--;             t[l] = i +  0 ;             cnt += j;           }         if (j)           for (int l = n - 1; l >= 0; l--)             if (z && t[l] -  0  == i - j) {               z--;               t[l] = i +  0 ;               cnt += j;             }       }       if (cnt < res) res = cnt, ans = t;       if (cnt == res) ans = min(ans, t);     }     cout << res << endl << ans;   }   int main() {     for (int tt = 1; tt <= (ttt = ttt); tt++) {       solve();     }   }   