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()
length = len(S)
if 'keyence' in S: print("YES")
elif 'keyenc' in S :
    place = S.find('keyenc')+6
    S.find('e',place,length)
    print("YES")
elif 'keyen' in S :
    place = S.find('keyen')+5
    S.find('ce',place,length)
    print("YES")
elif 'keye' in S :
    place = S.find('keye')+4
    S.find('nce',place,length)
    print("YES")
elif 'key' in S :
    place = S.find('key')+3
    S.find('ence',place,length)
    print("YES")
elif 'ke' in S :
    place = S.find('ke')+2
    S.find('yence',place,length)
    print("YES")
elif 'eyence' in S :
    place = S.find('k')-1
    S.find('k',0,place)
    print("YES")
else : print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
if s[1:] == "k" and s[-1:] == "e":
    print("NO")
elif s[1:] == "k" or s[-1:] == "e" or s == "keyence":
    print("YES")

else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k_str = 'keyence'

Submission status: Wrong Answer

Solution code:
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
n = len(s)
if s[0:7] == search:
    print("YES")
elif (s[-7:] == search):
    print("YES")
else:
    for i in range(7):
        if s[0:i+1] == search[0:i+1]:
            print(s[(-7+i+1):])
            print(search[i+1:])
            if (s[(-7+i+1):] == search[i+1:]):
                ans = "YES"
                break
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
input_str = input()
pattern_1 = r"[^k]{1,100}keyence$"
pattern_2 = r"^k[^ke]{1,100}eyence"
pattern_3 = r"^ke[^ey]{1,100}yence"
pattern_4 = r"^key[^ye]{1,100}ence"
pattern_5 = r"^keye[^en]{1,100}nce"
pattern_6 = r"^keyen[^nc]{1,100}ce"
pattern_6 = r"^keyenc[^ce]{1,100}e"
pattern_7 = r"^keyence[^e]{1,100}"
pattern_8 = r"^keyence$"
match_obj1 = re.match(pattern_1, input_str)
match_obj2 = re.match(pattern_2, input_str)
match_obj3 = re.match(pattern_3, input_str)
match_obj4 = re.match(pattern_4, input_str)
match_obj5 = re.match(pattern_5, input_str)
match_obj6 = re.match(pattern_6, input_str)
match_obj7 = re.match(pattern_7, input_str)
match_obj8 = re.match(pattern_8, input_str)
if match_obj1 or match_obj2 or match_obj3 or match_obj4 or match_obj5 or match_obj6 or match_obj7 or match_obj8:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S = input ( )

dusted = False
cont = False
line = 'keyence'
find = S.find ( 'keyence' )
rfind = S.rfind ( 'keyence' )
#print ( 'find {} rfind {}'.format ( find, rfind ) )
if find == 0 or rfind == len ( S ) - 7:
    print ( 'YES' )
    exit ( 0 )
elif find != -1:
    print ( 'NO' )
    exit ( 0 )

fs = True
line = ''
keyence = [ c for c in "keyence" ]
a_err=False
b_err=False
keyence2='keyence'
count=0
for i in range(len ( S )):

    #print ( keyence )
    #print ( 'i {} ri {}'.format ( S[i], S[len(S)-1-i] ) )
    try:
        if not  b_err:
            #print ( 'key2 {} S {}'.format ( keyence2[ 6 - i ], S[ len ( S ) - 1 - i ] ) )

            if keyence2[ 6 - i ] != S[ len ( S ) - 1 - i ]:
                keyence.remove ( S[ len ( S ) - 1 - i ] )
                print ( 'NO' )
                exit ( 0 )
            keyence.remove ( S[len(S)-1-i] )

            count+=1

    except ValueError:
        b_err=True

    if not keyence:
        print ( 'YES' )
        exit ( 0 )
    try:
        if not a_err:
            if keyence2[ i ] != S[ i]:
                keyence.remove (S[ i] )
                print ( 'NO' )
                exit ( 0 )
            keyence.remove ( S[i] )
    except ValueError:
        a_err=True

    if a_err and b_err:
        print('NO')
        exit(0)

    if not keyence:
        print ( 'YES' )
        exit ( 0 )

Submission status: Wrong Answer

Solution code:
S = input()

keyence = 'keyence'

if keyence in S:
    print('YES')
else:
    result = 'NO'
    for i in range(1, len(keyence) - 1):
        delimiters = keyence[:i], keyence[i:]
        if S.startswith(delimiters[0]) and S.endswith(delimiters[1]):
            result = 'YES'
            break
    print(result)

