Problem:


Score : 400 points

Problem Statement

Mr. Takahashi has a string s consisting of lowercase English letters.
He repeats the following operation on s exactly K times.

Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of z is a.

For example, if you perform an operation for the second letter on aaz, aaz becomes abz.
If you then perform an operation for the third letter on abz, abz becomes aba.

Mr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s.
Find the such string.

Constraints

1≤|s|≤10^5

All letters in s are lowercase English letters.

1≤K≤10^9

Input

The input is given from Standard Input in the following format:

s
K

Output

Print the lexicographically smallest string after performing exactly K operations on s.

Sample Input 1

xyz
4

Sample Output 1

aya

For example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.

Sample Input 2

a
25

Sample Output 2

z

You have to perform exactly K operations.

Sample Input 3

codefestival
100

Sample Output 3

aaaafeaaivap



Sample input:
xyz
4


Sample output:
aya

Submission status: Wrong Answer

Solution code:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


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:
	K = K % 26
	tmp = ord(ans[-1])
	if tmp + K > ord('z'):
		aa = tmp + K - ord('z')
		ans[-1] = chr(aa + ORDa)
	else:
		ans[-1] = chr(tmp + K)
		
print("".join(ans))
# last shori

Submission status: Wrong Answer

Solution code:
def next_char_ascii_num(c, k):
    n = ord(c) + k
    return n if n <= 122 else n - 26


s = input()
k = int(input())
new = []

for x in s:

    if k == 0:
        new.append(ord(x))

    else:
        v =[next_char_ascii_num(x, y) for y in range(k + 1)]
        min_index = v.index(min(v))
        new.append(v[min_index])
        k -= min_index

if k > 0 and len(s) != 1:
    new[-1] = next_char_ascii_num(chr(new[-1]), k)

print("".join([chr(x) for x in new]))

Submission status: Wrong Answer

Solution code:
#C-Next Letter
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)

Submission status: Wrong Answer

Solution code:
s=[c for c in raw_input()]
K=int(raw_input())

if len(s) == 1:
    n = K/26
    for i in xrange(n+1):
        s[0] = chr(ord(s[0])+K%26)

print s

Submission status: Wrong Answer

Solution code:
ring = raw_input()
num = input()

str = []
for i in range(len(ring)):
  str.append(ring[i])

for i in range(len(str)):
  if num-1 >= ord("z")-ord(str[i]):
    num =  num - (ord("z")-ord(str[i])+1)
    str[i] = "a"

ccc = []
ccc.append(str[-1])
num = num % 26
while(num > 0):
  if ccc[0] == "z":
    num -= 1
    ccc[0] = "a"
    continue
  ccc[0] = chr(ord(ccc[0])+1)
  num -= 1

str[-1] = ccc[0]
ans = ""
for i in str:
  ans += i
print ans

Submission status: Wrong Answer

Solution code:
#C-Next Letter
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]
print(result)
if (tempK != 0):
	result = result[:-1] + chr(ord(str[-1]) + tempK)
print(result)

Submission status: Wrong Answer

Solution code:
s=raw_input()
K=input()
s=list(s)
#a-z 97-122
for i in xrange(len(s)):
    print K
    if s[i]=='a':
        continue
    if ord(s[i])+K < 123:
        continue
    else:
        K-=(123-ord(s[i]))
        s[i]='a'
if K>0:
    asc=ord(s[-1])+K
    s[-1]=chr(asc)
print "".join(s)

Submission status: Wrong Answer

Solution code:
moji = {a: b for a, b in zip("abcdefghijklmnopqrstuvwxyz", range(26))}

s = list(raw_input())
k = int(raw_input())

for i, e in enumerate(s):
    if e != "a":
        if 26 - moji[e] <= k:
            s[i] = "a"
            k -= 26 - moji[e]

k = k % 26 if k >= 0 else 0
if k != 0:
    s[-1] = "abcdefghijklmnopqrstuvwxyz"[(moji[s[-1]] + k) % 25]

print "".join(s)

Submission status: Wrong Answer

Solution code:
ring = raw_input()
num = input()

str = []
for i in range(len(ring)):
  str.append(ring[i])

for i in range(len(str)):
  if num-1 >= ord("z")-ord(str[i]):
    num =  num - (ord("z")-ord(str[i])+1)
    str[i] = "a"

