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
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
T = "keyence"

if T in S:
    print("YES")
    exit()
for i in range(1, 7):
    left = T[:i]
    right = T[i:]
    l_idx = S.find(left) 
    r_idx = S.find(right) 
    if l_idx == - 1 or r_idx == -1:
        continue
    if l_idx < r_idx:
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

S = input()
T = []
i = 0
cur = ""
while i < len(S):
    if S[i] in "keyence":
        cur += S[i]
        i += 1
    else:
        T.append(cur)
        cur = ""
        while i < len(S) and S[i] not in "keyence":
            i += 1
if cur:
    T.append(cur)
for i in range(len(T)):
    if T[i] == "keyence":
        print("YES")
        exit()
    for j in range(i + 1, len(T)):
        if T[j] == "keyence":
            print("YES")
            exit()
        if T[i] + T[j] == "keyence":
            print("YES")
            exit()
print("NO")

Submission status: Wrong Answer

Solution code:
from sys import stdin

s = stdin.readline().strip()
t_len = len(s) - 7

if t_len == 0:
  if s == 'keyence': print('Yes')
  else: print('No')
  exit()
else:
  for i in range(7):
    if s[:i] + s[i+t_len:] == 'keyence':
      print('Yes')
      exit()
      
print('No')

Submission status: Wrong Answer

Solution code:
S = input()

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = max(0, t + i)
        break

if t == -1:
    t = 7

for i in range(1, 8):
    if not S[-i] == key[-i]:
        t = max(0, t + i)
        break

if t >= 7:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = max(0, t + i)
        break

if t == -1:
    t = 7

for i in range(1, 8):
    if not S[-i] == key[-i]:
        t = max(0, t + i - 1)
        break

if t >= 7:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = max(0, t + i)
        break

for i in range(1, 8):
    if not S[-i] == key[-i]:
        t = max(0, t + i - 1)
        break

if t >= 7 or t == -1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = max(0, t + i)
        break

for i in range(1, 8):
    if not S[-i] == key[-i]:
        t = max(0, t + i)
        break

if t >= 7 or t == -1:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
x=len(s)-7
if x==0:
  if  s=='keyence':
    print('YES')
    exit()
  else:
    print('NO')
    exit()

if s[:7]=='keyence':
    print('YES')
    exit()


for i in range(len(s)-6):
  if s[:i]+s[i+x:]=='keyence':
    print('YES')
    exit()
    
print('NO')

Submission status: Wrong Answer

Solution code:
s=input()
x=len(s)-7
if x==0:
  if  s=='keyence':
    print('YES')
    exit()
  else:
    print('NO')
    exit()


for i in range(len(s)-6):
  if s[:i+1]+s[i+6:]=='keyence':
    print('YES')
    exit()
    
print('NO')

Submission status: Wrong Answer

Solution code:
n = "keyence "
s = input()
cnt = 0


for i in s:
    if n[0] == i:
        n = n[1:]
        if cnt > 0:
            cnt = -1
    elif n[0] != i:
        if cnt == -1:
            break
        cnt += 1

if n == " ":
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
key = "keyence"
ptr = 0
cnt = 0
m = -1
f = True
if s == key:
    print("YES")
    exit()

for i in range(len(s)):
    if ptr != 7 and s[i] == key[ptr]:
        ptr += 1
    else:
        if m == -1 or m + 1 == i:
            m = i
        else:
            f = False

if f:
    f = (ptr == 7)

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

Submission status: Wrong Answer

Solution code:
s = input()
key = "keyence"
ptr = 0
cnt = 0
f = True
if s == key:
    print("YES")
    exit()

for i in range(len(s)):
    if ptr != 7 and s[i] == key[ptr]:
        f = True
        ptr += 1
    else:
        if f:
            cnt += 1
        f = False


print("YES" if ptr == 7 and cnt <= 1 else "NO")

Submission status: Wrong Answer

Solution code:
s = input()
key = "keyence"
ptr = 0

for c in s:
    if c == key[ptr]:
        ptr += 1
    if ptr == 7:
        break

print("YES" if ptr == 7 else "NO")

Submission status: Wrong Answer

Solution code:
S = input()
T = "keyence"
pos = 0
cnt = 0
for i in range(len(S)):
    if T[pos] == S[i]:
        pos += 1
    elif i != 0 and T[pos-1] == S[i-1]:
        cnt += 1
    if cnt == 2:
        print('NO')
        exit()
    if pos == len(T):
        print('YES')
        exit()
