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

#include<iostream>
#include<string>

using namespace std;

string map[101];
int count=0;
int n,m;

void dfs(char c,int i,int j){
  
    s[i][j] = '.';
    if(i+1 < n && s[i+1][j] == c)
    {
        dfs(c,i+1,j);
    }
    if(i-1 >= 0 && s[i-1][j] == c)
    {
        dfs(c,i-1,j);
    }
    if(j+1 < m && s[i][j+1] == c)
    {
        dfs(c,i,j+1);
    }
    if(j-1 >= 0 && s[i][j-1] == c)
    {
        dfs(c,i,j-1);
    }
}

int main(){

  while(1){

    cin >> n >> m;
     {
       if(n == 0 && m == 0)
	 break;
 
       count = 0;
       rep(i,n) cin >> s[i];
         
       rep(i,n)
	 {
	   rep(j,m)
	     {
	       if(s[i][j] != '.')
		 {
		   dfs(s[i][j],i,j);
		   count++;
		 }
	     }
	 }
         
       cout << count << endl;
     }
  }
}
 


Compiler output:
a.cc: In function 'void dfs(char, int, int)':
a.cc:12:5: error: 's' was not declared in this scope
   12 |     s[i][j] = '.';
      |     ^
a.cc: In function 'int main()':
a.cc:41:12: error: 'i' was not declared in this scope
   41 |        rep(i,n) cin >> s[i];
      |            ^
a.cc:41:8: error: 'rep' was not declared in this scope
   41 |        rep(i,n) cin >> s[i];
      |        ^~~
Language: C++

#include <iostream>
#include <cstido>

using namespace std;

const int MAX = 100;

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

//INPUT
int H, W, res;
char garden[MAX][MAX];

void dfs(int x, int y, char c) {
	garden[x][y] = '.';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (garden[nx][ny] == c) dfs(nx, ny, c);
	}
	return ;
}

void solve() {
	res = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (garden[i][j] == '#') {
				dfs(i, j, '#');
				res++;
			}
			if (garden[i][j] == '*') {
				dfs(i, j, '*');
				res++;
			}
			if (garden[i][j] == '@') {
				dfs(i, j, '@');
				res++;
			}
		}
	} 
	cout<<res<<endl;
	//从不是'.'的地方 开始填充
}

int main() {
	while(2333) {
		//判断输入结束 
		cin>>H>>W;
		if (H * W == 0) return 0;
		
		//输入前重置garden
		memset(garden, '.', sizeof(garden)); 
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) 
			cin>>garden[i][j];
		}  
		solve();
	}
}




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

#include <iostream>
#include <cstdio>

using namespace std;

const int MAX = 100;

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

//INPUT
int H, W, res;
char garden[MAX][MAX];

void dfs(int x, int y, char c) {
	garden[x][y] = '.';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (garden[nx][ny] == c) dfs(nx, ny, c);
	}
	return ;
}

void solve() {
	res = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (garden[i][j] == '#') {
				dfs(i, j, '#');
				res++;
			}
			if (garden[i][j] == '*') {
				dfs(i, j, '*');
				res++;
			}
			if (garden[i][j] == '@') {
				dfs(i, j, '@');
				res++;
			}
		}
	} 
	cout<<res<<endl;
	//从不是'.'的地方 开始填充
}

int main() {
	while(2333) {
		//判断输入结束 
		cin>>H>>W;
		if (H * W == 0) return 0;
		
		//输入前重置garden
		memset(garden, '.', sizeof(garden)); 
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) 
			cin>>garden[i][j];
		}  
		solve();
	}
}




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


#include<cstdio>
int H, W;
char map[201][201];
int dx[4]{ 0, 0, 1, -1 };
int dy[4]{ 1, -1, 0, 0 };
int ans = 0;
void dfs(int x, int y,char ch)
{
	map[x][y] = '.';//把符号@，#，*其中一个替换成.。和poj1979很像，稍微改下1979的代码就行
	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&&map[nx][ny] ==ch)dfs(nx, ny, ch);
	}
}
int main()
{
	scanf("%d%d", &H, &W);
	while (getchar() != '\n')continue;
	while (W&&H)
	{
		ans = 0;
		for (int i = 0; i < H; i++)
			gets(map[i]);
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++){
				if (map[i][j] == '#'){ dfs(i, j, '#'); ans++; }
				else if (map[i][j] == '@'){ dfs(i, j, '@'); ans++; }
				else if (map[i][j] == '*'){ dfs(i, j, '*') ; ans++; }
			}
		}
		printf("%d\n", ans);
		scanf("%d%d", &H, &W);
		while (getchar() != '\n')continue;
	}

}


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


#include<cstdio>
int H, W;
char map[201][201];
int dx[4]{ 0, 0, 1, -1 };
int dy[4]{ 1, -1, 0, 0 };
int ans = 0;
void dfs(int x, int y,char ch)
{
	map[x][y] = '.';
	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&&map[nx][ny] ==ch)dfs(nx, ny, ch);
	}
}
int main()
{
	scanf("%d%d", &H, &W);
	while (getchar() != '\n')continue;
	while (W&&H)
	{
		ans = 0;
		for (int i = 0; i < H; i++)
			gets(map[i]);
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++){
				if (map[i][j] == '#'){ dfs(i, j, '#'); ans++; }
				else if (map[i][j] == '@'){ dfs(i, j, '@'); ans++; }
				else if (map[i][j] == '*'){ dfs(i, j, '*') ; ans++; }
			}
		}
		printf("%d\n", ans);
		scanf("%d%d", &H, &W);
		while (getchar() != '\n') continue;
	}

}


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

