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()
search="keyence"
idx=0
flg = False
ans="NO"
for c in s:
    if c == search[idx]:
        idx += 1
    if idx >= 7:
        flg=True
        break
if flg:
    idx = -1
    for i in range(7):
        x=s.find(search[0:i])
        #print("ps=%s, ns=%s, reduce=%s" %(search[0:i], search[i+1:], s[x+i+i:]))
        if s[x+i+1:].find(search[i+1:]):
            ans = "YES"
            break
    print(ans)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
if(s[0:7]=='keyence'):
    print('YES')
elif(s[-7:]=='keyence'):
    print('YES')    
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: Wrong Answer

Solution code:
S = input()

tag = 'keyence'

ans = 0

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

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

Submission status: Wrong Answer

Solution code:
S=list(input())
if "k" and "e" and "y" and "e" and "n" and "c" and "e" in S:
    for i in range(len(S)):
        if S[i]=="k":
            if S[i+1]=="e":
                if S[i+2]=="y":
                    if S[i+3]=="e":
                        if S[i+4]=="n":
                            if S[i+5]=="c":
                                if S[i+6]=="e":
                                    print("YES")
                                    break
                                else:
                                    if S[-1]=="e":
                                        print("YES")
                                        break
                                    else:
                                        print("No")
                                        break
                            else:
                                if S[-1]=="e" and S[-2]=="c":
                                    print("YES")
                                    break
                                else:
                                    print("No")
                                    break
                        else:
                            if S[-1]=="e" and S[-2]=="c" and S[-3]=="n":
                                print("YES")
                                break
                            else:
                                print("NO")
                                break
                    else:
                        if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e":
                            print("YES")
                            break
                        else:
                            print("NO")
                            break
                else:
                    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y":
                        print("YES")
                        break
                    else:
                        print("NO")
                        break
            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")
                    break
                else:
                    print("NO")
                    break
else:
    print("NO")

Submission status: Wrong Answer

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

flag = False
ng_flag = False
count = 0
s_count = 0
for s in data:
    if 6 < s_count:
        if not ng_flag:
            count += 1
            ng_flag = True
        continue
    elif s == comp_s[s_count]:
        s_count += 1
        ng_flag = False
    else:
        if not ng_flag:
            count += 1
            ng_flag = True

if len(comp_s) == s_count and count <= 1:
    flag = True

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

Submission status: Wrong Answer

Solution code:
S = input()
target = "keyence"
cnt = 0

for moji in S:
    if moji == target[cnt]:
        cnt += 1
    else:
        if target[cnt:] in S:
            print("YES")
            break
        else:
            print("NO")
            break
if cnt == len(target):
    print("YES")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline

S = input()
key_word = "keyence"

cnt = 0
i = 0
for j in range(len(key_word)):
    k = key_word[j]
    for i in range(len(S)):
        s = S[i]
        if s == k:
            i += 1
            cnt += 1
            break

if cnt==7:
    ans = "YES"
else:
    ans = "NO"

print(ans)

Submission status: Wrong Answer

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

Solution code:
S = input()
ans = 0



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

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

Submission status: Wrong Answer

Solution code:
S = list(input())
s1 = list("keyence")

x = 0
y = 0
z = [1]
for i in range(len(S)):
  if x <= 6:
    #print(S[i])
    #print(s1[x])
    if S[i] == s1[x]:
      x += 1
      z.append(0)
    elif x != 0 and z[i] == 0:
      y += 1
      z.append(1)
    else:
      z.append(1)
    print(y)
  else:
    break


if y <= 1 and x != 0:
  print("YES")  
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S=input()
K=list('keyence')
n=0
flg=0
i_cut=[0,0]
for i,c in enumerate(S):
  if c==K[n]:
    if flg==1:
      i_cut[1] = i-1
      break 
    n+=1
    if n>=7:
      if flg==0:
        i_cut = [i+1,len(S)]
        break  
  else:
    if flg==0:
      i_cut[0] = i
      flg +=1
 
if S[:i_cut[0]]+S[1+i_cut[1]:]=='keyence':
  print("Yes")
else:
  print('No')

Submission status: Wrong Answer

Solution code:

P = list(str(input()))

#print(P[0])

N = len(P)

flg = 0

kaisu = 0

hantei = 0
i=0
j=0
k=0
l=0
m=0
n=0
o =0
w1=0
w2=0
w3=0
w4=0
w5=0
w6=0
w7 =0

