Harryxun/stf_run huggingface dataset:
import numpy as np


def main():
    H, W = [map(int, x) for x in input().split()]
    board = [[0 for i in range(H)] for j in range(W)]

    """ #は1, .は0 """
    for i in range(H):
        X = input()
        for j in range(len(X)):
            if X[j] == "#":
                board[i][j] = 1

    num_board = np.array(board)
    height, width = num_board.shape[:2]
    count = 0
    height_r, width_r = range(height), range(width)
    while (np.sum(num_board) != height*width):
        num_board_ans = np.zeros((height, width))
        for i in height_r:
            for j in width_r:
                if num_board[i, j] == 1:
                    num_board_ans[i, j] = 1
                    a = max(i-1, 0)
                    num_board_ans[a, j] = 1
                    b = max(j-1, 0)
                    num_board_ans[i, b] = 1
                    c = min(i+1, height-1)
                    num_board_ans[c, j] = 1
                    d = min(j+1, width-1)
                    num_board_ans[i, d] = 1
        num_board = num_board_ans
        count += 1

    print(count)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def bfs(h, w, board, visited):
    queue = deque([])
    for i in range(h):
        for j in range(w):
            if board[i][j] == "#":
                queue.append([i, j])
                visited[i][j] = 0
    ans = 0
    while queue:
        y, x = queue.popleft()
        for i, j in ([1, 0], [0, 1], [-1, 0], [0, -1]):
            yn, xn = y+i, x+j
            if yn >= h or xn >= w or yn < 0 or xn < 0:
                continue
            if visited[yn][xn] == -1 and board[yn][xn] == ".":
                visited[yn][xn] = visited[y][x] + 1
                queue.append([yn, xn])
                ans = max(ans, visited[yn][xn])

    return ans


def main():
    h, w = map(int, input().split())
    board = [input() for _ in range(h)]
    visited = [[-1 for _ in range(w)] for _ in range(h)]
    print(bfs(h, w, board, visited))


if __name__ == "__main__":
    main()
H, N = map(int, input().split())

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

s_sum = sum(s)

if s_sum < H:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

H, A = map(int, input().split())
counter = 0

while H > 0:
  H -= A
  counter += 1
  
print(counter)
N = int(input())

nums = []
max = 0

for i in range(0, N):
    nums.append(int(input()))

mx = sum(nums)
checker = [0 for i in range(0, mx)]

now = 0
res = 0
for i in range(0, N):
    v = nums[i]
    for j in range(now - 1, -1, -1):
        if checker[j] == 1:
            idx = checker[j] + v
            if idx > res and idx % 10 != 0:
                res = idx
            checker[idx] = 1
            checker[j] = 0
    checker[v] = 1
    now = now + v


print(str(res))


### FIXED CODE ###

N = int(input())

nums = []
max = 0

for i in range(0, N):
    nums.append(int(input()))

mx = sum(nums)
if mx % 10 != 0:
    print(str(mx))
    quit()

checker = [False for i in range(0, mx+1)]

now = 0
res = 0
for i in range(0, N):
    v = nums[i]
    for j in range(now, -1, -1):
        if checker[j]:
            idx = j + v
            if idx > res and idx % 10 != 0:
                res = idx
            checker[idx] = True
    checker[v] = True
    now = now + v

print(str(res))
import sys

def cheaperprice(item,checkloop,rawprices,menus):
    rawprice=rawprices[item]
    if item in checkloop:
        return rawprice
    elif item not in menus:
        checkloop.append(item)
        return rawprice
    else:
        checkloop.append(item)
        indegrients=menus[item]
        combinedprice=0
        for i in indegrients:
            combinedprice+=cheaperprice(i,checkloop,rawprices,menus)
        return min(combinedprice,rawprice)

