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:
import sys
s = input()
for i in range(len(s)):
    for j in range(i, len(s)+1):
        if s.replace(s[i:j],"")=="keyence":
            print("YES")
            sys.exit()
print("NO")

Submission status: Wrong Answer

Solution code:
def inpl(): return list(map(int, input().split()))
S = input()
x = "keyence"
for i in range(8):
    if x[:i] in S and x[i:] in S:
        print("YES")
        break
else:
    print("NO")

Submission status: Wrong Answer

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

for i in range(len(ch)):
    ch1 = ch[:i]
    ch2 = ch[i:]

    if ch1 in S and ch2 in S:
        print('YES')
        exit()
print('NO')

Submission status: Wrong Answer

Solution code:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]
# 


s = input()
key = "keyence"
ind = 0

for c in s:
    if ind == len(key):
        break
    else:
        if key[ind] == c:
            ind += 1

if ind == len(key):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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 I(): return int(sys.stdin.readline())
def SS(): return input()


S = SS()
n = 0
key = 'keyence'
for s in S:
    if s == key[n]:
        n += 1
    if n == len(key) - 1:
        print('YES')
        exit()

print('NO')

Submission status: Wrong Answer

Solution code:
test = "keyence"
S = input()
index = 0
for si in S:
    if si == test[index]:
        index += 1
        if index == len(test):
            break

if index == len(test):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
ans = "keyence"
a = 0
for s in S:
    if s == ans[a]:
        a += 1
    if a == len(ans):
        print("YES")
        exit()
print("NO")

Submission status: Time Limit Exceeded

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

flag = 0

for i in range(len(str)):
    if str[i] != key[i]:
        break
    
if i > 7:
    flag = 1

j = i

while(j <= len(str)):
    for j in range(j, len(str)):
        if str[j] == key[i]:
            break
    
        for k in range(len(str) - j):
            if str[j + k] != key[i]:
                break
            i += 1

if i == 7 or flag == 1:
    print('YES')
else :
    print('NO')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()

target = 'keyence'

if target in s:
    print('YES')
    sys.exit(0)

for start in range(len(s)):
    for end in range(start + 1, len(s) + 1):
        copy_s = list(s)
        copy_s[start:end] = ''
        if ''.join(copy_s) == target:
            print('YES')
            sys.exit(0)
print('NO')

Submission status: Accepted

Solution code:
S = input()
s = "keyence"
ans = "NO"
 
for i in range(len(S)):
  if s == S[:i] + S[len(S)-len(s)+i:]:
    ans = "YES"
    
print(ans)

Submission status: Accepted

Solution code:
S = input()
s = "keyence"
ans = "NO"

for i in range(len(S)):
  if s == S[:i] + S[len(S)-len(s)+i:]:
    ans = "YES"
    
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
for i in range(7):
    if "".join(s[:i] + s[-(7 - i):]) == "keyence":
        print("YES")
        exit()
print("YES" if "".join(s[:7]) == "keyence" else "NO")

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

S = input()
S = S.replace('\n','')
s_list = list(S)

K = "keyence"
k_list = list(K)

for start in range(len(s_list)):
    small_s_list = s_list[start:]
    if "".join(small_s_list)== K:
        print("YES")
        exit(0)

for end in reversed(range(len(s_list))):
    small_s_list = s_list[:end+1]
    if "".join(small_s_list)== K:
        print("YES")
        exit(0)
point = int(len(s_list)/2)
for delete_start in range(len(s_list)-point):
    if delete_start >= point:
        break
    for delete_end in reversed(range(len(s_list))):
        if delete_end < point:
            break
        small_s_list = s_list[:delete_start+1] + s_list[delete_end:]
        if "".join(small_s_list)== K:
            print("YES")
            exit(0)
print("NO")

Submission status: Accepted

Solution code:
s=input()
res='keyence'
n=len(s)
if s[0]!='k':
  if s[n-7:n]=='keyence':
    print('YES')
  else:
    print('NO')
elif s[n-1]!='e':
  if s[:7]=='keyence':
    print('YES')
  else:
    print('NO')
elif s[0]=='k' and s[n-1]=='e':
  lb=1
  while lb<6:
    if s[lb]==res[lb]:
      lb+=1
    else:
      break
  ub=1
  while ub<7-lb:
    if s[n-ub-1]==res[6-ub]:
      ub+=1
    else:
      break
  if ub+lb==7:
    print('YES')
  else:
    print('NO')

Submission status: Accepted

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

for i in range(8):
    if s[0:i] == kw[0:i] and s[-7 + i:] == kw[i:]:
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

Solution code:
import sys
import copy
import math
import itertools
import numpy as np
import re

