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

#include<cstdio>
#include<utility>
#include<queue>
#define N 800
using namespace std;

int a[N+2][N+2];
char s[N+1];

queue<pair<int,int> > Q;

int minim(int a,int b){
    return (a<b) ? a : b;
}

int main(){
    int n,m,k;
    int i,j;

    scanf ("%d%d%d\n",&n,&m,&k);

    pair<int,int> S;
    for(i=1;i<=n;i++){
        gets(s);

        for(j=0;j<m;j++){
            if (s[j]=='S') S={i,j+1};
            else
            if (s[j]=='#') a[i][j+1]=-1;
        }
    }

    for(i=1;i<=n;i++)
        a[i][0]=a[i][m+1]=-1;
    for(j=1;j<=m;j++)
        a[0][j]=a[n+1][j]=-1;

    a[S.first][S.second]=1;
    Q.push({S.first,S.second});
    int min=n;

    while(!Q.empty()){
        S=Q.front();
        Q.pop();

        min=minim(min,minim(S.first-1,minim(S.second-1,minim(n-S.first,m-S.second))));

        if (a[S.first][S.second]<=k){
            if (a[S.first+1][S.second]==0){
                a[S.first+1][S.second]=a[S.first][S.second]+1;
                Q.push({S.first+1,S.second});
            }
            if (a[S.first-1][S.second]==0){
                a[S.first-1][S.second]=a[S.first][S.second]+1;
                Q.push({S.first-1,S.second});
            }
            if (a[S.first][S.second+1]==0){
                a[S.first][S.second+1]=a[S.first][S.second]+1;
                Q.push({S.first,S.second+1});
            }
            if (a[S.first][S.second-1]==0){
                a[S.first][S.second-1]=a[S.first][S.second]+1;
                Q.push({S.first,S.second-1});
            }
        }
    }

    printf ("%d",1+(min-1)/k+1);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   24 |         gets(s);
      |         ^~~~
      |         getw
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
inline void write(int a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
inline int	read()//不管是正负数，都可以 
{
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
int ans=10000000,n,m,k,S1[4]={0,0,1,-1},S2[4]={1,-1,0,0},s1,s2;
bool vis[1000][1000];
char ch[1000][1000];
inline void dfs(int x,int y,int zs){
	if(vis[x][y]||ch[x][y]=='#')return;
	vis[x][y]=true;
	if(x==1||x==n||y==1||y==m){
		ans=min(ans,1); return;
	}
	ans=min(ans,1+min((x-2)/k+1,min((y-2)/k+1,min((n-x-1)/k+1,(m-y-1)/k+1))));
	if(zs<k)for(int i=0;i<4;i++)dfs(x+S1[i],y+S2[i],zs+1);
}
int main(){
	 int size = 25 << 20; // 256MB  
    char *p = (char*)malloc(size) + size;  
    __asm__("movl %0, %%esp\n" :: "r"(p));
	n=read(); m=read(); k=read();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)scanf("\n%c",&ch[i][j]);
		for(int j=1;j<=m;j++)if(ch[i][j]=='S'){
			s1=i; s2=j;
		}
	}
	dfs(s1,s2,0);
	writeln(ans);
}

Compiler output:
a.cc: Assembler messages:
a.cc:40: Error: operand type mismatch for `mov'
Language: C++

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t H,W,K;
char map[1000][1000];
bool ok[1000][1000];
int d[1000][1000]; // 最短距離
void func(int h, int w, int k)
{
	if (h < 0 || H <= h || w < 0 || W <= w) { return; }
	if (k < 0) { return; }
	//if (ok[h][w]) { return; }
    if(d[h][w] <= K - k) return;
	if (map[h][w] == '#') { return; }
	ok[h][w] = true;
    d[h][w] = K - k;
	func(h - 1, w, k - 1);
	func(h + 1, w, k - 1);
	func(h, w - 1, k - 1);
	func(h, w + 1, k - 1);
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> H>>W>>K;
	for (size_t i = 0; i < H; i++)
	{
		in >> map[i];
	}
	int sx, sy;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t w = 0; w < W; w++)
		{
			if (map[i][w] == 'S') {
				sx = w; sy = i; map[i][w] = '.';
			}
		}
	}
    for(int i = 0; i < 1000; ++i){
        d[i][j] = 999999;
    }
	func(sy, sx, K);

	int res = H*W;
	for (int i = 0; i < H; i++)
	{
		for (int w = 0; w < W; w++)
		{
			if (map[i][w] != '#' && ok[i][w]) {
				res = std::min(res, 1 + (std::min({ i,H - i - 1,w,W - w - 1 })+K-1)/K);
			}
		}
	}
	std::cout << res << std::endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:14: error: 'j' was not declared in this scope
   65 |         d[i][j] = 999999;
      |              ^
Language: C++

#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
 
auto& in = std::cin;
auto& out = std::cout;
 
int32_t H,W,K;
char map[1000][1000];
bool ok[1000][1000];
void func(int h, int w, int k)
{
	if (h < 0 || H <= h || w < 0 || W <= w) { return; }
	if (k < 0) { return; }
	if (ok[h][w]) { return; }
	if (map[h][w] == '#') { return; }
	ok[h][w] = true;
	func(h - 1, w, k - 1);
	func(h + 1, w, k - 1);
	func(h, w - 1, k - 1);
	func(h, w + 1, k - 1);
}
 
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
 
	in >> H>>W>>K;
	for (size_t i = 0; i < H; i++)
	{
		in >> map[i];
	}
	int sx, sy;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t w = 0; w < W; w++)
		{
			if (map[i][w] == 'S') {
				sx = w; sy = i; map[i][w] = '.';
			}
		}
	}
	func(sy, sx, K);
 
	int res = H*W;
	for (int i = 0; i < H; i++)
	{
		for (int w = 0; w < W; w++)
		{
			if (map[i][w] != '#' && ok[i][w]) {
				res = std::min(res, (long long)(1 + ceil(1.0 * (std::min({ i,H - i - 1,w,W - w - 1 }) / K)));
			}
		}
	}
	std::cout << res << std::endl;
 
	return 0;
}
#endif

Compiler output:
a.cc: In function 'int main()':
a.cc:70:69: error: 'ceil' was not declared in this scope
   70 |                                 res = std::min(res, (long long)(1 + ceil(1.0 * (std::min({ i,H - i - 1,w,W - w - 1 }) / K)));
      |                                                                     ^~~~
Language: C++

#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
 
auto& in = std::cin;
auto& out = std::cout;
 
int32_t H,W,K;
char map[1000][1000];
bool ok[1000][1000];
void func(int h, int w, int k)
{
	if (h < 0 || H <= h || w < 0 || W <= w) { return; }
	if (k == 0) { return; }
	if (ok[h][w]) { return; }
	if (map[h][w] == '#') { return; }
	ok[h][w] = true;
	func(h - 1, w, k - 1);
	func(h + 1, w, k - 1);
	func(h, w - 1, k - 1);
	func(h, w + 1, k - 1);
}
 
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
 
	in >> H>>W>>K;
	for (size_t i = 0; i < H; i++)
	{
		in >> map[i];
	}
	int sx, sy;
	for (size_t i = 0; i < H; i++)
	{
		for (size_t w = 0; w < W; w++)
		{
			if (map[i][w] == 'S') {
				sx = w; sy = i; map[i][w] = '.';
			}
		}
	}
	func(sy, sx, K);
 
	int res = H*W;
	for (int i = 0; i < H; i++)
	{
		for (int w = 0; w < W; w++)
		{
			if (map[i][w] != '#' && ok[i][w]) {
				res = std::min(res, 1 + (std::min({ i,H - i - 1,w,W - w - 1 })+K-1)/K);
			}
		}
	}
	std::cout << res << std::endl;
 
	return 0;
}

Compiler output:
a.cc:1: error: unterminated #if
    1 | #if 1
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define out(n) cout << (n) << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int h, w, k, minw, mini, z;
vector<vector<char> > buil(801, vector<char>(801));
vvi ma(801, vi(801, 99999));

int tansaku(int gh, int gw, int num) {
  int mmini = min(min(gh, h - gh), min(gw, w - gw));
  if(ma[gh][gw] <= num || buil[gh][gw] == '#' || mini + (k - num) < mmini) {
    return 1;
  }

  if(gh == 0 || gh == h - 1 || gw == 0 || gw == w - 1) {
    return 0;
  }

  if(num == k) {
    int mh = min(gh, h - gh), mw = min(gw, w - gw);
    int res = min(mh, mw);
    if(mini > res) {
      mini = res;
      z = gh <= mw && gh <= h - gh ? 0
      : h - gh <= mw && h - gh <= gh ? 1
      : gw <= mh && gw <= w - gw ? 2 : 3;
    }
    return 1;
  }

  ma[gh][gw] = num;

  return min(
    min(tansaku(gh + 1, gw, num + 1),
    tansaku(gh - 1, gw, num + 1)),
    min(tansaku(gh, gw + 1, num + 1),
    tansaku(gh, gw - 1, num + 1))
  );
}

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

  char a;
  int sh, sw;

  rep(i, 0, h) {
    rep(j, 0, w) {
      cin >> a;
      if(a == 'S') {
        sh = i;
        sw = j;
      }

      buil[i][j] = a;
    }
  }

  int mh = min(sh, h - sh), mw = min(sw, w - sw);
  mini = min(mh, mw);

  z = sh <= mw && sh <= h - sh ? 0
  : h - sh <= sw && h - sh <= sh ? 1
  : sw <= sh && sw <= w - sw ? 2 : 3;

  if(!tansaku(sh, sw, 0)) {
    out(1);
    return 0;
  }

  out((z == 0 ? mini : ) / k + 2)

  out(mini / k + 2);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:87:24: error: expected primary-expression before ')' token
   87 |   out((z == 0 ? mini : ) / k + 2)
      |                        ^
a.cc:13:25: note: in definition of macro 'out'
   13 | #define out(n) cout << (n) << endl;
      |                         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define out(n) cout << (n) << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int h, w, k, minw, mini;
vector<vector<char> > buil(801, vector<char>(801));
vvi ma(801, vi(801, 99999));

int tansaku(int gh, int gw, int num) {
  int mmini = min(min(gh, h - gh), min(gw, w - gw));
  if(ma[gh][gw] <= num || buil[gh][gw] == '#' || mini + (k - num) < mmini) {
    return 1;
  }

  if(gh == 0 || gh == h - 1 || gw == 0 || gw == w - 1) {
    return 0;
  }

  if(num == k) {
    int res = min(min(gh, h - gh), min(gw, w - gw));
    if(mini > res) {
      mini = res;
    }
    return 1;
  }

  ma[gh][gw] = num;

  return min(
    min(tansaku(gh + 1, gw, num + 1),
    tansaku(gh - 1, gw, num + 1)),
    min(tansaku(gh, gw + 1, num + 1),
    tansaku(gh, gw - 1, num + 1))
  );
}

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

  char a;
  int sh, sw;

  rep(i, 0, h) {
    rep(j, 0, w) {
      cin >> a;
      if(a == 'S') {
        sh = i;
        sw = j;
      }

      buil[i][j] = a;
    }
  }

  mini = min(min(sh, h - sh), min(sw, w - sw))

  if(!tansaku(sh, sw, 0)) {
    out(1);
    return 0;
  }

  out(min(min(h - mini, w - mini), mini) / k + 2);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:47: error: expected ';' before 'if'
   71 |   mini = min(min(sh, h - sh), min(sw, w - sw))
      |                                               ^
      |                                               ;
   72 | 
   73 |   if(!tansaku(sh, sw, 0)) {
      |   ~~
Language: C++


#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=805;
int h,w,k;
char grid[N][N];
bool vis[N][N];

bool lock_h(int l,int r,int x) {
    for (int i=l;i<=r;i++) {
        if (grid[x][i]=='#') return true;
    }
    return false;
}

bool lock_v(int u,int d,int y) {
    for (int i=u;i<=d;i++) {
        if (grid[i][y]=='#') return true;
    }
    return false;
}

int foo(int x,int y) {
    if (x==0||x==h-1||y==0||y==w-1) return 0;
    int res=INF;

    int tmp=(x-1)/k+1;
    if (lock_v(x-(((x-1)%k)+1),x-1,y)) tmp++;
    res=min(res,tmp);

    int xx=h-1-x;
    tmp=(xx-1)/k+1;
    if (lock_v(x+1,x+((xx-1)%k)+1,y)) tmp++;
    res=min(res,tmp);

    tmp=(y-1)/k+1;
    if (lock_h(y-(((y-1)%k)+1),y-1,x)) tmp++;
    res=min(res,tmp);

    int yy=w-1-y;
    tmp=(yy-1)/k+1;
    if (lock_h(y+1,y+((yy-1)%k)+1,x)) tmp++;
    res=min(res,tmp);

    return res;
}

int ans=INF;

struct node {
    int x,y,dis;
};

void bfs(int x,int y,int dis) {
    vis[x][y]=true;
    ans=min(ans,foo(x,y));
    queue<node> q;
    q.push({x,y,0});
    while (!q.empty()) {
        node cur=q.front();
        q.pop();
        if (vis[cur.xx][cur.yy]) continue;
        vis[cur.xx][cur.yy]=1;
        if (cur.dis>0) ans=min(ans,foo(cur.x,cur.y));
        for (int i=-1;i<=1;i++) {
            for (int j=-1;j<=1;j++) {
                if ((i==0&&j==0)||(i!=0&&j!=0)) continue;
                int xx=x+i;
                int yy=y+j;
                if (xx>0&&xx<h&&yy>0&&yy<h&&!vis[xx][yy]&&grid[xx][yy]!='#'&&cur.dis<dis) {
                    q.push({xx,yy,cur.dis+1});
                }
            }
        }
    }
}

int main() {
    scanf("%d%d%d",&h,&w,&k);
    for (int i=0;i<h;i++) {
        scanf("%s",grid[i]);
    }
    int sx,sy;
    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            if (grid[i][j]=='S') {
                sx=i;
                sy=j;
                break;
            }
        }
    }
    bfs(sx,sy,0);
    printf("%d\n",ans);
}


Compiler output:
a.cc: In function 'void bfs(int, int, int)':
a.cc:77:21: error: 'struct node' has no member named 'xx'; did you mean 'x'?
   77 |         if (vis[cur.xx][cur.yy]) continue;
      |                     ^~
      |                     x
a.cc:77:29: error: 'struct node' has no member named 'yy'; did you mean 'y'?
   77 |         if (vis[cur.xx][cur.yy]) continue;
      |                             ^~
      |                             y
a.cc:78:17: error: 'struct node' has no member named 'xx'; did you mean 'x'?
   78 |         vis[cur.xx][cur.yy]=1;
      |                 ^~
      |                 x
a.cc:78:25: error: 'struct node' has no member named 'yy'; did you mean 'y'?
   78 |         vis[cur.xx][cur.yy]=1;
      |                         ^~
      |                         y
Language: C++

#include<bits/stdc++.h>
#define up(j,k,i) for(ll i=j;i<k;i++)
#define down(j,k,i) for(ll i=j;i>k;i--)
#define M 1000000007
#define pp(n) printf("%lld\n",ll(n))
#define ps(n) printf("%lld ",ll(n))
#define pd(x,y) printf("%lld %lld\n",ll(x),ll(y))
#define is(n) scanf("%lld",&n)
#define inf 1e15
#define id(n,m) scanf("%lld%lld",&n,&m)
#define it(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll> 
#define db cout<<"######\n"
#define null(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,255,sizeof(a))
typedef long double ld;
typedef long long int ll;
using namespace std;
ll i,j,k,z,t,n,m,sum,ans,x,y,maxm=0,minm=inf; bool flag;
ll dist[805][805];
vector<pll> reach;
char a[805][805];
inline ll ceil(ll x,ll y)
{
if(x%y) return x/y+1;
else return x/y;
}
bool check(ll x, ll y)
{
if(x<1||x>n||y<1||y>m)
return false;
else
if(a[x][y]=='#')
return false;
else return true;
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
void bfs(ll x,ll y)
{
	dist[x][y]=0;
	
	priority_queue<pair<ll,pll>,vector<pair<ll,pll>>, greater<pair<ll,pll> >> Q;
	
	Q.push({0,{x,y}});
	
	while(!Q.empty())
	{
		auto c=Q.top(); Q.pop();
		
		z=c.F; x=c.S.F; y=c.S.S;
		
		if(z>k)
		continue;
		else
		reach.pb({x,y});
		
		up(0,4,i)
		if(check(x+dx[i],y+dy[i]))
		if(dist[x+dx[i]][y+dy[i]]>z+1)
		dist[x+dx[i]][y+dy[i]]=z+1,Q.push({z+1,{x+dx[i],y+dy[i]}});
		
	}
}
int main()
{
	it(n,m,k);
	
	up(1,n+1,i)
	up(1,m+1,j)
	{
		
		cin>>a[i][j];
		
		if(a[i][j]=='')
		x=i,y=j;
		
		dist[i][j]=inf;
	}
	
	if(x==1 or y==1)
	{
		pp(0);
		return 0;
	}
	
	bfs(x,y);
	
	ans=inf;
	
	for(auto c:reach)
	{
		ans=min(ans,min(min(ceil(n-c.F,k),ceil(c.F-1,k)),min(ceil(m-c.S,k),ceil(c.S-1,k)))+1);
	}
	
	pp(ans);	
}	


Compiler output:
a.cc:81:29: error: empty character constant
   81 |                 if(a[i][j]=='')
      |                             ^~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>

int main()
{
	long long h, w, k, sx, sy;
 
	std::cin >> h >> w >> k;
 
	std::vector<std::string> v(h);
 
	for (long long i = 0; i < h; i++) {
		std::cin >> v[i];
		auto pos = std::find(v[i].begin(), v[i].end(), 'S');
		if (pos != v[i].end()) {
			sx = i;
			sy = pos - v[i].begin();
		}
	}
 
	std::stack<std::pair<long long, long long> > s, p;
	s.push({ sx, sy });
	p.push({ sx, sy });
 
	int xx[] = { 1,0,-1,0 }, yy[] = { 0,1,0,-1 };
	while (!s.empty()) {
		int x = s.top().first, y = s.top().second;
		s.pop();
		for (int i = 0; i < 4; i++) {
			if (x + xx[i] < 0 || x + xx[i] >= h || y + yy[i] < 0 || y + yy[i] >= w) {
				continue;
			}
			if (std::abs(x + xx[i] - sx) + std::abs(y + yy[i] - sy) > k) {
				continue;
			}
			if (v[x + xx[i]][y + yy[i]] == '.') {
				s.push({ x + xx[i], y + yy[i] });
				p.push({ x + xx[i], y + yy[i] });
				v[x + xx[i]][y + yy[i]] = '#' // 一度行った場所に行かないようにする
			}
		}
	}

	long long ans = 1000000000000;
	while(!p.empty()){
		long long x = p.top().first, y = p.top().second;
		p.pop();
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * x / k)));
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * (h - x - 1) / k)));
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * y / k)));
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * (w - y - 1) / k)));
	}
 
	std::cout << ans + 1 << std::endl;
 
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:62: error: expected ';' before '}' token
   43 |                                 v[x + xx[i]][y + yy[i]] = '#' // 一度行った場所に行かないようにする
      |                                                              ^
      |                                                              ;
   44 |                         }
      |                         ~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>

int main()
{
	long long h, w, k, sx, sy;
 
	std::cin >> h >> w >> k;
 
	std::vector<std::string> v(h);
 
	for (long long i = 0; i < h; i++) {
		std::cin >> v[i];
		auto pos = std::find(v[i].begin(), v[i].end(), 'S');
		if (pos != v[i].end()) {
			sx = i;
			sy = pos - v[i].begin();
		}
	}
 
	std::stack<std::pair<long long, long long> > s, p;
	s.push({ sx, sy });
	p.push({ sx, sy });
 
	int xx[] = { 1,0,-1,0 }, yy[] = { 0,1,0,-1 };
	while (!s.empty()) {
		int x = s.top().first, y = s.top().second;
		s.pop();
		for (int i = 0; i < 4; i++) {
			if (x + xx[i] < 0 || x + xx[i] >= h || y + yy[i] < 0 || y + yy[i] >= w) {
				continue;
			}
			if (std::abs(x + xx[i] - sx) + std::abs(y + yy[i] - sy) > k) {
				continue;
			}
			if (v[x + xx[i]][y + yy[i]] == '.') {
				s.push({ x + xx[i], y + yy[i] });
				p.push({ x + xx[i], y + yy[i] });
			}
		}
	}
 
	long long ans = 1000000000000;
	while(!p.empty()){
		long long x = p.top().first, y = p.top().second;
		p.pop();
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * x / k)));
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * (h - x - 1) / k)));
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * y / k)));
		ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * (w - y - 1) / k)));
	}
 
	std::cout << ans + 1 << std::endl;
 
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:65: error: 'ceil' is not a member of 'std'
   50 |                 ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * x / k)));
      |                                                                 ^~~~
a.cc:51:65: error: 'ceil' is not a member of 'std'
   51 |                 ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * (h - x - 1) / k)));
      |                                                                 ^~~~
a.cc:52:65: error: 'ceil' is not a member of 'std'
   52 |                 ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * y / k)));
      |                                                                 ^~~~
a.cc:53:65: error: 'ceil' is not a member of 'std'
   53 |                 ans = std::min(ans, static_cast<long long>(std::ceil(1.0 * (w - y - 1) / k)));
      |                                                                 ^~~~
Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
const int M = 1e3;
char mmp[M][M], s[M][M];
int h, w, k, step[M][M], dr[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
struct TnT
{
    int x, y, step, flag;
};
bool vis[M][M];
void bfs(TnT sta)
{
    memset(step, 0, sizeof(step));
    step[sta.x][sta.y] = 1;
    memset(vis, false, sizeof(vis));
    vis[sta.x][sta.y] = true;
    queue<TnT>q;
    q.push(sta);
    while (!q.empty())
    {
        TnT gg = q.front();
        q.pop();
        for (int i = 0 ; i < 4 ; i++)
        {
            TnT gl = gg;
            gl.x += dr[i][0];
            gl.y += dr[i][1];
            if (gl.x >= 0 && gl.x < h && gl.y >= 0 && gl.y < w && mmp[gl.x][gl.y] != '#' && !vis[gl.x][gl.y])
            {
                gl.step++;
                step[gl.x][gl.y] = gl.step;
                vis[gl.x][gl.y] = true;
                q.push(gl);
            }
        }
    }
}
int main(void)
{
    scanf("%d%d%d", &h, &w, &k);
    for (int i = 0 ; i < h ; i++)
        scanf("%s", mmp[i]);
    TnT sta;
    for (int i = 0 ; i < h ; i++)
    {
        for (int j = 0 ; j < w ; j++)
        {
            if (mmp[i][j] == 'S')
            {
                sta.x = i, sta.y = j;
                break;
            }
        }
    }
    sta.step = 0, sta.flag = k;
    bfs(sta);
    int ans = 1000000000;
    for (int i = 0 ; i < h ; i++)
    {
        for (int j = 0 ; j < w ; j++)
        {
            if (step[i][j] != 0)
            {
                int gg = step[i][j], gl = 0;
                gl = gg / k + (gg % k != 0);
                gg = i;
                ans = min(ans, gl + gg / k + (gg % k != 0));
                gg = j;
                ans = min(ans, gl + gg / k + (gg % k != 0));
                gg = h - 1 - i;
                ans = min(ans, gl + gg / k + (gg % k != 0));
                gg = w - 1 - j;
                ans = min(ans, gl + gg / k + (gg % k != 0));
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Compiler output:
a.cc:81:11: error: expected constructor, destructor, or type conversion before '(' token
   81 |     printf("%d\n", ans);
      |           ^
a.cc:82:5: error: expected unqualified-id before 'return'
   82 |     return 0;
      |     ^~~~~~
a.cc:83:1: error: expected declaration before '}' token
   83 | }
      | ^
Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
const int M = 1e3;
char mmp[M][M], s[M][M];
int h, w, k, step[M][M], dr[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
struct TnT
{
    int x, y, step, flag;
};
bool vis[M][M];
void bfs(TnT sta)
{
    memset(step, 0, sizeof(step));
    step[sta.x][sta.y] = 1;
    memset(vis, false, sizeof(vis));
    vis[sta.x][sta.y] = true;
    queue<TnT>q;
    q.push(sta);
    while (!q.empty())
    {
        TnT gg = q.front();
        q.pop();
        for (int i = 0 ; i < 4 ; i++)
        {
            TnT gl = gg;
            gl.x += dr[i][0];
            gl.y += dr[i][1];
            if (gl.x >= 0 && gl.x < h && gl.y >= 0 && gl.y < w && mmp[gl.x][gl.y] != '#' && !vis[gl.x][gl.y])
            {
                gl.step++;
                step[gl.x][gl.y] = gl.step;
                vis[gl.x][gl.y] = true;
                q.push(gl);
            }
        }
    }
}
int main()
{
    scanf("%d%d%d", &h, &w, &k);
    for (int i = 0 ; i < h ; i++)
        scanf("%s", mmp[i]);
    TnT sta;
    for (int i = 0 ; i < h ; i++)
    {
        for (int j = 0 ; j < w ; j++)
        {
            if (mmp[i][j] == 'S')
            {
                sta.x = i, sta.y = j;
                break;
            }
        }
    }
    sta.step = 0, sta.flag = k;
    bfs(sta);
    int ans = 1000000000;
    for (int i = 0 ; i < h ; i++)
    {
        for (int j = 0 ; j < w ; j++)
        {
            if (step[i][j] != 0)
            {
                if (i == 0 || i == h - 1 || j == 0 || j == w - 1)//在边缘
                {
                    int gg = step[i][j];
                    ans = min(ans, gg / k + (gg % k != 0));
                }
                else
                {
                    int gl = step[i][j] / k + (gg % k != 0);//可以变gl次
                    int gg = i;
                    ans = min(ans, gl + gg / k + (gg % k != 0));
                    gg = j;
                    ans = min(ans, gl + gg / k + (gg % k != 0));
                    gg = h - 1 - i;
                    ans = min(ans, gl + gg / k + (gg % k != 0));
                    gg = w - 1 - j;
                    ans = min(ans, gl + gg / k + (gg % k != 0));
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:48: error: 'gg' was not declared in this scope; did you mean 'gl'?
   74 |                     int gl = step[i][j] / k + (gg % k != 0);//可以变gl次
      |                                                ^~
      |                                                gl
Language: C++

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

using namespace std;

const int dy[4] = {1, 0, -1, 0};
const int dx[4] = {0, 1, 0, -1};
int H, W, K;

class Coord {
    public:
        int y, x, k;

        Coord(int i, int j, int _k) {
            y = i; x = j; k = _k;
        }
        void setNextCoord(vector<Coord>& v) {
            for (int i=0; i<4; i++) {
                if (k+1 > K) continue;
                v.push_back(Coord(y+dy[i], x+dx[i], k+1));
            }
        }
        int hash() { return y*W + x; }
        int remain() { return min(min(y, H-y-1), min(x, W-x-1)); }
};

int main() {
    cin >> H >> W >> K;
    vector<String> A(H);

    unordered_set<int> st;
    queue<Coord> que;
    for (int i=0; i<H; i++) {
        cin >> A[i];
        for (int j=0; j<W; j++) {
            if (A[i][j] == 'S') que.push(Coord(i, j, 0));
        }
    }

    int minRemain = 801;
    vector<Coord> nextCoord;
    while (!que.empty()) {
        Coord c = que.front(); que.pop();
        st.insert(c.hash());

        cout << c.y <<","<< c.x <<","<< c.k <<"/"<< c.remain() << endl;

        minRemain = c.remain() < minRemain ? c.remain() : minRemain;
        if (minRemain == 0) break;

        nextCoord.clear();
        c.setNextCoord(nextCoord);

        for (Coord nc : nextCoord) {
            if (st.find(nc.hash()) != st.end()) continue;
            if (A[nc.y][nc.x] == '#') continue;
            que.push(nc);
        }
    }

    cout << 1 + (minRemain+K-1)/K << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:12: error: 'String' was not declared in this scope
   33 |     vector<String> A(H);
      |            ^~~~~~
a.cc:33:18: error: template argument 1 is invalid
   33 |     vector<String> A(H);
      |                  ^
a.cc:33:18: error: template argument 2 is invalid
a.cc:38:17: error: invalid types 'int[int]' for array subscript
   38 |         cin >> A[i];
      |                 ^
a.cc:40:18: error: invalid types 'int[int]' for array subscript
   40 |             if (A[i][j] == 'S') que.push(Coord(i, j, 0));
      |                  ^
a.cc:60:18: error: invalid types 'int[int]' for array subscript
   60 |             if (A[nc.y][nc.x] == '#') continue;
      |                  ^
Language: C++

#include <vector>
#include <string.h>
#include<iostream>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string.h>
#include<algorithm>
#include <stdlib.h>
#include<queue>
using namespace std;

const int mod=1e9+7;
typedef long long ll;

#define out_vector(v) for(auto a:v)cout<<a<<" "; cout<<endl;

int h,w,k;
char r[900][900];
int dp[900][900];

int main()
{
    cin>>h>>w>>k;
    int sa,sb;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>r[i][j];
            if(r[i][j]=='S'){
                sa=i,sb=j;
            }
        }
    }
    queue<pair<pair<int,int>,int> >que;
    que.push(make_pair(make_pair(sa, sb),0));
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
    int ans=900;
    while(que.size()){
        auto f=que.front();
        que.pop();
        int x=f.first.second,y=f.first.first;
        double mx=min(w-1-x,x);
        double my=min(h-1-y,y);
        if(mx==0||my==0)ans=1;
        else ans=min(ans,1+int(ceil(min(mx,my)/k)));
        if(f.second+1<=k){
            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&&r[ny][nx]=='.'){
                    que.push(make_pair(make_pair(ny, nx), f.second+1));
                }
            }
        }
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:32: error: 'ceil' was not declared in this scope
   47 |         else ans=min(ans,1+int(ceil(min(mx,my)/k)));
      |                                ^~~~
Language: C++

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

typedef long long ll;
const int N = 1000;
const int INF = 1 << 30;

inline char get(void) {
  return getchar();
  static char buf[100000], *S = buf, *T = buf;
  if (S == T) {
    T = (S = buf) + fread(buf, 1, 100000, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
template<typename T>
inline void read(T &x) {
  static char c; x = 0; int sgn = 0;
  for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
  for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
  if (sgn) x = -x;
}

char ch[N][N];
int mp[N][N];
int n, m, k, sx, sy, px, py, mn, dis;
int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

inline int Min(int a, int b) {
  return a < b ? a : b;
}
void dfs(int x, int y, int step) {
  if (step > k || mp[x][y] || x < 1 || y < 1 || x > n || y > m) {
    if (dis = Min(Min(x - 1, y - 1), Min(n - x, m - y)) < mn) {
      mn = Min(dis + 1, mn);
      px = x; py = y;
    }
    return;
  }
  for (int i = 0; i < 4; i++)
    dfs(x + d[i][0], y + d[i][1], step + 1);
}

int main(void) {
  read(n); read(m); read(k);
  for (int i = 1; i <= n; i++) gets(ch[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (ch[i][j] == 'S') sx = i, sy = j;
      else if (ch[i][j] == '#') mp[i][j] = 1;
  mn = INF; dfs(sx, sy, 0);
  cout << 1 + (mn + k - 1) / k << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:32: error: 'gets' was not declared in this scope; did you mean 'getw'?
   49 |   for (int i = 1; i <= n; i++) gets(ch[i] + 1);
      |                                ^~~~
      |                                getw
Language: C++

#include <iostream>
#include<algorithm>
#include<math.h>
using namespace std;
#define INF 10000000
int x[4]={-1,1,0,0};
int y[4]={0,0,1,-1};
int H,W,K,inf=INF;
int checked[800][800]={0};
int map[800][800];
int start[2];
char s;
vector<int> P;


void dfs(int a,int b,int d){
    checked[a][b]a=d;
    P.push_back(fmin(inf,fmin(fmin(a,H-1-a),fmin(b,W-1-b))));
    
    if(d<K){
    for(int i=0;i<4;i++){
        int nx=a+x[i];
        int ny=b+y[i];
        if(map[nx][ny]&&(checked[nx][ny]==0||checked[nx][ny]>d)&&nx>-1&&nx<H&&ny<W&&ny>-1){
            dfs(nx,ny,d+1);
        }
    }
    }
}

int main(void){
    cin>>H>>W>>K;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>s;
            if(s=='#')map[i][j]=0;
            if(s=='S'){
                map[i][j]=1;
                start[0]=i;
                start[1]=j;
            }
            if(s=='.')map[i][j]=1;
        }
    }
    
    
    dfs(start[0],start[1],0);
    sort(P.begin(),P.end());
    cout<<(P[0]+K-1)/K+1;
}


Compiler output:
a.cc:13:1: error: 'vector' does not name a type
   13 | vector<int> P;
      | ^~~~~~
a.cc: In function 'void dfs(int, int, int)':
a.cc:17:18: error: expected ';' before 'a'
   17 |     checked[a][b]a=d;
      |                  ^
      |                  ;
a.cc:18:5: error: 'P' was not declared in this scope
   18 |     P.push_back(fmin(inf,fmin(fmin(a,H-1-a),fmin(b,W-1-b))));
      |     ^
a.cc: In function 'int main()':
a.cc:48:10: error: 'P' was not declared in this scope
   48 |     sort(P.begin(),P.end());
      |          ^
Language: C++

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

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

int main() {
  int height, width, k;

  cin >> height
      >> width
      >> k;

  int startHeight;
  int startWidth;
  char grid[height][width];

  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cin >> grid[i][j];
      if (grid[i][j] == 'S') {
        startHeight = i;
        startWidth = j;
      }
    }
  }

  int min = 100000;
  int board[height][width];
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      board[i][j] = -1;
    }
  }

  board[statHeight][startWidth] = 0;
  queue<int> queueX;
  queue<int> queueY;
  queueX.push(startHeight);
  queueY.push(startWidth);
 while (queueX.size() > 0) {
    int x = queueX.front();
    int y = queueY.front();
    queueX.pop();
    queueY.pop();

    for (int i = 0; i < dx.size(); i++) {
      int nextX = x;
      int nextY = y;
      int majic = k;
      for (int j = 0; j < k; j++) {
        if (   grid[nextY + dy[i]][nextX + dx[i]] == '.'
            || grid[nextY + dy[i]][nextX + dx[i]] == 'S') {
          nextX += dx[i];
          nextY += dy[i];
        } else if (grid[nextY + dy[i]][nextX + dx[i]]] == "#" && k > 0) {
          nextX += dx[i];
          nextY += dy[i];
          k--;
        }
      }
      if (   0 <= nextX && nextX < width
          && 0 <= nextY && nextY < height
          && board[nextY][nextX] == -1) {
        board[nextY][nextX] = board[y][x] + 1;
        queueX.push(nextX);
        queueY.push(nextY);
      }
    }
  }
 for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      if (grid[i][j] == "." && board[i][j] == -1)
        return -1;
      min = std::min(min, board[i][j]);
    }
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:9: error: 'statHeight' was not declared in this scope; did you mean 'startHeight'?
   37 |   board[statHeight][startWidth] = 0;
      |         ^~~~~~~~~~
      |         startHeight
a.cc:48:28: error: request for member 'size' in 'dx', which is of non-class type 'int [4]'
   48 |     for (int i = 0; i < dx.size(); i++) {
      |                            ^~~~
a.cc:57:54: error: expected ')' before ']' token
   57 |         } else if (grid[nextY + dy[i]][nextX + dx[i]]] == "#" && k > 0) {
      |                   ~                                  ^
      |                                                      )
a.cc:57:54: error: expected primary-expression before ']' token
a.cc:74:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   74 |       if (grid[i][j] == "." && board[i][j] == -1)
      |           ~~~~~~~~~~~^~~~~~
Language: Java

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

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

		int h = in.nextInt(), w = in.nextInt(), k = in.nextInt();

		String[] mazes = new String[h];

		for (int i = 0; i < mazes.length; i++) {
			mazes[i] = in.next();
		}
		in.close();

		char[][] maze = new char[h][w];
		for (int i = 0; i < mazes.length; i++) {
			for (int j = 0; j < mazes[0].length(); j++) {
				maze[i][j] = mazes[i].charAt(j);
			}
		}

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

		int sx = -1, sy = -1;
		for (int i = 1; i < maze.length - 1; ++i) {
			for (int j = 0; j < maze[0].length - 1; j++) {
				if (maze[i][j] == 'S') {
					sy = i;
					sx = j;
				}

			}
		}
		int x1, x2, y1, y2, min;
		x1 = sx;
		y1 = sy;
		x2 = w - 1 - sx;
		y2 = h - 1 - sy;

		min = Math.min(x1, Math.min(y1, Math.min(x2, y2)));

		int maxAns = min / k;
		if (min % k > 0)
			++maxAns;
		++maxAns;

		Queue<Pair> que = new LinkedList<>();
		Queue<Pair> que2 = new LinkedList<>();
		Queue<Pair> queAns = new LinkedList<>();
		que.add(new Pair(sy, sx));
		for (int i = 0; i <= k && !que.isEmpty();) {
			while (!que.isEmpty()) {
				Pair p = que.poll();
				que2.add(p);
				queAns.add(p);
			}
			while (!que2.isEmpty()) {
				Pair p = que2.poll();
				int px = p.x, py = p.y;
				for (int j = 0; j < dy.length; j++) {
					if (0 <= py + dy[j] && py + dy[j] < h && 0 <= px + dx[j] && px + dx[j] < w
							&& maze[py + dy[j]][px + dx[j]] != '#') {
						que.add(new Pair(py + dy[j], px + dy[j]));
						maze[py + dy[j]][px + dx[j]] = '#';
					}
				}
			}
			++i;
		}
		while(!queAns.isEmpty()) {
			Pair p = queAns.poll();
			sx = p.x;
			sy = p.y;
			x1 = sx;
			y1 = sy;
			x2 = w - 1 - sx;
			y2 = h - 1 - sy;

			min = Math.min(min, Math.min(x1, Math.min(y1, Math.min(x2, y2))));
		}
		System.out.println(min);
	}

}

class Pair {
	int x, y;

	public Pair(int y, int x) {
		this.y = y;
		this.x = x;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + x;
		result = prime * result + y;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Pair other = (Pair) obj;
		if (x != other.x)
			return false;
		if (y != other.y)
			return false;
		return true;
	}



Compiler output:
Main.java:121: error: reached end of file while parsing
	}
	 ^
1 error
Language: Java

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	int H,W,K;
	String[]A;
	void solve(){
		Scanner sc=new Scanner(System.in);
		int count=0;
		H=sc.nextInt();
		W=sc.nextInt();
		K=sc.nextInt(); //=魔法の移動回数=開けられる部屋の個数
		A=new String[H];
		for(int i=0;i<H;i++){
			A[i]=sc.next();
		}
		int fx=-1;
		int fy=-1;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(A[i].charAt(j)=='S'){
					fx=j;
					fy=i;
				}
			}
		}
		Queue<Integer> nowq=new LinkedList<Integer>();
		nowq.add(encode(fy,fx));
		
		int[] vy=new int[]{1,0,-1,0};
		int[] vx=new int[]{0,1,0,-1};
		
		boolean[][] check=new boolean[H][W];
		check[fy][fx]=true;
		
		//幅優先探索
		LOOP:while(true){
			count++;
			//開けた部屋を入れるキュー
			Queue<Integer> nextq=new LinkedList<Integer>();
			
			Queue<Integer>nextnextq=new LinkedList<Integer>();
			
			while(!nowq.isEmpty()){
				int now=nowq.poll();
				int y=now/1000;
				int x=now%1000;
				//K回まで移動できる
				for(int i=0;i<K;i++){
					for(int j=0;j<4;j++){
						int ny=y+vy[j];
						int nx=x+vx[j];
					
						if(!ok(ny,nx))continue;
					
						if(check[ny][nx])continue;
					
						check[ny][nx]=true;
					
						if(A[ny].charAt(nx)!='#' && (ny==0 || ny==H-1 || nx==0 || nx==W-1)){
							System.out.println(count);
							break LOOP;
						}
						else if(A[ny].charAt(nx)=='#'){
							nextq.add(encode(ny,nx));
						}
						else{
							nowq.add(encode(ny,nx));
						}
					}
				}
			}
			
			nowq=nextq;
			
			while(!nowq.isEmpty()){
				int now=nowq.poll();
				int y=now/1000;
				int x=now%1000;
				
				//K-1回まで部屋を開ける(移動する）
				for(int i=0;i<K-1;i++){
					for(int j=0;j<4;j++){
						int ny=y+vy[j];
						int nx=x+vx[j];
					
						if(!ok(ny,nx))continue;
						
						if(check[ny][nx])continue;
					
						check[ny][nx]=true;
					
						if(A[ny].charAt(nx)=='#' && (ny==0 || ny==H-1 || nx==0 || nx==W-1)){
							System.out.println(count+1);
							break LOOP;
						}
						nextnextq.add(encode(ny,nx));
						nowq.add(encode(ny,nx));
					}
				}
			}
			nowq=nextnextq;
		}
	}

Compiler output:
Main.java:108: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

typedef long long ll;

int pos(int y, int x){
    return 1000 * y + x;
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> vs;
    int S;
    FOR(i,0,H){
        string in;
        cin >> in;
        vs.push_back(in);
        FOR(j,0,in.length()){
            if(in[j]=='S'){
                S = pos(i, j);
            }
        }
    }
    int vx[4] = {0,1,0,-1};
    int vy[4] = {-1,0,1,0};
    queue<int> que;
    que.push(S);
    int MIN = min(min(S/1000, abs(H-1-S/1000)), min(S%1000, abs(W-1-S%1000)));
    int k = 0;
    while(!que.empty()){
        int q = que.front();que.pop();
        int nowy = q/1000;
        int nowx = q%1000;
        FOR(i,0,4){
            int nexty = nowy + vy[i];
            int nextx = nowx + vx[i];
            if(vs[nexty][nextx]=='#') continue;
            que.push(pos(nexty, nextx));
            MIN = min(MIN, min(min(nexty, abs(H-1-nexty)),min(nextx, abs(W-1-nextx))));
        }
        k++;
        if(k==K) break;
    }
    if(MIN==0) cout << 1 < <endl;
    else cout << (MIN+K-1)/K+1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:28: error: expected primary-expression before '<' token
   60 |     if(MIN==0) cout << 1 < <endl;
      |                            ^
Language: C++

#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define mp make_pair
using namespace std;
int w, h, k;
char ch[810][810];
bool vis[810][810];

const int xx[4] = {0, 1, 0, -1};
const int yy[4] = {1, 0, -1, 0};

vector<pair<int, int> > pt;

void dfs(int x, int y, int time)
{
	if(time > k) return;
	pt.push_back(mp(x, y))
	for(int i = 0; i < 4; i ++)
	{
		int u = x + xx[i];
		int v = y + yy[i];
		if(u <= 0) continue;
		if(v <= 0) continue;
		if(u > w) continue;
		if(v > h) continue;
		if(vis[u][v]) continue;
		if(ch[u][v] == '#') continue;
		vis[u][v] = 1;
		dfs(u, v, time + 1);
	}
}

int main()
{
	cin >> h >> w >> k;
	for(int i = 1; i <= w; i ++)
		scanf("%s", ch[i] + 1);
	int stx, sty;
	for(int i = 1; i <= w; i ++)
		for(int j = 1; j <= h; j ++)
			if(ch[i][j] == 'S')
				{stx = i; sty = j; break;}

	if(stx == 1 || sty == 1 || stx == w || sty == h) {cout << 0 << endl; return;}
	//cout << stx << " " << sty << endl;
	vis[stx][sty] = 1;
	dfs(stx, sty, 0);
	int n = pt.size(), dis = 1e7;
	for(int i = 0; i < n; i ++)
	{	
		int x = pt[i].X;
		int y = pt[i].Y;
		dis = min(dis, x - 1);
		dis = min(dis, y - 1);
		dis = min(dis, w - x);
		dis = min(dis, h - y);
	}
	cout << 1 + ceil((double)dis / k);
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:19:31: error: expected ';' before 'for'
   19 |         pt.push_back(mp(x, y))
      |                               ^
      |                               ;
   20 |         for(int i = 0; i < 4; i ++)
      |         ~~~                    
a.cc:20:24: error: 'i' was not declared in this scope
   20 |         for(int i = 0; i < 4; i ++)
      |                        ^
a.cc: In function 'int main()':
a.cc:46:78: error: return-statement with no value, in function returning 'int' [-fpermissive]
   46 |         if(stx == 1 || sty == 1 || stx == w || sty == h) {cout << 0 << endl; return;}
      |                                                                              ^~~~~~
Language: C++

#include <stdio.h>
#include <queue>
using namespace std;

int H,W,K; char map[808][808]; int dist[808][808];

int main()
{
	scanf ("%d %d %d",&H,&W,&K);
	queue<pair<int, int> > Q;
	for (int i=0;i<H;i++){
		scanf ("%s",map[i]);
		for (int j=0;j<W;j++){
			dist[i][j] = -1;
			if (map[i][j] == 'S'){
				Q.push({i,j}); dist[i][j] = 0;
			}
		}
	}

	while (!Q.empty()){
		int x = Q.front().first, y = Q.front().second; Q.pop();
		int dx[4] = {0,1,0,-1};
		int dy[4] = {1,0,-1,0};
		for (int k=0;k<4;k++){
			int px = x + dx[k], py = y + dy[k];
			if (px < 0 || px >= H || py < 0 || py >= W) continue;
			if (dist[px][py] == -1 && map[px][py] != '#'){
				Q.push({px,py}); dist[px][py] = dist[x][y] + 1;
			}
		}
	}

	int ans = 0x7fffffff;
	for (int i=0;i<H;i++) for (int j=0;j<W;j++) if (dist[i][j] != -1 && dist[i][j] <= K){
		int r = (min({i,H-i-1,j,W-j-1}) + K - 1) / K + 1;
		ans = min(r,ans);
	}
	printf ("%d\n",ans);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:29: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   36 |                 int r = (min({i,H-i-1,j,W-j-1}) + K - 1) / K + 1;
      |                          ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/deque:62,
                 from /usr/include/c++/14/queue:62,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
Language: C++

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

using namespace std;

char str[888][888];
int sx,sy;

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

struct node
{
    int x,y;
};

int dp[888][888];
int vis[888][888];
int h,w,k;

void BFS()
{
    node a,b,c;
    a.x=sx;
    a.y=sy;
    queue<node> que;
    while(!que.empty())
        que.pop();
    que.push(a);
    vis[a.x][a.y]=1;
    int f=0;
    while(!que.empty())
    {
        b=que.front();
        que.pop();
        for(int i=0;i<4;i++)
        {
            c.x=b.x+dx[i];
            c.y=b.y+dy[i];
            if(c.x>=0 && c.x<h && c.y>=0 && c.y<w && !vis[c.x][c.y])
            {
                vis[c.x][c.y]=1;
                if(str[c.x][c.y]!=str[b.x][b.y] )
                {
                    dp[c.x][c.y]=dp[b.x][b.y]+1;
                    f=0;
                }
                else if(f>k)
                {
                    dp[c.x][c.y]=dp[b.x][b.y]+1;
                    f=0;
                }
                else
                {
                    dp[c.x][c.y]=dp[b.x][b.y];
                    f++;
                }
                que.push(c);
            }
        }
    }
}

int main()
{
    scanf("%d %d %d",&h,&w,&k);
    for(int i=0;i<h;i++)
    {
        scanf("%s",str[i]);
        for(int j=0;j<w;j++)
        {
            if(str[i][j]=='S')
            {
                sx=i;
                sy=j;
            }
        }
    }
    str[sx][sy]='.';
    BFS();
    int mins=INT_MAX;
    for(int i=0;i<w;i++)
    {
        mins=min(mins,dp[0][i]+1);
        mins=min(mins,dp[h-1][i]+1);
    }
    for(int i=0;i<h;i++)
    {
        mins=min(mins,dp[i][0]+1);
        mins=min(mins,dp[w-1][i]+1);
    }
    cout<<mins<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:14: error: 'INT_MAX' was not declared in this scope
   82 |     int mins=INT_MAX;
      |              ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <queue>
  +++ |+#include <climits>
    4 |