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:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    s = input()
    KEYENCE = 'keyence'
    index = 0
    err = 0
    isCount = True
    for i, v in enumerate(list(s)):
        print(v, index, err)
        if v == KEYENCE[index]:
            index += 1
            isCount = True
            if index == 7:
                if err == 0:
                    print('YES')
                elif err == 1 and (i == len(s) - 1):
                    print('YES')
                else:
                    print('NO')
                exit()
        elif isCount:
            err += 1
            isCount = False
            if err > 1:
                print('NO')
                exit()
    print('NO')
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    s = input()
    KEYENCE = 'keyence'
    index = 0
    err = 0
    isCount = False
    for i, v in enumerate(list(s)):
        if v == KEYENCE[index]:
            index += 1
            isCount = True
            if index == 7:
                if err == 0:
                    print('YES')
                elif err == 1 and (i == len(s) - 1):
                    print('YES')
                else:
                    print('NO')
                exit()
        elif isCount:
            err += 1
            isCount = False
            if err > 1:
                print('NO')
                exit()
    print('NO')
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    s = input()
    KEYENCE = 'keyence'
    index = 0
    err = 0
    isCount = False
    for i, v in enumerate(list(s)):
        if v == KEYENCE[index]:
            index += 1
            isCount = True
            if index == 7:
                if err == 0:
                    print('YES')
                elif err == 1 and (i == len(s) - 1):
                    print('YES')
                else:
                    print('NO')
                exit()
        elif isCount:
            err += 1
            isCount = False
            if err > 2:
                print('NO')
                exit()
    print('NO')
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    good = 'keyence'

    for start in range(len(s)):
        for end in range(len(s)):
            if s.replace(s[start:end],'') == good:
                print('YES')
                exit()

    print('NO')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
key = "keyence"
len_key = len(key)

S = input().rstrip("\n")

idx = 0
for i in S:
    if key[idx] == i:
        idx += 1
    if idx == len_key:
        break

if idx == len_key:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
key = tuple("keyence")

S = input().rstrip("\n")

idx = 0
for i in S:
    if i == key[idx]:
        idx += 1
    if idx == len(key):
        print("YES")
        exit()

print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

for i in range(len(S)+1):
    for j in range(len(S)+1):
        for k in range(len(S)+1):
            for l in range(len(S)+1):
                #print(S[i:j] + S[k:l])
                if S[i:j] + S[k:l] == "keyence":
                    print("YES")
                    exit()
                    
print("NO")

Submission status: Wrong Answer

Solution code:
S=input()
sk="keyence"
N=len(S)
Nsk=len(sk)

k=0
ans="N0"
if N>=Nsk:
    for i in range(Nsk):
        temp=S[0:i]+S[N-Nsk+i:]
        if temp==sk:
            ans="YES"
    
print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
sk="keyence"
N=len(S)
Nsk=len(sk)

k=0
ans="N0"
for i in range(N):
    lca=0
    for j in range(min(Nsk,N-i)):
        if S[i+j]==sk[j]:
            lca+=1
    if lca==Nsk:
        ans="YES"
    if lca>=1:
        for j in range(i+lca,N):
            if S[j:j+Nsk-lca]==sk[lca:]:
                ans="YES"
                break
            
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
word='keyence'
flag=0
if s[:6]==word:
    flag=1
if s[-7:]==word:
    flag=1
for i in range(7):
    if s[:i]+s[-(6-i):]==word:
        flag=1
print('YES' if flag else 'NO')

Submission status: Wrong Answer

Solution code:
s=input()
word='keyence'
flag=0
for i in range(7):
    if s[:i]+s[:-1-(8-i)]==word:
        flag=1
print('YES' if flag else 'NO')

Submission status: Wrong Answer

Solution code:
import re
s=input()
p1='.*?keyence'
p2='k.*?eyence'
p3='ke.*?yence'
p4='key.*?ence'
p5='keye.*?nce'
p6='keyen.*?ce'
p7='keyenc.*?e'
p8='keyence.*?'
p9='keyence'
patterns=[p1,p2,p3,p4,p5,p6,p7,p8,p9]
ans=False
for pat in patterns:
  ans=bool(ans or re.match(pat,s))
print('YES' if ans else 'NO')

Submission status: Wrong Answer

Solution code:
l = list(input())
ans = list("keyence")
count = 0
check = 0
check2 = 0
check3 = 0

for j in range(7):
  if l[len(l)-7+j] == ans[j]:
    check3 += 1
  if check3==7:
    print("YES")
    exit()
