peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
#52 1日かかった
N = int(input())
b = list(map(int,input().split()))
a = [min(b) for i in range(N)]

for i in range(N-1):
    while b[i] > max(a[i],a[i+1]): 
        a[i+1] += 1
    while b[i] < max(a[i],a[i+1]):
        a[i] -= 1
    if i <= N-3:
        if b[i] == b[i+1]:
            a[i+2] = a[i+1] = a[i]
            

print(sum(a))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = 0
if 1 not in a:
    ans = -1
else:
    for i in range(1,n+1):
        if i not in a:
            break
        else:
            rn = a.index(i)
            ans+= rn
            del a[:rn+1]
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
X=sorted(map(int,input().split()))
L=sorted([X[i+1]-X[i] for i in range(m-1)])
if n>=m:
    print(0)
else:
    print(sum(L)-sum([L[-i-1] for i in range(n-1)]))
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()

M = (10**9)+7
n = int(input())
As = map(int, input().split(" "))

cumsum = []
cur = 0
out = 0
for i in range(n-1):
    cur += As[i]
    out += cur*As[i+1] 
    out = out % M
print(out)
# Judge status: Accepted
s = input()

if s=="a" or s=="o" or s=="u" or s=="e" or s=="i":
  print("vowel")
  
else:
  print("consonant")
# Judge status: Accepted
l = list(input().split())
d = {}
for i in l:
    if i in d:
        d[i] +=1
    else:
        d.setdefault(i,1)
print(len(d))
# Judge status: Accepted
coin = [1,
6,6**2,6**3,6**4,6**5,6**6,
9,9**2,9**3,9**4,9**5]
n = int(input())
inf = 10**9
dp = [inf]*(n+1)
dp[0] = 0
for c in coin:
    for yen in range(c, n+1):
        dp[yen] = min(dp[yen], dp[yen-c] + 1)
print(dp[n])
# Judge status: Accepted
x, y = map(int, input().split())

for a in range(101):
    for b in range(101):
        if a+b==x and 2*a+4*b==y:
            print("Yes")
            exit()
else:
    print("No")
# Judge status: Accepted
from sys import stdin
n = int(input())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
c = list(map(int, stdin.readline().split()))
ans = sum(b)
for i in range (n-1):
    if a[i]+1 == a[i+1]:
        t = a[i]-1
        ans +=c[t]
print(ans)
# Judge status: Wrong Answer
S=input()
res=0
for st in [S[x:y] for x in range(len(S)) for y in range(len(S)) if x<=y]:
    for c in st:
        if not c in ('A','C','G','T'):
            break
    else:
        if res<len(st):
            res=len(st)
print(res)
# Judge status: Wrong Answer
def solve():
  n, m = map(int, input().split())
  if m//2 <= n:
    print(m//2)
  else:
    print("ばーか")
  return 0
 
if __name__ == "__main__":
  solve()
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())
cnt=wcnt=hcnt=0

while N>0:
    a = max(H-hcnt, W-wcnt)
    N -= a
    cnt+=1
    if a==W:
        H-=1
        hcnt+=1
    elif a==H:
        W-=1
        wcnt+=1
print(cnt)
# Judge status: Accepted
n, k = map(int, input().split())
x = list(map(int, input().split()))
k -= 1
ans = 10**9

for i in range(n - k):
    l = x[i]
    r = x[i + k]
    if l < 0:
        if r < 0:
            ref = -l
        else:
            ref = min(l*-2 + r, -l + r*2)
    else:
        ref = r
    ans = min(ans, ref)

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


def prime_numbers(N):
    n = N
    res = []
    for i in range(2, n):
        if i * i >= N: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.append(i)
    res.append(N)
    return res


a = prime_numbers(A)
b = prime_numbers(B)
ans = min(len(a), len(b)) + 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
if N // 9 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = list(map(int, input().split()))
a.sort()
cnt = 0
while max(a)-min(a)>1:
    a[0] += 2
    a.sort()
    cnt += 1
if a[0]==a[1]==a[2]:
    print(cnt)
elif a[0]==a[1]:
    print(cnt+1)
else:
    print(cnt+2)
# Judge status: Accepted
n = int(input())
ans = ['' for _ in range(n)]

def dfs(i, mx):
    if i == n:
        print(''.join(ans))
        return
    for j in range(mx+1):
        ans[i] = chr(ord('a') + j)
        dfs(i+1, max(j+1, mx))

