ZhenlongDai/ACPR huggingface dataset:
Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S = input()
K = int(input())

ord_a = ord('a')
ord_z = ord('z')

k = K
Ans = list(S)
for i, s in enumerate(S[:-1]):
    ord_s = ord(s)
    dif = ord_z - ord_s + 1

    if s == 'a':
        continue
    elif dif <= k:
        Ans[i] = 'a'
        k -= dif
    else:
        Ans[-1] = chr(ord_a + (ord(Ans[-1]) + k - ord_a)%26)
        k -= k
        break
else:
    Ans[-1] = chr(ord_a + (ord(Ans[-1]) + k - ord_a)%26)
print(''.join(Ans))

Failing test case input:
yzw
1

Expected output:
yaw


Actual output:
yzx


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

ord_a = ord('a')
ord_z = ord('z')

k = K
Ans = list(S)
for i, s in enumerate(S[:-1]):
    ord_s = ord(s)
    dif = ord_z - ord_s + 1

    if s == 'a':
        Ans[i] = 'a'
    elif dif <= k:
        Ans[i] = 'a'
        k -= dif
    else:
        pass
Ans[-1] = chr(ord_a + (ord(Ans[-1]) + k - ord_a)%26)
print(''.join(Ans))

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


Failing test case input:
caoeffstivdl
111

Expected output:
aaaaaaativdo


Actual output:
aaaaafstiadm


Fixed submission (verdict: Accepted):
s = str(input())
k = int(input())
S = []
for i in range(len(s)):
    S.append(ord(s[i]) - 97)
i = 0
while k > 0:
    if S[i] > 0 and 26 - S[i] <= k:
        k -= 26 - S[i]
        S[i] = 0
        i += 1
    else:
        i += 1
    if i >= len(s):
        S[-1] += k
        break
ans = ''
for x in S:
    ans += chr((x % 26) + 97)
print(ans)

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

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

Failing test case input:
lwsiuafffodc
101

Expected output:
aaaaaaaafodk


Actual output:
aaaaaaaffodf


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

asc = [0] * len(s)
for i in range(len(s)):
    asc[i] = ord(s[i]) - ord("a")
i = 0
for i in range(len(s)):
    if 26 - asc[i] <= k and asc[i] != 0:
        x = 26 - asc[i]
        asc[i] = 0
        k -= x
if k > 0:
    asc[-1] += k % 26
for i in range(len(s)):
    asc[i] += ord("a")
    asc[i] = chr(asc[i])
print("".join(asc))
Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):








s = input()
K = int(input())
l = len(s)
ans = ['a']*l

ORDa = 97

for i in range(l):
	now = ord(s[i]) - ORDa
	tmp = 26 - now
	
	if K == 0:
		ans[i] = s[i]
	elif tmp <= K:
		ans[i] = 'a'
		K -= tmp
	else:
		ans[i] = s[i]

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