if l[0] != "k":
  print("NO")
  exit()
for i in range(len(l)):
  if l[i] == ans[count]:
    check2 = 0
    count += 1
  else:
    if check2 == 1:
      continue
    else:
      check += 1
      check2 = 1
  if count == 7:
    if 1 >= check and i == len(l)-1:
      print("YES")
      exit()
    elif check == 0:
      print("YES")
      exit()
    else:
      print("NO")
      exit()

print("NO")

Submission status: Wrong Answer

Solution code:
l = list(input())
ans = list("keyence")
count = 0
check = 0
check2 = 0
check3 = 0
for i in range(len(l)-6):
  check3 = 0
  for j in range(7):
    
    if l[i+j]==ans[j]:
      check3 += 1
      
  if check3==7:
    print("YES")
    exit()
for i in range(len(l)):
  if l[i] == ans[count]:
    check2 = 0
    count += 1
  else:
    if check2 == 1:
      continue
    else:
      check += 1
      check2 = 1
  if count == 7:
    if 1 >= check:
      print("YES")
      exit()
    else:
      print("NO")
      exit()
\
print("NO")

Submission status: Wrong Answer

Solution code:
l = list(input())
ans = list("keyence")
count = 0
check = 0
check2 = 0
for i in range(len(l)):
  if l[i] == ans[count]:
    check2 = 0
    count += 1
  else:
    if check2 == 1:
      continue
    else:
      check += 1
      check2 = 1
  if count == 7:
    if 1 >= check:
      print("YES")
      exit()
    else:
      print("NO")
      exit()

print("NO")

Submission status: Wrong Answer

Solution code:
l = list(input())
ans = list("keyence")
count = 0
check = 0
check2 = 0
for i in range(len(l)):
  if l[i] == ans[count]:
    check2 = 0
    count += 1
  else:
    if check2 == 1:
      continue
    else:
      check += 1
      check2 = 1
  if count == 7:
    print("YES")
    exit()

print("NO")

Submission status: Wrong Answer

Solution code:
S=list(input())
A=list("keyence")
 
import sys
flag = False
flag2 = False
while True:
  s = S.pop(0)
  if s == A[0]:
    A.pop(0)
    if flag:
      flag2 = True
  else:
    flag = True
    if flag2:
      print("NO")
      sys.exit()
      
  if len(A) == 0:
    print("YES")
    sys.exit()
  if len(S) == 0:
    print("NO")
    sys.exit()

Submission status: Wrong Answer

Solution code:
print("YES")

Submission status: Wrong Answer

Solution code:
S=list(input())
A=list("keyence")
 
import sys
while True:
  s = S.pop(0)
  if s == A[0]:
    A.pop(0)
  else:
    pass
  if len(A) == 0:
    print("YES")
    sys.exit()
  if len(S) == 0:
    print("NO")
    sys.exit()

Submission status: Wrong Answer

Solution code:
from sys import stdin

s = stdin.readline().rstrip()
key = "keyence"

for i in range(len(s)):
    for j in range(len(s)-i):
        if s[:i]+s[j:] == key:
            print("YES")
            exit()

print("NO")

Submission status: Wrong Answer

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

ans=False
for i in range(len(t)):
    a=t[:i]
    b=t[i:]
    if s.find(a)==0 and s.find(b)!=-1:
        if s[s.find(b)+len(b):]=="" or i==0:
            ans = True
            break
if ans is True:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

ans=False
for i in range(len(t)):
    a=t[:i]
    b=t[i:]
    if s.find(a)==0 and s.find(b)!=-1:
        if s[s.find(b)+len(b):]=="" or (i==0 and s.find(b)==0):
            ans = True
            break

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

Submission status: Wrong Answer

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

ans=False
for i in range(len(t)):
    a=t[:i]
    b=t[i:]
    if s.find(a)==0 and s.find(b)!=-1:
        if s[s.find(b)+len(b):]=="" or (i==0 and s[0]=="k"):
            ans = True
            break

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

Submission status: Wrong Answer

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

ans=False
for i in range(len(t)):
    a=t[:i]
    b=t[i:]
    if s.find(a)==0 and s.find(b)!=-1:
        if s[s.find(b)+len(b):]=="":
            ans = True
            break

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

Submission status: Wrong Answer

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

ans=False
for i in range(len(t)):
    a=t[:i]
    b=t[i:]
    if s.find(a)==0 and s.find(b)!=-1:
        ans = True
        break

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

