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()
keyence = "keyence"
answer = 'NO'
if keyence in S:
    if S[:7] == keyence:
         answer = "YES"
    elif S[-7:] == keyence:
        answer = "YES"
else:
    for i in range(6):
        if (S[:i+1] == keyence[:i+1]) & (S[-6+i:] == keyence[-6+i:]):
            answer = "YES"
print(answer)

Submission status: Accepted

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

flg = False
for i in range(len(s) - 6):
    for j in range(len(s)):
        if s[:j] + s[j + i:] == S:
            flg = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
f = False
if S[:7] == 'keyence':
    f = True
if S[-7:] == 'keyence':
    f = True

for i in range(len(S)):
    s1 = S[:i]
    s2 = S[i:]
    if 'k' in s1 and 'eyence' in s2:
        if s1[0] == 'k':
            if s2[-6:] == 'eyence':
                f = True
                break
    if 'ke' in s1 and 'yence' in s2:
        if s1[:2] == 'ke':
            if s2[-5:] == 'yence':
                f = True
                break
    if 'key' in s1 and 'ence' in s2:
        if s1[:3] == 'key':
            if s2[-4:] == 'ence':
                f = True
                break
    if 'keye' in s1 and 'nce' in s2:
        if s1[:4] == 'keye':
            if s2[-3:] == 'nce':
                f = True
                break
    if 'keyen' in s1 and 'ce' in s2:
        if s1[:5] == 'keyen':
            if s2[-2:] == 'ce':
                f = True
                break
    if 'keyenc' in s1 and 'e' in s2:
        if s1[:6] == 'keyenc':
            if s2[-1] == 'e':
                f = True
                break
if f:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
def keyence(s):
    # keyence
    if s.count('keyence'):
        if s[:7] == 'keyence' or s[-7:] == 'keyence':
            return('YES')

    # k eyence or keyenc e
    elif s.count('eyence'):
        if s[:1] == 'k' and s[-6:] == 'eyence':
            return('YES')

    elif s.count('keyenc'):
        if s[:6] == 'keyenc' and s[-1:] == 'e':
            return('YES')

    # ke yence or keyen ce
    elif s.count('yence'):
        if s[:2] == 'ke' and s[-5:] == 'yence':
            return('YES')

    elif s.count('keyen'):
        if s[:5] == 'keyen' and s[-2:] == 'ce':
            return('YES')

    # key ence or keye nce
    elif s.count('ence'):
        if s[:3] == 'key' and s[-4:] == 'ence':
            return('YES')

    elif s.count('keye'):
        if s[:4] == 'keye' and s[-3:] == 'nce':
            return('YES')

    return('NO')

print(keyence(input()))

Submission status: Accepted

Solution code:
s = input()
key = "keyence"
ans = "NO"
for i in range(len(key)+1):
    if s.startswith(key[:(len(key))-i]):
        if s.endswith(key[-i:]):
            ans = "YES"
if s.startswith("keyence") or s.endswith("keyence"):
    ans = "YES"
print(ans)

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()
key='keyence'
ans='NO'
for i in range(len(key)):
    key1=key[:i]
    key2=key[i:]
    A=key1+'0'*(len(S)-len(key))+key2
    if all([S[l]==A[l] or A[l]=='0' for l in range(len(S))]):
        ans='YES'
print(ans)

Submission status: Accepted

Solution code:
S = input()

keyword = 'keyence'
if (S[:7] == keyword) or (S[-7:] == keyword):
    print('YES')
    exit()

f, b = 0, 0
# forward
for i, (key, s) in enumerate(zip(keyword, S)):
    if key != s:
        f = i
        break
    else:
        # keyword = keyword[1:]
        pass
# print(keyword)
# backward
for i, (key, s) in enumerate(zip(keyword[::-1], S[::-1])):
    # print(key, s)
    if key != s:
        b = i
        break
    else:
        keyword = keyword[1:]

# print(f, b)
if f + b > 6:
    print('YES')
else:
    print("NO")

Submission status: Accepted

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

a="keyence"
cnt=0
i=0
j=0
ans=""
if l<7:
  ans="NO"
