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 sys
sys.setrecursionlimit(10**8)
from itertools import combinations
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    H, W, K = MAP()
    c = [input() for i in range(H)]
    ans = 0
    for wmask in range(1 << W):
        for hmask in range(1 << H):
            cnt = 0
            for w in range(W):
                if wmask & (1 << w):
                    continue
                for h in range(H):
                    if hmask & (1 << h):
                        continue
                    if c[h][w] == "
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()

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

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

ANS=0
for i in range(1<<H):
    for j in range(1<<W):

        A=0

        for k in range(H):
            if i & (1<<k)!=0:
                continue
            for l in range(W):
                if j & (1<<l)!=0:
                    continue
                if MAP[k][l]=="
                    A+=1
        if A==K:
            ANS+=1
print(ANS)

Solution (Python):
import copy

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

ans = 0

N = 2 ** H
M = 2 ** W

for i in range(N):
  for j in range(M):
    cp = copy.deepcopy(c)
    for k in range(H):
      if (i >> k) & 1:
        for n in range(W):
          cp[k][n] = "."
    for k in range(W):
      if (j >> k) & 1:
        for n in range(H):
          cp[n][k] = "."
    cnt = 0
    for n in range(H):
      for m in range(W):
        if cp[n][m] == "
          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)]
ans = 0


for i in range(2**h):
    for j in range(2**w):
        A = [[0] * w for i in range(h)]
        for ii in range(h):
            for jj in range(w):
                if C[ii][jj] == "
                    A[ii][jj] = 1

        
        
        ib = format(i,"b").zfill(h)
        jb = format(j,"b").zfill(w)
        

        for ii in range(h):
            for jj in range(w):
                if ib[ii] == "1" or jb[jj] == "1":
                    A[ii][jj] = 0

        ans0 = sum([sum(A[ii]) for ii in range(h)])
        if ans0 == k:
            ans += 1
print(ans)

Solution (Python):
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W, K = map(int, readline().split())
C = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W]

