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 sys
import random
from copy import copy
from math import floor, e

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def write_output(out):
    with open("my_sample3.out", mode="w") as f:
        for x in out:
            f.write(str(x + 1) + "\n")


def main():
    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]

    sat_cur = 0
    last = [1] * 26
    out = [-1] * d

    for day in range(d):
        estimate = [0.0] * 26
        for cid in range(26):
            if s[day][cid] > 16000:
                estimate[cid] = last[cid] * c[cid] + c[cid] ** 1
        cur = estimate.index(max(estimate))
        out[day] = cur
        sat_cur += s[day][cur]
        last[cur] = 1
        for cid in range(26):
            if cid != cur:
                sat_cur -= last[cid] * c[cid]
                last[cid] += 1

    
    out_best = copy(out)
    sat_best = sat_cur
    num_of_try = 10000
    for i in range(1, num_of_try + 1):
        change_num = floor((num_of_try - i) / 5000)
        out_temp = copy(out_best)
        for j in range(change_num):
            
            c_day = random.randint(0,364)
            c_cid = random.randint(0, 25)
            out_temp[c_day] = c_cid

        last = [1] * 26
        sat_temp = 0
        for day in range(d):
            cur = out_temp[day]
            sat_temp += s[day][cur]
            last[cur] = 1
            for cid in range(26):
                if cid != cur:
                    sat_temp -= last[cid] * c[cid]
                    last[cid] += 1
        if sat_temp > sat_best:
            
            out_best = out_temp
            sat_best = sat_temp

    for x in out_best:
        print(x + 1)

    


if __name__ == '__main__':
    main()

Solution (Python):
import sys 
import time

