peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N=int(input())
v=sorted(map(int,input().split()))
value=v[0]
for i in range(1,N):
    value=(value+v[i])/2
print(value)
# Judge status: Accepted
def main():
    west_tower_height, east_tower_height = map(int, input().split(" "))
    east_tower_num = east_tower_height - west_tower_height
    print(east_tower_num * (east_tower_num + 1) // 2 - east_tower_height)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
dp = [10 ** 18 for _ in range(n)]
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])
# Judge status: Accepted
def hit(h):
    ans = 0
    if h == 1:
        ans += 1
    else:
        ans += 2*hit(h//2) + 1
    return ans
  
if __name__ == '__main__':
    print(hit(int(input())))
# Judge status: Accepted
# https://atcoder.jp/contests/agc024/tasks/agc024_a
a, b, c, k = map(int, input().split())

if k % 2 == 0:
    print(a - b)
else:
    print(b - a)
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
s = sum(a)
if a[m-1] < s / (4*m):
    print('No')
else:
    print('Yes')
# Judge status: Accepted
from functools import reduce
 
n,a,b=map(int,input().split())
DIV = 10**9 + 7

def nCr(N,R,DIV):
  f=lambda x,y:x*y%DIV
  X=reduce(f,range(N-R+1,N+1))
  Y=reduce(f,range(1,R+1))
  return X*pow(Y,DIV-2,DIV)%DIV


print((pow(2,n,DIV) - 1 - nCr(n,a,DIV) - nCr(n,b,DIV) ) % DIV)
# Judge status: Accepted
import numpy as np
N, M, K = map(int, input().split())
data = np.array([list(map(int, input().split())) for _ in range(N)])

costs = data[:, 0]
knows = data[:, 1:]

mincost = 1e+9
for i in range(2 ** N):
    bits = np.array([((i >> j) & 1) for j in range(N)])
    sumknows = (knows * bits[:, None]).sum(axis=0)
    if (sumknows >= K).all():
        cost = (costs * bits).sum()
        mincost = min(mincost, cost)
print(mincost if mincost < 1e+9 else -1)
# Judge status: Accepted
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)] + [0]

ans = 0
for i in range(N):
    # できるだけ左でペアを作る
    Lpair = A[i] // 2
    ans += Lpair
    A[i] -= 2 * Lpair

    if A[i] > 0 and A[i + 1] > 0:
        ans += 1
        A[i] -= 1
        A[i + 1] -= 1


print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = [list(input().split()) for i in range(M)]

start = []
goal = []
for i in range(len(A)):
    if A[i][0] == '1':
        start.append(A[i])
    elif A[i][1] == str(N):
        goal.append(A[i])

is_ok = False
for j in range(len(start)):
    for k in range(len(goal)):
        if start[j][1] == goal[k][0]:
            is_ok = True
            break
    if is_ok:
        break

if is_ok:
    print('POSSIBLE')
else:
    print('INPOSSIBLE')
# Judge status: Wrong Answer
N = int(input())
a = [int(x) for x in input().split()]

M = max(a)

C = [0] * (M + 1)

for i in range(N):
    C[a[i]] += 1 

ans = 0

for i in range(1,M):
    wa = C[i - 1] + C[i] + C[i + 1]
    ans = max(ans, wa)

print(ans)
# Judge status: Accepted
from bisect import bisect_left, bisect_right

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

res = 0
for i in b:
    res += bisect_left(a, i) * (n - bisect_right(c, i))

print(res)
# Judge status: Wrong Answer
a, b, x = map(int, input().split())

if (a + b) >= x >= a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A,B,C = list(map(int,input().split()))
if A == B == C and A%2 == 0 :
    print(-1)
elif A == B == C and A%2 == 1 :
    print(0)
else :
    cnt=0
    while A%2==B%2==C%2==0:
        total=A+B+C
        A=total//2-A//2
        B=total//2-B//2
        C=total//2-C//2
        cnt+=1
    print(cnt)
