Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import time
# from datetime import datetime
# import math
import random                                # random, uniform, randint, randrange, shuffle, sample
from random import randint
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')



def main():
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    inf = 10**15
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    
    
    def calc_total_score(schedule):
        ans = []
        last = [-1] * 26
        satisfy = 0
        for day in range(D):
            contest_id = schedule[day]
            last[contest_id] = day
            satisfy += score[day][contest_id]
            for i in range(26):
                satisfy -= c[i] * (day - last[i])
            ans.append(satisfy)
        return ans
    

    def change_contest(schedule, target_day, new_contest):
        # print(schedule, target_day, new_contest)
        prev_contest = schedule[target_day]
        diff = 0
        diff += (score[target_day][new_contest] - score[target_day][prev_contest])
        i = target_day - 1
        while i >= 0:
            if schedule[i] == prev_contest:
                break
            i -= 1
        j = target_day + 1
        while j <= len(schedule) - 1:
            if schedule[j] == prev_contest:
                break
            j += 1
        diff -= (j - target_day) * (target_day - i) * c[prev_contest]
        i = target_day - 1
        while i >= 0:
            if schedule[i] == new_contest:
                break
            i -= 1
        j = target_day + 1
        while j <= len(schedule) - 1:
            if schedule[j] == new_contest:
                break
            j += 1
        diff += (j - target_day) * (target_day - i) * c[new_contest]
        schedule[target_day] = new_contest
        return diff
    

    def build_greedy_schedule():
        schedule = []
        last = [-1] * 26
        for day in range(D):
            decided = None
            best_diff = -inf
            for contest in range(26):
                tmp = 0
                tmp += score[day][contest]
                for i in range(26):
                    if i != contest:
                        tmp -= c[i] * (day - last[i])
                if best_diff < tmp:
                    decided = contest
                    best_diff = tmp
            last[decided] = day
            schedule.append(decided)
        return schedule


    def solve():
        schedule = build_greedy_schedule()
        satisfy = calc_total_score(schedule)[-1]
        while True:
            if time.time() - start >= deadline:
                break
            # 改善を行う
            target_day = randint(0, D-1)
            while True:
                new_contest = randint(0, 25)
                if new_contest != schedule[target_day]:
                    break
            prev_contest = schedule[target_day]
            diff = change_contest(schedule, target_day, new_contest)
            if diff > 0:
                # 採用
                satisfy += diff
            else:
                # role back
                schedule[target_day] = prev_contest
        return schedule, satisfy



    
    start = time.time()
    deadline = 1.96
    D = ii()
    c = lmi()
    score = [lmi() for _ in range(D)]

    final_schedule, final_satisfy = solve()
    print(*final_schedule, sep='\n')

    # print(f'score... {max(10**6 + final_satisfy, 0)}')



if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3

import sys
import time
# from datetime import datetime
# import math
import random                                # random, uniform, randint, randrange, shuffle, sample
from random import randint
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')



def main():
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    inf = 10**15
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    
    
    def calc_total_score(schedule):
        ans = []
        last = [-1] * 26
        satisfy = 0
        for day in range(D):
            contest_id = schedule[day]
            last[contest_id] = day
            satisfy += score[day][contest_id]
            for i in range(26):
                satisfy -= c[i] * (day - last[i])
            ans.append(satisfy)
        return ans
    

    def change_contest(schedule, target_day, new_contest):
        # print(schedule, target_day, new_contest)
        prev_contest = schedule[target_day]
        diff = 0
        diff += (score[target_day][new_contest] - score[target_day][prev_contest])
        i = target_day - 1
        while i >= 0:
            if schedule[i] == prev_contest:
                break
            i -= 1
        j = target_day + 1
        while j <= len(schedule) - 1:
            if schedule[j] == prev_contest:
                break
            j += 1
        diff -= (j - target_day) * (target_day - i) * c[prev_contest]
        i = target_day - 1
        while i >= 0:
            if schedule[i] == new_contest:
                break
            i -= 1
        j = target_day + 1
        while j <= len(schedule) - 1:
            if schedule[j] == new_contest:
                break
            j += 1
        diff += (j - target_day) * (target_day - i) * c[new_contest]
        schedule[target_day] = new_contest
        return diff
    

    def build_greedy_schedule():
        schedule = []
        last = [-1] * 26
        for day in range(D):
            decided = None
            best_diff = -inf
            for contest in range(26):
                tmp = 0
                tmp += score[day][contest]
                for i in range(26):
                    if i != contest:
                        tmp -= c[i] * (day - last[i])
                if best_diff < tmp:
                    decided = contest
                    best_diff = tmp
            last[decided] = day
            schedule.append(decided)
        return schedule


    def solve():
        schedule = build_greedy_schedule()
        satisfy = calc_total_score(schedule)[-1]
        while True:
            if time.time() - start >= deadline:
                break
            # 改善を行う
            target_day = randint(0, D-1)
            while True:
                new_contest = randint(0, 25)
                if new_contest != schedule[target_day]:
                    break
            prev_contest = schedule[target_day]
            diff = change_contest(schedule, target_day, new_contest)
            if diff > bound:
                # 採用
                satisfy += diff
            elif diff > - bound and randint(0, 10)==0:
                # 少し悪くなるけど受け入れる
                satisfy += diff
            else:
                # role back
                schedule[target_day] = prev_contest
        return schedule, satisfy



    
    start = time.time()
    deadline = 1.6
    D = ii()
    c = lmi()
    score = [lmi() for _ in range(D)]
    avg = sum([sum(line) for line in score]) / (D * 26)
    bound = avg/100

    final_schedule, final_satisfy = solve()
    for contest in final_schedule:
        print(contest + 1)

    # print(f'score... {max(10**6 + final_satisfy, 0)}')



if __name__ == "__main__":
    main()