def main():
    n=0 #how many numbers of lists
    flag=0
    rawprices={}
    menus={}
    checkloop=[]
    for line in sys.stdin:
        line=line.strip()
        if n==0:
            if flag==0 and line=='0':
                break
            elif flag!=2:
                n=int(line)
            else:
                print cheaperprice(line,checkloop,rawprices,menus)
                rawprices={}
                menus={}
                checkloop=[]
            flag=(flag+1)%3
        else:
            line=line.split(' ')
            if flag==1: #rawprices
                rawprices[line[0]]=int(line[1])
            elif flag==2:
                menus[line[0]]=line[2:]
            n-=1
    return 0
    
main()

### FIXED CODE ###

while(1):
    n=int(raw_input())
    if n==0:
        break
    else:
        pricelist=[]
        recipedict={}
        costdict={}
        for i in range(n):
            [ii,p]=raw_input().split()
            pricelist.append([ii,int(p)])
            costdict[ii]=1000000000000
        pricelist.sort(key=lambda x:x[1])
        m=int(raw_input())
        for i in range(m):
            rec=raw_input().split()
            o=rec[0]
            k=int(rec[1])
            recipedict[o]=rec[2:]
        query=raw_input()
        while(1):
            cheapest=pricelist.pop(0)
            #if able to make
            if cheapest[0] in recipedict:
                priceifmade=0
                for reqitem in recipedict[cheapest[0]]:
                    priceifmade=priceifmade+costdict[reqitem]
                if priceifmade<cheapest[1]:
                    costdict[cheapest[0]]=priceifmade
                else:
                    costdict[cheapest[0]]=cheapest[1]
            else:
                costdict[cheapest[0]]=cheapest[1]
            for item in recipedict:
                priceifmade=0
                for reqitem in recipedict[item]:
                    priceifmade=priceifmade+costdict[reqitem]
                if priceifmade<costdict[item]:
                    costdict[item]=priceifmade
            if cheapest[0]==query:
                print costdict[cheapest[0]]
                break
import math
S = input()
Q = int(input())
for n in range(Q):
    T,F,C = input()
    if T == "1":
        S = S[::-1]
    else:
        if F == "1":
            S = C + S
        else:
            S = S + C
print(S)


### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())
flg = True
for _ in range(Q):
    query = input()
    if query[0] == "1":
        flg = not flg
    else:
        _,F,C = query.split()
        if (F == "1" and flg) or (F == "2" and not flg):
            S.appendleft(C)
        else:
            S.append(C)
if not flg:
    S.reverse()

print(''.join(S))
N = int(input())
A = list(map(int, input().split()))

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