# Judge status: Wrong Answer
r, g, b = map(int, input().split())
print("YES" if (r*100+g*10+b) % 4 == 0 else "No")
# Judge status: Accepted
S = input()

a = [True for _ in range(26)]

for s in S:
    a[ord(s) - ord("a")] = False

for i, aa in enumerate(a):
    if aa:
        print(chr(i + ord("a")))
        exit()

print("None")
# Judge status: Accepted
N, M = map(int, input().split())
maxL = 0
minR = N-1
LR = [0, N-1]
for i in range(M):
  LR = [int(i)-1 for i in input().split()]
  maxL = max(maxL, LR[0])
  minR = min(minR, LR[1])
if minR-maxL>=0:
  print(minR-maxL+1)
else:
  print(0)
# Judge status: Accepted
import heapq
n, m = map(int, input().split()) 

d = [[] for _ in range(m+1)]
for _ in range(n):
    a, b = map(int, input().split())
    if a < m+1:
        d[a].append(b)

hq = []
heapq.heapify(hq)
ans = 0
for i in range(1, m+1): 
    if len(d[i]) > 0:
        for j in d[i]:
            heapq.heappush(hq, j*(-1))
    if len(hq) > 0:
        ans += heapq.heappop(hq)*(-1)
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
 
if a<= c and c<=b:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
A = input()
D = input()
if A[0] == D[2] and A[1] == D[1] and A[2] == D[0]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
#n = int(input())
s = input()
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

if s == "hi":
    print("Yes")
    exit()
s = s.split("hi")
for i in s:
    if i != "":
        print("No")
        exit()
print("Yes")
# if len(s) != 1:
#     print("Yes")
# else:
#     print("No")
# Judge status: Accepted
n,m=[int(i) for i in input().split()]
dp=[1,1] ;a=set() ; mod=(10**9+7)
for i in range(m):
    a.add(int(input()))
if 1 in a: dp[1]=0
for i in range(2,n+1):
    if i not in a:
        dp.append((dp[-1]+dp[-2])%mod)
    else:
        dp.append(0)
print(dp[-1])
# Judge status: Accepted
# coding: utf-8

N = int(input())

x_ = N//1.08
ans = ':('
for i in range(1,100000):
    x = x_+i
    if int(1.08*x) == N:
        ans = int(x)
        break

print(ans)
# Judge status: Wrong Answer
def main():
    n = int(input())
    s = input().replace(')(', ') (').split()
    ans = ''
    for a in s:
        tmp = a
        lc = a.count('(')
        rc = a.count(')')
        if lc < rc:
            ans = '('*(rc - lc) + ans
        elif rc < lc:
            tmp += ')'*(lc - rc)
        ans += tmp
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
'''
Created on 2020/09/13

@author: okazakieiichiro
'''
num = input()

if num == 0:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
N = int(input())
S = [int(input()) for _ in range(N)]
total = sum(S)
for s in S:
    if total % 10 != 0:
        print(total)
        break
    else:
        total -= s
else:
    print(total)
# Judge status: Wrong Answer
n, x = map(int, input().split())
ns = list(map(int, input().split()))
d = 0
count = 0
for i in range(n):
    if d <= x:
        d += ns[i]
        count += 1
    else:
        break
print(count)
# Judge status: Accepted
S = len(input())
ans = ""
for i in range(S):
    ans += "x"
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
p,x = 0,0
l = [tuple(map(int,input().split())) for i in range(n)]
l.sort()
for a in l:
    if m-a[1]>=1:
        p+=a[0]*a[1]
        m-=a[1]
    else:
        p+=a[0]*m
        m=0
        break
print(p)
# Judge status: Accepted
S = list(input())
T = list(input())

def kakikae_count(S_i):
    count = 0
    for i in range(len(T)):
        if S[S_i + i] != T[i]:
            count += 1
    return count

