Harryxun/stf_run huggingface dataset:
n,q=map(int,input().split())
G=[[]*n for i in range(n)]
P=[0]*n
V=[0]*n
R=[0]*n
for i in range(n-1):
	a,b=map(int,input().split())
	G[a-1].append(b-1)
	G[b-1].append(a-1)
for i in range(q):
	c,d=map(int,input().split())
	P[c-1]+=d

def dsf(i,p):
    V[i]=1
    R[i]+=p+P[i]
    p=0
    if G[i]!=[]:
        for j in G[i]:
            if V[j]!=1:
                dsf(j,R[i])
dsf(0,0)
print(' '.join(map(str,R)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
s=sys.stdin.readlines()
n,q=map(int,s[0].split())
G=[[]*n for i in range(n)]
P=[0]*n
V=[0]*n
R=[0]*n
for e in s[1:n]:
    a,b=map(int,e.split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for e in s[n:]:
    c,d=map(int,e.split())
    P[c-1]+=d

def dsf(i,p):
    V[i]=1
    R[i]+=p+P[i]
    p=0
    for j in G[i]:
        if V[j]!=1:
            dsf(j,R[i])
dsf(0,0)
print(' '.join(map(str,R)))
import math
import itertools

a,b=map(int,input().split())
X = [[int(i) for i in input().split()] for i in range(a)] 
#for i in range():
c = list(itertools.combinations(X, 2))


ans = 0

for i in range(len(c)):
  d = 0
  for j in range(b):
    d += (c[i][0][j]-c[i][1][j])**2
    if j == b-1:
      d = math.sqrt(d)
      if d.is_integer():
        ans = ans+1

print(ans)



### FIXED CODE ###

a,b,c=map(int,input().split())
m = a*b
n = c
if m<=n:
  print(m)
  
else:
  print(n)
H, W = map(int, input().strip().split())
S = [input().strip() for _ in range(H)]
visited = [[False for _ in range(W)] for _ in range(H)]

def dfs(_i, _j, _S, _visited, _fs):
  if _i<H-1 and not _visited[_i+1][_j] and S[_i][_j]!=S[_i+1][_j]:
    if S[_i+1][_j] == '.':
      _fs.add((_i+1, _j))
    _visited[_i+1][_j] = True
    _fs |= dfs(_i+1, _j, _S, _visited, _fs)
    _visited[_i+1][_j] = False
  if _i>0 and not _visited[_i-1][_j] and S[_i][_j]!=S[_i-1][_j]:
    if S[_i-1][_j] == '.':
      _fs.add((_i-1, _j))
    _visited[_i-1][_j] = True
    _fs |= dfs(_i-1, _j, _S, _visited, _fs)
    _visited[_i-1][_j] = False
  if _j<W-1 and not _visited[_i][_j+1] and S[_i][_j]!=S[_i][_j+1]:
    if S[_i][_j+1] == '.':
      _fs.add((_i, _j+1))
    _visited[_i][_j+1] = True
    _fs |= dfs(_i, _j+1, _S, _visited, _fs)
    _visited[_i][_j+1] = False
  if _j>-0 and not _visited[_i][_j-1] and S[_i][_j]!=S[_i][_j-1]:
    if S[_i][_j-1] == '.':
      _fs.add((_i, _j-1))
    _visited[_i][_j-1] = True
    _fs |= dfs(_i, _j-1, _S, _visited, _fs)
    _visited[_i][_j-1] = False
  return _fs

ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      fs = set()
      visited[i][j] = True
      fs = dfs(i, j, S, visited, fs);
      ans += len(fs)
      for k in range(H):
        for l in range(W):
          visited[k][l] = False
          
print(ans)

### FIXED CODE ###

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

visited = [[False for _ in range(w)] for _ in range(h)]

ans = 0
for i in range(h):
  for j in range(w):
    if visited[i][j]:
      continue
    bc = 0
    wc = 0
    visited[i][j] = True
    node = [(i, j)]
    while node:
      ci, cj = node[0]
      node = node[1:]
      if s[ci][cj] == '#':
        bc += 1
      else:
        wc += 1
      if ci - 1 >= 0 and s[ci][cj] != s[ci-1][cj]:
        if not visited[ci-1][cj]:
          visited[ci-1][cj] = True
          node.append((ci-1, cj))
      if ci + 1 <= h-1 and s[ci][cj] != s[ci+1][cj]:
        if not visited[ci+1][cj]:
          visited[ci+1][cj] = True
          node.append((ci+1, cj))
      if cj - 1 >= 0 and s[ci][cj] != s[ci][cj-1]:
        if not visited[ci][cj-1]:
          visited[ci][cj-1] = True
          node.append((ci, cj-1))
      if cj + 1 <= w-1 and s[ci][cj] != s[ci][cj+1]:
        if not visited[ci][cj+1]:
          visited[ci][cj+1] = True
          node.append((ci, cj+1))
    ans += bc * wc

print(ans)
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    s = []
    for i in range(N):
        tmp = inputInt()
        s.append(tmp)
        
    ans = 0
    indexx = 2**100
    for i in range(indexx):
        ten = 0
        for j in range(100):
            tmp = i >> j
            if 1 == tmp & 1:
                ten += s[j]
        
        if ten % 10 == 0:
            ten = 0
        
        if ans < ten:
            ans = ten
            
    print(ans)
        
        
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    s = []
    flg = False
    onry = False
    tmp_max = 0
    tmp_arr = []
    for i in range(N):
        tmp = inputInt()
        s.append(tmp)
        if tmp % 10 != 0:
            tmp_max += tmp
            tmp_arr.append(tmp)
            flg = True
            if onry == False:
                onry = True
            else:
                onry = None
            
    if flg == False:
        print(0)
        sys.exit()
        
    if onry == True or tmp_max % 10 != 0:
        print(sum(s))
        sys.exit()
        
    print(sum(s)-min(tmp_arr))
        
        
if __name__ == "__main__":
	main()
N,K=map(int,input().split())
a = 0
while R <= N:
  N = N // R
  a +=a
 
print(a)

### FIXED CODE ###

N,K=map(int,input().split())
a = 1
while K <= N:
  N = N // K
  a =a+1
  
print(a)
File Edit Options Buffers Tools YASnippet Complete In/Out Signals Help                                                                     
l = raw_input()
flag = False
if len(l) == 7:
    if l == "keyence":
        flag = True
elif len(l) == 8:
    for i in range(8):
        tmp = l[:i] + l[i+1:]
        if tmp == "keyence":
            flag = True
else:
    flag = False
if flag == True:
    print "YES"
else:
    print "NO"


### FIXED CODE ###

l = raw_input()
flag = False
if len(l) >= 6:
    for i in range(7):
        tmp = l[0:i] + l[-7+i:]
        if tmp == "keyence":
            flag = True
if flag == True:
    print "YES"
else:
    print "NO"
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    max_value = max(A)
    max_index = A.index(max_value)

    for i in range(N):
        if i != max_index:
            print(max_value)
        else:
            if i == 0:
                print(max(A[1:]))
            elif i == N:
                print(max(A[:N]))
            else:
                print(max(max(A[:i]), max(A[i + 1 :])))

    return


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    max_value = max(A)
    max_index = A.index(max_value)

    for i in range(N):
        if i != max_index:
            print(max_value)
        else:
            if i == 0:
                print(max(A[1:]))
            elif i == N - 1:
                print(max(A[: N - 1]))
            else:
                print(max(max(A[:i]), max(A[i + 1 :])))

    return


if __name__ == "__main__":
    main()
n=int(input())
li=list(map(int,input().split()))
li.sort()
li2=[]
for i in range(len(li)+1):
    li2.append(li.count(i+1))
for s in li2:
    print(s)

### FIXED CODE ###

r=int(input())
x=2*r*3.14159265358979323846
print(x)
X, Y = map(int, input().split())

if (2*X-Y)%3:
    print(0)
else:
    a = (2*X-Y)//3
    b = X-2*a

    MOD = 10**9+7
    n = a+b+1
    fac = [1]*(n+1)
    rev = [1]*(n+1)
    
    for i in range(1,n+1):
        fac[i] = i*fac[i-1]%MOD
        rev[i] = pow(fac[i], MOD-2, MOD)
    comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD

    print(comb(a+b, a))

### FIXED CODE ###

X, Y = map(int, input().split())

mod = 10**9+7
N = 1333334
fac = [1]*(N+1)
rev = [1]*(N+1)
 
for i in range(1,N+1):
  fac[i] = i*fac[i-1]%mod
  rev[i] = pow(fac[i], mod-2, mod)
 
comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%mod

a, b = (2*X-Y)//3, (2*Y-X)//3
if a<0 or b<0 or (2*X-Y)%3 or (2*Y-X)%3:
    print(0)
else:
    print(comb(a+b, a))
a, b = map(int, raw_input().split())
print(a*b,' ',2*(a+b))

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b,2*(a+b))
import sys
import heapq


def dfs(u,s,target, vs):
    vs[u] = 1
    if(u == target):
        global h
        heapq.heappush(h,s)
        return
    for j in range(e):
        if(e_1[j] == u):
            if(vs[e_2[j]] != 1):
                count = s + e_w[j]
                print(s,e_2[j],vs)
                dfs(e_2[j],count,target,vs[0:])

def dijsktra(start, v, e):
    d = [0]*v
    prev = [0]*v
    v_q=[];

    INF = 9999999999999999999
    for u in range(v):
        if(u != start):
            d[u] = INF
        else:
            d[u] = 0 
        prev[u] = -1

    heapq.heappush(v_q,(0,start))
    heapq.heappush(v_q,(INF,0))
    

    while(True):
        cost,u = heapq.heappop(v_q)
        if(cost > d[u]):
            continue
        if(cost == INF):
            break
        for j in range(e):
            if(u == e_1[j]):
                alt = d[u]+e_w[j]
                if(d[e_2[j]] > alt):
                    d[e_2[j]] = alt
                    prev[e_2[j]] = u
                    heapq.heappush(v_q,(alt,e_2[j]))
    for i in range(v):
        if(d[i] != INF):
            print(d[i])
        else:
            print("INF")

v,e,r=map(int, input().split());

e_1=[0]*e;
e_2=[0]*e;
e_w=[0]*e;

for i in range(e):
    e_1[i], e_2[i], e_w[i] = map(int, input().split());

dijsktra(r,v,e)



### FIXED CODE ###

import sys
from collections import deque

v,e,r=map(int, input().split());

edge_info=[0]*v;
for i in range(v):
    edge_info[i] = []

for i in range(e):
    e1, e2, w = map(int, input().split());
    edge_info[e1].append((e2,w))

v_q=deque();

INF = 9999999999999999999
d = [INF for i in range(v)]
d[r] = 0
v_q.append((0,r))
while(len(v_q) != 0):
    cost,u = v_q.popleft()
    if(cost > d[u]):
        continue
    for j in range(len(edge_info[u])):
        e2,w = edge_info[u][j]
        alt = cost+w
        if(d[e2] > alt):
            d[e2] = alt
            v_q.append((alt,e2))

for i in range(v):
    if(d[i] != INF):
        print(d[i])
    else:
        print("INF")
def read_data():
  n=input()
  x=[]
  for i in range(10): x.append(map(int,raw_input().split()))
  return n, x

def is_area3(x,y):
  if x>7 or y>5: return False
  for dx in [0,1,2,1,0]:
    A=P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y+=1
  return True
      
def is_area2(x,y):
  if x>7 or y>7: return False
  for dy in [0,1,2]:
    A=P[y+dy][x:x+3]
    if A.count(0)>0: return False
  return True

def is_area1(x,y):
  if x>8 or y>7: return False
  for dx in [0,1,0]:
    A=P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y+=1
  return True

def ink(x,y,s,m):
  global P
  dx = [0,1,-1,0,0,1,1,-1,-1,2,-2,0,0]
  dy = [0,0,-0,1,-1,1,-1,1,-1,0,0,2,-2]
  for i in range([5,9,13][s-1]):
    P[y+dy[i]][x+dx[i]]+=m
  return

drops,P = read_data()
A=[]
i=-1
m=3
while i<99:
  i+=1
  y=i/10
  x=i%10
  if P[y][x]==0: continue

  if m==3:
    while is_area3(x,y):
      A.append([x,y,3])
      ink(x,y+2,3,-1)
    if P[y][x]==0:
      m=3
      continue
    else: m=2

  if m==2:
    while is_area2(x,y):
      A.append([x,y,2])
      ink(x+1,y+1,2,-1)
    if P[y][x]==0:
      m=3
      continue
    else: m=1

  if m==1:
    while is_area1(x,y):
      A.append([x,y,1])
      ink(x,y+1,1,-1)
    if P[y][x]==0:
      m=3
      continue
    else: m=0

  dx=[0,1,0]
  dy=[1,1,2]
  if m==0 and len(A)>0:
    x,y,m=A.pop()
    m-=1
    ink(x+dx[m],y+dy[m],m+1,1)
    i = y*10+x-1
  else:
    break
if drops <=12 and len(A)==drops:
  for x,y,s in A: print x+dx[s-1],y+dy[s-1],s

### FIXED CODE ###

def read_data():
  n=input()
  x=[]
  for i in range(10):
    x.append(map(int,raw_input().split()))
  return n, x
 
def is_area3(x,y):
  if x>7 or y>5: return False
  for dx in [0,1,2,1,0]:
    A = P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y += 1
  return True
       
def is_area2(x,y):
  if x>7 or y>7: return False
  for dy in [0,1,2]:
    A = P[y+dy][x:x+3]
    if A.count(0)>0: return False
  return True
 
def is_area1(x,y):
  if x>8 or y>7: return False
  for dx in [0, 1, 0]:
    A = P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y += 1
  return True
 
def ink(x,y,s,m):
  global P
  dx = [0,1,-1,0,0,1,1,-1,-1,2,-2,0,0]
  dy = [0,0,-0,1,-1,1,-1,1,-1,0,0,2,-2]
  for i in range([5,9,13][s-1]):
    P[y+dy[i]][x+dx[i]]+=m
  return
 
drops, P = read_data()
M=[]
i=-1
step =3
while i<99:
  i+=1
  y = i / 10
  x = i % 10
  if P[y][x]==0: continue
 
  if step==3:
    while is_area3(x,y):
      M.append([x,y,3])
      ink(x,y+2,3,-1)
    if P[y][x]==0:
      step = 3
      continue
    else: step = 2
 
  if step==2:
    while is_area2(x,y):
      M.append([x,y,2])
      ink(x+1,y+1,2,-1)
    if P[y][x]==0:
      step = 3
      continue
    else: step = 1
 
  if step==1:
    while is_area1(x,y):
      M.append([x,y,1])
      ink(x,y+1,1,-1)
    if P[y][x]==0:
      step = 3
      continue
    else: step = 0
 
  dx=0
  dy=1
  if step==0 and len(M)>0:
    x,y,tmp = M.pop()
    if tmp==3: dy=2
    elif tmp==2: dx=1
    ink(x+dx,y+dy,tmp,1)
    i = y*10+x-1
    step = tmp-1
  else: break
if drops <=12 and len(M)==drops:
  for x,y,s in M:
    dx=0
    dy=1
    if s==3: dy=2
    elif s==2: dx=1
    print x+dx,y+dy,s
if Y=n:
    z=n-1
    X＞n+(n-1)=2n-1
    これを満たすnが求める人数

### FIXED CODE ###

X,Y,Z=map(int,input().split())
ans=X//(Y+Z)
if X<ans*(Y+Z)+Z:
  print(ans-1)
else:  
  print(ans)
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

num_dict = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6
}

# Aの各要素の画数
count_list = [num_dict[a] for a in A]

# 最小の画数
min_matches = min(count_list)

# 画数の最小の値のうち最大の数値
min_num_list = []
[min_num_list.append(a) for a in A if num_dict[a] == min_matches]
min_num = max(min_num_list)


# 数値とあまり消化数のペア
A.sort(reverse=True)
res = {a: num_dict[a]-min_matches for a in A}


def dfs(nums, target, num_count):
    if len(nums) > num_count:
        return None
    if target == 0:
        return nums
    elif target < 0:
        return None
    else:
        for a in A:
            ret = dfs(nums+[a], target-res[a], num_count)
            if ret is not None:
                return ret
        return None


for num_count in range(N//min_matches, 0, -1):
    # あまりの本数
    mod = N - min_matches*num_count

    # あまりをどう分配するか(DFS)
    share = dfs([], mod, num_count)
    if share is not None:
        out_list = sorted([min_num]*(num_count-len(share))+share, reverse=True)
        out_list = [str(item) for item in out_list]
        print(''.join(out_list))
        break


### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10000)


N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

num_dict = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6
}
A.sort(reverse=True)

# dpを計算
dp = defaultdict(lambda: -1e18)
dp[0] = 0

for i in range(2, N+1):
    dp[i] = max([dp[i-num_dict[a]]+1 for a in A])

num_count = dp[N]

out_list = []
res_N = N
for _ in range(num_count):
    for a in A:
        if dp[res_N]-1 == dp[res_N-num_dict[a]]:
            out_list.append(str(a))
            res_N = res_N - num_dict[a]
            break

print(''.join(out_list))
D=int(input())
if D=25 :
  print("Christmas")
elif D=24 :
  print("Christmas Eve")
elif D=23 :
  print("Christmas Eve Eve")
else :
  print("Christmas Eve Eve Eve")

### FIXED CODE ###

D=int(input())
if D==25 :
  print("Christmas")
elif D==24 :
  print("Christmas Eve")
elif D==23 :
  print("Christmas Eve Eve")
else :
  print("Christmas Eve Eve Eve")
N, M, X, Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))    
for z in range(X+1, Y+1):
    if (max(x) < z) and (z <= min(y)):
        print("No War")
        break
    else:
        print("War")

