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):
def solve(d,c,s,k):
    last=[0]*27
    srate=[]
    ans=[]
    for i in range(1,d+1):
        a=0
        for j in range(1,27):
            a-=c[j-1]*(i-last[j])
        pa=0
        mlast=[0]*2
        for t in range(1,27):
            if s[i-1][t-1]+c[t-1]*(min(k*(k-1)/2,(366-d)*((366-d)-1)/2))>pa:
                mlast=[t,i]
                pa=s[i-1][t-1]+c[t-1]*(i-last[t])
        a+=pa
        last[mlast[0]]=mlast[1]           
        ans.append(mlast[0])
        srate.append(a)
    return ans,srate

def main():
    d=int(input())
    c=list(map(int,input().split()))
    s=[list(map(int,input().split())) for _ in range(d)]
    mrate=0
    ans,srate=solve(d,c,s,3)
    for i in ans:
        print(i)
    

if __name__ == '__main__':
    main()

Solution (Python):
import random
import time
import copy

t1=time.time()
d=int(input())
c=input()
cl=[int(n) for n in c.split()]
sl=list()
for i in range(d):
    s=input()
    sl=sl+[int(n) for n in s.split()]
tl=list()
for i in range(d):
    tl.append(random.randint(1,26))
sat=0
for i in range(d):
    sat+=sl[i*26+tl[i]-1]
last=list()
for i in range(26):
    last.append([a for a, x in enumerate(tl) if x==i+1])
dec=0
for i in range(26):
    if last[i]==list():
        dec+=(d*(d+1)/2)*cl[i]
    else:
        for v in range(len(last[i])):
            if v!=len(last[i])-1:    
                dec+=cl[i]*(last[i][v+1]-last[i][v]-1)*(last[i][v+1]-last[i][v])/2
            else:
                dec+=cl[i]*(d-last[i][v]-1)*(d-last[i][v])/2
        dec+=cl[i]*(last[i][0])*(last[i][0]+1)/2
        
def dechf(i,last):
    dech=0
    if last[i]==list():
        dech+=(d*(d+1)/2)*cl[i]
    else:
        for v in range(len(last[i])):
            if v!=len(last[i])-1:    
                dech+=cl[i]*(last[i][v+1]-last[i][v]-1)*(last[i][v+1]-last[i][v])/2
            else:
                dech+=cl[i]*(d-last[i][v]-1)*(d-last[i][v])/2
        dech+=cl[i]*(last[i][0])*(last[i][0]+1)/2
    return(int(dech))


oldlast=copy.deepcopy(last)
oldans=sat-int(dec)
oldtl=copy.copy(tl)
t2=time.time()
newans=0
while t2-t1<1.85:
    if round(t2)%2==0:
        d1=random.randint(1,d)
        d2=random.randint(1,d)
        if d1==d2:
            continue
        q1=tl[d2-1]
        q2=tl[d1-1]
        cha=sl[(d1-1)*26+q1-1]-sl[(d1-1)*26+tl[d1-1]-1]+sl[(d2-1)*26+q2-1]-sl[(d2-1)*26+tl[d2-1]-1]
        i=tl[d1-1]-1
        dech=dechf(i,last)
        i=tl[d2-1]-1
        dech+=dechf(i,last)
        last[tl[d2-1]-1].remove(d2-1)
        last[tl[d1-1]-1].remove(d1-1)
        last[tl[d1-1]-1].append(d2-1)
        last[tl[d1-1]-1].sort()
        last[tl[d2-1]-1].append(d1-1)
        last[tl[d2-1]-1].sort()
        tl[d2-1]=q2
        tl[d1-1]=q1
        i=tl[d1-1]-1
        dech-=dechf(i,last)
        i=tl[d2-1]-1
        dech-=dechf(i,last)
        newans=oldans+cha-dech
    else:
        da=random.randint(1,d)
        q=random.randint(1,26)
        cha=sl[(da-1)*26+q-1]-sl[(da-1)*26+tl[da-1]-1]
        i=tl[da-1]-1
        dech=dechf(i,last)
        last[tl[da-1]-1].remove(da-1)
        last[q-1].append(da-1)
        last[q-1].sort()
        tl[da-1]=q
        i=tl[da-1]-1
        dech-=dechf(i,last)
        newans=oldans+cha-dech
    r=0
    if newans<oldans:
        if 2.7**((newans-oldans)/(1.85-(t2-t1)))<random.random():
            r=1
    if r==1:
        tl=copy.copy(oldtl)
        last=[i[:] for i in oldlast]
    else:
        oldans=newans
        oldtl=copy.copy(tl)
        oldlast=[i[:] for i in last]
    t2=time.time()
