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:
#!/usr/bin/env python3
#CODEFESTIVAL2016 qual A C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
k = I()
n = len(s)
alpha = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
for i in range(n-1):
    a = 26 - alpha.index(s[i])
    if a <= k:
        k -= a
        ans += 'a'
    else:
        ans += s[i]
if k > 0:
    tmp = alpha.index(s[-1])
    ans += alpha[(tmp + k % 26) % 26]
print(ans)

Submission status: Wrong Answer

Solution code:
# 2019/09/17

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

for i in range(n):
    cnt=123-ord(s[i])
    if cnt>k:continue
    s[i]='a'
    k-=cnt
    if k==0:break
else:
    if k:
        s[-1]=chr(97+(ord(s[i])+k-97)%26)

print(''.join(s))

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, = map(int, input().split())
S = [ord(v) - ord("a") for v in input().strip()]
N, = map(int, input().split())

for i in range(len(S)):
    c = 26 - S[i]
    if c <= N:
        N -= c
        S[i] = 0

S[-1] += N % 26

print("".join([chr(ord("a") + v) for v in S]))

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, = map(int, input().split())
S = [ord("z") - ord(v) + 1 for v in input().strip()]
N, = map(int, input().split())

for i in range(len(S)):
    if S[i] <= N:
        N -= S[i]
        S[i] = 26

S[-1] -= N % 26