#include<cstdio>
int H, W;
char map[201][201];
int dx[4]{ 0, 0, 1, -1 };
int dy[4]{ 1, -1, 0, 0 };
int ans = 0;
void dfs(int x, int y,char ch)
{
	map[x][y] = '.';//把符号@，#，*其中一个替换成.。和poj1979很像，稍微改下1979的代码就行
	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&&map[nx][ny] ==ch)dfs(nx, ny, ch);
	}
}
int main()
{
	scanf("%d%d", &H, &W);
	while (getchar() != '\n')continue;
	while (W&&H)
	{
		ans = 0;
		for (int i = 0; i < H; i++)
			gets(map[i]);
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++){
				if (map[i][j] == '#'){ dfs(i, j, '#'); ans++; }
				else if (map[i][j] == '@'){ dfs(i, j, '@'); ans++; }
				else if (map[i][j] == '*'){ dfs(i, j, '*') ; ans++; }
			}
		}
		printf("%d\n", ans);
		scanf("%d%d", &H, &W);
		while (getchar() != '\n')continue;

	}
    return 0;
}




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

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int H, W;
vector<string> ts;
vector< vector<bool> > done;

void dfs(int y, int x) {
        if (done[y][x]) return;
        done[y][x] = true;

        for (int dx = -1; dx <= 1; dx++) {
                for (int dy = -1; dy <= 1; dy++) {
                        if (!(!dy ^ !dx)) continue;

                        int nx = x + dx;
                        int ny = y + dy;

                        if (ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
                        if (ts[y][x] != ts[ny][nx]) continue;

                        dfs(ny, nx);
                }
        }
}

int main(void) {
        while (cin >> H >> W, H) {
                ts = vector<string>(H);
                done = vector< vector<bool> >(H, vector<bool>(W));

                for (int y = 0; y < H; y++) cin >> ts[y];

                int cnt = 0;

                for (int y = 0; y < H; y++) {
                        for (int x = 0; x < W; x++) {
                                if (!done[y][x]) {
                                        dfs(y, x);
                                        cnt++;
                                }
                        }
                }

                cout << cnt << endl;
        }

        return 0;
}

~                     

Compiler output:
a.cc:80:2: error: expected class-name at end of input
   80 | ~
      |  ^
Language: C++

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

char area[200][200];

typedef pair<int, int> P;
#define x first
#define y second
/* struct P{
	int x, y;
};*/

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

int main()
{
	int w, h, area_sum;
	
	while (scanf("%d%d", &w, &h), w != 0){
		
		memset(area, 0, sizeof(area));
		
		area_sum = 0;
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++)scanf(" %c", &area[j][i]);
		}
		
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				if (area[j][i]){
					queue<P> que;
					que.push(P(j, i));
					while (!que.empty()){
						P st = que.front();
						que.pop();
						if (!area[st.x][st.y])continue;
						for (int i = 0; i < 4; i++){
							if (area[st.x][st.y] == area[st.x + dx[i]][st.y + dy[i]]){
								que.push(P(st.x + dx[i], st.y + dy[i]));
							}
						}
						area[st.x][st.y] = 0;
						
					}
					area_sum++;
				}
			}
		}
		
		printf("%d\n", area_sum);
	}
}

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

#include<iostream>
using namespace std;

char yard[102][102];
int ans=0;

void dfs(int x,int y,char c){
	if(yard[x][y]!=c) return;
    if(yard[x][y]==c) yard[x][y]='.';
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if((i==0||j==0)&&(i!=0||j!=0)){
				dfs(x+i,y+j,c);
			}
		}
	}
	return;
}
int main(){
	memset(yard,'.',sizeof(yard));
	int H,W;
	cin>>H>>W;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin>>yard[i][j];
		}
	}
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(yard[i][j]!='.'){
				dfs(i,j,yard[i][j]);
				ans++;
			}
		}
	}
	cin>>H>>W;
	cout<<ans<<endl;
}

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

#include<iostream>
using namespace std;

char yard[102][102];
int ans=0;

void dfs(int x,int y,char c){
	if(yard[x][y]!=c) return;
    if(yard[x][y]==c) yard[x][y]='.';
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if((i==0||j==0)&&(i!=0||j!=0)){
				dfs(x+i,y+j,c);
			}
		}
	}
	return;
}
int main(){
	memset(yard,'.',sizeof(yard));
	int H,W;
	cin>>H>>W;
	while(H!=0||W!=0){
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				cin>>yard[i][j];
			}
		}
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				if(yard[i][j]!='.'){
					dfs(i,j,yard[i][j]);
					ans++;
				}
			}
		}
		cout<<ans<<endl;
		ans==0;
		cin>>H>>W;
	}
	
}

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

#include<vector>

using namespace std;

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

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

bool tukattaka[100][100];
int h,w,count;//hはx　wはy

char sekai[100][100];

void func(int x,int y,char ki){
	tukattaka[x][y]=true;
	for(int i=0;i<4;i++){
		if(x+VECX[i]<w&&x+VECX[i]>=0&&y+VECY[i]<h&&y+VECY[i]>=0&&tukattaka[x+VECX[i]][y+VECY[i]]==false&&sekai[x+VECX[i]][y+VECY[i]]==ki){
			func(x+VECX[i],y+VECY[i],ki);
		}
	}
}

int main(){
	while(true){
		cin>>h>>w;
		if(h==0&&w==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>sekai[i][j];
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(!tukattaka[i][j]){
					func(i,j,sekai[i][j]);
					count++;
				}
			}
		}
		cout<<count<<endl;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				tukattaka[i][j]=false;
				sekai[i][j]=NULL;
			}
		}
		count=0;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: 'cin' was not declared in this scope
   25 |                 cin>>h>>w;
      |                 ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<vector>
  +++ |+#include <iostream>
    2 | 
