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)+1):
        if S[:i] + S[j:] == 'keyence':
            print('YES')
            exit()
print('NO')

Submission status: Accepted

Solution code:
S = input()
if (S[0:7] == 'keyence') or (S[-7:] == 'keyence'):
  print("YES")
else:
  flag = 0
  for i in range(1,7):
    if S[:i] + S[-(7-i):] == 'keyence':
      print("YES")
      flag=1
      break
  if flag==0:
    print("NO")

Submission status: Accepted

Solution code:
s=input()
n=len(s)
a=str()
b=str()
k='keyence'
l='ecneyek'
j=0
for i in range(n):
  if a+s[i] in k:
    a+=s[i]
    j=i+1
  else:
    break
for i in range(7-j):
  if b+s[n-i-1] in l:
    b+=s[n-i-1]
  else:
    break
if a+b[::-1]==k:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
s = input()
l = len(s)
cond = False
for i in range(8):
	if s[:i] + s[-(7-i):] == "keyence":
		cond = True

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

flg = False
for i in range(len(S)):
    for j in range(len(S)-i):
        if S[:j]+S[j+i:] == 'keyence':
            flg = True
            break
    if flg: break

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

Submission status: Accepted

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

Submission status: Accepted

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

idx = 0
for i in range(len(s)):
    if i < len(t):
        if s[i] != t[i]:
            idx = i
            break
    elif i == len(t):
        print('YES')
        exit()

for i in range(idx,len(s)):
    if s[:idx] + s[i:] == t:
        print('YES')
        exit()

print('NO')

Submission status: Accepted

Solution code:
import sys

S = input()

K = len(S)-7
N = len(S)

for i in range(N-K+1):
    s = S[0:i] + S[i+K:]

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

print("NO")

Submission status: Accepted

Solution code:
import sys
s = input()
l = len(s) - 7
for i in range(l+8):
    if (s[:i] + s[i+l:]) == 'keyence':
        print('YES')
        sys.exit()
print('NO')

Submission status: Accepted

Solution code:
import sys

S = input()

for i in range(7):

    #print (S[:i] , S[-(7-i):])
    if S[:i] + S[-(7-i):] == "keyence":
        print ("YES")
        sys.exit()

if S[:7] == "keyence":
    print ("Yes")
    sys.exit()
print ("NO")

Submission status: Accepted

Solution code:
T = 'keyence'
S = input()

s = 0
t = 0
while t < len(T) and s < len(S):
    if T[t] != S[s]:
        if T[t:] == S[-(len(T) - t):]:
            print('YES')
            exit()
        else:
            print('NO')
            exit()
        break
    t += 1
    s += 1

print('YES')

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0, 8):
	T = S[:i] + S[N-7+i:]
	if T == 'keyence':
		flg = 1

ans = 'YES' if flg else 'NO'
print(ans)

Submission status: Accepted

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

key = 'keyence'

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
s=input()
ans = "NO"
l = len(s)
if s[:7] == "keyence" or s[-7:] == "keyence":
	ans = "YES"

for i in range(7):
	if s[:i]+s[-(7-i):] == "keyence":
		ans = "YES"
print(ans)

Submission status: Accepted

Solution code:
S = input()
A = "keyence"
N = len(S)

flag = False
for i in range(N):
    for j in range(i, N):
        if S[:i]+S[j:] == A:
            flag = True

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

Submission status: Accepted

Solution code:
s = input()

keyence = 'keyence'

k = 0
while s[k] == keyence[k]:
    k += 1
    if k == 7:
        print('YES')
        exit()

t = k - 7
if s[t:] == keyence[t:]:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
S = list(input())
key = 'keyence'
ans = 'NO'
if len(S) == 7:
    if ''.join(S) == key:
        print('YES')
        exit()
    else:
        print('NO')
        exit()
for i in range(len(S)):
    tmp = S[0: i] + S[i + len(S) - 7:]
    if key == ''.join(tmp):
        ans = 'YES'
        break
print(ans)

Submission status: Accepted

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

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(S: str):

    N = len(S)
    if any([(S[0:i]+S[i+N-7:N]) == 'keyence' for i in range(N)]):
        print(YES)
    else:
        print(NO)


    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

keyence = "keyence"
ans = "NO"

