malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, k, mod = 1000000007, dp[2010][2010];   long long solve(long long num, long long x) {     long long i;     if (x == k) return 1;     if (dp[num][x] != -1) return dp[num][x];     long long res = 0;     for (i = 1; (i * num) <= n; i++) {       res += solve(num * i, x + 1) % mod;     }     return dp[num][x] = (res % mod);   }   int main() {     cin >> n >> k;     memset(dp, -1, sizeof dp);     cout << solve(1, 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, k, h = 0;     cin >> n >> k;     vector<int> v;     for (int i = 0; i < n; i++) v.push_back(i);     for (int ki = 1; ki <= k; ki++) {       int x;       cin >> x;       x = x - (x / (n)) * (n);       int d = (h + x) % n;       h = d;       if (d == n - 1) h = 0;       n--;       cout << v[d] + 1 <<    ;       vector<int> tmp;       for (int i = 0; i < v.size(); i++)         if (i != d) tmp.push_back(v[i]);       v = tmp;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, m, k, s = 0, sx, sy, num;   char grid[600][600];   bool vis[600][600];   long long int dx[4] = {0, 0, -1, 1};   long long int dy[4] = {-1, 1, 0, 0};   bool check(long long int x, long long int y) {     if (x >= 0 && x < n && y >= 0 && y < m && grid[x][y] ==  .  && !vis[x][y])       return 1;     return 0;   }   void dfs(long long int x, long long int y) {     vis[x][y] = 1;     grid[x][y] =  M ;     if (num >= s - k) return;     for (long long int i = 0; i < 4; i++) {       long long int nx = x + dx[i];       long long int ny = y + dy[i];       if (num >= s - k) {         break;       }       if (check(nx, ny)) {         num++;         dfs(nx, ny);       }     }   }   int main() {     cin >> n >> m >> k;     memset(vis, 0, sizeof vis);     for (long long int i = 0; i < n; i++) {       for (long long int j = 0; j < m; j++) {         cin >> grid[i][j];         if (grid[i][j] ==  . ) {           s++;           sx = i;           sy = j;         }       }     }     num = 1;     dfs(sx, sy);     for (long long int i = 0; i < n; i++) {       for (long long int j = 0; j < m; j++) {         if (grid[i][j] ==  . ) grid[i][j] =  X ;         if (grid[i][j] ==  M ) grid[i][j] =  . ;         cout << grid[i][j];       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505;   unordered_set<int> dp[N];   int main() {     int n, k;     scanf( %d%d , &n, &k);     dp[0].insert(0);     for (int i = 0; i < n; ++i) {       int c;       scanf( %d , &c);       for (int j = k; j >= c; --j) {         for (int l : dp[j - c]) dp[j].insert(l);         for (int l : dp[j - c]) dp[j].insert(l + c);         if (dp[j].size() > 0) dp[j].insert(j);       }     }     printf( %d n , dp[k].size());     vector<int> res;     for (int l : dp[k]) res.push_back(l);     sort(res.begin(), res.end());     for (int l : res) printf( %d  , l);   }
#include <bits/stdc++.h>   using namespace std;   const long double eps = 1e-10;   struct Tpoint {     long double x, y;     void input() {       double _x, _y;       scanf( %lf%lf , &_x, &_y);       x = _x;       y = _y;     }   } C, H, S;   double t1, t2;   long double T1, T2;   long double ret;   long double Fabs(long double x) { return x < 0 ? -x : x; }   long double Fmin(long double x, long double y) { return x < y ? x : y; }   long double Fmax(long double x, long double y) { return x > y ? x : y; }   long double dist2(Tpoint a, Tpoint b) {     return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);   }   long double dist(Tpoint a, Tpoint b) { return sqrt(Fabs(dist2(a, b))); }   void init() {     scanf( %lf%lf , &t1, &t2);     C.input();     H.input();     S.input();   }   bool Inside(Tpoint A, long double r, Tpoint p) {     return dist2(A, p) < r * r + eps;   }   bool inter(Tpoint A, Tpoint B, long double ra, long double rb) {     return dist(A, B) < ra + rb + eps;   }   void Normalize(long double &x) {     if (x > 1.0) x = 1.0;     if (x < -1.0) x = -1.0;   }   bool inter(Tpoint A, Tpoint B, Tpoint C, long double ra, long double rb,              long double rc) {     if (dist(A, B) < Fabs(ra - rb) + eps) return 1;     long double alpha = atan2(B.y - A.y, B.x - A.x);     long double dis2 = dist2(A, B);     long double cosine =         (ra * ra + dis2 - rb * rb) / (2.0 * ra * sqrt(Fabs(dis2)));     Normalize(cosine);     long double beta = acos(cosine);     Tpoint p;     p.x = A.x + ra * cos(alpha + beta);     p.y = A.y + ra * sin(alpha + beta);     if (Inside(C, rc, p)) return 1;     p.x = A.x + ra * cos(alpha - beta);     p.y = A.y + ra * sin(alpha - beta);     if (Inside(C, rc, p)) return 1;     return 0;   }   bool check(long double cur) {     long double rc = cur, rh = Fmax(0, T2 - cur),                 rs = Fmax(0, T1 - cur - dist(S, H));     if (!inter(C, H, rc, rh) || !inter(C, S, rc, rs) || !inter(H, S, rh, rs))       return 0;     if (inter(C, H, S, rc, rh, rs)) return 1;     if (inter(C, S, H, rc, rs, rh)) return 1;     if (inter(H, S, C, rh, rs, rc)) return 1;     return 0;   }   long double solve() {     T1 = dist(C, S) + dist(S, H) + t1;     T2 = dist(C, H) + t2;     if (T1 - t1 < T2 + eps) return Fmin(T1, T2);     long double L = 0, r = Fmin(T1, T2);     for (int it = 0; it < 100; it++) {       long double mid = (L + r) / 2;       if (check(mid))         L = mid;       else         r = mid;     }     return L;   }   void print() { printf( %.10lf n , (double)solve()); }   int main() {     init();     print();     return 0;   }
#include <bits/stdc++.h>   using ul = std::uint32_t;   using ull = std::uint64_t;   using li = std::int32_t;   using ll = std::int64_t;   using vull = std::vector<ull>;   using vul = std::vector<ul>;   const ul sz = 1 << 18;   const ul base = 1e9 + 7;   class scaler {    public:     ul v = 0;     scaler() = default;     scaler(ul x) : v(x) {}   };   scaler operator+(scaler a, scaler b) {     return scaler(a.v + b.v < base ? a.v + b.v : a.v + b.v - base);   }   scaler operator-(scaler a, scaler b) {     return scaler(a.v < b.v ? a.v + base - b.v : a.v - b.v);   }   scaler operator*(scaler a, scaler b) { return scaler(ull(a.v) * b.v % base); }   template <typename T>   void change(ul pos, const T& v, std::vector<T>& tree) {     for (tree[pos |= sz] = v, pos >>= 1; pos; pos >>= 1) {       tree[pos] = tree[pos << 1] + tree[pos << 1 | 1];     }   }   template <typename T>   T query(ul l, ul r, const std::vector<T>& tree) {     T ret = 0;     for (l = l - 1 | sz, r = r + 1 | sz; l ^ r ^ 1; l >>= 1, r >>= 1) {       if (~l & 1) {         ret = ret + tree[l ^ 1];       }       if (r & 1) {         ret = ret + tree[r ^ 1];       }     }     return ret;   }   std::vector<scaler> atree(sz << 1, ul(0));   vull tree(sz << 1, ul(0));   ul n, q;   vul a(2e5 + 1);   scaler compute(ul l, ul r, ul cut) {     return scaler(query(l, cut - 1, tree) % base) * scaler(a[cut]) -            query(l, cut - 1, atree) + query(cut + 1, r, atree) -            scaler(query(cut + 1, r, tree) % base) * scaler(a[cut]);   }   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     std::cin >> n >> q;     for (ul i = 1; i <= n; ++i) {       std::cin >> a[i];       a[i] -= i;     }     for (ul i = 1; i <= n; ++i) {       ul w;       std::cin >> w;       change(i, ull(w), tree);       change(i, scaler(a[i]) * scaler(w), atree);     }     for (ul i = 0; i != q; ++i) {       li x, y;       std::cin >> x >> y;       if (x < 0) {         ul id = -x;         ul w = y;         change(id, ull(w), tree);         change(id, scaler(a[id]) * scaler(w), atree);       } else {         ul l = x, r = y;         ull temp = query(l, r, tree);         ul lans = l, rans = r + 1;         while (lans + 1 != rans) {           ul mid = lans + rans >> 1;           if ((query(mid, r, tree) << 1) < temp) {             rans = mid;           } else {             lans = mid;           }         }         std::cout << compute(l, r, lans).v << std::endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int x, int y) {     while (x > 0 && y > 0) {       if (x > y) {         x %= y;       } else {         y %= x;       }     }     return x + y;   }   int main() {     int n, k;     cin >> n >> k;     vector<int> a(n + 1);     vector<bool> used(n + 1);     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     int q;     cin >> q;     int tasks = n / k;     int best = -1, worse = 1 << 30;     int ticketsLeft = k;     for (int i = 1; i <= q; i++) {       int curSum = 0;       for (int j = 1; j <= tasks; j++) {         int num;         cin >> num;         if (!used[num] && j == 1) {           ticketsLeft--;         }         used[num] = true;         curSum += a[num];       }       best = max(best, curSum);       worse = min(worse, curSum);     }     vector<int> unUsed;     for (int i = 1; i <= n; i++) {       if (!used[i]) {         unUsed.push_back(a[i]);       }     }     if (unUsed.size() >= tasks && ticketsLeft > 0) {       sort(unUsed.begin(), unUsed.end());       int curSum = 0;       for (int i = 0; i < tasks; i++) {         curSum += unUsed[i];       }       best = max(best, curSum);       worse = min(worse, curSum);       reverse(unUsed.begin(), unUsed.end());       curSum = 0;       for (int i = 0; i < tasks; i++) {         curSum += unUsed[i];       }       best = max(best, curSum);       worse = min(worse, curSum);     }     printf( %.15lf %.15lf n , double(worse) / double(tasks),            double(best) / double(tasks));   }
#include <bits/stdc++.h>   using namespace std;   long long dp[205][6003], dp1[205][6003];   int main() {     long long n, k;     cin >> n >> k;     long long tmp;     for (int i = 0; i <= k; i++) {       for (int j = 0; j <= 6000; j++) {         dp1[i][j] = -2e9;       }     }     dp1[0][0] = 0;     for (int i = 0; i < n; i++) {       cin >> tmp;       int cnt2 = 0, cnt5 = 0;       while (tmp % 2 == 0) {         tmp /= 2;         cnt2++;       }       while (tmp % 5 == 0) {         tmp /= 5;         cnt5++;       }       for (int l = 0; l <= k; l++) {         for (int j = 0; j <= 6000; j++) {           dp[l][j] = dp1[l][j];           if (j - cnt5 >= 0 && l > 0)             dp[l][j] = max(dp1[l - 1][j - cnt5] + cnt2, dp1[l][j]);         }       }       for (int l = 0; l <= k; l++) {         for (int j = 0; j <= 6000; j++) {           dp1[l][j] = dp[l][j];         }       }     }     long long max1 = 0;     for (long long j = 0; j <= 6000; j++) {       max1 = max(min(dp[k][j], j), max1);     }     cout << max1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e3 + 10;   char s[N], t[N];   int n;   vector<int> G;   void shift(int x) {     if (x == 0) return;     reverse(s, s + n);     reverse(s + x, s + n);     G.push_back(x);   }   int main() {     scanf( %d%s%s , &n, s, t);     for (int i = 0; i < n; i++) {       int j = i;       while (j < n && s[j] != t[n - i - 1]) j++;       if (j == n) {         puts( -1 );         exit(0);       }       shift(n);       shift(j);       shift(1);     }     printf( %d n , G.size());     for (int i = 0; i < (int)G.size(); ++i) printf( %d  , G[i]);   }
#include <bits/stdc++.h>   using namespace std;   long long n, l;   string s, s1, s2;   int main() {     cin >> n;     getline(cin, s);     while (n--) {       getline(cin, s);       s1 =   ;       s2 =   ;       l = s.length();       for (int i = 0; i <= 4; i++) s1 += s[i];       for (int i = l - 5; i < l; i++) s2 += s[i];       if (s1 ==  miao.  && s2 !=  lala. )         cout <<  Rainbow s  << endl;       else if (s1 !=  miao.  && s2 ==  lala. )         cout <<  Freda s  << endl;       else         cout <<  OMG>.< I don t know!  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, nmax, nrpar, nrimpar, par, impar, i, sol;   int luat[200005];   struct el {     int val, poz;   } a[200005];   bool rearanjare(el x, el y) {     if (x.poz < y.poz)       return 1;     else       return 0;   }   bool comp(el x, el y) {     if (x.val < y.val)       return 1;     else       return 0;   }   int main() {     cin >> n >> nmax;     for (i = 1; i <= n; i++) {       cin >> a[i].val;       a[i].poz = i;       if (a[i].val % 2 == 0)         nrpar++;       else         nrimpar++;       if (a[i].val <= 200000) luat[a[i].val] = 1;     }     sort(a + 1, a + n + 1, comp);     impar = 1;     par = 2;     for (i = 1; i <= n; i++)       if (a[i].val == a[i + 1].val) {         if (nrpar > nrimpar) {           sol++;           if (a[i].val % 2 == 0) {             nrimpar++;             nrpar--;           }           while (luat[impar]) impar += 2;           a[i].val = impar;           luat[impar] = 1;           if (impar > nmax) sol = -1000000;         } else if (nrpar < nrimpar) {           sol++;           if (a[i].val % 2 == 1) {             nrimpar--;             nrpar++;           }           while (luat[par]) par += 2;           a[i].val = par;           luat[par] = 1;           if (par > nmax) sol = -1000000;         } else {           if (a[i].val % 2 == 1) {             sol++;             while (luat[impar]) impar += 2;             a[i].val = impar;             luat[impar] = 1;             if (impar > nmax) sol = -1000000;           } else {             sol++;             while (luat[par]) par += 2;             a[i].val = par;             luat[par] = 1;             if (par > nmax) sol = -1000000;           }         }       }     i = 0;     while (nrpar != nrimpar) {       i++;       if (a[i].val % 2 == 0 and nrpar > nrimpar) {         sol++;         nrimpar++;         nrpar--;         while (luat[impar]) impar += 2;         a[i].val = impar;         luat[impar] = 1;         if (impar > nmax) sol = -1000000;       } else if (a[i].val % 2 == 1 and nrpar < nrimpar) {         sol++;         nrimpar--;         nrpar++;         while (luat[par]) par += 2;         a[i].val = par;         luat[par] = 1;         if (par > nmax) sol = -1000000;       }     }     sort(a + 1, a + n + 1, rearanjare);     if (sol < 0) {       cout << -1;       return 0;     }     cout << sol <<   n ;     for (i = 1; i <= n; i++) cout << a[i].val <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       string s, t;       cin >> s >> t;       long long w = 0;       char s1, t1, s2, t2;       int q = 0;       for (long long i = 0; i < n; i++) {         if (s[i] != t[i]) {           w++;         }         if (w == 1 && q == 0) {           s1 = s[i], t1 = t[i];           q++;         }         if (w == 2 && q == 1) {           s2 = s[i], t2 = t[i];           q++;         }       }       if (w != 2) {         cout <<  NO  << endl;       } else {         if (t1 == t2 && s1 == s2)           cout <<  yes  << endl;         else           cout <<  no  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int a;     scanf( %d , &a);     int m[a];     int p = 1, i;     for (i = 0; i < a; i++) {       scanf( %d , &m[i]);       if (i > 0) {         if (m[i] != m[i - 1]) {           p++;         }       }     }     printf( %d , p);   }
#include <bits/stdc++.h>   using namespace std;   int s[101][101];   int main() {     int n, a, r;     cin >> n;     a = 100;     while (a * (a - 1) * (a - 2) / 6 > n) a--;     n -= a * (a - 1) * (a - 2) / 6;     r = a;     for (int i = 1; i < a; i++)       for (int j = i + 1; j <= a; j++) s[i][j] = s[j][i] = 1;     for (int i = a; i >= 2; i--) {       while (n >= i * (i - 1) / 2) {         n -= i * (i - 1) / 2;         r++;         for (int j = 1; j <= i; j++) {           s[r][j] = s[j][r] = 1;         }       }     }     cout << r << endl;     for (int i = 1; i <= r; i++) {       for (int j = 1; j <= r; j++) {         cout << s[i][j];       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long a, long long b, long long mod) {     if (b == 0) return 1;     long long val = power(a, b >> 1, mod);     long long ans = ((val % mod) * (val % mod)) % mod;     if (b % 2 != 0) ans = ((ans % mod) * (a % mod)) % mod;     return ans;   }   int m[1002][1002] = {0};   int m2[1002][1002] = {0};   int main(void) {     int h, w;     cin >> h >> w;     vector<int> R, C;     for (int i = 0; i < h; i++) {       int r;       cin >> r;       for (int j = 0; j < r; j++) m[i][j] = 1;       R.push_back(r);     }     for (int i = 0; i < w; i++) {       int r;       cin >> r;       for (int j = 0; j < r; j++) m[j][i] = 1;       C.push_back(r);     }     for (int i = 0; i < h; i++) {       int c = 0;       for (int j = 0; j < w; j++) {         if (m[i][j] == 0) break;         c++;       }       if (c != R[i]) {         cout << 0 << endl;         return 0;       }     }     for (int i = 0; i < w; i++) {       int c = 0;       for (int j = 0; j < h; j++) {         if (m[j][i] == 0) break;         c++;       }       if (c != C[i]) {         cout << 0 << endl;         return 0;       }     }     long long cnt = 0;     for (int i = 0; i < h; i++) {       for (int j = 0; j < w; j++) {         if (m[i][j] == 0) {           for (int l = j + 1; l < w; l++) {             if (m[i][l] != 1) m2[i][l]++;           }           break;         }       }     }     for (int i = 0; i < w; i++) {       for (int j = 0; j < h; j++) {         if (m[j][i] == 0) {           for (int l = j + 1; l < h; l++) {             if (m[l][i] != 1) m2[l][i]++;           }           break;         }       }     }     for (int i = 0; i < h; i++) {       for (int j = 0; j < w; j++)         if (m2[i][j] == 2) cnt++;     }     cout << power(2, cnt, 1000000007) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1};   int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};   vector<int> adj[300010], val(300010, 1), vis(300010, 0), dis1(300010, 0),       dis2(300010, 0);   int myrandom(int i) { return std::rand() % i; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, t;     long double p;     cin >> n >> p >> t;     long double dp[t + 2][n + 2];     memset(dp, 0, sizeof(dp));     dp[0][0] = 1;     for (int i = 0; i <= t; i++) {       for (int j = 0; j <= n; j++) {         if (j < n) {           dp[i + 1][j + 1] += dp[i][j] * p;           dp[i + 1][j] += dp[i][j] * (1 - p);         } else {           dp[i + 1][j] += dp[i][j];         }       }     }     long double ans = 0;     for (int i = 1; i <= n; i++) {       ans = ans + i * (dp[t][i]);     }     cout << fixed << setprecision(20) << ans <<   n ;   }
#include <bits/stdc++.h>   int main() {     char a[200];     int n;     bool plat[200];     scanf( %d , &n);     scanf( %s , a);     for (int i = 0; i < n; i++) {       if (a[i] ==  * )         plat[i] = true;       else         plat[i] = false;     }     bool ans = false;     for (int i = 0; i < n; i++) {       if (!plat[i]) continue;       for (int m = 1; i + m * 4 < n; m++) {         if (plat[i + m] && plat[i + 2 * m] && plat[i + 3 * m] &&             plat[i + 4 * m]) {           ans = true;           break;         }       }     }     printf( %s , ans ?  yes n  :  no n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, p;     cin >> n >> p;     vector<int> a(n);     for (auto &i : a) cin >> i;     int m = *max_element((a).begin(), (a).end());     vector<int> freq(m + n + 10);     for (int i = 0; i < n; i++) {       freq[a[i]]++;     }     for (int i = 1; i < m + n + 10; i++) {       freq[i] += freq[i - 1];     }     vector<int> ans;     for (int x = max(1, m - n + 1); x < m; x++) {       int i = 0;       while (i < n) {         int vals = (freq[x + i] - i);         if (vals % p == 0) {           break;         }         i++;       }       if (i == n) ans.push_back(x);     }     cout << ans.size() << endl;     for (auto &x : ans) {       cout << x <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 5;   template <class T>   void read(vector<T> &arr) {     for (auto &x : arr) cin >> x;   }   template <class T>   void read(T &x) {     cin >> x;   }   template <class T>   void write(vector<T> &arr) {     for (auto x : arr) cout << x <<    ;     cout <<   n ;   }   template <class T>   void write(vector<vector<T>> &arr) {     for (auto &x : arr) {       for (auto &y : x) cout << y <<    ;       cout <<   n ;     }   }   template <class T>   void write(T &x) {     cout << x;   }   void solve() {     long long n;     cin >> n;     vector<long long> arr(n);     read(arr);     long long ans = 0;     bool isStarted = false;     for (long long i = 0; i < n; ++i) {       if (arr[i] == 1) {         isStarted = true;       }       if (arr[i] == 0 && isStarted) ans++;     }     for (long long i = n - 1; i > -1; --i) {       if (arr[i] == 1) break;       if (arr[i] == 0) ans--;     }     cout << ans <<   n ;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     long long t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       long long n, m;       cin >> n >> m;       vector<string> ar(11);       for (int i = 0; i < n; i++) {         cin >> ar[i];       }       string ans;       bool res = false;       for (int i = 0; i < m && !res; i++) {         for (int j = 0; j < 26 && !res; j++) {           string s = ar[0];           s[i] =  a  + j;           bool te = true;           for (int k = 0; k < n; k++) {             long long co = 0;             for (int l = 0; l < m; l++) {               if (ar[k][l] != s[l]) {                 co++;               }             }             if (co > 1) {               te = false;               break;             }           }           if (te) {             cout << s << endl;             res = true;             break;           }         }       }       if (!res) {         cout << -1 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, i;     cin >> n;     string s;     cin >> s;     map<char, long long int> a;     if (n > 26) {       cout << -1 << endl;       return 0;     }     long long int ans = 0;     for (i = 0; i < n; i++) {       if (a[s[i]] >= 1) ans++;       a[s[i]]++;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b) {       return a;     } else {       return b;     }   }   long long min(long long a, long long b) {     if (a < b) {       return a;     } else {       return b;     }   }   struct P {     double x, y;     P() {}     P(double x, double y) : x(x), y(y) {}     P operator+(const P &a) const { return P(x + a.x, y + a.y); }     P operator-(const P &a) const { return P(x - a.x, y - a.y); }     double operator^(const P &a) const { return x * a.x + y * a.y; }     void in() { scanf( %lf%lf , &x, &y); }     void out() { printf( REQUIRED %.7f %.7f n , x, y); }     double dist(P a, P b) {       return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));     }     double sqdist(P a, P b) {       return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);     }   };   int m, n;   int ma[50001][101];   int fin[50001][101];   int main() {     scanf( %d%d , &m, &n);     for (int i = (1); i <= (m); i++)       for (int j = (1); j <= (n); j++) scanf( %d , &ma[i][j]);     fin[1][1] = ma[1][1];     for (int i = (2); i <= (m); i++) fin[i][1] = fin[i - 1][1] + ma[i][1];     for (int j = (2); j <= (n); j++) {       fin[1][j] = ma[1][j] + fin[1][j - 1];       for (int i = (2); i <= (m); i++)         fin[i][j] = max(fin[i - 1][j] + ma[i][j], fin[i][j - 1] + ma[i][j]);     }     for (int i = (1); i <= (m); i++) printf( %d  , fin[i][n]);     puts(  );     return 0;   }