/* -*- coding: utf-8 -*- * * 3677.cc: No.3677 Global Checksum - yukicoder */ #include using namespace std; /* constant */ const int MAX_H = 1000000; const int MAX_HW = 4000000; const int BUFSIZE = MAX_HW * 11 + 30; /* typedef */ using ui = unsigned int; /* global variables */ ui ss[MAX_H]; char buf[BUFSIZE]; /* subroutines */ ui readint(size_t &k, size_t sz) { while (k < sz && buf[k] <= ' ') k++; ui num = 0; while (k < sz && buf[k] > ' ') num = num * 10 + (buf[k++] - '0'); return num; } void writechar(size_t &k, char c) { buf[k++] = c; } void writeint(size_t & k, ui a) { ui ds[20], l = 0; while (a > 0) ds[l++] = a % 10, a /= 10; if (l == 0) ds[l++] = 0; for (int i = l - 1; i >= 0; i--) writechar(k, '0' + ds[i]); } /* main */ int main() { auto sz = fread(buf, 1, BUFSIZE, stdin); size_t k = 0; ui h = readint(k, sz); ui w = readint(k, sz); ui t = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { ui aij = readint(k, sz); ss[i] += aij; } t += ss[i]; } k = 0; for (int i = 0; i < h; i++) { writeint(k, ss[i] + t); writechar(k, '\n'); } fwrite(buf, 1, k, stdout); return 0; }