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, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
l = len(s)
a = 'keyence'
flag = False
for i in range(l - 6): #消し始め
    for j in range(l - i + 1): #消す文字数
        if s[:i] + s[i+j:] == a:
            print('YES')
            exit()
print('NO')

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
l = len(s)
a = 'keyence'
flag = False
for i in range(l):
    for j in range(l - i):
        if s[:i] + s[j:] == a:
            print('YES')
            exit()
print('NO')

Submission status: Wrong Answer

Solution code:
# KEYENCE String 全通りのパターンを探索する

# input process
S = input()
s_length = len(S)

# initialization
is_same = False
for i in range(s_length):
    for j in range(i, s_length):
        # string slice
        tmp_str = S[:i+1] + S[j:]
        if tmp_str=="keyence":
            is_same = True
            break

if is_same:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# KEYENCE String 全通りのパターンを探索する

# input process
S = input()
s_length = len(S)

# initialization
is_same = False
for i in range(s_length):
    for j in range(i, s_length):
        # string slice
        tmp_str = S[:i] + S[j:]
        if tmp_str=="keyence":
            is_same = True
            break

if is_same:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# 2020/03/07
# キーエンス プログラミング コンテスト 2019 - B

# Input
s = input()
ts = "keyence"

# Calc
ans = "NO"
idx = 0
turnflg = 0

for i in range(len(s)):
    if s[i] == ts[idx]:
        idx = idx + 1
        if idx >= len(ts):
            ans = "YES"
            break
    else:
        if turnflg == 0:
            turnflg = 1
            idx2 = len(ts)-1
            for j in range(len(ts)-1, 0, -1):
                if s[j] == ts[idx2]:
                    idx2 = idx2 - 1
                    if (idx + idx2) == len(ts):
                        ans = "YES"
                        break
# Output
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = list(input())

ans = "NO"
n = len(s)
if n == 7:
    i = 0
    if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c' and s[i+6] == 'e':
        ans = "YES"

else:
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c' and s[i+6] == 'e':
            ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c' and i != 0:
            if s[n-1] == 'e':
                ans = "YES"
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c' and i == 0:
            for j in range(i+6, n):
                if s[j] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and i != 0:
            if s[n-2] == 'c' and s[n-1] == 'e':
                ans = "YES"
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and i == 0:
            for j in range(i+5, n - 1):
                if s[j] == 'c' and s[j+1] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and i != 0:
            if s[n-3] == 'n' and s[n-2] == 'c' and s[n-1] == 'e':
                ans = "YES"
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and i == 0:
            for j in range(i+4, n - 2):
                if s[j] == 'n' and s[j+1] == 'c' and s[j+2] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and i != 0:
            if s[n-4] == 'e' and s[n-3] == 'n' and s[n-2] == 'c' and s[n-1] == 'e':
                ans ="YES"
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and i == 0:
            for j in range(i+3, n - 3):
                if s[j] == 'e' and s[j+1] == 'n' and s[j+2] == 'c' and s[j+3] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and i != 0:
            if s[n-5] == 'y' and s[n-4] == 'e' and s[n-3] == 'n' and s[n-2] == 'c' and s[n-1] == 'e':
                ans = "YES"
        if s[i] == 'k' and s[i+1] == 'e' and i == 0:
            for j in range(i+2, n - 4):
                if s[j] == 'y' and s[j+1] == 'e' and s[j+2] == 'n' and s[j+3] == 'c' and s[j+4] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and i != 0:
            if s[n-6] == 'e' and s[n-5] == 'y' and s[n-4] == 'e' and s[n-3] == 'n' and s[n-2] == 'c' and s[n-1] == 'e':
                ans = "YES"
        if s[i] == 'k' and i == 0:
            for j in range(i+1, n - 5):
                if s[j] == 'e' and s[j+1] == 'y' and s[j+2] == 'e' and s[j+3] == 'n' and s[j+4] == 'c' and s[j+5] == 'e':
                    ans = "YES"
print(ans)

Submission status: Wrong Answer

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

if len(s) < len(t):
    print('NO')
    exit()

if s[0:len(t)] == t:
    print('YES')
    exit()

if s[len(s)-len(t):len(s)] == t:
    print('YES')
    exit()

for i in range(len(t)):
    if s[0:i+1] == t[0:i+1] and s[len(s)-(i+1):len(s)] == t[len(t)-(i+1):len(t)]:
        print('YES')
        exit()
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = str(input())
j = 0
flag = 0
if "key" in s:
    if "ence" in s:
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

Solution code:
# 2020/03/07
# キーエンス プログラミング コンテスト 2019 - B