for i in range(d):
    print(tl[i])

Solution (Python):
def solve(d,c,s,k):
    last=[0]*27
    srate=[]
    ans=[]
    for i in range(1,d+1):
        a=0
        for j in range(1,27):
            a-=c[j-1]*(i-last[j])
        pa=0
        mlast=[0]*2
        for t in range(1,27):
            if s[i-1][t-1]+c[t-1]*(min(k*(k-1)/2,(366-d)*((366-d)-1)/2))>pa:
                mlast=[t,i]
                pa=s[i-1][t-1]+c[t-1]*(i-last[t])
        a+=pa
        last[mlast[0]]=mlast[1]           
        ans.append(mlast[0])
        srate.append(a)
    return ans,srate

def main():
    d=int(input())
    c=list(map(int,input().split()))
    s=[list(map(int,input().split())) for _ in range(d)]
    ans,srate=solve(d,c,s,13)
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import numpy as np

def main():
  input = sys.stdin.readline
  d = int(input())
  c = np.array([int(x) for x in input().split()])
  
  last = np.zeros(26, dtype="int64")
  
  for i in range(d):
    s = np.array([int(x) for x in input().split()])
    key, value = -1, -1
    for i in range(26):
      if value < s[i] + last[i]:
        key = i
        value = s[i] + last[i]
    last[key] = 0
    print(key+1)
    last += c

if __name__ == "__main__":
  main()

Solution (Python):
import numpy
d = int(input())
c = list(map(int, input().split()))

for _ in range(d):
    s = list(map(int, input().split()))
    print(numpy.argmax(s) + 1)

Solution (Python):
d = int(input())
c = list(map(int, input().split()))

for _ in range(d):
    s = list(map(int, input().split()))
    ret = -20000
    ans = 1
    for i in range(26):
        tmp = s[i] - c[i] * 200
        if ret < tmp:
            ret = tmp
            ans = i + 1
    print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import exp, ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, e
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import random
import time
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

start = time.time()

D = INT()
C = LIST()
s = [LIST() for _ in range(D)]

def decrease(d, j):  
    tmp = 0
    for i in range(26):
        if i == j: continue
        tmp += C[i]*(d-last[i])
    return tmp 

def init():  
    global now
    for i in range(D):  
        ma = -INF
        ma_idx = None
        for j in range(26):  
            tmp = now
            tmp += s[i][j]
            tmp -= decrease(i+1, j)
            if tmp > ma:
                ma = tmp
                ma_idx = j
        now = ma
        last[ma_idx] = i+1
        score[ma_idx] += s[i][ma_idx]
        for j in range(26):
            score[j] -= C[j]*(i+1-last[j])
        last[ma_idx] = i+1
        ans[i] = ma_idx+1

def update(d, q):  
    d -= 1
    q -= 1
    c = ans[d]-1  
    ans[d] = q+1
    last_c = 0
    last_q = 0
    score_c = 0
    score_q = 0
    for j in range(D):
        if ans[j]-1 == c:
            last_c = j+1
            score_c += s[j][c]
        elif ans[j]-1 == q:
            last_q = j+1
            score_q += s[j][q]
        score_c -= C[c] * (j+1 - last_c)
        score_q -= C[q] * (j+1 - last_q)
    score[c] = score_c
    score[q] = score_q

def swap(d):  
    update(d, ans[d])
    update(d+1, ans[d-1])

