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

#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int len = s.size();
    
    int remove = 0;
    int keyence = 0;
    bool flg = false;
    //cout << s[0] << endl;
    rep(i, len){
        
        if(remove > 1){
            cout << "NO" << endl;
            return 0;
        }
        
        if(keyence == 0){
            if(s[i] == 'k'){
                keyence++;
                flg = false;
            }else{
                if(!flg){
                    remove++;
                    flg = true;
                }
            }
        }else if(keyence == 1){
            if(s[i] == 'e'){
                keyence++;
                flg = false;
            }else{
                if(!flg){
                    remove++;
                    flg = true;
                }
            }
        }else if(keyence == 2){
            if(s[i] == 'y'){
                keyence++;
                flg = false;
            }else{
                if(!flg){
                    remove++;
                    flg = true;
                }
            }
        }else if(keyence == 3){
            if(s[i] =='e'){
                keyence++;
                flg = false;
            }else{
                if(!flg){
                    remove++;
                    flg = true;
                }
            }
        }else if(keyence == 4){
            if(s[i] =='n'){
                keyence++;
                flg = false;
            }else{
                if(!flg){
                    remove++;
                    flg = true;
                }
            }
        }else if(keyence == 5){
            if(s[i] =='c'){
                keyence++;
                flg = false;
            }else{
                if(!flg){
                    remove++;
                    flg = true;
                }
            }
        }else if(keyence == 6){
            if(s[i] =='e'){
                keyence++;
                flg = false;
            }else{
                if(!flg){
                    remove++;
                    flg = true;
                }
            }
        }else if(keyence == 7){
            remove++;
            break;
        }
        
        //cout << i << " keyence " << keyence << "remove " << remove << endl;
    }
    if(keyence == 7 && remove <= 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}