Failing test case input:
{yz
19

Expected output:
aaq


Actual output:
aa	


Fixed submission (verdict: Accepted):








s = input()
K = int(input())
l = len(s)
ans = ['a']*l

ORDa = 97

for i in range(l):
	now = ord(s[i]) - ORDa
	tmp = 26 - now
	
	if K == 0:
		ans[i] = s[i]
	elif tmp == 26:
		ans[i] = s[i]
	elif tmp <= K:
		ans[i] = 'a'
		K -= tmp
	else:
		ans[i] = s[i]

if K > 0:
	K = K % 26
	tmp = ord(ans[-1])
	if tmp + K > ord('z'):
		aa = tmp + K - (ord('z') + 1)
		ans[-1] = chr(aa + ORDa)
	else:
		ans[-1] = chr(tmp + K)
		
print("".join(ans))

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list( input())
l = len(s)
K = int( input())
for i in range(l-1):
    if ord("z") - ord(s[i]) + 1 <= K:
        K -= ord("z") - ord(s[i]) + 1
        s[i] = "a"
s[l-1] = chr( ( ord(s[l-1]) - ord("a") + K)%26 + ord("a"))
print("".join(s))


Failing test case input:
caoeffstivdl
111

Expected output:
aaaaaaativdo


Actual output:
aaaaafstiadm


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

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

Failing test case input:
lwsiuafffodc
101

Expected output:
aaaaaaaafodk


Actual output:
aaaaaaaffodf


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

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

s = list(ord(i) for i in input())
k = int(input())

for i in range(len(s)):
  t = 123-s[i]
  if k >= t:
    s[i] = 97
    k -= t
if k > 0:
  k %= 26
  s[-1] += k
  if s[-1] > 122:
    s[-1] = s[-1] - 122 + 96
print("".join(list(map(chr, s))))

Failing test case input:
lwsiuafffodc
101

Expected output:
aaaaaaaafodk


Actual output:
aaaaaaaffodf


Fixed submission (verdict: Accepted):

s = list(ord(i) for i in input())
k = int(input())

for i in range(len(s)-1):
  if s[i] == ord("a"): continue
  t = ord("z")+1-s[i]
  if k >= t:
    s[i] = 97
    k -= t
if k > 0:
  k %= 26
  s[-1] += k
  if s[-1] > ord("z"):
    s[-1] -= 26
print("".join(list(map(chr, s))))
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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()


Failing test case input:
xxy
3

Expected output:
axy


Actual output:
xxb


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 string
import sys
s = input()
k = int(input())
a = [ord(_) for _ in s]
for i in range(len(s)-1):
   df = ord('z') - a[i] + 1
   if k >= df:
       a[i] = 97
       k -= df
   if k == 0:
        break
if k != 0:
    k = k % 26
    a[len(a)-1] += k
[print(chr(_), end="") for _ in a]
print("")


Failing test case input:
zyw
11

Expected output:
aae


Actual output:
aa


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 = list(input())
N = int(input())


  
for i, s in enumerate(S):
  if ord(s) - 97 > 0  and 122 - ord(s) < N:
    S[i] = "a"
    N -= 123 - ord(s)
else:
  S[i] = (chr((ord(S[i]) + N) % 122 ))
  
  
print("".join(S))

Failing test case input:
xxz
0

Expected output:
xxz


Actual output:
xx


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


  
for i, s in enumerate(S):
  if ord(s) - 97 > 0  and 122 - ord(s) < N:
    S[i] = "a"
    N -= 123 - ord(s)
else:
  S[i] = chr(N % 26 + ord(S[i])) 
       
print("".join(S))
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
K = int(input())

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

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

Failing test case input:
daoffestiwdl
101

Expected output:
aaaaaastiwdn


Actual output:
aaaafeaaiadl


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

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

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

Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):








s = input()
K = int(input())
l = len(s)
ans = ['a']*l

ORDa = 97

for i in range(l):
	now = ord(s[i]) - ORDa
	tmp = 26 - now
	
	if K == 0:
		ans[i] = s[i]
	elif tmp <= K:
		ans[i] = 'a'
		K -= tmp
	else:
		ans[i] = s[i]

if K > 0:
	ans[-1] = chr(ord(ans[-1]) + K)
		
print("".join(ans))



Failing test case input:
lwsiuafffodc
101

Expected output:
aaaaaaaafodk


Actual output:
aaaaaaaffodf


Fixed submission (verdict: Accepted):








s = input()
K = int(input())
l = len(s)
ans = ['a']*l

ORDa = 97

for i in range(l):
	now = ord(s[i]) - ORDa
	tmp = 26 - now
	
	if K == 0:
		ans[i] = s[i]
	elif tmp == 26:
		ans[i] = s[i]
	elif tmp <= K:
		ans[i] = 'a'
		K -= tmp
	else:
		ans[i] = s[i]

if K > 0:
	K = K % 26
	tmp = ord(ans[-1])
	if tmp + K > ord('z'):
		aa = tmp + K - (ord('z') + 1)
		ans[-1] = chr(aa + ORDa)
	else:
		ans[-1] = chr(tmp + K)
		
print("".join(ans))

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(S[i])
  if ord('z') - n + 1 <= K:
    K -= ord('z') - n + 1
    S[i] = 'a'

if K != 0:
  n = ord(S[-1])
  n -= ord('a')
  n += K
  n %= ord('z') - ord('a') + 1
  n += ord('a')
  S[-1] = chr(n)
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)):
  n = ord(S[i])
  if S[i] == 'a':
    continue
  if ord('z') - n + 1 <= K:
    K -= ord('z') - n + 1
    S[i] = 'a'
assert K >= 0
if K != 0:
  n = ord(S[-1])
  n -= ord('a')
  n += K
  n %= 26
  n += ord('a')
  S[-1] = chr(n)
print(''.join(S))
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:
    ans[-1] = chr(ord(ans[-1])+K % 26)

