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

/*
Á·Ï°Ìâ£ºProperty Distribution_AOJ 0118
*/
#include <cstdio>
using namespace std;

char maze[25][25];
int W, H;
int sx, sy;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int count;

void dfs1(int x, int y)
{
	for(int i=0; i<4; i++)
	{
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='@')
		{
			maze[nx][ny]='.';
			dfs1(nx,ny);
		}
	}
	return ;
}
void dfs2(int x, int y)
{
	for(int i=0; i<4; i++)
	{
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='*')
		{
			maze[nx][ny]='.';
			dfs2(nx,ny);
		}
	}
	return ;
}
void dfs3(int x, int y)
{
	for(int i=0; i<4; i++)
	{
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=0&&nx<W&&ny>=0&&ny<H&&maze[nx][ny]=='#')
		{
			maze[nx][ny]='.';
			dfs3(nx,ny);
		}
	}
	return ;
}

int main()
{
	while(scanf("%d%d", &H, &W)!=EOF)
	{
		count=0;
		if(W==0&&H==0)
			break;
		getchar();
		for(int i=0; i<W; i++)
			gets(maze[i]);
		for(int i=0; i<W; i++)
			for(int j=0; j<H; j++)
				if(maze[i][j]=='@')
				{
					sx=i;
					sy=j;
					count++;
					dfs1(sx, sy);
				}
				else if(maze[i][j]=='*')
				{
					sx=i;
					sy=j;
					count++;
					dfs2(sx, sy);
				}
				else if(maze[i][j]=='#')
				{
					sx=i;
					sy=j;
					count++;
					dfs3(sx, sy);
				}
		
		
		
		printf("%d\n", count);
		
	}
	
	return 0;
}


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

#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 105;
int h, w;
char Map[maxn][maxn];
int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
void Dfs(int x, int y, char c){
    Map[x][y] = '.';
    for(int i = 0; i < 4; i++){
        int xx = x + dir[i][0];
        int yy = y + dir[i][1];
        if(xx >= 0 && xx < h && yy >= 0 && yy < w && Map[xx][yy] == c){
            Dfs(xx, yy, c);
        }
    }
}
int main(){
    while(~scanf("%d%d",&h, &w)){
        if(!h + !w)) break;
        int ans = 0;
        for(int i = 0; i < h; i++)
            scanf("%s",Map[i]);
        for(int i = 0; i < h; i++){
            for(int j  = 0; j < h; j++){
                if(Map[i][j] != '.'){
                    Dfs(i, j, Map[i][j]);
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
    }

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:20:20: error: expected primary-expression before ')' token
   20 |         if(!h + !w)) break;
      |                    ^
Language: C++

#include <iostream>
using namespace std;


#define MaxH 20
#define MaxW 20
int W,H;
bool visited[MaxH][MaxW];
char A[MaxH][MaxW];
int dx[4] = {-1,0,1,0},dy[4] = {0,1,0,-1};

void dfs(int x, int y){
    for (int i = 0; i < 4; ++i) {
        int nextx = x + dx[i];
        int nexty = y + dy[i];

        if (nextx >=0 && nextx < H && nexty < W && nexty >= 0){
            if (!visited[nextx][nexty]){
                if ( A[x][y] == A[nextx][nexty]){
                    visited[nextx][nexty] = true;
                    dfs(nextx, nexty);
                }else
                    continue;
            }

        }
    }
}
int main(){
    while(cin>>W>>H && W && H) {
//        cin >> W >> H;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                cin >> A[i][j];
            }
        }
        int res = 0;

        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (!visited[i][j]) {
                    dfs(i, j);
                    res++;
                }
            }
        }
        cout << res;
    }
    return 0;



Compiler output:
a.cc: In function 'int main()':
a.cc:49:14: error: expected '}' at end of input
   49 |     return 0;
      |              ^
a.cc:29:11: note: to match this '{'
   29 | int main(){
      |           ^
Language: C++

#include <iostream>
using namespace std;


#define MaxH 20
#define MaxW 20
int W,H;
bool visited[MaxH][MaxW];
char A[MaxH][MaxW];
int dx[4] = {-1,0,1,0},dy[4] = {0,1,0,-1};

void dfs(int x, int y){
    for (int i = 0; i < 4; ++i) {
        int nextx = x + dx[i];
        int nexty = y + dy[i];

        if (nextx >=0 && nextx < H && nexty < W && nexty >= 0){
            if (!visited[nextx][nexty]){
                if ( A[x][y] == A[nextx][nexty]){
                    visited[nextx][nexty] = true;
                    dfs(nextx, nexty);
                }else
                    continue;
            }

        }
    }
}
int main(){
    while(cin>>W>>H && W!=0 && H!=0) {
//        cin >> W >> H;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                cin >> A[i][j];
            }
        }
        int res = 0;

        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (!visited[i][j]) {
                    dfs(i, j);
                    res++;
                }
            }
        }
        cout << res;
    }
    return 0;



Compiler output:
a.cc: In function 'int main()':
a.cc:49:14: error: expected '}' at end of input
   49 |     return 0;
      |              ^
a.cc:29:11: note: to match this '{'
   29 | int main(){
      |           ^
Language: C++

#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>

ssss
using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)

int h, w;
char ch[200][200];
int fl[200][200];

void dfs(int x, int y) {
	fl[x][y] = 0;
	int dx[] = { -1,0,1,0 };
	int dy[] = { 0,1,0,-1 };
	int nx, ny;
	printf("(%d,%d)", x, y);
	fori0(4) {
		
		nx = x + dx[i];
		ny = y + dy[i];
		if (0 <= nx && nx < h && 0 <= ny && ny < w&&fl[nx][ny]&&ch[x][y]==ch[nx][ny]) { dfs(nx, ny); }
	}
	return;

}

