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

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

typedef pair<int, int> P;

int main()
{
	int h, w;
	cin >> h >> w;
	bool maze[20][20] = { 0 };
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			if (c == '#')
			{
				maze[i][j] = true;
			}
		}
	}
	int max = 0;
	bool visit[20][20] = { 0 };
	int size = sizeof(visit);
	queue<P> que;
	for (int sy = 0; sy < h; sy++)for (int sx = 0; sx < w; sx++)
	{
		if (maze[sy][sx])
			continue;
		
		memset(visit, false, size);

		P s = make_pair(sy, sx);

		que.push(s);

		int max_ = 0;

		while (1)
		{
			queue<P> que2;
			while (!que.empty())
			{
				P now = que.front();
				que.pop();
				int& ny = now.first;
				int& nx = now.second;

				if ((nx == 0 ? false : maze[ny][nx - 1] ? false : visit[ny][nx - 1] ? false : true))
				{
					que2.push(make_pair(ny, nx - 1));
					visit[ny][nx - 1] = true;
				}
				if ((nx == w - 1 ? false : maze[ny][nx + 1] ? false : visit[ny][nx + 1] ? false : true))
				{
					que2.push(make_pair(ny, nx + 1));
					visit[ny][nx + 1] = true;
				}
				if ((ny == 0 ? false : maze[ny - 1][nx] ? false : visit[ny - 1][nx] ? false : true))
				{
					que2.push(make_pair(ny - 1, nx));
					visit[ny - 1][nx] = true;
				}
				if ((ny == h - 1 ? false : maze[ny + 1][nx] ? false : visit[ny + 1][nx] ? false : true))
				{
					que2.push(make_pair(ny + 1, nx));
					visit[ny + 1][nx] = true;
				}
			}
			if (que2.empty())
				break;
			que = que2;
			max_++;
		}

		max = (max_ > max ? max_ : max);
	}
	
	cout << max << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:17: error: 'memset' was not declared in this scope
   35 |                 memset(visit, false, size);
      |                 ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <queue>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

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

typedef pair<int, int> P;

int main()
{
	int h, w;
	cin >> h >> w;
	bool maze[20][20] = { 0 };
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			if (c == '#')
			{
				maze[i][j] = true;
			}
		}
	}
	int max = 0;
	bool visit[20][20] = { 0 };
	int size = sizeof(visit);
	queue<P> que;
	for (int sy = 0; sy < h; sy++)for (int sx = 0; sx < w; sx++)
	{
		if (maze[sy][sx])
			continue;
		
		memset(visit, false, size);

		P s = make_pair(sy, sx);

		que.push(s);

		int max_ = 0;

		while (1)
		{
			queue<P> que2;
			while (!que.empty())
			{
				P now = que.front();
				que.pop();
				int& ny = now.first;
				int& nx = now.second;

				if ((nx == 0 ? false : maze[ny][nx - 1] ? false : visit[ny][nx - 1] ? false : true))
				{
					que2.push(make_pair(ny, nx - 1));
					visit[ny][nx - 1] = true;
				}
				if ((nx == w - 1 ? false : maze[ny][nx + 1] ? false : visit[ny][nx + 1] ? false : true))
				{
					que2.push(make_pair(ny, nx + 1));
					visit[ny][nx + 1] = true;
				}
				if ((ny == 0 ? false : maze[ny - 1][nx] ? false : visit[ny - 1][nx] ? false : true))
				{
					que2.push(make_pair(ny - 1, nx));
					visit[ny - 1][nx] = true;
				}
				if ((ny == h - 1 ? false : maze[ny + 1][nx] ? false : visit[ny + 1][nx] ? false : true))
				{
					que2.push(make_pair(ny + 1, nx));
					visit[ny + 1][nx] = true;
				}
			}
			if (que2.empty())
				break;
			que = que2;
			max_++;
		}

		max = (max_ > max ? max_ : max);
	}
	
	cout << max << endl;

	return 0;
}

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

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

typedef pair<int, int> P;

int main()
{
	int h, w;
	cin >> h >> w;
	bool maze[20][20] = { 0 };
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			if (c == '#')
			{
				maze[i][j] = true;
			}
		}
	}
	int max = 0;
	bool visit[20][20] = { 0 };
	int size = sizeof(visit);
	queue<P> que;
	for (int sy = 0; sy < h; sy++)for (int sx = 0; sx < w; sx++)
	{
		if (maze[sy][sx])
			continue;
		
		memset(visit, false, size);

		P s = make_pair(sy, sx);

		que.push(s);

		int max_ = 0;

		while (1)
		{
			queue<P> que2;
			while (!que.empty())
			{
				P now = que.front();
				que.pop();
				int& ny = now.first;
				int& nx = now.second;

				//cout << "x:" << nx << " y:" << ny << endl;

				if ((nx == 0 ? false : maze[ny][nx - 1] ? false : visit[ny][nx - 1] ? false : true))
				{
					que2.push(make_pair(ny, nx - 1));
					visit[ny][nx - 1] = true;
				}
				if ((nx == w - 1 ? false : maze[ny][nx + 1] ? false : visit[ny][nx + 1] ? false : true))
				{
					que2.push(make_pair(ny, nx + 1));
					visit[ny][nx + 1] = true;
				}
				if ((ny == 0 ? false : maze[ny - 1][nx] ? false : visit[ny - 1][nx] ? false : true))
				{
					que2.push(make_pair(ny - 1, nx));
					visit[ny - 1][nx] = true;
				}
				if ((ny == h - 1 ? false : maze[ny + 1][nx] ? false : visit[ny + 1][nx] ? false : true))
				{
					que2.push(make_pair(ny + 1, nx));
					visit[ny + 1][nx] = true;
				}
			}
			if (que2.empty())
				break;
			que = que2;
			max_++;
		}

		max = (max_ > max ? max_ : max);
		//cout << "max:" << max <<" sx:" << sx <<" sy:" << sy << endl;
	}
	
	cout << max << endl;

}

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

