Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000)
readline = sys.stdin.readline
from collections import deque


def solve_beam():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    W, DEPTH = 3, 7

    def rec(day, rem):
        if rem == 0 or day > D:
            return 0, 0
        gains = sorted(((S[day - 1][t] + (day - lasts[t]) * C[t], t) for t in range(N)), reverse=True)
        max_gain = -1e10
        max_gain_t = 0
        for i in range(W):
            gain, t = gains[i]
            _t = lasts[t]
            lasts[t] = day
            f_gain, _ = rec(day + 1, rem - 1)
            lasts[t] = _t
            gain += f_gain
            if gain > max_gain:
                max_gain = gain
                max_gain_t = t

        return max_gain, max_gain_t

    for day in range(D):
        _, t = rec(day, DEPTH)
        lasts[t] = day
        ans[day - 1] = t
    
    for a in ans:
        print(a + 1)


solve_beam()

Fixed submission:
import sys
readline = sys.stdin.readline

def solve_greedy():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    for day in range(1, D + 1):
        m, mt = -1e10, 0
        for t in range(N):
            a = S[day - 1][t] + (day - lasts[t]) * C[t]
            if a > m:
                mt = t
                m = a
        
        lasts[mt] = day

        neg = sum((day - lasts[t]) * C[t] for t in range(N))
        pos = S[day - 1][t]

        ans[day - 1] = mt
    
    for a in ans:
        print(a + 1)



solve_greedy()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000)
readline = sys.stdin.readline
from collections import deque


def solve_beam():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    W, DEPTH = 3, 7

    def rec(day, rem):
        if rem == 0 or day > D:
            return 0, 0
        gains = [(S[day - 1][t] + (day - lasts[t]) * C[t], t) for t in range(N)]
        gains.sort(reverse=True)
        max_gain = -1e10
        max_gain_t = 0
        for i in range(W):
            gain, t = gains[i]
            _t = lasts[t]
            lasts[t] = day
            f_gain, _ = rec(day + 1, rem - 1)
            lasts[t] = _t
            gain += f_gain
            if gain > max_gain:
                max_gain = gain
                max_gain_t = t

        return max_gain, max_gain_t

    _total = 0
    for day in range(D):
        _, t = rec(day, DEPTH)
        lasts[t] = day
        ans[day - 1] = t
        _total += _
    
    for a in ans:
        print(a + 1)


solve_beam()

Fixed submission:
import sys
readline = sys.stdin.readline

def solve_greedy():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    for day in range(1, D + 1):
        m, mt = -1e10, 0
        for t in range(N):
            a = S[day - 1][t] + (day - lasts[t]) * C[t]
            if a > m:
                mt = t
                m = a
        
        lasts[mt] = day

        neg = sum((day - lasts[t]) * C[t] for t in range(N))
        pos = S[day - 1][t]

        ans[day - 1] = mt
    
    for a in ans:
        print(a + 1)



solve_greedy()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000)
readline = sys.stdin.readline
from collections import deque

def solve_greedy():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    for day in range(1, D + 1):
        m, mt = -1e10, 0
        for t in range(N):
            a = S[day - 1][t] + (day - lasts[t]) * C[t]
            if a > m:
                mt = t
                m = a
        
        lasts[mt] = day

        neg = sum((day - lasts[t]) * C[t] for t in range(N))
        pos = S[day - 1][t]

        ans[day - 1] = mt
    
    for a in ans:
        print(a + 1)


def solve_beam():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    W, DEPTH = 10, 4

    def rec(day, rem):
        if rem == 0 or day > D:
            return 0, 0
        gains = [(S[day - 1][t] + (day - lasts[t]) * C[t], t) for t in range(N)]
        gains.sort(reverse=True)
        max_gain = -1e10
        max_gain_t = 0
        for i in range(W):
            gain, t = gains[i]
            _t = lasts[t]
            lasts[t] = day
            f_gain, _ = rec(day + 1, rem - 1)
            lasts[t] = _t
            gain += f_gain
            if gain > max_gain:
                max_gain = gain
                max_gain_t = t

        return max_gain, max_gain_t

    #_total = 0
    for day in range(D):
        _, t = rec(day, DEPTH)
        lasts[t] = day
        ans[day - 1] = t
        #_total += _
    
    #print(_total)
    for a in ans:
        print(a + 1)


solve_beam()

Fixed submission:
import sys
readline = sys.stdin.readline

def solve_greedy():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    for day in range(1, D + 1):
        m, mt = -1e10, 0
        for t in range(N):
            a = S[day - 1][t] + (day - lasts[t]) * C[t]
            if a > m:
                mt = t
                m = a
        
        lasts[mt] = day

        neg = sum((day - lasts[t]) * C[t] for t in range(N))
        pos = S[day - 1][t]

        ans[day - 1] = mt
    
    for a in ans:
        print(a + 1)



solve_greedy()