#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif void solve() { int N, M; cin >> N >> M; vector> A(N, vector(M)); vector sum(M); for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) { cin >> A[i][j]; sum[j] += A[i][j]; } vector value(N); for (int i = 0; i < N; i++) { long long res = 0; for (int j = 0; j < M; j++) { res += sum[j] * A[i][j]; } value[i] = res; } sort(value.rbegin(), value.rend()); long long X = 0, Y = 0; for (int i = 0; i < N; i++) { if(i % 2 == 1) Y += value[i]; else X += value[i]; } cout << X - Y << endl; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }