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:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  1/13 21:11:56 2019

# Usage
#
"""
from collections import Counter
TARGET = "keyence"

def get_input():
    return input()

def solve(s):
    """
    >>> solve("keyence")
    YES
    >>> solve("keyofscience")
    YES
    >>> solve("ashlfyha")
    NO
    """
    pos = 0
    for i in TARGET:
        pos = mog(s,i,pos)
        if pos == -1:
            return "NO"
    return "YES"

def mog(original, target, pos):
    """
    >>> mog("keyence", "k", 0)
    1
    >>> mog("aaa", "k", 0)
    -1
    """
    if len(original) == pos:
        return -1

    if original[pos] == target:
        return pos + 1
    else:
        return mog(original, target, pos+1)

if __name__ == '__main__':
    print(solve(get_input()))

Submission status: Wrong Answer

Solution code:
import re

S=input()

if re.match("keyence",S) or re.match("^([a-x]+)keyenc$e",S) or re.match("^k([a-x]+)eyenc$e",S) or re.match("^ke([a-x]+)yenc$e",S) or re.match("^key([a-x]+)enc$e",S) or re.match("^keye([a-x\s]+)nc$e",S) or re.match("^keyen([a-x]+)c$e",S) or re.match("^keyenc([a-x]+)$e",S)  or re.match("^keyence$([a-x]+)",S):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
if(s[0]=='k'):
    for i in range(len(s)):
        for j in range(i,len(s)):
            for k in range(j,len(s)):
                for l in range(k,len(s)):
                    t=s[i:j+1]+s[k:l+1]
                    if(t=='keyence'):
                        print('YES')
                        exit()
    print('NO')
if(s[0]!='k'):
    if(s[-7:]=='keyence'):
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  1/13 21:11:56 2019

# Usage
#
"""
from collections import Counter
TARGET = "keyence"

def get_input():
    return input()

def solve(s):
    """
    >>> solve("keyence")
    YES
    >>> solve("keyofscience")
    YES
    >>> solve("ashlfyha")
    NO
    """
    pos = 0
    for i in TARGET:
        pos = mog(s,i,pos)
        print(i, pos)
        if pos == -1:
            return "NO"
    return "YES"

def mog(original, target, pos):
    """
    >>> mog("keyence", "k", 0)
    1
    >>> mog("aaa", "k", 0)
    -1
    """
    print("mog: " + str(pos))
    if len(original) == pos:
        return -1

    if original[pos] == target:
        return pos + 1
    else:
        return mog(original, target, pos+1)

if __name__ == '__main__':
    print(solve(get_input()))

Submission status: Wrong Answer

Solution code:
S = input()

keyence = list("keyence")

pos_list = []

for i, char in enumerate(S):
    if len(keyence) == 0:
        break
    if char == keyence[0]:
        pos_list.append(i)
        del keyence[0]

diff = map(lambda x, y: x - y, pos_list[1:], pos_list[:-1])
over_one_num = len(list(filter(lambda x: x > 1, diff)))

if over_one_num <= 1 and len(pos_list) == len(keyence):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
s = input()
time = 0
i = 0
n = 0
for i in range(7):
    if s[i+n] != "keyence"[i]:
        time += 1
        if time >= 2:
            print("NO")
            sys.exit()
        while "keyence"[i] != s[i+n]:
            n += 1
            if i+n >= len(s):
                print("NO")
                sys.exit()
if (len(s) - 7 <= n):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

ans = 'YES'
idx = 0
substr_cnt = 0
for key in key_str:
    exsist_key = False
    for i in range(idx, len(S)):
        if key == S[i]:
            exsist_key = True
            if i != idx:
                substr_cnt += 1
            idx = i+1
            break

    if not exsist_key or substr_cnt > 1:
        ans = 'NO'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  1/13 21:11:56 2019

# Usage
#
"""
from collections import Counter
TARGET = "keyence"

def get_input():
    return input()

def solve(s):
    """
    >>> solve("keyence")
    YES
    >>> solve("keyofscience")
    YES
    >>> solve("ashlfyha")
    NO
    """
    pos = 0
    for i in TARGET:
        pos = mog(s,i,pos)
        print(i, pos)
        if pos == -1:
            return "NO"
    return "YES"

def mog(original, target, pos):
    """
    >>> mog("keyence", "k", 0)
    1
    >>> mog("aaa", "k", 0)
    -1
    """
    print("mog: " + str(pos))
    if len(original) == pos:
        return -1

    if original[pos] == target:
        return pos + 1
    else:
        return mog(original, target, pos+1)

if __name__ == '__main__':
    import doctest
    doctest.testmod()

    # print(solve(get_input()))

Submission status: Wrong Answer

Solution code:
S = input()
k = "keyence"
ans = "NO"
if S.find(k) > -1:
    ans = "YES"
else:
    for i in range(6):
        a,b = S.find(k[:i+1]),S.find(k[i+1:])
        if a > -1 and b > -1 and a + len(k[:i+1]) < b:
            ans = "YES"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
key='keyence'
ans='NO'
for i in range(len(key)):
    key1=key[:i]
    key2=key[i:]
    A=key1+'0'*(len(S)-len(key))+key2
    for l in range(len(S)):
        if all([S[l]==A[l] or A[l]=='0' for l in range(len(S))]):
            ans='YES'
            print(A)
print(ans)

Submission status: Wrong Answer

Solution code:
k = input()
n = 'keyence'
z = 0
for i in range(len(k)):
    if k[i] == 'k':
        for j in range(len(n)):
            if k[i+j] != n[j]:
                z += 1
                for p in range(i+j, len(k)):
                    z = i+j+p
                    if n[j:] in k[z:]:
                        break
                    else:
                        z += 1
                        break
            
            break
    else:
        z = 2
    break

if z == 0 or z == 1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
key = 'keyence'
word = ''
s = input()
s_list = list(s)
flag = True
if key == s:
    print('YES')
    flag = False

for i in key:
    if not i in s_list:
        print('NO')
        flag = False
        break
    s_list.remove(i)

for j in s_list:
    word += j

if flag:
    if s.find(word):
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
k = 'keyence'
if (k in s):
  print('YES')
  sys.exit()
left = 0
right = 0
for i in range(len(s)):
  if (s[i] == k[i]):
    left += 1
  else:
    break
for j in range(1, len(s)):
  if (s[-1 * j] == k[-1 * j]):
    right += 1
  else:
    break
if(left + right == len(k)):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
a = 'keyence'
s = input()
S = len(s)
c = 0
i = 0
while i < S:
    if s[i] == a[c]:
        c += 1
    i += 1
    if c == 7:
        break
if c == 7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
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()
else:
  for i in range(1,len(x)):
    a=x[:i]
    b=x[i:]
    if s.count(a)>0 and s.count(b)>0:
      y=s.split(a)
      z=s.split(b)
      if y[0]=='' and z[1]=='':
        print('YES')
        exit()
    else:
      continue
print('NO')

Submission status: Wrong Answer

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

keyStr=input()
keyence="keyence"

before=""
after=""
chkflg=False

for char in range(len(keyence)-1):
  before=keyence[0:char+1]
  after=keyence[char+1:len(keyence)]
  
  bindex= keyStr.find(before)
  if bindex >= 0:
    if keyStr[bindex+len(before):len(keyStr)].find(after) >= 0:
      print("YES")
      chkflg=True
      break

if chkflg == False:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

target = "keyence"

for i in range(len(target)):
    if target[:i] in S:
        continue
    else:
        if target[i:] in S:
            print("YES")
        else:
            print("NO")
        break
else:
    print("YES")

Submission status: Wrong Answer

Solution code:
N=input()
kye="keyence"
Nlen=len(N)
i=0
flag=0
while flag==0 and N[i]==kye[i]:
    if i==6:
        flag=1
    i=i+1

x=i
while flag==0:
    if N[x]!=kye[i]:
        
        x=x+1
    else:
        break
    if x==Nlen-1:
        flag=2
    

while flag==0 and N[x]==kye[i]:
    if i==6:
        flag=1
    i=i+1
    x=x+1

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

Submission status: Wrong Answer

Solution code:
S = input()
S_list = [s for s in S]
trueWord = 'keyence'
truen = len(trueWord)  
n = 0
skip = 0
answer = 'NO'
pre = True
cur = True

for i in range(len(S)):
    s = S_list[i]
    if s == trueWord[n]:
        n += 1
        cur = True
    else:
        cur = False

    if pre != cur:
        skip += 1
    pre = cur

    if skip > 2:
        break

    if n == truen:
        answer = 'YES'
        break

print(answer)

Submission status: Wrong Answer

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

keyStr=input()
keyence="keyence"

before=""
after=""
chkflg=False

for char in range(len(keyence)-1):
  before=keyence[0:char+1]
  after=keyence[char+1:len(keyence)]
  print(before)
  print(after)
  
  bindex= keyStr.find(before)
  if bindex >= 0:
    if keyStr[bindex+len(before):len(keyStr)].find(after) >= 0:
      print("YES")
      chkflg=True
      break

if chkflg == False:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = 'keyence'
S = input()
ans = 'NO'

for i in range(len(S)):
    if S[i] == 'k':
        for l in range(1, len(s)):
            if S[i+l] != s[l]:
                break
        for n in range(len(S)):

            if S[i:l] + S[l+n:l+n+7-3] == s:
                ans = 'YES'
                break
    if ans == 'YES':
        break
print(ans)

Submission status: Wrong Answer

Solution code:
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return -1
 
a = input().split("#")
a = list(a[0])
judge = 0
A = []
B = []
 
A.append(my_index(a, 'k'))
if (my_index(a, 'k') != -1):
 a[ my_index(a, 'k') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'e'))
if (my_index(a, 'e') != -1):
 a[ my_index(a, 'e') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'y'))
if (my_index(a, 'y') != -1):
 a[ my_index(a, 'y') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'e'))
if (my_index(a, 'e') != -1):
 a[ my_index(a, 'e') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'n'))
if (my_index(a, 'n') != -1):
 a[ my_index(a, 'n') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'c'))
if (my_index(a, 'c') != -1):
 a[ my_index(a, 'c') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'e'))
if (my_index(a, 'e') != -1):
 a[ my_index(a, 'e') ] = 'AAA'
 judge += 1
 
B = A
A.sort()
if( (A == B) and (judge==7) ):
 print('YES')
else:
 print("NO")

Submission status: Wrong Answer

Solution code:
N = input()

S = 'keyence'
index = 0
for item in N:
    if index == len(S):
        break
    if S[index] == item:
        index += 1
    else:
        break

if index == 7:
    print('YES')
elif S == N[:len(S)]:
    print('YES')
elif S == N[-len(S):]:
    print('YES')
else:
    print('YES' if S[len(S) - index - 1:] == N[-(len(S) - index):] else 'NO')

Submission status: Wrong Answer

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

a="keyence"
cnt=0
i=0
j=0
ans=""
if l<7:
  ans="NO"
elif s==a:
  ans="YES"
else:
  while(i<l):
    if s[i]==a[j]:
      cnt+=1
      i+=1
      j+=1
      
    else:
      i+=l-7
      
if cnt==7:
  ans="YES"
else:
  ans="NO"
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
s = input()
key = 'keyence'
key_r = 'ecneyek'
j = 0
for i in key:
    if s[j] == i:
        j += 1
    else:
        break
k = -1
for i in key_r:
    if s[k] == i:
        k -= 1
    else:
        break

s = s[:j] + s[k:]
if j >= k + 1:
    s = key
elif len(s) > 7:
    s = key
if s == key:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
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.find(k[i:]) == len(S) - 7 + i:
        print('YES')
        exit()

print('NO')

Submission status: Wrong Answer

Solution code:
import copy

S = list(input())
ja = 0

sremove = ""
S_tmp = []

for i in range(len(S)):
    for j in range(i,len(S)+1):
        S_tmp = copy.deepcopy(S)

        del S_tmp[i:j]
        print(i,j)
        print(S_tmp)

        if "".join(S_tmp) == "keyence":
            ja = 1
            break

if ja == 1:
    print("YES")

else:
    print("NO")

Submission status: Wrong Answer

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

for i in range(len(t)-1):
    t1=t[:i+1]
    t2=t[i+1:]
    if S.count(t1)==1 and S.count(t2)==1:
        ind1=S.index(t1)
        ind2=S.index(t2)
        if ind1<=ind2:
            tmp=S.replace(t1,',').replace(t2,',').split(',')
            if len(tmp)<=3 and '' in tmp:
                print('YES')
                break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
L = list('keyence')
S_ = input()
S = list(S_)
K = ''
P = ''
i = 0
cnt = 0
for item in S[:]:
    if i >= len(L):
        cnt += 1
        break
    if item == L[i]:
        i += 1
        K += item
    else:
        if cnt == 0:
            cnt += 1
        P += item
if K != 'keyence' or cnt > 1:
    print('NO')
elif S_.find(P) != -1:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
t = "keyence"
y=0
if "keyence" in s:
    print("YES")
else:
    for i in range(len(s)):
        if s[i] == t[i]:
            y = 1
            print("YES")
            break
        else:
            if y != 1:
                print("NO")
                break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  1/13 21:11:56 2019

# Usage
#
"""
from collections import Counter
TARGET = "keyence"

def get_input():
    return input()

def solve(s):
    """
    >>> solve("keyence")
    YES
    >>> solve("keyofscience")
    YES
    >>> solve("ashlfyha")
    NO
    """
    pos = 0
    for i in TARGET:
        now = mog(s,i,pos)
        if now == -1:
            return "NO"
    return "YES"

def mog(original, target, pos):
    """
    >>> mog("keyence", "k", 0)
    1
    >>> mog("aaa", "k", 0)
    -1
    """
    if len(original) == pos:
        return -1

    if original[pos] == target:
        return pos + 1
    else:
        return mog(original, target, pos+1)

if __name__ == '__main__':
    # import doctest
    # doctest.testmod()

    print(solve(get_input()))

Submission status: Wrong Answer

Solution code:
a = input()
k="keyence"
ti = 0
x =[0]*(len(a)+1)
r = 0
for i in range(len(a)):
    if ti==7:
        r=4
        break
    if a[i] == k[ti]:
        ti +=1
        x[i]=1
        if i!=0 and  x[i-1]!=1:r+=1     
if ti == 7 and r < 2:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = 'keyence'
S = input()
ans = 'NO'

for i in range(len(S)):
    if S[i] == 'k':
        for l in range(1, len(s)):
            if S[i+l] != s[l]:
                break
        for n in range(len(S)-l):

            if S[i:l] + S[l+n:l+n+7-3] == s:
                ans = 'YES'
                break
    if ans == 'YES':
        break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
