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: Wrong Answer

Solution code:
import sys

s = input()
tmp = len(s) - 7
if s == "keyence":
    print("YES")
    sys.exit()
if s.count("k") >= 1 and s.count("e") >= 3 and s.count("y") >= 1 and s.count("n") >= 1 and s.count("c") >= 1:
    for i in range(len(s)):
        if s[i] == 'k':
            for j in range(i, len(s)):
                if s[j] == 'e':
                    for k in range(j, len(s)):
                        if s[k] == 'y':
                            for x in range(k, len(s)):
                                if s[x] == 'e':
                                    for y in range(x, len(s)):
                                        if s[y] == 'n':
                                            for z in range(y, len(s)):
                                                if s[z] == 'c':
                                                    for b in range(z, len(s)):
                                                        if s[b] == 'e':
                                                            print("YES")
                                                            sys.exit()


print("NO")

Submission status: Wrong Answer

Solution code:
STR = input()
FLAG = 0
STEP = 1
for s in STR:
	if STEP == 1:
		if s == "k":
			STEP = 2
		else:
			if FLAG == 0:
				FLAG = 1
	elif STEP == 2:
		if s == "e":
			STEP = 3
		else:
			if FLAG == 0:
				FLAG = 2
			elif FLAG == 2:
				pass
			else:
				print("NO")
				exit()
	elif STEP == 3:
		if s == "y":
			STEP = 4
		else:
			if FLAG == 0:
				FLAG = 3
			elif FLAG == 3:
				pass
			else:
				print("NO")
				exit()
	elif STEP == 4:
		if s == "e":
			STEP = 5
		else:
			if FLAG == 0:
				FLAG = 4
			elif FLAG == 4:
				pass
			else:
				print("NO")
				exit()
	elif STEP == 5:
		if s == "n":
			STEP = 6
		else:
			if FLAG == 0:
				FLAG = 5
			elif FLAG == 5:
				pass
			else:
				print("NO")
				exit()
	elif STEP == 6:
		if s == "c":
			STEP = 7
		else:
			if FLAG == 0:
				FLAG = 6
			elif FLAG == 6:
				pass
			else:
				print("NO")
				exit()
	elif STEP == 7:
		if s == "e":
			STEP = 8
		else:
			if FLAG == 0:
				FLAG = 7
			elif FLAG == 7:
				pass
			else:
				print("NO")
				exit()

if STEP == 8:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
def main(pro):
    ans = 'keyence'
    i = 0
    flag = 0
    for x in pro:
        if i < 7:
            if x == ans[i]:
                i += 1
                if flag == 1:
                    flag = -1
        elif flag == -1:
            print('NO')
            return
        else:
            flag = 1
    if i < 6:
        print('NO')
    else:
        print('YES')

main(input())

Submission status: Wrong Answer

Solution code:
l = ['k', 'e', 'y', 'e', 'n', 'c','e']
str = input() 

if all(x in str for x in l):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()

ans='keyence'
index=0
isCut=0
isKeyence=0
for i in range(len(s)):
    canRestart=0
    restart=0
    if isCut==1:
        if s[i]!=ans[index]:
            isKeyence=0
            if canRestart:
                canRestart=0
                i=restart
                index=restart+1
            else:
                break
    elif isCut==-1:
        if s[i]==ans[index]:
            restart=index
            canRestart=1
            isCut=1
    else:
        if s[i]==ans[index]:
            isKeyence=1
        else:
            isCut=-1
    index+=1
    if index>6:
        break

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

Submission status: Wrong Answer

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

for i in range(7):
  if i == 0:
    key = s[len(s)-7]
    if key == "keyence":
      break
  if 0 < i < 6:
    key = s[:i] + s[len(s) - 7 +i:]
    if key == "keyence":
      break
  if i == 6:
    key = s[:7]
    if key == "keyence":
      break
      
if key == "keyence":
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = input()

S = 'keyence'
index = 0
for item in N:
    if S[index] == item:
        index += 1
    else:
        break

