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:
# -*- coding: utf-8 -*-

keyStr=input()
keyence="keyence"

before=""
after=""
chkflg=False

if keyStr.find(keyence) >= 0:
  print("YES")

for char in range(len(keyence) -1):
  before=keyence[0:char+1]
  after=keyence[char+1:len(keyence)]
  
  bindex= keyStr.find(before)
  if bindex >= 0:
    if keyStr[bindex+len(before):len(keyStr)].find(after) >= 0:
      print("YES")
      chkflg=True
      break

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

Submission status: Wrong Answer

Solution code:
s = input()
search="keyence"
idx=0
ans="NO"
for c in s:
    if c == search[idx]:
        idx += 1
    if idx >= 7:
        ans = "YES"
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

key = 'keyence'
yes = False

if key in s:
    idx = s.index('key')
    if idx == 0:
        yes = True
    elif len(s) - idx == 7:
        yes = True
else:
    for i in range(1,8):
        pre = key[:i]
        post = key[i:]
        #print(pre, post)
        if pre in s:
            idx = s.index(pre)
            #print('end', s[len(s)-(7-i):])
            if s[len(s)-(7-i):] == post:
                yes = True
                break
        
if yes == True:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
a = [c for c in input()]
judge = 0
if "k" in a:
	if a.index("k") != 0:
		judge = judge + 1
	del a[:a.index("k")+1]
	if "e" in a:
		if a.index("e") != 0:
			judge = judge + 1
		del a[:a.index("e")+1]
		if "y" in a:
			if a.index("y") != 0:
				judge = judge + 1
			del a[:a.index("y")+1]
			if "e" in a:
				if a.index("e") != 0:
					judge = judge + 1
				del a[:a.index("e")+1]
				if "n" in a:
					if a.index("n") != 0:
						judge = judge + 1
					del a[:a.index("n")+1]
					if "c" in a:
						if a.index("c") != 0:
							judge = judge + 1
						del a[:a.index("c")+1]
						if "e" in a:
							if a.index("e") != 0:
								judge = judge + 1
							if judge == 0 or judge == 1:
								print("YES")
							else:
								print("NO")
						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:
import re
from sys import stdin
N=(stdin.readline().rstrip())
for i in range(7):
    mae="keyence"[0:i+1]
    ato="keyence"[i+1:8]
    if re.match("%s.*%s"%(mae, ato),N):
        print("YES")
        break
if i==6:
    print("NO")

Submission status: Wrong Answer

Solution code:
a = input()
k="keyence"
ti = 0
x =[0]*(len(a)+1)
r = 0
for i in range(len(a)):
    if ti==7:
        r+=1
        break
    if a[i] == k[ti]:
        ti +=1
        x[i]=1
        if i!=0 and  x[i-1]!=1:r+=1     
if ti == 7 and r < 2:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

target = list("keyence")
dif_flag = True
count = 0
tmp = target.pop(0)
for i in S:
  if tmp != i:
    if dif_flag:
      continue
    else:        
      dif_flag = True
      count += 1  
    if count >= 2:
      print("NO")
      break
    continue
  if len(target) == 0:
    print("YES")
    break
  dif_flag = False
  tmp = target.pop(0)
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
# 2019/01/13
# KEYENCE Programming Contest 2019 - B

# Input
s = input()

# Init
key_str = "keyence"
search_idx = 0
okflg = 0
ngcnt = 0

# Search
for idx in range(len(s)):
    if s[idx] == key_str[search_idx]:
        search_idx += 1
        okflg = 1
        if search_idx == len(key_str):
            break
    else:
        if okflg == 1:
            ngcnt += 1
            okflg = 0
        if ngcnt > 1:
            break

# Check
if search_idx == len(key_str):
    ans = "YES"
else:
    ans = "NO"

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
S=S.replace("keyence","A")
if S=="A":
    print("YES")
    exit()
elif S[0]=="A" and S[len(S)-1]!="A":
    print("YES")
    exit()
elif S[len(S)-1]=="A":
    print("YES")
    exit()
    
S1=S.replace("K","A")
S1=S1[::-1]
S1=S1.replace("ecneye","B")
S1=S1[::-1]
if S1[0]=="A" and S1[len(S1)-1]=="B":
    print("YES")
    exit()
S2=S.replace("Ke","A")
S2=S2[::-1]
S2=S2.replace("ecney","B")
S2=S2[::-1]
if S2[0]=="A" and S2[len(S2)-1]=="B":
    print("YES")
    exit()
