peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
INF = 1000000000 + 7
N = int(input())
ans = 1
for i in range(1, N + 1):
    ans = ans % INF * i

print(ans)
# Judge status: Accepted
s = input()
a = s[0]
s = s.replace(a,"")
if len(s) != 2:
  print("No")
  exit()
if s[0] == s[1]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
from itertools import accumulate
import sys


def LI():
    return list(map(int, input().split()))


N, M = LI()
X = LI()
if M <= N:
    print(0)
    sys.exit()
sa = []
X.sort()
for i in range(M-1):
    sa.append(X[i+1]-X[i])
sa.sort(reverse=True)
sa = list(accumulate(sa))
if N == 1:
    print(sa[M-2])
else:
    print(sa[M-2]-sa[N-2])
# Judge status: Wrong Answer
N, K = map(int,input().split())

while K != 0:
    N,K = K,N%K

print(N)
# Judge status: Accepted
x, y = map(int, input().split())

A = (1,3,5,7,8,10,12)
B = (4,6,9,11)
# (2) は合うことはない
if x in A and y in A:
  print("Yes")
elif x in B and y in B:  
  print("Yes")  
else:
  print("No")
# Judge status: Accepted
x,y=map(int,input().split())


a=(4*x-y)/2

if (a//1==a/1 and 0<=a<=x):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=int(input())
arr=list(map(int,input().split()))

ans=1000

for i in range(1,N):
    temp=abs(sum(arr[0:i])-sum(arr[i:]))
    ans=min(ans,temp)

print(ans)
# Judge status: Accepted
def main():
    N, A, B = map(int, input().split())

    if (B - A) % 2 == 0:
        print((B - A) // 2)
    else:
        ret = min(
            A + (B - A - 1) // 2,
            (N - B + 1) + (N - (A + N - B + 1)) // 2
        )
        print(ret)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = [0]

for s in input():
  if s=="I":
    A.append(A[-1]+1)
  else:
    A.append(A[-1]-1)

print(max(A))
# Judge status: Wrong Answer
N=int(input())
a=input().split()
A=[int(b) for b in a]
first=A[0]
last=A[-1]
if N==2:
    print(abs(first-last))
else:
    average = sum(A) // 2
    number = 0
    del A[0]
    del A[-1]
    for a in range(N - 2):
        number += A[a]
        if number >= average:
            break
    a1 = abs(sum(A[:a]) + first - last - sum(A[a:]))
    a2 = abs(sum(A[:a + 1]) + first - last - sum(A[a + 1:]))
    print(min(a1, a2))
# Judge status: Accepted
s = "".join(sorted(input()))
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n,x=map(int,input().split())
l=list(int(i) for i in input().split())
s=[]
for i in range(len(l)+1):
  t=sum(l[:i])
  if t <= x:
    s.append(t)
print(len(s))
# Judge status: Accepted
a = []
b = [0] * 9

def match(n):
    if n in a:
        b[a.index(n)] += 1

def is_bingo(l, m, n):
    return b[l]*b[m]*b[n]

line = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]

for i in range(3):
    a += [int(i) for i in input().split()]
n = int(input())
for i in range(n):
    match(int(input()))
print('Yes' if any((is_bingo(line[i][0], line[i][1], line[i][2]) for i in range(8))) else 'No')
# Judge status: Accepted
import math
h, a = map(int,input().split())
print(math.ceil(h/a))
# Judge status: Wrong Answer
# AliceのスコアAとBobのスコアBを整数で入力
A,B = map(int,input().split())
# AとBが同じならDrawを出力
if A == B:
    print("Draw")
# Aが1がBより大きいならAliceを出力
elif  B != 1 and A == 1 or A > B :
    print("Alice")
# Bの方が強ければBobを出力
else:
    print("Bob")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

A.sort()
x = A[-1]
A.pop()

z = x

for a in A:
    if abs(x-a*2) < abs(x-z*2):
        z = a

print(x, z)
# Judge status: Accepted
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def lcm(m, n):
    return m//gcd(m, n)*n

MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for x in a[1:]:
    l = lcm(x, l)
l %= MOD

ans = 0
for x in a:
    ans = (ans + l * pow(x, MOD-2, MOD)%MOD)%MOD
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
l, r = 0, n
for _ in range(m):
    li, ri = map(int, input().split())
    l = max(l, li)
    r = min(r, ri)
print(r - l + 1)
# Judge status: Accepted
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) -1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum([w * a for a, w in zip(ac, wa)])
print("{} {}".format(sum(ac), penalties))
# Judge status: Wrong Answer
import math


