peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import sys
import numpy as np
import math
input = sys.stdin.readline
 
N = int(input())
A = np.array(list(map(int,input().split())))
if N == 1:
    ans = 0
else:
    r = np.array(list(range(1,N+1)))
    B = A-r
    C = list(map(abs,B-(math.ceil(sum(B)/len(B)))))
    D = list(map(abs,B-(math.floor(sum(B)/len(B)))))
    E = list(map(abs,B-(B[N//2])))
    F = list(map(abs,B-(B[N//2+1])))

    ans = min(sum(C),sum(D))
    ans = min(ans,sum(E))
    ans = min(ans,sum(F))

print(ans)
# Judge status: Wrong Answer
def main():
    _ = input()
    A = list(map(int, input().split()))
    min_a = min(A)
    flag = True
    for a in A:
        if a % min_a != 0:
            flag = False
            break
    if flag is True:
        print(min_a)
        exit()

    for a in A:
        if a % 2 == 1:
            print(1)
            exit()
    print(2)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
st = input()

ans = 0
for i in range(len(st)//2):
  if st[i] != st[-i]:
    ans += 1
print(ans)
# Judge status: Accepted
n,x = map(int,input().split())
arr = list(map(int,input().split()))

arr.sort()
ans = 0

for i in range(n-1):
    x -= arr[i]
    if x >= 0:
        ans += 1

if arr[-1] == x:
    ans += 1

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

c = 0
m = 100
while True:
    m = m * 1.01
    m = int(m)
    c += 1
    if m > n:
        break
print(c)
# Judge status: Wrong Answer
n=int(input())
L=list(map(int, input().split()))
a=max(L)
b=0
for i in range(n):
	if min(a-L[i],L[i])>=b:
		b=L[i]
print(a,b)
# Judge status: Accepted
import math
N = int(input())
ans = math.factorial(N) % (10**9 + 7)
print(ans)
# Judge status: Accepted
s = list(input())
K = int(input())
n = len(s)
for i in range(n-1):
    m = ord('z') - ord(s[i]) + 1
    if not s[i] == 'a' and m <= K:
        s[i] = 'a'
        K -= m
s[n-1] = chr((ord(s[n-1])+K%26-97)%26+97)
print(''.join(s))
# Judge status: Accepted
# abc085_c.py
N,Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1):
        k = N-i-j
        if i*10000 + j*5000 + k*1000 == Y and k>=0:
            print(i,j,k)
            exit()
print(-1,-1,-1)
# Judge status: Accepted
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=0
l=[[] for i in range(n+1)]
for j in range(m):
  a,b=map(int,input().split())
  l[a].append(b)
  l[b].append(a)
for i in range(1,n+1):
  now=l[i]
  on=0
  for j in now:
    if h[i-1]>h[j-1]:
      on+=1
  if on==len(now):
    ans+=1
print(ans)
# Judge status: Accepted
def main():
    A, B, C, D = map(int, input().split())

    def lcm(v1, v2):
        v3 = v1 % v2
        if v3 == 0:
            return v2
        return lcm(v2, v3)

    def gcd(v1, v2):
        return v1 * v2 // lcm(v1, v2)

    count = B - (A - 1)

    c = B // C - (A - 1) // C
    d = B // D - (A - 1) // D

    CD = gcd(C, D)
    cd = B // CD - (A - 1) // CD

    print(count - c - d + cd)


main()
# Judge status: Accepted
N,H = list(map(int,input().split()))
a_max = 0
B = []
for i in range(N):
  a,b = list(map(int,input().split()))
  a_max = max(a_max,a)
  B.append(b)

B = sorted(B,key = lambda x:-x)
cnt = 0
for idx,b in enumerate(B):
  if b < a_max:
    break
  H -= b 
  cnt += 1
  if H <= 0:
    print(cnt)
    break

if H > 0 :
  
  print(cnt + (H-1)//a_max +1 )
# Judge status: Wrong Answer
n=int(input())
counter=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n-i*j):
            if((i*j+k)==n):
                counter=counter+1
print(counter)
# Judge status: Wrong Answer
N = int(input())
S = input()

c_e = 0
c_w = 0

for s in S:
    if s == "E":
        c_e += 1
    elif s == "W":
        c_w += 1

print(min(c_e, c_w))
# Judge status: Accepted
data = input().split()

h = int(data[0])
a = int(data[1])

div = h // a

if h % a != 0:
  div += 1

print(div)
# Judge status: Accepted
d, t, s =  map(int, input().split())
print("Yes" if t * s >= d else "No")
# Judge status: Wrong Answer
n, k = map(int, input().split())
n_sum = 0

for i in range(n):
  tmp = 1 / n
  now = 1
  while now < k:
    now *= 2
    tmp /= 1/2
  n_sum += tmp
print(n_sum)
# Judge status: Accepted
S = input()
if S == 'Sunny':
  print('Cloudy')
elif S == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')
# Judge status: Accepted
N,X=map(int,input().split())
import math
a=list(map(int,input().split()))
a.append(X)
a.sort()
S=[]
for i in range(N):
    S.append(a[i+1]-a[i])

    
ans=S[0]
for j in range(1,N):
    ans=math.gcd(ans,S[j])
    
print(ans)
# Judge status: Accepted
n, k = map(int,input().split())

per = 0

for i in range(1,n+1):
    a = 0
    while i<k:
        a += 1
        i *= 2
    per += (1/n) * (0.5**a)

print(per)
# Judge status: Accepted
n,a,b,c,d=map(int,input().split())
s=str(input())

if c<d:
    if s[min(a,b)-1:d+1].count("##")==0:
        print("Yes")
    else:
        print("No")
else:
    if s[min(a,b)-1:d+1].count("##")==0:
        if s[max(a,b)-2:d+1].count("...")==0:
            print("No")
        else:
            print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
N=int(input())
for i in range(1,10):
    if N%i==0 and N//i<10:
        print('Yes')
        break
print('No')
# Judge status: Wrong Answer
#42
N,M = map(int,input().split())
k = list(map(int,input().split()))
k = k[1:]
for i in range(N-1):
    l = list(map(int,input().split()))
    l = l[1:]
    for m in k:
        a = 0
        for n in l:
            if m == n:
                a +=1
                break
        if a ==0:
            k.remove(m)
    
print(len(k))
# Judge status: Accepted
x,y=map(int, input().split())
if x % y==0:
	print(-1)
else:
	print(x)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
a1 = []
e = [a,b]
f = [c,d]
for i in e:
    for j in f:
        a1.append(i*j)
print(max(a1))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)

alice=0
bob=0
i=0
while a:
    if i%2==0:
        alice+=a.pop()
    else:
        bob+=a.pop()
    i+=1
print(alice-bob)
# Judge status: Wrong Answer
import math

x, y = [int(i) for i in input().split()]

print(int(math.log2(y / x)) + 1)
# Judge status: Wrong Answer
pa, pb, pab, x, y = map(int, input().split())
li = []
if x-y>= 0:
    li.append(pa*x+pb*y)
    li.append(pa*(x-y)+pab*2*y)
    li.append(pa*(x-y+1)+pb+pab*2*(y-1))
    li.append(pab*2*x)
else:
    li.append(pa*x+pb*y)
    li.append(pb*(y-x)+pab*2*y)
    li.append(pa+pb*(y-x+1)+pab*2*(y-1))
    li.append(pab*2*y)
li.sort()
print(li[0])
# Judge status: Accepted
N=int(input())
flag=0
for i in range(25):
    for j in range(14):
        if 4*i+7*j==N:
            flag=1
print('Yes' if flag==1 else 'No')
# Judge status: Accepted
N=int(input())
ans=1000000000000
import math

for i in range(int(math.sqrt(N))):
    j=N/(i+1)
    if j%1==0:
        if i+int(j)-1<ans:
            ans=i+int(j)-1

print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(min(K, 50)):
    B = [0 for k in range(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]
    A = B.copy()
   
for b in B:
    print(b, end=" ")
# Judge status: Accepted
import math
n=int(input())

print(str(2*n*math.pi))
# Judge status: Accepted
X, A, B = map(int, input().split())

if B > A + X:
    print('dangerous')
elif B > A:
    print('safe')
else:
    print('delicious')
# Judge status: Accepted
c = input()
al = "abcdefghijklmnopqrstuvwxyz"
print(al[al.index(c) + 1])
# Judge status: Accepted
A, B, C, K = map(int, input().split())

if abs(A - B) > 10 ** 18:
    print('Unfair')
else:
    if K % 2 == 1:
        print(B - A)
    else:
        print(A - B)
# Judge status: Wrong Answer
a, b = map(int, input().split())
print('Evan' if a*b%2 else 'Odd')
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
tot=l[0]^l[1]
for i in range(2,n):
    tot=tot^l[i]
ar=[]
for i in l:
    ar.append(tot^i)
print(*ar)
# Judge status: Accepted
N = int(input())
an = list(map(int, input().split()))
over_cnt = 0
colors = []
for a in an:
    rate = a // 400
    if rate >= 8:
        over_cnt += 1
    elif rate not in colors:
        colors.append(rate)
 
print(max(len(colors), 1), len(colors) + over_cnt)
# Judge status: Accepted
n, m, x = map(int, input().split())
refs = [tuple(map(int, input().split())) for _ in range(n)]

min_fee = 1 << 64
for purchases in range(1 << n):
    total_fee = 0
    understands = [0] * m

    for i in range(n):
        if (purchases >> i) & 1:
            total_fee += refs[i][0]
            for j in range(m):
                understands[j] += refs[i][j + 1]

    if all([understand >= x for understand in understands]) and total_fee < min_fee:
        min_fee = total_fee

print(min_fee if min_fee != 1 << 64 else -1)
# Judge status: Accepted
N = int(input())
A = [int(x) for x in input().split()]
max_val = max(A)
B = [0]*(max_val+3)
for i in range(N):
  B[A[i]]+=1
  B[A[i]+1]+=1
  B[A[i]+2]+=1
print(max(B))
# Judge status: Wrong Answer
A, B = map(int, input().split())
if A > B:
    print('Alice')
elif B > A:
    print('Bob')
else:
    print('Draw')
# Judge status: Accepted
N = int(input())

A = [None] * N
B = [None] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

result = 0
for i in range(N - 1, -1, -1):
    result += (B[i] - (A[i] + result) % B[i]) % B[i]
print(result)
# Judge status: Wrong Answer
a, b = map(int, input().split())
n = 1
while n // 2 * (n + 1)  < a:
  n += 1

print(n // 2 * (n + 1) - a)
# Judge status: Wrong Answer
a,b = map(int, input().split(" "))
a1 = a / 0.08
b1 = b / 0.1
if a1 == b1:
  print(int(a1))
else:
  print(-1)
# Judge status: Wrong Answer
n,k = map(int,input().split())
s = input()

same = 0
diff = 0

for i in range(n-1):
    if s[i] != s[i+1]:
        diff += 1
    else:
        same += 1

if diff-1 >= k:
    ans = same + 2*k
else:
    ans = same + 2*(diff-1) + 1
print(ans)
# Judge status: Accepted
S = input()
l = len(S)
for i in range(l):
    print('x', end="")
# Judge status: Accepted
a,b = map(int,input().split())
k = (a+b)//2
if k-a==b-k:
  print(k)
else:
  print("IMPOSSIBLE")
# Judge status: Wrong Answer
S = list(map(int,input().split()))
count = 0
for s in S:
  if s == 0:
    count += 1
print(count)
# Judge status: Accepted
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()

odd = 0
count = 1
a = A[0]
for i in A[1:]:
  if i == a:
    count += 1
  else:
    a = i
    if count % 2 == 1:
      odd += 1
    count = 1
if count % 2 == 1:
      odd += 1
print(odd)
# Judge status: Accepted
n,m = map(int,input().split())

k=[]
l=[]
ans=0
for i in range(m):
    input_l = sorted(list(map(int,input().split())))
    if input_l[0]==1:
        k.append(input_l[1])
    if input_l[1]==n:
        l.append(input_l[0])
print('IMPOSSIBLE' if len(set(k)&set(l))==0 else 'POSSIBLE')
# Judge status: Wrong Answer
a = list(map(int, input().split()))
print(a.index(0))
# Judge status: Accepted
from collections import deque

k = int(input())
lun = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(k - 1):
    tmp = lun.popleft()
    if tmp % 10 != 0:
        lun.append(tmp * 10 + (tmp % 10 - 1))
    lun.append(tmp * 10 + (tmp % 10))
    if tmp % 10 != 9:
        lun.append(tmp * 10 + (tmp % 10 + 1))

print(lun.popleft())
# Judge status: Wrong Answer
from collections import defaultdict
import sys
input=sys.stdin.readline

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

ablist=[]
for i in range(N):
  A,B=map(int,input().split())
  ablist.append((B,-A))
ablist.sort()
  
answer=0
for i in reversed(range(M)):
  ablist_sub=[]
  while ablist:
    b,ma=ablist.pop()
    a=-ma
    if i+a<=M:
      answer+=b
      #print(i,a,b)
      break
    else:
      ablist_sub.append((b,ma))
      
  for ab in ablist_sub:
    ablist.append(ab)
    
print(answer)
# Judge status: Accepted
x = list(map(int, input().split()))

for i in range(len(x)):
    if x[i] == 0:
        print(i+1)
# Judge status: Wrong Answer
import math
from sys import stdin,stdout
#% 998244353
T = stdin.readline()
if T=="ABC":
    print("ARC")
elif T=="ARC":
    print("ABC")
# Judge status: Accepted
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
count = 0
for i,j in itertools.combinations_with_replacement(range(len(S)+1),2):
    if S[:i]+S[j:]=='keyence':
        print('YES')
        break
else:
    print('NO')
# Judge status: Wrong Answer
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
    exit()

cnt = [0] *101
ans1 = 0
ans2 = 0

for _p in p:
    cnt[_p] += 1

for i in range(x, 101):
    if cnt[i] == 0:
        ans1 = i
        break

for i in range(1, x):
    if cnt[i] == 0:
        ans2 = i

if abs(ans1 - x) < abs(ans2 - x):
    print(ans1)
elif abs(ans1 - x) >= abs(ans2 - x):
    print(ans2)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

zero = 0
two = 0
four = 0

for i in a:
    if i % 4 == 0:
        four += 1
    elif i % 2 == 0:
        two += 1
    else:
        zero += 1

if two == 0:
    if four >= zero - 1:
        print('Yes')
    else:
        print('No')

else:
    if four >= zero:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
a,b,c = [str(input()) for i in range(3)]
current = 'a'
while True:
    cur = current[len(current)-1]
    if cur == 'a':
      current+=a[0]
      a=a[1:]
    elif cur == 'b':
      current+=b[0]
      b=b[1:]
    elif cur == 'c':
      current+=c[0]
      c=c[1:]
    if a == '' or b =='' or c =='':
      print(current[len(current)-1].upper())
      print(current)
      break
# Judge status: Wrong Answer
from itertools import permutations

N=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
x=set([n for n in range(1,N+1)])
x=list(permutations(x,N))

a,b=0,0
for num in range(len(x)):
    if p==list(x[num]):
        a=num+1
    elif q==list(x[num]):
        b=num+1

print(abs(a-b))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
m = A[0]
c = 1000
for i, a in enumerate(A):
  if i == N-1:
    if a != m:
      c += c // m * (a - m)
    continue
  
  if a <= A[i+1]:
    continue
  
  c += c // m * (a - m)
  m = A[i+1]
print(c)
# Judge status: Wrong Answer
a = input()

if a >= '3200':
    print('pink')

elif a < '3200':
    print('red')
# Judge status: Accepted
n = int(input())

al = list(map(int, input().split()))
ail = []
for i,a in enumerate(al):
    ail.append((a,i+1))

ail.sort()
ans = []
for a,i in ail:
    ans.append(i)

print(*ans)
# Judge status: Accepted
a = int(input())
b = 0
for i in range(a+1):
    b += int(i)
print(b)
# Judge status: Accepted
a, b = map(int, input().split())
print('Possible') if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0 else print('Impossible')
# Judge status: Accepted
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
print((n-1+k-2)//(k-1))
# Judge status: Accepted
x = int(input())

if x % 11 == 0:
    print(x // 11 * 2)
elif x % 11 > 6:
    print(x // 11 * 2 + 2)
else:
    print(x // 11 * 2 + 1)
# Judge status: Wrong Answer
K,X = map(int,input().split())
A = X - (K-1)
B = X + (K-1)
ans = []

for i in range(A,B+1):
    ans.append(i)

print(ans)
# Judge status: Wrong Answer
#Kの倍数を出したい、ただしB>= nK >= Aの範囲内とする
k = int(input())
a,b = map(int,input().split())

#if k == 1:
	#print("YES")
	
print("OK" if (b-a)//k > 0 or (b-a)/k == 0 and a%k == 0  else "NG")
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
s=input()
c=a+b
A=0
B=0
for i in s:
    if A+B<=c:
        if i=="a":
            A+=1
            print("Yes")
        elif i=="b" and B<b:
            B+=1
            print("Yes")
        else:
            print("No")
    else:
        print("No")
# Judge status: Accepted
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from math import ceil
def main():
    n = tuple(map(int, tuple(input())))
    if sum(n) % 9 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
A = int(input())

result_num = 0
for a in range(A):
    if a % 3 == 0 and a % 5 ==0:
        pass
    elif a % 3 == 0:
        pass
    elif  a % 5 == 0:
        pass
    else:
        result_num += a
print(result_num)
# Judge status: Accepted
s,w=map(int,input().split())
print("safe" if s>w else "unsafe")
# Judge status: Accepted
h, n = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(n)]
h_max = 10 ** 4
inf = 10 ** 9
dp = [inf] * (h_max + 1)
dp[0] = 0
for h_target in range(1, h_max + 1):
    for attack, mp in AB:
        h_remain = max(0, h_target - attack)
        dp[h_target] = min(dp[h_target], dp[h_remain] + mp)
print(dp[h])
# Judge status: Accepted
S = list(input())
RD = S.count('R')
if RD != 2:
    print(RD)
else:
    if S[1] == 'R':
        print(RD)
    else:
        print(1)
# Judge status: Accepted
ol = list(input())
el = list(input())
ans = ''

for i in range(min(len(ol), len(el))):
    ans += ol.pop(0) + el.pop(0)
if len(ol) > 0:
    ans += ol.pop()

print(ans)
# Judge status: Wrong Answer
N = list(map(int,input().split()))
n = N[0]
k = N[1]

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

i=0
E = []
#期待値のリスト
for e in X:
  E.append((1+e)/2)
  i += 1

j = 0
T=[]
T.append(0)
#期待値の累積和
for t in E:
  T.append(T[j] + t)
  j += 1

max_val = 0
max_st = 0
for i in range(0,j-k):
  tmp_val = T[i+k] - T[i]
  if tmp_val >= max_val :
    max_st = i
    max_val = tmp_val


print(max_val)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
score_a = 0
score_b = 0

for i in range(N):
  if i % 2 == 0:
    score_a += A[i]
  else:
    score_b += A[i]
    
print(abs(score_a - score_b))
# Judge status: Accepted
X = int(input())

if(X >= 30):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
X = list(map(int,list(input())))

for i in range(2**3):
  t = X[0]
  for j in range(1,4):
    if(i >>j)&1:#1 is neg
      t -= X[j]
    else:
      t += X[j]
  if t == 7:
    ans = ""
    for k in range(4):
      ans+=str(X[k])
      if(i>>(k+1))&1:
        ans += "-"
      else:
        ans += "+"
    ans+="=7"
    print(ans)
    exit()
# Judge status: Wrong Answer
def isPalindrome(s):
    n = len(s)
    front = s[0:int((n-1)/2)]
    back = s[int((n+1)/2):]
    return front == back[::-1]


s = input()

sResult = isPalindrome(s)

if not sResult:
    print("No")
else:
    n = len(s)
    front = s[0:int((n-1)/2)]
    back = s[int((n+1)/2):]
    fResult = isPalindrome(front)
    bResult = isPalindrome(back)
    if fResult and bResult:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
s = int(input())

n = s
cnt = 1
while n != 4:
    cnt += 1
    if n % 2 == 0:
        n = n // 2
    else:
        n = (3 * n) + 1

print(cnt + 3)
# Judge status: Accepted
def solve(a, b, c):
    if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
        return 0
    a, b, c = sorted([a, b, c])
    return a * b


print(solve(*map(int, input().split())))
# Judge status: Accepted
n, a, b = map(int,input().split())

print(n // (a + b) * a + min(n % (a + b) ,a))
# Judge status: Wrong Answer
import sys

N, M, X=map(int, sys.stdin.readline().rstrip().split())
A = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(N)]
cost=[]

for i in range(1<<N):	#Bit All Search
	l=[0]*(M+1)
	for j in range(N):
		if((i>>j)&1):
			l=[l[k]+A[j][k] for k in range(M+1)]
	for k in range(M):
		if l[k+1]<X:
			break
		else:
			cost.append(l[0])
cost.sort()
print(-1 if cost==[] else cost[0])
# Judge status: Accepted
S=input()

l=[]
for i in range(len(S)):
	l.append((abs(753-int(S[i:i+3]))))

print(min(l))
# Judge status: Wrong Answer
import collections
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
l=[]
for _ in range(Q):
    l.append(list(map(int,input().split())))
c = collections.Counter(A)
sum=sum(A)
for i in range(Q):
    print(c)
    if c[l[i][0]] == 0:
        print(sum)
        continue
    else:
        sum+=c[l[i][0]]*(l[i][1]-l[i][0])
        c[l[i][1]]+=c[l[i][0]]
        del c[l[i][0]]
        print(sum)
# Judge status: Accepted
a, b, c = map(int, input().split())
print("YNeos"[not(a+b+c==max(a,b,c)*2)::2])
# Judge status: Wrong Answer
N, x = map(int, input().split())
ai = list(map(int, input().split()))
gokei = 0
for i in range(N - 1):
    taberu = ai[i] + ai[i+1] - x
    if taberu > 0:
        gokei += taberu
        ai[i+1] = ai[i+1] - taberu 
print(gokei)
# Judge status: Accepted
S = list(input())
K = int(input())

for i in range(len(S)):
  n = ord(S[i])
  if S[i] == 'a':
    continue
  if ord('z') - n + 1 <= K:
    K -= ord('z') - n + 1
    S[i] = 'a'
assert K >= 0
if K != 0:
  n = ord(S[-1])
  n -= ord('a')
  n += K
  n %= 26
  n += ord('a')
  S[-1] = chr(n)
print(''.join(S))
# Judge status: Accepted
X=int(input())
if(X<100):
    print(0)
    exit()
dp=[0]*100001
dp[100:106]=[1]*6
for i in range(106,X+1):
    for j in range(100,106):
        if(dp[i-j]==1):
            dp[i]=1
            break
print(dp[X])
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[14]:


N = int(input())
sp = []
for i in range(N):
    S,P = input().split()
    P = int(P)
    sp.append([i]+[S]+[P])


# In[16]:


mylist = sorted(sp, key=lambda x: x[2], reverse=True)
mylist = sorted(mylist, key=lambda x: x[1])
for i in range(len(mylist)):
    print(mylist[i][0]+1)


# In[ ]:
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        s=input()
        if s[0]=='A' and s[2:-1].count('C')==1:
            for i in range(2,len(s)):
                if s[i]!='C' and s[i].isupper():
                    return 'WA'
            if s[1].islower() and s[-1].islower():
                return 'AC'
        else:
            return 'WA'
    print(main())
resolve()
# Judge status: Accepted
n = input()
aa = list(map(int, input().split()))
aa.sort(reverse=True)
al = sum(aa[::2])
bb = sum(aa[1::2])
print(al - bb)
# Judge status: Wrong Answer
n,m=map(int,input().split())
n=[input() for _ in range(n)]
m=[input() for _ in range(m)]
r=[]
for i in m:
  t=[]
  for j in n:
    if i in j:
      t.append(j.index(i))
  if t: r.append(t)
print('NYoe s'[len(r) and all([1 for i in r if 0 in i] or [1 for i in r if 1 in i])::2])
# Judge status: Accepted
def resolve():
    h1, m1, h2, m2, k = map(int, input().split())
    print((h2-h1)*60 + (m2-m1) - k)
    
resolve()
# Judge status: Accepted
input = int(input())
if input == 0: print (1)
else: print (0)
# Judge status: Accepted
def main():
    N = int(input())
    A = [input() for i in range(N)]
    from collections import Counter
    c = Counter(A[0])
    for a in A[1:]:
        d = Counter(a)
        c = c & d
    print("".join(sorted(c.elements())))


if __name__ == '__main__':
    main()
# Judge status: Accepted
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b)) for b in B))
# Judge status: Wrong Answer
a = int(input())

print(a//500*1000+(a%5*5))
# Judge status: Wrong Answer
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n=II()
	A=[II() for _ in range(5)]
	ans=0

	for i in A:
		ans=max(ans,n//i)

	ans+=5

	print(ans)









if __name__ == "__main__":
	main()
# Judge status: Accepted
s = input()
if s.count('a') == 1 and s.count('b') == 1 and s.count('c'):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
    if i+1==p[i]:
        if i<n-1:
            p[i+1]=p[i]
        cnt+=1
    
print(cnt)
# Judge status: Accepted
import math

H = int(input())
W = int(input())
N = int(input())

if H < W:
    tmp = W
else:
    tmp = H

i = 1
while tmp * i < N:
    i += 1
print(i)