peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
o="RUD"
g="LUD"

s=input()

i=0
while i<len(s):
  if i%2==0:
    if s[i] =="R":
      print("No")
      exit()
    elif s[i]=="L":
      print("No")
      exit()
  i+=1
  
print("Yes")
# Judge status: Accepted
from math import *

a, b, x = map(int, input().split())

if a*a*b <= x*2:
  v = a*a*b - x
  print(degrees(atan(2*v/a**3)))
else:
  print(degrees(atan(a*b**2/2/x)))
# Judge status: Accepted
a = input()
c_zero = 0
c_one = 0
for digit in a:
    if digit == '0':
        c_zero += 1
    else:
        c_one += 1
print(min(c_one, c_zero) * 2)
# Judge status: Wrong Answer
import math
n, a, b = map(int,input().split())
score = 1
total = 0
for i in range(1,a):
  score = score * (n-i+1) // i
  total += score
score = score * (n-a+1)//a
for j in range(a,b):
  score =score * (n-j+1) // j
  total += score
score =score * (n-b+1) // b
for k in range(b,n//2 +1):
  score = score * (n-k+1) // k
  total += score
  if n % 2 == 1:
    total += score * (n-n//2) // (n//2 + 1)
print(total % (10**9 + 7))
# Judge status: Accepted
def solve(s, t, a, b, u):
    t = s == u
    return "%d %d" % (a - t, b - 1 + t)

s, t = input().split()
a, b = map(int, input().split())
u = input()
print(solve(s, t, a, b, u))
# Judge status: Accepted
a,b,c=map(int,input().split())
x = a*100+b*10+c
if not x%4:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
from copy import deepcopy
def main():
    N = int( input())
    if N == 1:
        print('a')
        return
    ANS = ['a']
    for _ in range(N-1):
        G = deepcopy(ANS)
        ANS = []
        for t in G:
            ANS.append(t+'a')
            ANS.append(t+'b')
    print('\n'.join(ANS))
if __name__ == '__main__':
    main()
# Judge status: Accepted
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

for i in range(D):
    print(i % 26 + 1)
# Judge status: Accepted
D,T,S=map(int,input().split())
m=D/S
if m<=T:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
line_1 = input().split()
N = int(line_1[0])
line_2 = input().split()
M = list(map(int,line_2))
 
Ms = sum(M)
 
if N-Ms > 0 :
  print(N-Ms)
else:
  print(-1)
# Judge status: Wrong Answer
def chk(nums):
  for i in nums:
    for ii in nums:
      if i == ii: return False
  return True
s = map(int, input().split())
if chk(s): print('YES')
else: print('NO')
# Judge status: Wrong Answer
a, b, c, k = map(int,input().split())

if a==b==c:
    print(0)
    exit()
    
for i in range(k):
    a_=b+c
    b_=a+c
    c_=a+b
    if abs(a_-b_) > 10**18:
        print('Unfair')
        exit()
    a=b+c
    b=a+c
    c=a+b

if k==0:
    print(a-b)
else:
    print(a_-b_)
# Judge status: Wrong Answer
a = [list(map(int,input().split()))for i in range(3)]
x = [10,0,0]
y = [0,0,0]

for i in range(3):
    y[i] = a[0][i]-x[0]

for i in range(3):
    x[i] = a[i][0]-y[0]

flag = True
print(y)
print(x)
for i in range(3):
    for j in range(3):
        if a[i][j] != x[i]+y[j]:
            flag=False

if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * n
for i in a:
  c[i - 1] += 1
print(sum(sorted(c, reverse=True)[k:]))
# Judge status: Accepted
a,b,c=map(int,input().split())
if a == b == c and a%2==0:
    print(-1)
else:
    na,nb,nc = 0,0,0
    cnt = 0
    while a%2==0 and b%2==0 and c%2==0:
        na = (b+c)//2
        nb = (c+a)//2
        nc = (a+b)//2
        cnt += 1
        a,b,c = na,nb,nc
    print(cnt)
# Judge status: Wrong Answer
S = input()
N = len(S)
print("Yes" if S[:(N-1)//2]==S[:(N-1)//2][::-1]else "No")
# Judge status: Wrong Answer
from sys import stdin

input = stdin.readline


def solve():
    s = input()
    if s[-1] == 's':
        print(s+'es')
    else:
        print(s+'s')


if __name__ == '__main__':
    solve()
# Judge status: Accepted
N=int(input())

m=[]
M=[]
for i in range(N):
    a,b=map(int,input().split())
    m.append(a)
    M.append(b)
m.sort()
M.sort()

if N%2==1:
    print(M[N//2]-m[N//2]+1)
else:
    M1=(M[N//2-1]+M[N//2])/2
    m1=(m[N//2-1]+m[N//2])/2
    print(int((M1-m1)*2+1))
# Judge status: Wrong Answer
s = list(input())
s = set(s)
s = sorted(s)
m = 'abcdefghijklmnopqrstuvwxyz'

for i in range(len(m)):
    if s[i] != m[i]:
        print(m[i])
        exit(0)

    if i + 1 != len(m) and i + 1 == len(s):
        print(m[i + 1])
        exit(0)

print('None')
# Judge status: Accepted
A, B = input().split()

a10 = int(''.join(list(reversed(A[0:2]))))
a34 = int(A[3:5])
if a10 < a34:
  amin = int(A[1:3]) + 1
else:
  amin = int(A[1:3])

b10 = int(''.join(list(reversed(B[0:2]))))
b34 = int(B[3:5])
if b10 <= b34:
  bmin = 100 - int(B[1:3]) - 1
else:
  bmin = 100 - int(B[1:3])

n0 = int(B[0]) - int(A[0]) + 1

print(n0 * 100 - amin - bmin)
# Judge status: Wrong Answer
N = int(input())
candies_i = list(map(int, input().split()))
candies_j = list(map(int, input().split()))

l = []
count = 0

for i in range(N):
    count+=1
    total_li = sum(candies_i[:count])
    total_lj = sum(candies_j[count:])
    total = total_li + total_lj
    l.append(total)

print(max(l))
# Judge status: Wrong Answer
N,A,B,C,D = map(int,input().split())
S = input()

if "##" in S[A-1:C] or "##" in S[B-1:D]:
  print("No")
elif C < D:
  print("Yes")
else:
  if "..." in S[B-2:D+2]:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
N, X = map(int, input().split())
L = list(map(int, input().split()))

D = 0
num = 1

while num <= N:
  D = D + L[num-1]
  if D > X:
    print(num)
    break
  num += 1
else:
  print(N+1)
# Judge status: Wrong Answer
X = int(input())

C = 0
P = 0
D = 0
L = 0
total = 0

if X >= 0 and X <= 10 ** 9:
    while True:
        if X > 500:
            C = X // 500
            P = 500 * C
            X = X - P
        elif X > 5:
            D = X // 5
            L = 5 * D
            X = X - L
        else:
            break

total = (1000 * C) + (5 * D)

print(total)
# Judge status: Accepted
def main():
    N = int(input())

    if N is 0:
        print(0)
        return

    ans = []  # 末尾の桁から
    while N:
        q, r = divmod(N, 2)
        ans.append(r)
        N = -q
    print(*reversed(ans), sep='')


if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
print(2**(math.floor(math.log2(int(input())))+1)-1)
# Judge status: Accepted
s = input()

ans = 1
t = s[0]
i = 1

while i < len(s)-1:
    if len(t) == 2:
        t = s[i]
        i += 1
    elif t == s[i]:
        t = s[i:i+2]
        i += 2
    else:
        t = s[i]
        i += 1
    ans += 1

if i == len(s)-1 and t != s[-1]:
    print(ans + 1)
else:
    print(ans)
# Judge status: Accepted
A,B = list(map(int,input().split()))
if A == 1 and B == 1:
    print("Draw")
elif A == 1:
    print("Alice")
elif B == 1:
    print("Bob")
elif A == B:
    print("Draw")
elif A > B:
    print("Alice")
else:
    print("Bob")
# Judge status: Wrong Answer
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    N,=pin()
    v=lispin()
    V=[v_*2 for v_ in v]
    V.sort()
    ans=V[0]
    for i in range(1,N):
        ans=(ans+V[i])//2
    print(ans/2)
    
resolve()
# Judge status: Accepted
import numpy as np

n = int(input())
a = input().split()
np_a=np.array(a, dtype=int)

ans=np.zeros(n, dtype=int)

all=np_a[0]
for i in range(1,n):
  all=all ^ np_a[i]
  

for i in range(0,n):
  ans[i]=all ^ np_a[i]
  
print (*ans)
# Judge status: Accepted
def is_kaibun(s):
    n = len(s)
    for i in range(n):
        if s[i] != s[n-1-i]:
            return False
    return True

def is_tsuyoi(s):
    n = len(s)
    if not is_kaibun(s):
        return False
    if not is_kaibun(s[:(n-1)//2]):
        return False
    if not is_kaibun(s[(n+3)//2-1:]):
        return False

    return True

S = input()

print('Yes' if is_tsuyoi(S) else 'No')
# Judge status: Accepted
N = int(input())
S = input()

list_str = ['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 = ''
for s in S:
  _ = list_str.index(s)
  next_index = _ + N
  if next_index >= 26:
    next_index =  next_index - 26
  ans += list_str[next_index]

print(ans)
# Judge status: Accepted
MOD = 10 ** 9 + 7

def inv(x):
  return pow(x, MOD - 2, MOD)


def gen_fact(n):
  fact = [1] * (n + 1)
  for i in range(2, n + 1):
    fact[i] = fact[i - 1] * i % MOD
  return fact


def binom(n, k, fact):
  assert 0 <= k <= n
  return fact[n] * inv(fact[k]) * inv(fact[n - k]) % MOD


def count(n, k, fact):
  n -= 3 * k
  return binom(n + k - 1, k - 1, fact)


if __name__ == '__main__':
  s = int(input())
  fact = gen_fact(s)
  res = 0
  for k in range(1, s // 3 + 1):
    res += count(s, k, fact)
  print(res % MOD)
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

import math

def lcm(x,y):
    return (x*y)//math.gcd(x,y)


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

print(lcm(x,y))
# Judge status: Accepted
s = input()

print(s.rfind("Z")-s.find("A")+1)
# Judge status: Wrong Answer
import numpy as np
from numpy import array


n, m, x = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

a = array(a)

c_min = 1e5 * n
flag = False

for i in range(1, n ** 2 + 1):
    b = np.zeros(m+1)

    for k in range(n):
        if ((i >> k) & 1):
            b += a[k]
    
    if np.all(b[1:] >= x):
        c_min = min(c_min, b[0])
        flag = True

if flag == False:
    c_min = -1

print(int(c_min))
# Judge status: Wrong Answer
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))

for i in range(1, N//2 + 1)[::-1]:
    wa = 0
    for j in range(2, N+1):
        if i * j > N:
            break
        wa += A[i*j]
    wa %= 2
    if A[i] == wa:
        A[i] = 0
    else:
        A[i] = 1


A = A[1:]
print(A.count(1))
for i, j in enumerate(A):
    if j == 1:
        print(i, end=' ')
# Judge status: Accepted
T = input()

for i, v in enumerate(T):
    if v == '?':
        print('D', end='')
    else:
        print(v, end='')
print('\n')
# Judge status: Accepted
w,h,x,y=map(int,input().split())
print(w*(h/2),1*(w/2==x and h/2==y))
# Judge status: Accepted
def Conv(x):
    return x * (x - 1) // 2

N, M = map(int, input().split())
print(Conv(N) + Conv(M))
# Judge status: Accepted
a,b,k=map(int,input().split())
ha=[i for i in range(a,a+k) if i<=b]
o=[i for i in range(b,b-k,-1) if i>=a]
wa=set(ha+o)
wa=sorted(list(wa))
for i in wa:
    print(i)
# Judge status: Accepted
def main4():
    lis = []
    n,k=map(int, input().split())
    for i in range(n):
        a,b = map(int, input().split())
        lis.append([a,b])
    lis.sort(key = lambda x:x[0])
    res = 0
    i=-1
    while(res < k):
        i+=1
        res += lis[i][1]
        if(res>=k):
            print(lis[i][0])
            break


if __name__ == '__main__':
    main4()
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
print((b - a) / x)
# Judge status: Accepted
s,w=map(int,input().split())
if w >= s:
    print('unsafe')
else:
    print('safe')
# Judge status: Accepted
from math import ceil

a = int(input())
print((ceil(a / 1000) * 1000) -  a)
# Judge status: Accepted
K = int(input())
S = input()
if(len(S)<=K):
    print(S)
else:
    print(S[:K]+"...")
# Judge status: Wrong Answer
X ,Y= map(int,input().split())
ans = X + Y/2
print(ans)
# Judge status: Accepted
def solve():
    ans = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            ans += 1
    return ans

if __name__ == '__main__':
    s = input()
    t = input()
    print(solve())
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a > k:
    print(':(')
else:
    print('Yay!')
# Judge status: Wrong Answer
L,R = (int(x) for x in input().split())
if (R-L)//2019:
  R -= (R-L)//2019*2019
ans = 2018
for i in range(L,R):
  for j in range(i+1,R+1):
    ans = min(ans,(i*j)%2019)
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-

A, B, C, D = map(int, input().split())

late_start = 0
first_stop = 0
same_time = 0

late_start = max(A, C)
first_stop = min(B, D)
if first_stop - late_start > 0:
    same_time = first_stop - late_start
else:
    same_time = 0

print(same_time)
# Judge status: Accepted
import itertools

N,D = map(int,input().split())

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

res = list(itertools.combinations(X,2))

cnt = 0

for i in itertools.combinations(X,2):
    #tmp = zip(i[0],i[1])
    tmp = 0
    for j in zip(i[0],i[1]):
        tmp += pow(j[0]-j[1],2)
    ans = tmp ** 0.5
    if ans.is_integer():
        cnt += 1

print(cnt)
# Judge status: Accepted
N,X,T=map(int,input().split())
s1=int(N/X)
s2=N%X
if s2>0:
  print((s1+1)*T)
else:
  print(s1*T)
# Judge status: Accepted
import math

n = int(input())

x = (n/1.08)

a = x//1
b = math.ceil(x)

if a*1.08//1 == n :
    print(math.ceil(a))
elif b*1.08//1 == n :
    print(b)
else:
    print(":(")
# Judge status: Accepted
n = int(input())
arr = [0] * 60000
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            n_ = x**2 + y**2 + z**2 + x*y + y*z + z*x
            arr[n_-1] += 1

print(*arr[:n], sep='\n')
# Judge status: Wrong Answer
s = str(input())
t = str(input())

count = 0
for i in range(len(s)):
  if s[i]==t[i]:
    count+=1
    
print(count)
# Judge status: Wrong Answer
s = input()
count = 0

for i in range(3):
  if s[i] == 1:
    count += 1
    
print(count)
# Judge status: Accepted
charset = [chr(ord("A") + i) for i in range(26)]
N = int(input())
S = input()
ans = ""
for s in S:
    ans += charset[(charset.index(s) + N) % 26]
print(ans)
# Judge status: Accepted
import sys
from bisect import bisect_left, bisect_right

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# dp と bisect.insort
N = ir()
INF = 10 ** 12
dp = [INF] * (N+1)
for _ in range(N):
    a = ir()
    i = bisect_right(dp, -a)
    dp[i] = -a

print(bisect_left(dp, INF))
# 18
# Judge status: Wrong Answer
K, A, B = map(int, input().split())
ans = 0
if B>A+1:
  if K>=A+1:
    ans += B
    K -= A+1
  k = K//2
  ans += (B-A)*k
  ans += K%2
else:
  ans = K+1

print(ans)
# Judge status: Accepted
import datetime

dt = datetime.datetime.strptime(input(), '%Y/%m/%d')
print('Heisei' if dt <= datetime.datetime(2019, 4, 30) else 'TBD')
# Judge status: Wrong Answer
# from pprint import pprint
import math

# import collections

# n = int(input())
n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

b = [math.log2(_a) for _a in a]

for _m in range(m):
    b[b.index(max(b))] -= 1

c = [int(2 ** _b) for _b in b]
ans = sum(c)
print(ans)
# Judge status: Accepted
x,y=map(int,input().split())
if x%y==0:
    print(-1)
else:
    for i in range(1,y):
        tmp = x*i
        if tmp%y!=0:
            print(tmp)
            exit()
    print(-1)
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

cnt = 0
for i in a:
    if x >= i:
        x -= i
        cnt += 1
    else:
        break
if x != 0 and cnt != 0 and cnt == n:
    cnt -= 1

print(cnt)
# Judge status: Accepted
n = int(input())
point = 0
ans = []
for i in range(1, n+1):
    point += i
    ans.append(str(i))
    if point >= n:
        if str(point - n) in ans:
            ans.remove(str(point - n))
        print('\n'.join(ans))
        break
# Judge status: Accepted
import sys

input = sys.stdin.readline
import bisect

INF = 10 ** 18
N = int(input())
A = [10 ** 10 - int(input()) for _ in range(N)]  # 逆順にしておく

# 最長単調減少列：狭義

dp = [INF] * (N + 1)  # 長さ、その長さの末端としてありうる最大値

for a in A:
    idx = bisect.bisect_right(dp, a)
    dp[idx] = a

answer = bisect.bisect_left(dp, INF)
print(answer)
# Judge status: Accepted
n=int(input())

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

nice_box = [0]*n

for i in range(n-1,-1,-1):
  baisu = 2
  ball_memo = 0
  index = i+1
  while baisu * index - 1 < n:
    ball_memo += nice_box[baisu * index - 1]
    baisu += 1

  if ball_memo % 2 != a[i]:
    nice_box[i] += 1

ans = []

for i in range(n):
  if nice_box[i] == 1:
    ans.append(i+1)

print(len(ans))
if len(ans)>0:
  print(*ans)
# Judge status: Wrong Answer
sx,sy,gx,gy=map(int,input().split())
s=''
t=''
for i in range(gx-sx):
  s+='R'
  t+='L'
for i in range(gy-sy):
  s+='U'
  t+='D'
s+=t
s+='D'
t='U'
for i in range(gx-sx+1):
  s+='R'
  t+='L'
for i in range(gy-sy+1):
  s+='U'
  t+='D'
s+='L'+t+'R'
print(len(s))
# Judge status: Accepted
# coding: utf-8
# Your code here!
a,b=input().split()
num=list(map(int,input().split()))

U=input()

if U==a:
    num[0]-=1
else:
    num[1]-=1

print(*num)
# Judge status: Accepted
a, b, c = map(int, input().split())
if a <= c and c <= b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a = str(input())

Cap = ['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']

if a in Cap:
  print('A')
else:
  print('a')
# Judge status: Accepted
import copy
n=int(input())
ans=[]
mins=55
a=[list(input()) for _ in range(n)]
for i in a:
  if mins > len(i):
    mins=min(mins,len(i))
    m=copy.copy(i)
for i in m:
  flg=0
  for j in a:
    if i not in j:
      flg=1
  if flg==0:
    ans.append(i)
    for j in a:
      j.remove(i)
ans.sort()
print(*ans,sep='')
# Judge status: Accepted
s=input()
if '2019/04/30'>=s:
  print("Heisei")
else:
  print("TBD")
# Judge status: Accepted
from math import floor, sqrt
N = int(input())
ans = 0
for o in range(1, N + 1, 2):
  cnt = 0
  for n in range(1, o + 1):
    if o % n == 0:
      cnt += 1
  if cnt == 8:
    ans += 1
print(ans)
# Judge status: Accepted
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
for x in X:
  if x<=Y[(N-1)//2]:
    print(Y[N//2])
  else:
    print(Y[N//2-1])
# Judge status: Accepted
def main():
    a, b = map(int, input().split())

    res = 0
    for i in range(2):
        if a > b:
            res += a
            a -= 1
        else:
            res += b
            b -= 1
    print(res)
    
if __name__ == '__main__':
    main()
# Judge status: Accepted
N=int(input())

if N%2==0:
    print(0.5)
else:
    print((N//2+1)/N)
# Judge status: Accepted
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import random
#####################################
n=int(input())
A=INPUT()
D=[0]*(n+1)
for i in range(n):
    D[A[i]]=(i+1)
print(*D[1:])
# Judge status: Accepted
from math import ceil
def main():
    N = int(input())
    if N%2==1:
        print(0)
        return
    else:
        # N=k*5^xのxが答えとする
        ans = 0
        N //= 2
        while N:
            ans += N//5
            N //= 5
        print(ans)
        return


main()
# Judge status: Accepted
#083_B
n,a,b=map(int,input().split())
def k_sum(x):
    x=[int(i) for i in list(str(x))]
    return sum(x)
print(sum([i for i in range(1,n+1) if a<=k_sum(i)<=b]))
# Judge status: Wrong Answer
n, p, *a = map(int, open(0).read().split())
if n == 1:
    if a[0] % 2 == p:
        print(1)
    else:
        print(0)
else:
    print(2**(n -1))
# Judge status: Accepted
a,b,c = map(int,input().split())
li = [a,b,c]
li.sort()
if li[1] == c:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer

x=int(input())
ans=360//x
print(ans)
# Judge status: Accepted
n = int(input())
sl = list(input())

max_k = 0
now = 0
for s in sl:
    if s == "(":
        now += 1
    else:
        now -= 1
    max_k = min(now, max_k)


print("(" * (-max_k) + "".join(sl) + max(now-max_k, 0) * ")")
# Judge status: Accepted
w,a,b=map(int,input().split())
d=max(a,b)
c=min(a,b)
if d-c<=w:
  ans=0
else:
  ans=d-c-w
print(ans)
# Judge status: Accepted
a = [0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1]
x, y = map(int, input().split())

if a[x] != a[y]:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
s = input()
s1 = s[0]
s2 = s[2:-1]
s = s.replace('A','')
s = s.replace('C','')
t = s.lower()
if(s1 == 'A' and s2.count('C') == 1 and t == s):
    print('AC')
else:
    print('WA')
# Judge status: Accepted
N = int(input())
steps = list(map(int, input().split(" ")))

costs = [None] * N
costs[0] = 0
costs[1] = abs(steps[1] - steps[0])

for i in range(2, N):
    cost1 = costs[i-1] + abs(steps[i-1] - steps[i])
    cost2 = costs[i-2] + abs(steps[i-2] - steps[i])
    costs[i] = min(cost1, cost2)

print(costs[N-1])
# Judge status: Wrong Answer
n = int(input())
s = input()
t = input()

for i in range(n):
  if s[-i-1:] != t[:i+1]:
    cnt = i

print(n * 2 - i)
# Judge status: Accepted
from collections import Counter
w = list(input())
c = Counter(w)
f = True
for i in list(c.values()):
    if i % 2 == 1:
        f = False
        break

if f:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S = sorted(input())
T = sorted(input())

print("Yes" if (S < T) else "No")
# Judge status: Accepted
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

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

if N <= M//2:
    ans = N + max(M-2*N,0)//4
else:
    ans = M // 2

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

ans = 0
for X in range(1, N+2):
  cnt = 0
  for i in range(N):
    if X - 1 <= A[i] <= X + 1:
      cnt += 1
  ans = max(ans, cnt)
  
print(ans)
# Judge status: Accepted
K = int(input())
A, B = map(int, input().split())
for i in range(A, B+1):
  if i % K == 0:
    print('OK')
    exit()
print('NG')

"""B問題"""
# Judge status: Accepted
N = int(input())
a = 0
n = N
while n > 1:
  n = n//2
  a += 1
ans = 2**a
print(ans)
# Judge status: Accepted
def solve():
    a,y = map(int,input().split())
    ans = 1
    while(a<=y):
        a*=2
        ans+=1
    print(ans-1)
if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
a = list(input())
b = int(a.index('0'))
print(b + 1)
# Judge status: Accepted

n = int(input())
A = list(map(int, input().split()))
dp = [0] * 9
for i in A:
    s = i // 400
    if s >= 8:
        dp[-1] += 1
    else:
        dp[s] = 1
 
ans = 0
for j in range(len(dp) - 1):
    ans += dp[j]
    
if ans == 0:
    print(1, dp[-1])
else:    
    print(ans, sum(dp))
# Judge status: Accepted
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
l = [0] * n
r = [0] * n
for i in range(1, n):
    l[i] = max(l[i-1], a[i-1])
for i in range(n-2, -1, -1):
    r[i] = max(r[i+1], a[i+1])
for i in range(n):
    print(max(l[i], r[i]))
# Judge status: Accepted
n= int(input())

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

if n == 0 and a[0]==1:
    print(1)
    exit(0)

if a[0] != 0:
    print(-1)
    exit(0)

b=1
count=1
asum =sum(a)
alim = asum

for i in range(n):
    if a[i+1] > 2*b:
        print(-1)
        exit(0)
    else:
        alim = alim - a[i+1]
        b= min(2*b-a[i+1], alim)

        count += b

print(count+ asum)
# Judge status: Accepted
from collections import Counter
N, M = list(map(int,input().split()))
city_list = [list(map(int,input().split())) +[i+1]  for i in range(M)]
city_list_sorted = sorted(city_list,key=lambda x: (x[0],x[1]) )
pre = 0
counter = 0

for i in range(M):
  if pre == city_list_sorted[i][0]:
    counter+=1
    city_list_sorted[i][1] = counter
  else:
    counter = 1
    city_list_sorted[i][1] = counter
    pre = city_list_sorted[i][0]

anslist = [[x[2]]+[format(x[0],'0>6') + format(x[1],'0>6') ] for x in city_list_sorted]
[print(x[1]) for x in sorted(anslist)]
# Judge status: Accepted
def main():
    S = list(input())
    K = int(input())
    L = len(S)
    for i in range(L):
        if S[i] == 'a':
            continue
        if ord('z') - ord(S[i]) + 1 <= K:
            K -= ord('z') - ord(S[i]) + 1
            S[i] = 'a'

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

    print(''.join(S))




if __name__ == "__main__":
    main()