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

Solution code:
s = input()
for i in range(0, 8):
    if s[:i] + s[-(7-i):] == "keyence":
        print("YES")
        exit()
print("NO")
#copy code

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


S = SI()

for l in range(len(S)):
    for r in range(l, len(S)):
        tmp = S[:l] + S[r:]
        if tmp == 'keyence':
            print('YES')
            exit()

print('NO')

Submission status: Accepted

Solution code:
S = input()
for i in range(7):
    if S[:i] + S[-7+i:] == 'keyence':
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
import re
i=input()
a=[".*keyence$","k.*eyence$","ke.*yence$","key.*ence$","keye.*nce$","keyen.*ce$","keyenc.*e$","keyence.*$"]
print(["YES","NO"][len([y for y in [re.match(x,i) for x in a] if y is not None])==0])

Submission status: Accepted

Solution code:
S = input()

KEYENCE = 'keyence'
patterns = []
for i in range(len(KEYENCE)):
    patterns.append((KEYENCE[:i:], KEYENCE[i::]))

for stt, end in patterns:
    if S.startswith(stt) and S.endswith(end):
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
def solve():
    k = "keyence"
    s = input()
    for i in range(0, 8):
        if s[:i] + s[i - 7:] == k:
            return "YES"
    return "NO"
print(solve())

Submission status: Accepted

Solution code:
import re

S = input()
key = 'keyence'

pattern = [r"^.*keyence$",
r"^k.*eyence$",
r"^ke.*yence$",
r"^key.*ence$",
r"^keye.*nce$",
r"^keyen.*ce$",
r"^keyenc.*e$",
r"^keyence.*$",]

judge = "NO"

for p in pattern :
    result = re.match(p, S)
    if result :
        judge = "YES"

print(judge)

Submission status: Accepted

Solution code:
import re
 
S = input()
 
R = [
    "^.*keyence$",
    "^k.*eyence$",
    "^ke.*yence$",
    "^key.*ence$",
    "^keye.*nce$",
    "^keyen.*ce$",
    "^keyenc.*e$",
    "^keyence.*$",
]
 
for ri in R:
    if re.match(ri, S):
        print("YES")
        exit(0)
print("NO")

Submission status: Accepted

Solution code:
S = input()
k = "keyence"
 
for i in range(len(k)):
    if (S.startswith(k[:i]) and S.endswith(k[i:])):
        print('YES')
        break
else: 
    print("NO")

Submission status: Accepted

Solution code:
N = input()

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

print(ans)

Submission status: Accepted

Solution code:
S = input()
L = len(S)
Truth = 0

for j in range(0, 8):
	if S[0:j] + S[L- 7 +j:] == "keyence":
		Truth = 1

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

Submission status: Accepted

Solution code:
def B():
    S = list(input())
    N = len(S)
    for i in range(N):
        for j in range(i, N):
            this_s = S[0:i] + S[j:N]
            if this_s == ['k', 'e', 'y', 'e', 'n', 'c', 'e']:
                ans = 1
                break
            else:
                ans = 0
        if ans:
            break
    if ans:
        print("YES")
    else:
        print("NO")
B()

Submission status: Accepted

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)==0 : # keyenceXXX のとき
            print('YES')
            break
        elif i==0 and S.index(keyence)!=0 and len(S)-7 == S.index(keyence) : # XXXkeyence のとき
            print('YES')
            break
        elif i!=0 and S.index(keyence[:i])==0 and S[len(keyence[:i])+(len(S)-7):] == keyence[i:] :  # keyXXXenceのとき
            print('YES')
            break
    else:
        print('NO')

Submission status: Accepted

Solution code:
s = input()
for i in range(0, 8):
    if s[:i] + s[-(7-i):] == "keyence":
        print("YES")
        exit()
print("NO")

Submission status: Accepted

Solution code:
S = input().strip()

T = "keyence"

found = False
if len(S)<len(T):
    print("NO")
else:
        for start in range(len(T)):
            if S.startswith(T[:start]) and S.endswith(T[start:]):
                found = True
                break

        if S.startswith(T):
            found = True

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

Submission status: Accepted

Solution code:
S = input()
l = len(S)
OK = False
if S[0:7]=='keyence':
    OK = True
elif S[l-7:]=='keyence':
    OK = True
