peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
l = []
for i in range(3):
  l.append(list(map(int, input().split())))

n = int(input())

for times in range(n):
  b = int(input())
  for cl in range(3):
    for rw in range(3):
      if b == l[cl][rw]:
        l[cl][rw] = 0

for i in range(3):
  if l[i][0] == l[i][1] == l[i][2] or l[0][i] == l[1][i] == l[2][i]:
    print("Yes")
    exit()
if l[0][0] == l[1][1] == l[2][2]:
  print("Yes")
  exit()
elif l[0][2] == l[1][1] == l[2][0]:
  print("Yes")
  exit()
print("No")
# Judge status: Accepted
N = int(input())
S = str(input())

def Main(N, S):
    ans = 0
    mx = ans
    for c in S:
        if c == "I":
            ans += 1
        else:
            ans -= 1
        mx = max(mx, ans)
    return mx
        
res = Main(N, S)
print(res)
# Judge status: Wrong Answer
from math import sqrt
a, b = map(int, input().split())
gcd = 1
for i in range(1, int(sqrt(min(a, b))+1)):
    if a % i == b % i == 0:
        gcd *= i
print(int(a * b / gcd))
# 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()))

r = int(input())

print(r**2)
# Judge status: Accepted
# coding: utf-8
# Your code here!
Q,H,S,D=map(int,input().split())
N=int(input())

cost=[Q,H,S,D]

ans=10**18
for index,item in enumerate(cost):
    temp=item*(N*2**(2-index) if index!=3 else N//2)
    
    for jndex,jtem in enumerate(cost[:3]):
        ans=min(ans,temp+jtem*(0 if index!=3 else (N%2)*2**(2-jndex)))
    
print(ans)
# Judge status: Wrong Answer
n, m, k = map(int, input().split())
for r in range(n+1):
    for c in range(m+1):
        if m*c + n*r - 2*c*r == k:
            print('Yes')
            break
    else:
        continue
    break
else:
    print('No')
# Judge status: Accepted
def resolve():
    S, T = input().split()
    A, B = list(map(int, input().split()))
    U = input()
    if S == U:
        A -= 1
    else:
        B -= 1
    print(A, B)

if '__main__' == __name__:
    resolve()
# Judge status: Wrong Answer
n, d = map(int, input().split())
s = 2*d+1
ans = (n+s-1)/s
print(ans)
# Judge status: Accepted
a, b, c, d = map(int, input().split())
ans = 0

for i in range(0, 101):
    if a <= i <= b and c <= i <= d:
        ans = ans + 1

if ans != 0:
    ans = ans - 1

print(ans)
# Judge status: Accepted
import sys
a,b,k=map(int,input().split())
for i in range(1,101):
  if a%(101-i)==0 and b%(101-i)==0:
    k-=1
  if k==0:
    print(101-i)
    sys.exit()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

b = [0 for _ in range(n)]


def check(i, n):
    cnt = 0
    t = i
    while t <= n:
        cnt += b[t-1]
        t += i
    return cnt


for i in range(n-1, -1, -1):
    if (a[i] + check(i+1, n)) % 2 == 1:
        b[i] = 1

ans = []
cnt = 0
for i in range(n):
    if b[i] == 1:
        cnt += 1
        ans.append(i+1)
print(cnt)
l = [str(int(i)) for i in ans]
print(' '.join(l))
# Judge status: Accepted
abcd=str(input())
for i in range(2**4):
    list=[int(abcd[0])]
    symbol=[]
    for j in range(1,4):
        if (i>>j)&1==True:
            list.append(int(abcd[j]))
            symbol.append('+')
        else:
            list.append(int(abcd[j])*(-1))
            symbol.append('-')
    if sum(list)==7:
        print(str(abcd[0])+symbol[0]+str(abcd[1])+symbol[1]+str(abcd[2])+symbol[2]+abcd[3]+"=7")
        break
# Judge status: Accepted
n=int(input())
a=[[int(i) for i in input().split()] for _ in range(n)]
u=0
for x in a[::-1]:
    if (x[0]+u)%x[1]!=0:u+=((x[0]+u)//x[1]+1)*x[1]-x[0]-u
print(u)
# Judge status: Accepted
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))
# Judge status: Wrong Answer
n=int(input())
l=list(map(int,input().split()))
ans=[]
for i in range(1,len(l)+1):
    ans.append(l.index(i)+1)