prime_list = primes(N // 2)

dps = [0 for _ in range(N)]

ans =[]
#半分までは確定
fs = N // 2
for i in range(fs, N):
    dps[i] += A[i]
    if A[i] == 1:
        ans.append(i+1)


for i in reversed(range(fs)):
    # 考慮すべき数i*素数 < N
    num = 0
    for p in prime_list:
        if (i+1) * p <= N:
            num += dps[(i+1) * p - 1]

    
    if num % 2 != A[i]:
        dps[i] += 1
        ans.append(i+1)


print(len(ans))
if len(ans) != 0:
    print(" ".join(map(str, ans)))




### FIXED CODE ###

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



dps = [False for _ in range(N + 1)]

ans =[]
#半分までは確定
fs = N // 2
for i in reversed(range(1, N + 1)):
    d_index = i * 2
    current_sum = 0
    while d_index <= N:
        if dps[d_index]:
            current_sum += 1
        d_index += i

    if current_sum % 2 == A[i-1]:
        dps[i] = False
    else:
        dps[i] = True


ans=[]
for i in range(1, N+1):
    if dps[i]:
        ans.append(i)


print(len(ans))
if len(ans) != 0:
    print(" ".join(map(str, ans)))
import itertools
import numpy as np
N,M,X=map(int,input().split())
lista=[]
for i in range(N):
    lista.append(list(map(int,input().split())))
lista=np.array(lista)
cost=1000000000000000
judge=[X]*M
data=[k for k in range(1,N+1)]
for i in range(1,N+1):
    a=list(itertools.combinations(data,i))
    for j in a:
        clist=np.array([0]*(M+1))
        for k in j:
            clist=clist+lista[k-1]
        if all(clist[1:]>=judge):
            if clist[0]<cost:
                cost=clist[0]
                m=j
c=0
for i in m:
    c+=lista[i][0]

print(c)    

### FIXED CODE ###

import itertools
import numpy as np
N,M,X=map(int,input().split())
lista=[]
for i in range(N):
    lista.append(list(map(int,input().split())))
lista=np.array(lista)
cost=1000000000000000
judge=[X]*M
data=[k for k in range(1,N+1)]
for i in range(1,N+1):
    a=list(itertools.combinations(data,i))
    for j in a:
        clist=np.array([0]*(M+1))
        for k in j:
            clist=clist+lista[k-1]
        if all(clist[1:]>=judge):
            if clist[0]<cost:
                cost=clist[0]
                m=j
c=0
try:
    for i in m:
        c+=lista[i-1][0]

    print(c)
except:
    print(-1)
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 21 20:58:03 2020

@author: naoki
"""

from collections import deque
f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
a = list(map(int, list(input())))

flag1 = [-100, -100]
flag2 = [-100, -100]
flag3 = [-100, -100]

for i in range(N//2):
    if a[i] == 2:
        flag1[0] = i
    if a[N-i-1] ==2 :
        flag1[1] = N-i-1
    if (a[i] == 1 and a[i+1] == 3) or (a[i] == 3 and a[i+1] == 1):
        flag2[0] = i
    if (a[N-i-1] == 1 and a[N-i-2] == 3) or (a[N-i-1] == 3 and a[N-i-2] == 1):
        flag2[1] = N-i-1
    
    if flag1[0] > 0 and flag1[1] > 0:
        b = a[0:flag1[0]].extend(a[flag1[1]:])
        break
    if flag2[0] > 0 and flag2[1] > 0:
        b = a[0:flag2[0]].extend(a[flag2[1]:])
        break
else:
    b = a
last = []
for i in range(len(b)-1):
    if b[i] != b[i+1]:
        last.append(b[i],b[i+1])

for i in range(len(last)-1):
    last = []
    for p in range(len(last) - i):
        last[p] = abs(last[p+1] - last[p])
print(last[0])
        

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 13:54:24 2020

@author: naoki
"""
import sys
#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
N = int(input())
a = list(map(lambda x:int(x)-1,list(input())))
   
all_odd = 0
kai = [0] * N

if (0 not in a) and (1 not in a):
    print(0)
    sys.exit()
if (1 not in a) and (2 not in a):
    print(0)
    sys.exit()
if (0 not in a) and (2 not in a):
    print(0)
    sys.exit()
    
for k in range(1,N):
    count = 0
    p = k
    for _ in range(N):
        if p % 2 == 1:
            kai[k] = kai[k-1] + count
            break
        p = p/2
        count += 1

all_num = 0
for k in range(N):
    if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
        all_num += 1

if all_num % 2 == 1:
    print(1)
elif 1 in a:
    print(0)
else:
    for i in range(N):
        a[i] = a[i]/2
    for k in range(N):
        if kai[-1] <= kai[k] + kai[N-1-k] and a[k] == 1:
            all_num += 1
    if all_num % 2 == 1:
        print(2)
    else:
        print(0)
import bisect

n,k= map(int,input().split())
x = [int(i) for i in input().split()]

idx = bisect.bisect_left(x,0)
"""
if x[idx] == 0:
    x.insert(idx,0)
"""

ans = 10**100

if x[idx] == 0 and idx - k + 1 >= 0:
    print(ans)

print(ans)
exit()

for i in range(k+1):
    #print(idx-i,idx+k-1-i)
    if i == 0 and idx+k-1 < n:
        ans = min(ans, x[idx+k-1])
    elif idx - i < 0 or idx+k-1-i >= n:
        continue
    else:
        ans = min(ans, - 2*x[idx-i] + x[idx+k-1-i])
        ans = min(ans, - x[idx-i] + 2*x[idx+k-1-i])

print(ans)

### FIXED CODE ###

import bisect

n,k= map(int,input().split())
x = [int(i) for i in input().split()]

idx = bisect.bisect_left(x,0)
"""
if x[idx] == 0:
    x.insert(idx,0)
"""
ans = 10**100


for i in range(k+1):
    #print(idx-i,idx+k-1-i)
    if i == 0 and idx+k-1 < n:
        ans = min(ans, x[idx+k-1])
    elif idx - i < 0 or idx+k-1-i >= n:
        continue
    else:
        ans = min(ans, - 2*x[idx-i] + x[idx+k-1-i])
        ans = min(ans, - x[idx-i] + 2*x[idx+k-1-i])

if idx == n:
    ans = -x[-k]

print(ans)
import sys
from collections import defaultdict


def dfs(v, p, ccc, links, ans):
    ret_colors = defaultdict(int)
    ret_count = 1
    cv = ccc[v]
    for u in links[v]:
        if u == p:
            continue
        sub_colors, sub_count = dfs(u, v, ccc, links, ans)
        cc = sub_count - sub_colors[cv]
        ans[cv] -= cc * (cc + 1) // 2
        ret_count += sub_count

        if len(ret_colors) < len(sub_colors):
            ret_colors, sub_colors = sub_colors, ret_colors

        for c, cnt in sub_colors.items():
            ret_colors[c] += cnt

    ret_colors[cv] = ret_count

    return ret_colors, ret_count


def solve(n, ccc, links):
    if n == 1:
        return [1]

    all_pair = n * (n + 1) // 2
    ans = [all_pair] * (n + 1)

    colors, count = dfs(0, -1, ccc, links, ans)
    assert count == n

    for c in range(1, n + 1):
        cc = n - colors[c]
        ans[c] -= cc * (cc + 1) // 2

    return ans[1:]


n, *cab = map(int, sys.stdin.buffer.read().split())
ccc = cab[:n]
links = [set() for _ in range(n)]

for a, b in zip(cab[n + 0::2], cab[n + 1::2]):
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)