S = input()
s = "keyence"
for i in range(len(S)):
    if re.fullmatch(s[:i]+".*"+s[i:],S):
        print("YES")
        sys.exit(0)

print("NO")

Submission status: Accepted

Solution code:
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = input()
    key = "keyence"
    if key in S:
        print("YES")
        return

    for i in range(len(S) - 1):
        for j in range(i + 1, len(S)):
            if S[:i] + S[j:] == key:
                print("YES")
                return

    print("NO")
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
s = input()
target = "keyence"

if s == target:
    print("YES")
    sys.exit()
for i in range(len(s)):
    for j in range(i, len(s)):
        st = s[:i] + s[j:]
        if st == target:
            print("YES")
            sys.exit()

print("NO")

Submission status: Accepted

Solution code:
s = list(input())
n = len(s)
for i in range(n):
    for j in range(i,n):
        t = s[:i] + s[j:]
        if ''.join(t) == 'keyence':
            print('YES')
            exit(0)
print('NO')

Submission status: Accepted

Solution code:
import re

s = input()
key = 'keyence'
ans = 'NO'
for i in range(len(key)):
    k1 = key[:i + 1]
    k2 = key[i + 1:]
    
    k1_temp = [m.span() for m in re.finditer(k1, s)]
    for j in range(len(k1_temp)):
        k2_temp= [m.span() for m in re.finditer(k2, s)]
        for k in range(len(k2_temp)):
            if k1_temp[j][1] == k2_temp[k][0]:
                ans = 'YES'
                break
            if  k1_temp[j][0] == 0 and k2_temp[k][1] == len(s):
                ans = 'YES'
                break
print(ans)

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

S = input()
T = 'keyence'
N = len(S)

i = 0
while i<7 and S[i]==T[i]:
    i += 1
j = 0
while j<7 and S[N-1-j]==T[6-j]:
    j += 1
judge(i+j>=7,['YES','NO'])

Submission status: Accepted

Solution code:
S = input()

for i in range(len(S)-1):
    for j in range(i,len(S)):
        memo = S[:i]+S[j:]
        #print(memo)
        if memo == 'keyence':
            print('YES')
            exit()
print('NO')

Submission status: Accepted

Solution code:
s=input()

n=len(s)
ans="NO"

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

Submission status: Accepted

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

if k in s:
  print('YES')
  exit()
if s[0] == 'k' and s[-1] == 'e':
  for i in range(len(s)):
    if s.startswith(k[:i]) and s.endswith(k[i:]):
      print('YES')
      exit()
print('NO')

Submission status: Accepted

Solution code:
def main():
    S = input()
    if S[0] != 'k':
        return ('NO')
    elif S == 'keyence':
        return ('YES')

    ans = 'keyence'
    i = 0
    j = 0
    while True:
        i += 1
        j += 1
        if S[i] != ans[j]:
            break

    #残りの文字数
    num = 7-j
    cnt = 0
    while cnt < num:
        cnt += 1
        #print(ans[-cnt])
        if S[-cnt] != ans[-cnt]:
            return ('NO')
    return ('YES')
print(main())

Submission status: Accepted

Solution code:
S = input()
if S == 'keyence':
    print('YES')
    exit()

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    N = len(S)
    for i in range(N):
        for j in range(i, N+1):
            ans = []
            for k in range(N):
                if i <= k and k < j:
                    continue
                ans.append(S[k])
            if "".join(ans) == "keyence":
                print("YES")
                return
    print("NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
import copy
s=input()
check="keyence"
tmp=6
sNow=0
cNow=0
#一度目のチェック
for i in s:
  sNow+=1
  if i == check[cNow]:
    cNow+=1
  else:
    break
#最初に見つかれば終了
if cNow == 7:
  print("YES")
  exit()

#print(check[cNow:], s[-1*(7-cNow):])
"""
sの最後が"keyence"の残りの文字と一致すればOK
例：keyaence
最初の"key"は合っているので，残りは"aence"の内"a"を除いたもの
cNow=3, 7-cNow=4
後ろの４文字が"ence"ならばYESとなる
"""
if check[cNow:] == s[-1*(7-cNow):]:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    s=SI()
    n=len(s)
    for i in range(8):
        s1=s[:i]
        s2=s[n+i-7:]
 
        if s1+s2=="keyence":
            print("YES")
            exit()
    print("NO")
        








if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import re
S=input()
if re.fullmatch(r"[a-z]*keyence",S)==None and re.fullmatch(r"k[a-z]*eyence",S)==None and re.fullmatch(r"ke[a-z]*yence",S)==None and re.fullmatch(r"key[a-z]*ence",S)==None and re.fullmatch(r"keye[a-z]*nce",S)==None and re.fullmatch(r"keyen[a-z]*ce",S)==None and re.fullmatch(r"keyenc[a-z]*e",S)==None and re.fullmatch(r"keyence[a-z]*",S)==None:
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
s = str(input()); n = len(s)
kn = 7
if n < kn:
  print("NO")
  exit()
for i in range(kn):
  temp = s[:i] + s[n-kn+i:]
  if temp == "keyence":
    print("YES")
    exit()
print("NO")

Submission status: Accepted

Solution code:
s=input()
flag=False
ans='keyence'

for i in range(len(s)):
  for j in range(i,len(s)):
    if ans==s[:i]+s[j:]:
      flag=True
      break
if flag:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
s=input()
rem = len(s)-7

if s[rem:] == 'keyence': 
    print('YES')
    exit()
for i in range(8):
    news = s[0:i] + s[i+rem:]
    if news == 'keyence':
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(K) + 1):
    l, r = K[:i], K[i:]
    if S.startswith(l) and S.endswith(r):
        print("YES")
        break