# Input
s = input()
ts = "keyence"

# Calc
ans = "NO"
idx = 0
skipflg = 0
for i in range(len(s)):
    if s[i] == ts[idx]:
        idx = idx + 1
        if idx >= len(ts):
            if skipflg == 0 or (i == len(s) - 1):
                ans = "YES"
            break
        if skipflg == 1:
            skipflg = 2
    else:
        if skipflg == 0:
            skipflg = 1
        elif skipflg == 2:
            break

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
st = 'keyence'
index = 0
delete = []
con = False
for i in range(len(s)):
    #print(i, index, s[i], st[index], con)
    if index < len(st) and s[i] == st[index]:
        if index != i:
            con = True
        index += 1
    elif index < len(st) and con:
        print('NO')
        exit()
if index == len(st):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = list(input())

ans = "NO"
n = len(s)
if n == 7:
    i = 0
    if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c' and s[i+6] == 'e':
        ans = "YES"

else:
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c' and s[i+6] == 'e':
            ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c':
            for j in range(i+6, n):
                if s[j] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n':
            for j in range(i+5, n - 1):
                if s[j] == 'c' and s[j+1] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e':
            for j in range(i+4, n - 2):
                if s[j] == 'n' and s[j+1] == 'c' and s[j+2] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y':
            for j in range(i+3, n - 3):
                if s[j] == 'e' and s[j+1] == 'n' and s[j+2] == 'c' and s[j+3] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k' and s[i+1] == 'e':
            for j in range(i+2, n - 4):
                if s[j] == 'y' and s[j+1] == 'e' and s[j+2] == 'n' and s[j+3] == 'c' and s[j+4] == 'e':
                    ans = "YES"
    for i in range(n - 7):
        if s[i] == 'k':
            for j in range(i+1, n - 5):
                if s[j] == 'e' and s[j+1] == 'y' and s[j+2] == 'e' and s[j+3] == 'n' and s[j+4] == 'c' and s[j+5] == 'e':
                    ans = "YES"
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = list(input())

ans = "NO"
n = len(s)
if n == 7:
    i = 0
    if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c' and s[i+6] == 'e':
        ans = "YES"

for i in range(n - 7):
    if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c' and s[i+6] == 'e':
        ans = "YES"
for i in range(n - 7):
    if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n' and s[i+5] == 'c':
        for j in range(i+6, n):
            if s[j] == 'e':
                ans = "YES"
for i in range(n - 7):
    if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e' and s[i+4] == 'n':
        for j in range(i+5, n - 1):
            if s[j] == 'c' and s[j+1] == 'e':
                ans = "YES"
for i in range(n - 7):
    if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y' and s[i+3] == 'e':
        for j in range(i+4, n - 2):
            if s[j] == 'n' and s[j+1] == 'c' and s[j+2] == 'e':
                ans = "YES"
for i in range(n - 7):
    if s[i] == 'k' and s[i+1] == 'e' and s[i+2] == 'y':
        for j in range(i+3, n - 3):
            if s[j] == 'e' and s[j+1] == 'n' and s[j+2] == 'c' and s[j+3] == 'e':
                ans = "YES"
for i in range(n - 7):
    if s[i] == 'k' and s[i+1] == 'e':
        for j in range(i+2, n - 4):
            if s[j] == 'y' and s[j+1] == 'e' and s[j+2] == 'n' and s[j+3] == 'c' and s[j+4] == 'e':
                ans = "YES"
for i in range(n - 7):
    if s[i] == 'k':
        for j in range(i+1, n - 5):
            if s[j] == 'e' and s[j+1] == 'y' and s[j+2] == 'e' and s[j+3] == 'n' and s[j+4] == 'c' and s[j+5] == 'e':
                ans = "YES"
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
st = 'keyence'
index = 0
delete = []
con = False
for i in range(len(s)):
    #print(i, index, s[i], st[index], con)
    if index < len(st) and s[i] == st[index]:
        if index != i:
            con = True
        index += 1
    elif con:
        print('NO')
        exit()
if index == len(st):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
# 2020/03/07
# キーエンス プログラミング コンテスト 2019 - B

# Input
s = input()
ts = "keyence"

# Calc
ans = "NO"
idx = 0
for i in range(len(s)):
    if s[i] == ts[idx]:
        idx = idx + 1
        if idx >= len(ts):
            ans = "YES"
            break

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