elif s==a:
  ans="YES"
else:
  while(i<l):
    if s[i]==a[j]:
      cnt+=1
      i+=1
      j+=1
      
    else:
      i+=l-7
  if cnt==7:
    ans="YES"
  else:
    ans="NO"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
if S[0:7] == "keyence":
    print("YES")
elif S[len(S)-7:len(S)] == "keyence":
    print("YES")
else:
    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()
import re
ans=[]
ans.append(re.match(".*keyence$",s))
ans.append(re.match("^k.*eyence$",s))
ans.append(re.match("^ke.*yence$",s))
ans.append(re.match("^key.*ence$",s))
ans.append(re.match("^keye.*nce$",s))
ans.append(re.match("^keyen.*ce$",s))
ans.append(re.match("^keyenc.*e$",s))
ans.append(re.match("^keyence.*",s))
c = sum(x!=None for x in ans)
if c > 0:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
import copy

S = list(input())
ja = 0

sremove = ""
S_tmp = []

for i in range(len(S)):
    for j in range(i,len(S)+1):
        S_tmp = copy.deepcopy(S)

        del S_tmp[i:j]

        if "".join(S_tmp) == "keyence":
            ja = 1
            break

if ja == 1:
    print("YES")

else:
    print("NO")

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    S = input()

    l = len(S)
    ans = 'NO'
    for i in range(7, -1, -1):
        j = l - (7 - i)
        if S[:i] + S[j:] == 'keyence':
            ans = 'YES'
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Submission status: Accepted

Solution code:
s = input()

key = 'keyence'
yes = False

if key in s:
    idx = s.index('key')
    if idx == 0:
        yes = True
    elif len(s) - idx == 7:
        yes = True
else:
    for i in range(1,8):
        pre = key[:i]
        post = key[i:]
        #print(pre, post)
        if pre == s[:len(pre)]:
            #print('end', s[len(s)-(7-i):])
            if s[len(s)-(7-i):] == post:
                yes = True
                break
        
if yes == True:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
K = "keyence"

S = raw_input()
N = len(S)
M = N - 7

if M == 0:
    print "YES" if S == K else "NO"
    exit()

for i in xrange(N):
    S1 = S[:i]
    S2 = S[i+M:]
    T = S1 + S2
    if T == K:
        print "YES"
        exit()

print "NO"

Submission status: Accepted

Solution code:
wlist=[ i for i in input()]
klist=["k","e","y","e","n","c","e"]
a=[]
for i in range(len(wlist)-1):
    for j in range(i+1,len(wlist)):
        if wlist[0:i+1]+wlist[j:]==klist:
                a.append(1)
        else:
                a.append(0)
                
if 1 in a:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

for i in range(8):
  if i == 0:
    key = s[len(s)-7:]
    if key == "keyence":
      break
  if 0 < i < 7:
    key = s[:i] + s[len(s) - 7 + i:]
    if key == "keyence":
      break
  if i == 7:
    key = s[:7]
    if key == "keyence":
      break

if key == "keyence":
  print("YES")
else:
  print("NO")

Submission status: Accepted

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

if(len(S) == 7 and ans==S):
    print('YES')
else:
    for i in range(7):
        if(S[i] == ans[i]):
            flag = True
        elif S[len(S)-7+i::] == ans[i::]:
            flag = True
            break
        else:
            flag = False
            break

    if(~flag):
        ans = ans[::-1]
        S = S[::-1]
        for i in range(7):
            if(S[i] == ans[i]):
                flag = True
            elif S[len(S)-7+i::] == ans[i::]:
                flag = True
                break
            else:
                flag = False
                break

    

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

Submission status: Accepted

Solution code:
def read():
    S = input().strip()
    return S,


def solve(S):
    key = "keyence"

    for i in range(len(key)):
        head = S[:i]
        tail = S[len(S) - len(key) + i:]
        if head == key[:i] and tail == key[i:]:
            return True
    return False


if __name__ == '__main__':
    inputs = read()
    print("YES" if solve(*inputs) else "NO")

Submission status: Accepted

