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:
import re

kwd = "keyence"
S = input()

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

judge = "NO"

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

print(judge)

Submission status: Accepted

Solution code:
S = input()

if "keyence" in S:
    if S[0:7] == "keyence" or S[-7:] == "keyence":
        print("YES")
    else:
        print("NO")
    exit()

s = "keyence"

for i in range(1,len(s)):
    if S[:i] == s[:i] and S[-(7-i):] == s[-(7-i):]:
        print("YES")
        exit()
print("NO")

Submission status: Accepted

Solution code:
S=list(input())
str1=""
str2=""
flag=0
for i in range(7):
    str1+=S[i]
    str2+=S[len(S)-7]

if str1=="keyence"or str2=="keyence":
    flag=1
s=""
t=""
for i in range(7):
    for j in range(i):
        s+=S[j]
    for j in range(7-i):
        t+=S[len(S)-7+i+j]
    if s+t=="keyence":
        flag=1
    s=""
    t=""
if flag==1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
n = input()

num = len(n)

flag = False
for i in range(num):
    if n[:i] + n[num + i -7:num] == 'keyence':
        flag = True

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

Submission status: Accepted

Solution code:
import re

s = input()
p1 = '^keyence$'
p2 = '.*'

for i in range(1, 9):
    p = '{0}{1}{2}'.format(p1[:i], p2, p1[i:])
    if re.match(p, s):
        print('YES')
        break
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

def make_pattern():
    template = 'keyence'
    xs = []
    for i in range(len(template) + 1):
        xs.append(template[:i] + '.*' + template[i:])
    
    pat = '^(?:' + '|'.join(xs) + ')$'
    return re.compile(pat)

def main():
    s = input()
    pat = make_pattern()

    m = pat.match(s)
    if m:
        print('YES')
    else:
        print('NO')

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

def check(s):
    n=len(s)
    if n<7:
        print("NO")
    elif n==7:
        if s[0:7]=="keyence":
            print("YES")
        else:
            print("NO")
    
    elif s[0]=="k" and s[n-1]=="e":
        count=0
        for i in range(6):
            if s[0:i+1]+s[n-(7-i-1):n]=="keyence":
                count=1
                
        if count==1:
            print("YES")
        else:
            print("NO")
            
    elif s[0]=="k":
        if s[0:7]=="keyence":
            print("YES")
        else:
            print("NO")
            
    elif s[n-1]=="e":
        if s[n-7:n]=="keyence":
            print("YES")
        else:
            print("NO")
        
    else:
        print("NO")

check(s)

Submission status: Accepted

Solution code:
S = input()

keyence = 'keyence'
new = S
if S.startswith(keyence) or S.endswith(keyence):
    print('YES')
    exit()
else:
    for char in S:
        if char == keyence[0]:
            new = new[1:]
            keyence = keyence[1:]
        else:
            break
if new.endswith(keyence):
    print('YES')
    exit()
print('NO')

Submission status: Accepted

Solution code:
S = input()
T = "keyence"
lens = len(S)
if lens == 7:
    if S == "keyence": print("YES")
    else: print("NO")
else:
    insert = lens - 7
    for i in range(8):
        if S[:i] == T[:i] and S[insert+i:] == T[i:]:
            print("YES")
            break
    else: print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

n = len(str)

for i in range(8):
    edit = str[0:i] + str[n - 7 + i:]
    if edit == ['k', 'e', 'y', 'e', 'n', 'c', 'e']:
        print('YES')
        sys.exit()
print('NO')

Submission status: Accepted

Solution code:
S=input()
check=0


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

for i in range(8):
  moji=S[i:len(S)-7+i]
  if S[:i]+S[len(S)-7+i:]=='keyence':
    print('YES')
    exit()

print('NO')

Submission status: Accepted

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

ans='NO'
for i in range(len(S)):
  if S[:i]+S[i+len(S)-7:]==key_:
    ans='YES'
    break

print(ans)

Submission status: Accepted

Solution code:
s = input()

if s == "keyence":
    print("YES")
    exit()

for i in range(len(s)):
    for j in range(i, len(s)):
        if i == 0:
            if j < len(s) - 1:
                ans = s[j+1:]
            else:
                ans = ""
        else:
            if j < len(s) - 1:
                ans = s[:i] + s[j+1:]
            else:
                ans = s[:i]
        if ans == 'keyence':
            print("YES")
            exit()

print("NO")

