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:
# B - KEYENCE String
S = input()
K = list('keyence#')
count = 0
idx_k = 0
is_NG = False

for s in S:
    if K[idx_k]==s:
        if idx_k<7:
            idx_k += 1
        is_NG = False
    else:
        if not is_NG:
            count +=1
            is_NG = True
    
    if count>=2:
        break
  
if count<=1 and idx_k>=6:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# B - KEYENCE String
S = input()
K = list('keyence')
count = 0
idx_k = 0
is_NG = False

for s in S:
    if K[idx_k]==s:
        if idx_k<6:
            idx_k += 1
        is_NG = False
    else:
        if not is_NG:
            count +=1
            is_NG = True
    
    if count>=2:
        break
  
if count<=1 and idx_k==6:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=list(input())
ans=''
cnt='NO'
for i in range(len(s)):
    if ans=='' and s[i]=='k':
        ans+=s[i]
    if ans=='k' and s[i]=='e':
        ans+=s[i]
    if ans=='ke' and s[i]=='y':
        ans+=s[i]
    if ans=='key' and s[i]=='e':
        ans+=s[i]
    if ans=='keye' and s[i]=='n':
        ans+=s[i]
    if ans=='keyen' and s[i]=='c':
        ans+=s[i]
    if ans=='keyenc' and s[i]=='e':
        ans+=s[i]
    if ans=='keyence':
        cnt='YES'
print(cnt)

Submission status: Wrong Answer

Solution code:
s=list(input())
ans=''
cnt='NO'
for i in range(len(s)):
    if ans=='' and s[i]=='k':
        ans+=s[i]
    elif ans=='k' and s[i]=='e':
        ans+=s[i]
    elif ans=='ke' and s[i]=='y':
        ans+=s[i]
    elif ans=='key' and s[i]=='e':
        ans+=s[i]
    elif ans=='keye' and s[i]=='n':
        ans+=s[i]
    elif ans=='keyen' and s[i]=='c':
        ans+=s[i]
    elif ans=='keyenc' and s[i]=='e':
        ans+=s[i]
    if ans=='keyence':
        cnt='YES'
print(cnt)

Submission status: Wrong Answer

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


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


def solve(S):
    key = 'keyence'
    for k in key:
        while S and S[0] != k:
            S = S[1:]
        if not S:
            return False
        S = S[1:]
    return True


if solve(S):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
print(
	"YES" if any(
      s[:i] + s[j:]
      for i in range(len(s))
      for j in range(len(s))
      if i <= j) else
  	"NO"
)

Submission status: Wrong Answer

Solution code:
def main():
  import re
  s=input()
  k="keyence"
  if len(s)<7:
    print("NO")
    return
  if s[:7]==k or s[-7:]==k:
    print("YES")
    return
  for i in range(1,7):
    if re.match(k[:i]+".*"+k[i:],s):
      print("YES")
      return
  print("NO")
main()

Submission status: Wrong Answer

Solution code:
def main():
  import re
  s=input()
  k="keyence"
  if s[:7]==k or s[-7:]==k:
    print("YES")
    return
  for i in range(1,7):
    if re.match(k[:i]+".*"+k[i:],s):
      print("YES")
      return
  print("NO")
main()

Submission status: Wrong Answer

Solution code:
s = input()
key = "keyence"
j = 0
counter = 0
judge = []
word = key[j]
for i in range(len(s)):
    if s[i] == key[j]:
        j +=1
    else:
        judge.append(i)
    if j == 7:
        break

for i in range(len(judge) - 1):
    if judge[i+1] - judge[i] > 1:
        counter +=1

if j == 7 and counter == 0:            
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
key = "keyence"
j = 0
counter = 0
judge = []
word = key[j]
for i in range(len(s)):
    if s[i] == key[j]:
        j +=1
    else:
        judge.append(i)
    if j == 7:
        break

for i in range(len(judge) - 1):
    if judge[i+1] - judge[i] > 1:
        counter +=1

