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):
D = int(input())
c = list(map(int, input().split()))
sdi = [list(map(int, input().split())) for i in range(D)]



lastdi = [0 for i in range(26)]
ans_c = []

d = 0
while True:
  if d == D:
    break
  if d > D - 2:
    day_s = sdi[d]
    
    sloss = [day_s[i] + c[i]*(d - lastdi[i]) for i in range(26) ]
    ans = sloss.index(max(sloss))
    ans_c.append( ans+1 )
    
    for i in range(26):
      if i != ans:
        lastdi[i] += 1
    lastdi[ans] = d
    d += 1
    
  else:
    
    a = [sdi[d][i] + sdi[d+1][i2] - sum([c[k]*( 2*d-lastdi[k]+1) for k in range(26) if k not in [i,i2]] ) -c[i] -c[i2]*(d-lastdi[i2]) for i in range(26) for i2 in range(26) ]
    idx = a.index(max(a))
    best_i2 = idx % 26 + 1
    best_i1 = (idx // 26) % 26 + 1
    
    ans_c.append(best_i1)
    ans_c.append(best_i2)
    lastdi[best_i1-1] = d
    lastdi[best_i2-1] = d+1
    
    d += 2

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

Solution (Python):
from time import time

start = time()
D = int(input())
C = [int(i) for i in input().split()]
scores = [[int(i) for i in input().split()] for j in range(D)]
t = []
for i in scores:
    t.append(i.index(max(i))+1)
DC = [0]*26

def calcScore(t):
    score = []
    S = 0
    last = [0]*26
    for d in range(1,D+1):
        S += scores[d-1][t[d-1]-1]
        last[t[d-1]-1] = d
        for i in range(26):
            S -= C[i] * (d - last[i])
            DC[i] += (d - last[i])
        score.append(S)
    return score[-1]

from random import randint
ts = calcScore(t)
i = 0
while time() - start < 1.8:
    d,q = i, randint(1,26)
    temp = [t[i] if d-1 != i else q for i in range(D)]
    if calcScore(temp) > ts:
        t = temp
        i += 1

print("\n".join(map(str, t)))

Solution (Python):

dd = int(input())
c = list(list(map(int, input().split())))
s = [[0]*26]*dd
v = [[0]*26]*dd
vs = [[0]*26]*dd
ans = [0]*dd
fdate = [0]*26
for i in range(dd):
    s[i] = list(list(map(int, input().split())))



for i in range(dd):

    for j in range(26):
        v[i][j] = s[i][j] + c[j] *(i-fdate[j]) *(i-fdate[j])
    maxv = -100000000
    for j in range(26):
        if maxv < v[i][j]:
            maxv = v[i][j]
            ans[i]=j+1
    fdate[ans[i]-1] =i+1

for a in ans:
    print(a)

Solution (Python):
import math

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

nocontest = [1 for i in range(26)]
count_nocontest = [1 for i in range(26)]
for i in range(D):
    s = S[i]
    contest = [0 for j in range(26)]
    for j in range(26):
        contest[j] = c[j] * nocontest[j] * s[j]
    
    max_contest = max(contest)
    ans = contest.index(max_contest)
    print(ans + 1)
    
    for j in range(26):
        if j == ans:
            nocontest[j] = 1
            count_nocontest[j] = 1
        else:
            nocontest[j] += count_nocontest[j]
            count_nocontest[j] += 1

Solution (Python):
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
s = [[] for i in range(365)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )

last = np.array( [-1]*26 )
av = np.array( [0]*26 )
id = np.identity(4,dtype=int)

def fav(d):
  return( s[d] - sum( c*(d-last) ) + c*(d-last) )

  
v = 0
for d in range(D):
  av = fav( d )
  m = max(av)
  for t in range(26):
    if av[t] == m:
      last[t] = d
      v += av[t]
      print(t+1)
      break

Solution (Python):
import sys
import random
import time
import numpy as np
import bisect

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def prob(e1,e2,T):
    if e2 < e1:
        return 1
    else:
        return np.exp((e1-e2)/T)

def solve():
    m = 26
    start = time.time()
    dT = 0.995
    T = 200
    D = ni()
    c = nl()
    s = [nl() for _ in range(D)]
    H = [None]*D
    for i in range(D):
        g = [s[i][j] - 20 * c[j] for j in range(m)]
        y = min(g)
        h = sum(g) - m * y
        g = [(x-y)/h for x in g]
        for j in range(1, m):
            g[j] += g[j-1]
        H[i] = g

    def calc(sche, m=26):
        last = [-1] * m
        ans = 0
        for i in range(D):
            t = sche[i]
            ans += s[i][t]
            last[t] = i
            for j in range(m):
                ans -= c[j] * (i - last[j])
        return ans

    def change(d, q, sc):
        b = sche[d]
        fq, bq = -1, D
        fb, bb = -1, D
        for i in range(d):
            if sche[i] == q:
                fq = i
            if sche[i] == b:
                fb = i
        for i in range(D-1, d, -1):
            if sche[i] == q:
                bq = i
            if sche[i] == b:
                bb = i
        sc += ((bb - d) * (bb - d - 1) // 2 + (d - fb) * (d - fb - 1) // 2) * c[b]
        sc += ((bq - fq) * (bq - fq - 1) // 2) * c[q]
        sc -= s[d][b]
        sc -= ((bq - d) * (bq - d - 1) // 2 + (d - fq) * (d - fq - 1) // 2) * c[q]
        sc -= ((bb - fb) * (bb - fb - 1) // 2) * c[b]
        sc += s[d][q]
        return sc

    sche = [0] * D
    for i in range(D):
        sche[i] = s[i].index(max(s[i]))
    sc = calc(sche)
    bestst = sche[:]
    best = sc

    while time.time() - start < 1.75:
        for _ in range(200):
            d = random.randint(0, D-1)
            q = bisect.bisect(H[d], random.random())
            nsc = change(d, q, sc)
            if best < nsc:
                bestst = sche[:]
                best = nsc
            if random.random() < prob(-sc, -nsc, T):
                sche[d] = q
                sc = nsc
        T *= dT
    prn([1 + x for x in bestst])

    return

solve()

Solution (Python):
D=int(input())
clist=list(map(int,input().split()))
smat=[[int(x) for x in input().split()] for _ in range(D)]



index_set=set(range(26))
for d in range(D):
  max_index=-1
  max_sd=-1
  for i in index_set:
    if max_sd<smat[d][i]:
      max_index=i
      max_sd=smat[d][i]
      
  max_index2=-1
  max_sd2=-1
  for i in range(26):
    if max_sd2<smat[d][i]:
      max_index2=i
      max_sd2=smat[d][i]
      
  if max_index==max_index2:
    print(max_index+1)
    index_set.remove(max_index)
  else:
    if max_sd2>4*max_sd:
      print(max_index2+1)
    else:
      print(max_index+1)
      index_set.remove(max_index)      
      
  if not index_set:
    index_set=set(range(26))
  else:
    max_c=0
    for i in index_set:
      max_c=max(max_c,clist[i])
    if max_c<25:
      index_set=set(range(26))

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

fuman=[]
for i in range(26):
    fuman.append(c[i]*66795)


for i in range(d):
    p=fuman.index(max(fuman))
    print(p+1)
    q=364-i
    fuman[p]=(q**2+q)*c[p]//2

Solution (Python):
import time
import random
import bisect
def test(li):
    m=0
    for i in range(D):
        m+=s[i][li[i]-1]
        last[li[i]-1]=i+1
        for j in range(26):
            m-=c[j]*(i+1-last[j])
    return m

def query(p,q,d):
    d+=1
    b=bisect.bisect_left(play[p],d)
    np=play[p][b+1] if b+1<len(play[p]) else 366
    bp=play[p][b-1]
    minus=((0+np-d)*(np-d+1)//2)-((d-bp+np-bp)*(np-d)//2)
    b=bisect.bisect_left(play[q],d)
    np=play[q][b+1] if b+1<len(play[q]) else 366
    bp=play[q][b-1]
    plus=((d-bp+np-bp)*(np-d)//2)-((0+np-d)*(np-d+1)//2)
    if plus-minus>0:
        if d in play[p]:
            play[p].remove(d)
        play[q].append(d)
        play[q].sort()
        return True
    else:
        return False

start=time.time()
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
last=[0]*26
t=[random.randrange(26) for i in range(D)]
play=[[0] for i in range(26)]
for i in range(D):
    play[t[i]-1].append(i+1)
for i in range(26):
    play[i].append(366)
    
res=test(t)
while(True):
    if time.time()-start>=1.70:
        break
    for i in range(D):
        if time.time()-start>=1.70:
            break
        q=random.randrange(26)
        p=t[i]
        query(p,q,i)
for i in range(D):
  print(t[i]+1)

Solution (Python):
import numpy as np


def solve(dd, c_arr, s_arr):
    missing_d = np.zeros(26, dtype=np.int64)
    
    res_list = []
    for d in range(dd):

        missing_d += 1

        score_add = s_arr[d, :]
        score_miss = c_arr * missing_d

        t = np.argmax(score_add + score_miss)

        

        res_list.append(t + 1)
        missing_d[t] = 0

    

    return res_list


def main():
    d = np.int64(input())
    c_arr = np.array(list(map(int, input().split()))).astype(np.int64)
    s_arr = np.array([list(map(int, input().split())) for _ in range(d)]).astype(np.int64)
    res = solve(d, c_arr, s_arr)
    for r in res:
        print(r)


if __name__ == "__main__":
    main()

Solution (Python):

D = int(input())
cs = list(map(int, input().split()))
ss = [input().split() for l in range(D)]
count=26
for i in range(365):
    print(count)
    count-=1
    if count==0:
        count=26

Solution (Python):



def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

u = [i+1 for i in range(26)]
ans = []
for i in range(365):
    ans.append(u[i%26])
for i in range(365):
    print(ans[i])

Solution (Python):
D = int(input())
c = list(map(int, input().split()))
last = [0] * 26
ans = []
S = []
prev_score = 0
maxsi_list = []

for d in range(1, D+1):
    s = list(map(int, input().split()))
    S += [s]
    maxs = float('-inf')
    maxss = float('-inf')
    maxi = -1
    maxii = -1
    cumsump = 0
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        cumsump += tmp
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        tmp2 = s[i] + cumsump - tmp
        if tmp2 > maxs:
            maxs = tmp2
            maxi = i
        if s[i] > maxss:
            maxii = i
            maxss = s[i]
    ans += [maxi+1]
    last[maxi] = d
    prev_score += maxs
    maxsi_list += [maxii+1]
best_ans = ans
best_score = prev_score
mergin = 1300
for tt in range(31):
    for dd in range(D):
        last = [0] * 26
        score = 0
        for d in range(1, D+1):
            if dd == (d-1):
                maxc = 0
                maxci = -1
                for i in range(26):
                    cost = c[i] * (d - last[i])
                    if maxc < cost:
                        maxc = cost
                        maxci = i+1
                prev_a = ans[dd]
                ans[dd] = maxci
            td = ans[d-1] - 1
            cumsump = 0
            for i in range(26):
                if td != i:
                    tmp = -c[i] * (d - last[i])
                    cumsump += tmp
            last[td] = d
            score += S[d-1][td]+cumsump
        if score <= prev_score-mergin:
            ans[dd] = prev_a
        elif best_score < score:
            best_ans = ans
            best_score = score
            prev_score = score
        else:
            prev_score = score

    for dd in range(D):
        last = [0] * 26
        score = 0
        prev_a = ans[dd]
        ans[dd] = maxsi_list[dd]
        for d in range(1, D+1):
            td = ans[d-1] - 1
            cumsump = 0
            for i in range(26):
                if td != i:
                    tmp = -c[i] * (d - last[i])
                    cumsump += tmp
            last[td] = d
            score += S[d-1][td]+cumsump
        if score <= prev_score-mergin:
            ans[dd] = prev_a
        elif best_score < score:
            best_ans = ans
            best_score = score
            prev_score = score
        else:
            prev_score = score

for a in best_ans:
    print(a)

Solution (Python):
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = 0
a = []
last = [0]*26
for i in range(1,d+1):
    res = -float("inf")
    index = 0
    for k in range(26):
        x = k
        tnplast = last
        tnplast[x] = i
        tnp = 0
        tnp += s[i-1][x]
        for j in range(26):
            tnp -= c[j]*(i-last[j])
        if (tnp > res):
            res = tnp
            index = k+1
    ans += res
    a.append(index)

def rec(t,x,y,ans):
    ans -= s[x-1][t[x-1]-1]
    ans += s[x-1][y-1]
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==t[x-1]):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==t[x-1]):
            mi = j
            break
    ans -= c[t[x-1]-1]*(x-mi)*(ma-x)
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==y):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==y):
            mi = j
            break
    ans += c[y-1]*(x-mi)*(ma-x)
    return ans
    
for i in range(20000):
    x = random.randrange(1,d+1)
    y = random.randrange(1,27)
    t = a
    A = rec(t,x,y,ans)
    if (ans < A):
        t[x-1] = y
        a = t
        ans = A

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    D = int(input())
    c = [0] + list(map(int, input().split()))
    s = [[0]*27]
    for _ in range(D):
        s.append([0] + list(map(int, input().split())))
    for i in range(1, 366):
        print(s[i].index(max(s[i])))

if __name__ == '__main__':
    main()

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

limit_secs = 2
start_time = time()

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

def calc_score():
    score = 0
    S = 0
    last = [-1] * 26
    for d in range(D):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def calc_satisfaction():
    S = 0
    last = [-1] * 26
    for d in range(D):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
    return S

def solution():
    return [i % 26 for i in range(D)]

t = solution()

score = calc_score()
while time() - start_time < limit_secs * 0.9:
    d = int(random() * D)
    q = int(random() * 26)
    old = t[d]
    t[d] = q
    
    new_score = calc_score()
    
    if new_score < score:
        t[d] = old
    else:
        
        score = new_score
print('\n'.join(str(e + 1) for e in t))

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 = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	minC = min(C)
	minCn = 0
	for i,val in enumerate(C):
		if val == minC:
			minCn = i

	for i,val in enumerate(S):
		tmp = max(val)
		mins = 0
		for j,vol in enumerate(val):
			if tmp == vol:
				mins = j+1
				break
		if i < D//2:
			ans.append(mins)
		else:
			ans.append(minCn+1)

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



if __name__ == "__main__":
	main()

Solution (Python):
import sys
import numpy as np
import numba
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    return D, C, S

@njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

def output(T):
    T += 1
    print(*T, sep='\n')

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :]), cache=True)
def random_update(D, C, S, T, last_days):
    d = np.random.randint(0, D, 1)[0]
    p = T[d]
    xcum = 0
    for q in range(26):
        if p == q:
            continue
        xcum += difference_update(D, C, S, T, last_days, d, q)
        if xcum > 0:
            return q, xcum
    difference_update(D, C, S, T, last_days, d, p)
    return p, 0

