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

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


for i in range(H):
    tm=input()
    for j in range(W):
        S[i][j]=tm[j]



anscount=0

for i in range(2 **(H+W)):
    tmp=copy.deepcopy(S)
    for j in range(H+W):
        if ((i >> j) & 1):
            
            if j<H:
                for k in range(W):
                    tmp[j][k]="."
            else:
                for k in range(H):
                    tmp[k][j-H]="."
    tmpcount=0
    
    for k in range(H):
        for l in range(W):
            if tmp[k][l]=="
                tmpcount+=1
    if tmpcount==K:
        anscount+=1
        
print(anscount)

Solution (Python):
import copy
H,W,K = map(int,input().split())
c = [list(str(input())) for _ in range(H)]
ans = 0
count = 0
for i in range(H):
  count += c[i].count("
for h in range(2**H):
  PH = bin(h)[2:].zfill(H)
  for w in range(2**W):
    PW = bin(w)[2:].zfill(W)
    
    count1 = copy.copy(count)
    check = [[0 for _ in range(W)]for _ in range(H)]
    for i in range(H):
      for j in range(W):
        if PH[i] == "1" or PW[j] == "1":
          if c[i][j] == "
            count1 -= 1
            check[i][j] = 1
    if count1 == K:
      ans += 1
print(ans)

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

tate=[]
yoko=[]
for i in range(1<<h):
  t=[]
  for j in range(h):
    if i&(1<<j):
      t.append(1)
    else:
      t.append(0)
  tate.append(t)
for i in range(1<<w):
  t=[]
  for j in range(w):
    if i&(1<<j):
      t.append(1)
    else:
      t.append(0)
  yoko.append(t)
ans=0


for i in range(len(tate)):
  for j in range(len(yoko)):
    tt=[]
    tt=deepcopy(c)
    t_cnt=0
    t_tate=tate[i]
    t_yoko=yoko[j]
    
    
    for a in range(len(t_tate)):
      if t_tate[a]==1:
        for b in range(w):
          tt[a][b]="@"
    for a in range(len(t_yoko)):
      if t_yoko[a]==1:
        for b in range(h):
          tt[b][a]="@"
    for a in range(h):
      for b in range(w):
        if tt[a][b]=="
          t_cnt+=1
    
    if t_cnt==k:
      ans+=1
print(ans)

Solution (Python):
h,w,k=map(int,input('').split(' '))
c=[]
for a in range(h):
    q=[]
    s=input('')
    for a in s:
        q.append(a)
    c.append(q)

bith=[]
bitw=[]
for a in range(h):
    bith.append(0)

for b in range(w):
    bitw.append(0)

p=0
while(1):
    s=0
    for a in range(h):
        if bith[a]==0:
            for b in range(w):
                if bitw[b]==0:
                    if c[a][b]=='
                        s=s+1

    if s==k:
        p=p+1

    bith[0]+=1
    for a in range(h-1):
        if bith[a]==2:
            bith[a]=0
            bith[a+1]+=1

    if bith[h-1]==2:
        bith[h-1]=0
        bitw[0]+=1

    for b in range(w-1):
        if bitw[b]==2:
            bitw[b]=0
            bitw[b+1]+=1
    if bitw[w-1]>=2:
        break

print(p)

Solution (Python):
from itertools import chain, combinations
import copy

def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
def del_list_indexes(l, id_to_del):
    somelist = [i for j, i in enumerate(l) if j not in id_to_del]
    return somelist
def splitw(word): 
    return [char for char in word] 
def countBlacks(rows,paintRows,paintCols):
  c = copy.deepcopy(rows)
  t = 0
  
  c = del_list_indexes(c,paintRows)
  for i in paintCols:
    for ii in c:
      ii[i] = 'r'
  
  for i in c:
    for ii in i:
      if ii == "
        t +=1

  return t

i = input().split(" ")
h,w,k = int(i[0]),int(i[1]),int(i[2])

rows = []
for i in range(h):
    ii = input()
    rows.append(splitw(ii))
    
    
rowChoices = []
for i in range(h):
  rowChoices.append(str(i)+'row')
colChoices = []
for i in range(w):
  colChoices.append(str(i)+'col')

l = powerset(rowChoices+colChoices)

correct = 0
for i in l:
  paintRows = []
  paintCols = []
  for paint in i:
    if 'row' in paint:
      paintRows.append(int(paint[0]))
    if 'col' in paint:
      paintCols.append(int(paint[0]))
      
  numBlack = countBlacks(rows,paintRows,paintCols)
  if numBlack == k:
    correct += 1
print(correct)

Solution (Python):
import copy
H,W,K = map(int,input().split())
c=[] 
while True:
    try:
        c.append(list(map(str,input())))

    except:
        break;
ans=0
patterns=[]
for i in range(2**(H+W)):
  tmp = [False] * (H+W)
  for j in range(H+W):
    if i >> j & 1:
      tmp[j] = True
  patterns.append(tmp)
  
for pattern in patterns:
  c_tmp=copy.deepcopy(c)
  counter=0
  
  
  for tf in pattern:
    if tf==True:
      if counter<H:
        for i in range(W):
          c_tmp[counter][i]="R"
      if counter>=H:
        
        for i in range(H):
          c_tmp[i][counter-H]="R"     
    counter+=1
  
      
  num=0
  for row in c_tmp:
    num+=row.count("
  
  
  if num==K:
    ans+=1
    
print(ans)

Solution (Python):
n,m,k=map(int,input().split())
ll=[]
tot=0
for i in range(n):
    s=input().split()[0]
    tot+=s.count('
    ll.append(s)
x=2**n
y=2**m

cou=0

for i in range(x):
    bx=bin(i)[2:]
    bx='0'*(n-len(bx))+bx
    row=[]
    for ii in range(n):
        if(bx[ii]=='0'):
            row.append(ii)
    for j in range(y):
        column=[]
        by=bin(j)[2:]
        by='0'*(m-len(by))+by
        for jj in range(m):
            if(by[jj]=='0'):
                column.append(jj)
        su=0
        
        for ii in row:
            for jj in range(m):
                if(ll[ii][jj]=='
                    su+=1
        
        for jj in column:
            for ii in range(n):
                if(ll[ii][jj]=='
                    su+=1
        
        
        for ii in row:
            for jj in column:
                if(ll[ii][jj]=='
                    su-=1
        
        if(tot-su==k):
            
            cou+=1
print(cou)

Solution (Python):
H, W, K=map(int, input().split())
s=[]
gyob=[0]*H
retub=[0]*W
for _ in range(H):
  c=input()
  gyob[_]=list(c).count("
  for j in range(W):
    if c[j]=="
      retub[j]+=1
  s.append(c)
bs=sum(gyob)

gyo=[]
for i in range(1, 2**H):
  l=[]
  for j in range(H):
    if (i>>j)&1:
      l.append(j)
  gyo.append(l)
retu=[]
for i in range(1, 2**W):
  l=[]
  for j in range(W):
    if (i>>j)&1:
      l.append(j)
  retu.append(l)
ans=0
for g in gyo:
  blc=0
  for i in g:
    blc+=gyob[i]
  if bs-blc==K:
    ans+=1
  elif bs-blc<K:
    continue
  for r in retu:
    tmp=0
    for j in r:
      tmp+=retub[j]
      for i in g:
        if s[i][j]=="
            tmp-=1
    if bs-(blc+tmp)==K:
      ans+=1
for r in retu:
  blc=0
  for j in r:
    blc+=retub[j]
  if bs-blc==K:
    ans+=1

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

Solution (Python):



def solve():
    H, W, K = map(int, input().split())
    C = [[] for _ in range(H)]
    for i in range(H):
        tmp = input()
        C[i] = list(tmp)
    
    
    ans = 0
    for i in range(2 ** (H + W)):
        cnt = 0
        h_i = []
        w_i = []
        for j in range(H + W):
            if (i >> j) & 1:
                if j < H:
                    h_i.append(j)
                else:
                    w_i.append(j - H)
        for k in range(H):
            for l in range(W):
                if k not in h_i and l not in w_i and C[k][l] == '
                    cnt += 1

        if cnt == K:
            ans += 1

    print(ans)


if __name__ == "__main__":
    solve()

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

h_list = []
w_list = []

for n in range(0, h+1):
    for conb in itertools.combinations(range(0, h), n):
        h_list.append(list(conb))
for n in range(0, w+1):
    for conb in itertools.combinations(range(0, w), n):
        w_list.append(list(conb))

ans = 0
for hh in h_list:
    for ww in w_list:
        cnt = 0
        for i in range(h):
            if i in hh:
                continue
            for j in range(w):
                if j in ww:
                    continue
                if s[i][j] == '
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
h,w,k=map(int,input().split())
c=[input() for l in range(h)]
gyou=[0]*h
s=0
ans=0
for i in range(h):
    for j in range(w):
        if c[i][j]=="
            gyou[i]+=1
            s+=1 
retu=[0]*w
for i in range(w):
    for j in range(h):
        if c[j][i]=="
            retu[i]+=1
for i in range(2**(h+w)):
    S=s
    a=[0]*(h+w)
    for j in range(h+w):
        if i>=2**(h+w-j-1):
            i-=2**(h+w-j-1)
            a[j]=1
    for i in range(h):
        if a[i]==1:
            S-=gyou[i]
    for i in range(w):
        if a[h+i]==1:
            S-=retu[i]
    for i in range(h):
        for j in range(w):
            if a[i]==1 and a[h+j]==1 and c[i][j]=="
                S+=1
    if S==k:
        ans+=1
print(ans)

Solution (Python):
import itertools

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


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


def makeRededList(c, h_list, w_list):
    new_c = []
    for i in range(H):
        new_c.append([])
        if i in h_list:
            new_c[i] = ["."] * W
        else:
            for j in range(W):
                if (j in w_list):
                    new_c[i].append(".")
                else:
                    new_c[i].append(c[i][j])
    return new_c


c = []


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

ans_count = 0

a = []
for i in range(H):
    a.append(f"h{i}")
for i in range(W):
    a.append(f"w{i}")


for i in range(W+H):
    for v in itertools.combinations(a, i):
        h_list = []
        w_list = []
        for string in v:
            if string[0] == "h":
                h_list.append(int(string[1]))
            else:
                w_list.append(int(string[1]))
        if countBlack(makeRededList(c, h_list, w_list)) == K:
            ans_count += 1

print(ans_count)

Solution (Python):
import itertools
import copy
def bitsuuretu(n):
    tmp = []
    for i in range(2**n):
        ls = [0] * n
        for j in range(len(ls)):
            if (i >> j) & 1:
                ls[j] += 1
        tmp.append(ls)
    
    return tmp

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

Carray = [input() for _ in range(H)]

CintArray = []
for cs in Carray:
    tmp = []
    for c in cs:
        if(c == "."):
            tmp.append(0)
        else:
            tmp.append(1)
        
    CintArray.append(tmp)

forHbitArray = bitsuuretu(H)
forWbitArray = bitsuuretu(W)



ans = 0
for Hs in forHbitArray:
    for Ws in forWbitArray:


        CarrayChecker = copy.deepcopy(CintArray)
        for Hindex, Hhoge in enumerate(Hs):
            for Windex, Whoge in enumerate(Ws):


                if(Hhoge == 1 or Whoge == 1):
                    CarrayChecker[Hindex][Windex] = 0
        

        

        sumCintArray = 0
        for Cints in CarrayChecker:
            sumCintArray += sum(Cints)

        if(sumCintArray == K):
            ans += 1

print(ans)

Solution (Python):
import copy

h, w, x = map(int, input().split())
c = []
for i in range(h):
    c.append(list(input()))

ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        cc = copy.deepcopy(c)
        for k in range(h):
            for l in range(w):
                if ((i >> k) & 1):
                    for m in range(w):
                        cc[k][m] = "1"
                if ((j >> l) & 1):
                    for n in range(h):
                        cc[n][l] = "1"
        cnt = 0
        for o in range(h):
            for p in range(w):
                if cc[o][p] == "
                    cnt += 1
        if cnt == x:
            ans += 1

print(ans)

Solution (Python):

import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"
import copy







r , c , k = map(int , input().split())
arr = [list(input()) for i in range(r)]
ans = 0
row = [i for i in range(r)]
col = [i for i in range(c)]
ans = 0
for ii in range(r+1):
	for i in combinations(row,ii):
		for jj in range(c+1):
			for j in combinations(col,jj):
				t = 0
				for r1 in range(r):
					for c1 in range(c):
						if r1 in i or c1 in j:continue
						if arr[r1][c1] == "
				if t == k: ans+=1
print(ans)

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

ans = 0
for i in range(2 ** h):
    a = deepcopy(c)
    for b in range(h):
        if i >> b & 1:
            a[b] = 'r' * w
    for j in range(2 ** w):
        e = deepcopy(a)
        for l in range(w):
            if j >> l & 1:
                for m in range(h):
                    aa = e[m]
                    e[m] = aa[:l] + 'r' + aa[l + 1:]
        cnt = 0
        aaa = ''.join(e)            
        for d in range(h * w):
            if aaa[d] == '
                cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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





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):
import numpy as np


def zero_padding(x, num):
    return "0" * (num - len(x)) + x


def main():
    h, w, k = map(int, input().split())
    c = [None] * h
    for i in range(h):
        c[i] = list(map(lambda x: 1 if x == "
    c_origin = np.array(c)
    ret = 0
    for i in range(2 ** h):
        for j in range(2 ** w):
            tmp = c_origin.copy()
            a = [_i for _i, x in enumerate(list(zero_padding(f"{i:b}", h))) if x == "1"]
            if a != []:
                tmp[a] = 0
            b = [_j for _j, x in enumerate(list(zero_padding(f"{j:b}", w))) if x == "1"]
            if b != []:
                tmp[:, b] = 0
            if np.sum(tmp) == k:
                ret += 1
    print(ret)


if __name__ == "__main__":
    main()

Solution (Python):
import itertools

h,w,k = map(int,input().split())
c = []
for i in range(h):
    wks = input()
    kk = [ 0 if e == '.' else 1 for e in wks ]
    c.append(kk)

ans = 0

for elc in itertools.product([0,1],repeat=h):
    for elr  in itertools.product([0,1],repeat=w):
        kk = 0
        for i in range(h):
            for j in range(w):
                kk += c[i][j] * elc[i] * elr[j]
        if kk == k :
            ans += 1

print(ans)

Solution (Python):
import copy
H,W,K=map(int,input().split())
CC=[0]*H
for i in range(H):
    CC[i]=list(input())

count=0
shar=0
kurokuro=0
for i in range(H):
    kurokuro=CC[i].count('



ans=0
for i in range(2**(H+W)):
    kuro=kurokuro
    c=copy.deepcopy(CC)

    for j in range(H+W):
        if((i>>j) & 1):
            if(j<H):
                for q in range(W):
                    if(c[j][q]=='
                        shar=shar+1
                        c[j][q]='.'
                kuro=kuro-shar

                shar=0
            else:
                for q in range(H):
                    if(c[q][j-H]=='
                        shar=shar+1
                        c[q][j-H]='.'

                kuro=kuro-shar
                shar=0

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

Solution (Python):
H, W, K = map(int, input().split())
M = []
for h in range(H):
    col = []
    s = input()
    for w in range(W):
        if s[w] == '.':
            col.append('.')
        else:
            col.append('
    M.append(col)
    

result = 0
for i in range(2 ** (H + W)):
    bag = []
    for j in range(H  + W): 
        if ((i >> j) & 1):  
            bag.append(j)  
    
    
    
    
    hight_list =[]
    width_list = []
    for b in bag:
        if b < H:
            hight_list.append(b)
        else:
            width_list.append(b - H)
    
    count = 0
    for r_h in hight_list:
        for r_w in width_list:
            if M[r_h][r_w] == '
                count+=1
    
    if count == K:
        result+=1
        
print(result)

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

c = []
for _ in range(H):
    letters = input()
    my_row = [1 if letter == '
    c.append(my_row)
    
import itertools
count = 0
for h in range(H + 1):
    for delete_rows in itertools.combinations(range(H), h):
        new_c = c
        new_c = [[0] * W if idx in delete_rows else row for idx, row in enumerate(c)]
        
        for w in range(W + 1):
            for delete_cols in itertools.combinations(range(W), w):
                new_new_c = [[0 if idx in delete_cols else score for idx, score in enumerate(row)] for row in new_c]
                
                
                if sum(sum(new_new_c[i]) for i in range(H)) == K:
                    count += 1
print(count)

Solution (Python):
import copy
h, w, k = map(int, input().split())
cp_c = []
ans = 0
for i in range(h):
    cp_c.append(list(input()))
for i in range(2**h):
    ti = format(i, '06b')
    ti = ti[6-h:]
    for j in range(2**w):
        tj = format(j, '06b')
        tj = tj[6-w:]
        c = copy.deepcopy(cp_c)
        for m in range(h):
            for l in range(w):
                if ti[m] == "1" or tj[l] == "1":
                    c[m][l] = '1'
        cnt = 0
        for s in range(h):
            for t in range(w):
                if c[s][t] == '
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

col_black = [0] * H
row_black = [0] * W
num_black = 0
for i in range(H):
    for j in range(W):
        if C[i][j]=='
            col_black[i] += 1
            row_black[j] += 1
            num_black += 1

ans = 0
for i in range(2**H):
    I = []
    num_i_black = 0
    for ii in range(H):
        if i>>ii & 1:
            I.append(ii)
            num_i_black += col_black[ii]
    for j in range(2**W):
        J = []
        num_j_black = 0
        for jj in range(W):
            if j>>jj & 1:
                J.append(jj)
                num_j_black += row_black[jj]
        
        num = num_i_black + num_j_black
        for ii in I:
            for jj in J:
                num -= C[ii][jj] == '
        
        if num_black - num == K:
            ans += 1

print(ans)

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline
import copy




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

d = []
for i in range(h):
    s = input()
    d.append(list(s[:-1]))


c_h = 2**h
c_w = 2**w
ans = 0
ans_d = defaultdict(int)


for i in range(c_h):
    d_ = copy.deepcopy(d)
    for _h in range(h):
        if i >> _h & 1:
            for _ in range(w):
                d_[_h][_] = 0

    for j in range(c_w):
        d2_ = copy.deepcopy(d_)
        for _w in range(w):
            if j >> _w & 1:
                for _ in range(h):
                    d2_[_][_w] = 0

        val = 0
        for s1 in range(h):
            for s2 in range(w):
                if d2_[s1][s2] == '
                    val += 1
        if val == k:
            ans += 1
        
        del d2_

print(ans)

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

Solution (Python):
h,w,k=map(int,input().split())
x=[]
for i in range(h):
    l=input()
    l2=[]
    for o in range(len(l)):
        l2.append(l[o])
    x.append(l2)
n=2**(h+w)
ans=0
for i in range(n):
    q=i
    num=[0]*(h+w)
    p=0
    while q>0:
        if q%2!=0:
            num[p]=1
        q=q//2
        p+=1
    cnt=0
    for tat in range(h):
        if num[tat]==0:
            for yok in range(w):
                if num[yok+h]==0  and  x[tat][yok]=="
                        cnt+=1
    if cnt==k:
        ans+=1
print(ans)

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

R = 0
for i in range(2**H):
    iis = [0]*H
    tmp = 0
    while i:
        if i%2:
            iis[tmp] = 1
        i = i//2
        tmp += 1
    for j in range(2**W):
        jjs = [0]*W
        tmp = 0
        while j:
            if j%2:
                jjs[tmp] = 1
            j = j//2
            tmp += 1
        co = 0
        for u in range(H):
            for v in range(W):
                if iis[u] or jjs[v]:
                    continue
                if X[u][v] == "
                    co += 1
        if co == K:
            R += 1

print(R)

Solution (Python):
import numpy as np
import itertools
H, W, K = [int(x) for x in input().split(" ")]

a = np.zeros((H, W), dtype=bool)
for i in range(H):
    a[i, [x == "

c = [[True, False]] * (H + W)
count = 0
for i in itertools.product(*c):
    h = i[:H]
    w = i[H:]
    ap = np.copy(a)
    ap[h, :] = False
    ap[:, w] = False
    if ap.sum() == K:
        count += 1
print(count)

Solution (Python):
def kuro(x,y,c):
    dcr=0
    for cc in c:
        if cc[0] in x:
            dcr+=1
        if cc[1] in y:
            dcr+=1   
    for i in x:
        for j in y:
            if [i,j] in c:
                dcr-=1
    return dcr

def nshinsu(x,h):
    lis=[]
    xx=x
    for i in range(h-1,-1,-1):
        if xx >= 2**i:
            lis.append(i)
            xx=xx-(2**i)
    return lis
h,w,k= map(int,input().split())
c =[]
black=0
ans=0
for i in range(h):
    l= input()
    for j in range(w):
        if l[j]=="
            c.append([i,j])
            black+=1
for i in range(2**h):
    for j in range(2**w):
        x =nshinsu(i,h)
        y =nshinsu(j,w)
        d =kuro(x,y,c)
        if d== black-k:
            ans+=1
        
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
c = []
for k in range(H):
    c.append(input())
"""
total = 0
for k in range(H):
    for j in range(W):
        if c[k][j] == '
            total +=1
"""
ans =0
for w in range(2**W):
    binw = str(bin(w))[2:]
    binw = "0"*(W-len(binw)) + binw
    for h in range(2**H):
        binh = str(bin(h))[2:]
        binh = "0"*(H-len(binh)) + binh 
        count = 0
        for k in range(H):
            for j in range(W):
                if binw[j] == '0' and binh[k] == '0':
                    if c[k][j] == '
                        count+=1
        if count == K:
            
            ans +=1
print(ans)

Solution (Python):
H,W,K = [int(i) for i in input().split()]
grid = [list(input()) for i in range(H)]
B = sum([i.count("
c = 0
for i in range(2**(H)):
    for j in range(2**(W)):
        gt = [[j for j in i] for i in grid]
        a,b = bin(i)[2:], bin(j)[2:]
        while len(a) < H:
            a = "0" + a
        while len(b) < W:
            b = "0" + b
        for x in range(H):
            if a[x] == "1":
                gt[x] = ["."]*W
        for y in range(W):
            for x in range(H):
                if b[y] == "1":
                    gt[x][y] = "."
        
        if sum([x.count("
            c += 1
        
        
        
        
        
        
        
        
        
        
        
        
        
print(c)

Solution (Python):
import copy

def main():
    H,W,K = map(int,input().split())
    c = []
    for h in range(H):
        c.append(list(map(str,input())))
    
    ans = 0
    for hh in range(2**H):
        for ww in range(2**W):
            C = copy.deepcopy(c)
            for h in range(H):
                if ((hh >> h)&1):
                    C[h] = ['R' for i in range(W)]
            for w in range(W):
                if ((ww >> w)&1):
                    for i in range(H):
                        C[i][w] = 'R'
            count = 0
            for i in range(H):
                for j in range(W):
                    if C[i][j] == '
                        count += 1
            if count == K:
                ans += 1
    
    print(ans)
    
if __name__ == '__main__':
    main()

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



ans=0
for i in range(2**h): 
    i_bin=format(i,'06b')
    for j in range(2**w): 
        j_bin=format(j,'06b')
        cnt=0
        
        for s in range(h):
            if i_bin[5-s]=='0':
                for t in range(w):
                    if j_bin[5-t]=='0' and c[s*w+t]=='
                        
                        cnt+=1
        if cnt==k:
            ans+=1
            
print(ans)

Solution (Python):

import itertools


def main(mtx, k):
    
    
    h_indices = []
    for i in range(len(mtx)):
        idx = [k for k in range(len(mtx))]
        h_indices += list(itertools.combinations(idx, i))

    w_indices = []
    for i in range(len(mtx[0])):
        idx = [k for k in range(len(mtx[0]))]
        w_indices += list(itertools.combinations(idx, i))

    cnt = 0
    for his in h_indices:
        for wis in w_indices:

            c = count(mtx, his, wis)
            
            if k == c:
                cnt += 1

    print(cnt)

def count(mtx, his, wis):
    
    c = 0
    for h in range(len(mtx)):
        if h in his: continue

        for w in range(len(mtx[h])):
            if w in wis: continue
            if mtx[h][w] == '
                c += 1

    return c


if __name__ == '__main__':
    h, w, k = [int(i) for i in input().split()]
    mtx = []
    for _ in range(h):
        mtx.append(list(input()))
    main(mtx, k)

Solution (Python):
import copy
H, W, K = map(int,input().split())
ls = [list(input()) for i in range(H)]
ans = 0
for i in range(2**H):
  for j in range(2**W):
    A = copy.deepcopy(ls)
    B = 0
    for a in range(H):
      if (i >> a) & 1 == 1:
        for b in range(W):
          A[a][b] = "$"
    for c in range(W):
      if (j >> c) & 1 == 1:
        for d in range(H):
          A[d][c] = "$"
    for k in range(H):
      for l in range(W):
        if A[k][l] == "
          B += 1
    if B == K:
      ans += 1
print(ans)

Solution (Python):
import numpy as np

h, w, k = map(int, input().split())
painted = []
for i in range(h):
    painted.append(list(input()))
ans = 0
for i in range(2**(h+w)):
    painted_dum = np.array(painted)
    for j in range(h):
        if ((i >> j) & 1):
            painted_dum[j, :] = '*'
    for l in range(w):
        if ((i >> (h + l)) & 1):
            painted_dum[:, l] = '*'
    cnt_dum = np.count_nonzero(painted_dum == '
    if cnt_dum == k:
        ans += 1
print(ans)

Solution (Python):
import numpy as np
import itertools
comb = itertools.combinations

H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]
C = [[1 if C[k][j] == '
C = np.array(C)
harray = np.arange(H)
warray = np.arange(W)

Corig = C.copy()

ans = 0
for h in range(H+1):
  for w in range(W+1):
    
    Hc = list(comb(harray, h))
    Wc = list(comb(warray, w))
    for hc in Hc:
      for wc in Wc:
        C = Corig.copy()
        for hcc in hc:
            C[hcc,:] = 0
        for wcc in wc:
          C[:,wcc] = 0
        
        
        
        if np.sum(C) == K:
          ans += 1
print(ans)

Solution (Python):
def count_black(matrix, mask_rows=[], mask_cols=[]):
  num_black = 0
  for i, row in enumerate(matrix):
    if i in mask_rows:
      continue
    for j, col in enumerate(row):
      if j in mask_cols:
        continue
      if col == "
        num_black += 1
  return num_black

def get_patterns(linenum):
  results = []
  patterns = 2**linenum
  for i in range(patterns):
    cmb = []
    if i & 1 == 1:
      cmb.append(0)
    if i & 2 == 2:
      cmb.append(1)
    if i & 4 == 4:
      cmb.append(2)
    if i & 8 == 8:
      cmb.append(3)
    if i & 16 == 16:
      cmb.append(4)
    if i & 32 == 32:
      cmb.append(5)
    results.append(cmb)
  return results

rows, cols, K = [int(x) for x in input().split(" ")]
matrix = []
for row in range(rows):
  matrix.append([x for x in input()])

row_ptrns = get_patterns(rows)
col_ptrns = get_patterns(cols)
result = 0
for row_ptrn in row_ptrns:
  for col_ptrn in col_ptrns:
    if count_black(matrix, row_ptrn, col_ptrn) == K:
      result += 1
print(result)

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

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

ans = 0
for row in product(['.', '%'], repeat=H):
    if row == tuple(['%']*H):
        continue
    tmp1 = deepcopy(board)
    for h in range(H):
        if row[h] == '%':
            tmp1[h] = ['%']*W
    for col in product(['.', '%'], repeat=W):
        if col == tuple(['%']*W):
            continue
        tmp2 = deepcopy(tmp1)
        for w in range(W):
            if col[w] == '%':
                for h in range(H):
                    tmp2[h][w] = '%'
        if sum(tmp2, []).count('
            ans += 1
print(ans)