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

#include <bits/stdc++.h>

using namespace std;

int H,M,cnt=0;
char farm[100][100];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};


void dfs(int x, int y ,char z){
  farm[x][y]='.';
  for(int i=0;i<4;i++){
    if(x+dx[i]>=0 && x+dx[i]<H && y+dy[i]>=0 && y+dy[i]<M && farm[x+dx[i]][y+dy[i]]==z) dfs(x+dx[i],y+dy[i],z);
    return ;
  }
}

int main(){
  scanf("%d %d",&H,&M);

  for(int i=0;i<H,i++){
    for(int j=0;j<M;j++){
      scanf("%c",&farm[i][j]);
    }
  }

  for(int i=0;i<H,i++){
    for(int j=0;j<M;j++){
      if(farm[i][j]!='.'){
        dfs(i,j,farm[i][j]); cnt++;
      }
    }
  }

  printf("%d",cnt);

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:22: error: expected ';' before ')' token
   21 |   for(int i=0;i<H,i++){
      |                      ^
      |                      ;
a.cc:27:22: error: expected ';' before ')' token
   27 |   for(int i=0;i<H,i++){
      |                      ^
      |                      ;
Language: C++

#include <cstdio>
#include <map>
#include <queue>
#include <cstring>

#define PRINTF(...) 

int h, w;
char area[100][100];

void visualize() {
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            PRINTF("%c", area[i][j]);
        }
        PRINTF("\n");
    }
}

void replace(char c, int i, int j) {
    int dirs[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    if (i < 0 || i >= h || j < 0 || j >= w || area[i][j] != c) {
        return;
    }
    area[i][j] = '.';
    for (int k = 0; k < 4; k++) {
        replace(c, i + dirs[k][0], j + dirs[k][1]);
    }

}

int solve() {
    char buf[4096];
    int count = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (area[i][j] != '.') {
                PRINTF("before\n");
                visualize();
                count++;
                gets(buf);
                replace(area[i][j], i, j);
                PRINTF("after\n");
                visualize();
                gets(buf);
            }
        }
    }
    return count;
}

int main() {
    while (true) {
        scanf(" %d %d", &h, &w);
        PRINTF("h: %d w: %d\n", h, w);
        if (h == 0 && w == 0)
            break;

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (scanf(" %c", &area[i][j]) == EOF) 
                    return 0;
            }
        }
        printf("%d\n", solve());
    }

}

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


#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <string>
//typedef pair<int,int> P;

using namespace std;

const int INF=INT_MAX/3;
const int V_MAX=10000,E_MAX=10000;

int H,W;
const int MAX=200;

char maps[MAX][MAX];

void solve(int i,int j){

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

  char c=maps[i][j];
  maps[i][j]='.';
  
  for(int k=0;k<4;k++){
    int ni=i+dx[k];
    int nj=j+dy[k];
    if((0<=ni && ni<H) && (0<=nj && nj<W))
      if(maps[ni][nj]!='.' && c==maps[ni][nj]){
	//cout<<"pohe"<<endl;
	solve(ni,nj);
      }
  }
  
  

}



int main(){

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

    for(int i=0;i<H;i++){
      cin>>maps[i];
    }
    //cout<<"hoge\n";

    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++){
	if(maps[i][j]!='.'){
	  solve(i,j);
	  res++;
	  //cout<<"piyo"<<endl;
	}
	/*
	for(int i=0;i<H;i++){
	  for(int j=0;j<W;j++){
	    cout<<maps[i][j]<<" ";
	  }
	  cout<<endl;
	}
	cout<<endl;
	
      }*/
    cout<<res<<endl;

    //cout<<solve()<<endl;
  }

  return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

char a[100][100];
int vis[110][110], m, n;
int di[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
void dfs(int x,int y,char zf){
	vis[x][y] = 1;
    for(int i = 0;i < 4;i++)
    {
        int tx = x + di[i][0];
        int ty = y + di[i][1];
        if(a[tx][ty] == op && tx < m && tx >= 0 && ty < n && ty >= 0 && !vis[tx][ty])
            dfs(tx, ty, op);
    }
	
	return ;
}
int main()
{
     while(scanf("%d %d", &m, &n), m && n)
     {
         memset(vis, 0, sizeof(vis));
         int ans = 0;
         for(int i = 0;i < m;i++)
            scanf("%s", a[i]);
         for(int i = 0;i < m;i++)
            for(int j = 0;j < n;j++)
            {
                if(!vis[i][j])
                {
                    dfs(i, j, a[i][j]);
                    ans++;
                }
            }
        printf("%d\n", ans);
     }
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, char)':
a.cc:14:25: error: 'op' was not declared in this scope
   14 |         if(a[tx][ty] == op && tx < m && tx >= 0 && ty < n && ty >= 0 && !vis[tx][ty])
      |                         ^~
Language: C++

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

const int MAX = 101;
int X[MAX][MAX]; //??????????¨????
int used[MAX][MAX]; //????????????????????????????????????
int ans = 0;

int H, W;
void input()
{
	cin >> H >> W;
	if (H == 0 && W == 0) return;
	for (int i = 0; i < H; i++) {
		string ch;
		cin >> ch;
		for (int j = 0; j < W; j++) {
			//char ch;
			//scanf("%c", &ch);
			if (ch[j] == '@') //????????´
				X[i][j] = 1;
			if (ch[j] == '#') //??????
				X[i][j] = 2;
			if (ch[j] == '*') //?????????
				X[i][j] = 3;
		}
	}
	memset(used, 0, sizeof(used));
	ans = 0;
}

void dfs(int i, int j) //
{
	used[i][j] = ans + 1;  //test
	int same = X[i][j];
	//?????????
	if (j - 1 >= 0 && !used[i][j - 1] && X[i][j - 1] == same)
		dfs(i, j - 1);
	//?????????
	if (i - 1 >= 0 && !used[i - 1][j] && X[i - 1][j] == same)
		dfs(i - 1, j);
	//???
	if (!used[i][j + 1] && X[i][j + 1] == same)
		dfs(i, j + 1);
	//???
	if (!used[i + 1][j] && X[i + 1][j] == same)
		dfs(i + 1, j);
	return;
}

void solve()
{
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (!used[i][j]) {
				dfs(i, j);
				ans++;
			}
		}
	}

	cout << ans << endl;
}

