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:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

s = ins()
k = inn()
n = len(s)
t = [ord(c)-ord('a') for c in s]
for i in range(n):
    if k>=26-t[i]:
        k -= 26-t[i]
        t[i] = 0
if k>0:
    t[n-1] = (t[n-1]+k)%26
print(''.join([chr(t[i]+ord('a')) for i in range(n)]))

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
ans = ''
for i,v in enumerate(s):
    if ord('z') - ord(v) + 1 <= k:
        k -= ord('z') - ord(v) + 1
        ans += 'a'
    else:
        ans += v
k %= 26
last = chr(ord('a')+(ord(ans[-1])-ord('a')+k)%26)

print(ans[:-1]+last)

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
ans = ''
for i,v in enumerate(s):
    if k <= 0:
        break
    if ord('z') - ord(v) + 1 <= k:
        k -= ord('z') - ord(v) + 1
        ans += 'a'
    else:
        ans += v
k %= 26
last = chr(ord('a')+(ord(ans[-1])-ord('a')+k)%26)

print(ans[:-1]+last)

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
s = [i for i in s]
for i,v in enumerate(s):
    if v == 'a':
        break
    if k <= 0:
        break
    if ord('z') - ord(v) + 1 <= k:
        k -= ord('z') - ord(v) + 1
        s[i] = 'a'
k %= 26
s[-1] = chr(ord('a')+(ord(s[-1])-ord('a')+k)%26)
print(''.join(s))

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
s = [i for i in s]
for i,v in enumerate(s):
    if v == 'a':
        break
    if k <= 0:
        break
    if ord('z') - ord(v) + 1 <= k:
        s[i] = 'a'
        k -= ord('z') - ord(v) + 1
k %= 26
s[-1] = chr(ord(s[-1])+k)
print(''.join(s))

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
Ans = []
for s in S[:-1]:
    if (123 - ord(s)) <= K:
        Ans.append('a')
        K -= 123 - ord(s)
    else:
        Ans.append(s)

K %= 26
if ord(S[-1]) + K >= 123:
    Ans.append(chr(ord(S[-1]) + K - 26))
else:
    Ans.append(chr(ord(S[-1]) + K))


print(''.join(Ans))

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
k = int(input())

d = [0] * n
for i in range(n):
    if s[i] != 'a':
        d[i] = ord('z') - ord(s[i]) + 1

ans = list(s)
for i in range(n):
    if d[i] != 0 and d[i] <= k:
        k -= d[i]
        ans[i] = 'a'
    if k == 0: break
    if i == n-1:
        ans[i] = chr(ord(s[i]) + k % 26)

print(''.join(ans))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
s = input()
k = int(input())
n = len(s)
ans = ""
# kを減らしていく。もし、aまで戻せるならaまで進めてk をその分減らす。
for i in range(n):
    if ord(s[i]) - 97 + k >= 26:
        ans += "a"
        k -= 123 - ord(s[i])
    else:
        if i < n - 1:
            ans += s[i]
        else:
            ans += chr((ord(s[i]) + k - 97) % 26 + 97)
print(ans)

Submission status: Wrong Answer

Solution code:
def codefes16qa_c():
    s = str(input())
    k = int(input())
    n = len(s)
    ans = ''
    for i in range(n):
        step2a = 1 + ord('z') - ord(s[i])
        if step2a <= k:
            ans += 'a'
            k -= step2a
        else:
            ans += s[i]
    if k > 0:
        last = ord(ans[-1]) + (k % 26)
        ans = ans[:n-1] + chr(last)
    print(ans)

codefes16qa_c()

Submission status: Wrong Answer