@njit((i4, i4[:], i4[:, :], i4[:], i4[:,:]), cache=True)
def main(D, C, S, T, last_days):
    x = 0
    for _ in range(10**5):
        x += random_update(D, C, S, T, last_days)[1]
    return T, x

def first_strategy(D, C, S):
    T = np.empty(D, np.int32)
    for d in range(D):
        T[d] = d % 26
    return T

D, C, S = get_input()

T = first_strategy(D, C, S)
last_days, score = first_computation(D, C, S, T)

T, x = main(D, C, S, T, last_days)

output(T)

Solution (Python):
import random
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def score(tt):
    ans=0
    for i,t in enumerate(tt):
        t-=1
        ans += ss[i][t]
        p = i - last[t]
        ans -= p * (p + 1) // 2 * cc[t]
        last[t] = i + 1
    for t in range(26):
        p = d - last[t]
        ans -= p * (p + 1) // 2 * cc[t]
    return ans

inf=10**16
d = II()
cc = LI()
ss = LLI(d)
ans = 0
last = [0] * 26
tt=list(range(1,27))*(d//26+1)
tt=tt[:d]
for _ in range(20000):
    i=random.randrange(d)
    mx=-inf
    best=1
    for j in range(1,27):
        tt[i]=j
        cur=score(tt)
        if cur>mx:
            mx=cur
            best=j
    tt[i]=best

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

Solution (Python):
import random
 
def calc1(D, s, t):
  last = [0 for _ in range(26)]
 
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value
 
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0 for _ in range(26)]
calc = [0 for _ in range(26)]

