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:
S = input()
cnt = 0
m_cnt = 0
res = []
for i, s in enumerate(S):
    if cnt == 6:
        if s == 'e':
            cnt = 7
        else:
            res.append([cnt, i])                
            cnt = 0
    if cnt == 5:
        if s == 'c':
            cnt = 6
        else:
            res.append([cnt, i])                
            cnt = 0
    if cnt == 4:
        if s == 'n':
            cnt = 5
        else:
            res.append([cnt, i])                
            cnt = 0
    if cnt == 3:
        if s == 'e':
            cnt = 4
        else:
            res.append([cnt, i])                
            cnt = 0
    if cnt == 2:
        if s == 'y':
            cnt = 3
        else:
            res.append([cnt, i])                
            cnt = 0
    if cnt == 1:
        if s == 'e':
            cnt = 2
        else:
            res.append([cnt, i])                
            cnt = 0
    if cnt == 0:
        if s == 'k':
            cnt = 1 
        else:
            res.append([cnt, i])                
            cnt = 0
res.append([cnt, i])

cnt2 = 0
m_cnt2 = 0
res2 = []
for i, s in enumerate(S[::-1]):
    if cnt2 == 6:
        if s == 'k':
            cnt2 = 7
        else:
            res2.append([cnt2, i])                
            cnt2 = 0
    if cnt2 == 5:
        if s == 'e':
            cnt2 = 6
        else:
            res2.append([cnt2, i])                
            cnt2 = 0
    if cnt2 == 4:
        if s == 'y':
            cnt2 = 5
        else:
            res2.append([cnt2, i])                
            cnt2 = 0
    if cnt2 == 3:
        if s == 'e':
            cnt2 = 4
        else:
            res2.append([cnt2, i])                
            cnt2 = 0
    if cnt2 == 2:
        if s == 'n':
            cnt2 = 3
        else:
            res2.append([cnt2, i])                
            cnt2 = 0

    if cnt2 == 1:
        if s == 'c':
            cnt2 = 2
        else:
            res2.append([cnt2, i])                
            cnt2 = 0

    if cnt2 == 0:
        if s == 'e':
            cnt2 = 1
        else:
            res2.append([cnt2, i])                
            cnt2 = 0
res2.append([cnt, i])

f = False
for i in res:
    if i[0] == 7:
        f = True
for i in res2:
    if i[0] == 7:
        f = True
for a in res:
    for b in res2:
        if a[1]+1 + b[1]+1 < len(S):
            if a[0] + b[0] >= 7:
                f = True
if f:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
ans = False
ans_str = {True:'YES', False:'NO'}
# 7 chars
target = 'keyence'

input_str = input()
input_len = len(input_str)
if input_len < 7:
    print('NO')
    sys.exit()

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

Submission status: Wrong Answer

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

T = "keyence"

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

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

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

Submission status: Wrong Answer

Solution code:
s = input()
finalcheck = 0
moji = 'keyence'
for i in range(1,8):
    check = 0
    for j in range(len(s)-i+1):
        if moji[:i] == s[j:j+i]:
            check = j+i
            if i == 7:
                if len(s[:j]) == 0 or len(s[j+i:]) == 0: finalcheck = 1
            break
    if check != 0:
        for j in range(check,len(s)-i+1):
            if moji[i:] == s[j:j+len(s)-i]:
                finalcheck = 1
                break
    if finalcheck == 1:break
if finalcheck:print('YES')
else:print('NO')

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")
            break
        elif num_false == 1:
            if now == len(S) - 1:
                print("YES")
                break
            else:
                num_false = 1
                pre_false = 1
                index = 0
        else:
            print("NO")
            break

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

Submission status: Wrong Answer

Solution code:
import sys, re

P = r'(.*)k(.*)e(.*)y(.*)e(.*)n(.*)c(.*)e(.*)'

s = input().rstrip('\n')

m = re.match(P, s)

if m is not None:
  print([ x for x in m.groups() if x])
  if len([ x for x in m.groups() if x]) <= 1:
    print('YES')
    sys.exit()