Submission status: Wrong Answer

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

ans=False
for i in range(len(t)):
    a=t[:i]
    b=t[i:]
    if s.find(a)!=-1 and s.find(b)!=-1:
        if s.find(a)<s.find(b):
            ans = True
            break

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

Submission status: Wrong Answer

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

ans=False
for i in range(len(t)):
    a=t[:i]
    b=t[i:]
    if i==0:
        if s.find(b)!=-1:
            ans = True
            break
    else:
        if s.find(a)!=-1 and s.find(b)!=-1:
            ans = True
            break

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

Submission status: Wrong Answer

Solution code:
s=input()
t="keyence"
ans=True

for i in range(len(t)):
    if s.find(t[i])!=-1:
        s=s[s.find(t[i])+1:]
    else:
        ans = False
        break

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

Submission status: Wrong Answer

Solution code:
s=list(input())
n=len(s)
flag=False
if ''.join(s)=='keyence':
    print('YES')
    flag=True
else:
    for i in range(n-1):
        for j in range(i+1,n):
            t=s.copy()
            del t[i:j+1]
            if ''.join(t)=='keyence':
                print('YES')
                flag=True
                break

if not flag:
    print('NO')

Submission status: Wrong Answer

Solution code:
S = input()

KEYENCE = 'keyence'

if S[0:7] == KEYENCE:
  print('YES')
elif S[0] == 'k':
  counter = 1
  for i in range(6):
    if S[i+1]==KEYENCE[i+1]:
      counter +=1
  if S[-(7-counter):] ==KEYENCE[counter:]:
    print('YES')
    exit()
  else:
    print('NO',counter)
    exit()
elif S[-7:] == KEYENCE:
  print('YES')
  exit()
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
S = [i for i in list(input())]
k = ['k', 'e', 'y', 'e', 'n', 'c', 'e'] + ['_']*100
N = len(S)
m = 0;c=0
flag=False
for i in S:
    if i == k[m]:
        m+=1
        if flag:
            flag = False
    else:
        if not flag: c+=1
        flag=True
# print(i, m, c)
if c<=1 and m==7: print('YES')
else: print('NO')

Submission status: Wrong Answer

Solution code:
S = [i for i in list(input())]
k = ['k', 'e', 'y', 'e', 'n', 'c', 'e'] + ['_']*100
N = len(S)
m = 0;c=0
flag=False
for i in S:
    if i == k[m]:
        m+=1
        if flag:
            flag = False
    else:
        if not flag: c+=1
        flag=True

if c<=1 and m==6: print('YES')
else: print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
key = 'keyence'
if 'k' not in s:
    print('NO')
else:
    k = s.index('k')
    count = 0
    st = 1
    if k != 0:
        count += 1
    if k >= len(s)-2:
        print('NO')
    else:
        flag = True
        for i in range(k+1,len(s)):
            if s[i] == key[st]:
                flag = True
                st += 1
                if st == 7:
                    if i != len(s)-1:
                        count += 1
                    break
                continue
            else:
                if flag:
                    count += 1
                    flag = False
        if count <= 1 and st == 7:
            print('YES')
        else:
            print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
key = 'keyence'
if 'k' not in s:
    print('NO')
else:
    k = s.index('k')
    count = 0
    st = 1
    if k != 0:
        count += 1
    if k >= len(s)-2:
        print('NO')
    else:
        flag = True
        for i in range(k+1,len(s)):
            if s[i] == key[st]:
                flag = True
                st += 1
                if st == 7:
                    if i != len(s)-1:
                        count += 1
                    break
                continue
            else:
                if flag:
                    count += 1
                    flag = False
        if count <= 1:
            print('YES')
        else:
            print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
key = 'keyence'
if 'k' not in s:
    print('NO')
else:
    k = s.index('k')
    count = 0
    st = 1
    if k != 0:
        count += 1
    if k >= len(s)-2:
        print('NO')
    else:
        flag = True
        for i in range(k+1,len(s)):
            if s[i] == key[st]:
                flag = True
                st += 1
                if st == 7:
                    break
                continue
            else:
                if flag:
                    count += 1
                    flag = False
        if count <= 1:
            print('YES')
        else:
            print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
if (S[0:7] == 'keyence') or (S[-7:] == 'keyence'):
  print("YES")
else:
  flag = 0
  for i in range(7):
    if S[:i] + S[-(7-i):] == 'keyence':
      print("YES")
      flag=1
  if flag==0:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
