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:
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 = list(input())
tf = [False for _ in range(7)]
key = list("keyence")
for n in range(7):
    if S[n] == key[n]:
        tf[n] = True
    else:
        break
for n in range(1, 8):
    if S[-n] == key[-n]:
        tf[-n] = True
    else:
        break
if all(tf):
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

if "keyence" == s:
    print("YES")
    exit()

for i in range(n):
    for j in range(i+1, n):
        if s[:i] + s[j:] == "keyence":
            print("YES")
            exit()

print("NO")

Submission status: Accepted

Solution code:
s = input()
k = 'keyence'
k_size = len(k)
d_size = len(s) - k_size

result = "NO"
for i in range(k_size):
    t = s[:i] + s[i+d_size:]
    if t == k:
        result = "YES"
        break
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
str = 'keyence'
pattern_keyence = []
for i in range(len(str)+1):
    pattern_keyence.append(r'{}'.format(str[:i]+'.*'+str[i:]))
for p in pattern_keyence:
    if re.fullmatch(p,S):
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
s=input()
n=len(s)
for i in range(n):
    tmp=s[:i]+s[i+n-7:]
    if tmp=="keyence":
        print("YES")
        exit()
print("NO")

Submission status: Accepted

Solution code:
import re,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
str = 'keyence'
pattern_keyence = []
for i in range(len(str)+1):
    pattern_keyence.append(str[:i]+'.*'+str[i:])
for x in pattern_keyence:
    if re.fullmatch(x,S):
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
count = 0
for i,j in itertools.combinations_with_replacement(range(len(S)+1),2):
    if S[:i]+S[j:]=='keyence':
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
for i,j in itertools.combinations(range(len(S)+2),2):
    if S[:i]+S[j-1:]=='keyence':
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
import re,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
p1 = r'.*keyence'
p2 = r'k.*eyence'
p3 = r'ke.*yence'
p4 = r'key.*ence'
p5 = r'keye.*nce'
p6 = r'keyen.*ce'
p7 = r'keyenc.*e'
p8 = r'keyence.*'
if re.fullmatch(p1,S) or re.fullmatch(p2,S) or re.fullmatch(p3,S) or re.fullmatch(p4,S) or re.fullmatch(p5,S) or re.fullmatch(p6,S) or re.fullmatch(p7,S) or re.fullmatch(p8,S):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
import sys

S = input()
target = "keyence"
del_len = len(S) - len(target)

for i in range(len(S) - del_len+1):
    s = S[:i] + S[i + del_len:]
    if s==target:
        print("YES")
        sys.exit()
print("NO")

Submission status: Accepted

Solution code:
S = input()
ans = "NO"
for i in range(len(S)):
  for j in range(len(S)):
    if S[0:i] + S[i+j:len(S)] == "keyence":
      print("YES")
      exit()
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[22]:


S = input()


# In[24]:


keyence = "keyence"
length = len(keyence)
flag = True
for i in range(len(keyence)):
#     print(S[:i+1], keyence[:i+1], S[-length+i+1:], keyence[-length+i+1:])
    if S[:i+1] == keyence[:i+1]:
        if S[-length+i+1:] == keyence[-length+i+1:]:
            print("YES")
            flag = False
            break
if flag:
    print("NO")


# In[ ]:

Submission status: Accepted

Solution code:
k = list('keyence')
s = list(input())
while len(k) > 0:
    if k[0] == s[0]:
        k.pop(0)
        s.pop(0)
    else:
        break
while len(k) > 0:
    if k[-1] == s[-1]:
        k.pop()
        s.pop()
    else:
        break
if len(k) == 0:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
A=input()
if A=="keyence" or A[:7]=="keyence" or A[-7:]=="keyence":
   print("YES")
   exit()
for i in range(6):
   if A[:i+1]+A[-6+i:]=="keyence":
      print("YES")
      exit()
print("NO")

Submission status: Accepted

Solution code:
S = input()

key = list("keyence")
target = 'keyence'

