Harryxun/stf_run huggingface dataset:
pattern = ["maerd", "remaerd", "esare", "resare"]

def rec(s):
    if (len(s) == 0):
        return True

    for candidate in pattern:
        if s[:len(candidate)] == candidate:
            rec(s[len(candidate):])
            return True

    return False

def main():
    S = input()
    S = S[::-1]

    if rec(S):
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

### FIXED CODE ###


S = input()
S = S[::-1]

pattern = ['maerd', 'remaerd', 'esare', 'resare']

pos = 0
possible = True

while pos < len(S):
    no_match = True
    for candidate in pattern:
        if S[pos : pos + len(candidate)] == candidate:
            pos += len(candidate)
            no_match = False
            break

    if no_match:
        possible = False
        break

if possible:
    print('YES')
else:
    print('NO')
import sys
sys.setrecursionlimit(100001)
N, M, K = map(int, input().split())

label = [-1] * N
n_label = [0] * N

F, B = {}, {}
for i in range(N):
    F[i] = set()
    B[i] = set()

for _ in range(M):
    x, y = map(int, input().split())
    F[x - 1].add(y - 1)
    F[y - 1].add(x - 1)

for _ in range(K):
    x, y = map(int, input().split())
    B[x - 1].add(y - 1)
    B[y - 1].add(x - 1)


def dfs(v, lab):
    if label[v] != -1:
        return 0
    label[v] = lab
    n_label[lab] += 1
    for n in F[v]:
        dfs(n, lab)
    return 1


# labeling
count = 0
for i in range(N):
    count += dfs(i, count)
n_label = n_label[:count]

# calc friend candidate
blocked = 0
for b in B[0]:
    if label[b] == label[0]:
        blocked += 1
print(n_label[label[0]] - 1 - len(F[0]) - blocked, end='')
for i in range(1, N):
    print(' ', end='')
    blocked = 0
    for b in B[i]:
        if label[b] == label[i]:
            blocked += 1
    print(n_label[label[i]] - 1 - len(F[i]) - blocked, end='')
print('')


### FIXED CODE ###

import math

N = int(input())
print(math.ceil(N / 2))
n=int(input())
s=list(input() for _ in range(n))
m,i,f,both=0,0,0,0

for i in range(n):
    m +=s[i].count("AB")

    if s[i][-1]=="A":
        f +=1
    if s[i][0]=="B" and s[i][1]=="A":
        both+=1
        i-=1
        f-=1

if both!=0:
    if i!=0 and f!=0:
        print(m+both+min(i,f)-1)
    else:
        print(m+both+min(i,f))

else:
    print(min(i,f))


### FIXED CODE ###

n,k=list(map(int,input().split()))
print(n-k+1)
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        else:
            break
    if n == count:
        print(num)
        quit()
print(-1)

### FIXED CODE ###

n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

for i in range(10**n):
    i = str(i)
    flag = True
    if len(i) == n:
        for j in range(m):
            if i[sc[j][0]-1] != str(sc[j][1]):
                flag = False
        if flag:
            print(i)
            quit()

print(-1)
s=input()
k=int(input())
a=[]
for i in range(0,len(s)):
    for j in range(1,len(s)+1):
        a.append(s[i:j])
a=sorted(a)
b=[]
for i in a:
    if i not in b:
        b.append(i)
b.remove("")
print(b[k-1])


### FIXED CODE ###

s=input()
k=int(input())
a=[s[i:i+j+1] for i in range(len(s)) for j in range(k+1)]
a=set(a)
a=sorted(a)
print(a[k-1])
A,B,K = [int(i) for i in input().rstrip().split()]

nums=list(range(A,B+1))

if K <= len(nums)/2:
  print(*(nums[:K] + nums[-K:]),sep="\n")
else:
  print(*nums,sep="\n")


### FIXED CODE ###

A,B,K = [int(i) for i in input().rstrip().split()]

if K <= (B-A+1)/2:
  print(*( list(range(A,A+K)) + list(range(B-K+1,B+1)) ),sep="\n")
else:
  print(*list(range(A,B+1)),sep="\n")
import math
a, b, x = map(float, input().split())
_x = x / a
if _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90.0 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90.0 - math.degrees(theta))


### FIXED CODE ###

import math
a, b, x = map(int, input().split())
_x = x / a
if _x == a * b:
    print(0.0)
elif _x <= a * b / 2:
    theta = math.atan(_x * 2 / b / b)
    print(90 - math.degrees(theta))
