Language: C++

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.*;
  
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] map=new char[h][w];
for(int i=0;i<h;i++){
map[i]=br.readLine().toCharArray();
}
Deque <Point> fifo  =new  ArrayDeque<Point>();
            int ans=0;
            for(int m=0;m<h;m++){
                for(int n=0;n<w;n++){
            if(map[m][n]!='.'){
                ans++;
                Point p = new Point(n,m);
                fifo.addLast(p);
            while(fifo.peekFirst()!=null){
                p=fifo.pollFirst();
                int x=p.x;
                int y=p.y;
                char crop = map[y][x];
                map[y][x]='.';
                int [] dx ={0,1,0,-1};
                int [] dy ={1,0,-1,0};
                   
                for(int i=0;i<4;i++){
                    int nx =x+dx[i];
                    int ny =y+dy[i];
                    if(map[ny][nx]==crop&&map[ny][nx]!='.'&&nx>=0&&nx<w&&ny>=0&&ny<h){                        Point np = new Point();
                        np.x=nx;
                        np.y=ny;
                     fifo.addLast(np);                       
}
}
}
}
}
}System.out.println(ans);
}
}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.BufferedReader;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.IOException;
      | ^~~~~~
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.io.InputStreamReader;
      | ^~~~~~
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.awt.Point;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.*;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:7: error: expected ':' before 'static'
    8 | public static void main(String[] args) throws IOException{
      |       ^~~~~~~
      |       :
a.cc:8:25: error: 'String' has not been declared
    8 | public static void main(String[] args) throws IOException{
      |                         ^~~~~~
a.cc:8:34: error: expected ',' or '...' before 'args'
    8 | public static void main(String[] args) throws IOException{
      |                                  ^~~~
a.cc:8:38: error: expected ';' at end of member declaration
    8 | public static void main(String[] args) throws IOException{
      |                                      ^
      |                                       ;
a.cc:8:40: error: 'throws' does not name a type
    8 | public static void main(String[] args) throws IOException{
      |                                        ^~~~~~
a.cc:51:2: error: expected ';' after class definition
   51 | }
      |  ^
      |  ;