print(''.join(ans))


Failing test case input:
lwshuafffodc
100

Expected output:
aaaaaaaafodi


Actual output:
aaaaaaaffodd


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.4.3), verdict: Wrong Answer):
s = list(input())
K = int(input())
n = len(s)
for i in range(n-1):
    m = ord('z') - ord(s[i]) + 1
    if m <= K:
        s[i] = 'a'
        K -= m
s[n-1] = chr((ord(s[n-1])+K-97)%26+97)
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())
n = len(s)
for i in range(n-1):
    m = ord('z') - ord(s[i]) + 1
    if not s[i] == 'a' and m <= K:
        s[i] = 'a'
        K -= m
s[n-1] = chr((ord(s[n-1])+K%26-97)%26+97)
print(''.join(s))

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)-1):
	changeNum = 122-ord(str[i])+1
	if (changeNum <= tempK):
		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)


Failing test case input:
lwsiuafffodc
101

Expected output:
aaaaaaaafodk


Actual output:
aaaaaaaffodf


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 (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    S = list(input())
    K = int(input())
    N = len(S)
    k = K
    for i,c in enumerate(S):
        distance = ord('z') + 1 - ord(c)
        if distance <= k:
            k -= distance
            S[i] = 'a'
    
    S[-1] = chr((ord(S[i]) - ord('a') + k) % 26 + ord('a'))
    print(''.join(S))

main()

Failing test case input:
lavitsgfeodc
111

Expected output:
aaaaaaaaeadh


Actual output:
aaaaaaafeadc


Fixed submission (verdict: Accepted):
def main():
    S = list(input())
    K = int(input())
    k = K
    for i,c in enumerate(S):
        distance = (ord('z') + 1 - ord(c))%26
        if distance <= k:
            k -= distance
            S[i] = 'a'
    S[-1] = chr((ord(S[-1]) - ord('a') + k) % 26 + ord('a'))
    print(''.join(S))

main()

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

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

Failing test case input:
lawitsffeodc
100

Expected output:
aaaaaaaaeodi


Actual output:
aaaaaaafeodd


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

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

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

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


print(''.join(s))

Failing test case input:
lwsiuafffodc
101

Expected output:
aaaaaaaafodk


Actual output:
aaaaaaaffodf


Fixed submission (verdict: Accepted):
s = list(input())
k = int(input())
n = len(s)
for i in range(n-1):
    d = (ord('z')-ord(s[i])+1)%26
    if d<=k:
        s[i] = 'a'
        k -= d

x = ord(s[-1])+k%26
if x>ord('z'):x-=26
s[-1] = chr(x)


print(''.join(s))
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 (123 - ord(sArr[i])) <= K:
        K -= (123 - ord(sArr[i]))
        sArr[i] = "a"

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

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

print(result)

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().strip()
k = int(input())

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

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

print(ans)

Failing test case input:
lavitsffeodc
110

Expected output:
aaaaaaaaeadf


Actual output:
aaaaaaafeodm


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

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

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

print(ans)

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


arr = [ord(S[i]) for i in range(len(S))]

count = K
for i in range(len(S)):
    if i == len(S) - 1:
        for j in range(count):
            arr[i] += 1
            if arr[i] == ord('z') + 1:
                arr[i] = ord('a')
        break

    if ord('z') - ord(S[i]) + 1 <= count:
        arr[i] = ord('a')
        count -= (ord('z') - ord(S[i]) + 1)

ans = ''
for c in arr:
    ans += chr(c)

print(ans)


Failing test case input:
lavitsffeodc
111

Expected output:
aaaaaaaaeadg


Actual output:
aaaaaaafeodn


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

arr = [ord(S[i]) for i in range(len(S))]
count = K
for i in range(len(S)):
    if i == len(S) - 1:
        count %= 26
        if ord('z') - arr[i] + 1 <= count:
            arr[i] = ord('a')
            count -= ord('z') - ord(S[i]) + 1
        arr[i] += count
        break

    if ord('z') - arr[i] + 1 <= count and arr[i] != ord('a'):
        arr[i] = ord('a')
        count -= ord('z') - ord(S[i]) + 1

    if count == 0:
        break

for c in arr:
    sys.stdout.write(chr(c))

print('')
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k = int(input())
slen = len(s)
new_s = ""

for i in range(slen):
  val = ord("z") + 1 - ord(s[i])
  if k >= val:
    k -= val
    new_s += "a"
  else:
    new_s += s[i]
    
if k > 0:
  tmp_val = ord(s[slen-1]) + k % 26
  if tmp_val > ord("z"):
    tmp_val -= 26
  new_s = new_s[:-1] + chr(tmp_val)

print(new_s)

Failing test case input:
{zz
21

Expected output:
aat


Actual output:
aas


Fixed submission (verdict: Accepted):
s = input()
k = int(input())
slen = len(s)
new_s = ""

for i in range(slen):
  val = (ord("z") + 1 - ord(s[i])) % 26
  if k >= val:
    k -= val
    new_s += "a"
  else:
    new_s += s[i]
    
if k > 0:
  tmp_val = ord(new_s[slen-1]) + k % 26
  if tmp_val > ord("z"):
    tmp_val -= 26
  new_s = new_s[:-1] + chr(tmp_val)

print(new_s)

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]) +1
        sArr[endpoint] = chr(ord("a") + K)
    else:
        sArr[endpoint] = chr(ord(sArr[endpoint]) + K)

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