elif S[l-6:]=='eyence' and S[0]=='k':
    OK = True
elif S[l-5:]=='yence' and S[:2]=='ke':
    OK = True
elif S[l-4:]=='ence' and S[:3]=='key':
    OK = True
elif S[l-3:]=='nce' and S[:4]=='keye':
    OK = True
elif S[l-2:]=='ce' and S[:5]=='keyen':
    OK = True
elif S[l-1:]=='e' and S[:6]=='keyenc':
    OK = True
else:
    OK = False
print('YES' if OK else 'NO')

Submission status: Accepted

Solution code:
def main() :
	S = input()

	remove_len = len(S)  - 7

	for i in range(len(S) - remove_len) :
		# s = S[i:i+7]
		s = S[0:i] + S[i+remove_len:]
		if (s == "keyence") :
			print("YES")
			return

	print("NO")


main()

Submission status: Accepted

Solution code:
s=input()
key="keyence"

l=len(s)

for i in range(l):
    for j in range(i,l):
        mo = s[:i] + s[j:]
        if mo == key:
            print("YES")
            exit()
print("NO")

Submission status: Accepted

Solution code:
s=input()
if s[0:1]=='k' and s[len(s)-6:len(s)]=='eyence':
  print('YES')
elif s[0:2]=='ke' and s[len(s)-5:len(s)]=='yence':
  print('YES')
elif s[0:3]=='key' and s[len(s)-4:len(s)]=='ence':
  print('YES')
elif s[0:4]=='keye' and s[len(s)-3:len(s)]=='nce':
  print('YES')
elif s[0:5]=='keyen' and s[len(s)-2:len(s)]=='ce':
  print('YES')
elif s[0:6]=='keyenc' and s[len(s)-1:len(s)]=='e':
  print('YES')
else:
  print('NO')

Submission status: Accepted

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

for i in range(len(K)):
    if S[:i]+S[i+len(S)-len(K):]==K:
        flag=True

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

Submission status: Accepted

Solution code:
import re

S = input()

R = [
    "^.*keyence$",
    "^k.*eyence$",
    "^ke.*yence$",
    "^key.*ence$",
    "^keye.*nce$",
    "^keyen.*ce$",
    "^keyenc.*e$",
    "^keyence.*$",
]

for ri in R:
    if re.match(ri, S):
        print("YES")
        exit(0)
print("NO")

Submission status: Accepted

Solution code:
import re
s=input()
if re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s):
    print("YES")
else:print("NO")

Submission status: Accepted

Solution code:
import re
s=input()
if re.match(".*keyence$",s) or re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s):
    print("YES")
else:print("NO")

Submission status: Accepted

Solution code:
s = input()
N = len(s)

bl = False
for i in range(N):
    for j in range(i, N):
        t = s[:i] + s[j:]
        if t == 'keyence':
            bl = True
            break

print('YES' if bl else 'NO')

Submission status: Accepted

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.rfind(r2)
  
  if r1i<0 or r2i<0:
    continue
  elif r1i==0:
    if r2i==len(s)-len(r2):
      res=True
if s.find(r)>=0 and s.find(r)==len(s)-len(r):
  res=True
if s.find(r)==0:
  res=True
    
  
if res:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
S = input()
k = "keyence"

res = False

if S[0:7] == k:
    res = True
elif S[-7:0] == k:
    res = True
    
for i in range(1,7):
    if S[0:i] == k[0:i] and S[i-7:] == k[i-7:]:
        res = True
        
if res:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input()

for i in range(len(s)):
    for j in range(i, len(s)):
        if s[:i] + s[j:] == "keyence":
            print("YES")
            exit()
print("NO")

Submission status: Accepted

Solution code:
s=input()
t="keyence"

if t in s:
  if s.find(t)==0 or s.find(t)==len(s)-7:
    print("YES")
  else:
    print("NO")
else:
  for i in range(1,7):
    a,b=t[:i],t[i:]
    if a in s and b in s:
      if s.find(a)==0 and s.rfind(b)==len(s)-len(b):
        print("YES")
        break
  else:
    print("NO")

Submission status: Accepted

Solution code:
S = input()

ans = False

if S[:7] == "keyence":
    ans = True