for i in range(len(keyence) + 1):
  head, tail = keyence[:i], keyence[i:]
  if s.startswith(head) and s.endswith(tail):
    ans = "YES"
    
print(ans)

Submission status: Accepted

Solution code:
S = input().strip()
flag = 0
if S=="keyence":
    flag = 1
else:
    for i in range(len(S)-1):
        for j in range(i+1,len(S)):
            x = S[:i]+S[j:]
            if x=="keyence":
                flag = 1
                break
        if flag==1:break
if flag==1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s=input()
a="keyence"
# if a in s:
#     print("YES")
#     exit()
for i in range(len(a)):
    if a[:i] in s:
        b=s.index(a[:i])
        if b!=0:
            if i==len(a)-1:
                pass
            else:
                continue
        if a[i:] in s[b:]:
            c=s.index(a[i:])
            #print(s.index(a[i:]),s[s.index(a[i:]):],a[i:])
            if s[c:]==a[i:]:
                print("YES")
                exit()
            else:
                while True:
                    #try:
                    if c+1>=len(s):
                        break
                    if a[i:] in s[c+1:]:
                        #print(c,s[c+1:])
                        d=s[c+1:].index(a[i:])
                        if d==0:
                            if s[c+1:]==a[i:]:
                                print("YES")
                                exit()
                            else:
                                c+=1
                                continue
                        #print(s[c+1:],a[i:],d)
                        c+=d
                        #print(c,s[c:],a[i:])
                        if s[c:]==a[i:]:
                            print("YES")
                            exit()
                    else:
                        break
                    # except:
                    #     break
                    
                
print("NO")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
s=list(input())
cnt=''
ans='NO'
for i in range(len(s)):
    for j in range(len(s)):
        if i<=j<=i+len(s)-8:
            continue
        cnt+=s[j]
    #print(cnt)
    if cnt=='keyence':
        ans='YES'
        break
    else:
        cnt=''
print(ans)

Submission status: Accepted

Solution code:
s=list(input())
cnt=''
ans='NO'
for i in range(len(s)):
    for j in range(len(s)):
        if i<=j<=i+len(s)-8:
            continue
        else:
            cnt+=s[j]
    #print(cnt)
    if cnt=='keyence':
        ans='YES'
        break
    else:
        cnt=''
print(ans)

Submission status: Accepted

Solution code:
s = input()

for l in range(len(s)-1):
    for r in range(l,len(s)):
        ss = s[:l]+s[r:]
        #print(ss)
        if ss == "keyence":
            print("YES")
            exit()
print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

x = "keyence"
for i in range(1,7):
    if s[0:i] == x[0:i] and s[-(7-i):] == x[i:7]:
        print("YES")
        exit()
        
print("NO")

Submission status: Accepted

Solution code:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = list(str(input().rstrip('\n')))
    for i in range(len(s)):
        for j in range(i + 1, len(s)):
            if "".join(s[:i + 1] + s[j:]) == "keyence":
                print("YES")
                exit()
    print("NO")


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# 2019-11-28 00:55:58(JST)
import sys
def main():
    s = sys.stdin.readline().rstrip()

    t = 'keyence'

    for i in range(8):
        if t[:i] == s[:i] and t[i:] == s[len(s)-7+i:len(s)]:
            ans = 'YES'
            break
    else:
        ans = 'NO'

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# 2019-11-28 00:55:58(JST)
import sys
def main():
    s = sys.stdin.readline().rstrip()

    t = 'keyence'
    for i in range(8):
        if t[:i] == s[:i] and t[i:] == s[-(7-i):]:
            ans = 'YES'
            break
    else:
        ans = 'NO'

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=input()
ks='keyence'
f=False
for i in range(8):
    # print(S[:i],S[-(7-i):],ks[:i],ks[-(7-i):]) #DB
    if S[:i]==ks[:i] and S[-(7-i):]==ks[-(7-i):]: # i=7で怪しい
        f=True
        break

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

Submission status: Accepted

Solution code:
S = input()
if len(S) == 7:
  if S == "keyence":
    print("YES")
  else:
    print("NO")
  exit()
T = len(S) - 7
for i in range(1,T+1):
  tmp = ""
  l = 0
  while l + i < len(S):
    tmp = S[:l] + S[l+i:]
    if tmp == "keyence":
      print("YES")
      exit()
    l += 1
print("NO")

Submission status: Accepted

Solution code:
S = input()
if S == "keyence":
  print("YES")
  exit()
if S[0] != "k":
  if S[-7:] == "keyence":
    print("YES")
  else:
    print("NO")
elif S[1] != "e":
    if S[-6:] == "eyence":
      print("YES")
    else:
      print("NO")
elif S[2] != "y":
    if S[-5:] == "yence":
      print("YES")
    else:
      print("NO")
elif S[3] != "e":
    if S[-4:] == "ence":
      print("YES")
    else:
      print("NO")
elif S[4] != "n":
    if S[-3:] == "nce":
      print("YES")
    else:
      print("NO")
elif S[5] != "c":
    if S[-2:] == "ce":
      print("YES")
    else:
      print("NO")
elif S[6] != "e":
    if S[-1] == "e":
      print("YES")
    else:
      print("NO")

Submission status: Accepted

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

ok = False
for l in range(N):
  for r in range(l, N):
    if S[:l] + S[r:] == 'keyence':
      ok = True
if ok:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
n=input()
a,b="keyence",0
for i,j in zip(a,n):
    if i==j:
        b+=1
    else:break
for i,j in zip(a[::-1],n[::-1]):
    if i==j:
        b+=1
    else:break
print("YES" if b>=7 else "NO")

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

S = ns()
start = 0
end = 0
S2 = 'keyence'
for i in range(7):
    if S[i] == S2[i]:
        start += 1
    else:
        break
for i in range(-1, -8, -1):
    if S[i] == S2[i]:
        end += 1
    else:
        break
print('YES' if start + end >= 7 else 'NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
goal = "keyence"
if S.startswith(goal) or S.endswith(goal):
    print("YES")
else:
    for i in range(len(S)-1):
        if S.startswith(goal[:len(S)-i]) and S.endswith(goal[len(S)-i:]):
            print("YES")
            exit(0)
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


S = sys.stdin.readline().rstrip()


def solve(S):
    key = 'keyence'
    ok = False
    for i in range(len(S)):
        ok |= S.startswith(key[:i]) and S.endswith(key[i:])
    return ok


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
S = input()
flag = False
res = re.match(r'.*keyence$',S)
if res :
  flag = True
res = re.match(r'^k.*eyence$',S)
if res :
  flag = True
res = re.match(r'^ke.*yence$',S)
if res :
  flag = True
res = re.match(r'^key.*ence$',S)
if res :
  flag = True
res = re.match(r'^keye.*nce$',S)
if res :
  flag = True
res = re.match(r'^keyen.*ce$',S)
if res :
  flag = True
res = re.match(r'^keyenc.*e$',S)
if res :
  flag = True
res = re.match(r'^keyence.*',S)
if res :
  flag = True
if flag :
  print('YES')
else :
  print('NO')

Submission status: Accepted

Solution code:
S=input()
k="keyence"
ans=False
if len(S)<len(k):
  ans=False
elif S[:len(k)]==k or S[-len(k):]==k:
  ans=True
else:
  for i in range(len(S)):
    if S[i]==k[i]:
      continue
    else:
      break
  rest=k[i:]
  if S[-len(rest):]==rest:
    ans=True
  else:
    ans=False
print(("NO","YES")[ans])

Submission status: Accepted

Solution code:
def main():
  s=input()
  k="keyence"
  if len(s)<7:
    print("NO")
    return
  if s[:7]==k or s[-7:]==k:
    print("YES")
    return
  for i in range(1,7):
    if s[:i]==k[:i] and s[i-7:]==k[i-7:]:
      print("YES")
      return
  print("NO")
main()

Submission status: Accepted

Solution code:
s = list(input())

key = list("keyence")

for i in range(len(s)):
    if s[i] == key[i]:
        continue
    else:
        check = i
        break
else:
    print("YES")
    exit()
    
if key[check:] == s[check-7:]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    S = input()
    
    if S.startswith('keyence'):
        print("YES")
        sys.exit()
        
    if S.endswith('keyence'):
        print("YES")
        sys.exit()
        
    key = "keyence"
    for i in range(1, len(key)):
        key_s = key[:i]
        key_e = key[i:]
        
        if S.startswith(key_s) and S.endswith(key_e):
            print("YES")
            sys.exit()
            
    print("NO")
    
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    keyence = 'keyence'

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

    List = []
    for i in range(len(keyence)):
        List.append((keyence[0:i], keyence[i:len(keyence)]))

    ans = "NO"

    for left, right in List:
        l = len(left)
        r = len(right)
        if s[0:l] == left and s[-r:] == right:

            ans = "YES"

    print(ans)
    return


main()

Submission status: Accepted

Solution code:
S = input()
keyence = 'keyence'
List = []
for i in range(len(keyence)):
  List.append((keyence[0:i],keyence[i:len(keyence)]))
Answer = 'NO'
for A,B in List:
  a = len(A)
  b = len(B)
  if S[0:a] == A and S[-b:] == B:
    Answer = 'YES'
    break
print(Answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

c = 'keyence'
flag = False
for i in range(8):
    if s[:i] == c[:i] and s[i-7:] == c[i:]:
        flag = True
        break

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

Submission status: Accepted

Solution code:
from sys import stdin
S = (stdin.readline().rstrip())
flag = False
for i in range(0,len(S)+1):
    for j in range(0,len(S)+1):
        if j >= i:
            if S[:i]+S[j:] == "keyence":
                flag = True
if flag:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue
from heapq import heappop, heappush
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = list(input())
n = len(s)
t = list('keyence')
ll = n - 7
for i in range(8):
    ss = s[::]
    for j in range(ll):
        del ss[i]
    if ss == t:
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
S = input()

for left in range(len(S) + 1):
    for right in range(len(S) + 1):
        T = list(S[:left]) + list(S[right:])
        if ''.join(T) == 'keyence':
            print('YES')
            exit()
print('NO')

Submission status: Accepted

Solution code:
S=input()
T="keyence"
X,Y=0,0
for i in range(7):
  if(S[i]==T[i]):
    X+=1;
  else:
    break
for i in range(7):
  if(S[len(S)-1-i]==T[6-i]):
    Y+=1;
  else:
    break
if(X+Y>=7):
  print("YES")
else:
  print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(k)):
    if s[:i] == k[:i] and s[-len(k)+i:] == k[-len(k)+i:]:
        print('YES')
        exit()

if s[:len(k)] == k:
    print('YES')
    exit()

print('NO')

Submission status: Accepted

Solution code:
s=str(input())
n=len(s)
for i in range(n):
    for k in range(i,n):
        if s[:i]+s[k:]=='keyence':
            print('YES')
            break
    else:
        continue
    break
else:
    print('NO')

Submission status: Accepted

Solution code:
s=list(input())
n=len(s)
for i in range(8):
    t=s[:]
    for j in range(n-7):
        t[i+j]=""
    if ''.join(t)=="keyence":
        print("YES")
        exit()

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()
lens = len(s)
for i in range(lens):
  for j in range(i, lens+1):
    ss = s[:i] + s[j:]
    #print(ss)
    if ss == "keyence":
      print("YES")
      exit()
print("NO")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s=input();n=len(s);print("YNEOS"[all(s[:i]+s[j:]!="keyence"for i in range(n)for j in range(i,n))::2])

Submission status: Accepted

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


print(ans)

Submission status: Accepted

Solution code:
s = input()

w = "keyence"
ans = "NO"

# keyencexxxxx
if s[:7] == w:
    ans = "YES"

# xxxxkeyence
if s[-7:] == w:
    ans = "YES"

# key xxx ence
for i in range(1, 7):
    ss = w[:i]
    tt = w[-7+i:]
    if s[: len(ss)] == ss and s[-len(tt):] == tt:
        ans = "YES"
        break

print(ans)

Submission status: Accepted

Solution code:

import sys
def input():
	return sys.stdin.readline().strip()

S = input()
target = 'keyence'

if S[0] != target[0]:
	if S[-7:] == target:
		print("YES")
	else:
		print("NO")
elif S[-1] != target[-1]:
	if S[0:7] == target:
		print("YES")
	else:
		print("NO")
else:
	num = 0
	i = 0
	while i < 7 and S[i] == target[i]:
		num += 1
		i += 1
	i = 0
	while i < 7 and S[-i-1] == target[-i-1]:
		num += 1
		i += 1
	if num >= 7:
		print("YES")
	else:
		print("NO")

Submission status: Accepted

Solution code:
# 2019/09/22

import re

s=input()
k='keyence'
n=len(s)

if re.search(r'^keyence',s) or re.search(r'keyence$',s):
    ans='YES'

rem=n-7
for i in range(n-rem+1):
    tmp=s[:i]+s[i+rem:]
    if tmp==k:
        ans='YES'
        break
else:ans='NO'
print(ans)

Submission status: Accepted

Solution code:
S = input()
K = 'keyence'

for i in range(1, len(S)):
    for j in range(i, len(S)):
        left = S[:i]
        right = S[j:]
        if left + right == K:
            print('YES')
            exit()

print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
s=':'+s+':'
t='keyence*'
fo,ba=0,0
while s[fo+1]==t[fo]:
    fo+=1
t='*keyence'
while s[ba-2]==t[ba-1]:
    ba-=1
if fo-ba>6:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
def main():

    S = input()
    n = len(S)
    if n < 7: return "NO"
    for i in range(7):
        if S[:i] + S[-7+i:] == "keyence":
            return "YES"
    return "NO"

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a="keyence"
s=input()
#print(s[:7],s[-7:])
if a==s[:7] or a==s[-7:]:
  print("YES")
else:
  i=0
  sw=0
  while 1:
    if a[i]==s[i]:
      i+=1
    else:
      break
  while 1:
    if a[i]==s[-7+i]:
      i+=1
    else:
      sw=1
      break
    if i==7:
      break
  print("NO" if sw==1 else "YES")

Submission status: Accepted

Solution code:
S = input()
target_S = "keyence"
flg = 0
 
if S.startswith(target_S) or S.endswith(target_S):
    flg = 1
else:
    for i in range(len(target_S)):
        target_left = target_S[:i]
        target_right = target_S[i:]
        
        if S.startswith(target_left) and S.endswith(target_right):
            flg = 1

print("YES") if flg == 1 else print("NO")

Submission status: Accepted

Solution code:
import re
S = input()
key = "keyence"
if re.fullmatch(r'(.*keyence)|(k.*eyence)|(ke.*yence)|(key.*ence)|(keye.*nce)|(keyen.*ce)|(keyenc.*e)|(keyence.*)', S):
    ans = True
else:
    ans = False



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

Submission status: Accepted

Solution code:
from re import fullmatch
S = input()
_s = "keyence"
flag = False
for i in range(len(_s)):
    tmp = fullmatch("(.*)" + _s[:i] + "(.*)" + _s[i:] + "(.*)", S)
    if tmp and sum([1 for j in range(1, 4) if tmp.group(j)]) <= 1:
        flag = True
print("YES") if flag else print("NO")

Submission status: Accepted

Solution code:
import re

def solve():
    S = input()
    for i in range(8):
        p = "keyence"
        p = p[:i] + ".*" + p[i:] 
        if re.fullmatch(p, S):
            return "YES"
    return "NO"

print(solve())

Submission status: Accepted

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

ans = False
for i in range(N):
  for j in range(i,N):
    if S[:i]+S[j:] == "keyence":
      print("YES")
      ans = True
      break
  if ans: break
else:
  print("NO")

Submission status: Accepted

Solution code:
def resolve():
    s = input()
    ls = len(s)
    for i in range(ls):
        for j in range(i, ls):
            if s[:i] + s[j:] == "keyence":
                print("YES")
                return 0
    print("NO")
    return 0


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input();print("YNEOS"[all("keyence"[:i]!=s[:i]or"keyence"[i-7 or len(s):]!=s[i-7 or len(s):]for i in range(8))::2])

Submission status: Accepted

Solution code:
S=input()
L=len(S)
Key="keyence"

for i in range(8):
    if i==0:
        temp=S[L-7:L+1]
    elif 1<=i<=6:
        temp=S[0:i]+S[L+i-7:L+1]
    else:
        temp=S
    if temp == Key:
        print("YES")
        exit()
print("NO")

Submission status: Accepted

Solution code:
S=list(input())
L=len(S)
Key="keyence"

for i in range(8):
    if i==0:
        temp="".join(S[L-7:L+1])
    elif 1<=i<=6:
        temp="".join(S[0:i])+"".join(S[L+i-7:L+1])
    else:
        temp="".join(S)
    if temp == Key:
        print("YES")
        exit()
print("NO")