print('\n'.join(map(str, solve(n, ccc, links))))


### FIXED CODE ###

import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)


def dfs(v, p, ccc, links, ans):
    ret_colors = defaultdict(int)
    ret_count = 1
    cv = ccc[v]
    for u in links[v]:
        if u == p:
            continue
        sub_colors, sub_count = dfs(u, v, ccc, links, ans)
        cc = sub_count - sub_colors[cv]
        ans[cv] -= cc * (cc + 1) // 2
        ret_count += sub_count

        if len(ret_colors) < len(sub_colors):
            ret_colors, sub_colors = sub_colors, ret_colors

        for c, cnt in sub_colors.items():
            ret_colors[c] += cnt

    ret_colors[cv] = ret_count

    return ret_colors, ret_count


def solve(n, ccc, links):
    if n == 1:
        return [1]

    all_pair = n * (n + 1) // 2
    ans = [all_pair] * (n + 1)

    colors, count = dfs(0, -1, ccc, links, ans)
    assert count == n

    for c in range(1, n + 1):
        cc = n - colors[c]
        ans[c] -= cc * (cc + 1) // 2

    return ans[1:]


n, *cab = map(int, sys.stdin.buffer.read().split())
ccc = cab[:n]
links = [set() for _ in range(n)]

for a, b in zip(cab[n + 0::2], cab[n + 1::2]):
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)

print('\n'.join(map(str, solve(n, ccc, links))))
n = int(input())
a = list(map(int, input().split()))

