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

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#define INF 10000000
using namespace std;
typedef pair<int,int> P;

vector< vector<int> > dist;//道のりvectorが入っているvector
int n,m,p,a,b;
int t[8];
int map[30][30];

void rec(vector<int> vec,int pos){
  if(pos==b){
    dist.push_back(vec);
  }else if(vec.size()!=n){
    for(int j=0;j<m;j++){
      if(map[pos][j]!=0){
        vec.push_back(map[pos][j]);
        rec(vec,j);
        vec.erase(vec.end()-1);
      }
    }
  }
  return;
}

int main(){
  while(1){
    cin >> n >> m >> p >> a >> b;
    if(!n&&!m&&!p&&!a&&!b) break;
    for(int i=0;i<n;i++){
      scanf("%d",&t[i]);
    }
    a--;
    b--;
    memset(map,0,sizeof(map));
    for(int i=0;i<p;i++){
      int x,y,z;
      scanf("%d%d%d",&x,&y,&z);
      map[x-1][y-1] = z;
      map[y-1][x-1] = z;
    }

    vector<int> first;
    rec(first,a);

    sort(t,t+n);
    if(dist.size()){
      double min = 10000000;
      for(int i=0;i<dist.size();i++){
        double sum = 0;
        sort(dist[i].begin(),dist[i].end());
        for(int j=0;j<dist[i].size();j++){
          //printf("t[%d]=%d\n",n-1-j,t[n-1-j]);
          sum += (double)dist[i][dist[i].size()-1-j] / t[n-1-j];
        }
        if(sum<min){
          min = sum;
        }
      }
      printf("%lf\n",min);
    }else{
      cout << "Impossible" << endl;
    }
    dist.clear();
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:5: error: 'memset' was not declared in this scope
   38 |     memset(map,0,sizeof(map));
      |     ^~~~~~
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 | #define INF 10000000
a.cc:49:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   49 |     sort(t,t+n);
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cstring>


using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
int const inf = 1 << 29;

int main(){
    int w, h;
    while (cin >> w >> h && w | h){
        vector<string> grid(h);
        vector<pair<int,int>> node;
        rep(i, h){
            cin >> grid[i];
            rep(j, grid[i].size())if (grid[i][j] == 'o')node.emplace_back(i, j);
        }
        rep(i, h)rep(j, w){
            if (grid[i][j] == '*')node.emplace_back(i, j);
        }

        static int d[20][20];
        rep(i, 20)rep(j, 20)d[i][j] = inf;

        rep(i, node.size()){
            int dx[] = { 1, 0, -1, 0 }, dy[] = { 0, 1, 0, -1 };
            queue<pair<int, int>> q;
            static int dist[25][25];
            rep(j, h)rep(k, w)dist[j][k] = inf;
            dist[node[i].first][node[i].second] = 0;
            q.emplace(node[i]);

            while (q.size()){
                auto p = q.front(); q.pop();
                int cx = p.second, cy = p.first;
                rep(j, 4){
                    int nx = cx + dx[j], ny = cy + dy[j];
                    if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
                    if (grid[ny][nx] == 'x') continue;
                    if (dist[ny][nx] > dist[cy][cx] + 1){
                        dist[ny][nx] = dist[cy][cx] + 1;
                        q.emplace(ny, nx);
                    }
                }
            }

            rep(j, node.size()){
                d[i][j] = dist[node[j].first][node[j].second];
            }
        }

        int idx[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
        long long ans = inf;
        do{
            long long t = 0;
            rep(i, node.size() - 1){
                t += d[idx[i]][idx[i + 1]];
            }
            ans = min(t, ans);
        } while (next_permutation(idx + 1, idx + node.size()));
        if (ans >= inf)ans = -1;
        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:18: error: 'next_permutation' was not declared in this scope
   65 |         } while (next_permutation(idx + 1, idx + node.size()));
      |                  ^~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
const int INF = 100000000;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};

bool in_range(int a, int b){ return a >= 0 && a < b;}

void bfs(map<int,int> &M, vector<int> &G, vector<string> C, int s){
  int h = C.size(), w = C[0].length();
  queue< pair<int,int> > que;
  que.emplace(s,0);
  while(!que.empty()){
    int p = que.front().first, d = que.front().second;
    que.pop();
    if(M[p])
      G[M[p]-1] = min(d,G[M[p]-1]);
    C[p/w][p%w] = 'x';
    for(int i = 0; i < 4; ++i){
      int x = p/w + dx[i], y = p%w + dy[i], p_ = x*w + y;
      if(in_range(x,h) && in_range(y,w) && C[x][y] != 'x')
        que.emplace(p_,d+1);
    }
  }
}

vector< vector<int> > make_graph(vector<string> &C, vector<int> &D){
  int h = C.size(), w = C[0].length(), n = D.size();
  map<int,int> M;
  for(int i = 0; i < n; ++i){
    M[D[i]] = i+1;
  }
  vector< vector<int> > G(n, vector<int>(n,INF));
  for(int i = 0; i < n; ++i){
    bfs(M,G[i],C,D[i]);
  }
  return G;
}

int main(){
  int w, h;
  while(cin >> w >> h, w){
    vector<string> C(h);
    vector<int> D;
    int s;
    for(int i = 0; i < h; ++i){
      cin >> C[i];
      for(int j = 0; j < w; ++j){
        if(C[i][j] == 'o') s = i*w+j;
        if(C[i][j] == '*'){
          D.push_back(i*w+j);
        }
      }
    }
    D.push_back(s);
    vector< vector<int> > G = make_graph(C,D);
    int n = G.size()-1;
    vector<int> V(n);
    for(int i = 0; i < n; ++i) V[i] = i;
    int ans = INF;
    do{
      int t = 0, v = n;
      for(int i = 0; i < n; ++i){
        t += G[v][V[i]];
        v = V[i];
      }
      ans = min(ans,t);
    }while(next_permutation(V.begin(),V.end()));
    if(ans >= INF) ans = -1;
    cout << ans << endl;
  }
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:70:12: error: 'next_permutation' was not declared in this scope
   70 |     }while(next_permutation(V.begin(),V.end()));
      |            ^~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<string>
#include<queue>

using namespace std;
using P = pair<int, int>;

int w, h, m;
string map[20];
int d[20][20][20][20];
P dirty[20];
int diri[] = {-1, 0, 1, 0};
int dirj[] = {0, -1, 0, 1};

void bfs(int si, int sj) {
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            d[si][sj][i][j] = -1;
        }
    }
    d[si][sj][si][sj] = 0;

    queue<P> q;
    q.push(make_pair(si, sj));

    while (!q.empty()) {
        P p = q.front();
        q.pop();
        int i = p.first;
        int j = p.second;
        int cost = d[si][sj][i][j];
        for (int k = 0; k < 4; ++k) {
            int ni = i + diri[k];
            int nj = j + dirj[k];
            if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if (map[ni][nj] == 'x') continue;
            //cout << ni << nj << " "<<d[si][sj][ni][nj]<< endl;
            if (d[si][sj][ni][nj] != -1) continue;
            d[si][sj][ni][nj] = cost + 1;
            q.push(make_pair(ni, nj));
        }
    }
    // for (int i = 0; i < h; ++i) {
    //     for (int j = 0; j < w; ++j) {
    //         cout << d[si][sj][i][j] << "  ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
}

void solve() {
    for (int i = 0; i < h; ++i) {
        cin >> map[i];
    }

    m = 0;
    int ri, rj;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (map[i][j] == '*') {
                dirty[m] = make_pair(i, j);
                m++;
                bfs(i, j);
            } else if (map[i][j] == 'o') {
                ri = i;
                rj = j;
                bfs(i, j);
            }
        }
    }

    sort(dirty, dirty + m);

    int mincost = 4000;
    do {
        int cost = 0;
        int i = ri;
        int j = rj;
        for (int k = 0; k < m; ++k) {
            int toi = dirty[k].first;
            int toj = dirty[k].second;
            cost += d[i][j][toi][toj];
            if (d[i][j][toi][toj] == -1) {
                mincost = -1;
                break;
            }
            i = toi;
            j = toj;
        }
        mincost = min(cost, mincost);
    } while (next_permutation(dirty, dirty + m));

    cout << mincost << endl;
}

