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

#include<cstdio.h>
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
struct PP{
	int x;
	int 
	int Z;
	int c;
};
char s[1002][1002],C[11]={"0123456789"};
int D[1002][1002];
int A[1002][1002],d;
int main(){
	PP S;
	queue<PP> P;
	int  w,h;
	int d=0,i=0,j=0,l=-1;
	int x[4]={ 1, 0,-1,0};
	int y[4]={ 0 ,1,0,-1};
	scanf("%d %d %d",&h,&w,&d);
	memset(A,0,sizeof(A));
   memset(D,0,sizeof(D));
		for(i=0;i<h;i++){
		scanf("%s",s[i]);
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
		if(s[i][j]=='S'){
			S.x=j;
			S.y=i;
			S.Z=0;
			S.c=1;
			P.push(S);
		}
		}
	}
	while(1){
		l++;
		
		if(l==4) {
			l=0;
			P.pop();
		}
		S=P.front();
		A[S.y][S.x]=1;
		S.x+=x[l];
		S.y+=y[l];
		S.Z++;
		if(A[S.y][S.x]==1||s[S.y][S.x]=='X'||S.y==h||S.x==w||S.x==-1||S.y==-1){
		continue;
		}
		if(s[S.y][S.x]=='.'){}
		else{
			if(C[S.c]==s[S.y][S.x]){
				S.c++;
				if(S.c==d+1){
				break;
				}
				while(!P.empty()){
				P.pop();
				
				}
			memset(A,0,sizeof(A));
			l=-1;
			}

		} 
		P.push(S);
	}
	printf("%d\n",S.Z);
	return 0;
}

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

#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cassert>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
const bool test=0;
int n,w,h;
int const N=1000+10;
char A[N][N];
char V[N][N];
char s[N];
int _h,_w;
int mov[2][4]={
	0,0,-1,1,
	-1,1,0,0
};
void show(){
	if(test){
		for(int i=1;i<=_h;i++){
			for(int j=1;j<=_w;j++){
				printf("%2d",A[i][j]);
			}
			printf("\n");
		}

	}
}
const int H=0,W=1;
struct point{
	int h;
	int w;
	int cnt;
	point(int h=1,int w=1,int cnt=inf):h(h),w(w),cnt(cnt){}
};
int cor(char x,int i,int j){
	switch(x){
		case 'S':
			h=i;
			w=j;
			return 0;
			break;
		case 'X':
			return -1;
		case '.':
			return 0;
		default:
			return x-'0';
	}
}
int search(int goal){
	memset(V,0,sizeof(V));
	int cnt=0;
	queue<point> q;
	q.push(point(h,w,cnt));
	point p;
	if(test){cout<<"root"<<cnt<<' '<<h<<' '<<w<<endl;
		show();
	}
	while(q.size()){
		p=q.front();
		q.pop();
		h=p.h;
		w=p.w;
		cnt=p.cnt;
		if(V[h][w]!=0)continue;
		if(A[h][w]==goal){
			return cnt;
		}
		if(test)cout<<"q.size "<<q.size()<<" cnt "<<cnt<<' '<<h<<' '<<w<<' '<<(int)V[h][w]<<" goal "<<goal<<endl;
		for(int c=0;c<4;c++){
			int tmph=h+mov[H][c];
			int tmpw=w+mov[W][c];
			if(!V[tmph][tmpw]&&A[h][w]!=-1)q.push(point(tmph,tmpw,cnt+1));
		}
		V[h][w]=1;
	}
	assert(q.size());
}
void solve(){
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=search(i);
	}
	cout<<sum<<endl;
}
int main()
{
	scanf("%d%d%d", &h,&w,&n);
	_h=h;
	_w=w;
	memset(A,-1,sizeof(A));
	for(int i=1;i<=_h;i++){
		scanf("%s",s);
		for(int j=1;j<=_w;j++){
			A[i][j]=cor(s[j-1],i,j);
		}
	}
	show();
	solve();
	return 0;
}
////aoj0558.cc
////generated automatically at Fri Sep  9 18:27:24 2016
////by xsthunder
/

Compiler output:
a.cc:118:1: error: expected unqualified-id before '/' token
  118 | /
      | ^
a.cc: In function 'int search(int)':
a.cc:91:1: warning: control reaches end of non-void function [-Wreturn-type]
   91 | }
      | ^
Language: C++

#include <algorithm>
#include <cmath>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

int cost[1100][1100];

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  vector<string> s;

  s.push_back(string(W+2, 'X'));
  REP(i, 0, H){
    string tmp;
    cin >> tmp;
    s.push_back('X' + tmp + 'X');
  }
  s.push_back(string(W+2, 'X'));

  vector<PII> v(N+1);
  REP(i, 0, H+2){
    REP(j, 0, W+2){
      char c = s[i][j];
      if(c >= '1' && c <= '9'){
        v[c-'0'] = {i, j};
      } else if(c == 'S'){
        v[0] = {i, j};
      }
    }
    //cout << s[i] << endl;
  }

  int dest = 0, res = 0;
  REP(i, 0, N){
    queue<PII> q;
    q.push(v[dest]);
    memset(cost, -1, sizeof(cost));
    cost[v[dest].fst][v[dest].snd] = 0;
    while(!q.empty()){
      PII a = q.front(); q.pop();
      const int dx[4] = {-1, 0, 1, 0};
      const int dy[4] = {0, -1, 0, 1};
      if(s[a.fst][a.snd] == i + '1'){
        res += cost[a.fst][a.snd];
        dest++;
        break;
      }
      REP(i, 0, 4){
        int ny = a.fst + dy[i];
        int nx = a.snd + dx[i];
        if(s[ny][nx] != 'X' && !(cost[ny][nx] + 1)){//cost[ny][nx] + 1 == 0 if not searched
          cost[ny][nx] = cost[a.fst][a.snd] + 1;
          q.push({ny, nx});
        }
      }
    }
  }
  cout << res << endl;

  return 0;
}

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

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

const int INF = 1<<30;
const int maxn = 1000+10;

int w,h,n;
char mp[maxn][maxn];
int d[maxn][maxn];

int dir[4][2] = {
	{-1,0},
	{1,0},
	{0,1},
	{0,-1},
};

int fac[10][2];

int bfs(int sx,int sy,int gx,int gy){
	memset(d,-1,sizeof(d));

	queue<pair<int,int> > Q;
	Q.push(make_pair(sx,sy));
	d[sx][sy] = 0;
	while(!Q.empty()){
		pair<int,int> p = Q.front(); Q.pop();
		if(p.first==gx && p.second==gy) break;

		for(int i=0; i<4; i++){
			int tx = p.first + dir[i][0];
			int ty = p.second + dir[i][1];
			if(tx>=0 && tx<h && ty>=0 && ty<w && mp[tx][ty]!='X' && d[tx][ty]==-1){
				Q.push(make_pair(tx,ty));
				d[tx][ty] = d[p.first][p.second] + 1;
			}
		}
	}

	return d[gx][gy];
}

int main(){
	scanf("%d%d%d",&h,&w,&n);	
	for(int i=0; i<h; i++)
		for(int j=0; j<w; j++)
			cin >> mp[i][j];

	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(mp[i][j] == 'S'){
				fac[0][0] = i;
				fac[0][1] = j;
				mp[i][j] = '.';
			}else if(isdigit(mp[i][j])){
				int index = mp[i][j] - '0';
				fac[index][0] = i;
				fac[index][1] = j;
			}
		}
	}

	int step = 0;
	for(int i=0; i<n; i++){
		step += bfs(fac[i][0],fac[i][1],fac[i+1][0],fac[i+1][1]);
	}

	printf("%d\n",step);
}

Compiler output:
a.cc: In function 'int bfs(int, int, int, int)':
a.cc:24:9: error: 'memset' was not declared in this scope
   24 |         memset(d,-1,sizeof(d));
      |         ^~~~~~
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 | using namespace std;
Language: C++

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

typedef pair<int,int> P;

int h,w,n;
char m[1000][1000];
int visited[1000][1000];

int main(){
	cin>>h>>w>>n;

	int pos;
	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			cin>>m[x][y];
			if(m[x][y]=='S') pos=x+y*1000;
		}
	}

	memset(visited,0,sizeof(visited));
	int ans=0;
	for(int now=1;now<=n;now++){
		queue<P> q;
		q.push(make_pair(pos,0));
		while(1){
			pos=q.front().first;
			int x=pos%1000;
			int y=pos/1000;
			int cost=q.front().second;
			q.pop();
			if(visited[x][y]==now || m[x][y]=='X') continue;
			if(m[x][y]==('0'+now)){
				ans+=cost;
				break;
			}
			visited[x][y]=now;
			if(0<x) q.push(make_pair(pos-1,cost+1));
			if(x+1<w) q.push(make_pair(pos+1,cost+1));
			if(0<y) q.push(make_pair(pos-1000,cost+1));
			if(y+1<h) q.push(make_pair(pos+1000,cost+1));
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

typedef pair<int, int> P;

int h, w, n;
char f[1000][1000];

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

struct Ele {
	Ele(int a, double b, P c) : g(a), h(b), p(c) {}
	bool operator<(const Ele& right) const {
		return g + h > right.g + right.h;
	}
	int g;
	double h;
	P p;
};

double euclidean(P s, P g) {
	int y = s.first - g.first;
	int x = s.second - g.second;
	return sqrt(x*x + y*y);
}

int Astar(P s, P g) {
	bool used[1000][1000] = { false };
	priority_queue<Ele> que;
	que.push(Ele(0, euclidean(s, g), s));

	while (!que.empty()) {
		Ele t = que.top();
		que.pop();

		if (t.p == g)
			return t.g;
		if (used[t.p.first][t.p.second])
			continue;
		used[t.p.first][t.p.second] = true;

		for (int i = 0; i < 4; ++i) {
			int ny = t.p.first + dy[i];
			int nx = t.p.second + dx[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w || f[ny][nx] == 'X')
				continue;

			P np(ny, nx);
			que.push(Ele(t.g + 1, euclidean(np, g), np));
		}
	}

	return 0;
}

int main() {
	cin >> h >> w >> n;

	P fac[10];
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> f[i][j];
			if ('1' <= f[i][j] && f[i][j] <= '9')
				fac[f[i][j] - '0'] = P(i, j);
			else if (f[i][j] == 'S')
				fac[0] = P(i, j);
		}
	}

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += Astar(fac[i], fac[i + 1]);
	}

	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'double euclidean(P, P)':
a.cc:33:16: error: 'sqrt' was not declared in this scope
   33 |         return sqrt(x*x + y*y);
      |                ^~~~
Language: C++

#include <iostream>
#include <stdlib.h>
#include <queue>
#define MAX_NUM 1010
using namespace std;
int H, W, N;
bool flag[MAX_NUM][MAX_NUM] = {false};

class Node
{
public:
	Node();
	Node(int x, int y, int step);
	~Node();
	int x;
	int y;
	int step;
};

Node::Node()
{
}

Node::Node(int x, int y, int step) {
	this->x = x;
	this->y = y;
	this->step = step;
}

Node::~Node()
{
}
int dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
int BFS(char map[][MAX_NUM], int sx, int sy, int ex, int ey) {
	queue<Node*> que;
	que.push(new Node(sx, sy, 0));
	flag[sx][sy] = true;
	while (!que.empty())
	{
		Node* cur = que.front();
		que.pop();
		if (cur->x == ex && cur->y == ey)
		{
			return cur->step;
		}
		else
		{
			for (int i = 0; i < 4; i++)
			{
				int k = cur->x + dir[i][0];
				int v = cur->y + dir[i][1];
				if (k>=0&&k<H&&v>=0&&v<W&&map[k][v]!='X'&&!flag[k][v])
				{
					que.push(new Node(k, v, cur->step + 1));
					flag[k][v] = true;
				}
			}
		}
	}
	return -1;

}

int main()
{
	int sx, sy, arr[10][2];
	char map[MAX_NUM][MAX_NUM];
	while (cin >> H >> W >> N && H && W)
	{
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> map[i][j];
				if (map[i][j] == 'S')
				{
					map[i][j] = '.';
					sx = i;
					sy = j;
				}
				if (isdigit(map[i][j]))
				{
					int index = map[i][j] - '0';
					arr[index][0] = i;
					arr[index][1] = j;
				}
			}
		}
		memset(flag, false, sizeof(flag));
		int res = 0;
		res += BFS(map, sx, sy, arr[1][0], arr[1][1]);
		for (int i = 1; i+1 <= N; i++)
		{
			memset(flag, false, sizeof(flag));
			res += BFS(map, arr[i][0], arr[i][1], arr[i + 1][0], arr[i + 1][1]);
		}
		cout << res << endl;
	}
	return 0;
}

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

#include <iostream>
#include <stdlib.h>
#include <queue>
#define MAX_NUM 1010
using namespace std;
int H, W, N;
bool flag[MAX_NUM][MAX_NUM] = {false};

class Node
{
public:
	Node();
	Node(int x, int y, int step);
	~Node();
	int x;
	int y;
	int step;
};

Node::Node()
{
}

Node::Node(int x, int y, int step) {
	this->x = x;
	this->y = y;
	this->step = step;
}

Node::~Node()
{
}
int dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
int BFS(char map[][MAX_NUM], int sx, int sy, int ex, int ey) {
	queue<Node> que;
	Node node(sx, sy, 0);
	que.push(node);
	flag[sx][sy] = true;
	while (!que.empty())
	{
		Node cur = que.front();
		que.pop();
		if (cur.x == ex && cur.y == ey)
		{
			return cur.step;
		}
		else
		{
			for (int i = 0; i < 4; i++)
			{
				int k = cur.x + dir[i][0];
				int v = cur.y + dir[i][1];
				if (k>=0&&k<H&&v>=0&&v<W&&map[k][v]!='X'&&!flag[k][v])
				{
					Node temp(k, v, cur.step + 1);
					que.push(temp);
					flag[k][v] = true;
				}
			}
		}
	}
	return -1;

}

int main()
{
	int sx, sy, arr[10][2];
	char map[MAX_NUM][MAX_NUM];
	while (cin >> H >> W >> N && H && W)
	{
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> map[i][j];
				if (map[i][j] == 'S')
				{
					map[i][j] = '.';
					sx = i;
					sy = j;
				}
				if (isdigit(map[i][j]))
				{
					int index = map[i][j] - '0';
					arr[index][0] = i;
					arr[index][1] = j;
				}
			}
		}
		arr[0][0] = sx;
		arr[0][1] = sy;
		int res = 0;
		for (int i = 0; i+1 <= N; i++)
		{
			memset(flag, false, sizeof(flag));
			res += BFS(map, arr[i][0], arr[i][1], arr[i + 1][0], arr[i + 1][1]);
		}
		cout << res << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:96:25: error: 'memset' was not declared in this scope
   96 |                         memset(flag, false, sizeof(flag));
      |                         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <queue>
  +++ |+#include <cstring>
    4 | #define MAX_NUM 1010
Language: C++

/*
 * AOJ 0558: Cheese
 * ?¢???????m*n???????????????????????????1???N??¨???N?????\??????????¢??????????????±????????????????1???N???????????????
 * ?±???????BFS???Queue??????Dijkstra???
 * ????????????S????????????1???N????????????????????\??¨BFS?±?N?¬???????????????´??????????????????
 */

#include <cstdio>
#include <iostream>
#include <queue>

using namespace std;

typedef pair<int, int> pii;

int m, n, N;
char mat[1002][1002];
int d[1002][1002];
int sx[10], sy[10];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int ans;

int bfs(int sx, int sy, int tx, int ty) {
  memset(d, -1, sizeof(d));
  d[sx][sy] = 0;
  queue<pii> q;
  q.push(make_pair(sx, sy));
  int x, y, xx, yy;
  while (!q.empty()) {
    pii cur = q.front();
    q.pop();
    x = cur.first;
    y = cur.second;
    for (int i = 0; i < 4; ++i) {
      xx = x + dx[i];
      yy = y + dy[i];
      if (xx >= 0 && xx < m && yy >= 0 && yy < n && mat[xx][yy] != 'X' && d[xx][yy] == -1) {
        d[xx][yy] = d[x][y] + 1;
        if (xx == tx && yy == ty) {
          return d[xx][yy];
        }
        q.push(make_pair(xx, yy));
      }
    }
  }

}

