Problem:


Score : 200 points

Problem Statement

A string is called a KEYENCE string when it can be changed to keyence by removing its contiguous substring (possibly empty) only once.

Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.

Constraints

The length of S is between 7 and 100 (inclusive).

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S is a KEYENCE string, print YES; otherwise, print NO.

Sample Input 1

keyofscience

Sample Output 1

YES

keyence is an abbreviation of key of science.

Sample Input 2

mpyszsbznf

Sample Output 2

NO

Sample Input 3

ashlfyha

Sample Output 3

NO

Sample Input 4

keyence

Sample Output 4

YES



Sample input:
keyofscience


Sample output:
YES

Submission status: Accepted

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

Submission status: Accepted

Solution code:
kstr = input()
klist = list(kstr)
klength = len(kstr)
ansstr = ["k","e","y","e","n","c","e"]
if klist[0:7] == ansstr :
  print("YES")
else:
  if (klist[0:6]+klist[klength-1:klength]) == ansstr :
    print("YES")
  else:
    if (klist[0:5]+klist[klength-2:klength]) == ansstr :
      print("YES")
    else:
      if (klist[0:4]+klist[klength-3:klength])== ansstr:
        print("YES")
      else:
        if (klist[0:3]+klist[klength-4:klength])== ansstr:
          print("YES")
        else:
          if (klist[0:2]+klist[klength-5:klength])== ansstr:
            print("YES")
          else:
            if (klist[0:1]+klist[klength-6:klength])== ansstr:
              print("YES")
            else:
              if (klist[klength-7:klength])== ansstr:
                print("YES")
              else:
                print("NO")

Submission status: Accepted

Solution code:
KEYENCE = 'keyence'


def keyence_string(s: str) -> bool:
    i = 0
    for i, c in enumerate(KEYENCE):
        if s[i] != c:
            break

    return s.endswith(KEYENCE[i:])


if __name__ == "__main__":
    s = input()

    if keyence_string(s):
        print('YES')
    else:
        print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
l = len(S)
k = 'keyence'
if S == k:
  print('YES')
elif S[len(S)-7:len(S)] == k:
  print('YES')
elif S[0:1]+S[len(S)-6:len(S)] == k:
  print('YES')
elif S[0:2]+S[len(S)-5:len(S)] == k:
  print('YES')
elif S[0:3]+S[len(S)-4:len(S)] == k:
  print('YES')
elif S[0:4]+S[len(S)-3:len(S)] == k:
  print('YES')
elif S[0:5]+S[len(S)-2:len(S)] == k:
  print('YES')
elif S[0:6]+S[len(S)-1:len(S)] == k:
  print('YES')
elif S[0:7]== k:
  print('YES')
else:
  print('NO')

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    S = input()

    rem_size = len(S) - 7
    if rem_size < 0:
        print(NO)
        return

    for b in range(len(S) - rem_size + 1):
        t = S[:b] + S[b + rem_size:]
        if t == "keyence":
            print(YES)
            return
    print(NO)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import copy
key = list(input())
hantei=0
length=len(key)
if "".join(key)=="keyence":
    hantei=1
for i in range(length):
    if hantei==1:
        break
    a=copy.deepcopy(key)
    if i==length-1:
        j=length-2
    else:
        j=i
    while j<length-1:
        del a[i]
        j+=1
        if "".join(a)=="keyence":
            hantei=1
            break
if hantei==1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Ss = input()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
 
S = input()
target = 'keyence'
 
for i in range(len(target)+1):
    a = target[:i]
    b = target[i:]
    if re.match('^' + a + '.*' + b + '$', S):
        print('YES')
        exit()
print('NO')

Submission status: Accepted

Solution code:
S = input()

Ans = "NO"
L = len(S)
for i in range(7):
    if S[0:i]+S[L-7+i:L]=="keyence":
        Ans = "YES"
        break

print(Ans)

Submission status: Accepted

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

Submission status: Accepted

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()
target = 'keyence'

for i in range(len(target)+1):
    a = target[:i]
    b = target[i:]
    if re.match('^' + a + '.*' + b + '$', S):
        print('YES')
        exit()
print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

for i in range(7):
	if s[:i] + s[i-7:] == 'keyence':
		print('YES')
		exit()

print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
k,n,c = "keyence",len(s),0
for i in range(8):
	if k[:i]==s[:i] and k[i:]==s[n+i-7:]: break
	else: c+=1
if c-8: print("YES")
else: print("NO")