int main() {
    while (1) {
        cin >> w >> h;
        if (w == 0) break;
        solve();
    }
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:73:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   73 |     sort(dirty, dirty + m);
      |     ^~~~
      |     short
a.cc:92:14: error: 'next_permutation' was not declared in this scope
   92 |     } while (next_permutation(dirty, dirty + m));
      |              ^~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>

using namespace std;

struct Point {
  int y;
  int x;
  int cost;
  Point() {;}
  Point(int y1, int x1, int c) : y(y1), x(x1), cost(c) {;}
};

int width;
int height;

char str[100];
char tile[30][30];
int dist[11][10];
int dirty_y[10];
int dirty_x[10];
int map[30][30];
bool check[30][30];
int dirty_tile;
int memo[1024][10];

int calc(int depth, int visit, int where) {
  if (memo[visit][where] != -1) { return memo[visit][where]; }
  if (depth == dirty_tile) { return 0; }
  int ret = 0x0f0f0f0f;
  for (int i = 0; i < dirty_tile; i++) {
    if (visit & (1 << i)) { continue; }
    int next_visit = visit | (1 << i);
    ret = min(ret, calc(depth + 1, next_visit, i) + dist[where][i]);
  }
  return memo[visit][where] = ret;
}

int main() {
  while (scanf("%d %d", &width, &height), width != 0 && height != 0) {
    fgets(str, 99, stdin);
    for (int i = 0; i < height; i++) {
      fgets(tile[i], 29, stdin);
    }
    int start_y;
    int start_x;
    dirty_tile = 0;
    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        if (tile[y][x] == '*') {
          dirty_y[dirty_tile] = y;
          dirty_x[dirty_tile] = x;
          map[y][x] = dirty_tile;
          dirty_tile++;
        } else if (tile[y][x] == 'o') {
          start_y = y;
          start_x = x;
        }
      }
    }
    dirty_y[dirty_tile] = start_y;
    dirty_x[dirty_tile] = start_x;
    map[start_y][start_x] = dirty_tile;
    memset(dist, -1, sizeof(dist));
    static const int dy[4] = { 1, -1, 0, 0 };
    static const int dx[4] = { 0, 0, 1, -1 };
    for (int i = 0; i < dirty_tile + 1; i++) {
      queue<Point> que;
      que.push(Point(dirty_y[i], dirty_x[i], 0));
      memset(check, false, sizeof(check));
      while (!que.empty()) {
        Point now = que.front();
        que.pop();
        if (check[now.y][now.x]) { continue; }
        check[now.y][now.x] = true;
        if (tile[now.y][now.x] == '*') {
          dist[i][map[now.y][now.x]] = now.cost;
        }
        for (int i = 0; i < 4; i++) {
          int ny = now.y + dy[i];
          int nx = now.x + dx[i];
          if (ny < 0 || ny >= height || nx < 0 || nx >= width || check[ny][nx] || tile[ny][nx] == 'x') { continue; }
          que.push(Point(ny, nx, now.cost + 1));
        }
      }
    }
    for (int i = 0; i < dirty_tile; i++) {
      if (dist[dirty_tile][i] == -1) {
        puts("-1");
        goto next_loop;
      }
    }
    memset(memo, -1, sizeof(memo));
    printf("%d\n", calc(0, 0, dirty_tile));
next_loop:
    ;
  }
}

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

#include <iostream>
#include <string>
#include <queue>

using namespace std;

const int INF = 9999999;

int w, h;
string b[20];
int d[20][20];

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

void dist(int sx, int sy){
	for(int i=0;i<20;i++)
		for(int j=0;j<20;j++)
			d[i][j] = INF;
	queue< pair<int,int> > qu;
	qu.push(make_pair(sx,sy));
	d[sy][sx] = 0;
	while(!qu.empty()){
		pair<int, int> p = qu.front(); qu.pop();
		int x = p.first, y = p.second;
		for(int i=0;i<4;i++){
			int nx = x + dx[i], ny = y + dy[i];
			if(nx<0||nx>=w||ny<0||ny>=h||b[ny][nx]=='x') continue;
			if(d[ny][nx] != INF) continue;
			d[ny][nx] = d[y][x] + 1;
			qu.push(make_pair(nx,ny));
		}
	}
}