for i in range(N):
    if P[i] == "k":
        w1 = i
        flg = 0
        for j in range(i+1,N):
            if P[j]=="e":
                w2 = j
                if w1+1 != w2:
                    flg = flg + 1
                for k in range(j+1,N):
                    if P[k]=="y":
                        w3 = k
                        if w2+1 != w3:
                            flg = flg + 1
                        for l in range(k+1,N):
                            if P[l]=="e":
                                w4 = l
                                if w3+1 != w4:
                                    flg = flg + 1
                                for m in range(l+1,N):
                                    if P[m]=="n":
                                        w5 = m
                                        if w4+1 != w5:
                                            flg = flg + 1
                                        for n in range(m+1,N):
                                                if P[n]=="c":
                                                    w6 = n
                                                    if w5+1 != w6:
                                                        flg = flg + 1
                                                    for o in range(n+1,N):
                                                        if P[o]=="e":
                                                            w7 = o
                                                            if w6+1 != w7:
                                                                flg = flg + 1
                                                            if  flg <= 1:
                                                                print("YES")
                                                                hantei = 1

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

Submission status: Wrong Answer

Solution code:
from sets import Set

s = raw_input().lower()
r_str = 'keyence'
k_split = list()
for i in xrange(len(r_str)):
	a = list()
	a.append(r_str[0 : i])
	a.append(r_str[i : ])
	k_split.append(a)

print_sig = False

for i in xrange(len(k_split)):
	single_split = k_split[i]
	f = s.find(single_split[0])
	b = s.find(single_split[1])
	if f != -1 and b != -1 and f < b:
		if f > 0 and b - f == 1 and b + len(single_split[1]) == len(s):
			print_sig = True
		if (f == 0) and b + len(single_split[1]) == len(s):
			print_sig = True
		if b + len(single_split[1]) == len(r_str):
			print_sig = True
		if print_sig == True:
			print 'YES'
			break

if print_sig == False:
	print 'NO'

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
S=input()
# print(S)
if S=="keyence":
	print("Yes")
	exit(0)
a="keyence"
# print(len(a))
for i in range(1,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: Wrong Answer

Solution code:
import sys
s = input()
l = len(s)

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



for i in range(1, l-6):
    a = s[0: i] + s[i + l - 7: l]
    if a == 'keyence':
        print('YES')
        sys.exit()

if s[l-7:l-1] == 'keyence':
    print('YES')

print('NO')

Submission status: Wrong Answer

Solution code:
S=list(input())
if "k" and "e" and "y" and "e" and "n" and "c" and "e" in S:
    for i in range(len(S)):
        if S[i]=="k":
            if S[i+1]=="e":
                if S[i+2]=="y":
                    if S[i+3]=="e":
                        if S[i+4]=="n":
                            if S[i+5]=="c":
                                if S[i+6]=="e":
                                    print("YES")
                                    break
                                else:
                                    if S[-1]=="e":
                                        print("YES")
                                        break
                                    else:
                                        print("No")
                                        break
                            else:
                                if S[-1]=="e" and S[-2]=="c":
                                    print("YES")
                                    break
                                else:
                                    print("No")
                                    break
                        else:
                            if S[-1]=="e" and S[-2]=="c" and S[-3]=="n":
                                print("YES")
                                break
                            else:
                                print("NO")
                                break
                    else:
                        if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e":
                            print("YES")
                            break
                        else:
                            print("NO")
                            break
                else:
                    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y":
                            print("YES")
                            break
                    else:
                        print("NO")
                        break
            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")
                    break
                else:
                    print("NO")
                    break
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:
#coding:utf-8

def concat(str_list):
    s = ""
    for i in str_list:
        s += i
    return s

in_s = input()
STRNUM = 8
is_key = False
keyence = "keyence"
if keyence in in_s:
    splt_res = in_s.split(keyence)
    if(splt_res[0]=="")|(splt_res[1]==""):
        is_key = True
else:
    for i in range(STRNUM-1):
        str1 = concat(keyence[0:i+1])
        str2 = concat(keyence[i+1:])
        # str1 で分割
        if str1 in in_s:
            splt_res = in_s.split(str1)
            if splt_res[0] == "":
                if str2 in splt_res[1]:
                    splt_res2 = splt_res[1].split(str2)
                    if(splt_res2[0]=="")|(splt_res2[1]==""):
                        is_key = True

if is_key == True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
x='keyence'
if s==x:
  print('YES')
  exit()
if s.count(x)>0:
  p=s.split('keyence')
  if p[0]=='' or p[1]=='':
    print('YES')
    exit()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
else:
  for i in range(1,len(x)):
    a=x[:i]
    b=x[i:]
    if s.count(a)>0 and s.count(b)>0:
      y=s.split(a)
      z=s.split(b)
      if (y[0]=='' and z[1]=='') or y[0]+y[1]=='keyence' or z[0]+z[1]=='keyence':
        print('YES')
        exit()
    else:
      continue
print('NO')

Submission status: Wrong Answer

Solution code:
import re
L = input()
if re.match('.*keyence', L) or re.match('keyence.*', L) or 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):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return -1

