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().strip()
N = len(S)
x = "keyence"
n = len(x)
if N<n:
    flag = 0
else:
    flag = 0
    for i in range(7):
        for j in range(1,8):
            if S[:i]+S[-j:]==x:
                flag = 1
                break
        if flag==1:break
if flag==1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

s=input()

key = "keyence"

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

Submission status: Accepted

Solution code:
S = input()
n = len(S)
ans = 'NO'
for i in range(n):
  j = i+n-7
  Q = S[:i] + S[j:]
  if Q == 'keyence':
    ans = 'YES'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = list(input())
nya = list("keyence")
slen = len(s)
for i in range(slen):
    #rint(s[:i],nya[:i],s[-7+i:],nya[-7+i:])
    if s[:i] == nya[:i] and s[-7 + i:] == nya[-7 + i:]:
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
s = input()
ans = "NO"
if s[:7] == "keyence" or s[-7:] == "keyence": ans = "YES"
elif len(s) >= 7:
    k = "keyence"
    for i in range(len(s)):
        if k[i] == s[i]: continue
        else: break
    if s[:i]+s[-(7-i):] == "keyence": ans = "YES"
print(ans)

Submission status: Accepted

Solution code:
S = list(input())

l = len(S)
for i in range(l):
    for j in range(i,l):
        tmp = S[:i] + S[j:]
        if "".join(tmp) == "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(i, n):
        string = s[:i] + s[j+1:]
        if string == 'keyence':
            ans = 'YES'
if s == 'keyence':
    ans = 'YES'

print(ans)

Submission status: Accepted

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

if s[0] != 'k' and s[-1] != 'e':
    print('NO')
else:
    if s[:7] == check or s[-7:] == check:
        print('YES')
        exit()
    else:
        for i in range(1, 7):
            if s[:i] + s[-(7 - i):] == check:
                print('YES')
                exit()
                # print(s[:i], s[-(7 - i):])
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

S = S()
L = len(S)

if S == "keyence":
  print("YES")
  exit()
  
for i in range(8):
  if S[:i]+S[-(7-i):] == "keyence":
    print("YES")
    exit()
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:
S=input()

ans='NO'
# print(S.find('k'))
if S.find('k')==0 and S.rfind('eyence')==len(S)-6:
    ans='YES'
elif S.find('ke')==0 and S.rfind('yence')==len(S)-5:
    ans='YES'
elif S.find('key')==0 and S.rfind('ence')==len(S)-4:
    ans='YES'
elif S.find('keye')==0 and S.rfind('nce')==len(S)-3:
    ans='YES'
elif S.find('keyen')==0 and S.rfind('ce')==len(S)-2:
    ans='YES'
elif S.find('keyenc')==0 and S.rfind('e')==len(S)-1:
    ans='YES'

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
interval = n - 7
flag = False
start = 0
end = interval
for i in range(n-interval):
    news = s[0:start] + s[end:]
    if news == 'keyence':
        print('YES')
        flag = True
        break
    start+=1
    end+=1
if not flag:
    print('NO')

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    is_keyence = False
    if S[:7] == "keyence":
        is_keyence = True
    elif S[-7:] == "keyence":
        is_keyence = True
    elif S[:1] == "k" and S[-6:] == "eyence":
        is_keyence = True
    elif S[:2] == "ke" and S[-5:] == "yence":
        is_keyence = True
    elif S[:3] == "key" and S[-4:] == "ence":
        is_keyence = True
    elif S[:4] == "keye" and S[-3:] == "nce":
        is_keyence = True
    elif S[:5] == "keyen" and S[-2:] == "ce":
        is_keyence = True
    elif S[:6] == "keyenc" and S[-1:] == "e":
        is_keyence = True

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=input()

ans='NO'
if S.find('k')==0 and S.rfind('eyence')==len(S)-6:
    ans='YES'
elif S.find('ke')==0 and S.rfind('yence')==len(S)-5:
    ans='YES'
elif S.find('key')==0 and S.rfind('ence')==len(S)-4:
    ans='YES'
elif S.find('keye')==0 and S.rfind('nce')==len(S)-3:
    ans='YES'