int main(){
	int c[11][11];
	int x[11], y[11];
	int ans[1<<11][11];
	while(cin >> w >> h){
		if(!(w||h)) break;
		int num = 1;
		for(int i=0;i<h;i++){
			cin >> b[i];
			for(int j=0;j<w;j++){
				if(b[i][j]=='o') x[0] = j, y[0] = i;
				if(b[i][j]=='*') x[num] = j, y[num++] = i;
			}
		}
		bool flag = false;
		memset(c,0,sizeof(c));
		dist(x[0],y[0]);
		for(int i=1;i<num;i++){
			c[0][i] = d[y[i]][x[i]];
			if(c[0][i] == INF) flag = true;
		}
		if(flag) { cout << -1 << endl; continue; }
		for(int i=1;i<num;i++){
			dist(x[i],y[i]);
			for(int j=0;j<num;j++){
				if(i==j) continue;
				c[i][j] = d[y[j]][x[j]];
			}
		}
		for(int i=0;i<(1<<num);i++) for(int j=0;j<num;j++) ans[i][j] = INF;
		ans[1][0] = 0;
		for(int i=0;i<(1<<num);i++){
			for(int j=0;j<num;j++)
				if((i>>j)&1)
					for(int k=0;k<num;k++)
						ans[i|(1<<k)][k] = min(ans[i|(1<<k)][k],ans[i][j]+c[j][k]);
		}
		int cost = INF;
		for(int i=1;i<num;i++) cost = min(cost, ans[(1<<num)-1][i]);
		cout << cost << endl;
	}
}

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

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<deque>
#include<queue>

using namespace std;

int main(){
  int h,w;
  while(scanf("%d%d\n",&w,&h),w+h){
    char board[22][22]={{0}};
    deque<pair<int,int> > pos;
    int count=3;
    for(int i=1;i<=h;i++){
      gets(&board[i][1]);
      for(int j=1;j<=w;j++){
	if(board[i][j]=='x')      board[i][j]=0;
	else if(board[i][j]=='.') board[i][j]=1;
	else if(board[i][j]=='*'){
	  board[i][j]=count++;
	  pos.push_back(make_pair(j,i));
	}else if(board[i][j]=='o'){
	  board[i][j]=2;
	  pos.push_front(make_pair(j,i));
	}
      }
    }

    /*
    for(int i=0;i<h+2;i++){
      for(int j=0;j<w+2;j++){
	printf("%d ",board[i][j]);
      }
      puts("");
    }
    */

    //int darty=pos.size()-1;
    int dist[11][11]={{0}};
    bool possible=true;
    for(int i=0;i<pos.size()-1;i++){
      //dijkstra
      int flag[22][22]={{0}};
      int d[22][22];
      for(int x=0;x<22;x++)
	for(int y=0;y<22;y++)
	  d[y][x]=1000;
      count=0;
      priority_queue<pair<int,pair<int,int> > > q;
      q.push(make_pair(0,make_pair(pos[i].first,pos[i].second)));
      while(!q.empty()){
	if(count==pos.size()) break;
	int x=q.top().second.first,y=q.top().second.second,hy=q.top().first;
	q.pop();
	//printf("(%d,%d)=%d\n",x,y,-hy);
	if(flag[y][x]!=0) continue;
	flag[y][x]=1;
	if(board[y][x]>=2){//darty or initial
	  //printf("test %d\n",board[y][x]-2);
	  dist[i][board[y][x]-2]=-hy;
	  dist[board[y][x]-2][i]=-hy;
	  count++;
	}
	if(board[y][x-1]!=0 && d[y][x-1]>-hy+1){
	  d[y][x-1]=-hy+1;
	  q.push(make_pair(hy-1,make_pair(x-1,y)));
	}
	if(board[y][x+1]!=0 && d[y][x+1]>-hy+1) {
	  d[y][x+1]=-hy+1;
	  q.push(make_pair(hy-1,make_pair(x+1,y)));
	}
	if(board[y-1][x]!=0 && d[y-1][x]>-hy+1){
	  d[y-1][x]=-hy+1;
	  q.push(make_pair(hy-1,make_pair(x,y-1)));
	}
	if(board[y+1][x]!=0 && d[y+1][x]>-hy+1){
	  d[y+1][x]=-hy+1;
	  q.push(make_pair(hy-1,make_pair(x,y+1)));
	}
      }
      if(count!=pos.size()){
	possible=false;
	break;
      }
    }
    if(!possible){
      puts("-1");
      continue;
    }
    
    /*
    for(int i=0;i<pos.size();i++){
      for(int j=0;j<pos.size();j++){
	printf("%3d",dist[i][j]);
      }
      printf("\n");
    }
    */
    //traveling salesman problem
    vector<int> v(pos.size()-1);
    int ans=100000;
    for(int i=0;i<pos.size()-1;i++) v[i]=i+1;
    do{
      int tmp=dist[0][v[0]];
      for(int i=0;i<pos.size()-2;i++){
	tmp+=dist[v[i]][v[i+1]];
	if(tmp>ans){
	  sort(&v[i+1],&v[pos.size()-2],greater<int>());
	  break;
	}
      }
      if(ans>tmp) ans=tmp;
    }while(next_permutation(v.begin(),v.end()));
    printf("%d\n",ans);
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:7: error: 'gets' was not declared in this scope; did you mean 'getw'?
   16 |       gets(&board[i][1]);
      |       ^~~~
      |       getw
Language: C++

#include <iostream>
#include <string>
#include <queue>

using namespace std;

int w, h;
string b[20];
int step[20][20];

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

void bfs(int x, int y){
	memset(step, -1, sizeof(step));
	queue< pair<int, int> > qu; qu.push(make_pair(x,y));
	step[x][y] = 0;
	while(!qu.empty()){
		pair<int, int> pr = qu.front(); qu.pop();
		int cx = pr.first, cy = pr.second;
		for(int i=0;i<4;i++){
			int nx = cx+dx[i], ny = cy+dy[i];
			if(nx<0||h<=nx||ny<0||w<=ny||b[nx][ny]=='x'||step[nx][ny]!=-1) continue;
			step[nx][ny] = step[cx][cy]+1;
			qu.push(make_pair(nx,ny));
		}
	}
}

int main(){
	int c[11][11];
	while(cin >> w >> h, w){
		for(int i=0;i<h;i++) cin >> b[i];
		vector<int> x(1), y(1);
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(b[i][j]=='o') x[0] = i, y[0] = j;
				if(b[i][j]=='*') x.push_back(i), y.push_back(j);
			}
		}
		int res = 1000000000;
		for(int i=0;i<x.size();i++){
			bfs(x[i], y[i]);
			for(int j=0;j<x.size();j++){
				c[i][j] = step[x[j]][y[j]];
				if(c[i][j]==-1) res = -1;
			}
		}
		vector<int> a(x.size()-1);
		for(int i=0;i<x.size()-1;i++) a[i] = i+1;
		do{
			int cur = c[0][a[0]];
			for(int i=0;i+1<a.size();i++) cur += c[a[i]][a[i+1]];
			res = min(res, cur);
		}while(next_permutation(a.begin(), a.end()));
		cout << res << endl;
	}
}