print(result)

Failing test case input:
caoffestiwdl
111

Expected output:
aaaaaaatiwdo


Actual output:
aaaaaesaiwdl


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 (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

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

if __name__ == '__main__':
    main()


Failing test case input:
yyz
3

Expected output:
aya


Actual output:
ayt


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

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

if __name__ == '__main__':
    main()
Problem: p03994
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
import math  
import bisect  
import queue  


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


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

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

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

    print(''.join(T))


if __name__ == '__main__':
    main()


Failing test case input:
lwsitafffodc
101

Expected output:
aaaaaaaafodj


Actual output:
aaaaaaaffode


Fixed submission (verdict: Accepted):
import sys
import math  
import bisect  
import queue  


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


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

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

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

    print(''.join(T))


if __name__ == '__main__':
    main()

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
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:
zxz
0

Expected output:
zxz


Actual output:
25
zxz


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

Failing test case input:
codefestival
101

Expected output:
aaaafeaaiaal


Actual output:
aaaafeaaivaq


Fixed submission (verdict: Accepted):
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])+k%26-97)%26+97)

print(ans)
Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
k=int(input())
n=len(s)
i=0
ans=""
while i<n:
    if i!=n-1:
        if k>=123-ord(s[i]):
            ans+="a"
            k-=(123-ord(s[i]))
        else:
            ans+=s[i]
    else:
        if k>=123-ord(s[i]):
            k-=(123-ord(s[i]))
            k=k%26
            ans+=chr(97+k)
        else:
            ans+=chr(ord(s[i])+k)
    i+=1
print(ans)

Failing test case input:
daoffestiwdl
101

Expected output:
aaaaaastiwdn


Actual output:
aaaafeaaiadl


Fixed submission (verdict: Accepted):
s=input()
k=int(input())
n=len(s)
i=0
ans=""
while i<n:
    if i!=n-1:
        if s[i]=="a":
            ans+="a"
            
        elif k>=123-ord(s[i]):
            ans+="a"
            k-=(123-ord(s[i]))
            
        else:
            ans+=s[i]
            
    else:
        if k>=123-ord(s[i]):
            k-=(123-ord(s[i]))
            k=k%26
            ans+=chr(97+k)
        else:
            ans+=chr(ord(s[i])+k)
        
    i+=1
print(ans)

Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
import itertools

import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


S = input()
K = int(input())

ans = []
for i, c in enumerate(S[:-1]):
    num = ord('z') - ord(c) + 1
    if K >= num:
        K -= num
        ans.append('a')
    else:
        ans.append(c)

ans.append(chr((ord(S[-1]) - ord('a') + K) % 26 + ord('a')))
print("".join(ans))
    


Failing test case input:
caoffestiwdl
101

Expected output:
aaaaaastiwdm


Actual output:
aaaafeaaiwdo


Fixed submission (verdict: Accepted):
import sys
import itertools

import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


S = input()
K = int(input())

ans = []
for i, c in enumerate(S):
    if c == 'a':
        ans.append(c)
        continue
    num = ord('z') - ord(c) + 1
    if K >= num:
        K -= num
        ans.append('a')
    else:
        ans.append(c)
if K > 0:
    ans[-1] = chr((ord(ans[-1]) - ord('a') + K % 26) % 26 + ord('a'))
