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

#include<iostream>
#include<set>
#include<vector>
#include<string>

using namespace std;

vector<string> solve(string s,int st){
	vector<string> ans;
	
	string s1 = s.substr(0,st);
	string s2 = s.substr(st,s.size()-st);
	
	// 両方正
	ans.push_back(s1+s2);
	ans.push_back(s2+s1);

	reverse(s1.begin(),s1.end());

	//s1が逆
	ans.push_back(s1+s2);
	ans.push_back(s2+s1);

	reverse(s2.begin(),s2.end());

	//両方逆
	ans.push_back(s1+s2);
	ans.push_back(s2+s1);

	reverse(s1.begin(),s1.end());

	//s2が逆
	ans.push_back(s1+s2);
	ans.push_back(s2+s1);

	return ans;
}

int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		set<string> s;
		string buf;
		cin >> buf;
		for(int j=1;j<buf.size();j++){
			vector<string> buf2 = solve(buf,j);
			for(int k=0;k<buf2.size();k++){
				s.insert(buf2[k]);
			}
		}

		cout << s.size() << endl;
	}
}

Compiler output:
a.cc: In function 'std::vector<std::__cxx11::basic_string<char> > solve(std::string, int)':
a.cc:18:9: error: 'reverse' was not declared in this scope
   18 |         reverse(s1.begin(),s1.end());
      |         ^~~~~~~
Language: C++

// AOJ 1142

#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(void)
{
	int m;
	cin >> m;
	while (m--){
		string str;
		map <string, int> mydata;
		cin >> str;
		for (int i = 1; i < (int)str.length(); i++){
			string first = str.substr(0, i);
			string second = str.substr(i, (int)str.length() - i);
			string frev = first; reverse(frev.begin(), frev.end());
			string srev = second; reverse(srev.begin(), srev.end());
			// cout << first << " " << second << endl;

			// そのまま＋そのまま
			mydata[first + second]++;
			// はんてん＋そのまま
			mydata[frev + second]++;
			// そのまま＋はんてん
			mydata[first + srev]++;
			// はんてん＋はんてん
			mydata[frev + srev]++;

			// いれかえする
			// そのまま＋そのまま
			mydata[second + first]++;
			// そのまま＋はんてん
			mydata[second + frev]++;
			// はんてん＋そのまま
			mydata[srev + first]++;
			// はんてん＋はんてん
			mydata[srev + frev]++;
		}

		cout << mydata.size() << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:46: error: 'reverse' was not declared in this scope
   20 |                         string frev = first; reverse(frev.begin(), frev.end());
      |                                              ^~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <set>


using namespace std;

int main(void){
	int n;
	string str,sub1,sub2;

	cin >> n;

	for(int i=0;i<n;i++){
		set<string>	val;
		cin >> str;
		for(int j=1;j<str.length();j++){
			sub2=str.substr(j);
			sub1=str.substr(0,j);

			val.insert(sub1+sub2);
			val.insert(sub2+sub1);
			reverse(sub2.begin(),sub2.end());
			val.insert(sub1+sub2);
			val.insert(sub2+sub1);
			reverse(sub1.begin(),sub1.end());
			reverse(sub2.begin(),sub2.end());
			val.insert(sub1+sub2);
			val.insert(sub2+sub1);
			reverse(sub2.begin(),sub2.end());
			val.insert(sub1+sub2);
			val.insert(sub2+sub1);
		}
		cout << val.size() << endl;
	}

	return 0;
}

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

//Tue Dec 22 22:01:34 JST 2009
#include<set>
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  int path[8];
  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//
    return false;
  }
  
  void make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	S.insert(*this);
	Q.push(*this);
	cnt--;
      }
      return;
    }

    //don't move
    
    if (can_good_pos(now) ){
      path[now]=-1;
      make_next(now+1,Q,S,CANMOVE,NG);
    }

    if ( flag == CANNOTMOVE)return;//

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];

      path[now]=i;

      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	make_next(now+1,Q,S,CANNOTMOVE,NG);//
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
        
  }
  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  queue<state> Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    Q.pop();
if (20<cnt+(max(now.x[0],dx)-min(now.x[0],dy)+
max(now.y[0],dy)-min(now.y[0],dy))/2)continue;
    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    now.make_next(0,Q,S,CANMOVE,NG);
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(cin>>n && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)cin>>ini.x[i]>>ini.y[i];
    cin>>m;
    rep(i,m){
      int f,s;
      cin>>f>>s;
      NG.insert(mp(f,s));
    }
    cin>>dx>>dy;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Compiler output:
