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:
s = list(input())
l = len(s)
key = ['k', 'e', 'y', 'e', 'n', 'c', 'e']

if s[0] == key[0]:
    if s[1] == key[1]:
        if s[2] == key[2]:
            if s[3] == key[3]:
                if s[4] == key[4]:
                    if s[5] == key[5]:
                        if s[6] == key[6]:
                            print('YES')
                            exit()
if s[l-7] == key[0]:
    if s[l-6] == key[1]:
        if s[l-5] == key[2]:
            if s[l-4] == key[3]:
                if s[l-3] == key[4]:
                    if s[l-2] == key[5]:
                        if s[l-1] == key[6]:
                            print('YES')
                            exit()

idx = 0
status, cont = True, False
for i in range(len(s)):
    if s[i] == key[idx]:
        if status:
            pass
        else:
            cont = False
        idx += 1
    else:
        if status:
            status, cont = False, True
        else:
            if cont:
                pass
            else:
                print('NO')
                exit()

    if idx == 7:
        print('YES')
        exit()

print('NO')

Submission status: Wrong Answer

Solution code:
s = list(input())

key = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
idx = 0
status, cont = True, False
for i in range(len(s)):
    if s[i] == key[idx]:
        if status:
            pass
        else:
            cont = False
        idx += 1
    else:
        if status:
            status, cont = False, True
        else:
            if cont:
                pass
            else:
                print('NO')
                exit()

    if idx == 7:
        print('YES')
        exit()

print('NO')

Submission status: Wrong Answer

Solution code:
s = list(input())

key = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
idx = 0
for i in range(len(s)):
    if s[i] == key[idx]:
        idx += 1
    if idx == 7:
        print('YES')
        exit()
print('NO')

Submission status: Wrong Answer

Solution code:
# 1
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_a
if False:
    print('YES' if set(input().split())==set(list('1974')) else 'NO')

# 2
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b
if True:
    S=input()
    ans='NO'
    K='keyence'
    for i in range(len(K)):
        l=K[:i]
        r=K[i:]
        # print(l,r)
        if l in S and r in S:
            l_i=S.index(l)
            for j in range(len(S)):
                # print(S[j:j+len(K)-1])
                if j+len(r)-1<len(S) and S[j:j+len(r)]==r:
                    r_i=j
            # print(l_i,r_i)
            if l_i<=r_i:
                ans='YES'
                break
    print(ans)

# 3
# https://atcoder.jp/contests/aising2019/tasks/aising2019_a
# N=int(input())
# H=int(input())
# W=int(input())
# print((N-H+1)*(N-W+1))

Submission status: Wrong Answer

Solution code:
# 1
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_a
if False:
    print('YES' if set(input().split())==set(list('1974')) else 'NO')

# 2
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b
if True:
    S=input()
    ans='NO'
    K='keyence'
    for i in range(len(K)):
        l=K[:i]
        r=K[i:]
        if l in S and r in S:
            l_i=S.index(l)
            r_i=len(S)-1-S[::-1].index(r[::-1])
            if l_i<r_i:
                ans='YES'
                break
    print(ans)

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()

if S[:7] == "keyence" or S[-7:]=="keyence":
    print("YES")
    exit()
else:
    ans = "No"
    for i in range(1,7):
        front = "keyence"[:i]
        back = "keyence"[i:]
        if S[:i] == front and S[-len(back):]==back:
            print("YES")
            exit()
    print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Wrong Answer

Solution code:
def myAnswer(S:str) -> str:
   for i in range(len(S)-1):
      for j in range(i+1,len(S)):
         if(S[:i]+S[j:] == "keyence"):
            return "YES"
   return "NO"

def modelAnswer():
   return
def main():
   S = (input())
   print(myAnswer(S))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
def myAnswer(S:list) -> str:
   for i in range(len(S)-1):
      for j in range(i+1,len(S)):
         if("".join(S[:i]+S[j:]) == "keyence"):
            return "YES"
   return "NO"

def modelAnswer():
   return
