Problem:


Score : 200 points

Problem Statement

A string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.

Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.

Constraints

The length of S is between 7 and 100 (inclusive).

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S is a KEYENCE string, print YES; otherwise, print NO.

Sample Input 1

keyofscience

Sample Output 1

YES

keyence is an abbreviation of key of science.

Sample Input 2

mpyszsbznf

Sample Output 2

NO

Sample Input 3

ashlfyha

Sample Output 3

NO

Sample Input 4

keyence

Sample Output 4

YES



Sample input:
keyofscience


Sample output:
YES

Submission status: Accepted

Solution code:

import re

def solve(s):
    if s == 'keyence':
        return True
    if re.match(r'^([a-z]+)keyence$', s):
        return True
    if re.match(r'^k([a-z]+)eyence$', s):
        return True
    if re.match(r'^ke([a-z]+)yence$', s):
        return True
    if re.match(r'^key([a-z]+)ence$', s):
        return True
    if re.match(r'^keye([a-z]+)nce$', s):
        return True
    if re.match(r'^keyen([a-z]+)ce$', s):
        return True
    if re.match(r'^keyenc([a-z]+)e$', s):
        return True
    if re.match(r'^keyence([a-z]+)$', s):
        return True
    return False

s = raw_input().rstrip()

if solve(s):
    print 'YES'
else:
    print 'NO'

Submission status: Accepted

Solution code:
s = input()

for i in range(len(s)):
  for j in range(i + 1, len(s)):
    if s == 'keyence' or s[:i] + s[j:] == 'keyence':
      print('YES')
      raise SystemExit

print('NO')

Submission status: Accepted

Solution code:
S=raw_input()
L=len(S)
r="NO"
for i in xrange(L):
  for j in xrange(i,L):
    if S[:i]+S[j:]=="keyence":
      r="YES"
print r

Submission status: Accepted

Solution code:
s=input()
n=len(s)
f=False
for i in range(n):
  for j in range(n):
    if(i<=j):
      if(s[:i]+s[j:]=="keyence"):
        f=True
print("YES" if f else "NO")

Submission status: Accepted

Solution code:
import sys
s = input()
N = len(s)
for i in range(N):
  for j in range(i+1):
    if s[:j]+ s[i:] == "keyence":
      print("YES")
      sys.exit()
else:
  print("NO")

Submission status: Accepted

Solution code:
#!/usr/bin/python3

secret = 'keyence'
s = input()
n = len(s)
m = len(secret)

if n < m:
    print("NO")
    exit(0)

for i in range(m):
    if s[:i] + s[-(m - i):] == secret:
        print("YES")
        exit(0)

print("NO")

Submission status: Accepted

Solution code:
while(True):
    try:
        s = input()
        for i in range(len(s)):
            for j in range(i, len(s)):
                if s[:i] + s[j:] == "keyence":
                    print("YES")
                    exit()
        print("NO")
    except EOFError:
        exit()

Submission status: Accepted

Solution code:
s = raw_input().strip()
for i in range(len(s)):
	for j in range(len(s)):
		s1 = s[0:i]+s[j:]
		if s1 == "keyence":
			print "YES"
			exit()
print "NO"

Submission status: Accepted

Solution code:
s=input()
ans='NO'
for i in range(len(s)):
    for j in range(i,len(s)+1):
        if s[:i]+s[j:]=='keyence':
            ans='YES'
print(ans)

Submission status: Accepted

Solution code:
import re
S = input()
cand = [
    r'^k.*eyence$', r'^ke.*yence$', r'^key.*ence$', r'^keye.*nce$',
    r'^keyen.*ce$', r'^keyenc.*e$', r'^keyence.*$'
]
for r in cand:
    if re.match(r, S):
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
s = input()

ans = 'NO'
for i in range(len(s)):
  for j in range(i, len(s)+1):
    t = s[:i] + s[j:]
    if t == 'keyence':
      ans = 'YES'

print(ans)

Submission status: Accepted

Solution code:
S=input()
T="keyence"
N=len(S)
for i in range(N):
    for j in range(i,N+1):
        U=(S[:i]+S[j:])
        if U==T:
            print("YES")
            exit()