void solve() {
  ans = 0;
  for (int i = 0; i < m; ++i) {
    cin >> mat[i];
    for (int j = 0; j < n; ++j) {
      if (mat[i][j] == 'S') {
        sx[0] = i;
        sy[0] = j;
      } else if (mat[i][j] >= '1' && mat[i][j] <= '9') {
        int t = mat[i][j] - '0';
        sx[t] = i;
        sy[t] = j;
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    int tmp = bfs(sx[i - 1], sy[i - 1], sx[i], sy[i]);
    ans += tmp;
  }
}

int main() {
  cin >> m >> n >> N;
  solve();
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int bfs(int, int, int, int)':
a.cc:25:3: error: 'memset' was not declared in this scope
   25 |   memset(d, -1, sizeof(d));
      |   ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   10 | #include <queue>
  +++ |+#include <cstring>
   11 | 
a.cc:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^
Language: C++

#include <cstdio>
#include <vector>

const int MAX_SIZE = 1000;
char field[MAX_SIZE + 1][MAX_SIZE + 1];

const int STEP_NUM = 4;
const int STEP[STEP_NUM][STEP_NUM] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

using Position = std::pair<int,int>;

const int MAXN = 10;
Position locations[MAXN];
 
int H, W, N;

int get_shortest_distance(int current_HP)
{
	int sx = locations[current_HP-1].first;
	int sy = locations[current_HP-1].second;
	int ex = locations[current_HP].first;
	int ey = locations[current_HP].second;

	bool is_visit[MAX_SIZE + 1][MAX_SIZE + 1]={};
	is_visit[sx][sy]=true;

	std::vector<Position> frontier(1,Position{sx,sy});
	for(int step=0;step<W*H;step++)
	{
		std::vector<Position> next_frontier;
		for(auto p:frontier)
			for(int i=0;i<STEP_NUM;i++)
			{
				int nx = p.first+STEP[i][0];
				int ny = p.second+STEP[i][1];
				if(nx==ex && ny==ey)	return step+1;
				if(nx<0 || H<=nx) 		continue;
				if(ny<0 || W<=ny) 		continue;
				if(field[nx][ny]=='X') 	continue;
				if(is_visit[nx][ny]) 	continue;
				next_frontier.push_back(std::make_pair(nx,ny));
				is_visit[nx][ny] = true;
			}
		frontier = next_frontier;
	}
	return -1;
}

int solve()
{
	int total_step = 0;
	for(int i=1;i<N+1;i++)
		total_step += get_shortest_distance(i);
	return total_step;
}

int main()
{
	scanf("%d %d %d", &H, &W, &N);
	for(int i=0; i<H; i++)
		scanf("%s", field[i]);
	for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
		{
			if(field[i][j]=='S')
				locations[0] = std::make_pair(i,j);
			if(isdigit(field[i][j]))
				locations[field[i][j]-'0'] = std::make_pair(i,j);
		}
	printf("%d\n", solve());
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:28: error: 'isdigit' was not declared in this scope
   67 |                         if(isdigit(field[i][j]))
      |                            ^~~~~~~
Language: C++

#include <cstdio>
#include <vector>

const int MAX_SIZE = 1000;
char field[MAX_SIZE + 1][MAX_SIZE + 1];

const int STEP_NUM = 4;
const int STEP[STEP_NUM][STEP_NUM] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

using Position = std::pair<int,int>;

const int MAXN = 10;
Position locations[MAXN];
 
int H, W, N;

int get_shortest_distance(int current_HP)
{
	int sx = locations[current_HP-1].first;
	int sy = locations[current_HP-1].second;
	int ex = locations[current_HP].first;
	int ey = locations[current_HP].second;

	bool is_visit[MAX_SIZE + 1][MAX_SIZE + 1]={};
	is_visit[sx][sy]=true;

	std::vector<Position> frontier;
	frontier.push_back(Position{sx,sy});
	for(int step=0;step<W*H;step++)
	{
		std::vector<Position> next_frontier;
		for(auto p:frontier)
			for(int i=0;i<STEP_NUM;i++)
			{
				int nx = p.first+STEP[i][0];
				int ny = p.second+STEP[i][1];
				if(nx==ex && ny==ey)	return step+1;
				if(nx<0 || H<=nx) 		continue;
				if(ny<0 || W<=ny) 		continue;
				if(field[nx][ny]=='X') 	continue;
				if(is_visit[nx][ny]) 	continue;
				next_frontier.push_back(std::make_pair(nx,ny));
				is_visit[nx][ny] = true;
			}
		frontier = next_frontier;
	}
	return -1;
}

int solve()
{
	int total_step = 0;
	for(int i=1;i<N+1;i++)
		total_step += get_shortest_distance(i);
	return total_step;
}

int main()
{
	scanf("%d %d %d", &H, &W, &N);
	for(int i=0; i<H; i++)
		scanf("%s", field[i]);
	for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
		{
			if(field[i][j]=='S')
				locations[0] = std::make_pair(i,j);
			if(isdigit(field[i][j]))
				locations[field[i][j]-'0'] = std::make_pair(i,j);
		}
	printf("%d\n", solve());
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:28: error: 'isdigit' was not declared in this scope
   68 |                         if(isdigit(field[i][j]))
      |                            ^~~~~~~
Language: C++

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

#define p(x) cout << "(" << x.first << "," << x.second << ")" << endl;

using namespace std;
const int MAX_H = 1005;
const int MAX_W = 1005;

char D[MAX_H][MAX_W];
bool visited[MAX_H][MAX_W];

int H, W, N;

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

typedef pair<int, int> PII;
typedef pair<PII, int> PIII;
typedef vector<PII> VII;

int bfs(PII from, PII to) {
  queue<PIII> que;
  memset(visited, false, sizeof(visited[0][0]) * MAX_H * MAX_W);

  que.push(make_pair(from, 0));
  while (!que.empty()) {
    PIII p = que.front(); que.pop();
    int d = p.second;
    if (p.first == to) {
      return d;
    }
    for (int k = 0; k < 4; k++) {
      int i2 = p.first.first + dx[k];
      int j2 = p.first.second + dy[k];
      if (0 <= i2 && i2 < H && 0 <= j2 && j2 < W && D[i2][j2] != 'X' && !visited[i2][j2]) {
        visited[i2][j2] = true;
        que.push(make_pair(make_pair(i2, j2), d+1));
      }
    }
  }
  return -1;
}

int main() {
  cin >> H >> W >> N;

  VII pos(N+1);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      D[i][j] = c;
      if (c == 'S') {
        pos[0] = make_pair(i, j);
      } else if (c > '0') {
        pos[c - '0'] = make_pair(i, j);
      }
    }
  }

  int res = 0;
  for (int i = 0; i < N; i++) {
    res += bfs(pos[i], pos[i+1]);
  }
  cout << res << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int bfs(PII, PII)':
a.cc:26:3: error: 'memset' was not declared in this scope
   26 |   memset(visited, false, sizeof(visited[0][0]) * MAX_H * MAX_W);
      |   ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <queue>
  +++ |+#include <cstring>
    4 | #include <vector>
Language: C++

#include<queue>
#include<cctype>
#include<cstdio>

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

using namespace std;

typedef pair<int , int > pii;


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

int h,w;
char grid[1010][1010];

int sortestDestance(int sx,int sy,int gx,int gy)
{
	static bool visited[1010][1010];
	rep(i,h)rep(j,w)  visited[i][j] = false;
	visited[sy][sx] = true;
	
	queue< pair< int ,pii > > qu;
	qu.push(mp(0,mp(sy,sx)));
	while(1)
	{
		pair<int ,pii> a = qu.front();
		qu.pop();
		int d = a.first,x = a.second.second,y = a.second.first;
		if(x == gx && y == gy) return d;
		
		rep(i,4)
		{
			int xx = x + dx[i], yy = y + dy[i];
			 if(0<=xx && xx<w && 0<=yy && yy<h && grid[yy][xx]!='X' && !visited[yy][xx])
			{
                visited[yy][xx]=true;
                qu.push(mp(d+1,mp(yy,xx)));
            }

		}
	}
}



int main(){
    int n;  scanf("%d%d%d",&h,&w,&n);
    int cx[10],cy[10];
    rep(i,h){
        scanf("%s",grid[i]);
        rep(j,w){
            if(grid[i][j]=='S')     cx[0]=j,cy[0]=i;
            if(isdigit(grid[i][j])) cx[grid[i][j]-'0']=j,cy[grid[i][j]-'0']=i;
        }
    }
 
    int cost=0;
    rep(i,n)    cost+=shortestDistance(cx[i],cy[i],cx[i+1],cy[i+1]);
    printf("%d\n",cost);
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:23: error: 'shortestDistance' was not declared in this scope; did you mean 'sortestDestance'?
   60 |     rep(i,n)    cost+=shortestDistance(cx[i],cy[i],cx[i+1],cy[i+1]);
      |                       ^~~~~~~~~~~~~~~~
      |                       sortestDestance
Language: C++

#include <iostream>
#include <queue>
#include <tuple>
#include <string.h>

#define BLOCK -1
#define ROAD 0
#define GONE -2

void clear(std::queue<std::tuple<int, int, int, int*>> &q) {
	while (!q.empty()) {
		auto& item = q.front();
		auto& map = std::get<int*>(item);
		delete[] map;
		q.pop();
	}
}

int* copy(int* base, int size) {
	int* copied = new int[size];
	std::memcpy(copied, base, size);
	return copied;
}

int main() {
	int w, h, total;
	std::cin >> h >> w >> total;
	int* original = new int[w * h];
	char temp;
	int positionW = -1, positionH = -1;

	for (int i = 0; i < w * h; i++) {
		std::cin >> temp;
		if (temp == 'S') {
			positionW = i % w;
			positionH = i / w;
			original[i] = ROAD;
		}
		else if (temp == '.') {
			original[i] = ROAD;
		}
		else if (temp == 'X') {
			original[i] = BLOCK;
		}
		else {
			original[i] = temp - '0';
		}
	}

	int* first = new int[w * h];
	std::memcpy(first, original, sizeof(int) * w * h);

	int next = 1;
	std::queue<std::tuple<int, int, int, int*>> queue;
	queue.push(std::make_tuple(positionW, positionH, 0, first));

	while (queue.size() != 0) {
		auto item = queue.front();
		queue.pop();

		int posW = std::get<0>(item);
		int posH = std::get<1>(item);
		int step = std::get<2>(item);
		int* map = std::get<3>(item);

		if (posW < 0 || posW >= w || posH < 0 || posH >= h)
			continue;

		int current = map[posH * w + posW];
		if (current == BLOCK || current == GONE) {
			delete[] map;
			continue;
		}

		map[posH * w + posW] = GONE;

		if (current > 0 && current == next) {
			next++;
			clear(queue);
			// if finished
			if (next > total) {
				std::cout << step << std::endl;
				return 0;
			}
			std::memcpy(map, original, sizeof(int) * w * h);
			map[posH * w + posW] = GONE;
		}

		step++;
		queue.push(std::make_tuple(posW + 1, posH, step, copy(map, sizeof(int) * w * h)));
		queue.push(std::make_tuple(posW - 1, posH, step, copy(map, sizeof(int) * w * h)));
		queue.push(std::make_tuple(posW, posH + 1, step, copy(map, sizeof(int) * w * h)));
		queue.push(std::make_tuple(posW, posH - 1, step, copy(map, sizeof(int) * w * h)));
		delete[] map;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int* copy(int*, int)':
a.cc:21:14: error: 'memcpy' is not a member of 'std'; did you mean 'wmemcpy'?
   21 |         std::memcpy(copied, base, size);
      |              ^~~~~~
      |              wmemcpy
a.cc: In function 'int main()':
a.cc:51:14: error: 'memcpy' is not a member of 'std'; did you mean 'wmemcpy'?
   51 |         std::memcpy(first, original, sizeof(int) * w * h);
      |              ^~~~~~
      |              wmemcpy
a.cc:85:30: error: 'memcpy' is not a member of 'std'; did you mean 'wmemcpy'?
   85 |                         std::memcpy(map, original, sizeof(int) * w * h);
      |                              ^~~~~~
      |                              wmemcpy
Language: C++

#include<bits/stdc++.h>
#define x first
#define y second
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;pair<int,int> p[12];bool t[1010][1010],v[1010][1010];queue<pair<int,pair<int,int> > >Q;int main(){int h,w,k,a=0,dx[]={0,1,0,-1},dy[]={1,0,-1,0};cin>>h>>w>>k;rep(i,0,h)rep(j,0,w){t[i][j]=true;char z;cin>>z;if(z=='X')t[i][j]=0;if(z=='S')p[0]=make_pair(i,j);if(z>'0'&&z<='9')p[z-'0']=make_pair(i,j);}rep(r,0,k){Q.push(make_pair(0,p[r]));rep(i,0,h)rep(j,0,w)v[i][j]=0;v[p[r].x][p[r].y]=1;while(1){int L=Q.front().x,Y=Q.front().y.x,X=Q.front().y.y;if(Y==p[r+1].x&&X==p[r+1].y){a+=L;break;}rep(i,0,4){int f=Y+dy[i],g=X+dx[i];if(f+1&&f<h&&g+1&&g<w)if(t[f][g]==1&&vis[f][g]==0)v[f][g]=1;Q.push(make_pair(L+1,make_pair(f,g)));}Q.pop();}while(!Q.empty())Q.pop();}cout<<a<<endl;return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:577: error: 'vis' was not declared in this scope
    5 | using namespace std;pair<int,int> p[12];bool t[1010][1010],v[1010][1010];queue<pair<int,pair<int,int> > >Q;int main(){int h,w,k,a=0,dx[]={0,1,0,-1},dy[]={1,0,-1,0};cin>>h>>w>>k;rep(i,0,h)rep(j,0,w){t[i][j]=true;char z;cin>>z;if(z=='X')t[i][j]=0;if(z=='S')p[0]=make_pair(i,j);if(z>'0'&&z<='9')p[z-'0']=make_pair(i,j);}rep(r,0,k){Q.push(make_pair(0,p[r]));rep(i,0,h)rep(j,0,w)v[i][j]=0;v[p[r].x][p[r].y]=1;while(1){int L=Q.front().x,Y=Q.front().y.x,X=Q.front().y.y;if(Y==p[r+1].x&&X==p[r+1].y){a+=L;break;}rep(i,0,4){int f=Y+dy[i],g=X+dx[i];if(f+1&&f<h&&g+1&&g<w)if(t[f][g]==1&&vis[f][g]==0)v[f][g]=1;Q.push(make_pair(L+1,make_pair(f,g)));}Q.pop();}while(!Q.empty())Q.pop();}cout<<a<<endl;return 0;}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ^~~
Language: C++

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

struct Node{
	int x,y;
};

const int max_n=1000+10;
int h,w,n,sx,sy,dx[]={0,0,-1,1},dy[]={-1,1,0,0},d[max_n][max_n],ans;
Node sN;
char c[max_n][max_n];

void bfs(int m){
	if(m>n)return;
	queue<Node> q;
	memset(d,0,sizeof(d));
	q.push(sN);
	d[sN.x][sN.y]=1;
	while(!q.empty()){
		Node p=q.front();
		q.pop();
		if(c[p.x][p.y]=='0'+m){
		    ans+=d[p.x][p.y]-1;
		    sN.x=p.x;
		    sN.y=p.y;
		    bfs(m+1);
		    return;
		}
		for(int i=0;i<4;i++){
			Node nN;
			nN.x=p.x+dx[i];
			nN.y=p.y+dy[i];
			if(nN.x>=0 && nN.y<h 
            && nN.y>=0 && nN.y<w 
		   	&& c[nN.x][nN.y]!='X' && !d[nN.x][nN.y]){
				q.push(nN);
				d[nN.x][nN.y]=d[p.x][p.y]+1;
			}
		}
	}
}

int main(){
    scanf("%d%d%d",&h,&w,&n);
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++){
            cin>>c[i][j];
            if(c[i][j]=='S'){sN.x=i;sN.y=j;}
        }
    bfs(1);
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:18:9: error: 'memset' was not declared in this scope
   18 |         memset(d,0,sizeof(d));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <queue>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

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

using namespace std;
using ll = long long;
const ll INF = 1e9;

ll H, W, N;
vector<vector<ll>> F(10);
string M[1001];

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

ll bfs(ll sx, ll sy, ll gx, ll gy) {
    ll d[1001][1001];
    queue<vector<ll>> que;
    for(ll i = 0; i < H; i++) for (ll j = 0; j < W; j++) d[i][j] = INF;

    que.push({sx, sy});
    d[sy][sx] = 0;

    while(que.size()) {
        vector<ll> p = que.front(); que.pop();
        if (p[0] == gx && p[1] == gy) break;

        for (ll i = 0; i < 4; i++) {
            ll nx = p[0] + dx[i], ny = p[1] + dy[i];
            if (M[ny][nx] != 'X' && nx >= 0 && nx < W && ny >= 0 && ny < H && d[ny][nx] == INF) {
                que.push({nx, ny});
                d[ny][nx] = d[p[1]][p[0]] + 1;
            }
        }
    }

    return d[gy][gx];
}

ll main() {
    ll ans = 0;
    cin >> H >> W >> N;
    for (ll i = 0; i < H; i++) {
        cin >> M[i];
        for (ll k = 0; k < W; k++) {
            if (M[i][k] == 'S') {
                F[0] = {k, i};
            }
            if (isdigit(M[i][k])) {
                F[M[i][k] - '0'] = {k, i};
            }
        }
    }

    for (ll i = 0; i < N; i++) {
        ans += bfs(F[i][0], F[i][1], F[i+1][0], F[i+1][1]);
    }

    cout << ans << endl;

    return 0;
}

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

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

typedef struct{
 int x;
 int y;
}P;

char graph[1000][1000];
P aim[10];
P s,g;//s?????????g??????
int N,W,H;
int vis[1000][1000]; 
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int bfs(P s,P g);

int main(){
    int i,j,t,step=0;
    cin>>H>>W>>N;
    
    for(i=0;i<H;i++)
    for(j=0;j<W;j++){
        cin>>graph[i][j];
      if(graph[i][j]<='9'&&graph[i][j]>='1'){ 
         t=graph[i][j]-'0';
         aim[t].x=i;
         aim[t].y=j;
      } 
      else if(graph[i][j]=='S'){
          s.x=i;
          s.y=j;
          graph[i][j]='.';
      }
    
    for(i=1;i<=N;i++){
       g.x=aim[i].x;
       g.y=aim[i].y;
       step+=bfs(s,g);
       s.x=g.x;
       s.y=g.y;
       graph[g.x][g.y]='.';
    }
   
    cout<<step<<endl;
}

int bfs(P s,P g){
    queue<P> que;
      P n;
    
    for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
     vis[i][j]=-1;
     
     que.push(s);
     vis[s.x][s.y]=0;
     
     while(que.size()){
         
       P p=que.front();
         que.pop();
       if(p.x==g.x&&p.y==g.y)
       break;
       
       for(int i=0;i<4;i++){
           n.x=p.x+dx[i];
           n.y=p.y+dy[i];
        if(0<=n.x&&n.x<H&&0<=n.y&&n.y<W&&graph[n.x][n.y]!='X'&&vis[n.x][n.y]==-1){
               que.push(n);
               vis[n.x][n.y]=vis[p.x][p.y]+1;
           }
       }
   }
     return vis[g.x][g.y];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:17: error: a function-definition is not allowed here before '{' token
   49 | int bfs(P s,P g){
      |                 ^
a.cc:77:2: error: expected '}' at end of input
   77 | }
      |  ^
a.cc:19:11: note: to match this '{'
   19 | int main(){
      |           ^
Language: C++

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

typedef pair<int, int> P;

const int INF = 1<<10;

int H, W, N;
char field[1010][1010];
int dx[4] = {0,0,1,-1}, dy[4] = {1,-1,0,0};
int tim[1010][1010];
int sx, sy;
int cnt;
int hp = 1;

int bfs() {
  for (int i = 1; i <= N; i++) {
    bool flag = false;
    queue<P> q;
    for (int y = 0; y < H; y++)
      for (int x = 0; x < W; x++) tim[y][x] = INF;
    q.push(P(sx, sy));
    tim[sy][sx] = 0;

    while (!q.empty() && !flag) {
      int x = q.front().first;
      int y = q.front().second;
      int c = tim[y][x];
      q.pop();
      for (int j = 0; j < 4; j++) {
        int tx = x + dx[j], ty = y + dy[j];
        if (tx < 0 || ty < 0 || tx >= W || ty >= H ||
            tim[ty][tx] != INF || field[ty][tx] == 'X') continue;
        if (field[ty][tx] == '0' + i) {
          cnt += c + 1;
          sx = tx; sy = ty;
          flag = true;
          break;
        }
        tim[ty][tx] = c + 1;
        q.push(P(tx, ty));
      }
    }
  }
}

int main() {
  cin >> H >> W >> N;
  for (int y = 0; y < H; y++) {
    cin >> field[y];
    for (int x = 0; x < W; x++) {
      if (field[y][x] == 'S') {
        sx = x; sy = y;
        field[y][x] = '.';
      }
    }
  }

Compiler output:
a.cc: In function 'int bfs()':
a.cc:46:1: warning: no return statement in function returning non-void [-Wreturn-type]
   46 | }
      | ^
a.cc: In function 'int main()':
a.cc:58:4: error: expected '}' at end of input
   58 |   }
      |    ^
a.cc:48:12: note: to match this '{'
   48 | int main() {
      |            ^
Language: C++

//
//  0558.cpp
//  
//
//  Created by Yoshida Satoshi on 2017/11/16.
//
//

#include <iostream>
#include <queue>
#include <utility>
#include <stdlib.h>

#define MAX 1000
#define INF 100000000
#define FOR(index,max) for(int index=0;index<max;index++)

using namespace std;

typedef pair<int, int> P;

int main(){
    int dx[4]={1,-1,0,0};
    int dy[4]={0,0,1,-1};
    
    int nx,ny;
    
    queue<P> que;
    int H,W,N;
    int state[MAX][MAX];//0:????????°or????????? -1:????????¶???
    bool isVisited[MAX][MAX];
    int d[MAX][MAX];
    int ans=0;
    int sx[9];
    int sy[9];
    P p;
    char in;
    cin>>H>>W>>N;
    FOR(i,H){
        FOR(j,W){
            cin>>in;
            if(in=='S'){
                sx[0]=i;
                sy[0]=j;
                state[i][j]=0;
            }
            else if(in=='X') state[i][j]=-1;
            else if(in=='.') state[i][j]=0;
            else{
                state[i][j]=0;
                sx[in-'0']=i;
                sy[in-'0']=j;
                
            }
        }
    }
    
    FOR(k,N){
        FOR(i,H){
            FOR(j,W){
                isVisited[i][j]=false;
                d[i][j]=INF;
            }
        }
        que.push(P(sx[k],sy[k]));
        d[sx[k]][sy[k]]=0;
        while(que.size()){
            p=que.front();
            que.pop();
            
            if(p==P(sx[k+1],sy[k+1]))   break;
            
            FOR(l,4){
                nx=p.first+dx[l];
                ny=p.seond+dy[i];
                
                if(!(nx<0||ny<0||nx>H-1||ny>W-1||state[nx][ny]==-1||d[nx][ny]==INF)){
                    que.push(P(nx,ny));
                    d[nx][ny]=d[p.first][p.second]+1;
                }
            }
        }
        
        ans += d[start[k+1].first][start[k+1].second];
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:22: error: 'P' {aka 'struct std::pair<int, int>'} has no member named 'seond'; did you mean 'second'?
   75 |                 ny=p.seond+dy[i];
      |                      ^~~~~
      |                      second
a.cc:75:31: error: 'i' was not declared in this scope
   75 |                 ny=p.seond+dy[i];
      |                               ^
a.cc:84:18: error: 'start' was not declared in this scope
   84 |         ans += d[start[k+1].first][start[k+1].second];
      |                  ^~~~~
Language: C++

//
//  0558.cpp
//  
//
//  Created by Yoshida Satoshi on 2017/11/16.
//
//

#include <iostream>
#include <queue>
#include <utility>
#include <stdlib.h>

#define MAX 1000
#define INF 100000000
#define FOR(index,max) for(int index=0;index<max;index++)

using namespace std;

typedef pair<int, int> P;

int main(){
    int dx[4]={1,-1,0,0};
    int dy[4]={0,0,1,-1};
    
    int nx,ny;
    
    queue<P> que;
    int H,W,N;
    int state[MAX][MAX];//0:????????°or????????? -1:????????¶???
    bool isVisited[MAX][MAX];
    int d[MAX][MAX];
    int ans=0;
    int sx[9];
    int sy[9];
    P p;
    char in;
    cin>>H>>W>>N;
    FOR(i,H){
        FOR(j,W){
            cin>>in;
            if(in=='S'){
                sx[0]=i;
                sy[0]=j;
                state[i][j]=0;
            }
            else if(in=='X') state[i][j]=-1;
            else if(in=='.') state[i][j]=0;
            else{
                state[i][j]=0;
                sx[in-'0']=i;
                sy[in-'0']=j;
                
            }
        }
    }
    
    FOR(k,N){
        FOR(i,H){
            FOR(j,W){
                isVisited[i][j]=false;
                d[i][j]=INF;
            }
        }
        que.push(P(sx[k],sy[k]));
        d[sx[k]][sy[k]]=0;
        while(que.size()){
            p=que.front();
            que.pop();
            
            if(p==P(sx[k+1],sy[k+1]))   break;
            
            FOR(l,4){
                nx=p.first+dx[l];
                ny=p.second+dy[l];
                
                if(!(nx<0||ny<0||nx>H-1||ny>W-1||state[nx][ny]==-1||d[nx][ny]==INF)){
                    que.push(P(nx,ny));
                    d[nx][ny]=d[p.first][p.second]+1;
                }
            }
        }
        
        ans += d[start[k+1].first][start[k+1].second];
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:18: error: 'start' was not declared in this scope
   84 |         ans += d[start[k+1].first][start[k+1].second];
      |                  ^~~~~
Language: C++

//
//  0558.cpp
//  
//
//  Created by Yoshida Satoshi on 2017/11/16.
//
//

#include <iostream>
#include <queue>
#include <utility>
#include <stdlib.h>

#define MAX 1000
#define INF 100000000
#define FOR(index,max) for(int index=0;index<max;index++)

using namespace std;

typedef pair<int, int> P;

int ctoi(char c){
    switch(c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default : return -1;
    }
}

int main(){
    int dx[4]={1,-1,0,0};
    int dy[4]={0,0,1,-1};
    
    int nx,ny;
    
    queue<P> que;
    int H,W,N;
    int state[MAX][MAX];//0:????????°or????????? -1:????????¶???
    int d[MAX][MAX];
    int ans=0;
    int sx[9];
    int sy[9];
    P p;
    char in;
    cin>>H>>W>>N;
    FOR(i,H){
        FOR(j,W){
            cin>>in;
            if(in=='S'){
                sx[0]=i;
                sy[0]=j;
                state[i][j]=0;
            }
            else if(in=='X') state[i][j]=-1;
            else if(in=='.') state[i][j]=0;
            else{
                state[i][j]=0;
                sx[ctoi(in)]=i;
                sy[ctoi(in)]=j;
                
            }
        }
    }
    
    FOR(k,N){
        FOR(i,H){
            FOR(j,W){
                isVisited[i][j]=false;
                d[i][j]=INF;
            }
        }
        que.push(P(sx[k],sy[k]));
        d[sx[k]][sy[k]]=0;
        while(que.size()){
            p=que.front();
            que.pop();
            
            if(p==P(sx[k+1],sy[k+1]))   break;
            
            FOR(l,4){
                nx=p.first+dx[l];
                ny=p.second+dy[l];
                
                if(!(nx<0||ny<0||nx>H-1||ny>W-1||state[nx][ny]==-1||d[nx][ny]==INF)){
                    que.push(P(nx,ny));
                    d[nx][ny]=d[p.first][p.second]+1;
                }
            }
        }
        
        ans += d[sx[k+1]][sy[k+1]];
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:17: error: 'isVisited' was not declared in this scope
   76 |                 isVisited[i][j]=false;
      |                 ^~~~~~~~~
Language: C++

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

int h,w,n;
int en;//energy indicates which cheese to eat next
const int MAX_N=1000;
char map[MAX_N][MAX_N];
struct point{
    int x,y;
    int step;
    point(int xx, int yy, int ss){
        x=xx;
        y=yy;
        step=ss;
    }
};
struct point p[10];
int dx[4]={-1,0,1,0}, dy[4]={0,1,0,-1};

int ok(int x, int y){
    if(x>=0 && x<h && y>=0 && y<w) return 1;
    return 0;
}

int bfs(int next){
    int nextcheese = next +1; int res=0;
    
    queue<point> q;
    point cur(p[next].x, p[next].y,0);
    q.push(cur);
    while(q.size()){
        cur = q.front(); q.pop(); 
        int x=cur.x, y=cur.y;
        int nx, ny;
        for(int i=0; i<4; i++){
            nx = x+dx[i]; ny=y+dy[i];
            if(ok(nx, ny)){
                if((map[nx][ny]-'0')==nextcheese) return ++cur.step;
                if(map[nx][ny]=='.'){
                    point temp(nx, ny, cur.step+1);
                    q.push(temp);
                }
            }
        }
    }
}

void solve(){
    int sx, sy;
    scanf("%d%d%d", &h, &w, &n);
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>ch; map[i][j]=ch;
            switch(ch){
                case '.': break;
                case 'X': break;
                case 'S': p[0].x = i; p[0].y = j; break;
                default:
                int t=ch-'0';
                p[t].x = i; p[t].y = j;
            }
        }
    }
    int step=0;
    for(int i=0; i<n; i++){
        step+=bfs(i);
    }
    printf("%d", step);
}


int main(){
    solve();
}


Compiler output:
a.cc:18:18: error: no matching function for call to 'point::point()'
   18 | struct point p[10];
      |                  ^
a.cc:12:5: note: candidate: 'point::point(int, int, int)'
   12 |     point(int xx, int yy, int ss){
      |     ^~~~~
a.cc:12:5: note:   candidate expects 3 arguments, 0 provided
a.cc:9:8: note: candidate: 'constexpr point::point(const point&)'
    9 | struct point{
      |        ^~~~~
a.cc:9:8: note:   candidate expects 1 argument, 0 provided
a.cc:9:8: note: candidate: 'constexpr point::point(point&&)'
a.cc:9:8: note:   candidate expects 1 argument, 0 provided
a.cc: In function 'void solve()':
a.cc:54:18: error: 'ch' was not declared in this scope; did you mean 'h'?
   54 |             cin>>ch; map[i][j]=ch;
      |                  ^~
      |                  h
a.cc: In function 'int bfs(int)':
a.cc:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
Language: C++

#include <cstdio>
#include <queue>
using namespace std;

int h, w, n;
const int MAX_N = 1000;
char map[MAX_N][MAX_N];
struct point{
	int x, y;
	int step;
	point(){
		x = 0; y = 0; step = 0;
	}
	point(int xx, int yy, int ss){
		x = xx;
		y = yy;
		step = ss;
	}
};
struct point p[10];
int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };

int ok(int x, int y){
	if (x >= 0 && x<h && y >= 0 && y<w) return 1;
	return 0;
}

int bfs(int next){
	int nextcheese = next + 1; int res = 0;

	queue<point> q;
	point cur(p[next].x, p[next].y, 0);
	q.push(cur);
	while (q.size()){
		cur = q.front(); q.pop();
		int x = cur.x, y = cur.y;
		int nx, ny;
		for (int i = 0; i<4; i++){
			nx = x + dx[i]; ny = y + dy[i];
			if (ok(nx, ny)){
				if ((map[nx][ny] - '0') == nextcheese) return ++cur.step;
				if (map[nx][ny] == '.'){
					point temp(nx, ny, cur.step + 1);
					q.push(temp);
				}
			}
		}
	}
}

void solve(){
	int sx, sy;
	scanf("%d%d%d", &h, &w, &n);
	for (int i = 0; i<h; i++){
		for (int j = 0; j<w; j++){
			char ch;
			cin >> ch; map[i][j] = ch;
			switch (ch){
			case '.': break;
			case 'X': break;
			case 'S': p[0].x = i; p[0].y = j; break;
			default:
				int t = ch - '0';
				p[t].x = i; p[t].y = j;
			}
		}
	}
	int step = 0;
	for (int i = 0; i<n; i++){
		step += bfs(i);
	}
	printf("%d", step);
}


int main(){
	solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:57:25: error: 'cin' was not declared in this scope
   57 |                         cin >> ch; map[i][j] = ch;
      |                         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <queue>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc: In function 'int bfs(int)':
a.cc:49:1: warning: control reaches end of non-void function [-Wreturn-type]
   49 | }
      | ^
Language: C++

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

int h,w,n;
int en;//energy indicates which cheese to eat next
const int MAX_N=1000;
char map[MAX_N][MAX_N];
struct point{
    int x,y;
    int step;
    point(int xx, int yy, int ss){
        x=xx;
        y=yy;
        step=ss;
    }
};
struct point p[10];
int dx[4]={-1,0,1,0}, dy[4]={0,1,0,-1};

int ok(int x, int y){
    if(x>=0 && x<h && y>=0 && y<w) return 1;
    return 0;
}

int bfs(int next){
    int nextcheese = next +1; int res=0;
    
    queue<point> q;
    point cur(p[next].x, p[next].y,0);
    q.push(cur);
    while(q.size()){
        cur = q.front(); q.pop(); 
        int x=cur.x, y=cur.y;
        int nx, ny;
        for(int i=0; i<4; i++){
            nx = x+dx[i]; ny=y+dy[i];
            if(ok(nx, ny)){
                if((map[nx][ny]-'0')==nextcheese) return ++cur.step;
                if(map[nx][ny]=='.'){
                    point temp(nx, ny, cur.step+1);
                    q.push(temp);
                }
            }
        }
    }
}

void solve(){
    int sx, sy;
    scanf("%d%d%d", &h, &w, &n);
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char ch;
            cin>>ch; map[i][j]=ch;
            switch(ch){
                case '.': break;
                case 'X': break;
                case 'S': p[0].x = i; p[0].y = j; break;
                default:
                int t=ch-'0';
                p[t].x = i; p[t].y = j;
            }
        }
    }
    int step=0;
    for(int i=0; i<n; i++){
        step+=bfs(i);
    }
    printf("%d\n", step);
}


int main(){
    solve();
}


Compiler output:
a.cc:19:18: error: no matching function for call to 'point::point()'
   19 | struct point p[10];
      |                  ^
a.cc:13:5: note: candidate: 'point::point(int, int, int)'
   13 |     point(int xx, int yy, int ss){
      |     ^~~~~
a.cc:13:5: note:   candidate expects 3 arguments, 0 provided
a.cc:10:8: note: candidate: 'constexpr point::point(const point&)'
   10 | struct point{
      |        ^~~~~
a.cc:10:8: note:   candidate expects 1 argument, 0 provided
a.cc:10:8: note: candidate: 'constexpr point::point(point&&)'
a.cc:10:8: note:   candidate expects 1 argument, 0 provided
a.cc: In function 'int bfs(int)':
a.cc:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^