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: Runtime Error

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(ord(s[i])+k)

print(''.join(s))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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))
        exit()

print(''.join(ans))

Submission status: Runtime Error

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:
        ans[0] = chr(ord(s[0])+K)

print(''.join(ans))

Submission status: Runtime Error

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 and len(ans) >= 1:
    ans[-1] = chr(ord(ans[-1])+K)
else:
    ans[0] = chr(ord(s[0])+K)

print(''.join(ans))

Submission status: Runtime Error

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)

print(''.join(ans))

Submission status: Runtime Error

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 += 'a'
    else:
        ans += s[i]

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

print(ans)

Submission status: Runtime Error

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 += 'a'
    else:
        ans += s[i]

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

print(ans)

Submission status: Runtime Error

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])
    if last_ind + num <= 122:
        last_ind += num
    else:
        last_ind = last_ind + num - 27
    s[-1] = chr(last_ind)

    print(''.join(s))



if __name__ == '__main__':
    main()

Submission status: Runtime Error

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] += k

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

Submission status: Runtime Error

Solution code:
S = input()
K = int(input())
length = len(S)
alpha, n = 'abcdefghijklmnopqrstuvwxyz', 26
i = 0
ans = ''
while i < length:
    diff = (n - (ord(S[i]) - ord('a'))) % 26
    
    if 0 <= diff <= K:
        ans += 'a'
        K -= diff
    else:
        ans += S[i]
        
    i += 1
    if K == 0:
        ans += S[i:]
else:
    ans = ans[:-1] + chr(ord(ans[-1]) + K % 26)
print(ans)

Submission status: Runtime Error

Solution code:
S = input()
K = int(input())
length = len(S)
alpha, n = 'abcdefghijklmnopqrstuvwxyz', 26
i = 0
ans = ''
while i < length:
    diff = (n - (ord(S[i]) - ord('a'))) % 26
    
    if 0 <= diff <= K:
        ans += 'a'
        K -= diff
    else:
        ans += S[i]
        
    i += 1
    if K == 0:
        ans += S[i:]
else:
    print(K)
    ans = ans[:-1] + chr(ord(ans[-1]) + K % 26)
print(ans)

Submission status: Runtime Error

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])]
    elif k>=26-alpha.index(s[i]):
        k-=26-alpha.index(s[i])
        s=s[:i]+'a'+s[i+1:]  
print(s)

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
for i in range(len(s)-1):
    if K == 0:
        break
    else:
        if s[i] == "a":
            continue
        else:
            if 123-ord(s[i]) <= K:
                K -= 123-ord(s[i])
                s[i] = "a"

K = K %26
if K > 0:
    if ord(s[-1])+K <= 122:
        s[-1] = chr(ord(s[-1])+K)
    else:
        s[-1] = chr(97+(ord(s[-1]+K-122)))

print(*s,sep="")

Submission status: Runtime Error

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: Runtime Error

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: Runtime Error

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:
    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: Runtime Error

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:
    ans+=chr(ord(s[-1])+k)
  elif k>=C[i]:
    ans+="a"
    k-=C[i]
  else:
    ans+=s[i]
print(ans)

Submission status: Runtime Error

Solution code:
s=input()
l=[]
for i in s:l.append((123-ord(i))%26)
k=int(input())
for i,j in enumerate(l):
    if j<=k:l[i],k=26,k-j
l[-1]=(l[-1]-k)+[0,26][l[-1]-k<1]
for i,j in enumerate(l):l[i]=chr(123-j)
print(''.join(map(str,l)))

Submission status: Runtime Error

Solution code:
alpha='abcdefghijklmnopqrstuvwxyz'
S=input()
K=int(input())
ans=''
for s in S:
    idx=alpha.index(s)
    if idx==0 or 26-idx>K:
        ans+=s
        continue
    else:
        K-=26-idx
        ans+='a'
if K>0:
    tar=ans[-1]
    idx=alpha.index(tar)
    ans=ans[:-1]+alpha[idx+K]
print(ans)

Submission status: Runtime Error

Solution code:
s=input()
K=int(input())
ans=[]

for c in s:
  if c=="a":
    ans.append(c)
    continue
  if ord("z")+1- ord(c)<=K:
    K-=ord("z")+1-ord(c)
    ans.append("a")
    continue
    
  ans.append(c)
    
if K:
  ans[-1]=chr( ord(ans[-1])+K)
print("".join(ans))

Submission status: Runtime Error

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 = ans[-1]
    tail_ord = ord(tail)
    ans = ans[:-1] + chr((tail_ord + K) % 97 + 97)

