peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
h = [ni() for i in range(n)]
h.sort()
d = [h[i] - h[i - 1] for i in range(1, n)]
d.sort()
ans = sum([d[i] for i in range(k - 1)])
print(ans)
# Judge status: Accepted
m=lambda:map(int,input().split())
a,b,c=m()
d,e,f=m()
g,h,i=m()
print(['No','Yes'][d-a==e-b==f-c and g-a==h-b==i-c])
# Judge status: Accepted
def solve():
    A,B,C,D = [int(i) for i in input().split()]
    takahashi_attack_cnt = (C+B-1) // B
    aoki_attack_cnt = (A+D-1) // D
    if takahashi_attack_cnt <= aoki_attack_cnt:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()
# Judge status: Accepted
o = input()
e = input()
ans = ''
for i in range(len(e)):
    ans += o[i] + e[i]

if len(o) == len(e)+1:
    ans += o[-1]

print(ans)
# Judge status: Wrong Answer
a,b,t = map(int,input().split())
now = 0
ans = 0
while now < t:
  ans += b
  now += a
print(ans)
# Judge status: Accepted
A, B, K = map(int, input().split())

if A >= K:
    A -= K
elif A + B >= K:
    B -= K - A
    A = 0
else:
    A = 0
    B = 0

print('{} {}' .format(A, B))
# Judge status: Accepted
k = int(input())
x = 0
for i in range(1,10**6+10):
    x = (x*10+7)%k
    if(x==0):
        print(i)
        exit()

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

if (A != X) and (A < X) and (A+B >= X):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
s = input()
aidx = -1
zidx = -1
for i in range(len(s)):
  if aidx == -1 and s[i] == 'A':
    aidx = i
  if zidx == -1 and s[len(s)-1-i] == 'Z':
    zidx = len(s)-1-i
  if aidx != -1 and zidx != -1:
    break
print(zidx-aidx+1)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0

for x in range(N):
    C = A[0:x+1] + B[x:N]
    n = sum(C)
    ans = max(ans, n)

print(ans)
# Judge status: Accepted
N = int(input())
count = 0
for i in range(N):
    D1, D2 = map(int, input().split())    
    if D1==D2:
        count += 1
    else:
        count = 0
    if count == 3:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
n,k = map(int,input().split())
ans = []
count = 0
for i in range(n):
    ans.append(list(map(int,input().split())))
ans.sort()
for i in range(n):
    count += ans[i][1]
    if count >= k:
        print(ans[i][0])
        break
# Judge status: Accepted
N, K = map(int,input().split())
count = 0
base_t = 0
for i in range(1, N+2):
    base_t += i
    if i>=K:
        count += ((N+1)-i)*i+1
print(count % (10**9+7))
# Judge status: Accepted
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
kouho = set([])
kouho2 = set([])
for i in c.most_common():
	if i[1] >= 2:
		kouho.add(i[0])
	if i[1] >= 4:
		kouho2.add(i[0])
kouholist = list(kouho)
kouholist2 = list(kouho2)
kouholist = kouholist + kouholist2
kouholist = sorted(kouholist)[::-1]
if len(kouholist) >= 2:
	print(kouholist[0]*kouholist[1])
else:
	print(0)
# Judge status: Wrong Answer
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, c, k = map(int, readline().split())
t = sorted([int(readline()) for i in range(n)])
cnt = 1
ans = 1
time = t[0] + k
for i in range(n):
    if cnt >= c or time < t[i]:
        ans += 1
        cnt = 0
        time = t[i] + k
    cnt += 1
print(ans)
# Judge status: Accepted
import sys
import numpy as np
from numba import jit, njit
input = lambda: sys.stdin.buffer.readline().rstrip()

@njit
def main(n,m,k,sa,sb):
  rx = 0
  rb = m
  for ra in range(0,n+1): 
    while (sb[rb] + sa[ra]) > k and rb>0 :
      rb-=1
    if (sb[rb] + sa[ra]) <= k:
      rx = max(rx,ra+rb)
  return(rx)

