Harryxun/stf_run huggingface dataset:
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  n,k = list(map(int,input().split()))
  #a = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = n
  zen = n
  count = 0
  lis = []
  
  if k == 1:
    print(0)
  elif k == 2:
    if n % 2 = 0:
      print(2)
    else:
      print(3)
  else:  
    while 1:
      hi = abs(ans-k)
      if hi < zen:
        zen = hi
        ans = hi
        
      else:
        print(ans)
        exit()
      
if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  n,k = list(map(int,input().split()))
  #a = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = n
  zen = n
  count = 0
  lis = []
  
  if k == 1:
    print(0)
  elif n <= abs(n-k):
    print(n)
  else:
    ans = n % k
    if ans > 2:
      while 1:
        hi = abs(ans-k)
        if hi < zen:
          zen = hi
          ans = hi

        else:
          print(ans)
          exit()
    else:
      print(ans)
    
      
if __name__ == '__main__':
  main()
n = int(input())
d = list(map(int, input().split()))
res = 0

d.sort()
first = d[0]

for i in range(1, n):
  if first < d[i]:
    res += 1
  first = d[i]
  
print(res)

### FIXED CODE ###

n = int(input())
d = [int(input()) for i in range(n)]
res = 1

d.sort()
first = d[0]

for i in range(1, n):
  if first < d[i]:
    res += 1
  first = d[i]
  
print(res)
n = int(input())
x = input()
popcount_x = x.count("1")
popcount_x1 = popcount_x + 1
popcount_x2 = popcount_x - 1


div1 = [0]*n
div2 = [0]*n
cur1 = 1
cur2 = 1
for i in range(n):
    cur1 %= popcount_x1
    cur2 %= popcount_x2
    div1[i] = cur1
    div2[i] = cur2
    cur1 *= 2
    cur2 *= 2


fn = [0]*n
for i in range(1,n):
    popcount = bin(i)[2:].count("1")
    fn[i] = fn[(i)%popcount] + 1

    
x_div1 = sum(int(x[i]) * div1[-i-1] for i in range(n)) % popcount_x1
x_div2 = sum(int(x[i]) * div2[-i-1] for i in range(n)) % popcount_x2

for i in range(n):
    if x[i] == "0": 
        xi_div = (x_div1 + div1[-i-1]) % popcount_x1
        print(fn[xi_div] + 1)
    else:
        xi_div = (x_div2 - div2[-i-1]) % popcount_x2
        print(fn[xi_div] + 1)

### FIXED CODE ###

n = int(input())
x = input()
popcount_x = x.count("1")
popcount_x1 = popcount_x + 1
popcount_x2 = popcount_x - 1

if popcount_x2 == 0: popcount_x2 = -1

div1 = [0]*n
div2 = [0]*n
cur1 = 1
cur2 = 1
for i in range(n):
    cur1 %= popcount_x1
    cur2 %= popcount_x2
    div1[i] = cur1
    div2[i] = cur2
    cur1 *= 2
    cur2 *= 2


fn = [0]*n
for i in range(1,n):
    popcount = bin(i)[2:].count("1")
    fn[i] = fn[(i)%popcount] + 1

    
x_div1 = sum(int(x[i]) * div1[-i-1] for i in range(n)) % popcount_x1
x_div2 = sum(int(x[i]) * div2[-i-1] for i in range(n)) % popcount_x2

for i in range(n):
    if x[i] == "0": 
        xi_div = (x_div1 + div1[-i-1]) % popcount_x1
        print(fn[xi_div] + 1)
    else:
        if popcount_x2 == -1:
            print(0)
        else:
            xi_div = (x_div2 - div2[-i-1]) % popcount_x2
            print(fn[xi_div] + 1)
N, *capacity = [int(input()) for _ in range(6)]

min_index = capacity.index(min(capacity))

ans = N // capacity[min_index]

if N <= capacity[0] and max(capacity) == capacity[0] and capacity[1:] not in capacity[0]:
    print(ans+4)
    exit()
print(ans+5)


### FIXED CODE ###

import math


N, *capacity = [int(input()) for _ in range(6)]

# min_index = capacity.index(min(capacity))

