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

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

#define col first
#define cn second

typedef pair<int, int> PR;

pair<int, int> puyo[10000+10] , tmp;

int sum;


int chek(int , /*PR[10000 + 10],*/ int ,int,int);


int main()
{
	int n;
	int pn=0;

	int a;

	int i;

	int sa=0;

	while (cin >> n, n != 0)
	{
		sa = 0;
		sum = n;
		pn = 0;

		cin >> a;
		puyo[pn].col = a;
		puyo[pn].cn = 1;


		for (i = 1; i < n; i++)
		{
			cin >> a;

			if (puyo[pn].col == a)
			{
				puyo[pn].cn++;
			}
			else
			{
				pn++;
				puyo[pn].col = a;
				puyo[pn].cn = 1;
			}
		}

		pn++;

		for (i = 1; i < pn - 1; i++)
		{

			if (puyo[i].cn == 3)
			{
				if (puyo[i + 1].col == puyo[i - 1].col && puyo[i + 1].cn + puyo[i - 1].cn >= 5)
				{
					//tmp = puyo[i + 1];
					//puyo[i + 1].cn--;

					sa = 3 + puyo[i + 1].cn + puyo[i - 1].cn;

					sum = min(sum, n - chek(pn, i - 2, i + 2, sa));
					//puyo[i + 1] = tmp;
				}
			}

			if( puyo[i+1].cn==1 && puyo[i].col == puyo[i+2].col )
			{
				if (puyo[i].cn + puyo[i + 2].cn >= 3)
				{
					//puyo[i + 1].cn--;
					sa = 1 + puyo[i].cn + puyo[i + 2].cn;

					sum = min(sum, n - chek(pn, i - 1, i + 3, sa));
					
				}
			}
/*
			if (puyo[i - 1].cn == 1 && puyo[i].col == puyo[i - 2].col)
			{
				if (puyo[i].cn + puyo[i - 2].cn >= 3)
				{
					//puyo[i - 1].cn--;
					sa = 1 + puyo[i].cn + puyo[i - 2].cn;

					sum = min(sum, n - chek(pn, i - 3, i + 1, sa));
				}
			}
		}
*/
		
		cout << sum << endl;
	}
	return 0;
}


int chek(int pn/*, PR tp[10000 + 10]*/, int go, int ba , int sa)
{
	if (puyo[go].col == puyo[ba].col && puyo[go].cn + puyo[ba].cn >= 4)
	{
		sa += puyo[go].cn + puyo[ba].cn;

		if (go - 1 >= 0 && ba + 1 < pn)
		{
			return chek(pn, go - 1, ba + 1, sa);
		}

	}

	return sa;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:107:1: error: a function-definition is not allowed here before '{' token
  107 | {
      | ^
a.cc:120:2: error: expected '}' at end of input
  120 | }
      |  ^
a.cc:19:1: note: to match this '{'
   19 | {
      | ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[10000];
int solve(int p, int n){
	int l = p-1, r = p+1, t;
	int s1, s2, ans = 0, f = 1;
	while(0 <= l){
		t = a[l];
		s1 = s2 = 0;
		if(f)s1 = 1, f = 0;
		//if(p == 5)printf("%d %d %d\n", l, r, t);
		while(0 <= l && a[l] == t){
			s1++;l--;
		}
		while(r < n && a[r] == t){
			s2++;r++;
		}
		if(s1+s2 >= 4){
			ans += s1+s2;
		}else break;
	}
	return n-ans;
}

int main(){
	int n, ans;
	while(){
	scanf("%d", &n);
		ans = INF;
		rep(i,n)scanf("%d", &a[i]);
		for(int i = 1;i < n-1;i++){
			ans = min(ans, solve(i, n));
		}
		if(ans == INF)printf("%d\n", n-1);
		else printf("%d\n", ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:15: error: expected primary-expression before ')' token
   39 |         while(){
      |               ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int check(vector<int> c)
{
  bool f=1;
  int cnt,i,j;
  vector<int>::iterator it,it2;
  while(f){
    cnt=f=0;
    it=it2=c.begin();
    for(it++;it!=c.end();it++){
      if(*it==*it2){
	cnt++;
      }else if(cnt>=3){
	for(;cnt>=0;cnt--){
	  it--;
	  it2=it;
	  c.erase(it2);
	}
	f=1;
	break;
      }else{
	cnt=0;
      }
      it2=it;
    }
  }
  return c.size();
}

int main()
{
  int N,i,j;
  int min,rest;
  while(cin>>N,N){
    vector<int> chara(N);
    for(i=0;i<N;i++)cin>>chara[i];
    min=INT_MAX;
    for(i=0;i<N;i++){
      for(j=1;j<=3;j++){
	if(chara[i]==j)continue;
	int t=chara[i];
	chara[i]=j;
	rest=check(chara);
	chara[i]=t;
	if(min>rest)min=rest;
      }
    }
    printf("%d\n",min);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: 'INT_MAX' was not declared in this scope
   39 |     min=INT_MAX;
      |         ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<vector>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++


class P
  attr_accessor :color, :size
  def initialize(color=0, size=0)
    @color = color
    @size  = size
  end
end

# [Pair] -> [Pair]
def compless1(v)
  res = [v[0]]

  v[1..(-1)].each do |e|
    if e.color == res[-1].color
      res[-1].size += e.size
    else
      res << e
    end
  end

  res
end

# [Int] -> [Pair]
def compless2(v)
  res = []

  v.each{ |e| res << P.new(e, 1) }

  compless1(res)
end



# main
while (n = gets.chomp.to_i) != 0
  chain = []
  n.times { chain << gets.chomp.to_i }

  best = 0
  n.times do |i|
    1.upto(3) do |color|
      buf = chain.dup
      buf[i] = color
      v = compless2(buf)

      cnt = 0
      loop do
        v = compless1(v)

        nv = v.reject{ |e| e.size >= 4 }

        break if v == nv
        cnt += v.inject(0) { |acc, e| acc + (e.size >= 4 ? e.size : 0) }
        v = nv

        break if v == []
      end

      best = [best, cnt].max
    end
  end

  puts (n - best)
end

Compiler output:
a.cc:5:5: error: stray '@' in program
    5 |     @color = color
      |     ^
a.cc:6:5: error: stray '@' in program
    6 |     @size  = size
      |     ^
a.cc:10:3: error: invalid preprocessing directive #[
   10 | # [Pair] -> [Pair]
      |   ^
a.cc:14:5: error: too many decimal points in number
   14 |   v[1..(-1)].each do |e|
      |     ^~~
a.cc:25:3: error: invalid preprocessing directive #[
   25 | # [Int] -> [Pair]
      |   ^
a.cc:36:3: error: invalid preprocessing directive #main
   36 | # main
      |   ^~~~
a.cc:3:17: error: found ':' in nested-name-specifier, expected '::'
    3 |   attr_accessor :color, :size
      |                 ^
      |                 ::
a.cc:3:3: error: 'attr_accessor' has not been declared
    3 |   attr_accessor :color, :size
      |   ^~~~~~~~~~~~~
a.cc:3:18: error: aggregate 'P color' has incomplete type and cannot be defined
    3 |   attr_accessor :color, :size
      |                  ^~~~~
a.cc:3:25: error: expected unqualified-id before ':' token
    3 |   attr_accessor :color, :size
      |                         ^
a.cc:31:12: error: expected constructor, destructor, or type conversion before '(' token
   31 |   compless1(res)
      |            ^
a.cc:41:3: error: 'best' does not name a type
   41 |   best = 0
      |   ^~~~
a.cc:54:9: error: expected unqualified-id before 'break'
   54 |         break if v == nv
      |         ^~~~~
a.cc:56:9: error: 'v' does not name a type
   56 |         v = nv
      |         ^
Language: Java

import java.util.*;

public class Main {

	static int n, m, ans;
	static int[] dx = {0,0,-1,1}, dy = {-1,1,0,0};
	static boolean[][] map, check;

	public static void dfs (int y, int x, int step) {
		max[y][x] = step;
		check[y][x] = true;
		boolean f = true;
		for (int i = 0; i < dx.length; i++) {
			int nextX = x + dx[i];
			int nextY = y + dy[i];
			if (0 <= nextX && nextX < m &&
				0 <= nextY && nextY < n &&
				map[nextY][nextX] &&
				!check[nextY][nextX]) {
				f = false;
				dfs(nextY,nextX,step + 1);
			}
		}
		if (f) ans = Math.max(step, ans);
		check[y][x] = false;
	}

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

		while (true) {
			ans = -1;
			m = sc.nextInt();
			n = sc.nextInt();
			if (m == 0 && n == 0) break;
			max = new int[n][m];
			map = new boolean[n][m];
			check = new boolean[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					map[i][j] = sc.nextInt() == 1;
					if (map[i][j]) {
						dfs(i,j,1);
						check = new boolean[n][m];
					}
				}
			}
			System.out.println(ans);
		}

	}
}

Compiler output:
Main.java:10: error: cannot find symbol
		max[y][x] = step;
		^
  symbol:   variable max
  location: class Main
Main.java:36: error: cannot find symbol
			max = new int[n][m];
			^
  symbol:   variable max
  location: class Main
2 errors
Language: Java

import java.io.*;
public class Main2 {

	static int n, m;
	static int[] dx = {0,0,-1,1}, dy = {-1,1,0,0};
	static boolean[][] map, check;

	public static int dfs(int y, int x) {
		int ret = 0;
		for (int d = 0 ; d < 4 ; d++) {
			int nextX = x + dx[d];
			int nextY = y + dy[d];
			if (0 <= nextX && nextX < m &&
					0 <= nextY && nextY < n &&
					map[nextY][nextX] &&
					!check[nextY][nextX]) {

					check[nextY][nextX] = true;
					ret = Math.max(dfs(nextY,nextX) + 1,ret);
					check[nextY][nextX] = false;
				}
		}
		return ret;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		while (true) {
			m = Integer.valueOf(s.readLine());
			n = Integer.valueOf(s.readLine());
			if (m == 0 && n == 0) break;
			map = new boolean[n][m];
			for (int i = 0 ; i < n ; i++) {
				String[] data = s.readLine().split(" ");
				for (int j = 0 ; j < m ; j++)
					map[i][j] = Integer.valueOf(data[j]) == 1;
			}
			int max = 0;
			for (int i = 0 ; i < n ; i++) {
				for (int j = 0 ; j < m ; j++) {
					if (map[i][j]) {
						check = new boolean[n][m];
						max = Math.max(max, dfs(i, j));
					}
				}
			}
			out.println(max);
		}
		out.flush();
	}
}

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

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

int InputIce[90][90];
int Ice[92][92];
int way=0;
int height; //???
int width;  //?¨?
int count=0,count_z=0;

void Check(int a,int b,int count_z){
    //a:height,b:width
    
    //?????????count++??????
    count_z++;
    //????????????
    Ice[a][b]=0;
    if(Ice[a-1][b]==1 && a-1>=0){
        Check(a-1,b,count_z);
    }
    if(Ice[a+1][b]==1 && a+1<=height+1){
        Check(a+1,b,count_z);
    }
    if(Ice[a][b-1]==1 && b-1>=0){
        Check(a,b-1,count_z);
    }
    if(Ice[a][b+1]==1 && b+1<=width+1){
        Check(a,b+1,count_z);
    }
    //?????£????°???????????????????
    Ice[a][b]=1;
    
    //????????§????????°???count?????\??????
    if(count<count_z) count=count_z;
    
}

int Main(void){
    
    int i,j,n,m;
    
    //?????¨?¨??????°??????????????????
    scanf("%d",&width);
    scanf("%d",&height);
    
    //?°??????¶??????????????????
    for(i=0;i<height;i++){
        for(j=0;j<width;j++){
            scanf("%d",&InputIce[i][j]);
        }
    }
    
    //?????????????????????????????????????????????0???????????§??????
    for(m=0;m<=width+1;m++) Ice[0][m]=0;
    for(n=0;n<=width+1;n++) Ice[height+1][n]=0;
    
    for(i=1;i<=height;i++){
        for(j=0;j<=width+1;j++){
            if(j==0 || j==width+1) Ice[i][j]=0;
            else Ice[i][j]=InputIce[i-1][j-1];
        }
    }
   
   //??????1?????¨???,Check?????????????????????????????????????????????
    for(i=1;i<=height;i++){
        for(j=1;j<=width;j++){
            if(Ice[i][j]==1) Check(i,j,0);
        }
    }
    
    //?????????count?????????
    printf("%d\n",count);
    return 0;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>

long tyousa(int,long,int,int,int*);

int main(void) {
	int map[92*92];
	int mapbak[92*92];
	int tate;
	int yoko;
	int x;
	int y;
	int i;
	long result;
	long resultbuf;
	while(1) {
		scanf("%d",&yoko);
		scanf("%d",&tate);
		if(yoko==0 && tate==0)break;
		for(y=0;y<92;y++) {
			for(x=0;x<92;x++) {
				mapbak[x+y*92]=0;
			}
		}
		for(y=1;y<tate+1;y++) {
			for(x=1;x<yoko+1;x++) {
				scanf("%d",&mapbak[x+y*92]);
			}
		}
		fclose(fp);
		result=0;
		for(y=1;y<tate+1;y++) {
			for(x=1;x<yoko+1;x++) {
				for(i=0;i<92*92;i++) {
					map[i]=mapbak[i];
				}
				resultbuf=tyousa(0,0,x,y,map);
				if(resultbuf>result)result=resultbuf;
			}
		}
		printf("%d\n",result);
	}
	return 0;
}

long tyousa(int dire,long kazu,int x,int y,int* map) {
	long result;
	long resultbuf;
	long kazubuf;
	int i;
	int mapbak[92*92];
	if(map[x+y*92]==0)return kazu;
	map[x+y*92]=0;
	for(i=0;i<92*92;i++) {
		mapbak[i]=map[i];
	}
	kazubuf=kazu+1;
	result=kazubuf;
	if(dire!=3) {
		resultbuf=tyousa(1,kazubuf,x-1,y,map);
		if(resultbuf>result)result=resultbuf;
	}
	for(i=0;i<92*92;i++) {
		map[i]=mapbak[i];
	}
	if(dire!=11) {
		resultbuf=tyousa(3,kazubuf,x+1,y,map);
		if(resultbuf>result)result=resultbuf;
	}
	for(i=0;i<92*92;i++) {
		map[i]=mapbak[i];
	}
	if(dire!=4) {
		resultbuf=tyousa(2,kazubuf,x,y-1,map);
		if(resultbuf>result)result=resultbuf;
	}
	for(i=0;i<92*92;i++) {
		map[i]=mapbak[i];
	}
	if(dire!=2) {
		resultbuf=tyousa(4,kazubuf,x,y+1,map);
		if(resultbuf>result)result=resultbuf;
	}
	for(i=0;i<92*92;i++) {
		map[i]=mapbak[i];
	}
	return result;
}

Compiler output:
main.c: In function 'main':
main.c:29:24: error: 'fp' undeclared (first use in this function)
   29 |                 fclose(fp);
      |                        ^~
main.c:29:24: note: each undeclared identifier is reported only once for each function it appears in
Language: C

int X,Y,T[90][90],r;
int R(int x,int y,int d){
	if(0<=x&&x<X&&0<=y&&y<Y&&T[y][x]){
		T[y][x]=0;
		R(x-1,y);
		R(x+1,y);
		R(x,y-1);
		R(x,y+1);
		T[y][x]=1;
	}else if(r<d)r=d;
}
main(){
	int i,j;
	for(;scanf("%d%d",&X,&Y),X;printf("%d\n",r)){
		for(j=0;j<Y;j++)for(i=0;i<X;i++)scanf("%d",T[j]+i);
		for(r=j=0;j<Y;j++)for(i=0;i<X;i++)R(i,j,0);
	}
}

Compiler output:
main.c: In function 'R':
main.c:5:17: error: too few arguments to function 'R'
    5 |                 R(x-1,y);
      |                 ^
main.c:2:5: note: declared here
    2 | int R(int x,int y,int d){
      |     ^
main.c:6:17: error: too few arguments to function 'R'
    6 |                 R(x+1,y);
      |                 ^
main.c:2:5: note: declared here
    2 | int R(int x,int y,int d){
      |     ^
main.c:7:17: error: too few arguments to function 'R'
    7 |                 R(x,y-1);
      |                 ^
main.c:2:5: note: declared here
    2 | int R(int x,int y,int d){
      |     ^
main.c:8:17: error: too few arguments to function 'R'
    8 |                 R(x,y+1);
      |                 ^
main.c:2:5: note: declared here
    2 | int R(int x,int y,int d){
      |     ^
main.c: At top level:
main.c:12:1: error: return type defaults to 'int' [-Wimplicit-int]
   12 | main(){
      | ^~~~
main.c: In function 'main':
main.c:14:14: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   14 |         for(;scanf("%d%d",&X,&Y),X;printf("%d\n",r)){
      |              ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int X,Y,T[90][90],r;
main.c:14:14: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   14 |         for(;scanf("%d%d",&X,&Y),X;printf("%d\n",r)){
      |              ^~~~~
main.c:14:14: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:14:36: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   14 |         for(;scanf("%d%d",&X,&Y),X;printf("%d\n",r)){
      |                                    ^~~~~~
main.c:14:36: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:14:36: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:14:36: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std; 
	int v[90][90];int memo[90][90];int a;
	void dfs(int x,int y,int count){
		a=max(a,count);
		memo[x][y]=3;
		//cout<<x<<""<<y<<"count "<<count<<endl;
		if(v[x-1][y]==1&&memo[x-1][y]!=3){//上
			
			dfs(x-1,y,count+1);
		}
		if(v[x+1][y]==1&&memo[x+1][y]!=3){//下
	
			dfs(x+1,y,count+1);
		}
		if(v[x][y+1]==1&&memo[x][y+1]!=3){//右
		
			dfs(x,y+1,count+1);
		}
		if(v[x][y-1]==1&&memo[x][y-1]!=3){//左
			
			dfs(x,y-1,count+1);
		}	
	
	}

int main(){
	int n,m;
	while(cin>>n>>m,n||m){
	int answer=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>v[i][j];
		}
	}
	
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(v[i][j]==0)continue;
			dfs(i,j,1);
			answer=max(a,answer);
			memset(memo,0,sizeof(memo));
		}
	}
	cout<<a<<endl;
	memset(v,1,sizeof(v));
	a=0;
	}
	return 0;
}

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

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

using namespace std;

int field[92][92] = { };
int vx[4] = { 1, -1, 0, 0 };
int vy[4] = { 0, 0, 1, -1 };
int ans = 0,ANSW=0;

int dfs(int X, int Y, int n){
	if (field[X][Y]==0)return n;
	field[X][Y] = 0;
	for (int i = 0; i < 4; i++){
		ans = max(ans, dfs(X + vx[i], Y + vy[i], n + 1));
	}
	field[X][Y] = 1;
	return ans;
}

int main(){
	while (1){
		int l, m;
		scanf_s("%d%d", &l, &m);
		for (int i = 0; i < l; i++){
			for (int j = 0; j < m; j++){
				cin>> field[i + 1][j + 1];
			}
		}
		for (int i = 0; i < l; i++){
			for (int j = 0; j < m; j++){
				if (field[i + 1][j + 1])ANSW = max(ANSW, dfs(i + 1, j + 1, 0));
			}
		}
		printf("%d\n", ANSW);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   26 |                 scanf_s("%d%d", &l, &m);
      |                 ^~~~~~~
      |                 scanf
Language: C++

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

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

int map[100][100];
int n, m;
int maxi;

void Search(int y, int x, int d)
{
	maxi = max(maxi, d);
	
	map[y][x] = 0;
	
//	bool f = false;
	
	for (int i = 0; i < 4; i++){
		if (map[y + dy[i]][x + dx[i]]){
			Search(y + dy[i], x + dx[i], d + 1);
//			f = true;
		}
	}
	
	map[y][x] = 1;
}

int main()
{
	while (scanf("%d %d", &m, &n), m + n){
		memset(map, 0, sizeof(map));
		maxi = 0;
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= m; j++){
				scanf("%d", &map[i][j]);
			}
		}
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				if (map[i][j]){
					Search(i, j, 1);
				}
			}
		}
		
		printf("%d\n", maxi);
	}
	
	return 0;
}

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

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;


bool kaku[90][90],kouri[90][90];

int dfs(int a,int b){
    int re=0;
    
    if(!kaku[a-1][b] && kouri[a-1][b]){
        kaku[a-1][b]=true;
        re=max(re,dfs(a-1,b));
    }
    if(!kaku[a][b-1] && kouri[a][b-1]){
        kaku[a][b-1]=true;
        re=max(re,dfs(a,b-1));
    }
    if(!kaku[a+1][b] && kouri[a+1][b]){
        kaku[a+1][b]=true;
        re=max(re,dfs(a+1,b));
    }
    if(!kaku[a][b+1] && kouri[a][b+1]){
        kaku[a][b+1]=true;
        re=max(re,dfs(a,b+1));
    }
    
    kaku[a][b]=false;
    return re+1;
}

void solve(int m,int n){
    int a,ans=0;
    
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            scanf("%d",&a);
            if(a==1)
                kouri[i][j]=true;
        }
    
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            ans=max(ans,dfs(i,j));
        }
    
    printf("%d\n",ans-1);
    
    return 0;
}

int main(){
    int m,n;
    while(1){
        scanf("%d%d",&m,&n);
        if(m+n==0)break;
        solve(m,n);
    }
}

Compiler output:
a.cc: In function 'void solve(int, int)':
a.cc:61:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   61 |     return 0;
      |            ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;

int dfs(int a,int b){
    int re=0;
    bool kaku[90][90]={0},kouri[90][90]={0};

    
    if(!kaku[a-1][b] && kouri[a-1][b]){
        kaku[a-1][b]=true;
        re=max(re,dfs(a-1,b));
    }
    if(!kaku[a][b-1] && kouri[a][b-1]){
        kaku[a][b-1]=true;
        re=max(re,dfs(a,b-1));
    }
    if(!kaku[a+1][b] && kouri[a+1][b]){
        kaku[a+1][b]=true;
        re=max(re,dfs(a+1,b));
    }
    if(!kaku[a][b+1] && kouri[a][b+1]){
        kaku[a][b+1]=true;
        re=max(re,dfs(a,b+1));
    }
    
    kaku[a][b]=false;
    return re+1;
}

void solve(int m,int n){
    int a,ans=0;
    
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            scanf("%d",&a);
            if(a==1)
                kouri[i][j]=true;
        }
    
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            ans=max(ans,dfs(i,j));
        }
    
    printf("%d\n",ans-1);
    
    return;
}

int main(){
    int m,n;
    while(1){
        scanf("%d%d",&m,&n);
        if(m+n==0)break;
        solve(m,n);
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve(int, int)':
a.cc:50:17: error: 'kouri' was not declared in this scope
   50 |                 kouri[i][j]=true;
      |                 ^~~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;


bool kaku[90][90],kouri[90][90];

int dfs(int a,int b){
    int re=0;
    if(kaku[a-1][b] || !kouri[a-1][b]) return 0;
    kaku[a][b]=true;
    
    
    me=dfs(a-1,b);
    re=max(re,me);
    me=dfs(a,b-1)
    re=max(re,me);
    me=dfs(a,b+1)
    re=max(re,me);
    me=dfs(a+1,b)
    re=max(re,me);
    
    kaku[a][b]=false;
    return re+1;
}

int main(){
    int m,n,a,ans,me;

    while(1){
        ans=0;
        
        scanf("%d%d",&m,&n);
        if(m+n==0)break;
        
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++){
                scanf("%d",&a);
                kouri[i][j]=(a==1);
            }
        
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++){
                me=dfs(i,j);
                ans=max(ans,me);
            }
        
        printf("%d\n",ans-1);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:26:5: error: 'me' was not declared in this scope; did you mean 're'?
   26 |     me=dfs(a-1,b);
      |     ^~
      |     re
Language: C++

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;


bool kaku[90][90],kouri[90][90];

int dfs(int a,int b){
    int re=0;
    if(kaku[a-1][b] || !kouri[a-1][b]) return 0;
    kaku[a][b]=true;
    
    
    me=dfs(a-1,b);
    re=max(re,me);
    me=dfs(a,b-1);
    re=max(re,me);
    me=dfs(a,b+1);
    re=max(re,me);
    me=dfs(a+1,b);
    re=max(re,me);
    
    kaku[a][b]=false;
    return re+1;
}

int main(){
    int m,n,a,ans,me;

    while(1){
        ans=0;
        
        scanf("%d%d",&m,&n);
        if(m+n==0)break;
        
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++){
                scanf("%d",&a);
                kouri[i][j]=(a==1);
            }
        
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++){
                me=dfs(i,j);
                ans=max(ans,me);
            }
        
        printf("%d\n",ans-1);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:26:5: error: 'me' was not declared in this scope; did you mean 're'?
   26 |     me=dfs(a-1,b);
      |     ^~
      |     re
Language: C++

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


int d0,d1,d2,d3,dmax,x,y;
int board[92][92];

int Search(x, y){
	if(board[x][y]==0) return 0;
	board[x][y]=0;
	d0=Search((x-1),y);

	dmax=d0;

	d1=Search((x+1),y);

	if(dmax<d1) dmax=d1;

	d2=Search(x,(y-1));

	if(dmax<d2) dmax=d2;

	d3=Search(x,(y+1));

	if(dmax<d3) dmax=d3;
	board[x][y]=1;
	return dmax+1;
}

int main(void) {
	int max=0,m,n,i,j;
	scanf("%d\n%d",&m,&n);
	for (i=1;i<=m;i++){
		for(j=1;j<=n;j++){
		scanf("%d",&board[i][j]);
		}
	}
	for (i=1;i<=m;i++){
			for(j=1;j<=n;j++){
			int	r=Search(i,j);
			if	(max<r) max=r;
			}
		}


	printf("%d\n",max);
	return EXIT_SUCCESS;
}

Compiler output:
a.cc:8:16: error: expression list treated as compound expression in initializer [-fpermissive]
    8 | int Search(x, y){
      |                ^
a.cc:8:17: error: expected ',' or ';' before '{' token
    8 | int Search(x, y){
      |                 ^
a.cc: In function 'int main()':
a.cc:40:41: error: 'Search' cannot be used as a function
   40 |                         int     r=Search(i,j);
      |                                   ~~~~~~^~~~~
Language: C++

10
10
1 1 0 0 0 1 0 0 1 1
1 0 0 0 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0
1 0 0 0 1 1 0 1 0 1
0 0 1 1 0 0 0 1 1 1
0 1 1 0 1 0 1 0 0 0
0 1 1 1 0 0 0 1 1 0
1 0 1 0 1 1 0 1 1 0
0 0 0 1 0 0 1 0 0 0
0 0 0 0 0 1 0 0 1 1

Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 10
      | ^~
Language: C++

#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int m, n;
bool tront[90][90];

int dfs(int y, int x) {
	int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
	int rep = 0;

	tront[ny][nx] = false;
	REP(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (! (nx >= 0 && nx < m && ny >= 0 && ny < n)) continue;
		if (! tront[ny][nx]) continue;
		tront[ny][nx] = false;
		rep = max(rep, dfs(ny, nx));
		tront[ny][nx] = true;
	}
	return rep + 1;
}


int main() {
	while (true) {
		int ans = 0;
		cin >> m >> n;
		if (n == 0 && m == 0) break;
		REP(i, n) REP(j, m) cin >> tront[i][j];

		REP(i, n) REP(j, m) if (tront[i][j])
			ans = max(ans, dfs(i, j));

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

Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:15:15: error: 'ny' was not declared in this scope; did you mean 'dy'?
   15 |         tront[ny][nx] = false;
      |               ^~
      |               dy
a.cc:15:19: error: 'nx' was not declared in this scope; did you mean 'dx'?
   15 |         tront[ny][nx] = false;
      |                   ^~
      |                   dx
Language: C++

#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <utility>
#define INF 1000000000
using namespace std;
typedef pair<int, int> pa;
typedef pair<int, pa> pp;

int M, N;
int ary[100][100], dp[100][100];
bool tay[100][100];
int dxy[5] = { 0,1,0,-1,0 };

int dfs(int dis,int y, int x) {
	tay[y][x] = true;
	int res = dis;
	for (int i = 0; i < 4; i++) {
		int yy = y + dxy[i];
		int xx = x + dxy[i + 1];
		if (1 <= yy&&yy <= N && 1 <= xx&&axx <= M && (!tay[yy][xx]) && (ary[yy][xx])) {
			res = max(res, dfs(dis + 1, yy, xx));
		}
	}
	tay[y][x] = false;
	return res;
}

int solve(int y, int x) {
	if (ary[y][x] == 0) {
		return 0;
	}
	for (int i = 1; i <= N; i++) fill(tay[i], tay[i] + M + 1, false);
	return dfs(1, y, x);
}


int main() {
	while (true) {
		cin >> M >> N;
		if (M == 0 && N == 0) break;
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= M; j++) {
				cin >> ary[i][j];
				dp[i][j] = INF;
			}
		}
		int res = 0;
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= M; j++) {
				res = max(res,solve(i, j));
			}
		}
		cout << res << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:22:50: error: 'axx' was not declared in this scope; did you mean 'xx'?
   22 |                 if (1 <= yy&&yy <= N && 1 <= xx&&axx <= M && (!tay[yy][xx]) && (ary[yy][xx])) {
      |                                                  ^~~
      |                                                  xx
Language: C++

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
int InputIce[90][90];
int Ice[92][92];
int way=0;
int height; //???
int width;  //??¨?
int count=0,count_z=0;
 
void Check(int a,int b,int count_z){
    //a:height,b:width
     
    //?????????count++??????
    count_z++;
    //????????????
    Ice[a][b]=0;
    if(Ice[a-1][b]==1 && a-1>=0){
        Check(a-1,b,count_z);
    }
    if(Ice[a+1][b]==1 && a+1<=height+1){
        Check(a+1,b,count_z);
    }
    if(Ice[a][b-1]==1 && b-1>=0){
        Check(a,b-1,count_z);
    }
    if(Ice[a][b+1]==1 && b+1<=width+1){
        Check(a,b+1,count_z);
    }
    //??????£?????°???????????????????
    Ice[a][b]=1;
     
    //?????????§?????????°???count?????\??????
    if(count<count_z) count=count_z;
     
}
 
int main(void){
     
    int i,j,n,m;
     
    //??????¨??¨???????°??????????????????
    scanf("%d",&width);
    scanf("%d",&height);
    if(width==0 && height==0) break;
     
    //??°???????¶??????????????????
    for(i=0;i<height;i++){
        for(j=0;j<width;j++){
            scanf("%d",&InputIce[i][j]);
        }
    }
     
    //?????????????????????????????????????????????0????????????§??????
    for(m=0;m<=width+1;m++) Ice[0][m]=0;
    for(n=0;n<=width+1;n++) Ice[height+1][n]=0;
     
    for(i=1;i<=height;i++){
        for(j=0;j<=width+1;j++){
            if(j==0 || j==width+1) Ice[i][j]=0;
            else Ice[i][j]=InputIce[i-1][j-1];
        }
    }
    
   //??????1??????¨???,Check?????????????????????????????????????????????
    for(i=1;i<=height;i++){
        for(j=1;j<=width;j++){
            if(Ice[i][j]==1) Check(i,j,0);
        }
    }
     
    //?????????count?????????
    printf("%d\n",count);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:31: error: break statement not within loop or switch
   46 |     if(width==0 && height==0) break;
      |                               ^~~~~
Language: C++

# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);


int d[90][90], dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 }, h, w;
int dfs(int x, int y) {
	int res = 0;
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&d[nx][ny]) {
			d[nx][ny] = 0;
			res = max(res, dfs(nx, ny) + 1);
			d[nx][ny] = 1;
		}
	}
	return res;
}

int main() {

	while (cin >> w >> h&&w&&h) {
		for (int i = 0; i < 90; i++)for (int j = 0; j < 90; j++)d[i][j] = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> d[i][j];
			}
		}
		int ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (d[i][j] == 1) {
					d[i][j] = 0;
					ans = max(ans, dfs(i, j) + 1);
					d[i][j] = 1;
				}
			}
		}
		cout << ans << endl;
	}
}

Compiler output:
a.cc:37:16: error: redefinition of 'int dx [4]'
   37 | int d[90][90], dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 }, h, w;
      |                ^~
a.cc:27:5: note: 'int dx [4]' previously defined here
   27 | int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
      |     ^~
a.cc:37:38: error: redefinition of 'int dy [4]'
   37 | int d[90][90], dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 }, h, w;
      |                                      ^~
a.cc:27:27: note: 'int dy [4]' previously defined here
   27 | int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
      |                           ^~
Language: C++


import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int w, h;
	boolean[][] map;
	int cnt;
	int max;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if( (w|h) == 0 ) break;
			map = new boolean[h+2][w+2];
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++)
				map[i][j] = sc.nextInt() == 1;
			max = 0;
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) {
				cnt = 0;
				if(map[i][j]) dfs(i, j);
			}
			System.out.println(max);
		}
	}
	int dx[] = {-1, 0, 1, 0};
	int dy[] = {0, -1, 0, 1};
	void dfs(int x, int y) {
		cnt++;
		max = max(cnt, max);
		map[x][y] = false;
		for(int i=0;i<4;i++) {
			if(map[ x+dx[i] ][y+dy[i]]) dfs(x+dx[i], y+dy[i]);
		}
		map[x][y] = true;
		cnt--;
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import static java.lang.Math.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import static java.util.Arrays.*;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class Main {
      | ^~~~~~
Language: C++

#include<cstdio>
#include<stack>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

int cell[100][100];
int dx[] = {1, 0,  0, -1};
int dy[] = {0, 1, -1,  0};
int n,m;
int ans;

void debug(){
	puts("");
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			printf("%s",cell[i][j]?"□":"■");
		}puts("");
	}
}

