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

Solution (Python):
import re
i=input()
a=[".*keyence$","k.*eyence$","ke.*yence$","key.*ence$","keye.*nce$","keyen.*ce$","keyenc.*e$","keyence.*$"]
print(["YES","NO"][len([y for y in [re.match(x,i) for x in a] if y is not None])==0])

Solution (Python):
S = input()

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

for stt, end in patterns:
    if S.startswith(stt) and S.endswith(end):
        print('YES')
        break
else:
    print('NO')

Solution (Python):
def solve():
    k = "keyence"
    s = input()
    for i in range(0, 8):
        if s[:i] + s[i - 7:] == k:
            return "YES"
    return "NO"
print(solve())

Solution (Python):
import re

S = input()
key = 'keyence'

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

judge = "NO"

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

print(judge)

Solution (Python):
import re
 
S = input()
 
R = [
    "^.*keyence$",
    "^k.*eyence$",
    "^ke.*yence$",
    "^key.*ence$",
    "^keye.*nce$",
    "^keyen.*ce$",
    "^keyenc.*e$",
    "^keyence.*$",
]
 
for ri in R:
    if re.match(ri, S):
        print("YES")
        exit(0)
print("NO")

Solution (Python):
S = input()
k = "keyence"
 
for i in range(len(k)):
    if (S.startswith(k[:i]) and S.endswith(k[i:])):
        print('YES')
        break
else: 
    print("NO")

Solution (Python):
N = input()

S = 'keyence'
if S == N[:len(S)]:
    ans = 'YES'
elif S == N[-len(S):]:
    ans = 'YES'
else:
    for index in range(len(S)):
        if S[:index] == N[:index] and S[-(len(S) - index):] == N[-(len(S) - index):]:
            ans = 'YES'
            break
    else:
        ans = 'NO'

print(ans)

Solution (Python):
S = input()
L = len(S)
Truth = 0

for j in range(0, 8):
	if S[0:j] + S[L- 7 +j:] == "keyence":
		Truth = 1

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

Solution (Python):
def B():
    S = list(input())
    N = len(S)
    for i in range(N):
        for j in range(i, N):
            this_s = S[0:i] + S[j:N]
            if this_s == ['k', 'e', 'y', 'e', 'n', 'c', 'e']:
                ans = 1
                break
            else:
                ans = 0
        if ans:
            break
    if ans:
        print("YES")
    else:
        print("NO")
B()

Solution (Python):
S = str(input())
keyence = 'keyence'

if len(S) == 7: 
    if S==keyence:
        print('YES')
    else:
        print('NO')
else :
    for i in range(0,7):
      if keyence[:i] in S and keyence[i:] in S[S.index(keyence[:i])+i:] : 
        if i==0 and S.index(keyence)==0 : 
            print('YES')
            break
        elif i==0 and S.index(keyence)!=0 and len(S)-7 == S.index(keyence) : 
            print('YES')
            break
        elif i!=0 and S.index(keyence[:i])==0 and S[len(keyence[:i])+(len(S)-7):] == keyence[i:] :  
            print('YES')
            break
    else:
        print('NO')

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

Solution (Python):
S = input().strip()

T = "keyence"

found = False
if len(S)<len(T):
    print("NO")
else:
        for start in range(len(T)):
            if S.startswith(T[:start]) and S.endswith(T[start:]):
                found = True
                break

        if S.startswith(T):
            found = True

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

Solution (Python):
S = input()
l = len(S)
OK = False
if S[0:7]=='keyence':
    OK = True
elif S[l-7:]=='keyence':
    OK = True
elif S[l-6:]=='eyence' and S[0]=='k':
    OK = True
elif S[l-5:]=='yence' and S[:2]=='ke':
    OK = True
elif S[l-4:]=='ence' and S[:3]=='key':
    OK = True
elif S[l-3:]=='nce' and S[:4]=='keye':
    OK = True
elif S[l-2:]=='ce' and S[:5]=='keyen':
    OK = True
elif S[l-1:]=='e' and S[:6]=='keyenc':
    OK = True
else:
    OK = False
print('YES' if OK else 'NO')