print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
ans = "keyence"
if S.find(ans) == 0:
    print("YES")
    exit()

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

Submission status: Wrong Answer

Solution code:
import re

s = input()
p = '^key[a-z]*ence|key[a-z]*ence$|^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)!=-1 and (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)!=-1 and s.find(b)==len(s)-len(b):
      print("YES")
      break
  else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
s = input()
time = 0
i = 0
n = 0
for i in range(7):
    if s[i+n] != "keyence"[i]:
        if time >= 2:
            print("NO")
            sys.exit()
        time += 1
        while "keyence"[i] != s[i+n]:
            n += 1
            if i+n >= len(s):
                print("NO")
                sys.exit()
print("YES")

Submission status: Wrong Answer

Solution code:
import re
s = input()
pat = '\w*'+"k"+'\w*'+"e"+'\w*'+"y"+'\w*'+"e"+'\w*'+"n"+'\w*'+"c"+'\w*'+"e"+'\w*'

if re.match:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
import sys
ans = False
ans_str = {True:'YES', False:'NO'}
# 7 chars
target = 'keyence'

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

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
f1=0
f2=0
answer='NO'
while(1):
    if (n<=i or len(I)==0):
        if len(I)==0:
            answer='YES'
        break
        
    if (s[i]==I[0]):
        del(I[0])
        i+=1
        if f1==1:
            f2=1

    else:
        if f2==1:break
        if f1==0:f1=1    
        i+=1

print(answer)

Submission status: Wrong Answer

Solution code:
S = list(input())
ans = ['k','e','y','e','n','c','e']

for s_ in S:
  for ans_ in ans:
    if s_ == ans_:
      ans.remove(s_)
    else:
      break

for s_ in S:
  for ans_ in ans:
    if s_ == ans_:
      break

for s_ in S:
  for ans_ in ans:
    if s_ == ans_:
      ans.remove(s_)
    else:
      break

if ans == []:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
import sys
import re
s = input()
k = 'keyence'
for i in range(8):
    if re.match(k[:i] + '[a-z]*' + k[i:], s):
        print('YES')
        sys.exit()
print('NO')

Submission status: Wrong Answer

Solution code:
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy
import scipy

from collections import defaultdict
from pprint import pprint

S = input()
ANS = "keyence"

i = 0
started_delete = False
deleted = False
ans = False
j = 0
for s in S:
    j += 1
    if s == ANS[i]:
        if started_delete:
            started_delete = False
        if i == len(ANS) - 1:
            if not deleted or len(S) == j:
                ans = True
            break
        i += 1;
        continue
    if started_delete:
        continue
    if not deleted:
        started_delete = True
        deleted = True
        continue
    else:
        break

if ans:
    print("YES")
else:
    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[(i + start):].index(T[start:])
        # print(i , j)
        found = True
        break
    except ValueError:
        found = False

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

Submission status: Wrong Answer

Solution code:
text = input()
ans = ["k","e","y","e","n","c","e"]
count = 2
flag = 1
i = 0
plus = 0
for ob in ans:
    if i > len(text):
        break
    if ob == text[i]:
        i+=1
        continue
    
    else:
        while ob != text[i]:
            i+=1
            if i >= len(text):
                flag = 0
                break
        i+=1
        count -=1
        if count == 0:
            flag =0
            break

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

Submission status: Wrong Answer

Solution code:
a = [c for c in input()]
if "k" in a:
	del a[:a.index("k")+1]
	if "e" in a:
		del a[:a.index("e")+1]
		if "y" in a:
			del a[:a.index("y")+1]
			if "e" in a:
				del a[:a.index("e")+1]
				if "n" in a:
					del a[:a.index("n")+1]
					if "c" in a:
						del a[:a.index("c")+1]
						if "e" in a:
							print("YES")
						else:
							print("NO")
					else:
						print("NO")
				else:
					print("NO")
			else:
				print("NO")
		else:
			print("NO")
	else:
		print("NO")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