a = input().split("!!!")
a = list(a[0])
judge = 0
count = 0 
tmp1 = 0 
tmp2 = 0
A = []
B = []

A.append(my_index(a, 'k'))
tmp1 = my_index(a, 'k')
if (my_index(a, 'k') != -1):
 a[ my_index(a, 'k') ] = 'AAA'
 judge += 1

A.append(my_index(a, 'e'))
tmp2 = my_index(a, 'e')
if (my_index(a, 'e') != -1):
 a[ my_index(a, 'e') ] = 'AAA'
 judge += 1
if (tmp2 - tmp1 >= 2 ):
 count +=1
tmp1 = tmp2

A.append(my_index(a, 'y'))
tmp2 = my_index(a, 'y')
if (my_index(a, 'y') != -1):
 a[ my_index(a, 'y') ] = 'AAA'
 judge += 1
if (tmp2 - tmp1 >= 2 ):
 count +=1
tmp1 = tmp2

A.append(my_index(a, 'e'))
tmp2 = my_index(a, 'e')
if (my_index(a, 'e') != -1):
 a[ my_index(a, 'e') ] = 'AAA'
 judge += 1
if (tmp2 - tmp1 >= 2 ):
 count +=1
tmp1 = tmp2

A.append(my_index(a, 'n'))
tmp2 = my_index(a, 'n')
if (my_index(a, 'n') != -1):
 a[ my_index(a, 'n') ] = 'AAA'
 judge += 1
if (tmp2 - tmp1 >= 2 ):
 count +=1
tmp1 = tmp2

A.append(my_index(a, 'c'))
tmp2 = my_index(a, 'c')
if (my_index(a, 'c') != -1):
 a[ my_index(a, 'c') ] = 'AAA'
 judge += 1
if (tmp2 - tmp1 >= 2 ):
 count +=1
tmp1 = tmp2

A.append(my_index(a, 'e'))
tmp2 = my_index(a, 'e')
if (my_index(a, 'e') != -1):
 a[ my_index(a, 'e') ] = 'AAA'
 judge += 1
if (tmp2 - tmp1 >= 2 ):
 count +=1
tmp1 = tmp2

B = A
A.sort()
if( (A == B) and (judge==7) and (count<=2) ):
 print('YES')