else:
    print("NO")

Submission status: Accepted

Solution code:
S = input().strip()
if S=="keyence":
    print("YES")
else:
    flag = 0
    for i in range(len(S)):
        for j in range(i,len(S)):
            x = S[:i]+S[j+1:]
            if x=="keyence":
                flag = 1
                break
        if flag==1:break
    if flag==1:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    l = len(S)
    m = l - 7

    def judge():
        for i in range(l - m + 1):
            first = S[:i]
            second = S[i + m:]
            if first + second == "keyence":
                return True
        return False

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=input()
t="keyence"
for i in range(1,7):
  if S[:i]==t[:i] and S[-(7-i):]==t[i:]:
    print('YES')
    exit()
    
print('NO')

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# KEYENCE Programming Contest 2019 / キーエンス プログラミング コンテスト 2019: B – KEYENCE String
S = input()

is_keyence = 'NO'

for i in range(0, 8):
    if S[:i] + S[i - 7:] == 'keyence':
        is_keyence = 'YES'
        break

print(is_keyence)

Submission status: Accepted

Solution code:
# KEYENCE Programming Contest 2019 / キーエンス プログラミング コンテスト 2019: B – KEYENCE String
S = input()

if (S[-7:] == 'keyence') or \
    (S[:1] == 'k' and S[-6:] == 'eyence') or \
    (S[:2] == 'ke' and S[-5:] == 'yence') or \
    (S[:3] == 'key' and S[-4:] == 'ence') or \
    (S[:4] == 'keye' and S[-3:] == 'nce') or \
    (S[:5] == 'keyen' and S[-2:] == 'ce') or \
    (S[:6] == 'keyenc' and S[-1:] == 'e') or \
    S[:7] == 'keyence':
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
import numpy as np
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

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

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    S = input()
    N = len(S)
    for i in range(N-1):
        for j in range(i, N):
            if S[:i]+S[j:] == 'keyence':
                print('YES')
                return
    print('NO')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = 'NO'
    k = 'keyence'
    S = input().rstrip('\n')
    if S[:7] == k or S[-7:] == k:
        ans = 'YES'
    elif S[0] == k[0]:
        for i in range(1,len(k)):
            if S[i] != k[i]:
                if S[-(7-i):] == k[i:]:
                    ans = 'YES'
                    break
                else:
                  break
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

if S == k:
    print("YES")
else:
    ans = "NO"
    s = S
    for i in range(8):
        S = list(s)
        del S[i:i+(len(S)-7)]
        if "".join(S) in k:
            ans = "YES"
            break
    
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


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


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


S = S()
cut_l = 0
cut_r = 0
for cut_l in range(len(S)):
    for cut_r in range(len(S)):
        # print(cut_l, cut_r)
        # print(S[:cut_l] + S[cut_r:])
        if (S[:cut_l] + S[cut_r:] == 'keyence'):
            print('YES')
            exit()
print('NO')

Submission status: Accepted

Solution code:
S = input()
K = "keyence"
for i in range(len(K)):
  if (K[:i] == S[:i]) and (K[(i-(len(K))):] == S[(i-(len(K))):]):
    print("YES")
    exit()
if K == S[:len(K)] or K == S[(-len(K)):]:
  print("YES")
  exit()
print("NO")

Submission status: Accepted

Solution code:
#15 B - KEYENCE String
S = list(input())

