Problem:
Score: 100 points

Problem Statement

E869120 has A 1-yen coins and infinitely many 500-yen coins.

Determine if he can pay exactly N yen using only these coins.

Constraints

N is an integer between 1 and 10000 (inclusive).

A is an integer between 0 and 1000 (inclusive).

Input

Input is given from Standard Input in the following format:

N
A

Output

If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.

Sample Input 1

2018
218

Sample Output 1

Yes

We can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.

Sample Input 2

2763
0

Sample Output 2

No

When we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.

Sample Input 3

37
514

Sample Output 3

Yes

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

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec_raw<>() -> Vec<String> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.to_string()).collect::<Vec<String>>().clone()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

/*fn get_score(r: usize,c:usize,n: usize,map: &Vec<Vec<usize>>) -> usize {
    let current = map[r][c].clone();
    match r {
        0 => if c < n - 1 { current + map[r + 1][c + 1] } else { current }
        1 => if c > 0 { current + map[r - 1][c - 1]} else {current}
        _ => panic!()
    }
}*/

fn get_result(return_point: usize,n: usize,map: &Vec<Vec<usize>>) -> usize{

    let mut r = 0;
    let mut c = 0;
    let mut flag = false;
    let mut result = map[r][c];

    for i in 0..n {
        if c == return_point && !flag {
            r = 1;
            flag = true;
            result += map[r][c]
        } else {
            c += 1;
            result += map[r][c]
        }
    }
    result
}

fn solve_a(){

    /*let mut str1 = read_vec_raw()[0].clone();
    let str2 = read_vec_raw()[0].clone();
    str1.push_str(&str2);*/

    let vec1 : Vec<Vec<usize>> = read_vec2(1);
    let n : usize = vec1[0][0].clone();
    let m : usize = vec1[0][1].clone();
    let mut vec2 : Vec<Vec<usize>> = read_vec2(m);
    vec2.sort();


    /*let mut graph = vec![vec![0;n];n];

    for v in vec2.iter() {
        let diff = v[1] - v[0];
        if diff == 1  {
            graph[v[0] - 1][v[1] - 1] = v[2];
            graph[v[1] - 1][v[0] - 1] = v[2];
        } else {

        }
    }*/

    println!("{:?}",vec2);

}

fn max(a: usize,b:usize) -> usize {
    if a > b {
        a
    } else {
        b
    }
}

fn min(a: usize,b:usize) -> usize {
    if a > b {
        b
    } else {
        a
    }
}

fn diff(a: usize,b: usize) -> usize {
    max(a,b) - min(a,b)
}

fn solve_c() {
    let grid: Vec<Vec<usize>> = read_vec2(3);
    let a1 = 0;
    let b1 = grid[0][0] - a1;
    let b2 = grid[0][1] - a1;
    let b3 = grid[0][2] - a1;
    let a2 = grid[1][0] - b1;
    let a3 = grid[2][0] - b1;
    
    let mut f = true;

    let v1 = vec![a1, a2, a3];
    let v2 = vec![b1, b2, b3];

    for i in 0..2 {
        for j in 0..2 {
            if !(v1[i] + v2[j] == grid[i][j]) {
                f = false;
                return;
            }
        }
    }

    if f {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main (){

    solve_c();
}