func_code_string: #include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int MAXN = 1000;   const int MAXK = 1000;   int n, K;   char s[MAXN + 1];   int act[MAXN + 1][2 * MAXK + 1];   char ret[MAXN + 1];   void run() {     scanf( %d%d%s , &n, &K, s);     memset(act, -1, sizeof(act));     act[0][MAXK] = 1;     for (int i = (0); i < (n); ++i) {       int mxb = min(i, K - 1);       for (int k = (-mxb); k <= (+mxb); ++k)         if (act[i][MAXK + k] != -1) {           for (int a = (-1); a <= (+1); ++a) {             if (s[i] ==  L  && a != -1) continue;             if (s[i] ==  D  && a != 0) continue;             if (s[i] ==  W  && a != +1) continue;             act[i + 1][MAXK + k + a] = a + 1;           }         }     }     for (int k = -K; k <= +K; k += 2 * K)       if (act[n][MAXK + k] != -1) {         for (int i = n - 1; i >= 0; --i) {           ret[i] =  LDW [act[i + 1][MAXK + k]];           k -= act[i + 1][MAXK + k] - 1;         }         ret[n] =   0 ;         printf( %s , ret);         return;       }     printf( NO n );   }   int main() {     run();     return 0;   }   