flg = False
for i in range(len(S)):
    for j in range(len(S)):
        tmp = S[0:i]+S[j:]

        if tmp == target and not flg:
            print("YES")
            flg = True
            break

if not flg:
    print("NO")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

S = input()
key = 'keyence'
K = []

if key in S:
    print('YES')
    exit()


for i in range(len(key)+1):
    K.append([key[:i],key[i:]])

for i in range(len(K)):
    if S[:len(K[i][0])] == K[i][0] and S[len(S)-len(K[i][1]):] == K[i][1]:
        print('YES')
        exit()
print('NO')

Submission status: Accepted

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:])

    pattern1 = r'{}{}'.format(b, a)
    pattern2 = r'^{}.*{}$'.format(b, a)
    #print(re.findall(pattern1, s))
    #print(re.findall(pattern2, s))
    if re.findall(pattern1, s) or re.findall(pattern2, s):
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

S = input()
key = 'keyence'
K = []

if key in S:
    print('YES')
    exit()


for i in range(len(key)+1):
    K.append([key[:i],key[i:]])

for i in range(len(K)):
    if K[i][0] in S and K[i][1] in S:
        if S[0] == 'k' and S[-1] == 'e':
            print('YES')
            exit()
print('NO')

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    s = IS()
    n = len(s)
    m = n-7
    for i in range(0,n-m):
        if s[:i]+s[i+m:] == 'keyence':
            print('YES')
            return None
    print('NO')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
T = input()
for f in range(8):
    b = 7-f
    if b and (T[:f] + T[-b:] == "keyence"):
        print("YES")
        exit()
    elif T[-7:] == "keyence":
        print("YES")
        exit()
print("NO")

Submission status: Accepted

Solution code:
#キーエンスプログラミングコンテスト2019-B
s = input()

target = 'keyence'
flg = False
for i in range(len(s)):
    for j in range(len(s)):
        tmp = s[0:i] + s[j:]
        if tmp == target and not flg:
            print('YES')
            flg = True
            break
if not flg:
    print('NO')

Submission status: Accepted

Solution code:
s = "0"+input()+'0'
l = len(s)-2
for i in range(1,l+1):
  for j in range(i,l+1):
    a = s[:i]+s[j:]
    if a=="0keyence0":
      print("YES")
      exit()
print("NO")

Submission status: Accepted

Solution code:
S = input()
ans = "keyence"
for i in range(7):
    #print(S[:i],ans[:i],S[-7+i:],ans[-7+i:])
    if S[:i] == ans[:i] and S[-7+i:] == ans[-7+i:]:
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
def main():
    S = list(input())
    tmp = list('keyence')
    st = -1; ed = -1
    if S[0] == tmp[0]:
        st = 0
        for i in range(1, len(tmp)):
            if S[i] == tmp[i]:
                st += 1
            else:
                break
    if st+1 == len(tmp):
        print('YES')
        return
    if S[-1] == tmp[-1]:
        ed = 0
        for i in range(1, len(tmp)):
            if S[-1-i] == tmp[-1-i]:
                ed += 1
            else:
                break
    if ed+1 == len(tmp):
        print('YES')
        return
    if st == -1 or ed == -1:
        print('NO')
        return
    rm = (st+1 + ed+1) - len(tmp)
    if rm >= 0:
        s = tmp[:st+1] + tmp[-ed-1+rm:]
        if s == tmp:
            print('YES')
    else:
        print('NO')

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

import sys

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

Submission status: Accepted

Solution code:
import itertools

S = list(input())
KEY = list('keyence')
LK = len(KEY)
L = len(S)
ok = False
for s,t in itertools.combinations(range(L),2):
  idx = 0
  sub_S = S[0:s] + S[t:]
  if sub_S == KEY:
    ok = True
    
if ok or S == KEY:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
S = str(input())

str_keyence = "keyence"

if S.find("keyence")==0 or S.rfind("keyence")==len(S)-7:
  print("YES")
