Language: C++

int main(){
	int n,m,x=0;
	std::cin>>n>>m;
	std::vector< std::vector <bool> > masu(n*m);

	for(int f=0;f<n;f++){
		for(int c=0;c<m;c++){
			masu[f][c]=!masu[f][c];

			if(f==0&&c==0){
				if(f<n-1){masu[f+1][c]=!masu[f+1][c];}
				if(c<m-1){masu[f][c+1]=!masu[f][c+1];}
				if(f<n-1&&c<m-1){masu[f+1][c+1]=!masu[f+1][c+1];}
			}

			else{
				if(f==0){
					if(c<m-1){
						masu[f][c-1]=!masu[f][c-1];
						masu[f][c+1]=!masu[f][c+1];
						if(f<n-1){
							masu[f+1][c-1]=!masu[f+1][c-1];
							masu[f+1][c]=!masu[f+1][c];
							masu[f+1][c+1]=!masu[f+1][c+1];
						}
					}
				}

				else if(c==0){
					if(f<n-1){
						masu[f-1][c]=!masu[f-1][c];
						masu[f+1][c]=!masu[f+1][c];
						if(c<m-1){
							masu[f-1][c+1]=!masu[f-1][c+1];
							masu[f][c+1]=!masu[f][c+1];
							masu[f+1][c+1]=!masu[f+1][c+1];
						}
					}
				}

				else{
					if(f<n-1&&c<m-1){
						masu[f-1][c-1]=!masu[f-1][c-1];
						masu[f-1][c]=!masu[f-1][c];
						masu[f-1][c+1]=!masu[f-1][c+1];
						masu[f][c-1]=!masu[f][c-1];
						masu[f][c+1]=!masu[f][c+1];
						masu[f+1][c-1]=!masu[f+1][c-1];
						masu[f+1][c]=!masu[f+1][c];
						masu[f+1][c+1]=!masu[f+1][c+1];
					}
					else if(f<n-1){
						masu[f-1][c-1]=!masu[f-1][c-1];
						masu[f-1][c]=!masu[f-1][c];
						masu[f][c-1]=!masu[f][c-1];
						masu[f+1][c-1]=!masu[f+1][c-1];
						masu[f+1][c]=!masu[f+1][c];
					}
					else if(c<m-1){
						masu[f][c-1]=!masu[f][c-1];
						masu[f-1][c-1]=!masu[f-1][c-1];
						masu[f-1][c]=!masu[f-1][c];
						masu[f-1][c+1]=!masu[f-1][c+1];
						masu[f][c+1]=!masu[f][c+1];
					}
				}
			}
		}
	}

	for(int f=0;f<n;f++){
		for(int c=0;c<m;c++){
			x+=(masu[f][c]?1:0);
		}
	}

	std::cout<<x<<std::endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:14: error: 'cin' is not a member of 'std'
    3 |         std::cin>>n>>m;
      |              ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | int main(){
a.cc:4:14: error: 'vector' is not a member of 'std'
    4 |         std::vector< std::vector <bool> > masu(n*m);
      |              ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | int main(){
a.cc:4:27: error: 'vector' is not a member of 'std'
    4 |         std::vector< std::vector <bool> > masu(n*m);
      |                           ^~~~~~
a.cc:4:27: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:4:35: error: expected primary-expression before 'bool'
    4 |         std::vector< std::vector <bool> > masu(n*m);
      |                                   ^~~~
a.cc:8:25: error: 'masu' was not declared in this scope
    8 |                         masu[f][c]=!masu[f][c];
      |                         ^~~~
a.cc:73:29: error: 'masu' was not declared in this scope
   73 |                         x+=(masu[f][c]?1:0);
      |                             ^~~~
a.cc:77:14: error: 'cout' is not a member of 'std'
   77 |         std::cout<<x<<std::endl;
      |              ^~~~
a.cc:77:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:77:28: error: 'endl' is not a member of 'std'
   77 |         std::cout<<x<<std::endl;
      |                            ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | int main(){