peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import re
S2=input().strip().replace("?",".")
T=input()
ans="UNRESTORABLE"
if len(S2)<len(T):
    pass
else:
    for i in range(len(S2)-len(T)+1):
        m=re.match(S2[len(S2)-len(T)-i:len(S2)-i],T)
        if m != None:
            ans=S2[:len(S2)-len(T)-i]+ T + S2[len(S2)-i:]
            ans=ans.replace(".","a")
            break

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

ac_count = 0
wa_count = 0
tle_count = 0
re_count = 0

arr = []
for i in range(cases):
    x = input()
    if x == "AC":
        ac_count += 1
    elif x == "WA":
        wa_count += 1
    elif x == "TLE":
        tle_count += 1
    elif x == "RE":
        re_count += 1

print("AC x {0}".format(ac_count))
print("WA x {0}".format(wa_count))
print("TLE x {0}".format(tle_count))
print("RE x {0}".format(re_count))
# Judge status: Wrong Answer
import math
N = int(input())
ans = 1
for i in range(10**5):
    if i**2 < N:
        ans = i**2
    if i**2 > N:
        break

print(ans)
# Judge status: Accepted
import sys
n,m,k = map(int,input().split())
for i in range(n+1):
    for j in range(m+1):
        if (m-j)*i+(n-i)*j == k:
            print("Yes")
            sys.exit()
print("No")
# Judge status: Wrong Answer
l =[list(map(int, input().split())) for i in range(3)]

total1 = total2 = 0
 
for i in range(3):
    total1 += sum(l[i])
    total2 += l[i][i]
    print(total1, total2)
    
if total1 == total2 * 3:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,m = map(int,input().split())
X = sorted(map(int,input().split()))
D = []

for i in range(m-1):
  D.append(X[i+1]-X[i])
  
print(sum(sorted(D)[:-n+1]))
# Judge status: Accepted
kk,nn = map(int, input().split(' '))
ll = list(map(int, input().split(' ')))
ll.append(kk)

aida = []
for j in range(len(ll)-1):
    #print(j)
    if j==0: aida.append(ll[-1]-ll[-2]+ll[0])
    else: aida.append(ll[j]-ll[j-1])
print(sum(aida)-max(aida))
# Judge status: Accepted
T = str(input())
N = len(T)
ans = [0] * N
for i in range(len(T)):
  if T[i] == "?":
    ans[i] = "D"
  else:
    ans[i] = T[i]

for i in range(N):
  print(ans[i], end = "")
# Judge status: Wrong Answer
s = input()
d = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
print(d[(d.index(s)+1)%7])
# Judge status: Wrong Answer
import math
def main():
    N, K = map(int, input().split())
    print(math.ceil(math.log(N+1,K)))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, Q = map(int, input().split())
S = list(input())

# 累積和の配列を定義
mark = [0]*(N+1)

# markの0, 1番目は0
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)
    # l = l - 1
    # r = r - 1
    # print(l, r)
    print(mark[r]-mark[l])
# Judge status: Accepted
def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    x = 0
    for i in range(N):
        x ^= a[i]

    x ^= a[0]
    xors = [x]
    for i in range(1, N):
        x ^= a[i-1]
        x ^= a[i]
        xors.append(x)

    print(' '.join(str(x) for x in xors))


main()
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
c = Counter(a)
res = 0
for key in c.keys():
    # print(key)
    if c[key] >= key:
        res += c[key] - key
    else:
        res += c[key]
print(res)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())

N5=0
N7=0

if a==5:
  N5 +=1
elif a==7:
    N7 +=1

if b==5:
  N5 +=1
elif b==7:
    N7 +=1
    
if c==5:
  N5 +=1
elif c==7:
    N7 +=1
    
if (N5==2)*(N7==1):
  print('Yes')
else:
    print('No')
# Judge status: Accepted
n=int(input())
Ns=list(map(int, input().split() ) ) 
ans=0
for i in range(n):
  for j in range(i,n):
    for k in range(j,n):
      a , b , c = sorted([Ns[i] , Ns[j] , Ns[k]])
      if a+b>c and a!=b and b!=c:
        ans+=1
print(ans)
# Judge status: Wrong Answer
a,b = map(int,input().split())

c = a*b

if c % 2 ==0:
  print ("Even")
