Problem:


Score : 200 points

Problem Statement

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

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

Constraints

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

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

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

Sample Input 1

keyofscience

Sample Output 1

YES

keyence is an abbreviation of key of science.

Sample Input 2

mpyszsbznf

Sample Output 2

NO

Sample Input 3

ashlfyha

Sample Output 3

NO

Sample Input 4

keyence

Sample Output 4

YES



Sample input:
keyofscience


Sample output:
YES

Submission status: Wrong Answer

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

if pattern in s:
    ans = 'YES'

for i in range(1, len(pattern) - 1):
    x = pattern[:i]
    y = pattern[i:]
    p = 0
    while s.find(x, p) >= 0:
        p = s.find(x, p) + len(x)
        if s.find(y, p - 1) >= 0:
            ans = 'YES'
            break

print(ans)

Submission status: Wrong Answer

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

if pattern in s:
    ans = 'YES'

for i in range(1, len(pattern) - 1):
    x = pattern[:i]
    y = pattern[i:]
    p = 0
    while s.find(x, p) >= 0:
        p = s.find(x, p) + len(x)
        if s.find(y, p) >= 0:
            ans = 'YES'
            break

print(ans)

Submission status: Wrong Answer

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

if pattern in s:
    ans = 'YES'

for i in range(1, len(pattern) - 1):
    x = pattern[:i]
    y = pattern[i:]
    p = 0
    while s.find(x, p) >= 0:
        p += s.find(x, p) + len(x)
        if s.find(y, p) >= 0:
            ans = 'YES'
            break

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 'NO'
pattern = 'keyence'
for i in range(len(pattern) - 1):
    x = pattern[:i]
    y = pattern[i:]
    p = 0
    while s.find(x, p) >= 0:
        p += 1
        if s.find(y, p + len(x) - 1) >= 0:
            ans = 'YES'
            break

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 'NO'
pattern = 'keyence'
for i in range(len(pattern) - 1):
    x = pattern[:i]
    y = pattern[i:]
    p = 0
    while s.find(x, p) >= 0:
        p += 1
        if s.find(y, p) >= 0:
            ans = 'YES'
            break

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 'NO'
pattern = 'keyence'
for i in range(len(pattern) - 1):
    x = pattern[:i]
    y = pattern[i:]
    if s.find(x) >= 0:
        if s.find(y, s.find(x) + len(x) - 1) >= 0:
            ans = 'YES'
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import re

def main():
    N = str(input())
    if re.match("^.*keyence$", N) or re.match("^k.*eyence$", N) or re.match("^ke.*yence$", N) or re.match("^key.*ence$", N) or re.match("^keye.*nce$", N) or re.match("^keyen.*ce$", N) or re.match("^keyenc.*e$", N) or re.match("^keyence.*$", N):
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s = input()

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

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

Submission status: Wrong Answer

Solution code:
s = input()

k = []
key = 'keyence'
for i in range(7):
    k.append([key[:i],key[i:]])

flag = False
for i in k:
    if i[0] in s and i[1] in s:
        flag = True
if flag:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S=input()
length=len(S)
ans='NO'
if S[0:7]=='keyence':
    ans='Yes'
elif S[-7:]=='keyence':
    ans='Yes'
elif S[0]=='k' and S[-6:]=='eyence':
    ans='Yes'
elif S[0:2]=='ke' and S[-5:]=='yence':
    ans='Yes'
elif S[0:3]=='key' and S[-4:]=='ence':
    ans='Yes'
elif S[0:4]=='keye' and S[-3:]=='nce':
    ans='Yes'
elif S[0:5]=='keyen' and S[-2:]=='ce':
    ans='Yes'
elif S[0:6]=='keyenc' and S[-1:]=='e':
    ans='yes'

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re
S=input()
patterns=['[a-z]*keyence','keyence[a-z]*']
keyence = "keyence"
for i in range(1,len(keyence)):
    patterns.append(keyence[:i]+'[a-z]*'+keyence[i:])
for p in patterns:
    if re.match(p,S):
        print('YES')
        exit()
print('NO')

Submission status: Wrong Answer

Solution code:
import re
S=input()
patterns=[]
keyence = "keyence"
for i in range(1,len(keyence)):
    patterns.append(keyence[:i]+'[a-z]*'+keyence[i:])
for p in patterns:
    if re.match(p,S):
        print('YES')
        exit()
print('NO')

Submission status: Wrong Answer

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

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

for i in range(n):
	ss = s[::]
	for j in range(i, n):
		ss.pop(i)
		if "".join(ss) == "keyence":
			print("YES")
			break
	else:
		continue
	break
else:
	print("NO")

Submission status: Wrong Answer

Solution code:
s = input()
k_index = []
k = 'keyence'

for i in range(len(s)):
    if s[i] == k[0]:
        k_index.append(i)

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

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
k_index = []
k = 'keyence'

for i in range(len(s)):
    if s[i] == k[0]:
        k_index.append(i)

