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())
listA = []
for o in range(0,H):
        listA.append(list(input()))
answer = 0
for a in range(0,2):
    for b in range(0,2):
        for c in range(0,2):
            for d in range(0,2):
                for e in range(0,2):
                    for f in range(0,2):
                        for g in range(0,2):
                            for h in range(0,2):
                                for i in range(0,2):
                                    for j in range(0,2):
                                        for k in range(0,2):
                                            for l in range(0,2):
                                                for m in range(0,1):
                                                    for n in range(0,1):
                                                        count = 0
                                                        try:
                                                            if a == 0 and g == 0 and listA[0][0] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if a == 0 and h == 0 and listA[0][1] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if a == 0 and i == 0 and listA[0][2] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if a == 0 and j == 0 and listA[0][3] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if a == 0 and k == 0 and listA[0][4] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if a == 0 and l == 0 and listA[0][5] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if b == 0 and g == 0 and listA[1][0] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if b == 0 and h == 0 and listA[1][1] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if b == 0 and i == 0 and listA[1][2] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if b == 0 and j == 0 and listA[1][3] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if b == 0 and k == 0 and listA[1][4] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if b == 0 and l == 0 and listA[1][5] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if c == 0 and g == 0 and listA[2][0] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if c == 0 and h == 0 and listA[2][1] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if c == 0 and i == 0 and listA[2][2] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if c == 0 and j == 0 and listA[2][3] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if c == 0 and k == 0 and listA[2][4] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if c == 0 and l == 0 and listA[2][5] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if d == 0 and g == 0 and listA[3][0] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if d == 0 and h == 0 and listA[3][1] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if d == 0 and i == 0 and listA[3][2] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if d == 0 and j == 0 and listA[3][3] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if d == 0 and k == 0 and listA[3][4] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if d == 0 and l == 0 and listA[3][5] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if e == 0 and g == 0 and listA[4][0] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if e == 0 and h == 0 and listA[4][1] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if e == 0 and i == 0 and listA[4][2] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if e == 0 and j == 0 and listA[4][3] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if e == 0 and k == 0 and listA[4][4] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if e == 0 and l == 0 and listA[4][5] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if f == 0 and g == 0 and listA[5][0] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if f == 0 and h == 0 and listA[5][1] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if f == 0 and i == 0 and listA[5][2] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if f == 0 and j == 0 and listA[5][3] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if f == 0 and k == 0 and listA[5][4] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        try:
                                                            if f == 0 and l == 0 and listA[5][5] == '
                                                                count = count + 1
                                                        except:
                                                            count = count
                                                        if count == K:
                                                            answer = answer + 1
place = 0.25
for i in range(0,7 - H):
    place = place * 2
for i in range(0,7 - W):
    place = place * 2
print(int(answer / place))

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

d = 0
kk = 0
g= []
gb=[]
for i in range(2 ** h):
    gg=[]
    for j in range(h):
        if ((i>>j) &1):
            gg.append(j)
    g.append(gg)
for i in range(2 ** w):
    gg=[]
    for j in range(w):
        if ((i>>j) &1):
            gg.append(j)
    gb.append(gg)

for lis in g:
    ii = lis
    for lisj in gb:
        jj = lisj
        for i in range(h):
            if i in ii:
                continue
            for j in range(w):
                if j in jj:
                    continue
                if c[i][j]=='
                    kk+=1

        if kk==k:
            d+=1
        kk = 0
print(d)

Solution (Python):
h, w, k = map(int, input().split())
mp = []
wh = 0
bk = 0
cnt = 0
for i in range(h):
    mp.append(list(input()))
    for j in range(w):
        if mp[i][j] == ".":
            wh += 1
        else :
            bk += 1
for i in range(2 ** h):
    wkH = []
    for n in range(h):
        if ((i>>n) & 1):
            wkH.append(n)
    for j in range(2 ** w):
        wkW = []
        wkBk = bk
        for m in range(w):
            if ((j>>m) & 1):
                wkW.append(m)
        for o in range(len(wkH)):
            for p in range(w):
                if mp[wkH[o]][p] == "
                    wkBk -= 1
        for o in range(len(wkW)):
            for p in range(h):
                if p in(wkH):
                    continue
                if mp[p][wkW[o]] == "
                    wkBk -= 1
        if wkBk == k:
            cnt += 1
