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 itertools
h, w, k = map(int, input().split())
ans = 0
s = [input() for _ in range(h)]
for hi in itertools.product([0, 1], repeat=h):
    for wi in itertools.product([0, 1], repeat=w):
        cnt = 0
        for i, j in itertools.product(range(h), range(w)):
            if hi[i] and wi[j]:
                if s[i][j] == "
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

for rows in range(1 << h):
    for cols in range(1 << w):
        black = 0
        for i in range(h):
            if (rows >> i) & 1:
                continue
            for j in range(w):
                if (cols >> j) & 1:
                    continue
                if grid[i][j] == "
                    black += 1

        if black == k:
            cnt += 1

print(cnt)

Solution (Python):
import numpy as np

H, W, K = map(int, input().split())
c = np.array([sum([2 ** i if s == "

ans = 0
for h in range(2 ** H):
  h_idx = np.array([bool(h & 2 ** i) for i in range(H)])
  for w in range(2 ** W):
    cnt = 0
    for a in c[h_idx]:
      cnt += bin(a & w).count("1")
    if cnt == K:
      ans += 1
      
print(ans)

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

c = []
ans = 0

for i in range(H):
    tmp =list(input())
    c.append(tmp)

for i in range(2**H):
    for j in range(2**W):
        now = 0
        for x in range(H):
            for y in range(W):
                if (i >> x) & 1 and (j >> y) & 1:
                    if c[x][y] == "
                        now += 1

        if now == K:
            ans += 1

print (ans)

Solution (Python):

def resolve():
    
    H, W, K = map(int, input().split())
    G = [list(input()) for _ in range(H)]

    ans = 0
    for bit_i in range(1<<H):
        for bit_j in range(1 << W):
            cnt = 0
            for i in range(H):
                for j in range(W):
                    if (bit_i>>i & 1) or (bit_j>>j & 1):
                        continue
                    if G[i][j] == "
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()

Solution (Python):
import sys
import math
import collections
import heapq

def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin


def int_input():
    return list(map(int, input().split()))


if __name__ == '__main__':
    

    
    t = 1

    for ti in range(1, t + 1):
        m, n, k = int_input()

        A = []

        res = 0

        for i in range(m):
            A.append([x for x in input()])

        

        for i in range(2 ** m):
            for j in range(2 ** n):
                cnt = 0

                for h in range(m):
                    for w in range(n):
                        if (i>>h & 1): continue
                        if (j>>w & 1): continue
                        cnt += A[h][w] == '

                if cnt == k:
                    res += 1

        print(res)

Solution (Python):



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

ans = 0

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

      if cnt == K: ans += 1
print(ans)

Solution (Python):
import copy

H,W,Q = map(int,input().split())
c = [list(input()) for _ in range(H)]
kotei = copy.deepcopy(c)
ans = 0

K = 2 
N = H+W 
for i in range(K**N):
    TF=[0]*N
    c = copy.deepcopy(kotei)

    for j in range(N):
        TF[N-j-1] = i % K
        i //= K
    
    
    for j in range(len(TF)):
        if TF[j] == 1 and 0 <= j < H:
            c[j] = ["R"]*W
        if TF[j] == 1 and j >= H:
            j -= H
            for k in range(H):
                c[k][j] = "R"

    
    black = 0
    for j in range(H):
        for k in range(W):
            if c[j][k] == "
                black += 1
    if black == Q:
        ans += 1

print(ans)

Solution (Python):
H, W, K = map(int,input().split())
c_list = [[]]*H

for i in range(H):
    c_list[i] = input()
    c_list[i] = list(c_list[i])

ans = 0
for a in range(2 ** H):
    for b in range(2 ** W):
        black = 0
        for i in range(H):
            for j in range(W):
                if ((a >> i) & 1) and ((b >> j) & 1) and c_list[i][j] == str("
                    black += 1
        if black == K:
            ans += 1

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')


from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations

import numpy as np    


def solve():
    H, W, K = MI()
    G = np.array([])
    for h in range(H):
        l = LS()
        for i in range(W):
            if l[i] == '
                l[i] = 1
            else:
                l[i] = 0
        G = np.append(G, l)
    G = G.reshape((H, W))

    ret = 0
    for x in product((0, 1), repeat=W):
        dX = G * x  
        for y in product((0, 1), repeat=H):
            s = (dX.T * y).sum()
            if s == K:
                ret += 1
    print(ret)


if __name__ == '__main__':
    solve()

Solution (Python):

def resolve():
    H, W, K = map(int, input().split())
    G = [list(input()) for _ in range(H)]
    all_cnt = sum([g.count("
    ans = 0
    for bit_i in range(1<<H):
        for bit_j in range(1 << W):
            cnt = 0
            for i in range(H):
                for j in range(W):
                    if bit_i>>i & 1 or bit_j>>j & 1:
                        if G[i][j] == "
                            cnt += 1
            if all_cnt - cnt == K:
                ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()

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

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

Solution (Python):
import sys
from itertools import combinations
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rr = lambda: sys.stdin.readline().rstrip()

h, w, k = rm()
li = np.array([np.array(list(rr())) for _ in range(h)])
cnt = 0

for i in range(h+1):
    for a in np.array(list(combinations(li, i))):
        a = a.T
        for j in range(w+1):
            for b in np.array(list(combinations(a, j))):
                t = np.count_nonzero(b == '
                if t == k:
                    cnt += 1
print(cnt)

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

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

ans = 0



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

print(ans)

Solution (Python):
def main():
    H, W, K = map(int, input().split())
    B = [[int(c == '

    def cnt_bk_cell(mask_r, mask_c):
        """未着色かつ黒のセルを数える"""
        ret = 0
        for r in range(H):
            if (mask_r >> r) & 1: continue  
            for c in range(W):
                if (mask_c >> c) & 1: continue  
                if B[r][c]: ret += 1
        return ret

    ans = 0
    for mask_r in range(1 << H):  
        for mask_c in range(1 << W):
            if K == cnt_bk_cell(mask_r, mask_c): ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
h, w, k = map(int, input().split()) 
s = sys.stdin.readlines()
ans = 0
for ib in range(1<<h):
  for jb in range(1<<w):
    cnt = 0
    for i in range(h):
      if ib >> i & 1:
        continue
      for j in range(w):
        if jb >> j & 1:
          continue
        if s[i][j] == "
          cnt += 1
    if cnt == k:
      ans += 1
print (ans)

Solution (Python):
import copy

h,w,k = map(int, input().split())
cij = ['' for i in range(h)]
for i in range(h):
    cij[i] =list(input())
Ans = 0

bb = 2 ** h
list_i = []
for i in range(bb):
    cc = str(bin(i)[2:]).zfill(h)
    dd = [list(cc)]
    list_i = list_i + dd

bbb = 2 ** w
list_j = []
for i in range(bbb):
    ccc = str(bin(i)[2:]).zfill(w)
    ddd = [list(ccc)]
    list_j = list_j + ddd

for i in range(len(list_i)):
    cij2 = copy.copy(cij)
    for i_ in range(len(list_i[i])):
        if list_i[i][i_]=='1':
            cij2[i_] = ['r' for i in range(w)]
    for j in range(len(list_j)):
        cij3 = copy.deepcopy(cij2)
        for j_ in range(h):
            for j__ in range(len(list_j[j])):
                if list_j[j][j__]=='1':
                    cij3[j_][j__] = 'r'
        cij4 = str(cij3)
        if cij4.count('
            Ans = Ans + 1
print(Ans)

Solution (Python):
import itertools
h,w,k=map(int,input().split())
li=[]
ans=0
for i in range(h):
    c=input()
    li.append(c)
for n in itertools.product([0,1],repeat=h):
    for m in itertools.product([0,1],repeat=w):
        sharp=0
        for i in range(h):
            if n[i]==1:
                continue
            else:
                for j in range(w):
                    if m[j]==1:
                        continue
                    else:
                        if li[i][j]=="
                            sharp+=1
        if sharp==k:
            ans+=1
print(ans)

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

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

ans = 0



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

print(ans)

Solution (Python):
a,b,c=map(eval,input().split())
lar=[[]for i in range(a)]
for j in range(a):
    start=input()
    for q in range(len(start)):
        lar[j]+=[start[q]]
kok=0
for i in range(a):
    for j in range(b):
        if lar[i][j]=="
            kok+=1
w=0
num2=(2**a)*(2**b)
for i in range(num2):
    pop=[[0 for i in range(b+5)]for j in range(a+5)]
    num=0
    p=bin(i)[2:]
    e=p[::-1]
    for q in range(len(e)):
        if q-a<=-1 and e[q]=="1":
            for m in range(b):
                pop[q][m]=1
        if q-a>-1 and e[q]=="1":
            for j in range(a):
                pop[j][q-a]=1
    for i in range(a):
        for j in range(b):
            if lar[i][j]=="
                num+=1
    if num==c:
        w+=1
print(w)

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

ans = 0
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 table[i][j] == '
                    black = black + 1
        if black == k: 
            ans = ans + 1
print(ans)

Solution (Python):
import itertools
H,W,K=map(int,input().split())
 
C=[]
 
for i in range(H):
  C.append(input())
 
ans=0
for i in range(H+1):
  for j in range(W+1):
    for n in itertools.combinations(list(range(H)),i):
      for m in itertools.combinations(list(range(W)),j):
        count = 0
        for a in n:
          for b in m:
            if(C[a][b]=="
        if(count == K):
          ans += 1
print(ans)

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

for iss in range(1<<h):
    for js in range(1<<w):
        cnt=0
        for i in range(h):
            for j in range(w):
                if iss>>i & 1: continue
                if js>>j & 1: continue
                if A[i][j]=='
        if cnt==k:
            ans+=1

print(ans)

Solution (Python):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

h,w,k=map(int,input().split())
C = [input() for i in range(h)]
for biti in range(2**h):
  for bitj in range(2**w):
    count = 0
    for i in range(h):
      for j in range(w):
        if C[i][j] == "." or (biti >> i &1) or (bitj >> j & 1):count += 1
    if h*w-count == k:
      ans += 1
    
print(ans)

Solution (Python):
from pprint import pprint

import sys
from collections import Counter
from itertools import product, combinations

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

C = []
for _ in range(H):
    C.append(input())

counter = Counter()
for row in C:
    counter.update(row)
n_blacks = counter['

if n_blacks < K:
    print(0)
    sys.exit()

ans = 0

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

print(ans)

Solution (Python):
def main():
    h,w,k=map(int, input().split())
    grid = []
    l = [[0]*w for _ in range(h)]
    ten_g = [0]*(h)
    ten_r = [0]*(w)
    for i in range(h):
        s = list(input().rstrip())
        grid.append(s)
    res = 0
    for bi in range(2**(h+w)):
        tmp = 0
        for i in range(h):
            for j in range(w):
                if(bi & 1<<i and bi&(1<<h+j)):
                    if(grid[i][j]=="
                        tmp+=1
        if(tmp == k):
            res+=1


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

Solution (Python):





import copy

H, W, K = list(map(int, input().split()))
c = ["" for i in range(H)]
for i in range(H):
    c[i] = input()
ans = 0
for i in range(2**(H+W)):
    d = copy.deepcopy(c)
    
    for j in range(H):
        if (i >> j ) & 1 == 1:
            d[j] = "." * W
    for j in range(W):
        if (i >> (j + H) ) & 1 == 1:
            for k in range(H):
                
                d[k] = d[k][0:j] + "." + d[k][j+1:W] 
    count = 0
    for j in range(H):
        for k in range(W):
            if d[j][k] == "
                count += 1
                
    if count == K:
        ans += 1
print(ans)

Solution (Python):
from pprint import pprint

import sys
from collections import Counter
from itertools import product, combinations

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

C = []
for _ in range(H):
    C.append(input())

counter = Counter()
for row in C:
    counter.update(row)
n_blacks = counter['

if n_blacks < K:
    print(0)
    sys.exit()


board = ''
for row in C:
    board += row

bitboard = 0b0
for cell_index in range(len(board)):
    digit = len(board) - cell_index - 1
    if board[cell_index] == '
        bitboard |= 0b1 << digit
    else:
        bitboard |= 0b0 << digit












def get_row_base_mask(n_col):
    ret = 0b0
    for c in range(n_col):
        ret |= 0b1 << c
    return ret

col_base_mask = get_row_base_mask(W)



def get_col_base_maak(n_row):
    ret = 0b0


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

print(ans)

Solution (Python):
def LI(): return map(int,input().split())
def I() :return int(input())

h,w,k=LI()
lst=[]
cnt=0
for i in range(h):
    lst+=[list(input())]
    for j in range(w):
        if lst[i][j]=="
            cnt+=1
black=0
ans=0
for rows in range(1<<h):
    for cols in range(1<<w):
        black=0
        for i in range(h):
            if (rows>>i)&1:continue
            for j in range(w):
                if (cols>>j)&1:continue
                elif lst[i][j]=="
                    black +=1
                    

        if black ==k:
            ans+=1
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
chw = [input() for _ in range(h)]
  
answer = 0
for col in range(2**h):
  for row in range(2**w):
    black = 0
    for i in range(h):
      for j in range(w):
        if ((col >> i) & 1) and ((row >> j) & 1) and (chw[i][j] == "
          black = black +1

    if black == k:
      answer += 1

print(answer)

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

rows = []
cols = []
for i in range(H):
    temp = 0
    for j in range(W):
        if M[i][j] == '
            temp += 1
    rows += [temp]

for j in range(W):
    temp = 0
    for i in range(H):
        if M[i][j] == '
            temp += 1
    cols += [temp]

total = sum(rows)
ans = 0
for i in range(2**H):
    s1 = "0"*(H-len(bin(i)[2:]))+bin(i)[2:]    
    for j in range(2**W):
        s2 = "0"*(W-len(bin(j)[2:]))+bin(j)[2:]
        delete = 0
        for p in range(H):
            if s1[p] == "1":
                    delete += rows[p]
        for q in range(W):
            if s2[q] == '1':
                delete += cols[q]
        
        for p in range(H):
            for q in range(W):
                if s1[p] == "1" and s2[q] == "1":
                    if M[p][q] == "
                        delete -= 1
        if total - delete == K:
            
            ans += 1
print(ans)

Solution (Python):

def convert(i,n):
    arr = []
    for k in range(n):
        arr = [i%2]+arr
        i = int(i/2)
    return arr

def copy(a,n,m):
    arr = [[0 for i in range(m)] for j in range(n)]
    for i in range(n):
       for j in range(m):
           arr[i][j] = a[i][j]
    return arr

def main():
    h,w,k = map(int,input().split())
    c = [['' for j in range(w)] for i in range(h)]
    for i in range(h):
        s = input()
        for j in range(w):
            c[i][j] = s[j]
    H = 2**h
    W = 2**w

    ans = 0
    for row in range(H):
        for col in range(W):
            t = copy(c,h,w)
            
            rowb = convert(row,h)
            colb = convert(col,w)
            
            
            for i in range(h):
                if rowb[i]==1:
                    for j in range(w):
                        t[i][j] = '_'
            for j in range(w):
                if colb[j]==1:
                    for i in range(h):
                        t[i][j] = '_'
            
            black = 0
            for i in range(h):
                black += t[i].count('

            if black==k:
                ans += 1

    print(ans)
    return
                    
    
    

if __name__=='__main__':
    main()

Solution (Python):
import numpy as np
import copy
from itertools import product
h, w, k = map(int, input().split())
C = [list(input()) for _ in range(h)]
C = np.array(C)

cnt = 0


for p in product([True, False], repeat=(h+w)):
    c = copy.deepcopy(C)
    c = np.array(c)
    for i, v in enumerate(p):
        if i < h and v:
            c[i, :] = "$"
        elif v:
            c[:, i - h] = "$"
    if np.count_nonzero(c == "
        cnt += 1

print(cnt)

Solution (Python):
import copy
import numpy as np

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

result = 0
table = []
for i in range(h):
  table.append(list(input()))

totalBlackCount = 0
for i in range(h):
  for j in range(w):
    if table[i-1][j-1] == '
      table[i-1][j-1] = 0
      totalBlackCount += 1
    else:
      table[i-1][j-1] = 1
npTable = np.asarray(table)

rowPattern = []
columnPattern = []
rowCount = 0
columnCount = 0
for i in range(2**h):
  rowPattern.append(list(format(rowCount, str('0')+str(h)+'b')))
  rowCount += 1
for i in range(2**w):
  columnPattern.append(list(format(columnCount, str('0')+str(w)+'b')))
  columnCount += 1

rowRed = []
rowBlack = []
columnRed = []
columnBlack = []
for i in range(h):
  columnRed.append(1)
  columnBlack.append(0)
for i in range(w):
  rowRed.append(1)
  rowBlack.append(0)

for i in range(2**h):
  npCalcTable = copy.deepcopy(npTable)
  rowBit = rowPattern[i-1]
  rowColorTable = []
  for j in range(h):
    if rowBit[j] == '0':
      rowColorTable.append(rowBlack)
    else:
      rowColorTable.append(rowRed)
  npRowColorTable = np.asarray(rowColorTable)
  for j in range(2**w):
    columnBit = columnPattern[j-1]
    columnColorTable = []    
    for k in range(w):
      if columnBit[k-1] == '0':
        columnColorTable.append(columnBlack)
      else:
        columnColorTable.append(columnRed)
    npColumnColorTable = np.asarray(columnColorTable).T
    npColorTable = npRowColorTable | npColumnColorTable
    npDiffTable = npColorTable | npCalcTable

    if np.sum(npDiffTable) == int(redK):
      result += 1
print(result)

Solution (Python):
h,w,K=map(int,input().split())
s=[list(input())for i in range(h)]
import numpy as np
s=np.array(s)
l=[]
for i in range(h):
    l.append(len(s[i][s[i]=="
for i in range(w):
    l.append(len(s[:,i][s[:,i]=="
ss=sum(l)//2
n=h+w
ans=0
for i in range(1<<n):
    tmp=ss
    for j in range(h):
        if i>>j&1:
            tmp-=l[j]
    for j in range(h,n):
        if i>>j&1:
            tmp-=l[j]
            for idx,k in enumerate(s[:,j-h]):
                if k=="
                    if i>>idx&1:
                        tmp+=1
    if tmp==K:
        ans+=1
print(ans)

Solution (Python):
h,w,k = map(int, input().split())
A = [input() for _ in range(h)]
ans = 0
for gyou in range(2**h):
  for retsu in range(2**w):
    black = 0
    for x in range(h):
      for y in range(w):
        if ((gyou >> x) & 1) == 0 and ((retsu >> y) & 1) == 0 and A[x][y] == "
          black = black + 1
    if black == k:
      ans = ans + 1
print(ans)

Solution (Python):


import itertools
import copy

H, W, k = map(int, input().split())
c = [list(input()) for _ in range(H)]

wlist = list(itertools.product([0, 1], repeat=W))
hlist = list(itertools.product([0, 1], repeat=H))

ans = 0 
for h in hlist:
    for w in wlist:
        black = 0 
        for i in range(H):
            for j in range(W):
                if h[i] == w[j] == 1 and c[i][j] == '
                    black += 1
        if black == k:
            ans += 1

print(ans)

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

for i in range(2**(H+W)):
    h=i%(2**H)
    w=i//(2**H)
    count=0
    for x in range(H):
        if (2**x) & h == 0:
            continue
        for y in range(W):
            if (2**y) & w == 0:
                continue
            if M[x][y]=='
                count+=1
    if count==K:
        ans+=1
print(ans)

Solution (Python):


import sys

def main():
    input = sys.stdin.readline
    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:
                        if C[i][j] =='
            if c == k: ans += 1
    print(ans)

    return


if __name__ == '__main__':
    main()

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): 
        black = 0
        for i in range(h):
            if ib&(1<<i):continue 
            for j in range(w):
                if jb&(1<<j):continue 
                black += c[i][j]=="
        if black==k: ans += 1
print(ans)

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

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

for i in range(2 ** H):
    for j in range(2 ** W):
        black = 0
        for x in range(H):
            for y in range(W):
                if ((i >> x) & 1) and ((j >> y) & 1) and C[x][y] == "
                    black += 1
        if black == K:
            cnt += 1
print(cnt)

Solution (Python):


import itertools
import copy

H, W, k = map(int, input().split())
c = [list(input()) for _ in range(H)]

clist = list(itertools.product([0, 1], repeat=H+W))


ans = 0 
for q in clist:
    black = 0 
    h = q[:H]
    w = q[H:]
    
    
    

    for i in range(H):
        for j in range(W):
            if h[i] == w[j] == 1 and c[i][j] == '
                black += 1
    if black == k:
        ans += 1

print(ans)

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

c = [None] * H

for i in range(H):
  c[i] = list(input())

res = 0

for h in range(2 ** H):
  for w in range(2 ** W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if ((h >> i) & 1) == 0 and ((w >> j) & 1) == 0 and c[i][j] == '
          cnt += 1
    
    if cnt == K:
      res += 1

print(res)

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



ans = 0
for R in range(2**H):
  for C in range(2**W):
    n = 0
    for y in range(H):
      for x in range(W):
        if C>>x&1 and R>>y&1:
          if c[y][x]=="
            n += 1
    if n==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 mask_H in product([True,False],repeat=H):
    for mask_w in product([True,False],repeat=W):
        black=0
        for i in range(H):
            for j in range(W):
                if mask_H[i] and mask_w[j] and c[i][j]=="
                    black+=1
        if black==K:
            ans+=1
print(ans)

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

cnt = 0
for i in range(1 << H):
    for j in range(1 << W):
        tmp_cnt = 0
        for h in range(H):
            if (i >> h) & 1:
                continue
            for w in range(W):
                if (j >> w) & 1:
                    continue
                tmp_cnt += masu[h][w] == "
        if tmp_cnt == K:
            cnt += 1
print(cnt)

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

for ib in range(1<<h):
    for jb in range(1<<w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if ib>>i&1: continue
                if jb>>j&1: continue
                if s[i][j] == '
                    cnt+=1
        if cnt == k:
            ans += 1

print(ans)

Solution (Python):
from itertools import combinations

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

cnt = 0
for rh in range(H):
    for rw in range(W):
        for h in combinations(range(H), rh):
            for w in combinations(range(W), rw):
                T = [c[:] for c in C]
                for hi in h:
                    T[hi] = list("." * W)
                for wj in w:
                    for i in range(H):
                        T[i][wj] = "."
                if K == sum(t.count("
                    cnt += 1

print(cnt)

Solution (Python):
import numpy as np
h,w,k = map(int,input().split())

ls = []
for i in range(h):
    ls.append(str(input()))


ns = np.zeros((h,w),dtype = int)
for i in range(h):
    for j in range(w):
        if ls[i][j] == "
            ns[i][j] = 1

ans = 0
for i in range(2** h):
    for j in range(2 ** w):
        black = 0
        for x in range(h):
            for y in range(w):
                if (i >> x) & 1 == 0 and (j >> y) & 1 == 0:
                    if ns[x][y] == 1:
                        black += 1
        if black == k:
            ans += 1

print(ans)

Solution (Python):
import itertools
h,w,k = map(int, input().split())
g = []
for _ in range(h):
  g.append(input())
ans = 0
for i in list(itertools.product([0,1], repeat=h)):
  for j in list(itertools.product([0,1], repeat=w)):
    e = 0
    for x in range(h):
      for y in range(w):
        if i[x] == 1 and j[y] == 1 and g[x][y]=='
          e+=1
    if e==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):
  for j in range(2**w):
    cnt=0
    for x in range(h):
      for y in range(w):
        if i>>x&1:continue
        if j>>y&1:continue
        if c[x][y]=="
    if cnt==k:
      ans+=1
print(ans)

Solution (Python):
import copy
h,w,K=map(int,input().split())
maze=[]
for i in range(h):
    line=list(input())
    maze.append(line)
ans=0
for i in range(2**(w+h)):
    g=[]
    r=[]
    for j in range(w+h):
        if i&(1<<j) and j<h:
            g.append(j)
        if i&(1<<j) and j>=h:
            r.append(j-h)
    tmp=copy.deepcopy(maze)
    cnt=0
    for k in range(h):
        for l in range(w):
            if k in g or l in r:
                continue
            if tmp[k][l]=="
                cnt+=1
    if cnt==K:
        ans+=1
print(ans)