if index == 7:
    print('YES')
else:
    print('YES' if S[len(S) - index - 1:] == N[-(len(S) - index):] else 'NO')

Submission status: Wrong Answer

Solution code:
x = input()
l = len(x)
flag = 0
for i in range(l):
    for j in range(l-1):
        res = x[0:i] + x[j:l]
        if(res == 'keyence'):
            flag = 1
if(flag == 1):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
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]
        j += 1
        if not last:
            print("YES")
            exit()
    # 残り文字がlast = enceみたいになるので
    # sの末尾がlast = enceになっていればOK
    if j + len(last) <= len(s) and s[j:] == last:
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(len(ans)):
    left = S.find(ans[:i+1])
    right = S.rfind(ans[i+1:])
    # print(ans[:i+1], ans[i+1:], left, right)
    if left < right and left!=-1 and right!=-1:
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

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

T = "keyence"

found = False
for start in range(len(T)):
    # print(T[:start], T[start:])

    try:
        i = S.index(T[:start])
        j = S.index(T[start:], i + 1)
        found = True
        break
    except ValueError:
        found = False

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10000)
import re

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

# N = [int(x) for x in input().split()]

S = input()

K = "keyence"

s_idx = 0
k_idx = 0
skip = False

while (S[s_idx] == K[k_idx]):
    s_idx += 1
    k_idx += 1
    if s_idx == len(S):
        print("YES")
        sys.exit(0)

while (S[s_idx] != K[k_idx]):
    s_idx += 1
    if s_idx == len(S):
        print("NO")
        sys.exit(0)


while (S[s_idx] == K[k_idx]):
    s_idx += 1
    k_idx += 1
    if s_idx >= len(S) or k_idx >= len(K):
        break

if s_idx == len(S) and k_idx == len(K):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

len_s = len(S)

key_s = "keyence"
len_key_s = len(key_s)

if len_s >= len_key_s:
    ok =True
    for char_i in range(len_key_s):
        if key_s[char_i] != S[char_i]:
            first_diff_i = char_i
            ok = False
            break

    if ok: # keyencee
        print("YES")
    else:
        for rev_char_i in range(len_key_s):
            char_i = - rev_char_i - 1
            if key_s[char_i] != S[char_i]:
                end_diff_i = char_i
                break
        mod_S = S[:first_diff_i] + S[end_diff_i+1:]
        if mod_S == key_s:
            print("YES")
        else:
            print("NO")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

result = ''
for v in S:
    if result == 'keyence':
        break
    if result == '' and v == 'k':
        result += 'k'
    if result == 'k' and v == 'e':
        result += 'e'
    if result == 'ke' and v == 'y':
        result += 'y'
    if result == 'key' and v == 'e':
        result += 'e'
    if result == 'keye' and v == 'n':
        result += 'n'
    if result == 'keyen' and v == 'c':
        result += 'c'
    if result == 'keyenc' and v == 'e':
        result += 'e'
if result == 'keyence':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

for i in range(8):
	p1,p2=t[:i] , t[i:]

	idx1=S.find(p1)
	idx2=S.find(p2)

	if 0<=idx1 and 0<=idx2  and idx1<idx2:
		print "YES"
		quit()
else:
	print "NO"

Submission status: Wrong Answer

Solution code:
S = input()
keyence = "keyence"
for idx, (s, k)  in enumerate(zip(S, keyence)):
    if s==k:
        continue
    else:
        nokori = keyence[idx:]
        if S[-len(nokori):] == nokori:
            print("YES")
            break
        else:
            print("NO")
            break
    print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

l = list('keyence')
counter = 0
former_result = True
swiched_count = 0
for i in S:
    if counter < len(l) and i == l[counter]:
        former_result = True
        counter += 1
    else:
        if former_result:
            swiched_count += 1
        former_result = False

if swiched_count <= 1 and counter == len(l):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
if 'keyence' in s:
    print('YES')
