Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define INF 100000
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
string  S;
int N, K;
int main() {
	cin >> N >> K;
	cin >> S;
	vector<int> Nums;
	int now = 1;
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		if (S[i] - '0' == now) {
			cnt++;
		}
		else {
			Nums.push_back(cnt);
			cnt = 1;
			now = 1 - now;
		}
	}
  	if (cnt != 0) Nums.push_back(cnt);
  	for (int i = 0; i < Nums.size(); ++i){
      cout << Nums[i] << endl;
    }
  	int Add = 2*K + 1;
	if (Nums.size() % 2 == 0) Nums.push_back(0);
	//累積和
	vector<int> Sums(N + 1);
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		Sums[i + 1] = Sums[i] + Nums[i];
	}
		//[right, left)の和を求める
	for (int left = 0; left < Nums.size(); left += 2)
	{
			int right = min(left + Add, Sums.size());
			sum = max(sum, Sums[right] - Sums[left]);
    }
	cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:40: error: no matching function for call to 'min(int, std::vector<int>::size_type)'
   56 |                         int right = min(left + Add, Sums.size());
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:56:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   56 |                         int right = min(left + Add, Sums.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:
/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:56:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |                         int right = min(left + Add, Sums.size());
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~