peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def main():
    N, M = list(map(int, input().split(' ')))
    N, M = min([N, M]), max([N, M])
    if N == 1:
        if M == 1:
            print(1)
        elif M == 2:
            print(0)
        else:
            print(M - 2)
    elif N == 2:
        print(0)
    else:
        print((N - 2) * (M - 2))


if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import Counter
n = int(input())
A = Counter(list(map(int, input().split())))
E = [0, 0]
for k, v in A.items():
    if v>=2:
        E.append(k)
    if v>=4:
        E.append(k)
E.sort()
print(E[-1]*E[-2])
# Judge status: Accepted
a,b,k=map(int,input().split())
for i in range(a,min(a+k,b+1)):
    print(i)
for i in range(max(a+k,b-k+1),b+1):
    print(i)
# Judge status: Accepted
s=[input() for i in range(3)]
l=[len(s[i]) for i in range(3)]
abc=[0,0,0]
now=0

while abc[now]!=l[now]:
    s_sub=s[now][abc[now]]
    abc[now]+=1
    now=(0 if s_sub=="a" else 1 if s_sub=="b" else 2)
    
print("A" if now==0 else "B" if now==1 else "C")
# Judge status: Accepted
a,b=map(int,input().split())
if a>8 or b>8:
    print(":(")
else:
    print("Yay!")
# Judge status: Accepted
def gcd(a,b):
    if a%b==0:
        return b
    return gcd(b,a%b)

A,B = map(int,input().split())
print((A*B)//gcd(A,B))
# Judge status: Wrong Answer
def main():
    s=input()
    li=[]
    for i in range(len(s)):
        if(s[i]!='B'):
            li.append(s[i])
        else:
            if(len(li)!=0):
                li.pop()
    for i in range(len(li)):
        print(i,end='')

main()
# Judge status: Accepted
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
XYC = [input().split() for _ in range(M)]
ans = min(a) + min(b)
for x, y, c in XYC:
  discount_price = a[int(x) - 1] + b[int(y) - 1] - int(c)
  ans = min(ans, discount_price)
print(ans)
# Judge status: Accepted
# 日立製作所 社会システム事業部 プログラミングコンテスト2020: B – Nice Shopping
A, B, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(j) for j in input().split()]
x, y, c = [], [], []
for k in range(M):
    tmp = [int(i) for i in input().split()]
    x.append(tmp[0])
    y.append(tmp[1])
    c.append(tmp[2])

prices = []

prices.append(min(a) + min(b))

for k in range(M):
    prices.append(a[x[k] - 1] + b[y[k] - 1] - c[k])

print(min(prices))
# Judge status: Accepted
A, B, C = map(int,input().split())
if (C>=A) and (C<=B):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
num=int(input())
i=0
while num>=2*int(i):
	i=i+1
print(i)
# Judge status: Accepted
h1, m1, h2, m2, k = map(int, input().split(" "))
print( ((h2-h1)*60+m2-m1)-k )
# Judge status: Accepted
def main():
    a, b, c = map(int, input().split())
    if a <= c and c <= b:
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if i+1 == P[i]:
        P[i], P[i+1] = P[i+1], P[i]
        ans += 1

print(ans)
# Judge status: Accepted
M,N = map(int,input().rstrip().split(" "))
if N != 0:
    A = set(map(int,input().rstrip().split(" ")))
    ans = -100
    sa = 10 ** 5
    for i in range(-1,102):
        if not i in A:
            if sa > abs(M - i):
                sa = abs(M - i)
                ans = i
    print(ans)
else:
    print(M)
# Judge status: Accepted
import collections
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
q=int(input())
x=collections.Counter(a)
for _ in range(q):
  b,c=map(int,input().split())
  s=s-x[b]*b+x[b]*c
  print(s)
  x[c]+=x[b]
  x[b]=0
# Judge status: Accepted
a = int(input())
if a % 2 == 1:
  print((a+1)/2/a)
else:
  print(0.5)
# Judge status: Accepted
N = int(input())
A = []
B = []
for _ in range(N):
    temp = int(input())
    A.append(temp)
    B.append(temp)

B.sort(reverse=True)
max_first = B[0]
max_second = B[1]

for i in range(N):
    if A[i] == max_first:
        print(max_second)
    else:
        print(max_first)