Submission status: Wrong Answer

Solution code:
import re

S=input()

if re.match("keyence",S) or re.match("^(.*)(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)(.*)$",S):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
target = 'keyence'
s_len = len(s)
flg = 0

for i in range(7):
    target1_ind = -1
    target1 = target[0:i]
    target2 = target[i:7]
    if target1 in s:
        target1_ind = s.index(target1)
        target1_len = len(target1)
        if target2 in s[target1_ind+target1_len:s_len] :
            if target1_ind == 0:
                if s.index(target2)+len(target2)==s_len:
                    flg = 1
                if s.index(target2)==0:
                    flg = 1
            else:
                 if s.index(target2)+len(target2)==s_len:
                    flg = 1
        

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

Submission status: Wrong Answer

Solution code:
a = "keyence"

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

Submission status: Wrong Answer

Solution code:
x = input().split()[0]

test = "keyence"
i = 0
for y in x:
  if i == len(test):
    break
  if y in test[i]:
    i += 1
  else:
    break
if i == len(test):
  print("YES")
else:
  k = len(test) - 1
  for j in range(len(x)):
    y = x[-(j+1)]
    if y in test[k]:
      k -= 1
    else:
      break
  if i == k+1:
    print("YES")
  else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

key = 'keyence'

flg = False
for split in range(1, len(key) + 1):
    a = S.find(key[:split])
    if a != -1:
        b = S[a:].find(key[split:])
        
        if b != -1:
            flg = True
            
            
if flg:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
s = list(input())

for i, string in enumerate(s):
    if s[:7] == list("keyence"):
        print("YES")
        sys.exit()
        
    if s[i] != "keyence"[i]:
        for j in range(1, len(s)-i-1):
            if s[i+j] == "keyence"[i]:
                if s[:i]+s[i+j:] == list("keyence"):
                    print("YES")
                    sys.exit()
        break

print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

str = "keyence"
a = [(str[0:i], str[i:]) for i in range(1, 7)]

flg = 0
for i, j in a:
    if s == "keyence":
        flg = 1
        break
    
    s = s.replace(i, "%")
    s = s.replace(j, "&")
    
    if "%" not in s:
        pass
    elif "&" not in s:
        pass
    elif s.index("%") < s.index("&"):
        pass
    else:
        flg = 1
        break
        
if flg == 1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
data = input()

def check(str):
    comp_s = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
    ng_flag = False
    count = 0
    s_count = 0
    flag = False
    for s in str:
        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

    return flag, count

ans = False
indexes = [i for i, x in enumerate(data) if x == 'k']
for i in indexes:
    result = check(data[i:len(data)])
    if result[0]:
        if result[1] == 0:
            ans = True
            break
        elif 1 <= result[1] and i == 0:
            ans = True


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

Submission status: Wrong Answer

Solution code:
s = input()

if s[1:] == "k" or s[-1:] == "e" or s == "keyence":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

s = input()
l = deque("keyence")
if (s[0:7] == "keyence"):
    print("YES")
elif (s[-7:-1] + s[-1] == "keyence"):
    print("YES")
else:
    if s[0] == 'k' and s[-1] == "e":
        count = 0
        c = 0
        mode = 0
        for ss in list(s):
            if count == 7:
                print("NO")
                sys.exit()
            if l[c] == ss:
                count += 1
                c += 1
                if mode == 1:
                    mode = 2
            else:
                if mode == 0:
                    mode = 1
                elif mode == 2:
                    print("NO")
                    sys.exit()
        if count == 7:
            print("YES")
            sys.exit()
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
s=input()
r="keyence"
res=False

for i in range(0,len(r)):
  if s.find(r[:i+1])>=0 and s.find(r[-(len(r)-i-1):]):
    res=True
  
if res:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
import re
key = list(str(input()))
keyence = list('keyence')
flag = 0

keylist = []
for i in range(len(keyence)+1):
    keyence.insert(i, '.*')

    key = ''.join(key)
    keyence = ''.join(keyence)

    result = re.match(keyence, key)
    if result:
        print("YES")
        quit()
    
    key = list(str(key))
    keyence = list(str(keyence))
    keyence.remove('.')
    keyence.remove('*')

print("NO")

Submission status: Wrong Answer