else:
  print("Odd")
# Judge status: Wrong Answer
from collections import Counter
from operator import itemgetter

N = int(input())
A = list(map(int,input().split()))
A = list(Counter(A).items())
A  = sorted(A,key=itemgetter(0),reverse = True)
A  = sorted(A,key=itemgetter(1),reverse = True)
#print(A)
ans = 0
for i in range(len(A)-1):
    if A[i][1] > 1:
        if A[i][1] > 3 :
            ans = max(ans,A[i][0]*2)
        if A[i][1] > 1 and A[i+1][1]>1:
            ans = max(ans ,A[i][0]*A[i+1][0])
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

ans = (a + b)%24

print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
cnt = 1
ans = 0

for i in range(n):
    if a[i] != cnt:
        ans += 1
    else:
        cnt += 1

if ans == n:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
N = list(input())
n = [int(val) for val in reversed(N)] + [0]
ln = len(N)

ans = 0
for i in range(ln):
    if n[i] <= 4: a = n[i]
    elif n[i] == 5:
        if n[i+1] <= 4:
            a = n[i]
        else:
            a = 10 - n[i]
            n[i+1] += 1
    else:
        n[i+1] += 1
        a = 10 - n[i]
    ans += a

ans += n[ln]
print(ans)
# Judge status: Wrong Answer
n=int(input())
s=input()
wc=[0]
ec=[0]
for i in range(n):
    if s[i]=="W":
        wc.append(wc[i]+1)
        ec.append(ec[i])
    else:
        wc.append(wc[i])
        ec.append(ec[i]+1)
ans=10**6
for i in range(n):
    tmp=0
    if s[i]=="w":
        tmp+=ec[i]
        tmp+=wc[n]-wc[i]
    else:
        tmp+=wc[i]
        tmp+=ec[n]-ec[i]
    ans=min(tmp,ans)
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().strip().split()]

for a in A:
    if a % 2:
        continue
    if a % 3 != 0 and a % 5 != 0:
        print('DENIED')
        exit()
else:
    print('APPROVED')
# Judge status: Accepted
n, m = map(int, input().split())

if n * 2 > m:
    print(m // 2)
else:
    print((m - 2*n) // 4 + n)
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))
M = 998244353
from collections import Counter

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

cd = Counter(D)
if cd[0] != 1:
    print(0)
    exit(0)

tmp = sorted(cd.items(), key=lambda x: x[0])

ans = 1


for kx in range(1, max(D)+1):
    ans *= pow(cd[kx-1], cd[kx],M)
    ans %= M

print(ans)
# Judge status: Accepted
_ = input()
L = sorted(list(map(int,input().split())))
print("YNeos"[sum(L[:-1]) <= L[-1]::2])
# Judge status: Accepted
N = int(input())
A = sorted(list(map(int,input().split())))
B = (10**6+1)*[0]

for a in A:
  B[a]+=1
  if B[a]==1:
    for n in range(2*a,10**6+1,a):
      B[n]+=2

print(B.count(1))
# Judge status: Wrong Answer
s = input()
LEN = len(s)
if LEN == 1:
    print(0)
    exit()
    
even = s[::2]
odd = s[1::2]

ew = even.count('1')
eb = LEN//2 - ew
ow = odd.count('1')
ob = (LEN+1)//2 - ow

