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

#include <iostream>
#include <algorthm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n;
  n = s.size();
  int a[n+1], b[n+1];
  a[0] = 0;
  b[0] = 0;
  int c[n+1], d[n+2];
  for(int i=1; i<n+1; i++){
    if(s[i] == '0') {
      a[i] = a[i-1] + 1;
      b[i] = b[i-1];
      c[a[i]-1] = i-1;
    }
    else {
      a[i] = a[i-1];
      b[i] = b[i-1] + 1;
      d[b[i]-1] = i-1;
    }
  }
  d[b[n-1]] = n+1;
  int ans = 0;
  if(a[n] <= k) ans = n;
  else if(b[n] <= k-1) ans = n;
  else{
    for(int i=k; i<=c[a[n-1]-1]; i++){
      ans = max(ans, a[i] - a[i-k] + 1);
    }
    ans = max(ans, b[k-1]);
    for(int i=k-1; i<=d[b[n-1]]; i++){
      ans = max(ans, b[i] - b[i-k+1]);
    }
  }
  cout << ans << endl;

}

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

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	long long int n, k;
	string str;
	cin >> n >> k;
	cin >> str;
	vector<long long int> vec;
	vec.push_back(0);
	long long int wa = 0;
	long long int i = 0;
	while (i < n) {
		long long int a = 0;
		for (; str[i] == '1'; i++, a++);
		wa += a;
		vec.push_back(wa);
		long long a = 0;
		for (; str[i] == '0'; i++, a++);
		wa += a;
		vec.push_back(wa);
		
	}
	long long int m = vec[1];
	for (int i = 1; i < vec.size(); i++) {
		//cout << vec[i] << endl;
		if (i + k * 2+1 < vec.size()) {
			m = max(m, vec[i + k * 2] - vec[i-1]);
		}
	}
	cout << m << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:27: error: redeclaration of 'long long int a'
   23 |                 long long a = 0;
      |                           ^
a.cc:19:31: note: 'long long int a' previously declared here
   19 |                 long long int a = 0;
      |                               ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;

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

    vector<unsigned int> arr, arr0, arr1;
    bool isStartWith1;
    if(S[0] == '1') isStartWith1 = true;
    else            isStartWith1 = false;

    arr.push_back(1);
    int temp = S[0];

    for(int i = 1; i < N; i++){
        if(temp == S[i]) arr[arr.size()-1]++;
        else             arr.push_back(1);

        temp = S[i];
    }

    for(int i = 0; i < arr.size(); i++){
        if(i % 2 == 0){
            if(isStartWith1){
                arr1.push_back(arr[i]);
            }else{
                arr0.push_back(arr[i]);
            }
        }else{
            if(isStartWith1){
                arr0.push_back(arr[i]);
            }else{
                arr1.push_back(arr[i]);
            }
        }
    }

    unsigned int ans = 0, temp1 = 0;
    unsigned int sizeArr0 = arr0.size();
    if(sizeArr0 <= K) ans = S.length();
    else{
        if(isStartWith1){
            for(int i = 0; i < K; i++){
                ans += arr0[i] + arr1[i];
            }
            ans += arr1[K];
        
            for(int i = 0; i < (sizeArr0 - K + 1); i++){
                for(int j = i; j < (i + K); j++){
                    temp1 += arr0[j] + arr1[j];
                }
                if(arr1.size() > (i+K))
                    temp1 += arr1[i+K];
                ans = max(ans, temp1);
                temp1 = 0;
            }
        }else{
            for(int i = 0; i < K; i++){
                ans += arr0[i] + arr1[i];
            }
        
            for(int i = 0; i < (sizeArr0 - K + 1); i++){
                for(int j = i; j < (i + K); j++){
                    temp1 += arr0[j] + arr1[j];
                }
              	if(j > 0) temp1 += arr1[j-1];
                if(arr1.size() > (i+K))
                    temp1 += arr1[i+K];
                ans = max(ans, temp1);
                temp1 = 0;
            }
        
        }
    }


    /*
    for(int i = 0; i < arr.size(); i++){
        cout << arr[i] << ", ";
    }
    */

    cout << ans << endl;


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:20: error: 'j' was not declared in this scope
   78 |                 if(j > 0) temp1 += arr1[j-1];
      |                    ^
Language: C++

#include <cstdio>
#include <vector>

class Status {
public:
  bool isStanding;
  int num;

  Status() {}
  Status(bool isStanding, int num) {
    this->isStanding = isStanding;
    this->num = num;
  }
};

