Problem:
 Score : 700 points    Problem Statement We have a grid with H rows and W columns of squares.
We will represent the square at the i -th row from the top and j -th column from the left as (i,\ j) .
Also, we will define the distance between the squares (i_1,\ j_1) and (i_2,\ j_2) as |i_1 - i_2| + |j_1 - j_2| .  Snuke is painting each square in red, yellow, green or blue.
Here, for a given positive integer d , he wants to satisfy the following condition:   No two squares with distance exactly d have the same color.   Find a way to paint the squares satisfying the condition.
It can be shown that a solution always exists.      Constraints  2 ≤ H, W ≤ 500  1 ≤ d ≤ H + W - 2         Input Input is given from Standard Input in the following format:  H  W  d       Output Print a way to paint the squares satisfying the condition, in the following format. If the square (i,\ j) is painted in red, yellow, green or blue, c_{ij} should be R , Y , G or B , respectively.  c_{11} c_{12} ... c_{1W}  :  c_{H1} c_{H2} ... c_{HW}         Sample Input 1 2 2 1      Sample Output 1 RY
GR  There are four pairs of squares with distance exactly 1 .
As shown below, no two such squares have the same color.   (1,\ 1) , (1,\ 2) : R , Y  (1,\ 2) , (2,\ 2) : Y , R  (2,\ 2) , (2,\ 1) : R , G  (2,\ 1) , (1,\ 1) : G , R        Sample Input 2 2 3 2      Sample Output 2 RYB
RGB  There are six pairs of squares with distance exactly 2 .
As shown below, no two such squares have the same color.   (1,\ 1) , (1,\ 3) : R , B  (1,\ 3) , (2,\ 2) : B , G  (2,\ 2) , (1,\ 1) : G , R  (2,\ 1) , (2,\ 3) : R , B  (2,\ 3) , (1,\ 2) : B , Y  (1,\ 2) , (2,\ 1) : Y , R

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w,d = list(map(int, input().split()))
v = [[0]*(h+w) for _ in range(h+w)]
dd = {(0,0): "R", (0,1): "Y", (1,0): "G", (1,1): "B"}
for i in range(h+w):
    for j in range(h+w):
        v[i][j] = dd[(i//d)%2, (j//d)%2]
ans = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        ans[i][j] = v[i+j][i-j+w]
for i in range(h):
    write("".join(ans[i]))

Solution (Python):
l = ['R', 'Y', 'G', 'B']
h, w, d = map(int, input().split())
res = [[None] * 1000 for _ in range(1000)]
for i in range(1000):
    if (i // d) % 2 == 0:
        for j in range(1000):
            res[i][j] = l[(j // d + 2) % 4]
    else:
        for j in range(1000):
            res[i][j] = l[j // d % 4]
ans = [[None] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        ans[i][j] = res[i + j][h - i - 1 + j]
for row in ans:
    print(''.join(row))

Solution (Python):
H,W,D=map(int,input().split())
if D&1:
  S='RY'*(W+1)
  for i in range(H):
    print(S[i&1:W+(i&1)])
  exit()
x=D>>1
M=max(H,W)<<2
Q=[[0]*(M+1) for j in range(M+1)]
S='RYGB'
for i in range(M+1):
  for j in range(M+1):
    Q[i][j]=((j//x)&1)+((i//(x*2))&1)*2
P=[[0]*W for i in range(H)]
M>>=1
for i in range(H):
  for j in range(W):
    P[i][j]=S[Q[M+i+j][M+((j-i)>>1)]]
for i in range(H):
  print(*P[i],sep='')

Solution (Python):
h,w,d=map(int,input().split())
for i in range(h):print(*["RYGB"[(i+j)//d%2*2+(i-j)//d%2]for j in range(w)],sep="")

Solution (Python):
h,w,d=map(int,input().split())
for i in range(h):print("".join(["RYGB"[(i+j)//d%2*2+(i-j)//d%2]for j in range(w)]))

Solution (Python):
for a in(lambda h,w,d:[["RYGB"[(i+j)//d%2*2+(i-j)//d%2]for j in range(w)]for i in range(h)])(*map(int,input().split())):print("".join(a))

Solution (Python):
h,w,d=map(int,input().split())
for i in range(h):
 l=[]
 for j in range(w):l+=["RYGB"[(i+j)//d%2*2+(i-j)//d%2]]
 print("".join(l))

Solution (Python):
h, w, d = map(int, input().split())
C = ["R", "Y", "G", "B"]
G = [[None]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    y, x = i+j, i-j
    G[i][j] = C[((y//d)%2)*2+(x//d)%2]
for g in G:
  print("".join(g))

Solution (Python):
h,w,d = map(int,input().split())
if d%2:
  for i in range(h):
    for j in range(w):
      if (i+j)%2:
        print("R",end="")
      else:
        print("G",end="")
    print()
else:
  cell = [["A" for i in range(2*d)] for j in range(2*d)]
  for i in range(d):
    for j in range(d):
      if (i+j)%2 == (d//2-1)%2:
        if abs(i-j) <= d//2-1 and d//2-1 <= i+j <= (d//2-1)*3:
          cell[i][j] = "R"
      elif j and cell[i][j-1] == "R":
        cell[i][j] = "R"
  for i in range(2*d):
    for j in range(2*d):
      if cell[(i-d)%(2*d)][(j-d)%(2*d)] == "R":
        cell[i][j] = "R"
      elif cell[(i-d//2)%(2*d)][(j-d//2)%(2*d)] == "R" or cell[(i+d//2)%(2*d)][(j+d//2)%(2*d)] == "R" :
        cell[i][j] = "G"
      elif cell[(i-d)%(2*d)][j] == "R" or cell[i][(j-d)%(2*d)] == "R":
        cell[i][j] = "B"
      elif cell[i][j] == "A":
        cell[i][j] = "Y"
  ans = [["A" for i in range(w)] for j in range(h)]
  for i in range(h):
    for j in range(w):
      x = cell[i%(2*d)][j%(2*d)]
      ans[i][j] = x
    print(*ans[i],sep="")

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    H, W, d = map(int, input().split())

    N = 1500
    grid = [[""] * N for _ in range(N)]
    if d & 1:
        ans = [[""] * W for _ in range(H)]
        for h in range(H):
            for w in range(W):
                if (h+w) & 1:
                    ans[h][w] = "R"
                else:
                    ans[h][w] = "B"
        for h in range(H):
            print("".join(ans[h]))
        exit()

    grid = [[""] * N for _ in range(N)]
    e = (d-2) // 2
    for h in range(N):
        if h * d >= N:
            break
        for w in range(N):
            if w * d >= N:
                break
            if (h+w) & 1:
                c = "R"
            else:
                c = "B"
            for hh in range(h*d - e, h*d + e + 1):
                for ww in range(w*d - e, w*d + e + 1):
                    if 0 <= hh < N and 0 <= ww < N and abs(h*d-hh) + abs(w*d-ww) <= e:
                        grid[hh][ww] = c
    for h in range(N):
        if h * d + d//2 >= N:
            break
        for w in range(N):
            if w * d + d//2 >= N:
                break
            if (h+w) & 1:
                c = "Y"
            else:
                c = "G"
            for hh in range(h*d + d//2 - e, h*d + d//2 + e + 1):
                for ww in range(w*d + d//2 - e, w*d + d//2 + e + 1):
                    if 0 <= hh < N and 0 <= ww < N and abs(h*d + d//2 - hh) + abs(w*d + d//2 - ww) <= e:
                        grid[hh][ww] = c

    for h in range(1, N):
        for w in range(N):
            if grid[h][w] == "":
                grid[h][w] = grid[h-1][w]

    for h in range(501, 500+H+1):
        print("".join(grid[h][501:500+W+1]))


if __name__ == '__main__':
    main()

Solution (Python):
col_list = ['R', 'Y', 'G', 'B']

H, W, d = map(int, input().split())

for i in range(H):
    tmp = ""
    for j in range(W):
        c = ((i+j)//d)%2 + (((i-j+W)//d)%2)*2
        tmp += col_list[c]
    print(tmp)

Solution (Python):

"""
Writer: SPD_9X2
https://atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_quala_d

dが奇数なら楽勝→2色でただの市松模様に塗れば終わり

dが偶数の時が問題

d = 2だったら

1 3 1 
 2 4 2
3 1 3
 4 2 4

みたいな感じで塗ってけばおｋ

斜めで　d/2ずつ12/34交互で、d/2こ連続して同じ数字を置けばいい(斜めの軸は合わせる)

→実装が面倒
→数学的に頑張る
"""

H,W,D = map(int,input().split())
sd = D//2

if D % 2 == 1:

    ans = [[""] * W for i in range(H)]

    for i in range(H):
        for j in range(W):

            if (i+j) % 2 == 0:
                ans[i][j] = "R"
            else:
                ans[i][j] = "Y"

    for i in ans:
        print ("".join(i))

else:

    ans = [[" "] * W for i in range(H)]

    for i in range(H):
        for j in range(W):

              if (i+j) % 2 == 0:
                  
                  if ((i+j)// D) % 2 == 0 and (((j-i)//D) % 2 == 0):
                      ans[i][j] = "R"
                  elif ((i+j)// D) % 2 == 1 and (((j-i)//D) % 2 == 0):
                      ans[i][j] = "Y"
                  elif ((i+j)// D) % 2 == 0 and (((j-i)//D) % 2 == 1):
                      ans[i][j] = "G"
                  else:
                      ans[i][j] = "B"

              else:
                  if ((i+j)// D) % 2 == 0 and (((j-i)//D) % 2 == 0):
                      ans[i][j] = "R"
                  elif ((i+j)// D) % 2 == 1 and (((j-i)//D) % 2 == 0):
                      ans[i][j] = "Y"
                  elif ((i+j)// D) % 2 == 0 and (((j-i)//D) % 2 == 1):
                      ans[i][j] = "G"
                  else:
                      ans[i][j] = "B"

    for i in ans:
        print ("".join(i))

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    H, W, d = map(int, input().split())
    color = ("R", "Y", "G", "B")
    d2 = d * 2
    for i in range(H):
        tmp = ""
        for j in range(W):
            tmp += color[2 * (((i+j) % d2) < d) + (((i-j) % d2) < d)]
        print(tmp)

if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    H, W, d = map(int, input().split())
    color = ("R", "Y", "G", "B")
    d2 = d * 2
    for i in range(H):
        for j in range(W):
            print(color[2 * (((i+j) % d2) < d) + (((i-j) % d2) < d)], end="")
        print()

if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    H, W, d = map(int, input().split())
    d2 = d * 2
    for i in range(H):
        for j in range(W):
            x = (i+j) % d2
            y = (i-j) % d2
            if x < d:
                if y < d:
                    print("R", end="")
                else:
                    print("Y", end="")
            else:
                if y < d:
                    print("G", end="")
                else:
                    print("B", end="")
        print()


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

H,W,D = map(int,input().split())

x = np.arange(H); y = np.arange(W)
plus = x[:,None] + y[None,:]
minus = x[:,None] - y[None,:]
plus //= D; plus %= 2
minus //= D; minus %= 2

x = plus + 2*minus
grid = np.zeros((H,W),dtype='U1')
grid[x==0] = 'R'
grid[x==1] = 'B'
grid[x==2] = 'G'
grid[x==3] = 'Y'

print('\n'.join(''.join(x for x in row) for row in grid))

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, D = list(map(int, sys.stdin.readline().split()))

X, Y = np.meshgrid(np.arange(H), np.arange(W))

X, Y = X + Y, X - Y
X = X.ravel()
Y = Y.ravel()

colors = np.zeros(H * W, dtype=str)
colors[(X % (D * 2) < D) & (Y % (D * 2) < D)] = 'R'
colors[(X % (D * 2) < D) & (Y % (D * 2) >= D)] = 'Y'
colors[(X % (D * 2) >= D) & (Y % (D * 2) < D)] = 'G'
colors[(X % (D * 2) >= D) & (Y % (D * 2) >= D)] = 'B'

x, y = (X + Y) // 2, (X - Y) // 2
ans = np.zeros((H, W), dtype=str)
ans[x, y] = colors
print('\n'.join(map(lambda r: ''.join(r), ans)))

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, D = list(map(int, sys.stdin.readline().split()))

X, Y = np.meshgrid(np.arange(H), np.arange(W))
X, Y = X + Y, X - Y
X = X.ravel()
Y = Y.ravel()
colors = np.zeros(H * W, dtype=str)

if D % 2 == 1:
    colors[X % 2 == 1] = 'R'
    colors[X % 2 == 0] = 'Y'
else:
    colors[(X % (D * 2) < D) & (Y % (D * 2) < D)] = 'R'
    colors[(X % (D * 2) < D) & (Y % (D * 2) >= D)] = 'Y'
    colors[(X % (D * 2) >= D) & (Y % (D * 2) < D)] = 'G'
    colors[(X % (D * 2) >= D) & (Y % (D * 2) >= D)] = 'B'

x, y = (X + Y) // 2, (X - Y) // 2
ans = np.zeros((H, W), dtype=str)
ans[x, y] = colors
print('\n'.join(map(lambda r: ''.join(r), ans)))

Solution (Python):
H, W, d = map(int, input().split())
G = [[None]*W for _ in range(H)]
Col = ['R', 'G', 'B', 'Y']
for i in range(H):
    for j in range(W):
        a, b = ((i+j)//d)%2, ((i-j)//d)%2
        G[i][j] = Col[2*a+b]
for g in G:
    print(''.join(g))

Solution (Python):
H, W, d = map(int, input().split())
for i in range(H):
	ans = ""
	for j in range(W):
		if (i+j) % (2*d) < d and (i-j) % (2*d) < d:
			ans += "R"
		elif (i+j) % (2*d) >= d and (i-j) % (2*d) < d:
			ans += "Y"
		elif (i+j) % (2*d) < d and (i-j) % (2*d) >= d:
			ans += "G"
		else:
			ans += "B"
	print(ans)

Solution (Python):
H, W, d = map(int, input().split())
if d%2 == 1:
	for i in range(H):
		print(*["R" if (i+j)%2 == 0 else "Y" for j in range(W)], sep="")
else:
	for i in range(H):
		ans = ""
		for j in range(W):
			if (i+j) % (2*d) < d and (i-j) % (2*d) < d:
				ans += "R"
			elif (i+j) % (2*d) >= d and (i-j) % (2*d) < d:
				ans += "Y"
			elif (i+j) % (2*d) < d and (i-j) % (2*d) >= d:
				ans += "G"
			else:
				ans += "B"
		print(ans)

Solution (Python):
H, W, d = map(int, input().split())
C = ["R", "Y", "G", "B"]
if d%2==1:
    for i in range(H):
        out = ""
        for j in range(W):
            out += C[(i+j)%4]
        print(out)
elif d%4 == 2:
    for i in range(H):
        out = ""
        for j in range(W):
            out += C[i%2*2+(i//2+j//2)%2]
        print(out)
else:
    for i in range(H):
        out = ""
        for j in range(W):
            out += C[(i+j)//d%2*2+(i-j)//d%2]
        print(out)

Solution (Python):
import sys
h,w,d = map(int, sys.stdin.readline().split())

x = [[0]*1600 for i in range(1600)]
for i in range(1600):
    for j in range(1600):
        a = i//d 
        b = j//d
        if (a%2 ==0 and b%2 == 0):
            x[i][j] = "R"
        elif (a%2 ==1 and b%2 == 0):
            x[i][j] = "Y"
        elif (a%2 ==1 and b%2 == 1):
            x[i][j] = "G"
        else:
            x[i][j] = "B"
for i in range(h):
    result = ""
    for j in range(w):
        result+= x[800+j-i][0+j+i] 
    print(result)

Solution (Python):
for a in (lambda H,W,d:[['RGBY'[(i + j) // d % 2 + (i - j) // d % 2 * 2] for j in range(W)] for i in range(H)])(*(map(int, input().split()))):print(''.join(a))

Solution (Python):
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
INF = float("inf")
sys.setrecursionlimit(10**7)


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    H, W, d = map(int, input().split())
    field = [[0] * W for _ in range(H)]

    
    if d % 2 != 0:
        for y in range(H):
            for x in range(W):
                field[y][x] = (y + x) % 2
    elif d % 4 == 2:
        for y in range(H):
            for x in range(W):
                field[y][x] = (y % 2 * 2) + (y // 2 + x // 2) % 2
    else:
        for y in range(H):
            for x in range(W):
                ny = y + x + 1000
                nx = y - x + 1000
                field[y][x] = ny // d % 2 * 2 + nx // d % 2
                if (y + x) % 2 == 1:
                    field[y][x] ^= 3

    c = "RGBY"
    for line in field:
        print("".join(c[x] for x in line))


if __name__ == '__main__':
    main()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    h,w,d = LI()
    r = [['.']*w for _ in range(h)]
    cs = ['R','Y','G','B']
    for i in range(0,h+d,d):
        for j in range(0,w+d,d):
            c = cs[(i+j) % (d*2) // d]
            for ii in range(-d,d):
                for jj in range(-d,d):
                    if i+ii < 0 or i+ii >= h or j+jj < 0 or j+jj >= w or abs(ii)+abs(jj) >= d or abs(ii)+abs(d-jj-1) >= d:
                        continue
                    r[i+ii][j+jj] = c
    for i in range(1,h+d,d):
        for j in range(0,w+d,d):
            c = cs[(i+j) % (d*2) // d + 2]
            for ii in range(d):
                for jj in range(d):
                    if i+ii < 0 or i+ii >= h or j+jj < 0 or j+jj >= w:
                        continue
                    if abs(ii)+abs(jj) >= d or r[i+ii][j+jj] != '.' or jj > ii:
                        break
                    r[i+ii][j+jj] = c
                for jj in range(-1,-d-1,-1):
                    if i+ii < 0 or i+ii >= h or j+jj < 0 or j+jj >= w:
                        continue
                    if abs(ii)+abs(jj) >= d or r[i+ii][j+jj] != '.':
                        break
                    r[i+ii][j+jj] = c


    return '\n'.join([''.join(c) for c in r])


print(main())

Solution (Python):
H, W, d = map(int, input().split())

colors = 'RYGB'
for i in range(H):
    for j in range(W):
        x = i - j
        y = i + j
        print(colors[(x // d % 2) * 2 + (y // d % 2)], end='')
    print()

Solution (Python):
H, W, d = map(int, input().split())

if d % 2 != 0:
    unit = ['BY', 'YB']
    size = 2

else:
    colors = 'RYGB'
    temp = [['' for j in range(2 * d)] for i in range(2 * d)]

    d2 = d // 2
    origin = [(-d, -2 * d), (-d, -d), (-d2, -3 * d2), (-d2, -d2)]
    offset = [(0, 0), (d, d)]

    for color, (r, c) in zip(colors, origin):
        for dr, dc in offset:
            for j in range(d2):
                for i in range(-j, j + 1):
                    temp[r + dr + i][c + dc + j] = color
                    temp[r + dr + i][c + dc + d - 1 - j] = color

    unit = [''.join(temp[i]) for i in range(2 * d)]
    size = 2 * d

for i in range(H):
    print(unit[i % size] * (W // size) + unit[i % size][:(W % size)])

Solution (Python):
H,W,d = map(int,input().strip().split())
colors = ('R','Y','G','B')
for i in range(H):
    line = []
    for j in range(W):
        x = (i+j)%(2*d) >= d
        y = (i-j)%(2*d) >= d
        line.append(colors[2*x+y])
    print(''.join(line))

Solution (Python):
H, W, d = [int(x) for x in input().split(" ")]

res = ''

d2 = 2 * d
for h in range(H):
    for w in range(W):
        x = h - w
        y = h + w
        if x % d2 < d:
            c = 'R' if  y % d2 < d else 'B'
        else:
            c = 'G' if  y % d2 < d else 'Y'
        res+= c
    res += '\n'

print(res)

Solution (Python):
colors = ["R", "B", "Y", "G"]

if __name__ == '__main__':
    H, W, d = list(map(int, input().split()))

    ans = [["" for j in range(W)] for i in range(H)]
    for i in range(0, H):
        for j in range(0, W):
            
            x = i - j
            y = i + j

            if 1 <= x % (2 * d) <= d:
                if 1 <= y % (2 * d) <= d:
                    ans[i][j] = "R"
                else:
                    ans[i][j] = "B"
            else:
                if 1 <= y % (2 * d) <= d:
                    ans[i][j] = "Y"
                else:
                    ans[i][j] = "G"

    for tmpans in ans:
        print("".join(tmpans))

Solution (Python):
import sys
H,W,d=map(int,input().split())
if d%2==1:
  l=W//4+1
  reg=list("RYGB"*l)
  for j in range(H):
    a=reg.pop(0)
    reg+=a
    print("".join(map(str,reg))[:W])
else:
  for i in range(H):
      c="RYGB"
      ans = []
      for j in range(W):
          b1 = ((i-j) // d) % 2
          b2 = ((i+j) // d) % 2
          ans+= c[b1 * 2 + b2]
      print("".join(ans))

Solution (Python):
H,W,D = map(int,input().split())

d = ['R','Y','G','B']

ans = [[] for i in range(H)]
for i in range(H):
    for j in range(W):
        x,y = i+j, i-j
        k = (x % (2*D)) // D
        k += ((y % (2*D)) // D) * 2
        ans[i].append(d[k])

for row in ans:
    print(''.join(row))

Solution (Python):
h,w,d=map(int,input().split())
c="RYGB"
for i in range(h):
	l=[]
	for j in range(w):
		x=(i-j)%(2*d)>=d
		y=(i+j)%(2*d)>=d
		l+=c[2*x+y]
	print(''.join(l))

Solution (Python):
h,w,d = map(int,input().split())
c = ('R','Y','G','B')

from itertools import product
for i in range(h):
  line = []
  for j in range(w):
    x = (i-j)%(2*d) >= d
    y = (i+j)%(2*d) >= d
    line.append(c[2*x+y])
  print(''.join(line))

Solution (Python):
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    h, w, d = read_int_list()
    a = [[0] * w for _ in range(h)]
    if d % 2 == 1:
        for i in range(h):
            for j in range(w):
                a[i][j] = (i + j) % 2
    else:
        for i in range(h):
            for j in range(w):
                x = (i + j) // d
                y = (i - j) // d
                if x % 2 == 1:
                    a[i][j] += 1
                if y % 2 == 1:
                    a[i][j] += 2

    s = 'RGBY'
    for i in range(h):
        for j in range(w):
            print(s[a[i][j]], end='')
        print()


main()

Solution (Python):



hwd = raw_input()
hwd = hwd.split()
h,w,d = map(int,hwd)

if d % 2 == 0:
    for i in range(h):
        s = ""
        for j in range(w):
            if i%(2*d) < d/2:
                if i%d <= j%(2*d) and j%(2*d) < d-i%d:
                    s += "R"
                elif d-i%d <= j%(2*d) and j%(2*d) < d+i%d:
                    s += "Y"
                elif d+i%d <= j%(2*d) and j%(2*d) < 2*d-i%d:
                    s += "G"
                else:
                    s += "B"
            elif i%(2*d) < d/2*2:
                if (d-i)%d <= j%(2*d) and j%(2*d) < d-(d-i)%d:
                    s += "G"
                elif d-(d-i)%d <= j%(2*d) and j%(2*d) < d+(d-i)%d:
                    s += "Y"
                elif d+(d-i)%d <= j%(2*d) and j%(2*d) < 2*d-(d-i)%d:
                    s += "R"
                else:
                    s += "B"
            elif i%(2*d) < d/2*3:
                if i%d <= j%(2*d) and j%(2*d) < d-i%d:
                    s += "G"
                elif d-i%d <= j%(2*d) and j%(2*d) < d+i%d:
                    s += "B"
                elif d+i%d <= j%(2*d) and j%(2*d) < 2*d-i%d:
                    s += "R"
                else:
                    s += "Y"
            else:
                if (d-i)%d <= j%(2*d) and j%(2*d) < d-(d-i)%d:
                    s += "R"
                elif d-(d-i)%d <= j%(2*d) and j%(2*d) < d+(d-i)%d:
                    s += "B"
                elif d+(d-i)%d <= j%(2*d) and j%(2*d) < 2*d-(d-i)%d:
                    s += "G"
                else:
                    s += "Y"
        print s
else:
    for i in range(h):
        s = ""
        for j in range(w):
            if (i+j)% 2 == 0:
                s += "R"
            else:
                s += "Y"
        print s

Solution (Python):
h, w, k = map(int, raw_input().split())
b = [[0] * w for i in xrange(h)]
c = "YGBR"
for i in xrange(h):
    for j in xrange(w):
        b[i][j] = c[(i+j)/k%2+(i-j)/k%2*2]
    print "".join(b[i])

Solution (Python):
for a in (lambda H,W,d:[['RGBY'[(i + j) // d % 2 + (i - j) // d % 2 * 2] for j in range(W)] for i in range(H)])(*(map(int, input().split()))):print(''.join(a))

Solution (Python):

H, W, d = map(int, input().split())

ret = [['RGBY'[(i + j) // d % 2 + (i - j) // d % 2 * 2] for j in range(W)] for i in range(H)]

for a in ret:
    print(''.join(a))

Solution (Python):
h, w, d = map(int, input().split())

clr = {'R':'Y', 'Y':'R', 'G':'B', 'B': 'G'}

ans = [['.' for _ in range(w)] for _ in range(h)]
if d % 2 == 1:
    d = 1
    ls = ["R"]
elif d == 2:
    ls = ["RR", "GB"]
else:
    ls = [['.' for _ in range(d)] for _ in range(d)]
    for i in range(d // 2 - 1, -1, -1):
        for j in range(d):
            if j < d // 2 - i - 1:
                ls[i][j] = 'G'
            elif d // 2 + i < j:
                ls[i][j] = 'B'
            else:
                ls[i][j] = 'R'
    for i in range(d // 2, d - 1):
        for j in range(d):
            if j <= (i - d // 2):
                ls[i][j] = 'B'
            elif 3 * d // 2 - i - 1 <= j:
                ls[i][j] = 'G'
            else:
                ls[i][j] = 'R'
    for j in range(d):
        if j < d // 2:
            ls[d - 1][j] = 'B'
        else:
            ls[d - 1][j] = 'G'
for i in range(h):
    for j in range(w):
        if i % (2 * d) < d and j % (2 * d) < d:
            ans[i][j] = ls[i % d][j % d]
        elif d <= i % (2 * d) and d <= j % (2 * d):
            ans[i][j] = ls[i % d][j % d]
        else:
            ans[i][j] = clr[ls[i % d][j % d]]
for row in ans:
    print(''.join(row))

Solution (Python):

import heapq
import math
import sys

tmp = input()
H, W, d = [int(a) for a in tmp.split()]

def decide_color(i, j, d2):
    x = i + j
    y = i - j
    if y < 0:
        y += (d2 * 2) * max(H, W)
    kinds = [a % (d2*2) < d2 for a in [x, y]]
    ids = [0 if k else 1 for k in kinds]
    
    return [['R', 'Y'], ['G', 'B']][ids[0]][ids[1]]
def decide_color2(i, j):
    return ['R', 'Y'][(i+j) % 2]

if d % 2 == 1:
    for i in range(H):
        print(''.join([decide_color2(i, j) for j in range(W)]))
else:
    for i in range(H):
        print(''.join([decide_color(i, j, d) for j in range(W)]))

Solution (Python):
import sys
import socket

if socket.gethostname() == 'N551J':
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    h, w, d = read_int_list()
    c = [[0] * w for _ in range(h)]
    if d % 2 == 1:
        for i in range(h):
            for j in range(w):
                c[i][j] = (i + j) % 2
    else:
        for i in range(h):
            for j in range(w):
                x = i + j
                y = i - j
                x -= x % 2
                y -= y % 2
                x //= 2
                y //= 2
                if x % d < d // 2:
                    c[i][j] += 1
                if y % d < d // 2:
                    c[i][j] += 2

    s = 'RYGB'
    res = [''.join(map(s.__getitem__, row)) for row in c]

    
    
    
    
    
    
    
    
    
    
    

    return res


def main():
    res = solve()
    print(*res, sep='\n')


if __name__ == '__main__':
    main()

Solution (Python):
def solve(h, w, d):
    col = 'RYGB'
    if d & 1:
        cols = col * (w // 4 + 2)
        buf = []
        for i in range(h):
            j = i % 4
            buf.append(cols[j:j + w])
        print('\n'.join(buf))
        return
    e = d // 2
    r = w // (2 * d) + 1
    s = []
    for i in range(1, e + 1):
        cf1 = 2 * (e - i) + 1
        cf2 = 2 * i - 1
        t = 'R' * i + 'Y' * cf1 + 'G' * cf2 + 'B' * cf1 + 'R' * (i - 1)
        s.append((t * r)[:w])
    for i in range(e, 0, -1):
        cf1 = 2 * (e - i) + 1
        cf2 = 2 * i - 1
        t = 'R' * i + 'B' * cf1 + 'G' * cf2 + 'Y' * cf1 + 'R' * (i - 1)
        s.append((t * r)[:w])
    for i in range(1, e + 1):
        cf1 = 2 * (e - i) + 1
        cf2 = 2 * i - 1
        t = 'G' * i + 'B' * cf1 + 'R' * cf2 + 'Y' * cf1 + 'G' * (i - 1)
        s.append((t * r)[:w])
    for i in range(e, 0, -1):
        cf1 = 2 * (e - i) + 1
        cf2 = 2 * i - 1
        t = 'G' * i + 'Y' * cf1 + 'R' * cf2 + 'B' * cf1 + 'G' * (i - 1)
        s.append((t * r)[:w])
    print('\n'.join(s[i % (2 * d)] for i in range(h)))


solve(*map(int, input().split()))

Solution (Python):
h, w, d = map(int, input().split())

cols = [[0]*w for i in range(h)]
if d % 2 == 1:
    for i in range(h):
        for j in range(w):
            cols[i][j] = "RY"[(i+j)%2]
else:
    arr = [[0]*(4*d) for i in range(4*d)]
    for i in range(d):
        for j in range(d):
            arr[i+d][j] = arr[i][j+d] = 2
    for i in range(d):
        for j in range(d):
            if abs(i) + abs(j) <= d//2-2:
                arr[i][j] = arr[i+d][j+d] = 1
                arr[i+d][j] = arr[i][j+d] = 3
            if abs(d-1-j) + abs(d-1-i) <= d//2-1:
                arr[i][j] = arr[i+d][j+d] = 1
                arr[i+d][j] = arr[i][j+d] = 3
            if abs(d-1-j) + abs(i) <= d//2-2:
                arr[i][j] = arr[i+d][j+d] = 3
                arr[i+d][j] = arr[i][j+d] = 1
            if abs(j) + abs(d-1-i) <= d//2-1:
                arr[i][j] = arr[i+d][j+d] = 3
                arr[i+d][j] = arr[i][j+d] = 1
    for i in range(h):
        for j in range(w):
            cols[i][j] = "RGBY"[int(arr[i%(2*d)][j%(2*d)])]
print("\n".join("".join(e) for e in cols))

Solution (Python):
n, m, d = map(int, input().strip().split())

c = "RYGB"

if d % 2 == 1:
    for i in range(n):
        print("".join([c[(i + j) % 2] for j in range(m)]))
else:
    for i in range(n):
        result = []
        for j in range(m):
            b1 = ((i + j) // d) % 2
            b2 = ((i - j) // d) % 2
            result += c[b1 * 2 + b2]
        print("".join(result))