peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
n, k, q = map(int, input().split())

scores = {i: 0 for i in range(1, n+1)}
for _ in range(q):
    n = int(input())
    scores[n] += 1

for i, score in sorted(scores.items()):
    if k + score - q > 0:
        print('YES')
    else:
        print('NO')
# Judge status: Accepted
N = int(input())
A = input().split()
l=list()
for i in range(N):
    A[i] = int(A[i])
    if A[i] % 2 == 1:
        l.append(0)
        break
    else:
        for j in range(30):
            A[i] = A[i] / 2
            if A[i] % 2 == 1:
                l.append(j+1)
                break
print(min(l))
# Judge status: Accepted
N = int(input())
A = list(int(input()) - 1 for _ in range(N))

x = 0

for i in range(N):
    x = A[x]
    if x == 1:
        print(i + 1)
        break
else:
    print(-1)
# Judge status: Accepted
n = int(input())
ans = [0] * (10**5)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            ans[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i-1] += 1
for i in range(n):
    print(ans[i])
# Judge status: Accepted
#!/usr/bin/env python3
# from typing import *

# def solve(X: int, Y: int, Z: int) -> Any:
def solve(x, y, z):
    x, y = y, x
    x, z = z, x
    return x, y, z

# generated by online-judge-template-generator (https://github.com/kmyk/online-judge-template-generator)
def main():
    X, Y, Z = map(int, input().split())
    ans = solve(X, Y, Z)
    print(*ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
s = []
for _ in range(n):
    s.append(input())

import collections
c = collections.Counter(s)
ans=[]
first=c.most_common()[0][1]
for tup in c.most_common():
    if tup[1] != first:
        break
    ans.append(tup[0])
ans.sort()

for i in ans:
    print(i)
# Judge status: Accepted
N=int(input())
count=0
max=0


for a in range(1,N+1):
    while(a%2==0):
        a/=2
        count+=1
    if(max<count):
        max=count
    count=0

print(2**max)
# Judge status: Accepted
n,m = map(int, input().split())
diff = abs(abs(n) - abs(m))
res = diff

if abs(n) <= abs(m):
  if n < 0:
    res += 1
  if m < 0:
    res += 1
  print(res)

else:
  if n > 0:
    res += 1
  if m > 0:
    res += 1
  print(res)
# Judge status: Wrong Answer
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

now = 1
for i in range(len(a[k:])):
    new = now * a[i + k] / a[i]
    if new > now:
        print("Yes")
    else:
        print("No")

    now = new
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    x,y = map(int, input().split())
    print(int(math.log(y/x,2)+1))


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
S = input()

d = [0] * N
if S[0] == "(":
    d[0] = 1
else:
    d[0] = -1
for i in range(1,N):
    d[i] = d[i-1]
    if S[i] == "(":
        d[i] += 1
    else:
        d[i] -= 1
        
x = max(-min(d), 0)
S = "(" * x + S + ")" * (d[N-1] + x)
print(S)
# Judge status: Accepted
S = input()
if (S[0] == S[1] and S[2] == S[3]) or (S[0] == S[2] and S[1] == S[3]) or (S[0] == S[3] and S[1] == S[2]):
  if S[0] == S[1] == S[2] == S[3]:
    print("No")
  else:
    print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)][::-1]
ans = 0
tmp = 0
add = 0
for i in range(N):
    add += tmp
    if (arr[i][0]+add) % arr[i][1] == 0:
        continue
    tmp = arr[i][1] - ((arr[i][0]+add) % arr[i][1])
    ans += tmp
print(ans)
# Judge status: Accepted
N=int(input())
if N==3 or N==5 or N==7:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
s = list(input())

ans = 0

for i in range(1,len(s)):
    if s[i] == s[i-1]:
        if s[i] == "0" :
            s[i] = "1"
        else:
            s[i] = "0"
        ans += 1

print(ans)
# Judge status: Wrong Answer
n=int(input())
alis=list(map(int,input().split()))
p=alis[0]
inf=10e+18
for i in range(1,n):
  p*=alis[i]
  if len(str(p))>18:
    print(-1)
    exit()
print(p)
# Judge status: Accepted
s=input()
chk={}
for i in range(4):
  if s[i] in chk:
    chk[s[i]]+=1
  else:
    chk[s[i]]=1
