import sys readline = sys.stdin.readline N, M = map(int, readline().split()) csum = [0]*M Tr = [list(map(int, readline().split())) for _ in range(N)] for i in range(N): for j in range(M): csum[j] += Tr[i][j] res = sum(-c**2 for c in csum) points = [0]*N for i in range(N): cnt = 0 for j in range(M): cnt += 2*csum[j]*Tr[i][j] points[i] = cnt points.sort(reverse = True) for i in range(0, N, 2): res += points[i] print(res)