void func(int c, int x, int y){
	if(c>ans)ans=c;
//	debug();
//	printf("%d\n", &c);
	for(int i = 0; i < 4; i++){
		if(x+dx[i] = 0 && x+dx[i] =< n && y+dy[i] > 0 && y+dy[i]<=m && cell[x+dx[i]][y+dy[i]]){
			cell[x][y]=0;
			func(c+1,x+dx[i], y+dy[i]);
			cell[x][y]=1;
		}
	}
}


int main(void){
	while(scanf("%d%d", &m, &n),m){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				scanf("%d", &cell[i][j]);
			}
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(cell[i][j])func(1, i, j);
			}
		}
		
		
		printf("%d\n", ans);
		ans=0;
	}
	return 0;
	
}

Compiler output:
a.cc: In function 'void func(int, int, int)':
a.cc:31:44: error: expected primary-expression before '<' token
   31 |                 if(x+dx[i] = 0 && x+dx[i] =< n && y+dy[i] > 0 && y+dy[i]<=m && cell[x+dx[i]][y+dy[i]]){
      |                                            ^
Language: C++

/*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/
int Field[91][91];
bool Visited[91][91];
static int g_num = 0;
static int g_max_num = 0;
/*****その他関数置き場*****/
void dfs(int sx,int sy){
	const int dx[] = {0,1,0,-1};
	const int dy[] = {-1,0,1,0};
	if(!Visited[sy][sx] && Field[sy][sx]){
		Visited[sy][sx] = true;
		for(int i=0;i<4;i++){
			g_num++;
			dfs(sx+dx[i],sy+dy[i]);
		}
	}
	g_num--;
	if(g_num > g_max_num)	g_max_num = g_num;
	return;
}
/*****main関数*****/
void main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	int height;
	int width;
	/*****処理部*****/
	while(1){
		g_max_num = 0;
		for(int k=0;k<91;k++){
			for(int r=0;r<91;r++){
				Visited[k][r] = false;
				Field[k][r] = 0;
			}
		}
		
		cin >> width >> height;
		if(width == 0 && height == 0)	break;
		for(int i=0;i<height;i++){
			for(int j=0;j<width;j++){
				cin >> Field[i+1][j+1];
			}
		}
		for(int i=0;i<=height;i++){
			for(int j=0;j<=width;j++){
				if(Field[i][j] == 1){
					for(int k=0;k<=height;k++){
						for(int r=0;r<=width;r++){
							Visited[k][r] = false;
						}
					}
					g_num = 1;
					dfs(j,i);
				}
			}
		}
		cout << g_max_num << endl;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
}

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

#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int,int> p;
int main(){
int x[90][90];
int y[90][90]={},max=0,themax=0,ax,ay,m,n;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
queue<p>que;
scanf("%d%d",&m,&n);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
scanf("%d",&x[i][j]);
}}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(x[i][j]==1){
	que.clear();
for(int f=0;i<n;i++){
for(int g=0;j<m;j++){
y[f][g]=10000;
}}
que.push(p(i,j));
y[i][j]=0;
while(que.size()){
p w=que.front();
que.pop();
for(int q=0;q<4;i++){
ax=w.first+dx[q];
ay=w.second+dy[q];
if(ax>=1 && ax<=n && ay>=1 &&ay<=m && y[ax][ay]==10000 && x[ax][ay]!=0){
y[ax][ay]=y[w.first][w.second]+1;
que.push(p(ax,ay));
}
}
}
if(themax<y[ax][ay]){themax=y[ax][ay];}
}}}
printf("%d\n",themax-10000);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:13: error: 'class std::queue<std::pair<int, int> >' has no member named 'clear'
   20 |         que.clear();
      |             ^~~~~
