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

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,n,m;
int x1,y1,x2,y2,x3,y3,wx,wy,r;

int crosscheck(int tx,int ty,int sx,int sy,int wx,int wy,int rr){

	int abx=sx-tx,aby=sy-ty;
	int awx=wx-tx,awy=wy-ty;
	int bwx=wx-sx,bwy=wy-sy;

	int rr2=rr*rr;
	int aw2=awx*awx+awy*awy;
	int bw2=bwx*bwx+bwy*bwy;
	int ab2=abx*abx+aby*aby;

	int tim=abx*awy-aby*awx;
	int abw=abx*awx+aby*awy;

	if(aw2<rr2 && bw2<rr2)return 0;
	if(aw2<rr2 || bw2<rr2)return 1;
	if( tim*tim/ab2 > (double)rr2)return 0;
	if(abw<0)return 0;
	if(abw>ab2)return 0;
	return 1;
}

int main(){
	if(crosscheck(10,3,10,9,10,10,1))printf("OK\n");

	while(scanf("%d %d",&x1,&y1)*x1){
		scanf("%d %d %d %d %d %d %d",&x2,&y2,&x3,&y3,&wx,&wy,&r);

		if(crosscheck(x1,y1,x2,y2,wx,wy,r)){printf("c\n");continue;}
		if(crosscheck(x2,y2,x3,y3,wx,wy,r)){printf("c\n");continue;}
		if(crosscheck(x3,y3,x1,y1,wx,wy,r)){printf("c\n");continue;}

		int d1=(x1-wx)*(x1-wx)+(y1-wy)*(y1-wy)-r*r;
		int d2=(x2-wx)*(x2-wx)+(y2-wy)*(y2-wy)-r*r;
		int d3=(x3-wx)*(x3-wx)+(y3-wy)*(y3-wy)-r*r;

		if(d1<=0 && d2<=0 && d3<=0){printf("b\n");continue;}

		if(d1==0 || d2==0 || d3==0){printf("d\n");continue;}

		int tim1=(wx-x1)*(y2-y1)-(wy-y1)*(x2-x1);
		int tim2=(wx-x2)*(y3-y2)-(wy-y2)*(x3-x2);
		int tim3=(wx-x3)*(y1-y3)-(wy-y3)*(x1-x3);

		if(tim1*tim2>0 && tim2*tim3>0){printf("a\n");continue;}
		printf("d\n");

	}
	return 0;
}

Compiler output:
main.c:6:8: error: 'y1' redeclared as different kind of symbol
    6 | int x1,y1,x2,y2,x3,y3,wx,wy,r;
      |        ^~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:28,
                 from main.c:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration of 'y1' with type 'double(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
Language: C++

#include "stdafx.h"
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <fstream>

using namespace std;

struct Point{
  int x;
  int y;
};

struct Delta{
  Point p[3];
};

struct Circle{
  Point p;
  int radius;
};

double distance(Point p1, Point p2){
  return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}

double dist_line(Point pl1, Point pl2, Point p){
  int a = pl1.x - pl2.x;
  int b = pl2.y - pl1.y;
  int c = pl1.y * pl2.x - pl1.x * pl2.y;
  double ans = b * p.x + a * p.y + c;
  ans = (ans >= 0) ? ans : -ans;
  return ans / sqrt(a*a + b*b);
}
int main(void){
  string str;
  ifstream ifs("../input.txt");
  if (ifs.fail()) {
	  cerr << "cannot find the file" << endl;
	  return 1;
  }
  while(1){
    Circle *c = (Circle *) malloc(sizeof(Circle));
	Delta *d = (Delta *) malloc(sizeof(Delta));
	for (int i = 0; i < 5; i++) {
		getline(ifs, str);

      if(str == "0 0") break;
	  
      int j;
      for(j = 0; j <(int) str.size(); j++){
	      if(str[j] == ' '){			
			str[j] = '\0';
			break;
        }
      }
      switch(i){
        case 0:
        case 1:
        case 2:
        d->p[i].x = atoi(str.c_str());
        d->p[i].y = atoi(&str[j+1]);
        break;
        case 3:
        c->p.x = atoi(str.c_str());
        c->p.y = atoi(&str[j+1]);
        break;
        case 4:
        c->radius = atoi(str.c_str());
        break;
      }
	  
    }
    if(str == "0 0") break;
	

    if(distance(d->p[0], c->p) <= c->radius&& distance(d->p[1], c->p) <= c->radius&& distance(d->p[2], c->p) <= c->radius){
      cout << 'b' << endl;
    }
    else if(dist_line(d->p[0], d->p[1], c->p) >= c->radius&& dist_line(d->p[0], d->p[2], c->p) >= c->radius&& dist_line(d->p[1], d->p[2], c->p) >= c->radius){
		if (dist_line(d->p[0], d->p[1], d->p[2]) <= distance(d->p[0], c->p) && dist_line(d->p[1], d->p[2], d->p[0]) <= distance(d->p[1], c->p) && dist_line(d->p[2], d->p[0], d->p[1]) <= distance(d->p[2], c->p))
			cout << 'd' << endl;
		else
			cout << 'a' << endl;
    }
    else if(dist_line(d->p[0], d->p[1], c->p) <= c->radius|| dist_line(d->p[0], d->p[2], c->p) <= c->radius|| dist_line(d->p[1], d->p[2], c->p) <= c->radius){
      cout << 'c' << endl;
    }
    else{

    }
	
  }
  return 0;
}

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

#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>

#define EPS 1e-8

using namespace std;

typedef complex<double> P; 
typedef vector<P> G;

double cross(const P &a, const P &b){
    return imag(conj(a)*b);
}

double dot(const P &a, const P &b){
    return real(conj(a) * b);
}

struct L : public vector<P> {
    L(const P &a, const P &b){
        push_back(a);
        push_back(b);
    }
    L(){}
};