a.cc:40:17: error: 'cout' was not declared in this scope
   40 |                 cout<<count<<endl;
      |                 ^~~~
a.cc:40:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:40:30: error: 'endl' was not declared in this scope
   40 |                 cout<<count<<endl;
      |                              ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<vector>
  +++ |+#include <ostream>
    2 | 
a.cc:44:45: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]
   44 |                                 sekai[i][j]=NULL;
      |                                             ^~~~
Language: C++

#include<vector>

using namespace std;

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

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

bool tukattaka[100][100];
int h,w,count;//hはx　wはy

char sekai[100][100];

void func(int x,int y,char ki){
	tukattaka[x][y]=true;
	for(int i=0;i<4;i++){
		if(x+VECX[i]<w&&x+VECX[i]>=0&&y+VECY[i]<h&&y+VECY[i]>=0&&tukattaka[x+VECX[i]][y+VECY[i]]==false&&sekai[x+VECX[i]][y+VECY[i]]==ki){
			func(x+VECX[i],y+VECY[i],ki);
		}
	}
}

int main(){
	while(true){
		std::cin>>h>>w;
		if(h==0&&w==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>sekai[i][j];
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(!tukattaka[i][j]){
					func(i,j,sekai[i][j]);
					count++;
				}
			}
		}
		std::cout<<count<<std::endl;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				tukattaka[i][j]=false;
				sekai[i][j]=0;
			}
		}
		count=0;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:22: error: 'cin' is not a member of 'std'
   25 |                 std::cin>>h>>w;
      |                      ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<vector>
  +++ |+#include <iostream>
    2 | 
a.cc:29:33: error: 'cin' was not declared in this scope
   29 |                                 cin>>sekai[i][j];
      |                                 ^~~
a.cc:29:33: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:40:22: error: 'cout' is not a member of 'std'
   40 |                 std::cout<<count<<std::endl;
      |                      ^~~~
a.cc:40:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:40:40: error: 'endl' is not a member of 'std'
   40 |                 std::cout<<count<<std::endl;
      |                                        ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<vector>
  +++ |+#include <ostream>
    2 |
Language: C++

import java.util.*;

public class Main{

Scanner sc=new Scanner(System.in);

int H=sc.nextInt();

int W=sc.nextInt();

String[][] k=new String[H][W];


for(int i=0;i<H;i++){

for(int j=0;j<W;j++){

k[i][j]=sc.next();

}

}

public static void main(String[] args){

int num=0;

for(int i=0;i<H;i++){

for(int j=0;j<W;j++){

if(k[i][j]!="."){

kukaku(k,i,j,H,W);

num++;

}

}

}

System.out.println(num);

}

public static void kukaku(int I,int J){

String p=k[I][J];

k[I][J]=".";

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

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

for(int i=0;i<4;i++){

if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){

kukaku(I+dx[i],J+dy[i]);

}

return;

}

}

}

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

import java.util.*;
 
public class Main{
 
public static void main(String[] args){
 
Scanner sc=new Scanner(System.in);
 
int H=sc.nextInt();
 
int W=sc.nextInt();
 
String[][] k=new String[H][W];
 
for(int i=0;i<H;i++){
 
for(int j=0;j<W;j++){
 
k[i][j]=sc.next();
 
}
 
}
 
int num=0;
 
for(int i=0;i<H;i++){
 
for(int j=0;j<W;j++){
 
if(k[i][j]!="."){
 
kukaku(k,i,j,H,W);
 
num++;
 
}
 
}
 
}
 
System.out.println(num);
 
}
 
public static void kukaku(String k[][],int I,int J,int h,int w){
 
String p=k[I][J];
 
k[I][J]=".";
 
int[] dx={-1,0,0,1};
 
int[] dy={0,-1,1,0};
 
for(int i=0;i<4;i++){
 
if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<h&&J+dy[i]>=0&&J+dy[i]<w){
 
kukaku(k,I+dx[i],J+dy[i],h,w);
 
}
 
 
}

return;
 
}
 
}

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

// Property Distribution
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	int h, w;
	char[][] field;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			h = sc.nextInt();
			w = sc.nextInt();
			if ((h | w) == 0)
				break;
			field = new char[h][];
			for (int i = 0; i < h; i++)
				field[i] = sc.next().toCharArray();
			int result = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (field[i][j] != '.') {
						result++;
						visit(i, j);
					}
				}
			}
			System.out.println(result);
		}
		sc.close();
	}

	void visit(int y, int x) {
		char c = field[y][x];
		Queue<P> queue = new ArrayDeque<P>();
		queue.add(new P(x, y));
		while (!queue.isEmpty()) {
			P p = queue.remove();
			field[p.y][p.x] = '.';
			if (p.y > 0 && field[p.y - 1][p.x] == c)
				queue.add(new P(p.x, p.y - 1));
			if (p.x > 0 && field[p.y][p.x - 1] == c)
				queue.add(new P(p.x - 1, p.y));
			if (p.y < h - 1 && field[p.y + 1][p.x] == c)
				queue.add(new P(p.x, p.y + 1));
			if (p.x < w - 1 && field[p.y][p.x + 1] == c)
				queue.add(new P(p.x + 1, p.y));
		}
	}

}

