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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

import sys
input = sys.stdin.readline

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


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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

S = S()
L = len(S)

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

Submission status: Wrong Answer

Solution code:
S=input()

ans='NO'
if 'keyence'in S:
    ans='YES'
elif S.find('k')>=0 and S.find('k')<S.rfind('eyence'):
    ans='YES'
elif S.find('ke')>=0 and S.find('ke')<S.rfind('yence'):
    ans='YES'
elif S.find('key')>=0 and S.find('key')<S.rfind('ence'):
    ans='YES'
elif S.find('keye')>=0 and S.find('keye')<S.rfind('nce'):
    ans='YES'
elif S.find('keyen')>=0 and S.find('keyen')<S.rfind('ce'):
    ans='YES'
elif S.find('keyenc')>=0 and S.find('keyenc')+5<S.rfind('e'):
    ans='YES'

print(ans)

Submission status: Wrong Answer

Solution code:
S=input()

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

print(ans)

Submission status: Wrong Answer

Solution code:
S=input()

ans='NO'
if 'keyence'in S:
    ans='YES'
elif S.find('k')>=0 and S.find('k')<S.rfind('eyence'):
    ans='YES'
elif S.find('ke')>=0 and S.find('ke')<S.rfind('yence'):
    ans='YES'
elif S.find('key')>=0 and S.find('key')<S.rfind('ence'):
    ans='YES'
elif S.find('keye')>=0 and S.find('keye')<S.rfind('nce'):
    ans='YES'
elif S.find('keyen')>=0 and S.find('keyen')<S.rfind('ce'):
    ans='YES'
elif S.find('keyenc')>=0 and S.find('keyenc')<S.rfind('e'):
    ans='YES'

print(ans)

Submission status: Wrong Answer

Solution code:
S=input()

ans='NO'
if 'keyence'in S:
    ans='YES'
elif S.find('k')>=0 and S.find('k')<S.rfind('eyence'):
    ans='YES'
elif S.find('ke')>=0 and S.find('ke')<S.rfind('yence'):
    ans='YES'
elif S.find('key')>=0 and S.find('k')<S.rfind('ence'):
    ans='YES'
elif S.find('keye')>=0 and S.find('k')<S.rfind('nce'):
    ans='YES'
elif S.find('keyen')>=0 and S.find('k')<S.rfind('ce'):
    ans='YES'
elif S.find('keyenc')>=0 and S.find('k')<S.rfind('e'):
    ans='YES'

print(ans)

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math
import sys


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


s = input()
n = len(s)
j = 0
key = "keyence"
for i in range(n):
    if j < 7 and s[i] == key[j]:
        j += 1
if j < 7:
    print("NO")
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math
import sys


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


s = input()

ck = "keyence"
pos = 0

for i in s:
    if ck[pos] == i:
        pos += 1
    if pos > 6:
        break
if pos > 6:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
import math
import sys


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


s = input()

ck = "keyence"
arr = [0] * 7

pos = 0

for i in s:
    if arr[pos] == 0 and ck[pos] == i:
        arr[pos] = 1
        pos += 1
    if pos == 7:
        break
if pos == 7:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
ans_word = "keyence"

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

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

Submission status: Wrong Answer

Solution code:
ans_word = "keyence"

s = input()
flag = False

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

Submission status: Wrong Answer

Solution code:
ans_word = "keyence"

s = input()
flag = False

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

Submission status: Wrong Answer

Solution code:
ans_word = "keyence"

s = input()
flag = False

for i in range(len(s)-1):
    for j in range(len(s)-1):
        if s[:i] + s[j:] == ans_word:
            flag = True
            break
    if flag:
        break
if flag:
    print("YES")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
ans_word = "keyence"

s = input()
flag = 0
tmp = 0

if (s[0] != "k" and s[-1] != "e") or len(s) < len(ans_word):
    flag = 0
elif (s[0] == "k" and s[-1] == "e"):
    for i, part_ans in enumerate(ans_word[1:]):
        if s[i + 1] != part_ans:
            # print(i)
            # print(part_ans)
            # print(s[i + 1:])
            tmp = i + 1
            flag = 0
            break
        if i == len(ans_word) - 2:
            flag = 1
    if flag == 0:
        # print(len(s), len(ans_word), tmp, 1)
        # print(len(s) - len(ans_word) + tmp + 1)
        # print(ans_word[len(s) - len(ans_word) + tmp + 1:-1])
        for i, part_ans in enumerate(ans_word[tmp - len(ans_word):-1]):
            # print(s[tmp - len(ans_word) + i:], part_ans)
            if s[tmp - len(ans_word) + i] != part_ans:
                flag = 0
                break
            flag = 1