#include <cstdio>
#include <cstring>

#define maxn 50
char mp[maxn][maxn];
bool vis[maxn][maxn];
int ans;
struct Queue {
  int x, y, d;
} q[maxn * maxn];
void bfs(int x, int y)
{
  memset(vis, 0, sizeof (vis));
  int head = 0, tail = 1;
  q[1] = (Queue) {x, y, 0}; vis[x][y] = 1;
  while (head < tail)
  {
    Queue now = q[++head];
    ans < now.d ? ans = now.d : 0;
    for (int i = 0; i < 4; ++i)
    {
      int nx = now.x + dx[i], ny = now.y + dy[i];
      if (!vis[nx][ny])
      {
        vis[nx][ny] = 1;
        q[++tail] = (Queue) {nx, ny, now.d + 1};
      }
    }
  }
}
int main()
{
  int n, m; scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    scanf("%s", mp[i] + 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      bfs(i, j);
  printf("%d\n", ans);
  return 0;
}

Compiler output:
a.cc: In function 'void bfs(int, int)':
a.cc:22:24: error: 'dx' was not declared in this scope; did you mean 'nx'?
   22 |       int nx = now.x + dx[i], ny = now.y + dy[i];
      |                        ^~
      |                        nx
a.cc:23:20: error: 'ny' was not declared in this scope; did you mean 'nx'?
   23 |       if (!vis[nx][ny])
      |                    ^~
      |                    nx
Language: C++

#include <bits/stdc++.h>
using namespace std;
using xy=pair<int,int>;
using Graph=vector<vector<xy>>;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> S(H);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char x;
      cin>>x;
      S.at(i).push_back(x);
    }
  }
  
  int dh[4]={1,0,-1,0};
  int dw[4]={0,1,0,-1};
  
  int Ans=-1;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)!='#'){
        vector<vector<int>> d(H,vector<int>(W,-1));
        queue<xy> que;
        d.at(i).at(j)=0;
        xy p=make_pair(i,j);
        que.push(p);
        int An=0;
        while(!que.empty()){
          p=que.front();
          que.pop();
          for(int k=0;k<4;i++){
            int nh=p.first+dh[k];
            int nw=p.second+dw[k];
            if(nh<0||nh>=H||nw<0||nw>=W){
              continue;
            }
            if(S.at(nh).at(nw)=='#'){
              continue;
            }
            if(d.at(nh).at(nw)>=0){
              continue;
            }
            d.at(nh).at(nw)=d.at(p.first).at(p.second)+1;
            An=d.at(nh).at(nw)
            que.push(make_pair(nh,nw));
          }
        }
        if(An>Ans){
          Ans=An;
        }
      }
    }               
  }
  cout<<Ans<<endl;
}
        
        

Compiler output:
a.cc: In function 'int main()':
a.cc:48:31: error: expected ';' before 'que'
   48 |             An=d.at(nh).at(nw)
      |                               ^
      |                               ;
   49 |             que.push(make_pair(nh,nw));
      |             ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using xy=pair<int,int>;
using Graph=vector<vector<xy>>;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> S(H);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char x;
      cin>>x;
      S.at(i).push_back(x);
    }
  }
  
  int dh[4]={1,0,-1,0};
  int dw[4]={0,1,0,-1};
  
  int Ans=-1;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)!='#'){
        vector<vector<int>> d(H,vector<int>(W,-1));
        queue<xy> que;
        d.at(i).at(j)=0;
        xy p=make_pair(i,j);
        que.push(p);
        int An=0;
        while(!que.empty()){
          p=que.front();
          que.pop();
          for(int k=0;k<4;i++){
            int nh=p.first+dh[k];
            int nw=p.second+dw[k];
            if(nh<0||nh>=H||nw<0||nw>=W){
              continue;
            }
            if(S.at(nh).at(nw)=='#'){
              continue;
            }
            if(d.at(nh).at(nw)>=0){
              continue;
            }
            d.at(nh).at(nw)=d.at(p.first).at(p.second)+1;
            An=d.at(nh).at(nw)
            que.push(make_pair(nh,nw);
          }
        }
        if(An>Ans){
          Ans=An;
        }
      }
    }               
  }
  cout<<Ans<<endl;
}
        
        

Compiler output:
a.cc: In function 'int main()':
a.cc:48:31: error: expected ';' before 'que'
   48 |             An=d.at(nh).at(nw)
      |                               ^
      |                               ;
   49 |             que.push(make_pair(nh,nw);
      |             ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using xy=pair<int,int>;
using Graph=vector<vector<xy>>;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> S(H);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char x;
      cin>>x;
      S.at(i).push_back(x);
    }
  }
  
  int dh[4]={1,0,-1,0};
  int dw[4]={0,1,0,-1};
  
  int Ans=-1;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)!='#'){
        vector<vector<int>> d(H,vector<int>(W,-1));
        queue<xy> que;
        d.at(i).at(j)=0;
        xy p=make_pair(i,j);
        que.push(p);
        int An=0;
        while(!que.empty()){
          p=que.front();
          que.pop(p);
          for(int k=0;k<4;i++){
            int nh=p.first+dh[k];
            int nw=p.second+dw[k];
            if(nh<0||nh>=H||nw<0||nw>=W){
              continue;
            }
            if(S.at(nh).at(nw)=='#'){
              continue;
            }
            if(d.at(nh).at(nw)>=0){
              continue;
            }
            d.at(nh).at(nw)=d.at(p.first).at(p.second)+1;
            An=d.at(nh).at(nw)
            que.push(make_pair(nh,nw);
          }
        }
        if(An>Ans){
          Ans=An;
        }
      }
    }               
  }
  cout<<Ans<<endl;
}
        
        

