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):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    ans = 0
    for b1 in range(2**H):
        for b2 in range(2**W):

            c = 0
            for i in range(H):
                for j in range(W):
                    if (b1 >> i) & 1 or (b2 >> j) & 1:
                        continue
                    else:
                        c += f[i][j] == '

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





def main():
    solve()


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import combinations

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

ans = 0
for i in range(h+1):
  for j in range(w+1):
    for ci in combinations(list(range(h)),i):
      for cj in combinations(list(range(w)),j):
        cnt = 0
        for l in ci:
          for m in cj:
            if c[l][m] == "
              cnt += 1
        if cnt == k:
          ans += 1
print(ans)

Solution (Python):

import copy
ans = 0
S = []
S_red = []
S_kuro = []
H_parameter = [[0]]
W_parameter = [[0]]
Hsize = 0
Wsize = 0
n1 = 0
n2 = 0
n3 = 0
n4 = 0
n5 = 0
n6 = 0


H,W,K   = map(int, input().split())
for i in range(H):
    S.append(list(map(str, input())))



for n1 in range(1,H+1,1):
    H_parameter.append([n1])
    for n2 in range(1,H+1,1):
        if n2 > n1:
            H_parameter.append([n1,n2])
            for n3 in range(1,H+1,1):
                if n3 > n2:
                    H_parameter.append([n1,n2,n3])
                    for n4 in range(1,H+1,1):
                        if n4 > n3:
                            H_parameter.append([n1,n2,n3,n4])
                            for n5 in range(1,H+1,1):
                                if n5 > n4:
                                    H_parameter.append([n1,n2,n3,n4,n5])
                                    for n6 in range(1,H+1,1):
                                        if n6 > n5:
                                            H_parameter.append([n1,n2,n3,n4,n5,n6])
Hsize = len(H_parameter)




n1 = 0
n2 = 0
n3 = 0
n4 = 0
n5 = 0
n6 = 0

for n1 in range(1,W+1,1):
    W_parameter.append([n1])
    for n2 in range(1,W+1,1):
        if n2 > n1:
            W_parameter.append([n1,n2])
            for n3 in range(1,W+1,1):
                if n3 > n2:
                    W_parameter.append([n1,n2,n3])
                    for n4 in range(1,W+1,1):
                        if n4 > n3:
                            W_parameter.append([n1,n2,n3,n4])
                            for n5 in range(1,W+1,1):
                                if n5 > n4:
                                    W_parameter.append([n1,n2,n3,n4,n5])
                                    for n6 in range(1,W+1,1):
                                        if n6 > n5:
                                            W_parameter.append([n1,n2,n3,n4,n5,n6])
Wsize = len(W_parameter)


Qcount = 0

