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:
def main():
  s = str(input())
  keyence = 'keyence'
  for i in range(len(keyence)+1):
    prefix = keyence[:i]
    postfix = keyence[i:]
    if s.startswith(prefix) and s.endswith(postfix):
      print('YES')
      return
  print('NO')


if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]
# 


s = input()
key = "keyence"
ind = 0

if s[:7] == key or s[7:] == key:
    print("YES")
else:
    ind = 0
    while ind < 7:
        if s[ind] == key[ind]:
            ind += 1
        else:
            break

    flag = True
    for i in range(7 - ind):
        if s[-i-1] != key[-i-1]:
            flag = False
            break
    if flag:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
S = input()

sample = 'keyence'
flag = True

for i in range(7):
    if S[i] != sample[i]:
        if S[-(7-i):] == sample[-(7-i):]:
            print('YES')

        else:
            print('NO')
        
        flag = False
        break

if flag:
    print('YES')

Submission status: Accepted

Solution code:
import sys

s=input()

target="keyence"
j=0
mismatch=0

for i in range(len(target)):
    if target[:i]==s[:i] and target[i:]==s[-7+i:]:
        print('YES')
        sys.exit()
print('NO')

Submission status: Accepted

Solution code:
import math
import copy

def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l

string=input()
removeSize=len(string)-7
target="keyence"
pairs=list()
for idx in range(0,7):
    pair=[target[:idx],target[idx:]]
    pairs.append(pair)
result="NO"
for pair in pairs:

    if string[:len(pair[0])]==pair[0] and string[-len(pair[1]):]==pair[1]:
        result="YES"
print(result)

Submission status: Accepted

Solution code:
import re

patterns = [
  r'^.*keyence$',
  r'^k.*eyence$',
  r'^ke.*yence$',
  r'^key.*ence$',
  r'^keye.*nce$',
  r'^keyen.*ce$',
  r'^keyenc.*e$',
  r'^keyence.*$',
]

def solve(S):
  for pattern in patterns:
    if re.match(pattern, S):
      return 'YES'
  return 'NO'

S = input()

print(solve(S))

Submission status: Accepted

Solution code:
sK = "keyence"

sS = input().rstrip()
if sS == sK or sS.startswith(sK) or sS.endswith(sK):
    print("YES")
else:
    for i in range(1,len(sK)):
        if sS.startswith(sK[:i]) and sS.endswith(sK[i:]):
            print("YES")
            exit()
    print("NO")

Submission status: Accepted

Solution code:
def main(s):
    for x in range(len(s)):
        for y in range(x, len(s)):
            if s[0:x] + s[y:] == 'keyence':
                return 'YES'
    return 'NO'

print(main(input()))

Submission status: Accepted

Solution code:
S = input()

keyword = "keyence"

if S[0] != 'k':
    if S[-7:] == keyword:
        print("YES")
    else:
        print("NO")
elif S[-1] != 'e':
    if S[:7] == keyword:
        print("YES")
    else:
        print("NO")
else:
    for i in range(1, len(keyword)):
        if S[:i] == keyword[:i] \
            and S[-7+i:] == keyword[-7+i:]:
            print("YES")
            exit(0)
    print("NO")

Submission status: Accepted

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

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    s = input()
    n = len(s)

    key = 'keyence'
    if n == 7:
        if s == key:
            print("YES")
            return 0
        else:
            print("NO")
            return 0

    for i in range(n):
        pre = s[:i]
        suf = s[i+(n-7):]
        dump(pre)
        dump(suf)
        if (pre+suf == key):
            print("YES")
            return 0

    print("NO")
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}

Submission status: Accepted

Solution code:
s = input()
 
n = len(s)
nozoku = n - 7

ans = 'NO'

if nozoku == 0:
    if s == 'keyence':
        ans = 'YES'
else:
    
    for i in range(8):
        if s[:i] + s[i+nozoku:] == 'keyence':
            ans = 'YES'
            break
   
    
print(ans)

Submission status: Accepted

