Buggy python submission (verdict: Runtime Error):

import random
import copy
import time
def evaluateSatisfaction(d, c, s, ans):
    score = 0
    last = [-1 for i in range(26)]
        
    for i in range(d):
        
        score += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(26):
            if j != ans[i] or True:
                score -= c[j]*(i - last[j])
    return score
    
def valuationFunction(d,c,s,contestType,day,last):
    
    gain = s[day][contestType]
    #78 =  (1/2) * ((13*13) - 13)
    lost = c[contestType] * (78)
    return gain - lost

def Input():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    #s[3][25] =   contest(25+1) of day(3+1)
    return d, c, s

def evolution(d, c, s, ans):
    score_before = evaluateSatisfaction(d, c, s, ans)
    ans_after = copy.copy(ans)

    idx1 = random.randint(0,d-1)
    idx2 = random.randint(0,d-1)
    
    tmp = ans_after[idx1]
    ans_after[idx1] = ans_after[idx2]
    ans_after[idx2] = tmp

    score_after = evaluateSatisfaction(d,c,s,ans_after)

    if score_after > score_before:
        return ans_after
    else:
        return ans

if __name__ == "__main__":
    
    d, c, s = Input()
    
    #print("val =", evaluateSatisfaction(d, c, s, [1, 17, 13, 14, 13]))

    #calc start
    t1 = time.time()
    ans = [0 for i in range(d)]
    last = [-1 for i in range(26)]
    for i in range(d):
        evalValueList = [0 for j in range(26)]
        for j in range(26):
            evalValueList[j] = valuationFunction(d, c, s, j,i,last)

        max_idx = 0
        max = evalValueList[0]

        for j in range(26):
            if (max < evalValueList[j]):
                max_idx = j
                max = evalValueList[j]
        
        ans[i] = max_idx
        last[ans[i]] = i


    ans = [1, 2, 3, 4, 5]
    t2 = time.time()
    while(float(t2-t1) < 1.0):
        ans = evolution(d, c, s, ans)
        #print("ans = ",evaluateSatisfaction(d,c,s,ans))
        t2 = time.time()
    for x in ans:
        print(x+1)

Fixed submission:

import random
import copy
def evaluateSatisfaction(d, c, s, ans):
    score = 0
    last = [-1 for i in range(26)]
        
    for i in range(d):
        
        score += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(26):
            if j != ans[i] or True:
                score -= c[j]*(i - last[j])
    return score
    
def valuationFunction(d,c,s,contestType,day,last):

    return s[day][contestType]

def Input():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    #s[3][25] =   contest(25+1) of day(3+1)
    return d, c, s

def evolution(d, c, s, ans):
    score_before = evaluateSatisfaction(d, c, s, ans)
    ans_after = copy.copy(ans)

    idx1 = random.randint(0,d-1)
    idx2 = random.randint(0,d-1)
    
    tmp = ans_after[idx1]
    ans_after[idx1] = ans_after[idx2]
    ans_after[idx2] = tmp

    score_after = evaluateSatisfaction(d,c,s,ans_after)

    if score_after > score_before:
        return ans_after
    else:
        return ans

if __name__ == "__main__":
    d, c, s = Input()
    
    #print("val =", evaluateSatisfaction(d, c, s, [1, 17, 13, 14, 13]))

    #calc start
    ans = [0 for i in range(d)]
    last = [-1 for i in range(26)]
    for i in range(d):
        evalValueList = [0 for j in range(26)]
        for j in range(26):
            evalValueList[j] = valuationFunction(d, c, s, j,i,last)

        max_idx = 0
        max = evalValueList[0]

        for j in range(26):
            if (max < evalValueList[j]):
                max_idx = j
                max = evalValueList[j]
        
        ans[i] = max_idx
        last[ans[i]] = i


    for i in range(100):
        ans = evolution(d, c, s, ans)
        #print(evaluateSatisfaction(d,c,s,ans))

    for x in ans:
        print(x+1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
D = int(input())
c = list(map(int,input().split()))
s = [ [0 for j in range(26)] for i in range(D)]
for i in range(D):
    tmp = list(map(int,input().split()))
    for j in range(26):
        s[i][j] = tmp[j]
t = []
v = [0] * D
last = [ [0 for j in range(26)] for i in range(D)]
sum = 0
for i in range(D):
    max = -10000
    for j in range(26):
        tmp_sum = sum
        tmp_last = copy.deepcopy(last)
        tmp_sum += s[i][j]
        tmp_last[i][j] = i+1
        for k in range(26):
            tmp_sum -= c[k] * ( (i+1) - tmp_last[i][j] )
        if tmp_sum > max:
            max_j = j
            max = tmp_sum
            last[i][j] = i+1
    sum = max
    t.append(max_j+1)


for i in range(D):
    print(t[i])

Fixed submission:
import copy
D = int(input())
c = list(map(int,input().split()))
s = [ [0 for j in range(26)] for i in range(D)]
for i in range(D):
    tmp = list(map(int,input().split()))
    for j in range(26):
        s[i][j] = tmp[j]
t = []
v = [0] * D
last = [ [0 for j in range(26)] for i in range(D)]
sum = 0
for i in range(D):
    max = -10000
    tmp_last = copy.deepcopy(last)
    for j in range(26):
        tmp_sum = sum
        if j != 0:
            tmp_last[i][j-1] = last[i][j-1]
        tmp_sum += s[i][j]
        tmp_last[i][j] = i+1
        for k in range(26):
            tmp_sum -= c[k] * ( (i+1) - tmp_last[i][j] )
        if tmp_sum > max:
            max_j = j
            max = tmp_sum
            last[i][j] = i+1
    sum = max
    t.append(max_j+1)


for i in range(D):
    print(t[i])