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

#include<bits/stdc++.h>
using namespace std;
int h,w,n;

void drop(vector<string> &cp){
  for(int j=0;j<w;j++){
    int empcnt=0;
    for(int i=h-1;i>=0;i--){
      if(cp[i][j]=='.') empcnt++;
      else if(empcnt>0){
	cp[i+empcnt][j]=cp[i][j];
	cp[i][j]='.';
      }
    }
  }
  return;
}

bool clear(vector<string> &cp){
  bool cleared=false;
  vector<vector<int>> cl(h,vector<int>(w,0));
  for(int i=0;i<h;i++){
    int prec='&'-'A';
    int cnt=0;
    for(int j=0;j<w;j++){
      if(prec==(cp[i][j]-'A')){
	cnt++;
      }
      else{
	if(cnt>=n){
	  for(int k=j-cnt;k<j;k++){
	    cl[i][k]=true;

	  }
	}
	if(isalpha(cp[i][j])){
	  prec=(cp[i][j]-'A');
	  cnt=1;
	}
	else{
      	  cnt=-10000;
	  prec='&'-'A';
	}
      }
    }
    if(prec!='&'-'A' && cnt>=n){
      for(int k=w-cnt;k<w;k++){

	cl[i][k]=true;
      }
    }
  }

  for(int j=0;j<w;j++){
    int prec='&'-'A';
    int cnt=-10000;
    for(int i=0;i<h;i++){
      if(prec==(cp[i][j]-'A')){

	cnt++;
      }
      else{
	if(cnt>=n){
	  for(int k=i-cnt;k<i;k++){
	    cl[k][j]=true;

	  }
	}
	  if(isalpha(cp[i][j])){
	    cnt=1;
	    prec=(cp[i][j]-'A');
	  }
	  else{
	    cnt=-10000;
	    prec='&'-'A';
	  }
	  
      }
      
    }
    if(prec!='&'-'A' && cnt>=n){
      for(int k=h-cnt;k<h;k++){
	cl[k][j]=true;

      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(cl[i][j]){
	cp[i][j]='.';
	cleared=false;
      }
    }
  }
  return cleared;
}

int times=0;
bool check(vector<string> &cp){
  times++;
  assert(times<500;
  bool no_block=true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      no_block=(no_block && cp[i][j]=='.');

    }

  }
  if(no_block) return true;
  drop(cp);
  if(!clear(cp)) return false;
  return check(cp);
}

int main(){
  while(cin>>h>>w>>n,h){
    vector<string> b(h);
    for(int i=0;i<h;i++) cin>>b[i];
    bool res=false;
    for(int i=0;i<h;i++){
      for(int j=0;j<w-1;j++){
	times=0;
	vector<string> cp=b;
	swap(cp[i][j],cp[i][j+1]);
	res=res||check(cp);
	if(res){
	  j=w;
	  i=h;
	}
      }
    }
    cout<<(res?"YES":"NO")<<endl;
  }
  return 0;
}

Compiler output:
a.cc:137:2: error: unterminated argument list invoking macro "assert"
  137 | }
      |  ^
a.cc: In function 'bool check(std::vector<std::__cxx11::basic_string<char> >&)':
a.cc:102:3: error: 'assert' was not declared in this scope
  102 |   assert(times<500;
      |   ^~~~~~
a.cc:2:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    1 | #include<bits/stdc++.h>
  +++ |+#include <cassert>
    2 | using namespace std;
a.cc:102:9: error: expected '}' at end of input
  102 |   assert(times<500;
      |         ^
a.cc:100:31: note: to match this '{'
  100 | bool check(vector<string> &cp){
      |                               ^
a.cc:102:9: warning: no return statement in function returning non-void [-Wreturn-type]
  102 |   assert(times<500;
      |         ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m,q;
	cin>>n>>m>>q;
	vs tmp(m,"");
	rep(i,n)rep(j,m){
		char c;cin>>c;
		tmp[j]=c+tmp[j];
	}
//	rep(i,m)cout<<in[i]<<endl;
	bool h=false;
	rep(x,m-1)rep(y,n)if(in[x][y]!='.'&&in[x+1][y]!='.'){
		vs in=tmp;
		swap(in[x][y],in[x+1][y]);
		rep(i,m){
			string t="";
			rep(j,n)if(in[i][j]!='.')t+=in[i][j];
			while(t.size()!=n)t+=".";
			in[i]=t;
		}
		while(1){
			vvi to(m,vi(n));
			rep(i,m)rep(j,n-1)if(in[i][j]!='.'){
				int t=j;
				while(t+1<n&&in[i][t]==in[i][t+1])t++;
				if(t-j+1>=q)loop(k,j,t+1)to[i][k]=true;
				j=t;
			}
			rep(i,n)rep(j,m-1)if(in[j][i]!='.'){
				int t=j;
				while(t+1<m&&in[t][i]==in[t+1][i])t++;
				if(t-j+1>=q)loop(k,j,t+1)to[k][i]=true;
				j=t;
			}
			bool he=false;
			rep(i,m){
				string t="";
				rep(j,n)if(!to[i][j])t+=in[i][j];
				while(t.size()!=n)t+=".";
				if(in[i]!=t)he=true;
				in[i]=t;
			}
			if(!he)break;
		}
		bool H=true;
		rep(i,m)rep(j,n)if(in[i][j]!='.')H=false;
		if(H)h=true;
	}
	if(h)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:30: error: 'in' was not declared in this scope; did you mean 'n'?
   54 |         rep(x,m-1)rep(y,n)if(in[x][y]!='.'&&in[x+1][y]!='.'){
      |                              ^~
      |                              n
a.cc:55:20: error: redeclaration of 'vs in'
   55 |                 vs in=tmp;
      |                    ^~
a.cc:54:30: note: '<typeprefixerror>in' previously declared here
   54 |         rep(x,m-1)rep(y,n)if(in[x][y]!='.'&&in[x+1][y]!='.'){
      |                              ^~
Language: C++

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

bool game(int n, int i, int j, vector<vector<int> > ennichi){

    int h = ennichi.size();
    int w = ennichi[0].size();
    int temp = ennichi[i][j];
    ennichi[i][j] = ennichi[i][j + 1];
    ennichi[i][j + 1] = temp;

    while(1){

        bool end = true;
        for(int i = 0; i < h; i++){
            for(int j = 0; j + n < w; j++){
                bool flag = true;
                int num = ennichi[i][j]
                for(int k = j + 1; k <= j + n; k++){
                    if(num != ennichi[i][k]){
                        flag = false;
                        end = true;
                        break;
                    }
                }

                if(flag) for(int k = j; k <= j + n; k++) ennichi[i][k] = 0;
            }
        }

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(ennichi[i][j] == 0){
                    for(int k = i - 1; k >= 0; k--){
                        ennichi[k + 1][j] = ennichi[k][j];
                    }
                    ennichi[0][j] = 0;
                }
            }
        }

        if(end) break;
    }

    bool flag = true;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(ennichi[i][j]){
                flag = false;
                break;
            }
        }
    }

    return flag

}

int main(){
    int h, w, n; cin >> h >> w >> n;
    vector<vector<int> > ennichi(h, vector<int> (w, 0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char input; cin >> input;
            if(input != '.') ennichi[i][j] = (int)input - 'A' + 1;
        }
    }

    bool flag = false;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w - 1; j++){
            if(ennichi[i][j] && ennichi[i][j + 1]) flag = game(n, i, j, ennichi);
            if(flag){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
}


Compiler output:
a.cc: In function 'bool game(int, int, int, std::vector<std::vector<int> >)':
a.cc:19:17: error: expected ',' or ';' before 'for'
   19 |                 for(int k = j + 1; k <= j + n; k++){
      |                 ^~~
a.cc:19:36: error: 'k' was not declared in this scope
   19 |                 for(int k = j + 1; k <= j + n; k++){
      |                                    ^
a.cc:55:16: error: expected ';' before '}' token
   55 |     return flag
      |                ^
      |                ;
   56 | 
   57 | }
      | ~
Language: C++

#include<iostream>
#include<Windows.h>
using namespace std;

int h,w,n;

void copy(int map[31][31],int copymap[31][31]){
	for(int i=0;i<31;i++){
		for(int j=0;j<31;j++){
			copymap[i][j] = map[i][j];
		}
	}
}

bool solve(int map[31][31]){
	POINT deletemap[10000];
	int count=0;
	int code;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(map[i][j] > 1){
				int num = 1;
				code = map[i][j];
				while(map[i][j+num] == code){
					num++;
				}
				if(n <= num){
					for(int k=0;k<num;k++){
						deletemap[count].x = j+k;
						deletemap[count].y = i;
						count++;
					}
				}

				num = 1;
				while(map[i+num][j] == code){
					num++;
				}
				if(n <= num){
					for(int k=0;k<num;k++){
						deletemap[count].x = j;
						deletemap[count].y = i+k;
						count++;
					}
				}
			}
		}
	}

	for(int i=0;i<count;i++){
		map[deletemap[i].y][deletemap[i].x] = 0;
	}

	bool flag  = true;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(map[i][j] > 1){
				flag = false;
			}
		}
	}
	if(flag){
		return true;
	}else if(count == 0){
		return false;
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(map[i][j] > 1 && map[i+1][j] == 0){
				map[i+1][j] = map[i][j];
				map[i][j] = 0;
			}
		}
	}

	return solve(map);
}

