Language: C++

#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


signed main(){
    int h,w;
    cin >> h >> w;
    twovec(a,h,w);
    REP(i,h){
        REP(j,w){
            cin >> a[i][j];
        }
    }
    vector<vector<int>> s;
    REP(i,h){
        REP(j,w){
            if(i%2==0){
                if(a[i][j]%2==1 && j != w-1){
                    //s.push_back(i+1 + ' ' + j+1 + " " + i+1 + " " + j+2);
                    s.push_back({i+1,j+1,i+1,j+2});
                    //cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
                    a[i][j+1]++;
                }
                else if(a[i][j]%2==1 && j == w-1 && i != h-1){
                    //s.push_back(i+1 + " " + j+1 + " " + i+2 + " " + j+1);
                    s.push_back({i+1,j+1,i+2,j+1});
                    //cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
                    a[i+1][j]++;
                }
            }
            else{
                if(a[i][w-1-j]%2==1 && j != w-1){
                    //s.push_back(i+1 + " " + w-j + " " + i+1 + " " + w-1-j);
                    s.push_back({i+1,w-j,i+1,w-1-j});
                    //cout << i+1 << " " << w-j << " " << i+1 << " " << w-1-j << endl;
                    a[i][w-2-j]++;
                }
            }
        }
    }
    int x = min((int)s.size(),h*w)
    print(x);
    REP(i,x){
        cout << s[i][0] << " " << s[i][1] << " " << s[i][2] << " " << s[i][3] << endl;
    }

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Compiler output:
a.cc:19:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   19 | void Debug(auto a);
      |            ^~~~
a.cc:20:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   20 | int nibul(auto a,auto b);
      |           ^~~~
a.cc:20:18: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   20 | int nibul(auto a,auto b);
      |                  ^~~~
a.cc:21:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | int nibuu(auto a,auto b);
      |           ^~~~
a.cc:21:18: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | int nibuu(auto a,auto b);
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:15:18: error: expected ',' or ';' before 'cout'
   15 | #define print(a) cout << (a) << endl;
      |                  ^~~~
a.cc:89:5: note: in expansion of macro 'print'
   89 |     print(x);
      |     ^~~~~
a.cc: At global scope:
a.cc:97:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   97 | void Debug(auto a){
      |            ^~~~
a.cc:104:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
  104 | int nibul(auto a,auto b){
      |           ^~~~
a.cc:104:18: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
  104 | int nibul(auto a,auto b){
      |                  ^~~~
a.cc:109:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
  109 | int nibuu(auto a,auto b){
      |           ^~~~
a.cc:109:18: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
  109 | int nibuu(auto a,auto b){
      |                  ^~~~