a.cc: In function 'int bfs(state, int, int, std::set<std::pair<int, int> >&)':
a.cc:97:8: error: 'cnt' was not declared in this scope; did you mean 'int'?
   97 | if (20<cnt+(max(now.x[0],dx)-min(now.x[0],dy)+
      |        ^~~
      |        int
a.cc: At global scope:
a.cc:108:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  108 | main(){
      | ^~~~
Language: Java

import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w, h;
		int x, y;
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0)
				break;
			Game game = new Game(w, h);
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					game.map[i][j] = sc.nextInt();
				}
			}
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(game.map[i][j] == 2){
						game.move(i, j, 0);
					}
				}
			}
			System.out.println(game.answer <= 10 ? game.answer : -1);
		}
	}

}
public class Game{
	int answer = 11;
	int w, h;
	int[][] map;
	int[] dx = new int[]{1, 0, -1, 0};
	int[] dy = new int[]{0, 1, 0, -1};
	Game(int iw, int ih){
		w = iw;
		h = ih;
		map = new int[h][w];
	}
	void move(int x, int y, int k){
		for(int i = 0; i < 4; i++){
			if(x+dx[i] < 0 || x+dx[i] >= h || y+dy[i] < 0 || y+dy[i] >= w)
				continue;
			if(map[x+dx[i]][y+dy[i]] != 1){
				switch(i){
				case 0:
					moveDown(x, y, k);
					break;
				case 1:
					moveRight(x, y, k);
					break;
				case 2:
					moveUp(x, y, k);
					break;
				case 3:
					moveLeft(x, y, k);
					break;
				}
			}
		}
	}
	void moveDown(int x, int y, int k){
		while(true){
			x = x + dx[0];
			y = y + dy[0];
			if(map[x][y] == 3){
				if(++k < answer)
					answer = k;
				break;
			}
			if(x == h-1)
				break;
			if(map[x+dx[0]][y+dy[0]] == 1){
				map[x+dx[0]][y+dy[0]] = 0;
				move(x, y, ++k);
				break;
			}
		}
	}
	void moveRight(int x, int y, int k){
		while(true){
			x = x + dx[1];
			y = y + dy[1];
			if(map[x][y] == 3){
				k++;
				if(k < answer)
					answer = k;
				break;
			}
			if(y == w-1)
				break;
			if(map[x+dx[1]][y+dy[1]] == 1){
				map[x+dx[1]][y+dy[1]] = 0;
				move(x, y, ++k);
				break;
			}
		}
	}
	void moveUp(int x, int y, int k){
		while(true){
			x = x + dx[2];
			y = y + dy[2];
			if(map[x][y] == 3){
				k++;
				if(k < answer)
					answer = k;
				break;
			}
			if(x == 0)
				break;
			if(map[x+dx[2]][y+dy[2]] == 1){
				map[x+dx[2]][y+dy[2]] = 0;
				move(x, y, ++k);
				break;
			}
		}
	}
	void moveLeft(int x, int y, int k){
		while(true){
			x = x + dx[3];
			y = y + dy[3];
			if(map[x][y] == 3){
				k++;
				if(k < answer)
					answer = k;
				break;
			}
			if(y == 0)
				break;
				if(map[x+dx[3]][y+dy[3]] == 1){
				map[x+dx[3]][y+dy[3]] = 0;
				move(x, y, ++k);
				break;
			}
		}
	}
}

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

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w, h;
		int x = 0, y = 0;
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0)
				break;
			Game game = new Game(w, h);
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					game.map[i][j] = sc.nextInt();
					if(game.map[i][j] == 2){
						x = i;
						y = j;
					}
				}
			}
			game.search(x, y, 0);
			System.out.println(game.answer <= 10 ? game.answer : -1);
		}
	}
}
public class Game{
	int answer = 11;
	int w, h;
	int[][] map;
	int[][] v = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
	Game(int iw, int ih){
		w = iw;
		h = ih;
		map = new int[h][w];
	}
	void search(int x, int y, int k){
		for(int i = 0; i < v.length; i++){
			int p = x, q = y;
			p += v[i][0];
			q += v[i][1];
			if(p < 0 || p >= h || q < 0 || q >= w)
				continue;
			if(map[p][q] == 1)
				continue;
			p -= v[i][0];
			q -= v[i][1];
			while(true){
				p += v[i][0];
				q += v[i][1];
				if(p < 0 || p >= h || q < 0 || q >= w)
					break;
				if(map[p][q] == 1){
					map[p][q] = 0;
					p -= v[i][0];
					q -= v[i][1];
					search(p, q, k+1);
					map[p][q] = 1;
				}	
				if(map[p][q] == 3){
					if(k+1 < answer)
						answer = k + 1;
					break;
				}
			}
		}
	}
}

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

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w, h;
		int x, y;
		while(true){
			x = 0;
			y = 0;
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0)
				break;
			Game game = new Game(w, h);
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					game.map[i][j] = sc.nextInt();
					if(game.map[i][j] == 2){
						x = i;
						y = j;
					}
				}
			}
			game.search(x, y, 0);
			System.out.println(game.answer <= 10 ? game.answer : -1);
		}
	}
}

public class Game{
	int answer = 11;
	int w, h;
	int[][] map;
	int[][] v = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
	Game(int iw, int ih){
		w = iw;
		h = ih;
		map = new int[h][w];
	}
	void search(int x, int y, int k){
		if(k >= answer)
			return;
		int p, q;
		for(int i = 0; i < v.length; i++){
			p = x + v[i][0];
			q = y + v[i][1];
			if(map[p][q] == 1)
				continue;
			while(p >= 0 && p < h && q >= 0 && q < w){
				if(map[p][q] == 1){
					map[p][q] = 0;
					search(p-v[i][0], q-v[i][1], k+1);
					map[p][q] = 1;
					break;
				}
				if(map[p][q] == 3){
					if(k+1 < answer)
						answer = k + 1;
					break;
				}
				p += v[i][0];
				q += v[i][1];
			}
		}
		return;
	}
}

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

public class Game{
	int answer = 11;
	int w, h;
	int[][] map;
	int[][] v = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
	Game(int iw, int ih){
		w = iw;
		h = ih;
		map = new int[h][w];
	}
	void search(int x, int y, int k){
		if(k >= answer)
			return;
		int p, q;
		for(int i = 0; i < v.length; i++){
			p = x + v[i][0];
			q = y + v[i][1];
			if(p < 0 || p >= h || q < 0 || q >= w || map[p][q] == 1)
				continue;
			while(p >= 0 && p < h && q >= 0 && q < w){
				if(map[p][q] == 1){
					map[p][q] = 0;
					search(p-v[i][0], q-v[i][1], k+1);
					map[p][q] = 1;
					break;
				}
				if(map[p][q] == 3){
					if(k+1 < answer)
						answer = k + 1;
					break;
				}
				p += v[i][0];
				q += v[i][1];
			}
		}
		return;
	}
}
class Game{
	int answer = 11;
	int w, h;
	int[][] map;
	int[][] v = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
	Game(int iw, int ih){
		w = iw;
		h = ih;
		map = new int[h][w];
	}
	boolean isInRange(int x, int y){
		return (x >= 0 && x < h && y >= 0 && y < w);
	}
	void search(int x, int y, int k){
		if(k >= answer)
			return;
		int p, q;
		for(int i = 0; i < v.length; i++){
			p = x + v[i][0];
			q = y + v[i][1];
			if(!isInRange(p, q) || map[p][q] == 1)
				continue;
			while(isInRange(p, q)){
				if(map[p][q] == 1){
					map[p][q] = 0;
					search(p-v[i][0], q-v[i][1], k+1);
					map[p][q] = 1;
					break;
				}
				if(map[p][q] == 3){
					if(k+1 < answer)
						answer = k + 1;
					break;
				}
				p += v[i][0];
				q += v[i][1];
			}
		}
		return;
	}
}

Compiler output:
Main.java:1: error: class Game is public, should be declared in a file named Game.java
public class Game{
       ^
Main.java:39: error: duplicate class: Game
class Game{
^
2 errors
Language: Java

import java.util.*;

public class Curling {

	static int startX, startY, goalX, goalY;
	static int[] moveX = {0,0,-1,1};
	static int[] moveY = {-1,1,0,0};
	static int w, h;
	static int maxMove = 10;
	static int ans;

	public static void finish (int move) {
		if (ans == -1) {
			ans = move;
		} else {
			ans = Math.min(move, ans);
		}
	}