ans = math.ceil(N/min(capacity))

print(ans+4)
from collections import Counter
inp=list(map(int,input().split()))
l=inp[0]
r=inp[1]
c=Counter([])
arr=[]
for i in range(l,r+1):
  if c[i]==0:
    c[i]+=1
    arr.append(i)
    continue
  else:
    break
if c[0]!=0:
  print (0)
ans=99999999999
for i in range(len(arr)):
  for j in range(i+1,len(arr)):
    ans=min(ans,(i*j)%2019)
   	if ans==0:
      break
  if ans==0:
    break
print (ans)

### FIXED CODE ###

from collections import Counter
inp=list(map(int,input().split()))
l=inp[0]
r=inp[1]
c=Counter([])
arr=[]
for i in range(l,r+1):
    if c[(i%2019)]==0:
        c[(i%2019)]+=1
        arr.append((i%2019))
        continue
    else:
        break
if c[0]!=0:
    print (0)
else:
    ans=99999999999
    for i in range(len(arr)):
        for j in range(i+1,len(arr)):
            ans=min(ans,(arr[i]*arr[j])%2019)
            if ans==0:
                break
        if ans==0:
            break
    print (ans)
from math import ceil
N, P = map(int,input().split())
if N >= 40: print(1)
else:
  ans = 1
  for i in range(1,ceil(P ** (1 / N))):
    if P % ((i + 1) ** N) == 0:
      ans = i + 1
print(ans)      
                 

### FIXED CODE ###

from math import ceil
N, P = map(int,input().split())
if N >= 40: print(1)
elif N == 1: print(P)  
else:
  ans = 1
  for i in range(1,ceil(P ** (1 / N))):
    if P % ((i + 1) ** N) == 0:
      ans = i + 1
  print(ans)
m=24*60*60
while True:
	n=int(input())
	if n==0:break
	dp=[0]*(m+1)
	for _ in range(n):
		a,d=input().split()
#		a,b,c=map(int,a.split(':'));
#		d,e,f=map(int,d.split(':'));
#		dp[a*3600+b*60+c]+=1
#		dp[d*3600+e*60+f]-=1
	for i in range(m):
		dp[i+1]+=dp[i]
	print(max(dp))

### FIXED CODE ###

m=24*60*60
while True:
	n=int(raw_input())
	if n==0:break
	dp=[0]*(m+1)
	for _ in range(n):
		a,d=raw_input().split()
		a,b,c=map(int,a.split(':'));
		d,e,f=map(int,d.split(':'));
		dp[a*3600+b*60+c]+=1
		dp[d*3600+e*60+f]-=1
	for i in range(m):
		dp[i+1]+=dp[i]
	print(max(dp))
num = [int(n) for n in input().split(" ")]

a = num[1]
b = num[2]
c = num[3]

count = 0
for i in range(a, b+1):
    if c % i == 0:
        count += 1
print(count)
        

### FIXED CODE ###

num = [int(n) for n in input().split(" ")]

a = num[0]
b = num[1]
c = num[2]

count = 0
for i in range(a, b+1):
    if c % i == 0:
        count += 1
print(count)
A = input().split()
A = [int(n) for n in A]
for i in range(N):
  count = 0
  for j in range(N-1):
	if i+1 == A[j]:
	  count += 1
  print(count)

### FIXED CODE ###

N = int(input())
A =[int(n) for n in input().split()]
b = [0]*N
for i in A:
  b[i-1]+=1
for i in range(N):
  print(b[i])
n, a, b, c, d = list(map(int, input().split()))
s = input()
if d > c:
    for i in range(a, d-1):
        if (s[i-1] == "#") & (s[i] == "#"):
            print("No")
            break
    else:
        print("Yes")
else:
    for i in range(a, d):
        if (s[i-1] == "#") & (s[i] == "#"):
            print("No")
            break
    else:
        for j in range(b-1, min(c, n)):
            if (s[j-1] == ".") & (s[j] == ".") & (s[j+1] == "."):
                print("Yes")
                break
        else:
            print("No")

### FIXED CODE ###

