#include #include #include #include int main(){ unsigned long long N, M; std::cin >> N >> M; unsigned long long minimum = INT64_MAX; unsigned long long sum = 0; for(unsigned long long y = 0; y < N; y++){ for(unsigned long long x = 0; x < M; x++){ unsigned long long value; std::cin >> value; sum += value; if(y % 2 == 0){ if(x % 2 == 1){ minimum = std::min(minimum, value); //printf("%lld %lld\n", y, x); } } else{ if(x % 2 == 0){ minimum = std::min(minimum, value); //printf("%lld %lld\n", y, x); } } } } //std::cout << "sum: " << sum << std::endl; //std::cout << "minimum: " << minimum << std::endl; if(N % 2 == 1 || M % 2 == 1){ std::cout << sum; } else{ std::cout << sum - minimum; } return 0; }