ZhenlongDai/ACPR huggingface dataset:
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
K = int(input())

a = [0] * len(s)
for i in range(len(s)):
  a[i] =  ((ord('z') - ord(s[i])) + 1)%26
  if a[i] == 0:
    pass
  elif K - a[i] >= 0:
    K -= a[i]
    a[i] = 0
for i in range(len(s)-1):
  print(chr((26-a[i])%26+ord('a')), end = '')

if K != 0:
  b = ord('a') + (ord(s[-1])-ord('a') + K)%26
  print( chr( b ) ) 
else:
  print(chr((26-a[-1])%26+ord('a')))
  


Failing test case input:
{yz
19

Expected output:
aaq


Actual output:
aap


Fixed submission (verdict: Accepted):
s = input()
K = int(input())

a = [0] * len(s)
for i in range(len(s) - 1):
  a[i] =  ((ord('z') - ord(s[i])) + 1)%26
  if a[i] == 0:
    pass
  elif K - a[i] >= 0:
    K -= a[i]
    a[i] = 0

for i in range(len(s)-1):
  print(chr((26-a[i])%26+ord('a')), end = '')

if K != 0:
  b = ord('a') + (ord(s[-1])-ord('a') + K)%26
  print( chr( b ) ) 
else:
  print(s[-1])

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
K = int(input())

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

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

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

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

print(result)

Failing test case input:
lavitsgfeodc
111

Expected output:
aaaaaaaaeadh


Actual output:
aaaaaaafeadc


Fixed submission (verdict: Accepted):
s = input()
K = int(input())

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

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

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

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

print(result)

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
l=len(s)
k=int(input())
z=''
for i in range(l):
  t=123-ord(s[i])
  if t<=k:
    z+='a'
    k-=t
  else:
    z+=s[i]
k=k%26
z=z[:l-1]+chr((ord(z[l-1])+k)%26)
print(z)

Failing test case input:
liwbtsffeodc
001

Expected output:
liwbtsffeodd


Actual output:
liwbtsffeod


Fixed submission (verdict: Accepted):
s=input()
l=len(s)
k=int(input())
z=''
for i in range(l):
  t=123-ord(s[i])
  if s[i]=='a':
    z+='a'
  elif t<=k:
    z+='a'
    k-=t
  else:
    z+=s[i]
v=ord(z[l-1])-97+k
z=z[:l-1]+chr(v%26+97)
print(z)
Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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))


Failing test case input:
caoffestiwdl
101

Expected output:
aaaaaastiwdm


Actual output:
aaaafeaaiwdo


Fixed submission (verdict: Accepted):
s = input()
K = int(input())

ans = []
for i in range(len(s)):
    if K >= ord('z')-ord(s[i])+1 and s[i] != 'a':
        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))

Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
k = int(input())
v = list(s)

a = [0 for i in range(len(s))]
t = ''

for i in range(len(s)):
  a[i] = 123 - ord(s[i])
  if k >= a[i]:
    v[i] = 'a'
    k -= a[i]

if k > 0:
  k %= 26
  v[len(s)-1] = chr(ord(v[len(s)-1])+k)
print (''.join(v))

Failing test case input:
lavitsgfeodc
101

Expected output:
aaaaaaaaeodj


Actual output:
aaaaaaafeode


Fixed submission (verdict: Accepted):
s = input()
k = int(input())
v = list(s)
n = len(s)
a = [0 for i in range(n)]

for i in range(n):
  a[i] = (123 - ord(s[i]))%26
  if k == 0:
    break
  if k >= a[i]:
    v[i] = 'a'
    k -= a[i]

if k > 0:
  k %= 26
  v[n-1] = chr(ord(v[n-1])+k)
print (''.join(v))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
K = int(input())

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

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

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

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

print(result)

Failing test case input:
daoffestiwdl
101

Expected output:
aaaaaastiwdn


Actual output:
aaaafeaaiadl


Fixed submission (verdict: Accepted):
s = input()
K = int(input())

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

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

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

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

print(result)
Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = list(input())
k = int(input())
t = list(map(lambda x:ord(x)-ord("a"),s)) 

for i in range(len(t)):
  diff = 26-t[i] 
  if diff <= k:
    t[i]+=diff
    k-=diff
  else:
    continue
t[-1]+=k 



u = "".join(list(map(lambda x:chr((x%26+ord("a"))),t)))
print(u)

Failing test case input:
caoffestiwdl
111

Expected output:
aaaaaaatiwdo


Actual output:
aaaaaesaiwdl


Fixed submission (verdict: Accepted):
s = list(input())
k = int(input())
t = list(map(lambda x:ord(x)-ord("a"),s)) 

for i in range(len(t)):
  diff = 26-t[i] 
  if diff != 26 and diff <= k: 
    t[i]+=diff
    k-=diff
  else:
    continue

t[-1]+=k 

u = "".join(list(map(lambda x:chr((x%26+ord("a"))),t)))
print(u)

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def cost_for_next_a(c):
    return 123 - ord(c)

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

new_s = ""











