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

Solution (Python):
import copy
H, W, K = map(int, input().split())
C = []
for i in range(H):
    C.append(list(input()))
ans = 0
for i in range(2**H):
    for j in range(2**W):
        tmp = copy.deepcopy(C)
        for k in range(H):
            if i >> k & 1:
                for m in range(W):
                    tmp[k][m] = "r"
        for l in range(W):
            if j >> l & 1:
                for n in range(H):
                    tmp[n][l] = "r"
        cnt = 0
        for h in range(H):
            for w in range(W):
                if tmp[h][w] == "
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):

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

ans = 0
for i in range((1 << H)):
    for j in range((1 << W)):
        black = 0
        for k in range(H):
            for l in range(W):
                if ((i >> k) & 1) == 0 and ((j >> l) & 1) == 0 and C[k][l] == '
                    black += 1
        if black == K:
            ans += 1
print(ans)

Solution (Python):
import itertools
def getCombList(xList):
  N = len(xList)
  result = []
  for n in range(1,N+1):
    for conb in itertools.combinations(xList, n):
      result.append(list(conb)) 
  
  return result

import numpy as np
L1 = input()
H, W, K = map(int, L1.split(" "))
mat = np.zeros([H,W], dtype="int32")
for i in range(H):
  Li = input()
  for j, s in enumerate(Li):
    if s == "
      mat[i,j] = 1

if np.sum(np.sum(mat)) < K:
  print(0)
else:
  if np.sum(np.sum(mat)) == K:
    c = 1
  else:
    c = 0
  matp = mat.copy()
  HList = list(range(H))
  WList = list(range(W))
  HcombList = getCombList(HList)
  WcombList = getCombList(WList)
  for Hcomb in HcombList:
    for Wcomb in WcombList:
      matp[Hcomb, :] = 0
      matp[:, Wcomb] = 0
      if np.sum(np.sum(matp)) == K:
        c = c + 1
      matp = mat.copy()
      
  for Hcomb in HcombList:
    matp[Hcomb, :] = 0
    if np.sum(np.sum(matp)) == K:
      c = c + 1
    matp = mat.copy()

  for Wcomb in WcombList:
    matp[:, Wcomb] = 0
    if np.sum(np.sum(matp)) == K:
      c = c + 1
    matp = mat.copy()

  print(c)

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