Submission status: Accepted

Solution code:
S = input()

length = len(S)
found = False
for i in range(length):
    for j in range(length - i):
        if S[:i] + S[i+j:] == 'keyence':
            found = True
            break
    if found:
        break

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

Submission status: Accepted

Solution code:
s = input()
target = "keyence"
l = len(target)
ls = len(s)
for i in range(len(target)):
    if s[:i] == target[:i] and s[ls-l+i:] == target[i:]:
        print("YES")
        exit(0)

print("NO")

Submission status: Accepted

Solution code:
s = list(input())

if s[0] == "k":
    li = []
    for i in range(6):
        li.append(s[len(s)-(6-i)])
    if "".join(li) == "eyence":
        print("YES")
        quit()

if s[0] + s[1] == "ke":
    li = []
    for i in range(5):
        li.append(s[len(s)-(5-i)])
    if "".join(li) == "yence":
        print("YES")
        quit()

if s[0] + s[1] + s[2] == "key":
    li = []
    for i in range(4):
        li.append(s[len(s)-(4-i)])
    if "".join(li) == "ence":
        print("YES")
        quit()

if s[0] + s[1] + s[2] + s[3] == "keye":
    li = []
    for i in range(3):
        li.append(s[len(s)-(3-i)])
    if "".join(li) == "nce":
        print("YES")
        quit()

if s[0] + s[1] + s[2] + s[3] + s[4] == "keyen":
    li = []
    for i in range(2):
        li.append(s[len(s)-(2-i)])
    if "".join(li) == "ce":
        print("YES")
        quit()

if s[0]  + s[1] + s[2] + s[3] + s[4] + s[5] == "keyenc":
    if s[len(s) - 1] == "e":
        print("YES")
        quit()

        
lis = []
for i in range(7):
    lis.append(s[len(s)-i-1])
if "".join(lis) == "keyence":
    print("YES")
    quit()

print("NO")

Submission status: Accepted

Solution code:
import sys
S=input()
N=len(S)
for i in range(N):
    for j in range(i,N+1):
        T=S[0:i]
        L=S[j:N+1]
        #print(T+L)
        if T+L=='keyence':
            print('YES')
            sys.exit()
print('NO')

Submission status: Accepted

Solution code:
import sys
S = list(input())
Ans_list=['k','e','y','e','n','c','e']
Ans = 'NO'
for i in range(len(S)):
    for j in range(i,len(S),+1):
        
        if (S[:i:]+S[j::]) == Ans_list:
           Ans = 'YES'
           print(Ans)
           sys.exit()
print(Ans)

Submission status: Accepted

Solution code:
from sys import stdin, stdout

s = stdin.readline().strip()
pattern = 'keyence'
ans = 0

for i in range(len(s)):
    for j in range(i, len(s)):
        if s[:i] + s[j:] == pattern:
            ans = 1

stdout.write(['NO', 'YES'][ans])

Submission status: Accepted

Solution code:
import sys

target = input()
search_string = 'keyence'

if target.find(search_string) != -1:
    print('YES')
    sys.exit()

split_index = 7
while 0 < split_index:
    split_index -= 1
    head = search_string[0:split_index]
    tail = search_string[split_index:]
    find_index = target.find(head)
    rfind_index = target.rfind(tail)
    rfind_tail_index = rfind_index + len(tail)
    # print('head: ' + str(find_index)  + ' : ' + head)
    # print('tail: ' + str(rfind_index) + ' : ' + tail)
    if find_index == -1 or rfind_index == -1:
        continue
    if (find_index + len(head)) > rfind_index:
        continue
    if find_index == 0 and rfind_tail_index == len(target):
        print('YES')
        sys.exit()
print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import itertools
s=str(input())
n='keyence'
k=''
w=list(itertools.combinations(range(len(s)+1), 2))
for i,y in w:
    k=s[i:y]
    ss=s.replace(k,'',1)
    #print(ss)
    if ss==n or k==n:
        print('YES')
        exit()