for i in range(len(s)):
    if i == len(s) - 1:
        if cost_for_next_a(s[i]) <= K:
            new_s += chr(97 + (K - cost_for_next_a(s[i])) % 26)
        else:
            new_s += chr(ord(s[i]) + K)
    elif cost_for_next_a(s[i]) <= K:
        new_s += "a"
        K -= cost_for_next_a(s[i])
    else:
        new_s += s[i]

print(new_s)


Failing test case input:
lavitsffeodc
110

Expected output:
aaaaaaaaeadf


Actual output:
aaaaaaafeodm


Fixed submission (verdict: Accepted):
def cost_for_next_a(c):
    return 123 - ord(c)

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

new_s = ""











for i in range(len(s)):
    if i == len(s) - 1:
        if cost_for_next_a(s[i]) <= K:
            new_s += chr(97 + (K - cost_for_next_a(s[i])) % 26)
        else:
            new_s += chr(ord(s[i]) + K)
    elif s[i] == 'a':
        new_s += 'a'
    elif cost_for_next_a(s[i]) <= K:
        new_s += "a"
        K -= cost_for_next_a(s[i])
    else:
        new_s += s[i]

print(new_s)

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

S = list(readline().rstrip())
K = int(readline())
N = len(S)
for i in range(N):
    t = ord(S[i])-97
    if 26 - t <= K:
        S[i] = 'a'
        K -= 26-t
S[-1] = chr((ord(S[-1])-97 + K%26)%26 + 97)
print(''.join(S))





Failing test case input:
lavitsgfeodc
101

Expected output:
aaaaaaaaeodj


Actual output:
aaaaaaafeode


Fixed submission (verdict: Accepted):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

S = list(readline().rstrip())
K = int(readline())
N = len(S)
for i in range(N):
    t = ord(S[i])-97
    if t == 0:
        continue
    if 26 - t <= K:
        S[i] = 'a'
        K -= 26-t
S[-1] = chr((ord(S[-1])-97 + K%26)%26 + 97)
print(''.join(S))
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(input())
k=int(input())
for i in range(len(s)):
    if k>=ord("z")-ord(s[i])+1:
        k-=(ord("z")-ord(s[i])+1)
        s[i]="a"

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

print("".join(s))


Failing test case input:
caoffestivdl
110

Expected output:
aaaaaaativdn


Actual output:
aaaaaestiadm


Fixed submission (verdict: Accepted):
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:
    k%=26
    s[-1]=chr(ord(s[-1])+k)

print("".join(s))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)



Failing test case input:
caoffestiwdl
111

Expected output:
aaaaaaatiwdo


Actual output:
aaaaaesaiwdl


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

print(ans[:-1]+last)

Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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))

Failing test case input:
lawitsffeodc
100

Expected output:
aaaaaaaaeodi


Actual output:
aaaaaaafeodd


Fixed submission (verdict: Accepted):
S = input()
K = int(input())
Ans = []
for s in S[:-1]:
    if s == 'a':
        Ans.append('a')
        continue
    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))
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline


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

Failing test case input:
caoeffstivdl
111

Expected output:
aaaaaaativdo


Actual output:
aaaaafstiadm


Fixed submission (verdict: Accepted):
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline


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 S[i] == 0:
        continue
    if c <= N:
        N -= c
        S[i] = 0

S[-1] += N % 26

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

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(input())
k=int(input())
for i in range(len(s)-1):
    if k>=ord("z")-ord(s[i])+1:
        k-=(ord("z")-ord(s[i])+1)
        s[i]="a"

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

print("".join(s))


Failing test case input:
caoffestiwdl
111

Expected output:
aaaaaaatiwdo


Actual output:
aaaaaesaiwdl


Fixed submission (verdict: Accepted):
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:
    k%=26
    s[-1]=chr(ord(s[-1])+k)

print("".join(s))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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()


Failing test case input:
lwsitafffodc
101

Expected output:
aaaaaaaafodj


Actual output:
aaaaaaaffode


Fixed submission (verdict: Accepted):
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)):
        if nums[i] == 0:
            continue
        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()
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
K = int(input())

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

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

print(''.join(s))


Failing test case input:
lavitsgfeodc
111

Expected output:
aaaaaaaaeadh


Actual output:
aaaaaaafeadc


Fixed submission (verdict: Accepted):
s = list(input())
K = int(input())

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

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

print(''.join(s))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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))


Failing test case input:
caoffestiwdl
101

Expected output:
aaaaaastiwdm


Actual output:
aaaafeaaiwdo


Fixed submission (verdict: Accepted):
S = input()
K = int(input())

A = []
for s in S:
    if s == 'a':
        A.append('a')
        continue
    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))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k =int(input())
sn = []
sa = []
num2alpha = lambda c: chr(c+64)
alpha2num = lambda c: ord(c) - ord('A') + 1

for c in s:
    sn.append(alpha2num(c))

for i in range(0,len(sn)-1):
    if 59 - sn[i] <= k:
        k -= 59 - sn[i]
        sn[i] = 33
    else:
        continue

sn[-1] = (sn[-1] + k-33) % 26 + 33

for c in sn:
    sa.append(num2alpha(c))

print("".join(sa))


Failing test case input:
caoffestivdl
110

