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

def solve(bit1):
    L1 = deepcopy(grid)
    ret = 0
    for i in range(h):
        if bit1[i]:
            L1[i] = ['x'] * w
    for i in range(1 << w):
        bit2 = [0] * w
        for j in range(w):
            if i >> j & 1:
                bit2[j] = 1
        cnt = 0
        L2 = deepcopy(L1)
        for l in range(w):
            if bit2[l]:
                for m in range(h):
                    L2[m][l] = 'x'
        for i in range(h):
            for j in range(w):
                if L2[i][j] == '
                    cnt += 1
        if cnt == k:
            ret += 1
    return ret

h, w, k = map(int, input().split())
grid = list(list(input()) for _ in range(h))
ans = 0
for i in range(1 << h):
    bit1 = [0] * h
    for j in range(h):
        if i >> j & 1:
            bit1[j] = 1
    ans += solve(bit1)
print(ans)

Solution (Python):
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7
sys.setrecursionlimit(10**4)

















 


Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()


def backtrack(cur,cnt):
    if cur == tot:
        tcnt = 0
        row = flag[:n]
        col = flag[n:n+m]
        for i in range(n):
            for j in range(m):
                if row[i] == 1 or col[j] == 1:
                    continue
                elif lis[i][j] == '
                    tcnt+=1
        if tcnt == k:
            cnt[0]+=1
        return 
         
    backtrack(cur+1,cnt)
    flag[cur] = 0
    backtrack(cur+1,cnt)
    flag[cur] = 1
     

n,m,k = Ri()
lis = []
for i in range(n):
    s = ri()
    lis.append(s)

cnt = [0]
flag = [1]*(n+m)
tot = n+m
backtrack(0,cnt)
print(cnt[0])

Solution (Python):
import itertools
H,W,K = map(int,input().split())
c = [input() for _ in range(H)]
res = 0
for ls1 in itertools.product([0,1], repeat=H):
    for ls2 in itertools.product([0,1], repeat=W):
        tmp = 0
        for h in range(H):
            for w in range(W):
                if c[h][w] == '
                    tmp += 1
        if tmp==K:
            res += 1
print(res)

Solution (Python):
from collections import Counter

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

cnt = 0
for h in range(2**H):
    h_list = []
    for _ in range(H):
        h_list.append(h%2)
        h //= 2
    for w in range(2**W):
        w_list = []
        for _ in range(W):
            w_list.append(w%2)
            w //= 2
        tmp = []
        
        for i in range(H):
            for j in range(W):
                if h_list[i] == 0 and w_list[j] == 0:
                    tmp.append(c[i][j])
        
        tmp = Counter(tmp)
        if tmp['
            cnt += 1
print(cnt)

Solution (Python):
import itertools

h,w,k = map(int,input().split())
ab = []
for _ in range(h):
    s=list(input())
    ab.append(s)

tate = []
yoko = []
 
for i in range(h):
    tate.append(i)

for i in range(w):
    yoko.append(i)

ans = 0

for i in range(h+1):
    for j in range(w+1):
        for v in itertools.combinations(tate, i):
            for vv in itertools.combinations(yoko, j):
                memo = 0
                for tt in range(h):
                    if tt in v:
                        continue
                    for yy in range(w):
                        if yy in vv:
                            continue
                        if ab[tt][yy] == '
                            memo += 1
                if memo == 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):
        CC = copy.deepcopy(C)
        tmp = 0
        for i in range(H):
            if (h >> i) & 1:
                for j in range(W):
                    CC[i][j] = 'R'
        for i in range(W):
            if (w >> i) & 1:
                for j in range(H):
                    CC[j][i] = 'R'
        for i in range(H):
            for j in range(W):
                if CC[i][j] == '
                    tmp += 1
        if tmp == K:
            ans += 1
            

print(ans)

Solution (Python):



H, W, K = map(int, input().split())
board = [['']*W for i in range(H)]
for i in range(H):
    s = list(input())
    for j in range(W):
        board[i][j] = s[j]


h_pattern = []
w_pattern = []
for i in range(2**H):
    p = [0]*H
    for j in range(H):
        if (i>>j)&1==1:
            p[j] = 1
    h_pattern.append(p)
for i in range(2**W):
    p = [0]*W
    for j in range(W):
        if (i>>j)&1==1:
            p[j] = 1
    w_pattern.append(p)


ans = 0



for h_p in h_pattern:
    for w_p in w_pattern:
        
        tmp = 0
        for i in range(H):
            if h_p[i]==0:
                for j in range(W):
                    if w_p[j]==0 and board[i][j]=='
                        tmp += 1
        
        if tmp==K:
            ans += 1


print(ans)

Solution (Python):
n, m, k = map(int, input().split())
mat = [list(input()) for _ in range(n)]
t = 0
for b in range(1<<(n+m)):
    c = 0
    for i in range(n):
        for j in range(m):
            if mat[i][j] == "
                c += 1
    if c == k:
        t += 1
print(t)

Solution (Python):
from sys import stdin
import numpy as np
import copy
from itertools import combinations
H,W,K = [int(x) for x in stdin.readline().rstrip().split()]
C = []
for i in range(H):
    c = list(input())
    C.append(c)

ans = 0

for h in range(0,H+1):
    for w in range(0,W+1):
        for i in combinations(range(0,H),h):
            for j in combinations(range(0,W),w):
                tmp = copy.deepcopy(C)
                tmp = np.array(tmp)
                for k in i:
                    tmp[k,] = "."
                for l in j:
                    tmp[:,l] = "."
                if np.sum(tmp == "
                    ans += 1
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):
        cnt = 0
        x = format(i, "b").zfill(h)
        y = format(j, "b").zfill(w)
        for xi in range(h):
            for yi in range(w):
                if x[xi] == "0" and y[yi] == "0":
                    if c[xi][yi] == "
                        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 += [input()]
ans = 0
for i in range(2**(w+h)):
    count = 0
    for y in range(h):
        for x in range(w):
            if c[y][x] == '
                count += 1
    if count == k:
        ans += 1
print(ans)

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

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

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

H, W, K = ri_()
c = [list(rs()) for _ in range(H)]
ans = 0
for bit in range(1<<H):
    for bitr in range(1<<W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if not (bit & (1 << i)):
                    if not (bitr & (1 << j)):
                        if c[i][j] == '
                            cnt += 1
        if cnt == K:
            ans += 1
print(ans)

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


ans=0
for x2 in range(2**(h+w)):
  x=format(x2, 'b')
  x=(h+w-len(x))*'0'+x
  co=0
  for i in range(h):
    if x[i]=='0':
      for j in range(w):
        if x[h+j]=='0' and c[i][j]=='
          co+=1
  if co==k:
    ans+=1
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10**6)

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

c = [0]*w
r = [0]*h

def count(hc, wc):
    ans = 0
    for i in range(h):
        for j in range(w):
            if l[i][j] == "
                ans += 1
    return ans

ans = 0
for i in range(2**h):
    for j in range(2**w):
        if count(i, j) == k:
            ans += 1
print(ans)

Solution (Python):
import itertools