	public static boolean ok (int y, int x) {
		return 0 <= y && y < h && 0 <= x && x < w;
	}

	public static void show (int[][] field) {

		for (int i = 0; i < field.length; i++) {
			for (int j = 0; j < field[i].length; j++) {
				System.out.printf("%2d ", field[i][j]);
			}
			System.out.println();
		}
		System.out.println();

	}

	public static void dfs (int y, int x, int move, int[][] field) {
//		System.out.println(y + "," + x + "   : " + move);
//		show(field);

		if (move == maxMove) return;

		for (int i = 0; i < moveX.length; i++) {

			if (ok(y + moveY[i],x + moveX[i]) &&
				field[y + moveY[i]][x + moveX[i]] != 1) {

				int nextY = y, nextX = x;

				while (ok(nextY + moveY[i],nextX + moveX[i])) {
					if (field[nextY + moveY[i]][nextX + moveX[i]] == 1) break;
					nextY += moveY[i];
					nextX += moveX[i];
					if (nextY == goalY && nextX == goalX) {
						finish(move + 1);
						return;
					}
				}

				boolean flag = false;

				if (ok(nextY + moveY[i],nextX + moveX[i])) {
					field[nextY + moveY[i]][nextX + moveX[i]]--;
					flag = true;
				}

				dfs(nextY,nextX,move + 1,field);

				if (flag) {
					field[nextY + moveY[i]][nextX + moveX[i]]++;
				}

			}

		}

	}

	public static void main(String[] args) {

		int[][] field;
		Scanner sc = new Scanner(System.in);

		while (true) {

			w = sc.nextInt();
			h = sc.nextInt();
			if (w == 0 && h == 0) break;
			ans = -1;
			field = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					field[i][j] = sc.nextInt();
					if (field[i][j] == 2) {
						startX = j;
						startY = i;
					} else if (field[i][j] == 3) {
						goalX = j;
						goalY = i;
					}
				}
			}
			dfs(startY, startX, 0, field);
			System.out.println("ans : " + ans);
		}

	}

}

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

import java.util.*;

public class Main {
	int w, h, sx, sy, ans;
	int[][] map;
	LinkedList<Integer> x, y;
	
	void loop(int p, int q, int r){
		if(r>=ans || r>=10) return;
		
		for(int i=p-1;i>=0;i--){
			if(map[q][i]==3){
				ans = r+1;
			}else if(map[q][i]==1){
				if(i==p-1){
					break;
				}else{
					map[q][i] = 0;
					x.push(i);
					y.push(q);
					loop(i+1, q, r+1);
					map[y.pop()][x.pop()] = 1;
					break;
				}
			}
		}
		
		for(int i=p+1;i<w;i++){
			if(map[q][i]==3){
				ans = r+1;
			}else if(map[q][i]==1){
				if(i==p+1){
					break;
				}else{
					map[q][i] = 0;
					x.push(i);
					y.push(q);
					loop(i-1, q, r+1);
					map[y.pop()][x.pop()] = 1;
					break;
				}
			}
		}
		
		for(int i=q-1;i>=0;i--){
			if(map[i][p]==3){
				ans = r+1;
			}else if(map[i][p]==1){
				if(i==q-1){
					break;
				}else{
					map[i][p] = 0;
					x.push(p);
					y.push(i);
					loop(p, i+1, r+1);
					map[y.pop()][x.pop()] = 1;
					break;
				}
			}
		}
		
		for(int i=q+1;i<h;i++){
			if(map[i][p]==3){
				ans = r+1;
			}else if(map[i][p]==1){
				if(i==q+1){
					break;
				}else{
					map[i][p] = 0;
					x.push(p);
					y.push(i);
					loop(p, i-1, r+1);
					map[y.pop()][x.pop()] = 1;
					break;
				}
			}
		}
	}

	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w==0 && h==0) break;
			
			map = new int[h][w];
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					map[i][j] = sc.nextInt();
					if(map[i][j]==2){
						sx = j;
						sy = i;
					}
				}
			}
			
			x = new LinkedList<Integer>();
			y = new LinkedList<Integer>();
			ans = Integer.MAX_VALUE;
			loop(sx, sy, 0);
			if(ans==Integer.MAX_VALUE) ans = -1;
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main.solve();
	}	
}

Compiler output:
Main.java:109: error: cannot find symbol
		new Main.solve();
		        ^
  symbol:   class solve
  location: class Main
1 error
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Curling2 {
	Scanner in = new Scanner(System.in);
	int W, H;
	int[][] map;
	int vx[] = {0, -1, 1, 0};
	int vy[] = {-1, 0, 0, 1};
	int ans = -1;
	
	void search(int x, int y, int dir, int cnt) {
		for (int i = 0; i < vx.length; i++) {
			int nextDir = (i + 2) % 4;
			int nx = x, ny = y;
			if (dir == nextDir) break;
			while (true) {
				nx += vx[i]; ny += vy[i];
				if (map[ny][nx] == 0) continue;
				else if (map[ny][nx] == 1) search(nx - vx[i], ny - vy[i], i, cnt + 1);
				else if (map[ny][nx] == 3) ans = Math.max(ans, cnt);
				break;
			}
		}
	}
	
	public void run() {
		while (true) {
			int startX = -1, startY = -1;
			W = in.nextInt(); H = in.nextInt();
			if ((W|H) == 0) break;
			map = new int[H+2][W+2];
			for (int i = 0; i < map.length; i++) {
				Arrays.fill(map[i], -1);
			}
			
			for (int i = 1; i < map.length - 1; i++) {
				for (int j = 1; j < map[i].length - 1; j++) {
					map[i][j] = in.nextInt();
					if (map[i][j] == 2) {
						startX = j; startY = i;
					}
				}
			}
			ans = -1;
			
			search(startX, startY, -1, 0);
			
			System.out.println(ans);
		}
	}
	
	public static void main(String args[]) {
		new Curling2().run();
	}
}

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