Compiler output:
a.cc: In function 'int main()':
a.cc:34:18: error: no matching function for call to 'std::queue<std::pair<int, int> >::pop(xy&)'
   34 |           que.pop(p);
      |           ~~~~~~~^~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:316:7: note: candidate: 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >]'
  316 |       pop()
      |       ^~~
/usr/include/c++/14/bits/stl_queue.h:316:7: note:   candidate expects 0 arguments, 1 provided
a.cc:48:31: error: expected ';' before 'que'
   48 |             An=d.at(nh).at(nw)
      |                               ^
      |                               ;
   49 |             que.push(make_pair(nh,nw);
      |             ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using xy=pair<int,int>;
using Graph=vector<vector<xy>>;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> S(H);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char x;
      cin>>x;
      S.at(i).push_back(x);
    }
  }
  
  int dh[4]={1,0,-1,0}
  int dw[4]={0,1,0,-1}
  
  int Ans=-1;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)!='#'){
        vector<vector<int>> d(H,vector<int>(W,-1));
        queue<xy> que;
        d.at(i).at(j)=0;
        xy p=make_pair(i,j);
        que.push(p);
        int An=0;
        while(!que.empty()){
          p=que.front();
          que.pop(p);
          for(int k=0;k<4;i++){
            int nh=p.first()+dh[k];
            int nw=p.second()+dw[k];
            if(nh<0||nh>=H||nw<0||nw>=W){
              continue;
            }
            if(S.at(nh).at(nw)=='#'){
              continue;
            }
            if(d.at(nh).at(nw)>=0){
              continue;
            }
            d.at(nh).at(nw)=d.at(p.first()).at(p.second)+1;
            An=d.at(nh).at(nw)
            que.push(make_pair(nh,nw);
          }
        }
        if(An>Ans){
          Ans=An;
        }
      }
    }               
  }
  cout<<Ans<<endl;
}
        
        

Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: expected ',' or ';' before 'int'
   19 |   int dw[4]={0,1,0,-1}
      |   ^~~
a.cc:34:18: error: no matching function for call to 'std::queue<std::pair<int, int> >::pop(xy&)'
   34 |           que.pop(p);
      |           ~~~~~~~^~~
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:316:7: note: candidate: 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >]'
  316 |       pop()
      |       ^~~
/usr/include/c++/14/bits/stl_queue.h:316:7: note:   candidate expects 0 arguments, 1 provided
a.cc:36:27: error: expression cannot be used as a function
   36 |             int nh=p.first()+dh[k];
      |                    ~~~~~~~^~
a.cc:37:28: error: expression cannot be used as a function
   37 |             int nw=p.second()+dw[k];
      |                    ~~~~~~~~^~
a.cc:37:31: error: 'dw' was not declared in this scope; did you mean 'nw'?
   37 |             int nw=p.second()+dw[k];
      |                               ^~
      |                               nw
a.cc:47:41: error: expression cannot be used as a function
   47 |             d.at(nh).at(nw)=d.at(p.first()).at(p.second)+1;
      |                                  ~~~~~~~^~
a.cc:48:31: error: expected ';' before 'que'
   48 |             An=d.at(nh).at(nw)
      |                               ^
      |                               ;
   49 |             que.push(make_pair(nh,nw);
      |             ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using xy=pair<int,int>
using Graph=vector<vector<xy>>;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> S(H);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      char x;
      cin>>x;
      S.at(i).push_back(x);
    }
  }
  
  int dh[4]={1,0,-1,0}
  int dw[4]={0,1,0,-1}
  
  int Ans=-1;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)!='#'){
        vector<vector<int>> d(H,vector<int>(W,-1));
        queue<xy> que;
        d.at(i).at(j)=0;
        xy p=make_pair(i,j);
        que.push(p);
        int An=0;
        while(!que.empty()){
          p=que.front();
          que.pop(p);
          for(int k=0;k<4;i++){
            int nh=p.first()+dh[k];
            int nw=p.second()+dw[k];
            if(nh<0||nh>=H||nw<0||nw>=W){
              continue;
            }
            if(S.at(nh).at(nw)=='#'){
              continue;
            }
            if(d.at(nh).at(nw)>=0){
              continue;
            }
            d.at(nh).at(nw)=d.at(p.first()).at(p.second)+1;
            An=d.at(nh).at(nw)
            que.push(make_pair(nh,nw);
          }
        }
        if(An>Ans){
          Ans=An;
        }
      }
    }               
  }
  cout<<Ans<<endl;
}
        
        

Compiler output:
a.cc:3:23: error: expected ';' before 'using'
    3 | using xy=pair<int,int>
      |                       ^
      |                       ;
    4 | using Graph=vector<vector<xy>>;
      | ~~~~~                  
a.cc: In function 'int main()':
a.cc:19:3: error: expected ',' or ';' before 'int'
   19 |   int dw[4]={0,1,0,-1}
      |   ^~~
a.cc:27:15: error: 'xy' was not declared in this scope
   27 |         queue<xy> que;
      |               ^~
a.cc:27:17: error: template argument 1 is invalid
   27 |         queue<xy> que;
      |                 ^
a.cc:27:17: error: template argument 2 is invalid
a.cc:29:11: error: expected ';' before 'p'
   29 |         xy p=make_pair(i,j);
      |           ^~
      |           ;
a.cc:30:13: error: request for member 'push' in 'que', which is of non-class type 'int'
   30 |         que.push(p);
      |             ^~~~
a.cc:30:18: error: 'p' was not declared in this scope
   30 |         que.push(p);
      |                  ^