import re
ans=[]
ans.append(re.match(".*keyence",s))
ans.append(re.match("k.*eyence",s))
ans.append(re.match("ke.*yence",s))
ans.append(re.match("key.*ence",s))
ans.append(re.match("keye.*nce",s))
ans.append(re.match("keyen.*ce",s))
ans.append(re.match("keyenc.*e",s))
ans.append(re.match("keyence.*",s))
c = sum(x!=None for x in ans)
if c > 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

for i, _ in enumerate(S):
    index1 = s.find(S[:i])
    index2 = s.find(S[i:])
    if index1 >= 0 and index1 < index2 and (index1 == 0 or index2 - index1 == len(S[:i])):
        print('YES')
        break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
keyence = 'keyence'
for i in range(8):
    fs, es = keyence[:i], keyence[i:]
    # print(fs, es)
    fsi = s.find(fs)
    esi = s.find(es)
    # print(fsi, esi)
    if fsi + len(fs) <= esi and fsi >= 0 and esi >= 0:
        print('YES')
        exit()
print('NO')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
s = input()
key = 'keyence'
key_r = 'ecneyek'
j = 0
for i in key:
    if s[j] == i:
        j += 1
    else:
        break
k = -1
for i in key_r:
    if s[k] == i:
        k -= 1
    else:
        break

s = s[:j] + s[k + 1:]
if j >= k+1: s = key
if s == key:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
q=input()
if "k" in q and "eyence" in q:
	POL=q.replace("k","1").replace("eyence","1")
	
	for i in range(len(POL)-1):
		if 1<=[POL[i],POL[i+1]].count("1")<=2:
			print("YES")
			exit()
		else:
			print("NO")
			exit()

