Buggy python submission (verdict: Time Limit Exceeded):
from time import time
stime = time()

from copy import copy
from random import randint

def get_fav_contest(s, t):
    s = copy(s)
    t = copy(t)
    dc = 0
    d = len(t)
    for i in range(1, d):
        dc += s[i][t[i]]
        ca[t[i]] = i
        dc -= sum([c[i2] * (i - ca[i2]) for i2 in range(1, 27)])
    return dc

d = int(input())
c = [0] + list(map(int, input().split(' ')))

s = [[]] + [[0] + list(map(int, input().split(' '))) for _ in range(d)]

t = 0 # 算出結果
tl = [0]

ca = [0] * (1 + 26) # 放置された不満の数々
cat = [] # 不満度の最適な算出のための一時配列
cat2 = []

for i in range(1, d + 1):
    cat = [0]
    for i2 in range(1, 27):
        cat2 = copy(ca)
        cat2[i2] = i
        cat.append(s[i][i2] + sum(c[i3] * (i - ca[i3]) for i3 in range(1, 27)))
    t = cat.index(max(cat))
    ca[t] = i
    tl.append(t)

default_t = get_fav_contest(s, tl)

ch = 0 # 適当に選んだ日
temp1 = 0 # 一時的に保存する場所
while time() - stime < 2:
    ch = randint(1, 365)
    temp1 = tl[ch]
    tl[ch] = randint(1, 26)
    if get_fav_contest(s, tl) < default_t:
        tl[ch] = temp1
print('\n'.join(map(str, tl[1:])))

Fixed submission:
d = int(input())
c = [0] + list(map(int, input().split(' ')))

s = [[]] + [[0] + list(map(int, input().split(' '))) for _ in range(d)]

t = 0 # 算出結果

ca = [0] * (1 + 26) # 放置された不満の数々
cat = [] # 不満度の最適な算出のための一時配列
dc = 0 # カレントな満足度
#dl = [] # 満足度のログ

for i in range(1, d + 1):
    cat = [c[i2] * (i - ca[i2]) for i2 in range(1, 27)]
    t = cat.index(min(cat)) + 1
    dc += s[i][t]
    ca[t] = i
    dc -= sum(cat)
    print(t)

Buggy python submission (verdict: Runtime Error):
import random

T = 26


def read_input():
    D = int(input())
    cs = list(map(int, input().split()))
    ss = [list(map(int, input().split())) for _ in range(D)]
    return D, cs, ss


def greedy(D, cs, ss):
    ts = []
    last = [0] * T
    for d in range(D):
        d_true = d + 1
        diffs = []
        ssc = ss[d]
        for t in range(T):
            s = ssc[t]
            d = s + cs[t] * (d_true - last[t])
            diffs.append((d, t))
        
        dc, tc = max(diffs)
        last[tc] = d_true
        ts.append(tc)
    
    return ts


def evaluate(out, D, c, s):
    sat = 0
    last = [0] * 26
    for d in range(D):
        assert(1 <= out[d] and out[d] <= 26)
        j = out[d] - 1
        last[j] = d + 1
        for i in range(26):
            sat -= (d + 1 - last[i]) * c[i]
        sat += s[d][j]
        
    return sat, max(0, 1000000 + sat)


def anneal(D, cs, ss, ts_init):
    def calc_cs(tds):
        last = 0
        css = 0
        for d in tds:
            css += (d + 1 - last) * (d - last) // 2
            last = d
        css += D - 1 - last
        return css

    ts = ts_init.copy()
    tds = [set() for t in range(26)]
    for d in range(D):
        t = ts[d]
        tds[t].add(d)

    for i in range(10000):
        r = random.random()
        if r < 1:  # flip
            d1, d2 = random.randint(0, D-1), random.randint(0, D-1)
            if d1 == d2 or ts[d1] == ts[d2]:
                continue
            d1, d2 = min(d1, d2), max(d1, d2)
            t1, t2 = ts[d1], ts[d2]
            diff1 = (ss[d2][t1] - ss[d1][t1]) + (ss[d1][t2] - ss[d2][t2])
            tds1_after = tds[t1].copy()
            tds1_after.add(d2)
            tds1_after.remove(d1)
            tds2_after = tds[t2].copy()
            tds2_after.add(d1)
            tds2_after.remove(d2)
            # print(tds1_after)
            # print(tds[t1])
            # print(calc_cs(sorted(tds1_after)))
            # print(calc_cs(sorted(tds[t1])))
            diff2 = cs[t1] * (calc_cs(sorted(tds1_after)) - calc_cs(sorted(tds[t1]))) \
                + cs[t2] * (calc_cs(sorted(tds2_after)) - calc_cs(sorted(tds[t2])))
            diff = diff1 + diff2
            # print(diff1, diff2)
            if diff > 0:
                # print("yead")
                ts[d1], ts[d2] = ts[d2], ts[d1]
                tds[t1] = tds1_after
                tds[t2] = tds2_after
        else:
            pass

        if i % 100 == 0:
            # print(evaluate(inc(ts), D, cs, ss))
    
    return ts


def inc(ts):
    return [t + 1 for t in ts]


def solve(D, cs, ss):
    ts = greedy(D, cs, ss)
    ts = anneal(D, cs, ss, ts)
    ts = inc(ts)
    return ts


if __name__ == "__main__":
    D, cs, ss = read_input()
    ts = solve(D, cs, ss)

    for t in ts:
        print(t)


Fixed submission:
D = int(input())
cs = list(map(int, input().split()))
ss = [list(map(int, input().split())) for _ in range(D)]

ts = []
for i in range(D):
    t = 1
    ts.append(t)

for t in ts:
    print(t)