Language: C++

#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int,int> p;
int main(){
	while(1){
int x[90][90];
int y[90][90]={},max=0,themax=0,ax,ay,m,n;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
queue<p>que;
scanf("%d%d",&m,&n);
if(m==0) break;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
scanf("%d",&x[i][j]);
}}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(x[i][j]==1){
for(int f=0;i<n;i++){
for(int g=0;j<m;j++){
y[f][g]=10000;
}}
que.push(p(i,j));
y[i][j]=0;
while(que.size()){
p w=que.front();
que.pop();
for(int q=0;q<4;i++){
ax=w.first+dx[q];
ay=w.second+dy[q];
if(ax>=1 && ax<=n && ay>=1 &&ay<=m && y[ax][ay]==10000 && x[ax][ay]!=0){
y[ax][ay]=y[w.first][w.second]+1;
que.push(p(ax,ay));
}
}
}
if(themax<y[ax][ay]){themax=y[ax][ay];}
}}}
printf("%d\n",themax);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:2: error: expected '}' at end of input
   44 | }
      |  ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int,int> p;
int main(){

int x[90][90];
int y[90][90]={},max=0,themax=0,ax,ay,m,n;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
queue<p>que;
fscanf(infile,"%d%d",&m,&n);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
scanf("%d",&x[i][j]);
}}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(x[i][j]==1){
for(int f=0;f<n;f++){
for(int g=0;g<m;g++){
y[f][g]=10000;
}}
que.push(p(i,j));
y[i][j]=0;
while(que.size()){
p w=que.front();
que.pop();
for(int q=0;q<4;q++){
ax=w.first+dx[q];
ay=w.second+dy[q];
if(ax>=1 && ax<=n && ay>=1 &&ay<=m && y[ax][ay]==10000 && x[ax][ay]!=0){
y[ax][ay]=y[w.first][w.second]+1;
que.push(p(ax,ay));
}
}
}
if(themax<y[ax][ay]){themax=y[ax][ay];}
}}}
printf("%d\n",themax);