a.cc:32:20: error: request for member 'empty' in 'que', which is of non-class type 'int'
   32 |         while(!que.empty()){
      |                    ^~~~~
a.cc:33:17: error: request for member 'front' in 'que', which is of non-class type 'int'
   33 |           p=que.front();
      |                 ^~~~~
a.cc:34:15: error: request for member 'pop' in 'que', which is of non-class type 'int'
   34 |           que.pop(p);
      |               ^~~
a.cc:37:31: error: 'dw' was not declared in this scope; did you mean 'nw'?
   37 |             int nw=p.second()+dw[k];
      |                               ^~
      |                               nw
a.cc:48:31: error: expected ';' before 'que'
   48 |             An=d.at(nh).at(nw)
      |                               ^
      |                               ;
   49 |             que.push(make_pair(nh,nw);
      |             ~~~
Language: C++

#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)

using namespace std;
static const int N = 100;
static const int INF = 1e9;

int h , w;
int sy, sx, gy, gx;
int d[N][N];
bool used[N][N];
vector<string> S;

void bfs(int sh, int sw){
    queue<pair<int, int> > Q;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) used[i][j] = false;
	for(int i = 0; i < h; i++) for(int j = 0; j < h; j++) d[i][j] = INF;
  
    used[sh][sw] = true;
    d[sy][sx] = 0;
    Q.push(make_pair(sy, sx));//全てはスタート地点をqueueに突っ込んでからは閉まる
    while(!Q.empty()){
        pair<int,int> u = Q.front();Q.pop();
        int th = u.first, tw = u.second;
        used[th][tw] = true;
        if(th + 1 < h && !used[th+1][tw] && S[th+1][tw] == '.'){
            Q.push(make_pair(th+1,tw));
            used[th+1][tw] = true;
            d[th+1][tw] = d[th][tw] + 1;
        }
        if(th - 1 >= 0 && !used[th - 1][tw] && S[th-1][tw] == '.'){
            Q.push(make_pair(th-1,tw));
            used[th - 1][tw] = true;
            d[u.first - 1][tw] = d[th][tw] + 1;
        }
        if(tw + 1 < w && !used[th][tw+1] && S[th][tw+1] == '.'){
            Q.push(make_pair(th,tw+1));
            used[th][tw+1] = true;
            d[u.first][tw+1] = d[th][tw] + 1;
        }
        if(tw - 1 >= 0 && !used[th][tw-1] && S[th][tw-1] == '.'){
            Q.push(make_pair(th,tw-1));
            used[th][tw-1] = true;
            d[u.first][tw-1] = d[th][tw] + 1;
        }
    }
  	int ans = 0;
  	rep(i, 0, h) rep(j, 0, w) if(d[i][j] != INF) ans = max(ans, d[i][j]);
}
int main(){
    cin >> h >> w;
    S.resize(h);
    for(int i = 0; i < h; i++) cin >> S[i];
  
  	int ans = 0;
    for(int i = 0; i < h; i++) for(int j = 0; j < h; j++) d[i][j] = INF;
    for(int i = 0; i < h; i++)for(int j = 0; j < w; j++) if(S[i][j] =='.'){
    	ans = max(bfs(i, j), ans);
    }
    cout << ans << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:22: error: invalid use of void expression
   59 |         ans = max(bfs(i, j), ans);
      |                   ~~~^~~~~~
Language: C++

#include<iostream>
#include<queue>
#define REP(i,n) for(int i = 0; i < n; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)

using namespace std;
static const int N = 100;
static const int INF = 1e9;

int h , w;
int sy, sx, gy, gx;
int d[N][N];
bool used[N][N];
vector<string> S;

void bfs(int sh, int sw){
    queue<pair<int, int> > Q;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) used[i][j] = false;
	for(int i = 0; i < h; i++) for(int j = 0; j < h; j++) d[i][j] = INF;
  
    used[sh][sw] = true;
    d[sy][sx] = 0;
    Q.push(make_pair(sy, sx));//全てはスタート地点をqueueに突っ込んでからは閉まる
    while(!Q.empty()){
        pair<int,int> u = Q.front();Q.pop();
        int th = u.first, tw = u.second;
        used[th][tw] = true;
        if(th + 1 < h && !used[th+1][tw] && S[th+1][tw] == '.'){
            Q.push(make_pair(th+1,tw));
            used[th+1][tw] = true;
            d[th+1][tw] = d[th][tw] + 1;
        }
        if(th - 1 >= 0 && !used[th - 1][tw] && S[th-1][tw] == '.'){
            Q.push(make_pair(th-1,tw));
            used[th - 1][tw] = true;
            d[u.first - 1][tw] = d[th][tw] + 1;
        }
        if(tw + 1 < w && !used[th][tw+1] && S[th][tw+1] == '.'){
            Q.push(make_pair(th,tw+1));
            used[th][tw+1] = true;
            d[u.first][tw+1] = d[th][tw] + 1;
        }
        if(tw - 1 >= 0 && !used[th][tw-1] && S[th][tw-1] == '.'){
            Q.push(make_pair(th,tw-1));
            used[th][tw-1] = true;
            d[u.first][tw-1] = d[th][tw] + 1;
        }
    }
  	int ans = 0;
  	rep(i, 0, h) rep(j, 0, w) if(d[i][j] != INF) ans = max(ans, d[i][j]);
}
int main(){
    cin >> h >> w;
    S.resize(h);
    for(int i = 0; i < h; i++) cin >> S[i];
  
  	int ans = 0;
    for(int i = 0; i < h; i++) for(int j = 0; j < h; j++) d[i][j] = INF;
    for(int i = 0; i < h; i++)for(int j = 0; j < w; j++) if(S[i][j] =='.'){
    	ans = max(bfs(i, j), ans);
    }
    cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:22: error: invalid use of void expression
   60 |         ans = max(bfs(i, j), ans);
      |                   ~~~^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std
  int ans; int h,w;
int grid[21][21];
const int dx[] = {-1, 0, 1, 0, -1,-1, 1, 1};
const int dy[] = { 0, 1, 0,-1, -1, 1,-1, 1};
bool isallowed(int x,int y)
{
  if(x>=0 and x<h and y>=0 and y<w and grid[x][y])
    return true;
  return false;
}
void bfs(int r,int c)
{
  int vis[h][w];
  memset(vis,0,sizeof(vis));
  queue<pair<int,pair<int,int>>>q;
  q.push({r,{c,0}});
  while(!q.empty())
  {
    r=q.front().first;
    c=q.front().second.first;
    int d=q.front().second.second;
    q.pop();
    vis[r][c]=1;
    ans=max(ans,d);
    for(int i=0;i<4;i++)
    {
      if(isallowed(r+dx[i],c+dy[i]) and !vis[r+dx[i]][c+dy[i]])
        q.push({r+dx[i],{c+dy[i],d+1}});
    }
  }
}
  int main()
{
 
  cin>>h>>w;
  string s;
  
  for(int i=0;i<h;i++)
  {
    cin>>s;
    for(int j=0;j<w;j++)
    {
      if(s[j]=='.')
        grid[i][j]=1;
      else
        grid[i][j]=0;
    }
  }
  for(int i=0;i<h;i++)
  {
    for(int j=0;j<w;j++)
    {
      if(grid[i][j])
        bfs(i,j);
    }
  }
    cout<<ans<<"\n";
    return 0;
  }


Compiler output:
a.cc:2:20: error: expected ';' before 'int'
    2 | using namespace std
      |                    ^
      |                    ;
    3 |   int ans; int h,w;
      |   ~~~
Language: C++

#include<bits/stdc++.h>
using namespace std
  int ans; int h,w;
int grid[21][21];
const int dx[] = {-1, 0, 1, 0, -1,-1, 1, 1};
const int dy[] = { 0, 1, 0,-1, -1, 1,-1, 1};
bool isallowed(int x,int y)
{
  if(x>=0 and x<h and y>=0 and y<w and grid[x][y])
    return true;
  return false;
}
void bfs(int r,int c)
{
  int vis[h][w];
  memset(vis,0,sizeof(vis));
  queue<pair<int,pair<int,int>>>q;
  q.push({r,{c,0}});
  while(!q.empty)
  {
    r=q.front().first;
    c=q.front().second.first;
    int d=q.front().second.second;
    q.pop();
    vis[r][c]=1;
    ans=max(ans,d);
    for(int i=0;i<4;i++)
    {
      if(isallowed(r+dx[i],c+dy[i]) and !vis[r+dx[i]][c+dy[i]])
        q.push({r+dx[i],{c+dy[i],d+1}});
    }
  }
}
  int main()
{
 
  cin>>h>>w;
  string s;
  
  for(int i=0;i<h;i++)
  {
    cin>>s;
    for(int j=0;j<w;j++)
    {
      if(s[j]=='.')
        grid[i][j]=1;
      else
        grid[i][j]=0;
    }
  }
  for(int i=0;i<h;i++)
  {
    for(int j=0;j<w;j++)
    {
      if(grid[i][j])
        bfs(i,j);
    }
  }
    cout<<ans<<"\n";
    return 0;
  }

Compiler output:
a.cc:2:20: error: expected ';' before 'int'
    2 | using namespace std
      |                    ^
      |                    ;
    3 |   int ans; int h,w;
      |   ~~~               
a.cc: In function 'void bfs(int, int)':
a.cc:19:12: error: cannot convert 'std::queue<std::pair<int, std::pair<int, int> > >::empty' from type 'bool (std::queue<std::pair<int, std::pair<int, int> > >::)() const' to type 'bool'
   19 |   while(!q.empty)
      |            ^~~~~
a.cc:19:12: error: in argument to unary !
   19 |   while(!q.empty)
      |          ~~^~~~~
Language: C++

#include <Header.hpp>

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

char G[MAXN][MAXN];
int  dist[MAXN][MAXN], h, w;

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

void bfs(int startX, int startY)
{
    memset(dist, INFC, sizeof(dist));
    // io.WA(dist, h, w);
    queue<pair<int, int>> q;
    while (!q.empty()) q.pop();
    q.push({startX, startY});
    dist[startX][startY] = 0;
    while (!q.empty())
    {
        pair<int, int> k = q.front();
        q.pop();
        for (int i = 0; i < 4; i++)
        {
            int tx = k.first + dir[i][0];
            int ty = k.second + dir[i][1];
            if (onBoard(tx, ty) && G[tx][ty] == '.' && dist[tx][ty] > dist[k.first][k.second] + 1)
            {
                dist[tx][ty] = dist[k.first][k.second] + 1;
                q.push({tx, ty});
            }
        }
        // io.WA(dist, h, w);
    }
}

int main()
{
    io >> h >> w;
    io.RA(G, h, w);
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (G[i][j] == '.')
            {
                bfs(i, j);
                goto out1;
            }
out1:
    int ax = 0, ay = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (dist[i][j] != INF && dist[i][j] > dist[ax][ay]) ax = i, ay = j;
    bfs(ax, ay);
    // io.WL(ax, ay);
    ax = 0, ay = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (dist[i][j] != INF && dist[i][j] > dist[ax][ay]) ax = i, ay = j;
    io.WL(dist[ax][ay]);
    return 0;
}

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

dr = [0, -1, 0, 1]
dc = [1, 0, -1, 0]

def get_child(M, i, j, h, w, vis):
    child = []
    for k in range(4):
        x = i + dr[k]
        y = j + dc[k]
        if 0<= x< h and 0 <= y < w and (x, y) not in vis and M[x][y]!='#':
            child.append((x, y))

    return child

def bfs(M, i, j, h, w):
    vis = {(i, j): True}
    li = [(i, j, 0)]
    mx = 0
    while li:
        tp = li.pop(0)
        mx = max(mx, tp[2])
        ch = get_child(M, tp[0], tp[1], h, w, vis)
        vis.update( {}.fromkeys(ch, True) )
        
        ch = [(t[0], t[1], tp[2]+1) for t in ch]
        li.extend(ch)

    return mx
        
        
def solve(M, h, w):
    ans = 0
    for r in range(h):
        for c in range(w):
            if M[r][c]=='.':
                ## start bfs from this point
                depth = bfs(M, r, c, h, w)
                ans = max(ans, depth)
    print(ans)
h, w = map(int, input().split())
Mat = []
for row in range(h):
    Mat.append(input())


solve(Mat, h, w)


Compiler output:
a.cc:35:17: error: stray '##' in program
   35 |                 ## start bfs from this point
      |                 ^~
a.cc:1:1: error: 'dr' does not name a type
    1 | dr = [0, -1, 0, 1]
      | ^~
a.cc:16:5: error: 'li' does not name a type
   16 |     li = [(i, j, 0)]
      |     ^~
a.cc:22:23: error: expected unqualified-id before '.' token
   22 |         vis.update( {}.fromkeys(ch, True) )
      |                       ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define int long long


main(){


    int h, w; cin >> h >> w;
    
    vector < vector <char> > table(h, vector <char> (w));
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> table[i][j];
        }
    }
    
    vector < pair <int, int> > g;
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            g.emplace_back(i, j);
        }
    }
    
    int INF = 1e9;
    vector < vector <int> > d(h * w, vector <int> (h * w, INF));
    
    for(int k = 0; k < g.size(); k++){
        for(int i = 0; i < g.size(); i++){
            for(int j = 0; j < g.size(); j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
            }
        }
    }
    
    
    
    return 0;
}