Solution code:
s = input()
key = "keyence"
if s[:7] == key:
    print("YES")
    exit()
elif s[-6:] == key:
    print("YES")
    exit()
else:
    for i in range(7):
        if s[:i] == key[:i] and s[-7+i:] == key[-7+i:]:
            print("YES")
            exit()
print("NO")

Submission status: Accepted

Solution code:
s = input()

word = "keyence"

for i in range(len(word)):
    a = s.find(word[:i])
    b = s.rfind(word[i:])
    if((a == 0 and b == 0) or (a == 0 and b == len(s)-len(word[i:]))):
        print("YES")
        exit()

print("NO")

Submission status: Accepted

Solution code:
s = input()
st = ""
ma = "keyence"
l = []

if s[0:7] == ma or s[-7:] == ma:
    print("YES")
else:
    for i in range(len(ma)):
        if s[0:i] + s[-7+i:] == ma:
            print("YES")
            exit()
    else:
        print("NO")

Submission status: Accepted

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

T = "keyence"

if S.startswith(T) or S.endswith(T):
    print("YES")
    exit()

count = 0
j = 0
is_last = False
for i in range(0,len(S)):
    if j >= len(T):
        print("NO")
        exit()
    if T[j] == S[i]:
        j += 1
        continue
    elif T[j] != S[i]:
        print("YES" if S.endswith(T[j:]) else "NO")
        exit()

if j == len(T):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
S=input()
print("YES" if sum([1 if S[:i] == "keyence"[:i] and S[i - 6:] == "keyence"[i - 6:] else 0 for i in range(1, 7)] + [1 if S[:7] == "keyence" or S[-7:] == "keyence" else 0]) > 0 else "NO")

Submission status: Accepted

Solution code:
S = "keyence"
line = input()
cnt = 0
for i in range(6):
    string = ""
    if(line.rfind(S[i+1:]) > line.find(S[0:i+1])>= 0): string += line[:line.find(S[0:i+1])+(i+1)] + line[line.rfind(S[i+1:]):]
    #print(line.find("keyenc"), string)
    if(string == S): cnt += 1
if(cnt>0): print("YES")
else: print("NO")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10000)
import re

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

# N = [int(x) for x in input().split()]

S = input()

K = "keyence"

s_idx = 0
k_idx = 0
skip = False

if S == K:
    print("YES")
    sys.exit(0)


while (S[s_idx] == K[k_idx]):
    s_idx += 1
    k_idx += 1

# s_idx -= 1
# k_idx -= 1

rs_idx = 1
rk_idx = 1
while (S[-rs_idx] == K[-rk_idx]):
    rs_idx += 1
    rk_idx += 1

    s1 = S[0:s_idx]
    s2 = S[-(rs_idx-1):]
    if s1+s2 == K:
        print("YES")
        sys.exit(0)


print("NO")

# print(S[0:s_idx])
# print(S[rs_idx:])

Submission status: Accepted

Solution code:
S = input()

n_len = len(S)
is_keyence = False

for i in range(n_len):
    for j in range(i, n_len):
        if S[:i] + S[j:] == 'keyence':
            is_keyence = True
    if is_keyence: break
        
print('YES' if is_keyence else 'NO')

Submission status: Accepted

Solution code:
l = raw_input()
flag = False
if len(l) >= 6:
    for i in range(7):
        tmp = l[0:i] + l[-7+i:]
        if tmp == "keyence":
            flag = True
if flag == True:
    print "YES"
else:
    print "NO"

Submission status: Accepted

Solution code:
import sys
import re
r = "keyence"
c1=re.compile("^.+?keyence$")
c2=re.compile("^k.+?eyence$")
c3=re.compile("^ke.+?yence$")
c4=re.compile("^key.+?ence$")
c5=re.compile("^keye.+?nce$")
c6=re.compile("^keyen.+?ce$")
c7=re.compile("^keyenc.+?e$")
c8=re.compile("^keyence.+?$")

