Problem p02614 (python)

Fixed submission:
h, w, k = map(int, input().split())
c = []
for cnt in range(h):
    c.append(input())

black_num = 0
temp_list = []
row_bit = []
line_bit = []

ans = 0

# for cnt_h in range(h):
#     for cnt_w in range(w):
#         if c[cnt_h][cnt_w] == "#":
#             black_num += 1
# if black_num == k:
#     print(1)
if 1 == 2:
    print()
else:
    for i in range(2**h):
        temp_bit = [0] * h

        for j in range(h):
            if((i >> j) & 1):
                temp_bit[h - 1 - j] = 1

        row_bit.append(temp_bit)

    for i in range(2**w):
        temp_bit = [0] * w

        for j in range(w):
            if((i >> j) & 1):
                temp_bit[w - 1 - j] = 1

        line_bit.append(temp_bit)

    # print(row_bit)
    # print(line_bit)

    for cnt_row in range(2**h):
        for cnt_line in range(2**w):
            temp_list = []
            black_num = 0
            for cnt_h in range(h):
                if row_bit[cnt_row][cnt_h] == 0:
                    # temp_list.append(c[cnt_h])
                    for cnt_w in range(w):
                        if line_bit[cnt_line][cnt_w] == 0:
                            # print("this", temp_list[cnt_line][cnt_w])
                            if c[cnt_h][cnt_w] == '#':
                                black_num += 1

            # black_num = 0
            # for cnt_h in range(len(temp_list)):
            #     for cnt_w in range(len(temp_list[cnt_h])):
            #         if temp_list[cnt_h][cnt_w] == "#":
            #             black_num += 1
            if black_num == k:
                ans += 1

    print(ans)

Buggy submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
c = []
for cnt in range(h):
    c.append(input())

black_num = 0
temp_list = []
row_bit = []
line_bit = []

ans = 0

# for cnt_h in range(h):
#     for cnt_w in range(w):
#         if c[cnt_h][cnt_w] == "#":
#             black_num += 1
# if black_num == k:
#     print(1)
if 1 == 2:

else:
    for i in range(2**h):
        temp_bit = [0] * h

        for j in range(h):
            if((i >> j) & 1):
                temp_bit[h - 1 - j] = 1

        row_bit.append(temp_bit)

    for i in range(2**w):
        temp_bit = [0] * w

        for j in range(w):
            if((i >> j) & 1):
                temp_bit[w - 1 - j] = 1

        line_bit.append(temp_bit)

    # print(row_bit)
    # print(line_bit)

    for cnt_row in range(2**h):
        for cnt_line in range(2**w):
            temp_list = []
            black_num = 0
            for cnt_h in range(h):
                if row_bit[cnt_row][cnt_h] == 0:
                    # temp_list.append(c[cnt_h])
                    for cnt_w in range(w):
                        if line_bit[cnt_line][cnt_w] == 0:
                            # print("this", temp_list[cnt_line][cnt_w])
                            if c[cnt_h][cnt_w] == '#':
                                black_num += 1

            # black_num = 0
            # for cnt_h in range(len(temp_list)):
            #     for cnt_w in range(len(temp_list[cnt_h])):
            #         if temp_list[cnt_h][cnt_w] == "#":
            #             black_num += 1
            if black_num == k:
                ans += 1

    print(ans)