Problem:


Score : 200 points

Problem Statement

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

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

Constraints

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

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

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

Sample Input 1

keyofscience

Sample Output 1

YES

keyence is an abbreviation of key of science.

Sample Input 2

mpyszsbznf

Sample Output 2

NO

Sample Input 3

ashlfyha

Sample Output 3

NO

Sample Input 4

keyence

Sample Output 4

YES



Sample input:
keyofscience


Sample output:
YES

Submission status: Wrong Answer

Solution code:
s=input()

a="keyence"

j=0

count=0

dif_count=2

if(s[0]!=a[0]):
    dif_count=1

for i in range(len(s)):
    if(s[i]==a[j]):
        j+=1
        count+=1
        if(count==7):
            if(i+1<len(s)):
                dif_count+=1
            break
        if(s[i+1]!=a[j] and i<len(s)-1):
            dif_count+=1
            
        
        
if(count==7 and dif_count<2 ):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
ans = "No"
for i in range(len(S)) :
    head = S[:i]
    for j in range(i,len(S)) :
        tail = S[j:]
        
        string = head + tail
        if string == "keyence" :
            ans = "Yes"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
correct_count = 0
wrong_char_index_list = []

for i in range(len(s)):
    if s[i] == "keyence"[correct_count]:
        correct_count += 1
        if correct_count == len("keyence"):
            break
    else:
        wrong_char_index_list.append(i)

# 全部間違い
if len(wrong_char_index_list) == len(s):
    print("NO")
    exit()

# 間違い箇所が飛んでたらダメ
if len(wrong_char_index_list) >= 2:
    for i in range(1, len(wrong_char_index_list)):
        if wrong_char_index_list[i] - wrong_char_index_list[i-1] != 1:
            print("NO")
            exit()

print("YES")
exit()

Submission status: Wrong Answer

Solution code:
s = input()
correct_count = 0
wrong_char_index_list = []

for i in range(len(s)):
    if s[i] == "keyence"[correct_count]:
        correct_count += 1
        if correct_count == len("keyence"):
            print("YES")
            exit()
    else:
        wrong_char_index_list.append(i)

#print(wrong_char_index_list)
# 全部間違い
if len(wrong_char_index_list) == len(s):
    print("NO")
    exit()

# 間違い箇所が飛んでたらダメ
for i in range(1, len(wrong_char_index_list)):
    if wrong_char_index_list[i] - wrong_char_index_list[i-1] != 1:
        print("NO")
        exit()

Submission status: Wrong Answer

Solution code:
s = input()
correct_count = 0
wrong_char_index_list = []

for i in range(len(s)):
    if s[i] == "keyence"[correct_count]:
        correct_count += 1
        if correct_count == len("keyence"):
            break
    else:
        wrong_char_index_list.append(i)

if correct_count != 7:
	print("NO")
	exit()

#print(wrong_char_index_list)
# 全部間違い
if len(wrong_char_index_list) == len(s):
    print("NO")
    exit()

# 間違い箇所が飛んでたらダメ
for i in range(1, len(wrong_char_index_list)):
    if wrong_char_index_list[i] - wrong_char_index_list[i-1] != 1:
        print("NO")
        exit()

print("YES")
exit()

Submission status: Wrong Answer

Solution code:
import re

S = input()

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

Submission status: Wrong Answer

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

solve()

Submission status: Wrong Answer

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

solve()

Submission status: Wrong Answer

Solution code:
s=input()
target="keyence"
flag=False
if target in s:
  flag=True
else:
  for i in range(1,7):
    l=target[:i]
    r=target[i:]
    try:
      indl=s.index(l)
      s.index(r,indl)
      flag=True
      break
    except:
      pass
if flag:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

found = False
for p in patterns:   
    c = re.compile(p)
    result = c.match(s)
    if result!=None:
        found = True # 見つかった

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

Submission status: Wrong Answer

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

    
    

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

Submission status: Wrong Answer

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
if S[:f] + S[b:] == T:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = [c for c in input()]

Target = ['k','e','y','e','n','c','e']
judge = False
for j in range(7):
    left = ''.join(Target[:j])
    right = ''.join(Target[j:])
    start = 0

    if left in ''.join(S):
        if left != '':
            start = ''.join(S).index(left)

    if right in ''.join(S[start:]):
        judge=True

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

Submission status: Wrong Answer

Solution code:
S = [c for c in input()]

Target = ['k','e','y','e','n','c','e']
judge = False
for j in range(7):
    left = ''.join(Target[:j])
    right = ''.join(Target[j:])
    start = 0

    if left in ''.join(S):
        if left != '':
            start = S.index(left[-1:])

    if right in ''.join(S[start:]):
        judge=True




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

Submission status: Wrong Answer

Solution code:
S = [c for c in input()]

Target = ['k','e','y','e','n','c','e']
judge = True
start = 0

for i in Target:
    if i in S[start:]:
        start = S.index(i)
        S[start] = ' '
    else:
        judge = False



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

Submission status: Wrong Answer

Solution code:
S = input()

Target = ['k','e','y','n','c']
judge = True
for i in Target:
    if i in S:
        if i == 'e' and S.count(i) < 3:
            judge = False
            break
        else:
            pass
    else:
        judge = False

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()

if S.startswith('keyence') or S.endswith('keyence'):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
import re

str1 = input()

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

Submission status: Wrong Answer

Solution code:
import sys
import re

str1 = input()

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

Submission status: Wrong Answer

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

i_t = 0
text="keyence"
continue_ = False

l_i_occurance = []

for i_s,c in enumerate(s):
    if i_t == 7:
        continue_ = True
        break

    if c == text[i_t]:
        i_t += 1
        l_i_occurance.append(i_s)

# print("l_i_occurance: ", l_i_occurance)

if len(l_i_occurance) == len(text):
    diff = []
    for i_l in range(len(l_i_occurance)-1):
        diff.append(  l_i_occurance[i_l+1] - l_i_occurance[i_l] ) 
    # print("diff: ", diff)
    al_penalty = l_i_occurance[0] != 0

    if   len(set(diff)) == 1:
        if al_penalty and continue_:
            print("NO")
        else:
            print("YES")
    elif len(set(diff)) == 2:
        if continue_:
            print("NO")
        elif al_penalty:
            print("NO")
        else:
            print("YES")
    elif len(set(diff)) >= 3:
        print("NO")
    # if len(set(diff)) >= 3:
    #     print("NO")
    # else:
    #     print("YES")
    
else:
    print("NO")

Submission status: Wrong Answer

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

i_t = 0
text="keyence"
continue_ = False

l_i_occurance = []

for i_s,c in enumerate(s):
    if i_t == 7:
        continue_ = True
        break

    if c == text[i_t]:
        i_t += 1
        l_i_occurance.append(i_s)

print("l_i_occurance: ", l_i_occurance)

if len(l_i_occurance) == len(text):
    diff = []
    for i_l in range(len(l_i_occurance)-1):
        diff.append(  l_i_occurance[i_l+1] - l_i_occurance[i_l] ) 
    print("diff: ", diff)
    al_penalty = l_i_occurance[0] != 0

    if   len(set(diff)) == 1:
        if al_penalty and continue_:
            print("NO")
        else:
            print("YES")
    elif len(set(diff)) == 2:
        if continue_:
            print("NO")
        elif al_penalty:
            print("NO")
        else:
            print("YES")
    elif len(set(diff)) >= 3:
        print("NO")
    # if len(set(diff)) >= 3:
    #     print("NO")
    # else:
    #     print("YES")
    
else:
    print("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(0,7):
      if keyence[:i] in S and keyence[i:] in S[S.index(keyence[:i])+i:] : # keyenceがある
        if i==0 and S.index(keyence[i:])==0 : # keyenceXXX のとき
            print('YES')
            break
        elif i==0 and S.index(keyence[i:])!=0 and len(S)-7 == S.index(keyence[i:]) : # XXXkeyence のとき
            print('YES')
            break
        elif i!=0 and S.index(keyence[:i])==0 and S[S.index(keyence[:i])+i:].index(keyence[i:])+i+len(keyence[i:]) == len(S) :  # keyXXXenceのとき
            print('YES')
            break
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
keyence = 'keyence'
ans = 'NO'
for i in range(len(keyence)):
    a = keyence[:i]
    b = keyence[i:]
    if s.find(a) != -1 and s.find(b) != -1 and s.find(a)  < s.rfind(b):
        ans = 'YES'
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
keyence = 'keyence'
ans = 'NO'
for i in range(len(keyence)):
    a = keyence[:i]
    b = keyence[i:]
    if s.find(a) != -1 and s.find(b) != -1 and s.find(a) + len(a) - 1 < s.rfind(b):
        ans = 'YES'
print(ans)

Submission status: Wrong Answer

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

	remove_len = len(S)  - 7

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

	print("NO")


main()

Submission status: Wrong Answer

Solution code:
s = input()
keyence = 'keyence'
ans = 'NO'
for i in range(len(keyence)):
    a = keyence[:i]
    b = keyence[i:]
    if s.find(a) != -1 and s.find(b) != -1 and s.find(a) + len(a) - 1 < s.find(b):
        ans = 'YES'
print(ans)

Submission status: Wrong Answer

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

i = 0
text="keyence"
for c in s:
    if i == 7:
        print("YES")
        exit(0)
    else:
        if c == text[i]:
            i += 1



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

Submission status: Wrong Answer

Solution code:
S = input()
s = ''
t = ''
cnt = 0
for c in S:
    if c=='k' and s=='':
        s += c
        if t!='':
            cnt += 1
    elif c=='e' and s=='k':
        s += c
        if t!='':
            cnt += 1
    elif c=='y' and s=='ke':
        s += c
        if t!='':
            cnt += 1
    elif c=='e' and s=='key':
        s += c
        if t!='':
            cnt += 1
    elif c=='n' and s=='keye':
        s += c
        if t!='':
            cnt += 1
    elif c=='c' and s=='keyen':
        s += c
        if t!='':
            cnt += 1
    elif c=='e' and s=='keyenc':
        s += c
        if t!='':
            cnt += 1
    else:
        t += c
        if cnt!=0:
            break
print('YES' if s=='keyence' else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()
keyence = 'keyence'
ans = 'NO'
for i in range(len(keyence)):
    a = keyence[:i]
    b = keyence[i:]
    if s.find(a) != -1 and s.find(b) != -1 and s.find(a) + len(a) < s.find(b):
        ans = 'YES'
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
keyence = 'keyence'
ans = 'NO'
for i in range(len(keyence)):
    a = keyence[:i]
    b = keyence[i:]
    if s.find(a) != -1 and s.find(b) != -1 and s.find(a) <= s.find(b):
        ans = 'YES'
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
keyence = 'keyence'
ans = 'NO'
for i in range(len(keyence)):
    a = keyence[:i]
    b = keyence[i:]
    if s.find(a) != -1 and s.find(b) != -1 and s.find(a) < s.find(b):
        ans = 'YES'
print(ans)

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(0,7):
      if keyence[:i] in S and keyence[i:] in S[S.index(keyence[:i])+i:] : # keyenceがある
        if i==0 and S.index(keyence[i:])==0 : # keyenceXXX のとき
            print('YES')
            break
        elif i==0 and S.index(keyence[i:])!=0 and len(S)-7 == S.index(keyence[i:]) : # XXXkeyence のとき
            print('YES')
            break
        elif i!=0 and S.index(keyence[:i])==0 and S[S.index(keyence[i:])+(7-i):] == '' :  # keyXXXenceのとき
            print('YES')
            break
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
keyence = 'keyence'
ans = 'NO'
for i in range(len(keyence)):
    a = keyence[:i+1]
    b = keyence[i+1:]
    if s.find(a) != -1 and s.find(b) != -1 and s.find(a) < s.find(b):
        ans = 'YES'
print(ans)

Submission status: Wrong Answer

Solution code:
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")

Submission status: Wrong Answer

Solution code:
S = input()
s = ''
for c in S:
    if c=='k' and s=='':
        s += c
    elif c=='e' and s=='k':
        s += c
    elif c=='y' and s=='ke':
        s += c
    elif c=='e' and s=='key':
        s += c
    elif c=='n' and s=='keye':
        s += c
    elif c=='c' and s=='keyen':
        s += c
    elif c=='e' and s=='keyenc':
        s += c
print('YES' if s=='keyence' else 'NO')

Submission status: Wrong Answer

Solution code:
S = input()
s = ''
for c in S:
    if c=='k':
        s += c
    elif c=='e' and s=='k':
        s += c
    elif c=='y' and s=='ke':
        s += c
    elif c=='e' and s=='key':
        s += c
    elif c=='n' and s=='keye':
        s += c
    elif c=='c' and s=='keyen':
        s += c
    elif c=='e' and s=='keyenc':
        s += c
print('YES' if s=='keyence' else 'NO')

Submission status: Wrong Answer

Solution code:
S = input()
if 'keyence' in S: print("YES")
elif 'keyenc' in S and S.find('e',S.find('keyenc')+7)!=-1 :print("YES")
elif 'keyen' in S and S.find('ce',S.find('keyen')+6)!=-1 :print("YES")
elif 'keye' in S and S.find('nce',S.find('keye')+5)!=-1 :print("YES")
elif 'key' in S and S.find('ence',S.find('key')+4)!=-1 :print("YES")
elif 'ke' in S and S.find('yence',S.find('ke')+3)!=-1 :print("YES")
elif 'k' in S and S.find('eyence',S.find('k')+2)!=-1 :print("YES")
else : print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
if 'keyence' in S: print("YES")
#elif 'keyenc' in S and S.find('e',S.find('keyenc')+7)!=-1 :print("YES")
elif 'keyen' in S and S.find('ce',S.find('keyen')+6)!=-1 :print("YES")
elif 'keye' in S and S.find('nce',S.find('keye')+5)!=-1 :print("YES")
elif 'key' in S and S.find('ence',S.find('key')+4)!=-1 :print("YES")
elif 'ke' in S and S.find('yence',S.find('ke')+3)!=-1 :print("YES")
elif 'k' in S and S.find('eyence',S.find('k')+2)!=-1 :print("YES")
else : print("NO")

Submission status: Wrong Answer

Solution code:
S=input()

K='keyence'
n=0

for i in range(len(S)):
    if n < len(K):
        if S[i]==K[n]:
            n+=1

if n==len(K):
    print('YES')
else:
    print('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(0,7):
      if keyence[:i] in S and keyence[i:] in S[S.index(keyence[:i])+i:] : # keyenceがある
        if i==0 and S.index(keyence[i:])==0 : # keyenceXXX のとき
            print('YES')
            break
        elif i==0 and S.index(keyence[i:])!=0 and len(S)-7 == S.index(keyence[i:]) : # XXXkeyence のとき
            print('YES')
            break
        elif S.index(keyence[:i])==0 and S[S.index(keyence[i:])+(7-i):] == '' :  # keyXXXenceのとき
            print('YES')
            break
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
ans='keyence'
i=0 # index of s
index=0 # index of ans
isCut=0
canRestart=0
restart=0
lenS=len(s)
while i<lenS:
    # print(i,index,end=' ')
    if isCut==1: # 切られたあと
        if index>6: # 7=len(ans)
            if canRestart:
                canRestart=0
                isCut=-1
                i=restartI
                index=restartIndex-1
            else:
                break
        if s[i]==ans[index]:
            index+=1
        else:
            if canRestart:
                canRestart=0
                isCut=-1
                i=restartI
                index=restartIndex-1
            else:
                break
    elif isCut==-1: # 切られている途中
        if s[i]==ans[index]:
            # 切り方を変えるときはiとindexを戻す
            restartIndex=index
            restartI=i
            canRestart=1
            isCut=1
            index+=1
    else: # 切られる前
        if s[i]==ans[index]:
            index+=1
        else:
            isCut=-1
    i+=1
    # print(isCut)
if index<=6|i<lenS|isCut==-1: # 7=len(ans)
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
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.find(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')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
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.find(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 res:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
if 'keyence' in S: print("YES")
elif 'keyenc' in S and S.find('e',S.find('keyenc')+6)!=-1 :print("YES")
elif 'keyen' in S and S.find('ce',S.find('keyen')+5)!=-1 :print("YES")
elif 'keye' in S and S.find('nce',S.find('keye')+4)!=-1 :print("YES")
elif 'key' in S and S.find('ence',S.find('key')+3)!=-1 :print("YES")
elif 'ke' in S and S.find('yence',S.find('ke')+2)!=-1 :print("YES")
elif 'k' in S and S.find('eyence',S.find('k')+1)!=-1 :print("YES")
else : print("NO")

Submission status: Wrong Answer

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

for i in range(7):
    target1_ind = -1
    target1 = target[:i]
    target2 = target[i:]
    if target2 == target:
        if target in s:
            if s.index(target) == 0 or s.index(target)+len(target) == s_len:
                flg = 1
    else:
        if target1 in s and target2 in s:
            if s.index(target1) == 0 and s.index(target2)+len(target2) == s_len:
                flg = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

s=input()
a=0
b=0
c=0
d=0
e=0
f=0
g=0
while s[a]!="k":
    a+=1
    if a==len(s):
        print("NO")
        sys.exit()
b=a+1
while s[b]!="e":
    b+=1
    if b==len(s):
        print("NO")
        sys.exit()
c=b+1
while s[c]!="y":
    c+=1
    if c==len(s):
        print("NO")
        sys.exit()
d=c+1
while s[d]!="e":
    d+=1
    if d==len(s):
        print("NO")
        sys.exit()
e=d+1
while s[e]!="n":
    e+=1
    if e==len(s):
        print("NO")
        sys.exit()
f=e+1
while s[f]!="c":
    f+=1
    if f==len(s):
        print("NO")
        sys.exit()
g=f+1
while s[g]!="e":
    g+=1
    if not "e" in s[g]:
        print("NO")
        sys.exit()
if s=="keyence":print("YES")
else:
    if a!=0 and (b==a+1 and c==b+1 and d==c+1 and e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b!=1 and(c==b+1 and d==c+1 and e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c!=2 and(d==c+1 and e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d!=3 and (e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e!=4 and (f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e==4 and f!=5 and g==f+1:
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e==4 and f==5 and g!=6:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
input_str = input()
pattern_1 = r".*?keyence$"
pattern_2 = r"^k.*?yence$"
pattern_3 = r"^ke.*?yence$"
pattern_4 = r"^key.*?ence$"
pattern_5 = r"^keye.*?nce$"
pattern_6 = r"^keyen.*?ce$"
pattern_6 = r"^keyenc.*?e$"
pattern_7 = r"^keyence.*?"
pattern_8 = r"^keyence$"
match_obj1 = re.match(pattern_1, input_str)
match_obj2 = re.match(pattern_2, input_str)
match_obj3 = re.match(pattern_3, input_str)
match_obj4 = re.match(pattern_4, input_str)
match_obj5 = re.match(pattern_5, input_str)
match_obj6 = re.match(pattern_6, input_str)
match_obj7 = re.match(pattern_7, input_str)
match_obj8 = re.match(pattern_8, input_str)
if match_obj1 or match_obj2 or match_obj3 or match_obj4 or match_obj5 or match_obj6 or match_obj7 or match_obj8:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import re
input_str = input()
pattern_1 = r".+?keyence$"
pattern_2 = r"^k.+?yence$"
pattern_3 = r"^ke.+?yence$"
pattern_4 = r"^key.+?ence$"
pattern_5 = r"^keye.+?nce$"
pattern_6 = r"^keyen.+?ce$"
pattern_6 = r"^keyenc.+?e$"
pattern_7 = r"^keyence.+?"
pattern_8 = r"^keyence$"
match_obj1 = re.match(pattern_1, input_str)
match_obj2 = re.match(pattern_2, input_str)
match_obj3 = re.match(pattern_3, input_str)
match_obj4 = re.match(pattern_4, input_str)
match_obj5 = re.match(pattern_5, input_str)
match_obj6 = re.match(pattern_6, input_str)
match_obj7 = re.match(pattern_7, input_str)
match_obj8 = re.match(pattern_8, input_str)
if match_obj1 or match_obj2 or match_obj3 or match_obj4 or match_obj5 or match_obj6 or match_obj7 or match_obj8:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S1 = "keyence"
S2 = input()
s1 = ""
s2 = ""

for i in range(0, 7):
    for j in range(0, i):
        s1 = s1 + S1[j]
        for k in range(i, 7):
            s2 = s2 + S1[k]

if 'S2'.find('s1') and 'S2'.find('s2') > -1:
        print('YES')
else:
        print('NO')

Submission status: Wrong Answer

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

def solveProblem(inputStr):
	pattern1 = r"[a-z]*keyence"
	pattern2 = r"k[a-z]*eyence"
	pattern3 = r"ke[a-z]*yence"
	pattern4 = r"key[a-z]*ence"
	pattern5 = r"keye[a-z]*nce"
	pattern6 = r"keyen[a-z]*ce"
	pattern7 = r"keyenc[a-z]*e"
	pattern8 = r"keyence[a-z]*"
	matchOB1 = re.search(pattern1,inputStr)
	matchOB2 = re.search(pattern2,inputStr)
	matchOB3 = re.search(pattern3,inputStr)
	matchOB4 = re.search(pattern4,inputStr)
	matchOB5 = re.search(pattern5,inputStr)
	matchOB6 = re.search(pattern6,inputStr)
	matchOB7 = re.search(pattern7,inputStr)
	matchOB8 = re.search(pattern8,inputStr)
	if matchOB1 != None:
		return "YES"
	if matchOB2 != None:
		return "YES"
	if matchOB3 != None:
		return "YES"
	if matchOB4 != None:
		return "YES"
	if matchOB5 != None:
		return "YES"
	if matchOB6 != None:
		return "YES"
	if matchOB7 != None:
		return "YES"
	if matchOB8 != None:
		return "YES"
	return "NO"


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

Submission status: Wrong Answer

Solution code:
string = input()
#print(string[1])
if 'k' in string and 'eyence' in string:
  if string.index('k')<string.rfind('eyence'):
  	print("YES")
  else:
  	print("NO")

elif 'ke' in string and 'yence' in string:
  if string.index('ke')<string.rfind('yence'):
  	print("YES")
  else:
  	print("NO")

elif 'key' in string and 'ence' in string:
  if string.index('key')<string.rfind('ence'):
  	print("YES")
  else:
  	print("NO")

elif 'keye' in string and 'nce' in string:
  if string.index('keye')<string.rfind('nce'):
  	print("YES")
  else:
  	print("NO")

elif  'keyen' in string and 'ce' in string:
  if string.index('keyen')<string.rfind('ce'):
  	print("YES")
  else:
  	print("NO")

elif  'keyenc' in string and 'e' in string:
  if string.index('keyenc')<string.rfind('e')-3:
  	print("YES")
  else:
  	print("NO")
elif 'keyence' in string:
  	print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
ans = "keyence"
i = 0
cout = False

for i in range(1, len(ans)):
    if s.find(ans[:i]) + 1:
        if s.find(ans[i:]) + 1:
            if (len(ans) - i) + s.find(ans[i:]) == len(s):
                cout = cout or True
            else:
                cout = cout or False

if cout == True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
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")

Submission status: Wrong Answer

Solution code:
import sys

s=input()
a=0
b=0
c=0
d=0
e=0
f=0
g=0
while s[a]!="k":
    a+=1
    if a==len(s):
        print("NO")
        sys.exit()
b=a+1
while s[b]!="e":
    b+=1
    if b==len(s):
        print("NO")
        sys.exit()
c=b+1
while s[c]!="y":
    c+=1
    if c==len(s):
        print("NO")
        sys.exit()
d=c+1
while s[d]!="e":
    d+=1
    if d==len(s):
        print("NO")
        sys.exit()
e=d+1
while s[e]!="n":
    e+=1
    if e==len(s):
        print("NO")
        sys.exit()
f=e+1
while s[f]!="c":
    f+=1
    if f==len(s):
        print("NO")
        sys.exit()
g=f+1
while s[g]!="e":
    g+=1
    if not "e" in s[g]:
        print("NO")
        sys.exit()
if s=="keyence":print("YES")
else:
    if b+g==c+f==d+e:
        print("YES")
    elif a==0 and b!=1 and(c==b+1 and d==c+1 and e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c!=2 and(d==c+1 and e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d!=3 and (e==d+1 and f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e!=4 and (f==e+1 and g==f+1):
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e==4 and f!=5 and g==f+1:
        print("YES")
    elif a==0 and b==1 and c==2 and d==3 and e==4 and f==5 and g!=6:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:

input_str = input()

str_list = list(input_str)

keyence = list("keyence")

# 各文字が入ってるインデックスを記録する辞書型
str_index_dict = {}
for char in keyence:
    str_index_dict.setdefault(char, [])

for i, char in enumerate(str_list):
    if char in keyence:
        str_index_dict[char].append(i)

can_skip = True  # 文字を飛ばせるのは一回まで
keyence_iter = iter(keyence)

succes = True

position = 0
for char in keyence:
    if str_index_dict[char] == []:
        succes = False
        break
    if position in str_index_dict[char]:
        str_index_dict[char].remove(position)
        position += 1
    else:
        if can_skip == True:
            tmp_list = str_index_dict[char]
            tmp_list.append(position)
            position = min(str_index_dict[char])
            position = min([i for i in tmp_list if i>position ])
            str_index_dict[char].remove(position)
            position+=1
            can_skip = False
        else:
            succes = False
            break

if succes == True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S1 = "keyence"
S2 = input()
s1 = ""
s2 = ""

for i in range(0, 7):
    for j in range(0, i):
        s1 = s1 + S1[j]
        for k in range(i, 7):
            s2 = s2 + S1[k]

if 'S2'.find('s1') and 'S'.find('s2') > -1:
        print('YES')
else:
        print('NO')

Submission status: Wrong Answer

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