t0=time.time()
import random
def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print(*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None

def main():
    mod = 1000000007
    

    D = int(input())
    
    cs = tuple(map(int, input().split())) 
    
    S = tuple(tuple(map(int, input().split())) for i in range(D)) 
    lss=[]
    ls=[0]*26
    anss=[-1]*D
    for i in range(D):
        s=S[i]
        if i==0:
            msc=-1000000
            ans=-1
            for j in range(26):
                sc=s[j]+cs[j]

                if msc<sc:
                    ans=j
                    msc=sc
            ls[ans]=1
            
            anss[i]=ans+1
            continue
        msc=0
        ans=-1
        dec=[-cs[j]*(i+1-ls[j]) for j in range(26)]
        msc=-10000000
        ans=-1
        for j in range(26):
            sc=s[j]-dec[j]
            if msc<sc:
                ans=j
                msc=sc
        ls[ans]=i+1
        
        anss[i]=ans+1
    
    def eval(anss):
        ls=[0]*26
        score=0
        for i in range(D):
            j=anss[i]-1
            ls[j]=i+1
            score+=S[i][j]
            dec=sum([cs[k]*(i+1-ls[k]) for k in range(26)])
            score-=dec
        return score
    
    def eval2(anss,score,target,val,pval):
        score=score-S[target][pval-1]+S[target][val-1]
        f1=0
        f2=0
        cp=cv=0
        if target>0:
            for i in range(target-1,-1,-1):
                a=anss[i]
                if a==pval and not f1:
                    cp=i
                    f1=1
                if a==val and not f2:
                    cv=i
                    f2=1
                if f1 and f2:
                    break
        f1=f2=0
        
        csv=cs[val-1]
        csp=cs[pval-1]
        tcv=(target-cv)*csv
        tcp=(target-cp)*csp
        

        score+=tcv-tcp
        for i in range(target+1,D):
            a=anss[i]
            if anss[i]==pval and not f2:
                f2=1
            if anss[i]==val and not f1:
                f1=1
            if not f1:
                score+=tcv
            if not f2:
                score-=tcp
                
            if f1 and f2:
                break

        return score

    csc=eval(anss)
    

    random.seed(1)
    yaki=1000
    count=0
    while time.time()-t0<1.9:
        count+=1
        target=random.randrange(0,D)
        
        pval=anss[target]
        val=pval
        while val==pval:
            val=random.randrange(0,26)+1
        
        
        nsc=eval2(anss,csc,target,val,pval)
        
        if nsc>csc:
            csc=nsc
            anss[target]=val
            
        else:
            r=random.random()
            if r<2**(-(csc-nsc)/yaki):
                anss[target]=val
            

    printl(anss)
    
    
    

if __name__ == "__main__":
    main()

Solution (Python):
import time
start = time.time()

import random
from collections import defaultdict


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


def calc_score_by_contest(contest, contest_schedule, loss_base, satisfied_matrix):
    plus = 0
    minus = 0
    for day in contest_schedule:
        plus += satisfied_matrix[day][contest]

    diff = [0] + contest_schedule[:-1]
    loss_base = loss_list[contest]
    for prev, open in zip(diff, contest_schedule):
        spend = open - prev
        loss = loss_base * spend * (spend + 1) // 2
        minus += loss

    return plus - minus


def update(day, old, new, loss_list, satisfied_matrix):
    if old == new:
        return None


def schedule_to_dict(schedule):
    dict = defaultdict(list)
    for day, contest in enumerate(schedule):
        dict[contest].append(day)

    for contest in range(26):
        dict[contest].append(364)

    return dict


def calc_score(schedule, loss_list, satisfied_matrix):
    schedule_dict = schedule_to_dict(schedule)
    plus = 0
    minus = 0
    for contest in range(26):
        day_list = schedule_dict[contest]
        for day in day_list:
            plus += satisfied_matrix[day][contest]

        diff = [0] + day_list[:-1]
        loss_base = loss_list[contest]
        for prev, open in zip(diff, day_list):
            spend = open - prev
            loss = loss_base * spend * (spend+1) // 2
            minus += loss

    return plus - minus


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


maxim_loss_contest = loss_list.index(max(loss_list))

ans = [i % 26 for i in range(365)]
prev = calc_score(ans, loss_list, satisfied_matrix)


while time.time() - start < 1.7:
    target_day = random.randint(3, 360)
    pairs = [target_day-3, target_day-2, target_day-1, target_day+1, target_day+2, target_day+3]

    for pair in pairs:
        ans[target_day], ans[pair] = ans[pair], ans[target_day]
        new_score = calc_score(ans, loss_list, satisfied_matrix)
        if new_score < prev:
            ans[target_day], ans[pair] = ans[pair], ans[target_day]
        else:
            prev = new_score
            break


for contest in ans:
    print(contest + 1)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import numpy as np

d = ni()
c = na()
s = []

for i in range(d):
    ss = na()
    s.append(ss)

c = np.array(c) 
s = np.array(s) 
s_t = s.T 
last = np.zeros(26)




def eva(n, cc, ss):
    r = np.random.rand()/2+1
    return (d-n)*cc + 30*ss*r

score = 0

for i in range(d): 
    last += 1 
    tow = c * last 
    sc = -100000
    M = -1
    for j in range(26):
        k = eva(i, tow[j], s[i][j])
        if sc < k:
            sc = k
            M = j
    last[M] = 0
    score -= np.dot(c,last)
    score += s[i][M]
    print(M+1)

Solution (Python):
for i in range(1,365+1):print(i%26+1)

Solution (Python):

dd = int(input())
c = list(list(map(int, input().split())))
s = [[0]*26]*dd
v = [[0]*26]*dd
vs = [[-10000000]*26]*dd
vs1 = [[-10000000]*26]*dd
vs2 = [[-10000000]*26]*dd
vs3 = [[-10000000]*26]*dd
ans = [0]*dd
ans2 = [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])
        if not i+1 == dd:
            vs[i][j] =s[i+1][j] + c[j] *(i-fdate[j]) *(i-fdate[j])- c[j] *(i-fdate[j]+1)
        if i+2 < dd:
            vs1[i][j] =s[i+2][j] + c[j] *(i-fdate[j]) *(i-fdate[j])- c[j] *(2*i-2*fdate[j]+3)
        if i+3 < dd:
            vs2[i][j] =s[i+3][j] + c[j] *(i-fdate[j]) *(i-fdate[j])- c[j] *(3*i-3*fdate[j]+6)



    maxv = -100000000

    for j in range(26):
        if maxv < v[i][j] and vs[i][j]<v[i][j]and vs1[i][j]<v[i][j]and vs2[i][j]<v[i][j]:
            maxv = v[i][j]
            ans[i] = j+1
    if ans[i] == 0:
        if maxv < v[i][j] and vs[i][j]<v[i][j]and vs1[i][j]<v[i][j]:
            maxv = v[i][j]
            ans[i] = j+1
    if ans[i] == 0:
        if maxv < v[i][j] and vs[i][j]<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):


