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

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

string exp;
int now,ans,p,q,r;

int multi(int x,int y){
	return min(x,y);
}

int plus(int x,int y){
	return max(x,y);
}

int minus(int x){
	if(x==2)
		return 0;
	if(x==1)
		return 1;
	if(x==0)
		return 2;
}

int calc(){
	if(exp[now]=='0' || exp[now]=='1' || exp[now]=='2'){
		now++;
		return exp[now]-'0';
	}
	if(exp[now]=='P'){
		now++;
		return p;
	}else if(exp[now]=='Q'){
		now++;
		return q;
	}else if(exp[now]=='R'){
		now++;
		return r;
	}else if(exp[now]=='-'){
		now++;
		return minus(calc());
	}else if(exp[now]=='('){
		now++;
		int left=calc(),right;
		if(exp[now]=='*'){
			now++;
			right=calc();
			now++;
			return multi(left,right);
		}
		else if(exp[now]=='+'){
			now++;
			right=calc();
			now++;
			return plus(left,right);
		}
	}
}

void solve(){
	now=0;
	ans=0;
	int k;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			for(int z=0;z<3;z++){
				p=i;
				q=j;
				r=z;	
				k=calc();
				if(k==2){
					ans++;
				}
				now=0;
			}
	cout<<ans<<"\n";
}


int main()
{
	cin>>exp;
	while(exp!="."){
		solve();
		cin>>exp;
	}
	return 0;
}

Compiler output:
a.cc:5:8: warning: built-in function 'exp' declared as non-function [-Wbuiltin-declaration-mismatch]
    5 | string exp;
      |        ^~~
a.cc: In function 'int calc()':
a.cc:41:24: error: reference to 'minus' is ambiguous
   41 |                 return minus(calc());
      |                        ^~~~~
In file included from /usr/include/c++/14/string:49,
                 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:1:
/usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus'
  163 |     struct minus;
      |            ^~~~~
