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 random, time
start = time.time()
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]

t = []
memo = [0 for _ in range(26)]
for i in range(d):
    scores = []
    for j in range(26):
        delta_score = 0
        delta_score += s[i][j]
        for k in range(26):
            if j == k:
                continue
            delta_score -= c[k] * (i+1 - memo[k])
        scores.append((delta_score, j))

    scores.sort(key=lambda x: -x[0])
    choice = scores[0][1]
    t.append(choice)
    memo[choice] = i+1


def delta_scoring(t, x, y):
    delta_score = 0
    before_ti, after_ti = 0, d+1
    before_y, after_y = 0, d+1

    for i in range(x):
        if t[i] == t[x]:
            before_ti = i+1
        if t[i] == y:
            before_y = i+1

    for i in range(x+1, d):
        if t[i] == t[x]:
            after_ti = i+1
            break
    for i in range(x+1, d):
        if t[i] == y:
            after_y = i+1
            break

    delta_score -= s[x][t[x]]
    delta_score += s[x][y]
    delta_score -= c[t[x]] * (x + 1 - before_ti) * (after_ti - x - 1)
    delta_score += c[y] * (x + 1 - before_y) * (after_y - x - 1)

    return delta_score

while time.time() - start < 1.0:
    x = random.randint(0, d-1)
    y = random.randint(0, 25)
    if delta_scoring(t, x, y) > 0:
        t[x] = y