min_count = len(T)
for i in range(0, len(S) - len(T) + 1):
    need_count = kakikae_count(i)
    if need_count < min_count:
        min_count = need_count
print(min_count)
# Judge status: Accepted
import sys

N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))

ans = 0
for i, p_i in enumerate(P):
    if p_i == i + 1:
        if i + 1 == N:
            P[i], P[i-1] = P[i-1], P[i]
        else:
            P[i+1], P[i] = P[i], P[i+1]
        ans += 1

print(ans)
# Judge status: Accepted
S = input()

ans = "Good"
for i in range(3):
    if S[i] == S[i + 1]:
        ans = "Bad"

print(ans)
# Judge status: Wrong Answer
chr1 = input(chr)
new = ord(chr1)+1
print(chr(new))
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
aa=min(a)
n-=k
import math
q=0
if n%(k-1)==0:
    q+=n//(k-1)
else:
    q+=n//(k-1)+1
print(q+1)
# Judge status: Wrong Answer
import math

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

def f(n):
  p_lis = []
  temp = n

  for i in range(2, int(math.sqrt(n)) + 1):
    if temp % i == 0:
      while temp % i == 0:
        temp //= i
      p_lis.append(i)
  
  if temp != 1:
    p_lis.append(temp)

  if p_lis == []:
    p_lis.append(n)

  return p_lis

ans = set(f(A)) & set(f(B))

print(len(ans) + 1)
# Judge status: Wrong Answer
n=int(input())
s=input()
ans=0
ans1=0
for i in range(n):
    if s[i]=='I':
        ans+=1
        ans1=max(0,ans)
    else:
        ans-=1
print(ans1)
# Judge status: Accepted
nn=int(input())
nc = [0] * (nn + 1)
for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      a = x * x + y * y + z * z + x * y + x * z + y * z
      if a > nn:
        break
      nc[a] += 1
for i in range(1, nn + 1):
  print(nc[i])
# Judge status: Wrong Answer
a,b = map(int, input().split())
c = 0
while a < b:
    if str(a)[::-1] == str(a):
        c += 1
    a += 1
print(c)
# Judge status: Accepted
d, n = map(int, input().split())
if n == 100:
  print(100**d*101)
else:
  print(100**d*n)
# Judge status: Accepted
import sys
input = sys.stdin.readline
from itertools import product

N,M,X=(int(x) for x in input().rstrip('\n').split())
pat = [x for x in product([0,1], repeat=N)]
OK = []
C={}
for i in range(N):
  C[i]=[int(x) for x in input().rstrip('\n').split()]
for i in pat:
  ans = [0]*(M+1)
  for x in range(N):
    add =  [y*i[x] for y in C[x]]
    ans = [y + z for (y,z) in zip(add,ans)]
  if all(y>=X for y in ans[1:]):
    OK.append(ans[0])
if len(OK) >0:
  print(min(OK))
else:
  print('-1')
# Judge status: Accepted
n, c, k = map(int, input().split())
times = []
for _ in range(n):
    t = int(input())
    times.append((t, t+k))
times.sort(key=lambda x: x[1])

ans = 0
x = 0
capacity = 0
for L, R in times:
    if L <= x:
        if c == capacity:
            capacity = 1
            ans += 1
            x = R
        else:
            capacity += 1
    else:
        x = R
        ans += 1
        capacity = 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
rslt = ""
sub = 1
while N >= 0:
    rslt = chr((N - 1) % 26 + ord('a')) + rslt
    sub *= 26
    N -= sub + (N % 26 - 1)
print(rslt)
# Judge status: Wrong Answer
a,b=map(int,input().split())
n=[1,3,5,7,8,10,12]
m=[4,6,9,11]
o=[2]
p=[n,m,o]
if p.count(a)==p.count(b):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
# coding: utf-8
# Your code here!
A,B,C = map(int,input().split())
v = A*B*C

if v%2 == 0:
    print(0)
else:
    print(min(A*B,B*C,C*A))
