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

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

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

T = []
t = 0
for d in range(D):
    t = int(random.uniform(1,27))
    T.append(t)

# print(*T,sep='\n')

score = 0
t = 0
for d in range(D):
    t = T[d] - 1
    O[d][t] = 1
    dw = 0
    for i in range(26):
        dw += C[i]*((d+1) - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
# print(score)

# for _ in range(10000):
    # a = int(random.uniform(0,D))
    # q = int(random.uniform(1,27))
    # old = T[a]
    # T[a] = q

for a in range(D):
    old = T[a]
    for q in range(1,27):
        T[a] = q

        now = 0
        t = 0
        for d in range(D):
            t = T[d] - 1
            O[d][t] = 1
            dw = 0
            for i in range(26):
                dw += C[i]*((d+1) - last(d,i))
            A[d][t] = S[d][t] - dw
            now += A[d][t]
        if score > now:
            T[a] = old
        else:
            score = now

# print(score)

print(*T,sep='\n')


Fixed submission:
D = int(input())
C = [*map(int, input().split())]
S = [[*map(int, input().split())] for _ in range(D)]

# print(D)
# print(C)
# print(*S,sep='\n')

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

score = 0
t = 0
for d in range(D):
    O[d][t] = 1
    dw = 0
    for i in range(26):
        dw += C[t]*(d - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
    print(t+1)
    t = (t+1) % 26
# print(score)

# t = 0
# for d in range(D):
#     O[d][t] = 1
#     dw = 0
#     for i in range(26):
#         dw += C[t]*(d - last(d,i))
#     A[d][t] = S[d][t] - dw
#     print(t)
#     t = (t+1) % 26

# for d in range(D):
#     s = 0
#     for t in range(26):
#         s += C[t]*(d - last(d,t))
#     print(s)

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

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

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

T = []
t = 0
for d in range(D):
    t = int(random.uniform(1,27))
    T.append(t)

# print(*T,sep='\n')

score = 0
t = 0
for d in range(D):
    t = T[d] - 1
    O[d][t] = 1
    dw = 0
    for i in range(26):
        dw += C[i]*((d+1) - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
# print(score)

for _ in range(10000):

    TT = []
    for d in range(D):
        t = int(random.uniform(1,27))
        TT.append(t)

    now = 0
    t = 0
    for d in range(D):
        t = TT[d] - 1
        O[d][t] = 1
        dw = 0
        for i in range(26):
            dw += C[i]*((d+1) - last(d,i))
        A[d][t] = S[d][t] - dw
        now += A[d][t]
    if score < now:
        score = now
        T = TT

# print(score)

print(*T,sep='\n')


Fixed submission:
D = int(input())
C = [*map(int, input().split())]
S = [[*map(int, input().split())] for _ in range(D)]

# print(D)
# print(C)
# print(*S,sep='\n')

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

score = 0
t = 0
for d in range(D):
    O[d][t] = 1
    dw = 0
    for i in range(26):
        dw += C[t]*(d - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
    print(t+1)
    t = (t+1) % 26
# print(score)

# t = 0
# for d in range(D):
#     O[d][t] = 1
#     dw = 0
#     for i in range(26):
#         dw += C[t]*(d - last(d,i))
#     A[d][t] = S[d][t] - dw
#     print(t)
#     t = (t+1) % 26

# for d in range(D):
#     s = 0
#     for t in range(26):
#         s += C[t]*(d - last(d,t))
#     print(s)

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

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

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

T = []
t = 0
for d in range(D):
    t = int(random.uniform(1,27))
    T.append(t)

# print(*T,sep='\n')

score = 0
t = 0
for d in range(D):
    t = T[d] - 1
    O[d][t] = 1
    dw = 0
    for i in range(26):
        dw += C[i]*((d+1) - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
# print(score)

for _ in range(100000):

    TT = []
    for d in range(D):
        t = int(random.uniform(1,27))
        TT.append(t)

    now = 0
    t = 0
    for d in range(D):
        t = TT[d] - 1
        O[d][t] = 1
        dw = 0
        for i in range(26):
            dw += C[i]*((d+1) - last(d,i))
        A[d][t] = S[d][t] - dw
        now += A[d][t]
    if score < now:
        score = now
        T = TT

# print(score)

print(*T,sep='\n')


Fixed submission:
D = int(input())
C = [*map(int, input().split())]
S = [[*map(int, input().split())] for _ in range(D)]

# print(D)
# print(C)
# print(*S,sep='\n')

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

score = 0
t = 0
for d in range(D):
    O[d][t] = 1
    dw = 0
    for i in range(26):
        dw += C[t]*(d - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
    print(t+1)
    t = (t+1) % 26
# print(score)

# t = 0
# for d in range(D):
#     O[d][t] = 1
#     dw = 0
#     for i in range(26):
#         dw += C[t]*(d - last(d,i))
#     A[d][t] = S[d][t] - dw
#     print(t)
#     t = (t+1) % 26

# for d in range(D):
#     s = 0
#     for t in range(26):
#         s += C[t]*(d - last(d,t))
#     print(s)