print(ans)

Submission status: Runtime Error

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)
newS[-1] = chr(ord(newS[-1]) + N)
print(''.join(newS))

Submission status: Runtime Error

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)
newS[-1] = chr(ord(newS[-1]) + N)
print(newS)

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
ans = ''
alphas = {'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}
a = 'abcdefghijklmnopqrstuvwxyz'
dict1 = {}
dict2 = {}
i = 1
while i <= 26:
  dict1[i] = a[i-1]
  dict2[a[i-1]] = i
  i += 1
for chara in s:
  if alphas[chara] <= K:
    ans = ans + 'a'
    K = K - alphas[chara]
  else:
    ans = ans + chara
K = K%26
ans = ans[:-1]+dict1[(dict2[ans[-1]]+K)%26]
print(ans)

Submission status: Runtime Error

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

    s[len(s) - 1] = chr(ord(s[len(s) - 1]) + K)
    
elif len(s) == 1:
    s[0] = chr(ord(s[0]) + K)

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

Submission status: Runtime Error

Solution code:
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

# ここから処理
s = ns()
k = ni()

chl = list(s)
res = k

for i, c in enumerate(chl):
    if res >= ord("z") - ord(c) + 1:
        chl[i] = "a"
        res -= (ord("z") - ord(c) + 1)

chl[-1] = chr(ord(chl[-1]) + res)

print("".join(chl))

Submission status: Runtime Error

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

ans = ""
for i in range(len(S)-1):
    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: Runtime Error

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)
print(ans)

Submission status: Runtime Error

Solution code:

aord = ord("a")
s = list(raw_input())
k = int(input())
i = 0

while k > 0 and i < len(s):
	if k >= ord('z') - ord(s[i]) + 1:
		if s[i] == "a": continue
		k -= ord('z') - ord(s[i]) + 1
		s[i] = "a"

	i += 1

s[len(s)-1] = chr(ord(s[len(s)-1]) + k)
print ''.join(s)

Submission status: Runtime Error

Solution code:

aord = ord("a")
s = list(raw_input())
k = int(input())
i = 0

while k > 0 and i < len(s):
	if k >= (aord + 26 - ord(s[i])):
		k -= (aord + 26 - ord(s[i]))
		s[i] = "a"

	i += 1

s[len(s)-1] = chr(ord(s[len(s)-1]) + k)
print ''.join(s)

Submission status: Runtime Error

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"

while K > 0:
    if ord("z") - ord(sArr[endpoint]) >= K:
        sArr[endpoint] = chr(ord(sArr[endpoint]) + K)
        K = 0
    else:
        sArr[endpoint] = "z"
        K -= ord("z") - ord(sArr[endpoint])
        endpoint -= 1
    if endpoint == 0 and K != 0:
        while endpoint != len(s) - 1 or K != 0:
            sArr[endpoint] = "a"
            K -= 1
            endpoint += 1

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

print(result)

Submission status: Runtime Error

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"

while K > 0:
    if ord("z") - ord(sArr[endpoint]) >= K:
        sArr[endpoint] = chr(ord(sArr[endpoint]) + K)
        K = 0
    else:
        sArr[endpoint] = "z"
        K -= ord("z") - ord(sArr[endpoint])
        endpoint -= 1
    if endpoint == 0 and K != 0:
        while endpoint != len(s) - 1:
            sArr[endpoint] = "a"
            K -= 1
            endpoint += 1

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

print(result)

Submission status: Runtime Error

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"

while K > 0:
    if ord("z") - ord(sArr[endpoint]) >= K:
        sArr[endpoint] = chr(ord(sArr[endpoint]) + K)
        K = 0
    else:
        sArr[endpoint] = "z"
        K -= ord("z") - ord(sArr[endpoint])
        endpoint -= 1
    if endpoint == 0 and K != 0:
        while endpoint != len(s) - 1:
            sArr[endpoint] = "a"
            K -= 1

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

print(result)

Submission status: Runtime Error

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"

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

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

print(result)

Submission status: Runtime Error

Solution code:
jkl;

Submission status: Runtime Error

Solution code:
hoge

Submission status: Runtime Error

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]+=k
for n in s:
    print(chr(ord('a')+n),end='')
print()

Submission status: Runtime Error

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

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
a[-1] = chr(temp)
print(''.join(a))

Submission status: Runtime Error

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: Runtime Error

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('a')+(26-(ord(s[len(s)-1])+k)-1))
print(''.join(s))

Submission status: Runtime Error

