#include <stdio.h>

    int lday[26] = {-1, -1, -1,-1, -1, -1,-1, -1, -1,-1, -1, -1,-1, -1, -1,-1, -1, -1,-1, -1, -1,-1, -1, -1,-1, -1}, dp[366], day[26][366] = {}, dayc[26] = {};   //  day     コンテストが実施された日    dayc    dayのインデックス
    int c[26], s[365][26], ave = 0;

int calc(int con, int dd)
{
    int i, ans;
    ans = s[dd][con];
    
    for (i = 0; i < con; i++)
        ans -= c[i] * (dd - lday[i]);
    for (i = con + 1; i < 26; i++)
        ans -= c[i] * (dd - lday[i]);
    return (ans);
}

int main(void){
    int d, D, ans[366], score = 0, tmpscore, tmpans[12][366];
    int i, ii, iii, iv, tmp, tmp2;
    scanf("%d", &D);
    for (i = 0; i < 26; i++)
        scanf("%d", c + i);
    for (ii = 0; ii < D; ii++)
        for (i = 0; i < 26; i++)
            scanf("%d", &s[ii][i]);
    
    for (i = 0; i < 26; i++)
        ave += c[i];
    ave /= 26;
    tmpscore = 0;
    for (d = 0;  d < D; d++)
    {
        tmp = -1000000;
        for (i = 0; i < 26; i++)
        {
            tmp2 = calc(i, d);
            if (tmp2 > tmp)
            {
                tmp = tmp2;
                ans[d] = i;
            }
        }
        tmpscore += tmp;
        day[ans[d]][dayc[ans[d]]++] = d;
        lday[ans[d]] = d;
    }
    for (i = 0; i < D; i++)
    {
        tmpans[0][i] = ans[i];
    }
    
    score = tmpscore;
    
    if (ave < 10)
        ave = 10;
    for (iv = 0; iv < 2; iv++)
    {
        for (i = 0; i < 26; i++)
            lday[i] = -1;
        for(i = 0; i < 26; i++)
        {
            if (c[i] > ave * 1.3 || c[i] > 70)
            {
                for (ii = 0; ii < dayc[i] - 1; ii++)
                {
                    if (day[i][ii + 1] - day[i][ii] > 80)
                    {
                        for (iii = dayc[i] + 1; iii > ii + 1; iii--)
                        {
                            day[i][iii] = day[i][iii - 1];
                        }
                        ans[(day[i][ii] + day[i][ii+1])/2] = i;
                        day[i][ii + 1] = (day[i][ii] + day[i][ii + 1]) / 2;
                        dayc[i]++;
                    }
                }
            }
            else if (c[i] > ave || c[i] > 50)
            {
                for (ii = 0; ii < dayc[i] - 1; ii++)
                {
                    if (day[i][ii + 1] - day[i][ii] > 100)
                    {
                        for (iii = dayc[i] + 1; iii > ii + 1; iii--)
                        {
                            day[i][iii] = day[i][iii - 1];
                        }
                        ans[(day[i][ii] + day[i][ii+1])/2] = i;
                        day[i][ii + 1] = (day[i][ii] + day[i][ii + 1]) / 2;
                        dayc[i]++;
                    }
                }
            }
            else if (c[i] > 0)
            {
                for (ii = 0; ii < dayc[i] - 1; ii++)
                {
                    if (day[i][ii + 1] - day[i][ii] > 150)
                    {
                        for (iii = dayc[i] + 1; iii > ii + 1; iii--)
                        {
                            day[i][iii] = day[i][iii - 1];
                        }
                        ans[(day[i][ii] + day[i][ii+1])/2] = i;
                        day[i][ii + 1] = (day[i][ii] + day[i][ii + 1]) / 2;
                        dayc[i]++;
                    }
                }
            }
        }
        tmp = 0;
        for (i = 0; i < D; i++)
        {
            tmp += calc(ans[d], i);
        }
        if (tmp > score)
        {
            for (i = 0; i < D; i++)
            {
                tmpans[0][i] = ans[i];
            }
            score = tmp;
        }
    }
    for (iv = 0; iv < 7; iv++)
    {
        for(i = 0; i < 26; i++)
        {
            if (c[i] > ave * 1.3 || c[i] > 70)
            {
                for (ii = 0; ii < dayc[i] - 1; ii++)
                {
                    if (day[i][ii + 1] - day[i][ii] > 80)
                    {
                        for (iii = dayc[i] + 1; iii > ii + 1; iii--)
                        {
                            day[i][iii] = day[i][iii - 1];
                        }
                        ans[(day[i][ii] + day[i][ii+1])/2] = i;
                        day[i][ii + 1] = (day[i][ii] + day[i][ii + 1]) / 2;
                        dayc[i]++;
                    }
                }
            }
        }
        for (i = 0; i < 26; i++)
            lday[i] = -1;
        tmp = 0;
        for (i = 0; i < D; i++)
        {
            tmp += calc(ans[d], i);
        }
        if (tmp > score)
        {
            for (i = 0; i < D; i++)
            {
                tmpans[0][i] = ans[i];
            }
            score = tmp;
        }
    }
    for (i = 0; i < D; i++)
        printf("%d\n", tmpans[0][i] + 1);
}

Measured memory_bytes: 1820