else:
  for i in range(1,7):
      #print(str_keyence[0:i],str_keyence[i:])
      #print(S.find(str_keyence[0:i]))
      #print(S.find(str_keyence[i:]))
      if S.find(str_keyence[0:i])==0 and S.rfind(str_keyence[i:])==len(S)-len(str_keyence[i:]):
          print("YES")
          break
  else:
      print("NO")

Submission status: Accepted

Solution code:
S = input()
L = len(S)

if(S == 'keyence'):
    print('YES')
    exit()

for i in range(L):
    count = 0
    for j in range(i, L):
        if (i == 0 and count == 0):
            s = S[1:]
        elif(i == L - 1):
            s = S[:i]
        else:
            s = S[:i] + S[i + count + 1:]

        if (s == 'keyence'):
            print('YES')
            exit()
        else:
            count += 1

print('NO')

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

Solution code:
S = input()

match = "keyence"
check = ""
revcheck = ""

flag = False

for x in range(len(S)):
    if x == len(match):
        break
    if match[x] == S[x]:
        check += S[x]
    else:
        flag = True
        break

if flag:
    remainFlag = False
    remain = match[x:]
    revS = "".join(reversed(S))
    revMatch = "".join(reversed(remain))
    for y in range(len(revS)):
        # print(revS[y])
        if y == len(revMatch):
            remainFlag = True
            break
        if revMatch[y] == revS[y]:
            revcheck += revS[y]
        else:
            break
    if remainFlag:
        print("YES")
    else:
        print("NO")
elif check == match:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
S = input()
ans = "NO"
for i in range(len(S)):
  for j in range(len(S)):
    if S[0:i] + S[i+j:len(S)] == "keyence":
      print("YES")
      exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
s = input()
t = 'keyence'
#分割区間を固定して、先頭・末尾のマッチング
for i in range(len(t)+1):
    if s.startswith(t[:i+1]) and s.endswith(t[i+1:]):
        print('YES');exit()
print('NO')

Submission status: Accepted

Solution code:
S = str(input())
N = len(S)
for i in range(N-1):
    for j in range(i+1, N):
        tmp = S[:i+1] + S[j:]
        if tmp == 'keyence':
            print('YES')
            quit()

print('NO')

Submission status: Accepted

Solution code:
s=input()
k="keyence"
if s.find(k,0,7)!=-1 or s.find(k,len(s)-7)!=-1:
    print("YES")  
    exit()
for i in range(1,7):
    a=s.find(k[:i],0,len(k[:i]))
    if a==0:
        b=s.find(k[i:],len(s)-len(k[i:]))
        if b!=-1:
            print("YES")
            exit()
print("NO")

Submission status: Accepted

Solution code:
s=input()
for i in range(7):
  if s[:i]+s[i-7:]=="keyence":
    print("YES")
    exit()
print('NO')

Submission status: Accepted

Solution code:
S = input()
 
for i in range(7):
	if S[:i] + S[i-7:] == "keyence":
		print("YES")
		exit()
print("NO")

Submission status: Accepted

Solution code:
S = input()

for i in range(7):
	if S[:i] + S[i-7:] == "keyence":
		print("YES")
		exit()
print("NO")

Submission status: Accepted

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

target = 'keyence'

for i in range(n):
	for j in range(i, n):
		res = s[:i] + s[j:]
		if res == target:
			print('YES')
			exit()

print('NO')

Submission status: Accepted

Solution code:
A=list("keyence")
f=-1;p=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]:
        p=p+1
      else:
        if A[0:p]+S[len(S)-(len(A)-p):len(S)]==A:
          f=1
          break
        else:
          f=0
          break
print("YES" if f==1 else "NO")

Submission status: Accepted

Solution code:
A=["k","e","y","e","n","c","e"]
f=-1;p=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]:
        p=p+1
      else:
        if A[0:p]+S[len(S)-(len(A)-p):len(S)]==A:
          f=1
          break
        else:
          f=0
          break
print("YES" if f==1 else "NO")