Solution code:
import re
S = input()
st = ''
ptnl = re.compile(r'k|ke|key|keye|keyen|keyenc|keyence')
ptnr = re.compile(r'eyence|yence|ence|nce|ce|e| ')
for i in range(len(S)):
  ml = ptnl.search(S[:i])
  mr = ptnr.search(S[i:])
  if(ml and mr):
    print('YES')
    break
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S = input ( )

dusted = False
cont = False
line = 'keyence'
find = S.find ( 'keyence' )
rfind = S.rfind ( 'keyence' )
#print ( 'find {} rfind {}'.format ( find, rfind ) )
if find == 0 or rfind == len ( S ) - 7:
    print ( 'YES' )
    exit ( 0 )
elif find != -1:
    print ( 'NO' )
    exit ( 0 )

fs = True
line = ''
keyence = [ c for c in "keyence" ]
a_err=False
b_err=False
keyence2='keyence'
count=0
for i in range(len ( S )):

    #print ( keyence )
    #print ( 'i {} ri {}'.format ( S[i], S[len(S)-1-i] ) )
    try:
        if not  b_err:
            if keyence2[ 6 - i ] != S[ len ( S ) - 1 - i ]:
                print ( 'NO' )
                exit ( 0 )
            keyence.remove ( S[len(S)-1-i] )

            count+=1

    except ValueError:
        b_err=True

    if not keyence:
        print ( 'YES' )
        exit ( 0 )
    try:
        if not a_err:
            if keyence2[ i ] != S[ i]:
                print ( 'NO' )
                exit ( 0 )
            keyence.remove ( S[i] )
    except ValueError:
        a_err=True

    if a_err and b_err:
        print('NO')
        exit(0)

    if not keyence:
        print ( 'YES' )
        exit ( 0 )

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
input_str = input()
pattern_1 = r"[^keyence]+?keyence"
pattern_2 = r"k[^keyence]+?eyence"
pattern_3 = r"ke[^keyence]+?yence"
pattern_4 = r"key[^keyence]+?ence"
pattern_5 = r"keye[^keyence]+?nce"
pattern_6 = r"keyen[^keyence]+?ce"
pattern_6 = r"keyenc[^keyence]+?e"
pattern_7 = r"keyence[^keyence]+?"
pattern_8 = r"keyence"
match_obj1 = re.match(pattern_1, input_str)
match_obj2 = re.match(pattern_2, input_str)
match_obj3 = re.match(pattern_3, input_str)
match_obj4 = re.match(pattern_4, input_str)
match_obj5 = re.match(pattern_5, input_str)
match_obj6 = re.match(pattern_6, input_str)
match_obj7 = re.match(pattern_7, input_str)
match_obj8 = re.match(pattern_8, input_str)
if match_obj1 or match_obj2 or match_obj3 or match_obj4 or match_obj5 or match_obj6 or match_obj7 or match_obj8:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

kn = 0
bf = False
las = False

tmp = ""
for i in range(len(S)):
    # もしKのindexが6を超える（全てOK）の場合抜ける
    if kn == 7:
        break

    # もし今見てるSとKが同じだったらKのindexをインクリメント
    # もし部分文字列を削除済みならもう削除する部分文字列は無い    
    if S[i] == K[kn]:
        kn += 1
        if bf == True:
            bf = False
            las = True
    else:
        if bf == False:
            tmp += S[i]
            bf = True
            continue
        elif bf == True and las == False:
            tmp += S[i]
            continue
        elif bf == True and las == True:
            print('NO')
            exit()

if kn == 7 or S.replace(tmp, ''):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import re
key = list(str(input()))
keyence = list('keyence')
flag = 0

keylist = []
for i in range(len(keyence)+1):
    keyence.insert(i, '.*')

    key = ''.join(key)
    keyence = ''.join(keyence)

    print(keyence)

    result = re.match(keyence, key)
    if result:
        print("YES")
        quit()
    
    key = list(str(key))
    keyence = list(str(keyence))
    keyence.remove('.')
    keyence.remove('*')

print("NO")

Submission status: Wrong Answer

Solution code:
import re
x = input()

result = re.findall(".*k.*e.*y.*e.*n.*c.*e.*", x)
answer = "NO"

if len(re.findall(".*keyence", x)) > 0 :
    answer = "YES"
if len(re.findall("k.*eyence", x)) > 0 :
    answer = "YES"
if len(re.findall("ke.*yence", x)) > 0 :
    answer = "YES"
if len(re.findall("key.*ence", x)) > 0 :
    answer = "YES"
if len(re.findall("keye.*nce", x)) > 0 :
    answer = "YES"
if len(re.findall("keyen.*ce", x)) > 0 :
    answer = "YES"
