#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #define _USE_MATH_DEFINES #include #include using namespace std; #include using namespace atcoder; #define REP(i,n) for(int i = 0; i < (int)n; i++) #define RREP(i,n) for(int i = (int)n-1; i >= 0; i--) #define LREP(i,n) for(LL i = 0; i < (LL)n; i++) #define Vi vector #define Vl vector #define LP pair #define P pair #define T3 tuple #define T4 tuple #define INF 1000000007 #define SIZE 310 #define MOD 1000000007 typedef long long LL; LL N, M; LL A[SIZE][SIZE]; LL C[SIZE]; int main() { cin >> N >> M; REP(i, N) REP(j, M) cin >> A[i][j]; REP(j, M) { LL c = 0; REP(i, N) { c += A[i][j]; } C[j] = c; } Vl X; REP(i, N) { LL cost = 0; REP(j, M) { cost += A[i][j] * C[j]; } X.push_back(cost); } sort(X.begin(), X.end(), greater()); LL ans = 0; REP(i, N) { if (i % 2 == 0) ans += X[i]; else ans -= X[i]; } cout << ans << endl; }