alexjercan/bugnet huggingface dataset:
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <queue>
#include <random>
#include <stack>
#include <stdio.h>
#include <vector>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1 << 30);
const ll INFLL = (1ll << 60);
const ll MOD = (ll)(1e9 + 7);

#define l_ength size

void mul_mod(ll &a, ll b) {
  a *= b;
  a %= MOD;
}

void add_mod(ll &a, ll b) {
  a = (a < MOD) ? a : (a - MOD);
  b = (b < MOD) ? b : (b - MOD);
  a += b;
  a = (a < MOD) ? a : (a - MOD);
}

int l[30];
ll c[30], s[400][30];
std::vector<P> v;

int main(void) {
  int d, i, j, n = 26;
  ll ansm = -INFLL;
  std::cin >> d;
  for (i = 0; i < n; ++i) {
    l[i] = -1;
    std::cin >> c[i];
  }
  for (i = 0; i < d; ++i) {
    for (j = 0; j < n; ++j) {
      std::cin >> s[i][j];
    }
  }
  for (i = 0; i < d; ++i) {
    for (j = 0; j < n; ++j) {
      v.push_back(P(s[i][j] + c[j] * (i - l[j]), j + 1));
    }
    std::sort(v.begin(), v.end(), std::greater<P>());
    std::cout << v[0].second << std::endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <queue>
#include <random>
#include <stack>
#include <stdio.h>
#include <vector>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1 << 30);
const ll INFLL = (1ll << 60);
const ll MOD = (ll)(1e9 + 7);

#define l_ength size

void mul_mod(ll &a, ll b) {
  a *= b;
  a %= MOD;
}

void add_mod(ll &a, ll b) {
  a = (a < MOD) ? a : (a - MOD);
  b = (b < MOD) ? b : (b - MOD);
  a += b;
  a = (a < MOD) ? a : (a - MOD);
}

int l[30];
ll c[30], s[400][30], ans[100100];
std::vector<int> v[150000];

int main(void) {
  int d, i, j, n = 26, k, m = 125000;
  ll ansm = -INFLL;
  for (k = 0; k < m; ++k) {
    for (j = 0; j < n; ++j) {
      v[k].push_back(j);
    }
    std::random_device seed_gen;
    std::mt19937 engine(seed_gen());
    std::shuffle(v[k].begin(), v[k].end(), engine);
  }
  std::cin >> d;
  for (i = 0; i < 26; ++i) {
    std::cin >> c[i];
  }
  for (i = 0; i < d; ++i) {
    for (j = 0; j < n; ++j) {
      std::cin >> s[i][j];
    }
  }
  for (k = 0; k < m; ++k) {
    for (j = 0; j < n; ++j) {
      l[j] = -1;
    }
    for (i = 0; i < d; ++i) {
      ans[k] += s[i][v[k][i % 26]];
      l[v[k][i % 26]] = i;
      for (j = 0; j < n; ++j) {
        ans[k] -= c[j] * (i - l[j]);
      }
    }
    ansm = std::max(ansm, ans[k]);
    // std::cout << ans[k] << std::endl;
  }
  for (k = 0; k < m; ++k) {
    if (ans[k] == ansm) {
      for (i = 0; i < d; ++i) {
        std::cout << v[k][i % 26] + 1 << std::endl;
      }
      break;
    }
  }
  return 0;
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  c = vi(D);
  s = vvi(D, vi(26));
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void output() {
  for (int i = 0; i < D; i++) {
    cout << ans[i] + 1 << endl;
  }
}

int simulate(vi a) {
  int sum = 0;
  for (int i = 0; i < D; i++) {
    sum += s[i][a[i]];
  }
  return sum;
}

void solve() {
  int sum = 0, y = 0;
  for (int i = 0; i < 26; i++) {
    vi a(D, i);
    int x = simulate(a);
    if (x > sum) {
      sum = x;
      y = i;
    }
  }

  ans = vi(D, y);
}

int main() {
  input();
  solve();
  output();
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void output() {
  for (int i = 0; i < D; i++) {
    cout << ans[i] + 1 << endl;
  }
}

int simulate(vi a) {
  int sum = 0;
  for (int i = 0; i < D; i++) {
    sum += s[i][a[i]];
  }
  return sum;
}

void solve() {
  int sum = 0, y = 0;
  for (int i = 0; i < 26; i++) {
    vi a = vi(D, i);
    int x = simulate(a);
    if (x > sum) {
      sum = x;
      y = i;
    }
  }

  ans = vi(D, y);
}

int main() {
  input();
  solve();
  output();
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using PL = pair<ll, ll>;
using P = pair<int, int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007; // = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

struct state {
  int D;
  vector<int> c;
  vector<vector<int>> s;
  vector<int> before;

  state(int D, vector<int> &c, vector<vector<int>> &s)
      : D(D), c(c), s(s), before(26, -1) {}

  vector<int> optimization() {
    vector<ll> ans(D + 1, 0);
    vector<int> indexs(D);
    rep(i, D) {
      int idx = next_day(i);
      before[idx] = i;
      indexs[i] = idx + 1;
    }
    return indexs;
  }

  int next_day(int d) {
    int idx = -1, ans = -INF;
    rep(i, 26) {
      int ret = s[d][i];
      int x = before[i];
      before[i] = d;
      rep(j, 26) { ret -= (d - before[j]) * c[j]; }
      if (ans < ret) {
        ans = ret;
        idx = i;
      }
      before[i] = x;
    }
    return idx;
  }
};

int main() {
  int D;
  cin >> D;
  ;
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) rep(j, 26) cin >> s[i][j];

  state st(D, c, s);
  vector<int> ans = st.optimization();
  rep(i, D) printf("%d\\n", ans[i]);
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using PL = pair<ll, ll>;
using P = pair<int, int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007; // = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

struct state {
  int D;
  vector<int> c;
  vector<vector<int>> s;
  vector<int> before;

  state(int D, vector<int> &c, vector<vector<int>> &s)
      : D(D), c(c), s(s), before(26, -1) {}

  vector<int> optimization() {
    vector<ll> ans(D + 1, 0);
    vector<int> indexs(D);
    rep(i, D) {
      P p = next_day(i);
      int ret = p.first, idx = p.second;
      ans[i] += (ll)ret;
      before[idx] = i;
      indexs[i] = idx + 1;
      ans[i + 1] += ans[i];
    }
    return indexs;
  }

  P next_day(int d) {
    int idx = -1, ans = 0;
    rep(i, 26) {
      int ret = s[d][i];
      int x = before[i];
      before[i] = d;
      rep(j, 26) { ret -= (d - before[j]) * c[j]; }
      if (ans < ret) {
        ans = ret;
        idx = i;
      }
      before[i] = x;
    }
    return P(ans, idx);
  }
};

int main() {
  int D;
  cin >> D;
  ;
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) rep(j, 26) cin >> s[i][j];

  state st(D, c, s);
  vector<int> ans = st.optimization();
  rep(i, D) printf("%d\\n", ans[i]);
  return 0;
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int d;
  vector<int> c(26);
  cin >> d;
  vector<vector<int>> s(d, vector<int>(26));

  for (int i = 0; i < 26; i++)
    cin >> c.at(i);
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++)
      cin >> s.at(i).at(j);
  }

  for (int i = 0; i < d; i++)
    cout << ((i % 26) + 1) << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));

  cin >> d;
  for (int i = 0; i < 26; i++)
    cin >> c.at(i);
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++)
      cin >> s.at(i).at(j);
  }

  for (int i = 0; i < d; i++)
    cout << ((i % 26) + 1) << endl;
}
Problem p02618 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int D;
int C[500];
int S[500][500];
vector<int> Ans;
int scoring(int day, int t) {
  int score = 0;
  Ans.push_back(t);
  score += S[day][t];
  rep(j, 26) {
    int now = 0;
    for (int k = 1; k <= day; k++) {
      if (Ans[k] == j)
        chmax(now, k);
    }
    score -= C[j] * (day - now);
  }
  Ans.pop_back();
  return score;
}
signed main() {
  cin >> D;
  rep(i, 26) cin >> C[i];
  rep(i, D) { rep(j, 26) cin >> S[i + 1][j]; }
  vector<int> Ans;
  int s = 0;
  Ans.push_back(-1);
  for (int now = 1; now <= D; now++) {
    int S = -INF;
    rep(j, 26) { S = max(S, scoring(now, j)); }
    rep(j, 26) {
      if (S == scoring(now, j)) {
        s += S;
        Ans.push_back(j);
        break;
      }
    }
  }
  // cout<<s<<endl;
  for (int i = 1; i <= D; i++)
    cout << Ans[i] + 1 << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int D;
int C[500];
int S[500][500];
int scoring(int day, vector<int> t) {
  int score = 0;
  for (int i = 1; i <= day; i++) {
    score += S[i][t[i]];
    rep(j, 26) {
      int now = 0;
      for (int k = 1; k <= i; k++) {
        if (t[k] == j)
          chmax(now, k);
      }
      score -= C[j] * (i - now);
    }
  }
  return score;
}
signed main() {
  cin >> D;
  rep(i, 26) cin >> C[i];
  rep(i, D) { rep(j, 26) cin >> S[i + 1][j]; }
  vector<int> Ans;
  Ans.push_back(-1);
  for (int now = 1; now <= D; now++) {
    int S = -INF;
    rep(i, 26) {
      vector<int> Ans0 = Ans;
      Ans0.push_back(i);
      S = max(S, scoring(now, Ans0));
    }
    rep(i, 26) {
      vector<int> Ans0 = Ans;
      Ans0.push_back(i);
      if (scoring(now, Ans0) == S) {
        Ans.push_back(i);
        break;
      }
    }
    // cout<<Ans.size()<<' '<<now<<endl;
  }
  for (auto x : Ans)
    cout << x + 1 << endl;
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll score = 0;

int main() {
  int D;
  cin >> D;
  int N = 26;

  vector<int> c(N + 1);
  vector<vector<int>> s(D + 1, vector<int>(N + 1));
  vector<int> t(D + 1);
  vector<int> last(N + 1, 0);

  for (int i = 1; i <= N; i++) {
    cin >> c[i];
  }

  for (int i = 1; i <= D; i++) {
    for (int j = 1; j <= N; j++) {
      cin >> s[i][j];
    }
  }

  for (int d = 1; d <= D; d++) {
    ll max_score = -1e9;
    vector<int> max_last;
    for (int n = 1; n <= N; n++) {
      ll tmp_score = 0;
      vector<int> tmp_last(N + 1);
      tmp_last = last;

      tmp_score += s[d][n];
      tmp_last[n] = d;

      int penalty = 0;
      for (int i = 1; i <= N; i++) {
        penalty += c[i] * (d - tmp_last[i]);
      }

      tmp_score -= penalty;

      if (max_score < tmp_score) {
        max_score = tmp_score;
        max_last = tmp_last;
        t[d] = n;
      }
    }

    last = max_last;
  }

  for (int i = 1; i <= D; i++) {

    cout << t[i] << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll score = 0;

int main() {
  int D;
  cin >> D;
  int N = 26;

  vector<int> c(N + 1);
  vector<vector<int>> s(D + 1, vector<int>(N + 1));
  vector<int> t(D + 1);
  vector<int> last(N + 1, 0);

  for (int i = 1; i <= N; i++) {
    cin >> c[i];
  }

  for (int i = 1; i <= D; i++) {
    for (int j = 1; j <= N; j++) {
      cin >> s[i][j];
    }
  }

  for (int d = 1; d <= D; d++) {
    ll max_score = 0;
    vector<int> max_last;
    for (int n = 1; n <= N; n++) {
      ll tmp_score = 0;
      vector<int> tmp_last = last;

      tmp_score += s[d][n];
      tmp_last[n] = d;

      int penalty = 0;
      for (int i = 1; i <= N; i++) {
        penalty += c[i] * (d - tmp_last[i]);
      }

      tmp_score -= penalty;

      if (max_score < tmp_score) {
        max_score = tmp_score;
        max_last = tmp_last;
        t[d] = n;
      }
    }
    last = max_last;
  }

  for (int i = 1; i <= D; i++) {
    cout << t[i] << endl;
  }
  return 0;
}
Problem p02618 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define mod (ll)(1e9 + 7)
#define inf (ll)(3e18 + 7)
#define pi (double)acos(-1.0)
#define P pair<int, int>
#define PiP pair<int, pair<int, int>>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;

int d;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26));

int get_score(vector<int> t) {
  int ans = 0;
  vector<int> last(26, 0);
  rep(i, d) {
    ans += s[i][t[i]];
    rep(j, 26) {
      if (t[i] == j)
        last[j] = i + 1;
      ans -= c[j] * ((i + 1) - last[j]);
    }
  }
  return ans;
}

int main() {
  cin >> d;
  rep(i, 26) cin >> c[i];
  rep(i, d) rep(j, 26) cin >> s[i][j];
  //-----code------//
  vector<int> t(d, 0);
  int m;
  cin >> m;
  rep(i, 100000) {
    int D = rand() % d, q = rand() % 26;
    int old = t[D], olds = get_score(t);
    t[D] = q;
    if (get_score(t) < olds)
      t[D] = old;
  }
  rep(i, d) cout << t[i] + 1 << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  } else {
    return false;
  }
}
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, n) for (int i = 1; i <= (n); i++)
#define mod (ll)(1e9 + 7)
#define inf (ll)(3e18 + 7)
#define pi (double)acos(-1.0)
#define P pair<int, int>
#define PiP pair<int, pair<int, int>>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;

