Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]
dp = {0: 0}
for i in range(N):
    for j in sorted(dp.keys(), reverse=True):
        w, v = wv[i][0], wv[i][1]
        nw = dp[j] + w
        nv = j + v
        if nw <= W:
            if nv < dp[nv]:
                dp[nv] = nw
        else:
            dp[nv] = nw

print(max(dp.keys()))

Fixed submission:
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]
dp = {0: 0}
for i in range(N):
    for j in sorted(dp.keys(), reverse=True):
        w, v = wv[i][0], wv[i][1]
        nw = dp[j] + w
        nv = j + v
        if nw <= W:
            if nv in dp:
                if nw < dp[nv]:
                    dp[nv] = nw
            else:
                dp[nv] = nw


print(max(dp.keys()))

Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]
dp = {0: 0}
for i in range(N):
    for j in sorted(dp.keys(), reverse=True):
        w, v = wv[i][0], wv[i][1]
        nw = dp[j] + w
        nv = j + v
        if nw <= W:
            if nv in dp:
                dp[nv] = nw
        else:
            dp[nv] = nw
            
print(max(dp.key()))

Fixed submission:
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]
dp = {0: 0}
for i in range(N):
    for j in sorted(dp.keys(), reverse=True):
        w, v = wv[i][0], wv[i][1]
        nw = dp[j] + w
        nv = j + v
        if nw <= W:
            if nv in dp:
                if nw < dp[nv]:
                    dp[nv] = nw
            else:
                dp[nv] = nw


print(max(dp.keys()))

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for i in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j < WV[i][0]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - WV[i][0]] + WV[i][1])


print(dp[-1][-1])


Fixed submission:
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]
dp = {0: 0}
for i in range(N):
    for j in sorted(dp.keys(), reverse=True):
        w, v = wv[i][0], wv[i][1]
        nw = dp[j] + w
        nv = j + v
        if nw <= W:
            if nv in dp:
                if nw < dp[nv]:
                    dp[nv] = nw
            else:
                dp[nv] = nw


