Language: C++

#include <iostream>

void change(long long *a)
{
  if(*a ==1){
  	*a = 0;
  }
  else if(*a == 0)
  {
    *a=1;
  }
    
}

int main(void)
{
	long long M,N;
  	std::cin >> N;
  	std::cin >> M;
  	long long answer;
  	long long mat[N][M];
 	
  	for(int i=0;i<N;i++)
    {
      for(int j=0;j<M;j++){
      	mat[i][j] = 0;
      }
    }
  
  for(int i=0;i<N;i++)
    {
      for(int j=0;j<M;j++){
        if(i-1>0 && j-1>0){
      	change(mat[i-1][j-1]);
        
        if(j-1>0)
        change(mat[i][j-1]);
        if(j-1>0 && i+1<N)
        change(mat[i+1][j-1]);
        if(i-1>0)
        change(mat[i-1][j]);
        
        change(mat[i][j]);
        if(i+1<N)
        change(mat[i+1][j]);
        if(i-1>0 && j+1<M)
        change(mat[i-1][j+1]);
        if(j+1<M)
        change(mat[i][j+1]);
        if(i+1<N && j+1<M)
        change(mat[i+1][j+1]);
        
      }
    }
  
    for(int i=0;i<N;i++)
    {
      for(int j=0;j<M;j++){
      	if(mat[i][j] == 1){
        	answer++;
        }
      }
    }
    
    std::cout << answer << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:28: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   34 |         change(mat[i-1][j-1]);
      |                ~~~~~~~~~~~~^
      |                            |
      |                            long long int
a.cc:3:24: note:   initializing argument 1 of 'void change(long long int*)'
    3 | void change(long long *a)
      |             ~~~~~~~~~~~^
a.cc:37:26: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   37 |         change(mat[i][j-1]);
      |                ~~~~~~~~~~^
      |                          |
      |                          long long int
a.cc:3:24: note:   initializing argument 1 of 'void change(long long int*)'
    3 | void change(long long *a)
      |             ~~~~~~~~~~~^
a.cc:39:28: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   39 |         change(mat[i+1][j-1]);
      |                ~~~~~~~~~~~~^
      |                            |
      |                            long long int
a.cc:3:24: note:   initializing argument 1 of 'void change(long long int*)'
    3 | void change(long long *a)
      |             ~~~~~~~~~~~^
a.cc:41:26: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   41 |         change(mat[i-1][j]);
      |                ~~~~~~~~~~^
      |                          |
      |                          long long int
a.cc:3:24: note:   initializing argument 1 of 'void change(long long int*)'
    3 | void change(long long *a)
      |             ~~~~~~~~~~~^
a.cc:43:24: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   43 |         change(mat[i][j]);
      |                ~~~~~~~~^
      |                        |
      |                        long long int
a.cc:3:24: note:   initializing argument 1 of 'void change(long long int*)'
    3 | void change(long long *a)
      |             ~~~~~~~~~~~^
a.cc:45:26: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   45 |         change(mat[i+1][j]);
      |                ~~~~~~~~~~^
      |                          |
      |                          long long int
a.cc:3:24: note:   initializing argument 1 of 'void change(long long int*)'
    3 | void change(long long *a)
      |             ~~~~~~~~~~~^
a.cc:47:28: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   47 |         change(mat[i-1][j+1]);
      |                ~~~~~~~~~~~~^
      |                            |
      |                            long long int
a.cc:3:24: note:   initializing argument 1 of 'void change(long long int*)'
    3 | void change(long long *a)
      |             ~~~~~~~~~~~^
a.cc:49:26: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   49 |         change(mat[i][j+1]);
      |                ~~~~~~~~~~^
      |                          |
      |                          long long int
a.cc:3:24: note:   initializing argument 1 of 'void change(long long int*)'
    3 | void change(long long *a)
      |             ~~~~~~~~~~~^
a.cc:51:28: error: invalid conversion from 'long long int' to 'long long int*' [-fpermissive]
   51 |         change(mat[i+1][j+1]);
      |                ~~~~~~~~~~~~^
      |                            |
      |                            long long int
a.cc:3:24: note:   initializing argument 1 of 'void change(long long int*)'
    3 | void change(long long *a)
      |             ~~~~~~~~~~~^
a.cc:66:2: error: expected '}' at end of input
   66 | }
      |  ^
a.cc:16:1: note: to match this '{'
   16 | {
      | ^