t = [0 for _ in range(D)]
 
for i in range(D):
  for j in range(26):
    day = i + 1
    calc[j] = c[j] * (day - last[j])
  min_idx = calc.index(max(calc))
  last[min_idx] = day
  t[i] = min_idx + 1

val = calc1(D, s, t)
for _ in range(45000):
  d_rand = random.randint(1,D)
  q_rand = random.randint(1,26)
  old = t[d_rand-1]
  t[d_rand-1] = q_rand
  new_val = calc1(D, s, t)
  if val > new_val:
    t[d_rand-1] = old
  else:
    val = new_val
for i in range(D):
  print(t[i])

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

tl = []



last_di = [-1]*26
ans = 0
for day in range(d):
    
    
    
    
    coef = 6.0 - day/500.0
    best_t = 0
    best_t_val = -999999999999
    for t in range(26):
        curr_val = sl[day][t]*1
        for i in range(26):
            if i == t: continue
            curr_val -= (day-last_di[i])*cl[i]*coef
        if curr_val >= best_t_val:
            best_t = t
            best_t_val = curr_val
    tl.append(best_t+1)
    last_di[best_t] = day
    ans += best_t_val
    
    
    
    

for t in tl:
    print(t)

Solution (Python):
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  s.append(list(map(int, input().split())))
  
