Harryxun/stf_run huggingface dataset:
def impossible(taro_cards, hanako_cards, average):
    if (sum(taro_cards) + sum(hanako_cards)) % 2 == 1:
        return True
    elif sum(taro_cards) + max(taro_cards) - min(hanako_cards) < average:
        return True
    elif sum(hanako_cards) + max(hanako_cards) - min(taro_cards) < average:
        return True
    else:
        return False


while True:
    n_taro, n_hanako = map(int, input().split())
    if n_taro == 0 and n_hanako == 0:
        break

    taro_cards = []
    hanako_cards = []
    change_pairs = []

    for i in range(n_taro):
        taro_cards.append(int(input()))
    for i in range(n_hanako):
        hanako_cards.append(int(input()))

    average = (sum(taro_cards) + sum(hanako_cards)) // 2

    if impossible(taro_cards, hanako_cards, average):
        print(-1)
    else:
        # record pairs of cards to be changed
        for i in range(len(taro_cards)):
            for j in range(len(hanako_cards)):
                if sum(taro_cards[:i]) + sum(taro_cards[i+1:]) + hanako_cards[j] == average:
                    change_pairs.append((taro_cards[i], hanako_cards[j]))
                    # print("{0} {1}".format(taro_cards[i], hanako_cards[j]))

        # print the pair of cards to be changed
        pairs_leastsum = change_pairs[0]
        for i in range(1, len(change_pairs)):
            if sum(change_pairs[i]) <= sum(pairs_leastsum):
                pairs_leastsum = change_pairs[i]
        print(*pairs_leastsum)

### FIXED CODE ###

def impossible(taro_cards, hanako_cards, average):
    if (sum(taro_cards) + sum(hanako_cards)) % 2 == 1:
        return True
    elif sum(taro_cards) + max(taro_cards) - min(hanako_cards) < average:
        return True
    elif sum(hanako_cards) + max(hanako_cards) - min(taro_cards) < average:
        return True
    else:
        return False


while True:
    n_taro, n_hanako = map(int, input().split())
    if n_taro == 0 and n_hanako == 0:
        break

    taro_cards = []
    hanako_cards = []
    change_pairs = []

    for _ in range(n_taro):
        taro_cards.append(int(input()))
    for _ in range(n_hanako):
        hanako_cards.append(int(input()))

    average = (sum(taro_cards) + sum(hanako_cards)) // 2

    if impossible(taro_cards, hanako_cards, average):
        print(-1)
    else:
        # record pairs of cards to be changed
        for i in range(len(taro_cards)):
            for j in range(len(hanako_cards)):
                if sum(taro_cards[:i]) + sum(taro_cards[i+1:]) + hanako_cards[j] == average:
                    change_pairs.append((taro_cards[i], hanako_cards[j]))
                    # print("{0} {1}".format(taro_cards[i], hanako_cards[j]))

        # print the pair of cards to be changed
        if change_pairs == []:
            print(-1)
        else:
            pairs_leastsum = change_pairs[0]
            for i in range(1, len(change_pairs)):
                if sum(change_pairs[i]) <= sum(pairs_leastsum):
                    pairs_leastsum = change_pairs[i]
            print(*pairs_leastsum)
n = int(input())
p = []
for i in range(n-1):
    p.append(list(map(int, input().split()))+ [1])
l = [[] for i in range(n+1)]
for pi in p: 
    l[pi[0]].append([pi[0],pi[1]])
    l[pi[1]].append([pi[1],pi[0]])
kyo = [float("inf")]*(n+1)
kyo[1] = 0
memo = [0] * (n+1)
memo[1] = 1
ruto = []
def dfs(start,ruto):
  ruto.extend(l[start])
  memo[start] = 1
  while ruto:
    a = ruto.pop()
    if memo[a[1]] == 1:
      continue
    kyo[a[1]] = kyo[a[0]] + 1
    dfs(a[1],ruto)
  return
