#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M));
    vector<int64_t> S(M);
    for(int i=0; i<N; i++) for(int j=0; j<M; j++){
        cin >> A[i][j];
        S[j] += A[i][j];
    }
    vector<int64_t> V(N);
    for(int i=0; i<N; i++) for(int j=0; j<M; j++) V[i] += 2*A[i][j]*S[j];
    sort(V.rbegin(), V.rend());
    int64_t ans = 0;
    for(int i=0; i<N; i+=2) ans += V[i];
    for(auto s : S) ans -= s*s;
    cout << ans << endl;
    return 0;
}