Compiler output:
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:35:58: error: expected ';' before '}' token
   35 |                 d[i][j] = min(d[i][j], d[i][k] + d[k][j])
      |                                                          ^
      |                                                          ;
   36 |             }
      |             ~
Language: C++

n, m = map(int, input().split())
ar = []
for i in range(n):
    ar.append(list(input()))

dx = [1, -1, 0, 0]
dy = [0, 0, -1, -1]


def recursion(x, y, vis):
    ans = 0
    for k in range(4):
        x1 = x + dx[k]
        y1 = y + dy[k]

        if 0 <= x1 < n and 0 <= y1 < m and ar[x1][y1] == '.' and vis[x1][y1] == 0:
            vis[x1][y1] = 1
            ans = max(ans, 1 + recursion(x1, y1, vis))
    return ans


res = 0
for i in range(n):
    for j in range(m):
        if ar[i][j] == '.':
            vis = [[0] * m for k in range(n)]
            res = max(res, recursion(i, j, vis))

print(res)


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, m = map(int, input().split())
      | ^
Language: C++

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#include "prettyprint.hpp"

vector<int> adj[500];
bool color[500];
int d[500];

int bfs(int start, int size) {
  for (int i = 0; i < size; i++) {
    color[i] = false;
    d[i] = -1;
  }

  queue<int> bfsQueue;
  bfsQueue.push(start);
  d[start] = 0;

  while (bfsQueue.size() > 0) {
    int u = bfsQueue.front();
    bfsQueue.pop();

    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      if (!color[v]) {
        color[v] = true;
        d[v] = d[u] + 1;
        bfsQueue.push(v);
      }
    }
  }

  int maxD = 0;
  int maxDid = -1;

  for (int i = 0; i < size; i++) {
    if (d[i] > maxD) {
      maxD = d[i];
      maxDid = i;
    }
  }

  return maxDid;
}

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

  string S[H];
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }

  int firstV = -1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int v = i * W + j;

      if (S[i][j] == '.') {
        if (firstV == -1) {
          firstV = v;
        }
        if (i - 1 >= 0 && S[i - 1][j] == '.') {
          adj[v].push_back((i - 1) * W + j);
        }
        if (i + 1 < H && S[i + 1][j] == '.') {
          adj[v].push_back((i + 1) * W + j);
        }
        if (j - 1 >= 0 && S[i][j - 1] == '.') {
          adj[v].push_back(i * W + j - 1);
        }
        if (j + 1 < W && S[i][j + 1] == '.') {
          adj[v].push_back(i * W + j + 1);
        }
      }
    }
  }

  // for (int i = 0; i < H * W; i++) {
  //   cout << i << ": " << adj[i] << endl;
  // }

  // start bfs from v
  int a = bfs(firstV, H * W);
  // cout << firstV << " " << a << " " << d[a] << endl;

  int b = bfs(a, H * W);

  // cout << a << " " << b << " " << d[b] << endl;

  cout << d[b] << endl;

  return 0;
}

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