dfs(1,ruto)

nkyo = [float("inf")]*(n+1)
nkyo[n] = 0
memo = [0] * (n+1)
memo[n] = 1
ruto = []
def dfs(start,ruto):
  ruto.extend(l[start])
  memo[start] = 1
  while ruto:
    a = ruto.pop()
    if memo[a[1]] == 1:
      continue
    nkyo[a[1]] = nkyo[a[0]] + 1
    dfs(a[1],ruto)
  return
dfs(n,ruto)
iti = 0
nko = 0
for i in range(1,n+1):
  if kyo[i] <= nkyo[i]:
    iti += 1
  else:
    nko += 1
if iti <= nko:
  print("Snuke")
else:
  print("Fennec")

### FIXED CODE ###

import sys
sys.setrecursionlimit(2000000)
n = int(input())
p = []
for i in range(n-1):
    p.append(list(map(int, input().split()))+ [1])
l = [[] for i in range(n+1)]
for pi in p: 
    l[pi[0]].append([pi[0],pi[1]])
    l[pi[1]].append([pi[1],pi[0]])
kyo = [float("inf")]*(n+1)
kyo[1] = 0
memo = [0] * (n+1)
memo[1] = 1
ruto = []
def dfs(start,ruto):
  ruto.extend(l[start])
  memo[start] = 1
  while ruto:
    a = ruto.pop()
    if memo[a[1]] == 1:
      continue
    kyo[a[1]] = kyo[a[0]] + 1
    dfs(a[1],ruto)
  return
dfs(1,ruto)

nkyo = [float("inf")]*(n+1)
nkyo[n] = 0
memo = [0] * (n+1)
memo[n] = 1
ruto = []
def dfs(start,ruto):
  ruto.extend(l[start])
  memo[start] = 1
  while ruto:
    a = ruto.pop()
    if memo[a[1]] == 1:
      continue
    nkyo[a[1]] = nkyo[a[0]] + 1
    dfs(a[1],ruto)
  return
dfs(n,ruto)
iti = 0
nko = 0
for i in range(1,n+1):
  if kyo[i] <= nkyo[i]:
    iti += 1
  else:
    nko += 1
if iti <= nko:
  print("Snuke")
else:
  print("Fennec")
num,time = map(int,raw_input().split())
t = map(int, raw_input().split())
ans = 0
for i in range(len(t)-1):
	if t[i]<time:
		ans += t[i]
	else:
	ans += time
ans += time
print ans

### FIXED CODE ###

num,time = map(int, raw_input().split())
t = raw_input().split()
ans = time
for i in range(0,num-1):
	if int(t[i+1])-int(t[i]) < time:
		ans += int(t[i+1])-int(t[i])
	else:
		ans += time
print ans
s = input()
t = "AKIHABARA"
idx = 0
ok = 1
for i in range(len(s)):
    if idx == len(t):
        ok = 0
        break
    if s[i] == t[idx]:
        idx += 1
    elif s[i] != 'A' and t[idx] == 'A':
        idx += 1
        if s[i] == t[idx]:
            idx += 1
        else:
            ok = 0
    else:
        ok = 0
if idx != len(t) and idx != len(t)-1:
    ok = 0
print("YES"*ok or "NO")

### FIXED CODE ###

s = input()
t = "AKIHABARA"
idx = 0
ok = 1
for i in range(len(s)):
    if idx == len(t):
        ok = 0
        break
    if s[i] == t[idx]:
        idx += 1
    elif s[i] != 'A' and t[idx] == 'A':
        idx += 1
        if idx < len(t) and s[i] == t[idx]:
            idx += 1
        else:
            ok = 0
    else:
        ok = 0
if idx != len(t) and idx != len(t)-1:
    ok = 0
print("YES"*ok or "NO")
A,B = map(int, input().split())
 
count = 1
while True:
  	if B == 1 :
        print(0)
        break
    if B - A <= 0:
        print (count)
        break
    else:
        B = B - A + 1
        count += 1