elif S.find('keyen')==0 and S.rfind('ce')==len(S)-2:
    ans='YES'
elif S.find('keyenc')==0 and S.rfind('e')==len(S)-1:
    ans='YES'

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = 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:
S=str(input())
l=len(S)
key='keyence'
if S=='keyence':
  print('YES')
  exit()
else:  
  for i in range(1,l):
    for j in range(l):
      if S[0:j]+S[i+j:l]==key:
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
ans_word = "keyence"

s = input()
flag = False
if s == ans_word:
    flag = True
else:
    for i in range(len(s)-1):
        for j in range(i+1, len(s)):
            if s[:i] + s[j:] == ans_word:
                flag = True
                break
        if flag:
            break

if flag:
    print("YES")
else:
    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 "keyence" == (S[:i]) + (S[j:]):
            print("YES")
            sys.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:
s=input()
x='keyence'
for i in range(7):
  if s[:i]+s[-7+i:]==x:
    print('YES')
    quit()
print('NO')

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit
import bisect
setrecursionlimit(10 ** 7)

s = input()
point = 0

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

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
ans = 'keyence'
S = input()
lenS = len(S)
for i in range(1,7):
    #print(ans[i:],S[lenS-7 + i:])
    #print(ans[:i], S[:i])
    if ans[:i] == S[:i] and ans[i:] == S[lenS - 7 + i:]:
        print('YES')
        exit()
print('NO')

Submission status: Accepted

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

n = len(S)
if S == 'keyence':
  ans = 'YES'
for i in range(n):
  for j in range(i,n):
    T = S[:i]+S[j:]
    if T == 'keyence':
      ans = 'YES'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = "keyence"
S = input().strip()
N = len(S)
flag = 0
for i in range(N):
    if flag==0 and i<len(a) and S[i]==a[i]:continue
    elif flag==0 and i<len(a) and S[i]!=a[i]:
        flag = 1
        cur = i
        break
if flag==0:
    print("YES")
else:
    if S[-(7-cur):]==a[cur:]:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import re

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

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

for i in range(N+1):
    S1 = S[:i]
    S2 = S[i:]
    exp = '^{0}(.*){1}$'.format(S1, S2)
    if re.match(exp, T):
        YES()
        exit()
NO()

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
mod = 10**9 + 7

s = input()

if "keyence" in s:
    print("YES")
    sys.exit()

n = len(s)
m = n - 7

for i in range(n):
    s_ = s[:i] + s[i + m:]
    if s_ == "keyence":
        print("YES")
        sys.exit()

print("NO")

Submission status: Accepted

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

ans = 'NO'
for i in range(n):
    for j in range(i-1, n):
        string = s[:i] + s[j+1:]
        if string == 'keyence':
            ans = 'YES'
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

S = input()[:-1]

if S=='keyence':
    print('YES')
    exit()

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

print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(k) + 1):
    if S[:i] == k[:i] and S[-(len(k) - i):] == k[-(len(k) - i):]:
        print("YES")
        exit()

print("NO")

Submission status: Accepted

Solution code:
s=input()
str1="keyence"
count=0
num=len(s)
if s==str1:
    yn=0
elif s[:7]==str1:
    yn=0
elif s[num-8:]==str1:
    yn=0
else:
    for i in range(7):
        if str1[i]==s[i]:
            count+=1
        else:
            break
    if s[num-7+count:]==str1[count:]:
        yn=0
    else:
        yn=1
if yn==0:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print('NO')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import product

S = input()

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

Submission status: Accepted

Solution code:
S = input()


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


f()

Submission status: Accepted

Solution code:
S = input()


def f():
    if S == "keyence":
        print("YES")
    else:
        n = len(S)
        for i in range(n):
            for j in range(i, n):
                T = ""
                for k in range(n):
                    if i <= k <= j:
                        continue
                    else:
                        T += S[k]
                if T == "keyence":
                    print("YES")
                    return
        else:
            print("NO")


f()

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:
s = input()
a = 'keyence'
n = len(s)
d =0
for i in range(n):
  for j in range(i,n+1):
    if s[:i]+s[j:] == a:
      d += 1
if d == 0:
  print('NO')