n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = np.cumsum([0]+a)
sb = np.cumsum([0]+b)
print(main(n,m,k,sa,sb))
# Judge status: Wrong Answer
N,T = map(int,input().split())
mn = 10**10
for i in range(N):
    c,t = map(int,input().split())
    print(c,t)
    if t <= T and c <= mn:
        mn = c
if mn == 10**10:
    print("TLE")
else:
    print(mn)
# Judge status: Wrong Answer
X, K, D = map(int, input().split())
scnt = abs(X) // D
if K <= scnt:
    if X > 0:
        print(X - K * D)
    else:
        print(X + K * D)
else:
    if abs(X) % D == 0:
        if (K - scnt) % 2 == 0:
            print(0)
        else:
            print(D)
    else:
        print(abs(X - scnt * D))
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(1,n+1):
  for j in range(1,n+1):
    if i%j == 0:
      ans += i
print(i)
# Judge status: Accepted
n = int(input())
ans = 8
if n >= 400:
    ans = 8
if n >= 600:
    ans = 7
if n >= 800:
    ans = 6
if n >= 1000:
    ans = 5
if n >= 1200:
    ans = 4
if n >= 1400:
    ans = 3
if n >= 1600:
    ans = 2
if n >= 1800:
    ans = 1
print(ans)
# Judge status: Wrong Answer
from sys import exit

A, B, C, K = map(int, input().split())


if A == B:
    print(0)
    exit()

if abs(A - B) > 10 ** 18:
    print("Unfair")
    exit()

sign = A - B // abs(A - B)

if K % 2 == 0:
    print(abs(A - B) * sign)
else:
    print(abs(A - B) * sign * (-1))
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a):
  for j in range(b):
    for k in range(c):
      if 500*i + 100*j + 50*k == x:
        cnt+=1
print(cnt)
# Judge status: Accepted

def main():
    N = int(input())
    a = sorted(map(int, input().split()),reverse=True)      #降順のリスト

    alice = 0
    bob = 0

    for i in range(N):
        if i % 2 == 0:
            alice += a[i]

        else:
            bob += a[i]

    print(alice - bob)


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

H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
max_a = max(a for a, _ in ab)
dp = [0]*(H+max_a)
for i in range(1,H+1):
  dp[i] = min(dp[i-a]+b for a,b in ab)
print(dp[H])
# Judge status: Accepted
import math
import numpy as np
n = int(input())
fac = []
sqrt_n = math.sqrt(n)
for i in range(2, int(sqrt_n)):
    if not n % i:
        fac.append(0)
    while not n % i:
        n /= i
        fac[-1] += 1
if n > sqrt_n:
    fac.append(1)
num = 0
for f in fac:
    num += np.count_nonzero(f >= np.cumsum(range(1, f+1)))
print(num)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=[0]*3
for i in a:
  if i%4==0:ans[2]+=1
  elif i%2==0:ans[1]+=1
  else:ans[0]+=1
print(['No','Yes'][ans[0]+(ans[1]>0)<=ans[2]+1])
# Judge status: Accepted
n = int(input())
h = list(map(int,input().split()))

cnt = 0
lst = [0]
for i in range(n-1):
    if h[i] >= h[i+1]:
        cnt += 1
        lst.append(cnt)
    else:
        cnt = 0

print(max(lst))
# Judge status: Wrong Answer

n = int(input())
a = ""
b = 0
l = []

for i in range(1,n+1):
    a,b = map(str,input().split())
    b = int(b)
    l.append([a,b,i])
l.sort()

#pprint.pprint(l)

for i in range(n):
    print(l[i][2])
