#include using namespace std; using lint = long long int; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i istream &operator>>(istream &is, vector &vec){ for (auto &v : vec) is >> v; return is; } #define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; int main() { int N, M; cin >> N >> M; vector>> A; REP(i, N) { vector v(M); cin >> v; A.emplace_back(-accumulate(v.begin(), v.end(), 0), v); } sort(A.begin(), A.end()); vector> d(2, vector(M)); bool b = false; for (auto x : A) { REP(i, M) d[b][i] += x.second[i]; b = !b; } lint ret = 0; REP(i, M) ret += d[0][i] * d[0][i] - d[1][i] * d[1][i]; cout << ret << '\n'; }