Submission status: Accepted

Solution code:
s = list(input())
k = list("keyence")

if s == k:
    print("YES")
    exit()

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

Submission status: Accepted

Solution code:
s = list(input())
flag = False
for i in range(len(s)):
    for j in range(i,len(s)+1):
        t = s[:]
        del t[i:j]
        if "".join(t) == 'keyence':
            flag = True
if flag:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input()
ok = False
string = 'keyence'
j = 0
ok = False
for i in range(len(s)):
    for j in range(len(s)):
        if s[0:i]+s[j:len(s)] == string:
            ok = True
if string in s:
    ok = True

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

Submission status: Accepted

Solution code:
s = list(input())
ans = list('keyence')
for i in s:
    if i == ans[0]:
        ans.pop(0)
    else:
        idx = i
        break

if ans == s[::-1][:len(ans)][::-1]:
    print('YES')
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys

S = input()

keyence = 'keyence'

for i in range(8):
    # print(S[:i],S[len(S)+i-7:])
    if S[:i] == keyence[:i] and S[len(S)+i-7:] == keyence[i-7:]:
        print('YES')
        sys.exit()
        
print('NO')

Submission status: Accepted

Solution code:
S = input()
c = 0
for i, s in enumerate("keyence"):
    if s == S[i]:
        c += 1
    else:
        break
S = S[::-1]
for i, s in enumerate("keyence"[::-1]):
    if s == S[i]:
        c += 1
    else:
        break

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

Submission status: Accepted

Solution code:
# coding: utf-8

def main():
    S = input()
    target = "keyence"

    if len(S) >= 7 and S[0:7] == "keyence":
        return "YES"

    for i in range(len(S)):
        if S[i] != target[i]:
            itti_len = i
            break

    latter = target[itti_len:7]

    if S[len(S)-(7-itti_len):len(S)] == latter:
        return "YES"
    else:
        return "NO"


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# B
# 
# input
s = input()
# calc
if s[0:7] == 'keyence' or s[-7:] == 'keyence':
  print('YES')
elif s[0:1]+s[-6:] == 'keyence':
  print('YES')
elif s[0:2]+s[-5:] == 'keyence':
  print('YES')
elif s[0:3]+s[-4:] == 'keyence':
  print('YES')  
elif s[0:4]+s[-3:] == 'keyence':
  print('YES')
elif s[0:5]+s[-2:] == 'keyence':
  print('YES')  
elif s[0:6]+s[-1:] == 'keyence':
  print('YES')
else:
  print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

s = input()

f = True
ac = 'keyence'
i = 0
j = 0

while i < len(s):
    if j == len(ac):
        break
    if s[i] == ac[j] and f:
        i += 1
        j += 1
    elif f:
        k = 1
        l = 1
        while abs(l) < len(ac) - j + 1:
            if s[len(s) - k] == ac[len(ac) - l]:
                k += 1
                l += 1
            else:
                print('NO')
                sys.exit()
        break
    else:
        print('NO')
        sys.exit()

print('YES')

Submission status: Accepted

Solution code:
x = input()
l = len(x)
flag = 0
for i in range(l):
    for j in range(l):
        res = x[0:i] + x[j:l]
        if(res == 'keyence'):
            flag = 1
if(flag == 1):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
import sys
s = input()
l =[['k','eyence'],['ke','yence'],['key','ence'],['keye','nce'],['keyen','ce'],['keyenc','e']]

if s.startswith('keyence') or s.endswith('keyence'):
    print('YES')
else:
    for i in l:
        tmps = s
        if s.startswith(i[0]) and s.endswith(i[1]):
            print('YES')
            sys.exit(0)
    else:
        print('NO')

Submission status: Accepted

Solution code:
def main():
    S = input()
    if S[0] != 'k':
        if S[-7:] == 'keyence':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[1] != 'e':
        if S[-6:] == 'eyence':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[2] != 'y':
        if S[-5:] == 'yence':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[3] != 'e':
        if S[-4:] == 'ence':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[4] != 'n':
        if S[-3:] == 'nce':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[5] != 'c':
        if S[-2:] == 'ce':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[6] != 'e':
        if S[-1:] == 'e':
            print('YES')
            return
        else:
            print('NO')
            return
    print('YES')


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=input()
if len(S)==7:
  if S=="keyence":
    print("YES")
  else:
    print("NO")
