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 Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	
	 static Scanner in = new Scanner(System.in);
	 
   
	public static void main(String args[])throws IOException  {
   
    	
        String s=in.nextLine(); 
        int len1=s.length();
        String s1=s;
        String str="keyence";
        int len=str.length();
        int pos=s.indexOf(str);
        if(pos!=-1&&(pos==0||pos==len1-len))
        {
    		System.out.println("YES");
    		return ;
    	}
        int t=len1-len;
        for(int i=1;i<len1-t;i++)
        {
        	s=s.substring(0,i)+s.substring(i+t,len1);
        	if(s.equals(str))
        	{
        		System.out.println("YES");
        		return ;
        	}
        	s=s1;
        }
    		System.out.println("NO");	
     	
    }

	
	
 
	
}