# Judge status: Accepted
#!/usr/bin/env python3
S = input()
a = S.find('A')
b = S.rfind('Z')
print(b - a + 1)
# Judge status: Wrong Answer
count = 0
a,b = map(int,input().split())
for i in range(1,a+1):
  for j in range(1,b+1):
    if i == j:
      count += 1
print(count)
# Judge status: Wrong Answer
a = list(map(str, input()))
b = list(map(str, input()))

if a[0] == b[0] and a[1] == b[1] and a[2] == b[2]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
S = input()

if S[:N//2]==S[N//2:]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

if N >= M:
    print(0)
    sys.exit()
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: Wrong Answer
n = int(input())
an = list(map(int, input().split()))
ans = 10*7
for i in range(min(an), max(an)+1):
    check = 0
    for a in an:
        check += (a-i)**2
    if ans >= check:
        ans = check
print(ans)
# Judge status: Wrong Answer

A = int(input())
B = [int(x) for x in input().split()]
count = 1
tanking = 0
ans = 0
flag = False
for i in range(A):
    if B[i] == count:
        count += 1
        ans += tanking
        tanking = 0
        flag = True
    else: 
        tanking += 1

if ans == 0 and not flag:print("-1")
else : print(ans)
# Judge status: Accepted
k,a,b=map(int,input().split())
if b-a<=2 or a>=k:
    print(1+k)
    exit()
bis=a
k-=a-1
bis+=k//2*(b-a)
if k%2==1:
    bis+=1
print(bis)
# Judge status: Accepted
def main():
    N, A, B = map(int, input().split())
    ans = []
    for i in range(1, N+1):
        tmp = list(str(i))
        tmplist = [int(x) for x in tmp]
        s = sum(tmplist)
        if A <= s <= B:
            ans.append(i)
    print(sum(ans))

if __name__ == "__main__":
    main()
# Judge status: Accepted
from sys import stdin

s = stdin.readline().rstrip()

ans = "Yes"
if len(s)%2 != 0:
    ans = "No"
else:
    for i in range(0, len(s), 2):
        if s[i] + s[i+1] != "hi":
            ans = "No"
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = [input() for _ in range(n)]

c = [s.count("AC"),s.count("WA"),s.count("TLE"),s.count("RE")]

print("AC","×",c[0])
print("WA","×",c[1])
print("TLE","×",c[2])
print("RE","×",c[3])
# Judge status: Wrong Answer
def resolve():
    N, M, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    ans = 0
    for z in range(X+1, Y+1):
        if max(x)<=z and z<=min(y):
            ans += 1
    print("No War" if ans != 0 else "War")
resolve()
# Judge status: Wrong Answer
n=int(input())
s=input()
c=0
for i in range(1,n):
  if(s[i]=='R'and s[i-1]=='R'):
    c+=1
print(c)
# Judge status: Accepted
import sys
D,T,S=map(int, sys.stdin.readline().split())
if D<=T*S:
    print "Yes"
else:
    print "No"
# Judge status: Wrong Answer
import numpy as np
from sys import stdin

def main():
  n = map(int,input().split())
  a = list(map(int, input().split()))
  print(a[0])
  b = np.argsort(a)+1
  str_ = ""
  for i in b:
    str_ = str_ + "{:d} ".format(i)  
  
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = int(input())
if N >= 999:
    print("ABC")
else:
    print("ABD")
# Judge status: Accepted
X,Y=map(int,input().split())
mod=pow(10,9)+7
m=(2*X-Y)//3
n=(2*Y-X)//3
if  m==(2*X-Y)/3 and n==(2*Y-X)/3 and m>=0 and n>=0:
    bunsi = 1
    bunbo = 1
    for i in range(0, n):
        bunsi = (bunsi * (m + 1 + i)) % mod
        bunbo = (bunbo * (1 + i)) % mod
    print((bunsi * pow(bunbo, mod - 2, mod)) % mod)

else:
    print(0)
# Judge status: Accepted
def ave(n):
    return (n+1)/2

n, k = map(int, input().split())
p = list(map(int, input().split()))

sum = 0

for i in range(k):
    sum += ave(p[i])

max_sum = sum

for i in range(n-k):
    sum -= ave(p[i])
    sum += ave(p[i+k])
    max_sum = max(sum, max_sum)

print(max_sum)
# Judge status: Accepted
n = int(input())
inf = 10**9
dp = [inf] * (n + 1)
dp[0] = 0

for i in range(1, n + 1):
    dp[i] = dp[i - 1] + 1
    mlp6 = 6
    while i - mlp6 >= 0:
        dp[i] = min(dp[i], dp[i - mlp6] + 1)
        mlp6 *= 6
    mlp9 = 9
    while i - mlp9 >= 0:
        dp[i] = min(dp[i], dp[i - mlp9] + 1)
        mlp9 *= 9
print(dp[-1])
# Judge status: Accepted
a,b,c=map(int,input().split());o=0
if a==b==c:print(a%2-1);exit()
while~-a*~-b*~-c%2:a,b,c=(b+c)//2,(c+a)//2,(a+b)//2;o+=1
print(o)
# Judge status: Wrong Answer
from heapq import heapify, heappop, heappush
N,*A=map(int, open(0).read().split())
A=sorted(A, reverse=True)
L=[0]*N
R=[0]*N
ans=0
L[0]=0
R[0]=0
H=[(A[0],0,0)]
heapify(H)
for i in range(1,N):
    a=A[i]
    p,pl,pr=heappop(H)
    ans+=p
    L[pr]=i
    R[pl]=i
    L[i]=pl
    R[i]=pr
    heappush(H,(min(A[pl],a),pl,i))
    heappush(H,(min(A[pr],a),i,pr))
print(ans)
# Judge status: Accepted
N = int(input())
X = list(map(int,input().split()))

X_max = X[0]
X_min = X[0]

for i in range(N):
    if X_max < X[i]:
        X_max = X[i]
    if X_min > X[i]:
        X_min = X[i]

min = 0
count = 0
for p in range(X_min, X_max+1, 1):
    total = 0
    for i in range(N):
        total += (X[i]-p)**2
    count += 1
    if count == 1:
        min = total
    elif  min > total:
        min = total

print(min)
# Judge status: Accepted
a, b, c = map(int, input().split())
for i in range(0, 101):
    if a > b or i == c:
        print(i)
        break
    b = b - a
# Judge status: Accepted
A,B=map(int,input().split())
if (A>9)|(B>9):
    print(-1)
else:
    print(A*B)
# Judge status: Accepted
import fractions
def gcd(x, y):
    gcd=fractions.gcd(x, y)
    return gcd

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

if n==1:
    print(abs(x-a[0]))

else:
    for i in range(n):
        a[i]=abs(x-a[i])
    
    ans=gcd(a[0], a[1])

    for i in range(2, n):
        ans=gcd(ans, a[i])
    
    print(ans)
# Judge status: Accepted
N,M=map(int,input().split())
box=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    box[a-1].append(b-1)
    box[b-1].append(a-1)
ans=[None]*(N)
ans[0]=0
que=[0]
while len(que)>0:
    index=que.pop(0)
    for x in box[index]:
        if ans[x]==None:
            ans[x]=index+1
            que.append(x)
print("Yes")
for i in range(1,N):
    print(ans[i])
# Judge status: Accepted
import fractions
import sys

def times_div2(n):
  times=0
  while(n%2==0):
    n//=2
    times+=1
  return times

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

aset=set()
tset=set()
for a in alist:
  aset.add(a)
  tset.add(times_div2(a))
  
if len(tset)>1:
  print(0)
  sys.exit(0)
  
lcm_a2s=1
for a in aset:
  a2=a//2
  lcm_a2s*=(a2)//fractions.gcd(lcm_a2s,a2)

#print(lcm_a2s)
print((M-lcm_a2s)//(2*lcm_a2s)+1)
# Judge status: Wrong Answer
import numpy as np
N=int(input())
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
max_count = 0
for i in range(1,N-1): # N字目で切った場合
  count_list = np.zeros(26)
  for k in range(i):
#    print(i,k,S[k],S[i:len(S)])
    if S[k] in S[i:len(S)]:
      count_list[s_list.index(S[k])] = count_list[s_list.index(S[k])] + 1
  if max_count < len([1 for x in count_list if x>0]):
    max_count = len([1 for x in count_list if x>0])
  print(count_list)
print(max_count)
# Judge status: Wrong Answer

A,B = input().split()
A = int(A)
B = int(B[0]+B[2:])
print(A*B//100)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    bn = 10**16
    for i in range(5):
        bn = min(bn, int(input()))
    print(n // bn + 5)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
H , W = map(int , input().split())
if H == 1:
    print(1)
elif(H * W ) % 2 == 0:
    print((H * W) // 2)

else:
    print((H * W) // 2 + 1 )
# Judge status: Accepted
n,m = map(int,input().split())
if(n%2==1):
    for i in range(1,m+1):
        print(' '.join(map(str,[i,n+1-i])))
    exit()

m1,m2 = (m+1)//2 ,m//2
sum1 = 1 + n//2
sum2 = (n//2+1) + (n-1)
for i in range(m1):
    print(' '.join(map(str,[1+i,n//2 -i])))
for i in range(m2):
    print(' '.join(map(str,[n//2+1+i,n-1-i])))
# Judge status: Accepted
S = input()

print('ARC' if S == 'ABC' else 'ABC')
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

D, N = map(int, input().rstrip().split())

if D == 0:
  print(N)
else:
  print(100 ** D * N)
# Judge status: Accepted
n = int(input())
count = 0
flag = False
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        count += 1
        if count == 3:
            flag = True
    else:
        count = 0
if flag:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
import numpy as np
rn=n**0.5
for ii in range(n):
  r=0
  for xx in np.arange(1,rn+1):
    for yy in np.arange(1,xx+1):
      for zz in np.arange(1,yy+1):
        if xx**2+yy**2+zz**2+xx*yy+xx*zz+yy*zz==n:
          r+=1
  print(r)
# Judge status: Wrong Answer
n = int(input())
if n%10==2 or 4 or 5 or 7 or 9:
  print("hon")
elif n%10==0 or 1 or 6 or 8:
  print("pon")
else:
  print("bon")
# Judge status: Accepted
a, b, x = map(int,input().split())

if a%x == 0 :
    first = a // x
else :
    first = ( a + x - a%x ) // x

if b%x == 0 :
    end = b // x
else :
    end = ( b - b%x ) // x

ans = end - first + 1

print(ans)
# Judge status: Wrong Answer
x=int(input())
if 360%x==0:
  print(360//x)
else:
  print(0)
# Judge status: Accepted
a,b,c,d = map(int,input().split())

if abs(a-c) <= d:
    print('Yes')

elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')

else:
    print('No')
# Judge status: Wrong Answer
S = input()
f,e = int(S[:2]),int(S[2:])
if f==0 or e==0 or (f>12 and e>12):
  print('NA')
  exit()
if 1<=f<=12:
  if e>12:
    print('MMYY')
  elif 1<=e<=12:
    print('AMBIGUOUS')
elif f>12:
  if 1<=e<=12:
    print('YYMM')
# Judge status: Accepted
if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    a, b, m = map(int, input().split())
    aa = list(map(int, input().split()))
    bb = list(map(int, input().split()))
    min_ab = min(aa) + min(bb)
    for _ in range(m):
        x, y, c = map(int, input().split())
        now = aa[x-1] + bb[y-1] - c
        if min_ab > now:
            min_ab = now
    print(min_ab)
# Judge status: Wrong Answer
a, b, c = input().split()

if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
w,h,x,y=map(int,input().split())


if 2*y==h and 2*x==w:
    print(h*w/2,1)
else:
    print(h*w/2,0)
# Judge status: Accepted
N=int(input())

dp=[]
mat=[]
for _ in range(2):
  array=list(map(int,input().split()))
  mat.append(array)
  dp.append([0]*N)
#print(mat)

for j in range(N):
  dp[0][j]=mat[0][j]+dp[0][j-1]
for j in range(N):
  dp[1][j]=mat[1][j]+max(dp[1][j-1],dp[0][j])

print(dp[-1][-1])
# Judge status: Accepted
from collections import deque
s = deque(input())
q = int(input())

cnt = 0
for _ in range(q):
    i = input().split()
    t = int(i[0])

    if t == 1:
        cnt += 1
    else:
        f = int(i[1])
        c = i[2]
        if (cnt % 2 == 0 and f == 1) or (cnt % 2 == 1 and f == 2):
            s.appendleft(i[2])
        else:
            s.append(i[2])

if cnt % 2 == 1:
    s.reverse()
print(''.join(s))
# Judge status: Wrong Answer
from collections import Counter
S = str(input())
S_ = Counter(S)
v,c =zip(*S_.most_common())
ans = 0
if len(c) == 1 and len(S) == 1:
  ans = 0
elif len(c) == 1 and len(S) > 1:
  ans = c[0]//2
elif len(c) > 1 and abs(c[1]-c[0]) == 1:
  ans = 0
elif len(c) > 1 and abs(c[1]-c[0]) != 1:
  ans = abs(c[1] - c[0])//2
print(ans)
# Judge status: Accepted
N = int(input())
ans = 'No'
for i in range(1, 10):
    for j in range(1, 10):
        if i * j == N:
            ans = 'Yes'
print(ans)
# Judge status: Wrong Answer
a,b,c = map(int, input().split())

if a % 2 == 0 or b % 2 == 0 or c % 2 == 0: print(0)
else:
  square = a*b*c/max(a,b,c)
  print(square)
# Judge status: Accepted
S = list(input())

ans = []
cnt = 0
for i in range(len(S)):
    if S[i] in ['A', 'C', 'G', 'T']:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)

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

if 400 <= a <= 599:
  print("8")
if 600 <= a <= 799:
  print("8")
if 800 <= a <= 999:
  print("8")  
if 1000 <= a <= 1199:
  print("8")
if 1200 <= a <= 1399:
  print("8")
if 1400 <= a <= 1599:
  print("8")
if 1600 <= a <= 1799:
  print("8")
if 1800 <= a <= 1999:
  print("8")
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

menuTimeList = [A, B, C, D, E]
menuExtraTimeList = [0, 0, 0, 0, 0]

maxExtraTime = 0
for i in range(5):
    extraTime = 0
    if menuTimeList[i] % 10 == 0:
        menuExtraTimeList[i] = 0 
    else:
        extraTime = 10 - menuTimeList[i] % 10
        menuExtraTimeList[i] = extraTime
    if maxExtraTime < extraTime:
        maxExtraTime = extraTime

answer = sum(menuTimeList) + sum(menuExtraTimeList) - maxExtraTime
print(answer)
# Judge status: Accepted
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 1
r = 1000000000
while l < r:
  m = (l+r)//2
  cnt = 0
  for i in a:
    c = math.ceil(i/m)-1
    cnt += c
  if cnt > k:
    l = m + 1
  else:
    r = m
print(l)
# Judge status: Accepted
s = input()
a = 1
f = 0
for i in s:
  if a == 1 and i == "L":
    print("No")
    f = 1
    break
  if a == 0 and i == "R":
    print("No")
    f = 1
    break
  a ^= 1
if f == 0:
  print("Yes")
# Judge status: Accepted
s=input()
s=s[::-1]
memo=[0]*2019
memo[0]=1
current=0

for i in range(len(s)):
    current+=int(s[i])*pow(10,i,2019)
    current%=2019
    memo[current]+=1

ans=0
for i in memo:
    if i>=2:
        ans+=i*(i-1)//2
print(ans)
# Judge status: Accepted
A,B,C = sorted(map(int, input().split()))
K = int(input())

print(A + B + C * 2**K)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

if a[0] == 1 and n != 1:
    print(-1)
    exit()

m = [1] * (n+1)
for i in range(1, n+1):
    m[i] = 2*m[i-1] - a[i]

    if (m[i] <= 0 and i != n) or (m[i] < 0 and i == n):
        print(-1)
        exit()

a.reverse()
m.reverse()
m[0] = a[0]
for i in range(1, n+1):
    m[i] = min(m[i], m[i-1]) + a[i]

print(sum(m))
# Judge status: Accepted
N = int(input())
L = list(map(int,input().split()))
L.sort(reverse=True)

cnt = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            c = L[i]
            b = L[j]
            a = L[k]
            if c < a+b and c > b-a and a != b and b != c and c != a:
                cnt += 1
print(cnt)
# Judge status: Accepted
import math
n = int(input())

min = n + 1
for i in range(1,int(math.sqrt(n))+5):
    if n%i==0:
        min = i + (n // i) if min > i + (n // i) else min

print(min - 2)
# Judge status: Wrong Answer
from math import sqrt
N = int(input())

ans = [0 for _ in range(N)]

num_m = (N-4)//2

for x in range(1, int(sqrt(N))+1):
    for y in range(1, int(sqrt(N))+1):
        for z in range(1, int(sqrt(N))+1):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n <= N-1:
                ans[n-1] += 1


print(*ans, sep="\n")
# Judge status: Accepted
n, k = map(int, input().split())
d = list(map(int, input().split()))
ok = [1] * 10
for i in d:
    ok[i] = 0

while 1:
    s = str(n)
    fin = 1
    for c in s:
        fin &= ok[int(c)]
    if fin:
        print(s)
        exit()
    n += 1
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
n = (a+b+c)//2
if n == max(a, b, c):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N,Q=map(int,input().split())
S=input()
s_cnt=[]
cnt=0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        cnt+=1
        s_cnt.append(cnt)
    else:
        s_cnt.append(cnt)
for i in range(Q):
    l,r=map(int,input().split())
    l-=2
    r-=2
    if l<1:
        print(s_cnt[r])
    else:    
        print(s_cnt[r] - s_cnt[l])
# Judge status: Accepted
from string import ascii_lowercase

def main():
    s = list(input())
    K = int(input())
    for i, c in enumerate(s):
        num = ord(c) - ord("a")

        if num > 0 and K - (26-num) >= 0:
            s[i] = "a"
            K -= (26-num)

    num = ord(s[-1]) - ord("a")
    last = (num + K)%26
    s[-1] = ascii_lowercase[last]
    print("".join(s))

        
if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
TS = []
for i in range(N):
    X, L = map(int, input().split())
    TS.append((X + L, X - L))
TS = sorted(TS)
cur = -10**10
ans = 0
for i in range(N):
    if cur <= TS[i][1]:
        ans += 1
        cur = TS[i][0]
print(ans)
# Judge status: Wrong Answer
n = int(input())
S = [int(input()) for _ in range(n)]

if sum(S)%10!=0:
    print(sum(S))
    exit()
ans = sum(S)
for i in range(n):
    if S[i]%10==0:
        continue
    ans -= S[i]
    if ans%10!=0:
        print(ans)
        exit()
print(0)
# Judge status: Accepted
H,W = map(int, input().split())
if W == 1 or H == 1:
  print(1)
elif H*W%2 == 0:
  print(H*W//2)
else:
  print(H*W//2+1)