Solution (Python):
def main() :
	S = input()

	remove_len = len(S)  - 7

	for i in range(len(S) - remove_len) :
		
		s = S[0:i] + S[i+remove_len:]
		if (s == "keyence") :
			print("YES")
			return

	print("NO")


main()

Solution (Python):
s=input()
key="keyence"

l=len(s)

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

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

Solution (Python):
S=input()
K='keyence'
flag=False

for i in range(len(K)):
    if S[:i]+S[i+len(S)-len(K):]==K:
        flag=True

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

Solution (Python):
import re

S = input()

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

for ri in R:
    if re.match(ri, S):
        print("YES")
        exit(0)
print("NO")

Solution (Python):
import re
s=input()
if re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s):
    print("YES")
else:print("NO")

Solution (Python):
import re
s=input()
if re.match(".*keyence$",s) or re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s):
    print("YES")
else:print("NO")

Solution (Python):
s = input()
N = len(s)

bl = False
for i in range(N):
    for j in range(i, N):
        t = s[:i] + s[j:]
        if t == 'keyence':
            bl = True
            break

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

Solution (Python):


import re
s=input()
r="keyence"
res=False

for i in range(0,len(r)):
  r1=r[:i+1]
  r2=r[-(len(r)-i-1):]
  r1i=s.find(r1)
  r2i=s.rfind(r2)
  
  if r1i<0 or r2i<0:
    continue
  elif r1i==0:
    if r2i==len(s)-len(r2):
      res=True
if s.find(r)>=0 and s.find(r)==len(s)-len(r):
  res=True
if s.find(r)==0:
  res=True
    
  
if res:
  print('YES')
else:
  print('NO')

Solution (Python):
S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")

Solution (Python):
S = input()
k = "keyence"

res = False

if S[0:7] == k:
    res = True
elif S[-7:0] == k:
    res = True
    
for i in range(1,7):
    if S[0:i] == k[0:i] and S[i-7:] == k[i-7:]:
        res = True
        
if res:
    print("YES")
else:
    print("NO")

Solution (Python):
s = input()

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

Solution (Python):
s=input()
t="keyence"

if t in s:
  if s.find(t)==0 or s.find(t)==len(s)-7:
    print("YES")
  else:
    print("NO")
else:
  for i in range(1,7):
    a,b=t[:i],t[i:]
    if a in s and b in s:
      if s.find(a)==0 and s.rfind(b)==len(s)-len(b):
        print("YES")
        break
  else:
    print("NO")

Solution (Python):
S = input()

ans = False

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

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

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

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

Solution (Python):
s=input()
ans='keyence'
i=0 
index=0 
isCut=0
canRestart=0
restart=0
lenS=len(s)
while i<lenS:
    
    if isCut==1: 
        if index>6: 
            if canRestart:
                canRestart=0
                isCut=-1
                i=restartI
                index=restartIndex
            else:
                break
        else:
            if s[i]==ans[index]:
                index+=1
            else:
                if canRestart:
                    canRestart=0
                    isCut=-1
                    i=restartI
                    index=restartIndex
                else:
                    break
    elif isCut==-1: 
        if s[i]==ans[index]:
            
            restartIndex=index
            restartI=i
            canRestart=1
            isCut=1
            index+=1
    else: 
        if s[i]==ans[index]:
            index+=1
        else:
            isCut=-1
    i+=1
    
if (index<=6)|(i<lenS)|(isCut==-1): 
    print('NO')
else:
    print('YES')

Solution (Python):
import sys
s = input()
k = 'keyence'
for i in range(len(s) - 1):
  for j in range(1, len(s)):
    if (s[:i] + s[j:] == k):
      print('YES')
      sys.exit()
print('NO')

Solution (Python):
S = input()

keyence = "keyence"

isKey = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            isKey = True
            break
    if isKey:
        break

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

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

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

Solution (Python):
S = input()

ans = False

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

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

Solution (Python):
s = input()

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

Solution (Python):
def main():
    S = input()
 
    key = "keyence"
 
    for i in range(len(key)):
        
        if (S.startswith(key[:i]) and S.endswith(key[i:])):
            return True
    return False
if (main()):
    print("YES")
else:
    print("NO")

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

for i in range(n): 
    for j in range(i,n): 
        tmp = s[:i]+s[j:]
        if tmp == "keyence":
            print("YES")
            quit()