return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:8: error: 'infile' was not declared in this scope; did you mean 'inline'?
   13 | fscanf(infile,"%d%d",&m,&n);
      |        ^~~~~~
      |        inline
Language: C++

#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<int,int> p;
int main(){

int x[90][90];
int y[90][90]={},max=0,themax=0,ax,ay,m,n;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
queue<p>que;
fscanf(infile,"%d%d",&m,&n);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
scanf("%d",&x[i][j]);
}}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(x[i][j]==1){
for(int f=0;f<n;f++){
for(int g=0;g<m;g++){
y[f][g]=-10000;
}}
que.push(p(i,j));
y[i][j]=0;
while(que.size()){
p w=que.front();
que.pop();
for(int q=0;q<4;q++){
ax=w.first+dx[q];
ay=w.second+dy[q];
if(ax>=1 && ax<=n && ay>=1 &&ay<=m && y[ax][ay]==-10000 && x[ax][ay]!=0){
y[ax][ay]=y[w.first][w.second]+1;
que.push(p(ax,ay));
}
}
}
if(themax<y[ax][ay]){themax=y[ax][ay];}
}}}
printf("%d\n",themax);

return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:8: error: 'infile' was not declared in this scope; did you mean 'inline'?
   13 | fscanf(infile,"%d%d",&m,&n);
      |        ^~~~~~
      |        inline