print("NO")

Submission status: Accepted

Solution code:
s = input()

f = False
for i in range(len(s)):
  for j in range(i,len(s)):
    if s[:i] + s[j:] == 'keyence':
      f = True

if f:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
S = input()
N = len(S)
key = "keyence"
for i in range(N + 1):
    for j in range(i, N + 1):
        if S[:i] + S[j:] == key:
            print("YES")
            quit()
print("NO")

Submission status: Accepted

Solution code:
from collections import deque
import sys
#sys.setrecursionlimit(200000)
#input = sys.stdin.readline
#n = int(input())
#x,y = map(int,input().split())
#a = list(map(int,input().split()))
s = input()
for i in range(len(s)):
    for j in range(len(s)):
        if i > j:
            continue
        if s[:i] + s[j:] == "keyence":
            print("YES")
            exit()
print("NO")

Submission status: Accepted

Solution code:
S = input()
N = len(S)
for start in range(N):
    for end in range(start, N):
        if S[:start] + S[end:] == "keyence":
            print("YES")
            exit(0)
else:
    print("NO")

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

k = "keyence"
m = len(k)

S = input()
N = len(S)

if N < m:
  print("NO")
  exit()

a = next(i for i in range(N, -1, -1) if S[:i] == k[:i])
b = next(i for i in range(N, -1, -1) if S[N-i:] == k[m-i:])

print("YES" if a + b >= m else "NO")

Submission status: Accepted

Solution code:

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

s=input().strip()

yes=0
for i in range(7):
    if s[:i]+s[-7+i:]=="keyence":
        yes=1
    #print(i,s[:i]+s[-7+i:])
if s[:7]=="keyence":    # this case is not considered in the loop
    yes=1

print("YES" if yes else "NO")

Submission status: Accepted

Solution code:
S = input()
N = len(S)
for i in range(N):
    for j in range(N):
        if i > j: continue
        if S[:i] + S[j:] == 'keyence':
            print('YES')
            exit(0)

print('NO')

Submission status: Accepted

Solution code:
import sys
S=input()
N=len(S)
for i in range(N):
    for j in range(i,N):
        T=S[0:i]
        L=S[j:N]
        if T+L=='keyence':
            print('YES')
            sys.exit()
print('NO')

Submission status: Accepted

Solution code:
s = input()
t = "keyence"

c = 0
for i in range(len(t)):
    if s[i] != t[i]:
        c = i
        break
else:
    c = 7
    
for i in range(len(t)):
    if s[-i-1] != t[-i-1]:
        c += i
        break
else:
    c += 7

if c>= 7:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input()
key = "keyence"


l = 0
r = 0
while l < len(s) and l < len(key) and s[l] == key[l]:l += 1

s = s[::-1]
key = key[::-1]
while r < len(s) and r < len(key) and s[r] == key[r]:r += 1

if (l + r) >= len(key):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
S = input()

for i in range(len(S)):
    for j in range(i,len(S)):
        if S[:i] + S[j:] == 'keyence':
            print('YES')
            exit()
print('NO')

Submission status: Accepted

Solution code:
s = input()
ok = False
for i in range(len(s)+1):
	for j in range(len(s)+1):
		if s[:i]+s[j:] == "keyence":
			ok = True
			break
if ok:
	print("YES")
else:
	print("NO")

Submission status: Accepted

Solution code:
s = input()
l = len(s)
for i in range(l):
    for j in range(i,l):
        if 'keyence' == (s[:i] + s[j:]):
            print('YES')
            exit()
print('NO')

Submission status: Runtime Error

Solution code:
s=input()
l='keyence'
x=0
n=len(s)
f=0
i=0
while(i<n):
    if(l[x]==s[i]):
        x+=1
    else:
        f+=1
        j=i
        while(j<n):
            if(l[x]==s[j]):
                x+=1
                i=j
                break
            else:
                j+=1
    i+=1
if(f<=1 and x==7):
    print("YES")
else:
    print('NO')

Submission status: Runtime Error

