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

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

int main(){
    int i, c = 0;
    string s;
    cin >> s;
    for(i=0; i<s.size(), i++){
        if(i%2 == 0 && s[i] == '0'){
            c++;
        }else if(i%2 == 1 && s[i] == '1'){
            c++;
        }
    }
    cout << min(c, s.size()-c) << '\n';
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:29: error: expected ';' before ')' token
    8 |     for(i=0; i<s.size(), i++){
      |                             ^
      |                             ;
a.cc:15:16: error: no matching function for call to 'min(int&, std::__cxx11::basic_string<char>::size_type)'
   15 |     cout << min(c, s.size()-c) << '\n';
      |             ~~~^~~~~~~~~~~~~~~
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:15:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   15 |     cout << min(c, s.size()-c) << '\n';
      |             ~~~^~~~~~~~~~~~~~~
/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:15:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |     cout << min(c, s.size()-c) << '\n';
      |             ~~~^~~~~~~~~~~~~~~
Language: C++

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std ;

const int N=1e5+100 ;

char s[N] ;
int n ;

int main ()
{
	int i , ans , res ;
	gets(s+1),n=strlen(s+1);
	ans=0 ;
	for ( i=1 ; i<=n ; i++ ) ans+=(s[i]!=((i&1)+'0'));
	res=ans,ans=0;
	for ( i=1 ; i<=n ; i++ ) ans+=(s[i]!=((~i&1)+'0'));
	res=min(res,ans);
	printf("%d\n",res);
	return 0 ;
}

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

#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  string s;
  cin >> s;
  LL answer = 0ll;
  REP(i, s.size()) {
    if(s[i]=='0'+i%2) ++ answer;
  }
  cout << min(answer,s.size()-answer) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:14: error: no matching function for call to 'min(LL&, long long unsigned int)'
   16 |   cout << min(answer,s.size()-answer) << endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
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:16:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   16 |   cout << min(answer,s.size()-answer) << endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/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:16:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   16 |   cout << min(answer,s.size()-answer) << endl;
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cin >> s;

    int c1 = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != i % 2 + '0') {
            c1++;
        }
    }

    if (n - c1 < c1) {
        c1 = n - c1;
    }

    cout << c1 << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'n' was not declared in this scope
   17 |     if (n - c1 < c1) {
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,n) for(int i=0;i<n;++i)
#define pie 3.141592653589793238462643383279
#define mod 1e9+7
signed main(){
	string s,ans=0,cnt=0;
	cin>>s;
	f(i,s.size()){
		if(s[i]-'0'==i%2) cnt++;
	}
	ans=cnt;
	cnt=0;
	f(i,s.size()){
		if(s[i]-'0'!=i%2) cnt++;
	}
	cout<<min(ans,cnt)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:38: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
   11 |                 if(s[i]-'0'==i%2) cnt++;
      |                                   ~~~^~
a.cc:14:13: error: ambiguous overload for 'operator=' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int')
   14 |         cnt=0;
      |             ^
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:817:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  817 |       operator=(const basic_string& __str)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:828:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  828 |       operator=(const _CharT* __s)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:840:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  840 |       operator=(_CharT __c)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:858:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  858 |       operator=(basic_string&& __str)
      |       ^~~~~~~~
a.cc:16:38: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
   16 |                 if(s[i]-'0'!=i%2) cnt++;
      |                                   ~~~^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  ll ans=MAX;
  rep(k,2) {
    ll cnt=0;
    rep(i,n) {
      if(s[i]-'0'!=(k+i)%2) cnt++;
    }
    ans=min(ans,cnt);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Compiler output:
a.cc: In function 'void Main()':
a.cc:34:11: error: 'n' was not declared in this scope
   34 |     rep(i,n) {
      |           ^
a.cc:16:44: note: in definition of macro 'REP'
   16 | #define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
      |                                            ^
a.cc:34:5: note: in expansion of macro 'rep'
   34 |     rep(i,n) {
      |     ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<ll> v(N),u;
    rep(i,N){
        v[i] = S[i] - '0';
    }
    ll now = 1;
    ll cnt = 0;
    rep(i,N){
        if(v[i] == now){
            cnt++;
        }else{
            u.push_back(cnt);
            i--;
            cnt = 0;
            now = (now?0:1);
        }
    }
    if(now == 1){
        u.push_back(cnt);
    }else{
        u.push_back(cnt);
        u.push_back(0);
    }
    //ll M = u.size();
    PR(u,M);
    vector<ll> us(M+1,0);
    rep(i,M){
        us[i+1] = us[i] + u[i]; 
    }
    if(M <= K*2){
        cout << us[M] << endl;
        return 0;
    }
    ll ans = 0;
    rep(i,M-K*2){
        cmax(ans,us[i+K*2+1] - us[i]);
        i++;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:10: error: 'M' was not declared in this scope
   46 |     PR(u,M);
      |          ^
Language: C++

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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0;
  int right = 0;
  int cn = 0;
  for (int left = 0; left < n; ++left){
    while (right < n && cn <= k){
      if(right + 1 < n && s[right] == '1' && s[right] == '0')cn++;
      ++right;
    }
    /* break した状態で right は条件を満たす最大なので、何かする */
    ans = max(ans,right - left);

    if (left + 1 < N && s[left] == '0' && s[left + 1] == '1') cont--;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:20: error: 'N' was not declared in this scope
   23 |     if (left + 1 < N && s[left] == '0' && s[left + 1] == '1') cont--;
      |                    ^
a.cc:23:63: error: 'cont' was not declared in this scope; did you mean 'const'?
   23 |     if (left + 1 < N && s[left] == '0' && s[left + 1] == '1') cont--;
      |                                                               ^~~~
      |                                                               const
Language: C++


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


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

    vector<int> c; 
    int now=1; //今見ている数
    int cnt=0; //nowがいくつ並んでいるか
    rep(i,n){
        if(s[i] == (char)(now + '0')) cnt++;
        else{
            c.push_back(cnt);
            now=1-now; //0と1を切り替えるときの計算
            cnt = 1; //新しいのをカウントし始める
        }
    }
    c.push_back(cnt);
    //1で始まって2で終わるようにしたいので終端が0だったら適当に1つ足す
    if(c.size()%2==0) c.push_back(0);

    int m=c.size();
    vector<int> s(m+1); //sが累積和のベクトル
    rep(i,m) s[i+1] = s[i] + c[i];

    int ans=0;
    //1-0-1...の1から始めるので偶数番目だけを見る
    for(int i=0; i<m; i+=2){
        int left=1;
        int right=min(i+2*k+1,m);
        chmax(ans,s[right]-s[left]);
    }
    cout << ans << endl;





}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: conflicting declaration 'std::vector<int> s'
   32 |     vector<int> s(m+1); //sが累積和のベクトル
      |                 ^
a.cc:13:12: note: previous declaration as 'std::string s'
   13 |     string s;
      |            ^
Language: C++

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

int main(){
  int n, k; cin >> n >> k;
  string s; cin >> s;
  vector<int> seq;
  if(s[0] == '0') seq.push_back(0);
  for(int i = 0; i < s.size()){
    int j = i;
    while(j < s.size() && s[j] == s[i]) j++;
    seq.push_back(j-i);
    i = j;
  }
  if(s.back() == '0') seq.push_back(0);
  vector<int> sum((int)seq.size()+1, 0);
  for(int i = 0; i < seq.size(); i++){
    sum[i+1] = sum[i] + seq[i];
  }
  int ans = 0;
  for(int i = 0; i < sum.size(); i += 2){
    int tmp = i + 2*k + 1;
    if(tmp >= sum.size()) tmp = sum.size() - 1;
    ans = max(ans, sum[tmp] - sum[i]);
  }
  cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:9:30: error: expected ';' before ')' token
    9 |   for(int i = 0; i < s.size()){
      |                              ^
      |                              ;
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;


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

    char current = S[0];

    vector<int> compress;
    int count = 0;
    rep(i,N){
        if (current == S[i]){
            count++;
        }
        else{
            compress.push_back(count);
            count = 1;
            current = S[i];
        }
    }
    compress.push_back(count);

    // 累積和を取得
    vector<int> cum(compress.size()+1,0);
    rep(i,compress.size()){
        cum[i+1] = cum[i] + compress[i];
    }

    int now = 0;
    if (S[0] == '1') now++;
    
    int ans = 0;
    for (int left = 0; left < cum.size(); left++){
        int tmp = 0;
        int add = 2*K;
        if (now == 1) add++;
        
        int right = min(i+add, cum.size()-1);
        tmp = cum[right] - cum[left];
        ans = max(ans, tmp);
        
        // 0と1を切り替える
        now = 1 - now;
    }

    cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:25: error: 'i' was not declared in this scope
   51 |         int right = min(i+add, cum.size()-1);
      |                         ^
Language: C++

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

int main(){
  int n,k;
  cin >> n >> k;
  
  string s;
  cin >> s;
  
  vector<int>nums;
  int now = 1;
  int count = 0;
  for(int i=0; i<n; i++){
    if(s[i]==('0'+now))  count++;
    else{
      nums.push_back(count);
      now = 1-now;
      count = 1;
    }
    if(count != 0) nums.push_back(count);
    if(nums.size()%2==0)nums.push_back(0);
    
    int add = 2*k+1;
    
    vector<int>sum(nums.size()+1);
    for(int i=0; i<sum.size(); i++){
     sum[i+1]=sum[i]+nums[i];
    }
    
    int ans =0;
    
    for(int i=0; i<nums.size(); i+=2){
     int left = i;
      int right = min(i+add,(int)nums.size());
      int tmp = sum[right]-sum[left];
      ans = max(tmp,ans);
      
    }
  
    
    cout << ans << endl;
    
    return 0;
  
}

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

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

int main(){
  int n,k;
  cin >> n >> k;
  
  string s;
  cin >> s;
  
  vector<int>nums;
  int now = 1;
  int count = 0;
  for(int i=0; i<n; i++){
    if(s[i]==('0'+now))  count++;
    else{
      nums.push_back(count);
      now = 1-now;
      count = 1;
    }
    if(count != 0) nums.push_back(count);
    if(nums.size()%2==0)nums.push_back(0);
    
    int add = 2*k+1;
    
    vector<int>sum(nums.size()+1);
    for(int i=0; i<sum.size(); i++){
     sum[i+1]=sum[i]+nums[i];
    }
    
    int ans =0;
    
    for(int i=0; i<nums.size(); i+=2){
     int left = i;
      int right = min(i+add,nums.size());
      int tmp = sum[right]-sum[left];
      ans = max(tmp,ans);
      
    }
  
    
    cout << ans << endl;
    
    return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:22: error: no matching function for call to 'min(int, std::vector<int>::size_type)'
   36 |       int right = min(i+add,nums.size());
      |                   ~~~^~~~~~~~~~~~~~~~~~~
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:36:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   36 |       int right = min(i+add,nums.size());
      |                   ~~~^~~~~~~~~~~~~~~~~~~
/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:36:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   36 |       int right = min(i+add,nums.size());
      |                   ~~~^~~~~~~~~~~~~~~~~~~
a.cc:47:2: error: expected '}' at end of input
   47 | }
      |  ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

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

int main(){
  int n,k;
  cin >> n >> k;
  
  string s;
  cin >> s;
  
  vector<int>nums;
  int now = 1;
  int count = 0;
  for(int i=0; i<n; i++){
    if(s[i]==('0'+now))  count++;
    else{
      nums.push_back(count);
      now = 1-now;
      count = 1;jj
    }
    if(count != 0) nums.push_back(count);
    if(nums.size()%2==0)nums.push_back(0);
    
    int add = 2*k+1;
    
    vector<int>sum(nums.size()+1);
    for(int i=0; i<sum.size(); i++){
     sum[i+1]=sum[i]+nums[i];
    }
    
    int ans =0: 
    
    for(int i=0; i<nums.size(); i+=2){
     int left = i;
      int right = min(i+add,nums.size());
      int tmp = sum[right]-sum[left];
      ans = max(tmp,ans);
      
    }
  
    
    cout << ans << endl;
    
    return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:17: error: 'jj' was not declared in this scope; did you mean 'jn'?
   20 |       count = 1;jj
      |                 ^~
      |                 jn
a.cc:32:15: error: expected ',' or ';' before ':' token
   32 |     int ans =0:
      |               ^
a.cc:34:37: error: expected ';' before ')' token
   34 |     for(int i=0; i<nums.size(); i+=2){
      |                                     ^
      |                                     ;
a.cc:47:2: error: expected '}' at end of input
   47 | }
      |  ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

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

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

  vector<int> V;
  S += '/';
  for (int i = 0, cnt = 1; i + 1 < S.size(); i++) {
    if (S.at(i) == S.at(i + 1)) cnt++;
    else {
      V.push_back(cnt);
      cnt = 1;
    }
  }
  if (S.front() != '1') V.insert(V.begin(), 0);

  N = V.size();
  vector<int> C(N + 1);
  for (int i = 1, sum = 0; i < N + 1; i++) {
    C.at(i) = sum += V.at(i - 1);
  }

  int mx = 0;
  for (int i = 0; i < N + 1; i += 2) {
    mx = max(mx, C.at(min(i + K * 2 + 1, N) - C.at(i));
  }
  cout << mx << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:55: error: expected ')' before ';' token
   28 |     mx = max(mx, C.at(min(i + K * 2 + 1, N) - C.at(i));
      |             ~                                         ^
      |                                                       )
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  
  //0か1のどちらかの連続になっていた...
  vi ct;
  int j = 0;
  int acc = 0;
  char prev = -1;
  rep(i, S.size()) {
    if(S[i] != prev) {
      if(i == 0 && S[0] == '1') {
        
      } else {
        ct.push_back(acc);
      }
      prev = S[i];
      acc = 0;
    }
    acc ++;
  }
  ct.push_back(acc);
  ct.push_back(0);
  
  // next
  N = ct.size();
  acc = 0;
  int klen = K * 2 + 1;
  rep(i, min(N, klen)) {
    acc += ct[i];
  }
  
  if(N <= klen) {
    fin(acc);
    return;
  }
  
  int maxv = acc;
  for(int i=0; i<N-klen; i+=2) {
    acc = acc - ct[i] - ct[i+2] + ct[i + klen] + ct[i + klen + 1];
    chmax(maxv, acc);
  }
  
  fin(maxv);
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:102:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
  102 |     return;
      |     ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,k;
    cin>>n>>k;
    char s[n];
    rep(i,n)cin>>s[i];
    vi d;
    int nowc=1;
    char now=s[0];
    for (int i=1;i<n;i++){
        if (now!=s[i]){
            d.push_back(nowc);
            nowc=1;
            now=s[i];
        }
        else nowc+=1;
    }
    d.push_back(nowc);
    int num=d.size();
    if (k>=num/2 && s[0]=='1'){
        cout<<n<<endl;
    }
    else if (s[0]=='0' && k>=double(num)/2.0){
        cout<<n<<endl;
    }
    else{
        if (s[0]=='1'){
            int ans=0;
            int ans1=0;
            rep(i,k){
                ans1+=d[2*i];
                ans1+=d[2*i+1];
            }
            ans1+=d[2*k];
            ans=ans1;
            for (int i=1;i+2*k+1<num;i+=2){
                ans1-=d[i-1];
                ans1-=d[i];
                ans1+=d[i+2*k];
                ans1+=d[i+2*k+1];
                ans=max(ans1,ans);
            }
            if (num%2==0){
                int ans2=0;
                rep(i,k){
                    ans2+=d[num-2*i-1]
                    ans2+=d[num-2*i-2];
                }
                ans=max(ans,ans2);
            }
            cout<<ans<<endl;
        }
        else{
            int ans=0;
            int ans1=0;
            rep(i,k){
                ans1+=d[2*i];
                ans1+=d[2*i+1];
            }
            //ans1+=d[2*k];
            ans=ans1;
            ans1-=d[0];
            ans1+=d[2*k];
            ans1+=d[2*k+1];
            ans=max(ans1,ans);
            for (int i=0;i+2*k+3<num;i+=2){
                //cout<<"!"<<endl;
                ans1-=d[i+1];
                ans1-=d[i+2];
                ans1+=d[i+2*k+2];
                ans1+=d[i+2*k+3];
                ans=max(ans1,ans);
            }
            int ans2=0;
            if(num%2==1){
            rep(i,k){
                ans2+=d[num-2*i-1];
                ans2+=d[num-2*i-2];
            }
            ans=max(ans,ans2);}
            
            cout<<ans<<endl;
        }
    }
    


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:39: error: expected ';' before 'ans2'
   68 |                     ans2+=d[num-2*i-1]
      |                                       ^
      |                                       ;
   69 |                     ans2+=d[num-2*i-2];
      |                     ~~~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N,K,cnt=0;
    string S;
    pair<ll,ll> P;
    P.first=1;
    P.second=0;
    cin>>N>>K>>S;
    vector<pair<ll,ll>> v;
    if(S[i]==0) v.push_back(P);
    for(ll i=0;i<N;i++){
        pair<ll,ll> p;
        ll cnt=1;
        if(S[i]=='0'){
            while(i+1<N&&S[i+1]=='0'){
                cnt++;
                i++;
            }
            p.first=0;
            p.second=cnt;
        }else{
            while(i+1<N&&S[i+1]=='1'){
                cnt++;
                i++;
            }
            p.first=1;
            p.second=cnt;
        }
        v.push_back(p);
    }
    
    if(v[N-1].first==0) v.push_back(P);

    for(ll i=1;i<v.size();i++) v[i].second+=v[i-1].second;
    if(v.size()<K*2){
        cout<<v[v.size()-1].second<<endl;
        return 0;
    }
    ll ans=v[K*2].second;
    for(ll i=K*2+2;i<v.size();i+=2){
        chmax(ans,v[i].second-v[i-K*2-1].second);
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:10: error: 'i' was not declared in this scope
   20 |     if(S[i]==0) v.push_back(P);
      |          ^
Language: Java

import javafx.util.Pair;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;

public class Main {


    static class MyPair{
        int k,v;
        MyPair(int first,int second) {
            this.k = first;
            this.v = second;
        }
    }
    public static void main(String[] args) {
        java.util.Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int k = input.nextInt();
        String s = input.next();
        int[] ss = new int[n];
        Vector<MyPair> d = new Vector<>();
        int prev = -1, cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '0') ss[i] = 0;
            else ss[i] = 1;
        }
        for (int i = 0; i < n; i++) {
            if (prev == ss[i]) cnt++;
            else {
                if (cnt > 0) d.add(new MyPair(prev, cnt));
                cnt = 1;
                prev = ss[i];
            }
        }
        if (cnt > 0) d.add(new MyPair(prev, cnt));
        int l = 0, r = 0, sum = 0, v = 0;
        for (int i = 0; i < d.size(); i++) {
            sum += d.get(i).v;
            if (d.get(i).k == 0) {
                v++;
                while (v > k) {
                    sum -= d.get(l).v;
                    if (d.get(l).k == 0) v--;
                    l++;
                }
            }
            if (r < sum) r = sum;
        }
        System.out.println(r);
    }
}


Compiler output:
Main.java:1: error: package javafx.util does not exist
import javafx.util.Pair;
                  ^
1 error
Language: Java

import javafx.util.Pair;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;

public class Main {
    public static void main(String[] args) {
        java.util.Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int k = input.nextInt();
        String s = input.next();
        int[] ss = new int[n];
        Vector<Pair<Integer, Integer>> d = new Vector<>();
        int prev = -1, cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '0') ss[i] = 0;
            else ss[i] = 1;
        }
        for (int i = 0; i < n; i++) {
            if (prev == ss[i]) cnt++;
            else {
                if (cnt > 0) d.add(new Pair<>(prev, cnt));
                cnt = 1;
                prev = ss[i];
            }
        }
        if (cnt > 0) d.add(new Pair<>(prev, cnt));
        int l = 0, r = 0, sum = 0, v = 0;
        for (int i = 0; i < d.size(); i++) {
            sum += d.get(i).getValue();
            if (d.get(i).getKey() == 0) {
                v++;
                while (v > k) {
                    sum -= d.get(l).getValue();
                    if (d.get(l).getKey() == 0) v--;
                    l++;
                }
            }
            if (r < sum) r = sum;
        }
        System.out.println(r);
    }
}


Compiler output:
Main.java:1: error: package javafx.util does not exist
import javafx.util.Pair;
                  ^
Main.java:15: error: cannot find symbol
        Vector<Pair<Integer, Integer>> d = new Vector<>();
               ^
  symbol:   class Pair
  location: class Main
Main.java:24: error: cannot find symbol
                if (cnt > 0) d.add(new Pair<>(prev, cnt));
                                       ^
  symbol:   class Pair
  location: class Main
Main.java:29: error: cannot find symbol
        if (cnt > 0) d.add(new Pair<>(prev, cnt));
                               ^
  symbol:   class Pair
  location: class Main
4 errors
Language: C

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int A[N];
    REP (i, N) {
        A[i] = S.at(i) - '0';
    }

    int block[N] = {};
    for (int i = 1; i < N; i++) {
        if (A[i] == A[i-1]) {
            block[i] = block[i-1];
        } else {
            block[i] = block[i-1] + 1;
        }
    }

    int ans = 0, sentinel;
    REP (i, N) {
        if (A[i] == 0) {
            sentinel = lower_bound(block, block+N, A[i]+K*2) - block;
        } else {
            sentinel = lower_bound(block, block+N, A[i]+K*2+1) - block;
        }
        ans = max(ans, sentinel - i);
    } 

    cout << ans << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n,k;cin>>n>>k;
  string s;cin>>s;
  vl vec;
  vl num(1,s[0]-'0');
  ll count=1;
  rep(i,n-1){
    if(s[i]==s[i+1]){
      count++;
    }
    else {
      vec.push_back(count);
      num.push_back(s[i+1]-'0');
      count=1;
    }
    if(i==n-2)vec.push_back(count);
  }
  vl wa(vec.size());
  wa[0]=vec[0];
  rep(i,vec.size()-1)wa[i+1]=wa[i]+vec[i+1];
  
    
      
   
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:36:45: error: expected '}' at end of input
   36 |   rep(i,vec.size()-1)wa[i+1]=wa[i]+vec[i+1];
      |                                             ^
a.cc:17:11: note: to match this '{'
   17 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
int main(){
  int n,k; cin >> n >> k;
  string s; cin >> s;
  vector<int> v;
  if(s[0]=='0') v.pb(0);
  for(int i=0; i<n;){
    int j = i;
    while(s[i]==s[j] && j<n){
      j++;
    }
    v.pb(j-i);
    i = j;
  }
  if(s.back()=='0') v.pb(0);
  vector<int> sums((int)v.size()+1, 0);
  rep(i,0,sums.size(){
    sums[i+1] = sums[i] + v[i];
  }
  int res = 0;
  for(int left=0 ; left<sums.size() ; left+=2) {
    int right = left+2*k+1;
    if(right>=sums.size()) right = (int)sums.size()-1;
    res = max(res, sums[right]-sums[left]);
  }
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc:38:2: error: unterminated argument list invoking macro "rep"
   38 | }
      |  ^
a.cc: In function 'int main()':
a.cc:27:3: error: 'rep' was not declared in this scope
   27 |   rep(i,0,sums.size(){
      |   ^~~
a.cc:27:6: error: expected '}' at end of input
   27 |   rep(i,0,sums.size(){
      |      ^
a.cc:12:11: note: to match this '{'
   12 | int main(){
      |           ^
Language: C++

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };


int main()
{
  int N,K;
  cin >> N >> K;
  string t;
  cin >> t;
  //0100100011→[0,1,1,2,1,3,2]みたいに奇数番目が0の連続個数、偶数番目が1の連続個数となるように配列を作る先頭が0ならダミーとして0を入れる
  //それでK=2として[0,1,1,2,1](1,3個目が二つの連続する０)、[1,2,1,3,2](3,5個目)を見ていく,で個数の合算が欲しいため累積和で、
  //S[6]-S[0]とS[7]-S[1]を比較して大きい方をとる
  vi S;
  if(t[0] == '0') S.push_back(0);
  rep(i,t.size()){
      int j = i;
      while(j < t.size() && t[j] == t[i]) j++;//同じやつなら違うのが出るまで進める
      S.push_back(j-i);
      i=j;
  }

  vi sum(S.size()+1,0);
  rep(i,S.size()) sum[i+1] = sum[i] + S[i];

  int ans=0;
  for(int left=0,left<sum.size();left+=2){
      //[0,1,1,3,3]なら次の0の和まで飛ぶためにleft+=2
      int right = left+K*2+1;//半開区間のため+1
      if(right >= sum.size()) right = sum.size()-1;
      ans = max(ans,sum[right]-sum[left]);
  }

  fin(ans);

}



Compiler output:
a.cc: In function 'int main()':
a.cc:85:22: error: expected ';' before '<' token
   85 |   for(int left=0,left<sum.size();left+=2){
      |                      ^
      |                      ;
a.cc:85:22: error: expected primary-expression before '<' token
Language: C++

n, k = map(int, input().split())
s = input()

l = []
if s[0] == '0':
    l.append(0)

now = 1
for i in range(1, len(s)):
    if s[i - 1] == s[i]:
        now += 1
    else:
        l.append(now)
        now = 1
l.append(now)

cum = [0]
for x in l:
    cum.append(cum[-1] + x)
# print(l)
# print(cum)
ans = max(l)
for i in range(0, n, 2):
    r = i + 2 * k + 1
    if r >= len(cum):
        break
    print(cum[r] - cum[i])
    ans = max(ans, cum[r] - cum[i])

print(ans)


Compiler output:
a.cc:20:3: error: invalid preprocessing directive #print
   20 | # print(l)
      |   ^~~~~
a.cc:21:3: error: invalid preprocessing directive #print
   21 | # print(cum)
      |   ^~~~~
a.cc:1:1: error: 'n' does not name a type
    1 | n, k = map(int, input().split())
      | ^
Language: C++

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

typedef long long ll;
const int mod = 1e9 + 7;

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

    string S;
    cin >> S;

    vector<int> nums;
    int now = 1;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == (char)('0' + now)) cnt++;
        else {
            nums.push_back(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    nums.push_back(cnt);

    if (nums.size() % 2 == 0) nums.push_back(0);

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

    int add = 2 * K + 1;
    int ans = 0;
    for (int i = 0; i < nums.size(); i += 2) {
        int tmp = 0;
        int left = i;
        int right = min(i + add, nums.size();
        for (int j = left; j < right; j++) {
            tmp += nums[j];
        }
        ans = max(tmp, ans);
    }

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:45: error: expected ')' before ';' token
   41 |         int right = min(i + add, nums.size();
      |                        ~                    ^
      |                                             )
Language: C++

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

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

    int cnt=0;
    int memo=0;
    bool turn = false;
    priority_queue<pair<int, int>> q;
    for(int i=0; i<n; i++){
        if(s.at(i)=='0' && !turn){
            cnt=0;
            turn = true;
            memo=i;
        }
        else if(s.at(i)=='0' && turn){
            cnt++;
        }
        else if(s.at(i)=='1' && turn){
            q.push(make_pair(memo,cnt));
            turn = false;
        }
        else if(s.at(i)=='1' && !turn) continue;

        if(i==n-1 && turn){
            q.push(make_pair(memo,cnt))
        }
    }

    while(!q.empty()){
        if(k==0) break;
        int x=q.top().first;
        int y=q.top().second;
        q.pop();
        for(int i=x; i<=x+y; i++){
            s.at(i) = '1';
        }
        k--;
    }


    //cout << s << endl;
    int ans = 0;
    int mans = 0;

    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='1'){
            ans++;
            mans = max(mans, ans);
        }
        else if(s.at(i)=='0'){
            mans = max(mans, ans);
            ans = 0;
        }
    }

    cout << mans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:40: error: expected ';' before '}' token
   30 |             q.push(make_pair(memo,cnt))
      |                                        ^
      |                                        ;
   31 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

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

  vector<pii> a;
  rep(i, n) {
    int cnt = 1;
    while (i < n-1 && s[i] == s[i+1]) {
      i++;
      cnt++;
    }
    a.push_back({cnt, s[i]-'0'});
  }

  ll right = 0;
  ll cnt = 0;
  ll sum = 0;
  ll ans = 0;
  rep(left, a.size()) {
    while (right < n && cnt + f(right) <= k) {
      cnt += !a[right].second;
      sum += a[right].first;
      right++;
      //cerr << left << " " << right << endl;
      //cerr << "  " << cnt << " " << sum << endl;
    }

    cmax(ans, sum);

    if (right == left) right++;
    else {
      cnt -= !a[right].second;
      sum -= a[left].first;
    }
  }

  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:31: error: 'f' was not declared in this scope
   34 |     while (right < n && cnt + f(right) <= k) {
      |                               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

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

  vector<pii> a;
  rep(i, n) {
    int cnt = 1;
    while (i < n-1 && s[i] == s[i+1]) {
      i++;
      cnt++;
    }
    a.push_back({cnt, s[i]-'0'});
  }

  ll right = 0;
  ll cnt = 0;
  ll sum = 0;
  ll ans = 0;
  rep(left, a.size()) {
    while (right < n && cnt + f(right) <= k) {
      cnt += !a[i].second;
      sum += a[right].first;
      right++;
      //cerr << left << " " << right << endl;
      //cerr << "  " << cnt << " " << sum << endl;
    }

    cmax(ans, sum);

    if (right == left) right++;
    else {
      cnt -= !a[i].second;
      sum -= a[left].first;
    }
  }

  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:31: error: 'f' was not declared in this scope
   34 |     while (right < n && cnt + f(right) <= k) {
      |                               ^
a.cc:35:17: error: 'i' was not declared in this scope
   35 |       cnt += !a[i].second;
      |                 ^
a.cc:46:17: error: 'i' was not declared in this scope
   46 |       cnt -= !a[i].second;
      |                 ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

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

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> num;

    REP(i, N) { num.push_back(S[i] - '0'); }

    vector<int> nums;
    if (num[0] == 0)
        nums.push_back(0);
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == S[i]) {
            ++j;
        }
        nums.push_back(j - i);
        i = j;
    }
    if (num[S.size() - 1] == 0)
        nums.push_back(0);

    vector<int> sum(nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); i++) {
        sum[i + 1] = nums[i] + sum[i];
    }
    vector<int> x;
    for (int i = 0; i < sum.size(); i += 2) {
        if (i + 2 * K + 1 < sum.size()) {
            x.push_back(sum[i + 2 * K + 1] - sum[i]);
        } else {
            x.push_back(sum[sum.size() - 1] - sum[i])
        }
    }

    cout << *max_element(ALL(x)) << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:54: error: expected ';' before '}' token
   47 |             x.push_back(sum[sum.size() - 1] - sum[i])
      |                                                      ^
      |                                                      ;
   48 |         }
      |         ~