from time import perf_counter
tick = perf_counter() + 1.90

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from random import randrange
from bisect import bisect

def resolve():
    it = map(int, sys.stdin.read().split())
    D = next(it)
    C = [next(it) for i in range(26)]
    S = [[next(it) for i in range(26)] for i in range(D)]
    L = [[-1] for i in range(26)]
    T = [0] * D

    def update(di, qi):
        T1, L1 = T[:], L[:]

        score = 0
        t0 = T[di]
        score += S[di][qi]-S[di][t0]
        T1[di] = qi

        L1[t0] = li = L[t0][:]
        ii = li.index(di)
        la = D if len(li)-1 == ii else li[ii+1]
        score -= C[t0] * (di-li[ii-1])*(la-di)
        li.pop(ii)

        L1[qi] = li = L[qi][:]
        ii = bisect(li, di)
        li.insert(ii, di)
        la = D if len(li)-1 == ii else li[ii+1]
        score += C[qi] * (di-li[ii-1])*(la-di)

        return score, T1, L1

    score = 0
    x = (1+D)*D//2
    for i in range(D):
        score += S[i][0]
        L[0].append(i)

    for i in range(1, 26):
        score -= C[i] * x

    while perf_counter() < tick:
        diff, T1, L1 = update(randrange(0, D), randrange(0, 26))
        if diff > 0:
            score += diff
            T, L = T1, L1

    print(*(i+1 for i in T), sep="\n")

if __name__ == "__main__":
    resolve()

Solution (Python):
import sys
input=sys.stdin.readline
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    sub=list(map(int,input().split()))
    s.append(sub)

last=[-1]*26

for i in range(d):
    m=-10**9
    change=-1
    for j in range(26):
        temp=0
        temp+=s[i][j]
        for k in range(26):
            if k!=j:
                temp-=c[k]*(i-last[k])
        if temp>m:
            m=temp
            change=j
    print(change+1)

Solution (Python):
def examA():
    def calc_score(d,k):
        rep = C[k]*(d-used[k]) + S[d][k]
        return rep

    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(D)]
    ans = 0
    T = [-1]*D
    used = [0]*N

    for d in range(D):
        s = -inf
        t = -1
        for i in range(N):
            cur = calc_score(d,i)
            if cur>s:
                s = cur
                t = i

        T[d] = t

        ans += S[d][t]
        used[t] = d + 1
        for j in range(N):
            ans -= C[j] * (d + 1 - used[j])


    def local_search(T0,ans):
        def search(d, k):
            l = 0; r = D
            for i in range(d + 1, D):
                if T[i] == k:
                    r = i
                    break
            for i in range(0, d)[::-1]:
                if T[i] == k:
                    l = i + 1
                    break
            return l, r

        def calc_cost(d, k):
            return C[k] * (d + 1) * d // 2

        que = deque()
        que.append([T0,ans])
        maxscore = ans

        for loop in range(100000):
            T,score = que.popleft()
            d = random.randint(0,D-1)

            old = deepcopy(T[d])
            change = -inf
            c = -1
            for q in range(N):
                if q==old:
                    continue
                T[d] = q

                old_l, old_r = search(d, old)
                new_l, new_r = search(d, q)

                cur = S[d][q] - S[d][old] \
                         - (calc_cost(old_r - old_l, old) - calc_cost(d - old_l, old) - calc_cost(old_r - d - 1, old)) \
                         + (calc_cost(new_r - new_l, q) - calc_cost(d - new_l, q) - calc_cost(new_r - d - 1, q))

                if cur>change:
                    change = cur
                    c = q

            j = random.randint(0, loop // 10 + 100)

            if change>0:
                T[d] = c
                que.append([T,score+change])
                if maxscore<score+change:
                    maxscore = score + change
            else:
                T[d] = old
                que.append([T,score+change])
                if len(que)>100:
                    continue

                if j>loop//10:
                    T[d] = c
                    que.append([T,score+change])

        ans = -inf
        rep = []
        used = [0] * N
        while(que):
            cur = 0
            T, _ = que.pop()
            for i in range(D):
                t = T[i]
                cur += S[i][t]
                used[t] = i + 1
                for j in range(N):
                    cur -= C[j] * (i + 1 - used[j])
            if cur>ans:
                rep = T
        return rep

    
    T = local_search(T,ans)
    

    for t in T:
        print(t+1)

    return

def examB():
    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(D)]
    T = [I()for _ in range(D)]
    ans = [0]*D
    used = [0]*N
    for i,t in enumerate(T):
        ans[i] += ans[i-1]
        t -= 1
        ans[i] += S[i][t]
        used[t] = i+1
        for j in range(N):
            ans[i] -= C[j]*(i+1-used[j])
    for v in ans:
        print(v)
    return