int main() {
	int co;
	


	while (1) {
		co = 0;
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		fori0(h)forj0(w) {
			cin >> ch[i][j];
			fl[i][j] = 1;
		}
		fori0(h)forj0(w) {
			if (fl[i][j]) {
				//fl[i][j] = 0;
				co++;
				dfs(i, j);
			}
		}
		printf("%d\n", co);
	}
	//system("pause");
	return 0;
}


Compiler output:
a.cc:7:1: error: 'ssss' does not name a type
    7 | ssss
      | ^~~~
a.cc: In function 'int main()':
a.cc:43:17: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   43 |                 cin >> h >> w;
      |                 ^~~
      |                 std::cin
In file included from a.cc:3:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: C++

#include <iostream>
#include <cstdio>
#include <queue>
#include <memory.h>

using namespace std;

const int LIM = 100;
char m[LIM][LIM];
bool vis[LIM][LIM + 1];
int R, C;

struct node {
    int r, c;
} DIR[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

void bfs(const int & r, const int & c, char ch) {
    queue<node> q;
    node crt = {r, c};
    vis[r][c] = true;
    q.push(crt);
    while (!q.empty()) {
        crt = q.front();
        q.pop();

        m[crt.r][crt.c] = '!';

        node next;
        for (int i = 0; i < 4; i++) {
            next.r = crt.r + DIR[i].r;
            next.c = crt.c + DIR[i].c;
            if (!vis[next.r][next.c] && m[next.r][next.c] == ch && next.r >= 0 && next.r < R && next.c >= 0 && next.c < C) {
                vis[next.r][next.c] = true;
                q.push(next);
            }
        }
    }
}

int main(void) {
    while (~scanf("%d%d", &R, &C) && R && C) {
        int cnt = 0;
        getchar();
        memset(vis, false, sizeof vis);
        for (int i = 0; i < R; i++)
            gets(m[i]);

        for (int i = 0; i < R; i++)
            for (int j = 0; j < C; j++)
                if (m[i][j] != '!') {
                    cnt++;
                    bfs(i, j, m[i][j]);
                }
        printf("%d\n", cnt);
    }
    return 0;
}


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


#include<iostream>
#include<cstdio>

using namespace std;

const int maxn=110;
int next[][2]={{0,1},{1,0},{0,-1},{-1,0}};
int h,w;
char s[maxn][maxn];

int safe(int row,int col)
{
	return row<h&&row>=0&&col<w&&col>=0;	
}

void dfs(int row,int col)
{
	char c=s[row][col];
	s[row][col]='.';
	for(int i=0;i<4;i++){
		int x=row+next[i][0];
		int y=col+next[i][1];
		if(safe(x,y)&&s[x][y]==c){
			dfs(x,y);
		}
	}	
	return ;	
}

int main()
{
	while(scanf("%d%d",&h,&w)!=EOF){
		if(h==0&&w==0){
			break;
		}else{
			for(int i=0;i<h;i++){
				scanf("%s",s[i]);
			}
			/*for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					printf("%c",s[i][j]);
				}
				printf("\n");
			}*/
			int ans=0;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(s[i][j]!='.'){
						ans++;
						dfs(i,j);
					}					
				}
			}
			printf("%d\n",ans);
		}		
	}
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:22:27: error: reference to 'next' is ambiguous
   22 |                 int x=row+next[i][0];
      |                           ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int next [4][2]'
    8 | int next[][2]={{0,1},{1,0},{0,-1},{-1,0}};
      |     ^~~~
a.cc:23:27: error: reference to 'next' is ambiguous
   23 |                 int y=col+next[i][1];
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int next [4][2]'
    8 | int next[][2]={{0,1},{1,0},{0,-1},{-1,0}};
      |     ^~~~
Language: C++

#include<bits./stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i<k,i++)
int H,W;
char m[102][102];
int dx[4]={1,0,-1,0}
int dy[4]=(0,1,0,-1)
void DFS(int x,int y,char c){
  if(m[x][y]!='c')break;
  m[x][y]='.';
  rep(i,0.4){
    DFS(x+dx[i],y+dy[i],c);
  }
}
int main(){
  cin >>H>>W;
  while(H!=0){
    int count =0;
    rep(i,0,102)rep(j,0,102)m[i][j]='.';
    rep(i,1,H)rep(j,1,W)cin >>m[i][j];
    rep(i,1,H)rep(j,1,W){
      if(m[i][j]!='.'){
        DFS(i,j,m[i][j]);
        count++;
      }
    }
    cout << count<<endl;
    cin >> H>>W;
  }
  return 0;
}


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

#include <iostream>
using namespace std;

char F[102][102];

void DFS(int Y,int X,char c){
  if(F[Y][X]!=c){
    return;
  }

  F[Y][X] = c;

  DFS(Y-1,X  );
  DFS(Y-1,X+1);
  DFS(Y  ,X+1);
  DFS(Y+1,X+1);
  DFS(Y+1,X  );
  DFS(Y+1,X-1);
  DFS(Y  ,X-1);
  DFS(Y-1,X-1);
}


int main(){
  int N,M;
  cin >> N >> M;
  for(int y=1;y<=N;y++){
    for(int x=1;x<=M;x++){
      cin >> F[y][x];
    }
  }

  int cnt = 0;
  for(int y=1;y<=N;y++){
    for(int x=1;x<=M;x++){
      if(F[y][x]=='@'){
        cnt++;
        DFS(y,x,'@');
      }
    }
  }
  for(int y=1;y<=N;y++){
    for(int x=1;x<=M;x++){
      if(F[y][x]=='#'){
        cnt++;
        DFS(y,x,'#');
      }
    }
  }
  for(int y=1;y<=N;y++){
    for(int x=1;x<=M;x++){
      if(F[y][x]=='*'){
        cnt++;
        DFS(y,x,'*');
      }
    }
  }

  cout << cnt << endl;

  return 0;
}