a.cc:16:5: note:                 'int minus(int)'
   16 | int minus(int x){
      |     ^~~~~
a.cc:55:32: error: reference to 'plus' is ambiguous
   55 |                         return plus(left,right);
      |                                ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
  160 |     struct plus;
      |            ^~~~
a.cc:12:5: note:                 'int plus(int, int)'
   12 | int plus(int x,int y){
      |     ^~~~
a.cc: In function 'int minus(int)':
a.cc:23:1: warning: control reaches end of non-void function [-Wreturn-type]
   23 | }
      | ^
Language: C++

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

string exp;
int now,ans,p,q,r;

int multi(int x,int y){
	return min(x,y);
}

int plus(int x,int y){
	return max(x,y);
}

int minus(int x){
	if(x==2)
		return 0;
	if(x==1)
		return 1;
	if(x==0)
		return 2;
	return false;
}
int calc(){
	if(exp[now]=='0' || exp[now]=='1' || exp[now]=='2'){
		char temp=exp[now];
		now++;
		return temp-'0';
	}
	if(exp[now]=='P'){
		now++;
		return p;
	}else if(exp[now]=='Q'){
		now++;
		return q;
	}else if(exp[now]=='R'){
		now++;
		return r;
	}else if(exp[now]=='-'){
		now++;
		return minus(calc());
	}else if(exp[now]=='('){
		now++;
		int left=calc(),right;
		if(exp[now]=='*'){
			now++;
			right=calc();
			now++;
			return multi(left,right);
		}
		else if(exp[now]=='+'){
			now++;
			right=calc();
			now++;
			return plus(left,right);
		}
	}
	return false;
}

void solve(){
	now=0;
	ans=0;
	int k;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			for(int z=0;z<3;z++){
				p=i;
				q=j;
				r=z;	
				k=calc();
				if(k==2){
					ans++;
				}
				now=0;
			}
	cout<<ans<<"\n";
}


int main()
{
	cin>>exp;
	while(exp!="."){
		solve();
		cin>>exp;
	}
	return 0;
}

Compiler output:
a.cc:5:8: warning: built-in function 'exp' declared as non-function [-Wbuiltin-declaration-mismatch]
    5 | string exp;
      |        ^~~
a.cc: In function 'int calc()':
a.cc:42:24: error: reference to 'minus' is ambiguous
   42 |                 return minus(calc());
      |                        ^~~~~
In file included from /usr/include/c++/14/string:49,
                 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:1:
/usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus'
  163 |     struct minus;
      |            ^~~~~
a.cc:16:5: note:                 'int minus(int)'
   16 | int minus(int x){
      |     ^~~~~
a.cc:56:32: error: reference to 'plus' is ambiguous
   56 |                         return plus(left,right);
      |                                ^~~~
/usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus'
  160 |     struct plus;
      |            ^~~~
a.cc:12:5: note:                 'int plus(int, int)'
   12 | int plus(int x,int y){
      |     ^~~~
Language: C++

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

#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REP(i,n) FOR(i,0,n)
typedef vector<int> vi;
typedef vector<vi> vii;
#define ALL(a) a.begin(),a.end()

int not(int n){
	switch(n){
	case 0:return 2;
	case 1:return 1;
	case 2:return 0;
	}
}
int and(int x,int y){
	switch(x){
	case 0:
		return 0;
	case 1:
		return (y==0?0:1);
	case 2:
		return y;
	}
}
int or(int x,int y){
	switch(x){
	case 0:
		return y;
	case 1:
		return (y==2?2:1);
	case 2:
		return 2;
	}
}
int n;
int go(string s,int p,int q,int r){
	int a,b,sign,v;
	switch(s[n]){
	case '0':
	case '1':
	case '2':
		v=s[n];
		n++;
		return v-'0';
	case 'P':
		n++;
		return p;
	case 'Q':
		n++;
		return q;
	case 'R':
		n++;
		return r;
	case '-':
		n++;
		return not(go(s,p,q,r));
	case '(':
		n++;
		a=go(s,p,q,r);
		sign=s[n];
		n++;
		b=go(s,p,q,r);
		n++;
		switch(sign){
		case '*':
			return and(a,b);
		case '+':
			return or(a,b);
		}
	case ')':
		assert(")");
	}
}

int main(){
	string s;
	while(cin>>s,s!="."){
		int ans=0;
		REP(p,3)REP(q,3)REP(r,3){
			n=0;
			if(go(s,p,q,r)==2){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}

Compiler output:
a.cc:14:5: error: expected unqualified-id before 'not' token
   14 | int not(int n){
      |     ^~~
a.cc:21:9: error: expected unqualified-id before 'int'
   21 | int and(int x,int y){
      |         ^~~
a.cc:21:9: error: expected ')' before 'int'
   21 | int and(int x,int y){
      |        ~^~~
      |         )
a.cc:31:5: error: expected unqualified-id before 'or' token
   31 | int or(int x,int y){
      |     ^~
a.cc: In function 'int go(std::string, int, int, int)':
a.cc:72:35: error: expected identifier before '(' token
   72 |                         return and(a,b);
      |                                   ^
a.cc:72:35: error: expected ';' before '(' token
   72 |                         return and(a,b);
      |                                   ^
      |                                   ;
a.cc:74:32: error: expected primary-expression before 'or' token
   74 |                         return or(a,b);
      |                                ^~
Language: C++

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define or(a,b) a > b ? a : b
#define and(a,b) a > b ? b : a
#define not(n) 1 - (n - 1)

int p[3];
char str[81];

int formula(int i){
	if(isupper(str[i]))
		return p[str[i] - 'P'];
	else if(isdigit(str[i]))
		return str[i] - '0';
	else if(str[i] == '-')
		return not(formula(i + 1));
	else if(str[i] == '('){
		int j = i;
		int cen = 0;
		while(1){
			if(str[++j] == '(')
				cen++;
			else if(str[j] == ')')
				cen--;
			if(cen == 0 && (str[j] == '*' || str[j] == '+')){
				if(str[j] == '*')
					return and(formula(i + 1),formula(j + 1));
				else
					return or(formula(i + 1),formula(j + 1));
			}
		}
	}
}

int main(void){
	int count,locate;
	gets(str);
	while(str[0] != '.'){
		str[strlen(str)] = '\0';
		count = 0;
		for(p[0] = 0;p[0] <= 2;p[0]++){
			for(p[1] = 0;p[1] <= 2;p[1]++){
				for(p[2] = 0;p[2] <= 2;p[2]++){
					if(formula(0) == 2)
						count++;
				}
			}
		}
		printf("%d\n",count);
		gets(str);
	}
	return 0;
}

Compiler output:
a.cc:4:9: error: "or" cannot be used as a macro name as it is an operator in C++
    4 | #define or(a,b) a > b ? a : b
      |         ^~
a.cc:5:9: error: "and" cannot be used as a macro name as it is an operator in C++
    5 | #define and(a,b) a > b ? b : a
      |         ^~~
a.cc:6:9: error: "not" cannot be used as a macro name as it is an operator in C++
    6 | #define not(n) 1 - (n - 1)
      |         ^~~
a.cc: In function 'int formula(int)':
a.cc:28:51: error: expected identifier before '(' token
   28 |                                         return and(formula(i + 1),formula(j + 1));
      |                                                   ^
a.cc:28:51: error: expected ';' before '(' token
   28 |                                         return and(formula(i + 1),formula(j + 1));
      |                                                   ^
      |                                                   ;
a.cc:29:33: error: expected '}' before 'else'
   29 |                                 else
      |                                 ^~~~
a.cc:26:73: note: to match this '{'
   26 |                         if(cen == 0 && (str[j] == '*' || str[j] == '+')){
      |                                                                         ^
a.cc:30:48: error: expected primary-expression before 'or' token
   30 |                                         return or(formula(i + 1),formula(j + 1));
      |                                                ^~
a.cc: At global scope:
a.cc:34:1: error: expected declaration before '}' token
   34 | }
      | ^
a.cc: In function 'int main()':
a.cc:38:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   38 |         gets(str);
      |         ^~~~
      |         getw
Language: C++

#include <algorithm>
#include <string>
#include <queue>
#include <cctype>
#include <cstdio>
#include <vector>

using namespace std;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;

const int INF = 1001001001;

int formula(const string& str, int& cur)
{
//	puts(str.substr(cur).c_str());
	if(isdigit(str[cur])){
		++cur;
		return str[cur-1] - '0';
	}
	if(str[cur] == '-'){
		++cur;
		return 2 - formula(str, cur);
	}

	++cur;
	int a = formula(str, cur);
	char op = str[cur];
	++cur;
	int b = formula(str, cur);
	++cur;
	if(op == '+')
		return max(a, b);
	else
		return min(a, b);
}

int main()
{
	char str[128];
	while(scanf("%s", str), str[0]!='.'){
		int n = strlen(str);
		int cnt = 0;
		rep(p, 3) rep(q, 3) rep(r, 3){
			string tmp = str;
			rep(i, n){
				if(tmp[i] == 'P') tmp[i] = p + '0';
				if(tmp[i] == 'Q') tmp[i] = q + '0';
				if(tmp[i] == 'R') tmp[i] = r + '0';
			}
			int cur = 0;
			cnt += formula(tmp, cur) == 2;
		}

		printf("%d\n", cnt);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:25: error: 'strlen' was not declared in this scope
   45 |                 int n = strlen(str);
      |                         ^~~~~~
a.cc:6:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <cstdio>
  +++ |+#include <cstring>
    6 | #include <vector>
Language: Java

import java.util.Scanner;

public class TwirlingRobot {
	Scanner in = new Scanner(System.in);
	int n, m;
	int[][][] dp;
	int[][] map;
	int[] cost;
	int[] vx = {1, 0, -1, 0};
	int[] vy = {0, 1, 0, -1};
	
	void dijkstra(int dir, int x, int y) {
		if (dp[dir][y][x] == -1) return;
		//debug(dir);
		int order = map[y-1][x-1];
		int go = (order == 4) ? -1 : (order + dir) % 4;
		for (int i = 0; i < vx.length; i++) {
			int nx = x + vx[i], ny = y + vy[i];
			int c = (go == i) ? 0 : cost[(i - dir + 4) % 4];
			if (dp[dir][y][x] != Integer.MAX_VALUE && dp[i][ny][nx] > dp[dir][y][x] + c) {
				dp[i][ny][nx] = dp[dir][y][x] + c;
				dijkstra(i, nx, ny);
			}
		}
	}
	
	public void run() {
		while (true) {
			n = in.nextInt();
			m = in.nextInt();
			if ((n|m) == 0) break;

			map = new int[m][n];
			for (int i = 0; i < map.length; i++) {
				for (int j = 0; j < map[i].length; j++) {
					map[i][j] = in.nextInt();
				}
			}
			
			cost = new int[4];
			for (int i = 0; i < cost.length; i++) {
				cost[i] = in.nextInt();
			}
			
			dp = new int[4][m+2][n+2];			
			for (int i = 0; i < dp.length; i++) {
				for (int j = 0; j < dp[i].length; j++) {
					for (int k = 0; k < dp[i][j].length; k++) {
						if (j == 0 || j == m + 1 || k == 0 || k == n + 1) 
							dp[i][j][k] = -1;
						else
							dp[i][j][k] = Integer.MAX_VALUE;
					}
				}
			}
			
			
			dp[0][1][1] = 0;
			dijkstra(0, 1, 1);
			
			for (int i = 0; i < 4; i++) {
				//debug(i);
			}
			int res = Integer.MAX_VALUE;
			for (int i = 0; i < dp.length; i++) {
				res = Math.min(res, dp[i][m][n]);
			}
			
			System.out.println(res);
		}
	}
	
	void debug(int i) {
		System.out.println("dir = " + i);
		for (int j = 1; j < dp[i].length - 1; j++) {
			for (int k = 1; k < dp[i][j].length - 1; k++) {
				System.out.print((dp[i][j][k] == Integer.MAX_VALUE ? "F" : dp[i][j][k]) + " ");
			}
			System.out.println();
		}
		System.out.println();
	}

	public static void main(String[] args) {
		new TwirlingRobot().run();
	}
}

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

#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 100000000;

class S{
public:
  int y, x, d, cost;
  S(){}
  S(int y, int x, int d, int cost) : y(y), x(x), d(d), cost(cost) {}
};

int h, w;
int map[30][30];
int cost[4];
int vis[30][30][4];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};

bool check(int y, int x){
  if(y<0 || y>=h) return false;
  if(x<0 || x>=w) return false;
  return true;
}

int solve(){
  S u, v;
  queue<S> q;
  q.push(S(0, 0, 1, 0));
  fill(vis[0][0], vis[30][0], INF);
  while(!q.empty()){
    u = q.front(); q.pop();
    if(map[u.y][u.x] != 4){
      v.d = (u.d+map[u.y][u.x])%4;
      v.y = u.y + dy[v.d];
      v.x = u.x + dx[v.d];
      v.cost = u.cost;
      if(check(v.y, v.x) && vis[v.y][v.x][v.d] > v.cost){
        vis[v.y][v.x][v.d] = v.cost;
        q.push(v);
      }
    }
    for(int i=0;i<4;i++){
      v.d = (u.d+i) % 4;
      v.y = u.y + dy[v.d];
      v.x = u.x + dx[v.d];
      v.cost = u.cost + cost[i];
      if(check(v.y, v.x) && vis[v.y][v.x][v.d] > v.cost){
        vis[v.y][v.x][v.d] = v.cost;
        q.push(v);
      }
    }
  }
  int res = INF;
  for(int i=0;i<4;i++) res = min(res, vis[h-1][w-1][i]);
  return res;
}

main(){
  while(cin >> w >> h && (h|w)){
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> map[i][j];
    for(int i=0;i<4;i++) cin >> cost[i];
    cout << solve() << endl;
  }
}

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

#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<map>
#define INF 1000000000
#define all(c) c.begin(),c.end()
#define uni(c) c.erase(unique(all(c)),c.end())
#define pb push_back
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef pair<int,PP> PPP;
int w,h;
int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
bool inf(int y,int x){
	if(x>=0&&x<w&&y>=0&&y<h)
		return true;
	return false;
}
int dij(vector<vector<int> > f, vector<int> op){
	priority_queue<PPP,vector<PPP> , greater<PPP> > que;
	int d[40][40][5];
	for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	for(int k=0;k<4;k++)
	d[i][j][k]=INF;
	que.push(PPP(0,PP(1,P(0,0))));
	d[0][0][1]=0;
	while(!que.empty()){
		PPP p=que.top();
		int dit=p.second.first;
		P now=p.second.second;
		int nc=p.first;
		que.pop();
		if(d[now.first][now.second][dit]<nc){
			continue;
		}
		if(now.first==h-1&&now.second==w-1){
			return nc;
		}
		d[now.first][now.second][dit]=nc;
		for(int i=0;i<4;i++){
			int nx=dx[(i+dit)%4]+now.second,ny=dy[(i+dit)%4]+now.first;
			if(!inf(ny,nx))
				continue;
			if(f[now.first][now.second]==i&&nc<d[ny][nx][(i+dit)%4]){
				que.push(PPP(nc,PP((i+dit)%4,P(ny,nx))));
				continue;
			}
			if(nc+op[i]<d[ny][nx][(i+dit)%4]){
				que.push(PPP(nc+op[i],PP((i+dit)%4,P(ny,nx))));
			}
		}
		
		
	}
	
	
	//return d[h-1][w-1][(i+dit)%4];
}
int main(){
	while(cin>>w>>h,w||h){
		vector<vector<int> > f(h,vector<int>(w));
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>f[i][j];
			}
		}
		vector<int> op(4);
		for(int i=0;i<4;i++)
			cin>>op[i];
		cout<<dij(f,op)<<endl;
		
	}
	return 0;
}

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

#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

int w, h;
int s[35][35];
int c[4];
int vx[4][4] = {{1, 0, -1, 0}, {0, 1, 0, -1}, {-1, 0, 1, 0}, {0, -1, 0, 1}};
int vy[4][4] = {{0, 1, 0, -1}, {-1, 0, 1, 0}, {0, -1, 0, 1}, {1, 0, -1, 0}};
int vv[4][4] = {{0, 3, 2, 1}, {1, 0, 3, 2}, {2, 1, 0, 3}, {3, 2, 1, 0}};

class robot {
	public :
		int x;
		int y;
		int v; // 向き
		int c;

		robot() {
			x = 0; y = 0; v = 0; c = 0;
		}

		bool operator<(const robot& other) const{
			return c > other.c;
		}

		bool operator>(const robot& other) const{
			return c < other.c;
		}

		bool next(int o) {
			if(o != s[y][x])
				c += ::c[o];
			x += vx[v][o];
			y += vy[v][o];
			v = vv[v][o];

			if(x < 0 || y < 0 || x >= w || y >= h)
				return false;

			return true;
		}
}; 

bool input() {
	cin >> w >> h;
	if(w == 0 && h == 0)
		return 0;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}

	for(int i = 0; i < 4; i++)
		cin >> c[i];

	return 1;
}

int solve(void) {
	priority_queue<robot> q;
	int use[35][35][4];
	memset(use, -1, 35 * 35 * 4 * sizeof(int));

	q.push(robot());
	while(!q.empty()) {
		robot now = q.top();
		q.pop();

		if(use[now.x][now.y][now.v] == -1) {
			use[now.x][now.y][now.v] = now.c;
		}

		else
			continue;

		if(now.x == w - 1 && now.y == h - 1){
			return now.c;
		}

		for(int i = 0; i < 4; i++) {
			robot temp = now;
			if(temp.next(i)){
					q.push(temp);
			}
		}
	}
	return -1;
}

int main(void) {
	while(input()){
		cout << solve() << endl;
	}
	return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <tuple>
using namespace std;

enum { STRAIGHT, RIGHT, BACK, LEFT, D };

constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};
constexpr int MAX_SIZE = 30;

int w, h;
int s[MAX_SIZE][MAX_SIZE];
int c[D];

int dist[MAX_SIZE][MAX_SIZE][D];

inline bool out(int x, int y) {
	return x < 0 || y < 0 || x >= w || y >= h;
}

int dijkstra() {
	typedef tuple<int, int, int, int> state;

	priority_queue<state, vector<state>, greater<state>> que;
	fill_n((int *)dist, sizeof(dist) / sizeof(int), INT_MAX);

	que.push(state(0, 0, 0, 0));
	dist[0][0][0] = 0;

	while(!que.empty()) {
		int d, x, y, dir;
		tie(d, x, y, dir) = que.top();
		que.pop();

		if(dist[x][y][dir] < d) continue;
		if(x == w - 1 && y == h - 1) return d;

		for(int command = 0; command < 4; ++command) {
			const int next_dir = (dir + command) & 0x3;
			const int nx = x + dx[next_dir];
			const int ny = y + dy[next_dir];

			if(out(nx, ny)) continue;

			const int next_dist = d + (s[y][x] == command ? 0 : c[command]);
			if(dist[nx][ny][next_dir] > next_dist) {
				dist[nx][ny][next_dir] = next_dist;
				que.push(state(next_dist, nx, ny, next_dir));
			}
		}
	}

	assert(false);
}

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

	while(cin >> w >> h && w) {
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				cin >> s[i][j];
			}
		}

		for(int i = 0; i < D; ++i) {
			cin >> c[i];
		}

		cout << dijkstra() << endl;
	}

	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'int dijkstra()':
a.cc:29:57: error: 'INT_MAX' was not declared in this scope
   29 |         fill_n((int *)dist, sizeof(dist) / sizeof(int), INT_MAX);
      |                                                         ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include <queue>
  +++ |+#include <climits>
    6 | #include <tuple>
Language: C++

#include <iostream>
#include <queue>
using namespace std;
#define INF INT_MAX
int G[30][30];
int c[4];
//
const int dirx[] = {-1, 0, 1, 0};
const int diry[] = { 0,-1, 0, 1};

class State{
  public:
    int x;
    int y;
    int dir;
    int cost;
    State(int x, int y, int dir, int cost){
      this->x=x;this->y=y;this->dir=dir;this->cost=cost;
    }
    bool operator < (const State &s)const{
      return cost > s.cost;
    }
};

int main(void){
  int w, h;
  while(cin >> w >> h, w | h){
    for(int i=0; i < h; i++){
      for(int j=0; j < w; j++){
        cin >> G[i][j];
      }
    }
    for(int i=0; i < 4; i++){
      cin >> c[i];
    }

    int d[30][30][4];
    vector<vector <bool> > used(30, vector<bool>(30, false));
    fill(d[0][0], d[0][0] + 30*30*4, INF);
    d[0][0][2] = 0;
    priority_queue<State> pq;
    pq.push(State(0, 0, 2, 0));
    while(!pq.empty()){
      State s = pq.top(); pq.pop();
      used[s.y][s.x] = true;
      for(int i=0; i < 4; i++){
        int ndir = (s.dir+i) % 4;
        int nx = s.x + dirx[ndir]; int ny = s.y + diry[ndir];
        if(!(nx >= 0 && nx < w && ny >= 0 && ny < h)) continue;
        if(G[s.y][s.x] == i){
          if(d[s.y][s.x][s.dir] < d[ny][nx][ndir]){
            d[ny][nx][ndir] = d[s.y][s.x][s.dir];
            pq.push(State(nx, ny, ndir, d[ny][nx][ndir]));
          }
        }else{
          if(d[s.y][s.x][s.dir] + c[i] < d[ny][nx][ndir]){
            d[ny][nx][ndir] = d[s.y][s.x][s.dir] + c[i];
            pq.push(State(nx, ny, ndir, d[ny][nx][ndir]));
          }
        }
      }
    }
    cout << min(d[h-1][w-1][0], min(d[h-1][w-1][1], min(d[h-1][w-1][2], d[h-1][w-1][3]))) << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:13: error: 'INT_MAX' was not declared in this scope
    4 | #define INF INT_MAX
      |             ^~~~~~~
a.cc:39:38: note: in expansion of macro 'INF'
   39 |     fill(d[0][0], d[0][0] + 30*30*4, INF);
      |                                      ^~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <queue>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include <iostream>
#include <climits>
#include <queue>
#include <functional>
int field[30][30] = { 0 };
int m[4][30][30]; //[??????][y][x] = ????°??????????
int costs[4] = { 0 };
int dx[] = { 1, 0, -1, 0, 1, 0, -1, 0 }, dy[] = {0, 1, 0, -1, 0, 1, 0, -1 };

struct Node{
	int x, y, cost = 0, d;
	bool operator < (const Node& rhs) const {
		return cost < rhs.cost;
	}
	bool operator < (Node&& rhs) const {
		return cost < rhs.cost;
	}
	bool operator > (const Node& rhs) const {
		return cost > rhs.cost;
	}
	bool operator > (Node&& rhs) const {
		return cost > rhs.cost;
	}
};

int main() {
	int w, h;
	while (std::cin >> w >> h && (w || h)) {
		std::memset(m, 0x7f, sizeof(int) * 4 * 30 * 30);
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				std::cin >> field[i][j];
			}
		}
		for (int i = 0; i < 4; i++) std::cin >> costs[i];

		std::priority_queue<Node, std::vector<Node>, std::greater<Node>> q;
		q.push({0, 0, 0, 0});
		bool isOk = false;
		int minCost = INT_MAX;
		while (!q.empty() && !isOk) {
			Node node = q.top(); q.pop();
			if (node.x == w - 1 && node.y == h - 1) {
				isOk = true;
				minCost = node.cost;
			}

			for (int i = 0; i < 4; i++) {
				Node next = node;
				if (i == 1) next.d++;
				else if (i == 2) next.d += 2;
				else if (i == 3) next.d--;
				if (next.d < 0) next.d = 4 + next.d;
				else if (next.d >= 4) next.d = next.d - 4;

				next.x += dx[next.d];
				next.y += dy[next.d];
				if (field[node.y][node.x] != i) next.cost += costs[i];

				if (next.x < 0 || next.x >= w || next.y < 0 || next.y >= h) continue;
				if (m[next.d][next.y][next.x] <= next.cost) continue;
				m[next.d][next.y][next.x] = next.cost;
				q.push(next);
			}
		}
		std::cout << minCost << std::endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:22: error: 'memset' is not a member of 'std'; did you mean 'wmemset'?
   29 |                 std::memset(m, 0x7f, sizeof(int) * 4 * 30 * 30);
      |                      ^~~~~~
      |                      wmemset
Language: C++

#include <iostream>
#include <queue>
using namespace std;
#define MAXH 31
#define MAXW MAXH
#define MAXC 4
#define INF (1<<20)
typedef enum {STRA=0,RIGHT=1,BACK=2,LEFT=3,STOP=4} TYPE;
int W,H;
int F[MAXH][MAXW];
int cost[MAXC+1]; // cost[STOP]=0;
int D[MAXH][MAXW][4];
bool visited[MAXH][MAXW][4];

class State {
public:
  int i,j,d,c; // i,j,direction,cost
  State (int i, int j, int d, int c) : i(i),j(j),d(d),c(c) {}
  bool operator < (const State &s) const {
    return c > s.c;
  }
};

bool ok(int i, int j) {
  return 1 <= i && i <= H && 1 <= j && j <= W;
}

int solve() {
  priority_queue<State> PQ;
  for(int i=1;i<=H;i++) {
    for(int j=1;j<=W;j++) {
      for(int k=0;k<MAXC;k++) {
	D[i][j][k]=INF;
      }
    }
  }
  memset(visited,0,sizeof(visited));
  PQ.push(State(1,1,RIGHT,0));
  D[1][1][RIGHT]=0;
  // x=>l, y=>k
  int di[][4]={ {-1, 0, 1, 0},
		{ 0, 1, 0,-1},
		{ 1, 0,-1, 0},
		{ 0,-1, 0, 1}};
  int dj[][4]={ { 0, 1, 0,-1},
		{ 1, 0,-1, 0},
		{ 0,-1, 0, 1},
		{-1, 0, 1, 0}};
  while(!PQ.empty()) {
    State u = PQ.top(); PQ.pop();
    int i = u.i, j=u.j, d=u.d, c=u.c;
    if(i==H&&j==W) {
      return D[i][j][d];
    }
    visited[i][j][d]=true;
    
    for(int k=0;k<4;k++) {
      int ui = i + di[d][k];
      int uj = j + dj[d][k];
      if(!ok(ui,uj)) continue;
      if(k == F[i][j]) { // no cost
	int _cost = D[i][j][d] + 0;
	if(_cost < D[ui][uj][(d+k)%4]) {
	  D[ui][uj][(d+k)%4] = _cost;
	  PQ.push(State(ui,uj,(d+k)%4,_cost));
	}
      } else { // have to pay cost
	int _cost = D[i][j][d] + cost[k];
	if(_cost < D[ui][uj][(d+k)%4]) {
	  D[ui][uj][(d+k)%4] = _cost;
	  PQ.push(State(ui,uj,(d+k)%4,_cost));
	}
      }
    } // for4
    
  }
}

main() {
  while(cin>>W>>H,W) {
    for(int i=1;i<=H;i++) {
      for(int j=1;j<=W;j++) {
	cin>>F[i][j];
      }
    }
    for(int i=0;i<MAXC;i++) 
      cin>>cost[i];
    cout << solve() << endl;
  }
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:37:3: error: 'memset' was not declared in this scope
   37 |   memset(visited,0,sizeof(visited));
      |   ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | using namespace std;
a.cc: At global scope:
a.cc:79:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   79 | main() {
      | ^~~~
a.cc: In function 'int solve()':
a.cc:77:1: warning: control reaches end of non-void function [-Wreturn-type]
   77 | }
      | ^
Language: C++

#include <iostream>
#include <queue>

using namespace std;

class Node{
public:
	int x, y, d, cost;
	Node(int x, int y, int d, int cost) : x(x), y(y), d(d), cost(cost) {}
	bool operator < (const Node &n) const { return cost > n.cost; }
};

char dx[] = {0,1,0,-1};
char dy[] = {1,0,-1,0};

int main(){
	int w, h;
	int op[4];
	int b[30][30];
	int c[30][30][4];
	while(cin >> w >> h){
		if(!(w||h)) break;
		memset(c, -1, sizeof(c));
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++) cin >> b[i][j];
		}
		for(int i=0;i<4;i++) cin >> op[i];
		priority_queue<Node> qu;
		qu.push(Node(0,0,0,0));
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			int x = nd.x, y = nd.y, d = nd.d, cost = nd.cost;
			if(c[x][y][d]!=-1) continue;
			c[x][y][d] = cost;
			for(int i=0;i<4;i++){
				int nx = x + dx[i], ny = y + dy[i];
				if(nx<0||nx>=h||ny<0||ny>=w) continue;
				if(b[x][y]!=4&&(b[x][y]+d)%4==i){
					qu.push(Node(nx,ny,i,cost));
				} else {
					qu.push(Node(nx,ny,i,cost+op[(4+i-d)%4]));
				}
			}
		}
		int ans = 9999999;
		for(int i=0;i<4;i++){
			if(c[h-1][w-1][i]!=-1) ans = min(ans,c[h-1][w-1][i]);
		}
		cout << ans << endl;
	}
}

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

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

typedef pair<int, pair<int, int> > pip;

int dx[] = {
	1, 0, -1, 0
};
int dy[] = {
	0, 1, 0, -1
};

int w, h;
int area[31][31];
int min_cost[31][31][4];
int c[4];

void bfs(){
	queue<pip> qp;
	qp.push(make_pair(0, make_pair(1, 1)));
	while(!qp.empty()){
		pip p = qp.front(); qp.pop();
		int y = p.second.first;
		int x = p.second.second;
		int d = p.first;
		for(int i = 0; i < 4; i++){
			int y2 = y+dy[(d+i)%4];
			int x2 = x+dx[(d+i)%4];
			if(y2 < 1 || y2 > h || x2 < 1 || x2 > w) continue;
			int cost = 0;
			int d2 = (d+i)%4;
			if(area[y][x] != i) cost = c[i];
			if(min_cost[y2][x2][d2] < 0 || min_cost[y][x][d] + cost < min_cost[y2][x2][d2]){
				min_cost[y2][x2][d2] = min_cost[y][x][d] + cost;
				qp.push(make_pair(d2, make_pair(y2, x2)));
			}
		}
	}
}

int main(){
	while(cin >> w >> h && (w || h)){
		memset(min_cost, -1, sizeof(min_cost));
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				cin >> area[i][j];
			}
		}
		for(int i = 0; i < 4; i++){
			cin >> c[i];
		}
		min_cost[1][1][0] = 0;
		bfs();
		int cost = 10000;
		for(int i = 0; i < 4; i++){
			if(min_cost[h][w][i] > 0) cost = min(cost, min_cost[h][w][i]);
		}
		cout << cost << endl;
	}
}

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

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

typedef pair<int, pair<int, int> > pip;

int dx[] = {
	1, 0, -1, 0
};
int dy[] = {
	0, 1, 0, -1
};

int w, h;
int area[31][31];
int min_cost[31][31][4];
int c[4];

void bfs(){
	queue<pip> qp;
	qp.push(make_pair(0, make_pair(1, 1)));
	while(!qp.empty()){
		pip p = qp.front(); qp.pop();
		int y = p.second.first;
		int x = p.second.second;
		int d = p.first;
		for(int i = 0; i < 4; i++){
			int y2 = y+dy[(d+i)%4];
			int x2 = x+dx[(d+i)%4];
			if(y2 < 1 || y2 > h || x2 < 1 || x2 > w) continue;
			int cost = 0;
			int d2 = (d+i)%4;
			if(area[y][x] != i) cost = c[i];
			if(min_cost[y2][x2][d2] < 0 || min_cost[y][x][d] + cost < min_cost[y2][x2][d2]){
				min_cost[y2][x2][d2] = min_cost[y][x][d] + cost;
				qp.push(make_pair(d2, make_pair(y2, x2)));
			}
		}
	}
}

int main(){
	while(cin >> w >> h && (w || h)){
		memset(min_cost, -1, sizeof(min_cost));
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				cin >> area[i][j];
			}
		}
		for(int i = 0; i < 4; i++){
			cin >> c[i];
		}
		min_cost[1][1][0] = 0;
		bfs();
		int cost = 10000;
		for(int i = 0; i < 4; i++){
			if(min_cost[h][w][i] > 0) cost = min(cost, min_cost[h][w][i]);
		}
		cout << cost << endl;
	}
}

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

#include <iostream>
#include <cstdlib>
#include <memory>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;

typedef pair<int, pair<int, int> > pip;

int dx[] = {
	1, 0, -1, 0
};
int dy[] = {
	0, 1, 0, -1
};

int w, h;
int area[31][31];
int min_cost[31][31][4];
int c[4];

void bfs(){
	queue<pip> qp;
	qp.push(make_pair(0, make_pair(1, 1)));
	while(!qp.empty()){
		pip p = qp.front(); qp.pop();
		int y = p.second.first;
		int x = p.second.second;
		int d = p.first;
		for(int i = 0; i < 4; i++){
			int y2 = y+dy[(d+i)%4];
			int x2 = x+dx[(d+i)%4];
			if(y2 < 1 || y2 > h || x2 < 1 || x2 > w) continue;
			int cost = 0;
			int d2 = (d+i)%4;
			if(area[y][x] != i) cost = c[i];
			if(min_cost[y2][x2][d2] < 0 || min_cost[y][x][d] + cost < min_cost[y2][x2][d2]){
				min_cost[y2][x2][d2] = min_cost[y][x][d] + cost;
				qp.push(make_pair(d2, make_pair(y2, x2)));
			}
		}
	}
}

int main(){
	while(cin >> w >> h && (w || h)){
		memset(min_cost, -1, sizeof(min_cost));
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				cin >> area[i][j];
			}
		}
		for(int i = 0; i < 4; i++){
			cin >> c[i];
		}
		min_cost[1][1][0] = 0;
		bfs();
		int cost = 10000;
		for(int i = 0; i < 4; i++){
			if(min_cost[h][w][i] > 0) cost = min(cost, min_cost[h][w][i]);
		}
		cout << cost << endl;
	}
}

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