if j == 7 and counter <= 1:            
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
key = "keyence"
j = 0
word = key[j]
for i in range(len(s)):
    if s[i] == key[j]:
        j +=1
    if j == 7:
        break
if j == 7:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

keyence = 'keyence'
flag = 0
k_i = 0
en = ""
en_list = []

for i in range(len(s)):
    if s[i] == keyence[k_i]:
        k_i += 1
        if k_i >= len(keyence)-1:
            break
        flag = 1
        if en != "":
            en_list.append(en)
            en = ""
    else:
        en += s[i]
if en != "":
    en_list.append(en)
if len(en_list) <= 1 and flag:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

keyence = 'keyence'
flag = 0
k_i = 0
en = ""
en_list = []

for i in range(len(s)):
    if s[i] == keyence[k_i]:
        k_i += 1
        if k_i >= len(keyence)-1:
          break
        flag = 1
        if en != "":
            en_list.append(en)
            en = ""
    else:
        en += s[i]

if len(en_list) <= 1 and flag:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
if s[:3]!="key":
    if s[-7:]=="keyence":
        print("YES")
    else:
        print("NO")
elif s[:7]=="keyence":
    print("YES")
elif s[-4:]=="ence":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S=input()
T="keyence"
ans=0
for i in range(8):
  X=1
  K=0
  for j in range(len(S)-i):
    if(j<i or j>i+len(S)-6):
      if(S[K]!=T[K]):
        X*=0
      K+=1
  ans+=X
if(ans):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S=input()
T="keyence"
ans=0
for i in range(8):
  X=1
  K=0
  for j in range(len(S)-i):
    if(j<i or j>i+len(S)-i-1):
      if(S[K]!=T[K]):
        X*=0
      K+=1
  ans+=X
if(ans):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
l = []
i = 0

for w in 'keyence':
    if w in s:
        i += s[i:].find(w)
        l.append(i)
        i += 1

if len(l) == len('keyence') and l== sorted(l):
    cnt = 0
    for i in range(len(l)-1):
        if l[i+1] - l[i] > 1:
            cnt += 1
    if cnt <= 1:
        print('YES')
        exit()

print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
l = []
i = 0

for w in 'keyence':
    if w in s:
        i += s[i:].find(w)
        l.append(i)
        i += 1

if len(l) == len('keyence') and l== sorted(l):
    cnt = 0
    for i in range(len(l)-1):
        if l[i+1] - l[i] > 1:
            cnt += 1
    if cnt < 2:
        print('YES')
        exit()

print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
l = []
i = 0

for w in 'keyence':
    if w in s:
        i += s[i:].find(w)
        l.append(i)
        i += 1

if len(l) == len('keyence') and l== sorted(l):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
from collections import Counter
a=Counter(input())
print("YES" if sum(a[i]==0 for i in "keync")==0 and a["e"]>2 else "NO")

Submission status: Wrong Answer

Solution code:
s = input()

ans = 'keyence'

for i in range(len(s)):
    if s[i]==ans[0]:
        ans=ans[1:]
        if ans=='':
            break
if ans=='':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

for j in range(len(S)):
    for i in range(7):
        left = K[:i]
        right = K[i:]
        if left in S[:j] and right in S[j:]:
            print('YES')
            exit()

print('NO')

Submission status: Wrong Answer

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

for i in range(7):
    left = K[:i]
    right = K[i:]
    if left in S and right in S:
        print('YES')
        exit()

print('NO')

Submission status: Wrong Answer

Solution code:
S = str(input())
for i in range(8):
    word = S[:i]+S[-7:][i:]
    if word == "keyence":
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():

    S = input()
    if S[:7] == "keyence" or S[-7:] == "keyence":
        return "YES"
    elif S[:3] == "key" and S[-4:] == "ence":
        return "YES"
    return "NO"


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

Submission status: Wrong Answer

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

for i in range(len(ans)):
    left=ans[:i]
    right=ans[i:]
    if ((left in s) and (right in s)) and (s.index(left)<=s.index(right)):
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

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