if (S[0:3] == 'key' and S[-4:] == 'ence') or (S[0:7] == 'keyence') or (S[-7:] == 'keyence'):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
if S[0:3] == 'key' and S[-4:] == 'ence':
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
a=str()
b=str()
k='keyence'
l='ecneyek'
for i in range(n):
  if a+s[i] in k:
    a+=s[i]
  else:
    break
for i in range(n):
  if b+s[n-i-1] in l:
    b+=s[n-i-1]
  else:
    break
if a+b[::-1]==k or a==k or b[::-1]==k:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
a=str()
b=str()
k='keyence'
l='ecneyek'
for i in range(n):
  if a+s[i] in k:
    a+=s[i]
  else:
    break
for i in range(n):
  if b+s[n-i-1] in l:
    b+=s[n-i-1]
  else:
    break
if a+b[::-1]==k or a==k or b[::-1]==l:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
if 'k' in s and 'eyence' in s[s.find('k') + 1:]:
    print('YES')
    exit()
elif 'ke' in s and 'yence' in s[s.find('ke') + 1:]:
    print('YES')
    exit()
elif 'key' in s and 'ence' in s[s.find('key') + 1:]:
    print('YES')
    exit()
elif 'keye' in s and 'nce' in s[s.find('keye') + 1:]:
    print('YES')
    exit()
elif 'keyen' in s and 'ce' in s[s.find('keyen') + 1:]:
    print('YES')
    exit()
elif 'keyenc' in s and 'e' in s[s.find('keyenc') + 1:]:
    print('YES')
    exit()
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
x = 'keyence'
cnt = 0
for i in s:
    if x[cnt] == i:
        cnt += 1
        if cnt == 6:
            print('YES')
            break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
li = list(input())
res = []
for x in li:
    if x == "k" or x == "e" or x == "y" or x == "n"or x == "c":
        res.append(x)
if "".join(sorted(set(res))) == "cekny":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

ans = 'NO'
for i in range(7):
    l = x[:i]
    r = x[i:]
    idxl = S.find(l)
    if idxl != -1:
        idxr = S.find(r,idxl)
        if idxr != -1:
            ans = 'YES'
            break
print(ans)

Submission status: Wrong Answer

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

ans = 'NO'
for i in range(7):
    l = x[:i]
    r = x[i:]
    idxl = S.find(l)
    if idxl != -1:
        idxr = S.find(r,idxl+len(l))
        if idxr != -1:
            ans = 'YES'
            break
print(ans)

Submission status: Wrong Answer

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

count = 0
count2 = 0
flag = True

for i in s:
    if count < len(t):
        if i == t[count]:
            count += 1
            flag = True
        else:
            if flag:
                count2 += 1
                flag = False
            else:
                pass
    else:
        count2 += 1
        break
        
if count2 <= 1 and count == len(t):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
if s.count('k')!=0 and s.count('eyence'):
    print('YES')

elif s.count('ke')!=0 and s.count('yence'):
    print('YES')
elif s.count('key')!=0 and s.count('ence'):
    print('YES')
elif s.count('keye')!=0 and s.count('nce'):
    print('YES')
elif s.count('keyen')!=0 and s.count('ce'):
    print('YES')
elif s.count('keyenc')!=0 and s.count('e'):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
if s.count('k')!=0 and s.count('eyence') and s.index('k')<s.index('eyence'):
    print('YES')

elif s.count('ke')!=0 and s.count('yence') and s.index('ke')<s.index('yence'):
    print('YES')
elif s.count('key')!=0 and s.count('ence') and s.index('key')<s.index('ence'):
    print('YES')
elif s.count('keye')!=0 and s.count('nce') and s.index('keye')<s.index('nce'):
    print('YES')
elif s.count('keyen')!=0 and s.count('ce') and s.index('keyen')<s.index('ce'):
    print('YES')
elif s.count('keyenc')!=0 and s.count('e') and s.index('keyenc')<s.index('e'):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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


t = 0
s = 0
cnt = 3
state = 1
while t < len(T) and s < len(S) and cnt:
    if T[t] == S[s]:
        t += 1
        s += 1
        if not state:
            state ^= 1
            cnt -= 1
    else:
        s += 1
        if state:
            state ^= 1
            cnt -= 1

if t == len(T) and cnt:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
si = 0
cnt = 0
for s in 'keyence':
  idx = S[si:].find(s)
  if idx == -1:
    print('NO')
    exit()
  else:
    if idx != 0:
      cnt += 1
    if cnt >= 2:
      print('NO')
      exit()
    si = idx+1+si