### FIXED CODE ###

A,B = map(int, input().split())
 
count = 1
while True:
    if B == 1 :
        print(0)
        break
    if B - A <= 0:
        print (count)
        break
    else:
        B = B - A + 1
        count += 1
import numpy as np

import itertools

import math 
from collections import defaultdict as dd
def main():
    N, Y = map(int, input().split())
    a = int(Y/10000)

    if a*10000 == Y:
        print (a,0,0)
        return

    s = -1
    for k in range(a+1):
        b = N-k
        if b >= 0:
            for j in range(b+1):
                s = 10000*k+5000*j+1000*(b-j)
                if s == Y:
                    print (k,j,(b-j))
                    return

    if s != Y:
        print ('-1 -1 -1')



if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()


### FIXED CODE ###

s  = input()
print ('2018'+s[4:])
def main():
    from builtin import min
    N = int(input())

    a = 0  # not carried
    b = 0  # carried
    t = N % 10
    a, b = a + t, a + (10 - t)
    N //= 10
    while N != 0:
        t = N % 10
        a, b = min(a + t, b + (t + 1)), min(a + (10 - t), b + (10 - (t + 1)))
        N //= 10
    print(min(a, b + 1))


main()


### FIXED CODE ###

N = input()

N = '0' + N
result = 0
carry = 0
for i in range(len(N) - 1, 0, -1):
    c = int(N[i]) + carry
    n = int(N[i - 1])
    if c < 5 or (c == 5 and n < 5):
        result += c
        carry = 0
    else:
        result += 10 - c
        carry = 1
result += carry
print(result)
N = int(input())
L = list(int, input())
count = 0

for i in range(N-2):
    Li = L[i]
    for j in range(i+1, N-1):
        Lj = L[j]
        for k in range(j+1, N):
            Lk = L[k]
            if (Li == Lj) or (Lj == Lk) or (Lk == Li):
                continue
            else:
                if ((Li + Lj) >= Lk) and ((Li + Lk) >= Lj) and ((Lk + Lj) >= Li):
                    count = count + 1
print(count)

### FIXED CODE ###

A = list(input())

n = A.count('R')
if n != 2:
    print(n)
else:
    m = A.index('S')
    if m == 1:
        print(1)
    else:
        print(2)
import itertools
N = int(input())
AB = [list(map(int, input().split())) for n in range(N)]

if N % 2 == 0:
  k1 = int(N/2-1)
  k2 = int(N/2)
  arr1 = list(range(AB[k1][0], AB[k1][1] + 1))
  arr2 = list(range(AB[k2][0], AB[k2][1] + 1))
  pattern = list(itertools.product(arr1, arr2))
  ans = set()
  for p in pattern:
    ans.add(sum(p))
  print(len(ans))
else:
  k = int((N+1)/2)-1
  A = AB[k][0]
  B = AB[k][1]
  print(B-A+1)

### FIXED CODE ###

import itertools
N = int(input())
AB = [list(map(int, input().split())) for n in range(N)]
sortA = sorted(AB, key= lambda x:x[0])
sortB = sorted(AB, key= lambda x:x[1])
if N % 2 == 0:
  k1 = int(N/2-1)
  k2 = int(N/2)
  minM = sortA[k1][0] + sortA[k2][0]
  maxM = sortB[k1][1] + sortB[k2][1]
  print(maxM-minM+1)
else:
  k = int((N+1)/2)-1
  A = sortA[k][0]
  B = sortB[k][1]
  print(B-A+1)
# -*- coding:utf-8 -*-

def is_onaji(S):
    pre_moji = S[0]
    for i in range(1, len(S)):
        if S[i] == pre_moji:
            pre_moji = S[i]
            continue
        else:
            return False
    return True