struct C{
    P p;
    double r;
    C(const P &p, double r) : p(p), r(r) { }
    C(){}
};

bool intersectSP(const L &s, const P &p) {
    return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

#define curr(G, i) G[i]
#define next(G, i) G[(i+1)%G.size()]
enum { OUT, ON, IN };
int contains(const G &g, const P &p) {
    bool in = false;
    for (int i = 0; i < g.size(); ++i) {
        P a = curr(g,i) - p, b = next(g,i) - p;
        if (imag(a) > imag(b)) swap(a, b);
        if (imag(a) <= 0 && 0 < imag(b))
            if (cross(a, b) < 0) in = !in;
        if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
    }
    return in ? IN : OUT;
}

int main(){
    int tmpx, tmpy,r;
    while(cin >> tmpx >> tmpy){
        if((tmpx | tmpy) == 0) break;
        G v(3);
        L *e = new L[3];
        C c;
        v[0] = P(tmpx, tmpy);
        cin >> tmpx >> tmpy;
        v[1] = P(tmpx, tmpy);
        cin >> tmpx >> tmpy;
        v[2] = P(tmpx, tmpy);
        e[0] = L(v[0],v[1]);
        e[1] = L(v[0],v[2]);
        e[2] = L(v[1],v[2]);
        cin >> tmpx >> tmpy >> r;
        c = C(P(tmpx,tmpy), r);
        //a:T contains C
        bool isA = true;
        for(int i=0;i<3;i++){
            //for all edges
            if(distanceSP(e[i], c.p) < r){
                isA = false;
            }
        }
        if(isA && contains(v, c.p) == IN){
            cout << "a" << endl;
            continue;
        }
        //b:C contains T
        bool isB = true;
        for(int i=0;i<3;i++){
            //for all vertex
            if(abs(v[i] - c.p) > r){
                isB = false;
            }
        }
        if(isB){
            cout << "b" << endl;
            continue;
        }
        bool isC = false;
        for(int i=0;i<3;i++){
            if(distanceSP(e[i]. c.p) <= r){
                isC = true;
            }
        }
        if(isC){
            cout << "c" << endl;
        }else{
            cout << "d" << endl;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:109:33: error: 'struct L' has no member named 'c'
  109 |             if(distanceSP(e[i]. c.p) <= r){
      |                                 ^
Language: Java


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Map.Entry;

public class Sample {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			Map<Integer, Integer> memo = new HashMap<Integer, Integer>();
			memo.put(0, 1);
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				Map<Integer, Integer> tmp = new HashMap<Integer, Integer>();
				tmp.putAll(memo);
				for (Entry<Integer, Integer> entry : memo.entrySet()) {
					for (int j = 1; j <= b; j++) {
						int c = entry.getKey() + a * j;
						if (c > 1000) {
							continue;
						}
						int d = entry.getValue();
						if (tmp.containsKey(c)) {
							tmp.put(c, d + tmp.get(c));
						} else {
							tmp.put(c, d);
						}

					}
				}
				memo = tmp;

			}
			int s = scanner.nextInt();
			while (s-- > 0) {
				int m = scanner.nextInt();
				if (!memo.containsKey(m)) {
					System.out.println(0);
				} else {
					System.out.println(memo.get(m));
				}
			}
		}
	}
}

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

public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			Map<Integer, Integer> memo = new HashMap<Integer, Integer>();
			memo.put(0, 1);
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				Map<Integer, Integer> tmp = new HashMap<Integer, Integer>();
				tmp.putAll(memo);
				for (Entry<Integer, Integer> entry : memo.entrySet()) {
					for (int j = 1; j <= b; j++) {
						int c = entry.getKey() + a * j;
						if (c > 1000) {
							continue;
						}
						int d = entry.getValue();
						if (tmp.containsKey(c)) {
							tmp.put(c, d + tmp.get(c));
						} else {
							tmp.put(c, d);
						}

					}
				}
				memo = tmp;

			}
			int s = scanner.nextInt();
			while (s-- > 0) {
				int m = scanner.nextInt();
				if (!memo.containsKey(m)) {
					System.out.println(0);
				} else {
					System.out.println(memo.get(m));
				}
			}
		}
	}
}

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) {
              ^
  (use --enable-preview to enable unnamed classes)
Main.java:43: error: class, interface, enum, or record expected
}
^
2 errors
Language: Java

import java.util.*;

public class AOJ_0154{
    class Card{
        int a;
        int b;
        Card(int a, int b){
            this.a = a;
            this.b = b;
        }
    }
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int[] card_num = new int[101];
            int m = sc.nextInt();
            if(m==0){
                break;
            }
            Card[] cards = new Card[m];
            for(int i = 0; i < m; i++){
                cards[i] = new Card(sc.nextInt(), sc.nextInt());
            }
            int ub = 7*100*10;
            int[] dp = new int[ub];
            dp[0] = 1;
            for(int i = 0; i < m; i++){
                for(int ii = 7 * 100 * 10 - cards[i].a -1; ii >= 0; ii--){
                    for(int iii = 1; iii <= cards[i].b; iii++){
                        if(ii + cards[i].a*iii < ub-1){
                            dp[ii + cards[i].a*iii] += dp[ii];
                        }
                    }
                }
            }
            /*
              System.out.println(Arrays.toString(dp));
              for(int i = 0; i < 100; i++){
              System.out.println(i + " : " + dp[i]);
              }
            */
            int g = sc.nextInt();
            for(int i = 0; i < g; i++){
                System.out.println(dp[sc.nextInt()]);
            }
        }
    }
    public static void main(String[] args){
        new AOJ_0154().run();
    }
}

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

import java.util.*;

