Language: C++

#include <bits/stdc++.h>
using namespace std;

void reverse(int **cell, i, j) {
	if (cell[i][j] == 0) {
		cell[i][j] = 1;
	} else {
		cell[i][j] = 0;
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	int cell[N+1][M+1];
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (j-1 >= 1) {
				reverse(i, j-1);
				if (i-1 >= 1) {
					reverse(i-1, j-1);
				}
				if (i+1 <= N) {
					reverse(i+1, j-1);
				}
			}
			if (i-1 >= 1) {
				reverse(i-1, j);
			}
			if (i+1 <= M) {
				reverse(i+1, j);
			}

			if (j+1 <= M) {
				reverse(i, j+1);
				if (i-1 >= 1) {
					reverse(i-1, j+1);
				}
				if (i+1 <= N) {
					reverse(i+1, j+1);
				}
			}
		}
	}

	int sum = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			sum += cell[i][j];
		}
	}

	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc:4:26: error: 'i' has not been declared
    4 | void reverse(int **cell, i, j) {
      |                          ^
a.cc:4:29: error: 'j' has not been declared
    4 | void reverse(int **cell, i, j) {
      |                             ^
a.cc: In function 'void reverse(int**, int, int)':
a.cc:5:18: error: 'i' was not declared in this scope
    5 |         if (cell[i][j] == 0) {
      |                  ^
a.cc:5:21: error: 'j' was not declared in this scope; did you mean 'jn'?
    5 |         if (cell[i][j] == 0) {
      |                     ^
      |                     jn
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::reverse(_BIter, _BIter) [with _BIter = int]':
a.cc:19:12:   required from here
   19 |                                 reverse(i, j-1);
      |                                 ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1089:63: error: no matching function for call to '__iterator_category(int&)'
 1089 |       std::__reverse(__first, __last, std::__iterator_category(__first));
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65,
                 from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note: candidate: 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&) [with _Iter = int]':
/usr/include/c++/14/bits/stl_algo.h:1089:63:   required from 'void std::reverse(_BIter, _BIter) [with _BIter = int]'
 1089 |       std::__reverse(__first, __last, std::__iterator_category(__first));
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
a.cc:19:12:   required from here
   19 |                                 reverse(i, j-1);
      |                                 ~~~~~~~^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:239:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  239 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~