peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = sum(A)

for i in range(N):
    
    if A[i] >= B[i]:
        A[i] -= B[i]
    
    else:
        A[i + 1] -= abs(A[i] - B[i])
        A[i + 1] *= int(A[i + 1] > 0)
        A[i] = 0 

print(ans - sum(A))
# Judge status: Accepted
N, A, B = [int(n) for n in input().split(" ")]

cnt = 0

for n in range(1,N+1):
  temp = 0
  i =n
  while n>0:
    temp += int(n)%10
    n /= 10
  if temp >= A and temp <= B:
    cnt += i

print(cnt)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
odd=0
even=0
ev=0 #4の倍数
for i in a:
    if i%4==0:
        ev+=1
    elif i%2==0:
        even+=1
    else:
        odd+=1
even%=2
odd+=even
if odd>ev+1:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
s=input()
t=input()
if s in t:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())

S = [None] * N

m = dict()

for i in range(N):
  s = input()
  if not s in m.keys():
    m[s] = 1
  else:
    m[s] += 1

max_cnt = max(m.values())

ret = []

for k, v in sorted(m.items(), key=lambda x: x[1], reverse=True):
  if v < max_cnt:
    break
  ret.append(k)

ret.sort()
print(ret)
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,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()))

a,b = inpl()
if a == 2 or b == 2:
    print(0)
elif a == 1 and b == 1:
    print(1)
elif a == 1 or b == 1:
    print(a*b-2)
else:
    print((a-2)*(b-2))
# Judge status: Accepted
from collections import Counter

s = input()
t = input()

s_cnt = Counter(s).most_common()
t_cnt = Counter(t).most_common()

for i in range(min(len(s_cnt), len(t_cnt))):
    if s_cnt[i][1] != t_cnt[i][1]:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted

import math
import itertools
import statistics
#import collections
n = int(input())
s = input()

amari = 0
plus = 0

for i in range(n):
    if s[i]=="(":
        plus += 1
    else:
        if plus <= 0:
            amari +=1
        else:
            plus -= 1

for i in range(amari):
    print("(", end="")

print(s, end="")

for i in range(plus):
    print(")", end="")
# Judge status: Wrong Answer
h=int(input())
a=1
while True:
 h=h//2
 a += 1
 if h//2==0:
  break

print(2**a-1)
# Judge status: Wrong Answer
S,T = input().split()
print(S,T, sep='')
# Judge status: Accepted
N = int(input())

def prefix_postfix(n):
    sn = str(n)
    return int(sn[0]), int(sn[-1])

import numpy as np
cnt = np.zeros((10, 10), np.uint64)

for i in range(1, N+1):
    pair = prefix_postfix(i)
    cnt[pair] += 1

ans = 0

for i in range(10):
    for j in range(10):
        ans += cnt[i, j] * cnt[j, i]

print(int(ans))
# Judge status: Accepted
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
a=7
ans=1
while ans<10**7:
    if a%k==0:
        print(ans)
        exit()
    a%=k
    a*=10
    a+=7
    ans+=1
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
count_a = Counter(a)
new_a = [i for i in count_a.keys() if count_a[i] >= 2]
#print(new_a)
if len(new_a) < 2:
    print(0)
    exit()
new_a = sorted(new_a, reverse=True)
ans = new_a[0] * new_a[1]
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
f = False
for i in range(n-1):
    if a[i+1] - a[i] == 0:
        f = True
        break

if f == True:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
S = input()
a = ['maerd', 'remaerd', 'esare', 'resare']
tmp =''
for s in S[::-1]:
    tmp += s
    if tmp in a: tmp=''
print('YES' if len(tmp)==0 else'NO')
# Judge status: Accepted
import collections
N = int(input())
A = list(map(int, input().split()))
edge = collections.Counter(A)
a = 0
b = 0
c = 0
for i in sorted(edge.items()):
    if i[1] >= 2:
        if i[0] > a:
            b = a
            a = i[0]
    if i[1] >= 4:
        c = i[0]

if a * b >= c * c:
    answer = a * b
else:
    answer = c * c

print(answer)
# Judge status: Wrong Answer
s = input()
n = len(s)
a = [0 for i in range(n)]
for i in range(n - 1):
  if s[i] == '<':
    a[i + 1] = max(a[i + 1], a[i] + 1)
for i in reversed(range(n - 1)):
  if s[i] == '>':
    a[i] = max(a[i], a[i + 1] + 1)
