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 C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>

int main()
{   int i,j,flag[7]={0};
    char s[101];
    scanf("%s",s);
    int l=strlen(s);
    for(i=0;i<l-6;i++){
        if(s[i]=='k'&&s[i+1]=='e'&&s[i+2]=='y'&&s[i+3]=='e'&&s[i+4]=='n'&&s[i+5]=='c'){
            for(j=i+6;j<l;j++){
                if(s[j]=='e'){
                    printf("YES");
                    return 0;
                }
            }
        }else if(s[i]=='k'&&s[i+1]=='e'&&s[i+2]=='y'&&s[i+3]=='e'&&s[i+4]=='n'){
                for(j=i+5;j<l-1;j++){
                    if(s[j]=='c'&&s[j+1]=='e'){
                        printf("YES");
                        return 0;
                    }
                }
            }else if(s[i]=='k'&&s[i+1]=='e'&&s[i+2]=='y'&&s[i+3]=='e'){
                for(j=i+4;j<l-2;j++){
                    if(s[j]=='n'&&s[j+1]=='c'&&s[j+2]=='e'){
                        printf("YES");
                        return 0;
                    }
                }
            }else if(s[i]=='k'&&s[i+1]=='e'&&s[i+2]=='y'){
                for(j=i+3;j<l-3;j++){
                    if(s[j]=='e'&&s[j+1]=='n'&&s[j+2]=='c'&&s[j+3]=='e'){
                        printf("YES");
                        return 0;
                    }
                }
            }else if(s[i]=='k'&&s[i+1]=='e'){
                for(j=i+2;j<l-4;j++){
                    if(s[j]=='y'&&s[j+1]=='e'&&s[j+2]=='n'&&s[j+3]=='c'&&s[j+4]=='e'){
                        printf("YES");
                        return 0;
                    }
                }
            }else if(s[i]=='k'){
                for(j=i+1;j<l-5;j++){
                    if(s[j]=='e'&&s[j+1]=='y'&&s[j+2]=='e'&&s[j+3]=='n'&&s[j+4]=='c'&&s[j+5]=='e'){
                        printf("YES");
                        return 0;
                    }
                }
            }
        }

    printf("NO");

    return 0;
}