dfs(0, 0)
# Judge status: Accepted
a = list(map(int,input().split()))
if (a.count(5) == 2) and (a.count(7) == 1):
  print("YES")
else:
  print("NO")
# Judge status: Accepted
s=list(map(int,input().split()))
a=s[0]*500
if s[1]<=a:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
from itertools import count

a, b, c, d = map(int, input().split())

for i in count():
    if i % 2 == 0:
        c -= b
        if c <= 0:
            print('Yes')
            break
    else:
        a -= d
        if a <= 0:
            print('No')
            break
# Judge status: Wrong Answer
import collections

s =  input()
lst = []
for i in s:
    lst.append(i)
c = collections.Counter(lst)
if sum(c.values()) % 2 == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
from math import ceil
n, k = map(int, input().split())
h_array = sorted([int(x) for x in input().split()])
if k >= n:
    print(0)
    exit()
print(sum(h_array[:n-k]))
# Judge status: Accepted
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print("Bad")
else:
  print("Good")
# Judge status: Accepted
print("red" if int(input())<3200 else input())
# Judge status: Wrong Answer
s = str(input().replace('\n', ''))
t = str(input().replace('\n', ''))
s, t = s[::-1], t[::-1]
tt = len(t)-1
ss = '?'*tt + t[-1]
flag = True
ans = ''
for i in s:
    ans += i
    if ss in ans and flag:
        flag=False
        ans = ans.replace(ss, t)
print(ans.replace('?', 'a')[::-1] if flag==False else 'UNRESTORABLE')
# Judge status: Accepted
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    N = int(readline())
    L = [0]*(N+1)
    L[0]=2
    L[1]=1
    for i in range(2,N+1):
        L[i] = L[i-1] + L[i-2]
    print(L[N])




if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b=map(int,input().split())
print(a+b if a+b < 24 else a+b-24)
# Judge status: Wrong Answer
# Nとcの定義
N = int(input())
C = input()

# 赤色の個数
red_num = str.count(C, "R")

# 左からred_num個までに含まれる白色の個数
white_num_left = str.count(C[:red_num], "W")

# 最小の操作回数
min_ope = white_num_left

# 最小の操作回数の出力
print("最小の操作回数: " + str(min_ope))
# Judge status: Accepted
import sys
a=sys.stdin.buffer.read
K,N,*A=map(int,a().split())
A+=[A[0]+K]
print(K-max(y-x for x,y in zip(A,A[1:])))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
odd = 0
even = 0
eveneven = 0
for a in A:
    if a % 4 == 0:
        eveneven += 1
    elif a % 2 == 0:
        even += 1
    else:
        odd += 1
        
if even == 0:
    #間に挟み込む
    if eveneven +1 >= odd:
        print('Yes')
    else:
        print('No')
else:
    #２を後ろに固める
    if odd <= eveneven:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,41)):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  l[0]=min(s[0],n)
  for i in range(1,n):
    l[i]=min(l[i-1]+s[i],n)
print(*l)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
num_A = [0]*(N+1)
for a in A:
  num_A[a]+=1

s=0
for n in num_A:
  s+=n*(n-1)//2