if "ke" in q and "yence" in q:
	POL=q.replace("ke","1").replace("yence","1")
	
	for i in range(len(POL)-1):
		if 1<=[POL[i],POL[i+1]].count("1")<=2:
			print("YES")
			exit()
		else:
			print("NO")
			exit()

if "key" in q and "ence" in q:
	POL=q.replace("key","1").replace("ence","1")
	
	for i in range(len(POL)-1):
		if 1<=[POL[i],POL[i+1]].count("1")<=2:
			print("YES")
			exit()
		else:
			print("NO")
			exit()
			
if "keye" in q and "nce" in q:
	POL=q.replace("keye","1").replace("nce","1")
	
	for i in range(len(POL)-1):
		if 1<=[POL[i],POL[i+1]].count("1")<=2:
			print("YES")
			exit()
		else:
			print("NO")
			exit()
if "keyen" in q and "ce" in q:
	POL=q.replace("keyen","1").replace("ce","1")
	
	for i in range(len(POL)-1):
		if 1<=[POL[i],POL[i+1]].count("1")<=2:
			print("YES")
			exit()
		else:
			print("NO")
			exit()
if "keyenc" in q and "e" in q:
	POL=q.replace("keyenc","1").replace("e","1")
	
	for i in range(len(POL)-1):
		if 1<=[POL[i],POL[i+1]].count("1")<=2:
			print("YES")
			exit()
		else:
			print("NO")
			exit()

Submission status: Wrong Answer

Solution code:
S=raw_input()
t="keyence"

for i in range(8):
	p1,p2=t[:i] , t[i:]

	idx1=S.find(p1)
	idx2=S.find(p2)

	if 0<=idx1 and 0<=idx2  and idx1<=idx2:
		if idx1==idx2:
			print "YES"
			quit()
		else:
			if idx2-len(p1)+7==len(S):
				print "YES"
				quit()
else:
	print "NO"

Submission status: Wrong Answer

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

keyStr=input()
keyence="keyence"

before=""
after=""
chkflg=False

for char in range(len(keyence) -1):
  before=keyence[0:char+1]
  after=keyence[char+1:len(keyence)]
  
  bindex= keyStr.find(before)
  if bindex >= 0:
    if keyStr[bindex+len(before):len(keyStr)].find(after) >= 0:
      print("YES")
      chkflg=True
      break

if chkflg == False:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

def is_keyence(S):
    keyence_str = "keyence"
    i = 0
    is_change = False
    change_num = 0
    for j in range(len(S)):
        if i >= len(keyence_str) or S[j] != keyence_str[i]:
            if is_change: change_num += 1
            else:
                if change_num > 0:
                    return False
                is_change = True
                change_num += 1
        else:
            if is_change: is_change = False
            i += 1
    if i == len(keyence_str):
        return True
    else: return False


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

Submission status: Wrong Answer

Solution code:
import sys
s = input()
time = 0
i = 0
n = 0
for i in range(7):
    if s[i+n] != "keyence"[i]:
        time += 1
        if time >= 2:
            print("NO")
            sys.exit()
        while "keyence"[i] != s[i+n]:
            n += 1
            if i+n >= len(s):
                print("NO")
                sys.exit()
if (len(s)-2 > i+n):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
org_str = input()
pattern = r".*k.*e.*y.*e.*n.*c.*e.*"

if org_str.count('e') != 3:
  print('NO')
  exit()
if len(org_str) < 7 and len(org_str) > 100:
  print('NO')
  exit()

matchOB = re.match(pattern , org_str)
if matchOB:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s=list(input())
t=list("keyence")
j=0
c=0
for i in range(len(s)):
    if s[i]==t[j]:
        j+=1
        if j==7:
            if c!=0 and s.pop():
                print("YES")
                exit()
            elif c==0:
                print("YES")
                exit()
            else:
                break
            c+=1
print("NO")

Submission status: Wrong Answer

Solution code:
key = 'keyence'
word = ''
s = input()
s_list = list(s)
flag = True
for i in key:
    if not i in s_list:
        print('NO')
        flag = False
        break
    s_list.remove(i)

for j in s_list:
    word += j
if flag:
    if s.find(word) > -1:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
