malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   int ans, pos[120000], fa[21][120000], tim, dep[120000], K, n, x, y;   vector<int> E[120000];   struct wph {     bool operator()(const int x, const int y) { return pos[x] < pos[y]; }   };   set<int, wph> S;   void prep(int x, int ff) {     fa[0][x] = ff;     for (int i = 1; i <= 20; ++i) fa[i][x] = fa[i - 1][fa[i - 1][x]];   }   void dfs(int x, int ff) {     pos[x] = ++tim;     prep(x, ff);     for (int i = 0; i < E[x].size(); ++i)       if (E[x][i] != ff) {         dep[E[x][i]] = dep[x] + 1;         dfs(E[x][i], x);       }   }   int pathlen(int x, int y) {     int ans = dep[x] + dep[y];     if (dep[x] < dep[y]) swap(x, y);     for (int i = 20; i >= 0; --i)       if ((dep[x] - dep[y]) >= 1 << i) x = fa[i][x];     if (x == y) return ans - 2 * dep[x];     for (int i = 20; i >= 0; --i)       if (fa[i][x] != fa[i][y]) x = fa[i][x], y = fa[i][y];     return ans - 2 * dep[fa[0][x]];   }   int calc(set<int>::iterator it) {     int len = 0;     auto p1 = it, p2 = it;     if (p1 == S.begin()) p1 = S.end();     p1--;     len += pathlen(*p1, *it);     p2++;     if (p2 == S.end()) p2 = S.begin();     len += pathlen(*p2, *it);     len -= pathlen(*p2, *p1);     return len;   }   int main() {     scanf( %d%d , &n, &K);     for (int i = 1; i <= n - 1; ++i) {       scanf( %d%d , &x, &y);       E[x].push_back(y);       E[y].push_back(x);     }     dfs(1, 0);     ans = 1;     S.insert(1);     int j = 1, size = 0;     for (int i = 2; i <= n; ++i) {       auto p = S.insert(i).first;       size += calc(p);       while (size / 2 + 1 > K) {         p = S.find(j);         size -= calc(p);         S.erase(p);         j++;       }       ans = max(ans, i - j + 1);     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1e9 + 7;   const long long int lim = 1e17;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int T = clock();     long long int n, k;     cin >> n >> k;     map<long long int, long long int> mpp;     vector<long long int> a(n);     for (long long int i = 0; i < n; i++) cin >> a[i];     long long int tot = 0;     mpp[0] = 1;     long long int ans = 0;     for (long long int i = 0; i < n; i++) {       tot += a[i];       long long int r = 1;       if (k == -1) {         ans += mpp[tot - 1];         ans += mpp[tot + 1];       } else if (k == 1)         ans += mpp[tot - 1];       else {         while (r < lim) {           if (mpp.find(tot - r) != mpp.end()) ans += mpp[tot - r];           r *= k;         }       }       mpp[tot]++;     }     cout << ans;     cerr <<   n nTIME:   << (double)(clock() - T) / CLOCKS_PER_SEC <<   sec n ;     T = clock();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[103], b[103], c[103];   char aa[103], bb[103], cc[103];   char temp[103];   int temp2;   char ss[602];   char s[602];   int n;   int main() {     scanf( %s%s%s , aa, bb, cc);     scanf( %d , &n);     int i, j, jj;     int coun1 = 0, coun2 = 0, coun3 = 0;     for (i = 0; aa[i]; i++)       if (aa[i] !=  _  && aa[i] !=  ;  && aa[i] !=  - ) a[coun1++] = aa[i];     for (i = 0; bb[i]; i++)       if (bb[i] !=  _  && bb[i] !=  ;  && bb[i] !=  - ) b[coun2++] = bb[i];     for (i = 0; cc[i]; i++)       if (cc[i] !=  _  && cc[i] !=  ;  && cc[i] !=  - ) c[coun3++] = cc[i];     for (i = 0; a[i]; i++)       if (a[i] > 96) a[i] -= 32;     for (i = 0; b[i]; i++)       if (b[i] > 96) b[i] -= 32;     for (i = 0; c[i]; i++)       if (c[i] > 96) c[i] -= 32;     if (coun1 < coun3) {       for (i = 0; i < coun1; i++) temp[i] = a[i];       for (i = 0; i < coun3; i++) a[i] = c[i];       for (i = 0; i < coun1; i++) c[i] = temp[i];       temp2 = coun1;       coun1 = coun3;       coun3 = temp2;     }     if (coun1 < coun2) {       for (i = 0; i < coun1; i++) temp[i] = a[i];       for (i = 0; i < coun2; i++) a[i] = b[i];       for (i = 0; i < coun1; i++) b[i] = temp[i];       temp2 = coun1;       coun1 = coun2;       coun2 = temp2;     }     if (coun2 < coun3) {       for (i = 0; i < coun2; i++) temp[i] = b[i];       for (i = 0; i < coun3; i++) b[i] = c[i];       for (i = 0; i < coun2; i++) c[i] = temp[i];       temp2 = coun2;       coun2 = coun3;       coun3 = temp2;     }     a[coun1] =   0 ;     b[coun2] =   0 ;     c[coun3] =   0 ;     int coun;     bool flag;     bool flag2;     bool flagi[5];     for (i = 0; i < n; i++) {       coun = 0;       scanf( %s , ss);       for (j = 0; j < 5; j++) flagi[j] = false;       for (j = 0; ss[j]; j++)         if (ss[j] !=  ;  && ss[j] !=  _  && ss[j] !=  - ) s[coun++] = ss[j];       for (j = 0; j < coun; j++)         if (s[j] > 96) s[j] -= 32;       for (j = 0; j < coun; j++) {         flag = false;         flag2 = true;         for (jj = 0; a[jj]; jj++)           if (a[jj] != s[j + jj] || j + jj == coun) flag2 = false;         if (flag2 && !flagi[0]) {           flag = true;           flagi[0] = true;           j = j + jj - 1;           continue;         }         flag2 = true;         for (jj = 0; b[jj]; jj++)           if (b[jj] != s[j + jj] || j + jj == coun) flag2 = false;         if (flag2 && !flagi[1]) {           flag = true;           flagi[1] = true;           j = j + jj - 1;           continue;         }         flag2 = true;         for (jj = 0; c[jj]; jj++)           if (c[jj] != s[j + jj] || j + jj == coun) flag2 = false;         if (flag2 && !flagi[2]) {           flag = true;           flagi[2] = true;           j = j + jj - 1;           continue;         }         if (!flag) break;         if (j == coun - 1) break;       }       if (flag) {         for (j = 0; j < 3; j++)           if (!flagi[j]) flag = false;       }       if (flag)         printf( ACC n );       else         printf( WA n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> arr;   int dp[101][101][101][2];   int solve(int index, int even, int odd, int pre) {     if (index == n + 1) return 0;     if (dp[index][even][odd][pre] != -1) return dp[index][even][odd][pre];     if (arr[index] != 0) {       int ans = solve(index + 1, even, odd, arr[index] % 2);       if (pre != -1) {         if ((arr[index] % 2) != pre) ans++;       }       return ans;     }     int ans = INT_MAX;     if (even > 0) {       ans = min(ans, solve(index + 1, even - 1, odd, 0) + (pre == 1));     }     if (odd > 0) {       ans = min(ans, solve(index + 1, even, odd - 1, 1) + (pre == 0));     }     dp[index][even][odd][pre] = ans;     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < 101; i++) {       for (int j = 0; j < 101; j++) {         for (int k = 0; k < 101; k++) {           dp[i][j][k][0] = dp[i][j][k][1] = -1;         }       }     }     arr.resize(n + 1);     int even = n / 2;     int odd = (n + 1) / 2;     for (int i = 1; i <= n; i++) {       cin >> arr[i];       if (arr[i] % 2)         odd--;       else if (arr[i])         even--;     }     int ans = solve(1, even, odd, -1);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2e5 + 5;   int parent[MAX];   int depth[MAX];   int get(int a) {     while (a != parent[a]) a = parent[a];     return a;   }   void join(int a, int b) {     a = get(a);     b = get(b);     if (a == b) return;     if (depth[a] > depth[b]) swap(a, b);     parent[a] = b;     depth[b] += depth[a];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, q, a, b, w;     cin >> n >> q;     for (int i = 1; i <= n + 1; i++) {       parent[i] = i;       depth[i] = 1;     }     vector<pair<int, pair<int, int>>> vp;     vector<long long> sol(MAX);     long long cnt = 0;     for (int i = 0; i < n - 1; i++) {       cin >> a >> b >> w;       vp.push_back({w, {a, b}});     }     sort(vp.begin(), vp.end());     reverse(vp.begin(), vp.end());     for (int j = 1; j < MAX; j++) {       while (!vp.empty() && vp.back().first <= j) {         a = vp.back().second.first;         b = vp.back().second.second;         vp.pop_back();         a = get(a);         b = get(b);         if (a == b) continue;         cnt -= 1ll * depth[a] * (depth[a] - 1) / 2;         cnt -= 1ll * depth[b] * (depth[b] - 1) / 2;         join(a, b);         a = get(a);         cnt += 1ll * depth[a] * (depth[a] - 1) / 2;       }       sol[j] = cnt;     }     while (q--) {       cin >> w;       cout << sol[w] <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     getline(cin, s);     long long n = s.length(), i = n - 1;     while (1) {       if ((s[i] >= 65 && s[i] <= 91) || (s[i] >= 97 && s[i] <= 122)) {         if (s[i] ==  a  || s[i] ==  y  || s[i] ==  e  || s[i] ==  i  ||             s[i] ==  o  || s[i] ==  u ) {           cout <<  YES  << endl;           break;         } else if (s[i] ==  A  || s[i] ==  Y  || s[i] ==  E  || s[i] ==  I  ||                    s[i] ==  O  || s[i] ==  U ) {           cout <<  YES  << endl;           break;         } else {           cout <<  NO  << endl;           break;         }       }       i--;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 30;   const long long inf = 1LL << 60;   const int N = 200010;   struct Edge {     int to, next;   } e1[N], e2[N];   int list1[N], list2[N], d1, d2;   priority_queue<pair<int, int> > Q;   queue<int> S;   bool vis[N];   vector<int> v[N];   void add(int x, int y, int *list, int &d, Edge *e) {     e[d].to = y, e[d].next = list[x], list[x] = d++;   }   int n, m, k;   int ans[N], Min[N], din[N], dout[N], d[N];   int read() {     int w(0), f(0);     char c = getchar();     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) f = 1, c = getchar();     while (c >=  0  && c <=  9 ) w = w * 10 + c -  0 , c = getchar();     return f ? -w : w;   }   void Imps() {     puts( -1 );     exit(0);   }   void Delete(int x) {     int y;     for (int i = list2[x]; i >= 0; i = e2[i].next) {       y = e2[i].to;       d[y]--;       if (!d[y] && !ans[y]) Q.push(make_pair(Min[y], y));     }   }   int main() {     n = read(), m = read(), k = read();     memset(list1, -1, 4 * (n + 1)), memset(list2, -1, 4 * (n + 1));     for (int i = 1; i <= n; ++i)       ans[i] = read(), vis[ans[i]] = 1, v[ans[i]].push_back(i);     int x, y;     pair<int, int> tmp;     for (int i = 1; i <= m; ++i) {       x = read(), y = read();       add(y, x, list1, d1, e1);       add(x, y, list2, d2, e2);       din[x]++, dout[y]++;     }     for (int i = 1; i <= n; ++i) {       d[i] = din[i];       if (!d[i]) S.push(i);     }     while (!S.empty()) {       x = S.front(), S.pop();       if (ans[x]) {         if (ans[x] < Min[x])           Imps();         else           Min[x] = ans[x];       } else if (!Min[x])         Min[x] = 1;       for (int i = list1[x]; i >= 0; i = e1[i].next) {         y = e1[i].to;         Min[y] = max(Min[y], Min[x] + 1);         d[y]--;         if (!d[y]) S.push(y);       }     }     for (int i = 1; i <= n; ++i) {       d[i] = dout[i];       if (!d[i] && !ans[i]) Q.push(make_pair(Min[i], i));     }     for (int i = k; i >= 1; --i) {       for (int j = 0; j < v[i].size(); ++j) {         x = v[i][j];         Delete(x);       }       while (!Q.empty()) {         tmp = Q.top();         if (tmp.first > i)           Imps();         else if (tmp.first == i)           ans[tmp.second] = i, vis[i] = 1, Q.pop(), Delete(tmp.second);         else           break;       }       if (!vis[i]) {         if (!Q.empty()) {           tmp = Q.top();           ans[tmp.second] = i, vis[i] = 1, Q.pop(), Delete(tmp.second);         } else           Imps();       }     }     for (x = 1; x <= n; ++x)       for (int i = list1[x]; i >= 0; i = e1[i].next)         if (ans[x] >= ans[e1[i].to]) Imps();     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       long long move = 0;       for (int i = 1; i <= n / 2; ++i) {         move += i * 1ll * i;       }       cout << move * 8 << endl;     }     return 0;   }
#include <bits/stdc++.h>   int n, m, x, i, ans;   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &x);       if (x == 2) ++m;     }     if (n == 1) ans = 1;     if (n == 2 && m == 0) ans = 2;     if (n == 2 && m == 1) ans = 2;     if (n == 2 && m == 2) ans = 2;     if (n == 3 && m == 0) ans = 4;     if (n == 3 && m == 1) ans = 6;     if (n == 3 && m == 2) ans = 6;     if (n == 3 && m == 3) ans = 6;     if (n == 4 && m == 0) ans = 10;     if (n == 4 && m == 1) ans = 16;     if (n == 4 && m == 2) ans = 24;     if (n == 4 && m == 3) ans = 24;     if (n == 4 && m == 4) ans = 24;     if (n == 5 && m == 0) ans = 26;     if (n == 5 && m == 1) ans = 50;     if (n == 5 && m == 2) ans = 80;     if (n == 5 && m == 3) ans = 120;     if (n == 5 && m == 4) ans = 120;     if (n == 5 && m == 5) ans = 120;     if (n == 6 && m == 0) ans = 76;     if (n == 6 && m == 1) ans = 156;     if (n == 6 && m == 2) ans = 300;     if (n == 6 && m == 3) ans = 480;     if (n == 6 && m == 4) ans = 720;     if (n == 6 && m == 5) ans = 720;     if (n == 6 && m == 6) ans = 720;     if (n == 7 && m == 0) ans = 232;     if (n == 7 && m == 1) ans = 532;     if (n == 7 && m == 2) ans = 1092;     if (n == 7 && m == 3) ans = 2100;     if (n == 7 && m == 4) ans = 3360;     if (n == 7 && m == 5) ans = 5040;     if (n == 7 && m == 6) ans = 5040;     if (n == 7 && m == 7) ans = 5040;     if (n == 8 && m == 0) ans = 764;     if (n == 8 && m == 1) ans = 1856;     if (n == 8 && m == 2) ans = 4256;     if (n == 8 && m == 3) ans = 8736;     if (n == 8 && m == 4) ans = 16800;     if (n == 8 && m == 5) ans = 26880;     if (n == 8 && m == 6) ans = 40320;     if (n == 8 && m == 7) ans = 40320;     if (n == 8 && m == 8) ans = 40320;     if (n == 9 && m == 0) ans = 2620;     if (n == 9 && m == 1) ans = 6876;     if (n == 9 && m == 2) ans = 16704;     if (n == 9 && m == 3) ans = 38304;     if (n == 9 && m == 4) ans = 78624;     if (n == 9 && m == 5) ans = 151200;     if (n == 9 && m == 6) ans = 241920;     if (n == 9 && m == 7) ans = 362880;     if (n == 9 && m >= 8) ans = 362880;     if (n == 10 && m == 0) ans = 9496;     if (n == 10 && m == 1) ans = 26200;     if (n == 10 && m == 2) ans = 68760;     if (n == 10 && m == 3) ans = 167040;     if (n == 10 && m == 4) ans = 383040;     if (n == 10 && m == 5) ans = 786240;     if (n == 10 && m == 6) ans = 1512000;     if (n == 10 && m == 7) ans = 2419200;     if (n == 10 && m >= 8) ans = 3628800;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, t, a, b, da, db;     while (cin >> x >> t >> a >> b >> da >> db) {       bool f = 0;       for (int i = 0; i <= t; i++) {         for (int j = 0; j <= t; j++) {           int t1, t2;           if (i == t)             t1 = 0;           else             t1 = a - i * da;           if (j == t)             t2 = 0;           else             t2 = b - j * db;           if (t1 + t2 == x) {             f = 1;             break;           }         }       }       if (f)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, ans;   int a[19];   int inv[2000009];   int f[17009];   int tag[19];   int qpow(int a, int b) {     int ans = 1;     for (; b; b >>= 1, a = (long long)a * a % 1000000007)       if (b & 1) ans = (long long)ans * a % 1000000007;     return ans;   }   void init() {     for (int i = 1; i <= 2000000; i++) inv[i] = qpow(i, 1000000007 - 2);   }   int main() {     init();     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int s = 1; s < (1 << n); s++) {       int sm = 0;       for (int t = (s - 1) & s; t; t = (t - 1) & s) {         int p = s ^ t, pb = 1;         for (int i = 1; i <= n; i++)           if (t >> (i - 1) & 1)             for (int j = 1; j <= n; j++)               if (p >> (j - 1) & 1)                 pb = (long long)pb * a[i] % 1000000007 * inv[a[i] + a[j]] %                      1000000007;         sm = (sm + (long long)f[t] * pb) % 1000000007;       }       f[s] = (1000000007 + 1 - sm) % 1000000007;     }     int ans = 0;     for (int i = 1; i <= n; i++)       for (int s = 1; s < (1 << n); s++)         if (s >> (i - 1) & 1) {           int pb = 1;           for (int i = 1; i <= n; i++)             if (s >> (i - 1) & 1)               for (int j = 1; j <= n; j++)                 if (!(s >> (j - 1) & 1))                   pb = (long long)pb * a[i] % 1000000007 * inv[a[i] + a[j]] %                        1000000007;           ans = (ans + (long long)f[s] * pb) % 1000000007;         }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void func(void) {     freopen( input.c ,  r , stdin);     freopen( output.c ,  w , stdout);   }   void print(vector<long long> &v) {     cout << v.size() << endl;     for (int i = 0; i < v.size(); i++) {       printf( %lld  , v[i]);     }     printf(  n );   }   void print(vector<pair<long long, long long> > &v) {     cout << v.size() << endl;     for (int i = 0; i < v.size(); i++) {       printf( %lld %lld n , v[i].first, v[i].second);     }   }   void print(double d) { cout << fixed << setprecision(10) << d << endl; }   void print(string s, double d) {     cout << s <<    ;     cout << fixed << setprecision(10) << d << endl;   }   const int N = 1e5 + 100;   struct info {     long long day, cost, place;     bool operator<(info k1) const { return day < k1.day; }   };   vector<info> in;   vector<info> out;   set<pair<long long, long long> > outFlight[N];   long long inFlight[N];   int main() {     long long n, q, i, j = 0, temp, t, k, ans = 0, sum = 0, x, y, z, cnt = 0, m,                        fg = 0, mx = 0, mx1 = 0, mn = 8e18,                        mn1 = 8000000000000000000;     scanf( %lld %lld %lld , &n, &m, &k);     for (int i = 0; i < m; i++) {       scanf( %lld %lld , &x, &y);       scanf( %lld %lld , &z, &t);       info xx;       xx.day = x;       xx.place = y;       if (y == 0) xx.place = z;       xx.cost = t;       if (y)         in.push_back(xx);       else         out.push_back(xx);     }     sort(in.begin(), in.end());     sort(out.begin(), out.end());     for (int i = 0; i < N; i++) inFlight[i] = 1e10;     int ok = 0;     for (int i = 0; i < out.size(); i++) {       outFlight[out[i].place].insert({out[i].cost, i});     }     long long outSum = 0;     long long inSum = 0;     for (int i = 1; i <= n; i++) {       if (outFlight[i].size() == 0) {         printf( -1 n );         return 0;       }       auto it = outFlight[i].begin();       pair<long long, long long> p = *it;       outSum += p.first;     }     cnt = 0;     for (int i = 0; i < in.size(); i++) {       long long now = in[i].day;       long long place = in[i].place;       long long cost = in[i].cost;       if (inFlight[place] == 1e10) {         inFlight[place] = cost;         inSum += cost;         cnt++;       } else {         inSum -= inFlight[place];         inFlight[place] = min(inFlight[place], cost);         inSum += inFlight[place];       }       now += k + 1;       fg = 0;       for (; ok < out.size(); ok++) {         if (out[ok].day >= now) break;         auto it = outFlight[out[ok].place].begin();         pair<long long, long long> p = *it;         outSum -= p.first;         p = {out[ok].cost, ok};         outFlight[out[ok].place].erase(p);         if (outFlight[out[ok].place].size() == 0) {           fg = 1;           break;         }         it = outFlight[out[ok].place].begin();         p = *it;         outSum += p.first;       }       if (fg) break;       if (cnt == n) {         mn = min(mn, inSum + outSum);       }     }     if (mn == 8e18) mn = -1;     cout << mn << endl;   }
#include <bits/stdc++.h>   using namespace std;   int flag = 0, ans, n;   int r[10], d[12], l[12], u[12];   int print(int x1, int y1, int x2, int y2) {     cout <<  ?   << x1 <<     << y1 <<     << x2 <<     << y2 << endl;     int val;     cin >> val;     if (flag) {       if (x1 <= l[0] && r[0] <= x2 && y1 <= d[0] && u[0] <= y2) return val - 1;     }     return val;   }   int findright(int l, int r) {     if (l > r) return 0;     int mid = (l + r) / 2;     int val = print(1, 1, mid, n);     if (val > 0) {       ans = mid;       findright(l, mid - 1);     } else {       findright(mid + 1, r);     }     return 0;   }   int findleft(int l, int r, int r1) {     if (l > r) return 0;     int mid = (l + r) / 2;     int val = print(mid, 1, r1, n);     if (val > 0) {       ans = mid;       findleft(mid + 1, r, r1);     } else {       findleft(l, mid - 1, r1);     }     return 0;   }   int findup(int l, int r, int l1, int r1) {     if (l > r) return 0;     int mid = (l + r) / 2;     int val = print(l1, 1, r1, mid);     if (val > 0) {       ans = mid;       findup(l, mid - 1, l1, r1);     } else {       findup(mid + 1, r, l1, r1);     }     return 0;   }   int finddown(int l, int r, int l1, int r1, int u1) {     if (l > r) return 0;     int mid = (l + r) / 2;     int val = print(l1, mid, r1, u1);     if (val > 0) {       ans = mid;       finddown(mid + 1, r, l1, r1, u1);     } else {       finddown(l, mid - 1, l1, r1, u1);     }     return 0;   }   int main() {     std::ios::sync_with_stdio(false);     int i;     cin >> n;     int r1, l1, u1, d1;     findright(1, n);     r1 = ans;     findleft(1, r1, r1);     l1 = ans;     l[0] = l1;     r[0] = r1;     findup(1, n, l1, r1);     u1 = ans;     finddown(1, u1, l1, r1, u1);     d1 = ans;     u[0] = u1;     d[0] = d1;     flag = 1;     findright(1, n);     r1 = ans;     findleft(1, r1, r1);     l1 = ans;     l[1] = l1;     r[1] = r1;     findup(1, n, l1, r1);     u1 = ans;     finddown(1, u1, l1, r1, u1);     d1 = ans;     u[1] = u1;     d[1] = d1;     cout <<  !  ;     for (i = 0; i < 1; i++) {       cout << l[i] <<     << d[i] <<     << r[i] <<     << u[i] <<    ;     }     i = 1;     cout << l[i] <<     << d[i] <<     << r[i] <<     << u[i];   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = (int)2e5 + 88;   char tu[maxn];   int lu[maxn];   int main() {     int n, a, b, k;     cin >> n >> a >> b >> k;     scanf( %s , tu);     for (int i = 0; i < maxn; i++) {       lu[i] = 0;     }     int ans = 0;     int ant = 0;     int ttt = 0;     for (int i = 0; i < n; i++) {       if (tu[i] ==  0 ) {         ant++;       } else         ant = 0;       if (ant != 0 && ant % b == 0) {         ans++;         if (ans >= a) {           lu[ttt++] = i;         }       }     }     cout << ttt << endl;     for (int i = 0; i < ttt; i++) {       cout << lu[i] + 1 <<    ;     }   }