def examC():
    def calc_start():
        rep = [0] * D
        used = [0] * N
        for i, t in enumerate(T):
            rep[i] += rep[i - 1]
            rep[i] += S[i][t]
            used[t] = i + 1
            for j in range(N):
                rep[i] -= C[j] * (i + 1 - used[j])
        return rep

    def search(d,k):
        l = 0; r = D
        for i in range(d+1,D):
            if T[i]==k:
                r = i
                break
        for i in range(0,d)[::-1]:
            if T[i]==k:
                l = i + 1
                break
        return l, r

    def calc_cost(d,k):
        return C[k]*(d+1)*d//2

    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(D)]
    T = [I()-1 for _ in range(D)]

    ans = calc_start()[D-1]

    

    M = I()
    for i in range(M):
        
        d, q = LI()
        d -= 1; q -= 1
        old = deepcopy(T[d])
        T[d] = q
        

        old_l, old_r = search(d,old)
        new_l, new_r = search(d,q)

        
        

        change = S[d][q] - S[d][old] \
                 - (calc_cost(old_r - old_l, old) - calc_cost(d-old_l, old) - calc_cost(old_r-d - 1, old))\
                 + (calc_cost(new_r - new_l, q) - calc_cost(d - new_l, q) - calc_cost(new_r - d - 1, q))

        ans += change

        print(ans)

    return


from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
import sys
import random
import time
import math
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 math.exp((e1-e2)/T)

def solve():
    m = 26
    start = time.time()
    dT = 0.993
    T = 500
    D = ni()
    c = nl()
    s = [nl() for _ in range(D)]
    H = [None]*D
    for i in range(D):
        g = [s[i][j] + 25 * 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.85:
        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):

import numpy as np
def main():
  d=int(input())
  c=np.array(list(map(int,input().split())))
  s=[None]*d
  r0=[None]*d
  r1=[None]*d
  cm=np.array([0]*26)
  cd=np.array([0]*26)

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


  for j in range(d):  
    
    
    r_i=np.argmax(s[j])
    cd=c*cm
    if np.max(cd>s[i][r_i]):
      r_i=np.argmax(cd)
    r0[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
    
  score0=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r0[j]
    score0+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score0+=-np.sum(cd)
  
  
  """
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    
    r_i=r0[j]
    cd=c*cm
    if rand[j]>80:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0

  """
    
  testc=(90,80,85,75,70,65,60,55,50,45,40,35,30)
  for l in testc:
    cm=np.array([0]*26)
    cd=np.array([0]*26)  
    rand = np.random.randint(100, size = d) 
    for j in range(d):  
    
      r_i=r0[j]
      cd=c*cm
      if rand[j]>l:
        r_i=np.argmax(cd)
      r1[j]=r_i
      for k in range(26):
        cm[k]+=1
      cm[r_i]=0
      
    score1=0
    cm=np.array([0]*26)
    cd=np.array([0]*26)  
    for j in range(d):
      r0_j=r1[j]
        
      score1+=s[j][r0_j]
      for k in range(26):
        cm[k]+=1
        cm[r0_j]=0
      cd=c*cm
      
      score1+=-np.sum(cd)
      
      
      if score1>score0:
        r0=r1
        score0=score1
    
  
  for j in range(d):  
    print(r0[j]+1) 
 
main()

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):
def main():
    import os

    INF = 10 ** 9 + 10

    D = int(input())
    *C, = map(int, input().split())
    
    
    S = [[int(x) for x in input().split()] for _ in range(D)]
    

    last = [-1] * 26

    def diff(d, t):
        ret = S[d][t]
        ret -= sum(ci * (d - last[i]) for i, ci in enumerate(C) if i != t)
        if d != D - 1:
            ret -= sum(ci * (d + 1 - last[i]) for i, ci in enumerate(C) if i != t)
        ret -= C[t]
        return ret

    T = []
    score = 0
    for d in range(D):
        delta = -INF
        take_t = -1
        for t_ in range(26):
            buf = diff(d, t_)
            if delta < buf:
                delta = buf
                take_t = t_
            elif delta == buf and C[t_] > C[take_t]:
                delta = buf
                take_t = t_

        last[take_t] = d
        score += buf
        T.append(take_t + 1)
    print(*T, sep='\n')
    
    
    
    
    

    