int main(){	
	int map[31][31]={-1};
	int bufmap[31][31];
	char buf;
	bool ans = false;

	cin >> h >> w >> n;

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> buf;
			if(buf == '.'){
				map[i][j] = 0;
			}else{
				map[i][j] = buf;
			}
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			if(map[i][j] == map[i][j+1]){
				continue;
			}
			
			copy(map,bufmap);
			int bufdata;
			bufdata = bufmap[i][j];
			bufmap[i][j] = bufmap[i][j+1];
			bufmap[i][j+1] = bufdata;
			
			ans = solve(bufmap);
			if(ans){
				break;
			}
		}
		if(ans){
			break;
		}
	}
	
	if(ans){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

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

#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

// distance between (x1,y1) and (x2,y2)
double cdis(double x1, double y1, double x2, double y2) {
  return sqrtl((x1 - x2) * (x1 - x2) +
               (y1 - y2) * (y1 - y2));
}
// cos a
double costh(double a, double b, double c) {
  return (b * b + c * c - a * a) / (2.0 * b * c);
}
double r, t;
int n;
pair<double, double> c[25];
double dis[25][25] = {0};
// possible? i -> j -> k
bool ch[25][25][25] = {0};
double dp[25][25][10000] = {0};

int solve();

int main() {
  cin >> n >> r >> t;
  for(int i = 0; i < n; ++i) {
    double x, y;
    cin >> x >> y;
    c[i] = make_pair(x, y);
  }
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j)
      dis[i][j] = dis[j][i] =
          cdis(c[i].fi, c[i].se, c[j].fi, c[j].se);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      for(int k = 0; k < n; ++k) {
        if(i == j || j == k) continue;
        double a = dis[i][k], b = dis[i][j], c = dis[j][k];
        if(180.0 - acos(costh(a, b, c)) * 180 / M_PI <= r &&
           fabs(c - a + b) > 0.0001 &&
           fabs(b - a + c) > 0.0001)
          ch[i][j][k] = 1;
      }

  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  for(int i = 1; i < n; ++i)
    if(dis[0][i] <= r) {
      dp[0][i][1] = dis[0][i];
      ans = 1;
    }
  if(ans == 0) return ans;
  // i -> j -> l
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      for(int l = 0; l < n; ++l) {
        if(i == j || j == l || (!ch[i][j][l]) ||
           dp[i][j][k - 1] == 0 ||
           dp[i][j][k - 1] + dis[j][l] > r)
          continue;
        if(dp[j][l][k] == 0) {
          ans = k;
          dp[j][l][k] = dp[i][j][k - 1] + dis[j][l];
        }
        else
          dp[j][l][k] =
              min(dp[j][l][k], dp[i][j][k - 1] + dis[j][l]);
      }
  if(ans != k) break;
}
return ans;
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:64:21: error: 'k' was not declared in this scope
   64 |            dp[i][j][k - 1] == 0 ||
      |                     ^
a.cc:67:21: error: 'k' was not declared in this scope
   67 |         if(dp[j][l][k] == 0) {
      |                     ^
a.cc:75:13: error: 'k' was not declared in this scope
   75 |   if(ans != k) break;
      |             ^
a.cc:75:16: error: break statement not within loop or switch
   75 |   if(ans != k) break;
      |                ^~~~~
a.cc: At global scope:
a.cc:77:1: error: expected unqualified-id before 'return'
   77 | return ans;
      | ^~~~~~
a.cc:78:1: error: expected declaration before '}' token
   78 | }
      | ^