class P {
	int x, y;

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

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.ArrayDeque;
      | ^~~~~~
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.Queue;
      | ^~~~~~
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 java.util.Scanner;
      | ^~~~~~
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 {
      | ^~~~~~
a.cc:65:2: error: expected ';' after class definition
   65 | }
      |  ^
      |  ;
a.cc: In constructor 'P::P(int, int)':
a.cc:62:22: error: request for member 'x' in '(P*)this', which is of pointer type 'P*' (maybe you meant to use '->' ?)
   62 |                 this.x = x;
      |                      ^
a.cc:63:22: error: request for member 'y' in '(P*)this', which is of pointer type 'P*' (maybe you meant to use '->' ?)
   63 |                 this.y = y;
      |                      ^
Language: C++

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

using namespace std;

char a[100][100];

int ans = 0;
int h, w;

void Solution(int y, int x, char z)
{
    a[y][x] = '0';
    
    if(a[y+1][x] == z)
    {
        Solution(y+1, x, z);
    }
    
    if(a[y - 1][x] == z)
    {
        Solution(y-1, x, z);
    }
    
    if(a[y][x + 1] == z)
    {
        Solution(y, x + 1, z);
    }
    
    if(a[y][x - 1] == z)
    {
        Solution(y, x - 1, z);
    }
}

int main()
{
    while (cin>>h>>w && (n|m))
    {
        ans = 0;
        
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                a[i][j] = '0';
            }
        }
        
        if(h == 0)
        {
            break;
        }
        
        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] != '0')
                {
                    Solution(i, j, a[i][j]);
                    ans++;
                }
            }
        }
        
        cout<<ans<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:26: error: 'n' was not declared in this scope; did you mean 'yn'?
   47 |     while (cin>>h>>w && (n|m))
      |                          ^
      |                          yn
a.cc:47:28: error: 'm' was not declared in this scope
   47 |     while (cin>>h>>w && (n|m))
      |                            ^
Language: C++

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

using namespace std;

char a[101][101];

int ans = 0;
int h, w;

void Solution(int y, int x, char z)
{
    a[y][x] = '0';
    
    if(a[y+1][x] == z)
    {
        Solution(y+1, x, z);
    }
    
    if(a[y - 1][x] == z)
    {
        Solution(y-1, x, z);
    }
    
    if(a[y][x + 1] == z)
    {
        Solution(y, x + 1, z);
    }
    
    if(a[y][x - 1] == z)
    {
        Solution(y, x - 1, z);
    }
}

int main()
{
    while (cin>>h>>w && (n|m))
    {
        ans = 0;
        
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                a[i][j] = '0';
            }
        }
        
        if(h == 0)
        {
            break;
        }
        
        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] != '0')
                {
                    Solution(i, j, a[i][j]);
                    ans++;
                }
            }
        }
        
        cout<<ans<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:26: error: 'n' was not declared in this scope; did you mean 'yn'?
   47 |     while (cin>>h>>w && (n|m))
      |                          ^
      |                          yn
a.cc:47:28: error: 'm' was not declared in this scope
   47 |     while (cin>>h>>w && (n|m))
      |                            ^
Language: C++

void append(char fruit[100][100], int (&map)[100][100], int count, int i, int j, int h, int w){
    if(j != w -1){
        if(map[i][j+1] == 0 && fruit[i][j+1] == fruit[i][j]){
            map[i][j+1] = count;
            append(fruit, map, count, i, j+1, h, w);
        }
    }
    
    if(i != h - 1){
        if(map[i+1][j] == 0 && fruit[i+1][j] == fruit[i][j]){
            map[i+1][j] = count;
            append(fruit, map, count, i+1, j, h, w);
        }
    }
    
    if(j != 0){
        if(map[i][j-1] == 0 && fruit[i][j-1] == fruit[i][j]){
            map[i][j-1] = count;
            append(fruit, map, count, i, j-1, h, w);
        }
    }
    
    if(i != 0){
        if(map[i-1][j] == 0 && fruit[i-1][j] == fruit[i][j]){
            map[i-1][j] = count;
            append(fruit, map, count, i-1, j, h, w);
        }
    }

}


int main(int argc, const char * argv[]) {
    
    while(true){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        
        
        int count = 0;
        int map[100][100] = {};
        char fruits[100][100] = {};
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cin >> fruits[i][j];
            }
        }
        
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(map[i][j] != 0){
                    continue;
                }else{
                    count++;
                    map[i][j] = count;
                    append(fruits, map, count, i, j, H, W);
                }
                
            }
        }
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout << map[i][j] << " ";
            }
            cout << endl;
        }
        
        cout << count << endl;
    }
        return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:37:9: error: 'cin' was not declared in this scope
   37 |         cin >> H >> W;
      |         ^~~
a.cc:69:17: error: 'cout' was not declared in this scope; did you mean 'count'?
   69 |                 cout << map[i][j] << " ";
      |                 ^~~~
      |                 count
a.cc:71:13: error: 'cout' was not declared in this scope; did you mean 'count'?
   71 |             cout << endl;
      |             ^~~~
      |             count
a.cc:71:21: error: 'endl' was not declared in this scope
   71 |             cout << endl;
      |                     ^~~~
a.cc:74:9: error: 'cout' was not declared in this scope; did you mean 'count'?
   74 |         cout << count << endl;
      |         ^~~~
      |         count
a.cc:74:26: error: 'endl' was not declared in this scope
   74 |         cout << count << endl;
      |                          ^~~~
Language: C++

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

using namespace std;

int H,W;

void saiki(char map[][100],int i,int j,char c){


	map[i][j] = ' ';
	for (int dx=-1;dx<=1;dx++){
	    if(i+dx >= 0 && i+dx<W){
		if(map[i+dx][j] == c){
		    saiki(map,i+dx,j,c);
		}
	    }
	}
	for (int dy=-1;dy<=1;dy++){
	    if(i+dy >= 0 && i+dy<W){
		if(map[i][j+dy] == c){
		    saiki(map,i,j+dy,c);
		}
	    }
	}
}