correct_s = "keyence"
correct_count = 0
false_index_list = []

for i in range(len(s)):
    if s[i] == correct_s[correct_count]:
        correct_count += 1
    else:
        false_index_list.append(i)
    if correct_count == len(correct_s):
        break

if len(false_index_list) == len(s):
    print("NO")
    exit()

for i in range(1, len(false_index_list)):
    if false_index_list[i] - false_index_list[i-1] != 1:
        print("NO")
        exit()

print("YES")
exit()

Submission status: Wrong Answer

Solution code:
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:
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b

import re


S = input()

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

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

Solution code:
s=input()
k="keyence"
c=0
f=0
t=0
pre=True
for i in range(len(s)):
    if c==7:
        t=1
        break
    elif f==2:
        break
    elif s[i]==k[c]:
        c+=1
        pre=True
    else:
        if pre:
            f+=1
        pre=False
if c==7:
    if f==1 and t==1:
        print("NO")
    else:
        print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
ans = "keyence"
if S.find(ans) != -1:
    print("YES")
    exit()

for i in range(len(ans)-1):
    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().rstrip()
target = list('keyence')
wrong = []
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: wrong.append(i)

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

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

Submission status: Wrong Answer

Solution code:
import re
x = input()

result = re.match(".*k.*e.*y.*e.*n.*c.*e.*", x)

if result == None :
    print("NO")
else :
    print("YES")

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()
	elif STEP == 8:
		if FLAG == 0:
			FLAG = 8
		elif FLAG == 8:
			pass
		else:
			print("NO")
			exit()

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

Submission status: Wrong Answer

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

for i in range(len(t)-1):
    if S.count(t[:i+1])==1 and S.count(t[i+1:])==1:
        if S.index(t[:i+1])<=S.index(t[i+1:]):
            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(1,len(S)- i+1):
        S_tmp = S

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

        S_tmp = 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()
finalcheck = 0
moji = 'keyence'
for i in range(1,8):
    check = 0
    for j in range(len(s)-i+1):
        if moji[:i] == s[j:j+i]:
            check = j+i
            if i == 7:finalcheck = 1
            break
    if check != 0:
        for j in range(check,len(s)-i+1):
            if moji[i:] == s[j:j+len(s)-i]:
                finalcheck = 1
                break
    if finalcheck == 1:break
if finalcheck:print('YES')
else:print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
ans = "keyence"
if S.find(ans) != -1:
    print("YES")
    exit()

for i in range(len(ans)-1):
    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:
import re
input_string = input()
keyence = "keyence"
patterns = ['k.*eyence', 'ke.*yence', 'key.*ence', 'keye.*nce', 'keyen.*ce', 'keyenc.*e', '.*keyence', 'keyence.*']
flag = False
for i in range(len(patterns)):
    if re.match(patterns[i], input_string):
        flag = True
        break
if flag == True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
ans = False
ans_str = {True:'YES', False:'NO'}
# 7 chars
target = 'keyence'

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

Submission status: Wrong Answer

Solution code:
s=input()
c=[]
for k in s:
  c.append(k)
n=["k","e","y","e","n","c","e"]
ans=0
for i in n:
  for j in range(len(c)):
    a=c.pop(0)
    if i==a:
      ans+=1
      break
  if ans==7:
    break
if ans==7:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
from sys import stdin

def main():
    S = input()

    l = len(S)
    if S[:7] == 'keyence' or S[l-7:] == 'keyence':
        ans = 'YES'
    else:
        s = 'keyence'
        for i in range(1, 8):
            if S[:i] != s[:i]:
                break
        j = l - i
        if S[j:] == s[i-1:]:
            ans = 'YES'
        else:
            ans = 'NO'
    print(ans)

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

Submission status: Wrong Answer

Solution code:
import sys