def is_keyence(target: str):
    key = "keyence"

    if target == key:
        return True

    for i in range(len(target)):
        for j in range(i, len(target)):
            tmp = ""
            if i > 0:
                tmp += target[0:i - 1]
            if j < len(target) - 1:
                tmp += target[j + 1:]
            if tmp == key:
                return True
    return False


print("YES" if is_keyence(input().rstrip()) else "NO")

Submission status: Wrong Answer

Solution code:
s = input()
st = 'keyence'
index = 0
delete = []
for i in range(len(s)):
    if index < len(st) and s[i] == st[index]:
        index += 1
    else:
        delete.append(i)
flag = True
if len(delete):
    former = delete[0]
    for i in range(1, len(delete)):
        if delete[i] != former + 1:
            flag = False
        former = delete[i]
if index == len(st) and flag:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
S=input()
tgt="keyence"
res=S==tgt
for i in range(len(S)-6):
    T = S[:i]+S[-7+i:]
    #print(T)
    if T==tgt:
        res=True
print("YES" if res else "NO")

Submission status: Wrong Answer

Solution code:
S=input()
tgt="keyence"
res=S==tgt
for i in range(len(S)-7):
    T = S[:i]+S[-7+i:]
    #print(T)
    if T==tgt:
        res=True
print("YES" if res else "NO")

Submission status: Wrong Answer

Solution code:
s = input()
st = 'keyence'
index = 0
for i in range(len(s)):
    if index < len(st) and s[i] == st[index]:
        index += 1
if index == len(st):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
S = list(input())[: -1]
for l in range(len(S)):
  for mr in range(l, len(S)):
    for ml in range(mr, len(S)):
      for r in range(ml, len(S)):
        t = S[l: mr + 1] + S[ml: r + 1]
        if "".join(t) == "keyence":
          print("YES")
          exit(0)
print("NO")

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()
k = "keyence"
j = 0

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

Submission status: Wrong Answer

Solution code:
s=str(input())
num=len(s)-7

ans="NO"

if num==0:
    if s=="keyence":
        ans="YES"

s=s+"!"

s1=""
s2=s[0:num]
s3=s[num:]

for _ in range(8):
    print(s1,s2,s3)
    if s1+s3=='keyence!':
        ans="YES"
        break
    s1=s1+s2[0]
    s2=s2[1:]+s3[0]
    s3=s3[1:]

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

master = "keyence"

i = 0
f = 0

if(master in s):
    print("YES")
else:
    i = 0
    while (s[i] == master[i]):
        i += 1
    if (s[-7+i:] == master[i:]):
        print("YES")
    print("NO")

Submission status: Wrong Answer

Solution code:
Key_str = 7

S = str(input())
count =0

if len(S)<Key_str:
    print("No")

else:
    del_str = len(S)-Key_str
    
    for i in range(len(S)-del_str):
        try_str = S[:i] + S[i+del_str:]
        if try_str == 'keyence':
            print("Yes")
            count+=1
            break
    if count==0:
        print("No")

Submission status: Wrong Answer

Solution code:
S=input()
a=1
for i in range(len(S)):
  for j in range(len(S)-i):
    if S[:i]+S[i+j+1:]=='keyence':
      a=0
print('YNEOS'[a::2])

Submission status: Wrong Answer

Solution code:
S=input()
a=1
for i in range(len(S)-6):
  if S[:i]+S[i-7:]=='keyence':
    a=0
print('YNEOS'[a::2])

Submission status: Wrong Answer

Solution code:
# アルゴリズムイントロダクション 15.4 LCS
# Longest Common Subsequenceをとり、以下を返す
# b: 結果
# c: そこまでのlongestのcount(内部用)
def lcs_length(x, y):
    m, n = len(x), len(y)
    b = [[0 for _ in range(n + 1)] for _ in range(m + 1)]
    c = [[0 for _ in range(n + 1)] for _ in range(m + 1)]
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if x[i - 1] == y[j - 1]:
                c[i][j] = c[i - 1][j - 1] + 1
                b[i][j] = '↖'
            elif c[i - 1][j] >= c[i][j - 1]:
                c[i][j] = c[i - 1][j]
                b[i][j] = "↑"
            else:
                c[i][j] = c[i][j - 1]
                b[i][j] = "←"
    return c, b

# アルゴリズムイントロダクション 15.4 LCS
# bを基にもともとのinput xから共通部分を抜き出す。
def lcs_decode(b, X, i, j):
    import collections
    res = collections.deque([])
    while True:
        # print("i={0}, j={1} b={2}".format(i,j,b[i][j]))
        if i == 0 or j == 0:
            break
        if b[i][j] == '↖':
            res.appendleft(X[i - 1])
            i -= 1
            j -= 1
        elif b[i][j] == "↑":
            i -= 1
            continue
        else:
            j -= 1
            continue
    return res