print(min(eb + ow, ew + ob))
# Judge status: Accepted
A,B,C=map(int, input().split())
S=max(A,B,C)*3
S+=3 if S&1!=(A+B+C)&1 else 0
print((S-(A+B+C))//2)
# Judge status: Wrong Answer
s = [int(input()) for i in range(6)]
for i in range(len(s)-2):
  for j in range(1,len(s)-1):
    if abs(s[i] - s[j]) <= s[-1]:
      print(':(')
      exit()
print('Yay!')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
n=int(input())
b=list(map(int,input().split()))

a=[b[0] for _ in range(n)]
a[n-1]=b[n-2]
for i in range(n-1):
  if i!=0 or i!=n-1:
    if b[i-1] <= b[i]:
      a[i]=b[i-1]
    else:
      a[i]=b[i]

sum=0
for i in range(n):
  sum+=a[i]

print(sum)
# Judge status: Accepted
n = int(input())
v = sorted(list(map(int,input().split())))

for i in range(n-1):
  v[0] =(v[0] + v[1])/2
  del v[1]

print(v[0])
# Judge status: Wrong Answer
a,b=input().split()
ab=int(a+b)

a=0
for i in range (4,317):
    if  ab==i*i:
        print('Yes')
        print(i)
        a=1
        break
if a==0:
    print('No')
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
d, e, f = sorted([a, b, c])
print('YES' if a == d and b == e and c == f else 'NO')
# Judge status: Accepted
N, M = map(int, input().split())

for i in range(M//N, 0, -1):
    if M % i == 0:
        print(i)
        break
# 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
a,b,k=map(int,input().split())
L=[]
for i in range(a,a+k):
    if i<=b:
        L.append(i)
for i in range(b+1-k,b+1):
    if i>=a:
        L.append(i)
for l in sorted(set(L)):
    print(l)
# Judge status: Wrong Answer
def main():
    a, b = map(int, input().split())
    a = max(a, b)
    b = min(a, b)

    d = gcd(a, b)
    d1 = a / d
    d2 = b / d
    print(int(d * d1 * d2))


def gcd(a, b):
    while b != 0:
        tmp = a % b
        a = b
        b = tmp
    return a


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

N = list(input())
counter = Counter(N)
# 最大だけ取り出す
counter = sorted(counter.items(), key=lambda x:x[1])[-1]

print("Yes" if counter[1] >= 3 else "No")
# Judge status: Accepted
s,w = map(int, input().split())
if w >= s:
  print("unsafe")
else:
  print("safe")
# Judge status: Accepted
# -*- coding: utf-8 -*-
import sys
import math

N = int(input())

prime = {}
p = 2
while N>=p**2:
  count = 0
  while N%p==0:
    count += 1
    N = N//p
  if count>0:
    prime[p] = count
  p += 1

if N>1:
  prime[N] = 1

answer = 0
for p,v in prime.items():
  minus = 1
  while v>=minus:
    answer += 1
    v -= minus
    minus += 1

print(answer)
# Judge status: Wrong Answer
n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) / a
print(ans)
# Judge status: Accepted
import sys

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


def resolve():
    r, g, b = input().split()
    number = int(r + g + b)
    print("YES" if number % 4 == 0 else "NO")


if __name__ == '__main__':
    resolve()
# Judge status: Accepted
n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()
ct=0
for i in range(n):
  ct += ab[i][1]
  if ct >= k:
    print(ab[i][0])
    exit()
# Judge status: Wrong Answer
N = int(input())
import math
print(800*N - 200*(math.ceil(N/15)))
# Judge status: Accepted
import collections
N = int(input())
A = list((map(int,input().split())))

index = list(range(1,N+1))

R = [index[i] - A[i] for i in range(N)]
L = [index[j] + A[j] for j in range(N)]

R_dict = collections.Counter(R)
L_dict = collections.Counter(L)

ans=0
for i in R_dict.keys()&L_dict.keys():
    ans+=R_dict[i]*L_dict[i]

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

ans = 0
for _ in range(10**6):
    if A%2 == 1 or B%2 == 1 or C%2 == 1:
        break
    a = (B+C)//2
    b = (C+A)//2
    c = (A+B)//2
    A = a
    B = b
    C = c
    ans += 1

if ans == 10**6:
    ans = -1
print(ans)
# Judge status: Accepted
s=list(input())
n=len(s)
k=int(input())
a=[]
for i in range(n):
  if i==n-1:
    s[i]=chr(97+(ord(s[i])-97+k)%26)
    break
  if s[i]=="a":continue
  t=26-(ord(s[i])-97)%26
  if t>k:continue
  k-=min(t,k)
  s[i]=chr(97+(ord(s[i])-97+t)%26)
print("".join(s))
# Judge status: Wrong Answer
S = str(input())
s = int(S)
n = len(S)
count = 0
for i in range(1,n+1):
    for j in range(i+4,n+1):
        si = s%10**(n-i+1)
        sij = si//10**(n-j)
        print(sij)
        if sij!= 0 and sij % 2019 == 0:
            count+=1

print(count)
# Judge status: Wrong Answer
N = int(input())
color = 0
a = int(input())
for i in range(1,N):
  b = int(input())
  if a >= b:
    color += 1
    
  a = b
  
print(color)
# Judge status: Wrong Answer
# https://atcoder.jp/contests/abc077/tasks/arc084_a
import sys
from bisect import bisect_left, bisect_right


def S(): return sys.stdin.readline().rstrip()


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
A = LI()
B = LI()
C = LI()
A.sort()
B.sort()
C.sort()
ans = 0
for i in A:
    b_left = bisect_left(B, i)

    for q in range(b_left, len(B)):
        c_left = bisect_left(C, B[q])

        ans += len(C) - c_left

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

tmp = M//N
ans = 0
for i in range(tmp,-1,-1):
    if M%i==0:
        ans = i
        break
print(ans)
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
s = input()

if C > D:
    if "##" in s:
        print("No")
    else:
        if "..." in s[B-2:D+1]:
            print("Yes")
        else:
            print("No")
else:
    if "##" in s[min(A,B)-1:D]:
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
n = int(input())
k = input()
k2 = k[::-1]
i1 = 0
i2 = 0
cnt = 0
while i1 < n:
  if k[i1] == 'W':
    while i2 < n:
      if k2[i2] == 'R':
        i2 += 1
        cnt += 1
        break
      i2 += 1
      if i1 + i2 >= n:
        break
  i1 += 1
  if i1 + i2 >= n:
    break
print(cnt)
# Judge status: Wrong Answer
n, m = map(int, input().split())
l = []

for i in range(m):
    p, y = input().split()
    l.append([p, y])

l.sort()

l[0][1] = 1

for i in range(1, m):
    if l[i][0] == l[i - 1][0]:
        l[i][1] = l[i - 1][1] + 1
    else:
        l[i][1] = 1

for i in l:
    ans = "0"*(6 - len(i[0])) + i[0] + "0"*(6 - len(str(i[1]))) + str(i[1])
    print(ans)
# Judge status: Accepted
K=int(input())
A,B=map(int, input().split())
for i in range(1,1001):
    if i%K==0 and A<=i and i<=B:
        print("OK")
        exit()

print("NG")
# Judge status: Accepted
n=int(input())
maxx=0
sec=0
lis=[]
for i in range(n):
  s=int(input())
  lis.append(s)
  if s>=maxx:
    sec=maxx
    maxx=s
  elif s>sec:
    sec=s
for j in range(0,n):
  if lis[j]==maxx:
    print(sec)
  else:
    print(maxx)
# Judge status: Accepted
s = input()
t = input()
S,T = len(s),len(t)
ans = T
for i in range(S-T+1):
    tmp = [c1!=c2 for c1,c2 in zip(s[i:i+T],t)].count(True)
    ans = min(ans,tmp)
print(ans)
# Judge status: Wrong Answer
s = list(map(int, input().split()))
t = [input() for i in range(s[0])]
for i in range(0, s[0] - 1):
    if t[i] > t[i + 1]:
        u = t[i]
        t[i] = t[i + 1]
        t[i + 1] = u
v = t[0]
for i in range(1, s[0]):
    v = v + t[i]
v
# Judge status: Wrong Answer
H = int(input())
W = int(input())
N = int(input())
for i in range(100):
    if max(H, W) * i >= N:
        print(i)
        exit()
# Judge status: Accepted
N=int(input())
S=input()
ap=[0]*(N+1)
bp=[0]*(N+1)
a=0
b=0
for i in range(N):
  if S[i]=='W':
    a+=1
  else:
    b+=1
  ap[i+1]=a
  bp[i+1]=b
ans=10**9
for j in range(1,N+1):
  ans=min(ap[j-1]+bp[N]-bp[j],ans)
print(ans)
# Judge status: Wrong Answer
n = list(input())
import collections
c = collections.Counter(n)

if c.most_common()[0][1] < 3:
    print('No')
elif n[0] != n[1] or n[1] != n[2]:
    print('No')
else:
    print('Yes')

# print(c.most_common()[0][1])
# Judge status: Wrong Answer
a,b,x=map(int,input().split())

r=b-a
if a%x==0 or b%x==0:
    ans=(b-a)//x+1
elif b==a:
    ans=0
else:
    ans=(b-a)//x
print(ans)
# Judge status: Accepted
#coding:utf-8
n,a,b = map(int, input().split())
if (a>b or (n==1 and a!=b)):
    print (0)
elif n==1:
    print (1)
else:
    print ((n-2)*(b-a)+1)
# Judge status: Accepted
import numpy as np

N = int(input())
p_array = np.array(list(map(int, input().split())))

sorted_p = np.sort(np.copy(p_array))
diff = (p_array != sorted_p).sum()

if diff == 0:
    print('YES')
elif diff == 2:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
def main():
    x, y = map(int, input().split())
    print(min(max(y-x, x-y+2), abs(x+y)+1))
if __name__ == '__main__':
    main()
# Judge status: Accepted

from collections import Counter
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A,B = map(int,input().split())
p1 = Counter(prime_decomposition(A))
p2 = Counter(prime_decomposition(B))
ans = 1
for p,_ in p1.items():
  if p2[p] > 0:
    ans += 1

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

lis = []
ans = "Yes"
for i in range(N):
    W = input()
    lis.append(W)
    if (W in lis == False) or (W[0] == lis[i-1][-1]):
        pass
    else:
        ans = "No"

print(ans)
# Judge status: Accepted
import itertools
a, b, c, d, e, k = int(input()), int(input()), int(input()), int(input()), int(input()), int(input())

for x, y in list(itertools.combinations([a, b, c, d, e], 2)):
    if y - x > k:
        print(':(')
        exit()
else:
    print('Yay!')
# Judge status: Accepted
## C - gacha
N = int(input())
S = [str(input()) for s in range(N)]
print(len(set(S)))
# Judge status: Accepted
a, b = map(int, input().split())

if (a + b) % 3 == 0 or b % 3 == 0 or a % 3 == 0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Wrong Answer
n,ng = map(int,input().split())
nglist = list(int(input()) for i in range(ng))

MOD   = 10**9+7 
dp    = [0]*(n+1)
dp[0] = 1

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

  if i in nglist:
    dp[i] == 0
    continue

  if i==1:
    dp[1] == dp[0]
    continue
  
  dp[i] = (dp[i-2] + dp[i-1]) % MOD

print(dp[n])
# Judge status: Accepted
a,b,x=map(int,input().split())
if a<=x<=(a+b-1):
    print('YES')
else:
    print('NO')
# Judge status: Accepted
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,x=nii()
a=lnii()
a.sort()

a_sum=0
for i in range(n):
  a_sum+=a[i]
  if a_sum>x:
    print(i)
    exit()

if x>sum(a):
  print(n-1)
else:
  print(n)
# Judge status: Wrong Answer
n = int(input())
s = input()

black = []
white = []

cb=0
cw=0
for l in s:
    if l =="#":
        cb+=1
    else:
        cw+=1
    black.append(cb)
    white.append(cw)

if n == 1:
    print(0)
else:
    ans = []
    for i in range(n+1):
        ans.append(black[i-1]+white[-1]-white[i-1])
    print(min(ans))
# Judge status: Wrong Answer
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, a, b = map(int, readline().split())

    ans = min(abs(x - a), abs(x - b))
    
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def c(n):
  res = 0
  while n > 0:
    res += n % 10
    n //= 10
  return res

n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
  if a <= c(i) <= b:
    ans += 1
print(ans)
# Judge status: Wrong Answer
import math

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

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

if N < 2:
  N = 0
elif N == 2:
  N == 1
else:
  N = comb(N,2)

if M < 2:
  M = 0
elif M == 2:
  M = 1
  
ans = N + M

print(ans)
# Judge status: Accepted
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
for i in range(3):
    if (A[i][0] in B and A[i][1] in B and A[i][2] in B) or (A[0][i] in B and A[1][i] in B and A[2][i] in B):
        print("Yes")
        exit()
if (A[0][0] in B and A[1][1] in B and A[2][2] in B) or (A[0][2] in B and A[1][1] in B and A[2][0] in B):
    print("Yes")
    exit()
print("No")
# Judge status: Accepted
a, b = input().split()
x = a * int(b)
y = b * int(a)
print(sorted([x, y])[0])
# Judge status: Wrong Answer
A = int()
B = int()
C = A*B
print(C)
# Judge status: Accepted
s = input()
n = s[::2].count("0")+s[1::2].count("1")
print(min(n, len(s)-n))
# Judge status: Accepted
#!/usr/bin/env python3
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
j = m
for i in range(n + 1):
    if A[i] > k:
        break
    while j > 0 and k - A[i] < B[j]:
        j -= 1
    ans = max(ans, i + j)

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

cnt= int(len(A) / 2) + 1
print(cnt)
cnts = 0
isYes = True

for i in A:
    if A.count(i) > 1:
        isYes = False
        break
    else:
        isYes = True
 
    if cnts == cnt:
        isYes = True
        break
    cnts += 1

if isYes:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
s = input().split('/')
if int(s[0]+s[1]+s[2]) > 20190430:
  print('Heisei')
else:
  print('TBD')
# Judge status: Accepted
N=int(input())
ans=N%1000
ans=1000-ans
ans=ans%1000
print(ans)
# Judge status: Accepted
N = int(input())
line = []
for i in range(N):
    tmp = [j for j in input().split()]
    tmp[1] = -1 * int(tmp[1])
    tmp.append(i + 1)
    line.append(tmp)
line.sort()
for i in range(N):
    print(line[i][2])
# Judge status: Accepted
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())
dic = {'r':P,'s':R,'p':S}
ans  = 0
for i in range(K):
    ans += dic[T[i]]
