#include <bits/stdc++.h>   using namespace std;   int n;   int dpr[300005];   int dpl[300005];   int A[300005];   pair<int, int> B[300005];   int fr(int pos) {     if (A[pos] == 0) return pos - 1;     if (pos == n - 1) return n - 1;     if (dpr[pos] != -1) return dpr[pos];     dpr[pos] = fr(pos + 1);     return dpr[pos];   }   int fl(int pos) {     if (A[pos] == 0) return pos + 1;     if (pos == 0) return 0;     if (dpl[pos] != -1) return dpl[pos];     dpl[pos] = fl(pos - 1);     return dpl[pos];   }   int main() {     int k;     cin >> n >> k;     memset(dpl, -1, sizeof dpl);     memset(dpr, -1, sizeof dpr);     int maxx = 0;     int coun = 0;     for (int i = 0; i < n; i++) {       cin >> A[i];       if (A[i] == 0) {         if (coun > maxx) {           maxx = coun;         }         coun = 0;       } else {         coun++;       }     }     if (coun > maxx) maxx = coun;     coun = maxx;     vector<int> C;     for (int i = 0; i < n; i++) {       if (A[i] == 0) {         if (i == 0) {           B[i].first = 0;           B[i].second = fr(i + 1);         } else if (i == n - 1) {           B[i].second = n - 1;           B[i].first = fl(i - 1);         } else {           B[i].first = fl(i - 1);           B[i].second = fr(i + 1);         }         C.push_back(i);       }     }     int sta = 0;     int fin = k - 1;     int a;     int smax = 0;     while ((fin < C.size()) && (k > 0) && (C.size() > 0)) {       a = (C[fin] - C[sta] + 1) + (C[sta] - B[C[sta]].first) +           (B[C[fin]].second - C[fin]);       if (a > maxx) {         maxx = a;         smax = B[C[sta]].first;       }       sta++;       fin++;     }     if ((sta < C.size()) && (C.size() > 0) && (k > 0)) {       a = n - C[sta] + (C[sta] - B[C[sta]].first);       if (a > maxx) {         maxx = a;         smax = B[C[sta]].first;       }     }     cout << maxx << endl;     if (coun != maxx) {       for (int i = smax; i < smax + maxx; i++) {         A[i] = 1;       }     }     for (int i = 0; i < n - 1; i++) {       cout << A[i] <<    ;     }     cout << A[n - 1] << endl;     return 0;   }   