Solution code:
S = input()
k = int(input())
goal = ord('z') + 1
ans = []
for c in S:
    if c == 'a': continue
    d = goal - ord(c)
    if k >= d:
        k -= d
        ans.append('a')
    else:
        ans.append(c)
last = (k + ord(ans[-1]) - ord('a')) % 26
ans[-1] = chr(ord('a') + last)
print(''.join(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
alphabet = "abcdefghijklmnopqrstuvwxyz"
my_listChar = []

def moveChar(inputchar):
    index = alphabet.find(inputchar)
    return alphabet[(index + 1) % 26]

def nextChar(inChar, maxNoOfConverted, inputString):
    maxNum = int(maxNoOfConverted)
    output = inChar
    my_listChar.append(output)
    for charInd in range(maxNum):
        output = moveChar(output)
        if (output <= inChar):
            my_listChar.pop()
            my_listChar.append(output)
            return (charInd + 1)
    #print output
    return 0

def convertStr(inputString, ith):
    remainNo = int(ith)
    if (len(inputString) == 1):
        movingSteps = remainNo
        output = inputString
        while(movingSteps > 0):
            output = moveChar(output)
            movingSteps = movingSteps - 1
        return output
    for charInd in range(len(inputString)):
        usedNo = nextChar(inputString[charInd], remainNo, inputString)
        remainNo = remainNo - usedNo

input1 = raw_input("K - number of converted times: ")
input2 = raw_input("<string> - input string to be converted: ")
output = convertStr(input2, input1)
print "===================================="
if my_listChar:
    print "Final output is ",''.join(my_listChar)
else:
    print "Final output is " + output
#print join(',',my_listChar)

Submission status: Runtime Error

Solution code:
my_listChar = []

def moveChar(inputchar):
    index = alphabet.find(inputchar)
    return alphabet[(index + 1) % 26]

def nextChar(inChar, maxNoOfConverted, inputString):
    maxNum = int(maxNoOfConverted)
    output = inChar
    my_listChar.append(output)
    for charInd in range(maxNum):
        output = moveChar(output)
        if (output <= inChar):
            my_listChar.pop()
            my_listChar.append(output)
            return (charInd + 1)
    #print output
    return 0

def convertStr(inputString, ith):
    remainNo = int(ith)
    if (len(inputString) == 1):
        movingSteps = remainNo
        output = inputString
        while(movingSteps > 0):
            output = moveChar(output)
            movingSteps = movingSteps - 1
        return output
    for charInd in range(len(inputString)):
        usedNo = nextChar(inputString[charInd], remainNo, inputString)
        remainNo = remainNo - usedNo

input1 = raw_input("K - number of converted times: ")
input2 = raw_input("<string> - input string to be converted: ")
output = convertStr(input2, input1)
print "===================================="
if my_listChar:
    print "Final output is ",''.join(my_listChar)
else:
    print "Final output is " + output
#print join(',',my_listChar)

Submission status: Runtime Error

Solution code:
a=[ord(i) for i in input()]
s = int(input())
for i in range(len(a)):
 if 26+97-a[i]<=s && a[i]!=97:
     aa=a[i]
     a[i]=97
     s-=26+97-aa
if s>0:
 a[-1]+=s
 if a[-1]>97+25:
     a[-1]=(a[-1]-97)%26+97
b=""
for i in a:
 b+=chr(i) 
print(b)

Submission status: Runtime Error

Solution code:
s = raw_input()
N = int(raw_input())
dis = [ord('z')-ord(c) for c in s]
for idx, d in enumerate(dis[:-1]):
    if d <= N:
        s[idx] = 'a'
        N -= d
if N > 0:
    N %= 27
    t = (dis[-1]-N) % 27
    s[-1] = chr(ord('z') - t)
print s

Submission status: Runtime Error

Solution code:
s = raw_input()
N = int(raw_input())
dis = [ord('z')-ord(c) for c in s]
for idx, d in enumerate(dis[:-1]):
    if d <= N:
        s[idx] = 'a'
        N -= d
if N > 0:
    N %= 27
    t = (dis[-1]-N) % 27
    s[-1] = chr(ord('z') - t)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-09-28
#

# Usage
#
"""
import sys

def input_single_line():
    """Receive Inputs."""
    return input()

def input_two_line():
    """Receive Two Lined Inputs.
    Like this.

    N
    1 2 3 4 5
    """
    n = sys.stdin.readline()
    n = n.rstrip("\n")
    target = sys.stdin.readline()
    target = target.rstrip("\n")
    # target = target.split(" ")

    return n, target


def check_a_becombility(one_str: str) -> int:
    """Check how can this str become "a"
    >>> check_a_becombility("a")
    0
    >>> check_a_becombility("z")
    1
    >>> check_a_becombility("b")
    25
    """
    if ord(one_str) == 97:
        return 0  # Because this is "a"

    return 123 - ord(one_str)


def make_suzuki_process(target_str :str, chance: int) -> str:
    """Suzuki Process.
    >>> make_suzuki_process("xyz", 4)
    'aya'
    >>> make_suzuki_process("a", 25)
    'z'
    >>> make_suzuki_process("codefestival", 100)
    'aaaafeaaivap'
    """
    target_str = list(target_str)
    costs = [check_a_becombility(i) for i in target_str]

    for pos, each_cost in enumerate(costs):
        if chance - each_cost >= 0:
            chance = chance - each_cost
            target_str[pos] = "a"

    if chance > 0:
        temp = ord(target_str[-1]) + chance
        if temp > 122:
            target_str[-1] = chr(temp % 97)
        else:
            target_str[-1] = chr(temp)

    return "".join(target_str)

if __name__ == "__main__":
    import doctest
    doctest.testmod()

    inputted = input_two_line()

    make_suzuki_process(inputted[0], inputted[1])

Submission status: Runtime Error

Solution code:
def decoder(str_int):
    s_=''
    for a in str_int:
        s_ = s_+(alpbet[a])
    return s_

s = raw_input()
K = input()

alpbet = 'abcdefghijklmnopqrstuvwxyz'
encoder = lambda s: [alpbet.index(a) for a in s]
inc_count = K
str_int = encoder(s)
for i in range(len(str_int)):
    #末尾文字でない
    if i != len(str_int)-1:
        #b~zの間でかつデクリメントできる
        if str_int[i] > 0:
            #aになるまで必要なインクリメント回数
            cost = 26 - str_int[i]
            if inc_count > cost:
                inc_count -= cost
                str_int[i] = 0
    else:
        str_int[i] = (str_int[i] + inc_count) % 26
        
print decoder(str_int)

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    if K > 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

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

print("".join(s))

Submission status: Runtime Error

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


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']

def s_i(st):
    return ord(st) - 96

j = 0
while k > 0:
    a = s_i(s[j])
    if s[j] == 'a' and j < len(s)-1:
        pass
    elif 27 - a <= k:
        k = k - (27 - a)
        s = s[:j] + 'a' + s[j+1:]
    elif j == len(s) - 1:
        t = (a+k)%26 - 1
        if t >= 0:
            s = s[:j] + s_l[t]
        else:
            s = s[:j] + s_l[t + 26]
        break
    else:
        pass
    j += 1

print s

Submission status: Runtime Error

Solution code:
s = raw_input()
K = input()
base = ord('a')
result = ''

if len(s) == 1:
    K = K % 26
    print chr( base + (((ord(s[0]) - base) + K) % 26))
    return
    
def willA(c, i):
    a = 26 - (ord(c) - base)
    if ord(c) - base + i >= 27:
        return True, a
    else:
        return False,0
    
for i in xrange(len(s) - 1):
    f, n = willA(s[i], K)
    K = K - n
    if f:
        result += 'a'
    else:
        result += s[i]

K = K % 26
result += chr( base + (((ord(s[-1:]) - base) + K) % 26))

Submission status: Runtime Error

Solution code:
s = raw_input()
k = float(raw_input())


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']

def s_i(st):
    for i in range(26):
        if st == s_l[i]:
            break
    return i + 1

j = 0
while k > 0:
    a = s_i(s[j])
    if s[j] == 'a' and j < len(s)-1:
        pass
    elif 27 - a <= k:
        k = k - (27 - a)
        s = s[:j] + 'a' + s[j+1:]
    elif j == len(s) - 1:
        t = (a+k)%26 - 1
        if t >= 0:
            s = s[:j] + s_l[t]
        else:
            s = s[:j] + s_l[t + 26]
        break
    else:
        pass
    j += 1

print s

Submission status: Runtime Error

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


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']

def s_i(st):
    for i in range(26):
        if st == s_l[i]:
            break
    return i + 1

j = 0
while k > 0:
    a = s_i(s[j])
    if s[j] == 'a' and j < len(s)-1:
        pass
    elif 27 - a <= k:
        k = k - (27 - a)
        s = s[:j] + 'a' + s[j+1:]
    elif j == len(s) - 1:
        t = (a+k)%26 - 1
        if t >= 0:
            s = s[:j] + s_l[t]
        else:
            s = s[:j] + s_l[t + 26]
        break
    else:
        pass
    j += 1

print s

Submission status: Runtime Error

Solution code:
#read in input
s = map((lambda x: ord(x) - 96), raw_input())
k = int(raw_input())


for i in range(len(s)):
  sv = s[i]
  if sv == 1 || (27 - sv) > k:
    continue
  s[i] = 1
  k = k - (27 - sv)

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

print "".join(map((lambda x: chr(x + 96)), s))

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

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

print("".join(s))

Submission status: Runtime Error

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


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']

def s_i(st):
    for i in range(26):
        if st == s_l[i]:
            return i + 1
            break

j = 0
while k > 0:
    a = s_i(s[j])
    if s[j] == 'a' and j < len(s)-1:
        pass
    elif 27 - a <= k:
        k = k - (27 - a)
        s = s[:j] + 'a' + s[j+1:]
    elif j == len(s) - 1:
        t = (a+k)%26 - 1
        if t >= 0:
            s = s[:j] + s_l[t]
        else:
            s = s[:j] + s_l[t + 26]
        break
    else:
        pass
    j += 1

print s

Submission status: Runtime Error

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


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']

def s_i(st):
    for i in range(26):
        if st == s_l[i]:
            return i + 1
            break

j = 0
while k > 0:
    if s[j] == 'a' and j < len(s)-1:
        pass
    elif 27 - s_i(s[j]) <= k:
        k = k - (27 - s_i(s[j]))
        s = s[:j] + 'a' + s[j+1:]
    elif j == len(s) - 1:
        t = (s_i(s[j])+k)%26 - 1
        if t >= 0:
            s = s[:j] + s_l[t]
        else:
            s = s[:j] + s_l[t + 26]
        break
    else:
        pass
    j += 1

print s

Submission status: Runtime Error

Solution code:
s=input()
k=int(input())
d = dict()
for i in range(len(alphabet)):
    d[alphabet[i]]=i
    
def f(s,k):
    s = [s[i] for i in range(len(s))]
    res = s
    L = 0
    for i in range(len(s)):
        l = max(26 - d[s[i]],0)
        if L + l < k:
            res[i] = "a"
            L += l
        else:
            if i==len(s)-1:
                res[i] = alphabet[(d[s[i]] + (k-L)) % 26]
            continue
    return(''.join(res))
print(f(s,k))

Submission status: Runtime Error

Solution code:
s=input()
k=int(input())
d = dict()
for i in range(len(alphabet)):
    d[alphabet[i]]=i
    
def f(s,k):
    s = [s[i] for i in range(len(s))]
    res = s
    L = 0
    for i in range(len(s)):
        l = max(26 - d[s[i]],0)
        if L + l < k:
            res[i] = "a"
            L += l
        else:
            if i==len(s)-1:
                res[i] = alphabet[(d[s[i]] + (k-L)) % 26]
            continue
    return(''.join(res))
f(s,k)

Submission status: Runtime Error

Solution code:
#C-Next Letter
str = input()
K = int(input())
tempK = K
result = ""
for i in range(len(str)-1):
	changeNum = 122-ord(str[i])+1
	if (changeNum <= tempK):
		result += "a"
		tempK -= changeNum
		if (tempK == 0):
			result += str[i+:]
			print(result)
			break
	else:
		result += str[i]
tempK %= 26
if (tempK > 0):
	changeNum = ord(str[-1]) + tempK
	if (changeNum > 122):
		changeNum = changeNum -122 + 97 -1
	else:
		changeNum = changeNum
	result += chr(changeNum)
else:
	result += str[-1]
print(result)

Submission status: Runtime Error

Solution code:
s=input()
list=[]
flag=false
k=int(input())
for i in range(len(s)):
    if (ord(s[i])+k)>122:
        list.append('a')
        k=k-(123-ord(s[i]))
    else:
        list.append(s[i])
        flag=true
if flag==true:
    for i in reversed(len(s)):
        if list[i]!='a':
            x=122-ord(s[i])
            if x<=k:
                list[i]=chr(ord(s[len(s)])+k)
            else:
                list[i]='z'
                k=k-x
else:
    for i in range(len(s)):
        print(list[i], end='')

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

# need = 0
# for i in range(len(s)):
#     need += ord("z") - ord(s[i]) + 1

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

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

print("".join(s))

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

need = 0
for i in range(len(s)):
    need += ord("z") - ord(s[i]) + 1

for i in range(len(s)):
    if K >= 26 or s[i] >= alphabet[-K]:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"

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

print("".join(s))