Solution code:
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')
    elif S = 'keyence':
        return ('YES')

    ans = 'keyence'
    i = 0
    j = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt < num:
        cnt += 1
        #print(ans[-cnt])
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())

Submission status: Runtime Error

Solution code:
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')

    ans = 'keyence'
    i = 0
    j = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt < num:
        cnt += 1
        #print(ans[-cnt])
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())

Submission status: Runtime Error

Solution code:
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')

    ans = 'keyence'
    i = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt <= num:
        cnt += 1
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())

Submission status: Runtime Error

Solution code:
import copy
s=input()
check="keyence"
tmp=0
if check in s:
  print("YES")
  exit()
for i in s:
  if i == check[tmp]:
    tmp+=1
  else:
    break
tmp2=copy.copy(tmp)
for i in s[tmp:]:
  if i != check[tmp]:
    tmp2+=1
  else:
    break

if tmp2 == len(s):
  print("NO")
  exit()

for i in s[tmp2:]:
  if i == check[tmp]:
    tmp+=1
  else:
    print("NO")
    exit()
print("YES")

Submission status: Runtime Error

Solution code:
s = str(input())
i = 0
ch = "keyence"
while len(s) > 7:
    if s[i] != ch[i]:
        s = s[:i] + s[i+1:]
    else:
        i += 1
if s == ch:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
keyence

Submission status: Runtime Error

Solution code:
S=list(input())
T=list('keyence')
A=[]
B=[]
C=[]
a=0
for i in range(len(S)):
    if S[i]==T[a]:
        A.append(i)
        a+=1
if len(A)!=7:
    print('NO')
elif A==[0,1,2,3,4,5,6]:
    print('YES')
else:
    for i in range(0,A[len(A)-1]+1):
        B.append(i)
    for i in range(len(B)):
        if B[i] not in A:
            C.append(B[i])
    if C[len(C)-1]-C[0]==len(C)-1:
        print('YES')
    else:
        print('NO')

Submission status: Runtime Error

Solution code:
S=list(input())
T=list('keyence')
A=[]
B=[]
C=[]
a=0
for i in range(len(S)):
    if S[i]==T[a]:
        A.append(i)
        a+=1
if len(A)!=7:
    print('NO')
elif len(A)==7:
    print('YES')
else:
    for i in range(0,A[len(A)-1]+1):
        B.append(i)
    for i in range(len(B)):
        if B[i] not in A:
            C.append(B[i])
    if C[len(C)-1]-C[0]==len(C)-1:
        print('YES')
    else:
        print('NO')

Submission status: Runtime Error

Solution code:
S = input()

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = i
        break

ans = True

if t:
    for i in range(1, 7 - t + 1):
        if not S[-i] == key[-i]:
            ans = False
            break

if ans:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
n = "keyence"
s = input()
cnt = 0


for i in s:
    if n[0] == i:
        n = n[1:]
        if cnt > 0:
            cnt = -1
    elif n[0] != i:
        if cnt == -1:
            break
        cnt += 1

if n == "":
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = input()
key = "keyence"
ptr = 0

for c in s:
    if c == key[ptr]:
        ptr += 1

print("YES" if ptr == 7 else "NO")

Submission status: Runtime Error

Solution code:
s = list(input())
ans = 'NO'
for i in range(len(s)):
    if ''.join(s[:i] + s[n-7+i:]) == 'keyence':
        ans = 'YES'
        break
print(ans)

Submission status: Runtime Error

Solution code:
s = input()

for i in range(1, 8):
    a, b = i, 7-i
    l, r = k[:i], k[i:]
    
    if l in s and r in s:
        print("YES")
        exit()

print('NO')

Submission status: Runtime Error

Solution code:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    s = S()
    cnt = 0
    tgt = "keyence"
    j = 0
    f = False
    for i in range(len(s)):
        if (s[i] == tgt[j]):
            j += 1
            f = True
        elif f:
            cnt += 1
            f = False
    #print(cnt,j)
    print("Yes" if cnt <= 1 and j == 7 else "No")

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline

s=input().rstrip()
t="keyence"
i,j=0,0
while len(s)>i:
    if s[i]==t[j]:
        j+=1
    i+=1
