Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import random
random.seed(0)

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

answer = []
L = [0 for _ in range(26)]
for S in list_S:
  contest_index = -1
  contest_manzoku = -10**9
  for i in range(26):
    i_manzoku = S[i]+C[i]+L[i]
    if i_manzoku > contest_manzoku:
      contest_index = i
      contest_manzoku = i_manzoku
  answer.append(contest_index)
  for i in range(26):
    if i==contest_index:
      L[i] = 0
    else:
      L[i] += C[i]

def manzoku(A):
  score = 0
  L = [0 for _ in range(26)]
  for i in range(D):
    contest_index = A[i]
    for j in range(26):
      if j==contest_index:
        L[j] = 0
        score += S[i][contest_index]
      else:
        L[j] += C[j]
        score -= L[j] 
  return score

manzoku_now = manzoku(answer)
answer_tmp = [answer[i] for i in range(D)]
for j in range(365):
  day = j%D
  contest = random.randrange(26)
  answer_tmp = [answer[i] for i in range(D)]
  answer_tmp[day] = contest
  manzoku_tmp = manzoku(answer_tmp)
  if manzoku_now < manzoku_tmp:
    manzoku_now = manzoku_tmp
    answer[day] = contest
  else:
    answer_tmp[day] = answer[day]

for index in answer:
  print(index+1)

Fixed submission:
# -*- coding: utf-8 -*-

D = int(input())
C = list(map(int, input().split()))
L = [0 for _ in range(26)]

for _ in range(1,D+1):
  S = list(map(int, input().split()))
  contest_index = -1
  contest_manzoku = -10**9
  for i in range(26):
    i_manzoku = S[i]+C[i]+L[i]
    if i_manzoku > contest_manzoku:
      contest_index = i
      contest_manzoku = i_manzoku
  print(contest_index+1)
  for i in range(26):
    if i==contest_index:
      L[i] = 0
    else:
      L[i] += C[i]

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import random
random.seed(0)

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

answer = []

def manzoku(A):
  score = 0
  L = [0 for _ in range(26)]
  for i in range(D):
    S = list_S[i]
    contest_index = A[i]
    for j in range(26):
      if j==contest_index:
        L[j] = 0
        score += S[j]
      else:
        L[j] += C[j]
        score -= L[j] 
  return score

L = [0 for _ in range(26)]
for S in list_S:
  contest_index = -1
  contest_manzoku = -10**9
  for i in range(26):
    i_manzoku = S[i]+C[i]+L[i]
    if i_manzoku > contest_manzoku:
      contest_index = i
      contest_manzoku = i_manzoku
  answer.append(contest_index)
  for i in range(26):
    if i==contest_index:
      L[i] = 0
    else:
      L[i] += C[i]

manzoku_now = manzoku(answer)

answer_tmp = [answer[i] for i in range(D)]
for _ in range(10000):
  day = random.randrange(D)
  contest = random.randrange(26)
  answer_tmp = [answer[i] for i in range(D)]
  answer_tmp[day] = contest
  if manzoku_now < manzoku(answer_tmp):
    answer[day] = contest
  else:
    answer_tmp[day] = answer[day]

print(manzoku(answer))
for index in answer:
  print(index+1)

Fixed submission:
# -*- coding: utf-8 -*-

D = int(input())
C = list(map(int, input().split()))
L = [0 for _ in range(26)]

for _ in range(1,D+1):
  S = list(map(int, input().split()))
  contest_index = -1
  contest_manzoku = -10**9
  for i in range(26):
    i_manzoku = S[i]+C[i]+L[i]
    if i_manzoku > contest_manzoku:
      contest_index = i
      contest_manzoku = i_manzoku
  print(contest_index+1)
  for i in range(26):
    if i==contest_index:
      L[i] = 0
    else:
      L[i] += C[i]