#print(s)
for a in A:
  ans = s - (num_A[a]*(num_A[a]-1)//2) + ((num_A[a]-1)*(num_A[a]-2)//2)
  print(ans)
# Judge status: Accepted
n, a = input(), map(int, raw_input().split())
mi = n + 1
ans = 0
for i, x in enumerate(a):
    if mi > x:
        ans += 1
    mi = min(mi, x)
print ans
# Judge status: Accepted
s=input()
if s[-1]=='s': print(s+'es')
else: print(s+'s')
# Judge status: Wrong Answer
age, price = map(int, input().split())

price = price if age >= 13 else price / 2 if 6 <= age <= 12 else 0

print(price)
# Judge status: Wrong Answer
a = input()
count = 0
for i in range(int(a)):
    if i % 3 == 0 and i % 5 == 0:
        #print('FizzBuzz')
        count += 0
    elif i % 3 == 0:
        #print('Fizz')
        count += 0
    elif i % 5 == 0:
        #print('Buzz')
        count += 0
    else:
        count += i
        #print(i)

print(count)
# Judge status: Accepted
N=int(input())
A=[0]*N
B=[0]*N
x,y=0,0
for i in range(N):
  x,y=map(int,input().split())
  A[i]=x
  B[i]=y
A.sort()
B.sort()
if N&1:
  print(B[N//2]-A[N//2]+1)
else:
  print(B[N//2]+B[N//2-1]-A[N//2]-A[N//2-1]+1)
# Judge status: Wrong Answer
a,b=map(int,input().split())
print((a+b-1)%24 +1)
# Judge status: Accepted
s=''
for i in input():
    if i=='B':
        if s!='':
            s=s[:-1]
    else:
        s+=i
    #print(s)
print(s)
# Judge status: Accepted
N = int(input())

ans = "No"
for i in range(9):
	if (N % (i+1) == 0) & ( N / (i+1) <= 9):
		ans = "Yes"
		break
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
ans=0
for i in range(a,b+1):
    if str(i)==str(i)[::-1]:
        ans+=1
print(ans)
# Judge status: Accepted
n = int(input())
c = 0
for i in range(1, n + 1):
    if i%2 != 0:
        c+=1
print(c/n)
# Judge status: Accepted

n = int(input())
dp = [10**9]*(n+1)
L = [6**i for i in range(1,7)]
L += [9**i for i in range(1,6)]

dp[0] = 0

for i in range(1,n+1):
    dp[i] = dp[i-1]+1
    k = 6
    while i-k >=0:
        dp[i] = min(dp[i],dp[i-k]+1)
        k *=6
    k = 9
    while i-k >=0:
        dp[i] = min(dp[i],dp[i-k]+1)
        k *=9
    #print(dp)
print(dp[n])
# Judge status: Accepted
N = int(input())
t = int(N / 1.08)
while True:
    if int(t*1.08) == N:
        print(t)
        break
    if int(t*1.08) > N:
        print(":(")
        break
    t += 1
# Judge status: Accepted
a, b, c = list(map(int, input().split()))
print(c,a,b)
# Judge status: Accepted
n = int(input())
c = input()
c = list(c)
r = 0
w = 0
for i in range(n):
    if c[i] == 'R':
        r += 1
    else:
        w += 1
ans = min(r,w)
t = 0
v = 0
for i in range(ans):
    if c[i] == 'R':
        t -= 1
for i in range(ans):
    if c[n-i-1] == 'W':
        v -= 1
if r <= w:
    ans = ans + t
else:
    ans = ans + v
print(ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
al = list(map(int, input().split()))

cnt = [0]*9
for i in range(1,10):
    cnt[i-1] = al.count(i)
cnt.sort()
cnt = cnt[cnt.count(0):]

print(sum(cnt[:-k]))
# Judge status: Accepted
from math import atan,degrees
a,b,x = map(int,input().split())

if x >= a**2*b/2:  # けっっこうおおめ
    print(degrees(atan(2*(a**2*b-x)/a**3) ))
elif x < a**2*b/2:  # すっくねえ
    print(degrees(atan(b**2*a/(2*x))))
# Judge status: Wrong Answer
n = int(input())
List = []
List2 = []
for i in range(n):
  List.append(input())
  S1 = sorted(List[0])
for j in range(1,n):
  for k in range(len(S1)):
    if List[j].count(S1[k]) == 0:
        List2.append(S1[k])
List2 = (List2)
List2 = set(List2)
List2 = list(List2)
for k in range(len(List2)):
    S1.remove(List2[k])
Answer = "".join(map(str,S1))
print(Answer)
# Judge status: Accepted
N = int(input())
ans = 0
a = - (1 << 100)
X = []
for _ in range(N):
    x, l = map(int, input().split())
    X.append((x, l))
X = sorted(X)
for x, l in X:
    if a > x - l:
        a = min(a, x + l)
    else:
        a = x + l
        ans += 1
print(ans)
# Judge status: Accepted
S = input()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')
# Judge status: Wrong Answer
n, k = map(int, input().split())

def calc(n, k):
  i = 1
  tmp = n
  while (tmp > k):
    tmp = tmp - k**i
    i += 1
    return i

print(str(calc(n,k)))
# Judge status: Accepted
s = input()
k = int(input())
ans = ""
l = 26
for i in range(len(s)-1):
    if l - ord(s[i]) + 97 <= k and s[i] != "a":
        k -= l - ord(s[i]) + 97
        ans += "a"
    else:
        ans += s[i]
ans += (chr(((ord(s[-1]) - 97) + k + l) % l + 97))
print(ans)
# Judge status: Wrong Answer
N = int(input())

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

if N == 1:
    print(1)
    exit()
    
A.sort()

current_number = A[0]
current_count = 1
count = 0

for i in range(1,N):
    if current_number == A[i]:
        current_count += 1
    else:
        current_number = A[i]
        if current_count % 2 != 0:
            count += 1
        current_count = 0

print(count)
# Judge status: Accepted
L = [2, 1]
for i in range(85):
	L.append(L[-1] + L[-2])
print(L[int(input())])
# Judge status: Wrong Answer
n=int(input())
cnt = 0
for i in range(1,n+1):
  if len(str(n))%2 == 1:
    cnt+=1
    
print(cnt)
# Judge status: Wrong Answer
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
ans=sum(b)
pre=0
for i in range(n):
    tabeta=a[i]
    if tabeta==pre+1:
        ans+=c[pre-1]
    pre=tabeta
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**7)
mo=10**9+7
def fact(x):
  if x==0:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)
# Judge status: Accepted
stng = input()
mindif = 9999999999
for i in range(len(stng)-2):
  mindif = min(mindif,abs(int(stng[i:i+3])-753))
print(mindif)
# Judge status: Wrong Answer
k = int(input())
s = input()
print(s if len(s)<k else s[:7]+'...')
# Judge status: Wrong Answer
n = int(input())
ls = [int(input()) for _ in range(5)]
k = n/min(ls)
if k % 1 != 0:
    k = int(k) + 1
print(k+4)
# Judge status: Accepted
from fractions import gcd


def solve():
    N, X, *x = map(int, open(0).read().split())
    
    d = [abs(X - xi) for xi in x]
    ans = d[0]
    for di in d[1:]:
        ans = gcd(ans, di)
    print(ans)


if __name__ == '__main__':
    solve()
# Judge status: Accepted
s=input()
t=input()
ans=[]
for i in range(len(s)-len(t)+1):
  cnt=0
  for j in range(len(t)):
    if (s[i+j]==t[j]) or (s[i+j]=='?'):
      if j==len(t)-1:
        ss=s[:i]+t+s[i+j+1:]
        if ss.count('?')>0:
          ss=ss.replace('?','a')
        ans.append(ss)
      else:
        pass
    else:
      break
if ans!=[]:
  print(min(ans))
else:
  print('UNRESTORABLE')
# Judge status: Wrong Answer
N = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
ans = 0
for i in range(N):
    d[a[i]] += 1
for i in range(1,1001):
    if d[i] == 1:
        ans += 1
        for j in range(2,2+10**6//i):
            d[j*i] = 0
    elif d[i] >= 2:
        for j in range(2,2+10**6//i):
            d[j*i] = 0
for i in range(1001,1000001):
    if d[i] >= 1:
        ans += 1
print(ans)
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
import random
D = int(input())
c = [int(x) for x in input().split()]
s = []
for _ in range(D):
    s.append([int(x) for x in input().split()])
t = [random.randint(1, 26) for x in range(D)]
last = [0]*26
ans = 0
for i in range(1, D + 1):
    ans += s[i - 1][t[i - 1] - 1]
    last[t[i - 1] - 1] = i
    for j in range(26):
        ans -= c[j]*(i - last[j])
    print(ans)
# Judge status: Accepted
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b,c,k = map(int,input().split())
if k%2 == 0:
    print(a-b)
elif k%2 == 1:
    print(b-a)
elif abs(a-b)>10**18:
    print("Unfair")
# Judge status: Accepted
from fractions import gcd
a,b,c,d = map(int, input().split())
ci = b//c - (a-1)//c
di = b//d - (a-1)//d
e = c * d // gcd(c, d)
cdi = b//e - (a-1)//e
print(b-(a-1)-(ci+di-cdi))
# Judge status: Accepted
X,Y,A,B,C =map(int,input().split())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
R = list(map(int,input().split()))

P.sort()
Q.sort()
R.sort()

P_new = P[-X::]
Q_new = Q[-Y::]


agg = P_new + Q_new +R
agg.sort()
print(sum(agg[-X-Y::]))
# Judge status: Wrong Answer
a,b=map(int, input().split());print((a+b)//24)
# Judge status: Accepted
a,b,c = map(int,input().split())

if c-a-b>0 and 4*a*b<(c-a-b)**2:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
def main():
    from operator import itemgetter
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    AB.sort(key=itemgetter(1))

    now = 0
    for a, b in AB:
        if now + a <= b:
            now += a
        else:
            print("No")
            return
    print("Yes")

main()
# Judge status: Wrong Answer
a,b = map(int, raw_input().split())
s = raw_input()
def f(s):
	for l in s:
		if l not in map(str, range(10)): return False
	return True
print 'Yes' if s[a] == '-' and f(s[a+1:]) else 'No'
# Judge status: Accepted
N,K=map(int,input().split())
p=list(map(int,input().split()))
print(sum(sorted(p)[:K]))
# Judge status: Accepted
a,b,c=map(int,input().split())
x=a**2 + b**2 + c**2 - 2*a*b - 2*a*c - 2*b*c
if x>0 and a+b-c<0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
ans = 0
for i in range(2, int(N**0.5 + 1)):
    f = 1
    while True:
        if N % i**f:
            f -= 1
            break
        f += 1
        N //= i**f
    ans += f
print(ans)
# Judge status: Accepted
import math
X=int(input())
ans=0
if X==1:
	print(1)
else:
	for i in range(1,X//2):
		for j in range(2,11):
			tmp=i**j
			if tmp<=X:
				ans=max(ans,tmp)
	print(ans)
# Judge status: Wrong Answer
x = int(input())

if x % 11 <= 6:
    print((x // 11) * 2 + 1)
else:
    print((x // 11) * 2 + 2)
# Judge status: Accepted
def main():
    s = input()

    good = 'keyence'

    for start in range(len(s)):
        for end in range(len(s)):
            if s.replace(s[start:end],'',1) == good:
                print('YES')
                exit()

    print('NO')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n,T = list(map(int,input().split()))
ans = 10000
for i in range(n):
  c,t = map(int,input().split())
  if(t<=T):
    ans=min(ans,c)
  else:
    None
print(ans)
# Judge status: Wrong Answer
n=int(input())
s=list(input())
for i in s:
  ord_= ord("A")
  t_ord = (ord_ +n) % 26
  i = chr(t_ord)
print(''.join(s))
# Judge status: Wrong Answer
import bisect

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

ans = 0
for b in B:
    top = bisect.bisect_right(A, b)
    bottom = N - bisect.bisect_left(C, b)
    ans += top * bottom

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

#累積和
for _ in range(K):
    B = [0]*N
    for i in range(N):
        l = max(0,i-A[i])
        r = min(N-1, i+A[i])
        B[l] += 1
        if r+1 < N: B[r+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    B,A = A,B
    if min(A) == N:
        break
print(*A)
# Judge status: Accepted
a = input()
if a.islower():
    print('a')
else:
    print('A')
# Judge status: Accepted
x, y = map(int, input().split())
grp1 = [1,3,5,7,8,10,12]
grp2 = [4,6,9,11]
grp3 = [2]

if x in grp1 and y in grp1:
    print('Yes')
elif x in grp2 and y in grp2:
    print('Yes')
elif x in grp3 and y in grp3:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N, W = map(int, input().split())
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    w, v = map(int, input().split())
    for j in range(1, W+1):
        if j<w:
            dp[i+1][j] = dp[i][j]
        if w<=j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)
print(dp[-1][-1])
# Judge status: Accepted
N = int(input().strip())

ans = ''
while N > 0:
    ans = chr(ord('a') + (N-1) % 26) + ans
    N = (N -1) // 26

print(ans)
# Judge status: Accepted
N, K, S = map(int, input().split())
X = [S] * K
if S != 10 ** 9:
    Y = [10 ** 9] * (N - K)
else:
    Y = [S - 1] * (N - K)
Z = X+Y

print(*Z, sep=" ")
# Judge status: Accepted
L,R=map(int,input().split())
mod=2019
ans=2018
if R-L>=mod:
    print(0)
else:
    R%=mod
    L%=mod
    if R<=L:
        R+=mod
    for i in range(L+1,R+1):
        for j in range(L,i):
            ans=min(ans,i*j%mod)
    print(ans)
# Judge status: Wrong Answer
from collections import deque

X = int(input())
N = 10**5+4
N_sq=N**(1/2)

check = deque(range(2,N+1))
search = deque([])

for n in range(N):
    if len(check)<=0:
        break
        
    c = check.popleft()
    search.append(c)

    check = deque([ _ for _ in check if _%c != 0])
    
    if c > N_sq:
        search.extend(check)
        break
        
for s in search:
    if X < s:
        print(s)
        break
# Judge status: Accepted
N=input()
A=input()

N=int(N)
A=int(A)

if N%500<=A:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
from sys import stdin
from itertools import groupby

s = list(stdin.readline().rstrip())
s.sort()
li = []
for key, value in groupby(s):
    li.append(len(list(value)))
if len(li) == 1:
    li += [0]*2
elif len(li) == 2:
    li += [0]
if sum(abs(li[i+1]-li[i]) for i in range(len(li)-1)) <= 2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
from math import atan


def find_angle(width, height, vol):
    area = vol/width
    if area > 1/2 * width * height:
        return atan(2*(width * height - area)/(width**2))
    else:
        return atan(height**2/(2*area))


a, b, x = [int(i) for i in input().split()]
print(find_angle(a, b, x) / (2*3.1415926535) * 360)
# Judge status: Accepted
h, w = map(int, input().split())
if w == 1 or h == 1:
	print(1)
else:
	print(((h + 1) // 2) * ((w + 1) // 2) + (h // 2) * (w // 2))
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = [ list(input()) for _ in range(n) ]
b = [ list(input()) for _ in range(m) ]

is_ok = False
for dx in range(n-m):
    for dy in range(n-m):
        f = True
        for y in range(m):
            for x in range(m):
                if a[y+dy][x+dx] != b[y][x]:
                    f = False

        is_ok = f

print("Yes" if is_ok else "No")
# Judge status: Accepted
N,A,B=map(int, input().split())
S=input()
cntA=0
cntB=0
for s in S:
  if s == 'c':
    print('No')
    continue
  if s == 'a' and (cntA+cntB) < A+B:
    print('Yes')
    cntA +=1
  elif (s == 'b') and ((cntA+cntB) < A+B) and (cntB < B):
    print('Yes')
    cntB +=1
  else:
    print('No')
# Judge status: Accepted
d,n = map(int, input().split())
if n == 100:
    n = 101
print((100**d)*n)
# Judge status: Accepted
N = int(input())
print((N - 1) * N // 2)
# Judge status: Wrong Answer
from collections import deque

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

tree=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

dist=[-1 for i in range(n)]
dist[0]=0

dq=deque()
dq.append(0)

while dq:
  x=dq.popleft()

  if x==n-1:
    if dist[x]==2:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')
    exit()

  for i in tree[x]:
    if dist[i]==-1:
      dist[i]=dist[x]+1
      dq.append(i)
# Judge status: Wrong Answer
n, m = map(int, input().split())
left, right = 1, n
for _ in range(m):
  l, r = map(int, input().split())
  if l > left:
    left = l
  if r < right:
    right = r
  if l > r:
    print(0)
    quit()
print(right - left + 1)
# Judge status: Wrong Answer
s=input()
if s=="SAT":
    print(1)
if s=="SUN":
    print(7)
if s=="MON":
    print(6)
if s=="TUE":
    print(5)
if s=="WED":
    print(4)
if s=="THU":
    print(3)
if s=="FRY":
    print(2)
# Judge status: Wrong Answer
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

n,p = map(int,input().split())
a = list(map(lambda x:int(x)%2,input().split()))
cnt0 = a.count(0)
cnt1 = n-cnt0
ans = 2**cnt0
temp=0
for i in range(p,cnt1+1,2):
    temp += cmb(n,i)
print(ans*temp)
# Judge status: Accepted
N = int(input().strip())
s = 0
for i in range(1,N+1):
    if i%3 and i%5:
        s+=i
print(s)
# Judge status: Accepted
# coding: utf-8


def main():
    operand_a, operand_b = map(int, input().split(' '))

    if operand_a < 10 and operand_b < 10:
        print(operand_a * operand_b)
    else:
        print(-1)

    return 0


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
S = input()
max = 0
i = 0
m = 0
while(i != len(S)):
  if S[i] == "R":
    m += 1
  
  else:
    max = m
    m = 0
    break
  i += 1

print(max)