for i in range(len(ans)):
    left=ans[:i]
    right=ans[i:]
    if ((left in s) and (right in s)) and (s.index(left)<s.index(right)):
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

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

for i in range(len(ans)):
    left=ans[:i]
    right=ans[i:]
    if (left in s) and (right in s):
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
pp="keyence"
j=0
cnt=0
p=0
for i in range(len(s)):
	if s[i]==pp[j]:
		j+=1
		if cnt==1:
			p=1
			cnt=0
	else:
		cnt=1
		if p==1:
			p=2
			break
	if j==6:
		if p==0:
			break
		else:
			if i==len(s)-1:
				break
			else:
				p=2
				break
if j==6 and p<=1:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
pp="keyence"
j=0
cnt=0
p=0
for i in range(len(s)):
	if s[i]==pp[j]:
		j+=1
		if cnt==1:
			p=1
			cnt=0
	else:
		cnt=1
		if p==1:
			p=2
			break
	if j==6:
		break
if j==6 and p<=1:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
p="keyence"
j=0
cnt=0
x=0
for i in range(len(s)):
	if s[i]==p[j]:
		j+=1
		if cnt==1:
			x+=1
			cnt=0
	else:
		cnt=1
		if x==1:
			x+=1
			break
	if j==6:
		break
if j==6 and x<=1:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
p="keyence"
j=0
cnt=0
x=0
for i in range(len(s)):
	if s[i]==p[j]:
		j+=1
		if cnt==1:
			x+=1
	else:
		cnt+=1
		if x==1:
			break
	if j==6:
		break
if j==6 and x==0:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
p="keyence"
j=0
for i in range(len(s)):
	if s[i]==p[j]:
		j+=1
	if j==6:
		break
if j==6:
	print("YES")
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s = input(); print("YES") if s[0:3] == "key" and s[-4:-1]+s[-1] == "ence" else print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

key = "keyence"
ans = True
r = -1

for i in range(len(S)):
    if not key and r != -1:
        ans = False
        break
    if S[i] == key[0]:
        key = key[1:]
    else:
        if r == -1:
            r = i
        elif i - r == 1:
            r = i
        else:
            ans = False
            break
if key:
    ans = False


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

Submission status: Wrong Answer

Solution code:
S = input()
target_S = "keyence"
 
if S.startswith(target_S) or S.endswith(target_S):
    print("YES")
else:
    for i in range(len(target_S)):
        target_left = target_S[:i]
        target_right = target_S[i:]
        
        if S.startswith(target_left) and S.endswith(target_right):
            print("YES")
            break

Submission status: Wrong Answer

Solution code:
from re import fullmatch
S = input()
_s = "keyence"
flag = False
for i in range(len(_s)):
    if fullmatch(".*" + _s[:i] + ".*" + _s[i:] + ".*", S):
        flag = True
print("YES") if flag else print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
a = 0
for i in range(1,len(s)-1):
    if s[i-1] == "k" and s[i] == "e" and s[i+1] == "y":
        a += 1
        break

for j in range(1,len(s)-1):
    if s[j-1] == "e" and s[j] == "n" and s[j+1] == "c" and s[j+2] == "e":
        a += 1
        break

if a == 2:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
def resolve():
    s = input()
    key = "keyence"
    if key in s:
        print("YES")
        return 0
    for i in range(1, len(key)):
        k1, k2 = key[:i], key[i:]
        if s.find(k1) < s.find(k2):
            print("YES")
            return 0
    print("NO")
    return 0


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
S = input()
key = "keyence"
ans = "No"
for i in range(len(S)):
    for j in range(i,len(S)):
        #print(S[:i]+S[j:])
        if S[:i] + S[j:] == key:
            ans = "Yes"
print(ans)

Submission status: Wrong Answer

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

k = "keyence"

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

print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
t='keyence'
i,j=0,0
co=0
while(i<len(s) and j<7):
    if(s[i]==t[j]):
        j+=1
        if co==1:
            co=2
    else:
        if(co==2):
            break
        elif co==1:
            pass
        else:
            co+=1
    i+=1