elif 'k' in s and 'eyence' in s:
    print('YES')
elif 'ke' in s and 'yence' in s:
    print('YES')
elif 'key' in s and 'ence' in s:
    print('YES')
elif 'keye' in s and 'nce' in s:
    print('YES')
elif 'keyen' in s and 'ce' in s:
    print('YES')
elif 'keyenc' in s and 'e' in s:
    print('YES')
elif 'keyence' in s:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
target = 'keyence'
s_len = len(s)
flg = 0
for i in range(7):
    target1_ind = -1
    target1 = target[0:i]
    target2 = target[i:7]
    if target1 in s:
        target1_ind = s.index(target1)
        if target2 in s[target1_ind:s_len]:
            flg = 1

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

Submission status: Wrong Answer

Solution code:
a = "keyence"

b = input()

k = len(b)
j = 0
jj = 0
kk = [0 for i in range(8)]
if k == 7:
	if a == b:
		print("YES")
	else:
		print("NO")
elif k >= 8:
	for i in range(k):
		if b[i] == a[j] and (jj == 0 or jj == 1 or jj == 2):
			j += 1
			if jj == 1:
				jj += 1
		elif jj == 0:
			jj = 1
		elif jj >= 2:
			print("NO")
			break
		if j == 7:
			if i != k-1:
				print("NO")
				break
			else:
				print("YES")
				break
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s = input().rstrip()
target = list('keyence')
delete = []
k = 0
e = 0
y = 0
n = 0
c = 0
for i, x in enumerate(s):
	if x == 'k': k += 1
	elif x == 'e': e += 1
	elif x == 'y': y += 1
	elif x == 'n': n += 1
	elif x == 'c': c += 1
	else: delete.append(i)

judge = 0
for i in range(len(delete)-2):
	judge = max(judge, delete[i+1] - delete[i])

if judge <= 1 and k >= 1 and e >= 3 and y >= 1 and n >= 1 and c >= 1:
	print('YES')
else:
	print('NO')

Submission status: Wrong Answer

Solution code:
import re

s = input()
p = 'key[a-z]*ence'
if re.match(p,s):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import copy

S = input()
ja = 0

sremove = ""
S_tmp = ""

for i in range(len(S)):
    for j in range(len(S)- i):
        S_tmp = S

        sremove = S_tmp[i:]
        sremove = sremove[j:]

        S_tmp.replace(sremove, "")

        if S_tmp == "keyence":
            ja = 1
            break

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

else:
    print("YES")

Submission status: Wrong Answer

Solution code:
S=input()
import copy
s=copy.deepcopy(S)
n=len(s)
I=['k','e','y','e','n','c','e']
i=0
while(1):
    if (n<=i or len(I)==0):break
    if (s[i]==I[0]):
        del(I[0])
        i+=1

    else:
        i+=1

if len(I)==0:
    print('YES')

if len(I)!=0:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
cnt = 0
m_cnt = 0
for s in S:
    if cnt == 6:
        if s == 'e':
            cnt = 7
        else:
            if m_cnt < cnt:
                m_cnt = cnt
            cnt = 0
    if cnt == 5:
        if s == 'c':
            cnt = 6
        else:
            if m_cnt < cnt:
                m_cnt = cnt
            cnt = 0
    if cnt == 4:
        if s == 'n':
            cnt = 5
        else:
            if m_cnt < cnt:
                m_cnt = cnt
            cnt = 0
    if cnt == 3:
        if s == 'e':
            cnt = 4
        else:
            if m_cnt < cnt:
                m_cnt = cnt
            cnt = 0
    if cnt == 2:
        if s == 'y':
            cnt = 3
        else:
            if m_cnt < cnt:
                m_cnt = cnt
            cnt = 0
    if cnt == 1:
        if s == 'e':
            cnt = 2
        else:
            if m_cnt < cnt:
                m_cnt = cnt
            cnt = 0
    if cnt == 0:
        if s == 'k':
            cnt = 1 
        else:
            if m_cnt < cnt:
                m_cnt = cnt
            cnt = 0
