Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.
def get_score(day, contest, prev_list, loss_list, satisfied_matrix):
    plus = satisfied_matrix[day][contest]
    minus = 0
    for type, prev in enumerate(prev_list):
        if type == contest:
            continue
        spend = day - prev
        minus += loss_list[type] * spend

    return plus - minus



days = int(input())
loss_list = list(map(int, input().split()))
satisfied_matrix = [list(map(int, input().split())) for _ in range(days)]

prev_list = [-1] * 26

ans = []
for day in range(days):
    best_contest = 0
    best_score = 0
    for contest in range(26):
        score = get_score(day, contest, prev_list, loss_list, satisfied_matrix)
        if score > best_score:
            best_contest = contest
            best_score = score

    ans.append(best_contest)
    prev_list[best_contest] = day

print(*ans, sep="\n")

def score(day, contest, prev_list, loss_list, satisfied_matrix):
    plus = satisfied_matrix[day][contest]
    minus = 0
    for type, prev in enumerate(prev_list):
        spend = day - prev
        minus += loss_list[type] * spend

    return plus - minus



days = int(input())
loss_list = list(map(int, input().split()))
satisfied_matrix = [list(map(int, input().split())) for _ in range(days)]

prev_list = [-1] * 26

total = 0
for day in range(days):
    contest = int(input())
    prev_list[contest-1] = day
    total += score(day, contest-1, prev_list, loss_list, satisfied_matrix)
    print(total)