def main():
   S = list(input())
   print(myAnswer(S[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
s = input()
len_s = len(s)
w = list("keyence")

ans = "YES"
for i in range(3):
    if s[i] != w[i] or s[len_s - i - 1] != w[6 - i]:
        ans = "NO"
        break
if s[3] != "e" and s[len_s-4] != "e":
    ans = "NO"

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

if S == "keyence":
    print("Yes")
    exit()

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

print("No")

Submission status: Wrong Answer

Solution code:
def myAnswer(S:list) -> str:
   key = ["k","e","y","e","n","c","e"]
   now = key.pop(0)
   flag = False
   total = 0
   ans = []
   for n,s in enumerate(S):
      # print(s,ans,total,flag)
      if(s ==now):
         if(flag):
            flag = False
            total += 1
         ans.append(s)
         if(len(key)==0):
            if(n != len(S) - 1):
               total +=1
               break
            else:
               break
         else:
            now = key.pop(0)
      else:
         flag = True
   # print(ans,total)
   if("".join(ans)== "keyence" and total <= 1):
      return "YES"
   else:
      return "NO"

def modelAnswer():
   return
def main():
   S = list(input())
   print(myAnswer(S[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:

def myAnswer(S:list) -> str:
   key = ["k","e","y","e","n","c","e"]
   now = key.pop(0)
   flag = False
   hantei = False
   ans = ""
   for n,s in enumerate(S):
      if(s == now):
         if(flag):
            hantei = True
         ans += s
         if(len(key) == 0):
            now = 0
         else:
            now = key.pop(0)
      elif(hantei):
         return "NO"
      else:
         flag = True
   if(ans == "keyence"):
      return "YES"
   else:
      return "NO"

def modelAnswer():
   return
def main():
   S = list(input())
   print(myAnswer(S[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
import re
m = re.match(r'^(\D+)keyence$|^k(\D+)eyence$|^ke(\D+)yence$|^key(\D+)ence$|^keye(\D+)nce$|^keyen(\D+)ce$|^keyenc(\D)+e$|^keyence(\D+)$',input())
print('YES' if m else 'NO')

Submission status: Wrong Answer

Solution code:
import re
m = re.match('.*keyence|k.*eyence|ke.*yence|key.*ence|keye.*nce|keyen.*ce|keyenc.*e|keyence.*',input())
print('YES' if m else 'NO')

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)
a = ['k','e','y','e','n','c','e']
flag = [False]*7
count = 0
i = 0;j=0
while i<7 and i+j<n:
    if a[i]!=s[i+j]:
        count += 1
        while i+j < n:
            if a[i]==s[i+j]:
                flag[i] = True
                break
            else:
                j += 1
    else:
        flag[i] = True 
    i += 1
b = 0
for i in flag:
    if i:
        b += 1
        
if b==7 and count<2:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
keyence_len = len("keyence")
keyence="keyence"

now=0
remove=False
removeout=False
for i in range(len(S)):
    if now >= keyence_len:
        if remove:
            print("NO")
        else:
            print("YES")
        exit()
    
    
    if  S[i]==keyence[now]:
        if remove:
            removeout = True
        now+=1
    else:
        if removeout:
            print("NO")
            exit()
        remove=True
if now==keyence_len:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
keyence_len = len("keyence")
keyence="keyence"

now=0
remove=False
removeout=False
for i in range(len(S)):
    if remove and now >= keyence_len:
        print("NO")
        exit()
    if now < keyence_len and S[i]==keyence[now]:
        if remove:
            removeout = True
        now+=1
    else:
        if removeout:
            print("NO")
            exit()
        remove=True
if now==keyence_len:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
keyence_len = len("keyence")
keyence="keyence"

now=0
remove=False
removeout=False
for i in range(len(S)):
    if remove and now >= keyence_len:
        print("NO")
        exit()
    if S[i]==keyence[now]:
        if remove:
            removeout = True
        now+=1
    else:
        if removeout:
            print("NO")
            exit()
        remove=True
if now==keyence_len:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import re
def checkkeyence(s):
    patternlist = [".*keyence", "k.*eyence","ke.*yence","key.*ence","keye.*nce","keyen.*ce","keyenc.*e","keyence.*"]
    for p in patternlist:
        if re.match(p,s) != None:
            return 'YES'
    return 'NO'
        
s=input();print(checkkeyence(s))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

# B - KEYENCE String
def is_keyence_string():
	for i in range(1, len(key)):
		left = key[:i]
		right = key[i-len(key):]
		
		if S.startswith(left) and S.endswith(right):
			return True
	
	return False


S = input()
key = 'keyence'

if S.startswith(key):
	print('YES')
elif S.endswith(key):
	print('YES')
else:
	if is_keyence_string():
		print('YES')
	else:
		print('NO')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

# B - KEYENCE String
def is_keyence_string():
	for i in range(1, len(key)):
		left = S[:i]
		right = S[i-len(key):]

		if S.startswith(left) and S.endswith(right):
			return True
	
	return False


S = input()
key = 'keyence'

if S.startswith(key):
	print('YES')
elif S.endswith(key):
	print('YES')
else:
	if is_keyence_string():
		print('YES')
	else:
		print('NO')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

# B - KEYENCE String
def is_keyence_string():
	i = 0

	for s in S:
		if s == key[i]:
			i += 1
			if i == len(key):
				return True

	return False


S = input()
key = 'keyence'

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

Submission status: Wrong Answer

Solution code:
S = input()

s = 'keyence'
for i in range(1, len(s)):
    left = s[:i]
    right = s[i:]
    l = S.find(left)
    if l > -1 and S[l + i:].find(right) > -1:
        print('YES')
        break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    ke="keyence"
    cunt=0
    if len(s)>8:
        print("NO")
        sys.exit()
    for i in range(len(s)):
        if s[i]==ke[cunt]:
            cunt+=1
            if cunt==7:
                print("YES")
                break
    else:print("NO")

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    ke="keyence"
    cunt=0
    for i in range(len(s)):
        if s[i]==ke[cunt]:
            cunt+=1
            if cunt==7:
                print("YES")
                break
    else:print("NO")

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)
T="keyence"
U=""
V=""

for i in range(7):
  if S[i]==T[i]:
    pass
  else:
    U=S[:i]
    break
for j in range(7):
  if S[-1-j]==T[-1-j]:
    pass
  else:
    V=S[-1-j+1:]
    break
    
if U=="" or V=="" or U+V==T:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

for i in range(1,N):
  #print(S[:i],S[i:])
  for j in range(1,7):
    #print( T[:j], T[j:] )
    if S[:i].count(T[:j]) >=1:
      if S[i:].count(T[j:]) >=1:
        ans="YES"
        print("YES")
        exit()
else:
  print("NO")

Submission status: Wrong Answer

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

for i in range(N):
  for j in range(7):
    if S[:i].count(T[:j]) >=1:
      if S[i:].count(T[j:]) >=1:
        ans="YES"
        print("YES")
        exit()
else:
  print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()

ans_str = "keyence"

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

if S[len(S)-7:len(S)] == ans_str:
    print("YES")
    exit()

count_insert = 0
count_ans_str = 0
for i in range(len(S)):
    if count_ans_str > 6:
        print("NO")
        exit()
    elif S[i] == ans_str[count_ans_str]:
        count_ans_str += 1
        if count_insert == 1:
            count_insert = 2
    else:
        if count_insert == 2:
            print("NO")
            exit()
        count_insert = 1

if count_ans_str < 6:
    print("NO")
    exit()
print("YES")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def ok(s):
    for i in range(len(s)+1):
        for j in range(i, len(s)+1):
            for k in range(len(s)):
                if i <= k and k < j:
                    print("_", end="")
                else:
                    print(s[k], end="")
            print()
            if s[:i] + s[j:] == "keyence":
                return True
    return False

def main():
    s = input().strip()
    print("YES" if ok(s) else "NO")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def ok(s):
    for i in range(len(s)):
        for j in range(i, len(s)):
            print(s[:i] + s[j:])
            if s[:i] + s[j:] == "keyence":
                return True
    return False

def main():
    s = input().strip()
    print("YES" if ok(s) else "NO")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s = input()

check = []
keyence = 'keyence'
for i in range(len(keyence)):
    check.append([keyence[:i],keyence[i:]])

for i in check:
    c = 0
    for j in i:
        if j in s:
            c += 1
        if c == 2:
            print('YES')
            quit()
    #print(s,i)
print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
key = 'keyence'
if 'keyence' in S:
    print('YES')
else:
    ans = 'NO'
    for i in range(1,6):
        f = key[:i]
        if S[:i] == f:
            if key[i:][::-1] == S[::-1][:7-i]:
                ans = 'YES'
                break
    print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
key = 'keyence'
if 'keyence' in S:
    print('Yes')
else:
    ans = 'No'
    for i in range(1,6):
        f = key[:i]
        if S[:i] == f:
            if key[i:][::-1] == S[::-1][:7-i]:
                ans = 'Yes'
                break
    print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
key = 'keyence'
if 'keyence' in S:
    print('Yes')
else:
    ans = 'No'
    for i in range(6):
        f = key[:i]
        if S[:i] == f:
            if key[i:][::-1] == S[::-1][:7-i]:
                ans = 'Yes'
                break
    print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
s="keyence"
l=len(S)
c=0
for i in range(7):
    j=0
    while i+j<=l:
        if S[j:j+i]==s[:i]:
            break
        j+=1
    else:
        continue
    while 7-i+j<=l:
        if S[j:7-i+j]==s[i:]:
            c=1
            print("YES")
            break
        j+=1
    else:
        continue
    break
if not c:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys

s = input()

for i in range(len(s)):
    for j in range(len(s)-i):
        l_s = s[:i]
        r_s = s[j:]
        ans = l_s+r_s
        
        if ans == 'keyence':
            print('YES')
            sys.exit()
        
    
print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

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


for bit in range(2 ** len(s)):
    ans = ""
    for j in range(len(s)):
        if (bit >> j) & 1:
            ans += s[j]

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

print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
keyenc = list('keyence')[::-1]
for s in S:
    if s == keyenc[-1]:
        keyenc.pop()
        if not keyenc:
            break
if keyenc:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
flg = 0
l = 0
for c in 'keyence':
    for i in range(l, N):
        if S[i] == c:
            l = i+1
            break
    else:
        break
else:
    flg = 1
if flg:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
def dfs(i, j, s):
    if j == 7:
        return s == 'keyence'
    if i >= N:
        return False
    res = False
    for k in range(i+1, N):
        res |= dfs(k, j+1, s+S[k])
    return res

S = input()
N = len(S)
flg = 0
for i in range(N-7+1):
    if S[i] == 'k':
        flg |= dfs(i, 1, 'k')
if flg:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
a="keyence"
b=0
flug=0

for i in range(len(s)):
    if s[i]==a[b]:
        b+=1
        if flug==1:
            flug=2
    else:
        if flug==0:
            flug=1
        elif flug==2:
            print("NO")
            exit()
    
    if b==7:
        if flug==0:
            print("YES")
            exit()
        else:
            if i+1==len(s):
                print("YES")
                exit()
            else:
                print("NO")
                exit()

print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
a="keyence"
b=0
flug=0

for i in s:
    if i==a[b]:
        b+=1
        if flug==1:
            flug=2
    else:
        if flug==0:
            flug=1
        elif flug==2:
            print("NO")
            exit()
    
    if b==7:
        print("YES")
        exit()

print("NO")

Submission status: Wrong Answer

Solution code:
import sys
#input = sys.stdin.buffer.readline
from collections import deque

def main():
    S = deque(list(input()))
    use = ["k","e","y","e","n","c","e"]

    l = 0
    while S:
        now = S.popleft()
        if now == use[l]:
            l += 1
        if l == 7:
            print("YES")
            exit()
    
    print("NO")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
#input = sys.stdin.buffer.readline
from collections import deque

def main():
    S = deque(list(input()))
    use = ["k","e","y","e","n","c","e"]

    l = 0
    while S:
        now = S.popleft()
        if now == use[l]:
            l += 1
        if l == 7:
            print("Yes")
            exit()
    
    print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
S=input()
moji="keyence"
i=0
j=0
while i<len(S) and j<7:
    if S[i]==moji[j]:
        i+=1
        j+=1
    else:
        i+=1
if j==7:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=str(input())
i=0
goal='keyence'
index=0
cnt=0
while i<len(s):
  if s[i]!=goal[index]:
    i+=1
  else:
    while index<len(goal) and i<len(s) and s[i]==goal[index]:
      index+=1
      i+=1
    cnt+=1
  if index==len(goal):
    i=len(s)
    break
if index==len(goal) and cnt<=2:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s=str(input())
tmp=''
goal='keyence'
index=0
for i in range(len(s)):
  if index<len(goal) and s[i]==goal[index]:
    index+=1
if index==len(goal):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
t="keyence"
i=0
for x in s:
    if t[i]==x:
        i+=1
        if i>6:
            print("YES")
            break
else:print("NO")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
import re
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    ANS = "keyence"
    for i in range(len(s)):
        for j in range(1, len(ANS)):
            if ANS[:j] in s[:i] and ANS[j:] in s[i:]:
                print("YES")
                return
    print("NO")

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    ANS = "keyence"
    l = list(ANS)
    for si in s:
        if l:
            if l[0] == si:
                del l[0]
        else:
            print("YES")
            return
    if l:
        print("NO")
    else:
        print("YES")

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    ANS = "keyence"
    l = list(ANS)
    for si in s:
        if l:
            if l[0] == si:
                del l[0]
        print("YES")
        return
    if l:
        print("NO")
    else:
        print("YES")

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    n = len(S)
    key = 'keyence'
    if S == key:
        print('YES')
        return
    for i, k in enumerate(key):
        if S[i] != k:
            rest = key[i:]
            for j in range(i, n):
                if S[j:] == rest:
                    print('YES')
                    return
    print('NO')
main()

Submission status: Wrong Answer

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

pos = 0
t = key[pos]
for c in s:
    if c == t:
        pos += 1
        if pos == len(key):
            print('YES')
            break
        t = key[pos]
else:
    print('NO')

Submission status: Wrong Answer

Solution code:

s = input()

for i in range(len(s)):
    if s[:i] + s[i + len(s)-7:] == "keyence":
        print("YES")
        break
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
s=list(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: Wrong Answer

Solution code:
key = "keyence"
s = str(input())
e = 0
flag = []
ma = ""

for i in range(len(s)):
    if(s[i] == key[e]):
        ma += s[i]
        e = min(len(key)-1,e+1)
        flag.append(1)
    else:
        flag.append(0)
if(len(ma) == len(key)):
    k = [flag[0]]
    for i in range(len(flag)-1):
        if(flag[i] != flag[i+1]):
            k.append(flag[i+1])
    if(k.count(0) < 2):
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
key = "keyence "
s = str(input())
e = 0
flag = []
ma = ""

for i in range(len(s)):
    if(s[i] == key[e]):
        ma += s[i]
        e += 1
        flag.append(1)
    else:
        flag.append(0)
if(len(ma) == 7):
    k = [flag[0]]
    for i in range(len(flag)-1):
        if(flag[i] != flag[i+1]):
            k.append(flag[i+1])
    if(k.count(0) < 2):
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
key = "keyence "
s = str(input())
e = 0
flag = []
ma = ""

for i in range(len(s)):
    if(s[i] == key[e]):
        ma += s[i]
        e += 1
        flag.append(1)
    else:
        flag.append(0)
if(len(ma) == 7):
    k = [flag[0]]
    for i in range(len(flag)-1):
        if(flag[i] != flag[i+1]):
            k.append(flag[i+1])
    if(k.count(0) < 2):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
key = "keyence"
s = str(input())
if(len(s) >= 7):
    e = 0
    for i in range(len(s)):
        if(s[i] == key[e]):
            e += 1
            if(e == 6):
                print("Yes")
                exit()
else:
    print("No")
print("No")

Submission status: Wrong Answer

Solution code:
S = input()

V = "keyence"

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

Submission status: Wrong Answer

Solution code:
S = input()

V = "keyence"

for i in range(len(S) - len(V) + 1):
    print(i, S[:i], S[i-len(V):])
    if S[:i] + S[i-len(V):] == V:
        print("YES")
        exit(0)
print("NO")

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    s = 'keyence'
    for i in range(len(s)+1):
        if S.startswith(s[:i+1]) and S.endswith(s[-i-i:]): return True
    return False

if __name__ == '__main__':
    print('YES' if main() else 'NO')

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    s = 'keyence'
    for i in range(len(s)+1):
        if S.startswith(s[:i+1]) and S.endswith((s[-i-i:])): return True
    return False

if __name__ == '__main__':
    print('YES' if main() else 'NO')

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    s = 'keyence'
    for i in range(len(s)+1):
        j = True
        for j in range(i):
            if s[j] != S[j]:
                j = False
                break
        for j in range(len(s)-i):
            if s[-1-j] != S[-1-j]:
                j = False
                break
        if j:
            return True
    return False

if __name__ == '__main__':
    print('YES' if main() else 'NO')

Submission status: Wrong Answer

Solution code:
import sys
def main():
    input = sys.stdin.readline
    S = input().rstrip()
    s = 'keyence'
    for i in range(len(s)+1):
        j = True
        for j in range(i):
            if s[j] != S[j]:
                j = False
                break
        for j in range(len(s)-i):
            if s[-1-j] != S[-1-j]:
                j = False
                break
        if j:
            return True
    return False

if __name__ == '__main__':
    print('YES' if main() else 'NO')

Submission status: Wrong Answer

Solution code:
import sys
def main():
    input = sys.stdin.readline
    S = input().rstrip()
    s = 'keyence'
    for i in range(len(s)+1):
        j = True
        for j in range(i):
            if s[j] != S[j]:
                j = False
                break
        else:
            for j in range(len(s)-i):
                if s[-1-j] != S[-1-j]:
                    j = False
                    break
        if j:
            return True
    return False

if __name__ == '__main__':
    print('YES' if main() else 'NO')

Submission status: Wrong Answer

Solution code:
import sys
def main():
    input = sys.stdin.readline
    S = input().rstrip()
    s = 'keyence'
    j = False
    for i in range(len(s)+1):
        for j in range(i):
            if s[j] != S[j]: break
        else:
            for j in range(len(s)-i):
                if s[-1-j] != S[-1-j]: break
            else:
                j = True
        if j:
            return True
    return False

if __name__ == '__main__':
    print('YES' if main() else 'NO')