print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
T = 'keyence'
j = 0
for i in range(len(S)):
    if S[i] == T[j]:
        j += 1
        if j >= 7:
            print('YES')
            exit()
print('NO')

Submission status: Wrong Answer

Solution code:
import re

S=input()

if re.match('([a-z]*)keyence',S):
  print('YES')
elif re.match('k([a-z]*)eyence',S):
  print('YES')
elif re.match('ke([a-z]*)yence',S):
  print('YES')
elif re.match('key([a-z]*)ence',S):
  print('YES')
elif re.match('keye([a-z]*)nce',S):
  print('YES')
elif re.match('keyen([a-z]*)ce',S):
  print('YES')
elif re.match('keyenc([a-z]*)e',S):
  print('YES')
elif re.match('keyence([a-z]*)',S):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
import re

S=input()

if re.match('k([a-z]*)eyence',S):
  print('YES')
elif re.match('ke([a-z]*)yence',S):
  print('YES')
elif re.match('key([a-z]*)ence',S):
  print('YES')
elif re.match('keye([a-z]*)nce',S):
  print('YES')
elif re.match('keyen([a-z]*)ce',S):
  print('YES')
elif re.match('keyenc([a-z]*)e',S):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
import re

S=input()

if re.match('k[a-z]*eyence',S):
  print('YES')
elif re.match('ke[a-z]*yence',S):
  print('YES')
elif re.match('key[a-z]*ence',S):
  print('YES')
elif re.match('keye[a-z]*nce',S):
  print('YES')
elif re.match('keyen[a-z]*ce',S):
  print('YES')
elif re.match('keyenc[a-z]*e',S):
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
import re

S=input()
print('YES' if re.match('k[a-z]*e[a-z]*y[a-z]*e[a-z]*n[a-z]*c[a-z]*e',S) else 'NO')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
S = input()
N = len(S)
k = "keyence"
flg = False
for i in range(len(k)):
    if S[:i+1]==k[:i+1] and S[N-i:]==k[len(k)-i:]:
        flg = True
    #print(S[:i+1], k[:i+1])
    #print(S[N-i:], k[N-i:])

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

Submission status: Wrong Answer

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

j = 0
ans = 'NO'
for i in range(len(s)):
    if s[i] == t[j]:
        j += 1
    if j == len(t):
        ans = 'YES'
        break

print(ans)

Submission status: Wrong Answer

Solution code:
h='keyence'
now=0
for s in input():
    if s==h[0]:h=h[1:]
    if h:continue
    break
else:print("NO");exit()
print("YES")

Submission status: Wrong Answer

Solution code:
S = input()

k = 'keyence'
now = ''
if S[:7] == k or S[-7:] == k:
    print('YES')
    exit()
if len(S) < 7:
    print('NO')
    exit()
for i in range(len(S)):
    now += S[i]
    if S[:i] != k[:i]:
        if S[-7+i:] == k[-7+i:]:
            print('YES')
            exit()
        else:
            print('NO')
            exit()
print('NO')

Submission status: Wrong Answer

Solution code:
S = input()

k = 'keyence'
now = ''
if S[:7] == k or S[-7:] == k:
    print('YES')
    exit()
for i in range(len(S)):
    now += S[i]
    if S[:i] != k[:i]:
        if S[-7+i:] == k[-7+i:]:
            print('YES')
            exit()
        else:
            print('NO')
            exit()

Submission status: Wrong Answer

Solution code:
S = input()

k = 'keyence'
for i in range(len(k)):
    if k[:i] in S and k[i:] in S:
        print('YES')
        exit()
print('NO')

Submission status: Wrong Answer

Solution code:
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    keyence = "keyence"
    s = readline().rstrip()
    lenS = len(s)
    for i in range(1, 7):
        if s.count(keyence[0:i]) > 0:
            idx = s.index(keyence[0:i]) + i
            if s[idx-1:lenS].count(keyence[i:7]) > 0:
                print("YES")
                return
    print("NO")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    keyence = "keyence"
    s = readline().rstrip()
    lenS = len(s)
    for i in range(1, 7):
        if s.count(keyence[0:i]) > 0:
            idx = s.index(keyence[0:i]) + i + 1
            if s[idx-1:lenS].count(keyence[i:7]) > 0:
                print("YES")
                return
    print("NO")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    keyence = "keyence"
    s = readline().rstrip()
    lenS = len(s)
    for i in range(1, 7):
        if s.count(keyence[0:i]) > 0:
            idx = s.index(keyence[0:i]) + i - 1
            if s[idx:lenS].count(keyence[i:7]) > 0:
                print("YES")
                return
    print("NO")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    keyence = "keyence"
    s = readline().rstrip()
    lenS = len(s)
    cnt = 0
    for i in range(1, 7):
        if s.count(keyence[0:i]) > 0:
            idx = s.index(keyence[0:i]) + i
            if s[idx:lenS].count(keyence[i:7]) > 0:
                print("YES")
                return
    print("NO")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    keyence = "keyence"
    s = list(readline().rstrip())
    lenS = len(s)
    cnt = 0
    for i in range(lenS):
        if keyence[cnt] == s[i]:
            cnt += 1
        if cnt == 7:
            print("YES")
            return
    print("NO")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=input()