n, a, b, c, d = list(map(int, input().split()))
s = input()
if d > c:
    for i in range(a, d-1):
        if (s[i-1] == "#") & (s[i] == "#"):
            print("No")
            break
    else:
        print("Yes")
else:
    for i in range(a, d):
        if (s[i-1] == "#") & (s[i] == "#"):
            print("No")
            break
    else:
        for j in range(b-1, d):
            if (s[j-1] == ".") & (s[j] == ".") & (s[j+1] == "."):
                print("Yes")
                break
        else:
            print("No")
# -*- coding: utf-8 -*-

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

answer_list = [0] * M
prefectures = [0] * (M+1)
data_set = [0] * M

data_set_dict = {}

for i in range(M):
	P, Y = map(int, input().split())
	data_set[i] = [P, Y, i]

data_set.sort()

for i in range(M):
	answer = ''
	P, Y, a = data_set[i]
	prefectures[P] += 1

	for j in range(6-len(list(str(P)))):
		answer += '0'

	answer += str(P)

	for j in range(6-len(list(str(prefectures[P])))):
		answer += '0'

	answer += str(prefectures[P])

	answer_list[a] = (answer)

for i in range(M):
	print(answer_list[i])

### FIXED CODE ###

# -*- coding: utf-8 -*-

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

answer_list = [0] * M
prefectures = [0] * (N+1)
data_set = [0] * M

for i in range(M):
	P, Y = map(int, input().split())
	data_set[i] = [P, Y, i]

data_set.sort()

for i in range(M):
	answer = ''
	P, Y, a = data_set[i]
	prefectures[P] += 1

	for j in range(6-len(list(str(P)))):
		answer += '0'

	answer += str(P)

	for k in range(6-len(list(str(prefectures[P])))):
		answer += '0'

	answer += str(prefectures[P])

	answer_list[a] = answer

for i in range(M):
	print(answer_list[i])
n = int(input())
print(math.ceil(n / 2) / n)


### FIXED CODE ###

import math
n = int(input())
print(math.ceil(n / 2) / n)
N= int(input())
S=[ input() for _ in range(N) ]

a=0
w=0
t=0
r=0

for i range(N):
  if S[i] =="AC":
    a+=1
  elif S[i] =="WA":
    w+=1
  elif S[i] =="TLE":
    t+=1
  elif S[i] =="RE":
    r+=1

print("AC x "+ str(a))
print("WA x "+ str(w))
print("TLE x "+ str(t))
print("RE x "+ str(r))


### FIXED CODE ###

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

a=0
w=0
t=0
r=0

for i in range(N):
  if S[i] =="AC":
    a+=1
  elif S[i] =="WA":
    w+=1
  elif S[i] =="TLE":
    t+=1
  elif S[i] =="RE":
    r+=1

print("AC x "+ str(a))
print("WA x "+ str(w))
print("TLE x "+ str(t))
print("RE x "+ str(r))
import math

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

ans = 0