int main()
{
	while (1) {
		input();
		if (H == 0 && W == 0) break;
		solve();
	}
	return 0;
}

Compiler output:
a.cc: In function 'void input()':
a.cc:29:9: error: 'memset' was not declared in this scope
   29 |         memset(used, 0, sizeof(used));
      |         ^~~~~~
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 "stdafx.h"
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_H 100

// ??\??? 
int H, W;
char graph[MAX_H + 2][MAX_H + 2];

int visited[MAX_H + 2][MAX_H + 2];

bool dfs(int bx, int by, int x, int y) {
	int dx[] = { 1,-1, 0, 0 }, dy[] = { 0,0, 1, -1 };
	int nx = x, ny = y;
	bool res;

	if (bx == -1 && by == -1) {
		visited[nx][ny] = 1;
	}

	else {
		if (graph[bx][by] == graph[nx][ny]) {
			visited[nx][ny] = 1;
		}
		else {
			return false;
		}
	}
	
	for (int i = 0; i < 4; i++) {
		if (visited[nx+dx[i]][ny+dy[i]] == 0) {
			res = dfs(nx, ny, nx + dx[i], ny + dy[i]);
		}
	}

	return true;

}


int main()
{

	int cnt = 0;
	int dust1, dust2;
	bool res;

	cin >> H >> W;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> graph[i][j];
			visited[i][j] = 0;
		}
	}

	cin >> dust1 >> dust2;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (visited[i][j] == 0) {
				res = dfs(-1, -1, i, j);
				cnt++;
			}
		}
	}

	cout << cnt << endl;

    return 0;
}

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

#include <stdio.h>

int H,W;
char map[100][100];

bool paint(int i,int j,char data){
	if(data==' ')return false;
	
	if(i>0&&map[i][j]==map[i-1][j])paint(i-1,j);
	if(j>0&&map[i][j]==map[i][j-1])paint(i,j-1);
	if(i<=H&&map[i][j]==map[i+1][j])paint(i+1,j);
	if(i<=W&&map[i][j]==map[i][j+1])paint(i,j+1);
	return true;

int main(){
	int num=0;
	
	scanf("%d %d",&H,&W);
	for(int i=0;i<W;i++){
		scanf("%s",map[i];
	}
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(paint(i,j))num++;
		}
	}

	printf("%d\n",num);
	return 0;
}

Compiler output:
a.cc: In function 'bool paint(int, int, char)':
a.cc:9:45: error: too few arguments to function 'bool paint(int, int, char)'
    9 |         if(i>0&&map[i][j]==map[i-1][j])paint(i-1,j);
      |                                        ~~~~~^~~~~~~