Expected output:
aaaaaaativdn


Actual output:
aaaaaestiadm


Fixed submission (verdict: Accepted):
s = input()
k =int(input())
sn = []
sa = []
num2alpha = lambda c: chr(c+64)
alpha2num = lambda c: ord(c) - ord('A') + 1

for c in s:
    sn.append(alpha2num(c))

for i in range(0,len(sn)-1):
    if sn[i] != 33 and 59 - sn[i] <= k:
        k -= 59 - sn[i]
        sn[i] = 33
    else:
        continue

sn[-1] = (sn[-1] + k-33) % 26 + 33

for c in sn:
    sa.append(num2alpha(c))

print("".join(sa))
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

str = input()
K = int(input())
tempK = K
result = ""
for i in range(len(str)):
	changeNum = 122-ord(str[i])+1
	if (changeNum <= tempK):
		result += "a"
		tempK -= changeNum
	else:
		result += str[i]
if (tempK != 0):
	result = result[:-1] + chr(ord(str[-1]) + tempK)
print(result)


Failing test case input:
xxz
2

Expected output:
xxb


Actual output:
xx{


Fixed submission (verdict: Accepted):

str = input()
K = int(input())
tempK = K
result = ""
for i in range(len(str)-1):
	changeNum = 122-ord(str[i])+1
	if (changeNum <= tempK and str[i] != "a"):
		result += "a"
		tempK -= changeNum
	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)

Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    S = input()
    K = int(input())
    ans = ['' for _ in range(len(S))]
    for i in range(len(S)):
        d = ord(S[i]) - ord('a')
        shift = (26 - d) % 26
        if K - shift >= 0:
            ans[i] = 'a'
            K -= shift
        else:
            ans[i] = S[i]
    if K > 0:
        K %= 26
        d = (K + ord(S[i]) - ord('a')) % 26
        ans[-1] = chr(d + ord('a'))
    print(''.join(ans))


if __name__ == '__main__':
    main()