print("NO")

Solution (Python):
S = input()
length = len(S)

for i in range(length):
    for j in range(i, length):
        if S[:i] + S[j:] == "keyence":
            print("YES")
            exit(0)
print("NO")

Solution (Python):
s=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')

Solution (Python):
import re

p = input()
a = 'keyence'

if p[:7] == a or p[:6] + p[-1:] == a or p[:5] + p[-2:] == a or p[:4] + p[-3:] == a or p[:3] + p[-4:] == a or p[:2] + p[-5:] == a or p[0] + p[-6:] == a or p[-7:] == a:
    print('YES')
else:
    print('NO')

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

for i in range(n):
    for j in range(i, n):
        tmp = s[:i]+s[j:]
        if tmp == "keyence":
            print("YES")
            quit()

print("NO")

Solution (Python):
S = input()

def is_keyence(S):
    key = "keyence"
    for i in range(len(key)):
        
        if (S.startswith(key[:i]) and S.endswith(key[i:])):
            return True
    return False


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

Solution (Python):
import re
key = list(str(input()))
keyence = list('^keyence$')
flag = 0

keylist = []
for i in range(1, len(keyence)):
    keyence.insert(i, r'\w*')
    
    key = ''.join(key)
    keyence = ''.join(keyence)
    result = re.match(keyence, key)
    if result:
        print("YES")
        quit()
    
    key = list(str(key))
    keyence = list(str(keyence))
    
    for s in r'\w*':
        keyence.remove(s)

print("NO")

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

Solution (Python):
def main():
    S = input()

    key = "keyence"

    for i in range(len(key)):
        
        if (S.startswith(key[:i]) and S.endswith(key[i:])):
            return True
    return False
if (main()):
    print("YES")
else:
    print("NO")

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

for i in range(n):
    for j in range(i, n):
        tmp = s[0:i]+s[j:]
        if tmp == "keyence":
            print("YES")
            quit()

print("NO")

Solution (Python):
S = input()

len_s = len(S)
key_s = "keyence"
len_key_s = len(key_s)

def main(S, key_s):
    if len_s >= len_key_s:
        ok =True
        for char_i in range(len_key_s):
            if key_s[char_i] != S[char_i]:
                first_diff_i = char_i
                ok = False
                break

        if ok: 
            
            return True
        else:
            end_diff_i = None
            for rev_char_i in range(len_key_s):
                char_i = - rev_char_i - 1
                
                if key_s[char_i] != S[char_i]:
                    end_diff_i = char_i
                    break

            if end_diff_i is None:
                end_diff_i = - len_key_s - 1

            mod_S = S[:first_diff_i] + S[end_diff_i+1:]

            if mod_S == key_s:
                
                return True
            else:
                
                
                last_char = mod_S[0]
                mod_S2 = last_char
                for char in mod_S[1:]:
                    if last_char != char:
                        mod_S2 += char
                    last_char = char
                
                if mod_S2 == key_s:
                    return True

                return False
    else:
        
        return False

res1 = main(S, key_s)



res = res1

out = "YES" if res else "NO"
print(out)

Solution (Python):
import re
x = input()

answer = "NO"

if len(re.findall(".*keyence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^k.*eyence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^ke.*yence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^key.*ence$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keye.*nce$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keyen.*ce$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keyenc.*e$", x)) > 0 :
    answer = "YES"

elif len(re.findall("^keyence.*", x)) > 0 :
    answer = "YES"

print(answer)

Solution (Python):
import re

S=input()

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

Solution (Python):
import sys
s = list(input())

for i, string in enumerate(s):
    if s[:7] == list("keyence"):
        print("YES")
        sys.exit()

    if s[i] != "keyence"[i]:
        for j in range(len(s)-i):
            if s[i+j] == "keyence"[i]:
                if s[:i]+s[i+j:] == list("keyence"):
                    print("YES")
                    sys.exit()
        break

print("NO")

Solution (Python):
S = input ( )

dusted = False
cont = False
line = 'keyence'
find = S.find ( 'keyence' )
rfind = S.rfind ( 'keyence' )

if find == 0 or rfind == len ( S ) - 7:
    print ( 'YES' )
    exit ( 0 )