S3=S.replace("Key","A")
S3=S3[::-1]
S3=S3.replace("ecne","B")
S3=S3[::-1]
if S3[0]=="A" and S3[len(S3)-1]=="B":
    print("YES")
    exit()
S4=S.replace("Keye","A")
S4=S4[::-1]
S4=S4.replace("ecn","B")
S4=S4[::-1]
if S4[0]=="A" and S4[len(S4)-1]=="B":
    print("YES")
    exit()
S5=S.replace("Keyen","A")
S5=S5[::-1]
S5=S5.replace("ec","B")
S5=S5[::-1]
if S5[0]=="A" and S5[len(S5)-1]=="B":
    print("YES")
    exit()
S6=S.replace("Keyenc","A")
S6=S6.replace("e","B")
if S6[0]=="A" and S6[len(S6)-1]=="B":
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

Solution code:
from sets import Set

s = raw_input()
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:
		print 'YES'
		print_sig = True
		break

if print_sig == False:
	print 'NO'

Submission status: Wrong Answer

Solution code:
S = input()
f = False
for i in range(len(S)):
    s1 = S[:i]
    s2 = S[i:]
    if 'keyence' in s2:
        f = True
        break
    if 'k' in s1 and 'eyence' in s2:
        f = True
        break
    if 'ke' in s1 and 'yence' in s2:
        f = True
        break
    if 'key' in s1 and 'ence' in s2:
        f = True
        break
    if 'keye' in s1 and 'nce' in s2:
        f = True
        break
    if 'keyen' in s1 and 'ce' in s2:
        f = True
        break
    if 'keyenc' in s1 and 'e' in s2:
        f = True
        break
    if 'keyence' in s1:
        f = True
        break
if f:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(len(s)):
    for j in range(i,len(s)):
        for k in range(j,len(s)):
            for l in range(k,len(s)):
                t=s[i:j]+s[k:l+1]
                if(t=='keyence'):
                    print('YES')
                    exit()
print('NO')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
k = 'keyence'
if (s == k):
  print('YES')
  sys.exit()
left = 0
right = 0
for i in range(len(s)):
  if (s[i] == k[i]):
    left += 1
  else:
    break
for j in range(1, len(s)):
  if (s[j * -1] == k[j * -1]):
    right += 1
  else:
    break
if(left + right == len(k)):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
L = input()
k1 = L.count("k")
e3 = L.count("e")
y1 = L.count("y")
n1 = L.count("n")
c1 = L.count("c")
if k1 >= 1 and e3 >= 3 and y1 >= 1 and n1 >= 1 and c1 >= 1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

for i in range(len(t)-1):
    t1=t[:i+1]
    t2=t[i+1:]
    if S.count(t1)==1 and S.count(t2)==1:
        ind1=S.index(t1)
        ind2=S.index(t2)
        if ind1<=ind2:
            if ind1==0:
                if ind2>ind1+len(t1) and ind2+len(t2)<len(S):
                    continue
            if ind1>0:
                if ind2>ind1+len(t1) or ind2+len(t2)<len(S):
                    continue
            print('YES')
            break
else:
    print('NO')

Submission status: Wrong Answer

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

kn = 0
bf = False
las = False
for i in range(len(S)):
    if kn == 7:
        break
    if S[i] == K[kn]:
        kn += 1
        if bf == True:
            las = True
    else:
        if bf == False:
            bf = True
            continue
        elif bf == True and las == False:
            continue
        elif bf == True and las == True:
            print('NO')
            exit()

if kn == 7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = list(input())
x = list("keyence")
k = 0
count = 0
for i in range(len(s)):
    if s[i] == x[k]:
        if k==0 and i>0:
            count+=1
        k+=1
    if k == len(x):
        if i != len(s)-1:
            print("NO")
            exit()
        break
    if s[i] != x[k] and count>0:
        print("NO")
        exit()
if k == len(x):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
"""
B - KEYENCE String
"""
#入力処理
def simple_input():
    temp_input = input().rstrip().split(' ')
    if len(temp_input) > 1:
        return temp_input
    return temp_input[0]

#メイン処理
if __name__ == '__main__':
    #入力
    s = input()
    keyence = "keyence"

    result = "NO"
    
    matchcount = 0
    for i in range(7):
        si = s[i]
        ki = keyence[i]
        if(si == ki):
            matchcount = matchcount + 1
        else:
            break

    for i in range(7):
        i2 = i * -1 - 1
        si = s[i2]
        ki = keyence[i2]
        if(si == ki):
            matchcount = matchcount + 1
        else:
            break

    if(matchcount >= 7):
        result = "YES"
    
    print(matchcount)

    #出力
    print(result)

