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

#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1e9
using namespace std;

const int maxn = 210000;

int n,m;
int A[maxn],B[maxn],C[maxn];

struct node{int x,i;};
inline bool operator <(const node x,const node y){return x.x<y.x;}
set<node>S;
set<node>::iterator it;

int p[maxn],q[maxn];
struct L{int l,i;};
vector<L>vl[maxn];
inline bool operator <(const L x,const L y){return x.l>y.l;}
priority_queue<L>q1;
struct R{int r,i;};
vector<R>vr[maxn];
inline bool operator <(const R x,const R y){return x.r<y.r;}
priority_queue<R>q2;

bool use[maxn],flag;
int ans[maxn],re;

int solve(const int k,const int ad){ return ans[k]==-1?-1:n-ans[k]+ad; }

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&A[i],&B[i]);
	for(int i=0;i<=n;i++) scanf("%d",&C[i]); sort(C,C+n+1); C[n+1]=-1;
	for(int i=n;i>=0;i--) if(C[i]!=C[i+1]) S.insert((node){C[i],i});
	S.insert((node){inf+1,n+1});
	
	for(int i=1;i<=n;i++)
	{
		it=S.lower_bound((node){A[i],0});
		A[i]=(*it).i; p[A[i]]++;
		it=S.lower_bound((node){B[i],0});
		B[i]=(*it).i;
		
		if(A[i]>B[i])
		{
			swap(A[i],B[i]); B[i]--;
			vl[B[i]].push_back((L){A[i],i});
			vr[A[i]].push_back((R){B[i],i});
		}
	}
	for(int i=0;i<=n;i++) p[i]--;
	for(int i=1;i<=n+1;i++) p[i]+=p[i-1];
	
	int ad=0;
	for(int i=n+1;i>=0;i--)
	{
		ad+=q[i]; p[i]+=ad; q[i]=0;
		for(int j=0;j<vl[i].size();j++) q1.push(vl[i][j]);
		
		if(p[i]<-1&&i!=n+1)
		{
			while(!q1.empty()&&p[i]<-1)
			{
				const L now=q1.top(); q1.pop();
				if(now.l>i) break;
				use[now.i]=true;
				p[i]++; ad++; if(now.l) q[now.l-1]--;
				if(B[now.i]>i) q[i+1]++,q[B[now.i+1]]--;
				re++;
			}
			if(p[i]<-1) { flag=true; break; }
		}
	}
	if(flag) for(int i=0;i<=n+1;i++) ans[i]=-1;
	else
	{
		ad=0;
		for(int i=0;i<=n;i++) ad+=q[i],q[i]=0,p[i]+=ad;
		for(int i=0;i<=n;i++) q[i]=0;
		ad=0;
		for(int i=0;i<=n;i++)
		{
			ans[i]=re;
			ad+=q[i]; p[i]+=ad;
			for(int j=0;j<vr[i].size();j++) if(!use[vr[i][j].i]) q2.push(vr[i][j]);
			
			if(p[i]<0)
			{
				while(!q2.empty()&&p[i]<0)
				{
					const R now=q2.top(); q2.pop();
					if(now.r<i) break;
					ad++; p[i]++; q[now.r+1]--;
					re++;
				}
				if(p[i]<0)
				{
					for(int j=i+1;j<=n+1;j++) ans[j]=-1;
					break;
				}
			}
		}
		if(ans[n+1]!=-1) ans[n+1]=re;
	}
	
	scanf("%d",&m);
	while(m--)
	{
		int x,y; scanf("%d%d",&x,&y);
		it=S.lower_bound((node){x,0}); x=(*it).i;
		it=S.lower_bound((node){y,0}); y=(*it).i;
		printf("%d\n",max(solve(x,1),solve(y,0)));
	}
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:28: error: narrowing conversion of '1.000000001e+9' from 'double' to 'int' [-Wnarrowing]
   53 |         S.insert((node){inf+1,n+1});
      |                            ^
Language: C++

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
int A[101010],B[101010],C[101010];
int D[101010],E[101010];
int dp[101010];
vector<int> ev[101010];

template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	V add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};
BIT<int,20> bt;