Solution code:
def main():
    s = list(input())
    k = int(input())

    for i in range(len(s)-1):
        mod = 26-(ord(s[i])-97)%26
        if k >= mod:
            k -= mod
            s[i] = 'a'
        if k == 0:
            break
    
    if k > 0:
        mod = ((ord(s[-1])-97)+k)%26
        s[-1] = chr(mod+97)
    print(''.join(s))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    s = list(input())
    k = int(input())

    for i in range(len(s)):
        mod = 26-(ord(s[i])-97)%26
        if k >= mod:
            k -= mod
            s[i] = 'a'
        if k == 0:
            break
    
    if k > 0:
        mod = ((ord(s[-1])-97)+k)%26
        s[-1] = chr(mod+97)
    print(''.join(s))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    s = list(input())
    k = int(input())

    for i in range(len(s)):
        mod = 26-(ord(s[i])-97)%26
        if k >= mod:
            k -= mod
            s[i] = 'a'
        if k == 0:
            break
    
    if k > 0:
        mod = ((ord(s[-1])-97)%26+k)%26
        s[-1] = chr(mod+97)
    print(''.join(s))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    s=list(input())
    k=int(input())
    i=0
    while k>=0 and i<len(s)-1:
        if k>=123-ord(s[i]):
            k-=123-ord(s[i])
            s[i]="a"
        i+=1
    if i==len(s)-1:
        s[-1]=chr(97+(k-(123-ord(s[i])))%26)
    print("".join(s))
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
X='abcdefghijklmnopqrstuvwxyz'*2
S=input()
k=int(input())
N=[]
for s in S:
    if s=='a':
        N.append(0)
    else:
        N.append(26-X.index(s))
ans=''
for i in range(len(S)):
    if N[i]<=k :
        k-=N[i]
        ans+='a'
    else:
        ans+=S[i]
print(k)
ans=ans[:-1]+X[X.index(ans[-1])+k%26]

Submission status: Wrong Answer

Solution code:
X='abcdefghijklmnopqrstuvwxyz'*2
S=input()
k=int(input())
N=[]
for s in S:
    if s=='a':
        N.append(0)
    else:
        N.append(26-X.index(s))
ans=''
for i in range(len(S)):
    if N[i]<=k :
        k-=N[i]
        ans+='a'
    else:
        ans+=S[i]
ans=ans[:-1]+X[X.index(S[-1])+k%26]

print(ans)

Submission status: Wrong Answer

Solution code:
X='abcdefghijklmnopqrstuvwxyz'*2
S=input()
k=int(input())
N=[]
for s in S:
    if s=='a':
        N.append(0)
    else:
        N.append(26-X.index(s))
ans=''
for i in range(len(S)):
    if N[i]<=k :
        k-=N[i]
        ans+='a'
    else:
        ans+=S[i]

for i in reversed(range(len(S))):
    if ans[i]!='a':
        ans=ans[:i]+X[X.index(ans[i])+k]+ans[i+1:]
        break

