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:
k = input()
n = 'keyence'
z = 0
for i in range(len(k)):
    if k[i] == 'k':
        for j in range(len(n)):
            if k[i+j] != n[j]:
                z += 1
                for p in range(i+j, len(k)):
                    
                    if n[j:] in k[p:]:
                        break
                    else:
                        z += 1
                        break
            
            break
        break
    else:
        z = 2
    

if z == 0 or z == 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import re
inp = input()
ref = "keyence"
pat = []
pat_comp = ""
for i, j in enumerate(ref):
    pat_comp += j
    pat.append((pat_comp, ref[i+1:]))

if inp.startswith("keyence"):
    print("YES")
elif inp.endswith("keyence"):
    print("YES")
else:
    for i, j in pat:
        p = i + ".*" + j
        if re.match(p, inp):
            print("YES")
            break
    else:
        print("NO")

Submission status: Wrong Answer

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

else:
    for i in range(-1,len(S)+1):
        for j in range(i+1,len(S)+1):
            S_ = list(S)
            del S_[i:j]
            re = "".join(S_)
            if re != "keyence":
                continue
            print("YES")
            ans = 1
            break
if ans == 0:
    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
        elif n_index >= 0:
            # 次の文字が欲しいものだった場合
            if f == len(key) - 1: # 見つけ切った
                return True
            if n_index + 1 >= len(sub):
                return False
            sub=sub[n_index+1:]
            f += 1
            if n_index > 0: # 隙間が空いた場合
                cnt += 1
                if cnt > 1:
                    return False
    return False
        
if findkey(S):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
key_str = "keyence"
key_list = list(key_str)
string = input()
str_list = list(string)
count = 0
flg = True
for key in key_list:
  if(str_list[count] != key):
    key_str[count:]
    if(string.endswith(key_str)):
      print("YES")
    else:
      print("NO")
    flg = False
    break
  count+=1
if(flg):
  print("YES")

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

print(answer)

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

Submission status: Wrong Answer

Solution code:
s = input()
if 'keyence' in s:
    print("YES")
elif 'keyenc' in s:
    index = s.find('keyenc')
    index2 = s.find('e',index+4)
    if index2 != -1:
        print("YES")
elif 'keyen' in s:
    index = s.find('keyen')
    index2 = s.find('ce',index+3)
    if index2 != -1:
        print("YES")
elif 'keye' in s:
    index = s.find('keye')
    index2 = s.find('nce',index+2)
    if index2 != -1:
        print("YES")
elif 'key' in s:
    index = s.find('key')
    index2 = s.find('ence',index+1)
    if index2 != -1:
        print("YES")
elif 'ke' in s:
    index = s.find('ke')
    index2 = s.find('yence',index)
    if index2 != -1:
        print("YES")
elif 'k' in s:
    index = s.find('k')
    index2 = s.find('eyence',index)
    if index2 != -1:
        print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

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

    if pre != cur:
        skip += 1
    pre = cur

    if skip > 2:
        answer = 'NO'
        break

if n == 7 and answer!='NO':
    answer = 'YES'
else:
    answer = 'NO'

print(answer)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
s = input()
key = 'keyence'
key_r = 'ecneyek'
j = 0
for i in key:
    if s[j] == i:
        j += 1
    else:
        break
k = 1
for i in key_r:
    if s[-k] == i:
        k += 1
    else:
        break

s = s[:j] + s[-k+1:]
if s == key:
    print('YES')
elif len(s) == 14:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
s = input()
if 'keyence' in s:
    print("YES")
elif 'keyenc' in s:
    index = s.find('keyenc')
    index2 = s.find('e',index+5)
    if index2 != -1:
        print("YES")
elif 'keyen' in s:
    index = s.find('keyen')
    index2 = s.find('ce',index+4)
    if index2 != -1:
        print("YES")
elif 'keye' in s:
    index = s.find('keye')
    index2 = s.find('nce',index+3)
    if index2 != -1:
        print("YES")
elif 'key' in s:
    index = s.find('key')
    index2 = s.find('ence',index+4)
    if index2 != -1:
        print("YES")
elif 'ke' in s:
    index = s.find('ke')
    index2 = s.find('yence',index+4)
    if index2 != -1:
        print("YES")
elif 'k' in s:
    index = s.find('k')
    index2 = s.find('eyence',index+4)
    if index2 != -1:
        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=''