Compiler output:
a.cc: In function 'void bfs(int, int)':
a.cc:15:9: error: 'memset' was not declared in this scope
   15 |         memset(step, -1, sizeof(step));
      |         ^~~~~~
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 | 
a.cc: In function 'int main()':
a.cc:55:24: error: 'next_permutation' was not declared in this scope
   55 |                 }while(next_permutation(a.begin(), a.end()));
      |                        ^~~~~~~~~~~~~~~~
Language: C++

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

using namespace std;

int w, h;
string b[20];
int step[20][20];

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

void bfs(int x, int y){
	memset(step, -1, sizeof(step));
	queue< pair<int, int> > qu; qu.push(make_pair(x,y));
	step[x][y] = 0;
	while(!qu.empty()){
		pair<int, int> pr = qu.front(); qu.pop();
		int cx = pr.first, cy = pr.second;
		for(int i=0;i<4;i++){
			int nx = cx+dx[i], ny = cy+dy[i];
			if(nx<0||h<=nx||ny<0||w<=ny||b[nx][ny]=='x'||step[nx][ny]!=-1) continue;
			step[nx][ny] = step[cx][cy]+1;
			qu.push(make_pair(nx,ny));
		}
	}
}

int main(){
	int c[11][11];
	while(cin >> w >> h, w){
		for(int i=0;i<h;i++) cin >> b[i];
		vector<int> x(1), y(1);
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(b[i][j]=='o') x[0] = i, y[0] = j;
				if(b[i][j]=='*') x.push_back(i), y.push_back(j);
			}
		}
		int res = 1000000000;
		for(int i=0;i<x.size();i++){
			bfs(x[i], y[i]);
			for(int j=0;j<x.size();j++){
				c[i][j] = step[x[j]][y[j]];
				if(c[i][j]==-1) res = -1;
			}
		}
		vector<int> a(x.size()-1);
		for(int i=0;i<x.size()-1;i++) a[i] = i+1;
		do{
			int cur = c[0][a[0]];
			for(int i=0;i+1<a.size();i++) cur += c[a[i]][a[i+1]];
			res = min(res, cur);
		}while(next_permutation(a.begin(), a.end()));
		cout << res << endl;
	}
}

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


#include <iostream>
#include <string>
#include <queue>

using namespace std;

const int INF = 9999999;

int w, h;
string b[20];
int d[20][20];

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

void dist(int sx, int sy){
	for(int i=0;i<20;i++)
		for(int j=0;j<20;j++)
			d[i][j] = INF;
	queue< pair<int,int> > qu;
	qu.push(make_pair(sx,sy));
	d[sy][sx] = 0;
	while(!qu.empty()){
		pair<int, int> p = qu.front(); qu.pop();
		int x = p.first, y = p.second;
		for(int i=0;i<4;i++){
			int nx = x + dx[i], ny = y + dy[i];
			if(nx<0||nx>=w||ny<0||ny>=h||b[ny][nx]=='x') continue;
			if(d[ny][nx] != INF) continue;
			d[ny][nx] = d[y][x] + 1;
			qu.push(make_pair(nx,ny));
		}
	}
}

int main(){
	int c[11][11];
	int x[11], y[11];
	int ans[1<<11][11];
	while(cin >> w >> h){
		if(!(w||h)) break;
		int num = 1;
		for(int i=0;i<h;i++){
			cin >> b[i];
			for(int j=0;j<w;j++){
				if(b[i][j]=='o') x[0] = j, y[0] = i;
				if(b[i][j]=='*') x[num] = j, y[num++] = i;
			}
		}
		bool flag = false;
		memset(c,0,sizeof(c));
		dist(x[0],y[0]);
		for(int i=1;i<num;i++){
			c[0][i] = d[y[i]][x[i]];
			if(c[0][i] == INF) flag = true;
		}
		if(flag) { cout << -1 << endl; continue; }
		for(int i=1;i<num;i++){
			dist(x[i],y[i]);
			for(int j=0;j<num;j++){
				if(i==j) continue;
				c[i][j] = d[y[j]][x[j]];
			}
		}
		for(int i=0;i<(1<<num);i++) for(int j=0;j<num;j++) ans[i][j] = INF;
		ans[1][0] = 0;
		for(int i=0;i<(1<<num);i++){
			for(int j=0;j<num;j++)
				if((i>>j)&1)
					for(int k=0;k<num;k++)
						ans[i|(1<<k)][k] = min(ans[i|(1<<k)][k],ans[i][j]+c[j][k]);
		}
		int cost = INF;
		for(int i=1;i<num;i++) cost = min(cost, ans[(1<<num)-1][i]);
		cout << cost << endl;
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:17: error: 'memset' was not declared in this scope
   52 |                 memset(c,0,sizeof(c));
      |                 ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <queue>
  +++ |+#include <cstring>
    5 | 
a.cc:77:10: error: expected '}' at end of input
   77 |         }
      |          ^
a.cc:37:11: note: to match this '{'
   37 | int main(){
      |           ^
Language: C++

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

int INF = INT_MAX / 4;

int calculateDist(vector<string>& tile, int y1, int x1, int y2, int x2)
{
    int h = tile.size();
    int w = tile[0].size();
    vector<vector<int> > minDist(h, vector<int>(w, INF));

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

    queue<pair<int, int> > q;
    q.push(make_pair(y1, x1));
    minDist[y1][x1] = 0;
    while(!q.empty()){
        int y0 = q.front().first;
        int x0 = q.front().second;
        q.pop();
        for(int i=0; i<4; ++i){
            int y = y0 + dy[i];
            int x = x0 + dx[i];
            if(tile[y][x] != 'x' && minDist[y][x] == INF){
                minDist[y][x] = minDist[y0][x0] + 1;
                if(y == y2 && x == x2)
                    return minDist[y][x];
                q.push(make_pair(y, x));
            }
        }
    }
    return INF;
}

int solve(vector<string>& tile)
{
    int h = tile.size();
    int w = tile[0].size();

    int sy, sx;
    vector<int> y, x;
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            if(tile[i][j] == 'o'){
                sy = i;
                sx = j;
            }
            if(tile[i][j] == '*'){
                y.push_back(i);
                x.push_back(j);
            }
        }
    }

    int n = y.size();
    vector<vector<int> > dist(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){
            dist[i][j] = dist[j][i] = calculateDist(tile, y[i], x[i], y[j], x[j]);
        }
    }

    vector<vector<int> > minDist(n, vector<int>(1<<n, INF));
    for(int i=0; i<n; ++i){
        minDist[i][1<<i] = calculateDist(tile, sy, sx, y[i], x[i]);
    }
    for(int i=0; i<(1<<n); ++i){
        bitset<10> bs(i);
        for(int j=0; j<n; ++j){
            for(int k=0; k<n; ++k){
                if(bs[k])
                    continue;
                bs[k] = true;
                minDist[k][bs.to_ulong()] = min(minDist[k][bs.to_ulong()], minDist[j][i] + dist[j][k]);
                bs[k] = false;
            }
        }
    }

    int ret = INF;
    for(int i=0; i<n; ++i){
        ret = min(ret, minDist[i][(1<<n)-1]);
    }
    if(ret == INF)
        return -1;
    return ret;
}

int main()
{
    for(;;){
        int w, h;
        cin >> w >> h;
        if(w == 0)
            break;

        vector<string> tile(h+2);
        tile[0] = tile[h+1] = string(w+2, 'x');
        for(int i=1; i<=h; ++i){
            cin >> tile[i];
            tile[i] = 'x' + tile[i] + 'x';
        }
        cout << solve(tile) << endl;
    }
}

Compiler output:
a.cc:18:11: error: 'INT_MAX' was not declared in this scope
   18 | int INF = INT_MAX / 4;
      |           ^~~~~~~
a.cc:16:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   15 | #include <cfloat>
  +++ |+#include <climits>
   16 | using namespace std;
Language: C++

#include<iostream>
#define MAX_V 20
#define INF 10000000
#include<queue>
#include<string>
#include<map>
#include<vector>
using namespace std;
struct edge{
	int to,cost;
};
int co[MAX_V][MAX_V];
int h,w,V,dx[]={0,0,1,-1},dy[]={1,-1,0,0};
string s[1000];
typedef pair<int,int> P;
map<P,int> mp;
int dp[1 << MAX_V][MAX_V];
int rec(int S,int v){
	if(dp[S][v]>=0)
		return dp[S][v];
	if(S==(1<<V)-2){
		return dp[S][v]=0;
	}
	int res=INF;
	for(int u=0;u<V;u++){
		if(!(S>>u&1)){
			res=min(res,rec(S|1<<u,u)+co[v][u]);
		}
	}
	return dp[S][v]=res;
}
void solve(){
	memset(dp,-1,sizeof(dp));
	int temp=rec(0,0);
	if(temp==INF)
	cout<<-1<<endl;
	else
	cout<<temp<<endl;
}
void func(int y,int x,int q){
	int d[MAX_V][MAX_V];
	for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)
	d[i][j]=INF;
	d[y][x]=0;
	queue<P> box;
	box.push(P(y,x));
	while(!box.empty()){
		int nx,ny,sx,sy;
		P pre=box.front();
		box.pop();
		sy=pre.first;
		sx=pre.second;
		for(int i=0;i<4;i++){
			nx=sx+dx[i];
			ny=sy+dy[i];
			if((nx>=0&&ny>=0&&nx<w&&ny<h)&&(s[ny][nx]=='o'||s[ny][nx]=='.'||s[ny][nx]=='*')&&(d[ny][nx]==INF)){
				box.push(P(ny,nx));
				if(s[ny][nx]=='*'||s[ny][nx]=='o'){
					co[mp[P(ny,nx)]][q]=d[sy][sx]+1;
					co[q][mp[P(ny,nx)]]=d[sy][sx]+1;
				}
				d[ny][nx]=d[sy][sx]+1;
			}
		}
	}
}
int main(){
	while(cin>>w>>h,h||w){
		V=1;
		for(int i=0;i<h;i++)
		cin>>s[i];
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		if(s[i][j]=='o')
			mp[P(i,j)]=0;
		else if(s[i][j]=='*'){
			mp[P(i,j)]=V;
			V++;
		}
		for(int i=0;i<V;i++)
		for(int j=0;j<V;j++){
			co[i][j]=INF;
		
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++){
			if(s[i][j]=='o'){
				func(i,j,0);
			}else if(s[i][j]=='*'){
				func(i,j,mp[P(i,j)]);
			}
		}
		
		
		}
		solve();
	}
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:33:9: error: 'memset' was not declared in this scope
   33 |         memset(dp,-1,sizeof(dp));
      |         ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include<map>
  +++ |+#include <cstring>
    7 | #include<vector>
Language: C++

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

struct P{
	int x,y;
} s;
int w, h;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
int to[12][12];
int cnt[21][21];
string f[21];

void solve(int x, int y, int cnt_,int from ,vector<struct P>& vc){
	
	for(int i=0 ; i<4 ; i++ ){
		int mx = x + dx[i];
		int my = y + dy[i];
		if( mx < 0 || my < 0 || mx >= w || my >= h ){
			continue;
		}else if( cnt[my][mx] == -1 ){
			continue;
		}else if( cnt[my][mx] > cnt_ ){
			cnt[my][mx] = cnt_;
			if( f[my][mx] == '.' ){
				solve( mx , my , cnt_+1 , from , vc );
			}else if( f[my][mx] == '*' ){
				for(int j=0 ; j < (int)vc.size() ; j++ ){
					if( vc[j].x == mx && vc[j].y == my ){
						to[from][j+1] = cnt_;
						to[j+1][from] = cnt_;
						break;
					}
				}
			}
		}
	}
}

/*
void debug(int x,int y,char c){
	cout << c << ":(x,y) = (" << x << "," << y << ")\n";
}*/