Solution code:
s = str(input())
n = len(s)
if s == "keyence":
 print("YES")
 exit()
else:
 for I in range(8):
  t = s[0:I]+s[I+n-7:n]
  if t == "keyence":
   print("YES")
   exit()
print("NO")

Submission status: Accepted

Solution code:
def main():
    """
    問題が 3問出題され、
    1問目の配点は A点以下、
    2問目の配点は A+1点以上 B点以下、
    3問目の配点は  B+1点以上である。
    """
    S = input()
    ans = f(S)
    if ans:
        print("YES")
    else:
        print("NO")


def f(S):
    n = len(S)
    ok = False
    target = "keyence"
    for i in range(n):
        for j in range(i, n):
            # print(S[:i], S[i:j], S[j:])
            if S[:i] == target:
                return True
            elif S[:i] + S[j:] == target:
                return True
            elif S[j:] == target:
                return True

    return False


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
s="keyence"
ss=input()
a=7
b=7
for i in range(7):
 if ss[i]!=s[i]:
    a=i
    break
for i in range(7):
 if ss[-(i+1)]!=s[-(i+1)]:
    b=i
    break

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

Submission status: Accepted

Solution code:

import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    if S == "keyence":
        print "YES"
        return
    for i in range(len(S)):
        for j in range(len(S)):
            new_S = S[:i] + S[j:]
            if new_S == "keyence":
                print "YES"
                return

    print "NO"

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
need = "keyence"
s = input()
n = len(s)
m = len(need)
ir = set()
ir.add(s)
for i in range(1, m+1):
    if n >= i and n - m + i + 1 >= i:
        ir.add(s[0:i] + s[n - m + i:])
#for i in ir:
    #print(i)
if need in ir:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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


def solve():
    S = input()
    for i in range(len('keyence')+1):
        if S.startswith('keyence'[:i]) and S.endswith('keyence'[i:]):
            print('YES')
            return
    print('NO')


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

num=0
if S[0]=="k":
    num=1
    for i in range(1,7):
        if S[i]==key[i]:
            num+=1
        else:
            break
    if num==7:
        print "YES"
    else:
        for i in range(1,8-num):
            if S[-i]==key[-i]:
                num+=1
            else:
                break
        if num==7:
            print "YES"
                    
if num<7:
    for i in range(1,8):
        if S[-i]==key[-i]:
            num+=1
        else:
            break
    if num==7:
        print "YES"
    else:
        print "NO"

Submission status: Accepted

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

def solve():
    s = input()
    k = 'keyence'
    if s.startswith(k) or s.endswith(k):
        print("YES")
        return

    for i in range(len(k)):
        start = k[:i]
        end = k[i:]
        if s.startswith(start) and s.endswith(end):
            print("YES")
            return
    print("NO")

if __name__=="__main__":
    solve()

Submission status: Accepted

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

    elim_len = len(kstring) - 7

    for i in range(len(kstring) - elim_len + 1):
        cand_str = kstring[:i] + kstring[i+elim_len:]
        #print(cand_str)
        if cand_str == 'keyence':
            print('YES')
            return
    print('NO')
    return

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math as mt
import itertools as it
import functools as ft
import random as rnd

stdin = lambda type_ = "int", sep = " ": list(map(eval(type_), input().split(sep)))
joint = lambda sep = " ", *args: sep.join(str(i) if type(i) != list else sep.join(map(str, i)) for i in args)

s = input()

if len(s) < 7:
    print('NO')
else:
    for i in range(0, 8):
        if s[:i] + s[-7 + i:] == 'keyence':
            print('YES')
            exit(0)
    print("NO")

Submission status: Accepted

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

if S[0] == 'k':
    flag = True
    for i in range(1, 7):
        if S[i] != ans[i]:
            flag = False
            break
    if flag:
        print('YES')

    else:
        if ans[i:] == S[-len(ans[i:]):]:
            print('YES')
        else:
            print('NO')
else:
    if S[-7:] == ans:
        print('YES')
    else:
        print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
