Problem:


Score : 300 points

Problem Statement

We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.

Consider doing the following operation:

Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.

You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.

Constraints

1 \leq H, W \leq 6

1 \leq K \leq HW

c_{i,j} is . or #.

Input

Input is given from Standard Input in the following format:

H W K
c_{1,1}c_{1,2}...c_{1,W}
c_{2,1}c_{2,2}...c_{2,W}
:
c_{H,1}c_{H,2}...c_{H,W}

Output

Print an integer representing the number of choices of rows and columns satisfying the condition.

Sample Input 1

2 3 2
..#
###

Sample Output 1

5

Five choices below satisfy the condition.

The 1-st row and 1-st column

The 1-st row and 2-nd column

The 1-st row and 3-rd column

The 1-st and 2-nd column

The 3-rd column

Sample Input 2

2 3 4
..#
###

Sample Output 2

1

One choice, which is choosing nothing, satisfies the condition.

Sample Input 3

2 2 3
##
##

Sample Output 3

0

Sample Input 4

6 6 8
..##..
.#..#.
#....#
######
#....#
#....#

Sample Output 4

208



Sample input:
2 3 2
..#
###


Sample output:
5

Submission status: Runtime Error

Solution code:
h,m,k=map(int,input().split())
cl=[list(input().split()) for _ in range(h)]
b=h+m
c1=0
for i in range(2**b):
    c=copy.deepcopy(cl)
    bit=format(i, 'b').zfill(b)
    for j in range(h):#行
        if bit[j]=='1':
            for u in range(m):
                c[j][u]='+'
    
    for l in range(h,b):#列
        if bit[l]=='1':
            for o in range(h):
                c[o][l-h]='+'
    
    c2=0
    for p in range(h):
        c2+=c[p].count('#')
    if c2==k:c1+=1

print(c1)

Submission status: Runtime Error

Solution code:

import numpy as np
import os

def bcount(C):
    u, counts = np.unique(C, return_counts=True)
    return counts[0]


def main():
    H, W, K = map(int,input().split())
    C = []
    form1 = '0'+str(W)+'b'
    form2 = '0'+str(H)+'b'
    h2 = [str(format(i, form2)).split('b')[0] for i in range(2**H)]
    w2 = [str(format(i, form1)).split('b')[0] for i in range(2**W)]
    default_count = 0
    black_count = 0
    for i in range(H):
        C.append(list(map(str, list(input()))))
        default_count += C[i].count("#")
    print(default_count)
    
    if default_count == K:
        print(1)
        os._exit(1)
    elif default_count < K:
        print(0)
        os._exit(1)
    C = np.array(C,dtype = str)

    for i in range(len(h2)):
        co = np.copy(C)
        tmp = list(h2[i])
        for j in range(len(tmp)):
            if(tmp[j] == '1'):
                co[j,:] = "%"
        for k in range(len(w2)):
            co2 = np.copy(co)
            tmp = list(w2[k])
            for j in range(len(tmp)):
                if(tmp[j] == '1'):
                    co2[:,j] = "%"
            if (bcount(co2) == K):
                black_count += 1

    print(black_count)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:

import numpy as np
import os

def bcount(C):
    u, counts = np.unique(C, return_counts=True)
    return counts[0]


def main():
    H, W, K = map(int,input().split())
    C = []
    form1 = '0'+str(W)+'b'
    form2 = '0'+str(H)+'b'
    h2 = [str(format(i, form2)).split('b')[0] for i in range(2**H)]
    w2 = [str(format(i, form1)).split('b')[0] for i in range(2**W)]
    default_count = 0
    black_count = 0
    for i in range(H):
        C.append(list(map(str, list(input()))))
        default_count += C[i].count("#")
    print(default_count)
    
    if default_count == K:
        print(1)
        os._exit(1)
    elif default_count < K:
        print(0)
        os._exit(1)
    C = np.array(C,dtype = str)

    for i in range(len(h2)):
        co = np.copy(C)
        tmp = list(h2[i])
        for j in range(len(tmp)):
            if(tmp[j] == '1'):
                co[j,:] = "%"
        if (bcount(co) == K):
            black_count += 1

        for k in range(len(w2)):
            co2 = np.copy(co)
            tmp = list(w2[k])
            for j in range(len(tmp)):
                if(tmp[j] == '1'):
                    co2[:,j] = "%"
            if (bcount(co2) == K):
                black_count += 1

    print(black_count)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
