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

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

sqr = [32, 16, 8, 4, 2, 1]

def bin_num(n):
    paint_num = []
    for i in range(6):
        if n > sqr[i]:
            paint_num.append(5-i)
            n -= sqr[i]
    return paint_num 

ans = 0
h_count = 2**h
w_count = 2**w
for i in range(h_count):
    h_ng = bin_num(i+1)
    for j in range(w_count):
        w_ng = bin_num(j+1)
        count = 0
        for m in range(h):
            for l in range(w):
                if (c[m][l] == '
                    count += 1
        if count == k:
            ans += 1
print(ans)

Solution (Python):
h,w,k=map(int,input().split())
s=[]
Sh=[0]*h
Sw=[0]*w
cnt=[]
Th=[]
Tw=[]
for i in range(h):
    s.append(input())

for i in range(h):
    cnt.append(s[i].count('

for i in range(w):
    c=0
    for j in range(h):
        if s[j][i]=='
            c+=1
    cnt.append(c)



def cheak(s,i,j):
    if s[i][j]=='
        return 1
    else:
        return 0

def rech(k):
    totalh=0
    if k==h:
        for i in range(h):
            if Sh[i]==1:
                totalh+=cnt[i]
        
        th=Sh.copy()
        Th.append(th)
        Th.append(totalh)
        return
    rech(k+1)
    Sh[k]=1
    rech(k+1)
    Sh[k]=0

def recw(k):
    totalw=0
    if k==w:
        for i in range(w):
            if Sw[i]==1:
                totalw+=cnt[h+i]
        
        tw=Sw.copy()
        Tw.append(tw)
        Tw.append(totalw)
        return
    recw(k+1)
    Sw[k]=1
    recw(k+1)
    Sw[k]=0

total=sum(cnt[0:h])
ans=0
'''
for i in range(h):
    for j in range(w):
        if total-(cnt[i]+cnt[h+j]-cheak(s,i,j))==k:
            ans+=1
'''
rech(0)
recw(0)



for i in range(2**h):
    for j in range(2**w):
        cheaktotal=0
        for p in range(h):
            for q in range(w):
                if Th[2*i][p]==1 and Tw[2*j][q]==1:
                    cheaktotal+=cheak(s,p,q)
        if total-Th[2*i+1]-Tw[2*j+1]+cheaktotal==k:
            ans+=1
print(ans)

Solution (Python):
import numpy as np
from itertools import combinations
h,w,k = map(int,input().split())
grid = [list(input()) for i in range(h)]
cnt = [[0 for _ in range(w)] for __ in range(h)]
ans = 0
for i in range(w):
    for j in range(h):
        if grid[j][i] == '
            cnt[j][i] = 1
cnt = np.array(cnt)

h_ = [i for i in range(h)]
w_ = [i for i in range(w)]
ans = 0
h_combo = []
w_combo = []
for i in range(1,h+1):
    for h_com in combinations(h_,i):
        h_combo.append(h_com)
for i in range(1,w+1):
    for w_com in combinations(w_,i):
        w_combo.append(w_com)

for i in h_combo:
    for j in w_combo:
        cnt2 =cnt.copy()
        for i2 in i:
            cnt2[i2,:] = 0
            for j2 in j:
                cnt2[:,j2] = 0
                
        if sum(sum(cnt2)) == k:
            ans += 1
            
for i in h_combo:
    cnt2 =cnt.copy()
    for i2 in i:
        cnt2[i2,:] = 0
    if sum(sum(cnt2)) == k:
            ans += 1
for j in w_combo:
    cnt2 =cnt.copy()
    for j2 in j:
        cnt2[:,j2] = 0
    if sum(sum(cnt2)) == k:
        ans += 1
        
if sum(sum(cnt)) == k:
    ans += 1

print(ans)

Solution (Python):
import numpy as np
import itertools
h,w,k=map(int,input().split())
g=np.ones((h,w))
l=['' for _ in range(h)]
for i in range(h):
  l[i]=str(input())
for i in range(h):
  for j in range(w):
    if l[i][j]=='.': g[i][j]=0
s=np.sum(g)
ans=0
for i in range(h):
  for j in range(w):
    u=list(itertools.combinations(range(h),i))
    v=list(itertools.combinations(range(w),j))
    for x in u:
      for y in v:
        a=0
        b=0
        c=0
        for p in x:
          a+=np.sum(g[p,:])
        for q in y:
          b+=np.sum(g[:,q])
        for p in x:
          for q in y:
            c+=g[p][q]
        if s-a-b+c==k: 
          ans+=1
print(ans)

Solution (Python):

from collections import Counter
import itertools
import copy
from itertools import product


def count_black(array):
    flatten = itertools.chain.from_iterable(array)
    c = Counter(flatten)
    return c['


def red_row(array, i):
    length = len(array[0])
    array[i] = ['r'] * length
    return array


def red_col(array, j):
    for row in array:
        row[j] = 'r'
    return array


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

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

total = 0

row_select_patterns = product([True, False], repeat=H)
col_select_patterns = list(product([True, False], repeat=W))

for row_select_pattern in row_select_patterns:
    for col_select_pattern in col_select_patterns:
        c = copy.deepcopy(C)

        for i, i_flag in enumerate(row_select_pattern):
            for j, j_flag in enumerate(col_select_pattern):
                if i_flag:
                    c = red_row(c, i)

                if j_flag:
                    c = red_col(c, j)

        if count_black(c) == K:
            total += 1

print(total)

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

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

Solution (Python):
import copy

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

c = []

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

count = 0
for i in range(2 ** len(c)):        
    tmp_c = [c[k] for k in range(len(c)) if ((i >> k) & 1)]
    for j in range(2 ** len(c[0])):
        tmp_tmp_c = copy.copy(tmp_c)
        for l in range(len(tmp_c)):
            tmp_tmp_c[l] = [tmp_c[l][k] for k in range(len(tmp_c[0])) if ((j >> k) & 1)]

        total_blacks = 0
        for i in range(len(tmp_tmp_c)):
            total_blacks += tmp_tmp_c[i].count('
        
        if total_blacks == K:
            count += 1

print(count)

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

Black=[]
for h in range(H):
    L_=list(input())
    for w in range(W):
        if L_[w]=='
            Black.append([h,w])

from itertools import product

ans=0

for h in product(range(2),repeat=H):
    for w in product(range(2),repeat=W):
        h_=[]
        for _ in range(H):
            if h[_]==1:
                h_.append(_)
        w_=[]
        for _ in range(W):
            if w[_]==1:
                w_.append(_)
                    
        Black_=[]
        
        if len(h_) == 0 and len(w_) == 0:
            pass
        elif len(w_) > 0 and len(h_) == 0:
            for W_ in w_:
                for black in Black:
                    if black[1] == W_:
                        if black not in Black_:
                            Black_.append(black)
        
        elif len(w_) == 0 and len(h_) > 0:
            for H_ in h_:
                for black in Black:
                    if black[0] == H_:
                        if black not in Black_:
                            Black_.append(black)            
        
        elif len(h_)>0 and len(w_)>0:
            for H_ in h_:
                for W_ in w_:
                    for black in Black:
                        if black[0] == H_ or black[1] == W_:
                            if black not in Black_:
                                Black_.append(black)
                    
        if len(Black)-len(Black_) == K:

            ans+=1
print(ans)

Solution (Python):


import copy

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

C = []

x_l = []
y_l = []


for y in range(H):
    tmp = list(str(input()))
    C.append(tmp)


for i in range(2 ** H):
    x_l.append(list(str(bin(i))[2:].zfill(H)))

for i in range(2 ** W):
    y_l.append(list(str(bin(i))[2:].zfill(W)))





tmp_k = 0
ans = 0
for x in x_l:
    for y in y_l:
        tmp_k = 0
        tmp_C = copy.deepcopy(C)
        
        for i in range(len(x)):
            if x[i] == '1':
                tmp_C[int(i)] = ['.'] * W
        
        for j in range(len(y)):
            if y[j] == '1':
                for k in range(len(x)):
                            tmp_C[k][int(j)] = '.'
        
        for tmp_tmp_C in tmp_C:
            tmp_k = tmp_k + tmp_tmp_C.count('
        
        if tmp_k == K:
            ans += 1


print(ans)

Solution (Python):
h,w,ka=map(int,input().split())
mat=[list(input()) for i in range(h)]
ans=0
for i  in range(2**(h+w)):
    b=bin(i)[2:].zfill(h+w)
    rs=b[:h]
    cs=b[h:]
    ct=0
    for l in range(h):
        for k in range(w):
            if mat[l][k]=='
                ct+=1
    if ct==ka: ans+=1
print(ans)

Solution (Python):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
H,W,K = LI()
c = [S() for _ in range(H)]
black = 0
for h in range(H):
    for w in range(W):
        if c[h][w]=='
            black += 1
ans = 0
for h in range(2**H):
    for w in range(2**W):
        copy_black = black
        bit_h = [h>>i&1 for i in range(H)]
        bit_w = [w>>i&1 for i in range(W)]
        for i,bit_i in enumerate(bit_h):
            for j in range(W):
                if bit_i==1:
                    if c[i][j]=='
                        copy_black -= 1
        for j,bit_j in enumerate(bit_w):
            for i in range(H):
                if bit_j==1:
                    if c[i][j]=='
                        copy_black -= 1
        for i,bit_i in enumerate(bit_h):
            for j,bit_j in enumerate(bit_w):
                if bit_i==bit_j==1:
                    if c[i][j]=='
                        copy_black += 1
        if copy_black==K:
            ans += 1
print(ans)

Solution (Python):
import copy

h = []
w = []

def countSharp(work):
    cnt = 0
    for row in work:
        for col in row:
            if col == '
                cnt += 1
    return cnt

def makeH(current, end):
  if len(current) == end:
    h.append(copy.copy(current))
    return
  else:
    current.append(True)
    makeH(current, end)
    current.pop(len(current) - 1)

    current.append(False)
    makeH(current, end)
    current.pop(len(current) - 1)

def makeW(current, end):
  if len(current) == end:
    w.append(copy.copy(current))
    return
  else:
    current.append(True)
    makeW(current, end)
    current.pop(len(current) - 1)

    current.append(False)
    makeW(current, end)
    current.pop(len(current) - 1)

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

makeH([], H)
makeW([], W)




matrix = []
for i in range(0, H):
    row = []
    for c in input():
        row.append(c)
    matrix.append(row)




answer = 0

for hh in h:
    for ww in w:
        work = []
        for h in range(0, H):
            work.append(copy.copy(matrix[h]))

        for i in range(0, H):
            for j in range(0, W):
                if hh[i] == True:
                    for jjj in range(0, W):
                        work[i][jjj] = 'r'
                if ww[j] == True:
                    for iii in range(0, H):
                        work[iii][j] = 'r'

        count = countSharp(work)
        if count == K:
            answer += 1

print(answer)

Solution (Python):
from collections import defaultdict
import itertools

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

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

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

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

if __name__ == '__main__':
    main()

Solution (Python):
import copy

h, w, k = map(int, input().split())
table = [0]*h
for i in range(h):
    table[i] = [0 if j == "." else 1 for j in input()]
ans = 0

for i in range(2 ** (h + w)):
    t = copy.deepcopy(table)
    for j in range(h + w):
        if ((i >> j) & 1):
            if j < h:
                for l in range(w):
                    t[j][l] = 0
            else:
                for l in range(h):
                    t[l][j-h] = 0
    black = sum(map(sum, t))
    if black == k:
        ans += 1

print(ans)

Solution (Python):

import math
import itertools
h, w, k = map(int, input().split())
c = []
cnt_ans = 0
for i in range(h):
    c.append(input())

y = itertools.product([0, 1], repeat=h)
x = itertools.product([0, 1], repeat=w)

y = [s for s in y]
x = [s for s in x]

for i in y:
    for j in x:
        cnt_kuro = 0
        for a in range(h):
            if i[a] == 0:
                continue
            for b in range(w):
                if j[b] == 0:
                    continue
                if c[a][b] == "
                    cnt_kuro += 1
        if cnt_kuro == k:
            cnt_ans += 1
print(cnt_ans)

Solution (Python):
h,w,k=map(int,input().split())
c=[]
for _ in range(h):
  c.append(list(input()))
ans=0
for i in range(2**h):
  for j in range(2**w):
    q=0
    for i_ in range(h):
      for j_ in range(w):
        if ((i>>i_)&1) and ((j>>j_)&1) and c[i_][j_]=='
          q+=1
    if q==k:
      ans+=1
print(ans)

Solution (Python):

import numpy as np

from itertools import combinations, product

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

ls = []

for h in range(H):
    ls.append(
        list(
            map(
                lambda x : 1 if x == "
                )
            )
        )

ls = np.array(ls)

all_sum = np.sum(ls)

cnt = 0

bool_ind_h = np.array([False for _ in range(H)])
bool_ind_w = np.array([False for _ in range(W)])
ls_tmp = ls.copy()

for h in range(H + 1):
    for w in range(W + 1):
        ls_tmp = ls.copy()
        comb_h = combinations(range(H), h)
        comb_w = combinations(range(W), w)
        for ch, cw in product(comb_h, comb_w):
            ls_tmp = ls.copy()
            ls_tmp[list(ch), :] = 0
            ls_tmp[:, list(cw)] = 0
            if np.sum(ls_tmp) == K:
                cnt += 1

print(cnt)

Solution (Python):
h, w, k = map(int, input().split())
c = []
w_count = []
h_count = [0 for _ in range(w)]
n = 0
for _ in range(h):
    tmp = list(input())
    for i in range(w):
        if tmp[i] == "
            h_count[i] += 1
    tc = tmp.count("
    n += tc
    w_count.append(tc)
    c.append(tmp)


ans = 0
for w_bin in range(2 ** w):
    for h_bin in range(2 ** h):
        w_bin_st = bin(w_bin)[2:].zfill(w)
        h_bin_st = bin(h_bin)[2:].zfill(h)
        
        num = 0
        i_list = []
        j_list = []
        for i, wb in enumerate(list(w_bin_st)):
            if wb == "1":
                i_list.append(i)
                num += h_count[i]
        for j, hb in enumerate(list(h_bin_st)):
            if hb == "1":
                j_list.append(j)
                num += w_count[j]
        if n-num <= k:
            for il in i_list:
                for jl in j_list:
                    if c[jl][il] == "
                        num -= 1
            if n-num == k:
                
                ans += 1

print(ans)

Solution (Python):
import itertools
h,w,k2=map(int,input().split())
temp=[]
htemp=[i for i in range(h+w)]

for i in range(h):
    temp.append(list(input()))

retsum=0
import copy
def check(temp3,htemplist2):
    temp2=copy.deepcopy(temp3)
    for k in range(len(htemplist2)):
        if htemplist2[k]<h:
            for l in range(w):
                temp2[htemplist2[k]][l]="."
        if htemplist2[k]>=h:
            for l in range(h):
                temp2[l][htemplist2[k]-h]="."
    tempsum=0
    for x in range(h):
        for y in range(w):
            if temp2[x][y]=="
                tempsum+=1
    if tempsum==k2:
        return 1
    else:
        return 0

tempsum2=0
for x in range(h):
    for y in range(w):
        if temp[x][y]=="
            tempsum2+=1
if tempsum2==k2:
    retsum+=1

for i in range(1,h+w):
    htemplist=list(itertools.combinations(htemp,i))
    for j in range(len(htemplist)):
        retsum+=check(temp,htemplist[j])



print(retsum)

Solution (Python):
import itertools
import copy
import numpy as np

def main():
    H, W, K  = map(int, input().split())
    if K == 0:
        print(1)
        exit()
    c = np.full((H, W), False)
    for h in range(H):
        for w, s in enumerate(input()):
            if s == '
                c[h][w] = True
            else:
                c[h][w] = False
    ans = 0
    for h in range(H):
        for coh in itertools.combinations(range(H), h):
            cc = np.delete(c, coh, 0)
            for w in range(W):
                for cow in itertools.combinations(range(W), w):
                    ccc = np.delete(cc, cow, 1)
                    if ccc.sum() == K:
                        ans += 1
    print(ans)
if __name__ == "__main__":
    main()

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

def resolve():
  H, W, K = map(int, input().split(" "))
  tasksH = []
  tasksH.append([])
  rangeH = range(H)
  for h in rangeH:
    tasksH.extend([list(x) for x in combinations(rangeH, h + 1)])

  tasksW = []
  tasksW.append([])
  rangeW = range(W)
  for w in rangeW:
    tasksW.extend([list(x) for x in combinations(rangeW, w + 1)])


  tasks = [list(x) for x in product(tasksH, tasksW)]

  C = []
  for h in range(H):
    C.append([x == "
  C = np.array(C)

  result = 0
  for task in tasks:
    if np.sum(C[np.ix_(task[0], task[1])]) == K:
      result += 1
  print(result)

if __name__ == "__main__":
  resolve()

Solution (Python):
import itertools
from dataclasses import dataclass, field
from typing import List


@dataclass
class Cell:
    i: int
    j: int
    color: str

    def to_red(self):
        return Cell(self.i, self.j, color='R')


@dataclass
class Board:
    cells: List[Cell] = field(default_factory=list)
    count: int = 0

    @classmethod
    def create(cls, H: int, W: int, C: List[List[str]]):
        cells = []
        for i in range(H):
            for j in range(W):
                cell = Cell(i + 1, j + 1, C[i][j])
                cells.append(cell)

        return Board(cells)

    def count_black(self) -> int:
        return len([c for c in self.cells if c.color == '

    def paint_row(self, row: int):
        new_cells = []

        for cell in self.cells:
            if cell.i == row:
                new_cells.append(cell.to_red())
            else:
                new_cells.append(cell)

        return Board(new_cells)

    def paint_col(self, col: int):
        new_cells = []

        for cell in self.cells:
            if cell.j == col:
                new_cells.append(cell.to_red())
            else:
                new_cells.append(cell)

        return Board(new_cells)


def actual(H, W, K, C):
    count = 0

    patterns = list(itertools.product(range(2), repeat=H + W))

    for pattern in patterns:
        board = Board.create(H, W, C)

        row_info = pattern[:H]
        col_info = pattern[H:]

        for row_idx, row in enumerate(row_info, start=1):
            if row == 1:
                board = board.paint_row(row_idx)

        for col_idx, col in enumerate(col_info, start=1):
            if col == 1:
                board = board.paint_col(col_idx)

        if board.count_black() == K:
            count += 1

    return count

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

print(actual(H, W, K, C))

Solution (Python):
import sys

def main():
    H,W,K=map(int,input().split())
    gyou=[]
    retu_index=[]
    retu=[0 for _ in range(W)]
    black=0
    for i in range(H):
        s=input()
        gyou.append(s.count("
        tmp=[]
        for j in range(W):
            if s[j]=="
                retu[j]+=1
                black+=1
                tmp.append(j)
        retu_index.append(tmp)

    p=black-K
    if p<0:
        print(0)
        sys.exit()


    gyou.extend(retu)
    matrix=gyou

    res=0
    for i in range(pow(2,H+W)):
        n=0
        matrix_=matrix[:]
        for j in range(H+W):
            if (i & (1<<j))!=0:
                if j<H:
                    for k in retu_index[j]:
                        matrix_[H+k]-=1
                n+=matrix_[j]

        if n==p:
            res+=1
    print(res)


if __name__=="__main__":
    main()

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

c = list()
judge = list()
for a in range(h):
    c.append(list(input()))
    judge.append([False]*w)

red = '*'

exist = False

ans = list()

for i in range(2 ** h):
    tmp = copy.deepcopy(c)
    for j in range(h):
        if (i >> j) & 1:
            tmp[j] = [red]*w
    ans.append(tmp)

result = list()

length = len(ans)
for now in range(length):
    for i in range(2**w):
        tmp = copy.deepcopy(ans[now])
        for j in range(w):
            if (i >> j) & 1:
                tmp_length = len(tmp)
                for z in range(tmp_length):
                    tmp[z][j] = red
        result.append(tmp)

result_length = len(result)

num = 0

for a in range(result_length):
    red_count = 0
    for b in range(h):
        red_count += result[a][b].count('
    if k == red_count:
        num += 1

print(num)

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

hk=[]
for i in range(h):
    kki=0
    hwi=input()
    hw=[]
    for j in range(w):
        if hwi[j]=='
            hw.append(1)
            kki+=1
        else:
            hw.append(0)
    c.append(hw)
    hk.append(kki)
kk=sum(hk)
ans=0

for i in range(2**h):
    
    wk=[0]
    wk*=w
    for j in range(h):
        if (i>>j &1):
            
            for l in range(w):
                wk[l]+=c[j][l]
    
    for j in range(2**w):
        ansi=0
        for l in range(w):
            if (j>>l & 1):
                ansi+=wk[l]
        if ansi==k:
            ans+=1
    
print(ans)

Solution (Python):



import math
import itertools

def main():
    h, w, k = input_list()
    maze = []
    for H in range(h):
        maze.append(list(input()))

    ans = []
    a = 0
    all = 0
    for l in maze:
        a += l.count('
        all += l.count('
    ans.append(a)
    hash_list_H = []
    kumi = 0
    for H in range(h):
        if maze[H].count('
            kumi += 1
        

    hash_list_W = []
    for W in range(w):
        a = 0
        for H in range(h):
            if maze[H][W] == '
                a += 1
        if a == k:
            kumi += 1
        hash_list_W.append(a)
    
    
    
    
    
    
    
    
    
    
    
    
    ss = 0
    
    
    
    
    
    
    
    r = 0
    done = []
    for H in range(h+1):
        for W in range(w+1):
            for hc in itertools.combinations(range(h), H):
                for wc in itertools.combinations(range(w), W):
                    if (hc, wc) in done:
                        continue
                    done.append((hc, wc))
                    if count(maze, hc, wc) == k:
                        r += 1
    print(r)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def count(mazes, hc, wc):
    hc = list(hc)
    wc = list(wc)
    r = 0
    for hi, row in enumerate(mazes):
        if hi in hc:
            continue
        for wi, m in enumerate(row):
            if wi in wc:
                continue
            if m == '
                r += 1
    return r

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

def input_list_str():
    return list(map(str, input().split()))

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

def split(word): 
    return [int(char) for char in word]  

H, W, K = map(int, input().split())
C = []
for _ in range(H):
    buff = str(input())
    for i in range(W):
        if buff[i] == '
            C.append(1)
        else:
            C.append(0)


C = np.array(C).reshape(H,W)

cnum = np.sum(C)

count = 0
if cnum < K:
    print(0)
    exit(0)
else:  
    for h in range(2 ** H):
        for w in range(2 ** W):
            
            wline = bin(w)[2:].zfill(W)
            wline = split(wline)  
            wzero = split(''.zfill(W))
            hline = bin(h)[2:].zfill(H)
            hline = split(hline)  
            
            HW = []
            for hlin in hline:
                if hlin:
                    HW.append(wline)
                else:
                    HW.append(wzero)
            HW = np.array(HW).reshape(H, W)
            cnew = np.sum(C * HW)
            
            if cnew == K:
                count += 1
            
print(count)

Solution (Python):
import pprint
import copy
import itertools as it
H, W, K = map(int, input().split())
M__ = []
M_ = []
M = []
for _ in range(H):
    M__.append(list(input()))
rows = []
for i in range(H):
    rows += list(it.combinations(range(H), i))
cols = []
for i in range(W):
    cols += list(it.combinations(range(W), i))

def fillrow(n):
    global M_
    M_[n] = ['x' for _ in range(W)]

def fillcol(n):
    global M
    for i in range(H):
        M[i][n] = 'x'

ans = 0
for row in rows:
    M_ = copy.deepcopy(M__)
    for v in row:
        fillrow(v)

    for col in cols:
        M = copy.deepcopy(M_)
        for v in col:
            fillcol(v)
        if sum([M[i].count('
            ans += 1

print(ans)

Solution (Python):
H, W, K = map(int, input().split())
c = [[0 for i in range(W)] for j in range(H)]
cnt = 0
ans = 0
for i in range(H):
    line = input()
    for j, l in enumerate(line):
        if l == '.':
            continue
        else:
            c[i][j] = 1
            cnt += 1
for i in range(1<<H):
    for j in range(1<<W):
        flags = [[0 for i in range(W)] for j in range(H)]
        for n in range(H):
            if i>>n & 1:
                for p in range(W):
                    flags[n][p] = 1
                    '''
                    if c[n][p] & flags[n][p] == 0:
                        res -= 1
                        flags[n][p] = 1
                    '''
        for m in range(W):
            if j>>m & 1:
                for q in range(H):
                    flags[q][m] = 1
                    '''
                    if c[q][m] & flags[q][m] == 0:
                        res -= 1
                        flags[q][m] = 1
                    '''
        res = 0
        for p in range(H):
            for q in range(W):
                if flags[p][q] == 0 and c[p][q] == 1:
                    res += 1
        if res == K:
            ans += 1
print(ans)

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

t=[[0 for i in range(w)] for j in range(h)]
c=0
for i in range(h):
  for j in range(w):
    t[i][j]=g[i][0][j]
    if g[i][0][j]=='
      c+=1
black=[]
for i in range(h):
  l=0
  for j in range(w):
    if t[i][j]=='
      l+=1
  black.append(t)
for i in range(w):
  l=0
  for j in range(h):
    if t[j][i]=='
      l+=1
  black.append(l)
ans=0
for i in range(2**(h+w)):
  count=0
  i=format(i,'b').rjust(h+w,'0')
  
  hl=[]
  wl=[]
  for j in range(h):
    if i[j]=='1':
      hl.append(j)
  for k in range(h,h+w):
    if i[k]=='1':
      wl.append(k-h)
  for i in range(h):
    for j in range(w):
      if i not in hl and j not in wl and t[i][j]=='
        count+=1

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

Solution (Python):
from itertools import combinations
def main():
    h,w,k = tuple([int(t)for t in input().split()])

    a = [list(input()) for _ in [0]*h]

    ans = 0
    for i in range(h+1):
        for rcom in combinations(range(h),i):
            for j in range(w+1):
                for ccom in combinations(range(w),j):
                    s = 0
                    for x in range(h*w):
                        if x//w in rcom or x%w in ccom:
                            continue
                        if a[x//w][x%w] == '
                            s += 1
                    if s==k:
                        ans +=1
                

    print(ans)
    

if __name__ == "__main__":
    main()

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	H,W,K = inputMap()
	maps = []
	for i in range(H):
		s = inputStr()
		maps.append(s)

	ans = 0
	for i in range(2**H):
		iBin = bin(i)[2:]
		pl = ""
		for ttt in range(len(iBin), H):
			pl += "0"
		iBin = pl + iBin
		iBin = iBin[::-1]
		for j in range(2**W):
			jBin = bin(j)[2:]
			pl = ""
			for ttt in range(len(jBin), W):
				pl += "0"
			jBin = pl + jBin
			jBin = jBin[::-1]

			kuro = 0
			for iii,mapH in enumerate(maps):
				if iBin[iii] == "1":
					continue
				for jjj,mapW in enumerate(mapH):
					if jBin[jjj] == "1":
						continue
					if mapW == "
						kuro += 1
			if kuro == K:
				ans += 1
	print(ans)






if __name__ == "__main__":
	main()

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

sum=0
f=[0]*h
g=[0]*w
for i in range(0,h):
	f[i]=c[i].count("
	sum+=f[i]

	
		
			
ans=0
for bit in range(1<<h+w):
	d=list(range(h)) 
	e=sum 
	for j in range(h+w):
		if(bit>>j)&1:
			if j<h:
				d.remove(j)
				e-=f[j]
				
			else:
				for l in d:
					if c[l][j-h]=="
						e-=1
	if e==k:
		ans+=1

print(ans)