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 copy import deepcopy

def readinput():
    h,w,k=list(map(int,input().split()))
    c=[]
    for _ in range(h):
        l=list(input())
        c.append(l)
    return h,w,k,c

def printC(c):
    for l in c:
        print(l)

def main(h,w,k,c):
    ans=0
    for g in range(2**h):
        for r in range(2**w):
            cc=deepcopy(c)
            for i in range(h):
                b=2**i
                if g & b == b:
                    for j in range(w):
                        cc[i][j]='*'
            for j in range(w):
                b=2**j
                if r & b == b:
                    for i in range(h):
                        cc[i][j]='*'
            
            
            count=0
            for i in range(1,h+1):
                for j in range(1,w+1):
                    if cc[i-1][j-1]=='
                        count+=1
            if count==k:
                ans+=1

    return ans

if __name__=='__main__':
    h,w,k,c=readinput()
    ans=main(h,w,k,c)
    print(ans)

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

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

Solution (Python):
h,w,k=map(int,input().split())
lis=[[0 for i in range(6)]for j in range(6)]
for i in range(h):
  tmp=input()
  for j in range(w):
    if(tmp[j]=="
      lis[i][j]=1

ans=0
for i in range(2**h):
  for j in range(2**w):
    tmp=0
    hoge="{:0>{}b}".format(i, 6)[::-1]
    huga="{:0>{}b}".format(j, 6)[::-1]
    for a in range(6):
      for b in range(6):
        if(hoge[a]=="0" and huga[b]=="0"):
          if(lis[a][b]==1):
            tmp+=1
            
    if(tmp==k):
      ans+=1
      
      
print(ans)

Solution (Python):
H,W,K=map(int,input().split())
C=[list(input())for _ in range(H)]
S=0
for c in C:
    S+=c.count('

ans=0
for i in range(2**H): 
    Bit_i = list(range(1,H+1)) 
    for k in range(H): 
        if (i >> k) & 1:
            Bit_i[k]*=-1
    for j in range(2**W): 
        Bit_j = list(range(1,W+1)) 
        for l in range(W): 
            if (j >> l) & 1:
                Bit_j[l]*=-1
        count=0
        for a in Bit_i:
            for b in Bit_j:
                if a>0:
                    count+=(C[a-1][abs(b)-1]=='
                elif b>0:
                    count+=(C[abs(a)-1][b-1]=='
        ans+=(S-count==K)         

print(ans)

Solution (Python):
import copy
h,w,k=map(int,input().split())
v=[]
for _ in range(h):
    array=list(input())
    v.append(array)
ans=0
for a in range(2**h):
    c=copy.deepcopy(v)
    for b in range(h):
        if a>>b & 1:
            for d in range(w):
                c[b][d]=0
    for e in range(2**w):
      z=copy.deepcopy(c)
      temp=0
      for f in range(w):
        if e>>f & 1:
          for g in range(h):
            z[g][f]=0
      for p in range(h):
        temp+=z[p].count("
      if temp==k:
        ans+=1
print(ans)

Solution (Python):
import numpy as np


H, W, K = map(int,input().split())
L = np.zeros([6,6],dtype=int)
count = 0


for i in range(H):
    s = input()
    for j in range(W):
        if s[j-1] == "
            L[i,j] = 1



for i in range(2**H):
    for j in range(2**W):
        tmp = L.copy()
        for ib in range(H):
            if (i >> ib) & 1:
                tmp[ib,:] = 0
            for jb in range(W):
                if (j >> jb) & 1:
                    tmp[:,jb] = 0
        if np.sum(tmp) == K:
            count += 1

print(count)

Solution (Python):
import numpy as np

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

c = []

for _ in range(h):
    s = input()
    yoko = [0 if i=='.' else 1 for i in s]
    c.append(yoko)

c = np.array(c)

ans = 0
















for i in range(2**h):
    arr = np.copy(c)
 
    s = str(bin(i))
    condition = s[2:].zfill(h)

    for i_h in range(h):
        if condition[i_h] == '0':
            arr[i_h] = 0

    
    for j in range(2**w):
        arr2 = np.copy(arr)

        s = str(bin(j))
        condition = s[2:].zfill(w)

        for j_w in range(w):
                
            if condition[j_w] == '0':
                arr2[:,j_w] = 0

        if arr2.sum() == k:
            ans += 1

print(ans)

Solution (Python):
from math import *
from cmath import rect

def dft(f,x):
  if len(f)==1:
    return
  f0,f1=f[0::2],f[1::2]
  dft(f0,x)
  dft(f1,x)
  z=rect(1,x*2*acos(-1)/len(f))
  n=1+0j
  for i in range(len(f)):
    f[i]=f0[i%len(f0)]+n*f1[i%len(f1)]
    n=n*z

def pm(p,q):
  siz=1
  while len(p)+len(q)>siz:
    siz*=2
  np=[]
  nq=[]
  for i in range(len(p)):
    np.append(rect(p[i],0))
  for i in range(len(q)):
    nq.append(rect(q[i],0))
  while len(np)<siz:
    np.append(0+0j)
  while len(nq)<siz:
    nq.append(0+0j)
  dft(np,1)
  dft(nq,1)
  for i in range(siz):
    np[i]=np[i]*nq[i]
  dft(np,-1)
  EPS=0.1
  for i in range(siz):
    np[i]=int(np[i].real/siz+EPS)
  return np

H,W,K=map(int,input().split())
C=[input() for i in range(H)]
DP=0
X=[]
P=0

def poly(x):
  r=[0]*x
  r.append(1)
  r[0]+=1
  return r

def knapsack(L):
  if len(L)==1:
    return poly(L[0])
  a=knapsack(L[:len(L)//2])
  b=knapsack(L[len(L)//2:])
  return pm(a,b)[:K+1]

for i in range(1,1<<H):
  X=[0]*W
  for j in range(H):
    if i&(1<<j):
      for k in range(W):
        if C[j][k]=='
          X[k]+=1
  DP=knapsack(X)
  if len(DP)>K:
    P+=DP[K]
print(P)

Solution (Python):
import numpy as np
H, W, K = map(int, input().split())
state = np.zeros((H, W), dtype=int)
for h in range(H):
  hlist = input()
  for w in range(W):
    if hlist[w] == "
      state[h][w]=1

startb = np.sum(state)
count = 0

if startb < K:
  print(0)
else:
  h_l = 2**H
  w_l = 2**W
  for h in range(h_l):
    for w in range(w_l):
      t1 = [int(i) for i in list(str(bin(h))[2:])]
      t2 = np.zeros(H-len(t1), dtype=int)
      wflag = np.append(t2, t1)
      state_t = state * np.array([wflag]*W).T

      t1 = [int(i) for i in list(str(bin(w))[2:])]
      t2 = np.zeros(W-len(t1), dtype=int)
      hflag = np.append(t2, t1)
      state_t = state_t * np.array([hflag]*H)

      if np.sum(state_t)==K:
        count=count+1
  print(count)

Solution (Python):


import copy
import random
import bisect 
import fractions 
import math
import sys
import collections
from decimal import Decimal 
import numpy as np

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
"""
H, W, K = LI()
c = [[0 for j in range(W)] for i in range(H)]

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


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


"""

"""
ans = 0



def n2kdigit(n,k):
    digits = [0 for i in range(H + W)]
    tmp = 0
    while n > 0:
        digits[tmp] = n % k
        n = n // k
        tmp += 1

    return digits

for i in range(2 ** (H + W)):
    cnt = 0
    c_ = copy.deepcopy(c)
    digits = n2kdigit(i, k = 2)
    for j, digit in enumerate(digits):
        if digit == 1:
            if j >= H:
                for h in range(H):
                    
                    c_[h][j - H - 1] = 0
            else:
                "Hを示す"
                c_[j] = [0 for k in range(W)]
    
    for h in range(H):
        cnt += sum(c_[h])
    if cnt == K:
        ans += 1

print(ans)


"""


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

c = []
for h in range(H):
    l = []
    for s in input():
        if s == ".":
            l.append(0)
        else:
            l.append(1)
    c.append(l)

ans = 0
for bit_h in range(2 ** H): 
    for bit_w in range(2 ** W):
        k = 0
        nn = np.asarray(c)
        
        for h in range(H):
            """
            (bit_h & 2 ** h)の部分で，マスクがかかっている部分を調べる
            >> hによって，参照したい行が0 or 1なのかを調べる．0なら色がないので，したの作業がいらない
            """
            if (bit_h & 2 ** h) >> h == 0:
                continue
            nn[h] = np.zeros((1, W))
        for w in range(W):
            if (bit_w & 2 ** w) >> w == 0:
                continue
            nn[:, w] = np.zeros((1, H))
        
        if K == np.sum(nn):
            ans += 1
print(ans)

Solution (Python):
H,W,K=map(int,input().split())
C=[input() for i in range(H)]
DP=[0]*(K+1)
X=[]
P=0
for i in range(1,1<<H):
  X=[0]*W
  for j in range(H):
    if i&(1<<j):
      for k in range(W):
        if C[j][k]=='
          X[k]+=1
  for j in range(K+1):
    DP[j]=0
  DP[0]=1
  for j in range(W):
    for k in range(K,-1,-1):
      if k+X[j]<=K:
        DP[k+X[j]]+=DP[k]
  P+=DP[K]
print(P)

Solution (Python):
import copy
H, W, K = map(int,input().split())
C = [list(input()) for y in range(H)]
D = copy.deepcopy(C)       
ans = 0
import itertools


def retu(x):            
    for y in range(H):
        C[y][x] = "R"

def gyou(x):            
    for y in range(W):
        C[x][y] = "R"


for p in range(2**H):
    for q in range(2**W):
        for r in range(H):
            if p >> r & 1:
                gyou(r)
        for s in range(W):
            if q >> s & 1:
                retu(s)
        E = list(itertools.chain.from_iterable(C))  
        
        if E.count("
            ans += 1
        C = copy.deepcopy(D)


print(ans)

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

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

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

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

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

ans = 0
for h_combo in range(2**H):
    for w_combo in range(2**W):
        curr_cnt = 0

        for i in range(H):
            for j in range(W):
                if (h_combo >> i) & 1 == 0 and (w_combo >> j) & 1 == 0:
                    if arr[i][j] == '
                        curr_cnt += 1
        
        if curr_cnt == K:
            ans += 1

print(ans)

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

Solution (Python):
H, W, K= map(int, input().split())
c = [input() for i in range(H)]
true_cnt = 0
for j in range(2**H):
  bin_j = str(bin(j))[2:].zfill(H)
  for k in range(2**W):
    bin_k = str(bin(k))[2:].zfill(W)
    cnt = 0
    
    for l in range(H):
      if bin_j[l] == "0":
        continue
      for m in range(W):
        if bin_k[m] == "0":
          continue
        elif c[l][m] == "
          cnt += 1
    if cnt == K:
      true_cnt += 1
print(true_cnt)

Solution (Python):
H, W, K = map(int, input().split())
arr = []
tot_cnt = 0
for _ in range(H):
    curr = list(input())
    arr.append(curr)
    tot_cnt += curr.count('

tot_moves = 0
for h_combo in range(2**H):
    h_combo = list(bin(h_combo)[2:])
    h_combo = ['0'] * (H - len(h_combo)) + h_combo
    
    for w_combo in range(2**W):
        w_combo = list(bin(w_combo)[2:])
        w_combo = ['0'] * (W - len(w_combo)) + w_combo

        curr_cnt = 0
        for i in range(H):
            if h_combo[i] == '1':
                curr_cnt += arr[i].count('
        
        for i in range(W):
            if w_combo[i] == '1':
                for j in range(H):
                    if h_combo[j] != '1':
                        curr_cnt += 1 if arr[j][i] == '
        
        if tot_cnt - curr_cnt == K:
            tot_moves += 1

print(tot_moves)

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

ln = []
for i in range(H):
    sam = []
    sam2 = input()
    for j in sam2:
      sam.append(j)
    ln.append(sam)

line_H = list(itertools.product([0,1],repeat = H))
line_W = list(itertools.product([0,1],repeat = W))
counter = 0
total = 0
for h in line_H:
    for w in line_W:
        
        counter = 0
        for i,k in enumerate(h):
            for j,l in enumerate(w):
                
                if ln[i][j] == '
                    counter +=1
                
        if counter == K:
            total += 1
print(total)

Solution (Python):
h,w,k = map(int,input().split())
a = []
for i in range(h):
	temp = []
	t = input()
	for j in range(w):
		if t[j] == ".": temp.append(0)
		else: temp.append(1)
	a.append(temp)

h_max = pow(2,h)
w_max = pow(2,w)
ans = 0
for i in range(h_max):
	h_str = str(bin(i)[2:])
	if len(h_str) < h: h_str = "0"*(h-len(h_str)) + h_str
	for j in range(w_max):
		w_str = str(bin(j)[2:])
		if len(w_str) < w: w_str = "0"*(w-len(w_str)) + w_str
		s = 0
		for m in range(h):
			for n in range(w):
				if h_str[m] == "0" and w_str[n] == "0":
					if a[m][n]: s += 1
		if s == k: ans += 1
		
print(ans)

Solution (Python):
def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

H, W, K = MI()
C = []

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

ans = 0    

for h in range(1 << H):
    for w in range(1 << W):
        sharp = 0
        for i in range(H):
            if (h >> i) & 1:
                continue
            for j in range(W):
                if (w >> j) & 1:
                    continue
                sharp += int(C[i][j] == "
        
        if sharp == K:
            ans += 1

print(ans)

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


res = 0
for ih in range(1<<h):
    for iw in range(1<<w):

        h_use = [False] * h 
        w_use = [False] * w 
        for jh in range(h):
            if(ih & (1 << jh) != 0): h_use[jh] = True
        
        for jw in range(w):
            if(iw & (1 << jw) != 0): w_use[jw] = True

        cnt = 0
        for i in range(h):
            for j in range(w):
                
                if(h_use[i] or w_use[j]): continue
                if(c[i][j] == '.'): continue
                
                cnt += 1
        
        if(cnt == k): res += 1

print(res)

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

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

print(ans)

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

res = 0
for use_h in product([0, 1], repeat=h):
    for use_w in product([0, 1], repeat=w):
        
        cnt = 0
        for i in range(h):
            for j in range(w):
                
                

                if(use_h[i] == 0 and use_w[j] == 0 and c[i][j] == '
        
        if(cnt == k): res += 1

print(res)

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

origin = [list(input()) for _ in range(H)]
ans = 0
for i in range(2**H):
    for j in range(2**W):
        cnt = 0
        for h_shift in range(H):
            for w_shift in range(W):
                if i >> h_shift & 1 == 1 or j >> w_shift & 1: 
                    continue
                if origin[h_shift][w_shift] == "
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):
import numpy as np
H,W,K = map(int,input().split())
ll = []
for h in range(H):
    l = []
    for s in input():
        if s == ".":
            l.append(0)
        else:
            l.append(1)
    ll.append(l)
cnt = 0
for bh in range(2 ** H):
    for bw in range(2 ** W):
        nn = np.asarray(ll)
        k = 0
        for h in range(H):
            if (bh & 2 ** h) >> h == 0:
                continue
            nn[h] = np.array([0] * W)
        for w in range(W):
            if (bw & 2 ** w) >> w == 0:
                continue
            nn[:,w] = np.array([0] * H)
        for h in range(H):
            for w in range(W):
                k += nn[h][w]
        if k == K:
            cnt += 1
print(cnt)

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):
        count = 0
        for m in range(h):
            for n in range(w):
                if (i >> m) & 1 == 0 and (j >> n) & 1 == 0 and C[m][n] == '
                    count += 1
                else:
                    continue
        if count == k:
            ans += 1

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    H, W, K = map(int, readline().split())
    grid = []
    for _ in range(H):
        grid.append(list(readline().rstrip().decode()))
    
    ans = 0
    for i in range(1<<H):
        for j in range(1<<W):
            cnt = 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] == '
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

ans = 0
def main():
    H, W, K = map(int, readline().split())
    grid = []
    for _ in range(H):
        grid.append(list(input()))

    
    
    bitr = [0 for _ in range(H)]
    bitc = [0 for _ in range(W)]
    
    def dfsr(i): 
        if i == H:
            dfsc(0)
            return
        dfsr(i+1)
        bitr[i] = 1
        dfsr(i+1)        
        bitr[i] = 0
    
    def dfsc(i):
        global ans
        cnt = 0
        if i == W:
            
            for j in range(H):
                
                if bitr[j] == 1: 
                    continue
                for k in range(W):
                    
                    if bitc[k] == 1:
                        continue
                    
                    if grid[j][k] == '
                        cnt += 1
            if cnt == K:
                ans += 1
            return
        dfsc(i+1) 
        bitc[i] = 1
        dfsc(i+1)
        bitc[i] = 0
    
    dfsr(0)
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import itertools
import copy
deta = [0,1]

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

c = [list(input()) for _ in range(h)]



h1 = list(itertools.product(deta, repeat=h))
w1 = list(itertools.product(deta, repeat=w))

count = 0

for i in h1:
    for j in w1:
        c1 = copy.deepcopy(c)
        for k in range(h):
            if i[k] == 1:
                for l in range(w):
                    c1[k][l] = '.'
        for l in range(w):
            if j[l] == 1:
                for k in range(h):
                    c1[k][l] = '.'
        

        temp = 0
        for k in range(h):
            for l in range(w):
                if c1[k][l] == "
                    temp += 1
        if temp == k1:
            count += 1

print(count)

Solution (Python):
h, w, x = map(int, input().split())
matrix = []
total = 0
row = []
col = [0] * w
for _ in range(h):
  c = input()
  cnt = 0
  for i in range(w):
    if c[i] == '
      cnt += 1
      col[i] += 1
  total += cnt
  row.append(cnt)
  matrix.append(c)

ans = 0
for k in range(2**h):
  for l in range(2**w):
    state = total
    r_lst = []
    c_lst = []
    for i in range(h):
      if k & (1 << i) == 2**i:
        state -= row[i]
        r_lst.append(i)
    for j in range(w):
      if l & (1 << j) == 2**j:
        state -= col[j]
        c_lst.append(j)
    for p in r_lst:
      for q in c_lst:
        if matrix[p][q] == '
          state += 1
    if state == x:
      ans += 1
print(ans)

Solution (Python):
h,w,k = map(int,input().split())
c = []
for i in range(h):
    c.append(tuple(input()))
res = 0
for maskh in range(1<<h):
    for maskw in range(1<<w):
        brack = 0
        for i in range(h):
            for j in range(w):
                if (maskh >> i) & 1 and (maskw >> j) & 1:
                    if c[i][j] == '
        if brack == k:
            res += 1
print(res)

Solution (Python):
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
hbit, wbit = 1 << H, 1 << W
cnt = 0
for i in range(hbit):
  for j in range(wbit):
    ccnt = 0
    for k in range(H):
      for l in range(W):
        if not (((i>>k)&1) + ((j>>l)&1)):
          ccnt += (S[k][l] == '
    cnt += (ccnt == K)
print(cnt)

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())
c_ij = [list(map(str, input().split())) for i in range(h)]
ans = 0
for x in range(2 ** h):
    for y in range(2 ** w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if x >> i & 1 == 0 or y >> j & 1 == 0 : continue
                if c_ij[i][0][j] == "
        if cnt == k: ans += 1
print(ans)

Solution (Python):
import copy


def main():
    height, width, leave_black = [int(x) for x in input().split()]
    table = [list(input()) for _ in range(height)]
    ans = 0
    for num_h in range(2 ** height):
        for num_w in range(2 ** width):
            tmp = copy.deepcopy(table)
            for bit_h in range(height):
                if num_h >> bit_h & 1:
                    tmp[bit_h] = ['r'] * width
            for bit_w in range(width):
                if num_w >> bit_w & 1:
                    for row in tmp:
                        row[bit_w] = 'r'
            
            if sum(c == '
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    height, width, leave_black = [int(x) for x in input().split()]
    table = [input() for _ in range(height)]

    def bit_patterns(height, width):
        for num_h in range(2 ** height):
            for num_w in range(2 ** width):
                yield num_h, num_w

    def count_black(height, width, num_h, num_w):
        for bit_h in range(height):
            for bit_w in range(width):
                if num_h >> bit_h & 1 or num_w >> bit_w & 1:
                    continue
                yield table[bit_h][bit_w] == '

    def black_matched(height, width):
        for ii, jj in bit_patterns(height, width):
            yield sum(count_black(height, width, ii, jj)) == leave_black

    print(sum(black_matched(height, width)))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    height, width, leave_black = [int(x) for x in input().split()]
    table = [input() for _ in range(height)]

    def bit_patterns(height, width):
        for num_h in range(2 ** height):
            for num_w in range(2 ** width):
                yield num_h, num_w

    def count_black(height, width, num_h, num_w):
        for bit_h in range(height):
            for bit_w in range(width):
                if num_h >> bit_h & 1 or num_w >> bit_w & 1:
                    continue
                yield table[bit_h][bit_w] == '

    def black_matched(height, width):
        for ii, jj in bit_patterns(height, width):
            yield sum(count_black(height, width, ii, jj)) == leave_black

    print(sum(black_matched(height, width)))


if __name__ == '__main__':
    main()

Solution (Python):
h,w,x = 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):
        black = 0
        for k in range(h):
            for l in range(w):
                if ((i >> k) & 1) == 0 and ((j >> l) & 1) == 0 and c[k][l] == "
                    black += 1
        if black == x:
            ans += 1

print(ans)

Solution (Python):

def main():
    height, width, leave_black = [int(x) for x in input().split()]
    table = [input() for _ in range(height)]

    ans = 0
    for num_h in range(2 ** height):
        for num_w in range(2 ** width):
            black_count = 0
            for bit_h in range(height):
                for bit_w in range(width):
                    if num_h >> bit_h & 1 or num_w >> bit_w & 1:
                        continue
                    black_count += table[bit_h][bit_w] == '
            ans += black_count == leave_black

    print(ans)


if __name__ == '__main__':
    main()

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

ans = 0
for j in range(2**H):
    for k in range(2**W):
        count = 0
        for l in range(H):
            for m in range(W):
                if j >> l & 1 == 0 and k >> m & 1 == 0:
                    if listc[l][m] == "
                        count += 1
        if count == 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: 
         if board[i][j]=='
           cnt+=1
   if cnt==k: 
     ans+=1
print(ans)

Solution (Python):
H,W,K=list(map(int,input().split()))
board = [list(input()) for i 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 sys
import time
import math
st = time.perf_counter()
def inpl():
    return list(map(int, input().split()))


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

ans = 0
for h in range(2**H):
	for w in range(2**W):
		kuro = 0
		for i in range(H):
			if (2 ** i) & h == 0: continue
			for j in range(W):
				if (2 ** j) & w == 0: continue
				if c[i][j] == '
					kuro += 1
		if kuro == K:
			ans += 1

print(ans)



ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7



def paint(i, j, copied):

    for I in range(h):
        if((i>>I)&1):
            for J in range(w):
                copied[I][J] = "$"

    for J in range(w):
        if((j>>J)&1):
            for I in range(h):
                copied[I][J] = "$"

def check(grid1):
    toret = 0
    for i in range(h):
        for j in range(w):
            if(grid1[i][j]=='
                toret+=1
    return (toret==k)

h,w,k = MAP()

grid = []

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


ans = 0

for row in range(1<<h):
    for col in range(1<<w):
        copied = [x[:] for x in grid]
        paint(row, col, copied)

        ans+=check(copied)
        
print(ans)

Solution (Python):
h, w, k = map(int,input().split())
grid = [[] for x in range(h)]
for i in range(h):
    grid[i] = input()
cnt = 0
for i in range(1<<h):
    for j in range(1<<w):
        black = 0
        for p in range(h):
            for q in range(w):
                if 1&(i>>p) == 0 and 1&(j>>q) == 0 and grid[p][q] == '
                    black += 1
        if black == k:
            cnt += 1
print(cnt)

Solution (Python):
H = 0
W = 0
K = 0
m = []
 
try:
  line = input().split(' ')
  H = int(line[0])
  W = int(line[1])
  K = int(line[2])
  for i in range(H):
      m.append(input())      
except:
  pass

nPatterns = 0
for h in range(1 << H):
    for w in range(1 << W):
        nBlacks = 0
        for h2 in range(H) :
            for w2 in range(W):
                if (h & (1 << h2)) == 0 and (w & (1 << w2)) == 0:
                    if m[h2][w2] == '
                        nBlacks += 1
        if nBlacks == K:
            nPatterns += 1
            
print(nPatterns)