Compiler output:
a.cc: In function 'void DFS(int, int, char)':
a.cc:13:6: error: too few arguments to function 'void DFS(int, int, char)'
   13 |   DFS(Y-1,X  );
      |   ~~~^~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int Y,int X,char c){
      |      ^~~
a.cc:14:6: error: too few arguments to function 'void DFS(int, int, char)'
   14 |   DFS(Y-1,X+1);
      |   ~~~^~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int Y,int X,char c){
      |      ^~~
a.cc:15:6: error: too few arguments to function 'void DFS(int, int, char)'
   15 |   DFS(Y  ,X+1);
      |   ~~~^~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int Y,int X,char c){
      |      ^~~
a.cc:16:6: error: too few arguments to function 'void DFS(int, int, char)'
   16 |   DFS(Y+1,X+1);
      |   ~~~^~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int Y,int X,char c){
      |      ^~~
a.cc:17:6: error: too few arguments to function 'void DFS(int, int, char)'
   17 |   DFS(Y+1,X  );
      |   ~~~^~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int Y,int X,char c){
      |      ^~~
a.cc:18:6: error: too few arguments to function 'void DFS(int, int, char)'
   18 |   DFS(Y+1,X-1);
      |   ~~~^~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int Y,int X,char c){
      |      ^~~
a.cc:19:6: error: too few arguments to function 'void DFS(int, int, char)'
   19 |   DFS(Y  ,X-1);
      |   ~~~^~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int Y,int X,char c){
      |      ^~~
a.cc:20:6: error: too few arguments to function 'void DFS(int, int, char)'
   20 |   DFS(Y-1,X-1);
      |   ~~~^~~~~~~~~
a.cc:6:6: note: declared here
    6 | void DFS(int Y,int X,char c){
      |      ^~~
Language: C++

int main(){
  while(1){
  int N,M;
  cin>>N>>M;
  if(N==0&&M==0){
    break;
  }
  for(int h=1;h<=N;h++){
    for(int w=1;w<=M;w++){
      cin>>F[h][w];
    }
  }
 
  int cnt=0;
  for(int h=1;h<=N;h++){
    for(int w=1;w<=M;w++){
      if(F[h][w]=='@'){
        cnt++;
        DFS(h,w,'@');
      }else if(F[h][w]=='#'){
        cnt++;
        DFS(h,w,'#');
      }else if(F[h][w]=='*'){
          cnt++;
          DFS(h,w,'*');
      }
    }
  }
  cout<<cnt<<endl;
}
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
    4 |   cin>>N>>M;
      |   ^~~
a.cc:10:12: error: 'F' was not declared in this scope
   10 |       cin>>F[h][w];
      |            ^
a.cc:17:10: error: 'F' was not declared in this scope
   17 |       if(F[h][w]=='@'){
      |          ^
a.cc:19:9: error: 'DFS' was not declared in this scope
   19 |         DFS(h,w,'@');
      |         ^~~
a.cc:22:9: error: 'DFS' was not declared in this scope
   22 |         DFS(h,w,'#');
      |         ^~~
a.cc:25:11: error: 'DFS' was not declared in this scope
   25 |           DFS(h,w,'*');
      |           ^~~
a.cc:29:3: error: 'cout' was not declared in this scope
   29 |   cout<<cnt<<endl;
      |   ^~~~
a.cc:29:14: error: 'endl' was not declared in this scope
   29 |   cout<<cnt<<endl;
      |              ^~~~
Language: C++

#include <iostream>
using namespace std;

char F[100][100];

void DFS(int H, int W, char c){
  if(F[H][W]!=c)
    return;

  F[H][W] = '.';

  DFS(H-1, W  ,c);
  DFS(H  , W+1,c);
  DFS(H+1, W  ,c);
  DFS(H  , W-1,c);
}

int main(){
  int N,M;
  cin >> N >> M;
  for(int y=1; y<=N; y++)
    for(int x=1; x<=M; x++)
      cin >> F[y][x];

  int cnt = 0;
  for(int y=1; y<=N; y++)
    for(int x=1; x<=M; x++)
      if(F[y][x]!='.'){
        cnt++;
        DFS(y, x, F[y][x]);
      }
  cout << cnt << endl;
}
while(true){
  int w,h;
  cin >> w >> h;
  if(w==0){
    break;
  }
}
  return 0;
}



Compiler output:
a.cc:34:1: error: expected unqualified-id before 'while'
   34 | while(true){
      | ^~~~~
a.cc:41:3: error: expected unqualified-id before 'return'
   41 |   return 0;
      |   ^~~~~~
a.cc:42:1: error: expected declaration before '}' token
   42 | }
      | ^
Language: C++

#include<iostream>
using namespace std;

char F[102][102];

void DFS(int y, int x, char a){#include<iostream>
using namespace std;

char F[102][102];

void DFS(int y, int x, char a){
  if(F[y][x]!=a){
    return;
  }
  F[y][x]='.';

  DFS(y-1,x,a);
  DFS(y,x+1,a);
  DFS(y+1,x,a);
  DFS(y,x-1,a);
}

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n==m==0){
      break;
    }
    for(int y=1; y<=n; y++){
      for(int x=1; x<=m; x++){
        cin >> F[y][x];
      }
    }

    int cnt=0;
    for(int y=1; y<=n; y++){
      for(int x=1; x<=m; x++){
        if(F[y][x]=='#'){
          cnt++;
          DFS(y,x,'#');
        }
        if(F[y][x]=='*'){
          cnt++;
          DFS(y,x,'*');
        }
        if(F[y][x]=='@'){
          cnt++;
          DFS(y,x,'@');
        }
      }
    }
    cout << cnt << endl;
    return 0;
  }
}

  if(F[y][x]!=a){
    return;
  }
  F[y][x]='.';

  DFS(y-1,x,a);
  DFS(y,x+1,a);
  DFS(y+1,x,a);
  DFS(y,x-1,a);
}

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n==m==0){
      break;
    }
    for(int y=1; y<=n; y++){
      for(int x=1; x<=m; x++){
        cin >> F[y][x];
      }
    }

    int cnt=0;
    for(int y=1; y<=n; y++){
      for(int x=1; x<=m; x++){
        if(F[y][x]=='#'){
          cnt++;
          DFS(y,x,'#');
        }
        if(F[y][x]=='*'){
          cnt++;
          DFS(y,x,'*');
        }
        if(F[y][x]=='@'){
          cnt++;
          DFS(y,x,'@');
        }
      }
    }
    cout << cnt << endl;
    return 0;
  }
}