def solve():
    S = input()
    K = int(input())
    N = len(S)

    if N == 1:
        print(K//2)
        return

    # 1回目
    base1 = 0
    pre_moji = S[0]
    for i in range(1, N):
        if S[i] == pre_moji:
            base1 += 1
            pre_moji = "?"
        else:
            pre_moji = S[i]

    if K == 1:
        print(base1)
        return

    # 2回目
    base2 = 0
    for i in range(0, N):
        if S[i] = pre_moji:
            base2 += 1
            pre_moji = "?"
        else:
            pre_moji = S[i]

    if K == 2:
        print(base1+base2)

    # 3回目
    base3 = 0
    for i in range(0, N):
        if S[i] = pre_moji:
            base3 += 1
            pre_moji = "?"
        else:
            pre_moji = S[i]

    if K == 3:
        print(base1+base2+base3)

    if base1 == base2 and base2 == base3:
        print(base1*K)
    elif base1 != base2 and base2 == base3:
        print(base1 + base2*(K-1))
    else:
        # base1とbase2が交互にくる
        print(base1*((K+1)//2) + base2*(K//2))


if __name__ == "__main__":
    solve()


### FIXED CODE ###

# -*- coding:utf-8 -*-

def is_onaji(S):
    pre_moji = S[0]
    for i in range(1, len(S)):
        if S[i] == pre_moji:
            pre_moji = S[i]
            continue
        else:
            return False
    return True


def solve():
    S = input()
    K = int(input())
    N = len(S)

    if N == 1:
        print(K//2)
        return

    # 1回目
    base1 = 0
    pre_moji = S[0]
    for i in range(1, N):
        if S[i] == pre_moji:
            base1 += 1
            pre_moji = "?"
        else:
            pre_moji = S[i]

    if K == 1:
        print(base1)
        return

    # 2回目
    base2 = 0
    for i in range(0, N):
        if S[i] == pre_moji:
            base2 += 1
            pre_moji = "?"
        else:
            pre_moji = S[i]

    if K == 2:
        print(base1+base2)
        return

    # 3回目
    base3 = 0
    for i in range(0, N):
        if S[i] == pre_moji:
            base3 += 1
            pre_moji = "?"
        else:
            pre_moji = S[i]

    if K == 3:
        print(base1+base2+base3)
        return

    if base1 == base2 and base2 == base3:
        print(base1*K)
    elif base1 != base2 and base2 == base3:
        print(base1 + base2*(K-1))
    else:
        # base1とbase2が交互にくる
        print(base1*((K+1)//2) + base2*(K//2))


if __name__ == "__main__":
    solve()
def ppc(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x = x + (x >> 8) 
    x = x + (x >> 16) 
    x = x + (x >> 32) 
    return x & 0x0000007f

def sol():
    n=int(input())
    x=input()
    chk=0
    for i,j in enumerate(x[::-1]):
        if j=="1":
            chk+=2**i
    c,d={},{}
    ans=[]
    for i,j in enumerate(x[::-1]):
        p=pow(2,i)
        if j=="1":
            t=chk-p
        else:
            t=chk+p
        s=t
        cnt=0
        while t:
            if t not in c:
                pc=ppc(t)
                c[t]=pc
            else:
                pc=c[t]
            t%=pc
            cnt+=1
            if t in d:
                cnt+=d[t]
                break
        if s not in d:
            d[s]=cnt
        ans.append(cnt)
    for i in ans[::-1]:
        print(i)

if __name__=="__main__":
    sol()

### FIXED CODE ###

n=int(input())
x=input()
chk0=chk1=chk2=0
b=x.count("1")
if b==1 and x=="1":
    print(0)
    exit()
elif b==1:
    for i in range(n):
        if i==n-1: print(2)
        elif x[i]=="0": print(1)
        else: print(0)
    exit()
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk1+=pow(2,i,b+1)
        if b>1: chk2+=pow(2,i,b-1)
        else: chk2=0
l=[]
for i,j in enumerate(x[::-1]):
    if b: a1=pow(2,i,b+1)
    else: a1=1
    if b>1: a2=pow(2,i,b-1)
    else: a2=1
    if j=="0":
        t=chk1+a1
    else:
        if b>1: t=chk2+b-1-a2
        else: t=0
    ans,f=0,1
    while t:
        if f:
            if j=="0": t%=(b+1)
            else: t%=(b-1)
            f=0
        else:
            t%=bin(t).count("1")
        ans+=1
    l.append(ans)
for i in l[::-1]:
    print(i)
A B C =input()



print('YES' if A[count(A-1)]==B[0] and B[count(B-1)]==c[0] else 'No')

### FIXED CODE ###

A,B,C = input().split()
print("YES" if A[-1]==B[0] and B[-1] == C[0] else "NO")
n = int(input())
alist=list(map(int,input().split()))
core = 0
for i in range(1,n-3):
  core +=min(alist[i-1],alist[i],alist[i+1])
print(core +min(alist[-2],alist[-1]) +alist[-1] +min(alist[0],alist[1]))

### FIXED CODE ###

n = int(input())
alist=list(map(int,input().split()))
alist.insert(0,1e7)
alist.append(1e7)
core = 0
for i in range(n):
  core +=min(alist[i],alist[i+1])
print(core)
import heapq
n,m=[int(i) for i in input().split()]
a=[-int(i) for i in input().split()]
for i in range(m):
    heapq.heapify(a)
    b=heapq.heappop(a)
    b=b/2
    heapq.heappush(a,b)
ans=0
for i in c:
    ans-=int(i)
print(ans)

### FIXED CODE ###

import heapq
n,m=[int(i) for i in input().split()]
a=[-1*int(i) for i in input().split()]
heapq.heapify(a)
for i in range(m):
    b=heapq.heappop(a)
    b=b/2
    heapq.heappush(a,b)
ans=0
for i in a:
    ans-=int(i)
print(ans)
import sys
import collections


def alg_duplicate_combination_mod(n, r, mod):
    n = n + r - 1
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    t = m
    d = collections.defaultdict(int)
    for i in range(2, int(t ** 0.5) + 1):
        while True:
            if t % i == 0:
                d[i] += 1
                t //= i
            else:
                break
    if t != 1:
        cnt *= alg_duplicate_combination_mod(n, v, od)
        cnt %= mod
    print(cnt)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import collections


def alg_duplicate_combination_mod(n, r, mod):
    n = n + r - 1
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    t = m
    d = collections.defaultdict(int)
    for i in range(2, int(t ** 0.5) + 1):
        while True:
            if t % i == 0:
                d[i] += 1
                t //= i
            else:
                break
    if t != 1:
        d[t] += 1
    cnt = 1
    for k, v in d.items():
        cnt *= alg_duplicate_combination_mod(n, v, mod)
        cnt %= mod
    print(cnt)


if __name__ == '__main__':
    solve()
n,m = map(int,input().split())
a = [list(input())for i in range(n)]
b = [list(input())for i in range(m)]
count = 0
for x in range (m):
    #print(x)
    for y in range(n-m):
        #print(y)
        for z in range(n-m):
            if b[x] == a[y][z:(z+m)]:
                for p in range(m):
                    if b[x+p] == a[y+p][z:(z+m)]:
                        count += 1
                        if count == m:
                            print("Yes")
                            exit()
else:
    print("No")

### FIXED CODE ###

n,m = map(int,input().split())
a = [list(input())for i in range(n)]
b = [list(input())for i in range(m)]
for y in range(n-m+1):
    for z in range(n-m+1):
        count = 0
        for p in range(m):
            if b[p] == a[y+p][z:(z+m)]:
                count += 1
                if count == m:
                    print("Yes")
                    exit()
            else:
                count = 0
print("No")
n,k=input().split(" ")
n,k_int=map(int,n,k)
if k==1:
    return 0
else:
    return n-k

### FIXED CODE ###

n,k= [int(i) for i in input().split()]
if k==1:
    print (0)
else:
    print (n-k)
n = int(input())
p = [input() for i in range(n)]
max_value = p.index(max(p))
p[max_value] = int(p[max_value]) / 2
sum = 0
for i in range(len(p)):
    sum += int(p[i])
print(sum)


### FIXED CODE ###

ChrismasDay = 25
text = "Christmas"
D = int(input())
D = 25 - D
for i in range(D):
    text = text + " Eve"
print(text)
x = input().split()
 
a = x[0]
b = x[1]
 
if a > b * 2:
  print(a - b * 2)
else:
  print(0)

### FIXED CODE ###

x = input().split()
 
a = int(x[0])
b = int(x[1])
 
if a > b * 2:
  ret = a - b * 2
else:
  ret = 0
  
print(ret)
N=int(input())
X=list(map(int,input().split()))
ans=[]
for i in range(min(X),max(X)):
    goukei = 0
    for j in range(len(X)):
        goukei+=(X[j]-i)**2
    ans.append(goukei)
print(min(ans))



### FIXED CODE ###

N=int(input())
X=list(map(int,input().split()))
ans=[]
for i in range(max(X)+1):
    goukei = 0
    for j in range(N):
        if i%1==0:
            goukei+=(X[j]-i)**2
    ans.append(goukei)
kotae=set(ans)
print(min(kotae))
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
c = 0
while K > 0:
    if not A == [] and not B == []:
        if A[0] >= B[0]:
            K = K - A[0]
            A.remove(A[0])
            if K >= 0:
                c += 1
        else:
            K = K - B[0]
            B.remove(B[0])
            if K >= 0:
                c += 1
    if A == []:
        K = K - B[0]
        B.remove(B[0])
        if K >= 0:
            c += 1
    if B == []:
        K = K - A[0]
        A.remove(A[0])
        if K >= 0:
            c += 1
print(c)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for j in range(M):
    b.append(b[j] + B[j])

ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j = j -1
    ans = max(ans, i+j)
    
print(ans)
S = input()
T = input()

N = len(S)
M = len(T)

ans = 'UNRESTORABLE'
for i in range(N-M,-1,-1):
    b = True
    for j in range(M):
        if S[i+j] == '?' or S[i+j] == T[j]:
            continue
        b = False
    if b:
        ans = S[:i] + T + S[i+j+1:]
        break
ans = list(ans)
for i in range(N):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))


### FIXED CODE ###

S = list(input())
T = list(input())
lenS = len(S)
lenT = len(T)
change = 0
for i in range(lenS-lenT,-1,-1):
    a = 1
    for j in range(lenT):
        if S[i+j] != T[j] and S[i+j] != '?':
            a = 0
    if a == 1:
        for j in range(lenT):
            S[i+j] = T[j]
        change = 1
        break

for i in range(lenS):
    if S[i] == '?':
        S[i] = 'a'

if change == 1:
    print(''.join(S))
else:
    print('UNRESTORABLE')
input_data = [int(i) for i in input().split(" ")]

if input_data[0] == 1:
    print("Hello World")
    exit()

print(input_data[1] + input_data[2])


### FIXED CODE ###

if int(input()) == 1:
    print("Hello World")
else:
    print(int(input()) + int(input()))
n=int(input())
p=[int(input()) for _ in range(n)]
dp=[0]*(n+10)
for i in p:
  dp[p]=dp[p-1]+1
print(n-max(dp))


### FIXED CODE ###

n=int(input())
p=[int(input()) for _ in range(n)]
dp=[0]*(n+10)
for i in p:
  dp[i]=dp[i-1]+1
print(n-max(dp))
def com(n):
    return n*(n-1)//2
ans=0
n=int(input())
a=list(map(int,input().split()))
coun=[0]*n
for i in range(n):
    coun[a[i]]+=1
for i in range(n):
    ans+=com(coun[i])
for i in range(n):
    m=com(coun[a[i]]-1)
    o=com(coun[a[i]])
    print(ans-o+m)

### FIXED CODE ###

import collections
N=int(input())
lst=input().split()
s=0
dic=collections.Counter(lst)
for i in dic.values():
    s+=(i*i-i)//2
for i in lst:
    print(s+1-dic[i])
s = input()
K = int(input())
ans = ''
alphas = {'a':0,'b':25,'c':24,'d':23,'e':22,'f':21,'g':20,'h':19,'i':18,'j':17,'k':16,'l':15,'m':14,'n':13,'o':12,'p':11,'q':10,'r':9,'s':8,'t':7,'u':6,'v':5,'w':4,'x':3,'y':2,'z':1}
a = 'abcdefghijklmnopqrstuvwxyz'
dict1 = {}
dict2 = {}
i = 1
while i <= 26:
  dict1[i] = a[i-1]
  dict2[a[i-1]] = i
  i += 1
for chara in s:
  if alphas[chara] <= K:
    ans = ans + 'a'
    K = K - alphas[chara]
  else:
    ans = ans + chara
K = K%26
ans = ans[:-1]+dict1[(dict2[ans[-1]]+K)%26]
print(ans)

### FIXED CODE ###

s = input()
K = int(input())
ans = ''
alphas = {'a':0,'b':25,'c':24,'d':23,'e':22,'f':21,'g':20,'h':19,'i':18,'j':17,'k':16,'l':15,'m':14,'n':13,'o':12,'p':11,'q':10,'r':9,'s':8,'t':7,'u':6,'v':5,'w':4,'x':3,'y':2,'z':1}
a = 'abcdefghijklmnopqrstuvwxyz'
dict1 = {}
dict2 = {}
i = 1
while i <= 26:
  dict1[i%26] = a[i-1]
  dict2[a[i-1]] = i
  i += 1
for chara in s:
  if alphas[chara] <= K:
    ans = ans + 'a'
    K = K - alphas[chara]
  else:
    ans = ans + chara
K = K%26
if len(ans)>=2:
  ans = ans[:-1]+dict1[(dict2[ans[-1]]+K)%26]
else:
  ans = dict1[(dict2[ans]+K)%26]
print(ans)
a,b,c = input().split()

int(sum) = 1
if a == b:
    sum +=1
if a == c:
    sum +=1
if b == c:
    sum += 1
print(sum)

### FIXED CODE ###

import collections

pen = list(map(str,input().split()))

print(len(collections.Counter(pen)))
A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if A >= B
    if A + V * T >= B + W * T:
        print('YES')
    else:
        print('NO')
else:
    if V >= W:
        print('NO')
    elif A + V * T >= B + W * T:
        print('YES')
    else:
        print('NO')

### FIXED CODE ###

A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if A <= B:
    if A + V * T >= B + W * T:
        print('YES')
    else:
        print('NO')
else:
    if A - V * T <= B -  W * T:
        print('YES')
    else:
        print('NO')
n = int(input())
x = range(n)
P =[]
s = 0
for _ in x:P += [[int(i) for i in input().split()]]
P+=P[0]
for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

### FIXED CODE ###

x=range(int(input())-1,-1,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j+1][1]*P[j][0]-P[j][1]*P[j+1][0]
print(_*0.5)
#a = []
while (True):
    b = list(map(int, input().split(" ")))
    #print(b)
    if(b == ['']): break
    #a.append(b)
    c = 1
    d = b[0] + b[1]
    while(d >= 10):
        c += 1
        d = d / 10
    print(c)


### FIXED CODE ###

# 何行あるかわからない入力をまとめて処理する
import sys
line = sys.stdin.readlines()
#print(line)
for i in line:
    # map関数は配列の型を一括変換するのに便利
    b = list(map(int, i.split(" ")))
    c = 1
    d = b[0] + b[1]
    while(d >= 10):
        c += 1
        d = d / 10
    print(c)