Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dx[] = { 1, -1, 0, 0 };
ll dy[] = { 0,0,1,-1 };
int H, W;
int field[510][510];
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> field[i][j];
		}
	}
	int a[H*W + 1], b[H*W + 1], c[H*W + 1], d[H*W + 1];
	int a, b, c, d;
	int cnt = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < 4; k++) {
				int ny = i + dy[k];
				int nx = j + dx[k];
				if (field[i][j] == 0) {
					continue;
				}
				if (ny >= 0 && ny < H && nx >= 0 && nx < W) {
					if (i == a && j == b { continue; }
					if (field[i][j] % 2 == 1 && field[ny][nx] % 2 == 1) {
						field[i][j]--;
						field[ny][nx]++;
						a[cnt] = i + 1, b[cnt] = j + 1, c[cnt] = ny + 1, d[cnt] = nx + 1;
						cnt++;
						break;
					}
					for (int m = 0; m <4; m++) {
						int sy = ny + dy[m];
						int sx = nx + dx[m];
						if (sy >= 0 && sy < H && sx >= 0 && sx < W) {
							if (sy == i && sx == j) { continue; }
							if (field[i][j] % 2 == 1 && field[ny][nx] % 2 == 0 && field[sy][sx] % 2 == 1) {

								field[i][j]--;
								field[ny][nx]++;
								a[cnt] = i + 1, b[cnt] = j + 1, c[cnt] = ny + 1, d[cnt] = nx + 1;

								cnt++;
								field[ny][nx]--;
								field[sy][sx]++;
								a = ny, b = nx;
								a[cnt] = ny + 1, b[cnt] = nx + 1, c[cnt] = sy + 1, d[cnt] = sx + 1;
								cnt++;
								break;
							}
						}
					}
				}
			}
		}
	}
	cout << cnt << endl;
	for (int i = 0; i < cnt; i++) {
		cout << a[i] << " " << b[i] << " " << c[i] << " " << d[i] << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:13: error: conflicting declaration 'int a'
   16 |         int a, b, c, d;
      |             ^
a.cc:15:13: note: previous declaration as 'int a [((H * W) + 1)]'
   15 |         int a[H*W + 1], b[H*W + 1], c[H*W + 1], d[H*W + 1];
      |             ^
a.cc:16:16: error: conflicting declaration 'int b'
   16 |         int a, b, c, d;
      |                ^
a.cc:15:25: note: previous declaration as 'int b [((H * W) + 1)]'
   15 |         int a[H*W + 1], b[H*W + 1], c[H*W + 1], d[H*W + 1];
      |                         ^
a.cc:16:19: error: conflicting declaration 'int c'
   16 |         int a, b, c, d;
      |                   ^
a.cc:15:37: note: previous declaration as 'int c [((H * W) + 1)]'
   15 |         int a[H*W + 1], b[H*W + 1], c[H*W + 1], d[H*W + 1];
      |                                     ^
a.cc:16:22: error: conflicting declaration 'int d'
   16 |         int a, b, c, d;
      |                      ^
a.cc:15:49: note: previous declaration as 'int d [((H * W) + 1)]'
   15 |         int a[H*W + 1], b[H*W + 1], c[H*W + 1], d[H*W + 1];
      |                                                 ^
a.cc:27:47: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 |                                         if (i == a && j == b { continue; }
      |                                             ~~^~~~
a.cc:27:57: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 |                                         if (i == a && j == b { continue; }
      |                                                       ~~^~~~
a.cc:27:61: error: expected ')' before '{' token
   27 |                                         if (i == a && j == b { continue; }
      |                                            ~                ^~
      |                                                             )
a.cc:35:57: error: 'm' was not declared in this scope
   35 |                                         for (int m = 0; m <4; m++) {
      |                                                         ^