ans = sum(a)
print(ans)
# Judge status: Accepted
import sys
import math
import collections
from collections import deque
import heapq
#n = int(input())
n, m = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))
a = list(map(lambda x: -x, a))
heapq.heapify(a)
for i in range(m):
    x = heapq.heappop(a) * (-1)
    x = math.floor(x/2)
    heapq.heappush(a, -x)

print(-sum(a))
# Judge status: Accepted

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

from fractions import gcd
from itertools import accumulate

X = list(accumulate(A, gcd))
Y = list(accumulate(A[::-1], gcd))

Y.insert(0,0)
X.insert(0,0)

ans = -1
for i in range(N):
  ans = max(ans, gcd(X[i], Y[N-1-i]))

print(ans)
# Judge status: Accepted
n = int(input())
l = ['a','b','c','d','e','f','g','h','i','j']

def dfs(res,i):
    if len(res)==n:
        print(res)
        return
    for k in range(i):
        dfs(res+l[k],i)
    dfs(res+l[i],i+1)

dfs('',0)
# Judge status: Accepted
n,m= map(int,input().split())
print(int(n*(n-1)/2+m*(m-1)/2))
# Judge status: Wrong Answer
N = int(input())
a = []
for i in range(1,N):
  if i%3==0 or i%5==0:
    pass
  else:
    a.append(i)
print(sum(a))
# Judge status: Accepted
A=[int(input()) for i in range(5)]
ans=0
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
        A[i]=0
B=[str(i) for i in A]
C=[B[i][-1] for i in range(5)]
C=[int(C[i]) for i in range(5)]
D=[None]*5
for i in range(5):
    D[i]=int(B[i])-int(C[i])
E=list([n for n in(sorted(C,reverse=True)) if n>0])
for i in range(len(E)-1):
    ans+=10
try:
    ans=ans+E[-1]+int(sum(D))
except(IndexError):
    ans=ans+int(sum(D))
print(ans)
# Judge status: Accepted
n = int(input())
s = list(input())
ans = 0
for i in range(n):
         if ans < len(set(s[:i]) & set(s[i:])):
                  ans = len(set(s[:i]) & set(s[i:]))
print(ans)
# Judge status: Accepted
n,_ = map(int,input().split())
ds = list(input().split())

amount = n
while 1:
  s_amount = str(amount)
  for d in s_amount:
    if d in ds:
      break
  else:
    break
  amount += 1
print(amount)
# Judge status: Accepted
N = int(input())

dp = [0] * 100001

dp[1] = 1

for i in range(2, N + 1):
    dp[i] = dp[i - 1] + 1
    j = 1
    while 6 ** j <= i:
        dp[i] = min(dp[i], dp[i - (6 ** j)] + 1)
        j += 1
    j = 1
    while 9 ** j <= i:
        dp[i] = min(dp[i], dp[i - (9 ** j)] + 1)
        j += 1

print(dp[N])
# Judge status: Accepted
N = int(input())
b = 10**9+7
A = list((int(x) for x in input().split()))
sum = 0
for a in A:
  sum += a
ans = 0
for i in range(N-1):
  sum -= A[i]
  ans += A[i]*sum
print(ans % b)
# Judge status: Accepted
d = int(input())
c = 'Christmas'
e = ' Eve'
if d == 25:
    print(c)
elif d == 24:
    print(c + e)
elif d == 23:
    print(c + e + e)
else:
    print(c + e + e + e)
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())

X = list(map(int, input().split()))

X.sort()

dist = []
for i in range(len(X)-1):
    dist.append(X[i+1]-X[i])

dist.sort()

print(sum(dist[:len(dist)-(N-1)]))
# Judge status: Accepted
def solve(a, b, h):
    print(int((a + b) / 2 * h))



a = int(input())
b = int(input())
h = int(input())
solve(a, b, h)
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))

ans=1

if 0 in A:
    print(0)
    exit()

for i in A:
   ans=ans*i
   if ans>10**18:
    print(-1)
    exit()


print(ans)
# Judge status: Accepted
l = list(input())
for i in range(1,len(l)//2):
  l1 = l[:len(l)-2*i]
  if l1 == l1[:len(l)//2-i]*2:
    print(len(l1))
    exit()
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))

l = sorted(a)
flag = False
for i in range(n):
    x -= l[i]
    if x < 0:
        flag = True
        break
if flag:
    print(i)
elif x == 0:
    print(n)
