Harryxun/stf_run huggingface dataset:
from collections import deque

H,W = map(int,input().split())
maze = [[] for i in range(H)]
con = 0
inf = 10 ** 9
distance = [[inf] * W for i in range(H)]

for i in range(H):
  m = list(input())
  maze[i] = m
  con += m.count("#")

def bfs(maze, disrance, sh, sw):
  queue = deque([[sh, sw]])
  distance[sh][sw] = 0
  while queue:
    h,w = queue.popleft()
    if h == H - 1 and w == W - 1:
      return distance[h][w]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_h, new_w = h + j, w + k
      if new_h < 0 or new_h >= H or \
        new_w < 0 or new_w >= W:
          continue
      elif maze[new_h][new_w] != "#" and \
        distance[new_h][new_w] > distance[h][w] + 1:
        distance[new_h][new_w] = distance[h][w] + 1

        queue.append([new_h, new_w])
        
minpath = bfs(maze,distance,0,0)

print(H * W - con - minpath - 1)



### FIXED CODE ###

from collections import deque

H,W = map(int,input().split())
maze = [[] for i in range(H)]
con = 0
inf = 10 ** 6
distance = [[inf] * W for i in range(H)]

for i in range(H):
  m = list(input())
  maze[i] = m
  con += m.count("#")

def bfs(maze, distance, sh, sw):
  queue = deque([[sh, sw]])
  distance[sh][sw] = 0
  while queue:
    h,w = queue.popleft()
    if h == H - 1 and w == W - 1:
      return distance[H - 1][W - 1]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_h, new_w = h + j, w + k
      if new_h < 0 or new_h >= H or \
        new_w < 0 or new_w >= W:
          continue
      elif maze[new_h][new_w] != "#" and \
        distance[new_h][new_w] > distance[h][w] + 1:
        distance[new_h][new_w] = distance[h][w] + 1

        queue.append([new_h, new_w])
  
minpath = bfs(maze,distance,0,0)

if minpath == None:
  print(-1)
else:
  print(H * W - minpath - con - 1)