#include<stdio.h>
int map[20][20];
int W, H;
int mx(int a, int b) {
	if (a == -1 && b == -1) return -1;
	if (a == -1) return b;
	if (b == -1) return a;
	if (a < b) {
		if (a == 10) return -1;
		return a;
	if (b == 10) return -1;
	return b;
}
int solve(int x, int y) {
	int righ, lef, up, dow;
	int i, n;
	if (x == H - 1) dow = -1;
	else if (map[x + 1][y] == 1) dow = -1;
	else if (map[x + 1][y] == 3) return 1;
	else {
		for (i = 1; 1; i ++) {
			if (x + i >= H) {
				dow = -1; break;
			}
			if (map[x + i][y] == 1) {
				map[x + i][y] = 0;
				dow = solve(x + i - 1, y);
				map[x + i][y] = 1;
				break;
			} else if (map[x + i][y] == 3) return 1;
		}
	}
	if (x == 0) up = -1;
	else if (map[x - 1][y] == 1) up = -1;
	else if (map[x - 1][y] == 3) return 1;
	else {
		for (i = 1; 1; i ++) {
			if (x - i <= -1) {
				up = -1; break;
			}
			if (map[x - i][y] == 1) {
				map[x - i][y] = '0';
				up = solve(x - i + 1, y);
				map[x - i][y] = 1;
				break;
			} else if (map[x - i][y] == 3) return 1;
		}
	}
	if (y == W - 1) righ = -1;
	else if (map[x][y + 1] == 1) righ = -1;
	else if (map[x][y + 1] == 3) return 1;
	else {
		for (i = 1; 1; i ++) {
			if (y + i >= W) {
				righ = -1; break;
			}
			if (map[x][y + i] == 1) {
				map[x][y + i] = 0;
				righ = solve(x, y + i - 1);
				map[x][y + i] = 1;
				break;
			} else if (map[x][y + i] == 3) return 1;
		}
	}
	if (y == 0) lef = -1;
	else if (map[x][y - 1] == 1) lef = -1;
	else if (map[x][y - 1] == 3) return 1;
	else {
		for (i = 1; 1; i ++) {
			if (y - i <= -1) {
				lef = -1; break;
			}
			if (map[x][y - i] == 1) {
				map[x][y - i] = 0;
				righ = solve(x, y - i + 1);
				map[x][y - i] = 1;
				break;
			} else if (map[x][y - i] == 3) return 1;
		}
	}
	n = mx(dow, mx(up, mx(righ, lef)));
	if (n == -1) return -1;
	return n + 1;
}
int main() {
	int i, j, x, y, n;
	while (1) {
		scanf("%d %d", &W, &H);
		if (!(W||H)) break;
		for (i = 0; i < H; i ++) {
			for (j = 0; j < W; j ++) {
				scanf("%d", &map[i][j]);
				if (map[i][j] == 2) {
					x = i; y = j;
				}
			}
		}
		n = solve(x, y);
		printf("%d\n", n);
	}
	return 0;
}

Compiler output:
main.c: In function 'mx':
main.c:102:1: error: expected declaration or statement at end of input
  102 | }
      | ^
Language: C

#include<algorithm>
#include<cstring>
#include<cstdio>
#include<string>
#include<queue>
#include<stack>
#include<iostream>
#include<cmath>
using namespace std;
#define inf 0x3f3f3f3f
const int maxn = 20 + 8;

int n,m,sx,sy,x,y;
int g[maxn][maxn];
int ans;
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};