elif x > 0:
    print(n - 1)
# Judge status: Wrong Answer
n,a,b = map(int,input().split())
count_list = [0]*n

for i in range(1,n):
  for k in range(i + 1,n + 1):
    count_list[i-1] = min(k - i,abs(a-i)+ abs(b-k) + 1)
    
for co in range(1,n +1):
  print(count_list.count(co))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

mi = n+1
ans = 0
for i in a:
    if mi>=i:
        ans+=1
    mi = min(mi,i)
print(ans)
# Judge status: Accepted
s = input()
t = input()
if sorted(s) < sorted(t,reverse=True): print("Yes")
else: print("No")
# Judge status: Accepted
from sys import stdin

n = int(stdin.readline().rstrip())
a, b, c = [[int(x) for x in stdin.readline().rstrip().split()]
           for _ in range(3)]
total = 0
for i in range(len(a)):
    total += b[a[i]-1]
    if (i != len(a) - 1) and (a[i + 1] - a[i] == 1):
        total += c[a[i] - 1]

print(total)
# Judge status: Accepted
input_numbers = list(map(int,input().split()))
a = input_numbers[0]
b = input_numbers[1]
A = a
B = b
x = 0
y = 0
while A > 0:
  x += 10 ** (A-1) * b
  A -= 1
while B > 0:
  y += 10 ** (B-1) * a
  B -= 1
if x > y:
  print(x)
else:
  print(y)
# Judge status: Accepted
N=input()

MM=0
mm=0


if int(N[0])>1 or (int(N[0])==1 and int(N[1])>2) or N[0:2]=="00":
    MM=0
else:
    MM=1
if int(int(N[2]))>1 or (int(N[2])==1 and int(N[3])>2 or N[2:4]=="00"):
    mm=0
else:
    mm=1

if MM+mm==2:
    print("AMBIGUOUS")
elif MM==1:
    print("MMYY")
elif mm==1:
    print("YYMM")
else:
    print("NA")
# Judge status: Accepted
n=int(input())
d={}
for k in range(2,10**6):
  while n%k<1: n//=k; d[k]=d.get(k,0)+1
a=0
for i in d.values():
  t=c=0
  while t+c<i: c+=1; t+=c
  a+=c
print(a+(n>1))
# Judge status: Wrong Answer
n, h = map(int, input().split())
a = [0]*n
b = [0]*n
maxa = 0
for i in range(n):
    a[i], b[i] = map(int, input().split())
    maxa = max(maxa, a[i]) 
b.sort()
bsum = sum(b)
count = n

if bsum >= h:
    i = 0
    while bsum - b[i] > h:
        bsum -= b[i]
        i += 1
        count -= 1
else:
    if (h - bsum) % maxa == 0:
        count += (h - bsum) // maxa
    else:
        count += (h - bsum)//maxa
        count += 1111

print(count)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split())) 

tmp = 0
for a in A:
    tmp ^= a

ans = []

for a in A:
    ans.append(tmp^a)


an_c = str(ans[0])
for an in ans[1:]:
    an_c += " " + str(an)
    
print(an_c)
# Judge status: Accepted
# A - Two Coins
a,b,c=list(map(int,input().split()))
if (a+b)>=c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b = map(int, input().split())
if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
# Judge status: Accepted
def main():
  n,h=map(int,input().split())
  ab=[list(map(int,input().split())) for _ in range(n)]
  amax=max([a for a,b in ab])
  b=[b for a,b in ab if b>amax]
  b.sort(reverse=True)
  ans=0
  sumb=sum(b)
  if h<sumb:
    d=0
    while d<h:
      d+=b[ans]
      ans+=1
    print(ans)
  else:
    d=h-sumb
    ans=len(b)+(d+amax-1)//amax 
    print(ans)
if __name__=='__main__':
  main()
# Judge status: Wrong Answer
import math
n = int(input())
t = [int(input()) for _ in range(n)]
ans = 1
for i in range(n-1):
    ch = math.gcd(t[i+1],ans)
    ans = t[i]*t[i+1]//ch
print(ans)
# Judge status: Accepted
n=int(input())
wordset=set()
pw=input()
wordset.add(pw)
ans='Yes'
for _ in range(n-1):
  w=input()
  if pw[-1] != w[0] or w in wordset:
    ans='No'
    break
  wordset.add(w)
  pw=w
print(ans)
# Judge status: Accepted
N=int(input())