ans = 'NO'
for i in k_index:
    j = 0
    flag = 0
    for a in range(len(s[i:])):
        if s[i+a] == k[j]:
            j += 1
            if j == len(k):
                ans = 'YES'
                break
        else:
            if k[j:] in s[i+a:]:
                ans = 'YES'
            break
    if ans == 'YES':
        break

print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
k_index = []
k = list('keyence')

for i in range(len(s)):
    if s[i] == k[0]:
        k_index.append(i)

ans = 'NO'
for i in k_index:
    j = 0
    flag = 0
    for a in s[i:]:
        if a == k[j]:
            j += 1
            if flag == 0:
                flag = 1 # reading 1st half
            elif flag == 2:
                flag = 3 # reading 2nd half
            if j == len(k):
                ans = 'YES'
                break
        elif flag == 1: # end of 1st half
            flag = 2 # reading middle
        elif flag == 3:
            break
        if ans == 'YES':
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
s = input()
n = len(s)
yes = False
for i in range(n):
    for j in range(i, n):
        if (s[: i] + s[j :]).startswith("keyence"):
            yes = True
            break
    if yes:
        break
if yes:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
s = input()
x = "keyence"
yes = False
for i in range(8):
    left = x[: i]
    right = x[i : ]
    # print("left =", left)
    # print("right =", right)
    l = s.find(left)
    if l == -1:
        continue
    r = s[l + len(left) :].find(right)
    if r != -1:
        yes = True
        break
if yes:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
s = input()
x = "keyence"
yes = False
for i in range(8):
    left = x[: i]
    right = x[i : ]
    # print("left =", left)
    # print("right =", right)
    l = s.find(left)
    r = s.find(right)
    if l != -1 and r != -1 and l + len(left) <=  r:
        # print(l, r)
        yes = True
        break
if yes:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
s = input()
x = "keyence"
yes = False
for i in range(8):
    left = x[: i]
    right = x[i : ]
    # print("left =", left)
    # print("right =", right)
    l = s.find(left)
    r = s.find(right)
    if l != -1 and r != -1 and l < r:
        yes = True
        break
if yes or "keyence" in s:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
s = input()
x = "keyence"
yes = False
for i in range(8):
    left = x[: i]
    right = x[i : ]
    # print("left =", left)
    # print("right =", right)
    l = s.find(left)
    r = s.find(right)
    if l != -1 and r != -1 and l < r:
        yes = True
        break
if yes:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
key = 'keyence'
index_num = -1
for i in range(len(key)):
    if S[i] != key[i]:
        index_num = i
        break
else:
    print('YES')
    exit()

string = S[:index_num] + S[-index_num-1:]
if string == key:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    n = len(s)
    key = list("keyence")

    cnt = 0
    flg = True
    for i in range(n):
        if len(key) != 0 and s[i] == key[0]:
            key.pop(0)
            flg = True
        else:
            if flg:
                cnt += 1
                flg = False

    if cnt > 1 or len(key) != 0:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
S=input()
l=len(S)
a=0
for i in range(l):
  for j in range(i+1,l):
    if S[:i]+S[j:]=="keyence":
      a=1
print(["NO","YES"][a])

Submission status: Wrong Answer

Solution code:
s = input()
k = 'keyence'+s
i = c = 0
f = False
for x in s:
    if k[i]==x:
        i+=1
        if f:
            c+=1
            f = False
    else:
        f = True
if f:c+=1
print('YES' if i>6 and c<=1 else 'NO')

Submission status: Wrong Answer

Solution code:
s = input()
k = 'keyence'
i = c = 0
inds = []
ans = 'NO'
for a,x in enumerate(s):
    if i<7:
        if x==k[i]:
            i+=1
            inds.append(a)
        if i==7:
            for z in range(i-1):
                if inds[z+1]-inds[z]>1:
                    c+=1
            if c<=1:ans='YES'
    else:
        if c:ans='NO'
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
k = 'keyence'
i = 0
inds = []
ans = 'NO'
for a,x in enumerate(s):
    if x==k[i]:
        i+=1
        inds.append(a)
    if i==6:
        c = 0
        for z in range(i-1):
            if inds[z+1]-inds[z]>1:
                c+=1
        if c<=1:ans='YES'
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S=list(input())
l="keyence"
for i in range(len(S)):
    if S[i] in l:
        pass
    else:
        S[i]="*"

lst=[]
flag1=True
#print(S)
f=len(S)+2
for i in range(len(S)):
    if S[i]=="*":
        if flag1:
            f=i
            g=i
            flag1=False
        else:
            g=i

for i in range(len(S)):
    if f<=i and i<=g:
        continue
    lst.append(S[i])
flag=False
for i in range(len(lst)):
    if (i+6)>=len(lst):
        break
    tmp=""
    for j in range(7):
        tmp=tmp+lst[i+j]

    if tmp==l:
        print("YES")
        exit()
print("NO")

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)

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

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

print("NO")