else:
  print('YES')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
L = len(S)
key = list("keyence")

for i in range(0,8):
    if S[0:i] == key[0:i] and S[L-7+i:] == key[i:]:
        print("YES")
        exit()
print("NO")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():

        s=input()
        n=len(s)
        if s=='keyence':
            return 'YES'
        else:
            for i in range(n):
                for j in range(i+1,n+1):
                    if s[:i]+s[j:]=='keyence':
                        return 'YES'
            return 'NO'
    print(main())
resolve()

Submission status: Accepted

Solution code:

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


if __name__ == "__main__":
    main()

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()
b = s[:7]
e = s[-7:]
flg = 0
for i in range(7):
  if b[:i] + e[i:] == "keyence":
    flg = 1
if flg:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
S = input()
target = "keyence"
length = len(target)+1

# 部分文字列を取り除く方法は、
# 1. 先頭の文字列を削除
# 2. 真ん中の文字列を削除
# 3. 末尾の文字列を削除

if target in S: # 1 & 3
    print("YES")
    exit()
else: # 2
    for i in range(1, length):
      first = target[:i]
      second = target[i:]
      # print("{} + {}".format(S[0:len(first)], S[len(target)-len(second):len(target)]))
      if first in S and second in S and S.find(first) < S.rfind(second):
          if S[0:len(first)] + S[len(S)-len(second):len(S)] == target:
                print("YES")
                exit()
print("NO")

Submission status: Accepted

Solution code:
import sys
s = input()
O = "keyence"
k = 0
for i in range(7,0,-1):
    if s[:i] == O[:i]:
        k = i
        if k == 7:
            print("YES")
            sys.exit()
        break
if s[len(s)+k-7:len(s)] == O[k:]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input()
tgt = 'keyence'
ans = 'NO'
for i in range(8):
    if s[:i] == tgt[:i] and s[len(s)-(7-i):] == tgt[i:]:
        ans = 'YES'
        break
print(ans)

Submission status: Accepted

Solution code:
import sys, re

S = sys.stdin.readline().rstrip()

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

Submission status: Accepted

Solution code:
import re

S = input()

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

Submission status: Accepted

Solution code:
from pprint import pprint

s = str(input())


keyence_list = [[0,0] for _ in range(6)]

#下記のリストを埋めていく
#[[{keyenc},{e}],
# [{keyen},{ce}],
# [{keye},{nce}],
# [{key},{ence}],
# [{ke},{yence}],
# [{k},{eyence}]]


#前から探す
i = 0
if s[i] == "k":
    if s[i+1] == "e":
        if s[i+2] == "y":
            if s[i+3] == "e":
                if s[i+4] == "n":
                    if s[i+5] == "c":
                        if s[i+6] == "e":
                            print("YES")
                            exit()
                        else:
                            keyence_list[0][0] = 1
                    else:
                        keyence_list[1][0] = 1
                else:
                    keyence_list[2][0] = 1
            else:
                keyence_list[3][0] = 1
        else:
            keyence_list[4][0] = 1
    else:
        keyence_list[5][0] = 1
else:
    pass

#後ろから探す
j = len(s)-1
if s[j] == "e":
    if s[j-1] == "c":
        if s[j-2] == "n":
            if s[j-3] == "e":
                if s[j-4] == "y":
                    if s[j-5] == "e":
                        if s[j-6] == "k":
                            print("YES")
                            exit()
                        else:
                            keyence_list[5][1] = 1
                    else:
                        keyence_list[4][1] = 1
                else:
                    keyence_list[3][1] = 1
            else:
                keyence_list[2][1] = 1
        else:
            keyence_list[1][1] = 1
    else:
        keyence_list[0][1] = 1
else:
    pass

for k in range(6):
    for l in range(k,6):
        if keyence_list[k][0] == keyence_list[l][1] == 1:
            print("YES")
            exit()

print("NO")
exit()