print('YES')

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
si = 0
for s in 'keyence':
  idx = S[si:].find(s)
  if idx == -1:
    print('NO')
    exit()
  else:
    si = idx+1+si
print('YES')

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
si = 0
for s in 'keyence':
  idx = S[si:].find(s)
  if idx == -1:
    print('NO')
    exit()
  else:
    si = idx+1
print('YES')

Submission status: Wrong Answer

Solution code:
s = input()

keyence = 'keyence'
k = 0
for i in keyence:
    count = 0
    for j in range(k, len(s)):
        if i == s[j]:
            k = j+1
            count += 1
            break
    if count <= 0:
        print('NO')
        exit()

print('YES')

Submission status: Wrong Answer

Solution code:
S = list(input())
key = 'keyence'
ans = 'NO'
if len(S) == 7:
    if ''.join(S) == key:
        print('YES')
        exit()
    else:
        print('NO')
        exit()
for i in range(len(S) - 7):
    tmp = S[0: i] + S[i + len(S) - 7:]
    if key == ''.join(tmp):
        ans = 'YES'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
key = 'keyence'
ans = 'NO'
for i in range(len(S) - 6):
    tmp = S[0: i] + S[i + len(S) - 7:]
    if key == ''.join(tmp):
        ans = 'YES'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

S = input()
key = 'keyence'
char1 = []
char2 = ''
ans = ''

for i in range(len(S)):
    for j in range(i, len(S) + 1):
        char1 = S[i:j]
        char2 = S.replace(char1,"")
        if key == char2:
            print("YES")
            exit()
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

S = input()
key = 'keyence'
char1 = []
char2 = ''
ans = ''

for i in range(len(S)):
    for j in range(i + 1, len(S) + 1):
        char1 = S[i:j]
        char2 = S.replace(char1,"")
        if key == char2:
            print("YES")
            exit()
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# coding: utf-8

S = input()
key = 'keyence'
ctr = 0
ans = ''

for i in range(len(S)):
    if S[i] == key[ctr]:
       ans += S[i]
       ctr += 1
    if ctr == len(key):
        break
    
