peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
s = input()
max_num = 0
for i in range(1, len(s)):
    if i % 2 == 0 and s[:i] == s[:int(i/2)] * 2:
        max_num = i
    
print(max_num)
# Judge status: Accepted
import math
from operator import itemgetter
n,k = map(int,input().split())

lst1 = [list(map(int,input().split())) for i in range(n)]
lst1.sort(key=itemgetter(1),reverse=True)
ans = 0

x = 0
for i in range(n):
    x = max(x,lst1[i][0])

for i in range(n):
    if lst1[i][1] > x:
        k -= lst1[i][1]
        ans += 1
    if k <= 0:
        print(ans)
        exit()


print(ans + math.ceil(k/x) )
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
print((A+C)//(B+C))
# Judge status: Wrong Answer
n,m=map(int,input().split())

if n>=2 and m>=2:
    print((n-2)*(m-2))

elif n==1:
    print(m-2)

elif m==1:
    print(n-2)
# Judge status: Accepted
s = input()
print("ARC" if s[1] == "B" else "ABC")
# Judge status: Wrong Answer
n = int(input())
P = list(map(int, input().split()))
c = 0
for i in range(n-1):
    if P[i] == i+1:
        P[i], P[i+1] = P[i+1], P[i]
        c += 1
print(c)
# Judge status: Wrong Answer
n = int(input())
l = list(map(int,input().split()))
flg = 0
for i in range(0, n):
    if l[i] < sum(l)-l[i]:
        pass
    else:
        flg = 1
if flg == 1:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
import collections
import math
n = int(input())
a = [0]*n
b = 0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for j in range(n):
    t = list(input())
    t.sort()
    m = " ".join(t)
    a[j] = m
c = collections.Counter(a)
d = list(c)
for k in range(len(d)):
    if c[d[k]] > 1:
        b += combinations_count(c[d[k]], 2)
    else:
        continue
print(b)
# Judge status: Accepted

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

S=0
ans=[]
for a in A:
    S^=a
for a in A:
    ans.append(S^a)
print(*ans)
# Judge status: Wrong Answer

from bisect import bisect_left,bisect

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

a.sort()
ai=max(a)


if ai%2==0:
    ai2=ai//2+1
else:
    ai2=ai//2

jj=bisect(a,ai2)

if jj+1<n:
    if abs(a[jj]-ai2)>abs(a[jj+1]-ai2):
        jj=jj+1
if jj-1>=0:
    if abs(a[jj]-ai2)>abs(a[jj-1]-ai2):
        jj=jj-1
    
if jj==n-1:
    jj=jj-1
    
aj=a[jj]

print(ai,aj)
# Judge status: Accepted
a,b,c,x,y = map(int,input().split())
ans = 0
if a+b<c*2:
    ans = a*x+b*y
else:
    if x>y:
        ans = min(2*c*y+(x-y)*a, 2*c*x)
    else:
        ans = min(2*c*x+(y-x)*b, 2*c*y)
print(ans)
# Judge status: Accepted
check = ['dream', 'dreamer', 'erase', 'eraser']
    
s=input()

end = len(s)

while 0 < end:
    if s[end-5:end] in check:
        end -= 5
    elif s[end-6:end] in check:
        end -= 6
    elif s[end-7:end] in check:
        end -= 7
    else:
        print('NO')
        exit()
print('YES')
# Judge status: Wrong Answer
import sys
si=sys.stdin.readline

n=int(si())
t=0
while n:
  n-=1
  a,b=[int(e) for e in si().split()]
  if a==b:
    t+=1
  else:
    t=0
if t>=3:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
s=input()
t=input()
if s==t:
    print("Yes")

else:
    flag=True
    for i in range(1,len(s)):
        if s[0:i]==t[len(s)-i:len(s)] and s[i:len(s)]==t[0:len(s)-i]:
            print("Yes")
            flag=False
            exit()

    if flag:
        print("No")
# Judge status: Accepted
l, r = map(int, input().split())
m = 2019
if r - l >= 673:
    print(0)
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j)%m)
        if ans <= 2:
            break
    print(ans)
# Judge status: Accepted
import math