if len(re.findall("keyenc.*e", x)) > 0 :
    answer = "YES"
if len(re.findall("keyence.*", x)) > 0 :
    answer = "YES"
print(answer)

Submission status: Wrong Answer

Solution code:
x = input().split()[0]

test = "keyence"
#  はじめ文字から調べる
i = 0
for y in x:
  if y in test[i]:
    i += 1
  else:
    break
if i == len(test):
  print("YES")
else:
  k = len(test) - 1
  for j in range(len(x)):
    y = x[-(j+1)]
    if y in test[k]:
      k -= 1
    else:
      break
  if i == k+1:
    print("YES")
  else:
    print("NO")

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[S.index(keyence[:i])+i:] :
          print('YES')
          break
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

a = [("k", "eyence"), ("ke", "yence"), ("key", "ence"), ("keye", "nce"), ("keyen", "ce"), ("keyenc", "e")]

flg = 0
for i, j in a:
    if s == "keyence":
        flg = 1
        break
    
    s = s.replace(i, "%")
    s = s.replace(j, "&")
    
    if "%" not in s:
        pass
    elif "&" not in s:
        pass
    elif s.index("%") < s.index("&"):
        pass
    else:
        flg = 1
        break
        
if flg == 1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
a = input()
k="keyence"
ti = 0
x =[0]*(len(a))
r = 0
for i in range(len(a)):
    if ti==7:
        r+=1
        break
    elif 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()
L = 'keyence'
j = 0
unres = ''
res = ''
for i in range(len(S)):
    # print(j)
    if j >= len(L):
        unres += S[j:]
        break
    if S[i] == L[j]:
        res += S[i]
        j += 1
    else:
        unres += S[i]
# print(res, unres)
if res == L and S.find(unres) != -1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
n = len(s)
if s[0:7] == search:
    print("YES")
elif (s[-7:] == search):
    print("YES")
else:
    for i in range(7):
        x=s.find(search[0:i+1])
        if x==0:
            if (s[i:].find(search[i+1:])>=0):
                ans = "YES"
                break
        else:
            continue
    print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
length = len(S)
if 'keyence' in S: print("YES")
elif 'keyenc' in S :
    place = S.find('keyenc')+6
    S.find('e',place,length)
    print("YES")
elif 'keyen' in S :
    place = S.find('keyen')+5
    S.find('ce',place,length)
    print("YES")
elif 'keye' in S :
    place = S.find('keye')+4
    S.find('nce',place,length)
    print("YES")
elif 'key' in S :
    place = S.find('key')+3
    S.find('ence',place,length)
    print("YES")
elif 'ke' in S :
    place = S.find('ke')+2
    S.find('yence',place,length)
    print("YES")
elif 'k' in S :
    place = S.find('k')+1
    S.find('eyence',place,length)
    print("YES")
else : print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
string="keyence"
flag1=0
flag2=0
v=0

for i in range(len(s)):
  try:
    if s[i]==string[v]:
      v+=1
      if flag1==1:
        flag2=1
    else:
      flag1=1
      mojiretsu=string[v:]
      if len(mojiretsu)==1:
        if s[-1]==mojiretsu and flag2 == 0:
          print('YES')
          exit()
      if s[-1:-len(mojiretsu)-1:-1][::-1]==mojiretsu:
        print('YES')
        exit()
      if flag1==1 and flag2==1:
        print("NO")
        exit()
      if v==len(string)+1:
        print('NO')
        exit()
  except IndexError:
    if flag1==0 and flag2==0:
      print('YES')
      exit()
    else:
      print('NO')
      exit()

if flag1==0 and flag2==0:
  print('YES')
elif flag1==1 and flag2==0:
  print('NO')
else:
  print('YES')

Submission status: Wrong Answer

Solution code:
S = input()
L = 'keyence'
j = 0
unres = ''
res = ''
for i in range(len(S)):
    print(j)
    if j >= len(L):
        unres += S[j:]
        break
    if S[i] == L[j]:
        res += S[i]
        j += 1
    else:
        unres += S[i]
# print(res, unres)
if res == L and S.find(unres) != -1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
target = 'keyence'
s_len = len(s)
flg = 0

for i in range(7):
    target1_ind = -1
    target1 = target[0:i]
    target2 = target[i:7]
    if target1 in s:
        target1_ind = s.index(target1)
        target1_len = len(target1)
        if target2 in s[target1_ind+target1_len:s_len] :
            if s.index(target2)+len(target2)==s_len:
                flg = 1
            if s.index(target2)+len(target2)==7:
                flg = 1

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