sdictlist = []
sdictlistsorted = []
for i in range(D):
  onedict = {}
  for j in range(26):
    onedict[j] = s[i][j]
  sdictlist.append(onedict)
  onesorteddict = sorted(onedict.items(), key=lambda x:x[1], reverse=True)
  sdictlistsorted.append(onesorteddict)

cignorelen = 3
csorted = sorted(c)
csorted = csorted[:cignorelen]
ignorelist = []
for i in range(26):
  if(c[i] in csorted):
    ignorelist.append(i+1)
    
lenpastmax = 18 








pastlist = []
for i in range(D):
  j = 0
  while(sdictlistsorted[i][j][0] in pastlist or sdictlistsorted[i][j][0]+1 in ignorelist):
    j += 1
  print(sdictlistsorted[i][j][0]+1)
  pastlist.append(sdictlistsorted[i][j][0])
  if(len(pastlist)==lenpastmax):
    pastlist.pop(0)

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

D = ir()
c = lr()
d = [0 for i in range(26)]
s = [lr() for i in range(D)]

for k in range(1,D+1):
    now = -1
    pre = -inf
    for i in range(26):
        total = s[k-1][i]
        sumc = 0
        for j in range(26):
            if j != i:
                sumc += c[j]*(k-d[j])
        total-=sumc
        if total > pre:
            pre = total
            now = i
    print(now+1)
    d[now] = k

