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

Solution in Python (3.4.3) (judge verdict: Wrong Answer)

#!/mnt/c/Users/moiki/bash/env/bin/python
s = input()

i_t = 0
text="keyence"
continue_ = False

l_i_occurance = []

for i_s,c in enumerate(s):
    if i_t == 7:
        continue_ = True
        break

    if c == text[i_t]:
        i_t += 1
        l_i_occurance.append(i_s)

# print("l_i_occurance: ", l_i_occurance)

if len(l_i_occurance) == len(text):
    diff = []
    for i_l in range(len(l_i_occurance)-1):
        diff.append(  l_i_occurance[i_l+1] - l_i_occurance[i_l] ) 
    # print("diff: ", diff)
    al_penalty = l_i_occurance[0] != 0

    if   len(set(diff)) == 1:
        if al_penalty and continue_:
            print("NO")
        else:
            print("YES")
    elif len(set(diff)) == 2:
        if continue_:
            print("NO")
        elif al_penalty:
            print("NO")
        else:
            print("YES")
    elif len(set(diff)) >= 3:
        print("NO")
    # if len(set(diff)) >= 3:
    #     print("NO")
    # else:
    #     print("YES")
    
else:
    print("NO")