print("".join(ans))
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

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

Failing test case input:
lavitsffeodc
110

Expected output:
aaaaaaaaeadf


Actual output:
aaaaaaafeodm


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

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def c_next_letter(S, K):
    s = list(S)
    for t, elem in enumerate(s):
        if t == len(s) - 1 and K > 0:
            
            s[t] = chr(ord('a') + (ord(elem) - ord('a') + K) % 26)
        elif ord('z') - ord(elem) + 1 <= K:
            
            s[t] = 'a'
            K -= ord('z') - ord(elem) + 1
    ans = ''.join(s)
    return ans

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

Failing test case input:
daoffestiwdl
101

Expected output:
aaaaaastiwdn


Actual output:
aaaafeaaiadl


Fixed submission (verdict: Accepted):
def c_next_letter(S, K):
    s = list(S)
    for t, elem in enumerate(s):
        if t == len(s) - 1 and K > 0:
            
            s[t] = chr(ord('a') + (ord(elem) - ord('a') + K) % 26)
        elif elem == 'a':
            continue  
        elif ord('z') - ord(elem) + 1 <= K:
            
            s[t] = 'a'
            K -= ord('z') - ord(elem) + 1
    ans = ''.join(s)
    return ans

S = input()
K = int(input())
print(c_next_letter(S, K))
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)-1):
	changeNum = 122-ord(str[i])+1
	if (changeNum <= tempK):
		result += "a"
		tempK -= changeNum
		if (tempK == 0):
			result += str[i+1:]
			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)


Failing test case input:
caoffestiwdl
101

Expected output:
aaaaaastiwdm


Actual output:
aaaafeaaiwdo


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.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') + (ord(A[-1]) - ord('a') + K % 26) % 26)

print("".join(A))


Failing test case input:
lwshuafffodc
100

Expected output:
aaaaaaaafodi


Actual output:
aaaaaaaffodd


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):
import sys
S = str(input())
K = int(input())



arr = [ord(S[i]) for i in range(len(S))]
count = K
for i in range(len(S)):
    if i == len(S) - 1:
        count %= 26
        if ord('z') - arr[i] + 1 <= count:
            arr[i] = ord('a')
            count -= ord('z') - ord(S[i]) + 1
        arr[i] += count
        break

    if ord('z') - arr[i] + 1 <= count:
        arr[i] = ord('a')
        count -= (ord('z') - ord(S[i]) + 1)

    if count == 0:
        break

for c in arr:
    sys.stdout.write(chr(c))

print('')


Failing test case input:
lavitsgfeodc
111

Expected output:
aaaaaaaaeadh


Actual output:
aaaaaaafeadc


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

arr = [ord(S[i]) for i in range(len(S))]
count = K
for i in range(len(S)):
    if i == len(S) - 1:
        count %= 26
        if ord('z') - arr[i] + 1 <= count:
            arr[i] = ord('a')
            count -= ord('z') - ord(S[i]) + 1
        arr[i] += count
        break

    if ord('z') - arr[i] + 1 <= count and arr[i] != ord('a'):
        arr[i] = ord('a')
        count -= ord('z') - ord(S[i]) + 1

    if count == 0:
        break

for c in arr:
    sys.stdout.write(chr(c))

print('')
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k = int(input())
s = [i for i in s]
for i,v in enumerate(s):
    if v == 'a':
        break
    if k <= 0:
        break
    if ord('z') - ord(v) + 1 <= k:
        s[i] = 'a'
        k -= ord('z') - ord(v) + 1
k %= 26
s[-1] = chr(ord(s[-1])+k)
print(''.join(s))

Failing test case input:
caoffestivdl
110

Expected output:
aaaaaaativdn


Actual output:
aaoffestivdt


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 (Python (3.8.2), verdict: Wrong Answer):
s = list(input())
k = int(input())
num = len(s)
for i in range(num):
    a = 122-ord(s[i])+1
    if a <= k:
        k -= a
        s[i] = 'a'
if k > 0:
    s[-1] = chr(ord(s[-1])+k%26)
print(*s, sep='')
        


Failing test case input:
lavitsffeodc
110

Expected output:
aaaaaaaaeadf


Actual output:
aaaaaaafeodm


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

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

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,s in enumerate(S):
    t = ord(s)-97
    if 26 - t <= K:
        S[i] = 'a'
        K -= 26-t