Submission status: Wrong Answer

Solution code:

s = input()

f = "keyence"
h = 0
n = len(s)
for i in range(8):

    first = f[:i+1]
    second = f[i+1:]
    check = len(first)
    find1 = s.find(first)
    find2 = s.find(second,find1+check)

    if i!=7:
        if find1!=0:
            continue

        if find2==-1:
            continue

        if find2+len(second)!=n:
            continue

        else:
            print("YES")
            h = 1
            break

    else:
        if find1 == 0 or find1+len(first) == n :
            print("YES") 
            h = 1
            break



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

Submission status: Wrong Answer

Solution code:
import sys
s = input()
k = 'keyence'
if (s == k):
  print('YES')
  sys.exit()
left = 0
right = 0
for i in range(len(s)):
  if (s[i] == k[i]):
    left += 1
  else:
    break
for j in range(1, len(s) + 1):
  if (s[j * -1] == k[j * -1]):
    right += 1
  else:
    break
if(left + right == len(k)):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
import re
s = input()
k1 = 'keyence'
k2 = 'keyofscience'
ans = 'NO'
if s in 'keyence' or s in 'keyofscience':
    ans = 'YES'
else:
    for i in range(len(k1)):
        a = '^'+k1[:i]+'.*?'+k1[i+1:]+'$'
        if re.match(a,s):
            ans = 'YES'
    for i in range(len(k2)):
        a = '^'+k2[:i]+'.*?'+k2[i+1:]+'$'
        if re.match(a,s):
            ans = 'YES'
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
k = "keyence"
ans = "NO"
for i in range(7):
    a,b = S.find(k[:i]),S.find(k[i:])
    if a > -1 and b > -1 and a <= b:
        ans = "YES"
        break
print(ans)

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-6:
    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-5:
    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-4:
    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-3:
    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-2:
    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-1:
    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:
s=list(input())
t=list("keyence")
j=0
c=0
for i in range(len(s)):
    if s[i]==t[c]:
        j+=1
        if j==7:
            if c!=0 and s.pop():
                print("YES")
                exit()
            elif c==0:
                print("YES")
                exit()
            else:
                break
        c+=1
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+1):
    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:
s = input()
a = 'keyence'
flag = 1

for i in range(8):
    if a[0:i] in s:
        firstindex = s.index(a[0:i])
        if a[i:8] in s[firstindex:]:
            secondindex = s.index(a[i:8])
            
            if s.replace(s[firstindex+i:secondindex],'') == a:
                print('YES')
                flag = 0
                break

if flag == 1:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(len(s)):
    for j in range(i,len(s)):
        for k in range(j,len(s)):
            for l in range(k,len(s)):
                t=s[i:j]+s[k:l+1]
                print(t)
                if(t=='keyence'):
                    print('YES')
                    exit()
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):
        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 = 0
        else:
            flg = 0
            print("NO")
            break

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

Submission status: Wrong Answer

Solution code:
S = input()

k = 'keyence'

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

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


print('NO')

Submission status: Wrong Answer

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

kn = 0
bf = False
las = False
for i in range(len(S)):
    if kn == 7:
        break
    if S[i] == K[kn]:
        kn += 1
        if bf == True:
            las == True
    else:
        if bf == False:
            bf = True
            continue
        elif bf == True and las == False:
            continue
        elif bf == True and las == True:
            print('NO')
            exit()

if kn == 7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()


def judge():
    L = len(S)
    keyence = 'keyence'
    if S[0] != 'k':
        if S[-7:] != 'keyence':
            return False
        else:
            return True
    else:
        for i in range(8):
            if S[0:i] == keyence[0:i] and S[L-(7-i):L] == keyence[i:7]:
                return True
        return False


def main():
    print(judge())

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import re

keyence = "keyence"
S = raw_input()
ans = False
for i in range(len(keyence)+1):
  if re.match(keyence[:i]+".*"+keyence[i:],S):
    ans = True
print "YES" if ans else "NO"

Submission status: Wrong Answer

Solution code:
S=input()
def func(S):
  target="keyence"
  for i in range(6):
    a=target[:i]
    b=target[i:]
    if S.find(a)!=-1 and S.find(b,S.find(a)+1)!=-1:
      return True
  return False

if func(S):
  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: # keyence + "abdedd"
        print("YES")
    else:
        end_diff_i = None
        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

        if end_diff_i is None:
            end_diff_i = - len_key_s - 1

        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:
import re
org_str = input()
pattern = r".*k.*e.*y.*e.*n.*c.*e.*"

