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 numpy as np
from itertools import combinations
h,w,k = map(int,input().split())
c = np.empty((h,w))
for i in range(h):
    c[i,:] = np.array(list(map(int,input().replace(".",'0 ').replace("

cnt = 0
row,col = range(h),range(w)

for i in range(1,h+1):
    for j in range(1,w+1):
        if i==h and j==w:
            break
        for x in combinations(row, i):
            for y in combinations(col,j): 
                s = c[np.array(x),:]
                s = s[:,np.array(y)].sum()
                if s==k:
                    cnt+=1
if c.sum()==k:cnt+=1
print(cnt)

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

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



black = []
a = 0

for i in range(h):
    for j in range(w):
        if c[i][j] == "
            black.append((i, j))


for i in range(2 ** (h+w)):
    total = 0
    row = []
    col = []
    for j in range(h + w):  
        if ((i >> j) & 1):  
            if j < h:
                row.append(j)
            else:
                col.append(j - h)
    

    
    s = 0
    for r, c in black:
        
        if (r not in row) and (c not in col):
            s += 1
        

    if s == k:
        a += 1

print(a)

Solution (Python):
import itertools

import numpy as np


def _run(H, W, K, C):
    input = np.zeros([H, W], dtype=np.int8)
    for h in range(H):
        for w in range(W):
            if C[h][w] == "
                input[h, w] = 1

    count = 0
    for r in itertools.product(*[[0, 1] for _ in range(H + W)]):
        copy_input = input.copy()
        for h in range(H):
            if r[h] == 1:
                copy_input[h] = 0
        for w in range(W):
            if r[H + w] == 1:
                copy_input[:, w] = 0

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


def _main():
    H, W, K = map(int, input().split())
    C = [str(input()) for _ in range(H)]
    _run(H, W, K, C)


if __name__ == "__main__":
    _main()

Solution (Python):
import numpy as np

s = input().split()

H = int(s[0])
W = int(s[1])
K = int(s[2])

m = np.zeros((H, W))

def make_list(n):
  r = []
  b = bin(n)[2:]
  for i in range(len(b)):
    if b[i] == "1":
      r.append(len(b) - i - 1)
  return r
    
for i in range(H):
  s = input()
  for j in range(W):
    if s[j] == "
      m[i, j] = 1

result = 0
for i in range(2**H):
  h = make_list(i)
  for j in range(2**W):
    w = make_list(j)
    M = np.delete(m, h, 0)
    M = np.delete(M, w, 1)
    if np.sum(M) == K:
      result += 1
      
      
print(result)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)



from collections import deque

import itertools


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W, K = map(int, input().split())
    C = [[] for _ in range(H)]
    for i in range(H):
        C[i] = list(input())
    ccc =[0]*37
    ans = 0

    for h in itertools.product("01", repeat=H):
        for w in itertools.product("01", repeat=W):
            count = 0

            for i in range(H):
                for j in range(W):
                    if h[i] == "1" and w[j] == "1" and C[i][j] == "
                        count += 1
            ccc[count] +=1

    print(ccc[K])


if __name__ == "__main__":
    main()

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


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

c = np.array([[1 if s == '

hs = [list(hs) for hh in range(1, h + 1) for hs in combinations(range(h), hh)]
ws = [list(ws) for ww in range(1, w + 1) for ws in combinations(range(w), ww)]

a = 0
for hss in hs:
    cc = c[hss]
    for wss in ws:
        if np.sum(cc[:, wss]) ==k:
            a += 1
print(a)

Solution (Python):
import sys
import numpy as np
import math  
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate 
from itertools import permutations
import itertools
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache 
def print_red(field, high):
    for i in range(len(high)):
        if high[i] == 1:
            field[i] = ['X' for _ in range(len(field[0]))]
    return field

def count_sharp_without_width(field, width):
    count = 0
    for i in range(len(field)): 
        for j in range(len(width)): 
            if width[j] == 1:
                continue
            if field[i][j] == '
                count += 1
    return count

def main():
    h, w, k = list(map(int,input().split()))
    field = [list(input()) for _ in range(h)]
    

    ans = 0

    for high in itertools.product([1, 0], repeat=h):
        field_temp = deepcopy(field)
        field_temp = print_red(field_temp, high)
        count_k = 0
        
        for i in range(h):
            count_k += field_temp[i].count('
        
        if count_k < k: continue 
        
        for width in itertools.product([1, 0], repeat=w):
            
            count_k = count_sharp_without_width(field_temp, width)
            if count_k == k:
                ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
import copy

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

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

ans = 0
change_h = np.array(["." for _ in range(h)])
change_w = np.array(["." for _ in range(w)])

for i in range(2**h):
    for j in range(2**w):
        idx_i, idx_j = [], []
        for ii in range(h):
            if i>>ii & 1:
                idx_i.append(ii)
        for jj in range(w):
            if j>>jj & 1:
                idx_j.append(jj)

        d = copy.deepcopy(c)
        for item in idx_i:
            d[item, :] = change_w
        for item in idx_j:
            d[:, item] = change_h
        x = np.count_nonzero(d == "
        if x == k:
            ans += 1
        
print(ans)

Solution (Python):
import itertools

def checker(data, h, w, k, h_ax, w_ax):
  flag = {i: {j: 0 for j in range(w)} for i in range(h)}
  for i in h_ax:
    for j in range(w):
      flag[i][j] = 1
  for i in w_ax:
    for j in range(h):
      flag[j][i] = 1
  c = 0
  for i in range(h):
    for j in range(w):
      if data[i][j] == "
        c += 1
  if c == k:
    return True
  else:
    return False

h, w, k = map(int, input().split())
data = [input() for _ in range(h)]

counter = 0
for i in range(h):
  for j in range(w):
    for h_ax in itertools.combinations(range(h), i):
      for w_ax in itertools.combinations(range(w), j):
        if checker(data, h, w, k, h_ax, w_ax):
          counter += 1

print(counter)

Solution (Python):
H,W,K = map(int, input().split())
c_table = [input() for _ in range(H)]
SUM = 0
for i in range(H):
    for j in range(W):
        if c_table[i][j] == '
            SUM += 1
answer = 0

for i in range(2 ** (H)):
    tmp_h = [False] * H
    for j in range(H):
        if i >> j & 1:
            tmp_h[j] = True
    for k in range(2**W):
        tmp_w = [False] * W
        for l in range(W):
            if k>>l & 1:
                tmp_w[l] = True
        cnt = 0
        for ti in range(len(tmp_h)):
            if tmp_h[ti]:
                for tk in range(W):
                    if c_table[ti][tk] == '
                        cnt += 1
        for tj in range(len(tmp_w)):
            if tmp_w[tj]:
                for tk in range(H):
                    if tmp_h[tk]:
                        continue
                    if c_table[tk][tj] == '
                        cnt += 1

        if K == SUM - cnt:
            answer += 1
        

print(answer)

Solution (Python):
H, W, K = map(int, input().split())
S = []
ans = 0

def binlist(x,k):
  s = []
  for i in range(k):
    s.append(x % 2)
    x = x // 2
  return s
    
for i in range(H):
  temp1 = input()
  temp2 = [temp1[i] for i in range(len(temp1))]
  S.append(temp2)
for i in range(2 ** H):
  for j in range(2 ** W):
    A = binlist(i, H)
    B = binlist(j, W)
    c = 0
    for k in range(H):
      for l in range(W):
        if A[k] == 0 and B[l] == 0 and S[k][l] == "
          c += 1
    if c == K:
      ans += 1
      
print(ans)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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


ANS = []
def dfs(l):
    if len(l) == H + W:
        h = l[:H]
        w = l[-W:]
        
        
        
        
        cnt = 0
        for y in range(H):
            for x in range(W):
                if h[y] or w[x]:
                    continue
                if masu[y][x] == "
                    cnt += 1
        
        if cnt == K:
            
            
            
            
            ANS.append(1)
        return
    for b in [0, 1]:
        l.append(b)
        dfs(l)
        l.pop()
    
dfs([])
ans = len(ANS)
print(ans)

Solution (Python):
import numpy as np
import copy
h, w, k = map(int, input().split())
m = []
for i in range(h):
  tmp_m = []
  s = input()
  for j in range(w):
    if s[j] == ".":
      tmp_m.append(0)
    else:
      tmp_m.append(1)
  m.append(tmp_m)

m = np.array(m)
n = h + w
cnt = 0
for i in range(2 ** n):
  l = []
  for j in range(n):
    if ((i >> j) & 1):
      l.append(j)
  curr_m = copy.deepcopy(m)
  for a in l:
    if a < w:
      if a != w:
        curr_m[:, a] = 0
    else:
      a -= w
      if a != h:
        curr_m[a, :] = 0
  if np.sum(curr_m) == k:
    cnt += 1

print(cnt)

Solution (Python):
import sys
input =sys.stdin.readline
import numpy as np
import itertools

H,W,K=(int(x) for x in input().rstrip('\n').split())

for i in range(H):
  x = list(input().rstrip('\n'))
  y = [0 if p=='.' else 1 for p in x]
  if i == 0:
    stage=np.array([y])
    stage=np.reshape(stage,(1,W))
  else:
    sta = np.array([y])
    sta=np.reshape(sta,(1,W))
    stage = np.append(stage,sta,axis=0)
total_h = [x for x in itertools.product((0,1),repeat=H)]
total_w = [x for x in itertools.product((0,1),repeat=W)]
res = 0
for h in total_h:
  for w in total_w:
    sta2 = [[0]*W]*H
    for i in range(H):
      if h[i]==1:
        sta2[i]=[1]*W
      else:
        sta2[i]=list(w)
    sta2 =np.array(sta2)
    sta_n = stage-sta2
    if np.sum(sta_n>0)==K:
      res += 1
print(res)

Solution (Python):


def count_black(grid,painted_row,painted_col):
    count = 0
    for id_row,row in enumerate(grid):
        for id_col,item in enumerate(row):
            if painted_row[id_row] == 0 and painted_col[id_col] == 0 and item == "
                count += 1
    return count



def generate_selection(limit=0):
    result = []
    arr = [0 for i in range(limit)]
    max_result_len = limit**2

    while True:
        result.append(arr.copy())

        pos_to_change = -1
        for i in range(limit-1,-1,-1):
            if arr[i] == 0:
                pos_to_change = i
                break
        
        if pos_to_change == -1:
            break
        
        arr[pos_to_change] = 1
        for i in range(pos_to_change+1,limit):
            arr[i] = 0
    
    return result

if __name__ == "__main__":
    h,w,k = [int(i) for i in input().split()]
    grid = []
    for i in range(h):
        row = input()
        grid.append(row)
    
    
    row_selections = generate_selection(limit=h)
    col_selections = generate_selection(limit=w)


    result = 0
    for row_selection in row_selections:
        for col_selection in col_selections:
            if count_black(grid,row_selection,col_selection) == k:
                result += 1
    
    print(result)

Solution (Python):
h,w,k = map(int,input().split())
ss = []
for i in range(h):
    s = list(input())
    ss.append(s)
ans = 0
for i in range(2**h):
    for j in range(2**w):
        count = 0
        for x in range(h):
            for y in range(w):
                if i>>x&1 == 1 or j>>y&1 == 1:continue
                if ss[x][y] == "
                    count += 1 
        if count == k:
            ans += 1
print(ans)

Solution (Python):
from itertools import combinations 
def powerset(string): 
    al=[]
    for i in range(0,len(string)+1): 
        sl=[]
        for element in combinations(string,i): 
            al.append(element)
    return al
import sys
def check(l,row,col,el,r,c):
    cc=0
    
    for i in range(r):
        for j in range(c):
            if(l[i][j]=="
                cc+=1
    
    if cc==el:
        return True;
    return False



r,c,k=map(int,input().split())
l=[]
for i in range(r):
    tt=list(input())
    l.append(tt)
s1=[]
for i in range(r):
    s1.append(i)
s2=[]
for i in range(c):
    s2.append(i)
row=powerset(s1)
col=powerset(s2)
ans=0

for i in row:
    for j in col:
        if(check(l,i,j,k,r,c)):
            ans+=1
print(ans)

Solution (Python):
import numpy as np

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

ans = 0
for bit in range(1 << (H+W)):
    red_array = np.full((H, W), False)
    cnt = 0
    for i in range(H+W):
        
        if (bit>>i)&1 == 1:
            if i < H:
                red_array[i,:] = True
            else:
                red_array[:,i-H] = True
    
    
    for y in range(H):
        for x in range(W):
            
            if c[y][x] == 1 and not red_array[y, x]:
                cnt += 1
    
    if cnt == K:
        ans += 1
print(ans)

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

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

C = []

for _ in range(H):
    
    c = list(input())

    C.append(c)

C = np.array(C)

cnt = 0

chooseH = list(product([False, True], repeat=(H)))
chooseW = list(product([False, True], repeat=(W)))

for array_h in chooseH:
    for array_w in chooseW:
        D = np.copy(C)
        D[array_h, :] = "R"
        D[:, array_w] = "R"
        
        if np.sum(D.flatten() == "
            cnt += 1











print(cnt)

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


y=[0]*w
x=[0]*h
for i in range(h):
    x[i]=c[i].count('

for i in range(w):
    for j in range(h):
        if c[j][i]=='
            y[i]+=1
qq=sum(x)

ans=0
for i in range(2**h):
    p=[]
    for i2 in range(h):
        if (i>>i2)&1:
            p.append(i2)
    for j in range(2 ** w):
        cnt = qq
        q = []
        for j2 in range(w):
            if (j >> j2) & 1:
                q.append(j2)
        for v in p:
            cnt -= x[v]
        for v2 in q:
            cnt -= y[v2]
        for v3 in p:
            for v4 in q:
                if c[v3][v4] == '
                    cnt += 1

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

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    h, w, k = MI()
    C = []
    for _ in range(h):
        C.append(input())
    c_h = [0]*h
    c_w = [0]*w
    cnt = 0
    for i in range(h):
        for j in range(w):
            if C[i][j] == '
                c_h[i] += 1
                c_w[j] += 1
                cnt += 1
    ans = 0
    for i in range(2**h):
        for j in range(2**w):
            cnt_temp = cnt
            row = []
            col = []
            for ii in range(h):
                if ((i >> ii) & 1):
                    cnt_temp -= c_h[ii]
                    row.append(ii)
            for jj in range(w):
                if ((j >> jj) & 1):
                    cnt_temp -= c_w[jj]
                    col.append(jj)
            for ro in row:
                for co in col:
                    if C[ro][co] == '
                        cnt_temp += 1
            if cnt_temp == k:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

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

count = 0
for i in range(2**h):
    row = []
    r = 0
    while i:
        if i & 1:
            row.append(r)
        i >>= 1
        r += 1

    for j in range(2**w):
        col = []
        c = 0
        while j:
            if j & 1:
                col.append(c)
            j >>= 1
            c += 1

        black = 0
        for r in row:
            for c in col:
                if grid[r][c] == "
                    black += 1

        if black == k:
            count += 1

print(count)

Solution (Python):




import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

H,W,K = map(int,input().split())
c = int_mtx(H)
ans = 0

for ih in range(2**H):

    for iw in range(2**W):

        ca = c.copy()

        for jh in range(0,H):

            for jw in range(0,W):

                if ((ih >> jh) & 1):
                    ca[jh,:] = 0
                if ((iw >> jw) & 1):
                    ca[:,jw] = 0

        if np.count_nonzero(ca == "
            ans += 1

print(ans)

Solution (Python):
import math
import itertools

h, w, k = map(int, input().split(" "))
cL = [input() for _ in range(h)]

blackCount = 0
for c in cL:
    for item in c:
        if item == "
            blackCount += 1

ans = 0
for x in range(w + 1):
    for y in range(h + 1):
        for x2 in itertools.combinations(range(w), x):
            for y2 in itertools.combinations(range(h), y):
                yCnt = 0
                xCnt = 0
                for y4 in y2:
                    
                    xCnt += cL[y4].count("
                for x4 in x2:
                    for y3 in range(h):
                        if cL[y3][x4] == "
                            yCnt += 1
                th = 0
                for xa in x2:
                    for ya in y2:
                        if cL[ya][xa] == "
                            th += 1
                _sum = blackCount - yCnt - xCnt + th
                if k == _sum:
                    ans += 1

print(ans)

Solution (Python):
from itertools import product
import copy

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

ans = 0
cnt = 0

for Hbit in product([0,1], repeat = H):
    c = copy.deepcopy(d)
    for x,name in enumerate(Hbit):
        if name == 1:
            for j in range(W):
                c[x][j] = "r"
    e = copy.deepcopy(c)
    for Wbit in product([0,1], repeat = W):
        c = copy.deepcopy(e)
        for x,name in enumerate(Wbit):
            if name == 1:
                for j in range(H):
                    c[j][x] = "r"
        
        for i in range(H):
            for j in range(W):
                if c[i][j] == "
                    cnt += 1
        
        if cnt == K:
            ans += 1
        
        cnt = 0

print(ans)

Solution (Python):
from itertools import combinations as comb


def main():

    
    H, W, K = map(int, input().split())
    lst = [[i for i in input()] for _ in range(H)]
    ans = 0

    for h in range(H):
        for w in range(W):
            for i in comb(range(H), h):
                for j in comb(range(W), w):
                    black_sum = 0
                    for k1 in range(H):
                        if k1 in i:
                            continue
                        for k2 in range(W):
                            if k2 in j or lst[k1][k2] == ".":
                                continue
                            black_sum += 1
                    if black_sum == K:
                        
                        ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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

C=[]

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

ans=0
for i in range(H+1):
  for j in range(W+1):
    for n in itertools.combinations(list(range(H)),i):
      for m in itertools.combinations(list(range(W)),j):
        count = 0
        for a in n:
          for b in m:
            if(C[a][b]=="
        if(count == K):
          ans += 1
print(ans)

Solution (Python):
from copy import deepcopy
import numpy as np
H, W, K = map(int, input().split())
C = np.array([[1 if a == '

HA = 2 ** H
WA = 2 ** W



ans = 0
for i in range(HA):
    R = np.copy(C)
    for j in range(H):
        if (i >> j) & 1:
            R[j] = 0
    for k in range(WA):
        RR = np.copy(R)
        for l in range(W):
            if (k>>l) & 1:
                RR[:,l]=0
        if np.sum(RR) == K:
            ans += 1
print(ans)

Solution (Python):
import itertools

h, w, k = map(int, input().split())
c = [0]*h
d = [0]*h
for i in range(h):
    c[i] = input()

H = list(itertools.product([0,1], repeat=h))
W = list(itertools.product([0,1], repeat=w))

ans = 0

for i in H:
    for j in W:
        for e in range(h):
                d[e] = c[e]
        
        a = 0
        for x in range(h):
            if i[x] == 1:
                d[x] = 'xxxxxx'
            else:
                for y in range(w):
                    if j[y] == 1:
                        d[x] = d[x][:y] + 'x' + d[x][y+1:]
            for D in d[x]:
                if D == '
                    a += 1
        
        if a == k:
            ans += 1
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

h, w, k = map(int, input().split())
board = [0] * h
for i in range(h):
    board[i] = list(input().strip())

ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        bin_i = format(i, '0{}b'.format(h))
        bin_j = format(j, '0{}b'.format(w))
        black = 0
        for ch in range(h):
            for cw in range(w):
                if bin_i[ch] == '1':
                    continue
                if bin_j[cw] == '1':
                    continue
                if board[ch][cw] == '
                    black += 1
        if black == k:
            ans += 1
print(ans)

Solution (Python):
from copy import deepcopy


h, w, k = map(int, input().split())
grid = [list(input()) for _ in range(h)]

R = [format(i, "0" + str(h) + "b") for i in range(2**h)]
C = [format(j, "0" + str(w) + "b") for j in range(2**w)]

ans = 0
for r in R:
    for c in C:
        tmp = deepcopy(grid)
        for i in range(h):
            if r[i] == "1":
                for j in range(w):
                    tmp[i][j] = "R"
        for j in range(w):
            if c[j] == "1":
                for i in range(h):
                    tmp[i][j] = "R"
        cnt = 0
        for i in range(h):
            for j in range(w):
                if tmp[i][j] == "
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Solution (Python):

"""
@author: H_Hoshigi
"""
def main():
    H, W, K = map(int, input().split())
    c_list = [input() for i in range(H)]
    c_list_list = [ [(0 if c[j]=="." else 1) for j in range(W) ] for c in c_list]

    counter = 0
    for i in range(pow(2, H+W)):
        bin_i = format(i, "b").zfill(H+W)
        this_c_list_list = [c_list[:] for c_list in c_list_list]
        for row in range(H):
            if bin_i[row] == "1":
                this_c_list_list[row] = [0]*W
        for column in range(W):
            if bin_i[H+column] == "1":
                for j in range(H):
                    this_c_list_list[j][column] = 0
        sum_1 = sum([sum(c_list) for c_list in this_c_list_list])
        
        if sum_1 == K:
            counter += 1
        
    print(counter)

if __name__ == "__main__":
    main()

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

h, w, k = map(int, input().split())
c = np.empty((h, w), dtype='U1')
for i in range(h):
    c[i] = list(input())

res = 0
for arr in product(range(2), repeat=h+w):
    a = arr[:h]
    b = arr[h:]
    d = np.copy(c)
    for i in range(h):
        if not a[i]:
            continue
        d[i] = ['R'] * w
    for i in range(w):
        if not b[i]:
            continue
        d[:, i] = ['R'] * h
    if np.count_nonzero(d == '
        res += 1
print(res)

Solution (Python):
import itertools
H,W,K = [int(i) for i in input().split()]

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

h_list = list(range(H))
w_list = list(range(W))

h_result=[]
for n in range(1,len(h_list)+1):
    for conb in itertools.combinations(h_list, n):
        h_result.append(list(conb)) 
h_result.append([100])


w_result=[]
for n in range(1,len(w_list)+1):
    for conb in itertools.combinations(w_list, n):
        w_result.append(list(conb)) 
w_result.append([100])


ans = 0

for H_item in h_result:
    for W_item in w_result:

        tmp = 0
        for k in range(H):
            if k in H_item:
                continue
            for l in range(W):
                if l in W_item:
                    continue
                if M[k][l] == '
                    tmp += 1
        if K == tmp:
            ans += 1

print(ans)

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

ans = 0

for i in range(2 ** H):
    for k in range(2 ** W):
        black = 0
        for j in range(H):
            if (i >> j) & 1:
                for l in range(W):
                    if (k >> l) & 1:
                        if c[j][l] == "
                            black += 1
        if black == K: ans += 1
print(ans)

Solution (Python):
import copy

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

for h in range(2**H):
    for w in range(2**W):
        tmp = copy.deepcopy(C)
        w_bin = bin(w)[2:].zfill(W)
        h_bin = bin(h)[2:].zfill(H)
        for index_w,flag_w in enumerate(w_bin):
            for index_h,flag_h in enumerate(h_bin):
                if flag_h == '1':
                    tmp[index_h] = ['.' for _ in range(W)]
                if flag_w == '1':
                    tmptmp = [list(x) for x in zip(*tmp)]
                    tmptmp[W-index_w-1] = ['.' for _ in range(H)]
                    tmp = [list(x) for x in zip(*tmptmp)]
        a = 0
        for i in tmp:
            a += i.count('
        if K == a:
            ans += 1
print(ans)

Solution (Python):
import itertools
import numpy as np

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

matrix = np.zeros((H, W))
for x in range(H):
    for y in range(W):
        if C[x][y] == '
            matrix[x, y] = 1

n_success = 0
for h in range(H + 1):
    for rows in itertools.combinations(range(H), h):
        for w in range(W + 1):
            for cols in itertools.combinations(range(W), w):
                X = matrix.copy()
                X[rows, :] = 0
                X[:, cols] = 0
                if X.sum() == K:
                    n_success += 1
print(n_success)

Solution (Python):

from collections import deque




import os
import sys
from io import BytesIO, IOBase





















































from bisect import bisect_left as bl
from math import log2,ceil
from heapq import heappush, heappop
from itertools import permutations

def main():
    
        
        
        h,w,k = [int(j) for j in input().split()]
        l = [i for i in range(h)]
        m = [i for i in range(w)]
        l_ = [[0], []]
        for i in range(1,h):
            
            
            
            for ls in range(len(l_)):
                
                l_.append(l_[ls]+[l[i]])
        m_ = [[0], []]
        for i in range(1,w):
            
            
            
            for ls in range(len(m_)):
                
                m_.append(m_[ls]+[m[i]])
                
        
        ct = 0
        ip = []
        for i in range(h):
            ip.append(list(input()))
            for j in range(w):
                if ip[i][j]=='
                    ct+=1
        fct = 0
        for lh in l_:
            for lw in m_:
                ct_ = ct
                for r in range(h):
                    for c in range(w):
                        if ip[r][c]=='
                            if (r in lh or c in lw):
                                ct_-=1
                if ct_==k:
                    fct+=1
        print(fct)
            

        


        
        






if __name__ == "__main__":
    main()

Solution (Python):


import copy
import itertools

h, w, k = map(int, input().split())
c_l = [list(input()) for y in range(h)]

ans = 0

for i in range(2**w):
    _c_l = copy.deepcopy(list(zip(*c_l)))
    for x in range(w):
        if (i >> x) & 1:
            _c_l[x] = [0] * h
    _c_l = list(zip(*_c_l))
    for j in range(2**h):
        __c_l = copy.deepcopy(_c_l)
        for y in range(h):
            if (j >> y) & 1:
                __c_l[y] = [0] * w
        _list = list(itertools.chain.from_iterable(__c_l))
        if _list.count("
            ans += 1
    
print(ans)

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


def main():
  H, W, K = list(map(int, input().split()))
  map_ = [input()[:-1] for _ in range(H)]
  
  hseq = range(H)
  wseq = range(W)
  hcomb = []
  wcomb = []
  for i in range(H):
    hcomb.extend(list(itertools.combinations(hseq, i)))
  for i in range(W):
    wcomb.extend(list(itertools.combinations(wseq, i)))

  
  
  num_comb = 0
  for i in range(len(hcomb)):
    for j in range(len(wcomb)):
      cnt = 0
      
      if not(len(hcomb[i]) or len(wcomb[j])):
        for hh in range(H):
          for ww in range(W):
            if map_[hh][ww] == '
              cnt += 1

      if not len(hcomb[i]):
        
        for hh in range(H):
          for ww in wcomb[j]:
            if map_[hh][ww] == '
              cnt += 1

      elif not len(wcomb[j]):
        
        for hh in hcomb[i]:
          for ww in range(W):
            if map_[hh][ww] == '
              cnt += 1

      else:
        for hh in hcomb[i]:
          for ww in wcomb[j]:
            if map_[hh][ww] == '
              cnt += 1
      if cnt == K:
        
        num_comb += 1

  print(num_comb)


if(__name__ == '__main__'):
  main()