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=list(input())
if "k" and "e" and "y" and "e" and "n" and "c" and "e" in S:
    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y" and S[-6]=="e" and S[-7]=="k":
        print("YES")
    else:
        if S[0]=="k":
            if S[1]=="e":
                if S[2]=="y":
                    if S[3]=="e":
                        if S[4]=="n":
                            if S[5]=="c":
                                if S[6]=="e":
                                    print("YES")
                                else:
                                    if S[-1]=="e":
                                        print("YES")
                                    else:
                                        print("NO")
                            else:
                                if S[-1]=="e" and S[-2]=="c":
                                    print("YES")
                                else:
                                    print("NO")
                        else:
                            if S[-1]=="e" and S[-2]=="c" and S[-3]=="n":
                                print("YES")
                            else:
                                print("NO")
                    else:
                        if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e":
                            print("YES")
                        else:
                            print("NO")
                else:
                    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y":
                        print("YES")
                    else:
                        print("NO")
            else:
                if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y" and S[-6]=="e":
                    print("YES")
                else:
                    print("NO")
        else:
            print("NO")
else:
    print("NO")

Solution (Python):
s = input()
t = "keyence"
if t in s:
    print("YES")
    exit()
if len(s) >= 7:
    if "k" in s and "eyence" in s:
        if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[-3] == "n" and s[-4] == "e" and s[-5] == "y" and s[-6] == "e":
            print("YES")
            exit()
    if "ke" in s and "yence" in s:
        if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[-3] == "n" and s[-4] == "e" and s[-5] == "y" and s[1] == "e":
            print("YES")
            exit()
    if "key" in s and "ence" in s:
        if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[-3] == "n" and s[-4] == "e" and s[2] == "y" and s[1] == "e":
            print("YES")
            exit()
    if "keye" in s and "nce" in s:
        if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[-3] == "n" and s[3] == "e" and s[2] == "y" and s[1] == "e":
            print("YES")
            exit()
    if "keyen" in s and "ce" in s:
        if s[0] == "k" and s[-1] == "e" and s[-2] == "c" and s[4] == "n" and s[3] == "e" and s[2] == "y" and s[1] == "e":
            print("YES")
            exit()
    if "keyenc" in s and "e" in s:
        if s[0] == "k" and s[-1] == "e" and s[5] == "c" and s[4] == "n" and s[3] == "e" and s[2] == "y" and s[1] == "e":
            print("YES")
            exit()
print("NO")

Solution (Python):
n = list(map(str,input()))

flg = 0

if ''.join(n) == 'keyence':
    print('YES')
    flg = 1
else:
    for i in range(8):
        arr = list(''.join(n)) 
        del arr[i:i+len(n)-7]
        tmp = ''.join(arr)
        if tmp == 'keyence':
            print('YES')
            flg = 1
            break

if flg == 0:
    print('NO')

Solution (Python):


keyStr=input()
keyence="keyence"
chkflg=False

for char in range(len(keyence)-1):
  before=keyence[0:char+1]
  after=keyence[char+1:len(keyence)]
  
  if keyStr.startswith(before) and keyStr.endswith(after):
    print("YES")
    chkflg=True
    break
  if keyStr.startswith(keyence) or keyStr.endswith(keyence):
    print("YES")
    chkflg=True
    break

if chkflg == False:
  print("NO")

Solution (Python):
import re
n = input()
if re.fullmatch(r'.*keyence',n) != None or re.fullmatch(r'keyence.*',n) != None or re.fullmatch(r'k.*eyence',n) != None or re.fullmatch(r'ke.*yence',n) != None or re.fullmatch(r'key.*ence',n) != None or re.fullmatch(r'keye.*nce',n) != None or re.fullmatch(r'keyen.*ce',n) != None or re.fullmatch(r'keyenc.*e',n) != None:
  print("YES")
else:
  print("NO")

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

if S == 'keyence': print('YES')
elif len(S) == 7: print('NO')
else:
	for length in range(len(S)-7):
		for i in range(len(S)-length):
			if S[0:i] + S[i+length+1:] == 'keyence':
				print('YES')
				exit(0)
	print('NO')

Solution (Python):
import re
s = input()
if len(s) < 7 or len(s) > 107:
    print('NO')