for line in sys.stdin.readlines():
    target = line.strip()
    if len(target) == 7:
        if target == r:
            print("YES")
        else:
            print("NO")
    else:
        if re.search(c1, target) is not None or re.search(c2, target) is not None or re.search(c3, target) is not None or re.search(c4, target) is not None or re.search(c5, target) is not None or re.search(c6, target) is not None or re.search(c7, target) is not None or re.search(c8, target) is not None:
            print("YES")
        else:
            print("NO")

Submission status: Accepted

Solution code:
thisinput=str(input())
lengthofdelete=len(thisinput)-7
key="keyence"
if lengthofdelete==0:
    if thisinput==key:
        print("YES")
    else:
        print("NO")
else:
    #code
    for x in range(8):
        newstr = thisinput[:x] + thisinput[x+lengthofdelete:]
        if newstr==key:
            print("YES")
            break
        else:
            if x==7:
                print("NO")
            else:
                continue

Submission status: Accepted

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

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

for i in range(len(keyence) + 1):
    head, tail = keyence[:i], keyence[-(len(keyence) - i):]
    s_head, s_tail = s[:i], s[-(len(keyence) - i):]
    if head == s_head and tail == s_tail:
        print('YES')
        exit(0)

#print('YES')
print('NO')

Submission status: Accepted

Solution code:
S = list(str(input()))
KEY = ["k","e","y","e","n","c","e"]
num = 0
endY = False
endN = False
cnt = 0
for i in range(len(S)):
	cnt += 1
	if(num == 6):
		print("YES")
		break
	elif(endY == True):
		print("YES")
		break
	elif(endN == True):
		print("NO")
		break
	elif(len(S)<7):
		print("NO")
		break		
	elif(len(S)==7 and S[0]!="k"):
		print("NO")
		break

	elif(S[i]==KEY[num]):
		num += 1

	elif(num>=0 and S[i]!=KEY[num]):
		num2 = 0
		for j in range(len(S)):
			if(num+num2 == 7):
				endY = True
				break
			
			elif((num+num2 <7) and S[len(S)-(j+1)] == KEY[7-(j+1)]):
				num2 += 1
			
			else:
				endN = True
				break

Submission status: Accepted

Solution code:
"""
B - KEYENCE String
"""
#入力処理
def simple_input():
    temp_input = input().rstrip().split(' ')
    if len(temp_input) > 1:
        return temp_input
    return temp_input[0]

#メイン処理
if __name__ == '__main__':
    #入力
    s = input()
    keyence = "keyence"

    result = "NO"
    
    matchcount = 0
    for i in range(7):
        si = s[i]
        ki = keyence[i]
        if(si == ki):
            matchcount = matchcount + 1
        else:
            break

    for i in range(7):
        i2 = i * -1 - 1
        si = s[i2]
        ki = keyence[i2]
        if(si == ki):
            matchcount = matchcount + 1
        else:
            break

    if(matchcount >= 7):
        result = "YES"
    
    #出力
    print(result)

Submission status: Accepted

Solution code:
S = input()
ans = False
for first_idx in range(len(S)):
    for last_idx in range(first_idx, len(S)):
        if("keyence" == S[:first_idx] + S[last_idx:]):
            ans = True
            break

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

Submission status: Accepted

Solution code:
import re
if re.compile(r'(\A.*keyence\Z|\Ak.*eyence\Z|\Ake.*yence\Z|\Akey.*ence\Z|\Akeye.*nce\Z|\Akeyen.*ce\Z|\Akeyenc.*e\Z|\Akeyence.*\Z)').search(input()):
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
S = input()
answer = "keyence"
a = 0

for s in S:
    if s == answer[a]:
        a += 1
        if a == len(answer):
            print("YES")
            break
    else:
        tmp = len(answer)-a
        if S[-tmp:] == answer[a:]:
            print("YES")
        else:
            print("NO")
        break

Submission status: Accepted

Solution code:

s = input()

f = "keyence"
h = 0
n = len(s)
for i in range(8):

    first = f[:i+1]
    second = f[i+1:]
    check = len(first)
    find1 = s.find(first)
    find2 = s.find(second,n-len(second))

    if i!=7:
        if find1!=0:
            continue

        if find2==-1:
            continue

        if find2+len(second)!=n:
            continue

        else:
            print("YES")
            h = 1
            break

    else:
        if find1 == 0 or find1+len(first) == n :
            print("YES") 
            h = 1
            break



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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

