func_code_string: #include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const double PI = acos(-1.0);   const long long int mod = 1e9 + 7;   const int MAXN = 1e6 + 5;   void cp() {     int n, k;     string s;     cin >> n >> k >> s;     vector<pair<int, int> > group;     int l = 0, r = 0;     while (l < n) {       while (l < n && s[l] ==  L ) l++;       if (l >= n) break;       r = l;       while (r + 1 < n && s[r + 1] ==  W ) r++;       group.push_back({l, r});       l = r + 1;     }     vector<pair<int, int> > diff;     for (int i = 0; i < ((int)group.size()) - 1; i++) {       int d = group[i + 1].first - group[i].second - 1;       diff.push_back({d, i});     }     sort(diff.rbegin(), diff.rend());     while (k > 0 && !diff.empty()) {       pair<int, int> last = diff.back();       diff.pop_back();       int can = min(last.first, k);       k -= can;       for (int i = group[last.second].second + 1;            i < group[last.second + 1].first && can > 0; i++, can--)         s[i] =  W ;     }     if (k > 0) {       int pos = -2;       for (int i = 0; i < n; i++)         if (s[i] ==  W ) pos = i;       pos++;       if (pos >= 0 && pos < n)         for (int i = pos; i < n && k > 0; i++)           if (s[i] ==  L ) s[i] =  W , k--;     }     if (k > 0 && s[0] ==  L ) {       int pos = n;       for (int i = 0; i < n && pos == n; i++)         if (s[i] ==  W ) pos = i;       pos--;       if (pos >= 0) {         for (int i = pos; i >= 0 && k > 0; i--)           if (s[i] ==  L ) s[i] =  W , k--;       }     }     int score = 0;     for (int i = 0; i < n; i++) {       score += (s[i] ==  W );       if (i - 1 >= 0 && s[i] ==  W  && s[i - 1] ==  W ) score++;     }     cout << score <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int t;     t = 1;     cin >> t;     while (t--) {       cp();     }     return 0;   }   