#問題の読み違え
#一部分を削った文字列が"keyence"と一致しないといけない。（"keyence"を含む、ではない）
#from pprint import pprint
#
#s = str(input())
#
#keyence_list = [[float("inf"),-float("inf")] for _ in range(6)]
#
#
#
##前から探す
#for i in range(len(s)-6):
#    if s[i] == "k":
#        if s[i+1] == "e":
#            if s[i+2] == "y":
#                if s[i+3] == "e":
#                    if s[i+4] == "n":
#                        if s[i+5] == "c":
#                            if s[i+6] == "e":
#                                print("YES")
#                                exit()
#                            else:
#                                keyence_list[0][0] = min(keyence_list[0][0],i)
#                        else:
#                            keyence_list[1][0] = min(keyence_list[1][0],i)
#                    else:
#                        keyence_list[2][0] = min(keyence_list[2][0],i)
#                else:
#                    keyence_list[3][0] = min(keyence_list[3][0],i)
#            else:
#                keyence_list[4][0] = min(keyence_list[4][0],i)
#        else:
#            keyence_list[5][0] = min(keyence_list[5][0],i)
#    else:
#        pass
#
##後ろから探す
#for j in range(len(s)-1,5,-1):
#    if s[j] == "e":
#        if s[j-1] == "c":
#            if s[j-2] == "n":
#                if s[j-3] == "e":
#                    if s[j-4] == "y":
#                        if s[j-5] == "e":
#                            if s[j-6] == "k":
#                                print("YES")
#                                exit()
#                            else:
#                                keyence_list[5][1] = max(keyence_list[0][1],j-5)
#                        else:
#                            keyence_list[4][1] = max(keyence_list[1][1],j-4)
#                    else:
#                        keyence_list[3][1] = max(keyence_list[2][1],j-3)
#                else:
#                    keyence_list[2][1] = max(keyence_list[3][1],j-2)
#            else:
#                keyence_list[1][1] = max(keyence_list[4][1],j-1)
#        else:
#            keyence_list[0][1] = max(keyence_list[5][1],j)
#    else:
#        pass
#
##pprint(keyence_list)
#
#
#for k in range(6):
#    for l in range(k,6):
#        if keyence_list[k][0] <= keyence_list[l][1]:
#            print("YES")
#            exit()
#
#print("NO")
#exit()
#
#
#
#

#下記のリストを埋めていく
#[[{keyenc},{e}],
# [{keyen},{ce}],
# [{keye},{nce}],
# [{key},{ence}],
# [{ke},{yence}],
# [{k},{eyence}]]
#
# 0列目はsを前から走査し、1列目はsを後ろから走査
# 0列目のset{}の中で最小のものと、1列目のset{}の中で最大のものの大小関係がおかしくなければTrue

Submission status: Accepted

Solution code:
s=input()
k='keyence'
ans='NO'
for i in range(8):
  if s[:i]==k[:i] and s[len(s)-(7-i):]==k[i:]:
    ans='YES'
print(ans)

Submission status: Accepted

Solution code:
def main():
    S  = input()
    K = 'keyence'
    if len(S)<=7:
        if S == K:
            print('YES')
        else:
            print('NO')
    else :
        ShaveN = len(S) - 7
        for i in range(len(S) - ShaveN + 1):
            Shave = S[:i] + S[i+ShaveN:]
            if Shave == K:
                print('YES')
                return
        print('NO')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
key = "keyence"
j = 0
while j < len(key) and s[j] == key[j]:
    j += 1

j -= 1
for i in range(len(key) - j - 1):
    if s[len(s) - 1 - i] != key[len(key) - 1 - i]:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
import re
s = input()
a = []
a += [re.match(r'.*keyence$', s)]
a += [re.match(r'k.*eyence$', s)]
a += [re.match(r'ke.*yence$', s)]
a += [re.match(r'key.*ence$', s)]
a += [re.match(r'keye.*nce$', s)]
a += [re.match(r'keyen.*ce$', s)]
a += [re.match(r'keyenc.*e$', s)]
a += [re.match(r'keyence.*$', s)]
print('YES' if any(a) else 'NO')

Submission status: Accepted

Solution code:
S = input()

if S[0] != "k":
    if S[-7:] == "keyence":
        print("YES")
    else:
        print("NO")

elif S[-1] != "e":
    if S[:7] == "keyence":
        print("YES")
    else:
        print("NO")

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