else:
    if ans_word in s:
        flag = 1

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

Submission status: Wrong Answer

Solution code:
ans_word = "keyence"

s = input()
flag = 0
tmp = 0

if (s[0] != "k" and s[-1] != "e") or len(s) < len(ans_word):
    flag = 0
elif (s[0] == "k" and s[-1] == "e"):
    for i, part_ans in enumerate(ans_word[1:]):
        if s[i + 1] != part_ans:
            # print(i)
            # print(part_ans)
            # print(s[i + 1:])
            tmp = i + 1
            flag = 0
            break
        if i == len(ans_word) - 2:
            flag = 1
    if flag == 0:
        for i, part_ans in enumerate(ans_word[tmp - len(ans_word):-1]):
            if s[tmp - len(ans_word) + i] != part_ans:
                flag = 0
                break
            flag = 1
else:
    if ans_word in s:
        flag = 1

if flag == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
S = input()


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

print("NO")

Submission status: Wrong Answer

Solution code:
import sys 
S =  input()

string = ""
flag1 = 0
#フラグ管理かなぁ
lis1 = []
for i in range(len(S)):
    string = string + S[i]
    lis1.append(string)

    if string == "key":
        flag1 = 1
        break
     
string2 = "" 
lis2 = []
flag2 = 0
for i in range(len(S)-1,-1,-1):
    string2 = string2 + S[i]
    lis2.append(string2)
    
    if string2 == "ecne":
        flag2 = 1

if flag1 == 1 and flag2 == 1:
    print("YES")
    sys.exit()
elif flag1 == 0 and flag2 == 0:
    print("NO")
    sys.exit()

elif flag1 == 1 and flag2 == 0:
     for i in lis2:
         if "ecne" in i:
             print("YES")
             sys.exit()

elif flag1 == 0 and flag2 == 1:
     for i in lis1:
         if "key" in i:
             print("YES")
             sys.exit()

print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = list(input())
l = list("keyence")
i = 0
for si in s:
    if l[i] == si:
        i+=1
        if i == 7:
            print("YES")
            break
else:
    print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
key="key" in s
ence="ence" in s
if key and ence:
  k=e=-1
  for i in range(len(s)):
    if k!=-1 and e!=-1:
      continue
    if s[i:i+3]=="key":
      k=i
    elif s[i:i+4]=="ence":
      e=i
  if k<e:
    print("YES")
  else:
    print("NO")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
S = list(input())
L = len(S)
key = list("keyence")
if S[0:7] == key:
    print("YES")
    exit()

if S[L-7:] == key:
    print("YES")
    exit()

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

Submission status: Wrong Answer

Solution code:
import re

S = input()

patterns = (".*keyence", "k.*eyence", "ke.*yence", "key.*ence", "keye.*nce", "keyen.*ce", "keyenc.*e", "keyence.*")
if any(re.match(pattern, S) for pattern in patterns):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if target in S:
    print("YES")
    exit()
else:
    for i in range(1, length):
      first = target[:i]
      second = target[i:]
      if first in S and second in S and S.find(first) < S.rfind(second):
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

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

if target in S:
    print("YES")
    exit()
else:
    for i in range(1, length):
      first = target[:i]
      second = target[i:]
      if first in S and second in S and S.find(first) <= S.rfind(second):
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

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

for i in range(length):
  first = target[:i]
  second = target[i:]
  if (first == '' and second in S) or (first != '' and first in S and second in S and S.find(first) <= S.find(second)):
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

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

for i in range(length):
  first = target[:i]
  second = target[i:]
  if first in S and second in S and S.find(first) <= S.find(second):
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

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

S = input()

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

Submission status: Wrong Answer

Solution code:
import re

S = input()

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

Submission status: Wrong Answer

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

S = input()

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

Submission status: Wrong Answer

Solution code:
import sys, re
#input = sys.stdin.readline

S = input()

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

Submission status: Wrong Answer

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

S = input()

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

Submission status: Wrong Answer

Solution code:
from pprint import pprint

s = str(input())

keyence_list = [[float("inf"),-float("inf")] for _ in range(6)]



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

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

#pprint(keyence_list)


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

print("NO")
exit()





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

Submission status: Wrong Answer

Solution code:
from pprint import pprint

s = str(input())

keyence_list = [[float("inf"),-float("inf")] for _ in range(6)]



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

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

#pprint(keyence_list)


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

print("NO")
exit()





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

Submission status: Wrong Answer

Solution code:
from pprint import pprint

s = str(input())

keyence_list = [[float("inf"),-float("inf")] for _ in range(6)]



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

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

#pprint(keyence_list)


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

print("NO")
exit()





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