C = 1 * (C == b'

def f(C, x, y):
    D = C.copy()
    for i in range(H):
        if x & (1 << i):
            D[i] = 0
    for i in range(W):
        if y & (1 << i):
            D[:, i] = 0
    return D.sum() == K

ans = 0
for x in range(1 << H):
    for y in range(1 << W):
        ans += f(C, x, y)
print(ans)

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

grid = np.array([list(map(lambda x: x == '

from itertools import product

res = 0
for p in product(range(2),repeat=H+W):
    ngrid = grid.copy()
    ngrid[:,[i for i,v in enumerate(p[:W]) if v]] = 0
    ngrid[[i for i,v in enumerate(p[W:]) if v],:] = 0
    if ngrid.sum() == K:
        res += 1

print(res)

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

ans = 0
for tate in itertools.product([0,1], repeat=h):
    for yoko in itertools.product([0,1], repeat=w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if tate[i] or yoko[j]:continue
                cnt += C[i][j] == "
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
h,w,k = map(int, input().split())
board = [list(map(lambda x: int(x=="

ans = 0
for i in range(1<<h):
    for j in range(1<<w):
        nboard = [board[i][:] for i in range(h)]
        for x in range(h):
            if i & (1<<x):
                for z in range(w):
                    nboard[x][z] = 0
        for y in range(w):
            if j & (1<<y):
                for z in range(h):
                    nboard[z][y] = 0
        if sum(sum(x) for x in nboard) == k:
            ans += 1
print(ans)

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

h,w,k=map(int,input().split())
c=[input() for i in range(h)]
ans=0
for gyo in product(range(2),repeat=h):
    for retsu in product(range(2),repeat=w):
            cnt=0
            
            
            for i in range(h):
                for j in range(w):
                    if gyo[i]==0 and retsu[j]==0 and c[i][j]=="
                        cnt+=1
            if cnt==k:
                ans+=1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
board = []
for _ in range(H):
    board.append(list(input()))
ans = 0
for bh in range(1 << H):
    for bw in range(1 << W):
        num = 0
        for y in range(H):
            if (bh >> y) & 1 == 0:
                continue
            for x in range(W):
                if (bw >> x) & 1 == 0:
                    continue
                if board[y][x] == '
                    num += 1
        if num == K:
            ans += 1
print(ans)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

B = [[] for _ in range(H)]

for h in range(H):
    B[h] = list(input())

ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for h in range(H):
            for w in range(W):
                if ((i >> h) & 1) == 1 or ((j >> w) & 1) == 1:
                    continue
                if B[h][w] == '
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Solution (Python):
h,w,k = map(int,input().split())
s = [str(input()) for i in range(h)]
ans = 0
for i in range(2 ** w):
    for j in range(2 ** h):
        a = format(i,"b").zfill(w)
        b = format(j,"b").zfill(h)
        cnt = 0
        for f in range(w):
            for g in range(h):
                if b[g] == "0" and a[f] == "0" and s[g][f] == "
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

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

ans = 0
for rows in range(1<<H):
    for columns in range(1<<W):
        num = 0
        for i in range(H):
            for j in range(W):
                if (rows>>i) & 1 and (columns>>j) & 1:
                    if css[i][j] == '
                        num += 1
        if num == K:
            ans += 1

print(ans)

Solution (Python):
def main():
    H, W, K = (int(i) for i in input().split())
    c = [input() for i in range(H)]
    ans = 0
    from itertools import combinations
    for i in range(H+1):
        for j in range(W+1):
            for sh in combinations(range(H), i):
                for sw in combinations(range(W), j):
                    v = 0
                    for h in sh:
                        for w in sw:
                            if c[h][w] == "
                                v += 1
                    if v == K:
                        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from copy import deepcopy
H,W,K=map(int,input().split())
c=[list(input()) for i in range(H)]
ans=0
for i in range(2**H):
        for k in range(2**W):
            G=deepcopy(c)
            cnt=0
            for j in range(H):
                if i>>j&1:
                    for x in range(W):
                        G[j][x]='@'
            for f in range(W):
                if k>>f&1:
                    for y in range(H):
                        G[y][f]='@'
            for j in range(H):
                for f in range(W):
                    if G[j][f]=='
                        cnt+=1
            if cnt==K:
                ans+=1
print(ans)

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



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

C = [0] * H
for i in range(H):
    C[i] = input()

ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        val = 0
        for y in range(H):
            if i & 1 << y > 0:
                continue
            for x in range(W):
                if j & 1 << x > 0:
                    continue
                if C[y][x] == '
                    val += 1
        if val == K:
            ans += 1
print(ans)

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

ans = 0
for nh in range(2**H):
    for nw in range(2**W):
        count = 0
        for h in range(H):
            for w in range(W):
                if 2**h&nh!=2**h and 2**w&nw!=2**w and c[h][w]=='
                    count += 1
        if count==K:
            ans += 1
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W, K = MAP()
c = [list(input()) for _ in range(H)]

ans = 0
for y in product([0, 1], repeat=H):
    for x in product([0, 1], repeat=W):
        c_copy = deepcopy(c)
        for i in range(H):
            if y[i]:
                for j in range(W):
                    c_copy[i][j] = "R"
        for i in range(W):
            if x[i]:
                for j in range(H):
                    c_copy[j][i] = "R"
        cnt = 0
        for i in range(H):
            for j in range(W):
                if c_copy[i][j] == "
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Solution (Python):
from itertools import product
H, W, K = map(int, input().split())
black = 0
C = []
for _ in range(H):
    s = input()
    black += s.count("
    C.append(s)

ans = 0
row = tuple(product(range(2), repeat=H))
col = tuple(product(range(2), repeat=W))

for r in row:
    for c in col:
        cnt = 0
        for i in range(H):
            for j in range(W):
                if r[i] or c[j]:
                    cnt += int(C[i][j] == "
        if black - cnt == K:
            ans += 1

print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

H,W,K=map(int,input().split())
c=[list(map(int,list(input().replace('.','0').replace('
ans=0
for i in range(2**H):
    for k in range(2**W):
        d=[c[i][:] for i in range(H)]
        for j in range(H):
            if (i>>j)&1:
                d[j]=[0]*W
        for l in range(W):
            if (k>>l)&1:
                for m in range(H):
                    d[m][l]=0
        cnt=0
        for j in range(H):
            cnt+=sum(d[j])
        ans+=cnt==K
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]
ans = 0
for i in range(2**H):
    for j in range(2**W):
        res = [[0 for y in range(W)] for x in range(H)]
        for x in range(H):
            for y in range(W):
                if C[x][y] == '
                    res[x][y] = 1
        for x in range(H):
            if (i >> x) & 1:
                for y in range(W):
                    res[x][y] = 0
        for y in range(W):
            if (j >> y) & 1:
                for x in range(H):
                    res[x][y] = 0
        tmp = 0
        for x in range(H):
            for y in range(W):
                if res[x][y]:
                    tmp += 1
        if tmp == K:
            ans += 1
print(ans)

Solution (Python):
from itertools import product
H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]

ans = 0
for hp in product(range(2), repeat=H):
    for wp in product(range(2), repeat=W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if hp[i] and wp[j] and C[i][j] == "
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):
from copy import deepcopy

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

cs = [list(map(lambda c: 1 if c == '

count = 0
for hbits in range(1<<H):
    for wbits in range(1<<W):
        cs_copy = deepcopy(cs)
        for i in range(H):
            if (1 << i) & hbits:
                for j in range(W):
                    cs_copy[i][j] = 0
        for j in range(W):
            if (1 << j) & wbits:
                for i in range(H):
                    cs_copy[i][j] = 0
        blacks = sum(map(sum, cs_copy))
        if blacks == K:
            count += 1

print(count)

Solution (Python):
import copy
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def is_nth_bit_set(x, n):
    if x & (1 << n):
        return True
    else:
        return False


def count(c, H, W):
    res = 0
    for h in range(H):
        for w in range(W):
            if c[h][w] == "
                res += 1

    return res


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

    ans = 0
    for h_pattern in range(2 ** H):
        for w_pattern in range(2 ** W):
            tmp = copy.deepcopy(C)

            for h in range(H):
                if not is_nth_bit_set(h_pattern, h):
                    continue

                for w in range(W):
                    tmp[h][w] = "r"

            for w in range(W):
                if not is_nth_bit_set(w_pattern, w):
                    continue

                for h in range(H):
                    tmp[h][w] = "r"

            c = count(tmp, H, W)
            if c == K:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

h, w, kk = na()
mp = []
for i in range(h):
    mp.append(ns())

ans = 0
for i in range(1<<h):
    for j in range(1<<w):
        ct = 0
        for k in range(h):
            for l in range(w):
                if i>>k&1:
                    if j>>l&1:
                        if mp[k][l] == "
                            ct += 1
        if ct == kk:
            ans += 1
print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
from copy import deepcopy
h,w,k=map(int,input().split())
c=[list(input().rstrip()) for _ in range(h)]
ans=0

for H in range(2**h):
    for W in range(2**w):
        b=deepcopy(c)
        nowh=bin(H)[2:].zfill(h)
        noww=bin(W)[2:].zfill(w)
        for hi in range(h):
            if nowh[hi]=="1":
                for i in range(w):b[hi][i]="r"
        for wi in range(w):
            if noww[wi]=="1":
                for i in range(h):b[i][wi]="r"
        cnt=0
        for i in b:
            cnt+=i.count("
        if cnt==k:ans+=1
print(ans)

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

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


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    h,w,k = get_nums_l()
    grid_s = [input() for _ in range(h)]

    ans = 0
    for by in range(2**h):
        for bx in range(2**w):
            c = 0

            for y in range(h):
                for x in range(w):
                    if 2**y & by == 0 and 2**x & bx == 0 and grid_s[y][x] == "
                        c += 1

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


main()

Solution (Python):
H,W,K=map(int,input().split())
c=[input() for i in range(H)]
a=0
from itertools import product
for i in product([0,1], repeat=H):
    for j in product([0,1],repeat=W):
        t=0
        for k in range(H):
            for l in range(W):
                if i[k] and j[l] and c[k][l]=="
                    t+=1
        if t==K:
            a+=1
print(a)

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

ans = 0
for bit_h in range(1 << h):
    for bit_w in range(1 << w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (bit_h >> i) & 1 == 1 or (bit_w >> j) & 1 == 1:
                    continue
                if c[i][j] == '
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

H,W,K = map(int,readline().split())
grid = [readline().rstrip() for i in range(H)]
ans = 0
for i in range(2**H):
    for j in range(2**W):
        cnt = 0
        for h in range(H):
            for w in range(W):
                if (i>>h)&1 and (j>>w)&1 and grid[h][w] == '
                    cnt += 1
        if K == cnt:
            ans += 1
print(ans)

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

ans = 0
for bit_state_h in range(1 << h):
    for bit_state_w in range(1 << w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if c[i][j] == "
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
import itertools

h, w, k = map(int, input().split())
c = [input() for i in range(h)]
ans = 0
for i in itertools.product(range(2), repeat=h):
  for j in itertools.product(range(2), repeat=w):
    s = 0
    for x in range(h):
      for y in range(w):
        if c[x][y] == '
          s += 1
    if s == k:
      ans += 1
print(ans)

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

from itertools import product
HS = list(product([0,1], repeat=H))
WS = list(product([0,1], repeat=W))
out = 0
for H1 in HS:
    for W1 in WS:
        cnt = 0
        for i in range(H):
            for j in range(W):
                if H1[i]!=1 and W1[j]!=1 and C[i][j]=="
                    cnt+=1
        if cnt==K:
            out += 1
print(out)

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

ans = 0
for bit_h in range(2 ** H):
    for bit_w in range(2 ** W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (bit_h >> i & 1) and (bit_w >> j & 1) and X[i][j] == "
                    cnt += 1
                    
        ans += int(cnt == K)
        
print(ans)

Solution (Python):
import itertools
H,W,K=map(int,input().split())
c=[list(input()) for i in range(H)]
s=[[0 for j in range(W)] for i in range(H)]
ans=0
for X in itertools.product(range(2),repeat=H):
    for Y in itertools.product(range(2),repeat=W):
        for i in range(H):
            for j in range(W):
                if c[i][j]=="
                    s[i][j]=1
                else:
                    s[i][j]=0
        for i in range(H):
            for j in range(W):
                if X[i]==1 or Y[j]==1:
                    s[i][j]=0
        tmp=0
        for i in range(H):
            for j in range(W):
                if s[i][j]==1:
                    tmp+=1
        if tmp==K:
            ans+=1
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
H, W, K = map(int, input().split())
c = [list(input())[: -1] for _ in range(H)]
res = 0
for i in range(1 << H):
  for j in range(1 << W):
    table = [[c[i][j] for j in range(W)] for i in range(H)]
    t = 0
    for u in range(H):
      for v in range(W):
        if (1 << u) & i or (1 << v) & j: continue
        if c[u][v] == "
    res += t == K
print(res)

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

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

retval=0
for w in itertools.product([0,1],repeat=W):
    for h in itertools.product([0,1], repeat=H):
        _c=deepcopy(c)
        for i,_w in enumerate(w):
            if _w:
                for j in range(H):
                    _c[j][i]=False
        for i,_h in enumerate(h):
            if _h:
                for j in range(W):
                    _c[i][j]=False

        if np.sum(_c)==K:
            retval+=1

print(retval)

Solution (Python):
H, W, K = map(int, input().split())
X = [[1 if a == "
ans = 0
for ii in range(1 << H):
    for jj in range(1 << W):
        if sum([sum([X[i][j] for j in range(W) if jj >> j & 1]) for i in range(H) if ii >> i & 1]) == K:
            ans += 1
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    H,W,K = map(int,input().split())
    grid = [list(input()) for _ in range(H)]
    ans = 0
    for bit in range(1<<H):
        row = [0] * H
        for i in range(H):
            if (bit>>i)&1:
                row[i] = 1
        for bit2 in range(1<<W):
            column = [0] * W
            for i in range(W):
                if (bit2>>i)&1:
                    column[i] = 1
            cnt = 0
            for i in range(H):
                for j in range(W):
                    if row[i] == 1 or column[j] == 1:
                        continue
                    if grid[i][j] == '
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

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

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

ans = 0
for bit1 in range(1<<H):
    for bit2 in range(1<<W):
        c = 0
        for h in range(H):
            for w in range(W):
                if state[h][w] == "
                    c += 1
        if c == K:
            ans += 1
print(ans)

Solution (Python):
h,w,k=map(int, input().split())
grid=[]
for i in range(h):
    grid.append([1 if s=='
ans=0
for i in range(1<<h):
    for j in range(1<<w):
        cnt=0
        for ih in range(h):
            for iw in range(w):
                if (i>>ih)%2==0 and (j>>iw)%2==0 and grid[ih][iw]==1:
                    cnt+=1
        if cnt==k:
            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(1<<h):
  for j in range(1<<w):
    cnt = 0
    for y in range(h):
      if (i>>y)&1:
        continue
      for x in range(w):
        if (j>>x)&1:
          continue
        if c[y][x] == '
          cnt += 1
    if cnt == k:
      ans += 1
print(ans)

Solution (Python):
def main():
    H, W, K = map(int, input().split())
    C = [list(input()) for _ in range(H)]
    def cnt(C, hp, wp):
        c = 0
        for h in range(H):
            if hp & (1 << h):
                continue
            for w in range(W):
                if wp & (1 << w):
                    continue
                if C[h][w] == '
                    c += 1
        return c

    c = 0
    for hp in range(2 ** H):
        for wp in range(2 ** W):
            if cnt(C, hp, wp) == K:
                c += 1
    return c

print(main())

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
h,w,k=map(int,input().split())
C=[list(input()) for _ in range(h)]

ans=0
for i in range(2**h):
  for j in range(2**w):
    ct=0
    for ih in range(h):
      for iw in range(w):
        if i&(1<<ih)==0 and j&(1<<iw)==0 and C[ih][iw]=="
          ct+=1
    if ct==k:
      ans+=1
print(ans)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache





MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b: a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





H,W,K = IL()
data = SLs(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 and data[i][j] == "
          count += 1
    if count == K:
      ans += 1
print(ans)

Solution (Python):
from itertools import product
H, W, K = map(int, input().split())
G = [list(input()) for _ in range(H)]

ans = 0
for h_paint in product((0, 1), repeat=H):
	for w_paint in product((0, 1), repeat=W):
		black = 0
		for h in range(H):
			for w in range(W):
				if h_paint[h] or w_paint[w]:
					continue
				if G[h][w] == '
					black += 1
		if black == K:
			ans += 1

print(ans)