a.cc: In function 'int solve()':
a.cc:76:1: warning: control reaches end of non-void function [-Wreturn-type]
   76 | }
      | ^
Language: C++

#include<iostream>
#include<complex>
#include<queue>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
typedef complex<double> P;
 
struct S{
  int w,p,n;
  double d;
  bool operator<(S s)const{
    return d>s.d;
  }
};
 
double dot(P a,P b){
  return (conj(a)*b).real();
}
 
int main(){
  int n;
  double r,th;
  cin>>n>>r>>th;
  P p[21];
  for(int i=1;i<=n;i++){
    int x,y;
    cin>>x>>y;
    p[i]=P(x,y);
  }
  priority_queue<S> que;
  que.push({1,0,0,0});
  static bool mem[21][21][22222];
  int m=0;
  while(!que.mepty()){
    auto cs=que.top();
    if(cs.d>r)break;
    que.pop();
    if(mem[cs.w][cs.p][cs.n]++)continue;
    m=max(m,cs.n);
    for(int i=1;i<=n;i++){
      if(i==cs.w)continue;
      auto f=p[cs.w]-p[cs.p];
      auto t=p[i]-p[cs.w];
      if(cs.p&&acos(dot(f,t)/abs(f)/abs(t))*90>th*acos(0))continue;
      que.push({i,cs.w,cs.n+1,cs.d+abs(t)});
    }
  }
  cout<<m<<endl;
}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:37:14: error: 'class std::priority_queue<S>' has no member named 'mepty'; did you mean 'empty'?
   37 |   while(!que.mepty()){
      |              ^~~~~
      |              empty
a.cc:41:28: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
   41 |     if(mem[cs.w][cs.p][cs.n]++)continue;
      |        ~~~~~~~~~~~~~~~~~~~~^
Language: C++

#include<iostream>
#include<complex>
#include<queue>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
typedef complex<double> P;
 
struct S{
  int w,p,n;
  double d;
  bool operator<(S s)const{
    return d>s.d;
  }
};

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const long double PI = 3.14159255358979323846264338327950288l;
int n; long long r, s;
struct Point { long double px, py; };
long double theta(long double a, long double b, long double c) {
	long double s = (a + b + c) / 2.0l;
	long double S = sqrtl(s*(s - a)*(s - b)*(s - c));
	long double A = -1000, B = -1000, C = -1000, H;

	if (a > b && a > c) { H = 2.0l * S / a; B = asin(H / c)*180.0l / PI; C = asin(H / b)*180.0l / PI; A = 180.0l - B - C; }
	else if (b > a && b > c) { H = 2.0l * S / b; A = asin(H / c)*180.0l / PI; C = asin(H / a)*180.0l / PI; B = 180.0l - A - C; }
	else { H = 2.0l * S / c; A = asin(H / b)*180.0l / PI; B = asin(H / a)*180.0l / PI; C = 180.0l - A - B; }

	return A;
}
long double theta_(Point a, Point b, Point c) {
	//a->b->c
	long double A1 = sqrtl((a.px - c.px)*(a.px - c.px) + (a.py - c.py)*(a.py - c.py));
	long double B1 = sqrtl((a.px - b.px)*(a.px - b.px) + (a.py - b.py)*(a.py - b.py));
	long double C1 = sqrtl((b.px - c.px)*(b.px - c.px) + (b.py - c.py)*(b.py - c.py));
	return theta(A1, B1, C1);
}
long double dp[20000][30][30], r, t; Point x[30]; int n;
int main() {
	cin >> n >> r >> t;
	for (int i = 0; i < n; i++)cin >> x[i].px >> x[i].py;
	for (int i = 0; i < 20000; i++) { for (int j = 0; j < 30; j++) { for (int k = 0; k < 30; k++) { dp[i][j][k] = 999999999.9l; } } }
	for (int i = 0; i < 20000; i++) { dp[1][0][i] = sqrtl((x[0].px - x[i].px)*(x[0].px - x[i].px) + (x[0].py - x[i].py)*(x[0].py - x[i].py)); }
	for (int i = 1; i < 15000; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				for (int l = 0; l < n; l++) {
					if (j == k || k == l)continue;
					long double T = theta_(x[j], x[k], x[l]);
					long double dst = sqrtl((x[k].px - x[l].px)*(x[k].px - x[l].px) + (x[k].py - x[l].py)*(x[k].py - x[l].py));
					dp[i + 1][k][l] = min(dp[i + 1][k][l], dp[i][j][k] + dst);
				}
			}
		}
	}
	int maxn = 0;
	for (int i = 0; i < 20000; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (dp[i][j][k] <= r)maxn = max(maxn, i);
			}
		}
	}
	cout << maxn << endl;
	return 0;
}

Compiler output:
a.cc:26:32: error: conflicting declaration 'long double r'
   26 | long double dp[20000][30][30], r, t; Point x[30]; int n;
      |                                ^
a.cc:6:18: note: previous declaration as 'long long int r'
    6 | int n; long long r, s;
      |                  ^
a.cc:26:55: error: redefinition of 'int n'
   26 | long double dp[20000][30][30], r, t; Point x[30]; int n;
      |                                                       ^
a.cc:6:5: note: 'int n' previously declared here
    6 | int n; long long r, s;
      |     ^
Language: C++

#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);

int main(void){
	int n,ans,i,j,k,ok;
	double r,sit;
	double x[20];
	double y[20];
	double dp[20][20]={0};//x??????y????????????
	double dpc[20][20]={0};
	double d;
	double pi=3.141592653589793238462643383279502884197;
	scanf("%d",&n);
	scanf("%lf %lf",&r,&sit);
	sit=(sit/180)*pi;
	for(i=0;i<n;i++){
		scanf("%lf %lf",&x[i],&y[i]);
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			dp[i][j]=0;
			dpc[i][j]=big;
		}
	}
	for(ans=0;;ans++){
		for(k=0;k<n;k++){
			for(i=0;i<n;i++){
				for(j=0;j<n;j++){
					if(ans!=0&&(k-i)*(i-j)==0){
						continue;
					}
					if(j-k==0){
						continue;
					}
					if(ans==0&&k!=0){
						continue;
					}
					d=abs(atan2(y[i]-y[k],x[i]-x[k])-atan2(y[k]-y[j],x[k]-x[j]));
					if(ans!=0&&min(2*pi-d,d)>sit){continue;}
					dpc[k][j]=min(dpc[k][j],dp[i][k]+hypot(x[k]-x[j],y[k]-y[j]));
				}
			}
		}
		ok=0;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				dp[i][j]=dpc[i][j];
				if(dpc[i][j]<r){
					ok=1;
				}
				dpc[i][j]=big;
			}
		}
		if(ok==0){break;}
	}
	
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:15: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
    6 | #define scanf scanf_s
      |               ^~~~~~~
