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()
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
            else:
                if target1_ind+len(target) == 7:
                    flg = 1

if flg == 1:
    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()

a="keyence"

j=0

count=0

dif_count=0

if(s[0]!=a[0]):
    dif_count=1

for i in range(len(s)):
    if(s[i]==a[j]):
        j+=1
        count+=1
        if(count==7):
            if(i+1<len(s)):
                dif_count+=1
            break
        if(s[i+1]!=a[j] and i<len(s)-1):
            dif_count+=1
            
        
        
if(count==7 and dif_count<2 ):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import re
s = input()
t = 'keyence'

for i in range(7):
    m1 = re.search(t[:i], s)
    m2 = re.search(t[i:], s)
    if (m1 is not None) and (m2 is not None):
        s1 = m1.start()
        s2 = m2.start()
        if (s1 < s2) and (' ' not in s[s1:s2]):
            print('YES')
            break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# coding: utf-8

cnt=0
keyence="keyence"
flg=[-1,-1,-1,-1,-1,-1,-1]
s=input()

for i in range(len(s)):
    for j in range(len(keyence)):
        if s[i]==keyence[j] and flg[j]==-1:
            flg[j]=i
        elif flg[j]==-1:
            break

for i in range(len(flg)-1):
    if flg[i+1]-flg[i]!=1:
        cnt+=1

print(flg)

if flg[0]!=0:
    cnt+=1
if flg[6]!=len(s)-1:
    cnt+=1

if cnt<2:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
def A():
    S = list(input())
    cnt = 0
    p = 3
    keyence = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
    for i in range(7):
        if S[i] != keyence[i]:
            if i == 0:
                p = 1
            if i < 7:
                p = 2
                cnt = i
                break
            if i >= 7:
                p = 3
    ans = 0
    if S[:7:] == keyence:
        ans = 1
    elif S[len(S) - 7::] == keyence:
        ans = 1
    elif S[len(S) - (7 - cnt)::] == keyence[6 - cnt::]:
        ans = 1
    else:
        ans = -1
    if ans == 1:
        print("YES")
    else:
        print("NO")
A()

Submission status: Wrong Answer

Solution code:

def n_gram(target, n):
    result = []
    for i in range(0, len(target) - n + 1):
        result.append(target[i:i + n])

    return result

x = input()
true="keyence"    
bigram_t = n_gram(true,2)
bigram_x = n_gram(x,2)
cnt=0
for i in bigram_x:
    for j in bigram_t:
        if j == i:
            cnt += 1
print("YES") if cnt >= len(bigram_t)-1 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:] != '':
                        pass
                    else:
                        ans = 'Yes'
                        break
    if ans == 'YES':
        break