print("Yes" if len(chk)==2 and chk[s[0]]==2 else "No")
# Judge status: Accepted
n = input()

if n in 'aeiou':
    print('vowel')
else:
    print('consonant')
# Judge status: Wrong Answer
x = input().split()
y = input().split()



a = [int(i) for i in x]
b = [int(i) for i in y]

M = a[1]
s = sum(b)
c = 0
f = False

for i in b:
    if i >= ((1/(4*M)*s)):
        c += 1
    if c > 1:
        print("Yes")
        f = True
        break

if not f:
    print("No")
# Judge status: Accepted
N, K = map(int, input().split())
p = list(map(int, input().split()))
S = 0

p.sort()

for i in range(K):
    S += p[i]

print(S)
# Judge status: Accepted
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

iter_list = list(range(1, N+1))
permutations_list = list(itertools.permutations(iter_list, N)) #辞書順でリストに格納される

a = permutations_list.index(P)
b = permutations_list.index(Q)

print(abs(a-b))
# Judge status: Accepted
n,m=map(int,input().split())
a,b,c=[],[],[]
for i in range(n):
    a.append(list(map(int,input().split())))
    c.append([])
for i in range(m):
    b.append(list(map(int,input().split())))
for i in range(n):
    for j in range(m):
        c[i].append(abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1]))
for i in range(n):
    print(c[i].index(min(c[i]))+1)
# Judge status: Wrong Answer
N=int(input())
counter=0
flag=0
for i in range(N):
     D1, D2=map(int,input().split())
     if D1==D2:
         counter+=1
     else:
         counter=0
         if counter>=3:
             flag=1
             break
if flag==1:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
x, y = map(int,input().split())

aG = [1,3,5,7,8,10,12]
bG = [4,6,9,11]
cG = [2]

if (x in aG and y in aG) or (x in bG and y in bG) and (x in cG and y in cG):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=0
import collections
c=collections.Counter(a)
values,counts=zip(*c.most_common())
lv=list(values)
lc=list(counts)
temp=[]
for i in range(0,len(lc)):
  if lc[i]>=4:
    temp.append(lv[i])
    temp.append(lv[i])    
  elif lc[i]>=2:
    temp.append(lv[i])
temp.sort(reverse=True)
if len(temp)>=2:
  ans=temp[0]*temp[1]
print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[0]*(n-k)
for i in range(k,n):
    ans[i-k]=(a[i]>a[i-k])
for i in range(0,n-k):
    print("Yes" if ans[i] else "No")
# Judge status: Accepted
def main():
    N,K = map(int, input().split())
    p = [int(i) for i in input().split()]

    tmp_max = sum(p[:K])
    tmp = sum(p[:K])
    for i in range(N-K):
        tmp += p[K+i]
        tmp -= p[i]

        if tmp > tmp_max:
            tmp_max = tmp

    ans = (tmp_max + K) / 2
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
S = sum(A)

for _ in range(int(input())):
    b, c = map(int, input().split())
    k = count[b]
    count[b] = 0
    count[c] += k
    S += (c - b) * k
    print(S)
# Judge status: Accepted
import math
s = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y3 = math.ceil(s/10**9)
y2 = 1
x3 = x2*y3-s

print(x1,y1,x2,y2,x3,y3)
# Judge status: Accepted
N = int(input())
l = []
for i in range(N):
    l.append([int(x) for x in input().split()])

xlim = []
ylim = []

def cha(a):
    return [a[0]-a[1],a[0]+a[1]]

for i in range(N):
        ylim.append(cha(l[i])[1])
        xlim.append(cha(l[i])[0])

xlim.sort()
ylim.sort()

print(max(xlim[-1]-xlim[0],ylim[-1]-ylim[0]))
# Judge status: Wrong Answer
s = input()
t = input()
if 1 <= len(s) <= 10:
    if s in t and len(s) + 1 == len(t):
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
n=int(input())
a=[int(x) for x in input().rstrip().split()]

ruiseki=[0]
for i in range(n):
  ruiseki.append(ruiseki[i]+a[i])

ans=float('inf')
last=ruiseki[len(ruiseki)-1]
# print(last)
# print(ruiseki)
for i in range(1,len(ruiseki)-1):
  now=(last-ruiseki[i])
  ans=min(ans,abs(ruiseki[i]-now))
