Language: C++

#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll H,W;
ll d;
ll ans[600][600];

int main(){
  cin >> H >> W >> d;
  if(d%2 == 1){
    rep(i,H){
      rep(j,W){
        ans[i][j] = (i+j) % 4 + 1;
      }
    }
  }
  else if(d % 2 == 0 && d % 4 == 2){
    rep(i,H){
      rep(j,W){
        if((i+j) % 4 <= 1){
          ans[i][j] = (i) % 2+ 1;
        }
        else{
          ans[i][j] = (i) % 2 + 3;
        }
      }
    }
  }
  else{
    rep(i,H){
      rep(j,W){
        ll I = i % d;
        ll J = j % d;
        if((i/d + j/d) % 2 == 0){
          if(I >= J && I < d/2){
            ans[i][j] = 1;
            ans[i+(d/2 - I)][j] = 1;
          }
          else if(J > I && J <= d/2){
            ans[i][j] = 2;
            ans[i][j+(d/2-J)] = 2;
            ans[i+(d/2-I)][j] = 3;
            ans[i+(d/2-I)][j+(d/2-J)] = 3;
          }
          else if(I < d/2 && d-J >= I){
            ans[i][j] = 4;
            ans[i+(d/2-I)][j] = 4;
          }
        }
        else{
          if(I >= J && I < d/2){
            ans[i][j] = 4;
            ans[i+(d/2 - I)][j] = 4;
          }
          else if(J > I && J <= d/2){
            ans[i][j] = 3;
            ans[i][j+(d/2-J)] = 3;
            ans[i+(d/2-I)][j] = 2;
            ans[i+(d/2-I)][j+(d/2-J)] = 2;
          }
          else if(I < d/2 && d-J >= I){
            ans[i][j] = 1;
            ans[i+(d/2-I)][j] = 1;
          }
        }
      }
    }
  }
  rep(i,H){
    rep(j,W){
      if(ans[i][j] == 1){
        cout << "R";
      }
      if(ans[i][j] == 2){
        cout << "G";
      }
      if(ans[i][j] == 3){
        cout << "B";
      }
      if(ans[i][j] == 4){
        cout << "Y";
      }
    }
    cout << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:3: error: 'cin' was not declared in this scope
   22 |   cin >> H >> W >> d;
      |   ^~~
a.cc:10:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    9 | #include <stack>
  +++ |+#include <iostream>
   10 | #define rep(i,n) for(ll i=0;i<n;i++)
a.cc:85:9: error: 'cout' was not declared in this scope
   85 |         cout << "R";
      |         ^~~~
a.cc:85:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:88:9: error: 'cout' was not declared in this scope
   88 |         cout << "G";
      |         ^~~~
a.cc:88:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:91:9: error: 'cout' was not declared in this scope
   91 |         cout << "B";
      |         ^~~~
a.cc:91:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:94:9: error: 'cout' was not declared in this scope
   94 |         cout << "Y";
      |         ^~~~
a.cc:94:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:97:5: error: 'cout' was not declared in this scope
   97 |     cout << endl;
      |     ^~~~
a.cc:97:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'