public class AOJ_0154_2{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            if(m==0){
                break;
            }
            int[] value = new int[m];
            int[] num = new int[m];
            for(int i = 0; i < m; i++){
                value[i] = sc.nextInt();
                num[i] = sc.nextInt();
            }
            int[] dp = new int[1001];
            dp[0] = 1;
            for(int i = 0; i < m; i++){
                for(int ii = 1000 - value[i]; ii >= 0; ii--){
                    for(int iii = 1; iii <= num[i]; iii++){
                        if(ii + value[i]*iii <= 1000){
                            dp[ii + value[i]*iii] += dp[ii];
                        }
                    }
                }
            }
            /*
              System.out.println(Arrays.toString(dp));
              for(int i = 0; i < 100; i++){
              System.out.println(i + " : " + dp[i]);
              }
            */
            int g = sc.nextInt();
            for(int i = 0; i < g; i++){
                System.out.println(dp[sc.nextInt()]);
            }
        }
    }
    public static void main(String[] args){
        new AOJ_0154_2().run();
    }
}

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

import java.util.*;

public class AOJ_0154_2{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            if(m==0){
                break;
            }
            int[] value = new int[m];
            int[] num = new int[m];
            for(int i = 0; i < m; i++){
                value[i] = sc.nextInt();
                num[i] = sc.nextInt();
            }
            int[] dp = new int[1001];
            dp[0] = 1;
            for(int i = 0; i < m; i++){
                for(int ii = 1000 - value[i]; ii >= 0; ii--){
                    for(int v = value[i]; v <= value[i] * num[i]; v += value[i]){
                        if(ii + v <= 1000){
                            dp[ii + v] += dp[ii];
                        }
                    }
                }
            }
            /*
              System.out.println(Arrays.toString(dp));
              for(int i = 0; i < 100; i++){
              System.out.println(i + " : " + dp[i]);
              }
            */
            int g = sc.nextInt();
            for(int i = 0; i < g; i++){
                System.out.println(dp[sc.nextInt()]);
            }
        }
    }
    public static void main(String[] args){
        new AOJ_0154_2().run();
    }
}

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

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

const int MAX_M = 7, MAX_B = 10, MAX_N = 1000;
int m,g,n;
int a[MAX_M], b[MAX_M];
int dp[MAX_M + 1][MAX_N + 1];

int main()
{
    while(cin >> m && m) {
        for(int i = 0; i < m; i++)
            cin >> a[i] >> b[i];

        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;

        for(int i = 0; i < m; i++) {
            for(int j = 0; j <= MAX_N; j++) {
                for(int k = 0; k <= b[i]; k++) {
                    if(j + a[i] * k > 1000) continue;
                    dp[i+1][j+a[i]*k] += dp[i][j];
                }
            }
        }
        
        cin >> g;
        for(int k = 0; k < g; k++) {
            cin >> n;
            cout << dp[m][n] << endl;
        }

        
    }
}

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

#include<iostream>
using namespace std;

long long int dp[1001];
int a[8],b[8];
int main(void){
	int n,g;
	while(1){
		memset(dp,0,sizeof(dp));
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			scanf("%d%d",&a[i],&b[i]);
		}
		dp[0]=1;
		for(int i=0;i<n;i++){
			for(int j=1000;j>=0;j--){
				for(int k=1;k<=b[i];k++){
					if(a[i]*k<=j){
						dp[j]+=dp[j-a[i]*k];
					}
				}
			}
		}
		scanf("%d",&g);
		for(int i=0;i<g;i++){
			int a;
			scanf("%d",&a);
			printf("%d\n",dp[a]);
		}
	}
    return 0;
}

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

#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
int as[7];
int bs[7];
int m;
int sums[100 * 10 + 1];
void solve(int n, int sum) {
	if (sum > 1000)
		return;
	if (n == m) {
		sums[sum]++;
		return;
	}
	for (int i = 0; i <= bs[n]; i++) {
		solve(n + 1, sum + (i * as[n]));
	}
}

int main() {
	while (cin >> m, m) {
		memset(sums, 0, sizeof(sums));
		for (int i = 0; i < m; i++) {
			cin >> as[i];
			cin >> bs[i];
		}
		solve(0, 0);
		int g;
		cin >> g;
		for (int i = 0; i < g; i++) {
			int ni;
			cin >> ni;
			cout << sums[ni] << endl;
		}
	}
	return 0;
}

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

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

typedef pair<double,int> P;

const double INF = 1000000000;
struct edge { int to; double cost; };
vector<edge> G[1001];

void solve(int s, int g) {
    double d[1001]; fill(d, d+1001, INF);
    int prv[1001]; fill(prv, prv+1001, -1);
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.push(make_pair(0, s));
    while ( ! q.empty()) {
        int v = q.top().second;
        q.pop();
        for (int i=0; i<(int)G[v].size(); ++i) {
            edge &e = G[v][i];
            if (e.cost != INF && d[v] + e.cost < d[e.to]) {
                d[e.to] = d[v] + e.cost;
                q.push(make_pair(d[e.to], e.to));
                prv[e.to] = v;
            }
        }
    }
    int k = g;
    if (prv[k] < 0) {
        cout << "NA" << endl;
    } else {
        vector<int> ret;
        while (0 <= k) {
            ret.push_back(k);
            k = prv[k];
        }
        for (int i=ret.size()-1; i>=0; --i) {
            cout << ret[i] << (i != 0 ? " " : "");
        }
        cout << endl;
    }
}