if __name__ == '__main__':
    main()

Solution (Python):
D=int(input())
for i in range(D):
  print((25-i)%26+1)

Solution (Python):
from collections import defaultdict
from time import time
import bisect
from random import randint
d = int(input())
T = time()
c = [0]+list(map(int,input().split()))
s = [0]
for i in range(d):
    s.append([0]+list(map(int,input().split())))
dic = defaultdict(int)
contest = [[] for _ in range(27)]
contests = [-1]*(d+1)
for i in range(1,d+1):
    maxscore = 0
    maxcontest = -1
    for k in range(1,27):
        score = 0
        score += s[i][k]
        score += c[k]*(i-dic[k])
        if score > maxscore:
            maxscore = score
            maxcontest = k
    dic[maxcontest] = i
    contests[i] = maxcontest
    contest[maxcontest].append(i)
ans = 0
for i in range(1,d+1):
    ans += s[i][contests[i]]
penalty = [0]*27
for i in range(1,27):
    p = 0
    cur = 1
    for j in contest[i]:
        blank = j-cur
        cur = j+1
        p += blank*(blank+1)//2*c[i]
    blank = d+1-cur
    p += blank*(blank+1)//2*c[i]
    ans -= p
    penalty[i] = p
def dscore(d,q):
    old = contests[d]
    ds = 0
    ds -= s[d][old]
    ds += s[d][q]
    ds += penalty[old]
    ds += penalty[q]
    p1 = 0
    p2 = 0
    cur = 1
    contest_o = contest[old][:]
    contest_o.remove(d)
    contest_q = contest[q][:]
    bisect.insort(contest_q,d)
    for j in contest_q:
        blank = j-cur
        cur = j+1
        p1 += blank*(blank+1)//2*c[q]
    blank = d+1-cur
    p1 += blank*(blank+1)//2*c[q]
    cur = 1
    for j in contest_o:
        blank = j-cur
        cur = j+1
        p2 += blank*(blank+1)//2*c[old]
    blank = d+1-cur
    p2 += blank*(blank+1)//2*c[old]
    ds -= p1+p2
    return (ds,p1,p2)
while time()-T < 1.8:
    di = randint(1,d)
    qi = randint(1,26)
    old = contests[di]
    ds,p1,p2 = dscore(di,qi)
    if ds > 0:
        ans += ds
        penalty[old] = p2
        penalty[qi] = p1
        contest[old].remove(di)
        bisect.insort(contest[qi],di)
        contests[di] = qi
for i in range(1,d+1):
    print(contests[i])

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import random
import time
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    start = time.time()
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 100000
    sum_ = sum(c)
    q = [(0, 0, [0]*n, sum_)]
    pre = [[None]*n for i in range(d)]
    sc = [[float("inf")]*n for i in range(d)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, x, last, minus = heappop(q)
            if i > 0 and v > sc[i-1][x]:
                continue
            for ti in range(n):
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                heappush(nq,(nv,ti,nl,nm))
                if sc[i][ti] > nv:
                    sc[i][ti] = nv
                    pre[i][ti] = x
        q = [i for i in nq]
    t = []
    argmax = 0
    m = sc[-1][0]
    for i in range(1,n):
        sci = sc[-1][i]
        if m > sci:
            m = sci
            argmax = i
    t.append(argmax)
    x = argmax
    for i in range(1,d)[::-1]:
        y = pre[i][x]
        t.append(y)
        x = y
    t = [i+1 for i in t[::-1]]
    v = score(t)
    i = 0
    while time.time() < 1.8+start:
        nt = [i for i in t]
        r = random.randrange(1,n+1)
        nt[i] = r
        nv = score(nt)
        if v < nv:
            t = [i for i in nt]
            v = nv
        i += 1
        i %= d
    for i in t:
        print(i)
    return


if __name__ == "__main__":
    solve()