peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N,M=map(int,input().split())
if N==M==1:
    print(1)
elif N==1 or M==1:
    print(N*M-2)
elif N==2 or M==2:
    print(0)
else:
    print((N-2)*(M-2))
# Judge status: Wrong Answer
k, s = map(int, input().split())

count=0
for i in range(k+1):
  if s-i-2*k >=0:
    for j in range(k+1):
      if s-i-j-k>=0:
        for h in range(k+1):
          if i+j+h ==s:
            count+=1
print(count)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
count=0
count2=0
for i in range(n):
    if a[i]%4==0:
        count+=1
    elif a[i]%2==0:
        count2+=1
#print(count2)
if (n-count2//2)//2<count or n==count2 :
    print("Yes ")
elif  2<=count2  and (n-count2)//2<count:
    print("Yes ")
else:
    print("No")
# Judge status: Accepted
s=str(input())
s=list(s)
for i in range(0,len(s)):
  if i%2==0:
    if s[i]!="R" and s[i]!="U" and s[i]!="D":
      print("No")
      break
  else:
    if s[i]!="L" and s[i]!="U" and s[i]!="D":
      print("No")
      break
else:
  print("Yes")
# Judge status: Accepted
a = list(map(int,input().split()))
if a.count(5) == 2 and a.count(7) == 1:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
n = int(input())

xl = [[int(i) for i in input().split()] for j in range(n)]

xl.sort()

now = xl[0][0] + xl[0][1]
count = 1

if(n == 1):
    print(1)
else:
    for i in range(1, n):
        if(now <= xl[i][0] - xl[i][1]):
            count += 1
            now <= xl[i][0] - xl[i][1]

    print(count)
# Judge status: Wrong Answer
from sys import exit
 
N = int(input())
h = list(map(int,input().split()))
 
pre = 0
for i in range(N-1):
    if h[i] <= h[i+1]:
        pre = h[i]
    else:
        if h[i] - h[i+1] == 1:
            if pre > h[i]-1:
                print("No")
                exit(0)
            else:
                pre = h[i]-1
        else:
            print("No")
            exit(0)

print("Yes")
# Judge status: Accepted
n=input()
if n=="25":
     print("Christmas") 
elif n=="24":
     print("Christmas Eve") 
elif n=="23": 
      print("Christmas Eve Eve") 
elif n=="22": 
      print("Christmas Eve Eve Eve")
# Judge status: Accepted
# coding: utf-8
num, size = map(int,input().split())
data =[]
for x in range(num):
    data.append(input())
print(''.join(sorted(data)))
# Judge status: Accepted
from collections import deque

K = int(input())

q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

cnt  = 0


while q:
    x = q.popleft()

    cnt += 1
    if cnt == K:
        print(x)
        break

    y = x % 10
    z = 10*x+y
    if y != 0:
        q.append(z-1)
    q.append(z)
    if y != 9:
        q.append(z+1)
# Judge status: Wrong Answer
import math
ans=-100000000
a,b,n=map(int,input().split())
st=1
if n>1000000:
    st=b-1
for i in range(st,n+1):
    keep=math.floor(a*i/b)-a*math.floor(i/b)
    if ans<keep:
        ans=keep
print(ans)
# Judge status: Accepted
a, b = input().split()
num = int(a + b)
heihosu = []
for i in range(4, 1000):
    heihosu.append(i * i)
# print(heihosu)
if num in heihosu:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B,C = I()
if A <= C <= B:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from collections import deque
n, m = map(int, input().split())
way = [[] for i in range(n + 1)]
ans = [-1 for i in range(n + 1)]
reached = [0 for i in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    way[a].append(b)
    way[b].append(a)
D = deque([1])
while D:
    go = D.popleft()
    for i in way[go]:
        if reached[i] == 0:
            D.append(i)
            reached[i] = 1
            ans[i] = go
print('Yes')
for i in range(2, n + 1):
    print(ans[i])
# Judge status: Accepted
import sys
input = sys.stdin.readline

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

sd = sorted(d)
ss = sd[N//2-1]
sb = sd[N//2]
print(sb-ss)
# Judge status: Accepted
import sys
x=int(input())
for a in range(-1000,1000):
    for b in range(-1000,1000):
        if a**5-b**5==x:
            print(a,b)
            sys.exit()
# Judge status: Accepted
S, C = map(int, input().split())

if S>=C//2:
    print(C//2)
else:
    ans = S
    C -= S*2
    ans += C//4
    print(ans)
# Judge status: Wrong Answer
import sys
n = int(input())
dp=[sys.maxsize]*(n+1)
def beki(arg):
  res=0
  t=1
  while t < n:
    t=t*arg
    res+=1
  return res

dp[0]=0
a = beki(9)
b = beki(6)

for i in range(n):
  dp[i+1]=min(dp[i+1],dp[i]+1)
  for j in range(1,a):
    if i+9**j > n:
      break
    dp[i+9**j]=min(dp[i+9**j],dp[i]+1)
  for j in range(1,b):
    if i+6**j > n:
      break
    dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
print(dp[n])
# Judge status: Accepted
x = input()
x = '000'+x
z = x[:-2]
y = x[-2:]
s = 0
z = int(z)
y = int(y)
L = []
for i in range(1,21):
    s +=5
    if s>=y and z>=i:
        print(1)
        exit()
if z>=20:
    print(1)
    exit()
print(0)
# Judge status: Accepted
import sys

a, b = map(int,input().split())
num = int(a*b%2019)

for i in range(a, b + 1):
  for j in range(i + 1, b + 1):
    if(i >= j):
      continue
    num = min(num, (i*j)%2019)
    if(num == 0):
      print(0)
      sys.exit()

print(num % 2019)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))


c1=0
c2=0

from math import floor
for i in range(n):
    if a[i]>b[i]:
        c1+=a[i]-b[i]
    elif a[i]<b[i]:
        c2+=floor((b[i]-a[i])/2)

if c2>=c1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a, b, c = map(int, input().split())
if a < c < b or a > c > b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

a=0
result=0

for i in range(n-1):
  if A[i] > A[i+1]:
    a = A[i] - A[i+1]
    A[i+1] += a
    result += a
    
print(result)
# Judge status: Wrong Answer
#!/usr/bin/env python3

# input
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

# calc
d = {}
for i in s:
    if i in d.keys():
        d[i] += 1
    else:
        d[i] = 1 

for i in t:
    if i in d.keys():
        d[i] -= 1
    else:
        d[i] = -1

#import pdb; pdb.set_trace()
if len(d.keys()) != 1:
    print(max(d.values()))
else:
    print(max(list(d.values())[0], 0))
# Judge status: Wrong Answer
n = int(open(0).read())
i = 0
while i*(i+1)//2 <= n:
    i += 1
print(n - (i-1)*i//2 + i-1)
# Judge status: Wrong Answer
s = input()
if s == "AAA" or "BBB":
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
N  = int(input())
A = list(map(int, input().split()))
status = 0 # 0 = defalt 1 = up 2 = down
cnt = 1
for i in range(1,N):
    if A[i-1] < A[i]: #up petern
        if status == 0:
            status = 1
        elif status == 2:
            status = 0
            cnt += 1
    elif A[i-1] > A[i]:
        if status == 0:
            status = 2
        elif status:
            status = 0
            cnt += 1
print(cnt)
# Judge status: Accepted
x, n = map(int, input().split())
p = list(map(int, input().split()))
i = 0
while True:
  if x-i not in p:
    print(x-i)
    exit()
  elif x+i not in p:
    print(x+i)
    exit()
  i += 1
# Judge status: Accepted
import math
from functools import reduce
K = int(input())
ans = 0
for i in range(1, K-1):
    for j in range(i+1, K):
        for k in range(j+1, K+1):
            n = math.gcd(i, math.gcd(j,k))
            ans += 6*n
for i in range(1, K+1):
    for j in range(i+1, K+1):
        n = math.gcd(i,j)
        ans += 6*n
print(ans+sum(list(i for i in range(K+1))))
# Judge status: Accepted
def actual(n):
    s = str(n)

    if s[0] == s[1] == s[2] or s[1] == s[2] == s[3]:
        return 'Yes'
    return 'No'

    # if len(set(str(n))) <= 2:
    #     return 'Yes'
    #
    # return 'No'

s = input()
print(actual(s))
# Judge status: Accepted
n=input()
import re
n2 = re.split('(..)',n)[1::2]


if len(n) % 2 != 0:
    print('No')
else: 
    cnt = 0
    for i,s in enumerate(n2):
        if 'hi' in s:
            cnt += 1
    if cnt == len(n2):
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
a,b=map(int,input().split())
if a==1 and b!=1:
    print("Alice")
elif a!=1 and b==1:
    print("Bob")
elif a==1 and b==1:
    print("Draw")
else:
    if a>b:
        print("Alice")
    elif a<b:
        print("Bob")
    else:
        print("Draw")
# Judge status: Accepted
a,b= map(int,input().split())
if b !=100:
  print((100 ** a)*b)
else:
  print((100 ** a)*(b+1))
# Judge status: Accepted
S = input()
cnt = []
c = S[0]
tmp = 0
for i in range(len(S)):
	if S[i] == c:
		tmp += 1
	else:
		cnt.append(tmp)
		c = S[i]
		tmp = 1
cnt.append(tmp)

cnt_S, cnt_T = 0,0
delete = 0
if S[0] != 'S':
	cnt.pop(0)
cnt_S = cnt[0]
for i in range(1,len(cnt),2):
	if cnt_S >= cnt[i]:
		cnt_S -= cnt[i]
		delete += cnt[i]*2
	else:
		delete += cnt_S*2
		cnt_S = 0

	if i+1 >= len(cnt):
		break

	cnt_S += cnt[i+1]

print(len(S)-delete)
# Judge status: Accepted
n=int(input());print(n*(n+1)//2)
# Judge status: Accepted
n = int(input())
ans=(n*(n-1))//2
print(int(ans))
# Judge status: Accepted
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
import heapq as hq
gcd = math.gcd
n,k = ma()
A = list(ma())
mi = min(A)
cnt = 0
ans = 0
f = True #これまでにmiが含まれていないか
for a in A:
    if a==mi:
        if f or cnt==0:
            f = False
            continue
    cnt+=1
    if cnt ==k-1:
        ans+=1
        cnt=0
        f=True
if cnt>0:ans+=1

print(ans)
# Judge status: Accepted
import sys
input=sys.stdin.readline

n=int(input())

pt=0
pxy=0
for i in range(n):
    t,x,y=map(int,input().split())
    dt=t-pt
    dxy=abs(x+y-pxy)
    if dxy>dt or dt%2!=dxy%2:
        print('No')
        exit()
else:
    print('Yes')
# Judge status: Wrong Answer
N, x = map(int, input().split())
a = list(map(int, input().split()))

# 小さい数から配っていくと子供の人数を最大化できる
a = sorted(a)

leftCandy = 0
childrenCnt = 0
for i in range(len(a)):
  leftCandy = x - a[i]
  if leftCandy >= 0:
    childrenCnt += 1

if leftCandy > 0:
  print(N-1)
else:
  print(childrenCnt)
# Judge status: Accepted
num = int(input())
l = list(map(int, input().split()))
count = 1
var = var2 = 0
c = l[0]
for i in l[1:]:
    if c < i:
        var = 1
    elif c > i:
        var2 = 1
    if var == 1 and var2 == 1:
        count += 1
        var = var2 = 0
    c = i
print(count)
# Judge status: Accepted
S = str(input())
N = len(S)
for i in range(N-1):
    for j in range(i+1, N):
        tmp = S[:i+1] + S[j:]
        if tmp == 'keyence':
            print('YES')
            quit()

print('NO')
# Judge status: Accepted
s = input()
if len(s.replace("hi", "")) == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=int(input())
a=[2,4,5,7,9]
b=[0,1,6,8]
f=N%10
if f in a:
  print("hon")
elif f in b:
  print("pon")
else:
  print("bon")
# Judge status: Accepted
S = input()
N = len(S)

S_1 = S[0:int((N-1)/2)]
S_2 = S[int((N+3)/2-1):N+1]

print('Yes' if S[::-1] == S and S_1[::-1] == S_1 and S_2[::-1] == S_2 else 'No')
# Judge status: Accepted
n, m = map(int, input().split())

A = [0] * n
B = [0] * n

for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        A[b-1] = 1
    elif b == 1:
        A[a-1] = 1
    elif a == n:
        B[b-1] = 1
    elif b == n:
        B[a-1] = 1

for i in range(n):
    if A[i] == B[i] == 1:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
# Judge status: Wrong Answer
from collections import Counter

s = list(input())
t = list(input())

if Counter(s) == Counter(t):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
X, N = map(int, input().split())
p = list(map(int, input().split()))

d = {i: 1 for i in p}
idx = X
while True:
    if d.get(idx) is None:
        ans_plus = idx
        break
    else:
        idx += 1

idx = X
while True:
    if d.get(idx) is None:
        ans_minus = idx
        break
    else:
        idx -= 1

if abs(X - ans_plus) < abs(X - ans_minus):
    print(ans_plus)
else:
    print(ans_minus)
# Judge status: Accepted
vars = input().split()
n,a,b = int(vars[0]),int(vars[1]),int(vars[2])
passed = 0
os = 1
parts = input()
for c in parts:
  if c=="c":
    print("No")
  elif c=="b" and passed<a+b and os<=b:
    print("Yes")
    passed += 1
    os += 1
  elif c=="a" and passed<a+b:
    print("Yes")
    passed += 1
  else:
    print("No")
# Judge status: Wrong Answer
N=int(input())
a_list = list(map(int,input().split()))
ans = 0
min = a_list[0]
for i in range(1,N):
  if min > a_list[i]:
    ans += a_list[i]-min
  else:
    min = a_list[i]
print(ans)
# Judge status: Accepted
import sys
import math

N = int(input())
if N % 2 == 1:
    print(0)
    sys.exit()

count_2 = 0
count_5 = 0
deno = 2
while deno <= N:
    count_2 += N // deno
    deno *= 2

deno = 10
while deno <= N:
    count_5 += N // deno
    deno *= 5

print(min(count_2, count_5))
# Judge status: Accepted
H = int(input())
p = 0
for i in range(50):
    if 2**i <= H and H < 2**(i + 1):
        p = i
        break
# print(p)
print(2**(p + 1) - 1)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
  if a[i] <= b[i]:
    if a[i+1] >= b[i] - a[i]:
      ans += b[i]
      a[i+1] -= b[i] - a[i]
    else:
      ans += a[i] + a[i+1]
      a[i+1] = 0
  else:
    ans = b[i]
print(ans)
# Judge status: Accepted
w=['Sunny', 'Cloudy', 'Rainy']
print(w[(w.index(input())+1)%3])
# Judge status: Accepted
n,k=list(map(int,input().split()))
li=[]
for _ in range(n):
  a,b=list(map(int,input().split()))
  li.append([a,b])
li.sort()

for a,b in li:
  k -= b
  if k <= 0:
    print(a)
    break
# Judge status: Accepted
import math
def main():
    S = int(input())
    r = math.ceil(math.sqrt(S))
    print(0, 0, r, 1, r * r - S, r)

main()
# Judge status: Accepted
D,N=map(int,input().split())
print(100**D*N if N!=100 else 100**D*101)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
if n==0 and a[0]!=1:
  print(-1)
  exit()
b=[a[0]==0]
for i in a[1:]:
  b+=[2*b[-1]-i]
  if b[-1]<0:
    print(-1)
    exit()
b.pop()
ans=root=a[-1]
a=a[::-1]
b=b[::-1]
for i,j in zip(a[1:],b):
  root=min(root,j)+i
  ans+=root
print(ans)
# Judge status: Accepted
s = input()
if (int(s[:2]) >= 13 or s[:2] == '00') and (int(s[2:4]) >= 13 or s[2:4] == '00'):
    print('NA')
elif 0 < int(s[:2]) <= 12 and 0 < int(s[2:4]) <= 12:
    print('AMBIGUOUS')
elif 0 < int(s[:2]) <= 12:
    print('MMYY')
else:
    print('YYMM')
# Judge status: Accepted
X = int(input())

if X >=400 and X<600:
    print(8)
elif  X<800:
    print(7)
elif  X<1000:
    print(6)
elif  X<1200:
    print(5)
elif  X<1400:
    print(4)
elif  X<1600:
    print(3)
elif  X<1800:
    print(2)
elif  X<2000:
    print(1)
# Judge status: Accepted
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
n, m = map(int, input().split())
a = [int(i) * -1 for i in input().split()]
# print(a)
heapq.heapify(a)
for i in range(m):
    maximum = heapq.heappop(a) * -1
    heapq.heappush(a, (maximum // 2) * -1)
print(sum(a) * -1)
# Judge status: Wrong Answer
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
for i in range(d):
    print(i % d + 1)
# Judge status: Accepted
X,N = map(int, input().split())
P = list(map(int, input().split()))
maxP = 0 if P == [] else max(P)
le = 1000
for k in reversed(range(X+1)):
  if k not in P:
    le = X-k
    ans = k
    break
# for k in range(X,maxP+1):
for k in range(X,102):
  if k not in P:
    if le > k-X:
      ans = k
      break
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(K):
  imos = [0] * (N + 1)
  for i in range(N):
    l = max(0, i - a[i])
    r = min(N - 1, i + a[i]) + 1
    imos[l] += 1
    imos[r] -= 1
  for i in range(N): imos[i + 1] += imos[i]
  a = imos[: -1]
  if a.count(N) == N: break
print(*a)
# Judge status: Accepted
k,x = map(int,input().split())

ans = [str(i) for i in range(x-k+1,x+k)]
print(" ".join(ans))
# Judge status: Wrong Answer
n=int(input())
ans = ""
for c in input():
  print(ord(c),ord('A'))
  ans+= chr((ord(c)-ord('A')+n)%26+ord('A'))
print(ans)
# Judge status: Wrong Answer
s = input()
q = int(input())
flag = 1
for i in range(q):
    A = list(input().split())
    if A[0] == '1':
        flag *= -1
    else:
        if flag * int(A[1]) == 1 or -2:
            s = A[2]+s
        else:
            s = A[2]+s
if flag == -1:
    print(s[::-1])
else:
    print(s)
# Judge status: Accepted
a , b = map(int , input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
x,a,b = map(int,input().split())
A= 1
syoumikigen = A + a
B = A + b
safe = syoumikigen + x
out = safe + 1
if B <= syoumikigen:
    print("delicious")
elif syoumikigen < B <= safe:
    print("safe")
else:
    print("dangerous")
# Judge status: Accepted
a,b=map(int,input().split())
if (a>b and b!=1) or (a==1 and b!=1):
   print('Alice')
elif (a<b and a!=1) or (a!=1 and b==1):
    print('Bob')
else:
    print('Draw')
# Judge status: Accepted
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print(-1)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

MOD = 10**9+7
S = sum(A)
ans = 0

for i in range(N-1):
    S -= A[i]
    ans = (ans + S*A[i])%MOD
    
print(ans)
# Judge status: Accepted
def main():
    a,b=map(int, input().split())
    if(a%3==0 or b%3==0 or (a+b)%3==0):
        print("Possible")
    else:
        print("Impossible")
if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
*A, = map(int, input().split())

Pmax = [0 for _ in range(N+1)]
Pmax[0] = 1-A[0]
for i in range(1, N+1):
    Pmax[i] = 2*Pmax[i-1] - A[i]

ans = 0
v = 0
for i in range(N, -1, -1):
    if Pmax[i]*2 < v:
        ans = -1
        break
    v = min(v, Pmax[i])+A[i]
    ans += v

print(ans)
# Judge status: Wrong Answer
w,h,x,y = map(int,input().split())
men1 = min(h*x,h*(w-x))
men2 = min(w*y,w*(h-y))

print(max(men1,men2),sep = " ",end = "")
if men1 == men2:
    print(" 1")
else:
    print(" 0")
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

pos = -1
seen = [False] * n
last = [-1] * n
hist = []
i = 0
cnt = 0

while(seen[i] == False):
    seen[i] = True
    last[i] = cnt
    cnt += 1
    hist.append(i)
    ne = a[i]-1
    i = ne
    if (seen[i] == True):
        pos = i

cycle = hist[last[pos]:]
preCircle = last[pos]

if (k <= preCircle):
    print(hist[k] + 1)
else:
    k -= preCircle
    ans = k % len(cycle)
    print(cycle[ans] + 1)
# Judge status: Wrong Answer
from math import sqrt
a,b,c=map(int,input().split())
if sqrt(a)+sqrt(b)<sqrt(c):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a,b=map(int,input().split())
if (a+b)%2==0:
    print(int((a+b)/2))
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
#
s = [[] for i in range(D)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
v = 0
cc =  np.array( [0]*26 )
last = np.array( [-1]*26 )
for d in range(D):
  cc += c
  av = s[d] - sum( cc ) + cc
  av2 = av + cc*min((D-d-1),3)
  m = max(av2)
  for t in range(26):
    if av2[t] == m:
      cc[t] = 0
      v += av[t]
      print(t+1)
      break
#
#print( v )
# Judge status: Accepted
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
m = 1000005

count = 0
cnt = [0] * m
for i in range(n):
  if cnt[a[i]] == 0:
    for j in range(a[i], m, a[i]):
      cnt[j] += 1
  else:
    cnt[a[i]] = 2
for i in range(n):
  if cnt[a[i]] == 1:
    count += 1
print(count)
# Judge status: Accepted
x=int(input())
if x%11==0:
  print((x//11)*2)
else:
  if x%11<7:
    print((x//11)*2+1)
  else:
    print((x//11)*2+2)
# Judge status: Wrong Answer
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    p = list(map(int,input().split()))

    for i in range(n):
        if x-i in p:
            if x+i in p:
                a =0
            else:
                print(x+i)
                exit(0) 
        else:
            print(x-i)
            exit(0)
# Judge status: Accepted
# C - Reconciled?
def main():
    from math import factorial

    n, m = map(int, input().split())
    p = 10**9+7

    if abs(n-m) < 2:
        if n == m:
            print(2*factorial(n)*factorial(m)%p)
        else:
            print(factorial(n)*factorial(m)%p)
    else:
        print(0)

if __name__ ==  "__main__":
    main()
# Judge status: Wrong Answer
import sys
S = list(">")
lis = [0] * (len(S)+1)

if len(S) == 1:
    print(1)
    sys.exit()


#最初は < を処理する
for i in range(len(S)):
    if S[i] == "<":
        lis[i+1] = lis[i] + 1




for j in range(len(S)-1,-1,-1):
    if S[j] == ">":
        lis[j] = max(lis[j],lis[j+1] + 1)



print(sum(lis))
# Judge status: Accepted
def resolve():
    N, Y = map(int, input().split())

    resx, resy, resz = (-1, -1, -1)
    for x in range(N+1):
        for y in range(N+1-x):
            z = N - x - y
            total = 10000*x + 5000*y + 1000*z

            if total == Y:
                resx, resy, resz = (x, y, z)
                break
    
    print(resx, resy, resz)
    
resolve()
# Judge status: Accepted
# palace
n = input()
T, target = [int(e) for e in input().split()]
H = list(map(int, input().split()))

average_temp = []
min_diff = float('inf')
index = -1

for index, value in enumerate(H):
    average_temp = T - value*0.006
    diff = abs(target - average_temp)
    if min_diff > diff:
        min_diff = diff
        min_index = index+1
print(min_index)
# Judge status: Accepted
import bisect
N=int(input())
L=sorted(map(int,input().split()))
count=0
for a in range(N-2):
    for b in range(a+1,N-1):
        count+=bisect.bisect_left(L,L[a]+L[b])-(b+1)
print(count)
# Judge status: Accepted
a, b, c = map(int, input().split())
print(max(c-(a-b), 0))
# Judge status: Accepted
N,M = map(int,input().split())
mi = 0
ma = 10 ** 6
for i in range(M):
  L,R = map(int,input().split())
  mi = max(mi,L)
  ma = min(ma,R)
if(ma - mi + 1 <= 0):
  print("0")
else:
  print(str(ma - mi + 1))
# Judge status: Wrong Answer
N = int(input())
point = []
arm = {}
for n in range(N):
    i, L = map(int, input().split())
    point.append(i)
    arm[i] = L
sorted_point = sorted(point)
count = 1
pre_point = sorted_point[0]
for n in range(1, len(sorted_point), 1):
    if arm[sorted_point[n]] + arm[pre_point] <= sorted_point[n]-pre_point :
        count += 1
        pre_point = sorted_point[n]
print(count)
# Judge status: Wrong Answer
import math
flag = 0
a,b = map(int,input().split())

for i in range(1000):
    if int(i*0.08) == a and int(i*0.1) == b:
        print(i)
        break
    elif i*0.08 > a and i*0.1 > b:
        print(-1)
        break
# Judge status: Wrong Answer
import math

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

for i in range(len(A)):
    A[i] -= (i + 1)
# print(A)

average = math.floor(sum(A) / len(A))

for i in range(len(A)):
    A[i] = abs(A[i] - average)

sadness = sum(A)

print(sadness)
# Judge status: Accepted
L = int(input())

print ((L/3) ** 3)
# Judge status: Accepted
W, a, b = list(map(int,input().split()))

a, b = sorted([a,b])

print(max(b-(a+W),0))
# Judge status: Wrong Answer
A = int(input())
B = int(input())

print(5-A-B)	#和から誤答を引けば正答
# Judge status: Accepted
s=sorted(input())
if s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]:print("Yes")
else:print("No")