for i in range(K,N):
    if T[i-K] != T[i]:
        ans += dic[T[i]]
    else:
        T[i] = 'e'
print(ans)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
if abs(a-c) <= d: print('Yes')
else:
    if a < c:
        if 0 <= b-a <= d and 0 <= c-b <= d: print('Yes')
        else: print('No')
    else:
        if 0 <= a-b <= d and 0 <= b-c <= d: print('Yes')
        else: print('No')
# Judge status: Wrong Answer
def main():
    N, M = map(int, input().split(" "))
    i = 2
    result = 0
    while i * i <= M:
        if M % i == 0:
            if i <= M / N:
                result = i
            else:
                break
        i += 1
    print(result)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1,0,-1):
    if H[i-1] - H[i] > 1:
        print("No")
        exit()
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1

for i in range(N-1):
    if H[i] > H[i+1]:
        print("No1")
        exit()
        
print("Yes")
# Judge status: Wrong Answer
def main():
    import math
    n, m = map(int, input().split())
    if n - m <= -2 or n - m >= 2:
        print(0)
        exit()

    else:
        if n != m:
            ans = math.factorial(n) % (10*9 + 7) * math.factorial(m) % (10**9 + 7)
        else:
            ans = math.factorial(n) * 2 % (10**9 + 7) * math.factorial(m) % (10**9 + 7)

    print(ans)


    

 
    
    
