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: Accepted)

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

void inverse(char *a,char *b){
	int i;
	
	for(i=0;i<strlen(a);i++){
		b[i]=a[strlen(a)-i-1];
	}
}

int main(){
	char S[100];
	char Sinv[100];
	char keyence[7]="keyence";
	char keyenceinv[7]="ecneyek";
	int i,f;
	int patn=0;
	int n=0;
	
	gets(S);
	
	patn=strcspn(S,"k");
	
	if(patn==strlen(S)){
		printf("NO");
	}else if(1<=patn){
		if(strstr(S,keyence)!=NULL){
			printf("YES");
		}else{
			printf("NO");
		}
	}else{
		if(strstr(S,keyence)!=NULL){
			printf("YES");
		}else{
			inverse(S,Sinv);
			i=0;
			while(S[i]==keyence[i]){
				i++;
			}
			
			f=0;
			while(Sinv[f]==keyenceinv[f] && f<7-i){
				f++;
			}
			
			if(i+f==7)	printf("YES");
			else	printf("NO");
		}
	}
	
	return 0;
}