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 os
import sys

import numpy as np


def solve(inp):
    def bitree_sum(bit, t, i):
        s = 0
        while i > 0:
            s += bit[t, i]
            i ^= i & -i
        return s

    def bitree_add(bit, n, t, i, x):
        while i <= n:
            bit[t, i] += x
            i += i & -i

    def bitree_lower_bound(bit, n, d, t, x):
        sum_ = 0
        pos = 0
        for i in range(d, -1, -1):
            k = pos + (1 << i)
            if k <= n and sum_ + bit[t, k] < x:
                sum_ += bit[t, k]
                pos += 1 << i
        return pos + 1

    def initial_score(d, ccc, sss, ttt):
        bit_n = d + 3
        bit = np.zeros((26, bit_n), dtype=np.int64)
        INF = 10 ** 18
        for t in range(26):
            bitree_add(bit, bit_n, t, bit_n - 1, INF)

        last = np.full(26, -1, dtype=np.int64)
        score = 0

        for i in range(d):
            t = ttt[i]
            score += sss[i, t]
            for u in range(26):
                if u == t:
                    continue
                score -= ccc[u] * (i - last[u])
            last[t] = i
            bitree_add(bit, bit_n, t, i + 2, 1)

        return bit, score

    def update_score(bit, bit_n, bit_d, ccc, sss, ttt, d, q):
        diff = 0
        t = ttt[d]
        k = bitree_sum(bit, t, d + 2)
        c = bitree_lower_bound(bit, bit_n, bit_d, t, k - 1) - 2
        e = bitree_lower_bound(bit, bit_n, bit_d, t, k + 1) - 2
        b = ccc[t]
        diff -= b * (d - c) * (e - d)
        diff -= sss[d, t]

        k = bitree_sum(bit, q, d + 2)
        c = bitree_lower_bound(bit, bit_n, bit_d, q, k) - 2
        e = bitree_lower_bound(bit, bit_n, bit_d, q, k + 1) - 2
        b = ccc[q]
        diff += b * (d - c) * (e - d)
        diff += sss[d, q]

        return diff

    d = inp[0]
    ccc = inp[1:27]
    sss = np.zeros((d, 26), dtype=np.int64)
    for r in range(d):
        sss[r] = inp[27 + r * 26:27 + (r + 1) * 26]

    ttt = np.random.choice(26, d)

    bit, score = initial_score(d, ccc, sss, ttt)
    bit_n = d + 3
    bit_d = int(np.log2(bit_n))

    for _ in range(5 * 10 ** 6):
        cd = np.random.randint(0, d)
        ct = np.random.randint(0, 26)
        diff = update_score(bit, bit_n, bit_d, ccc, sss, ttt, cd, ct)
        if diff > 0:
            score += diff
            bitree_add(bit, bit_n, ttt[cd], cd + 2, -1)
            bitree_add(bit, bit_n, ct, cd + 2, 1)
            ttt[cd] = ct

    return ttt + 1


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def scores(c, s, t):
    last = [0] * 26
    V = []
    lastv = 0
    D = len(t)
    for d, i in enumerate(t):
        last[i] = d+1
        if d != D-1:
            continue
        v = s[d*26+i]
        sub = sum([c[j]*(d+1-last[j]) for j in range(26)])
        
        lastv += v-sub
        V.append(lastv)
    return V


def main():
    D, *cs = map(int, read().split())
    c = cs[:26]
    s = cs[26:]

    b = 0
    ans = []
    for d in range(D):
        maxi = 0
        score_max = -1000000000
        for i in range(26):
            score = scores(c, s, ans + [i])[-1]
            
            if score > score_max:
                maxi = i
                score_max = score
        ans.append(maxi)
        b += 26

    ans = [a+1 for a in ans]
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

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

Solution (Python):
D = int(input())
C = list(map(int ,input().split()))
S = [list(map(int, input().split())) for i in range(D)]
sumc = sum(C)
last = [0 for i in range(26)]

for i in range(D):
    ans = 0
    m = -1000000000000
    t = 1
    for k in range(26):
        l = last[k]
        last[k] = i+1
        ans = S[i][k]
        for j in range(26):
            ans -= C[j]*(i+1 - last[j])
        if ans > m:
            m = ans
            t = k + 1
        last[k] = l
    last[t-1] = i+1
    print(t)

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

 
last=[0 for i in range(26)]
 