for i in S:
    #print('{} and ds:{} cont:{} line:{}'.format(i,dusted,cont,line))
    if i!='k' and i!='y' and i!='e' and i!='n' and i!='c':
        if dusted:
            if cont:
                pass
            else:
                print('NO')
                exit(0)
        else:
            dusted=True
            cont=True
    else:
        if line=='':
            if i!='k':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='k'
                cont=False
        elif line=='k':
            if i!='e':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='e'
                cont=False
        elif line=='ke':
            if i!='y':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='y'
                cont=False
        elif line=='key':
            if i!='e':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='e'
                cont=False
        elif line=='keye':
            if i!='n':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='n'
                cont=False
        elif line=='keyen':
            if i!='c':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='c'
                cont=False
        elif line=='keyenc':
            if i!='e':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='e'
                cont=False
        elif line=='keyence':
            if dusted:
                if cont:
                    pass
                else:
                    print ( 'NO' )
                    exit ( 0 )
            else:
                dusted = True
    if dusted:
        if fs:
            fs=False
            cont=True

print('YES' if line=='keyence' else 'NO')

Submission status: Wrong Answer

Solution code:
s=input()
string="keyence"
flag1=0
flag2=0
flag3=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
      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())
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 and S.index(keyence[:i])+i-1 < S.index(keyence[i:]):
          print('YES')
          break
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
from sets import Set

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

print_sig = False

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

if print_sig == False:
	print 'NO'

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=input()
kye="keyence"
Nlen=len(N)
i=0
flag=0
flagz=0
while flag==0 and N[i]==kye[i]:
    if i==6:
        flag=1
    i=i+1

x=i
while flag==0:
    flagz=1
    if N[x]!=kye[i]:
        
        x=x+1
    else:
        break
    if x==Nlen-1:
        flag=2
    

while flag==0 and N[x]==kye[i]:
    if i==6:
        flag=1
    i=i+1
    x=x+1


if flagz==1 and x!=Nlen:
    flag=2

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

Submission status: Wrong Answer

Solution code:
# B
S = input()
K = 'keyence'
k = 0
for i in range(1,len(K)):
    n = S.find(K[:i])
    #print(n)#
    #print(S[n+i:],K[i:])#
    m = S[n+i:].find(K[i:])
    #if n>=0 and m>=0:
    if (n==0 and m>=0) or (n>0 and S[n+i:]==K[i:]):
        
        res = 'YES'
        break
else: res = 'NO'        
print(res)

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(".*keyence.*",N):
        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:
N=input()
kye="keyence"
Nlen=len(N)
i=0
flag=0
flagz=0
while flag==0 and N[i]==kye[i]:
    if i==6:
        flag=1
    i=i+1

x=i
while flag==0:
    flagz=1
    if N[x]!=kye[i]:
        
        x=x+1
    else:
        break
    if x==Nlen-1:
        flag=2
    

while flag==0 and N[x]==kye[i]:
    if i==6:
        flag=1
    i=i+1
    x=x+1

print(Nlen)

if flagz==1 and x!=Nlen:
    flag=2

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

Submission status: Wrong Answer

Solution code:
from sets import Set

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

print_sig = False

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

if print_sig == False:
	print 'NO'

Submission status: Wrong Answer

Solution code:
arr = input()
KEY = "keyence"

def solve():
  index = 0
  state = 0
  for letter in arr:
    print(arr, state)
    if letter == KEY[index]:
      index+=1
      if index == 7:
        return "YES"
      if state == 1:
        state = 2
    else:
      if state == 0:
        state = 1
      elif state == 1:
        pass
      elif state == 2:
        return "NO"
  return "NO"

print(solve())

Submission status: Wrong Answer

Solution code:
s = list(input())
ss = ['k','e','y','e','n','c','e']
p = 6
a = 0
b = 0
c = 0
for i in range(len(ss)):
    if s[i] == ss[i]:
        continue
    else:
        a = i
        break
else:
    print('YES')
    exit()



for j in range(len(s)-1,-1,-1):
    if p >= 0 :
        if (s[j] == ss[p]):
            p -= 1
            c += 1
        else:
            b = c
            break
else:
    print('YES')
    exit()

if a+b == 7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import re
L = input()
if re.match('.*k+.*e+.*y+.*e+.*n+.*c+.*e+.*', L):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

a= input()

if ('k' in a and 'eyence' in a):
    print("YES")