ans = [0]*D
last = [0]*26
score = [0]*26
now = 0

init()

TL = 1.8 - (time.time()-start)
start = time.time()
T0 = 2e3
T1 = 6e2
T = T0
randint = random.randint
rand = random.random
while 1:
    t = (time.time()-start)/TL
    if t >= 1:
        break
    T = pow(T0, 1-t)*pow(T1, t)
    if rand() < 0.5:  
        d = randint(1, D)
        q = randint(1, 26)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        update(d, q)
        s_new = sum(score)
        if s_new <= s_old and exp((s_new-s_old)/T) <= rand():  
            score = old_score
            ans[d-1] = old
    else:  
        d = randint(1, D-1)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        swap(d)
        s_new = sum(score)
        if s_new <= s_old and exp((s_new-s_old)/T) <= rand():
            score = old_score
            ans[d-1] = old

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import exp, ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, e
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import random
import time
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

start = time.time()

D = INT()
C = LIST()
s = [LIST() for _ in range(D)]

def decrease(d, j):  
    tmp = 0
    for i in range(26):
        if i == j: continue
        tmp += C[i]*(d-last[i])
    return tmp 

def init():  
    global now
    for i in range(D):  
        ma = -INF
        ma_idx = None
        for j in range(26):  
            tmp = now
            tmp += s[i][j]
            tmp -= decrease(i+1, j)
            if tmp > ma:
                ma = tmp
                ma_idx = j
        now = ma
        last[ma_idx] = i+1
        score[ma_idx] += s[i][ma_idx]
        for j in range(26):
            score[j] -= C[j]*(i+1-last[j])
        last[ma_idx] = i+1
        ans[i] = ma_idx+1

def update(d, q):  
    d -= 1
    q -= 1
    c = ans[d]-1  
    ans[d] = q+1
    last_c = 0
    last_q = 0
    score_c = 0
    score_q = 0
    for j in range(D):
        if ans[j]-1 == c:
            last_c = j+1
            score_c += s[j][c]
        elif ans[j]-1 == q:
            last_q = j+1
            score_q += s[j][q]
        score_c -= C[c] * (j+1 - last_c)
        score_q -= C[q] * (j+1 - last_q)
    score[c] = score_c
    score[q] = score_q

def swap(d):  
    update(d, ans[d])
    update(d+1, ans[d-1])

ans = [0]*D
last = [0]*26
score = [0]*26
now = 0

init()

TL = 1.8 - (time.time()-start)
start = time.time()
T0 = 2e3
T1 = 6e2
T = T0
randint = random.randint
rand = random.random
while 1:
    t = (time.time()-start)/TL
    if t >= 1:
        break
    T = pow(T0, 1-t)*pow(T1, t)
    if rand() < 0.5:  
        d = randint(1, D)
        q = randint(1, 26)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        update(d, q)
        s_new = sum(score)
        if s_new <= s_old and exp((s_new-s_old)/T) <= rand():  
            score = old_score
            ans[d-1] = old
    else:  
        d = randint(1, D-1)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        swap(d)
        s_new = sum(score)
        if s_new <= s_old and exp((s_new-s_old)/T) <= rand():
            score = old_score
            ans[d-1] = old

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import exp, ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, e
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import random
import time
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

start = time.time()

D = INT()
C = LIST()
s = [LIST() for _ in range(D)]

def compute_score(out):
    score = 0
    last = [0]*26

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

    return score

def decrease(d, j):  
    tmp = 0
    for i in range(26):
        if i == j: continue
        tmp += C[i]*(d-last[i])
    return tmp 

def init():  
    global now
    for i in range(D):  
        ma = -INF
        ma_idx = None
        for j in range(26):  
            tmp = now
            tmp += s[i][j]
            tmp -= decrease(i+1, j)
            if tmp > ma:
                ma = tmp
                ma_idx = j
        now = ma
        last[ma_idx] = i+1
        score[ma_idx] += s[i][ma_idx]
        for j in range(26):
            score[j] -= C[j]*(i+1-last[j])
        last[ma_idx] = i+1
        ans[i] = ma_idx+1

