Problem:
Score: 300 points

Problem Statement

We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.

According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.

Determine if he is correct.

Constraints

c_{i, j} \ (1 \leq i \leq 3, 1 \leq j \leq 3) is an integer between 0 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3}

Output

If Takahashi's statement is correct, print Yes; otherwise, print No.

Sample Input 1

1 0 1
2 1 2
1 0 1

Sample Output 1

Yes

Takahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.

Sample Input 2

2 2 2
2 1 2
2 2 2

Sample Output 2

No

Takahashi is incorrect in this case.

Sample Input 3

0 8 8
0 8 8
0 8 8

Sample Output 3

Yes

Sample Input 4

1 8 6
2 9 7
0 7 7

Sample Output 4

No

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_macros)]
macro_rules! dump (
    ($($arg:tt)*) => { {
        if cfg!(local) {
            let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
            r.expect("failed printing to stderr");
        }
    } }
);

#[allow(dead_code)]
struct Chrono {
    st: std::time::SystemTime,
}

#[allow(dead_code)]
impl Chrono {
    fn new() -> Chrono {
        Chrono { st: std::time::SystemTime::now() }
    }

    fn elapsed_ms(&self) -> i64 {
        let elapsed = self.st.elapsed().unwrap();
        elapsed.as_secs() as i64 * 1000 + elapsed.subsec_nanos() as i64 / 1_000_000
    }

    fn reset(&mut self) {
        self.st = std::time::SystemTime::now();
    }
}

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    pub fn line(&mut self) -> String {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|&c| c == '\n' || c == '\r')
            .take_while(|&c| !(c == '\n' || c == '\r'))
            .collect::<String>();
        self.buffer.clone()
    }

    pub fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    pub fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    pub fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            if cfg!(local) {
                writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            }
            std::process::exit(0);
        }
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let c: Vec<Vec<i32>> = sc.mat(3, 3);
        let mut ok = true;
        for i in 0..2 {
            ok &= c[i][1] - c[i][0] == c[i+1][1] - c[i+1][0];
            ok &= c[i][2] - c[i][1] == c[i+1][2] - c[i+1][1];
            ok &= c[1][i] - c[0][i] == c[1][i+1] - c[0][i+1];
            ok &= c[2][i] - c[1][i] == c[2][i+1] - c[1][i+1];
        }
        let ans = if ok {
            "Yes"
        } else {
            "No"
        };
        println!("{}", ans);
    }
}