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



Sample input:
2 3 2
..#
###


Sample output:
5

Submission status: Accepted

Solution code:
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] == "#" and (not(bit_state_h & (1 << i))) and (not(bit_state_w & (1 << j))):
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
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] == '#' and i[x] and j[y]:
          s += 1
    if s == k:
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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] == "#": t += 1
    res += t == K
print(res)

Submission status: Accepted

Solution code:
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=="#" for j in input()])

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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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] == "#" and not bit1&(1<<h) and not bit2&(1<<w):
                    c += 1
        if c == K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
h,w,k=map(int, input().split())
grid=[]
for i in range(h):
    grid.append([1 if s=='#' else 0 for s in input()])
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
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)]

######OUTPUT######
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()

#####Shorten#####
def DD(arg): return defaultdict(arg)

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

######Combination######
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

######Factorization######
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

#####MakeDivisors######
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

#####MakePrimes######
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

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

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

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

#####ChangeBase#####
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]

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

#############
# Main Code #
#############

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,w,K = LI()
    c = [list(input()) for i in range(h)]
    for i in range(h):
        for j in range(w):
            if c[i][j] == "#":
                c[i][j] = 1
            else:
                c[i][j] = 0
    n = h+w
    ans = 0
    for b in range(1<<n):
        nc = [[i for i in j] for j in c]
        for i in range(n):
            if (b>>i)&1:
                if i < h:
                    for k in range(w):
                        nc[i][k] = 0
                else:
                    j = i-h
                    for k in range(h):
                        nc[k][j] = 0
        s = sum([sum(i) for i in nc])
        if s == K:
            ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

ans = 0
for R in range(2**H):
  for C in range(2**W):
    n = 0
    for y in range(H):
      if R>>y&1:
        for x in range(W):
          if C>>x&1:
            if c[y][x]=="#":
              n += 1
    if n==K:
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
h, w, kk = map(int, input().split())
c = [[i == "#" for i in input()] for _ in range(h)]
ans = 0
for i in range(2**h):
    for j in range(2**w):
        d =[x[:] for x in c]

        for k in range(h):
            if (i>>k)&1==1:
                for l in range(w):
                    d[k][l] = 0
        
        for k in range(w):
            if (j >> k) & 1 == 1:
                for l in range(h):
                    d[l][k] = 0
        
        if kk == sum(map(sum,d)):
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
H, W, K = map(int, input().split())
c = [input().rstrip() for _ in range(H)]
ans = 0
for biti in range(1 << H):
    for bitj in range(1 << W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if c[i][j] == '#' and not (biti >> i & 1) and not (bitj >> j & 1):
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
h,w,k=map(int,input().split())
ans=0
maze=[input()for i in range(h)]
for i in range(2**h):
    for j in range(2**w):
        tate={c for c in range(h)if (i>>c)%2 }
        yoko={c for c in range(w)if (j>>c)%2 }
        cnt=0
        for x in range(h):
            if x in tate:continue
            for y in range(w):
                if y in yoko:continue
                cnt+=int(maze[x][y]=="#")
        if cnt==k:ans+=1
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
H,W,K=map(int, input().split())
C=[input()for _ in range(H)]
ans=0
for hp in product([True,False], repeat=H):
    for wp in product([True,False], repeat=W):
        cnt = 0
        for h in range(H):
            for w in range(W):
                if C[h][w]=="#" and not hp[h] and not wp[w]:
                    cnt += 1
        if cnt==K:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
H,W,K=map(int,input().split())
S=[input() for i in range(H)]
P=0
Q=0
for i in range(1<<H):
  for j in range(1<<W):
    Q=0
    for k in range(H):
      for l in range(W):
        if S[k][l]=='#' and i&(1<<k)!=0 and j&(1<<l)!=0:
          Q+=1
    if Q==K:
      P+=1
print(P)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip('\n')

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

r = 0
for rows in range(1<<H):
	for cols in range(1<<W):
		bl = 0
		for y, l in enumerate(C):
			if rows & (1<<y): continue

			for x, c in enumerate(l):
				if cols & (1<<x): continue

				if c == '#': bl += 1

		if bl == K:
			r += 1
print(r)

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    H, W, K = map(int, input().split())
    grid = []
    for _ in range(H):
        grid.append(input().rstrip('\n'))

    ans = 0
    for i in range(2**H):
        red_h = [0] * H
        for x in range(H):
            if i >> x & 1:
                red_h[x] = 1
        for j in range(2**W):
            red_w = [0] * W
            for y in range(W):
                if j >> y & 1:
                    red_w[y] = 1
            cnt = 0
            for h in range(H):
                if red_h[h] == 1:
                    continue
                for w in range(W):
                    if grid[h][w] == "#":
                        if red_w[w] == 0:
                            cnt += 1
            if cnt == K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
for i in range(2**H):
    I = []
    for k in range(H):
        if i & (1<<k) > 0:
            I.append(k)
    for j in range(2**W):
        J = []
        for k in range(W):
            if j & (1<<k) > 0:
                J.append(k)
        cnt = 0
        for a in range(H):
            if a in I:
                continue
            for b in range(W):
                if b in J:
                    continue
                if C[a][b] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

h, w, k = MAP()
c = [STR() for _ in range(h)]
ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        cnt = 0
        for y in range(h):
            for x in range(w):
                if c[y][x] == '#' and (i >> y) & 1 and (j >> x) & 1:
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import copy
h, w, K = map(int, input().split())
g = [list(input()) for i in range(h)]
ans = 0
for i in range(2**h):

    i = format(i, "0{}b".format(h))
    for j in range(2**w):
        j = format(j, "0{}b".format(w))

        c = copy.deepcopy(g)
        for k in range(h):
            if i[k] == "1":
                for l in range(w):
                    c[k][l] = "."
        for k in range(w):
            if j[k] == "1":
                for l in range(h):
                    c[l][k] = "."

        count = 0
        for a in range(h):
            for b in range(w):
                if c[a][b] == "#":
                    count += 1

        if count == K:
            ans += 1

print(ans)

Submission status: Accepted

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

for i in range(2**H):
    for j in range(2**W):
        test=0
        for k in range(H*W):
            h=k//W
            w=k%W
            if i>>h&1==0 and j>>w&1==0:
                test+=(c[h][w]=="#")
        ans+=(test==K)

print(ans)

Submission status: Accepted

Solution code:
h,w,k=map(int,input().split())
s=[input()for _ in range(h)]
ans=0
for ib in range(1<<h):
  for jb in range(1<<w):
    cc=0
    for i in range(h):
      if ib&(1<<i):continue
      for j in range(w):
        if jb&(1<<j):continue
        cc+=s[i][j]=="#"
    if cc==k:ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): 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 li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