k='keyence'
if k in s:
    exit(print('YES'))

for i in range(len(k)):
    print(s[:i], s[len(k)-i:])
    if s[:i]+s[len(s)-len(k)+i:] == k:
        exit(print('YES'))
print('NO')

Submission status: Wrong Answer

Solution code:
S = input()
for i in range(len(S)):
    if S[i] != "k":
        continue
    index = i-1
    jump = True
    for j in "keyence":
        # print(j, index)
        try:
            temp = S.index(j, index+1)
            # print(temp, index)
            if temp - index != 1:
                if jump:
                    jump = False
                else:
                    break
            index = temp
        except:
            break
    else:
        print("YES")
        break
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

if s == 'keyence':
    print('YES')
    exit()

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

Submission status: Wrong Answer

Solution code:
s = input()
key = 'keyence'
n = len(s)
i = 0
j = 0
L = 0
R = 0
while i < n and j < 7:
    if s[i] == key[j]:
        i += 1
        j += 1
    else:
        L = i
        while s[i] != key[j]:
            i += 1
            if i == n:
                break
        R = i
        break
if L == 0 and s[R:] == key:
    print('YES')
elif j == 7 and s[0:i] == key:
    print('YES')
else:
    if s[0:L]+s[R:] == key:
        print('YES')
    else:
        print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
key = 'keyence'
L =''
R = ''

n = len(s)

i = 0
j = 0
flg = False

while i < n and j < 7:
    if s[i] == key[j]:
        i += 1
        j += 1
    else:
        if flg:
            print('NO')
            exit()
        flg = True
        while s[i] != key[j]:
            i += 1
            if i==n:
                break
if (flg and i < n):
    print('NO')
elif j < 7:
    print('NO')
else:
    print('YES')

Submission status: Wrong Answer

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

n = len(s)

i = 0
j = 0
cnt = 0
L = 0
R = 0
for v in cmp_s:
    if v == s[i]:
        i+=1
    else:
        L = i
        while v != s[i]:
            i += 1
            if i == n:
                break
        R = i
        break
if s[0:L]+s[R:] == cmp_s or (L == 0 and R == 0):
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

n = len(s)

i = 0
j = 0
cnt = 0
while i < n and j < 7:
    if s[i] == cmp_s[j]:
        while s[i] == cmp_s[j] and j < 7 and i < n:
            i += 1
            j += 1
            if 7<=j or n<=i:
                break
    else:
        cnt += 1
        if 2 <= cnt:
            print('NO')
            exit()
        while s[i] != cmp_s[j]:
            i += 1
            if 7<=j or n<=i:
                break
if j == 7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
i = 0
t = 'keyence'
for j in range(n):
  if i == 6:
    break
  if s[j] == t[i]:
    i += 1

if i == 6:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

k = 'keyence'


for i in range(1, 8):
    a, b = i, 7-i
    l, r = k[:i], k[i:]
    
    if l in s and r in s:
        if s.find(l) < s.find(r):
            print("YES")
            exit()

print('NO')

Submission status: Wrong Answer

Solution code:
s = input()

k = 'keyence'


for i in range(1, 8):
    a, b = i, 7-i
    l, r = k[:i], k[i:]
    
    if l in s and r in s:
        print("YES")
        exit()

print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
k = 'keyence'
a = 0
b = 6

for i in range(n):
    if k[a] == s[i]:
        a += 1
    else:
        break
    if a == 7:
        break

for i in range(n)[::-1]:
    if k[b] == s[i]:
        b -= 1
    else:
        break
    if b == -1:
        break

b = 7 - b + 1
if a + b >= 7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
s = input()
flag = False
r = "keyence"
for i in range(len(s)):
  #print(s[:i+1], r[:i+1])
  #print(s[i+1:], r[i+1:])
  if s[:i+1].find(r[:i+1])!=-1 and s[i+1:].find(r[i+1:])!=-1:
    flag = True
    break