print(ans)

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.search(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()
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
            else:
                if target1_ind+len(target) == 7 or target1_ind+len(target)==s_len:
                    flg = 1

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

Submission status: Wrong Answer

Solution code:
import sys
num_list = input()
key = 'keyence'
i = 0



while num_list[i]==key[i]:
    i+=1
    if i == 7:
        print('YES')
        exit()
n = i



i = -1
while num_list[i]==key[i]:
    i -= 1
    n += 1


    if n >= 6:
        print('YES')
        exit()
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
L = 'keyence'
idx = 0
i = 0
prev = True
now = True
cnt = 0
for item in S:
    if idx >= len(L):
        if i != len(S):
            cnt += 1
        break
    else:
        if L[idx] == item:
            idx += 1
            now = True
        else:
            now = False
        if prev and (not now):
            cnt += 1
    i += 1
    prev = now
if idx == len(L) and cnt < 2:
    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
for i in range(len ( S )):

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

    except ValueError:
        b_err=True

        if not keyence:
            print ( 'YES' )
            exit ( 0 )
    try:
        if not a_err:
            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 ( )

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
for i in range(len ( S )):

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

    except ValueError:
        b_err=True

        if not keyence:
            print ( 'YES' )
            exit ( 0 )
    try:
        if not a_err:
            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
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.search(".*keyencekeyence",N):
        if (re.sub('.*keyencekeyence', '', N)=="")==True:
            print("YES")
            break
    if re.search("keyencekeyence.*",N):
        if (re.sub('keyencekeyence.*', '', N)=="")==True:
            print("YES")
            break
    if (re.sub('.*keyence', '', N)=="")==True:
        print("YES")
        break
    if (re.sub('keyence.*', '', N)=="")==True:
        print("YES")
        break
    if re.match("%s.*%s"%(mae, ato),N):
        print("YES")
        break
if i==6:
    print("NO")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
S=input()
import copy
s=copy.deepcopy(S)
n=len(s)
I=['k','e','y','e','n','c','e']
i=0

f1=0
f2=0
answer='NO'  
while(1):
    if (n<=i)or(len(I)==0):
        if len(I)==0:
            if f1==0:
                # print(1)
                answer='YES'
            else:
                if i!=n:break
                # print(i)
                answer='YES'
        break
        
    if (s[i]==I[0]):
        del(I[0])
        i+=1
        if f1==1:
            f2=1

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

I=['k','e','y','e','n','c','e']
I.reverse()
i=n-1
f1=0
f2=0
while(1):
    if (i<0)or(len(I)==0):
        if len(I)==0:
            if f1==0:
                # print(1)
                answer='YES'
            else:
                if i!=-1:break
                # print(i)
                answer='YES'
        break
        
    if (s[i]==I[0]):
        del(I[0])
        i-=1
        if f1==1:
            f2=1

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

print(answer)

Submission status: Wrong Answer

Solution code:
S = input()

len_s = len(S)
key_s = "keyence"
len_key_s = len(key_s)

def main(S, 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")
            return True
        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")
                return True
            else:
                #print("NO")
                return False
    else:
        #print("NO")
        return False

res1 = main(S, key_s)
res2 = main(S[::-1], key_s[::-1])

res = res1 and  res2

out = "YES" if res else "NO"
print(out)

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

k_count = data.count('k')
if data.count('k') == 0:
    print('NO')
else:
    ans = False
    for i in range(k_count):
        if check(data[i:len(data)]):
            ans = True
            break

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

STRNUM = 8

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

in_s = input()
l = len(in_s)
is_key = False
if(l >= 7)|(l <= 100):
    keyence = list("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[1]=="":
                            is_key = True
                            break
                else:
                    break
            else:
                break

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

Submission status: Wrong Answer

Solution code:
S=input()
answer = 'NO'

if 'keyence' in S:
    answer = 'YES'
elif S[:1] == 'k':
    if S[-6:] == 'eyence':
        answer = 'YES'
elif S[:2] == 'ke':
    if S[-5:] == 'yence':
        answer = 'YES'
elif S[:3] == 'key':
    if S[-4:] == 'ence':
        answer = 'YES'
elif S[:4] == 'keye':
    if S[-3:] == 'nce':
        answer = 'YES'
elif S[:5] == 'keyen':
    if S[-2:] == 'ce':
        answer = 'YES'
elif S[:6] == 'keyenc':
    if S[-1:] == 'e':
        answer = 'YES'



print(answer)

Submission status: Wrong Answer

Solution code:
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
for i in range(7):
    x=s.find(search[0:i+1])
    #print("ps=%s, ns=%s, reduce=%s" %(search[0:i+1], search[i+1:], s[x+i+1:]))
    if x == -1:
        break
    if s[x+i:].find(search[i+1:])>=0:
        ans = "YES"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
str_input = input().rstrip()

str_input_list = []
for a in str_input:
    str_input_list.append(a)


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

for a in range(7):
    if keyence_list[a] in str_input_list:
        keyence_list[a] = '*'

        for b in range(len(str_input_list)):
            if str_input_list[b] == keyence_list[a]:
                str_input_list.remove(b)
                break

if keyence_list == ['*', '*', '*', '*', '*', '*', '*']:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

if (s.count('k') >= 1) and (s.count('e') >= 3) and (s.count('y') >= 1) and (s.count('n') >= 1) and (s.count('c') >= 1):
    print("YES")
    exit()

print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
string="keyence"
flag1=0
flag2=0
flag3=1
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[-len(mojiretsu):len(mojiretsu)+1]==mojiretsu:
        print('YES')
        # print('koko?')
        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')
      # print('ここ？')
      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 = list(input())
x = list("keyence")
k = 0
t0 = 0
t1 = 0
t2 = 0
for i in range(len(s)):
    if s[i]!=x[k]:
        if k>0 and t0==1:
            break
        if k>0 and t1==1:
            t2 = 1
        if k>0 and t1==2:
            break
    if s[i]==x[k]:
        if k==0 and i>0:
            t0 = 1
        if t0==0:
            t1 = 1
        if t2==1:
            t1=2
        k+=1
    if k==len(x):
        break

if i==len(s)-1 and k==len(x):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

s = s.replace("key", "%")
s = s.replace("ence", "&")

if "%" not in s:
    print("NO")
elif "&" not in s:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
import re
input_string = input()
keyence = "keyence"
patterns = ['.*?(keyence)', '(k).*?(eyence)', '(ke).*?(yence)', '(key).*?(ence)', '(keye).*?(nce)', '(keyen).*?(ce)', '(keyenc).*?(e)', '(keyence).*?']
flag = False
for i in range(len(patterns)):
    if re.match(patterns[i], input_string):
        flag = True
        break
if flag == True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S='keyenceaa'
answer = 'NO'

if 'keyence' in S:
    answer = 'YES'
elif S[:1] == 'k':
    if S[-6:] == 'eyence':
        answer = 'YES'
elif S[:2] == 'ke':
    if S[-5:] == 'yence':
        answer = 'YES'
elif S[:3] == 'key':
    if S[-4:] == 'ence':
        answer = 'YES'
elif S[:4] == 'keye':
    if S[-3:] == 'nce':
        answer = 'YES'
elif S[:5] == 'keyen':
    if S[-2:] == 'ce':
        answer = 'YES'
elif S[:6] == 'keyenc':
    if S[-1:] == 'e':
        answer = 'YES'



print(answer)

Submission status: Wrong Answer

Solution code:
print('YES')

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:
            b= var.find("e",b,len(var))+1
            if "y" in var and var.find("y",b,len(var))+1 > b:
                b= var.find("y",b,len(var))+1
                if "e" in var and var.find("e",b,len(var))+1 > b:
                     b= var.find("e",b,len(var))+1
                     if "n" in var and var.find("n",b,len(var))+1 > b:
                         b= var.find("n",b,len(var))+1
                         if "c" in var and var.find("c",b,len(var))+1 > b:
                             b= var.find("c",b,len(var))+1
                             if "e" in var and var.find("e",b,len(var))+1 > b:
                                 flg = True
if flg:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S='keyenceaa'
answer = 'NO'

if 'keyence' in S:
    answer = 'YES'
elif S[0] == 'k':
    if S[-6:] == 'eyence':
        answer = 'YES'
elif S[:2] == 'ke':
    if S[-5:] == 'yence':
        answer = 'YES'
elif S[:3] == 'key':
    if S[-4:] == 'ence':
        answer = 'YES'
elif S[:4] == 'keye':
    if S[-3:] == 'nce':
        answer = 'YES'
elif S[:5] == 'keyen':
    if S[-2:] == 'ce':
        answer = 'YES'
elif S[:6] == 'keyenc':
    if S[-5:] == 'e':
        answer = 'YES'



print(answer)

Submission status: Wrong Answer

Solution code:
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
for i in range(7):
    x=s.find(search[0:i+1])
    #print("ps=%s, ns=%s, reduce=%s" %(search[0:i+1], search[i+1:], s[x+i+1:]))
    if x == -1:
        break
    if s[x+i+1:].find(search[i+1:])>=0:
        ans = "YES"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

k = 'keyence'

if len(S) < 7:
    print('NO')
    exit()

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')

Submission status: Wrong Answer

Solution code:
N=input()
kye="keyence"
Nlen=len(N)
flag=0
i=0
x=0
if 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:
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)==len(s):
                    flg = 1
            else:
                if target1_ind+len(target) == 7:
                    flg = 1

if flg == 1:
    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:
    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y" and S[-6]=="e" and S[-7]=="k":
        print("YES")
    else:
        if S[0]=="k":
            if S[1]=="e":
                if S[2]=="y":
                    if S[3]=="e":
                        if S[4]=="n":
                            if S[5]=="c":
                                if S[6]=="e":
                                    print("YES")
                                else:
                                    if S[-1]=="e":
                                        print("YES")
                                    else:
                                        print("No")
                            else:
                                if S[-1]=="e" and S[-2]=="c":
                                    print("YES")
                                else:
                                    print("No")
                        else:
                            if S[-1]=="e" and S[-2]=="c" and S[-3]=="n":
                                print("YES")
                            else:
                                print("NO")
                    else:
                        if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e":
                            print("YES")
                        else:
                            print("NO")
                else:
                    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y":
                        print("YES")
                    else:
                        print("NO")
            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")
                else:
                    print("NO")
        else:
            print("NO")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import re
s = input()
t = 'keyence'

for i in range(7):
    m1 = re.search(t[:i], s)
    m2 = re.search(t[i:], s)
    if (m1 is not None) and (m2 is not None):
        if m1.start() < m2.start():
            print('YES')
            break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
input_str = input()
target_lst = ['k','e','y','e','n','c','e']

i = 0
del_list = []
for elm in input_str:
  if elm in target_lst:
    target_lst.remove(elm)
    del_list.append(i)
  i+=1

if len(target_lst) !=  0:
  print('NO')
else:
  for i in range(len(del_list)):
    if i == 0:
      continue
    else:
      if del_list[i] < del_list[i-1]:
        print('NO')

  print('YES')

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.search(".*keyencekeyence",N):
        print("YES")
        break
    if re.search("keyencekeyence.*",N):
        print("YES")
    
    if (re.sub('.*keyence', '', N)=="")==True:
        print("YES")
        break
    if (re.sub('keyence.*', '', N)=="")==True:
        print("YES")
        break
    if re.match("%s.*%s"%(mae, ato),N):
        print("YES")
        break
if i==6:
    print("NO")

Submission status: Wrong Answer

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

for i in range(len(keyence)):
    if keyence[:i] in S:
        s = S.find(keyence[:i]) + i
        S2 = S[s:]
        if keyence[i:] in S2:
            print("YES")
            sys.exit()

print("NO")

Submission status: Wrong Answer

Solution code:
import re
input_string = input()
keyence = "keyence"
patterns = ['.*(keyence)', '(k).*(eyence)', '(ke).*(yence)', '(key).*(ence)', '(keye).*(nce)', '(keyen).*(ce)', '(keyenc).*(e)', '(keyence).*']
flag = False
for i in range(len(patterns)):
    if re.match(patterns[i], input_string):
        flag = True
        break
if flag == True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

result = "NO"

if "keyence" in S:
    result = "YES"
if "k" in S:
    k_index = S.index("k")
    if "eyence" in S[k_index + 1:]:
        result = "YES"
if "ke" in S:
    ke_index = S.index("ke")
    if "yence" in S[ke_index + 1:]:
        result = "YES"
if "key" in S:
    key_index = S.index("key")
    if "ence" in S[key_index + 1:]:
        result =  "YES"
if "keye" in S:
    keye_index = S.index("keye")
    if "nce" in S[keye_index + 1:]:
        result = "YES"
if "keyen" in S:
    keyen_index = S.index("keyen")
    if "ce" in S[keyen_index + 1:]:
        result = "YES"
if "keyenc" in S:
    keyenc_index = S.index("keyenc")
    if "e" in S[keyenc_index + 1:]:
        result = "YES"

print(result)

Submission status: Wrong Answer

Solution code:
S = input()
K = 'keyence'
for i in range(len(S)):
    if not S[i] in K:
        S = S.replace(S[i], ' ')
S = S.split()
if S[0]==K or S[0]+S[len(S)-1]==K or S[len(S)-1]==K or K in S[0]:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

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


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

Submission status: Wrong Answer

Solution code:
S = input()

keyence = list("keyence")
keyence_len = len(keyence)

keyence_pos = []
other_pos = []

for i, char in enumerate(S):
    if len(keyence) > 0 and char == keyence[0]:
        del keyence[0]
        keyence_pos.append(i)
    else:
        other_pos.append(i)

if len(other_pos) > 0:
    first = other_pos[0]
    other_pos = list(map(lambda x: x - first, other_pos))
    if set(other_pos) == set(range(len(other_pos))) and len(keyence_pos) == keyence_len:
        print("YES")
    else:
        print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
a = str(input())
k = "keyence"
lk = len(k)
la = len(a)

ok = 0

if len(a) >= lk:
    s1 = a.find(k)
    s2 = len(a[s1:])
    if s1 == 0 or s2 == lk:
        ok = 1

    for i in range(la):
        s1 = a.find(k[:i])
        s2 = a[s1+i:].find(k[i:])
        if s1 >= 0 and s2 >= 0:
            if s1 == 0 and len(a[s1+i+s2:]) == len(k[i:]):
                ok = 1

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

cnt=0
keyence="keyence"
flg=[-1,-1,-1,-1,-1,-1,-1]
s=input()

for i in range(len(s)):
    for j in range(len(keyence)):
        if s[i]==keyence[j] and flg[j]==-1:
            flg[j]=i
        elif flg[j]==-1:
            break

for i in range(len(flg)-1):
    if flg[i+1]-flg[i]!=1:
        cnt+=1

if cnt<=2:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

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

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

if s[0] == 'k' and s[1] == 'e' and s[2] == 'y' and s[-4] == 'e' and s[-3] == 'n' and s[-2] == 'c' and s[-1] == 'e':
    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 and S[l+n+5:] == '':
                if i == 0 or  n == 0:
                    ans = 'YES'
                    break
    if ans == 'YES':
        break
print(ans)

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" ]
for i in range(len ( S )):

    print ( keyence )
    print ( 'i {} ri {}'.format ( S[i], S[len(S)-1-i] ) )
    try:
        keyence.remove ( S[len(S)-1-i] )
        if not keyence:
            print ( 'YES' )
            exit ( 0 )
        keyence.remove ( S[i] )

    except ValueError:
        print ( 'NO' )
        exit ( 0 )
    if not keyence:
        print ( 'YES' )
        exit ( 0 )

Submission status: Wrong Answer

Solution code:
s=input()
string="keyence"
flag1=0
flag2=0
flag3=1
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:
          print('YES')
          exit()
      if s[-len(mojiretsu):len(mojiretsu)+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 = str(input())
 
kchars = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
 
remaining_string = S
current_position = 0
for idx, char in enumerate(kchars):
    if char not in remaining_string:
        # 文字列が見つからなければ失敗
        print('NO')
        break
 
    if idx == len(kchars) - 1:
        # 含まれていた文字列が、最後の文字'e'だった場合、成功
        print('YES')
        break
    else:
        char_index = remaining_string.index(char)
        remaining_string = S[current_position + char_index + 1:]
        current_position += char_index + 1