H, W, K = mi()
C = [input() for i in range(H)]

B_i = 2 ** H
B_j = 2 ** W

ans = 0
for x in range(B_i):
    for y in range(B_j):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (x & (1 << i)) or y & (1 << j):
                    continue
                if C[i][j] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1
                
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    H,W,K=MI()
    C=[]
    for i in range(H):
        c=input()
        C.append(c)
    
    import itertools
    ans=0
    for ite in itertools.product([0,1], repeat=H+W):
        temp=0
        for i in range(H):
            for j in range(W):
                if ite[i]==1 or ite[j+H]==1:
                    pass
                else:
                    if C[i][j]=="#":
                        temp+=1
        if temp==K:
            ans+=1
            
    print(ans)

main()

Submission status: Accepted

Solution code:
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]
ans = 0
for i in range(1<<h):
	for j in range(1<<w):
		cnt = 0
		for x in range(h):
			for y in range(w):
				if (i >> x) & 1 and (j >> y) & 1 and c[x][y] == "#":
					cnt += 1
		if cnt == k:
			ans += 1
print(ans)

Submission status: Accepted

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

c = []
ans = 0

for i in range(H):

    tmp =list(input())
    c.append(tmp)

for i in range(2**H):

    for j in range(2**W):

        now = 0
        for x in range(H):
            for y in range(W):

                if 2**x & i > 0 and 2**y & j > 0:
                    if c[x][y] == "#":
                        now += 1

        if now == K:
            ans += 1

print (ans)

Submission status: Runtime Error

Solution code:
N = int(input())

ans = 0
for i in range(1, N):
    ans += (N-1) // i

print(ans)

Submission status: Runtime Error

Solution code:
H, W, K = map(int, input().split())
lis = []
ans = 0
for i in range(H):
  lis.append(list(map(int, input().split())))
for i in range(1<<H):
  for j in range(1<<W):
    cnt = 0
    for p in range(H):
      for q in range(W):
        if (i>>p) & 1:
          continue
        if (j>>q) & 1:
          continue
        if lis[p][q] == "#":
          cnt += 1
    if cnt == K:
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    H, W, K = map(int, input().split(" "))
    c = [[c for c in input()] for _ in range(H)]
    cnt = 0
    ans = 0
    for i in range(1 << H):
        for j in range(1 << W):
            cnt = 0
            for ii in range(H):
                for jj in range(W):
                    if(i >> ii & 1):
                        continue
                    if(j >> jj & 1):
                        continue
                    if(c[ii][jj] == '#'):
                        cnt += 1
            if cnt == K :
                ans += 1
    print(ans)
    
    
 
if __name__ == "__main__":
    main()