if(j==7):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
t='keyence'
i,j=0,0
while(i<len(s) and j<7):
    if(s[i]==t[j]):
        j+=1
        i+=1
    else:
        i+=1
if(j==7):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
t='keyence'
i,j=0,0
while(i<len(s) and j<7):
    if(s[i]==t[j]):
        j+=1
    else:
        i+=1
if(j==7):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = list(input())
keyword = list('keyence')

cur = 0
ans = "NO"
while cur < len(S):
    target = keyword[0]
    if S[cur] == target:
        keyword.pop(0)
    if len(keyword) == 0:
        ans = "YES"
        break
    cur += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
ans="No"
for i in range(8):
  T=S[:i]+S[len(S)-(7-i):]
  if T=='keyence':
    ans="Yes"
    break
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
a = str(input())
nums = {"k":1,"e":3,"y":1,"n":1,"c":1}
temp = Counter(a)
good = True
for letter in nums.keys():
    if temp[letter] < nums[letter]:
        good = False
if good:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

S = input()
N = len(S)

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

if N==7:
  print('NO')
  exit()

for l in range(N - 6):
  if S[l:l+6]=='keyenc' and 'e' in S[l+6:N]:
    print('YES')
    exit()

for l in range(N - 6):
  if S[l:l+5]=='keyen' and 'ce' in S[l+5:N]:
    print('YES')
    exit()

for l in range(N - 6):
  if S[l:l+4]=='keye' and 'nce' in S[l+4:N]:
    print('YES')
    exit()

for l in range(N - 6):
  if S[l:l+3]=='key' and 'ence' in S[l+3:N]:
    print('YES')
    exit()

for l in range(N - 6):
  if S[l:l+2]=='ke' and 'yence' in S[l+2:N]:
    print('YES')
    exit()

for l in range(N - 6):
  if S[l:l+1]=='k' and 'eyence' in S[l+1:N]:
    print('YES')
    exit()

print('NO')

Submission status: Wrong Answer

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

S = input()
N = len(S)

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

if N==7:
  print('NO')
  exit()

for l in range(N - 7):
  if S[l:l+6]=='keyenc' and 'e' in S[l+6:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+5]=='keyen' and 'ce' in S[l+5:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+4]=='keye' and 'nce' in S[l+4:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+3]=='key' and 'ence' in S[l+3:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+2]=='ke' and 'yence' in S[l+2:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+1]=='k' and 'eyence' in S[l+1:N]:
    print('YES')
    exit()

print('NO')

Submission status: Wrong Answer

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

S = input()
N = len(S)

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

if N==7:
  print('NO')
  exit()

for l in range(N - 7):
  if S[l:l+6]=='keyenc' and 'e' in S[l+7:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+5]=='keyen' and 'ce' in S[l+6:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+4]=='keye' and 'nce' in S[l+5:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+3]=='key' and 'ence' in S[l+4:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+2]=='ke' and 'yence' in S[l+3:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+1]=='k' and 'eyence' in S[l+2:N]:
    print('YES')
    exit()

print('NO')

Submission status: Wrong Answer

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

S = input()
N = len(S)

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

if N==7:
  print('NO')
  exit()

for l in range(N - 8):
  if S[l:l+6]=='keyenc' and 'e' in S[l+7:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+5]=='keyen' and 'ce' in S[l+6:N]:
    print('YES')
    exit()

for l in range(N - 6):
  if S[l:l+4]=='keye' and 'nce' in S[l+5:N]:
    print('YES')
    exit()

for l in range(N - 5):
  if S[l:l+3]=='key' and 'ence' in S[l+4:N]:
    print('YES')
    exit()

for l in range(N - 4):
  if S[l:l+2]=='ke' and 'yence' in S[l+3:N]:
    print('YES')
    exit()

for l in range(N - 3):
  if S[l:l+1]=='k' and 'eyence' in S[l+2:N]:
    print('YES')
    exit()

print('NO')

Submission status: Wrong Answer

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

S = input()
N = len(S)

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

if N==7:
  print('NO')
  exit()