elif find != -1:
    print ( 'NO' )
    exit ( 0 )

fs = True
line = ''
keyence = [ c for c in "keyence" ]
a_err=False
b_err=False
keyence2='keyence'
count=0
for i in range(len ( S )):

    
    
    try:
        if not  b_err:
            

            if keyence2[ 6 - i ] != S[ len ( S ) - 1 - i ]:
                b_err=True
            if not b_err:
                keyence.remove ( S[len(S)-1-i] )

            count+=1

    except ValueError:
        b_err=True

    if not keyence:
        print ( 'YES' )
        exit ( 0 )
    try:
        if not a_err:
            if keyence2[ i ] != S[ i]:
                a_err=True
            if not a_err:
                keyence.remove ( S[i] )
    except ValueError:
        a_err=True

    if a_err and b_err:
        print('NO')
        exit(0)

    if not keyence:
        print ( 'YES' )
        exit ( 0 )

Solution (Python):
a = "keyence"

b = input()
o = 0
k = len(b)
j = 0
jj = 0
kk = [0 for i in range(8)]
al = 0
if k == 7:
	if a == b:
		print("YES")
	else:
		print("NO")
elif k >= 8:
	for i in range(k):
		if j == 7:
			al = 1
			print("YES")
			break
		if b[i] == a[j] and jj == 0:
			j += 1
		else:
			jj = 1
			o = j
		if jj == 1 and o == 0:
			if b[-7:] == a:
				print("YES")
				break
			else:
				print("NO")
				break
		elif jj == 1:
			if b[-(7-o):] == a[o:]:
				print("YES")
				break
			else:
				print("NO")
				break
else:
	print("NO")

Solution (Python):
str=str(input())
k="keyence"
for i in range(8):
  l=str.find(k[0:i])
  r=str.rfind(k[i:7])
  if(l==0 and r==len(str)-(7-i) and l-r<=0):
    print("YES")
    break
else:
  print("NO")

Solution (Python):
text = input()
i = 0
ans = "keyence"
for ob_n in range(len(ans)):
    if text[i] != ans[ob_n]:
        if text.endswith(ans[ob_n:]):
            flag = 1
            break
        else:
            flag = 0
            break
    i+=1
    if i == len(text):
        flag = 1
        break
if flag == 1:
    print("YES")
else :
    print("NO")

Solution (Python):
s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
c=0
if len(s)>=7:
    while c<7:
        if s[c]!=k[c]:
            break
        c+=1
    if c==7:
        ans="YES"
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)

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

Solution (Python):
S = input()
T = "keyence"

result = "NO"

for n in range(1, 7):
    m = 7 - n
    if S[:n] == T[:n] and S[-m:] == T[-m:]:
        result = "YES"
        break

print(result)

Solution (Python):
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
n = len(s)
if s[0:7] == search:
    print("YES")
elif (s[-7:] == search):
    print("YES")
else:
    for i in range(7):
        if s[0:i+1] == search[0:i+1]:
            
            
            if (s[(-7+i+1):] == search[i+1:]):
                ans = "YES"
                break
    print(ans)

Solution (Python):
S = input()
key = 'keyence'

re = 'NO'
for i in range(1,7):
    bef = key[0:i]
    aft = key[i:]
    b_index = S.find(bef)
    a_index = S.rfind(aft)
    if b_index == 0 and a_index + len(aft) == len(S) : 
        re = 'YES'
        break
    elif (b_index == 0 or a_index + len(aft) == len(S)) and b_index + len(bef) == a_index: 
        re = 'YES'
        break

print(re)

Solution (Python):
S = input()

keyence = 'keyence'

if keyence in S:
    print('YES')
else:
    result = 'NO'
    for i in range(1, len(keyence)):
        delimiters = keyence[:i], keyence[i:]
        if S.startswith(delimiters[0]) and S.endswith(delimiters[1]):
            result = 'YES'
            break
    print(result)

Solution (Python):
num_list = input()
key = 'keyence'
i = 0
l = len(num_list)

n = 0

while num_list[i]==key[i]:
    i+=1
    n +=1
    if n==7:
        print('YES')
        exit()

i = -1
while num_list[i]==key[i]:
    n += 1
    i -= 1
    if n==7:
        print('YES')
        exit()