def main():
    H, W, K = map(int, input().split(" "))
    c = [[c for c in input()] for _ in range(H)]
    cnt = 0
    ans = 0
    for i in range(1 << H):
        for j in range(1 << W):
            cnt = 0
            for ii in range(H):
                for jj in range(W):
                    if(i >> ii & 1):
                        continue
                    if(j >> jj & 1):
                        continue
                    if(c[ii][jj] == '#'):
                        cnt += 1
            if cnt == K :
                ans += 1
    print(ans)
    
    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
H, W, K, = list(map(int, input().split()))
C = [0] * H
for i in range(H):
  C[i] = input()
  C[i] = [1 if(C[i][j] == "#") else 0 for j in range(W)]
h = 2 ** H
w = 2 ** W
ans = 0
cnt = 0
for i in range(2 ** H):
  w = 2 ** W
  for j in range(2 ** W):
    cnt = 0
    for k in range(H):
      for l in range(W):
        if(bin(h)[k + 3] == "0" and bin(w)[l + 3] == "0"):
          cnt += D[k][l]
    ans += (cnt == K)
    w += 1
  h += 1
print(ans)

Submission status: Runtime Error

Solution code:
k=int(input())
n=0
for i in range(1,k):
  n=n*10+7
  n=n%k
  if n==0:
    print(i)
    break

Submission status: Runtime Error

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

#H,Wが小さいことが肝
#つまり全通り試してみる

#itertoolのうちpermutationが順列、combinationが組み合わせ
#productが直積

ans=0
import itertools
tf=("Yes", "No")
for l in itertools.product(tf, repeat=(H+W)):
  L=list(l)
black=0
for i in range(2**(H+W)):
  for j in range(H):
    for k in range(W):
      if l[i][j]=="No"and l[i][H+k]=="No"and C[j][k]=="#":
        black+=1
  if black==K:
    ans+=1
    black=0
print(ans)

Submission status: Runtime Error

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

#H,Wが小さいことが肝
#つまり全通り試してみる

#itertoolのうちpermutationが順列、combinationが組み合わせ
#productが直積

ans=0
import itertools
tf=("Yes", "No")
for l in itertools.product(tf, repeat=(H+W)):
  L=list(l)
black=0
for i in range(2**(H+W)):
  for j in range(H):
    for k in range(W):
      if l[i][j]=="No", l[i][H+k]="No", C[j][k]="#":
        black+=1
  if black=K:
    ans+=1
    black=0
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
from typing import List


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

    print(hv(c, h, w, k))


def hv(c: List[List[str]], h: int, w: int, k: int) -> int:
    ret = 0
    for comb_h in itertools.product((False, True), repeat=h):
        for comb_w in itertools.product((False, True), repeat=w):
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if comb_h[i] and comb_w[j] and c[i][j] == '#':
                        cnt += 1
            if cnt == k:
                ret += 1
    return ret


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
H, W, K = map(int, input().split())
fi = []
for _ in range(H):
  s = input()
  fi.append(s)
a = 1 << H
b = 1 << W
total = 0

for i in range(a * b):
  lh = list()
  lw = list()

  for j in range(h):
    if i & (1 << j):
      lh.append(1)
    else:
      lh.append(0)
  for j in range(W):
    if i & (1 << (j + H)):
      lw.append(1)
    else:
      lw.append(0)

  cnt = 0
  for j in range(H):
    for l in range(W):
      if lh[j] == 1 or lw[j] == 1:
        continue
      if fi[j][l] == '#':
        cnt += 1
  if cnt == K:
    total += 1

print(total)

Submission status: Runtime Error

Solution code:
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

H, W, K = list(map(int,input().split()))
S = list(input())
for i in range(H):
    S.extend(list(input()))
n = S.count("#")
r = K
if n<r:
    print(0)
    exit()
else:
    print(cmb(n,r))

Submission status: Runtime Error

Solution code:
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

H, W, K = list(map(int,input().split()))
S = list(map(str,input().split()))
for i in range(H):
    S.extend(list(map(str,input().split())))
n = S.count("#")
r = K
if n<r:
    print(0)
    exit()
else:
    print(cmb(n,r))

Submission status: Runtime Error

Solution code:
import itertools as it
n,m,k=list(map(int,input().split()))
S=[list(str(input())) for h in range(m)]
ans=0
for i in it.product([0,1],repeat=n):
  for j in it.product(range(2),repeat=m):
    count=0
    for h in range(n):
      for c in range(m):
        if S[h][c]=="#" and i[h]+j[c]==0:
          count+=1
    if count==k:
      ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product

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

C = [list(input().split()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt == K:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product

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

C = [list(input() for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == '#' and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt == K:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product

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

C = [list(input().split()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == '#' and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt == K:
                ans += 1
print(ans)