else:
    _x = a * b - _x
    theta = math.atan(a * a / 2 / _x)
    print(90 - math.degrees(theta))
n=int(input())
m=n
A=['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']
for i in range(1,11):
  n-=26**i
  if n<=0:
    count=i
    break
n=m

for i in range(1,count):
  n-=26**i
n-=1

B=[]
for i in range(count-1,0,-1):
  B.append(n//(26**i))
  n-=(n//(26**i))*(26**i)
B.append(n)

C=[]
for i in B:
  C.append(A[i])
print(''.join(C))

### FIXED CODE ###

n=int(input())
m=n
A=['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']
for i in range(1,12):
  n-=26**i
  if n<=0:
    count=i
    break
n=m

for i in range(1,count):
  n-=26**i
n-=1

B=[]
for i in range(count-1,0,-1):
  B.append(n//(26**i))
  n-=(n//(26**i))*(26**i)
B.append(n)

C=[]
for i in B:
  C.append(A[i])
print(''.join(C))
def digital_root(n):
  	return n if n < 10 else digital_root(sum(map(int,str(n))))
 
num = input()
if(digital_root(n)%9==0):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

def digital_root(n):
  return n if n < 10 else digital_root(sum(map(int,str(n))))
 
n = int(input())
if(digital_root(n) % 9 == 0):
  print("Yes")
else:
  print("No")
cap, current, rem = input.split()
cap, current, rem = int(cap), int(current), int(rem)

while current < cap and rem > 0:
  current += 1
  rem -= 1
print(rem)

### FIXED CODE ###

cap, current, rem = input().split()
cap, current, rem = int(cap), int(current), int(rem)
 
while current < cap and rem > 0:
  current += 1
  rem -= 1
print(rem)
import functools
import math

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

def lcm_lot(nums):
    return functools.reduce(lcm2, nums, 1)

N = int(input())
T = []
for i in range(N):
    ti = int(input())
    T.append(ti)

print(lcm_lot(T))

### FIXED CODE ###

import functools
import math

def gcd(x,y):
    a,b = max(x,y), min(x,y)
    while b != 0:
        a,b = b,a%b

    return a

def lcm2(x,y):
    return x*y // gcd(x,y)
    
N = int(input())
T = []
for i in range(N):
    ti = int(input())
    T.append(ti)

result = 1
for t in T:
    result = lcm2(result, t)

print(result)
def solve(scores):
  sm = sum(scores)
  if(sm % 10 != 0): return sm
  heapq.heapify(scores)
  while scores:
    mn = heapq.heappop(scores)
    sm -= mn
    if(sm % 10 != 0) : return sm
    sm += mn
  else:
    return 0 
    

N = input()
S = [input() for i in range(N)]
scores = S[:]

print solve(scores)

### FIXED CODE ###

import heapq

def solve(scores):
  sm = sum(scores)
  if(sm % 10 != 0): return sm
  heapq.heapify(scores)
  while scores:
    mn = heapq.heappop(scores)
    sm -= mn
    if(sm % 10 != 0) : return sm
    sm += mn
  else:
    return 0     

N = input()
S = [input() for i in range(N)]
heapq.heapify(S)

while S:
  arr = [i for i in S]
  best = solve(arr)
  if(best > 0):
    print best
    break
  heapq.heappop(S)
else:
  print 0
x,n  = map(int,input().split())
if(n==0):
    print(x)
else:

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

    l = list(range(min(p),max(p)+1))

    rl =  set(l) - set(p)
    m = max(p)
    for i in  rl:
        if(abs(i-x) < m):
            m = abs(i-x)
            ans = i
    print(ans)

### FIXED CODE ###

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

Q = [q for q in range(-1, 102) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)
C = input()

alpha = [chr(ord('a') + i) for i in range(25)]

print(alpha[alpha.index(C)+1])


### FIXED CODE ###

C = input()

alpha = [chr(ord('a') + i) for i in range(26)]

print(alpha[alpha.index(C)+1])
N = int(input())
A = [[x-1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]

def can_match(i, A, next_set):
  if not A[i]:
    return
  if A[A[i][-1]][-1] == i:
    if i < j:
      next_set.add((i,j))
    else:
      next_set.add((j,i))
      
next_set = set()
for i in range(N):
  can_match(i, A, next_set)
  
day = 0
battle = 0
while next_set:
  day += 1
  current_set, next_set = next_set, set()
  for match in current_set:
    battle += 1
    del A[match[0]][-1]
    can_match(match[0], A, next_set)
    del A[match[1]][-1]
    can_match(match[1], A, next_set)
    
if battle == N*(N-1)//2:
  print(day)
else:
  print(-1)

### FIXED CODE ###


N = int(input())
A = [[x-1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]


def can_match(i, A, next_set):
  if not A[i]:
    return
  j = A[i][-1]
  if A[j][-1] == i:
    if i < j:
      next_set.add((i,j))
    else:
      next_set.add((j,i))

      
next_set = set()
for i in range(N):
  can_match(i, A, next_set)
  
day = 0
battle = 0
while next_set:
  day += 1
  current_set = next_set.copy()
  next_set = set()
  for match in current_set:
    battle += 1
    del A[match[0]][-1]
    can_match(match[0], A, next_set)
    del A[match[1]][-1]
    can_match(match[1], A, next_set)
if battle == N*(N-1)//2:
  print(day)
else:
  print(-1)
# 帰宅経路数と時間を取得
N, T = map(int, input().split())
# 時間制限
ans = 1001
# N個の帰宅経路と時間を取得し、比較する
for i in range(N):
    cost, time = map(int, input().split())
    if time < T:
        ans = min(ans, cost)
# 出力する
if ans == 1001:
    print("TLE")
else:
    print(ans)

### FIXED CODE ###

#年齢を取得
N = int(input())
#年齢による条件判断
if N == 1:
    print('Hello World')
elif N == 2:
    #AとBの値を取得
    A = int(input())
    B = int(input())
    #制約の判断
    if A < 1 or A > 9 or B < 1 or B > 9:
        SystemExit
    print(A+B)
sam = input()
ans = input()
for i in range(len(ans)) :
    if (ans[:i] in sam) == False : break

print(ans[ :i-1])
print(ans[i-1:])
print(sam[:len(ans[i-1:])])

if   ((ans[i - 1 :]) in sam[:len(ans[i-1:])])== True and len(ans) != 1 : print('Yes')
elif (ans in sam) == True                                      : print('Yes') 
else                                                           : print('No')                                                 : print('No')

### FIXED CODE ###

s = input() * 2
p = input()
 
if p in (s):
    print("Yes")
else:
    print("No")
import numpy as np
x, n = map(int, input().split())
num_list = list(map(int,input().split()))
num_100 = list(range(1, 101))

for num in num_list:
    numbers = num_100.remove(num)

numbers1 = np.array(numbers)
numbers2 = numbers - x
numbers3 = np.abs(numbers)
min_index = numbers.argmin()
print(numbers1[min_index])

### FIXED CODE ###

import numpy as np
x, n = map(int, input().split())
num_list = list(map(int,input().split()))
num_list = sorted(num_list)
num_100 = list(range(-100, 102))

if n ==0:
    print(x)
else:
 for num in num_list:
     num_100.remove(num)

 numbers1 = np.array(num_100)
 numbers2 = numbers1 - x
 numbers3 = np.abs(numbers2)
 min_index = numbers3.argmin()
 print(numbers1[min_index])
N, M = map(int, input().split())
L, R = 1, N

def merge_list(list):
    # sortずみ
    return (list[-1][0], min(map(lambda x: x[1], list)))

data = []
for i in range(0, M):
    l, r = input().split()
    data.append((int(l), int(r)))
data = sorted(data, key=lambda x: x[0])

import math
logM = math.floor(math.log2(M))

# 2つずつくみでしょりしたい
def saiki(totyuu):
    for i in range(0, logM):
        if len(totyuu) < 100:
            mid = int(math.floor(len(totyuu)/2))
            m1 = merge_list(totyuu[:mid])
            m2 = merge_list(totyuu[mid:])
            return merge_list([m1, m2])
        else:
            return merge_list([saiki(totyuu[:mid]), saiki(totyuu[mid:])])

data = saiki(data)
L = data[0]
R = data[1]

print(max(0, R-L+1))

### FIXED CODE ###

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

Ls = []
Rs = []
for i in range(0, M):
    l, r = input().split()
    Ls.append(int(l))
    Rs.append(int(r))

maxL = max(Ls)
minR = min(Rs)
result = max(0, minR-maxL+1)

print(result)
N, M = map(int, input().split())
pS = [list(input().split()) for i in range(M)]

for x in range(M):
    pS[x][0] = int(pS[x][0])
    
Ans, Pen = 0, 0
for x in range(M):
    if (pS[x][0] != pS[x-1][0]):
        pS_temp = 0
        Ans_temp = 0
    if (pS[x][1] == 'AC') and (pS_temp == 0):
        Ans += 1
        Ans_temp += 1
        pS_temp += 1
    elif (pS[x][1] == 'WA') and (pS_temp == 0) and (Ans_temp == 0):
        Pen += 1
print(Ans, Pen)

### FIXED CODE ###

N, M = map(int, input().split())
Q_n = [0] * N
C = [0] * N

Ans = 0
Pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if (S == 'AC') and (Q_n[p] == 0):
        Q_n[p] = 1
        Ans += 1
        Pen += C[p]
    elif (S == 'WA'):
        C[p] += 1
        
print(Ans, Pen)
H=[int(x) for x in input().split()]
way=[]
for i in range(M):
    way.append([int(x) for x in input().split()])
 
dic={}
for i in range(N):
    dic[i]=set()
 
for h in way:
    dic[h[0]-1].add(h[1]-1)
    dic[h[1]-1].add(h[0]-1)
    
 
print(sum(all([H[i]>H[hs] for hs in dic[i]])for i in range(N)))

### FIXED CODE ###

n,m=map(int,input().split())
h=list(map(int,input().split()))
dic={i:set() for i in range(n)}
for j in range(m):
  a,b=map(lambda x:int(x)-1,input().split())
  dic[a].add(b)
  dic[b].add(a)
co=0
for i in range(n):
  if all([h[i]>h[way] for way in dic[i]]):co+=1
print(co)
s=input();k=int(input())    
a=sorted({s[i:i+j+1] for i in range(len(s)) for j in range(k)}[k-1])
print(a)

### FIXED CODE ###

s=input()
k=int(input())

a=sorted({s[i:i+j+1] for i in range(len(s)) for j in range(k)})[k-1]
print(a)
"""
memo1[i] => i列目とi+1列目の間に横棒があるような場合の数
memo2[i] => i列目の両サイドに横棒がないような場合の数
"""
if W == 1:
    print(1)
    exit()
H,W,K = map(int,input().split())
mod = 10**9 +7
memo1 = [0]*(W-1)
memo2 = [0]*W
for i in range(2**(W-1)):
    #bin(i)が横棒の配置パターンを表す
    binI = format(i,"0"+str(W-1)+"b")
    #パターンが正しいかを確かめる
    for j in range(W-2):
        if binI[j]=="1" and binI[j+1]=="1":
            break
    else:
        for j in range(W-1):
            if binI[j] == "1":
                memo1[j] += 1
        if binI[0] == "0":
            memo2[0] += 1
        if binI[-1] == "0":
            memo2[-1] += 1
        for j in range(1,W-1):
            if binI[j-1]=="0" and binI[j]=="0":
                memo2[j] += 1


#dp[i][j] => i回目の移動が終わったタイミングで、j列目にいるような場合の数
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        #真下に移動する場合の数
        dp[i+1][j] += dp[i][j]*memo2[j]
        dp[i+1][j] %= mod

        #右に移動する場合の数
        if j != W-1:
            dp[i+1][j+1] += dp[i][j]*memo1[j]
            dp[i+1][j+1] %= mod

        #左に移動する場合の数
        if j != 0:
            dp[i+1][j-1] += dp[i][j]*memo1[j-1]
            dp[i+1][j-1] %= mod

print(dp[-1][K-1])

### FIXED CODE ###

"""
15,8,5の場合：
何回右に移動するか、何回左に移動するか。
dp[i][j] => i回目下降が終わった時点で、j列目にいる場合の数
memo[j] => 特定の高さを見たときに、j列目とj+1列目の間に横棒があるような横棒配置パターン数
memo2[j] => j列目の左右に横棒がないような場合の数
"""
mod = 10**9 +7
H,W,K = map(int,input().split())
if W == 1:
    print(1)
    exit()
memo = [0]*(W-1)
memo2 = [0]*(W-1)
cnt = 0
for i in range(2**(W-1)):
    binI = format(i,"0"+str(W-1)+"b")
    #パターンの有効性をチェックする
    for j in range(W-2):
        if binI[j] == "1" and binI[j+1] == "1":
            break
    else:
        cnt += 1
        for j in range(W-1):
            if binI[j] == "1":
                memo[j] += 1
        for j in range(1,W-1):
            if binI[j-1]=="0" and binI[j] =="0":
                memo2[j] += 1
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        #右の列に移動する
        if j != W-1:
            dp[i+1][j+1] += memo[j]*dp[i][j]%mod
            dp[i+1][j+1] %= mod
        #左の列に移動する
        if j != 0:
            dp[i+1][j-1] += memo[j-1]*dp[i][j]%mod
            dp[i+1][j-1] %= mod
        #真下に移動する
        if j == 0:
            dp[i+1][j] += (cnt-memo[j])*dp[i][j]%mod
        elif j == W-1:
            dp[i+1][j] += (cnt-memo[j-1])*dp[i][j]%mod
        else:
            dp[i+1][j] += memo2[j]*dp[i][j]%mod
        dp[i+1][j]%=mod

print(dp[-1][K-1])
a, b, c = list(input().split(' '))
if a[-1] = b[-1] and b[-1] = c[-1]:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a, b, c = list(input().split(' '))
if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')
from decimal import *
x=int(input())

for i in range (100):
  h=Decimal(x)-Decimal(i)**Decimal('5')
  if h<=0:
    bh=Decimal(h)**Decimal('0.2')
    if Decimal(bh)%1==0:
      print(i,int(bh))
      exit()
  else:
    hh=abs(h)
    bh=Decimal(hh)**Decimal('0.2')
    if Decimal(bh)%1==0:
      print(i,(-1)*int(bh))
      exit()

### FIXED CODE ###

x=int(input())

for i in range (200):
  for j in range (-200,200):
    if (i**5-j**5)==x:
      print(i,j)
      exit()
a,b,c=map(int, input().split(" "))
	
if a>c :
	k=c
	c=a
	a=k
if c<b :
	k=b
	b=c
	c=k
if b<a
	k=b
	b=a
	a=k
a,b,c=map(str,(a,b,c))
print(a+' '+b+' '+c)

### FIXED CODE ###

a,b,c=map(int, input().split(" "))
	
if a>c :
	k=c
	c=a
	a=k
if c<b :
	k=b
	b=c
	c=k
if b<a :
	k=b
	b=a
	a=k
a,b,c=map(str,(a,b,c))
print(a+' '+b+' '+c)
candy = input().split(" ")
if sum(candy)-max(candy) == max(candy):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

candy = list(map(int, input().split(" ")))
if sum(candy)-max(candy) == max(candy):
  print("Yes")
else:
  print("No")
import numpy as np
n,k = map(int,input().split())
a_list = sorted(map(int,input().split()))
mod = 10**9+7
if False:
  print("test")
else:
    a_list.sort(key = abs,reverse = True)
    if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
        negative_min_big = max([num for num in a_list[:k] if np.sign(num)==-1])
        positive_min_big = min([num for num in a_list[:k] if np.sign(num)!=-1])
        negative_max_small = min([num for num in a_list[k:] if np.sign(num)==-1])
        positive_max_small = max([num for num in a_list[k:] if np.sign(num)!=-1])
        if positive_max_small/negative_min_big < negative_max_small/positive_min_big:
            remove = negative_min_big
            add = positive_max_small
        else:
            remove = positive_min_big
            add = negative_max_small
ans = 1
for num in a_list[:k]:
    ans *= num
    ans %= mod
    
if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
    ans *= add
    ans %= mod
    ans *= pow(remove, mod-2, mod)
    ans %= mod
 
print(ans)

### FIXED CODE ###

import numpy as np
import sys
n,k = map(int,input().split())
a_list = sorted(map(int,input().split()))
mod = 10**9+7
if n-k < a_list.count(0):
    print(0)
    exit()
if (sum([1 for a in a_list if np.sign(a)!=-1])==0 and k%2==1) or (k==n and len([1 for a in a_list if np.sign(a)==-1])%2==1):
    a_list.sort(key = abs)
    ans = 1
    for num in a_list[:k]:
        ans *= num
        ans %= mod
    print(ans)
    exit()
else:
    a_list.sort(key = abs,reverse = True)
    add = 1
    remove = 1
    if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
        negative_big = [num for num in a_list[:k] if np.sign(num)==-1]
        positive_big = [num for num in a_list[:k] if np.sign(num)!=-1]
        negative_small = [num for num in a_list[k:] if np.sign(num)==-1]
        positive_small = [num for num in a_list[k:] if np.sign(num)!=-1]
        
        
        if len(negative_big)==0 or len(positive_small)==0:
            remove = min(positive_big)
            add = min(negative_small)
        elif len(positive_big)==0 or len(negative_small)==0:
            remove = max(negative_big)
            add = max(positive_small)
        else:
            positive_small_max = max(positive_small)
            negative_big_max = max(negative_big)
            negative_small_min = min(negative_small)
            positive_big_min = min(positive_big)
            if positive_small_max*positive_big_min > negative_small_min*negative_big_max:
                remove = negative_big_max
                add = positive_small_max
            else:
                remove = positive_big_min
                add = negative_small_min
ans = 1
for num in a_list[:k]:
    ans *= num
    ans %= mod
    
if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
    ans *= add
    ans %= mod
    ans *= pow(remove, mod-2, mod)
    ans %= mod

print(ans)
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
L=sorted(x+[X])
if N==1:
	print(abs(X-x[0]))
else:
	LL=[L[i+1]-L[i] for i in range(N)]
	def GCD(LIST):
		if len(LIST)==2:
			return math.gcd(LIST[0],LIST[1])
		else:
			return GCD([math.gcd(LIST[0],LIST[1])]+LIST[2::])
	print(GCD(LL))

### FIXED CODE ###

from functools import reduce
N,X=map(int,input().split())
x=list(map(int,input().split()))
L=x+[X]
if N==1:
	print(abs(X-x[0]))
else:
	LL=[abs(L[i+1]-L[i]) for i in range(N)]
	def gcd(a,b):
		while b>0:
			a,b=b,a%b
		return a
	print(reduce(gcd,LL))
import itertools
dic={"61":"z","62":".","63":"?","64":"!","65":" "}
cnt=ord("a")
for i in itertools.product(range(1,6),repeat=2):
    dic["".join(map(str,i))]=chr(cnt)
    cnt+=1

while True:
    try:
        s=raw_input()
    except EOFError:
        break
    if len(s)%2!=0:
        print "NA"
    else:
        print "".join(dic[s[i:i+2]] for i in range(0,len(s),2))

### FIXED CODE ###

import itertools
dic={"61":"z","62":".","63":"?","64":"!","65":" "}
cnt=ord("a")
for i in itertools.product(range(1,6),repeat=2):
    dic["".join(map(str,i))]=chr(cnt)
    cnt+=1

while True:
    try:
        s=raw_input()
    except EOFError:
        break
    if len(s)%2!=0:
        print "NA"
    else:
        try:
            print "".join(dic[s[i:i+2]] for i in range(0,len(s),2))
        except KeyError:
            print "NA"
n= int(input())
dp =[0]*3
for i in range(n):
    ndp=[0]*3
    c =list(map(int,input().split()))
    for j in range(n):
        for k in range(n):
            if j !=k:
                ndp[k] = max(ndp[k],dp[j]+c[k])
    dp = ndp
print(max(dp))
        


### FIXED CODE ###

n= int(input())
dp =[0]*3
for i in range(n):
    ndp=[0]*3
    c =list(map(int,input().split()))
    for j in range(3):
        for k in range(3):
            #print(j,k)
            if j !=k:
                ndp[k] = max(ndp[k],dp[j]+c[k])
                
    dp = ndp
    
print(max(dp))
text = input()
ans = ["k","e","y","e","n","c","e"]
count = 2
flag = 1
i = 0
plus = 0
for ob in ans:
    if i >= len(text):
        flag = 0
        break
        
    if ob == text[i]:
        i+=1
        continue
    
    else:
        while ob != text[i]:
            i+=1
            if i >= len(text) - 1:
                continue
            else:
                while text[i] == text[i+1]:
                    i+=1
                    if i >= len(text):
                        flag = 0
                        break
            if i >= len(text):
                flag = 0
                break
        i+=1
        count -=1
        if count == 0:
            flag =0
            break
if i < len(text):
    count -=1
    if count == 0:
        flag = 0
if flag == 1:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

text = input()
i = 0
ans = "keyence"
for ob_n in range(len(ans)):
    if text[i] != ans[ob_n]:
        if text.endswith(ans[ob_n:]):
            flag = 1
            break
        else:
            flag = 0
            break
    i+=1
    if i == len(text):
        flag = 1
        break
if flag == 1:
    print("YES")
else :
    print("NO")
print((int(input())//2)*(int(input())-int(input())//2))

### FIXED CODE ###

N=int(input())
print((N//2)*(N-N//2))
from collections import Counter
 
def counter(list_1):
	return reduce(lambda a,b:a*b,map(lambda x:x+1,list_1))

N=input()
S=list(input())
answer=counter(S)
print(answer)

### FIXED CODE ###

from collections import Counter
from functools import reduce
 
def counter(list_1):
	return ((reduce(lambda a,b:a*b,map(lambda x:x+1,list_1))-1)%(10**9+7))
  
N=input()
S=input()
answer=counter(Counter(S).values())
print(answer)