ccc = []
ccc.append(str[-1])
while(num > 0):
  if ccc[0] == "z":
    num -= 1
    ccc[0] = "a"
    continue
  ccc[0] = chr(ord(ccc[0])+1)
  num -= 1

str[-1] = ccc[0]
ans = ""
for i in str:
  ans += i
print ans

Submission status: Wrong Answer

Solution code:

in_str = input()

c_l = []
for c in in_str:
    
    c_l.append(c)

steps = int(input())

#result = []
i = 0
for c in c_l:
    if i + 1 == len(c_l):
        c_l[i] = chr(((ord(c) + steps) - ord('a')) % 26 + ord('a'))
    if ord(c) - ord('a') - 26 + steps < 0:
        i += 1
        continue
    steps += ord(c) - ord('a') - 26
    c_l[i] = 'a'
    #result.append('a')
    i += 1

print (''.join(c_l))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = raw_input()
K = int(raw_input())
new = []
for i in range(1,K):
	index = i % (len(s))
	l = (ord(s[index])+1)
	if l >= 122:
		l = (l - 122)+97
	new.append( chr(l) )
print ''.join(new)

Submission status: Wrong Answer

Solution code:
def num_to_char(s_num):
    ch = []
    for num in s_num:
        ch.append(alphabet[(num%26)-1])
    return ch

s = raw_input()
K = input()

alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','\
q','r','s','t','u','v','w','x','y','z']
ans = []

s_num = []
for char in s:
    s_num.append(alphabet.index(char) + 1)

for i in xrange(len(s_num)):
    if 27 - s_num[i] < K and (s_num[i] != 1) and (i != len(s_num) - 1):
	K = K - (27 - s_num[i])
	s_num[i] = 27

    elif 27 - s_num[i] < K and (s_num[i] != 1) and (i == len(s_num) - 1):
	s_num[i] = s_num[i] + K

    elif 27 - s_num[i] >= K and (i != len(s_num)-1):
        pass

    elif s_num[i] == 1 and (i != len(s_num) - 1):
        pass

    elif i == len(s_num) - 1:
        s_num[i] = s_num[i] + K

print "".join(num_to_char(s_num))

Submission status: Wrong Answer

Solution code:
def f(s,n,m):
    m = m%26
    if ord(s[n])+m <= 122:
        s[n] = chr(ord(s[n])+m)
    else:
        t = ord(s[n])+m-122
        s[n] = chr(96+t)
    return s

def judge(c,n):
    if ord(c)+n > 122:
        return 123 - ord(c)
    else:
        return 0
        
s = list(input())
n = int(input())
l = len(s)

for i in range(0,l):
    if i == l-1:
        s = f(s,i,n)
    else:
        d = judge(s[i],n)
        s = f(s,i,d)
        n = n - d

print(''.join(s))

Submission status: Wrong Answer

Solution code:
import string as stri

s = input()
K = int(input())
ans = ""
# indexes of letter : from 0 to 25
for i in range(len(s)):
	#print(ord(i)-97)
	if (26-ord(s[i])+97 <= K):
		ans += "a"
		K -= 26+97-ord(s[i])
	else:
		ans += s[i]

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

print(ans[:-1] + lastletter)

Submission status: Wrong Answer

Solution code:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


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))
# last shori

Submission status: Wrong Answer

Solution code:
ring = raw_input()
num = input()

str = []
for i in range(len(ring)):
  str.append(ring[i])

for i in range(len(str)):
  if num-1 >= ord("z")-ord(str[i]):
    num =  num - (ord("z")-ord(str[i])+1)
    print num
    str[i] = "a"
ccc = []
ccc.append(str[-1])
while(num > 0):
  if ccc[0] == "z":
    num -= 1
    ccc[0] = "a"
    continue
  ccc[0] = chr(ord(ccc[0])+1)
  num -= 1

str[-1] = ccc[0]
ans = ""
for i in str:
  ans += i
print ans

Submission status: Wrong Answer

Solution code:
s = list(raw_input())
K = input()
for i in xrange(len(s)):
    if 123-ord(s[i]) <= K:
        K-=123-ord(s[i])
        s[i] = 'a'