str1 = "keyence"
str2 = input()
c, b = lcs_length(str1, str2)
s = "".join(list(lcs_decode(b, str1, len(str1), len(str2))))
print("YES" if s=="keyence" else "NO")

Submission status: Wrong Answer

Solution code:
s=input()
c=0
if 'keyence' in s:
  c=1
if s[:1]=='k' and s[-6:]=='eyence':
  c=1
if s[:2]=='ke' and s[-5:]=='yence':
  c=1
if s[:3]=='key' and s[-4:]=='ence':
  c=1
if s[:4]=='keye' and s[-3:]=='nce':
  c=1
if s[:5]=='keyen' and s[-2:]=='ce':
  c=1
if s[6:]=='keyenc' and s[-1:]=='e':
  c=1

print('YES' if c==1 else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()
ans = 'keyence'
state = 0
for i in range(len(s)):
    if state == 7:
        print('YES')
        break
    elif s[i]==ans[state]:
        state += 1
    else:
        continue
else:
    print('YES' if state==7 else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()
ans = 'keyence'
state = 0
for i in range(len(s)):
    if state == 7:
        break
    elif s[i]==ans[state]:
        state += 1
    else:
        continue
else:
    print('YES' if state==7 else 'NO')

Submission status: Wrong Answer

Solution code:
S = input()
if(S.rfind("key") < S.rfind("ence")):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import re
s = input()
pat = ".*key.*ence"
pat2 = "key.*ence.*"
if re.findall(pat, s) or re.findall(pat2, s):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import re
s = input()
pat = "key.*ence"
if re.findall(pat, s):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
k = 'keyence'
r = 'NO'
for i in range(len(k)):
    fid = s.find(k[:i])
    if -1<fid:
        bid = s[fid+i:].rfind(k[i:])
        if -1<bid:
            r = 'YES'
print(r)

Submission status: Wrong Answer

Solution code:
s = input()
k = 'keyence'
r = 'NO'
for i in range(len(k)):
    fid = s.find(k[:i])
    bid = s.rfind(k[i:])
    if -1<fid<bid:
        r = 'YES'
print(r)

Submission status: Wrong Answer

Solution code:
s = input()
k = 'keyence'
r = 'NO'
for i in range(1, len(k)-1):
    if k[:i] in s and k[i:] in s:
        fid = s.index(k[:i])
        bid = s.index(k[i:])
        if -1<fid<bid:
            r = 'YES'
print(r)

Submission status: Wrong Answer

Solution code:
def examA():
    N = LI()
    N.sort()
    if N==[1,4,7,9]:
        print("YES")
    else:
        print("NO")
    return

def examB():
    S = SI()
    K = "keyence"
    for i in range(8):
        if S[:i]+S[-7+i:0]==K:
            print("YES")
            return
    print("NO")
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Submission status: Wrong Answer

Solution code:
S = input()
moji = "keyence"
cnt = 0
flag = 0
for i in range(len(S)):
	if S[i] == moji[cnt]:
		cnt += 1
		if flag == 1:
			flag = 2
	else:
		if flag == 2:
			print("NO")
			exit()
		flag = 1
	if cnt == 7:
		print("YES")
		exit()
print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
moji = "keyence"
cnt = 0
for i in range(len(S)):
	if S[i] == moji[cnt]:
		cnt += 1
	if cnt == 7:
		print("YES")
		exit()
print("NO")

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = sys.stdin.readline()

	counter = 0
	if(S[0]!='k'):
		if(S[-8:-1]=='keyence'):
			print("Yes")
		else:
			print("No")
	elif(S[0]=="k" and S[-2]!="e"):
		if(S[0:7]=='keyence'):
			print("Yes")
		else:
			print("No")
	elif(S[0]=="k" and S[-2]=="e"):
		key = "keyence"
		for i in range(2,7):
			if(key == str(S[0:i])+str(S[-8+i:-1])):
				print("Yes")
				break
	else:
		print("No")

main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = sys.stdin.readline()

	counter = 0
	if(S[0]!='k'):
		if(S[-8:-1]=='keyence'):
			print("Yes")
		else:
			print("No")
	elif(S[0]=="k" and S[-2]!="e"):
		if(S[0:7]=='keyence'):
			print("Yes")
		else:
			print("No")
	elif(S[0]=="k" and S[-2]=="e"):
		key = "keyence"
		for i in range(2,7):
			if(key == str(S[0:i])+str(S[-8+i:-1])):
				print("Yes")
	else:
		print("No")

main()

Submission status: Wrong Answer

Solution code:
s=str(input())
f=False
for i in range(len(s)-1):
  for j in range(i+1,len(s)):
    if s[:i]+s[j:]=="keyence":
      f=True
      break
print("YES" if f==True else "NO")

Submission status: Wrong Answer

Solution code:
s=str(input())
f=False
for i in range(len(s)-1):
  for j in range(i+1,len(s)+1):
    if s[:i]+s[j:]=="keyence":
      f=True
      break
print("YES" if f==True else "NO")

Submission status: Wrong Answer

Solution code:
S = input()


ans = True
for i in range(len(S)):
    for j in range(i, len(S)):
        moji = S[:i] + S[j:]
        if moji == 'keyence':
            ans = True
            break

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

Submission status: Wrong Answer

Solution code:
s = input()

idx_key = s.find('key')
idx_ence = s.find('ence')
idx_keyence = s.find('keyence')

ans = False
# keyとenceの間に無駄な文字列が入ってるパターン
if idx_key == 0 and idx_ence == len(s) - 4:
    ans = True
# keyenceがあるとき
elif idx_keyence != -1:
    # keyenceの左右いずれかに無駄な文字列があるパターン
    if len(s[:idx_keyence]) == 0 or len(s[idx_keyence+7:]) == 0:
        ans = True

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

Submission status: Wrong Answer

Solution code:
s = input()
end = len(s)
flg = False
for i in range(end,0,-1):
    for j in range(end):
        string = s.replace(s[j:i],'')
        if string == 'keyence':
            flg = True
            break
            
print('YES' if flg else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()
end = len(s)
flg = False
for i in range(end,1,-1):
    for j in range(end):
        string = s.replace(s[j:i],'')
        if string == 'keyence':
            flg = True
            break
            
print('YES' if flg else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()
search = 'keyence'
flg = True

for i in search:
    if i in s:
        idx = s.find(i)
        s = s[idx:]
    else:
        flg = False
        break
               
print('YES' if flg else 'NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
print('YES' if len(s)>=7 and s[:3]=='key' and s[-4:]=='ence' else 'NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
chk='keyence'
if chk in s:
	print('YES')
else:
	for i in range(6):
		if chk[:i] in s:
			k=s.index(chk[:i])+i
			if chk[:i+1] in s[k:]:
				print('YES')
				break
	else:
		print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input()
b = "keyence"
j = 0
for i in a:
    if j == 7:
        break
    elif i==b[j]:
        j+=1
print("YES" if j >= 7 else "NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    exam = list("keyence")
    count = 0
    flag = False
    over = 0

    for s in S:
        if len(exam) == 0:
            over += 1
        if over == 1:
            break
        if (s == exam[0]) & (flag == False):
            exam.pop(0)
        elif flag == False:
            flag = True
            count += 1
        elif (flag == True) & (s == exam[0]):
            exam.pop(0)
            flag = False




    if (count <= 1) & (len(exam) == 0) & (over == 0):
        print("YES")
    else:
        print("NO")

    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    exam = list("keyence")

    for s in S:
        if s == exam[0]:
            exam.pop(0)
        if len(exam) == 0:
            print("YES")
            return 0
    print("NO")


    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = input()

k = 'keyence'

ans = ''
j=0
for i, c in enumerate(s):
  if c == k[i]:
    pass
  else:
    ans = s[0:i]
    s = s[i:]
    j=i
    break

for i, c in enumerate(s):
  if k[j] == c:
    j = i
    ans += s[i:]
    break

if ans == k:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    S=input()
    n=len(S)

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

    print("NO")
resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC140 E
#類題 AGC5 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def check(a,b):
    if b in s:
        idx = s.index(b)
        if a in s[:idx]:
            return True
    return False
s = input()
t = 'keyence'
n = len(t)
for i in range(n):
    if check(t[:i],t[i:]):
        print('YES')
        quit()
print('NO')

Submission status: Wrong Answer

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

def main():
    s = input()
    KEYENCE = 'keyence'
    if s[:7] == KEYENCE or s[-7:] == KEYENCE:
        print('YES')
        exit()

    index = 0
    err = 0
    isCount = True
    ans = 'NO'
    for i, v in enumerate(list(s)):
        if v == KEYENCE[index]:
            index += 1
            isCount = True
            if index == 7:
                if i == len(s) - 1:
                    ans = 'YES'
                break
        elif isCount:
            err += 1
            isCount = False
            if err > 1:
                break
    print(ans)
    
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 = True
    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()