a.cc:6:6: note: declared here
    6 | bool paint(int i,int j,char data){
      |      ^~~~~
a.cc:10:45: error: too few arguments to function 'bool paint(int, int, char)'
   10 |         if(j>0&&map[i][j]==map[i][j-1])paint(i,j-1);
      |                                        ~~~~~^~~~~~~
a.cc:6:6: note: declared here
    6 | bool paint(int i,int j,char data){
      |      ^~~~~
a.cc:11:46: error: too few arguments to function 'bool paint(int, int, char)'
   11 |         if(i<=H&&map[i][j]==map[i+1][j])paint(i+1,j);
      |                                         ~~~~~^~~~~~~
a.cc:6:6: note: declared here
    6 | bool paint(int i,int j,char data){
      |      ^~~~~
a.cc:12:46: error: too few arguments to function 'bool paint(int, int, char)'
   12 |         if(i<=W&&map[i][j]==map[i][j+1])paint(i,j+1);
      |                                         ~~~~~^~~~~~~
a.cc:6:6: note: declared here
    6 | bool paint(int i,int j,char data){
      |      ^~~~~
a.cc:15:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   15 | int main(){
      |         ^~
a.cc:15:9: note: remove parentheses to default-initialize a variable
   15 | int main(){
      |         ^~
      |         --
a.cc:15:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:15:11: error: a function-definition is not allowed here before '{' token
   15 | int main(){
      |           ^
a.cc:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:6:34: note: to match this '{'
    6 | bool paint(int i,int j,char data){
      |                                  ^
Language: C++

#include <stdio.h>

int H,W;
char map[100][100];

bool paint(int i,int j){
	if(data==' ')return false;
	
	if(i>0&&map[i][j]==map[i-1][j])paint(i-1,j);
	if(j>0&&map[i][j]==map[i][j-1])paint(i,j-1);
	if(i<=H&&map[i][j]==map[i+1][j])paint(i+1,j);
	if(i<=W&&map[i][j]==map[i][j+1])paint(i,j+1);
	return true;
}

int main(){
	int num=0;
	
	scanf("%d %d",&H,&W);
	for(int i=0;i<W;i++){
		scanf("%s",map[i];
	}
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(paint(i,j))num++;
		}
	}

	printf("%d\n",num);
	return 0;
}

Compiler output:
a.cc: In function 'bool paint(int, int)':
a.cc:7:12: error: 'data' was not declared in this scope
    7 |         if(data==' ')return false;
      |            ^~~~
a.cc: In function 'int main()':
a.cc:21:34: error: expected ')' before ';' token
   21 |                 scanf("%s",map[i];
      |                      ~           ^
      |                                  )
Language: C++

#include <stdio.h>

int H,W;
char map[100][100];

bool paint(int i,int j){
	if(map[i][j]==' ')return false;
	
	if(i>0&&map[i][j]==map[i-1][j])paint(i-1,j);
	if(j>0&&map[i][j]==map[i][j-1])paint(i,j-1);
	if(i<=H&&map[i][j]==map[i+1][j])paint(i+1,j);
	if(i<=W&&map[i][j]==map[i][j+1])paint(i,j+1);
	map[i][j]=' ';
	return true;
}

int main(){
	int num=0;
	
	scanf("%d %d",&H,&W);
	for(int i=0;i<W;i++){
		scanf("%s",map[i];
	}
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(paint(i,j))num++;
		}
	}

	printf("%d\n",num);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:34: error: expected ')' before ';' token
   22 |                 scanf("%s",map[i];
      |                      ~           ^
      |                                  )
Language: C++

#include<stdio.h>
#include<string.h>
using namespace std;
int m,n,ans,v[30][30],move[4][2]= {0,1,0,-1,1,0,-1,0};
char a[30][30];
void dfs(char c,int x,int y)
{
    for(int i = 0; i < 4; i ++)
    {
        int x1 = x+move[i][0];
        int y1 = y+move[i][1];
        if(x1>=0&&x1<m&&y1<n&&y1>=0&&a[x1][y1]==c&&!v[x1][y1])
        {
            v[x1][y1]=1;
            dfs(c,x1,y1);
        }
    }
    return;
}
int main()
{
    while(scanf("%d%d",&n,&m)&&n!=0&&m!=0)
    {
        getchar();
        int i,j;
        ans=0;
        memset(v,0,sizeof(v));
        for(i=0; i<m; i++)
            gets(a[i]);
        for(i=0; i<m; i++)
            for(j=0; j<n; j++)
                if(!v[i][j])
                {
                    dfs(a[i][j],i,j);
                    ans++;
                }
        printf("%d\n",ans);
    }
    return 0;
}

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

#include<iostream>
using namespace std;
const int MAXN = 200;
char B[MAXN][MAXN];
int W,H,cnt;

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

void isStar(int y, int x)
{
	for(int i =0 ; i<5;i++)
		if(B[y+dy[i]][x+dx[i]]=='*')
			{B[y+dy[i]][x+dx[i]]='0';isStar(y+dy[i],x+dx[i]);}
}

void isSharp(int y, int x)
{
	for(int i =0 ; i<5;i++)
		if(B[y+dy[i]][x+dx[i]]=='#')
			{B[y+dy[i]][x+dx[i]]='0';isSharp(y+dy[i],x+dx[i]);}
}

void isAt(int y, int x)
{
	for(int i =0 ; i<5;i++)
		if(B[y+dy[i]][x+dx[i]]=='@')
			{B[y+dy[i]][x+dx[i]]='0';isAt(y+dy[i],x+dx[i]);}
}



void solve()
{

	for(int i = 1; i<=H;i++)
		for(int j = 1; j<=W;j++)
		{
			if(B[i][j] == '*')
			{
				B[i][j] = '0';
				cnt++;
				isStar(i,j);
			}
			else if(B[i][j] == '#')
			{
				B[i][j] = '0';
				cnt++;
				isSharp(i,j);
			}
			else if(B[i][j] == '@')
			{
				B[i][j] = '0';
				cnt++;
				isAt(i,j);
			}
		}
	
	cout << cnt<<endl;
}

int main()
{
	
	
	
	while(cin >>H>> W && W||H)
	{
		memset(B,'0',sizeof(B));
		
		for(int i = 1; i<= H; i++)
		{
			for(int j = 1; j<= W; j++)
				cin >> B[i][j];
		getchar();
		}
		cnt = 0;
		solve();
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:69:17: error: 'memset' was not declared in this scope
   69 |                 memset(B,'0',sizeof(B));
      |                 ^~~~~~
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 <cstdio>
#include <algorithm>
using namespace std;

const int max_n = 21;
int W, H;

char farm[max_n][max_n];
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

void dfs(int x, int y, char t){
    farm[x][y] = '!';
    for(int i = 0; i < 4; i++){
        int xx =  x+dx[i]; int yy = y+dy[i];
        if(xx >= 0 && xx < H && yy >= 0 && yy < W && farm[xx][yy] == t){
            dfs(xx, yy , t);
        }
    }
}

solve(){
    int ans = 0;

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(farm[i][j] != '!'){
                dfs(i,j,farm[i][j]);
                ++ans;
            }
        }
    }

    printf("%d\n", ans);
}

int main(){
    while(scanf("%d%d", &W, &H) > 0 && H && W){
            getchar();
        for(int i = 0; i < H; i++){
            gets(farm[i]);
        }
        solve();
    }
    return 0;
}

Compiler output:
a.cc:22:1: error: ISO C++ forbids declaration of 'solve' with no type [-fpermissive]
   22 | solve(){
      | ^~~~~
a.cc: In function 'int solve()':
a.cc:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^
a.cc: In function 'int main()':
a.cc:41:13: error: 'gets' was not declared in this scope; did you mean 'getw'?
   41 |             gets(farm[i]);
      |             ^~~~
      |             getw
Language: C++

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

const int max_n = 21;
int W, H;

char farm[max_n][max_n];
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

void dfs(int x, int y, char t){
    farm[x][y] = '!';
    for(int i = 0; i < 4; i++){
        int xx =  x+dx[i]; int yy = y+dy[i];
        if(xx >= 0 && xx < H && yy >= 0 && yy < W && farm[xx][yy] == t){
            dfs(xx, yy , t);
        }
    }
}

void solve(){
    int ans = 0;

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(farm[i][j] != '!'){
                dfs(i,j,farm[i][j]);
                ++ans;
            }
        }
    }

    printf("%d\n", ans);
}

int main(){
    while(scanf("%d%d", &W, &H) > 0 && H && W){
            getchar();
        for(int i = 0; i < H; i++){
            gets(farm[i]);
        }
        solve();
    }
    return 0;
}

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

#include <stdio.h>

void dfs(char values,int H,int W,int x, int y,int item)
{
	if(x<0 || H<=x) return;
	if(y<0 || W<=y) return;
	if(values[x][y]!=item) return;
	farms[x][y] = '.';
	dfs(values,H,W,x+1,y,item);
	dfs(values,H,W,x-1,y,item);
	dfs(values,H,W,x,y+1,item);
	dfs(values,H,W,x,y-1,item);
}


int solve(char values,int H,int W){
	int res = 0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(farms[i][j] != '.')
			{
				dfs(values,H,W,i,j,values[i][j]);
				res++;
			}
	return res;
}

int main()
{
	int H, W;
	cin >> H >> W;
	char values[101][101];
	while (!(H == 0 && W == 0))
	{
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				cin >> values[i][j];
		printf("%d", solve(value,H,W));
		cin >> H >> W;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(char, int, int, int, int, int)':
a.cc:7:18: error: invalid types 'char[int]' for array subscript
    7 |         if(values[x][y]!=item) return;
      |                  ^
a.cc:8:9: error: 'farms' was not declared in this scope
    8 |         farms[x][y] = '.';
      |         ^~~~~
a.cc: In function 'int solve(char, int, int)':
a.cc:20:28: error: 'farms' was not declared in this scope
   20 |                         if(farms[i][j] != '.')
      |                            ^~~~~
a.cc:22:58: error: invalid types 'char[int]' for array subscript
   22 |                                 dfs(values,H,W,i,j,values[i][j]);
      |                                                          ^
a.cc: In function 'int main()':
a.cc:31:9: error: 'cin' was not declared in this scope
   31 |         cin >> H >> W;
      |         ^~~
a.cc:38:36: error: 'value' was not declared in this scope; did you mean 'values'?
   38 |                 printf("%d", solve(value,H,W));
      |                                    ^~~~~
      |                                    values
Language: C++

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

void dfs(char values,int H,int W,int x, int y,int item)
{
	if(x<0 || H<=x) return;
	if(y<0 || W<=y) return;
	if(values[x][y]!=item) return;
	farms[x][y] = '.';
	dfs(values,H,W,x+1,y,item);
	dfs(values,H,W,x-1,y,item);
	dfs(values,H,W,x,y+1,item);
	dfs(values,H,W,x,y-1,item);
}


int solve(char values,int H,int W){
	int res = 0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(farms[i][j] != '.')
			{
				dfs(values,H,W,i,j,values[i][j]);
				res++;
			}
	return res;
}

int main()
{
	int H, W;
	cin >> H >> W;
	char values[101][101];
	while (!(H == 0 && W == 0))
	{
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				cin >> values[i][j];
		printf("%d", solve(value,H,W));
		cin >> H >> W;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(char, int, int, int, int, int)':
a.cc:9:18: error: invalid types 'char[int]' for array subscript
    9 |         if(values[x][y]!=item) return;
      |                  ^
a.cc:10:9: error: 'farms' was not declared in this scope
   10 |         farms[x][y] = '.';
      |         ^~~~~
a.cc: In function 'int solve(char, int, int)':
a.cc:22:28: error: 'farms' was not declared in this scope
   22 |                         if(farms[i][j] != '.')
      |                            ^~~~~
a.cc:24:58: error: invalid types 'char[int]' for array subscript
   24 |                                 dfs(values,H,W,i,j,values[i][j]);
      |                                                          ^
a.cc: In function 'int main()':
a.cc:40:36: error: 'value' was not declared in this scope; did you mean 'values'?
   40 |                 printf("%d", solve(value,H,W));
      |                                    ^~~~~
      |                                    values
Language: C++

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

/*
void dfs(char values,int H,int W,int x, int y,int item)
{
	if(x<0 || H<=x) return;
	if(y<0 || W<=y) return;
	if(values[x][y]!=item) return;
	farms[x][y] = '.';
	dfs(values,H,W,x+1,y,item);
	dfs(values,H,W,x-1,y,item);
	dfs(values,H,W,x,y+1,item);
	dfs(values,H,W,x,y-1,item);
}


int solve(char values,int H,int W){
	int res = 0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(farms[i][j] != '.')
			{
				dfs(values,H,W,i,j,values[i][j]);
				res++;
			}
	return res;
}
*/
int main()
{
	int H, W;
	cin >> H >> W;
	char values[101][101];
	while (!(H == 0 && W == 0))
	{
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				cin >> values[i][j];
		printf("%d", solve(value,H,W));
		cin >> H >> W;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:36: error: 'value' was not declared in this scope; did you mean 'values'?
   41 |                 printf("%d", solve(value,H,W));
      |                                    ^~~~~
      |                                    values
a.cc:41:30: error: 'solve' was not declared in this scope
   41 |                 printf("%d", solve(value,H,W));
      |                              ^~~~~
Language: C++

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

/*
void dfs(char values,int H,int W,int x, int y,int item)
{
	if(x<0 || H<=x) return;
	if(y<0 || W<=y) return;
	if(values[x][y]!=item) return;
	farms[x][y] = '.';
	dfs(values,H,W,x+1,y,item);
	dfs(values,H,W,x-1,y,item);
	dfs(values,H,W,x,y+1,item);
	dfs(values,H,W,x,y-1,item);
}


int solve(char values,int H,int W){
	int res = 0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(farms[i][j] != '.')
			{
				dfs(values,H,W,i,j,values[i][j]);
				res++;
			}
	return res;
}
*/
int main()
{
	int H, W;
	std::cin >> H >> W;
	char values[101][101];
	while (!(H == 0 && W == 0))
	{
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				std::cin >> values[i][j];
		std::cout << solve(value,H,W) << std::endl;
		std::cin >> H >> W;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:36: error: 'value' was not declared in this scope; did you mean 'values'?
   41 |                 std::cout << solve(value,H,W) << std::endl;
      |                                    ^~~~~
      |                                    values
a.cc:41:30: error: 'solve' was not declared in this scope
   41 |                 std::cout << solve(value,H,W) << std::endl;
      |                              ^~~~~
Language: C++

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

/*
void dfs(char values,int H,int W,int x, int y,int item)
{
	if(x<0 && H<=x) return;
	if(y<0 && W<=y) return;
	if(values[x][y]!=item) return;
	farms[x][y] = '.';
	dfs(values,H,W,x+1,y,item);
	dfs(values,H,W,x-1,y,item);
	dfs(values,H,W,x,y+1,item);
	dfs(values,H,W,x,y-1,item);
}


int solve(char values,int H,int W){
	int res = 0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(farms[i][j] != '.')
			{
				dfs(values,H,W,i,j,values[i][j]);
				res++;
			}
	return res;
}
*/
int main()
{
	int H, W;
	std::cin >> H >> W;
	char values[101][101];
	while (!(H == 0 && W == 0))
	{
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				std::cin >> values[i][j];
		std::cout << solve(values,H,W) << std::endl;
		std::cin >> H >> W;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:30: error: 'solve' was not declared in this scope
   41 |                 std::cout << solve(values,H,W) << std::endl;
      |                              ^~~~~
Language: C++

#include <stdio.h>

/*
void dfs(char values,int H,int W,int x, int y,int item)
{
	if(x<0 && H<=x) return;
	if(y<0 && W<=y) return;
	if(values[x][y]!=item) return;
	farms[x][y] = '.';
	dfs(values,H,W,x+1,y,item);
	dfs(values,H,W,x-1,y,item);
	dfs(values,H,W,x,y+1,item);
	dfs(values,H,W,x,y-1,item);
}


int solve(char values,int H,int W){
	int res = 0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(farms[i][j] != '.')
			{
				dfs(values,H,W,i,j,values[i][j]);
				res++;
			}
	return res;
}
*/
int main()
{
	int H, W;
	std::cin >> H >> W;
	char values[101][101];
	while (!(H == 0 && W == 0))
	{
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				std::cin >> values[i][j];
		std::cout << solve(values,H,W) << std::endl;
		std::cin >> H >> W;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:14: error: 'cin' is not a member of 'std'
   32 |         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 <stdio.h>
  +++ |+#include <iostream>
    2 | 
a.cc:38:38: error: 'cin' is not a member of 'std'
   38 |                                 std::cin >> values[i][j];
      |                                      ^~~
a.cc:38:38: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:22: error: 'cout' is not a member of 'std'
   39 |                 std::cout << solve(values,H,W) << std::endl;
      |                      ^~~~
a.cc:39:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:30: error: 'solve' was not declared in this scope
   39 |                 std::cout << solve(values,H,W) << std::endl;
      |                              ^~~~~
a.cc:39:56: error: 'endl' is not a member of 'std'
   39 |                 std::cout << solve(values,H,W) << std::endl;
      |                                                        ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <stdio.h>
  +++ |+#include <ostream>
    2 | 
a.cc:40:22: error: 'cin' is not a member of 'std'
   40 |                 std::cin >> H >> W;
      |                      ^~~
a.cc:40:22: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <stdio.h>

/*
void dfs(char values,int H,int W,int x, int y,int item)
{
	if(x<0 && H<=x) return;
	if(y<0 && W<=y) return;
	if(values[x][y]!=item) return;
	farms[x][y] = '.';
	dfs(values,H,W,x+1,y,item);
	dfs(values,H,W,x-1,y,item);
	dfs(values,H,W,x,y+1,item);
	dfs(values,H,W,x,y-1,item);
}


int solve(char values,int H,int W){
	int res = 0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(farms[i][j] != '.')
			{
				dfs(values,H,W,i,j,values[i][j]);
				res++;
			}
	return res;
}
*/
int main()
{
	int H, W;
	std::cin >> H >> W;
	char values[101][101];
	while (!(H == 0 && W == 0))
	{
	/*
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				std::cin >> values[i][j];
		std::cout << solve(values,H,W) << std::endl;
		std::cin >> H >> W;
	*/
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:14: error: 'cin' is not a member of 'std'
   32 |         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 <stdio.h>
  +++ |+#include <iostream>
    2 |
Language: C++

import sys
sys.setrecursionlimit(100000)

fields = []
i = 0
H, W = 0, 0
field = []
for line in sys.stdin:
	line = line.rstrip()
	if line[0] not in ["#", "@", "*"]:
		line = line.split(" ")
		tmpH = H
		tmpW = W
		H = int(line[0])
		W = int(line[1])
		if (len(field) != 0):
			fields.append([field, tmpH, tmpW])
			field = []
		if (H == 0 and W == 0):
			break

	else:
		field.append(list(line))
	i += 1

def dfs(x, y, fruit):
	field[x][y] = "0"
	for dx in [-1, 0, 1]:
		if dx == -1: width = [0]
		if dx == 0: width = [-1, 0, 1]
		if dx == 1: width = [0]
		for dy in width:
			nx = x+dx
			ny = y+dy
			inField = (0 <= nx) and (0 <= ny) and (nx < H) and (ny < W)
			if inField and field[nx][ny] == fruit:
				dfs(nx, ny, fruit)
print(fields)
count = 0
for field_info in fields:
	field = field_info[0]
	H = field_info[1]
	W = field_info[2]
	for x in range(H):
		for y in range(W):
			if (field[x][y] != "0"):
				dfs(x, y, field[x][y])
				count += 1
	print(count)
	count = 0

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>
using namespace std;
/*
void dfs(char values,int H,int W,int x, int y,int item)
{
	if(x<0 && H<=x) return;
	if(y<0 && W<=y) return;
	if(values[x][y]!=item) return;
	farms[x][y] = '.';
	dfs(values,H,W,x+1,y,item);
	dfs(values,H,W,x-1,y,item);
	dfs(values,H,W,x,y+1,item);
	dfs(values,H,W,x,y-1,item);
}


int solve(char values,int H,int W){
	int res = 0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(farms[i][j] != '.')
			{
				dfs(values,H,W,i,j,values[i][j]);
				res++;
			}
	return res;
}
*/
int main()
{
	int H, W;
	std::cin >> H >> W;
	char values[101][101];
	while (!(H == 0 && W == 0))
	{
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				std::cin >> values[i][j];
		std::cout << solve(values,H,W) << std::endl;
		std::cin >> H >> W;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:30: error: 'solve' was not declared in this scope
   39 |                 std::cout << solve(values,H,W) << std::endl;
      |                              ^~~~~
Language: C++

import sys
sys.setrecursionlimit(100000000)


def main():
    process()


def process():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if -1 < a < H:
            pass
        else:
            continue
        for b in xrange(j-1, j+2):
            if -1 < b < W:
                pass
            else:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue
            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()

Compiler output:
a.cc:65:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   65 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>

using namespace std;

int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
char table[100][100];

void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) {
  char cur = table[x][y];
  table[x][y] = 'X';
  for (int i = 0; i < 4; ++i) {
    int next_x = x + dir[i][0];
    int next_y = y + dir[i][1];
    if (next_x >= 0 && next_x < w
        && next_y >=0 && next_y < h
        && table[next_x][next_y] == cur) {
        Dfs(table, h, w, next_x, next_y);
    }
  }
}

int main() {
  int h, w;
  while (cin >> h >> w) {
    if (h == 0 || w == 0) break;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> table[i][j];
      }
    }
    int ret = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (table[i][j] != 'X') {
          Dfs(table, h, w, i, j);
          ++ret;
        }
      }
    }
    cout << ret << endl;
  }
  return 0;
}

Compiler output:
a.cc:8:6: error: variable or field 'Dfs' declared void
    8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) {
      |      ^~~
a.cc:8:10: error: 'vector' was not declared in this scope
    8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) {
      |          ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
a.cc:8:17: error: 'vector' was not declared in this scope
    8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) {
      |                 ^~~~~~
a.cc:8:17: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:8:24: error: expected primary-expression before 'char'
    8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) {
      |                        ^~~~
a.cc:8:40: error: expected primary-expression before 'int'
    8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) {
      |                                        ^~~
a.cc:8:47: error: expected primary-expression before 'int'
    8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) {
      |                                               ^~~
a.cc:8:54: error: expected primary-expression before 'int'
    8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) {
      |                                                      ^~~
a.cc:8:61: error: expected primary-expression before 'int'
    8 | void Dfs(vector<vector<char> >& table, int h, int w, int x, int y) {
      |                                                             ^~~
a.cc: In function 'int main()':
a.cc:35:11: error: 'Dfs' was not declared in this scope
   35 |           Dfs(table, h, w, i, j);
      |           ^~~
Language: C++

#include<iostream>  
 
using namespace std;  
   
char table[100][100];  
int W, H;  
const int direction[4][2] = {{ -1, 0 },  { 1, 0 },  { 0, -1 },  { 0, 1 }};  
   
void dfs(int x, int y, char cur)  
{  
  table[x][y] = 'x';  
  for (int i = 0; i < 4; ++i)  
  {  
    int nx = x + direction[i][0];  
    int ny = y + direction[i][1];  
    if (nx >= 0 && nx < W && ny >= 0 && ny < H && table[nx][ny] == tree)  
    {  
      dfs(nx, ny, tree);  
    }  
  }  
}  
   
int main()  
{  
   
  while (cin >> H >> W, W > 0)  
  {  
    int res = 0;  
    int x, y;  
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        cin >> table[x][y];  
      }  
    }  
   
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        if (table[x][y] != 'x')  
        {  
          dfs(x, y, table[x][y]);  
          ++res;  
        }  
      }  
    }  
    cout << res << endl;  
  }  
  return 0;  
} 

Compiler output:
a.cc: In function 'void dfs(int, int, char)':
a.cc:16:68: error: 'tree' was not declared in this scope; did you mean 'free'?
   16 |     if (nx >= 0 && nx < W && ny >= 0 && ny < H && table[nx][ny] == tree)
      |                                                                    ^~~~
      |                                                                    free
Language: C++

#include<iostream>  
 
using namespace std;  
   
char table[100][100];  
int W, H;  
const int direction[4][2] = {{ -1, 0 },  { 1, 0 },  { 0, -1 },  { 0, 1 }};  
   

void Dfs(int x, int y, char cur) {
  table[x][y] = 'X';
  for (int i = 0; i < 4; ++i) {
    int next_x = x + dir[i][0];
    int next_y = y + dir[i][1];
    if (next_x >= 0 && next_x < w
        && next_y >=0 && next_y < h
        && table[next_x][next_y] == cur) {
        Dfs(next_x, next_y, cur);
    }
  }
}

int main()  
{  
   
  while (cin >> H >> W, W > 0)  
  {  
    int res = 0;  
    int x, y;  
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        cin >> table[x][y];  
      }  
    }  
   
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        if (table[x][y] != 'x')  
        {  
          Dfs(x, y, table[x][y]);  
          ++res;  
        }  
      }  
    }  
    cout << res << endl;  
  }  
  return 0;  
} 

Compiler output:
a.cc: In function 'void Dfs(int, int, char)':
a.cc:13:22: error: 'dir' was not declared in this scope; did you mean 'div'?
   13 |     int next_x = x + dir[i][0];
      |                      ^~~
      |                      div
a.cc:15:33: error: 'w' was not declared in this scope
   15 |     if (next_x >= 0 && next_x < w
      |                                 ^
a.cc:16:35: error: 'h' was not declared in this scope
   16 |         && next_y >=0 && next_y < h
      |                                   ^
Language: C++

#include<iostream>  
 
using namespace std;  
   
char table[100][100];  
int W, H;  
const int dir[4][2] = {{ -1, 0 },  { 1, 0 },  { 0, -1 },  { 0, 1 }};  
   

void Dfs(int x, int y, char cur) {
  table[x][y] = 'X';
  for (int i = 0; i < 4; ++i) {
    int next_x = x + dir[i][0];
    int next_y = y + dir[i][1];
    if (next_x >= 0 && next_x < w
        && next_y >=0 && next_y < h
        && table[next_x][next_y] == cur) {
        Dfs(next_x, next_y, cur);
    }
  }
}

int main()  
{  
   
  while (cin >> H >> W, W > 0)  
  {  
    int res = 0;  
    int x, y;  
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        cin >> table[x][y];  
      }  
    }  
   
    for (y = 0; y < H; ++y)  
    {  
      for (x = 0; x < W; ++x)  
      {  
        if (table[x][y] != 'x')  
        {  
          Dfs(x, y, table[x][y]);  
          ++res;  
        }  
      }  
    }  
    cout << res << endl;  
  }  
  return 0;  
} 

Compiler output:
a.cc: In function 'void Dfs(int, int, char)':
a.cc:15:33: error: 'w' was not declared in this scope
   15 |     if (next_x >= 0 && next_x < w
      |                                 ^
a.cc:16:35: error: 'h' was not declared in this scope
   16 |         && next_y >=0 && next_y < h
      |                                   ^
Language: C++

#include<iostream>
using namespace std;

char Array[200000][200000];
int count;

void DFS(int h,int w,char c){

  if(Array[h][w] != c){
    return;
  }

  char tmp=Array[h][w];

  Array[h][w] = '.';

  DFS(h-1,w,tmp);
  DFS(h,w+1,tmp);
  DFS(h+1,w,tmp);
  DFS(h,w-1,tmp);

}

int main(){
    int H,W;

    while(1){
      cin >> H >> W;
      if(H == 0 && W == 0){
        break;
      }
      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
          cin >> Array[i][j];
        }
      }

      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
          if(Array[i][j] != '.'){
            count++;
            DFS(i,j,Array[i][j]);
          }
        }
      }
      cout << count << endl;

  }
    return 0;
}

Compiler output:
/tmp/ccgoxiMR.o: in function `main':
a.cc:(.text+0x1bc): relocation truncated to fit: R_X86_64_PC32 against symbol `count' defined in .bss section in /tmp/ccgoxiMR.o
a.cc:(.text+0x1c5): relocation truncated to fit: R_X86_64_PC32 against symbol `count' defined in .bss section in /tmp/ccgoxiMR.o
a.cc:(.text+0x21b): relocation truncated to fit: R_X86_64_PC32 against symbol `count' defined in .bss section in /tmp/ccgoxiMR.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
using namespace std;

char T[102][102];

void DFS(int y,int x,char f){

	if(T[y][x]!=f)
		return;

	T[y][x]='?';

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

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

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>T[i][j];
		}
	}

	int count=0;
	
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(T[i][j]=='@'){
				count++;
				DFS(i,j,@);
			}
		}

	}

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(T[i][j]=='#'){
				count++;
				DFS(i,j,#);
			}
		}

	}

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(T[i][j]=='*'){
				count++;
				DFS(i,j,*);
			}
		}

	}

	cout<<count<<endl;

	return 0;
}