for l in range(N - 8):
  if S[l:l+6]=='keyenc' and 'e' in S[l+7:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+5]=='keyen' and 'ce' in S[l+6:N]:
    print('YES')
    exit()

for l in range(N - 6):
  if S[l:l+4]=='keye' and 'nce' in S[l+5:N]:
    print('YES')
    exit()

for l in range(N - 5):
  if S[l:l+3]=='key' and 'ence' in S[l+4:N]:
    print('YES')
    exit()

for l in range(N - 4):
  if S[l:l+2]=='ke' and 'yence' in S[l+3:N]:
    print('YES')
    exit()

for l in range(N - 8):
  if S[l:l+1]=='k' and 'eyence' in S[l+2:N]:
    print('YES')
    exit()

print('NO')

Submission status: Wrong Answer

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

S = input()
N = len(S)

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

if N==7:
  print('NO')
  exit()

for l in range(N - 8):
  if S[l:l+6]=='keyenc' and 'e' in S[l+7:N]:
    print('YES')
    exit()

for l in range(N - 7):
  if S[l:l+5]=='keyen' and 'ce' in S[l+6:N]:
    print('YES')
    exit()

for l in range(N - 6):
  if S[l:l+4]=='keye' and 'nce' in S[l+5:N]:
    print('YES')
    exit()

for l in range(N - 5):
  if S[l:l+3]=='key' and 'ence' in S[l+4:N]:
    print('YES')
    exit()

for l in range(N - 4):
  if S[l:l+2]=='ke' and 'yence' in S[l+3:N]:
    print('YES')
    exit()

for l in range(N - 8):
  if S[l:l+1]=='k' and 'ce' in S[l+2:N]:
    print('YES')
    exit()

print('NO')

Submission status: Wrong Answer

Solution code:
s = input().rstrip()
k = "keyence"
for i in range(1, 7):
    if k[:i] in s and k[i:] in s:
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
if "k" in s and "y" in s and "n" in s and "c" in s and s.count("e")>=3:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S=input()
k='keyence'
for i in range(1,7):
    if S.find(k[:i]) != -1 and S.rfind(k[i:]) != -1 and S.find(k[:i]) < S.rfind(k[i:]):
        print('YES')
        exit()
print('NO')

Submission status: Wrong Answer

Solution code:
# keyence2019B - KEYENCE String
def main():
    S = input()
    K = "keyence"
    for i in range(1, 7):
        a, b = K[:i], K[i:]
        if a in S and b in S:
            print("YES")
            break
    else:
        print("NO")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
s=input()
l=len(s)-7
if l<0:
    print('NO')
    sys.exit()
for i in range(7):
    print(s[:i]+s[i+l:])
    if s[:i]+s[i+l:]=='keyence':
        print('YES')
        sys.exit()
if s[:7]=='keyence':
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
s=input()
l=len(s)-7
if s[:7]=='keyence':
    print('YES')
    sys.exit()
if l<=0:
    print('NO')
    sys.exit()
for i in range(l):
#    print(s[:i]+s[i+l:])
    if s[:i]+s[i+l:]=='keyence':
        print('YES')
        sys.exit()
print('NO')

Submission status: Wrong Answer

Solution code:
import sys
s=input()
l=len(s)-7
if s=='keyence':
    print('YES')
    sys.exit()
if l<=0:
    print('NO')
    sys.exit()
for i in range(l):
#    print(s[:i]+s[i+l:])
    if s[:i]+s[i+l:]=='keyence':
        print('YES')
        sys.exit()
print('NO')

Submission status: Wrong Answer

Solution code:
import sys
s=input()
l=len(s)-7
if s=='keyence':
    print('YES')
    sys.exit()
if l<=0:
    print('NO')
    sys.exit()
for i in range(l):
    print(s[:i]+s[i+l:])
    if s[:i]+s[i+l:]=='keyence':
        print('YES')
        sys.exit()
print('NO')

Submission status: Wrong Answer

Solution code:
import sys
s = list(input())
S = list('keyence')
cur = 0
num = 0
for x in S:
    while x != s[cur]:
        cur += 1
        if cur == len(s):
            print('NO')
            sys.exit()
    cur += 1