else:
    if re.match('^keyence.*',s) or re.match('.*keyence$',s) or re.match('^k.*eyence$',s) or re.match('^ke.*yence$',s) or re.match('^key.*ence$',s) or re.match('^keye.*nce$',s) or re.match('^keyen.*ce$',s) or re.match('^keyenc.*e$',s):
        print('YES')
    else:
        print('NO')

Solution (Python):
def sol(inp=input):
    if determine_res(inp):
        return 'YES'
    return 'NO'
def determine_res(inp=input):
    query=inp()

    goal='keyence'
    if query.startswith(goal):
        return True
    for i,q_c,g_c in zip(range(len(query)),query,goal):
        if q_c!=g_c:
            len_left_mch=i
            break
    return query.endswith(goal[i:])

print(sol())

Solution (Python):
import re
L = input()
k1 = L.count("k")
e3 = L.count("e")
y1 = L.count("y")
n1 = L.count("n")
c1 = L.count("c")
if k1 >= 1 and e3 >= 3 and y1 >= 1 and n1 >= 1 and c1 >= 1:
    if re.match("^k.*eyence$", L) or re.match("^ke.*yence$", L) or re.match("^key.*ence$", L) or re.match("^keye.*nce$", L) or re.match("^keyen.*ce$", L) or re.match("^keyenc.*e$", L) or re.match("^.*keyence$", L) or re.match("^keyence.*$", L):
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Solution (Python):
s = list(input())
ss = ['k','e','y','e','n','c','e']
a = 0
b = 0
c = 0
for i in range(len(ss)):
    if s[i] == ss[i]:
        continue
    else:
        a = i
        break
else:
    print('YES')
    exit()


sss = ss[a:]
for i in range(len(sss)):
    if sss[len(sss)-i-1] == s[len(s)-i-1]:
        continue
    else:
        print('NO')
        break
else:
    print('YES')

Solution (Python):
s=input()

t='keyence'

ans = []

for i in range(8):
    if s[0:i] + s[-(7-i):] == 'keyence':
        ans.append(1)
    else:
        ans.append(0)

print('YES' if any(ans) else 'NO')

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

if S == "keyence":
    ans = 1

else:
    for i in range(len(S)+1):
        for j in range(i+1,len(S)+1):
            S_ = list(S)
            del S_[i:j]
            re = "".join(S_)
            if re != "keyence":
                continue
            else:
                ans = 1
                break

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

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

Solution (Python):
def main(pro):
    ans = 'keyence'
    try:
        lokasi = pro.index(ans)
        if lokasi > 0 and lokasi + len(ans) < len(pro):
            raise ValueError()
        else:
            print('YES')
            return
    except:
        for i in range(len(ans)):
            if ans[i] != pro[i]:
                break
        r = len(ans) - i
        for a in range(1,r+1):
            if ans[-r] != pro[-r]:
                print('NO')
                return
        print('YES')

main(input())

Solution (Python):


import re

S = input()

if "keyence" == S:
    print("YES")
else:
    patterns = ["^keyence(.*)", "^k(.*)eyence$", "^ke(.*)yence$", "^key(.*)ence$", "^keye(.*)nce$", "^keyen(.*)ce$", "^keyenc(.*)e$", "keyence$"]

    matched = False
    for pattern in patterns:
        matchOB = re.search(pattern, S)
        if matchOB:
            matched = True
            break
    if matched:
        print("YES")
    else:
        print("NO")

Solution (Python):


import sys

def check(inputstring) :

    check_string = [['keyence'],
                    ['k','eyence'],
                    ['ke','yence'],
                    ['key','ence'],
                    ['keye','nce'],
                    ['keyen','ce'],
                    ['keyenc','e'],
                    ['keyence']]

    if check_string[0][0] == inputstring[0:7] :
        return "YES"

    for i in range(1, 7) :
        if check_string[i][0] == inputstring[0:len(check_string[i][0])] and check_string[i][1] == inputstring[-len(check_string[i][1]):] :
            return "YES"

    if check_string[7][0] == inputstring[-7:] :
        return "YES"


    return "NO"

if __name__ == '__main__' :
    line = sys.stdin.readline()

    print(check(line.rstrip()))

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