Compiler output:
a.cc:40:41: error: stray '@' in program
   40 |                                 DFS(i,j,@);
      |                                         ^
a.cc:50:41: error: stray '#' in program
   50 |                                 DFS(i,j,#);
      |                                         ^
a.cc: In function 'int main()':
a.cc:40:42: error: expected primary-expression before ')' token
   40 |                                 DFS(i,j,@);
      |                                          ^
a.cc:50:42: error: expected primary-expression before ')' token
   50 |                                 DFS(i,j,#);
      |                                          ^
a.cc:60:42: error: expected primary-expression before ')' token
   60 |                                 DFS(i,j,*);
      |                                          ^
Language: C++

#include<iostream>
using namespace std;

char HW[101][101];

void DFS(int Y,int X,char c)
{
	if(HW[Y][X]=='0'||HW[Y][X]!=c)
		return;

	HW[Y][X]='0';
	
	DFS(Y-1,X,c);
	DFS(Y,X+1,c);
	DFS(Y+1,X,c);
	DFS(Y,X-1,c);
}	
	
int main()
{
	int H,W;
	while(1){
		cin>>H>>W;

		if(H==0&&W==0)
			break;

		for(int y=1;y<=H+1;y++){
			for(int x=1;x<=W;x++){
				cin>>HW[y][x];
	
		int count=0;
		for(int y=1;y<=H;y++){
			for(int x=1;x<=W;x++){
				if((HW[y][x]=='@')||(HW[y][x]=='#')||(HW[y][x]=='*')){
					count++;
					DFS(y,x,HW[y][x]);
					}
			}
		}
	
		cout<<count<<endl;
	}

	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:46:2: error: expected '}' at end of input
   46 | }
      |  ^
a.cc:22:17: note: to match this '{'
   22 |         while(1){
      |                 ^
a.cc:46:2: error: expected '}' at end of input
   46 | }
      |  ^
a.cc:20:1: note: to match this '{'
   20 | {
      | ^
Language: C++

#include<iostream>
#include<algorithm>
#include<utility>
#include<cmath>
#include<string>

using namespace std;

char map[101][101];

void dfs(int x,int y,char a){
  if(x>a||x<0){
    return;
  }
  else if(y>b||y<0){
    return;
  }

  if(map[x][y]== a){
    map[x][y]='x';
  }
  else{
    return;
  }

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

int main(){
  int a,b;
  int ans;
  ans=0;
  
  while(cin>>a>>b){
  if(a==0&&b==0){
    return 0;
  }
  	
  for(int i=0;i<a;i++){
    for(int j=0;j<b;i++){
      cin >> map[i][j];
    }
  }


  for(int i=0;i<a;i++){
    for(int j=0;j<b;i++){
      if(map[i][j]!='x'){
	dfs(i,j,map[i][j]);
	ans+=1;
      }
    }
  }
  }
  cout << ans << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, char)':
a.cc:15:13: error: 'b' was not declared in this scope
   15 |   else if(y>b||y<0){
      |             ^
Language: C++

#include<iostream>
#include<algorityhm>

using namespace std;

int x,y;

int map(int a,int b,char s){
  if(a>x||a<0){
    return;
  }
  if(b>y||b<0){
    return;
  }
  if(s=='@'||s=='#'||s=='*'){
    s='X';
  }
  if(s!='X'){  
  map(a+1,b,s);
  map(a-1,b,s);
  map(a,b-1,s);
  map(a,b+1,s);
  }
}
  
  
int main(){
  
  char t[100][100];
  
  while(cin>>x>>y){
    if(x==0&&y==0){
      return 0;
    }
    int ans=0;
    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
	cin>>t[i][j];
      }
    }
    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
	if(t[i][j]!='X'){
	  map(i,j,t[i][j]);
      }
	else{
	  ans+=1;
	}
      }
    }
      cout << ans << endl;
  }
	return 0;
}

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

#include<iostream>

using namespace std;

int x,y;

int map(int a,int b,char s){
  if(a>x||a<0){
    return;
  }
  if(b>y||b<0){
    return;
  }
  if(s=='@'||s=='#'||s=='*'){
    s='X';
  }
  if(s!='X'){  
  map(a+1,b,s);
  map(a-1,b,s);
  map(a,b-1,s);
  map(a,b+1,s);
  }
}
  
  
int main(){
  
  char t[100][100];
  
  while(cin>>x>>y){
    if(x==0&&y==0){
      return 0;
    }
    int ans=0;
    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
	cin>>t[i][j];
      }
    }
    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
	if(t[i][j]!='X'){
	  map(i,j,t[i][j]);
      }
	else{
	  ans+=1;
	}
      }
    }
      cout << ans << endl;
  }
	return 0;
}