if S.find("k") != -1:
    if S.find("keyenc")== 0and S[-1] == "e":
        ans = True
    if S.find("keyen")== 0 and S[-2:] == "ce":
        ans = True
    if S.find("keye")== 0 and S[-3:] == "nce":
        ans = True
    if S.find("key")== 0and S[-4:] == "ence":
        ans = True
    if S.find("ke")== 0 and S[-5:] == "yence":
        ans = True
    if S.find("k")== 0 and S[-6:] == "eyence":
        ans = True

else:
    if S[-7:] == "keyence":
        ans = True

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

Submission status: Accepted

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:
    # print(i,index,end='=>')
    if isCut==1: # 切られたあと
        if index>6: # 7=len(ans)
            if canRestart:
                canRestart=0
                isCut=-1
                i=restartI
                index=restartIndex
            else:
                break
        else:
            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)|(i<lenS)|(isCut==-1): # 7=len(ans)
    print('NO')
else:
    print('YES')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

keyence = "keyence"

isKey = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            isKey = True
            break
    if isKey:
        break

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)

for i in range(n):
  for j in range(i,n):
    tmp = s[:i]+s[j:]
    if tmp == 'keyence':
      print('YES')
      exit()
print('NO')

Submission status: Accepted

Solution code:
S = input()

ans = False

if S[:7] == "keyence":
    ans = True

if S.find("k") != -1:
    if S.find("keyenc") == 0 and S[-1] == "e":
        ans = True
    if S.find("keyen") == 0 and S[-2:] == "ce":
        ans = True
    if S.find("keye") == 0 and S[-3:] == "nce":
        ans = True
    if S.find("key") == 0 and S[-4:] == "ence":
        ans = True
    if S.find("ke") == 0 and S[-5:] == "yence":
        ans = True
    if S.find("k") == 0 and S[-6:] == "eyence":
        ans = True
    if S[-7:] == "keyence":
        ans = True
if ans:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input()

for i in range(7, -1, -1):
    j = -(7 - i)
    if s[:i]+s[j:] == "keyence":
        print("YES")
        exit()
print("NO")

Submission status: Accepted

Solution code:
def main():
    S = input()
 
    key = "keyence"
 
    for i in range(len(key)):
        #print(key[:i], key[i:])
        if (S.startswith(key[:i]) and S.endswith(key[i:])):
            return True
    return False
if (main()):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s=input()
n = len(s)

for i in range(n): #文字列の長さ分繰り返す
    for j in range(i,n): #
        tmp = s[:i]+s[j:]
        if tmp == "keyence":
            print("YES")
            quit()

print("NO")

Submission status: Accepted

Solution code:
S = input()
length = len(S)

for i in range(length):
    for j in range(i, length):
        if S[:i] + S[j:] == "keyence":
            print("YES")
            exit(0)
print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

p = input()
a = 'keyence'

if p[:7] == a or p[:6] + p[-1:] == a or p[:5] + p[-2:] == a or p[:4] + p[-3:] == a or p[:3] + p[-4:] == a or p[:2] + p[-5:] == a or p[0] + p[-6:] == a or p[-7:] == a:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
s = input()
n = len(s)

for i in range(n):
    for j in range(i, n):
        tmp = s[:i]+s[j:]
        if tmp == "keyence":
            print("YES")
            quit()

print("NO")

Submission status: Accepted

Solution code:
S = input()

def is_keyence(S):
    key = "keyence"
    for i in range(len(key)):
        #print(key[:i], key[i:])
        if (S.startswith(key[:i]) and S.endswith(key[i:])):
            return True
    return False


if is_keyence(S):
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

keylist = []
for i in range(1, len(keyence)):
    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: Accepted

Solution code:
s=input()
n=0
if(s[0]=='k'or s[len(s)-7]=='k'):
  n+=1
if(s[1]=='e'or s[len(s)-6]=='e'):
  n+=1
if(s[2]=='y'or s[len(s)-5]=='y'):
  n+=1
if(s[3]=='e'or s[len(s)-4]=='e'):
  n+=1
if(s[4]=='n'or s[len(s)-3]=='n'):
  n+=1
if(s[5]=='c'or s[len(s)-2]=='c'):
  n+=1
if(s[6]=='e'or s[len(s)-1]=='e'):
  n+=1
