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 = str(input())
S = S.replace(' ', 'h')
if len(S) > 100 or len(S) < 7:
    print('NO')
elif not(S.isalpha() and S.islower()):
    print('NO')
else:
    # 分割のパターンを洗い出す方法
    k_str = 'keyence'
    patterns = [[k_str[:i], k_str[i:]] for i in range(0, len(k_str))]
    for pattern in patterns:
        if pattern[0] in S:
            next_starting_idx = S.index(pattern[0]) + len(pattern[0])
            if pattern[1] in S[next_starting_idx:]:
                print('YES')
                break
    else:
        print('NO')

Submission status: Wrong Answer

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

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
j,old = 0,0
for i in bigram_t:
    j = 0
    while len(bigram_x)>old+j:
        if i == bigram_x[old+j]:
            cnt += 1
            old += j
            break
        j += 1
        
print("YES") if cnt >= len(bigram_t)-2 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(0,7):
      if keyence[:i] in S and keyence[i:] in S[S.index(keyence[:i])+i:] : # keyenceがある
        if i==0 and S.index(keyence[i:])==0 : # keyenceXXX のとき
            print('YES')
            break
        elif i==0 and S.index(keyence[i:])!=0 and len(S)-7 == S.index(keyence[i:]) : # XXXkeyence のとき
            print('YES')
            break
        elif S[S.index(keyence[i:])+(7-i):] == '' :  # keyXXXenceのとき
            print('YES')
            break
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
string = input()
#print(string[1])
if 'k' in string and 'eyence' in string:
  if string.index('k')<string.rfind('eyence'):
  	print("YES")
elif 'ke' in string and 'yence' in string:
  if string.index('ke')<string.rfind('yence'):
  	print("YES")  
elif 'key' in string and 'ence' in string:
  if string.index('key')<string.rfind('ence'):
  	print("YES")
elif 'keye' in string and 'nce' in string:
  if string.index('keye')<string.rfind('nce'):
  	print("YES")
elif  'keyen' in string and 'ce' in string:
  if string.index('keyen')<string.rfind('ce'):
  	print("YES")
elif  'keyenc' in string and 'e' in string:
  if string.index('keyenc')<string.rfind('e')-3:
  	print("YES")
  else:
  	print("NO")
elif 'keyence' in string:
  	print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_KeyencePrograming_Contest-B
#  TODO https://keyence2019.contest.atcoder.jp/tasks/keyence2019_b
import re

def solveProblem(inputStr):
	pattern1 = r"[a-z]*keyence"
	pattern2 = r"k[a-z]*eyence"
	pattern3 = r"ke[a-z]*yence"
	pattern4 = r"key[a-z]*ence"
	pattern5 = r"keye[a-z]*nce"
	pattern6 = r"keyen[a-z]*ce"
	pattern7 = r"keyenc[a-z]*e"
	pattern8 = r"keyence[a-z]*"
	matchOB1 = re.search(pattern1,inputStr)
	matchOB2 = re.search(pattern2,inputStr)
	matchOB3 = re.search(pattern3,inputStr)
	matchOB4 = re.search(pattern4,inputStr)
	matchOB5 = re.search(pattern5,inputStr)
	matchOB6 = re.search(pattern6,inputStr)
	matchOB7 = re.search(pattern7,inputStr)
	matchOB8 = re.search(pattern8,inputStr)
	if matchOB1 != None:
		return "Yes"
	if matchOB2 != None:
		return "Yes"
	if matchOB3 != None:
		return "Yes"
	if matchOB4 != None:
		return "Yes"
	if matchOB5 != None:
		return "Yes"
	if matchOB6 != None:
		return "Yes"
	if matchOB7 != None:
		return "Yes"
	if matchOB8 != None:
		return "Yes"
	return "No"


if __name__ == '__main__':
	S = input().strip()
	solution = solveProblem(S)
	print("{}".format(solution))

Submission status: Wrong Answer