S = str(input())
s = list(S)
L = len(s)
break2 = 0
text = ""
for i in range(L):
    j = 0
    for j in range(L):
        t = copy.deepcopy(s)
        del t[i:j+1]
        text = "".join(t)
        if text == "keyence":
            print("YES")
            break2 = 1
            break
        else:
            pass
    if break2 == 1:
        break
if break2 == 0:
    print("NO")

Submission status: Accepted

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

    i = 0
    while True:
        if S[i] != keyence[i]:
            break

        if i == len(keyence) - 1:
            print("YES")
            return

        i += 1

    res = len(keyence) - i

    i = -res
    while True:
        if S[i] != keyence[i]:
            print("NO")
            return

        if i == -1:
            print("YES")
            return

        i += 1

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

w = 'keyence'
l = len(w)
flag = False
for i in range(l):
	f = w[:i]
	b = w[-(l-i):]
	sf = S[:i]
	sb = S[-(l-i):]
	if f == sf and b == sb:
		print('YES')
		flag = True
		break

if not flag:
	print('NO')

Submission status: Accepted

Solution code:
S = input()
ch = 'keyence'
for i in range(len(ch)+1):
    ch1 = ch[:i]
    ch2 = ch[i:]

    if ch1 == S[:i] and ch2 == S[-len(ch2):]:
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
S = input()

head = 0
back = 0

key = 'keyence'

for i in range(len(key)):
    if S[:i+1] == key[:i+1]:
        head = i+1

for i in range(len(key)):
    if S[len(S)-i-1:] == key[len(key)-i-1:]:
        back = i+1

if head + back >= len(key):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
def main():
    S = input()
    lenS = len(S)
    for i in range(lenS):
        for j in range(i, lenS):
            ss = S[0:i+1] + S[j+1:lenS]
            if ss == "keyence":
                return "YES"
    return "NO"

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

Submission status: Accepted

Solution code:
import sys

S=input()

L="keyence"

for i in range(7):
    if L[:i]==S[:i] and L[i:]==S[-(7-i):]:
        print("YES")
        break

else:
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
i = 0
key = "keyence"
while i < 7:
    if s[i] == key[i]:
        i += 1
    else:
        break
    if i == 7:
        print("YES")
        exit()

if s[:i] + s[-7+i:] == key:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
def has_keyence(S):
    if S.startswith('keyence'):
        return 'YES'
    elif S.endswith('keyence'):
        return 'YES'
    else:
        check = [['k', 'eyence'],
                 ['ke', 'yence'],
                 ['key', 'ence'],
                 ['keye', 'nce'],
                 ['keyen', 'ce'],
                 ['keyenc', 'e']]
        for c in check:
            if S.startswith(c[0]) and S.endswith(c[1]):
                return 'YES'
    return 'NO'

S = input()
print(has_keyence(S))

Submission status: Accepted

Solution code:
S = input()

keyence = 'keyence'

ans = 'NO'
if S[0] != 'k':
    if S[-7:] == keyence:
        ans = 'YES'

for i in range(7):
    if S[:i] == keyence[:i]:
        if S[i-7:] == keyence[i-7:]:
            ans = 'YES'

print(ans)

Submission status: Accepted

Solution code:
s = "keyence"
s1 = raw_input()
ans = "NO"
for i in range(len(s)):
	fhalf = s[:i]
	shalf = s[i:]
	if s1[0:len(fhalf)] == fhalf and s1[len(s1) - len(shalf):] == shalf:
		ans = "YES"
print ans

Submission status: Accepted

Solution code:
def is_keyence(s):
    n = len(s)

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

    print ("NO")

