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

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

int sum(int c,vector<int> t){//c=size
      int d = 0;
      if(c >= 0){
      for(int j = 0; j < c; j++){
        d += t[j];
      }
      }
      return d;
    }

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  vector<int> t(50000);//s[0]==0
  vector<int> u(50000);//s[0]==1
  cin >> s;
  int x = 0;//t.size
  int max = 0;
  
  if(s[0] == '0'){
    int a = 0;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == '0'+ a){
        b++;
      }
      else {
        t[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        t[x] = b;
        x++;
      }   
    }
    
    for(int i = 0; 2*k+i <= x; i += 2){
      if(max < sum(2*k+i,t)-sum(i-1,t)){
        max = sum(2*k+i,t)-sum(i-1,t);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
        
  else{
    int a = 1;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == '0'+a){
        b++;
      }
      else {
        u[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        u[x] = b;
        x++;
      }   
    }
    
    for(int i = 0; 2*k+i+1 <= x; i += 2){
      if(max < sum(2*k+i+1,u)-sum(i,u){
        max = sum(2*k+i+1,u)-sum(i,u);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:81:39: error: expected ')' before '{' token
   81 |       if(max < sum(2*k+i+1,u)-sum(i,u){
      |         ~                             ^
      |                                       )
a.cc:84:5: error: expected primary-expression before '}' token
   84 |     }
      |     ^
Language: C++

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

int sum(int c,vector<int> t(50000)){//c=size
      int d = 0;
      if(c >= 0){
      for(int j = 0; j < c; j++){
        d += t[j];
      }
      }
      return d;
    }

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  vector<int> t(50000);//s[0]==0
  vector<int> u(50000);//s[0]==1
  cin >> s;
  int x = 0;//t.size
  int max = 0;
  
  if(s[0] == '0'){
    int a = 0;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == '0'+ a){
        b++;
      }
      else {
        t[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        t[x] = b;
        x++;
      }   
    }
    
    for(int i = 0; 2*k+i <= x; i += 2){
      if(max < sum(2*k+i,t)-sum(i-1,t)){
        max = sum(2*k+i,t)-sum(i-1,t);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
        
  else{
    int a = 1;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == '0'+a){
        b++;
      }
      else {
        u[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        u[x] = b;
        x++;
      }   
    }
    
    for(int i = 0; 2*k+i+1 <= x; i += 2){
      if(max < sum(2*k+i+1,u)-sum(i,u){
        max = sum(2*k+i+1,u)-sum(i,u);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
}


Compiler output:
a.cc:4:28: error: expected ',' or '...' before '(' token
    4 | int sum(int c,vector<int> t(50000)){//c=size
      |                            ^
a.cc: In function 'int main()':
a.cc:81:39: error: expected ')' before '{' token
   81 |       if(max < sum(2*k+i+1,u)-sum(i,u){
      |         ~                             ^
      |                                       )
a.cc:84:5: error: expected primary-expression before '}' token
   84 |     }
      |     ^
Language: C++

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

int sum(int c){//c=size
      int d = 0;
      if(c >= 0){
      for(int j = 0; j < c; j++){
        d += t[j];
      }
      }
      return d;
    }

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  vector<int> t(50000);//s[0]==0
  vector<int> u(50000);//s[0]==1
  cin >> s;
  int x = 0;//t.size
  int max = 0;
  
  if(s[0] == '0'){
    int a = 0;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == '0'+ a){
        b++;
      }
      else {
        t[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        t[x] = b;
        x++;
      }   
    }
    
    for(int i = 0; 2*k+i <= x; i += 2){
      if(max < sum(2*k+i)-sum(i-1)){
        max = sum(2*k+i)-sum(i-1);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
        
  else{
    int a = 1;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == '0'+a){
        b++;
      }
      else {
        t[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        t[x] = b;
        x++;
      }   
    }
    
    for(int i = 0; 2*k+i+1 <= x; i += 2){
      if(max < sum(2*k+i+1)-sum(i)){
        max = sum(2*k+i+1)-sum(i);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
}


Compiler output:
a.cc: In function 'int sum(int)':
a.cc:8:14: error: 't' was not declared in this scope
    8 |         d += t[j];
      |              ^
Language: C++

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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  vector<int> t(50000);//s[0]==0
  vector<int> u(50000);//s[0]==1
  cin >> s;
  int x = 0;//t.size
  int max = 0;
  
  if(s[0] == '0'){
    int a = 0;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == '0'+ a){
        b++;
      }
      else {
        t[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        t[x] = b;
        x++;
      }   
    }
    int sum(int c){//c=size
      int d = 0;
      if(c >= 0){
      for(int j = 0; j < c; j++){
        d += t[j];
      }
      }
      return d;
    }
    for(int i = 0; 2*k+i <= x; i += 2){
      if(max < sum(2*k+i)-sum(i-1)){
        max = sum(2*k+i)-sum(i-1);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
        
  else{
    int a = 1;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == '0'+a){
        b++;
      }
      else {
        t[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        t[x] = b;
        x++;
      }   
    }
    int sum(int c){//c=size
      int d = 0;
      if(c >= 0){
      for(int j = 0; j < c; j++){
        d += t[j];
      }
      }
      return d;
    }
    for(int i = 0; 2*k+i+1 <= x; i += 2){
      if(max < sum(2*k+i+1)-sum(i)){
        max = sum(2*k+i+1)-sum(i);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:19: error: a function-definition is not allowed here before '{' token
   37 |     int sum(int c){//c=size
      |                   ^
a.cc:47:16: error: 'sum' was not declared in this scope
   47 |       if(max < sum(2*k+i)-sum(i-1)){
      |                ^~~
a.cc:77:19: error: a function-definition is not allowed here before '{' token
   77 |     int sum(int c){//c=size
      |                   ^
a.cc:87:16: error: 'sum' was not declared in this scope
   87 |       if(max < sum(2*k+i+1)-sum(i)){
      |                ^~~
Language: Java

public class Main {
    
    public static void main(String[] args) throws IOException {
        
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String[] str = bf.readLine().split(" ");
        int N = Integer.parseInt(str[0]), K = Integer.parseInt(str[1]), max = 0;
        String[] S = bf.readLine().split("");
        ArrayList<Integer> data = new ArrayList<>();
        int value = Integer.parseInt(S[0]);
        if (value == 0) {
            data.add(0);
        }
        for (int i = 0; i < N; value = 1 - value) {
            int count = 0;
            while (i < N && Integer.parseInt(S[i]) == value) {
                count++;
                i++;
            }
            data.add(count);
        }
        if (value == 1) {
            data.add(0);
        }
        int size = data.size(), sum = 0;
        for (int i = 0; i < 2 * K + 1 && i < size; i++) {
            sum += data.get(i);
        }
        max = sum;
        for (int i = 3; i + 2 * K - 1 < size; i += 2) {
            sum += -data.get(i - 3) - data.get(i - 2) + data.get(i + 2 * (K - 1)) + data.get(i + 2 * K - 1);
            if (max < sum) {
                max = sum;
            }
        }
        System.out.println(max);
    }
}

Compiler output:
Main.java:3: error: cannot find symbol
    public static void main(String[] args) throws IOException {
                                                  ^
  symbol:   class IOException
  location: class Main
Main.java:5: error: cannot find symbol
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        ^
  symbol:   class BufferedReader
  location: class Main
Main.java:5: error: cannot find symbol
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
                                ^
  symbol:   class BufferedReader
  location: class Main
Main.java:5: error: cannot find symbol
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
                                                   ^
  symbol:   class InputStreamReader
  location: class Main
Main.java:9: error: cannot find symbol
        ArrayList<Integer> data = new ArrayList<>();
        ^
  symbol:   class ArrayList
  location: class Main
Main.java:9: error: cannot find symbol
        ArrayList<Integer> data = new ArrayList<>();
                                      ^
  symbol:   class ArrayList
  location: class Main
6 errors
Language: Java

ソースコード 

Copy
Copy
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));
        String[] str = bf.readLine().split(" ");
        int N = Integer.parseInt(str[0]),
            K = Integer.parseInt(str[1]),
            max = 0;
        String[] S = bf.readLine().split("");            
        ArrayList<Integer> data = new ArrayList<>();
        int value = Integer.parseInt(S[0]);
        if(value == 0){
            data.add(0);
        }
        for(int i = 0; i < N; value = 1-value){
            int count = 0;
            while(i < N && Integer.parseInt(S[i]) == value){
                count++;
                i++;
            }            
            data.add(count);
        }
        if(value == 1){
            data.add(0);
        }
        int size = data.size(),
            sum = 0;
        for(int i = 0; i < 2*K+1 && i < size; i++){
            sum += data.get(i);
        }
        max = sum;
        for(int i = 3; i+2*K-1 < size; i += 2){
            sum += -data.get(i-3) - data.get(i-2) + data.get(i+2*(K-1))+data.get(i+2*K-1);
            if(max < sum){
                max = sum;
            }
        }
        System.out.println(max);
    }
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
?????? 
^
Main.java:6: error: class, interface, enum, or record expected
import java.util.*;
^
2 errors
Language: Java

import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));
        String[] str = bf.readLine().split(" ");
        int N = Integer.parseInt(str[0]),
            K = Integer.parseInt(str[1]),
            max = 0;
        String[] S = bf.readLine().split("");            
        ArrayList<Integer> data = new ArrayList<>();
        int value = Integer.parseInt(S[0]);
        if(value == 0){
            data.add(0);
        }
        for(int i = 0; i < N; value = 1-value){
            int count = 0;
            while(i < N && Integer.parseInt(S[i]) == value){
                count++;
                i++;
            }            
            data.add(count);
        }
        if(value == 1){
            data.add(0);
        }
        int size = data.size(),
            sum = 0;
        for(int i = 0; i < 2*K+1 && i < size; i++){
            sum += data.get(i);
        }
        max = sum;
        for(int i = 3; i+2*K-1 < size; i += 2){
            sum += -data.get(i-3) - data.get(i-2) + data.get(i+2*(K-1))+data.get(i+2*K-1);
            if(max < sum){
                max = sum;
            }
        }
        System.out.println(max);
    }

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

#include<bits/stdc++.h>
using namespace std;
long long n,k;
vector<long long> v;
string s;
long long res=-1;
int main()
{
	cin>>n>>k>>s;
	long long tmp=0;
	long long x=s[0]-'0';
	for(long long i=0;i<n;i++)
	{
		if(x!=s[i]-'0')
		{
			v.push_back(tmp);
			tmp=0;
			x^=1;
		}
		++tmp;
	}
	v.push_back(tmp);
	for(long long i=0;i<v.size();i++)
	{
		long long u=k*2+(i!=0&&i!=v.size()-1-(k-1)*k);
		long long ans=0;
		for(long long j=i;j<min(v.size()-1,i+u);j++)
			ans+=v[j];
		res=max(res,ans);
	}
	cout<<res<<endl;
	return 0;
}

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

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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  vector<int> t(50000);//s[0]==0
  vector<int> u(50000);//s[0]==1
  cin >> s;
  int x = 0;//t.size
  int max = 0;
  
  if(s[0] == '0'){
    int a = 0;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == a){
        b++;
      }
      else {
        t[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        t[x] = b;
        x++;
      }   
    }
    int sum(int c){//c=size
      int d = 0;
      if(c >= 0){
      for(int j = 0; j < c; j++){
        d += t[j];
      }
      }
      return d;
    }
    for(int i = 0; 2*k+i <= x; i += 2){
      if(max < sum(2*k+i)-sum(i-1)){
        max = sum(2*k+i)-sum(i-1);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
        
  else{
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:19: error: a function-definition is not allowed here before '{' token
   37 |     int sum(int c){//c=size
      |                   ^
a.cc:47:16: error: 'sum' was not declared in this scope
   47 |       if(max < sum(2*k+i)-sum(i-1)){
      |                ^~~
Language: C++

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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  vector<int> t(50000);//s[0]==0
  vector<int> u(50000);//s[0]==1
  cin >> s;
  int x = 0;//t.size
  int max = 0;
  
  if(s[0] == '0'){
    int a = 0;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == a){
        b++;
      }
      else {
        t[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        t[x] = b;
        x++;
      }   
    }
    int sum(int c)//c=size
      int d = 0;
      if(c >= 0){
      for(int j = 0; j < c; j++){
        d += t[j];
      }
      }
      return d;
    }
    for(int i = 0; 2*k+i <= x; i += 2){
      if(max < sum(2*k+i)-sum(i-1)){
        max = sum(2*k+i)-sum(i-1);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
        
  else{
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:7: error: expected initializer before 'int'
   38 |       int d = 0;
      |       ^~~
a.cc:39:10: error: 'c' was not declared in this scope
   39 |       if(c >= 0){
      |          ^
a.cc:41:9: error: 'd' was not declared in this scope
   41 |         d += t[j];
      |         ^
a.cc:44:14: error: 'd' was not declared in this scope
   44 |       return d;
      |              ^
a.cc:47:16: error: 'sum' was not declared in this scope
   47 |       if(max < sum(2*k+i)-sum(i-1)){
      |                ^~~
a.cc: At global scope:
a.cc:54:3: error: expected unqualified-id before 'else'
   54 |   else{
      |   ^~~~
a.cc:56:1: error: expected declaration before '}' token
   56 | }
      | ^
Language: C++

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

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  vector<int> t(50000);//s[0]==0
  vector<int> u(50000);//s[0]==1
  cin >> s;
  int x = 0;//t.size
  int max = 0;
  
  if(s[0] == '0'){
    int a = 0;
    int b = 0;
    for(int i = 0; i < n; i++){
      if(s[i] == a){
        b++;
      }
      else {
        t[x] = b;
        x++;
        b = 1;
        if(a == 0){
          a = 1;
        }
        else{
          a = 0;
        }
      }
      if(i == n-1){
        t[x] = b;
        x++;
      }   
    }
    int sum(int c){//c=size
      int d = 0;
      if(c >= 0){
      for(int j = 0; j < c; j++){
        d += t[j];
      }
      }
      return d;
    }
    for(int i = 0; 2*k+i <= x; i += 2){
      if(max < sum(2*k+i)-sum(i-1)){
        max = sum(2*k+i)-sum(i-1);//最後の項の輪の議論が怪しい
      }
    }
    cout << max << endl;
  }
        
  else{
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:19: error: a function-definition is not allowed here before '{' token
   37 |     int sum(int c){//c=size
      |                   ^
a.cc:47:16: error: 'sum' was not declared in this scope
   47 |       if(max < sum(2*k+i)-sum(i-1)){
      |                ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define vecin1(n) vector<int> vec1(n); rep(i,n) cin >> vec1.at(i)
#define vecin2(n) vector<int> vec2(n); rep(i,n) cin >> vec2.at(i)
typedef long long ll;


int main() {

int ans = 0;
int n = 0; //S.length()
int K = 0; //ひっくりかえせる回数
vector<int> sum(0); //連続する0の回数を格納する配列
string S;
cin >> n >> K >> S;
int p = 0; //rep用仮保管
int q = 0;
int mode = 0; //前回の数字のメモ
rep(i,n)
{
  if (mode = 0)
  {
  if (S.at(i) == 0)
    p++; //連続する0の回数を数える
  else
  {
    sum.push_back(p); //連続する0の終わりにつき，その回数をsumに格納
    p = 1; //リセット
    mode = 1;
  }
  }

  else
  {
    if (S.at(i) == 1)
    p++; //連続する0の回数を数える
  else
  {
    sum.push_back(p); //連続する0の終わりにつき，その回数をsumに格納
    p = 1; //リセット
    mode = 0;
  }
  }
}
sum.push_back(p) //最後に残ったpを格納
if (mode = 1)
sum.push_back(0) //もし最後が連続する1の和で終わったら困るので，最後は0の列が0個とする．列の数は奇数

vector<int> sum2(n); //累積和を考える
rep(i,n)
{
  if(i==0)
  sum2.at(i) = sum.at(i)
  else
  sum2.at(i) = sum2.at(i-1)+sum.at(i)
}
vector<int> sum3(n); //累積和から最大値を考える
rep(i,n)
{
  sum3.at(i) = sum2.at(2*k+2) - sum()
}
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:17: error: expected ';' before 'if'
   49 | sum.push_back(p) //最後に残ったpを格納
      |                 ^
      |                 ;
   50 | if (mode = 1)
      | ~~               
a.cc:57:3: error: 'sum2' was not declared in this scope; did you mean 'sum'?
   57 |   sum2.at(i) = sum.at(i)
      |   ^~~~
      |   sum
a.cc:64:16: error: 'sum2' was not declared in this scope; did you mean 'sum3'?
   64 |   sum3.at(i) = sum2.at(2*k+2) - sum()
      |                ^~~~
      |                sum3
a.cc:64:26: error: 'k' was not declared in this scope
   64 |   sum3.at(i) = sum2.at(2*k+2) - sum()
      |                          ^
a.cc:64:36: error: no match for call to '(std::vector<int>) ()'
   64 |   sum3.at(i) = sum2.at(2*k+2) - sum()
      |                                 ~~~^~
Language: C++

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

int main(){
  int ans = 0;
  int N;
  cin >> N;
  int K;
  cin >> K;
  int S[N];
  vector<int> v;
  for(int i=0;i<N;i++){
    cin >> S[i];
  }
  for(int i=0;i<N;i++){
    int count = 0;
    int one_times = 0;
    if(S[i] == 1){
      one_times++;
    }
    for(int j=i;S[j] == 0;j++){
          count++;
          i++;
        }
      v.push_back(count);
  }
   std::sort(v.begin(), v.end(), std::greater<int>() );
  int times = 0;
  for(int i=0;i<K;i++){
    times += v[i];
  }
  ans = times + one_times;
  cout << ans << endl;
  return 0;
}
    
          
          
      

Compiler output:
a.cc: In function 'int main()':
a.cc:35:17: error: 'one_times' was not declared in this scope
   35 |   ans = times + one_times;
      |                 ^~~~~~~~~
Language: Java

package abc124;

import java.util.ArrayList;
import java.util.Scanner;

public class Handstand {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		int k = sc.nextInt();
		sc.nextLine();
		String s = sc.nextLine();
		Column c = new Column(s);
		int h = c.getHandsSize();
		int maxPoint = 0;
		for(int i = 0; i < h - k; i++) {
			int point = c.getPoint(i, i + k);
			if(point > maxPoint) {
				maxPoint = point;
			}
		}
		System.out.println(maxPoint);
	}

}
class Column{
	ArrayList<Integer> Hands = new ArrayList<Integer>();
	ArrayList<Integer> Stands = new ArrayList<Integer>();
	Column(String s){
		StringBuilder sb = new StringBuilder(s);
		while(sb.length() != 0){
			addHandStand(sb);
		}
		Hands.add(0);
	}
	void addHandStand(StringBuilder sb) {
		int h = sb.indexOf("0");
		if(h == -1) {
			h = sb.length();
		}
		Hands.add(h);
		sb.delete(0, h);

		int s = sb.indexOf("1");
		if(s == -1) {
			s = sb.length();
		}
		Stands.add(s);
		sb.delete(0, s);
	}
	int getPoint(int i, int i2) {
		if(i == i2) {
			return Hands.get(i);
		}else if(i > i2){
			return 0;
		}
		return Hands.get(i) + Stands.get(i) + getPoint(i+1, i2);
	}
	int getHandsSize() {
		return Hands.size();
	}
}


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

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

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

  char beg=S[0], en=S[N-1];

  vi C0, C1;

  if(beg=='0') C1.push_back(0);
  else C0.push_back(0);

  int l=0;

  for (int i=0;i<=N;++i){
    if(i==0) l++;
    
    else if(i==N){
      if(S[i-1]=='0') C0.push_back(l);
      else C1.push_back(l);
    }
    
    else{
      if(S[i]!=S[i-1]){
        if(S[i-1]=='0') {C0.push_back(l);l=0;}
        else{C1.push_back(l);l=0;}
      }
      else l++;
    }
  }

  if(en=='0') C1.push_back(0);
  else C0.push_back(0);

  int L=C0.size();
  if(L<=K){cout << N << endl; return 0;}

  int tmp=0;
  for (int i=0;i<K;++i){
    tmp+=C0[i]+C1[i];
  }

  int ans=tmp;

  for (int i=K;i<L;++i){
    tmp-=C0[i-K]+C1[i-K];
    tmp+=C0[i]+C1[i];
    ans=max(ans, tmp);
  }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'vi' was not declared in this scope
   10 |   vi C0, C1;
      |   ^~
a.cc:12:16: error: 'C1' was not declared in this scope; did you mean 'y1'?
   12 |   if(beg=='0') C1.push_back(0);
      |                ^~
      |                y1
a.cc:13:8: error: 'C0' was not declared in this scope; did you mean 'y0'?
   13 |   else C0.push_back(0);
      |        ^~
      |        y0
a.cc:21:23: error: 'C0' was not declared in this scope; did you mean 'y0'?
   21 |       if(S[i-1]=='0') C0.push_back(l);
      |                       ^~
      |                       y0
a.cc:22:12: error: 'C1' was not declared in this scope; did you mean 'y1'?
   22 |       else C1.push_back(l);
      |            ^~
      |            y1
a.cc:27:26: error: 'C0' was not declared in this scope; did you mean 'y0'?
   27 |         if(S[i-1]=='0') {C0.push_back(l);l=0;}
      |                          ^~
      |                          y0
a.cc:28:14: error: 'C1' was not declared in this scope; did you mean 'y1'?
   28 |         else{C1.push_back(l);l=0;}
      |              ^~
      |              y1
a.cc:34:15: error: 'C1' was not declared in this scope; did you mean 'y1'?
   34 |   if(en=='0') C1.push_back(0);
      |               ^~
      |               y1
a.cc:35:8: error: 'C0' was not declared in this scope; did you mean 'y0'?
   35 |   else C0.push_back(0);
      |        ^~
      |        y0
a.cc:37:9: error: 'C0' was not declared in this scope; did you mean 'y0'?
   37 |   int L=C0.size();
      |         ^~
      |         y0
a.cc:42:16: error: 'C1' was not declared in this scope; did you mean 'y1'?
   42 |     tmp+=C0[i]+C1[i];
      |                ^~
      |                y1
a.cc:48:18: error: 'C1' was not declared in this scope; did you mean 'y1'?
   48 |     tmp-=C0[i-K]+C1[i-K];
      |                  ^~
      |                  y1
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
string str;
int  main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    cin>>str;
    char ch ='0';
    int cnt=0;
    vector<pair<int,char> > v;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]==ch) cnt++;
        else
        {
            if(cnt)v.pb(mp(cnt,ch));
            if(ch=='1') ch='0';
            else ch='1';
            cnt=1;
        }
    }
    v.pb(mp(cnt,ch));
    int dif=2*k;
    ll ans=0;
    for(int i=0;i<v.size();i++)
    {
        int temp=0;
        char  e=v[i].second;
        int last=0;
        if(e=='0') last=i+dif-1;
        else last=i+dif;
        for(int j=i;j<=last and j<v.size(); j++)
        {
            temp+=v[j].first;
        }
        ans=max(ans,temp);
        //cout<<i<<' '<<temp<<endl;
    }
    printf("%lld\n",ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:16: error: no matching function for call to 'max(long long int&, int&)'
   44 |         ans=max(ans,temp);
      |             ~~~^~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:44:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   44 |         ans=max(ans,temp);
      |             ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:44:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   44 |         ans=max(ans,temp);
      |             ~~~^~~~~~~~~~
Language: C++


void Main()
{
   int N, K;
   cin >> N >> K;
   bitset<100000> S;
   cin >> S;
   int A[100002] = {0};
   int k = 0;
   if (S[0] == 0)
   {
      k = 1;
      A[1] = 1;
   }
   A[0] = 1;
   for (int i = 1; i < N; i++)
   {
      if (S[i] != S[i - 1])
      {
         k++;
      }
      A[k]++;
   }
   if (S[N - 1] == 0)
      k++;

   if (K >= k / 2)
   {
      cout << N << endl;
      return;
   }

   int MAX = 0;
   int max;
   for (int n = 0; n <= k - 2 * K; n += 2)
   {
      max = 0;
      for (int m = n; m <= n + 2 * K; m++)
      {
         max += A[m];
      }
      if (max > MAX)
         MAX = max;
   }
   cout << MAX << endl;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}

Compiler output:
a.cc: In function 'void Main()':
a.cc:5:4: error: 'cin' was not declared in this scope
    5 |    cin >> N >> K;
      |    ^~~
a.cc:6:4: error: 'bitset' was not declared in this scope
    6 |    bitset<100000> S;
      |    ^~~~~~
a.cc:6:19: error: 'S' was not declared in this scope
    6 |    bitset<100000> S;
      |                   ^
a.cc:29:7: error: 'cout' was not declared in this scope
   29 |       cout << N << endl;
      |       ^~~~
a.cc:29:20: error: 'endl' was not declared in this scope
   29 |       cout << N << endl;
      |                    ^~~~
a.cc:45:4: error: 'cout' was not declared in this scope
   45 |    cout << MAX << endl;
      |    ^~~~
a.cc:45:19: error: 'endl' was not declared in this scope
   45 |    cout << MAX << endl;
      |                   ^~~~
a.cc: In function 'int main()':
a.cc:50:9: error: 'cin' is not a member of 'std'
   50 |    std::cin.tie(nullptr);
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:51:9: error: 'std::ios_base' has not been declared
   51 |    std::ios_base::sync_with_stdio(false);
      |         ^~~~~~~~
a.cc:52:9: error: 'cout' is not a member of 'std'
   52 |    std::cout << std::fixed << std::setprecision(15);
      |         ^~~~
a.cc:52:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:52:22: error: 'fixed' is not a member of 'std'
   52 |    std::cout << std::fixed << std::setprecision(15);
      |                      ^~~~~
a.cc:1:1: note: 'std::fixed' is defined in header '<ios>'; this is probably fixable by adding '#include <ios>'
  +++ |+#include <ios>
    1 | 
a.cc:52:36: error: 'setprecision' is not a member of 'std'
   52 |    std::cout << std::fixed << std::setprecision(15);
      |                                    ^~~~~~~~~~~~
a.cc:1:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
  +++ |+#include <iomanip>
    1 |
Language: Java

N,K = map(int,input().split())
S = list(map(int,input()))
tmp = 1
nums = []
cont = 0
for s in S:
    if int(s) == tmp:
        cont += 1
    else:
        nums.append(cont)
        cont = 1
        tmp = 1 - tmp
if cont != 0:
    nums.append(cont)
if len(nums) % 2 == 0:
    nums.append(0)
ans = 0
lst = []
for i in range(0,len(nums),2):
    for j in range(i,min(i+K*2+1,len(nums))):
        ans += nums[j]
    lst.append(ans)
    ans = 0
print(max(lst))

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
N,K = map(int,input().split())
^
1 error
Language: C++

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

using namespace std;

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

    string S;
    cin >> S;

    vector<int> cum_sum;
    cum_sum.push_back(0);

    int counter = 0;
    char tmp_char = S[0];
    if (tmp_char == '0') cum_sum.push_back(0);

    for (int i = 0; i < N; i++) {
        if (tmp_char == S[i]) {
            counter++;
            if (i == (N-1)) cum_sum.push_back(cum_sum.back()+counter);
        } else {
            cum_sum.push_back(cum_sum.back() + counter);
            counter = 1;
            tmp_char = S[i];
            if (i == (N-1)) cum_sum.push_back(cum_sum.back()+1);

            //cout << S[i] << endl;
        }
        //cout << cum_sum.back() << endl;
    }

    if (S[N-1] == '0') cum_sum.push_back(cum_sum.back());

    //for (int i = 0; i != cum_sum.size(); ++i) {
    //    cout << cum_sum[i] << endl;
    //}
    int max_1 = 0; 
    counter = 0;
  
  
      if (K==0) {
        for (int i = 0; i < N; i++) {
            if (S[i]=='1') counter++;
            else {
                max_1 = max(max_1, counter);
                counter = 0;
            }
        }
        max_1 = max(max_1, counter);
        cout << max_1 << endl;
        return 0;
    }
    
    int ans = 1;
    for (int i = 0; i + (2*K+1) < cum_sum.size(); i = (i+2)) {
        ans = max(ans, cum_sum[(2*K+1) + i] - cum_sum[i]);
    }
    for (int i = cum_sum.size() - 1; i - (2*K+1) > 0; i = (i-2)) {
        //cout << i << (i - (2 * K + 1)) << endl;
        ans = max(ans, cum_sum[i] - cum_sum[i - (2*K+1)]);
    }

    cout << ans << endl;
    return 0;

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

#include <bits/stdc++.h>

int N, K;
	std::cin >> N >> K;

	std::string S;
	S.reserve(N + 2);
	std::cin >> S;

	std::vector<int> counts;
	counts.reserve(N);

	{
		char prevBit = S[0];

		counts.emplace_back(0);
		for (char bit : S)
		{
			if (bit != prevBit)
			{
				counts.emplace_back(0);
			}

			counts.back()++;
			prevBit = bit;
		}
	}

	for (int i = 1; i < counts.size(); i++)
	{
		counts[i] += counts[i - 1];
	}

	int maxSum = 0;
	for (int index = 0; index < counts.size(); index++)
	{
		const int numElems = [&] {
			if ((S[0] == '0') ^ (index % 2 == 0))
			{
				return 2 * K + 1;
			}
			else
			{
				return 2 * K;

			}
		}();

		int sum = counts[std::min(index + numElems - 1, (int)counts.size() - 1)];
		if (index - 1 >= 0) { sum -= counts[index - 1]; }

		maxSum = std::max(maxSum, sum);
	}

	std::cout << maxSum << std::endl;

Compiler output:
a.cc:4:14: error: 'cin' in namespace 'std' does not name a type
    4 |         std::cin >> N >> K;
      |              ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:7:9: error: 'S' does not name a type
    7 |         S.reserve(N + 2);
      |         ^
a.cc:8:14: error: 'cin' in namespace 'std' does not name a type
    8 |         std::cin >> S;
      |              ^~~
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:11:9: error: 'counts' does not name a type; did you mean 'const'?
   11 |         counts.reserve(N);
      |         ^~~~~~
      |         const
a.cc:13:9: error: expected unqualified-id before '{' token
   13 |         {
      |         ^
a.cc:29:9: error: expected unqualified-id before 'for'
   29 |         for (int i = 1; i < counts.size(); i++)
      |         ^~~
a.cc:29:25: error: 'i' does not name a type
   29 |         for (int i = 1; i < counts.size(); i++)
      |                         ^
a.cc:29:44: error: 'i' does not name a type
   29 |         for (int i = 1; i < counts.size(); i++)
      |                                            ^
a.cc:35:9: error: expected unqualified-id before 'for'
   35 |         for (int index = 0; index < counts.size(); index++)
      |         ^~~
a.cc:35:29: error: 'index' does not name a type
   35 |         for (int index = 0; index < counts.size(); index++)
      |                             ^~~~~
a.cc:35:52: error: 'index' does not name a type
   35 |         for (int index = 0; index < counts.size(); index++)
      |                                                    ^~~~~
a.cc:55:14: error: 'cout' in namespace 'std' does not name a type
   55 |         std::cout << maxSum << std::endl;
      |              ^~~~
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C

#include<stdio.h>
int main(void)
{
  int N;
  int K;
  char S[100000];
  int h, i, j;
  int cnt = 0;
  int a;
  
 scanf("%d", &N);
  scanf("%d", &K);
  scanf("%s", S);
  
  a = (N / 2) + 1;
  
  int num0[a] = {0};
  int num1[a] = {0};
  int soezi0 = 0;
  int soezi1 = 0;
  
  for(i = 0; i < N; i++){
    if(S[i] == '1'){
      num1[soezi1]++;
      if(num0[soezi0] != 0){
        soezi0++;
     }
     }
     else{
       num0[soezi0]++;
       if(num1[soezi1] != 0){
         soezi1++;
       }
     }
  }
  
  int sum = 0;
  int max = 0;
  
  for(i = 0; i < K; i++){
    if(S[0] == '1'){
      for(j = 0; j <= soezi0; j++){
        sum = num1[j] + num0[j] + num1[j + 1];
        if(max <= sum){
          max = sum;
          h = j;
        }
      }
      num1[h] = max;
      for(j = h + 1; j <= soezi1; j++){
        num1[j] = num1[j +1];
      }
      num1[j] = 0;
      soezi1--;
      for(j = h + 1; j <= soezi0; j++){
        num0[j] = num0[j +1];
      }
      num0[j] = 0;
      soezi0--;
    }
    else{
      for(j = 0; j <= soezi0; j++){
        if(j != 0){
          sum = num1[j - 1] + num0[j] + num1[j];
        }
        else{
          sum = num0[j] + num1[j];
        }
        if(max <= sum){
          max = sum;
          h = j;
        }
      }
      num1[h] = max;
      for(j = h + 1; j <= soezi1; j++){
        num1[j] = num1[j +1];
      }
      num1[j] = 0;
      soezi1--;
      for(j = h + 1; j <= soezi0; j++){
        num0[j] = num0[j +1];
      }
      num0[j] = 0;
      soezi0--;
    }
  }
  
  printf("%d\n", max);
 return 0;
}


Compiler output:
main.c: In function 'main':
main.c:17:17: error: variable-sized object may not be initialized except with an empty initializer
   17 |   int num0[a] = {0};
      |                 ^
main.c:18:17: error: variable-sized object may not be initialized except with an empty initializer
   18 |   int num1[a] = {0};
      |                 ^
Language: C

#include<stdio.h>
int main(void)
{
  int N;
  int K;
  char S[100000];
  int h, i, j;
  int cnt = 0;
  
  scanf("%d", &N);
  scanf("%d", &K);
  scanf("%s", S);
  
  int num0[N / 2 + 1] = {0};
  int num1[N / 2 + 1] = {0};
  int soezi0 = 0;
  int soezi1 = 0;
  
  for(i = 0; i < N; i++){
    if(S[i] == '1'){
      num1[soezi1]++;
      if(num0[soezi0] != 0){
        soezi0++;
      }
     }
     else{
       num0[soezi0]++;
       if(num1[soezi1] != 0){
         soezi1++;
       }
     }
  }
  
  int sum = 0;
  int max = 0;
  
  for(i = 0; i < K; i++){
    if(S[0] == '1'){
      for(j = 0; j <= soezi0; j++){
        sum = num1[j] + num0[j] + num1[j + 1];
        if(max <= sum){
          max = sum;
          h = j;
        }
      }
      num1[h] = max;
      for(j = h + 1; j <= soezi1; j++){
        num1[j] = num1[j +1];
      }
      num1[j] = 0;
      soezi1--;
      for(j = h + 1; j <= soezi0; j++){
        num0[j] = num0[j +1];
      }
      num0[j] = 0;
      soezi0--;
    }
    else{
      for(j = 0; j <= soezi0; j++){
        if(j != 0){
          sum = num1[j - 1] + num0[j] + num1[j];
        }
        else{
          sum = num0[j] + num1[j];
        }
        if(max <= sum){
          max = sum;
          h = j;
        }
      }
      num1[h] = max;
      for(j = h + 1; j <= soezi1; j++){
        num1[j] = num1[j +1];
      }
      num1[j] = 0;
      soezi1--;
      for(j = h + 1; j <= soezi0; j++){
        num0[j] = num0[j +1];
      }
      num0[j] = 0;
      soezi0--;
    }
  }
  
  printf("%d\n", max);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:14:25: error: variable-sized object may not be initialized except with an empty initializer
   14 |   int num0[N / 2 + 1] = {0};
      |                         ^
main.c:15:25: error: variable-sized object may not be initialized except with an empty initializer
   15 |   int num1[N / 2 + 1] = {0};
      |                         ^
Language: C++

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

int main() {

int N;
  int K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> one(N);
  vector<int> zero(N);
  int a=0;
  int b=0;
  int count=0;
  
  if(S.at(0)=='0'){
    zero.at(0)=0;
    b=1;
  }
  
  for( int i=0; i<(N-1); i++){
    if(S.at(i)=='1' & S.at(i+1)=='0'){
      int j = i;
      while (S.at(j)=='1' & j>=0){
        j--;
      }
      one.at(a)=(j+1);
      a++;
      
      int l=(i+1);
      while(S.at(l)=='0' & l<N){
        l++;
      }
      zero.at(b)=(l-1);
      b++;
      count++;
    }
  }
    if(S.at(N-1)=='1'){
      int q=(N-1);
      while (S.at(q)=='1' & q>=0){
        k--;
      }
      one.at(a)=(q+1);
    }
  if(b<K){
    cout << N << endl;
  }
  else{
    int ans = 0;
    if(S.at(0)=='1'){
    one.at(0)~one.at(0+k
    
    
    
    if(count==0){
      ans = N;
    }
      

}



Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'k' was not declared in this scope
   43 |         k--;
      |         ^
a.cc:53:14: error: expected ';' before '~' token
   53 |     one.at(0)~one.at(0+k
      |              ^
      |              ;
a.cc:53:11: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::at(size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   53 |     one.at(0)~one.at(0+k
      |     ~~~~~~^~~
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:1:
/usr/include/c++/14/bits/stl_vector.h:1180:7: note: declared here
 1180 |       at(size_type __n)
      |       ^~
a.cc:62:2: error: expected '}' at end of input
   62 | }
      |  ^
a.cc:50:7: note: to match this '{'
   50 |   else{
      |       ^
a.cc:62:2: error: expected '}' at end of input
   62 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
  int n,k;
  char s[100001];
  cin >> n;
  cin >> k;
  cin >> s;
  int fast = 0, last;
  int i;
  int now = 1;
  int range = 0;
  for(i = 0; i < n ; i++)
  {
    s[i] -= '0';
  }
  for(i = 0; i < n ; i++)
  {
    if(now != s[i])
    {
      if(now == 0)
      {
        range++;
        if(range == k)
        {
          break;
        }
      }
      now = s[i];
    }
  }
  int max = i;
  for(last = i; last < n; last++)
  {
    if(now != s[last])
    {
      if(now == 1)
      {
        int fnow = 1;
        for(;; first++)
        {
          if(fnow != s[first])
          {
            fnow = s[first];
            if(fnow == 0)
            {
              break;
            }
          }
        }
      }
      else
      {
      }
      now = s[i];
    }
    if(last - start > max)
    {
      max = last - start;
    }
    
  }
  cout << max << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:16: error: 'first' was not declared in this scope
   42 |         for(;; first++)
      |                ^~~~~
a.cc:59:15: error: 'start' was not declared in this scope
   59 |     if(last - start > max)
      |               ^~~~~
Language: C++

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define UL unsigned long long


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

    vector<int> zero;
    vector<int> one;
    if (s[0] == '0') {
        one.emplace_back(0);
    }

    int cnt = 1;
    char c = s[0];
    for(auto i = 1; i < n; i++)
    {
        if (c == s[i]) {
            cnt++;
            //cerr << cnt;
        }
        if ((c != s[i]) || (i == n-1)) { 
            if (c == '0') {
                zero.emplace_back(cnt);
            } else {
                one.emplace_back(cnt);
            }
            c = s[i];
            cnt = 1;
        }
    }
    
    /*
    cerr << "zero: ";
    for(int i = 0; i < zero.size() ; i++) {
        cerr << zero[i] << " ";
    }
    cerr << "one: ";
    for(int i = 0; i < one.size() ; i++) {
        cerr << one[i] << " ";
    }
    */
    
    int m = zero.size();
    if (m < k) {
        cout << n << endl; 
        return 0;
    }

    int ans = 0;
    for(auto i = 0; i <= m-k; i++)
    {
        int count = 0;
        for (auto j = 0; j < k ; j++){
            count += one[i+j] + zero[i+j];
        }
        \\cerr << "count: " << count << endl;
        if (i != m-k) count += one[i+k];
        if (ans < count)  ans = count; 
    }
    

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


Compiler output:
a.cc:66:9: error: stray '\' in program
   66 |         \\cerr << "count: " << count << endl;
      |         ^
a.cc:66:10: error: stray '\' in program
   66 |         \\cerr << "count: " << count << endl;
      |          ^