Language: C++

import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();

		boolean map[][] = new boolean[N][M];

		for(int n=0;n<N;n++){
			for(int m=0;m<M;m++){
				map[n][m] = true;
			}
		}

		for(int n=0;n<N;n++){
			for(int m=0;m<M;m++){		

				if(n!=0 && m!=0)			
				map[n-1][m-1] = !map[n-1][m-1];

				if(n!=0)
				map[n-1][m] = !map[n-1][m];

				if(n!=0 && m!=M-1)
				map[n-1][m+1] = !map[n-1][m+1];

				if(m!=0)
				map[n][m-1] = !map[n][m-1];

				map[n][m] = !map[n][m];

				if(m!=M-1)
				map[n][m+1] = !map[n][m+1];

				if(n!=N-1 && m!=0)
				map[n+1][m-1] = !map[n+1][m-1];

				if(n!=N-1)
				map[n+1][m] = !map[n+1][m];

				if(n!=N-1 && m!=M-1)
				map[n+1][m+1] = !map[n+1][m+1];
			}	
		}

		int count = 0;
		for(int n=0;n<N;n++){
			for(int m=0;m<M;m++){
				if(!map[n][m]) count++;
			}	
		}

		System.out.println(count);

	}
}

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:5:15: error: expected ':' before 'static'
    5 |         public static void main(String args[]){
      |               ^~~~~~~
      |               :
a.cc:5:33: error: 'String' has not been declared
    5 |         public static void main(String args[]){
      |                                 ^~~~~~
a.cc:61:2: error: expected ';' after class definition
   61 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:7:17: error: 'Scanner' was not declared in this scope
    7 |                 Scanner sc = new Scanner(System.in);
      |                 ^~~~~~~
a.cc:9:25: error: 'sc' was not declared in this scope
    9 |                 int N = sc.nextInt();
      |                         ^~
a.cc:12:17: error: 'boolean' was not declared in this scope; did you mean 'bool'?
   12 |                 boolean map[][] = new boolean[N][M];
      |                 ^~~~~~~
      |                 bool
a.cc:16:33: error: 'map' was not declared in this scope
   16 |                                 map[n][m] = true;
      |                                 ^~~
a.cc:24:33: error: 'map' was not declared in this scope
   24 |                                 map[n-1][m-1] = !map[n-1][m-1];
      |                                 ^~~
a.cc:27:33: error: 'map' was not declared in this scope
   27 |                                 map[n-1][m] = !map[n-1][m];
      |                                 ^~~
a.cc:30:33: error: 'map' was not declared in this scope
   30 |                                 map[n-1][m+1] = !map[n-1][m+1];
      |                                 ^~~
a.cc:33:33: error: 'map' was not declared in this scope
   33 |                                 map[n][m-1] = !map[n][m-1];
      |                                 ^~~
a.cc:35:33: error: 'map' was not declared in this scope
   35 |                                 map[n][m] = !map[n][m];
      |                                 ^~~
a.cc:54:37: error: 'map' was not declared in this scope
   54 |                                 if(!map[n][m]) count++;
      |                                     ^~~
a.cc:58:17: error: 'System' was not declared in this scope
   58 |                 System.out.println(count);
      |                 ^~~~~~