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<stdio.h>
#include<string.h>

int main(){
    int i=0;
    int j=0;
    int a=0;
    int b=0;
    int c=0;
    int d=0;
    int e=0;
    int f=0;
    int g=0;
    int mojiretu=0;
    char array[101];
    char array2[101];
    int tori=0;
    char key[8];
    key[0]='k';
    key[1]='e';
    key[2]='y';
    key[3]='e';
    key[4]='n';
    key[5]='c';
    key[6]='e';
    key[7]='\0';
    //printf(key);
    scanf("%s",array);
    for(i=0; array[i]!='\0'; i++){
        mojiretu++;        
    }
    //printf("%d\n",tori);
    //printf(array);
    //printf(key);
    if(mojiretu==7){
        if(strcmp(array,key)==0){
            
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    else{

        //printf(array2);
        for(i=0; i<=6; i++){
            for(j=0;j<=mojiretu-1;j++){
                array2[j]=array[j];
            } 
            //printf("%d\n",i);
            //(i==0){
            //    for(j=7;j<=mojiretu-1;j++){
            //        array2[j] = 'a';
            //    }
            //}
            for(j=i;j<=mojiretu-8+i;j++){
                array2[j]='a';
            }
            //printf(array2);
            //printf("\n");
            for(j=0; j<=mojiretu-1;j++){
                //printf("%c",array2[j]);
                if(array2[j]=='k'){
                    a++;
                }
                if(array2[j]=='e' && a==1 && b==0){
                    b++;
                }
                if(array2[j]=='y'&&b==1&&c==0){
                    c++;
                }
                if(array2[j]=='e'&&c==1&&d==0){
                    d++;
                }
                if(array2[j]=='n'&&d==1&&e==0){
                    e++;
                }
                if(array2[j]=='c'&&e==1&&f==0){
                    f++;
                }
                if(array2[j]=='e'&&f==1&&g==0){
                    g++;
                }   
                
            }
        
        }
        if(g>0){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}