S[-1] = chr((ord(S[i]) + K%26)%97+97)
print(''.join(S))





Failing test case input:
caoeffstivdl
111

Expected output:
aaaaaaativdo


Actual output:
aaaaafstiadm


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 = input()
K = int(input())

new = ""
for i in range(len(s) - 1):
  diff = 123 - ord(s[i])
  if diff <= K:
    K -= diff
    new += "a"
  else:
    new += s[i]

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

print(new)



Failing test case input:
lawitsffeodc
100

Expected output:
aaaaaaaaeodi


Actual output:
aaaaaaafeodd


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

new = ""
for i in range(len(s) - 1):
  diff = (123 - ord(s[i])) % 26
  if diff <= K:
    K -= diff
    new += "a"
  else:
    new += s[i]

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

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

for i in range(len(s)):
    s[i]-=97

c=0
while k>0:
    if c==len(s)-1:
        s[c]=(s[c]+k)%26
        k=0
    elif s[c]+k>=26:
        k-=26-s[c]
        s[c]=0
        c+=1
    else:
        c+=1

seq=""
for i in range(len(s)):
    seq+=chr(s[i]+97)

print(seq)

Failing test case input:
lavitsffeodc
111

Expected output:
aaaaaaaaeadg


Actual output:
aaaaaaafeodn


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

for i in range(len(s)):
    s[i]-=97

c=0
while k>0:
    if c==len(s)-1:
        s[c]=(s[c]+k)%26
        k=0
    elif s[c]==0:
        c+=1
    elif s[c]+k>=26:
        k-=26-s[c]
        s[c]=0
        c+=1
    else:
        c+=1

seq=""
for i in range(len(s)):
    seq+=chr(s[i]+97)

print(seq)

Problem: p03994
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = list(SS())
    K = I()

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

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

if __name__ == '__main__':
    resolve()


Failing test case input:
caoeffstivdl
111

Expected output:
aaaaaaativdo


Actual output:
aaaaafstiadm


Fixed submission (verdict: Accepted):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = list(SS())
    K = I()

    
    for i in range(len(s) - 1):
        diff = (ord('a') - ord(s[i])) % 26
        if K >= diff:
            K -= diff
            s[i] = 'a'

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

if __name__ == '__main__':
    resolve()
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def codefes16qa_c():
    s = str(input())
    k = int(input())
    n = len(s)
    ans = ''
    for i in range(n):
        step2a = 1 + ord('z') - ord(s[i])
        if step2a <= k:
            ans += 'a'
            k -= step2a
        else:
            ans += s[i]
    if k > 0:
        last = ord(ans[-1]) + (k % 26)
        ans = ans[:n-1] + chr(last)
    print(ans)

codefes16qa_c()

Failing test case input:
lavitsgfeodc
111

Expected output:
aaaaaaaaeadh


Actual output:
aaaaaaafeadc


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

codefes16qa_c()

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
z=ord('z')
a=ord('a')
print(z-a)
ss=input()
s=list(ss)
k=int(input())
l=len(s)

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

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

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

Failing test case input:
cdoeffstbwjl
001

Expected output:
cdoeffstbwjm


Actual output:
25
cdoeffstbwjm


Fixed submission (verdict: Accepted):
z=ord('z')
a=ord('a')
ss=input()
s=list(ss)
k=int(input())
l=len(s)

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

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

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

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
K = int(input())
z = ord('z') + 1

res = ""
flg = False
for i,c in enumerate(S):
    if z - ord(c) <= K:
        res += 'a'
        K -= z-ord(c)
    else:
        res += chr(ord(c))

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


Failing test case input:
lavitsffeodc
110

Expected output:
aaaaaaaaeadf


Actual output:
aaaaaaafeodm


Fixed submission (verdict: Accepted):
S = input()
K = int(input())
z = ord('z') + 1

res = ""
flg = False
for i,c in enumerate(S):
    if c == 'a':
        res += 'a'
        continue
    elif z - ord(c) <= K:
        res += 'a'
        K -= z-ord(c)
    else:
        res += chr(ord(c))

res = res[:-1] + chr((ord(res[-1])-ord('a') + K) % 26 + ord('a'))
print(res)
Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
daoffestiwdl
101

Expected output:
aaaaaastiwdn


Actual output:
aaaafeaaiadl


Fixed submission (verdict: Accepted):
s = [ord(i) - 97 for i in input()]
k = int(input())

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)