# Judge status: Accepted
s = int(input())
MOD = 10**9 + 7
memo = [[0]*(s+1) for _ in range(s//3 + 1)]
flag = True
if s <= 2: flag = False

if flag:
    memo[1] = [0] * 3 + [1] * (s-2)

    for i in range(2, s//3 + 1):
        for j in range(3*i-3, s+1):
            memo[i][j] = memo[i][j-1] + memo[i-1][j-3]

    ans = 0
    for i in range(s//3 + 1):
        ans += memo[i][s]
        ans %= MOD
    print(ans) 
else: print(0)
# Judge status: Wrong Answer
s = input()
days = {
	"SUN" : 0, "MON": 6, "TUE": 5, "WED": 4, "THU" : 3, "FRI" : 2,  "SAT": 1
}
print(days[s])
# Judge status: Accepted
s = input()
k = int(input())

L = []
for i in range(len(s)):
    L.append((ord("z")-ord(s[i])+1))

ans = ""
i = 0
while i < len(s):
    if s[i] == "a":
        ans +="a"
        i +=1
    elif k-L[i] >= 0:
        ans +="a"
        k -=L[i]
        i +=1
    else:
        ans +=s[i]
        i +=1
k = k%26
ans = ans[:-1] + chr(ord(ans[-1]) + k)
print(ans)
# Judge status: Wrong Answer
n = int(input())
m = str(input())
if m[:n//2] == m[n//2:]:
	print("yes")
else:
	print("No")
# Judge status: Accepted
abc=list(map(int,input().split()))
print(len(set(abc)))
# Judge status: Accepted
n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
for i, v in enumerate(p):
    x, y = v
    p[i] = x-y, x+y

xm, ym = -10**9, -10**9
xw, yw = 10**9, 10**9
for x, y in p:
    xm = max(xm, x)
    xw = min(xw, x)
    ym = max(ym, y)
    yw = min(yw, y)

# print(p)
ans = max(abs(xm - xw), abs(ym - yw))
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
box_l=[1]*n
red_l=[0]*n
red_l[0]=1

for i in range(m):
	x,y=map(int,input().split())
	x-=1
	y-=1
	if red_l[x]==1:
		red_l[y]=1
		if box_l[x]==1:
			red_l[x]=0
	box_l[x] -= 1
	box_l[y] += 1
print(sum(red_l))
# Judge status: Wrong Answer
import numpy as np

a = [list(map(int,input().split())) for _ in range(3)]

n = int(input())

b = list([int(input()) for _ in range(n)])

c = [[0]*3]*3

for k in b:
    for i in range(3):
        for j in range(3):
            if k == a[i][j]:
                c[i][j]=1

c = np.array(c)

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([c[i,i] for i in range(3)])==3) or (c[2,0]+c[1,1]+c[0,2]==3):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x = int(input())

ans = 0
r = 1.01
ret = 100
while( x - ret > 0 ):
  ret = int( ret * r )
  ans += 1
print( ans )
# Judge status: Accepted
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
li = [0]*m
for _ in range(n):
  for i in rl()[1:]:
    li[i-1]+=1
print(sum([i==n for i in li]))
# Judge status: Accepted
N = int(input())
a =list(map(int,input().split()))
b=[]

for i in range(N):
    a1 = i % 2
    a2 = a[i] % 2
    if (a1==0 and a2==1):
        b.append(i)
print(len(b))
# Judge status: Wrong Answer
import numpy as np

def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort(reverse=True)
    return a

N,M = map(int,input().split())
f = factorization(M)
for i in f:
    if i <= M/N:
        print(i)
        exit()
# Judge status: Accepted
def resolve():
  a, b, c, k = map(int, input().split())
  if k % 2 == 0:
    print(a-b)
  else:
    print(b-a)
  return

if __name__ == "__main__":
  resolve()
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,input().split()))
a.sort()
print(sum(a[N:2*N]))
# Judge status: Wrong Answer
a=int(input())
b=int(input())
h=int(input())

s=(a+b)*h/2

print(s)
# Judge status: Accepted
a,b = map(int,input().split())
if (a*b) % 3 == 0 or (a+b) % 3 == 0:
  print('Possible')
else:
  print('Impossible')
# Judge status: Accepted
a, b = map(int, input().split())

diff = b - a
alen = ((diff-1) * diff) // 2
print(alen - a)
# Judge status: Accepted
n = input()

def sumdigits(num):
  cc = 0
  for c in num:
    cc += int(c)
  return cc

if all([s == '9' for s in n]):
  print(9 * len(n))
else:
  print(max(9 * (len(n) - 1) + int(n[0]) - 1, sumdigits(n)))
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
ans = 0
count = 1
num = A[0]
for i in range(1, N):
    if A[i] == num:
        count += 1
    else:
        if count % 2 == 1:
            ans += 1
        num = A[i]
        count = 1
print(ans)
# Judge status: Accepted
l=list(map(int,input().split()))

if(l[0]==l[1]+l[2]):
    print("Yes")
elif(l[1]==l[0]+l[2]):
    print("Yes")
elif(l[2]==l[0]+l[1]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,m=map(int,input().split())
if n==1 and m==1:
  print(1)
elif n==1 and m!=1:
  print(m-2)
elif m==1 and n!=1: 
  print(n-2)
elif n==2:
  print(0)
elif n>3:
  print((m-2)*(n-2))
# Judge status: Wrong Answer
import numpy as np
import math

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

aList = [int(input()) for _ in range(M)]

trg = np.ones(N+1, dtype = np.int64)
dp = np.zeros(N+1, dtype = np.int64)

for a in aList:
    trg[a] -= 1

for i in range(1, N+1):
    if(i <= 2):
        dp[i] = 1 * trg[i]
    
    else:
        dp[i] = (dp[i-1] + dp[i-2]) * trg[i]

print(dp[N] % 1000000007)
# Judge status: Wrong Answer
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
  
A, B, K = map(int, input().split())
ans = list(reversed(list(set(divisor(A)) & set(divisor(B)))))
print(ans[K-1])
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

A = list(map(int, input().split()))

neg_cnt = 0
minimum = 10**10
for num in A:
    minimum = min(minimum, abs(num))
    if num < 0:
        neg_cnt += 1
        

print(minimum)
ans = 0
for num in A:
    if num < 0:
        ans += -num
    else:
        ans += num 

print(ans)
print(neg_cnt)
if neg_cnt % 2 == 0:
    print(ans)               
else:
    print(ans - minimum * 2)
# Judge status: Wrong Answer
code = list(input())
status = False
for x in range(1, len(code)):
  if code[x] == code[x-1]:
    print("Bad")
    status = True
if status == False:
  print("Good")
# Judge status: Wrong Answer
D=int(input())
*c,=map(int,input().split())
# for Greedy
ci=[(c[i-1],i) for i in range(1,27)]
ci=[(0,0)]+ci
# ci=[(0,0)]+sorted(ci,reverse=True)

last=[[0]*27]*(D+1)
S=[[0]*27]*(D+1)
DP=[[0]*27]*(D+1)
T=[0]*(D+1)
for d in range(1,D+1):
    *S[d],=map(int,input().split())
    S[d]=[0]+S[d]
import random
TI=26
Ts=random.sample(range(1,27),k=TI)
for t in Ts:
  print(t)
# Judge status: Accepted
import math

N, D = map(int, input().split())
poses = []
for i in range(N):
    pos = [num for num in map(int, input().split())]
    poses.append(pos)
count = 0
for pos in poses:
    kyori = math.sqrt(pos[0]**2 + pos[1]**2)
    if kyori <= D:
        count += 1

print(count)
# Judge status: Accepted
n = int(input())
s = input()

white_to_red = 0
red_to_white = s.count('R')

ans = red_to_white
for i in range(n):
    if s[i] == 'W':
        white_to_red += 1
    else:
        red_to_white -= 1
    ans = min(ans, max(white_to_red, red_to_white))

print(ans)
# Judge status: Accepted
N=int(input())
x=(N+1)//2
print(x/N)
# Judge status: Wrong Answer
import copy

n = int(input())
x = list(map(int,input().split()))

xx= sorted(x)
L_x = xx[n//2 - 1]
R_x = xx[n//2]

for arr in x:
  print(L_x if L_x >= arr else R_x)
# Judge status: Accepted
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N = i()
K = i()
X = i()
Y = i()
print(N*X-max(0,N-K)*(X-Y))
# Judge status: Wrong Answer
x, y = map(int, input().split())

z = x+y/2
print(z)
# Judge status: Accepted
S = input()
k = 'keyence'

for i in range(len(S)):
    for j in range(i, len(S)):
        # print(S[:i] + S[j:])
        if S[:i] + S[j:] == k:
            print('YES')
            exit()
print('NO')
# Judge status: Accepted
import math
h,w = map(int,input().split())
if h%2 == 0:
    print(h//2 * w)
elif h==1 or w == 1:
    print(1)
else:
    tmp1 = math.floor(h/2)
    tmp2 = math.ceil(h/2)
    buf = math.floor(w/2)
    print(tmp2 * (w-buf) + tmp1 * (buf))
# Judge status: Accepted
import re

S = input()
Sa = S.replace("?", "a")
Sd = S.replace("?", ".")
T = input()

word_L = []
for i in range(len(S)-len(T)+1):
  if re.match(Sd[i:i+len(T)], T) is not None:
    s = Sa[:i] + T + Sa[i+len(T):]
    word_L.append(s)

ans = "UNRESTORABLE"
if word_L:
  ans = sorted(word_L)[0]
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
a,b,c=sorted([a,b,c])
if (a,b,c)==(5,5,7):print('YES')
else:print('NO')
# Judge status: Accepted
S = int(input())
ans = [0, 0, 1, 10 ** 9]
if S % (10 ** 9) == 0:
    ans.extend([S // (10 ** 9), 0])
else:
    ans.extend([S // (10 ** 9) + 1, 10 ** 9 - S % (10 ** 9)])
print(' '.join([str(a) for a in ans]))
# Judge status: Accepted
#ABC130 C-Rectangle Cutting 14:59

W,H,x,y = map(int, input().split())

def func(W,H,x,y):
    if x* 2 == W and y*2 == H:
        return W*H/2, 1
    else:
        return W*H/2, 0
print(*func(W,H,x,y))
# Judge status: Accepted
s = input()
s_len = len(s)
check = s[0]
if s_len == 2 and s[0] != s[1]:
    print(2)
    exit()
s = s+"1"
ind = 0
ans = 1
for i in range(1,s_len):
    if check == s[ind+1]:
       check = s[ind+1:ind+3]
       ind += 1
    else:
       check = s[ind+1]
    ind += 1
    ans += 1
    if ind >= s_len-1:
        break
if ind == s_len and s[s_len-1] == s[s_len-2]:
    ans -= 1
print(ans)
# Judge status: Accepted
n,Q=map(int,input().split())
s=input()

a=[0]*(n+1)
for i in range(2,n+1):
    if s[i-2]=='A' and s[i-1]=='C':
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]

for i in range(Q):
    l,r=map(int,input().split())
    print(a[r]-a[l])
# Judge status: Accepted
K, X = map(int, input().split())
ans = []
num = X - K
for i in range(K*2-1):
    num += 1
    ans.append(num)
print(*ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    l = len(S)
    if l % 2 != 0:
        print('No')
    elif S.count('hi') == l // 2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

pre = 1
for i in range(K-1):
    pre *= A[i]

for k in range(K, N):
    score = (pre * A[k]) // A[k-K]
    if score > pre:
        print("Yes")
    else:
        print("No")
    pre = score
# Judge status: Accepted
n = int(input())
s = input()
t = input()

ans = len(s) + len(t)
for i in range(1,n+1):
  if s[-i:] == t[:i]:
    ans = 2*n - i
    
print(ans)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
b = [(i * ai) % 2 for i, ai in enumerate(a)]
print(sum(b))
# Judge status: Accepted
import bisect
from collections import deque
def LIS(a):
    lis = deque()
    lis.append(-1)
    for i in range(len(a)):
        index = bisect.bisect_left(lis,a[i])
        if index == 0:
            lis.appendleft(a[i])
        else:
            lis[index-1] = a[i]
    return len(lis)

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    print(LIS(a))

if __name__ == "__main__":
    main()
# Judge status: Accepted
n=int(input())

if n < 1000:
    print("ABC")
else:
    print("ABD")
# Judge status: Accepted
#!/usr/bin/env python3
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    mod = 10 ** 9 + 7
    if n == 1:
        print(0)
    elif n == 2:
        print(2)
    else:
        print((pow(10, n, mod) - pow(9, n, mod) * 2 + pow(8, n, mod)) % mod)


if __name__ == '__main__':
    main()
# Judge status: Accepted
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]
# print(xyc)
cost = []
cost.append(min(a) + min(b))
for x, y, c in xyc:
    tmp = a[x - 1] + b[y - 1] - c
    cost.append(tmp)
print(min(cost))
# Judge status: Wrong Answer
N = int(input())
X = list(map(int, input().split()))
ans = 0
for i in range(1, N+1):
  k = []
  for a in X:
    k.append((a-i)**2)
  if i==1:
    ans = sum(k)
  if ans>sum(k):
    ans = sum(k)
print(ans)
# Judge status: Accepted
a = []
for _ in range(3):
    a += list(map(int, input().split()))
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a:
        i = a.index(b)
        a[i] = 0
if sum(a[0:3]) == 0 or sum(a[3:6]) == 0 or sum(a[6:]) == 0 \
    or sum(a[0::3]) == 0 or sum(a[1::3]) == 0 or sum(a[2::3]) == 0 \
    or sum(a[0::4]) == 0 or sum(a[2:7:2]) == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from heapq import heappop, heappush

k = int(input())
ten = [[0,1]] + [[i-1, i, i+1] for i in range(1,9)] + [[8,9]]

cnt = 0
heap = []
for i in range(1, 10):
    heappush(heap, [i, i])

memo = set()
while heap or cnt < 20:
    num,pre = heappop(heap)
    if num in memo or num < 1:
        continue
    else:
        memo.add(num)
    cnt += 1
    # print(num,pre)
    if cnt >= k:
        print(num)
        break
    for i in ten[pre]:
        heappush(heap, [num*10+i, i])
# Judge status: Wrong Answer
n,m=map(int,input().split())
lst=[int(input()) for i in range(m)]
DP=[0]*(n+1)
temp=0
DP[0]=1
DP[1]=1
for i in range(1, n+1):
  if i in lst:
    DP[i]=0
  else:
    DP[i]=(DP[i-1]+DP[i-2])%(10**9+7)
print(DP[n])
# Judge status: Accepted
import math
def main():
  x = int(input())
  sum=0
  if x==0 or x==1:
    sum=x
  else:
    for i in range(2,int(math.sqrt(x))+1):
      j=2
      while True:
        if pow(i,j) <= x:
          if pow(i,j) > sum:
            sum=pow(i,j)
        else:
          break
        j+=1
  print(sum)
main()
# Judge status: Wrong Answer
s= str(input())
print('A' + ''+ s[0] + '' +'C')
# Judge status: Accepted
s=int(input())
s1=s//100
s2=s%100
if 12>=s1>=1 and 12>=s2>=1:
    ans="AMBIGUOUS"
elif 12>=s1>=1 and not 12>=s2>=1:
    ans="MMYY"
elif 12>=s2>=1 and not 12>=s1>=1:
    ans="YYMM"
else:
    ans="NA"
print(ans)
# Judge status: Wrong Answer
N=int(input())
C=list(map(int,input().split()))
ans=[0]*(N-1)
for i in range(1,N+1):
  ans.insert(C[i-1],str(i))
for _ in range(N-1):
  ans.remove(0)
ans=' '.join([str(n) for n in ans])
print(ans)
# Judge status: Wrong Answer
inpo=input().split()
for i in inpo:
  if i=="B":
    print("R",end="")
  elif i=="R":
    print("B",end="")
  else:
    print(i,end="")
# Judge status: Accepted
a = input()
x = [a[i:i+1] for i in range(len(a))]

b = input()
y = [b[i:i+1] for i in range(len(b))]
n=0
for i in range(len(x)):
    n = n+1
    if x[i] != y[i]:
        print("No")
        break

if n == len(a) and x[len(a)-1]==y[len(a)-1]:
    print("Yes")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
aabs = [i if i>=0 else i*(-1) for i in a]
MIN = min(aabs)
ans = 0
mcount = 0

for i in range(n):
  if a[i] < 0:
    mcount += 1
    
if mcount%2 == 0:
  for i in a:
    ans += abs(i)
    print(ans)
else:
  for i in a:
    ans += abs(i)
  print(ans - 2*MIN)
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))
LM = max(L)
L.remove(LM)
print('Yes' if LM < sum(L) else 'No')
# Judge status: Wrong Answer
a=int(input())
print(a+a**2)
# Judge status: Accepted
n = int(input())
for i in range(n,1000):
    arr = list(str(i))
    s = list(set(arr))
    if len(s) == 1:
        print(i)
        break
# Judge status: Accepted
no = "abcdefghijklmnopqrstuvwxyz"

def main():
    N = int(input())
    ans = ""
    while N > 0:
        N -= 1
        ans += no[N % 26]
        N //= 26
    return ans[::-1]

if __name__ == '__main__':
    print(main())
# Judge status: Accepted
s = list(input())
k = int(input())
abc = "abcdefghijklmnopqrstuvwxyz"
c = 0
for e,i in enumerate(s):
    # print(26-abc.index(i))
    if k-26+abc.index(i)>=0 and i!='a':
        s[e] = 'a'
        k-=26-abc.index(i)
    # print(k)  
k+=abc.index(s[-1])
k%=26
s[-1] = abc[k]

print("".join(s))
# Judge status: Accepted
N = int(input())
A = []
B = []
for i in range(N):
  A.append(int(input()))
  
A.sort()
B.append(1)

for i in range(1, N):
  if(A[i]!= A[i- 1]):
    B.append(1)
  else:
    B[-1]+= 1
  i+= 1
  
ans = list(filter(lambda x: x % 2 == 1, B))

print(len(ans))
# Judge status: Accepted
import sys
#N = I()
#A = [LI() for _ in range(N)]

a, b = list(map(int,sys.stdin.readline().rstrip().split()))

if a > 0:
    print('Positive')
elif a <= 0 and b >= 0:
    print('Zero')
else:
    if (a+b)%2 == 0:
        print('Negative')
    else:
        print('Positive')
# Judge status: Wrong Answer
a,b,c = list(map(int, input().split()))
print((a * b) / 2)
# Judge status: Accepted
n, l = map(int, input().split())
s = sorted([input() for i in range(n)])
ans = ""
for i in s:
    ans += i
print(ans)
# Judge status: Wrong Answer
list = input()
#print(list[2])
#print(len(list))
cnt = 0
for n in list:
  #print(n)
  if n == "R":
    cnt+=1
print(cnt)
# Judge status: Accepted
import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
n = II()
print(n+n**2+n**3)
# Judge status: Wrong Answer
import math

target = int(input()) # 目標金額
have = 100 # 手持ちの金額（100円スタート）
years = 0 # 何年かかるか

while have <= target:
    #print(have, years)
    have = math.floor(have * 1.01)
    years += 1

print(years)
# Judge status: Accepted
import numpy as np
n = int(input())
a = np.array(tuple(map(int, input().split())))
b = len(np.where(a < 0)[0])
a = abs(a)
if b % 2 == 0:
    print(np.sum(a))
else:
    print(np.sum(a) - 2 * np.min(a))
# Judge status: Wrong Answer
n,m,x,y = map(int,input().split())
d = "War"
l_x = sorted(list(map(int,input().split())))[::-1]
l_y = sorted(list(map(int,input().split())))
for i in range(x,y+1):
  if l_x[0]<=i and l_y[0]>=i:
    d = "No War"
    break
print(d)
# Judge status: Accepted
s=input()
print('No') if 'L' in s[::2] or 'R' in s[1::2] else print('Yes')
# Judge status: Wrong Answer
n, m = map(int, input().split())
mod = 10**9+7

if abs(n - m) >= 2:
   print(0)
   exit()

import math

minx = min(n, m)
x = math.factorial(minx) % mod

if n == m:
   print(2*pow(x,2,mod)%mod)
else:
   print(pow(x,2,mod)*(x+1)%mod)
# Judge status: Wrong Answer
N, K = map(int, input().split())
p = list(map(int, input().split()))
ansmax = 0
for i in range(N-K+1):
  ans = 0
  for j in range(K):
    ans += (p[i+j]+1)/2
  print(ans)
  if(ansmax < ans):
    ansmax = ans
print(ansmax)
# Judge status: Accepted
n,p=int(input()),list(map(int,input().split()))
k= n//2 if n%2==0 else n//2+1
a,b=list(range(0,k)),list(range(k-1,n))[::-1]
c=[]
for x,y in zip(a,b):
  c.append(x)
  c.append(y)
c= c if n%2==0 else c[:-1]
c=c[::-1]
l=list([])
for x,y in zip(c,list(range(n))):
  l.append([x,y])
l=sorted(l)
for i in range(n):
  print(p[l[i][1]],end=" ")
# Judge status: Accepted
def half_and_half(a,b,c,x,y):
    z = x   if x > y else y
    can = []
    
    for n in range(z+1):
        p = x - n if x > n else 0
        q = y - n if y > n else 0
        amount = p*a + q*b + n*c*2
        #print("%d = %d x %d + %d x %d + %d x %d " %(amount,p,a,q,b,n,c))
        can.append(amount)

    return min(can)

if __name__ == '__main__':
    a,b,c,x,y = map(int,input().split())
    print(half_and_half(a,b,c,x,y))
# Judge status: Accepted
a, b, c = map(int, input().split())

s = set()
for i in range(1, b + 1):
    aa = a * i
    amari = aa % b
    if amari in s:
        break
    s.add(amari)

if c in s:
    print('YES')
else:
    print('NO')