print(cnt)

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

mp = [input() for i in range(h)]

mp_h = []
for i in range(h):
    cnt = 0
    for j in range(w):
        if(mp[i][j]=="
            cnt+=1
    mp_h.append(cnt)

mp_w=[]
for i in range(w):
    cnt = 0
    for j in range(h):
        if(mp[j][i]=="
            cnt+=1
    mp_w.append(cnt)

sum_all = sum(mp_w)

sub_sum = sum_all - k
if(sub_sum < 0):
    print(0)
    exit()


from itertools import combinations

lw = range(w)
lh = range(h)
l_w = [[x for x in combinations(lw,i)] for i in range(0,w+1)]   
l_h = [[x for x in combinations(lh,i)] for i in range(0,h+1)]

def check(t_w,t_h):
    
    t_sum = 0
    cnt = 0
    for x in t_w:
        t_sum += mp_w[x]
    for y in t_h:
        t_sum += mp_h[y]
    
    for x in t_w:
        for y in t_h:
            if(mp[y][x]=="
                cnt += 1
    t_sum -= cnt
    
    if((sum_all-t_sum)==k):
        return True
    return False


ans = 0
for i in range(w+1):
    if(i==0):
        target_w = []
    else:
        target_w = l_w[i-1]
    for j in range(h+1):
        if(j==0):
            target_h = []
        else:
            target_h = l_h[j-1]
        for t_w in target_w:
            for t_h in target_h:
                if(check(t_w,t_h)):
                    ans += 1
print(ans)

Solution (Python):
import itertools

h, w, k = list(map(int, input().split()))
s = []
a = []
h_index = []
w_index = []
for i in range(h):
    h_index.append(i)
for i in range(w):
    w_index.append(i)
for i in range(h):
    s.append(input())
    a.append([])
    for j in s[i]:
        if(j == '.'):
            a[i].append(0)
        else:
            a[i].append(1)

ans = 0
h_list = []
for i in range(h+1):
    h_list.extend(list(itertools.combinations(h_index, i)))

w_list = []
for i in range(w+1):
    w_list.extend(list(itertools.combinations(w_index, i)))

for selected_hs in h_list:
    for selected_ws in w_list:
        for i in selected_hs:
            a[i] = [0] * w
        for j in selected_ws:
            for i in range(h):
                a[i][j] = 0
        kuro = 0
        for a_sub in a:
            kuro += sum(a_sub)
        if(kuro == k):
            ans += 1
        for i in range(h):
            for j in range(w):
                if(s[i][j] == '.'):
                    a[i][j] = 0
                else:
                    a[i][j] = 1

print(ans)

Solution (Python):
def main():
    import numpy as np
    from builtins import int, map, list, print, len
    from itertools import combinations
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    H, W, K = input_number_list()
    field = []
    ans = 0
    yoko = [0] * H
    tate = [0] * W
    total = 0
    for i in range(H):
        line = input()
        field.append(list(line))
        black_count = line.count("
        yoko[i] = black_count
        total += black_count
        for j in range(W):
            if line[j] == "
                tate[j] += 1
    
    if total == K:
        ans += 1
    combi_h = []
    for i in range(1, H + 1):
        combi_h.extend(combinations(range(H), i))

    combi_w = []
    for i in range(1, W + 1):
        combi_w.extend(combinations(range(W), i))
    field = np.array(field)
    for c_h in combi_h:
        f_tmp = field.copy()
        for h in c_h:
            f_tmp[h] = "." * len(f_tmp[h])
        if np.count_nonzero(f_tmp == '
            ans += 1
        for c_w in combi_w:
            f_tmp2 = f_tmp.copy()
            for w in c_w:
                f_tmp2[:, w] = '.'
            if np.count_nonzero(f_tmp2 == '
                ans += 1
    for c_w in combi_w:
        f_tmp = field.copy()
        for w in c_w:
            f_tmp[:, w] = "." * len(f_tmp[:, w])
        if np.count_nonzero(f_tmp == '
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
  
import copy
from itertools import combinations
h, w, k = map(int, input().split())
c =[input() for i in range(h)]
ans = 0
y = []
for i in range(h):
    y.append(i)
x = []
for i in range(w):
    x.append(i)
for i in range(h+1):
    ty = list(combinations(y, i))
    for j in range(w+1):
        tx = list(combinations(x, j))
        for l in ty:
            for m in tx:
                cnt = 0
                for p in l:
                    for q in m:
                        if c[p][q] == '
                            cnt += 1
                if cnt == k:
                    ans += 1
print(ans)

Solution (Python):
import itertools
import copy

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

c = ['a'] * H
cnt = 0

for i in range(H):
    c[i] = input()
    cnt += c[i].count('



cnt = cnt - K
ans = 0
comH = list(range(H))
comW = list(range(W))



for n in range(len(comH)+1):
    for combiH in itertools.combinations(comH, n):
        
        LcomH = list(combiH)
        tmpc = copy.deepcopy(c)
        Hchange = 0
        for i in LcomH:
            Hchange += tmpc[i].count('
            tmpc[i] = tmpc[i].replace('
        for m in range(len(comW)+1):
            for combiW in itertools.combinations(comW, m):
                
                LcomW = list(combiW)
                Wchange = 0
                for j in LcomW:
                    for gyo in range(H):
                        if tmpc[gyo][j] == '
                            Wchange += 1
                
                
                if Hchange + Wchange == cnt:
                    ans += 1

print(ans)

Solution (Python):
import copy
h,w,k2=map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0

for i in range(2**h):
    for j in range(2**w):
        d = copy.deepcopy(c)
        for k in range(h):
            if i%(2**(k+1))//(2**k)==1:
                for j2 in range(w):
                    d[k][j2]='r'
        for l in range(w):
            if j%(2**(l+1))//(2**l)==1:
                for i2 in range(h):
                    d[i2][l]='r'
        black = 0
        for i3 in range(h):
            for j3 in range(w):
                if d[i3][j3]=='
                    black +=1
        if black == k2:
            ans+=1
print(ans)

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





h = len(c)
hl = []
for i in range(2 ** h):
 bit_set = []
 for j in range(h):
   if ((i >> j) & 1):
     bit_set.append(j)

 hl.append(bit_set)

wl = []
for i in range(2 ** W):
 bit_set = []
 for j in range(W):
   if ((i >> j) & 1):
     bit_set.append(j)
 wl.append(bit_set)


ans = 0
for w in wl:
  wll = []
  for ww in w:
    wll.append(ww)

  for h in hl:
    count = 0
    for i, cc in enumerate(c):
      if not i in h:
        for k, ccc in enumerate(cc):
          if not k in wll:
            if ccc == '
              count += 1

    if count == K:
      ans += 1


print(ans)

Solution (Python):
from collections import defaultdict
import itertools
import copy

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

def p(arr):
	for i in arr:
		for j in i:
			print(j, end="")
		print()

def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans

def dyeh(arr,b):
	for i in range(len(b)):
		if b[i]==1:
			for j in range(w):
				arr[i][j]="."
	return arr

def dyew(arr,b):
	for i in range(len(b)):
		if b[i]==1:
			for j in range(h):
				arr[j][i]="."

def count(arr):
	ans = 0
	for i in arr:
		for j in i:
			if j=="
				ans+=1
	return ans

h,w,k = readInts()
c = [list(input()) for i in range(h)]
ans = 0
for i in bitArr(h):
	d = copy.deepcopy(c)
	dyeh(d,i)

	for j in bitArr(w):
		e = copy.deepcopy(d)
		dyew(e,j)
		if count(e)==k:
			ans+=1

print(ans)

Solution (Python):


import numpy as np
H, W, K = list(map(int, input().split()))

org = np.zeros((H, W), dtype=np.uint8)

'''
.: shiro -> 0

'''

for h in range(H):
    l = list(input())
    l = [0 if val == '.' else 1 for val in l]

    org[h, :] = l



j_list = [[None]]
for j_b in range(2 ** H): 

    tmp_l = []
    for j_l in range(H):
        j = (j_b >> j_l) & 1  
        if j == 1:
            tmp_l.append(j_l)

    if len(tmp_l) > 0:
        j_list.append(tmp_l)
        

i_list = [[None]]
for i_b in range(2 ** W): 

    tmp_l = []
    for i_l in range(W):
        i = (i_b >> i_l) & 1  
        if i == 1:
            tmp_l.append(i_l)

    if len(tmp_l) > 0:
        i_list.append(tmp_l)
        
     
cnt = 0
for j_s in j_list:
    for i_s in i_list:
        dst_array = org.copy()

        for j in j_s:
            if j is not None:
                dst_array[j, :] = 0

        for i in i_s:
            if i is not None:
                dst_array[:, i] = 0

       
        sumval = np.sum(dst_array)

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

Solution (Python):
import numpy as np
import itertools

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

cells = []
for _ in range(h):
  cells.append(list(input()))
cells = np.asarray(cells)

n_choice = 0
for n_target_rows in range(h + 1):
  target_rows = list(itertools.combinations(range(h), n_target_rows))
  
  for n_target_clms in range(w + 1):
    target_clms = list(itertools.combinations(range(w), n_target_clms))
    
    for rows in target_rows:
      row_converted_cells = cells.copy()
      row_converted_cells[rows, :] = 'r' * w
      
      for clms in target_clms:
        clm_converted_cells = row_converted_cells.copy()
        clm_converted_cells[:, clms] = 'r'
        n_black = np.count_nonzero(clm_converted_cells == '
        
        if n_black == k:
          n_choice += 1
                    
print(n_choice)

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

for i in range(1<<W):
    D = [0]*37
    D[0] = 1

    for c in C:
        cnt = 0
        for b in range(6):
            if (i & (1<<b)) and c[b] == '
               cnt += 1

        for j in range(36-cnt, -1, -1):
            D[j+cnt] += D[j]

    ANS += D[K]

print(ANS)

Solution (Python):
import numpy as np
def main():
  h,w,k = map(int, input().split())
  c = []
  for i in range(h):
    c.append(list(input()))
  c = np.array(c)=='
  
  count = 0
  for i in range(2**(h+w)):
    tmp = np.array(list(bin(4096+i)))=='1'
    row = tmp[(h+w)*-1:w*-1]
    col = tmp[w*-1:]
    if c[np.ix_(row,col)].sum()==k:
      count += 1
  print(count)
main()

Solution (Python):
from sys import stdin
import sys
import math
import random
from decimal import Decimal
import itertools as it


H, W, K = [int(x) for x in stdin.readline().rstrip().split()]

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


a = [[(0,)]]
a2 = [[(0,)]]
b = []
b2 = []
for i in range(1, H+1):
    b.append(i)
for i in range(1, H):
    a.append(list(it.combinations(b, i)))
for i in range(1, W+1):
    b2.append(i)
for i in range(1, W):
    a2.append(list(it.combinations(b2, i)))

b.append(0)
b2.append(0)
ans = 0
ans1 = 0
for iw, vw in enumerate(a2):
    for kw in range(len(vw)):
        for ih, vh in enumerate(a):
            for kh in range(len(vh)):
                vw[kw] = list(vw[kw])
                vh[kh] = list(vh[kh])
                ans = 0
                for iww in range(1, W+1):
                    if iww not in vw[kw]:
                        for ihh in range(1, H+1):
                            if ihh not in vh[kh]:
                                if c[ihh-1][iww-1] == '
                                    ans += 1
                
                if ans == K:
                    ans1 += 1
print(ans1)

Solution (Python):

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

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

case_list = []

for i in range(2 ** (H + W)):
    case_list.append(format(i, "

ans = 0
for i in range(2 ** (H + W)):

    counter = 0
    for j in range(H):
        for k in range(W):
            if case_list[i][j] == "0" and case_list[i][H + k] == "0" and c_list[j][k] == "
                counter += 1
    if counter == K:
        ans += 1

print(ans)