x = int(input())

ans = 0
for i in range(x):
    if i * i > x: break
    ans = i * i
print(ans)
# Judge status: Accepted
n = int(input())
C = list(i for i in range(1,n+1))
L = list(map(int,input().split()))
cnt = 0
for c,l in zip(C,L):
  if c != l:
    cnt += 1
print('YES' if cnt == 0 or cnt == 2 else 'NO')
# Judge status: Accepted
n = int(input())
sides = [int(x) for x in input().split()]
tot = sum(sides)

for i in sides:
  if tot - i <= i:
    print('No')
    break
else:
  print('Yes')
# Judge status: Accepted
N = int(input())
alpha = [chr(ord("a") + i) for i in range(26)]


def dfs(n, s):
    if len(s) == n:
        print(s)
        return
    cnt = len(set(s))
    cnt += 1

    for a in alpha[:cnt]:
        ns = s + a
        dfs(n, ns)


dfs(N, "")
# Judge status: Wrong Answer
n = int(input())
l = {}
for i in range(n):
  a = int(input())
  if a in l:
    l[a] = 0
  else:
    l[a] = 1
    
print(sum(l.values()))
# Judge status: Accepted
s, t = map(str, input().split())
a, b = map(int, input().split())
u = input()
if u == s:
    print(a-1, b)
if u == t:
    print(a, b-1)
# Judge status: Accepted
a,b=map(int,input().split())
from math import ceil
print(ceil((a+b)/2))
# Judge status: Wrong Answer
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  # print(n, p, e)
  while n >= (p ** e) and n % (p ** e) == 0:
    n = n // (p ** e)
    score += 1
    e += 1
  else:
    p = p + 1 if p == 2 else p + 2
else:
  # print(p,n, [i for i in range(p, n + 1)])
  # print([n % i == 0 for i in range(p, n + 1)])
  if sum([n % i == 0 for i in range(p, n + 1)]) == 1:
    score += 1
print(score)
# Judge status: Accepted
def main():
    s = input()

    na, nb, nc = 0, 0, 0

    for c in s:
        if c == "a":
            na += 1

        if c == "b":
            nb += 1
        
        if c == "c":
            nc += 1

    mi = min(na, nb, nc)

    na -= mi
    nb -= mi
    nc -= mi

    if na >= 2 or nb >= 2 or nc >= 2:
        print("NO")
    else:
        print("YES")
        
if __name__ == "__main__":
    main()
# Judge status: Accepted
import re

split = re.split('[^ACGT]', input())

print(max(map(len, split)))
# Judge status: Wrong Answer
N = int(input())

a = list(map(int, input().split()))
anslst = [0]*(N-1)

for i in a:
  anslst[i-1] += 1

for ans in anslst:
  print(ans)
# Judge status: Wrong Answer
#Ans
N=str(input())
if N[-1]=="2"or N[-1]=="４"or N[-1]=="５"or N[-1]=="７"or N[-1]=="９":
    print("hon")
elif N[-1]=="0" or N[-1]=="1"or N[-1]=="6"or N[-1]=="8":    
    print("pon")
elif N[-1]=="3":
    print("bon")
# Judge status: Accepted
# coding: utf-8
# Your code here!

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

if A <= 9 and B <= 9 : 
    print(A*B)
else : 
    print(-1)
# Judge status: Accepted
N, *A = map(int, open(0).read().split())

ans = []
p = A[0]
for i in range(N):
    if i == 0:
        continue
    if p > A[i]:
        ans.append(p - A[i])
    else:
        p = A[i]

print(sum(ans))
# Judge status: Accepted
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N >= K:
  cost = K * X + (N - K) * Y
else:
  cost = N * X

print(cost)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

ans = 'APPROVED'

for i in range(N):
  if A[i] % 2 == 0 or A[i] % 6 == 0 or A[i] % 10:
    continue
  else:
    ans = 'DENIED'
    break

print(ans)
# Judge status: Accepted
import itertools
import math
import fractions
import functools
import copy