print(ans)
# Judge status: Accepted
N=int(input())
if N%2==0:
    print(N/2/N)
else:
    print((N+1)/2/N)
# Judge status: Accepted
N = int(input())
A = int(input())
if N % 500 <= A:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = list(map(int, input()[::-1])) + [0]
s = 0
res = 0
for i, ni in enumerate(n[:-1]):
    k = ni + s
    if k < 5 or (k == 5 and int(n[i + 1]) < 5):
        res += k
        s = 0
    else:
        res += 10 - k
        s = 1
res += s
print(res)
# Judge status: Accepted
a = int(input())
s = input()
print(s if a >= 3200 else 'red')
# Judge status: Wrong Answer
def main():
    N = 10**9
    s = int(input())
    s *= 2
    a,b = 0,0
    i = 1
    while True:
        if s % i == 0:
            if s // i <= N:
                a = i
                b = s//i
                break
        if i * i > s:break
        i+= 1
    print("0 0 {0} 0 0 {1}".format(str(a),str(b))) 


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import math
mod = 10**9 + 7

def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

lis = list()

lis.append(combinations(n, a))
lis.append(combinations(n, b))

2**n-1 - sum(lis)%mod
# Judge status: Accepted
N, K = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(K*2)]

indexs = []
for i in range(len(L)):
    if i%2 != 0:
        indexs.append(L[i])

uniq_list = []
for li in indexs:
    for e in li:
        if e not in uniq_list:
            uniq_list.append(e)

print(N - len(uniq_list))
# Judge status: Accepted
k = int(input())

l = [1,2,3,4,5,6,7,8,9]

c = 0
while k>len(l):
    f = str(l[c])

    if int(f[-1])!=0:
        l.append(int(f)*10 + int(f[-1])-1)

    l.append(int(f)*10 + int(f[-1]))

    if int(f[-1])!=9:
        l.append(int(f)*10 + int(f[-1])+1)

    c += 1

print(l[k-1])
# Judge status: Accepted
n,k=map(int,input().split())
count=[0]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        count[a[j]-1]+=1
ans=0
for i in range(n):
    if count[i]==0:
        ans+=1
print(ans)
# Judge status: Wrong Answer
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
pos = a.index(1)+1
right = n-pos
left = pos
ans = 0
if n == k:
    print(1)
    exit()
if right < k-1:
    right = n
    left = n-k
    ans = 1
if left < k-1:
    left = 0
    right = k
    ans = 1
print(math.ceil((n-right)/(k-1)) + math.ceil(left/(k-1))+ans)
# Judge status: Accepted
x, y = map(int, input().split())

list_1 = [1, 3, 5, 7, 8, 10, 12]
list_2 = [4, 6, 9, 11]
list_3 = [2]

if x in list_1:
  tmp = list_1
elif x in list_2:
  tmp = list_2
else:
  tmp = list_3

if y in tmp:
  ans = 'Yes'
else:
  ans = 'No'

print(ans)
# Judge status: Wrong Answer
N, Q = map(int, input().split())
S = list(input())

mark = [0]*(N+1)

for i in range(2, N+1):
    if S[i-2] == 'A' and S[i-1] == 'C':
        mark[i] = mark[i-1] + 1
    else:
        mark[i] = mark[i-1]

for i in range(Q):
    l,r = map(int,input().split())
    print(l, r)
    print(mark[r]-mark[l])
# Judge status: Accepted
import heapq

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

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

heapq.heapify(cands[0])
total = 0
for i in range(m):
    if len(cands[0]) > 0:
        total -= heapq.heappop(cands[0])
    if i < m - 1:
        for c in cands[i + 1]:
            heapq.heappush(cands[0], c)

print(total)
# Judge status: Wrong Answer
n = int(input())
w = list(map(int, input().split()))

m = sum(w)//2
s = 0
for i in range(1,n):
  if sum(w[:i]) >= m:
    s = abs(sum(w[:i]) - sum(w[i:]))
    break

l = w[::-1]
t = 0
for i in range(1,n):
  if sum(l[:i]) >= m:
    t = abs(sum(l[:i]) - sum(l[i:]))
print(min(s,t))
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if a-b>k and a-c>k and a-d>k and a-e>k and b-c>k and b-d>k and b-e>k and c-d>k and c-e>k and d-e>k:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
N = int(input())
 
tmp = int(input())
rlt = tmp//2
tmp -= 2*(tmp//2)

for i in range(1,N):
  a = int(input())
  if a == 0:
    tmp = 0
  elif tmp == 1:
    rlt += 1
    a -= 1
  tmp = a
  rlt += tmp//2
  tmp -= 2*(tmp//2)
  
print(rlt)
# Judge status: Wrong Answer
import math
import sys
from functools import reduce
input = sys.stdin.readline

def fullsearch(a):
    for i in range(-100, 101):
        yield reduce(lambda total, x: (x - i) ** 2 + total, a, 0)

def main():
    input()
    print(min(fullsearch(int(c) for c in input().split())))

main()
# Judge status: Accepted
first = input().split(' ')
health = int(first[0])
skills_count = int(first[1])

second = input().split(' ')
skills = [int(s) for s in second]

if sum(skills) < health:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
N = int(input())
h = list(map(int, input().split()))
ans = True
MIN = h[0]-1

for i in range(N-1):
    MIN = max(MIN, h[i]-1)
    if h[i] > h[i+1]:
        if h[i]-h[i+1] > 1:
            ans = False
            break
        else:
            if MIN > h[i+1]:
                ans = False
                break

if ans:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
temp=100
ans=0
dp=list(list(map(int,input().split())) for i in range(n))

for i in range(1,n):
  dp[i][0]+=max(dp[i-1][1], dp[i-1][2])
  dp[i][1]+=max(dp[i-1][0], dp[i-1][2])
  dp[i][2]+=max(dp[i-1][1], dp[i-1][0])
print(max(dp[n-1]))
# Judge status: Wrong Answer
n = int(input())
s = input()
t = input()

cnt = 0
for i in range(n):
  if s[-(i+1)] == t[i]:
    cnt += 1

print(2 * n - cnt)
# Judge status: Accepted
h, a = map(int, input().split())
print((h + a - 1) // a)
# Judge status: Accepted
N,K=map(int,input().split())
A = list(map(int, input().split()))

count={}

for i in range(N):
  if A[i] not in count:
    count[A[i]]=1
  else:
    count[A[i]]+=1

if(len(count)<=K):
  print(0)
else:
  x=len(count)-K #減らさなければならない種類
  answer=0
  sorted_count=sorted(count.items(),key=lambda x:x[1])
  for i in range(x):
    answer+=int(sorted_count[i][1])
  
  print(answer)
# Judge status: Accepted
#coding: utf-8

N,M = map(int, input().split())
ans = abs(N-2)*abs(M-2)
print(ans)
# Judge status: Accepted
import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

a, b, x = imap()
ans = (b//x) - (a//x)
if a % x == 0: ans += 1
print(ans)
# Judge status: Accepted
arr = list(map(int, input().split()))
arr.sort()

count = 0
while(True):
    if arr[1] < arr[2]:
        arr[1] += 1
        arr[0] += 1
        count += 1
    else:
        break

while(True):
    if arr[0] < arr[2]:
        arr[0] += 2
        count += 1
    else:
        break

if arr[0] == arr[1] == arr[2]:
    print(count)
else:
    print(count+1)
# Judge status: Wrong Answer
NK = list(map(int, input().split()))
N = NK[0]
K = NK[1]

d = list()
A = list()
for _ in range(K):
	d.append(int(input()))
	A.append(list(map(int, input().split())))

print(N - max(d))
# Judge status: Wrong Answer
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
ans=b[a[0]-1]
for i in range(1,n):
    print("ans: ", ans)
    print("a[i]: ",a[i])
    ans+=b[a[i]-1]
    if a[i-1]+1 == a[i]:
        print("a[i]: ",a[i])
        ans+=c[a[i]-2]
        print("c: ",c[i-1])
print(ans)
# Judge status: Wrong Answer
import collections
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  b = collections.deque()
  for i in range(n):
    if i % 2 == n % 2:
      b.append(a[i])
    else:
      b.appendleft(a[i])
  if n % 2 == 0:
    b.reverse()
  b = map(str, b)
  print(" ".join(b))
  return 0
 
if __name__ == "__main__":
  solve()
# Judge status: Wrong Answer
import math
s = input()
ls = len(s)
e0 = s[::2].count('0')
e1 = s[::2].count('1')
o0 = s[1::2].count('0')
o1 = s[1::2].count('1')
if s.count('0')>s.count('1'):
    if e0>e1:
        print(e1+o0)
    else:
        print(e0+o1)
else:
    if o0>o1:
        print(o1+e0)
    else:
        print(o0+e1)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print(min(c, (a //b)))
# Judge status: Accepted
N = int(input())


s_ = input()
s_set = set([s_])

ans = 'Yes'

for _ in range(N-1):
    s = input()
    if s in s_set:
        ans = 'No'
    if s[0] != s_[-1]:
        ans = 'No'
    s_set.add(s)
    s_ = s

print(ans)
# Judge status: Accepted
N,A,B=map(int,input().split())
 
if N==1:
  if A==B:
    print(1)
  else:
    print(0)
elif A==B:
  print(1)
elif A>B:
  print(0)
else:
  print(B*(N-2)-A*(N-2)+1)
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k, n):
    if a[i - k] / a[i] < 1:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
n = int(input())
clist = input()

rs = clist.count("R")
ws = clist.count("W")

sort_rs = rs - clist[0:rs-1].count("R")

ans = 10**7

if rs < ans:
    ans = rs
if ws < ans:
    ans = ws
if sort_rs < ans:
    ans = sort_rs
print(ans)
# Judge status: Accepted
N = int(input())
print(sum(map(lambda x:x if (x % 3 != 0) and (x % 5 != 0) else 0,list(range(N + 1)))))
# Judge status: Wrong Answer
N = int(input())
D = list(map(int, input().split()))

D.sort()

print(D)
print(D[N//2] - D[N//2 - 1])
# Judge status: Accepted
import sys
range = xrange
input = raw_input

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

for i in range(n - k):
    print 'Yes' if A[i] < A[i + k] else 'No'
# Judge status: Wrong Answer
S = input()
if 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:]) <= 12:
    print("AMBIGUOUS")
elif int(S[:2]) > 12:
    print("YYMM")
elif int(S[2:]) > 12:
    print("MMYY")
else:
    print("NA")
# Judge status: Accepted
N=int(input())
print(N+N*N+N*N*N)
# Judge status: Wrong Answer
H, N = map(int, input().split())
A, B = [], []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
dp_max = 1000000
dp = [dp_max for i in range(H+1)]
dp[0] = 0

for i in range(H+1):
  if dp[i] == dp_max:
    continue

  for j in range(N):
    ni = min(H, i + A[j])

    dp[ni] = min(dp[ni], dp[i] + B[j])
print(dp[H])
# Judge status: Accepted
from collections import deque
S = deque(input())
Q = int(input())

reverse = False
for _ in range(Q):
    query = input().split()
    if query[0] == "1":
        reverse = not reverse
    else:
        tail = bool(int(query[1]) - 1) ^ reverse
        c = query[2]
        if tail:
            S.append(c)
        else:
            S.appendleft(c)

print("".join(reversed(S)) if reverse else "".join(S))
# Judge status: Wrong Answer
S=input()
for i in range(len(S)):
    if i%2==0 and S[i]=="L" or i%2==1 and S[i]=="R":
        print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
D = int(input())
print("Christmas" + "Eve"*(25-D))
# Judge status: Accepted
n, m = map(int, input().split())
h = list(map(int, input().split()))

ans = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] < h[b-1]:
        ans[a-1] += 1
    elif h[a-1] > h[b-1]:
        ans[b-1] += 1
    else:
        ans[a-1] += 1
        ans[b-1] += 1

print(ans.count(0))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
tmp=-5
res=0
for i in range(n):
  res += b[a[i]-1]
  if tmp==a[i]-2:
    res += c[a[i]-2]
  tmp=a[i]-1
print(res)
# Judge status: Accepted
n=int(input())
a=[int(input()) for i in range(n)]

dp=[0]*10001
dp[a[0]]=1

for i in range(1,n):
    for j in reversed(range(10001)):
        if dp[j]>0 and j+a[i]<=10000:
            dp[j+a[i]]=1
    dp[a[i]]=1

ans=0
for i in range(10001):
    if i%10!=0 and dp[i]>0:
        ans=i
print(ans)
# Judge status: Accepted
n=int(input())
ans=n
for n1 in range(n+1):
  n2=n-n1
  cnt1=0
  while n1>0:
    cnt1+=n1%6
    n1=n1//6
  cnt2=0
  while n2>0:
    cnt2+=n2%9
    n2=n2//9
  ans=min(ans,cnt1+cnt2)
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())

from math import factorial
mod =(10**9) + 7
# v_n = 1
# for i in range(1,n+1):
#     v_n*= i%mod
# v_m = 1
# for j in range(1,m+1):
#     v_m*= j%mod

v_n = factorial(n)
v_m = factorial(m)
if n==m:
    value = (v_n *v_m * 2)%mod
    print(value)

elif abs(n-m)>=2:
    print(0)

else:
    ans = (v_n * v_m)%mod
    print(ans)
# Judge status: Accepted
n = int(input())
a = sorted(map(int, input().split()))
ans = 0
l = 0
r = 3*n-1
while l < r:
    ans += a[r-1]
    l += 1
    r -= 2
    # print(l, r)

print(ans)
# Judge status: Accepted
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = min(a) + min(b)
for i in range(M):
  x,y,c = map(int,input().split())
  s = a[x - 1] + b[y - 1] - c
  if ans > s:
    ans = s
print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a < b <= 12:
    print(a)
elif a == b > 12 or (a,b > 12):
    print(12)
else:
    print(b)
# Judge status: Accepted
S = input()
for i in range(7):
    if S[:i] + S[i-7:] == 'keyence':
        print('YES')
        exit()
print('NO')
# Judge status: Accepted
n,m = [int(x) for x in input().split()]


if n < m:
    ans = n
    m -= n*2
    if m > 0:
        ans += m // 4
else:
    ans = m // 2

print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

sorted_AB = sorted(AB, key=lambda x: x[0])

total_cost = 0
total_drink = 0
for i in range(N):
    total_cost += sorted_AB[i][0] * sorted_AB[i][1]
    total_drink += sorted_AB[i][1]

    if total_drink >= M:
        timing_count = i
        break

answer = total_cost - (total_drink - M) * sorted_AB[timing_count][0]

print(answer)
# Judge status: Accepted
x = int(input())

s = 600
t = 8
while True:
  if x < s:
    print(t)
    break
  s += 200
  t -= 1
# Judge status: Accepted
x,y=map(int, input().split())
cnt=0
tmp=x
while tmp<=y:
    cnt+=1
    tmp*=2
print(cnt)
# Judge status: Wrong Answer
s = list(input())
ans = 0
for i in range(len(s)):
    if s[i] == "9":
        ans += 9
    if s[i] != "9":
        if i == 0:
            ans += int(s[i])-1+(len(s)-1-i)*9
            
        else:
            ans += 8+(len(s)-1-i)*9
            
        print(ans)
        exit()
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
flag=[0]*m
for i in range(n):
    list1=list(map(int,input().split()))
    for j in range(1,len(list1)):
        flag[(list1[j])-1]+=1
print(flag.count(n))
# Judge status: Accepted
N,M = (int(x) for x in input().split()) 
H = list(map(int, input().split()))
A = [0]*M
B = [0]*M
ANS = [0]*N
for i in range(M):
    A[i],B[i] = (int(x) for x in input().split()) 
for i in range(M):
    if(H[A[i]-1] < H[B[i]-1]):
        ANS[A[i]-1] = 1
    elif(H[A[i]-1] > H[B[i]-1]):
        ANS[B[i]-1] = 1
    else:
        ANS[A[i]-1] = 1
        ANS[B[i]-1] = 2
print(ANS.count(0))
# Judge status: Accepted
l = list(map(int, input().split()))

print('Yes') if sum(l) / 2 in l else print('No')
# Judge status: Wrong Answer
n, *a = map(int, open(0).read().split())
a.sort()
for i in range(1, n):
    x, y = a[0], a[1]
    while y%x:
            y -= y//x*x
            x, y = y, x
print(x)
# Judge status: Accepted
n,c,k = map(int, input().split())
l=[int(input()) for x in range(n)]
l.sort()
flg=l[0]
bus=1
capa=1
for i in range(1,n):

    if capa==c:
        bus+=1
        capa=1
        flg=l[i]
    
    elif flg <= l[i] <= flg+k:
            capa+=1
    else:
        bus+=1
        capa=1
        flg=l[i]    
print(bus)