print (ans, end=" ")
# Judge status: Wrong Answer
N = int(input())
data = []
ans = []
for i in range(1, N+1):
  city, score = input().split()
  score = int(score)
  data.append([city, score, i])
city_list = [x[0] for x in data]
score_list = [x[1] for x in data]
num_list = [x[2] for x in data]
city_unique = sorted(set(city_list))

for city_u in city_unique:
  city_index = [i for i, x in enumerate(city_list) if x == city_u]
  for score in sorted([score_list[x] for x in city_index], reverse=True):
    ans.append(num_list[score_list.index(score)])
print(ans)
# Judge status: Accepted
n = int(input())
b = list(map(int,input().split()))
ans = 0
ans += b[0]
ans += b[n-2]
for i in range(0,n-2):
    ans += min(b[i],b[i+1])
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))

from fractions import gcd
def two(n):
    ans = 0
    while n%2==0:
        n //= 2
        ans += 1
    return ans

def multi_lcm(A):
    ans = A[0]
    for a in A:
        ans *= a//gcd(ans,a)
    return ans

def solve(N,M,A):
    ans = 0
    num_two = len(set(map(two,A)))
    if num_two != 1:
        return 0
    l = multi_lcm(A)
    ans = (M+l//2)//l
    return ans
print(solve(N,M,A))
# Judge status: Accepted
h, n = map(int,input().split())
a = list(map(int,input().split()))
c = 0
for i in range(n):
  c = c + a[i]
if (c >= h):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n, y = map(int, input().split())

a, b, c = -1, -1, -1

for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        if 10000*i + 5000*j + 1000*k == y:
            a, b, c = i, j, k

print(a, b, c)
# Judge status: Accepted
n,m=map(int,input().split())
num=[]
for i in range(n):
    a,b=map(int,input().split())
    num.append([a,b])
str1= lambda val: val[0]
num.sort(key=str1)
numa=0
numb=0
for i in range(n):
    numa+=(num[i][1])*(num[i][0])
    numb+=num[i][1]
    if numb>=m:
        numa-=(numb-m)*num[i][0]
        break
print(numa)
# Judge status: Wrong Answer
k=list(map(int, input().split(' ')))
a=list(map(int, input().split(' ')))
m=a[0]
for i in range(k[1]):
    if i==k[1]-1:
        if k[0]-a[i]+a[0]>m:
            m=k[1]-a[i]+a[0]>m
    else:
        if a[i+1]-a[i]>m:
            m=a[i+1]-a[i]>m
print(k[0]-m)
# Judge status: Accepted
S = list(input())
T = list(input())

S.sort()
T.sort(reverse=True)

if S < T:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s=list(map(int,input().split()))
s=sorted(s)
print(10*s[2]+s[1]+s[0])
# Judge status: Accepted
D = int(input())
#かわむら

today = "Christmas"

x = 25 - D

today += x * " Eve"

print(today)
# Judge status: Wrong Answer
N,K = map(int,input().split())
X = list(map(int,input().split()))
ls = []
rs = []
for x in X:
    if x < 0:
        ls.append(-x)
    else:
        rs.append(x)
ls.reverse()

ans = float('inf')
if len(ls) >= K:
    ans = min(ans, ls[K-1])
if len(rs) >= K:
    ans = min(ans, rs[K-1])

for l in range(1,K):
    r = K-l
    if l >= len(ls) or r >= len(rs): break    
    ans = min(ans, ls[l-1]*2 + rs[r-1])
    ans = min(ans, rs[r-1]*2 + ls[l-1])
print(ans)
# Judge status: Wrong Answer
T={'Sunny':'Cloudy','Cloudy':'Rainy','Rainy':'Sunny'}
print(T['Sunny'])
# Judge status: Accepted
# 初期入力
import sys
import math
input = sys.stdin.readline
N = int(input())
a_max =[] #移動手段の最大乗車人数
num =[0]*5 #各移動機関の稼働回数
for i in range(5):
    x = int(input())
    a_max.append(x)
    num[i] =math.ceil(N /x)

#ボトルネックを過ぎれば、時間は距離に比例
max_value = max(num)
max_index = num.index(max_value)
ans =num[max_index] +6-2
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    h=list(map(int,input().split()))+[INF]*K
    dp=[INF]*(2*10**5)
    dp[0]=0
    for i in range(N):
        for k in range(1,K+1):
            dp[i+k]=min(dp[i+k],dp[i]+abs(h[i+k]-h[i]))
    print(dp[N-1])

if __name__ == '__main__':
    main()
# Judge status: Accepted
d,t,s = map(int,input().split())
print('Yes' if s*t>=d else 'No')
# Judge status: Wrong Answer
from fractions import gcd
A, B = map(int, input().split())

saidai_kouyaku = gcd(A,B)
kouyaku = [0 for _ in range(int(saidai_kouyaku**0.5)+1)]
kouyaku[1] = 1

for i in range(2,len(kouyaku)):
    while saidai_kouyaku%i==0:
        kouyaku[i]+=1
        saidai_kouyaku = saidai_kouyaku/i

answer = 0
for i in range(len(kouyaku)):
    if kouyaku[i] > 0:
        answer += 1

if answer >= 2:
    print(answer)
else:
    print(2)
# Judge status: Accepted
n = int(input())
S = input()
s = list(S)
p = 1
if n % 2 == 0:
    for i in range(n//2):
        if s[i] == s[i + n//2]:
            continue
        else:
            p = 0
else:
    p = 0
if p == 1:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import math
k=int(input())
ans=0
if k==1:
  print('1')
i=0
while True:
  k=math.floor(k/2)
  ans+=2**i
  i+=1
  if k<1:
    print(ans)
    exit()
# Judge status: Wrong Answer
h,n=map(int,input().split())
ans=0
magic=[]
al=[]
bl=[]
for i in range(n):
  a,b=map(int,input().split())
  magic.append([a,b])
  al.append(a)
  bl.append(b)
amx=max(al)
bmn=min(bl)
dp=[-1]*(h+amx+1)
dp[0]=0
for i in range(1,h+amx+1):
  mn=9999999
  for j in magic:
    mp=j[1]
    at=j[0]
    if at>i:
      continue
    cst=dp[i-at]+mp
    if cst<mn:
      mn=cst
  if mn==9999999:
    mn=bmn
  dp[i]=mn
  
print(min(dp[h:]))
# Judge status: Accepted
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    G=np.array([list(map(int,input().split())) for _ in range(3)])
    G[1]-=G[0]
    G[2]-=G[0]
    if len(set(G[1]))==1 and len(set(G[2]))==1:
        print('Yes')
    else:
        print('No')


resolve()
# Judge status: Accepted
from collections import Counter
S = input()
l = list()
for i in S:
    l.append(i)
c = Counter(l)
print(min(c['0'], c['1'])*2)
# Judge status: Accepted
N,D=map(int,input().split())
print((2*D+N)//(2*D+1))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

c = 0
for i in range(n):
    a_m = min(a[i], b[i])
    c += a_m
    b[i] -= a_m
    b_m = min(a[i+1], b[i])
    a[i+1] -= b_m
    c += b_m

print(c)
# Judge status: Accepted
a, b = map(int, input().split())

if a > b:
    print(a-1)
else:
    print(a)
# Judge status: Wrong Answer
import math

a,b,h,m=map(int, input().split())

h_rad = 30*h
m_rad = 0.5*m
diff1 = abs(h_rad-m_rad)
diff2 = 360-diff1
diff = min(diff1,diff2)
cos = math.cos(math.radians(diff))
ans = math.sqrt(a**2+b**2-(2*a*b*cos))
print(ans)
# Judge status: Accepted
N,K=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
cnt=0
l=[]
l.append([A[0],0])
for i in range(len(A)):
  if A[i]==l[cnt][0]:
    l[cnt][1]+=1
  else:
    cnt+=1
    l.append([A[i],1])
if len(l) <= K:
  print(0)
else:
  l.sort(key=lambda x: x[1])
  sum=0
  for i in range(len(l)-K):
    sum+=l[i][1]
  print(sum)
# Judge status: Wrong Answer
#abc044 b
s=input()
moji=dict()
flag=True
for i in range(len(s)):
    if i not in moji:
        moji[i]=1
    else:
        moji[i]+=1
for i in moji.values():
    if i%2==1:
        flag=False
        break
print("Yes" if flag else "No")
# Judge status: Accepted
T = list(input())
ans = 0
i = 0
while i < len(T):
  if T[i] == "?":
    T[i] = "D"
  i += 1
print("".join(T))
# Judge status: Wrong Answer
N=input()
list=[a for a in N]
if list.count(list[0])==3 or list.count(list[1])==3 or list.count(list[2])==3 or list.count(list[3])==3:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a = int(input())
b = int(input())
if a==1 and b==2:print(3)
elif a==2 and b == 3:print(1)
elif a==3 and b == 1:print(2)
# Judge status: Accepted
def main():
  k = int(input())
  #s = input()
  #s = input().split()
  a,b = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  for i in range(a,b+1):
    if i % k == 0:
      print("OK")
      exit()
  print("NG")

if __name__ == '__main__':
  main()
# Judge status: Wrong Answer
h,n=map(int,input().split())
s = sum(list(map(int,input().split())))

print("Yes" if s>=h else print("No"))
# Judge status: Accepted
L, R, d = [int(i) for i in input().split()]

cnt = 0
for i in range(L, R+1):
    if i % d == 0:
        cnt += 1
        
print(cnt)
# Judge status: Accepted
x = int(input())
j = 0
for i in range(360):
  j += x
  j %= 360
  if j == 0:
    print(i+1)
    exit()
# Judge status: Accepted
S = input()
b = 1
B = 0
l = 0
for i in S:
  if int(i) != b:
    B += 1
  b = 1 - b
  l += 1
print(min(B, l - B))
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(1,a+1):
  for j in range(1,b+1):
    for k in range(1,c+1):
      if i*500+j*100+k*50==x:
        ans+=1

print(ans)
# Judge status: Accepted
n,w=map(int,input().split())

weight=[]
value=[]

for i in range(n):
    a,b=map(int,input().split())
    weight+=[a]
    value+=[b]

dp=[[0]*(w+1) for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j<weight[i]:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-weight[i]]+value[i])

print(dp[n][w])
# Judge status: Wrong Answer
l, r = map(int, input().split())

i = l
j = i + 1
count = 0
arr = []
while(True):
    if count == 10000 or j == r:
        break
    else:
        arr.append((i*j) % 2019)
        j += 1
        count += 1
if len(arr) == 0:
    arr.append((l*r) % 2019)
        
print(min(arr))
# Judge status: Accepted
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

tt = list(t)
d = {'r':p, 's': r, 'p':s}
dp = [d[t[i]] for i in range(n)]

for i in range(n-k):
    if tt[i]==tt[i+k]:
        dp[i+k] = 0
        tt[i+k] = 'x'

print(sum(dp))
# Judge status: Wrong Answer
l = [[0.25],[0.5],[1],[2]]
tmp = list(map(int,input().split()))
for i in range(4):
    l[i].append(tmp[i])

for i in range(4):
    l[i].append(l[i][1]*4//l[i][0])

from operator import itemgetter
l = sorted(l, key=itemgetter(2))

ans = 0
n = int(input())
for i in range(4):
    tmp = n//l[i][0]
    if tmp > 0:
        ans += tmp * l[i][1]
        n -= tmp*l[i][0]

print(int(ans))
# Judge status: Accepted
N = int(input())
arms = []
for i in range(0, N):
  X, L = map(int, input().split(" "))
  arms.append((X + L, X - L))

arms.sort()
ans = 0
coord = -float('inf')

for arm in arms:
  if arm[1] >= coord:
    ans += 1
    coord = arm[0]

print(ans)
# Judge status: Wrong Answer
o=input()
e=input()
t=""
for i in range(len(e)):
    t+=o[i]
    t+=e[i]
print(t)
# Judge status: Accepted
S=input()                                                                             
print(S.count('1'))
# Judge status: Accepted
import math
n = int(input())
abcde = [int(input()) for _ in range(5)]
print(4 + math.ceil(n / min(abcde)))
# Judge status: Accepted
N = int(input())
d = list(map(int, input().split()))
d.sort()
print (d[N//2]-d[N//2-1])
# Judge status: Accepted
n, p = map(int, input().split())
A = list(map(int, input().split()))
if all(a % 2 == 0 for a in A):
	print(0 if p == 1 else 2**n)
else:
	print(2**(n - 1))
# Judge status: Accepted
N= int(input())
d=list(map(int,input().split()))
d.sort()
ans=d[N//2]-d[N//2-1]
print(ans)
# Judge status: Wrong Answer
d,t,s=list(map(int,input().split()))

if d/t<=s:
    print("yes")
else:
    print("No")
# Judge status: Wrong Answer
N,M = map(int,input().split())
H = list(map(int,input().split()))
datas = []
anss = []
for i in range(M):
    datas.append(list(map(int,input().split())))
for data in datas:
    ans = []
    for dat in data:
        ans.append(H[dat-1]) 
    anss.append(max(ans))
print(len(set(anss)))
# Judge status: Accepted
N = int(input())
s = sorted([int(input()) for _ in range(N)])

all_10 = True
for i in range(N):
    if s[i] % 10 != 0:
        all_10 = False

if all_10:
    print(0)
    exit()

sum_s = sum(s)

if sum_s % 10 != 0:
    print(sum_s)
else:
    for i in range(N):
        if s[i] % 10 != 0:
            print(sum_s - s[i])
            break
# Judge status: Accepted
N, K, S = map(int, input().split())

l = []
for i in range(K):
    l.append(str(S))

for i in range(N-K):
    if S == 1:
        l.append(str(S+1))
    else:
        l.append(str(S-1))

print(' '.join(l))
# Judge status: Wrong Answer
import math

x = int(input())
orig = 100
counter = 0

while orig <= x:
    orig = math.floor(orig * 1.01)
    counter += 1

print(counter)
# Judge status: Accepted
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == i*500 + j*100 + 50*k:
                cnt+=1
print(cnt)
# Judge status: Wrong Answer
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

#loop check
gone = []
pos = 0
i = 0
while pos not in gone:
    gone.append(pos)
    pos = A[pos] - 1
    i += 1
    if (pos in gone):
        loop_flag = True
        loop_pos = gone.index(pos)
        loop_len = len(gone)-loop_pos



if (loop_flag):
    pos = loop_pos
    for i in range(((K - loop_pos) % loop_len)-1):
        pos = A[pos]-1
    
else:
    pos = 0
    for i in range(K):
        pos = A[pos]-1

print(pos+1)
# Judge status: Accepted
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = max(A,B)+1
    while t < K:
        i -= 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()
# Judge status: Wrong Answer
# coding: utf-8
x=input().split(" ")
k=int(x[0])
s=int(x[1])
sum=0
for i in range(k+1):
    if s-i<=k*2 and s-i>=k:
        sum+=k*2-s+i+1
    elif s-i<k:
        sum+=s-i+1
print(sum)
# Judge status: Accepted
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, X, Y = map(int, readline().split())

    X -= 1
    Y -= 1

    ans = [0] * N

    for i in range(N - 1):
        for j in range(i + 1, N):
            d = min(j - i, abs(i - X) + 1 + abs(Y - j))
            ans[d] += 1

    print('\n'.join(map(str, ans[1:])))
    return


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s = input()
min_ = 10**18
for i in range(len(s)-3):
  min_ = min(min_, abs(753 - int(s[i:i+3])))
# Judge status: Accepted
s = input()
n = int(s)

m = []

y = n
while y > 0:
    z = y % 10
    m.append(z)
    y = int(y / 10)
    
p = m[len(m) - 1]


max_num = 0
for i in range(len(m)):
    max_num = max(max_num, m[i])

if p < max_num:
    p += 1


for i in range(len(m)):
    m[i] = p
    print(m[i], end='')

print('')
# Judge status: Accepted
import numpy as np
from collections import defaultdict

s = list(map(int, input().split()))
n=s[0]
a = np.array(list(map(int, input().split())))
s = list(map(int, input().split()))
q=s[0]
num=defaultdict(int)
ans=0

for i in a:
    num[i]+=1
    ans+=i

for i in range(q):
    s = list(map(int, input().split()))
    a=s[0]
    b=s[1]
    ans=ans-a*num[a]-b*num[b]
    num[b]=num[a]+num[b]
    ans = ans+b*num[b]
    num[a]=0
    print(ans)
# Judge status: Wrong Answer
n = int(input())
A = []
for _ in range(n):
    a = int(input())
    A.append(a)
ans = 0
tmp = 1
if n==1:print(1);exit()
for i in range(n-1):
    if A[i]>=A[i+1]:
        tmp += 1
    else:
        tmp = 1
    ans = max(ans,tmp)
print(ans)
# Judge status: Accepted
N, x = map(int,input().split())
a = list(map(int,input().split()))
count = 0
a_new = sorted(a)

for i in range(0, N):
	count += a_new[i]
	if x == count:
		index = i + 1
		break
	if count > x:
		index = i
		break
	index = i

print(str(index))
# Judge status: Accepted
s = list(input())
n = len(s)
k = int(input())
t = [ord(s[i]) - 97 for i in range(n)]
for i in range(n):
    if k == 0:
        break
    x = 26 - t[i]
    if 0 < x % 26 <= k:
        k -= x
        s[i] = "a"
t[-1] = ord(s[-1]) - 97
if k > 0:
    s[-1] = chr((k + t[-1]) % 26 + 97)
print("".join(s))
# Judge status: Wrong Answer
s = input()
d = { "eam":5, "mer":7, "ase":5, "ser":6}
index = len(s)
while index != 0:
  tmp = s[index-3:index]
  if tmp not in d.keys():
    break
  index -= d[tmp]
  if index < 0:
    break
else:
  print("YES")
  exit()
print("NO")
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
B = [a-i-1 for i, a in enumerate(A)]
med = sorted(B)[n//2]
print(sum(abs(a-med) for a in B))
# Judge status: Wrong Answer
n=input()
l=len(n)
k=0
for i in range(l):
    for j in range(i,l):
        if n[i]!=n[j]:
            k=1
            
if k==1:
    print(n[0]*l)
else:
    print(n)
# Judge status: Wrong Answer
A,B,C,X,Y=map(int,input().split())
price=0
if A+B>C+C:
    minXY=min(X,Y)
    price+=minXY*C*2
    X-=minXY
    Y-=minXY
if A>C+C:
    price=X*2*C
    X=0
else:
    price+=A*X
    X=0
if B>C+C:
    price=Y*2*C
    Y=0
else:
    price+=B*Y
    Y=0
print(price)
# Judge status: Accepted
N, M = map(int, input().split())

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(max(N, M) - 2)
else:
    print((N - 2) * (M - 2))
# Judge status: Accepted
N = int(input())

ans = 0
for i in range(1, N+1):
    ans += (N-1) // i

print(ans)
# Judge status: Accepted

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

ans = X[0] + X[-1]
for i in range(N - 2):
    ans += min(X[i], X[i + 1])

print(ans)
# Judge status: Accepted
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A = list(map(int, input().split()))

    print('YES') if A.count(5) == 2 and A.count(7) == 1 else print('NO')

if __name__ == '__main__':
    main()
# Judge status: Accepted
n, m = map(int, input().split())

if n > m:
    t = n
    n = m
    m = t

w = 0

if m == n == 1:
    print(1)
    exit()

if n == 1 and m != 1:
    print(m-2)
elif n != 1:
    print((n-2)*(m-2))
# Judge status: Wrong Answer
from collections import Counter

n = int(input())
S = input()

n = Counter(S)
ans = 1
for i, j in n.items():
  ans *= (j+1)
print(ans-1)
# Judge status: Accepted
from fractions import gcd
from functools import reduce

def Skip(n , x , xl):

    xl = map(lambda i: abs(i - x), xl)
    return reduce(gcd , xl)

def main():
    n , x = map(int , input().split())
    xl = list(map(int , input().split()))
    print(Skip(n , x , xl))

if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import deque
s=deque(input())
q=int(input())
cnt=0
for i in range(q):
    query=list(input().split())
    if query[0]=="1":
        cnt+=1
    else:
        if (cnt+int(query[1]))%2==1:
            s.appendleft(query[2])
        else:
            s.append(query[2])
if cnt%2==1:
    s=reversed(s)
print("".join(s))
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
l = []
for i in range(n):
  a,b = map(int,input().split())
  l.append([a,b])
i = 0
count = 0
money = 0
while count < m:
  count += l[i][1]
  money = l[i][0]*l[i][1]
  i += 1
i -= 1
if count > m:
  money - (m-count)*l[i][1]
print(money)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
A = []
B = []
C = []
for i in range(N):
  if a[i]%4 == 0:
    A.append(a[i])
  elif a[i]%2 == 0:
    B.append(a[i])
  else:
    C.append(a[i])
if len(B) == 0 and len(A)+1 >= len(C):
  print('Yes')
elif len(A) >= len(C):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N = input()

for i in N:
    if i == '7':
        print('Yes')
    else:
        print('No')