#include #include #include #include struct FastScanner { static constexpr size_t BUF_SIZE = 1 << 20; // 1MB char inbuf[BUF_SIZE]; size_t in_pos = 0; size_t in_len = 0; inline bool skip_whitespace() { while (true) { if (in_pos >= in_len) { in_pos = 0; in_len = fread(inbuf, 1, BUF_SIZE, stdin); if (in_len == 0) return false; } while (in_pos < in_len && static_cast(inbuf[in_pos]) <= ' ') { in_pos++; } if (in_pos < in_len) return true; } } inline bool read_uint(uint32_t& x) { if (!skip_whitespace()) return false; x = 0; while (true) { while (in_pos < in_len) { char c = inbuf[in_pos]; if (c < '0' || c > '9') { return true; } x = x * 10 + static_cast(c - '0'); in_pos++; } in_pos = 0; in_len = fread(inbuf, 1, BUF_SIZE, stdin); if (in_len == 0) break; } return true; } }; struct FastPrinter { static constexpr size_t BUF_SIZE = 1 << 20; // 1MB char outbuf[BUF_SIZE]; size_t out_pos = 0; inline void flush() { if (out_pos > 0) { fwrite(outbuf, 1, out_pos, stdout); out_pos = 0; } } inline void write_uint(uint32_t x) { // 数値1つ + 改行を出力するのに十分な空きがない場合はフラッシュ if (out_pos + 16 >= BUF_SIZE) { flush(); } if (x == 0) { outbuf[out_pos++] = '0'; outbuf[out_pos++] = '\n'; return; } char temp[12]; int len = 0; while (x > 0) { temp[len++] = static_cast('0' + (x % 10)); x /= 10; } while (len > 0) { outbuf[out_pos++] = temp[--len]; } outbuf[out_pos++] = '\n'; } ~FastPrinter() { flush(); } }; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); static FastScanner scanner; static FastPrinter printer; uint32_t H, W; if (!scanner.read_uint(H) || !scanner.read_uint(W)) return 0; std::vector S(H, 0); uint32_t T = 0; for (uint32_t i = 0; i < H; ++i) { uint32_t row_sum = 0; for (uint32_t j = 0; j < W; ++j) { uint32_t val; scanner.read_uint(val); row_sum += val; // 自動的に mod 2^32 } S[i] = row_sum; T += row_sum; // 自動的に mod 2^32 } for (uint32_t i = 0; i < H; ++i) { printer.write_uint(S[i] + T); // 自動的に mod 2^32 } return 0; }