int main() {
    int n, m, s, g;
    int b[1000], x[1000], y[1000];
    while (cin >> n, n) {
        for (int i=0; i<n; ++i) {
            cin >> b[i] >> x[i] >> y[i];
        }
        for (int i=0; i<1001; ++i) {
            G[i].clear();
        }
        for (int i=0; i<n; ++i) {
            for (int j=i+1; j<n; ++j) {
                int cost = (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
                if (2500 < cost) {
                    G[b[i]].push_back((edge){b[j], INF});
                    G[b[j]].push_back((edge){b[i], INF});
                } else {
                    G[b[i]].push_back((edge){b[j], sqrt(cost)});
                    G[b[j]].push_back((edge){b[i], sqrt(cost)});
                }
            }
        }
        cin >> m;
        for (int i=0; i<m; ++i) {
            cin >> s >> g;
            solve(s, g);
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:52: error: 'sqrt' was not declared in this scope
   66 |                     G[b[i]].push_back((edge){b[j], sqrt(cost)});
      |                                                    ^~~~
Language: C++

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

const double EPS = 1e-4;

struct Building{
	int x, y;
};

struct Edge{
	int to;
	double cost;
	Edge(){}
	Edge(const int &_to, const double &_cost){
		to = _to; cost = _cost;
	}
};

struct Data{
	int n;
	double cost;
	Data(){}
	Data(const int &_n, const double &_cost){
		n = _n; cost = _cost;
	}
	bool operator < (const Data &a) const{
		return cost > a.cost;
	}
};

double GetDistance(const Building &b1, const Building &b2){
	double dx = b1.x - b2.x, dy = b1.y - b2.y;
	return sqrt(dx*dx + dy*dy);
}

int main(){
	int N, M, B, S, G;

	while(cin >> N, N){
		Building v[1000];
		vector<Edge> e[1000];

		for(int i = 0; i < N; i++){
			cin >> B; B--;
			cin >> v[B].x >> v[B].y;
		}

		for(int i = 0; i < N; i++){
			for(int j = i+1; j < N; j++){
				double dist = GetDistance(v[i], v[j]);
				if(dist <= 50){
					e[i].push_back( Edge(j, dist) );
					e[j].push_back( Edge(i, dist) );
				}
			}
		}

		cin >> M;
		for(int j = 0; j < M; j++){
			cin >> S >> G; S--; G--;

			priority_queue<Data> pq;
			Data pq_top;
			pq.push( Data(S, 0) );
			double memo[1000];
			fill_n(memo, N, -1);
			bool na = true;

			while( !pq.empty() ){
				pq_top = pq.top(); pq.pop();
			
				if(memo[pq_top.n] > -0.5) continue;
				memo[pq_top.n] = pq_top.cost;
				if(pq_top.n == G){
					na = false; break;
				}

				for(int i = 0; i < e[pq_top.n].size(); i++){
					pq.push( Data( e[pq_top.n][i].to, pq_top.cost + e[pq_top.n][i].cost ) );
				}
			}

			if(na){
				puts("NA"); break;
			}

			stack<int> ans;
			while(true){
				ans.push(G);
				if(G == S) break;
				for(int i = 0; i < e[G].size(); i++){
					if( abs(memo[G] - memo[ e[G][i].to ] - e[G][i].cost) < EPS){
						G = e[G][i].to; break;
					}
				}
			}
		
			printf("%d", ans.top()+1 ); ans.pop();
			while( !ans.empty() ){
				printf(" %d", ans.top()+1 ); ans.pop();
			}puts("");
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'double GetDistance(const Building&, const Building&)':
a.cc:38:16: error: 'sqrt' was not declared in this scope
   38 |         return sqrt(dx*dx + dy*dy);
      |                ^~~~
Language: C++

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

const double EPS = 1e-4;

struct Building{
	int x, y;
};

struct Edge{
	int to;
	double cost;
	Edge(){}
	Edge(const int &_to, const double &_cost){
		to = _to; cost = _cost;
	}
};

struct Data{
	int n;
	double cost;
	Data(){}
	Data(const int &_n, const double &_cost){
		n = _n; cost = _cost;
	}
	bool operator < (const Data &a) const{
		return cost > a.cost;
	}
};

double GetDistance(Building &b1, Building &b2){
	double dx = b1.x - b2.x, dy = b1.y - b2.y;
	return sqrt(dx*dx + dy*dy);
}

int main(){
	int N, M, B, S, G;

	while(cin >> N, N){
		Building v[1000];
		vector<Edge> e[1000];

		for(int i = 0; i < N; i++){
			cin >> B; B--;
			cin >> v[B].x >> v[B].y;
		}

		for(int i = 0; i < N; i++){
			for(int j = i+1; j < N; j++){
				double dist = GetDistance(v[i], v[j]);
				if(dist <= 50){
					e[i].push_back( Edge(j, dist) );
					e[j].push_back( Edge(i, dist) );
				}
			}
		}

		cin >> M;
		for(int j = 0; j < M; j++){
			cin >> S >> G; S--; G--;

			priority_queue<Data> pq;
			Data pq_top;
			pq.push( Data(S, 0) );
			double memo[1000];
			fill_n(memo, N, -1);
			bool na = true;

			while( !pq.empty() ){
				pq_top = pq.top(); pq.pop();
			
				if(memo[pq_top.n] > -0.5) continue;
				memo[pq_top.n] = pq_top.cost;
				if(pq_top.n == G){
					na = false; break;
				}

				for(int i = 0; i < e[pq_top.n].size(); i++){
					pq.push( Data( e[pq_top.n][i].to, pq_top.cost + e[pq_top.n][i].cost ) );
				}
			}

			if(na){
				puts("NA"); break;
			}

			stack<int> ans;
			while(true){
				ans.push(G);
				if(G == S) break;
				for(int i = 0; i < e[G].size(); i++){
					if( abs(memo[G] - memo[ e[G][i].to ] - e[G][i].cost) < EPS){
						G = e[G][i].to; break;
					}
				}
			}
		
			printf("%d", ans.top()+1 ); ans.pop();
			while( !ans.empty() ){
				printf(" %d", ans.top()+1 ); ans.pop();
			}puts("");
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'double GetDistance(Building&, Building&)':
a.cc:38:16: error: 'sqrt' was not declared in this scope
   38 |         return sqrt(dx*dx + dy*dy);
      |                ^~~~
Language: C++

#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<functional>
using namespace std;
typedef pair<double, int> P;
priority_queue<P, vector<P>, greater<P>> Q;
#define MAX_N 1005
int x[MAX_N], y[MAX_N]; double dist[MAX_N];
vector<int>path[MAX_N]; vector<P>X[MAX_N];
void dijkstra(int a, int b) {
	memset(dist, 1e+9, sizeof(dist));
	for (int i = ; i < MAX_N; i++) { path[i].clear(); }
	Q.push(make_pair(0.0, a)); dist[a] = 0; path[a].push_back(a);
	while (!Q.empty()) {
		pair<double, int>pa = Q.top(); Q.pop();
		double a1 = pa.first; int a2 = pa.second;
		for (int i = 0; i < X[a2].size(); i++) {
			int to = X[a2][i].second; double dis = X[a2][i].first;
			if (dist[to] > a1 + dis) {
				dist[to] = a1 + dis; path[to].clear();
				path[to] = path[a2]; path[to].push_back(to);
				Q.push(make_pair(dist[to], to));
			}
		}
	}
	if (path[b].size() == 0) { cout << "NA" << endl; }
	else {
		for (int i = 0; i < path[b].size(); i++) { if (i) { cout << ' '; } cout << path[b][i]; }
		cout << endl;
	}
}
int main() {
	int N, Q, s, g;
	while (true) {
		cin >> N; if (N == 0) { break; }
		for (int i = 0; i < N; i++) { cin >> x[i] >> y[i]; }
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				double dist2 = (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]);
				if (dist2 <= 50.0) {
					X[i].push_back(make_pair(dist2, j));
				}
			}
		}
		cin >> Q; for (int i = 0; i < Q; i++) { cin >> s >> g; dijkstra(s, g); }
	}
	return 0;
}

Compiler output:
a.cc: In function 'void dijkstra(int, int)':
a.cc:14:22: error: expected primary-expression before ';' token
   14 |         for (int i = ; i < MAX_N; i++) { path[i].clear(); }
      |                      ^
Language: C++


#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int N=1001;
//near equal?
int F(double x,double y){return fabs(x-y)<1e-9;}
//IÉÜÜêévÌCfbNX
int G(const vector<int>&I,int v){return find(I.begin(),I.end(),v)-I.begin()+1;}
int main()
{
	int n,m,i,j,b,x,y,s,g,X[N],Y[N];
	static double D[N][N],V=1e10,t;
	while(scanf("%d",&n),n)
	{
		vector<int>I;	//rÌÔÌW
		for(i=0;i<n;++i)scanf("%d%d%d",&b,&x,&y),I.push_back(b),X[I.size()]=x,Y[I.size()]=y;
		for(i=1;i<=n;++i)for(j=1;j<=n;++j)D[i][j]=D[j][i]=hypot(X[i]-X[j],Y[i]-Y[j]);
		for(scanf("%d",&m);m--;)
		{
			scanf("%d%d",&s,&g);
			typedef pair<double,int>P;	//-ÅZ£AtoIndex ©firstÉ-Â¯ÄéÌYêÈ¢ÅËIftHÌless()ÅåävÈæ¤ÉI
			P p;
			priority_queue<P>q;
			double d[N];	//»ÌrÔÜÅÌÅZ£
			fill(d,d+N,V);
			//_CNXgÅÅZoHÌZo
			q.push(P(0,G(I,s)));
			d[G(I,s)]=0;
			while(!q.empty())
			{
				p=q.top();q.pop();
				for(i=1;i<=n;++i)
					if(t=D[p.second][i],t<=50&&d[p.second]+t<d[i])
						d[i]=d[p.second]+t,q.push(P(p.first-t,i));
			}
			if(d[G(I,g)]==V)puts("NA");
			else
			{
				//S[©çÔÉAÚ±³êÄ¢éÓðgÁÄ¢éàÌð½ÇÁÄ¢­
				//tÉÇÁµÄ¾ÁÄ¢éÌÅAoÍàtÉ
				//©ª©gÉ}ÂÈ°¿á¾ßæÆ
				vector<int>v(1,G(I,g));
				for(i=G(I,g);i-G(I,s);v.push_back(i=j))for(j=1;j<=n;++j)
					if(i-j&&F(d[i],D[i][j]+d[j]))break;
				for(i=v.size()-1;i>=0;--i)printf("%d%c",I[v[i]-1],i?' ':'\n');
			}
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int G(const std::vector<int>&, int)':
a.cc:12:41: error: 'find' was not declared in this scope
   12 | int G(const vector<int>&I,int v){return find(I.begin(),I.end(),v)-I.begin()+1;}
      |                                         ^~~~
Language: C++

#include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <ctime>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef pair<double, int> state;

double memo[100];
int pre[100];
int name[100];
double x[100];
double y[100];

map<int, int> nums;

double dis(int i, int j){
  return sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
}

int main(){
  int n, m;
  int b;
  int s, g;
  while(cin >> n &&n){
    nums.clear();
    rep(i, n){
      cin >> b >> x[i] >> y[i];
      name[i] = b;
      nums[b] = i;
    }
    cin >> m;
    rep(i, m){
      memset(pre, -1, sizeof(pre));
      fill(memo, memo + 100, 1e10);
      cin >> s >> g;
      memo[nums[s]] = 0;
      priority_queue<state, vector<state>, greater<state> > que;
      que.push(state(0, nums[s]));
      while(!que.empty()){
	state st = que.top();
	que.pop();
	int v = st.second;
	double cost = st.first;
	if(name[v] == g){
	  break;
	}
	if(cost > memo[v]) continue;
	rep(i, n){
	  double d = dis(v, i);
	  if(d > 50.0) continue;
	  if(memo[i] > memo[v] + d){
	    memo[i] = memo[v] + d;
	    pre[i] = v;
	    que.push(state(memo[i], i));
	  }
	}
      }
      if(pre[nums[g]] == -1 && s != g){
	cout << "NA" << endl;
      }else{
	vector<int> res;
	int v = nums[g];
	res.push_back(v);
	while(pre[v] >= 0){
	  v = pre[v];
	  res.push_back(v);
	}
	rep(i, (int)res.size()){
	  if(i != 0) cout << " " ;
	  cout << name[res[res.size() - 1 - i]];
	}
	cout << endl;
      }
    }
  }
  return 0;
}

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

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <cstring>
#include <climits>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int n, x[1001], y[1001], m, s[1001], g[1001];
float amt[1001][1001], vtx[1001];
int pre[1001];
queue<int> que;
stack<int> out;

int main()
{
	while( cin >> n, n)
	{
		CLR(amt);

		FOR(i, 0, n)
		{
			int b;
			cin >> b >> x[i] >> y[i];
		}

		cin >> m;

		FOR(i, 0, m)
		{
			cin >> s[i] >> g[i];
			s[i]--;
			g[i]--;
		}

		FOR(j, 0, n)
			FOR(i, j, n)
			{
				if( i != j )
				{
					double dis =  sqrt( pow((float)(x[i] - x[j]), 2) + pow((float)(y[i] - y[j]), 2) );

					if(dis <= 50.0)
					{
						amt[j][i] = dis;
						amt[i][j] = dis;
					}
				}
			}
		
		FOR(k, 0, m)
		{
			que.push(s[k]);

			FOR(i, 0, n)
			{
				vtx[i] = INT_MAX;
			}
		
			vtx[s[k]] = 0;

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

				FOR(tg, 0, n)
				{
					if( amt[now][tg] > 0 && now != tg && vtx[now] + amt[now][tg] < vtx[tg] )
					{
						vtx[tg] = vtx[now] + amt[now][tg];
						pre[tg] = now;
						que.push(tg);
					}
				}

			}

			if( vtx[g[k]] >= INT_MAX )
			{
				cout << "NA" <<endl;
			}
			else
			{
				int now = g[k];
				
				while( now != s[k] )
				{
					out.push(pre[now]);
					now = pre[now];
				}

				while( !out.empty() )
				{
					cout << out.top()+1 << " ";
					out.pop();
				}

				cout << g[k]+1 << endl;
			}
		}


	}

	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:61: error: 'pow' was not declared in this scope
   52 |                                         double dis =  sqrt( pow((float)(x[i] - x[j]), 2) + pow((float)(y[i] - y[j]), 2) );
      |                                                             ^~~
a.cc:52:55: error: 'sqrt' was not declared in this scope
   52 |                                         double dis =  sqrt( pow((float)(x[i] - x[j]), 2) + pow((float)(y[i] - y[j]), 2) );
      |                                                       ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int n, x[1001], y[1001], m, s[1001], g[1001], pre[1001];
double amt[1001][1001], vtx[1001];

queue<int> que;
stack<int> out;

int main()
{
	while( cin >> n, n)
	{
		CLR(amt);

		FOR(i, 0, n)
		{
			int b;
			cin >> b >> x[i] >> y[i];
		}

		cin >> m;

		FOR(i, 0, m)
		{
			cin >> s[i] >> g[i];
			s[i]--;g[i]--;
		}

		FOR(j, 0, n)
			FOR(i, j, n)
			{
				if( i != j )
				{
					double dis =  sqrt( pow((double)(x[i] - x[j]), 2) + pow((double)(y[i] - y[j]), 2) );

					if(dis <= 50.0)
					{
						amt[j][i] = dis;
						amt[i][j] = dis;
					}
				}
			}
		
		FOR(k, 0, m)
		{
			que.push(s[k]);

			FOR(i, 0, n)
			{
				vtx[i] = DBL_MAX;
			}
		
			vtx[s[k]] = 0;

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

				FOR(tg, 0, n)
				{
					if( amt[now][tg] > 0 && now != tg && vtx[now] + amt[now][tg] < vtx[tg] )
					{
						vtx[tg] = vtx[now] + amt[now][tg];
						pre[tg] = now;
						que.push(tg);
					}
				}

			}

			if( vtx[g[k]] == DBL_MAX )
			{
				cout << "NA" <<endl;
			}
			else
			{
				int now = g[k];
				
				while( now != s[k] )
				{
					out.push(pre[now]);
					now = pre[now];
				}

				while( !out.empty() )
				{
					cout << out.top()+1 << " ";
					out.pop();
				}

				cout << g[k]+1 << endl;
			}
		}


	}

	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:42: error: 'DBL_MAX' was not declared in this scope
   63 |                                 vtx[i] = DBL_MAX;
      |                                          ^~~~~~~
a.cc:10:1: note: 'DBL_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>'
    9 | #include <cmath>
  +++ |+#include <cfloat>
   10 | 
a.cc:85:42: error: 'DBL_MAX' was not declared in this scope
   85 |                         if( vtx[g[k]] == DBL_MAX )
      |                                          ^~~~~~~
a.cc:85:42: note: 'DBL_MAX' is defined in header '<cfloat>'; this is probably fixable by adding '#include <cfloat>'
Language: C++

#include <iostrerm>
#include <memory>

using namespace std;

int x[1001], y[1001];
bool v[1001];
int p[1001];
int d[1001];
int edge[1001][1001];
int INF = (1 << 20);

void compute(int i, int j) {
  int temp = (x[i] - x[j]) * (x[i] - x[j]) - (y[i] - y[j]) * (y[i] - y[j]);
  if (temp <= 2500) edge[i][j] = temp;
}

void dijkstra(int s, int g, int n) {
  int mn,hozon,b;
  int a[1001];

  // init
  memset(v, false, sizeof(v));
  memset(p, 0, sizeof(p));
  memset(d, INF, sizeof(d));

  d[s] = 0;

  for(;;) {
    mn = INF;

    //tmp=hozon;
    for(int i = 1; i <= n; i++) {
      if(mn > d[i] && !v[j]) {
	mn = d[i];
	hozon = i;
      }
    }
    //via[hozon]=tmp;
    if(mn == INF) break;

    v[hozon] = true;
    
    for(int j = 1; j <= n; j++) {
      if(d[j] > d[hozon] + map[hozon][j]) {
	d[j] = map[hozon][j] + d[hozon];
	p[j] = hozon;
      }
    }
  }
  if(d[g] == INF) {
    cout << "NA" << endl;
  } else {
    b = p[g];
    while(1){
      if (b == s) break;
      a[cnt++] = b;
      b = p[b];
    }

    for(int i = cnt - 1; i >= 1; i--) {
      cout << a[i] << " ";
    }
    cout << a[0];
  }
}

int main (void) {
  int s, g;
  int n;

  while(1) {
    
    cin >> n; if (n == 0) break;
    
    for(int i = 1; i <= n; i++) {
      cin >> b;
      cin >> x[b] >> y[b];
    }
    
    for(int i = 1; i <= 1001; i++) {
      for(int j = 1; j <= 1001; j++) {
	edge[i][j] = INF;
	if(i != j) compute(i, j);
      }
    }
    
    cin >> m;
    
    for(int i = 1; i <= m; i++) {
      dijkstra(s, j, n);
    }
    
  }
  
  return 0;
}

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

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

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

class State
{
public:
  int x, y, cost;
  bool water;

  State(int _x, int _y, int _cost, bool _water)
    :x(_x), y(_y), cost(_cost), water(_water) {}

  bool operator < (const State& st) const
  {
    return this->cost > st.cost;
  }
};

int main()
{
  int n, m;
  while (cin >> n >> m) {
    if ((n|m) == 0)
      break;

    int sx, sy;
    vector<string> castle(m);
    for (int i = 0; i < m; ++i) {
      cin >> castle[i];
      castle[i].insert(castle[i].begin(), '.');
      castle[i].insert(castle[i].end(), '.');

      if (castle[i].find_first_of("&") != string::npos) {
	sx = castle[i].find_first_of("&");
	sy = i;
	castle[sy][sx] = '.';
      }
    }
    castle.insert(castle.begin(), string(n+2, '.'));
    castle.push_back(string(n+2, '.'));
    ++sy;

    priority_queue<State> que;
    que.push(State(sx, sy, 0, false));
    vector<vector<int> > dp(m+2, vector<int>(n+2, INF));
    while (!que.empty()) {
      const State st = que.top();
      que.pop();

      if (st.x == 0 || st.x == n+1 || st.y == 0 || st.y == m+1) {
	cout << st.cost << endl;
	break;
      }

      if (dp[st.y][st.x] < st.cost)
	continue;
      dp[st.y][st.x] = st.cost;

      for (int d = 0; d < 4; ++d) {
	int x = st.x + dx[d];
	int y = st.y + dy[d];
	if (x < 0 || n+2 <= x || y < 0 || m+2 <= y)
	  continue;

	if (st.water) {
	  if (castle[y][x] == '#' && dp[y][x] > st.cost) {
	    dp[y][x] = st.cost;
	    que.push(State(x, y, st.cost, true));
	  }

	  if (castle[y][x] == '.' && dp[y][x] > st.cost+1) {
	    dp[y][x] = st.cost+1;
	    que.push(State(x, y, st.cost+1, false));
	  }
	} else {
	  if (castle[y][x] == '#' && dp[y][x] > st.cost) {
	    dp[y][x] = st.cost;
	    que.push(State(x, y, st.cost, true));
	  }

	  if (castle[y][x] == '.' && dp[y][x] > st.cost) {
	    dp[y][x] == st.cost;
	    que.push(State(x, y, st.cost, false));
	  }
	}
      }
    }
  }
  return 0;
}

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

def ReadMap(n, m):
  Map = [0] * m
  for i in range(m):
    a = raw_input()
    b = list(a)
    if a.count('&')>0:
      j = a.index('&')
      PosCas = [j, i]
      b[j] = '.'
    Map[i] = b
  return Map, PosCas

def fill(SP, c1, c2):
  for x, y in SP:
    try:
      if Map[y][x] != c1:continue
    except: continue
    if x in [0, n-1] or y in [0, m-1]: return 1
    Map[y][x] = c2
    SP += [[x+1, y], [x-1, y], [x, y+1], [x, y-1]]
  return 0

while 1:
  n, m = map(int, raw_input().split())
  if n == m == 0: break
  Map, PosCas = ReadMap(n, m)
  c = 0
  while 1:
    SP = [PosCas]
    if fill(SP, '.', '#'): break
    c += 1
    if fill(SP, '#', '.'): break
  print c

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def ReadMap(n, m):
      | ^~~
Language: C++

#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define MAX_N 1000
int X[MAX_N][MAX_N], dist[MAX_N][MAX_N], W, H, gx, gy; char c;
int main() {
	while (true) {
		cin >> W >> H; memset(dist, 127, sizeof(dist)); queue<pair<int, int> >Q;
		memset(X, 127, sizeof(X));
		if (W == 0 && H == 0) { break; }
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> c; if (c == '&') { gx = i; gy = j; }
				if (c == '#') { X[i][j] = 1; }
				else { X[i][j] = 0; }
				if (i == 1 || i == H || j == 1 || j == W) {
						Q.push(make_pair(i, j));
						dist[i][j] = X[i][j];
					}
				}
			}
		}
		while (!Q.empty()) {
			pair<int, int>pa = Q.front(); Q.pop(); int cx = pa.first, cy = pa.second;
			int dx[4] = { 1,0,-1,0 };
			int dy[4] = { 0,1,0,-1 };
			for (int i = 0; i < 4; i++) {
				int ex = cx + dx[i], ey = cy + dy[i];
				if (X[ex][ey] <= 1) {
					int dis = dist[cx][cy] + X[ex][ey];
					if (dist[ex][ey] > dis) {
						dist[ex][ey] = dis; Q.push(make_pair(ex, ey));
					}
				}
			}
		}
		cout << dist[gx][gy] << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:25: error: 'Q' was not declared in this scope
   25 |                 while (!Q.empty()) {
      |                         ^
a.cc: At global scope:
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^
Language: C++

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

typedef pair<int, int> P;

const int INF = 10000;
const int MAX = 100;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};
int m,n,sx,sy;
int step[MAX + 2][MAX + 2];
char field[MAX + 2][MAX + 2];

int main()
{
    while(cin >> n >> m && m) {
        memset(step, INF, sizeof(step));
        memset(field, '.', sizeof(field));
        
        for(int i = 1; i <= m; i++) {
            for(int j = 1; j <= n; j++) {
                cin >> field[i][j];
                if(field[i][j] == '&') {
                    sx = j;
                    sy = i;
                }
            }
        }

        queue<P> que;
        que.push(P(sx, sy));
        step[sy][sx] = 0;
        while(!que.empty()) {
            P p = que.front(); que.pop();
            int x = p.first, y = p.second;
            for(int k = 0; k < 4; k++) {
                int nx = x + dx[k], ny = y + dy[k], s = step[y][x];
                if(field[ny][nx] == '#') s++;
                if(nx >= 0 && nx <= n + 1  && ny >= 0 && ny <= m + 1 && s < step[ny][nx]) {
                    step[ny][nx] = s;
                    que.push(P(nx, ny));
                }
            }
        }

        int res = INF;
        for(int i = 0; i <= m + 1; i++)
            for(int j = 0; j <= n + 1; j++)
                if(i == 0 || i == m + 1 || j == 0 || j == n + 1) 
                    res = min(res, step[i][j]);

        cout << res << endl;
    }
}

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

#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
#define mp make_pair
typedef pair<int, int> P;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int N, M;
char maze[110][110];
unsigned int minp[110][110];

int main() {
	for(;;) {
		memset(minp, -1, sizeof minp);
		scanf(" %d %d", &N, &M);
		if(!N && !M) break;
		for(int i = 0; i < M; i++) {
			scanf(" %s", maze[i]);
		}
#if 1
		for(int i = 0; i < M; i++) {
			printf("%s\n", maze[i]);
		}
#endif

		// P = (x, y)
		// maze[y][x]
		queue<P> que;
		{
			P put;
			for(int x = 0; x < N; x++) {
				for(int y = 0; y < M; y++) {
					if(maze[y][x] == '&') {
						put.first = x;
						put.second = y;
						minp[y][x] = 0;
						maze[y][x] = '.';
					}
				}
			}
			que.push(put);
		}
		;
		while(!que.empty()) {
			P p = que.front();
			que.pop();
			// endð Èµ ?
			

			// push
			for(int i = 0; i < 4; i++) {
				int nx = p.first + dx[i];
				int ny = p.second + dy[i];
				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first];
					que.push(mp(nx, ny));
				}

				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first];
					que.push(mp(nx, ny));
				}

				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first] + 1;
					que.push(mp(nx, ny));
				}

				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first];
					que.push(mp(nx, ny));
				}
			}
		}
		unsigned int minv = INT_MAX;
		for(int i = 0; i < N; i++) {
			minv = min(minv, min(minp[0][i], minp[M - 1][i]));
		}
		for(int i = 0; i < M; i++) {
			minv = min(minv, min(minp[i][0], minp[N - 1][i]));
		}
		printf("%d\n", minv);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:37: error: 'INT_MAX' was not declared in this scope
   79 |                 unsigned int minv = INT_MAX;
      |                                     ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include <algorithm>
  +++ |+#include <climits>
    6 | using namespace std;
Language: C++

#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
#define mp make_pair
typedef pair<int, int> P;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int N, M;
char maze[110][110];
unsigned int minp[110][110];

int main() {
	for(;;) {
		memset(minp, -1, sizeof minp);
		scanf(" %d %d", &N, &M);
		if(!N && !M) break;
		for(int i = 0; i < M; i++) {
			scanf(" %s", maze[i]);
		}

		// P = (x, y)
		// maze[y][x]
		queue<P> que;
		{
			P put;
			for(int x = 0; x < N; x++) {
				for(int y = 0; y < M; y++) {
					if(maze[y][x] == '&') {
						put.first = x;
						put.second = y;
						minp[y][x] = 0;
						maze[y][x] = '.';
					}
				}
			}
			que.push(put);
		}
		;
		while(!que.empty()) {
			P p = que.front();
			que.pop();

			// push
			for(int i = 0; i < 4; i++) {
				int nx = p.first + dx[i];
				int ny = p.second + dy[i];
				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first];
					que.push(mp(nx, ny));
				}

				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first];
					que.push(mp(nx, ny));
				}

				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '.' && maze[ny][nx] == '#' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first] + 1;
					que.push(mp(nx, ny));
				}

				if(0 <= nx && nx < N && 0 <= ny && ny < M && maze[p.second][p.first] == '#' && maze[ny][nx] == '.' && minp[ny][nx] > minp[p.second][p.first]) {
					minp[ny][nx] = minp[p.second][p.first];
					que.push(mp(nx, ny));
				}
			}
		}
		unsigned int minv = INT_MAX;
		for(int i = 0; i < N; i++) {
			minv = min(minv, min(minp[0][i], minp[M - 1][i]));
		}
		for(int i = 0; i < M; i++) {
			minv = min(minv, min(minp[i][0], minp[N - 1][i]));
		}
		printf("%d\n", minv);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:37: error: 'INT_MAX' was not declared in this scope
   71 |                 unsigned int minv = INT_MAX;
      |                                     ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 | using namespace std;