Failing test case input:
{yy
19

Expected output:
aap


Actual output:
aan


Fixed submission (verdict: Accepted):
def main():
    S = input()
    K = int(input())
    ans = ['' for _ in range(len(S))]
    for i in range(len(S)):
        d = ord(S[i]) - ord('a')
        shift = (26 - d) % 26
        if K - shift >= 0:
            ans[i] = 'a'
            K -= shift
        else:
            ans[i] = S[i]
    if K > 0:
        K %= 26
        d = (K + ord(ans[-1]) - ord('a')) % 26
        ans[-1] = chr(d + ord('a'))
    print(''.join(ans))


if __name__ == '__main__':
    main()
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

readline = sys.stdin.buffer.readline


def main():
    s = list(readline())
    s = s[:-1]
    K = int(readline())

    B = [0 for _ in range(len(s))]
    for i in range(len(s)):
        b = 26 - (s[i] - ord("a"))
        if b <= K:
            K -= b
            B[i] = 0
        else:
            B[i] = b

    if K != 0:
        B[-1] -= K
        B[-1] %= 26

    ans = list(map(lambda c: chr(ord("a") + (26 - c) % 26), B))
    print("".join(ans))


main()


Failing test case input:
caoffestivdl
110

Expected output:
aaaaaaativdn


Actual output:
aaaaaestiadm


Fixed submission (verdict: Accepted):
def main():
    s = list(input())
    K = int(input())

    s = list(map(lambda x: ord(x), s))
    B = [0 for _ in range(len(s))]
    for i in range(len(s)):
        b = 26 - (s[i] - ord("a"))
        if b == 26:
            B[i] = 0
        elif b <= K:
            K -= b
            B[i] = 0
        else:
            B[i] = b

    if K != 0:
        B[-1] -= K
        B[-1] %= 26

    ans = list(map(lambda c: chr(ord("a") + (26 - c) % 26), B))
    print("".join(ans))


main()

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    s = input()
    k = int(input())
    a = [ord(_) - 97 for _ in s]
    l = len(s)
    for i in range(l):
        if k < 1:
            break
        c = a[i]
        if c == 0:
            break
        d = 26 - c
        if k >= d:
            a[i] = 0
            k -= d
    a[-1] = (a[-1] + k) % 26
    return ''.join([chr(_ + 97) for _ in a])

print(f())


Failing test case input:
lavitsgfeodc
101

Expected output:
aaaaaaaaeodj


Actual output:
aavitsgfeodk


Fixed submission (verdict: Accepted):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    s = input()
    k = int(input())
    a = [ord(_) - ord('a') for _ in s]
    l = len(s)
    for i in range(l):
        if k < 1:
            break
        c = a[i]
        if c == 0:
            continue
        d = 26 - c
        if k >= d:
            a[i] = 0
            k -= d
    a[-1] = (a[-1] + k) % 26
    return ''.join([chr(_ + ord('a')) for _ in a])

print(f())

Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
k=int(input())
l=list(s)

for i in range(len(s)):
  f=-ord(s[i])+ord("z")+1
  if f<=k:
    l[i]="a"
    k-=f
k=k%26
a=ord(l[-1])+k if ord(l[-1])+k<= ord("z") else ord(l[-1])+k -26
l[-1]=chr(a)
print("".join(l))

Failing test case input:
lavitsffeodc
110

Expected output:
aaaaaaaaeadf


Actual output:
aaaaaaafeodm


Fixed submission (verdict: Accepted):
s=input()
k=int(input())
l=list(s)

for i in range(len(s)):
  f=(-ord(s[i])+ord("z")+1)%26
  if f<=k:
    l[i]="a"
    k-=f

k=k%26
a=ord(l[-1])+k 
if a> ord("z"):a-=26
l[-1]=chr(a)
print("".join(l))
Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

goal = ord("z") + 1 
s = input()
k = int(input())
n = len(s)
ans = [0] * n
for i,si in enumerate(s):
  if goal - ord(si) <= k:
    k -= goal - ord(si)
    ans[i] = "a"
  else:
    ans[i] = si
m = k % 26
ans[-1] = chr(((ord(ans[-1]) - ord("a")) + m)%26 + ord("a"))
print(*ans,sep="")

Failing test case input:
lavitsgfeodc
101

Expected output:
aaaaaaaaeodj


Actual output:
aaaaaaafeode


Fixed submission (verdict: Accepted):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

goal = ord("z") + 1 
s = input()
k = int(input())
n = len(s)
ans = [0] * n
for i,si in enumerate(s):
  if si == "a":ans[i] = "a"
  elif goal - ord(si) <= k:
    k -= goal - ord(si)
    ans[i] = "a"
  else:
    ans[i] = si
m = k % 26
ans[-1] = chr((ord(ans[-1]) - ord("a") + m)%26 + ord("a"))
print(*ans,sep="")

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def cost_for_next_a(c):
    return 123 - ord(c)

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

new_s = ""


for i in range(len(s)):
    if cost_for_next_a(s[i]) <= K:
        new_s += "a"
        K -= cost_for_next_a(s[i])
    elif i != len(s) - 1:
        new_s += s[i]
    else:
        new_s += chr(ord(s[i]) + K)

print(new_s)


Failing test case input:
caoffestiwdl
111

Expected output:
aaaaaaatiwdo


Actual output:
aaaaaesaiwdl


Fixed submission (verdict: Accepted):
def cost_for_next_a(c):
    return 123 - ord(c)

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

new_s = ""











for i in range(len(s)):
    if i == len(s) - 1:
        if cost_for_next_a(s[i]) <= K:
            new_s += chr(97 + (K - cost_for_next_a(s[i])) % 26)
        else:
            new_s += chr(ord(s[i]) + K)
    elif s[i] == 'a':
        new_s += 'a'
    elif cost_for_next_a(s[i]) <= K:
        new_s += "a"
        K -= cost_for_next_a(s[i])
    else:
        new_s += s[i]

print(new_s)

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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()

Failing test case input:
caoffestiwdl
111

Expected output:
aaaaaaatiwdo


Actual output:
aaaaaesaiwdl


Fixed submission (verdict: Accepted):
def main():
    s=list(input())
    k=int(input())
    i=0
    while k>=0 and i<len(s)-1:
        if s[i]!='a' and 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()
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
ints = [ord(i) - ord('a') for i in s]
K = int(input())
n = len(s)
i = 0
while i < n:
    if 25 - ints[i] + 1<= K:
        K -= 25 - ints[i] + 1
        ints[i] = 0
    i += 1

K %= 26
ints[-1] = (ints[-1] + K) % 26
s_ = ''
for i in ints:
    s_ += chr(i + ord('a'))

print(s_)


Failing test case input:
lwsitafffodc
101

Expected output:
aaaaaaaafodj


Actual output:
aaaaaaaffode


Fixed submission (verdict: Accepted):
s = input()
ints = [ord(i) - ord('a') for i in s]
K = int(input())
n = len(s)
i = 0
while i < n:
    if ints[i] != 0 and 25 - ints[i] + 1 <= K:
        K -= 25 - ints[i] + 1
        ints[i] = 0
    i += 1

K %= 26
ints[-1] = (ints[-1] + K) % 26
s_ = ''
for i in ints:
    s_ += chr(i + ord('a'))

print(s_)

Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = list(input())
K = int(input())

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

print("".join(S))


Failing test case input:
caoffestiwdl
111

Expected output:
aaaaaaatiwdo


Actual output:
aaaaaesaiwdl


Fixed submission (verdict: Accepted):
S = list(input())
K = int(input())

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

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

print("".join(S))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def f(c):
    return ord("z") - ord(c) + 1

s = input()
K = int(input())
ans = list(s)
for i, c in enumerate(s):
    n = f(c) 
    
    if n <= K:
        ans[i] = "a"
        K -= n
if K > 0:
    ans[-1] = chr((ord(ans[-1]) - ord("a") + K) % 26 + ord("a"))
print("".join(ans))


Failing test case input:
lwsitafffodc
101

Expected output:
aaaaaaaafodj


Actual output:
aaaaaaaffode


Fixed submission (verdict: Accepted):
def f(c):
    if c == "a":
        return 0
    return ord("z") - ord(c) + 1

s = input()
K = int(input())
ans = list(s)
for i, c in enumerate(s):
    n = f(c) 
    
    if n <= K:
        ans[i] = "a"
        K -= n
if K > 0:
    ans[-1] = chr((ord(ans[-1]) - ord("a") + K) % 26 + ord("a"))
print("".join(ans))
Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    s = input()
    K = int(input())
    a = ord("a")
    code = [ord(c) - a for c in s]
    for i in range(len(s)):
        x = 26 - code[i] % 26
        if x <= K:
            code[i] = 0
            K -= x
    code[-1] = code[-1] + K % 26
    ans = "".join([chr(a + x) for x in code])
    print(ans)


if __name__ == "__main__":
    main()


Failing test case input:
daoffestiwdl
101

Expected output:
aaaaaastiwdn


Actual output:
aaaafeaaiadl


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


if __name__ == "__main__":
    main()

Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s, k, t = input(), int(input()), ""
for s in s:
    if (p := 123 - ord(s)) <= k:
        k -= p
        t += "a"
    else:
        t += s
print(t[:-1] + chr((ord(t[-1]) - 97 + k) % 26 + 97))

Failing test case input:
lavitsgfeodc
101

Expected output:
aaaaaaaaeodj


Actual output:
aaaaaaafeode


Fixed submission (verdict: Accepted):
s, k, t = input(), int(input()), ""
for q in s:
    if (p := (123 - ord(q)) % 26) <= k:
        k -= p
        t += "a"
    else:
        t += q
print(t[:-1] + chr((ord(t[-1]) - 97 + k) % 26 + 97))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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

Failing test case input:
lwsitafffodc
101

Expected output:
aaaaaaaafodj


Actual output:
aaaaaaaffode


Fixed submission (verdict: Accepted):

s = list(input())
k = int(input())
for tmp in range(len(s)):
    if k == 0:
        break
    a = 26-(ord(s[tmp]) - ord('a'))
    if s[tmp] != 'a' and k >= a: 
        k -= a
        s[tmp] = 'a'
    else:
        pass
if k > 0:
    s[len(s)-1] = chr((ord(s[len(s)-1])+k%26))
print(''.join(s))

Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s, k, t, i = input(), int(input()), "", 0
for s in s:
    if (p := 123 - ord(s)) <= k:
        k -= p
        t += "a"
    else:
        t += s
print(t[:-1] + chr((ord(t[-1]) + k % 26) % 96 + 96))

Failing test case input:
lwshuafffodc
100

Expected output:
aaaaaaaafodi


Actual output:
aaaaaaaffodd


Fixed submission (verdict: Accepted):
s, k, t = input(), int(input()), ""
for q in s:
    if (p := (123 - ord(q)) % 26) <= k:
        k -= p
        t += "a"
    else:
        t += q
print(t[:-1] + chr((ord(t[-1]) - 97 + k) % 26 + 97))
Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
print(ord("z") - ord("a"))
s=list(input())
K=int(input())
for i in range(len(s)-1):
    a= ord("z")+1 - ord(s[i])
    if K>=a:
        s[i]="a"
        K-=a
print(K)
if K:
    s[-1]=chr((K+ord(s[-1])-ord("a"))%(ord("z") - ord("a")+1)+ord("a"))
print("".join(s))


Failing test case input:
xzy
6

Expected output:
aaa


Actual output:
25
2
aaa


Fixed submission (verdict: Accepted):
s=list(input())
K=int(input())
for i in range(len(s)-1):
    if s[i]!="a":
        a= ord("z")+1 - ord(s[i])
        if K>=a:
            s[i]="a"
            K-=a
if K:
    s[-1]=chr((K+ord(s[-1])-ord("a"))%(ord("z") - ord("a")+1)+ord("a"))
print("".join(s))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(input())
k=int(input())

for i in range(len(s)):
    if k==0:break
    num=ord(s[i])
    ch_num=123-num
    if i==len(s)-1:
        s[i]=chr(96+(num+k)%122) if num+k>122 else chr(num+k)

    elif ch_num<=k:
        s[i]='a'
        k-=ch_num
print(''.join(s))

Failing test case input:
lwsitafffodc
101

Expected output:
aaaaaaaafodj


Actual output:
aaaaaaaffode


Fixed submission (verdict: Accepted):
s=list(input())
k=int(input())

for i in range(len(s)):
    if k==0:break

    num=ord(s[i])
    ch_num=123-num
    if i==len(s)-1:
        s[i]=chr(97+(num+k-97)%26) 
        
        k=0
        break
    elif s[i]=='a':continue
    elif ch_num<=k:
        s[i]='a'
        k-=ch_num
print(''.join(s))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
k = int(input())
goal = ord('z') + 1
ans = []
for c in S:
    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))