Solution (Python):
import numpy as np
import copy
D=int(input())

c_list=list(map(int,input().split()))
c_list=np.array(c_list)
c_ll=np.array([0]*26)

d_list=[]
for i in range(D):
    dl=list(map(int,input().split()))
    d_list.append(np.array(dl))


score=0


exp=[0]*26
for d in range(D):
    c_ll+=1
    for i in range(26):
        exp[i]+=d_list[d][i]
        c_ll2=copy.deepcopy(c_ll)
        c_ll2[i]=0
        exp[i]-=sum(c_list*c_ll2)

    j=exp.index(max(exp))
    c_ll[j]=0
    print(j+1)

Solution (Python):
import numpy as np

d=int(input())
c=np.array(list(map(int,input().split())))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

lastd=np.zeros(26)

ans=[0]*d
for i in range(d):  
  a=np.argmax(c*([i]*26-lastd))
  lastd[a]=i
  
  ans[i]=(i+a)%26+1

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

Solution (Python):

from copy import deepcopy
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]

last = {}
for i in range(26):
    last[i] = -1

s = 0
Ret = []
for d in range(D):
    sr = {}
    ll = {}
    for c in range(26):
        last_cp = deepcopy(last)
        s_cp = deepcopy(s)
        last_cp[c] = d
        s_cp += S[d][c]
        for i in range(26):
            s_cp -= C[i] * (d-last_cp[i])
        sr[c] = s_cp
        ll[c] = last_cp
    sr = sorted(sr.items(), key=lambda x:x[1])
    

    ret = sr[-1][0]

    s = sr[-1][1]
    last = deepcopy(ll[ret])
    Ret.append(ret+1)

