Language: C++

#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(){
    int N, K;
    cin>>N>>K;
    string S;
    cin>>S;
    int x = 1;
    int a = S[0]=='1'?1:0;
    // queue<int> b;
    vector<int> b;
    if (S[0]=='0') {
        b.push_back(0);
    }
    
    int m=0;
    // int x1=0, x0=0;
    REP(i, 1, N){
        if(S[i-1]=='1'&&S[i]=='1'){
            ++x;
        }else if(S[i-1]=='1'&&S[i]=='0'){
            b.push_back(x);
            x = 1;
        }else if(S[i-1]=='0'&&S[i]=='1'){
            b.push_back(x);
            x = 1;
        }else if(S[i-1]=='0'&&S[i]=='0'){
            ++x;
        }
    }
    b.push_back(x);
    if (S[N-1]=='0') {
        b.push_back(0);
    }

    vector<int> c;
    c.push_back(0);

    rep(i, b.size()){
        MSG(b[i]+c[i]);
        c.push_back(b[i]+c[i]);
    }
    

    
    int k = K*2+1;
    int hoge = min(k, c.size());
    rep(i, hoge){
     m = max(m, c[i]);
    }
    REP(i, k, c.size()){
        if(S[0]=='0'){
            cout<<i<<c[i]-c[i-k+1]<<" ";
            m = max(c[i]-c[i-k+1], m);

        }
        else
        {
            cout<<i<<c[i]-c[i-k+1]<<" ";
            m = max(c[i]-c[i-k], m);
        }
        
    }
    cout<<endl;



    cout<<m<<endl;

    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:82:19: error: no matching function for call to 'min(int&, std::vector<int>::size_type)'
   82 |     int hoge = min(k, c.size());
      |                ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_tree.h:63,
                 from /usr/include/c++/14/set:62,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:82:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   82 |     int hoge = min(k, c.size());
      |                ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:24:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:82:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |     int hoge = min(k, c.size());
      |                ~~~^~~~~~~~~~~~~