S = input()
t = "keyence"

# full matching
idx = S.find(t)
if idx == 0 or idx == len(S)-7:
    print("YES")
    sys.exit()

# partial matching
for idx in range(6):
    if S.find(t[0:6-idx]) == 0 and S.endswith(t[7-idx-1:7], len(S) - 1 -idx, len(S)):
        print("YES")
        sys.exit()
        
print("NO")

Submission status: Accepted

Solution code:
import sys
ans = False
ans_str = {True:'YES', False:'NO'}
# 7 chars
target = 'keyence'

input_str = input()
input_len = len(input_str)
if target in input_str:
    if input_str.index(target) == 0:
        print('YES')
    elif input_str.index(target) == -7:
        print('YES')
    else:
        print('NO')
    sys.exit()
else:
    for i in range(6):
        if input_str.find(target[:(i+1)]) == 0 and input_str[-(6-i):] == target[(i+1):]:
            print('YES')
            sys.exit()
    print('NO')
    sys.exit()

Submission status: Accepted

Solution code:
S = input()
N = len(S)
if S[0:7] == 'keyence':
  print('YES')
  exit()
if S[-7:] == 'keyence':
  print('YES')
  exit()
for i in range(6):
  X = S[0:i+1]
  Y = S[-6+i:]
  if X + Y == 'keyence':
    print('YES')
    exit()
print('NO')

Submission status: Accepted

Solution code:
import re
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


S = ii(str).lower()
if S == "keyence":
    print("YES")
    exit()
if (
    re.sub("k[a-z]*eyence", "", S)
    and re.sub("ke[a-z]*yence", "", S)
    and re.sub("key[a-z]*ence", "", S)
    and re.sub("keye[a-z]*nce", "", S)
    and re.sub("keyen[a-z]*ce", "", S)
    and re.sub("keyenc[a-z]*e", "", S)
    and re.sub("keyence[a-z]*", "", S)
):
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:

a = list(input().rstrip())


count = 0

for i in range(len(a)):
    if a[i] == 'k':
        count = count + 1
        a[i] = '-'
        if a[i+1] == 'e':
            count = count + 1
            a[i] = '-'
            if a[i+2] == 'y':
                count = count + 1
                a[i] = '-'
                if a[i+3] == 'e':
                    count = count + 1
                    a[i] = '-'
                    if a[i+4] == 'n':
                        count = count + 1
                        a[i] = '-'
                        if a[i+5] == 'c':
                            count = count + 1
                            a[i] = '-'
                            if a[i+5] == 'e':
                                count = count + 1
                                a[i] = '-'
                            else:
                                break
                        else:
                            break    
                    else:
                        break
                else:
                    break
            else:
                break    
        else:
            break   
    else:
        continue

a.reverse()

for j in range(len(a)):
    if a[i] == 'e':
        count = count + 1
        a[i] = '-'
        if a[i+1] == 'c':
            count = count + 1
            a[i] = '-'
            if a[i+2] == 'n':
                count = count + 1
                a[i] = '-'
                if a[i+3] == 'e':
                    count = count + 1
                    a[i] = '-'
                    if a[i+4] == 'y':
                        count = count + 1
                        a[i] = '-'
                        if a[i+5] == 'e':
                            count = count + 1
                            a[i] = '-'
                            if a[i+5] == 'k':
                                count = count + 1
                                a[i] = '-'
                            else:
                                break
                        else:
                            break    
                    else:
                        break
                else:
                    break
            else:
                break    
        else:
            break   
    else:
        continue

if count >= 7 and (i == 0 and j == 0):
    print('YES')
elif 'keyence' in a and (i == 0 or j == 0):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
S = input()
str = "keyence"
frag = False

for a in range(0,len(S)):
  if (S[0:a] + S[a - 7:]) == str:
    frag = True

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

Submission status: Accepted

Solution code:
s = input()