Submission status: Wrong Answer

Solution code:
x = input().split()[0]

test = "keyence"
#  はじめ文字から調べる
i = 0
for y in x:
  if y in test[i]:
    i += 1
  else:
    break

k = len(test) - 1
for j in range(len(x)):
  y = x[-(j+1)]
  if y in test[k]:
    k -= 1
  else:
    break

if i == k+1:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
import re
key = list(str(input()))
keyence = list('keyence')
flag = 0

keylist = []
for i in range(len(keyence)):
    keyence.insert(i, '.*')

    key = ''.join(key)
    keyence = ''.join(keyence)

    result = re.match(keyence, key)
    if result:
        print("YES")
        quit()
    
    key = list(str(key))
    keyence = list(str(keyence))
    keyence.remove('.')
    keyence.remove('*')

print("NO")

Submission status: Wrong Answer

Solution code:
S = input ( )

dusted = False
cont = False
line = 'keyence'
find = S.find ( 'keyence' )
rfind = S.rfind ( 'keyence' )
#print ( 'find {} rfind {}'.format ( find, rfind ) )
if find == 0 or rfind == len ( S ) - 7:
    print ( 'YES' )
    exit ( 0 )
elif find != -1:
    print ( 'NO' )
    exit ( 0 )

fs = True
line = ''
keyence = [ c for c in "keyence" ]
a_err=False
b_err=False
keyence2='keyence'
count=0
for i in range(len ( S )):

    #print ( keyence )
    #print ( 'i {} ri {}'.format ( S[i], S[len(S)-1-i] ) )
    try:
        if not  b_err:
            if keyence2[ 6 - i ] != S[ len ( S ) - 1 - i ]:
                print ( 'NO' )
                exit ( 0 )
            keyence.remove ( S[len(S)-1-i] )

            count+=1

    except ValueError:
        b_err=True

        if not keyence:
            print ( 'YES' )
            exit ( 0 )
    try:
        if not a_err:
            if keyence2[ i ] != S[ i]:
                print ( 'NO' )
                exit ( 0 )
            keyence.remove ( S[i] )
    except ValueError:
        a_err=True

    if a_err and b_err:
        print('NO')
        exit(0)

    if not keyence:
        print ( 'YES' )
        exit ( 0 )

Submission status: Wrong Answer

Solution code:
import re

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

Submission status: Wrong Answer

Solution code:
s = input()

length = len(s)
flag = False
if(s == "keyence"):
    flag = True

for k in range(length - 7 + 1):
    for l in range(length):
        r = l + k - 1
        if(l > r):
            continue
        if(s[0:l-1]+s[r+1:length] == "keyence"):
            flag = True

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

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

s = input()
l = deque("keyence")
if (s[0:7] == "keyence"):
    print("YES")
elif (s[-7:-1] + s[-1] == "keyence"):
    print("YES")
else:
    if s[0] == 'k' and s[-1] == "e":
        count = 0
        c = 0
        mode = 0
        for ss in list(s):
            if count == 7:
                sys.exit()
            if l[c] == ss:
                count += 1
                c += 1
                if mode == 1:
                    mode = 2
            else:
                if mode == 0:
                    mode = 1
                elif mode == 2:
                    print("NO")
                    sys.exit()
        if count == 7:
            print("YES")
            sys.exit()
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

a = [("k", "eyence"), ("ke", "yence"), ("key", "ence"), ("keye", "nce"), ("keyen", "ce"), ("keyenc", "e")]

flg = 0
for i, j in a:
    s = s.replace(i, "%")
    s = s.replace(j, "&")
    
    if "%" not in s:
        pass
    elif "&" not in s:
        pass
    elif s.index("%") < s.index("&"):
        pass
    else:
        flg = 1
        break
        
if flg == 1:
    l.index("%") <= l.index("&")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
s=input()

if re.search(r'.*k.*e.*y.*.*e.*n.*c.*e.*', s):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
import re

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

Submission status: Wrong Answer

Solution code:
N=input()
kye="keyence"
Nlen=len(N)
flag=0
i=0
x=0
if Nlen== N==kye:
    flag==1

if N[0]==kye[0]and flag==0:
    while flag==0 and N[i]==kye[i]:
        i=i+1
        if i==7:
            flag=1
    x=i
    while flag==0 and N[x]!=kye[i]:
        x=x+1
        if x==Nlen:
            flag=2
    
    if N[x:]==kye[i:]:
            flag=1