elif('ke' in a and'yence' in a):
    print("YES")
elif('key' in a and 'ence' in a):
    print("YES")
elif('keye' in a and 'nce' in a):
    print("YES");
elif('keyen' in a and 'ce' in a):
    print("YES")
elif('keyenc' in a and 'e' in a):
    print("YES")
elif('keyence' in a):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()

S = 'keyence'
index = 0
for item in N:
    if index == len(S):
        break
    if S[index] == item:
        index += 1
    else:
        break

if index == 7:
    print('YES')
elif S == N[:len(S)]:
    print('YES')
elif S == N[-len(S):]:
    print('YES')
else:
    for index in range(len(S)):
        if S[:index] == N[:index] and S[len(S) - index - 1:] == N[-(len(S) - index):]:
            print('YES')
            break
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
S = input()

keyence = list("keyence")
str_len = len(keyence)

pos_list = []

for i, char in enumerate(S):
    if len(keyence) == 0:
        break
    if char == keyence[0]:
        pos_list.append(i)
        del keyence[0]

diff = map(lambda x, y: x - y, pos_list[1:], pos_list[:-1])
over_one_num = len(list(filter(lambda x: x > 1, diff)))

if over_one_num <= 1 and len(pos_list) == str_len:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
str=str(input())
k="keyence"
for i in range(7):
  l=str.find(k[0:i+1])
  r=str.rfind(k[i+1:8])
  if(l>=0 and r>=0 and l-r<=0):
    print("YES")
    break
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
k = input()
n = 'keyence'
z = 0
for i in range(len(k)):
    if k[i] == 'k':
        for j in range(len(n)):
            if k[i+j] != n[j]:
                z += 1
                for p in range(i+j, len(k)):
                    
                    if n[j:] in k[p:]:
                        break
                    else:
                        z += 1
                        break
            
            break
    else:
        z = 2
    break

if z == 0 or z == 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

    else:
        if a in S:
            return 'YES'
        else:
            return 'NO'



print(m())

Submission status: Wrong Answer

Solution code:
moji = input()
if moji.find('k') >= 0 and moji.find("eyence") >= 0 and moji.find('k')<moji.find("eyence"):
    print("YES")
elif moji.find('ke') >= 0 and moji.find("yence") >= 0 and moji.find('ke')<moji.find("yence"):
    print("YES")
elif moji.find('key') >= 0 and moji.find("ence") >= 0 and moji.find('key')<moji.find("ence"):
    print("YES")
elif moji.find('keye') >= 0 and moji.find("nce") >= 0 and moji.find('keye')<moji.find("nce"):
    print("YES")
elif moji.find('keyen') >= 0 and moji.find("ce") >= 0 and moji.find('keyen')<moji.find("ce"):
    print("YES")
elif moji.find('keyenc') >= 0 and moji.find("e") >= 0 and moji.find('keyenc')<moji.find("e"):
    print("YES")
elif "keyence" in moji:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
N = input()

S = 'keyence'
index = 0
for item in N:
    if index == len(S):
        break
    if S[index] == item:
        index += 1
    else:
        break

if index == 7:
    print('YES')
elif S == N[:len(S)]:
    print('YES')
elif S == N[-len(S):]:
    print('YES')
else:
    for index in range(len(S)):
        if S[len(S) - index - 1:] == N[-(len(S) - index):]:
            print('YES')
            break
    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
ngflg = 0
ngcnt = 0

# Search
for idx in range(len(s)):
    if s[idx] == key_str[search_idx]:
        search_idx += 1
        ngflg = 0
        if search_idx == len(key_str):
            if len(s) > (idx + 1) and ngcnt >= 1:
                search_idx = -1
            break
    else:
        if ngflg == 0:
            ngcnt += 1
            ngflg = 1
        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 = 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 and S.index(keyence[:i])+i < S.index(keyence[i:]):
          print('YES')
          break
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
q=0

if s.find("keyence")!=-1:
    q=1#ok