for r in Ret:
    print(r)

Solution (Python):
import sys
input = sys.stdin.readline

d = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(d)]

c = 26



ans = 0
L = [[-1] * c for i in range(d)]
T = [-1] * d  

for i in range(d):
    ANS = [0] * c
    L[i] = L[i-1][:]
    for k in range(c):
        ANS[k] = S[i][k] + C[k] * (i - L[i][k])
    ind = ANS.index(max(ANS))
    ans += S[i][ind]
    L[i][ind] = i
    for j in range(c):
        ans -= C[j] * (i - L[i][j])
    
    
    T[i] = ind






K = [[] for i in range(d)]

cp = 3
dp = 3

CC = [[C[i], i] for i in range(c)]
CC.sort(reverse=True)
for i in range(d):
    for k in range(cp):
        K[i].append(CC[k][1])

for i in range(d):
    DD = [[S[i][j], j] for j in range(c)]
    DD.sort(reverse=True)
    for k in range(dp):
        K[i].append(DD[k][1])


    
from random import randint

m = 5*10**5

Q = [[0] * 2 for i in range(m)]
for i in range(m):
    dd = randint(0, d-1)
    
    
    q = K[dd][randint(0, len(K[dd])-1)]
    Q[i][0] = dd
    Q[i][1] = q



for i in range(m):
    
    
    dd = Q[i][0]
    q = Q[i][1]
    nans = ans
    
    nans -= S[dd][T[dd]]
    nans += S[dd][q]
    for j in range(dd, d):
        
        if T[j] == q:
            
            break
        nans += C[q] * (j - L[j][q])
        nans -= C[q] * (j - dd)
        L[j][q] = dd
    
    old = T[dd]
    T[dd] = q

    for j in range(dd, d):
        
        if T[j] == old:
            
            break
        oldl = L[j-1][old] if j > 0 else -1
        nans += C[old] * (j - dd)
        nans -= C[old] * (j - oldl)
        L[j][old] = oldl

    

    if nans < ans:
        if i != m-1:
            Q[i+1] = [dd, old]
        else:
            T[dd] = old
    
    ans = nans


for i in T:
    print(i+1)

Solution (Python):
import random
import numpy as np
import sys
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
    temp = list(map(int, input().split()))
    s.append(temp)
s = np.array(s)
c = np.array(c)


'''dice = list(range(26))
w = list(map(lambda x: x*x, c))
samples = random.choices(dice, k=d, weights=w)
for one in samples:
    print(one+1, file=f)'''
def p(text):
    print(text)

with open('output.txt', 'w') as f:
    for i in range(d):
        if max(s[i])>17000:
            if random.random()>0.2:
                
                p(s[i].argmax()+1)
            else:
                
                p(int(random.random()*26+1))
        else:
            
            dice = list(range(26))
            w = c**3
            samples = random.choices(dice, k=1, weights=w)
            for one in samples:
                p(one+1)

Solution (Python):
import numpy as np
D = int(input())
s = [input() for i in range(D+1)]
for i in range(0,D+1):
    s[i] = s[i].split()
    s[i] = [int(p) for p in s[i]]
a = []
b = [0]*len(s[0])
S = 0
for i in range (1,D+1):
    mx = np.argmax(s[i])
    for j in range(0,len(s[0])):
        if j == mx:
            b[j] = 0
        else:
            b[j] = b[j] + s[0][j]
    S = S + s[i][mx] - sum(b)
    a.append(mx+1)
for i in (a):
    print(i)