if ans == key:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
t="keyence"
n = len(s)
m = len(t)
dp = [[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
if dp[n][m]!=7:
    print("NO")
    exit()
for i in range(1,7):
    z=[t[:i],t[i:]]
    #print(z)
    for j in range(n):
        y=[s[:j],s[j:]]
        #print(y)
        if z[0] in y[0] and z[1] in y[1]:
            print("YES")
            exit()
if t in s:
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
t="keyence"
n = len(s)
m = len(t)
dp = [[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
if dp[n][m]!=7:
    print("NO")
    exit()
for i in range(1,7):
    z=[t[:i],t[i:]]
    #print(z)
    for j in range(n):
        y=[s[:j],s[j:]]
        print(y)
        if z[0] in y[0] and z[1] in y[1]:
            print("YES")
            exit()
if t in s:
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
t="keyence"
n = len(s)
m = len(t)
dp = [[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
if dp[n][m]!=7:
    print("NO")
    exit()
for i in range(1,7):
    z=[t[:i],t[i:]]
    #print(z)
    for j in range(n):
        if z[0] in s[:j] and z[1] in s[j:]:
            print("YES")
            exit()
if t in s:
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
t="keyence"
n = len(s)
m = len(t)
dp = [[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
if dp[n][m]!=7:
    print("NO")
    exit()
for i in range(1,7):
    z=[t[:i],t[i:]]
    #print(z)
    for j in range(n):
        if z[0] in s[:j] and z[1] in s[j:]:
            #print("YES")
            exit()
if t in s:
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
t="keyence"
n = len(s)
m = len(t)
dp = [[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
if dp[n][m]!=7:
    print("NO")
    exit()
for i in range(1,7):
    z=[t[:i],t[i:]]
    print(z)
    for j in range(n):
        if z[0] in s[:j] and z[1] in s[j:]:
            print("YES")
            exit()
if t in s:
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
a="keyence"
# if a in s:
#     print("YES")
#     exit()
for i in range(len(a)):
    if a[:i] in s:
        b=s.index(a[:i])
        if b!=0:
            if i==len(a)-1:
                pass
            else:
                continue
        if a[i:] in s[b:]:
            c=s.index(a[i:])
            #print(s.index(a[i:]),s[s.index(a[i:]):],a[i:])
            if s[c:]==a[i:]:
                print("YES")
                exit()
            else:
                while True:
                    try:
                        d=s[c+1:].index(a[i:])
                        #print(s[c+1:],a[i:],d)
                        if d==0:
                            if s[c+1:]==a[i:]:
                                print("YES")
                                exit()
                            break
                        c+=d
                        #print(c,s[c:],a[i:])
                        if s[c:]==a[i:]:
                            print("YES")
                            exit()
                    except:
                        break
                    
                
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
a="keyence"
# if a in s:
#     print("YES")
#     exit()
for i in range(len(a)):
    if a[:i] in s:
        b=s.index(a[:i])
        if a[i:] in s[b:]:
            c=s.index(a[i:])
            #print(s.index(a[i:]),s[s.index(a[i:]):],a[i:])
            if s[c:]==a[i:]:
                print("YES")
                exit()
            else:
                while True:
                    try:
                        d=s[c+1:].index(a[i:])
                        #print(s[c+1:],a[i:],d)
                        if d==0:
                            if s[c+1:]==a[i:]:
                                print("YES")
                                exit()
                            break
                        c+=d
                        #print(c,s[c:],a[i:])
                        if s[c:]==a[i:]:
                            print("YES")
                            exit()
                    except:
                        break
                    
                
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
a="keyence"
if a in s:
    print("YES")
    exit()
for i in range(len(a)):
    if a[:i] in s:
        b=s.index(a[:i])
        if a[i:] in s[b:]:
            c=s.index(a[i:])
            #print(s.index(a[i:]),s[s.index(a[i:]):],a[i:])
            if s[c:]==a[i:]:
                print("YES")
                exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
a="keyence"
for i in range(len(a)):
    if a[:i] in s:
        b=s.index(a[:i])
        if a[i:] in s[b:]:
            c=s.index(a[i:])
            #print(s.index(a[i:]),s[s.index(a[i:]):],a[i:])
            if s[c:]==a[i:]:
                print("YES")
                exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
a="keyence"
cnt=0
my=False
my2=False
for b in s:
    if cnt==7:
        if my2:
            print("NO")
            exit()
        print("YES")
        exit()
    if b==a[cnt]:
        cnt+=1
        if my:
            my2=True
    else:
        if my2:
            print("NO")
            exit()
        my=True
        
if cnt==7:
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
a="keyence"
cnt=0
my=False
my2=False
for b in s:
    if cnt==7:
        print("YES")
        exit()
    if b==a[cnt]:
        cnt+=1
        if my:
            my2=True
    else:
        if my2:
            print("NO")
            exit()
        my=True
        
if cnt==7:
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
t="keyence"
k=0
for i in range(len(s)):
    if t[k]==s[i]:
        k+=1
    if k==len(t):
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
a="keyence"
cnt=0
for b in s:
    if cnt==7:
        print("YES")
        exit()
    if b==a[cnt]:
        cnt+=1
        
if cnt==7:
    print("YES")
    exit()
print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    d = collections.deque(list("keyence"))
    s = str(input().rstrip('\n'))
    for i in range(len(s)):
        if len(d) == 0:
            break
        else:
            p = d.popleft()
            if p != s[i]:
                d.appendleft(p)
    print("YES" if len(d) == 0 else "NO")


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
# 2019-11-28 00:55:58(JST)
import sys
def main():
    s = sys.stdin.readline().rstrip()

    target = 'keyence'
    i = 0
    t = target[0]
    for char in s:
        if char == t:
            i += 1
            if i == 7:
                ans = 'YES'
                break
            t = target[i]
    else:
        ans = 'NO'

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=input()

n=len(s)
flag=False
for i in range(n):
    for j in range(i,n):
        if (s[:i]+s[j:])=='keyence':
            flag=True
        print(s[:i]+s[j:])
print('YES' if flag else 'NO')

Submission status: Wrong Answer

Solution code:
s=input()

n=len(s)
flag=False
for i in range(n):
    for j in range(i,n):
        if (s[:i]+s[j:])=='keyence':
            flag=True
        print(s[:i]+s[j:])
print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
# B - KEYENCE String
S = input()
K = list('keyence#')
count = 0
idx_k = 0
is_NG = False

for s in S:
    if K[idx_k]==s:
        if idx_k<7:
            idx_k += 1
        is_NG = False
    else:
        if not is_NG:
            count +=1
            is_NG = True
    
    if count>=2:
        break
  
if count<=1 and idx_k>=7:
    print('YES')
else:
    print('NO')