else:
    si=s.find("keyenc")
    if si!=-1 and si+6<=len(s)-1:
        if s[si+6:].find("e")!=-1:
            q=1
    else:
        si=s.find("keyen")
        if si!=-1 and si+6<=len(s)-1:
            if s[si+5:].find("ce")!=-1:
                q=1
        else:
            si=s.find("keye")
            if si!=-1 and si+6<=len(s)-1:
                if s[si+4:].find("nce")!=-1:
                    q=1
            else:
                si=s.find("key")
                if si!=-1 and si+6<=len(s)-1:
                    if s[si+3:].find("ence")!=-1:
                        q=1
                else:
                    si=s.find("ke")
                    if si!=-1 and si+6<=len(s)-1:
                        if s[si+2:].find("yence")!=-1:
                            q=1
                    else:
                        si=s.find("k")
                        if si!=-1 and si+6<=len(s)-1:
                            if s[si+1:].find("eyence")!=-1:
                                q=1
if q==1:
    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.find('keyence')
if  find == 0 or rfind==len(S)-7:
    print('YES')
    exit(0)
elif find != -1:
    print('NO')
    exit(0)

fs=True
line=''
for i in S:
    #print('{} and ds:{} cont:{} line:{}'.format(i,dusted,cont,line))
    if i!='k' and i!='y' and i!='e' and i!='n' and i!='c':
        if dusted:
            if cont:
                pass
            else:
                print('NO')
                exit(0)
        else:
            dusted=True
            cont=True
    else:
        if line=='':
            if i!='k':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='k'
                cont=False
        elif line=='k':
            if i!='e':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='e'
                cont=False
        elif line=='ke':
            if i!='y':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='y'
                cont=False
        elif line=='key':
            if i!='e':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='e'
                cont=False
        elif line=='keye':
            if i!='n':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='n'
                cont=False
        elif line=='keyen':
            if i!='c':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='c'
                cont=False
        elif line=='keyenc':
            if i!='e':
                if dusted:
                    if cont:
                        pass
                    else:
                        print ( 'NO' )
                        exit ( 0 )
                else:
                    dusted = True
            else:
                line+='e'
                cont=False
        elif line=='keyence':
            if dusted:
                if cont:
                    pass
                else:
                    print ( 'NO' )
                    exit ( 0 )
            else:
                dusted = True
    if dusted:
        if fs:
            fs=False
            cont=True

print('YES' if line=='keyence' else 'NO')

Submission status: Wrong Answer

Solution code:
key = 'keyence'
word = ''
s = input()
s_list = list(s)
flag = True

for i in key:
    if not i in s_list:
        print('NO')
        flag = False
        break
    s_list.remove(i)

for j in s_list:
    word += j

if flag:
    if s.count(word) == 1 or len(word) == 0:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:

a= input()

if ('k' in a and 'eyence' in a):
    print("YES")
elif('ke' in a and'yence' in a):
    print("YES")
elif('key' in a and 'ence' in a):
    print("YES")
elif('keye' in a and 'nce' in a):
    print("YES");
elif('keyen' in a and 'ce' in a):
    print("YES")
elif('keyenc' in a and 'e' in a):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
correct_count = 0
wrong_char_index_list = []

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

#print(wrong_char_index_list)
# 全部間違い
if len(wrong_char_index_list) == len(s):
    print("NO")
    exit()

# 間違い箇所が飛んでたらダメ
for i in range(1, len(wrong_char_index_list)):
    if wrong_char_index_list[i] - wrong_char_index_list[i-1] != 1:
        print("NO")
        exit()

print("YES")
exit()

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[S.index(t1)+len(t1):].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:

def solve(s):
  t = 'keyence'
  if t in s[0:7] or t in s[-7:]:
    return 'YES'

  p = 0
  for i in range(len(s)):
    if t[p] == s[i]:
      p = p + 1
    else:
      if t[p:] in s[-p:]:
        return 'YES'
      else:
        return 'NO'
  return 'NO'

print(solve(input()))

Submission status: Wrong Answer

Solution code:
s = list(input())
ss = ['k','e','y','e','n','c','e']
p = 6
a = 0
b = 0
c = 0
for i in range(len(ss)):
    if s[i] == ss[i]:
        continue
    else:
        a = i
        break
else:
    print('YES')
    exit()



for j in range(len(s)-1,-1,-1):
    if p >= 0 :
        if (s[j] == ss[p]):
            print('ヌッ',c)
            p -= 1
            c += 1
        else:
            b = c
            break
else:
    print('YES')
    exit()

if a+b == 7:
    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+i:]:
            secondindex = s.index(a[i:8])
            
            if s[0:firstindex+i]+s[secondindex:] == a:
                print('YES')
                flag = 0
                break

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

Submission status: Wrong Answer

Solution code:
import re
x = input()

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

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