### FIXED CODE ###

a, b, c = (int(x) for x in input().split())
print(a + b + c + max(a, b, c)*9)
A, B, C, D, E, F = map(int, input().split())

W = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))
S = [max([c*C + d*D for c in range((E*w / 100) / C + 1) for d in range((E*w / 100) / D + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]
print(W[I] + S[I], S[I])


### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())

W = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))
S = [max([c*C + d*D for c in range(int((E*w / 100) / C) + 1) for d in range(int((E*w / 100) / D) + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]
I = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]
print(100*A if W[I] == 0 else W[I] + S[I], S[I])
from bisect import bisect_right
N,C=map(int,input().split())
S=[[int(i) for i in input().split()] for i in range(N)]
Way1=[S[0][1]-S[0][0]]
p1=[]
if Way1[0]>0:
  p1.append(0)
for i in range(1,N):
  Way1.append(Way1[i-1]+S[i][1]-(S[i][0]-S[i-1][0]))
  if p1==[] and Way1[i]>0:
    p1.append(i)
  elif Way1[p1[-1]]<Way1[i]:
    p1.append(i)
    
Way2=[S[-1][1]-(C-S[-1][0])]
p2=[]
if Way2[0]>0:
  p2.append(N-1)
for i in range(1,N):
  Way2.append(Way2[i-1]+S[N-i-1][1]+(S[N-i-1][0]-S[N-i][0]))
  if p2==[] and Way2[i]>0:
    p2.append(N-i-1)
  elif Way2[N-1-p2[-1]]<Way2[i]:
    p2.append(N-i-1)
Way2.reverse()
p2.reverse()

ans=0
for i in p1:
  if i!=N-1:
    if bisect_right(p2,i+0.1)<len(p2):
      j=p2[bisect_right(p2,i+0.1)]
      ans=max(ans,Way1[i],Way1[i]-S[i][0]+Way2[j],Way1[i]-(C-S[j][0])+Way2[j])
    else:
      ans=max(ans,Way1[i])
  else:
    ans=max(ans,Way1[i])
for j in p2:
  ans=max(ans,Way2[j])
print(ans)
  

### FIXED CODE ###

from bisect import bisect_right,bisect_left
N,C=map(int,input().split())
S=[[int(i) for i in input().split()] for i in range(N)]
Way1=[S[0][1]-S[0][0]]
p1=[]
if Way1[0]>0:
  p1.append(0)
for i in range(1,N):
  Way1.append(Way1[i-1]+S[i][1]-(S[i][0]-S[i-1][0]))
  if p1==[] and Way1[i]>0:
    p1.append(i)
  elif p1!=[]:
    if Way1[p1[-1]]<Way1[i]:
      p1.append(i)
    
Way2=[S[-1][1]-(C-S[-1][0])]
p2=[]
if Way2[0]>0:
  p2.append(N-1)
for i in range(1,N):
  Way2.append(Way2[i-1]+S[N-i-1][1]+(S[N-i-1][0]-S[N-i][0]))
  if p2==[] and Way2[i]>0:
    p2.append(N-i-1)
  elif p2!=[]:
    if Way2[N-1-p2[-1]]<Way2[i]:
      p2.append(N-i-1)
Way2.reverse()
p2.reverse()

ans=0
for i in p1:
  if i!=N-1:
    if bisect_right(p2,i+0.1)<len(p2):
      j=p2[bisect_right(p2,i+0.1)]
      ans=max(ans,Way1[i],Way1[i]-S[i][0]+Way2[j])
    else:
      ans=max(ans,Way1[i])
  else:
    ans=max(ans,Way1[i])
for j in p2:
  if j!=0:
    if bisect_left(p1,j-0.1)>0:
      i=p1[bisect_left(p1,j-0.1)-1]
      ans=max(ans,Way2[j],Way1[i]-(C-S[j][0])+Way2[j])
    else:
      ans=max(ans,Way2[j])
  else:
    ans=max(ans,Way2[j])
    
print(ans)
def main():
    S = input()

    while True:
        result_1 = search('dreamer$', S)
        result_2 = search('eraser$', S)
        result_3 = search('erase$', S)
        result_4 = search('dream$', S)

        if result_1:
            S = S[:result_1.start()]
        elif result_2:
            S = S[:result_2.start()]
        elif result_3:
            S = S[:result_3.start()]
        elif result_4:
            S = S[:result_4.start()]
        else:
            print("NO")
            break

        if len(S) == 0:
            print("YES")
            break


if __name__ == "__main__":
    main()


### FIXED CODE ###


def main():
    S = input()
    while True:
        if S[-7:] == "dreamer":
            S = S[:-7]
        elif S[-6:] == "eraser":
            S = S[:-6]
        elif S[-5:] == "erase":
            S = S[:-5]
        elif S[-5:] == "dream":
            S = S[:-5]
        else:
            print("NO")
            break

        if len(S) == 0:
            print("YES")
            break


if __name__ == "__main__":
    main()
s = input()
print(str(x)*len(s))

### FIXED CODE ###

s = input()
print('x'*len(s))
def main():
    n = 10**18
    a = 10**18
    b = 10**18
    print(n, a, b)
    n, a, b = map(int, input().split())

    if (b-a) % 2 == 1:
        t = min(a-1, n-b)
        if a-1 == t:
            a = 1
            b = b-t
            print(t + 1 + ((b-1)-a)//2)
        else:
            a = a + t
            b = n
            print(t + 1 ((b-1)-a)//2)

    else:
        print((b-a)//2)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = 10**18
    a = 10**18
    b = 10**18
    n, a, b = map(int, input().split())

    if (b - a) % 2 == 1:
        print((b-a)//2 + (b-a) % 2 + min(a-1, n-b))
    else:
        print((b - a) // 2)


if __name__ == '__main__':
    main()
h, w, k = [int(x) for x in input.split()]
ans = 0

grid = []

for i in range(h):
    grid.append(input.split())

black = 0

for maskRow in range(0, 1 << h):
    for maskCol in range(0, 1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
                    black += 1
    if black == k:
        ans += 1

print(ans)

### FIXED CODE ###

# def c():
#     n = int(input())
#     inp = {}
#     for i in range(n):
#         a = input()
#         if inp.get(a) is None:
#             inp[a] = 0
#         inp[a] += 1
#     print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
#     print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
#     print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
#     print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")

# c()


h, w, k = [int(x) for x in input().split()]
ans = 0

grid = []

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

black = 0

for maskRow in range(0, 1 << h):
    for maskCol in range(0, 1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1

print(ans)