if K > 0:
    s[-1] = chr(((ord(s[-1])+K%26)%97)%26+97)
print ''.join(s)

Submission status: Wrong Answer

Solution code:
def num_to_char(s_num):
    ch = []
    for num in s_num:
        ch.append(alphabet[(num%26)-1])
    return ch

s = raw_input()
K = input()

alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','\
q','r','s','t','u','v','w','x','y','z']
ans = []

s_num = []
for char in s:
    s_num.append(alphabet.index(char) + 1)

for i in xrange(len(s_num)):
    if 27 - s_num[i] <	K and (s_num[i] != 1):
        K = K - (27 - s_num[i])
	s_num[i] = 27

    elif 27 - s_num[i] >= K and (i != len(s_num)-1):
        pass

    elif s_num[i] == 1 and (i != len(s_num) - 1):
        pass

    elif i == len(s_num) - 1:
        s_num[i] = s_num[i] + K

print "".join(num_to_char(s_num))

Submission status: Wrong Answer

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

arr = [ord(S[i]) for i in range(len(S))]
K %= (len(S) * 26)
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)

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

print(ans)

Submission status: Wrong Answer

Solution code:
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


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))
# last shori

Submission status: Wrong Answer

Solution code:
#coding: utf-8
z = ord('z')
s = raw_input().strip()
K = int(raw_input())
used = 0
ret = ""
for i in xrange(len(s)):
    if i+1 == len(s):
        w = ord(s[i]) + K%26
        if w > z:
            w = ord('a') + w - z -1
        ret += chr(w)
    elif K < z - ord(s[i]) + 1:
        ret += s[i]
    else:
        K -= z - ord(s[i]) + 1
        ret += 'a'
print ret

Submission status: Wrong Answer

Solution code:
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)

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)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

s = raw_input()
k = input()

li = []

for c in s:
    if k - (123 - ord(c)) >= 0:
        li.append("a")
        k -= (123 - ord(c))
    else:
        li.append(c)
else:
    if k >= 0:
        li.append(chr(ord(li.pop()) + k % 26))

print "".join(li)

Submission status: Wrong Answer

Solution code:
s=[c for c in raw_input()]
K=int(raw_input())

c=0

while c < K:
    m_let = max(s)
    pos = s.index(m_let)
    while s[pos] != 'a' and c < K:
        c+=1
        if s[pos] == 'z':
            s[pos] = 'a'
            break
        else:
            s[pos] = chr(ord(s[pos])+1)

print s

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = raw_input()
K = int(raw_input())
new = []
for i in range(0,K):
    index = i % (len(s))
    new.append( chr((ord(s[index])+1)))
print ''.join(new)

Submission status: Wrong Answer

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

def toA(char):
    return (ord('z')-ord(char)+1)%26

def toC(char,k):
    if(ord('z')-ord(char)>=k):
        return chr(ord(char)+k)
    else:
        return chr(ord('a')+k-ord('z')-ord(char))
for i in range(len(s)):
    if(k>=toA(s[i])):
        k-=toA(s[i])
        s[i]='a'
    if(i==len(s)-1) and k>0:
        s[i]= chr(ord(s[i])+k)
print("".join(s))

Submission status: Wrong Answer

Solution code:
s = list(raw_input())
K = input()
for i in xrange(len(s)):
    if 123-ord(s[i]) <= K:
        K-=123-ord(s[i])
        s[i] = 'a'
if K > 0:
    s[-1] = chr(((ord(s[-1])+K%27)%97)%27+97)
print ''.join(s)

Submission status: Wrong Answer

Solution code:
def num_to_char(s_num):
    ch = []
    for num in s_num:
        ch.append(alphabet[(num%26)-1])
    return ch

s = raw_input()
K = input()

alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','\
q','r','s','t','u','v','w','x','y','z']
ans = []

s_num = []
for char in s:
    s_num.append(alphabet.index(char) + 1)

for i in xrange(len(s_num)):
    if 27 - s_num[i] <	K and (s_num[i] != 1):
        K = K - (27 - s_num[i])
	s_num[i] = 27

    elif 27 - s_num[i] >= K and (i != len(s_num)-1):
        pass

    elif s_num[i] == 1:
        pass

    elif i == len(s_num) - 1:
        s_num[i] = s_num[i] + K

