Buggy python submission (verdict: Time Limit Exceeded):
import random


def _calc_today_max_v3(today, D, Ci, Sdi, last_day):
    bad_1st_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    total_bad_1st_value = sum(bad_1st_values)
    bad_2nd_values = [Ci[contest] * (today + 2 - last_day[contest]) for contest in range(26)]
    total_bad_2nd_value = sum(bad_2nd_values)
    bad_3rd_values = [Ci[contest] * (today + 3 - last_day[contest]) for contest in range(26)]
    total_bad_3rd_value = sum(bad_3rd_values)
    bad_4th_values = [Ci[contest] * (today + 4 - last_day[contest]) for contest in range(26)]
    total_bad_4th_value = sum(bad_4th_values)
    bad_5th_values = [Ci[contest] * (today + 5 - last_day[contest]) for contest in range(26)]
    total_bad_5th_value = sum(bad_5th_values)

    head1 = 5
    head2 = 5
    contests_2nd = list(range(26))
    contests_3rd = list(range(26))
    contests_4th = list(range(26))
    contests_5th = list(range(26))
    random.shuffle(contests_2nd)
    random.shuffle(contests_3rd)
    random.shuffle(contests_4th)
    random.shuffle(contests_5th)

    max_value = -99999999999999999
    max_context = 0
    for contest_1st in range(26):
        contest_1st_value = Sdi[today][contest_1st]
        bad_1st_value = total_bad_1st_value - bad_1st_values[contest_1st]
        if today == D - 1:
            today_value = contest_1st_value - bad_1st_value
            if max_value < today_value:
                max_value = today_value
                max_context = contest_1st
        else:
            bad_00_mid = bad_1st_values[contest_1st] + 1 * Ci[contest_1st]
            contest_00_mid = contest_1st_value - bad_1st_value
            for contest_2nd in contests_2nd[0:head1]:
                contest_2nd_value = Sdi[today + 1][contest_2nd]
                bad_2nd_value = total_bad_2nd_value - bad_2nd_values[contest_2nd] - bad_00_mid
                if today == D - 2:
                    today_value = contest_00_mid + contest_2nd_value - bad_2nd_value
                    if max_value < today_value:
                        max_value = today_value
                        max_context = contest_1st
                else:
                    bad_0_mid = bad_1st_values[contest_1st] + 2 * Ci[contest_1st] - \
                                bad_2nd_values[contest_2nd] + Ci[contest_2nd]
                    contst0mid = contest_00_mid + contest_2nd_value - bad_2nd_value
                    for contest_3rd in contests_3rd[0:head1]:
                        contest_3rd_value = Sdi[today + 2][contest_3rd]
                        bad_3rd_value = total_bad_3rd_value - bad_0_mid - bad_3rd_values[contest_3rd]
                        if today == D - 3:
                            today_value = contst0mid + contest_3rd_value - bad_3rd_value
                            if max_value < today_value:
                                max_value = today_value
                                max_context = contest_1st
                        else:
                            bad_1st_mid = bad_1st_values[contest_1st] + 3 * Ci[contest_1st] - \
                                          bad_2nd_values[contest_2nd] + 2 * Ci[contest_2nd] - \
                                          bad_3rd_values[contest_3rd] + Ci[contest_3rd]
                            contest1mid = contst0mid + contest_3rd_value - - bad_3rd_value
                            for contest_4th in contests_4th[0:head2]:
                                contest_4th_value = Sdi[today + 3][contest_4th]
                                bad_4th_value = total_bad_4th_value - bad_4th_values[contest_4th] - bad_1st_mid
                                if today == D - 4:
                                    today_value = contest1mid + contest_4th_value - bad_4th_value
                                    if max_value < today_value:
                                        max_value = today_value
                                        max_context = contest_1st
                                else:
                                    bad_5th_mid = bad_1st_values[contest_1st] + 4 * Ci[contest_1st] - \
                                                  bad_2nd_values[contest_2nd] + 3 * Ci[contest_2nd] - \
                                                  bad_3rd_values[contest_3rd] + 2 * Ci[contest_3rd] - \
                                                  bad_4th_values[contest_4th] + 1 * Ci[contest_4th]

                                    contest_5th_mid = contest1mid + contest_4th_value - bad_4th_value
                                    for contest_5th in contests_5th[0:head2]:
                                        contest_5th_value = Sdi[today + 4][contest_5th]
                                        bad_5th_value = total_bad_5th_value - bad_5th_mid - bad_5th_values[contest_5th]
                                        today_value = contest_5th_value - bad_5th_value + contest_5th_mid
                                        if max_value < today_value:
                                            max_value = today_value
                                            max_context = contest_1st

    return max_context