print("YES"if j==7 else "NO")

Submission status: Runtime Error

Solution code:
S = input()

"""
7<=|S|<=100
c ∈ {[a-z]}

keyaaence
keyence
"""

ref = "keyence"

if S == ref:
    print("YES")
    exit(0)

ri = 0
ci = 0

missmatch=[]

while ci < len(S):
    if ref[ri] == S[ci] and ri <= len(ref)-1:
        # match
        ri+=1
    else:
        missmatch.append(ci)

    ci += 1
if ri != len(ref):
    print("NO")
    exit(0)

ok = True
for i in range(len(missmatch)-1):
    if missmatch[i] + 1 != missmatch[i+1]:
        ok = False
# print(missmatch)
if ok:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
# coding:utf-8
s = input()
for i in range(n := len(s))
    if s[:i] + s[n-7+i:] == 'keyence':
        print('YES')
        exit()
print('NO')

Submission status: Runtime Error

Solution code:
# coding:utf-8
s = input()
for i in range(n := len(s))
	if s[:i] + s[n-7+i:] == 'keyence':
    	print('YES')
		exit()
print('NO')

Submission status: Runtime Error

Solution code:
S=input()
key="keyence"

exclude=0
now=False
count=0
for i in range(len(S)):
    s=S[i]
    if s==key[count] and count<7:
        if now:
            now=False
        count+=1
    else:
        if (not now) and exclude>0:
            print("NO")
            exit()
        if not now:
            exclude+=1
            now=True
if count!=7:
    print("NO")
else:
    print("YES")
#print(count)

Submission status: Runtime Error

Solution code:
S=input()
key="keyence"

exclude=0
now=False
count=0
for i in range(len(S)):
    s=S[i]
    if s==key[count]:
        if now:
            now=False
        count+=1
    else:
        if (not now) and exclude>0:
            print("NO")
            exit()
        if not now:
            exclude+=1
            now=True
if count!=len(S)-1:
    print("NO")
else:
    print("YES")

Submission status: Runtime Error

Solution code:
S=input()
l = len(S)
#keyencexxxxx
if s[:7]=="keyence":
  print("YES")
#kxxxxxeyence
elif s[:1]=="k" and s[l-6:]=="eyence":
  print("YES")
#kexxxxxyence
elif s[:2]=="ke" and s[l-5:]=="yence":
  print("YES")
#keyxxxxxence
elif s[:3]=="key" and s[l-4:]=="ence":
  print("YES")
#keyexxxxxnce
elif s[:4]=="keye" and s[l-3:]=="nce":
  print("YES")
#keyenxxxxxce
elif s[:5]=="keyen" and s[l-2:]=="ce":
  print("YES")
#keyencxxxxxe
elif s[:6]=="keyenc" and s[l-1:]=="e":
  print("YES")
#xxxxxkeyence
elif s[l-7:]=="keyence":
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

key = "keyence"

S = input()

l = []
j = 0
for i in range(len(S)):
	if S[i] != key[j]:
		l.append(i)
	else:
		j += 1

if j != 7:
	print("NO")
elif l == [] or l == list(range(l[0], l[-1]+1)):
	print("YES")
else:
	print("NO")

Submission status: Runtime Error

Solution code:
s = input()
n = len(s)
w = "keyence"

for i in range(7):
    if S[:i] == w[:i] and s[n-7+i:] == w[i:]:
        print("YES")
        exit()

print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
ans = list("keyence")
x = 0

for c in s:
    if c == ans[x]:
        x += 1

if x >= 6:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s=str(input())
st=list(s)
l=len(st)
if st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[5]=="c" and st[6]=="e":
  print("YES")
elif st[l-7]=="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[5]=="c" and st[l-1]=="e":
  print("YES")
else:
  ptint("NO")

Submission status: Runtime Error

Solution code:
s=str(input())
st=list(s)
l=len(st)
if st[0]="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" st[4]=="n" and st[5]=="c" and st[6]=="e":
  print("YES")