#include<bits.stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
ll INF = 1000000;
int main(){
    ll h, w, ans=0,tmp,start,goal;
    cin >> h >> w;
    vector<vector<char> > vec(h+2, vector<char>(w+2,'#'));
    ll dp[h+2][w+2][h+2][w+2];
    rep(i,h+2)rep(j,w+2)rep(k,h+2)rep(l,w+2)dp[i][j][k][l]=INF;
    rep(i,h)rep(j,w){
        cin >> vec.at(i+1).at(j+1);
    }
    int mvx[4]={0,-1,0,1},mvy[4]={-1,0,1,0};
    rep(i,h)rep(j,w){
        if(vec.at(i+1).at(j+1)=='.'){
            rep(k,4){
                if(vec.at(i+1+mvx[k]).at(j+1+mvy[k])=='.'){
                    dp[i+1][j+1][i+1+mvx[k]][j+1+mvy[k]]=1;
                }
            }
        }
    }
    rep(m,h){
        rep(n,w){
            rep(i,h){
                rep(j,w){
                    rep(k,h){
                        rep(l,w){
                            dp[i+1][j+1][k+1][l+1]=min(dp[i+1][j+1][k+1][l+1],dp[i+1][j+1][m+1][n+1]+dp[m+1][n+1][k+1][l+1]);
                        }
                    }
                }
            }
        }
    }
    ll mx=0LL;
    rep(i,h)rep(j,w)rep(k,h)rep(l,w){
        mx=max(mx,(dp[i+1][j+1][k+1][l+1]<INF)?dp[i+1][j+1][k+1][l+1]:0);
    }
    cout << mx << endl;
}


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

