#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using lint = long long int; long long int INF = 1001001001001001LL; int inf = 1000000007; long long int MOD = 1000000007LL; double PI = 3.1415926535897932; templateinline void chmin(T1 &a,const T2 &b){if(a>b) a=b;} templateinline void chmax(T1 &a,const T2 &b){if(a> n >> m; vector> a(n, vector(m)); vector s(m, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; s[j] += a[i][j]; } } vector score(n, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { score[i] += a[i][j] * s[j]; } } sort(RALL(score)); int ans = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0) ans += score[i]; else ans -= score[i]; } cout << ans << endl; return 0; }