elif st[l-7]="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]="k" and st[1]=="e" and st[l-5]=="y" and st[l-4]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]="k" and st[1]=="e" and st[2]=="y" and st[l-4]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" st[4]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" st[4]=="n" and st[5]=="c" and st[l-1]=="e":
  print("YES")
else:
  ptint("NO")

Submission status: Runtime Error

Solution code:
def main():
    S = input()

    str_key = 'keyence'

    tmp = 0
    for s in S:
        if s == str_key[tmp]:
            tmp += 1
    if tmp == 7:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
S=input()

ans='NO'
if 'keyence'in S:
    ans='YES'
elif S.find('k')>=0 and S.find('k')<S.rfind('eyence'):
    ans='YES'
elif S.find('ke')>=0 and S.find('ke')<S.rfind('yence'):
    ans='YES'
elif S.find('key')>=0 and S.find('key')<S.rfind('ence'):
    ans='YES
elif S.find('keye')>=0 and S.find('keye')<S.rfind('nce'):
    ans='YES'
elif S.find('keyen')>=0 and S.find('keyen')<S.rfind('ce'):
    ans='YES'
elif S.find('keyenc')>=0 and S.find('keyenc')<S.rfind('e'):
    ans='YES'

print(ans)

Submission status: Runtime Error

Solution code:
a=input()
c=len(a)
d=c-7
for i in range(8):
  if a[:i]+a[-(7-i):]=="keyence" or a[:i]=="keyence" or a[-(7-i):]=="keyence":
    print("YES")
    sys.exit()
print("NO")

Submission status: Runtime Error

Solution code:
s=input()
for i in range(len(s)):
    for j in range(i,len(s)+1):
        if s[:i]+s[j]=="keyence":
            print("YES")
            exit()
print("NO")

Submission status: Runtime Error

Solution code:
S = input()
target = "keyence"
length = len(target)+1

if target in S:
    print("YES")
    exit()
else:
    for i in range(1, length):
      first = target[:i]
      second = target[i:]
      if first in S and second in S and S.find(first) < S.rfind(second):
          if S[0:len(first)] + S[len(target)-len(second):len(target)]] == target:
                print("YES")
                exit()
print("NO")

Submission status: Runtime Error

Solution code:
S = input()
target = "keyence"
length = len(target)

for i in range(length):
  first = target[:i]
  second = target[i:]
  if first == '' and second in S  or first != '' first in S and second in S and S.find(first) <= S.find(second):
    print("YES")
    exit()
print("NO")

Submission status: Runtime Error

Solution code:
import sys, re
input = sys.stdin.readline().rstrip()

S = input()

if S == 'keyence' or re.fullmatch(r'[a-z]+keyence', S) or re.fullmatch(r'k[a-z]+eyence', S) or re.fullmatch(r'ke[a-z]+yence', S) or re.fullmatch(r'key[a-z]+ence', S) or re.fullmatch(r'keye[a-z]+nce', S) or re.fullmatch(r'keyen[a-z]+ce', S) or re.fullmatch(r'keyenc[a-z]+e', S) or re.fullmatch(r'keyence[a-z]+', S):
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
S = input()

key = list("keyence")

k = 0
f = True
cnt = 0
for i in range(len(S)):
    if S[i] == key[k]:
        f = True
        k+=1
    else:
        if f :
            cnt+=1
        f = False
        

if cnt >1 or k != len(key):
    print("NO")
else:
    print("YES")

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
s  = input()
#  = int(input())
#  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

query = list('keyence')

import re

for p in range(8):
    b = ''.join(query[:p])
    a = ''.join(query[p:])

    pattern = f'.*{b}.*{a}.*'
    if re.findall(pattern, s):
        print('YES')
        break
else:
    print('NO')

Submission status: Runtime Error

Solution code:
s = input()

chkStr = ["k","e","y","e","n","c","e"]

inpStr = list(s)
idx = 0

chkCount = 0


# print(chkStr)
# print(inpStr)

for i in range(len(inpStr)):
    if chkStr[idx] == inpStr[i]:
        idx += 1
        chkCount += 1
    
    if idx - 1 == len(chkStr):
        break