int hoge(int v) {
	ZERO(bt.bit);
	int i;
	FOR(i,N+1) bt.add(i,-1);
	bt.add(v,1);
	FOR(i,N) bt.add(A[i],1);
	
	priority_queue<pair<int,int>> P;
	int ret=N;
	FOR(i,N+1) {
		FORR(e,ev[i]) P.push({A[e],e});
		while(bt(i)<0) {
			if(P.empty()) return -10;
			int x=P.top().second;
			P.pop();
			bt.add(B[x],1);
			bt.add(A[x],-1);
			ret--;
		}
	}
	
	return ret;
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i]>>B[i];
	FOR(i,N+1) cin>>C[i];
	FOR(i,N+2) dp[i]=-3;
	sort(C,C+N+1);
	
	FOR(i,N) {
		B[i]=min(A[i],B[i]);
		A[i]=lower_bound(C,C+N+1,A[i])-C;
		B[i]=lower_bound(C,C+N+1,B[i])-C;
		if(B[i]<A[i]) ev[B[i]].push_back(i);
	}
	cin>>Q;
	asert(N*Q<=1000000);
	FOR(i,Q) {
		cin>>x>>y;
		x=lower_bound(C,C+N+1,x)-C;
		y=lower_bound(C,C+N+1,y)-C;
		cout<<max({-1,hoge(x)+1,hoge(y)})<<endl;
		//cout<<max({-1,dp[x]+1,dp[y]})<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:72:9: error: 'asert' was not declared in this scope; did you mean 'assert'?
   72 |         asert(N*Q<=1000000);
      |         ^~~~~
      |         assert
a.cc: In instantiation of 'V BIT<V, ME>::add(int, V) [with V = int; int ME = 20]':
a.cc:33:19:   required from here
   33 |         FOR(i,N+1) bt.add(i,-1);
      |                    ~~~~~~^~~~~~
a.cc:25:69: warning: no return statement in function returning non-void [-Wreturn-type]
   25 |         V add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
      |                                                                     ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  vector<long long> A(n);for(int i = 0; n > i; i++)cin>>A[i];
  long long ans = 1000000000000000LL;
  for(int bit = 0; (1<<(n-1)) > bit; bit++){
    if(__builtin_popcount(bit)+1 != k)continue;
    long long he = A[0];
    long long tmp = 0;
    for(int i = 0; n > i; i++){
      if(bit & (1<<i)){
        if(he < A[i+1]){
          he = A[i+1];
        }else{
          he++;
          tmp +=he-A[i+1];
        }
      }else{
        he = max(he,A[i+1]);
    }
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}
    


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

#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <algorithm>
#define llint long long
#define inf 1000000000000LL

using namespace std;
typedef pair<string, llint> P;

llint n;
string s[10005];
string t;
vector<P> vec;

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

  cin >> n;
  for(int i = 1; i <= n; i++) cin >> s[i];
  cin >> t;

  llint l;
  for(int i = 1; i <= n; i++){
    string S = s[i];
    for(int i = 0; i < S.size(); i++){
      if(S[i] == '?') S[i] = 'z';
    }
    vec.push_back(P(S, i));
  }
  string T = t;
  for(int i = 0; i < t.size(); i++){
    if(T[i] == '?') T[i] = 'a';
  }
  vec.push_back(P(T, 0));
  sort(vec.begin(), vec.end());

  for(int i = 0; i < vec.size(); i++){
    if(vec[i].second == 0){
      l = i+1;
      break;
    }
  }
  vec.clear();

  llint r;
  for(int i = 1; i <= n; i++){
    string S = s[i];
    for(int i = 0; i < S.size(); i++){
      if(S[i] == '?') S[i] = 'a';
    }
    vec.push_back(P(S, i));
  }
  string T = t;
  for(int i = 0; i < t.size(); i++){
    if(T[i] == '?') T[i] = 'z';
  }
  vec.push_back(P(T, inf));
  sort(vec.begin(), vec.end());

  for(int i = 0; i < vec.size(); i++){
    if(vec[i].second == inf){
      r = i+1;
      break;
    }
  }

  for(int i = l; i <= r; i++) cout << i <<  " ";
  cout << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:10: error: redeclaration of 'std::string T'
   57 |   string T = t;
      |          ^
a.cc:34:10: note: 'std::string T' previously declared here
   34 |   string T = t;
      |          ^
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <utility>
#define llint long long
#define inf 1000000000000LL

using namespace std;
typedef pair<string, llint> P;

llint n;
string s[100005];
string t;
vector<P> vec;

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

  cin >> n;
  for(int i = 1; i <= n; i++) cin >> s[i];
  cin >> t;

  llint l;
  for(int i = 1; i <= n; i++){
    string S = s[i];
    for(int i = 0; i < S.size(); i++){
      if(S[i] == '?') S[i] = 'z';
    }
    vec.push_back(P(S, i));
  }
  string T = t;
  for(int i = 0; i < t.size(); i++){
    if(T[i] == '?') T[i] = 'a';
  }
  vec.push_back(P(T, 0));
  sort(vec.begin(), vec.end());

  for(int i = 0; i < vec.size(); i++){
    if(vec[i].second == 0){
      l = i+1;
      break;
    }
  }
  vec.clear();

  llint r;
  for(int i = 1; i <= n; i++){
    string S = s[i];
    for(int i = 0; i < S.size(); i++){
      if(S[i] == '?') S[i] = 'a';
    }
    vec.push_back(P(S, i));
  }
  for(int i = 0; i < t.size(); i++){
    string T = t;
    if(T[i] == '?') T[i] = 'z';
  }
  vec.push_back(P(T, inf));
  sort(vec.begin(), vec.end());

  for(int i = 0; i < vec.size(); i++){
    if(vec[i].second == inf){
      r = i+1;
      break;
    }
  }

  for(int i = l; i <= r; i++) cout << i <<  " ";
  cout << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   38 |   sort(vec.begin(), vec.end());
      |   ^~~~
      |   short
Language: C++

#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  string a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  //上にしかいない、下にしかいないを探す
  string m;cin>>m;
  int uponly = 0;
  int downonly = 0;
  for(int i = 0; n > i; i++){
    bool up = false;
    bool down = false;
    if(a[i]==a[j]){
      up = true;
      down = true;
    }
    for(int j = 0; min(m.size(),a[i].size()) > j; j++){
      if(up&&down)break;
      if(a[i][j]=='?'){
        if(m[j]=='a'){
          down = true;
        }else if(m[j]=='z'){
          up = true;
        }else{
          down = true;
          up = true;
        } 
      }else{
        if(a[i][j]>m[j]){
          up = true;
          break;
        }else if(a[i][j] < m[j]){
          down = true;
          break;
        }
      }
    }
    if((!up)&&down){
      downonly++;
    }else if((!down)&&up){
      uponly++;
    }
  }
  for(int i = uponly; downonly+2 > i; i++){
    cout << i;
    if(i+1!=n+2)cout << " ";
  }
  cout << endl;
}
        
      
          
        
      

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: 'j' was not declared in this scope
   16 |     if(a[i]==a[j]){
      |                ^
Language: C++

#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  string a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  //上にしかいない、下にしかいないを探す
  string m;cin>>m;
  int uponly = 0;
  int dwnonly = 0;
  for(int i = 0; n > i; i++){
    bool up = false;
    bool down = false;
    if(a[i]==a[j]){
      up = true;
      down = true;
    }
    for(int j = 0; min(m.size(),a[i].size()) > j; j++){
      if(up&&down)break;
      if(a[i][j]=='?'){
        if(m[j]=='a'){
          down = true;
        }else if(m[j]=='z'){
          up = true;
        }else{
          down = true;
          up = true;
        } 
      }else{
        if(a[i][j]>n[j]){
          up = true;
          break;
        }else if(a[i][j] < n[j]){
          down = true;
          break;
        }
      }
    }
    if((!up)&&down){
      downonly++;
    }else if((!down)&&up){
      uponly++;
    }
  }
  for(int i = uponly; n+2 > i; i++){
    cout << i;
    if(i+1!=n+2)cout << " ";
  }
  cout << endl;
}
        
      
          
        
      

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: 'j' was not declared in this scope
   16 |     if(a[i]==a[j]){
      |                ^
a.cc:32:21: error: invalid types 'int[int]' for array subscript
   32 |         if(a[i][j]>n[j]){
      |                     ^
a.cc:35:29: error: invalid types 'int[int]' for array subscript
   35 |         }else if(a[i][j] < n[j]){
      |                             ^
a.cc:42:7: error: 'downonly' was not declared in this scope; did you mean 'dwnonly'?
   42 |       downonly++;
      |       ^~~~~~~~
      |       dwnonly
Language: C++

#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
#include <math.h>
using namespace std;
char s[10001][30],s1[30];
int ans[10000],len,kk=0,n;
int strcmp1(const char *str1,const char *str2)
{
    if(*str1=='?'&&*str2!='z')
    return 0;
    //printf("!!");
    while((*str1 == *str2)||(*str1=='?'&&*str2=='z'))
    {
        //printf("!!!\n");
        if(*str1 == '\0')
            return 0;
        str1++;
        str2++;
    }
    if(*str1=='?'&&*str2!='z')
    return 0;
    return *str1 - *str2;
}
void solve(int k,int sum)
{
    if(k==n)
    {
        ans[kk++]=sum;
        return;
    }
    int j=strcmp1(s[k],s1);
    //printf("%d\n",j);
    if(j<0)
    {
       // printf("%s %s\n",s[k],s1);
        solve(k+1,sum+1);
    }
    else if(j==0)
    {
        solve(k+1,sum+1);
        solve(k+1,sum);
    }
    else
    {
        solve(k+1,sum);
    }
}
int main()
{
    scanf("%d",&n);
    getchar();
    for(int i=0;i<n;i++)
    {
        scanf("%s",s[i]);
        getchar();
    }
    gets(s1);
    int len=strlen(s1);
    solve(0,1);
    sort(ans,ans+kk);
    int fag=1,flag=1;
    /*
    for(int i=0;i<strlen(s1);i++)
    {
        if(s1[i]!='z')
        fag=1;
        if(s1[i]!='a')
        flag=1;
    }
    if(fag==1)
    printf("1\n");
    else if(flag==1)
    printf("%d\n",n+1);*/
    int jj=0;
        for(int i=0;i<kk;i++)
    {
        if(ans[i]!=ans[i-1]||i==0)
        {
            if(jj==1)
            printf(" %d",ans[i]);
            else
            printf("%d",ans[i]);
            jj=1;
        }
    }
    printf("\n");
}

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

#include <bits/stdc++.h>
 
using namespace std;
 
string s[10001], smin[10001], smax[10001], target;
int strict, pos, n;
 
int main(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>s[i];
        smin[i]=s[i];
        smax[i]=s[i];
        for(int j=0; j<s[i].size(); j++){
            if(s[i][j]=='?')smin[i][j]='a';
            if(s[i][j]=='?')smax[i][j]='z';
        }
    }
    cin>>target;
    for(int i=0; i<n; i++){
        if(smin[i]<=target && target<=smax[i]){
            pos++;
        }
        if(smax[i]<target){
            strict++;
        }
    }
    for(int i=0; i<pos; i++){
        cout<<strict+i+1<<" ";
    }
    cout << strict+i+pos;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:20: error: 'i' was not declared in this scope
   31 |     cout << strict+i+pos;
      |                    ^
Language: C

#include<stdio.h>
char s[10000][21],t[21];
int main(int argc, char const *argv[]){
	int n,a=0,b=0,i,j,bf,nf;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	scanf("%s",t);
	for(i=0;i<n;i++){
		af=1;
		bf=1;
		for(j=0;j<20;j++){
			if(s[i][j]=='\0'){
				if(t[j]!='\0'){
					if(af) a++;
				}
				break;
			}else if(t[j]=='\0'){
				if(bf) b++;
				break;
			}else if(s[i][j]=='?'){
				if(t[j]=='a') bf=0;
				else if(t[j]=='z') af=0;
				else break;
			}else if(s[i][j]>t[j]){
				if(bf) b++;
			}else if(s[i][j]<t[j]){
				if(af) a++;
			}
		}
	}
	printf("%d",a+1);
	for(i=a+1;i<n+1-b;i++){
		printf(" %d",i);
	}
	printf("\n");
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:11:17: error: 'af' undeclared (first use in this function); did you mean 'nf'?
   11 |                 af=1;
      |                 ^~
      |                 nf
main.c:11:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
bool c(string a,string b)
{
	for(int i=0;i<a.size();i++)a[i]=='?'&&(a[i]='z');
	return b<=a;
}
bool d(string a,string b)
{
	for(int i=0;i<a.size();i++)a[i]=='?'&&(a[i]='a');
	return a<=b;
}
main()
{
	vector<string>a;int n;cin>>n;
	string t;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		a.push_back(t);
	}
	cin>>t;
	sort(a.begin(),a.end());
	vector<int>ans;
	for(int i=0;i<n;i++)
	{
		if(c(a[i],t))ans.push_back(i+1);
		if(d(a[i],t)&&(i==n-1||c(a[i+1],t))ans.push_back(i+2);
	}
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
	for(int i=0;i<ans.size();i++)
	{
		cout<<(i?" ":"")<<ans[i];
	}
	cout<<endl;
}


Compiler output:
a.cc:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:30:52: error: expected ';' before 'ans'
   30 |                 if(d(a[i],t)&&(i==n-1||c(a[i+1],t))ans.push_back(i+2);
      |                                                    ^~~
      |                                                    ;
a.cc:31:9: error: expected primary-expression before '}' token
   31 |         }
      |         ^
a.cc:30:71: error: expected ')' before '}' token
   30 |                 if(d(a[i],t)&&(i==n-1||c(a[i+1],t))ans.push_back(i+2);
      |                   ~                                                   ^
      |                                                                       )
   31 |         }
      |         ~                                                              
a.cc:31:9: error: expected primary-expression before '}' token
   31 |         }
      |         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

string s[10001], smin[10001], smax[10001], target;
int strict, pos, n;

int main(){
cin>>n;
for(int i=0, i<n; i++){
cin>>s[i];
smin[i]=s[i];
smax[i]=s[i];
for(int j=0; j<s[i].size(); j++){
if(s[i][j]=='?')smin[i][j]='a';
if(s[i][j]=='?')smax[i][j]='z';
}
}
cin>>target;
for(int i=0, i<n; i++){
if(smin[i]<=target && target<=smax[i]){
pos++;
}
if(smax[i]<target){
strict++;
}
}
for(int i=0, i<pos; i++){
cout<<strict+i+1<<" ";
}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: expected ';' before '<' token
   10 | for(int i=0, i<n; i++){
      |               ^
      |               ;
a.cc:10:15: error: expected primary-expression before '<' token
a.cc:20:15: error: expected ';' before '<' token
   20 | for(int i=0, i<n; i++){
      |               ^
      |               ;
a.cc:20:15: error: expected primary-expression before '<' token
a.cc:28:15: error: expected ';' before '<' token
   28 | for(int i=0, i<pos; i++){
      |               ^
      |               ;
a.cc:28:15: error: expected primary-expression before '<' token
Language: C++

#include <vector>
#include <string.h>
#include<iostream>
#include<set>
#include<map>
#include<unordered_map>
#include<string.h>
#include<algorithm>
#include <stdlib.h>
#include<queue>
using namespace std;




int main(){
    int n;
    int before=0,after=0i, ambiguous=0;
    cin>>n;
    vector<string>vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    string name;
    cin>>name;
    priority_queue<int>str_has_q;
    for(int i=0;i<n;i++){
        string s,s2;
        s=vec[i],s2=vec[i];
        s2=s;
        bool q=false;
        for(int j=0;j<s.length();j++){
            if(s[j]=='?'){
                s[j]='a';
                s2[j]='z';
                q=true;
            }
        }
        if(q){
            if(s<name&&s2<name){
                before++;
            } else if(s>name&&s2>name){
                after++;
            } else {
                ambiguous++;
            }
            str_has_q.push(i);
        }
    }
    
    while(str_has_q.size()){
        int to=str_has_q.top();
        str_has_q.pop();
        vec.erase(vec.begin()+to);
    }
    sort(vec.begin(),vec.end());
    bool out=false;
    if(vec[0]>name){
        for(int i=max(0,before-after);i<before;i++)
            cout<<1+i<<" ";
        cout<<1+before<<endl;
        return 0;
    }
    vector<int>ans;
    for(int i=0;i<vec.size();i++){
        if(name==vec[i]){
            ans.push_back(i+1);
            out=true;
        }
        if(i>0&&vec[i]>name&&name>=vec[i-1]){
            ans.push_back(i+1);
            
            set<int>ind;
            for(int i=0;i<=ambiguous;i++){
                for(auto a:ans){
                    ind.insert(before+i+a);
                }
            }
            vector<int>ult;
            for(auto a:ind){
                ult.push_back(a);
            }
            for(int i=0;i<ult.size()-1;i++){
                cout<<ult[i]<<" ";
            }
            cout<<ult[ult.size()-1]<<endl;
            return 0;
        }
    }
    ans.push_back(vec.size()+1);
    set<int>ind;
    for(int i=0;i<=ambiguous;i++){
        for(auto a:ans){
            ind.insert(before+i+a);
        }
    }
    vector<int>ult;
    for(auto a:ind){
        ult.push_back(a);
    }
    for(int i=0;i<ult.size()-1;i++){
        cout<<ult[i]<<" ";
    }
    cout<<ult[ult.size()-1]<<endl;
    //else cout<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:24: error: cannot convert '__complex__ int' to 'int' in initialization
   18 |     int before=0,after=0i, ambiguous=0;
      |                        ^~
Language: C++

#include <iostream>
#include <cstring>

#define   offcin        ios::sync_with_stdio(false)
using namespace std;

const int maxn = 1e4 + 5;

string s[maxn], a[maxn], b[maxn];

int main(int argc, const char * argv[]) {
    offcin;
    int N;
    cin>>N;
    for (int i = 1; i <= N; i ++) {
        cin>>s[i];
        long len = s[i].length();
        for (int j = 0; j < len; j ++) {
            if (s[i][j] == '?') a[i] += 'a', b[i] += 'z';
            else a[i] += s[i][j], b[i] += s[i][j];
        }
    }
    string t; cin>>t;
//    a[N + 1] = b[N + 1] = t;
    sort(a + 1, a + N + 1);
    sort(b + 1, b + N + 1);
    
    int l1 = 1, l2 = 1;
    while (l1 <= N && a[l1] < t) l1 ++;
    while (l2 <= N && b[l2] <= t) l2 ++;
    
    if (l1 > l2) swap(l1, l2);
    
    for (long i = l1; i <= l2; i ++) cout<<i<<" ";
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:25:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   25 |     sort(a + 1, a + N + 1);
      |     ^~~~
      |     short
Language: C++

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

int main() {
    int n;
    cin >> n;
    string s[n];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    string t;
    cin >> t;
    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++) {
        if (t < s[i]) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: request for member 'begin' in 's', which is of non-class type 'std::string [n]' {aka 'std::__cxx11::basic_string<char> [n]'}
   13 |     sort(s.begin(), s.end());
      |            ^~~~~
a.cc:13:23: error: request for member 'end' in 's', which is of non-class type 'std::string [n]' {aka 'std::__cxx11::basic_string<char> [n]'}
   13 |     sort(s.begin(), s.end());
      |                       ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int n;
string s[100010], t;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> s[i];
	cin >> t;
	int ansl = 1, ansr = 1;
	for(int i = 1; i <= n; i ++)
	{
		bool L = 0, R = 0;
		string x = s[i];
		for(int j = 0; j < x.size(); j ++)
			if(s[i][j] == '?') x[j] = 'z';
		if(x >= t) R = 1;
		for(int j = 0; j < x.size(); j ++)
			if(s[i][j] == '?') x[j] = 'a';
		if(x <= t) L = 1;
		if(L && R) ansr ++;
		else if(L) ansl ++, ansr ++;
	}
	for(int i = ansl; i <= ansr; i ++)
		cout<<i<<" \n"[i==r];
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:35: error: 'r' was not declared in this scope
   27 |                 cout<<i<<" \n"[i==r];
      |                                   ^
Language: C++

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

int n; 
string s[100010], t;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i ++) 
		cin >> s[i];
	cin >> t;
	int ansl = 1, ansr = 1;
	for(int i = 1; i <= n; i ++)
	{
		bool L = 0, R = 0;
		string x = s[i];
		for(int j = 0; j < x.size(); j ++)
			if(s[i][j] == '?') x[j] = 'z';
		if(x >= t) R = 1;
		for(int j = 0; j < x.size(); j ++)
			if(s[i][j] == '?') x[j] = 'a';
		if(x <= t) L = 1;
		if(L && R) ansr ++;
		else if(L) ansl ++, ansr ++;
	}
	for(int i = ansl; i <= ansr; i ++) 
		cout << i << " ";
}


Compiler output:
a.cc:2:9: error: no macro name given in #define directive
    2 | #define
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
string s[10010];
string t;
int main(void){
	cin >> N;
	rep(i, N)cin >> s[i];
	cin >> t;
	string tmp = t;
	while(t.size() < 20){
		t += 'A';
	}

	int mae = 0, usi = 0;
	rep(k, N){
		string d = s[k];
		bool fmae = false, fusi = false;

		if(d != tmp){
			rep(i, s.size()){
				if(d[i] != '?' && d[i] < t[i]){
					fmae = true;
					break;
				}else if(d[i] != '?' && d[i] > t[i]){
					fusi = true;
					break;
				}else if(d[i] == '?' && t[i] != 'a' && t[i] != 'z'){
					// printf("k\n");
					fmae = true; fusi = true;
					break;
				}else if(d[i] == '?' && t[i] != 'z'){
					fusi = true;
				}else if(d[i] == '?' && t[i] != 'a'){
					fmae = true;
				}
			}
		}else{
			fmae = true; fusi = true;
		}

		if(fmae) mae++;
		if(fusi) usi++;
	}

	// printf("%d %d\n", mae, usi);
	int r = mae + 1;
	int l = N - usi + 1;
	// printf("%d\n", r - l);
	reps(i, l, r + 1){
		if(i != r)printf("%d ", i);
		else printf("%d\n", i);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:34: error: request for member 'size' in 's', which is of non-class type 'std::string [10010]' {aka 'std::__cxx11::basic_string<char> [10010]'}
   41 |                         rep(i, s.size()){
      |                                  ^~~~
a.cc:7:33: note: in definition of macro 'rep'
    7 | #define rep(i,n) for(int i=0;i<(n);i++)
      |                                 ^
Language: C++

import java.util.Scanner;

public class Main {
	static boolean win(StringBuilder a, StringBuilder b){
		StringBuilder c = new StringBuilder(a);
		StringBuilder d = new StringBuilder(b);
		for(int i=0; i<c.length(); i++){
			if(c.charAt(i) == '?') c.setCharAt(i, 'a');
		}
		for(int i=0; i<d.length(); i++){
			if(d.charAt(i) == '?') d.setCharAt(i, 'z');
		}
		for(int i=0; i<c.length() && i<d.length(); i++){
			if(c.charAt(i) != d.charAt(i)){
				return c.charAt(i) < d.charAt(i);
			}
		}
		return c.length() <= d.length();
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		StringBuilder s[] = new StringBuilder[n];
		StringBuilder t;
		for(int i=0; i<n; i++) s[i] = new StringBuilder(sc.next());
		t = new StringBuilder(sc.next());
		int low = 0, high = 0;
		for(int i=0; i<n; i++){
			boolean p1 = win(t, s[i]);
			boolean p2 = win(s[i], t);
			if(p1 && p2){
				high++;
			}
			else if(p2){
				low++;
				high++;
			}			
		}
		sc.close();
		for(int i=low+1; i<=high+1; i++){
			System.out.print(i);
			if(i <= high) System.out.print(" ");
			else System.out.println("");
		}
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

#include<stdio.h>
#include<string.h>
int main (){
char moji[10003][21],s[10003][21],tmp[21];
int n,i,j,a;
scanf("%d",&n) ;
for(i=0;i<n+1;i++){
scanf("%s",moji[i]);
}
a=n;
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
if(strcmp(moji[j-1], moji[j])>0){
strcpy(tmp, moji[j-1]);
strcpy(moji[j-1], moji[j]);
strcpy(moji[j], tmp);
if (j==a) a=j-1;
}
}
}
printf("%d\n",a+1);
for(i=a;i>=0;i--){
if (strcmp(moji[i-1],moji[i])==0) printf("%d\n",i);
if else  break;
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:4: error: expected '(' before 'else'
   24 | if else  break;
      |    ^~~~
      |    (
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

bool win(string a, string b){
	for(auto &i : a) if(i == '?') i = 'a';
	for(auto &i : b) if(i == '?') i = 'z';
	return a <= b;
}

int n;
string a, b[10005];

int main(){
	cin >> n;
	for(int i=0; i<n; i++) cin >> b[i];
	cin >> a;
	int l = 0, h = 0;
	for(int i=0; i<n; i++){
		if(win(a, b[i]) && win(b[i], a)) h++;
		else if(win(b[i], a)) l++, h++;
	}
	for(int i=l+1; i<=h+1; i++){
cout << i;
if(i <= h) cout << " ";
}


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

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

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n) cin >> a[i];
    ll ans=1e18;
  rep(bit,1<<n){
    if(__builtin_popcount(bit)<k || bit%2==0)continue;
    vector<ll> s;
    rep(i,n) {
      if(bit>>j&1) s.push_back(i);
    }
    ll l = 0,total = 0;
    rep(j,s.size()){
        l = max(l+1,*max_element(a+s[j],a+s[j+1]));
        total += l - a[s[j]];
    }
    ans = min(ans,total);
  }
  cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: 'j' was not declared in this scope
   20 |       if(bit>>j&1) s.push_back(i);
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  

Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: expected '}' at end of input
    7 | int main() {
      |            ~^
Language: C

#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
long long dp[100010];
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;}
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
  long long n, k;
  cin >> n >> k;
  long long a[n];
  rep(i,n)
    cin >> a[i];
  long long ans = INF;
  rep(i,(1<<n)){
    if(bitset<64>(i).count()==k){
      int bit[30];
      rep(j,n)
        bit[j] = (i/(1<<j))%2;
      bool flag = true;
      long long tmp=0, pre = 0;
      rep(j,n){
        chmax(tmp, a[j]);
        if(bit[j]==1){
          if(flag){
            flag = false;
          } else{
            if(a[j]<=tmp){
              tmp++;
              pre += tmp-a[j];
            } else {
              tmp = a[j];
            }
          }
        }
      }
      chmin(ans,pre);
    }
  }
  cout << ans << endl;
}


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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans=1e15;
    for(ll i=0;i<(1<<n);i++){
        ll cost=0;
        ll mh=0;
        ll num=0;
        vector<ll>b=a;
        for(ll j=0;j<n;j++){
            if(i & (1<<j)){
                cost+=max(0,mh+1-b[j]);
                b[j]=max(b[j],mh+1);
                if(b[j]>mh) num++;
            }
            mh=max(mh,b[j]);
        }
        if(num>=k) ans=min(ans,cost);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:26: error: no matching function for call to 'max(int, ll)'
   20 |                 cost+=max(0,mh+1-b[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: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:20:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   20 |                 cost+=max(0,mh+1-b[j]);
      |                       ~~~^~~~~~~~~~~~~
/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:20:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |                 cost+=max(0,mh+1-b[j]);
      |                       ~~~^~~~~~~~~~~~~
Language: C++

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

#define ll long long

void chmin(ll& a, ll b) {
  if (a > b) a = b;
}

int main() {

  int N, K;
  cin >> N >> K;
  
  vector<ll> a(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  // i番目までで最も高いもの
  vector<ll> height(N);
  height[0] = 0;
  height[1] = a[0];
  
  ll SUBMAX = a[0];
  for (int i = 1; i < N; i++) {
    if (a[i] > SUBMAX) {
      height[i] = a[i-1];
    } else {
      height[i] = SUBMAX;
    }
  }
  

  
  ll ans = 10000000000000;
  
  // bit 全探索
  for (int bit = 0; bit < (1 << N); bit++) {
    ll color = 0;
    ll cost = 0;
    
    ll temp = 0; 
    for (int i = 0; i < N; i++) {
      
      if (!(bit & (1 << 0)) continue;
          
      if (bit & (1 << i)) {
        color++;

        // 次の建物に必要な最低限の高さを temp で現す
        if (temp >= height[i]) {
          temp++;
        } else {
          temp = height[i]+1;
        }
        
        // cost の計算
        if (i == 0) {
          temp = a[0];
          continue;
        }
        if (a[i] > temp) {
           temp = a[i];
           continue;
        }
        cost += temp -a[i];
      }
    }
    
    if (color >= K) chmin(ans, cost);
    
  }  
  
  cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:28: error: expected ';' before 'continue'
   47 |       if (!(bit & (1 << 0)) continue;
      |                            ^~~~~~~~~
      |                            ;
a.cc:49:7: error: expected primary-expression before 'if'
   49 |       if (bit & (1 << i)) {
      |       ^~
a.cc:47:38: error: expected ')' before 'if'
   47 |       if (!(bit & (1 << 0)) continue;
      |          ~                           ^
      |                                      )
   48 | 
   49 |       if (bit & (1 << i)) {
      |       ~~                              
a.cc:70:5: error: expected primary-expression before '}' token
   70 |     }
      |     ^
Language: C++

#include <iostream>
#include <vector>
#include <climits>

using namespace std;

typedef long long ll;

vector<int> v;

ll dfs(ll i, ll N, ll K, ll *a, ll m) {
    if (i == N) {
        if (v.size() < K)
            return 999999999999;
        
        return 0;
    }

    ll ans;
    if (a[i] <= m) {
        v.push_back(i);
        ans = m+1-a[i]+dfs(i+1, N, K, a, m+1);
        v.pop_back();
        ans = min(ans, dfs(i+1, N, K, a, m));
        return ans;
    }
    else {
        v.push_back(i);
        ans = dfs(i+1, N, K, a, a[i]);
        v.pop_back(i);
        return ans;
    }
}

int main() {
    ll N, K;   cin >> N >> K;
    ll *a = new ll[N];
    for (int i = 0; i < N; i++)
        cin >> a[i];
    
    cout << dfs(0, N, K, a, 0) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'll dfs(ll, ll, ll, ll*, ll)':
a.cc:30:19: error: no matching function for call to 'std::vector<int>::pop_back(ll&)'
   30 |         v.pop_back(i);
      |         ~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1324:7: note: candidate: 'void std::vector<_Tp, _Alloc>::pop_back() [with _Tp = int; _Alloc = std::allocator<int>]'
 1324 |       pop_back() _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1324:7: note:   candidate expects 0 arguments, 1 provided
Language: C++

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

int main() {
   int N,K;
   cin >> N >> K;
   int A[N];
   for (int i=0; i<N; i++) {
       cin >> A[i];
   }
   cout << total << endl;
   for (int tmp=0; tmp<(1<<15); tmp++) {
       bitset<15> s(tmp);
       int B[K],C[N],count=0;
       if (!s.test(count)) continue;
       for (int i=0; i<N; i++) {
           if (s.test(i)) count++;
       }
       if (count!=K) continue;
       count=0;
       for (int i=0; i<N; i++) {
           if (s.test(i) && count!=K) {
               B[count]=i;count++;
           }
           else C[i]=A[i];
       }
       C[0]=A[0];
       int n=A[0];
       count=0;
       for (int i=1; i<K; i++) {
           int a=B[i-1];
           int b=B[i];
           for (int j=a; j<b; j++) {
               if (n<C[j]) n=C[j];
               if (j==b-1 && n<A[b]) C[b]=A[b];
               else if (j==b-1) {
                   C[b]=n+1;
                   count+=n+1-A[b];
               }
           }
       }
       if (total>count) total=count;
   }
   cout << total << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 'total' was not declared in this scope
   11 |    cout << total << endl;
      |            ^~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

int N, K;
vector<ll> A;

void solve(){
    ll m = 1e+10;
    ll height = A[0];
    if(N == K){
        ll cost = 0;
        for (int i = 1; i < N; i++){
            ll dif = height - A[i];
            if(dif >= 0){
                cost += dif + 1;
                height += 1;
                continue;
            }
            height = A[i];
        }
        m = cost;
    }
    else{
       
        
        for (int b = 0; b < (1 << N); b++)
        {
            height = A[0];
            ll cost = 0;
            bitset<> bs(b);
            int cnt = 0;
            vector<int> v;

            for (int i = 0; i < N; i++){
                if(bs.test(i)){
                    cnt++;
                    v.push_back(i);
                }
            }

            if(cnt == K && bs.test(0)){
                for (int i = 1; i < (int)v.size(); i++){
                    ll dif = height - A[v[i]];
                    if(dif >= 0){
                        cost += dif + 1;
                        height += 1;
                        continue;
                    }
                   
                    height = A[v[i]];
                }

                 m = min(m, cost);
            }

           
            
        }
        
    }
    cout << m << endl;
}


int main(){
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    
    solve();

    return 0;

}

Compiler output:
a.cc: In function 'void solve()':
a.cc:34:20: error: wrong number of template arguments (0, should be 1)
   34 |             bitset<> bs(b);
      |                    ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bitset:804:11: note: provided for 'template<long unsigned int _Nb> class std::bitset'
  804 |     class bitset
      |           ^~~~~~
a.cc:39:23: error: request for member 'test' in 'bs', which is of non-class type 'int'
   39 |                 if(bs.test(i)){
      |                       ^~~~
a.cc:45:31: error: request for member 'test' in 'bs', which is of non-class type 'int'
   45 |             if(cnt == K && bs.test(0)){
      |                               ^~~~
Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];

  ll ans = 1e16;

  rep(i, (1 << N)){
    if(bitset<16>(i).count() != K or
    !bitset<16>(i).test(0) ) continue;

    ll cost = 0;
    ll h = a[0];
    // hはなるべき高さ
    rep(j ,N){
      if((i >> j) % 2 == 1){
        cost += max(h - a[j] , (ll)0);
        h = max(++h, a[j] + 1);
      }
    }
    // cout << i << " " << cost << endl;
    ans = min(ans , cost);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:8: error: 'bitset' was not declared in this scope
   41 |     if(bitset<16>(i).count() != K or
      |        ^~~~~~
a.cc:11:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   10 | #include<iomanip>
  +++ |+#include <bitset>
   11 | using namespace std;
a.cc:41:22: error: request for member 'count' in 'i', which is of non-class type 'll' {aka 'long long int'}
   41 |     if(bitset<16>(i).count() != K or
      |                      ^~~~~
a.cc:42:20: error: request for member 'test' in 'i', which is of non-class type 'll' {aka 'long long int'}
   42 |     !bitset<16>(i).test(0) ) continue;
      |                    ^~~~
Language: C++


#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N, K; cin >> N >> K;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];

  ll ans = 1e16;

  rep(i, (1 << N)){
    if(bitset<16>(i).count() != K or
    !bitset<16>(i).test(0) ) continue;

    ll cost = 0;
    ll h = a[0];
    // hはなるべき高さ
    rep(j ,N){
      if((i >> j) % 2 == 1){
        cost += max(h - a[j] , (ll)0);
        h = max(++h, a[j] + 1);
      }
    }
    // cout << i << " " << cost << endl;
    ans = min(ans , cost);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:12: error: 'cin' was not declared in this scope
   34 |   ll N, K; cin >> N >> K;
      |            ^~~
a.cc:11:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   10 | #include<iomanip>
  +++ |+#include <iostream>
   11 | using namespace std;
a.cc:41:8: error: 'bitset' was not declared in this scope
   41 |     if(bitset<16>(i).count() != K or
      |        ^~~~~~
a.cc:11:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   10 | #include<iomanip>
  +++ |+#include <bitset>
   11 | using namespace std;
a.cc:41:22: error: request for member 'count' in 'i', which is of non-class type 'll' {aka 'long long int'}
   41 |     if(bitset<16>(i).count() != K or
      |                      ^~~~~
a.cc:42:20: error: request for member 'test' in 'i', which is of non-class type 'll' {aka 'long long int'}
   42 |     !bitset<16>(i).test(0) ) continue;
      |                    ^~~~
a.cc:56:3: error: 'cout' was not declared in this scope
   56 |   cout << ans << endl;
      |   ^~~~
a.cc:56:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include<bits/stdc++.h>
using namespace std;
int64_t f(vector<int64_t>a,int64_t k){
int N=a.size();
  if(N<k)
  return 200000000000;
  else if(k==1){
  return 0;
  }else {
  if(a.at(0)<a.at(1)){
  a.erase(a.begin());
    return f(a,k-1);
  }else{
  int t=a.at(0)+1-a.at(1);
    a.erase(a.begin());
    a.erase(a.begin());
    return min(t+f(a,k-2),f(a,k-1));
  }
  
  }

}
int main(){
int64_t N,K;
  cin>>N>>K;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  int64_t ans=f(a,K);
  cout<<ans<<endl;
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:17: error: could not convert 'a' from 'vector<int>' to 'vector<long int>'
   29 |   int64_t ans=f(a,K);
      |                 ^
      |                 |
      |                 vector<int>
Language: C++

#include<bits/stdc++.h>
using namespace std;
int64_t f(vector<int64_t>a,int64_t k){
int N=a.size();
  if(N<k)
  return 200000000000;
  else if(k==1){
  return 0;
  }else {
  if(a.at(0)<a.at(1)){
  a.erase(a.begin());
    return f(a,k-1);
  }else{
  int t=a.at(0)+1-a.at(1);
    a.erase(a.begin());
    a.erase(a.begin());
    return min(t+f(a,k-2),f(a,k-1));
  }
  
  }

}
int main(){
int N,K;
  cin>>N>>K;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  int ans=f(a,K);
  cout<<ans<<endl;
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:13: error: could not convert 'a' from 'vector<int>' to 'vector<long int>'
   29 |   int ans=f(a,K);
      |             ^
      |             |
      |             vector<int>
Language: C++

#include<bits/stdc++.h>
using namespace std;
int f(vector<int>a,int k){
int N=a.size();
  if(N<k)
  return 20000000000;
  else if(k==1){
  return 0;
  }else {
  if(a.at(0)<a.at(1){
  a.erase(a.begin());
    return f(a,k-1);
  }else{
  int t=a.at(0)+1-a.at(0);
    a.erase(a.begin());
    a.erase(a.begin());
    return min(t+f(a,k-2),f(a,k-1));
  }
  
  }

}
int main(){
int N,K;
  cin>>N>>K;
  vector<int>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  int ans=f(a,K);
  cout<<ans<<endl;
   return 0;
}

Compiler output:
a.cc: In function 'int f(std::vector<int>, int)':
a.cc:6:10: warning: overflow in conversion from 'long int' to 'int' changes value from '20000000000' to '-1474836480' [-Woverflow]
    6 |   return 20000000000;
      |          ^~~~~~~~~~~
a.cc:10:21: error: expected ')' before '{' token
   10 |   if(a.at(0)<a.at(1){
      |     ~               ^
      |                     )
a.cc:20:3: error: expected primary-expression before '}' token
   20 |   }
      |   ^
a.cc:22:1: warning: control reaches end of non-void function [-Wreturn-type]
   22 | }
      | ^