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):
def C():
    H, W, K = map(int, input().split())
    C = []
    for _ in range(H):
        C.append(input())
    count = 0
    for mask_i in range(2**H-1):
        for mask_j in range(2**W-1):
            black = 0
            for i in range(H):
                for j in range(W):
                    if mask_i >> i & 1 == 0 and mask_j >> j & 1 == 0 and C[i][j] == '
                        black += 1
            if black == K:
                count += 1
    print(count)

C()

Solution (Python):
from itertools import *

h, w, k = map(int, input().split())
c = []
ans = 0

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

count = 0

for i in range(h+1):
    conbI = list(combinations(list(range(h)), i))

    for j in range(w+1):
        conbJ = list(combinations(list(range(w)), j))

        for tupleI in conbI:
            for tupleJ in conbJ:
                temp = 0
                for x in range(h):
                    for y in range(w):
                        if x in tupleI or y in tupleJ:
                            continue
                        else:
                            if c[x][y] == '
                                temp += 1

                if temp == k:
                    ans += 1


print(ans)

Solution (Python):
import copy
(H,W,K) = map(int,input().split())
l = [[0 for i in range(W)] for j in range(H)]
ans = 0
for i in range(H):
    a = input()
    for j in range(W):
        l[i][j]=a[j]

t = [0 for i in range(W)]
y = [0 for i in range(H)]

for i in range(H):
    for j in range(W):
        if l[i][j]=='
            t[j]+=1
            y[i]+=1

sum = 0

for i in range(H):
    sum += y[i]

for i in range(1<<H):
    for j in range(1<<W):
        S = sum
        Y = copy.deepcopy(y)
        T = copy.deepcopy(t)
        for k in range(H):
            if i>>k&1:
                S-=Y[k]
                for q in range(W):
                    if l[k][q]=='
                        T[q]-=1
        for p in range(W):
            if j>>p&1:
                S-=T[p]
        if S == K:
            ans += 1
            
            
        



print(ans)

Solution (Python):
from itertools import product

h, w, k = map(int, input().split())
c = [input() for _ in range(h)]
ans = 0
for bh in product([0, 1], repeat=h):
    for bw in product([0, 1], repeat=w):
        cnt = 0
        for i, j in enumerate(bh):
            for x, y in enumerate(bw):
                if j == 1 and y == 1 and c[i][x] == "
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
import sys
import numpy as np
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
H, W, K = map(int, readline().split())
C = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W]
 