print('NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    S = input()
    if len(S) < 7:
        return (False)
    keyence = "keyence"
    for i in range(len(keyence) + 1):
        head = S[0:i]
        tail = S[len(S) - len(keyence) + i:len(S)]
        if keyence[:i] != head:
            continue
        if keyence[i:] != tail:
            continue
        else:
            return (True)
    return (False)


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

Submission status: Accepted

Solution code:
def solve():
    S = input()
    if len(S) < 7:
        return(False)
    keyence = "keyence"
    for i in range(len(keyence) + 1):
        head = S[0:i]
        tail = S[len(S)-len(keyence)+i:len(S)]
        if keyence[:i] != head:
            continue
        if keyence[i:] != tail:
            continue
        else:
            return(True)
    return(False)

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

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#x = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
l = len(a)
p = 0
for i in range(l):
    b = a[:i]
    for z in range(l):
        c = a[z:]
        d = ''.join([b,c])
        if 'keyence' == d : j(1)
j(0)

Submission status: Accepted

Solution code:
#! /usr/bin/env python
import sys

CHECK_STRING = 'keyence'

def main():
  line = sys.stdin.readline().strip()

  CheckKeys = list(CHECK_STRING)
  checkChar = CheckKeys.pop(0)

  missIndex = 0
  for i in list(line):
    if i == checkChar:
      if len(CheckKeys) != 0:
        checkChar = CheckKeys.pop(0)
      else:
        print('YES')
        return
    else:
      break
    missIndex += 1

  restString = CHECK_STRING[missIndex:]
  checkRestString = line[missIndex:]

  index = -1
  completed = True
  while len(restString) >= abs(index):
    r = restString[index]
    c = checkRestString[index]
    if r != c:
      completed = False
      break
    index -= 1

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


main()

Submission status: Accepted

Solution code:
import sys
a = list(input())
k = list("keyence")
n = 7
for i in range(7):
  if k[i]==a[i]:
  	check=True
  else:
    check = False
    n -= i
    break

if check:
  print("YES")
  sys.exit()

check2=False
for i in range(n):
  if k[-i-1]==a[-i-1]:
    check2=True
  else:
    check2=False
    break
if check2:
  print("YES")
else: print("NO")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re

s = input()
key = 'keyence'
x = 0

str0 = re.compile(r'^' + key)
str1 = re.compile(r'' + key + '$')

if str0.search(s) != None or str1.search(s) != None:
  x = 1
else:
  for i in range(1,7):
    if x == 1:
      break
    str0 = re.compile(r'^' + key[:i])
    str1 = re.compile(r'' + key[i-6:] + '$')
    if str0.search(s) != None and str1.search(s) != None:
      x = 1

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

Submission status: Accepted

Solution code:
S = list(input())
s1 = list("keyence")

x = [1]
y = [1]
for i in range(7):
  if S[i] == s1[i]:
    x.append(x[len(x)-1])
  else:
    x.append(0)
  if S[len(S)-1-i] == s1[6-i]:
    y.append(y[len(y)-1])
  else:
    y.append(0)

if sum(x) + sum(y) >= 9:
  print("YES")  
else:
  print("NO")

Submission status: Accepted

Solution code:
word = 'keyence'
l = input()
i = l.find(word)
if i == 0 or i == (len(l)-len(word)) :
  print('YES')
  exit()

for i in range(1,len(word)):
  a = word[:i]
  b = word[i:]
  #print(l[:len(a)], l[-len(b):])
  if l[:len(a)] == a and l[-len(b):] == b:
    print('YES')
    exit()
print('NO')

Submission status: Accepted

Solution code:
S = input()
keyence = 'keyence'
count = 0

for i in range(7):
	'''
	print(S[:i])
	print(keyence[:i])
	print(S[len(S)-7+i:])
	print(keyence[i:])
	'''
	
	if S[:i] == keyence[:i] and S[len(S)-7+i:] == keyence[i:]:
		count += 1
	
if count > 0:
	print('YES')
else:
	print('NO')

Submission status: Accepted

Solution code:
S=input()
if S == "keyence":
  print("YES")
else:

  flag=0
  for i in range(len(S)):
      for j in range(i+1,len(S)):
          if S[0:i]+S[j:] == 'keyence':
              flag=1
  if flag==1:
      print("YES")
  else:
      print("NO")

Submission status: Accepted

Solution code:
L = input()
A = 'keyence'

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

Submission status: Accepted

Solution code:
S = input()
LEN = len(S)

K = "keyence"

if K in S:
    print("YES")
else:
    isok = False
    LENK = len(K)
    for i in range(LENK):
        if K[0:i+1] == S[0:i+1] and \
        K[i+1:LENK] == S[LEN-LENK+(i+1):LEN]:
            isok = True
            break
    if isok:
        print("YES")
    else:
        print("NO")

Submission status: Accepted

Solution code:
s = input()
if s.find("keyence") != -1:
    print("YES")
else:
    cond = False
    for i in range(1,7):
        if s[0:i]+s[-(7-i):] == "keyence":
            cond = True
            print("YES")
            break
    if cond == False:
        print("NO")

Submission status: Accepted

Solution code:
S = input()

ky = 'keyence'

lky = len(ky)
#for i in range(lky):
    # print(keyence[:i] + keyence[-(lky-i):])

tf = [all({S[:i] == ky[:i], S[-(lky-i):] == ky[-(lky-i):]}) for i in range(lky)]
    
if any(tf):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
S = input()

def is_keyence_str(S):
    for i in range(len(S) + 1):
        for j in range(i, len(S) + 1):
            r = S[:i] + S[j:]
            # print(i, j, r)
            if r == "keyence":
                return True
    return False

if is_keyence_str(S):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
S = list(input())
s1 = list("keyence")

x = [1]
y = [1]
for i in range(7):
  if S[i] == s1[i]:
    x.append(x[len(x)-1])
  if S[len(S)-1-i] == s1[6-i]:
    y.append(y[len(y)-1])
  

if sum(x) + sum(y) >= 9:
  print("YES")  
else:
  print("NO")

Submission status: Accepted

Solution code:
S = list(input())
s1 = list("keyence")

x = []
y = []
for i in range(7):
  if S[i] == s1[i]:
    x.append(1)
  if S[len(S)-1-i] == s1[6-i]:
    y.append(1)
  

if sum(x) + sum(y) >= 7:
  print("YES")  
else:
  print("NO")

Submission status: Accepted

Solution code:
S = list(input())
L = list('keyence')
while len(L)*len(S) > 0 and L[0] == S[0]:
    del L[0]
    del S[0]
while len(L)*len(S) > 0 and L[-1] == S[-1]:
    del L[-1]
    del S[-1]
if L == []:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
S = input()
flg = 0

target_S = "keyence"

if S.startswith(target_S) or S.endswith(target_S):
    flg = 1
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):
            flg = 1

