Language: C++

#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> v;
  int index = 0;
  char pre = s[0];
  int now = 0;
  if(s[0]=='0')
    v.push_back(0);
  rep(i,int(s.size())){
    if(s[i]==pre){
      now++;
      if(i==s.size()-1){
        v.push_back(now);
      }
    }else{
      v.push_back(now);
      pre = s[i];
      now = 1;
      if(i==s.size()-1){
        v.push_back(now);
      }
    }
  }
  if(s.back()=='0')
    v.push_back(0);
  ll ans = 0;
  vector<ll> sum(v.size() + 1, 0);
  rep(i, v.size()) sum[i + 1] = sum[i] + v[i];
  for (int i = 0; i < sum.size(); i+=2){
    int j = i + 2 * k + 1;
    if(j >= sum.size())
      j = sum.size() - 1;
    chmax(ans, ll(sum[right] - sum[left]));
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:23: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-fpermissive]
   59 |     chmax(ans, ll(sum[right] - sum[left]));
      |                       ^~~~~
      |                       |
      |                       std::ios_base& (*)(std::ios_base&)
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:59:36: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-fpermissive]
   59 |     chmax(ans, ll(sum[right] - sum[left]));
      |                                    ^~~~
      |                                    |
      |                                    std::ios_base& (*)(std::ios_base&)
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~