S = input()
is_keyence(S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ans = "NO"
N = len(S)

for i in range(N):
    for j in range(i, N + 1):
        tmp = (S[:i] + S[j:])
        if tmp == "keyence":
            ans = "YES"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

isOk = False

for k in range(8):
    if k == 0:
        temp = S[-7:]
    elif k == 7:
        temp = S[:7] 
    else:
        temp = (S[0:k] + S[-(7 - k):])
    if temp == test:
        isOk = True

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

Submission status: Accepted

Solution code:
S = input()
key = 'keyence'
for i in range(len(key) + 1):
  pre = key[:i]
  post = key[i:]
  p = len(S) - len(key) + i
  if S[:i] == pre and S[p:] == post:
    print('YES')
    break
else:
  print('NO')

Submission status: Accepted

Solution code:
N = str(input())   # 単純な入力
# input = list(input()) # ひとかたまりの文字列をリスト化
# N = int(input())  # 整数一つ
# input = input().split()   # スペース区切りを文字としてリスト化
# X,Y = map(int,input().split())  # ２個や３個の整数をそれぞれ取得
for i in range(len(N)):
    for j in range(i,len(N)):
        if N[0:i] + N[j:len(N)] == "keyence":
            print("YES")
            exit()
print("NO")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from itertools import product
S = input()
cur = 0
ans = False
for i, j in product(range(len(S)), range(len(S))):
    if i >= j:
        continue
    if S[:i] + S[j:] == 'keyence':
        ans = True
print(['NO', 'YES'][ans or S == 'keyence'])

Submission status: Accepted

Solution code:
KEYENCE = 'keyence'
S = input()
ans = False
for i in range(len(KEYENCE)):
    if S.startswith(KEYENCE[:i]) and S.endswith(KEYENCE[i:]):
        ans = True
        break
if ans:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
k = "keyence"

pre = None
for i in range(1,7+1):
    if s[:i]==k[:i]:
        pre = i

if pre is None:
    print("NO")
elif pre==7:
    print("YES")
elif k[pre:]==s[-(7-pre):]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input().strip()

if s[:7]=="keyence" or s[0]+s[-6:]=="keyence" or s[:2]+s[-5:]=="keyence" or s[:3]+s[-4:]=="keyence" or s[:4]+s[-3:]=="keyence" or s[:5]+s[-2:]=="keyence" or s[:6]+s[-1]=="keyence" or s[-7:]=="keyence":
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
Ss = input()

for i in range(8):
    if Ss[:i] + Ss[-7+i:] == 'keyence':
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:

def main():
    buf = input()
    S = buf
    if S[0:len("keyence")] == "keyence" or S[len(S)-len("keyence"):len(S)] == "keyence":
        print("YES")
        return
    for i in range(len("keyence")):
        if S[0:i] == "keyence"[0:i] and S[len(S)-(len("keyence")-i):len(S)] == "keyence"[i:len("keyence")]:
            print("YES")
            return
    print("NO")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

judge = "NO"
for i in range(N):
	for j in range(i, N + 1):
		if S[0:i] + S[j:] == "keyence":
			judge = "YES"

print(judge)

Submission status: Accepted

Solution code:
def main():
    S = input()
    keyence = "keyence"
    for i in range(len(keyence)+1):
        if S.startswith(keyence[:i]) and S.endswith(keyence[i:]):
            print("YES")
            return
    print("NO")
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

s = input()
if s == 'keyence':
    print('YES')
    exit()

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

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    S = input()
    l = len(S)
    r = "keyence"
    for i in range(min(l, 7)):
        if S[i] != r[i]: break
    for j in range(1, min(l, 7) + 1):
        if S[-j] != r[-j]: break
    j -= 1
    return i + j >= 7


if __name__ == "__main__":
    print(["NO", "YES"][main()])

Submission status: Accepted

Solution code:
t="keyence"
S=input()
def judge(S):
    for i in range(7):
        if S[i]!=t[i]:
            for j,s in zip(range(6,i-1,-1),S[i:][::-1]):
                if t[j]!=s: return False
    return True
print(["NO","YES"][judge(S)])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = input()
ans=False
for i in range(1, 8):
    if s[0:i]+s[len(s)-(7-i):len(s)]=='keyence':ans=True
print('YES' if ans else 'NO')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

S = input()
if S == 'keyence':
    print("YES")
else:
    cands = [S[:i]+S[j:] for i, j in itertools.combinations(range(len(S)), 2)]
    if 'keyence' in cands:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
S = input()
l = len(S)
for f in range(l+1):
  for t in range(f, l+1):
    if S[:f] + S[t:] == 'keyence':
      print('YES')
      exit()
print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B
S = input()
compare = "keyence"
j = -1
for i in range(7):
    if S[i] != compare[i]:
        j = i
        break
if j >= 0:
    if S[-(7-j):] == compare[-(7-j):]:
        print("YES")
    else:
        print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
s_all = input()
# s_all = "keyofscience"
for i in range(8):
    if i < 7:
        if s_all[:i] + s_all[-(7-i):] == "keyence":
            print("YES")
            break
    else:
        if s_all[:i] == "keyence":
            print("YES")
            break
else:
    print("NO")

Submission status: Accepted

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

print("NO")

Submission status: Accepted

Solution code:
import re


S = input()

if re.match('^keyence$', S):
    print('YES')
elif re.match('^(.+)keyence$', S):
    print('YES')
elif re.match('^k(.+)eyence$', S):
    print('YES')
elif re.match('^ke(.+)yence$', S):
    print('YES')
elif re.match('^key(.+)ence$', S):
    print('YES')
elif re.match('^keye(.+)nce$', S):
    print('YES')
elif re.match('^keyen(.+)ce$', S):
    print('YES')
elif re.match('^keyenc(.+)e$', S):
    print('YES')
elif re.match('^keyence(.+)$', S):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
S = input()
key = 'keyence'
for i in range(7):
    x = key[:i]
    y = key[i:]
    if S[:i] == x and S[-7+i:] == y:
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
p, s = input(), "keyence"
n = len(s)
ok = False
for i in range(n):
    if p.startswith(s[:i]) and p.endswith(s[i:]):
        ok = True
        break
print("YES" if ok else "NO")

Submission status: Accepted

Solution code:
s = input()
res = False
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[:i]+s[j:] == "keyence":
            res = True

if res:
    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)+1):
        if s[:i] + s[(j):] == "keyence":
            print("YES");
            exit(0);

print("NO");

Submission status: Accepted

Solution code:
S = input()
k = "keyence"
n = 0
ans = False
for i in range(8):
    if i==0:
        if S[-7:] == k:
            ans = True
    elif i==7:
        if S[:7]==k:
            ans = True
    else:
        if S[:i]==k[:i] and S[-(7-i):]==k[-(7-i):]:
            ans = True
if ans:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

S = input()


def solve(S):
    remove = len(S) - 7
    if remove == 0:
        return S == 'keyence'
    for i in range(len(S) - remove + 1):
        T = S[:i] + S[i+remove:]
        if T == 'keyence':
            return True
    return False
    
if solve(S):
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

print('NO')

Submission status: Accepted

Solution code:
s = raw_input().strip()
t = 'keyence'
for i in xrange(7):
    if s[i] != t[i]:
        break
else:
    i = 8
for j in xrange(7):
    if s[-j-1] != t[-j-1]:
        break
else:
    j = 8
print "YES" if i + j >= 7 else "NO"

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


S = s_in()

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

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

Submission status: Accepted

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

print("NO")

Submission status: Accepted

Solution code:
K = "keyence"
N = len(K)


def judge(s):
    for i in range(N + 1):
        if s.startswith(K[:i]) and s.endswith(K[i:]):
            return True
    else:
        return False


def main():
    print("YES" if judge(input()) else "NO")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

#a = [int(i) for i  in input().split()]

s = input()
a = len(s)
ok=0
for i in range(a):
    for j in range(i,a):
        c = s[:i]+s[j:]
#        print(c)
        if c == 'keyence':
            ok = 1
        
if ok:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

def solve():
    if s.startswith(K) or s.endswith(K):
        return "YES"
    else:
        for i in range(len(K)):
            head = K[:i]
            tail = K[i:]
            if s.startswith(head) and s.endswith(tail):
                return "YES"
    return "NO"

print(solve())

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