// ACM-ICPCà\I2008 D. ¿åë¿åë{bg

#include <iostream>
#include <queue>

using namespace std;

class Node{
public:
	int x, y, d, cost;
	Node(int x, int y, int d, int cost) : x(x), y(y), d(d), cost(cost) {}
	bool operator < (const Node &n) const { return cost > n.cost; }
};

char dx[] = {0, 1, 0, -1};
char dy[] = {1, 0, -1, 0};

int main(){
	int w, h;
	int op[4];
	int b[30][30];
	int c[30][30][4];
	while(cin >> w >> h, w){
		memset(c, -1, sizeof(c));
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++) cin >> b[i][j];
		}
		for(int i=0;i<4;i++) cin >> op[i];
		priority_queue<Node> qu;
		qu.push(Node(0,0,0,0));
		int ans = 9999999;
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			int x = nd.x, y = nd.y, d = nd.d, cost = nd.cost;
			if(c[x][y][d]!=-1) continue;
			if(x==h-1&&y==w-1) { ans = cost; break; }
			c[x][y][d] = cost;
			for(int i=0;i<4;i++){
				int nx = x + dx[i], ny = y + dy[i];
				if(nx<0||nx>=h||ny<0||ny>=w) continue;
				if(b[x][y]!=4&&(b[x][y]+d)%4==i)
					qu.push(Node(nx,ny,i,cost));
				else
					qu.push(Node(nx,ny,i,cost+op[(4+i-d)%4]));
			}
		}
		cout << ans << endl;
	}
}

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

