Problem p02618 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;

#define dump(...)                                                              \
  DUMPOUT << "  ";                                                             \
  DUMPOUT << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]"   \
          << std::endl;                                                        \
  DUMPOUT << "    ";                                                           \
  dump_func(__VA_ARGS__)
#define PI 3.14159265358979323846
#define EPS 1e-10
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(j) (j).begin(), (j).end()
#define SZ(j) ((int)(j).size())

const int D = 365;

long long eval(vector<int> out, vector<int> c, vector<vector<int>> s) {
  long long sat = 0;
  vector<int> last(26, 0);
  // for d in range(D):
  REP(d, D) {
    //     assert(1 <= out[d] and out[d] <= 26)
    assert(1 <= out[d] and out[d] <= 26);
    //     j = out[d] - 1
    int j = out[d] - 1;
    //     last[j] = d + 1
    last[j] = d + 1;
    //     for i in range(26):
    REP(i, 26) {
      //         sat -= (d + 1 - last[i]) * c[i]
      sat -= (d + 1 - last[i]) * c[i];
    }
    //     sat += s[d][j]
    sat += s[d][j];
    cout << sat << endl;
  }

  // print("satisfaction: {}".format(sat))
  return sat;
  // print("score: {}".format(max(0, 1000000 + sat)))
}

int main() {

  int tempD;
  cin >> tempD;

  vector<int> c(26);
  REP(i, 26) cin >> c[i];

  vector<vector<int>> s(D, vector<int>(26));
  REP(d, D) REP(i, 26) cin >> s[d][i];

  vector<int> res(D);

  eval(res, c, s);

  REP(d, D) {
    int t = 0;
    REP(i, 26) {
      if (s[d][i] > t) {
        t = s[d][i];
        res[d] = i + 1;
      }
    }
  }

  for (int e : res)
    cout << e << endl;

  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;

#define dump(...)                                                              \
  DUMPOUT << "  ";                                                             \
  DUMPOUT << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]"   \
          << std::endl;                                                        \
  DUMPOUT << "    ";                                                           \
  dump_func(__VA_ARGS__)
#define PI 3.14159265358979323846
#define EPS 1e-10
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(j) (j).begin(), (j).end()
#define SZ(j) ((int)(j).size())

const int D = 365;

long long eval(vector<int> out, vector<int> c, vector<vector<int>> s) {
  long long sat = 0;
  vector<int> last(26, 0);
  // for d in range(D):
  REP(d, D) {
    //     assert(1 <= out[d] and out[d] <= 26)
    assert(1 <= out[d] and out[d] <= 26);
    //     j = out[d] - 1
    int j = out[d] - 1;
    //     last[j] = d + 1
    last[j] = d + 1;
    //     for i in range(26):
    REP(i, 26) {
      //         sat -= (d + 1 - last[i]) * c[i]
      sat -= (d + 1 - last[i]) * c[i];
    }
    //     sat += s[d][j]
    sat += s[d][j];
    cout << sat << endl;
  }

  // print("satisfaction: {}".format(sat))
  return sat;
  // print("score: {}".format(max(0, 1000000 + sat)))
}

int main() {

  int tempD;
  cin >> tempD;

  vector<int> c(26);
  REP(i, 26) cin >> c[i];

  vector<vector<int>> s(D, vector<int>(26));
  REP(d, D) REP(i, 26) cin >> s[d][i];

  vector<int> res(D);

  REP(d, D) {
    int t = 0;
    REP(i, 26) {
      if (s[d][i] > t) {
        t = s[d][i];
        res[d] = i + 1;
      }
    }
  }

  for (int e : res)
    cout << e << endl;

  return 0;
}