from collections import deque

m,n = map(int,list(input().split()))

dirr = ((1,0),(0,1),(-1,0),(0,-1))


def valid(tmp,maze,seen):
    x = tmp[0]
    y = tmp[1]
    if x<0 or y<0 or x>=len(maze) or y>=len(maze[0]) or (tmp in seen) or maze[x][y] == '#':
        return False
    return True

def bfs(maze,i,j):    
    seen = {(i,j)}
    q = deque()
    q.append((i,j))

    tmpMoves = 0

    while q:
        gen = deque()
        while q:
            curr = q.pop()
            for d in dirr:
                x = curr[0]+d[0]
                y = curr[1]+d[1]
                tmp = (x,y)
                if valid(tmp,maze,seen):
                    gen.append(tmp)
                    seen.add(tmp)

        if not gen:break
        tmpMoves+=1        
        q = gen

    return tmpMoves
    

maze = [['.' for _ in range(n) ] for _ in range(m)]
for i in range(m):
    maze[i] = list(input())


max_moves = 0

for i in range(m):
    for j in range(n):
        if maze[i][j] == '#':continue
        ans = bfs(maze,i,j)        
        max_moves = max(ans,max_moves)

print(max_moves)


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
from collections import deque
^
1 error
Language: C++

#include<iostream>
#include<stdio.h>
#define MAXH 20
#define MAXW 20
#define INF 10000
using namespace std;
typedef long long ll;

int H,W;
char m[MAXH][MAXW];
int dd[MAXH][MAXW]; //コピー前
int d[MAXH][MAXW]; //コピー後
int ans;

void calc(int n, int h, int w) {
	if (h > 0) {
		if (m[h - 1][w] == '.' && d[h - 1][w] > n + 1) {
			d[h - 1][w] = n + 1;
			calc(n + 1, h - 1, w);
		}
	}
	if (h < H-1) {
		if (m[h + 1][w] == '.' && d[h + 1][w] > n + 1) {
			d[h + 1][w] = n + 1;
			calc(n + 1, h + 1, w);
		}
	}
	if (w > 0) {
		if (m[h][w - 1] == '.' && d[h][w - 1] > n + 1) {
			d[h][w - 1] = n + 1;
			calc(n + 1, h, w - 1);
		}
	}
	if (w < W-1) {
		if (m[h][w + 1] == '.' && d[h][w + 1] > n + 1) {
			d[h][w + 1] = n + 1;
			calc(n + 1, h, w + 1);
		}
	}
}

int maxd() {
	int r = 0;
	for (int i = 0; i<H; i++) {
		for (int j = 0; j < W; j++) {
			if (d[i][j]!=INF && d[i][j] > r) {
				r = d[i][j];
			}
		}
	}
	return r;
}

int main() {
	ans = 0;

	cin >> H >> W;
	for (int i = 0; i<H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> m[i][j];
			dd[i][j] = INF;
		}
	}
	
	for (int i = 0; i<H; i++) {
		for (int j = 0; j < W; j++) {
			if (m[i][j] == '.') {
				memcpy(d, dd, sizeof(dd));
				calc(0, i, j);
				if (maxd() > ans) {
					ans = maxd();
				}
			}			
		}
	}

	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:33: error: 'memcpy' was not declared in this scope
   68 |                                 memcpy(d, dd, sizeof(dd));
      |                                 ^~~~~~
a.cc:2:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #include<stdio.h>
Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
const int di[]={0,-1,0,1};
const int dj[]={-1,0,1,0};
int main(){
  ll h,w;
  cin>>h>>w;
  vstr ta(h);
  ll ans=0;
  rep(i,h) cin>>ta[i];
  rep(si,h) rep(sj,w){
    if(ta[si][sj]=='#') continue;
    vvll dist(h,vll(w,INF));
    queue<pll> q;
    auto j = [&](int i, int j, int x) {
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(pll(i,j)); // .emplace(i,j)
    };
    j(si,sj,0);
    while(!q.empty()){
      ll i=q.front().F;
      ll j=q.front().S;
      q.pop();
      rep(dir,4){
        ll ni=i+di[dir],nj=j+dj[i];
        if(ni<0||ni>=h||nj<0||nj>=w) continue;
        if(ta[ni][nj]=='#') continue;
        j(ni,nj,dist[i][j]+1);
      }
    }
    rep(i,h)rep(j,w){
      if(ta[i][j]=='#') continue;
      ans=max(ans,dist[i][j]);
    }
  }
  COUT(ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:10: error: 'j' cannot be used as a function
   64 |         j(ni,nj,dist[i][j]+1);
      |         ~^~~~~~~~~~~~~~~~~~~~
Language: Java

import java.io.*;
import java.util.*;

public class maze {
    static BufferedReader in;
    static int max = 0;

    public static void solve() throws IOException {
        Integer[] mn = nextArray(2);
        int m = mn[0];
        int n = mn[1];

        char[][] maze = new char[m][n];

        for (int i = 0; i < m; i++) {
            maze[i] = in.readLine().toCharArray();
        }

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (maze[i][j] == '#') continue;
                bfs(i, j, maze);
            }
        }

        System.out.println(max);


    }

    private static void bfs(int i, int j, char[][] maze) {
        Queue<List<Integer>> q = new LinkedList<>();
        q.add(Arrays.asList(i, j));
        Set<List<Integer>> visited = new HashSet<>();

        int moves = 0;
        while (!q.isEmpty()) {
            Queue<List<Integer>> next = new LinkedList<>();

            while (!q.isEmpty()) {
                List<Integer> curr = q.poll();
                int x = curr.get(0);
                int y = curr.get(1);



                visited.add(curr);
                List<Integer> t1 = (Arrays.asList(x+1,y));
                List<Integer> t2 =(Arrays.asList(x,y+1));
                List<Integer> t3 =(Arrays.asList(x-1,y));
                List<Integer> t4 =(Arrays.asList(x,y-1));

                if(valid(t1,maze,visited))next.add(t1);
                if(valid(t2,maze,visited))next.add(t2);
                if(valid(t3,maze,visited))next.add(t3);
                if(valid(t4,maze,visited))next.add(t4);


            }
            if(next.isEmpty())break;
            moves++;

            q = next;
        }

        max = Math.max(moves,max);

    }

    static boolean valid(List<Integer> curr, char[][] maze,Set<List<Integer>> visited){
        int x = curr.get(0);
        int y = curr.get(1);
        if (x < 0
                || y < 0
                || x >= maze.length
                || y >= maze[0].length
                || visited.contains(curr)
                || maze[x][y] == '#')
            return false;

        return true;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        solve();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(in.readLine().trim());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(in.readLine().trim());
    }

    static Integer[] nextArray(int n) throws IOException {
        StringTokenizer st = new StringTokenizer(in.readLine());
        Integer[] tmp = new Integer[n];
        for (int i = 0; i < tmp.length; i++) {
            tmp[i] = Integer.parseInt(st.nextToken());
        }

        return tmp;
    }

}



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