H,W,K = [int(i) for i in input().split()]
c = []
for _ in range(H):
    a = list(input())
    a = [1 if i == "
    c.append(a)
ans = 0
for i in range(H+1):
    for j in range(W+1):
        for A in itertools.combinations(range(H), i):
            for B in itertools.combinations(range(W),j):
                s = 0
                for k in A:
                    for l in B:
                        s += c[k][l]
                if s == K:
                    ans += 1
print(ans)

Solution (Python):

import sys
from itertools import product


def solve(H, W, K, C):
    cnt = 0
    L1 = list(product([True, False], repeat=H))
    L2 = list(product([True, False], repeat=W))
    for l1 in L1:
        for l2 in L2:
            num = 0
            for i in range(H):
                if not l1[i]:
                    continue
                for j in range(W):
                    if not l2[j]:
                        continue
                    num += C[i][j]
            if num == K:
                cnt += 1
    print(cnt)
    return


def main():
    
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))
    W = int(next(tokens))
    K = int(next(tokens))
    C = [[0 for _ in range(W)] for _ in range(H)]
    for i in range(H):
        col = next(tokens)
        for j in range(W):
            C[i][j] = 1 if col[j] == "
    solve(H, W, K, C)

if __name__ == '__main__':
    main()

Solution (Python):
import copy
import itertools

import numpy as np

H, W, K = map(int, input().split())
C = np.array([list(input()) for _ in range(H)])
F = np.zeros([H, W], dtype=np.int64)

for i in range(H):
    for j in range(W):
        if C[i][j] == "
            F[i][j] = 1


cnt = 0
for i in itertools.product(range(2), repeat=H):
    f = copy.deepcopy(F)

    ii = np.arange(H)[np.array(i) == 1]

    f[ii] = 0

    for j in itertools.product(range(2), repeat=W):
        jj = np.arange(W)[np.array(j) == 1]
        ff = copy.deepcopy(f)
        ff[:, jj] = 0
        if np.sum(ff) == K:
            cnt += 1

print(cnt)

Solution (Python):

import itertools as it