Solution code:
import re
input_str = input()
pattern_1 = r".+?keyence$"
pattern_2 = r"^k.+?yence$"
pattern_3 = r"^ke.+?yence$"
pattern_4 = r"^key.+?ence$"
pattern_5 = r"^keye.+?nce$"
pattern_6 = r"^keyen.+?ce$"
pattern_6 = r"^keyenc.+?e$"
pattern_7 = r"^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()
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 target2 == target:
        if target in s:
            if s.index(target) == 0 or s.index(target)+7 == s_len:
                flg = 1
    else:
        if target1 in s and target2 in s:
            if s.index(target1) == 0 and s.index(target2)+len(target2) == s_len-1:
                flg = 1

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

if kn == 7 or S.replace(tmp, ''):
    print('YES')
else:
    a = 0
    b = 6
    agr = 0
    St = 0
    La = len(S)
    for i in range(St, len(S)):
        if a >= b:
            break
        if S[i] == K[a]:
            a += 1
            for j in range(La-agr-1, 0, -1):
                if S[j] == K[b]:
                    b -= 1
                    agr+= 1
                    break
                    if a == b:
                        print("YES")
                        exit()
    print("NO")
    exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :
 
"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  1/13 21:11:56 2019
 
# Usage
#
"""
 
TARGET = "keyence"
global CREDIT
CREDIT = True
 
 
def get_input():
    return input()
 
def solve(s):
    """
    >>> solve("keyence")
    YES
    >>> solve("keyofscience")
    YES
    >>> solve("ashlfyha")
    NO
    """
    pos = 0
 
    for i in TARGET:
        if CREDIT:
            pos = mog(s,i,pos)
            if pos == -1:
                return "NO"
        else:
            pos = mogmog(s,i,pos)
            if pos == -1:
                return "NO"
    if CREDIT:
        return "YES"
    else:
        if pos == len(s):
            return "YES"
        else:
            return "NO"
def mogmog(original, target, pos):
    """
    >>> mog("keyence", "k", 0)
    1
    >>> mog("aaa", "k", 0)
    -1
    """
    if len(original) == pos:
        return -1
    if original[pos] == target:
        return pos + 1
    else:
        return -1
 
def mog(original, target, pos):
    """
    >>> mog("keyence", "k", 0)
    1
    >>> mog("aaa", "k", 0)
    -1
    """
    if len(original) == pos:
        return -1
    if original[pos] == target:
        return pos + 1
    else:
        global CREDIT
        CREDIT = False
        return mog(original, target, pos+1)
 
if __name__ == '__main__':
    print(solve(get_input()))

Submission status: Wrong Answer

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

ans = 'NO'
if S[:7] == s:
    ans = 'YES'
elif S[0] == 'k':
    if S[-6:] == s[1:]:
       ans = 'YES'
elif S[0] != 'k':
    if S[-7:] == s:
        ans = 'YES'
print(ans)

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:
            break

if kn == 7 or S.replace(tmp, ''):
    print('YES')
else:
    a = 0
    b = 6
    agr = 0
    St = 0
    La = len(S)
    for i in range(St, len(S)):
        if a >= b:
            break
        if S[i] == K[a]:
            a += 1
            for j in range(La-agr-1, 0, -1):
                if S[j] == K[b]:
                    b -= 1
                    agr+= 1
                    if a == b:
                        print("YES")
                        exit()
    print("NO")
    exit()

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
input_str = input()
pattern_1 = r"[a-z]+?keyence$"
pattern_2 = r"^k[a-z]+?yence$"
pattern_3 = r"^ke[a-z]+?yence$"
pattern_4 = r"^key[a-z]+?ence$"
pattern_5 = r"^keye[a-z]+?nce$"
pattern_6 = r"^keyen[a-z]+?ce$"
pattern_6 = r"^keyenc[a-z]+?e$"
pattern_7 = r"^keyence[a-z]+?"
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:
a = input()
k="keyence"
ti = 0
x =[0]*(len(a))
r = 0
if a[0] !=k[0]:r+=1
aaa = a.count(k)
for i in range(len(a)):
    if ti==7:
        r+=1
        break
    elif a[i] == k[ti]:
        ti +=1
        x[i]=1
    elif i !=0 and a[i] !=k[ti] and x[i-1]==1:r+=1    
if ti == 7 and r < 2 and aaa==1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
ans='keyence'
i=0 # index of s
index=0 # index of ans
isCut=0
canRestart=0
restart=0
lenS=len(s)
while i<lenS:
    if isCut==1: # 切られたあと
        if index>6: # 7=len(ans)
            if canRestart:
                canRestart=0
                i=restartI
                index=restartIndex
            else:
                break
        if s[i]==ans[index]:
            index+=1
        else:
            if canRestart:
                canRestart=0
                isCut=-1
                i=restartI
                index=restartIndex
            else:
                break
    elif isCut==-1: # 切られている途中
        if s[i]==ans[index]:
            # 切り方を変えるときはiとindexを戻す
            restartIndex=index
            restartI=i
            canRestart=1
            isCut=1
            index+=1
    else: # 切られる前
        if s[i]==ans[index]:
            index+=1
        else:
            isCut=-1
    i+=1
    # print(i,index,isCut)

if index<=6: # 7=len(ans)
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
s = input()
if s[:1] == "k" and s[-1:] == "e":
    print("NO")
elif s[1:2] == "k" or s[-1:] == "e" or s == "keyence":
    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 target2 == target:
        if target in s:
            if s.index(target) == 0 or s.index(target)+7 == s_len:
                flg = 1
    else:
        if target1 in s and target2 in s:
            if s.index(target1) == 0 and s.index(target2)+len(target2) == s_len:
                flg = 1

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

Submission status: Wrong Answer

Solution code:
S = list(input())

key = list('keyence ')

index = 0
breakpoint = 0
is_prev_keyword = True
for c in S:
  if c != key[index]:
    if is_prev_keyword:
      breakpoint += 1
    is_prev_keyword = False

  else:
    is_prev_keyword = True
    index += 1

if index == len(key) - 1 and breakpoint <= 1:
  print('YES')
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)):
  r1=r[:i+1]
  r2=r[-(len(r)-i-1):]
  r1i=s.find(r1)
  r2i=s.find(r2)
  
  if r1i<0 or r2i<0:
    continue
  elif r1i==0:
    if r2i==len(s)-len(r2):
      res=True
  
if res:
  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:
            break

if kn == 7 or S.replace(tmp, ''):
    print('YES')
else:
    a = 0
    b = 6
    St = 0
    La = len(S)
    for i in range(St, len(S)):
        if a >= b:
            break
        if S[i] == K[a]:
            a += 1
            for j in range(La-b-1, 0, -1):
                if S[j] == K[b]:
                    b -= 1
                    if a == b:
                        print("YES")
                        exit()
    print("NO")
    exit()

Submission status: Wrong Answer

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

ans = 'NO'
if S[:7] == s:
    ans = 'YES'
elif S[0] == 'k':
    if S[:-6] == s[1:]:
       ans = 'YES'
elif S[0] != 'k':
    if S[:-7] == s:
        ans = 'YES'
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

s=input()
a=0
b=0
c=0
d=0
e=0
f=0
g=0
while s[a]!="k":
    a+=1
    if a==len(s):
        print("NO")
        sys.exit()
b=a+1
while s[b]!="e":
    b+=1
    if b==len(s):
        print("NO")
        sys.exit()
c=b+1
while s[c]!="y":
    c+=1
    if c==len(s):
        print("NO")
        sys.exit()
d=c+1
while s[d]!="e":
    d+=1
    if d==len(s):
        print("NO")
        sys.exit()
e=d+1
while s[e]!="n":
    e+=1
    if e==len(s):
        print("NO")
        sys.exit()
f=e+1
while s[f]!="c":
    f+=1
    if f==len(s):
        print("NO")
        sys.exit()
g=f+1
while s[g]!="e":
    g+=1
    if not "e" in s[g]:
        print("NO")
        sys.exit()
if s=="keyence":print("YES")
else:
    if b+g==c+f==d+e:
        print("YES")
    elif a==0 and b!=1 and(c==b+1 and d==c+1 and e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c!=2 and(d==c+1 and e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d!=3 and (e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e!=4 and (f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e==4 and f!=5 and g==f+1:
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e==4 and f!=5 and g!=6:
        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, r'\w*')
    
    key = ''.join(key)
    keyence = ''.join(keyence)
    result = re.match(keyence, key)
    if result:
        print("YES")
        quit()
    
    key = list(str(key))
    keyence = list(str(keyence))
    
    for s in r'\w*':
        keyence.remove(s)

print("NO")

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
input_str = input()
pattern_1 = r"[^k]+?keyence$"
pattern_2 = r"^k[^ke]+?yence$"
pattern_3 = r"^ke[^ey]+?yence$"
pattern_4 = r"^key[^ye]+?ence$"
pattern_5 = r"^keye[^en]+?nce$"
pattern_6 = r"^keyen[^nc]+?ce$"
pattern_6 = r"^keyenc[^ce]+?e$"
pattern_7 = r"^keyence[^e]+?"
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 = str(input())
if len(S) > 100 or len(S) < 7:
    print('NO')
elif not(S.isalpha() and S.islower()):
    print('NO')
else:
    # 分割のパターンを洗い出す方法
    k_str = 'keyence'
    patterns = [[k_str[:i], k_str[i:]] for i in range(0, len(k_str))]
    for pattern in patterns:
        if pattern[0] in S:
            next_starting_idx = S.index(pattern[0]) + len(pattern[0])
            if pattern[1] in S[next_starting_idx:]:
                print('YES')
                break
    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:
            break

if kn == 7 or S.replace(tmp, ''):
    print('YES')
else:
    a = 0
    b = 6
    St = 0
    La = len(S)
    for i in range(St, len(S)):
        if a >= b:
            break
        if S[i] == K[a]:
            a += 1
            for j in range(La-1, 0, -1):
                if S[j] == K[b]:
                    b -= 1
                    if a == b:
                        print("YES")
                        exit()
    print("NO")
    exit()

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(0,7):
      if keyence[:i] in S and keyence[i:] in S[S.index(keyence[:i])+i:] : # keyenceがある
        if i==0 and S.index(keyence[i:])==0 : # keyenceXXX のとき
            print('YES')
            break
        elif S[S.index(keyence[i:])+(7-i):] == '' :  # keyXXXenceのとき
            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:
            #print ( 'key2 {} S {}'.format ( keyence2[ 6 - i ], S[ len ( S ) - 1 - i ] ) )

            if keyence2[ 6 - i ] != S[ len ( S ) - 1 - i ]:
                b_err=True
            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]:
                a_err=True
            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()
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:
            break

if kn == 7 or S.replace(tmp, ''):
    print('YES')
else:
    a = 0
    b = 6
    St = 0
    La = len(S)
    for i in range(St, len(S)):
        if a >= b:
            break
        if S[i] == K[a]:
            a += 1
            for j in range(La-1, 0, -1):
                if S[j] == K[b]:
                    b -= 1
                    if a + 1 == b:
                        print("YES")
                        exit()
    print("NO")
    exit()

Submission status: Wrong Answer

Solution code:

input_str = input()

str_list = list(input_str)

keyence = list("keyence")

# 各文字が入ってるインデックスを記録する辞書型
str_index_dict = {}
for char in keyence:
    str_index_dict.setdefault(char, [])

for i, char in enumerate(str_list):
    if char in keyence:
        str_index_dict[char].append(i)

can_skip = True  # 文字を飛ばせるのは一回まで
keyence_iter = iter(keyence)

succes = True

position = 0
for char in keyence:
    if str_index_dict[char] == []:
        succes = False
        break
    # if char == "k":
    #     position = min(str_index_dict[char])
    #     str_index_dict[char].remove(position)
    #     position+=1
    # else:
    if position in str_index_dict[char]:
        str_index_dict[char].remove(position)
        position += 1
    else:
        if can_skip == True:
            position = min(str_index_dict[char])
            str_index_dict[char].remove(position)
            position+=1
            can_skip = False
        else:
            succes = False
            break

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

Submission status: Wrong Answer

Solution code:
string = input()
#print(string[1])
if 'k' in string and 'eyence' in string:
  if string.index('k')<string.find('eyence'):
  	print("YES")
elif 'ke' in string and 'yence' in string:
  if string.index('ke')<string.find('yence'):
  	print("YES")  
elif 'key' in string and 'ence' in string:
  if string.index('key')<string.find('ence'):
  	print("YES")
elif 'keye' in string and 'nce' in string:
  if string.index('keye')<string.find('nce'):
  	print("YES")
elif  'keyen' in string and 'ce' in string:
  if string.index('keyen')<string.find('ce'):
  	print("YES")
elif  'keyenc' in string and 'e' in string:
  if string.index('keyenc')<string.find('e'):
  	print("YES")
elif 'keyence' in string:
  	print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
a = input()
k="keyence"
ti = 0
x =[0]*(len(a))
r = 0
if a[0] !=k[0]:r+=1
for i in range(len(a)):
    if ti==7:
        r+=1
        break
    elif a[i] == k[ti]:
        ti +=1
        x[i]=1
    elif i !=0 and 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:
S = str(input())
# 分割のパターンを洗い出す方法
k_str = 'keyence'
patterns = [[k_str[:i], k_str[i:]] for i in range(0, len(k_str))]
for pattern in patterns:
    if pattern[0] in S:
        next_starting_idx = S.index(pattern[0]) + len(pattern[0])
        if pattern[1] in S[next_starting_idx:]:
            print('YES')
            break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
K = "keyence"
i = 0
j = 0
flag = 0
while i < len(S):
  if(j >= 6):
    if(len(S) - i != 1):
      flag = flag + 1
    break
  if(S[i]==K[j]):
    j = j + 1
    i = i + 1
  if(S[i]!=K[j]):
    flag = flag + 1
    while S[i] != K[j]:
      i = i + 1
      if(len(S) - i < 1):
        flag = 2
        break
if flag == 0 or flag == 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(0,7):
      if keyence[:i] in S and keyence[i:] in S[S.index(keyence[:i])+i:] : # keyenceがある
        if i==0 and S.index(keyence[i:])==0 : # keyenceXXX のとき
            print('YES', S.index(keyence[:i]))
            break
        elif S[S.index(keyence[i:])+(7-i):] == '' :  # keyXXXenceのとき
            print('YES')
            break
    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):
        print('YES')
        break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
k_str = 'keyence'
patterns = [[k_str[:i], k_str[i:]] for i in range(0, len(k_str))]
for pattern in patterns:
    print(pattern)

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
j,old = 0,0
for i in bigram_t:
    j = 0
    while len(bigram_x)>old+j:
        if i == bigram_x[old+j]:
            cnt += 1
            old += j
            break
        j += 1
        
print("YES") if cnt >= len(bigram_t)-1 else print("NO")

Submission status: Wrong Answer

Solution code:

P = list(str(input()))

#print(P[0])

N = len(P)

flg = 0

kaisu = 0

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

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

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('eyence')-1
    S.find('k',0,place)
    print("YES")
else : print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
import re
ptn = re.compile(r'k(.*)eyence|ke(.*)yence|key(.*)ence|keye(.*)nce|keyen(.*)ce|keyenc(.*)e|keyence(.*)|(.*)keyence')
m = ptn.search(S)
if(m):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
import re
x = input()

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:
S = input()
import re
ptn = re.compile(r'k(.*)eyence|ke(.*)yence|key(.*)ence|keye(.*)nce|keyen(.*)ce|keyenc(.*)e|keyence')
m = ptn.search(S)
if(m):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
k_str = 'keyence'
patterns = [[k_str[:i], k_str[i:]] for i in range(0, len(k_str))]