if org_str.count('e') != 3:
  print('NO')
  exit()

matchOB = re.match(pattern , org_str)
if matchOB:
  print('YES')
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]:
        time += 1
        if time >= 2:
            print("NO")
            sys.exit()
        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:
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:
        break

if j == lenT:
    print("YES")
    exit(0)
if i == lenS:
    print("NO")
    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:
import re

S=input()

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

Submission status: Wrong Answer

Solution code:

s = input()

f = "keyence"
h = 0
n = len(s)
for i in range(7):

    first = f[:i+1]
    second = f[i+1:]
    check = len(first)
    find1 = s.find(first)
    find2 = s.find(second,find1+check)

    if i!=6:
        if find1!=0:
            continue

        if find2==-1:
            continue

        if find2+len(second)!=n:
            continue

        else:
            print("YES")
            h = 1
            break

    else:
        if find1 == 0 or find1+len(first) == n :
            print("YES") 
            h = 1
            break



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

Submission status: Wrong Answer

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

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

    if not exsist_key:
        ans = 'NO'
        break
print(ans)

Submission status: Wrong Answer

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

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] < len(S):
            if a[0] + b[0] >= 7:
                f = True
if f:
    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 < len(ans) and x == ans[i]:
            i += 1
            if flag == 1:
                flag = -1
        elif flag == -1:
            print('NO')
            return
        else:
            flag = 1
    if i < len(ans)-1:
        print('NO')
    else:
        print('YES')

main(input())

Submission status: Wrong Answer

Solution code:
import copy

S = list(input())
ja = 0

sremove = ""
S_tmp = []

for i in range(len(S)):
    for j in range(1,len(S)- i+1):
        S_tmp = copy.deepcopy(S)

        del S_tmp[i:j]

        if "".join(S_tmp) == "keyence":
            ja = 1
            break

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

else:
    print("YES")

Submission status: Wrong Answer

Solution code:
import fnmatch
S=[]
S.append(input())
if S == fnmatch.filter(S, "*keyence") or S == fnmatch.filter(S, "k*eyence") or S == fnmatch.filter(S, "ke*yence") or S == fnmatch.filter(S, "key*ence") or S == fnmatch.filter(S, "keye*nce") or S == fnmatch.filter(S, "keyen*ce") or S == fnmatch.filter(S, "keyenc*e") or S == fnmatch.filter(S, "keyence*"):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s = input()
a = 'keyence'
flag = 1

for i in range(8):
    if a[0:i] in s:
        firstindex = s.index(a[0:i])
        if a[i:8] in s[firstindex:]:
            secondindex = s.index(a[i:8])
            
            if s.replace(s[firstindex+i:secondindex],'') == a:
                print('YES')
                flag = 0

if flag == 1:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

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

Submission status: Wrong Answer

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

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


if y <= 1 and x != 0:
  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 < len(ans) and x == ans[i]:
            print('a1')
            i += 1
            if flag == 1:
                flag = -1
        elif flag == -1:
            print('b')
            print('NO')
            return
        else:
            print('c')
            flag = 1
    print('d')
    if i < len(ans)-1:
        print('NO')
    else:
        print('YES')

main(input())

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 i < len(text):
    count -=1
    if count == 0:
        flag = 0
if flag == 1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
target = 'keyence'
s_len = len(s)
flg = 0
target1_len = 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)
        target1_len = len(target1)
        if target2 in s[target1_ind+target1_len:s_len]:
            flg = 1
if flg == 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import re
s = input()
k1 = 'keyence'
k2 = 'keyofscience'
ans = 'NO'
if s in 'keyence' or s in 'keyofscience':
    ans = 'YES'
else:
    for i in range(len(k1)):
        a = k1[:i]+'.*?'+k1[i+1:]
        if re.match(a,s):
            ans = 'YES'
    for i in range(len(k2)):
        a = k2[:i]+'.*?'+k2[i+1:]
        if re.match(a,s):
            ans = 'YES'
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = 'keyence'
cnt = 0
j = False
p = 0
for i in range(len(s)):
  if t[p] == s[i]:
    if j == True:
      j = False
      cnt = cnt + 1
    p = p + (1 if p < len(t) - 1 else 0)
  else:
    j = True
print('YES' if p == len(t) - 1 and cnt <= 1 else 'N0')

Submission status: Wrong Answer

Solution code:
s = input()
key = "keyence"
count = 0
flag = False
flagexit = False

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

for c in s:
    if count == 7:
        if flag:
            print("NO")
            exit()
        continue
    if 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()

k = 'keyence'

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

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


print('NO')