mod = int(1e9+7)
n,k = map(int,input().split())
L=list(map(int,input().split()))

ans = 1

pos = []
neg = []
for i in L:
    if i>=0:
        pos.append(i)
    else:
        neg.append(i)
pos.sort(reverse=True)
neg.sort()
if len(pos) == 0 and k%2!=0:
    for i in range(1,k+1):
        ans*=neg[-i]
        ans%=mod
    print(ans%mod)
    sys.exit()
if k%2!=0:
    ans*=pos.pop(0)
    k-=1
l=[]
for i in range(1,len(pos),2):
    l.append(pos[i]*pos[i-1])

for i in range(1,len(neg),2):
    l.append(neg[i]*neg[i-1])

l.sort(reverse = True)
for i in range(k//2):
    ans*=l[i]
    ans%=mod

print(ans%mod)

Submission status: Runtime Error

Solution code:
    for i in range(H+W):
        summ += lis[i]*num
        num *= 2
    return(summ)
    
            
stock = []
counter = 0
import copy
for i0 in range(2):
    for i1 in range(2):
        for i2 in range(2):
            for i3 in range(2):
                for i4 in range(2):
                    for i5 in range(2):
                        for j0 in range(2):
                            for j1 in range(2):
                                for j2 in range(2):
                                    for j3 in range(2):
                                        for j4 in range(2):
                                            for j5 in range(2):
                                                preI = [i0,i1,i2,i3,i4,i5]
                                                preJ = [j0,j1,j2,j3,j4,j5]
                                                I = preI[0:H]
                                                J = preJ[0:W]
                                                
                                                if I+j in stock:
                                                    break
                                                stock.append(I+J)
                                                D = copy.deepcopy(C)
                                                
                                                for i in range(H):
                                                    gyotsubushi(i,D)
                                                for j in range(W):
                                                    retsutsubushi(j,D)
                                               
                                                count = 0
                                                for i in range(H):
                                                    for j in range(W):
                                                        if D[i][j] == '#':
                                                            count += 1
                                                            
                                                if count == K:
                                                    counter += 1

    
print(counter)

Submission status: Runtime Error

Solution code:
 h,w,k = map(int,input().split())
 board = [list(input()) for i in range(h)]
 ans = 0
 for paint_h in range(2**h):
     for paint_w in range(2**w):
         cnt = 0
         for i in range(h):
             for j in range(w):
                 if(paint_h >> i)&1==0 and (paint_w >> j)&1==0:
                    if board[i][j]=='#':
                        cnt += 1
        if cnt ==k:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
h,w,k = map(int,input().split())
board = [list(input()) for _ in range]
ans = 0
for paint_h in range(2**h):
    for paint_w in range(2**w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if(paint_h>>i)&1==0 and (paint_w>>j)&1==0:
                    if board[i][j]=='#':
                        cnt += 1
        if cnt == k:    
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
h,w,k = map(int,input().split())
board = [list(input()) for _ in range]
ans = 0
for paint_h in range(2**h):
    for paint_w in range(2**w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if(paint_h>>i)&1==0 and (paint_w>>j)&1==0:
                    cnt += 1
        if cnt == k:    
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import copy
h, w, k = map(int, input().split())
hw = []
mas = []
mas_su = 0

for i in range(h):
    hwi = input()
    masi = []
    for j in range(w):
        if hwi[j] == "#":
            masi.append(1)
        else:
            masi.append(0)

    mas_su += sum(masi)
    mas.append(masi)

l = 2**(h+w)
ans = 0

for i in range(l):
    test = copy.deepcopy(mas)
    num = 0
    for j in range(h+w):
        if ((i >> j) & 1):
            if j < h:
                for p in range(w):
                    if test[j][p]==1:
                        test[j][p] = 0
                        num += 1
            else:
                for p in range(h):
                    if test[p][j-w]==1:
                        test[p][j-w] = 0
                        num += 1
    if mas_su-num == k:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat=H):
    for col_bit in product(range(2), repeat=H):
        count = 0
        for h in range(H):
            for w in range(W):
                if c[h][w] == "#" and (row_bit[h] == 0 and col_bit[w] == 0):
                    count += 1
        if count == K:
            ans += 1


print(ans)

Submission status: Runtime Error

Solution code:
h, w, k = map(int, input().split())
grid = [input() for _ in range(h)]
ans = 0
for i in range(1<<h):
  for j in range(1<<w):
    count = 0
    for x in range(h):
      if i >> n & i:
        continue
      for y in range(w):
        if j >> m & 1:
          continue
        if grid[x][y] == '#':
          count += 1 
    if count == k:
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
h, w, k = map(int, input().split())
grid = [input() for _ in range(h)]
ans = 0
for i in range(1<<h):
  for j in range(1<<w):
    count = 0
    for x in range(h):
      if 1 << i & m:
        continue
      for y in range(w):
        if 1 << j & n:
          continue
        if grid[x][y] == '#':
          count += 1 
    if count == k:
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
h, w, k=map(int, input(). split())
table=[0]*h

for i in range(h):
    table[i]=input()


cnt=0
ans=0

for i in range(2**h):
    for j in range(2*:w):
        cnt=0
        for k in range(h):
            for l in range(w):
                if ((i>>k)&1)==1 and ((j>>l)&1)==1 and table[k][l]=="#":
                    cnt+=1
        
        if cnt==k:
            ans+=1


print(ans)

Submission status: Runtime Error

Solution code:
# def c():
#     n = int(input())
#     inp = {}
#     for i in range(n):
#         a = input()
#         if inp.get(a) is None:
#             inp[a] = 0
#         inp[a] += 1
#     print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
#     print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
#     print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
#     print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")

# c()


h, w, k = [int(x) for x in input.split()]
ans = 0

grid = []

for i in range(h):
    grid.append(input.split())

black = 0

for maskRow in range(0, 1 << h):
    for maskCol in range(0, 1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
                    black += 1
    if black == k:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
h, w, k = [int(x) for x in input.split()]
ans = 0

grid = []

for i in range(h):
	grid.append(input.split())

black = 0

for maskRow in range(0, 1 << h):
	for maskCol in range(0, 1 << w):
      black = 0
      for i in range(h):
        for j in range(w):
          if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
              black += 1
      if black == k:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
h, w, k = [int(x) for x in input.split()]
ans = 0

grid = []

for i in range(h):
    grid.append(input.split())

black = 0

for maskRow in range(0, 1 << h):
    for maskCol in range(0, 1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
                    black += 1
    if black == k:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
def kaijo(n):
  if n==1:
    return n
  return n*kaijo(n-1)

def Comb(n,r):
  return kaijo(n)/(kaijo(r)*kaijo(n-r))

H,W,K = map (int,input().split())
bector = []
for i in range(H):
  bec=[]
  bec = list(input())
  bector.append(bec)
count= = 0
for i in range(W+1):
  bectorA = bector
  for j in range(H):
    bectorA[j][:i] = "+"
    #これでi列分すべて赤になる
  for k in range(H+1):
    bectorB = bectorA
    for l in range(W):
      bectorB[k+1][l] = "+"
      #これでk行分すべて赤になる
      if bectorB.count("#") == K:
        count += Comb(H,k)*Comb(W,i)
print(count)

Submission status: Runtime Error

Solution code:
import copy
h,w,k = map(int,input().split())
li = []
ans = 0
for i in range(h):
    li.append(list(input()))
moto = 0
for i in range(h):
    moto += li[i].count("#")
for i in range(2**(h+w)):
    b = "0"*(h+w-len(bin(i))+2)+bin(i)[2:]
    libi = [int(b[s]) for s in range(h+w)]
    liloop = copy.deepcopy(li)
    for j in range(h+w):
        if libi[j] == 1:
            if j < h:
                for l in range(w):
                    liloop[j][l] = "." 
            else:
                for l in range(h):
                    liloop[l][j-w] = "."
    count = 0
    for j in range(h):
        count += liloop[j].count("#")
    if count == k:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
H, W, K = map(int, input().split())
G = [list(input()) for _ in range(H)]
for rows in range(2**H):
    for cols in range(2**W):
        black = 0
        for i in range(H):
            if rows >> i & 1:
                continue
            for j in range(W):
                if cols >> j & 1:
                    continue
                if G[i][j] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

int factorization(int n){
    int fac_ans = 1.0;
    for(int i=1;i<=n;i++) fac_ans *= i;
    return fac_ans;
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 100000000;


int main() {
    int h,w,k;
    cin >> h >> w >> k;
    string c[h];
    rep(i,h) cin >> c[i];

    int64_t ans=0,cnt=0;
    for(int tmp1 = 0; tmp1 < 1<<h; tmp1++){
        for(int tmp2 = 0; tmp2 < 1<<w; tmp2++){
            rep(i,h){
                rep(j,w){
                    if((tmp1&1<<i) || (tmp2&1<<j)) continue;
                    if(c[i][j] == '#') cnt++;
                }
            }
            if(cnt==k) ans++;
            cnt=0;
        }
    }

    cout << ans << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
from itertools import combinations
import copy
H,W,K = map(int,input().split())
cs = [list(input()) for i in range(H)]
HC = [i for i in range(H)]
WC = [i for i in range(W)]
cBlackCount=0
c=0
for i in range(H+1):
  for j in range(W+1):
    for selectRows in combinations(HC,i):
      for selectCols in combinations(WC,j):
        cBlackCount=fBlackCount
        for m in range(H):
          for n in range(W):
            if cs[m][n] == '#':
              if m in selectRows or n in selectCols:
                cBlackCount+=1
        if cBlackCount == K:
          c+=1
print(c)

Submission status: Runtime Error

Solution code:
import math
import numpy as np

large_input = input().split(' ')
H = int(large_input[0])
W = int(large_input[1])
K = int(large_input[2])

h_list = []
combination_black_in_h = 0
answer = 0

for h in range(H):
    num_black=0
    w_list = []
    w_black_list = []
    w_list_origin = input()
    for w in range(W):
        _ = w_list_origin[w:w+1]
        w_list.append(_)
        # 行で黒をK個取れる組合せを求める
        # #の数をカウント
        if _=='#':
            num_black += 1
            w_black_list.append(num_black)
    # print('num_black', num_black)
    h_list.append(w_list)
    # num_black coombination K = ()
    if num_black>=K:
        # print('num_black!', math.factorial(num_black))
        # print('(num_black - K)!', math.factorial(num_black - K))
        # print('K!', math.factorial(K))
        combination_black_in_h = math.factorial(num_black) / (math.factorial(num_black - K)*math.factorial(K))    
    # print(combination_black_in_h)
    answer += combination_black_in_h

for h_i in range(H):
    for h_j in range(H-1):
        if w_black_list[h_i]+w_black_list[h_i+1]==K:
            answer += 1

h_list_T = np.array(h_list).T.tolist()

for w in range(W):
    num_black=0
    w_list = []
    w_black_list_from_h = []
    w_list_origin_from_h = h_list_T[w]
    # w_list_origin = input()
    for h in range(H):
        _ = w_list_origin_from_h[h]
        # w_list.append(_)
        # 行で黒をK個取れる組合せを求める
        # #の数をカウント
        if _=='#':
            num_black += 1
            w_black_list_from_h.append(num_black)
    # print('num_black', num_black)
    # h_list.append(w_list)
    # num_black coombination K = ()
    if num_black>=K:
        # print('num_black!', math.factorial(num_black))
        # print('(num_black - K)!', math.factorial(num_black - K))
        # print('K!', math.factorial(K))
        combination_black_in_h = math.factorial(num_black) / (math.factorial(num_black - K)*math.factorial(K))    
    # print(combination_black_in_h)
    answer += combination_black_in_h

for h_i in range(H):
    for h_j in range(H-1):
        if w_black_list_from_h[h_i]+w_black_list_from_h[h_i+1]==K:
            answer += 1

# print(h_list)
print(int(answer))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define ll long long



int main(){
	int h, w, k, ans;
	cin >> h >> w >> k;
	char c[h][w];
	for(int i=0; i<h; i++) {
		for(int j=0; j<w; j++) {
			cin >> c[i][j];
		}
	}
	for(int i=0; i< 1<<h; i++) {
		for(int j=0; j< 1<<w; j++) {
			int black = 0;
			for(int x=0; x<h; x++) {
				for(int z=0; z<w; z++) {
					if(!(i>>x&1) && !(j>>z&1) && c[x][z] == '#'){
						black ++;
					}
				}
			}
			if(black == k) {
				ans ++;
			}
		}
	}
	cout << ans;
}

Submission status: Runtime Error

Solution code:
H,W,K=map(int,input().split())
F=[input() for _ in range(H)]
ans=0
for i in range(2**H):
 for j in range(2**W):
  cnt=0
  for ii in range(H):
   for jj in range(W):
    if i>>ii%2==0 or j>>jj%2==0 or F[ii][jj]==".":
     continue
    cnt+=1
  if cnt==K:
  ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np

h, w, k = map(int, input().split())
f = [list(input()) for i in range(h)]
f = np.array(f)
ans = 0
for i in range(w+1):
    for j in range(h+1):
        for p in itertools.combinations(range(w), i):
            for q in itertools.combinations(range(h), j):
                g = f.copy()
                cnt = 0
                for r in q:
                    g[r] = 'r'
                for r in p:
                    g.T[r] = 'r'
                
                for s in range(w):
                    for t in range(h):
                        if g[t][s] == '#':
                            cnt +=1
                if cnt == k:
                    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
'''
K = 2
H, W = 5, 5
a = np.array([
	[0, 0, 0, 0, 1],
	[0, 0, 0, 1, 1],
	[0, 0, 1, 1, 1],
	[0, 1, 1, 1, 1],
	[1, 1, 1, 1, 1]
])
'''

def conv(c):
	return int(c=='#')
H, W, K = map(int, input().split())
a = np.array([map(conv, input().split()) for _ in range(H)])

count = 0
for i in range(2 ** H - 1):
	b = np.delete(a.copy(), [j for j in range(H) if ((i >> j) & 1)], 0)
	for i in range(2 ** W - 1):
		c = np.delete(b.copy(), [j for j in range(H) if ((i >> j) & 1)], 1)
		#print(np.sum(c))
		if K==np.sum(c):
			count += 1
print(count)
print()

Submission status: Runtime Error

Solution code:
import numpy as np
'''
K = 2
H, W = 5, 5
a = np.array([
	[0, 0, 0, 0, 1],
	[0, 0, 0, 1, 1],
	[0, 0, 1, 1, 1],
	[0, 1, 1, 1, 1],
	[1, 1, 1, 1, 1]
])
'''

H, W, K = map(int, input().split())
a = np.array([map(int, input().split()) for _ in range(H)])

count = 0
for i in range(2 ** H - 1):
	b = np.delete(a.copy(), [j for j in range(H) if ((i >> j) & 1)], 0)
	for i in range(2 ** W - 1):
		c = np.delete(b.copy(), [j for j in range(H) if ((i >> j) & 1)], 1)
		#print(np.sum(c))
		if K==np.sum(c):
			count += 1
print(count)
print()

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
import copy
h, w, k = map(int, input().split())
f = [list(input()) for i in range(h)]
f = np.array(f)
ans = 0
for i in range(w+1):
    for j in range(h+1):
        for p in itertools.combinations(range(w), i):
            for q in itertools.combinations(range(h), j):
                g = f.copy()
                cnt = 0
                for r in q:
                    g[r] = 'r'
                for r in p:
                    g.T[r] = 'r'
                
                for s in range(w):
                    for t in range(h):
                        if g[t][s] == '#':
                            cnt +=1
                if cnt == k:
                    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
import copy
from itertools import combinations


def A(x):
  return 1000 - x % 1000 if x % 1000 != 0 else 0


def B(n, ss):
  keys_values = Counter(ss)
  orders = ['AC', 'WA', 'TLE', 'RE']
  for order in orders:
    if order in keys_values:
      print("{} x {}".format(order, keys_values[order]))
    else:
      print("{} x {}".format(order, 0))


def _get_num_black(c_list, r_list, h, w, g):
  num_black = 0
  for i in range(h):
    if i in r_list:
      continue
    for j in range(w):
      if j in c_list:
        continue
      num_black += (1 if g[i][j] == '#' else 0)
  return num_black


def C(h, w, k, g):
  num_choice = 0
  for i in range(k + 1):
    for j in range(k - i + 1):
      for c_list in list(combinations(range(w), j)):
        for r_list in list(combinations(range(h), i)):
          if _get_num_black(c_list, r_list, h, w, g) == k:
            num_choice += 1
          # print(h, i, r_list, w, j, c_list, num_black, k)
  return num_choice


def C2(H, W, K, g):
  """All copied."""
  c = []
  for i in range(H):
    c.append([])
    for j in range(W):
      c[i].append(g[i][j])

  ans = 0
  for h in range(H + 1):
    for w in range(W + 1):
      for h2 in combinations(list(range(H)), h):
        for w2 in combinations(list(range(W)), w):
          paint = copy.deepcopy(c)
          for h3 in h2:
            for i in range(W):
              paint[h3][i] = "r"
          for i in range(H):
            for w3 in w2:
              paint[i][w3] = "r"
          count_black = 0
          for i in range(H):
            count_black += paint[i].count("#")
            #print(count_black,paint[i])
          if count_black == K:
            ans += 1

  return ans


def C3(h, w, k, g):
  """
  - Change the calculation of count_black.
  - Change the name of variables.
  """
  num_choice = 0
  for i in range(h + 1):
    for j in range(w + 1):
      for h2 in combinations(list(range(h)), i):
        for w2 in combinations(list(range(w)), j):
          if _get_num_black(w2, h2, h, w, g) == k:
            ans += 1
  return num_choice


def main():
  h, w, k = map(int, input().split())
  g = []
  for i in range(h):
    g.append(input())
  print(C3(h, w, k, g))


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
import numpy as np
'''
K = 2
H, W = 5, 5
a = np.array([
	[0, 0, 0, 0, 1],
	[0, 0, 0, 1, 1],
	[0, 0, 1, 1, 1],
	[0, 1, 1, 1, 1],
	[1, 1, 1, 1, 1]
])
'''

H, W, K = map(int, input().split())
a = np.array([map(int, input().split()) for _ in range(H)])

count = 0
for i in range(2 ** H - 1):
	b = np.delete(a.copy(), [j for j in range(H) if ((i >> j) & 1)], 0)
	for i in range(2 ** W - 1):
		c = np.delete(b.copy(), [j for j in range(H) if ((i >> j) & 1)], 1)
		#print(np.sum(c))
		if K==np.sum(c):
			count += 1
print(count)

Submission status: Runtime Error

Solution code:
H, W, K = (int(x) for x in input().split())

all = []
all.append(list(range(H+2)))
for idx in range(H):
    row = list(input())
    row.insert(0,'')
    all.append(row)

def copyList(i, j):
    res = []
    for idxI in range(H+1):
        if idxI != i:
            copyRow = []
            for idxJ in range(W+1):
                if idxJ != j:
                    copyRow.append(all[idxI][idxJ])
            res.append(copyRow)
    return res

def cntSharp():
    result = 0
    for tarI in range(H):
        for tarJ in range(W):
            tar = copyList(tarI,tarJ)
            cnt = 0
            for r in tar:
                for c in r:
                    if c == '#':
                        cnt = cnt + 1
            if cnt == K:
                result = result + 1
    return result

print(cntSharp())

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np

N,W,K = map(int,input().split())
g_all = np.array([list(input()) for i in range(N)])

K_all = np.count_nonzero(g_all == '#')
count = 0

def dfs(i,g):
  if (i<N):
    g[i,:] = ['r']*W
  else:
    g[:,i-N] = ['r']*N
  return g

g = g_all

for L in range(2**(N+W)): #2^n通り
  g = g_all.copy()
  for i in range(N+W):　#bit列分
    if (i<N):
      if ((L>>i)&1):
        g[i,:] = ['r']*W
    else:
      if ((L>>i)&1):
        g[:,i-N] = ['r']*N
  if np.count_nonzero(g == '#') ==K:
    count+=1
print(count)

Submission status: Runtime Error

Solution code:
H=2
W=3
K=2

masme = [
[".",".","#"],
["#","#","#"]
]

H, W, K =  [int(i) for i in input().split()]

masme = []
for i in range(H):
    masme.append(list(input()))

#print(masme)

h_p = []
for h in range(pow(2,H)):
    h_p.append(str(bin(h))[2:].zfill(H))

#print(h_p)

w_p = []
for w in range(pow(2,W)):
    w_p.append(str(bin(w))[2:].zfill(W))

#print(w_p)

def count(mas):
    ans = 0
    for i in mas:
        for j in i:
            if( j == "#"):
                ans += 1
    return ans

def delete_row(mas, i):
    ilist = list(i)
    #print(ilist)
    ans = []
    for n in range(len(ilist)):
        #print(ilist[n])
        if ilist[n] == "0":
            ans.append(mas[n])
            #print(ans)
    return ans

def delete_column(mas, i):
    ilist = list(i)
    ans = []
    for row in mas:
        #print(row)
        tmp_row=[]
        for n in range(len(ilist)):
            if(ilist[n] == "0"):
                tmp_row.append(row[n])
        #print(tmp_row)
        ans.append(tmp_row)
    return ans

newmas = delete_column(masme, "010")

#print(newmas)

ans_cnt = 0
for h in h_p:
    for w in w_p:
        tmp = delete_row(masme, h)
        tmp2= delete_column(tmp, w)
        cnt = count(tmp2)
        if(cnt == K):
            ans_cnt += 1

print(ans_cnt)

Submission status: Runtime Error

Solution code:
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int h, w, k; 

int check(vector<string> &da, int a, int b) {
    int ans = 0;
    rip(i,h,0) {
        rip(j,w,0) {
            if(((a >> i)&1)==0 && ((b >> j)&1) == 0) {
                if(da[i][j] == '#') ++ans;
            }
        }
    }
    return ans;
}

int main() {
    cin >> h >> w >> k;
    vector<string> da(h);
    rip(i,h,0) cin >> da[i];
    int ans = 0;
    rip(i, 1 << h, 0) {
        rip(j, 1 << w, 0) {
            if(check(da, i, j) == k) ++ans;
        }
    }
    cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
h, w, k = map(int, input().split())
c = []
for _ in range(h):
    c.append(list(map(str, input().split())))
ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        iter = 0
        for ij in range(h):
            for jj in range(w):
                if ((i >> ij) & 1) or ((j >> jj) & 1):
                    continue
                if c[ij][jj] == "#":
                    iter += 1
        if iter == k:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import copy 

h, w, k = map(int, input().split())
c = []
for _ in range(h):
    c.append(list(map(str, input().split())))
ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        iter = 0
        for ij in range(h):
            for jj in range(w):
                if ((i >> ij) & 1) or ((j >> jj) & 1):
                    continue
                if c[ij][jj] == "#":
                    iter += 1
        if iter == k:
            ans += 1
print(ans)