if m_cnt < cnt:
    m_cnt = cnt
            
cnt2 = 0
m_cnt2 = 0
for s in S[::-1]:
    if cnt2 == 6:
        if s == 'k':
            cnt2 = 7
        else:
            if m_cnt2 < cnt2:
                m_cnt2 = cnt2
            cnt2 = 0
    if cnt2 == 5:
        if s == 'e':
            cnt2 = 6
        else:
            if m_cnt2 < cnt2:
                m_cnt2 = cnt2
            cnt2 = 0
    if cnt2 == 4:
        if s == 'y':
            cnt2 = 5
        else:
            if m_cnt2 < cnt2:
                m_cnt2 = cnt2
            cnt2 = 0
    if cnt2 == 3:
        if s == 'e':
            cnt2 = 4
        else:
            if m_cnt2 < cnt2:
                m_cnt2 = cnt2
            cnt2 = 0
    if cnt2 == 2:
        if s == 'n':
            cnt2 = 3
        else:
            if m_cnt2 < cnt2:
                m_cnt2 = cnt2
            cnt2 = 0

    if cnt2 == 1:
        if s == 'c':
            cnt2 = 2
        else:
            if m_cnt2 < cnt2:
                m_cnt2 = cnt2
            cnt2 = 0

    if cnt2 == 0:
        if s == 'e':
            cnt2 = 1
        else:
            if m_cnt2 < cnt2:
                m_cnt2 = cnt2
            cnt2 = 0
if m_cnt2 < cnt2:
    m_cnt2 = cnt2

if m_cnt + m_cnt2 >=7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()

ans = False

if S[:7] == "keyence":
    ans = True

if S.find("k") != -1:
    if S.find("keyenc")!= -1 and S[-1] == "e":
            ans = True
    if S.find("keyen")!= -1 and S[-2:] == "ce":
        ans = True
    if S.find("keye")!= -1 and S[-3:] == "nce":
        ans = True
    if S.find("key")!= -1 and S[-4:] == "ence":
        ans = True
    if S.find("ke")!= -1 and S[-5:] == "yence":
        ans = True
    if S.find("k")!= -1 and S[-6:] == "eyence":
        ans = True

else:
    if S[-7:] == "keyence":
        ans = True

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

Submission status: Wrong Answer

Solution code:
import sys

s = input()

f = True
ac = 'keyence'
i = 0
j = 0

while i < len(s):
    if j == len(ac):
        break
    if s[i] == ac[j] and f:
        i += 1
        j += 1
    elif f:
        k = 1
        l = 1
        while abs(k) < len(ac) - j:
            if s[len(s) - k] == ac[len(ac) - l]:
                k += 1
                l += 1
            else:
                print('NO')
                sys.exit()
        break
    else:
        print('NO')
        sys.exit()

print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
key = list("keyence")
count = 0
cut = 0
flag = False
flagexit = False
for c in s:
    if count != 7 and key[count] == c:
        count += 1
        if flag:
            flagexit = True
    else:
        flag = True
        if flagexit:
            print("NO")
            exit()
if count == 7:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
S = input()
keyence = "keyence"

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

print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

s.find('keyence'[0:])
for i, _ in enumerate('keyence'):
    index = s.find('keyence'[i:])
    if index > 0 and s.find('keyence'[:i]) < index:
        print('YES')
        break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
N = input()

S = 'keyence'
index = 0
for item in N:
    if S[index] == item:
        index += 1
    else:
        break

print('YES' if S[len(S) - index - 1:] == N[-(len(S) - index):] else 'NO')

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import re
if re.compile(r'.*k.*e.*y.*e.*n.*c.*e.*').search(input()):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
tmp = "keyence"
# if s == "keyence":
#     print("YES")
#     exit()
cnt = 0
aaa = True
for i in s:
    if i == tmp[0]:
        aaa = True
        tmp = tmp[1:]
        if len(tmp) == 0:
            break
    else:
        if aaa and cnt == 0:
            aaa = False
            cnt += 1
        elif not aaa and cnt == 1:
            pass
        else:
            break