l, r = a[:2]
m = 1
b = [(l,r)]
for i in range(2, n-2):
    r += a[i]
    for j in range(m, i):
        nl, nr = l+a[j], r-a[j]
        if abs(l-r) < abs(nl-nr): 
            break
        l, r = nl, nr
        m = j
    else:
        m += 1
    b.append((l,r))

l, r = a[-2:]
m = n-2
c = [(l,r)]
for i in range(2, n-2)[::-1]:
    l += a[i]
    for j in range(i+1, m+1)[::-1]:
        nl, nr = l-a[j], r+a[j]
        if abs(l-r) < abs(nl-nr): 
            break
        l, r = nl, nr
        m = j
    else:
        m -= 1
    c.append((l,r))

r = 10**9
for i in range(n-4):
    x = max(*b[i], *c[-i-1])
    y = min(*b[i], *c[-i-1])
    r = min(r, x-y)

print(r)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

l, r = a[:2]
m = 1
b = [(l,r)]
for i in range(2, n-2):
    r += a[i]
    for j in range(m, i):
        nl, nr = l+a[j], r-a[j]
        if abs(l-r) < abs(nl-nr): 
            break
        l, r = nl, nr
        m += 1
    b.append((l,r))

l, r = a[-2:]
m = n-2
c = [(l,r)]
for i in range(2, n-2)[::-1]:
    l += a[i]
    for j in range(i+1, m+1)[::-1]:
        nl, nr = l-a[j], r+a[j]
        if abs(l-r) < abs(nl-nr): 
            break
        l, r = nl, nr
        m -= 1
    c.append((l,r))

r = 10**9
for i in range(n-3):
    x = max(b[i]+c[-i-1])
    y = min(b[i]+c[-i-1])
    r = min(r, x-y)
print(r)
a

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
#def input():
#    return sys.stdin.readline()[:-1]

'''
n=int(input())
for i in range(n):
    a[i]=int(input())
    a[i],b[i]=map(int,input().split())
a=[int(x) for x in input().split()]
n,m=map(int,input.split())
from operator import itemgetter
a = [(1, "c", 1), (1, "b", 3), (2, "a", 0), (1, "a", 2)]
print(sorted(a))  # 0 番目の要素でソート、先頭の要素が同じなら 1 番目以降の要素も見る
print(sorted(a, key=itemgetter(0)))  # 0 番目の要素だけでソート
print(sorted(a, key=itemgetter(0, 2)))  # 0 番目と 2 番目の要素でソート
print(sorted(a, key=lambda x: x[0] * x[2]))  # 0 番目の要素 * 2 番目の要素でソート
print(sorted(a, reverse=True))  # 降順にソート
a.sort()  # 破壊的にソート、sorted() よりも高速
try: # エラーキャッチ list index out of range
    for i in range():
        k=b[i]
except IndexError as e:
    print(i)
'''

test_data1 = '''\
A??C
'''

test_data2 = '''\
ACACAC
'''

test_data3 = '''\
????C?????B??????A???????
'''

test_data4 = '''\
?AC?AC
'''
td_num=3

def GetTestData(index):
    if index==1:
        return test_data1
    if index==2:
        return test_data2
    if index==3:
        return test_data3
    if index==4:
        return test_data4
    
if False:
    with open("../test.txt", mode='w') as f:
        f.write(GetTestData(td_num))
    with open("../test.txt") as f:
        # Start Input code ---------------------------------------
        s=f.readline()
        # End Input code ---------------------------------------
else:
    # Start Input code ---------------------------------------
    s=input()
    # End Input code ---------------------------------------
