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

#include <cstdio>
#include <vector>

const int kMaxTurn = 64; //1????????????1??\??????????????§, 50???????????\??????????????????.
const int kMaxSquare = 64;

int roulette[4];

typedef struct{
	int type;
	int value;
} BoardState;

BoardState board[51];

typedef struct{
	float prob;
	int money;
} BpState;

int bp(int X, int Y){
	std::vector<BpState> bp[kMaxTurn][kMaxSquare];
	float prob = 1.0f / (float)X;

	bp[0][0].push_back({ 1.0f, 0 });

	for (int t = 0; t < Y; t++){
		for (int n = 0; n < Y; n++){
			if (bp[t][n].size() == 0) continue;
			for (int k = 0; k < X; k++){
				int pos = (n + roulette[k] < Y) ? n + roulette[k] : Y;
				switch (board[pos].type){
				case 0:
					for (int i = 0; i < bp[t][n].size(); i++)
						bp[t + 1][pos].push_back({ bp[t][n].at(i).prob * prob, bp[t][n].at(i).money });
					break;
				case 1:
					for (int i = 0; i < bp[t][n].size(); i++)
						bp[t + 1][pos + board[pos].value].push_back({ bp[t][n].at(i).prob * prob, bp[t][n].at(i).money });
					break;
				case 2:
					for (int i = 0; i < bp[t][n].size(); i++)
						bp[t + 1][pos].push_back({ bp[t][n].at(i).prob * prob, bp[t][n].at(i).money + board[pos].value });
					break;
				case 3:
					for (int i = 0; i < bp[t][n].size(); i++)
					bp[t + 1][pos].push_back({ bp[t][n].at(i).prob * prob, 
						(bp[t][n].at(i).money - board[pos].value >= 0) ? bp[t][n].at(i).money - board[pos].value : 0 });
				default:
					break;
				}
			}
		}
	}

	float res = 0.0f;
	for (int i = 1; i <= Y; i++)
		for (int j = 0; j < bp[i][Y].size(); j++)
			res += bp[i][Y].at(j).prob * (float)bp[i][Y].at(j).money;
	return (int)res;
}