def update(d, q):  
    d -= 1
    q -= 1
    c = ans[d]-1  
    ans[d] = q+1
    last_c = 0
    last_q = 0
    score_c = 0
    score_q = 0
    for j in range(D):
        if ans[j]-1 == c:
            last_c = j+1
            score_c += s[j][c]
        elif ans[j]-1 == q:
            last_q = j+1
            score_q += s[j][q]
        score_c -= C[c] * (j+1 - last_c)
        score_q -= C[q] * (j+1 - last_q)
    score[c] = score_c
    score[q] = score_q

def swap(d):  
    update(d, ans[d])
    update(d+1, ans[d-1])

ans = [0]*D
last = [0]*26
score = [0]*26
now = 0

init()

TL = 1.8 - (time.time()-start)
start = time.time()
T0 = 2e3
T1 = 6e2
T = T0
randint = random.randint
rand = random.random
while 1:
    t = (time.time()-start)/TL
    if t >= 1:
        break
    T = pow(T0, 1-t)*pow(T1, t)
    if rand() < 0.5:  
        d = randint(1, D)
        q = randint(1, 26)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        update(d, q)
        s_new = sum(score)
        if s_new <= s_old and exp((s_new-s_old)/T) <= rand():  
            score = old_score
            ans[d-1] = old
    else:  
        d = randint(1, D-1)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        swap(d)
        s_new = sum(score)
        if s_new <= s_old and exp((s_new-s_old)/T) <= rand():
            score = old_score
            ans[d-1] = old

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

Solution (Python):
D = int(input())
C = list(map(int, input().split()))
S = []
N = 26
for d in range(D):
    S += [list(map(int, input().split()))]


myans = [d%N for d in range(D)]
for d in range(D):
  print(myans[d]+1)

Solution (Python):
def main():
    D = int(input())
    C = [0] * 26
    C = list(map(int,input().split()))
    S = [ list(map(int,input().split(" "))) for i in range(D)]
    
    last = [0] * 26
    for i in range(D):
        max = -9999999999999
        max_t = 0
        for t in range(26):
            score = 0
            for j in range(26):
                if j == t:
                    
                    score += S[i][j]
                else:
                    
                    score -= (last[j]+10)*C[j]
            if  score > max:
                max = score
                max_t = t
        for j in range(26):
            if j == max_t:
                last[j] = 0
            else:
                last[j] += 1
        print(max_t + 1)
if __name__ == '__main__':
    main()

Solution (Python):
import time


def data_input():
    D = int(input())
    C = tuple(map(int, input().split()))

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

    return D, C, S


def score(D, C, S, T):
    """入力D, C, Sと出力Tからスコアを計算する関数"""

    last = [0] * 26  

    def decrease(d):
        """d日めにiを開催した時の満足度の減少を返す関数"""
        res = 0
        base = sum(C)
        for i in range(26):
            res += S[d][i] - C[i] * (d+1 - last[i])
        return res

    v = 0
    for d, i in enumerate(T):
        last[i] = d + 1
        v += decrease(d)
    return v


start_time = time.time()
D, C, S = data_input()
input_time = time.time() - start_time

T = []

max_v = 0
for d in range(D):
    max_t = 0
    for i in range(26):
        v = score(d, C, S[:d+1], T+[i])
        if v > max_v:
            
            max_t = i
            max_v = v
    T.append(max_t)
    print(max_t+1)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, e
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import random
import time
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

start = time.time()

D = INT()
C = LIST()
s = [LIST() for _ in range(D)]

def compute_score(out):
    score = 0
    last = [0]*26

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

    return score

def decrease(d, j):  
    tmp = 0
    for i in range(26):
        if i == j: continue
        tmp += C[i]*(d-last[i])
    return tmp 

