#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; void solve() { int N, M; cin >> N >> M; vll S(M); vector A(N, vll(M)); rep(i, N) { rep(j, M) { cin >> A[i][j]; S[j] += A[i][j]; } } vll T(N); rep(i, N) { rep(j, M) { T[i] += S[j] * A[i][j] * 2; } } sort(T.rbegin(), T.rend()); ll ans = 0; rep(i, N) { if (i % 2 == 0) { ans += T[i]; } } rep(i, M) { ans -= S[i] * S[i]; } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }