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

Solution (Python):
S = input()
if S[0:7] == "keyence":
    print("YES")
elif S[len(S)-7:len(S)] == "keyence":
    print("YES")
else:
    if (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")
    else:
        print("NO")

Solution (Python):
s = input()
import re
ans=[]
ans.append(re.match(".*keyence$",s))
ans.append(re.match("^k.*eyence$",s))
ans.append(re.match("^ke.*yence$",s))
ans.append(re.match("^key.*ence$",s))
ans.append(re.match("^keye.*nce$",s))
ans.append(re.match("^keyen.*ce$",s))
ans.append(re.match("^keyenc.*e$",s))
ans.append(re.match("^keyence.*",s))
c = sum(x!=None for x in ans)
if c > 0:
  print("YES")
else:
  print("NO")

Solution (Python):
import copy

S = list(input())
ja = 0

sremove = ""
S_tmp = []

for i in range(len(S)):
    for j in range(i,len(S)+1):
        S_tmp = copy.deepcopy(S)

        del S_tmp[i:j]

        if "".join(S_tmp) == "keyence":
            ja = 1
            break

if ja == 1:
    print("YES")

else:
    print("NO")

Solution (Python):
from sys import stdin

def main():
    S = input()

    l = len(S)
    ans = 'NO'
    for i in range(7, -1, -1):
        j = l - (7 - i)
        if S[:i] + S[j:] == 'keyence':
            ans = 'YES'
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Solution (Python):
s = input()

key = 'keyence'
yes = False

if key in s:
    idx = s.index('key')
    if idx == 0:
        yes = True
    elif len(s) - idx == 7:
        yes = True
else:
    for i in range(1,8):
        pre = key[:i]
        post = key[i:]
        
        if pre == s[:len(pre)]:
            
            if s[len(s)-(7-i):] == post:
                yes = True
                break
        
if yes == True:
    print('YES')
else:
    print('NO')

Solution (Python):
K = "keyence"

S = raw_input()
N = len(S)
M = N - 7

if M == 0:
    print "YES" if S == K else "NO"
    exit()

for i in xrange(N):
    S1 = S[:i]
    S2 = S[i+M:]
    T = S1 + S2
    if T == K:
        print "YES"
        exit()

print "NO"

Solution (Python):
wlist=[ i for i in input()]
klist=["k","e","y","e","n","c","e"]
a=[]
for i in range(len(wlist)-1):
    for j in range(i+1,len(wlist)):
        if wlist[0:i+1]+wlist[j:]==klist:
                a.append(1)
        else:
                a.append(0)
                
if 1 in a:
    print("YES")
else:
    print("NO")

Solution (Python):
s = input()
key = ""

for i in range(8):
  if i == 0:
    key = s[len(s)-7:]
    if key == "keyence":
      break
  if 0 < i < 7:
    key = s[:i] + s[len(s) - 7 + i:]
    if key == "keyence":
      break
  if i == 7:
    key = s[:7]
    if key == "keyence":
      break

if key == "keyence":
  print("YES")
else:
  print("NO")

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

if(len(S) == 7 and ans==S):
    print('YES')
else:
    for i in range(7):
        if(S[i] == ans[i]):
            flag = True
        elif S[len(S)-7+i::] == ans[i::]:
            flag = True
            break
        else:
            flag = False
            break

    if(~flag):
        ans = ans[::-1]
        S = S[::-1]
        for i in range(7):
            if(S[i] == ans[i]):
                flag = True
            elif S[len(S)-7+i::] == ans[i::]:
                flag = True
                break
            else:
                flag = False
                break

    

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

Solution (Python):
def read():
    S = input().strip()
    return S,


def solve(S):
    key = "keyence"

    for i in range(len(key)):
        head = S[:i]
        tail = S[len(S) - len(key) + i:]
        if head == key[:i] and tail == key[i:]:
            return True
    return False


if __name__ == '__main__':
    inputs = read()
    print("YES" if solve(*inputs) else "NO")

Solution (Python):
s = input()
key = "keyence"
if s[:7] == key:
    print("YES")
    exit()
elif s[-6:] == key:
    print("YES")
    exit()
else:
    for i in range(7):
        if s[:i] == key[:i] and s[-7+i:] == key[-7+i:]:
            print("YES")
            exit()
print("NO")

Solution (Python):
s = input()

word = "keyence"

for i in range(len(word)):
    a = s.find(word[:i])
    b = s.rfind(word[i:])
    if((a == 0 and b == 0) or (a == 0 and b == len(s)-len(word[i:]))):
        print("YES")
        exit()

print("NO")

Solution (Python):
s = input()
st = ""
ma = "keyence"
l = []

if s[0:7] == ma or s[-7:] == ma:
    print("YES")
else:
    for i in range(len(ma)):
        if s[0:i] + s[-7+i:] == ma:
            print("YES")
            exit()
    else:
        print("NO")

Solution (Python):
S = input().strip()

T = "keyence"

if S.startswith(T) or S.endswith(T):
    print("YES")
    exit()

count = 0
j = 0
is_last = False
for i in range(0,len(S)):
    if j >= len(T):
        print("NO")
        exit()
    if T[j] == S[i]:
        j += 1
        continue
    elif T[j] != S[i]:
        print("YES" if S.endswith(T[j:]) else "NO")
        exit()

if j == len(T):
    print("YES")
else:
    print("NO")

Solution (Python):
S=input()
print("YES" if sum([1 if S[:i] == "keyence"[:i] and S[i - 6:] == "keyence"[i - 6:] else 0 for i in range(1, 7)] + [1 if S[:7] == "keyence" or S[-7:] == "keyence" else 0]) > 0 else "NO")

Solution (Python):
S = "keyence"
line = input()
cnt = 0
for i in range(6):
    string = ""
    if(line.rfind(S[i+1:]) > line.find(S[0:i+1])>= 0): string += line[:line.find(S[0:i+1])+(i+1)] + line[line.rfind(S[i+1:]):]
    
    if(string == S): cnt += 1
if(cnt>0): print("YES")
else: print("NO")

Solution (Python):
import sys

sys.setrecursionlimit(10000)
import re







S = input()

K = "keyence"

s_idx = 0
k_idx = 0
skip = False

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


while (S[s_idx] == K[k_idx]):
    s_idx += 1
    k_idx += 1




rs_idx = 1
rk_idx = 1
while (S[-rs_idx] == K[-rk_idx]):
    rs_idx += 1
    rk_idx += 1

    s1 = S[0:s_idx]
    s2 = S[-(rs_idx-1):]
    if s1+s2 == K:
        print("YES")
        sys.exit(0)


print("NO")

Solution (Python):
S = input()

n_len = len(S)
is_keyence = False

for i in range(n_len):
    for j in range(i, n_len):
        if S[:i] + S[j:] == 'keyence':
            is_keyence = True
    if is_keyence: break
        
print('YES' if is_keyence else 'NO')

Solution (Python):
l = raw_input()
flag = False
if len(l) >= 6:
    for i in range(7):
        tmp = l[0:i] + l[-7+i:]
        if tmp == "keyence":
            flag = True
if flag == True:
    print "YES"
else:
    print "NO"

Solution (Python):
import sys
import re
r = "keyence"
c1=re.compile("^.+?keyence$")
c2=re.compile("^k.+?eyence$")
c3=re.compile("^ke.+?yence$")
c4=re.compile("^key.+?ence$")
c5=re.compile("^keye.+?nce$")
c6=re.compile("^keyen.+?ce$")
c7=re.compile("^keyenc.+?e$")
c8=re.compile("^keyence.+?$")

for line in sys.stdin.readlines():
    target = line.strip()
    if len(target) == 7:
        if target == r:
            print("YES")
        else:
            print("NO")
    else:
        if re.search(c1, target) is not None or re.search(c2, target) is not None or re.search(c3, target) is not None or re.search(c4, target) is not None or re.search(c5, target) is not None or re.search(c6, target) is not None or re.search(c7, target) is not None or re.search(c8, target) is not None:
            print("YES")
        else:
            print("NO")

Solution (Python):
thisinput=str(input())
lengthofdelete=len(thisinput)-7
key="keyence"
if lengthofdelete==0:
    if thisinput==key:
        print("YES")
    else:
        print("NO")
else:
    
    for x in range(8):
        newstr = thisinput[:x] + thisinput[x+lengthofdelete:]
        if newstr==key:
            print("YES")
            break
        else:
            if x==7:
                print("NO")
            else:
                continue

Solution (Python):
s = input()
keyence = 'keyence'

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

for i in range(len(keyence) + 1):
    head, tail = keyence[:i], keyence[-(len(keyence) - i):]
    s_head, s_tail = s[:i], s[-(len(keyence) - i):]
    if head == s_head and tail == s_tail:
        print('YES')
        exit(0)


print('NO')

Solution (Python):
S = list(str(input()))
KEY = ["k","e","y","e","n","c","e"]
num = 0
endY = False
endN = False
cnt = 0
for i in range(len(S)):
	cnt += 1
	if(num == 6):
		print("YES")
		break
	elif(endY == True):
		print("YES")
		break
	elif(endN == True):
		print("NO")
		break
	elif(len(S)<7):
		print("NO")
		break		
	elif(len(S)==7 and S[0]!="k"):
		print("NO")
		break

	elif(S[i]==KEY[num]):
		num += 1

	elif(num>=0 and S[i]!=KEY[num]):
		num2 = 0
		for j in range(len(S)):
			if(num+num2 == 7):
				endY = True
				break
			
			elif((num+num2 <7) and S[len(S)-(j+1)] == KEY[7-(j+1)]):
				num2 += 1
			
			else:
				endN = True
				break

Solution (Python):
"""
B - KEYENCE String
"""

def simple_input():
    temp_input = input().rstrip().split(' ')
    if len(temp_input) > 1:
        return temp_input
    return temp_input[0]


if __name__ == '__main__':
    
    s = input()
    keyence = "keyence"

    result = "NO"
    
    matchcount = 0
    for i in range(7):
        si = s[i]
        ki = keyence[i]
        if(si == ki):
            matchcount = matchcount + 1
        else:
            break

    for i in range(7):
        i2 = i * -1 - 1
        si = s[i2]
        ki = keyence[i2]
        if(si == ki):
            matchcount = matchcount + 1
        else:
            break

    if(matchcount >= 7):
        result = "YES"
    
    
    print(result)

Solution (Python):
S = input()
ans = False
for first_idx in range(len(S)):
    for last_idx in range(first_idx, len(S)):
        if("keyence" == S[:first_idx] + S[last_idx:]):
            ans = True
            break

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

Solution (Python):
import re
if re.compile(r'(\A.*keyence\Z|\Ak.*eyence\Z|\Ake.*yence\Z|\Akey.*ence\Z|\Akeye.*nce\Z|\Akeyen.*ce\Z|\Akeyenc.*e\Z|\Akeyence.*\Z)').search(input()):
  print('YES')
else:
  print('NO')

Solution (Python):
S = input()
answer = "keyence"
a = 0

for s in S:
    if s == answer[a]:
        a += 1
        if a == len(answer):
            print("YES")
            break
    else:
        tmp = len(answer)-a
        if S[-tmp:] == answer[a:]:
            print("YES")
        else:
            print("NO")
        break

Solution (Python):

s = input()

f = "keyence"
h = 0
n = len(s)
for i in range(8):

    first = f[:i+1]
    second = f[i+1:]
    check = len(first)
    find1 = s.find(first)
    find2 = s.find(second,n-len(second))

    if i!=7:
        if find1!=0:
            continue

        if find2==-1:
            continue

        if find2+len(second)!=n:
            continue

        else:
            print("YES")
            h = 1
            break

    else:
        if find1 == 0 or find1+len(first) == n :
            print("YES") 
            h = 1
            break



if h == 0:
    print("NO")

Solution (Python):

import sys

S = input()
t = "keyence"


idx = S.find(t)
if idx == 0 or idx == len(S)-7:
    print("YES")
    sys.exit()


for idx in range(6):
    if S.find(t[0:6-idx]) == 0 and S.endswith(t[7-idx-1:7], len(S) - 1 -idx, len(S)):
        print("YES")
        sys.exit()
        
print("NO")

Solution (Python):
import sys
ans = False
ans_str = {True:'YES', False:'NO'}

target = 'keyence'

input_str = input()
input_len = len(input_str)
if target in input_str:
    if input_str.index(target) == 0:
        print('YES')
    elif input_str.index(target) == -7:
        print('YES')
    else:
        print('NO')
    sys.exit()
else:
    for i in range(6):
        if input_str.find(target[:(i+1)]) == 0 and input_str[-(6-i):] == target[(i+1):]:
            print('YES')
            sys.exit()
    print('NO')
    sys.exit()

Solution (Python):
S = input()
N = len(S)
if S[0:7] == 'keyence':
  print('YES')
  exit()
if S[-7:] == 'keyence':
  print('YES')
  exit()
for i in range(6):
  X = S[0:i+1]
  Y = S[-6+i:]
  if X + Y == 'keyence':
    print('YES')
    exit()
print('NO')

Solution (Python):
import re
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


S = ii(str).lower()
if S == "keyence":
    print("YES")
    exit()
if (
    re.sub("k[a-z]*eyence", "", S)
    and re.sub("ke[a-z]*yence", "", S)
    and re.sub("key[a-z]*ence", "", S)
    and re.sub("keye[a-z]*nce", "", S)
    and re.sub("keyen[a-z]*ce", "", S)
    and re.sub("keyenc[a-z]*e", "", S)
    and re.sub("keyence[a-z]*", "", S)
):
    print("NO")
else:
    print("YES")

Solution (Python):

a = list(input().rstrip())


count = 0

for i in range(len(a)):
    if a[i] == 'k':
        count = count + 1
        a[i] = '-'
        if a[i+1] == 'e':
            count = count + 1
            a[i] = '-'
            if a[i+2] == 'y':
                count = count + 1
                a[i] = '-'
                if a[i+3] == 'e':
                    count = count + 1
                    a[i] = '-'
                    if a[i+4] == 'n':
                        count = count + 1
                        a[i] = '-'
                        if a[i+5] == 'c':
                            count = count + 1
                            a[i] = '-'
                            if a[i+5] == 'e':
                                count = count + 1
                                a[i] = '-'
                            else:
                                break
                        else:
                            break    
                    else:
                        break
                else:
                    break
            else:
                break    
        else:
            break   
    else:
        continue

a.reverse()

for j in range(len(a)):
    if a[i] == 'e':
        count = count + 1
        a[i] = '-'
        if a[i+1] == 'c':
            count = count + 1
            a[i] = '-'
            if a[i+2] == 'n':
                count = count + 1
                a[i] = '-'
                if a[i+3] == 'e':
                    count = count + 1
                    a[i] = '-'
                    if a[i+4] == 'y':
                        count = count + 1
                        a[i] = '-'
                        if a[i+5] == 'e':
                            count = count + 1
                            a[i] = '-'
                            if a[i+5] == 'k':
                                count = count + 1
                                a[i] = '-'
                            else:
                                break
                        else:
                            break    
                    else:
                        break
                else:
                    break
            else:
                break    
        else:
            break   
    else:
        continue

if count >= 7 and (i == 0 and j == 0):
    print('YES')
elif 'keyence' in a and (i == 0 or j == 0):
    print('YES')
else:
    print('NO')

Solution (Python):
S = input()
str = "keyence"
frag = False

for a in range(0,len(S)):
  if (S[0:a] + S[a - 7:]) == str:
    frag = True

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

Solution (Python):
s = input()

ans = 'keyence'
ret = 'NO'
if s[:7] == ans:
    ret = 'YES'
elif s[-7:] == ans:
    ret = 'YES'
else:
    for i in range(7):
        j = 7-i
        if s[:i] == ans[:i] and s[-j:] == ans[-j:]:
            ret = 'YES'
print(ret)

Solution (Python):

s = input()

if s.startswith("keyence") or s.endswith("keyence"):
    print("YES")
    exit()

c = 0
for s1, k1 in zip(s, "keyence"):
    if s1 == k1:
        c += 1
    else:
        break

for s1, k1 in zip(s[::-1], "keyence"[::-1]):
    if s1 == k1:
        c += 1
    else:
        break

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

Solution (Python):
ans = "keyence"

s = input()
flag=0
if ans in s:
  flag=1
  print("YES")
else:
  for i in range(1,len(ans)):
    if s[:i] == ans[:i] and s[i-len(ans):] == ans[i-len(ans):]:
      flag=1
      print("YES")
      break
if flag==0:
  print("NO")

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

else:
    print("NO")

Solution (Python):
s = str(input())
word = 'keyence'

ans = 'NO'
if s.startswith('keyence'):
    ans = 'YES'
elif s.endswith('keyence'):
    ans = 'YES'
else:
    for i in range(7):
        if s.startswith(word[:i]):
            postword = word[i:]
            if s.endswith(postword):
                ans = 'YES'
            else:
                 continue

print(ans)

Solution (Python):
s = input()
key = 'keyence'
if len(s) < len(key):
    print("NO")
elif s[:len(key)] == key:
    print("YES")
elif s[-len(key):] == key:
    print("YES")
else:
    for i in range(1, len(key)):
        head = s.startswith(key[0:i])
        hip = s.endswith(key[i:])
        if head and hip:
            print("YES")
            break
    else:
        print("NO")

Solution (Python):
S = input()


def judge():
    L = len(S)
    keyence = 'keyence'
    if S[0] != 'k':
        if S[-7:] != 'keyence':
            return False
        else:
            return True
    else:
        for i in range(8):
            if S[0:i] == keyence[0:i] and S[L-(7-i):L] == keyence[i:7]:
                return True
        return False


def main():
    if judge():
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Solution (Python):
s = input()
for i in range(len(s)):
    for j in range(i, len(s)):
        if 'keyence' == '{}{}'.format(s[0:i+1], s[j:len(s)+1]):
            print('YES')
            quit()
print('NO')

Solution (Python):
import fnmatch
S=[]
S.append(input())
if S == fnmatch.filter(S, "*keyence") or S == fnmatch.filter(S, "k*eyence") or S == fnmatch.filter(S, "ke*yence") or S == fnmatch.filter(S, "key*ence") or S == fnmatch.filter(S, "keye*nce") or S == fnmatch.filter(S, "keyen*ce") or S == fnmatch.filter(S, "keyenc*e") or S == fnmatch.filter(S, "keyence*"):
  print("YES")
else:
  print("NO")

Solution (Python):


import math
import sys
import itertools
import numpy as np


m = list(input())
n = list("keyence")

a=0
for i in range(len(n)):
    if m[i]==n[i]:
        a += 1
    else:
        break

for i in range(1,len(n)):
    if m[-i]==n[-i]:
        a += 1
    else:
        break    

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

Solution (Python):
S = input()
l = len(S)
ans = 0
if S[0] == 'k':
	ans += 1
	if S[1] == 'e':
		ans += 1
		if S[2] == 'y':
			ans += 1
			if S[3] == 'e':
				ans += 1
				if S[4] == 'n':
					ans += 1
					if S[5] == 'c':
						ans += 1
						if S[6] == 'e':
							ans += 1
if S[l-1] == 'e':
	ans += 1
	if S[l-2] == 'c':
		ans += 1
		if S[l-3] == 'n':
			ans += 1
			if S[l-4] == 'e':
				ans += 1
				if S[l-5] == 'y':
					ans += 1
					if S[l-6] == 'e':
						ans += 1
						if S[l-7] == 'k':
							ans += 1
if ans >=7 :
	print('YES')
else:
	print('NO')

Solution (Python):
s=input()
k='keyence'
for i in range(len(k)):
    if s.startswith(k[:i]) and s.endswith(k[i:]):
        print('YES')
        break
else:
    print('NO')

Solution (Python):
T = "keyence"
S = input()
N = len(S)

def check(start, end):
    if N - (end - start) != 7:
        return False
    
    j = 0
    for s in S[:start]:
        
        if T[j] != s:
            return False
        j += 1
    
    for s in S[end:]:
        
        if T[j] != s:
            return False
        j += 1
    return True
    
def solve():
    for start in range(N-1):
        for end in range(start, N):
            
            if check(start, end):
                return True
    return False

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

Solution (Python):
S=input()
b=len(S)
a=[]
a=list(S)
if a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[4]=='n'and a[5]=='c'and a[6]=='e':
    print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[4]=='n'and a[5]=='c'and a[b-1]=='e':
    print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[4]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[1]=='e'and a[b-5]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[b-6]=='e'and a[b-5]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[b-7]=='k'and a[b-6]=='e'and a[b-5]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
else:
    print("NO")

Solution (Python):
s = list(input())
removed = False
removing = False
for i in range(len(s)):
    last = list("keyence")
    j = i
    while j < len(s):
        if s[j] == last[0]:
            del last[0]
            if not last:
                print("YES")
                exit()
        else:
            j += 1
            break
        j += 1
    
    
    if i == 0 and j + len(last) <= len(s) and s[len(s)-len(last):] == last:
        print("YES")
        exit()
print("NO")

Solution (Python):



from collections import deque
import heapq
import bisect
import math


def main():
    s =input()

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

    print("NO")


if __name__ == '__main__':
    main()

Solution (Python):
import copy
S = list(input())
diff = len(S)-len("keyence")
for i in range(len(S)-diff):
    S_tmp = copy.deepcopy(S)
    
    del S_tmp[i:(i+diff)]
    
    if "keyence" == "".join(S_tmp):
        print("YES")
        exit(0)
print("NO")

Solution (Python):
from sys import stdin

str = stdin.readline().rstrip()
target = "keyence"
status = 0
for i in range(6):
    before = target[0:i+1]
    after =target[i+1:]
    bindex = str.find(before)
    if bindex > 0:
        if bindex == str.find("keyence"):
            status += 1
    elif bindex == 0:
        aindex = str.rfind(after)
        if aindex == (len(str) - len(after)):
            status += 1
        elif aindex == len(before):
            status += 1
if status == 0:
    print("NO")
else:
    print("YES")

Solution (Python):
s = raw_input()
string = 'keyence'
back = 0
front = 0
ptr = len(string)-1
for i in xrange(len(s)-1, -1, -1):
	if ptr < 0:
		break
	if s[i] == string[ptr]:
		back += 1
		ptr -= 1
	else:
		break
for i in xrange(len(s)):
	if i == len(string):
		break
	if s[i] == string[i]:
		front += 1
	else:
		break
if front + back >= len(string):
	print 'YES'
else:
	print 'NO'

Solution (Python):
S = input()
ans = False
if(S.find("keyence") == 0 or S.find("keyence") == len(S) - 7):
  ans = True
else:
  for i in range(7):
    if(S[0: i + 1] + S[len(S) - 6  +i : len(S)]  == "keyence"):
      ans = True
      break
if ans:
  print("YES")
else:
  print("NO")

Solution (Python):
import re

kwd = "keyence"
S = input()

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

judge = "NO"

for p in pattern:
    result = re.match(p,S)
    if result:
        judge = "YES"

print(judge)

Solution (Python):
S = input()

if "keyence" in S:
    if S[0:7] == "keyence" or S[-7:] == "keyence":
        print("YES")
    else:
        print("NO")
    exit()

s = "keyence"

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

Solution (Python):
S=list(input())
str1=""
str2=""
flag=0
for i in range(7):
    str1+=S[i]
    str2+=S[len(S)-7]

if str1=="keyence"or str2=="keyence":
    flag=1
s=""
t=""
for i in range(7):
    for j in range(i):
        s+=S[j]
    for j in range(7-i):
        t+=S[len(S)-7+i+j]
    if s+t=="keyence":
        flag=1
    s=""
    t=""
if flag==1:
    print("YES")
else:
    print("NO")

Solution (Python):
n = input()

num = len(n)

flag = False
for i in range(num):
    if n[:i] + n[num + i -7:num] == 'keyence':
        flag = True

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

Solution (Python):
import re

s = input()
p1 = '^keyence$'
p2 = '.*'

for i in range(1, 9):
    p = '{0}{1}{2}'.format(p1[:i], p2, p1[i:])
    if re.match(p, s):
        print('YES')
        break
else:
    print('NO')

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

Solution (Python):
import re

def make_pattern():
    template = 'keyence'
    xs = []
    for i in range(len(template) + 1):
        xs.append(template[:i] + '.*' + template[i:])
    
    pat = '^(?:' + '|'.join(xs) + ')$'
    return re.compile(pat)

def main():
    s = input()
    pat = make_pattern()

    m = pat.match(s)
    if m:
        print('YES')
    else:
        print('NO')

main()

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

Solution (Python):
s=input()

def check(s):
    n=len(s)
    if n<7:
        print("NO")
    elif n==7:
        if s[0:7]=="keyence":
            print("YES")
        else:
            print("NO")
    
    elif s[0]=="k" and s[n-1]=="e":
        count=0
        for i in range(6):
            if s[0:i+1]+s[n-(7-i-1):n]=="keyence":
                count=1
                
        if count==1:
            print("YES")
        else:
            print("NO")
            
    elif s[0]=="k":
        if s[0:7]=="keyence":
            print("YES")
        else:
            print("NO")
            
    elif s[n-1]=="e":
        if s[n-7:n]=="keyence":
            print("YES")
        else:
            print("NO")
        
    else:
        print("NO")

check(s)

Solution (Python):
S = input()

keyence = 'keyence'
new = S
if S.startswith(keyence) or S.endswith(keyence):
    print('YES')
    exit()
else:
    for char in S:
        if char == keyence[0]:
            new = new[1:]
            keyence = keyence[1:]
        else:
            break
if new.endswith(keyence):
    print('YES')
    exit()
print('NO')

Solution (Python):
S = input()
T = "keyence"
lens = len(S)
if lens == 7:
    if S == "keyence": print("YES")
    else: print("NO")
else:
    insert = lens - 7
    for i in range(8):
        if S[:i] == T[:i] and S[insert+i:] == T[i:]:
            print("YES")
            break
    else: print("NO")

Solution (Python):
S = input()

if S[0] == "k" and S[-6] == "e" and S[-5] == "y" and S[-4] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[-7] == "k" and S[-6] == "e" and S[-5] == "y" and S[-4] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[-5] == "y" and S[-4] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[-4] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[3] == "e" and S[-3] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[3] == "e" and S[4] == "n" and S[-2] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[3] == "e" and S[4] == "n" and S[5] == "c" and S[-1] == "e":
  print("YES")
elif S[0] == "k" and S[1] == "e" and S[2] == "y" and S[3] == "e" and S[4] == "n" and S[5] == "c" and S[6] == "e":
  print("YES")
else:
  print("NO")

Solution (Python):
import sys
str = list(input())

n = len(str)

for i in range(8):
    edit = str[0:i] + str[n - 7 + i:]
    if edit == ['k', 'e', 'y', 'e', 'n', 'c', 'e']:
        print('YES')
        sys.exit()
print('NO')

Solution (Python):
S=input()
check=0


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

for i in range(8):
  moji=S[i:len(S)-7+i]
  if S[:i]+S[len(S)-7+i:]=='keyence':
    print('YES')
    exit()

print('NO')

Solution (Python):
S=input()
key_='keyence'

ans='NO'
for i in range(len(S)):
  if S[:i]+S[i+len(S)-7:]==key_:
    ans='YES'
    break

print(ans)

Solution (Python):
s = input()

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

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

print("NO")

Solution (Python):
s = list(input())
k = list("keyence")

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

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

Solution (Python):
s = list(input())
flag = False
for i in range(len(s)):
    for j in range(i,len(s)+1):
        t = s[:]
        del t[i:j]
        if "".join(t) == 'keyence':
            flag = True
if flag:
    print("YES")
else:
    print("NO")

Solution (Python):
s = input()
ok = False
string = 'keyence'
j = 0
ok = False
for i in range(len(s)):
    for j in range(len(s)):
        if s[0:i]+s[j:len(s)] == string:
            ok = True
if string in s:
    ok = True

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

Solution (Python):
s = list(input())
ans = list('keyence')
for i in s:
    if i == ans[0]:
        ans.pop(0)
    else:
        idx = i
        break

if ans == s[::-1][:len(ans)][::-1]:
    print('YES')
else:
    print('NO')