n=len(s)
lc_a=[0]*n
lc_c=[0]*n
lc_w=[0]*n
rc_a=[0]*n
rc_c=[0]*n
rc_w=[0]*n
rc_a0=s.count('A')
rc_c0=s.count('C')
rc_w0=s.count('?')
c_a=0
c_c=0
c_w=0
for i in range(n-1):
    ch=s[i]
    if ch=='A':
        c_a+=1
    if ch=='C':
        c_c+=1        
    if ch=='?':
        c_w+=1
    lc_a[i+1]=c_a
    #lc_c[i+1]=c_c
    lc_w[i+1]=c_w
    #rc_a[i+1]=rc_a[0]-c_a
    rc_c[i]=rc_c0-c_c
    rc_w[i]=rc_w0-c_w
      
ans=0
mo=10**9+7
#mo=2291979612924+1
#print(ans,'n,s=',n,s,'lc(a,w)=',lc_a,lc_w,'rc(c,w)=',rc_c,rc_w)
for i in range(1,n-1):
    ch=s[i]
    if ch=='B' or ch=='?':
        ans+=(lc_a[i]*pow(3,lc_w[i],mo)+pow(3,max(0,lc_w[i]-1),mo)*lc_w[i])*(rc_c[i]*pow(3,rc_w[i],mo)+pow(3,max(0,rc_w[i]-1),mo)*rc_w[i])%mo
    #print('i,ans',i,ans)
#print(ans,'n,s=',n,s,'lc(a,w)=',lc_a,lc_w,'rc(c,w)=',rc_c,rc_w)
print(ans%mo)
#ans=count(0)+2^(count(n)-1)
s = list(input())
print(len(s[s.index("A"):s.index("Z",-1)]+1))

### FIXED CODE ###

s= input()
print(s.rindex("Z")-s.index("A")+1)
P,Q,R = map(int,input().split())

a = P + Q
b = P + R
c = Q + R
d = Q + P
e = R + Q
f = R + P

mn_list = list[a,b,c,d,e,f]
mn = min(mn_list)

print(mn)

### FIXED CODE ###

a,b,c = map(int,input().split())
print(min(a+b,a+c,b+c))
s = input()

f = "keyence"
h = 0
for i in range(7):

    first = f[:i+1]
    second = f[i+1:]
    check = len(first)
    find1 = s.find(first)
    find2 = s.find(second,find1+check)

    if find2 + len(second) < n:
        continue

    if find1 != -1 and find2!=-1:
        print("YES")
        h = 1
        break



if h == 0:
    print("NO")

### FIXED CODE ###


s = input()

f = "keyence"
h = 0
n = len(s)
for i in range(8):

    first = f[:i+1]
    second = f[i+1:]
    check = len(first)
    find1 = s.find(first)
    find2 = s.find(second,n-len(second))

    if i!=7:
        if find1!=0:
            continue

        if find2==-1:
            continue

        if find2+len(second)!=n:
            continue

        else:
            print("YES")
            h = 1
            break

    else:
        if find1 == 0 or find1+len(first) == n :
            print("YES") 
            h = 1
            break



if h == 0:
    print("NO")
class Dice:
??
????????def __init__(self, faces):
????????????????self.faces = tuple(faces)
??
????????def roll_north(self):
????????????????self.faces = (self.faces[1], self.faces[5], self.faces[2],
????????????????????????????????????????????self.faces[3], self.faces[0], self.faces[4])
??
????????def roll_south(self):
????????????????self.faces = (self.faces[4], self.faces[0], self.faces[2],
????????????????????????????????????????????self.faces[3], self.faces[5], self.faces[1])
??
????????def roll_west(self):
????????????????self.faces = (self.faces[2], self.faces[1], self.faces[5],
????????????????????????????????????????????self.faces[0], self.faces[4], self.faces[3])
??
????????def roll_east(self):
????????????????self.faces = (self.faces[3], self.faces[1], self.faces[0],
????????????????????????????????????????????self.faces[5], self.faces[4], self.faces[2])
??
????????def number(self, face_id):
????????????????return self.faces[face_id - 1]
??
??
dice = Dice(list(map(int, input().split())))
commands = input()
??
for c in commands:
????????if c == "N":
????????????????dice.roll_north()
????????elif c == "S":
????????????????dice.roll_south()
????????elif c == "W":
????????????????dice.roll_west()
????????elif c == "E":
????????????????dice.roll_east()
print(dice.number(1))