def _calc_today_max_v2(today, D, Ci, Sdi, last_day):
    today_bad_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    today_total_bad_value = sum(today_bad_values)
    bad_2nd_values = [Ci[contest] * (today + 2 - last_day[contest]) for contest in range(26)]
    total_bad_2nd_value = sum(bad_2nd_values)

    max_value = -99999999999999999
    max_context = 0
    for contest_1st in range(26):
        contest_1st_value = Sdi[today][contest_1st]
        bad_1st_value = today_total_bad_value - today_bad_values[contest_1st]
        if today == D - 1:
            today_value = contest_1st_value - bad_1st_value
            if max_value < today_value:
                max_value = today_value
                max_context = contest_1st
        else:
            for contest_2nd in range(26):
                contest_2nd_value = Sdi[today + 1][contest_2nd]
                bad_2nd_value = total_bad_2nd_value - today_bad_values[contest_1st] - bad_2nd_values[contest_2nd]
                today_value = contest_1st_value + contest_2nd_value - bad_1st_value - bad_2nd_value
                if max_value < today_value:
                    max_value = today_value
                    max_context = contest_1st
    return max_context


def _calc_today_max(today, D, Ci, Sdi, last_day):
    today_bad_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    today_total_bad_value = sum(today_bad_values)

    max_value = -99999999999999999
    max_context = 0
    for contest in range(26):
        today_contest_value = Sdi[today][contest]
        today_bad_value = today_total_bad_value - today_bad_values[contest]
        today_value = today_contest_value - today_bad_value
        if max_value < today_value:
            max_value = today_value
            max_context = contest

    return max_context


def _main(D, Ci, Sdi):
    last_day = [0] * 26
    for today in range(D):
        max_contest = _calc_today_max_v3(today, D, Ci, Sdi, last_day)
        print(max_contest + 1)
        last_day[max_contest] = today + 1


def _execute():
    D = int(input())
    Ci = list(map(int, input().split()))
    Sdi = []
    for i in range(D):
        Sdi.append(list(map(int, input().split())))
    _main(D, Ci, Sdi)


if __name__ == "__main__":
    _execute()


Fixed submission:
def _calc_today_max(today, Ci, Sdi, last_day):
    today_total_bad_value = \
        sum([Ci[contest] * today + 1 - last_day[contest] for contest in range(26)])

    max_value = -999999999
    max_context = 0
    for contest in range(26):
        today_contest_value = Sdi[today][contest]
        today_bad_value = today_total_bad_value - Ci[contest]
        today_value = today_contest_value - today_bad_value
        if max_value < today_value:
            max_value = today_value
            max_context = contest
    return max_context


def _main(D, Ci, Sdi):
    last_day = [0] * 26
    for today in range(D):
        max_contest = _calc_today_max(today, Ci, Sdi, last_day)
        print(max_contest + 1)
        last_day[max_contest] = today + 1


def _execute():
    D = int(input())
    Ci = list(map(int, input().split()))
    Sdi = []
    for i in range(D):
        Sdi.append(list(map(int, input().split())))
    _main(D, Ci, Sdi)


if __name__ == "__main__":
    _execute()

