Problem:
 Score : 300 points    Problem Statement We have a grid of H rows and W columns of squares. The color of the square at the i -th row from the top and the j -th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j} : the square is white if c_{i,j} is . , and black if c_{i,j} is # .  Consider doing the following operation:   Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.   You are given a positive integer K . How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.      Constraints  1 \leq H, W \leq 6  1 \leq K \leq HW  c_{i,j} is . or # .         Input Input is given from Standard Input in the following format:  H  W  K  c_{1,1}c_{1,2}...c_{1,W}  c_{2,1}c_{2,2}...c_{2,W}  :  c_{H,1}c_{H,2}...c_{H,W}       Output Print an integer representing the number of choices of rows and columns satisfying the condition.        Sample Input 1 2 3 2
..#
###      Sample Output 1 5  Five choices below satisfy the condition.   The 1 -st row and 1 -st column  The 1 -st row and 2 -nd column  The 1 -st row and 3 -rd column  The 1 -st and 2 -nd column  The 3 -rd column        Sample Input 2 2 3 4
..#
###      Sample Output 2 1  One choice, which is choosing nothing, satisfies the condition.       Sample Input 3 2 2 3
##
##      Sample Output 3 0       Sample Input 4 6 6 8
..##..
.#..#.
#....#
######
#....#
#....#      Sample Output 4 208

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

lit = []
for i in range(2 ** H):
    for j in range(2 ** W):
        row = str(bin(i))[2:].zfill(H)
        col = str(bin(j))[2:].zfill(W)
        lit.append([row, col])



