Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
import numba
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    return D, C, S

@njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            # k 日目に入るスコアの変更
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

def output(T):
    T += 1
    print(*T, sep='\n')

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :]), cache=True)
def random_update(D, C, S, T, last_days):
    d = np.random.randint(0, D, 1)[0]
    p = T[d]
    xcum = 0
    for q in range(26):
        if p == q:
            continue
        xcum += difference_update(D, C, S, T, last_days, d, q)
        if xcum > 0:
            return q, xcum
    difference_update(D, C, S, T, last_days, d, p)
    return p, 0

@njit((i4, i4[:], i4[:, :], i4[:], i4[:,:]), cache=True)
def main(D, C, S, T, last_days):
    x = 0
    for _ in range(5*10**5):
        x += random_update(D, C, S, T, last_days)[1]
    return T, x

def first_strategy(D, C, S):
    T = np.empty(D, np.int32)
    for d in range(D):
        T[d] = d % 26
    return T

D, C, S = get_input()

T = first_strategy(D, C, S)
last_days, score = first_computation(D, C, S, T)

T, x = main(D, C, S, T, last_days)

output(T)


Fixed submission:
import sys
import numpy as np
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    return D, C, S

@numba.njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@numba.njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            # k 日目に入るスコアの変更
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

def first_strategy(D, C, S):
    # S - 26C をキーにして greedy
    key = S - 26 * C
    T = np.empty(D, np.int32)
    for d in range(D):
        T[d] = np.argmax(key[d])
    return T

def output(T):
    T += 1
    print(*T, sep='\n')

D,C,S = get_input()

T = first_strategy(D,C,S)
output(T)
#last_days, score = first_computation(D,C,S,T)