We need to determine if string S can be turned into "keyence" by removing one contiguous substring (possibly empty). So we need to check if S can be partitioned into prefix + middle + suffix, where removing the middle (contiguous substring) yields "keyence". That means there exist i <= j such that S[0:i] + S[j+1:] == "keyence". Equivalent to there exist indices such that the concatenation of two parts equals "keyence". Let T = "keyence" (length 7). We need to see if we can split T into two parts (prefix and suffix) such that S starts with that prefix and ends with that suffix, and the total length of S is at least 7, and the removed part is the middle part. That is: There exists k from 0 to 7 inclusive such that S begins with T[0:k] and ends with T[k:7] (i.e., the suffix part of T). And the lengths satisfy: len(prefix) + len(suffix) = 7, and S's length is arbitrary, but the middle removed part is S[k : len(S)- (7-k) ]? Actually if S starts with prefix and ends with suffix, then the removed middle is the part between them in S. That is, S = prefix + X + suffix, where X is any string (possibly empty). Then after removing X we get prefix + suffix = "keyence". So condition: There exists k (0 <= k <= 7) such that S[0:k] == T[0:k] and S[-(7-k):] == T[k:]. And we also need that the total length of S >= 7? Actually if S is length between 7 and 100, it's fine. But the condition automatically ensures that since we need to have at least prefix length k and suffix length 7-k, S must be at least 7. But S could be longer, which is allowed because the removed middle can be any non-empty or empty string. So we just check for any k.
Thus solution: For k from 0 to 7 inclusive, check if S starts with T[:k] and ends with T[k:]. If any true, print YES else NO.
Edge cases: k=0 means prefix empty, so suffix must be entire "keyence". So check if S ends with "keyence". k=7 means suffix empty, so S starts with "keyence". Also k in between.
We must be careful with slicing in Python: S[-len(suffix):] == suffix.
Implementation: read S, T = "keyence". For i in range(len(T)+1): if S.startswith(T[:i]) and S.endswith(T[i:]): print("YES") and exit. After loop print("NO").
Alternatively, we could brute force all possible removals: For each i, j, check if S[:i] + S[j:] == T. But O(N^2) is fine.
We'll implement simple loop.
We'll answer accordingly. ```python
import sys
def solve() -> None:
S = sys.stdin.readline().strip()
T = "keyence"
n = len(T)
for k in range(n + 1):
prefix = T[:k]
suffix = T[k:]
if S.startswith(prefix) and S.endswith(suffix):
print("YES")
return
print("NO")
if name == "main":
solve()