Compiler output:
a.cc: In function 'int map(int, int, char)':
a.cc:9:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
    9 |     return;
      |     ^~~~~~
a.cc:12:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   12 |     return;
      |     ^~~~~~
a.cc:23:1: warning: control reaches end of non-void function [-Wreturn-type]
   23 | }
      | ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1000,inf=0x3f3f3f3f;
char maze[maxn][maxn];
int h,w,ans=0;
void dfs(int x,int y,char sig){
	maze[x][y]='.';
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(i*j==0){
				int nx=x+i,ny=y+j;
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&maze[nx][ny]==sig)
					dfs(nx,ny,sig);
			}
		}
	}
}
int main()
{
	//freopen("read.txt", "r", stdin);
	while(cin>>h>>w&&h&&w){
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				cin>>maze[i][j];
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++){
				if(maze[i][j]!='.'){
					char c=maze[i][j];
					dfs(i,j,c);
					ans++;
				}
			}
		cout<<ans<<endl;
                ans=0
	}
	//fclose(stdin);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:22: error: expected ';' before '}' token
   36 |                 ans=0
      |                      ^
      |                      ;
   37 |         }
      |         ~
Language: C++

def infection(i, j,H, W, moji):
    if farm[i][j] == moji:
        farm[i][j] = '+'
        if j + 1 < W : infection(i, j + 1,H,W,moji)
        if i + 1 < H : infection(i + 1, j,H,W,moji)
        if j - 1 >= 0 :infection(i, j - 1,H,W,moji)
        if i - 1 >= 0 :infection(i - 1, j,H,W,moji)