result = 'NO'
for i in range(len(S)):
    Scpy = S.copy()
    for j in range(i,len(S)):
        Scond = Scpy[:i]+Scpy[j:]
        if (''.join(Scond)) == ('keyence'):
            result = 'YES'
            break
    else:
        continue
    break
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    key = "keyence"
    ans = False
    if s == key:
        ans = True
    for i in range(len(s)):
        for j in range(i+1,len(s)):
            ex = s[:i] + s[j:]
            if ex == key:
                ans = True
    print("YES" if ans else "NO")
main()

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    key_lst = []
    for i in range(0,8):
        key_lst.append(["keyence"[:i],"keyence"[i:]])
    ans = False
    for b,f in key_lst:
        st = s[:len(b)]
        go = s[len(s)-len(f):]
        if st == b and go == f:
            ans = True
    

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

Submission status: Accepted

Solution code:
s=input()
ans=False
for x in range(len(s)):
    for y in range(x,len(s)):
        if (s[:x]+s[y:])=='keyence':
            ans=True
if ans:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
#キーエンス プログラミング コンテスト 2019 b
s=input()
ans=False
for x in range(len(s)):
    for y in range(x,len(s)):
        if (s[:x]+s[y:])=='keyence':
            ans=True
if ans:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
S = input()
k = 'keyence'
Srev = S[::-1]
krev = k[::-1]

ans = 'NO'
for i in range(8):
    if S[:i]==k[:i] and Srev[:(7-i)]==krev[:(7-i)]:
        ans = 'YES'

print(ans)

Submission status: Accepted

Solution code:
s = input()
ok = False

if s.startswith('keyence'):
    ok = True
if s.startswith('k') and s.endswith('eyence'):
    ok = True
if s.startswith('ke') and s.endswith('yence'):
    ok = True
if s.startswith('key') and s.endswith('ence'):
    ok = True
if s.startswith('keye') and s.endswith('nce'):
    ok = True
if s.startswith('keyen') and s.endswith('ce'):
    ok = True
if s.startswith('keyenc') and s.endswith('e'):
    ok = True
if s.endswith('keyence'):
    ok = True

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

Submission status: Accepted

Solution code:
s = input()

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

print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

for i in s:
    if n[0] == i:
        n = n[1:]
    else:
        break

for i in s[::-1]:
    if n == "":
        print("YES")
        exit()
    elif n[-1] == i:
        n = n[:-1]
    else:
        break

print("NO")

Submission status: Accepted

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

for i in s:
    if n[0] == i: #文字が一致するなら
        n = n[1:] #比較中の文字を削る
    else:
        break

n = n[::-1]

for i in s[::-1]:
    if n == "":
        break
    elif n[0] == i:
        n = n[1:]
    else:
        break

if n == "":
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
u=str(input())
S=u.replace(' ','z')
A=[]
for i in range(len(S)+1):
    for j in range(len(S)+1):
        if i<=j:
            A.append(S.replace(S[i-1:j],'',1))
if 'keyence' in A:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
S = input()
c = "keyence"
if S[-7:] == c or S[:7] == c:
    print("YES")
else:
    for i in range(1, 7):
        c_, _c = c[:i], c[i:]
        if S[:i] == c_ and S[-(7-i):] == _c:
            print("YES")
            break
    else:
        print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ok = False
if S.startswith(T) or S.endswith(T):
    ok = True
for i in range(1, 7):
    left = T[:i]
    right = T[i:]
    a = S.startswith(left)
    b = S.endswith(right)
    if a and b:
        ok = True
if ok:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().strip()
t_len = len(s) - 7

if t_len == 0:
  if s == 'keyence': print('YES')
  else: print('NO')
  exit()
else:
  for i in range(7):
    if s[:i] + s[i+t_len:] == 'keyence':
      print('YES')
      exit()
      
print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = i
        break

if t == -1:
    t = 7

for i in range(1, 8):
    if not S[-i] == key[-i]:
        t += i - 1
        break

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

Submission status: Accepted

Solution code:
s=input()
x=len(s)-7
if x==0:
  if  s=='keyence':
    print('YES')
    exit()
  else:
    print('NO')
    exit()

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


for i in range(len(s)-5):
  if s[:i]+s[i+x:]=='keyence':
    print('YES')
    exit()
    
print('NO')

Submission status: Accepted

Solution code:
s = input()

res = False
for i in range(len(s)+1):
    for j in range(i, len(s)+1):
        if (s[:i] + s[j:]) == "keyence":
            res = True
            break

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

Submission status: Accepted

Solution code:
s = list(input())
ls = len(s)
key = "keyence"
if "".join(s) == key:
    print("YES")
    exit()