int main(){

    bool flag=true;
    while(true){
	int count = 0;
	cin >> H >> W;
	if(H==0&&W==0) break;
	char map[100][100];
	for(int i=0;i<W;i++){
	    for(int j=0;j<H;j++){
		cin >> map[i][j];
	    }
	}

	int i=0,j=0;
	char c;
	for(int i=0;i<W;i++){
	    for(int j=0;j<H;j++){
		c = map[i][j];
		if(c != ' '){
		    count++;
		    saiki(map,i,j,c);
		}
	    }
	}

	cout << count << endl;

	}
	return 0;
    }javascript:void(0)

Compiler output:
a.cc:60:6: error: 'javascript' does not name a type
   60 |     }javascript:void(0)
      |      ^~~~~~~~~~
Language: C++

//??-2015-11-1
/*
?意：
在H * W的矩形果?里有苹果、梨、蜜柑三?果?， 相?（上下左右）的同?果?属于同一个区域，?出果?的果?分布，求?共有多少个区域。 （原?的??中苹果?リ，梨?カ，蜜柑?ミ， ?中共10个区域）
?入：
多?数据，??数据第一行??个整数H，W（H <= 100, W <= 100）， H = 0 且 W = 0代表?入?束。以下H行W列表示果?的果?分布， 苹果是@，梨是#， 蜜柑是*。
?出：
?于??数据，?出其区域的个数。
*/
# include <cstdio>
# include <algorithm>
# include <stack>
# include <string>
# include <iostream>

using namespace std;
int direction[4][2] = { { -1, 0 }, { 1, 0 }, { 0, -1 }, {0,1} };             //方向，上下左右
int H, W;
int vis[105][105];
string s[105];
struct node
{
	int w, h;
}node1[10005];
void DFS(int i, int j)
{
	stack<node>S;
	int k, z;
	char c = s[i][j];
	node temp;
	temp.h = i;
	temp.w = j;
	vis[temp.h][temp.w] = 1;
	S.push(temp);

	while (!S.empty())                            //?不空的?
	{
		node temp1 = S.top();
		S.pop();
		for (k = 0; k < 4; k++)
		{
			if (temp1.h + direction[k][0] >= 0 && temp1.h + direction[k][0] < H&&temp1.w + direction[k][1] >= 0 && temp1.w + direction[k][1] < W &&!vis[temp1.h + direction[k][0]][temp1.w + direction[k][1]] && s[temp1.h + direction[k][0]][temp1.w + direction[k][1]] == c)   //没有越界，并且没有???，和原来的符号一??，就入?
			{
				node temp2;
				temp2.h = temp1.h + direction[k][0];
				temp2.w = temp1.w + direction[k][1];
				vis[temp2.h][temp2.w] = 1;                              //在入?的?候就??
				S.push(temp2);
			}
		}
	}
}
int main(void)
{
	//freopen("in.txt", "r", stdin);
	
	while (scanf("%d%d", &H, &W) != EOF&&H&&W)
	{
		memset(vis, 0, sizeof(vis));
		int i, j,count_number = 0;
		getchar();
		for (i = 0; i < H; i++)
		{
			cin >> s[i];
		}
		for (i = 0; i < H; i++)
		{
			for (j = 0; j < W; j++)
			{
				if (!vis[i][j])
				{
					DFS(i, j);
					count_number++;
				}
			}
		}
		printf("%d\n", count_number);
	}
	return 0;
}

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

#include <bits/stdc++.h>
#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;

int h, w;
string field[100];

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

void dfs(int y, int x, char mark){
    field[y][x] = '-';

    for(int i = 0; i < 4; i++){
        int yy = y + dy[i];
        int xx = x + dx[i];
        if(yy < 0 || h <= yy ||
           xx < 0 || w <= xx || 
           field[yy][xx] != mark) continue;

        dfs(yy, xx, mark);
    }
}

int main(void){
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;

        for(int y = 0; y < h; y++){
            cin >> field[y];
        }

        int res = 0;
        for(int y = 0; y < h; y++){
            for(int x = 0; x < w; x++){
                if(field[y][x] != '-'){
                    dfs(y, x, field[y][x]);
                    res++;
                }
            }
        }

        cout << res << endl;
    }

	return 0;
}

Compiler output:
a.cc:9:5: error: scalar object 'dx' requires one element in initializer
    9 | int dx = { 1, 0,-1, 0};
      |     ^~
a.cc:10:5: error: scalar object 'dy' requires one element in initializer
   10 | int dy = { 0,-1, 0, 1};
      |     ^~
Language: C++

#include<stdio.h>

int map[102][102];

void paint(int x,int y,int type){
    if(map[x][y]==type){
        map[x][y]=0;
        paint(x-1,y,type);
        paint(x+1,y,type);
        paint(x,y-1,type);
        paint(x,y+1,type);
    }
}

