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: Runtime Error)

S=list(input())
if "k" and "e" and "y" and "e" and "n" and "c" and "e" in S:
    for i in range(len(S)):
        if S[i]=="k":
            if S[i+1]=="e":
                if S[i+2]=="y":
                    if S[i+3]=="e":
                        if S[i+4]=="n":
                            if S[i+5]=="c":
                                if S[i+6]=="e":
                                    print("YES")
                                    break
                                else:
                                    if S[-1]=="e":
                                        print("YES")
                                        break
                                    else:
                                        print("No")
                                        break
                            else:
                                if S[-1]=="e" and S[-2]=="c":
                                    print("YES")
                                    break
                                else:
                                    for j in range(len(S)-i-5):
                                        if S[i+5+j]=="c":
                                            if S[i+5+j+1]=="e":
                                                if i+5+j+2==len(S):
                                                    print("YES")
                                                    break
                                                else:
                                                    print("NO")
                                                    break
                                            else:
                                                print("NO")
                                                break
                        else:
                            if S[-1]=="e" and S[-2]=="c" and S[-3]=="n":
                                print("YES")
                                break
                            else:
                                for j in range(len(S)-i-4):
                                        if S[i+4+j]=="n":
                                            if S[i+4+j+1]=="c":
                                                if S[i+4+j+2]=="e":
                                                    if i+4+j+3==len(S):
                                                        print("YES")
                                                        break
                                                    else:
                                                        print("NO")
                                                        break
                                                else:
                                                    print("NO")
                                                    break
                                            else:
                                                print("NO")
                                                break
                    else:
                        if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e":
                            print("YES")
                            break
                        else:
                            for j in range(len(S)-i-3):
                                if S[i+3+j]=="e":
                                    if S[i+3+j+1]=="n":
                                        if S[i+3+j+2]=="c":
                                            if S[i+3+j+3]=="e":
                                                if i+3+j+4==len(S):
                                                    print("YES")
                                                    break
                                                else:
                                                    print("NO")
                                                    break
                                            else:
                                                print("NO")
                                                break
                                        else:
                                            print("NO")
                                            break
                                    else:
                                        print("NO")
                                        break
                else:
                    if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y":
                            print("YES")
                            break
                    else:
                        for j in range(len(S)-i-2):
                            if S[i+2+j]=="y":
                                if S[i+2+j+1]=="e":
                                    if S[i+2+j+2]=="n":
                                        if S[i+2+j+3]=="c":
                                            if S[i+2+j+4]=="e":
                                                if i+2+j+5==len(S):
                                                    print("YES")
                                                    break
                                                else:
                                                    print("NO")
                                                    break
                                            else:
                                                print("NO")
                                                break
                                        else:
                                            print("NO")
                                            break
                                    else:
                                        print("NO")
                                        break
                                else:
                                    print("NO")
                                    break
            else:
                if S[-1]=="e" and S[-2]=="c" and S[-3]=="n" and S[-4]=="e" and S[-5]=="y" and S[-6]=="e":
                    print("YES")
                    break
                else:
                    for j in range(len(S)-i-1):
                        if S[i+1+j]=="e":
                            if S[i+1+j+1]=="y":
                                if S[i+1+j+2]=="e":
                                    if S[i+1+j+3]=="n":
                                        if S[i+1+j+4]=="c":
                                            if S[i+1+j+5]=="e":
                                                if i+1+j+6==len(S):
                                                    print("YES")
                                                    break
                                                else:
                                                    print("NO")
                                                    break
                                            else:
                                                print("NO")
                                                break
                                        else:
                                            print("NO")
                                            break
                                    else:
                                        print("NO")
                                        break
                                else:
                                    print("NO")
                                    break
                            else:
                                print("NO")
                                break
else:
    print("NO")