import re
s = input()
k1 = 'keyence'
ans = 'NO'
for i in range(len(k1)):
    a = '^'+k1[:i]+'.*?'+k1[i+1:]+'$'
    if re.match(a,s):
        ans = 'YES'
print(ans)

Submission status: Wrong Answer

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

T = "keyence"

found = False
for start in range(len(T)):
    print(T[:start], T[start:])

    i = S.find(T[:start])
    if i == -1:
        continue
    # print(S[(i + start):])
    j = S[(i + start):].find(T[start:])
    # prijnt(i , j)
    if j > -1:
        found = True
        break

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

Submission status: Wrong Answer

Solution code:
s = input()

word = "keyence"

for i in range(len(word)):
    a = s.find(word[:i])
    b = s.rfind(word[i:])
    if(a == b or (a == 0 and b == len(s)-len(word[i:]))):
        print("YES")
        exit()

print("NO")

Submission status: Wrong Answer

Solution code:
from sets import Set

s = raw_input().lower()
r_str = 'keyence'
k_split = list()
for i in xrange(len(r_str)):
	a = list()
	a.append(r_str[0 : i])
	a.append(r_str[i : ])
	k_split.append(a)

print_sig = False

for i in xrange(len(k_split)):
	single_split = k_split[i]
	f = s.find(single_split[0])
	b = s.find(single_split[1])
	if f != -1 and b != -1 and f < b:
		print 'YES'
		print_sig = True
		break

if print_sig == False:
	print 'NO'

Submission status: Wrong Answer

Solution code:
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy
import scipy

from collections import defaultdict
from pprint import pprint

S = input()
ANS = "keyence"

i = 0
started_delete = False
deleted = False
ans = False
j = 0

for s in S:
    j += 1
    if s == ANS[i]:
        if started_delete:
            started_delete = False
        if i == len(ANS) - 1:
            if not deleted or len(S) == j:
                ans = True
            break
        i += 1;
        continue
    if started_delete:
        continue
    if not deleted:
        started_delete = True
        deleted = True
        continue

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

Submission status: Wrong Answer

Solution code:
FAIL = -1

def aho_corasick(string, keywords):
    transitions = {}
    outputs = {}
    fails = {}

    new_state = 0

    for keyword in keywords:
        state = 0

        for j, char in enumerate(keyword):
            res = transitions.get((state, char), FAIL)
            if res == FAIL:
                break
            state = res

        for char in keyword[j:]:
            new_state += 1
            transitions[(state, char)] = new_state
            state = new_state

        outputs[state] = [keyword]

    queue = []
    for (from_state, char), to_state in transitions.items():
        if from_state == 0 and to_state != 0:
            queue.append(to_state)
            fails[to_state] = 0

    while queue:
        r = queue.pop(0)
        for (from_state, char), to_state in transitions.items():
            if from_state == r:
                queue.append(to_state)
                state = fails[from_state]

                while True:
                    res = transitions.get((state, char), state and FAIL)
                    if res != FAIL:
                        break
                    state = fails[state]

                failure = transitions.get((state, char), state and FAIL)
                fails[to_state] = failure
                outputs.setdefault(to_state, []).extend(
                    outputs.get(failure, []))

    state = 0
    results = []
    for i, char in enumerate(string):
        while True:
            res = transitions.get((state, char), state and FAIL)
            if res != FAIL:
                state = res
                break
            state = fails[state]

        for match in outputs.get(state, ()):
            pos = i - len(match) + 1
            results.append((pos, match))

    return results

l = ['k', 'e', 'y', 'e', 'n', 'c','e']
str = input() 

result = aho_corasick(str, l)
if len(result)>=7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import re
ms = re.finditer("k(.*)e(.*)y(.*)e(.*)n(.*)c(.*)e",input())
compFlag = False
for i in ms:
    noCount = 0
    for j in range(6):
        if len(i.group(j+1)) > 0:
            noCount += 1
    if noCount <= 1:
        compFlag = True
        break
print("YES" if compFlag else "NO")

Submission status: Wrong Answer

Solution code:
s = 'keyence'
S = input()
ans = 'NO'