Compiler output:
a.cc:6:32: error: stray '#' in program
    6 | void DFS(int y, int x, char a){#include<iostream>
      |                                ^
a.cc: In function 'void DFS(int, int, char)':
a.cc:6:33: error: 'include' was not declared in this scope
    6 | void DFS(int y, int x, char a){#include<iostream>
      |                                 ^~~~~~~
a.cc:6:49: error: expected primary-expression before '>' token
    6 | void DFS(int y, int x, char a){#include<iostream>
      |                                                 ^
a.cc:7:1: error: expected primary-expression before 'using'
    7 | using namespace std;
      | ^~~~~
a.cc:11:31: error: a function-definition is not allowed here before '{' token
   11 | void DFS(int y, int x, char a){
      |                               ^
a.cc:23:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   23 | int main(){
      |         ^~
a.cc:23:9: note: remove parentheses to default-initialize a variable
   23 | int main(){
      |         ^~
      |         --
a.cc:23:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:23:11: error: a function-definition is not allowed here before '{' token
   23 | int main(){
      |           ^
Language: C++

nclude<iostream>
using namespace std;

char f[102][102];
char cnt_c[1];

void DFS(int y,int x){
  if(f[y][x]=='.'||f[y][x]==0||f[y][x]!=cnt_c[0])return;
  if(f[y][x]==cnt_c[0]){
    f[y][x]='.';
  }
  DFS(y+1,x);
  DFS(y-1,x);
  DFS(y,x+1);
  DFS(y,x-1);
}

int main(){
  int H,W;
  while(cin>>H>>W){
     if(H==0&&W==0)return 0;
      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>f[i][j];
        }
      }
      int cnt=0;
      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
          if(f[i][j]=='@'||f[i][j]=='#'||f[i][j]=='*'){
            cnt_c[0]=f[i][j];
            DFS(i,j);
            cnt++;
          }
        }
      }
      cout<<cnt<<endl;
    }
}



Compiler output:
a.cc:1:1: error: 'nclude' does not name a type
    1 | nclude<iostream>
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:20:9: error: 'cin' was not declared in this scope
   20 |   while(cin>>H>>W){
      |         ^~~
a.cc:37:7: error: 'cout' was not declared in this scope
   37 |       cout<<cnt<<endl;
      |       ^~~~
a.cc:37:18: error: 'endl' was not declared in this scope
   37 |       cout<<cnt<<endl;
      |                  ^~~~
Language: C++

import java.util.Scanner;
import java.util.Queue;
import java.util.Stack;

public class Main {
	int H, W;
	char[][] map;
	int res;
	char tmp;
	char ringo = '@', kaki = '#', mikan = '*', non = '.';
	void deback() {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				System.out.print(map[i][j]);
			}
			System.out.println();
		}
		System.out.println();
	}
	void dfs(int y, int x) {
		if(y < 0 || x < 0 || y >= H || x >= W) return;
//		deback();
		if(tmp == map[y][x]) {
			map[y][x] = non;
			dfs(y, x+1);
			dfs(y+1, x);
			dfs(y, x-1);
			dfs(y-1, x);		
		}
	}

	void solve() {
		res = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(map[i][j] == '.') continue;
				tmp = map[i][j];
				dfs(i, j);
				res += 1;
//				deback();
			}
		}
		System.out.println(res);
	}
	void run() {
		
		Scanner scan = new Scanner(System.in);
		while(true) {
			H = scan.nextInt();
			W = scan.nextInt();
			if (H==0 && W==0) break;
			map = new char[H][];
			for(int i = 0; i < H; i++) {
				map[i] = scan.next().toCharArray();
			}
//			System.out.println(map[0][9]);
			solve();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}





Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Queue;
      | ^~~~~~
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 java.util.Stack;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
    5 | public class Main {
      | ^~~~~~
Language: C++

#include<iostream>
using namespace std;
#define LP(i,N) for(int i=0;i<N;i++)
#define MAX 100
int H,W;
char map[MAX+1][MAX+1];
int dx[]={ 0, 1, 0,-1};
int dy[]={-1, 0, 1, 0};
void dfs(int h,int w,char fruit){
	if(map[h][w]=='0')return ;

	fruit
	map[h][w]='0';
	LP(i,4){
		if(h+dy[i]<0||w+dx[i]<0||h+dy[i]>=W||w+dx[i]>=H||fruit!=map[h+dy[i]][w+dx[i]])continue;
		dfs(h+dy[i],w+dx[i],fruit);
	}
	return ;
}

int
main(){

	while(cin>>H>>W&&(H||W)){
		int count=0;
		LP(i,H){
			LP(j,W)cin>>map[i][j];
		}
		LP(i,H){
			LP(j,W)
			if(map[i][j]!='0'){
				count++;
				dfs(i,j,map[i][j]);
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, char)':
a.cc:12:14: error: expected ';' before 'map'
   12 |         fruit
      |              ^
      |              ;
   13 |         map[h][w]='0';
      |         ~~~
Language: C++

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

int farm[101][101];

void kubun(int k,int a,int b){
	farm[a][b]=0;
	if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
	if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
	if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
	if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
	
}
int main(void){
	char c[101][101];
	int a,b;
	int h,w;
	int ans=0;
	while(1){
		ans=0;
		memset(farm,0,sizeof(farm));
		cin >> h >> w;
		if(h==0 && w==0)break;
		for(b=0;b<w;b++){
			cin >> c[b];
			for(a=0;a<h;a++){
				if(c[b][a]=='@')farm[a][b]=1;
				if(c[b][a]=='#')farm[a][b]=2;
				if(c[b][a]=='*')farm[a][b]=3;
				
			}
		}
		for(b=0;b<w;b++){
			for(a=0;a<h;a++){
				if(farm[a][b]==0);
				else{
					ans++;
					kubun(farm[a][b],a,b); 
				}
			}
		}
		cout<< ans << endl;
	}
	return 0;
}

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

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

int farm[101][101];

void kubun(int k,int a,int b){
	farm[a][b]=0;
	if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
	if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
	if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
	if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
	return;
	
}
int main(void){
	char c[101][101];
	int a,b;
	int h,w;
	int ans=0;
	while(1){
		ans=0;
		memset(farm,0,sizeof(farm));
		cin >> h >> w;
		if(h==0 && w==0)break;
		for(b=0;b<w;b++){
			cin >> c[b];
			for(a=0;a<h;a++){
				if(c[b][a]=='@')farm[a][b]=1;
				if(c[b][a]=='#')farm[a][b]=2;
				if(c[b][a]=='*')farm[a][b]=3;
				
			}
		}
		for(b=0;b<w;b++){
			for(a=0;a<h;a++){
				if(farm[a][b]==0);
				else{
					ans++;
					kubun(farm[a][b],a,b); 
				}
			}
		}
		cout<< ans << endl;
	}
	return 0;
}

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

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

int farm[101][101];

void kubun(int k,int a,int b){
	farm[a][b]=0;
	if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
	if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
	if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
	if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
	return;
	
}
int main(){
	char c[101][101];
	int a,b;
	int h,w;
	int ans=0;
	while(1){
		ans=0;
		memset(farm,0,sizeof(farm));
		cin >> h >> w;
		if(h==0 && w==0)break;
		for(b=0;b<w;b++){
			cin >> c[b];
			for(a=0;a<h;a++){
				if(c[b][a]=='@')farm[a][b]=1;
				if(c[b][a]=='#')farm[a][b]=2;
				if(c[b][a]=='*')farm[a][b]=3;
				
			}
		}
		for(b=0;b<w;b++){
			for(a=0;a<h;a++){
				if(farm[a][b]==0);
				else{
					ans++;
					kubun(farm[a][b],a,b); 
				}
			}
		}
		cout<< ans << endl;
	}
	return 0;
}

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

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

int farm[101][101];

void kubun(int k,int a,int b){
	farm[a][b]=0;
	if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
	if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
	if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
	if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
	return;
	
}
int main(){
	char c[101][101];
	int a,b;
	int h,w;
	int ans=0;
	while(1){
		ans=0;
		memset(farm,0,sizeof(farm));
		cin >> h >> w;
		if(h==0 && w==0)break;
		for(b=0;b<w;b++){
			cin >> c[b];
			for(a=0;a<h;a++){
				if(c[b][a]=='@')farm[a][b]=1;
				if(c[b][a]=='#')farm[a][b]=2;
				if(c[b][a]=='*')farm[a][b]=3;
				
			}
		}
		for(b=0;b<w;b++){
			for(a=0;a<h;a++){
				if(farm[a][b]==0);
				else{
					ans++;
					kubun(farm[a][b],a,b); 
				}
			}
		}
		cout<< ans << "\n";
	}
	return 0;
}

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

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

int farm[101][101];

void kubun(int k,int a,int b){
	farm[a][b]=0;
	if(k==farm[a-1][b])kubun(farm[a-1][b],a-1,b);
	if(k==farm[a+1][b])kubun(farm[a+1][b],a+1,b);
	if(k==farm[a][b-1])kubun(farm[a][b-1],a,b-1);
	if(k==farm[a][b+1])kubun(farm[a][b+1],a,b+1);
	
}
int main(){
	char c[101][101];
	int a,b;
	int h,w;
	int ans=0;
	while(1){
		ans=0;
		memset(farm,0,sizeof(farm));
		scanf("%d %d",&h,&w);
		if(h==0 && w==0)break;
		for(b=0;b<h;b++){
			scanf("%s",c[b]);   
			for(a=0;a<w;a++){
				if(c[b][a]=='@')farm[a][b]=1;
				if(c[b][a]=='#')farm[a][b]=2;
				if(c[b][a]=='*')farm[a][b]=3;
				
			}
		}
		for(b=0;b<h;b++){
			for(a=0;a<w;a++){
				if(farm[a][b]==0);
				else{
					ans++;
					kubun(farm[a][b],a,b); 
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

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

int h,w;
string s[100];

void newland(int i, int j) {
  char t = s[i][j];
  s[i][j] = '.';
  if(j!=w-1 && t == s[i][j+1]) newland(i,j+1);
  if(i!=h-1 && t == s[i+1][j]) newland(i+1,j);
  if(j!=0 && t == s[i][j-1]) newland(i,j-1);
  if(i!=0 && t == s[i-1][j]) newland(i-1,j);
}

void solve() {
  int i,j;
  while(1) {
    int n=0
    cin >> h >> w;
    if(h==0) break;
    for(i=0 ; i<h ; i++) {
      cin >> s[i];
    }
    for(i=0 ; i<h ; i++) {
      for(j=0 ; j<w ; j++) {
	if(s[i][j]!='.') {
	  newland(i,j);
	  n++;
	}
      }
    }
    cout << n << endl;
  }
}

int main(void) {
  solve();
  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:22:5: error: expected ',' or ';' before 'cin'
   22 |     cin >> h >> w;
      |     ^~~
Language: C++

#include <cstdio>

#define N_MAX 100
#define M_MAX 100

int N, M;
char Field[N][M+1]

int main(void) {
    scanf("%d %d", &N, &M);
    int i, j;
    for(i = 0; i < N; i++) {
        scanf("%s", Field[i]);
    }
    scanf("%d %d", &i, &j);
    if(i == 0 && j == 0) return 1;

    int count = 0;
    for(i = 0; i < N; i++) {
        for(j = 0; j < M; j++) {
            if(Field[i][j] != '.') {
                solve(i, j);
                count++;
            }
        }
    }
    printf("%d", count);
    return 0;
}

void solve(int x, int y) {
    char tmp = Field[x][y];
    Field[x][y] = '.';

    int nx, ny;
    for(int i = -1; i <= 1; i++) {
        for(int j =-1; j<= 1; j++) {
            nx = x + i;
            ny = y + i;
            if(0 <= nx && nx < N && 0<= ny && ny < M && Field[nx][ny] == tmp) {
                solve(nx, ny);
            }
        }
    }
    return;
}

Compiler output:
a.cc:9:1: error: expected initializer before 'int'
    9 | int main(void) {
      | ^~~
a.cc: In function 'void solve(int, int)':
a.cc:32:16: error: 'Field' was not declared in this scope
   32 |     char tmp = Field[x][y];
      |                ^~~~~
Language: C++

#include <cstdio>

#define N_MAX 100
#define M_MAX 100

int N, M;
char Field[N][M+1];

int main(void) {
    scanf("%d %d", &N, &M);
    int i, j;
    for(i = 0; i < N; i++) {
        scanf("%s", Field[i]);
    }
    scanf("%d %d", &i, &j);
    if(i == 0 && j == 0) return 1;

    int count = 0;
    for(i = 0; i < N; i++) {
        for(j = 0; j < M; j++) {
            if(Field[i][j] != '.') {
                solve(i, j);
                count++;
            }
        }
    }
    printf("%d", count);
    return 0;
}

void solve(int x, int y) {
    char tmp = Field[x][y];
    Field[x][y] = '.';

    int nx, ny;
    for(int i = -1; i <= 1; i++) {
        for(int j =-1; j<= 1; j++) {
            nx = x + i;
            ny = y + i;
            if(0 <= nx && nx < N && 0<= ny && ny < M && Field[nx][ny] == tmp) {
                solve(nx, ny);
            }
        }
    }
    return;
}

Compiler output:
a.cc:7:16: error: size of array 'Field' is not an integral constant-expression
    7 | char Field[N][M+1];
      |               ~^~
a.cc:7:12: error: size of array 'Field' is not an integral constant-expression
    7 | char Field[N][M+1];
      |            ^
a.cc: In function 'int main()':
a.cc:22:17: error: 'solve' was not declared in this scope
   22 |                 solve(i, j);
      |                 ^~~~~
Language: C++

#include <cstdio>

#define N_MAX 100
#define M_MAX 100

int N, M;
char Field[N_MAX][M_MAX+1];

int main(void) {
    scanf("%d %d", &N, &M);
    int i, j;
    for(i = 0; i < N; i++) {
        scanf("%s", Field[i]);
    }
    scanf("%d %d", &i, &j);
    if(i == 0 && j == 0) return 1;

    int count = 0;
    for(i = 0; i < N; i++) {
        for(j = 0; j < M; j++) {
            if(Field[i][j] != '.') {
                solve(i, j);
                count++;
            }
        }
    }
    printf("%d", count);
    return 0;
}

void solve(int x, int y) {
    char tmp = Field[x][y];
    Field[x][y] = '.';

    int nx, ny;
    for(int i = -1; i <= 1; i++) {
        for(int j =-1; j<= 1; j++) {
            nx = x + i;
            ny = y + i;
            if(0 <= nx && nx < N && 0<= ny && ny < M && Field[nx][ny] == tmp) {
                solve(nx, ny);
            }
        }
    }
    return;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'solve' was not declared in this scope
   22 |                 solve(i, j);
      |                 ^~~~~
Language: C++

#include<iostream>
using namespace std;
void dfs(int x,int y,char z);
char a[100][100];
int ans = 0;
int main(){
    int h,w;
    while(cin>>h>>w,h){
        ans = 0;

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>a[i][j];
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(a[i][j]!='.')dfs(i,j,a[i][j]),ans++;
            }
        }
        cout<<ans<<endl;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                a[i][j] = '.';
            }
        }

    }


    return 0;
}
void dfs(int x,int y,char z){
    a[x][y] = '.';
    if(z==a[x][y+1]&&y+1<w)dfs(x,y+1,z);
    if(z==a[x+1][y]&&x+1<h)dfs(x+1,y,z);
    if(z==a[x][y-1]&&y-1>=0)dfs(x,y-1,z);
    if(z==a[x-1][y]&&x-1>=0)dfs(x-1,y,z);

    return;
}

Compiler output:
a.cc: In function 'void dfs(int, int, char)':
a.cc:35:26: error: 'w' was not declared in this scope
   35 |     if(z==a[x][y+1]&&y+1<w)dfs(x,y+1,z);
      |                          ^
a.cc:36:26: error: 'h' was not declared in this scope
   36 |     if(z==a[x+1][y]&&x+1<h)dfs(x+1,y,z);
      |                          ^
Language: C++

#include<algorithm>
#include<iostream>
#include<string.h>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
using namespace std;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double PI=acos(-1.0);
const int maxn=100010;
typedef __int64 ll;
char maze[150][150];
int n,m;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
void dfs(int x,int y)
{
    int i,nx,ny;
    char t=maze[x][y];
    maze[x][y]=0;
    for(i=0;i<4;i++)
    {
        nx=x+dx[i];
        ny=y+dy[i];
        if(nx>=0&&nx<n&&ny>=0&&ny<m&&maze[nx][ny]==t)
            dfs(nx,ny);
    }
}
int main()
{
    int i,j,ans;

    while(scanf("%d%d",&n,&m),n||m)
    {
        ans=0;
        for(i=0;i<n;i++)
            scanf("%s",maze[i]);
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                if(maze[i][j]!=0)
                {
                    ans++;
                    dfs(i,j);
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Compiler output:
a.cc:18:9: error: '__int64' does not name a type; did you mean '__int64_t'?
   18 | typedef __int64 ll;
      |         ^~~~~~~
      |         __int64_t
Language: C++

//-*-coding:utf-8-*-
//----------------------------------------------------------
// module: main
//----------------------------------------------------------
#include <algorithm>
#include <vector>
#include <deque>
#include <map>

#include <iostream>
#include <cstdio>

using namespace std;

const int MAX_S = 100+1;

int w;
int h;

char m[MAX_S][MAX_S]; // map
bool u[MAX_S][MAX_S]; // used

typedef pair<int, int> pos;

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

pos getnext(int i, pos p){
    p.first += dx[i];
    p.second += dy[i];
    return p;
}

void walk(int x, int y){
    vector<pos> s;
    s.push_back(pos(x, y));
    char tile = m[y][x];

    while(!s.empty()){
        pos p = s.back();
        s.pop_back();

        if(u[p.second][p.first]) continue;
        u[p.second][p.first] = true;

        for (int i = 0; i < 4; ++i)
            {
                pos next = getnext(i, p);
                if (m[next.second][next.first] != tile) continue;
                
                s.push_back(next);
            }
    }
}

void solve(){
    memset(u, 0, MAX_S*MAX_S);

    int count = 0;
    for (int i = 0; i < h; ++i)
        {
            for (int j = 0; j < w; ++j)
                {
                    if(u[i][j]) continue;
                    count ++;
                    walk(j, i);
                }
        }
    printf("%d\n", count);
};

int main(int argc, char *argv[])
{
    while(true){
        scanf("%d %d", &w, &h);
        if(w <= 0) break;
        for (int i = 0; i < h; ++i)
            {
                scanf("%s", m[i]);
            }
        solve();
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:57:5: error: 'memset' was not declared in this scope
   57 |     memset(u, 0, MAX_S*MAX_S);
      |     ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   11 | #include <cstdio>
  +++ |+#include <cstring>
   12 |
Language: C++

#include <cstdio>

using namespace std;

const int MAX_H = 101;
const int MAX_W = 101;
int H, W;
char blocks[MAX_H][MAX_W];

int init() {
	scanf("%d%d", &H, &W);

	if (H == 0 && W == 0) return -1;
	
	for (int i = 0; i < H; i++) {
		scanf("%s", blocks[i]);
	}
	
	return 0;
}

void fill(int row, int col) {
	char type = blocks[row][col];
	blocks[row][col] = ' ';
	
	int di[] = {1, -1, 0, 0};
	int dj[] = {0, 0, 1, -1};
	
	for (int k = 0; k < 4; k++) {
		int ti = i + di[k];
		int tj = j + dj[k];
		
		if (0 <= ti && ti < H && 0 <= tj && tj < W) {
			if (blocks[ti][tj] == type) {
				fill(row, col);
			}
		}
	}
}

void solve() {
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (blocks[i][j] != ' ') {
				fill(i, j);
				ans++;
			}
		}
	}
	printf("%d\n", ans);
}

int main() {
	while (!init()) {
		solve();
	}
}

Compiler output:
a.cc: In function 'void fill(int, int)':
a.cc:30:26: error: 'i' was not declared in this scope; did you mean 'ti'?
   30 |                 int ti = i + di[k];
      |                          ^
      |                          ti
a.cc:31:26: error: 'j' was not declared in this scope; did you mean 'tj'?
   31 |                 int tj = j + dj[k];
      |                          ^
      |                          tj
Language: C++

#include <iostream>

using namespace std;

const int MAX_H = 1000;
const int MAX_W = 1000;
char field[MAX_H][MAX_W];

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

void dfs(int i, int j) {
  char c = field[i][j];
  if (c == 0) return;
  field[i][j] = 0;  // mark as visited

  for (int k = 0; k < 4; k++) {
    int new_i = i + dy[k];
    int new_j = j + dx[k];
    if (field[new_i][new_j] == c) {
      dfs(new_i, new_j);
    }
  }
}

int main() {

  while (1) {
    int W, H;
    cin >> H >> W;
    if (W == 0 && H == 0) {
      break;
    }

    int ans = 0;

    memset(field, 0, MAX_W * MAX_H);
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        cin >> field[i][j];
      }
    }

    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        if (field[i][j]) {
          dfs(i, j);
          ans++;
        }
      }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: 'memset' was not declared in this scope
   37 |     memset(field, 0, MAX_W * MAX_H);
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 |
Language: C++

#include <iostream>
#include <cstdlib>

using namespace std;

const int MAX_H = 1000;
const int MAX_W = 1000;
char field[MAX_H][MAX_W];

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

void dfs(int i, int j) {
  char c = field[i][j];
  if (c == 0) return;
  field[i][j] = 0;  // mark as visited

  for (int k = 0; k < 4; k++) {
    int new_i = i + dy[k];
    int new_j = j + dx[k];
    if (field[new_i][new_j] == c) {
      dfs(new_i, new_j);
    }
  }
}

int main() {

  while (1) {
    int W, H;
    cin >> H >> W;
    if (W == 0 && H == 0) {
      break;
    }

    int ans = 0;

    memset(field, 0, MAX_W * MAX_H);
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        cin >> field[i][j];
      }
    }

    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        if (field[i][j]) {
          dfs(i, j);
          ans++;
        }
      }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:38:5: error: 'memset' was not declared in this scope
   38 |     memset(field, 0, MAX_W * MAX_H);
      |     ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdlib>
  +++ |+#include <cstring>
    3 |
Language: C++

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;

const int M = 186;

int n;
int m;
char g[M][M];
int dir[4][2] = {{0,-1},{0,1},{-1,0},{1,0}};

void dfs(int x,int y,char k)
{
	int i;
	int dx;
	int dy;
	for(i = 0 ;i < 4; i++)
	{
		dx = x+dir[i][0];
		dy = y+dir[i][1];
		if( 0<=dx < n && 0 <= dy < m && g[dx][dy] == k)
		{
			g[dx][dy] = 'b';
			dfs(dx,dy,k);
		}
	}
}

void solve()
{
	int i;
	int j;
	int count = 0;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		if(n == 0 && m == 0)
		{
			break;
		}
		count = 0;
		for(i=0;i<n;i++)
		{
			scanf("%s",g[i]);
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<m;j++)
			{
				if(g[i][j]!='b')
				{
					dfs(i,j,g[i][j]);
					count++;
				}
			}
		}
		cout<<count<<endl;
	}
}

int main()
{
	solve();
	return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:65:18: error: expected '}' at end of input
   65 |         return 0;
      |                  ^
a.cc:63:1: note: to match this '{'
   63 | {
      | ^
Language: Java

import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;
public class Main {
   static Scanner sc = new Scanner(System.in);
   static int h, w;
   static char fruitFarm;
   static int dx = {-1, 0, 1, 0};
   static int dy = {0, -1, 0, 1};
   static Deque<int> stack; 
   public static void main(String args){ 
      while (true) {
         h = sc.nextInt();
         w = sc.nextInt();
         if (h == 0 && w == 0) break;
         //fruitFarm???????????????
         fruitFarm = new char[h][w];
         for (int i = 0; i < h; i++) {
            String s = sc.next();
            for (int j = 0; j < w; j++) {
               fruitFarm[i][j] = s.charAt(j);
            }
         }
         int answer = 0;
         for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
               if (fruitFarm[i][j] != '.') {
                  stack = new ArrayDeque<int>();
                  stack.offerLast(new int{i, j});
                  //stack??????????????£?????????????????§??????????????????????¨???????????????????????????????????????£???
                  while (!stack.isEmpty()) {
                     int xy = stack.pollLast();
                     int x = xy[0];
                     int y = xy[1];
                     dfs(x, y);
                  }
                  answer++;
               }
            }
         }
         System.out.println(answer);
      }
   }
 
   static void dfs(int x, int y) {
      char target = fruitFarm[x][y];
      fruitFarm[x][y] = '.';
      //?§??????????4??????????????????
      for (int k = 0; k < 4; k++) {
         int nx = x + dx[k];
         int ny = y + dy[k];
         //nx??¨ny???????????????????????????????????????????¨??????????????????????????????????????????????
         if (target != '.' && nx >= 0 && nx <= h - 1 && ny >= 0 && ny <= w - 1 && fruitFarm[nx][ny] == target) {
            stack.offerLast(new int{nx, ny});
         }
      }
   }
}

Compiler output:
Main.java:29: error: '[' expected
                  stack.offerLast(new int{i, j});
                                         ^
Main.java:54: error: '[' expected
            stack.offerLast(new int{nx, ny});
                                   ^
2 errors
Language: C++

#include <queue>
#include <cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> G[20];
	int deg[20]={};
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].push_back(v);
		deg[v]++;
	}

	vector<int> ans;
	bool vis[20]={};
	while(count(vis,vis+n,false)>0){
		rep(u,n) if(!vis[u] && deg[u]==0) {
			vis[u]=true;
			rep(i,G[u].size()){
				int v=G[u][i];
				deg[v]--;
			}
			if(u!=1) ans.push_back(u);
		}
	}
	ans.push_back(1);

	rep(u,n) printf("%d%c",ans[u]+1,u<n-1?' ':'\n');

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: 'count' was not declared in this scope
   20 |         while(count(vis,vis+n,false)>0){
      |               ^~~~~
Language: C++

#include <bits/stdc++.h>


#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

using namespace std;

vector<int> ans, usd(22), g[22];

void dfs(int s){
	if(usd[s]) return;
	usd[s]=1;
	for(auto v: g[s]) if(!usd[v]) dfa(v);
	ans.push_back(s);

}


int main()
{
	
	int n,m;
	cin >> m >> n;
	rep(i,n){
		int x,y; cin >>x >>y;
		g[x-1].push_back(y-1);
	}
	rep(i,m) dfs(i);
	for(int i=ans.size()-1;i>=0;i--) printf("%d\n",ans[i]+1);
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:13:39: error: 'dfa' was not declared in this scope; did you mean 'dfs'?
   13 |         for(auto v: g[s]) if(!usd[v]) dfa(v);
      |                                       ^~~
      |                                       dfs