Buggy python submission (verdict: Time Limit Exceeded):
""" 局所探索の例 """
import numpy as np
import sys
import random

input = sys.stdin.readline


contest_types = 26
days = int(input())
cs = list(map(int, input().strip().split()))
ss = [list(map(int, input().strip().split())) for _ in range(days)]
# ts = [int(input()) - 1 for _ in range(days)] # 0 始まりにする

# m = int(input())
# queries = [list(map(int, input().strip().split())) for _ in range(m)]
# queries = np.array(queries, dtype=np.int32)
# queries -= 1  # 0始まりにする


# コンテストごとの開催日
def calc_contest_dict(ts):
    contest_dict = [[-1, days] for _ in range(contest_types)]
    for d, t in enumerate(ts):
        contest_dict[t].append(d)

    for contest_days in contest_dict:
        contest_days.sort()

    return contest_dict


def count_block(contest_days):
    block = 0
    for i in range(len(contest_days) - 1):
        period = contest_days[i + 1] - contest_days[i]
        block += period * (period - 1) // 2
    return block


def calc_score(cs, ss, ts):
    contest_dict = calc_contest_dict(ts)
    # 満足度
    satisfaction = 0
    # 開催されることによる増加分
    for d, t in enumerate(ts):
        satisfaction += ss[d][t]

    # 減少分
    for t, contest_days in enumerate(contest_dict):
        decrease = cs[t] * count_block(contest_days)
        satisfaction -= decrease

    return satisfaction


def greedy():
    last_days = np.array([-1] * contest_types, dtype=np.int32)
    results = [0] * days

    for d in range(days):
        max_diff = - 1e9
        max_c_type = None
        for t in range(contest_types):
            diff = ss[d][t] - np.sum(cs * (d - last_days)) \
                   + cs[t] * (d - last_days[t])

            if diff > max_diff:
                max_diff = diff
                max_c_type = t

        results[d] = max_c_type

    return results


ts = greedy()
best_score = calc_score(cs, ss, ts)
contest_dict = calc_contest_dict(ts)
best_ts = ts

for i in range(50000):
    d, q = random.randint(0, days - 1), random.randint(0, contest_types - 1)
    old_t = ts[d]
    new_t = q
    old_decrease = cs[old_t] * count_block(contest_dict[old_t]) \
                 + cs[new_t] * count_block(contest_dict[new_t])
    ts[d] = new_t
    contest_dict = calc_contest_dict(ts)
    open_diff = ss[d][new_t] - ss[d][old_t]

    new_decrease = cs[old_t] * count_block(contest_dict[old_t]) \
                 + cs[new_t] * count_block(contest_dict[new_t])

    diff = open_diff + old_decrease - new_decrease

    if best_score + diff > best_score:
        best_score = best_score + diff
        # print(best_score)
    else:
        # 戻す
        ts[d] = old_t

for t in ts:
    print(t + 1)


Fixed submission:
""" 貪欲法での攻略 """

import numpy as np

contest_types = 26
days = int(input())
cs = list(map(int, input().strip().split()))
ss = [list(map(int, input().strip().split())) for _ in range(days)]

cs = np.array(cs, dtype=np.int32)
ss = np.array(ss, dtype=np.int32)

last_days = np.array([-1] * contest_types, dtype=np.int32)
results = [0] * days

satisfaction = 0

for d in range(days):
    max_diff = - 1e9
    max_c_type = None
    for t in range(contest_types):
        diff = ss[d][t] - np.sum(cs * (d - last_days)) \
                        + cs[t] * (d - last_days[t])

        if diff > max_diff:
            max_diff = diff
            max_c_type = t

    results[d] = max_c_type

# 結果の出力
for t in results:
    print(t + 1)

Buggy python submission (verdict: Time Limit Exceeded):
""" 局所探索の例 """
import numpy as np
import sys
import random

input = sys.stdin.readline


contest_types = 26
days = int(input())
cs = list(map(int, input().strip().split()))
ss = [list(map(int, input().strip().split())) for _ in range(days)]
# ts = [int(input()) - 1 for _ in range(days)] # 0 始まりにする

# m = int(input())
# queries = [list(map(int, input().strip().split())) for _ in range(m)]
# queries = np.array(queries, dtype=np.int32)
# queries -= 1  # 0始まりにする


# コンテストごとの開催日
def calc_contest_dict(ts):
    contest_dict = [[-1, days] for _ in range(contest_types)]
    for d, t in enumerate(ts):
        contest_dict[t].append(d)

    for contest_days in contest_dict:
        contest_days.sort()

    return contest_dict


def count_block(contest_days):
    block = 0
    for i in range(len(contest_days) - 1):
        period = contest_days[i + 1] - contest_days[i]
        block += period * (period - 1) // 2
    return block


def calc_score(cs, ss, ts):
    contest_dict = calc_contest_dict(ts)
    # 満足度
    satisfaction = 0
    # 開催されることによる増加分
    for d, t in enumerate(ts):
        satisfaction += ss[d][t]

    # 減少分
    for t, contest_days in enumerate(contest_dict):
        decrease = cs[t] * count_block(contest_days)
        satisfaction -= decrease

    return satisfaction


def greedy():
    last_days = np.array([-1] * contest_types, dtype=np.int32)
    results = [0] * days

    for d in range(days):
        max_diff = - 1e9
        max_c_type = None
        for t in range(contest_types):
            diff = ss[d][t] - np.sum(cs * (d - last_days)) \
                   + cs[t] * (d - last_days[t])

            if diff > max_diff:
                max_diff = diff
                max_c_type = t

        results[d] = max_c_type

    return results


ts = greedy()
best_score = calc_score(cs, ss, ts)
contest_dict = calc_contest_dict(ts)
best_ts = ts

for i in range(100000):
    d, q = random.randint(0, days - 1), random.randint(0, contest_types - 1)
    old_t = ts[d]
    new_t = q
    old_decrease = cs[old_t] * count_block(contest_dict[old_t]) \
                 + cs[new_t] * count_block(contest_dict[new_t])
    ts[d] = new_t
    contest_dict = calc_contest_dict(ts)
    open_diff = ss[d][new_t] - ss[d][old_t]

    new_decrease = cs[old_t] * count_block(contest_dict[old_t]) \
                 + cs[new_t] * count_block(contest_dict[new_t])

    diff = open_diff + old_decrease - new_decrease

    if best_score + diff > best_score:
        best_score = best_score + diff
        print(best_score)
    else:
        # 戻す
        ts[d] = old_t





Fixed submission:
""" 貪欲法での攻略 """

import numpy as np

contest_types = 26
days = int(input())
cs = list(map(int, input().strip().split()))
ss = [list(map(int, input().strip().split())) for _ in range(days)]

cs = np.array(cs, dtype=np.int32)
ss = np.array(ss, dtype=np.int32)

last_days = np.array([-1] * contest_types, dtype=np.int32)
results = [0] * days

satisfaction = 0

for d in range(days):
    max_diff = - 1e9
    max_c_type = None
    for t in range(contest_types):
        diff = ss[d][t] - np.sum(cs * (d - last_days)) \
                        + cs[t] * (d - last_days[t])

        if diff > max_diff:
            max_diff = diff
            max_c_type = t

    results[d] = max_c_type

# 結果の出力
for t in results:
    print(t + 1)