Buggy python submission (verdict: Time Limit Exceeded):
import copy
import sys

import numpy as np

global NN
NN = 26

readline = sys.stdin.buffer.readline


class Contest:
    """
    d: ある日付
    i: テストの種類
    self.day: 最後にテストiを開催した日
    """

    def __init__(self, c, s, D):
        self.last = [-1 for _ in range(NN)]
        self.C = c
        self.S = s
        self.score = 0

    def minus_score(self, d, i):
        m = self.C[i] * (d - self.last[i])
        return m

    def sum_minus_scores(self, d):
        m = 0
        for i in range(NN):
            m += self.minus_score(d, i)

        return m

    # テストiを開催したときのスコア
    def update_score(self, i, d):
        self.last[i] = d
        self.score += S[d][i]
        self.score -= self.sum_minus_scores(d)
        return self.score

    # 日付を更新せずにスコアを計算
    def calc_score(self, i, d):
        s = self.score
        last_d = self.last[i]
        self.last = d
        s += S[d][i]
        s -= self.sum_minus_scores(d)
        self.last = last_d

        return s

    def find_worst(self, tests):
        old_score = 0
        diff = []
        for day, test in enumerate(tests):
            score = self.update_score(test, day)
            diff.append(score - old_score)
            old_score = score

        return diff


D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

tests = []
for s in S:
    s = np.array(s)
    tests.append(np.argmax(s))

T = Contest(C, S, D)
T.find_worst(tests)

k = 2
for cnt in range(10**6):
    org_tests = copy.deepcopy(tests)
    org_score = T.score

    diff = T.find_worst(tests)
    a = np.argsort(diff)

    if cnt % 10 == 0:
        ind = np.random.randint(D)
        tests[ind] = np.random.randint(0, NN)

        if T.score < org_score:
            tests = org_tests

        # print(T.score, org_score)

    else:
        ind = [int(np.arange(D)[a == i]) for i in range(k)]

        for i in range(k):
            tests[ind[i]] = np.random.randint(0, NN)

        if T.score < org_score:
            tests = org_tests

    # print(T.score)

ans = [str(i + 1) for i in tests]
print("\n".join(ans))


Fixed submission:
import random

global NN
NN = 26


class Contest:
    """
    d: ある日付
    i: テストの種類
    self.day: 最後にテストiを開催した日
    """

    def __init__(self, c, s, D):
        self.test = [i % NN for i in range(D)]
        self.last = [0 for _ in range(NN)]
        self.C = c
        self.S = s
        self.score = 0

    def update_day(self, i, d):
        self.last[i] = d

    def minus_score(self, d, i):
        m = self.C[i] * (d - self.last[i])
        return m

    def sum_minus_scores(self, d):
        m = 0
        for i in range(NN):
            m += self.minus_score(d, i)

        return m

    # テストiを開催したときのスコア
    def update_score(self, i, d):
        s = self.score
        self.update_day(i, d)
        s += S[d][i]
        s -= self.sum_minus_scores(d)
        return s


D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

r = [random.randrange(1, NN + 1) for _ in range(D)]
print(*r)

# T = Contest(C, S, D)
#
# for i in range(D):
#     j = i % NN
#     score = T.update_score(j, 1)
#     print(j, score)
#
# print()
#
# T = Contest(C, S, D)
#
# for i in range(D):
#     j = random.randrange(NN)
#     score = T.update_score(j, 1)
#     print(j, score)


"""
+ 方針
  + Cの大きいテストは定期的に開催する
  + Cの小さいテストはまれに開催する
    + d = 1, 2, 3, 4, 5 ....
    + d-last[d] = 1, 3, 6, 10, 15 ...
    + 結構緩やか？

+ スコアを伸ばす方法
  + プラスを大きくする
  + マイナスを小さくする

"""