a.cc:26:9: note: in expansion of macro 'scanf'
   26 |         scanf("%d",&n);
      |         ^~~~~
Language: C++

#include <iostream>
#include <cstdlib>

int main() {
  cout << rand() % (1e9 + 7) << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    5 |   cout << rand() % (1e9 + 7) << endl;
      |   ^~~~
      |   std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:5:18: error: invalid operands of types 'int' and 'double' to binary 'operator%'
    5 |   cout << rand() % (1e9 + 7) << endl;
      |           ~~~~~~ ^ ~~~~~~~~~
      |               |         |
      |               int       double
a.cc:5:33: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    5 |   cout << rand() % (1e9 + 7) << endl;
      |                                 ^~~~
      |                                 std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> P;
typedef pair<int,int> Pi;
typedef pair<double,int> Pd;
typedef pair<Pd,Pi> S;

int n;
double r,d;
P p[20];
double dp[10001][20][20];

bool check(int a,int b,int c){
  if(b==c)return 0;
  if(a==b)return 1;
  P o=p[b]-p[a],s=p[c]-p[b];
  s*=conj(o);
  return real(s/abs(s))>=cos(M_PI*d/180);
}

int cal(){
  priority_queue<S,vector<S>,greater<S> > Q;
  int ans=0;
  for(int i=0;i<=r;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<n;k++)dp[i][j][k]=1e9;
  dp[0][0][0]=0;
  Q.push(S(Pd(0,0),Pi(0,0)));
  while(!Q.empty()){
    double cs=Q.top().first.first;
    int i=Q.top().first.second;
    int j=Q.top().second.first;
    int k=Q.top().second.second;
    Q.pop();
    if(dp[i][j][k]<cs)continue;
    if(cs>r)return ans
    dp[i][j][k]=1;
    for(int l=0;l<n;l++){
      double ncs=cs+abs(p[k]-p[l]);
      if(check(j,k,l)&&ncs<=r){
	if(dp[i+1][k][l]>ncs){
	  Q.push(S(Pd(cs+abs(p[k]-p[l]),i+1),Pi(k,l)));
	  dp[i+1][k][l]=ncs;
	}
      }
    }
    ans=max(ans,i);
  }
  return ans;
}

int main(){
  cin>>n>>r>>d;
  double a,b;
  for(int i=0;i<n;i++)cin>>a>>b,p[i]=P(a,b);
  cout<<cal()<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int cal()':
a.cc:38:23: error: expected ';' before 'dp'
   38 |     if(cs>r)return ans
      |                       ^
      |                       ;
   39 |     dp[i][j][k]=1;
      |     ~~
Language: C++

#include<iostream>
#include<complex>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
typedef complex<double> P;

const double EPS=0.000000001;
const double INF=1000000;
double r,theta;

	double memo[10001][20][20];

bool is_ok(P a,P b,P c){
	P in=b-a,out=c-b;
	double dot=in.real()*out.real()+in.imag()*out.imag();
//	cout<<in<<out<<endl;
//	cout<<2.0*theta*asin(1.0)/180.0<<endl;
//	cout<<cos(90.0*theta*2.0*asin(1.0)/180.0)<<endl;
//	cout<<cos(theta*2.0*asin(1.0)/180.0)<<" "<<dot/(abs(in)*abs(out))<<endl;
	if(cos(theta)<dot/(abs(in)*abs(out))) return true;
	return false;
}

class Idx{
public:
	int num,bef,now;
	Idx(int bef,int now,int num):bef(bef),now(now),num(num){}
};

class Info{
public:
	Idx idx;
	double sum_r;
	Info(Idx idx,double sum_r):idx(idx),sum_r(sum_r){}
};

int main()
{
	int n;
	cin>>n>>r>>theta;
	vector<P> V;
	for(int i=0;i<n;i++){
		double a,b;
		cin>>a>>b;
		V.push_back(P(a,b));
	}

	for(int i=0;i<10001;i++)
		for(int j=0;j<20;j++)
			for(int k=0;k<20;k++)
				memo[i][j][k]=INF;

	memo[0][0][0]=0.0;
	int ans=0;

	bool ok[20][20][20];
	memset(ok,false,sizeof(ok));
	for(int in=0;in<n;in++){
		for(int out=0;out<n;out++){
			if(in==out) continue;
			for(int next=0;next<n;next++){
				if(in==next || out==next) continue;
//				cout<<"check "<<in<<" "<<out<<" "<<next<<endl;
				if(is_ok(V[in],V[out],V[next])){ok[in][out][next]=true;
				//cout<<"ok"<<endl;;
				}
			}
		}
	}

	for(int num=1;num<=10000;num++){
		for(int in=0;in<n;in++){
			for(int out=0;out<n;out++){
				if(memo[num-1][in][out]>r+EPS) continue;
				for(int next=0;next<n;next++){
					if((num==1 && next!=0) || ok[in][out][next]){
						if(memo[num-1][in][out]+abs(V[out]-V[next])<r+EPS){
							ans=num;
							memo[num][out][next]=memo[num-1][in][out]+abs(V[out]-V[next]);
//							cout<<in<<" "<<out<<" "<<next<<" "<<memo[num][out][next]<<" "<<num<<endl;
						}
					}
				}
			}
		}
		if(ans!=num) break;
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:60:9: error: 'memset' was not declared in this scope
   60 |         memset(ok,false,sizeof(ok));
      |         ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include<map>
  +++ |+#include <cstring>
    7 | using namespace std;
Language: C++

#include <iostream>
#include <cstdlib>
#define zmin(a,b) a=(a<b&&a>0?a:b)
using namespace std;

int gcd(int a, int b){
	return ( b == 0 ) ? a : gcd(b, a%b);
}

int main(){
	double m,n,a,b,c,d;
//	while(cin>>m>>n>>a>>b>>c>>d,m){
	cin>>m>>n>>a>>b>>c>>d;
	int x1,x2,y1,y2,s;
	if(a*d-b*c){
		x1=d*m/(a*d-b*c);
		y1=-b*m/(a*d-b*c);
		x2=-c*m/(a*d-b*c);
		y2=a*m/(a*d-b*c);
		s=abs(x1*y2-x2*y1);
	}else{
		int i,j,x,y;
		for(i=1,x=a,y=b;x||y;i++){
			x+=a;y+=b;
			x%=m;y%=n;
		}
		for(j=1,x=c,y=d;x||y;j++){
			x+=c;y+=d;
			x%=m;y%=n;
		}
		s=i*j/gcd(i,j);
	}
	cout<<(int)s-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:26: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   25 |                         x%=m;y%=n;
      |                         ~^~~
a.cc:25:26: note:   in evaluation of 'operator%=(int, double)'
a.cc:25:31: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   25 |                         x%=m;y%=n;
      |                              ~^~~
a.cc:25:31: note:   in evaluation of 'operator%=(int, double)'
a.cc:29:26: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   29 |                         x%=m;y%=n;
      |                         ~^~~
a.cc:29:26: note:   in evaluation of 'operator%=(int, double)'
a.cc:29:31: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   29 |                         x%=m;y%=n;
      |                              ~^~~
a.cc:29:31: note:   in evaluation of 'operator%=(int, double)'
Language: C++

#include <iostream>
#include <cstdlib>
#define zmin(a,b) a=(a<b&&a>0?a:b)
using namespace std;

int gcd(int a, int b){
	return ( b == 0 ) ? a : gcd(b, a%b);
}

int main(){
	double m,n,a,b,c,d;
//	while(cin>>m>>n>>a>>b>>c>>d,m){
	cin>>m>>n>>a>>b>>c>>d;
	int x1,x2,y1,y2,s;
	if(a*d-b*c){
		x1=d*m/(a*d-b*c);
		y1=-b*m/(a*d-b*c);
		x2=-c*m/(a*d-b*c);
		y2=a*m/(a*d-b*c);
		s=abs(x1*y2-x2*y1);
	}else{
		int i,j,x,y;
		for(i=1,x=a,y=b;x||y;i++){
			x+=a;y+=b;
			x=fmod(x,m);y=fmod(y,n);
		}
		for(j=1,x=c,y=d;x||y;j++){
			x+=c;y+=d;
			x=fmod(x,m);y=fmod(y,n);
		}
		s=i*j/gcd(i,j);
	}
	cout<<(int)s-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:27: error: 'fmod' was not declared in this scope
   25 |                         x=fmod(x,m);y=fmod(y,n);
      |                           ^~~~
a.cc:29:27: error: 'fmod' was not declared in this scope
   29 |                         x=fmod(x,m);y=fmod(y,n);
      |                           ^~~~
Language: C++

#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
map<pair<int, int>, int> dt;
int N, Q, cur, cs, tp[40009], a[40009], b[40009], es[40009], id[40009], seq[40009]; bool vis[40009]; vector<int> g[40009], gs[40009];
void dfs(int pos) {
	id[pos] = cur;
	for (int i : g[pos]) {
		if (id[i] == -1) dfs(i);
	}
}
void dfs2(int pos) {
	vis[pos] = true;
	seq[cs++] = pos;
	for (int i : gs[pos]) {
		if (!vis[i]) dfs2(i);
	}
}
int main() {
	scanf("%d %d", &N, &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d %d %d", &tp[i], &a[i], &b[i]);
		if (tp[i] == 1) dt[make_pair(a[i], b[i])] = i, es[i] = -1;
		if (tp[i] == 2) es[dt[make_pair(a[i], b[i])]] = i;
	}
	int B = sqrt(Q);
	for (int i = 0; i < B; i++) {
		int l = i * Q / B, r = (i + 1) * Q / B;
		for (int j = 0; j < N; j++) g[j].clear();
		for (int j = 0; j < l; j++) {
			if (tp[j] == 1 && (es[j] == -1 || es[j] >= r)) {
				g[a[j]].push_back(b[j]);
				g[b[j]].push_back(a[j]);
			}
		}
		cur = 0;
		fill(id, id + N, -1);
		for (int j = 0; j < N; j++) {
			if (id[j] == -1) {
				dfs(j);
				cur++;
			}
		}
		for (int j = 0; j < cur; j++) gs[j].clear();
		for (int j = 0; j < l; j++) {
			if (id[a[j]] != id[b[j]] && l <= es[j] && es[j] < r) {
				gs[id[a[j]]].push_back(id[b[j]]);
				gs[id[b[j]]].push_back(id[a[j]]);
			}
		}
		for (int j = l; j < r; j++) {
			if (tp[j] == 1) {
				gs[id[a[j]]].push_back(id[b[j]]);
				gs[id[b[j]]].push_back(id[a[j]]);
			}
			if (tp[j] == 2) {
				gs[id[a[j]]].erase(find(gs[id[a[j]]].begin(), gs[id[a[j]]].end(), id[b[j]]));
				gs[id[b[j]]].erase(find(gs[id[b[j]]].begin(), gs[id[b[j]]].end(), id[a[j]]));
			}
			if (tp[j] == 3) {
				cs = 0;
				dfs2(id[a[j]]);
				printf(vis[id[b[j]]] ? "YES\n" : "NO\n");
				for (int k = 0; k < cs; k++) vis[seq[k]] = false;
			}
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:52: error: 'find' was not declared in this scope
   61 |                                 gs[id[a[j]]].erase(find(gs[id[a[j]]].begin(), gs[id[a[j]]].end(), id[b[j]]));
      |                                                    ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

long solve(){
  int n;
  cin>>n;
  long ret=0;
  vector<long> h(n+1), a(n+1), d(n+1), s(n+1), t(n+1);
  rep(i,n+1) cin>>h[i]>>a[i]>>d[i]>>s[i];

  repl(i,1,n+1){
    long tmp = a[0]-d[i];
    if(tmp<0){
      if(a[i]>d[0]) return -1;
      else tmp=1;
    }
    t[i] = (h[i]+tmp-1)/tmp;
  }

  // ?????´?????? ????????¬??????????????????
  repl(i,1,n+1)if(s[0]>s[i]){
    h[0] += max(a[i]-d[0], 0L);
    ret -= max(a[i]-d[0], 0L);
  }

  vector<int> vec(n);
  rep(i,n) vec[i]=i+1;

  sort(all(vec), [&](int i, int j){
    long ia = max(a[i]-d[0],0L);
    long ja = max(a[j]-d[0],0L);
    return ia*t[j] > ja*t[i];
  });

  long acctime = 0;
  rep(i,n){
    int id = vec[i];
    acctime += t[id];
    h[0] -= max(a[id]-d[0],0L) * acctime;
    ret += max(a[id]-d[0],0L) * acctime;
    if(h[0]<=0) return -1;
  }

  else return ret;
}

int main(){
  cout<<solve()<<endl;

  return 0;
}

Compiler output:
a.cc: In function 'long int solve()':
a.cc:57:3: error: 'else' without a previous 'if'
   57 |   else return ret;
      |   ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

const int MAX_N = 16;
const int MAX_M = 16;
const double EPS = 1e-10;

double dp[1<<MAX_M][MAX_N];

double prob[MAX_M][MAX_N];
int M, N;

double dfs(int b, int x){
  if(x == N) return 1.0;
  if(b == (1<<M)-1){
    return 0.0;
  }
  if(dp[b][x] - -1 < EPS) return dp[b][x];
  //cout << b << " " << x << " " << M << " " << N << endl;  
  double ret = 0; 
  for(int i=0;i<M;i++){
    if(b&(1<<i)) continue;
    double p = 0.0;
    double tmpp = 1.0;
    for(int j=x;j<N;j++){
      p += tmpp * (1 - prob[i][j]) * dfs(b | (1<<i), j);
      //cout << p << endl;
      //cout << "tmpp: " << tmpp << " prob[i][j]: " << prob[i][j] << endl;      
      tmpp *= prob[i][j];
    }
    p += tmpp * dfs(b | (1<<i), N);
    ret = max(ret, p);
  }
  dp[b][x] = ret;
  return ret;
}

int main(){
  scanf("%d%d", &M, &N);
  memset(dp, -1, sizeof(dp));
  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      scanf("%lf", &prob[i][j]);
    }
  }

  printf("%0.12lf\n", dfs(0, 0));
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:43:3: error: 'memset' was not declared in this scope
   43 |   memset(dp, -1, sizeof(dp));
      |   ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cstdio>
  +++ |+#include <cstring>
    4 |
Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

class HashVI {  // ???????????\??¢??°???????????§??????
public:
	size_t operator()(pair<int,vector<int>> x) const {
		size_t t = x.first;
		t *= 16;
		
		for (int i = 0; i < x.second.size(); ++i) {
			t += x.second[i];
			t *= 2;
		}
		return t;
		
	}
	size_t operator()(const vector<vector<int>> &x) const {
		const int C = 997;      // ?´???°
		size_t t = 0;
		for (int i = 0; i != x.size(); ++i) {
			for (int j = 0; j < x[i].size(); ++j) {
				t = t * C + x[i][j];
			}
		}
		return t;
	}
};
vector<vector<ld>>pers;
unordered_map<pair<int,vector<int>>, ld, HashVI>memo;
int M, N;
ld check(const int now,vector<int>&lives) {
	if (memo.find(make_pair(now, lives))!=memo.end()) {
		return memo[make_pair(now, lives)];
	}
	else {
		ld amax = 0;
		for (int i = 0; i < lives.size(); ++i) {
			if (lives[i]) {
				lives[i] = false;
				ld per = 0;
				ld living = 1;
				for (int enemy = now; enemy < N; ++enemy) {
					per += living*(1 - pers[i][enemy])*check(enemy,lives);
					living *= pers[i][enemy];
				}
				per += living;
				amax = max(amax, per);
				lives[i] = true;
			}
		}
		return memo[make_pair(now, lives)]=amax;
	}

}

int main() {cin >> M >> N;
	pers.resize(M);
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < N; ++j) {
			ld p; cin >> p;
			pers[i].push_back(p);
		}
	}
	ld ans = check(0, vector<int>(M, true));
	cout << fixed << setprecision(22) << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:27: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
   70 |         ld ans = check(0, vector<int>(M, true));
      |                           ^~~~~~~~~~~~~~~~~~~~
a.cc:37:36: note:   initializing argument 2 of 'ld check(int, std::vector<int>&)'
   37 | ld check(const int now,vector<int>&lives) {
      |                        ~~~~~~~~~~~~^~~~~
Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

class HashVI {  // ???????????\??¢??°???????????§??????
public:
	size_t operator()(pair<int,vector<int>> x) const {
		size_t t = x.first;
		t *= 16;
		
		for (int i = 0; i < x.second.size(); ++i) {
			t += x.second[i];
			t *= 2;
		}
		return t;
		
	}
	size_t operator()(const vector<vector<int>> &x) const {
		const int C = 997;      // ?´???°
		size_t t = 0;
		for (int i = 0; i != x.size(); ++i) {
			for (int j = 0; j < x[i].size(); ++j) {
				t = t * C + x[i][j];
			}
		}
		return t;
	}
};
vector<vector<ld>>pers;
unordered_map<pair<int,vector<int>>, ld, HashVI>memo;
int M, N;
ld check(const int now,vector<int>&lives) {
	if (memo.find(make_pair(now, lives))!=memo.end()) {
		return memo[make_pair(now, lives)];
	}
	else {
		ld amax = 0;
		for (int i = 0; i < lives.size(); ++i) {
			if (lives[i]) {
				lives[i] = false;
				ld per = 0;
				ld living = 1;
				for (int enemy = now; enemy < N; ++enemy) {
					per += living*(1 - pers[i][enemy])*check(enemy,lives);
					living *= pers[i][enemy];
				}
				per += living;
				amax = max(amax, per);
				lives[i] = true;
			}
		}
		return memo[make_pair(now, lives)]=amax;
	}

}

int main() {cin >> M >> N;
	pers.resize(M);
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < N; ++j) {
			ld p; cin >> p;
			pers[i].push_back(p);
		}
	}
	ld ans = check(0, vector<int>(M, 1));
	cout << fixed << setprecision(22) << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:27: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
   70 |         ld ans = check(0, vector<int>(M, 1));
      |                           ^~~~~~~~~~~~~~~~~
a.cc:37:36: note:   initializing argument 2 of 'ld check(int, std::vector<int>&)'
   37 | ld check(const int now,vector<int>&lives) {
      |                        ~~~~~~~~~~~~^~~~~
Language: C++

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

int n;
int m;
double dp[17][(1 << 16) + 1];
double P[17][17];

int main() {
  scanf("%d%d", &m, &n);
  for (int i=0; i<m; i++) {
    for (int j=0; j<n; j++) {
      scanf("%lf", &P[i][j]);
    }
  }

  int lim = 1 << m;
  for (int i=n-1; i>=0; --i) {
    for (int st=0; st<lim; ++st) {
      if(st) dp[n][st] = 1.0;
      for (int j=0; j<m; j++) {
        if (!(st >> j & 1)) continue;
        double p = 1.0;
        double cand = 0.0;
        int nst = st & ~(1 << j);
        cand += dp[k][nst]*(1-P[j][i]);
        cand += dp[k+1][st]*P[j][i];
        dp[i][st] = max(dp[i][st], cand);
      }
    }
  }
  printf("%.20f\n", dp[0][lim-1]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:20: error: 'k' was not declared in this scope
   26 |         cand += dp[k][nst]*(1-P[j][i]);
      |                    ^
Language: C++

#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef float double;

real dp[17][17][1 << 16];
int n, m;
real p[17][17];
real solve(int stage, int now, int cats){
	real &res = dp[stage][now][cats];
	if(res != -1)return res;
	res = 0;
	if((1<<now) & cats)return res;
	if(stage == n)return res = 1;
	
	if(now == 16){
		for(int i = 0;i < m;i++){
			res = max(res, solve(stage, i, cats));
		}
	}
	else{
		res = solve(stage+1, now, cats) * p[now][stage]
			+ solve(stage, 16, cats | (1<<now)) * (1 - p[now][stage]);
	}
	return res;
}

int main(){
	cin >> m >> n;
	for(int i = 0;i < m;i++){
		for(int j = 0;j < n;j++){
			cin >> p[i][j];
		}
	}
	for(int i = 0;i < 17;i++)
		for(int j = 0;j < 17;j++)
			for(int k = 0;k < (1<<17);k++)
				dp[i][j][k] = -1;

	printf("%.10lf\n", solve(0, 16, 0));
	return 0;
}


Compiler output:
a.cc:5:9: error: multiple types in one declaration
    5 | typedef float double;
      |         ^~~~~
a.cc:5:15: error: declaration does not declare anything [-fpermissive]
    5 | typedef float double;
      |               ^~~~~~
a.cc:7:1: error: 'real' does not name a type
    7 | real dp[17][17][1 << 16];
      | ^~~~
a.cc:9:1: error: 'real' does not name a type
    9 | real p[17][17];
      | ^~~~
a.cc:10:1: error: 'real' does not name a type
   10 | real solve(int stage, int now, int cats){
      | ^~~~
a.cc: In function 'int main()':
a.cc:33:32: error: 'p' was not declared in this scope
   33 |                         cin >> p[i][j];
      |                                ^
a.cc:39:33: error: 'dp' was not declared in this scope
   39 |                                 dp[i][j][k] = -1;
      |                                 ^~
a.cc:41:28: error: 'solve' was not declared in this scope
   41 |         printf("%.10lf\n", solve(0, 16, 0));
      |                            ^~~~~
Language: Java

import java.util.*;

public class main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long p = sc.nextLong();
		long q = sc.nextLong();
		long INF = 1000_000_000_000_000L;
		if (a == 1 && b == 1) {
			// (p+q)N
			long ans = INF;
			long div = m / (p + q);
			div = Math.min(div, n);
			ans = Math.min(ans, Math.abs(div * (p + q) - m));
			div = Math.min(div + 1, n);
			ans = Math.min(ans, Math.abs(div * (p + q) - m));
			System.out.println(ans);
			return;
		}
		// pa^k+qb^k
		long lim = 0;
		while (p * Math.pow(a, lim) + q * Math.pow(b, lim) <= m) {
			++lim;
		}
		lim += 1;
		lim = Math.min(lim, n);
		lim = Math.min(lim, 40);
		ArrayList<Long> pending1 = new ArrayList<>();
		ArrayList<Long> pending2 = new ArrayList<>();
		long[] powA = new long[42];
		long[] powB = new long[42];
		powA[0] = 1;
		powB[0] = 1;
		for (int i = 1; i < powA.length; ++i) {
			powA[i] = powA[i - 1] * a;
			powB[i] = powB[i - 1] * b;
		}
		for (int t = 0; t < 2; ++t) {
			long max = (t == 0 ? lim / 2 : (lim + 1) / 2);
			outer: for (long i = 0; i < (1L << max); ++i) {
				long s = 0;
				for (int j = 0; j < max; ++j) {
					if ((i & (1L << j)) > 0) {
						s += p * powA[(int) (j + (t == 1 ? lim / 2 : 0))]
								+ q * powB[(int) (j + (t == 1 ? lim / 2 : 0))];
						if (s > INF)
							continue outer;
					}
				}
				if (t == 0)
					pending1.add(s);
				else
					pending2.add(s);
			}
		}

		Collections.sort(pending1);
		Collections.sort(pending2);

		long ans = m;
		for (int j = 0; j < 2; ++j) {
			int t = pending2.size() - 1;
			for (int i = 0; i < pending1.size(); ++i) {
				if (j == 0)
					while (t > 0 && pending1.get(i) + pending2.get(t) > m)
						--t;
				else if (j == 1)
					while (t > 0 && pending1.get(i) + pending2.get(t) >= m
							&& pending1.get(i) + pending2.get(t - 1) >= m)
						--t;
				ans = Math.min(ans, Math.abs(-m + pending1.get(i) + pending2.get(t)));
			}
		}

		System.out.println(ans);

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	static long pow(long a, long n) {
		long ret = 1;
		for (; n > 0; n >>= 1, a *= a) {
			if (n % 2 == 1) {
				ret *= a;
			}
		}
		return ret;
	}
}

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

import java.util.*;

public class main {
	public static void Main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long p = sc.nextLong();
		long q = sc.nextLong();
		long INF = 1000_000_000_000_000L;
		if (a == 1 && b == 1) {
			// (p+q)N
			long ans = INF;
			long div = m / (p + q);
			div = Math.min(div, n);
			ans = Math.min(ans, Math.abs(div * (p + q) - m));
			div = Math.min(div + 1, n);
			ans = Math.min(ans, Math.abs(div * (p + q) - m));
			System.out.println(ans);
			return;
		}
		// pa^k+qb^k
		long lim = 0;
		while (p * Math.pow(a, lim) + q * Math.pow(b, lim) <= m) {
			++lim;
		}
		lim += 1;
		lim = Math.min(lim, n);
		lim = Math.min(lim, 40);
		ArrayList<Long> pending1 = new ArrayList<>();
		ArrayList<Long> pending2 = new ArrayList<>();
		long[] powA = new long[42];
		long[] powB = new long[42];
		powA[0] = 1;
		powB[0] = 1;
		for (int i = 1; i < powA.length; ++i) {
			powA[i] = powA[i - 1] * a;
			powB[i] = powB[i - 1] * b;
		}
		for (int t = 0; t < 2; ++t) {
			long max = (t == 0 ? lim / 2 : (lim + 1) / 2);
			outer: for (long i = 0; i < (1L << max); ++i) {
				long s = 0;
				for (int j = 0; j < max; ++j) {
					if ((i & (1L << j)) > 0) {
						s += p * powA[(int) (j + (t == 1 ? lim / 2 : 0))]
								+ q * powB[(int) (j + (t == 1 ? lim / 2 : 0))];
						if (s > INF)
							continue outer;
					}
				}
				if (t == 0)
					pending1.add(s);
				else
					pending2.add(s);
			}
		}

		Collections.sort(pending1);
		Collections.sort(pending2);

		long ans = m;
		for (int j = 0; j < 2; ++j) {
			int t = pending2.size() - 1;
			for (int i = 0; i < pending1.size(); ++i) {
				if (j == 0)
					while (t > 0 && pending1.get(i) + pending2.get(t) > m)
						--t;
				else if (j == 1)
					while (t > 0 && pending1.get(i) + pending2.get(t) >= m
							&& pending1.get(i) + pending2.get(t - 1) >= m)
						--t;
				ans = Math.min(ans, Math.abs(-m + pending1.get(i) + pending2.get(t)));
			}
		}

		System.out.println(ans);

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	static long pow(long a, long n) {
		long ret = 1;
		for (; n > 0; n >>= 1, a *= a) {
			if (n % 2 == 1) {
				ret *= a;
			}
		}
		return ret;
	}
}

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

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long p = sc.nextLong();
		long q = sc.nextLong();
		long INF = 1000_000_000_000_000L;
		if (a == 1 && b == 1) {
			// (p+q)N
			long ans = INF;
			long div = m / (p + q);
			div = Math.min(div, n);
			ans = Math.min(ans, Math.abs(div * (p + q) - m));
			div = Math.min(div + 1, n);
			ans = Math.min(ans, Math.abs(div * (p + q) - m));
			System.out.println(ans);
			return;
		}
		// pa^k+qb^k
		long lim = 0;
		while (p * Math.pow(a, lim) + q * Math.pow(b, lim) <= INF) {
			++lim;
		}
		lim = Math.min(lim, n);
		lim = Math.min(lim, 41);
		ArrayList<Long> pending1 = new ArrayList<>();
		ArrayList<Long> pending2 = new ArrayList<>();
		for (int t = 0; t < 2; ++t) {
			long max = (t == 0 ? lim / 2 : (lim + 1) / 2);
			outer: for (long i = 0; i < (1L << max); ++i) {
				long s = 0;
				for (int j = 0; j < 20; ++j) {
					if ((i & (1L << j)) > 0) {
						s += p * Math.pow(a, j + (t == 1 ? lim / 2 : 0)) + q * Math.pow(b, j + (t == 1 ? lim / 2 : 0));
						if (s > INF)
							continue outer;
					}
				}
				if (t == 0)
					pending1.add(s);
				else
					pending2.add(s);
			}
		}

		Collections.sort(pending1);
		Collections.sort(pending2);

		long ans = m;
		for (int j = 0; j < 2; ++j) {
			int t = pending2.size() - 1;
			for (int i = 0; i < pending1.size(); ++i) {
				if (j == 0)
					while (t > 0 && pending1.get(i) + pending2.get(t) > m)
						--t;
				else if (j == 1)
					while (t > 0 && pending1.get(i) + pending2.get(t) >= m
							&& pending1.get(i) + pending2.get(t - 1) >= m)
						--t;
				ans = Math.min(ans, Math.abs(-m + pending1.get(i) + pending2.get(t)));
			}
		}

		System.out.println(ans);

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
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<iostream>
#include<vector>
using namespace std;

typedef long long ll;

int main(){
	ll n,m,a,b,p,q;
	cin >> n >> m >> a >> b >> p >> q;
	
	if(a == 1 && b == 1){
		cout << max( m%(p+q) , m-(p+q)*n ) << endl;
	}
	else {
		vector<ll> vec;
		ll s = 1 , t = 1;
		for(int i = 0 ; i < n ; i ++){
			if(p*s+q*t > m)break;
			vec.push_back(p*s+q*t);
			s *= a;
			t *= b;
		}
		int N = vec.size();
		vector<ll> A,B;
		A.push_back(0);
		for(int i = 0 ; i < N/2 ; i ++){
			int x = A.size();
			for(int j = 0 ; j < x ; j ++){
				A.push_back(vec[i]+A[j]);
			}
		}
		B.push_back(0);
		for(int i = N/2 ; i < N ; i ++){
			int x = B.size();
			for(int j = 0 ; j < x ; j ++){
				B.push_back(vec[i]+B[j]);
			}
		}
		sort(B.begin(),B.end());
		ll ret = m;
		for(int i = 0 ; i < A.size() ; i ++){
			int x = upper_bound(B.begin(),B.end(),m-A[i])-B.begin();
			x --;
			ret = min ( ret , m-A[i]-B[x] );
		}
		cout << ret << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   39 |                 sort(B.begin(),B.end());
      |                 ^~~~
      |                 short
a.cc:42:33: error: 'upper_bound' was not declared in this scope
   42 |                         int x = upper_bound(B.begin(),B.end(),m-A[i])-B.begin();
      |                                 ^~~~~~~~~~~