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(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:88:16: error: no matching function for call to 'min(std::vector<std::vector<long long int> >::size_type, long long int)'
   88 |     int x = min(s.size(),h*w)
      |             ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:88:16: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long int')
   88 |     int x = min(s.size(),h*w)
      |             ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:88:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   88 |     int x = min(s.size(),h*w)
      |             ~~~^~~~~~~~~~~~~~
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){
      |                  ^~~~