if(n==7):
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
def main():
    S = input()

    key = "keyence"

    for i in range(len(key)):
        #print(key[:i], key[i:])
        if (S.startswith(key[:i]) and S.endswith(key[i:])):
            return True
    return False
if (main()):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input()
n = len(s)

for i in range(n):
    for j in range(i, n):
        tmp = s[0:i]+s[j:]
        if tmp == "keyence":
            print("YES")
            quit()

print("NO")

Submission status: Accepted

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")
                #mod_S = S[:first_diff_i] + S[end_diff_i+1:]
                last_char = mod_S[0]
                mod_S2 = last_char
                for char in mod_S[1:]:
                    if last_char != char:
                        mod_S2 += char
                    last_char = char
                
                if mod_S2 == key_s:
                    return True

                return False
    else:
        #print("NO")
        return False

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

#res = res1 and  res2
res = res1

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

Submission status: Accepted

Solution code:
import re
x = input()

answer = "NO"

if len(re.findall(".*keyence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^k.*eyence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^ke.*yence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^key.*ence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keye.*nce$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keyen.*ce$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keyenc.*e$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keyence.*", x)) > 0 :
    answer = "YES"

print(answer)

Submission status: Accepted

Solution code:
import re

S=input()

if re.match("keyence",S) or re.match("^(.*)(keyence)$",S) or re.match("^k(.*)(eyence)$",S) or re.match("^(ke)(.*)(yence)$",S) or re.match("^(key)(.*)(ence)$",S) or re.match("^(keye)(.*)(nce)$",S) or re.match("^(keyen)(.*)(ce)$",S) or re.match("^(keyenc)(.*)(e)$",S)  or re.match("^(keyence)(.*)$",S):
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

for i, string in enumerate(s):
    if s[:7] == list("keyence"):
        print("YES")
        sys.exit()

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

print("NO")

Submission status: Accepted

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
            if not b_err:
                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
            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: Accepted

Solution code:
a = "keyence"

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
text = input()
i = 0
ans = "keyence"
for ob_n in range(len(ans)):
    if text[i] != ans[ob_n]:
        if text.endswith(ans[ob_n:]):
            flag = 1
            break
        else:
            flag = 0
            break
    i+=1
    if i == len(text):
        flag = 1
        break
if flag == 1:
    print("YES")
else :
    print("NO")

Submission status: Accepted

Solution code:
s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
c=0
if len(s)>=7:
    while c<7:
        if s[c]!=k[c]:
            break
        c+=1
    if c==7:
        ans="YES"
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)

Submission status: Accepted

Solution code:
S=input()
N=len(S)
for i in range(0,N+1):
    for j in range(i,N+1):
        if  S[:i] + S[j:] == 'keyence':
            print("YES")
            exit(0)
else:
    print('NO')

Submission status: Accepted

Solution code:
S = input()
T = "keyence"

result = "NO"

for n in range(1, 7):
    m = 7 - n
    if S[:n] == T[:n] and S[-m:] == T[-m:]:
        result = "YES"
        break

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

re = 'NO'
for i in range(1,7):
    bef = key[0:i]
    aft = key[i:]
    b_index = S.find(bef)
    a_index = S.rfind(aft)
    if b_index == 0 and a_index + len(aft) == len(S) : # 真ん中を抜けばいい場合
        re = 'YES'
        break
    elif (b_index == 0 or a_index + len(aft) == len(S)) and b_index + len(bef) == a_index: # 前後どちらかを抜く場合
        re = 'YES'
        break

print(re)

Submission status: Accepted

Solution code:
S = input()

keyence = 'keyence'

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

Submission status: Accepted

Solution code:
num_list = input()
key = 'keyence'
i = 0
l = len(num_list)

n = 0

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

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

Submission status: Accepted

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

if s == a:
    print('YES')
    flag = 0

for i in range(1,len(s)-6):
    #iは取り除く文字列の長さ
    for j in range(len(s)-i+1):
        if s[0:j]+s[j+i:] == a:
            print('YES')
            flag = 0
            break

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

Submission status: Accepted

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()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
for i in range(1,len(x)):
  a=x[:i]
  b=x[i:]
  if s.count(a)>0 and (s.index(a)==0 and s[len(s)-len(b):]==b):
    print('YES')
    exit()
  else:
    continue