C = 1 * (C == b'
 
def f(C, x, y):
    rows = [i for i in range(H) if x & (1<<i)]
    cols = [i for i in range(W) if y & (1<<i)]
    D = C[rows][:,cols]
    return D.sum() == K
 
ans = 0
for x in range(1 << H):
    for y in range(1 << W):
        ans += f(C, x, y)
print(ans)

Solution (Python):
h,*c=open(0)
h,w,k=map(int,h.split())
print(sum(k==sum(y>>w+z//w&y>>z%w&ord(c[z//w][z%w])&1for z in range(h*w))for y in range(1<<h+w)))

Solution (Python):
h,*c=open(0)
h,w,k=map(int,h.split())
print(sum(k==sum(y>>w+z//w&y>>z%w&ord(c[z//w][z%w])&1for z in range(h*w))for y in range(1<<h+w)))

Solution (Python):
def b_in_row(row):
  return sum([1 if c == '

def in_flag(value, flag):
  return bool((1 << value) & flag)

def count_removes(h, w, row_flag, col_flag):
  tbr = 0
  for row in range(h):
    if in_flag(row, row_flag):
      tbr += b_in_row(m[row])
    else:
      for col in range(w):
        if in_flag(col, col_flag):
          if m[row][col] == '
            tbr += 1
  return tbr

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

m = []
for _ in range(h):
  m.append(input())

black = sum([b_in_row(row) for row in m])

remove = black - k

ans = 0
for row_flag in range(1 << h):
  for col_flag in range(1 << w):
    tbr = count_removes(h, w, row_flag, col_flag)
    
    if tbr == remove:
      ans += 1

print(ans)

Solution (Python):
h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
import itertools
ans = 0
for hbit, wbit in itertools.product(range(1<<h), range(1<<w)):
    c = 0
    for i, j in itertools.product(range(h), range(w)):
        if hbit>>i & 1 and wbit>>j & 1 and C[i][j] == '
    if c == k: ans += 1
print(ans)

Solution (Python):
import itertools
h,w,k = map(int,input().split())
grid = []
black = 0
cnt = 0
for _ in range(h):
    s = input()
    grid.append(s)


row = list(itertools.product([0,1],repeat=h))
column = list(itertools.product([0,1],repeat=w))
result = 0
for i in row:
    for j in column:
        cnt = 0
        for m in range(len(i)):
            for n in range(len(j)):
                if i[m]==0 and j[n] == 0 and grid[m][n] == '
                    cnt += 1

        if cnt == k:
            
            result += 1

print(result)

Solution (Python):
h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
ans = 0
for hbit in range(1<<h): 
    for wbit in range(1<<w): 
        c = 0
        for i in range(h):
            for j in range(w):
                if hbit>>i & 1 and wbit>>j & 1 and C[i][j] == '
        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 bi in range(1<<h):
    for bj in range(1<<w):
        tmp = sum(c[i][j]=='
        if tmp==k:
            ans += 1
print(ans)

Solution (Python):
import itertools

h, w, k = map(int, input().split())
s = [0] * h
countH = [0] * h
countW = [0] * w
ans = []
ans_sub = [[0 for j in range(2)] for i in range(h * w)]
num = 0
ans_count = 0

for i in range(h):
    s[i] = list(input())
    for j in range(w):
        if s[i][j] == '
            ans_sub[num][0] = i
            ans_sub[num][1] = j + h
            ans.append(ans_sub[num])
            num += 1

lis = list(range(h + w))


for n in range(h + w):
    for pair in itertools.combinations(lis, n + 1):
        count = 0
        for i in range(len(ans)):  
            if (ans[i][0] not in pair) and (ans[i][1] not in pair):
                count += 1  
            
        if count == k:
            
            ans_count += 1
            
if k == len(ans):
    ans_count += 1

print(ans_count)

Solution (Python):
h, w, k = map(int, input().split())
ans = 0
c = [input() for i in range(h)]
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 c[l][m] == '
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):


H, W, K = map(int, input().split())
c = [input() for _ in range(H)]
result = 0
"""
bit全探索
1<<HOGE=2^HOGE
根元事象が2のコインのようなものが得意
"""


for rows in range(1 << H):
    for cols in range(1 << W):
        black = 0
        
        
        
        for i in range(H):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(W):
                if (cols >> j) % 2 == 1:
                    continue
                if c[i][j] == "
                    black += 1
        if black == K: 
            result += 1

print(result)

Solution (Python):
import numpy as np

H,W,K=map(int,input().split())
E=[]
for e in range(H):
    _=input()
    temp=_.replace('
    
    E.append(list(map(int,temp)))

Arr=np.array(E)

FA=0

for h in range (2**H):
    
    select_H=[]
    for i in range (H):
        if (h>>i) & 1==1:
            select_H.append(1)
        else:
            select_H.append(0)
    sHarr=np.array(select_H)
    delSHarr=np.where(sHarr==1)
    
    
    _ans=np.delete(Arr,delSHarr,axis=0)
    
    

    for w in range (2**W):
        
        select_W=[]
        for j in range (W):
            if (w>>j) &1 ==1:
                select_W.append(1)
            else:
                select_W.append(0)
        sWarr=np.array(select_W)
        delsWarr=np.where(sWarr==1)
        ans=np.delete(_ans,delsWarr,axis=1)
        
        

        if np.sum(ans)==K:
            FA+=1

print(FA)

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

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

ans = 0
for ii in range(2**H):
    for jj in range(2**W):
        tmp = 0
        for i in range(H):
            for j in range(W):
                
                if (ii>>i)&1 or (jj>>j)&1:
                    continue
                if C[i][j] =="
                    tmp += 1
        if tmp == K:
            ans += 1
print(ans)

Solution (Python):


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

c = [input() for _ in range(h)]
ret = 0
for i_s in range(2 ** h):
    for j_s in range(2 ** w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (i_s >> i)&1 == 1:
                    continue
                if (j_s >> j)&1 == 1:
                    continue
                if c[i][j] == "
                    black += 1
        
        if black == k:
            ret += 1

print(ret)

Solution (Python):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H,W,K = map(int,readline().split())
grid = [list(readline().decode().rstrip()) for _ in range(H)]
black_cnt = 0
for i in range(H):
  for j in range(W):
    if grid[i][j] == '
      black_cnt += 1
erase_cnt = black_cnt - K
ans = 0
for bit_H in range(1 << H):
    for bit_W in range(1 << W):
        cnt = 0 
        for i in range(H):
            for j in range(W):
                if (((bit_H >> i) & 1) or ((bit_W >> j) & 1)) and grid[i][j] == '
                    cnt += 1              
        if erase_cnt == cnt:
            ans += 1
print(ans)

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

A = 0
for ibit in range(2 ** H):
    for jbit in range(2 ** W):
        B = 0
        for i in range(H):
            for j in range(W):
                if (ibit & (1 << i)) or (jbit & (1 << j)):
                    continue
                if c[i][j] == '
                    B += 1
        if B == K:
            A += 1
print(A)

Solution (Python):
import itertools
H, W, K = map(int, input().split())
ans = 0
pattern = []

for i in range(H):
  pattern.append(list(input()))

for i in itertools.product([0,1], repeat=H):
  for j in itertools.product([0,1], repeat=W):
    numsharp = 0
    for h in range(H):
      for w in range(W):
        if i[h] == 0 and j[w] == 0:
          if pattern[h][w] == '
            numsharp += 1
    if numsharp == K:
      ans += 1

print(ans)

Solution (Python):
h,*c=open(0)
h,w,k=map(int,h.split())
print(sum(k==sum(y>>w+z//w&y>>z%w&1and'.'>c[z//w][z%w]for z in range(h*w))for y in range(1<<h+w)))

Solution (Python):
import copy
def board_check(tmp_board):
    count=0
    for i in range(H):
        for j in range(W):
            if tmp_board[i][j]=='
                count+=1
    if count == K:
        return 1
    else:
        return 0
if __name__ == "__main__":
    H,W,K = map(int,input().split())
    board = [list(input()) for _ in range(H)]
    n_H=2**H
    n_W = 2**W
    cnt = 0
    for i in range(n_H):
        l_h=[]
        for ih in range(H):
            if i>>ih & 1:
                l_h.append(ih)
        for j in range(n_W):
            tmp_board=copy.deepcopy(board)
            
            l_w =[]
            for jw in range(W):
                if j >> jw & 1:
                    l_w.append(jw)
            
            
            
            
            if l_h :
                for x in l_h:
                    for j in range(W):
                        tmp_board[x][j] = 'x'
                
            if l_w:
                for x in l_w:
                    for j in range(H):
                        tmp_board[j][x] = 'x'
            if board_check(tmp_board)==1:
                
                
                cnt+=board_check(tmp_board)
    print(cnt)

Solution (Python):
import itertools

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

for i in range(H):
  c = list(input())
  C.append(c)
  
ans = 0

for h in itertools.product([0, 1], repeat = H):
  for w in itertools.product([0, 1], repeat = W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if h[i] == 0 and w[j] == 0 and C[i][j] == "
          cnt += 1
    if cnt == K:
      ans += 1

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

H, W, K = inm()
grid = [ins() for _ in range(H)]


def solve():
    ans = 0
    for i in range(1 << H):
        for j in range(1 << W):
            cnt = 0
            for r in range(H):
                if i & (1 << r):
                    continue
                for c in range(W):
                    if j & (1 << c):
                        continue
                    if grid[r][c] == "
                        cnt += 1
            if cnt == K:
                ans += 1

    return ans


print(solve())

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

mat = []
for i in range(H):
	mat.append(str(input()))

num = 0
for i in range(H):
	for j in range(W):
		if mat[i][j] == '
			num += 1

ans = 0
for i in range(1<<H):
	for j in range(1<<W):
		cnt = 0
		for ii in range(H):
			for jj in range(W):
				if (i>>ii) & 1 == 1 and (j>>jj) & 1 == 1 and mat[ii][jj] == '
					cnt += 1
		if cnt == K:
			ans += 1

print(ans)

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

ans = 0
for row in range(1 << H):
  for col in range(1 << W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if (row & (1 << i)) or (col & (1 << j)):
          continue
        if C[i][j] == '
          
          cnt += 1
    
    if cnt == K:
      ans += 1

print(ans)

Solution (Python):
import sys

def resolve():
    c = sys.stdin.readlines()
    c = list(map(lambda x: x.strip(), c))
    H, W, K = tuple(map(int, c[0].split(' ')))
    del c[0]
    ans = 0
    for hh in range(1<<H):
        for ww in range(1<<W):
            cnt = 0
            for h in range(H):
                for w in range(W):
                    if hh >> h & 1:
                        continue
                    if ww >> w & 1:
                        continue
                    if c[h][w] == '
                        cnt += 1

            if cnt == K:
                ans += 1

    print(ans)

resolve()

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

for maskR in range(1 << h):
    for maskC in range(1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if maskR >> i & 1 == 0 and maskC >> 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 = [list(input()) for i in range(h)]
 
h1 = [list(f"{i:0{h}b}") for i in range(2**h)]
w1 = [list(f"{i:0{w}b}") for i in range(2**w)]
 
cnt = 0
for hh in h1:
    for ww in w1:
        black = 0
        x = [i for i in range(h) if hh[i]=='1']
        y = [i for i in range(w) if ww[i]=='1']
        for i in x:
            for j in y:
                if c[i][j] == '
                    black += 1
        if black == k:
            cnt += 1
            
 
print(cnt)

Solution (Python):
from itertools import product

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

ans = 0
for row in product([0, 1], repeat=H):
    for col in product([0, 1], repeat=W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if row[i] and col[j] and grid[i][j] == '
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Solution (Python):
from itertools import product

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

ans = 0
for row in product([0, 1], repeat=H):
    for col in product([0, 1], repeat=W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if row[i] == 0 and col[j] == 0 and grid[i][j] == '
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Solution (Python):

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

ans = 0











for i_bits in range(1 << H):
  
  
  for j_bits in range(1 << W):
    
    
    cnt = 0 
    for i in range(H):
      for j in range(W):
        
        
        
        
        
        
        
        
        
        
        
        
        
        if (i_bits & (1 << i)) == 0 and (j_bits & (1 << j)) == 0:
          
          
          if C[i][j] == "
            cnt += 1
            
    if cnt == K:
      ans += 1
      
print(ans)

Solution (Python):



def main():
    H, W, K = map(int, input().split())
    C = [int(input().replace(".", "0").replace("
    res = 0
    for bit in range(1 << (H + W)):
        cnt_black = sum(
            (C[i] >> j) & 1 and not (bit >> i) & 1 and not (bit >> (j + H)) & 1
            for i in range(H)
            for j in range(W)
        )
        if cnt_black == K:
            res += 1
    print(res)


if __name__ == "__main__":
    main()

Solution (Python):
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

h,w,k = (int(x) for x in input().split())
row_cnt = []
col_cnt = []
lst = []
total = 0
for i in xrange(h):
    lst.append([1 if c=='
    row_cnt.append(sum(lst[-1]))
    total += row_cnt[-1]
for j in xrange(w):
    col_cnt.append(sum((lst[i][j] for i in xrange(h))))

ans = 0
for i in xrange(2**h):
    bini = bin(i)[2:]
    bini = ((h-len(bini))*'0')+bini
    curk = total
    for ii,c in enumerate(bini):
        if c == '1':
            curk -= row_cnt[ii]
    
    for j in xrange(2**w):
        binj = bin(j)[2:]
        binj = ((w-len(binj))*'0')+binj
        cur = curk
        for ii,c in enumerate(binj):
            if c == '1':
                bonus = 0
                for jj,cc in enumerate(bini):
                    if cc == '1' and lst[jj][ii] == 1:
                        bonus += 1
                cur -= col_cnt[ii] - bonus
        if cur == k:
            ans += 1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
c = [list(input()) for _ 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
print(ans)

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

for i in range(1<<H):
  for j in range(1<<W):
    count = 0
    for row in range(H):
      for col in range(W):
        if (i>>row)&1 == 1 and (j>>col)&1 == 1 and grid[row][col] == '
          count += 1
    if count == K: ans += 1
print(ans)

Solution (Python):
def li():
    return [int(x) for x in input().split()]

H, W, K = li()
c = [list(input()) for x in range(H)]

ans = 0
for maskRow in range(2**H):
    for maskCol in range(2**W):
        black = 0
        for i in range(H):
            for j in range(W):
                
                
                
                
                
                if not maskRow & (1 << i) and not maskCol & (1 << j) and c[i][j] == "
                    black += 1
        if black == K:
            ans += 1

print(ans)

Solution (Python):

def main():
    H, W, K = map(int, input().split())
    C = [input().rstrip() for _ in range(H)]
    res = 0
    for bit in range(1 << (H + W)):
        cnt_black = sum(
            C[i][j] == "
            for i in range(H)
            for j in range(W)
        )
        if cnt_black == K:
            res += 1
    print(res)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    H, W, K, *C = open(0).read().split()
    H, W, K, C = int(H), int(W), int(K), "".join(C)
    res = 0
    for bit in range(1 << (H + W)):
        cnt_black = sum(
            C[i * W + j] == "
            for i in range(H)
            for j in range(W)
        )
        if cnt_black == K:
            res += 1
    print(res)


if __name__ == "__main__":
    main()

Solution (Python):

import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    H, W, K = map(int, readline().split())
    C = [line.decode() for line in readlines()]
    res = 0
    for bit in range(1 << (H + W)):
        cnt_black = sum(
            C[i][j] == "
            for i in range(H)
            for j in range(W)
        )
        if cnt_black == K:
            res += 1
    print(res)


if __name__ == "__main__":
    main()

Solution (Python):

import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    H, W, K = map(int, readline().split())
    C = [line.decode() for line in readlines()]
    res = 0
    for bit in range(1 << (H + W)):
        cnt_black = sum(
            not (bit >> i) & 1 and not (bit >> (j + H)) & 1 and C[i][j] == "
            for i in range(H)
            for j in range(W)
        )
        if cnt_black == K:
            res += 1
    print(res)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    H, W, K = map(int, input().split())
    c = [list(input()) for _ in range(H)]
    res = 0
    for i in range(1 << H):
        for j in range(1 << W):
            cnt = 0
            for a in range(H):
                for b in range(W):
                    if not (i >> a & 1 or j >> b & 1) and c[a][b] == '
                        cnt += 1
            if cnt == K:
                res += 1
    print(res)

main()

Solution (Python):

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    H, W, K = map(int, readline().split())
    C = [line.decode() for line in read().split()]
    res = 0
    for bit_row in range(1 << H):
        for bit_col in range(1 << W):
            cnt_black = 0
            for i in range(H):
                for j in range(W):
                    if (
                        not ((bit_row >> i) & 1)
                        and not ((bit_col >> j) & 1)
                        and C[i][j] == "
                    ):
                        cnt_black += 1
            if cnt_black == K:
                res += 1
    print(res)


if __name__ == "__main__":
    main()

Solution (Python):
import sys 
import numpy as np

readline = sys.stdin.buffer.readline

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

C_ij = []
for h in range(H):
    C_ij.append(input()) 

ans = 0

for h_bit in range(2**H):
    for w_bit in range(2**W):
        black = 0
        for h in range(H):
            for w in range(W):
                if not((h_bit >> h) & 1) and not((w_bit >> w) & 1) and \
                C_ij[h][w] == '
                    black += 1
        if black == K:
            ans += 1


print(ans)

Solution (Python):
import copy

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

def tenchi(matrix, H, W):
	tmatrix = []
	for i in range(W):
		tmatrix_row = []
		for vector in matrix:
			tmatrix_row.append(vector[i])
		tmatrix.append(tmatrix_row)    
	return(tmatrix)
for i in range(2**(H+W)):
	tmp = i
	tmpc = copy.deepcopy(c)
	for j in range(H):
		if tmp % 2 == 1:
			tmpc[j] = ["."]*W
		tmp //= 2
	tmpc = tenchi(tmpc, H, W)
	for j in range(W):
		if tmp % 2 == 1:
			tmpc[j] = ['.']*H
		tmp //= 2
	
	count = 0
	for j in range(W):
		for k in range(H):
			if tmpc[j][k]=='
				count += 1
	if count == K:
		ans += 1

print(ans)

Solution (Python):
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
res = 0
for i in range(1 << h):
    for j in range(1 << w):
        cnt = 0
        for a in range(h):
            for b in range(w):
                if not (i >> a & 1 or j >> b & 1) and c[a][b] == '
                    cnt += 1
        if cnt == k:
            res += 1
print(res)

Solution (Python):
import copy
H,W,K = map(int,input().split())
ls3 = []
for i in range(H):
    ls1 = input()
    ls2 = [0 if j == '.' else 1 for j in ls1]
    ls3.append(ls2)

ii = 0
for i in range(2**H):
    for j in range(2**W):
        ls4 = copy.deepcopy(ls3)
        for k in range(H):
            for l in range(W):
                if (i>>k & 1):
                    ls4[k][l] = 0
                if (j>>l & 1):
                    ls4[k][l] = 0
        cou = 0
        for ls in ls4:
            cou += ls.count(1)
        if cou == K:
            ii+=1       

print(ii)

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


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

print(ans)

Solution (Python):
















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

grid = []

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

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)

Solution (Python):
import copy
import itertools
h,w,k = map(int,input().split())
c = [[0]*w]*h
for i in range(h):
	c[i] = input()
	c[i] = list(c[i])

counter = 0	
ans = 0
b = 0
for (i,j) in itertools.product(range(h), range(w)):
	if c[i][j] == '
		b += 1

for hl in range(h+1):
	for wl in range(w+1):
		for	hi in itertools.combinations(range(h),hl):
			for wj in itertools.combinations(range(w),wl):
				C = copy.deepcopy(c)
				for i in hi:
					for j in range(w):
						if C[i][j] == '
							counter += 1
							C[i][j] = '.'
				for j in wj:
					for i in range(h):
						if C[i][j] == '
							counter += 1
				if b - counter == k:
					ans += 1
				counter = 0
print(ans)

Solution (Python):
import copy
import itertools
h,w,k = map(int,input().split())
c = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
	c[i] = input()
	c[i] = list(c[i])

counter = 0	
ans = 0
b = 0
for (i,j) in itertools.product(range(h), range(w)):
	if c[i][j] == '
		b += 1

for hl in range(h+1):
	for wl in range(w+1):
		for	hi in itertools.combinations(range(h),hl):
			for wj in itertools.combinations(range(w),wl):
				C = copy.deepcopy(c)
				for i in hi:
					for j in range(w):
						if C[i][j] == '
							counter += 1
							C[i][j] = '.'
				for j in wj:
					for i in range(h):
						if C[i][j] == '
							counter += 1
				if b - counter == k:
					ans += 1
				counter = 0
print(ans)

Solution (Python):
h,w,k = map(int, input().split())
c = [list(input()) for _ in range(h)]
ans = 0
for ib in range(1<<h):
    for jb in range(1<<w):
        cc = 0
        for i in range(h):
            if ib&(1<<i):
                continue
            for j in range(w):
                if jb&(1<<j):
                    continue
                cc += c[i][j]=="
        if cc==k:
            ans += 1
print(ans)

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

def m_fun(x):
    if x == '.':
        return 0
    return 1

def subsets(s):
    if len(s) == 0:
        return [[]]
    if len(s) == 1:
        return [[], s]
    prev_subsets = subsets(s[1:])
    return prev_subsets + [[s[0]] + l for l in prev_subsets]
    

A = [None] * h
for i in range(h):
    A[i] =  [m_fun(x) for x in list(input())]

count = 0

for ri in subsets(list(range(h))):
    for ci in subsets(list(range(w))):
        subcount = 0
        for i in ri:
            for j in ci:
                if A[i][j] == 1:
                    subcount += 1
        if subcount == k:
            count += 1
            
print(count)

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

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


        if black ==k:
            ans += 1

print(ans)

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

for h in range(1 << H):
    for w in range(1 << W):
        black = 0
        for i in range(H):
            if (h >> i) % 2 == 1:
                continue
            for j in range(W):
                if (w >> j) % 2 == 1:
                    continue
                if table[i][j] == '
                    black += 1
        if black == K:
            ans += 1

print(ans)

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

ans = 0
for ib in range(1<<H):
    for jb in range(1<<W):
        count = 0
        for i in range(H):
            for j in range(W):
                if ib>>i&1:
                    continue
                if jb>>j&1:
                    continue
                if mat[i][j] == '
                    count += 1
        if count == K:
            ans += 1
print(ans)