Submission status: Accepted

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]:
        p=p+1
      else:
        if A[0:p]+S[len(S)-(len(A)-p):len(S)]==A:
          #print(A[0:p]+S[len(S)-(len(A)-p):len(S)])
          f=1
          break
        else:
          f=0
          break
print("YES" if f==1 else "NO")

Submission status: Accepted

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

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

    print('NO')
    
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans = 'NO'
pattern = 'keyence'

for i in range(len(pattern) + 1):
    x = s[:i]
    y = s[::-1][:len(pattern) - i][::-1]
    if x + y == pattern:
        ans = 'YES'
        break

print(ans)

Submission status: Accepted

Solution code:
import re

def main():
    N = str(input())
    if re.match("^.*keyence$", N) or re.match("^k.*eyence$", N) or re.match("^ke.*yence$", N) or re.match("^key.*ence$", N) or re.match("^keye.*nce$", N) or re.match("^keyen.*ce$", N) or re.match("^keyenc.*e$", N) or re.match("^keyence.*$", N):
        print("YES")
    else:
        print("NO")



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
t = 'keyence'
if(s[:7] == t or s[-7:] == t):
    print('YES')
else:
    for i in range(7):
        if(s[:i+1] == t[:i+1] and s[-7+i+1:] == t[-7+i+1:]):
            print('YES')
            exit()
    print('NO')

Submission status: Accepted

Solution code:
s = input()
for i in range(8):
    b = i
    e = i+len(s)-7
    if s[:i]+s[e:]=='keyence':
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
import re
def main():
  S = input()
  if 'keyence' in S:
    print('YES')
    return
  
  if re.match(r'^k[a-z]*eyence$', S) or re.match(r'^ke[a-z]*yence$', S) or re.match(r'^key[a-z]*ence$', S) or re.match(r'^keye[a-z]*nce$', S) or re.match(r'^keyen[a-z]*ce$', S) or re.match(r'^keyenc[a-z]*e$', S):
    print('YES')
  else:
    print('NO')
  return

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
s = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
length=len(S)
ans='NO'
if S[0:7]=='keyence':
    ans='YES'
elif S[-7:]=='keyence':
    ans='YES'
elif S[0]=='k' and S[-6:]=='eyence':
    ans='YES'
elif S[0:2]=='ke' and S[-5:]=='yence':
    ans='YES'
elif S[0:3]=='key' and S[-4:]=='ence':
    ans='YES'
elif S[0:4]=='keye' and S[-3:]=='nce':
    ans='YES'
elif S[0:5]=='keyen' and S[-2:]=='ce':
    ans='YES'
elif S[0:6]=='keyenc' and S[-1:]=='e':
    ans='YES'

print(ans)

Submission status: Accepted

Solution code:
import re
S=input()
keyence = 'keyence'
patterns = []
for i in range(len(keyence)):
    patterns.append('^'+keyence[:i]+'[a-z]*'+keyence[i:]+'$')
for p in patterns:
    if re.match(p,S):
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
S = input()
N = len(S)

for i in range(7+1):
  if S[:i] + S[i+N-7:] == "keyence":
    print("YES")
    exit()
print("NO")

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    S = input()
    L = len(S)
    ans = 'NO'
    for i in range(0,8):
        s = S[:i] + S[L-7+i:]
        if s == 'keyence':
            ans = 'YES'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
l = len(S)
out = l - 7
ans = 'NO'
for i in range(7):
    s = S[:i] + S[i+out:]
    if s == 'keyence':
        ans = 'YES'
print(ans)

Submission status: Accepted

Solution code:
# Problem B - KEYENCE String

# input
s = input()
s_l = len(s)

# initialization
is_ok = False

# check
for i in range(s_l):
    for j in range(i, s_l):
        tmp_s = s[:i] + s[j:]
        if tmp_s=='keyence':
            is_ok = True
            break

# output
if is_ok:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
def myAnswer(S:str) -> str:
   N = len(S) - 7
   for i in range(N,len(S)):
      # print(S[:i-N],S[i:])
      if(S[:i-N]+S[i:] == "keyence"):
         return "YES"
   return "NO"