print(max(dp.keys()))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
if M % N == 0:
    print(M // N)
    quit()
for i in range(M // N + 1):
    if M % (M//N-i) == 0:
        print(M//N-i)
        quit()

Fixed submission:
N, M = map(int, input().split())
if M % N == 0:
    print(M // N)
    quit()
for i in range(M//N + 1):
    if M % (M//N-i) == 0:
        print(M//N-i)
        quit()
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
mod = 10**9 + 7


def factorize(n):
    b = 2
    fct = {}
    while b * b <= n:
        while n % b == 0:
            n //= b
            if b in fct.keys():
                fct[b] += 1
            else:
                fct[b] = 1
        b = b + 1
    if n > 1:
        fct[n] = 1
    return fct

from scipy.special import comb
fac_list = factorize(M)
ans = 1
for k, v in fac_list.items():
    ans *= comb(v+N-1, v)
    if ans >= mod:
        ans %= mod

print(int(ans))

Fixed submission:
N, M = map(int, input().split())
mod = 10**9 + 7


def factorize(n):
    b = 2
    fct = {}
    while b * b <= n:
        while n % b == 0:
            n //= b
            if b in fct.keys():
                fct[b] += 1
            else:
                fct[b] = 1
        b = b + 1
    if n > 1:
        fct[n] = 1
    return fct


from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


fac_list = factorize(M)
ans = 1
for k, v in fac_list.items():
    ans *= cmb(v+N-1, v)
    if ans >= mod:
        ans %= mod

print(int(ans))

Buggy python submission (verdict: Runtime Error):
import sympy
sympy.factorint(2016)

Fixed submission:
N, M = map(int, input().split())
mod = 10**9 + 7


def factorize(n):
    b = 2
    fct = {}
    while b * b <= n:
        while n % b == 0:
            n //= b
            if b in fct.keys():
                fct[b] += 1
            else:
                fct[b] = 1
        b = b + 1
    if n > 1:
        fct[n] = 1
    return fct


from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


fac_list = factorize(M)
ans = 1
for k, v in fac_list.items():
    ans *= cmb(v+N-1, v)
    if ans >= mod:
        ans %= mod

print(int(ans))
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
matrix = [str(input()) for i in range(H)]


matrix_1 = []
for i in range(H):
    if matrix[i] != "." * W:
        matrix_1.append(matrix[i])


matrix_2 = []
for i in range(W):
    a = ""
    for l in range(len(matrix_1)):
        a += matrix_1[l][i]
    matrix_2.append(a)


ans = []
k = len(matrix_1)
for i in range(W):
    if matrix_2[i] != "." * k:
        ans.append(matrix_2[i])


ans_2 = []
for i in range(len(ans)):
    a = ""
    for l in range(len(ans[0])):
        a += ans[l][i]
    ans_2.append(a)


for i in range(len(ans_2)):
    print(ans_2[i])

Fixed submission:
H, W = map(int, input().split())
matrix = [str(input()) for i in range(H)]


matrix_1 = []
for i in range(H):
    if matrix[i] != "." * W:
        matrix_1.append(matrix[i])


matrix_2 = []
for i in range(W):
    a = ""
    for l in range(len(matrix_1)):
        a += matrix_1[l][i]
    matrix_2.append(a)


ans = []
k = len(matrix_1)
for i in range(W):
    if matrix_2[i] != "." * k:
        ans.append(matrix_2[i])


ans_2 = []
for i in range(len(ans[0])):
    a = ""
    for l in range(len(ans)):
        a += ans[l][i]
    ans_2.append(a)


for i in range(len(ans_2)):
    print(ans_2[i])
Buggy python submission (verdict: Runtime Error):
N = int(input())

prime = [3, 5, 7, 11, 13]

# 約数が8個ということは、素因数分解した時の素因数の個数が0/7, 1/3, 1/1/1以外ありえない
zero_seven = 0
one_three = [a * (b ** 3) for a in prime for b in prime if a != b]
one_three = [i for i in one_three if i <= 200]
one_one_oen = [a * b * c for a in prime for b in prime for c in prime
               if a != b and b != c and c != a]
one_one_oen = [i for i in one_one_oen if i <= 200]

ans = sorted(set(one_three + one_one_oen))
i = 0
if ans[-1] < N:
    print(len(ans))
else: 
    while ans[i] <= N:
        i += 1
        if ans[i] > N:
            print(i)
            quit()

print(i)

Fixed submission:
N = int(input())

prime = [3, 5, 7, 11, 13]

# 約数が8個ということは、素因数分解した時の素因数の個数が0/7, 1/3, 1/1/1以外ありえない
zero_seven = 0
one_three = [a * (b ** 3) for a in prime for b in prime if a != b]
one_three = [i for i in one_three if i <= 200]
one_one_one = [a * b * c for a in prime for b in prime for c in prime
               if a != b and b != c and c != a]
one_one_one = [i for i in one_one_one if i <= 200]

ans = sorted(set(one_three + one_one_one))
if N <= 104:
    print(0)
elif 105 <= N <= 134:
    print(1)
elif 135 <= N <= 164:
    print(2)
elif 165 <= N <= 188:
    print(3)
elif 189 <= N <= 194:
    print(4)
elif 195 <= N:
    print(5)

Buggy python submission (verdict: Runtime Error):
N = int(input())

prime = [3, 5, 7, 11, 13]

# 約数が8個ということは、素因数分解した時の素因数の個数が0/7, 1/3, 1/1/1以外ありえない
zero_seven = 0
one_three = [a * (b ** 3) for a in prime for b in prime if a != b]
one_three = [i for i in one_three if i <= 200]
one_one_oen = [a * b * c for a in prime for b in prime for c in prime
               if a != b and b != c and c != a]
one_one_oen = [i for i in one_one_oen if i <= 200]

ans = sorted(set(one_three + one_one_oen))
i = 0
while ans[i] <= N:
    i += 1
    if ans[i] > N:
        print(i)

Fixed submission:
N = int(input())

prime = [3, 5, 7, 11, 13]

# 約数が8個ということは、素因数分解した時の素因数の個数が0/7, 1/3, 1/1/1以外ありえない
zero_seven = 0
one_three = [a * (b ** 3) for a in prime for b in prime if a != b]
one_three = [i for i in one_three if i <= 200]
one_one_one = [a * b * c for a in prime for b in prime for c in prime
               if a != b and b != c and c != a]
one_one_one = [i for i in one_one_one if i <= 200]

ans = sorted(set(one_three + one_one_one))
if N <= 104:
    print(0)
elif 105 <= N <= 134:
    print(1)
elif 135 <= N <= 164:
    print(2)
elif 165 <= N <= 188:
    print(3)
elif 189 <= N <= 194:
    print(4)
elif 195 <= N:
    print(5)
Buggy python submission (verdict: Runtime Error):
S = str(input())
K = int(input())

if K == 1:
    print(S[0])
elif K >= 2:
    if S[0] != "1":
        print(S[0])
        quit()
    elif S[0:K] == "1" * K:
        print(S[0])
        quit()
    else:
        i = 1
        while S[i] == "1" and len(S) - 2 >= i:
            i += 1
        print(S[i])


Fixed submission:
S = list(input())
K = int(input())
if K == 1:
    print(S[0])
    quit()
    
for i in range(K):
    if S[i] != '1':
        print(S[i])
        quit()

print('1')

Buggy python submission (verdict: Runtime Error):
S = str(input())
K = int(input())

if K == 1:
    print(S[0])
elif K >= 2:
    if S[0] != "1":
        print(S[0])
    elif S[0:K] == "1" * K:
        print("1")
    else:
        i = 1
        while S[i] == "1" and len(S) - 2 >= i:
            i += 1
        print(S[i])

Fixed submission:
S = list(input())
K = int(input())
if K == 1:
    print(S[0])
    quit()
    
for i in range(K):
    if S[i] != '1':
        print(S[i])
        quit()

print('1')

Buggy python submission (verdict: Runtime Error):
S = str(input())
K = int(input())

if K == 1:
    print(S[0])
elif K >= 2:
    if S[0] != "1":
        print(S[0])
    else:
        i = 1
        while S[i] == "1":
            i += 1
        print(S[i])

Fixed submission:
S = list(input())
K = int(input())
if K == 1:
    print(S[0])
    quit()
    
for i in range(K):
    if S[i] != '1':
        print(S[i])
        quit()

print('1')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
if N >= K:
    ans = N % K
else:
    ans = 1
print(b)

Fixed submission:
N, K = map(int, input().split())
if N % K == 0:
    ans = 0
else:
    ans = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import unionfind

Fixed submission:
D, G = map(int, input().split())
PC = [list(map(int, input().split())) for i in range(D)]


def solve(G, i):
    if i <= 0:
        return float('inf')
    n = min(int(G/(100*i)), PC[i-1][0])
    score = 100 * i * n
    if n == PC[i-1][0]:
        score += PC[i-1][1]
    if G > score:
        n += solve(G-score, i-1)
    return min(n, solve(G, i-1))


print(solve(G, D))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A = [A[i]-(i+1) for i in range(N)]

ans = float("inf")
for b in range(min(A), max(A)+1):
    loss = sum([abs(A[i] - b) for i in range(N)])
    ans = min(ans, loss)


print(ans)


Fixed submission:
N = int(input())

if N % 2 == 0:
    ans = N
else:
    ans = 2 * N


print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

from itertools import accumulate


ans = float("inf")
if N == 4:
    ans = min(ans, (max(A) - min(A)))
else:
    cs = accumulate(A)
    for i in range(2, N - 2):
        left_cs = cs[:i]
        right_cs = cs[i:]
        for l, v in enumerate(left_cs):
            if v + left_cs[l + 1] >= left_cs[-1]:
                P = left_cs[l]
                Q = left_cs[-1] - P
                break
        for r, v in enumerate(right_cs):
            if v + right_cs[r + 1] >= right_cs[-1]:
                R = right_cs[r]
                S = right_cs[-1] - R
                break
        ans = min(ans, (max(P, Q, R, S) - min(P, Q, R, S)))

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

from statistics import median
A = [a - i - 1 for i, a in enumerate(A)]
m = int(median(A))

print(sum(abs(a - m) for a in A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

from itertools import accumulate


ans = float("inf")
if N == 4:
    ans = min(ans, (max(A) - min(A)))
else:
    cs = accumulate(A)
    for i in range(2, N - 2):
        left_cs = cs[:i]
        right_cs = cs[i:]
        for l, v in enumerate(left_cs):
            if v + left_cs[l + 1] >= left_cs[-1]:
                P = left_cs[l]
                Q = left_cs[-1] - P
                break
        for r, v in enumerate(right_cs):
            if v + right_cs[r + 1] >= right_cs[-1]:
                R = right_cs[r]
                S = right_cs[-1] - R
                break
        ans = min(ans, (max(P, Q, R, S) - min(P, Q, R, S)))

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

from itertools import accumulate


ans = float("inf")
if N == 4:
    ans = min(ans, (max(A) - min(A)))
else:
    cs = list(accumulate(A))
    l = 0
    r = 0
    for i in range(1, N - 2):
        while cs[i] > cs[l] + cs[l+1]:
            l += 1
        while cs[-1] + cs[i] > cs[r] + cs[r+1]:
            r += 1
        P = cs[l]
        Q = cs[i] - P
        R = cs[r] - P - Q
        S = cs[-1] - cs[r]
        ans = min(ans, (max(P, Q, R, S) - min(P, Q, R, S)))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

import numpy as np


ans = float("inf")
if N == 4:
    ans = min(ans, (max(A) - min(A)))
else:
    for i in range(2, N - 2):
        left_cs = list(np.cumsum(A[:i]))
        right_cs = list(np.cumsum(A[i:]))
        for l, v in enumerate(left_cs):
            if v + left_cs[l + 1] >= left_cs[-1]:
                P = left_cs[l]
                Q = left_cs[-1] - P
                break
        for r, v in enumerate(right_cs):
            if v + right_cs[r + 1] >= right_cs[-1]:
                R = right_cs[r]
                S = right_cs[-1] - R
                break
        ans = min(ans, (max(P, Q, R, S) - min(P, Q, R, S)))

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

from itertools import accumulate


ans = float("inf")
if N == 4:
    ans = min(ans, (max(A) - min(A)))
else:
    cs = list(accumulate(A))
    l = 0
    r = 0
    for i in range(1, N - 2):
        while cs[i] > cs[l] + cs[l+1]:
            l += 1
        while cs[-1] + cs[i] > cs[r] + cs[r+1]:
            r += 1
        P = cs[l]
        Q = cs[i] - P
        R = cs[r] - P - Q
        S = cs[-1] - cs[r]
        ans = min(ans, (max(P, Q, R, S) - min(P, Q, R, S)))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

L = len(str(N))
S = sum([N // 10**i for i in range(1, N+1)])

if N % S == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
N = str(input())


S = sum([int(i) for i in N])

if int(N) % S == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())

def sum_digits(n, m):
    r = 0
    while n:
        r = r + n % m
        m = n // m
    return r

ans = float("inf")
for i in range(N+1):
    ans = min(ans, sum_digits(i, 6) + sum_digits(N-i, 9))

Fixed submission:
N = int(input())

if N >= 1000:
    print("ABD")
else:
    print("ABC")
Buggy python submission (verdict: Runtime Error):


N = int(input())
A = [1]
for i in range(1,7):
    A.append(6 ** i)
for i in range(1, 6):
    A.append(9 ** i)


A = sorted(A)
dp = [float("inf")] * (N+1)
dp[0] = 0

for i in range(1,N+1):
    for k, v in enumerate(A):
        if i >= v:
            dp[i] = min(dp[i], dp[i-A[s]]+1)
            
            
print(dp[N])

Fixed submission:
N = int(input())
A = []

A.append(1)
for i in range(1,7):
    A.append(6**i)
for i in range(1,6):
    A.append(9**i)
    
    
A.sort()
dp = [10*5+5]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for s in range(len(A)):
        if i-A[s] >= 0:
            dp[i] = min(dp[i-A[s]]+1, dp[i])
            
            
print(dp[N])

Buggy python submission (verdict: Runtime Error):
N = int(input())

def sum_digits(n, m):
    r = 0
    while n:
        r = r + n % m
        m = n // m
    return r

ans = float("inf")
for i in range(N+1):
    ans = min(ans, sum_digits(i, 6) + sum_digits(N-i, 9))

print(ans)

Fixed submission:
N = int(input())
A = []

A.append(1)
for i in range(1,7):
    A.append(6**i)
for i in range(1,6):
    A.append(9**i)
    
    
A.sort()
dp = [10*5+5]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for s in range(len(A)):
        if i-A[s] >= 0:
            dp[i] = min(dp[i-A[s]]+1, dp[i])
            
            
print(dp[N])

Buggy python submission (verdict: Runtime Error):
N = int(input())

def sum_digits(n, m):
    r = 0
    while n:
        r = r + n % m
        m = n // m
    return r

ans = float("inf")
for i in range(N+1):
    ans = min(ans, sum_digits(i, 6) + sum_digits(N-i, 9))

print(ans)

Fixed submission:
N = int(input())
A = []

A.append(1)
for i in range(1,7):
    A.append(6**i)
for i in range(1,6):
    A.append(9**i)
    
    
A.sort()
dp = [10*5+5]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for s in range(len(A)):
        if i-A[s] >= 0:
            dp[i] = min(dp[i-A[s]]+1, dp[i])
            
            
print(dp[N])

Buggy python submission (verdict: Runtime Error):
N = int(input())

def sum_digits(n, m):
    r = 0
    while n:
        r = r + n % m
        m = n // m
    return r

ans = float("inf")
for i in range(N+1):
    ans = min(ans, sum_digits(i, 6) + sum_digits(N-i, 9))

Fixed submission:
N = int(input())
A = []

A.append(1)
for i in range(1,7):
    A.append(6**i)
for i in range(1,6):
    A.append(9**i)
    
    
A.sort()
dp = [10*5+5]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for s in range(len(A)):
        if i-A[s] >= 0:
            dp[i] = min(dp[i-A[s]]+1, dp[i])
            
            
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())

ans = float("inf")
E = S.count("E")
W = S.count("W")
for i, v in enumerate(S):
    left = S[:i]
    left_E = left.count("E")
    left_W = left.count("W")
    if v == "E":
        right_E = E - left_E - 1
    else:
        right_E = E - left_E
    ans = min(ans, left_W + right_E)


print(ans)


Fixed submission:
import numpy as np
N = int(input())
S = str(input())

E = np.cumsum([1 if s == "E" else 0 for s in S])
W = np.cumsum([1 if s == "W" else 0 for s in S])

ans = float("inf")
for i, v in enumerate(S):
    if v == "E":
        ans = min(ans, (E[-1] - E[i]) + W[i])
    else:
        ans = min(ans, (E[-1] - E[i]) + W[i] - 1)
    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())

ans = float("inf")
E = S.count("E")
W = S.count("W")
for i, v in enumerate(S):
    left = S[:i]
    left_E = left.count("E")
    left_W = left.count("W")
    if v == "E":
        right_E = E - left_E - 1
    else:
        right_E = E - left_E
    ans = min(ans, left_W + right_E)


print(ans)

Fixed submission:
import numpy as np
N = int(input())
S = str(input())

E = np.cumsum([1 if s == "E" else 0 for s in S])
W = np.cumsum([1 if s == "W" else 0 for s in S])

ans = float("inf")
for i, v in enumerate(S):
    if v == "E":
        ans = min(ans, (E[-1] - E[i]) + W[i])
    else:
        ans = min(ans, (E[-1] - E[i]) + W[i] - 1)
    

print(ans)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [list(map(str, input().split())) for i in range(H)]

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
for h in range(H):
    for w in range(W):
        if S[h][w] == '#' or 'b':
            for i in range(4):
                nh, nw = h+dx[i], w+dy[i]
                if 0 <= nh < H and 0 <= nw < W:
                    if S[nh][nw] == '#' or S[nh][nw] == 'b':
                        S[nh][nw] = 'b'
                        S[h][w] = 'b'

counter = 0
for i in range(H):
    for l in range(W):
        if S[i][l] == "#":
            counter += 1


if counter == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
H, W = map(int, input().split())
S = [[s for s in str(input())] for i in range(H)]

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            for i in range(4):
                nh, nw = h+dx[i], w+dy[i]
                if 0 <= nh < H and 0 <= nw < W:
                    if S[nh][nw] == '#' or S[nh][nw] == 'b':
                        S[nh][nw] = 'b'
                        S[h][w] = 'b'

counter = 0
for i in range(H):
    for l in range(W):
        if S[i][l] == "#":
            counter += 1


if counter == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

white = '.'
black = '#'
grid = [[black * 100] for i in range(50)] + [[white * 100] for i in range(50)]

for i in range(A-1):
    grid[(i % 50) * 2][0] = grid[(i % 50) * 2][0][:(i % 50) * 2] + white + grid[(i % 50) * 2][0][(i % 50) * 2 + 1:]

for i in range(B-1):
    grid[(i % 50) * 2+49][0] = grid[(i % 50) * 2+49][0][:(i % 50) * 2] + black + grid[(i % 50) * 2+49][0][(i % 50) * 2 + 1:]

print(100, 100)
for g in grid:
    print(g[0])

Fixed submission:
A, B = map(int, input().split())

white = '.'
black = '#'
grid = [[black * 100] for i in range(50)] + [[white * 100] for i in range(50)]

for i in range(A-1):
    grid[(i // 50)*2][0] = grid[(i // 50)*2][0][:(i % 50) * 2] + white + grid[(i // 50)*2][0][(i % 50) * 2 + 1:]

for i in range(B-1):
    grid[(i // 50)*2 + 51][0] = grid[(i // 50)*2 + 51][0][:(i % 50) * 2] + black + grid[(i // 50)*2 + 51][0][(i % 50) * 2 + 1:]

print(100, 100)
for g in grid:
    print(g[0])

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

white = '.'
black = '#'
grid = [[black * 100] for i in range(50)] + [[white * 100] for i in range(50)]

for i in range(A-1):
    grid[(i % 50) * 2][0] = grid[(i % 50) * 2][0][:(i % 50) * 2] + white + grid[(i % 50) * 2][0][(i % 50) * 2 + 1:]

for i in range(B-1):
    grid[(i % 50) * 2+49][0] = grid[(i % 50) * 2+49][0][:(i % 50) * 2] + black + grid[(i % 50) * 2+49][0][(i % 50) * 2 + 1:]

print(100, 100)
for g in grid:
    print(g)

Fixed submission:
A, B = map(int, input().split())

white = '.'
black = '#'
grid = [[black * 100] for i in range(50)] + [[white * 100] for i in range(50)]

for i in range(A-1):
    grid[(i // 50)*2][0] = grid[(i // 50)*2][0][:(i % 50) * 2] + white + grid[(i // 50)*2][0][(i % 50) * 2 + 1:]

for i in range(B-1):
    grid[(i // 50)*2 + 51][0] = grid[(i // 50)*2 + 51][0][:(i % 50) * 2] + black + grid[(i // 50)*2 + 51][0][(i % 50) * 2 + 1:]

print(100, 100)
for g in grid:
    print(g[0])

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

white = '.'
black = '#'
grid = [[black * 100] for i in range(50)] + [[white * 100] for i in range(50)]

for i in range(A-1):
    print(grid[(i % 50) * 2][0][:(i % 50) * 2])
    grid[(i % 50) * 2][0] = grid[(i % 50) * 2][0][:(i % 50) * 2] + white + grid[(i % 50) * 2][0][(i % 50) * 2 + 1:]

for i in range(B-1):
    print(grid[(i % 50) * 2+49][0][:(i % 50) * 2])
    grid[(i % 50) * 2+49][0] = grid[(i % 50) * 2+49][0][:(i % 50) * 2] + black + grid[(i % 50) * 2+49][0][(i % 50) * 2 + 1:]

print(100, 100)
for g in grid:
    print(g)

Fixed submission:
A, B = map(int, input().split())

white = '.'
black = '#'
grid = [[black * 100] for i in range(50)] + [[white * 100] for i in range(50)]

for i in range(A-1):
    grid[(i // 50)*2][0] = grid[(i // 50)*2][0][:(i % 50) * 2] + white + grid[(i // 50)*2][0][(i % 50) * 2 + 1:]

for i in range(B-1):
    grid[(i // 50)*2 + 51][0] = grid[(i // 50)*2 + 51][0][:(i % 50) * 2] + black + grid[(i // 50)*2 + 51][0][(i % 50) * 2 + 1:]

print(100, 100)
for g in grid:
    print(g[0])