Problem: p03994
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
K = int(input())
z = ord('z') + 1

res = ""
flg = False
for i,c in enumerate(S):
    if z - ord(c) <= K:
        res += 'a'
        K -= z-ord(c)
    else:
        res += chr(ord(c))

print(res)


Failing test case input:
cdoeffstival
111

Expected output:
aaaaafativam


Actual output:
aaaaafatival


Fixed submission (verdict: Accepted):
S = input()
K = int(input())
z = ord('z') + 1

res = ""
flg = False
for i,c in enumerate(S):
    if c == 'a':
        res += 'a'
        continue
    elif z - ord(c) <= K:
        res += 'a'
        K -= z-ord(c)
    else:
        res += chr(ord(c))

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

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

cnt=0
for i in range(len(s)):
    num_al=ord(s[i])
    a_=123-num_al
    if k==0:break
    if s[i]=='a':continue
    if a_<=k:
        k-=a_
        s[i]='a'
    elif a_>k and i<len(s)-1:continue
    else:
        s[i]=chr(num_al+k)
        k=0
print(''.join(s))

Failing test case input:
{yz
19

Expected output:
aaq


Actual output:
aaa


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.8.2), verdict: Wrong Answer):
s = input()
K = int(input())
k = K

ans = ""
for i in range(len(s)-1):
    if(s[i] == "a"):
        continue
    if(ord(s[i])+k >= ord("z")+1):
        ans += "a"
        k -= ord("z")+1-ord(s[i])
    else:
        ans += s[i]

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

Failing test case input:
lavitsgfeodc
111

Expected output:
aaaaaaaaeadh


Actual output:
aaaaaaaeadh


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

ans = ""
for i in range(len(s)-1):
    if(s[i] == "a"):
        ans += s[i]
        continue
    if(ord(s[i])+k >= ord("z")+1):
        ans += "a"
        k -= ord("z")+1-ord(s[i])
    else:
        ans += s[i]

a = ord(s[-1])+k%26
if(a > ord("z")):
    a -= 26
ans += chr(a)
    
print(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("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]))

Failing test case input:
caoffestiwdl
101

Expected output:
aaaaaastiwdm


Actual output:
aaaafeaaiwdo


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 = input()
k = int(input())
ans = ""
l = 26
for i in range(len(s)-1):
    if l - ord(s[i]) + 97 <= k:
        k -= l - ord(s[i]) + 97
        ans += "a"
    else:
        ans += s[i]
ans += (chr(((ord(s[-1]) - 97) + k + l**100) % l + 97))
print(ans)

Failing test case input:
lavitsffeodc
111

Expected output:
aaaaaaaaeadg


Actual output:
aaaaaaafeodn


Fixed submission (verdict: Accepted):
s = input()
k = int(input())
ans = ""
l = 26
for i in range(len(s)-1):
    if l - ord(s[i]) + 97 <= k and s[i] != "a":
        k -= l - ord(s[i]) + 97
        ans += "a"
    else:
        ans += s[i]
ans += (chr(((ord(s[-1]) - 97) + k + l) % l + 97))
print(ans)

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

arr = [ord(S[i]) for i in range(len(S))]

count = K
for i in range(len(S)):
    if i == len(S) - 1:
        if ord('z') - ord(S[i]) + 1 <= count:
            arr[i] = ord('a')
            count -= (ord('z') - ord(S[i]) + 1)
        arr[i] += count
        break

    if ord('z') - ord(S[i]) + 1 <= count:
        arr[i] = ord('a')
        count -= (ord('z') - ord(S[i]) + 1)

ans = ''
for c in arr:
    ans += chr(c)

print(ans)


Failing test case input:
lavitsgfeodc
111

Expected output:
aaaaaaaaeadh


Actual output:
aaaaaaafeadc


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

arr = [ord(S[i]) for i in range(len(S))]
count = K
for i in range(len(S)):
    if i == len(S) - 1:
        count %= 26
        if ord('z') - arr[i] + 1 <= count:
            arr[i] = ord('a')
            count -= ord('z') - ord(S[i]) + 1
        arr[i] += count
        break

    if ord('z') - arr[i] + 1 <= count and arr[i] != ord('a'):
        arr[i] = ord('a')
        count -= ord('z') - ord(S[i]) + 1

    if count == 0:
        break

for c in arr:
    sys.stdout.write(chr(c))

print('')