Problem:
   Problem Statement AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for D days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows.   The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative.  Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type i on day d will increase the satisfaction by s_{d,i} .  If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type i has an integer c_i , and at the end of each day d=1,2,...,D , the satisfaction decreases as follows. Let \mathrm{last}(d,i) be the last day before day d (including d ) on which a contest of type i was held. If contests of type i have never been held yet, we define \mathrm{last}(d,i)=0 . At the end of day d , the satisfaction decreases by \sum _{i=1}^{26}c_i \times (d-\mathrm{last}(d,i)) .   Please schedule contests on behalf of AtCoder.
If the satisfaction at the end of day D is S , you will get a score of \max(10^6 + S, 0) .
There are 50 test cases, and the score of a submission is the total scores for each test case.
You can make submissions multiple times, and the highest score among your submissions will be your score.      Constraints  D = 365  Each c_i is an integer satisfying 0\leq c_i \leq 100 .  Each s_{d,i} is an integer satisfying 0\leq s_{d,i} \leq 20000 .         Input Input is given from Standard Input in the following format:  D  c_1  c_2  \cdots  c_{26}  s_{1,1}  s_{1,2}  \cdots  s_{1,26}  \vdots  s_{D,1}  s_{D,2}  \cdots  s_{D,26}       Output Let t_d ( 1\leq t_d \leq 26 ) be the type of the contest that will be held at day d .
Print D integers t_d to Standard Output in the following format:  t_1  t_2  \vdots  t_D   Any output that does not follow the above format may result in 0 points WA for that test case.      Input Generation Each integer c_i and s_{d,i} is generated independently and uniformly at random from the integers in the range described in the problem statement.        Sample Input 1 5
86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82
19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424
6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570
6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256
8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452
19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192      Sample Output 1 1
17
13
14
13  Note that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case. The final satisfaction with this output is 79325, so the score is 1079325.  Input generator, score calculator, and visualizer      Beginner's Guide If you don't know what to do, proceed to problem B or C.

Solution (Python):
import copy as cp
import time
import random


t_start = time.time()
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    new = [int(i) for i in input().split()]
    s.append(new)


def score(ans):
    if len(ans) != D:
        print("wrong length")
        return 0
    else:
        p = 0
        last = [-1]*26
        for i in range(D):
            contest = ans[i]-1
            p += s[i][contest]
            last[contest] = i
            for j in range(26):
                p -= c[j]*(i-last[j])
        return p

