func_code_string: #include <bits/stdc++.h>   using namespace std;   class Task {    public:     char invert(char c) {       if (c ==  W ) return  B ;       return  W ;     }     void shift_left(string& s, int k) {       int n = s.length();       string t = s;       for (int i = 0; i < n; i++) t[i] = s[(i + k) % n];       s = t;     }     void shift_left(vector<bool>& v, int k) {       int n = v.size();       auto w = v;       for (int i = 0; i < n; i++) w[i] = v[(i + k) % n];       v = w;     }     void solve() {       int n, k;       cin >> n >> k;       string s;       cin >> s;       vector<bool> unstable(n);       for (int i = 0; i < n; i++) {         if (s[(i + 1) % n] != s[i] && s[(i - 1 + n) % n] != s[i]) {           unstable[i] = true;         }       }       bool all_stable = true;       for (int i = 0; i < n; i++) {         if (unstable[i]) {           all_stable = false;           break;         }       }       if (all_stable) {         cout << s <<   n ;         return;       }       int stable = -1;       for (int i = 0; i < n; i++) {         if (!unstable[i]) {           stable = i;           break;         }       }       if (stable == -1) {         k %= 2;         for (int i = 0; i < n; i++) {           if (k % 2 == 1) {             cout << invert(s[i]);           } else {             cout << s[i];           }         }         cout <<   n ;         return;       }       if (stable == 0) {         stable = n - 1;         while (stable > 0 && !unstable[stable]) stable--;         stable = (stable + 1) % n;         shift_left(s, stable);         shift_left(unstable, stable);       } else {         shift_left(s, stable);         shift_left(unstable, stable);       }       for (int i = 2; i < n;) {         if (unstable[i]) {           int j;           for (j = i; j < n && unstable[j]; j++)             ;           for (int t = i; t < min(i + k, i + (j - i + 1) / 2); t++)             s[t] = s[(i - 1 + n) % n];           for (int t = j - 1; t >= max(j - k, j - (j - i + 1) / 2); t--)             s[t] = s[j % n];           if (k % 2 == 1) {             for (int t = min(i + k, i + (j - i + 1) / 2);                  t < max(j - k, j - (j - i + 1) / 2); t++)               s[t] = invert(s[t]);           }           i = j;         } else {           i++;         }       }       shift_left(s, n - stable);       cout << s <<   n ;     }   };   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     for (int t = 1; t <= T; t++) {       (new Task())->solve();     }     return 0;   }   