criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int main()
{
	int N,K;
	string S;

	cin >> N >> K;
	cin >> S;

	S+="_";
	string str="";
	vector<int> sum;
	int cnt=0;
	for(int i=0;i<N;i++)
	{
		cnt++;
		if(S[i]!=S[i+1])
		{
			str+=S[i];
			sum.push_back(cnt);
			cnt=0;
		}
	}

	int ans=0;
	for(auto&& i:sum)
		ans=max(ans,i);

	for(int i=0;i<sum.size();i++)
	{
		if(i!=sum.size()-1)
			sum[i+1]+=sum[i];
	}

	for(int i=0;i<str.size();i++)
	{
		int tans=0;
		int l=i;
		int r=i+2*K;
		if(str[i]=='0')r--;
		
		r=min(r,str.size()-1);
		if(l==0)
			tans=sum[r];
		else
			tans=sum[r]-sum[l-1];
		ans=max(ans,tans);
	}

	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:22: error: no matching function for call to 'min(int&, std::__cxx11::basic_string<char>::size_type)'
   47 |                 r=min(r,str.size()-1);
      |                   ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:47:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   47 |                 r=min(r,str.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,
                 from a.cc:2:
/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:47:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |                 r=min(r,str.size()-1);
      |                   ~~~^~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;


int main(){

    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    vector<int> Nums;
    int cnt = 0;
    int now = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == (char)('0' + now)) cnt++;
        else {
            Nums.push_back(cnt);
            now  = 1 - now;
            cnt = 1;
        }
    }
    if (cnt != 0) Nums.push_back(cnt);
    if (Nums.size() % 2 == 0) Nums.push_back(0);

    int Add = 2 * k + 1;
    int ans = 0;
    int left = 0;
    int right = 0;
    int temp = 0;
    for (int i = 0; i < Nums.size(); i += 2) {

        int Nextleft = i;
        int Nextright = min(i + Add, (int)Nums.size());

        // 左端を移動
        while (Nextleft > left) {
            temp -= Nums[left];
            left++;
         while (Nextleft > right) {
            temp += Nums[right];
            right++;
        ans = max(ans, temp);
    }

    cout << ans << '\n';

}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:2: error: expected '}' at end of input
   52 | }
      |  ^
a.cc:35:46: note: to match this '{'
   35 |     for (int i = 0; i < Nums.size(); i += 2) {
      |                                              ^
a.cc:52:2: error: expected '}' at end of input
   52 | }
      |  ^
a.cc:9:11: note: to match this '{'
    9 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;


int main(){

    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    vector<int> Nums;
    int cnt = 0;
    int now = 1;
    for (int i = 0; i < N; i++) {
        if (s[i] == (char)('0' + now)) cnt++;
        else {
            Nums.push_back(cnt);
            now 1 - now;
            cnt = 1;
        }
    }
    if (cnt != 0) Nums.push_back(cnt);
    if (Nums.size() % 2 == 0) Nums.push_back(0);

    int Add = 2 * k + 1;
    int ans = 0;
    for (int i = 0; i < Nums.size(); i += 2) {

        int temp = 0;
        for (int j = 0; j < min(i + Add, Nums.size(); j++) {
            temp += Nums[j];
        }
            ans = max(ans, temp);
    }

    cout << ans << '\n';

}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:25: error: 'N' was not declared in this scope
   19 |     for (int i = 0; i < N; i++) {
      |                         ^
a.cc:23:16: error: expected ';' before numeric constant
   23 |             now 1 - now;
      |                ^~
      |                ;
a.cc:35:53: error: expected ')' before ';' token
   35 |         for (int j = 0; j < min(i + Add, Nums.size(); j++) {
      |                                ~                    ^
      |                                                     )
Language: C


#include <string>
#include <stdio.h>
#include <stdlib.h>


int main()
{
	int n, k, start = 0, end = 0;
	char s[100001];
	scanf("%d %d", &n, &k);
	fflush(stdin);
	gets(s);
	int max = 0;
	for (int i = 1; i <= k; i++)
	{
		for (int j = 0; j <n; j++)
		{
			int len = 0, right, left = j - 1, st = j;
			if (s[j] == '0')
			{
				while (s[j] == '0' && j < n)
				{
					len++;
					j++;
				}
				right = j;
				j--;
				while (s[right] == '1' && right < n)
				{
					len++;
					right++;
				}
				while (left >= 0 && s[left] == '1' && left < n)
				{
					len++;
					left--;
				}
				if (len > max)
				{
					max = len;
					start = st;
					end = j;
				}
			}
			else
			{
				while (s[j] == '1' && j < n)
				{
					j++;
					len++;
				}
				if (len > max)
					max = len;
				j--;
			}
			
		}
		for (int l = start; l <= end; l++)
			s[l] = '1';
	}
	printf("%d\n", max);
	
	return 0;
}

Compiler output:
main.c:2:10: fatal error: string: No such file or directory
    2 | #include <string>
      |          ^~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
	int n, k, start = 0, end = 0;
	char s[100001];
	cin >> n >> k;
	fflush(stdin);
	gets(s);
	int max = 0;
	for (int i = 1; i <= k; i++)
	{
		for (int j = 0; j <n; j++)
		{
			int len = 0, right, left = j - 1, st = j;
			if (s[j] == '0')
			{
				while (s[j] == '0' && j < n)
				{
					len++;
					j++;
				}
				right = j;
				j--;
				while (s[right] == '1' && right < n)
				{
					len++;
					right++;
				}
				while (left >= 0 && s[left] == '1' && left < n)
				{
					len++;
					left--;
				}
				if (len > max)
				{
					max = len;
					start = st;
					end = j;
				}
			}
			else
			{
				while (s[j] == '1' && j < n)
				{
					j++;
					len++;
				}
				if (len > max)
					max = len;
				j--;
			}
			
		}
		for (int l = start; l <= end; l++)
			s[l] = '1';
	}
	cout << max << endl;
	//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   13 |         gets(s);
      |         ^~~~
      |         getw
Language: C++

#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
	int n, k, start = 0, end = 0;
	char s[100001];
	cin >> n >> k;
	fflush(stdin);
	gets(s);
	int max = 0;
	for (int i = 1; i <= k; i++)
	{
		for (int j = 0; j < s.size(); j++)
		{
			int len = 0, right, left = j - 1, st = j;
			if (s[j] == '0')
			{
				while (s[j] == '0' && j < s.size())
				{
					len++;
					j++;
				}
				right = j;
				j--;
				while (s[right] == '1' && right < s.size())
				{
					len++;
					right++;
				}
				while (left >= 0 && s[left] == '1' && left < s.size())
				{
					len++;
					left--;
				}
				if (len > max)
				{
					max = len;
					start = st;
					end = j;
				}
			}
			else
			{
				while (s[j] == '1' && j < s.size())
				{
					j++;
					len++;
				}
				if (len > max)
					max = len;
				j--;
			}
			
		}
		for (int l = start; l <= end; l++)
			s[l] = '1';
	}
	cout << max << endl;
//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   13 |         gets(s);
      |         ^~~~
      |         getw
a.cc:17:39: error: request for member 'size' in 's', which is of non-class type 'char [100001]'
   17 |                 for (int j = 0; j < s.size(); j++)
      |                                       ^~~~
a.cc:22:61: error: request for member 'size' in 's', which is of non-class type 'char [100001]'
   22 |                                 while (s[j] == '0' && j < s.size())
      |                                                             ^~~~
a.cc:29:69: error: request for member 'size' in 's', which is of non-class type 'char [100001]'
   29 |                                 while (s[right] == '1' && right < s.size())
      |                                                                     ^~~~
a.cc:34:80: error: request for member 'size' in 's', which is of non-class type 'char [100001]'
   34 |                                 while (left >= 0 && s[left] == '1' && left < s.size())
      |                                                                                ^~~~
a.cc:48:61: error: request for member 'size' in 's', which is of non-class type 'char [100001]'
   48 |                                 while (s[j] == '1' && j < s.size())
      |                                                             ^~~~
Language: C++

#include <string>
#include <numeric>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int len = s.length();
  int A[100000] = {};
  int Asum[100000] = {};
  //int A[30] = {};
  //int Asum[30] = {};
  int j = 0;
  int count = 1;
  for (int i=1; i<len; i++){
    if (s[i-1] == s[i]) count += 1;
    else {
      A[j] = count;
      Asum[j] = Asum[j-1] + count;
      count = 1;
      j += 1;
    }
  }
  A[j] = count;
  Asum[j] = Asum[j-1] + count;
  for (int ii = j; ii<len; ii++) Asum[ii] = Asum[j-1] + count;
  //for (int i=0; i<10; i++){
  //  cout << Asum[i] << endl;
  //}
  
  int sum = 0;
  int sum_tmp = 0;
  int i = 0;
  if (s[0] == '0') {
    i = 1;
    sum = Asum[2*k-1];
    //cout << sum << endl;
  }
  while (A[i] != 0){
    //cout << "sum" << endl;
    sum_tmp = Asum[i+2*k] - Asum[i-1];
    if (sum_tmp >= sum) sum = sum_tmp;
    i = i+2;
  }
  
  cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> n >> k;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <numeric>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:48:3: error: 'cout' was not declared in this scope
   48 |   cout << sum << endl;
      |   ^~~~
a.cc:48:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:48:18: error: 'endl' was not declared in this scope
   48 |   cout << sum << endl;
      |                  ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <numeric>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

from itertools import groupby
n, k = map(int, input().split())
s = input()

t = []
if s[0] == "0":
    t.append(("1", 0))
for c, v in groupby(s):
    t.append((c, sum(1 for _ in v)))

if s[-1] == "0":
    t.append(("1", 0))

S = [t[0][1]]
rm = [0]
m = len(t)
for i in range(m//2):
    tmp = S[-1]
    S.append(tmp+t[2*i+1][1]+t[2*i+2][1])
    rm.append(tmp+t[2*i+1][1])

ans = []
for i in range(m//2+1):
    if i - k < 0:
        ans.append(S[i])
    else:
        ans.append(S[i]-rm[i-k])
print(max(ans))


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from itertools import groupby
      | ^~~~
Language: C++

#include <iostream>
#include <string>

using namespace std;

int check(string s, int p, int k) {
    char c = s[p];
    int t = 1;
    if(c == '0') k--;
    for(int i=p+1; i<s.size();i++){
        if(c!=s[i]) {
            if(c == '0') {
                c = '1';
            } else {
                if(k == 0) {
                    break;
                }
                k--;
                c = '0';
            }
        }
        t++;
    }

    return t;
}

int main()
{
    int n, k;
    string s;

    cin >> n >> k;
    cin >> s;
    char c;
    if(s[0] == '0') {
        c = '1';
    } else {
        c = '0';
    }

    int t = 0;
    for(int i=0; i < n; i++) {
        if(c!=s[i]) {
            t = max(t, check(s, i, k));
            c = s[i];
        }
    }
    cout << t << endl;

    return 0;
}
#include <iostream>
#include <string>

using namespace std;

int check(string s, int p, int k) {
    char c = s[p];
    int t = 1;
    if(c == '0') k--;
    for(int i=p+1; i<s.size();i++){
        if(c!=s[i]) {
            if(c == '0') {
                c = '1';
            } else {
                if(k == 0) {
                    break;
                }
                k--;
                c = '0';
            }
        }
        t++;
    }

    return t;
}

int main()
{
    int n, k;
    string s;

    cin >> n >> k;
    cin >> s;
    char c;
    if(s[0] == '0') {
        c = '1';
    } else {
        c = '0';
    }

    int t = 0;
    for(int i=0; i < n; i++) {
        if(c!=s[i]) {
            t = max(t, check(s, i, k));
            c = s[i];
        }
    }
    cout << t << endl;

    return 0;
}


Compiler output:
a.cc:58:5: error: redefinition of 'int check(std::string, int, int)'
   58 | int check(string s, int p, int k) {
      |     ^~~~~
a.cc:6:5: note: 'int check(std::string, int, int)' previously defined here
    6 | int check(string s, int p, int k) {
      |     ^~~~~
a.cc:80:5: error: redefinition of 'int main()'
   80 | int main()
      |     ^~~~
a.cc:28:5: note: 'int main()' previously defined here
   28 | int main()
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,k;
    string str;
    cin >> n >> k;
    cin >> str;

    vector<int> v;
    vector<int> mv;
    v.push_back(0);
    if(n==1) {
        cout << 1 << endl;
        return 0;
    }
    char c = str.at(0);
    int count = c == '0' ? -1 : 1;
    for(int i = 1; i < n; i++) {
        if(c == str.at(i)) {
            if(c == '0') count--;
            else count++;
        }
        else {
            if(c == '0') mv.push_back(v.size());
            v.push_back(count);
            c = str.at(i);
            count = c == '0' ? -1 : 1;
        }
    }
    v.push_back(count);

    v.push_back(0);

    for(int l = 0; l < k; l++) {
        int ti = -1;
        int tis = -1;
        int mvi = -1;
        int mvs = mv.size();
        for(int i = 0; i < mvs; i++) {
            if(v.at(mv.at(i)) < 0) {
                int m = v.at(mv.at(i)-1) + -1*v.at(mv.at(i)) + v.at(mv.at(i)+1);
                if(tis < m) {
                    ti = mv.at(i);
                    tis = m;
                    mvi = i;
                }
            }
        }
        if(tis > 0) {
            mv.erase(mv.begin() + mvi);
            int minus = 2 - ((mvi == 1 ? 1 : 0) + (mvi == v.size()-2 ? 1 : 0));
            for(int i = mvi; i < mv.size(); i++) {
                mv.at(i) -= minus;
                if(i != 
            }
            v.at(ti) = tis;
            if (ti+1 != v.size()-1) v.erase(v.begin() + ti+1);
            if (ti-1 != 0) v.erase(v.begin() + ti-1);
        }
    }
    int ans = 0;
    for(int i = 1; i < v.size() -1; i++) {
        if(ans < v.at(i)) ans = v.at(i);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:13: error: expected primary-expression before '}' token
   56 |             }
      |             ^
a.cc:55:24: error: expected ')' before '}' token
   55 |                 if(i !=
      |                   ~    ^
      |                        )
   56 |             }
      |             ~           
a.cc:56:13: error: expected primary-expression before '}' token
   56 |             }
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
    int cnt = 1, n, k, len, max = 0, sum;
    string s;
    vector<int> a;

    cin >> n >> k;
    cin >> s;

    if (s[0] == '0') {
        a.push_back(0);
    }

    for (int i = 1; i < s.length(); i++) {
        if (s[i - 1] == s[i]) {
            cnt++;
        } else {
            a.push_back(cnt);
            cnt = 1;
        }
    }
    a.push_back(cnt);
    len = (int)a.size();

    if (len <= 2 * k + 1) {
        max = accumulate(a.begin(), a.end(), 0);
        cout << max << endl;

        return 0;
    }

    for (int i = 0; i < 2 * k + 1; i++) {
        max += a[i];
    }

    for (int i = 2; i < len - 2 * k; i+=2) {
        sum -= a[i - 1] + a[i - 2];
        sum += a[2 * k - 1] + a[2 * k];

        if (sum > max) {
            max = sum;
        }
    }

    if (len % 2 == 0) {
        sum -= a[i - 1] + a[i - 2];
        sum += a[2 * k - 1];

        if (sum > max) {
            max = sum;
        }
    }
    cout << max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:18: error: 'i' was not declared in this scope
   48 |         sum -= a[i - 1] + a[i - 2];
      |                  ^
Language: C++


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n, k;
char s[100001];
int box[100001], num=0;
cin >> n>>k;
cin >> s;
char c=s[0];
for(int i=0;i<n;i++){
box[num]++;
if(i=n-1)break;
if(c!=s[i+1]){
c=s[i+1];
num++;
}
}
vector<int> vec(num-k+1,0);
for(int i=0;i<num-k;i++){
for(int j=0;j<k;j++)vec[i]+=box[i+j];
}

sort(vec.rbegin(), vec.rend());
cout << vec[0];
}

Compiler output:
a.cc:9:1: error: 'cin' does not name a type
    9 | cin >> n>>k;
      | ^~~
a.cc:10:1: error: 'cin' does not name a type
   10 | cin >> s;
      | ^~~
a.cc:12:1: error: expected unqualified-id before 'for'
   12 | for(int i=0;i<n;i++){
      | ^~~
a.cc:12:13: error: 'i' does not name a type
   12 | for(int i=0;i<n;i++){
      |             ^
a.cc:12:17: error: 'i' does not name a type
   12 | for(int i=0;i<n;i++){
      |                 ^
a.cc:21:1: error: expected unqualified-id before 'for'
   21 | for(int i=0;i<num-k;i++){
      | ^~~
a.cc:21:13: error: 'i' does not name a type
   21 | for(int i=0;i<num-k;i++){
      |             ^
a.cc:21:21: error: 'i' does not name a type
   21 | for(int i=0;i<num-k;i++){
      |                     ^
a.cc:25:5: error: expected constructor, destructor, or type conversion before '(' token
   25 | sort(vec.rbegin(), vec.rend());
      |     ^
a.cc:26:1: error: 'cout' does not name a type
   26 | cout << vec[0];
      | ^~~~
a.cc:27:1: error: expected declaration before '}' token
   27 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, k;
    string s;
    cin >> n >> k >> s;

    vector<int> v(n, 0);
    v[0] = (s[0] == '0' ? 1 : 0);

    REP(i, n-1){
        v[i+1] = v[i];
        if(s[i] == '1' && s[i+1] == '0') v[i+1]++;
    }

    int ans = 0;

    REP(i, v.back()){
        chmax(ans, lower_bound(all(v), i+k+1) - lower_bound(all(v), i));
    }

    cout << ans << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:14: error: no matching function for call to 'chmax(int&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   46 |         chmax(ans, lower_bound(all(v), i+k+1) - lower_bound(all(v), i));
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:26:27: note: candidate: 'template<class T> bool chmax(T&, const T&)'
   26 | template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}
      |                           ^~~~~
a.cc:26:27: note:   template argument deduction/substitution failed:
a.cc:46:14: note:   deduced conflicting types for parameter 'const T' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   46 |         chmax(ans, lower_bound(all(v), i+k+1) - lower_bound(all(v), i));
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,k,count=0,ans=0,i,j=0,l=0;
  	cin>>n>>k;
  	string s;
  	cin>>s;

  	vector<pair<ll,ll>> a;
  
  	for(i=0;i<n;i++){
		if(s[i]=='1'){
          l++;
          if(i==n-1){
				a.push_back(make_pair(l,j));
          }
        }else{
			if(i!=0&&s[i-1]=='1'){
         	 	a.push_back(make_pair(l,j));
         	 	l=0;
            }
          j=i+1;
        }
    }
 
    ll m=a.size();
  
  	vector<ll> b(m-1);
 	for(i=0;i<m-1;i++){
		b[i]=a[i+1].second-a[i].second+a[i+1].first;
    }f
  
  	ll c,max=0;

  	for(i=0;i<m-min(m,k)+1;i++){
      c=0;
      for(j=i;j<i+min(k,m);j++){
  		c+=b[j];
        if(j!=i){
          c-=a[j].first;
        }
      }
      if(c>max){
		max=c;
      }
    }

  	cout<<(m==1?n:max)<<endl;
      
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:6: error: 'f' was not declared in this scope
   32 |     }f
      |      ^
a.cc:37:7: error: 'c' was not declared in this scope
   37 |       c=0;
      |       ^
a.cc:49:23: error: overloaded function with no contextual type information
   49 |         cout<<(m==1?n:max)<<endl;
      |                       ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  long long N, K;
  string S;
  cin >> N >> K >> S;
  
  vector<long long> V;
  if (S.at(0) == '0') V.push_back(0);
  for (long long i = 1, cnt = 1; i < N; i++)
  {
    if (S.at(i - 1) == S.at(i)) cnt++;
    else 
    {
      V.push_back(cnt);
      cnt = 1;
    }
    if (i == N - 1) V.push_back(cnt);
  }
  if (S.at(N - 1) == '0') V.push_back(0);
  
  long long ans = 0;
  long long M = K * 2 + 1;
  int V.size() = L;
  if (M >= L) ans = N;
  else
  {
    for (int i = 0; i < L - M + 1; i += 2)
    {
      long long A = 0;
      for (int j = 0; j < M; j++)
      {
        A += V.at(i + j);
      }
      //cout << A << endl;
      chmax(ans, A);
    }
  }
  //cout << endl;
  
  //for (int i = 0; i < V.size(); i++) cout << V.at(i) << endl;
  //cout << endl;
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:8: error: expected initializer before '.' token
   34 |   int V.size() = L;
      |        ^
a.cc:35:12: error: 'L' was not declared in this scope
   35 |   if (M >= L) ans = N;
      |            ^
Language: C++

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n, k;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  scan(n); scan(k);
  string s;
  scan(s);

  vint a;
  vint cnt;

  vint a0, a1;
  int j=0;
  int a0num=0, a1num=0;
  REP(i, n){
    if(s[i]=='0') a0num++;
    else          a1num++;
    if(i!=n-1 && s[i]=='0' && s[i+1]=='1'){
      a0.pb(a0num);
      a1.pb(a1num);
      j++;
      a0num=0;
      a1num=0;
    }
    if(i==n-1){
      a0.pb(a0num);
      a1.pb(a1num);
      if(s[i-1]=='0'){
        a0.pb(0);
        a1.pb(0);
      }
    }
  }
  if(s[n-1]=='1') j=j-k+1;
  else
  vint sum;
  int sumnum=0;
  REP(i, j){
    for(int m=i; m<i+k; m++)  sumnum+=a0[m]+a1[m];
    sumnum+=a1[i+k];
    sum.pb(sumnum);
    sumnum=0;
  }

  int res;
  if(j<=0)  res = n;
  else      res = *max_element( ALL(sum) );
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:5: error: 'sum' was not declared in this scope
   79 |     sum.pb(sumnum);
      |     ^~~
a.cc:85:37: error: 'sum' was not declared in this scope
   85 |   else      res = *max_element( ALL(sum) );
      |                                     ^~~
a.cc:23:19: note: in definition of macro 'ALL'
   23 | #define ALL(obj) (obj).begin(), (obj).end()
      |                   ^~~
Language: C++


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int K=scan.nextInt();
		String c=scan.next();
		List <Integer>list=new ArrayList<Integer>();
		int count=0;
		int mina=0;
		int zeon=c.charAt(0)=='0'?0:1;
		for(int i=0;i<a;i++) {
			if(i==a-1) {
				if(c.charAt(i)=='1') {
					list.add(count+1);
					break;
				}
			}
			if(c.charAt(i)=='1') {
				if(mina!=0) {
					list.add(mina);
				}
				mina=0;
				count++;
			}
			else {
				if(count!=0) {
				list.add(count);
				}
				mina++;
				count=0;
			}
		}
		int co=0;
		int ans=0;
		if(zeon==0) {
			for(int i=0;i<list.size();i++) {
				co+=list.get(i);
				if(i>K*2) {//ex:001001100 3→2,1,2,2,2
					co-=list.get(i-K);
				}
			}
		}
		else {
			
		}
		System.out.println(ans);
	}
}

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.ArrayList;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.List;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.Scanner;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    vector<int> a;
    if (s[0] == '0') {
        a.push_back(0);  
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        ++cnt;
        if (i < n - 1 && s[i] != s[i + 1]) {
            a.push_back(cnt);
            cnt = 0;            
        }
    }
    if (cnt) {
        a.push_back(cnt);  
    }
    //cout << "division: " << endl;
    /*for (int i = 0; i < a.size(); ++i) {
        cout << a[i] << ' ';
    }
    cout << endl;*/
    vector<int> suma(a.size() + 1, 0);
    for (int i = 1; i <= a.size(); ++i) {
        suma[i] = suma[i - 1] + a[i - 1];  
    }
      
    int ans = 0;
    for (int i = 0; i < a.size(); i += 2) {
        int r = i + 2 * k;        
        int cursum;
        if (r >= a.size()) {
            r = a.size() - 1;  
        }
        ans = max(ans, suma[r + 1] - suma[i]);
        //cout << "sum of interval [" << i << ", "<< r << "] -> " << suma[r + 1] - suma[i] << endl;
    }
    //cout << "ans = ";
    cout << ans;
    return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:46:14: error: expected '}' at end of input
   46 |     return 0;
      |              ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++


#include<iostream>
#include<algorithm>
#include<vector>
usimg namespace std;
int n, k;
char s[100001];
int box[100001], num=0;
cin >> n>>k;
cin >> s;
char c=s[0];
for(int i=0;i<n;i++){
box[num]++;
if(i=n-1)break;
if(c!=s[i+1]){
c=s[i+1];
num++;
}
}
vector<int> vec(num-k+1,0);
for(int i=0;i<num-k;i++){
for(int j=0;j<k;j++)vec[i]+=box[i+j];
}

sort(vec.rbegin(), vec.rend());
cout << vec[0];
}

Compiler output:
a.cc:5:1: error: 'usimg' does not name a type
    5 | usimg namespace std;
      | ^~~~~
a.cc:9:1: error: 'cin' does not name a type
    9 | cin >> n>>k;
      | ^~~
a.cc:10:1: error: 'cin' does not name a type
   10 | cin >> s;
      | ^~~
a.cc:12:1: error: expected unqualified-id before 'for'
   12 | for(int i=0;i<n;i++){
      | ^~~
a.cc:12:13: error: 'i' does not name a type
   12 | for(int i=0;i<n;i++){
      |             ^
a.cc:12:17: error: 'i' does not name a type
   12 | for(int i=0;i<n;i++){
      |                 ^
a.cc:20:1: error: 'vector' does not name a type
   20 | vector<int> vec(num-k+1,0);
      | ^~~~~~
a.cc:21:1: error: expected unqualified-id before 'for'
   21 | for(int i=0;i<num-k;i++){
      | ^~~
a.cc:21:13: error: 'i' does not name a type
   21 | for(int i=0;i<num-k;i++){
      |             ^
a.cc:21:21: error: 'i' does not name a type
   21 | for(int i=0;i<num-k;i++){
      |                     ^
a.cc:25:5: error: expected constructor, destructor, or type conversion before '(' token
   25 | sort(vec.rbegin(), vec.rend());
      |     ^
a.cc:26:1: error: 'cout' does not name a type
   26 | cout << vec[0];
      | ^~~~
a.cc:27:1: error: expected declaration before '}' token
   27 | }
      | ^
Language: C++

#include <algorithm>
#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;

  string s;
  cin >> s;

  int max = 0;
  int count01 = 0;
  int point_list[110000];
  point_list[0] = 0;
  for(int j = 0; j < n - 1; ++j){
    if(s[j] == "0" & s[j+1] == "1"){
      count01++;
      point_list[count01] = j + 1;
      if(count01 >= k){
        hoge = point_list[count01] - point_list[count01 - 2 ]
        if (max < hoge){
          max = hoge;
        }
      }
    }
  }
  count << max << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |     if(s[j] == "0" & s[j+1] == "1"){
a.cc:16:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |     if(s[j] == "0" & s[j+1] == "1"){
a.cc:20:9: error: 'hoge' was not declared in this scope
   20 |         hoge = point_list[count01] - point_list[count01 - 2 ]
      |         ^~~~
a.cc:27:9: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator<<'
   27 |   count << max << endl;
      |   ~~~~~~^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    string s; cin >> s;
    
    vector<int> handstands(n, 0);
    
    int before_last_one_cur = -1, last_one_cur = 0; int h = 0; int remaining = m; bool before_bit = false;
    for (int cur = 0; cur < s.size(); ++cur) {
        if (before_last_one_cur == last_one_cur) {
            if (s[cur] == '1') {
                last_one_cur = cur;
            } else {
                continue;
            }
        }
        if (s[cur] == '1') {
            if (!before_bit) {
                before_last_one_cur = last_one_cur;
                last_one_cur = cur;
            }

            h++;

            if (!before_bit && cur != 0) {
                remaining--;
                if (remaining == 0) {
                    handstands.push_back(h);
                    cur = last_one_cur - 1;
                    h = 0;
                    remaining = m;
                }
            }
            before_bit = true;
        } else {
            before_bit = false;
            if (cur == s.size() -1) {
                if (remaining) h++;
                handstands.push_back(h);
                break;
            }
            if (!before_bit && cur != 0) {
                h++;
                continue;
            }

            h++;
        }
    }
    
    cout << *max_element(handstands.begin(), handstands.end()) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:14: error: 'max_element' was not declared in this scope
   57 |     cout << *max_element(handstands.begin(), handstands.end()) << endl;
      |              ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> dist;
    // 01001001001001
    // 1回ひっくり返せるとき、1箇所の1-0-1区間がつなげられる
    // 2回ひっくり返せるとき、２か所の1-0-1-0-1区間がつなげられる
    // 3回ひっくり返せるとき、３か所の1-0-1-0-1-0-1区間がつなげられる
    // 1-0-1-0-1-0-1の数を求めてやる
    // 1から2K+1この数の和が最大になるような区間を求めればよい
    if (S[0] == '0') dist.push_back(0);
    int len = 1;
    for (int i=0;i<N;i++){
        if (i == N -1) {
            dist.push_back(len);
            break;
        }
        if (S[i] != S[i+1]){
            dist.push_back(len);
            len = 1;
        } else {
            len++;
        }
    }
    if (S[N-1] == '0') dist.push_back(0);
    
    for (int i=0;i<dist.size();i++) cout << dist[i] << endl;

    int ans = 0;
    if (2*K+1 <= dist.size()){
        int initial = 0;
        for (int i=0;i<2*K+1;i++){
            initial += dist[i];
        }
        ans = initial;
        int d;
        for (int i=2;i<dist.size() - 2*K + 1;i=i+2){
            d = ans - dist[i-2] - dist[i-1] + dist[i+2*K-1] + dist[i+2*K]
            ans = max(ans, d);
            cout << ans << endl;
        }
    } else {
        for (int i=0;i<dist.size();i++){
            ans += dist[i];
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:74: error: expected ';' before 'ans'
   47 |             d = ans - dist[i-2] - dist[i-1] + dist[i+2*K-1] + dist[i+2*K]
      |                                                                          ^
      |                                                                          ;
   48 |             ans = max(ans, d);
      |             ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<n;i++)
#define ll long long

int ahan(string s,int k){
    int n=s,size();
    int x=0,y=0;
    int z[100100];
    int j=0;
    int i=0;
    while(i,n){
        if(s[i]=='0' && x==1){
            z[j]=y;
            j++;
            x=0;
            y=0;
            y++;
            i++;
        }
        else if(s[i]==0 && x==0){
            y++;
            i++;
        }
        else if(s[i]==1 && x==0){
            z[j]=-y;
            j++;
            x=1;
            y=0;
            y++;
            i++;
        }
        else {
            y++;
            i++;
        }
    }
    int max=0;
    int u[100000];
    int c=0;
    for(int p=0;p+k<n&&c<=k;p++){
        for(int q=p;c<=k;q++){
            u[p]+=z[q];
        }
    }
    rep(w,100000){
        max=max(max,u[w])
    }
    return max;
}

int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    cout<<ahan(s,k)<<endl;
}

Compiler output:
a.cc: In function 'int ahan(std::string, int)':
a.cc:8:11: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int' in initialization
    8 |     int n=s,size();
      |           ^
      |           |
      |           std::string {aka std::__cxx11::basic_string<char>}
a.cc:8:17: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
    8 |     int n=s,size();
      |                 ^~
a.cc:8:17: note: remove parentheses to default-initialize a variable
    8 |     int n=s,size();
      |                 ^~
      |                 --
a.cc:8:17: note: or replace parentheses with braces to value-initialize a variable
a.cc:48:16: error: 'max' cannot be used as a function
   48 |         max=max(max,u[w])
      |             ~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int sum[100005];
int main() {
  int n,k;
  cin>>n>>k;
  string s1;
  cin>>s1;
  int s[100005];
  for (int i=0; i<n; i++) {
    s=s[i]-'0';
  }
  int i=0,j=0;
  while (i<n) {
    int x=s[i],sum1=0;
    while (i<n) {
      if (s[i]==x) {
	sum1++;
	i++;
      }
      else {
	sum[j]=sum1;
	j++;
	break;
      }
    }
  }
  int ans=0,add;
  if (s[0]==0) {
    if (k*2<=j+1) {
      add=0;
      for (int l=0; l<k*2; l++) {
	add+=sum[l];
      }
      ans=max(add,ans);
    }
  }
  if (s[n-1]==0) {
    if (k*2<=j+1) {
      add=0;
      for (int l=n-1; l<k*2; l--) {
	add+=sum[l];
      }
      ans=max(add,ans);
    }
  }
  if (k*2+1<=j) {
    for (int l=(s[0]? 0:1); l+k*2<=j-1; l+=2) {
      add=0;
      for (int m=0; m<k*2+1; m++) {
	add+=s[l+m];
      }
      ans=max(ans,add);
    }
  }
  else ans=n;
    
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:6: error: incompatible types in assignment of 'int' to 'int [100005]'
   12 |     s=s[i]-'0';
      |     ~^~~~~~~~~
Language: C++

#include <string>

using namespace std;

int main()
{
    string s;
    int n,k;
    cin >> n >> k;
    cin >> s;
    int a=0,b=0,to=0,c=0,last=0;
    char l='0';
    while(to<(n-last))
    {
        a=0;
        while(to<n&&a<=k)
        {
            if((s[to]==l&&to!=b&&s[to-1]!=l)||(to==b&&s[to]==l))
                {
                    a++;
                }
            to++;
        }
        if(a==(k+1))
        c=to-b-1;
        ++b;
        to=b;
        if(c>last)
            last=c;
    }
    cout << last << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin >> n >> k;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <string>
  +++ |+#include <iostream>
    2 | 
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout << last << endl;
      |     ^~~~
a.cc:31:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:31:21: error: 'endl' was not declared in this scope
   31 |     cout << last << endl;
      |                     ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <string>
  +++ |+#include <ostream>
    2 |
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> vec;
  vec = {};
  int k = 1;
  for (int i = 1; i < N; i++) {
    
    if ( S.at(i - 1) == S.at(i)){
      k ++;
    }
    else{
      vec.push_back(k);
      k = 1;
    }
  }
  int maxsum = 0;
  if ( S.at(0) == '1'){
    if ( vec.size () / 2 <= Q ){
      cout << N << endl;
    }
    else {
      for ( int i = 1; i < vec.size () / 2  - 1; i ++){
        int sum = 0;
        for ( int j = 2 * i -; j < 2 * i + 2 * Q  ; j++){
          sum += vec.at(j);
        }
        if (maxsum < sum){
          maxsum = sum;
        }
      }
    }
  } 
  if ( S.at(0) == '0'){
    if ( vec.size () / 2 + 1<= Q ){
      cout << N << endl;
    }
    else {
      for ( int i = 1; i < vec.size () / 2 ; i ++){
        int sum = 0;
        for ( int j = 2 * 1; j < 2 * i + 2 * Q - 1  ; j++){
          sum += vec.at(j);
        }
        if (maxsum < sum){
          maxsum = sum;
        }
      }
    }
  }
  cout << maxsum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:30: error: expected primary-expression before ';' token
   30 |         for ( int j = 2 * i -; j < 2 * i + 2 * Q  ; j++){
      |                              ^
Language: C++

#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
typedef long long ll;

int main() {
    int N;
    int K;
    cin >> N >> K;
    string s;
    cin >> s;
    int ans,tmp=0;
    ans = 0;
    queue<int> q;
    bool n0=false;//今ゼロか
    int zs=0;//ゼロ塊が何回来たか
    for(int i=0;i!=N;i++){
        tmp++;
        if(s[i]=='0'){
            if(n0==false){
                zs++;
                n0=true;
            }
            if(zs>K){
                tmp--;
                if(ans<tmp){
                    ans=tmp;
                }
                if(K!=1){
                    zs = zs-2;
                    tmp = tmp - q.front();
                }
                else{
                    zs=0;
                    tmp=0;
                }
                n0=false;
                i--;
            }
        }
        else{
            if(n0==true){
                n0=false;
                if(zs!=0&&zs<K+1){
                    if(q.size()==K){
                        q.pop(0);
                        q.push(i);
                    }
                    else{
                        q.push(i);
                    }
                }
            }
        }
    }
    if(tmp>ans){
        ans=tmp;
        cout << ans << endl;
    }
    else{
        cout << ans << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:30: error: no matching function for call to 'std::queue<int>::pop(int)'
   48 |                         q.pop(0);
      |                         ~~~~~^~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:316:7: note: candidate: 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]'
  316 |       pop()
      |       ^~~
/usr/include/c++/14/bits/stl_queue.h:316:7: note:   candidate expects 0 arguments, 1 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;

    int tmp = 0;
    vector<int> zero_cnt(N);
    for (int i = 0; i < N; i++) {
        zero_cnt.at(i) = 0;
    }
    for (int i=0;i<N;i++){
        if (S.at(i)=='0') {
            tmp = tmp+1;
            if (i==(N-1)){
                zero_cnt.at(i) = tmp;
            }
        }else{
            zero_cnt.at(i-1)=tmp;
            tmp = 0;   
        }
    }
    sort(zero_cnt.begin(), zero_cnt.end());
    reverse(zero_cnt.begin(), zero_cnt.end());
    int count = 0;
    for (int i=0;i<K;i++){
        if (zero_cnt.at(i)!=0){
            count = count + 1;
        }
    }
    
    int tmp2 = 0;
    vector<int> zero_cnt2(N);
    for (int i = 0; i < N; i++) {
        zero_cnt2.at(i) = 0;
    }
    for (int i=0;i<N;i++){
        if (S.at(i)=='1') {
            tmp2 = tmp2+1;
            if (i==(N-1)){
                zero_cnt2.at(i) = tmp2;
            }
        }else{
            zero_cnt2.at(i-1)=tmp2;
            tmp2 = 0;   
        }
    }
    
    for (int i=0;i<count;i++){
        int t = *max_element(zero_cnt2.begin(), zero_cnt2.end());
        cout << t << endl;
        for (int j=0;j<zero_cnt2.at(t);j++){
            S.at(t-j)=1;
        }
    }
	cout << t << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:17: error: 't' was not declared in this scope
   59 |         cout << t << endl;
      |                 ^
Language: C++


#include <iostream>
#include <string>

using namespace std;

int main(){
    int N,K;
    string S(100000,'0');
    cin >> N >> K;
    cin >> S;
    int count = 0;
    int length = 0;
    for(int k = 0;k < N;k++){
        string S1 = S;
        if(S1[k] == '0'){
            for(int i = k;i < N;i++){
                    for(int j = i;j < N;j++){
                        if(S1[j] == '0'){
                            S1[j] = '1';
                        }else{
                            i = j;
                            k = j;
                            break;
                        }
                    }
                    count ++;
                    //cout << S1 << endl;
                if(count == K){
                    //cout << count;
                    break;
                }
            }
        }
        for(int i = 0;i < N;i++){
                if(S1[i] == '1'){
                    if(i == N -1){
                        length =max(length,1);
                    }
                    for(int j = i;j < N + 1;j++){
                        if(S1[j] == '0'){
                            //cout << length << endl;
                            if(i == 0){
                            length = max(length,j-i);
                            }
                            else{
                                length = max(lengh,j-i+1);
                            }
                            i = j;
                        }
                    }
                }
            }
    }
    cout << length << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:46: error: 'lengh' was not declared in this scope; did you mean 'length'?
   47 |                                 length = max(lengh,j-i+1);
      |                                              ^~~~~
      |                                              length
Language: C++

//handstand
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;

	vector<int> vec;

	int count = 0;
	int tmp = 0;
	char cur = s[0];
	while(1){
		if (s[count] == cur){
			tmp++;
		}else{
			vec.push_back(tmp);
			tmp = 1;
			if (cur == '1'){
				cur = '0';
			}else{
				cur = '1';
			}
		}
		count ++;
		if(count == n){
			vec.push_back(tmp);
			break;
		}
	}

	if(s[0] == '0'){
		vec.insert(vec.begin(),0);
	}
	if(s[n-1] == '0'){
		vec.push_back(0);
	}

	if(vec.size < k*2+1){
		int sum = 0;
		for (int i = 0; i < vec.size(); ++i)
		{
			sum+=vec[i];
		}
		cout << sum << endl;
	}else{
		int times = vec.size()/2-k+1;
		int max = 0;
		for (int i = 0; i < times; i++)
		{
			int index = i*2;
			int t = 0;
			for (int j = index; j < index+k*2+1; ++j)
			{
				t += vec[j];
			}
			if(t>max){max = t;}
			// cout << t << endl;
		}
		cout << max << endl;
	}

	// for (int i = 0; i < vec.size(); ++i)
	// {
	// 	cout << vec[i];
	// }
	// cout<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:43:16: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   43 |         if(vec.size < k*2+1){
      |            ~~~~^~~~
      |                    ()