Buggy python submission (verdict: Time Limit Exceeded):
def _calc_today_max_v3(today, D, Ci, Sdi, last_day):
    bad_1st_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    total_bad_1st_value = sum(bad_1st_values)
    bad_2nd_values = [Ci[contest] * (today + 2 - last_day[contest]) for contest in range(26)]
    total_bad_2nd_value = sum(bad_2nd_values)
    bad_3rd_values = [Ci[contest] * (today + 3 - last_day[contest]) for contest in range(26)]
    total_bad_3rd_value = sum(bad_2nd_values)

    max_value = -99999999999999999
    max_context = 0
    for contest_1st in range(26):
        contest_1st_value = Sdi[today][contest_1st]
        bad_1st_value = total_bad_1st_value - bad_1st_values[contest_1st]
        if today == D - 1:
            today_value = contest_1st_value - bad_1st_value
            if max_value < today_value:
                max_value = today_value
                max_context = contest_1st
        else:
            for contest_2nd in range(26):
                contest_2nd_value = Sdi[today + 1][contest_2nd]
                bad_2nd_value = total_bad_2nd_value - bad_1st_values[contest_1st] - bad_2nd_values[contest_2nd] \
                                + Ci[contest_1st]

                today_value = contest_1st_value + contest_2nd_value - bad_1st_value - bad_2nd_value
                # if max_value < today_value:
                #     max_value = today_value
                #     max_context = contest_1st
                if today == D - 2:
                    today_value = contest_1st_value + contest_2nd_value - bad_1st_value - bad_2nd_value
                    if max_value < today_value:
                        max_value = today_value
                        max_context = contest_1st
                else:
                    for contest_3rd in range(26):
                        contest_3rd_value = Sdi[today + 2][contest_3rd]
                        bad_3rd_value = total_bad_3rd_value - bad_1st_values[contest_1st] + 2 * Ci[contest_1st]
                        - bad_2nd_values[contest_2nd] + Ci[contest_2nd] - bad_3rd_values[contest_3rd]
                        today_value = contest_1st_value + contest_2nd_value + contest_3rd_value - bad_1st_value - bad_2nd_value - bad_3rd_value
                        if max_value < today_value:
                            max_value = today_value
                            max_context = contest_1st

    return max_context


def _calc_today_max_v2(today, D, Ci, Sdi, last_day):
    today_bad_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    today_total_bad_value = sum(today_bad_values)
    bad_2nd_values = [Ci[contest] * (today + 2 - last_day[contest]) for contest in range(26)]
    total_bad_2nd_value = sum(bad_2nd_values)

    max_value = -99999999999999999
    max_context = 0
    for contest_1st in range(26):
        contest_1st_value = Sdi[today][contest_1st]
        bad_1st_value = today_total_bad_value - today_bad_values[contest_1st]
        if today == D - 1:
            today_value = contest_1st_value - bad_1st_value
            if max_value < today_value:
                max_value = today_value
                max_context = contest_1st
        else:
            for contest_2nd in range(26):
                contest_2nd_value = Sdi[today + 1][contest_2nd]
                bad_2nd_value = total_bad_2nd_value - today_bad_values[contest_1st] - bad_2nd_values[contest_2nd]
                today_value = contest_1st_value + contest_2nd_value - bad_1st_value - bad_2nd_value
                if max_value < today_value:
                    max_value = today_value
                    max_context = contest_1st
    return max_context


def _calc_today_max(today, D, Ci, Sdi, last_day):
    today_bad_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    today_total_bad_value = sum(today_bad_values)

    max_value = -99999999999999999
    max_context = 0
    for contest in range(26):
        today_contest_value = Sdi[today][contest]
        today_bad_value = today_total_bad_value - today_bad_values[contest]
        today_value = today_contest_value - today_bad_value
        if max_value < today_value:
            max_value = today_value
            max_context = contest

    return max_context


def _main(D, Ci, Sdi):
    last_day = [0] * 26
    for today in range(D):
        max_contest = _calc_today_max_v3(today, D, Ci, Sdi, last_day)
        print(max_contest + 1)
        last_day[max_contest] = today + 1


def _execute():
    D = int(input())
    Ci = list(map(int, input().split()))
    Sdi = []
    for i in range(D):
        Sdi.append(list(map(int, input().split())))
    _main(D, Ci, Sdi)


if __name__ == "__main__":
    _execute()


Fixed submission:
def _calc_today_max(today, Ci, Sdi, last_day):
    today_total_bad_value = \
        sum([Ci[contest] * today + 1 - last_day[contest] for contest in range(26)])

    max_value = -999999999
    max_context = 0
    for contest in range(26):
        today_contest_value = Sdi[today][contest]
        today_bad_value = today_total_bad_value - Ci[contest]
        today_value = today_contest_value - today_bad_value
        if max_value < today_value:
            max_value = today_value
            max_context = contest
    return max_context


def _main(D, Ci, Sdi):
    last_day = [0] * 26
    for today in range(D):
        max_contest = _calc_today_max(today, Ci, Sdi, last_day)
        print(max_contest + 1)
        last_day[max_contest] = today + 1


def _execute():
    D = int(input())
    Ci = list(map(int, input().split()))
    Sdi = []
    for i in range(D):
        Sdi.append(list(map(int, input().split())))
    _main(D, Ci, Sdi)


if __name__ == "__main__":
    _execute()