def main():
    H, W, K = map(int,input().split(" "))
    S = [[int(_) for _ in input().replace("
    

    kw = []
    for i in range(1,W+1):
        kw += list(it.combinations(range(W),i))
    kh = []
    for i in range(1,H+1):
        kh += list(it.combinations(range(H),i))

    def slice(w,h):
        r = 0
        for w_ in w:
            for h_ in h:
                r += S[h_][w_]
        return r

    ans=0
    for iw in kw:
        for ih in kh:
            if slice(iw,ih) == K: ans+=1
                
    print(ans)
    return

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

H, W, K = [int(s) for s in input().split()]

c_mat = []

for _ in range(H):
    row = input()
    cs = []
    
    for j in range(W):
        if row[j] == ".":
            cs.append(0)
        else:
            cs.append(1)


    c_mat.append(cs)

c_np = np.array(c_mat, dtype=np.int)


count = 0


for h in range(2**H):
    for w in range(2**W):
        c_np_tmp = np.copy(c_np)

        for i in range(H):
            if (h >> i) % 2 == 1:
                c_np_tmp[i, :] = 0

        for j in range(W):
            if (w >> j) % 2 == 1:
                c_np_tmp[:, j] = 0

        if c_np_tmp.sum() == K:
            count += 1

print(count)

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

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

ans = 0
for h in range(2**H):
    h = "{:06b}".format(h)[-H:]
    for w in range(2**W):
        w = "{:06b}".format(w)[-W:]

        cnt = 0
        for i in range(len(h)):
            for j in range(len(w)):
                if h[i] == "0" and w[j] == "0":
                    if 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(' '))
C = []
ans = 0

for _ in range(H):
    row = input()
    C.append([el for el in row])

for h in range(2**H):
    for w in range(2**W):
        h_red = str(bin(h)).lstrip("0b").zfill(H)
        w_red = str(bin(w)).lstrip("0b").zfill(W)
        table = deepcopy(C)
        num_black = 0
        for i, f in enumerate(h_red):
            if f == '1':
                table[i] = ['r' for _ in range(W)]
        for i, f in enumerate(w_red):
            if f == '1':
                for s in table:
                    s[i] = 'r'
        for s in table:
            num_black += s.count('
        if num_black == K:
            ans += 1

print(ans)

Solution (Python):
import copy
h,w,k=map(int,input().split())
c=[None]*h
for i in range(h):
  c[i]=list(input())
ans=0
for i1 in range(2**h):
  for i2 in range(2**w):
    tmp=copy.deepcopy(c)
    b=0
    for j1 in range(h):
      for j2 in range(w):
      	if not ((i1 >> j1) & 1) and not ((i2 >> j2) & 1):
          if c[j1][j2]=='
            b+=1
    if b==k:
      ans+=1
print(ans)

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

A = []
for _ in range(H):
    A.append(input())

hrange = list(range(H))
wrange = list(range(W))

def check(hvs, wvs):
    c = 0
    for i in range(H):
        if i in hvs:
            continue
        for j in range(W):
            if j in wvs:
                continue
            if A[i][j] == "
                c += 1
    return c

res = 0
from itertools import combinations
for h in range(H):
    for w in range(W):
        for hv in combinations(hrange, h):
            for wv in combinations(wrange, w):
                if check(hv, wv) == K:
                    res += 1
print(res)

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

def f(x):
    x = bin(x)
    ans = []
    l = len(x)
    for i in range(l):
        if x[l-1-i]=='1':
            ans.append(i)
    return ans

ans = 0
for i in range(2**H):
    for j in range(2**W):
        tmp = 0
        I = f(i)
        J = f(j)
        for x in range(H):
            for y in range(W):
                if (x not in I) and (y not in J) and c[x][y]=='
                    tmp += 1
        if tmp==K:
            ans += 1
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)
from bisect import bisect_left


def read():
    H, W, K = map(int, input().strip().split())
    C = [["." for j in range(W)] for i in range(H)]
    for i in range(H):
        c = list(input().strip())
        for j in range(W):
            C[i][j] = c[j]
    return H, W, K, C


def solve(H, W, K, C):
    ans = 0
    D = [["." for j in range(W)] for i in range(H)]

    for p in range(1<<H):
        for q in range(1<<W):
            
            for i in range(H):
                for j in range(W):
                    D[i][j] = C[i][j]
            
            
            for i in range(H):
                if (p >> i) & 1 == 1:
                    for j in range(W):
                        D[i][j] = "."
            for j in range(W):
                if (q >> j) & 1 == 1:
                    for i in range(H):
                        D[i][j] = "."
            
            
            count = 0
            for i in range(H):
                for j in range(W):
                    if D[i][j] == "
                        count += 1
            if count == K:
                ans += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):




def input_int():
    return int(input())



def int1(x):
    return int(x) - 1



def input_to_int_map():
    return map(int, input().split())



def input_to_int_tuple():
    return tuple(map(int, input().split()))



def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


import itertools
def main():
    h, w, k = input_to_int_map()
    table = [input() for i in range(h)]

    ans = 0
    for row in itertools.product("01", repeat=h):
        row_target = []
        for ir, r in enumerate(row):
            if r == "0":
                row_target.append(ir)
        for column in itertools.product("01", repeat=w):
            col_target = []
            for ic, c in enumerate(column):
                if c == "0":
                    col_target.append(ic)

            cnt = 0
            for i in row_target:
                for j in col_target:
                    if table[i][j] == "
                        cnt += 1

            if cnt == k:
                ans += 1

    return ans


if __name__ == "__main__":
    print(main())

Solution (Python):
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    h, w, k = map(int, input().split())
    masu = [list(input()) for i in range(h)]
    ans = 0
    for i in range(w+1):
        for k1 in itertools.combinations(range(w), i):
            for j in range(h+1):
                for k2 in itertools.combinations(range(h), j):
                    sushi = 0
                    for y in k2:
                        for x in k1:
                            if masu[y][x] == "
                                sushi += 1
                    if sushi == k:
                        ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
H, W, K = map(int, input().split())
grid = [[c for c in str(input())] for _ in range(H)]
ans = 0
from itertools import product
for rarr in product(range(2), repeat=H):
    for carr in product(range(2), repeat=W):
        bk = 0
        for i in range(H):
            if rarr[i] == 0: continue
            for j in range(W):
                if carr[j] == 0: continue
                if grid[i][j] == '
        if bk == K:
            ans += 1
print(ans)

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

ans = 0

for h in itertools.product([0, 1], repeat=H):
    for w in itertools.product([0, 1], repeat=W):
        
        count = 0
        for i in range(H):
            for j in range(W):
                if h[i] == 0 and w[j] == 0:
                    if S[i][j] == "
                        count += 1
        
        if count == K:
            ans += 1

print(ans)

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

g = [[0] * w for _ in range(h)]
for i in range(h):
    li = list(input())
    for j in range(len(li)):
        if li[j] == '
            g[i][j] = 1
ans = 0
for i in range(2<<h):
    for j in range(2<<w):
        gg = deepcopy(g)
        for k in range(h):
            for l in range(w):
                if ((i>>k)&1):
                    for mm in range(w):
                        gg[k][mm] = 0
                if ((j>>l)&1):
                    for m in range(h):
                        gg[m][l] = 0
        sum_ = 0
        for kk in range(h):
            for ll in range(w):
                sum_ += gg[kk][ll]
        if sum_ == K:
            ans += 1
print(ans//4)

Solution (Python):
import copy
h,w,k=map(int,input().split())
c=[[[".","
l=0
for i in range(2**h):
    for j in range(2**w):
        x,y=bin(i)[2:].zfill(h),bin(j)[2:].zfill(w)
        a,b=[],[]
        for p in range(h):
            if x[p]=="1":
                a+=[p]
        for p in range(w):
            if y[p]=="1":
                b+=[p]
        d=copy.deepcopy(c)
        for x in a:
            d[x]=[2]*w
        for x in b:
            for y in range(h):
                d[y][x]=2
        p=[]
        for x in d:
            p+=x
        l+=(k==p.count(1))
print(l)

Solution (Python):


import math; from collections import *
import sys; from functools import reduce


def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def get_string(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9)+7; SEXYMOD = 998244353; MAXN = int(1e5)
import copy



r, c, k = get_ints()
matr = []
for i in range(r):
    matr.append(list(input()))
ans = 0
for i in range(2**r):
    for j in range(2**c):
        matrc = copy.deepcopy(matr)
        ii = bin(i)[2:].zfill(r)
        for indu in range(r):
            if ii[indu] == '1':
                matrc[indu] = ['r'] * c
        jj = bin(j)[2:].zfill(c)
        for indu in range(c):
            if jj[indu] == '1':
                for jks in range(r):
                    matrc[jks][indu] = 'r'
        temp = 0
        for ud in range(r):
            for it in range(c):
                if matrc[ud][it] == '
                    temp += 1
        if temp == k:
            ans += 1
        
        
        
print(ans)
        


'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

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

ans=0

for i in range(2**h):
    for j in range(2**w):
        temph=format(i, '06b')
        tempw=format(j, '06b')
        temp=0
        for x in range(h):
            for l in range(w):
                
                
                if temph[-1-x]=='0' and tempw[-1-l]=='0' and c[x][l]=='
                    temp += 1
        
        if temp==k:
            ans+=1

print(ans)

Solution (Python):


def countb(h, w, mskh, mskw, s):
    ret=0
    for i in range(w):
        for j in range(h):
            if (2**i)&mskw == 0 and (2**j)&mskh == 0:
                ret += 1 if s[j][i] == "
    return ret

def main(h,w,k,s):
    ans=0
    for i in range(2**w):
        for j in range(2**h):
            ans += 1 if countb(h, w, j, i, s)==k else 0

    print(ans)
    return

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h, w, K = LI()
c = [list(input()) for _ in range(h)]
count = 0
for i in range(h):
    for j in range(w):
        if c[i][j] == '
            count += 1
ans = 0
for i in range(1 << h):
    f = defaultdict(lambda : 0)
    cnt = count
    for k in range(h):
        if i >> k & 1:
            for l in range(w):
                if c[k][l] == "
                    f[(k, l)] = 1
                    cnt -= 1
    for j in range(1 << w):
        cnt2 = cnt
        f2 = defaultdict(lambda : 0)
        for k, l in f.items():
            if l == 1:
                f2[k] = 1
        for k in range(w):
            if j >> k & 1:
                for l in range(h):
                    if c[l][k] == "
                        f2[(l, k)] = 1
                        cnt2 -= 1
        if cnt2 == K:
            ans += 1
print(ans)

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

ans = 0
for bith in product([0, 1], repeat=h):
    for bitw in product([0, 1], repeat=w):
        ss = copy.deepcopy(s)
        tmp = 0
        for i, bh in enumerate(bith):
            for j, bw in enumerate(bitw):
                if bh == 1 or bw == 1:
                    ss[i][j] = 'o'
        for i in range(h):
            for j in range(w):
                if ss[i][j] == '
                    tmp += 1
        if tmp == k:
            ans += 1
print(ans)

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")



def main():
    H, W, K = map(int, input().split())
    C = [list(input()[:-1]) for _ in range(H)]
    black = 0
    for i in range(H):
        for j in range(W):
            if C[i][j] == "
                black += 1
    
    ans = 0
    for n in range(2**H):
        for m in range(2**W):
            tmp = black
            used = [[False]*W for _ in range(H)]
            for h in range(H):
                if n & (1 << h):
                    for j in range(W):
                        if C[h][j] == "
                            tmp -= 1
                            used[h][j] = True
            for w in range(W):
                if m & (1 << w):
                    for i in range(H):
                        if C[i][w] == "
                            tmp -= 1
                            used[i][w] = True
            if tmp == K:
                ans += 1
    
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import itertools

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


def is_valid(xs, ys):
    k = 0
    for i in range(1, H + 1):
        if i in ys:
            continue
        for j in range(1, W + 1):
            if j in xs:
                continue
            if C[i - 1][j - 1] == '
                k += 1
    return k == K


ans = 0
for i in range(0, H + 1):
    for j in range(0, W + 1):
        for ys in itertools.combinations(range(1, H + 1), i):
            for xs in itertools.combinations(range(1, W + 1), j):
                if is_valid(xs, ys):
                    ans += 1

print(ans)

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

ans = 0
for x in range(2**W):
    for y in range(2**H):
        m = [[False for _ in range(W)] for _ in range(H)]

        for xi in range(W):
            if ((x >> xi) & 1):
                for i in range(H):
                    m[i][xi] = True

        for yi in range(H):
            if ((y >> yi) & 1):
                for i in range(W):
                    m[yi][i] = True
        
        count = 0
        for i in range(W):
            for j in range(H):
                if C[j][i] == "
                    count += 1
        if count == K:
            ans += 1
print(ans)

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

result = 0

for i in range(2 ** H):
    h = str(format(i, 'b')).zfill(H)
    for j in range(2 ** W):
        w = str(format(j, 'b')).zfill(W)
        count = 0
        for k in range(H):
            for l in range(W):
                if c[k][l] == "
                    count += 1
        if count == K:
            result += 1

print(result)

Solution (Python):






import itertools

import numpy as np

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

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

for h in range(H):
    cs = input().strip()
    for w in range(W):
        C[h, w] = 1 if cs[w] == "

count = 0

for max_h in range(H + 1):
    for max_w in range(W + 1):
        for hs in itertools.combinations(range(H), max_h):
            for ws in itertools.combinations(range(W), max_w):

                tmp = np.array(C)

                for h in hs:
                    for w in range(W): tmp[h, w] = 0

                for w in ws:
                    for h in range(H): tmp[h, w] = 0

                if int(np.sum(tmp)) == K:
                    count += 1

print(count)