def greedy(ahead=0):
    ans = []
    p = 0
    last = [-1]*26
    for i in range(D):
        decay = 0
        for j in range(26):
            decay -= c[j]*(i-last[j])
            
        max_j = -1
        max_plus_mod = decay
        max_plus = decay
        for j in range(26):
            plus = s[i][j] + c[j]*(i-last[j])
            modify = c[j]*(ahead*(i-last[j])+ahead*(ahead+1)//2)
            if (plus+modify) > max_plus_mod:
                max_plus = plus
                max_plus_mod = plus+modify
                max_j = j
        ans.append(max_j+1)
        last[max_j]=i
        p += max_plus + decay
    return ans, p

def schedule(ans):
    dates = [[] for i in range(26)]
    for i in range(D):
        dates[ans[i]-1].append(i)
    return dates

def swap(ans):
    ans_temp = cp.copy(ans)
    t1 = random.randint(0,D-1)
    t2 = random.randint(0,D-1)
    temp = ans_temp[t1]
    ans_temp[t1] = ans_temp[t2]
    ans_temp[t2] = temp
    return ans_temp

def change(ans):
    ans_temp = cp.copy(ans)
    t = random.randint(0,D-1)
    A = random.randint(1,26)
    ans_temp[t] = A
    return ans_temp

        

max_points = -10000000
for k in range(20):
    ans_temp, points = greedy(ahead = k)
    
    if points > max_points:
        max_points = points
        ans = cp.copy(ans_temp)
        
dates = schedule(ans)

count = 0
while True:
    if count % 100 == 0:
        t_now = time.time()
        if t_now-t_start > 1.8:
            break
    r = random.randint(0,1)
    if r == 0:
        ans_temp = swap(ans)
        points_temp = score(ans_temp)
    else:
        ans_temp = change(ans)
        points_temp = score(ans_temp)
    
    if points_temp > points:
        points = points_temp
        ans = cp.copy(ans_temp)


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

Solution (Python):
D=int(input())
*c,=map(int,input().split())
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

dt=[]
last=[-1]*26
v=0
for d in range(D):
    news=[s[d][i]-c[i]*((d+10)-last[i])*((d+10)-last[i]-1)//2 for i in range(26)]
    maxi=0
    tmp=-float('inf')
    for i in range(26):
        if tmp<news[i]:
            maxi=i
            tmp=news[i]
    last[maxi]=d
    v+=s[d][maxi]
    for i in range(26):
        v-=c[i]*(d-last[i])
    dt.append(maxi+1)

for i in dt:
    print(i)

Solution (Python):
D=int(input())
*c,=map(int,input().split())
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

dt=[]
last=[-1]*26
v=0
for d in range(D):
    news=[s[d][i]+c[i]*(d-last[i])*(d-last[i]-1)//2 for i in range(26)]
    maxi=0
    tmp=-float('inf')
    for i in range(26):
        if tmp<news[i]:
            maxi=i
            tmp=news[i]
    last[maxi]=d
    v+=s[d][maxi]
    for i in range(26):
        v-=c[i]*(d-last[i])
    dt.append(maxi+1)

for i in dt:
    print(i)

Solution (Python):
D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
    s.append(list(map(int,input().split())))

last=[0]*26
ans=0
for d in range(1,D+1):
    mx=-3650000
    mxt=-1

    for j in range(26):
        temp=last[j]
        last[j]=d
        score=0
        for i in range(26):
           score-=c[i]*(d-last[i])
        score+=s[d-1][j]

        if mx<score:
            mx=score
            mxt=j
        last[j]=temp
    last[mxt]=d

    print(mxt+1)

Solution (Python):
D=int(input())
*c,=map(int,input().split())
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

dt=[]
last=[-1]*26
v=0
for d in range(D):
    news=[s[d][i]-c[i]*(d-last[i]) for i in range(26)]
    maxi=0
    tmp=-float('inf')
    for i in range(26):
        if tmp<news[i]:
            maxi=i
            tmp=news[i]
    last[maxi]=d
    v+=s[d][maxi]
    for i in range(26):
        v-=c[i]*(d-last[i])
    dt.append(maxi+1)

for i in dt:
    print(i)

Solution (Python):
from copy import copy
import random
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
T = 300
for i in range(42000):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    if x == y:
        continue
    na[x-1],na[y-1] = na[y-1],na[x-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
    T *= 0.99
for a in ans:
    print(a)

Solution (Python):
from copy import copy
import random
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
T = 3000
for i in range(40000):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    if x == y:
        continue
    na[x-1],na[y-1] = na[y-1],na[x-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
    T *= 0.99
for a in ans:
    print(a)

Solution (Python):
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
k = [-1] * 26
for i in range(d):
    res = -100000000
    p = 0
    for j in range(26):
        tmp = 0
        tmp += s[i][j]
        for x in range(26):
            if x == j:
                continue
            tmp -= c[x] * (i - k[x] + 6)
        if res < tmp:
            res = tmp
            p = j
    k[p] = i
    print(p + 1)

Solution (Python):
import random
import numpy as np


D=int(input())
C=np.array(list(map(int,input().split())))
S=[]
for _ in range(D):
    S.append(list(map(int,input().split())))




l=np.zeros(26,int)

def decrease(d):
    return np.dot(C,(d-l))

def pick(i,l):
    diff=[]
    ll=l.copy()
    for j in range(26):
        ll[j]=i
        diff.append(S[i][j]-decrease(i))
    return np.argmax(diff)+1


for i in range(D):
    p=pick(i,l)
    print(p)
    l[p-1]=i+1

Solution (Python):
import copy as cp

D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    new = [int(i) for i in input().split()]
    s.append(new)


def score(ans):
    if len(ans) != D:
        print("wrong length")
        return 0
    else:
        p = 0
        last = [-1]*26
        for i in range(D):
            contest = ans[i]-1
            p += s[i][contest]
            last[contest] = i
            for j in range(26):
                p -= c[j]*(i-last[j])
        return p

def greedy(ahead=0):
    ans = []
    p = 0
    last = [-1]*26
    for i in range(D):
        decay = 0
        for j in range(26):
            decay -= c[j]*(i-last[j])
            
        max_j = -1
        max_plus_mod = decay
        max_plus = decay
        for j in range(26):
            plus = s[i][j] + c[j]*(i-last[j])
            modify = c[j]*(ahead*(i-last[j])+ahead*(ahead+1)//2)
            if (plus+modify) > max_plus_mod:
                max_plus = plus
                max_plus_mod = plus+modify
                max_j = j
        ans.append(max_j+1)
        last[max_j]=i
        p += max_plus + decay
    return ans, p
        

max_points = -10000000
for k in range(20):
    ans_temp, points = greedy(ahead = k)
    
    if points > max_points:
        max_points = points
        ans = cp.copy(ans_temp)

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

Solution (Python):
import copy as cp

D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    new = [int(i) for i in input().split()]
    s.append(new)


def score(ans):
    if len(ans) != D:
        print("wrong length")
        return 0
    else:
        p = 0
        last = [-1]*26
        for i in range(D):
            contest = ans[i]-1
            p += s[i][contest]
            last[contest] = i
            for j in range(26):
                p -= c[j]*(i-last[j])
        return p

def greedy(ahead=0):
    ans = []
    p = 0
    last = [-1]*26
    for i in range(D):
        decay = 0
        for j in range(26):
            decay -= c[j]*(i-last[j])
            
        max_j = -1
        max_plus = decay
        for j in range(26):
            plus = s[i][j] + c[j]*(i-last[j]) + c[j]*(ahead*(i-last[j])+ahead*(ahead+1)//2)
            if plus > max_plus:
                max_plus = plus
                max_j = j
        ans.append(max_j+1)
        last[max_j]=i
        p += max_plus + decay - c[max_j]*ahead
    return ans, p
        

max_points = -10000000
for k in range(20):
    ans_temp, points = greedy(ahead = k)
    if points > max_points:
        max_points = points
        ans = cp.copy(ans_temp)

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

Solution (Python):
import random
import numpy as np


D=int(input())
C=np.array(list(map(int,input().split())))
S=[]
for _ in range(D):
    S.append(list(map(int,input().split())))


T=[]
for i in range(D):
    print(np.argmax(S[i])+1)

Solution (Python):


D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    new = [int(i) for i in input().split()]
    s.append(new)


def score(ans):
    if len(ans) != D:
        print("wrong length")
        return 0
    else:
        p = 0
        last = [-1]*26
        for i in range(D):
            contest = ans[i]-1
            p += s[i][contest]
            last[contest] = i
            for j in range(26):
                p -= c[j]*(i-last[j])
        return p

def greedy():
    ans = []
    p = 0
    last = [-1]*26
    for i in range(D):
        decay = 0
        for j in range(26):
            decay -= c[j]*(i-last[j])
            
        max_j = -1
        max_plus = decay
        for j in range(26):
            plus = s[i][j] + c[j]*(i-last[j])
            if plus > max_plus:
                max_plus = plus
                max_j = j
        ans.append(max_j+1)
        last[max_j]=i
        p += max_plus + decay
    return ans, p
        

ans, points = greedy()


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

Solution (Python):
def resolve():
    D = int(input())
    C = [int(x) for x in input().split()]
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))
    last_d = []
    score = 0

    
    for d in range(D):
        contest = 0
        for i in range(len(C)):  
            contest = max(contest, S[d][i])
        score += contest
        last_d.append(S[d].index(contest))  
        for i in range(len(C)):
            if i in last_d:
                score -= C[i] * last_d[::-1].index(i)
            else:
                score -= C[i] * (d + 1)
        print(S[d].index(contest) + 1)

    
if __name__ == "__main__":
    resolve()

Solution (Python):
from copy import copy
import random
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for i in range(40000):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    if x == y:
        continue
    na[x-1],na[y-1] = na[y-1],na[x-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    if ns > score:
        ans = na
        score = ns
for a in ans:
    print(a)

Solution (Python):
d = int(input())
cs = list(map(int, input().split()))
sm = [list(map(int, input().split())) for _ in range(d)]

import random
for i in range(d):
    mx = max(sm[i])
    t = sm[i].index(mx) + 1
    print(t)

Solution (Python):
import numpy as np
import copy
D = int(input())
c_list = np.array(list(map(int,input().split())))
s_list = [list(map(int,input().split())) for _ in range(D)]
last_d_list = np.array([0]*26)
s_max_list = [np.argmax(s_row) for s_row in s_list]

for day,s_row in enumerate(s_list):
    choice_d = None
    max_reward = -1
    for i,last_d in enumerate(last_d_list):
        reward = s_row[i] + (last_d+1)*c_list[i]
        next_max_reward = -1
        for j,new_last_d in enumerate(last_d_list):
            if day+1==len(s_list):
                break
            if j!=i:
                next_reward = s_list[day+1][j] + (new_last_d+2)*c_list[j]
            else:
                next_reward = s_list[day+1][j] + c_list[j]
            if next_reward > next_max_reward:
                next_max_reward = next_reward
        reward += next_max_reward
        if reward > max_reward:
            max_reward = reward
            choice_d = i
    last_d_list+=1
    last_d_list[choice_d] = 0
    
    print(choice_d+1)

Solution (Python):
import numpy as np
D = int(input())
c_list = np.array(list(map(int,input().split())))
s_list = [list(map(int,input().split())) for _ in range(D)]
last_d_list = np.array([0]*26)
for s_row in s_list:
    choice_d = None
    max_reward = -1
    for i,last_d in enumerate(last_d_list):
        reward = s_row[i] + (last_d+1)*c_list[i]
        if reward > max_reward:
            max_reward = reward
            choice_d = i
    last_d_list+=1
    last_d_list[choice_d] = 0
    
    print(choice_d+1)

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	D = inputInt()
	C = inputList()
	S = []
	for i in range(D):
		s = inputList()
		S.append(s)

	ans1 = []
	ans2 = []
	ans3 = []
	ans4 = []
	for i in range(D):
		bestSco1 = 0
		bestSco2 = 0
		bestSco3 = 0
		bestSco4 = 0
		bestI1 = 1
		bestI2 = 1
		bestI3 = 1
		bestI4 = 1

		for j,val in enumerate(S[i]):
			if j == 0:
				tmpAns = ans1 + [j+1]
				tmpSco = findScore(tmpAns, S, C)
				if bestSco1 < tmpSco:
					bestSco4 = bestSco3
					bestI4 = bestI3
					bestSco3 = bestSco2
					bestI3 = bestI2
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco
					bestI1 = j+1
			else:
				tmpAns1 = ans1 + [j+1]
				tmpAns2 = ans2 + [j+1]
				tmpAns3 = ans3 + [j+1]
				tmpAns4 = ans4 + [j+1]
				tmpSco1 = findScore(tmpAns1, S, C)
				tmpSco2 = findScore(tmpAns2, S, C)
				tmpSco3 = findScore(tmpAns3, S, C)
				tmpSco4 = findScore(tmpAns4, S, C)
				if bestSco1 < tmpSco1:
					bestSco1 = tmpSco1
					bestI1 = j+1
				if bestSco2 < tmpSco2:
					bestSco2 = tmpSco2
					bestI2 = j+1
				if bestSco3 < tmpSco3:
					bestSco3 = tmpSco3
					bestI3 = j+1
				if bestSco4 < tmpSco4:
					bestSco4 = tmpSco4
					bestI4 = j+1
		ans1.append(bestI1)
		ans2.append(bestI2)
		ans3.append(bestI3)
		ans4.append(bestI4)

	aa = []
	aa.append(bestSco1)
	aa.append(bestSco2)
	aa.append(bestSco3)
	aa.append(bestSco4)
	aa.sort()
	aa = aa[::-1]

	if aa[0] == bestSco1:
		for i in ans1:
			print(i)
	elif aa[0] == bestSco2:
		for i in ans2:
			print(i)
	elif aa[0] == bestSco3:
		for i in ans3:
			print(i)
	elif aa[0] == bestSco4:
		for i in ans4:
			print(i)


def findScore(ans, S, C):
	scezhu = [inf for i in range(26)]
	sco = 0
	for i,val in enumerate(ans):
		tmp = S[i][val-1]
		scezhu[val-1] = i
		mins = 0
		for j,vol in enumerate(C):
			if scezhu[j] == inf:
				mins = mins + (vol * (i+1))
			else:
				mins = mins + (vol * ((i+1)-(scezhu[j]+1)))
		tmp -= mins
		sco += tmp
	return sco



if __name__ == "__main__":
	main()

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	D = inputInt()
	C = inputList()
	S = []
	for i in range(D):
		s = inputList()
		S.append(s)

	ans1 = []
	ans2 = []
	ans3 = []
	ans4 = []
	for i in range(D):
		bestSco1 = 0
		bestSco2 = 0
		bestSco3 = 0
		bestSco4 = 0
		bestI1 = 1
		bestI2 = 1
		bestI3 = 1
		bestI4 = 1

		for j,val in enumerate(S[i]):
			if j == 0:
				tmpAns = ans1 + [j+1]
				tmpSco = findScore(tmpAns, S, C)
				if bestSco1 < tmpSco:
					bestSco4 = bestSco3
					bestI4 = bestI3
					bestSco3 = bestSco2
					bestI3 = bestI2
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco
					bestI1 = j+1
			else:
				tmpAns1 = ans1 + [j+1]
				tmpAns2 = ans2 + [j+1]
				tmpAns3 = ans3 + [j+1]
				tmpAns4 = ans4 + [j+1]
				tmpSco1 = findScore(tmpAns1, S, C)
				tmpSco2 = findScore(tmpAns2, S, C)
				tmpSco3 = findScore(tmpAns3, S, C)
				tmpSco4 = findScore(tmpAns4, S, C)
				if bestSco1 < tmpSco1:
					bestSco1 = tmpSco1
					bestI1 = j+1
				if bestSco2 < tmpSco2:
					bestSco2 = tmpSco2
					bestI2 = j+1
				if bestSco3 < tmpSco3:
					bestSco3 = tmpSco3
					bestI3 = j+1
				if bestSco4 < tmpSco4:
					bestSco4 = tmpSco4
					bestI4 = j+1
		ans1.append(bestI1)
		ans2.append(bestI2)
		ans3.append(bestI3)
		ans4.append(bestI4)

	aa = []
	aa.append(bestSco1)
	aa.append(bestSco2)
	aa.append(bestSco3)
	aa.append(bestSco4)
	aa.sort()

	if aa[0] == bestSco1:
		for i in ans1:
			print(i)
	elif aa[0] == bestSco2:
		for i in ans2:
			print(i)
	elif aa[0] == bestSco3:
		for i in ans3:
			print(i)
	elif aa[0] == bestSco4:
		for i in ans4:
			print(i)


def findScore(ans, S, C):
	scezhu = [inf for i in range(26)]
	sco = 0
	for i,val in enumerate(ans):
		tmp = S[i][val-1]
		scezhu[val-1] = i
		mins = 0
		for j,vol in enumerate(C):
			if scezhu[j] == inf:
				mins = mins + (vol * (i+1))
			else:
				mins = mins + (vol * ((i+1)-(scezhu[j]+1)))
		tmp -= mins
		sco += tmp
	return sco



if __name__ == "__main__":
	main()

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	D = inputInt()
	C = inputList()
	S = []
	for i in range(D):
		s = inputList()
		S.append(s)

	ans1 = []
	ans2 = []
	ans3 = []
	ans4 = []
	ans5 = []
	for i in range(D):
		bestSco1 = 0
		bestSco2 = 0
		bestSco3 = 0
		bestSco4 = 0
		bestSco5 = 0
		bestI1 = 1
		bestI2 = 1
		bestI3 = 1
		bestI4 = 1
		bestI5 = 1

		for j,val in enumerate(S[i]):
			if j == 0:
				tmpAns = ans1 + [j+1]
				tmpSco = findScore(tmpAns, S, C)
				if bestSco1 < tmpSco:
					bestSco5 = bestSco4
					bestI5 = bestI4
					bestSco4 = bestSco3
					bestI4 = bestI3
					bestSco3 = bestSco2
					bestI3 = bestI2
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco
					bestI1 = j+1
			else:
				tmpAns1 = ans1 + [j+1]
				tmpAns2 = ans2 + [j+1]
				tmpAns3 = ans3 + [j+1]
				tmpAns4 = ans4 + [j+1]
				tmpAns5 = ans5 + [j+1]
				tmpSco1 = findScore(tmpAns1, S, C)
				tmpSco2 = findScore(tmpAns2, S, C)
				tmpSco3 = findScore(tmpAns3, S, C)
				tmpSco4 = findScore(tmpAns4, S, C)
				tmpSco5 = findScore(tmpAns5, S, C)
				if bestSco1 < tmpSco1:
					bestSco5 = bestSco4
					bestI5 = bestI4
					bestSco4 = bestSco3
					bestI4 = bestI3
					bestSco3 = bestSco2
					bestI3 = bestI2
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco1
					bestI1 = j+1
				if bestSco1 < tmpSco2:
					bestSco5 = bestSco4
					bestI5 = bestI4
					bestSco4 = bestSco3
					bestI4 = bestI3
					bestSco3 = bestSco2
					bestI3 = bestI2
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco1
					bestI1 = j+1
				if bestSco1 < tmpSco3:
					bestSco5 = bestSco4
					bestI5 = bestI4
					bestSco4 = bestSco3
					bestI4 = bestI3
					bestSco3 = bestSco2
					bestI3 = bestI2
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco1
					bestI1 = j+1
				if bestSco1 < tmpSco4:
					bestSco5 = bestSco4
					bestI5 = bestI4
					bestSco4 = bestSco3
					bestI4 = bestI3
					bestSco3 = bestSco2
					bestI3 = bestI2
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco1
					bestI1 = j+1
				if bestSco1 < tmpSco5:
					bestSco5 = bestSco4
					bestI5 = bestI4
					bestSco4 = bestSco3
					bestI4 = bestI3
					bestSco3 = bestSco2
					bestI3 = bestI2
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco1
					bestI1 = j+1
		ans1.append(bestI1)
		ans2.append(bestI2)
		ans3.append(bestI3)
		ans4.append(bestI4)
		ans5.append(bestI5)

	for i in ans1:
		print(i)


def findScore(ans, S, C):
	scezhu = [inf for i in range(26)]
	sco = 0
	for i,val in enumerate(ans):
		tmp = S[i][val-1]
		scezhu[val-1] = i
		mins = 0
		for j,vol in enumerate(C):
			if scezhu[j] == inf:
				mins = mins + (vol * (i+1))
			else:
				mins = mins + (vol * ((i+1)-(scezhu[j]+1)))
		tmp -= mins
		sco += tmp
	return sco



if __name__ == "__main__":
	main()

Solution (Python):
from time import time
import random
from collections import Counter


def main():
    random.seed(0)

    start = time()

    MAX = 26

    
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]

    
    t = []
    prev = [0] * MAX
    for day, row in enumerate(s, 1):
        mxi = 1
        mx = 0
        for i, (es, ec) in enumerate(zip(row, c), 1):
            point = es + ec * (day - prev[i - 1])
            if point > mx:
                mx = point
                mxi = i

        prev[mxi - 1] = day
        t.append(mxi)

    
    last = [0] * MAX
    score = 0
    for day, e in enumerate(t, 1):
        score += s[day-1][e-1]
        last[e-1] = day

        for ec, elast in zip(c, last):
            score -= ec * (day - elast)

    
    d_li = []
    for i in range(1, d + 1):
        ln = max(1, (-(i - d // 2) ** 2 + d ** 2 // 4) // 500)
        d_li += [i] * ln

    di_max = len(d_li) - 1

    
    sc = []
    for row in s:
        app = []
        for i, (es, ec) in enumerate(zip(row, c), 1):
            app += [i] * max(1, (es + ec * d) // 20)

        sc.append(app)

    
    
    
    
    while time() - start <= 1.85:
        
        prev_score = score

        di = random.randint(0, di_max)
        ed = d_li[di]
        qi = random.randint(0, len(sc[ed-1]) - 1)
        eq = sc[ed-1][qi]

        q_old = t[ed-1]
        d_prev = {q_old: 0, eq: 0}

        c_old = c[q_old-1]
        c_new = c[eq-1]

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score += c_old * (day - d_prev[q_old])
            score += c_new * (day - d_prev[eq])

        score -= s[ed-1][q_old-1]
        score += s[ed-1][eq-1]

        t[ed-1] = eq

        d_prev = {q_old: 0, eq: 0}

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score -= c_old * (day - d_prev[q_old])
            score -= c_new * (day - d_prev[eq])

        if prev_score > score:
            val = (score - prev_score) / (1000 * (time() - start))
            
            if val > -10:
                continue
            
            
            t[ed-1] = q_old
            score = prev_score

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


if __name__ == "__main__":
    main()

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	D = inputInt()
	C = inputList()
	S = []
	for i in range(D):
		s = inputList()
		S.append(s)

	ans1 = []
	ans2 = []
	for i in range(D):
		bestSco1 = 0
		bestSco2 = 0
		bestI1 = 1
		bestI2 = 1

		for j,val in enumerate(S[i]):
			if j == 0:
				tmpAns = ans1 + [j+1]
				tmpSco = findScore(tmpAns, S, C)
				if bestSco1 < tmpSco:
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco
					bestI1 = j+1
			else:
				tmpAns1 = ans1 + [j+1]
				tmpAns2 = ans2 + [j+1]
				tmpSco1 = findScore(tmpAns1, S, C)
				tmpSco2 = findScore(tmpAns2, S, C)
				if bestSco1 < tmpSco1:
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco1
					bestI1 = j+1
				if bestSco1 < tmpSco2:
					bestSco2 = bestSco1
					bestI2 = bestI1
					bestSco1 = tmpSco2
					bestI1 = j+1
		ans1.append(bestI1)
		ans2.append(bestI2)

	for i in ans1:
		print(i)


def findScore(ans, S, C):
	scezhu = [inf for i in range(26)]
	sco = 0
	for i,val in enumerate(ans):
		tmp = S[i][val-1]
		scezhu[val-1] = i
		mins = 0
		for j,vol in enumerate(C):
			if scezhu[j] == inf:
				mins = mins + (vol * (i+1))
			else:
				mins = mins + (vol * ((i+1)-(scezhu[j]+1)))
		tmp -= mins
		sco += tmp
	return sco



if __name__ == "__main__":
	main()

Solution (Python):
D = int(input())
C = [int(i) for i in input().split()]
scores = [[int(i) for i in input().split()] for j in range(D)]
ans = [0]*D
S = 0
last = [0]*26
for d in range(1,D+1):
    m = -float("inf")
    index = -1
    for i,t in enumerate(scores[d-1]):
        st = S + t
        lt = [i for i in last]
        lt[i] = d
        for j in range(26):
            st -= C[j] * (d - lt[j])
        if m < st:
            m = st
            index = i
    S = m
    ans[d-1] = index+1
    last[index] = d
print("\n".join(map(str, ans)))