int main(){
	while( cin >> w >> h , w||h ){
		vector<struct P> vc;
		for(int y=0 ; y<12 ; y++ ){
			for(int x=0 ; x<12 ; x++ ){
				to[y][x] = 1000;
			}
		}
		
		for(int y=0 ; y < h ; y++ ){
			cin >> f[y];
			for(int x=0 ; x < w ; x++ ){
				if( f[y][x] == 'o' ){
					cnt[y][x] = -1;
					s.x = x, s.y = y;
				}else if( f[y][x] == '*' ){
					struct P p;
					p.x = x, p.y = y;
					vc.push_back( p );				
				}else if( f[y][x] == 'x' ){
					cnt[y][x] = -1;
				}
			}
		}
		
		for(int i=0 ; i <= (int)vc.size() ; i++ ){
			for(int y=0 ; y<21 ; y++ )
				for(int x=0 ; x<21 ; x++ )
					if( cnt[y][x] != -1 )
						cnt[y][x] = 1000;
			if( i > 0 ){
				cnt[ vc[i-1].y ][ vc[i-1].x ] = -1;
				solve( vc[i-1].x , vc[i-1].y , 1 , i , vc );
			}else{
				solve( s.x , s.y , 1 , i , vc );
			}
		}

		vector<int> vc_;
		bool flag = true;
		int ans = 10000000;
		for(int i=0 ; i < (int)vc.size() ; i++ )
			vc_.push_back( i+1 );
		do{
			int ans_ = 0;
			for(int i=0 ; i < (int)vc_.size() ; i++ ){
				//cout << "+ : " << to[ ((i==0)? 0 : vc_[i-1]) ][ vc_[i] ] << " ";
				if( to[ ((i==0)? 0 : vc_[i-1]) ][ vc_[i] ] == 1000 ){
					flag = false;
					break;
				}else{
					ans_ += to[ ((i==0)? 0 : vc_[i-1]) ][ vc_[i] ];
				}
			}
			ans = min( ans_ , ans );
		}while( next_permutation( vc_.begin() , vc_.end() ) && flag );
		//cout << endl;
		
		/*debug( s.x , s.y , 'S' );
		for(int i=0 ; i < (int)vc.size() ; i++ ){
			debug( vc[i].x , vc[i].y , i+'0' );
			//cout << "start => " << to[0][i+1] << endl;
		}
		for(int y=0 ; y <= (int)vc.size() ; y++ ){
			for(int x=0 ; x <= (int)vc.size() ; x++ ){
				cout << to[y][x] << "  ";
			}
			cout << endl;
		}*/
		cout << ( (flag)? ans : -1 ) << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:102:25: error: 'next_permutation' was not declared in this scope
  102 |                 }while( next_permutation( vc_.begin() , vc_.end() ) && flag );
      |                         ^~~~~~~~~~~~~~~~
Language: C++

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

using namespace std;

struct Point {
  int x, y;
  Point(int x, int y) : x(x), y(y) {;}
};

typedef pair<int, Point> State;

int W, H, C, INF = (1 << 22);
vector<Point> pos;
char field[20][20];
int  dist[11][11];
int dx[4] = {0, 1, 0, -1},
    dy[4] = {-1, 0, 1, 0};
int dp[1 << 11][11];

void bfs(int src)
{
  int d[20][20];
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      d[i][j] = INF;

  Point start = pos[src];

  queue<State> que;
  que.push(State(0, start));

  while (!que.empty()) {
    State s = que.front(); que.pop();
    Point p = s.second;
    if (d[p.y][p.x] != INF) continue;

    d[p.y][p.x] = s.first; 
    for (int k = 0; k < 4; k++) {
      int nx = p.x + dx[k], ny = p.y + dy[k];
      if (nx >= 0 && nx < W && ny >= 0 && ny < H && field[ny][nx] != 'x') {
        que.push(State(s.first + 1, Point(nx, ny)));
      }
    }
  }

  for (int dst = 0; dst < C; dst++) 
    if (dst != src) 
      dist[src][dst] = d[pos[dst].y][pos[dst].x];
}

int rec(int S, int v)
{
  // 訪問済み
  if (dp[S][v] >= 0) 
    return dp[S][v];

  // すべての頂点を訪れて戻ってきた
  if (S == (1 << C) - 1) {
    return dp[S][v] = 0;
  }

  int res = INF;
  for (int u = 0; u < C; u++) {
    if (!(S >> u & 1)) {
      // uが未訪問なので、uへ移動
      res = min(res, rec(S | 1 << u, u) + dist[v][u]);
    }
  }

  return dp[S][v] = res;
}

void solve()
{
  
  // 距離テーブルの初期化
  for (int i = 0; i < C; i++) 
    for (int j = 0; j < C; j++) 
      if (i == j) 
        dist[i][j] = 0;
      else 
        dist[i][j] = INF;

  // 全点間の距離を求める
  for (int src = 0; src < C; src++) 
    bfs(src);

  // TSP
  memset(dp, -1, sizeof(dp));
  int res = rec(0, 0);
  if (res >= INF) 
    cout << -1 << endl;
  else
    cout << res << endl;
}

int main()
{
  while (cin >> W >> H && (W && H)) {

    // スタート+汚れたタイルの数
    C = 1;
    pos.clear();
    pos.push_back(Point(-1, -1));
    // read
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> field[i][j];
        if (field[i][j] == '*') {
          pos.push_back(Point(j, i));
          C++;
        } else if (field[i][j] == 'o') {
          pos[0].x = j;
          pos[0].y = i;
        }
      }
    }

    solve();
  }
}

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

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

using namespace std;

struct Point {
  int x, y;
  Point(int x, int y) : x(x), y(y) {;}
};

typedef pair<int, Point> State;

int W, H, C, INF = (1 << 22);
vector<Point> pos;
char field[20][20];
int  dist[11][11];
int dx[4] = {0, 1, 0, -1},
    dy[4] = {-1, 0, 1, 0};
int dp[1 << 11][11];

void bfs(int src)
{
  int d[20][20];
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      d[i][j] = INF;

  Point start = pos[src];

  queue<State> que;
  que.push(State(0, start));

  while (!que.empty()) {
    State s = que.front(); que.pop();
    Point p = s.second;
    if (d[p.y][p.x] != INF) continue;

    d[p.y][p.x] = s.first; 
    for (int k = 0; k < 4; k++) {
      int nx = p.x + dx[k], ny = p.y + dy[k];
      if (nx >= 0 && nx < W && ny >= 0 && ny < H && field[ny][nx] != 'x') {
        que.push(State(s.first + 1, Point(nx, ny)));
      }
    }
  }

  for (int dst = 0; dst < C; dst++) 
    if (dst != src) 
      dist[src][dst] = d[pos[dst].y][pos[dst].x];
}

int rec(int S, int v)
{
  // 訪問済み
  if (dp[S][v] >= 0) 
    return dp[S][v];

  // すべての頂点を訪れて戻ってきた
  if (S == (1 << C) - 1) {
    return dp[S][v] = 0;
  }

  int res = INF;
  for (int u = 0; u < C; u++) {
    if (!(S >> u & 1)) {
      // uが未訪問なので、uへ移動
      res = min(res, rec(S | 1 << u, u) + dist[v][u]);
    }
  }

  return dp[S][v] = res;
}

void solve()
{
  
  // 距離テーブルの初期化
  for (int i = 0; i < C; i++) 
    for (int j = 0; j < C; j++) 
      if (i == j) 
        dist[i][j] = 0;
      else 
        dist[i][j] = INF;

  // 全点間の距離を求める
  for (int src = 0; src < C; src++) 
    bfs(src);

  // TSP
  memset(dp, -1, sizeof(dp));
  int res = rec(0, 0);
  if (res >= INF) 
    cout << -1 << endl;
  else
    cout << res << endl;
}

int main()
{
  while (cin >> W >> H && (W && H)) {

    // スタート+汚れたタイルの数
    C = 1;
    pos.clear();
    pos.push_back(Point(-1, -1));
    // read
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> field[i][j];
        if (field[i][j] == '*') {
          pos.push_back(Point(j, i));
          C++;
        } else if (field[i][j] == 'o') {
          pos[0].x = j;
          pos[0].y = i;
        }
      }
    }

    solve();
  }
}

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

/*********************
AOJ_1140
Cleaning Robot
*********************/
#include <iostream>
#include <queue>
#include <string>
using namespace std;

//構造体宣言
struct pos{
	int x;		//座標
	int y;		
	int dis;	//距離
};