def main():
	N, M = [int(a) for a in input().split(" ")]
	divM = []
	for i in range(1, int(math.sqrt(M)) + 1):
		if M % i == 0:
			divM += [i, M // i]
	divM.sort()
	divM = list(filter(lambda m: m >= N, divM))
	print(M // divM[0])

main()
# Judge status: Wrong Answer
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

aa=sorted(nl())[::-1]

ans = (aa[1]-aa[2])//2
ans += aa[0]-aa[1]
print(ans)
# Judge status: Accepted
from bisect import bisect_left

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

x = int(input())

ps = primes(10**5+100)

i = bisect_left(ps,x)
print(ps[i])
# Judge status: Wrong Answer
ss=input().strip()
flg=False
for i in range(1,len(ss)):
  if ss[i]==ss[i-1]:
    True
    
if flg==True:
  print("Bad")
else:
  print("Good")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
V = [0]*(N+1)
flug = 0
Lsum= sum(A)
 
V[0] = 1
for i in range(N):
    V[i+1] = (V[i]*2 - A[i+1])
    if V[i+1] < 0 and i != N-1 :
        flug = 1
    Lsum = Lsum - A[i+1]
    if V[i+1] > Lsum :
        V[i+1] = Lsum
 
ans = sum(V)+sum(A)
if A[0] != 0 or A[N] == 0:
    ans = -1
if flug == 1:
   ans = -1
if N == 0:
    ans = -1
 
print(ans)
# Judge status: Wrong Answer
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.reverse()
B.reverse()

ans = 0
total_time = 0
while A or B:
    if not A:
        t = B.pop()
    elif not B:
        t = A.pop()
    else:
        if A[-1] < B[-1]:
            t = A.pop()
        else:
            t = B.pop()
    total_time += t
    if total_time <= K:
        ans += 1
    else:
        break
print(ans)
# Judge status: Accepted
def main():
    N = int(input())
    a = [int(input()) for _ in range(N)]

    ans = 0
    nxt = 1
    while True:
        if ans > N:
            print(-1)
            exit()
        elif nxt == 2:
            break
        nxt = a[nxt-1]
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
S = input()
T = input()

ans = 0
for i in range(len(S)):
  if S[i] != T[i]:
    ans += 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
print(A)
# Judge status: Accepted
s = input()
t = input()
n = len(s)
jisho1 = {}
jisho2 = {}


def ng():
    print("No")
    exit()


for i in range(n):
    if s[i] in jisho1:
        if jisho1[s[i]] != t[i]:
            ng()
    else:
        jisho1[s[i]] = t[i]
    if t[i] in jisho2:
        if jisho2[t[i]] != s[i]:
            ng()
    else:
        jisho2[t[i]] = s[i]
print("Yes")
# Judge status: Accepted
n = int(input())
ans = ''
a = {'a': 100001, 'b': 100001, 'c': 100001, 'd': 100001, 'e': 100001, 'f': 100001, 'g': 100001, 'h': 100001, 'i': 100001, 'j': 100001, 'k': 100001, 'l': 100001, 'm': 100001,
     'n': 100001, 'o': 100001, 'p': 100001, 'q': 100001, 'r': 100001, 's': 100001, 't': 100001, 'u': 100001, 'v': 100001, 'w': 100001, 'x': 100001, 'y': 100001, 'z': 100001}
for i in range(n):
    s = input()
    for j in a:
        a[j] = min(s.count(j), a[j])
for k in a:
    ans += k*a[k]
print(ans)
# Judge status: Accepted
import math

n, k = map(int, input().split())
lst = list(map(int, input().split()))

print(math.ceil((n-1)/(k-1)))
# Judge status: Accepted
s=input()
print("2018"+s[4::])
# Judge status: Accepted
#!/usr/bin/env python3

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

if a >= 13:
    print(b)
elif a >= 6:
    print(b//2)
else:
    print(0)
# Judge status: Accepted
import sys
s=input()
for i in range(ord("a"),ord("z")+1):
  if chr(i) not in s:
    print(chr(i))
    sys.exit()
print("None")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = sorted(A)
for i in range(N-1):
  if B[i] == B[i+1]:
    print('NO')
    exit()
print('YES')
# Judge status: Accepted
x, y = list(map(int, input().split()))

def ncr(n, r, p):
    num = 1
    den = 1

    for i in range(r):
        num = (num*(n-i)) % p
        den = (den*(i+1)) % p

    return (num*pow(den, p-2, p)) % p

if (x+y)%3 == 0:
    n = (x+y)//3

    if not (n <= x <= 2*n):
        print(0)
    else:
        print(ncr(n, x-n, 1000000007))
else:
    print(0)
# Judge status: Accepted
n=int(input())
d=dict()
for _ in range(n):
    hoge=int(input())
    if d.get(hoge,0)==0:
        d[hoge]=1
    else:
        d[hoge]+=1
ans=0
for i in d.values():
    if i%2==1:
        ans+=1
print(ans)
# Judge status: Wrong Answer
a = list(map(int, input().split()))
if sum(a) == 17 and a.count(5) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
As = list(map(int, input().split()))

max_per = max(As)
ansList = [0 for _ in range(max_per + 10)]

for A in As:
    checkList = [i for i in range(A, max_per+1, A)]
    #print(checkList,As)

    for check in checkList:
        ansList[check] += 1

ans = 0

for A in As:
    if(ansList[A] == 1):
        ans += 1

print(ans)
# Judge status: Accepted
N,K = map(int, input().split())
A = [int(i) for i in input().split()]

"""
切る回数は広義単調減少になる
にぶたん
"""

def is_dekiru(L):
    cnt = 0
    for a in A:
        cnt += (a + L - 1) // L - 1
    return cnt <= K

ok = 10 ** 9 + 10
ng = 0
while (ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_dekiru(mid):
        ok = mid
    else:
        ng = mid

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

if N < 10:
  print(R+(100*(10-N)))
else:
  print(R)
# Judge status: Accepted
n = int(input())
 
s = 0
p = 0
for _ in range(n):
  t,x,y = map(int, input().split())
  s = t - s
  p = abs((x+y)-p)
  if s < p:
    print("No")
    exit()
  elif s%2 != p%2:
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
d,t,s=map(int,input().split())
print('NYoe s'[d<=t*s::2])
# Judge status: Accepted
r=range(1,int(input())+1)
from math import gcd 
print(sum(gcd(gcd(a,b),c) for a in r for b in r for c in r))
# Judge status: Wrong Answer
x = int (input ())
if 1800 < x:
  print (1)
elif 1600 < x:
  print (2)
elif 1400 < x:
  print (3)
elif 1200 < x:
  print (4)
elif 1000 < x:
  print (5)
elif 800 < x:
  print (6)
elif 600 < x:
  print (7)
else:
  print (8)
# Judge status: Accepted
X=int(input())

t=100
cnt=0
while t<X:
    t+=int(t*0.01)
    cnt+=1
print(cnt)
# Judge status: Wrong Answer
N = int(input())

ans = 0

Line = [int(s) for s in input().split()]

for i,x in enumerate(Line):
    if i % 2 == 1:
        # print(x)
        if x % 2 == 1:
            ans += 1

print(ans)
# Judge status: Accepted
x,y,a,b,c=map(int, input().split())
p=sorted(list(map(int, input().split())), reverse=True)[:x]
q=sorted(list(map(int, input().split())), reverse=True)[:y]
r=sorted(list(map(int, input().split())), reverse=True)[:x+y]

new=sorted(p+q+r, reverse=True)
print(sum(new[:x+y]))
# Judge status: Wrong Answer
a = [input(),input()]
if len(a[0]) >= 3200:
    print(a[1])
else:
    print("red")
# Judge status: Accepted
import sys

def solve():
    N = int(input())
    T, A = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]

    dif = sys.maxsize
    ans = -1
    for i in range(N):
        t = T - H[i] * 6 / 1000
        if abs(t - A) < dif:
            dif = abs(t - A)
            ans = i + 1
    print(ans)

if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
ans = ""
O = input()
E = input()
for o, e in zip(O, E):
    ans += o + e
print(ans)
# Judge status: Accepted
from collections import defaultdict

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

D = defaultdict(int)

for i in range(N):
    D[A[i]] += 1
    if D[A[i]] == 2:
        print('NO')
        break
else:
    print('YES')
# Judge status: Accepted
x, y = map(int, input().split())

if x % y == 0:
  ans = -1
else:
  ans = x
  
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())

for i in range(10000):
    while k**i > n:
        print(i)
        exit()
# Judge status: Accepted
num = int(input())

if num >= 30 :
    print('Yes')
else :
    print('No')
# Judge status: Accepted
s=input()
if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))