print(ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
print(s)
K=int(input())
i=0
while i<len(s):
    if i==len(s)-1:
        s[i]=chr(97+(ord(s[i])-97+K)%26)
        break
    if K<abs(123-ord(s[i]))%26:
        i+=1
    elif K>=abs(123-ord(s[i]))%26:
        sub=abs(123-ord(s[i]))%26
        s[i]="a"
        K-=sub
        i+=1
print("".join(s))

Submission status: Wrong Answer

Solution code:
S=list(input())
k=int(input())
Ans=[0]*len(S)
for i in range(len(S)):
  if (26-(ord(S[i])-97))%26<=k:
    Ans[i]="a"
    k=k-(26-(ord(S[i])-97)%26)
  else:
    Ans[i]=S[i]
  if i==len(S)-1:
    Ans[i]=chr(((ord(Ans[i])+k%26-97)%26+97))
print("".join(Ans))

Submission status: Wrong Answer

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

for i in range(len(s)):
    if 123 - ord(s[i]) <= k:
        k -= 123 - ord(s[i])
        s[i] = chr(97)
if k != 0:
    x = k%26
    if ord(s[-1]) + x >= 123:
        s[-1] = chr(ord(s[-1]) + x - 123)
    else:
        s[-1] = chr(ord(s[-1]) + x)
for i in range(len(s)):
    print(s[i],end ="")
print("")

Submission status: Wrong Answer

Solution code:
s = [ord(i) for i in input()]
k = int(input())
for i in range(len(s)):
    if 123 - s[i] <= k:
        k -= 123 - s[i]
        s[i] = 97
        if k == 0:
            break
if k != 0:
    s[-1] = s[-1] + k % 26
print("".join([chr(i) for i in s]))

Submission status: Wrong Answer

Solution code:
s = input()
s_li = list(s)
k = int(input())

alp = list('abcdefghijklmnopqrstuvwxyz')
moji_li = []
count_li = []
for ss in s_li:
    ind = alp.index(ss)
    moji_li.append(alp.index(ss))
    count_li.append(26 - alp.index(ss))
for i,c in enumerate(count_li):
    if i == len(count_li)-1:
        moji_li[i]+= k
        break
    else:
        if c<=k:
            k-=c
            moji_li[i]=0
ans = ''
#print('count_li',count_li)
#print(moji_li)
for m in moji_li:
    ans += alp[m%26]
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s_li = list(s)
k = int(input())

alp = list('abcdefghijklmnopqrstuvwxyz')
moji_li = []
count_li = []
for ss in s_li:
    ind = alp.index(ss)
    moji_li.append(alp.index(ss))
    count_li.append(26 - alp.index(ss))
for i,c in enumerate(count_li):
    if i == len(count_li)-1:
        moji_li[i]+= k
    else:
        if c<=k:
            k-=c
            moji_li[i]=0
ans = ''
#print('count_li',count_li)
#print(moji_li)
for m in moji_li:
    ans += alp[m%26]
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s_li = list(s)
k = int(input())

alp = list('abcdefghijklmnopqrstuvwxyz')
moji_li = []
count_li = []
for ss in s_li:
    ind = alp.index(ss)
    moji_li.append(alp.index(ss))
    count_li.append(26 - alp.index(ss))
for i,c in enumerate(count_li):
    if i == len(count_li)-1:
        moji_li[i]+= k
    else:
        if c<=k:
            k-=c
            moji_li[i]=0
ans = ''
#print('count_li',count_li)
#print(moji_li)
for m in moji_li:
    if m>=26:
        ans += alp[m%26]
    else:
        ans += alp[m]
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s_li = list(s)
k = int(input())

alp = list('abcdefghijklmnopqrstuvwxyz')
moji_li = []
count_li = []
for ss in s_li:
    ind = alp.index(ss)
    moji_li.append(alp.index(ss))
    count_li.append(26 - alp.index(ss))
for i,c in enumerate(count_li):
    if i == len(count_li)-1:
        moji_li[i]+= k
    else:
        if c<=k:
            k-=c
            moji_li[i]+=c
ans = ''
for m in moji_li:
    if m>=26:
        ans += alp[m%26]
    else:
        ans += alp[m]
print(ans)

Submission status: Wrong Answer

Solution code:
a = list(input())
k = int(input())
abc = "abcdefghijklmnopqrstuvwxyz"
c = 0
for e,i in enumerate(a[:-1]):
    if k-26+abc.index(i)>=0:
        a[e] = 'a'
        k-=26-abc.index(i) 
k+=abc.index(a[-1])
k%=26
a[-1] = abc[k]

print("".join(a))

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    k=int(input())
    len_s=len(s)
    new_s=""
    for i,ss in enumerate(s[:-1]):
        t=ord('z')-ord(ss)+1
        if t<=k:
            k-=t
            new_s+='a'
        else:
            new_s+=ss
    if ord(s[-1])+k%26<=ord('z'):
        new_s+=chr(ord(s[-1])+k%26)
    else:
        new_s+=chr(ord(s[-1])+k%26-26) 
    print(new_s)

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
n=len(s)
s=[s[i] for i in range(n)]
l={"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}
for i in range(n):
    c=s[i]
    if l[c]>k:
        continue
    k-=l[c]
    s[i]="a"
if k>0:
    k=k%26
    c=s[-1]
    for i in l:
        if l[i]==l[c]-k:
            s[-1]=i
s=''.join(s)
print(s)

Submission status: Wrong Answer

Solution code:
z=ord('z')
a=ord('a')
ss=input()
s=list(ss)
k=int(input())
l=len(s)

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

if k>0:
    last=(ord(s[-1])+k-a)%26+a
    s[-1]=chr(last)

ans=''.join(s)
print(ans)

Submission status: Wrong Answer

Solution code:
z=ord('z')
a=ord('a')
print(z-a)
ss=input()
s=list(ss)
k=int(input())
l=len(s)

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

if k>0:
    last=(ord(s[-1])+k-a)%26+a
    s[-1]=chr(last)

ans=''.join(s)
print(ans)

Submission status: Wrong Answer

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

if k>0:
    last=(ord(s[-1])+k-a)%(z-a)+a
    s[-1]=chr(last)

ans=''.join(s)
print(ans)

Submission status: Wrong Answer

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

if k>0:
    last=(ord(s[-1])+k-a)%z+a
    s[-1]=chr(last)

ans=''.join(s)
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
ls = len(s)
k= int(input())
for i in range(ls-1):
    tn = ord('z')-ord(s[i])+1
    if k>=tn:
        k-=tn
        print('a',end='')
    else:
        print(s[i],end='')
ik = (k + ord(s[-1])-ord('a')) % 26
print(chr(ord('a')+ik))

Submission status: Wrong Answer

Solution code:
sl = list(input())
rsl = range(len(sl))
sn = [ord('z')-ord(sl[i])+1 for i in rsl]
k= int(input())
for i in rsl:
    if k >= sn[i]:
        k-= sn[i]
        sl[i]='a'
ik = (k + ord(sl[-1])-ord('a')) % 26
sl[-1] = chr(ord('a')+ik)
print(''.join(sl))

Submission status: Wrong Answer

Solution code:
sl = list(input())
sn = [0 for _ in range(len(sl))]
k= int(input())
for i,c in enumerate(sl):sn[i] = ord('z')-ord(c)+1
for i in range(len(sl)):
    if k >= sn[i]:
        k-= sn[i]
        sl[i]='a'
else:
    ik = (k + ord(sl[-1])-ord('a')) % 26
    sl[-1] = chr(ord('a')+ik)
print(''.join(sl))

Submission status: Wrong Answer

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

for i in range(len(s)):
    cost = ord('z') - ord(s[i]) + 1
    c = s[i]
    if cost <= k:
        k -= cost
        c = 'a'
    s[i] = c
k %= 26
if k > 0:
    c = chr(ord(s[i]) + k)
    if ord(c) > ord('z'):
        c = chr(ord('a') + (ord(c) - ord('z') - 1))
    s[i] = c
print("".join(s))

Submission status: Wrong Answer

Solution code:
import itertools

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

alp = list('abcdefghijklmnopqrstuvwxyz')

index_list = [alp.index(s[i]) for i in range(len(s))]

cnt_list = []
for j in index_list:
    if j > 0:
        cnt_list.append(26-j)
    else:
        cnt_list.append(0)

s_list = list(s)

if sum(cnt_list) <= K:
    num = (K - sum(cnt_list)) % 26
    l = "a" * (len(s)-1) + alp[num]
    print(l)
else:
    i = 0
    for i in range(len(s)):
        if i == len(s):
            if K >= cnt_list[i]:
                num = (K - cnt_list[i]) % 26
                s_list[i] = alp[num]
            else:
                s_list[i] = alp[K-cnt_list[i]]
        elif K >= cnt_list[i]:
            K -= cnt_list[i]
            s_list[i] = 'a'
        else:
            pass
    ans = ''.join(s_list)
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    s = list(input().strip())
    K = int(input())
    for i, c in enumerate(s):
        z = 123 - ord(c)
        if K >= z:
            s[i] = 'a'
            K -= z
        if K == 0:
            break
    
    s[-1] = chr(((ord(s[-1])-97+K))%26+97)

    print(''.join(s))

if __name__ == '__main__':
     main()

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    K = int(input())
    new_s = ""

    l = ['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']
    d = {
        "a": 0,
        "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,
    }

    for i in range(len(s)-1):
        if d[s[i]] <= K:
            K -= d[s[i]]
            new_s += 'a'
        else:
            new_s += s[i]
        if K == 0:
            break

    new_s += l[(l.index(s[-1]) + K) % 26]

    print(new_s)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

len_s = len(s)
moji = [0]*(len_s)

for i in range(len_s):
    num = 26-(ord(s[i])-ord('a'))
    if num <= k:
        moji[i] = 'a'
        k -= num
    else:
        moji[i] = s[i]

     
if k != 0:
    #print(k)
    moji[len_s-1] = chr(ord(moji[len_s-1])+k%26)
        
print(*moji,sep='')

Submission status: Wrong Answer

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

len_s = len(s)
moji = [0]*(len_s)

for i in range(len_s):
    num = 26-(ord(s[i])-ord('a'))
    if num <= k:
        moji[i] = 'a'
        k -= num
    else:
        moji[i] = s[i]
        
if k != 0:
    #print(k)
    moji[len_s-1] = chr(ord(moji[len_s-1])+k%26)
        
print(*moji,sep='')

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    a = list(input())
    K = int(input())
    for i in range(len(a)):
        val = 123 - ord(a[i])
        if val <= K:
            a[i] = 'a'
            K -= val
        if i == len(a) - 1 and K > 0:
            a[-1] = chr(ord(a[-1]) + K%26)
    print(''.join(a))


resolve()

Submission status: Wrong Answer

Solution code:
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

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

#################################################
#################################################
#################################################
#################################################


s = input()
k = int(input())
n = len(s)

a = []
for i in range(n):
    a.append(ord(s[i])-ord('a'))

for i in range(n):
    need = 26 - a[i]
    if(k>=need):
        a[i]=0
        k-=need


k %= 26

for ii in range(n):
    i = n-1-ii
    rem = 25 - a[i]
    if(rem<=k):
        a[i]+=rem
        k-=rem
    else:
        a[i]+=k
        k=0
        
        break
ans = [' ' for i in range(n)]
for i in range(n):        
    ans[i] = chr(a[i]+ord('a'))
print(''.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
original_s = list(input())
s = list(map(lambda x:ord(x)-97-26, original_s))
K = int(input())

ans = original_s
for i in range(len(s)):
    if abs(s[i]) <= K and s[i] != -26:
        ans[i] = "a"
        K += s[i]

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

print("".join(ans))

Submission status: Wrong Answer

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

for i in range(len(sl)):
    ord_s = ord(sl[i])
    use = 123 - ord_s
    if k - use >= 0:
        sl[i] = "a"
        k -= use

if k > 0:
    sl[-1] = chr((ord(sl[-1]) + k - 97) % 26 + 97)

print("".join(sl))

Submission status: Wrong Answer

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

for i in range(len(sl)):
    ord_s = ord(sl[i])
    use = 123 - ord_s
    if k - use >= 0:
        sl[i] = "a"
        k -= use

if k > 0:
    sl[-1] = chr((ord(sl[-1]) + k - 97) % 25 + 97)

print("".join(sl))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
ss = [0]*len(s)
for i in range(len(s)):
    if k >= 26:
        k = k + ord(s[i])-97-26
        ss[i] = "a"
    elif 97+26 - ord(s[i]) <= k:
        k = k + ord(s[i])-97-26
        ss[i] = "a"
    else:
        ss[i] = s[i]
ss[-1] = chr(ord(s[-1])+(k%26))

for i in range(len(s)):
    print(ss[i],end='')
print()

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
ss = [0]*len(s)
for i in range(len(s)):
    if k >= 26:
        k = k + ord(s[i])-97-26
        ss[i] = "a"
    elif 97+26 - ord(s[i]) <= k:
        k = k + ord(s[i])-97-26
        ss[i] = "a"
    else:
        ss[i] = s[i]
if k != 0:
    ss[-1] = chr(ord(s[-1])+(k%26))

for i in range(len(s)):
    print(ss[i],end='')
print()

Submission status: Wrong Answer

Solution code:
N = list(str(input()))
K = int((input()))

for i in range(len(N) - 1):
    if ord(N[i]) >= 98 and K >= 123 - int(ord(N[i])):
        K = K - (123 - ord(N[i]))
        N[i] = 'a'
a = ord(N[len(N)-1]) + K
if a > 122:
    b = (a - 98) % 25
    a = b + 97
N[len(N)-1] = chr(a)
for j in N:
    print(j, end='')

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


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

    S = [s for s in S]
    D = [ord('z') - ord(s) + 1 for s in S]
    T = []
    for s, d in zip(S, D):
        if d <= K:
            T.append('a')
            K -= d
        else:
            T.append(s)

    c = ord(T[-1])
    for _ in range(K):
        if c == ord('z'):
            c = ord('a')
        else:
            c += 1
    T[-1] = chr(c)

    print(''.join(T))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
n = len(s)
for i in range(n):
  num = ord(s[i])
  if 123-num > k:
    continue
  k -= (123-num)
  s = s[:i] + 'a' + s[i+1:]
if k > 0:
  t = k%26
  s = s[:n-1] + chr(ord(s[n-1])+t)
print(s)

Submission status: Wrong Answer

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

diff = [ord('z') - ord(c) + 1 for c in s]
# print(diff)

for i in range(len(s)):
    if diff[i] <= K:
        K -= diff[i]
        diff[i] = 0
# print(diff)
diff[-1] = (diff[-1] - K) % 26

ans = ''.join([chr(ord('z') + 1 - val) if val != 0\
    else 'a' for val in diff])
print(ans)

Submission status: Wrong Answer

Solution code:
INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque

def main():
    s = list(input())
    k = int(input())
    for i in range(len(s)):
        if s[i] == 'a':
            continue
        if k >= ord('z') - ord(s[i]) + 1:
            k -= ord('z') - ord(s[i]) + 1
            s[i] = 'a'
            if k == 0:
                break
    
    if k > 0:
        s[-1] = chr((ord(s[-1]) + k - 91)%26 + 91)
    
    print(''.join(s))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def solve():
    S = input()
    l = len(S)
    K = int(input())
    i = 0
    ans = ''
    while i < l-1 and K>0:
        n = ord(S[i])-ord('a')
        if 25-n<K:
            ans += 'a'
            K -= 26-n
        else:
            ans += S[i]
        i += 1
    if K == 0:
        ans += S[i:]
    else:
        ans += chr((ord(S[-1])-ord('a')+K)%26+ord('a'))
    return ans
print(solve())

Submission status: Wrong Answer

Solution code:
s=input()
K=int(input())
znum=ord("z")
count=0
ans=[]
lst=dict()

for i in range(len(s)):
    num=ord(s[i])
    if s[i]=="a":
        ans.append("a")
        continue
    sa=znum-num+1
    if sa<=K:
        ans.append("a")
        K-=sa
    else:
        ans.append(s[i])

if count<K:
    K%=26
    ans[-1]=chr(ord(s[-1])+K)

S=""
for i in range(len(ans)):
    S=S+ans[i]
print(S)

Submission status: Wrong Answer

Solution code:
s=input()
K=int(input())
znum=ord("z")
count=0
ans=[]
lst=dict()
for i in range(26):
    sl=chr(97+i)
    lst[sl]=97+i
for i in range(len(s)):
    num=lst[s[i]]
    if s[i]=="a":
        ans.append("a")
        continue
    sa=znum-num+1
    if (count+sa)<=K:
        ans.append("a")
        count+=sa
    else:
        ans.append(s[i])

if count<K:
    num=K-count
    num=num%26
    lnum=ord(s[-1])
    anum=lnum+num
    if anum>122:
        lnum=anum-122
        anum=96+lnum
    ls=chr(anum)
    S=""
    for i in range(len(ans)):
        if i==(len(ans)-1):
            S=S+ls
            continue
        S=S+ans[i]

else:
    S=""
    for i in range(len(ans)):
        S=S+ans[i]

print(S)

Submission status: Wrong Answer

Solution code:
s=input()
K=int(input())
znum=ord("z")
count=0
ans=[]
for i in range(len(s)):
    num=ord(s[i])
    if s[i]=="a":
        ans.append("a")
        continue
    sa=znum-num+1
    if (count+sa)<=K:
        ans.append("a")
        count+=sa
    else:
        ans.append(s[i])

if count<K:
    num=K-count
    num=num%26
    lnum=ord(s[-1])
    anum=lnum+num
    if anum>122:
        lnum=anum-122
        anum=96+lnum
    ls=chr(anum)
    S=""
    for i in range(len(ans)):
        if i==(len(ans)-1):
            S=S+ls
            continue
        S=S+ans[i]

else:
    S=""
    for i in range(len(ans)):
        S=S+ans[i]

print(S)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = input()
    K = int(input())
    nums = []
    a = ord("a")
    for s in S:
        nums.append(ord(s) - a)

    for i in range(len(S)):
        diff = 26 - nums[i]
        if diff <= K:
            nums[i] = 0
            K -= diff

    if K > 0:
        nums[-1] = (nums[-1] + K) % 26

    ans = ""
    for n in nums:
        ans += chr(n + a)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def icc(c):
	ret=(ord('z') - ord(c) + 1)
	return ret
	
def nn(c,v):
	ret=chr(ord(c)+v)
	return ret

def main():
	s=input()
	n = int(input())
	#b , c = IN()
	#s = input()
	ret = []
	for c in s:
		#print(c,icc(c),n)
		if icc(c) <= n:
			ret.append('a')
			n-=icc(c)
		else:
			ret.append(c)
	
	n%=26
	if icc(ret[-1])<=n:
		n-=icc(ret[-1])
		ret[-1]='a'
	ret[-1]=nn(ret[-1], n)
	return ''.join(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def icc(c):
	ret=(ord('z') - ord(c) + 1)
	return ret
	
def nn(c,v):
	ret=chr(ord(c)+v)
	return ret

def main():
	s=input()
	n = int(input())
	#b , c = IN()
	#s = input()
	ret = []
	for c in s:
		#print(c,icc(c),n)
		if icc(c) <= n:
			ret.append('a')
			n-=icc(c)
		else:
			ret.append(c)
	n%=26
	if icc(ret[-1])<n:
		n-=icc(ret[-1])
		ret[-1]='a'
	ret[-1]=nn(ret[-1], n)
	return ''.join(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)