func_code_string: #include <bits/stdc++.h>   using namespace std;   bool dp[1005][2005];   pair<long long int, long long int> prv[1005][2005];   char val[1005][2005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int n, k;     cin >> n >> k;     string s;     cin >> s;     s =  *  + s;     dp[0][k] = 1;     for (long long int i = 1; i < n; i++) {       for (long long int j = 0; j <= 2 * k; j++) {         if (s[i] ==  W ) {           if (j == 1 && i != n) continue;           if (j >= 1 && dp[i - 1][j - 1]) {             dp[i][j] = 1;             prv[i][j] = {i - 1, j - 1};             val[i][j] =  W ;           }         }         if (s[i] ==  L ) {           if (j == 2 * k - 1 && i != n) continue;           if (j <= 2 * k - 1 && dp[i - 1][j + 1]) {             dp[i][j] = 1;             prv[i][j] = {i - 1, j + 1};             val[i][j] =  L ;           }         }         if (s[i] ==  D ) {           if ((j == 0 || j == 2 * k) && i != n) continue;           if (dp[i - 1][j]) {             dp[i][j] = 1;             prv[i][j] = {i - 1, j};             val[i][j] =  D ;           }         }         if (s[i] ==  ? ) {           if (!(j == 1 && i != n) && j >= 1 && dp[i - 1][j - 1]) {             dp[i][j] = 1;             prv[i][j] = {i - 1, j - 1};             val[i][j] =  W ;           }           if (!(j == 2 * k - 1 && i != n) && j <= 2 * k - 1 && dp[i - 1][j + 1]) {             dp[i][j] = 1;             prv[i][j] = {i - 1, j + 1};             val[i][j] =  L ;           }           if (!((j == 0 || j == 2 * k) && i != n) && dp[i - 1][j]) {             dp[i][j] = 1;             prv[i][j] = {i - 1, j};             val[i][j] =  D ;           }         }       }     }     if (s[n] ==  W ) {       if (!dp[n - 1][2 * k - 1]) return cout <<  NO , 0;       dp[n][2 * k] = 1;       prv[n][2 * k] = {n - 1, 2 * k - 1};       val[n][2 * k] =  W ;     }     if (s[n] ==  L ) {       if (!dp[n - 1][1]) return cout <<  NO , 0;       dp[n][0] = 1;       prv[n][0] = {n - 1, 1};       val[n][0] =  L ;     }     if (s[n] ==  D ) {       return cout <<  NO , 0;     }     if (s[n] ==  ? ) {       if (dp[n - 1][2 * k - 1]) {         dp[n][2 * k] = 1;         prv[n][2 * k] = {n - 1, 2 * k - 1};         val[n][2 * k] =  W ;       }       if (dp[n - 1][1]) {         dp[n][0] = 1;         prv[n][0] = {n - 1, 1};         val[n][0] =  L ;       }     }     if (dp[n][0] || dp[n][2 * k]) {       long long int x, y;       if (dp[n][0])         x = n, y = 0;       else         x = n, y = 2 * k;       string ans;       while (x) {         ans.push_back(val[x][y]);         pair<long long int, long long int> xx = prv[x][y];         x = xx.first, y = xx.second;       }       reverse(ans.begin(), ans.end());       cout << ans;     } else       return cout <<  NO , 0;   }   