for i in range(d):
    print(t[i] + 1)

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]-c[i],i+1] for i in range(26)]
	ss.sort(reverse = True)
	data = ss[random.randrange(10)][1]
	sel[i] = ss[data-1][1]
	ans += s[i][data-1]

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



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]

	for i in range(ima+1,365):
		if day[i][now] == i:
			ppp += (i - ima) * c[now]
			break
	else:
		ppp -= (364-ima) * c[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

for i in sel:
	print(i)

Solution (Python):
from copy import deepcopy

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

def func(ans_lst):
    last = {}
    for i in range(1,27):
        last[i] = 0
    for i in range(5):
        last[ans_lst[i]] = i+1

    total_sat = 0
    for d in range(6,D+1):
        ans = [1,-float('inf')]
        for i in range(1,27):
            satisfaction = 0
            satisfaction += s[d-1][i-1]
            for j in range(1,27):
                if i != j:
                    satisfaction -= c[j-1]*(d-last[j])
            if ans[1] <= satisfaction:
                ans = [i,satisfaction]
        last[ans[0]] = d
        ans_lst.append(ans[0])
        total_sat += ans[1]
    return [total_sat,ans_lst]

def rec(d,ans_lst):
    if d == 6:
        return func(ans_lst)
    ans_lst1 = deepcopy(ans_lst)
    ans_lst2 = deepcopy(ans_lst)

    a,b,*gomi = sorted(s[d-1],reverse=True)
    ans_lst1.append(s[d-1].index(a)+1)
    ans_lst2.append(s[d-1].index(b)+1)
    ret = [rec(d+1,ans_lst1),rec(d+1,ans_lst2)]
    ret.sort(reverse=True)
    return ret[0]

out = rec(1,[])
for i in range(365):
    print(out[1][i])

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


cand = [[0, [], [-1]*26]]
while 1:
    for I in range(len(cand)):
        scr, tt, lst = cand[0]
        del cand[0]
        for j in range(26):
            score = scr
            for col in range(26):
                if col==j:
                    score += s[len(tt)][j]
                    lst[j] = len(tt)
                score -= c[col] * (len(tt) - lst[col])
            cand.append([score, tt+[j], lst])
    cand.sort(key=lambda x:-x[0])
    if len(cand[0][1])==d: break
    cand = cand[:5]

for i in cand[0][1]:
    print(i+1)

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 

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(0)
    yaki=0.005
    for _ in range(1400000):
        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
        
            
        
            
            
            



    printl(anss)
    printe(csc)
    
    

if __name__ == "__main__":
    main()

Solution (Python):
import sys
import random
import numpy as np
random.seed(42)
TYPE_NUM = 26
WEIGHT1 = 16
WEIGHT2 = 4
WEIGHT3 = 1

def resolve():

    inp = sys.stdin.readlines()
    D = int(inp[0])
    c = np.array(list(map(int, inp[1].split(' '))))
    s = []
    last = np.zeros(TYPE_NUM, dtype=int)
    types = []

    for i in range(2, len(inp)):
        s.append(list(map(int, inp[i].split(' '))))
    s = np.array(s, dtype=int)

    for d in range(D):
        temp_delta_satis = np.zeros([TYPE_NUM, TYPE_NUM, TYPE_NUM], dtype=int)
        for idx in range(TYPE_NUM):
            val = s[d, idx]
            org = last[idx]
            last[idx] = d+1
            temp_delta_satis[:, :, idx] = (np.sum(-c*(d+1-last)) + val)*WEIGHT1
            if D > d+1:
                for idx2 in range(TYPE_NUM):
                    rand = random.random()
                    if rand > 0.7:
                        val2 = s[d+1, idx2]
                        org2 = last[idx2]
                        last[idx2] = d+2
                        temp_delta_satis[idx2, idx] += (np.sum(-c*(d+2-last)) + val2)*WEIGHT2
                        last[idx2] = org2
                    else:
                        temp_delta_satis[idx2, idx] = -10 ** 16
                        continue
                if D > d+2:
                    for idx3 in range(TYPE_NUM):
                        rand = random.random()
                        if rand > 0.7:
                            val3 = s[d+2, idx3]
                            org3 = last[idx3]
                            last[idx3] = d+3
                            temp_delta_satis[idx3, idx2, idx] += (np.sum(-c*(d+3-last)) + val3)*WEIGHT3
                            last[idx3] = org3
                        else:
                            temp_delta_satis[idx3, idx2, idx] = -10 ** 16
            last[idx] = org
        opt_idx = np.unravel_index(np.argmax(temp_delta_satis), temp_delta_satis.shape)[2]
        last[opt_idx] = d+1
        types.append(opt_idx+1)
    print(*types, sep='\n')

resolve()

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





typ=0
ans=0

types=[(i%26)+1 for i in range(D)]

sc = [0] * D
last=[0]*26
for i in range(D):
    typ = types[i] - 1
    score = s[i][typ]
    dwn = 0
    last[typ] = (i + 1)
    for j in range(26):
        dwn = dwn + c[j] * ((i + 1) - last[j])
    ans = score - dwn
    
    sc[i] = ans
all = sum(sc)
for _ in range(800):
    types2 = []
    mi=float("inf")
    ind=0
    for i in range(D):
        if mi>sc[i]:
            mi=sc[i]
            ind=i
    l=list(range(1,27))
    
    
    lab1=l.pop(types[ind]-1)
    lab2=random.choice(l)
    spans=ind//26
    types2=types
    for i in range(spans*26,min((spans+1)*26,D)):
        if types[i]==lab2:
            types[i]=lab1
            types[ind]=lab2
            break
    sc2=[0]*D
    last=[0]*26
    for i in range(D):
        typ = types[i] - 1
        score = s[i][typ]
        dwn = 0
        last[typ] = (i + 1)
        for j in range(26):
            dwn = dwn + c[j] * ((i + 1) - last[j])
        ans = score - dwn
                
        sc2[i] = ans
    all2 = sum(sc2)
    if all2<all:
        types=types2
    else:
        sc=sc2
        all=all2
        sc2=[]
    
for i in range(D):
    print(types[i])

Solution (Python):
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+1)
print(*ans,sep='\n')

Solution (Python):
import random
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))
t = [1]*D
def my_index(l,x,d,default=False):
    if x in l:
        return l.index(x)
    else:
        return d
def last(d,i):
    a= t[:d]
    a.reverse()
    day = -1*(my_index(a,i,d))+d
    return day
score = 0
for i in range(40):
    score_v=0
    t_old = t
    d_change = random.randint(0,D-1)
    q_change = random.randint(1,26)
    t[d_change]=q_change
    for d in range(1,D+1):
        score_v += s[d-1][t[d-1]-1]
        for i in range(1,27):
            score_v -= c[i-1]*(d-last(d,i))
    if score_v>score:
        score=score_v
    else:
        t = t_old
for i in range(D):
    print(t[i])

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

t = [0] * 26

x = 0 
for i in range(D): 
  l = []
  for j in range(26): 
    u = copy.deepcopy(t)
    u[j] = i+1
    x += s[i][j]
    for k in range(26): 
      x -= c[k] * ((i+1) - u[k])
    l.append(x)
  v = l.index(max(l))
  t[v] = i+1
  print(v+1)

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 l in range(330, 366):
  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):
from random import randrange

def score(c,s,t):
    ans = 0
    scorelast = [0] * 26
    for i in range(d,365):
        ans += s[i][t[i]]
        scorelast[t[i]] = i + 1
        for j in range(26):
            ans -= c[j] * (i + 1 - scorelast[j])
    return ans

def diffscore(old,q,c,s,t):
    cq = c[q]
    scorelast = [0] * 2
    diff = 0
    for i in range(365):
        if t[i] == q:
            diff += s[i][q]
            scorelast[0] = i + 1
        elif t[i] == old:
            diff += s[i][old]
            scorelast[1] = i + 1
        diff -= cq * (i + 1 - scorelast[0])
        if cq != old:
            diff -= c[old] * (i + 1 - scorelast[1])

    return diff
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D): s.append(list(map(int,input().split())))
d = 0
t = []
last = [-1] * 26
for i in range(D):
    maximum = 0
    maxs = 0
    for j in range(26):
        if maximum < s[i][j] + c[j] * (i - last[j]):
            maxs = j
            maximum = s[i][j] + c[j] * (i - last[j])
    last[maxs] = i
    t.append(maxs)

for i in range(20000):
    d = randrange(D)
    q = randrange(26)
    old = t[d]
    before = diffscore(old,q,c,s,t)
    t[d] = q
    if before > diffscore(old,q,c,s,t): t[d] = old
for i in t: print(i + 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):
    return (d-n)*cc + 50*ss

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

types = []
last = [-1] * 26
S = 0
for d in range(D):
    
    M = -float('inf')
    for tt in range(26):
        _last = last[:]
        tmp = s[d][tt]

        _last[tt] = d
        for i in range(26):
            tmp -= c[i] * (d - _last[i])

        if tmp > M:
            M = tmp
            M_tt = tt

    S += s[d][M_tt]

    last[M_tt] = d
    for i in range(26):
        S -= c[i] * (d - last[i])
    types.append(M_tt)


last = [-1] * 26
S = 0
ans = []
for d in reversed(range(D)):
    seq = []
    for tt in range(26):
        _last = last[:]
        tmp = s[d][tt]

        _last[tt] = d
        for i in range(26):
            tmp -= c[i] * (d - _last[i])

        seq.append([tmp, tt])

    seq.sort(reverse=True)

    tmpmax = -float('inf')
    for i in range(15):
        tt = seq[i][1]
        _last = last[:]
        _types = types[:]
        _types[d] = tt
        _S = S

        for dd in range(d, D):
            _S += s[dd][_types[dd]]
            _last[_types[dd]] = dd
            for i in range(26):
                _S -= c[i] * (dd - _last[i])

        if _S > tmpmax:
            cand = tt
            tmpmax  = _S

    S += s[d][cand]
    last[cand] = d
    for i in range(26):
        S -= c[i] * (d - last[i])

    ans.append(cand + 1)
    
for _ans in reversed(ans):
    print(_ans)

Solution (Python):


import sys
import math
import random

def calc_sat_change(d, q): 
  dif_sat = s[d-1][q-1] - s[d-1][ans[d-1]-1]

  lastday = 0
  nextday = D+1
  for i in reversed(range(d-1)):
    if ans[i] == q:
      lastday = i+1
  for i in range(d, D):
    if ans[i] == q:
      nextday = i+1
  dif_sat += c[q-1]*(d+1-lastday)*(nextday-d+1)

  lastday = 0
  nextday = D+1
  for i in reversed(range(d-1)):
    if ans[i] == ans[d-1]:
      lastday = i+1
  for i in range(d, D):
    if ans[i] == ans[d-1]:
      nextday = i+1
  dif_sat -= c[ans[d-1]-1]*(d+1-lastday)*(nextday-d+1)

  return dif_sat


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

lastdays = [0] * 26
sat = 0
ans = [0] * D

for i in range(D):
  maxtmpsat = -1000000
  for j in range(26):
    tmpsat = s[i][j] + c[j] * (i+1 - lastdays[j]) 
    if tmpsat > maxtmpsat:
      maxtmpsat = tmpsat
      ans[i] = j+1
  lastdays[ans[i]-1] = i+1

for _ in range(10000):
  d = random.randint(1, 365)
  q = random.randint(1, 26)
  if calc_sat_change(d, q) > 0:
    ans[d-1] = q

for i in range(D):
  print(ans[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 = 800000
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):
from collections import Counter
import sys
from random import randint
from time import time
start = time()
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline


def get_sat():
    sat = 0
    when = [-1] * 26
    for i in range(d):
        sat += s[i][t[i]]
        when[t[i]] = i
        for j in range(26):
            sat -= c[j] * (i - when[j])
    return sat


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)]
ans = get_sat()
while time() - start < 1.8:
    p, q = randint(0, d - 1), randint(0, 25)
    x = t[p]
    t[p] = q
    y=get_sat()
    if ans >= y:
        t[p] = x
    else:
        ans=y
for i in t:
    print(i + 1)

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

tL = []
for i in range(D):
    tL.append(S[i].index(max(S[i])) + 1)

for t in tL:
    print(t)

Solution (Python):
d=int(input())
for _ in range(d): print(13)

Solution (Python):
import numpy as np
D = int(input())
C = np.array(list(map(int, input().split())))
S = np.zeros((D,26),int)
for i in range(0,D):
    S[i] = list(map(int, input().split()))

np.random.seed(seed=32)
Plan = np.random.randint(1,26,(D))

[print(i+1) for i in Plan]

Solution (Python):
from time import time
stime = time()
 
from copy import copy
from random import randint
 
def get_fav_contest(s, t):
    s = copy(s)
    t = copy(t)
    dc = 0
    d = len(t)
    for i in range(1, d):
        dc += s[i][t[i]]
        ca[t[i]] = i
        dc -= sum([c[i2] * (i - ca[i2]) for i2 in range(1, 27)])
    return dc
 
d = int(input())
c = [0] + list(map(int, input().split(' ')))
 
s = [[]] + [[0] + list(map(int, input().split(' '))) for _ in range(d)]
 
t = 0 
tl = [0]
 
ca = [0] * (1 + 26) 
cat = [] 
cat2 = []
 
for i in range(1, d + 1):
    cat = [0]
    for i2 in range(1, 27):
        cat2 = copy(ca)
        cat2[i2] = i
        cat.append(s[i][i2] + sum(c[i3] * (i - ca[i3]) for i3 in range(1, 27)))
    t = cat.index(max(cat))
    ca[t] = i
    tl.append(t)
 
default_t = get_fav_contest(s, tl)
 
ch = 0 
temp1 = 0 
tempt = 0
while time() - stime < 1.95:
    ch = randint(1, 365)
    temp1 = tl[ch]
    tl[ch] = randint(1, 26)
    tempt = get_fav_contest(s, tl)
    if tempt < default_t:
        tl[ch] = temp1
    else:
        default_t = tempt
print('\n'.join(map(str, tl[1:])))

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


ans = [s[k].index(max(s[k]))+1 for k in range(D)]

p = 0

ch = c.index(min(c))

scheduled = [0 for _ in range(26)]

for k in range(D):
    t = ans[k]
    scheduled[t-1] = -1
    for j in range(26):
        scheduled[j] +=1
        p -= c[j]*scheduled[j]
    p += s[k][t-1]

np = p

for n in range(D):
    op = 0+ np
    oa = 0 + ans[n]
    ans[n] = ch
    for k in range(D):
        t = ans[k]
        scheduled[t-1] = -1
        for j in range(26):
            scheduled[j] +=1
            np -= c[j]*scheduled[j]
        np += s[k][t-1]
    if np > op:
        continue
    else:
        ans[n] = oa



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

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)

D = int(readline())
C = list(map(int,readline().split()))
S = [list(map(int,readline().split())) for i in range(D)]
t = [0]*D
for j,s in enumerate(S):
    ansidx = 0
    anssum = 0
    for i,si in enumerate(s,start=1):
        if anssum < si:
            ansidx = i
            anssum = si
    t[j] = ansidx
def score():
    ans = 0
    minus = 0
    last = [0]*26
    for i in range(D):
        ans += S[i][t[i]-1]
        minus = 0
        last[t[i]-1] = i+1
        for j in range(26):
            minus += C[j]*(i-last[j]+1)
        ans -= minus
    return ans
a = score()
import random
for k in range(5000):
    d,q = random.randint(1,D),random.randint(1,26)
    told = t[::]
    t[d-1] = q
    b = score()
    if a > b:
        t = told
    else:
        a = b
for ti in t:
    print(ti)

Solution (Python):

import random

def main():
    D = int(input())
    c_list = list(map(int, input().split()))
    s_list = [list(map(int, input().split())) for _ in range(D)]
    
    basic_bad = sum(c_list)

    
    res = 0
    bad = 0
    last_open = [0] * 26
    t_list = [0] * D

    max_res = -1
    max_t_list = [0] * D

    
    for m in range(10**4):
        t_list = [random.randint(0,25) for i in range(D)]
        res = 0
        bad = 0
        last_open = [0] * 26
        for i in range(D):
            t = t_list[i]
            
            res += s_list[i][t]
            bad += basic_bad - (i+1 - last_open[t]) * c_list[t]
            last_open[t] = i+1

            res -= bad
            
        if max_res == -1 or max_res < res:
            max_res = res
            max_t_list = t_list.copy()

    for t in max_t_list:
        print(t+1)

if __name__ == "__main__":
    main()

Solution (Python):
import random
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    temp_s = list(map(int, input().split()))
    s.append(temp_s)
for i in range(1, D + 1):
    print(random.randint(1,26))

Solution (Python):
import numpy as np
from time import time
start = time()
def scoring(c,s,t):
    score = 0
    from_last = np.zeros(26)
    for i in range(s.shape[0]):
        from_last = from_last+1
        score += s[i,t[i]-1]
        from_last[t[i]-1] = 0
        score = score - (c*from_last).sum()
    return score



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


t = []
for i in range(D):
    chosen = s[i,:].flatten().argmax()+ 1
    t.append(chosen)

freq = np.zeros(26)
for i in t:
    freq[i-1] += 1
w = c*(365-freq)
num = np.arange(1,27)
score = scoring(c,s,t)
while time()-start < 1.85:
    i = np.random.randint(D)
    old = t[i]
    t[i] = np.random.choice(num, p = w/w.sum())
    new_score = scoring(c,s,t)
    if new_score > score:
        score = new_score
        w[t[i]-1] -= c[t[i]-1]
        w[old-1] += c[old-1]
    else:
        t[i] = old


for i in t:
	print(i)

Solution (Python):
d = int(input())
c = [0] + list(map(int, input().split()))
s = [0] + list([0] + list(map(int, input().split())) for _ in range(d))

kaisai = [0]*27

for i in range(1, d+1):
    decrese = 0
    zantei = [0]*27
    for k in range(1, 26):
        zantei[k] = s[i][k] + c[k]*(i - kaisai[k])
    increase = max(zantei)
    index = zantei.index(increase)

    kaisai[index] = i
    print(index)

Solution (Python):

d=int(input())
c= list(map(int, input().split()))
D= [list(map(int, input().split())) for i in range(d)]
cc=[0]*26
for i in range(26):
    cc[i]=[c[i],i+1]
cc.sort(reverse=True)

ans=[0]*d

PL=[0]*26

for i in range(d):
    cnt=0
    cntt=-10**9
    x=1
    for k in range(len(c)):
        v=PL[:]
        cnt = D[i][cc[k][1]-1]
        v[cc[k][1]-1] = i+1
        for j in range(len(c)):
            cnt-=(i+1-v[j])*c[j]
        if cnt>cntt+30:
            x=cc[k][1]
            cntt=max(cnt,cntt)
    ans[i]=x
    PL[x-1]=i


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