malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long M = 998244353;   long long f[300005];   vector<long long> m1[300005], m2[300005];   int32_t main() {     std::ios::sync_with_stdio(0);     std::cin.tie(0);     ;     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       long long x, y;       cin >> x >> y;       m1[x].push_back(y);       m2[y].push_back(x);     }     f[0] = 1;     for (long long i = 1; i < 300005; i++) f[i] = f[i - 1] * i % M;     long long ans = f[n], d1 = 1, d2 = 1, d3 = 1;     for (long long i = 1; i <= n; i++) d1 = d1 * f[m1[i].size()] % M;     for (long long i = 1; i <= n; i++) d2 = d2 * f[m2[i].size()] % M;     ans = ((ans - d1 - d2) % M + M) % M;     vector<long long> a, b;     for (long long i = 1; i <= n; i++) {       if (m1[i].size() == 0) continue;       sort((m1[i]).begin(), (m1[i]).end());       map<long long, long long> m;       for (long long e : m1[i]) m[e]++;       for (pair<long long, long long> p : m) d3 = d3 * f[p.second] % M;       a.push_back(i);       b.push_back(m1[i][0]);       b.push_back(m1[i].back());     }     for (long long i = 0; i < a.size() - 1; i++)       if (a[i + 1] < a[i]) d3 = 0;     for (long long i = 0; i < b.size() - 1; i++)       if (b[i + 1] < b[i]) d3 = 0;     ans = (ans + d3) % M;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 1e9 + 7;   void print(vector<long long> &a) {     int n = a.size();     for (int i = 0; i < n; i++) {       cout << a[i] <<    ;     }     cout << endl;   }   void print(vector<int> &a) {     int n = a.size();     for (int i = 0; i < n; i++) {       cout << a[i] <<    ;     }     cout << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int te;     te = 1;     while (te--) {       int n;       cin >> n;       vector<int> a(n), sol;       sol.push_back(1);       int sum = 0, coal = 0;       for (int i = 0; i < n; i++) {         cin >> a[i];         sum += a[i];         if (i == 0)           coal += a[i];         else {           if (a[0] >= 2 * a[i]) {             sol.push_back(i + 1);             coal += a[i];           }         }       }       if (2 * coal <= sum) {         cout << 0 << endl;       } else {         cout << sol.size() << endl;         print(sol);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long digit(long long n) {     long long ans = 0;     long long i = 0;     while (n > 0) {       long long tmp = n % 10;       if (tmp != 0) {         ans = ans + (tmp * pow(10, i));         i++;       }       n = n / 10;     }     return ans;   }   int main() {     char arr[8][8];     for (int i = 0; i < 8; i++) cin >> arr[i];     int w = 0, b = 0;     for (int i = 0; i < 8; i++)       for (int j = 0; j < 8; j++) {         if (arr[i][j] >=  A  && arr[i][j] <  a  && arr[i][j] !=  . ) {           char c = arr[i][j];           if (c ==  Q ) w += 9;           if (c ==  R ) w += 5;           if (c ==  B  || c ==  N ) w += 3;           if (c ==  P ) w += 1;         } else if (arr[i][j] >=  a  && arr[i][j] !=  . ) {           char c = arr[i][j];           if (c ==  q ) b += 9;           if (c ==  r ) b += 5;           if (c ==  b  || c ==  n ) b += 3;           if (c ==  p ) b += 1;         }       }     if (b > w)       cout <<  Black ;     else if (w > b)       cout <<  White ;     else       cout <<  Draw ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int n, x, y, b[N], cnt[N], a[N];   bool vis[N];   bool cmp(int i, int j) {     return make_pair(cnt[b[i]], b[i]) > make_pair(cnt[b[j]], b[j]);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int T;     cin >> T;     while (T--) {       cin >> n >> x >> y;       for (int i = 1; i <= n + 1; i++) cnt[i] = 0;       for (int i = 1; i <= n; i++) cin >> b[i], ++cnt[b[i]], vis[i] = 0;       int oth = 0;       for (int i = 1; i <= n + 1; i++)         if (!cnt[i]) {           oth = i;           break;         }       int l = 0, r = n;       while (l < r) {         int mid = (l + r) >> 1, sum = 0;         for (int i = 1; i <= n + 1; i++) sum += max(0, cnt[i] - mid);         if (sum <= x)           r = mid;         else           l = mid + 1;       }       if (2 * (n - x - l) < y - x) {         cout <<  NO n ;         continue;       }       cout <<  YES n ;       int sum = x;       for (int i = 1; i <= n; i++)         if (cnt[b[i]] > l) --cnt[b[i]], a[i] = b[i], vis[i] = 1, --sum;       for (int i = 1; i <= n && sum; i++)         if (!vis[i]) --cnt[b[i]], a[i] = b[i], vis[i] = 1, --sum;       vector<int> id;       for (int i = 1; i <= n; i++)         if (!vis[i]) id.push_back(i);       sort(id.begin(), id.end(), cmp);       vector<int> seq;       for (int i = 0; i < int(id.size()); i++)         if (i == 0 || b[id[i]] != b[id[i - 1]]) seq.push_back(b[id[i]]);       if (!seq.empty()) {         seq.push_back(seq[0]);         seq.erase(seq.begin());       }       for (int i = 0, p = 0; i < int(seq.size()); i++)         for (int j = 1; j <= cnt[seq[i]]; j++) a[id[p++]] = seq[i];       sum = n - x;       for (int i = 1; i <= n; i++)         if (!vis[i] && a[i] == b[i]) a[i] = oth, --sum;       for (int i = 1; i <= n && sum > y - x; i++)         if (!vis[i] && a[i] != oth) a[i] = oth, --sum;       for (int i = 1; i <= n; i++) cout << a[i] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2e5 + 20;   int n, a[MAX];   int main(void) {     int T;     scanf( %d , &T);     while (T--) {       scanf( %d , &n);       bool allBad = 1;       int rl = 0, rr = 0;       scanf( %d , &a[1]);       for (register int i = (2); i <= (n); ++i) {         scanf( %d , &a[i]);         if (abs(a[i] - a[i - 1]) > 1) {           allBad = 0;           rl = i - 1, rr = i;         }       }       if (allBad)         printf( NO n );       else         printf( YES n%d %d n , rl, rr);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<pair<long long, int>> xs(n);     for (int i = 0; i < xs.size(); ++i) {       cin >> xs[i].first;       xs[i].second = i + 1;     }     sort(xs.begin(), xs.end());     int k;     cin >> k;     vector<long long> sums1(n), sums2(n);     int qk = 2;     long long sumsl = 0;     int jl = 0;     long long cur_sum = 0;     long long min_sum = -1;     int min_pos = -1;     for (int i = 1; i < k; ++i) {       sumsl += xs[i].first - xs[0].first;     }     for (int i = 1; i < xs.size(); ++i) {       sums1[i] = sums1[i - 1] + (xs[i].first - xs[i - 1].first) * (qk - 1);       if (qk <= k) {         qk++;         cur_sum += sums1[i];       } else {         sums1[i] -= xs[i].first - xs[jl].first;         ++jl;         cur_sum = cur_sum + sums1[i] - sumsl;         sumsl = sumsl - (xs[jl].first - xs[jl - 1].first) * (k - 1) +                 (xs[i].first - xs[jl].first);       }       if (qk > k) {         if (min_sum == -1 || cur_sum < min_sum) {           min_sum = cur_sum;           min_pos = i;         }       }     }     for (int i = 0; i < k; ++i) {       cout << xs[min_pos - i].second <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 505;   int a[maxn][maxn], b[maxn][maxn];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , &a[i][j]);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , &b[i][j]);     bool flag = 1;     for (int i = 1; i <= n; i++) {       int cnt = 0;       for (int j = 1; j <= m; j++)         if (a[i][j] != b[i][j]) cnt++;       if (cnt % 2) flag = 0;     }     for (int j = 1; j <= m; j++) {       int cnt = 0;       for (int i = 1; i <= n; i++)         if (a[i][j] != b[i][j]) cnt++;       if (cnt % 2) flag = 0;     }     if (flag)       printf( Yes n );     else       printf( No n );   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2,unroll-loops )   using namespace std;   const int mod = 1000000007, N = 17;   int n, x, ans;   int A[1 << N], B[N + 1][1 << N], C[N + 1][1 << N], D[1 << N], E[1 << N];   long long fib[1 << N];   inline void fix(int& x) {     if (x >= mod) x -= mod;     if (x < 0) x += mod;   }   void SOS1(int* A, int inv) {     for (int j = 0; j < N; j++)       for (int mask = 0; mask < (1 << N); mask++)         if (mask & (1 << j)) fix(A[mask] += inv * A[mask ^ (1 << j)]);   }   void SOS2(int* A, int inv) {     for (int j = 0; j < N; j++)       for (int mask = 0; mask < (1 << N); mask++)         if (mask & (1 << j)) fix(A[mask ^ (1 << j)] += inv * A[mask]);   }   void XOR(int* A, bool inv) {     for (int j = 0; j < N; j++)       for (int mask = 0; mask < (1 << N); mask++)         if (mask & (1 << j)) {           int a = A[mask ^ (1 << j)], b = A[mask];           fix(A[mask ^ (1 << j)] = a + b);           fix(A[mask] = a - b);         }     if (inv) {       long long tmp = 1, inv2 = (mod + 1) / 2;       for (int i = 0; i < N; i++) tmp = tmp * inv2 % mod;       for (int mask = 0; mask < (1 << N); mask++) A[mask] = A[mask] * tmp % mod;     }   }   int main() {     fib[1] = 1;     for (int i = 2; i < (1 << N); i++) fib[i] = (fib[i - 1] + fib[i - 2]) % mod;     scanf( %d , &n);     while (n--) scanf( %d , &x), A[x]++;     for (int i = 0; i <= N; i++) {       for (int mask = 0; mask < (1 << N); mask++)         if (__builtin_popcount(mask) == i) B[i][mask] = A[mask];       SOS1(B[i], +1);     }     for (int i = 0; i <= N; i++)       for (int j = 0; i + j <= N; j++) {         for (int mask = 0; mask < (1 << N); mask++)           C[i + j][mask] = (C[i + j][mask] + 1ll * B[i][mask] * B[j][mask]) % mod;       }     for (int i = 0; i <= N; i++) SOS1(C[i], -1);     for (int mask = 0; mask < (1 << N); mask++)       D[mask] = C[__builtin_popcount(mask)][mask] * fib[mask] % mod;     for (int mask = 0; mask < (1 << N); mask++) {       E[mask] = A[mask];       A[mask] = A[mask] * fib[mask] % mod;     }     XOR(E, 0);     for (int mask = 0; mask < (1 << N); mask++)       E[mask] = 1ll * E[mask] * E[mask] % mod;     XOR(E, 1);     for (int mask = 0; mask < (1 << N); mask++)       E[mask] = E[mask] * fib[mask] % mod;     SOS2(A, +1);     SOS2(D, +1);     SOS2(E, +1);     for (int mask = 0; mask < (1 << N); mask++)       A[mask] = 1ll * A[mask] * D[mask] % mod * E[mask] % mod;     SOS2(A, -1);     for (int i = 0; i < N; i++) fix(ans += A[1 << i]);     if (ans < 0) ans += mod;     printf( %d n , ans);     return 0;   }
#include <iostream>   #include <algorithm>   #include <string>   #include <vector>   #include <queue>   #include <stack>   #include <set>   #include <map>   #include <cstdio>   #include <cstdlib>   #include <cstring>   #include <cmath>   #include <cctype>   #include <functional>   using namespace std;      typedef long long ll;      const int MAXN = 1005;   const double EPS = 1e-8;   const int INF = 1e9+7;      int s[MAXN];   set<int> st;      int main(){    int t;    scanf( %d , &t);    while(t--){     int n; scanf( %d , &n);     st.clear();     for (int i = 0; i < n;i++){      scanf( %d , &s[i]);     }     for (int i = 0; i < n;i++){      for (int j = i + 1; j < n;j++){       st.insert(s[j] - s[i]);      }     }     printf( %d n ,st.size());    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;      const int MAXN = 3e5 + 10;      int N;   int A[MAXN];   int B[MAXN];      int ans[MAXN];      bool is_permutation() {     sort(B + 1, B + 1 + N);     for (int i = 1; i <= N; ++i)       if (B[i] != i)         return false;     return true;   }      void solve(bool has_one) {     for (int i = 1; i <= N; ++i) ans[i] = 0;        if (!has_one) return;        map<int, int> freq;     for (int i = 1; i <= N; ++i) ++freq[A[i]];        int L = 1;     int R = N;     int cur;     for (cur = 1; cur <= N; ++cur) {       if (freq[cur] != 1) break;       if (A[L] == cur) ++L;       else if (A[R] == cur) --R;       else break;     }        if (is_permutation()) ans[1] = 1;        if (L > R) {       for (int k = 2; k <= N; ++k) ans[k] = 1;       return;     }     int len = R - L + 1;     if (!freq[cur]) ++len;     for (int k = len; k <= N; ++k) ans[k] = 1;   }      int main() {     cin.sync_with_stdio(false);     cin.tie(0);     int t; cin >> t;     while (t--) {       cin >> N;       bool has_one = false;       for (int i = 1; i <= N; ++i) {         cin >> A[i];         B[i] = A[i];         if (A[i] == 1) has_one = true;       }       solve(has_one);       for (int i = 1; i <= N; ++i) cout << ans[i];       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, sum, ans, a;   int main() {     scanf( %d %d , &n, &x);     for (int i = 0; i < n; i++) {       scanf( %d , &a);       sum += a;     }     sum = abs(sum);     ans = (sum / x) + (sum % x != 0);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 200411;   vector<int> root;   int now, n, s[N], p[N], toghe;   void dfs(int v) {     if (s[v]) {       if (s[v] == now) root.push_back(v);       return;     }     s[v] = now;     dfs(p[v]);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &p[i]);       if (p[i] == i) toghe = i;     }     for (int i = 1; i <= n; i++) {       now = i;       if (!s[i]) dfs(i);     }     cout << root.size() - (toghe > 0) << endl;     if (toghe == 0) toghe = root[0];     for (int i = 0; i < root.size(); i++) p[root[i]] = toghe;     for (int i = 1; i <= n; i++) printf( %d  , p[i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, y;     cin >> n;     vector<vector<int> > g(n);     for (int i = 0; i < n - 1; i++) {       cin >> x >> y;       x--;       y--;       g[x].push_back(y);       g[y].push_back(x);     }     int res = 0;     for (int i = 0; i < n; i++) {       if (g[i].size() <= 1) res++;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<long long int> dis(n);     vector<long long int> ans(n);     vector<bool> vis(n, 0);     long long int acc = 0;     for (long int i = 0; i < n; i++) {       cin >> dis[i];       acc += dis[i];     }     vector<vector<int>> edg(n);     for (long int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       edg[a].push_back(b);       edg[b].push_back(a);     }     vector<vector<int>> p(3);     p[0].push_back(0);     p[1].push_back(0);     p[2].push_back(0);     vis[0] = 1;     int i = 0;     long long int x = 0;     while (p[0].size() < n) {       for (long int j = 0; j < edg[p[0][i]].size(); j++) {         if (!vis[edg[p[0][i]][j]]) {           p[0].push_back(edg[p[0][i]][j]);           p[1].push_back(p[0][i]);           p[2].push_back(p[2][i] + 1);           x += ((long long int)(p[2][i] + 1)) * (dis[edg[p[0][i]][j]]);           vis[edg[p[0][i]][j]] = 1;         }       }       i++;     }     for (int j = n - 1; j > 0; j--) {       dis[p[1][j]] += dis[p[0][j]];     }     ans[0] = x;     for (long int i = 0; i < n; i++) {       if (i == 0) continue;       ans[p[0][i]] = acc + ans[p[1][i]] - 2 * dis[p[0][i]];     }     cout << *max_element(ans.begin(), ans.end());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   const long long mod = 1e9 + 7;   template <typename T>   inline T gcd(T a, T b) {     return !b ? a : gcd(b, a % b);   }   template <typename T>   inline T q_pow(T a, T x) {     T ans = 1, tmp = a;     while (x) {       if (x & 1) (ans *= tmp) %= mod;       (tmp *= tmp) %= mod;       x >>= 1;     }     return ans;   }   template <typename T>   inline void re(T &N) {     int f = 1;     char c;     while ((c = getchar()) <  0  || c >  9 )       if (c ==  - ) f = -1;     N = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) N = N * 10 + c -  0 ;     N *= f;   }   int m, n, t = 1, st, en, k;   inline int getmask(string &s) {     int ans = 0;     for (int i = 0; i < s.size(); i++)       if (s[i] -  0 ) ans |= 1 << i;     return ans;   }   string a, b;   int p[110];   int d[2][1 << 20];   int main() {     ios::sync_with_stdio(0);     cin >> n >> m >> k;     cin >> a >> b;     for (int i = 0; i < k; i++) p[i] = i;     for (int i = 0; i < 1 << k; i++) {       d[0][i] = 1e9;       d[1][i] = -1e9;     }     d[0][getmask(a)] = d[1][getmask(b)] = 0;     for (int i = 1; i <= n; i++) {       int x, y;       cin >> x >> y;       swap(p[x - 1], p[y - 1]);       string _a(k,  0 ), _b(k,  0 );       for (int j = 0; j < k; j++) {         _a[p[j]] = a[j];         _b[p[j]] = b[j];       }       d[0][getmask(_a)] = min(d[0][getmask(_a)], i);       d[1][getmask(_b)] = max(d[1][getmask(_b)], i);     }     pair<int, pair<int, int> > ans = {0, {1, m}};     int ca = count(a.begin(), a.end(),  1 ), cb = count(b.begin(), b.end(),  1 );     for (int i = (1 << k) - 1; ~i; i--) {       if (d[1][i] - d[0][i] >= m)         ans = max(ans, {k - ca - cb + 2 * __builtin_popcount(i),                         {d[0][i] + 1, d[1][i]}});       for (int j = 0; j < k; j++)         if (i & (1 << j)) {           d[0][i ^ (1 << j)] = min(d[0][i ^ (1 << j)], d[0][i]);           d[1][i ^ (1 << j)] = max(d[1][i ^ (1 << j)], d[1][i]);         }     }     cout << ans.first <<   n           << ans.second.first <<     << ans.second.second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<long long> > mul(vector<vector<long long> > a,                                  vector<vector<long long> > b) {     vector<vector<long long> > c;     c.resize(a.size());     for (int i = 0; i < c.size(); i++) c[i].resize(b[0].size(), 0);     for (int i = 0; i < c.size(); i++)       for (int j = 0; j < c[i].size(); j++)         for (int k = 0; k < b.size(); k++)           c[i][j] = (c[i][j] + a[i][k] * b[k][j]);     return c;   }   vector<vector<long long> > Def;   vector<vector<long long> > bpow(vector<vector<long long> > a, long long st) {     if (st == 0) return Def;     if (st == 1) return a;     vector<vector<long long> > b = bpow(a, st >> 1);     b = mul(b, b);     if (st & 1) b = mul(a, b);     return b;   }   long long AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MOD = 1e9 + 993;   long long myrand() {     long long ZR = (XR * AR + YR * BR + CR) % MOD;     XR = YR;     YR = ZR;     return ZR;   }   long long sqr(long long x) { return x * x; }   const long long llinf = 2e18;   const long double EPS = 1e-9;   const long double PI = atan2(0, -1);   const int maxn = 2e5 + 100, inf = 1e9 + 100, mod = 1e9 + 7;   int n, W, H;   vector<int> g[maxn];   queue<int> w[maxn];   queue<int> def[maxn];   int answer[maxn];   pair<int, pair<int, int> > danc[maxn];   vector<pair<pair<int, int>, int> > q;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> W >> H;     for (int i = 0; i < n; i++) {       cin >> danc[i].first >> danc[i].second.first >> danc[i].second.second;       if (danc[i].first == 1)         q.push_back(make_pair(danc[i].second, i));       else         g[danc[i].second.second - danc[i].second.first + H].push_back(i);       answer[i] = i;     }     for (int i = 0; i < maxn; i++)       if (!g[i].empty()) {         vector<pair<int, int> > s(g[i].size());         for (int j = 0; j < g[i].size(); j++)           s[j] = make_pair(danc[g[i][j]].second.first, g[i][j]);         sort(s.begin(), s.end());         reverse(s.begin(), s.end());         for (int j = 0; j < s.size(); j++)           w[i].push(s[j].second), def[i].push(s[j].second);       }     sort(q.begin(), q.end());     for (int i = 0; i < q.size(); i++) {       int id = q[i].first.second - q[i].first.first + H;       if (id < 0 || g[id].empty()) continue;       answer[w[id].front()] = q[i].second;       w[id].pop();       w[id].push(q[i].second);     }     for (int i = 0; i < maxn; i++)       if (!g[i].empty())         for (int j = 0; j < g[i].size(); j++)           answer[w[i].front()] = def[i].front(), def[i].pop(), w[i].pop();     for (int i = 0; i < n; i++) {       int x = answer[i];       if (danc[x].first == 1)         cout << danc[x].second.first <<     << H <<   n ;       else         cout << W <<     << danc[x].second.first <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int n;     cin >> n;     long int a[n];     for (long int i = 0; i < n; i++) cin >> a[i];     long int b[101] = {0};     for (long int i = 0; i < n; i++) b[a[i]]++;     long int c[101] = {0};     long int ans = 0;     for (long int i = 1; i <= 100; i++) {       if (c[i] == 0 && b[i] > 0) {         ans++;         for (long int j = i; j < 101; j += i) c[j] = 1;       }       bool pp = 0;       for (long int j = 1; j < 101; j++) {         if (b[j] >= 1 && c[j] == 0) pp = 1;       }       if (pp == 0) break;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x;     cin >> n >> x;     if (n == 3) {       cout <<  >vv  << endl <<  ^<.  << endl <<  ^.<  << endl;       cout << 1 <<     << 3;     }     if (n == 5) {       cout <<  >...v  << endl            <<  v.<..  << endl            <<  ..^..  << endl            <<  >....  << endl            <<  ..^.<  << endl;       cout << 1 <<     << 1;     }     if (n == 100) {       cout <<  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.>.>.>.>.>.>.>.>                 .>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.v             << endl;       for (int i = 0; i < 49; i++) {         cout <<  ^v.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<<<<<<<<<<<                   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<               << endl;         cout <<  ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.>.>.>.>.>.>.>                   .>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.v               << endl;       }       cout <<  ^<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<.<<<<<<<<<<<<<                 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<             << endl;       cout << 1 <<     << 1;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void out(T x) {     cout << x << endl;     exit(0);   }   using ll = long long;   const ll mod = 1e9 + 7;   const int maxn = 1e6 + 5;   int n, k;   string S;   bool test(int start) {     string s = S;     int cur = 0;     for (int i = 0; i < start; i++) {       if (s[i] ==  ?  || s[i] ==  Y ) {         s[i] =  Y ;         cur = 0;       } else if (s[i] ==  N ) {         cur++;       }       if (cur > k) return false;     }     if (start > 0 && s[start - 1] ==  N ) {       return false;     }     for (int i = start; i < start + k; i++) {       if (s[i] ==  Y ) {         return false;       }     }     if (start + k < n && s[start + k] ==  N ) {       return false;     }     cur = 0;     for (int i = start + k; i < n; i++) {       if (s[i] ==  ?  || s[i] ==  Y ) {         s[i] =  Y ;         cur = 0;       } else if (s[i] ==  N ) {         cur++;       }       if (cur > k) return false;     }     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     cin >> S;     for (int i = 0; i + k - 1 < n; i++) {       if (test(i)) {         out( YES );       }     }     cout <<  NO n ;     return 0;   }