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

M = [0]*h
for i in range(h):
  r = list(input())
  r = [0 if j == '.' else 1 for j in r ]
  M[i] = r
  

total = sum([sum(r) for r in M])

import copy
ans = 0
for i in range(2**h):
  for j in range(2**w):
    del_cnt = 0
    MC = copy.deepcopy(M)
    for x in range(h):
      if i>>x&1:
        for y in range(w):
          if MC[x][y]==1:
            MC[x][y] = 0
            del_cnt += 1
    for x in range(w):
      if j>>x&1:
        for y in range(h):
          if MC[y][x] == 1:
            MC[y][x] = 0
            del_cnt += 1
    if del_cnt == total - k:
      ans += 1
  
print(ans)

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

ans=0
for row in range(2**h):
    for col in range(2**w):
        cnt=0
        for i in range(h):
            for j in range(w):
                if (row>>i)&1 and (col>>j)&1 and matrix[i][j]=="
                    cnt+=1
        if cnt==k:
            ans+=1
            
print(ans)

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

for i in range(2 ** h):
    l = []
    for j in range(h):
        if ((i >> j) & 1):
            l.append(ma[j])

    for p in range(2 ** w):
        cnt = 0
        for q in range(w):
            if ((p >> q) & 1):
                for g in l:
                    if g[q] == "
                        cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Solution (Python):