if t in s:
  if s.find(t)==0 or s.find(t)==len(s)-7:
    print("YES")
  else:
    print("NO")
else:
  for i in range(1,7):
    a,b=t[:i],t[i:]
    if a in s and b in s:
      if s.find(a)==0 and s.rfind(b)==len(s)-len(b):
        print("YES")
        break
  else:
    print("NO")

Solution (Python):
S = input()

target = "keyence"
length = len(S)
if target in S[:7]:
    print("YES")
elif target in S[length-7:]:
    print("YES")
else:
    for i in range(1,8):
        if S[:i] == target[:i] and S[length-7+i:] == target[7-7+i:]:
            print("YES")
            break
    else:
        print("NO")

Solution (Python):
import re

s = input().strip()

def check(s):
    p = [
            '\A.*keyence\Z'
            , '\Ak.*eyence\Z'
            , '\Ake.*yence\Z'
            , '\Akey.*ence\Z'
            , '\Akeye.*nce\Z'
            , '\Akeyen.*ce\Z'
            , '\Akeyenc.*e\Z'
            , '\Akeyence.*\Z'
        ]
    for _p in p:
        if re.match(_p, s):
            return True
        
    return False

print('YES' if check(s) else 'NO')

Solution (Python):
S = list(str(input()))
correct = list("keyence")


def search():
    index = 0
    words = 0
    if S[:7] == correct:
        print("YES")
    elif S[len(S)-7:] == correct:
        print("YES")
    else:
        for now, s in enumerate(S):
            if s == correct[index]:
                index += 1
                words += 1
            else:
                break
        index = 6
        for s in S[::-1]:
            if s == correct[index]:
                index -= 1
                words += 1
            else:
                break
        if words >= 7:
            print("YES")
        else:
            print("NO")
search()

Solution (Python):
s=input()
if(s[0:7]=='keyence'):
    print('YES')
    exit()
elif(s[-7:]=='keyence'):
    print('YES')
    exit()    
else:
    for i in range(7):
        t=s[0:i+1]+s[-6+i:]
        
        if(s[0:i+1]+s[-6+i:]=='keyence'):   
            print('YES')
            exit()
print('NO')

Solution (Python):
S = input()

avi = False
if len(S) != 7:
    for i in range(len(S)):
        w = S[:i] + S[(i + (len(S) - 7)):]

        if w == "keyence":
            avi = True
            break
elif S == "keyence":
    avi = True

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

Solution (Python):

import sys
S = input()
key = 'keyence'

i = 0
state = 0
for j in range(len(S)):
    if state == 0:
        if key[i] == S[j]:
            i += 1
        else:
            state += 1
    elif state == 1:
        if key[i] == S[j]:
            if len(key) - i == len(S) - j:
                i += 1
                state += 1
            elif len(key) - i > len(S) - j:
                print('NO')
                sys.exit()
    elif state == 2:
        if key[i] == S[j]:
            i += 1
        else:
            print('NO')
            sys.exit()
if i == len(key):
    print('YES')
else:
    print('NO')

Solution (Python):
S=input()

if S=="keyence":
	print("YES")
	exit(0)
a="keyence"
if S[0:len(a)]==a:
	print("YES")
	exit(0)


for i in range(0,len(a)):
	
	
	
	
	
	
	if S[0:i]==a[0:i] and S[len(S)+i-len(a):len(S)]==a[i:len(S)]:
		print("YES")
		exit(0)
print("NO")
exit(0)

Solution (Python):
import re

a = input()

if re.match('^([a-zA-Z]*?)keyence$', a):
  print("YES")
else:
  if re.match('^k([a-zA-Z]*?)eyence$', a):
    print("YES")
  else:
    if re.match('^ke([a-zA-Z]*?)yence$', a):
      print("YES")
    else:
      if re.match('^key([a-zA-Z]*?)ence$', a):
        print("YES")
      else:
        if re.match('^keye([a-zA-Z]*?)nce$', a):
          print("YES")
        else:
          if re.match('^keyen([a-zA-Z]*?)ce$', a):
            print("YES")
          else:
            if re.match('^keyenc([a-zA-Z]*?)e$', a):
              print("YES")
            else:
              if re.match('^keyence([a-zA-Z]*?)$', a):
                print("YES")
              else:
                print("NO")

