Problem:


Score : 400 points

Problem Statement

Mr. Takahashi has a string s consisting of lowercase English letters.
He repeats the following operation on s exactly K times.

Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.

For example, if you perform an operation for the second letter on aaz, aaz becomes abz.
If you then perform an operation for the third letter on abz, abz becomes aba.

Mr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.
Find the such string.

Constraints

1≤|s|≤10^5

All letters in s are lowercase English letters.

1≤K≤10^9

Input

The input is given from Standard Input in the following format:

s
K

Output

Print the lexicographically smallest string after performing exactly K operations on s.

Sample Input 1

xyz
4

Sample Output 1

aya

For example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.

Sample Input 2

a
25

Sample Output 2

z

You have to perform exactly K operations.

Sample Input 3

codefestival
100

Sample Output 3

aaaafeaaivap



Sample input:
xyz
4


Sample output:
aya

Submission status: Wrong Answer

Solution code:
import string
alp=string.ascii_lowercase
s=input()
k=int(input())
ans=''
i=0
while k>0 and i<len(s)-1:
    d=(26-alp.index(s[i]))%26
    if d<=k:
        k-=d
        ans+='a'
    else:
        ans+=s[i]
    i+=1
if k>0:
    ans+=alp[(alp.index(s[-1])+k%26)%26]
else:
    ans+=s[-1]
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
A={}
for i in range(26):
  A[chr(ord('a')+i)]=26-i
C=[]
for ss in s:
  C.append(A[ss])
ans=""
for i in range(len(s)):
  if i==len(s)-1:
    k%=26
    if ord(s[-1])+k>122:
      ans+=chr(ord(s[-1])+k-26)
    else:
      ans+=chr(ord(s[-1])+k)
  elif k>=C[i]:
    ans+="a"
    k-=C[i]
  else:
    ans+=s[i]
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    K = int(input())
    a = ord("a")
    code = [ord(c) - a for c in s]
    for i in range(len(s)):
        x = 26 - code[i] % 26
        if x <= K:
            code[i] = 0
            K -= x
    code[-1] = code[-1] + K % 26
    ans = "".join([chr(a + x) for x in code])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# 入力
s = input()
K = int(input())

# 先頭文字から順に可能な限りaにする
# 余った操作回数はすべて末尾文字に適用する
t = list(s)
L = K
for i in range(len(s)):
    d = 123 - ord(s[i])
    if d <= L:
        t[i] = 'a'
        L -= d
t[-1] = chr((ord(t[-1]) - 97 + L) % 26 + 97)
ans = ''.join(t)

# 出力
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
C - 次のアルファベット / Next Letter
https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c