s = input()
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 + 1, len(s)):
                if s[j] == 'e':
                    for k in range(j + 1, len(s)):
                        if s[k] == 'y':
                            for x in range(k + 1, len(s)):
                                if s[x] == 'e':
                                    for y in range(x + 1, len(s)):
                                        if s[y] == 'n':
                                            for z in range(y + 1, len(s)):
                                                if s[z] == 'c':
                                                    for b in range(z + 1, len(s)):
                                                        if s[b] == 'e':
                                                            print("YES")
                                                            sys.exit()


print("NO")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
S = input()
S_list = [s for s in S]
trueWord = 'keyence'
n = 0
skip = 0
answer = 'NO'
pre = True
cur = True

for i in range(len(S)):
    s = S_list[i]
    if s == trueWord[n]:
        n += 1
        cur = True
    else:
        cur = False


    
    if n == len(trueWord) - 1:
        answer = 'YES'
        break
    
    if pre != cur:
        skip += 1

    if skip > 3:
        break
    
    pre = cur


print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re

S=input()

if re.match("keyence",S) or re.match("[a-x\s]+keyence",S) or re.match("k[a-x\s]+eyence",S) or re.match("ke[a-x\s]+yence",S) or re.match("key[a-x\s]+ence",S) or re.match("keye[a-x\s]+nce",S) or re.match("keyen[a-x\s]+ce",S) or re.match("keyenc[a-x\s]+e",S)  or re.match("keyence[a-x\s]+",S):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
t='keyence'
ans=[]
if s == t:
    print('YES')