print "".join(num_to_char(s_num))

Submission status: Wrong Answer

Solution code:
def needed_to_flip(c):
    return ord('z') - ord(c) + 1

s = list(raw_input())
K = int(raw_input())
#s = list('za')
#K = 4


for i, c in enumerate(s):
	if c == 'a' and i != len(s) - 1:
		continue
	needed = needed_to_flip(c)
	print "%s: needed: %d, has: %d" % (c, needed, K)
	if K >= needed:
		K -= needed
		s[i] = 'a'
		
	print "flip: %s needed: %d, has: %d" % (s[i], needed,K) 
	if i == len(s) - 1:
		s[i] = chr(ord(s[i]) + (K % 26))

print ''.join(s)

Submission status: Wrong Answer

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


def compTup(a, b):
  if a[0] > b[0]:
    return 1
  elif a[0] == b[0]:
    return 0
  else:
    return -1

eff = [(float(26-s[i])/s[i],i) for i in range(len(s))]

eff.sort(cmp=compTup)

for f in eff:
  i = f[1]
  sv = s[i]
  if (27 - sv) > k:
    break
  s[i] = 1
  k = k - (27 - sv)

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

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

Submission status: Wrong Answer

Solution code:
ring = raw_input()
num = input()

str = []
for i in range(len(ring)):
  str.append(ring[i])

for i in range(len(str)):
  if num-1 >= ord("z")-ord(str[i]):
    while(num != 0):
      if str[i] == "z":
        num -= 1
        str[i] = "a"
        break
      str[i] = chr(ord(str[i])+1)
      num -= 1

ccc = []
ccc.append(str[-1])
while(num != 0):
  if ccc[0] == "z":
    num -= 1
    ccc[0] = "a"
    continue
  ccc[0] = chr(ord(ccc[0])+1)
  num -= 1

str[-1] = ccc[0]
ans = ""
for i in str:
  ans += i
print ans

Submission status: Wrong Answer

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

for i in range(len(s)):
    tmp = ord(s[i])
    if 1 <= 123 - tmp <= K and i != "a":
        s[i] = "a"
        K -= (123 - tmp)

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

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

Submission status: Wrong Answer

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

arr = [ord(S[i]) for i in range(len(S))]
K %= len(S) * 26
count = K
for i in range(len(S)):
    if i == len(S) - 1:
        count %= 26
        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)

Submission status: Wrong Answer

Solution code:
def needed_to_flip(c):
    return ord('z') - ord(c) + 1

s = list(raw_input())
K = int(raw_input())
#s = list('za')
#K = 4


for i, c in enumerate(s):
	if c == 'a':
		continue
	needed = needed_to_flip(c)
	#print "%s: needed: %d, has: %d" % (c, needed, K)
	if K >= needed:
		K -= needed
		s[i] = 'a'
		
	#print "flip: %s needed: %d, has: %d" % (s[i], needed,K) 
	if i == len(s) - 1:
		s[i] = chr(ord(s[i]) + (K % 26))

print ''.join(s)

Submission status: Wrong Answer

Solution code:
import sys

s = sys.stdin.readline().strip()
K = int(sys.stdin.readline())
c = []
for i in s:
        c.append(ord(i)-ord('a'))

i =0
while i< len(c):
        path2a = (26-c[i] ) % 26
        if path2a < K:
                K -= path2a
                c[i] = 0
        i+=1
c[-1] = (c[-1]+ K) %26

res = ""
for i in c:
        res += chr(i+ord('a'))

sys.stdout.write( res)

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())
for i, c in enumerate(s):
    if K >= (123-ord(c)):
        print ('a',end="")
        K-=(123-ord(c))
    else:
        print (c,end="")

Submission status: Wrong Answer

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

def dista(c):
    return ord('z')-ord(c)+1


s = [c for c in s]

for i in range(len(s)):
    if(dista(s[i])<=K):
        K -= dista(s[i])
        s[i] = 'a'
    

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

Submission status: Wrong Answer

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

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

    elif i == len(s) - 1 and numChanges > k:
        s[i] = chr(ord(s[i]) + k)

print ''.join(s)

Submission status: Wrong Answer

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

def cord(c):
    return ord(c)-97

def cchr(n):
    return chr(n+97)