# Judge status: Accepted
str = input()
ipt = list(map(lambda x: int(x), str.split()))
ipt.sort()
if ipt[0]==ipt[1] and ipt[1]==ipt[2]:
  print('No')
elif ipt[0]==ipt[1] or ipt[1]==ipt[2]:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer


T = input()

T = T.replace("??", "PD");

T = list(T)
for i in range(len(T)):
    if T[i] == "?":
        T[i] = 'D'
        if i+1 < len(T):
            if T[i+1] == 'D':
                T[i] = 'P'


for i in T:
    print(i, end=""),
print()
# Judge status: Accepted
n = int(input())
l = []
for i in range(1,n):
    sur = n%i
    ans = n/i
   # print(i,ans,sur)
    if ans < i:
        break
    elif sur == 0:
        l.append(i)
l.sort(reverse=True)
max = l[0]
max_op = n/max
ite = max-1+max_op-1
print(int(ite))
# Judge status: Accepted
A, B, C, D = map(int, input().split())
T = max(B, D) + 1
ans = 0
for i in range(T):
    if A <= i < B and C <= i < D:
        ans += 1

print(ans)
# Judge status: Accepted
N,M=map(int, input().split()) 
if M == 1 or M==0:
    answer = N * (N-1)//2
elif N == 1 or N==0:
    answer = M * (M-1)//2    
else:
    answer = (N * (N-1))//2 + (M * (M-1))//2
print(answer)
# Judge status: Wrong Answer
N,R = map(int,input().split())

if N >= 10:
    print(R)
else:
    print(R-100*(10-N))