if c % d == 0:
    print((b - a + 1) - (b//d - a//d))
elif d % c == 0:
    print((b - a + 1) - (b//c - a//c))
else:
    tot = c * d / math.gcd(c, d)
    tmp = (b // d - a // d) + (b//c - a//c) - (b // tot - a // tot)
    print(int((b - a + 1) - tmp))

### FIXED CODE ###

import fractions

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

ans = 0

if c % d == 0:
    print((b - a + 1) - ((b)//d - (a-1)//d))
elif d % c == 0:
    print((b - a + 1) - ((b)//c - (a-1)//c))
else:
    tot = c * d // fractions.gcd(c, d)
    tmp = ((b) // d - (a-1) // d) + ((b)//c - (a-1)//c) - ((b) // tot - (a-1) // tot)
    print(int((b - a + 1) - tmp))
import sys
input = sys.stdin.readline


class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0] * size

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


N = int(input())
G = [set() for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    G[a].add(b)
    G[b].add(a)
visited = [False] * N
visited[0] = True


def dfs(v):
    if v == N-1:
        return [N-1]
    for u in G[v]:
        if visited[u]:
            continue
        visited[u] = True
        ret = dfs(u)
        visited[u] = False
        if ret:
            return [v] + ret
    return None


path = dfs(0)
l = len(path)
u, v = 0, 0
if l % 2 == 0:
    u = path[l//2-1]
    v = path[l//2]
else:
    u = path[l//2]
    v = path[l//2+1]
G[u].remove(v)
G[v].remove(u)

uf = UnionFind(N)
for u in range(N):
    for v in G[u]:
        uf.unite(u, v)
fen = 0
snu = 0
for v in range(N):
    if uf.same(v, 0):
        fen += 1
    else:
        snu += 1
if fen > snu:
    print('Fennec')
else:
    print('Snuke')


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    G[a].append(b)
    G[b].append(a)


def dfs(v, dist):
    for u in G[v]:
        if dist[u] != -1:
            continue
        dist[u] = dist[v] + 1
        ret = dfs(u, dist)


dist_fen = [-1] * N
dist_fen[0] = 0
dfs(0, dist_fen)

dist_snu = [-1] * N
dist_snu[N-1] = 0
dfs(N-1, dist_snu)

fen = 0
for v in range(N):
    if dist_fen[v] <= dist_snu[v]:
        fen += 1
if fen > N // 2:
    print('Fennec')
else:
    print('Snuke')
n = int(input())
p = list(map(int,input().split()))
min_energy = 250000
for i range(100):
  energy = 0
  for k range(n):
    energy += (i+1-p[k])(i+1-p[k])
  if energy < min_energy:
    min_energy = energy
print(min_energy)

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)
A,B,K=map(int,input().split())

S=[]
for i in range(1,B+1):
  if A % i==0 and B%i==0:

    S.append(i)

print(S[K+1])

### FIXED CODE ###

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

S=[]
for i in range(1,B+1):
  if A % i==0 and B%i==0:

    S.append(i)

print(S[-K])
import sys
c = [0 for i in range(37)]
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                c[i+j+k+l] += 1
for line in sys.stdin:
    print(c[int(line)])

### FIXED CODE ###

import sys
t = [None for i in range(10000)]
c = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                t[c] = i + j + k + l 
                c += 1
for line in sys.stdin:
    print(t.count(int(line)))
n,k=map(int,input())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(2,n):
    for j in range(1,k):
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
        pront(dp[n-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(1,n):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-k),i))
print(dp[n-1])
import numpy as np
h,w=map(int,input().split())
icon=list()
for i in range(h):
    icon.append(list(input().split()))

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if icon[i][j]=='#':
            row[i]=True
            col[j]=True

for  i in range(h):
    if row[i]==True:
        for j in range(w):
            if col[j]==True:
                print(icon[i][j],end='')
        print()  

### FIXED CODE ###

n,i=map(int,input().split())
print(n+1-i)
N, K = [int(x) for x in input().split(' ')]
m = 10**9 + 7
import math
def combination(n, r):
  return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
  
n = min(K, N-K+1)
for k in range(1, n+1):
  print(combination(N-K+1, k) * combination(K-1, k-1) % m)


### FIXED CODE ###

S = input()
if all([S.count(x) == 2 for x in set(S)]):
  print("Yes")
else:
  print("No")
N=int(input())
if N==0:
    print(0)
elif N>0:
    a=0
    i=31
    while i>=0:
        if N%(2**i)==0:
            if i%2==1:
                a+=2**(i+1)+2**i
                break
            else:
                a+=2**i
                break
        else:
            if N>2**i:
                N-=2**i
                if i%2==1:
                    a+=2**(i+1)+2**i
                else:
                    a+=2**i
            i-=1
    print(int(format(a,2)))
else:
    a=0
    i=31
    while i>=0:
        if N%(2**i)==0:
            if i%2!=1:
                a+=2**(i+1)+2**i
                break
            else:
                a+=2**i
                break
        else:
            if -N>2**i:
                N+=2**i
                if i%2!=1:
                    a+=2**(i+1)+2**i
                else:
                    a+=2**i
            i-=1
    print(int(format(a,2)))


### FIXED CODE ###

N=int(input())
if N==0:
    N=0
elif N>0:
    n=format(N,"b")
    for i in range(10**9):
        if i==len(n):
            break
        elif i%2==1:
            if n[-i-1]=="1":
                N+=2**(i+1)
                n=format(N,"b")
else:
    N*=-1
    n=format(N,"b")
    for i in range(10**9):
        if i==len(n):
            break
        elif i%2==0:
            if n[-i-1]=="1":
                N+=2**(i+1)
                n=format(N,"b")
print(int(format(N,"b")))
import numpy as np
import itertools
 
H, W, K = list(map(int, input().split())) 
c = [input().split() for l in range(H)]
b=[]
d=[]
for m in range(len(c)):
  for item in c[m]:
    item_mod = item.replace("."  , "0")
    item_mod = item_mod.replace("#" , "1")
    b.append(item_mod)
  d.append(b)
  b=[]

C_arr = np.array(d , dtype = "int")
C_arr = C_arr.reshape((H,W))
 
In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertools.product([0,1] , repeat=W)))
 
ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])
 
    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)
 
    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()
 
    if ICO.count(1) == K:
      ans += 1
 
print(ans)

### FIXED CODE ###

H, W, K = list(map(int, input().split()))
 
c = [list(input()) for i in range(H)]
 
cnt = 0
for i in range(2**H):
    for j in range(2**W):
        cnt_black = 0
        for k in range(H):
            if (i >> k) & 1:
                continue
            for l in range(W):
                if (j >> l) & 1:
                    continue
                if c[k][l] == '#':
                    cnt_black += 1
        if cnt_black == K:
            cnt += 1
 
print(cnt)
def dfs(i, V, E):
    vi = V[i]
    for j, value in E[i].items():
        if V[j] > value + vi:
            V[j] = value + vi
            V = dfs(j, V, E)
    return V

INF = 10 ** 14
n = int(input())
V = [INF for _ in range(n + 1)]
E = [{} for _ in range(n + 1)]
for i in range(n - 1):
    ai, bi, ci = map(int, input().split())
    E[ai][bi] = ci
    E[bi][ai] = ci

q, k = map(int, input().split())
z = [list(map(int, input().split())) for _ in range(q)]
V[k] = 0

V = dfs(k, V, E)
for i in range(q):
    x, y = z[i]
    print(V[x] + V[y])


### FIXED CODE ###

def dfs(i, V, E):
    S = [i]
    while(len(S) > 0):
        vi = S.pop()
        d = V[vi]
        for j, value in E[vi].items():
            if V[j] > value + d:
                V[j] = value + d
                S.append(j)
    return V

INF = 10 ** 14
n = int(input())
V = [INF for _ in range(n + 1)]
E = [{} for _ in range(n + 1)]
for i in range(n - 1):
    ai, bi, ci = map(int, input().split())
    E[ai][bi] = ci
    E[bi][ai] = ci

q, k = map(int, input().split())
z = [list(map(int, input().split())) for _ in range(q)]
V[k] = 0

V = dfs(k, V, E)
for i in range(q):
    x, y = z[i]
    print(V[x] + V[y])
Input_list = list(input())

print(Input_list[int(input())-1])

### FIXED CODE ###

Input_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(Input_list[int(input())-1])
#coding UTF-8
from collections import Counter
n= int(input())#1行目のNを取得する
l=[input()for i in range(n)] #複数行の数値の入力を取得
c=cCounter(l)

print(len(c))

### FIXED CODE ###

#coding UTF-8
from collections import Counter
n= int(input())#1行目のNを取得する
l=[input()for i in range(n)] #複数行の数値の入力を取得
c=Counter(l)

print(len(c))
def main():
    N = int(input())
    restaurants = []
    for i in range(N):
        si, pi = input().split()
        restaurants.append([i+1, si, int(pi)])
    cities = sorted(set([restaurant[1] for restaurant in restaurants]))

    for city in cities:
        same_cities = []
        for restaurant in restaurants:
            if restaurant[1] == city:
                same_cities.append(restaurant)
        sorted_restaurants = sorted(same_cities, key=lambda restaurant: restaurant[2], reverse=True)
        [print(restaurant[0]) for restaurant in sorted_restaurants]


if __name__ == '__main__':
    main()


### FIXED CODE ###


def main():
    A, P = [ int(x) for x in input().split() ]
    n = (A * 3 + P) / 2
    print(int(n))

if __name__ == '__main__':
    main()
N= input()
S= input()







Len = len(S)#文字数の長さ
LIST = list(S)#文字列を1文字ごとに分割する。

ANSWER = ""
#リストの中身をループ
for SS in LIST:
    NUNBER = ord(SS)#アスキーコードを出す組み込み関数:1文字しか対応していない
    NUNBER = NUNBER -65#アスキーコードからアルファベット順に変更
    AFFTER = NUNBER + N
    LAST  = AFFTER % 26
   # if LAST == 0:
    #    LAST = 26
    LAST  = chr(LAST+65)#アスキーコードからアルファベットに戻す
    ANSWER = ANSWER + LAST
    
print(ANSWER)


### FIXED CODE ###

N= input()
S= input()


N = int(N)
Len = len(S)#文字数の長さ
LIST = list(S)#文字列を1文字ごとに分割する。

ANSWER = ""
#リストの中身をループ
for SS in LIST:
    NUNBER = ord(SS)#アスキーコードを出す組み込み関数:1文字しか対応していない
    NUNBER = NUNBER -65#アスキーコードからアルファベット順に変更
    AFFTER = NUNBER + N
    LAST  = AFFTER % 26
    LAST  = chr(LAST+65)#アスキーコードからアルファベットに戻す
    ANSWER = ANSWER + LAST
    
print(ANSWER)
n = int(input())
ans = []
for x in range(2,n//2+1):
    y = n-x
    X = sum(list(map(int, list((str(x))))))
    Y = sum(list(map(int, list((str(y))))))
    ans.append(X+Y)
print(min(ans))

### FIXED CODE ###

n = int(input())
N = n//2
ans = float("INF")
for i in range(1,N+1):
  a,b = list(str(i)), list(str(n-i))
  A,B = sum(list(map(int, a))), sum(list(map(int, b)))
  if ans > A+B: ans = A+B
print(ans)
n = int(input())
a = list(map(int,input().split()))
import math
b = [math.log10(i) for i in a]    
if sum(b)>18:
    print(-1)
else:
    z = 1
    for i in a:
        z*=i
    if z>10**18:
        print(-1)
    else:
        print(z)

### FIXED CODE ###

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

if sorted(a)[0]==0:
    print(0)
else:
    import math
    b = [math.log10(i) for i in a if i!=0]    
    if sum(b)>18:
        print(-1)
    else:
        z = 1
        for i in a:
            z*=i
        if z>10**18:
            print(-1)
        else:
            print(z)
n = int(input())
nums = [int(i) for i in input().split()]
ans = 0
while True:
    if [i for i in nums if i % 2 == 1]:
        break
    nums = [i//2 for i in nums]
    ans += 1
print(ans)

### FIXED CODE ###

s = input()
print(s.count("1"))
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = read().rstrip().decode()

if N isupper():
	print('A')
else:
	print('a')


### FIXED CODE ###

S = input() # 標準入力がStringの場合
if S.isupper():
  print('A')
else:
  print('a')
import sys

alphabet = "abcdefghijklmnopqrstuvwxyz"
a_len = len(alphabet)
table = {c: idx for idx, c in enumerate(alphabet)}

rl = sys.stdin.readline
s = rl().rstrip()
k = int(rl())

ans = ""
for i in range(len(s[:-1])):
    gap = a_len - table[s[i]]
    if gap <= k:
        ans += "a"
        k -= gap
    elif k == 0:
        ans += s[i:-1]
    else:
        ans += s[i]

ans += alphabet[(table[s[-1]] + k) % a_len]
print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = rl().rstrip()
    K = int(rl())
    
    ans = []
    for si in s:
        if si == 'a':
            ans.append('a')
            continue
        cnt = ord('z') - ord(si) + 1
        if cnt <= K:
            ans.append('a')
            K -= cnt
        else:
            ans.append(si)
    
    ans[-1] = chr(ord('a') + (ord(ans[-1]) - ord('a') + K % 26) % 26)
    print(''.join(ans))


if __name__ == '__main__':
    solve()