def smcheck(c, k):
    return 26-cord(c) <= k

def smcnt(c, k):
    return 26-cord(c)

ans = ''
for c in s:
    sc = smcnt(c, K)
    if sc <= K and sc < 26:
        K -= sc
        ans += cchr((cord(c) + sc)%26)
        print(K,ans)
    else:
        ans += c
if K>26:
    K = K%26
if K>0:
    lc = ans[-1]
    ans = ans[:-1]
    ans += cchr((cord(lc)+K)%26)

print(ans)

Submission status: Wrong Answer

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

opreq = [(ord('z') - ord(c) + 1) % 26 for c in s]

s_ = []

if len(s) > 1:
    i = 0
    while k > 0 and i < len(s) - 1:
        if opreq[i] < k:
            k = k - opreq[i]
            s_.append('a')
        else:
            s_.append(s[i])
        i += 1

# Last character
last_c = chr((k + ord(s[-1]) - ord('a')) % 26 + ord('a'))
s_.append(last_c)

print("".join(s_))

Submission status: Wrong Answer

Solution code:
def needed_to_flip(c):
    return ord('z') - ord(c) + 1

s = raw_input().split()
K = int(raw_input())
#s = list('xyz')
#K = 4


for i, c in enumerate(s):
	if c == 'a':
		continue
	needed = needed_to_flip(c)
	#print "%s: needed: %d, has: %d" % (c, needed, K)
	if K >= needed:
		K -= needed
		s[i] = 'a'
		
	#print "flip: %s needed: %d, has: %d" % (s[i], needed,K) 
	if i == len(s) - 1:
		s[i] = chr(ord(s[i]) + (K % 26))

print ''.join(s)

Submission status: Wrong Answer

Solution code:
S = raw_input()
k = input()

n0 = ord("a")
ans = []
for t in S:
    n_t = ord(t)
    m = 26 - (n_t - n0)
    if m <= k:
        ans.append("a")
        k -= m
    else:
        ans.append(t)

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

print "".join(ans)

Submission status: Wrong Answer

Solution code:
moji = {a: b for a, b in zip("abcdefghijklmnopqrstuvwxyz", range(26))}

s = list(raw_input())
k = int(raw_input())

for i, e in enumerate(s):
    if 26 - moji[e] <= k:
        s[i] = "a"
        k -= 26 - moji[e]

k = k % 26 if k >= 0 else 0
if k != 0:
    s[-1] = "abcdefghijklmnopqrstuvwxyz"[(moji[s[-1]] + k) % 26]

print "".join(s)

Submission status: Wrong Answer

Solution code:
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') - 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)

Submission status: Wrong Answer

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

def toA(char):
    return (ord('z')-ord(char)+1)%26
for i in range(len(s)):
    if(k>=toA(s[i])):
        k-=toA(s[i])
        s[i]='a'
    if(i==len(s)-1) and k>0:
        s[i]= chr(ord(s[i])+k)
print("".join(s))

Submission status: Wrong Answer

Solution code:
z = ord('z')
s = raw_input()
K = int(raw_input())
used = 0
ret = ""
for i in xrange(len(s)):
    if i+1 == len(s):
        w = ord(s[i]) + K%26
        if w > z:
            w = ord('a') + w - z -1
        ret += chr(w)
    elif K < z - ord(s[i]) + 1:
        ret += s[i]
    else:
        K -= z - ord(s[i]) + 1
        ret += 'a'
print ret

Submission status: Wrong Answer

Solution code:
ring = raw_input()
num = input()

str = []
for i in range(len(ring)):
  str.append(ring[i])

for i in range(len(str)):
  if num-1 >= ord("z")-ord(str[i]):
    while(num != 0):
      if str[i] == "z":
        num -= 1
        str[i] = "a"
        break
      str[i] = chr(ord(str[i])+1)
      num -= 1

ans = ""
for i in str:
  ans += i
print ans

Submission status: Wrong Answer

Solution code:
s = list(raw_input())
k = input()
for i in xrange(len(s)-1):
    need = ord('z') - ord(s[i]) + 1
    if need <= k:
        k -= need
        s[i] = 'a'
k %= 26
s[-1] = chr(((ord(s[-1]) + k - ord('a')) % 26) + ord('a'))
print ''.join(s)