if N%2==0:
    print("0.5")
else:
    print(((N+1)/2)/N)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

cnt = 0
for i in range(N-1):
    if A[i] == i+1:
        A[i],A[i+1] = A[i+1],A[i]
        cnt += 1
        i += 1
if A[N-1]==N:
    cnt += 1
print(cnt)
# Judge status: Accepted
n = int(input())
A = sorted(list(map(int, input().split())), reverse = True)
l = 0
ln = []
for a in A:
    if l == a:
        ln.append(a)
        l = 0
    else:
        l = a
    if len(ln) == 2:
        break
if len(ln) == 2:
    print(ln[0]*ln[1])
else:
    print(0)
# Judge status: Wrong Answer
s = input()
t = input()

for i in range(len(s)):
    ns = s[i:] + s[:i]
    if(s == t):
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
a=int(input())
if a<=9:
    ans=a
elif a<=99:
    ans=9
elif a<=999:
    ans=9+(a-99)
elif a<=9999:
    ans=909
elif a<=99999:
    ans=909+(a-9999)
else:
    ans=90909
print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
r,s,p=map(int,input().split())
T=input()
cnt=0
N=[0]*n
for i in range(n):
    if N[i]==1:
        continue
    if i+k<=n-1:
        if T[i]==T[i+k]:
            N[i+k]=1
    
    if T[i]=='r':
        cnt+=p
    elif T[i]=='s':
        cnt+=r
    else:
        cnt+=s

print(cnt)
# Judge status: Accepted
s=input().split()[1]
print("A"+s[0]+"C")
# Judge status: Wrong Answer
n=int(input())
l=[input().split() for i in range(n)]
tmp_l = sorted(l, key=lambda x: x[1],reverse=True)
ans=sorted(tmp_l,key=lambda x: x[0])
for i in range(n):
 print(1+ans.index(ans[i]))
# Judge status: Accepted
x = int(input())
chokin = 100
count = 0
while chokin < x:
    chokin = int(chokin *1.01)
    count += 1
print(count)
# Judge status: Accepted
import bisect
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]

dp = deque()
dp.append(A[0])

for i in range(1, N):
    ind = bisect.bisect_left(dp, A[i])

    if ind == 0:
        dp.appendleft(A[i])
    # elif dp[-1] < A[i]:
    #     dp[-1] = A[i]
    else:
        dp[ind-1] = A[i]

print(len(dp))
# Judge status: Accepted
n,m,x = map(int,input().split())


cal = [list(map(int,input().split())) for _ in range(n)]


from itertools import product
ans = float("inf")

for bits in product([0, 1], repeat=n):
    ansl = [0 for _ in range(m+1)]
    for idx, bit in enumerate(bits):
        for i in range(m+1):
            ansl[i] += bit * cal[idx][i]
    for i in range(1, m+1):
        if ansl[i] < x:
            break
    else:
        ans = min(ansl[0], ans)
    continue
if ans == float("inf"):
    print(-1)
else:
    print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(n):
  if i%2==1 and (a[i]+1)%2==1:
    ans += 1
    
print(ans)
# Judge status: Accepted
x = int(input())
res = x // 11
mod = x % 11
res*=2
if mod > 6:
    res+=2
elif mod!=0:
    res+=1
print(res)
# Judge status: Accepted
w, h, n = list(map(int, input().split()))
x_min, x_max, y_min, y_max = 0, w, 0, h
for _ in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        x_min = max(x_min, x)
    elif a == 2:
        x_max = min(x_max, x)
    elif a == 3:
        y_min = max(y_min, y)
    else:
        y_max = min(y_max, y)
if x_min >= x_max or y_min >= y_max:
    print(0)
else:
    print((x_max - x_min) * (y_max - y_min))
# Judge status: Accepted
N = int(input())
A = input()
A_list = [int(x) for x in A.split()]

if len(A_list) == len(set(A_list)):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N, M =map(int, input().split())
ans = []
for i in range(M):
    a, b = map(int, input().split())
    ans.append(a)
    ans.append(b)

for i in range(1,N+1):
    print(ans.count(i))
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]

left = [a[0]]
right = [a[-1]]
for i in range(1, n):
    left.append(max(left[i-1], a[i]))
    right.append(max(right[i-1], a[n-i-1]))
right = right[::-1]
print(right[1])

for i in range(1, n-1):
    print(max(left[i-1], right[i+1]))