print('NO')

Submission status: Accepted

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):
    ans = True
print "YES" if ans or S == keyence else "NO"

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import re
str_in_org = input()
KEYENCE = 'keyence'
flag = False
for n in range(1,7):
    str_in = str_in_org
    len_in = len(str_in)
    len_tail = len_in - (7 - n)
    str_div1 = str_in[:n]
    str_div2 = str_in[len_tail:]
    key_div1 = KEYENCE[:n]    
    key_div2 = KEYENCE[n:]
    
    if( str_div1 == key_div1 and str_div2 == key_div2 ):
        if( str_div1 + str_div2 == KEYENCE ):
            flag = True
if flag == True :
    print ('YES')
else:
    print ('NO')

Submission status: Accepted

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)):
    result = re.match(patterns[i], input_string)
    if result:
        flag = True
        break
if flag == True:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input()
l = (['', 'keyence'], ['k', 'eyence'], ['ke', 'yence'], ['key', 'ence'],
     ['keye', 'nce'], ['keyen', 'ce'], ['keyenc', 'e'], ['keyence', ''])
for a in l:
    p, q = a[0], a[1]
    if s.startswith(p) and s.endswith(q):
        exit(print('YES'))
print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = raw_input()
if S.startswith('k') and S.endswith('eyence'):
    print('YES')
elif S.startswith('ke') and S.endswith('yence'):
    print('YES')
elif S.startswith('key') and S.endswith('ence'):
    print('YES')
elif S.startswith('keye') and S.endswith('nce'):
    print('YES')
elif S.startswith('keyen') and S.endswith('ce'):
    print('YES')
elif S.startswith('keyenc') and S.endswith('e'):
    print('YES')
elif S == 'keyence':
    print('YES')
else:
    print('NO')

Submission status: Accepted

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]:
            cnt = i
            break
    ans = 0
    if S[:7:] == keyence:
        ans = 1
    elif S[len(S) - 7::] == keyence:
        ans = 1
    elif S[len(S) - (7 - cnt)::] == keyence[cnt::]:
        ans = 1
    else:
        ans = -1
    if ans == 1:
        print("YES")
    else:
        print("NO")
    #print(cnt, S[len(S) - (7 - cnt)::], keyence[cnt::])
A()

Submission status: Accepted

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

# Input
s = input()

# Init
key_str = "keyence"
ans = "NO"
search_idx = 0

# Search
if s[0] == key_str[0]:
    # Pattern 2 or 3
    for idx in range(len(s)):
        if s[idx] == key_str[search_idx]:
            search_idx += 1
            if search_idx == len(key_str):
                # Pattern 3
                ans = "YES"
                break

        else:
            # Pattern 2
            for idx2 in range(len(s) - len(key_str) + search_idx, len(s)):
                if s[idx2] == key_str[search_idx]:
                    search_idx += 1
                    if search_idx == len(key_str):
                       ans = "YES"
            break
else:
    # Pattern 1
    for idx in range(len(s) - len(key_str), len(s)):
        if s[idx] == key_str[search_idx]:
            search_idx += 1
            if search_idx == len(key_str):
                ans = "YES"
                break

# Output
print(ans)

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
i = 0
if 'k' in s and 'eyence' in s:
    if s[:1] =='k' and s[n-6:] == 'eyence':
        print('YES')
        exit()
if 'ke' in s and 'yence' in s:
    if s[:2] =='ke' and s[n-5:] == 'yence':
        print('YES')
        exit()
if 'key' in s and 'ence' in s:
    if s[:3] =='key' and s[n-4:] == 'ence':
        print('YES')
        exit()
if 'keye' in s and 'nce' in s:
    if s[:4] =='keye' and s[n-3:] == 'nce':
        print('YES')
        exit()
if 'keyen' in s and 'ce' in s:
    if s[:5] =='keyen' and s[n-2:] == 'ce':
        print('YES')
        exit()
if 'keyenc' in s and 'e' in s:
    if s[:6] =='keyenc' and s[n-1:] == 'e':
        print('YES')
        exit()
if 'keyence' in s:
    if s[:7] == 'keyence' or s[n-7:] == 'keyence':
        print('YES')
        exit()
print('NO')