### FIXED CODE ###

import sys
 
class Dice(object):
    def __init__(self, dice):
        self.__dice = dice
 
    def roll_north(self):
        self.__dice = (self.__dice[1], self.__dice[5], self.__dice[2],
                       self.__dice[3], self.__dice[0], self.__dice[4])
 
    def roll_south(self):
        self.__dice = (self.__dice[4], self.__dice[0], self.__dice[2],
                       self.__dice[3], self.__dice[5], self.__dice[1])
 
    def roll_west(self):
        self.__dice = (self.__dice[2], self.__dice[1], self.__dice[5],
                       self.__dice[0], self.__dice[4], self.__dice[3])
 
    def roll_east(self):
        self.__dice = (self.__dice[3], self.__dice[1], self.__dice[0],
                       self.__dice[5], self.__dice[4], self.__dice[2])
 
    def number(self, face_id):
        return self.__dice[face_id - 1]
 
 
dice = Dice([int(i) for i in sys.stdin.readline().split()])
command = sys.stdin.readline().strip()
for c in command:
    if c == "N":
        dice.roll_north()
    elif c == "S":
        dice.roll_south()
    elif c == "W":
        dice.roll_west()
    elif c == "E":
        dice.roll_east()
print(dice.number(1))
def main():
      a, v = map(int,input().split())
  b, w = map(int,input().split())
  t = int(input())
  ans = True
  vect = v - w
  if vect <= 0:
    ans = False
  else:
    if vect * t > abs(a - b):
      ans = True
    else:
      if (a + w * t > 10 ** 9 and b + v * t > 10 ** 9 and b > a):
        ans = True
      elif (a - w * t < -10 ** 9 and b - v * t < 10 ** 9 and b < a):
        ans = True
      else:
        ans = False
  if ans:
    print("YES")
  else:
    print("NO")   
            

main()

### FIXED CODE ###

def main():
  a, v = map(int,input().split())
  b, w = map(int,input().split())
  t = int(input())
  ans = True

  if v - w < 0: 
    ans  = False
  elif (v - w) * t >= abs(a - b):
    ans = True
  else:
    ans = False
      
  if ans:
    print("YES")
  else:
    print("NO")            


main()
N=int(input())
arr = list(map(int,list(input().split())))
ds = set(arr)
############################################

allxor=0
for i in range(N):
	allxor=allxor ^ ds.pop()

for i in range(N):
	if i==0 :
		s=str(allxor ^ arr[i])
	else:
		s=s + ' ' + str((allxor ^ arr[i]))

print(s)


### FIXED CODE ###

N=int(input())
arr = list(map(int,list(input().split())))
ds = set(arr)
############################################

allxor=0
for i in range(N):
	#if len(ds)==0:
	#	break
	#allxor=allxor ^ ds.pop()
	allxor=allxor ^ arr[i]

for i in range(N):
	print(allxor ^ arr[i],end='')
	print(' ',end='')

#for i in range(N):
#	if i==0 :
#		s=str(allxor ^ arr[i])
#	else:
#		s=s + ' ' + str((allxor ^ arr[i]))
#print(s)
N = int(input())
a = list(map(int,input().split()))
one = 0
four = 0
two = 0

for j in range(N):

  if a[j]%2 == 1:
    one += 1
  elif a[j]%4 == 0:
    four += 1
  else :
    two +=1

  
if one <= four:
  print('Yes')
else :
  if two == 0:
    if four == (two+1):
      print('Yes')
  else:
    print('No')

### FIXED CODE ###

n,m = map(int,input().split())

print((n-1)*(m-1))