Solution (Python):
import re
S=input()
t='keyence'

for i in range(len(t)+1):
    t1=t[:i]
    t2=t[i:]
    if re.search('^'+t1+'[a-z]*'+t2+'$',S) is not None:
        print('YES')
        break
else:
    print('NO')

Solution (Python):

import copy

sf=str(input())
x=int(0)
s=copy.copy(sf)

if "keyence" in s:
    s=s.replace("keyence","",1)
    if s in sf:
        x=1
elif s.find("keyenc") == 0:
    if s.rfind("e") == len(s)-1:
        x=1 
elif s.find("keyen") == 0:
    if s.rfind("ce") == len(s)-2:
        x=1 
elif s.find("keye") == 0:
    if s.rfind("nce") == len(s)-3:
        x=1
elif s.find("key") == 0:
    if s.rfind("ence") == len(s)-4:
        x=1
elif s.find("ke") == 0:
    if s.rfind("yence") == len(s)-5:
        x=1
elif s.find("k") == 0:
    if s.rfind("eyence") == len(s)-6:
        x=1 

if x==1:
    print("YES")
else:
    print("NO")

Solution (Python):
def m():
    S = input()
    a = 'keyence'
    x = 0
    if S[0] == 'k':
        for i in range(len(S)):
            if S[i] == a[x]:
                x += 1
                continue
            else:
                break
        if S[-7+x:] == a[-7+x:]:
            return 'YES'
        else:
            return 'NO'


    else:
        if a == S[-7:]:
            return 'YES'
        else:
            return 'NO'



print(m())

Solution (Python):
if __name__ == '__main__':
    s = input()
    keyence = "keyence"
    for i in range(7):
        if s[:i] == keyence[:i] and s[-7+i:] == keyence[-7+i:]:
            print("YES")
            quit(0)

    if s[:7] == keyence:
        print("YES")
    else:
        print("NO")

Solution (Python):
import re
s = input()
keyence = 'keyence'
for i in range(7):
    fs, es = keyence[:i], keyence[i:]
    
    fsis = [m.start() for m in re.finditer(fs, s)]
    esis = [m.start() for m in re.finditer(es, s)]
    for fsi in fsis:
        for esi in esis:
            
            if fsi + len(fs) <= esi:
                if es == 'keyence' and (esi == 0 or esi + len(es) == len(s)):
                    print('YES')
                    exit()
                elif fsi == 0 and esi + len(es) == len(s):
                    print('YES')
                    exit()
print('NO')

Solution (Python):
s = input()

string = 'keyence'
if s[-7:] == string:
    ans = 'YES'
elif s[:7] == string:
    ans = 'YES'
else:
    ans = 'NO'
    for i in range(1, 7):
        if s[:i] == string[:i] and s[-(7-i):] == string[-(7-i):]:
            ans = 'YES'
            break
print(ans)

Solution (Python):
import copy

ls = []

S = str(input())
l = list(S)

h = 0

for i in range(len(l)):
    for j in range(len(l) - i):
        ls = copy.copy(l)
        del ls[i : i + j]
        b = "".join(ls)
        if(b == "keyence"):
            h = 1

if(h == 1):
    print("YES")
else:
    print("NO")

Solution (Python):
S = input()
num=len(S)
ans=""
judge=False
if("keyence" in S):
    judge=True
for i in range(0,num):
    for j in range(i,num):
        ans=S[:i]+S[j:]
        if(ans=="keyence"):
            judge=True
if(judge):
    print("YES")
else:
    print("NO")

Solution (Python):
S = list(input())

ans = 'NO'
for i in range(len(S)):
    for j in range(len(S)-i):
        copyS = S.copy()
        del copyS[i : j+i]
        if ''.join(copyS) == 'keyence':
            ans = 'YES'
        
print(ans)

Solution (Python):
N = input()

S = 'keyence'
if S == N[:len(S)]:
    print('YES')
elif S == N[-len(S):]:
    print('YES')
else:
    for index in range(len(S)):
        if S[:index] == N[:index] and S[-(len(S) - index):] == N[-(len(S) - index):]:
            print('YES')
            break
    else:
        print('NO')