else:
  l=len(S)-7
  flg=False
  for i in range(1,8):
    s=S[0:i]+S[i+l:]
    if s=="keyence":
      flg=True
      break
  if flg:
    print("YES")
  else:
    print("NO")

Submission status: Accepted

Solution code:
S = input()
sample = "keyence"
flag = 0
num = 0
for i in range(7):
    if S[i] == sample[i]:
        num += 1
    else:
        break
if num == 7:
    print("YES")
elif sample[num:] == S[-(7 - num):]:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s=input()
l=['k','e','y','e','n','c','e']
flag=False
cnt=0
for i in range(7):
    if flag==False and s[i]==l[i]:
        cnt+=1
    else:
        flag=True
        if s[-(7-i)]==l[i]:
            cnt+=1
if cnt==7:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = input()
WORD = "keyence"

if S == WORD:
    print("YES")
    exit()

for s in range(len(S)):
    for e in range(s,len(S)+1):
        a = S[:s]
        sub = S[s:e]
        b = S[e:]
        # print(a)
        # print(sub)
        # print(b)
        if a+b == WORD:
            print("YES")
            exit()

print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
p=list("keyence")
if s==p:
    print("YES")
else:
    t=len(s)-7
    for i in range(7):
        h=s[:i]+s[i+t:]
        if h==p:
            print("YES")
            break
    else:
        print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

A = ["","k","ke","key","keye","keyen","keyenc","keyence"]
B = ["keyence","eyence","yence","ence","nce","ce","e",""]
ans = "NO"
for i in range(len(A)) :
    if S[:len(A[i])] + S[-len(B[i]):] == "keyence" :
        ans = "YES"

print(ans)

Submission status: Accepted

Solution code:
S = input()
keyence = "keyence"
if S.split()[0] == keyence:
    print("YES")
for idx, (s, k)  in enumerate(zip(S, keyence)):
    if s==k:
        continue
    else:
        nokori = keyence[idx:]
        if S[-len(nokori):] == nokori:
            print("YES")
            break
        else:
            print("NO")
            break

Submission status: Accepted

Solution code:
S = input()
w = 'keyence'
n = len(w)
N = len(S)
ch = 0
if 'keyence' in S and len(S) == len('keyence'):
    ch = 1

elif S[:3] == 'key' and S[-4:] == 'ence':
    ch = 1

elif S[:1] == 'k' and S[-6:] == 'eyence':
    ch = 1

elif S[:2] == 'ke' and S[-5:] == 'yence':
    ch = 1
elif S[:4] == 'keye' and S[-3:] == 'nce':
    ch = 1
elif S[:5] == 'keyen' and S[-2:] == 'ce':
    ch = 1
elif S[:6] == 'keyenc' and S[-1:] == 'e':
    ch = 1

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

Submission status: Accepted

Solution code:
s=input()
f = 0
if s[:7] == 'keyence':
    f = 1
elif s[-7:] == 'keyence':
    f = 1
else:
    for i in range(7):
        if s[:i]+s[-7+i:] == 'keyence':
            f = 1
            break
if f == 1:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
s = input()

ans="NO"
if s[0:7]=="keyence":
  ans="YES"
elif s[-8:-1]=="keyence":
  ans="YES"
elif s[0:1]=="k" and s[-6:]=="eyence":
  ans="YES"
elif s[0:2]=="ke" and s[-5:]=="yence":
  ans="YES"
elif s[0:3]=="key" and s[-4:]=="ence":
  ans="YES"
elif s[0:4]=="keye" and s[-3:]=="nce":
  ans="YES"
elif s[0:5]=="keyen" and s[-2:]=="ce":
  ans="YES"
elif s[0:6]=="keyenc" and s[-1:]=="e":
  ans="YES"

print(ans)

Submission status: Accepted

Solution code:
S = input()

ans = False

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

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

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
import re
sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    K = 'keyence'
    if S == K:
        return 'YES'
    if re.fullmatch('[a-z]+'+K, S):
        return 'YES'
    if re.fullmatch(K+'[a-z]+', S):
        return 'YES'

    for i in range(len(K)):
        if re.fullmatch(K[:i]+'[a-z]+'+K[i:], S):
            return 'YES'

    return 'NO'


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
str = input()
n = len(str)
flag = "NO"
for i in range(8):
	buf = str[:i]+str[n-7+i:]
	if(buf == "keyence"):
		flag = "YES"
	#print(str[n-i-7:])
print(flag)