bool is_in(int x,int y)
{
    return x >= 0 && x < n && y >= 0 && y < m;
}
void dfs(int r,int c,int num)
{
    if(num == 10 || num >= ans) return;
    for(int i = 0; i < 4; ++i){
        int x = r + dx[i];
        int y = c + dy[i];
        if(!is_in(x,y) || g[x][y] == 1) continue;
        while(is_in(x,y) && g[x][y] == 0)
        {
            x += dx[i];
            y += dy[i];
        }
        if(!is_in(x,y)) continue;
       // cout << " a2: " << x-dx[i] <<" "<< y-dy[i] <<"\n";
        if(g[x][y] == 3)
        {
            ans = min(ans, num);
            return;
        }
        g[x][y] = 0;
         dfs(x - dx[i], y - dy[i],num + 1);
         g[x][y] = 1;

    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    while(scanf("%d%d", &m, &n) && n + m )
    {
        sx = 0,sy = 0;
        memset(g,0,sizeof g);
        for(int i = 0; i < n; ++i)
        {
            for(int j = 0; j < m; ++j)
            {
                scanf("%d",&g[i][j]);
                if(g[i][j] == 2)
                {
                    sx = i; sy = j;
                }
            }
        }
        g[sx][sy] = 0;
        ans = inf;
        dfs(sx,sy,0);
        printf("%d\n", ans == inf ? -1 : ans + 1);
    }
    return 0;
}
/*

6 6
1 0 0 2 1 0
1 1 0 0 0 0
0 0 0 0 0 3
0 0 0 0 0 0
1 0 0 0 0 1
0 1 1 1 1 1
0 0

*/
/*
  0 1 2 3 4 5
0 1 0 0 2 1 0
1 1 1 0 0 0 0
2 0 0 0 0 0 3
3 0 0 0 0 0 0
4 1 0 0 0 0 1
5 0 1 1 1 1 1

*/

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

#include<cstdio>
#include<iostream>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int map[111][111];
int ans;
int w,h;
int judge(int x,int y)
{
    if(x>=0&&x<h&&y>=0&&y<w)  
        return 1;  
    return 0; 
}
void dfs(int x,int y,int step)
{
	if(step>10)
		return;
	for(int i=0;i<4;i++)
	{
		int nowx=x+dx[i];
		int nowy=y+dy[i];
		if(map[nowx][nowy]!=1&&judge(nowx,nowy))
		{
			nowx=x;
			nowy=y;
			while(1)
			{
				nowx+=dx[i];
				nowy+=dy[i];
				if(!judge(nowx,nowy))
					break;
				if(map[nowx][nowy]==3)
				{
					ans=min(ans,step);
					return;
				}
				if(map[nowx][nowy]==1)
				{
					map[nowx][nowy]=0;
					dfs(nowx-dx[i],nowy-dy[i],step+1);
					map[nowx][nowy]=1;//回溯
					break;//??跳出 
				}
			}
		}
	}
}
int main()
{
	int sx,sy;
	while(~scanf("%d",&w,&h)&&w&&h)
	{
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
			{
				scanf("%d",&map[i][j]);
				if(map[i][j]==2)
				{
					sx=i;
					sy=j;
				}
			}
		ans=INF;
		dfs(sx,sy,1);
		if(ans==INF)
			printf("-1\n");
		else
			printf("%d\n",ans);
	}
	return 0;	
}

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

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

int w,h;
int area[21][21];

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

void rec( int x, int y, int n ){
  //    cout << "rec : " << x << " " << y << " " << n << endl;

  int nn=n+1;
  bool f;
  if( n>10 ) return;

  for( int i,j, k=0;k<4;k++ ){
    //    cout << "k="<<k<<endl;
    i=x; j=y; f=true;
    while( f ){
      i+=dx[k]; j+=dy[k];
      if(j<0) break;      if(i<0) break;
      if(i>=h) break;     if(j>=w) break;
	 //	 cout << " i="<<i<< " j="<<j<< " "<<area[i][j] << endl;
      switch( area[i][j] ){
      case 3:  ans=min(ans,nn);return;
      case 1:{
	if( i-dx[k]!=x || j-dy[k]!=y ){
	  area[i][j]=0;
	  rec(i-dx[k],j-dy[k],nn);
	  area[i][j]=1;
	}
	f=false;
	break;
      }
      }	 
    }
  }
    //    cout << "ret="<<ret<<endl;
}

  void pr(){
    for( int i=0;i<h;i++ ){
      for( int j=0;j<w;j++ )
	cout << area[i][j] << " " ;
      cout << endl;
    }
  }

int main(){
  int sx,sy;

  while( cin>>w>>h && (w|h) ){
    //    cout << " h="<<h << " w="<<w << endl;

    for( int i=0;i<h;i++ )
      for( int j=0;j<w;j++ ){
	cin >> area[i][j];
	if( area[i][j]==2 ){ sx=i;sy=j;area[i][j]=0; }
      }
    /*
    cout << "area"<<endl;
    pr();
    cout<< "answer"<<endl;
    */
    ans=100;
    rec( sx,sy,0 );
    //    cout << "ans="<<ans<<endl;

    if( ans>10 ) ans=-1;
    cout << ans << 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 <iostream>
#include <vector>
using namespace std;

int w, h, ans;

void curling(int x, int y, vector< vector<int> > m, int sum)
{
	if (x < 0 || y < 0 || x >= m[y].size() || y >= m.size() || sum > 10) {
		return;
	}

	if (m[y][x] == 3) {
		if (sum < ans) {
			ans = sum;
		}
		return;
	}

	int minx = -10, miny = -10, maxx = -10, maxy = -10;

	for (int i = y + 1; i < m.size(); ++i) {
		if (m[i][x] == 1) {
			if (i == y + 1) {
				break;
			}
			maxy = i;
			break;
		}
		if (m[i][x] == 3) {
			maxy = i + 1;
			break;
		}
	}
	for (int i = y - 1; i >= 0; --i) {
		if (m[i][x] == 1) {
			if (i == y - 1) {
				break;
			}
			miny = i;
			break;
		}
		if (m[i][x] == 3) {
			miny = i - 1;
			break;
		}
	}
	for (int i = x + 1; i < m[y].size(); ++i) {
		if (m[y][i] == 1) {
			if (i == x + 1) {
				break;
			}
			maxx = i;
			break;
		}
		if (m[y][i] == 3) {
			maxx = i + 1;
			break;
		}
	}
	for (int i = x - 1; i >= 0; --i) {
		if (m[y][i] == 1) {
			if (i == x - 1) {
				break;
			}
			minx = i;
			break;
		}
		if (m[y][i] == 3) {
			minx = i - 1;
		}
	}

	if (minx != -10) {
		m[y][minx] = 0;
		curling(minx + 1, y, m, sum + 1);
	}
	if (maxx != -10) {
		m[y][maxx] = 0;
		curling(maxx - 1, y, m, sum + 1);
	}
	if (miny != -10) {
		m[miny][x] = 0;
		curling(x, miny + 1, m, sum + 1);
	}
	if (maxy != -10) {
		m[maxy][x] = 0;
		curling(x, maxy - 1, m, sum + 1);
	}

}

int main(void)
{
	while (cin >> w >> h && w != 0) {
		vector< vector<int> > m(h, vector<int>(w));
		ans = 1000000;
		int sx, sy;
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				cin >> m[i][j];
				if (m[i][j] == 2) {
					sx = j;
					sy = i;
				}
			}
		}
		curling(sx, sy, m, 0);
		if (ans == 1000000) {
			ans = -1;
		}
 		cout << ans << endl;
	}

	return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:115:18: error: expected '}' at end of input
  115 |         return 0;
      |                  ^
a.cc:94:1: note: to match this '{'
   94 | {
      | ^
Language: C++

3 0 0 1
1 0 0 1
1 1 1 1
3 3
2 0 0
0 0 3
1 0 0
3 3
0 0 2
3 0 0
0 0 1
3 3
0 3 0
0 0 0
2 0 1
3 3
0 3 0
0 0 0
1 0 2
3 3
1 0 0
0 0 3
2 0 0
5 5
1 1 2 0 0
0 0 0 0 3
0 0 0 0 0
1 0 0 0 1
1 1 1 1 1



Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 3 0 0 1
      | ^
Language: C++

#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;


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

const Int M_H(20);
const Int M_W(20);

int tile[M_H][M_W];
int H, W;

struct point{
	Int x, y, step;
	int tile[M_H][M_W];
	point(Int x_, Int y_, Int s,int tile_[M_H][M_W]) :x(x_), y(y_), step(s)
	{
		memcpy(tile, tile_, sizeof(tile));
	}
};

queue<point> que;

int solve()
{
	while (!que.empty()){
		auto now = que.front();
		que.pop();

		int i(4);
		while (i--){
			int x = now.x + dx[i];
			int y = now.y + dy[i];
			if (now.tile[y][x] == 1)
				continue;
			if (now.tile[y][x] == 4)
				continue;
			while(now.tile[y][x] == 0){
				x += dx[i];
				y += dy[i];
				if (x >= M_W || x < 0 || y >= M_H || y < 0)
					break;
			} 
			if (x >= M_W || x < 0 || y >= M_H || y < 0 || now.step >= 10)
				continue;
			if (now.tile[y][x] == 1){
				int temp[M_H][M_W];
				memcpy(temp, now.tile, sizeof(temp));
				temp[y][x] = 0;
				que.emplace(x - dx[i], y - dy[i], now.step + 1, temp);
			}
			if (now.tile[y][x] == 3)
				return now.step + 1;

			if (now.tile[y][x] == 4)
				continue;
		}
	}
	return -1;
}

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	//fstream fs("input.txt");
	////////////ここから開始///////////
	//fs >> W >> H;
	 
	while (cin >> W >> H,H){
		REP(i, M_H)REP(j, M_W){ tile[i][j] = 4;}

		REP(i, H)REP(j, W)cin >> tile[i][j];

		que = {};

		REP(i, H)REP(j, W){
			if (tile[i][j] == 2){
				tile[i][j] = 0;
				que.emplace(j, i, 0, tile);
			}
		}
		cout << solve() << endl;
	}

	return 0;
}

Compiler output:
a.cc: In constructor 'point::point(Int, Int, Int, int (*)[20])':
a.cc:34:17: error: 'memcpy' was not declared in this scope
   34 |                 memcpy(tile, tile_, sizeof(tile));
      |                 ^~~~~~
a.cc:12:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   11 | #include <numeric>
  +++ |+#include <cstring>
   12 | 
a.cc: In function 'int solve()':
a.cc:64:33: error: 'memcpy' was not declared in this scope
   64 |                                 memcpy(temp, now.tile, sizeof(temp));
      |                                 ^~~~~~
a.cc:64:33: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include<iostream>
using namespace std;
int grid[40][40];
int dy[4] = {1, 0, -1, 0};
int dx[4] = {0,-1, 0, 1};
int w, h;

int dfs(int x, int y, int depth){
  if(depth >= 10)return 1e9;
  int res = 1e9;
  bool flag = false;
    
  for (int i = 0; i < 4; i++) {
    int nx = x, ny = y;
    if(grid[ny + dy[i]][nx + dx[i]] == 1)continue;
    while(0 <= nx + dx[i] && nx + dx[i] < w &&
          0 <= ny + dy[i] && ny + dy[i] < h &&
          grid[ny + dy[i]][nx + dx[i]] == 0)
      nx += dx[i], ny += dy[i];
    
    if(nx + dx[i] < 0 || w <= nx + dx[i] ||
       ny + dy[i] < 0 || h <= ny + dy[i]){
      continue;
    }else if(grid[ny + dy[i]][nx + dx[i]] == 3){
      return depth + 1;
    }else{
      flag = true;
      grid[ny + dy[i]][nx + dx[i]] = 0;
    }
    res = min(res, dfs(nx, ny, depth + 1));
    if(flag)grid[ny + dy[i]][nx + dx[i]] = 1;
  }
  return res;
}

int main(int argc, char *argv[]){
  while(cin >> w >> h, w){
    memset(grid, 0, sizeof(grid));
    int sx, sy, tx, ty;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> grid[i][j];
        if(grid[i][j] == 2){
          sx = j;sy = i;
          grid[i][j] = 0;
        }else if(grid[i][j] == 3){
          tx = j;ty = i;
        }
      }
    }
    int ans = dfs(sx, sy, 0);
    if(ans == 1e9){
      std::cout << -1 << std::endl;
    }else{
      std::cout << ans << std::endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:38:5: error: 'memset' was not declared in this scope
   38 |     memset(grid, 0, sizeof(grid));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>

#define MAX_W 20
#define MAX_H 20

int w, h;
int sx, sy;
int ans;
char field[MAX_W][MAX_H];

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

bool dfs(int x, int y, int count);

int main(){
while(true){
std::cin >> w >>h;
for(int i = 0; i < h; ++i){
for(int j = 0; j < w; ++j){
std::cin >> field[j][i];
if(field[j][i] == '2')
sx = j, sy = i; 
}
}

if(dfs(sx, sy, 0))
std::cout << ans << std::endl;
else
std::cout << "-1" << std::endl;
}
return 0;
}

bool dfs(int x, int y, int count){
if(count > 10)
return false;

for(int i = 0; i < 4; ++i){
int nx = x, ny = y;

while(true){
if(nx + dx[i] >= 0 && nx + dx[i] < MAX_W && ny + dy[i] >= 0 && ny + dy[i] < MAX_H){
if(dfs(nx, ny, count + 1))
return true;
if(field[nx + dx[i]][ny + dy[i]] == '1'){
field[nx + dx[i]][ny + dy[i]] == '0';
if(dfs(nx, ny, count + 1))
return true;
else
field[nx + dx[i]][ny + dy[i]] == '1';
}
if(field[nx + dx[i]][ny + dy[i]] == '3'){
ans = count + 1;
return true;
}
}
return false;
}
}

Compiler output:
a.cc: In function 'bool dfs(int, int, int)':
a.cc:59:2: error: expected '}' at end of input
   59 | }
      |  ^
a.cc:34:34: note: to match this '{'
   34 | bool dfs(int x, int y, int count){
      |                                  ^
a.cc:59:2: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      |  ^
Language: C++

#include <iostream>

using namespace std;

int w, h;
int f[21][21];
int ans;

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

void rec(int n, int x, int y) {
  if (n >= ans) { return; }

  for (int i=0; i<4; i++) {
    int mx=x, my=y;
    mx += dx[i]; my += dy[i];
    if (mx < 0 || mx >= w) { continue; }
    if (my < 0 || my >= h) { continue; }
    if (f[my][mx] == 1) { continue; }

    while (1) {
      if (f[my][mx] == 3) {
        ans = n;
        return;
      }

      mx += dx[i]; my += dy[i];
      if (mx < 0 || mx >= w) { break; }
      if (my < 0 || my >= h) { break; }

      if (f[my][mx] == 1) {
        f[my][mx] = 0;
        rec(n+1, mx-dx[i], my-dy[i]);
        f[my][mx] = 1;
        break;
      }
    }
  }
}

int main() {
  while (cin >> w >> h, (w || h)) {
    int sx, sy;
    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        cin >> f[y][x];
        if (f[y][x] == 2) {
          sx = x; sy = y;
        }
      }
    }

    ans = 11;
    rec(1, sx, sy);
    if (ans > 10) { ans = -1; }
    cout << ans << endl;
  }

  return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:60:12: error: expected '}' at end of input
   60 |   return 0;
      |            ^
a.cc:42:12: note: to match this '{'
   42 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int map[30][30];
int sx, sy, gx, gy, h, w;
int dfs(int x, int y, int n) {
	if (n > 11)return 11;
	int ret = 11, p;
	p = x - 1;
	if (p > 0 && map[p][y] != 1) {
		while (p > 0) {
			if (map[p - 1][y] == 1) {
				map[p - 1][y] = 0;
				ret = min(ret, dfs(p, y, n + 1));
				break;
			}
			else if (p == gx&&y == gy)return n + 1;
			p--;
		}
	}
	p = x + 1;
	if (p <= w&& map[p][y] != 1) {
		while (p <= w) {
			if (map[p + 1][y] == 1) {
				map[p + 1][y] = 0;
				ret = min(ret, dfs(p, y, n + 1));
				break;
			}
			else if (p == gx&&y == gy)return n + 1;
			p++;
		}
	}
	p = y - 1;
	if (p > 0 && map[x][p] != 1) {
		while (p > 0) {
			if (map[x][p - 1] == 1) {
				map[x][p - 1] = 0;
				ret = min(ret, dfs(x, p, n + 1));
				break;
			}
			else if (p == gy&&x == gx)return n + 1;
			p--;
		}
	}
	p = y + 1;
	if (p <= h&& map[x][p] != 1) {
		while (p <= h) {
			if (map[x][p + 1] == 1) {
				map[x][p + 1] = 0;
				ret = min(ret, dfs(x, p, n + 1));
				break;
			}
			else if (p == gy&&x == gx)return n + 1;
			p++;
		}
	}
	return ret;
}
int main() {
	while (cin >> h >> w, h, w) {
		memset(map, 0, sizeof(map));
		for (int i = 1; i <= w; i++) for (int j = 1; j <= h; j++) {
			cin >> map[i][j];
			if (map[i][j] == 2) { sx = i; sy = j; map[i][j] = 0; }
			if (map[i][j] == 3) { gx = i; gy = j; }
		}
		int key = dfs(sx, sy, 0);
		if (key == 11)cout << "-1\n"; else cout << key << endl;
	}
}

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

#include <string.h>

int gx, gy, h, w;
int cost[20][20];
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

void solve(int x,int y, int field[20][20]){
	static int count = 0;
	int i, j, flag;
	if(cost[y][x] > count || cost[y][x] == -1){
		cost[y][x] = count;
		if(field[y][x] == 3)
			return;
	}
	if(count < 10){
		for(i = 0;i < 4;i++){
			flag = 0;
			for(j = 1;x + dx[i] * j >= 0 && x + dx[i] * j < w && y + dy[i] * j >= 0 && y + dy[i] * j < h;j++){
				if(field[y + dy[i] * j][x + dx[i] * j]){
					flag = 1;
					break;
				}
			}
			if(field[y + dy[i] * j][x + dx[i] * j] == 3){
				count++;
				solve(x + dx[i] * j,y + dy[i] * j,field);
				count--;
			}
			else if(j != 1 && flag){
				field[y + dy[i] * j][x + dx[i] * j] = 0;
				count++;
				solve(x + dx[i] * (j - 1),y + dy[i] * (j - 1),field);
				field[y + dy[i] * j][x + dx[i] * j] = 1;
				count--;
			}
		}	
	}
}


int main(void){
	int i, j, field[20][20], sx, sy;
	while(1){
		scanf("%d%d",&w,&h);
		if(w == 0 && h == 0)
			break;
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++)
				scanf("%d",&field[i][j]);
		}
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				if(field[i][j] == 2){
					sy = i, sx = j;
					field[i][j] = 0;
				}
				else if(field[i][j] == 3)
					gy = i, gx = j;
			}
		}
		memset(cost,-1,sizeof(cost));
		solve(sx,sy,field);
		printf("%d\n",cost[gy][gx]);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:17: error: 'scanf' was not declared in this scope
   44 |                 scanf("%d%d",&w,&h);
      |                 ^~~~~
a.cc:63:17: error: 'printf' was not declared in this scope
   63 |                 printf("%d\n",cost[gy][gx]);
      |                 ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    1 | #include <string.h>
  +++ |+#include <cstdio>
    2 |
Language: C++

// cleartime: 4時間くらい？
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;

typedef vector< vector<int> > field;

int w, h;
field f, closed;
int mx[] = {0, 0, 1, -1},
    my[] = {1, -1, 0, 0};

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

int bt(int x, int y, int step) {
    int res = INT_MAX, tmp;

    // 終了条件
    if ( step == 10 ) {
        return res;
    }

    // 上下左右に進めるなら進む
    REP(i, 4) {
        int nx = x, ny = y;

        while(1) {
            nx += mx[i];
            ny += my[i];

            if ( !in_range(nx, ny, w, h) ) {
                break;
            }

            if ( f[ny][nx] == 1 ) {
                break;
            } else if ( f[ny][nx] == 3 ) {
                return step + 1;
            }
        }

        if ( !in_range(nx, ny, w, h) || abs(x-nx) == 1 || abs(y-ny) == 1 ) continue;

        // 障害物を破壊
        f[ny][nx] = 0;
        tmp = bt(nx-mx[i], ny-my[i], step+1);
        f[ny][nx] = 1;

        // 最小手の更新
        if ( tmp < res )
            res = tmp;
    }

    return res;
}

int main() {
    int fx, fy, res;

    while( cin >> w >> h, w || h ) {
        f = field(h, vector<int>(w));

        // 入力
        REP(i, h) {
            REP(j, w) {
                cin >> f[i][j];
                if ( f[i][j] == 2 ) {
                    fx = j;
                    fy = i;
                }
            }
        }

        res = bt(fx, fy, 0);

        if ( res != INT_MAX )
            cout << res;
        else
            cout << -1;
        cout << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int bt(int, int, int)':
a.cc:22:15: error: 'INT_MAX' was not declared in this scope
   22 |     int res = INT_MAX, tmp;
      |               ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <vector>
  +++ |+#include <climits>
    5 | 
a.cc:52:9: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   52 |         tmp = bt(nx-mx[i], ny-my[i], step+1);
      |         ^~~
      |         tm
a.cc: In function 'int main()':
a.cc:82:21: error: 'INT_MAX' was not declared in this scope
   82 |         if ( res != INT_MAX )
      |                     ^~~~~~~
a.cc:82:21: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

    if(board[y+dy[i]][x+dx[i]] ==1){
      flag[i] = 1;
    }
  }
  if(k <=10){
    //左方向
    if(flag[2]==0){
    for(int j = x;j >0;j--){
      if(board[y][j] ==3){
	step = min(step,k);
	break;
      }else if(board[y][j-1] ==1){
	board[y][j-1] =0;
	dfs(j,y,k+1);
	board[y][j-1] = 1;
	break;
      }
    }
    }
    //右方向
    if(flag[0]==0){
    for(int j = x; j <=w;j++){
      if(board[y][j] ==3){
	step = min(step,k);
	break;
      }else if(board[y][j+1] ==1){
	board[y][j+1] =0;
	dfs(j,y,k+1);
	board[y][j+1] = 1;
	break;
      } 
    }
    }
    //上方向 
    if(flag[1] ==0){
    for(int j = y; j >0;j--){
      if(board[j][x] ==3){
	step = min(step,k);
	break;
      }else if(board[j-1][x] ==1){
	board[j-1][x] =0;
	dfs(x,j,k+1);
	board[j-1][x] = 1;
	break;
      }
    }
    }
    //下方向 
    if(flag[3]==0){
    for(int j = y; j <=h;j++){
      if(board[j][x] ==3){
	step = min(step,k);
	break;
      }else if(board[j+1][x] ==1){
	board[j+1][x] =0;
	dfs(x,j,k+1);
	board[j+1][x] = 1;
	break;
      }
    } 
    }
  }
    return;
}


int main()
{
  while(cin>>w>>h,w||h){
    step =1000;
    for(int i = 1;i <=h;i++){
      for(int j = 1;j <=w;j++){
	cin >>board[i][j];
      }
    }
    for(int i = 1;i <=h;i++){
      for(int j = 1;j <=w;j++){
	if(board[i][j] ==2){
	  int sx = j;
	  int sy = i;
	  dfs(sx,sy,1);
	}
      }
    }
    if(step ==1000){
      cout <<"-1"<<endl;
    }else
      cout <<step<<endl;
  }
  return 0;
}

Compiler output:
a.cc:1:5: error: expected unqualified-id before 'if'
    1 |     if(board[y+dy[i]][x+dx[i]] ==1){
      |     ^~
a.cc:4:3: error: expected declaration before '}' token
    4 |   }
      |   ^
a.cc:5:3: error: expected unqualified-id before 'if'
    5 |   if(k <=10){
      |   ^~
a.cc:63:5: error: expected unqualified-id before 'return'
   63 |     return;
      |     ^~~~~~
a.cc:64:1: error: expected declaration before '}' token
   64 | }
      | ^
a.cc: In function 'int main()':
a.cc:69:9: error: 'cin' was not declared in this scope
   69 |   while(cin>>w>>h,w||h){
      |         ^~~
a.cc:69:14: error: 'w' was not declared in this scope
   69 |   while(cin>>w>>h,w||h){
      |              ^
a.cc:69:17: error: 'h' was not declared in this scope
   69 |   while(cin>>w>>h,w||h){
      |                 ^
a.cc:70:5: error: 'step' was not declared in this scope
   70 |     step =1000;
      |     ^~~~
a.cc:73:15: error: 'board' was not declared in this scope
   73 |         cin >>board[i][j];
      |               ^~~~~
a.cc:78:12: error: 'board' was not declared in this scope
   78 |         if(board[i][j] ==2){
      |            ^~~~~
a.cc:81:11: error: 'dfs' was not declared in this scope
   81 |           dfs(sx,sy,1);
      |           ^~~
a.cc:86:7: error: 'cout' was not declared in this scope
   86 |       cout <<"-1"<<endl;
      |       ^~~~
a.cc:86:20: error: 'endl' was not declared in this scope
   86 |       cout <<"-1"<<endl;
      |                    ^~~~
a.cc:88:7: error: 'cout' was not declared in this scope
   88 |       cout <<step<<endl;
      |       ^~~~
a.cc:88:20: error: 'endl' was not declared in this scope
   88 |       cout <<step<<endl;
      |                    ^~~~
Language: C++

#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int pos,n;#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int pos,n;
string s,t,p;
string f();
string expr(){
	string a=f();
	while(isdigit(s[pos])||isalpha(s[pos])){
		if(a.size()>n)
			break;
		a+=f();
	}
	return a;
}
string f(){
	t="";
	if(isdigit(s[pos])){
		int ret=0,i=0;
		for(;isdigit(s[pos]);pos++){
			ret*=10;
			ret+=s[pos]-'0';
		}
		p=f();
		for(;i<ret;i++){
			t+=p;
			if(t.size()>n)
				break;
		}
	}else if(s[pos]=='('){
		pos++;
		t=expr();
		pos++;
	}else{
		for(;isalpha(s[pos]);pos++){
			t+=s[pos];
			if(t.size()>n)
				break;
		}
	}
	return t;
}
int main(){
	while(cin>>s>>n,s!="0"||n){
		pos=0;
		s+="#";
		string t=expr();
		if(t.size()-1<n)
		cout<<0<<endl;
		else
		cout<<t[n]<<endl;
	}
	return 0;
}
string s;
string f();
string expr(){
	string a=f();
	while(isdigit(s[pos])||isalpha(s[pos])){
		if(a.size()>n)
		return a;
		a+=f();
	}
	return a;
}
string f(){
	string t;
	if(isdigit(s[pos])){
		int ret=0;
		for(;isdigit(s[pos]);pos++){
			ret*=10;
			ret+=s[pos]-'0';
		}
		t="";
		string p=f();
		for(int i=0;i<ret;i++){
			t+=p;
			if(t.size()>n)
				return t;
		
		}
	}else if(s[pos]=='('){
		pos++;
		t=expr();
		pos++;
	}else{
		t="";
		for(;isalpha(s[pos]);pos++){
			t+=s[pos];
			if(t.size()>n)
				return t;
		}
	}
	return t;
}
int main(){
	while(cin>>s>>n,s!="0"||n){
		pos=0;
		s+="#";
		string t=expr();
		if(t.size()-1<n)
		cout<<0<<endl;
		else
		cout<<t[n]<<endl;
	}
	return 0;
}

Compiler output:
a.cc:5:11: error: stray '#' in program
    5 | int pos,n;#include<iostream>
      |           ^
a.cc:5:12: error: 'include' does not name a type
    5 | int pos,n;#include<iostream>
      |            ^~~~~~~
a.cc:9:5: error: redefinition of 'int pos'
    9 | int pos,n;
      |     ^~~
a.cc:5:5: note: 'int pos' previously declared here
    5 | int pos,n;#include<iostream>
      |     ^~~
a.cc:9:9: error: redefinition of 'int n'
    9 | int pos,n;
      |         ^
a.cc:5:9: note: 'int n' previously declared here
    5 | int pos,n;#include<iostream>
      |         ^
a.cc:60:8: error: redefinition of 'std::string s'
   60 | string s;
      |        ^
a.cc:10:8: note: 'std::string s' previously declared here
   10 | string s,t,p;
      |        ^
a.cc:62:8: error: redefinition of 'std::string expr()'
   62 | string expr(){
      |        ^~~~
a.cc:12:8: note: 'std::string expr()' previously defined here
   12 | string expr(){
      |        ^~~~
a.cc:71:8: error: redefinition of 'std::string f()'
   71 | string f(){
      |        ^
a.cc:21:8: note: 'std::string f()' previously defined here
   21 | string f(){
      |        ^
a.cc:101:5: error: redefinition of 'int main()'
  101 | int main(){
      |     ^~~~
a.cc:48:5: note: 'int main()' previously defined here
   48 | int main(){
      |     ^~~~