Problem p03361 (python)

Fixed submission:
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    if len(field) == 1:
        if len(field[0]) == 1:
            return "No"

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "#"

            if j - 1 >= 0:
                available |= field[i][j - 1] == "#"
            if j + 1 < len(row):
                available |= field[i][j + 1] == "#"

            if i + 1 < len(field):
                available |= field[i + 1][j] == "#"
            if not available:
                return "No"

    return "Yes"


if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)

Buggy submission (verdict: Runtime Error):
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    if len(field) == 1:
        if len(field[0]) == 1:
            return "No"

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "#"

            if j - 1 >= 0:
                available |= field[i][j - 1] == "#"
            if j + 1 < len(row):
                available |= field[i][j + 1] == "#"

            if i + 1 < len(row):
                available |= field[i + 1][j] == "#"
            if not available:
                return "No"

    return "Yes"


if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)

Buggy submission (verdict: Runtime Error):
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    if len(field) == 1:
        if len(field[0]) == 1:
            return "No"

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "#"

            if j - 1 >= 0:
                available |= field[i][j - 1] == "#"
            if j + 1 < len(row):
                available |= field[i][j + 1] == "#"

            if i + 1 < len(row):
                available |= field[i + 1][j] == "#"
            if not available:
                return "No"

    return "Yes"


if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)

Buggy submission (verdict: Runtime Error):
def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "#"

            if j - 1 >= 0:
                available |= field[i][j - 1] == "#"
            if j + 1 < len(row):
                available |= field[i][j + 1] == "#"

            if i + 1 < len(row):
                available |= field[i + 1][j] == "#"
            if not available:
                return "No"

    return "Yes"


if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)