peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import math
N, X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
x.append(X)
x.sort()

xdst = [x[i+1] - x[i] for i in range(N)]
print(xdst)

ans = 10**10
if len(xdst) == 1:
    #print(xdst[0])
    exit()

for i in range(N-1):
    ans = min(math.gcd(xdst[i], xdst[i+1]),ans)
print(ans)
# Judge status: Accepted
from itertools import accumulate
N,K = map(int,input().split())
P = [(int(i) + 1) / 2 for i in input().split()]
ans = []
hope = [0] + list(accumulate(P))

for j in range(N-K+1):
  ans.append(hope[j+K]-hope[j])
print(max(ans))
# Judge status: Accepted
n = int(input())
n2 = int(n**0.5//1)

def div(n,p):
    cnt = 0
    a = 1
    while n%p == 0:
        n = n//p
        cnt += 1
        if cnt == a:
            cnt = 0
            a += 1
    return [n,a-1]

ans = 0
for z in range(2,n2):
    if n%z == 0:
        n,cur = div(n,z)
        ans += cur

if n != 1: ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))
ans = 1000000
for p in range(1,101):
  d = 0
  for x in l:
    d += (x-p)**2
  ans = min(d,ans)
print(ans)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heapify, heappop, heappush 
def main():
    N, M = map(int, readline().split())
    A = [-int(i) for i in readline().split()]
    heapify(A)
    for _ in range(M):
        v = -heappop(A)
        heappush(A, -(v//2))
    print(sum([-i for i in A]))
if __name__ == '__main__':
    main()
# Judge status: Accepted
alphabet='abcdefghijklmnopqrstuvwxyz'
S=input()
ans="None"
for a in alphabet:
    if S.count(a)==0:
        ans=a
        break
print(ans)
# Judge status: Wrong Answer
n = int(input())
h = []
for _ in range(n):
    a,b,c = map(int,input().split())
    h.append([a,b,c])
dp=[[0 for i in range(3)] for j in range(n)]
dp[0] = h[0]
for i in range(1,n):
    for j in range(3):
        dp[i][j]=dp[i-1][j]+max(h[i][(j+1)%3],h[i][(j+2)%3])
print(max(dp[-1]))
# Judge status: Accepted
a,b,c,d=input()
for i in range(2**3):
    op=["-","-","-"]
    for j in range(3):
        if (i>>j&1):
            op[j]="+"
    if eval(a+op[0]+b+op[1]+c+op[2]+d)==7:
        print(a+op[0]+b+op[1]+c+op[2]+d+"=7")
        exit()
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
x = e - a
if x < k:
  print('Yey!')
else:
  print(':(')
# Judge status: Accepted
# -*- coding: utf-8 -*-
n, x, y = map(int, input().split())
count = [0]*(n-1)

for i in range(1, n+1):
    for j in range(i+1, n+1):
        dist = min(j-i, abs(x-i) + 1 + abs(y-j))
        count[dist-1] += 1

for ci in count:
    print(ci)
# Judge status: Accepted
N=int(input())
S=input()
b=[None]*(N+1)
b[0]=0
w=[None]*(N+1)
w[N]=0
for i in range(1,N+1):
    b[i]=b[i-1]+(S[i-1]=='#')
for i in range(N-1,-1,-1):
    w[i]=w[i+1]+(S[i]=='.')
print(min([x+y for x,y in zip(b,w)]))
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
cnt=0
if a==b==c:
  print(-1)
  exit()
while a%2==b%2==c%2==0:
  a,b,c=(b+c)//2,(a+c)//2,(a+b)//2
  cnt+=1
print(cnt)
# Judge status: Accepted
A,B=map(int,input().split(" "))

K=(A+B)/2
print(int(K) if int(K)==K else "IMPOSSIBLE")
# Judge status: Accepted
N,*aa = map(int, open(0).read().split())

ans = [None]*(N//2) + aa[N//2:]

for i in range(N//2,0,-1):
    ans[i-1] = (sum(ans[2*i-1::i])%2)^aa[i-1]

p = sum(ans)
print(p)
if p:
    print(*(i+1 for i,v in enumerate(ans) if v))
# Judge status: Accepted
a, b, m = map(int,input().split())
ai = list(map(int,input().split()))
bi = list(map(int,input().split()))

ans = min(ai)+min(bi)
for k in range(m):
    ak, bk, mk = map(int,input().split())
    ansk = ai[ak-1]+bi[bk-1]-mk
    if ansk<ans:
        ans = ansk
print(ans)
# Judge status: Accepted
import heapq
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = 0
heap = []
heapq.heappush(heap, -a[0])
for i in range(1, n):
    tmp = heapq.heappop(heap)
    tmp *= -1
    ans += tmp
    heapq.heappush(heap, -a[i])
    heapq.heappush(heap, -a[i])
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
s = str(input())
ans = ''
if s[k-1] == 'A':
    ans = s[:k-1] + 'a' + s[k:]
    print(ans)
    exit()
elif s[k-1] == 'B':
    ans = s[:k-1] + 'b' + s[k:]
    print(ans)
    exit()
elif s[k-1] == 'C':
    ans = s[:k-1] + 'c' + s[k:]
    print(ans)
    exit()
# Judge status: Accepted
from sys import stdin

s = stdin.readline().rstrip()
N = len(s)

dp = [0]*N
dp[0] = 1
if s[0] == s[1]:
    dp[1] = 1
else:
    dp[1] = 2
for i in range(2,N):
    if s[i] == s[i-1]:
        dp[i] = dp[i-3] + 2
    else:
        dp[i] = dp[i-1] + 1

print(dp[N-1])
# Judge status: Accepted
count = int(input())

strlist = set()
for i in range(count):
  strlist.add(input())

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

r = [False] * n
r[0] = True
l = [1] * n

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    l[x] -= 1
    l[y] += 1
    r[y] = r[x] | r[y]
    if not l[x]:
        r[x] = False

c = 0
for i in range(n):
    if r[i] == True and l[i] > 0:
        c += 1

print(c)
# Judge status: Wrong Answer
import itertools
N = int(input())

ans = []
while N !=0:
    ans.append(N%2)
    N = -(N-N%2)//2
print("".join(list(map(str,ans))))
# Judge status: Accepted
import math
n=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
	if i%n==0:
		print("OK")
		exit()
print("NG")
# Judge status: Wrong Answer
a,b=map(int,input().split())
print(["P","Imp"][a%3==b%3 and a%3==1 or a%3==2]+"ossible")
# Judge status: Accepted
N, M = map(int, input().split())
ab=[]
for _ in range(M):
    ab.append(tuple(map(int, input().split())))
#print(ab)

from_1=set([el[1] for el in ab if el[0]==1])
from_N=set([el[0] for el in ab if el[1]==N])
#print(from_1, from_N)
if from_1 & from_N:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Judge status: Accepted
import sys
input = sys.stdin.readline

N, H = map(int, input().split())
a_max = 0
b = []

for _ in range(N):
    ai, bi = map(int, input().split())
    a_max = max(a_max, ai)
    b.append(bi)

b.sort(reverse=True)
ans = 0

for bi in b:
    if a_max>bi:
        break
    
    H -= bi
    ans += 1
    
    if H<=0:
        print(ans)
        exit()

ans += (H+a_max-1)//a_max

print(ans)
# Judge status: Accepted
S = input()
a = 'dream'
b = 'dreamer'
c = 'erase'
d = 'eraser'
T = S
while len(T) > 4:
    if S[len(T)-5:len(T)] == a:
        T = T[0:len(T)-5]
    elif S[len(T)-7:len(T)] == b:
        T = T[0:len(T)-7]
    elif S[len(T)-5:len(T)] == c:
        T = T[0:len(T)-5]
    elif S[len(T)-6:len(T)] == d:
        T = T[0:len(T)-6]
    else:
        break
if T == '':
    print('YES')
else:
    print('NO')
# Judge status: Accepted
w = input()
for i in w:
    if w.count(i) %2 != 0:
        print("No")
        break
else:
    print("Yes")
# Judge status: Accepted
import sys
input = sys.stdin.readline

mod = 10**9+7
n, m = map(int, input().split())
l = [0]*n
for _ in range(m):
  l[int(input())-1] = 1

t, s = 1, 0

for i in range(n):
  if l[i]:
    t, s = 0, t
  else:
    t, s = (s+t)%mod, t

print(t)
# Judge status: Accepted
N = int(input())

c = 0

for n in range(1, N+1):
    if n % 3 != 0 and n % 5 != 0:
        c += n

print(c)
# Judge status: Wrong Answer
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

INF = 10**9+7

if __name__ == "__main__":
    k = int(input())
    if k%2 == 0:
        print(-1)
        sys.exit()
    a = 7
    p = len(str(k)) + 1
    for i in range(p):
        if a%k == 0:
            print(i+1)
            sys.exit()
        a*=10
        a+=7
    print(k-1)
# Judge status: Accepted
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
ac = sorted([(i, v) for i, v in Counter(A).items() if v >= 2], reverse=True)
s = []
for k, v in ac:
  for _ in range(v//2):
    s.append(k)
  if len(s) >= 2:
    break
if len(s) >= 2:
  print(s[0]*s[1])
else:
  print(0)
# Judge status: Accepted
a,b,c=sorted(map(int,input().split()))
#print(a,b,c)
cnt=0
if a%2==b%2==c%2:
    cnt=0
elif a%2==b%2:
    cnt+=1
    a+=1
    b+=1
elif b%2==c%2:
    cnt+=1
    b+=1
    c+=1
elif a%2==c%2:
    cnt+=1
    a+=1
    c+=1
#print(cnt,a,b,c)
cnt+=(c-a)//2+(c-b)//2
print(cnt)
# Judge status: Accepted
a,b,c = input().split()
if int(a) + int(b) + int(c) >= 22:
    print('bust')
else:
    print('win')
# Judge status: Accepted
from collections import Counter

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

counter = Counter(a)

for i in range(n):
    print(counter[i+1])
# Judge status: Accepted
x, k, d = map(int, input().split())

if x < 0:
    flag = -1
else:
    flag = 1

if abs(x) >= k * d:
    ans = x - k * d * flag
else:
    k -= abs(x) // d
    x = abs(x) % d * flag
    ans = x if k % 2 == 0 else x - d * flag

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

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

res = 0
for k, v in d.items():
    if k > v:
        res += v
    else:
        res += v - k
print(res)
# Judge status: Accepted
from fractions import gcd

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

div_c = b//c - a//c
if a%c == 0: div_c += 1
div_d = b//d - a//d
if a%d == 0: div_d += 1
lcm_cd = c*d//gcd(c, d)
div_cd = b//lcm_cd - a//lcm_cd
if a%lcm_cd == 0: div_cd += 1
print(b - a + 1 - div_c - div_d + div_cd)
# Judge status: Accepted
s = input()
print("yes" if len(s) == len(list(set(s))) else "no")
# Judge status: Accepted
def main():
    N, L = map(int, input().split())
    word_list = list()

    for i in range(N):
        word_list.append(input())
    
    word_list.sort()

    print("".join(word_list))
main()
# Judge status: Accepted
N=int(input())

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

a.sort()
c=1
ans=0
for i in range(N-1):
    if a[i]==a[i+1]:
        c+=1
        if c>a[i]:
            ans+=1
    else:
        if c<a[i]:
            ans+=c
            c=1
        else:
            c=1
if c<a[N-1]:
    ans+=c

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

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

ans = [0] * N
for i in range(N):
    ans[i] = tmp ^ A[i]

print (*ans)
# Judge status: Accepted
s = input()
n = len(s)
c = 0
for i in range(n // 2):
    if s[i] != s[-i -1]:
        c = c + 1
print(c)
# Judge status: Accepted
s = input()
t = input()
ls = sorted(list(s))
lt = sorted(list(t),reverse=True)
os = [ord(x) for x in ls]
ot = [ord(x) for x in lt]
for i in range(min(len(s),len(t))):
	if os[i] < ot[i]:
		print('Yes')
		break
	elif os[i] > ot[i]:
		print('No')
		break
else:
	if len(s) < len(t):
		print('Yes')
	else:
		print('No')
# Judge status: Wrong Answer
a, b = map(int, input().split())
print(min(a, b))
# Judge status: Accepted
n = int(input())
lucas = [2, 1] + [0] * (n - 1)
for i in range(2, n + 1):
  lucas[i] = lucas[i - 1] + lucas[i - 2]
print(lucas[n])
# Judge status: Accepted
h,a=map(int,input().split())
if h%a==0:
    print(int(h/a))
else:
    print(int(h/a+1))
# Judge status: Wrong Answer
a,b,c = map(int,input().split())

print(c-(a-b))
# Judge status: Wrong Answer
S = input().split()

if S[1::2] == "R" or S[1::2] == "U" or S[1::2] == "D" :
  print("Yes")
  
else :
  print("No")
# Judge status: Accepted
N = int(input())
a = [int(i) for i in input().split()]
ans = float("inf")
for i in range(-100, 101):
    ans = min(sum([(n - i)** 2 for n in a]), ans)
print(ans)
# Judge status: Accepted
N,L=map(int,input().split())
A=L
if L<=0 and L-1+N>=0:
  A=0
elif L<=0:
  A=L+N-1
print(N*(N-1)//2+L*N-A)
# Judge status: Accepted
K = int(input())
A, B = list(map(int, input().split()))

ans = "NG"
for i in range(A, B + 1):
    if i % K == 0:
        ans = "OK"
print(ans)
# Judge status: Wrong Answer
n = input()
a = [list(map(int,raw_input().split())) for i in range(2)]
x = 0
y = 0
total = a[0][0]
while 1:
    right = sum([a[y][i] for i in range(x+1,n)])+a[1][n-1] if x != n-1 else 0
    down = sum([a[1][i] for i in range(x,n)])
    if right > down:
        x += 1
        total += a[y][x]
    else:
        total += down
        break
print total
# Judge status: Accepted
L, R, d = map(int, input().split())
if L % d != 0:
    L += d - (L % d)
if R % 2 == 1:
    R -= L % d
if L > R:
    print(0)
else:
    print((R - L)//d + 1)
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))

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

c = {}
for i in D:
    if i in c:
        c[i] += 1
    else:
        c[i] = 1

if c[0] != 1:
    print(0)
    exit()

result = 1
for i in range(1, max(D) + 1):
    if i not in c:
        print(0)
        exit()
    result *= pow(c[i - 1], c[i], 998244353)
    result %= 998244353
print(result)
# Judge status: Accepted
w, h, n = map(int, input().split())
x1 = [0]
x2 = [w]
y1 = [0]
y2 = [h]

for i in range(n):
  x, y, a = map(int, input().split())
  if a == 1:
    x1.append(x)
  elif a == 2:
    x2.append(x)
  elif a == 3:
    y1.append(y)
  elif a == 4:
    y2.append(y)

left = max(x1)
right = min(x2)
bottom = max(y1)
top = min(y2)

ans =max(0, right - left)*max(0, top - bottom)
print(ans)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

if 2 * d >= abs(c - a):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
S = sorted([int(input()) for n in range(N)])
a = sum(S)
n = 0

while a%10==0 and a!=0:
  a-=S[n]
  n+=1

print(a)
# Judge status: Accepted
n=int(input())
d1=[]
d2=[]
f=0
for i in range(n):
    x,y=map(int, input().split())
    d1.append(x)
    d2.append(y)
for i in range(2,n):
    if d1[i]==d2[i] and d1[i-1]==d2[i-1] and d1[i-2]==d2[i-2] :
        f=1
if f==1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def resolve():
    A, B, C, D = map(int, input().split())
    d = D
    c = C
    gcd = 0
    while gcd == 0:
        if d % c == 0:
            gcd = c
        else:
            e = d%c
            d = c
            c = e
    lcm = C*D//gcd
    A = A-1
    print((B-B//C-B//D+B//lcm)-(A-A//C-A//D+A//lcm))
resolve()
# Judge status: Accepted
a, b = map(int, input().split())
if int(a*b%2) == 1:
  print('Odd')
else:
  print('Even')
# Judge status: Accepted
from fractions import gcd
a, b, k = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    print(divisors[len(divisors) - k])
make_divisors(gcd(a, b))
# Judge status: Accepted
def solve():
    s = list(input())
    K = int(input())

    for i in range(len(s)):
        distToA = (ord('z')+1 - ord(s[i])) % 26
        if distToA <= K:
            s[i] = 'a'
            K -= distToA
    else:
        s[-1] = chr(ord(s[-1]) + K%26)
    
    print("".join(s))

if __name__ == '__main__':
    solve()
# Judge status: Wrong Answer
A, B, C, D = map(int, input().split())

if A < C and B > C:
  print(min(B, D) - C)
elif A > C and B > C:
  print(min(B, D) - A)
else:
  print(0)
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


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


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))


n = in_int()

a = in_list()

av=  sum(a)//n

ans  = 0

p = 0
for xx in a:
    p += (xx-av)*(xx-av)

ans = p


p = 0
for xx in a:
    p += (xx-av-1)*(xx-av-1)


ans = min(ans, p)

print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print("Yes" if max(a, b, c) == b or min(a, b, c) == b else "NO")
# Judge status: Wrong Answer
N = int(input())
count = 0

if N == 1:
    print(1)

elif N == 2 or N == 3:
    print(2)

else:
    even = [i for i in range(2, N+1, 2)]

    while len(even) >1:
        i = 0
        count +=1
        while i < len(even):
            if even[i]%2 == 0:
                even[i] = even[i]/2
                i +=1
            else:
                del even[i]
                i +=1
    print(2**count)
# Judge status: Wrong Answer
input_line = list(input().split())
input_line = [int(n) for n in input_line]

[D, T, S] = input_line

condition = D >= T*S
if condition:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
MOD = 10 ** 9 + 7
n, k = map(int, input().split())

def calc(a):
  smallest = a * (a-1) / 2
  largest = smallest + a * (n-a+1)
  return largest - smallest + 1

ans = 0
for a in range(k, n+2):
  ans += calc(a)
  ans %= MOD
  
print(ans)
# Judge status: Accepted
n = int(input())
A = tuple(map(int, input().split()))
cnt = 0
zero = False
for a in A:
    if a < 0:
        cnt += 1
    elif a == 0:
        zero = True

if cnt%2 == 0 or zero:
    print(sum(map(abs, A)))
else:
    A = sorted(map(abs, A))
    print(sum(A) - 2*A[0])
# Judge status: Wrong Answer
a = list(map(int,input().split()))

ans = max(a) -min(a)
print(ans)
# Judge status: Wrong Answer
import numpy as np
n,W,*wv=map(int,open(0).read().split())
w=np.array(wv[::2])
v=np.array(wv[1::2])
dp=np.zeros([n+1,W+1],dtype=int)
for i in range(1,n+1):
  now=np.zeros(W+1,dtype=int)
  print(dp[i-1],now)
  now[w[i-1]:]=dp[i-1][:-w[i-1]]+v[i-1]
  print(dp[i-1],now)
  dp[i]=np.maximum(dp[i-1],now)
print(dp[-1][-1])
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
a = map(int, input().split())
counter = Counter()

for ai in a:
    counter[ai] += 1

for ai in a:
    print(max(0, counter[ai]))
# Judge status: Accepted
from collections import defaultdict
N = int(input())
a = [int(input()) for _ in range(N)]

d = defaultdict(int)
for i, e in enumerate(a, 1):
    d[i] = e

count = 1
tmp = d[1]
if tmp == 2:
    print(1)
    exit()

while count <= N:
    v = d[tmp]
    count += 1
    if v == 2:
        print(count)
        exit()
    tmp = v
print(-1)
# Judge status: Accepted
def main():
  N = int(input())
  A = [int(_)//400 for _ in input().split()]
  U = [a for a in A if a < 8]
  O = N - len(U)
  print(max(1, len(set(U))), len(set(U)) + O)
  return

if __name__ == '__main__':
  main()
# Judge status: Accepted
n,a,b=map(int,input().split())
m=10**9+7
def com(n,k,m):
  p,q=1,1
  for i in range(n-k+1,n+1):
    p*=i
    p%=m
  for i in range(1,k+1):
    q*=i
    q%=m
  return p*pow(q,m-2,m)%m
ca,cb=com(n,a,m),com(n,b,m)
ans=(pow(2,n,m)-1-ca-cb)%m
print(ans)
# Judge status: Accepted
n=int(input())
s=[]
for i in range(n):
    s.append(input())
print('AC x {}'.format(s.count('AC')))
print('WA x {}'.format(s.count('WA')))
print('TLE x {}'.format(s.count('TLE')))
print('RE x {}'.format(s.count('RE')))
# Judge status: Accepted
# -*- coding: utf-8 -*-

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

a_b = abs(a-b)
a_c = abs(a-c)
b_c = abs(b-c)

if a_c <= d or (a_b <= d and b_c <= d):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import math
# math.gcd(x,y)

K = int(input())
ans = 0
for i in range(K):
  for j in range(K):
    for k in range(K):
      ans += math.gcd(math.gcd(i, j), k)

print(ans)
# Judge status: Accepted
def solve(L, R):
  minmod = float('inf')
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      minmod = min((i * j) % 2019, minmod)
      if minmod == 0:
        return minmod
  return minmod

L, R = map(int, input().split(' '))
print(solve(L, R))
# Judge status: Accepted
from collections import Counter
s=input()
t=input()
if Counter(Counter(s).values()) == Counter(Counter(t).values()):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
S = list(input())
n = len(S)
cnt=0
for i in range(int(n/2)):
	if S[2*i]=='L' or S[2*i+1]=='R':
		print('No')
		cnt+=1
		break
	else:
		continue

if cnt == 0:
	print('Yes')
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
count = 0
while all(a%2==0 for a in A):
    A = [a/2 for a in A]
    count+=1
print(count)
# Judge status: Wrong Answer
x = int(input())
Y = [500, 100, 50, 5, 1]
ans = 0
for i in Y:
    if i == 500:
       ans +=  (x // i)*1000
    elif i == 5:
        ans +=  (x // i)*5
    x -= (x//i)*i
    if x == 0:
        break
print(ans)
# Judge status: Wrong Answer
N = int(input())
t=[0]*(N+1); x=[0]*(N+1); y=[0]*(N+1)
t_diff=0; x_diff=0; y_diff=0

for i in range(1,N+1):
    t[i], x[i], y[i] = map(int, input().split())

# print(t, x, y)

for i in range(N):
    t_diff = t[i+1]-t[i]
    x_diff = abs(x[i+1]-x[i])
    y_diff = abs(y[i+1]-y[i])
    if t_diff%2 != (x_diff+y_diff)%2 or t[-1] < (x[-1]+y[-1]):
        print("No")
        exit()

print("Yes")
# Judge status: Accepted
import sys
n = int(input())
ans = 0
flag = False
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        ans += 1
    else:
        ans = 0
    if ans == 3:
        flag = True
if flag == True:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
if N==2: print(max(A));exit()
from math import gcd
L = {}
R = {}
L[0] = A[0]
R[N-1] = A[-1]
ans = 0
for i in range(1,N):
    L[i] = gcd(L[i-1],A[i])
    R[N-i-1] = gcd(R[N-i],A[N-i-1])
for i in range(2,N):
    ans = max(ans,gcd(L[i-2],R[i]))
ans = max(ans,R[1])
ans = max(ans,L[N-1])
ans = max(ans,R[0])
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

ans = 0
if M > N:
    dist = []
    for i in range(1,M):
        dist.append(abs(X[i]-X[i-1]))
    dist.sort()
    for i in range(M-N):
        ans += dist[i]

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

for i in range(len(A)):
  if A[i] %2 == 0:
    if A[i]%3 != 0 and A[i]%5 != 0:
      print("DENIED")
      exit()
    else:
      pass
  else:
    pass
  
print("APPROVED")
# Judge status: Accepted
N,M=map(int,input().split())
H=list(map(int,input().split()))
ans=[1 for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())  
  if H[A-1]>H[B-1]:
    if H[A-1]!=0:
      ans[B-1]=0
  elif H[A-1]<H[B-1]:
    if H[B-1]!=0:
      ans[A-1]=0
  else:
    ans[A-1]=0
    ans[B-1]=0
print(ans.count(1))
# Judge status: Accepted
s = input()
t = input()
n = len(s)
for i in range(n):
    if t[i:]+t[:i] == s:
        print('Yes')
        exit()
print('No')
# Judge status: Wrong Answer
n,m=[int(x) for x in input().rstrip().split()]
a=[int(x) for x in input().rstrip().split()]
a.sort(reverse=True)
d=[]
bc=[]
for i in range(m):
  b,c=[int(x) for x in input().rstrip().split()]
  bc.append([b,c])

cnt=0
for b,c in bc:

  d.extend([c]*b)
  cnt+=b
  if n<cnt:
    break
  
d.sort(reverse=True)
a+=d
a.sort(reverse=True)
print(sum(a[:n]))
# Judge status: Accepted
a,b,c=map(int,input().split())

print('Yes') if a+b>=c else print('No')
# Judge status: Accepted
N=int(input())
*A,=map(int,input().split())

if N%2==0:
    print(' '.join(map(str,A[1::2][::-1]+A[::2])))
else:
    print(' '.join(map(str,A[::2][::-1]+A[1::2])))
# Judge status: Accepted
# 入力 : 数字2つ
x, y = map(int, input().split())

# 出力　x, y が同一のグループに属しているか判定してください。

list1 = [1, 3, 5, 7, 8, 10, 12]
list2 = [4, 6, 9, 11]
list3 = [2]

if x in list1 and y in list1:
    print("Yes")
elif x in list2 and y in list2:
    print("Yes")
elif x in list3 and y in list3:
    print("Yes")
else :
    print("No")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a<=b<=c:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a, b = map(int, input().split())
cnt = 0

for i in range(a, b+1):
    s = str(i)
    if(s == s[::-1]):
        cnt += 1
print(cnt)
# Judge status: Accepted
a,b =map(int, input().split())

if b < 0:
    if (b-a+1)%2 == 0:
        print('Positive')
    else:
        print('Negative')
elif b >= 0 and a <= 0:
    print('Zero')
else:
    print('Positive')
# Judge status: Wrong Answer
s, c = map(int, input().split())

ans = 0

if s == 1 and c == 1:
    print(ans)
    exit()

if 2*s >= c:
    ans += s
else:
    ans += s+ ( c - 2*s )//4

print(ans)