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

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

int main() {
  int n,k,sum = 0;
  int ans = 0; cin >> n >> k;
  string s; cin >> s;
  vector<int> num;
  int count = 1;
  if(s[0] == '0') a.push_back(0);
  for(int i=0;i<n-1;i++){
    if(s[i] == s[i+1]) count++;
    else {
      a.push_back(count);
      count = 1;
    }
  }
  a.push_back(count);
  if(s[n-1] == '0') a.push_back(0);
  if(a.size() == 1) {
    cout << a[0] << endl;
    return 0;
  }
  if(k*2+1 >= a.size()) {
    cout << n << endl;
    return 0;
  }
  for(int i=0;i<k;i++) sum += a[i];
  ans = sum;
  int l = 0; int r = k;
  for(int i=0;i<(a.size()-k)/2;i++) {
    sum -= a[l]; l++;
    sum -= a[l]; l++;
    sum += a[r]; r++;
    sum += a[r]; r++;
    ans = max(sum,ans);
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:19: error: 'a' was not declared in this scope
   10 |   if(s[0] == '0') a.push_back(0);
      |                   ^
a.cc:14:7: error: 'a' was not declared in this scope
   14 |       a.push_back(count);
      |       ^
a.cc:18:3: error: 'a' was not declared in this scope
   18 |   a.push_back(count);
      |   ^
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

int main() {
  ll n,k,ans=0,tmp=0;
  string s;
  cin >> n >> k >> s;
  vector<ll>w;
  rep(i,n){
  	if(s.at(i)=='0') tmp++;
  	if(s.at(i)=='0' && i==n-1){
  		w.push_back(tmp);
  	}
  	else{
  		if(tmp!=0) w.push_back(tmp);
  		tmp=0;
  		ans++;
  	}
  }
  sort(w.begin(),w.end());
  reverse(w.begin(),w.end());
  rep(i,min(k,w.size())) ans=min(ans+w.at(i),n);
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:12: error: no matching function for call to 'min(ll&, std::vector<long long int>::size_type)'
   25 |   rep(i,min(k,w.size())) ans=min(ans+w.at(i),n);
      |         ~~~^~~~~~~~~~~~
a.cc:3:32: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(ll i=0;i<(n);i++)
      |                                ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:25:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'})
   25 |   rep(i,min(k,w.size())) ans=min(ans+w.at(i),n);
      |         ~~~^~~~~~~~~~~~
a.cc:3:32: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(ll i=0;i<(n);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:
/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:25:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |   rep(i,min(k,w.size())) ans=min(ans+w.at(i),n);
      |         ~~~^~~~~~~~~~~~
a.cc:3:32: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(ll i=0;i<(n);i++)
      |                                ^
Language: C

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int n, k;
  char s[MAX];
  scanf("%d %d %s", &n, &k, s);

  int nsize = 0, nums[MAX]; // 1-0-...-0-1と並ぶ配列
  int now = 1;              // 今見ている数
  int cnt = 0;              // 今見ている数の連続して並んでいる数
  rep(i, 0, n) {
    if (s[i] == (char)('0' + now)) cnt++;
    else {
      nums[nsize++] = cnt;
      now = 1 - now;
      cnt = 1;
    }
  }
  nums[nsize++] = cnt;

  // 最後が0で終わっている場合(1-0-...1-0)
  // 最後を1で終わっている配列にする(1-0-...-0-1)
  if (nsize % 2 == 0) nums[nsize++] = 0;

  /********** 尺取法 ***********/

  // int range = 2 * k + 1; // 尺
  // int ans = 0;

  // int left = 0;
  // int right = 0;
  // int tmp = 0; // [left, right)のsum(仮ans)

  // for (int i = 0; i < nsize; i += 2) { // 左端に合わせてループ
  //   int nleft = i;
  //   int nright = min(nleft + range, nsize);

  //   // 左差分を計算
  //   while (left < nleft) {
  //     tmp -= nums[left];
  //     left++;
  //   }

  //   // 右差分を計算
  //   while (right < nright) {
  //     tmp += nums[right];
  //     right++;
  //   }
  //   ans = max(ans, tmp);
  // }

  /********** 累積和 ***********/

  // 累積和を計算
  int sum[MAX];
  sum[0] = nums[0];
  rep(i, 1, nsize) {
    sum[i] = sum[i - 1] + nums[i];
  }

  int ans = 0;
  int range = 2 * k + 1;
  rep(i, 0, nsize) {
    int left = i;
    int right = min(i + range, nsize);
    ans = max(ans, sum[right] - sum[left])
  }

  printf("%d\n", ans);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:85:3: error: expected ';' before '}' token
   85 |   }
      |   ^
Language: C

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int n, k;
  char s[MAX];
  scanf("%d %d %s", &n, &k, s);

  int nsize = 0, nums[MAX]; // 1-0-...-0-1と並ぶ配列
  int now = 1;              // 今見ている数
  int cnt = 0;              // 今見ている数の連続して並んでいる数
  rep(i, 0, n) {
    if (s[i] == (char)('0' + now)) cnt++;
    else {
      nums[nsize++] = cnt;
      now = 1 - now;
      cnt = 1;
    }
  }
  nums[nsize++] = cnt;

  // 最後が0で終わっている場合(1-0-...1-0)
  // 最後を1で終わっている配列にする(1-0-...-0-1)
  if (nsize % 2 == 0) nums[nsize++] = 0;

  /********** 尺取法 ***********/

  // int range = 2 * k + 1; // 尺
  // int ans = 0;

  // int left = 0;
  // int right = 0;
  // int tmp = 0; // [left, right)のsum(仮ans)

  // for (int i = 0; i < nsize; i += 2) { // 左端に合わせてループ
  //   int nleft = i;
  //   int nright = min(nleft + range, nsize);

  //   // 左差分を計算
  //   while (left < nleft) {
  //     tmp -= nums[left];
  //     left++;
  //   }

  //   // 右差分を計算
  //   while (right < nright) {
  //     tmp += nums[right];
  //     right++;
  //   }
  //   ans = max(ans, tmp);
  // }

  /********** 累積和 ***********/

  // 累積和を計算
  int sum[MAX];
  sum[0] = nums[0];
  rep(i, 1, nsize) {
    sum[i] = sum[i - 1] + nums[i];
  }

  int range = 2 * k + 1;
  rep(i, 0, nsize) {
    int left = i;
    int right = min(i + range, nsize);
    ans = max(ans, sum[right] - sum[left])
  }

  printf("%d\n", ans);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:83:5: error: 'ans' undeclared (first use in this function); did you mean 'acs'?
   83 |     ans = max(ans, sum[right] - sum[left])
      |     ^~~
      |     acs
main.c:83:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:84:3: error: expected ';' before '}' token
   84 |   }
      |   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define LOOP(val, times)   for(val = 0; val < (times); val++)
int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  vector<int> aa(0);
  int dd=1;
  s.push_back('y');
  for(int i=0;i<n;i++){
    if(s[i]==s[i+1]){
      dd++;
    }
    else{
      aa.push_back(dd);
      dd=1;
    }
  }
  s.pop_back();
  int ans=0;
  int hh=0;
  if(s[0]=='1'){
    for(int i=0;i<aa.size();i+=2){
      for(int j=i;j<2*k+1+i;j++){
        hh+=aa[j];
      }
      ans=max(ans,hh);
      hh=0;
    }
    if(s[n-1]=='0'){
      for(int j=aa.size()-1;j>=aa.size()-2*k;j--){
        hh+=a[j];
      }
      ans=max(ans,hh);
    }
  }
  else{
    for(int i=0;i<=2*k-2;i++){
      ans+=aa[i];
    }
    for(int i=1;i<aa.size();i+=2){
      for(int j=i;j<2*k+1+i;j++){
        hh+=aa[i];
      }
      ans=max(ans,hh);
    }
    if(s[n-1]=='0'){
       for(int j=aa.size()-1;j>=aa.size()-2*k;j--){
        hh+=a[j];
      }
      ans=max(ans,hh);
    }
  }
  cout<<ans<<endl;
}
    
  
      

Compiler output:
a.cc: In function 'int main()':
a.cc:34:13: error: 'a' was not declared in this scope
   34 |         hh+=a[j];
      |             ^
a.cc:51:13: error: 'a' was not declared in this scope
   51 |         hh+=a[j];
      |             ^
Language: C++

#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int n,k; cin >> n >> k;
  string s; cin >> s;
  char first=s[0];
  vector<int> seqNum;
  char now=first;
  rep(i,n){
    int seq=0;
    while (s[i]==now){
      seq++;i++;
    }
    i--;
    seqNum.push_back(seq);
    if (now=='0'){now='1';}else{now='0';}
  }

  //rep(i,seqNum.size()){cout << seqNum[i] << endl;}

  int zero;
  int siz=seqNum.size();
  if (first=='0') {zero=(int)ceil(siz/2.0);}
  else {zero=(int)floor(siz/2.0);}
  int ans;

  if (k>=zero) {ans = n;}
  else {
    int l,r;
    l=0;
    if (first=='0'){r=2*k-1;} else {r=2*k;}
    int sum=0;
    for (int i=l; i<=r; i++){
      sum+=seqNum[i];
    }
    //cout << sum << endl;
    ans=sum;
    if (first=='0'){
      l++;r+=2;
    } else {
      l+=2;r+=2;
      sum -= seqNum[l-2];
    }
    if (r==siz) {r=siz-1;flag=1;}
    sum -= seqNum[l-1];
    if (flag == 0){sum += seqNum[r-1]+seqNum[r];}
    else {sum += seqNum[r];}
    ans = max(sum,ans);
    l+=2;r+=2;
    int flag = 0;
    if (r==siz) {r=siz-1;flag=1;}
    while (r<siz){
      sum -= seqNum[l-1]+seqNum[l-2];
      if (flag == 0){sum += seqNum[r-1]+seqNum[r];}
      else {sum += seqNum[r];}
      ans = max(sum,ans);
      l+=2;r+=2;
      if (r==siz) {r=siz-1;flag=1;}
    }
  }

  cout << ans << endl;


  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:26: error: 'flag' was not declared in this scope
   62 |     if (r==siz) {r=siz-1;flag=1;}
      |                          ^~~~
a.cc:64:9: error: 'flag' was not declared in this scope
   64 |     if (flag == 0){sum += seqNum[r-1]+seqNum[r];}
      |         ^~~~
Language: C++


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


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

	vector<int> Ls;
	vector<int> sum_l;

	int cnt = 1;
	sum_l.push_back(0);
	for (int ni = 1; ni < N; ni++){
		if(S[ni -1] == S[ni]){
			cnt++;
		}else{
			Ls.push_back(cnt);
			sum_l.push_back(sum_l.back() + cnt);
			cnt = 1;
		}		
	}
	Ls.push_back(cnt);
	sum_l.push_back(sum_l.back() + cnt);

	int mod = 0;
	if (S[0] == '0'){
		mod = 1;
	}

	int len = min( (int)sum_l.size() - 1, 2 * K + 1);

	if (len = 1) {
		printf("%d", N);
		return 0;
	}

	int sum;
	int u_sum = 0;
	for (int li = 0; li < sum_l.size()- len + 1; li++){
		if (li % 2 == mod && li != sum_l.size() - len) {
			sum = sum_l[li + len] - sum_l[li];
		}
		else {
			sum = sum_l[li + len - 1] - sum_l[li];
		}

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

	}

	int ans = u_sum;



Compiler output:
a.cc: In function 'int main()':
a.cc:66:25: error: expected '}' at end of input
   66 |         int ans = u_sum;
      |                         ^
a.cc:16:1: note: to match this '{'
   16 | {
      | ^
Language: C++

int N, K; string S;
 // ---------------------------------------- -------------------------------------------------- --------- 
void _main () {
	cin >> N >> K >> S;
 
	auto blocks = runLengthEncoding (S);
	 int M = blocks.size ();
	 int ans = 0 ;
	 int sm = 0 ;
	 int L = 0 ;
	 int zero = 0 ;
	rep (R, 0 , M) {
		sm + = blocks [R] .second;
		if (blocks [R] .first == '0' ) zero ++;
 
		while (K <zero) {
			sm-= blocks [L] .second;
			if (blocks [L] .first == '0' ) zero--;
			L ++;
		}
 
		chmax (ans, sm);
	}
	cout << ans << endl;
}

Compiler output:
a.cc:1:11: error: 'string' does not name a type
    1 | int N, K; string S;
      |           ^~~~~~
a.cc: In function 'void _main()':
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> N >> K >> S;
      |         ^~~
a.cc:4:26: error: 'S' was not declared in this scope
    4 |         cin >> N >> K >> S;
      |                          ^
a.cc:6:23: error: 'runLengthEncoding' was not declared in this scope
    6 |         auto blocks = runLengthEncoding (S);
      |                       ^~~~~~~~~~~~~~~~~
a.cc:12:14: error: 'R' was not declared in this scope
   12 |         rep (R, 0 , M) {
      |              ^
a.cc:12:9: error: 'rep' was not declared in this scope
   12 |         rep (R, 0 , M) {
      |         ^~~
a.cc:24:9: error: 'cout' was not declared in this scope
   24 |         cout << ans << endl;
      |         ^~~~
a.cc:24:24: error: 'endl' was not declared in this scope
   24 |         cout << ans << endl;
      |                        ^~~~
Language: Java

import java.util.*;

public class D124{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());

      String s = sc.next();
      int lng = s.length();
      char[] c = new char[lng];
      for(int i=0;i<lng;i++){
        c[i] = s.charAt(i);
      }

      int[] kore = new int[n];
      int[] or01 = new int[n];
      int cnt = 0;
      for(int i=0;i<n-1;i++){
        if(c[i]==c[i+1]){
          kore[cnt]++;
        }
        else{
          if(c[i]=='0'){
            or01[cnt] = 0;
          }
          else{
            or01[cnt] = 1;
          }
          cnt++;
        }
      }
      for(int i=0;i<=cnt;i++){
        kore[i]++;
      }

//////main////////////////////////////////////
int range = 2*k+1;
int ans = 0;
int max = 0;
for(int i=-k;i<=lng-range;i++){

if(i<0){
//////////////////////////////////
for(int j=0;j<range+i;j++){
  max += kore[j];
}
//////////////////////////////////
}
else if(0<=i && i<=lng-range){
//////////////////////////////////
  if(or01[i]==1){
    for(int j=i;j<i+range;j++){
      max += kore[j];
    }
  }
//////////////////////////////////
}
else if(lng-range<i){
//////////////////////////////////
for(int j=i;j<lng;j++){
  max += kore[j];
}
//////////////////////////////////
}
  ans = Math.max(ans,max);
  max = 0;
}
System.out.println(ans);
//////////////////////////////////////////////

      /*for(int kores : kore){
        System.out.println(kores);
      }*/

    }
}


Compiler output:
Main.java:3: error: class D124 is public, should be declared in a file named D124.java
public class D124{
       ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> ii;
    ii.push_back(0);
    for(int i=1;i<N;i++){
        if(S[i]!=S[i-1])ii.push_back(i);
    }
    int mx=0;
    ii.push_back(N);
    rep(i,ii.size()-1){
      	int s=S[ii[i]]-'0';
        int y=min(i+2*K+s,(int)ii.size()-1);
        chmax(mx,ii[y]-ii[i])
    }
    cout << mx;
}

/*



 */



Compiler output:
a.cc: In function 'int main()':
a.cc:31:30: error: expected ';' before '}' token
   31 |         chmax(mx,ii[y]-ii[i])
      |                              ^
      |                              ;
   32 |     }
      |     ~
Language: C

#include<stdio.h>
int main(void){
        int n,k;
        int l=0,r=0;
        int i;
        int len=0;
        char s[1000000];
        scanf("%d%d",&n,&k);
        scanf("%s",s);

        for(i=0;i<k+(s[0]=='1');i++){
                if ((s[n-1]=='1'&&r<n-1)(s[n-1]=='0'&&r<n)) r++;
                while(r<n-1&&(s[r]!='1'||s[r+1]!='0')){
                        r++;
                }
        }
        len=r-l+1;
        //printf("%d\n",r);
        while(l<n-1&&r<n){
                if((s[n-1]=='1'&&r<n-1)(s[n-1]=='0'&&r<n)){
                    l++; r++;
                }
                while(l<n-1&&(s[l]!='0'||s[l+1]!='1')) l++;
                if(s[n-1]=='1'){
                    while(r<n-1&&(s[r]!='1'||s[r+1]!='0')) r++;
                }else{
                    while(r<n&&(s[r]!='1'||s[r+1]!='0')) r++;
                }
                if(r-l>len) len=r-l;
                //printf("%d %d\n",l,r);
        }
        printf("%d\n",len);
        return 0;
}

Compiler output:
main.c: In function 'main':
main.c:12:33: error: called object is not a function or function pointer
   12 |                 if ((s[n-1]=='1'&&r<n-1)(s[n-1]=='0'&&r<n)) r++;
      |                     ~~~~~~~~~~~~^~~~~~~~
main.c:20:32: error: called object is not a function or function pointer
   20 |                 if((s[n-1]=='1'&&r<n-1)(s[n-1]=='0'&&r<n)){
      |                    ~~~~~~~~~~~~^~~~~~~~
Language: C++

#include<iostream>
using namespace std;
int n,k,l,r,ans;
string s;
int main(){
	cin>>n>>k>>s;
	s+='e';
	k+=(s[0]=='1');
	while(k--)r=f(r);
	while(l!=n){
		ans=max(ans,r-l);
		while(l!=n&&s[l++]=='1');
		while(l!=n&&s[l]=='0')l++;
		while(r!=n&&s[r++]=='0');
		while(r!=n&&s[r]=='1')r++;
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:21: error: 'f' was not declared in this scope
    9 |         while(k--)r=f(r);
      |                     ^
Language: C++

#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
#ifdef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
  boost::for_each(vc, [&os](T value) {
#else
  std::for_each(vc.begin(), vc.end(), [&os](T value) {
#endif
    os << value << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  ui N{}, K{}; cin >> N >> K;
  string S{}; std::cin >> S;

  vector<pair<ui, uc>> A;
  A.reserve(N);

  uc flag = S[0] - '0';
  A.push_back({ 0, flag });
  rep(0, N)
  {
    uc tmp = S[i] - '0';
    if (tmp != flag)
    {
      A.push_back({ i, tmp });
      flag = tmp;
    }
  }
  vector<ull> res(A.size());
  A.push_back({ N, -1 });
  rep(0, res.size())
  {
    auto cnt = K * 2;
    if (!A[i].second) --cnt;
    auto end = std::min(A.size() - 1, i + cnt + 1);

    res[i] = A[end].first - A[i].first;
  }

  auto ans = *boost::max_element(res);

  using std::cout;
  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


Compiler output:
a.cc:2:10: fatal error: boost/range/algorithm.hpp: No such file or directory
    2 | #include <boost/range/algorithm.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

 #include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b,d,g,h,s;
  string c;
  cin>>a>>b>>c;
  vector<int> e;
  d=c[0]-'0';
  char f;
  for(int i=0;i<a;i=i){
    g=0;
    f=c[i];
    while(i<a){
      if(c[i]==f){
        g++;
        i++;
      }
    }
    e.push_back(g);
  }
  vector<int> v(e.size());
  v[0]=e[0];
  for(int i=1;i<e.size();i++)
    v[i]=v[i-1]+e[i];
  if(d){
    s=e.size()/2;
    if(s<=b)
      cout<<c.size()<<endl;
    else{
    for(int i=0;i<s-b+1;i++){
      i

Compiler output:
a.cc: In function 'int main()':
a.cc:86:8: error: expected ';' at end of input
   86 |       i
      |        ^
      |        ;
a.cc:86:8: error: expected '}' at end of input
a.cc:85:29: note: to match this '{'
   85 |     for(int i=0;i<s-b+1;i++){
      |                             ^
a.cc:86:8: error: expected '}' at end of input
   86 |       i
      |        ^
a.cc:84:9: note: to match this '{'
   84 |     else{
      |         ^
a.cc:86:8: error: expected '}' at end of input
   86 |       i
      |        ^
a.cc:80:8: note: to match this '{'
   80 |   if(d){
      |        ^
a.cc:86:8: error: expected '}' at end of input
   86 |       i
      |        ^
a.cc:58:14: note: to match this '{'
   58 | signed main(){
      |              ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
long long n,o;
long long sum;
long long a[100005];
long long b[100005];
bool cmp(long long a,long long y){
	return a.x<y.x;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<0){
			b[o++].x=-a[i];
		}
		else b[o++].x=a[i];
	}
	sort(b,b+o,cmp);
		for(int i=0;i<n;i++){
			sum+=b[i].x;
		}
	if(o%2!=0){
		sum-=b[0].x*2;
	}
	cout<<sum;
}

Compiler output:
a.cc: In function 'bool cmp(long long int, long long int)':
a.cc:9:18: error: request for member 'x' in 'a', which is of non-class type 'long long int'
    9 |         return a.x<y.x;
      |                  ^
a.cc:9:22: error: request for member 'x' in 'y', which is of non-class type 'long long int'
    9 |         return a.x<y.x;
      |                      ^
a.cc: In function 'int main()':
a.cc:16:32: error: request for member 'x' in 'b[(o ++)]', which is of non-class type 'long long int'
   16 |                         b[o++].x=-a[i];
      |                                ^
a.cc:18:29: error: request for member 'x' in 'b[(o ++)]', which is of non-class type 'long long int'
   18 |                 else b[o++].x=a[i];
      |                             ^
a.cc:22:35: error: request for member 'x' in 'b[i]', which is of non-class type 'long long int'
   22 |                         sum+=b[i].x;
      |                                   ^
a.cc:25:27: error: request for member 'x' in 'b[0]', which is of non-class type 'long long int'
   25 |                 sum-=b[0].x*2;
      |                           ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
int N,K; cin >> N >> K;
  string S; cin >> S;
  vector<int> vec;
  //0,2,4,,番目に連続する1の個数を、1,3,5,,,番目に連続する0の個数をpush_backする
  if( S[0] == '0'){
    vec.push_back(0);} //最初の連続する1の個数は０
  int head = 0;
  while(head < N){
    //headは0(または１）の連続する個数を数えるためのスタート位置
    int tail = head; int cnt = 0;
    while((head + tail) < N && S[tail] == S[head]){ tail++; cnt++;}
    head = tail; vec.push_back(cnt);}

  if( S.back() == '0'){ vec.push_back(0);} //最初と最後は1の個数で終わりたい　
  //このときのvecの長さは必ず奇数
  
  vector<long long > sum((int) vec.size() + 1, 0);
  
  for(int i = 0; i <vec.size(); i++){
    sum[i + 1] = sum[i] + vec[i];}

long long ans = 0;

 for(int start = 0; start < (int)vec.size(); start++){
   long long res = 0; int j = start;
   if( j % 2 == 0){ //vec[start]は１の個数
    int goal = min( (int) vec.size() - 1 , j + 2 * K);
    res = sum[goal + 1] - sum[j];}
   
   else{
     // vec[start]は0の個数
     int goal = min((int) vec.size() - 1 , j + 2 * K - 1);
     res = sum[goal + 1] - sum[j - 1]; }
   
   ans = max( ans , res);
 }

Compiler output:
a.cc: In function 'int main()':
a.cc:41:3: error: expected '}' at end of input
   41 |  }
      |   ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

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

int main(){
  int n, k;
  string S;
  int count=0;
  for(int i=0; i<n; ++i){
    if(S[i]=='0')
      count ++;
  }
  int max1=0;
  for(int i=0; i<n; ++i){
    if(S[i]=='0')
      count++;
      max1=max(count, max1);
    else if(S[i]=='1')
      count--;
      max1=max(count, max1);
  }
  
  for(int i=k; i<n; ++i){
    if(S[i]=='0')
      count ++;
  }
  
  cout << count+max1 << endl;

}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: 'else' without a previous 'if'
   17 |     else if(S[i]=='1')
      |     ^~~~
Language: C++

#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int n, k, ct0=0, ct1=0;
    ll sum0=0, sum1=0;
    string s;
    vector<int> num0, num1;
    vector<pair<ll,int>> sumvec0;
    map<int,ll> sumap1;
    cin >> n >> k >> s;
    FOR(i,0,n){
        if(s[i]=='0'){
            if(ct1!=0){num1.push_back(ct1);}
            ct1 = 0;
            ct0 += 1;
        }else{
            if(ct0!=0){num0.push_back(ct0);}
            ct0 = 0;
            ct1 += 1;
        }
    }

    if(num0.size()<=k){
        cout << s.size() << endl;
    }
    else{
        FOR(j,0,k){
            sum0 += num0[j];
        }
        FOR(x,0,k+1){
            sum1 += num1[x];
        }
        sumvec0.push_back(make_pair(sum0,0));
        sumap1[0] = sum1;

        FOR(m,1,num0.size()-k+1){
            sum0 = sum0 - num0[m-1] + num0[m+k-1];
            sumvec0.push_back(make_pair(sum0,m));
        }
        FOR(m,1,num1.size()-k){
            sum1 = sum1 - num0[m-1] + num0[m+k];
            sumap1[m] = sum1;
        }
        sort(sumvec0.begin(),sumvec0.end());
        if(s[0]==1){
            cout << sumap1[sumvec0[0].second] + sumvec0[0].first << endl;
        }
        else{
            cout << sumap1[sumvec0[0].second-1] + sumvec0[0].first << endl;
        }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:2: error: expected '}' at end of input
   65 | }
      |  ^
a.cc:15:11: note: to match this '{'
   15 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N,K;
	cin >> N >> K;
	char S[N];
	cin >> S;
	vector<pair<int,int>> st(N); //first is num. second is count.
	rep(i,0,N){
		if(st.empty() || st.back().first != S[i]){
			st.emplace_back(S[i],1);
		}else{
			st.back().second++;
		}
	}
	int ret=0,ptr=0,sum = 0,all = 0;
	for(auto &p : st){
		while(ptr < st.size() && sum+(st[ptr].first == '0')<=K){
			sum += (st[ptr].first == '0');
			all += st[ptr].second;
			++ptr;
		}
		chmax(ret,all);
		sum -= p.first == '0';
		all -= p.second;
	}
	cout << ret << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:17: error: 'chmax' was not declared in this scope
   35 |                 chmax(ret,all);
      |                 ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N,K;
	cin >> N >> K;
	char S[N];
	cin >> S;
	vector<pair<int,int>> st(N); //first is num. second is count.
	rep(i,0,N){
		if(st.empty() || st.back().first != S[i]){
			st.emplace_back(S[i],1);
		}else{
			st.back().second++;
		}
	}
	int ret=0,ptr=0,sum = 0,all = 0;
	for(auto &p : st){
		while(ptr < st.size() && sum+(st[ptr].first == '0')<=K){
			sum += (st[ptr].first == '0');
			all += st[ptr].second;
			++ptr;
		}
		chmax(ret,all);
		sum -= p,first == '0';
		all -= p.second;
	}
	cout << ret << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:17: error: 'chmax' was not declared in this scope
   35 |                 chmax(ret,all);
      |                 ^~~~~
a.cc:36:21: error: no match for 'operator-=' (operand types are 'int' and 'std::pair<int, int>')
   36 |                 sum -= p,first == '0';
      |                 ~~~~^~~~
a.cc:36:26: error: 'first' was not declared in this scope
   36 |                 sum -= p,first == '0';
      |                          ^~~~~
Language: C++

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

vector <long long> dp;
vector <long long> PS;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n, k;
	cin >> n >> k;
	dp.push_back(1);
	string s;
	cin >> s;
	for (long long i = 1; i < n; i++){
		if (s[i] != s[i - 1]){
			dp.push_back(1);
		}
		else{
			dp[dp.size() - 1] ++;
		}
	}
	PS.resize(dp.size() + 1);
	for (long long i = 1; i <= dp.size(); i++)
		PS[i] = PS[i - 1] + dp[i - 1];
	if (dp.size() <= 2 * k || (dp.size() == 2 * k + 1) && s[0] == '1'){
		cout << n;
		return 0;
	}
	long long ans = 0;
	for (long long i = 0; i < dp.size(); i++){
		if (s[0] == i % 2 + '0'){
			if (i + 2 * k > dp.size()){
				ans = max(ans, PS[dp.size] - PS[i]);
				// break;
			}
			ans = max(ans, PS[i + 2 * k] - PS[i]);
		}
		else{
			if (i + 2 * k + 1 > dp.size()){
				ans = max(ans, PS[dp.size] - PS[i]);
				// break;
			}
			ans = max(ans, PS[i + 2 * k + 1] - PS[i]);
		}
	}
	cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:50: error: invalid use of non-static member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long long int; _Alloc = std::allocator<long long int>; size_type = long unsigned int]'
   36 |                                 ans = max(ans, PS[dp.size] - PS[i]);
      |                                                  ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:992:7: note: declared here
  992 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
a.cc:43:50: error: invalid use of non-static member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long long int; _Alloc = std::allocator<long long int>; size_type = long unsigned int]'
   43 |                                 ans = max(ans, PS[dp.size] - PS[i]);
      |                                                  ^
/usr/include/c++/14/bits/stl_vector.h:992:7: note: declared here
  992 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  string s;cin>>s;
  int count=0;
  vector<int> v(n),v2(n);
  for(inti=0;i<n-1;i++){
    if(s[i]=='0'&&s[i+1]=='1'){
      count++;
      v[count]=i;
    }
    if(s[i]=='1'&&s[i+1]=='0'){
      v2[count]=i;
    }
  }
  int ma=0;
  for(int i=k+1;i<count+1;i++){
    ma=max(v2[i]-v[i-k],ma);
  }
  cour<<ma<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'inti' was not declared in this scope; did you mean 'int'?
    8 |   for(inti=0;i<n-1;i++){
      |       ^~~~
      |       int
a.cc:8:14: error: 'i' was not declared in this scope
    8 |   for(inti=0;i<n-1;i++){
      |              ^
a.cc:21:3: error: 'cour' was not declared in this scope
   21 |   cour<<ma<<endl;
      |   ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> val;
    int cnt=0;
    char v=S[0];
    int flg=int(v=='1');
    rep(i,N){
        if(S[i]==v)cnt++;
        else{
            val.push_back(cnt);
            cnt=1;
            v=S[i];
        }
        if(i==N-1)val.push_back(cnt);
    }
    vector<int> sum_val;
    int tmp=0;
    sum_val.push_back(0);
    for(auto x:val){
        tmp+=x;
        sum_val.push_back(tmp);
    }
    // K = min(K,int(sum_val.size()));
    // DEBUG{
    //     cout << K << endl;
    //     rep(i,sum_val.size()){
    //         cout << sum_val[i] << endl;
    //     }
    // }
    int res=0;
    rep(i,N) {
        if(flg){
            if(i+2*K>=sum_val.size())continue;
            else if(i+2*K+1>=sum_val.size()){
                res = max(res, sum_val[i+2*K]-sum_val[i]);
                continue
            }
            res = max(res, sum_val[i+2*K+1]-sum_val[i]);
        }
        else{
            if(i+2*K>=sum_val.size())continue;
            res = max(res, sum_val[i+2*K]-sum_val[i]);
        }
        flg =1-flg;
    }
    if(res==0){
        res=sum_val[sum_val.size()-1];
    }
    cout << res << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:25: error: expected ';' before '}' token
   47 |                 continue
      |                         ^
      |                         ;
   48 |             }
      |             ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX_N (int)1e5

int N, K;
string S;
vector<pair<int, char>> a;

void solve(){
    a.emplace_back(make_pair(0, S[0]));
    for(int i=1;i<N;i++) {
        if(S[i] != S[i-1]){
            a.emplace_back(make_pair(i, S[i]));
        }
    }
    a.emplace_back(make_pair(N, S[N-1]));

    while(a.size()<3*K+1){
        a.emplace_back(make_pair(N, S[N-1]));
    }

    int MAX = 0;
    rep(i, a,size()-2*K){
        if(a[i].second=='0'){
            MAX = max(MAX, a[i+2*K].first - a[i].first);
        }else if(a[i].second=='1'){
            MAX = max(MAX, a[i+2*K+1].first - a[i].first);
        }
    }
    printf("%d\n", MAX);
}

int main(){
    cin >> N >> K;
    cin >> S;    
    solve();
    // printf("%d\n", a.size());
    // rep(i, a.size()){
    //     printf("%d\n", a[i].first);
    // }
    return 0;
}

Compiler output:
a.cc:26:24: error: macro "rep" passed 3 arguments, but takes just 2
   26 |     rep(i, a,size()-2*K){
      |                        ^
a.cc:5:9: note: macro "rep" defined here
    5 | #define rep(i,n) for(int i=0;i<n;i++)
      |         ^~~
a.cc: In function 'void solve()':
a.cc:26:5: error: 'rep' was not declared in this scope
   26 |     rep(i, a,size()-2*K){
      |     ^~~
Language: C++

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

  vector<int> nums;
  if (S.at(0) == '0') nums.push_back(0);
  for (int i = 0; i < S.size();) {
    int j = i;
    while (j < S.size() && S.at(j) == S.at(i)) j++;
    nums.push_back(j - i);  // 違うポイント
    i = j;
  }
  if (S.back() == '0') nums.push_back(0);
  // 累積和
  vector<int> sums((int)nums.size + 1, 0);
  for (int i = 0;i < nums.size(); i++) sums.at(i+1) = sums.at(i) + nums.at(i);
  
  int res = 0;
  for (int left = 0; left < sums.size(); left += 2) {
    int right = left + K*2+1;
    if (right >= sums.size()) right = (int)sums.size()-1;
    res = max(res,sums.at(right) - sums.at(left));  // max関数ってこんな使い方できるんや
  }
  cout << res << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:30: 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 '()' ?)
   20 |   vector<int> sums((int)nums.size + 1, 0);
      |                         ~~~~~^~~~
      |                                  ()
Language: C++

vector<int> section_sum(vector<int> numbers,int separate){
    int n = numbers.size()-separate;
    int initial_sum;
    decltype(numbers)::iterator nb = numbers.begin();
    decltype(numbers)::iterator ne = numbers.end();
    if (n<=0){
        vector<int> sep1;
        sep1.push_back(accumulate(nb,ne,0));
        return sep1;
    }else{
        vector<int> sep1(n),sep2(n),sep3(separate);
        sep1 = vector<int>(nb+separate , ne);
        sep2 = vector<int>(nb , ne-separate);
        sep3 = vector<int>(nb , nb+separate);
        initial_sum=accumulate(sep3.begin(),sep3.end(),0);
        for(int i=0  ;i<n  ;i++) sep1[i]-=sep2[i];
        for(int i=1  ;i<n  ;i++) {sep1[i]+=sep1[i-1];sep1[i-1]+=initial_sum;}
        sep1[n-1]+=initial_sum;
        sep1.insert(sep1.begin(),initial_sum);
        return sep1;
    }
}

Compiler output:
a.cc:1:1: error: 'vector' does not name a type
    1 | vector<int> section_sum(vector<int> numbers,int separate){
      | ^~~~~~
Language: C++

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    string s;
    cin >> n >> k >> s;
    VI s_cnt;
    if(s.front == '0') s_cnt.push_back(0);
    s_cnt.push_back(1);
    FOR(i, 1, s.size() - 1) {
        if(s[i] != s[i - 1]) s_cnt.push_back(1);
        else s_cnt.back()++;
    }
    if(s.back() == '0') s_cnt.push_back(0);

    VI s_sum((int)s_cnt.size() + 1, 0);
    REP(i, s_cnt.size()) s_sum[i + 1] = s_sum[i] + s_cnt[i];
    
    int ans = 0;
    for(int left = 0; left < (int)s_sum.size(); left += 2) {
        int right = min(left + k * 2 + 1, (int)s_sum.size() - 1);
        ans = max(ans, s_cnt[right] - s_cnt[left]);
    }
    cout << ans << ln;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:16: error: invalid operands of types '<unresolved overloaded function type>' and 'char' to binary 'operator=='
   29 |     if(s.front == '0') s_cnt.push_back(0);
      |        ~~~~~~~ ^~ ~~~
      |          |        |
      |          |        char
      |          <unresolved overloaded function type>
Language: C++

n,k=[int(i) for i in input().split()]
s=input()
 
ope=s[0]
cnt=1
l=[];
if s[0]=='0':
	l.append(0)
for i in range(1,len(s)):
	if s[i]==ope:
		cnt+=1
	else:
		l.append(cnt)
		ope=s[i]
		cnt=1
l.append(cnt)
 
if s[len(s)-1]=='0':
	l.append(0)
	
start=0
end=2*k
 
max_sum=sum(l[start:end+1])
cur_sum=max_sum
start+=2
end+=2
while end<len(l):
    cur_sum=cur_sum-l[start-2]-l[start-1]+l[end-1]+l[end]
    max_sum=max([max_sum,cur_sum])
    start+=2
    end+=2
print(max_sum)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,k=[int(i) for i in input().split()]
      | ^
a.cc:7:1: error: expected unqualified-id before 'if'
    7 | if s[0]=='0':
      | ^~
Language: C++

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

int main() {
  int n,k;
  std::string s;
  char last = '0';
  cin >> n >> k >> s;
  int a[114514]={0};
  int j=0;
  for(int i=0;i<n;i++){
    if(s[i]=='0'&&last=='1'){
      j++;
      a[j]=a[j-1]+1;
      last='0';
    }else if(s[i]=='0'){
      a[j]++;
    }else if(s[i]=='1'&&last=='0'){
      j++;
      a[j]=a[j-1]+1;
      last='1';
    }else if(s[i]=='1'){
      a[j]++;
    }
  }
  if(j<2*k)cout << n <<endl;
  else{
    int res=a[2*k-1];
    for(int i=0;2*i<=j-2*k-1;i++){
      if(res<a[2*k+2*i+1]-a[2*i])res=a[2*k+2*i+1]-a[2*i];
    }
    if(j%2==0&&a[j]-a[j-2*i]>res)res=a[j]-a[j-2*i];
    cout << res <<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:27: error: 'i' was not declared in this scope
   32 |     if(j%2==0&&a[j]-a[j-2*i]>res)res=a[j]-a[j-2*i];
      |                           ^
Language: C++

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

int main() {
  int n,k;
  std::string s;
  char last = '0';
  cin >> n >> k >> s;
  int a[114514]={0};
  int j=0;
  for(int i=0;i<n;i++){
    if(s[i]=='0'&&last=='1'){
      j++;
      a[j]=a[j-1]+1;
      last='0';
    }else if(s[i]=='0'){
      a[j]++;
    }else if(s[i]=='1'&&last=='0'){
      j++;
      a[j]=a[j-1]+1;
      last='1';
    }else if(s[i]=='1'){
      a[j]++;
    }
  }
  if(j<2*k)cout << n <<endl;
  else{
    int res=a[2*k-1];
    for(int i=0;2*i<=j-2*k-1;i++){
      if(res<a[2*k+2*i+1]-a[2*i])res=a[2*k+2*i+1]-a[2*i];
    }
    if(j%2==1&&a[j]-a[j-2*i]>res)res=a[j]-a[j-2*i];
    cout << res <<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:27: error: 'i' was not declared in this scope
   32 |     if(j%2==1&&a[j]-a[j-2*i]>res)res=a[j]-a[j-2*i];
      |                           ^
Language: C++

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

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

     // Recording "number of 1" and "number of 0" alternately
     vector < int > nums;    
     if (S [ 0 ] == '0' ) nums.push_back ( 0 ); // If the beginning is 0
     for ( int i = 0 ; i <S.size ();) {
         int j = i;
         while (j <S.size () & & S [j] == S [i]) ++ j; // How far does the value of S [i] continue?
         nums.push_back (j-i);
         i = j;
     }
     if (S.back () == '0' ) nums.push_back ( 0 ); // If the last is 0

     // Cumulative sum
     vector < int > sums (( int ) nums.size () + 1 , 0 );
     for ( int i = 0 ; i <nums.size (); ++ i) sums [i + 1 ] = sums [i] + nums [i];

     // Find the maximum value of the sum of the interval of length 2K + 1 (or less) starting from the even index
     int res = 0 ;
     for ( int left = 0 ; left <sums.size (); left + = 2 ) {
         int right = left + K * 2 + 1 ;
         if (right> = sums.size ()) right = ( int ) sums.size () -1 ;
         res = max (res, sums [right]-sums [left]);
     }
     cout << res << endl;
 }



Compiler output:
a.cc: In function 'int main()':
a.cc:15:40: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   15 |          while (j <S.size () & & S [j] == S [i]) ++ j; // How far does the value of S [i] continue?
a.cc:27:54: error: expected primary-expression before '=' token
   27 |      for ( int left = 0 ; left <sums.size (); left + = 2 ) {
      |                                                      ^
a.cc:29:21: error: expected primary-expression before '=' token
   29 |          if (right> = sums.size ()) right = ( int ) sums.size () -1 ;
      |                     ^
Language: C++

#include <iostream>
#include <string>

using namespace std;

#define MAX(a, b) ((a)>(b) ? (a) : (b))


size_t count_1(char *S)
{
    for(size_t i=0; i<strlen(S); i++){
        if(S[i] != '0')
            return i;
    }

    return strlen(S);
}

size_t count_0(char *S)
{
    for(size_t i=0; i<strlen(S); i++){
        if(S[i] != '0')
            return i;
    }

    return strlen(S);
}

int main(void)
{
    size_t N;   cin >> N;
    int K = 0;  cin >> K;
    string S;   cin >> S;

    size_t l=0, r=0;
    size_t lenl=0, lenr=0, len0=0, len1=0;
    int max=0;

    
    for(int i=0; i<K; i++){

        max= 0;

        for(size_t itr; itr<S.size();){
            lenl = count_1(&S[itr]);
            len0 = count_0(&S[itr]);
            lenr = count_1(&S[itr]);
            
            if(max < lenl+len0+lenr){
                l = itr + lenl;
                r = itr + lenl + len0;

                max = lenl+len0+lenr;
            }

            itr += lenl+len0+lenr;
        }

        for(size_t i=l; i<r; i++){
            S[i] = '1';
        }
    }

    max = 0;

    for(size_t itr; itr<S.size();){
        len1 = count_1(&S[itr]);
        
        max= MAX(max, len1);

        itr += len1;
    }

    cout << len1;

    return 0;
}

Compiler output:
a.cc: In function 'size_t count_1(char*)':
a.cc:11:23: error: 'strlen' was not declared in this scope
   11 |     for(size_t i=0; i<strlen(S); i++){
      |                       ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
a.cc:16:12: error: 'strlen' was not declared in this scope
   16 |     return strlen(S);
      |            ^~~~~~
a.cc:16:12: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc: In function 'size_t count_0(char*)':
a.cc:21:23: error: 'strlen' was not declared in this scope
   21 |     for(size_t i=0; i<strlen(S); i++){
      |                       ^~~~~~
a.cc:21:23: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:26:12: error: 'strlen' was not declared in this scope
   26 |     return strlen(S);
      |            ^~~~~~
a.cc:26:12: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'