a,b = map(int,input().sprit())
print((a*b+1)//2)

### FIXED CODE ###

a,b = map(int,input().split())
print((a+b+1)//2)
A, B = map(int,input().split())

def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x

n = gcd(max(A,B),min(A,B))

is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = True

for i in range(2, int(n**0.5) + 1):
    if is_prime[i]:
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

take_l = [i for i in range(1, n + 1) if all([is_prime[i], A%i == 0, B%i == 0])]
print(len(take_l))

### FIXED CODE ###

A, B = map(int, input().split())

# 最大公約数
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

GCD = gcd(A, B)

# 最大公約数の素因数を求める
prime_factor = []

# 素因数で可能な限り割る
def divide_by_prime_factor(GCD, p):
    if GCD%p == 0:
        prime_factor.append(p)
        while GCD%p == 0:
            GCD /= p
    return GCD, prime_factor

GCD, prime_factor = divide_by_prime_factor(GCD, 2)

for i in range(3, int(GCD**0.5)+1, 2):
    GCD, prime_factor = divide_by_prime_factor(GCD, i)

# GCDそれ自身が素数の場合を考慮。GCD==1の場合を除くことに注意
if GCD > 2:
    GCD, prime_factor = divide_by_prime_factor(GCD, GCD)

# 素因数の数+1を出力
print(len(prime_factor)+1)
n, m = map(int, input().split())
print(n(n-1)//2 + m(m-1)//2)

### FIXED CODE ###

n, m = map(int, input().split())
print(n*(n-1)//2 + m*(m-1)//2)
name_a,name_b=(x for x in input().split())
a_count,b_count=(int(x) for x in input().split())
fetch_color=input()

if fetch_color=name_a:
  a_coount = a_count-1
elif:
  fetch_color=name_b
  b_count = b_count-1
print(a_count,b_count)

### FIXED CODE ###

a,b=input().split()
a_num,b_num=input().split()
c=input()
 
if c==a:
  a_num=int(a_num)-1
elif c==b:
  b_num=int(b_num)-1
print(a_num,b_num)
import sys
def line():return sys.stdin.readline().strip()
def cin():return sys.stdin.readline().strip().split()
while True:
    N,M = [int(i) for i in cin()]
    if N == 0:break
    X = [int(line()) for _ in range(N)]
    c = 1
    for i in range(M):
        c+=int(line())
        if c < N and X[c - 1] != 0:
            c+=X[c - 1]
        if c >= N:
            print(i + 1)
            break

### FIXED CODE ###

import sys
def line():return sys.stdin.readline().strip()
def cin():return sys.stdin.readline().strip().split()
while True:
    N,M = [int(i) for i in cin()]
    if N == 0:break
    X = [int(line()) for _ in range(N)]
    Y = [int(line()) for _ in range(M)]
    c = 1
    for i in range(M):
        c+=int(Y[i])
        if c < N and X[c - 1] != 0:
            c+=X[c - 1]
        if c >= N:
            print(i + 1)
            break
n = int(input())
li = list(map(int, input().split()))
ans = true
for i in li:
  if i % 2 == 1:
    ans = false
    break
  else:
    if i % 3 != 0 and i % 5 != 0:
      ans = false
      break
if ans:
  print("APPROVED")
else:
  print("DENIED")

### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
ans = True
for i in li:
  if i % 2 == 1:
    continue
  else:
    if i % 3 != 0 and i % 5 != 0:
      ans = False
      break
if ans:
  print("APPROVED")
else:
  print("DENIED")
ef hantei(s):
    rev_s = s[::-1]

    for x in range(len(s)):
        if s[x] != rev_s[x]:
            return False
    
    return True

s = input()

if hantei(s) and hantei(s[:int((len(s)-1)/2)]) and hantei(s[int((len(s)+3)/2)-1:]):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

def hantei(s):
    rev_s = s[::-1]

    for x in range(len(s)):
        if s[x] != rev_s[x]:
            return False
    
    return True

s = input()

if hantei(s) and hantei(s[:int((len(s)-1)/2)]) and hantei(s[int((len(s)+3)/2)-1:]):
    print("Yes")
else:
    print("No")
n,a,b=map(int,input().split())
ans=0
for i in range(1,N+1):
  s=0
  for j in str(i):
    s+=int(j)
  if a<=s<=b:
    ans+=1
print(ans)

### FIXED CODE ###

n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
  s=0
  for j in str(i):
    s+=int(j)
  if a<=s<=b :
    ans+=i
print(ans)
n = int(input())
m = int(input())

print(m*n)

### FIXED CODE ###

n,m = input().split()

n = int(n)
m = int(m)


print((m-1)*(n-1))
n, m = map(int, input().split())
outlist = [int(input()) for i in range(m)]


def Fib(num):
    a, b = 1, 0
    for _ in range(num):
        a, b = (a + b) % 1000000007, a % 1000000007
    return (a)


def stepcount(x, y):
    if y - x <= 1:
        return 1
    else:
        return Fib(y - x)


answer = Fib(outlist[0] - 1)

for i in range(m - 1):
    answer *= stepcount(outlist[i] + 1, outlist[i + 1] - 1)
    answer = answer % 1000000007

answer = (answer * stepcount(outlist[m - 1] + 1, n)) % 1000000007

for i in range(m - 1):
    if outlist[i + 1] - outlist[i] == 1:
        answer = 0

print(answer)

### FIXED CODE ###

n, m = map(int, input().split())
outlist = [int(input()) for i in range(m)]


def Fib(num):
    a, b = 1, 0
    for _ in range(num):
        a, b = (a + b) % 1000000007, a % 1000000007
    return (a)


def stepcount(x, y):
    if y - x <= 1:
        return 1
    else:
        return Fib(y - x)

if m != 0:
    answer = Fib(outlist[0] - 1)

    for i in range(m - 1):
        answer *= stepcount(outlist[i] + 1, outlist[i + 1] - 1)
        answer = answer % 1000000007

    answer = (answer * stepcount(outlist[m - 1] + 1, n)) % 1000000007

    for i in range(m - 1):
        if outlist[i + 1] - outlist[i] == 1:
            answer = 0
else:
    answer = Fib(n)

print(answer)
N, Y = map(int, input().split())
a, b, c = -1, -1, -1

if Y >= 2000 * 10000:
    ZN = 1
    YN = 1
    XN = 2000
else:
    ZN = min(N, Y//1000)
    YN = min(N, Y//5000)
    XN = min(N, Y//10000)
    
for z in range(ZN + 1):
    for y in range(YN + 1):
        for x in range(XN + 1):
            if x + y + z == N and 1000*z + 5000*y + 10000*x == Y:
                a, b, c = x, y, z
                break

print(a, b, c)


### FIXED CODE ###

S = input()

ans = "2018" + S[4:]
print(ans)
S = input()
S2 = S + S
K = int(input())
n = len(S2)
i = 0
s = 0
while i < n-1 :
    i += 1
    x = S2[i]
    y = S2[i+1]
    if x == y:
        s += 1
        i += 1
p = s//2
q = s-p
ans = p + q*(K-1)

### FIXED CODE ###

A = input()
n = len(A)
S = []
R = [A[n-1]]
for i in range(n):
    S.append(A[i])
    R.append(A[i])
K = int(input())
s = 0
p = S[0]
q = S[n-1]
for i in range(n-1):
    x = S[i]
    y = S[i+1]
    if x == y:
        S[i+1] = 1
        s += 1
t = 0
for j in range(n):
    x = R[j]
    y = R[j+1]
    if x == y:
        R[j+1] = 1
        t += 1
if p != q:
    ans = s*K
else:
    if S[n-1] == 1:
        ans = s*K
    else:
        if R[n] == 1:
            k = K//2
            ans = (K-k)*s + k*t
        else:
            ans = s + (K-1)*t
print(ans)
import sys
sys.setrecursionlimit(2*10**5)

# input
N = int(input())
Tree = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    Tree[a-1].append(b-1)
    Tree[b-1].append(a-1)

# process
# treeを2グループに分類
def to2g(tg, i):
    g = (tg[i]+1)%2
    for p in Tree[i]:
        if tg[p] == 1:
            continue
        tg[p] = g
        to2g(tg, p)

tg = [-1]*(N)
tg[0] = 0
to2g(tg, 0)

# 順列を求める
ans = [0]*N
cnt0 = tg.count(0)
cnt1 = N-cnt0
if cnt0 < 2 or cnt1 < 2:
    for i in range(0, N):
        ans[i] = i+1
else:
    mod0 = 3
    mod1 = 1
    mod2 = 2
    for i, g in enumerate(tg):
        if g == 0 and mod1 <= N:
            ans[i] = mod1
            mod1 += 3
        elif g == 1 and mod2 <= N:
            ans[i] = mod2
            mod2 += 3
        elif mod0 <= N:
            ans[i] = mod0
            mod0 += 3
        else:
            ans = [-1]

# output
print(" ".join(map(str, ans)))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
from collections import deque

# input
N = int(input())
Edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    Edges[a-1].append(b-1)
    Edges[b-1].append(a-1)

# process
# 頂点を2グループに分類
group = [-1]*N
group[0] = False
def categorize2g(pi, i, g):
    for ci in Edges[i]:
        if ci == pi:
            continue
        group[ci] = not g
        categorize2g(i, ci, not g)

categorize2g(-1, 0, 0)

# 順列を求める
ans = [0]*N
mod0 = [x for x in range(1, N+1) if x%3 == 0]
mod1 = [x for x in range(1, N+1) if x%3 == 1]
mod2 = [x for x in range(1, N+1) if x%3 == 2]
gtnum = sum(group)
if gtnum <= N//3:
    dq = deque(mod1+mod2+mod0)
elif N-gtnum <= N//3:
    dq = deque(mod0+mod1+mod2)
else:
    dq = deque(mod1+mod0+mod2)

if len(ans) == N:
    for i, g in enumerate(group):
        if g:
            ans[i] = dq.pop()
        else:
            ans[i] = dq.popleft()

# output
# print(group)
print(" ".join(map(str, ans)))
input();a=0
print([sorted(i)[1]==i[1]for i in [list(map(int,input().split()))[i:i+3] for i in range(len(list(map(int,input().split())))-4)]].count(True))

### FIXED CODE ###

#gets;a=0
#gets.split.map(&:to_i).each_cons(3){|_|a+=_.sort[1]==_[1]?1:0}
#p a

def each_cons(x, size):
    return [x[i:i+size] for i in range(len(x)-size+1)]
input();a=0
print([sorted(i)[1]==i[1]for i in each_cons(list(map(int,input().split())),3)].count(True))
h, n = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

#dp[i][j] := i番目までの物ででjまでのコストで実現できる最大値
dp = [[0] * 100000001 for _ in range(n+1)]

for i in range(n):
    for j in range(1001):
        if j < items[i][1]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i+1][j-items[i][1]] + items[i][0])

m = 0
while True:
    if dp[n][m] >= h:
        print(m)
        exit()
    m += 1

### FIXED CODE ###

h, n = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

#dp[i][j] := i番目までの物でjの価値を実現するのに必要な最小コスト
dp = [[0] * (h+1) for _ in range(n+1)]
for j in range(1, h+1):
    dp[0][j] = float("inf")

for i in range(n):
    for j in range(h+1):
        if j < items[i][0]:
            dp[i+1][j] = min(dp[i][j], items[i][1])
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-items[i][0]] + items[i][1])

print(dp[n][h])
N = int(input())
S = []
c = 0
for i in range(N):
	S.append(input())
    S = list(set(S))
print(len(S))

### FIXED CODE ###

N = int(input())
S = []
c = 0
for i in range(N):
	S.append(input())

S = list(set(S))
print(len(S))
from string import ascii_lowercase
alp = ascii_lowercase
num = {char: i for i, char in enumerate(alp)}

s = input()
k = int(input())
ns = [num[char] for char in s]

for i in range(len(ns)):
    v = ns[i]
    if 26 - v <= k:
        ns[i] = 0
        k -= 26 - v

ns[-1] += k

print(''.join(alp[n] for n in ns))

### FIXED CODE ###

from string import ascii_lowercase
s = input()
k = int(input())

def main(s, k):
    alp = ascii_lowercase
    num = {char: i for i, char in enumerate(alp)}

    ns = [num[char] for char in s]

    for i in range(len(ns)):
        v = ns[i]
        if v != 0 and 26 - v <= k:
            ns[i] = 0
            k -= 26 - v

    ns[-1] = (ns[-1] + k) % 26

    return ''.join(alp[n] for n in ns)
print(main(s, k))
#C
X,N = map(int,input().split())
p = list(map(int,input().split()))
r = max(100,max(p),abs(min(p)))
for i in range(max(min(min(p)-2,-1),101),min(min(p)-2,-1),-1):
    if i in p:
        pass
    else:
        if abs(r-X) >= abs(i-X):
            r = i
        else:
            pass
print(r)

### FIXED CODE ###

#C
X,N = map(int,input().split())
p = list(map(int,input().split()))
r = 101
for i in range(101,-1,-1):
    if i in p:
        pass
    else:
        if abs(r-X) >= abs(i-X):
            r = i
print(r)
N, M  = map(int, input().split())
A = [ input() for i in range(N)]
B = [ input() for i in range(M)]


def serch(x0, y0):
  for i in range(M):
    for j in range(M):
      if A[x0+i][y0+j] != B[i][j]:
        return False
  return True

if M > N:
  print('No')
  exit()


for x in range(N):
  for y in range(N):
    if not serch(x,y):
      continue
    else:
      print('Yes')
      exit()
print('No')


### FIXED CODE ###

N, M  = map(int, input().split())
A = [ input() for i in range(N)]
B = [ input() for i in range(M)]


def serch(x0, y0):
  for i in range(M):
    for j in range(M):
      if x0+i >= N or y0+j >= N:
        return False
      if A[x0+i][y0+j] != B[i][j]:
        return False
  return True

if M > N:
  print('No')
  exit()


for x in range(N):
  for y in range(N):
    if not serch(x,y):
      continue
    else:
      print('Yes')
      exit()
print('No')
import sys

L = [0,1,6,8]

def main():
  N = int(input())
  
  if N[-1] == 3:
    print("bon")
  elif N[-1] in [0,1,6,8]:
    print("pon")
  else:
    print("hon")

    
main()

### FIXED CODE ###

import sys
 
def main():
  N = str(input())
  L = [0,1,6,8]
  n_last = int(N[-1])
  if n_last == 3:
    print("bon")
  elif (n_last in L):
    print("pon")
  else:
    print("hon")
 
    
main()
print( sys.stdin.split().indx("0"))


### FIXED CODE ###

print(input().split().index("0") + 1)
h, a = map(int, input())
print(h//a+1 if h%a != 0 else h//a)

### FIXED CODE ###

h, a = map(int, input().split())
print(h//a+1 if h%a != 0 else h//a)
n = input()
h = input().split()
hl = [0]*n
 
for i in range(n):
  hi = h[i]
  hl[i] = int(hi)
 
ans = 1
m = n - 1
high = hl[0]
 
for i in range(m):
  if hl[i+1] >= high:
    ans += 1
    high = hl[i+1]
   else:
    continue
 
print(ans)
n = input()
h = input().split()
hl = [0]*n

for i in range(n):
  hi = h[i]
  hl[i] = int(hi)

ans = 1
m = n - 1
high = hl[0]
 
for i in range(m):
  if hl[i+1] >= high:
    ans += 1
    high = hl[i+1]
   else:
    continue
 
print(ans)

### FIXED CODE ###

n = int(input())
h = input().split()
 
ans = 1
m = n-1
high = int(h[0])
 
for i in range(m):
    if int(h[i+1]) >= high:
        ans += 1
        high = int(h[i+1])
    else:
        continue
        
 
print(ans)
def main():
    from operator import itemgetter
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    X = list(map(int,input().split))
    for i in range(X):
        if X[i] == 0:
            print(i+1)
            return

main()

### FIXED CODE ###

def main():
    from operator import itemgetter
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    X = list(map(int, input().split()))
    for i in range(len(X)):
        if X[i] == 0:
            print(i+1)
            return

main()
n = int(input())
import numpy as np
a = np.array([int(input()) for _ in range(n)])
M1,M2 = sorted(set(a))[::-1][0:2]
for b,i in zip(a==M1,a):
  if b:
    print(M2)
  else:
    print(M1)

### FIXED CODE ###

n = int(input())
import numpy as np
a = np.array([int(input()) for _ in range(n)])
M = max(a)
if np.sum(a==M) >= 2:
  [print(M) for _ in range(n)]
else:
  result = [M]*n
  result[np.argmax(a)] = sorted(a)[-2]
  [print(i) for i in result]
a = raw_input()
b = raw_input()
dic = {
    "0":0,
    "1":1,
    "2":2,
    "3":3,
    "4":4,
    "5":5,
    "6":6,
    "7":7,
    "8":8,
    "9":9,
    "A":10,
    "B":11,
    "C":12,
    "D":13,
    "E":14,
    "F":15}
aa = dic[a]
bb = dic[b]

if(aa < bb):
    y = "<"
elif(aa > bb):
    y = ">"
else:
    y = "="
    
print(y)

### FIXED CODE ###

a, b = raw_input().split()

dic = {
    "A":10,
    "B":11,
    "C":12,
    "D":13,
    "E":14,
    "F":15}
aa = dic[a]
bb = dic[b]

if(aa < bb):
    y = "<"
elif(aa > bb):
    y = ">"
else:
    y = "="
    
print(y)
h,w=map(int,input().split())
a=[list(input().split()) for _ in range(h)]

#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

for i in range(h):
	tmpl=[]
	for j in range(w):
		if not a[i][j]=="0":
			tmpl.append(a[i][j])
	if "#" in tmpl or "." in tmpl:
		print(" ".join(tmpl))		

### FIXED CODE ###

h,w=map(int,input().split())
a=[]
for _ in range(h):
	b=[]
	s=input()
	for i in range(w):
		b.append(s[i])
	a.append(b)
	
#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

for i in range(h):
	tmpl=[]
	for j in range(w):
		if not a[i][j]=="0":
			tmpl.append(a[i][j])
	if "#" in tmpl or "." in tmpl:
		print("".join(tmpl))		#listを詰めて表示
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from scipy.misc import comb

def man_comb(_N, _K):
    if _K > (_N/2):
        return comb(_N, _N - _K, exact=True)
    else:
        return comb(_N, _K, exact=True)

MAX = 10**9 + 7

def mod_inv(i, mod):
    return pow(i, mod-2, mod)

def combination(_N, _K):
    if _K > (_N/2):
        _K = _N - _K
    up = 1
    low = 1
    for i in range (_K):
        up = up * (_N - i) % MAX
        low = low * (i + 1) % MAX
    ret = up * mod_inv(low, MAX) % MAX
    return ret

def solve():
    N, M, K = [int(_) for _ in raw_input().split()]
    disSum = M*N* (M*(N+1)*(N-1) + N*(M+1)*(M-1)) // 6
    ret = disSum * combination(M*N-2, K-2) % MAX
    print ret

def cum_sum(N):
    return N * (N+1) // 2

def solve2():
    N, M, K = [int(_) for _ in raw_input().split()]
    sumx = 0
    for xi in range(1, N+1):
        sumx = (sumx + cum_sum(N) - (N + 1 - xi) * xi)
    sumx = (sumx * M * M) // 2 %MAX
    sumy = 0
    for yi in range(1, M+1):
        sumy = (sumy + cum_sum(M) - (M + 1 - yi) * yi)
    sumy = (sumy * N * N) // 2 %MAX
    ret = (sumx + sumy) * combination(M*N-2, K-2) % MAX
    print ret

if __name__ == '__main__':
    solve2()


### FIXED CODE ###

MAX = 10**9 + 7

def mod_inv(i, mod):
    return pow(i, mod-2, mod)

def combination(_N, _K):
    if _K > (_N/2):
        _K = _N - _K
    up = 1
    low = 1
    for i in range (_K):
        up = up * (_N - i) % MAX
        low = low * (i + 1) % MAX
    ret = up * mod_inv(low, MAX) % MAX
    return ret

def solve():
    N, M, K = [int(_) for _ in raw_input().split()]
    disSum = (M*N* ((M*(N+1)*(N-1))%MAX + (N*(M+1)*(M-1)) % MAX)) % MAX
    disSum *= mod_inv(6, MAX) % MAX
    ret = disSum * combination(M*N-2, K-2) % MAX
    print ret

if __name__ == '__main__':
    solve()
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i,m):
  if m == 0:
    return True
  if i >= n:
    return False
  i = i + 1
  res = solve(i,m) or solve(i, m - A[i])
  return res

for m in M:
    if solve(0, m):
      print 'yes'
    else:
      print 'no'

### FIXED CODE ###

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

min = min(A)
sum = sum(A)

def solve(i,m):
  if sum < m:
    return False
  if m == 0:
    return True
  if i >= n:
    return False
  res = solve(i+1,m) or solve(i+1, m - A[i])
  return res
 
for m in M:
    if solve(0, m):
      print 'yes'
    else:
      print 'no'
N = int(input())
d = list(map(int, input().split()))


def combinations(d, tmp_out, i, j):
    if (j >= N):
        i += 1
        j = i + 1
        if (i >= N):
            return tmp_out
        elif (j >= N):
            return tmp_out
    tmp_out += d[i] * d[j]

    return combinations(d, tmp_out, i, j + 1)


out = combinations(d, 0, 0, 1)

print(out)

### FIXED CODE ###

N = int(input())
d = list(map(int, input().split()))

out = 0
for i in range(N):
    for j in range(i + 1, N):
        out += d[i] * d[j]

print(out)
N,K = map(int,input().split())
H = list(map(int,input().split()))

dp = [0 for i in range(N)]

for i in range(1,K+1) :
    dp[i] = abs(H[0] - H[i])

for i in range(K+1,N) :
    cost = float("inf")
    for j in range(1,K+1) :
        cost = min(cost, dp[i-j] + abs(H[i-j] - H[i]))
    
    dp[i] = cost

ans = dp[N-1]

print(ans)


### FIXED CODE ###

N,K = map(int,input().split())

L = list(map(int,input().split()))

dp = [0 for i in range(N)]
if N >= K :    
    for i in range(1,K+1) :
        dp[i] = abs(L[i]-L[0])
    for i in range(K+1,len(dp)) :
        state = float("inf")
        for j in range(i-K,i) :
            calc = abs(L[i]-L[j]) + dp[j]
            if state > calc :
                state = calc
        dp[i] = state
    print(dp[N-1])
else :
    print(abs(min(L[1:])-L[0]))
n = int(input())
if n>=30:
  print("Yes)
else:
  print("No")

### FIXED CODE ###

n=int(input())
if n>=30:
  print("Yes")
else:
  print("No")
H, W = map(int, input().split())

for i in range(H):
  s = input().split()
  if W != 1:
    if len(set(s)) == 2:
      row = i+1
      col = 65+s.index('snuke')
      break
  else:
    if s == ["snuke"]:
      row = i+1
      col = 65
print("{}{}".format(chr(col), row))


### FIXED CODE ###

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

for i in range(H):
  s = input().split()
  if "snuke" in s:
    row = i+1
    col = 65+s.index('snuke')
    break
print("{}{}".format(chr(col), row))
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF=10**9

def dfs(cur, a, b, c):
if cur == N:
return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
ret0 = dfs(cur + 1, a, b, c)
ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
#example answer

### FIXED CODE ###

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF=10**9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
#example answer
if scan()=="SUN":
  print("7")
elif scan()=="MON":
  print("6")
elif scan()=="TUE":
  print("5")
elif scan()=="WED":
  print("4")  
elif scan()=="TUH":
  print("3")
elif scan()=="FRI":
  print("2")
else:
  print("1")

### FIXED CODE ###

week =input()

if week=="SUN":
  print("7")
elif week=="MON":
  print("6")
elif week=="TUE":
  print("5")
elif week=="WED":
  print("4")  
elif week=="THU":
  print("3")
elif week=="FRI":
  print("2")
else:
  print("1")