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):
H, W, K = map(int, input().split(' '))
ls, result = [], 0
for i in range(H):
    ls.append(input())

for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for s in range(H):
            if i >> s & 1:
                continue
            for t in range(W):
                if j >> t & 1:
                    continue
                if ls[s][t] == '
                    cnt += 1
        if cnt == K:
            result += 1
print(result)

Solution (Python):
H, W, K = map(int, input().split())
L = [list(input()) for _ in range(H)]
ans = 0

for h_p in range(2 ** H):
    for w_p in range(2 ** W):
        count = 0
        for h in range(H):
            for w in range(W):
                if (h_p >> h) & 1 == 0 and (w_p >> w) & 1 == 0:
                    if (L[h][w] == '
                        count += 1
        if count == K:
            ans += 1

print(ans)

Solution (Python):

import sys

def main():
    H,W,K = list(map(int, sys.stdin.readline().split()))
    C_list = [list( sys.stdin.readline().rstrip() ) for _ in range(H)]

    bit_H = 1 << H
    bit_W = 1 << W
    cnt_K = 0

    for b_H in range(bit_H):
        for b_W in range(bit_W):
            cnt_black = 0

            for row in range(H):
                for col in range(W):
                    if (C_list[row][col] == "
                        cnt_black += 1
            
            if cnt_black == K:
                cnt_K += 1
    
    print(cnt_K)


if __name__ == "__main__":
    main()

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

Solution (Python):
import numpy as np
h,w,k = map(int,input().split())
c = list(list(input()) for i in range(h))
c = np.array(c)
ans = 0
for i in range(2**h):
    for j in range(2**w):
        x = i
        y = j
        s = np.copy(c)
        n = 0
        while x > 0:
            if x % 2 == 1:
                for l in range(w):
                    s[n][l] = '0'
            x = x // 2
            n += 1
        m = 0
        while y > 0:
            if y % 2 == 1:
                for l in range(h):
                    s[l][m] = '0'
            y = y // 2
            m += 1
        p = np.count_nonzero(s == '
        if p == k:
            ans += 1
print(ans)

Solution (Python):
H,W,K=map(int,input().split())
C=[input() for _ in range(H)]
ans=0
for i in range(2**H):
  for j in range(2**W):
    c=0
    for ii in range(H):
      for jj in range(W):
        if 1&(i>>ii)&(j>>jj):
          if C[ii][jj]=='
            c+=1
    if c==K:
      ans+=1
print(ans)

Solution (Python):
H,W,K=map(int,input().split())
C=[input() for _ in range(H)]
ans=0
for i in range(2**H):
  for j in range(2**W):
    c=0
    for ii in range(H):
      for jj in range(W):
        if (i>>ii)&(j>>jj)&1:
          if C[ii][jj]=='
            c+=1
    if c==K:
      ans+=1
print(ans)

Solution (Python):
H,W,K=map(int,input().split())
C=[input() for _ in range(H)]
ans=0
for i in range(2**H):
  for j in range(2**W):
    c=0
    for ii in range(H):
      for jj in range(W):
        if i>>ii&1 and j>>jj&1:
          if C[ii][jj]=='
            c+=1
    if c==K:
      ans+=1
print(ans)

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

for bh in range(1 << h):
    for bw in range(1 << w):
        B = 0
        for H in range(h):
            for W in range(w):
                if ((bh >> H) & 1) == 0 and ((bw >> W) & 1) == 0 and m[H][W] == "
                    B += 1
        if B == k:
            ans += 1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
C = [[(c=="
cnt0 = sum(sum(c) for c in C)
ans = 0
for sy in range(1<<H):
    for sx in range(1<<W):
        D = [c.copy() for c in C]
        cnt = cnt0
        for y in range(H):
            for x in range(W):
                if sy>>y&1 | sx>>x&1:
                    cnt -= D[y][x]
                    D[y][x] = False
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):
H, W, K = map(int, input().split(' '))
ls,result = [], 0

for i in range(H):
    ls.append(input())

for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for s in range(H):
            if i >> s & 1:
                continue
            for t in range(W):
                if j >> t & 1:
                    continue
                if ls[s][t] == '
                    cnt += 1
        if cnt == K:
            result += 1
print(result)

Solution (Python):
import itertools



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

masu_list = []
for i in range(H):
    str = input()
    masu_list.append(list(str))
ans = 0

for H_bit in range(1 << H):
    for W_bit in range(1 << W):
        break_i = 0
        cnt = 0
        for i in range(H):
            if break_i == 1:
                break
            for j in range(W):
                if (H_bit >> i) & 1 and (W_bit >> j) & 1:
                    if masu_list[i][j] == "
                        cnt += 1
                        if cnt > K:
                            break_i = 1
                            break
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):
import itertools



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

masu_list = []
for i in range(H):
    str = input()
    masu_list.append(list(str))
ans = 0

for H_bit in range(1 << H):
    for W_bit in range(1 << W):
        break_i = 0
        cnt = 0
        for i in range(H):
            if break_i == 1:
                break
            for j in range(W):
                if (H_bit >> i) & 1 and (W_bit >> j) & 1:
                    if masu_list[i][j] == "
                        cnt += 1
                        if cnt > K:
                            break_i = 1
                            break
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):
from itertools import product, chain

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

sum_num = 0

for y in range(1<<H):
    for x in range(1<<W):
        s = [list(c) for c in C]
        for k in range(H):
            if (y>>k)%2:
                s[k] = ["X"]*W
        for k in range(W):
            if (x>>k)%2:
                for l in range(H):
                    s[l][k] = "X"
        black = sum(c=="
        if black == K:
            sum_num += 1

print(sum_num)

Solution (Python):
from copy import deepcopy

HEIGHT, WIDTH, K = map(int, input().split())
CELLS = [list(input()) for i in range(HEIGHT)]

ans = 0

for maskY in range(1<<HEIGHT):
  for maskX in range(1<<WIDTH):
    black=0
    for y in range(HEIGHT):
      for x in range(WIDTH):
        if (maskY >> y & 1) == 0 and (maskX >> x & 1) == 0 and CELLS[y][x] == '
          black+=1
    if K == black:
      ans+=1


print(ans)

Solution (Python):
h,w,k=map(int,input().split())
c=[0]*h
for i in range(h):
  c[i]=list(str(input()))
l=h+w
ans=0
M = 2
def dfs(A):
    global ans
    
    if len(A) == l:
        b=0
        for i in range(h):
          if A[i]==0:
            continue
          else:
            for j in range(w):
              if A[h:l][j]==1 and c[i][j]=='
                b+=1
        if b==k:
          ans+=1
        return
    for v in range(M):
        A.append(v)
        dfs(A)
        A.pop() 
dfs([])
print(ans)

Solution (Python):
h,w,k=map(int,input().split())
c=[0]*h
for i in range(h):
  c[i]=list(str(input()))
l=h+w
ans=0
M = 2
def dfs(A):
    global ans
    
    if len(A) == l:
        b=0
        for i in range(h):
          if A[i]==0:
            continue
          else:
            for j in range(w):
              if A[h:l][j]==1 and c[i][j]=='
                b+=1
        if b==k:
          ans+=1
        return
    for v in range(M):
        A.append(v)
        dfs(A)
        A.pop() 
dfs([])
print(ans)

Solution (Python):
from copy import deepcopy

HEIGHT, WIDTH, K = map(int, input().split())
CELLS = [list(input()) for i in range(HEIGHT)]

ans = 0

for maskY in range(1<<HEIGHT):
  for maskX in range(1<<WIDTH):
    black=0
    for y in range(HEIGHT):
      for x in range(WIDTH):
        if (maskY >> y & 1) == 0 and (maskX >> x & 1) == 0 and CELLS[y][x] == '
          black+=1
    if K == black:
      ans+=1


print(ans)

Solution (Python):
import copy

h,w,k=map(int,input().split())
a=[]
for _ in range(h):
  b=list(input())
  a.append(b)

ans=0
for i in range(2**h):
  for j in range(2**w):
    c=copy.deepcopy(a)
    for x in range(h):
      if ((i>>x)&1):
        for u in range(w):
          c[x][u]='R'
          
    for y in range(w):
      if ((j>>y)&1):
        for t in range(h):
          c[t][y]='R'
    ch=0
    for z in c:
      ch+=z.count('
    if ch==k:
      ans+=1
      
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    H, W, K = map(int, input().split())
    c = [input() for i in range(H)]

    ans = 0
    for maskR in range(2 ** H):
        for maskC in range(2 ** W):
            black = 0
            for i in range(H):
                for j in range(W):
                    if ((maskR >> i) & 1) and ((maskC >> j) & 1) and c[i][j] == '
                        black += 1
                    
            if black == K:
                ans += 1
            
    print(ans) 

main()

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    H, W, K = map(int, input().split())
    c = [input() for i in range(H)]

    ans = 0
    for maskR in range(2 ** H):
        for maskC in range(2 ** W):
            black = 0
            for i in range(H):
                for j in range(W):
                    if 2 ** i & maskR > 0 and 2 ** j & maskC > 0 and c[i][j] == '
                        black += 1
                    
            if black == K:
                ans += 1
            
    print(ans) 

main()

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

ans = 0

for row in range(1 << h): 
  for col in range(1 << w): 
    black = 0
    for i in range(h):
      for j in range(w):
        if (row >> i) & 1 == 0 and (col >> j) & 1 == 0 and c[i][j] =='
           black += 1
    if black == k:
      ans += 1

print(ans)

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

ans = 0

for row in range((1 << h) - 1): 
  for col in range((1 << w) - 1): 
    black = 0
    for i in range(h):
      for j in range(w):
        if (row >> i) & 1 == 0 and (col >> j) & 1 == 0 and c[i][j] =='
           black += 1
    if black == k:
      ans += 1

print(ans)

Solution (Python):


import numpy as np
H,W,K = map(int,input().split())
HW = np.repeat('', H*W).reshape(H,W) 
ans = 0
for _ in range(H):
    HW[_] = np.array(list(input()))

for _ in range(1<<(H+W)):
    
    choices = format(_, 'b').zfill(H+W)
    r = [i for i, v in enumerate(choices[:H]) if v == '1']
    c = [i for i, v in enumerate(choices[H:]) if v == '1']
    ans += [0, 1][np.sum(HW[r,:][:,c] == '

print(ans)

Solution (Python):
import itertools
import numpy as np

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

temp = []
for _ in range(H):
    C = list(input())
    A = [c.replace('.', '0') for c in C]
    A = [a.replace('
    A = list(map(lambda x: int(x), A))
    temp.append(A)

C = np.array(temp)

count = 0
l = [0, 1]
wide = itertools.product(l, repeat=W)
for w in wide:
    hight = itertools.product(l, repeat=H)
    for h in hight:
        copy_C = C.copy()
        for num, i in enumerate(w):
            if i == 1:
                copy_C[:, num-1] = 0
            for num2, j in enumerate(h):
                if j == 1:
                    copy_C[num2-1, :] = 0
        if copy_C.sum() == K:
            count += 1

print(count)

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

res = 0
from itertools import product
for v1 in product([0,1], repeat=h):
    for v2 in product([0,1], repeat=w):
        cnt = 0
        for i in range(h):
            if v1[i] == 0: continue
            for j in range(w):
                if v2[j] == 1 and c[i][j] == '
                    cnt += 1
        if cnt == k:
            res += 1
print(res)

Solution (Python):
import copy
h,w,k=map(int,input().split())
M=[list(input()) for _ in range(h)]
a=0
for i in range(2**w):
  for j in range(2**h):
    b=0
    for c in range(w):
      for r in range(h):
        if (i>>c)&1==0 and (j>>r)&1==0 and M[r][c]=='
          b+=1
    if b==k:
      a+=1
print(a)

Solution (Python):
from itertools import product
import copy
H,W,K = map(int,input().split())
C_ary = [[_ for _ in input()] for j in range(H)]
patrn_h = []
patrn_w = []
cntup = 0
for i in product([0,1], repeat = H):
    patrn_h.append(i)
for i in product([0,1], repeat = W):
    patrn_w.append(i)
for i in patrn_h:
    for j in patrn_w:
        cnt = 0
        test_ary = copy.deepcopy(C_ary)
        for h in range(H):
            for w in range(W):
                if i[h] == 0 or j[w] == 0:
                    test_ary[h][w] = "."
            cnt += test_ary[h].count("
        if cnt == K:
            cntup += 1
print(cntup)

Solution (Python):
from itertools import product
import copy
H,W,K = map(int,input().split())
C_ary = [[_ for _ in input()] for j in range(H)]
patrn_h = []
patrn_w = []
cntup = 0
for i in product([0,1], repeat = H):
    patrn_h.append(i)
for i in product([0,1], repeat = W):
    patrn_w.append(i)
for i in patrn_h:
    for j in patrn_w:
        fnl_cnt = 0
        test_ary = copy.deepcopy(C_ary)
        for h in range(H):
            cnt = 0
            for w in range(W):
                if i[h] == 0 or j[w] == 0:
                    test_ary[h][w] = "."
            cnt = test_ary[h].count("
            fnl_cnt += cnt
        if fnl_cnt == K:
            cntup += 1
print(cntup)

Solution (Python):
from itertools import product


def abc173c_h_and_v():
    h, w, k = map(int, input().split())
    c = [input() for _ in range(h)]
    cnt = 0
    for hp in product(range(2), repeat=h):
        for wp in product(range(2), repeat=w):
            a = [c[i][j] for j in range(w) if wp[j] == 1 for i in range(h) if hp[i] == 1]
            if k == a.count('
                cnt += 1
    print(cnt)

abc173c_h_and_v()

Solution (Python):
h, w, k = map(int, input().split())
fi = []
for _ in range(h):
  s = input()
  fi.append(s)
a = 1 << h
b = 1 << w
ans = 0
for i in range(a * b):
  lh = [0 for _ in range(h)]
  lw = [0 for _ in range(w)]
  for j in range(h):
    if i & (1 << j):
      lh[j] += 1
  for j in range(w):
    if i & (1 << (j + h)):
      lw[j] += 1
  cnt = 0
  for j in range(h):
    for l in range(w):
      if lh[j] == 1:
        continue
      if lw[l] == 1:
        continue
      if fi[j][l] == '
        cnt += 1
  if cnt == k:
    ans += 1
print(ans)

Solution (Python):
H,W,K = map(int, input().split())
C = []
for i in range(H):
    C.append(list(input()))
ans = 0

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

print(ans)

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

blacks = [[None] * W for _ in range(H)]
black_sums = [[0] * W for _ in range(H)]
black_col_sums = [[0] * W for _ in range(H)]

for i in range(H):
    for j, item in enumerate(input()):
        if item == "
            blacks[i][j] = 1
        else:
            blacks[i][j] = 0


ok_count = 0
for i in range(1<<H):
    for j in range(1<<W):
        

        black_count = 0
        for m in range(H):
            for n in range(W):
                if (1 & i >> m and 1 & j >> n) == False:
                    continue
                black_count += blacks[m][n]
        if black_count == K:
            ok_count += 1

print(ok_count)

Solution (Python):
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    h, w, k = nm()
    g = [ns() for _ in range(h)]
    ans = 0
    for bih in range(1 << h):
        for biw in range(1 << w):
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if bih & (1 << i) and biw & (1 << j) and g[i][j] == '
                        cnt += 1
            if cnt == k:
                ans += 1
    print(ans)
    return

solve()

Solution (Python):
import numpy as np
from copy import deepcopy
from heapq import heappop, heappush
from bisect import bisect_left, bisect
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations

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

for h in range(H):
    s = list(input())
    for w in range(W):
        if s[w] == ".":
            c[w, h] = 0
        else:
            c[w, h] = 1

n = 0

for wt in product([1, 0], repeat=W):
    for ht in product([1, 0], repeat=H):
        d = deepcopy(c)
        for i in range(W):
            if wt[i] == 1:
                d[i, :] = 0
        for i in range(H):
            if ht[i] == 1:
                d[:, i] = 0
        if np.count_nonzero(d) == K:
            n += 1
print(n)
exit()

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

h, w, k = map(int, input().split())
arr = np.empty((0, w), int)
for _ in range(h):
    s = list(input().replace(".", "0").replace("
    arr = np.append(arr, np.array([list(map(int, s))]), axis=0)
cnt = 0
for i in product((0, 1), repeat=h):
    tmp = (arr.T * i).T
    cnt += sum(sum(sum(tmp * j)) == k for j in product((0, 1), repeat=w))
print(cnt)

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

ans = 0
for hselection in range(1 << H):
    for wselection in range(1 << W):
        count = 0
        for h in range(H):
            for w in range(W):
                if hselection & (1 << h) or wselection & (1 << w):
                    continue
                if C[h][w] == "
                    count += 1
        if count == K:
            ans += 1
print(ans)

Solution (Python):
import copy

h, w, k = map(int, input().split())
clist0 = []
result = 0
for i0 in range(h):
    c = list(input())
    clist0.append(c)
for i in range(2**h):
    for j in range(2**w):
        clist = copy.deepcopy(clist0)
        for hi in range(h):
            
            if((i & 2**hi) == 2**hi):
                
                for j2 in range(w):
                    clist[hi][j2] = "1"
        for wi in range(w):
            if((j & 2**wi) == 2**wi):
                for i2 in range(h):
                    clist[i2][wi] = "1"
        temp = 0
        
        for ci in clist:
            temp += ci.count("
        if(temp == k):
            result +=1
print(result)

Solution (Python):
H, W, K = list(map(int, input().split()))
c = []
for _ in range(H):
    c.append( input() )
count = 0
for h_pattern in range( 2**H ):
    for w_pattern in range( 2**W ):
        black_count = 0
        for h in range(H):
            for w in range(W):
                if (h_pattern>>h)&1 and (w_pattern>>w)&1 and c[h][w]=='
                    black_count+=1
        if black_count==K:
            count += 1
print(count)

Solution (Python):
from sys import stdin,stdout
def fn(mask_r,mask_c):
    cells=0
    for cur_r in range(r):
        for cur_c in range(c):
            if mask_c &(1<<cur_c)==0 or mask_r&(1<<cur_r)==0:continue
            if a[cur_r][cur_c]=='
    return cells==k
for _ in range(1):
    
    ans=0
    r,c,k= map(int,stdin.readline().split())
    a=[input() for _ in range(r)]
    for mask_r in range(1<<r):
        for mask_c in range(1<<c):
            
            if fn(mask_r,mask_c):ans+=1
    print(ans)

Solution (Python):
from itertools import combinations
n,m,k = map(int,input().split())
mat = []
for _ in range(n):
    mat.append(list(input()))

def black(row,col):
    new = [mat[i] for i in range(n) if i not in row]
    if not new:return 0
    new = list(zip(*new))
    new = [new[i] for i in range(m) if i not in col]
    if not new:return 0
    return sum([i.count("
ans = 0
rows = []
cols = []
for i in range(0,n+1):
    rows += list(combinations([i for i in range(n)],i))
for i in range(0,m+1):
    cols += list(combinations([i for i in range(m)],i))

for row in rows:
    for col in cols:
        if black(set(row),set(col))==k:
            
            ans+=1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
a = [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 a[k][l] == '
                    black += 1
        if black == K:
            ans += 1
print(ans)

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

h, w, k = map(int, input().split())
l = []
for _ in range(h):
    s = input().replace(".", "0")
    s = map(int, list(s.replace("
    l.append(np.array(list(s)))
arr = np.array(l)
cnt = 0
for i in product((0, 1), repeat=h):
    tmp = (arr.T * i).T
    for j in product((0, 1), repeat=w):
        if sum(sum(tmp * j)) == k:
            cnt += 1
print(cnt)

Solution (Python):
import numpy as np
import sys
import distutils.util

h, w, k = (int(x) for x in input().split())
count = 0
map = ''
for i in range(h):
    map += sys.stdin.readline().replace('\n','')
map2 = [True]*len(map)
for i in range(len(map)):
    if map[i]=='.': map2[i]=False
map2 = np.array(map2, dtype=bool).reshape((h, w))

for i in range(2**h):
    tmp = bin(i)[2:]
    tmp = '0'*(h-len(tmp)) + tmp
    a = list((bool(distutils.util.strtobool(tmp[i]))
              for i in range(len(tmp))))
    tmp = np.array(a*w).reshape(w, h).transpose()
    for j in range(2**w):
        tmp2 = bin(j)[2:]
        tmp2 = '0'*(w-len(tmp2)) + tmp2
        b = list((bool(distutils.util.strtobool(tmp2[i]))
                  for i in range(len(tmp2))))
        tmp2 = np.array(b*h).reshape(h, w)
        if sum(sum(list(tmp & tmp2 & map2)))==k: count+=1

print (count)

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

count = 0
for binh in range(2**h):
    for binw in range(2**w):
        redh, redw = bin(binh)[2:].zfill(h), bin(binw)[2:].zfill(w)  
        squares = [list(row) for row in c]
        for i, rh in enumerate(redh):
            for wh in range(w):
                if rh == '1':
                    squares[i][wh] = '*'
        for j, rw in enumerate(redw):
            for hw in range(h):
                if rw == '1':
                    squares[hw][j] = '*'
        count += sum(row.count('

print(count)

Solution (Python):
import itertools
import numpy as np

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

count = 0
for ph in itertools.product([0, 1], repeat=h):
    for pw in itertools.product([0, 1], repeat=w):
        squares = np.array([[1 if cell == '
        squares[np.array(ph) == 1, :] *= 0
        squares[:, np.array(pw) == 1] *= 0
        count += np.count_nonzero(squares == 1) == k

print(count)

Solution (Python):
import itertools
import numpy as np

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

count = 0
for ph in itertools.product([0, 1], repeat=h):
    for pw in itertools.product([0, 1], repeat=w):
        squares = np.array([[1 if cell == '
        squares[np.array(ph) == True, :] *= 0
        squares[:, np.array(pw) == True] *= 0
        if np.count_nonzero(squares == 1) == k:
            count += 1

print(count)

Solution (Python):

H, W, K = [int(n) for n in input().split(" ")]
M = []
for _ in range(H):
    a = [n for n in input()]
    assert(len(a) == W)
    M.append(a)

import copy
import itertools
"""
M = [[".", ".", "
     ["
]
W = len(M[0])
H = len(M)
K = 2
"""


def makeCombination(candidate, n, lessFlag):
    if len(candidate) <= 0:
        return [[]]
    _candidate = [n for n in candidate]
    _candidate = sorted(_candidate)
    result = []
    if lessFlag is False:
        tmp = list(set(list(itertools.combinations(_candidate, n))))
        for t in tmp:
            result.append(list(t))
    else:
        for i in range(n):
            result += makeCombination(candidate, i + 1, False)
        result += [[]]
    return result


def check(m, h, w):
    MM = copy.deepcopy(m)
    for a in h:
        for i in range(W):
            MM[a][i] = "R"
    for a in w:
        for i in range(H):
            MM[i][a] = "R"

    count = 0
    for i in range(len(MM)):
        for j in range(len(MM[i])):
            if MM[i][j] == "
                count += 1
    return count


HHH = makeCombination([n for n in range(H)], H, True)
WWW = makeCombination([n for n in range(W)], W, True)

OK = 0

for i in range(len(HHH)):
    for j in range(len(WWW)):
        if check(M, HHH[i], WWW[j]) == K:
            OK += 1
print(OK)

Solution (Python):
row, col, num = map(int, input().split())

tmp_l = []
board = []
for i in range(row):
  str = input()
  for j in range(col):
    if str[j] == '.':
      tmp_l.append(0)
    if str[j] == '
      tmp_l.append(1)
  board.append(tmp_l)
  tmp_l = []

onoff = []
bi = [32, 16, 8, 4, 2, 1]
for i in range(64):
  tmp = i
  for j in bi:
    tmp_l.insert(0, int(tmp / j))
    tmp %= j
  onoff.append(tmp_l)
  tmp_l = []

count = 0
ans = 0
for i in range(2**row):
  for j in range(2**col):
    for k in range(row):
      if onoff[i][k] == 1:
        for l in range(col):
          if onoff[j][l] == 1:
            if board[k][l] == 1:
              count += 1
    if count == num:
      ans += 1
    count = 0

print(ans)

Solution (Python):
H,W,K=map(int,input().split())
l=[]
for i in range(H):
    S=input()
    l.append(S)
l_2d="".join(l)
x=l_2d.count("
for i in range(W):
    S=""
    for j in range(H):
        S+=l[j][i]
    l.append(S)
ans=0
for i in range(2**(H+W)):
    bag=[]
    h=[]
    w=[]
    for j in range(H+W):
        if ((i>>j)&1):
            bag.append(l[j])
            if j<H:
                h.append(j)
            else:
                w.append(j-H)
    bag_2d="".join(bag)
    y=bag_2d.count("
    for k in h:
        for m in w:
            if l[k][m]=="
                y-=1
    if x-y==K:
        ans+=1
print(ans)

Solution (Python):
from itertools import groupby, accumulate, product, permutations, combinations
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
ans = 0
for p in product([0,1],repeat=H+W):
  cnt = 0
  for i in range(H):
    for j in range(W):
      if S[i][j]=='
        cnt += 1
  if cnt == K:
    ans += 1
print(ans)

Solution (Python):
H, W, K = map(int, input().split(' '))
ls, rst = [], 0
for i in range(H):
    ls.append(input())

for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for s in range(H):
            if i >> s & 1:
                continue
            for t in range(W):
                if j >> t & 1:
                    continue
                if ls[s][t] == '
                    cnt += 1
        if cnt == K:
            rst += 1
print(rst)

Solution (Python):
H, W, K = map(int, input().split())
a = [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 a[k][l] == '
                    black += 1
        if black == K:
            ans += 1
print(ans)

Solution (Python):
h,w,K = map(int,input().split())
a = [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 a[k][l]=='
                    black += 1
                    
        if black == K:
            ans += 1
print(ans)

Solution (Python):
H,W,K = map(int,input().split())
c = []
row = [0]*H
col = [0]*W
total = 0

for i in range(H):
    c.append(list(input()))
    for j in range(W):
        if c[i][j] == '
            row[i] += 1
            col[j] += 1
            total += 1


ans = 0
for i in range(2**(H+W)):
    x = [0]*(H+W)
    ii = i
    for j in range(H+W):
        x[j] = ii % 2
        ii//=2
    
    D = 0
    for j in range(H):
        D += row[j]*x[j]
    for j in range(H,H+W):
        D += col[j-H]*x[j]

    for j in range(H):
        for k in range(W):
            if c[j][k] == '
                D -= x[j]*x[H+k]
    
    if total -D == K:
        ans += 1
    

print(ans)