Language: C++

#include<cstdio>
#include<cctype>
#include<iostream>
#include<algorithm>

using namespace std;

bool ice[100][100];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
int n,m;

int bre(int x,int y,int c);

int main(){
  int i,j;
  while(1){
    scanf("%d %d",&m,&n);
    if(!m && !n) break;
    memset(ice,false,sizeof(ice));
    for(i=1;i<=n;i++){
      for(j=1;j<=m;j++){
	int a;
	scanf("%d", &a);
	if(a) ice[i][j] = true;
      }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= m; j++){
	if(ice[i][j]){
	  ice[i][j] = false;
	  ans = max(ans,bre(i,j,1));
	  ice[i][j] = true;
	}
      }
    }
    cout << ans << endl;
  }
}

int bre(int x,int y,int c){
  int ret = c;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(ice[nx][ny]){
      ice[nx][ny] = false;
      ret = max(ret,bre(nx,ny,c+1));
      ice[nx][ny] = true;
    }
  }
  return ret;
}

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

#include<cstdio>
#include<cctype>
#include<iostream>
#include<algorithm>

using namespace std;

bool ice[100][100];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
int n,m;

int bre(int x,int y,int c){
  int ret = c;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(ice[nx][ny]){
      ice[nx][ny] = false;
      ret = max(ret,bre(nx,ny,c+1));
      ice[nx][ny] = true;
    }
  }
  return ret;
}