black = sum([c.count('



res = 0
for row, col in lit:

    ans = black
    black_row = 0
    black_col = 0
    for i, r in enumerate(row):
        if r == '1':
            ans -= C[i].count('
            black_row += C[i].count('
        

    for j, c in enumerate(col):
        if c == '1':
            for k in range(H):
                if row[k] == '1':
                    continue
                if C[k][j] == '
                    ans -= 1
                    black_col += 1
    
    if ans == K:
        res += 1

print(res)

Solution (Python):
import math
import sys
from itertools import combinations 
import itertools

def main():
    h, w, n = list(map(int, input().split()))
    c = [input() for _ in range(h)]
    ans = 0
    black = 0
    for i in range(2 **h):
        for j in range(2 **w):
            black = 0
            for k in range(h):
                for l in range(w):
                    if ((i >>k) & 1) == 0 and ((j >> l) & 1) == 0:
                        if c[k][l] == "
                            black += 1
            if black == n:
                ans += 1
    print(ans)
    
main()

Solution (Python):
from itertools import product

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

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if c[row][col] == "
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Solution (Python):
from itertools import product
h,w,k=map(int,input().split())
f=0
c=[]
for i in range(h):
  tmp=list(input())
  c.append(tmp)
  f+=tmp.count("
ans=0
for i in product([0,1],repeat=h):
  for j in product([0,1],repeat=w):
    cnt=0
    for x in range(h):
      for y in range(w):
        if i[x]==1 or j[y]==1:
          if c[x][y]=="
    if f-cnt==k:
      ans+=1
print(ans)

Solution (Python):
import sys
from copy import deepcopy

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    H, W, K = map(int, rl().split())
    c = [list(rl().rstrip()) for _ in range(H)]
    
    ans = 0
    for sh in range(1 << H):
        for sw in range(1 << W):
            cc = deepcopy(c)
            for y in range(H):
                if sh >> y & 1:
                    for x in range(W):
                        cc[y][x] = '.'
            for x in range(W):
                if sw >> x & 1:
                    for y in range(H):
                        cc[y][x] = '.'
            cnt = 0
            for y in range(H):
                for x in range(W):
                    cnt += cc[y][x] == '
            ans += cnt == K
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline



def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    h, w, k = geta(int)
    c = []
    for _ in range(h):
        c.append(gete())

    ans = 0
    for bi in range(1 << h):
        for bj in range(1 << w):

            rem = 0
            for i in range(h):
                if bi >> i & 1 == 1:
                    continue
                for j in range(w):
                    if bj >> j & 1 == 1:
                        continue
                    if c[i][j] == "
                        rem += 1

            if rem == k:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()

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

ans = 0
bk = 0
pt1 = []
pt2 = []

for i in range(2 ** h):
    tmp1 = [False] * (h)
    for j in range(h):
        if i >> j & 1:
            tmp1[j] = True
    pt1.append(tmp1)

for i in range(2 ** w):
    tmp2 = [False] * (w)
    for j in range(w):
        if i >> j & 1:
            tmp2[j] = True
    pt2.append(tmp2)

for i in range(len(pt1)):
    for j in range(len(pt2)):
        for x in range(h):
            if (pt1[i][x]==True):
                bk = bk + s[x][0].count('
        
        for y in range(w):
            if (pt2[j][y]==True):
                for z in range(h):
                    if (pt1[i][z]==True and s[z][0][y]=='
                        bk == bk
            else:
                for z in range(h):
                    if (pt1[i][z]==True and s[z][0][y]=='
                        bk -= 1

        if bk == k:
            ans += 1
        
        bk = 0

print(ans)

Solution (Python):
def main():
    H,W,K = [int(x) for x in input().split()]

    B = 0
    BH = [0]*H
    BW = [0]*W
    BHW = []
    for h in range(H):
        BHW.append([0]*W)
    for i in range(H):
        C = list(input())
        for j in range(W):
            if C[j] == '
                B += 1
                BH[i] += 1
                BW[j] += 1
                BHW[i][j] = 1

    cnt = 0
    for ibit in range(0,1<<H):
        for jbit in range(0,1<<W):
            ib = 0
            jb = 0
            ijb = 0
            for i in range(H):
                if (1<<i) & ibit:
                    ib += BH[i]
            for j in range(W):
                if (1<<j) & jbit:
                    jb += BW[j]
            for i in range(H):
                for j in range(W):
                    if (1<<i) & ibit and (1<<j) & jbit:
                        ijb += BHW[i][j]
            b = B - ib - jb + ijb
            if K == b:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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

if __name__ == '__main__':
  h,w,k=map(int,input().strip("\n").split())
  s=[]
  for i in range(h):
    s.append(list(input().strip("\n")))
  ans=0
  
  
  for iS in range(1<<h):
    
    for js in range(1<<w):
      
      cnt=0
      for i in range(h):
        for j in range(w):
          
          
          if iS>>i&1: continue
          if js>>j&1: continue
          if s[i][j]=='
      if cnt==k: ans+=1

  print(ans)

Solution (Python):
H, W, K = map(int, input().split())
G = [list(input()) for _ in range(H)]
ans = 0
for rows in range(2**H):
    for cols in range(2**W):
        black = 0
        for i in range(H):
            if rows >> i & 1:
                continue
            for j in range(W):
                if cols >> j & 1:
                    continue
                if G[i][j] == '
                    black += 1
        if black == K:
            ans += 1
print(ans)

Solution (Python):
from itertools import product
import sys
read = sys.stdin.read
def main():
    h, w, k = map(int, input().split())
    c = []
    for _ in range(h):
        row = [c == '
        c.append(row)
    r = 0
    p1 = tuple(product((0, 1), repeat=w))
    p2 = tuple(product((0, 1), repeat=h))
    pat = tuple(product(p1, p2))
    for pe in pat:
        t = 0
        for x, col in enumerate(pe[0]):
            for y, row in enumerate(pe[1]):
                t += col * row * c[y][x]
        if t == k:
            r += 1
    print(r)
if __name__ == '__main__':
    main()

Solution (Python):


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

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

ans = 0

for h_ in range(2 ** H):
    h_b = format(h_, '0' + str(H) + 'b')
    for w_ in range(2 ** W):
        w_b = format(w_, '0' + str(W) + 'b')
        
        b_count = 0
        for h in range(H):
            for w in range(W):
                if h_b[h] == "0" and w_b[w] == "0" and C[h][w] == "
                    b_count += 1
        if b_count == K:
            ans += 1

print(ans)

Solution (Python):
import numpy as np
import itertools

h,w,k = (int(x) for x in input().split())
c = np.array([list(input()) for x in range(h)])
answer = 0


for x,y in itertools.product(range(2**h), range(2**w)):
    count = 0
    for i,j in itertools.product(range(h), range(w)):
        if x>>i &1 or y>>j&1:continue
        if c[i,j]=="
            count+=1
    if count == k:
        answer += 1
        
print(answer)

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):
import itertools
import copy
def count_hash(arr):
    b_count = 0
    for v in arr:
        for r in v:
            if r == "
                b_count += 1
    return b_count
def h_and_v(arr, k):
    rows = len(arr)
    cols = len(arr[0])
    mix_arr = []
    for i in range(rows):
        mix_arr.append(str(i) + "r")
    for j in range(cols):
        mix_arr.append(str(j) + "c")
    combo_arr = []
    for i in range(0, len(mix_arr)):
        temp_arr = list(itertools.combinations(mix_arr, i))
        combo_arr.append(temp_arr)
    del temp_arr
    del mix_arr
    all_combo = []
    for v in combo_arr:
        for r in v:
            all_combo.append(r)
    count = 0
    for a in all_combo:
        temp = copy.deepcopy(arr)
        for i, r in enumerate(a):
            if r[-1] == "r":
                temp[int(r[0])][:] = ["r"]*(len(temp[0]))
            else:
                for i in range(len(temp)):
                    temp[i][int(r[0])] = "r"
        if count_hash(temp) == k:
            count += 1
    print(count, end="")




def start():
    h,w,k = [int(v) for v in input().split(" ")]
    arr = []
    for i in range(h):
        arr.append([char for char in input()])
    h_and_v(arr, k)

start()

Solution (Python):
h,w,k = map(int,input().split())
c = []
for i in range(h):
    c.append(list(input()))
ans = 0
for i in range(2**h-1):
    for j in range(2**w-1):
        num = 0
        for ii in range(h):
            for jj in range(w):
                if  i&1<<ii==0 and j&1<<jj==0:
                    if c[ii][jj]=="
                        num += 1
        if num==k:
            
            ans += 1


print(ans)

Solution (Python):
inp = list(map(int,input().split()))
row=inp[0]
col=inp[1]
k=inp[2]
arr=[]
for i in range(row):
    s=input()
    arr.append(s)
ans=0
for i in range((1<<row)-1,-1,-1):
    for j in range((1<<col)-1,-1,-1):
        black=0
        for a in range(row):
            for b in range(col):
                if ((i>>a)&1 ==0 and (j>>b)&1 ==0):
                    if arr[a][b]=='
                        black+=1
        if black==k:
            ans+=1
print (ans)

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

Solution (Python):
def main():
    H, W, K = map(int, input().split())
    Field = []

    sharpNum = 0

    for i in range(H):
        rowString = input()

        colSharpNum = rowString.count("
        sharpNum = sharpNum + colSharpNum
        wField = []

        for j in range(W):
            wField.append(rowString[j])
                    
        Field.append(wField)
    
    answer = 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 Field[i][j] == "
                        black = black + 1
            if black == K:
                answer = answer + 1

    print(answer)

if __name__ == "__main__":
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    ans = 0
    for mask_r in range(1 << H):
        for mask_c in range(1 << W):
            black = 0
            for i in range(H):
                for j in range(W):
                    if ((mask_r & (1 << i)) == 0) and ((mask_c & (1 << j)) == 0) and G[i][j] == '
                        black += 1
            if black == 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):
        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):
from itertools import product
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

ans = 0

for rows in product([True, False], repeat=H):
    
    for cols in product([True, False], repeat=W):
        
        black = 0
        for r, c in product(range(H), range(W)):
            
            if rows[r] and cols[c] and C[r][c] == '
                black += 1
        if black == K:
            ans += 1

print(ans)

Solution (Python):
import sys


def resolve():
    """
    全パターンは2**12=4096通りだからbit全探索
    消さない行列だけ判定するコードの方がスマート？(解説動画より)
    """

    readline = sys.stdin.readline    

    H, W, K = map(int, readline().split())
    c = [list(readline().strip()) for _ in [0] * 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 (1
                            and bit_i & (1 << i)
                            and bit_j & (1 << j)
                            and c[i][j] == '
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)


resolve()

Solution (Python):

from collections import deque

h,w,ans = map(int,input().split())
tmap = ['']*w
map = []
count = 0

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

for i in range(2**h):
    for j in range(2**w):
        map2 = []
        tmap2 = ['']*w
        sharp = 0
        for k in range(h):
            if((i>>k)&1):
                map2.append(['.']*w)
            else:
                map2.append(map[k])
            for l in range(w):
                tmap2[l] += map2[k][l]
        for k in range(w):
            if not((j>>k)&1):
                sharp += tmap2[k].count('
        if sharp == ans:
            count += 1
        

print(count)

Solution (Python):
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007

inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file=0



def solve():
    
    
    h,w,k=mi()
    a=[]
    cnt=0
    for i in range(h):
        a.append(si())
        for j in a[i]:
            if j=='
                cnt+=1
    ans=0
    
    for i in range(1<<(h+w)):
        c=set()
        x=[]
        y=[]
        for j in range(h):
            if (i>>j)&1:
                x.append(j)
                for k1 in range(w):
                    if a[j][k1]=='
                        c.add(tuple([j,k1]))
        for j in range(w):
            if (i>>(h+j))&1:
                for k1 in range(h):
                    if a[k1][j]=='
                        c.add(tuple([k1,j]))
        c1=cnt-len(c)
        if(c1==k):
            
            ans+=1
        
    print(ans)



 









if __name__ =="__main__":

    if(file):

        if path.exists('input1.txt'):
            sys.stdin=open('input1.txt', 'r')
            sys.stdout=open('output1.txt','w')
        else:
            input=sys.stdin.readline
    solve()

Solution (Python):
H,W,K = map(int,input().split())
s = [list(input()) for i 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 == 1 and (j>>w)&1==1:
          if s[h][w]=='
            cnt += 1
    if cnt==K:
      ans += 1
print(ans)

Solution (Python):

import itertools
import numpy as np


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    H, W, K = list(map(int, input().split()))
    c = []
    for h in range(H):
        c.append(input())

    return H, W, K, c


def main(H: int, W: int, K: int, c: list) -> None:
    """
    メイン処理.

    Args:\n
        H (int): 行数（1 <= H <= 6）
        W (int): 列数（1 <= W <= 6）
        K (int): 正の整数（1 <= K <= HW）
        c (list): マスの色
    """
    
    l = np.zeros(shape=(H, W))
    for h, w in itertools.product(range(H), range(W)):
        l[h, w] = (c[h][w] == "

    
    ans = 0
    for h_bit, w_bit in itertools.product(range(1 << H), range(1 << W)):
        l_copy = l.copy()
        for h in range(H):
            if h_bit & (1 << h):
                l_copy[h, :] = [0]
        for w in range(W):
            if w_bit & (1 << w):
                l_copy[:, w] = [0]
        ans += (np.sum(l_copy) == K)

    
    print(ans)


if __name__ == "__main__":
    
    H, W, K, c = get_input()

    
    main(H, W, K, c)

Solution (Python):
H, W, K = map(int, input().split())
c = [0] * H
ans = 0
for i in range(H):
    c[i] = input()
for row in range(1 << H):
    for line in range(1 << W):
        black = 0
        for h in range(H):
            if (row >> h) % 2 == 1:
                continue
            for w in range(W):
                if (line >> w) % 2 == 1:
                    continue
                if c[h][w] == '
                    black += 1
        if black == K:
            ans += 1
print(ans)

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

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

Solution (Python):
H, W, K = map(int, input().split())
g = [input() for _ in range(H)]
ans = 0
for bit in range(2**(H+W)):
    cnt = 0
    for h in range(H):
        if ((bit >> h) & 1):
            continue
        for w in range(W):
            if ((bit >> H + w) & 1):
                continue
            if g[h][w] == '
                cnt += 1
    if cnt == K:
        ans += 1
print(ans)

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

ttcl = [x for x in zip(*cl)]
tcl = []
for i in range(len(ttcl)):
  tt = "".join(ttcl[i])
  tcl.append(tt)

n = h
hb = ['0'] * n
hbl = []
for bit in range(1 << n):
  for i in range(n):
    if (bit >> i) & 1:
      hb[i] = '1'
    else:
      hb[i] = '0'
  hbl.append("".join(hb))

n = w
wb = ['0'] * n
wbl = []
for bit in range(1 << n):
  for i in range(n):
    if (bit >> i) & 1:
      wb[i] = '1'
    else:
      wb[i] = '0'
  wbl.append("".join(wb))

rc = 0
for i in range(len(hbl)):
  for j in range(len(wbl)):
    tbc = 0
    for m in range(h):
      for n in range(w):
        if (hbl[i][m] == '1') and (wbl[j][n] == '1'):
          if cl[m][n] == '
            tbc += 1
    if tbc == k:
      rc += 1
print(rc)

Solution (Python):
H,W,K=map(int,input().split())
import numpy as np
import copy
c=[]
for i in range(H):
  c.append(list(input().replace('.','0').replace('

def count(xdel,ydel,l):
  cnt=0
  for i in range(H):
      for j in range(W):
        if 2**i&ydel!=0 or 2**j&xdel!=0:
          l[i][j]=2
        if l[i][j]=='1':
          cnt+=1
          l[i][j]=1
        
  return cnt

result=0
for i in range(2**H):
  for j in range(2**W):
    l=copy.deepcopy(c)
    if count(j,i,l)==K:
      result+=1
print(result)

Solution (Python):
def count(C, H, W):
    v = 0
    for h in range(H):
        for w in range(W):
            if C[h][w] == '
                v += 1
    return v

def main():
    H, W, K, = map(int, input().split())
    C = []
    for _ in range(H):
        C.append([c for c in input()])
    
    ans = 0
    for h in range(2**H - 1):
        D = []
        for i in range(H):
            if (h >> i) & 1 == 1:
                D.append(['-' for w in range(W)])
            else:
                D.append([C[i][w] for w in range(W)])
        for w in range(2**W):
            E = []
            for a in range(H):
                E.append([D[a][b] for b in range(W)])
            for j in range(W):
                if (w >> j) & 1 == 1:
                    for k in range(H):
                        E[k][j] = '-'
            v = count(E, H, W)
            
            if v == K:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):

import itertools
import numpy as np


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


l = np.zeros(shape=(H, W))
for h, w in itertools.product(range(H), range(W)):
    l[h, w] = (c[h][w] == "

ans = 0
for h_bit, w_bit in itertools.product(range(1 << H), range(1 << W)):
    l_copy = l.copy()
    for h in range(H):
        if h_bit & (1 << h):
            l_copy[h, :] = [0]
    for w in range(W):
        if w_bit & (1 << w):
            l_copy[:, w] = [0]
    ans += (np.sum(l_copy) == K)


print(ans)

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

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

a = np.array([list(input()) for _ in range(h)])

cnt = 0
for rows in product([False, True], repeat = h):
    for cols in product([False, True], repeat = w):
        if np.count_nonzero(a[np.ix_(rows,cols)]=='
           cnt += 1

print(cnt)

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

total = 0

for i in range(2**(H)):
  for j in range(2**(W)):
    pattern = 0
    bin_H = '{:09b}'.format(i)[-H:]
    bin_W = '{:09b}'.format(j)[-W:]
    for hi,h in enumerate(bin_H):
      if h == '0':
        for wi,w in enumerate(bin_W):
          if w == '0' and C[hi][wi] == "
            pattern += 1
    if pattern == K:
      total += 1
print(total)

Solution (Python):
from itertools import *
h,w,k=map(int,input().split())
c=[]
s=[]
H=[i for i in range(h)]
W=[i for i in range(w)]
ans=0
for i in range(h):
    c.append(list(input()))
for i in range(2**h):
    for j in range(2**w):
        tmp=0
        for ii in range(h):
            for jj in range(w):
                if ((i>>ii)&1) and ((j>>jj)&1):
                    if c[ii][jj]=="
                        tmp+=1
        if tmp==k:
            ans+=1
                        
print(ans)

Solution (Python):
import numpy as np
'''
K = 2
H, W = 5, 5
a = np.array([
	[0, 0, 0, 0, 1],
	[0, 0, 0, 1, 1],
	[0, 0, 1, 1, 1],
	[0, 1, 1, 1, 1],
	[1, 1, 1, 1, 1]
])
'''

def conv(c):
	
	return int(c=='
H, W, K = map(int, input().split())
a = np.array([list(map(conv, input())) for _ in range(H)])
count = 0
for i in range(2 ** H - 1):
	b = np.delete(a.copy(), [j for j in range(H) if ((i >> j) & 1)], 0)
	blen = b.shape[1]
	for i in range(2 ** W - 1):
		c = np.delete(b, [j for j in range(blen) if ((i >> j) & 1)], 1)
		
		if K==np.sum(c):
			count += 1
print(count)
print()

Solution (Python):
H, W, K =  [int(i) for i in input().split()]

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



h_p = []
for h in range(pow(2,H)):
    h_p.append( [int(i) for i in list(str(bin(h))[2:].zfill(H))] )



w_p = []
for w in range(pow(2,W)):
    w_p.append( [int(i) for i in list(str(bin(w))[2:].zfill(W))] )



def count(mas, h_b, w_b):
    ans = 0
    for i in range(H):
        for j in range(W):
            if h_b[i] * w_b[j] == 1 and mas[i][j] == "
                ans += 1
    return ans


ans_cnt = 0

for h in h_p:
    for w in w_p:
        cnt = 0
        for i in range(H):
            for j in range(W):
                if h[i] * w[j] == 1 and masme[i][j] == "
                    cnt += 1
        if(cnt == K):
            ans_cnt += 1

print(ans_cnt)

Solution (Python):
H, W, K =  [int(i) for i in input().split()]

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



h_p = []
for h in range(pow(2,H)):
    h_p.append( [int(i) for i in list(str(bin(h))[2:].zfill(H))] )



w_p = []
for w in range(pow(2,W)):
    w_p.append( [int(i) for i in list(str(bin(w))[2:].zfill(W))] )

ans_cnt = 0

for h in h_p:
    for w in w_p:
        cnt = 0
        for i in range(H):
            for j in range(W):
                if h[i] * w[j] == 1 and masme[i][j] == "
                    cnt += 1
        if(cnt == K):
            ans_cnt += 1

print(ans_cnt)

Solution (Python):
def main():
    H,W,K = [int(x) for x in input().split()]

    B = 0
    BH = [0]*H
    BW = [0]*W
    BHW = []
    for h in range(H):
        BHW.append([0]*W)
    for i in range(H):
        C = list(input())
        for j in range(W):
            if C[j] == '
                B += 1
                BH[i] += 1
                BW[j] += 1
                BHW[i][j] = 1

    cnt = 0
    for ibit in range(0,1<<H):
        for jbit in range(0,1<<W):
            icost = 0
            jcost = 0
            ijcost = 0
            for i in range(H):
                if (1<<i) & ibit:
                    icost += BH[i]
            for j in range(W):
                if (1<<j) & jbit:
                    jcost += BW[j]
            for i in range(H):
                for j in range(W):
                    if (1<<i) & ibit and (1<<j) & jbit:
                        ijcost += BHW[i][j]
            b = B - icost - jcost + ijcost
            if K == b:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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


num_h = 2**h-1
num_w = 2**w-1
result = 0
for i in range(num_h):
  for j in range(num_w):
    tmp = 0
    for row in range(h):
      for col in range(w):
        if (i >> row) & 1 == 1:
          continue
        if (j >> col) & 1 == 1:
          continue
        if c[row][col] == '
          tmp += 1
    if tmp == k:
      result += 1

print(int(result))

Solution (Python):
h, w, k = map(int, input().split())
g = [input() for _ in range(h)]
ans = 0
for bit in range(2**(h+w)):
    cnt = 0
    for hh in range(h):
        if ((bit >> hh) & 1):
            continue
        for ww in range(w):
            if ((bit >> h + ww) & 1):
                continue
            if g[hh][ww] == '
                cnt += 1
    if cnt == k:
        ans += 1
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
c = [input() for i in range(h)]
ans = 0
for i in range(1 << h):
    for j in range(1 << w):
        cnt = 0
        for x in range(h):
            for y in range(w):
                if (i >> x & 1) or (j >> y & 1):
                    continue
                if c[x][y] == "
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
c = [input() for i in range(h)]
ans = 0
for i in range(1 << h):
    for j in range(1 << w):
        cnt = 0
        for x in range(h):
            for y in range(w):
                if (i >> x & 1) or (j >> y & 1):
                    continue
                if c[x][y] == "
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

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

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

for i in range(2**h):
  x = 0
  h_flag = [0]*(h)
  while i != 0:
      if i % 2 == 1:
        h_flag[x] = 1
      i = i // 2
      x += 1
  for j in range(2**w):
    black = 0
    w_flag = [0]*(w)
    y = 0
    while j != 0:
      if j % 2 == 1:
        w_flag[y] = 1
      j = j // 2
      y += 1
    for m in range(h):
      for n in range(w):
        if c[m][n] == '
          black += 1

    if black == 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):
H, W, K =  [int(i) for i in input().split()]

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



h_p = []
for h in range(pow(2,H)):
    h_p.append( [int(i) for i in list(str(bin(h))[2:].zfill(H))] )



w_p = []
for w in range(pow(2,W)):
    w_p.append( [int(i) for i in list(str(bin(w))[2:].zfill(W))] )



def count(mas, h_b, w_b):
    ans = 0
    for i in range(H):
        for j in range(W):
            if h_b[i] * w_b[j] == 1 and mas[i][j] == "
                ans += 1
    return ans


ans_cnt = 0
for h in h_p:
    for w in w_p:
        cnt = count(masme, h, w)
        if(cnt == K):
            ans_cnt += 1

print(ans_cnt)

Solution (Python):
import itertools
import copy

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

print(ans)