Problem:
Score : 100 points

Problem Statement

AtCoDeer has three cards, one red, one green and one blue.

An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.

We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.

Is this integer a multiple of 4?

Constraints

1 ≤ r, g, b ≤ 9

Input

Input is given from Standard Input in the following format:

r g b

Output

If the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.

Sample Input 1

4 3 2

Sample Output 1

YES

432 is a multiple of 4, and thus YES should be printed.

Sample Input 2

2 3 4

Sample Output 2

NO

234 is not a multiple of 4, and thus NO should be printed.

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

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
struct XorShift {
    x: u32,
    y: u32,
    z: u32,
    w: u32,
}
#[allow(dead_code)]
impl XorShift {
    fn new() -> XorShift {
        XorShift {
            x: 0x34fb2383,
            y: 0x327328fa,
            z: 0xabd4b54a,
            w: 0xa9dba8d1,
        }
    }
    fn seed(s: u32) -> XorShift {
        let mut rnd = XorShift::new();
        rnd.w = s;
        rnd
    }
    fn xor128(&mut self) -> u32 {
        let t = self.x ^ (self.x << 11);
        self.x = self.y;
        self.y = self.z;
        self.z = self.w;
        self.w = (self.w ^ (self.w >> 19)) ^ (t ^ (t >> 8));
        self.w
    }
    fn next_i32(&mut self, r: i32) -> i32 {
        (self.xor128() % r as u32) as i32
    }
    fn next_i32_lr(&mut self, l: i32, r: i32) -> i32 {
        self.next_i32(r - l + 1) + l
    }
    fn next_i64(&mut self, r: i64) -> i64 {
        ((((self.xor128() as u64) << 32) + self.xor128() as u64) % r as u64) as i64
    }
    fn next_i64_lr(&mut self, l: i64, r: i64) -> i64 {
        self.next_i64(r - l + 1) + l
    }
    fn next_f64(&mut self, r: f64) -> f64 {
        (self.xor128() as f64) / (0xffffffffu32 as f64) * r
    }
    fn next_f64_lr(&mut self, l: f64, r: f64) -> f64 {
        self.next_f64(r - l) + l
    }
}

// need XorShift
type Node = i64;
#[derive(Clone)]
#[allow(dead_code)]
struct RbstNode {
    v: Node,
    size: usize,
    l: Option<usize>,
    r: Option<usize>,
}
#[allow(dead_code)]
impl RbstNode {
    fn new(v: Node) -> RbstNode {
        RbstNode {
            v: v,
            size: 1,
            l: None,
            r: None,
        }
    }
}

#[allow(dead_code)]
struct Rbst {
    pool: Vec<RbstNode>,
    rnd: XorShift,
}
#[allow(dead_code)]
impl Rbst {
    fn new() -> Rbst {
        Rbst {
            pool: vec![],
            rnd: XorShift::new(),
        }
    }
    fn insert(&mut self, root: Option<usize>, k: usize, v: Node) -> Option<usize> {
        let s = self.split(root, k);
        let t = Some(self.pool.len());
        self.pool.push(RbstNode::new(v));
        let r = self.merge(t, s.1);
        return self.merge(s.0, r);
    }
    fn erase(&mut self, root: Option<usize>, k: usize) -> Option<usize> {
        let s1 = self.split(root, k + 1);
        let s2 = self.split(s1.0, k);
        return self.merge(s2.0, s1.1);
    }
    fn get_at(&self, root: Option<usize>, index: usize) -> Node {
        let t = self.at(root, index);
        self.pool[t.unwrap()].v
    }
    fn set_at(&mut self, root: Option<usize>, index: usize, v: Node) {
        let t = self.at(root, index);
        self.pool[t.unwrap()].v = v;
    }
    // private
    fn merge(&mut self, l: Option<usize>, r: Option<usize>) -> Option<usize> {
        if l.is_none() {
            return r;
        }
        if r.is_none() {
            return l;
        }
        if self.rnd.xor128() as usize % (self.count(l) + self.count(r)) < self.count(l) {
            let child_r = self.pool[l.unwrap()].r;
            self.pool[l.unwrap()].r = self.merge(child_r, r);
            self.update_count(l.unwrap());
            return l;
        } else {
            let child_l = self.pool[r.unwrap()].l;
            self.pool[r.unwrap()].l = self.merge(l, child_l);
            self.update_count(r.unwrap());
            return r;
        }
    }
    // [0, k), [k, n)
    fn split(&mut self, t: Option<usize>, k: usize) -> (Option<usize>, Option<usize>) {
        if t.is_none() {
            return (None, None);
        }
        let t = t.unwrap();
        if k <= self.count(self.pool[t].l) {
            let l = self.pool[t].l;
            let s = self.split(l, k);
            self.pool[t].l = s.1;
            self.update_count(t);
            return (s.0, Some(t));
        } else {
            let l = self.pool[t].l;
            let r = self.pool[t].r;
            let cnt = k - self.count(l) - 1;
            let s = self.split(r, cnt);
            self.pool[t].r = s.0;
            self.update_count(t);
            return (Some(t), s.1);
        }
    }
    fn at(&self, root: Option<usize>, index: usize) -> Option<usize> {
        assert!(root != None);
        let mut index = index;
        let t = root.unwrap();
        let l = self.pool[t].l;
        let r = self.pool[t].r;
        if index < self.count(l) {
            return self.at(l, index);
        } else {
            index -= self.count(l);
        }
        if index == 0 {
            return Some(t);
        }
        index -= 1;
        return self.at(r, index);
    }
    fn count(&self, t: Option<usize>) -> usize {
        if let Some(t) = t {
            self.pool[t].size
        } else {
            0
        }
    }
    fn update_count(&mut self, t: usize) {
        self.pool[t].size = 1 + self.count(self.pool[t].l) + self.count(self.pool[t].r);
    }
}

#[test]
fn rbst_test() {
    let mut rbst = Rbst::new();
    let mut root = None;

    root = rbst.insert(root, 0, 10);
    root = rbst.insert(root, 1, 30);
    assert!(rbst.get_at(root, 0) == 10);
    assert!(rbst.get_at(root, 1) == 30);

    root = rbst.erase(root, 0);
    assert!(rbst.get_at(root, 0) == 30);

    rbst.set_at(root, 0, 123);
    assert!(rbst.get_at(root, 0) == 123);

    root = rbst.insert(root, 0, 222);
    assert!(rbst.get_at(root, 0) == 222);
    assert!(rbst.get_at(root, 1) == 123);
}

#[test]
fn rbst_test2() {
    let mut rbst = Rbst::new();
    let mut root = None;
    for i in 0..1000 {
        root = rbst.insert(root, i, i as i64);
    }
    for i in 0..1000 {
        assert!(rbst.get_at(root, i) == i as i64);
    }
    for i in 0..1000 {
        root = rbst.insert(root, 0, i as i64);
    }
    for i in 0..1000 {
        assert!(rbst.get_at(root, i) == 999 - i as i64);
    }
    for i in 0..1000 {
        root = rbst.erase(root, i);
    }
    for i in 0..500 {
        assert!(rbst.get_at(root, i) == 998 - i as i64 * 2);
    }
    for i in 0..500 {
        assert!(rbst.get_at(root, 500 + i) == 1 + i as i64 * 2);
    }
}

fn main() {
    let n = read::<usize>();
    let k = read::<i64>();
    let mut aseq = vec![0; n];
    for i in 0..n {
        aseq[i] = read::<i64>();
    }
}