if flag:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    s = S()
    cnt = 0
    tgt = "keyence"
    j = 0
    f = False
    for i in range(len(s)):
        if (s[i] == tgt[j]):
            if j < 6:j += 1
            f = True
        elif f:
            cnt += 1
            f = False
    #print(cnt,j)
    print("YES" if cnt <= 1 and j == 7 else "NO")

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    s = S()
    cnt = 0
    tgt = "keyence"
    for i in range(len(tgt)):
        a,b = tgt[:i],tgt[i:]
        if a in s and b in s:
            print("YES")
            exit()
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    s = S()
    cnt = 0
    tgt = "keyence"
    for i in range(len(tgt)):
        a,b = tgt[:i],tgt[i:]
        if a in s and b in s:
            print("Yes")
            exit()
    print("No")

Submission status: Wrong Answer

Solution code:
import re
S = input()
k = 'keyence'
for i in range(0, len(k)+1):
    rs = k[:i] + '.*' + k[i:]
    if re.match(rs, S) is not None:
        print('YES')
        break
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
def main():
    s=input()
    a="keyence"
    c=[False] * 7
    idx = 0
    skipped = False
    for i in range(len(s)):
        if idx >= len(a):
            print("NO" if skipped else "YES")
            return
        elif s[i] == a[idx]:
            c[idx] = True
            idx += 1
        elif not skipped:
            skipped = True
        else:
            break
    if all(c):
            print("YES")
            return
    print("NO")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s = input()
t = 'keyence0'
j = 0
p = 0
flg = False

for i in range(len(s)):
    if s[i] == t[j]:
        j += 1
        if flg:
            p += 1
            flg = False
    else:
        flg = True
    if p == 2:
        break

if flg:
    p += 1

if j == 7:
    if p == 2:
        print('NO')
    else:
        print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

for i in range(len(s)):
    if s[i] == t[j]:
        j += 1
    if j == 7:
        break

if j == 7:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    s = input()
    t = 'keyence'
    n = len(s)
    m = len(t)
    i = 0
    j = 0
    cnt = 0
    c = 0
    p = 0
    while i < n and j < m:
        if s[i] == t[j]:
            j += 1
            c = 1
        else:
            c = 0
        
        if c != p and i:
            cnt += 1

        i += 1
        p = c

    if j == m and cnt <= 1:
        print("YES")
    else:
        print("NO")


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()

"""

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    s = input()
    t = 'keyence'
    n = len(s)
    m = len(t)
    i = 0
    j = 0
    cnt = 0
    c = 0
    p = 0
    while i < n and j < m:
        if s[i] == t[j]:
            j += 1
            c = 1
        else:
            c = 0
        
        if c != p and i:
            cnt += 1

        i += 1
        p = c

    if j == m and cnt <= 2:
        print("YES")
    else:
        print("NO")


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()

"""

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    s = input()
    t = 'keyence'
    n = len(s)
    m = len(t)
    i = 0
    j = 0
    cnt = 0
    c = 0
    p = 0
    while i < n and j < m:
        if s[i] == t[j]:
            j += 1
            c = 1
        else:
            c = 0
        
        if c != p:
            cnt += 1

        i += 1
        p = c

    if j == m and cnt <= 3:
        print("YES")
    else:
        print("NO")


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()

"""

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    s = input()
    t = 'keyence'
    n = len(s)
    m = len(t)
    i = 0
    j = 0
    cnt = 0
    prv = 0
    while i < n and j < m:
        if s[i] == t[j]:
            j += 1
            prv = 1
        else:
            if prv == 1:
                cnt += 1
            prv = 0
        i += 1

    if j == m and cnt == 1:
        print("YES")
    else:
        print("NO")


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()

"""

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    s = input()
    t = 'keyence'
    n = len(s)
    m = len(t)
    i = 0
    j = 0
    cnt = 1
    prv = 0
    while i < n and j < m:
        if s[i] == t[j]:
            j += 1
            prv = 1
        else:
            if prv == 1:
                cnt += 1
            prv = 0
        i += 1

    if j == m and cnt == 1:
        print("YES")
    else:
        print("NO")


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()

"""

"""

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]


def solve():
    s = input()
    t = 'keyence'
    n = len(s)
    m = len(t)
    i = 0
    j = 0
    while i < n and j < m:
        if s[i] == t[j]:
            j += 1
        i += 1

    if j == m:
        print("YES")
    else:
        print("NO")


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()

"""

"""

Submission status: Wrong Answer