#include<bits/stdc++.h>
#include<queue>
#include<string>
#include<vector>
using namespace std;


long long H,W, INF= 1000000000;

vector<string> s;

//縦横の移動
long long dx[4] = { 0, 0, 1, -1 }, dy[4] = { 1, -1, 0, 0 };

//X,Yはスタート位置
long long BFS(long long X,long long Y){
    //キューの宣言(二次元)
    queue<pair<long long,long long>> q;
    //可変長配列の宣言(H×Wの配列)　INFは初期値　訪問用の記録変数
    vector<vector<long long> > Dist(H,vector<long long>(W,INF));

    q.push({X,Y});
    Dist[X][Y] = 0;
    while(!q.empty()){
        pair<long long , long long> P = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            //X座標、Y座標を±1 Pは現在地
            long long NX = P.first + dx[i], NY = P.second + dy[i];

            //次の訪問先が範囲内の場合
            if (0 <= NX && NX < H && 0 <= NY && NY < W) {
                //次の訪問先が移動可能の場合
                if(s[NX][NY] == '.' and Dist[NX][NY] == INF){

                    Dist[NX][NY] = Dist[P.first][P.second] + 1;
                    q.push({NX,NY});
                
                }
            }
        }
    }

    long long MAX = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++)
            if(Dist[i][j] != INF) MAX = max(MAX,Dist[i][j]); 
    }
    return MAX;
}


int main(){
    cin >> H >> W;
    s.resize(H);
	for (int i = 0; i < H; i++) cin >> s[i];
    long long ans = 0;
    for(int i = 0; i < H; i++ ){
        for(int j = 0; j < W; j++ ){
            if(s.at[i][j] == '.') ans = max(ans,BFS(i,j)); 
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:20: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   60 |             if(s.at[i][j] == '.') ans = max(ans,BFS(i,j));
      |                    ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int H, W;
string S;
vi va, vb;
int field[30][30];

void input() {
  cin >> H >> W;
  rep(i, 1, H) {
    ;
    ;
    rep(j, 1, W) {
      char c;
      cin >> c;
      field[i][j] = (c == '#' ? 0 : 1);
      ;
    }
  };
  ;
}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0};
void solve() {
  // rep(i, 1, H) {
  //   rep(j, 1, W) { cout << field[i][j] << " "; }
  //   cout << endl;
  // };
  // 400 とおり？

  // wfs?
  int ans = -1;
  rep(sth, 1, H) {
    ;
    rep(stw, 1, W) {  // wfs
      // set<pii> st;
      if (!field[sth][stw]) continue;
      int table[23][23];
      rep(i, 0, 22) { rep(j, 0, 22) table[i][j] = -1; }
      queue<pii> q;
      q.push(pii(sth, stw));
      table[sth][stw] = 0;
      while (q.size()) {
        // debug(q.size());
        pii qq = q.front();
        q.pop();
        // pii qq = q1.first;
        // st.insert(qq);

        int nowh = qq.first, noww = qq.second;
        // int cnt = q1.second;
        // ans = max(ans, cnt);
        chmax(ans, table[i][j]);
        rep(i, 0, 3) {
          int nexth = nowh + dh[i];
          int nextw = noww + dw[i];
          if (table[nexth][nextw] != -1) {
            continue;
          }
          if ((nexth < 1) || (nextw < 1) || (nexth > H) || (nextw > W)) {
            continue;
          } else {
            if (field[nexth][nextw] && (table[nexth][nextw] == -1)) {
              table[nexth][nextw] = table[nowh][noww] + 1;
              q.push(pii(nexth, nextw));

            } else {
              continue;
            }
          }
        }
      }
      // rep(i, 1, H) {
      //   rep(j, 1, W) {
      //     // debug(table[i][j]);
      //   }
      // }
      // debug2(sth, stw);
      // debug(ans);
    }
  }
  cout << ans << endl;

  ;
}
signed main() {
  input();
  solve();
  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:70:26: error: 'i' was not declared in this scope
   70 |         chmax(ans, table[i][j]);
      |                          ^
a.cc:13:32: note: in definition of macro 'chmax'
   13 | #define chmax(x, y) x = max(x, y)
      |                                ^
a.cc:70:29: error: 'j' was not declared in this scope
   70 |         chmax(ans, table[i][j]);
      |                             ^
a.cc:13:32: note: in definition of macro 'chmax'
   13 | #define chmax(x, y) x = max(x, y)
      |                                ^