if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b,c,d,e=(int(x) for x in input().split())
if a==0:
    print('1')
elif b==0:
    print('2')
elif c==0:
    print('3')
elif d==0:
    print('4')
elif e==0:
    print('5')
# Judge status: Accepted
import numpy as np

N = int(input())

Ns = [i for i in range(1,N+1)]

counts = []
for N in Ns:
    count = 0
    while N % 2 == 0:
        N //= 2
        count += 1
    counts.append(count)

print(Ns[np.argmax(counts)])
# Judge status: Accepted
d, t, x = map(int, input().split())
if x*t >= d:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
a,b = b,c
a,c = c,a
print(a,b,c)
# Judge status: Wrong Answer
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))
 
inp = LI()
n,Y = [inp.pop(0) for _ in range(2)]
 
x = int(Y/10000)
y = int((Y-x*10000)/5000)
z = int((Y-x*10000-y*5000)/1000)
 
if x+y+z<=n:
    print(str(x)+' '+str(y)+' '+str(z))
else:
    print('-1 -1 -1')
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
    x, y = map(int, input().split())
    ans = abs(abs(x) - abs(y))
    if x * y < 0:
        ans += 1
    elif x > y and x * y == 0:
        ans += 1
    elif x > y:
        ans += 2
    print(ans)
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
s,c = map(int,input().split())

print(s+(c-s*2)//4)
# Judge status: Wrong Answer
K = int(input())
cnt = 0
i = 1
while cnt < K:
  s = str(i)
  if len(s) == 1:
    cnt += 1
  else:
    flg = True
    for j in range(1, len(s)):
      if abs(s[j] - s[j-1]) > 1:
        flg = False
        break
    if flg:
      cnt += 1
    i += 1
print(i-1)