int d;
vector<int> c(26);
vector<vector<int>> s(400, vector<int>(26));

int get_score(vector<int> t) {
  int ans = 0;
  vector<int> last(26, 0);
  rep(i, d) {
    ans += s[i][t[i]];
    rep(j, 26) {
      if (t[i] == j)
        last[j] = i + 1;
      ans -= c[j] * ((i + 1) - last[j]);
    }
  }
  return ans;
}

int main() {
  cin >> d;
  rep(i, 26) cin >> c[i];
  rep(i, d) rep(j, 26) cin >> s[i][j];
  //-----code------//
  vector<int> t(d, 0);
  int m;
  cin >> m;
  while ((clock() / CLOCKS_PER_SEC) < 1.9) {
    int D = rand() % d, q = rand() % 26;
    int old = t[D], olds = get_score(t);
    t[D] = q;
    if (get_score(t) < olds)
      t[D] = old;
  }
  rep(i, d) cout << t[i] + 1 << endl;
}
Problem p02618 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

inline void InitRand() { srand((unsigned int)time(NULL)); }

int main() {
  InitRand();
  int D;
  cin >> D;
  veci C(26);
  vecveci S(D, veci(26));
  veci T(D);
  REP(i, 26) cin >> C[i];
  REP(i, D) REP(j, 26) cin >> S[i][j];
  REP(i, D) { T[i] = rand() % 26; }
  int M;
  M = 1e5;
  veci B(M), Q(M);
  REP(i, M) {
    B[i] = rand() % D;
    Q[i] = rand() % 26;
  }

  veci last_d(26);
  ll old_ans = 0;
  REP(i, D) {
    int d = i + 1;
    last_d[T[i]] = d;
    old_ans += S[i][T[i]];
    REP(j, 26) { old_ans -= C[j] * (d - last_d[j]); }
  }

  REP(i, M) {
    int old_p = T[B[i]];
    T[B[i]] = Q[i];
    ll score = 0;
    veci last(26);
    REP(j, D) {
      int d = j + 1;
      last[T[j]] = d;
      score += S[j][T[j]];
      REP(k, 26) { score -= C[k] * (d - last[k]); }
    }
    if (old_ans < score) {
      old_ans = score;
    } else {
      T[B[i]] = old_p;
    }
  }
  REP(i, D) cout << T[i] + 1 << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

inline void InitRand() { srand((unsigned int)time(NULL)); }

int main() {
  InitRand();
  int D;
  cin >> D;
  veci C(26);
  vecveci S(D, veci(26));
  veci T(D);
  REP(i, 26) cin >> C[i];
  REP(i, D) REP(j, 26) cin >> S[i][j];
  REP(i, D) { T[i] = rand() % 26; }
  int M;
  M = 3 * 1e5;
  veci B(M), Q(M);
  REP(i, M) {
    B[i] = rand() % D;
    Q[i] = rand() % 26;
  }

  veci last_d(26);
  ll old_ans = 0;
  REP(i, D) {
    int d = i + 1;
    last_d[T[i]] = d;
    old_ans += S[i][T[i]];
    REP(j, 26) { old_ans -= C[j] * (d - last_d[j]); }
  }

  REP(i, M) {
    int old_p = T[B[i]];
    T[B[i]] = Q[i];
    ll score = 0;
    veci last(26);
    REP(j, D) {
      int d = j + 1;
      last[T[j]] = d;
      score += S[j][T[j]];
      REP(k, 26) { score -= C[k] * (d - last[k]); }
    }
    if (old_ans < score) {
      old_ans = score;
    } else {
      T[B[i]] = old_p;
    }
  }
  REP(i, D) cout << T[i] + 1 << endl;
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; (i) < ((int)(n)); ++(i))

int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, 26) cin >> c[i];
  rep(i, D) {
    rep(j, 26) { cin >> s[i][j]; }
  }
  vector<int> ans(D);
  rep(i, D) {
    auto it = max_element(s[i].begin(), s[i].end());
    ans[i] = it - s[i].begin() + 1;
  }
  rep(i, D - 1) cout << ans[i] << " ";
  cout << ans[D - 1] << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; (i) < ((int)(n)); ++(i))