int main(void){
    int h,w,i,j,ans=0;
    char str[110];
    scanf("%d%d",&h,&w);

    while(h!=0 || w!=0){
    
    for(i=0; i<=h+1; i++){
        for(j=0; j<=w+1; j++){
            map[i][j]=0;
        }
    }
    for(i=1; i<=h; i++){
        scanf("%s",str);
        for(j=0; j<w; j++){
            if(str[j]=='@'){
                map[i][j+1]=1;
            }else if(str[j]=='#'){
                map[i][j+1]=2;
            }else if(str[j]=='*'){
                map[i][j+1]=3;
            }
        }
    }
    for(i=1; i<=h; i++){
        for(j=1; j<=w; j++){
            if(map[i][j]!=0){
                paint(i,j,map[i][j]);
                ans++;
            }
        }
    }
    printf("%d\n",ans);
        
    scanf("%d%d",&h,&w);
        javascript:void(0)
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:27: error: expected ';' before '}' token
   50 |         javascript:void(0)
      |                           ^
      |                           ;
   51 |     }
      |     ~
Language: C++

#include <string>
#include <vector>
#include <iostream>

using namespace std;

int H, W;

vector<string> map;

const vector<int> dx = { 0, 1, 0, -1 };
const vector<int> dy = { 1, 0, -1, 0 };

void rec(int x, int y, char c)
{
    map[y][x] = '.';
    
    for(int i = 0; i < 4; i++)
    {
        if(0 <= x + dx[i] && x + dx[i] < W && 0 <= y + dy[i] && y + dy[i] < H)
        {
            if(map[y + dy[i]][x + dx[i]] == c)
            {
                dfs(x + dx[i], y + dy[i]);
            }
        }
    }
}

int solve()
{
    int ret = 0;
    
    for(int i = 0; i < H; i++)
    {
        for(int i = 0; i < W; i++)
        {
            if(map[i][j] != '.')
            {
                rec(j, i); ret++;
            }
        }
    }
    
    return ret;
}

int main()
{
    while(true)
    {
        cin >> H >> W;
        
        map = vector<string>(H);
        
        for(int i = 0; i < H; i++)
        {
            cin >> map[i];
        }
        
        cout << solve() << endl;
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'void rec(int, int, char)':
a.cc:24:17: error: 'dfs' was not declared in this scope
   24 |                 dfs(x + dx[i], y + dy[i]);
      |                 ^~~
a.cc: In function 'int solve()':
a.cc:38:23: error: 'j' was not declared in this scope
   38 |             if(map[i][j] != '.')
      |                       ^
Language: C++

#include <string>
#include <vector>
#include <iostream>

using namespace std;

int H, W;

vector<string> map;

const vector<int> dx = { 0, 1, 0, -1 };
const vector<int> dy = { 1, 0, -1, 0 };

void rec(int x, int y, char c)
{
    map[y][x] = '.';
    
    for(int i = 0; i < 4; i++)
    {
        if(0 <= x + dx[i] && x + dx[i] < W && 0 <= y + dy[i] && y + dy[i] < H)
        {
            if(map[y + dy[i]][x + dx[i]] == c)
            {
                dfs(x + dx[i], y + dy[i]);
            }
        }
    }
}

int solve()
{
    int ret = 0;
    
    for(int i = 0; i < H; i++)
    {
        for(int i = 0; i < W; i++)
        {
            if(map[i][j] != '.')
            {
                rec(j, i, map[i][j]); ret++;
            }
        }
    }
    
    return ret;
}

int main()
{
    while(true)
    {
        cin >> H >> W;
        
        map = vector<string>(H);
        
        for(int i = 0; i < H; i++)
        {
            cin >> map[i];
        }
        
        cout << solve() << endl;
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'void rec(int, int, char)':
a.cc:24:17: error: 'dfs' was not declared in this scope
   24 |                 dfs(x + dx[i], y + dy[i]);
      |                 ^~~
a.cc: In function 'int solve()':
a.cc:38:23: error: 'j' was not declared in this scope
   38 |             if(map[i][j] != '.')
      |                       ^
Language: C++

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

using namespace std;
typedef long long ll;
ll W, H;
char a[101][101];
ll sx, sy;
ll SUM;

void dfs(int x,int y, char cur) {
	if(a[y][x]==cur) {
		a[y][x] = '-';
	}else {
		return;
	}
	int dx[4] = { -1,1,0,0 };
	int dy[4] = { 0,0,-1,1 };
	for (int i = 0; i < 4;i++) {
		int px = x + dx[i];
		int py = y + dy[i];
		if (0 <= px && px < W && 0<=py && py<H) {
			dfs(px, py, cur);
		}
	}
}

int main() {
	vector<ll> res;
	do {
		memset(a, 0, sizeof(a));
		cin >> W >> H;
		SUM = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				char tmp;
				cin >> tmp;
				a[i][j] = tmp;
			}
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W;j++) {
				if (a[i][j] != '-') {
					dfs(j,i,a[i][j]);
					SUM++;
				}
			}
		}
		res.push_back(SUM);
	} while (W != 0 && H != 0);
	for (int i = 0; i < res.size() - 1;i++) {
		cout << res[i] << endl;
	}
	return 0;
}

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

#include<iostream>
using namespace std;

#define MAXSIZE 100

char Graph[MAXSIZE][MAXSIZE];
int visited[MAXSIZE][MAXSIZE];
int h,w,number;
int x[4]={-1,1,0,0};
int y[4]={0,0,-1,1};

void dfs(int i,int j)
{
 int d,p,q;
 for(d=0;d<4;d++)
 {
	p=i+x[d];
	q=j+y[d];
	if(p>=0&&p<h&&q>=0&&q<w&&Graph[i][j]==Graph[p][q]&&visited[p][q]==0)
	{
      visited[p][q]=1;
	  dfs(p,q);
	}
 }
}

int main()
{
	int i,j;
	memset(visited,0,sizeof(visited));
	while(cin>>h&&cin>>w&&h!=0&&w!=0)
	{
		number=0;
		for(i=0;i<h;i++)
			for(j=0;j<w;j++)
				cin>>Graph[i][j];
		for(i=0;i<h;i++)
			for(j=0;j<w;j++)
			{
				if(!visited[i][j])
				{
					visited[i][j]=1;
					dfs(i,j);
                    number++;
				}	
			}
	cout<<number<<endl;
	}
return 0;
}

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

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

int dfs(char **map,int **check,int i,int j,int h){
	int res=1;
	check[i][j]=2;
	if(map[i][j+1]==map[i][j] && check[i][j+1]==1)res=0;
	if(map[i][j+1]==map[i][j] && check[i][j+1]==0){
		if(map[i][j+1]=='\n')return 0;
		else res*=dfs(map,check,i,j+1,h);
	}
	if(i+1>=h)return res;
	if(map[i+1][j]==map[i][j] && check[i+1][j]==0){
		res*=dfs(map,check,i+1,j,h);
	}
	return res;
}

int main(){
	char** map;
	int** check;
	int i,j,k,l,count,sx,sy;

while(1){
	count=0;
	scanf("%d %d",&sx,&sy);
	if(sx==0)break;

	map=malloc(sizeof(char *)*sx);
	for(i=0;i<sx;i++){
		map[i]=malloc(sizeof(char)*(sy+1));
	}
	check=malloc(sizeof(int *)*sx);
	for(i=0;i<sx;i++){
		check[i]=malloc(sizeof(int)*(sy+1));
	}
	for(i=0;i<sx;i++){
		for(j=0;j<=sy;j++){
			check[i][j]=0;
		}
	}

	scanf("%c",&map[0][0]);
	for(i=0;i<sx;i++){
		for(j=0;j<=sy;j++){
			scanf("%c",&map[i][j]);
		}
	}

	for(i=0;i<sx;i++){
		for(j=0;j<sy;j++){
			if(check[i][j]==0){
				count+=dfs(map,check,i,j,sx);
				for(k=0;k<sx;k++){
					for(l=0;l<=sy;l++){
						if(check[k][l]==2)check[k][l]=1;
					}
				}
			}
		}
	}

	printf("%d\n",count);
	for(i=0;i<sx;i++){
		free(map[i]);
	}
	free(map);
}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:19: error: invalid conversion from 'void*' to 'char**' [-fpermissive]
   29 |         map=malloc(sizeof(char *)*sx);
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~
      |                   |
      |                   void*
a.cc:31:30: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
   31 |                 map[i]=malloc(sizeof(char)*(sy+1));
      |                        ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |                              |
      |                              void*
a.cc:33:21: error: invalid conversion from 'void*' to 'int**' [-fpermissive]
   33 |         check=malloc(sizeof(int *)*sx);
      |               ~~~~~~^~~~~~~~~~~~~~~~~~
      |                     |
      |                     void*
a.cc:35:32: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   35 |                 check[i]=malloc(sizeof(int)*(sy+1));
      |                          ~~~~~~^~~~~~~~~~~~~~~~~~~~
      |                                |
      |                                void*
Language: C++

#include <iostream>
using namespace std;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
char map[105][105];  //H <= 100, W <= 100
int h, w, vis[105][105];

void dfs(int x, int y, char c)
{
    int i, xx, yy;

    for(i = 0; i < 4; i++)
    {
        xx = x + dx[i];
        yy = y + dy[i];
        
        if(xx >= 0 && xx < h && yy >= 0 && yy < w && !vis[xx][yy] && ma[xx][yy] == c)  //?找相同区域?char相同
        {
            vis[xx][yy] = 1;  //搜索的?置?1以防下次搜索?区域
            dfs(xx, yy, c);
        }
    }
}

int main()
{
    int i, j, ans;

    while(scanf("%d%d", &h, &w) && (h || w))
    {
        getchar();  //?行考?

        for(i = 0; i < h; i++) scanf("%s", map[i]);  //按行?取
        memset(vis, 0, sizeof vis);  //vis全部元素置?0，即初始化数?
        ans = 0;

        for(i = 0; i < h; i++)
        {
            for(j = 0; j < w; j++)
            {
                if(!vis[i][j])
                {
                    ans++;  //一?始就是一个区域
                    dfs(i, j, map[i][j]);  //深度搜索
                }
            }
        }
        printf("%d\n", ans);
    }

    return 0;
}

/*
??附?
在H*W的矩形果?里有苹果、梨、蜜柑三?果?，相?（上下左右）的同?果?属于同一个区域，?出果?的果?分布，求?共有多少个区域。
（原?的??中苹果?リ，梨?カ，蜜柑?ミ， ?中共10个区域） 
?入：
多?数据，??数据第一行??个整数H、W（H <= 100, W <= 100）， H =0 且 W = 0代表?入?束。
以下H行W列表示果?的果?分布，苹果是@，梨是#， 蜜柑是*。
?出：
?于??数据，?出其区域的个数。
*/

Compiler output:
a.cc: In function 'void dfs(int, int, char)':
a.cc:18:70: error: 'ma' was not declared in this scope; did you mean 'map'?
   18 |         if(xx >= 0 && xx < h && yy >= 0 && yy < w && !vis[xx][yy] && ma[xx][yy] == c)  //?找相同区域?char相同
      |                                                                      ^~
      |                                                                      map
a.cc: In function 'int main()':
a.cc:35:9: error: 'memset' was not declared in this scope
   35 |         memset(vis, 0, sizeof vis);  //vis全部元素置?0，即初始化数?
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>
using namespace std;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
char map[105][105];  //H <= 100, W <= 100
int h, w, vis[105][105];

void dfs(int x, int y, char c)
{
    int i, xx, yy;

    for(i = 0; i < 4; i++)
    {
        xx = x + dx[i];
        yy = y + dy[i];
        
        if(xx >= 0 && xx < h && yy >= 0 && yy < w && !vis[xx][yy] && map[xx][yy] == c)  //?找相同区域?char相同
        {
            vis[xx][yy] = 1;  //搜索的?置?1以防下次搜索?区域
            dfs(xx, yy, c);
        }
    }
}

int main()
{
    int i, j, ans;

    while(scanf("%d%d", &h, &w) && (h || w))
    {
        getchar();  //?行考?

        for(i = 0; i < h; i++) scanf("%s", map[i]);  //按行?取
        memset(vis, 0, sizeof vis);  //vis全部元素置?0，即初始化数?
        ans = 0;

        for(i = 0; i < h; i++)
        {
            for(j = 0; j < w; j++)
            {
                if(!vis[i][j])
                {
                    ans++;  //一?始就是一个区域
                    dfs(i, j, map[i][j]);  //深度搜索
                }
            }
        }
        printf("%d\n", ans);
    }

    return 0;
}

/*
??附?
在H*W的矩形果?里有苹果、梨、蜜柑三?果?，相?（上下左右）的同?果?属于同一个区域，?出果?的果?分布，求?共有多少个区域。
（原?的??中苹果?リ，梨?カ，蜜柑?ミ， ?中共10个区域） 
?入：
多?数据，??数据第一行??个整数H、W（H <= 100, W <= 100）， H =0 且 W = 0代表?入?束。
以下H行W列表示果?的果?分布，苹果是@，梨是#， 蜜柑是*。
?出：
?于??数据，?出其区域的个数。
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'memset' was not declared in this scope
   35 |         memset(vis, 0, sizeof vis);  //vis全部元素置?0，即初始化数?
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>
#include <sstream>
#include <cstdlib>

const int MAX_W = 100;
const int MAX_H = 100;
int H, W;
char field[MAX_H][MAX_W] = {'.'};

void solve(int y, int x) {
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, 1, 0, -1};
    char c = field[y][x];
    field[y][x] = '.';

    for(int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx >= 0 and ny >= 0 and nx < W and ny < H and field[ny][nx] == c) {
            solve(ny, nx, H, W);
        }
    }


}

void print(int w, int h) {
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            std::cout << field[i][j];
        }
        std::cout << std::endl;
    }

    std::cout << std::endl;
}

int main() {
    while (std::cin >> H >> W, H) {
        for (int i = 0; i < H; i++) {
            std::cin >> field[i];
        }

        int count = 0;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (field[i][j] != '.') {
                    solve(i, j);
                    count++;
                }
            }
        }
        std::cout << count << std::endl;
    }

    return 0;
    return 0;
}

Compiler output:
a.cc: In function 'void solve(int, int)':
a.cc:20:18: error: too many arguments to function 'void solve(int, int)'
   20 |             solve(ny, nx, H, W);
      |             ~~~~~^~~~~~~~~~~~~~
a.cc:10:6: note: declared here
   10 | void solve(int y, int x) {
      |      ^~~~~
Language: C++

#include <iostream>
using namespace std;

char f[124][124];
int H, W;

const dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
inline bool inside(int y, int x){return 0 <= y && y < H && 0 <= x && x < W;}

void area(int y, int x)
{
	char if2 = f[y][x];
	f[y][x] = '0';
	
	for (int i = 0; i < 4; i++){
		int ny = y + dy[i], nx = x + dx[i];
		if (inside(y, x) && f[ny][nx] != '0' && f[ny][nx] == if2){
			area(ny, nx);
		}
	}
}

int main()
{
	while (cin >> H >> W, H || W){
		int c = 0;
		for (int i = 0; i < H; i++){
			cin >> f[i];
		}
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if (f[i][j] != '0'){
					area(i, j);
					c++;
				}
			}
		}
		cout << c << endl;
	}
	
	return 0;
}

Compiler output:
a.cc:7:7: error: 'dx' does not name a type
    7 | const dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
      |       ^~
a.cc:7:27: error: expected unqualified-id before ',' token
    7 | const dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
      |                           ^
a.cc:7:34: error: expected constructor, destructor, or type conversion before '=' token
    7 | const dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
      |                                  ^
a.cc: In function 'void area(int, int)':
a.cc:16:30: error: 'dy' was not declared in this scope; did you mean 'ny'?
   16 |                 int ny = y + dy[i], nx = x + dx[i];
      |                              ^~
      |                              ny
a.cc:17:43: error: 'nx' was not declared in this scope; did you mean 'ny'?
   17 |                 if (inside(y, x) && f[ny][nx] != '0' && f[ny][nx] == if2){
      |                                           ^~
      |                                           ny
Language: C++

//AOJ0118 Property Distribution
#include<cstdio>
#include<cstring>
char map[105][105];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int W,H;
void dfs(int x,int y,char c){
    map[x][y]='.';
    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&&map[nx][ny]==c)dfs(nx,ny,c);果樹園
    }
}
int main(){
    while(scanf("%d%d",&W,&H),W&&H){
        int cnt=0;
        memset(map,'.',sizeof(map));
        for(int i=0;i<H;i++)scanf("%s",map[i]);
        for(int i=0;i<H;i++)
            for(int j=0;j<W;j++)
                if(map[i][j]!='.'){
                    dfs(i,j,map[i][j]);
                    cnt++;
                }
        printf("%d\n",cnt);
    }
    return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, char)':
a.cc:12:66: error: '\U0000679c\U00006a39\U00005712' was not declared in this scope
   12 |         if(0<=nx&&nx<H&&0<=ny&&ny<W&&map[nx][ny]==c)dfs(nx,ny,c);果樹園
      |                                                                  ^~~~~~