print('NO')

Solution (Python):
s = input()
a = 'keyence'
flag = 1

if s == a:
    print('YES')
    flag = 0

for i in range(1,len(s)-6):
    
    for j in range(len(s)-i+1):
        if s[0:j]+s[j+i:] == a:
            print('YES')
            flag = 0
            break

if flag == 1:
    print('NO')

Solution (Python):
s=input()
x='keyence'
if s==x:
  print('YES')
  exit()
if s.count(x)>0:
  p=s.split('keyence')
  if p[0]=='' or p[1]=='':
    print('YES')
    exit()
  elif p[0]+p[1]=='keyence':
    print('YES')
    exit()
for i in range(1,len(x)):
  a=x[:i]
  b=x[i:]
  if s.count(a)>0 and (s.index(a)==0 and s[len(s)-len(b):]==b):
    print('YES')
    exit()
  else:
    continue
print('NO')

Solution (Python):
import re

keyence = "keyence"
S = raw_input()
ans = False
found = False
for i in range(len(keyence)+1):
  if re.match("^"+keyence[:i]+".*"+keyence[i:]+"$",S):
    ans = True
print "YES" if ans or S == keyence else "NO"

Solution (Python):
from sys import stdin
import re
flug = 0
l = stdin.readline()
for i in range(7):
    pattern = list("keyence$")
    pattern.insert(i, "[a-z]*")
    
    r = re.compile("".join(pattern))
    if (r.match(l) != None) :
        if flug == 0:
            print("YES")
        flug = 1

if(flug == 0):
    print("NO")

Solution (Python):
import re
str_in_org = input()
KEYENCE = 'keyence'
flag = False
for n in range(1,7):
    str_in = str_in_org
    len_in = len(str_in)
    len_tail = len_in - (7 - n)
    str_div1 = str_in[:n]
    str_div2 = str_in[len_tail:]
    key_div1 = KEYENCE[:n]    
    key_div2 = KEYENCE[n:]
    
    if( str_div1 == key_div1 and str_div2 == key_div2 ):
        if( str_div1 + str_div2 == KEYENCE ):
            flag = True
if flag == True :
    print ('YES')
else:
    print ('NO')

Solution (Python):
import re
input_string = input()
keyence = "keyence"
patterns = ['^.*(keyence)$', '^k.*eyence$', '^ke.*yence$', '^key.*ence$', '^keye.*nce$', '^keyen.*ce$', '^keyenc.*e$', '^keyence.*$']
flag = False
for i in range(len(patterns)):
    result = re.match(patterns[i], input_string)
    if result:
        flag = True
        break
if flag == True:
    print("YES")
else:
    print("NO")

Solution (Python):
s = input()
l = (['', 'keyence'], ['k', 'eyence'], ['ke', 'yence'], ['key', 'ence'],
     ['keye', 'nce'], ['keyen', 'ce'], ['keyenc', 'e'], ['keyence', ''])
for a in l:
    p, q = a[0], a[1]
    if s.startswith(p) and s.endswith(q):
        exit(print('YES'))
print('NO')

Solution (Python):
import re
from sys import stdin
N=(stdin.readline().rstrip())
for i in range(7):
    mae="keyence"[0:i+1]
    ato="keyence"[i+1:8]
    if re.search(".*keyencekeyence",N):
        if (re.sub('.*keyencekeyence', '', N)=="")==True:
            print("YES")
            break
    if re.search("keyencekeyence.*",N):
        if (re.sub('keyencekeyence.*', '', N)=="")==True:
            print("YES")
            break
    if (re.sub('.*keyence', '', N)=="")==True:
        print("YES")
        break
    if (re.sub('keyence.*', '', N)=="")==True:
        print("YES")
        break
    if re.match("%s.*%s"%(mae, ato),N):
        if (re.sub('%s.*%s'%(mae,ato) ,"", N)=="")==True:
            print("YES")
            break
if i==6:
    print("NO")

Solution (Python):
S = raw_input()
if S.startswith('k') and S.endswith('eyence'):
    print('YES')
elif S.startswith('ke') and S.endswith('yence'):
    print('YES')
elif S.startswith('key') and S.endswith('ence'):
    print('YES')
