Language: C++

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_NK 100000

using namespace std;

unsigned int N, K;
string S;

vector<int> sct;

int solve() {
    if(S[0] == '0') sct.push_back(0);
    char prev = S[0];
    int sct_len = 0;
    S.push_back('2');
    for(int i = 0; i < S.size(); ++i) {
        if(S[i] == prev)
            ++sct_len;
        else {
            sct.push_back(sct_len);
            sct_len = 1;
        }
        prev = S[i];
    }
    if(S[S.size() - 1] == '0') sct.push_back(0);

    int start = 0;
    int end = min(K * 2, sct.size() - 1);

    int sum = 0;
    for(int i = start; i <= end; ++i)
        sum += sct[i];
    int res = sum;

    while(end + 2 <= sct.size()) {
        sum -= sct[start];
        sum -= sct[start + 1];
        sum += sct[end + 1];
        sum += sct[end + 2];
        res = max(res, sum);
        end += 2;
        start += 2;
    }

    return res;
}

int main(int argc, char **argv) {
    cin >> N >> K;
    cin >> S;

    printf("%d\n", solve());
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:35:18: error: no matching function for call to 'min(unsigned int, std::vector<int>::size_type)'
   35 |     int end = min(K * 2, sct.size() - 1);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:3:
/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:35:18: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   35 |     int end = min(K * 2, sct.size() - 1);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:35:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
   35 |     int end = min(K * 2, sct.size() - 1);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~