Submission status: Wrong Answer

Solution code:
import string as stri

s = input()
K = int(input())
ans = ""
# indexes of letter : from 0 to 25
for i in range(len(s)):
	#print(ord(i)-97)
	if (26-ord(s[i])+97 <= K):
		ans += "a"
		K -= 26+97-ord(s[i])
	else:
		ans += s[i]

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

print(ans[:-1] + lastletter)

Submission status: Wrong Answer

Solution code:
z = ord('z')
s = raw_input()
K = int(raw_input())
used = 0
ret = ""
for i in xrange(len(s)):
    if i+1 == len(s):
        w = ord(s[i]) + K%26 - z
        ret += chr(ord('a') + w)
    elif K < z - ord(s[i]) + 1:
        ret += s[i]
    else:
        K -= z - ord(s[i]) + 1
        ret += 'a'
print ret

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

s = raw_input()
k = input()

li = []

for c in s:
    if 123 - ord(c) <= k:
        li.append("a")
        k -= 123 - ord(c)
    else:
        li.append(c)
else:
    if k > 0:
        li.append(chr(ord(li.pop()) + k % 26))

print "".join(li)

Submission status: Wrong Answer

Solution code:
jisho = ["z","y","x","w","v","u","t","s","r","q","p","o","n","m","l","k","j","i","h","g","f","e","d","c","b","a"]

s = list(input())
n = len(s)
k =int(input())
cou = 0
res = ""

for elem in s:
   cou += jisho.index(elem)+1
k = k % cou

for elem in s:
    if jisho.index(elem)+1 <= k:
        res += "a"
        k -= jisho.index(elem)+1
    else:
        res += elem

res = res[0:n-1] + jisho[jisho.index(res[n-1])-k]
print(res)

Submission status: Wrong Answer

Solution code:
s = raw_input()
k = int(raw_input())
albets = 'abcdefghijklmnopqrstuvwxyz'
dic = {}
for idx, letter in enumerate(albets):
    dic[letter] = 26 - idx
ans = ''
for l in s[:-1]:
    if k >= dic[l]:
        ans += 'a'
        k -= dic[l]
    else:
        ans += l
ans += albets[(26 - dic[s[-1]] + k) % 26]
print ans

Submission status: Wrong Answer

Solution code:
s = raw_input()
K = int(raw_input())
s_list = list(s)
for i in range(len(s_list)):
    # how long does it take to force a
    lag = ord('z') - ord(s_list[i]) + 1
    if s_list[i] != 'a' and K >= lag:
        # not a and can conv
        s_list[i] = 'a'
        K -= lag
    elif i == len(s_list) - 1:
        s_list[i] = chr(ord('a') + ((ord(s_list[i]) - ord('a') + K) % 26))
print "".join(s_list)

Submission status: Wrong Answer

Solution code:
o = ord('a')
s = [ord(c) - o for c in raw_input().strip()]
k = int(raw_input())
for i, c in enumerate(s):
    if c and 26 - c < k:
        t = 26 - c
        k -= t
        s[i] = 0
k %= 26
s[-1] += k
if s[-1] >= 26:
    s[-1] -= 26
print ''.join(chr(o + c) for c in s)

Submission status: Wrong Answer

Solution code:
import string as stri

s = input()
K = int(input())
ans = ""
# indexes of letter : from 0 to 25
for i in range(len(s)):
	#print(ord(i)-97)
	if (26-ord(s[i])+97 <= K):
		ans += "a"
		K -= 26+97-ord(s[i])
	else:
		ans += s[i]

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    s = raw_input()
    k = input()

    li = []

    for c in s:
        if 123 - ord(c) <= k:
            li.append("a")
            k -= 123 - ord(c)
        else:
            li.append(c)
    else:
        if k > 0:
            li.append(chr(ord(li.pop()) + k))

    print "".join(li)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys 

s = sys.stdin.readline().strip()
K = int(sys.stdin.readline())
c = []
for i in s:
        c.append(ord(i)-ord('a'))
                                                                                                                                                                                                                                      
i =0
while i< len(c):
        path2a = (26-c[i] ) % 26
        if path2a < K:
                K -= path2a
                c[i] = 0 
        i+=1
c[-1] = (c[-1]+ K) %26 

