voidwork(){ cin >> n >> m >> s + 1; if (m & 1) return (void) (cout << "NO\n"); for (int k = 0; k < m; ++k) { int f = -1; for (int i = k; i <= n; i += m) { if (!i || s[i] == '?') continue; if (~f && s[i] - '0' != f) return (void) (cout << "NO\n"); f = s[i] - '0'; } if (~f) for (int i = k; i <= n; i += m) s[i] = f + 48; } int sum = 0, v = 0; for (int i = 1; i <= m; ++i) { if (s[i] == '?') ++v; else sum += s[i] == '1' ? -1 : 1; } abs(sum) <= v ? cout << "YES\n" : cout << "NO\n"; }