//SPFA
#include <cstdio>
#include <cstring>
#include<queue>
using namespace std;
#define INF (10*900*4)
#define rep(i,n) for(i=0;i<(n);i++)
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

struct Node{
	int y,x,dir;
};

void _a(Node *a){a->y+=dy[a->dir];a->x+=dx[a->dir];}
void _b(Node *a){a->dir=(a->dir+1)%4;_a(a);}
void _c(Node *a){a->dir=(a->dir+2)%4;_a(a);}
void _d(Node *a){a->dir=(a->dir-1+4)%4;_a(a);}
void _e(Node *a){}
void (*action[5])(struct Node *)={_a,_b,_c,_d,_e};

int in(int y,int x,int h,int w){
	return 0<=y&&y<h&&0<=x&&x<w;
}

int main(){
	queue<Node> que;
	int inQ[30][30][4],dst[30][30][4];
	int head,tail;	
	Node a,b;
	
	int w,h,s[30][30],c[4];
	int i,j,k,ans;
	while(scanf("%d%d",&w,&h)==2&&(w||h)){
		rep(i,h)
			rep(j,w)scanf("%d",&s[i][j]);
		rep(i,4)scanf("%d",c+i);
		memset(inQ,0,sizeof(inQ));
		rep(i,h)rep(j,w)rep(k,4)dst[i][j][k]=INF;
		a.y=a.x=a.dir=0;
		while(!que.empty())que.pop();
		dst[a.y][a.x][a.dir]=0;
		que.push(a);
		while(head<tail){
			a=que.front();
			qu.pop();
			inQ[a.y][a.x][a.dir]=0;
			b=a;
			action[s[b.y][b.x]](&b);
			if(in(b.y,b.x,h,w) && dst[a.y][a.x][a.dir] < dst[b.y][b.x][b.dir]){
				dst[b.y][b.x][b.dir] = dst[a.y][a.x][a.dir];
				if(inQ[b.y][b.x][b.dir]==0){
					qu.push(b);
					inQ[b.y][b.x][b.dir]=1;
				}
			}
			rep(i,4){
				b=a;
				action[i](&b);
				if(in(b.y,b.x,h,w) && dst[a.y][a.x][a.dir]+c[i] < dst[b.y][b.x][b.dir]){
					dst[b.y][b.x][b.dir] = dst[a.y][a.x][a.dir]+c[i];
					if(inQ[b.y][b.x][b.dir]==0){
						qu.push(b);
						inQ[b.y][b.x][b.dir]=1;
					}
				}
			}
		}
		ans=INF;
		rep(i,4){
			if(dst[h-1][w-1][i] < ans)ans = dst[h-1][w-1][i];
		}
		printf("%d\n",ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:25: error: 'qu' was not declared in this scope; did you mean 'que'?
   46 |                         qu.pop();
      |                         ^~
      |                         que
Language: C++

//SPFA
#include <cstdio>
#include <cstring>
#include<queue>
using namespace std;
#define INF (10*900*4)
#define rep(i,n) for(i=0;i<(n);i++)
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

struct Node{
	int y,x,dir;
};

void _a(Node *a){a->y+=dy[a->dir];a->x+=dx[a->dir];}
void _b(Node *a){a->dir=(a->dir+1)%4;_a(a);}
void _c(Node *a){a->dir=(a->dir+2)%4;_a(a);}
void _d(Node *a){a->dir=(a->dir-1+4)%4;_a(a);}
void _e(Node *a){}
void (*action[5])(struct Node *)={_a,_b,_c,_d,_e};

bool in(int y,int x,int h,int w){
	return 0<=y&&y<h&&0<=x&&x<w;
}

int main(){
	queue<Node> que;
	bool inQ[30][30][4];
	int dst[30][30][4];
	Node a,b;
	
	int w,h,s[30][30],c[4];
	int i,j,k,ans;
	while(scanf("%d%d",&w,&h)==2&&(w||h)){
		rep(i,h)
			rep(j,w)scanf("%d",&s[i][j]);
		rep(i,4)scanf("%d",c+i);
		memset(inQ,false,sizeof(inQ));
		rep(i,h)rep(j,w)rep(k,4)dst[i][j][k]=INF;
		a.y=a.x=a.dir=0;
		while(!que.empty())que.pop();
		dst[a.y][a.x][a.dir]=0;
		que.push(a);
		while(!que.empty()){
			a=que.front();
			que.pop();
			inQ[a.y][a.x][a.dir]=false;
			b=a;
			action[s[b.y][b.x]](&b);
			if(in(b.y,b.x,h,w) && dst[a.y][a.x][a.dir] < dst[b.y][b.x][b.dir]){
				dst[b.y][b.x][b.dir] = dst[a.y][a.x][a.dir];
				if(!inQ[b.y][b.x][b.dir]){
					que.push(b);
					inQ[b.y][b.x][b.dir]=true;
				}
			}
			rep(i,4){
				b=a;
				action[i](&b);
				if(in(b.y,b.x,h,w) && dst[a.y][a.x][a.dir]+c[i] < dst[b.y][b.x][b.dir]){
					dst[b.y][b.x][b.dir] = dst[a.y][a.x][a.dir]+c[i];
					if(!inQ[b.y][b.x][b.dir]){
						que.push(b);
						inQ[b.y][b.x][b.dir]=true;
					}
				}
			}
		}
		printf("%d\n",*min_element(dst[h-1][w-1],dst[h-1][w-1]+4));
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:69:32: error: 'min_element' was not declared in this scope
   69 |                 printf("%d\n",*min_element(dst[h-1][w-1],dst[h-1][w-1]+4));
      |                                ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>

using namespace std;
#define MAX_COST 100
#define INF 999999999
typedef pair<int, int> P;
typedef pair<P, P> PP; // h, w, cost, direction
struct
{
	int to;
	int cost;
};
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

void solve()
{
	int w, h;
	while(cin >> w >> h, w || h)
	{
		vector< vector<int> > order(h, vector<int>(w));
		for(int i = 0; i < h; ++i)
		{
			for(int j = 0; j < w; ++j)
			{
				cin >> order[i][j];
			}
		}
		int c[4];
		for(int i = 0; i < 4; ++i)
		{
			cin >> c[i];
		}
		int dist[31][31][4];
		for(int i = 0; i < h; ++i)
		{
			for(int j = 0; j < w; ++j)
			{
				for(int k = 0; k < 4; ++k)
				{
					dist[i][j][k] = INF;
				}
			}
		}
		dist[0][0][1] = 0;
		priority_queue<PP, vector<PP>, greater<PP> > pq;
		pq.push(PP(P(0, 0), P(0, 1)));
		while(!pq.empty())
		{
			PP pp = pq.top();
			int y = pq.top().first.first;
			int x = pq.top().first.second;
			int sum_cost = pq.top().second.first;
			int dir = pq.top().second.second;
			pq.pop();
			if(dist[y][x][dir] < sum_cost)
			{
				continue;
			}
			for(int i = 0; i < 4; ++i)
			{
				int cost = c[i];
				if(order[y][x] == i)
				{
					cost = 0;
				}
				int prev = dir;
				int next = (prev + i) % 4;
				int nx = x + dx[next];
				int ny = y + dy[next];

				if(nx < 0 || nx >= w || ny < 0 || ny >= h)
				{
					continue;	
				}
				if(dist[ny][nx][next] > sum_cost + cost)
				{
					dist[ny][nx][next] = sum_cost + cost;
					pq.push(PP(P(ny, nx), P(sum_cost + cost, next)));
				}
			}
		}
		int min_cost = INF;
		for(int i = 0; i < 4; ++i)
		{
			if(min_cost > dist[h - 1][w - 1][i])
			{
				min_cost = dist[h - 1][w - 1][i];
			}
		}
		cout << min_cost << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Compiler output:
a.cc:14:1: error: abstract declarator '<unnamed struct>' used as declaration
   14 | };
      | ^
Language: C++


 #include<iostream>
 #include<algorithm>
 #include<set>
 #include<map>
 using namespace std;
 typedef set<int> Shape;
 #define MAX 12
 int W, H, C[MAX][MAX], ncell, sx, sy, tx, ty, sd, td, flip;
 bool V[MAX][MAX];
 map<Shape, bool> U;
 
 void rotate( int &x, int &y ){
     if ( td == 1 ){ swap( x, y ); x *= (-1);}
     else if ( td == 2 ) { x *= (-1); y *= (-1);}
     else if ( td == 3 ) { swap( x, y ); y *= (-1);}
     x *= flip;
 }
 
 bool dfs( Shape shape ){
     if ( shape.size() == ncell ) return true;
     
     U[shape] = true;
     
     static const int dx[4] = {0, -1, 0, 1};
     static const int dy[4] = {1, 0, -1, 0};
     int nx, ny, tnx, tny, diffx, diffy;
     Shape nextS;
     
     for ( Shape::iterator it = shape.begin(); it != shape.end(); it++ ){
        for ( int d = 0; d < 4; d++ ){
             nx = (*it)/W + dx[d];
            ny = (*it)%W + dy[d];
             if ( !C[nx][ny] || V[nx][ny] ) continue;
             diffx = nx - sx;
             diffy = ny - sy;
             rotate( diffx, diffy );
             tnx = tx + diffx;
             tny = ty + diffy;
             if ( nx == tnx && ny == tny ) continue;
             if ( !C[tnx][tny] || V[tnx][tny] ) continue;
             nextS = shape;
             nextS.insert( nx*W + ny );
             if ( U[nextS] ) continue;
             V[nx][ny] = V[tnx][tny] = true;
             if ( dfs( nextS ) ) return true;
             V[nx][ny] = V[tnx][tny] = false;
         }
     }
     return false;
}
 
bool parse(){
    U = map<Shape, bool>();
    for ( int x = 1; x <= H; x++ ){
        for ( int y = 1; y <= W; y++ ) V[x][y] = 0;
     }
     Shape shape;
     shape.insert( sx*W + sy );
     U[shape] = true;
     V[sx][sy] = V[tx][ty] = true;
     return dfs( shape );
 }
 
 bool check(){
     if ( ncell % 2 != 0 || ncell < 2 ) return false;
     ncell /= 2;
     for ( tx = 1; tx <= H; tx++ ){
         for ( ty = 1; ty <= W; ty++ ){
             if ( (tx == sx && ty == sy) || C[tx][ty] == 0) continue;
             for ( td = 0; td < 4; td++ ){
                 flip = 1;
                 if ( parse() ) return true;
                 flip = -1;
                 if ( parse() ) return true;
             }
       }
     }
     return false;
 }
 
int main(){

     while( cin >> W >> H && ( W && H ) ){
         ncell = 0;
         sx = sy = -1;
         for ( int x = 0; x < H + 2; x++ ){a
             for ( int y = 0; y < W + 2; y++ ){
                 C[x][y] = 0;
                 if ( 1 <= x && 1 <= y && x <= H && y <= W ) cin >> C[x][y];
                 if ( C[x][y] ) ncell++;
                 if ( C[x][y] && sx == -1 ){ sx = x; sy = y; }
             }
         }
         if ( check() ) cout << "YES" << endl;
         else cout << "NO" << endl;
     }
	 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:44: error: 'a' was not declared in this scope
   87 |          for ( int x = 0; x < H + 2; x++ ){a
      |                                            ^
a.cc:88:31: error: 'y' was not declared in this scope
   88 |              for ( int y = 0; y < W + 2; y++ ){
      |                               ^
Language: Java

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

public class Main{
 public static void main(String[] args){
  Scanner sc=new Scanner(System.in);
  int n=1,p=1,judge=0;
  ArrayList<Integer> mayor =new ArrayList<Integer>();
  for(int i=0;i<50;i++){
   mayor.add(i,0);
  }
  ArrayList<Integer> winner =new ArrayList<Integer>();
  int k=0;
  while(n!=0||p!=0){
  n=sc.nextInt();
  p=sc.nextInt();
  for(int i=0;i<n;i++){
   mayor.set(i,0);
  }
  while(judge!=n-1){
   for(int i=0;i<n;i++){
    judge=0;
    if(p>0){
     p--;
    mayor.set(i,mayor.get(i)+1);
   }else{
    p+=mayor.get(i);
    mayor.set(i,0);
   }
   if(mayor.get(i)!=0){
   for(int j=0;j<n;j++){
    if(mayor.get(j)==0)
    judge++;
  }
  }
   if(judge==n-1){
    winner.add(k,mayor.get(i));
    break;
    }
   }
   }
   k++;
  }

  for(int j=0;j<k;j++){
   System.out.println(winner.get(j));
  }
 }
 }

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.Scanner;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.ArrayList;
^
2 errors
Language: Java

class main {
	public static void main(String[] args) {
		while (true) {
			Scanner s = new Scanner(System.in);

			String[] line = s.nextLine().split(" ");
            int n = Integer.parseInt(line[0]);
            int p = Integer.parseInt(line[1]);



			//int n = s.nextInt();
			//int p = s.nextInt();
			if (n == 0 && p == 0) {
				break;
			}
			int pos = 0;
			int wan = p;
			int person[] = new int[n];
			for (int i = 0; i < n; i++) {
				person[i] = 0;
			}
			while (true) {
				if (wan != 0) {
					person[pos]++;
					wan--;
					if (person[pos] == p) {
						break;
					} // if2
				} // if2
				else {
					wan = person[pos];
					person[pos] = 0;
				} // else
				pos++;
				if (pos == n) {
					pos = 0;
				} // if3
			} // while2
			System.out.println(pos);
		} // while1
	}// method
}// class

Compiler output:
Main.java:4: error: cannot find symbol
			Scanner s = new Scanner(System.in);
			^
  symbol:   class Scanner
  location: class main
Main.java:4: error: cannot find symbol
			Scanner s = new Scanner(System.in);
			                ^
  symbol:   class Scanner
  location: class main
2 errors
Language: Java

import java.util.Scanner;

public class main {
	public static void main(String[] args) {
		while (true) {
			Scanner s = new Scanner(System.in);
			int n = s.nextInt();
			int p = s.nextInt();
			if (n == 0 && p == 0) {
				break;
			}
			int pos = 0;
			int wan = p;
			int person[] = new int[n];
			for (int i = 0; i < n; i++) {
				person[i] = 0;
			}
			while (true) {
				if (wan != 0) {
					person[pos]++;
					wan--;
					if (person[pos] == p) {
						break;
					} // if2
				} // if2
				else {
					wan = person[pos];
					person[pos] = 0;
				} // else
				pos++;
				if (pos == n) {
					pos = 0;
				} // if3
			} // while2
			System.out.println(pos);
		} // while1
	}// method
}// class

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

class Main {
	public static void main(String[] args) {
		while (true) {
			Scanner s = new Scanner(System.in);
			int n = s.nextInt();
			int p = s.nextInt();
			if (n == 0 && p == 0) {
				break;
			}
			int pos = 0;
			int wan = p;
			int person[] = new int[n];
			for (int i = 0; i < n; i++) {
				person[i] = 0;
			}
			while (true) {
				if (wan != 0) {
					person[pos]++;
					wan--;
					if (person[pos] == p) {
						break;
					} // if2
				} // if2
				else {
					wan = person[pos];
					person[pos] = 0;
				} // else
				pos++;
				if (pos == n) {
					pos = 0;
				} // if3
			} // while2
			System.out.println(pos);
		} // while1
	}// method
}// class

Compiler output:
Main.java:4: error: cannot find symbol
			Scanner s = new Scanner(System.in);
			^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
			Scanner s = new Scanner(System.in);
			                ^
  symbol:   class Scanner
  location: class Main
2 errors