Problem:


Score : 200 points

Problem Statement

A string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.

Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.

Constraints

The length of S is between 7 and 100 (inclusive).

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S is a KEYENCE string, print YES; otherwise, print NO.

Sample Input 1

keyofscience

Sample Output 1

YES

keyence is an abbreviation of key of science.

Sample Input 2

mpyszsbznf

Sample Output 2

NO

Sample Input 3

ashlfyha

Sample Output 3

NO

Sample Input 4

keyence

Sample Output 4

YES



Sample input:
keyofscience


Sample output:
YES

Submission status: Accepted

Solution code:
S = input()

tag = 'keyence'

ans = 0

if S[0:7]==tag:
    ans = 1
elif S[len(S)-7:len(S)]==tag:
    ans = 1
else:
    for j in range(1, 6):
        f_tag = tag[0:j]
        a_tag = tag[j+1:7]
        f = 1
        for k in range(len(f_tag)):
            if not S[k]==f_tag[k]:
                f = -1
        for k in range(len(a_tag)):
            if not S[len(S)-len(a_tag)+k]==a_tag[k]:
                f = -1
        if f>0:
            ans = 1

if ans>0:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

ans = 'NO'
for i in range(len(key_str)):
    if i == 0:
        if S.startswith(key_str) or S.endswith(key_str):
            ans = 'YES'
            break
    else:
        left = key_str[:i]
        right = key_str[i:]
        if S.startswith(left) and S.endswith(right):
            ans = 'YES'
            break
print(ans)

Submission status: Accepted

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

if S == T:
    print("YES")
    exit(0)

for i in range(7):
    if S.startswith(T[:i]) and S.endswith(T[i:]):
        print("YES")
        break
else:
    print("NO")

Submission status: Accepted

Solution code:
import sys
S = input().strip()
keyence = "keyence"
n = len(keyence)

if keyence in S:
    k = S.find(keyence)
    if k == 0:
        print("YES")
        sys.exit()
    elif k + n == len(S):
        print("YES")
        sys.exit()

for i in range(n):
    if S[:i] == keyence[:i] and S[-(n-i):] == keyence[-(n-i):]:
        print("YES")
        sys.exit()

print("NO")

Submission status: Accepted

Solution code:
S=raw_input()

if S=="keyence":
	print "YES"
	quit()

l=len(S)
l_amari=len(S)-7

for i in range( l - l_amari+1):
	str1=S[0:i]
	str2=S[i+l_amari:]
	if str1+str2 == "keyence":
		print "YES"
		quit()
else:
	print "NO"

Submission status: Accepted

Solution code:
S = input()

k = 'keyence'


if S.find(k) == 0 or S.find(k) == len(S) - 7:
    print('YES')
    exit()

for i in range(1, len(k)):
    if S.find(k[:i]) == 0 and S[::-1].find(k[i:][::-1]) == 0:
        print('YES')
        exit()

print('NO')

Submission status: Accepted

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

K='keyence'

for n in range(7):
    if S[n]!=K[n]:
        if S[N-7+n:N]==K[n:7]:
            print('YES')
            break
        else:
            print('NO')
            break

    if n==6:
        print('YES')

Submission status: Accepted

Solution code:
S=input()
s=list()
a=['k','e','y','e','n','c','e']
j,p=1,1
for i in S:
	s.append(i)
c,t=len(s),len(a)
if s[0]!=a[0]:
	if s[-t:c]!=a:
		p=0
else:
	for i in range(6):
		if (s[0:j]!=a[0:j]) & (s[(-t):c]!=a[(-t):7]):
			p=0
		t=t-1
		j=j+1
if p==1:
	print('YES')
elif p==0:
	print('NO')

Submission status: Accepted

Solution code:
s=input()
q=0

if s.find("keyence")!=-1:
    q=1#ok
else:
    if s[:6]== "keyenc" and s[len(s)-1]=="e":
        q=1
    else:
        if s[:5]=="keyen" and s[len(s)-2:]=="ce":
            q=1
        else:
            if s[:4]=="keye" and s[len(s)-3:]=="nce":
                q=1
            else:

                if s[:3]=="key" and s[len(s)-4:]=="ence":
                    q=1
                else:

                    if s[:2]=="ke" and s[len(s)-5:]=="yence":
                        q=1
                    else:

                        if s[0]=="k" and s[len(s)-6:]=="eyence":
                            q=1
if q==1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b

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")

Submission status: Accepted

Solution code:
#! /usr/bin/env 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()))

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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
        # print(s, _p)
    return False

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
S = input()

avi = False
if len(S) != 7:
    for i in range(len(S)):
        w = S[:i] + S[(i + (len(S) - 7)):]
#        print(w)
        if w == "keyence":
            avi = True
            break
elif S == "keyence":
    avi = True

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

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-
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')

Submission status: Accepted

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

# print(len(a))
for i in range(0,len(a)):
	# print(i)
	# print(S[0:i])
	# print(a[0:i])
	# print(S[len(S)+i-len(a):len(S)])
	# print(a[i:len(S)])
	
	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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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")

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
import re
s = input()
keyence = 'keyence'
for i in range(7):
    fs, es = keyence[:i], keyence[i:]
    # print(fs, es)
    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:
            # print(fsi, esi)
            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')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# coding: utf-8
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

sa = len(s) - len(ans)
#print(sa)

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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:
            # print("remain:",ans[k:])
            # print("to search in:",S[i:])
            break
    # print(ans[k:],S[-(N-k):])
    if ans[k:] == S[-(N-k):]:
        flag = True

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
s = input()
kw = "keyence"
# print(kw[len(kw)-3:])
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")

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

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
        # print(l, r)
        for i in range(len(S)):
            if l <= i <= r:
                continue
            # print(i, n)
            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')

Submission status: Accepted

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

    print("YES")

    exit()

print("NO")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:

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()))

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")