for l in range(Hsize):
    ll = len(H_parameter[l])
    for m in range(Wsize):
        S_red.clear()
        S_red = copy.deepcopy(S)
        mm = len(W_parameter[m])
        for q in range(ll):
            for r in range(mm):
                if H_parameter[l] != [0]:
                    for p in range(W):
                        S_red[H_parameter[l][q]-1][p]= 'R'
                if W_parameter[m] != [0]:            
                    for s in range(H):
                        S_red[s][W_parameter[m][r]-1]= 'R'
                
        
        Q = 0
        Qcount += 1
        S_kuro.clear()
        for j in range(H):
            for k in range(W):
                S_kuro.append(S_red[j][k])
        Q =S_kuro.count('
        
        
        if Q == K : ans += 1


print(ans)

Solution (Python):
info = list(map(int, input().split()))
matrix = [[""] * info[1] for i in range(info[0])]

for i in range(info[0]):
    matrix[i] = list(input())


Black = 0

for i in range(info[0]):
    for j in range(info[1]):
        if matrix[i][j] == "
            Black += 1


combination = 0

for i in range(2 ** info[0]):
    non_selected = set()
    count = 0

    for j in range(info[0]):
        if (i >> j) & 1:
            
            for k in range(info[1]):
                if matrix[j][k] == "
                    count += 1
        else:
            non_selected.add(j)
    

    for l in range(2 ** info[1]):

        count2 = count
        for t in range(info[1]):
            if (l >> t) & 1:

                for s in non_selected:
                    if matrix[s][t] == "
                        count2 += 1

        if (Black - count2) == info[2]:
            combination += 1


print(combination)

Solution (Python):
h, w, k = map(int, input().split())
X = [[1 if a == "
ans = 0
for ii in range(1 << h):
  for jj in range(1 << w):
    if sum([sum([X[i][j] for j in range(w) if jj >> j & 1]) for i in range(h) if ii >> i & 1]) == k:
      ans += 1
print(ans)

Solution (Python):
H, W, K = map(int, input().split(' '))
ls, rst = [], 0
for i in range(H):
    ls.append(list(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):
import copy
H, W, K = map(int, input().split())
lst = []
num = 0
for i in range(H):
    arrange = input()
    num += arrange.count('
    lst.append(arrange)

count = 0

for i in range(2**H):
    
    rlst = copy.copy(lst)
    counted = 0
    rstr = str(format(i, '0' + str(H) + 'b'))
    
    while '1' in rstr:
        index = rstr.find('1')
        counted += rlst[index].count('
        rlst[index] = "." * W
        rstr = rstr.replace('1','0',1)
    
    for j in range(2**W):
        ccounted = counted
        clst = copy.copy(rlst)
        cstr = str(format(j, '0' + str(W) + 'b'))
        
        while '1' in cstr:
            index = cstr.find('1')
            dlst = ""
            for k in range(H):
                dlst += clst[k][index]
                clst[k] = clst[k][:index] + '.' + clst[k][index+1:]
            ccounted += dlst.count("
            cstr = cstr.replace('1','0',1)
        
        
        if num - ccounted == K:
            count += 1

print(count)

Solution (Python):
import copy
H, W, K = map(int, input().split())
lst = []
num = 0
for i in range(H):
    arrange = input()
    num += arrange.count('
    lst.append(arrange)

count = 0

for i in range(2**H):
    
    rlst = copy.copy(lst)
    counted = 0
    rstr = str(format(i, '0' + str(H) + 'b'))
    
    while '1' in rstr:
        index = rstr.find('1')
        counted += rlst[index].count('
        rlst[index] = "." * W
        rstr = rstr.replace('1','0',1)
    
    for j in range(2**W):
        ccounted = counted
        clst = copy.copy(rlst)
        cstr = str(format(j, '0' + str(W) + 'b'))
        
        while '1' in cstr:
            index = cstr.find('1')
            dlst = ""
            for k in range(H):
                dlst += clst[k][index]
                clst[k] = clst[k][:index] + '.' + clst[k][index+1:]
            ccounted += dlst.count("
            cstr = cstr.replace('1','0',1)
        
        
        if num - ccounted == K:
            count += 1

print(count)

Solution (Python):
import itertools







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













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

rows = list(itertools.product((0,1), repeat=H))
columns = list(itertools.product((0,1), repeat=W))

def num_of_blacks(row, column):
    tot = 0
    for i in range(H):
        if row[i] == 0:
            continue
        for j in range(W):
            if column[j] == 0:
                continue
            if cells[i][j] == "
                tot += 1
    return tot

ans = 0
for row in rows:
    for column in columns:
        _ = num_of_blacks(row, column)
        if _ == K:
            ans += 1

print(ans)

Solution (Python):
number=list(map(int,input().split()))
H,W,K=number[0],number[1],number[2]
masu=[]
for i in range(H):
    tmp=list(str(input()))
    masu.append(tmp)
count=0
ans=0
for cowmask in range(1<<H):
    for rowmask in range(1<<W):
        count=0
        for x in range(H):
            for y in range(W):
                if (cowmask>>x)&1==0 and (rowmask>>y)&1==0 and masu[x][y]=="
                    count+=1
        if count==K:
            ans+=1
print(ans)

Solution (Python):


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





ans=0
for i in range(1,2**H):
    for j in range(1,2**W):
        resx=[]
        resy=[]
        ct=0
        for k in range(H):
            if (i>>k)&1:
                resx.append(k)
        for l in range(W):
            if (j>>l)&1:
                resy.append(l)
        
        B=[[A[k][l] for l in resy] for k in resx]
        for k in range(len(resx)):
            ct+=B[k].count('
        
        if ct==K:
            ans+=1
print(ans)

Solution (Python):
import numpy as np
hwk=input().split()
H=int(hwk[0])
W=int(hwk[1])
K=int(hwk[2])
bits=np.zeros(H+1,dtype='int64')
c = [input() for _ in range(H)]
ans=int(0)
while bits[H]==0:
    dp=np.zeros(H*W+1,dtype='int64')
    dp[0]+=1
    for j in range(W):
        kaz=0
        for i in range(H):
            if bits[i]==1 and c[i][j]=='
                kaz+=1
        for i in range(H*W,kaz-1,-1):
            dp[i]+=dp[i-kaz]
    ans+=dp[K]

    bits[0]+=1
    bas=0
    while bits[bas]==2:
        bits[bas]=0
        bas+=1
        bits[bas]+=1
print(ans)

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

Solution (Python):
h0, w0, k0 = [ int(x) for x in input().split() ]
found, buf = 0, {}
for i in range(h0): buf[1 << i] = { 1 << j for j,x in enumerate(input()) if x == '
for i in range(1, 1 << h0):
  idx = {}
  for k,vs in buf.items():
    if k & i == 0: continue
    for v in vs: idx[v] = idx.get(v, 0) + 1
  for j in range(1, 1 << w0):
    n = sum([ v for k,v in idx.items() if k & j ])
    if n == k0: found += 1
print(found)

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

for h in range(2**H):
  for w in range(2**W):
    c = 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]=="
          c+=1
    if c==K:
      ans+=1

print(ans)

Solution (Python):
import sys
import itertools
input = sys.stdin.readline
 
def SI(): return str(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
   
    H, W, K = MI()
    grid = [SI().rstrip('\n') for _ in range(H)]

    n = H + W
    ans = 0
    
    for i in itertools.product(range(2),repeat = H):
        for j in itertools.product(range(2),repeat = W):
            count = 0
            for k in range(H):
                if i[k] == 1:
                    continue
                for l in range(W):
                    if j[l] == 1:
                        continue
                    if grid[k][l] == "
                        count += 1
            if count == K:
                ans +=1
    print(ans)
main()

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

def count_num(m, target, goal):
    for i in range(h):
        count = sum(map(lambda x: x.count(target), m))
    
    return count == goal

def change_row(m, i_row_0):
    m[i_row_0] = 'r'*w    
    return m

def change_col(m, j_col_0):
    for i in range(h):
        if j_col_0 < w:
            m[i] = m[i][:j_col_0]+'r'+ m[i][j_col_0+1:]
    return m




for idx_h in range(2**h):
    for idx_w in range(2**w):
        m = masu.copy()
        for i_row, row in enumerate(m):
            if idx_h & (2 ** i_row) > 0:
                m = change_row(m, i_row)

            for j_col, col in enumerate(row):
                if idx_w & (2 ** j_col) > 0:
                    m = change_col(m, j_col)
        
        
        if count_num(m, '
            ans += 1
        
print(ans)

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

def count_num(m, target, goal):
    for i in range(h):
        count = sum(map(lambda x: x.count(target), m))
    
    return count == goal

def change_row(m, i_row_0):
    m[i_row_0] = 'r'*w    
    return m

def change_col(m, j_col_0):
    for i in range(h):
        if j_col_0 < w:
            m[i] = m[i][:j_col_0]+'r'+ m[i][j_col_0+1:]
    return m




for idx_h in range(2**h):
    for idx_w in range(2**w):
        m = masu.copy()
        for i_row, row in enumerate(m):
            if idx_h & (2 ** i_row) > 0:
                m = change_row(m, i_row)

            for j_col, col in enumerate(row):
                if idx_w & (2 ** j_col) > 0:
                    m = change_col(m, j_col)
        
        
        if count_num(m, '
            ans += 1
        
print(ans)

Solution (Python):
h, w, k = map(int,input().split())
c = []
for i in range(h):
  c.append(input())
  
def countb(c):
  num = 0
  for i in range(h):
    num += c[i].count("
  return(num)

def printb(c, row, col):
  c = c[:]
  
  cnt = 0
  while row != 0:
    if row  & 0b1:
     
      c[cnt] = "."*w
    cnt += 1
    row = row >> 1
  
  cnt = 0
  while col != 0:
    
    if col & 0b1:
      for i in range(h):
        c[i] = c[i][:cnt]+"."+c[i][cnt+1:]
    cnt += 1
    col = col >> 1
    
  
  return countb(c)

ans = 0
for i in range(2**h):
  for j in range(2**w):
    if printb(c,i,j) == k:
      ans += 1
print(ans)

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

masu = [input() for _ in range(h)]

ans = 0
for idx_h in range(2 ** h):
    for idx_w in range(2 ** w):
        m = masu.copy()
        for i_row, row in enumerate(m):
            for j_col, col in enumerate(row):
                if idx_h & (2 ** i_row) > 0 or idx_w & (2 ** j_col) > 0:
                    
                    m[i_row] = m[i_row][:j_col] + 'r' + m[i_row][j_col+1:]
        
        count_black = sum(map(lambda x: x.count('
        if count_black == k:
            ans += 1

print(ans)

Solution (Python):
import numpy as np

h,w,k = map(int,input().split())
lines = [input() for v in range(h)]
ans = 0

for ir in range(2**h):
    for ic in range(2**w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (ir>>i) & 1 == 0 and (ic>>j) & 1 == 0:
                    if lines[i][j]  == '
                      cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Solution (Python):
import sys

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):


import copy
import itertools
import numpy as np

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

for i in range(h):
    row = list(input())
    
    row = [0 if x=="." else 1 for x in row]
    row = np.array(row).reshape(1, w)
    if i == 0:
        c_matrix = row
    else:
        c_matrix = np.append(c_matrix, row, axis=0)
    

row_list = list(range(h))
col_list = list(range(w))
count = 0
for i in range(h+1):
    row_idx = list(itertools.combinations(row_list, i))
    for j in range(w+1):
        col_idx = list(itertools.combinations(col_list, j))
        
        for row in row_idx:
            for col in col_idx:
                tmp = copy.deepcopy(c_matrix)
                tmp[row, :] = 0 
                tmp[:, col] = 0
                ans = np.sum(np.sum(tmp, axis=1))
                if ans == k:
                    count += 1
                    
            
print(count)

Solution (Python):
from itertools import product

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

p1 = list(product([False, True], repeat=H))
p2 = list(product([False, True], repeat=W))
ans = 0

for i in range(len(p1)):
    for j in range(len(p2)):
        count = 0
        for a in range(H):
            for b in range(W):
                if C[a][b] == "
                    count += 1
        if count == K:
            ans += 1
print(ans)

Solution (Python):
import numpy as np
import copy
import itertools
h,w,k = map(int, input().split())
s = [list(input()) for i in range(h)]
data = np.zeros(h*w).reshape(h,w)
for i in range(h):
    for j in range(w):
        if s[i][j] == '
            data[i][j] = 1
 
ans = 0

if np.sum(data == 1) == k:
    ans = 1

if k == 0:
    ans = 1
 
a = list()
b = list()
for i in range(1,h):
    a += list(itertools.combinations(range(h), i))
for i in range(1,w):
    b += list(itertools.combinations(range(w), i))
 
for i in a:
    for j in b:
        temp = data.copy()
        temp[i,:] = 2
        temp[:,j] = 2
        if np.sum(temp == 1) == k:
            ans += 1
 
for i in a:
    temp = data.copy()
    temp[i,:] = 2
    if np.sum(temp == 1) == k:
        ans += 1
        
for j in b:
    temp = data.copy()
    temp[:,j] = 2
    if np.sum(temp == 1) == k:
        ans += 1
        
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
c = []
for i in range(h):
  c.append(input())
t = 2**(h+w)
ans = 0
for i in range(t):
  tc = c[:]
  b = format(i, 'b').zfill(h+w)
  for j in range(len(b)):
    if b[j] == "1":
      if j < h:
        tc[j] = "?"*w
      else:
        for l in range(h):
          tc[l] = tc[l][:(j-h)] + "?" + tc[l][(j-h+1):]
  cn = 0
  for j in range(h):
    cn += tc[j].count("
  if cn == k:
    ans += 1
print(ans)

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

for i in range(H):
    ls.append(list(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):
from  itertools import combinations as cmb
import copy 

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

C = []
ans = 0

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

for i in range(H):
  for j in range(W):
    for hs in cmb(range(H),i):
      for ws in cmb(range(W),j):
        tmpC = copy.deepcopy(C)
        for h in hs:
          tmpC[h] = ["" for k in range(W)]
        for w in ws:
          for k in range(H):
            tmpC[k][w]="" 
        
        if sum(tmpC,[]).count("
          ans +=1    
print(ans)

Solution (Python):
h, w, f = list(map(int, input().split()))
c = [input() for i in range(h)]
count = 0
bit_h = []
for k in range(2**h):
    hh = []
    for l in range(h):
        if((k >> l) & 1):
            hh.append(1)
        else:
            hh.append(0)
    bit_h.append(hh)

bit_w = []
for i in range(2**w):
    ww = []
    for j in range(w):
        if((i >> j) & 1):
            ww.append(1)
        else:
            ww.append(0)
    bit_w.append(ww)

ans = 0
for i in range(len(bit_h)):
    for j in range(len(bit_w)):
        count = 0
        for k in range(h):
            for l in range(w):
                if bit_h[i][k] == 1 and bit_w[j][l] == 1 and c[k][l] == "
                    count += 1
        if count == f:
            ans += 1
print(ans)

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

ans=0

for i in range(2**H):
	for j in range(2**W):
		cnt=0
		for k in range(H):
			for l in range(W):
				if c_map[k][l]=='
					cnt+=1
		if cnt==K:
			ans+=1

print(ans)

Solution (Python):
import math
import copy

ans = 0

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

for i in range(int(math.pow(2, H+W))):
    i_bin = ''.join(list(reversed(format(i, 'b').zfill(100))))
    C = copy.deepcopy(c)
    for h in range(H):
        if i_bin[h] == '1':
            for w in range(W):
                C[h][w] = '.'
    for w in range(W):
        if i_bin[H + w] == '1':
            for h in range(H):
                C[h][w] = '.'
    count = 0
    for h in range(H):
        count += C[h].count('
    if count == K:
        ans += 1

print(ans)

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

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

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:
      ans += 1

print(ans)

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

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

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

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

ans = 0
for hi in range(2 ** h):
    hs = set()
    for hj in range(h):
        if (hi >> hj) & 1:
            hs.add(hj)
    for wi in range(2 ** w):
        ws = set()
        for wj in range(w):
            if (wi >> wj) & 1:
                ws.add(wj)
        cnt = 0
        for i in range(h):
            if i in hs:
                continue
            for j in range(w):
                if j in ws:
                    continue
                if c[i][j] == "
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
import itertools

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

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

print(ans)

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

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

c = [0] * h

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

ans = 0
for rows in range(1 << h):
    for cols in range(1 << w):
        b_cnt = 0
        for _h in range(h+1):
            if not (rows >> _h) & 1:
                continue
            for _w in range(w+1):
                if not (cols >> _w) & 1:
                    continue
                if c[_h][_w] == '
                    b_cnt += 1
        if b_cnt == k:
            ans += 1

print(ans)

Solution (Python):
import copy
H,W,n_black = map(int,input().split())
grid = [list(input()) for _ in range(H)]
for y in range(H):
    for x in range(W):
        if grid[y][x] == "
            grid[y][x] = 1
        else:
            grid[y][x] = 0
num_pat = 2**(H+W)
ans = 0
for i in range(num_pat):
    now_grid = copy.deepcopy(grid)
    for j in range(H+W):    
        if i>>j & 1:
            if j < H:
                for x in range(W):
                    now_grid[j][x] = 0
            else:
                j -= H
                for y in range(H):
                    now_grid[y][j] = 0
    black = 0
    for y in range(H):
        black += sum(now_grid[y])
    if black == n_black:
        ans += 1
print(ans)

Solution (Python):

_INPUT = """\
2 3 2
..

"""

def main():
    H, W, K = map(int, input().split())
    grid = [input() for _ in range(H)]
    
    n = H + W
    ans = 0
    for i in itertools.product(range(2), repeat=H):
        for j in itertools.product(range(2), repeat=W):
            cnt = 0            
            for y in range(H):
                if i[y]:
                    continue
                for x in range(W):
                    if j[x]:
                        continue
                    if grid[y][x] == "
                            cnt += 1
            if cnt == K:
                ans += 1
    print(ans)

if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools

    
    main()

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 m in itertools.combinations(list(range(H)), i):
            for n in itertools.combinations(list(range(W)), j):
                count = 0
                for a in m:
                    for b in n:
                        if(C[a][b] == "
                            count += 1
                if(count == K):
                    ans += 1

print(ans)

Solution (Python):
import copy

H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]
k = sum([ci.count("
ans = 0

for i2 in range(2 ** H):
  for j2 in range(2 ** W):
    cr = copy.deepcopy(c)
    for k in range(H+1):
      if i2 & 2**k == 2**k:
        for j in range(W):
          cr[k][j] = "$"
    for l in range(W+1):
      if j2 & 2**l == 2**l:
        for i in range(H):
          cr[i][l] = "$"
    if K == sum([ci.count("
      ans += 1
    
print(ans)

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

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

ans = 0

for i in range(1 << h):
	for j in range(1 << w):
		cnt = 0
		for n in range(h):
			for m in range(w):
				if i >> n & 1:
					continue
				if j >> m & 1:
					continue
				if c[n][m] == '
					cnt += 1
		if cnt == k:
			ans += 1
print(ans)

Solution (Python):



import numpy
from copy import deepcopy

def binary(x, n):
  l = []
  for i in range(n):
    l.append(x%2==1)
    x //= 2
  return l

def main():
  h, w, k = map(int, input().strip().split())
  mat = numpy.array([[1 if c=='
  
  def f(mat, i, j):
    mat[binary(i, h)] = 0
    mat[:, binary(j, w)] = 0
    return mat.sum() == k
  
  cnt = 0
  for i in range(2 ** h):
    for j in range(2 ** w):
      if f(deepcopy(mat), i, j):
        cnt += 1
  print(cnt)
      
if __name__=='__main__':
  main()

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

Solution (Python):
from itertools import combinations
import copy

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

w = list(range(W))
h = list(range(H))
for i in range(W+1):
    for comi in combinations(w, i):
        for j in range(H+1):
            for comj in combinations(h, j):
                tmpC = copy.deepcopy(C)
                for ci in comi:
                    for hj in range(H):
                        tmpC[hj][ci] = '.'
                for cj in comj:
                    for wi in range(W):
                        tmpC[cj][wi] = '.'
                tmp = 0
                for tc in tmpC:
                    tmp += tc.count('
                if tmp == K:
                    ans += 1

print(ans)

Solution (Python):
def Qc():
    """
    塗りつぶされた列をbitに置き換えて探索する
    """
    h, w, k = map(int, input().split())
    lines = [input() for v in range(h)]
    ans = 0
    for ir in range(2 ** h):
        for ic in range(2 ** w):
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if (ir >> i) & 1 and (ic >> j) & 1:
                        if lines[i][j] == '
                            cnt += 1
            if cnt == k:
                ans += 1
    print(ans)


if __name__ == '__main__':
    Qc()

Solution (Python):
import copy

h, w, k = map(int, input().split())
grd = [list(i for i in input()) for _ in range(h)]
ans = 0
for i in range(2**h):
    grd1 = copy.deepcopy(grd)
    for i1 in range(h):
        if i >> i1 & 1:
            grd1[i1] = ['r'] * w
    for j in range(2**w):
        grd2 = copy.deepcopy(grd1)
        for j1 in range(w):
            if j >> j1 & 1:
                for n in range(h):
                    grd2[n][j1] = 'r'

        if sum(grd2,[]).count('
            ans += 1
print(ans)