int main(){
	int w, h;
	while(1){
		cin >> w >> h;
		if(w == 0 || h == 0) break;

		//タイルの初期化
		char tile[30][30];
		for(int i = 0; i < 30; i ++){
			for(int j = 0; j < 30; j++){
				tile[i][j] = 'x';
			}
		}
		//タイルの入力
		int stain = 0;	//汚れの数
		queue<pos> que;
		for(int i = 1; i <= h; i++){
			string input;
			cin >> input;
			for(int j = 1; j <= w; j++){
				tile[i][j] = input[j-1];
				if(tile[i][j] == '*') stain++;
				if(tile[i][j] == 'o'){
					pos p;
					p.y = i; p.x = j;
					p.dis = 0;
					que.push(p);
					tile[i][j] = '.';
				}
			}
		}

		int count = 0;
		while(stain > 0){
			char bfs[30][30];
			memcpy(bfs, tile, sizeof(bfs));
			pos p = que.front();
			bfs[p.y][p.x] = 0;
			int x1[] = {-1, 0, 1, 0}, y1[] = {0, -1, 0, 1};
			int f = 1;
			while(f && !que.empty()){
				pos p1 = que.front();
				que.pop();
				for(int i = 0; i < 4; i++){
					p = p1;
					p.x += x1[i]; p.y += y1[i];
 					if(bfs[p.y][p.x] == '.'){
						p.dis++;
						bfs[p.y][p.x] = p.dis;
						que.push(p);
					}else if(bfs[p.y][p.x] == '*'){
						count += p.dis+1;
						stain--;
						tile[p.y][p.x] == '.';
						while(!que.empty()) que.pop();
						p.dis = 0;
						que.push(p);
						f = 0;
						break;
					}
				}
			}
			if(que.empty()) break;
		}

		if(stain > 0) cout << "-1" << endl;
		else cout << count << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:25: error: 'memcpy' was not declared in this scope
   52 |                         memcpy(bfs, tile, sizeof(bfs));
      |                         ^~~~~~
a.cc:7:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include <queue>
  +++ |+#include <cstring>
    7 | #include <string>
Language: C++

/*********************
AOJ_1140
Cleaning Robot
*********************/
#include <iostream>
#include <queue>
#include <string>
#include <cstdio>
using namespace std;

//構造体宣言
struct pos{
	int x;		//座標
	int y;		
	int dis;	//距離
};

int main(){
	int w, h;
	while(1){
		cin >> w >> h;
		if(w == 0 || h == 0) break;

		//タイルの初期化
		char tile[30][30];
		for(int i = 0; i < 30; i ++){
			for(int j = 0; j < 30; j++){
				tile[i][j] = 'x';
			}
		}
		//タイルの入力
		int stain = 0;	//汚れの数
		queue<pos> que;
		for(int i = 1; i <= h; i++){
			string input;
			cin >> input;
			for(int j = 1; j <= w; j++){
				tile[i][j] = input[j-1];
				if(tile[i][j] == '*') stain++;
				if(tile[i][j] == 'o'){
					pos p;
					p.y = i; p.x = j;
					p.dis = 0;
					que.push(p);
					tile[i][j] = '.';
				}
			}
		}

		int count = 0;
		while(stain > 0){
			char bfs[30][30];
			memcpy(bfs, tile, sizeof(bfs));
			pos p = que.front();
			bfs[p.y][p.x] = 0;
			int x1[] = {-1, 0, 1, 0}, y1[] = {0, -1, 0, 1};
			int f = 1;
			while(f && !que.empty()){
				pos p1 = que.front();
				que.pop();
				for(int i = 0; i < 4; i++){
					p = p1;
					p.x += x1[i]; p.y += y1[i];
 					if(bfs[p.y][p.x] == '.'){
						p.dis++;
						bfs[p.y][p.x] = p.dis;
						que.push(p);
					}else if(bfs[p.y][p.x] == '*'){
						count += p.dis+1;
						stain--;
						tile[p.y][p.x] == '.';
						while(!que.empty()) que.pop();
						p.dis = 0;
						que.push(p);
						f = 0;
						break;
					}
				}
			}
			if(que.empty()) break;
		}

		if(stain > 0) cout << "-1" << endl;
		else cout << count << endl;
	}

	return 0;
}

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

/*********************
AOJ_1140
Cleaning Robot
*********************/
#include <iostream>
#include <queue>
#include <string>
#include <string>
using namespace std;

//構造体宣言
struct pos{
	int x;		//座標
	int y;		
	int dis;	//距離
};

int main(){
	int w, h;
	while(1){
		cin >> w >> h;
		if(w == 0 || h == 0) break;

		//タイルの初期化
		char tile[30][30];
		for(int i = 0; i < 30; i ++){
			for(int j = 0; j < 30; j++){
				tile[i][j] = 'x';
			}
		}
		//タイルの入力
		int stain = 0;	//汚れの数
		queue<pos> que;
		for(int i = 1; i <= h; i++){
			string input;
			cin >> input;
			for(int j = 1; j <= w; j++){
				tile[i][j] = input[j-1];
				if(tile[i][j] == '*') stain++;
				if(tile[i][j] == 'o'){
					pos p;
					p.y = i; p.x = j;
					p.dis = 0;
					que.push(p);
					tile[i][j] = '.';
				}
			}
		}

		int count = 0;
		while(stain > 0){
			char bfs[30][30];
			memcpy(bfs, tile, sizeof(bfs));
			pos p = que.front();
			bfs[p.y][p.x] = 0;
			int x1[] = {-1, 0, 1, 0}, y1[] = {0, -1, 0, 1};
			int f = 1;
			while(f && !que.empty()){
				pos p1 = que.front();
				que.pop();
				for(int i = 0; i < 4; i++){
					p = p1;
					p.x += x1[i]; p.y += y1[i];
 					if(bfs[p.y][p.x] == '.'){
						p.dis++;
						bfs[p.y][p.x] = p.dis;
						que.push(p);
					}else if(bfs[p.y][p.x] == '*'){
						count += p.dis+1;
						stain--;
						tile[p.y][p.x] == '.';
						while(!que.empty()) que.pop();
						p.dis = 0;
						que.push(p);
						f = 0;
						break;
					}
				}
			}
			if(que.empty()) break;
		}

		if(stain > 0) cout << "-1" << endl;
		else cout << count << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:25: error: 'memcpy' was not declared in this scope
   53 |                         memcpy(bfs, tile, sizeof(bfs));
      |                         ^~~~~~
a.cc:7:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include <queue>
  +++ |+#include <cstring>
    7 | #include <string>
Language: Java

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

public class Eratosthenes {
	//途中
	
	int prime[];

	void eratosthenes(int max) {
		prime = new int[max + 1];
		Arrays.fill(prime, 1);
		prime[0] = prime[1] = 0;
		for (int i = 2; i * i <= max; i++) {
			if (prime[i] == 1) {
				for (int j = i * i; j <= max; j += i) {
					prime[j] = 0;
				}
			}
		}
	}

	void eratosthenes2(int max) {
		int end = max / 2 + 1;
		prime = new int[end];
		Arrays.fill(prime, 1);
		prime[0] = 0;
		for (int i = 0; (2 * i + 1) * (2 * i + 1) <= max; i++) {
			if (prime[i] == 1) {
				for (int j = 2 * i * (i + 1); j < end; j += 2 * i + 1) {
					prime[j] = 0;
				}
			}
		}
	}

	void eratosthenes3(int max) {
		int end = max / 6 + 1;
		prime = new int[end];
		Arrays.fill(prime, 1);
		prime[0] ^= 1;
		for (int i = 0; (6 * i + 5) * (6 * i + 5) <= max; i++) {

		}
	}

	boolean isPrime2(int n) {
		if (n == 2) return true;
		if (n % 2 == 0) return false;
		n = (n - 1) / 2;
		if (prime[n] == 1) return true;
		return false;
	}

	void run() {
		Scanner sc = new Scanner(System.in);
	}

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

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

import java.util.Scanner;
public class Main {
	
	static boolean sosuu(int s) {
		if(s == 1) return false;
		for(int i=2; i*i<=s; i++) {
			if(s%i == 0) return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int a = sc.nextInt();
				int d = sc.nextInt();
				int n = sc.nextInt();
				if(a+d+n == 0) break;
				
				int sum = a;
				int ans = a;
				if(sosuu(a)) n--;
				if(n != 0) {
					for(int i=0;;i++) {
						sum =+ d;
						if(sosuu(sum)) n--;
						if(n == 0) {
							ans = sum;
							break;
						}
					}
				}
				System.out.println(ans);
			}
		}
	}
}
import java.util.Scanner;
public class Main {
	
	static boolean sosuu(int s) {
		if(s == 1) return false;
		for(int i=2; i*i<=s; i++) {
			if(s%i == 0) return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int a = sc.nextInt();
				int d = sc.nextInt();
				int n = sc.nextInt();
				if(a+d+n == 0) break;
				
				int sum = a;
				int ans = a;
				if(sosuu(a)) n--;
				if(n != 0) {
					for(int i=0;;i++) {
						sum =+ d;
						if(sosuu(sum)) n--;
						if(n == 0) {
							ans = sum;
							break;
						}
					}
				}
				System.out.println(ans);
			}
		}
	}
}



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

import java.io.*;
import java.util.*;
import java.math.*;
class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	int[] prime = new int[1000000];
	prime[0] = 1; prime[1] = 1;
	for(int i=2; i<1000; i++)
	    if(prime[i]==0)
		for(int j=i*i; j<1000000; j+=i)
		    prime[j]=1;
	try {
	    while(true){
		String[] st = sc.readLine().split(" ");
		int a = Integer.valueOf(st[0]), d = Integer.valueOf(st[1]), n = Integer.valueOf(st[2]);
		if(a==0 && b==0 && c==0)
		    break;
		int check = 0;
		while(check!=n){
		    if(prime[a]==0)
			check++;
		    a+=d;
		}
		System.out.println(a-d);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Compiler output:
Main.java:17: error: cannot find symbol
		if(a==0 && b==0 && c==0)
		           ^
  symbol:   variable b
  location: class Main
Main.java:17: error: cannot find symbol
		if(a==0 && b==0 && c==0)
		                   ^
  symbol:   variable c
  location: class Main
2 errors
Language: Java

import java.util.*;
public class P1141__ {
	public static void main(String[] args) {
		int MAX = 1000000;
		boolean[] p;
		p = new boolean[MAX+1]; p[0] = p[1] = true;
		for(int i=2;i<=MAX;i++) if(!p[i])
			for(int j=i*2;j<=MAX;j+=i) p[j] = true;
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int a = sc.nextInt(), d = sc.nextInt(), n = sc.nextInt();
			if( (a|d|n) == 0 ) break;
			for(;n!=0;a+=d) if(!p[a])n--;
			System.out.println(a-d);
		}
	}
}

Compiler output:
Main.java:2: error: class P1141__ is public, should be declared in a file named P1141__.java
public class P1141__ {
       ^
1 error