ans = 'keyence'
ret = 'NO'
if s[:7] == ans:
    ret = 'YES'
elif s[-7:] == ans:
    ret = 'YES'
else:
    for i in range(7):
        j = 7-i
        if s[:i] == ans[:i] and s[-j:] == ans[-j:]:
            ret = 'YES'
print(ret)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()

if s.startswith("keyence") or s.endswith("keyence"):
    print("YES")
    exit()

c = 0
for s1, k1 in zip(s, "keyence"):
    if s1 == k1:
        c += 1
    else:
        break

for s1, k1 in zip(s[::-1], "keyence"[::-1]):
    if s1 == k1:
        c += 1
    else:
        break

if c >= 7:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
ans = "keyence"

s = input()
flag=0
if ans in s:
  flag=1
  print("YES")
else:
  for i in range(1,len(ans)):
    if s[:i] == ans[:i] and s[i-len(ans):] == ans[i-len(ans):]:
      flag=1
      print("YES")
      break
if flag==0:
  print("NO")

Submission status: Accepted

Solution code:
a = input()
word = "keyence"
if a[:7] == word or a[-7:]==word:
    print("YES")
elif (a[0]=="k" and a[-6:]=="eyence") or \
        (a[:2]=="ke" and a[-5:]=="yence") or \
        (a[:3]=="key" and a[-4:]=="ence") or \
        (a[:4]=="keye" and a[-3:]=="nce") or \
        (a[:5]=="keyen" and a[-2:]=="ce") or \
        (a[:6]=="keyenc" and a[-1]=="e"):
        print("YES")

else:
    print("NO")

Submission status: Accepted

Solution code:
s = str(input())
word = 'keyence'

ans = 'NO'
if s.startswith('keyence'):
    ans = 'YES'
elif s.endswith('keyence'):
    ans = 'YES'
else:
    for i in range(7):
        if s.startswith(word[:i]):
            postword = word[i:]
            if s.endswith(postword):
                ans = 'YES'
            else:
                 continue

print(ans)

Submission status: Accepted

Solution code:
s = input()
key = 'keyence'
if len(s) < len(key):
    print("NO")
elif s[:len(key)] == key:
    print("YES")
elif s[-len(key):] == key:
    print("YES")
else:
    for i in range(1, len(key)):
        head = s.startswith(key[0:i])
        hip = s.endswith(key[i:])
        if head and hip:
            print("YES")
            break
    else:
        print("NO")

Submission status: Accepted

Solution code:
S = input()


def judge():
    L = len(S)
    keyence = 'keyence'
    if S[0] != 'k':
        if S[-7:] != 'keyence':
            return False
        else:
            return True
    else:
        for i in range(8):
            if S[0:i] == keyence[0:i] and S[L-(7-i):L] == keyence[i:7]:
                return True
        return False


def main():
    if judge():
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
for i in range(len(s)):
    for j in range(i, len(s)):
        if 'keyence' == '{}{}'.format(s[0:i+1], s[j:len(s)+1]):
            print('YES')
            quit()
print('NO')

Submission status: Accepted

Solution code:
import fnmatch
S=[]
S.append(input())
if S == fnmatch.filter(S, "*keyence") or S == fnmatch.filter(S, "k*eyence") or S == fnmatch.filter(S, "ke*yence") or S == fnmatch.filter(S, "key*ence") or S == fnmatch.filter(S, "keye*nce") or S == fnmatch.filter(S, "keyen*ce") or S == fnmatch.filter(S, "keyenc*e") or S == fnmatch.filter(S, "keyence*"):
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# 文字列を一文字ずつのリストに代入 test は['t', 'e', 's', 't']
m = list(input())
n = list("keyence")

a=0
for i in range(len(n)):
    if m[i]==n[i]:
        a += 1
    else:
        break

for i in range(1,len(n)):
    if m[-i]==n[-i]:
        a += 1
    else:
        break    

if a >= 7:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
S = input()
l = len(S)
ans = 0
if S[0] == 'k':
	ans += 1
	if S[1] == 'e':
		ans += 1
		if S[2] == 'y':
			ans += 1
			if S[3] == 'e':
				ans += 1
				if S[4] == 'n':
					ans += 1
					if S[5] == 'c':
						ans += 1
						if S[6] == 'e':
							ans += 1
