Problem p03402 (python)

Fixed submission:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

a,b = m()

print(100,100)
aa = [["." for i in range(100)] for j in range(100)]
c = 0
for i in range(50):
    for j in range(100):
        aa[i][j] = "#"
a -= 1
b -= 1
k = 0
for i in range(100):
    if i <= 48:
        if k == 1:
            k = 0
            continue
        if a != 0:
            for j in range(100):
                if a == 0:
                    break
                if i//2 % 2 == 0:
                    if j % 2 == 0:
                        aa[i][j] = "."
                        a -= 1
                        k = 1
                else:
                    if j % 2 == 1:
                        aa[i][j] = "."
                        a -= 1
                        k = 1
    elif i >= 51:
        if k == 1:
            k = 0
            continue
        if b == 0:
            break
        else:
            for j in range(100):
                if b == 0:
                    break
                if i//2 % 2 == 0:
                    if j % 2 == 0:
                        aa[i][j] = "#"
                        b -= 1
                        k = 1
                else:
                    if j % 2 == 1:
                        aa[i][j] = "#"
                        b -= 1
                        k = 1
    else:
        k = 0

for i in range(100):
    print("".join(aa[i]))

Buggy submission (verdict: Runtime Error):
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

a,b = m()

print(100,100)
aa = [["." for i in range(100)] for j in range(100)]
c = 0
for i in range(50):
    for j in range(100):
        aa[i][j] = "#"
a -= 1
b -= 1
for i in range(100):
    if i <= 48:
        if k == 1:
            k = 0
            continue
        if a != 0:
            for j in range(100):
                if a == 0:
                    break
                if i//2 % 2 == 0:
                    if j % 2 == 0:
                        aa[i][j] = "."
                        a -= 1
                        k = 1
                else:
                    if j % 2 == 1:
                        aa[i][j] = "."
                        a -= 1
                        k = 1
    elif i >= 51:
        if k == 1:
            k = 0
            continue
        for j in range(100):
            if b != 0:
                for j in range(100):
                    if b == 0:
                        break
                    if i//2 % 2 == 0:
                        if j % 2 == 0:
                            aa[i][j] = "#"
                            b -= 1
                            k = 1
                    else:
                        if j % 2 == 1:
                            aa[i][j] = "#"
                            b -= 1
                            k = 1
    else:
        k = 0

for i in range(100):
    print("".join(aa[i]))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())

k = 50

m = []

for i in range(k):
    m.append(["#"]*2*k)
for i in range(k):
    m.append(["."]*2*k)

a , b -= 1

for i in range(0,k-1,2):
    for j in range(0,2*k,2):
        if a > 0:
            m[i][j] = "."
            a -= 1 
for i in range(k+1,2*k,2):
    for j in range(0,2*k,2):
        if b > 0:
            m[i][j] = "#"
            b -= 1  

print(2*k,2*k)


for i in m:
    print("".join[i])