print(left[-2])
# Judge status: Accepted
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    c=b-a
    ct=0
    for i in range(c):
        ct+=i
    print(ct-a)
if __name__ == '__main__':
    do()
# Judge status: Accepted
A=list(map(int,input().split()))
A.sort()
a=A[2]-A[1]
b=A[2]-A[0]
if a%2==0 and b%2==0:
  print(a//2+b//2)
elif a%2==1 and b%2==1:
  print(a//2+b//2+1)
else:
  print(a//2+1+b//2+1)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 10**12
for i in range(N - K + 1):
    l = A[i]
    r = A[i + K - 1]
    d = r - l + min(abs(r), abs(l))
    ans = min(d, ans)

print(ans)
# Judge status: Accepted
S=input()
T=input()
x=len(S)
y=len(T)
l=[]
for i in range(x-(y-1)):
    s=0
    for j in range(y):
        if S[j+i]==T[j]:
            s+=1
    l.append(y-s)
print(min(l))
# Judge status: Accepted
import math
def main():
  N=int(input())
  X=list(map(int,input().split()))
  x_mean=round(sum(X)/len(X))
  sumX=0
  for i in range(len(X)):
    sumX=sumX+(X[i]-x_mean)**2
  print(sumX)

if __name__ == '__main__':
	main()
# Judge status: Wrong Answer
import math

a = []
for i in input().split(" "):
    a.append(math.sqrt(int(i)))


if a[0] +a[1] - a[2]< 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted

X = int(input())

if X > 2000:
    out=1
elif X < 100:
    out=0
else:
    A = X // 100
    if X - A*100 <= 5*A:
        out=1
    else:
        out=0
print(out)
# Judge status: Wrong Answer
def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

a,b,c,d= NextInts() #高橋体力a 青木体力c

while((a>0) or (c>0)):
	c-=b
	if c<=0:
		break
	a-=d
if a<c:
	print("No")
else:
	print("Yes")
# Judge status: Accepted
s = input()
ans = 0

for i in range(1, len(s) - 1):
    u = s[:-i]
    p = len(u)//2
    if u[:p] == u[p:]:
        ans = max(ans, len(u))

print(ans)
# Judge status: Accepted
import numpy as np
a = np.array([int(input()) for _ in range(5)])
k = int(input())

bl = a.max() - a.min() <= k

print("Yay!") if bl else print(":(")
# Judge status: Wrong Answer
n=int(input())
a=list()
for i in range (n):
    a.append(int(input()))
new_a=sorted(a)
max=new_a[0]
max2=new_a[1]
for i in a:
    if(i==max):
        print(max2)
    else:
        print(max)
# Judge status: Accepted
a,b,c = input().split()
List = [a,b,c]
print(len(set(List)))
# Judge status: Accepted
N, M = list(map(int, input().split()))
A_list = list(map(int, input().split()))
n = N - sum(A_list)
if n < 0:
    print('-1')
else:
    print(n)
# Judge status: Accepted
import math
n,d=map(int,input().split())

x=[]
for i in range(n):
  x.append(list(map(int,input().split())))

cnt=0

for i in range(n-1):
  for j in range(i+1,n):
    s=0
    for k in range(d):
      s+=(x[i][k]-x[j][k])**2
    if int(math.sqrt(s))**2==s:
      cnt+=1
      
print(cnt)
# Judge status: Wrong Answer
n = int(input())
a_l = list(map(int,input().split()))
ia = list(enumerate(a_l))
del_l = []
for j in range(n):
    if ia[j][1] >= n-1:
        del_l.append(j)

for j in del_l[::-1]:
    del ia[j]
        
count = 0
for i1, a1 in ia[:-1]:
    if a1 >= n-1-i1:
        continue
    for i2, a2 in ia[i1+a1+1:n]:
        if (i2-i1) == (a2+a1):
            count += 1

print(count)
# Judge status: Accepted
n, m = map(int, input().split())
p, s = [], []
pslist = []
for i in range(m):
  row = list(input().split( ))
  pslist.append(row)
aclist = [0] * n
walist = [0] * n
for j, k in pslist:
  j = int(j)
  if k == 'AC':
    if aclist[j - 1] == 0:
      aclist[j - 1] = 1
  if k == 'WA':
    if aclist[j - 1] == 0:
      walist[j - 1] += 1
wacountlist = [x * y for (x, y) in zip(aclist, walist)]
print(sum(aclist), sum(wacountlist))
# Judge status: Wrong Answer
s=list(input())
t=list(input())
ans='U'
for i in range(len(s)-len(t),-1,-1):
  if s[i]==t[0]:
    cnt=0
    for j in range(len(t)-1):
      if s[i+j]==t[j] or s[i+j]=='?':
        cnt+=1
    if cnt==len(t)-1:
      s[i:i+len(t)]=t
      u=''
      for k in s:
        u+=k
      u=u.replace('?','a')
      print(u)
      exit()
      
print('UNRESTORABLE')
# Judge status: Accepted
n=int(input())
t=[int(input())for _ in range(n)]
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
ans=t[0]
for i in t[1:]:ans=lcm(ans,i)
print(ans)
# Judge status: Wrong Answer
n = int(input())
q = list(map(int, input().split(" ")))

result = 0
flg = True
temp = 10

for i, item in enumerate(q):
  if temp > item:
    for j in q[:i+1]:
      if j < item:
        flg = False
        temp = item
        break
      flg = True
  else:
    flg = False

  if flg:
    result = result + 1

print(result)
# Judge status: Accepted
from itertools import accumulate
N, M, K = map(int, input().split())
As = [0] + list(map(int, input().split()))
Bs = [0] + list(map(int, input().split()))
csum_A = list(accumulate(As))
csum_B = list(accumulate(Bs))

ok = 0
ng = N + M + 2
while ng - ok > 1:
    mid = (ng + ok) // 2
    min_time = 10 ** 9 + 10
    for t in range(max(0, mid-M), min(mid+1, N+1)):
        min_time = min(min_time, csum_A[t] + csum_B[mid - t])
    
    if K >= min_time:
        ok = mid
    else:
        ng = mid

print(ok)
# Judge status: Accepted
s = list(input())

ans = ''
for i in s:
    if i == '0':
        ans += '0'
    elif i == '1':
        ans += '1'
    elif ans != '':
        ans = ans[:len(ans) - 1]

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

L.sort()
print("Yes" if sum(L[:-1]) > L[-1] else "No")
# Judge status: Accepted
#!python3

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


def main():
    if N == 100:
        ans = 100 ** (D + 1) + 100 ** D
    else:
        ans = str(N) + "00" * D
    print(ans)


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

A = []
for i in range(N):
    a = int(input())
    A.append([a, i])
    
A_ = sorted(A, reverse=True)

#print(A_)

for i in range(N):
    if A_[0][1] == i:
        print(A_[1][0])
    else:
        print(A_[0][0])
# Judge status: Wrong Answer
n = int(input())
a = sorted(map(int, input().split())) + [0]
print(sum(map(lambda a, b: abs(a + b), a[::2], a[1::2])))
# Judge status: Accepted
N,A,B,C,D=[int(c) for c in input().split()]
S=input()
print("Yes" if ("##" not in S[A-1:C-1]) and ('##' not in S[B-1:D-1]) and (C<D or ("..." in S[B-2:D+1])) else "No")
# Judge status: Accepted
thp,tat,ahp,aat = map(int,input().split())
while True:
    ahp -= tat
    if ahp <= 0:
        print("Yes")
        break
    thp -= aat
    if thp <= 0:
        print("No")
        break
# Judge status: Wrong Answer
r, g, b, = map(int, input().split())

if (r * 100 + g * 10 + b) % 4 == 0:
    print('YES')
else:
    print('No')
# Judge status: Accepted
def main():
    X,N = map(int, input().split())
    l = [int(x) for x in input().split()]
    
    ans=0
    if N == 0:
        ans = X
    
    for i in range(100000):
        if not (X-i in l):
            ans=X-i
            break
        elif not(X+i in l):
            ans=X+i
            break
    print(ans)
main()
# Judge status: Accepted
h,a=map(int, input().split())
n=(h-1)//a+1
print(n)
# Judge status: Accepted
s = input()
if s[0]!='A' or s[2:-1].count('C')!= 1:
  print('WA')
  exit()
  
for c in s[1:]:
  if not(('a'<= c <= 'z') or  c=='C'):
    print('WA')
    break
else:
  print('AC')
# Judge status: Accepted
a, b = map(int, input().split())
if a == 1 and b == 1:
    print('Draw')
else:
    if a == 1:
        print('Alice')
    elif b == 1:
        print('Bob')
    else:
        if a == b:
            print('Draw')
        elif a < b:
            print('Bob')
        else:
            print('Alice')