Problem:
Score : 100 points

Problem Statement

A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal.

Given a string S, determine whether it is coffee-like.

Constraints

S is a string of length 6 consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S is coffee-like, print Yes; otherwise, print No.

Sample Input 1

sippuu

Sample Output 1

Yes

In sippuu, the 3-rd and 4-th characters are equal, and the 5-th and 6-th characters are also equal.

Sample Input 2

iphone

Sample Output 2

No

Sample Input 3

coffee

Sample Output 3

Yes

Solution in Rust (1.15.1) (judge verdict: Runtime Error)

use std::io::Read;
use std::collections::HashMap;

const MOD: usize = 1000000007;


fn mod_pow(v: usize, k: usize) -> usize {
    if k == 0 {
        return 1;
    }
    let mut ret = mod_pow(v * v % MOD, k / 2);
    if k % 2 == 1 {
        ret = ret * v % MOD;
    }
    return ret;
}

fn solve(mut memo: &mut HashMap<(usize, usize), (usize, usize)>, g: &Vec<Vec<usize>>, fac: &Vec<usize>, cur: usize, parent: usize) -> (usize, usize) {
    {
        let ans = memo.get(&(cur, parent));
        if ans.is_some() {
            return *ans.unwrap();
        }
    }
    let mut count = 1;
    let mut ans = 1;
    let mut div = 1;
    for &next in &g[cur] {
        if next == parent {
            continue;
        }
        let (child_count, child_ans) = solve(&mut memo, g, fac, next, cur);
        count += child_count;
        ans = ans * child_ans % MOD;
        div = div * mod_pow(fac[child_count], MOD - 2) % MOD;
    }
    ans = ans * div % MOD;
    ans = ans * fac[count - 1] % MOD;
    memo.insert((cur, parent), (count, ans));
    return (count, ans);
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_to_string(&mut line);
    let input: Vec<usize> = line.split_whitespace().map(|a| a.parse().unwrap()).collect();
    let n = input[0];
    let mut g: Vec<Vec<usize>> = Vec::new();
    let mut fac: Vec<usize> = vec![0; n + 1];
    fac[0] = 1;
    for i in 1 .. fac.len() {
        fac[i] = fac[i - 1] * i % MOD;
    }
    g.resize(n, Vec::new());
    for i in 0..n - 1 {
        let (a, b) = (input[i * 2 + 1] - 1, input[i * 2 + 2] - 1);
        g[a].push(b);
        g[b].push(a);
    }


    let mut memo: HashMap<(usize, usize), (usize, usize)> = HashMap::new();

    for i in 0..n {
        let (_, ans ) = solve( &mut memo, &g, &fac, i, n);
        println!("{}", ans);
    }
}