print("".join([chr(ord("z") - v + 1) for v in S]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    remain = k  # 残りの操作回数
    ans = ['' for _ in range(len(s))]

    # See:
    # http://code-festival-2016-quala.contest.atcoder.jp/data/other/code-festival-2016-quala/editorial.pdf
    # KeyInsight
    # 辞書順最小：先頭の要素から順に見て，見ている要素をできるだけ小さくする，ことを貪欲に行う
    for index, si in enumerate(s):
        # アルファベットを数字に変換して扱う
        need = (ord('z') - ord(si) + 1) % 26

        # 先頭から'a'にできるかどうか判定
        if remain >= need:
            remain -= need
            ans[index] = 'a'
        else:
            ans[index] = si

    # 最後に，一番右の文字に対して残ったk回(mod 26)の操作を実行
    # 操作回数kはは最大で10^9回であり，愚直に計算すると実行時間制限をオーバーしてしまう
    # そこで，操作とアルファベットの関係にに注目する
    # 26文字で1周するという性質から，x周(ここは無視できる)+α回操作すると言い換える
    # α回操作して，該当する文字を返す

    # See:
    # https://atcoder.jp/contests/code-festival-2016-quala/submissions/7337728
    ans[-1] = chr((ord(s[-1]) - ord('a') + remain) % 26 + ord('a'))

    print(''.join(map(str, ans)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    remain = k  # 残りの操作回数
    ans = ['' for _ in range(len(s))]

    # See:
    # http://code-festival-2016-quala.contest.atcoder.jp/data/other/code-festival-2016-quala/editorial.pdf
    # KeyInsight
    # 辞書順最小：先頭の要素から順に見て，見ている要素をできるだけ小さくする，ことを貪欲に行う
    for index, si in enumerate(s):
        # アルファベットを数字に変換して扱う
        need = (ord('z') - ord(si) + 1) % 26

        # 先頭から'a'にできるかどうか判定
        if remain >= need:
            remain -= need
            ans[index] = 'a'
        else:
            ans[index] = si

    # 最後に，一番右の文字に対して残ったk回(mod 26)の操作を実行
    # 操作回数kはは最大で10^9回であり，愚直に計算すると実行時間制限をオーバーしてしまう
    # そこで，操作とアルファベットの関係にに注目する
    # 26文字で1周するという性質から，x周(ここは無視できる)+α回操作すると言い換える
    # α回操作して，該当する文字を返す

    # See:
    # https://atcoder.jp/contests/code-festival-2016-quala/submissions/7337728
    if remain > 0:
        ans[-1] = chr(((ord(s[-1]) - ord('a') + remain) % 26) + ord('a'))

    print(''.join(map(str, ans)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    remain = k  # 残りの操作回数
    ans = ['' for _ in range(len(s))]

    # See:
    # http://code-festival-2016-quala.contest.atcoder.jp/data/other/code-festival-2016-quala/editorial.pdf
    # KeyInsight
    # 辞書順最小：先頭の要素から順に見て，見ている要素をできるだけ小さくする，ことを貪欲に行う
    for index, si in enumerate(s):
        # アルファベットを数字に変換して扱う
        need = (ord('z') - ord(si) + 1) % 26

        # 先頭から'a'にできるかどうか判定
        if remain >= need:
            remain -= need
            ans[index] = 'a'
        else:
            ans[index] = si

    # 最後に，一番右の文字に対して残ったk回(mod 26)の操作を実行
    # 操作回数kはは最大で10^9回であり，愚直に計算すると実行時間制限をオーバーしてしまう
    # そこで，操作とアルファベットの関係にに注目する
    # 26文字で1周するという性質から，x周(ここは無視できる)+α回操作すると言い換える
    # α回操作して，該当する文字を返す

    # See:
    # https://atcoder.jp/contests/code-festival-2016-quala/submissions/7337728
    if remain > 0:
        ans[-1] = chr(ord('a') + ((ord(s[-1]) - ord('a') + remain) % 26))

    print(''.join(map(str, ans)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    remain = k  # 残りの操作回数
    alpha2number = lambda c: ord(c) - ord('a')
    ans = ''

    # See:
    # http://code-festival-2016-quala.contest.atcoder.jp/data/other/code-festival-2016-quala/editorial.pdf
    # KeyInsight
    # 辞書順最小：先頭の要素から順に見て，見ている要素をできるだけ小さくする，ことを貪欲に行う
    for si in s:
        # アルファベットを数字に変換して扱う
        need = 26 - alpha2number(si)

        # 先頭から'a'にできるかどうか判定
        if remain >= need:
            remain -= need
            ans += 'a'
        else:
            ans += si

    # 最後に，一番右の文字に対して残ったk回(mod 26)の操作を実行
    # 操作回数kはは最大で10^9回であり，愚直に計算すると実行時間制限をオーバーしてしまう
    # そこで，操作とアルファベットの関係にに注目する
    # 26文字で1周するという性質から，x周(ここは無視できる)+α回操作すると言い換える
    # α回操作して，該当する文字を返す

    # See:
    # https://atcoder.jp/contests/code-festival-2016-quala/submissions/7337728
    if remain > 0:
        ans = ans[:-1] + chr(ord('a') + ((alpha2number(s[-1]) + remain) % 26))

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    remain = k # 残りの操作回数
    alpha2number = lambda c: ord(c) - ord('a')
    ans = ''

    # See:
    # http://code-festival-2016-quala.contest.atcoder.jp/data/other/code-festival-2016-quala/editorial.pdf
    # KeyInsight
    # 辞書順最小：先頭の要素から順に見て，見ている要素をできるだけ小さくする，ことを貪欲に行う
    for si in s[:-1]:
        # アルファベットを数字に変換して扱う
        need = 26 - alpha2number(si)

        # 先頭から'a'にできるかどうか判定
        if remain >= need:
            remain -= need
            ans += 'a'
        else:
            ans += si

    # 最後に，一番右の文字に対して残ったk回(mod 26)の操作を実行
    # 操作回数kはは最大で10^9回であり，愚直に計算すると実行時間制限をオーバーしてしまう
    # そこで，操作とアルファベットの関係にに注目する
    # 26文字で1周するという性質から，x周(ここは無視できる)+α回操作すると言い換える
    # α回操作して，該当する文字を返す

    # See:
    # https://atcoder.jp/contests/code-festival-2016-quala/submissions/7337728
    ans += chr(ord('a') + ((alpha2number(s[-1]) + remain) % 26))

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    remain = k # 残りの操作回数
    alpha2number = lambda c: ord(c) - ord('a')
    ans = ''

    # See:
    # http://code-festival-2016-quala.contest.atcoder.jp/data/other/code-festival-2016-quala/editorial.pdf
    # KeyInsight
    # 辞書順最小：先頭の要素から順に見て，見ている要素をできるだけ小さくする，ことを貪欲に行う
    for si in s:
        # アルファベットを数字に変換して扱う
        need = 26 - alpha2number(si)

        # 先頭から'a'にできるかどうか判定
        if remain >= need:
            remain -= need
            ans += 'a'
        else:
            ans += si

    # 最後に，一番右の文字に対して残ったk回(mod 26)の操作を実行
    # 操作回数kはは最大で10^9回であり，愚直に計算すると実行時間制限をオーバーしてしまう
    # そこで，操作とアルファベットの関係にに注目する
    # 26文字で1周するという性質から，x周(ここは無視できる)+α回操作すると言い換える
    remain %= 26

    if remain > 0:
        # α回操作して，該当する文字を返す
        order = ord(s[-1]) + remain
        ans = ans[:-1] + chr(order)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    remain = k # 残りの操作回数
    alpha2number = lambda c: ord(c) - ord('a')
    ans = ''

    # See:
    # http://code-festival-2016-quala.contest.atcoder.jp/data/other/code-festival-2016-quala/editorial.pdf
    # KeyInsight
    # 辞書順最小：先頭の要素から順に見て，見ている要素をできるだけ小さくする，ことを貪欲に行う
    for si in s:
        # アルファベットを数字に変換して扱う
        need = 26 - alpha2number(si)

        # 先頭から'a'にできるかどうか判定
        if remain >= need:
            remain -= need
            ans += 'a'
        else:
            ans += si

    # 最後に，一番右の文字に対して残ったk回(mod 26)の操作を実行
    # 操作回数kはは最大で10^9回であり，愚直に計算すると実行時間制限をオーバーしてしまう
    # そこで，操作とアルファベットの関係にに注目する
    # 26文字で1周するという性質から，x周(ここは無視できる)+α回操作すると言い換える
    remain %= 26

    if remain > 0:
        # α回操作して，該当する文字を返す
        order = ord(s[-1]) + remain

        # 'z'よりも大きい数字になった場合
        if order > 122:
            order -= 26

        ans = ans[:-1] + chr(order)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = []
for i in range(len(s)):
    if K >= ord('z')-ord(s[i])+1:
        K -= ord('z')-ord(s[i])+1
        ans.append('a')
    else:
        ans.append(s[i])

# if K >= 1:
#     ans[-1] = chr(ord(ans[-1])+K % 26)

print(''.join(ans))

Submission status: Wrong Answer

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

ans = []
for i in range(len(s)):
    if K >= ord('z')-ord(s[i])+1:
        K -= ord('z')-ord(s[i])+1
        ans.append('a')
    else:
        ans.append(s[i])

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

print(''.join(ans))

Submission status: Wrong Answer

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

ans = []
for i in range(len(s)):
    if K >= ord('z')-ord(s[i])+1:
        K -= ord('z')-ord(s[i])+1
        ans.append('a')
    else:
        ans.append(s[i])

if K >= 1:
    if len(ans) >= 1:
        ans[-1] = chr(ord(ans[-1])+K % 26)
    else:
        ans[0] = print(chr(ord(s[0])+K % 26))

print(''.join(ans))

Submission status: Wrong Answer

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

ans = []
for i in range(len(s)):
    if K >= ord('z')-ord(s[i])+1:
        K -= ord('z')-ord(s[i])+1
        ans.append('a')
    else:
        ans.append(s[i])

if K >= 1:
    if len(ans) >= 1:
        ans[-1] = chr(ord(ans[-1])+K % 26)
    else:
        print(chr(ord(s[0])+K % 26))

print(''.join(ans))

Submission status: Wrong Answer

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

ans = []
for i in range(len(s)):
    if K >= ord('z')-ord(s[i])+1:
        K -= ord('z')-ord(s[i])+1
        ans.append('a')
    else:
        ans.append(s[i])

# if K >= 1:
#     if len(ans) >= 1:
#         ans[-1] = chr(ord(ans[-1])+K)
#     else:
#         print(chr(ord(s[0])+K))

print(''.join(ans))

Submission status: Wrong Answer

Solution code:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




def main():
    s = list(input())
    num = int(input())

    for i in range(len(s)):
        now_ind = ord(s[i])
        if now_ind + num > 122:
            num -= 123 - now_ind
            s[i] = 'a'

    last_ind = ord(s[-1]) - 97
    last_ind = (last_ind + num) % 26 + 97
    s[-1] = chr(last_ind)

    print(''.join(s))



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = [ord(i) - 97 for i in input()]
k = int(input())
print(s)
for i in range(len(s)):
    diff = 26 - s[i]
    if (s[i] != 0) and (diff <= k):
        k -= diff
        s[i] = 0

s[-1] = (s[-1] + k) % 26

ans = "".join(chr(i+97) for i in s)
print(ans)

Submission status: Wrong Answer

Solution code:
s = [ord(i) - 96 for i in input()]
k = int(input())

for i in range(len(s)):
    if 27 - s[i] <= k:
        k -= 27 - s[i]
        s[i] = 1

s[-1] = (s[-1] + k) % 27

ans = "".join(chr(i+96) for i in s)
print(ans)

Submission status: Wrong Answer

Solution code:
s = [ord(i) - 97 for i in 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

ans = "".join(chr(i+97) for i in s)
print(ans)

Submission status: Wrong Answer

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

for i,c in enumerate(S):
    needed = 97 + 26 - ord(c)
    if needed <= N:
        N -= needed
        S[i] = "a"

N %= 26

S[-1] = chr(  ((ord(S[-1]) -97) + N) %26 + 97 )
print("".join(S))

Submission status: Wrong Answer

Solution code:
S = input()
S = list(S)
N = int(input())
while True: # +の変化を行うフェイズ
    flag = True

    for i,c in enumerate(S):
        needed = 97 + 26 - ord(c)
        if needed <= N:
            N -= needed
            S[i] = "a"
            flag = False
    if flag:
        break
S[-1] = chr(ord(c) + N)
print("".join(S))

Submission status: Wrong Answer

Solution code:
s=input();K=int(input());n=""
for c in s:
 i=123-ord(c)
 if K>=i:n+="a";K-=i
 else:n+=c
print(n[:-1]+chr((ord(n[-1])-97+K)%26+97))

Submission status: Wrong Answer

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

while k>0:
    for i in range(len(s)):
        ss=ord(s[i])
        check=122-ss+1
        if check <= k:
            k-=check
            s[i]='a'
        else:
            continue
    if s.count('a')==len(s) and k>0:
        k=k%26
        s[-1]=chr(ord(s[-1])+k)
        ans=''.join(s)
        break
    else:
        s[-1]=chr(ord(s[-1])+k)
        ans=''.join(s)
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())
for i, c in enumerate(s):
    if i == len(s) - 1:
        res = K % 26
        if (ord(c) + res) <= ord("z"):
            s = s[:i] + chr(ord(c) + res) + s[i+1:]
        else:
            s = s[:i] + chr((ord(c) + res) - ord("z") + ord("a") - 1) + s[i+1:]
    elif ord(c) == ord("a"):
        continue
    elif K > ord("z") - ord(c) + 1:
        s = s[:i] + "a" + s[i+1:]
        K -= ord("z") - ord(c) + 1
    else:
        continue
    print(K)
print(s)

Submission status: Wrong Answer

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

a_num = 97
z_num = 122

for i in range(len(s)):
    if K == 0:
        break
    else:
        if i == len(s) - 1:
          if ord(s[i])+ (K%26) <= z_num:
            s[i] = chr(ord(s[i]) + (K%26))
          else:
            s[i] = chr(ord(s[i]) + (K%26) - 26)

        elif ord(s[i]) == a_num:
            continue
        elif K > z_num - ord(s[i]) + 1:
            K -= z_num - ord(s[i]) + 1
            s[i]="a"
        
print("".join(s))

Submission status: Wrong Answer

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

a_num = 97
z_num = 122

for i in range(len(s)):
    if K == 0:
        break
    else:
        if ord(s[i]) == a_num and i != len(s) - 1:
            continue
        elif K > z_num - ord(s[i]) + 1:
            K -= z_num - ord(s[i]) + 1
            s[i]="a"
        elif i == len(s) - 1:
            if ord(s[i])+K <= z_num:
              s[i] = chr(ord(s[i]) + K)
            else:
              s[i] = chr(ord(s[i]) + K - 26)

print("".join(s))

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
ans_list = []
for i, v in enumerate(s):
    
    a = "abcdefghijklmnopqrstuvwxyz".index(v)
    if i != len(s) - 1:
        if a + k >= 26 and 26 - a >= 0:
            k -= 26 - a
            v = "a"
        
    else:
        v = "abcdefghijklmnopqrstuvwxyz"[(a+k)%26]
    ans_list.append(v)

print("".join(ans_list))

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
ans_list = []
for i, v in enumerate(s):
    
    a = "abcdefghijklmnopqrstuvwxyz".index(v)
    if i != len(s) - 1:
        if a + k >= 26:
            k -= 26 - a
            v = "a"
        
    else:
        v = "abcdefghijklmnopqrstuvwxyz"[(a+k)%26]
    ans_list.append(v)

print("".join(ans_list))

Submission status: Wrong Answer

Solution code:
S = list(input())
K = int(input())
characters = ['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']
L = []
for s in S:
  L.append(characters.index(s))
#print(L)

for i in range(len(L)):
  if L[i] == 0:
    pass
  elif 26-L[i] <= K:
    K -= (26-L[i])
    L[i] = 0
  elif K == 0:
    pass
  else:
    pass

#print(L)

P = ""

for l in L:
  P += characters[l]
print(P)

Submission status: Wrong Answer

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

A = []
for s in S:
    t = ord('z') - ord(s) + 1
    if t <= K:
        K -= t
        A.append('a')
    else:
        A.append(s)

A[-1] = chr((ord(A[-1]) + K - ord('a')) % 26 + ord('a'))
print("".join(A))

Submission status: Wrong Answer

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

A = []
for s in S[:-1]:
    t = ord('z') - ord(s) + 1
    if t <= K:
        K -= t
        A.append('a')
    else:
        A.append(s)

A.append(chr(ord('a') + (ord(S[-1]) - ord('a') + K % 26) % 26))

print("".join(A))

Submission status: Wrong Answer

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

A = []
for s in S:
    t = ord('z') - ord(s) + 1
    if t <= K:
        K -= t
        A.append('a')
    else:
        A.append(s)

if K > 0:
    A[-1] = chr(ord('a') + (ord(A[-1]) - ord('a') + K % 26) % 26)

print("".join(A))

Submission status: Wrong Answer

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

A = []
for s in S:
    t = ord('z') - ord(s) + 1
    if t <= K:
        K -= t
        A.append('a')
    else:
        A.append(s)

if K > 0:
    A[-1] = chr(ord(A[-1]) + K % 26)

print("".join(A))

Submission status: Wrong Answer

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

a='abcdefghijklmnopqrstuvwxyz'
d=dict()
for i in range(26):
	d[a[i]]=i
	
for i in range(len(s)):
	if 26-d[s[i]]<n:
		n-=(26-d[s[i]])%26
		s[i]='a'

s[len(s)-1]=a[(d[s[len(s)-1]]+n)%26]
print(''.join(s))

Submission status: Wrong Answer

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

a='abcdefghijklmnopqrstuvwxyz'
d=dict()
for i in range(26):
	d[a[i]]=i
	
for i in range(len(s)):
	if 26-d[s[i]]<=n:
		n-=26-d[s[i]]
		s[i]='a'

s[len(s)-1]=a[(d[s[len(s)-1]]+n)%26]
print(''.join(s))

Submission status: Wrong Answer

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

a='abcdefghijklmnopqrstuvwxyz'
d=dict()
for i in range(26):
	d[a[i]]=i
	
for i in range(len(s)):
	if 26-d[s[i]]<n:
		n-=26-d[s[i]]
		s[i]='a'

s[len(s)-1]=a[(d[s[len(s)-1]]+n)%26]
print(''.join(s))

Submission status: Wrong Answer

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

a='abcdefghijklmnopqrstuvwxyz'
d=dict()
for i in range(26):
	d[a[i]]=i
	
for i in range(len(s)):
	if 26-d[s[i]]<n:
		n-=26-d[s[i]]
		s[i]='a'

s[len(s)-1]=a[(d[s[i]]+n)%26]
print(''.join(s))

Submission status: Wrong Answer

Solution code:
s=input()
K=int(input())
S=[c for c in s]
def diff(c):
    return ord('z')-ord(c)
for i in range(len(s)):
    d=diff(S[i])
    if d<K:
        K-=d+1
        S[i]='a'
k=K%26
S[-1]=chr(ord(S[-1])+k) if k<=diff(S[-1]) else chr(ord(S[-1])+k-26)
print(''.join(S))

Submission status: Wrong Answer

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

D = {chr(i): 0 for i in range(ord('a'),ord('z')+1)}
for i,k in enumerate(D) :
    D[k] = 26-i
D['a'] = 0

ans = []

for i,s in enumerate(S) :
    if i == len(S)-1 :
        K %= 26
        o = (ord(s)-97+K)%26 + 97
        ans.append(chr(o))

    
    elif K >= D[s] :
        K -= D[s]
        ans.append("a")
    
    else :
        ans.append(s)

print(''.join(ans))

Submission status: Wrong Answer

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

D = {chr(i): 0 for i in range(ord('a'),ord('z')+1)}
for i,k in enumerate(D) :
    D[k] = 26-i
D['a'] = 0

ans = []

for i,s in enumerate(S) :
    if i == len(S)-1 :
        K %= 26
        o = (ord(s)-97+K)%26 + 97
        ans.append(chr(o))

    
    elif K >= D[s] :
        K -= D[s]
        ans.append("a")
    
    else :
        ans.append(s)

print("".join(ans))

Submission status: Wrong Answer

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

D = {chr(i): 0 for i in range(ord('a'),ord('z')+1)}
for i,k in enumerate(D) :
    D[k] = 26-i
D['a'] = 0

ans = ""

for i,s in enumerate(S) :
    if i == len(S)-1 :
        K %= 26
        o = (ord(s)-97+K)%26 + 97
        ans += chr(o)

    
    elif K >= D[s] :
        K -= D[s]
        ans += 'a'
    
    else :
        ans += s

print(ans)

Submission status: Wrong Answer

Solution code:
print("aya")

Submission status: Wrong Answer

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

D = {chr(i): 0 for i in range(ord("a"),ord("z")+1)}
for i,k in enumerate(D) :
    D[k] = 26-i
#D['a'] = 0

ans = ""

for i,s in enumerate(S) :
    if i == len(S)-1 :
        K %= 26
        o = (ord(s)-97+K)%26 + 97
        ans += chr(o)
    
    elif s == "a" :
        ans += "a"
        
    
    elif K >= D[s] :
        K -= D[s]
        ans += "a"
    
    else :
        ans += s
print(ans)

Submission status: Wrong Answer

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

D = {chr(i): 0 for i in range(ord("a"),ord("z")+1)}
for i,k in enumerate(D) :
    D[k] = 26-i
#D['a'] = 0

ans = ""

for i,s in enumerate(S) :
    if s == "a" :
        ans += "a"
        
    
    elif K >= D[s] :
        K -= D[s]
        ans += "a"
    
    else :
        ans += s

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

Submission status: Wrong Answer

Solution code:
S = list(input())
K = int(input())
a = ord("a")
for i,s in enumerate(S):
    t = a-ord(s)+26
    if K>=t:
        K-=t
        S[i] = "a"
if K>0:
    S[-1] = chr(a + (ord(S[-1])-a+K)%26)
print("".join(S))

Submission status: Wrong Answer

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

ans = ""
for i in range(len(S)):
    if ord("z") - ord(S[i]) + 1 <= K and i != len(S) - 1:
        ans += "a"
        if S[i] == "a":
            continue
        K -= ord("z") + 1 - ord(S[i])
    elif ord("z") - ord(S[i]) + 1 <= K and i == len(S) - 1:
        K %= 26
        K -= ord("z") + 1 - ord(S[i])
        ans += chr(ord("a") + K)
    elif i == len(S)-1:
        ans += chr( ord(S[i]) + K)
    else:
        ans += S[i]

print(ans)

Submission status: Wrong Answer

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

ans = ""
for i in range(len(S)):
    if ord("z") - ord(S[i]) + 1 <= K and i != len(S) - 1:
        ans += "a"
        K -= ord("z") + 1 - ord(S[i])
    elif ord("z") - ord(S[i]) + 1 <= K and i == len(S) - 1:
        K %= 26
        K -= ord("z") + 1 - ord(S[i])
        ans += chr(ord("a") + K)
    elif i == len(S)-1:
        ans += chr( ord(S[i]) + K)
    else:
        ans += S[i]

print(ans)

Submission status: Wrong Answer

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

ans = ""
for i in range(len(S)):
    if ord("z") - ord(S[i]) + 1 <= K:
        ans += "a"
        K -= ord("z") + 1 - ord(S[i])
    else:
        if i == len(S) - 1:
            if K > 0:
                ans += chr( ord(S[i]) + K%26)
            else:
                ans += S[i]
        else:
            ans += S[i]
print(ans)

Submission status: Wrong Answer

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

ans = ""
for i in range(len(S)):
    if ord("z") - ord(S[i]) + 1 <= K:
        ans += "a"
        K -= ord("z") + 1 - ord(S[i])
    else:
        if i == len(S) - 1:
            if K > 0:
                ans += chr( ord(S[i]) + K)
            else:
              ans += S[i]
        else:
            ans += S[i]

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
alpha=[chr(i) for i in range(97, 97+26)]
for i in range(len(s)):
    if i==len(s)-1:
        k%=26
        s=s[:i]+alpha[(k+alpha.index(s[i]))%26]
    elif k>=26-alpha.index(s[i]):
        k-=26-alpha.index(s[i])
        s=s[:i]+'a'+s[i+1:]  
print(s)

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
alpha=[chr(i) for i in range(97, 97+26)]
for i in range(len(s)):
    if k>=26-alpha.index(s[i]):
        k-=26-alpha.index(s[i])
        s=s[:i]+'a'+s[i+1:]
    elif i==len(s)-1:
        k%=26
        s=s[:i]+alpha[k+alpha.index(s[i])]
print(s)

Submission status: Wrong Answer

Solution code:
S = input()
K = int(input())
N = len(S)
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for i in range(N):
    s = S[i]
    index = alp.find(s)
    if i == N-1:
        ans += alp[(index+K)%26]
    else:
        if 26-index <= K:
            ans += "a"
            K -= (26-index)
        else:
            ans += s
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    alp = list("abcdefghijklnmopqrstuvwxyz")
    s = list(input())
    n = int(input())

    for i in range(len(s)):
        if s[i]=="a": continue
        if alp.index("z") - alp.index(s[i]) < n:
            n -= alp.index("z")-alp.index(s[i]) + 1
            s[i] = 'a'
    if n>0: s[-1] = alp[alp.index(s[-1])+n%26]
    print("".join(s))

if __name__=="__main__": main()

Submission status: Wrong Answer

Solution code:
def main():
    alp = list("abcdefghijklnmopqrstuvwxyz")
    s = list(input())
    n = int(input())

    for i in range(len(s)):
        if alp.index("z") - alp.index(s[i]) < n:
            n -= alp.index("z")-alp.index(s[i]) + 1
            s[i] = 'a'
    s[-1] = alp[alp.index(s[-1])+n%26]

    print("".join(s))

if __name__=="__main__": main()

Submission status: Wrong Answer

Solution code:
def main():
    alp = list("abcdefghijklnmopqrstuvwxyz")
    s = list(input())
    n = int(input())

    for i in range(len(s)-1):
        if alp.index("z") - alp.index(s[i]) < n:
            n -= alp.index("z")-alp.index(s[i]) + 1
            s[i] = 'a'
    b = alp.index(s[-1])+n
    if b>26: s[-1] = alp[b%26-1]
    else: s[-1] = alp[b%26]
    print("".join(s))

if __name__=="__main__": main()

Submission status: Wrong Answer

Solution code:
def main():
    alp = list("abcdefghijklmnopqrstuvwxyz")
    s = list(input())
    n = int(input())

    for i in range(len(s)-1):
        if alp.index("z") - alp.index(s[i]) < n:
            n -= alp.index("z")-alp.index(s[i]) + 1
            s[i] = 'a'
    s[-1] = alp[(alp.index(s[-1])+n)%26]
    print("".join(s))

if __name__=="__main__": main()

Submission status: Wrong Answer

Solution code:
def main():
    alp = list("abcdefghijklmnopqrstuvwxyz")
    s = list(input())
    n = int(input())

    for i in range(len(s)-1):
        if alp.index("z") - alp.index(s[i]) + 1 < n:
            n -= alp.index("z")-alp.index(s[i]) + 1
            s[i] = 'a'
    s[-1] = alp[(alp.index(s[-1])+n)%26]
    print("".join(s))

if __name__=="__main__": main()

Submission status: Wrong Answer

Solution code:
def main():
    alp = list("abcdefghijklnmopqrstuvwxyz")
    s = list(input())
    n = int(input())

    for i in range(len(s)-1):
        if alp.index("z") - alp.index(s[i]) + 1 < n:
            n -= alp.index("z")-alp.index(s[i]) + 1
            s[i] = 'a'
    s[-1] = alp[(alp.index(s[-1])+n)%26]
    print("".join(s))

if __name__=="__main__": main()

Submission status: Wrong Answer

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

t = ""

for i in range(len(s)):
    c=ord(s[i])-97
    if c!=0:
        if K>=26-c:
            K-=26-c
            t="".join([t,"a"])
        else:
            if i!=len(s)-1:
                t="".join([t,s[i]])
            else:
                t="".join([t,chr(97+c+K)])
    else:
        if i!=len(s)-1:
            t="".join([t,"a"])
        else:
            t="".join([t,chr(97+K%26)])

print(t)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())
ans = ''
for ind,i in enumerate(s):
    if(i=='a' and ind!=len(s)-1):
        ans+='a'
        continue
    d = 122-ord(i)
    if(ind==len(s)-1):
        if(K>26):
            K%=26
    if(K>d):
        K-=(d+1)
        ans+='a'
    elif(ind==len(s)-1):
        ans+=chr(ord(i)+K)
    else:
        ans+=i
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())
ans = ''
for ind,i in enumerate(s):
    if(i=='a' and ind!=len(s)-1):
        ans+='a'
        continue
    n = ord(i)
    d = 122-n
    if(ind==len(s)-1):
        K%=26
    if(K>d):
        K-=d+1
        ans+='a'
    elif(ind==len(s)-1):
        K%=26
        ans+=chr(ord(i)+K)
    else:
        ans+=i
print(ans)

Submission status: Wrong Answer

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

ans = ''

for i in range(len(s)-1):
    a = 123-ord(s[i])
    if a==26:
        ans += s[i]
    elif a<k:
        ans += 'a'
        k-=a
    else:
        ans += s[i]

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

print(ans)

Submission status: Wrong Answer

Solution code:
#n,x=map(int,input().split())
#a=[int(i) for i in input().split()]
import string
alp=string.ascii_lowercase
di={}
for i in range(26):
    di[alp[i]]=i
s=input()
a=[]
for i in s:
    a.append(i)
l=a.pop()
if a:
    a=a[::-1]
k=int(input())
ans=''
i=0
while a:
    t=a.pop()
    d=(26-di[t])%26
    if d<=k:
        k-=d
        #ans+='a'
    else:
        0
        #ans+=t
    i+=1
kk=k%26
#ans+=alp[(alp.index(l)+kk)%26]
print(ans)

Submission status: Wrong Answer

Solution code:
#n,x=map(int,input().split())
#a=[int(i) for i in input().split()]
import string
alp=string.ascii_lowercase
di={}
for i in range(26):
    di[alp[i]]=i
s=input()
a=[]
for i in s:
    a.append(i)
l=a.pop()
if a:
    a=a[::-1]
k=int(input())
ans=''
i=0
while a:
    t=a.pop()
    d=(26-di[t])%26
    if d<=k:
        k-=d
        ans+='a'
    else:
        ans+=t
    i+=1
kk=k%26
#ans+=alp[(alp.index(l)+kk)%26]
print(ans)

Submission status: Wrong Answer

Solution code:
#n,x=map(int,input().split())
#a=[int(i) for i in input().split()]
import string
alp=string.ascii_lowercase
di={}
for i in range(26):
    di[alp[i]]=i
s=input()
a=[]
for i in s:
    a.append(i)
l=a.pop()
if a:
    a=a[::-1]
k=int(input())
ans=''
i=0
while a:
    t=a.pop()

Submission status: Wrong Answer

Solution code:
#n,x=map(int,input().split())
#a=[int(i) for i in input().split()]
import string
alp=string.ascii_lowercase
di={}
for i in range(26):
    di[alp[i]]=i
s=input()
a=[]
for i in s:
    a.append(i)