#include #include #include #include int main(){ int N, M; std::cin >> N >> M; int minimum = INT32_MAX; long long sum; std::cin >> sum; for(int i = 1; i < N * M - 1; i++){ int value; std::cin >> value; sum += value; if(i % 2 == 1){ minimum = std::min(minimum, value); } } int end; std::cin >> end; sum += end; //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; }