if chkCount == len(chkStr):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A=["k","e","y","e","n","c","e"]
f=-1;p=0;q=0;r=0
S=list(map(str,input()))
if S[0:7]==A or S[len(S)-7:len(S)]==A:
  f=1
else:
  if S[0]!=A[0]:
    f=0
  else:    
    for i in range(len(S)):
      if S[i]==A[i-q]:
        p=p+1
        r=0
      else:
        if q>0 and r==0:
          f=0
          q=q+1
          
        else:
          r=1
          q=q+1
if f==0:
  print("NO")
  
elif f==1:
  print("YES")
  
else:
  if p==7 and (p+q)==len(S):
    print("YES")
    
  else:
    print("NO")

Submission status: Runtime Error

Solution code:
A=["k","e","y","e","n","c","e"]
f=-1;p=0;q=0;r=0
S=list(map(str,input()))
if S[0:7]==A or S[len(S)-7:len(S)]==A:
  f=1
else:
  if S[0]!=A[0]:
    f=0
  else:    
    for i in range(len(S)):
      if S[i]==A[i-q]:
        p=p+1
        r=0
      else:
        if q>0 and r==0:
          f=0
          break
        else:
          r=1
          q=q+1
if f==0:
  print("NO")
  
elif f==1:
  print("YES")
  
else:
  if p==7 and (p+q)==len(S):
    print("YES")
    
  else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = input()
o = ""
c = 'keyence'
j = 0
l = []
for i in range(len(s)):
    if(s[i] == c[j]):
        j += 1
        l.append(i)
c = 0
l.append(len(s))
for i in range(len(l) - 1):
    if(l[i+1]-l[i] > 1):c += 1
if(c > 1 or len(l) != 8):print('NO')
else:print('YES')

Submission status: Runtime Error

Solution code:
s = list(input())
n = len(s)

if "".join(s) == "keyence":
	print("YES")
	eixt()

for i in range(n):
	ss = s[::]
	for j in range(i, n):
		ss.pop(i)
		print("".join(ss))
		if "".join(ss) == "keyence":
			print("YES")
			break
	else:
		continue
	break
else:
	print("NO")

Submission status: Runtime Error

Solution code:
s = list(input())
k_index = []
k = list('keyence')

for i in range(len(s)):
    if s[i] == k[0]:
        k_index.append(i)

ans = 'NO'
for i in k_index:
    j = 0
    flag = 0
    for a in s[i:]:
        if a == k[j]:
            j += 1
            if flag == 0:
                flag = 1 # reading 1st half
            elif flag == 2:
                flag = 3 # reading 2nd half
            if j == len(k):
                ans = 'YES'
        elif flag == 1: # end of 1st half
            flag = 2 # reading middle
        elif flag == 3:
            break

print(ans)

Submission status: Runtime Error

Solution code:
s = input()
k = 'keyence'
i = 0
flag = 0
ans = 'YES'
for a in s:
    if a == k[i]:
        i += 1
        if flag == 0:
            flag = 1 # reading 1st half
        elif flag == 2:
            flag = 3 # reading 2nd half
    elif flag == 1: # end of 1st half
        flag = 2 # reading middle
    elif flag == 3:
        ans = 'NO'
        break

if flag == 0:
    ans = 'NO'
print(ans)

Submission status: Runtime Error

Solution code:
s = input()
k = 'keyence'
i = 0
inds = []
ans = 'NO'
for a,x in enumerate(s):
    if x==k[i]:
        i+=1
        inds.append(a)
    if i==6:
        c = 0
        for z in range(i-1):
            if inds[z+1]-inds[z]>1:
                c+=1
        if c<=1:ans='YES'
print(ans)

Submission status: Runtime Error

Solution code:
S = input()
keyence_len = len("keyence")
keyence="keyence"

now=0
remove=False
removeout=False
for i in range(len(S)):
    if S[i]==keyence[now]:
        if remove:
            removeout = True
        now+=1
    else:
        if removeout:
            print("NO")
            exit()
        remove=True
if now==keyence_len:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
# B - KEYENCE String
def is_keyence_string():
	for i in range(1, len(key)):
		left = key[:i]
		right = key[i-len(key):]
		
		if S.startswith(left) and S.endswith(right):
			return True
	
	return False