int main(){
  int i,j;
  while(1){
    scanf("%d %d",&m,&n);
    if(!m && !n) break;
    memset(ice,false,sizeof(ice));
    for(i=1;i<=n;i++){
      for(j=1;j<=m;j++){
	int a;
	scanf("%d", &a);
	if(a) ice[i][j] = true;
      }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= m; j++){
	if(ice[i][j]){
	  ice[i][j] = false;
	  ans = max(ans,bre(i,j,1));
	  ice[i][j] = true;
	}
      }
    }
    cout << ans << endl;
  }
}

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

#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

bool ice[100][100];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
int n,m;

int bre(int x,int y,int c){
  int ret = c;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(ice[nx][ny]){
      ice[nx][ny] = false;
      ret = max(ret,bre(nx,ny,c+1));
      ice[nx][ny] = true;
    }
  }
  return ret;
}

int main(void){
  int i,j;
  while(1){
    scanf("%d %d",&m,&n);
    if(!m && !n) break;
    memset(ice,false,sizeof(ice));
    for(i=1;i<=n;i++){
      for(j=1;j<=m;j++){
	int a;
	scanf("%d", &a);
	if(a) ice[i][j] = true;
      }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= m; j++){
	if(ice[i][j]){
	  ice[i][j] = false;
	  ans = max(ans,bre(i,j,1));
	  ice[i][j] = true;
	}
      }
    }
    cout << ans << endl;
  }
}

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

