use std::io::{self, Read as _, Write as _}; struct Scanner<'a>(std::str::SplitWhitespace<'a>); impl<'a> Scanner<'a> { fn new(s: &'a str) -> Self { Self(s.split_whitespace()) } fn next(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, { let s = self.0.next().expect("found EOF"); match s.parse() { Ok(v) => v, Err(msg) => { println!( "parse error. T = {}, s = \"{}\": {:?}", std::any::type_name::(), s, msg ); panic!() } } } } fn main() { let mut stdin = String::new(); std::io::stdin().read_to_string(&mut stdin).unwrap(); let mut sc = Scanner::new(&stdin); let stdout = io::stdout(); let mut stdout = io::BufWriter::new(stdout.lock()); let n = sc.next(); let m = sc.next(); let a: Vec> = (0..n) .map(|_| (0..m).map(|_| sc.next()).collect()) .collect(); let coef: Vec = (0..m).map(|j| a.iter().map(|a| a[j]).sum()).collect(); let mut b: Vec = (0..n) .map(|i| { coef.iter() .zip(&a[i]) .map(|(&c, &a): (&i64, &i64)| c * a) .sum() }) .collect(); b.sort(); b.reverse(); let mut ans = 0; for i in 0..n { match i % 2 { 0 => ans += b[i], _ => ans -= b[i], } } writeln!(stdout, "{}", ans).unwrap(); stdout.flush().unwrap(); }