else:
 print("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
#
"""

TARGET = "keyence"
global CREDIT
CREDIT = True


def get_input():
    return input()

def solve(s):
    """
    >>> solve("keyence")
    YES
    >>> solve("keyofscience")
    YES
    >>> solve("ashlfyha")
    NO
    """
    pos = 0

    for i in TARGET:
        if CREDIT:
            pos = mog(s,i,pos)
            if pos == -1:
                return "NO"
        else:
            pos = mogmog(s,i,pos)
            if pos == -1:
                return "NO"
    if CREDIT:
        return "YES"
    else:
        if pos == len(s):
            return "YES"
        else:
            return "NO"
def mogmog(original, target, pos):
    """
    >>> mog("keyence", "k", 0)
    1
    >>> mog("aaa", "k", 0)
    -1
    """
    if len(original) == pos:
        return -1
    if original[pos] == target:
        return pos + 1
    else:
        return -1

def mog(original, target, pos):
    """
    >>> mog("keyence", "k", 0)
    1
    >>> mog("aaa", "k", 0)
    -1
    """
    if len(original) == pos:
        return -1
    if original[pos] == target:
        return pos + 1
    else:
        global CREDIT
        CREDIT = False
        return mog(original, target, pos+1)

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

Submission status: Wrong Answer

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

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


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

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

	if 0<=idx1 and 0<=idx2  and idx1<idx2:
		if idx1+len(p1)==idx2:	#Renzoku
			if  0<idx1 and idx2+len(p2)<len(S)-1:
				pass
			else:
				print "YES"
				quit()

		else:   #Bundan
			if idx2+len(p2)-idx1==len(S):
				print "YES"
				quit()

else:
	print "NO"

Submission status: Wrong Answer

Solution code:
S = input()

avi = False
if len(S) != 7:
    for i in range(len(S) - 7):
        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: Wrong Answer

Solution code:
from sets import Set

s = raw_input().lower()
r_str = 'keyence'
k_split = list()
for i in xrange(len(r_str)):
	a = list()
	a.append(r_str[0 : i])
	a.append(r_str[i : ])
	k_split.append(a)

print_sig = False

for i in xrange(len(k_split)):
	single_split = k_split[i]
	f = s.find(single_split[0])
	b = s.find(single_split[1])
	if f != -1 and b != -1 and f < b:
		if f > 0 and b - f == 1:
			print_sig = True
		if (b - f > 1 or f == 0) and b + len(single_split[1]) == len(s):
			print_sig = True
		if print_sig == True:
			print 'YES'
			break

if print_sig == False:
	print 'NO'

Submission status: Wrong Answer

Solution code:
#coding:utf-8

def concat(str_list):
    s = ""
    for i in str_list:
        s += i
    return s

in_s = input()
STRNUM = 8
is_key = False
keyence = "keyence"
if keyence in in_s:
    splt_res = in_s.split(keyence)
    if(splt_res[0]=="")|(splt_res[1]==""):
        is_key = True
else:
    for i in range(STRNUM):
        str1 = concat(keyence[0:i+1])
        str2 = concat(keyence[i+1:])
        # str1 で分割
        if str1 in in_s:
            splt_res = in_s.split(str1)
            if splt_res[0] == "":
                if str2 in splt_res[1]:
                    splt_res2 = splt_res[1].split(str2)
                    if(splt_res2[0]=="")|(splt_res2[1]==""):
                        is_key = True

if is_key == True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import re
org_str = input()
#pattern = r"[^k]*?k[^e]*?e[^y]*?y[^e]*?e[^n]*?n[^c]*?c[^e]*?e[^e]*?"
pattern = r"[a-z]*?k[a-z]*?e[a-z]*?y[a-z]*?e[a-z]*?n[a-z]*?c[a-z]*?e[a-z]*?"

matchOB = re.match(pattern , org_str)
if matchOB:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
A = 'keyence'
S = input()
i = 0
idx = 0
prev = True
cnt = 0
for item in S:
    if i == len(A):
        if idx != len(S):
            cnt += 1
        break
    now = True
    if item == A[i]:
        now = True
        i += 1
    else:
        now = False
    if prev is True and now is False:
        cnt += 1
    idx += 1
    prev = now
if cnt > 1 or i != len(A):
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
for i in range(7):
    if s[:i]+s[len(s)-i-1:]=="keyence" or s[:7]=="keyence" or s[len(s)-7:]=="keyence":
        print("YES")
        break
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
q=0

if s.find("keyence")!=-1:
    q=1#ok
else:
    si=s.find("keyenc")
    if si==0 :
        if s[si+6:].find("e")!=-1:
            q=1
    else:
        si=s.find("keyen")
        if si==0:
            if s[si+5:].find("ce")!=-1:
                q=1
        else:
            si=s.find("keye")
            if si==0 :
                if s[si+4:].find("nce")!=-1:
                    q=1
            else:
                si=s.find("key")
                if si==0 :
                    if s[si+3:].find("ence")!=-1:
                        q=1
                else:
                    si=s.find("ke")
                    if si==0:
                        if s[si+2:].find("yence")!=-1:
                            q=1
                    else:
                        si=s.find("k")
                        if si==0:
                            if s[si+1:].find("eyence")!=-1:
                                q=1
if q==1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
var =input()
b =""
flg = False
for a in var:
 
    if "k" in var:
        b= var.find("k")
        if "e" in var and var.find("e",b,len(var)) > b:
            b= var.find("e",b,len(var))
            if "y" in var and var.find("y",b,len(var)) > b:
                b= var.find("y",b,len(var))
                if "e" in var and var.find("e",b,len(var)) > b:
                     b= var.find("e",b,len(var))
                     if "n" in var and var.find("n",b,len(var)) > b:
                         b= var.find("n",b,len(var))
                         if "c" in var and var.find("c",b,len(var)) > b:
                             b= var.find("c",b,len(var))
                             if "e" in var and var.find("e",b,len(var)) > b:
                                 flg = True
if flg:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
ans = 0
if S == "keyence":
    print("YES")
    ans = 1

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
org_str = input()
pattern = r"[^k]*?k[^e]*?e[^y]*?y[^e]*?e[^n]*?n[^c]*?c[^e]*?e[^e]*?"

matchOB = re.match(pattern , org_str)
if matchOB:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 'YES'
idx = 0
substr_cnt = 0
for key in key_str:
    exsist_key = False
    for i in range(idx, len(S)):
        if key == S[i]:
            exsist_key = True
            if i != idx:
                substr_cnt += 1
            idx = i+1
            break

    if not exsist_key or substr_cnt > 1:
        ans = 'NO'
        break
if idx < len(S):
    ans = 'NO'
print(ans)

Submission status: Wrong Answer

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 s == key:
    print('YES')
elif len(s) > 7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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


def search():
    index = 0
    pre_false = 0
    num_false = 0
    flg = 1
    left_last_word = 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
                pre_false = 0
            else:
                if pre_false == 0:
                    if num_false == 0:
                        left_last_word = index - 1
                    num_false += 1
                    pre_false = 1

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