def modelAnswer():
   return
def main():
   S = (input())
   print(myAnswer(S))
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
s = input()
k = 'keyence'

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

print('NO')

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
s = input()
n = len(s)
yes = False
for i in range(n):
    for j in range(i, n):
        if (s[: i] + s[j :]) == "keyence":
            yes = True
            break
    if yes:
        break
if yes:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input()

l = len(s)
d = l - 7

for i in range(7):
    if s[:i] + s[(i + d):] == "keyence":
        print("YES")
        break
    elif i == 6:
        print("NO")

Submission status: Accepted

Solution code:
S = input()
key = 'keyence'
index_num = -1
for i in range(len(key)):
    if S[i] != key[i]:
        index_num = i
        break
else:
    print('YES')
    exit()
string = S[:index_num] + S[-len(key)+index_num:]
print('YES' if string == key else 'NO')

Submission status: Accepted

Solution code:
S = input()
if S == "keyence":
    print("YES")
    exit()
for s in range(len(S)):
    for e in range(s, len(S)):
        string = S[:s] + S[e:]
        if string == "keyence":
            print("YES")
            exit()
print("NO")

Submission status: Accepted

Solution code:
s1="keyence"
s=input()
k=-1
for i in range(len(s)):
    if s[i]!=s1[i]:
        k=i
        break
if k==-1:
    print("YES")
else:
    if s[:k]+s[len(s)-7+k:]==s1:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
s = input()
if len(s) < 7:
  print("NO")
else:
  if s[:7] == "keyence" or s[-7:] == "keyence":
    print("YES")
  else:
    flag = True
    for i in range(1, 7):
      if s[:i]+s[i-7:] == "keyence":
        flag = False
        print("YES")
        break
    if flag:
      print("NO")

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''

    S = input()

    is_flag = False
    key = 'keyence'

    for i in range(8):
        if i == 0:
            if S[-7:] == key:
                is_flag = True

        elif 1 <= i < 7:
            if S[:i] == key[:i] and S[-1*(7-i):] == key[-1*(7-i):]:
                is_flag = True
        else:
            if S[:7] == key:
                is_flag = True

    print('YES') if is_flag else print('NO') 


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
S = input()
key = 'keyence'
ok = False
for i in range(8):
    # print(S[i-8:i])
    if i == 7:
        j = S[:7]
    else:
        j = S[:i] + S[i-7:]
    if key == j:
        ok = True

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

Submission status: Accepted

Solution code:
s = list(input())
key = list("keyence")
index = 0
ans = "NO"
n = len(s)
for i in range(8):
    mid = n-7
    tmp = s[:i] + s[i+mid:]
    if tmp == key:
        ans = "YES"
print(ans)

Submission status: Accepted

Solution code:
s = list(input())


ans = 0

for i in range(len(s)+1):
    for j in range(i, len(s) + 1):
        if s[:i] + s[j:] == list("keyence"):
            ans = 1
            break
if ans:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

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:
S=input()
N=len(S)
if S=="keyence":
    print("YES")
    exit()
for i in range(N):
    for j in range(i,N):
        tmp=""
        for k in range(N):
            if i<=k and k<=j:
                continue
            tmp=tmp+S[k]
        if tmp=="keyence":
            print("YES")
            exit()

print("NO")

Submission status: Accepted

Solution code:
s=input()
print('NYOE S'[any([s[:i]=='keyence'[:i] and s[len(s)-7+i:]=='keyence'[i:] for i in range(8)])::2])

Submission status: Accepted

Solution code:
s=input()
flags=True
for i in range(8):
    if s[:i]=='keyence'[:i] and s[len(s)-7+i:]=='keyence'[i:]:
        print('YES')
        flags=False
        break
if flags:
    print('NO')

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, 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
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

S = input()
N = len(S)
for l in range(N):
	for r in range(l, N):
		if S[:l] + S[r:] == "keyence":
			print("YES")
			exit()
print("NO")