Problem p03404 (python)

Fixed submission:
#!/usr/bin/env python

import math


def main():
    A, B = map(int, input().split())

    A, B = B, A

    if A == B == 1:
        print(1, 2)
        print('.#')
        return

    N = 50 if max(A, B) >= 50 else max(A, B)

    ans = []
    if A != 1:
        if B != 1:
            a = A - 1
        else:
            a = A
        while a > 0:
            tmp = []
            for i in range(N):
                if a <= 0:
                    tmp.append('..')
                else:
                    # print('#.', end='')
                    tmp.append('#.')
                    a -= 1
            ans.append(''.join(tmp))
            ans.append('.' * N * 2)
    if B != 1:
        if A != 1:
            b = B - 1
        else:
            b = B
        ans.append('#' * N * 2)
        while b > 0:
            tmp = []
            for i in range(N):
                if b <= 0:
                    tmp.append('##')
                else:
                    tmp.append('.#')
                    b -= 1
            ans.append(''.join(tmp))
            ans.append('#' * N * 2)
    print(len(ans), len(ans[0]))
    for l in ans:
        print(l)


if __name__ == '__main__':
    # print(main())
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

import math


def main():
    A, B = map(int, input().split())

    A, B = B, A

    if A == B == 1:
        print(1, 2)
        print('.#')

    N = 50 if max(A, B) >= 50 else max(A, B)

    ans = []
    if A != 1:
        if B != 1:
            a = A - 1
        else:
            a = A
        while a > 0:
            tmp = []
            for i in range(N):
                if a <= 0:
                    tmp.append('..')
                else:
                    # print('#.', end='')
                    tmp.append('#.')
                    a -= 1
            ans.append(''.join(tmp))
            ans.append('.' * N * 2)
    if B != 1:
        if A != 1:
            b = B - 1
        else:
            b = B
        ans.append('#' * N * 2)
        while b > 0:
            tmp = []
            for i in range(N):
                if b <= 0:
                    tmp.append('##')
                else:
                    tmp.append('.#')
                    b -= 1
            ans.append(''.join(tmp))
            ans.append('#' * N * 2)
    print(len(ans), len(ans[0]))
    for l in ans:
        print(l)


if __name__ == '__main__':
    # print(main())
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

import math


def main():
    A, B = map(int, input().split())

    A, B = B, A

    if A == B == 1:
        print(1, 2)
        print('.#')

    N = 50 if max(A, B) >= 50 else max(A, B)

    ans = []
    if A != 1:
        if B != 1:
            a = A - 1
        else:
            a = A
        while a > 0:
            tmp = []
            for i in range(N):
                if a <= 0:
                    # print('..', end='')
                    tmp.append('..')
                else:
                    # print('#.', end='')
                    tmp.append('#.')
                    a -= 1
            ans.append(''.join(tmp))
            ans.append('.' * N * 2)
    if B != 1:
        if A != 1:
            b = B - 1
        else:
            b = B
        ans.append('#' * N * 2)
        while b > 0:
            tmp = []
            for i in range(N):
                if b <= 0:
                    tmp.append('##')
                else:
                    tmp.append('.#')
                    b -= 1
            ans.append('#' * N * 2)
    print(len(ans), len(ans[0]))
    for l in ans:
        print(l)


if __name__ == '__main__':
    # print(main())
    main()