Solution code:
S = input()
s = "keyence"
for i in range(8):
  if s[:i] in S and s[i:] in S: 
    print("YES")
    break
else: print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

if s == "keyence":
    print("YES")
    exit()

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

print("NO")

Submission status: Wrong Answer

Solution code:
s = input()

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

print("NO")

Submission status: Wrong Answer

Solution code:
import sys
s = list(input())
sr = list(reversed(s))
k = list("keyence")
kr = list(reversed(k))
cur = 0
curr = 0
mlen = 0
mlenr = 0
i = 0
ir = 0
while cur <= len(s)-1:
  if s[cur] == k[i]:
    i += 1
    mlen = max(mlen,i)
    if mlen == 7:
      print("YES")
      sys.exit()
  else:
    i = 0
  cur += 1
while curr <= len(sr)-1:
  if sr[curr] == kr[ir]:
    ir += 1
    mlenr = max(mlenr,ir)
  else:
    ir = 0
  curr += 1
if mlen+mlenr >= 7:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
s = list(input())
k = list("keyence")
i = 0
cur = 0
while cur <= len(s)-1:
  if s[cur] == k[i]:
    i += 1
  cur += 1
  if i == 7:
    print("YES")
    break
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import copy

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

s = list(input())

d = deque(["k","e","y","e","n","c","e"])

for i in s:
	if not d:
		break
	t = d.popleft()
	if t==i:
		continue
	else:
		d.appendleft(t)

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import copy

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

s = list(input())

d = deque(["e","y","e","n","c","e"])
t = "k"

for i in s:
	if not d:
		break
	if t==i:
		t = d.popleft()

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

Submission status: Wrong Answer

Solution code:
S = input()

p = 0
keyence = list("keyence")
# print(keyence)
id = []

for s in S:
    if p > 6:
        id.append(p)
        continue
    if s != keyence[p]:
        id.append(p)
        continue
    if p <= 6:
        p += 1

# print(p, id)
if p == 7 and (len(set(id)) == 1 or len(id) == 0):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

p = 0
keyence = list("keyence")
# print(keyence)
id = []

for s in S:
    if p > 6:
        continue
    if s != keyence[p]:
        id.append(p)
        continue
    if p <= 6:
        p += 1

# print(p, id)
if p == 7 and (len(set(id)) == 1 or len(id) == 0):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

p = 0
keyence = list("keyence")
# print(keyence)
id = []

for s in S:
    if p > 6 or s != keyence[p]:
        id.append(p)
        continue
    if p <= 6:
        p += 1

# print(p, id)
if p == 7 and (len(set(id)) == 1 or len(id) == 0):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()

p = 0
keyence = list("keyence")
# print(keyence)

for s in S:
    if p <= 6 and s == keyence[p]:
        p += 1

# print(p)
if p == 7:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
s = input()
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

K = 'keyence'

for i in range(len(s) + 1):
    for j in range(7 + 1):
        s1 = s[0:i]
        s2 = s[i:i + j]
        s3 = s[i + j:]

        if s1 == K or s2 == K or s3 == K or s1 + s2 == K or s1 + s3 == K or s2 + s3 == K:
            print('YES')
            exit()

print('NO')

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
s = input()
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

K = 'keyence'

for i in range(len(s) + 1):
    for j in range(7 + 1):
        s1 = s[0:i]
        s2 = s[i:i + j]
        s3 = s[i + j:]

        print(s1, s2, s3)
        if s1 == K or s2 == K or s3 == K or s1 + s2 == K or s1 + s3 == K or s2 + s3 == K:
            print('YES')
            exit()

print('NO')

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
s = input()
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

K = 'keyence'

for i in range(len(s)):
    for j in range(7):
        s1 = s[0:i]
        s2 = s[i:i + j]
        s3 = s[i + j:]

        if s1 + s2 == K or s1 + s3 == K or s2 + s3 == K:
            print('YES')
            exit()

print('NO')

Submission status: Wrong Answer

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

S = input()

for i in range(len(S)):
    for j in (i,len(S)):
        t = S[0:i]+S[j:]
        if t == "keyence":
            print("YES")
            sys.exit()

print("NO")

Submission status: Wrong Answer

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

S = input()

# keyenceXXXXX
# YYYYkeyence
# keyZZZZZence

if S[0:7] == "keyence" or S[len(S)-7:len(S)] == "keyence" :
    print("YES")
    sys.exit()

if S[0:3] == "key" and S[len(S)-4:len(S)] == "ence":
    print("YES")
    sys.exit()

print("NO")