else:
    while flag==0 and N[x]!=kye[i]:
        x=x+1
        if x==Nlen:
            flag=2
    
    if N[x:]==kye:
            flag=1



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

Submission status: Wrong Answer

Solution code:
import re
x = input()

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

if len(re.findall(".*keyence", x)) > 0 :
    print("YES")
elif len(re.findall("k.*eyence", x)) > 0 :
    print("YES")
elif len(re.findall("ke.*yence", x)) > 0 :
    print("YES")
elif len(re.findall("key.*ence", x)) > 0 :
    print("YES")
elif len(re.findall("keye.*nce", x)) > 0 :
    print("YES")
elif len(re.findall("keyen.*ce", x)) > 0 :
    print("YES")
elif len(re.findall("keyenc.*e", x)) > 0 :
    print("YES")
elif len(re.findall("keyence.*", x)) > 0 :
    print("YES")
else :
    print("NO")

Submission status: Wrong Answer

Solution code:
from sys import stdin
import re
flug = 0
l = stdin.readline()
for i in range(7):
    pattern = list("keyence")
    pattern.insert(i, "[a-z]*")
    r = re.compile("".join(pattern))
    if (r.match(l) != None) :
        if flug == 0:
            print("YES")
        flug = 1

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

Submission status: Wrong Answer

Solution code:
s = input()
target = 'keyence'
s_len = len(s)
flg = 0

for i in range(7):
    target1_ind = -1
    target1 = target[0:i]
    target2 = target[i:7]
    if target1 in s:
        target1_ind = s.index(target1)
        target1_len = len(target1)
        if target2 in s[target1_ind+target1_len:s_len] :
            if target1_ind == 0:
                if s.index(target2)+len(target2)==s_len:
                    flg = 1
                if s.index(target2)+len(target2)==7:
                    flg = 1

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

Submission status: Wrong Answer

Solution code:
S = input()

key = ['k', 'e', 'y', 'e', 'n', 'c' ,'e']

def findkey(s):
    top_index = s.find('k') # 先頭を探す
    sub = s[top_index+1:]
    f = 1
    cnt = 0
    while f < len(key):
        n_index = sub.find(key[f])
#        print(sub, n_index, key[f])
        if n_index < 0: # 次の文字が見つからない時
            return False, top_index, -1, -1
        elif n_index >= 0:
            # 次の文字が欲しいものだった場合
            if f == len(key) - 1: # 見つけ切った
                return True,  top_index, len(sub) - n_index - 1, cnt
            if n_index + 1 >= len(sub):
                return False,  top_index, -1, -1
            sub=sub[n_index+1:]
            f += 1
            if n_index > 0: # 隙間が空いた場合
                cnt += 1
                if cnt > 1:
                    return False,  top_index, -1, -1
    return False,  top_index, -1

sub = S
i = 0
cnt = 0
while i < len(sub):
#    print(sub)
    top = sub.find('k')
    cnt += 1
    if i < 0:
        flg = False
        break
    else:
        sub = sub[i:]
        flg, i, last, mid = findkey(sub)
        if flg:
            if cnt > 1 or top  > 0: # 前が空いている場合
                if last > 0 or mid> 0:
                    flg = False
            elif last > 0 and mid > 0:
                flg = False
            break
        if i + 1 >= len(sub):
            flg = False
            break
        sub = sub[i+1:]
        
#print(cnt, top, last, mid)
            
if flg:
    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)(.+)(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()
k = 'keyence'
left = 0
right = 0
for i in range(len(k)):
  if (s[i] == k[i]):
    left += 1
  else:
    break
for i in range(1, len(k) + 1):
  if (s[-i] == k[-i]):
    right += 1
  else:
    break
if ((left == 7) | (left + right == 7)):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

for i in range(len(S)):
    if S[i] == 'k':
        for l in range(1, len(s)):
            if S[i+l] != s[l]:
                break
        for n in range(len(S)):
            if S[i:l] + S[l+n:l+n+4] == s:
                if i == 0:
                    if n == 0 or S[l+n+5:] == '':
                        ans = 'YES'
                        break
                else:
                    if n == 0 and S[l+n+5:] == '':
                        ans = 'YES'
                        break
    if ans == 'YES':
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

length = len(s)
flag = False
for k in range(length - 7):
    for l in range(length):
        r = l + k - 1
        if(s[0:l-1]+s[r+1:length] == "keyence"):
            flag = True

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