int main(){
	while (1){
		int X, Y, Z; //X:????????¬?????????????????°, Y: ??????????????°(???: ????????????), Z: ???????????????????????°
		scanf_s("%d %d %d", &X, &Y, &Z);
		if (X == 0) return 0;
		for (int i = 0; i < X; i++)
			scanf_s("%d", &roulette[i]);
		for (int i = 0; i < 51; i++)
			board[i] = { 0, 0 };
		for (; Z > 0; Z--){
			int N, E, A; //N: ?????????, E: ??????????¨????, A: ??????????????§????????° or ?¢????????????????
			scanf_s("%d %d %d", &N, &E, &A);
			board[N] = { E, A };
		}
		printf("%d\n", bp(X, Y));
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   66 |                 scanf_s("%d %d %d", &X, &Y, &Z);
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include <cstdio>
#include <map>

#define scanf scanf_s

const int kMaxSquare = 64;

int roulette[4];

typedef struct{
	int type;
	int value;
} BoardState;

BoardState board[kMaxSquare];

int bp(int X, int Y){
	std::map<int, double> bp[kMaxSquare];
	double prob = 1.0f / static_cast<double>(X);

	bp[0][0] = 1.0f;
	for (int n = 0; n < Y; n++){
		for (std::map<int, double>::iterator it = bp[n].begin(); it != bp[n].end(); it++){
			for (int k = 0; k < X; k++){
				int pos = (n + roulette[k] < Y) ? n + roulette[k] : Y;
				switch (board[pos].type){
				case 0:
					bp[pos][it->first] += it->second * prob;
					break;
				case 1:
					bp[(pos + board[pos].value > Y) ? pos + board[pos].value : Y][it->first] 
						+= it->second * prob;
					break;
				case 2:
					bp[pos][it->first + board[pos].value] += it->second * prob;
					break;
				case 3:
					bp[pos][(it->first - board[pos].value > 0) ? it->first - board[pos].value : 0] 
						+= it->second * prob;
				default:
					break;
				}
			}
		}
	}

	double res = 0.0f;
	for (std::map<int, double>::iterator it = bp[Y].begin(); it != bp[Y].end(); it++)
		res += static_cast<double>(it->first) * it->second;
	return static_cast<int>(res);
}

int main(){
	while (1){
		int X, Y, Z; //X:????????¬?????????????????°, Y: ??????????????°(???: ????????????), Z: ???????????????????????°
		scanf("%d %d %d", &X, &Y, &Z);
		if (X == 0) return 0;
		for (int i = 0; i < X; i++)
			scanf("%d", &roulette[i]);
		for (int i = 0; i < kMaxSquare; i++)
			board[i] = { 0, 0 };
		for (; Z > 0; Z--){
			int N, E, A; //N: ?????????, E: ??????????¨????, A: ??????????????§????????° or ?¢????????????????
			scanf("%d %d %d", &N, &E, &A);
			board[N] = { E, A };
		}
		printf("%d\n", bp(X, Y));
	}
}

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

#include <cstdio>
#include <algorithm>

//#define scanf scanf_s

const int kMaxSquare = 64;
const int kMaxMoney = 5100;
const int kMaxGainMoney = 100;

int roulette[4];

typedef struct{
	int type;
	int value;
} BoardState;

BoardState board[kMaxSquare];

int bp(int X, int Y){
	float bp[kMaxSquare][kMaxMoney];
	float prob = 1.0f / static_cast<float>(X);

	bp[0][0] = 1.0f;
	for (int n = 0; n < Y; n++){
    for (int m = 0; m <= kMaxGainMoney * n; m++){
      if(bp[n][m] == 0.0f) continue;
			for (int k = 0; k < X; k++){
        int pos = min(n+roulette[k], Y);
				if (board[pos].type == 1)
					bp[min(pos + board[pos].value, Y)][m] += bp[n][m] * prob;
				else if (board[pos].type == 2)
					bp[pos][m + board[pos].value] += bp[n][m]* prob;
				else if (board[pos].type == 3)
					bp[pos][max(m - board[pos].value, 0)] += bp[n][m] * prob;
				else
					bp[pos][m] += bp[n][m] * prob;
			}
		}
	}

	float res = 0.0f;
  for (int m = 0; m <= Y * kMaxGainMoney; m++)
		res += static_cast<float>(m) * bp[Y][m];
	return static_cast<int>(res);
}

int main(){
	while (1){
		int X, Y, Z;
		scanf("%d %d %d", &X, &Y, &Z);
		if (X == 0) return 0;
		for (int i = 0; i < X; i++)
			scanf("%d", &roulette[i]);
		for (int i = 0; i < kMaxSquare; i++)
			board[i] = { 0, 0 };
		for (; Z > 0; Z--){
			int N, E, A;
			scanf("%d %d %d", &N, &E, &A);
			board[N] = { E, A };
		}
		printf("%d\n", bp(X, Y));
	}
}

Compiler output:
a.cc: In function 'int bp(int, int)':
a.cc:28:19: error: 'min' was not declared in this scope; did you mean 'std::min'?
   28 |         int pos = min(n+roulette[k], Y);
      |                   ^~~
      |                   std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:34:49: error: 'max' was not declared in this scope; did you mean 'std::max'?
   34 |                                         bp[pos][max(m - board[pos].value, 0)] += bp[n][m] * prob;
      |                                                 ^~~
      |                                                 std::max
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

#include <cstdio>
#include <algorithm>

//#define scanf scanf_s

const int kMaxSquare = 64;
const int kMaxMoney = 5100;
const int kMaxGainMoney = 100;

int roulette[4];

typedef struct{
	int type;
	int value;
} BoardState;

BoardState board[kMaxSquare];

int bp(int X, int Y){
	float bp[kMaxSquare][kMaxMoney];
	float prob = 1.0f / static_cast<float>(X);

  for(int n = 0; n <= X; n++)
    for(int m = 0; m <= Y*kMaxGainMOney; m++)
      pb[n][m] = 0.0f;

	bp[0][0] = 1.0f;
	for (int n = 0; n < Y; n++){
    for (int m = 0; m <= kMaxGainMoney * n; m++){
      if(bp[n][m] == 0.0f) continue;
			for (int k = 0; k < X; k++){
        int pos = std::min(n+roulette[k], Y);
				if (board[pos].type == 1)
          bp[std::min(pos + board[pos].value, Y)][m] += bp[n][m] * prob;
				else if (board[pos].type == 2)
					bp[pos][m + board[pos].value] += bp[n][m]* prob;
				else if (board[pos].type == 3)
          bp[pos][std::max(m - board[pos].value, 0)] += bp[n][m] * prob;
				else
					bp[pos][m] += bp[n][m] * prob;
			}
		}
	}

	float res = 0.0f;
  for (int m = 0; m <= Y * kMaxGainMoney; m++)
		res += static_cast<float>(m) * bp[Y][m];
	return static_cast<int>(res);
}

int main(){
	while (1){
		int X, Y, Z;
		scanf("%d %d %d", &X, &Y, &Z);
		if (X == 0) return 0;
		for (int i = 0; i < X; i++)
			scanf("%d", &roulette[i]);
		for (int i = 0; i < kMaxSquare; i++)
			board[i] = { 0, 0 };
		for (; Z > 0; Z--){
			int N, E, A;
			scanf("%d %d %d", &N, &E, &A);
			board[N] = { E, A };
		}
		printf("%d\n", bp(X, Y));
	}
}

Compiler output:
a.cc:25:23: error: stray '\23' in program
   25 |       pb[n][m] = 0.0f;<U+0013>
      |                       ^~~~~~~~
a.cc: In function 'int bp(int, int)':
a.cc:24:27: error: 'kMaxGainMOney' was not declared in this scope; did you mean 'kMaxGainMoney'?
   24 |     for(int m = 0; m <= Y*kMaxGainMOney; m++)
      |                           ^~~~~~~~~~~~~
      |                           kMaxGainMoney
a.cc:25:7: error: 'pb' was not declared in this scope; did you mean 'bp'?
   25 |       pb[n][m] = 0.0f;
      |       ^~
      |       bp
Language: C++

#include <cstdio>
#include <algorithm>

//#define scanf scanf_s

const int kMaxSquare = 64;
const int kMaxMoney = 5100;
const int kMaxGainMoney = 100;

int roulette[4];

typedef struct{
	int type;
	int value;
} BoardState;

BoardState board[kMaxSquare];

int bp(int X, int Y){
	float bp[kMaxSquare][kMaxMoney];
	float prob = 1.0f / static_cast<float>(X);

  for(int n = 0; n <= X; n++)
    for(int m = 0; m <= Y*kMaxGainMoney; m++)
      bp[n][m] = 0.0f;

	bp[0][0] = 1.0f;
	for (int n = 0; n < Y; n++){
    for (int m = 0; m <= kMaxGainMoney * n; m++){
      if(bp[n][m] == 0.0f) continue;
			for (int k = 0; k < X; k++){
        int pos = std::min(n+roulette[k], Y);
				if (board[pos].type == 1)
          bp[std::min(pos + board[pos].value, Y)][m] += bp[n][m] * prob;
				else if (board[pos].type == 2)
					bp[pos][m + board[pos].value] += bp[n][m]* prob;
				else if (board[pos].type == 3)
          bp[pos][std::max(m - board[pos].value, 0)] += bp[n][m] * prob;
				else
					bp[pos][m] += bp[n][m] * prob;
			}
		}
	}

	float res = 0.0f;
  for (int m = 0; m <= Y * kMaxGainMoney; m++)
		res += static_cast<float>(m) * bp[Y][m];
	return static_cast<int>(res);
}

int main(){
	while (1){
		int X, Y, Z;
		scanf("%d %d %d", &X, &Y, &Z);
		if (X == 0) return 0;
		for (int i = 0; i < X; i++)
			scanf("%d", &roulette[i]);
		for (int i = 0; i < kMaxSquare; i++)
			board[i] = { 0, 0 };
		for (; Z > 0; Z--){
			int N, E, A;
			scanf("%d %d %d", &N, &E, &A);
			board[N] = { E, A };
		}
		printf("%d\n", bp(X, Y));
	}
}

Compiler output:
a.cc:25:23: error: stray '\23' in program
   25 |       bp[n][m] = 0.0f;<U+0013>
      |                       ^~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100
#define MMAX 5001
int X, Y, Z, A[MAX], V[MAX], E[MAX];
void compute() {
	float P[MMAX][MAX];
	for (int i = 0; i < MMAX; i++) {
		for (int j = 0; j <= Y; j++)
			P[i][j] = 0;
	}
	P[0][0] = 1.0;
	int np, nv;
	for (int j = 0; j < Y; j++) {
		for (int i = 0; i < MMAX; i++) {
			if (P[i][j] == 0)
				continue;
			for (int k = 0; k < X; k++) {
				np = min(Y, j + V[k]);
				nv = i;
				if (E[np] == 1) {
					np = min(Y, np + A[np]);
				} else if (E[np] == 2) {
					nv = i + A[np];
				} else if (E[np] == 3) {
					nv = max(0, i - A[np]);
				}
				P[nv][np] += P[i][j] * (1.0 / X);
			}
		}
	}
	double ex = 0;
	for (int i = 0; i < MMAX; i++)
		ex += P[i][Y] * i;
	cout << (int) ex << endl;
}
void main() {
	int n, e, a;
	while(1) {
		cin >> X >> Y >> Z;
		if ( X == 0 && Y == 0 && Z == 0 ) break;
		for ( int i = 0; i <= Y; i++ ) A[i] = E[i] = 0;
		for ( int i = 0; i < X; i++ ) cin >> V[i];
		for ( int i = 0; i < Z; i++ ) {
			cin >> n >> e >> a;
			A[n] = a;
			E[n] = e;
		}
		compute();
	}
	return 0;
}

Compiler output:
a.cc:38:1: error: '::main' must return 'int'
   38 | void main() {
      | ^~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
typedef long long ll;
enum {GO=1,GET=2,LOST=3};
/*
  [bgÍ4íÞ
  }XÌy <= 50
  50 * 50 * (100*50) * 4
  dp[ith][jth turn][syojikin] = p^[
*/
const int N = 53;
const int M = 5001;
ll dp[N][2][M];
//event,eventvalue
//¡ñæÌ}XÉiÞ±ÆÍÈ¢Æ¼è·éB
double solve(int n,int X,int *rt,int *event,int *eval,int sum){
  rep(i,n+1)rep(j,2)rep(k,M)dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  double prob = 1/(double)X;
  double ret = 0;
  rep(j,n+1){//turn
    bool isupd=false;
    rep(i,n){//pos
      rep(k,sum+1){//money
	if (dp[i][0][k] == 0)continue;
	rep(l,X){
	  int next = i + rt[l];
	  int nextm=k;
	  while(next < n && event[next] == 1)next += eval[next];
	  if (next < n){
	    if (event[next] == 2){
	      nextm += eval[next];
	    }else if (event[next] == 3){
	      nextm -= eval[next];
	    }
	  }
	  next = min(next,n);
	  nextm= max(0,nextm);
	  isupd=true;
	  dp[next][1][nextm] += dp[i][0][k];
	}
      }
    }
    rep(k,sum+1){
      ret += (dp[n][1][k]*prob)* k;
   }
    prob *= (1/(double)X);
    rep(i,n)rep(k,sum+1){
      dp[i][0][k] = dp[i][1][k];
      dp[i][1][k] = 0;
    }
    rep(k,sum+1)dp[n][0][k] = 0,dp[n][1][k] = 0;
    //if (!isupd)break;
  }
  return ret;
}

main(){
  int X,n,z;
  while(cin>>X>>n>>z && X){
    int event[n],eval[n],rt[X];
    rep(i,n)event[i] = 0;
    rep(i,X)cin>>rt[i];
    int sum = 0;
    rep(i,z){
      int tmp;cin>>tmp;
      cin>>event[tmp]>>eval[tmp];
      if (event[tmp] == 2)sum += eval[tmp];
    }
    sum++;
    double ans = floor(solve(n,X,rt,event,eval,sum)+1e-10);
    printf("%lld\n",(ll)ans);
  }
  
}

Compiler output:
a.cc:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:75:18: error: 'floor' was not declared in this scope
   75 |     double ans = floor(solve(n,X,rt,event,eval,sum)+1e-10);
      |                  ^~~~~
Language: C++

#include <cstdio>
#include <cstring>

#include <map>

#include <algorithm>

using namespace std;

typedef pair<int, int> P;

int x, y, z, n, a, e;

int v[4];

P event[55];

 double dp[55][5050][2];

//double dp[55][5050];
int main() {

    while (scanf("%d%d%d",&x,&y,&z)) {

        if (!x&&!y&&!z) break;

        fill(event, event+55, P(0,0));

        memset(dp, 0, sizeof(dp));
        for (int i=0; i<x; i++) scanf("%d",&v[i]);

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

            scanf("%d%d%d",&n,&a,&e);

            event[n]=P(a,e);
//            event[n]=P((a==1),a==3?-e:e);

        }
        dp[0][0][0]=1.0;
//        dp[0][0]=1.0;
        for (int i=0; i<y; i++) {
            if (event[i].first==1) {
                int next=min(y,i+event[i].second);
                for (int j=0; j<5050; j++) {
                    dp[next][j][1]+=dp[i][j][0];
                    for (int k=0; k<x; k++) {
                        int next2=min(y,i+v[k]);
                        dp[next2][j][0]+=dp[i][j][1]/x;
                    }
                }
            } else {
                for (int j=0; j<5050; j++) {
                    if (dp[i][j][0]==0.0&&dp[i][j][1]==0.0) continue;
                    for (int k=0; k<x; k++) {
                        int next=min(y,i+v[k]);
                        if (event[i].first==2) {
                            dp[next][j+event[i].second][0]+=dp[i][j][0]/x;
                            dp[next][j][0]+=dp[i][j][1]/x;
                        } else if (event[i].first==3) {
                            dp[next][max(0,j-event[i].second)][0]+=dp[i][j][0]/x;
                            dp[next][j][0]+=dp[i][j][1]/x;
                        } else {
                            dp[next][j][0]+=(dp[i][j][0]+dp[i][j][1])/x;
                        }
                    }
                }
            }
/*            for (int j=0; j<5050; j++) {
                if (dp[i][j]==0.0) continue;
                for (int k=0; k<x; k++) {
                    int nv=min(y,i+v[k]);
                    int np=j;
                    if (nv<y) {
                        if (event[nv].first) nv+=event[nv].second;
                        else np+=event[nv].second;
                    }
                    dp[min(y,nv)][max(0,np)]+=dp[i][j]/x;
                }
            }
        }*/
        double res=0.0;
        for (int k=0; k<5050; k++) res+=(dp[y][k][0]+dp[y][k][1])*k;
//        for (int k=0; k<5050; k++) res+=dp[y][k]*k;
//        printf("%.0f\n",res);
        printf("%d\n",(int)res);

    }

}

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

#include "stdafx.h"

#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>

int x,y,z;
int invN[51],invE[51],invA[51],le[5];
long double dp[5001][51];

using namespace std;

void life(int m,int n){
	int a,b,c;
	int next,gm;
	int flag=1;
	if(n==y)return;
	//ルーレットを回す
	for(a=0;a<x;a++){
		next=n+le[a];
		//ゴール
		if(next>=y){
			dp[m][y]+=dp[m][n]/x;
		}else{
			//イベントマスにとまったか
			flag=0;
			for(b=0;b<z;b++){
				if(next==invN[b]){
					flag=1;
					//イベントマスに止まった
					if(invE[b]==1){
						c=next+invA[b];
						if(c>=y)c=y;
						dp[m][c]+=dp[m][n]/x;
						life(m,c);
					}
					if(invE[b]==2){
						gm=m+invA[b];
						dp[gm][next]+=dp[m][n]/x;
						life(gm,next);

					}
					if(invE[b]==3){
						gm=m-invA[b];
						if(gm<0)gm=0;
						dp[gm][next]+=dp[m][n]/x;
						life(gm,next);
					}
				}
			}
			//イベントマスに止まらなかった
			if(flag==0){
				dp[m][next]+=dp[m][n]/x;
				life(m,next);
			}
		}
	}
}

int main(void){
	int a,b;
	int ans=0;
	while(1){
		for(b=0;b<5001;b++)for(a=0;a<51;a++)dp[b][a]=0.0;
		dp[0][0]=1;
		ans=0;
		cin >> x >> y >> z;
		for(a=0;a<x;a++)cin >> le[a];
		for(a=0;a<z;a++)cin >> invN[a] >> invE[a] >> invA[a];
		life(0,0);
		for(a=0;a<5001;a++)ans+=a*dp[a][y];
		cout << ans <<endl;
	}
	return 0;
}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

int x,y,z;
int invN[51],invE[51],invA[51],le[5];
double dp[5001][51];
double ans=0;

using namespace std;

void life(int m,int n){
	int a,b,c;
	int next,gm;
	int flag=1;
	if(n==y)return;
	//ルーレットを回す
	for(a=0;a<x;a++){
		next=n+le[a];
		//ゴール
		if(next>=y){
			ans+=m*dp[m][n]/x;
		}else{
			//イベントマスにとまったか
			flag=0;
			for(b=0;b<z;b++){
				if(next==invN[b]){
					flag=1;
					//イベントマスに止まった
					if(invE[b]==1){
						c=next+invA[b];
						if(c>=y)c=y;
						dp[m][c]+=dp[m][n]/x;
						life(m,c);
					}
					if(invE[b]==2){
						gm=m+invA[b];
						dp[gm][next]+=dp[m][n]/x;
						life(gm,next);

					}
					if(invE[b]==3){
						gm=m-invA[b];
						if(gm<0)gm=0;
						dp[gm][next]+=dp[m][n]/x;
						life(gm,next);
					}
				}
			}
			//イベントマスに止まらなかった
			if(flag==0){
				dp[m][next]+=dp[m][n]/x;
				life(m,next);
			}
		}
	}
}

int main(void){
	int a,b;
	while(1){
		dp[0][0]=1;
		ans=0.0;
		cin >> x >> y >> z;
		if(x==0)break;
		for(b=0;b<=y*100;b++)for(a=1;a<=y;a++)dp[b][a]=0.0;
		for(a=0;a<x;a++)cin >> le[a];
		for(a=0;a<z;a++)cin >> invN[a] >> invE[a] >> invA[a];
		life(0,0);
		cout << (int)ans << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:17: error: 'cin' was not declared in this scope
   60 |                 cin >> x >> y >> z;
      |                 ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | int x,y,z;
a.cc:66:17: error: 'cout' was not declared in this scope
   66 |                 cout << (int)ans << endl;
      |                 ^~~~
a.cc:66:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:66:37: error: 'endl' was not declared in this scope
   66 |                 cout << (int)ans << endl;
      |                                     ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | int x,y,z;
Language: C++

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

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

vector<int> V;
struct Cell
{
    int N, E, A;
};
vector<Cell> cells;

float memo[50][100 * 50];

float rec(int current, int patternNum, int money) {

    if(memo[current][money] != -1) return memo[current][money];

    //cout << "current " << current << ' ' << patternNum << endl;
    if(current >= cells.size() - 1) {
        //cout << "goal! " << patternNum << ' ' << money << endl;
        return 1.0 * money / patternNum;
    }

    Cell &cell = cells[current];
    switch(cell.E) {
        case 1:
            current += cell.A;
            break;
        case 2:
            money += cell.A;
            break;
        case 3:
            money = max(0, money - cell.A);
            break;
    }

    float ret = 0;
    rep(i, V.size()) {
        ret += rec(current + V[i], patternNum * V.size(), money);
    }
    return ret;
}

int main() {
    int X, Y, Z;
    while(true) {
        cin >> X >> Y >> Z;
        if(!X && !Y && !Z) break;

        V = vector<int>(X);
        rep(i, X) cin >> V[i];

        Cell zero = {0, 0, 0};
        cells = vector<Cell>(Y + 1, zero);
        rep(i, Z) {
            Cell cell;
            cin >> cell.N >> cell.E >> cell.A;
            cells[cell.N] = cell;
        }

        memset(memo, -1, 50 * 100 * 50 * sizeof(float));

        cout << (int)rec(0, 1, 0) << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:9: error: 'memset' was not declared in this scope
   63 |         memset(memo, -1, 50 * 100 * 50 * sizeof(float));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <iostream>
#include <string>
using namespace std;
#define rep(x,to) for(int x=0; x<(to); ++(x))

int main() {
    int x;
    while(cin >> x, x) {
        string ans = "";
        while(x) {
            int tmp = (x % 10 + 10) % 10;
            ans += '0' + tmp;
            x = (x - tmp) / -10;
        }
        reverse(ans.begin(), ans.end());
        cout << ans << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'reverse' was not declared in this scope
   15 |         reverse(ans.begin(), ans.end());
      |         ^~~~~~~
Language: C++

#include<cstdio>
#include<string>

using namespace std;

typedef	long long	ll;

int main(){
	for(ll n;scanf("%lld",&n),n;){
		string ans;
		while(n){
			int dgt=n%10;
			if(dgt<0)	dgt+=10;
			ans+=(dgt+'0');
			n=(n-dgt)/-10;
		}
		reverse(ans.begin(),ans.end());
		puts(ans.c_str());
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 'reverse' was not declared in this scope
   17 |                 reverse(ans.begin(),ans.end());
      |                 ^~~~~~~
Language: C++

char s[];n,a;main(r){for(;scanf("%d",&a)*a;puts(s+n))for(;a;a=(r-a)/10)r=(a%10+10)%10,s[--n]=r+48;}

Compiler output:
a.cc:1:6: error: storage size of 's' isn't known
    1 | char s[];n,a;main(r){for(;scanf("%d",&a)*a;puts(s+n))for(;a;a=(r-a)/10)r=(a%10+10)%10,s[--n]=r+48;}
      |      ^
a.cc:1:10: error: 'n' does not name a type
    1 | char s[];n,a;main(r){for(;scanf("%d",&a)*a;puts(s+n))for(;a;a=(r-a)/10)r=(a%10+10)%10,s[--n]=r+48;}
      |          ^
a.cc:1:18: error: expected constructor, destructor, or type conversion before '(' token
    1 | char s[];n,a;main(r){for(;scanf("%d",&a)*a;puts(s+n))for(;a;a=(r-a)/10)r=(a%10+10)%10,s[--n]=r+48;}
      |                  ^
Language: C++

#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll rsum[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000};
//int dm[]={1,-1};
ll abs(ll a){ return a>0?a:-a; }
int main(){
  ll n;
  while(scanf("%lld",&n),n){
    int st = 0;
    ll res = 0;
    if(n<0) st = 1;
    n=abs(n);
    int k=0;
    bool tf = false;
    while(n>0){
      ll a = n%10;
      if(!(st&1)){
	if(tf){
	  a++;
	}
	tf=false;
      } else {
	if(a!=0){
	  a = 10-a;
	  tf=true;
	}
      }
      res += a*rsum[k];
      k++; st++;
      n/=10;
    }
    if(tf){
      res += rsum[k];
    }
    printf("%lld\n",res);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:10: error: call of overloaded 'abs(ll&)' is ambiguous
   17 |     n=abs(n);
      |       ~~~^~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
a.cc:10:4: note: candidate: 'll abs(ll)'
   10 | ll abs(ll a){ return a>0?a:-a; }
      |    ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Language: C++

#include<stdio.h>



long long solve(int x){
    int ans[] = {9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0};
    long long now = -909090909090;
    now = (long long)x - now;
    int p = 11, i;
    while(now){
	ans[p] = abs(ans[p] - (now % 10));
	p--;now/=10;
    }
    char res[100];
    for(i = 0;i < 12;i++)res[i] = ans[i] + '0';
    res[12] = 0;
    sscanf(res, "%lld", &now);
    return now;
}


int main(){
    int n;
    while(scanf("%d", &n), n)
	printf("%lld\n", solve(n));
    return 0;
}

Compiler output:
a.cc: In function 'long long int solve(int)':
a.cc:11:18: error: 'abs' was not declared in this scope; did you mean 'ans'?
   11 |         ans[p] = abs(ans[p] - (now % 10));
      |                  ^~~
      |                  ans
Language: Java

import java.util.Scanner;

//Aizu Buried Treasure
public class Main{

	int w, h, f, m, o;
	long[][] a;
	long[][][][] dp;
	
	
	long get(int i, int j, int s, int rest){
		if(i==h)return 0;
		if(rest<1)return dp[i][j][s][rest] = 1L<<30;
		if(dp[i][j][s][rest]!=-1)return dp[i][j][s][rest];
		long x = 0;
		int nr = rest;
		int ns = s;
		if((s&(1<<j))!=0){
			ns -= 1<<j;
			if(a[i][j]<0)x = -a[i][j];
			else {
				a[i][j] = Math.min(m, a[i][j]);
				nr = (int)Math.min(m, nr+a[i][j]);
			}
		}
		long min = 1<<30;
		min = Math.min(min, x+get(i+1,j,(1<<w)-1,nr-1));
		if(j>0)min = Math.min(min, x+get(i,j-1,ns,nr-1));
		if(j<w-1)min = Math.min(min, x+get(i,j+1,ns,nr-1));
		return dp[i][j][s][rest] = min;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h)==0)break;
			f = sc.nextInt();
			m = sc.nextInt();
			o = sc.nextInt();
			a = new long[h][w];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)a[i][j]=sc.nextLong();
			dp = new long[h][w][1<<w][m+1];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)for(int k=0;k<1<<w;k++)for(int l=0;l<=m;l++)dp[i][j][k][l]=-1;
			long min = 1<<30;
			for(int j=0;j<w;j++)min = Math.min(min, get(0,j,(1<<w)-1,o-1));
			System.out.println(min==1<<30||f<min?"NA":min);
		}
	}
	
	public static void main(String[] args) {
		new AOJ0234().run();
	}
}

Compiler output:
Main.java:53: error: cannot find symbol
		new AOJ0234().run();
		    ^
  symbol:   class AOJ0234
  location: class Main
1 error
Language: C++

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int lli;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1},dy[]={0,1,0};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

struct State{
	int x,y,d,o,s;
	State(int a,int b,int h,int e,int g):x(b),y(a),d(h),o(e),s(g){}
	bool operator>(const State& s)const{
		return d>s.d;
	}
};

int W,H,f,m,o,c[10][10],d[10][10][51][1<<10],ans;

void Solve(){
	fill_n((int*)d,10*10*51*(1<<10),INF);
	ans=INF;
	priority_queue<State,vector<State>,greater<State>> que;
	REP(x,0,W){
		int cost=0,oxy=o-1;
		if(c[0][x]<0) cost=-c[0][x];
		else oxy=min(m,oxy+c[0][x]);
		if(cost>f||oxy==0) continue;
		d[0][x][o][1<<x]=cost;
		que.push(State(0,x,cost,oxy,1<<x));
	}
	while(!que.empty()){
		State v=que.top();
		que.pop();
		int vy=v.y,vx=v.x,vd=v.d,vo=v.o,vs=v.s;
		if(vy==H-1) ans=min(ans,d[vy][vx][vo][vs]);
		if(d[vy][vx][vo][vs]<vd||vo<=1) continue;
		/*
		REP(i,0,3){
			int ny=vy+dy[i],nx=vx+dx[i];
			if(ny<0||H<=ny||nx<0||W<=nx) continue;
			int cost=0,no=vo-1,ns=vs|(1<<nx);
			if(ny!=vy||((vs>>nx)&1)==0){
				if(c[ny][nx]<0) cost=-c[ny][nx];
				else no=min(m,no+c[ny][nx]);
			}
			if(ny!=vy) ns=1<<nx;
			if(vd+cost<d[ny][nx][no][ns]&&vd+cost<=f){
				d[ny][nx][no][ns]=vd+cost;
				que.push(State(ny,nx,d[ny][nx][no][ns],no,ns));
			}
		}
	}
	*/
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	while(true){
		cin >> W >> H;
		if(W==0&&H==0) break;
		cin >> f >> m >> o;
		REP(y,0,H) REP(x,0,W) cin >> c[y][x];
		Solve();
		if(ans==INF) cout << "NA";
		else cout << ans;
		cout << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void Solve()':
a.cc:98:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   98 | int main(){
      |         ^~
a.cc:98:9: note: remove parentheses to default-initialize a variable
   98 | int main(){
      |         ^~
      |         --
a.cc:98:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:98:11: error: a function-definition is not allowed here before '{' token
   98 | int main(){
      |           ^
a.cc:112:2: error: expected '}' at end of input
  112 | }
      |  ^
a.cc:61:13: note: to match this '{'
   61 | void Solve(){
      |             ^
Language: C++

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

int c[11][11], d[11][11][51][1 << 10];
int dx[]{ 1,0,0 }, dy[]{ 0,1,-1 };
struct st { int x, y, p, v, c; };
bool operator<(st a, st b) { return a.c > b.c; }
int main() {
	int w, h;
	while (scanf("%d%d", &w, &h), w) {
		int f, m, o; scanf("%d%d%d", &f, &m, &o);
		if (o == 0) { puts("NA"); goto g; }
		rep(i, h)rep(j, w)scanf("%d", &c[i + 1][j]);
		priority_queue<st>que;
		memset(d, 0x3f, sizeof(d));
		rep(i, w) {
			d[0][i][o][0] = 0; que.push({ 0,i,o,0,0 });
		}
		while (!que.empty()) {
			st p = que.top(); que.pop();
			if (d[p.x][p.y][p.p][p.v] != p.c)continue;
			rep(i, 3) {
				int nx = p.x + dx[i], ny = p.y + dy[i];
				if (!(nx <= h && 0 <= ny&&ny < w))continue;
				int a = (c[nx][ny] > 0 && (!i || !(p.v >> ny & 1)) ? p.p - 1 + c[nx][ny] : p.p - 1);
				if (a <= 0)continue;
				if (a > m)a = m;
				int e = (c[nx][ny] > 0 ? (p.v | 1 << ny) : p.v);
				if (!i)e = 0;
				int b = (c[nx][ny] < 0 ? p.c - c[nx][ny] : p.c);
				if (d[nx][ny][a][e] > b) {
					d[nx][ny][a][e] = b; que.push({ nx,ny,a,e,b });
				}
			}
		}
		int Min = INF;
		rep(i, w)rep(j, m + 1)rep(k, 1 << w)Min = min(Min, d[h][i][j][k]);
		if (Min > f)puts("NA");
		else printf("%d\n", Min);
	g:;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:9: error: jump to label 'g'
   42 |         g:;
      |         ^
a.cc:14:48: note:   from here
   14 |                 if (o == 0) { puts("NA"); goto g; }
      |                                                ^
a.cc:38:21: note:   crosses initialization of 'int Min'
   38 |                 int Min = INF;
      |                     ^~~
a.cc:16:35: note:   crosses initialization of 'std::priority_queue<st> que'
   16 |                 priority_queue<st>que;
      |                                   ^~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<sstream>
#include<set>
#include<map>
#include<algorithm>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair

const int inf=1<<29;
int w,h,f,m,o;
int c[10][10],dp[11][10][51][10][10];

int main(){
	while(cin>>w>>h,w){
		cin>>f>>m>>o;
		rep(i,h)rep(j,w)cin>>c[i][j];
		
		rep(i,h+1)rep(j,w)rep(k,m+1)rep(l,w)rep(r,w)dp[i][j][k][l][r]=inf;
		rep(i,w)dp[0][i][o][i][i]=0;
		
		int ans=inf;
		rep(i,h)rep(range,w)for(int k=m;k>1;k--)
		rep(it,2)rep(l,w-range)rep(x,range+1){
			int r=l+range,j=it?l+x:r-x,cost=dp[i][j][k][l][r];
			if(cost==inf)continue;
			
			if(c[i][j]>0){
				int sanso=min(m,k-1+c[i][j]);
				dp[i+1][j][sanso][j][j]=min(dp[i+1][j][sanso][j][j],cost);
			}
			else{
				dp[i+1][j][k-1][j][j]=min(dp[i+1][j][k-1][j][j],cost-c[i][j]);
			}
			if(i==0)continue;
			if(j>0){
				if(l<j)dp[i][j-1][k-1][l][r]=min(dp[i][j-1][k-1][l][r],cost);
				else{
					if(c[i-1][j-1]>0){
						int sanso=min(m,k-1+c[i-1][j-1]);
						dp[i][j-1][sanso][l-1][r]=min(dp[i][j-1][sanso][l-1][r],cost);
					}
					else{
						dp[i][j-1][k-1][l-1][r]=
						min(dp[i][j-1][k-1][l-1][r],cost-c[i-1][j-1]);
					}
				}
			}
			if(j<w-1){
				if(j<r)dp[i][j+1][k-1][l][r]=min(dp[i][j+1][k-1][l][r],cost);
				else{
					if(c[i-1][j+1]>0){
						int sanso=min(m,k-1+c[i-1][j+1]);
						dp[i][j+1][sanso][l][r+1]=min(dp[i][j+1][sanso][l][r+1],cost);
					}
					else{
						dp[i][j+1][k-1][l][r+1]=
						min(dp[i][j+1][k-1][l][r+1],cost-c[i-1][j+1]);
					}
				}
			}
		}
		int ans=inf;
		rep(i,w)for(int j=1;j<=m;j++)rep(l,w)rep(r,w)ans=min(ans,dp[h][i][j][l][r]);
		if(ans>f)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:73:21: error: redeclaration of 'int ans'
   73 |                 int ans=inf;
      |                     ^~~
a.cc:32:21: note: 'int ans' previously declared here
   32 |                 int ans=inf;
      |                     ^~~
Language: C++

#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Data
{
public:
    int y, x, left, right, o;
    Data(int y0, int x0, int left0, int right0, int o0)
    {
        y = y0;
        x = x0;
        left = left0;
        right = right0;
        o = o0;
    }
    int toInt()
    {
        return (((y * w + x) * w + left) * w + right) * (m+1) + o;
    }
};

int w, h, f, m, o;
vector<vector<int> > cell;

int solve()
{
    vector<int> dp(5 * (h+1) * w * w * w * (m+1), INT_MAX);
    multimap<int, Data> mm;

    for(int i=0; i<w; ++i){
        Data d(0, i, 0, w-1, o);
        dp[d.toInt()] = 0;
        mm.insert(make_pair(0, d));
    }

    while(!mm.empty()){
        int cost = mm.begin()->first;
        Data d = mm.begin()->second;
        mm.erase(mm.begin());

        if(cost > dp[d.toInt()])
            continue;
        if(d.y == h)
            return cost;

        for(int i=-1; i<=1; ++i){
            int cost1 = cost;
            Data d1 = d;
            -- d1.o;

            d1.x += i;
            if(d1.x < 0 || d1.x >= w || d1.o == 0)
                continue;

            if(i == 0){
                ++ d1.y;
                d1.left = d1.x;
                d1.right = d1.x - 1;
            }

            if(d1.x < d1.left || d1.x > d1.right){
                d1.left = min(d1.left, d1.x);
                d1.right = max(d1.right, d1.x);
                if(cell[d1.y][d1.x] < 0){
                    cost1 += -cell[d1.y][d1.x];
                }else{
                    d1.o += cell[d1.y][d1.x];
                    d1.o = min(d1.o, m);
                }
            }

            if(cost1 < dp[d1.toInt()]){
                dp[d1.toInt()] = cost1;
                mm.insert(make_pair(cost1, d1));
            }
        }
    }

    return INT_MAX;
}

int main()
{
    for(;;){
        cin >> w >> h >> f >> m >> o;
        if(w == 0 && h == 0)
            return 0;

        cell.assign(5*h+1, vector<int>(5*w, 0));
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cin >> cell[i+1][j];
            }
        }

        int ret = solve();
        if(ret > f)
            cout << "NA" << endl;
        else
            cout << ret << endl;
    }
}

Compiler output:
a.cc: In member function 'int Data::toInt()':
a.cc:34:23: error: 'w' was not declared in this scope
   34 |         return (((y * w + x) * w + left) * w + right) * (m+1) + o;
      |                       ^
a.cc:34:58: error: 'm' was not declared in this scope; did you mean 'tm'?
   34 |         return (((y * w + x) * w + left) * w + right) * (m+1) + o;
      |                                                          ^
      |                                                          tm
Language: C++

#include <cstdio>
#include <cstdlib>
#include <queue>
 
using namespace std;
 
#define inf (1<<27)

struct State {
    int x,y,l,r,o,c;
    State(int xx,int yy,int ll,int rr,int oo,int cc) {
        x=xx,y=yy,l=ll,r=rr,o=oo,c=cc;
    }
};
 
bool operator > (const State &left,const State &right) {
	return left.c>right.c;
}

int map[10][10];
int cost[10][10][10][10][51];

int main() {
	int W,H,f,m,o;
	while(scanf("%d %d",&W,&H),W) {
		memset(cost,0x10,sizeof(cost));
		scanf("%d %d %d",&f,&m,&o);
		for(int j=0;j<H;j++)for(int i=0;i<W;i++) {
			scanf("%d",&map[i][j]);
		}
		if(o==1){printf("NA\n");continue;}
		priority_queue<State,vector<State>,greater<State> > que;
		for(int i=0;i<W;i++) {
			int oo=o-1,cc=0;
			if(map[i][0]<0) {
				cc-=map[i][0];
			}else {
				oo+=map[i][0];
				if(oo>m)oo=m;
			}
			que.push(State(i,0,i,i,oo,cc));
		}
		int res=inf;
		while(!que.empty()) {
			State s=que.top();
			que.pop();
			s.o--;
			if(s.y==(H-1)){res=s.c;break;}
			if(s.o==0){continue;}
			if(cost[s.x][s.y][s.l][s.r][s.o]<s.c){continue;}
			State ns=s;
			ns.y++;ns.l=ns.r=ns.x;
			if(ns.y<H) {
				if(map[ns.x][ns.y]>0) {
					ns.o+=map[ns.x][ns.y];
					if(ns.o>m)ns.o=m;
				}else {
					ns.c-=map[ns.x][ns.y];
				}
				if(cost[ns.x][ns.y][ns.l][ns.r][ns.o]>ns.c) {
					cost[ns.x][ns.y][ns.l][ns.r][ns.o]=ns.c;
					que.push(ns);
				}
			}
			ns=s;
			ns.x++;
			if(ns.x<W) {
				if(ns.x>ns.r) {
					ns.r=ns.x;
					if(map[ns.x][ns.y]>0) {
						ns.o+=map[ns.x][ns.y];
						if(ns.o>m)ns.o=m;
					}else {
						ns.c-=map[ns.x][ns.y];
					}
				}
				if(cost[ns.x][ns.y][ns.l][ns.r][ns.o]>ns.c) {
					cost[ns.x][ns.y][ns.l][ns.r][ns.o]=ns.c;
					que.push(ns);
				}
			}
			ns=s;
			ns.x--;
			if(ns.x>=0) {
				if(ns.l>ns.x) {
					ns.l=ns.x;
					if(map[ns.x][ns.y]>0) {
						ns.o+=map[ns.x][ns.y];
						if(ns.o>m)ns.o=m;
					}else {
						ns.c-=map[ns.x][ns.y];
					}
				}
				if(cost[ns.x][ns.y][ns.l][ns.r][ns.o]>ns.c) {
					cost[ns.x][ns.y][ns.l][ns.r][ns.o]=ns.c;
					que.push(ns);
				}
			}
		}
		if(res<=f)printf("%d\n",res);
		else printf("NA\n");
	}
}

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

#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 1<<25


typedef struct n
{
	int w,h,m,o,g[11][11];
}n;

struct Order
{
	bool operator ()(n const& a, n const& b) const
	{
		return a.m<b.m;
	}
};

int W,H,F,M,O,G[11][11],mv[4]={0,1,0,-1},f;

n cr(int h,int w,int o,int m,int g[11][11])
{
	n ins;
	ins.h=h;ins.w=w;
	ins.m=m+(g[h][w]<0?g[h][w]:0);
	ins.o=min(M,o-1+(g[h][w]>0?g[h][w]:0));
	memcpy(ins.g,g,sizeof(ins.g));
	ins.g[h][w]=0;
	return ins;
}

int main()
{
	for(;~scanf("%d%d%d%d%d",&W,&H,&F,&M,&O),W;)
	{
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				scanf("%d",&G[i][j]);
		priority_queue<n,vector<n>,Order>Q;
		for(int i=0;i<W;i++)
		{
			n ins=cr(0,i,O,F,G);
			Q.push(ins);
		}
		for(f=0;!Q.empty();)
		{
			n tmp=Q.top();Q.pop();
			if(tmp.h==H-1)
			{
				printf("%d\n",F-tmp.m);
				f=1;
				break;
			}
			for(int i=0;i<3;i++)
			{
				int nh=tmp.h+mv[i];
				int nw=tmp.w+mv[i+1];
				if(0<=nw&&nw<W&&tmp.o>1)
				{
					int nc=tmp.m+(G[nh][nw]<0?G[nh][nw]:0);
					if(nc>0)
					{
						n ins=cr(nh,nw,tmp.o,tmp.m,tmp.g);
						Q.push(ins);
					}
				}
			}
		}
		if(!f)puts("NA");
	}
	return 0;
}

Compiler output:
a.cc: In function 'n cr(int, int, int, int, int (*)[11])':
a.cc:29:9: error: 'memcpy' was not declared in this scope
   29 |         memcpy(ins.g,g,sizeof(ins.g));
      |         ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: Java

import java.util.Scanner;

public class SaveBrian {
	static int [][] map;
	static int N;
	static int total;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x,y;
		while(sc.hasNext()){
			N=sc.nextInt();
			if(N==0){
				sc.close();
				break;
			}
			initialise(N);
			//値の更新　N-1個分のデータがくる
			for(int i=0;i<N-1;i++){
				x=sc.nextInt()-1;
				y=sc.nextInt()-1;
				map[x][y]=sc.nextInt();
				map[y][x]=map[x][y];
			}

			total=0;
			search(0,0,-1);
			System.out.println(total);
		}

	}

	public static void initialise(int N){
		map=new int [N][N];
		for(int x=0;x<N;x++){
			for(int y=0;y<N;y++){
				map[x][y]=0;
			}
		}
	}

	public static void search(int np,int cost,int pp){
		int count=0;
		for(int x=0;x<N;x++){
			if(map[x][np]!=0 && x!=pp){
				count++;
			}
		}
		if(count==0){
			return;
		}
		total+=cost*2;
		for(int x=0;x<N;x++){
			if(map[x][np]!=0 && x!=pp){
				search(x,map[x][np],np);
			}
		}
	}
}

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

int n;
int t[22][22];

int solve(int idx){
  int res = 0;
  rep(i,n){
    if(t[idx][i] > 0){
      t[i][idx] = 0;
      res = max(res,t[idx][i]+solve(i));
    }
  }
  return res;
}

int main(void){
  while(cin>>n,n){
    memset(t,0,sizeof(t));

    int sum = 0;
    rep(i,n-1){
      int a,b,cost;
      cin>>a>>b>>cost;
      t[a-1][b-1] = t[b-1][a-1] = cost;
      sum += cost * 2;
    }

    rep(i,n){
      int cnt=0, idx;
      rep(j,n){
        if(t[i][j] > 0 || t[i][j] == -1){
          cnt++;
          idx = j;
        }
      }
      if(i != 0 && cnt == 1){
        sum -= 2 * t[i][idx];
        t[i][idx] = t[idx][i]= -1;
      }
    }

    cout<<sum-solve(0)<<endl;
  }

  return 0;
}

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
int n;
^
  (use --enable-preview to enable unnamed classes)
Main.java:2: error: class, interface, enum, or record expected
int t[22][22];
^
Main.java:6: error: ';' expected
  rep(i,n){
          ^
Main.java:16: error: not a statement
  while(cin>>n,n){
               ^
Main.java:22: error: not a statement
      cin>>a>>b>>cost;
               ^
Main.java:41: error: not a statement
    cout<<sum-solve(0)<<endl;
                      ^
Main.java:15: error: <identifier> expected
int main(void){
             ^
Main.java:16: error: ')' expected
  while(cin>>n,n){
              ^
Main.java:16: error: ';' expected
  while(cin>>n,n){
                ^
Main.java:20: error: ';' expected
    rep(i,n-1){
              ^
Main.java:27: error: ';' expected
    rep(i,n){
            ^
Main.java:29: error: ';' expected
      rep(j,n){
              ^
12 errors
Language: C

#include<stdio.h>
#include<vector>
using namespace std;
#define INF 100000
int d[20][20];
vector<int> ch[20];
bool term[20];
bool nterm[20];
bool used[20];
int min(int a,int b){return a<b?a:b;}
int main(){
	int n;
	int i,j,k;
	while(1){
	scanf("%d",&n);
	if(n==0)return 0;
	for(i=0;i<n;i++)for(j=0;j<n;j++)d[i][j]=INF;
	for(i=0;i<n;i++){
		term[i]=false;
		nterm[i]=false;
		used[i]=false;
	}
	for(i=0;i<n-1;i++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		d[a-1][b-1]=c;
		d[b-1][a-1]=c;
		ch[a-1].push_back(b-1);
		ch[b-1].push_back(a-1);
	}
	for(i=0;i<n;i++){
		if(ch[i].size()==1){
			term[i]=true;
			nterm[ch[i][0]]=true;
		}
	}
	for(i=0;i<n;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)if(i!=j)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	int p=0;
	int v;
	int ans=0;
	while(1){
		v=-1;
		for(i=0;i<n;i++)if(nterm[i]&&(v==-1||d[p][i]<d[p][v]))v=i;
		if(v==-1)break;
		ans+=d[p][v];
		p=v;
		for(i=0;i<ch[p].size();i++){
			if(term[ch[p][i]]){
				ch[p].erase(ch[p].begin()+i);
				i--;
			}
		}
		if(ch[p].empty())break;
		if(ch[p].size()<=1){
			nterm[p]=false;
			term[p]=true;
			nterm[ch[p][0]]=true;
		}		
	}
	printf("%d\n",ans);
	}
}

Compiler output:
main.c:2:9: fatal error: vector: No such file or directory
    2 | #include<vector>
      |         ^~~~~~~~
compilation terminated.