#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>
#include <random>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

constexpr int CONTEST_SIZE = 26;
constexpr int DAY_MAXSIZE = 365;

int calc_score(int *r, const int c[CONTEST_SIZE], const int s[DAY_MAXSIZE][CONTEST_SIZE], int t[DAY_MAXSIZE], int D = DAY_MAXSIZE)
{
    int score = 0, prev_score = 0;
    int last[CONTEST_SIZE] = {};
    for (int d = 0; d < D; d++)
    {
        int con = t[d];
        score += s[d][con];
        last[con] = d+1;
        for (int i = 0; i < CONTEST_SIZE; i++)
        {
            score -= c[i] * (d+1 - last[i]);
        }
        if (r) r[d] = score - prev_score;
        prev_score = score;
    }
    return score;
}


int update_score_swap(int *r, const int c[CONTEST_SIZE], const int s[DAY_MAXSIZE][CONTEST_SIZE], int t[DAY_MAXSIZE], int D, int d1, int d2)
{
    int c1 = t[d1], c2 = t[d2];
}

int main()
{
    std::random_device seed_gen;
    mt19937 rnd(seed_gen());
    uniform_int_distribution con_dist(0, CONTEST_SIZE-1);
    uniform_int_distribution day_dist(0, DAY_MAXSIZE-1);

    int D; io >> D;
    int c[CONTEST_SIZE];
    int s[DAY_MAXSIZE][CONTEST_SIZE];
    for (int i = 0; i < CONTEST_SIZE; i++)
        io >> c[i];
    for (int d = 0; d < D; d++)
        for (int c = 0; c < CONTEST_SIZE; c++)
            io >> s[d][c];
    
    int t[DAY_MAXSIZE];

    for (int d = 0; d < D; d++)
    {
        int max_score = SINT_MIN;
        t[0] = 0;
        for (int i = 0; i < CONTEST_SIZE; i++)
        {
            int pre = t[d];
            t[d] = i;
            if (int cur_score = calc_score(nullptr, c, s, t, d+1); cur_score > max_score)
                max_score = cur_score;
            else
                t[d] = pre;
        }
    }

/*
    int diff_score[DAY_MAXSIZE];
    int time_count = 100000;
    while (time_count--)
    {
        int cur_score = calc_score(diff_score, c, s, t ,D);

        int d1;
        if (rnd() % 3)
        {
            d1 = distance(begin(diff_score), min_element(begin(diff_score), end(diff_score)));
        }
        else
        {
            d1 = day_dist(rnd);
        }

        int q = con_dist(rnd);
        int old1 = t[d1];
        t[d1] = q;
        if (int ss = calc_score(nullptr, c, s, t, D); ss > cur_score)
        {
            cur_score = ss;
        }
        else
        {
            t[d1] = old1;
        }

    }
*/

#if DEBUG
    int score = calc_score(nullptr, c, s, t ,D);
    io << score << BR;
#else
    for (int d = 0; d < D; d++)
        io << (t[d] + 1) << BR;
#endif

}


Measured memory_bytes: 3792