int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) cin >> c[i];
  rep(i, D) {
    rep(j, 26) { cin >> s[i][j]; }
  }
  vector<int> ans(D);
  rep(i, D) {
    auto it = max_element(s[i].begin(), s[i].end());
    ans[i] = it - s[i].begin();
  }
  rep(i, D - 1) cout << ans[i] << " ";
  cout << ans[D - 1] << endl;
}
Problem p02618 (C++) — buggy submission, verdict: Runtime Error

/**
 *    author:  boutarou
 *    created: 28.06.2020 20:54:48
 **/

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

const double PI = 3.1415926535897932;

int d;
int c[26];
int s[365][26];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> d;
  rep(i, 26) cin >> c[i];
  rep(i, d) { rep(j, 26) cin >> s[i][j]; }
  rep(i, d) {
    int ma = 0;
    rep(j, 26) chmax(ma, s[i][j]);
    int ans;
    rep(j, 26) if (ma == s[i][j]) ans = j;
    cout << ans + 1 << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

/**
 *    author:  boutarou
 *    created: 28.06.2020 20:54:48
 **/

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

const double PI = 3.1415926535897932;

constexpr int CONTEST = 26;

int d;
int c[CONTEST];
int s[CONTEST][CONTEST];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> d;
  rep(i, CONTEST) cin >> c[i];
  rep(i, d) { rep(j, CONTEST) cin >> s[i][j]; }
  rep(i, d) {
    int ma = 0;
    rep(j, CONTEST) chmax(ma, s[i][j]);
    int ans;
    rep(j, CONTEST) if (ma == s[i][j]) ans = j;
    cout << ans + 1 << endl;
  }

  return 0;
}