"""
import sys

from string import ascii_lowercase

def solve(s, K):
    ans = []
    for ch in s:
        distance = ascii_lowercase[::-1].index(ch) + 1
        if distance <= K:
            K -= distance
            ans.append('a')
        else:
            ans.append(ch)
    ans[-1] = ascii_lowercase[(ord(ans[-1]) - ord('a') + K) % 26]
    return ''.join(ans)


def main(args):
    s = input()
    K = int(input())
    ans = solve(s, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
def main() :
    s = input()
    K = int(input())
    ord_z = ord('z')

    for i in range(len(s)) :
        need_manipulation = ord_z - ord(s[i]) + 1
        # if (s[i] == 'a' ) :
        #     continue

        if (need_manipulation <= K) :
            # s[i] = 'a'
            s = s[:i] + 'a' + s[i+1:]
            K -= need_manipulation
        else :
            # 操作可能数が足りないときは、次の文字を小さくする
            continue
    
    if (K > 0) :
        # 操作可能数が残った場合は最後の文字で帳尻あわせする
        mani = K % 26
        if (mani + ord(s[-1]) > ord_z) :
            o = ord('a') + (mani + ord(s[-1]) - ord_z)
            # s[-1] = chr(o)
            s = s[:-1] + chr(o)
        else :
            o = ord(s[-1]) + mani
            # s[-1] = chr(o)
            s = s[:-1] + chr(o)

    print(s)


main()

Submission status: Wrong Answer

Solution code:
def main() :
    s = input()
    K = int(input())
    ord_z = ord('z')

    for i in range(len(s)) :
        need_manipulation = ord_z - ord(s[i]) + 1
        # if (s[i] == 'a' ) :
        #     continue

        if (need_manipulation <= K) :
            # s[i] = 'a'
            s = s[:i] + 'a' + s[i+1:]
            K -= need_manipulation
        else :
            # 操作可能数が足りないときは、次の文字を小さくする
            continue
    

    print(s)
    if (K > 0) :
        # 操作可能数が残った場合は最後の文字で帳尻あわせする
        mani = K % 26
        if (mani + ord(s[-1]) > ord_z) :
            o = ord('a') + (mani + ord(s[-1]) - ord_z)
            # s[-1] = chr(o)
            s = s[:-1] + chr(o)
        else :
            o = ord(s[-1]) + mani
            # s[-1] = chr(o)
            s = s[:-1] + chr(o)

    print(s)


main()

Submission status: Wrong Answer

Solution code:
a = list(map(str, input()))
b = int(input())

for i in range(len(a)):
    if a[i] == 'a':
        continue
    else:
        s = ord(a[i]) - 96
        if 27 - s <= b:
            a[i] = 'a'
            b -= 27 - s

if b != 0:
    a[-1] = chr(((ord(a[-1]) - 96 + b) % 27) + 96)

print(''.join(a))

Submission status: Wrong Answer

Solution code:
s,k=open(0)
k=int(k)
*l,=map(ord,s)
for i,t in enumerate(l):
  j=(19-t)%26
  if j<=k:k-=j;l[i]=97
l[-2]+=k%26
print(*map(chr,l),sep='')

Submission status: Wrong Answer

Solution code:
s,k=open(0)
k=int(k)
*l,=map(ord,s)
for i,t in enumerate(l):
  j=(19-t)%26
  if j<=k:k-=j;l[i]=97
l[-1]+=k%26
print(*map(chr,l),sep='')

Submission status: Wrong Answer

Solution code:
s = input().strip()
k = int(input())

ans = ''
for _s in s[:-1]:
  if _s == 'a':
    continue
  if 26 - ord(_s) + ord('a') <= k:
    ans += 'a'
    k -= 26 - ord(_s) + ord('a')
  else:
    ans += _s

ans += chr(ord('a') + (ord(s[-1]) - ord('a') + k) % 26)

print(ans)

Submission status: Wrong Answer

Solution code:
s = input().strip()
k = int(input())

ans = ''
for _s in s[:-1]:
  if 26 - ord(_s) + ord('a') <= k:
    ans += 'a'
    k -= 26 - ord(_s) + ord('a')
  else:
    ans += _s

ans += chr(ord('a') + (ord(s[-1]) - ord('a') + k) % 26)

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
x=[i-96for i in map(ord,s)]
#print(x)
n=int(input())
for i in range(len(s)):
    if 26-x[i]+1<=n:
        n-=26-x[i]+1
        x[i]=1
#print(x,n)
x[-1]+=n%26
print("".join(map(chr,[i+96 for i in x])))

Submission status: Wrong Answer

Solution code:
alp = "abcdefghijklmnopqrstuvwxyz"
d = dict(zip(alp,range(1,27)))
s = input()
k = int(input())
ans = ""
for i in s[:-1]:
  if 27-d[i] <= k:
    ans += "a"
    k -= 27-d[i]
  else:
    ans += i
ans += alp[(alp.index(s[-1])+k)%26]
print(ans)

Submission status: Wrong Answer

Solution code:
ord_a = ord('a')

ss = input()
K = int(input())

As = [ord(s) - ord_a for s in ss]

anss = []
for A in As[:-1]:
    num = 26 - A
    if K >= num:
        anss.append(0)
        K -= num
    else:
        anss.append(A)

anss.append((As[-1] + K) % 26)

print(''.join([chr(ans + ord_a) for ans in anss]))

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())


Costs = {chr(98 + i): (25 - i) for i in range(25)}
Costs['a'] = 0
alphabets = [chr(97 + i) for i in range(26)]


ans = ""
for i in range(len(S)):
    s = S[i]
    if K >= Costs[s]:
        K -= Costs[s]
        ans += 'a'
    else:
        ans += s

if K:
    K %= 26
    ans = ans[:-1] + alphabets[(alphabets.index(S[-1]) + K) % 26]
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())


Costs = {chr(98 + i): (25 - i) for i in range(25)}
Costs['a'] = 0
alphabets = [chr(97 + i) for i in range(26)]


ans = ""
for i in range(len(S)):
    s = S[i]
    if K >= Costs[s]:
        K -= Costs[s]
        ans += 'a'
    else:
        ans += s

if K:
    ans = ans[:-1] + alphabets[(alphabets.index(S[-1]) + K) % 26]
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())


Costs = {chr(98 + i): (25 - i) for i in range(25)}
Costs['a'] = 0
alphabets = [chr(97 + i) for i in range(26)]


ans = ""
for i in range(len(S)):
    s = S[i]
    if K >= Costs[s]:
        K -= Costs[s]
        ans += 'a'
    else:
        ans += s


ans = ans[:-1] + alphabets[(alphabets.index(S[-1]) + K) % 26]
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())


Costs = {chr(98 + i): (25 - i) for i in range(25)}
Costs['a'] = 0
alphabets = [chr(97 + i) for i in range(26)]


ans = ""
for i in range(len(S)):
    s = S[i]
    if K >= Costs[s]:
        K -= Costs[s]
        ans += 'a'
    else:
        ans += s

if K:
    K %= 26
    tail = S[-1]
    ans = ans[:-1] + alphabets[(alphabets.index(tail) + K) % 26]

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())


Costs = {chr(98 + i): (25 - i) for i in range(25)}
Costs['a'] = 0


ans = ""
for i in range(len(S) - 1):
    s = S[i]
    if K >= Costs[s]:
        K -= Costs[s]
        ans += 'a'
    else:
        ans += s

if K:
    tail = S[-1]
    tail_ord = ord(tail)
    tail_ord -= 97
    ans = ans + chr((tail_ord + K) % 26 + 97)

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())


Costs = {chr(98 + i): (25 - i) for i in range(25)}
Costs['a'] = 0


ans = ""
for i in range(len(S)):
    s = S[i]
    if K >= Costs[s]:
        K -= Costs[s]
        ans += 'a'
    else:
        ans += s

if K:
    tail = ans[-1]
    tail_ord = ord(tail)
    ans = ans[:-1] + chr((tail_ord + K) % 97 + 97)

print(ans)

Submission status: Wrong Answer

Solution code:
d1={'a':26,
'b':25,
'c':24,
'd':23,
'e':22,
'f':21,
'g':20,
'h':19,
'i':18,
'j':17,
'k':16,
'l':15,
'm':14,
'n':13,
'o':12,
'p':11,
'q':10,
'r':9,
's':8,
't':7,
'u':6,
'v':5,
'w':4,
'x':3,
'y':2,
'z':1}
d2=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a']
s=list(input())
k=int(input())
lens=len(s)
ans=''
ind=1
for i in s:
  if ind==lens:
    ans+=d2[(d2.index(i)+k)%26]
  elif k>=d1[i]:
    k-=d1[i]
    ans+='a'
  else:
    ans+=i
  ind+=1
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
N = int(input())
newS = []
for s in S:
    dis = 26 - (ord(s) - ord('a')) % 26
    if N >= dis:
        newS.append('a')
        N -= dis
    else:
        newS.append(s)
newS[-1] = chr(ord(newS[-1]) + N % 26)
print(''.join(newS))

Submission status: Wrong Answer

Solution code:
S = input()
N = int(input())
newS = []
for s in S:
    dis = 26 - (ord(s) - ord('a'))
    if N >= dis:
        newS.append('a')
        N -= dis
    else:
        newS.append(s)
N %= 26
newS[-1] = chr(ord(newS[-1]) + N)
print(''.join(newS))

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
ans = []
for i in range(len(s)):
  toa =(ord('z')-ord(s[i]))+1
  if toa <= k:
    k -= toa 
    ans += 'a'
  else: ans += s[i]

if k == 0:print("".join(ans))
else: 
  rest = k%26
  tmp = ord(ans[-1])+rest
  if tmp >122:
    tmp -= 26
  ans[-1] = chr(tmp)
  print("".join(ans))

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
ans = []
for i in range(len(s)):
  toa =(ord('z')-ord(s[i]))+1
  if toa <= k:
    k -= toa 
    ans += 'a'
  else: ans += s[i]

if k == 0:print(ans)
else: 
  rest = k%26
  tmp = ord(ans[-1])+rest
  if tmp >122:
    tmp -= 26
  ans[-1] = chr(tmp)
  print("".join(ans))

Submission status: Wrong Answer

Solution code:
a=ord('a')
alpha=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

s=input()
K=int(input())
a=ord('a')
N=len(s)
L=[0]*N
t=K
for i in range(N):
    L[i]=ord(s[i])-a
i=0
while i<N:
    #print(L)
    if t>=26-L[i]:
        t=t-(26-L[i])
        L[i]=0
    i+=1
    if t==0:
        break
L[-1]=(L[-1]+t)%26
x=''
for i in range(N):
    x+=alpha[L[i]]
print(x)

Submission status: Wrong Answer

Solution code:
s = list( input())
l = len(s)
K = int( input())
for i in range(l-1):
    if ord("z") - ord(s[i]) + 1 <= K:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"
s[l-1] = chr( ( ord(s[l-1]) - ord("a") + K)%26 + ord("a"))
print("".join(s))

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())
N = len(s)

abc = 'abcdefghijklmnopqrstuvwxyz'
abc_to_num = {abc[_]: _ for _ in range(26)}

ans = ''
for i in range(N):
    if (26 - abc_to_num[s[i]]) % 26 > K or i == N - 1:
        ans += s[i]
    else:
        ans += 'a'
        K -= 26 - abc_to_num[s[i]]
ans = ans[:-1] + abc[(abc_to_num[ans[-1]] + K) % 26]
print(ans)

Submission status: Wrong Answer

Solution code:
A=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
Num=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]

s=list(input())
K=int(input())

S=[]
for i in range(len(s)):
    for j in range(26):
        if s[i]==A[j]:
            S.append(Num[j])

for a in range(len(S)-1):
    if (26-S[a])%26<=K:
        K-=(26-S[a])
        S[a]=(S[a]+(26-S[a]))%26

S[len(S)-1]=(S[len(S)-1]+K)%26
#print(S)

for x in range(len(S)):
    for y in range(26):
        if S[x]==Num[y]:
            S[x]=A[y]
print("".join(S))

Submission status: Wrong Answer

Solution code:
s=input()
N=len(s)
K=int(input())
a="abcdefghijklmnopqrstuvwxyz"
S=[]
A=list(a)
for i in range(N-1):
  if s[i]!="a":
    k=A.index(s[i])
    if K>=26-k:
      S.append("a")
      K-=26-k
    else:
      S.append(s[i])
  else:
    S.append("a")
if K>0:
  k=A.index(s[N-1])
  S.append(A[(k+K)%26])
print("".join(S))

Submission status: Wrong Answer

Solution code:
s=input()
K=int(input())
S=list(ord(s[i]) for i in range(len(s)))

for i in range(len(s)):
    if i!=len(s):
        if S[i]!=97 and 123-S[i]<=K:
            K-=123-S[i]
            S[i]=97
    if i==len(s):
        m=K%26
        S[i]+=m
        if S[i]>=123:
            S[i]=S[i]-123+97
T=""
for i in range(len(s)):
    T+=chr(S[i])
print(T)

Submission status: Wrong Answer

Solution code:
s=list(input())
k=int(input())
al=list('abcdefghijklmnopqrstuvwxyz')
n=0
while k>0:
    if n==len(s)-1:k=k%26
    if 26-al.index(s[n])<=k and s[n]!='a':
        k-=26-al.index(s[n])
        s[n]='a'
        n=min(len(s)-1,n+1)
    else:
        if n<len(s)-1:n+=1
        else:
            s[n]=al[al.index(s[n])+k]
            k=0
print(''.join(s),k,n)

Submission status: Wrong Answer

Solution code:
s=list(input())
k=int(input())
al=list('abcdefghijklmnopqrstuvwxyz')
n=0
while k>0:
    if n==len(s)-1:k=k%26
    if 26-al.index(s[n])<=k:
        k-=26-al.index(s[n])
        s[n]='a'
        n=min(len(s)-1,n+1)
    else:
        if n<len(s)-1:n+=1
        else:
            s[n]=al[al.index(s[n])+k]
            k=0
print(''.join(s))

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
f=lambda x:123-ord(x)
h=lambda x:ord(x)-97
g=lambda x:chr((ord(x)-97+k)%26+97)

b=[]
for i in s:
  cost=f(i)
  if cost<=k:
    b.append("a")
    k-=cost
  else:
    b.append(i)
if k:b[-1]=g(b[-1])
print("".join(b))

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
f=lambda x:123-ord(x)
h=lambda x:ord(x)-97
g=lambda x,k:chr(97+((h(x)+(k%26))%26))

b=[]
for i in s:
  cost=f(i)
  if cost<=k:
    b.append("a")
    k-=cost
  else:
    b.append(i)
if k:b[-1]=g(b[-1],k)
print("".join(b))

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
f=lambda x:123-ord(x)
g=lambda x:chr(97+(ord(x)-97+(k%26))%26)
b=[]
for i in s:
  cost=f(i)
  if cost<=k:
    b.append("a")
    k-=cost
  else:
    b.append(i)
if k:b[-1]=g(b[-1])
print("".join(b))

Submission status: Wrong Answer

Solution code:
def c_next_letter(S, K):
    s = list(S)
    for t, elem in enumerate(s):
        if t == len(s) - 1 and K > 0:
            # 末尾に来たときに操作回数が残っていたら、その回数だけ操作する
            s[t] = chr(ord('a') + (ord(elem) - ord('a') + K) % 26)
        elif ord('z') - ord(elem) + 1 <= K:
            # K回以下の操作で'a'にできるなら、そうする
            s[t] = 'a'
            K -= ord('z') - ord(elem) + 1
    ans = ''.join(s)
    return ans

S = input()
K = int(input())
print(c_next_letter(S, K))

Submission status: Wrong Answer

Solution code:
alp = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
       "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
s = list(input())
k = int(input())
a = 0
while k > 0:
    for i in range(26):
        if alp[i] == s[a]:
            t = i
            break
    if a == len(s) - 1:
        s[a] = alp[(t + k) % 26]
        break
    elif 26 - t <= k:
        s[a] = "a"
        k -= 26 - t
    a += 1
print("".join(s))

Submission status: Wrong Answer

Solution code:
s = list(input())
K = int(input())
i = 0
if len(s) > 1:
    while True:
        if i >= len(s):
            break
        if 122 - ord(s[i]) + 1 <= K:
            K -= (122 - ord(s[i]) + 1)
            s[i] = 'a'
        i += 1
    K = K % 26
    s[-1] = chr(ord(s[-1]) + K)
    
elif len(s) == 1:
    if 122 - ord(s[0]) + 1 <= K:
        K -= (122 - ord(s[0]) + 1)
        s[0] = 'a'
    K = K % 26
    s[0] = chr(ord(s[0]) + K)

for i in s:
    print(i, end = "")
print()

Submission status: Wrong Answer

Solution code:
s = list(input())
K = int(input())
i = 0
if len(s) > 1:
    while True:
        if i >= len(s):
            break
        if 122 - ord(s[i]) + 1 <= K:
            K -= (122 - ord(s[i]) + 1)
            s[i] = 'a'
        i += 1
    K = K % 26
    s[len(s) - 1] = chr(ord(s[len(s) - 1]) + K)
    
elif len(s) == 1:
    if 122 - ord(s[0]) + 1 <= K:
        K -= (122 - ord(s[0]) + 1)
        s[0] = 'a'
    K = K % 26
    s[0] = chr(ord(s[0]) + K)

for i in s:
    print(i, end = "")
print()

Submission status: Wrong Answer

Solution code:
s = list(input())
K = int(input())
i = 0
if len(s) > 1:
    while True:
        if i >= len(s):
            break
        if 122 - ord(s[i]) + 1 <= K:
            K -= (122 - ord(s[i]) + 1)
            s[i] = 'a'
        i += 1
    K = K % 26
    s[len(s) - 1] = chr(ord(s[len(s) - 1]) + K)
    
elif len(s) == 1:
    if 122 - ord(s[i]) + 1 <= K:
        K -= (122 - ord(s[i]) + 1)
        s[i] = 'a'
    K = K % 26
    s[0] = chr(ord(s[0]) + K)

for i in s:
    print(i, end = "")
print()

Submission status: Wrong Answer

Solution code:
def change(s):
    if ord(s) != 122:
        return chr(ord(s) + 1)
    return "a"
s = list(input())
K = int(input())
i = 0
if len(s) > 1:
    while True:
        if i >= len(s):
            break
        if 122 - ord(s[i]) + 1 <= K:
            K -= (122 - ord(s[i]) + 1)
            s[i] = 'a'
        i += 1

    while True:
        if K <= 0:
            break
        s[len(s) - 1] = change(s[len(s) - 1])
        K -= 1
elif len(s) == 1:
    while True:
        if K <= 0:
            break
        s[0] = change(s[0])
        K -= 1

for i in s:
    print(i, end = "")
print()

Submission status: Wrong Answer

Solution code:
def change(s):
    if ord(s) != 122:
        return chr(ord(s) + 1)
    return "a"
s = list(input())
K = int(input())
i = 0
if len(s) > 0:
    while True:
        if i >= len(s):
            break
        if 122 - ord(s[i]) + 1 <= K:
            K -= (122 - ord(s[i]) + 1)
            s[i] = 'a'
        i += 1

    while True:
        if K <= 0:
            break
        s[len(s) - 1] = change(s[len(s) - 1])
        K -= 1
elif len(s) == 0:
    while True:
        if K <= 0:
            break
        s[0] = change(s[0])

for i in s:
    print(i, end = "")
print()

Submission status: Wrong Answer

Solution code:
import string
alph = string.ascii_lowercase * 2
s = input()
k = int(input())

needed = 0
ind_list = []
for i in range(len(s)):
	ind_list.append(alph.index(s[i]))
	if ind_list[-1] != 0:
		needed += 26 - ind_list[-1]

if needed <= k:
	mod = (k - needed) % 26
	print("a" * (len(s) - 1) + alph[mod])
else:
	ans = []
	for i in range(len(s) - 1):
		if k == 0:
			ans.append(s[i])
			continue
		if k >= 26 - ind_list[i]:
			ans.append("a")
			k -= 26 - ind_list[i]
		else:
			ans.append(s[i])

	if k == 0:
		ans.append(s[-1])
	else:
		ans.append(alph[(ind_list[-1] + k) % 26])

	print(*ans, sep="")

Submission status: Wrong Answer

Solution code:
S = list(input())
k = int(input())

for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= k:
        S[i] = 'a'
        k -= (ord('z') - ord(s) + 1) % 26

S[-1] = chr((ord(S[-1]) + k) % ord('a') % 26 + ord('a'))

print(str().join(S))

Submission status: Wrong Answer

Solution code:
S = list(input())
k = int(input())

for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= k:
        S[i] = 'a'
        k -= (ord('z') - ord(s) + 1)

S[-1] = chr((ord(S[-1]) + k) % ord('a') % 26 + ord('a'))

print(str().join(S))

Submission status: Wrong Answer

Solution code:
S = list(input())
k = int(input())

for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= k:
        S[i] = 'a'
        k -= (ord('z') - ord(s) + 1)

S[-1] = chr((ord(S[-1]) + (k % 26)) % ord('a') % 26 + ord('a'))

print(str().join(S))

Submission status: Wrong Answer

Solution code:
S = list(input())
k = int(input())

for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= k:
        S[i] = 'a'
        k -= (ord('z') - ord(s) + 1)

S[-1] = chr((ord(S[-1]) + (k % 26)) % ord('a') + ord('a'))

print(str().join(S))

Submission status: Wrong Answer

Solution code:
S = list(input())
k = int(input())

for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= k:
        S[i] = 'a'
        k -= ord('z') - ord(s) + 1

S[-1] = chr((ord(S[-1]) + (k % 26)) % ord('a') + ord('a'))

print(str().join(S))

Submission status: Wrong Answer

Solution code:
S = list(input())
k = int(input())

for i, s in enumerate(S):
    if ord('z') - ord(s) + 1 <= k:
        S[i] = 'a'
        k -= ord('z') - ord(s) + 1

S[-1] = chr(ord(S[-1]) + (k % 26)) 

print(str().join(S))

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
cost = [ord("z") - ord(s) + 1 for s in S]
A = [chr(ord("a") + i) for i in range(26)]

ans = ""
for i in range(len(S)-1):
    if cost[i] <= K:
        K -= cost[i]
        ans += "a"
    else:
        ans += S[i]

ans += A[(A.index(S[-1]) + K) % 26]
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
cost = [ord("z") - ord(s) + 1 for s in S]

ans = ""
for i in range(len(S)):
    if cost[i] <= K:
        K -= cost[i]
        ans += "a"
    else:
        ans += S[i]

ans = ans[:-1] + chr(ord(ans[-1]) + K % 26)
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())

sArr = list(s)
endpoint = len(sArr) - 1
result = ""

for i in range(len(sArr)):
    if (123 - ord(sArr[i])) <= K:
        K -= (123 - ord(sArr[i]))
        sArr[i] = "a"

if K > 0:
    K %= 26
    sArr[endpoint] = chr(ord(sArr[endpoint]) + K)

for j in range(len(sArr)):
    result += sArr[j]

print(result)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())

sArr = list(s)
endpoint = len(sArr) - 1
result = ""

for i in range(len(sArr)):
    if (123 - ord(sArr[i])) <= K:
        K -= (123 - ord(sArr[i]))
        sArr[i] = "a"

if K > 0:
    K %= 26
    if (123 - ord(sArr[endpoint])) <= K:
        K -= (123 - ord(sArr[endpoint]))
        sArr[endpoint] = chr(ord("a") + K)
    else:
        sArr[endpoint] = chr(ord(sArr[endpoint]) + K)

for j in range(len(sArr)):
    result += sArr[j]

print(result)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())

sArr = list(s)
endpoint = len(sArr) - 1
result = ""

for i in range(len(sArr)):
    if ord("z") - ord(sArr[i]) + 1 <= K:
        K -= ord("z") - ord(sArr[i]) + 1
        sArr[i] = "a"

if K > 0:
    K %= 26
    if ord("z") - ord(sArr[endpoint]) < K:
        K -= ord("z") - ord(sArr[endpoint]) +1
        sArr[endpoint] = chr(ord("a") + K)
    else:
        sArr[endpoint] = chr(ord(sArr[endpoint]) + K)

for j in range(len(sArr)):
    result += sArr[j]

print(result)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())

sArr = list(s)
endpoint = len(sArr) - 1
result = ""

for i in range(len(sArr)):
    if ord("z") - ord(sArr[i]) + 1 <= K:
        K -= ord("z") - ord(sArr[i]) + 1
        sArr[i] = "a"

if K > 0:
    K %= 26
    if ord("z") - ord(sArr[endpoint]) < K:
        K -= ord("z") - ord(sArr[endpoint]) -1
        sArr[endpoint] = chr(ord("a") + K)
    else:
        sArr[endpoint] = chr(ord(sArr[endpoint]) + K)

for j in range(len(sArr)):
    result += sArr[j]

print(result)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())

sArr = list(s)
endpoint = len(sArr) - 1
result = ""

for i in range(len(sArr)):
    if ord("z") - ord(sArr[i]) + 1 <= K:
        K -= ord("z") - ord(sArr[i]) + 1
        sArr[i] = "a"

if K > 0:
    K %= 26
    if ord("z") - ord(sArr[endpoint]) < K:
        K -= ord("z") - ord(sArr[endpoint])
        sArr[endpoint] = chr(ord("a") + K)
    else:
        sArr[endpoint] = chr(ord(sArr[endpoint]) + K)

for j in range(len(sArr)):
    result += sArr[j]

print(result)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())

sArr = list(s)
endpoint = len(sArr) - 1
result = ""

for i in range(len(sArr)):
    if ord("z") - ord(sArr[i]) + 1 <= K:
        K -= ord("z") - ord(sArr[i]) + 1
        sArr[i] = "a"

if K > 0:
    K %= 26
    sArr[endpoint] = chr(ord(sArr[endpoint]) + K)

for j in range(len(sArr)):
    result += sArr[j]

print(result)

Submission status: Wrong Answer

Solution code:
# coding : utf-8
s=list(map(lambda c:ord(c)-ord('a'),input()))
k=int(input())
for i in range(len(s)):
    if 26-s[i]<=k and s[i]!=ord('a'):
        k-=(26-s[i])
        s[i]=0
s[-1]=(s[-1]+k)%26
for n in s:
    print(chr(ord('a')+n),end='')
print()

Submission status: Wrong Answer

Solution code:
# coding : utf-8
s=list(map(lambda c:ord(c)-ord('a'),input()))
k=int(input())
for i in range(len(s)):
    if 26-s[i]<=k:
        k-=(26-s[i])
        s[i]=0
s[-1]=(s[-1]+k)%26
for n in s:
    print(chr(ord('a')+n),end='')
print()

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    n = int(input())
    
    t = []
    a = []
    for i in s:
        ord_i = ord(i)
        t.append(((123 - ord_i)%26, ord_i))
    print(t)
    
    for i in t:
        if n >= i[0]:
            a.append('a')
            n -= i[0]
        else:
            a.append(chr(i[1]))
            
    a[-1] = chr(ord(a[-1]) + n%26)
    print(''.join(a))
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin

def main():
    s = input()
    n = int(stdin.readline())
    
    t = []
    a = []
    for i in s:
        ord_i = ord(i)
        t.append((123 - ord_i, ord_i))
    
    for i in t:
        if n >= i[0]:
            a.append(chr(97))
            n -= i[0]
        else:
            a.append(chr(i[1]))
            
    a[-1] = chr(ord(a[-1]) + n%26)
    print(''.join(a))
    
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin

def main():
    s = stdin.readline()
    n = int(stdin.readline())
    
    t = []
    a = []
    for i in s:
        ord_i = ord(i)
        t.append((123 - ord_i, ord_i))
    
    for i in t:
        if n >= i[0]:
            a.append(chr(97))
            n -= i[0]
        else:
            a.append(chr(i[1]))
        
    temp = ord(a[-1]) + n%26
    
    a[-1] = chr(temp)
    print(''.join(a))
    
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = list(input())
n = int(input())
ret = ""
for i, ss in enumerate(s):
    a = 123 - ord(ss)
    if a == 26:
        a = 0
    if n < a:
        if i == len(s) - 1:
            ret += chr(ord(ss) +(n % 26))
        else:
            ret += ss
    else:
        n -= a
        ret += 'a'

print(ret)

Submission status: Wrong Answer

Solution code:
s = list(input())
n = int(input())
ret = ""
for i, ss in enumerate(s):
    a = 123 - ord(ss)
    if a == 26:
        a = 0
    if n < a:
        if i == len(s) - 1:
            ret += chr(ord(ss) + n)
        else:
            ret += ss
    else:
        n -= a
        ret += 'a'

print(ret)

Submission status: Wrong Answer

Solution code:
s = list(input())
n = int(input())
ret = ""
for i, ss in enumerate(s):
    a = 123 - ord(ss)
    if n < a:
        if i == len(s) - 1:
            ret += chr(ord(ss) + n)
        else:
            ret += ss
    else:
        n -= a
        ret += 'a'

print(ret)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
s = list(input())
k = int(input())
for tmp in range(len(s)):
    if k == 0:
        break
    a = 26-(ord(s[tmp]) - ord('a'))
    if k >= a:
        k -= a
        s[tmp] = 'a'
    else:
        pass
if k > 0:
    s[len(s)-1] = chr((ord(s[len(s)-1])+k%26))
print(''.join(s))

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
s = list(input())
k = int(input())
for tmp in range(len(s)):
    if k == 0:
        break
    a = 26-(ord(s[tmp]) - ord('a'))
    if k >= a:
        k -= a
        s[tmp] = 'a'
    else:
        pass
if k > 0:
    if ord('z') >= ord(s[len(s)-1])+k:
        s[len(s)-1] = chr(ord(s[len(s)-1])+k)
    else:
        s[len(s)-1] = chr((ord(s[len(s)-1])+k%26))
print(''.join(s))

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
ans = ""
for i in range(len(S)):
    if(S[i] != 'a' and K >= (ord('a') - ord(S[i]))%26):
        ans += 'a'
        K -= (ord('a') - ord(S[i]))%26
    else:
        ans += S[i]
    if(not K):
        break

K %= 26
ans = ans[:-1] + chr(ord('a') + (ord(ans[-1])-ord('a') + K)%26)
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
ans = ""
for i in range(len(S)):
    if(S[i] != 'a' and K > (ord('a') - ord(S[i]))%26):
        ans += 'a'
        K -= (ord('a') - ord(S[i]))%26
    else:
        ans += S[i]
    if(not K):
        break

K %= 26
ans = ans[:-1] + chr(ord('a') + (ord(ans[-1])-ord('a') + K)%26)
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
ans = ""
for i in range(len(S)):

    if(K > (ord('a') - ord(S[i]))%26):
        ans += 'a'
        K -= (ord('a') - ord(S[i]))%26
    else:
        ans += S[i]
        
    if(not K):
        break

ans = ans[:-1] + chr(ord('a') + (ord(ans[-1])-ord('a') + K)%26)
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    K = int(input())

    k = K
    for i, s in enumerate(S):
        if 122 - ord(s) < k:
            print('a', end='')
            k -= 122 - ord(s) + 1
        else:
            if i == len(S) - 1:
                print(chr(k % ord(s) + ord(s)))
            else:
                print(s, end='')

main()

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    K = int(input())

    k = K
    for i in range(len(S)):
        if 122 - ord(S[i]) < k:
            print('a', end='')
            k -= 122 - ord(S[i]) + 1
        else:
            if i == len(S) - 1:
                print(chr(ord(S[i]) + k))
            else:
                print(S[i], end='')

main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 23 20:28:29 2017

@author: taichiNakamura
"""
#import numpy as np
# スペース区切りの整数の入力
def f(c):
    return ord(c)-ord('a')
x = input()
K = int(input())
x = list(map(f, x))

#出来るだけ配列を辞書順として小さくする処理
for i in range(len(x)):
    if K >= (26-x[i]):
        K -= 26-x[i]
        x[i] = 0

#出来るだけ配列を大きくせずにKを消費する
x[-1] = (x[-1] + K) % 26
 
def decode(c):
    return chr(c+ord('a'))
 
x = list(map(decode, x))
         
for i in x:
    print(i, end='')