if flg == 1:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
s = input()
target = 'keyence'
s_len = len(s)
flg = 0

if s.startswith(target) or s.endswith(target):
  flg = 1
for i in range(len(target)):
  target1 = target[:i]
  target2 = target[i:]
  if s.startswith(target1) and s.endswith(target2):
    flg = 1

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

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_KeyencePrograming_Contest-B
#  TODO https://keyence2019.contest.atcoder.jp/tasks/keyence2019_b
import re

def solveProblem(inputStr):
	strLength = len(inputStr)
	flag = False
	sentouRenge = range(0,strLength+1,+1)
	kouhouRenge = range(0,strLength+1,+1)
	for i in sentouRenge:
		for j in kouhouRenge:
			sentou = inputStr[0:i]
			kouhou = inputStr[j:strLength]
			goukei = sentou+kouhou
			if goukei == "keyence":
				flag = True
	if flag:
		return "YES"
	else:
		return "NO"


if __name__ == '__main__':
	S = input().strip()
	solution = solveProblem(S)
	print("{}".format(solution))

Submission status: Accepted

Solution code:
import re

S = input()

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

flg = False
for r in reg:
  if re.search(r, S):
    flg = True

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

flag = False
for i in range(len(S)+1):
  for j in range(len(S)+1):
    if(S[:i]+S[j:] == 'keyence'):
      flag = True
      break
if(flag):
  print('YES')
else:
  print('NO')

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    s = input()
    n = len(s)

    for i in range(n):
        for k in range(i, n):
            if (s[:i] + s[k:]) == 'keyence':
                print('YES')
                exit()

    print('NO')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
N = len(S)
ok = 0
for i in range(N):
    for j in range(i, N+1):
        if S[:i] + S[j:] == 'keyence':
            ok = 1
print("YES" if ok else "NO")

Submission status: Accepted

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

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

print("NO")

Submission status: Accepted

Solution code:
s=input();print('NYOE S'['ke'in s and'e'==s[-1]::2])

Submission status: Accepted

Solution code:
import re

S = input()

pat = 'keyence'
for i in range(len(pat) + 1):
    if re.match('^%s.*%s$' % (pat[:i], pat[i:]), S):
        print("YES")
        break
else:
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
  s=input()
  for l in range(len(s)):
    for r in range(l,len(s)+1):
      if "keyence"==s[:l]+s[r:]:
        print("YES")
        return
  print("NO")