else:
    for i in range(0,8):
        try:
            if s.index(t[0:i])+s[i:].index(t[i:7])>0:
                ans.append(1)
            else:
                ans.append(0)
        except:
            ans.append(0)
    print('YES' if any(ans) else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()
correct_s = "keyence"
correct_count = 0
false_index_list = []

for i in range(len(s)):
    if s[i] == correct_s[correct_count]:
        correct_count += 1
    else:
        false_index_list.append(i)
    if correct_count == len(correct_s):
        break
#print(false_index_list)
for i in range(1, len(false_index_list)):
    if len(false_index_list) == len(s):
        print("NO")
        exit()
    if false_index_list[i] - false_index_list[i-1] != 1:
        print("NO")
        exit()

print("YES")
exit()

Submission status: Wrong Answer

Solution code:
s = input()
t = "keyence"
p = 0
for i in range(len(s)):
    if p == 0:
        if i <= 6:
            if s[i] != t[i]:
                k = i
                p = 1
    elif p == 1:
        if s[i] == t[k]:
            j = i
            p = 2
        if i == len(s) - 1:
            if s[i] == "e":
                print("YES")
                exit()
            else:
                print("NO")
                exit()
    elif p == 2:
        if k + i - j <= 6:
            if s[i] != t[k + i - j]:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
print("YES")

Submission status: Wrong Answer

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

if len(S) == 7:
    if S==keyence:
        print('YES')
    else:
        print('NO')
else :
    for i in range(1,7):
      if keyence[:i] in S and keyence[i:] in S:
          print('YES')
          break
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
T = "keyence"
lenS = len(S)
lenT = len(T)

i = 0
j = 0

while S[i] == T[j]:
    i += 1
    j += 1
    if i == lenS or j == lenT:
        print("YES")
        exit(0)

while S[i] != T[j]:
    i += 1
    if i == lenS:
        print("NO")
        exit(0)

if S[i:] == T[j:]:
    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[s.index('k')+1:]:
    print('YES')
elif 'ke' in s and 'yence' in s[s.index('ke')+1:]:
    print('YES')
elif 'key' in s and 'ence' in s[s.index('key')+1:]:
    print('YES')
elif 'keye' in s and 'nce' in s[s.index('keye')+1:]:
    print('YES')
elif 'keyen' in s and 'ce' in s[s.index('keyen')+1:]:
    print('YES')
elif 'keyenc' in s and 'e' in s[s.index('keyenc')+1:]:
    print('YES')
elif 'keyence' in s:
    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:
import re
input_string = input()
keyence = "keyence"
patterns = ['k.*eyence', 'ke.*yence', 'key.*ence', 'keye.*nce', 'keyen.*ce', 'keyenc.*e']
flag = False
for i in range(len(patterns)):
    if re.match(patterns[i], input_string):
        flag = True
        break
if flag == True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import re

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

Submission status: Wrong Answer

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

    print("NO")

Submission status: Wrong Answer

Solution code:
def m():
    S = input()
    a = 'keyence'
    x = 0
    flag = 0
    for i in S:
        if x >=6:
            break
        if i == a[x]:
            x += 1
            continue
        flag += 1
        if flag > 1:
            return 'NO'

    if x >=6:
        return 'YES'
    else:
        return 'NO'

print(m())

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')
elif S in N:
    print('YES')
else:
    print('YES' if S[len(S) - index - 1:] == N[-(len(S) - index):] else '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)!=-1 and s.find(b)==len(s)-len(b):
      print("YES")
      break
  else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
t='keyence'
ans=[]
for i in range(0,8):
    try:
        if s.index(t[0:i])+s[i:].index(t[i:7])>=0:
            ans.append(1)
        else:
            ans.append(0)
    except:
        ans.append(0)
print('YES' if any(ans) else '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 k_idx == len(K):
        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:
str = ['k', 'e', 'y', 'e', 'n', 'c','e']
l = input() 

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

Submission status: Wrong Answer

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

T = "keyence"

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

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

Submission status: Wrong Answer

Solution code:
S = input()

keyword = 'keyence'
cnt = 0

while S:
    if cnt == 7:
        break

    moji = S[0]
    S = S[1:]
    if moji == keyword[0]:
        cnt += 1
        keyword = keyword[1:]

if (len(S) != 0)or(len(keyword) != 0):
    print('NO')
elif cnt == 7:
    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:
S = input()
if "keyence"in S:
	print("YES")
	exit()
for i in range(len(S)-6):
	#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:
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy
import scipy

from collections import defaultdict
from pprint import pprint

S = input()
ANS = "keyence"

i = 0
started_delete = False
deleted = False
ans = False
for s in S:
    if s == ANS[i]:
        if started_delete:
            started_delete = False
        if i == len(ANS) - 1:
            ans = True
            break
        i += 1;
        continue
    if started_delete:
        continue
    if not deleted:
        started_delete = True
        deleted = True
        continue
    else:
        break

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

Submission status: Wrong Answer

Solution code:
S=input()
S=S.replace("keyence","A")
if S=="A":
    print("YES")
elif S[0]=="A" and S[len(S)-1]!="A":
    print("YES")
elif S[len(S)-1]!="A":
    print("YES")
    
S1=S.replace("K","A")
S1=S1.replace("eyence","B")
if S1[0]=="A" and S1[len(S1)-1]=="B":
    print("YES")
S2=S.replace("Ke","A")
S2=S2.replace("yence","B")
if S2[0]=="A" and S2[len(S2)-1]=="B":
    print("YES")
S3=S.replace("Key","A")
S3=S3.replace("ence","B")
if S3[0]=="A" and S3[len(S3)-1]=="B":
    print("YES")
S4=S.replace("Keye","A")
S4=S4.replace("nce","B")
if S4[0]=="A" and S4[len(S4)-1]=="B":
    print("YES")
S5=S.replace("Keyen","A")
S5=S5.replace("ce","B")
if S5[0]=="A" and S5[len(S5)-1]=="B":
    print("YES")
S6=S.replace("Keyenc","A")
S6=S6.replace("e","B")
if S6[0]=="A" and S6[len(S6)-1]=="B":
    print("YES")

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"
    if counted["e"] >= 3:
        return "YES"
    else:
        return "NO"


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

Submission status: Wrong Answer

Solution code:
ans = list("keyence")

S = input()
for i in range(len(S)):
  if len(ans) == 0:
    break
  if S[i] == ans[0]:
    ans.pop(0)

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

Submission status: Wrong Answer

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