func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   inline T bigmod(T b, T p, T m) {     T ret;     if (p == 0) return 1;     if (p & 1) {       ret = (bigmod(b, p / 2, m) % m);       return ((b % m) * ret * ret) % m;     } else {       ret = (bigmod(b, p / 2, m) % m);       return (ret * ret) % m;     }   }   int dx4[] = {1, -1, 0, 0};   int dy4[] = {0, 0, 1, -1};   int dx6[] = {0, 0, 1, -1, 0, 0};   int dy6[] = {1, -1, 0, 0, 0, 0};   int dz6[] = {0, 0, 0, 0, 1, -1};   int dx8[] = {1, -1, 0, 0, -1, 1, -1, 1};   int dy8[] = {0, 0, 1, -1, 1, 1, -1, -1};   int dkx8[] = {-1, 1, -1, 1, -2, -2, 2, 2};   int dky8[] = {2, 2, -2, -2, 1, -1, 1, -1};   int tc = 1;   const double eps = 1e-9;   const double pi = acos(-1.0);   const long long int mx = 5e5;   const long long int mod = 1e9 + 7;   string str;   int n, k;   int main() {     int i, j, cnt, a, b;     ios::sync_with_stdio(0);     while (cin >> n >> k >> str) {       cnt = 0;       if (k == 2) {         a = 0;         b = 0;         for (i = 0; i < n; i++) {           if (i % 2 == 0) {             if (str[i] ==  B ) a++;             if (str[i] ==  A ) b++;           } else {             if (str[i] ==  A ) a++;             if (str[i] ==  B ) b++;           }         }         if (a < b) {           cout << a <<   n ;           for (i = 0; i < n; i++) cout << ((i % 2 == 0) ?  A  :  B );           cout <<   n ;         } else {           cout << b <<   n ;           for (i = 0; i < n; i++) cout << ((i % 2 != 0) ?  A  :  B );           cout <<   n ;         }         continue;       }       for (i = 0; i < n - 1; i++) {         if (str[i] == str[i + 1] && str[i] == str[i + 2]) {           for (j = 0; j < k; j++) {             if (str[i + 1] != (j +  A )) {               str[i + 1] = (j +  A );               cnt++;               break;             }           }         } else if (str[i] == str[i + 1]) {           for (j = 0; j < k; j++) {             if (i > 0 && str[i - 1] != (j +  A ) && str[i] != (j +  A )) {               str[i] = (j +  A );               cnt++;               break;             } else if (i == 0 && str[i] != (j +  A )) {               str[i] = (j +  A );               cnt++;               break;             }           }         }       }       cout << cnt <<   n ;       cout << str <<   n ;     }     return 0;   }   