print("YES" if len(tmp) == 0 else "NO")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  1/13 21:11:56 2019

# Usage
#
"""
from collections import Counter

def get_input():
    return input()

def solve(s):
    counted = Counter(s)
    v = counted.keys()
    for i in list("keyence"):
        if i in v:
            continue
        else:
            return "NO"
    return "YES"


if __name__ == '__main__':
	print(solve(get_input()))

Submission status: Wrong Answer

Solution code:
S = input()

A = ["k","ke","key","keye","keyen","keyenc"]
A = list(reversed(A))
B = ["eyence","yence","ence","nce","ce","e"]
ans = "NO"

if "keyence" in S :
    if (S[:7] == "keyence") or (S[-7:] == "keyence") :
        ans = "YES"
    else :
        ans = "NO"
else :
    for i in range(len(A)) :
        if S[:len(A[i])] == A[i] :
            if (B[i] in S) and (S[-len(B[i]):] == B[i]) :
                ans = "YES"
            else :
                ans = "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
S = input()
WORD = "keyence"

if S == WORD:
    print("YES")
    exit()

for s in range(len(S)):
    for e in range(len(S)-s):
        a = S[:s]
        sub = S[s:e]
        b = S[e:]
        # print(a)
        # print(sub)
        # print(b)
        if a+b == WORD:
            print("YES")
            exit()

print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
ok = False
string = 'keyence'
j = 0
ok = False
for i in s:
    if i == string[j]:
        j += 1
    if j == 7:
        ok = True
        break


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

Submission status: Wrong Answer

Solution code:
s=list(input())
t=list("keyence")
j=0
c=0
for i in s:
    if i==t[c]:
        j+=1
        if j==7:
            print("YES")
            exit()
        c+=1
print("NO")

Submission status: Wrong Answer

Solution code:
S = input()


x = "keyence"

if S[:7] == x:
    print("YES")
    exit()

for i in range(0,len(x)):
    print(S[:i]== x[:i] , S[-(7-i):] == x[i:])
    if S[:i]== x[:i] and S[-(7-i):] == x[i:] :
        print("YES")
        exit()
    # tr:
    #     index1 = S.index(x[:i])
    #     index2 = S.rindex(x[i:])
    #     print(index1,index2)
    #     if index1==0 and index2+i == len(S) and index1<index2:
    #         print(index1,index2)
    #         print("YES")
    #         exit()
    # except ValueError:
    #     continue
print("NO")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
import re
sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    K = 'keyence'
    if S == K:
        return 'YES'
    if re.match('[a-z]+'+K, S):
        return 'YES'
    if re.match(K+'[a-z]+', S):
        return 'YES'

    for i in range(len(K)):
        if re.match(K[:i]+'[a-z]+'+K[i:], S):
            return 'YES'

    return 'NO'


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import re
S = input()

result = ''
for v in S:
    if result == '' and v == 'k':
        result += 'k'
    if result == 'k' and v == 'e':
        result += 'e'
    if result == 'ke' and v == 'y':
        result += 'y'
    if result == 'key' and v == 'e':
        result += 'e'
    if result == 'keye' and v == 'n':
        result += 'n'
    if result == 'keyen' and v == 'c':
        result += 'c'
    if result == 'keyenc' and v == 'e':
        result += 'e'
if result == 'keyence':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

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

if s.startswith('key') and s.endswith('ence'):
    print('YES')

else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

word = "keyence"

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

print("NO")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
s = input()
n = len(s)
k = 0
for i in range(n):
    for j in range(i,n+1):
        if "keyence" == s[:i] + s[j:]:
            k = 1
            break
if k == 0:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
import sys

s = input()

f = True
ac = 'keyence'
i = 0
j = 0

while i < len(s):
    if s[i] == ac[j] and f:
        i += 1
        j += 1
    elif f:
        k = 1
        l = 1
        while abs(k) < len(ac) - j:
            if s[len(s) - k] == ac[len(ac) - l]:
                k += 1
                l += 1
            else:
                print('NO')
                sys.exit()
        break
    else:
        print('NO')
        sys.exit()

print('YES')

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
if S == "keyence" or S[1:] == "keyence" or S[:N-1] == "keyence":
    print("YES")
    exit(0)

for k in range(N-1):
    for l in range(k+1,N):
        if S[:k]+S[l+1:] == "keyence":
            print("YES")
            exit(0)
print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

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

Submission status: Wrong Answer

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

index = 0
pre_false = 0
num_false = 0
flg = 1
for now, s in enumerate(S):
    if s == correct[index]:
        index += 1
        pre_false = 0
    else:
        if pre_false == 0:
            num_false += 1
            pre_false = 1

    # contain keyence
    if index == len(correct):
        flg = 0
        if num_false == 0:
            print("YES")
        elif num_false == 1:
            if now == len(S) - 1:
                print("YES")
            else:
                print("NO")
        else:
            print("NO")
        break

# not contain
if flg:
    print("NO")

Submission status: Wrong Answer

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()
n = 0
cnt = 0
key = 'keyence'
state = 0
for i in range(len(S)):
    s = S[i]
    if n == len(key) - 1:
        break
    if s == key[n]:
        n += 1
        state = 0
    else:
        if state == 0:
            cnt += 1
        state = 1

    if cnt > 1:
        print('NO')
        exit()


if i == len(S) - 1 and n == len(key) - 1:
    print('YES')
elif cnt == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
i = 0
a = [0]*7
while i < n:
    if s[i] == 'k':
        i += 1
        break
    else:
        i += 1
        a[0] = 1
        if i == n:
            print('NO')
            exit()
if i == n:
    print('NO')
    exit()
while i < n:
    if s[i] == 'e':
        i += 1
        break
    else:
        i += 1
        a[1] = 1
        if i ==n:
            print('NO')
            exit()
if i == n:
    print('NO')
    exit()
while i < n:
    if s[i] == 'y':
        i += 1
        break
    else:
        i += 1
        a[2] = 1
        if i ==n:
            print('NO')
            exit()
if i == n:
    print('NO')
    exit()
while i < n:
    if s[i] == 'e':
        i += 1
        break
    else:
        i += 1
        a[3] = 1
        if i == n:
            print('NO')
            exit()
if i == n:
    print('NO')
    exit()
while i < n:
    if s[i] == 'n':
        i += 1
        break
    else:
        i += 1
        a[4] = 1
        if i ==n:
            print('NO')
            exit()
if i == n:
    print('NO')
    exit()
while i < n:
    if s[i] == 'c':
        i += 1
        break
    else:
        i += 1
        a[5] = 1
        if i ==n:
            print('NO')
            exit()
if i == n:
    print('NO')
    exit()
while i < n:
    if s[i] == 'e':
        i += 1
        break
    else:
        i += 1
        a[6] = 1
        if i == n:
            print('NO')
            exit()

if a.count(1) <= 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
org_str = input()
pattern = r"k*e*y*e*n*c*e*"
matchOB = re.match(pattern , org_str)
if matchOB:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
#s = list(map(int, input().split()))
s = input()
yojou = len(s) - 7

for i in range(yojou + 1):
    # print(s[0:i] + s[i + yojou:])
    if s[0:i] + s[i + yojou:] == 'keyence':
        print("YES")
        exit(0)
print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
#N = int(input())
#N = list(map(int, input().split()))
# a = list(map(int, input().split()))
# X = [int(input()) for _ in range(N)]

ans = 'YES'
keyence = 'keyence'

for i in range(len(S)):
    if i == 7:
        S = S[0:7]
        break
    if keyence[i] == S[i]:
        continue
    else:
        S = S[0:i] + S[len(S) - 1 - i:]
        break


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