dp = []
base_num = A_list[0]
for i in range(1, N):
    dp.append(i - (base_num + A_list[i]))

ans = 0
for i in range(N):
    print(base_num - A_list[i] - i)
    ans += dp.count(-1 * (base_num - A_list[i] - i))
print(ans)
# Judge status: Accepted

def divisor(n):
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass  # sortされていない


n, m = map(int, input().split())
m_div = divisor(m)
m_div.sort()
ans = 0
for i in m_div:
    if i * n <= m and (m - i*n) % i == 0:
        ans = max(ans, i)
print(ans)
# Judge status: Accepted
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))

a = len(A)
ans_1 = a - K
ans = 1 + math.ceil(ans_1/(K -1))
print(ans)
# Judge status: Accepted
n = int(input())
for i in range(int(n ** 0.5), 0, -1):
    if n % i == 0:
        print(i + n // i - 2)
        break
# Judge status: Wrong Answer
from collections import deque
from bisect import bisect_left
N=int(input())
li=[]
ans=0
for i in range(N):
    a=-int(input())
    b=bisect_left(li,a+1)
    if b==len(li):
        li.append(a)
        ans+=1
    else:
        li[b]=a
    print(li)
print(ans)
# Judge status: Accepted
from collections import Counter
n=int(input())
s=Counter(input())

for i in range(n-1):
    s&=Counter(input())
print("".join(sorted(s.elements())))
# Judge status: Wrong Answer
n= int(input())

azlist = list('abcdefghijklmnopqrstuvwxyz')
ans = ''
def aaa(n):
  for i in range(1,10**9):
    if (n-26**i)<=0:
      return n
    else:
      n = n-26**i

n = aaa(n)


for i in range(1,10**9):
  ans = azlist[n%26 - 1] + ans
  if n//26 == 0 or (n//26 == 1 and n%26==0 ):
    break
  else:
    n = n//26

print(ans)
# Judge status: Accepted
n=input()
print("A"+n[8]+"C")
# Judge status: Accepted
import sys
input = sys.stdin.readline

from math import factorial
from itertools import combinations
from collections import Counter
from copy import deepcopy
from operator import mul
from functools import reduce

def main():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    r = 0
    for ia in range(a + 1):
        for ib in range(min(b + 1, (x - ia * 500)//100 + 1)):
            r +=  (x - ia * 500 - ib * 100) // 50 <= c

    print(r)

if __name__ == '__main__':
    main()
# Judge status: Accepted
g = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x, y = map(int,input().split())

print('Yes') if g[x] == g[y] else print('No')
# Judge status: Accepted
a = int(input())
print(int(a + a**2 + a**3))
# Judge status: Accepted
def myAnswer(N:int,A:list) -> str:
   counter4 = 0
   counter2 = 0
   for a in A:
      if(a % 4 == 0):
         counter4 += 1
      elif(a % 2 == 0):
         counter2 += 1
   if(counter4 >= N//2):
      return "Yes"
   elif(counter4 >= (N-(counter2//2)*2)//2):
      return "Yes"
   else:
      return "No"


def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()
# Judge status: Accepted
n, k = map(int, input().split())
s = input()

h = 0
for a, b in zip(s, s[1:]):
    if a == b:
        h += 1
h += 2 * k

print(min(n-1, h))
# Judge status: Accepted
N=int(input())
l=[[0,0,0]]+[list(map(int,input().split())) for _ in range(N)]

sum=[[0]*3 for _ in range(N+1)]
for i in range(1,N+1):
    sum[i][0]=max(sum[i-1][1],sum[i-1][2])+l[i][0]
    sum[i][1]=max(sum[i-1][0],sum[i-1][2])+l[i][1]
    sum[i][2]=max(sum[i-1][0],sum[i-1][1])+l[i][2]
ans=max(sum[N])
print(ans)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        w=list(input())
        w.sort()
        if len(w)%2!=0:
            print('No')
        else:
            for i in range(0,len(w)-1,2):
                if w[i]!=w[i+1]:
                    return 'No'
            return 'Yes'
    print(main())
resolve()
# Judge status: Accepted
a,b,c,d=map(int,input().split())
if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import heapq
n,m = map(int,input().split())
a = list(map(lambda x:int(x)*(-1),input().split()))

heapq.heapify(a)
for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-tmp_min//2))
print(-sum(a))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
flag = 0
for i in range(N-1,0,-1):
  if A[i] >= A[i-1]:
    continue
  else:
    if A[i-1]-A[i] == 1:
      A[i-1] -= 1
    else:
      flag += 1
      print("No")
      break
if flag == 0:
  print("Yes")
# Judge status: Accepted
a, b = map(int,input().split(' '))
ans = a*b//2

if (a*b)%2 == 1:
  ans+=1
if a == 1 or b == 1:
    print(1)
else:
    print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
ans = float("INF")
LS = [0]*(N+1)
LS[0] = 0
for i in range(N-1):
  LS[i+1] = A[i] + LS[i]
  ans = min(ans, abs(LS[i+1] - (S - LS[i+1])))
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split( ))
i = 1
ViewH = {}
H_list = input().split( )
countlist = []
while i <= N:
    ViewH[i] = int(H_list[i-1])
    countlist.append(0)
    i += 1


for count in range(M - 1):
    A, B = map(int, input().split())
    if ViewH[A] > ViewH[B]:
        countlist[B-1] = 1
    elif ViewH[A] == ViewH[B]:
        countlist[A-1] = 1
        countlist[B-1] = 1
    else:
        countlist[A-1] = 1

print(countlist.count(0))
# Judge status: Accepted
import math

N = int(input())
A = []
for i in range(2,int(math.sqrt(N))+1):
    if N%i == 0:
        A.append(i + (N//i) - 2)
if not A:
    print(N-1)
else:
    print(min(A))
# Judge status: Accepted
N,M = map(int, input().split())
h = list(map(int, input().split()))
ma = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    ma[a-1] = max(ma[a-1],h[b-1])
    ma[b-1] = max(ma[b-1],h[a-1])
ans = 0
for a in range(N):
    if h[a] > ma[a]:
        ans = ans + 1

print(ans)
# Judge status: Accepted
n,k=[int(i) for i in input().split()]
if n%k==0:
  print('0')
else:
  print('1')
# Judge status: Accepted
import numpy as np
n = int(input())
lst = list(map(int,input().split()))
s = 0
t = 0
for x in lst:
  s += x
  t += (x ** 2) % (10**9+7)

w = (s**2-t) % (10**9+7)
if w % 2 == 0:
  print(w//2)
else:
  print((w+10**9+7)//2)
# Judge status: Accepted


AB, BC, CA = map(int, input().split())


i = (AB * BC) // 2
print(i)
# Judge status: Wrong Answer
# C - 白昼夢
S = input()
S2 = S
W_L = ["dream","dreamer","erase","eraser"]
while True:
    
    for w in W_L:
        if S2.endswith(w):
            S2 = S2[:-(len(w))]
        else:
            print('NO')
            exit()
            
    if len(S2)<=7:
        break
    
if S2 ==''or S2 in W_L:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N, W = map(int, input().strip().split())
 
values = []
weights = []
 
for _ in range(N):
    w, v = map(int, input().strip().split())
    weights.append(w)
    values.append(v)
    
dp = [0]*(W+1)
for i in range(N):
    for w in range(W, weights[i] - 1, -1):
        dp[w] = max(dp[w], values[i] + dp[w - weights[i]])
# Judge status: Accepted
def ABC_49_A():
    c = input()

    if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':
        print('vowel')
    else:
        print('consonant')


if __name__ == '__main__':

    ABC_49_A()
# Judge status: Wrong Answer
import heapq as hq
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
n = sum(B) - sum(A)
hq.heapify(A)
hq.heapify(B)
for i in range(n):
  a = hq.heappop(A)
  hq.heappush(A, a+2)
  b = hq.heappop(B)
  hq.heappush(B, b+1)
for i in range(N):
  if hq.heappop(A) != hq.heappop(B):
    print("No")
    exit()
print("Yes")
# Judge status: Wrong Answer
S = input()
K = int(input())
ans = "1"
for i in range(len(S)):
  if S[i] != "1":
    ans = S[i]
    break
  if i > K:
    break
print(ans)
# Judge status: Accepted
from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
a = [0]*n
b = [0]*n

for i in range(n):
    a[i], b[i] = map(int, input().split())

a.sort()
b.sort()

if n%2!=0 :
    l = a[int(n/2)]
    u = b[int(n/2)]
    ans = u - l + 1
else:
    l = a[int(n/2-1)] + a[int(n/2)]
    u = b[int(n/2-1)] + b[int(n/2)]
    ans = u - l +1

print(ans)
# Judge status: Wrong Answer
import sys
import math
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n, m = map(int, input().rstrip().split())
    if abs(n - m) > 2:
        print("0")
        return
    if n == m:
        print(math.factorial(n) * math.factorial(m) * 2 % (pow(10, 9) + 7))
    else:
        print(math.factorial(n) * math.factorial(m) % (pow(10, 9) + 7))


if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
c=0
for i in range(1,n+1):
    if len(str(i))%2==1:
        c+=1
print(c)
# Judge status: Accepted
s = sorted([_ for _ in input()])

if s == ['a', 'b', 'c']:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
*A, = map(int, input().split())
s = 0
for a in A:
    s = s ^ a
X = [s ^ a for a in A]
print(*X)
# Judge status: Wrong Answer
n,m = map(int,input().split())
ls = list(map(int,input().split()))
for i in range(m):
    b,c = map(int,input().split())
    ls.sort()
    for j in range(b):
        if ls[j] < c:
            ls[j] = c
        if ls[j] >= c:
            break
print(sum(ls))
# Judge status: Accepted
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return a*b // gcd(a,b)

n = int(input())
a = list(map(int,input().split()))
b = a[::-1]
l = [0]
r = [0]
for i in range(n):
    l.append(gcd(a[i],l[-1]))
    r.append(gcd(b[i],r[-1]))
r = r[::-1]
ans = 0
for i in range(n):
    ans = max(ans,gcd(l[i],r[i+1]))
print(ans)
# Judge status: Accepted
def divisors(n):
    d=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
    d.sort()
    return d

x,y=map(int,input().split())
print(-1 if y in divisors(x) else x)
# Judge status: Wrong Answer
n = int(input())
s = []
t = 0
for i in range(n):
  s.append(i)

for i in range(n):
  if(s[i] != i + 1):
    t += 1
if(t == 0 or 2):
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
a, b=map(str,input().split())
c, d=map(int,input().split())
e=input()
f=str(e)
if e==f:
  print(c-1,d)
else:
  print(c,d-1)
# Judge status: Accepted
penki = [i for i in map(int, input().split())]
count = 3
if penki[0] == penki[1]:
    count -= 1
if penki[0] == penki[2]:
    count -= 1
if penki[1] == penki[2]:
    count -= 1
if penki[1] == penki[2] == penki[0]:
    count += 1
print(count)
# Judge status: Accepted
a,b=map(int,input().split())
print(sum(i==i[::-1] for i in map(str, range(a, b+1))))
# Judge status: Accepted
n,x=map(int,input().split())
a=[0]+list(map(int,input().split()))

cnt=0
for i in range(n):
  t=max(a[i]+a[i+1]-x,0)
  cnt+=t
  a[i+1]-=t
print(cnt)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
count = 0

for i in range(1, n - 1):
    s = [p[i-1], p[i], p[i+1]]
    s = sorted(s)
    if s[1] == p[i]:
        count += 1

print(count)
# Judge status: Wrong Answer
x = int(input())

l = -(-x//105)
h = x//100

for i in range(l,h+1):
    for b in range(0,i):
        for c in range(0,i):
            for d in range(0,i):
                for e in range(0,i):
                    if x - (i*100 + 1*b+2*c+3*d+4*e+5*(i-b-c-d-e)) == 0:
                            print('1')
                            exit()
else:
    print('0')
# Judge status: Accepted
N = int(input())

jdg = False

for i in range(26):
    price4 = N - i * 4
    if price4 >= 0 and price4 % 7 == 0:
        jdg = True
        break
print('Yes' if jdg else 'No')
# Judge status: Accepted
import sys

N, K = map(int, sys.stdin.readline().strip().split())

r = N // K
print(min((N, N - r*K, (r+1)*K - N)))
# Judge status: Wrong Answer
from fractions import gcd

P = 10**9 + 7
n = int(input())

def lcm(p,q):
    return p*q//gcd(p,q)

a = list(map(int, input().split()))
x = a[0]
for i in range(1,n):
    x = lcm(x,a[i])
ans = 0
for i in range(n):
    ans += x//a[i]
    if i%5==0:
        ans = ans%P
print(ans)