Solution (Python):

s = input()
key = 'keyence'
key_r = 'ecneyek'
j = 0
for i in key:
    if s[j] == i:
        j += 1
    else:
        break
k = 1
for i in key_r:
    if s[-k] == i:
        k += 1
    else:
        break

s = s[:j] + s[-k+1:]
if j + k > 7:
    s = key
if s == key:
    print('YES')
else:
    print('NO')

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

Solution (Python):
import re
s = input()
if len(s) >= 7 and len(s) <= 107 and (re.match('^keyence.*',s) or re.match('.*keyence$',s) or re.match('^k.*eyence$',s) or re.match('^ke.*yence$',s) or re.match('^key.*ence$',s) or re.match('^keye.*nce$',s) or re.match('^keyen.*ce$',s) or re.match('^keyenc.*e$',s)):
    print('YES')
else:
    print('NO')

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

sa = len(s) - len(ans)


for i in range(len(s) - sa):
    new = s[:i] + s[i+sa:]
    if new == ans:
        print("YES")
        break
else:
    print("NO")

Solution (Python):
string = input()
N = len(string)
N0 = 7
judge = 0

if string == "keyence":
	judge = 1

for i in range(0,N0):
	stringnew = string[0:i]+string[i+N-N0:N]
	if stringnew == "keyence":
		judge = 1

if judge == 1:
	print("YES")
else:
	print("NO")

Solution (Python):
STR = input()
if len(STR) < len("keyence"):
	print("NO")
	exit()

word = "keyence"
word_index = STR.find(word)

if word_index >= 0:
	if STR[:word_index] == "" or STR[word_index + len(word):] == "":
		print("YES")
		exit()

word = "keyenc"
word_index = STR.find(word)

if word_index >= 0:
	if STR[:word_index] == "":
		if STR[-1] == "e":
			print("YES")
			exit()

word = "keyen"
word_index = STR.find(word)

if word_index >= 0:
	if STR[:word_index] == "":
		if STR[-2] + STR[-1] == "ce":
			print("YES")
			exit()

word = "keye"
word_index = STR.find(word)

if word_index >= 0:
	if STR[:word_index] == "":
		if STR[-3] + STR[-2] + STR[-1] == "nce":
			print("YES")
			exit()

word = "key"
word_index = STR.find(word)

if word_index >= 0:
	if STR[:word_index] == "":
		if STR[-4] + STR[-3] + STR[-2] + STR[-1] == "ence":
			print("YES")
			exit()

word = "ke"
word_index = STR.find(word)

if word_index >= 0:
	if STR[:word_index] == "":
		if STR[-5] + STR[-4] + STR[-3] + STR[-2] + STR[-1] == "yence":
			print("YES")
			exit()

word_index = STR.find("k")

if word_index >= 0:
	if STR[:word_index] == "":
		if STR[-6] + STR[-5] + STR[-4] + STR[-3] + STR[-2] + STR[-1] == "eyence":
			print("YES")
			exit()

print("NO")

Solution (Python):
centence=input()
str1="keyence"
a=0
if "keyence" in centence:
    print("YES")
else:
    for i in range(1,len(centence)):
        if (centence.startswith(str1[:i])) and (centence.endswith(str1[i:])):
            a=1
    if a==1:
        print("YES")
    else:
        print("NO")

Solution (Python):
def solve():
  arr = input()
  KEY = "keyence"
  N = len(arr)
  L = N-7
  for s in range(N-L):
    extracted = arr[:s]+arr[s+L:]
    if(extracted == KEY):
      return "YES"
  return "NO"

print(solve())

Solution (Python):
s = input()
tmp = len(s) - 7
if s[tmp:] == "keyence" or s[:tmp] == "keyence":
    print("YES")
    exit()

for i in range(len(s) - tmp):

    if s[:i + 1] + s[i + 1 + tmp:] == "keyence":
        print("YES")
        exit()
print("NO")

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

N = len(ans)
k = 0

flag = False

if S[:N] == ans:
    flag = True
elif S[-N:] == ans:
    flag = True
else:
    for i,s in enumerate(S):
        if s == ans[k]:
            k += 1
        else:
            
            
            break
    
    if ans[k:] == S[-(N-k):]:
        flag = True

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

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

