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

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)



import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;


public class Main {

	static final int INF=Integer.MAX_VALUE;			// 2147483647
	static final long LINF=Long.MAX_VALUE;			// 9223372036854775807

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
//		int k = sc.nextInt();
		long k = sc.nextLong();
		sc.close();
		char[] Strs = str.toCharArray();
		int n = Strs.length;
		int[] Ints = new int[n];
		for (int i = 0; i<n; i++) {
			Ints[i] = Char2Num(Strs[i]);
		}

		
//		pa(Strs);
//		pa(Ints);
		
		for (int i = 0; i<n; i++) {
			int delta = 26 - Ints[i];
//			p(delta);
			if (delta <= k) {
				k -= delta;
				Ints[i] = 0;
			}
		}
		// Kの端数は最後に押し付け
		k = (k % 26);
		if (k > 0) {
			Ints[n-1] = (Ints[n-1] + (int)k) % 26;
		}

		for (int i = 0; i<n; i++) {
			pn(Num2Char(Ints[i]));
		}
		p("");
	}
	
	
	
	
	public static void p(Number a) {
		System.out.println(a);		
	}
	public static void p(String a) {
		System.out.println(a);		
	}
	public static void p(char a) {
		System.out.println(a);		
	}
	public static void pn(Number a) {
		System.out.print(a);		
	}
	public static void pn(String a) {
		System.out.print(a);		
	}
	public static void pn(char a) {
		System.out.print(a);		
	}
	public static void pa(String[] As) {
		for (int i = 0; i<As.length; i++) {
			pn(As[i]);
			pn(", ");
		}
		p("");
	}
	public static void pa(Number[] As) {
		for (int i = 0; i<As.length; i++) {
			pn(As[i]);
			pn(", ");
		}
		p("");
	}
	public static void pa(int[] As) {
		for (int i = 0; i<As.length; i++) {
			pn(As[i]);
			pn(", ");
		}
		p("");
	}
	

	public static int powerInt(int a, int b) {
		return (int) Math.pow(a, b);
	}

	public static int max(int arr[]) {
		int max = arr[0];
		
		for (int i=0; i<arr.length; i++) {
			if (max < arr[i]) {
				max = arr[i];
			}
		}
		
		return max;
	}
	public static double max(double arr[]) {
		double max = arr[0];
		
		for (int i=0; i<arr.length; i++) {
			if (max < arr[i]) {
				max = arr[i];
			}
		}
		
		return max;
	}	
	public static int min(int arr[]) {
		int max = arr[0];
		
		for (int i=0; i<arr.length; i++) {
			if (max > arr[i]) {
				max = arr[i];
			}
		}
		
		return max;
	}
	public static double min(double arr[]) {
		double max = arr[0];
		
		for (int i=0; i<arr.length; i++) {
			if (max > arr[i]) {
				max = arr[i];
			}
		}
		
		return max;
	}
	
	public static char Num2Char(int num) {
		return (char)(num + 'a');
	}
	public static int Char2Num(char c) {
		return (int)(c - 'a');
	}
	
//	static Map<String, Integer> Alph2Num = new HashMap<String, Integer>() {
//		{
//			put("a", 0);
//			put("b", 1);
//			put("c", 2);
//			put("d", 3);
//			put("e", 4);
//			put("f", 5);
//			put("g", 6);
//			put("h", 7);
//			put("i", 8);
//			put("j", 9);
//			put("k", 10);
//			put("l", 11);
//			put("m", 12);
//			put("n", 13);
//			put("o", 14);
//			put("p", 15);
//			put("q", 16);
//			put("r", 17);
//			put("s", 18);
//			put("t", 19);
//			put("u", 20);
//			put("v", 21);
//			put("w", 22);
//			put("x", 23);
//			put("y", 24);
//			put("z", 25);
//		}
//	};
//
//
//	static Map<Integer, String> Num2Alph = new HashMap<Integer, String>() {
//		{
//			put(0, "a");
//			put(1, "b");
//			put(2, "c");
//			put(3, "d");
//			put(4, "e");
//			put(5, "f");
//			put(6, "g");
//			put(7, "h");
//			put(8, "i");
//			put(9, "j");
//			put(10, "k");
//			put(11, "l");
//			put(12, "m");
//			put(13, "n");
//			put(14, "o");
//			put(15, "p");
//			put(16, "q");
//			put(17, "r");
//			put(18, "s");
//			put(19, "t");
//			put(20, "u");
//			put(21, "v");
//			put(22, "w");
//			put(23, "x");
//			put(24, "y");
//			put(25, "z");
//		}
//	};

}