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 Rust (1.15.1) (judge verdict: Accepted)

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let c = sc.chars();
    let s: Vec<char> = "keyence".chars().collect();
    if c.len() < s.len() {
        println!("NO");
        return;
    }

    let n = c.len();
    let mut head = 0;
    for i in 0..n {
        if s[head] == c[i] {
            head += 1;
        } else {
            break;
        }
        if head == s.len() {
            break;
        }
    }

    let mut tail = 0;
    for i in (0..n).rev() {
        if s[s.len() - 1 - tail] == c[i] {
            tail += 1;
        } else {
            break;
        }
        if tail == s.len() {
            break;
        }
    }

    if head + tail >= s.len() {
        println!("YES");
    } else {
        println!("NO");
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}