malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int m, n;   char a[1005][1005];   int f[1005][1005];   int cc;   int g[1000005];   bool ok[15];   vector<int> s[1000005];   int ki[4] = {0, 0, 1, -1};   int kj[4] = {1, -1, 0, 0};   int main() {     scanf( %d%d , &m, &n);     for (int i = 1; i <= m; i++)       for (int j = 0; j <= n; j++) scanf( %c , &a[i][j]);     int cc = 0;     memset(f, -1, sizeof(f));     for (int i = 1; i <= m; i++)       for (int j = 1; j <= n - 1; j++)         if (a[i][j] ==  .  && a[i][j + 1] ==  .  && f[i][j] == -1 &&             f[i][j + 1] == -1)           cc++, f[i][j] = f[i][j + 1] = cc;     for (int i = 1; i <= m - 1; i++)       for (int j = 1; j <= n; j++)         if (a[i][j] ==  .  && a[i + 1][j] ==  .  && f[i][j] == -1 &&             f[i + 1][j] == -1)           cc++, f[i][j] = f[i + 1][j] = cc;     for (int i = 1; i <= m; i++)       for (int j = 1; j <= n; j++)         if (a[i][j] ==  # )           f[i][j] = -2;         else if (f[i][j] == -1) {           for (int k = 0; k <= 3; k++)             if (f[i + ki[k]][j + kj[k]] >= 0) {               f[i][j] = f[i + ki[k]][j + kj[k]];               break;             }           if (f[i][j] == -1) {             cout << -1;             return 0;           }         }     memset(g, -1, sizeof(g));     for (int i = 1; i <= m; i++)       for (int j = 1; j <= n; j++) {         if (i < m && f[i][j] >= 0 && f[i + 1][j] >= 0 && f[i][j] != f[i + 1][j])           s[f[i][j]].push_back(f[i + 1][j]), s[f[i + 1][j]].push_back(f[i][j]);         if (j < n && f[i][j] >= 0 && f[i][j + 1] >= 0 && f[i][j] != f[i][j + 1])           s[f[i][j]].push_back(f[i][j + 1]), s[f[i][j + 1]].push_back(f[i][j]);       }     for (int u = 1; u <= cc; u++) {       memset(ok, true, sizeof(ok));       for (typeof(s[u].begin()) v = s[u].begin(); v != s[u].end(); v++)         if (g[*v] >= 0) ok[g[*v]] = false;       for (int i = 0; i <= 9; i++)         if (ok[i]) {           g[u] = i;           break;         }     }     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= n; j++)         if (f[i][j] == -2)           printf( # );         else           printf( %d , g[f[i][j]]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void pr1(T a) {     cout << a;     cout <<   n ;   }   template <class T, class T2>   void pr2(T a, T2 b) {     cout << a <<     << b;     cout <<   n ;   }   template <class T, class T2, class T3>   void pr3(T a, T2 b, T3 c) {     cout << a <<     << b <<     << c;     cout <<   n ;   }   template <class T>   void PR(T a, int n) {     for (int i = (int)(0); i < (int)(n); i++) {       if (i) cout <<    ;       cout << a[i];     }     cout <<   n ;   }   bool check(int n, int m, int x, int y) {     return x >= 0 && x < n && y >= 0 && y < m;   }   const long long MAX = 1000000007, MAXL = 1LL << 60, dx[4] = {-1, 0, 1, 0},                   dy[4] = {0, 1, 0, -1};   void Main() {     double d, h, v, e;     cin >> d >> h >> v >> e;     double r = d / 2;     double t = v / (r * r * M_PI);     double ans = h / (t - e);     if (ans < 0)       pr1( NO );     else {       printf( YES n );       printf( %.10f n , ans);     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     Main();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int in(char &c) { return scanf( %c , &c); }   int in(char s[]) { return scanf( %s , s); }   int in(int &x) { return scanf( %d , &x); }   int in(long long &x) { return scanf( %lld , &x); }   int in(double &x) { return scanf( %lf , &x); }   int in(pair<int, int> &p) { return scanf( %d%d , &p.first, &p.second); }   int in(pair<long long, long long> &p) {     return scanf( %lld%lld , &p.first, &p.second);   }   int in(pair<double, double> &p) { return scanf( %lf%lf , &p.first, &p.second); }   int in(long double &a) { return scanf( %Lf , &a); }   int in(int &x, long long &y) { return scanf( %d%lld , &x, &y); }   int in(long long &x, int &y) { return scanf( %lld%d , &x, &y); }   int in(int &x, int &y) { return scanf( %d%d , &x, &y); }   int in(long long &x, long long &y) { return scanf( %lld%lld , &x, &y); }   int in(char s[], int &n) { return scanf( %s%d , s, &n); }   int in(int &n, char s[]) { return scanf( %d%s , &n, s); }   int in(char a[], char b[]) { return scanf( %s%s , a, b); }   int in(double &x, double &y) { return scanf( %lf%lf , &x, &y); }   int in(int &n, char s[], char t[]) { return scanf( %d%s%s , &n, s, t); }   int in(int &x, int &y, int &z) { return scanf( %d%d%d , &x, &y, &z); }   int in(long long &x, long long &y, long long &z) {     return scanf( %lld%lld%lld , &x, &y, &z);   }   int in(double &x, double &y, double &z) {     return scanf( %lf%lf%lf , &x, &y, &z);   }   int in(int &x, int &y, int &z, int &k) {     return scanf( %d%d%d%d , &x, &y, &z, &k);   }   int in(long long &x, long long &y, long long &z, long long &k) {     return scanf( %lld%lld%lld%lld , &x, &y, &z, &k);   }   int in(double &x, double &y, double &z, double &k) {     return scanf( %lf%lf%lf%lf , &x, &y, &z, &k);   }   const int N = 3e5 + 10, M = 1e3 + 10, mod = 1e9 + 7;   const double eps = 1e-6, Pi = acos(-1.0);   vector<int> g[N];   int dep[N], vis[N], op[N], u[N], v[N], In[N], col[N], use[N], Out[N];   queue<int> que;   int topsort(int n) {     for (int i = 1; i <= n; i++) {       if (In[i] == 0) {         que.push(i);       }     }     int cnt = 0;     while (!que.empty()) {       int u = que.front();       que.pop();       dep[u] = ++cnt;       for (auto e : g[u]) {         In[e]--;         if (In[e] == 0) {           que.push(e);         }       }     }     return (n != cnt);   }   int main() {     int T, c = 0, t;     in(T);     t = T;     while (T--) {       c++;       int n, m;       in(n, m);       for (int i = 1; i <= n; i++) In[i] = dep[i] = vis[i] = 0, g[i].clear();       for (int i = 1; i <= m; i++) {         in(op[i], u[i], v[i]);         if (op[i] == 1) {           In[v[i]]++;           g[u[i]].push_back(v[i]);         }       }       if (topsort(n)) {         printf( NO n );         continue;       }       printf( YES n );       for (int i = 1; i <= m; i++) {         if (op[i] == 0) {           if (dep[u[i]] > dep[v[i]]) swap(u[i], v[i]);         }         printf( %d %d n , u[i], v[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int par[4000];   long long int sub[4000];   long long int n;   vector<long long int> adj[4000];   long long int dp[4000][4000];   long long int conec[4000][4000];   void dfsc(long long int node, long long int cur, long long int dir,             long long int prev) {     conec[node][cur] = dir;     long long int ele = adj[cur].size();     for (long long int i = 0; i <= ele - 1; i++) {       if (adj[cur][i] != prev) {         dfsc(node, adj[cur][i], dir, cur);       }     }   }   void dfss(long long int node) {     sub[node] = 1;     long long int ele = adj[node].size();     for (long long int i = 0; i <= ele - 1; i++) {       if (par[node] != adj[node][i]) {         par[adj[node][i]] = node;         dfss(adj[node][i]);         sub[node] += sub[adj[node][i]];       }     }   }   long long int depth(long long int now, long long int pr) {     if (adj[now].size() == 1) return 0;     long long int ret = 0;     for (long long int i = 0; i <= adj[now].size() - 1; i++) {       if (adj[now][i] != pr) ret = max(ret, depth(adj[now][i], now));     }     return 1 + ret;   }   void dfs(long long int start, long long int fin) {     if (dp[start][fin] != -1) return;     if (par[start] == fin) {       dp[start][fin] = sub[start] * (n - sub[start]);       return;     }     if (par[fin] == start) {       dp[start][fin] = sub[fin] * (n - sub[fin]);       return;     }     dfs(conec[start][fin], fin);     dfs(start, conec[fin][start]);     long long int lef, rig;     if (par[start] == conec[start][fin])       lef = sub[start];     else       lef = n - sub[conec[start][fin]];     if (par[fin] == conec[fin][start])       rig = sub[fin];     else       rig = n - sub[conec[fin][start]];     dp[start][fin] =         lef * rig + max(dp[start][conec[fin][start]], dp[conec[start][fin]][fin]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long int cur, TESTS, q, a, m, s, b, r, c, k, p, w, d, x, i, j, y, z, xs,         ys, t;     TESTS = 1;     memset(par, -1, sizeof(par));     memset(dp, -1, sizeof(dp));     while (TESTS--) {       cin >> n;       for (long long int i = 0; i <= n - 2; i++) {         cin >> a >> b;         a--;         b--;         adj[a].push_back(b);         adj[b].push_back(a);       }       dfss(0);       for (long long int i = 0; i <= n - 1; i++) {         long long int ele = adj[i].size();         for (long long int j = 0; j <= ele - 1; j++) {           dfsc(i, adj[i][j], adj[i][j], i);         }       }       for (long long int i = 0; i <= n - 1; i++) {         for (long long int j = 0; j <= n - 1; j++) {           if (i == j) continue;           dfs(i, j);         }       }       long long int ans = 0;       for (long long int i = 0; i <= n - 1; i++)         for (long long int j = 0; j <= n - 1; j++) ans = max(ans, dp[i][j]);       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   struct intmod {     long long val;     intmod(long long _val = 1) {       val = _val % MOD;       if (val < 0) val += MOD;     }     bool operator!=(intmod rhs) const { return val != rhs.val; }     bool operator==(intmod rhs) const { return val == rhs.val; }     intmod operator+=(intmod rhs) {       val += rhs.val;       if (val >= MOD) val -= MOD;       return *this;     }     intmod operator-=(intmod rhs) {       val -= rhs.val;       if (val < 0) val += MOD;       return *this;     }     intmod operator*=(intmod rhs) {       val = val * rhs.val % MOD;       return *this;     }     friend intmod operator+(intmod lhs, intmod rhs) { return lhs += rhs; }     friend intmod operator-(intmod lhs, intmod rhs) { return lhs -= rhs; }     friend intmod operator*(intmod lhs, intmod rhs) { return lhs *= rhs; }     friend intmod sqr(intmod a) { return a * a; }     friend intmod bpow(intmod a, int p) {       intmod ans(1);       while (p) {         if (p & 1) ans *= a;         a = sqr(a);         p >>= 1;       }       return ans;     }     friend intmod inv(intmod a) { return bpow(a, MOD - 2); }     intmod operator/=(intmod rhs) { return (*this) *= inv(rhs); }     friend intmod operator/(intmod lhs, intmod rhs) { return lhs /= rhs; }     friend istream &operator>>(istream &is, intmod &im) { return is >> im.val; }     friend ostream &operator<<(ostream &os, intmod im) { return os << im.val; }   };   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     cout << bpow(intmod(2), n + m) << endl;     return 0;   }
#include <bits/stdc++.h>   long long int power(long long int x, long long int n) {     long long int result = 1;     while (n) {       if (n % 2 == 1) result = result * x;       n = n / 2;       x = x * x;     }     return result;   }   long long int gcd(long long int a, long long int b) {     if (!b) return a;     return gcd(b, a % b);   }   long long int lcm(long long int a, long long int b) {     return (a * b) / gcd(a, b);   }   long long int BS(long long int a[], long long int s, long long int n,                    long long int val) {     long long int mid, beg = s, end = n - 1;     while (beg <= end) {       mid = (beg + end) / 2;       if (val == a[mid]) {         break;       } else if (val > a[mid]) {         beg = mid + 1;       } else {         end = mid - 1;       }     }     return mid;   }   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t;     cin >> t;     while (t--) {       long long int n, k;       cin >> n >> k;       long long int d, ans = 0;       d = (n / 2) + 1;       long long int a[n * k];       for (long long int i = 0; i < n * k; i++) cin >> a[i];       long long int count = k;       if (n != 2 && n != 1) {         for (long long int j = n * k - d; j >= 0; j -= d) {           ans += a[j];           count--;           if (count == 0) break;         }         cout << ans <<   n ;       } else if (n == 2) {         long long int x = k;         for (long long int i = 0; i < n * k; i++) {           ans += a[i];           x--;           i++;           if (x == 0) break;         }         cout << ans <<   n ;       } else if (n == 1) {         for (long long int i = 0; i < n * k; i++) ans += a[i];         cout << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     char with[1005], make[1005];     int count1[26], count2[26], ans = 0;     bool flag = false;     scanf( %s , with);     memset(count1, 0, sizeof(count1));     memset(count2, 0, sizeof(count2));     for (int i = 0; with[i]; i++) {       count1[with[i] -  a ]++;     }     int m;     scanf( %s , make);     for (int j = 0; make[j]; j++) {       count2[make[j] -  a ]++;     }     for (int i = 0; i <= 25; i++) {       if (count1[i] >= count2[i])         ans += count2[i];       else if (count1[i] < count2[i] && count1[i] > 0)         ans += count1[i];       else         flag = true;     }     if (flag) {       cout <<  -1  << endl;     } else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   std::vector<int> a[500005];   int n, m, col[500005], ans[505][505], f[505][505];   int read() {     char ch = getchar();     if (ch ==  .  || ch ==  X ) return ch ==  X ;     return read();   }   int t(int x, int y) { return (x - 1) * m + y; }   std::pair<int, int> it(int id) {     return std::make_pair((id - 1) / m + 1, (id - 1) % m + 1);   }   void add(int x, int y) {     a[x].push_back(y);     a[y].push_back(x);   }   void dfs(int v) {     for (int i = 0; i < (int)a[v].size(); i++) {       int u = a[v][i];       if (col[u] != -1) continue;       col[u] = 1 - col[v];       dfs(u);     }   }   int getans(int x, int y) {     int s = 0;     if (!f[x + 1][y]) s = s + ans[x + 1][y];     if (!f[x - 1][y]) s = s + ans[x - 1][y];     if (!f[x][y + 1]) s = s + ans[x][y + 1];     if (!f[x][y - 1]) s = s + ans[x][y - 1];     return s;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) f[i][j] = read();     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         if (!f[i][j]) {           col[t(i, j)] = -1;           continue;         }         int cnt = 0;         if (!f[i + 1][j]) ++cnt;         if (!f[i - 1][j]) ++cnt;         if (!f[i][j + 1]) ++cnt;         if (!f[i][j - 1]) ++cnt;         if (cnt == 1 || cnt == 3) return puts( NO ), 0;         if (!cnt) continue;         if (cnt == 2) {           int p1 = 0, p2 = 0;           if (!f[i + 1][j]) !p1 ? p1 = t(i + 1, j) : p2 = t(i + 1, j);           if (!f[i][j + 1]) !p1 ? p1 = t(i, j + 1) : p2 = t(i, j + 1);           if (!f[i - 1][j]) !p1 ? p1 = t(i - 1, j) : p2 = t(i - 1, j);           if (!f[i][j - 1]) !p1 ? p1 = t(i, j - 1) : p2 = t(i, j - 1);           add(p1, p2);         } else if (cnt == 4) {           add(t(i + 1, j), t(i, j + 1));           add(t(i + 1, j), t(i, j - 1));           add(t(i - 1, j), t(i, j + 1));           add(t(i - 1, j), t(i, j - 1));         }       }     for (int i = 1; i <= n * m; i++)       if (col[i] == -1) col[i] = 0, dfs(i);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (!f[i][j]) ans[i][j] = (col[t(i, j)] ? 1 : 4);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (f[i][j]) ans[i][j] = getans(i, j);     puts( YES );     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) printf( %d  , ans[i][j]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, x, y;   string s;   bool v[505][505];   bool judge(int x, int y) { return (x >= 1 && x <= n && y >= 1 && y <= m); }   int dirx(char x) {     if (x ==  L  || x ==  R ) return 0;     if (x ==  U ) return -1;     return 1;   }   int diry(char x) {     if (x ==  U  || x ==  D ) return 0;     if (x ==  L ) return -1;     return 1;   }   int main() {     cin >> n >> m >> x >> y;     cin >> s;     int len = (int)s.length();     int nx, ny;     v[x][y] = true;     printf( 1  );     for (int i = 0; i < len - 1; ++i) {       nx = x + dirx(s[i]);       ny = y + diry(s[i]);       if (!judge(nx, ny)) {         printf( 0  );         continue;       }       x = nx;       y = ny;       if (v[x][y])         printf( 0  );       else {         v[x][y] = true;         printf( 1  );       }     }     int ans = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (!v[i][j]) ans++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int v[1 << 20], n, L = 1048575;   void R(int i) {     if (~i) {       int p;       for (; v[p = L ^ i] || p > n; L /= 2)         ;       v[p] = 1;       R(i - 1);       printf( %d  , p);     }   }   int main() {     scanf( %d , &n);     printf( %lld n , 1LL * n * (n + 1));     R(n);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       if (a == b)         cout << 0 << endl;       else if ((a < b && (b - a) % 2 == 1) || ((a > b) && (a - b) % 2 == 0)) {         cout << 1 << endl;       } else if ((a < b && (b - a) % 2 == 0) || ((a > b) && (a - b) % 2 == 1)) {         cout << 2 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     unordered_map<char, int> v;     int cnt = 0;     int j = 0;     for (int i1 = 1; i1 <= n; ++i1) {       char ch;       string second;       cin >> ch >> second;       if (ch ==  ! ) {         if (cnt == 0) {           for (int i = 0; i < second.length(); ++i) {             if (v[second[i]] == 0) {               v[second[i]] = 1;             }           }           cnt++;         } else {           unordered_map<char, int> v1;           for (int i = 0; i < second.length(); ++i) {             if (v1[second[i]] == 0) {               v1[second[i]] = 1;             }           }           for (char ch1 =  a ; ch1 <=  z ; ++ch1) {             if (v[ch1] == 1 && v1[ch1] == 1) {               v[ch1] = 1;             } else {               v[ch1] = -1;             }           }         }       } else if (ch ==  . ) {         if (cnt == 0) {           for (int i = 0; i < second.length(); ++i) {             v[second[i]] = -1;           }         } else {           for (int i = 0; i < second.length(); ++i) {             v[second[i]] = -1;           }         }       } else {         if (i1 != n) {           v[second[0]] = -1;         }       }       int sum = 0, sum1 = 0;       for (char ch1 =  a ; ch1 <=  z ; ++ch1) {         if (v[ch1] == 1) {           sum += 1;         } else if (v[ch1] == -1) {           sum1--;         }       }       j++;       if (sum == 1 || sum1 == -25) {         break;       }     }     int totSum = 0;     for (int i = j + 1; i <= n; ++i) {       char ch;       string second;       cin >> ch >> second;       if (ch ==  ! ) {         totSum++;       } else if (ch ==  ?  && i != n) {         totSum++;       }     }     cout << totSum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ar[1000010];   int main() {     long long n;     cin >> n;     long long ans = 0;     if (n % 2 == 1)       puts( 0 );     else {       n = n / 2;       n = (n - 1) / 2;       cout << n << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   int n, m, k, par[maxn], ans[maxn];   bool arr[maxn];   pair<int, pair<int, int>> e[maxn];   int get_path(int v) { return par[v] < 0 ? v : (par[v] = get_path(par[v])); }   void merge(int v, int u) {     if ((v = get_path(v)) == (u = get_path(u))) return;     if (par[v] < par[u]) swap(v, u);     par[u] += par[v];     par[v] = u;     arr[u] = arr[u] || arr[v];   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 0; i < k; i++) {       int x;       cin >> x;       arr[x] = 1;     }     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       e[i] = {w, {u, v}};     }     sort(e, e + m);     int ind;     memset(par, -1, sizeof(par));     for (int i = 0; i < m; i++) {       int u = e[i].second.first, v = e[i].second.second;       if ((u = get_path(u)) != (v = get_path(v)) && arr[u] && arr[v]) {         ind = i;       }       merge(u, v);     }     for (int i = 0; i < k; i++) {       cout << e[ind].first <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Yahia74() {}   const int N = 1e5 + 74, M = 1e5 + 74, OO = 0x3f3f3f3f;   int main() {     Yahia74();     int n, cnt[N] = {};     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       if (i < n / 2) {         if (x - i >= 0) cnt[x - i]++;       } else {         if (x - (n - i - 1) >= 0) cnt[x - (n - i - 1)]++;       }     }     int mx = 0;     for (int i = 1; i < 100001; i++) mx = max(mx, cnt[i]);     cout << n - mx << endl;     return 0;   }
#include <bits/stdc++.h>   template <typename Sep, typename Head, typename... Tail>   void fold_print(Sep sep, Head&& h, Tail&&... args) {     ((std::cerr << h) << ... << (std::cerr << sep, args));   }   std::mt19937_64 myrand(       std::chrono::high_resolution_clock::now().time_since_epoch().count());   using namespace std;   using LL = long long int;   void init();   void process();   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int T = 1;     init();     for (int t = 1; t <= T; t++) {       process();     }     cout.flush();     return 0;   }   constexpr LL MOD = 998244353;   vector<LL> fac(5000 * 2 + 1), inv(5000 * 2 + 1);   LL fastpw(LL x, LL p) {     if (p == 0) return 1;     LL tmp = fastpw(x * x % MOD, p / 2);     if (p % 2 == 0)       return tmp;     else       return tmp * x % MOD;   }   LL modinv(LL x) { return fastpw(x, MOD - 2); }   void init() {     fac[0] = 1;     for (LL i = 1; i < fac.size(); i++) {       fac[i] = i * fac[i - 1] % MOD;     }     for (size_t i = 0; i < inv.size(); i++) {       inv[i] = modinv(fac[i]);     }   }   LL C(LL n, LL m) { return fac[n] * inv[m] % MOD * inv[n - m] % MOD; }   void process() {     int n, k;     cin >> n >> k;     vector<int> arr(n);     {       for (auto& x : arr) {         char ch;         cin >> ch;         x = ch -  0 ;       }     }     auto permute = [&](LL l, LL r, LL one) {       LL len = r - l + 1;       LL cnt[] = {len - one, one};       if (len == 1 || cnt[0] == len || cnt[1] == len) return 0ll;       cnt[1 - arr[l]] -= 1;       return C(len - 1, cnt[0]);     };     LL ans = 1, r = 0, cnt = arr[0];     for (LL i = 0; i < n; cnt -= arr[i], i += 1) {       while (r + 1 < n && cnt + arr[r + 1] <= k) {         cnt += arr[r + 1], r += 1;       }       if (cnt != k) break;       if (r == n - 1) {         for (int j = i; j < n; cnt -= arr[j], j += 1) {           ans = (ans + permute(j, r, cnt)) % MOD;         }         break;       } else {         ans = (ans + permute(i, r, cnt)) % MOD;       }     }     cout << ans <<   n ;   }