elif S.startswith('keye') and S.endswith('nce'):
    print('YES')
elif S.startswith('keyen') and S.endswith('ce'):
    print('YES')
elif S.startswith('keyenc') and S.endswith('e'):
    print('YES')
elif S == 'keyence':
    print('YES')
else:
    print('NO')

Solution (Python):
def A():
    S = list(input())
    cnt = 0
    p = 3
    keyence = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
    for i in range(7):
        if S[i] != keyence[i]:
            cnt = i
            break
    ans = 0
    if S[:7:] == keyence:
        ans = 1
    elif S[len(S) - 7::] == keyence:
        ans = 1
    elif S[len(S) - (7 - cnt)::] == keyence[cnt::]:
        ans = 1
    else:
        ans = -1
    if ans == 1:
        print("YES")
    else:
        print("NO")
    
A()

Solution (Python):




s = input()


key_str = "keyence"
ans = "NO"
search_idx = 0


if s[0] == key_str[0]:
    
    for idx in range(len(s)):
        if s[idx] == key_str[search_idx]:
            search_idx += 1
            if search_idx == len(key_str):
                
                ans = "YES"
                break

        else:
            
            for idx2 in range(len(s) - len(key_str) + search_idx, len(s)):
                if s[idx2] == key_str[search_idx]:
                    search_idx += 1
                    if search_idx == len(key_str):
                       ans = "YES"
            break
else:
    
    for idx in range(len(s) - len(key_str), len(s)):
        if s[idx] == key_str[search_idx]:
            search_idx += 1
            if search_idx == len(key_str):
                ans = "YES"
                break


print(ans)

Solution (Python):
S=input()
answer = 'NO'

if 'keyence' in S:
    answer = 'YES'
elif S[:6] == 'keyenc':
    if S[-1:] == 'e':
        answer = 'YES'
elif S[:5] == 'keyen':
    if S[-2:] == 'ce':
        answer = 'YES'
elif S[:4] == 'keye':
    if S[-3:] == 'nce':
        answer = 'YES'
elif S[:3] == 'key':
    if S[-4:] == 'ence':
        answer = 'YES'
elif S[:2] == 'ke':
    if S[-5:] == 'yence':
        answer = 'YES'
elif S[:1] == 'k':
    if S[-6:] == 'eyence':
        answer = 'YES'

print(answer)

Solution (Python):

S = input()
K = 'keyence'
k = 0
for i in range(1,len(K)):
    n = S.find(K[:i])
    
    m = S[n+i:].find(K[i:])
    
    
    
    
    if (n==0 and m==0) or (n==0 and m>0 and S[-len(K[i:]):]==K[i:]) or \
        (n>0 and S[n+i:]==K[i:]):
        
        res = 'YES'
        break
else: res = 'NO'        
print(res)

Solution (Python):
s = input()
n = len(s)
i = 0
if 'k' in s and 'eyence' in s:
    if s[:1] =='k' and s[n-6:] == 'eyence':
        print('YES')
        exit()
if 'ke' in s and 'yence' in s:
    if s[:2] =='ke' and s[n-5:] == 'yence':
        print('YES')
        exit()
if 'key' in s and 'ence' in s:
    if s[:3] =='key' and s[n-4:] == 'ence':
        print('YES')
        exit()
if 'keye' in s and 'nce' in s:
    if s[:4] =='keye' and s[n-3:] == 'nce':
        print('YES')
        exit()
if 'keyen' in s and 'ce' in s:
    if s[:5] =='keyen' and s[n-2:] == 'ce':
        print('YES')
        exit()
if 'keyenc' in s and 'e' in s:
    if s[:6] =='keyenc' and s[n-1:] == 'e':
        print('YES')
        exit()
if 'keyence' in s:
    if s[:7] == 'keyence' or s[n-7:] == 'keyence':
        print('YES')
        exit()
print('NO')

Solution (Python):
S=input()
answer = 'NO'

if 'keyence' in S:
    answer = 'YES'
elif S[:6] == 'keyenc':
    if S[-1:] == 'e':
        answer = 'YES'
elif S[:5] == 'keyen':
    if S[-2:] == 'ce':
        answer = 'YES'
elif S[:4] == 'keye':
    if S[-3:] == 'nce':
        answer = 'YES'