ans = 0
for row_bit in product(range(2), repeat=H):
    for col_bit in product(range(2), repeat=W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == "
                    cnt += 1
        
        if cnt == K:
            ans += 1

print(ans)

Solution (Python):
from itertools import product
import numpy as np

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

ans = 0
hw_bits = product([False, True], repeat=H+W)
for hw_ in hw_bits:
    h_ = list(hw_[:H])
    w_ = list(hw_[H:])
    if sum(list(h_))!=0 and sum(list(w_))!=0:
        x = np.sum(C[h_].T[w_] == '
        if x == K:
            ans += 1
print(ans)

Solution (Python):
import sys
import itertools


def resolve(in_):
    h, w, k = map(int, next(in_).split())
    c = [row.strip() for row in in_]
    
    

    ans = 0
    black_char = ord(b'
    red_mask = itertools.product(
        itertools.product((True, False), repeat=h),
        itertools.product((True, False), repeat=w),
    )
    for not_red_row, not_red_col in red_mask:
        black_n = 0
        
        for i, j in itertools.product(range(h), range(w)):
            
            if c[i][j] == black_char and not_red_row[i] and not_red_col[j]:
                black_n += 1
                if black_n > k:
                    break
        else:
            if black_n == k:
                ans += 1

    return ans


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):


def solve():
    h, w, k = map(int, input().split())
    c = [list(input()) for i in range(h)]
    ans = 0
    for ii in range(1<<h):
        for jj in range(1<<w):
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if ii>>i & 1:
                        continue
                    if jj>>j & 1:
                        continue
                    if c[i][j] == '
                        cnt += 1
            if cnt == k:
                ans += 1
    return ans

print(solve())

Solution (Python):
h, w, k = map(int, input().split(' '))

c = [[0 for j in range(w)] for i in range(h)]

for i in range(h):
    line = input()
    for j in range(w):
        c[i][j] = line[j]

ans = 0

for il in range(1<<h):
    for jl in range(1<<w):
        count = 0
        for i in range(h):
            for j in range(w):
                if il>>i&1: continue
                if jl>>j&1: continue
                if c[i][j] == '
        if count == k: ans += 1

print(ans)

Solution (Python):
def prov(maskHor, maskVert):
    kol = 0
    for i in range(h):
        for j in range(v):
            if m[i][j] == '
                b = 0
                for hor in maskHor:
                    if hor == i:
                        b = 1
                for vert in maskVert:
                    if vert == j:
                        b = 1
                if b == 0:
                    kol += 1
    
    
    
    
    
    
    
    if kol == k:
        global ans
        ans += 1


def genMaskVert(pos, mask, maskHor):
    if (pos == v):
        prov(maskHor, mask)
        
        
        return
    else:
        genMaskVert(pos + 1, mask, maskHor)
        temp = mask
        temp.append(pos)
        genMaskVert(pos + 1, temp, maskHor)
        if not len(mask) == 0:
            mask.pop()
        return


def genMaskHor(pos, mask):
    if (pos == h):
        genMaskVert(0, [], mask)
        
        
        return
    else:
        genMaskHor(pos + 1, mask)
        mask.append(pos)
        genMaskHor(pos + 1, mask)
        if not len(mask) == 0:
            mask.pop()
        return


h, v, k = input().split()
h = int(h)
v = int(v)
k = int(k)
ans = 0
m = []
for i in range(h):
    m.append(input())
genMaskHor(0, [])
print(ans)

Solution (Python):
import copy
h,w,k=map(int,input().split())
L=[list(input()) for i in range(h)]
r=0
for i in range(1<<h):
    for j in range(1<<w):
        T=copy.deepcopy(L)
        for l in range(h):
            if i & (1<<l):
                for a in range(w):
                    T[l][a]='.'
        for m in range(w):
            if j & (1<<m):
                for b in range(h):
                    T[b][m]='.'
        c=0
        for d in range(h):
            for e in range(w):
                if T[d][e]=='
                    c+=1
        if c==k:
            r+=1
print(r)

Solution (Python):
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]
ybla = [0]*H
xbla = [0]*W
all_black = 0
for i in range(H):
    all_black += c[i].count('
    ybla[i] += c[i].count('
    for j in range(W):
        if c[i][j] == '
            xbla[j] += 1


ans = 0
for i in range(2**H):
    y = []
    total1 = 0
    for j in range(H):
        if (i >> j) & 1:
            y.append(j)
            total1 += ybla[j]
    
    for k in range(2**W):
        x = []
        total2 = 0
        for l in range(W):
            if (k >> l) & 1:
                
                x.append(l)
                total2 += xbla[l]
        total = total1 + total2
        if len(y) and len(x):
            for yy in y:
                for xx in x:
                    if c[yy][xx] == '
                        total -= 1
        
    
        if all_black == K + total:
            ans += 1

print(ans)

Solution (Python):
from itertools import combinations

h, w, k = map(int, input().split())
C = [input() for _ in range(h)]

columns = [i for i in range(w)]
rows = [i for i in range(h)]

ans = 0
for c in range(w+1):
    for r in range(h+1):
        for column in combinations(columns, c):
            for row in combinations(rows, r):
                cnt = 0
                for x in range(w):
                    for y in range(h):
                        if not (x in column or y in row):
                            if C[y][x] == '
                                cnt += 1
                if cnt == k:
                    ans += 1

print(ans)

Solution (Python):
h, w, n = map(int, input().split())
test = [input() for i in range(h)]
ans = 0
for binh in range(2 ** h):
	for binw in range(2 ** w):
		tmp = 0
		for l in range(h):
			for m in range(w):
				if ((binh >> l) & 1) == 0  and ((binw >> m) & 1) == 0 and test[l][m] == "
					tmp += 1
		if tmp == n:
			ans += 1	
print(ans)

Solution (Python):


H,W,K = map(int,input().split())

HB = [0] * H 
ans = 0

for i in range(H):
    koko = input()
    HB[i] = koko

for r in range(int(1 << H) - 1):
    for c in range(int(1 << W) - 1):
        black = 0
        for i in range(H):
            for j in range(W):
                if((r >> i) & 1) == 0 and ((c >> j) & 1) == 0 and HB[i][j] == '
                    black += 1
        if black == K:
            ans += 1

print('{}'.format(ans))

Solution (Python):



from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

import copy
H, W, K = [int(_) for _ in input().split()]
C = [input() for i in range(H)]

def calc(lis):
    global C, K

    c = copy.copy(C)

    for i in lis:
        if i // 10 == 1:
            c[i%10-1] = "-" * W
        else:
            for j in range(H):
                tmp = list(c[j])
                tmp[i-1] = "-"
                c[j] = "".join(tmp)

    ct = 0
    for i in c:
        a = Counter(i)
        ct += a["
    
    if ct == K:
        return 1
    return 0
                
count = 0
lis = list(range(1, W + 1)) + list(range(11, 10 + H + 1))

ret = 0
for i in range(H+W):
    for com in list(combinations(lis, i)):
        ret += calc(com)

print(ret)

Solution (Python):
import itertools
import copy

h,w,k = list(map(int, input().split()))
lst = [None for i in range(h)]
for i in range(h):
    lst[i] = list(input())
ans = 0

H = list(itertools.product([0,1],repeat=h))
W = list(itertools.product([0,1],repeat=w))

for i in H:
    for j in W:
        lst_test = copy.deepcopy(lst)
        for I in range(h):
            if i[I]==1:
                for a in range(w):
                    lst_test[I][a] = "R"
        for J in range(w):
            if j[J]==1:
                for a in lst_test:
                    a[J] = "R"
        
        
        count = 0
        for a in lst_test:
            for b in a:
                if b=="
                    count += 1
        if count == k:
            ans += 1

print(ans)

Solution (Python):
def get_unique_list(seq):
  seen = []
  return [x for x in seq if x not in seen and not seen.append(x)]

import itertools
h,w,k = map(int, input().split())
m = []
s=0
for i in range(h):
  t = input()
  m.append(t)
  s+=t.count("
list_w = [i for i in range(w)]
list_h = [i for i in range(h)]
combi_w=[]
combi_h=[]
for i in range(w):
  for pair in itertools.combinations(list_w, i):
    combi_w.append(pair)
for i in range(h):
  for pair in itertools.combinations(list_h, i):
    combi_h.append(pair)
ans=0
for i in combi_w:
  temp_w=[]
  for row in i:
    for c in range(h):
      if m[c][row] == "
        temp_w.append([c,row])
  for j in combi_h:
    temp_h=[]
    for col in j:
      for r in range(w):
        if m[col][r] == "
          temp_h.append([col,r])
    temp2 = get_unique_list(temp_w + temp_h)
    if len(temp2) == s-k:
      ans += 1
    
print(ans)

Solution (Python):
import numpy as np

H, W, K = map(int, input().split())
m = []
for _ in range(H):
  m.append([1 if s=="

m = np.array(m)
ans = 0

for h in range(2**H):
  for w in range(2**W):
    mcopy = m.copy()
    hcopy = h
    wcopy = w
    for i in range(H):
      if hcopy%2==1:
        mcopy[i,:] = 0
      hcopy = hcopy//2
    for i in range(W):
      if wcopy%2==1:
        mcopy[:,i] = 0
      wcopy = wcopy//2
    if mcopy.sum()==K:
      ans += 1

print(ans)

Solution (Python):
def count(lst):
    count = 0
    for i in lst:
        for j in i:
            if j == "
    return count

def main(n, m, k, lst):
    ways = 0
    for i in range(2**(n+m)):
        binS = "0" * ((n+m) - len(str(bin(i))[2:])) + str(bin(i))[2:]
        lst1 = lst.copy()
        ind, ind1 = 0, 0
        for j in range(len(binS)):
            if binS[j] == "1":
                if j+1 <= m:
                    for r in range(len(lst1)):
                        lst1[r] = lst1[r][:j-ind] + lst1[r][j+1-ind:]
                    ind += 1
                else:
                    c = j - m - ind1
                    lst1 = lst1[:c] + lst1[c+1:]
                    ind1 += 1
        if count(lst1) == k:
            ways += 1
    return ways

lst = []
n, m, k = [int(x) for x in input().split()]
for _ in range(n):
    s = input()
    lst.append(s)
print(main(n, m, k, lst))

Solution (Python):
h,w,z = map(int,input().split())
import copy
c = [list(input()) for _ in range(h)]
ans = 0
for i in range(2**h):
    for j in range(2**w):
        mat = copy.deepcopy(c)
        count = 0
        for k in range(w):
            if j>>k &1:
                for u in range(h):
                    mat[u][k] = "red"
        for l in range(h):
            if i>>l & 1:
                for g in range(w):
                    mat[l][g] = "red"
        for k in range(h):
            for l in range(w):
                if mat[k][l] == "
                    count += 1
        if count == z:
            ans += 1
print(ans)

Solution (Python):
import numpy as np
from itertools import chain, combinations, product

H, W, K = [int(x) for x in input().split()]
rows = [input() for _ in range(H)]

def create_grid(rows, value_map, dtype=None):
    return np.array([[value_map[c] for c in row] for row in rows], dtype=dtype)
grid = create_grid(rows, {'.': 0, '

count = 0
row_combinations = list(chain(*[combinations(range(H), i) for i in range(H)]))
column_combinations = list(chain(*[combinations(range(W), i) for i in range(W)]))
for rows, columns in product(row_combinations, column_combinations):
    copy = grid.copy()
    for i in rows:
        copy[i] = 0
    for j in columns:
        copy[:, j] = 0
    if copy.sum() == K:
        count += 1

print(count)

Solution (Python):
h, w, k = map(int, input().split())
arr = [input() for _ in range(h)]

ans = 0
for bit_h in range(2**h):
    for bit_w in range(2**w):
        tmp = 0
        for i in range(h):
            if (bit_h >> i) & 1:
                continue
            for j in range(w):
                if (bit_w >> j) & 1:
                    continue
                if arr[i][j] == '
                    tmp += 1
        if tmp == k:
            ans += 1

print(ans)

Solution (Python):
'''
全通り列挙して数える
'''

h,w,k = map(int, input().split())

c = []
cnt = 0
ans = 0

for i in range(h):
    c.append(str(input()))

for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for ib in range(h):
            for jb in range(w):
                
                if (i>>ib)&1 or (j>>jb)&1:
                    pass
                elif c[ib][jb] == "
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Solution (Python):
h,w,k=map(int,input().split())
L=list()
for i in range(h):
    L.append(list(input()))
import itertools
import copy
v1=itertools.product([0,1],repeat=h)
v2=itertools.product([0,1],repeat=w)
V=list(itertools.product(v1,v2))
ans=0
for v in V:
    
    
    S=0
    Lcopy=copy.deepcopy(L)
    
    for i in v[0]:
        for j in range(h):
            if v[0][j]==1:
                Lcopy[j]=['.']*w
    for i in v[1]:
        for j in range(w):
            if v[1][j]==1:
                for l in range(h):
                    Lcopy[l][j]='.'
    
    for i in range(h):
        for j in range(w):
            if Lcopy[i][j]=='
                S+=1
    if S==k:
        ans+=1
        
print(ans)

Solution (Python):


def solve():
    import numpy as np
    import copy

    H, W, K = list(map(int, input().split()))
    Cs = []
    for _ in range(H):
        s = input()
        lst = []
        for moji in s:
            a = 0 if moji == "." else 1
            lst.append(a)
        Cs.append(lst)
    Cs = np.array(Cs)

    Hs = []
    for bits in range(1<<H):
        lst = []
        for i in range(H):
            lst.append(bits>>i&1)
        Hs.append(np.array(lst).reshape(H,1))

    Ws = []
    for bits in range(1<<W):
        lst = []
        for i in range(W):
            lst.append(bits>>i&1)
        Ws.append(np.array(lst))

    ans = 0
    oCs = Cs
    for hs in Hs:
        for ws in Ws:
            Cs = copy.deepcopy(oCs)
            
            Cs *= ws
            Cs *= hs
            
            
            
            
            if Cs.sum() == K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):
h,w,k = map(int,input().split())
c = [list(input()) for _ in range(h)]
ans = 0
for i in range(1 << h):
    for j in range(1 << w):
        cnt = 0
        for l in range(h):
            for m in range(w):
                if (i >> l) & 1 == 0 and (j >> m) & 1 == 0: 
                    if c[l][m] == "
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
H, W, K= map(int, input().split()) 

Map = []
M = []
for _ in range(H):
    M.append(input())
Map = [list(i) for i in M]
tmpH = [2**h for h in range(H)]
tmpW = [2**w for w in range(W)]




numH = 2**H
numW = 2**W
count = 0
result = 0

for nh in range(numH):
    for nw in range(numW):
        for h_id in range(len(tmpH)):
            for w_id in range(len(tmpW)):
                if tmpH[h_id] & nh == 0 and tmpW[w_id] & nw == 0 and Map[h_id][w_id] == '
                    count += 1
        if count == K:
            result += 1
        count = 0

print(result)

Solution (Python):
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=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if c[row][col] == "
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Solution (Python):
h, w, k = [int(s) for s in input().split() ]
squares = []


for i in range(h):
    squares = squares + [s for s in input()]

ans = 0
for i in range(2**h):
    for j in range(2**w):
        buf = [s for s in squares]
        for d in range(h):
            if (i>>d) & 1:
                for n in range(w):
                    buf[d * w + n] = 'x'

        for d in range(w):
            if (j>>d) & 1:
                for n in range(h):
                    buf[d + w * n] = 'x'

        if buf.count('
            ans = ans + 1

print(ans)

Solution (Python):
def main():
    H,W,K=map(int,input().split())
    HW = [input() for _ in range(H)]
    ans = 0
    for h in range(1<<H):
        for w in range(1<<W):
            tmp = 0
            for i in range(H):
                for j in range(W):
                    if ((h>>i)&1)==0 and ((w>>j)&1)==0 and HW[i][j]=="
                        tmp += 1
            if K == tmp:
                ans += 1
    print(ans)

main()

Solution (Python):
import numpy as np
import copy
H, W, K = map(int, input().split())
mat = np.zeros((H, W), dtype = int)
for i in range(H):
    s = input()
    s = s.replace('.', '0 ')
    s = s.replace('
    mat[i, :] = list(map(int, s.split()))
cnt = 0
for i in range(2 ** H):
    for j in range(2 ** W):
        a = copy.deepcopy(mat)
        for k in range(H):
            if (i >> k) & 1:
                a[k, :] *= 0
            for l in range(W):
                if (j >> l) & 1:
                    a[:, l] *= 0
        if np.count_nonzero(a == 1) == K:
            cnt += 1
print(cnt)

Solution (Python):
H,W,K = map(int, input().split())

id_count = 0
d = {}

for i in range(H):
  
  l = input()
  for j in range(W):

    if l[j] == '
      if i in d:
        d[i].append(id_count)
      else:
        d[i]=[id_count]
        
      if j+H in d:
        d[j+H].append(id_count)
      else:
        d[j+H]=[id_count]
      id_count +=1


      
ans = 0





  
for i in range(2 ** (H+W)):
  wrk_list=[]
  for j in range(H+W):  
    if ((i >> j) & 1):  
      wrk_list.extend(d.get(j,[]))  
    if wrk_list==[]:
      set1 = []
    else:
      set1 = set(wrk_list)
  

  if id_count - len(set1) == K:
    ans +=1
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]
ans = 0
for h_p in range(2 ** h):
    for w_p in range(2 ** w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (h_p >> i) & 1 and (w_p >> j) & 1 and c[i][j] == '
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
import copy
import numpy as np


def count_black(c):
    count = 0
    for row in c:
        count += row.count('
    return count


h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
ans = 0

for h_p in range(2 ** h):
    for w_p in range(2 ** w):
        c_cp = np.array(copy.deepcopy(c))
        for i in range(h):
            if (h_p >> i) & 1:
                c_cp[i, :] = 'r'

        for j in range(w):
            if (w_p >> j) & 1:
                c_cp[:, j] = 'r'

        if count_black(c_cp.tolist()) == k:
            ans += 1
print(ans)

Solution (Python):
import numpy as np


def main():
    h, w, k = map(int, input().split())
    cs = np.array([list(input()) for _ in range(h)])

    ans = 0
    for paint_h in range(2 ** h):
        for paint_w in range(2 ** w):
            cnt = 0
            for j in range(h):
                for l in range(w):
                    if ((paint_h >> j) & 1) == 0 and ((paint_w >> l) & 1) == 0:
                        if cs[j][l] == '
                            cnt += 1
            if cnt == k:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
from copy import copy

def binaryList(n,HW):
    l=np.zeros(HW)
    for i in range(HW):
        if n%2==0:
            l[i]=0
        else:
            l[i]=1
        n=n//2
    return l

if __name__ == "__main__":
    HWK=input().split(" ")
    H,W,K=int(HWK[0]),int(HWK[1]),int(HWK[2])
    l=[]
    for i in range(H):
        buf=[]
        s=input()
        for i in s:
            buf.append(1 if i=="
        l.append(buf)
    l=np.array(l,np.uint8)
    cnt=0
    for i in range(2**H):
        for j in range(2**W):
            buf=copy(l)
            h=binaryList(i,H).reshape(1,-1).repeat(W,0).transpose().astype(np.uint8)
            w=binaryList(j,W).reshape(1,-1).repeat(H,0).astype(np.uint8)
            buf[h==1]=0
            buf[w==1]=0
            if buf.sum()==K:
                cnt+=1
    print(cnt)

Solution (Python):
import copy
h,w,k = map(int,input().split())
c = [[1*(i=="
ans = 0
for i in range(2**h):
    l1 = []
    for i1 in range(h):
        l1.append(i >> i1 & 1)
    for j in range(2**w):
        l2 = []
        for j1 in range(w):
            l2.append(j >> j1 & 1)
        
        c2 = copy.deepcopy(c)
        for i2 in range(h):
            if l1[i2]:
                for j3 in range(w):
                    c2[i2][j3] = 0
        for j2 in range(w):
            if l2[j2]:
                for i3 in range(h):
                    c2[i3][j2] = 0
        s = 0
        for t in range(h):
            s += sum(c2[t])
        if s == k:
            ans += 1

print(ans)

Solution (Python):
h, w, k = map(int, input().split())
c = [""] * h
for i in range(h):
    c[i] = input()

ans = 0
for i in range(2 ** h):
    hst = set()
    for ii in range(h):
        if (i >> ii) & 1:
            hst.add(ii)
    for j in range(2 ** w):
        wst = set()
        for jj in range(w):
            if (j >> jj) & 1:
                wst.add(jj)
        cnt = 0
        for x in range(h):
            for y in range(w):
                if x in hst or y in wst:
                    continue
                if c[x][y] == "
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
def main():
    H, W, K = [int(i) for i in input().split(' ')]
    grid = [list(input()) for i in range(H)]
    res = 0
    for i in range(2**H):
        for j in range(2**W):
            g = grid

            remains_black = 0
            for h in range(H):
                if (i >> h) & 1 == 1:
                    continue
                for w in range(W):
                    if (j >> w) & 1 == 1:
                        continue
                    if grid[h][w] == '
                        remains_black += 1

            if remains_black == K:
                res += 1
    return res

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

Solution (Python):
from itertools import product

H, W, K = map(int, input().split())
ary = []
for y in range(H):
    ary.append(input())

case = 0
for yb in range(1<<H):
    for xb in range(1<<W):
        nb = 0
        for y in range(H):
            for x in range(W):
                if ((not ((yb >> y) & 1) and ((xb >> x) & 1))) and ary[y][x] == '
                    nb += 1
        if nb == K:
            case += 1

print(case)

Solution (Python):
def resolve():
    H, W, K = map(int, input().split())
    c = []
    ans = 0
    for i in range(H):
        C = list(input())
        c.append(C)
    for p in range(2**H):
        for q in range(2**W):
            count = 0
            for h in range(H):
                for j in range(W):
                    if ((p >> h) & 1) == 0 and ((q >> j) & 1) == 0 and c[h][j] == "
                        count += 1
            if count == K:
                ans += 1
    print(ans)
resolve()

Solution (Python):
H, W, K = map(int, input().split(' '))
C = []*H
ans=0
C = [list(input()) for _ in range(H)]
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 C[i][j] == '
                        cnt+=1
        if cnt==K:
            ans+=1
print(ans)

Solution (Python):
H,W,K=map(int,input().split())

C=[list(input()) for _ in range(H)]
ans=0

for i in range(2**(H+W)):
    H_,W_=[0]*H,[0]*W
    bin_=format(i,'b').zfill(H+W)
    for n,b in enumerate(bin_):
        if n<H and b=='1':
            H_[n-1]=1
        elif n>=H and b=='1':
            W_[n-H]=1
    blackCnt=0
    for n,c_ in enumerate(C):
        for m,c in enumerate(c_):
            if H_[n]==0 or W_[m]==0:
                continue
            if c=='
                blackCnt+=1
    if blackCnt==K:
        ans+=1

print(ans)

Solution (Python):
h, w, k = [int(x) for x in input().rstrip().split(' ')]
counter = 0
mat = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
  line = input().rstrip()
  for j, c in enumerate(line):
    if c == '
      mat[i][j] = 1
h_mask = [0 for i in range(h)]
w_mask = [0 for j in range(w)]
for itr in range(2**(h+w)):
  _counter = 0
  for i in range(h):
    h_mask[i] = itr%2
    itr//=2
  for j in range(w):
    w_mask[j] = itr%2
    itr//=2
  for i in range(h):
    for j in range(w):
      if h_mask[i] == 1 and w_mask[j] == 1:
        _counter += mat[i][j]
  if _counter == k:
    counter+=1

print(counter)

Solution (Python):



import numpy as np

H, W, K = map(int, input().split())

c = np.zeros((H, W))
result = 0
for i in range(H):
    word = input()
    for j in range(W):
        if word[j] == '.':
            c[i][j] = 0
        elif word[j] == '
            c[i][j] = 1

for mask_h in range(2**H):
    bin_mask_h = format(mask_h,  '0' + str(H) + 'b')
    for mask_w in range(2**W):
        bin_mask_w = format(mask_w, '0' + str(W) + 'b')
        black_num = 0
        for i in range(H):
            if bin_mask_h[i] == '0':
                continue
            for j in range(W):
                if bin_mask_w[j] == '0':
                    continue
                if c[i][j] == 1:
                    black_num += 1
        
        if black_num == K:
            result += 1

print(result)

Solution (Python):
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]
ans = 0

for x in range(2**h):
    for y in range(2**w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (x&(1<<i)) or (y&(1<<j)):
                    continue
                if c[i][j] == "
                    cnt += 1

        if cnt == k:
            ans += 1

print(ans)

Solution (Python):
import numpy as np
import itertools
H,W,K = map(int,input().split())
all_,choice = [],[]

lis = ['h'+str(h) for h in range(H)]
w_lis = ['w'+str(w) for w in range(W)]
lis.extend(w_lis)

for j in range(0,len(lis)+1):
  choice.extend(list(itertools.combinations(lis,j)))

for h in range(H):
  l = list(input().replace('
  all_.append(l)

all_ = np.array(all_,dtype=int)
ans = 0

for i in choice:
  A = all_.copy()
  for k in i:
    if k==None:
      pass
    elif k[0]=='h':
      A[int(k[1]),:]=0
    elif k[0]=='w':
      A[:,int(k[1])]=0
  
  if A.sum()==int(K):
    ans+=1
      
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
board = [input() for _ in range(h)]
cnt = 0
for redlines in range(2**h):
    redlines_bin = format(redlines, 'b').zfill(h)
    for redclms in range(2**w):
        redclms_bin = format(redclms, 'b').zfill(w)
        
        rem_black = 0
        for i in range(h):
            for j in range(w):
                if redlines_bin[i] == '0' and redclms_bin[j] == '0' and board[i][j] == '
                    rem_black += 1
        
        if rem_black == k:
            cnt += 1

print(cnt)