#include // clang-format off using Int = long long; #define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++) #define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__) struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io; #ifndef dump #define dump(...) #endif // clang-format on /** * author: knshnb * created: Fri May 22 22:59:44 JST 2020 **/ template T make_vec(S x) { return x; } template auto make_vec(size_t n, Ts... ts) { return std::vector(ts...))>(n, make_vec(ts...)); } signed main() { Int n, m; std::cin >> n >> m; auto a = make_vec(n, m, 0); std::vector sum(m); REP(i, n) REP(j, m) std::cin >> a[i][j], sum[j] += a[i][j]; std::vector score(n); REP(i, n) REP(j, m) score[i] += a[i][j] * sum[j]; std::sort(score.rbegin(), score.rend()); Int ans = 0; REP(i, n) { ans += i % 2 ? -score[i] : score[i]; } std::cout << ans << std::endl; }