for i in range(D):
  best=0
  sat=0
  for j in range(26):
    tempsat=0
    tempsat+=s[i][j]
    templast=last[j]
    last[j]=i
    for k in range(26):
      tempsat-=c[k]*(i-last[k])
    if(sat<=tempsat):
      sat=tempsat
      best=j
    last[j]=templast
  print(best+1)

Solution (Python):


from time import perf_counter

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

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

    while perf_counter() < 1.9:
        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 random
import math
import copy

def calc(D, solution):
    satisfaction = 0
    for i in range(D):
        satisfaction = S[i][solution[i]-1] + satisfaction - \
                       sum([C[k] * ((i + 1) - last[k]) for k in range(26)]) \
                       + C[solution[i]-1] * ((i + 1) - last[solution[i]-1])

    return satisfaction


D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
satisfaction = 0
last = [0]*26
solution = []

for i in range(D):
    best_sat = -100000000000
    for t in range(26):
        t_sat = S[i][t] + satisfaction - \
                sum([C[k]*((i+1)-last[k]) for k in range(26)]) + C[t]*((i+1)-last[t])
        
        if t_sat > best_sat:
            best_T = t
            best_sat = t_sat

    satisfaction = best_sat
    last[best_T] = i + 1
    solution.append(best_T+1)

for i in range(100):
    r = math.ceil(random.random()*26)
    if r == 0:
        r = 1
    f = math.floor(random.random()*D)
    f_solution = copy.deepcopy(solution)
    f_solution[f] = r
    present_sat = calc(D,solution)
    new_sat = calc(D,f_solution)
    
    if new_sat > present_sat:
        solution = f_solution

    

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

Solution (Python):
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]
t = []
last = [[-1] for i in range(26)]


for i in range(D):
    op = 0
    mx = 0
    for j in range(26):
        if s[i][j]*c[j] > mx:
            mx = s[i][j]*c[j]
            op = j
    t.append(op+1)
    last[op].append(i)
    
    
    
    
    
    


from bisect import *
import random
m = 2000000
def suminc(a,b):
    return b*(b-1)//2-a*(a-1)//2
while m:
    m-=1
    update = 0
    d = random.randint(1,D)
    q = random.randint(1,26)
    d-=1
    q-=1
    oq = t[d]-1
    update += s[d][q]-s[d][oq]
    idx = bisect_left(last[oq],d)
    if idx == len(last[oq])-1:
        cnt = D - last[oq][idx]
    else:
        cnt = last[oq][idx+1] - last[oq][idx]
    update += c[oq]*suminc(0,cnt)
    cntprv = last[oq][idx] - last[oq][idx-1]
    update -= c[oq]*suminc(cntprv,cntprv+cnt)

    idx2 = bisect_left(last[q],d)-1
    if idx2 == len(last[q])-1:
        cnt = D - d
    else:
        cnt = last[q][idx2+1] - d
    if idx2 == len(last[q])-1:
        cntprv = D - last[q][idx2] - cnt
    else:
        cntprv = last[q][idx2+1] - last[q][idx2] - cnt
    update += c[q]*suminc(cntprv,cntprv+cnt)
    update -= c[q]*suminc(0,cnt)

    if update > 0:
    
        del last[oq][idx]
        last[q].insert(idx2+1,d)
        
        t[d] = q+1





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

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

Solution (Python):
import time
import random

def check(j,l,r):
    global point
    last=[0]*26
    sum_=0
    t=ans.copy()
    t[l],t[r]=t[r],t[l]
    for i in range(D):
        d=i+1
        sum_+=s[i][t[i]]
        for k in range(26):
            if t[i]==k:
                continue
            sum_-=c[k]*(d-last[k])
        last[t[i]]=d
    if sum_>point:
        point=sum_
        return True
    else:
        return False

start=time.time()
INF=10**30
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
last=[0]*26
ans=[]
point=0
for i in range(D):
    d=i+1
    res=-INF
    z=-1
    for j in range(26):
        p=s[i][j]
        for k in range(26):
            if k==j:
                continue
            p-=c[k]*(d-last[k])
        res=max(res,p)
        if res==p:
            z=j
    ans.append(z)
    last[z]=i+1
    point+=res