S = input().trim()
key = 'keyence'

if S.startswith(key):
	print('YES')
elif S.endswith(key):
	print('YES')
elif is_keyence_string():
	print('YES')
else:
	print('NO')

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

# B - KEYENCE String
def is_keyence_string():
	i = 0

	for s in S:
		if s == key[i]:
			i += 1
			if i == len(key) and S.endswith('e'):
				return True

	return False


S = input()
key = 'keyence'

if S.find(key) > -1:
	print('YES')
elif is_keyence_string():
	print('YES')
else:
	print('NO')

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    ke="keyence"
    cunt=0
    cunt_str=0
    flag=False
    for i in range(len(s)):
        if s[i]==ke[cunt]:
            cunt+=1
            flag=False
        elif cunt_str==0 and flag==False:
            flag=True
            cunt_str+=1
        elif flag==False and cunt_str==1:
            print("NO")
            break
        print(i,s[i],flag)
    else:
        if cunt==7:print("YES")
        else:print("NO")

if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
S = input()

ans_str = "keyence"

if S[0:7] == ans_str:
    print("YES")
    exit()

if S[len(S)-7:len(S)] == ans_str:
    print("YES")
    exit()

count_check_str = 0
count_insert = 0
count_ans_str = 0
for i in range(len(S)):
    if S[i] == ans_str[count_ans_str]:
        count_check_str += 1
        count_ans_str += 1
        if count_insert == 1:
            count_insert = 2
    else:
        if count_insert == 2:
            print("NO")
            exit()
        count_insert = 1

if count_check_str < 6:
    print("NO")
    exit()
print("YES")

Submission status: Runtime Error

Solution code:
s = input()
sa = "keyence"
sl = 0
for i in range(len(s)):
    if s[i] == sa[sl]:
        sl += 1
if sl == len(sa) and s[0] == sa[0] and s[-1] == sa[-1]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s = input()
sa = 'keyence'
sl = 0
for i in range(len(s)):
    if s[i] == sa[sl]:
        sl += 1
if sl == len(sa) and s[0] == sa[0] and s[-1] == sa[-1]:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
dum1 = min(a,b)
dum2 = max(a,b)
ans = ""
for i in range(dum2):
  ans += str(dum1)
print(ans)

Submission status: Runtime Error

Solution code:
S=input()
moji="keyence"
i=0
j=0
while i<len(S):
    if S[i]==moji[j]:
        i+=1
        j+=1
    else:
        i+=1
if j==7:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
s=input()
t="keyence"
i=0
for x in s:
    if t[i]==x:i+=1
print("YES" if i>6 else "NO")

Submission status: Runtime Error

Solution code:
import sys
S=(input())

key=['k','e','y','e','n','c','e']
ans=''
i=0
number=[]

if(S=="keyence"):
    print("YES")
    sys.exit()

for n,s in enumerate(S):
    if(s==key[i]):
        ans+=s
        i+=1
    else:
        number.append(n)

pre=number.pop(0)
a=pre
for n in number:
    if(pre!=(n-1)):
        print("NO")
        sys.exit()
    pre=n
if(ans!="keyence"):
    print('NO')
else:
    print('YES')

Submission status: Runtime Error

Solution code:
S = input()

target = "keyence"
now = 0
start = None
end = None
for i in range(len(S)):
    if target[now] == S[i]:
        now += 1
        if start is not None and end is None:
            end = i
    elif start is not None:
        continue
    else:
        start = i

if start is None:
    pred = S
elif end is None:
    pred = S[:start]
else:
    pred = S[:start] + S[end:]

if pred == target:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
S = input()
ls = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
is_ng = True
for i in range(len(S)-len(ls)+1):
    if S[i] == 'k':
        idx = 0
        tmp = 0
        for j in range(i, len(S)):
            if S[j] == ls[idx]:
                if tmp == 1:
                    tmp = 2
                idx += 1
            else:
                if tmp == 0:
                    tmp = 1
                elif tmp==2:
                    break
                continue
            if idx == len(ls):
                is_ng = False
print('YNEOS'[is_ng::2])