int main(int argc, char const *argv[]) {
  int N, K, result = 0, numOfStanding = 0;
  char c, last = 'x';
  std::vector<Status> arr(0);
  scanf("%d %d\n", &N, &K);

  while ((c = getc(stdin)) != '\n') {
    if (c != last) {
      Status *st;
      if (c == '0') {
        st = new Status(true, 1);
        ++numOfStanding;
      } else {
        st = new Status(false, 1);
      }

      arr.push_back(*st);
      last = c;
    } else {
      Status& st = arr.back();
      st.num++;
    }
  }

  if (numOfStanding <= K) {
    printf("%d\n", N);
    return 0;
  }

  int start = 0;
  for (int i = 0; i <= arr.size(); ++i) {
    int count = 0, j = start, num = 0;
    
    while (num < K) {
      if (arr[j].isStanding) {
        ++num;
      count += arr[j].num;
      ++j;
    }
    if (j < arr.size()) count += arr[j].num;
    if (count > result) result = count;
    start += 1;
  }

  printf("%d\n", result);

  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:63:2: error: expected '}' at end of input
   63 | }
      |  ^
a.cc:16:40: note: to match this '{'
   16 | int main(int argc, char const *argv[]) {
      |                                        ^
Language: C++

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




int main()
{
    int N;
    int K;
    string S;
    cin >> N >> K;
    cin >> S;
    for(int j=0;j<K;j++){
        int start=0;
        int goal=0;
        int count=0;
        int maxcount=0;
        int maxstart=0;
        int maxgoal=0;
        for(int i=0;i<N;i++){
            if(S[i]=='0'){
                if(count==0) start=i;
                count++;
                if(i==N-1){
                goal=i;
                }
            }else{        
            count=0;
            maxcount=max(count,maxcount);
            goal=max(i-1,0);
            }
            if(count=maxcount){
                maxstart=start;
                maxgoal=goal;
            }
            for(int i=maxstart;i<=maxgoal;i++){
                S[i]=1;
            }
        }
    }   int start=0;
        int goal=0;
        int count=0;
        int maxcount=0;
        int maxstart=0;
        int maxgoal=0;
        for(int i=0;i<N;i++){
            if(S[i]=='0'){
                if(count==0) start=i;
                count++;
                if(i==N-1){
                goal=i;
                }
            }else{        
            count=0;
            maxcount=max(count,maxcount);
            goal=max(i-1,0);
            }
    cout << maxcount <<endl;
    return 0;
}






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

#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = 0;

	long N, K; cin >> N >> K;
	string S; cin >> S;

	long turn0 = 0, turn1 = 0;

	long c0[100009] = {}, c1[100009] = {}; //0のまとまり //1のまとまり
	long count0 = 0, count1 = 0;
	for (int i = 1; i <= N; i++) {

		if (turn0 == 0 && S[i - 1] == '0') turn0 = 1;
		if (S[i - 1] == '0') count0++;
        if (S[i - 1] == '1' && i >= 2) if(S[i - 2] == '0') { c0[turn0] = count0; turn0++; count0 = 0; }
		if (i == N && S[N - 1] == '0') c0[turn0] = count0;
		if (i == N && S[N - 1] == '1') turn0--;

		if (turn1 == 0 && S[i - 1] == '1') turn1 = 1;
		if (S[i - 1] == '1') count1++;
        if (S[i - 1] == '0' && i >= 2) if(S[i - 2] == '1') { c1[turn1] = count1; turn1++; count1 = 0; }
		if (i == N && S[N - 1] == '1') c1[turn1] = count1;
		if (i == N && S[N - 1] == '0') turn1--;

	}

    if (turn0 <= K) {cout << N << endl; return 0;}
    
	//turn0 は 0 のまとまりの数。c0はれんぞくする0の数それぞれturn0個とturn1個
	//最初が0のとき
	long Kwa[100009] = {};
    c0[0] = 0;
    c1[0] = 0;
    c0[turn0 + 1] = 0;
    c1[turn1 + 1] = 0;
    long f , l;
    if (S[0] == '0') f = 0 ;else f = 1;
    if (S[N-1] == '0') l = 0; else l = 1;
    
    if (f == l ){
		for (int i = 1; i <= turn0; i++){ for (int j = 1; j <= K; j++) {
           Kwa[i] += c0[i + j - 1] + c1[i + j - 1 - l]; }
           Kwa[i] += c1[i - 1 + f]; 
                         }
    }else{
        for (int i = 1; i <= turn0; i++){ for (int j = 1; j <= K; j++) {
           Kwa[i] += c0[i + j - 1] + c1[i + j - 1 ]; }
           Kwa[i] += c1[i - 1 ]; 
                         }
    }
        
    if(f == 0 && l == 1){
        for (int i = 1; i <= turn0; i++){ for (int j = 1; j <= K; j++) {
           Kwa[i] += c0[i + j - 1] + c1[i + j - 2 ]; }
           Kwa[i] += c1[i]; 
    }
    
    
    
 
	sort(Kwa + 1, Kwa + turn0 + 1);

	res = Kwa[turn0];

		cout << res << endl;
}

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

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

#define REP(i,n) for(i=0;i<n;i++)

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    int n = iin(), k = iin();
    char s[n];
    stin(s);
    int t[n];
    memset(t, 0, sizeof t);
    int i, index = 0, first, c, count = 0;
    first = s[0] - '0';
    last = s[n - 1] - '0';
    c = first;
    REP(i, n) {
        if (s[i] != (c + '0')) {
            if (s[i] == '1') count++;
            if (index > 0) t[index] += t[index - 1];
            index++;
            c != c;
        }
        t[index]++;
    }
    if (index > 0) t[index] += t[index - 1];

    if (last == 0) count++;

    if (count <= k) {
        iout(n);
        return 0;
    }

    REP(i, n) {
        iout(t[i]);
    }

    int max = 0, tmp;
    for (i = -1; i < index; i+=2) {
        if (first == 0) {
            if (i == -1) {
                tmp = t[k * 2 - 1];
            } else {
                if (k * 2 + 1 + i < index) {
                    tmp = t[k * 2 + 1 + i] - t[i];
                } else if (k * 2 + 1 + i == index) {
                    tmp = t[k * 2 + i] - t[i];
                } else {
                    break;
                }
            }
        } else {
            if (i == -1) {
                tmp = t[k * 2 + 1 + i];
            } else {
                if (k * 2 + 1 + i == index) {
                    tmp = t[k * 2 + i] - t[i];
                } else if (k * 2 + 1 + i < index) {
                    tmp = t[k * 2 + 1 + i] - t[i];
                } else {
                    break;
                }
            }
        }
        if (max < tmp) {
            max = tmp;
        }
    }
    iout(max);
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:65:5: error: 'last' undeclared (first use in this function)
   65 |     last = s[n - 1] - '0';
      |     ^~~~
main.c:65:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;

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

    vector<unsigned int> arr, arr0, arr1;
    bool isStartWith1;
    if(S[0] == '1') isStartWith1 = true;
    else            isStartWith1 = false;

    arr.push_back(1);
    int temp = S[0];

    for(int i = 1; i < N; i++){
        if(temp == S[i]) arr[arr.size()-1]++;
        else             arr.push_back(1);

        temp = S[i];
    }

    for(int i = 0; i < arr.size(); i++){
        if(i % 2 == 0){
            if(isStartWith1){
                arr1.push_back(arr[i]);
            }else{
                arr0.push_back(arr[i]);
            }
        }else{
            if(isStartWith1){
                arr0.push_back(arr[i]);
            }else{
                arr1.push_back(arr[i]);
            }
        }
    }

    unsigned int ans = 0, temp1 = 0;
    unsigned int sizeArr0 = arr0.size();
    if(sizeArr0 <= K) ans = S.length();
    else{
        if(isStartWith1){
            for(int i = 0; i < K; i++){
                ans += arr0[i] + arr1[i];
            }
            ans += arr1[K];
        
            for(int i = 0; i < (sizeArr0 - K + 1); i++){
                for(int j = i; j < (i + K); j++){
                    temp1 += arr0[j] + arr1[j];
                }
              	if(j > 0) temp1 += arr1[j-1];
                if(arr0.size() > (i+K))
                    temp1 += arr0[i+K];
                ans = max(ans, temp1);
                temp1 = 0;
            }
        }else{
            for(int i = 0; i < K; i++){
                ans += arr0[i] + arr1[i];
            }
        
            for(int i = 0; i < (sizeArr0 - K + 1); i++){
                for(int j = i; j < (i + K); j++){
                    temp1 += arr0[j] + arr1[j];
                }
                if(arr1.size() > (i+K))
                    temp1 += arr1[i+K];
                ans = max(ans, temp1);
                temp1 = 0;
            }
        
        }
    }


    /*
    for(int i = 0; i < arr.size(); i++){
        cout << arr[i] << ", ";
    }
    */

    cout << ans << endl;


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:20: error: 'j' was not declared in this scope
   64 |                 if(j > 0) temp1 += arr1[j-1];
      |                    ^
Language: C++

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

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  char tmp = s.at(0);
  int ic = stoi(tmp);
  vector<int> hoge = {0,1};
  for (int i=1; i<n; i++) {
    if (s.at(i) == tmp) {
      hoge.back()++;
    }
    else {
      tmp = s.at(i);
      hoge.push_back(hoge.back()+1);
    }
  }
  cout << hoge.size() << endl;
  cout << ic << endl;
  int ans = 0;
    if (hoge.size() >= k*2 +2) {
      for (int i=0; i<=hoge.size()-(k*2 +2); i++) {
        ans = max(ans, hoge.at(i +k*2 +ic) - hoge.at(i));
        ic = (ic+1)%2;
      }
    }
    else {
      ans = hoge.back();
    }
  cout << ans << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: no matching function for call to 'stoi(char&)'
   10 |   int ic = stoi(tmp);
      |            ~~~~^~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:22: note:   no known conversion for argument 1 from 'char' to 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'}
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidate: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:23: note:   no known conversion for argument 1 from 'char' to 'const std::wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int count1 = 0;
	int count0 = 0;
	bool flag = true;
	if (s[0] == '1') {
		count1++;
	}
	else {
		count0++;
		flag = false;
	}
	deque<int>array1, array0;
	rep(i, n-1) {
		if (s[i] == s[i + 1]) {
			if (s[i] == '1') { count1++; }
			else { count0++; }
		}
		else {
			if (s[i] == '1') {
				array1.push_back(count1);
				count1 = 0;
				count0 = 1;
			}
			else {
				array0.push_back(count0);
				count1 = 1;
				count0 = 0;
			}
			
		}
	}
	if (count1 > 0) {
		array1.push_back(count1);
	}
	else if (count0 > 0) {
		array0.push_back(count0);
	}

	deque<int>sum1,sum0;
	int sum = 0;
	rep(i, array1.size()) {
		sum += array1[i];
		sum1.push_back(sum);
	}
	sum = 0;
	rep(i, array0.size()) {
		sum += array0[i];
		sum0.push_back(sum);
	}
	int ans = 0;
	if (flag) {
		//1start
		rep(i, sum0.size() - k+1) {
			int tmp = 0;
			if (i > 0) {
				tmp += sum0[i + k - 1] - sum0[i - 1];
				if (sum1.size() > sum0.size()) {
					tmp += sum1[i + k]-sum1[i-1] ;
				}
				else {
					tmp += sum1[i + k - 1]-sum[i-1];
				}
			}
			else {
				tmp += sum0[i + k-1];
				tmp += sum1[i + k-1];
			}
			ans = max(ans, tmp);
		}
	}
	else {
		//0start
		rep(i, sum0.size() - k+1 ) {
			int tmp = 0;
			if (i > 0) {
				tmp += sum0[i + k-1] - sum0[i - 1];
				if (sum1.size() - 1 >= i + k-1) {
					tmp += sum1[i + k-1];
				}
				else {
					tmp += sum1[i + k -2];
				}
				if (i > 1) {
					tmp -= sum1[i - 2];
				}

			}
			else {
				tmp += sum0[i + k-1];

				if (sum1.size() - 1 >= i + k-1) {
					tmp += sum1[i + k-1];
				}
				else {
					tmp += sum1[i + k - 2];
				}

			}
			ans = max(ans, tmp);
			//cout << tmp << endl;
		}
	}
	if (s.size() == 1) {
		ans++;
	}
	cout << ans << endl;
}

Compiler output:
a.cc:16:9: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   16 | #include<boost/multiprecision/cpp_int.hpp>
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.Scanner;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		int ans=0;
		int start=0;
		ArrayList<Integer> list=new ArrayList<>();
		for(int i = 0; i<n; i++){
			if(s.charAt(i)=='0'){
				while(s.charAt(i)=='0'){
					i++;
				}
				i--;
				list.add(i);
			}
		}
		int count=0;
		int u=1;
		for(int i :list){
			if(count==0){
				count++;
				continue;
			}
			while(s.charAt(i+1)=='1'){
				j++;
			}
			j--;
			
			ans=Math.max(ans,i+j-start);
			u++;
			start=list.get(u);
		}
		System.out.println(ans);
	}
}


