#include #include #include struct FastScanner { static constexpr size_t BUF_SIZE = 1 << 20; char inbuf[BUF_SIZE]; size_t in_pos = 0; size_t in_len = 0; inline char get_char() { if (in_pos >= in_len) { in_pos = 0; in_len = fread(inbuf, 1, BUF_SIZE, stdin); } return inbuf[in_pos++]; } inline uint32_t read_uint() { uint32_t x = 0; char c = get_char(); while (c < '0' || c > '9') { c = get_char(); } while ('0' <= c && c <= '9') { x = x * 10 + static_cast(c - '0'); c = get_char(); } return x; } }; struct FastPrinter { static constexpr size_t BUF_SIZE = 1 << 20; 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) { if (out_pos + 16 >= BUF_SIZE) { flush(); } if (x == 0) { outbuf[out_pos++] = '0'; outbuf[out_pos++] = '\n'; return; } char temp[10]; int len = 0; while (x > 0) { uint32_t q = x / 10; temp[len++] = static_cast('0' + (x - q * 10)); x = q; } while (len > 0) { outbuf[out_pos++] = temp[--len]; } outbuf[out_pos++] = '\n'; } ~FastPrinter() { flush(); } }; int main() { static FastScanner scanner; static FastPrinter printer; uint32_t H = scanner.read_uint(); uint32_t W = scanner.read_uint(); std::vector S(H); 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) { row_sum += scanner.read_uint(); } S[i] = row_sum; T += row_sum; } for (uint32_t i = 0; i < H; ++i) { printer.write_uint(S[i] + T); } return 0; }