def init():  
    global now
    for i in range(D):  
        ma = -INF
        ma_idx = None
        for j in range(26):  
            tmp = now
            tmp += s[i][j]
            tmp -= decrease(i+1, j)
            if tmp > ma:
                ma = tmp
                ma_idx = j
        now = ma
        last[ma_idx] = i+1
        score[ma_idx] += s[i][ma_idx]
        for j in range(26):
            score[j] -= C[j]*(i+1-last[j])
        last[ma_idx] = i+1
        ans[i] = ma_idx+1

def update(d, q):  
    d -= 1
    q -= 1
    c = ans[d]-1  
    ans[d] = q+1
    last_c = 0
    last_q = 0
    score_c = 0
    score_q = 0
    for j in range(D):
        if ans[j]-1 == c:
            last_c = j+1
            score_c += s[j][c]
        elif ans[j]-1 == q:
            last_q = j+1
            score_q += s[j][q]
        score_c -= C[c] * (j+1 - last_c)
        score_q -= C[q] * (j+1 - last_q)
    score[c] = score_c
    score[q] = score_q

def swap(d):  
    update(d, ans[d])
    update(d+1, ans[d-1])

ans = [0]*D
last = [0]*26
score = [0]*26
now = 0

init()

TL = 1.7 - (time.time()-start)
start = time.time()
T0 = 2e3
T1 = 6e2
T = T0
randint = random.randint
rand = random.random
while 1:
    t = (time.time()-start)/TL
    if t >= 1:
        break
    T = pow(T0, 1-t)*pow(T1, t)
    if rand() < 0.5:  
        d = randint(1, D)
        q = randint(1, 26)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        update(d, q)
        s_new = sum(score)
        if s_new <= s_old or (s_old-s_new) >= T or ((s_old-s_new) <= T and pow(e, (s_old-s_new)/T) >= rand()):  
            score = old_score
            ans[d-1] = old
    else:  
        d = randint(1, D-1)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        swap(d)
        s_new = sum(score)
        if s_new <= s_old or (s_old-s_new) >= T or ((s_old-s_new) <= T and pow(e, (s_old-s_new)/T) >= rand()):
            score = old_score
            ans[d-1] = old
print(*ans, sep="\n")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, e
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import random
import time
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

start = time.time()

D = INT()
C = LIST()
s = [LIST() for _ in range(D)]

def compute_score(out):
    score = 0
    last = [0]*26

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

    return score

def decrease(d, j):  
    tmp = 0
    for i in range(26):
        if i == j: continue
        tmp += C[i]*(d-last[i])
    return tmp 

def init():  
    global now
    for i in range(D):  
        ma = -INF
        ma_idx = None
        for j in range(26):  
            tmp = now
            tmp += s[i][j]
            tmp -= decrease(i+1, j)
            if tmp > ma:
                ma = tmp
                ma_idx = j
        now = ma
        last[ma_idx] = i+1
        score[ma_idx] += s[i][ma_idx]
        for j in range(26):
            score[j] -= C[j]*(i+1-last[j])
        last[ma_idx] = i+1
        ans[i] = ma_idx+1

def update(d, q):  
    d -= 1
    q -= 1
    c = ans[d]-1  
    ans[d] = q+1
    last_c = 0
    last_q = 0
    score_c = 0
    score_q = 0
    for j in range(D):
        if ans[j]-1 == c:
            last_c = j+1
            score_c += s[j][c]
        elif ans[j]-1 == q:
            last_q = j+1
            score_q += s[j][q]
        score_c -= C[c] * (j+1 - last_c)
        score_q -= C[q] * (j+1 - last_q)
    score[c] = score_c
    score[q] = score_q

def swap(d):  
    update(d, ans[d])
    update(d+1, ans[d-1])

ans = [0]*D
last = [0]*26
score = [0]*26
now = 0

init()

TL = 1.8 - (time.time()-start)
start = time.time()
T0 = 2e3
T1 = 6e2
T = T0
randint = random.randint
rand = random.random
while 1:
    t = (time.time()-start)/TL
    if t >= 1:
        break
    T = pow(T0, 1-t)*pow(T1, t)
    if rand() < 0.5:  
        d = randint(1, D)
        q = randint(1, 26)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        update(d, q)
        s_new = sum(score)
        if s_new <= s_old or (s_old-s_new) >= T or ((s_old-s_new) <= T and pow(e, (s_old-s_new)/T) >= rand()):  
            score = old_score
            ans[d-1] = old
    else:  
        d = randint(1, D-1)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        swap(d)
        s_new = sum(score)
        if s_new <= s_old or (s_old-s_new) >= T or ((s_old-s_new) <= T and pow(e, (s_old-s_new)/T) >= rand()):
            score = old_score
            ans[d-1] = old
print(*ans, sep="\n")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, e
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
import random
import time
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

start = time.time()

D = INT()
C = LIST()
s = [LIST() for _ in range(D)]

def compute_score(out):
    score = 0
    last = [0]*26

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

    return score

def decrease(d, j):  
    tmp = 0
    for i in range(26):
        if i == j: continue
        tmp += C[i]*(d-last[i])
    return tmp 

def init():  
    global now
    for i in range(D):  
        ma = -INF
        ma_idx = None
        for j in range(26):  
            tmp = now
            tmp += s[i][j]
            tmp -= decrease(i+1, j)
            if tmp > ma:
                ma = tmp
                ma_idx = j
        now = ma
        last[ma_idx] = i+1
        score[ma_idx] += s[i][ma_idx]
        for j in range(26):
            score[j] -= C[j]*(i+1-last[j])
        last[ma_idx] = i+1
        ans[i] = ma_idx+1

def update(d, q):  
    d -= 1
    q -= 1
    c = ans[d]-1  
    ans[d] = q+1
    last_c = 0
    last_q = 0
    score_c = 0
    score_q = 0
    for j in range(D):
        if ans[j]-1 == c:
            last_c = j+1
            score_c += s[j][c]
        elif ans[j]-1 == q:
            last_q = j+1
            score_q += s[j][q]
        score_c -= C[c] * (j+1 - last_c)
        score_q -= C[q] * (j+1 - last_q)
    score[c] = score_c
    score[q] = score_q

def swap(d):  
    update(d, ans[d])
    update(d+1, ans[d-1])

ans = [0]*D
last = [0]*26
score = [0]*26
now = 0

init()

TL = 1.8 - (time.time()-start)
start = time.time()
T0 = 2e3
T1 = 6e2
T = T0
randint = random.randint
rand = random.random
while 1:
    t = (time.time()-start)/TL
    if t >= 1:
        break
    T = pow(T0, 1-t)*pow(T1, t)
    if rand() < 0.5:  
        d = randint(1, D)
        q = randint(1, 26)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        update(d, q)
        s_new = sum(score)
        if s_new <= s_old or (s_old-s_new) >= T and ((s_old-s_new) <= T and pow(e, (s_old-s_new)/T) >= rand()):  
            score = old_score
            ans[d-1] = old
    else:  
        d = randint(1, D-1)
        old = ans[d-1]
        old_score = score.copy()
        s_old = sum(score)
        swap(d)
        s_new = sum(score)
        if s_new <= s_old or (s_old-s_new) >= T and ((s_old-s_new) <= T and pow(e, (s_old-s_new)/T) >= rand()):
            score = old_score
            ans[d-1] = old
print(*ans, sep="\n")

Solution (Python):
def main():
    D = int(input())
    C = [0] * 26
    C = list(map(int,input().split()))
    S = [ list(map(int,input().split(" "))) for i in range(D)]
    
    last = [0] * 26
    for i in range(D):
        max = -9999999999999
        max_t = 0
        for t in range(26):
            score = 0
            for j in range(26):
                if j == t:
                    
                    score += S[i][j]
                else:
                    
                    score -= (last[j]+3)*C[j]
            if  score > max:
                max = score
                max_t = t
        for j in range(26):
            if j == max_t:
                last[j] = 0
            else:
                last[j] += 1
        print(max_t + 1)
if __name__ == '__main__':
    main()