n,d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
l = list(range(0,n))
pair = list(itertools.combinations(l, 2))
count = 0
for i in range(len(pair)):
    distance = 0
    for j in range(d):
        distance += (x[pair[i][0]][j] - x[pair[i][1]][j])**2
    if (math.sqrt(distance)).is_integer():
        count += 1
print(count)
# Judge status: Accepted
# import itertools
# import math
import sys

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, K = map(int, input().split())
H = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()


if K >= len(H):
    print(0)
    sys.exit()

H.sort(reverse = True)

print(sum(H[K:]))
# Judge status: Accepted
import math

X,K,D = map(int,input().split())

X = abs(X)

if X//D > K:
    ans = X - D*K
    print(abs(ans))
elif (K-(X//D))%2 == 0:
    Y = X - (X//D)*D
    print(abs(Y))
else:
    Y = X - (X//D)*D
    print(abs(D-Y))
# Judge status: Wrong Answer
sx, sy, tx, ty = map(int, input().split())

X = tx-sx
Y = ty-sy

print('R'*X+'U'*Y+'L'*X+'D'*Y+'D'+'R'*(X+1) +
      'U'*(Y+1)+'L'+'L'*(X+1)+'D'*(Y+1)+'R')
# Judge status: Accepted
def solve():
  S = input()
  a = S.find('A')
  z = S[::-1].find('Z')
  ans = len(S)-a-z
  return ans
print(solve())
# Judge status: Wrong Answer
x = input()

if str.lower(x):
  print("a")
else:
  print("A")
# Judge status: Accepted
s = input()

S = s[:-1]

for i in range(len(s)):
    if len(S) % 2 == 0:
        c= len(S)//2
        a = S[0:c]
        b = S[c:len(S)]
        if a == b:
            print(len(s)-i-1)
            break
        else:
            S = S[:-1]
    else:
        S = S[:-1]
# Judge status: Accepted
s=input()
t=input()
u=[]
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j]!='?' and s[i+j]!=t[j]:
      break
  else:
    u.append(s[:i].replace('?','a')+t+s[i+len(t):].replace('?','a'))
if len(u)==0:
  print('UNRESTORABLE')
  exit()
u.sort()
print(u[0])
# Judge status: Wrong Answer
N, L = list(map(int, input().strip().split()))
strl = [input().strip() for s in range(N)]
strl = sorted(strl)
s = strl[0]
for t in strl:
  s += str(t)
print(s)
# Judge status: Accepted
import math

K = int(input())

S=0

for a in range(1,K+1):
    p=a
    for b in range(p+1,K+1):
        q=b
        for c in range(q+1,K+1):
            g=math.gcd(a,b)
            g=math.gcd(g,c)
            S=S+6*g
for a in range(1,K+1):
    p=a
    for b in range(p+1,K+1):
        g=math.gcd(a,b)
        S=S+6*g
for a in range(1,K+1):
    S=S+a
print(S)
# Judge status: Accepted
a, b = map(int, input().split())
 
if a<=b:
  print(a)
else:
  print(a-1)
# Judge status: Wrong Answer
def factorial(n):
    f=1
    for i in range(1,n+1):
        f*=i%(10**9+7)
    return f
n,m=map(int,input().split())
N=factorial(n)
if abs(n-m)>1:
    print(0)
elif abs(n-m)==0:
    print(2*N*N%(10**9+7))
elif n>m:
    print((N*N//n)%(10**9+7))
else:
    print(N*N*m*m%(10**9+7))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

free = 0
colors = {}

for a in A:
    if a < 3200:
        ai = a // 400
        colors[ai] = True

    else:
        free += 1

lc = len(colors)

print(max(1, lc), lc + free)
# Judge status: Wrong Answer
import math
r = int(input())
h = round(math.pi,4)
print(r*h)
# Judge status: Accepted
import random
for i in range(365):
  print(random.randint(1,26))
# Judge status: Wrong Answer
import numpy as np
bars = list(map(int, input().split(" ")))

length = len(bars)

def check_triangle(a, b, c):
    if a == b or b == c or c == a:
        return 0
    if ((a + b) > c) and ((b + c) > a) and ((c + a) > b):
        return 1
    else:
        return 0


count = 0
for i, li in enumerate(bars):
    for k in range(i+1, length):
        res = np.sum([check_triangle(bars[i], bars[k], bars[j]) for j in range(k+1, length)])
        count += int(res)
print(count)
# Judge status: Accepted
A,B = map(int, input().split())

ans = -1

if A >= 1 and A < 10:
  if B >= 1 and B < 10:
    ans = A * B
  
print(ans)
# Judge status: Accepted
n = int(input())
k = input()

a = k.count("R")
b = k[:a].count("W")
print(b)
# Judge status: Accepted
from collections import defaultdict
n = int(input())
A = [int(i) for i in input().split()]
my_dict = defaultdict(int)
for i in A:
    my_dict[i] += 1
ans = sum(A) # sum up once
Q = int(input())
for q in range(Q):
    b, c = [int(i) for i in input().split()]
    if b in my_dict:
        my_dict[c] += my_dict[b]
        ans += my_dict[b] * (c-b)
        my_dict[b] = 0
    print(ans)
# Judge status: Accepted
A, B, C, D = map(int, input().split())

def gcd(a,b):
    if b>a:
        a,b = b,a
    while b:
        a,b = b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
E = lcm(C,D)

R = (B - A + 1) - ((B//C - (A-1)//C) + (B//D - (A-1)//D) - (B//E - (A-1)//E))

print(R)
# Judge status: Accepted
a, b = map(int, input().split(' '))
aa = ''.join([str(a) for i in range(b)])
bb = ''.join([str(b) for i in range(a)])

print(aa) if aa< bb else print(bb)
# Judge status: Accepted
n,a,b = map(int,input().split())
ans = 0
for i in range(1,n+1):
    temp = 0
    c = str(i)
    for j in range(len(c)):
        temp += int(c[j])
    if a <= temp and temp <= b:
        ans += i
print(ans)
# Judge status: Wrong Answer
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0
if N<2*M:
    count = N
    N1=0
    M1=M-2*N
    count+=M1//4
else:
    count += M//2
print(count)
# Judge status: Wrong Answer
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(x*min(n,k) + y * min(n-k, 0))
# Judge status: Accepted
k=int(input())
a,b=map(int,input().split())

min=(a//k)+1
if a%k==0:
    print("OK")
else:
    if a<=k*min and k*min<=b:
        print("OK")
    else:
        print("NG")
# Judge status: Accepted

import math
import itertools
import statistics
#import numpy as np
import collections

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

l = [2, 1]

if n==1:
    print(1)
    exit()
else:
    for i in range(2, n+1):
        l.append(l[i-1]+l[i-2])

print(l[-1])
# Judge status: Accepted
N,K = map(int,input().split())
p = list(map(int,input().split()))
def maxexp(p,K):
    s = 0 
    for i in range(0,K):
        s = s + p[i]
        t = s
    for j in range(0,len(p)-K):
        s = s - p[j] + p[j+K]
        t = max(s,t)
    return (t+K)/2
print(maxexp(p,K))
# Judge status: Accepted
n,m=map(int,input('').split(' '))
if m>=n:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,k=map(int,input().split())
a=lmp()

def ok(s):
    c=0
    for i in a:
        c+=-(-i//s)-1
    return c<=k


l=0
r=max(a)
while r>l+1:
    md=(r+l)//2
    if ok(md):
        r=md
    else:
        l=md
print(r)
# Judge status: Accepted
n = int(input())
s = input()
t = input()
for i in range(n+1):
    k = s[:i] + t
    if k[:n] == s:
        print(n+i)
        break
# Judge status: Accepted
n,t = map(int,input().split())
cost = 1001
for i in range(n):
    c,time = map(int,input().split())
    if time <= t:
        cost = min(cost,c)
if cost == 1001:
    print('TLE')
else:
    print(cost)
# Judge status: Wrong Answer
n = int(input())
l = sorted(list(int(input()) for _ in range(n)))
a = sum(l)
if a%10!=0:
  print(a)
else:
  for i in l:
    a -= i
    if a%10!=0:
      print(a)
      break
    else:
      continue
  else:
    print(0)
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
aoki_new = b-c
taka_new1 = d-a
if taka_new1 < aoki_new :
	print("No") #takahasi is loses because its heath is zero first
else:
	print("Yes")
# Judge status: Accepted
S = input()
n = len(S) // 2
ans = 0
for i, j in zip(S[:n + 1], S[-1:n - 1:-1]):
    if i != j:
        ans += 1

print(ans)
# Judge status: Wrong Answer
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    q, h, s, d = map(int, input().split())
    n = int(input())
    t = min(q // 0.25, h // 0.5, s)

    if n == 1:
        print(t)
    else:
        if n % 2 == 0:
            print(min(t * n, d * n // 2))
        else:
            print(min(t * n, d * (n - 1) // 2 + t))


if __name__ == '__main__':
    resolve()
# Judge status: Accepted
n = int(input())
A=list(map(int, input().split()))

ans="No"
c1=c2=c4=0
for a in A:
    if a%4==0:
        c4+=1
    elif a%2==0:
        c2+=1
    else:
        c1+=1

if c4==0 and c1>0 :
    ans="No"
elif c1<=c4+(c2==0) :
    ans="Yes"
else:
    ans="No"

print( ans )
# Judge status: Accepted
from collections import Counter

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

total = 1
count = 0
for i in range(n):
  num = c.get(i, 0)
  if num == 0:
    total = 0
    break
  count += num
  if i == 0 and (c[i] != 1 or D[0] != 0):
    total = 0
  if i > 0:
    total = (total * (c[i - 1] ** c[i])) % 998244353
  if count == n:
    break
print(total)
# Judge status: Accepted
a, b, c = map(int, input().split())
if a <= c <= b or b <= c <= a:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import sys


def LI():
    return list(map(int, input().split()))


N, K, S = LI()
if K == 0:
    if S == 10**9:
        for i in range(N):
            print(10**9-1, end=" ")
    else:
        for i in range(N):
            print(10**9, end=" ")
    sys.exit()
for i in range(K):
    print(S, end=" ")
for i in range(N-K):
    print(S+1, end=" ")
# Judge status: Wrong Answer
m, n = map(int, input().split())
a = [input().strip() for i in range(m)]
b = [input().strip() for i in range(n)]

c = 0

for i in range(m-1):
	for j in range(n-1):
		if set(a[i]) == set(b[j]) & set(a[i+1]) == set(b[j+1]):
			c += 1
            
if c > 0:
  print("Yes")
else:
  print('No')
# Judge status: Accepted
N, K = map(int, input().split())

ans = 0

for i in range(1, N+1):
    M = 1.0/N
    S = i
    while S < K:
        S *= 2
        M /= 2
    ans += M

print(ans)
# Judge status: Accepted
A,B=input().split()
A=int(A)
B=int(B)

counter=0 #答え（初期化）

i=A

while i<=B:
    #回文になっているか判定
    temp=str(i) #文字列に置き換え
    if (temp[0]==temp[4])and(temp[1]==temp[3]): #スライスして0番目の文字と4、1と3が一致するか判定
        counter+=1 #一致すれば、counterを増やす
    i+=1 #インクリース

print(counter)
# Judge status: Wrong Answer
n,k =list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
ans = 0
tmp = a[0]
cnt = 1
for i in range(n):
    if tmp != a[i]:
        cnt += 1
        tmp = a[i]
    if cnt > k:
        ans = n-i
        break
print(ans)
# Judge status: Accepted
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()
    
    n = int(input()) 
    d = list(map(int, input().split()))
    mod = 998244353
    from collections import Counter as cc
    c = cc(d)
    if c[0] != 1 or d[0] != 0:
        print(0)
        return
    m = max(d)
    ans = 1
    for i in range(1, m+1):
        ans *= pow(c[i-1], c[i], mod)
        ans %= mod
    print(ans)
    
    
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N=int(input())
S_list = []
count = 0
for i in range(N):
  s = str(input())
  S_list.append(s)
  if not (s in S_list):
    count = count + 1
print(len(S_list))
# Judge status: Accepted
a,b=input(),input();n=[i+j for i,j in zip(a,b)]
print(*[n,n+[a[-1]]][len(a)-len(b)==1],sep='')
# Judge status: Accepted
a, b = map(int, input().split())

for x in range(1,100001):
    if int(x * 0.08) == a and int(x * 0.10) == b:
        print(x)
        break
else:
    print(-1)
# Judge status: Accepted
N = int(input())
ans = (N//11)*2
nokori = N%11
if nokori == 0:
  ans += 0
elif nokori <= 6:
  ans += 1
else:
  ans += 2
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
n,k = list(map(int,input().split()))
s = input()
rl_cnt = s.count("RL")
ret = 0
s0 = s[0]
sn = s[-1]
if s0==sn:
    ret=n-1-2*max(0,rl_cnt-k)
elif s0=="L" and sn=="R":
    if k<=rl_cnt:
        ret=n-2-2*(rl_cnt-k)
    else:
        ret=n-1
else:
    if k<rl_cnt:
        ret = n - 2*(rl_cnt-k)
    else:
        ret = n-1
print(ret)
# Judge status: Wrong Answer
from sys import stdin,stdout


if __name__=="__main__":

    n=int(stdin.readline())
    b=[int(x) for x in stdin.readline().split()]
    b.append(1000000)

    s=b[0]

    for i in range(n-1):
        if b[i]>b[i+1]:
            s+=b[i+1]
        else:
            s+=b[i]
    stdout.write(str(s)+"\0")
# Judge status: Wrong Answer
m, n = map(int, input().split())
mod = 10 ** 9 + 7

def combination(n, r, mod=10**9+7):
    if r == 0:
        return 1
    elif r < 0:
        return 0
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * pow(i+1, mod-2, mod) % mod
    return res
 

if (m + n) % 3 != 0:
    print(0)
else:
    p = (m + n) // 3
    k = m - p
    print(combination(p,k))
# Judge status: Accepted
S = input()
print('yes' if len(S) == len(set(S)) else 'no')
# Judge status: Accepted
N, K = map(int, input().split())
D = set(map(str, input().split()))
f = True
while f:
    if set(list(str(N))) == set(list(str(N))) - D:
        print(N)
        f = False
    else:
        N += 1
# Judge status: Accepted
x = int(input())
if x>=30:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
r, g, b = input().split()

rgb = int(r + g + b)

if rgb % 4 == 0:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
n, m, k = (int(x) for x in input().split())

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

K = k
ans = 0

i = 0
while K-a[i]>=0:
    K -= a[i]
    i += 1
    if i==n:
        break
ans = i
    
# K = k
for j in range(i-1, -1, -1):
    l = 0
    while K-b[l]>=0:
        K -= b[l]
        l += 1
        if l==m:
            break
    ans = max(ans, j+l+1)
    K += a[j]


print(ans)
# Judge status: Accepted
X, Y = map(int, input().split())

if X * 4 == Y:
    print('Yes')
    exit()

for i in range(1, X+1):
    if i * 2 + (X-i) * 4 == Y:
        print('Yes')
        exit()

print('No')
# Judge status: Accepted
N = int(input())
S = input()
l = 0
r = 0
for i in range(N):
  if S[i] == ')':
    if r > 0:
      r-=1
    else:
      l+=1
  else:
    r+=1
for _ in range(l):
  print('(', end='')
print(S, end='')
for _ in range(r):
  print(')', end='')
# Judge status: Wrong Answer
N = int(input())
L = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    for j in range(i):
        for k in range(j):
            if L[i] != L[j] != L[k] and L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[j] + L[k] > L[i]:
                ans += 1
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = 0
b = 0
for i in range(10):
  a = 2 ** i
  if a >= n :
    print(b)
    break
  else:
    b = a
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(n):
  ans += B[A[i]-1]
  if i<n-1 and A[i]+1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)
# Judge status: Accepted
n,m,k = map(int, input().split())

for i in range(n+1):
    for j in range(m+1):
        if i*(m-j) + j*(n-i) == k:
            print("Yes")
            exit()
print("No")
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())

s = input()

if s.find('##',a,c) < 0 and s.find('##',b,d) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b-2,d+1)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')
# Judge status: Wrong Answer
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

if N >= M :
    print(0)
    exit()

sub = []
for i in range(1,M):
    sub.append(X[i]-X[i-1])

sub = sorted(sub)
ans = sum(sub[:-(N-1)])
print(ans)
# Judge status: Wrong Answer
import datetime

def main():
    H1, M1, H2, M2, K = map(int, input().split())

    start = H1*60 + M1
    sleep = H2*60 + M2

    print( K * ( abs((sleep - 1)-start) // K) )


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import math
n = int(input())
la = [int(i) for i in input().split()]
la.sort(reverse=True)
ans = 1

if la[-1] == 0:
    print(0)
    exit()

for a in la:
    if math.log10(a) > 18:
        print(-1)
        exit()
    ans *= a
    if ans % 10 == 0 and math.log10(ans) == 18:
        print(ans)
    elif math.log10(ans) > 18:
        print(-1)
        exit()
print(ans)
# Judge status: Wrong Answer
s = input()

print("2018" + s[:4])