if S[l-1] == 'e':
	ans += 1
	if S[l-2] == 'c':
		ans += 1
		if S[l-3] == 'n':
			ans += 1
			if S[l-4] == 'e':
				ans += 1
				if S[l-5] == 'y':
					ans += 1
					if S[l-6] == 'e':
						ans += 1
						if S[l-7] == 'k':
							ans += 1
if ans >=7 :
	print('YES')
else:
	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:
T = "keyence"
S = input()
N = len(S)

def check(start, end):
    if N - (end - start) != 7:
        return False
    #print("start")
    j = 0
    for s in S[:start]:
        #print(s, T[j])
        if T[j] != s:
            return False
        j += 1
    #print("here")
    for s in S[end:]:
        #print(s, T[j])
        if T[j] != s:
            return False
        j += 1
    return True
    
def solve():
    for start in range(N-1):
        for end in range(start, N):
            #print("!!", start, end)
            if check(start, end):
                return True
    return False

print("YES" if solve() else "NO")

Submission status: Accepted

Solution code:
S=input()
b=len(S)
a=[]
a=list(S)
if a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[4]=='n'and a[5]=='c'and a[6]=='e':
    print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[4]=='n'and a[5]=='c'and a[b-1]=='e':
    print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[4]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[3]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[1]=='e'and a[2]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[1]=='e'and a[b-5]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[0]=='k'and a[b-6]=='e'and a[b-5]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
elif a[b-7]=='k'and a[b-6]=='e'and a[b-5]=='y'and a[b-4]=='e'and a[b-3]=='n'and a[b-2]=='c'and a[b-1]=='e':
        print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = list(input())
removed = False
removing = False
for i in range(len(s)):
    last = list("keyence")
    j = i
    while j < len(s):
        if s[j] == last[0]:
            del last[0]
            if not last:
                print("YES")
                exit()
        else:
            j += 1
            break
        j += 1
    # 残り文字がlast = enceみたいになるので
    # sの末尾がlast = enceになっていればOK
    if i == 0 and j + len(last) <= len(s) and s[len(s)-len(last):] == last:
        print("YES")
        exit()
print("NO")

Submission status: Accepted

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import bisect
import math


def main():
    s =input()

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

    print("NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import copy
S = list(input())
diff = len(S)-len("keyence")
for i in range(len(S)-diff):
    S_tmp = copy.deepcopy(S)
    #print(i)
    del S_tmp[i:(i+diff)]
    #print(str(S_tmp))
    if "keyence" == "".join(S_tmp):
        print("YES")
        exit(0)
print("NO")

Submission status: Accepted

Solution code:
from sys import stdin

str = stdin.readline().rstrip()
target = "keyence"
status = 0
for i in range(6):
    before = target[0:i+1]
    after =target[i+1:]
    bindex = str.find(before)
    if bindex > 0:
        if bindex == str.find("keyence"):
            status += 1
    elif bindex == 0:
        aindex = str.rfind(after)
        if aindex == (len(str) - len(after)):
            status += 1
        elif aindex == len(before):
            status += 1
if status == 0:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
s = raw_input()
string = 'keyence'
back = 0
front = 0
ptr = len(string)-1
for i in xrange(len(s)-1, -1, -1):
	if ptr < 0:
		break
	if s[i] == string[ptr]:
		back += 1
		ptr -= 1
	else:
		break
for i in xrange(len(s)):
	if i == len(string):
		break
	if s[i] == string[i]:
		front += 1
	else:
		break
if front + back >= len(string):
	print 'YES'
else:
	print 'NO'

Submission status: Accepted

Solution code:
S = input()
ans = False
if(S.find("keyence") == 0 or S.find("keyence") == len(S) - 7):
  ans = True
else:
  for i in range(7):
    if(S[0: i + 1] + S[len(S) - 6  +i : len(S)]  == "keyence"):
      ans = True
      break
if ans:
  print("YES")
else:
  print("NO")