print('YES')

Submission status: Wrong Answer

Solution code:
import sys
s = list(input())
S = list('keyence')
cur = 0
num = 0
for x in S:
    while x != s[cur]:
        cur += 1
        if cur == len(s):
            print('NO')
            sys.exit()
print('YES')

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
s=input()
flag=0
for i in range(7):
  if s[:i]+s[-(7-i):]=="keyence":
    flag=1
    break
if s[:7]=="keyence":
  flag=1
if flag==1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s=input()
l=len(s)
flag=0
for i in range(7):
  if s[:i]+s[-(7-i):]=="keyence":
    flag=1
    break
if s[:7]=="keyence":
  flag=1
if flag==1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s = input()
ans = "NO"
ls = len(s)
if s[:7] == "keyence":
    ans = "YES"
elif s[-7:] == "keyence":
    ans = "YES"
else:
    for i in range(6):
        print(s[:i+1],s[ls-6+i:])
        if s[:i+1]+s[ls-6+i:] == "keyence":
            ans = "YES"
print(ans)

Submission status: Wrong Answer

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

s = input()
print(solve(s))

Submission status: Wrong Answer

Solution code:
def solve(s):
    t = "keyence"
    n = len(s)
    m = len(t)
    j = 0
    for i in range(n):
        if (j < m) and (t[j] == s[i]):
            j += 1
    return "YES" if (j == m) else "NO"

s = input()
print(solve(s))

Submission status: Wrong Answer

Solution code:
k = "keyence"
s = input()
j = 0
state = 0
flag = True
for i in range(len(s)):
    if state == 0:
        if s[i] != k[j]:
            state = 1
        else:
            j += 1
    elif state == 1:
        if s[i] == k[j]:
            state = 2
            j += 1
    elif state == 2:
        if s[i] != k[j]:
            flag = False
            break
        else:
            j += 1
    if j == len(k):
        if i == len(s)-1:
            break
        elif state == 0:
            break
        else:
            flag = False
            break
if j != len(k):
    flag = False
if flag:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
k = "keyence"
s = input()
j = 0
state = 0
flag = True
for i in range(len(s)):
    if state == 0:
        if s[i] != k[j]:
            state = 1
        else:
            j += 1
    elif state == 1:
        if s[i] == k[j]:
            state = 2
            j += 1
    elif state == 2:
        if s[i] != k[j]:
            flag = False
            break
        else:
            j += 1
    if j == len(k):
        if i == len(s)-1:
            break
        elif state == 0:
            break
        else:
            flag = False
            break
if state == 1:
    flag = False
if flag:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S=input()
key='keyence'
if S[:7] == key or S[-7:] == key:
    print('YES')
    exit()
for i in range(len(S)):
    if S[i] != key[i]:
        left = i
        break
for i in range(len(S)):
    if S[-i-1] != key[-i-1]:
        right = i
        break
print('YES' if left + right > 7 else 'NO')

Submission status: Wrong Answer

Solution code:
S=input()
key='keyence'
if S[:7] == key or S[-7:] == key:
    print('YES')
    exit()
for i in range(len(S)):
    if S[i] != key[i]:
        left = i
        break
for i in range(len(S)):
    if S[-i-1] != key[-i-1]:
        right = -i
        break
print('YES' if S[:left] + S[right:] == key else 'NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
keyence = 'keyence'
l,r = '',''
for i in range(7):
    l,r = keyence[:i],keyence[i:]
    if l in s and r in s:
        print('YES')
        exit()
print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
keyence = 'keyence'
l,r = '',''
for i in range(7):
    if s[i]==keyence[i]:    l += s[i]
    else:   break
if l == keyence:
    print('YES')
    exit()
for i in range(1,8):
    if s[-i]==keyence[-i]:    r += s[-i]
    else:   break
if r[::-1] == keyence:
    print('YES')
    exit()
if l+r[::-1] == keyence:    print('YES')
else:   print('NO')