Solution (Python):
S = input()

temp = ''
result = ''
for i in range(len(S)):
    for n in range(len(S)):
        if temp + S[n:] == 'keyence':
            result = temp + S[n:]
            break
    temp += S[i]

if result == 'keyence':
    print('YES')
else:
    print('NO')

Solution (Python):
def solve():
    k = "keyence"
    s = input()
    if s[:7] == k or s[-7:] == k:
        return "YES"
    for i in range(1, 7):
        if s[:i] + s[-(7 - i):] == k:
            return "YES"
    return "NO"
print(solve())

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

flag = 0
for i in range(len(k)+1):
    if S[0:i] == k[0:i] and S[len(S)-len(k)+i:] == k[i:]:
        flag = 1
        break
if flag:
    print('YES')
else:
    print('NO')

Solution (Python):
s = input()
kw = "keyence"

l = len(s)
if kw in s:
    pos = s.find(kw)
    if pos == 0 or pos == len(s)-6-1:
        print("YES")
else:
    if (s[0:1] == "k") and (s[l-6:]=="eyence"):
        print("YES")
    elif (s[0:2] == "ke") and (s[l-5:]=="yence"):
        print("YES")
    elif (s[0:3] == "key") and (s[l-4:]=="ence"):
        print("YES")
    elif (s[0:4] == "keye") and (s[l-3:]=="nce"):
        print("YES")
    elif (s[0:5] == "keyen") and (s[l-2:] == "ce"):
        print("YES")
    elif (s[0:6] == "keyenc") and (s[l-1:]=="e"):
        print("YES")
    else:
        print("NO")

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def SS(): return input()


S = SS()

key = 'keyence'
n = 0
j = 0
for l in range(-1, len(S)):
    for r in range(l, len(S)):
        n = 0
        j = 0
        
        for i in range(len(S)):
            if l <= i <= r:
                continue
            
            if n == len(key):
                j = 1
                break
            if S[i] == key[n]:
                n += 1
            else:
                break
        else:
            if n == len(key) and j == 0:
                print('YES')
                exit()

print('NO')

Solution (Python):
n = input()
for i in range(7):
  N = n[:i] + n[-(7-i):]
  if N == "keyence":

    print("YES")

    exit()

print("NO")

Solution (Python):
S=input()
def func(S):
  target="keyence"
  if S[:7]==target or S[-7:]==target:
    return True
  for i in range(7):
    a=target[:i]
    b=target[i:]
    if S[-len(b):]==b and S[:i]==a:
      return True
  return False

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

Solution (Python):

def solve(s):
  t = 'keyence'
  if t in s[0:7] or t in s[-7:]:
    return 'YES'

  p = 0
  for i in range(len(s)):
    if t[p] == s[i]:
      p = p + 1
    else:
      if t[p:] in s[-7+p:]:
        return 'YES'
      else:
        return 'NO'
  return 'NO'

print(solve(input()))

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

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

Solution (Python):
string = input()

ret = 0
i = 0
j = 0
if string == "keyence":
    ret = 1

while i < len(string):
    j = i 
    while j < len(string):
        kiritori = string[:i] + string[j:]
        if kiritori == "keyence":
            ret = 1
        j += 1
    i += 1


if ret == 1:
    print("YES")
else:
    print("NO")

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

Solution (Python):
S = input()
len_S = len(S)
dif = len_S - 7

for i in range(8):
    temp = S[0:i] + S[dif+i:]
    if temp == "keyence":
        print("YES")
        exit()
print("NO")

Solution (Python):
S = input()
keyence = "keyence"
answer = 'NO'
if keyence in S:
    if S[:7] == keyence:
         answer = "YES"
    elif S[-7:] == keyence:
        answer = "YES"
else:
    for i in range(6):
        if (S[:i+1] == keyence[:i+1]) & (S[-6+i:] == keyence[-6+i:]):
            answer = "YES"
print(answer)

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

flg = False
for i in range(len(s) - 6):
    for j in range(len(s)):
        if s[:j] + s[j + i:] == S:
            flg = True

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