elif S[:3] == 'key':
    if S[-4:] == 'ence':
        answer = 'YES'
elif S[:2] == 'ke':
    if S[-5:] == 'yence':
        answer = 'YES'
elif S[:1] == 'k':
    if S[-6:] == 'eyence':
        answer = 'YES'

print(answer)

Solution (Python):
S = input()

tag = 'keyence'

ans = 0

if S[0:7]==tag:
    ans = 1
elif S[len(S)-7:len(S)]==tag:
    ans = 1
else:
    for j in range(1, 6):
        f_tag = tag[0:j]
        a_tag = tag[j+1:7]
        f = 1
        for k in range(len(f_tag)):
            if not S[k]==f_tag[k]:
                f = -1
        for k in range(len(a_tag)):
            if not S[len(S)-len(a_tag)+k]==a_tag[k]:
                f = -1
        if f>0:
            ans = 1

if ans>0:
    print('YES')
else:
    print('NO')

Solution (Python):
S = input()
key_str = 'keyence'

ans = 'NO'
for i in range(len(key_str)):
    if i == 0:
        if S.startswith(key_str) or S.endswith(key_str):
            ans = 'YES'
            break
    else:
        left = key_str[:i]
        right = key_str[i:]
        if S.startswith(left) and S.endswith(right):
            ans = 'YES'
            break
print(ans)

Solution (Python):
S = input()
T = "keyence"

if S == T:
    print("YES")
    exit(0)

for i in range(7):
    if S.startswith(T[:i]) and S.endswith(T[i:]):
        print("YES")
        break
else:
    print("NO")

Solution (Python):
import sys
S = input().strip()
keyence = "keyence"
n = len(keyence)

if keyence in S:
    k = S.find(keyence)
    if k == 0:
        print("YES")
        sys.exit()
    elif k + n == len(S):
        print("YES")
        sys.exit()

for i in range(n):
    if S[:i] == keyence[:i] and S[-(n-i):] == keyence[-(n-i):]:
        print("YES")
        sys.exit()

print("NO")

Solution (Python):
S=raw_input()

if S=="keyence":
	print "YES"
	quit()

l=len(S)
l_amari=len(S)-7

for i in range( l - l_amari+1):
	str1=S[0:i]
	str2=S[i+l_amari:]
	if str1+str2 == "keyence":
		print "YES"
		quit()
else:
	print "NO"

Solution (Python):
S = input()

k = 'keyence'


if S.find(k) == 0 or S.find(k) == len(S) - 7:
    print('YES')
    exit()

for i in range(1, len(k)):
    if S.find(k[:i]) == 0 and S[::-1].find(k[i:][::-1]) == 0:
        print('YES')
        exit()

print('NO')

Solution (Python):
S=input()
N=len(S)

K='keyence'

for n in range(7):
    if S[n]!=K[n]:
        if S[N-7+n:N]==K[n:7]:
            print('YES')
            break
        else:
            print('NO')
            break

    if n==6:
        print('YES')

Solution (Python):
S=input()
s=list()
a=['k','e','y','e','n','c','e']
j,p=1,1
for i in S:
	s.append(i)
c,t=len(s),len(a)
if s[0]!=a[0]:
	if s[-t:c]!=a:
		p=0
else:
	for i in range(6):
		if (s[0:j]!=a[0:j]) & (s[(-t):c]!=a[(-t):7]):
			p=0
		t=t-1
		j=j+1
if p==1:
	print('YES')
elif p==0:
	print('NO')

Solution (Python):
s=input()
q=0

if s.find("keyence")!=-1:
    q=1
else:
    if s[:6]== "keyenc" and s[len(s)-1]=="e":
        q=1
    else:
        if s[:5]=="keyen" and s[len(s)-2:]=="ce":
            q=1
        else:
            if s[:4]=="keye" and s[len(s)-3:]=="nce":
                q=1
            else:

                if s[:3]=="key" and s[len(s)-4:]=="ence":
                    q=1
                else:

                    if s[:2]=="ke" and s[len(s)-5:]=="yence":
                        q=1
                    else:

                        if s[0]=="k" and s[len(s)-6:]=="eyence":
                            q=1
if q==1:
    print("YES")
else:
    print("NO")