def check(C, H, W, hp, wp):
    count = 0
    for hi in range(H):
        for wi in range(W):
            if (C[hi][wi] == '
                count += 1
    return count

def main():
    H, W, K = map(int, input().split())
    C = [list(input()) for _ in range(H)]
    ans = 0
    for hp in range(2**H):
        for wp in range(2**W):
            if check(C, H, W, hp, wp) == K:
                ans += 1
    print(ans)

main()

Solution (Python):
H,W,K = map(int,input().split())
B=[[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j,c in enumerate(input()):
        if c == "
            B[i][j] = 1

def getCnt(r,c):
    cnt = 0
    for i in r:
        for j in c:
            if B[i][j] == 1:
                cnt += 1
    return cnt

ans = 0
for y in range(2**H):
    r = []
    for i in range(H):
        if (y>>i) % 2 == 1:
            r.append(i)
    for x in range(2**W):
        c = []
        for j in range(W):
            if (x >> j) % 2 == 1:
                c.append(j)
        if getCnt(r,c) == K:
            ans += 1

print(ans)

Solution (Python):
from itertools import product, compress


def main():
    h, w, k = list(map(int, input().split()))
    c = [None for _ in range(h)]
    for i in range(h):
        c[i] = input()
    ans = 0
    for columns in product([1, 0], repeat=w):
        columns = list(compress(list(range(w)), columns))
        for rows in product([1, 0], repeat=h):
            count = 0
            rows = list(compress(list(range(h)), rows))
            
            for row in rows:
                for column in columns:
                    if c[row][column] == "
                        count += 1
            if count == k:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import itertools
H,W,K=map(int,input().split())
c=[input() for _ in range(H)]
ans=0
for i in list(itertools.product([0,1], repeat=H+W)):
  a=0
  for j in range(H):
    if i[j]==1:
      continue
    for k in range(W):
      if i[H+k]==1:
        continue
      if c[j][k]=='
        a+=1
  if a==K:
    ans+=1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]
cH = [sum([1 for x in c[i] if x == '
cW = [sum([1 for j in range(H) if c[j][i] == '
B, ans = sum(cH), 0

for num in range(2**(W+H)):
    indexes = [(num >> i) % 2 for i in range(W+H)]
    indexesH = []
    temp = B
    for i in range(H):
        if indexes[i] == 1:
            temp -= cH[i]
            indexesH.append(i)
    for i in range(W):
        if indexes[H+i] == 1:
            temp -= cW[i] - sum([int(c[j][i] == '
    if temp == K:
        ans += 1
print(ans)

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

blk = 0
ans = 0

for i in range(h):
    for j in range(w):
        if c[i][j] == '
            blk += 1

for i in range(2**(h+w)):
    tmp_blk = blk
    tmp = format(i, '0'+str(h+w)+'b')
    for j in range(h):
        if tmp[j] == '1':
            
            for k in range(w):
                if c[j][k] == "
                    tmp_blk -= 1
    for j in range(w):
        if tmp[h+j] == '1':
            for k in range(h):
                if c[k][j] == "
                    tmp_blk -= 1
    if tmp_blk == K:
        ans += 1
    
        
print(ans)

Solution (Python):





import sys
import heapq

def main():
    h, w, K = map(int, input().split())
    table = []
    for _ in range(h):
        temp = input()
        table.append([])
        for i in temp:
            table[-1].append(i)    
    ans = 0
    for i in range(2 ** (w + h)):
        cnt = 0
        tempTable = [_[:] for _ in table]

        rowNum = i % (2 ** h)
        colNum = i // (2 ** h)
        cntRow = 0
        cntCol = 0

        while rowNum:
            if rowNum % 2:
                tempTable[cntRow] = ["R"] * w
            rowNum = rowNum // 2
            cntRow += 1
        while colNum:
            if colNum % 2:
                for j in range(h):
                    tempTable[j][cntCol] = "R"
            colNum = colNum // 2
            cntCol += 1
        for j in range(h):
            for k in range(w):
                if tempTable[j][k] == "
                    cnt += 1
        
        if cnt == K:
            ans += 1

    print(ans)


    return

if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
h,w,k = map(int,input().split())
s = 0
a = [[0]*(w+1)]
for i in range(h):
  ar = input().rstrip()
  for i in ar:
    if i == '
      s += 1
  a.append([0]+list(ar))
  
ans = 0
for i in range(2**(h+1)):
  for j in range(2**(w+1)):
    chk = s
    for num,ai in enumerate(a):
      if i>>num&1:
        for aa in ai:
          if aa == '
            chk -= 1
      else:
        for bb in range(w+1):
          if j>>bb&1 and ai[bb] == '
            chk -= 1
    if chk == k:
      ans += 1
print(ans//4)

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

import itertools
for conh in itertools.product([True,False], repeat = h):
    for conw in itertools.product([True,False], repeat = w):
        count = 0
        for i in range(h):
            for j in range(w):
                if conh[i] or conw[j]:
                    continue
                else:
                    if arr[i][j] == "
                        count += 1
        if count == k:
            ans += 1

print(ans)

Solution (Python):
import itertools
h,w,k = map(int,input().split())
s = ["" for _ in range(h)]
for i in range(h):
  si = str(input())
  s[i] = si
lh = [i for i in range(h)]
lw = [j for j in range(w)]
sh = [0 for _ in range(h)]
sw = [0 for _ in range(w)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "
      sh[i] += 1
      sw[j] += 1  
g = sum(sh) - k
c = 0
for i in range(h+1):
  for vh in itertools.combinations(lh,i):
    for j in range(w+1):
      for vw in itertools.combinations(lw,j):
        t = 0
        for hx in vh:
          t += sh[hx] 
        for hy in vw:
          t += sw[hy]
        for hx in vh:
          for hy in vw:
            if s[hx][hy] == "
              t -= 1
        if t == g:
          c += 1
print(c)

Solution (Python):
import copy
import itertools

h, w, k = map(int,input().split())
li = [list(input()) for i in range(h)]
ans = 0



for i in range(2**h):
    for j in range(2**w):
        x = copy.deepcopy(li)
        count = 0

        for b in range(h):
            if ((i >> b) & 1): 
                x[b] = ["-"] * w
        for b in range(w):
            if ((j >> b) & 1): 
                for a in range(h):
                    x[a][b] = "-"
        
        x = list(itertools.chain.from_iterable(x))
        if x.count("
            ans += 1


print(ans)

Solution (Python):
H,W,K = map(int,input().split())
c = [[0] * W for i in range(H)]
p = 0
ans = 0
for i in range(H):
    a = str(input())
    for j in range(W):
        if a[j] == ".":
            c[i][j] = 0
        else:
            c[i][j] = 1
            p += 1
aa = [0]*(H + W)
for i in range(2**(H + W)):
    pp = p
    for j in range(H + W):
        aa[j] = i%2
        i = i//2
    for k in range(H):
        for l in range(W):
            if c[k][l] == 1:
                if aa[k] == 1 or aa[H + l] == 1:
                    pp -= 1
    if pp == K:
        ans += 1
print(ans)

Solution (Python):



from math import *
from copy import *					
from heapq import *					
from string import *				
from random import *				
from bisect import *				
from sys import stdin				
from sys import maxsize				
from operator import *				
from itertools import *				
from decimal import Decimal 		
from collections import Counter		
from collections import defaultdict 

'''
2 3 2
..

'''

def solve(L,H,W,K):
	R,C = [],[]
	rows = [i for i in range(H)]
	cols = [i for i in range(W)]
	for r in range(H+1):
		R.append(list(combinations(rows,r)))
	for c in range(W+1):
		C.append(list(combinations(cols,c)))
	RR,CC = [],[]
	for i in R:
		for j in i:
			jj = list(j)
			RR.append(jj)
	for i in C:
		for j in i:
			jj = list(j)
			CC.append(jj)
	ans = 0
	blacks = 0
	for i in range(H):
		for j in range(W):
			if(L[i][j] == '
				blacks += 1
	for rc in RR:
		for cc in CC:
			curr = blacks
			for r in range(H):
				for c in range(W):
					if(r in rc or c in cc):
						if(L[r][c] == '
							curr -= 1
			if(curr == K):
				ans += 1
	return ans



H,W,K = list(map(int, stdin.readline().rstrip().split()))
L = []
for i in range(H):
	L.append(list(input()))
ans = solve(L,H,W,K)
print(ans)

Solution (Python):
import copy
H, W, K = list(map(int, input().split()))
c = []
for _ in range(H):
    s = input()
    tmp = []
    for one in s:
        if one=='
            tmp.append(1)
        else:
            tmp.append(0)
    c.append(tmp)


h = 1<<H
w = 1<<W
cnt = 0
for j in range(h):
    tmp_c = copy.deepcopy(c)
    for p in range(H):
        if j>>p & 1==1:
            tmp_c[p] = [0]*W
    
    for i in range(w):
        tm_c = copy.deepcopy(tmp_c)
        for q in range(W):
            if i>>q & 1==1:
                for k in range(H):
                    tm_c[k][q] = 0
        if sum([sum(one) for one in tm_c])==K:
            cnt+=1
print(cnt)

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

ans = 0

def foo(x,y):
  sx = set()
  i = 0
  while x > 0:
    if x % 2 == 1:
      sx.add(i)
    i += 1
    x //= 2
  sy = set()
  i = 0
  while y > 0:
    if y % 2 == 1:
      sy.add(i)
    i += 1
    y //= 2

  r = 0
  for i in range(H):
    for j in range(W):
      if b[i][j] == '
        if i not in sx and j not in sy:
          r += 1
  if r == K:
    return 1
  else:
    return 0

for i in range(2**H):
  for j in range(2**W):
    ans += foo(i,j)
print(ans)

Solution (Python):
from itertools import product
from copy import deepcopy

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

ans = 0

for a in product([0,1], repeat = H+W):
    ca = deepcopy(c)
    for i in range(H):
        if a[i] == 1:
            for j in range(W):
                ca[i][j] = 'r'
    for j in range(W):
        if a[H+j] == 1:
            for i in range(H):
                ca[i][j] = 'r'
    count = 0
    for i in range(H):
        for j in range(W):
            if ca[i][j] == '
             count += 1
    if count == K:
             ans += 1

print(ans)

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

n=h+w
ans=0
for i in range(2**n):
    a=copy.deepcopy(s)
    for j in range(n):
        if ((i >> j) & 1):
            if j<h:
                for l in range(w):
                    a[j][l]='.'
            else:
                for l in range(h):
                    a[l][j-h]='.'
    cnt=0
    for j in range(h):
        for l in range(w):
            if a[j][l]=='
                cnt+=1
    if cnt==k:
        ans+=1
print(ans)

Solution (Python):

from itertools import chain,combinations
from itertools import product
def powerset(iterable):
    "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

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

    rows = []
    for h in range(H):
        rows.append(input())
    
    row_choices = list(powerset(range(H)))
    col_choices = list(powerset(range(W)))

    ans = 0
    for r_set, c_set in product(row_choices, col_choices):
        selected_rows = [r for i, r in enumerate(rows) if i not in r_set]
        n_blacks = 0
        for r in selected_rows:
            n_blacks += len([c for j, c in enumerate(r) if j not in c_set and c == '
        
        if n_blacks == K:
            ans += 1

    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):
import copy
H,W,K = map(int,input().split())
C = []
for i in range(H):
  temp = str(input())
  temp = list(temp)
  C.append(temp)


def count(X):
  ret = 0
  for i in range(H):
    for j in range(W):
      if X[i][j] == "
        ret +=1
  return ret
ans = 0
for p in range(2**H):
  for q in range(2**W):
    D = copy.deepcopy(C)
    for i in range(H):
      if(p>>i)&1==1:
        D[i] = ["1" for _ in range(W)]
    for j in range(W):
      if(q>>j)&1==1:
        for t in range(H):
          D[t][j] = "1"
    
    if count(D) == K:
      ans += 1
print(ans)

Solution (Python):


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

h_l = [i for i in range(H)]
w_l = [i for i in range(W)]

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

print(ans)

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

ans = 0
for b1 in range(2 ** h):
  for b2 in range(2 ** w):
    CC = [c[:] for c in C]
    for i in range(h):
      if (b1 >> i) & 1:
        for ww in range(w):
          CC[i][ww] = "."
    for j in range(w):
      if (b2 >> j) & 1:
        for hh in range(h):
          CC[hh][j] = "."
    bl = 0
    for line in CC:
      bl += line.count("
    if bl == k:
      ans += 1
print(ans)

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

grid = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    s = input()
    for j in range(w):
        if s[j] == '.':
            grid[i][j] = 1

ans = 0

for i in range(2**h):
    draw_row = [0 for k in range(h)]
    c = i
    for k in range(h):
        if c % 2 == 1:
            draw_row[k] = 1
        c >>= 1
    for j in range(2**w):
        draw_col = [0 for k in range(w)]
        c = j
        for k in range(w):
            if c % 2 == 1:
                draw_col[k] = 1
            c >>= 1

        count = 0
        for row in range(h):
            for col in range(w):
                if draw_row[row] == 0 and draw_col[col] == 0 and grid[row][col] == 0:
                    count += 1
        if count == k_num:
            ans += 1

print(ans)

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

h,w,k=mp()
rh=[i for i in range(h)]
rw=[i for i in range(w)]
grid=[]
for i in range(h):
    grid.append(input())
lh=[]
lw=[]
for i in range(h):
    lh.extend(list(itertools.combinations(rh, i)))
for i in range(w):
    lw.extend(list(itertools.combinations(rw, i)))



ans=0

for x in lh:
    for y in lw:



        ch=[[0]*w for i in range(h)]
        for i in range(h):
            for j in range(w):
                if i in x or j in y:
                    ch[i][j]=1
        c=0
        for i in range(h):
            for j in range(w):
                if ch[i][j]==0 and grid[i][j]=="
                    c+=1


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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy



from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd

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

def main():
    h,w,k = map(int,input().split())
    c = [list(input()) for _ in range(h)]
    ans = 0
    for n1 in range(h+1):
        for e1 in combinations(range(h),n1):
            for n2 in range(w+1):
                for e2 in combinations(range(w),n2):
                    cc = copy.deepcopy(c)
                    for x in e1:
                        for j in range(w):
                            cc[x][j] = '.'
                    for x in e2:
                        for i in range(h):
                            cc[i][x] = '.'
                    cnt = 0
                    for i in range(h):
                        for j in range(w):
                            if cc[i][j] == '
                                cnt += 1
                    if cnt == k:
                        ans += 1
    print(ans)
    
if __name__ == "__main__":
    main()

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

c = []
n_black = 0
for i in range(H):
  c.append(input().strip())
  n_black += c[-1].count("


def rec_col(count, n):
  if n == len(c):
    yield count
  else:
    yield from rec_col(list(count), n+1)
    for i, color in enumerate(c[n]):
      if color == "
        count[i] += 1
    yield from rec_col(list(count), n+1)

def rec_row(result, count, n):
  if n == len(count):
    yield result
  else:
    yield from rec_row(result + count[n], count, n+1)
    yield from rec_row(result, count, n+1)

import collections
ans = collections.Counter()
for count in rec_col([0] * W, 0):
  ans.update(rec_row(0, count, 0))
print(ans[K])

Solution (Python):


import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union














from copy import copy, deepcopy              








from itertools import product, permutations  







def main():
    Num = Union[int, float]
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    
    
    
    h, w, k = mi()
    grid = [li() for _ in range(h)]
    ans = 0

    for h_pattern in product([True, False], repeat=h):
        for w_pattern in product([True, False], repeat=w):
            painted = deepcopy(grid)
            for i in range(h):
                if h_pattern[i]:
                    for j in range(w):
                        painted[i][j] = 'R'
            for j in range(w):
                if w_pattern[j]:
                    for i in range(h):
                        painted[i][j] = 'R'
            if sum([line.count('
                
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):



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


h,w,k = mp()
ans = 0
grid = []
for i in range(h):
    grid.append(list(input()))
h_pat = []
w_pat = []
for i in range(2**h):
    p = bin(i)[2:].zfill(h)
    h_pat.append(p)
for i in range(2**w):
    p = bin(i)[2:].zfill(w)
    w_pat.append(p)
import copy
for i in range(len(h_pat)):
    for j in range(len(w_pat)):
        tar_g = copy.deepcopy(grid)
        cnt = 0
        h_tar = h_pat[i]
        w_tar = w_pat[j]
        for v in range(len(h_tar)):
            if h_tar[v] == "1":
                tar_g[v] = ["R"]*w
        tar_g = [list(x) for x in zip(*tar_g)]
        for v in range(len(w_tar)):
            if w_tar[v] == "1":
                tar_g[v] = ["R"]*h
        for v in range(w):
            cnt += tar_g[v].count("
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
from itertools import combinations
h,w ,k = map(int, input().split())
grid = []
for i in range(h):
    grid.append(list(input()))
ans = 0
for row in range(2**h):
    for column in range(2**w):
        grid_a =[[True for i in range(w)] for j in range(h)]
        count = 0
        for p in range(h):
            if (row >> p) & 1:
                for i in range(w):
                    grid_a[p][i] = False
        for p in range(w):
            if (column >> p) & 1:
                for i in range(h):
                    grid_a[i][p] = False
        for i in range(h):
            for j in range(w):
                if grid_a[i][j] and grid[i][j] == '
                    count+=1
        if count == k:
            ans += 1
print(ans)

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

res = 0
for i in range(2**H):
    a = bin(i)[2:].zfill(H)
    for j in range(2**W):
        b = bin(j)[2:].zfill(W)

        c = 0

        for (p, x) in enumerate(X):
            for (q, y) in enumerate(x):
                if a[p] != '1' and b[q] != '1' and y == '
                    c += 1

        if c == K:
            res += 1

print(res)

Solution (Python):
lis = []
H, W, K = tuple(int(x) for x in input().strip().split())
for _ in range(H):
    lis.append(tuple(1 if x == '
lis = tuple(lis)

selectH = [False for _ in range(H)]
selectW = [False for _ in range(W)]
cnt = 0

def judge(h, w):
    ret = 0
    for i in range(H):
        if (h >> i) & 1:
            for j in range(W):
                if (w >> j) & 1:
                    ret += lis[i][j]
    return ret
            
if __name__ == '__main__':
    cnt = 0
    for h in range(1 << H):
        for w in range(1 << W):
            if judge(h, w) == K:
                cnt += 1
    print(cnt)

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

for i in range(2 ** (H + W)):
  now = 0
  hh = [0] * H
  ww = [0] * W
  for j in range(H):
    if ((i >> j) & 1):
      hh[j] = 1
  for k in range(W):
    if (i >> (k + H)) & 1:
      ww[k] = 1
   
  for j in range(H):
    for k in range(W):
      if (hh[j] == 1) and (ww[k] == 1):
        if HW[j][k] == "
          now += 1
  
  if now == K:
    ans += 1
    
print(ans)

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

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

black = 0
for i in range(h):
  s = input()
  for j in range(w):
    if s[j] == "
      c[i][j] = 1
      black += 1

ans = 0
for i in range(2 ** h):
  for j in range(2 ** w):
    _black = black
    for _i in range(h):
      for _j in range(w):
        if (i & (2 ** _i)) != 0 or (j & (2 ** _j)) != 0:
          _black -= c[_i][_j]
    if _black == k:
      ans += 1

print(ans)

Solution (Python):
import sys
from itertools import product, chain
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


def main():
    H, W, K = readnums()
    c = [readstr() for _ in range(H)]
    b = sum([x.count('

    ans = 0
    for p in product([0, 1], repeat=H):
        ch = [c[i] for i, a in enumerate(p) if a]
        for q in product([0, 1], repeat=W):
            tmp = []
            for i, qq in enumerate(q):
                tmp.append([chw[i] for chw in ch if qq])
            tmp = list(chain.from_iterable(tmp))
            if tmp.count('
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import itertools

H, W, K = input().split()
a = [list(input()) for l in range(int(H))]

h_l = [i for i in range(int(H))]
w_l = [i for i in range(int(W))]

re_h = []
re_w = []
for n in range(len(h_l)+1):
    for comb in itertools.combinations(h_l, n):
        re_h.append(list(comb))
for n in range(len(w_l)+1):
    for comb in itertools.combinations(w_l, n):
        re_w.append(list(comb))
sum_c = 0
for r_h in re_h:
    for r_w in re_w:
        nokori_h = list(set(h_l) - set(r_h))
        nokori_w = list(set(w_l) - set(r_w))
        count = 0
        for no_h in nokori_h:
            for no_w in nokori_w:
                if a[no_h][no_w] == "
                    count += 1
        if count == int(K):
            sum_c += 1
print(sum_c)

Solution (Python):
H,W,K= list(map(int,input().split()))
import copy
ans=0
l=[list(input()) for _ in range(H)]
for i in range(2**H):
   for j in range(2**W):
      tmp=copy.deepcopy(l)
      for k in range(H):
         if ((i >> k) & 1):
            tmp[k]=[0]*W
      for m in range(W):
         if ((j >> m) & 1):
            for x in range(H):
               tmp[x][m]=[0]
      tmp=sum(tmp,[])
      if tmp.count("
         ans+=1
print(ans)

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

ans = 0
for yb in range(2 ** h):
    for xb in range(2 ** w):
        n = 0
        for y in range(h):
            for x in range(w):
                if yb & (1 << y) != 0 and xb & (1 << x) != 0 and c[y][x] == '
                    n += 1
        if n == k:
            ans += 1
print(ans)

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

M = [input().strip() for _ in range(H)]


def count(m):
    res = 0
    for j in range(H):
        for i in range(W):
            if m[j][i] == "
                res += 1
    return res


ans = 0

for j in range(2 ** H):
    for i in range(2 ** W):
        tmp = []
        for m in range(len(M)):
            tmp.append(M[m])

        for m in range(6):
            if j >> m & 1 == 1:
                tmp[m] = "r" * W

        for m in range(6):
            if i >> m & 1 == 1:
                for h in range(H):
                    tmp[h] = tmp[h][0:m] + "r" + tmp[h][m+1:]
        if count(tmp) == K:
            ans += 1

print(ans)

Solution (Python):
H,W,K=map(int,input().split())
L=[]
for i in range(H):
    s=list(input())
    for j in range(W):
        if s[j]=="
            s[j]=1
        else:
            s[j]=0
    L.append(s)


import copy
ans=0
l=[0 for i in range(W)]
for h in range(2**H):
    A=copy.deepcopy(L)
    Y=h+0
    for y in range(H):
        if Y&1==0:
            A[y]=l
        Y=Y>>1
    
    
    for w in range(2**W):
        X=w+0
        cnt=0
        for x in range(W):
            if X&1==1:
                for z in range(H):
                    cnt+=A[z][x]
            X=X>>1
        
        if cnt==K:
            ans+=1
print(ans)

Solution (Python):
import copy

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



S = 0
for i in range(2 ** (H+W)):
    field = copy.deepcopy(c)
    bag = []
    for j in range(H+W):  
        if ((i >> j) & 1):  
            if j < W:
                for y in range(H):
                    field[y][j] = "."
            else:
                for x in range(W):
                    field[j-W][x] = "."
    
    
    Sum = 0
    for x in range(W):
        for y in range(H):
            if field[y][x] == "
                Sum += 1

    if Sum == K:
        S += 1

print(S)

Solution (Python):
import numpy as np
h,w,k = map(int,input().split())
c = np.zeros((h,w), dtype="int")
f = lambda x: 1 if x=="
for i in range(h):
    l=list(map(f,list(input())))
    c[i] = l

sum_=(c.sum())
cc=0
for i in range(2 ** h):
    l=[]
    for j in range(h):
        if ((i >> j) & 1): 
            l.append(j)
            
    for ii in range(2 ** w):
        ll=[]
        for jj in range(w):
            if ((ii >> jj) & 1): 
                ll.append(jj)
        if l and ll:
            ans = (c[l].sum()+c[:,ll].sum()-c[l][:,ll].sum())
        elif l and (not ll):
            ans = (c[l].sum())
        elif ll and (not l):
            ans = (c[:,ll].sum())
        else:
            ans = (0)
        
        if sum_-k == ans:
            cc+=1
print(cc)