Solution (Python):
import re
s = input()
k = 'keyence'
ans = 'NO'
for i in range(len(k)):
    a = '^'+k[:i]+'.*?'+k[i:]+'$'
    if re.match(a,s):
        ans = 'YES'
print(ans)

Solution (Python):
S = input()
f = False
if S[:7] == 'keyence':
    f = True
if S[-7:] == 'keyence':
    f = True

for i in range(len(S)):
    s1 = S[:i]
    s2 = S[i:]
    if 'k' in s1 and 'eyence' in s2:
        if s1[0] == 'k':
            if s2[-6:] == 'eyence':
                f = True
                break
    if 'ke' in s1 and 'yence' in s2:
        if s1[:2] == 'ke':
            if s2[-5:] == 'yence':
                f = True
                break
    if 'key' in s1 and 'ence' in s2:
        if s1[:3] == 'key':
            if s2[-4:] == 'ence':
                f = True
                break
    if 'keye' in s1 and 'nce' in s2:
        if s1[:4] == 'keye':
            if s2[-3:] == 'nce':
                f = True
                break
    if 'keyen' in s1 and 'ce' in s2:
        if s1[:5] == 'keyen':
            if s2[-2:] == 'ce':
                f = True
                break
    if 'keyenc' in s1 and 'e' in s2:
        if s1[:6] == 'keyenc':
            if s2[-1] == 'e':
                f = True
                break
if f:
    print('YES')
else:
    print('NO')

Solution (Python):
def keyence(s):
    
    if s.count('keyence'):
        if s[:7] == 'keyence' or s[-7:] == 'keyence':
            return('YES')

    
    elif s.count('eyence'):
        if s[:1] == 'k' and s[-6:] == 'eyence':
            return('YES')

    elif s.count('keyenc'):
        if s[:6] == 'keyenc' and s[-1:] == 'e':
            return('YES')

    
    elif s.count('yence'):
        if s[:2] == 'ke' and s[-5:] == 'yence':
            return('YES')

    elif s.count('keyen'):
        if s[:5] == 'keyen' and s[-2:] == 'ce':
            return('YES')

    
    elif s.count('ence'):
        if s[:3] == 'key' and s[-4:] == 'ence':
            return('YES')

    elif s.count('keye'):
        if s[:4] == 'keye' and s[-3:] == 'nce':
            return('YES')

    return('NO')

print(keyence(input()))

Solution (Python):
s = input()
key = "keyence"
ans = "NO"
for i in range(len(key)+1):
    if s.startswith(key[:(len(key))-i]):
        if s.endswith(key[-i:]):
            ans = "YES"
if s.startswith("keyence") or s.endswith("keyence"):
    ans = "YES"
print(ans)

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

T = "keyence"

found = False
if len(S) < len(T):
    print("NO")
else:
    for start in range(len(T)):
        if S.startswith(T[:start]) and S.endswith(T[start:]):
            found = True
            break

    if S.startswith(T):
        found = True

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

Solution (Python):
S=input()
key='keyence'
ans='NO'
for i in range(len(key)):
    key1=key[:i]
    key2=key[i:]
    A=key1+'0'*(len(S)-len(key))+key2
    if all([S[l]==A[l] or A[l]=='0' for l in range(len(S))]):
        ans='YES'
print(ans)

Solution (Python):
S = input()

keyword = 'keyence'
if (S[:7] == keyword) or (S[-7:] == keyword):
    print('YES')
    exit()

f, b = 0, 0

for i, (key, s) in enumerate(zip(keyword, S)):
    if key != s:
        f = i
        break
    else:
        
        pass


for i, (key, s) in enumerate(zip(keyword[::-1], S[::-1])):
    
    if key != s:
        b = i
        break
    else:
        keyword = keyword[1:]


if f + b > 6:
    print('YES')
else:
    print("NO")

Solution (Python):
s=input()
l=len(s)

a="keyence"
cnt=0
i=0
j=0
ans=""
if l<7:
  ans="NO"
elif s==a:
  ans="YES"
else:
  while(i<l):
    if s[i]==a[j]:
      cnt+=1
      i+=1
      j+=1
      
    else:
      i+=l-7
  if cnt==7:
    ans="YES"
  else:
    ans="NO"
print(ans)

Solution (Python):
s = input()

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