criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		String str = scanner.next();
		String[] strArray = str.split("");
		String firstPose = strArray[0];
		int i = 0;
		int[] lenArray = new int[n];
		int lenNum = 0;
		while (i < strArray.length) {
			while (i < strArray.length && firstPose.equals(strArray[i])) {
				lenArray[lenNum]++;
				i++;
			}

			while (i < strArray.length && !firstPose.equals(strArray[i])) {
				lenArray[lenNum]++;
				i++;
			}

			lenNum++;
		}
		if (strArray.length > 1) {
		if (strArray[0].equals("1")) {
			lenArray[1] += lenArray[0];
			lenArray[0] = 0;
		}
		
		if (strArray[n-1].equals("1")) {
			lenArray[lenNum - 2] += lenArray[lenNum -1];
			lenArray[lenNum -1] = 0;
		}
		}
		
		int result = 0;
		for (int j = 0; j < lenNum - k + 1; j++) {
			int tmp = 0;
			for (int l = 0; l < k; l++) {
				tmp += lenArray[l+j];
			}
			if (tmp > result) {
				result = tmp;
			}
			tmp = 0;
		}
		System.out.println(result);
		
	}

Compiler output:
Main.java:52: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

#include <cstdio>

char str[100010];
int arr[100010], top;

int main()
{
  int len, i, k, flg;
  scanf("%d%d", &len, &k);
  scanf("%s", str);
  
  top = 0;
  arr[0] = 1;
  for(i = 1; i < len; i++){
    if(str[i] != str[i - 1]) top++;
    arr[top++];
    if(str[i] == str[i - 1]) arr[top]++;
  }
  top++;

  if(str[0] == '0') flg = 1;
  
  int now, res = 0;
  for(i = 0; i < top; i++){
    if(flg xor (i % 2)) k--;
    if(k < 0) break;
    res += arr[i];
  }
  itn fnt, lst;
  fnt = 0, lst = i;

  if(i == top){
    print("%d\n", res);
    return 0;
  }

  now = res;
  while(lst < top){
    now -= arr[fnt];
    if((fnt % 2) xor flg){
      while(lst < top){
        now += arr[lst];
        lst++;
        if((!(lst % 2)) xor flg) break;
      }
      if(now > res) res = now;
    }
    fnt++;
  }
  printf("%d\n", res);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:3: error: 'itn' was not declared in this scope; did you mean 'int'?
   29 |   itn fnt, lst;
      |   ^~~
      |   int
a.cc:30:3: error: 'fnt' was not declared in this scope; did you mean 'int'?
   30 |   fnt = 0, lst = i;
      |   ^~~
      |   int
a.cc:30:12: error: 'lst' was not declared in this scope
   30 |   fnt = 0, lst = i;
      |            ^~~
a.cc:33:5: error: 'print' was not declared in this scope; did you mean 'printf'?
   33 |     print("%d\n", res);
      |     ^~~~~
      |     printf
Language: C++

#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k;
string s;

int main(){
	cin >> n >> k >> s;
	vector<ll> v;
	
	bool start = (s[0] == 0);
    bool isst = false;
	bool noww = start;
	ll block = 0;
	for(ll i = 0; i < n; i++){
		if(!isst){isst = true;}
		else{
			if(s[i] == '0'){
				if(!noww){
					v.push_back(block);
					noww = true;
					block = 0;
				}
			}
			else{
				if(noww){
					v.push_back(block);
					noww = false;
					block = 0;
				}
			}
		}
		block++;
		if(i == n-1){v.push_back(block);}
	}
	if(s[n-1] == '0'){v.push_back(0);}
	
	ll m = v.size();
	for(ll j = 1; j < m; j++){v[j] += v[j-1];}
	
	ll ans = 0;
	if(start){
		if(m <= 2*k){ans = v[m-1];}
		else{
			ans = v[2*k-1];
			for(ll ki = 0; 2*ki+2*k+1 < m; ki++){
				ans = max(v[2*ki+2*k+1]-v[2*ki], ans);
			}
		}
	}
	else{
		if(m <= 2*k+1){ans = v[m-1];}
		else{
			ans = v[2*k];
			for(ll ki = 0; 2*ki+1+2*k+1 < m; ki++){
				ans = max(v[2*ki+1+2*k+1]-v[2*ki+1], ans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k;
string s;

int main(){
	cin >> n >> k >> s;
	vector<ll> v;
	
	bool start = (s[0] == 0);
    bool isst = false;
	bool noww = start;
	ll block = 0;
	for(ll i = 0; i < n; i++){
		if(!isst){isst = true;}
		else{
			if(s[i] == '0'){
				if(!noww){
					v.push_back(block);
					noww = true;
					block = 0;
				}
			}
			else{
				if(noww){
					v.push_back(block);
					noww = false;
					block = 0;
				}
			}
		}
		block++;
		if(i == n-1){v.push_back(block);}
	}
	if(s[n-1] == '0'){v.push_back(0);}
	
	ll m = v.size();
	for(ll j = 1; j < m; j++){v[j] += v[j-1];}
	
	ll ans = 0;
	if(start){
		if(m <= 2*k){ans = v[m-1];}
		else{
			ans = v[2*k-1];
			for(ll ki = 0; 2*ki+2*k+1 < m; ki++){
				ans = max(v[2*ki+2*k+1]-v[2*ki], ans);
			}
		}
	}
	else{
		if(m <= 2*k+1){ans = v[m-1];}
		else{
			ans = v[2*k];
			for(ll ki = 0; 2*ki+1+2*k+1 < m; ki++){
				ans = max(v[2*ki+1+2*k+1]-v[2*ki+1], ans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:69:2: error: stray '#' in program
   69 | }#include <iostream>
      |  ^
a.cc:69:3: error: 'include' does not name a type
   69 | }#include <iostream>
      |   ^~~~~~~
a.cc:79:4: error: redefinition of 'll n'
   79 | ll n, k;
      |    ^
a.cc:11:4: note: 'll n' previously declared here
   11 | ll n, k;
      |    ^
a.cc:79:7: error: redefinition of 'll k'
   79 | ll n, k;
      |       ^
a.cc:11:7: note: 'll k' previously declared here
   11 | ll n, k;
      |       ^
a.cc:80:8: error: redefinition of 'std::string s'
   80 | string s;
      |        ^
a.cc:12:8: note: 'std::string s' previously declared here
   12 | string s;
      |        ^
a.cc:82:5: error: redefinition of 'int main()'
   82 | int main(){
      |     ^~~~
a.cc:14:5: note: 'int main()' previously defined here
   14 | int main(){
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

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

  vi zero_endpts;
  vi one_endpts;
  

  for (int i=0;i<N;++i){
    if(i==N-1){
      if(S[i]=='0'){zero_endpts.push_back(i+1);}
      else{one_endpts.push_back(i+1);}
    }
    else{
      if(S[i]=='0'&&S[i+1]=='1'){zero_endpts.push_back(i+1);}
      else if (S[i]=='1'&&S[i+1]=='0'){one_endpts.push_back(i+1);}
    }
  }

  int ans=0;

  int M=zero_endpts.size();
  int L=one_endpts.size();

  if(M<=K){ans=N;}
  else if(L==0){}
  else{
    if(S[0]=='0'){
      int best_score=one_endpts[K-1];
      for(int i=K;i<M;++i){
        if(zero_endpts[i]!=N-1){
          best_score=max(best_score,one_endpts[i]-zero_endpts[i-K]);
        }
        else{
          best_score=max(best_score, zero_endpts[i]-zero_endpts[i-K]);
        }
      }
      ans =best_score;
    }

    else{
      if(L>=K+1){int best_score=one_endpts[K];}
      else{int best_score=N;}
      
      for (int i=K;i<M;++i){
        if(zero_endpts[i]!=N-1){
          best_score=max(best_score,one_endpts[i+1]-zero_endpts[i-K]);
        }
        else{
          best_score=max(best_score, zero_endpts[i]-zero_endpts[i-K]);
        }
      }
      ans=best_score;
    }

  }
  

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

Compiler output:
a.cc: In function 'int main()':
a.cc:51:11: error: 'best_score' was not declared in this scope
   51 |           best_score=max(best_score,one_endpts[i+1]-zero_endpts[i-K]);
      |           ^~~~~~~~~~
a.cc:54:11: error: 'best_score' was not declared in this scope
   54 |           best_score=max(best_score, zero_endpts[i]-zero_endpts[i-K]);
      |           ^~~~~~~~~~
a.cc:57:11: error: 'best_score' was not declared in this scope
   57 |       ans=best_score;
      |           ^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

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

  vi zero_endpts;
  vi one_endpts;
  

  for (int i=0;i<N;++i){
    if(i==N-1){
      if(S[i]=='0'){zero_endpts.push_back(i+1);}
      else{one_endpts.push_back(i+1);}
    }
    else{
      if(S[i]=='0'&&S[i+1]=='1'){zero_endpts.push_back(i+1);}
      else if (S[i]=='1'&&S[i+1]=='0'){one_endpts.push_back(i+1);}
    }
  }

  int ans=0;

  int M=zero_endpts.size();
  int L=one_endpts.size();

  if(M<=K){ans=N;}
  else if(L==0){}
  else{
    if(S[0]=='0'){
      int best_score=one_endpts[K-1];
      for(int i=K;i<M;++i){
        if(zero_endpts[i]!=N-1){
          best_score=max(best_score,one_endpts[i]-zero_endpts[i-K]);
        }
        else{
          best_score=max(best_score, zero_endpts[i]-zero_endpts[i-K]);
        }
      }
      ans =best_score;
    }

    else{
      if(L>=K+1){int best_score=one_endpts[K];}
      else{best_score=N;}
      
      for (int i=K;i<M;++i){
        if(zero_endpts[i]!=N-1){
          best_score=max(best_score,one_endpts[i+1]-zero_endpts[i-K]);
        }
        else{
          best_score=max(best_score, zero_endpts[i]-zero_endpts[i-K]);
        }
      }
      ans=best_score;
    }

  }
  

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

Compiler output:
a.cc: In function 'int main()':
a.cc:47:12: error: 'best_score' was not declared in this scope
   47 |       else{best_score=N;}
      |            ^~~~~~~~~~
a.cc:51:11: error: 'best_score' was not declared in this scope
   51 |           best_score=max(best_score,one_endpts[i+1]-zero_endpts[i-K]);
      |           ^~~~~~~~~~
a.cc:54:11: error: 'best_score' was not declared in this scope
   54 |           best_score=max(best_score, zero_endpts[i]-zero_endpts[i-K]);
      |           ^~~~~~~~~~
a.cc:57:11: error: 'best_score' was not declared in this scope
   57 |       ans=best_score;
      |           ^~~~~~~~~~
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		String S = scan.next();
		int[] n = new int[N];
		
		int index = 0;
		int count = 1;
		char cur = S.charAt(0);
		char cur_c = cur;
		for (int i = 0; i < N; i++) {
			if (i == N - 1 || cur != S.charAt(i + 1)) {
				n[index++] = count;
				count = 0;
				if (i != N - 1)
					cur = S.charAt(i + 1);
			}
			count++;
		}
//		System.out.println(Arrays.toString(n));
		int sum = 0;
		for (int j = 0; j < K + (K + (cur_c == '1' ? 1 : 0)); j++)
			sum += n[j];
//		System.out.println(sum);
		int max = sum;
		if (cur_c == '0') {
			max = sum;
			sum = 0;
			for (int j = 1; j < K + (K + 2); j++)
				sum += n[j];
//			System.out.println(sum);
			max = Math.max(max, sum);
		}
		for (int i = (cur_c == '1' ? 0 : 1); i < index; i+= 2) {
//			System.out.println("m: " + n[i] + ", " + n[i + 1] + ", p: " + n[i + (K * 2 + 1)] + ", " + n [i + (K * 2 + 2)]);
			sum = sum - (n[i] + n[i + 1]) + (n[i + (K * 2 + 1)] + n [i + (K * 2 + 2)]);
//			System.out.println(sum);
			max = Math.max(max, sum);
		}
		System.out.println(max);
	}
    public static void main(String[] args) {
    	new Main().run();
    }

Compiler output:
Main.java:49: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

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

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

    int n,k;
    string s;
    cin >> n >> k >> s;
    vector<int> narabi;

    char nowmark = s[0];
    int count = 1;
    for(int i=1; i<n; i++){

        if(nowmark != s[i]){
            narabi.push_back(count);
            nowmark = s[i];
            count = 1;
        }else{
            count ++;
        }
    }
    narabi.push_back(count);
    // for(int i=0; i<narabi.size(); i++){
    //     cout << narabi[i];
    // }
    // cout << endl;

    int max = 0;
    int first_sakadachi;
    if(s[0] == '1'){
        first_sakadachi = 0;
    }else{
        first_sakadachi = 1;
    }

    int table[k+1][narabi.size()] = {};
    for(int i=first_sakadachi; i<narabi.size(); i+=2){
        table[0][i] = narabi[i];
        if(max < table[0][i]){
            max = table[0][i];
        }
    }

    for(int i=1; i<=k; i++){
        if(first_sakadachi == 1){
            if(vector.size() > 1){
                table[i][0] = table[i-1][1] + narabi[0];
                if(max < table[i][0]){
                    max = table[i][0];
                }
            }
        }
        for(int j=first_sakadachi; j+2*i <= narabi.size(); j+=2){
            if (j+2*i != narabi.size()){
                table[i][j] = table[i-1][j] + narabi[j+2*i] + narabi[j+2*i-1];
            }else{
                table[i][j] = table[i-1][j] + narabi[j+2*i-1];
            }
            if(table[i][j] > max){
                max = table[i][j];
            }
        }
    }
    
    cout << max << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:22: error: expected unqualified-id before '.' token
   53 |             if(vector.size() > 1){
      |                      ^
Language: C++

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



int main(){
  int a,b;
  cin >> a >> b;
  int c[50000] = {};
  int d = 0;//cのカウント
  int e = 0;//連続数のカウント
  char num = '2';//0か1か
  char fnum;//はじめの文字
  char f;
  int count = 0;
    cin >> f;
    fnum = f;
    e = 1;
    num = f;
    while(cin >> f){
      if(count == a){
        c[d] = e;
        e = 1;
        num = f;
        d++;
        break;
      }
      if(num == f){
        e++;
      }else{
        c[d] = e;
        e = 1;
        num = f;
        d++;
      }
      count++;

    }
  if(d < b*2-1){
    cout << a << endl;
    ruturn 0;
  }
  int big;
  int kari;
  for(int i = 0;i < d-b*2+2;i = i+2){
    if(fnum == '0'){
      if(i == 0){
        for(int j = 0;j < b*2-1;j++){
          kari += c[j];
        }
        big = kari;
      }else{
        kari = kari - c[i-2] - c[i-3];
        kari = kari + c[i+b*2-2] + c[i+b*2-1];
        if(big < kari){
          big = kari;
        }
      }
    }else{
      if(i == 0){
        for(int j = 0;j < b*2+1;j++){
          kari += c[j];
        }
        big = kari;
      }else{
        kari -= c[i-2];
        kari -= c[i-1];
        kari += c[i+b*2-1];
        kari += c[i+b*2];
        if(big < kari){
          big = kari;
        }
      }
    }
  }

  cout << big-1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:5: error: 'ruturn' was not declared in this scope
   41 |     ruturn 0;
      |     ^~~~~~
Language: Java

import java.util.*;
public class abc124d {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		String S = sc.next();
		long ans1 = 0, ans = 0;
		List<Integer> a = new ArrayList<>();
		long con = 1;
		if(N == 1)
			a.add(1);
		else if(S.charAt(0) != S.charAt(1))
			a.add(1);
		for(int i = 1; i < N; i++) {
			if(S.charAt(i) == S.charAt(i-1)) {
				con += 1;
			}
			else {
				a.add(con);
				con = 1;
			}
			if(i == N-1)
				a.add(con);
		}
		if(S.charAt(0) == '1') {
			LOOP:for(int i = 0; i < a.size(); i += 2) {
				ans1 = 0;
				for(int j = i; j <= i + K*2 && j < a.size(); j++) {
					ans1 += a.get(j);
				}
				ans = Math.max(ans, ans1);
				if(i + K*2 >= a.size())
					break LOOP;
			}
		}
		else {
			for(int i = 0; i < K*2 && i < a.size(); i++)
				ans += a.get(i);
			LOOP:for(int i = 1; i < a.size(); i += 2) {
				ans1 = 0;
				for(int j = i; j <= i + K*2 && j < a.size(); j++) {
					ans1 += a.get(j);
				}
				ans = Math.max(ans, ans1);
				if(i + K*2 >= a.size())
					break LOOP;
			}
		}
		System.out.println(ans);
	}

}

Compiler output:
Main.java:2: error: class abc124d is public, should be declared in a file named abc124d.java
public class abc124d {
       ^
Main.java:21: error: incompatible types: long cannot be converted to Integer
				a.add(con);
				      ^
Main.java:25: error: incompatible types: long cannot be converted to Integer
				a.add(con);
				      ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
3 errors
Language: C++

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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char now='1';
  vector<int>zo(1, 0);
  for(int i=0; i<n; i++){
    if(s[i]==now)zo[zo.size()-1]++;
    else {
      now=s[i];
      zo.push_back(1);
    }
  }
  if(now=='0')zo.push_back(0);
  if(zo.size()<=2*k+1){
    cout << s.length();
    return 0;
  }
  int cnt=0, ret=0;
  for(int i=0; i<min(zo.size(), 2*k+1); i++)cnt+=zo[i];
  ret=cnt;
  for(int i=2*k+1; i<n; i+=2){
    cnt-=zo[i-2*k-1]+zo[i-2*k];
    cnt+=zo[i]+zo[i+1];
    ret=max(ret, cnt);
  }
  cout << ret;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:21: error: no matching function for call to 'min(std::vector<int>::size_type, int)'
   27 |   for(int i=0; i<min(zo.size(), 2*k+1); i++)cnt+=zo[i];
      |                  ~~~^~~~~~~~~~~~~~~~~~
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:27:21: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   27 |   for(int i=0; i<min(zo.size(), 2*k+1); i++)cnt+=zo[i];
      |                  ~~~^~~~~~~~~~~~~~~~~~
/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:4:
/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:27:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   27 |   for(int i=0; i<min(zo.size(), 2*k+1); i++)cnt+=zo[i];
      |                  ~~~^~~~~~~~~~~~~~~~~~
Language: C++

#include <cstdio>

char str[100010];
int arr[100010], top;

int main()
{
  int len, i, k, flg;
  scanf("%d%d", &len, &k);
  scanf("%s", str);
  
  top = 0;
  arr[0] = 1;
  for(i = 1; i < len; i++){
    if(str[i] != str[i - 1]) top++;
    arr[top++];
    if(str[i] == str[i - 1]) arr[top]++;
  }
  top++;

  if(str[0] == '0') flg = 1;
  
  int now, res = 0;
  for(i = 0; i < top; i++){
    if(flg xor (i % 2)) k--;
    if(k < 0) break;
    res += arr[i];
  }
  fnt = 0, lst = i;

  if(i == top){
    printf("%d\n", res);
    return 0;
  }

  now = res;
  while(lst < top){
    now -= arr[fnt];
    if((fnt % 2) xor flg){
      while(lst < top){
        now += arr[lst];
        lst++;
        if((!(lst % 2)) xor flg) break;
      }
      if(now > res) res = now;
    }
    fnt++;
  }
  printf("%d\n", res);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:3: error: 'fnt' was not declared in this scope; did you mean 'int'?
   29 |   fnt = 0, lst = i;
      |   ^~~
      |   int
a.cc:29:12: error: 'lst' was not declared in this scope
   29 |   fnt = 0, lst = i;
      |            ^~~
Language: C++

#include <cstdio>

char str[100010];
int arr[100010], top;

int main()
{
  int len, i, k, flg;
  scanf("%d%d", &len, &k);
  scanf("%s", str);
  
  top = 0;
  arr[0] = 1;
  for(i = 1; i < len; i++){
    if(str[i] != str[i - 1]) top++;
    arr[top++];
    if(str[i] == str[i - 1]) arr[top]++;
  }
  top++;

  if(str[0] == '0') flg = 1;
  
  int now, res = 0;
  for(i = 0; i < top; i++){
    if(flg xor (i % 2)) k--;
    if(k < 0) break;
    res += arr[i];
  }
  int fnt, lst;
  fnt = 0, lst = i;

  if(i == top){
    print("%d\n", res);
    return 0;
  }

  now = res;
  while(lst < top){
    now -= arr[fnt];
    if((fnt % 2) xor flg){
      while(lst < top){
        now += arr[lst];
        lst++;
        if((!(lst % 2)) xor flg) break;
      }
      if(now > res) res = now;
    }
    fnt++;
  }
  printf("%d\n", res);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:5: error: 'print' was not declared in this scope; did you mean 'printf'?
   33 |     print("%d\n", res);
      |     ^~~~~
      |     printf
Language: C++

#include <cstdio>
#include <queue>
#include <string>
using namespace std;

int main()
{
  long long n, k;
  char s[100001];
  queue<int> q;
  long long count = 0;
  long long ans = 0;
  scanf("%lld %lld", &n, &k);
  scanf("%s", s);
  for (int i = 0; i < strlen(s); i++) {
    q.push(s[i]);
    if (s[i] == '0' && s[i + 1] == '1') 
      count++;
    if (q.size() > ans)
      ans = q.size();
    if (count == k && s[i] == '1' && s[i + 1] == '0')
      while (1) {
	q.pop();
	if (q.front() == '0') {
	  while(1) {
	    q.pop();
	    if (q.front() == '1')
	      break;
	  }
	  count--;
	  break;
	}
      }
  }
  printf("%lld\n", ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:23: error: 'strlen' was not declared in this scope
   15 |   for (int i = 0; i < strlen(s); i++) {
      |                       ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <string>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const int INF =100100100;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back 
#define mp make_pair

signed main (){	
	string hoge;
	int NN,KK ;
	cin >> NN >> KK ;
	cin >> hoge;
	vector <int> renzokuchi;
	char temp;
	temp = hoge[0];
	int counter = 1;
	Rep(i,1,NN){
		if(temp == hoge[i]) {
			counter ++;
		} else {
			temp = hoge[i];
			renzokuchi.pb(counter);
			if(i == NN - 1){
				renzokuchi.pb(1);
				counter = 0;
				break;
			}
			counter = 1;
		}
	}
	if(counter != 0 ) {
		renzokuchi.pb(counter);
	}

	int max = 0;
	int current_value = 0;
	int blocks = renzokuchi.size();

	int start,end;
	// 直立はじまりのとき
	if(hoge[0] == '0') {

		// 全部行けるとき
		if ((blocks + blocks%2)/2 <= KK) {
			rep(i,blocks){
				max += renzokuchi[i];
			}
			cout << max << endl;
			return 0;
		}

		start = 0;
		end = 2 * KK;

		rep(i, end) {	// 最初の長さを取る
				current_value += renzokuchi[i];
		}
		max = current_value;

		while(end < blocks) {
			// blocksの先頭を取って、しゃくとりをする
			if(start == 0) {
				current_value -= renzokuchi[start];
				current_value += renzokuchi[end];
				if(end+1 < blocks){
						current_value += renzokuchi[end+1];
				}
				start += 1;
				end +=2 
				continue;
			}
			else {
				current_value -= renzokuchi[start];
				current_value -= renzokuchi[start+1];
				current_value += renzokuchi[end];
				if(end+1 < blocks){
						current_value += renzokuchi[end+1];
				}
			}

			if( max < current_value) {max = current_value;}
			start += 2;
			end +=2;
		}

	} 
	else { // 倒立始まり
		// 全部行けるとき
		if ((blocks - blocks%2)/2 <= KK) {
			rep(i,blocks){
				max += renzokuchi[i];
			}
			cout << max << endl;
			return 0;
		}

		start = 0;
		end = 2 * KK + 1;

		rep(i, end ) {
				current_value += renzokuchi[i];
		}
		max = current_value;

		while(end < blocks) {	// 最初の長さを取る
			
			// blocksの先頭を取って、しゃくとりをする
			current_value -= renzokuchi[start];
			current_value -= renzokuchi[start+1];

			current_value += renzokuchi[end];
			if(end+1 < blocks){
				current_value += renzokuchi[end+1];
			}
			if( max < current_value) max = current_value;
			
			start += 2;
			end +=2;
		}
	}
	cout << max << endl;


	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:40: error: expected ';' before 'continue'
   82 |                                 end +=2
      |                                        ^
      |                                        ;
   83 |                                 continue;
      |                                 ~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  string S;
  cin >> N >> K >> S;
  

Compiler output:
a.cc: In function 'int main()':
a.cc:6:22: error: expected '}' at end of input
    6 |   cin >> N >> K >> S;
      |                      ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,K;
  cin >> N >> K;
  string S;
  vector <ll> v;
  cin >> S;
  int cnt=0;
  for(int i=0;i<N;i++){
    if(S[i]=='0'){
      cnt++;
      if(S[i+1]=='1'){
        v.push_back(cnt);
        cnt=0;
      }
    }else{
      cnt++;
      if(S[i+1]=='0'){
        v.push_back(cnt);
        cnt=0;
      }
    }
  }

  ll sum=0;
  ll n=v.size();
  for(int i=0;i<=2*K-1;i++){
      sum+=v[i];
  }
  for(int i=0;i<n-2*K+1;i++){
    sum=sum-v[i]+v[i+2*K-1]
    ans=max(sum,ans);
  }
  sum=0;
  if(S[i]=='1'){
    for(int i=0;i<=2*K-1;i++){
        sum+=v[i];
    }
    ll ous= n/(2*K+1)+(n-2*K-1)/2;
    for(int i=0;i<ous-1;i++){
      sum=sum-v[i*2]-v[2*i+1]+v[2*i+2*K+1]+v[2*i+1+2*K+1];
      ans=max(ans,sum);
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:28: error: expected ';' before 'ans'
   69 |     sum=sum-v[i]+v[i+2*K-1]
      |                            ^
      |                            ;
   70 |     ans=max(sum,ans);
      |     ~~~                     
a.cc:73:8: error: 'i' was not declared in this scope
   73 |   if(S[i]=='1'){
      |        ^
a.cc:80:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   80 |       ans=max(ans,sum);
      |       ^~~
      |       abs
a.cc:83:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   83 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long ll;

int main(){
	int N, K;
	string S;
	cin>>N>>K>>S;
	char f = '0';
	int ct = 0;
	int ans = 0;
	int k = K;
	int a = 0;
	for(int i = 0; i < N; i++){
		if(a--)continue;
		f = S[i];
		int ct = 0;
		int k = K;
		if(S[i] == '0')k--;
		for(int j = i; j < N; j++){
			if(f == S[j] or S[j] == '1'){
				if(S[j] == '1')f = '1';
				ct++;
			}else {
				if(k){
					if(af){
						a = ct;
						af = false;
					}
					f = S[j];
					ct++;
					k--;
				}else{
					break;
				}
			}
		}
		ans = max(ans, ct);
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:44: error: 'af' was not declared in this scope; did you mean 'a'?
   30 |                                         if(af){
      |                                            ^~
      |                                            a
Language: C++

using namespace std;

int main() {
	string s;
	int n, k;
	cin >> n >> k >> s;
	s += '0';
	int ans = 0,co=0,gg=0;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (s[0] == '0')
		co++;
	for (int i = 0;i < n;i++) {
		if (s[i] == '1' && s[i+1] == '0') {
			if (co == k) {
				ans = max(ans, i -gg+1);
				gg++;
				while (s[gg-1] != '0' || s[gg] != '1')
					gg++;
			}
			else
				co++;
		}
	}
	ans = max(ans, n - gg);
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:9: error: 'string' was not declared in this scope
    4 |         string s;
      |         ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:6:9: error: 'cin' was not declared in this scope
    6 |         cin >> n >> k >> s;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:6:26: error: 's' was not declared in this scope
    6 |         cin >> n >> k >> s;
      |                          ^
a.cc:10:17: error: 'cout' was not declared in this scope
   10 |                 cout << 1 << endl;
      |                 ^~~~
a.cc:10:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:10:30: error: 'endl' was not declared in this scope
   10 |                 cout << 1 << endl;
      |                              ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:18:39: error: 'max' was not declared in this scope
   18 |                                 ans = max(ans, i -gg+1);
      |                                       ^~~
a.cc:27:15: error: 'max' was not declared in this scope
   27 |         ans = max(ans, n - gg);
      |               ^~~
a.cc:28:9: error: 'cout' was not declared in this scope
   28 |         cout << ans << endl;
      |         ^~~~
a.cc:28:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:28:24: error: 'endl' was not declared in this scope
   28 |         cout << ans << endl;
      |                        ^~~~
a.cc:28:24: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

#include <cstdio>
char s[100001];
int m[100001], cnt, N, K;
int max(int a, int b) {return a > b ? a : b;}
int main()
{
    int f, ans = 0;
    scanf("%d%d\n", &N, &K);
    K += K + 1;
    gets(s);
    f = !(s[0] - '0');
    for (int i = 0; i <= N; ++i)
    {
        if (f + '0' != s[i])
        {
            m[cnt++] = i;
            f = !f;
        }
        if (s[i] == '\0') break;
    }
    for (int i = 0; i < cnt; ++i)
    {
        int t = max(i - K, 0);
        if (((m[i] == N && s[m[i] - 1] == '1') || s[m[i]] == '0') && ans < m[i] - m[t])
        {
            ans = m[i] - m[t];
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

#include<bits/stdc++.H>
using namespace std;
int n,k;
char s[100005];
vector<int>v;
int main()
{
    scanf("%d%d",&n,&k);
    scanf("%s",s+1);
    int ans=0;
    bool flag=true;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='0'&&flag)
            flag=false,v.push_back(i);
        if(s[i]=='1')
            flag=true;
    }
    v.push_back(n+1);
    int pos=0,si=v.size();
    flag=true;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='0'&&flag)
            flag=false,pos++;
        if(s[i]=='1')
        {
            flag=true;
            //cout<<i<<' '<<pos<<' '<<pos+k<<' '<<v[min(pos+k,si-1)]<<endl;
            ans=max(ans,v[min(pos+k,si-1)]-i);
        }
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc:1:9: fatal error: bits/stdc++.H: No such file or directory
    1 | #include<bits/stdc++.H>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	char current;
	int count;
	vector<Len> length;
	for (int i = 0; i < S.size();)
	{
		current = S[i];
		count = 0;
		for (int j = i; j < S.size(); ++j,++count)
		{
			if (S[i] != S[j])
				break;
		}

		length.push_back(Len(current, count));
		i += count;
	}

	int maximum = length[0].len;

	int opeCount;
	for (int i = 0; i < length.size() - K; ++i)
	{
		int current = 0;
		opeCount = 0;
		int j;
		for (j = i; j < length.size() && opeCount < K; ++j)
		{
			current += length[j].len;
			if (length[j].num == '0')
				++opeCount;
		}

		if (j < length.size() && length[j].num == '1')
			current += length[j].len;
		maximum = max(maximum, current);
	}

	cout << maximum << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: 'Len' was not declared in this scope
   17 |         vector<Len> length;
      |                ^~~
a.cc:17:19: error: template argument 1 is invalid
   17 |         vector<Len> length;
      |                   ^
a.cc:17:19: error: template argument 2 is invalid
a.cc:28:24: error: request for member 'push_back' in 'length', which is of non-class type 'int'
   28 |                 length.push_back(Len(current, count));
      |                        ^~~~~~~~~
a.cc:32:29: error: invalid types 'int[int]' for array subscript
   32 |         int maximum = length[0].len;
      |                             ^
a.cc:35:36: error: request for member 'size' in 'length', which is of non-class type 'int'
   35 |         for (int i = 0; i < length.size() - K; ++i)
      |                                    ^~~~
a.cc:40:40: error: request for member 'size' in 'length', which is of non-class type 'int'
   40 |                 for (j = i; j < length.size() && opeCount < K; ++j)
      |                                        ^~~~
a.cc:42:42: error: invalid types 'int[int]' for array subscript
   42 |                         current += length[j].len;
      |                                          ^
a.cc:43:35: error: invalid types 'int[int]' for array subscript
   43 |                         if (length[j].num == '0')
      |                                   ^
a.cc:47:32: error: request for member 'size' in 'length', which is of non-class type 'int'
   47 |                 if (j < length.size() && length[j].num == '1')
      |                                ^~~~
a.cc:47:48: error: invalid types 'int[int]' for array subscript
   47 |                 if (j < length.size() && length[j].num == '1')
      |                                                ^
a.cc:48:42: error: invalid types 'int[int]' for array subscript
   48 |                         current += length[j].len;
      |                                          ^
Language: C++

/*{{{*/
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  string s;
  ll n,k;
  cin >> n >> k;
  cin >> s;
  vector<ll> arr;
  ll ti = -1;
  ll ui = -1;
  bool onef = s[0] == '1';
  REP(i,n){
    if(s[i]=='1' && ti==-1){
      ti = i;
    }
    if(s[i]=='0' && ti!=-1){
      arr.push_back(i-ti);
      ti = -1;
    }
    if(s[i]=='0' && ui==-1){
      ui = i;
    }
    if(s[i]=='1' && ui!=-1){
      arr.push_back(i-ui);
      ui = -1;
    }
  }
  if(ti!=-1){
    arr.push_back(n-ti);
  }
  if(ui!=-1){
    arr.push_back(n-ui);
  }
  vector<ll> cand;
  ll mk;
  if(onef){
    mk = arr.size()/2;
  } else {
    mk = (arr.size()+1)/2;
  }
  k = min(k,mk);
  REP(i,mk-k+1){
    ll ad = 0;
    if(onef){
      REP(j,2*k+1){
        if(2*i+j<arr.size())ad += arr[2*i+j];
      }
    } else {
      if(i==0){
        REP(j,2*k){
          if(2*i+j<arr.size())ad += arr[2*i+j];
        }
      } else {
        REP(j,2*k+1){
          if(2*i+j<arr.size())ad += arr[2*i+j];
        }
      }
    }
    cand.push_back(ad);
  }
  sort(cand.begin(),cand.end());
  cout << cand[cand.size()-1] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:3: error: 'vector' was not declared in this scope
   23 |   vector<ll> arr;
      |   ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include<sstream>
  +++ |+#include <vector>
    6 | 
a.cc:23:12: error: expected primary-expression before '>' token
   23 |   vector<ll> arr;
      |            ^
a.cc:23:14: error: 'arr' was not declared in this scope
   23 |   vector<ll> arr;
      |              ^~~
a.cc:49:12: error: expected primary-expression before '>' token
   49 |   vector<ll> cand;
      |            ^
a.cc:49:14: error: 'cand' was not declared in this scope; did you mean 'rand'?
   49 |   vector<ll> cand;
      |              ^~~~
      |              rand
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()
{
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  vector<int> V;
  if (S.at(0) == '0') V.push_back(0);
  for (int 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);
  }
  
  int ans = 0;
  int M = K * 2 + 1;
  if (M >= V.size()) ans = N;
  else
  {
    for (int i = 0; i < V.size() - M + 1; i++;)
    {
      int 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:32:46: error: expected ')' before ';' token
   32 |     for (int i = 0; i < V.size() - M + 1; i++;)
      |         ~                                    ^
      |                                              )
a.cc:32:47: error: expected primary-expression before ')' token
   32 |     for (int i = 0; i < V.size() - M + 1; i++;)
      |                                               ^
Language: C++

#include<stdio.h>
int main(void)
{
	int n,k;
	char s[100000];
	int switching[100000];
	int count=0;
	int long=0;
	int start=0;
	scanf("%d",&n);
	scanf("%d",&k);
	scanf("%s",s);
	if(s[0]=='0')start=0;
	else start=1;
	for (int i=1;i<n;i++)
	{
		if((s[i-1]=='0'&&s[i]=='1')||(s[i-1]=='1'&&s[i]=='0'))
		{
			switching[count]=i;
			count++;
		}
	}
	for (int i=1-start;i<count;i+=2)
	{
		if(long<switching[i+k*2+2]-switching[i])long=switching[i+k*2+2]-switching[i];
	}
	printf("%d",long);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: expected unqualified-id before '=' token
    8 |         int long=0;
      |                 ^
a.cc:25:20: error: 'long int' is not a template
   25 |                 if(long<switching[i+k*2+2]-switching[i])long=switching[i+k*2+2]-switching[i];
      |                    ^~~~
a.cc:25:55: error: the value of 'switching' is not usable in a constant expression
   25 |                 if(long<switching[i+k*2+2]-switching[i])long=switching[i+k*2+2]-switching[i];
      |                                                       ^
a.cc:6:13: note: 'switching' was not declared 'constexpr'
    6 |         int switching[100000];
      |             ^~~~~~~~~
a.cc:25:20: error: expected primary-expression before 'long'
   25 |                 if(long<switching[i+k*2+2]-switching[i])long=switching[i+k*2+2]-switching[i];
      |                    ^~~~
a.cc:25:20: error: expected ')' before 'long'
   25 |                 if(long<switching[i+k*2+2]-switching[i])long=switching[i+k*2+2]-switching[i];
      |                   ~^~~~
      |                    )
a.cc:25:61: error: expected unqualified-id before '=' token
   25 |                 if(long<switching[i+k*2+2]-switching[i])long=switching[i+k*2+2]-switching[i];
      |                                                             ^
a.cc:27:21: error: expected primary-expression before 'long'
   27 |         printf("%d",long);
      |                     ^~~~
Language: C++

#include<stdio.h>
int main(void)
{
	int n,k;
	char s[100000];
	int switch[100000];
	int count=0;
	int long=0;
    int start=0;
	scanf("%d",&n);
	scanf("%d",&k);
	scanf("%s",s);
	if(s[0]=='0')start=0;
	else start=1;
	for (int i=1;i<n;i++)
	{
		if((s[i-1]=='0'&&s[i]=='1')||(s[i-1]=='1'&&s[i]=='0'))
		{
			switch[count]=i;
			count++;
		}
	}
	for (int i=1-start;i<count;i+=2)
	{
		if(long<switch[i+k*2+2]-switch[i])long=switch[i+k*2+2]-switch[i];
	}
	printf("%d",long);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: expected unqualified-id before 'switch'
    6 |         int switch[100000];
      |             ^~~~~~
a.cc:8:17: error: expected unqualified-id before '=' token
    8 |         int long=0;
      |                 ^
a.cc:19:31: error: expected '(' before '[' token
   19 |                         switch[count]=i;
      |                               ^
      |                               (
a.cc:25:20: error: 'long int' is not a template
   25 |                 if(long<switch[i+k*2+2]-switch[i])long=switch[i+k*2+2]-switch[i];
      |                    ^~~~
a.cc:25:20: error: expected primary-expression before 'long'
a.cc:25:20: error: expected ')' before 'long'
   25 |                 if(long<switch[i+k*2+2]-switch[i])long=switch[i+k*2+2]-switch[i];
      |                   ~^~~~
      |                    )
a.cc:25:55: error: expected unqualified-id before '=' token
   25 |                 if(long<switch[i+k*2+2]-switch[i])long=switch[i+k*2+2]-switch[i];
      |                                                       ^
a.cc:27:21: error: expected primary-expression before 'long'
   27 |         printf("%d",long);
      |                     ^~~~
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 stt,tmp;
    ans = 0;
    stt=0;
    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;
                }
                zs=zs-2;
                n0=false;
                tmp = tmp-stt+1;
                i--;
            }
        }
        else{
            if(n0==true){
                n0=false;
                if(zs==K-1){
                    stt=i;
                }
            }
        }
    }
    if(tmp>ans){
        ans=tmp;
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |     ans = 0;
      |     ^~~
      |     abs
Language: C++

#include<stdio.h>
int main(void)
{
	int n,k;
	char s[100000];
	int switch[100000];
	int count=0;
	int long=0;
	scanf("%d",&n);
	scanf("%d",&k);
	scanf("%s",s);
	if(s[0]=='0')start=0;
	else start=1;
	for (int i=1;i<n;i++)
	{
		if((s[i-1]=='0'&&s[i]=='1')||(s[i-1]=='1'&&s[i]=='0'))
		{
			switch[count]=i;
			count++;
		}
	}
	for (int i=1-start;i<count;i+=2)
	{
		if(long<switch[i+k*2+2]-switch[i])long=switch[i+k*2+2]-switch[i];
	}
	printf("%d",long);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: expected unqualified-id before 'switch'
    6 |         int switch[100000];
      |             ^~~~~~
a.cc:8:17: error: expected unqualified-id before '=' token
    8 |         int long=0;
      |                 ^
a.cc:12:22: error: 'start' was not declared in this scope
   12 |         if(s[0]=='0')start=0;
      |                      ^~~~~
a.cc:13:14: error: 'start' was not declared in this scope
   13 |         else start=1;
      |              ^~~~~
a.cc:18:31: error: expected '(' before '[' token
   18 |                         switch[count]=i;
      |                               ^
      |                               (
a.cc:22:22: error: 'start' was not declared in this scope
   22 |         for (int i=1-start;i<count;i+=2)
      |                      ^~~~~
a.cc:24:20: error: 'long int' is not a template
   24 |                 if(long<switch[i+k*2+2]-switch[i])long=switch[i+k*2+2]-switch[i];
      |                    ^~~~
a.cc:24:20: error: expected primary-expression before 'long'
a.cc:24:20: error: expected ')' before 'long'
   24 |                 if(long<switch[i+k*2+2]-switch[i])long=switch[i+k*2+2]-switch[i];
      |                   ~^~~~
      |                    )
a.cc:24:55: error: expected unqualified-id before '=' token
   24 |                 if(long<switch[i+k*2+2]-switch[i])long=switch[i+k*2+2]-switch[i];
      |                                                       ^
a.cc:26:21: error: expected primary-expression before 'long'
   26 |         printf("%d",long);
      |                     ^~~~
Language: C++

#include <cstdio>

char str[100010];
int arr[100010], top;

int main()
{
  int len, i, k, flg;
  scanf("%d%d", &len, &k);
  scanf("%s", str);
  
  top = 0;
  arr[0] = 1;
  for(i = 1; i < len; i++){
    if(str[i] != str[i - 1]) top++;
    arr[top++];
    if(str[i] == str[i - 1]) arr[top]++;
  }
  top++;

  if(str[0] == '0') flg = 1;
  
  int now, res = 0;
  for(i = 0; i < top; i++){
    if(flg xor (i % 2)) k--;
    if(k < 0) break;
    res += arr[i];
  }
  fnt = 0, lst = i;

  if(i == top){
    print("%d\n", res);
    return 0;
  }

  now = res;
  while(lst < top){
    now -= arr[fnt];
    if((fnt % 2) xor flg){
      while(lst < top){
        now += arr[lst];
        lst++;
        if((!(lst % 2)) xor flg) break;
      }
      if(now > res) res = now;
    }
    fnt++;
  }
  printf("%d\n", res);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:3: error: 'fnt' was not declared in this scope; did you mean 'int'?
   29 |   fnt = 0, lst = i;
      |   ^~~
      |   int
a.cc:29:12: error: 'lst' was not declared in this scope
   29 |   fnt = 0, lst = i;
      |            ^~~
a.cc:32:5: error: 'print' was not declared in this scope; did you mean 'printf'?
   32 |     print("%d\n", res);
      |     ^~~~~
      |     printf
Language: C++

#include <cstdio>
char s[100001];
int m[100001], cnt, N, K;
int max(int a, int b) {return a > b ? a : b;}
int main()
{
    int f, ans = 0;
    scanf("%d%d\n", &N, &K);
    K += K + 1;
    gets(s);
    f = !(s[0] - '0');
    for (int i = 0; i <= N; ++i)
    {
        if (f + '0' != s[i])
        {
            m[cnt++] = i;
            f = !f;
        }
        if (s[i] == '\0') break;
    }
    for (int i = 0; i < cnt; ++i)
    {
        int t = max(i - K, 0);
        if (ans < m[i] - m[t])
        {
            ans = m[i] - m[t];
        }
    }
    printf("%d\n", ans);
    return 0;
}


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