res = ""
for i in c:
        res += chr(i+ord('a'))

print res

Submission status: Wrong Answer

Solution code:
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)

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)

Submission status: Wrong Answer

Solution code:
moji = {a: b for a, b in zip("abcdefghijklmnopqrstuvwxyz", range(26))}

s = list(raw_input())
k = int(raw_input())

for i, e in enumerate(s):
    if 26 - moji[e] <= k:
        s[i] = "a"
        k -= 26 - moji[e]

k = k % 26
if k != 0:
    s[-1] = "abcdefghijklmnopqrstuvwxyz"[(moji[s[-1]] + k) % 26]

print "".join(s)

Submission status: Wrong Answer

Solution code:
S = list(raw_input())
K = input()

k = K
while True:
    flag = False

    for i,s in enumerate(S):
        cost = ord('z')-ord(s)+1
        if cost <= k and s != "a":
            k-=cost
            S[i] = 'a'
            flag = True
            break
    if not flag:
        break
print S[-1],k
c = chr((ord(S[-1])-ord('a')+k)%26+ord('a'))
S[-1] = c

print "".join(S)

Submission status: Wrong Answer

Solution code:
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:
        K %= 26
        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)

Submission status: Wrong Answer

Solution code:
s = raw_input()
K = int(raw_input())
s_list = list(s)
for i in range(len(s_list)):
    # how long does it take to force a
    lag = ord('z') - ord(s_list[i]) + 1
    if s_list[i] != 'a' and K >= lag:
        # not a and can conv
        s_list[i] = 'a'
        K -= lag
    elif i == len(s_list) - 1:
        s_list[i] = ord('a') + ((ord(s_list[i]) - ord('a') + K) % 26)
print "".join(s_list)

Submission status: Wrong Answer

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

def cord(c):
    return ord(c)-97

def cchr(n):
    return chr(n+97)

def smcheck(c, k):
    return 26-cord(c) <= k

def smcnt(c, k):
    return 26-cord(c)

ans = ''
for c in s:
    sc = smcnt(c, K)
    if sc <= K:
        K -= sc
        ans += cchr((cord(c) + sc)%26)
    else:
        ans += c
if K>0:
    lc = ans[-1]
    ans = ans[:-1]
    ans += cchr((cord(lc)+K)%26)

print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
z = ord('z')
s = raw_input()
K = int(raw_input())
used = 0
ret = ""
for i in xrange(len(s)):
    if i+1 == len(s):
        ret += chr(ord(s[i]) + K%26)
    elif K < z - ord(s[i]) + 1:
        ret += s[i]
    else:
        K -= z - ord(s[i]) + 1
        ret += 'a'
print ret

Submission status: Wrong Answer

Solution code:
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) 
    # print(c, n, K)
    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))

Submission status: Wrong Answer

Solution code:
import string

# -*- coding: utf-8 -*-
s = raw_input()
k = int(raw_input())

a_ls = list(string.ascii_lowercase)
a_len = len(a_ls)

end = ''

for c in s:
    idx = a_ls.index(c)
    for_overflow = (a_len - idx)
    if c is not 'a' and k - for_overflow > 0:
        end += 'a'
        k -= for_overflow
    else:
        end += c

if k > 0:
    end = end[:len(end)-1] + a_ls[(a_ls.index(end[-1]) + k) % a_len]

# output
print end

Submission status: Wrong Answer

Solution code:
#[int(x)-1 for x in input().split()]
s= input()
K=int(input())
def can_change_to_a(st,remains):
    if ord('z')+1 - ord(st) <= remains:
        return True
    return False

s_ans = list(s)
for i,ch in enumerate(s):
    if K >= ord('z')+1-ord(ch):
        K -= ord('z')+1-ord(ch)
        s_ans[i]='a'

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

print(''.join(s_ans))

Submission status: Wrong Answer

Solution code:
z = ord('z')
s = raw_input()
K = int(raw_input())
used = 0
ret = ""
for i in xrange(len(s)):
    if i+1 == len(s):
        ret += chr(ord(s[i]) + (K - used)%26)
    elif K - used < z - ord(s[i]) + 1:
        ret += s[i]
    else:
        used += z - ord(s[i]) + 1
        ret += 'a'

print ret