#include <iostream>
#include <stack>
using namespace std;
int main(){
int m;
int n;
int b;
int c;
int h;//現在の割った氷
int i;//割った氷の最高
int j;
int k;
while(cin >>m>>n){
if(m==0&&n==0){break;}
int a[n][m];
int g[n][m];//氷が残っているか
b=0;
while(b<n){
c=0;
while(c<m){
cin >>a[b][c];
g[b][c]=a[b][c];
c=c+1;}
b=b+1;}
stack<int> d;//nの値
stack<int> e;//mの値
stack<int> f;//次進む経路0上1下2左3右
i=0;
b=0;
while(b<n){
c=0;
while(c<m){
d.push(b);
e.push(c);
f.push(1);
h=1;
k=0;
while(h!=0){
if(f.top()==0&&d.top()!=0&&g[d.top()-1][e.top()]==1&&k==0){d.push(d.top()-1); e.push(e.top()); f.push(0); g[d.top()][e.top()]=0; h=h+1;}
else if(f.top()==1&&d.top()!=n&&g[d.top()+1][e.top()]==1&&k==0){d.push(d.top()+1); e.push(e.top()); f.push(0); g[d.top()][e.top()]=0; h=h+1;}
else if(f.top()==2&&d.top()!=0&&g[d.top()][e.top()-1]==1&&k==0){d.push(d.top()); e.push(e.top()-1); f.push(0); g[d.top()][e.top()]=0; h=h+1;}
else if(f.top()==3&&d.top()!=m&&g[d.top()][e.top()+1]==1&&k==0){d.push(d.top()); e.push(e.top()+1); f.push(0); g[d.top()][e.top()]=0; h=h+1;}
k=0;
else if(f.top()!=3){j=f.top(); f.pop(); f.push(j+1);}
else{g[d.top()][e.top()]=1; h=h-1; d.pop(); e.pop(); f.pop(); k=1;}
if(h>i){i=h;}
}
c=c+1;}
b=b+1;}
cout <<i<<endl;}}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:1: error: 'else' without a previous 'if'
   44 | else if(f.top()!=3){j=f.top(); f.pop(); f.push(j+1);}
      | ^~~~
Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int solve(int x, int y, int w, int h, vector<vector<int> > f)
{
int ans = 0;

if(f[x][y] == 0)
return 0;

f[x][y] = 0;

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

for(int i = 0; i < 4; ++i) {
int nx = dx[i] + x;
int ny = dy[i] + y;
if(nx < 0 || ny < 0 || nx >= w || ny >= h)
continue;
int tmp = solve(nx, ny, w, h, f);
ans = max(ans, tmp);
}

f[x][y] = 1;

return ans + 1;
}

int main()
{
while(true) {
int w, h;
vector<vector<int> f;
scanf("%d%d", &w, &h);
if(w == 0)
break;
f.resize(w);
for(int i = 0; i < w; ++i)
f[i].resize(h);
for(int y = 0; y < h; ++y) {
for(int x = 0; x < w; ++x)
scanf("%d", &f[x][y]);
}
int ans = 0;
for(int x = 0; x < w; ++x) {
for(int y = 0; y < h; ++y)
ans = max(ans, solve(x, y, w, h, f));
}
printf("%d\n", ans);
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:20: error: template argument 1 is invalid
   36 | vector<vector<int> f;
      |                    ^
a.cc:36:20: error: template argument 2 is invalid
a.cc:40:1: error: 'f' was not declared in this scope
   40 | f.resize(w);
      | ^