Compiler output:
Main.java:29: error: cannot find symbol
				j++;
				^
  symbol:   variable j
  location: class Main
Main.java:31: error: cannot find symbol
			j--;
			^
  symbol:   variable j
  location: class Main
Main.java:33: error: cannot find symbol
			ans=Math.max(ans,i+j-start);
			                   ^
  symbol:   variable j
  location: class Main
3 errors
Language: C++

#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;


ll N, K;
string S;
int  ans;
int A[200009];
int B[200009];
int main() {

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


	char mae = '0';
	int cur = 0;
	FOR(i, 0, N) {
		if (mae == '0'&&S[i] == '1') {
			cur++;
			A[cur] += i + 1;
		}
		if (mae == '1'&&S[i] == '0') {
			cur++;
			A[cur] += i;
		}
		if (S[i] == '1'&&i == N - 1) {
			cur++;
			A[cur] += i + 1;
		}
		mae = S[i];
	}
	for (int j = 2;j<cur+1; j += 2) {
		ans = max(A[j] - A[max(ll(0),j - 2*K)],ans);
	}
	char mae = '0';
	reverse(S.begin(), S.end());
	cur = 0;
	FOR(i, 0, N) {
		if (mae == '0'&&S[i] == '1') {
			cur++;
			B[cur] += i + 1;
		}
		if (mae == '1'&&S[i] == '0') {
			cur++;
			B[cur] += i;
		}
		if (S[i] == '1'&&i == N - 1) {
			cur++;
			B[cur] += i + 1;
		}
		mae = S[i];
	}
	for (int j = 2; j<cur+1; j += 2) {
		ans = max(B[j] - B[max(ll(0),j - 2*K)], ans);
	}



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

Compiler output:
a.cc: In function 'int main()':
a.cc:57:14: error: redeclaration of 'char mae'
   57 |         char mae = '0';
      |              ^~~
a.cc:37:14: note: 'char mae' previously declared here
   37 |         char mae = '0';
      |              ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for ( int i = 0 ; i < n ; i++ )
#define pb push_back
vector<int> find_all(string &str,string &subStr) {
    vector<int> &result;
 
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
  int a = 0;
 
    while (true) {
        if (typeid(pos) == typeid(a)) {
          result.push_back(pos);
          pos = str.find(subStr, pos + subStrSize);
        }
      else {
        break;
      }
    }
 
    return result;
}

int main() {
  int N,T;
  string S;
  cin >> S;
  string x = "01";
  string y = "10";
  vector<int> D = find_all(S,x);
  vector<int> E = find_all(S,y);
  int ans;
  if ( S[0] == '0') {
    ans = 0;
  }
  else {
    ans = E[T]+1;
  }
  for ( int i = 0; i<E.size()-T-1 && D.size();i++) {
    if ( ans < E[i+T+1]-D[i] ) {
      ans = E[i+T+1]-D[i];
    }
  }
  cout << ans << endl;
}
  
    
    

Compiler output:
a.cc: In function 'std::vector<int> find_all(std::string&, std::string&)':
a.cc:6:18: error: 'result' declared as reference but not initialized
    6 |     vector<int> &result;
      |                  ^~~~~~
Language: C++

#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
using namespace std;
 
int main(void){
  int N,K,max=0,temp=0;
  string S;
  cin>>N>>K>>S;
  int count[2];
  count[0] = count[1] =0;
  std::vector<int> vec;
  
  
  
  rep(i,N){
  	if(S[i]=='1') {
      count[1]++;
    }
  	else {
      vec.push_back(count[1]);
      if(count[0]==K){
        for(auto itr = vec.begin(); itr != vec.end(); ++itr) {
       		temp += *itr; 
   	  }                      
        vev.erase(vec.begin());
        if(max < temp+K)max=temp+K;
        temp=0;
      }
      count[0]++;
      count[1]=0;
    }
    
  }
  vec.push_back(count[1]);
  if(count[0]==K){
    for(auto itr = vec.begin(); itr != vec.end(); ++itr) {
      temp += *itr; 
    }                      
    vev.erase(vec.begin());
    if(max < temp+K)max=temp+K;
    temp=0;
  }
  cout<<max;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'vev' was not declared in this scope; did you mean 'vec'?
   27 |         vev.erase(vec.begin());
      |         ^~~
      |         vec
a.cc:41:5: error: 'vev' was not declared in this scope; did you mean 'vec'?
   41 |     vev.erase(vec.begin());
      |     ^~~
      |     vec
Language: C++

#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
using namespace std;
 
int main(void){
  int N,K,max=0,temp=0;
  string S;
  cin>>N>>K>>S;
  int count[2];
  count[0] = count[1] =0;
  std::vector<int> vec;
  
  
  
  rep(i,N){
  	if(S[i]=='1') {
      count[1]++;
    }
  	else {
      vec.push_back(count[1]);
      if(count[0]==K){
        for(auto itr = vec.begin(); itr != vec.end(); ++itr) {
       		temp += *itr; 
   	  }                      
        v.erase(vec.begin());
        if(max < temp+K)max=temp+K;
        temp=0;
      }
      count[0]++;
      count[1]=0;
    }
    
  }
  vec.push_back(count[1]);
  if(count[0]==K){
    for(auto itr = vec.begin(); itr != vec.end(); ++itr) {
      temp += *itr; 
    }                      
    v.erase(vec.begin());
    if(max < temp+K)max=temp+K;
    temp=0;
  }
  cout<<max;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'v' was not declared in this scope
   27 |         v.erase(vec.begin());
      |         ^
a.cc:41:5: error: 'v' was not declared in this scope
   41 |     v.erase(vec.begin());
      |     ^
Language: C++

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

int main(){
  int N,K,ans=0;
  string S;
  cin>>N>>K>>S;
  vector<int> Z;
  
  int AAA=0,BBB=0;
  for(int i=0; i<N; ++i){
    if(S.at(i)=='1'){
      BBB ++;
      if(AAA>0){
        Z.push_back(AAA); 
        AAA=0;
      }
    }
    else{
      AAA ++;
      if(BBB>0){
        Z.push_back(BBB); 
        BBB=0;
      }
    }
  }
  
  vector<int> ZZ;
  int g=0;
  for(int i=0; i<Z.size(); ++i){
    g+=Z[i];
    ZZ.push_back(g);
  }
  
  if(S.at(i)=='0'){
    for(int i=0; i<Z.size()-2*K; ++i){
      if(i%2==1)ans=max(ans,ZZ[i+2*K]-ZZ[i]);
    }
  }
  else{
    for(int i=0; i<Z.size()-2*K; ++i){
      if(i%2==0)ans=max(ans,ZZ[i+2*K]-ZZ[i]);
    }
  }
  
  cout<<ans<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:38:11: error: 'i' was not declared in this scope
   38 |   if(S.at(i)=='0'){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
using namespace std;
 
int main(void){
  int N,K,max=0,temp=0;
  string S;
  cin>>N>>K>>S;
  int count[2];
  count[0] = count[1] =0;
  std::vector<int> vec;
  
  
  
  rep(i,N){
  	if(S[i]=='1') {
      count[1]++;
    }
  	else {
      vec.push_back(count[1]);
      if(count[0]==K){
        for(auto itr = v.begin(); itr != v.end(); ++itr) {
       		temp += *itr; 
   	  }                      
        v.erase(v.begin());
        if(max < temp+K)max=temp+K;
      }
      count[0]++;
      count[1]=0;
    }
    
  }
  vec.push_back(count[1]);
  if(count[0]==K){
    for(auto itr = v.begin(); itr != v.end(); ++itr) {
      temp += *itr; 
    }                      
    v.erase(v.begin());
    if(max < temp+K)max=temp+K;
  }
  cout<<max;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:24: error: 'v' was not declared in this scope
   24 |         for(auto itr = v.begin(); itr != v.end(); ++itr) {
      |                        ^
a.cc:27:9: error: 'v' was not declared in this scope
   27 |         v.erase(v.begin());
      |         ^
a.cc:37:20: error: 'v' was not declared in this scope
   37 |     for(auto itr = v.begin(); itr != v.end(); ++itr) {
      |                    ^
a.cc:40:5: error: 'v' was not declared in this scope
   40 |     v.erase(v.begin());
      |     ^
Language: C++

e(int*, int, int);

int main(void)
{
    int n, k, count, code[50000], max, sum;
    int i, j;
    char str[100000], state;

    cin >> n;
    cin >> k;
    cin >> str;

    i = j = 0;
    count = 0;
    state = '0';
    while ( str[i] != '\0' ) {
        if (state != str[i]) {
            code[j] = count;
            state = str[i];
            count = 0;
            j++;
        } else {
            i++;
            count++;
        }
    }
    code[j] = count;

    max = 0;
    for (int i=0; i<j; i++) {
        sum = sum_range(code, i, min(i+2*k+(i%2), j+1));
        if (max < sum) {
            max = sum;
        }
    }

    cout << max << endl;

    return 0;
}

int sum_range(int *array, int s, int e)
{
    int res;
    res = 0;
    for (int i=s; i<e; i++) {
        res += array[i];
    }
    return res;
}


Compiler output:
a.cc:1:18: error: expected constructor, destructor, or type conversion before ';' token
    1 | e(int*, int, int);
      |                  ^
a.cc: In function 'int main()':
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin >> n;
      |     ^~~
a.cc:31:34: error: 'min' was not declared in this scope; did you mean 'main'?
   31 |         sum = sum_range(code, i, min(i+2*k+(i%2), j+1));
      |                                  ^~~
      |                                  main
a.cc:31:15: error: 'sum_range' was not declared in this scope
   31 |         sum = sum_range(code, i, min(i+2*k+(i%2), j+1));
      |               ^~~~~~~~~
a.cc:37:5: error: 'cout' was not declared in this scope; did you mean 'count'?
   37 |     cout << max << endl;
      |     ^~~~
      |     count
a.cc:37:20: error: 'endl' was not declared in this scope
   37 |     cout << max << endl;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

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

  vector<int> a{0};
  int cnt = 1;
  rep(i, 1, N) {
    if (S[i] != S[i-1]) a.push_back(cnt);
    cnt++;
  }
  a.push_back(cnt);

  int a_size = a.size();
  if (a_size == 2) {
    cout << N << endl;
    return;
  }
  int begin_i = (S[0] == '0') ? 2 : 1;
  int end_i = (S[N-1] == '0') ? a_size-1 : a_size;
  int ans = 0;
  for (int i=begin_i; i+K*2<a_size; i++) {
    chmax(ans, a[i+K*2]-a[i-1]);
  }

  if (S[0] == '0') {
    chmax(ans, a[min(a_size-1, K*2+1)]-a[0]);
  }
  if (S[N-1] == '0') {
    chmax(ans, t-u);
  }

  cout << ans << endl;
}


Compiler output:
a.cc: In function 'void _main()':
a.cc:46:16: error: 't' was not declared in this scope
   46 |     chmax(ans, t-u);
      |                ^
a.cc:46:18: error: 'u' was not declared in this scope
   46 |     chmax(ans, t-u);
      |                  ^
Language: C++

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

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

  int count=0;
  for(i=0;i<N;i++){
    if(S.at(i)=='0'){count++;}
  }
  if(count==0){cout <<N<<endl;}
  else{if(count%2==0){cout <<count+K+1<<endl;}
       else{cout <<count+K-1<<endl;}
      }
    
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >>N>>K;
      |   ^~~
a.cc:7:2: error: 'string' was not declared in this scope
    7 |  string S;
      |  ^~~~~~
a.cc:8:9: error: 'S' was not declared in this scope
    8 |   cin >>S;
      |         ^
a.cc:11:7: error: 'i' was not declared in this scope
   11 |   for(i=0;i<N;i++){
      |       ^
a.cc:14:16: error: 'cout' was not declared in this scope; did you mean 'count'?
   14 |   if(count==0){cout <<N<<endl;}
      |                ^~~~
      |                count
a.cc:14:26: error: 'endl' was not declared in this scope
   14 |   if(count==0){cout <<N<<endl;}
      |                          ^~~~
a.cc:15:23: error: 'cout' was not declared in this scope; did you mean 'count'?
   15 |   else{if(count%2==0){cout <<count+K+1<<endl;}
      |                       ^~~~
      |                       count
a.cc:15:41: error: 'endl' was not declared in this scope
   15 |   else{if(count%2==0){cout <<count+K+1<<endl;}
      |                                         ^~~~
a.cc:16:13: error: 'cout' was not declared in this scope; did you mean 'count'?
   16 |        else{cout <<count+K-1<<endl;}
      |             ^~~~
      |             count
a.cc:16:31: error: 'endl' was not declared in this scope
   16 |        else{cout <<count+K-1<<endl;}
      |                               ^~~~
Language: C++

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

string S;
void rvs(int l, int r){
	if(r < l){
		int tmp = l;
		l = r;
		r = tmp;
	}
	for(int i = l-1; i <= r; i++)
		S[i] = '1';
}
int res(){
	int max = 0, now = 0;
	for(int i = 0; i < S.size(); i++){
		if(S[i] == '1'){
			now++;
			if(now > max)
				max++;
		}else{
			now = 0;
		}
	}
	return max;
}
int search(int pt){
	int l = pt, r = pt;
	int lsum = 0, rsum = 0;
	while(0 <= l && S[l] == '1'){
		l--;
	}
	l--;
	while(0 <= l && S[l] == '0'){
		lsum++;
		l--;
	}
	while(r < S.size() && S[r] == '1'){
		r++;
	}
	r++;
	while(r < S.size() && S[r] == '0'){
		rsum++;
		r++;
	}
	return (lsum > rsum ? l : r);
}

int main(){
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;
	int max = 0, pt = 0;
	while(pt < N){
		if(s.at[pt] == '1'){
			S = s;
			for(int i = 0; i < K; i++){
				rvs(search(pt),pt);
			}
			if(max < res())
				max = res();
		}
		pt++;
	}
	cout << max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:24: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   56 |                 if(s.at[pt] == '1'){
      |                        ^
Language: C++

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

string S;
void rvs(int l, int r){
	if(r < l){
		int tmp = l;
		l = r;
		r = tmp;
	}
	for(int i = l-1; i <= r; i++)
		S[i] = "1";
}
int res(){
	int max = 0, now = 0;
	for(int i = 0; i < S.size(); i++){
		if(S[i] == "1"){
			now++;
			if(now > max)
				max++;
		}else{
			now = 0;
		}
	}
	return max;
}
int search(int pt){
	int l = pt, r = pt;
	int lsum = 0, rsum = 0;
	while(0 <= l && S[l] == '1'){
		l--;
	}
	l--;
	while(0 <= l && S[l] == '0'){
		lsum++;
		l--;
	}
	while(r < S.size() && S[r] == '1'){
		r++;
	}
	r++;
	while(r < S.size() && S[r] == '0'){
		rsum++;
		r++;
	}
	return (lsum > rsum ? l : r);
}

int main(){
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;
	int max = 0, pt = 0;
	while(pt < N){
		if(s.at[pt] == '1'){
			S = s;
			for(int i = 0; i < K; i++){
				rvs(search(pt),pt);
			}
			if(max < res())
				max = res();
		}
		pt++;
	}
	cout << max << endl;
}

Compiler output:
a.cc: In function 'void rvs(int, int)':
a.cc:12:24: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   12 |                 S[i] = "1";
      |                        ^~~
      |                        |
      |                        const char*
a.cc: In function 'int res()':
a.cc:17:25: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |                 if(S[i] == "1"){
a.cc: In function 'int main()':
a.cc:56:24: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   56 |                 if(s.at[pt] == '1'){
      |                        ^
Language: C++

/*
*  Author: windystreet
*  Date  : 2019-04-13 20:02:03
*  Motto : Think twice, code once.
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

string s;
int num[maxn];
void solve(){
	int n,k;
	while(cin>>n>>k){
		cin>>s;
		int pos = 0;
		int cnt = 0;
		mem(num,0);
		for(int i=1;i<n;i++){
			if(s[i] != s[i-1]){
				num[++pos] = cnt+1;
				cnt = 0;
			}else{
				++cnt;
			}
		}
		num[++pos] = cnt+1;
		// for(int i=1;i<=pos;i++){
		// 	printf("%d%c",num[i]," \n"[i==pos] );
		// }
		int ans = 0;int sum = 0;
		if(s[0] == '0'){
			sum = 0;
			for(int i=1; i<=pos &&i<=k*2;i++){
				sum += num[i];
			}
			ans = max(ans,sum);
			int flag = 0;
			for(int i=k*2+1;i<=pos;i++){
				flag ^=1;
				sum += (num[i] - num[i-k*2]);
				if(flag&1){
					ans = max(ans,sum);
				}else{
					ans = max(ans,sum - num[i-k*2]);
				}
			}
		}else{
			sum = 0;
			for(int i=1; i<=pos &&i<=k*2+1;i++){
				sum += num[i];
			}
			ans = max(ans,sum);
			int flag = 1;
			for(int i=k*3;i<=pos;i++){
				flag ^=1;
				sum += (num[i] - num[i-k*2-1]);
				if(flag&1){
					ans = max(ans,sum);
				}else{
					ans = max(ans,sum - num[i-k*2-1]);
				}
			}
		}
		if(s[n-1] =='0'){
			sum = 0;
			for(int i=pos;i>=1 && i>=pos - 2*k+1;i--)
				sum += num[i];
			ans = max(ans,sum);
			int flag = 0;
			for(int i=pos- 2*k;i>=1;i--){
				flag^=1;
				sum += (num[i] - num[i+k*2]);
				if(flag&1){
					ans = max(ans,sum);
				}else{
					ans = max(ans,sum - num[i+k+2])
				}
			}
		}else{
			sum = 0;
			for(int i=pos;i>=1 && i>=pos - 2*k;i--)
				sum += num[i];
			int flag = 1;
			ans = max(ans,sum);
			for(int i=pos- 2*k-1;i>=1;i--){
				flag ^= 1;
				sum += (num[i] - num[i+k*2+1]);
				if(flag&1){
					ans = max(ans,cnt);
				}else{
					ans = max(ans,sum - num[i+k*2+1]);
				}
			}
		


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


    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("F:/in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:96:72: error: expected ';' before '}' token
   96 |                                         ans = max(ans,sum - num[i+k+2])
      |                                                                        ^
      |                                                                        ;
   97 |                                 }
      |                                 ~
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<ll> daiji;
    for(int i = 0; i < N;i++){
        char c = S[i];
        ll count = 0;
        while(S[i] == c){
            count++;
            i++;
        }
        i--;
        daiji.push_back(count);
    }
    if(daiji.size() <= 2*K+1 && S[0] == '1'){
        cout << N << endl;
        return 0;
    }else if(daiji.size() <= 2*K && S[0] == '0'){
        cout << N << endl;
        return 0;
    }
    ll max = 0;
    if(S[0] == '1'){
        if(S[S.size()-1] == '0'){
             for(int i = 0; i < daiji.size()-(2*K;1);i++){
                if(i%2 == 0){
                    ll tmp=0;
                    for(int j = i; j < i+2*K+1;j++){
                        tmp += daiji[j];
                    }
                    if(max < tmp) max = tmp;
                }
            }

        }else{
            for(int i = 0; i < daiji.size()-(2*K);i++){
                if(i%2 == 0){
                    ll tmp=0;
                    for(int j = i; j < i+2*K+1;j++){
                        tmp += daiji[j];
                    }
                    if(max < tmp) max = tmp;
                }
            }
        }

    }else{
        for(int i = 0; i < daiji.size()-(2*K);i++){
            if(i%2 == 0){
                ll tmp=0;
                for(int j = i; j < i+2*K;j++){
                    tmp += daiji[j];
                }
                if(max < tmp) max = tmp;
            }else{
                ll tmp=0;
                for(int j = i; j < i+2*K+1;j++){
                    tmp += daiji[j];
                }
                if(max < tmp) max = tmp;
                
            }
        }
    }
    cout << max << endl;
    

    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:50: error: expected ')' before ';' token
   60 |              for(int i = 0; i < daiji.size()-(2*K;1);i++){
      |                                              ~   ^
      |                                                  )
a.cc:60:54: error: 'i' was not declared in this scope
   60 |              for(int i = 0; i < daiji.size()-(2*K;1);i++){
      |                                                      ^
Language: C++

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

struct set
{
	int idx;
	int num;
	int setNum;
};

char s[100000];
int main() {
	int n, k;

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

	vector<set> address;

	int preNum = s[0] - '0';
	int setNum = 1;
	for (int i = 1; i < n; i++) {
		int a = s[i] - '0';
		if (a == preNum) {
			setNum++;
		}
		else {
			set hoge;
			hoge.idx = i - 1;
			hoge.num = preNum;
			hoge.setNum = setNum;

			preNum = a;
			setNum = 1;
		}
	}

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

		int maxNum = 0;
		int maxIdx = -1;
		for (int j = 0; j < address.size - 1; j++) {
			int sum = 0;
			for (int k = 0; k < 3;k++) {
				if (j+k < address.size) {
					sum += address[j + k].setNum;
				}
			}

			if (sum > maxNum) {
				maxIdx = address[j].idx;
				maxNum = sum;
			}

			if (maxIdx < 0) {
				continue;
			}

			address[maxIdx].setNum = sum;
			for (int k = 1; k < 3;k++) {
				if (maxIdx < address.size) {
					address.erase(address.begin() + maxIdx + k);
				}
			}
		}
	}

	int max = 0;
	for (int i = 0; i < address.size;i++) {
		if (address[i].setNum > max) {
			max = address[i].setNum;
		}
	}

	cout << max;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:45: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = set; _Alloc = std::allocator<set>; size_type = long unsigned int]' (did you forget the '()' ?)
   44 |                 for (int j = 0; j < address.size - 1; j++) {
      |                                     ~~~~~~~~^~~~
      |                                                 ()
a.cc:47:51: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = set; _Alloc = std::allocator<set>; size_type = long unsigned int]' (did you forget the '()' ?)
   47 |                                 if (j+k < address.size) {
      |                                           ~~~~~~~~^~~~
      |                                                       ()
a.cc:63:54: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = set; _Alloc = std::allocator<set>; size_type = long unsigned int]' (did you forget the '()' ?)
   63 |                                 if (maxIdx < address.size) {
      |                                              ~~~~~~~~^~~~
      |                                                          ()
a.cc:71:37: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = set; _Alloc = std::allocator<set>; size_type = long unsigned int]' (did you forget the '()' ?)
   71 |         for (int i = 0; i < address.size;i++) {
      |                             ~~~~~~~~^~~~
      |                                         ()
Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>
#include <utility>

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

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

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

	vector<int> start;
	vector<int> end;

	if(s[0]=='1'){
		start.push_back(0);
	}
	repd(i,1,n){
		if(s[i-1]=='1' && s[i]=='0')
			end.push_back(i-1);
		if(s[i-1]=='0' && s[i]=='1')
			start.push_back(i);
	}

	if(s[n-1]=='1'){
		end.push_back(n-1);
	}

	int score=0;
	int index;
	rep(i,k){

		vector<int> judge;
		judge.push_back(end[0]-0+1);

		repd(j,1,end.size()){
			judge.push_back(end[j]-start[j-1]+1);
		}

		judge.push_back(n-start[start.size()-1]);

		rep(l0,judge.size()){
			if(judge[l0]>score){
				score=judge[l0];
				index=l0;
			}
		}

		if(score==n){
			cout << n << endl
			return 0;
		}

		if(index==0){
			start[0]=0;
		}else if(index==start.size()){
			end[start.size()-1]=n-1;
		}else{
			start.erase(start.begin()+index);
			end.erase(end.begin()+index-1);
		}
	}

	cout << score << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:95:42: error: expected ';' before 'return'
   95 |                         cout << n << endl
      |                                          ^
      |                                          ;
   96 |                         return 0;
      |                         ~~~~~~
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