while True:
    if time.time()-start>1.80:
        break
    for i in range(D):
        if time.time()-start>1.80:
            break
        l=random.randrange(D)
        r=random.randrange(D)
        if check(i,l,r):
            ans[l],ans[r]=ans[r],ans[l]
for i in range(D):
    print(ans[i]+1)

Solution (Python):
D = int(input())
C = list(map(int, input().split()))
S = [tuple(map(int, input().split())) for _ in range(D)]
Z = 26

last = [-1] * Z
ans = 0
T = []
for d in range(D):
    maxScore = -float('inf')
    cand = 0
    for i in range(26):
        tmp = last[i]
        last[i] = d
        up = S[d][i]
        down = sum(C[j] * (d - last[j]) for j in range(Z))
        score = up - down
        if maxScore < score:
            cand = i
            maxScore = score
        last[i] = tmp
    T.append(cand + 1)
print(*T, sep='\n')

Solution (Python):
from bisect import bisect_right, bisect_left

class BITbisect():
    def __init__(self, InputProbNumbers):
        
        self.ind_to_co = [-10**18]
        self.co_to_ind = {}
        for ind, num in enumerate(InputProbNumbers):
            self.ind_to_co.append(num)
            self.co_to_ind[num] = ind+1
        self.max = len(self.co_to_ind)
        self.data = [0]*(self.max+1)
    
    def __str__(self):
        retList = []
        for i in range(1, self.max+1):
            x = self.ind_to_co[i]
            if self.count(x):
                c = self.count(x)
                for _ in range(c):
                    retList.append(x)
        return "[" + ", ".join([str(a) for a in retList]) + "]"
    
    def __getitem__(self, key):
        key += 1
        s = 0
        ind = 0
        l = self.max.bit_length()
        for i in reversed(range(l)):
            if ind + (1<<i) <= self.max:
                if s + self.data[ind+(1<<i)] < key:
                    s += self.data[ind+(1<<i)]
                    ind += (1<<i)
        if ind == self.max or key < 0:
            raise IndexError("BIT index out of range")
        return self.ind_to_co[ind+1]
    
    def __len__(self):
        return self._query_sum(self.max)
    
    def __contains__(self, num):
        if not num in self.co_to_ind:
            return False
        return self.count(num) > 0
    
    
    
    def _query_sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    
    
    def _add(self, i, x):
        while i <= self.max:
            self.data[i] += x
            i += i & -i
    
    
    def push(self, x):
        if not x in self.co_to_ind:
            raise KeyError("The pushing number didnt initialized")
        self._add(self.co_to_ind[x], 1)
            
    
    def delete(self, x):
        if not x in self.co_to_ind:
            raise KeyError("The deleting number didnt initialized")
        if self.count(x) <= 0:
            raise ValueError("The deleting number doesnt exist")
        self._add(self.co_to_ind[x], -1)

    
    def count(self, x):
        return self._query_sum(self.co_to_ind[x]) - self._query_sum(self.co_to_ind[x]-1)
    
    
    def bisect_right(self, x):
        if x in self.co_to_ind:
            i = self.co_to_ind[x]
        else:
            i = bisect_right(self.ind_to_co, x) - 1
        return self._query_sum(i)

    
    def bisect_left(self, x):
        if x in self.co_to_ind:
            i = self.co_to_ind[x]
        else:
            i = bisect_left(self.ind_to_co, x)
        if i == 1:
            return 0
        return self._query_sum(i-1)

import sys
input = sys.stdin.readline

Days = int(input())
C = list(map(int, input().split())) 
Ss = [list(map(int, input().split())) for _ in range(Days)]


INF = 10**18

def outputToScore(T):
    last = [0]*26

    satisfied = 0
    for d, t in enumerate(T):
        t -= 1; d += 1
        satisfied += Ss[d-1][t]
        last[t] = d
        for i, c in enumerate(C):
            satisfied -= c*(d-last[i])
        
    return satisfied

def outputToScore2(T):
    last = [0]*26
    used = [BITbisect(list(range(Days+1))) for _ in range(26)]
    satisfied = 0
    for d, t in enumerate(T):
        t -= 1; d += 1
        satisfied += Ss[d-1][t]
        used[t].push(d)
        last[t] = d
        for i, c in enumerate(C):
            satisfied -= c*(d-last[i])
        
    return satisfied, used

def greedy():
    last = [0]*26
    T = []
    for d in range(Days):
        satisfied_max = -INF
        selected = -1
        for t in range(26):
            score_t = Ss[d][t]
            for j, c in enumerate(C):
                if t != j:
                    score_t -= c*(d+1-last[j])
            if score_t > satisfied_max:
                satisfied_max = score_t
                selected = t
        T.append(selected+1)
        last[selected] = d+1
    return T


def modifiedScore(d, aft, Used, T):
    aft -= 1
    bef = T[d-1]-1
    deltaSatis = Ss[d-1][aft] - Ss[d-1][bef]
    
    befind = Used[bef].bisect_left(d)
    aftind = Used[aft].bisect_left(d)
    
    
    
    
    befday0 = 0
    befday2 = Days+1
    if befind > 0:
        befday0 = Used[bef][befind-1]
    if befind < len(Used[bef])-1:
        befday2 = Used[bef][befind+1]
    befd01 = d - befday0
    befd12 = befday2 - d
    befd02 = befday2-befday0
    deltaSatis -= C[bef]*(befd02*(befd02-1)//2) - C[bef]*(befd01*(befd01-1)//2 + befd12*(befd12-1)//2)

    
    if len(Used[aft]) > 0:
        aftday0 = 0
        aftday2 = Days+1
        if aftind < len(Used[aft])-1:
            aftday2 = Used[aft][aftind]
        if aftind > 0:
            aftday0 = Used[aft][aftind-1]
        aftd01 = d - aftday0
        aftd12 = aftday2 - d
        aftd02 = aftd01 + aftd12
        deltaSatis += C[aft]*(aftd02*(aftd02-1)//2) - C[aft]*(aftd01*(aftd01-1)//2 + aftd12*(aftd12-1)//2)
    else:
        d01 = d
        d12 = Days+1 - d
        deltaSatis += C[aft] * Days*(Days+1)//2 - C[aft]*(d01*(d01-1)//2 + d12*(d12-1)//2)

    return deltaSatis

def goingup(T, Used):
    for d in reversed(range(Days)):
        d += 1
        tmp_score = -INF
        bef = T[d-1]-1
        aft = -1
        for t in range(26):
            if bef != t:
                ds = modifiedScore(d, t, Used, T)
                
                if ds > tmp_score:
                    tmp_score = ds
                    aft = t
        Used[bef].delete(d)
        Used[aft].push(d)
        T[d-1] = aft+1
    return T, Used




T = greedy()
Satisfied, Used = outputToScore2(T)

for _ in range(20):
    T, Used = goingup(T, Used)
    
    
for t in T:
    print(t)

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,25,20,15,99,98,97,96,95)
  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):
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	return int(input())
def s(x): 
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
sel = [0 for i in range(365)]

day = [[0 for i in range(26)] for j in range(365)]
ans = 0
for i in range(d):
	s.append(l())
	ss = [[s[-1][i],i+1] for i in range(26)]

	ak = 0

	for j in range(26):
		if i != 0:
			ak -= c[j] * (i-day[i-1][j]+1)
		else:
			ak -= c[j]

	ma = [-1,-1]
	for j in range(26):
		if i != 0:
			if ma[0] <= c[j] * (i-day[i-1][j]+1) + s[-1][j]:
				ma[0] = c[j] + (i-day[i-1][j]+1) + s[-1][j]
				ma[1] = j
		else:
			if ma[0] <= c[j] + s[-1][j]:
				ma[0] = c[j] + s[-1][j]
				ma[1] = j
	ans += ma[0] + ak
	sel[i] = ma[1]+1

	for j in range(26):
		if j == ma[1]:
			day[i][j] = i
		else:
			day[i][j] = day[i-1][j] if i - 1 >= 0 else 0



for _ in range(140000):
	ima = random.randrange(365)
	po = [[s[ima][i]-c[i],i+1] for i in range(26)]
	po.sort(reverse = True)
	while True:
		data = random.randrange(10)
		if sel[ima] != data+1:
			break
	data = po[data][1]-1
	ppp = 0
	for i in range(26):
		if ima == day[ima][i]:
			now = i
			break
	else:
		while True:
			now = random.randrange(26)
			if now != data:
				break 
	for i in range(ima+1,365):
		if day[i][data] == i:
			ppp += (i - ima) * c[data]
			break
	else:
		ppp += (364-ima) * c[data]
	ppp += s[ima][data]

	for i in range(ima+1,365):
		if day[i][now] == i:
			ppp -= (i - ima) * c[now]
			break
	else:
		ppp -= (364-ima) * c[now]
	ppp -= s[ima][now]
	if ppp > 0:
		for i in range(ima,365):
			if day[i][data] != i:
				day[i][data] = ima
			else:
				break
		po = ima - 1 if ima != 0 else 0
		for i in range(ima,365):
			if day[i][now] != i:
				day[i][now] = po
			else:
				break
		sel[ima] = data+1
		ans += ppp

for i in sel:
	print(i)

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)
        if d < D - 2:
            ret -= sum(ci * (d + 2 - 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):
import sys
from random import randint
input = sys.stdin.readline
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [randint(0, 25) for i in range(D)]
last = [0] * 26
def score(day, score):
  for i in range(26): score -= (day - last[i]) * c[i]
  return score
def run(day):
  global last
  last = [0] * 26
  res = 0
  for d in range(day):
    contest = t[d]
    last[contest] = d + 1
    res = score(d + 1, res) + s[d][contest]
  return res


for d in range(1, D + 1):
  mx = -float("inf")
  mxx = randint(0, 25)
  for x in range(26):
    t[d - 1] = x
    res = run(d)
    if mx < res:
      mx = res
      mxx = x
  t[d - 1] = mxx

for _ in range(3):
  ll = randint(1, 340)
  for l in range(ll, ll + 15):
    last = [0] * 26
    run(l)
    
    zmx = -float("inf")
    zmxz = 0
    for z in range(26):
      t[l - 1] = z

      for d in range(l + 1, D + 1):
        mx = -float("inf")
        mxx = t[d - 1]
        for x in range(26):
          t[d - 1] = x
          res = score(d, 0) + s[d - 1][x]
          if mx < res:
            mx = res
            mxx = x
        t[d - 1] = mxx
        last[mxx] = d
      zres = run(D)
      if zres > zmx:
        zmx = zres
        zmxz = z
    t[l - 1] = zmxz

for x in t: print(x + 1)

Solution (Python):
import sys
import random
import time
my_input = sys.stdin.readline

start = time.time()
D = int(input())
C = list(map(int, my_input().split()))
S = [list(map(int, my_input().split())) for _ in range(D)]


def main():
    cnt = 0
    best_ans, best_score = generate_first_ans()
    while time.time() - start < 1.81:
        cnt += 1
        ans = best_ans[:]

        x = random.random()
        if x > 0.2:
            si, sj = random.randint(0, 364), random.randint(0, 364)
            if si == sj:
                continue
            ans[si], ans[sj] = ans[sj], ans[si]
        else:
            ans[random.randint(0, 364)] = random.randint(0, 25)

        score = calc_score(ans)
        if score > best_score:
            best_score = score
            best_ans = ans

    
    for a in best_ans:
        print(a + 1)


def generate_first_ans():
    best_ans = []
    best_score = 0
    last_day = [-1] * 26
    for d in range(365):
        d_ans = -1
        d_score = -float('inf')
        d_last_day = [-1] * 26
        for t in range(26):
            d_tmp_score = 0
            d_tmp_score += S[d][t]
            d_tmp_last_day = last_day[:]
            d_tmp_last_day[t] = d
            for c, ld in zip(C, d_tmp_last_day):
                d_tmp_score -= c * (d - ld)

            if d_tmp_score > d_score:
                d_ans = t
                d_score = d_tmp_score
                d_last_day = d_tmp_last_day[:]

        best_ans.append(d_ans)
        best_score += d_score
        last_day = d_last_day[:]

    return best_ans, best_score


def calc_score(T):
    score = 0
    last_day = [-1] * 26
    for d, t in enumerate(T):
        score += S[d][t]
        last_day[t] = d
        for c, ld in zip(C, last_day):
            score -= c * (d - ld)
    return score


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(3*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)