f = False
for l in range(ls):
    for r in range(l + 1, ls):
        f |= "".join(["".join(s[:l]), "".join(s[r:])]) == key

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
for l in range(n):
    for r in range(n):
        ans = s[:l] + s[r:]
        if ans == 'keyence':
            print("YES")
            exit()
print("NO")

Submission status: Accepted

Solution code:
s=input()
if s[-7]+s[-6]+s[-5]+s[-4]+s[-3]+s[-2]+s[-1]=='keyence':
    print("YES")
    exit()
elif s[0]=='k':
    if s[-6]+s[-5]+s[-4]+s[-3]+s[-2]+s[-1]=='eyence':
        print("YES")
        exit()
    elif s[1]=='e':
        if s[-5]+s[-4]+s[-3]+s[-2]+s[-1]=='yence':
            print("YES")
            exit()
        elif s[2]=='y':
            if s[-4]+s[-3]+s[-2]+s[-1]=='ence':
                print("YES")
                exit()
            elif s[3]=='e':
                if s[-3]+s[-2]+s[-1]=='nce':
                    print("YES")
                    exit()
                elif s[4]=='n':
                    if s[-2]+s[-1]=='ce':
                        print("YES")
                        exit()
                    elif s[5]=='c':
                        if s[-1]=='e':
                            print("YES")
                            exit()
print("NO")

Submission status: Accepted

Solution code:
n = list(input())

for i in range(len(n)):
    for j in range(i,len(n)):
        tmp = n[:]
        del tmp[i:j]
        if ''.join(tmp) == 'keyence':
            print('YES')
            exit()
else:
    print('NO')

Submission status: Accepted

Solution code:
s = list(input())
ans = 'NO'
for i in range(len(s)):
    if ''.join(s[:i] + s[len(s)-7+i:]) == 'keyence':
        ans = 'YES'
        break
print(ans)

Submission status: Accepted

Solution code:
import re

S=input()

if re.fullmatch('([a-z]*)keyence',S):
  print('YES')
elif re.fullmatch('k([a-z]*)eyence',S):
  print('YES')
elif re.fullmatch('ke([a-z]*)yence',S):
  print('YES')
elif re.fullmatch('key([a-z]*)ence',S):
  print('YES')
elif re.fullmatch('keye([a-z]*)nce',S):
  print('YES')
elif re.fullmatch('keyen([a-z]*)ce',S):
  print('YES')
elif re.fullmatch('keyenc([a-z]*)e',S):
  print('YES')
elif re.fullmatch('keyence([a-z]*)',S):
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
S=input()
n=len(S)
ans="NO"
for i in range(n):
  for j in range(i,n):
    if S[:i]+S[j:]=="keyence":
      ans="YES"
      break
print(ans)

Submission status: Accepted

Solution code:
def check(s):
    t = 'keyence'
    if s == t:
        return 'YES'
    for i in range(len(s)):
        for j in range(i + 1, len(s)):
            if t == s[:i] + s[j:]:
                return 'YES'
    return 'NO'


s = input()
print(check(s))

Submission status: Accepted

Solution code:
#15
import sys

s = input()
l = len(s) 
for i in range(l+1):
    for j in range(l+1):
        mozi1 = s[0:i]
        mozi2 = s[j:]
        if mozi1+mozi2 == "keyence":
            print("YES")
            sys.exit()
print("NO")

Submission status: Accepted

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

for start in range(n):
  for end in range(start, n):
    tmp_s = s[:start] + s[end:]
    if tmp_s == "keyence":
      print("YES")
      exit(0)

print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

k = 'keyence'
if S[:7] == k or S[-7:] == k:
    print('YES')
    exit()
for i in range(len(S)):
    if S[:i] != k[:i]:
        if S[-7+i-1:] == k[-7+i-1:]:
            print('YES')
            exit()
        else:
            print('NO')
            exit()
print('NO')

Submission status: Accepted

Solution code:
s=input()
n="keyence"
res=False
if s[:7]==n or s[-7:]==n:
    res=True
else:
    for i in range(7):
        if s[:i+1]+s[i-6:]==n:
            res=True
            break

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

Submission status: Accepted

Solution code:
s=input()
n="keyence"
res=False
if s[:8]==n or s[-7:]==n:
    res=True
else:
    for i in range(7):
        if s[:i+1]+s[i-6:]==n:
            res=True
            break

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

Submission status: Accepted

Solution code:
s = input()

ks = "keyence"

if s.startswith(ks) or s.endswith(ks):
  print("YES")
  exit(0)
  
for i in range(1, len(ks)):
  k1 = ks[:i]
  k2 = ks[i:len(ks)]
  if s.startswith(k1) and s.endswith(k2):
    print("YES")
    exit(0)

print("NO")