Failing test case input:
lawitsffeodc
100

Expected output:
aaaaaaaaeodi


Actual output:
aaaaaaafeodd


Fixed submission (verdict: Accepted):
S = input()
k = int(input())
goal = ord('z') + 1
ans = []
for c in S:
    if c == 'a':
        ans.append('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))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
k=int(input())
ss=[]
for i in range(len(s)):
	ss.append(ord(s[i])-ord("a"))
i=0
while k>0:
	if i==len(s)-1:
		ss[i]=(k+ss[i])%26
		break
	if k>=26-ss[i]:
		k-=26-ss[i]
		ss[i]=0
		if i!=len(s)-1:
			i+=1
		else:
			ss[i]=k%26
	else:
		i+=1
ans=""
for i in range(len(s)):
	ans+=chr(ord("a")+ss[i])
print(ans)


Failing test case input:
lawitsffeodc
100

Expected output:
aaaaaaaaeodi


Actual output:
aaaaaaafeodd


Fixed submission (verdict: Accepted):
s=input()
k=int(input())
ss=[]
for i in range(len(s)):
	ss.append(ord(s[i])-ord("a"))
i=0
while k>0:
	if i==len(s)-1:
		ss[i]=(k+ss[i])%26
		break
	elif k>=26-ss[i] and ss[i]!=0:
		k-=(26-ss[i])
		ss[i]=0
	i+=1
ans=""
for i in range(len(s)):
	ans+=chr(ord("a")+ss[i])
print(ans)
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(input())
k=int(input())

for i in range(len(s)):
    if k==0:break

    num=ord(s[i])
    ch_num=123-num
    if i==len(s)-1:
        s[i]=chr(96+(num+k)%122) if num+k>=122 else chr(num+k)
        k=0
        break
    elif s[i]=='a':continue
    elif ch_num<=k:
        s[i]='a'
        k-=ch_num
print(''.join(s))

Failing test case input:
a
25

Expected output:
z

Actual output:
`


Fixed submission (verdict: Accepted):
s=list(input())
k=int(input())

for i in range(len(s)):
    if k==0:break

    num=ord(s[i])
    ch_num=123-num
    if i==len(s)-1:
        s[i]=chr(97+(num+k-97)%26) 
        
        k=0
        break
    elif s[i]=='a':continue
    elif ch_num<=k:
        s[i]='a'
        k-=ch_num
print(''.join(s))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import string
import sys
s = input()
k = int(input())
a = [ord(_) for _ in s]
for i in range(len(s)-1):
   print(k)
   df = ord('z') - a[i] + 1
   if k >= df:
       a[i] = ord('a')
       k -= df
   if k == 0:
        break
if k != 0:
    k = k % 26
    a[len(a)-1] += k -26 if ord('z') < k + a[len(a)-1] else k
[print(chr(_), end="") for _ in a]
print("")


Failing test case input:
xxz
8

Expected output:
aab


Actual output:
8
5
aab


Fixed submission (verdict: Accepted):
import string
import sys
s = input()
k = int(input())
a = [ord(_) for _ in s]
for i in range(len(s)-1):
    if a[i] != ord('a'):
        df = ord('z') - a[i] + 1
        if k >= df:
            a[i] = ord('a')
            k -= df
    if k == 0: break
if k != 0:
    k = k % 26
    a[len(a)-1] += k - 26 if ord('z') < k + a[len(a)-1] else k
[print(chr(_), end="") for _ in a]
print("")

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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))


Failing test case input:
caoffestiwdl
101

Expected output:
aaaaaastiwdm


Actual output:
aaaafeaaiwdo


Fixed submission (verdict: Accepted):
S = input()
K = int(input())

A = []
for s in S:
    if s == 'a':
        A.append('a')
        continue
    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))
Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s=str(input())
k=int(input())

lista=[]
for i in range(26):
	lista.append(chr(ord('a') + i))
	


s_list=list(s)
len_s=len(list(s))
temp1=k
temp2=0
for i in range(len_s):
	if (123-ord(s_list[i])<=temp1):
		temp1=temp1-(123-ord(s_list[i]))
		s_list[i]="a"
if temp1!=0:

	temp2=temp1%26+ord(s_list[-1])
	if temp2>122:
		temp2=temp2-122+96
	s_list[-1]=chr(temp2)



for i in range(len(s_list)):
	print(s_list[i],end="")
print()

		
	
	
	


Failing test case input:
lavitsgfeodc
111

Expected output:
aaaaaaaaeadh


Actual output:
aaaaaaafeadc


Fixed submission (verdict: Accepted):
s=str(input())
k=int(input())

lista=[]
for i in range(26):
	lista.append(chr(ord('a') + i))
	


s_list=list(s)
len_s=len(list(s))
temp1=k
temp2=0
for i in range(len_s):
	if (123-ord(s_list[i])<=temp1)and (s_list[i] != 'a'):
		temp1=temp1-(123-ord(s_list[i]))
		s_list[i]="a"
if temp1!=0:

	temp2=temp1%26+ord(s_list[-1])
	if temp2>122:
		temp2=temp2-122+96
	s_list[-1]=chr(temp2)



for i in range(len(s_list)):
	print(s_list[i],end="")
print()

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
n = int(input())
ret = ""
for i, ss in enumerate(s):
    a = 123 - ord(ss)
    if a == 26:
        a = 0
    if n < a:
        if i == len(s) - 1:
            ret += chr(ord(ss) + n)
        else:
            ret += ss
    else:
        n -= a
        ret += 'a'

print(ret)


Failing test case input:
xx{
2

Expected output:
xxc


Actual output:
xxa


Fixed submission (verdict: Accepted):
s = list(input())
n = int(input())
ret = ""
for i, ss in enumerate(s):
    a = 123 - ord(ss)
    if a == 26:
        a = 0
    if i == len(s) - 1:
        c = ord(ss) + (n % 26)
        if c > 122:
            c -= 26
        ret += chr(c)
        break
    if n < a:
        ret += ss
    else:
        n -= a
        ret += 'a'

print(ret)

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = str(input())
n = int(input())
k = ord("z")
a = [0]*len(s)
for i in range(len(s)):
    a[i] = ord(s[i])
for i in range(len(s)):
    if n>=k+1-a[i]:
        n = n-k-1+a[i]
        a[i] = ord("a")
    
    if n<=0:
        break
if n>0:
    a[-1] += n%26
ans = ""
for i in range(len(s)):
    ans += chr(a[i])
print(ans)


Failing test case input:
lawitsffeodc
100

Expected output:
aaaaaaaaeodi


Actual output:
aaaaaaafeodd


Fixed submission (verdict: Accepted):
s = str(input())
n = int(input())
k = ord("z")
a = [0]*len(s)
for i in range(len(s)):
    a[i] = ord(s[i])
for i in range(len(s)):
    if a[i] == ord("a"):
        continue
    if n>=k+1-a[i]:
        n = n-k-1+a[i]
        a[i] = ord("a")
    
    if n<=0:
        break
if n>0:
    a[-1] += n%26
ans = ""
for i in range(len(s)):
    ans += chr(a[i])
print(ans)
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    S = list(input())
    k = int(input())
    ans = []
    for s in S:
        if k == 0:
            break
        if s != 'a' and ord(s) >= 123 - k:
            ans.append('a')
            k -= 123 - ord(s)
        else:
            ans.append(s)
    if k > 0:
        k %= 26
        ans[-1] = chr(ord(ans[-1]) + k)
    print(''.join(ans))

if __name__ == '__main__':
    main()


Failing test case input:
wxw
4

Expected output:
axw


Actual output:
a


Fixed submission (verdict: Accepted):
def main():
    S = list(input())
    k = int(input())
    ans = []
    for s in S:
        if s != 'a' and ord(s) >= 123 - k:
            ans.append('a')
            k -= 123 - ord(s)
        else:
            ans.append(s)
    if k > 0:
        ans[-1] = chr((ord(ans[-1]) + k - 97) % 26 + 97)
    print(''.join(ans))

if __name__ == '__main__':
    main()

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
makeA = lambda c: (ord('z')-ord(c)+1) % 26
s = list(map(makeA,list(input())))

K = int(input())
len_s = len(s)

for i in range(len_s-1):
    if s[i] <= K:
        K -= s[i]
        s[i] = 0
        print(s)
if K > 0:
    s[-1] = (s[-1] + 26 - (K % 26)) % 26

makeS = lambda n: chr((26-n)%26+ord('a'))
print(''.join(list(map(makeS,s))))


Failing test case input:
xxz
3

Expected output:
axz


Actual output:
[0, 3, 1]
axz


Fixed submission (verdict: Accepted):
makeA = lambda c: (ord('z')-ord(c)+1) % 26
s = list(map(makeA,list(input())))

K = int(input())
len_s = len(s)

for i in range(len_s-1):
    if s[i] <= K:
        K -= s[i]
        s[i] = 0
        
if K > 0:
    s[-1] = (s[-1] + 26 - (K % 26)) % 26

makeS = lambda n: chr((26-n)%26+ord('a'))
print(''.join(list(map(makeS,s))))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
K = int(input())

ans = ''
for i, c in enumerate(s):
    dif = ord('z') - ord(c) + 1
    if i == len(s) - 1:
        K %= 26
        if ord(c) + K > ord('z'):
            K -= 26
        ans += chr(ord(c) + K)
    elif dif <= K:
        ans += 'a'
        K -= dif
    else:
        ans += c
print(ans)


Failing test case input:
daoffestiwdl
101

Expected output:
aaaaaastiwdn


Actual output:
aaaafeaaiadl


Fixed submission (verdict: Accepted):
s = input()
K = int(input())

ans = ''
for i, c in enumerate(s):
    dif = ord('z') - ord(c) + 1
    dif %= 26
    if i == len(s) - 1:
        K %= 26
        if ord(c) + K > ord('z'):
            K -= 26
        ans += chr(ord(c) + K)
    elif dif <= K:
        ans += 'a'
        K -= dif
    else:
        ans += c
print(ans)
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k = int(input())

ans = []

for i in range(len(s)):
    if 123 - ord(s[i]) <= k:
        ans.append("a")
        k -= 123 - ord(s[i])
    else:
        ans.append(s[i])

last = chr((ord(ans[-1])-97+k)%26 + 97)
ans[-1] = last
print(*ans, sep = "")


Failing test case input:
lavitshfeodc
101

Expected output:
aaaaaaaaeodk


Actual output:
aaaaaaafeodf


Fixed submission (verdict: Accepted):
s = input()
k = int(input())

ans = []

for i in range(len(s)):
    if 123 - ord(s[i]) <= k:
        if s[i] == "a":
            ans.append("a")
            continue
        ans.append("a")
        k -= 123 - ord(s[i])
    else:
        ans.append(s[i])

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


print(*ans, sep = "")

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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

Failing test case input:
lavitshfeodc
101

Expected output:
aaaaaaaaeodk


Actual output:
aaaaaaafeodf


Fixed submission (verdict: Accepted):

s = list(input())
k = int(input())
for tmp in range(len(s)):
    if k == 0:
        break
    a = 26-(ord(s[tmp]) - ord('a'))
    if s[tmp] != 'a' and k >= a: 
        k -= a
        s[tmp] = 'a'
    else:
        pass
if k > 0:
    s[len(s)-1] = chr((ord(s[len(s)-1])+k%26))
print(''.join(s))

Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s=str(input())
k=int(input())

lista=[]
for i in range(26):
	lista.append(chr(ord('a') + i))
	


s_list=list(s)
len_s=len(list(s))
temp1=k
temp2=0
for i in range(len_s):
	if (123-ord(s_list[i])<=temp1)&(temp1>=0):
		temp1=temp1-(123-ord(s_list[i]))
		s_list[i]="a"
if temp1!=0:

	temp2=temp1%26+ord(s_list[-1])
	if temp2>122:
		temp2=temp2-122+96
	s_list[-1]=chr(temp2)



for i in range(len(s_list)):
	print(s_list[i],end="")
		

		
	
	
	


Failing test case input:
lavitsffeodc
111

Expected output:
aaaaaaaaeadg


Actual output:
aaaaaaafeodn

Fixed submission (verdict: Accepted):
s=str(input())
k=int(input())

lista=[]
for i in range(26):
	lista.append(chr(ord('a') + i))
	


s_list=list(s)
len_s=len(list(s))
temp1=k
temp2=0
for i in range(len_s):
	if (123-ord(s_list[i])<=temp1)and (s_list[i] != 'a'):
		temp1=temp1-(123-ord(s_list[i]))
		s_list[i]="a"
if temp1!=0:

	temp2=temp1%26+ord(s_list[-1])
	if temp2>122:
		temp2=temp2-122+96
	s_list[-1]=chr(temp2)



for i in range(len(s_list)):
	print(s_list[i],end="")
print()
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
K = int(input())

a = [0] * len(s)
for i in range(len(s)):
  a[i] =  ((ord('z') - ord(s[i])) + 1)%26
  if a[i] == 0:
    pass
  elif K - a[i] >= 0:
    K -= a[i]
    a[i] = 0
for i in range(len(s)-1):
  print(chr((26-a[i])%26+ord('a')), end = '')

b = ord('a') + (ord(s[-1])-ord('a') + K)%25
print( chr( b ) ) 
  


Failing test case input:
zxy
3

Expected output:
axa


Actual output:
axy


Fixed submission (verdict: Accepted):
s = input()
K = int(input())

a = [0] * len(s)
for i in range(len(s) - 1):
  a[i] =  ((ord('z') - ord(s[i])) + 1)%26
  if a[i] == 0:
    pass
  elif K - a[i] >= 0:
    K -= a[i]
    a[i] = 0

for i in range(len(s)-1):
  print(chr((26-a[i])%26+ord('a')), end = '')

if K != 0:
  b = ord('a') + (ord(s[-1])-ord('a') + K)%26
  print( chr( b ) ) 
else:
  print(s[-1])

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
K=int(input())
S=list(ord(s[i]) for i in range(len(s)))

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

Failing test case input:
{yz
21

Expected output:
aas


Actual output:
aaa


Fixed submission (verdict: Accepted):
s=input()
K=int(input())
S=list(ord(s[i]) for i in range(len(s)))

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

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def cost_for_next_a(c):
    return 123 - ord(c)

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

new_s = ""











for i in range(len(s)):
    if i == len(s) - 1:
        if cost_for_next_a(s[i]) <= K:
            new_s += chr(97 + K - cost_for_next_a(s[i]))
        else:
            new_s += chr(ord(s[i]) + K)
    elif cost_for_next_a(s[i]) <= K:
        new_s += "a"
        K -= cost_for_next_a(s[i])
    else:
        new_s += s[i]

print(new_s)


Failing test case input:
lwsiuafffodc
101

Expected output:
aaaaaaaafodk


Actual output:
aaaaaaaffodf


Fixed submission (verdict: Accepted):
def cost_for_next_a(c):
    return 123 - ord(c)

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

new_s = ""











for i in range(len(s)):
    if i == len(s) - 1:
        if cost_for_next_a(s[i]) <= K:
            new_s += chr(97 + (K - cost_for_next_a(s[i])) % 26)
        else:
            new_s += chr(ord(s[i]) + K)
    elif s[i] == 'a':
        new_s += 'a'
    elif cost_for_next_a(s[i]) <= K:
        new_s += "a"
        K -= cost_for_next_a(s[i])
    else:
        new_s += s[i]

print(new_s)