for i in range(len(S)):
    if S[i] == 'k':
        for l in range(1, len(s)):
            if S[l] != s[l]:
                break
        for n in range(len(S)-l):

            if S[i:l] + S[l+n:l+n+7-3] == s:
                ans = 'YES'
                break
    if ans == 'YES':
        break
print(ans)

Submission status: Wrong Answer

Solution code:
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return -1

a = input().split()
a = list(a[0])
judge = 0
A = []
B = []

A.append(my_index(a, 'k'))
if (my_index(a, 'k') != -1):
 a[ my_index(a, 'k') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'e'))
if (my_index(a, 'e') != -1):
 a[ my_index(a, 'e') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'y'))
if (my_index(a, 'y') != -1):
 a[ my_index(a, 'y') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'e'))
if (my_index(a, 'e') != -1):
 a[ my_index(a, 'e') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'n'))
if (my_index(a, 'n') != -1):
 a[ my_index(a, 'n') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'c'))
if (my_index(a, 'c') != -1):
 a[ my_index(a, 'c') ] = 'AAA'
 judge += 1
A.append(my_index(a, 'e'))
if (my_index(a, 'e') != -1):
 a[ my_index(a, 'e') ] = 'AAA'
 judge += 1

B = A
A.sort()
if( (A == B) and (judge==7) ):
 print('YES')
else:
 print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
import re
ans=[]
ans.append(re.match("k.*eyence",s))
ans.append(re.match("ke.*yence",s))
ans.append(re.match("key.*ence",s))
ans.append(re.match("keye.*nce",s))
ans.append(re.match("keyen.*ce",s))
ans.append(re.match("keyenc.*e",s))
c = sum(x!=None for x in ans)
if c > 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
org_str = input()
pattern = r".*k.*e.*y.*e.*n.*c.*e.*"

if org_str.count('e') != 3:
  print('NO')
  exit()
if len(org_str) < 7:
  print('NO')
  exit()

matchOB = re.match(pattern , org_str)
if matchOB:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
ans = 0
if S == "keyence":
    print("YES")
    ans = 1
else:
    for i in range(len(S)):
        for j in range(i+1,len(S)+1):
            S_ = list(S)
            del S_[i:j]
            re = "".join(S_)
            if re != "keyence":
                continue
            print("YES")
            ans = 1
            break
if ans == 0:
    print("NO")

Submission status: Wrong Answer

Solution code:
ans = ['k','e','y','e','n','c','e']
S = input()

N = len(ans)
k = 0
flag =False
mode = 0
for s in S:
    if k == N:
        if mode > 0:
            flag =False
            break
        else:
            break
    if mode == 0:
        if s == ans[k]:
            k += 1
        else:
            mode += 1
    elif mode == 1:
        if s == ans[k]:
            k += 1
            mode += 1
    elif mode ==2:
        if s == ans[k]:
            k += 1
        else:
            mode += 1
    else:
        flag == False
    if k == N:
        if mode<3:
            flag =True
    # print("mode:",mode,"k",k,"s",s)
        # print('complete')
    
if flag:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  1/13 21:11:56 2019

# Usage
#
"""
from collections import Counter
TARGET = "keyence"

def get_input():
    return input()

def solve(s):
    """
    >>> solve("keyence")
    YES
    >>> solve("keyofscience")
    YES
    >>> solve("ashlfyha")
    NO
    """
    pos = 0
    for i in TARGET:
        if mog(s, i, pos) == -1:
            return "NO"
    return "YES"

def mog(original, target, pos):
    """
    >>> mog("keyence", "k", 0)
    1
    >>> mog("aaa", "k", 0)
    -1
    """
    if len(original) == pos:
        return -1

    if original[pos] == target:
        return pos + 1
    else:
        return mog(original, target, pos+1)

if __name__ == '__main__':
    # import doctest
    # doctest.testmod()

    print(solve(get_input()))

Submission status: Wrong Answer

Solution code:
import re

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

Submission status: Wrong Answer

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

if len(S) == 7:
    if S==keyence:
        print('YES')
    else:
        print('NO')
else :
    for i in range(1,7):
      if keyence[:i] in S and keyence[i:] in S and S.index(keyence[:i]) < S.index(keyence[i:]):
          print('YES')
          break
    else:
        print('NO')