solve()

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S=str(input())

ans='keyence'

if S[-7:]=='keyence':
    print('YES')
    exit()
   
for i in range(1,7):
    if S[:i]==ans[:i] and S[-7+i:]==ans[i:]:
        print('YES')
        exit()

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

print('NO')

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
# B
import re
s = input() 
# s = "keyencLeL"
patterns = ["^.+keyence$", 
            "^k.+eyence$",
            "^ke.+yence$",
            "^key.+ence$",
            "^keye.+nce$",
            "^keyen.+ce$",
            "^keyenc.+e$",
            "^keyence.+$",
            "^keyence$"]

found = False
for p in patterns:   
    c = re.compile(p)
    m = c.match(s)
    if m: found = True
print("YES" if found else "NO")

Submission status: Accepted

Solution code:
import sys

S = input()
N = len(S)

ret = False
for i in range(0, N):
    for j in range(i, N):
        a = S[:i]
        b = S[j:]
        if a + b == "keyence":
            print("YES")
            sys.exit(0)

print("NO")

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
s = input()

i_t = 0
text="keyence"
continue_ = False

def check1(s, text):
    if s.find(text) == 0:
        return True
    else:
        return False
def check3(s, text):
    rev_text = text[::-1]
    rev_s    =    s[::-1]

    if rev_s.find(rev_text) == 0:
        return True
    else:
        return False

def check2(s, text):
    is_ok = False
    for i in range(1, 7): # 1 to 6
        first  = text[:i]
        second = text[i:]
        # print("first: ", first)
        # print("second: ", second)
        if check1(s, first) and check3(s,second):
            is_ok = True
            break
    if is_ok:
        return True
    else:
        return False

    
    
# print(check1(s, text) , check2(s, text) , check3(s, text))

if check1(s, text) or check2(s, text) or check3(s, text):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
# B　解２
S = input()
K = 'keyence'
lenK = len(K)
for i in range(len(S)+1):
    rem = S[:i]
    rem2 = S[-lenK+i:]
    if len(rem2)>7: rem2 = ''
    rem += rem2
    #print(rem)#
    if rem==K:
        res = 'YES'
        break
else: res = 'NO'        
print(res)

Submission status: Accepted

Solution code:
S = list(input())
s = ['k','e','y','e','n','c','e']
a = 0
for i in range(len(s)):
    if S[i] == s[i]:
        continue
    else:
        a = i
        break
else:
    print('YES')
    exit()


ss = s[a:]


for i in range(len(ss)):
    if ss[i] == S[len(S)-len(ss)+i]:
        continue
    else:
        print('NO')
        exit()

else:
    print('YES')

Submission status: Accepted

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

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

i = len(s) - 1
o = 6

while a != 7:
    if s[i] == t[o]:
        a += 1
    else:
        break
    i -= 1
    o -= 1

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

Submission status: Accepted

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

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


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

Submission status: Accepted

Solution code:
S = input()
keyword = "keyence"
R = S[::-1]
c=0
r = 0
for i in range(7):
    if S[i]==keyword[i]:
        c+=1
    if S[i] !=keyword[i] and R[r]==keyword[-1-r]:
        r+=1
if r+c ==7:
    print("YES")
else:print("NO")

Submission status: Accepted

Solution code:
S = list(input())
T = list("keyence")
f = 0
b = 0
for i in range(len(S)):
  if S[i] != T[i]:
    f = i
    break
for i in range(len(S)):
  if S[-1*i] != T[-1*i]:
    b = -1*i+1
    break
U = S[:f] + S[b:]
a = -1
for i in range(1, len(U)):
  if U[i] == U[i-1]:
    a = i
if a != -1:
  del U[a]
if U == T:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
import fnmatch
S=[]
S.append(input())
if S == fnmatch.filter(S, "k*eyence") or S == fnmatch.filter(S, "ke*yence") or S == fnmatch.filter(S, "key*ence") or S == fnmatch.filter(S, "keye*nce") or S == fnmatch.filter(S, "keyen*ce") or S == fnmatch.filter(S, "keyenc*e") :
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
S = input()
s = 'keyence'
c = False

for i in range(7):

    if S[:i] + S[len(S)-(7-i):] == s:
        c = True

if c == True:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
s=input()
S='keyence'
c=0
for i in range(7):
  if s[0:i]==S[0:i] and s[len(s)-7+i:len(s)]==S[i:7]:
    c+=1
if c>0:print('YES')
else:print('NO')