Submission status: Accepted

Solution code:
S = input()


x = "keyence"

if S[:7] == x:
    print("YES")
    exit()

for i in range(0,len(x)):
    if S[:i]== x[:i] and S[-(7-i):] == x[i:] :
        print("YES")
        exit()
    # tr:
    #     index1 = S.index(x[:i])
    #     index2 = S.rindex(x[i:])
    #     print(index1,index2)
    #     if index1==0 and index2+i == len(S) and index1<index2:
    #         print(index1,index2)
    #         print("YES")
    #         exit()
    # except ValueError:
    #     continue
print("NO")

Submission status: Accepted

Solution code:
N = str(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
N = len(s)
k = "keyence"
K = len(k)
flag = False
if s[N - K:] == k:
    print("YES")
    exit()
if s[:K] == k:
    print("YES")
    exit()

for i in range(1, K):
    if s[:i] == k[:i] and s[N - (K - i):] == k[K - (K - i):]:
        print("YES")
        exit()

print("NO")

Submission status: Accepted

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

from itertools import product
ans = 'NO'
for start, end in product(range(len(s)), range(len(s))):
    if start > end:
        continue
    else:
        temp = s[:start] + s[end:]
        if true == temp:
            ans = 'YES'
            break
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
l = list("keyence")
ans = "NO"
for i in range(len(s)):
    for j in range(len(s)-i):
        #del_s = s[i:i+j]
        part = s[:i] + s[i+j:]
        if part == l:
            ans = "YES"
            break
print(ans)

Submission status: Accepted

Solution code:
#s = list(map(int, input().split()))
s = input()
yojou = len(s) - 7

for i in range(yojou + 2):
    # print(s[0:i] + s[i + yojou:])
    if s[0:i] + s[i + yojou:] == 'keyence':
        print("YES")
        exit(0)
print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
if s=="keyence":
	print("YES")
	quit()
for i in range(len(s)):
	for p in range(i,len(s)):
		if i==0 and p==len(s)-1:
			continue
		if i==0:	
			t=s[p+1]
			if t=="keyence":
				print("YES")
				quit()
		if p==len(s)-1:
			t=s[:i]
			if t=="keyence":
				print("YES")
				quit()
		t=s[:i]+s[p+1:]
		if t=="keyence":
				print("YES")
				quit()
print("NO")

Submission status: Accepted

Solution code:
S = input()
N = len(S)
if S == "keyence" or S[1:] == "keyence" or S[:N-1] == "keyence":
    print("YES")
    exit(0)

for k in range(N):
    for l in range(k,N):
        if S[:k]+S[l+1:] == "keyence":
            print("YES")
            exit(0)
print("NO")

Submission status: Accepted

Solution code:
A=input()
char=len(A)-7
flag=0

if A[:7]=="keyence":
    flag=1

for i in range(len(A)-char):
    if A[:i]+A[i+char:]=="keyence":
        flag=1
    #print(A[:i]+A[i+char:])
if flag==1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
a = input()
minus = len(a)-7
check = 0
for i in range(len(a)-minus+1):
  tmp = a[0:i] + a[i+minus:]
  if tmp == 'keyence':
    check = 1
    break
if check == 1:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
S = input()
res = 'NO'
for s in range(len(S)):
    for t in range(len(S)):
        #print(S[:s] + S[s+t:])
        if S[:s] + S[t+1:] == 'keyence':
            res = 'YES'
print(res)

Submission status: Accepted

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

import re

def solve():
    S = input()
    k = 'keyence'
    res = any(re.fullmatch(k[:i]+'.*'+k[i:], S) for i in range(len(k)+1))
    if res:
        res = 'YES'
    else:
        res = 'NO'
    return str(res)

if __name__ == '__main__':
    print(solve())

Submission status: Accepted

Solution code:
import re
S = input()

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
lens = len(s)
ans = False
keyence = "keyence"


for i in range(0,8):
    if s[:i] == keyence[:i] and s[i+lens-7:] == keyence[i:]:
        ans = True
            
print("YES") if ans else print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
r = "keyence"
flag = False
for i in range(len(r)):
    if r[0:i] == s[0:i] and s[-1 * (7-i):] == r[-1 * (7-i):]:
        flag = True

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

Submission status: Accepted

Solution code:
S = input()
#N = int(input())
#N = list(map(int, input().split()))
# a = list(map(int, input().split()))
# X = [int(input()) for _ in range(N)]

ans = 'YES'
keyence = 'keyence'

for i in range(len(S)):
    if i == 7:
        S = S[0:7]
        break
    if keyence[i] == S[i]:
        continue
    else:
        S = S[0:i] + S[len(S) - 1 - 6 + i :]
        break


if S == keyence:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
S = list(input())

S_rev = S[::-1]

key_front = [False] * 7

key_back = [False] * 7

s_key = ["k", "e", "y", "e", "n", "c", "e"]
s_key_rev = s_key[::-1]

i = 0
while S[i] == s_key[i] and i < 6:
    key_front[i] = True
    i += 1

i = 0
while S_rev[i] == s_key_rev[i] and i < 6:
    key_back[i] = True
    i += 1
ans = 0
for b in key_front:
    if b:
        ans += 1
for b in key_back:
    if b:
        ans += 1

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

Submission status: Accepted

Solution code:
s = list(input())
t = "keyence"
a = i = 0

while True:
    if len(s) == i:
        break
    
    if s[i] == t[i]:
        a += 1
    else:
        break
    i += 1

i = len(s) - 1
o = len(t) - 1

while True:
    if a == len(t):
        break
    
    if s[i] == t[o]:
        a += 1
    else:
        break
    i -= 1
    o -= 1

if a == len(t):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = [i  for i in input()]
left = ["k", "e", "y", "e", "n", "c", "e"]
right = ["e", "c", "n", "e", "y", "e", "k"]
num = 0
for i in range(7):
    if(s[i] == left[i]):
        num += 1
s = list(reversed(s))
for i in range(7):
    if(s[i] == right[i]):
        num += 1
if(num>=7):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
k = 'keyence'
a = input()
b = a.split(k)
if k in a:
    if all(b):
        print('NO')
    else:
        print('YES')
else:
    for i in range(1,7):
        if k[:i] == a[:i] and k[i-7:] == a[i-7:]:
            print('YES')
            break
    else:
        print('NO')

Submission status: Accepted

Solution code:
S = input()
flag = 0
if S == "keyence":
    flag = 1
for i in range(len(S)-3):
    if str(S[:i]) + str(S[(-1)*(7-i):]) == "keyence":
        flag = 1
if flag == 1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
k="keyence"
S=input()
check=0
for i in range(7):
  if k[i]!=S[i]:
    for j in range(-1,-8+i,-1):
      if k[j]!=S[j]:
        check=1
        break
    break
if check==0:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
# encoding: utf-8
S = input()
target = 'keyence'

for i in range(1, len(S)):
    tarl = target[:i]
    tarr = target[i:]
    if S.startswith(tarl) and S.endswith(tarr):
        print('YES')
        break
    else: continue
else:
    print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
s = input()

r1 = '^.*keyence$'
r2 = '^k.*eyence$'
r3 = '^ke.*yence$'
r4 = '^key.*ence$'
r5 = '^keye.*nce$'
r6 = '^keyen.*ce$'
r7 = '^keyenc.*e$'
r8 = '^keyence.*$'

if re.match(r1, s) or re.match(r2, s) or re.match(r3, s) or re.match(r4, s) or re.match(r5, s) or re.match(r6, s) or re.match(r7, s) or re.match(r8, s):
    print("YES")
else :
    print("NO")

Submission status: Accepted

Solution code:
s = input()

keyence = 'keyence'

for index, char in enumerate(s):
    if char!=keyence[0]:
        break
    keyence = keyence[1:]

keyence = keyence[::-1]
for index, char in enumerate(s[::-1]):
    if keyence and char!=keyence[0]:
        break
    keyence = keyence[1:]
    
if not keyence:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
import re

s = input()
t = 'keyence'

for i in range(len(t)):
    ptn = '^' + t[:i] + '.*' + t[i:] + '$'
    # print(ptn)
    m = re.match(ptn, s)
    if m: break

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

Submission status: Accepted

Solution code:
s = input()

if s.startswith('k') and s.endswith('eyence'):
  print('YES')
elif s.startswith('ke') and s.endswith('yence'):
  print('YES')
elif s.startswith('key') and s.endswith('ence'):
  print('YES')
elif s.startswith('keye') and s.endswith('nce'):
  print('YES')
elif s.startswith('keyen') and s.endswith('ce'):
  print('YES')
elif s.startswith('keyenc') and s.endswith('e'):
  print('YES')
else:
  print('NO')