while(1):
    farm = []
    cnt = 0
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0: break

    for i in range(H):
        farm.append(list(input()))

    for i in range(H):
        for j in range(W):
            if farm[i][j] == '+': continue
            cnt += 1
            infection(i, j,H,W,moji)
    print(cnt)

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def infection(i, j,H, W, moji):
      | ^~~
Language: C++

#include <stdio.h>
#include <string.h>
int k,t=0;
char a[100][100];
void bfs(int i,int j,int n,int m,char x)
{
	k=0;
	if (i<0||j<0||i>=n||j>=m||a[i][j]=='\0'||a[i][j]!=x) return ;
	a[i][j]='\0';
	bfs(i-1,j,n,m,x);
	bfs(i+1,j,n,m,x);
	bfs(i,j-1,n,m,x);
	bfs(i,j+1,n,m,x);
	k++;
}
int main (void)
{
	int n,m,i,j;
	while (scanf ("%d%d",&n,&m)!=EOF)
	{
		if (n==0&&m==0) return 0;
		getchar();
		for (i=0;i<n;i++)
		gets(a[i]);
		for (i=0;i<n;i++)
		for (j=0;j<m;j++)
		{
			bfs(i,j,n,m,a[i][j]);
			if (k!=0) t++;
		}
		printf ("%d\n",t);
	}
	return 0;
}


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

#include<iostream>
#include<algorithm>
#include<cstring>
char arr[105][105],temp;
int n,m;
int direction[4][2]={{0,1},{-1,0},{0,-1},{1,0}};

using namespace std;

void bfs(int i,int j)
{
   	if(i<0||i>=m||j<0||j>=n)
   	   return;
   	if(arr[i][j]!=temp)
   	   return;
   	arr[i][j]='.';
   	for(int k=0;k<4;k++)
   	   bfs(i+direction[k][0],j+direction[k][1]);	
}

int main()
{

	while(scanf("%d%d",&m,&n)==2&&m!=0&&n!=0)
	{
		int cnt=0;
		getchar();
		for(int i=0;i<m;i++)
		   gets(arr[i]);
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(arr[i][j]!='.')
				{
				  temp=arr[i][j];
				  bfs(i,j);
				  cnt++;
			    }
			}
		}
		cout << cnt <<endl;
	}
}


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