# Judge status: Wrong Answer
k, n = map(int, input().split())
a=[0]*n
a=list(map(int, input().split()))
for i in range(n):
    if a[i]>(k+0.5)//2:
        a[i]=int((k+0.5)//2)-a[i]
la=sorted(a)
print(max(a)-la[0])
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
N, K, Q = map(int, input().split())
A = [int(input().rstrip()) for i in range(Q)]
print(A)
score =[0]*(N)


for i in range(Q):
    score[A[i]-1] += 1
print(score)


for i in range(N):
    if K+score[i]-Q >0:
        print('yes')
    else:
        print('No')
# Judge status: Wrong Answer
N = int(input())
ls = []
now = 0
simekiri = 0
flag = 0
for i in range(N):
    a,b = map(int,input().split())
    ls.append([b,a])
ls.sort()
print(ls)
for i in range(len(ls)):
    simekiri = ls[i][0]
    now += ls[i][1]
    if now > simekiri:
        print("No")
        flag += 1
        break
if flag == 0:
    print("Yes")
# Judge status: Accepted
N, K = map(int, input().split())
p = list(map(int, input().split()))
sum = 0

p.sort()

for i in range(0, K):
    sum += p[i]

print(str(sum))
# Judge status: Accepted
n = int(input())
minus = 0
m = float("inf")
s = 0
for i in map(int,input().split()):
    if i < 0:
        minus += 1
        m = min(m,-i)
        s -= i
    else:
        m = min(m,i)
        s += i
if minus % 2 == 0:
    print(s)
else:
    print(s-2*m)
# Judge status: Wrong Answer
import math
a,b,x=map(int, input().split())
A=math.ceil(a/x)
B=math.floor(b/x)
print(B-A+1)
# Judge status: Wrong Answer
H, A = map(int, input().split())
print(H // A + 1)
# Judge status: Accepted
N,K=(int(x) for x in input().split())
x=N%K
print(min([x,abs(K-x)]))
# Judge status: Wrong Answer
from collections import Counter
mod = 998244353

n = int(input())
dl = list(map(int, input().split()))
c = Counter(dl)

if dl[0]!=0:
    print(0)
    exit()

for x in range(max(dl)+1):
    if c[x]==0:
        print(0)
        exit()

res = 1
for x in range(max(dl)):
    res *= pow(c[x],c[x+1],mod)
    res %= mod

print(res)
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]
L = [0] * n
cnt = 0
i = 0
while True:
    if L[i] == 1:
        print(-1)
        break
    else:
        L[i] = 1
        i = a[i] - 1
        cnt += 1
        if i == 1:
            print(cnt)
            break
# Judge status: Wrong Answer
n = int(input())

m  =  n // 2 +1
if n-m > 0: print(n-m)
print(m)
# Judge status: Accepted
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V > W and abs(A - B) / (V - W) <= T:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
K = int(input())
A, B = map(int,input().split())
n = 1
m = 1
for i in range(1100):
  if A <= K * i:
    n = i
for i in range(n, 1100):
  if B >= K * i:
    m = i - 1
if m - n >= 0:
  print("OK")
else:
  print("NG")
# Judge status: Accepted
s = int(input())
thld = pow(10,9)
x = (thld-s%thld)%thld
print(0, 0, thld, 1, x, (s+x)//thld)
# Judge status: Accepted
from collections import Counter
s=input()
t=Counter(s)
if len(t)==2 and max(t.values())==2:
	print("Yes")
else:
	print("No")
# Judge status: Wrong Answer
a,b = map(str, input().split())
c = int(a+b)
flag = False
for i in range(1000):
    if i**2 == c:
        flag = True
        exit(0)
print("Yes") if flag else print("No")
# Judge status: Accepted
w, h, x, y = map(int, input().split())

ans = (w*h)/2
num = 0
if w/2 == x and h/2 == y:
    num = 1

print(ans,num)
# Judge status: Accepted
def main():
    x = int(input())
    cnt = x // 11 * 2
    rem = x % 11
    if rem > 6:
        cnt += 2
    elif rem > 0:
        cnt += 1

    print(cnt)

if  __name__ == '__main__':
    main()
# Judge status: Accepted
import sys

N, M, X, Y = map(int, input().split())
X_lis = list(input().split())
X_lis = [int(X_lis[i]) for i in range(N)]
Y_lis = list(input().split())
Y_lis = [int(Y_lis[i]) for i in range(M)]

for Z in range(X+1, Y+1):
    if Z > max(X_lis) and Z <= min(Y_lis):
        print('No War')
        sys.exit()
    
print('War')
# Judge status: Accepted
n, k = map(int, input().split( ))
arr = []
for _ in range(n):
  arr.append(int(input()))
a = sorted(arr)
m = 10**9
for i in range(n-k+1):
  ma = a[i+k-1] - a[i]
  m = min(m, ma)
print(m)
# Judge status: Wrong Answer
n = int(input())

s = input()

e = int(s.count('E'))
w = n - e

if e >= w:
    print(w)
else:
    print(e)
# Judge status: Accepted
l = input()#三文字まで
counter = 0
for i in range(3):
    if l[i] == "1":
        counter += 1
print(counter)
# Judge status: Wrong Answer
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = II()
    cnt = 0
    val = 10
    while True:
        if n <= val: break
        cnt += n//val
        val *= 5
    print(cnt)

if __name__ == '__main__':
    main()
# Judge status: Accepted
y, m, d = map(str, input().split('/'))
print('2018' + '/' + m + '/' + d)
# Judge status: Accepted
import math
from decimal import Decimal

A,B=map(Decimal,input().split())
print(math.floor(A*B))
# Judge status: Accepted
X,Y=map(int,input().split())
mod=10**9+7
if (X+Y)%3!=0:
  print(0)
else:
  N=int((2*Y-X)/3)
  M=int((2*X-Y)/3)
  if N<0 or M<0:
    print(0)
  if N==0 or M==0:
    print(1)
  if N>0 and M>0:
    List=[0 for i in range(N+M)]
    List[0]=1
    for i in range(N+M-1):
      List[i+1]=List[i]*(i+2)%mod
    print(List[N+M-1]*pow(List[N-1],mod-2,mod)*pow(List[M-1],mod-2,mod)%mod)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=0
half=N//2+N%2
for i in range(1,N):
    if i<half:
        ans+=A[i-1]
    elif i==N-1:
        ans+=A[half-1]
    else:
        ans+=A[i-half+1]

print(ans)
# Judge status: Accepted
N = int(input())

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

m = 1000
s = 0
for i in range(N-1):
  if A[i]<A[i+1]:
    s = m//A[i]
    m += (A[i+1]-A[i])*s
print(m)
# Judge status: Accepted
import sys
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
for g in G[0]:
    if N - 1 in G[g]:
        print('POSSIBLE')
        sys.exit()
print('IMPOSSIBLE')
# Judge status: Wrong Answer
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = int(input())
    MOD = 10 ** 9 + 7

    if S <= 3:
        print(0)
        exit()

    dp = [1] * (S + 1)
    dp[0] = 0
    dp[1] = 0
    dp[2] = 0


    for i in range(3, S + 1):
        for j in range(i - 3, 1, -1):
            dp[i] += dp[j]
            dp[i] %= MOD

    print(dp[S] % MOD)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s=input()
print('YNeos'[(2<len(set(s))) or s[1]!=s[2]::2])
# Judge status: Accepted
import math
x, y = map(int, input().split())
if x%y == 0:
  print(-1)
else:
  print(x)
# Judge status: Accepted
s, t = input().split()
a, b = map(int, input().split())
u = input()

balls = {}

balls[s] = a
balls[t] = b

balls[u] = balls[u] - 1

print('{0} {1}'.format(balls[s], balls[t]))
# Judge status: Accepted
from bisect import bisect_right

n = int(input())

l = [1]
i = 1
while 6 ** i <= 100000:
    l.append(6 ** i)
    i += 1
i = 1
while 9 ** i <= 100000:
    l.append(9 ** i)
    i += 1
l.sort()

dp = [float('inf')] * (n+1)
dp[0] = 0
for i in range(1, n+1):
    for v in l:
        if v > i:
            break
        dp[i] = min(dp[i], dp[i-v] + 1)

print(dp[n])
# Judge status: Accepted
print(['TBD','Heisei'][input()<='2019/04/30'])
# Judge status: Wrong Answer
t = input()
t1 = t.replace('?', 'D')
t2 = t.replace('?', 'P')
print(max(t1.count('D') + t1.count('PD'), t2.count('D') + t2.count('PD')))
# Judge status: Accepted
from math import ceil

n, k = [int(_) for _ in input().split()]

a = [int(_) for _ in input().split()]

# a.sort()


l, r = 0, 10**9

while r-l > 1:

    m = (l+r)//2
    c = 0
    for i in range(n):
        if a[i] < m:
            continue
        c += a[i]//m-(a[i] % m == 0)
    # print(c, l, r, m)
    if c > k:
        l = m
    else:
        r = m

print(r)
# Judge status: Accepted
S = list(input())
s = 0
g = len(S) -1
while S[s] != "A":
    s += 1
while S[g] != "Z":
    g -= 1
print(g-s+1)
# Judge status: Accepted
a, b = map(int, input().split())
cnt=0
while a <=b:
  cnt+=1
  a = a*2
print(cnt)
# Judge status: Accepted
import sys

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def main():
    N, M = mi()
    if N == M == 1:
        print(1)
    elif N == 1 or M == 1:
        print(max(N, M)-2)
    else:
        print((N-2)*(M-2))


if __name__ == '__main__':
    main()
# Judge status: Accepted
A = input()

if A.isupper():
  print("A")
else:
  print("a")
# Judge status: Accepted
n = int(input())

s = 0

for i in range(1, n+1):
  s += i

print(s)
# Judge status: Accepted
a,b,c,d=map(int,input().split())
while(a>0 and c>0):
    c-=b
    a-=d
if c<=0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b,x = map(int,input().split())
tmp = 0

if x>b:
    print(0)
elif x<a:
    if a%x==0 or b%x==0:
        tmp += 1
    print((b-a)//x+tmp)
else:
    if b-a>=x:
        if a%x==0 or b%x==0:
            tmp += 1
        print((b-a)//x+tmp)
    else:
        if a%x+b%x==x:
            tmp += 1
        print(tmp)
# Judge status: Wrong Answer
n = int(input())
al = list(map(int, input().split()))

n_4, n_2, m = 0, 0, 0

for a in al:
    if a % 4 == 0:
        n_4 += 1
    elif a == 2:
        n_2 += 1
    else:
        m += 1

print('Yes' if n//2 - n_2//2 <= n_4 else 'No')
# Judge status: Accepted
Q, H, S, D = list(map(int, input().split()))
N = int(input())

calc = N//2 * min(8*Q, 4*H, 2*S, D) + (N%2) * min(4*Q, 2*H, S)

print(calc)
# Judge status: Accepted
import sys

input = sys.stdin.readline
MOD = 1000000007

Q,H,S,D = map(int,input().split())
N = int(input())

#1L min
min_1L = min(min(4*Q,2*H),S)

min_2L = min(D,2*min_1L)

#num of 2L
print(N//2*min_2L + N%2*min_1L)
# Judge status: Accepted
args = input().split()
args.sort(reverse=True)

num1 = int(''.join(args[0:2]))
num2 = int(''.join(args[2:3]))

print(num1+num2)
# Judge status: Accepted
A,B=map(int,input().split())
ans=0
for n in range(A,B+1):
  N=list(str(n))
  if N[0]==N[4] and N[1]==N[3]:
    ans+=1
print(ans)
# Judge status: Accepted
a=input()
s=[]
i=0
total=1000000
while True:
    s=100*int(a[i])+10*int(a[i+1])+int(a[i+2])
    d=abs(s-753)
    if total>d:
        total=d
    i+=1
    if i+2==len(a):
        print(total)
        break
# Judge status: Accepted
N,x=map(int,input().split())
a=list(map(int,input().split()))
temp=x
ans=0
a.sort()
i=-1
while True:
    i+=1
    x-=a[i]
    if x<0:
        break
    ans+=1
    if ans==N:
        break
if sum(a)<temp:
    ans-=1
    
print(ans)
# Judge status: Wrong Answer
s = input()

if s[2]==s[3] or s[4]==s[5]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = input()
N_list = list(N)
N = int(N)
K = len(N_list)

ans = int(N_list[0])+(K-1)*9
if N > ans:
    print(ans - 1)
else:
    print(ans)
# Judge status: Accepted
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
a, b = [int(x) for x in input().split()]
try:
    print(next(x for x in range(2000) if 8 * x // 100 == a and 10 * x // 100 == b))
except StopIteration:
    print(-1)
# Judge status: Wrong Answer
a,b = map(int,input().split())
count = 0
for i in range(a,b+1):
    c = list(str(i))
    L = len(c)
    if L%2 == 0:
        d = c[:int(L/2)]
        e = c[:int(L/2):-1]
    else:
        d = c[:int(L/2)]
        e = c[int(L/2)+1:]
        reversed(e)
    if d == e:
        count += 1
print(count)
# Judge status: Wrong Answer
L = int(input())
x = int(L/3)

if L%3 >= 1:
    y = int(L/3) + 1
else:
    y = int(L/3)

if L%3 >= 2:
    h = int(L/3) + 1
else:
    h = int(L/3)

print(x**3)
# Judge status: Wrong Answer
s = input().split()
print(s[0]+s[1]+s[2])
# Judge status: Wrong Answer
n=int(input())
s=input()
cnt=len(s)
a='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans=''
for i in range(cnt):
  ans=ans+a[(i+n)%26]
print(ans)
# Judge status: Wrong Answer
a, b, c= map(int, input().split())
if a==b==c:
  print(1)
elif a==b:
  print(2)
elif b==c:
  print(2)
else:
  print(3)