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

D = int(input())

C = [int(y) for y in input().split()]

S = []

ans = []

def scoring(inp,poi):
    
    score = 0
    day = 1
    last = [0] * 26
    
    for I in inp:
        score += poi[day-1][I-1]
        last[I-1] = day
        for ind,J in enumerate(last):
            score -= C[ind] * (day - ind - 1)
        day += 1
        
    return score

for i in range(D):
    s = [int(y) for y in input().split()]
    S.append(s)

for i in S:
    k = 0
    num = 0
    for f,t in enumerate(i):
        k = max(k,t)
        if k == t:
            num = f + 1
    ans.append(num)

counter = 500

base = scoring(ans,S)
nbase = 0
d = 0
ansc = ans.copy()

for i in range(counter):
    p = random.randint(0,25)
    q = random.randint(0,D-1)
    ansc[q] = p
    nbase = scoring(ansc,S)
    if nbase > base:
        ans = ansc.copy()
    else:
        ansc = ans.copy()

for i in ans:
    print("{}".format(int(i)))

base = scoring(ans,S)

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

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

for s in S:
    ansidx = 0
    anssum = 0
    for i,si in enumerate(s,start=1):
        if anssum < si:
            ansidx = i
            anssum = si
    print(ansidx)

Solution (Python):
def main():
    d=int(input())
    c=list(map(int,input().split()))
    s=[list(map(int,input().split())) for _ in range(d)]
    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]*(i-last[t])>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)
    for i in ans:
        print(i)
    
    

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = []
    for _ in range(D):
        si = list(map(int, input().split()))
        s.append(si)
    for i in range(D):
        best_idx = -1
        best_val = 0
        for j in range(26):
            val = s[i][j] + (20000 - c[j] * 200)
            if val > best_val:
                best_idx = j
                best_val = val
        print(best_idx+1)
if __name__ == "__main__":
    main()

Solution (Python):
import time
import random
import math
def sigmoid(x):
  return 1/(1+math.exp(-x))
def score(a,c,s,d):
  l=[-1 for i in range(26)]
  r=0
  for i in range(d):
    l[a[i]]=i
    r+=s[i][a[i]]
    for j in range(26):
      r-=c[j]*(i-l[j])
  return r
  
st=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

ans=[]
l=[-1 for i in range(26)]
ld=[]
for i in range(d):
  ms=-10**9
  mt=None
  for j in range(26):
    js=c[j]*(i-l[j])+s[i][j]
    if ms<js:
      ms=js
      mt=j
  l[mt]=i
  ans.append(mt)
  ld.append([l[mt],d])
  if l[mt]>=0:
    ld[l[mt]][1]=i

os=score(ans,c,s,d)
nt=st
rate=1000
while nt-st<1.50:
  nt=time.time()
  na=[ans[i] for i in range(d)]
  na[random.randint(1,d-1)]=random.randint(0,25)
  ns=score(na,c,s,d)
  if sigmoid((ns-os)/rate/((2-nt+st)**2)-0.5)>random.random():
    os=ns
    ans=na
  
  


for i in ans:
  print(i+1)

Solution (Python):
t = [16,8,17,7,8,21,13,5,1,25,12,14,12,6,4,24,6,9,18,3,22,19,3,24,7,7,2,23,11,6,14,17,4,21,24,23,6,14,6,15,26,22,19,18,20,11,10,16,18,5,16,7,7,24,18,16,14,18,22,25,19,20,13,23,3,25,19,25,25,3,17,16,5,22,9,11,5,6,6,13,26,14,9,13,11,11,1,19,22,23,19,18,5,14,26,11,25,3,24,6,24,20,12,19,7,25,16,19,6,1,4,16,15,15,5,6,24,26,2,3,15,5,10,21,22,16,22,1,2,15,25,7,16,15,5,25,12,6,16,2,14,16,12,10,22,18,22,9,16,25,1,13,25,5,8,23,17,14,17,18,17,16,13,24,21,10,10,12,15,15,22,1,15,23,21,24,23,8,13,19,14,3,2,24,3,15,11,19,6,26,11,22,1,20,24,4,11,14,12,25,10,25,8,6,9,24,10,19,23,14,11,11,21,6,14,21,24,24,26,18,26,2,13,14,13,7,17,15,15,11,5,20,12,25,8,14,11,15,1,21,7,26,17,18,3,4,4,9,21,20,5,9,15,10,23,1,25,25,26,16,22,19,3,13,16,19,1,10,12,6,22,7,21,2,6,1,1,15,22,12,26,25,12,14,20,18,11,4,3,16,23,19,18,20,5,19,10,23,8,4,9,26,3,15,2,26,3,14,6,23,12,17,9,10,20,22,4,23,22,24,8,18,3,2,12,4,22,7,25,12,23,7,2,21,19,2,13,2,15,18,24,20,12,8,3,19,13,16,24,15,8,7,13,7,14,11,5,21,6,4,24,15,20,15,7]
for i in range(365):
  print(t[i])

Solution (Python):
import numpy as np

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



  s=np.array(input().split(), dtype=np.int64)
  sc_mul=s*c
  max_space=np.argmax(sc_mul)
  print(max_space+1)

Solution (Python):
def main():
    D = int(input())
    fuman = list(map(int, input().split()))
    manzoku = [[0]*26 for _ in range(D)]
    for i in range(D): manzoku[i] = list(map(int, input().split()))
    
    
    
    
    timepass = [0]*26
    
    x,t = 0,0
    for j in range(26):
        tmp = manzoku[i][j]
        if tmp>x:
            tprev = t
            x = tmp
            t = j
    print(tprev+1)
    for i in range(1,D):
        
        x1 = 0
        t1 = 0
        for j in range(26):
            tmp = manzoku[i][j]
            for k in range(26):
                if not j==k: tmp -= fuman[k]*timepass[k]
            if tmp>x1:
                x1 = tmp
                t1 = j

        
        for j in range(26):
            if not j==t1: timepass[j] += 1
            else: timepass[j] = 0
        print(t1+1)



main()

Solution (Python):
D = int(input())
c = [int(_) for _ in input().split()]
s = [[int(_) for _ in input().split()] for _ in range(D)]

sat = 0
last = [0] * 26
for d in range(D):
    v = -1000000
    for x in range(26):
        if v < (d + 1 - last[x]) * c[x]:
            j = x
            v = (d + 1 - last[x]) * c[x]
    last[j] = d + 1
    print(j+1)

    for i in range(26):
        sat -= (d + 1 - last[i]) * c[i]
    sat += s[d][j]

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

with open('output.txt', 'w') as f:
    dice = list(range(26))
    w = c
    samples = random.choices(dice, k=d, weights=w)
    for one in samples:
        print(one+1)

Solution (Python):
D = int(input())
C = list(map(int, input().split()))
s = list()
for i in range(D):
  s1 = list(map(int, input().split()))
  s.append(s1)
t = list()
for i in range(D):
  t.append(i%26)

def point(t, C, s):
  done = [0] * 26
  ans = 0
  for d in range(1, D+1):
    td = t[d-1]
    done[td] = d
    ans += s[d-1][td]
    for i in range(26):
      ans -= C[i]*(d-done[i])
  return ans

ans = 0
bettert = 0
for i in range(26):
  t[0] = i
  if(point(t, C, s) > ans):
    ans = point(t, C, s)
    bettert = i
    
print(bettert+1)
for i in range(1,D):
  print(t[i]+1)

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

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import random

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

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




def init():
    cont = 0
    last = [0]*26
    t = []
    for i in range(D):
        max_c = 0
        max_i = -1
        for j in range(26):
            if max_c < s[i][j] + c[j]*(i+1-last[j]):
                max_i = j
                max_c = s[i][j] + c[j]*(i+1-last[j])
        t.append(max_i+1)        
        cont += s[i][t[i]-1]
        last[t[i]-1] = i+1
    return t,cont

def content(t):
    cont = 0
    last = [0]*26
    for i in range(D):
        cont += s[i][t[i]-1]
        last[t[i]-1] = i+1
        for j in range(26):
            cont -= c[j]*(i+1-last[j])
    return cont

def main():
    t,prev = init()
    for i in range(6000):
        d,q = random.randint(0,D-1), random.randint(1,26)
        prev_t = t[d]
        t[d] = q
        now = content(t)
        if prev>content(t):
            t[d] = prev_t
        else:
            prev=now
    for a in t:
        print(a)


if __name__ == '__main__':
    main()

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

Solution (Python):
for i in range(int(input())):
    print(2)

Solution (Python):
import random
import time

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


def main():
    best_score = 0
    best_ans = [0] * 26
    base = list(range(26))
    ans = [0] * 26
    while time.time() - start < 1.8:
        random.shuffle(base)
        score = calc_score(base)
        if score > best_score:
            best_score = score
            ans = base[:]

    for d in range(D):
        print(ans[d % 26] + 1)


def calc_score(T):
    score = 0
    last_day = [-1] * 26
    for d in range(D):
        t = T[d % 26]
        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):
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
ans = [1]*D
for i in range(D):
    tmp = 0
    for k in range(26):
        manzoku_down = 0
        ans[i] = k+1
        for j in range(26):
            last = 0
            for l in range(0,i+1):
                if ans[l] == j+1:
                    last = j+1
            manzoku_down += C[j]*((i+1)-last)
        if S[i][k]-manzoku_down >= tmp:
            tmp = S[i][k]-manzoku_down
            ans[i] = k+1
for i in ans:
    print(i)

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

for i in range(d):
  max_value = max(s[i])
  max_index = s[i].index(max_value)
  print(max_index+1)

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

import random

for i in range(d):
    print(random.randrange(1,27))

Solution (Python):
from random import *
D=int(input())
for i in range(D):
  print(randrange(1,27))

Solution (Python):
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
lastday=[0 for j in range(26)]
points=[0 for i in range(D)]
t=[0 for i in range(D)]


lastday=[lastday[i]+1 for i in range(26)]
firstday=s[0].index(max(s[0]))
lastday[firstday]=0
t[0]=firstday+1

for days in range(1,D):
    temp=[s[days][i]-c[i]*lastday[i] for i in range(26)]
    today=temp.index(min(temp))
    lastday=[lastday[i]+1 for i in range(26)]
    lastday[today]=0
    t[days]=today+1

for ts in t:
    print(ts)

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

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	D = int(input())  
	vC = [0,]+linput()     
	
	
	
	
	mS = [[0,]+linput() for _ in [0,]*D]
	
	
	

	vL = [-1,]*(26+1)   
	
	
	res = 0      
	vR = []
	vT = []
	rapp = vR.append
	tapp = vT.append
	
	for d in range(D): 
		
		bestT = 1
		candiR = []
		vS = mS[d]
		for t in range(1,27):  
			candir = 0
			Sdt = vS[t]
			candir += Sdt
			
			vltmp = vL[t]
			vL[t] = d
			C = sum(c*(d-l) for c,l in zip(vC,vL))
			candir -= C
			candiR.append(candir)
			
			vL[t] = vltmp
		
		bestR = max(candiR)
		bestT = candiR.index(bestR) + 1
		res += bestR
		rapp(res)
		tapp(bestT)
	
	
	
	
	print(*vT, sep='\n')
	print(*vR, file=sys.stderr)
	print(sum(vR), file=sys.stderr)

if __name__ == "__main__":
	main()

Solution (Python):
import sys
import numpy as np
TYPE_NUM = 26

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):
        opt_delta_satis = -10 ** 32
        opt_idx = 0
        for idx in range(TYPE_NUM):
            val = s[d, idx]
            org = last[idx]
            last[idx] = d+1
            temp_delta_satis = np.sum(-c*(d+1-last)) + val
            if opt_delta_satis < temp_delta_satis:
                opt_delta_satis = temp_delta_satis
                opt_idx = idx
            last[idx] = org
        types.append(opt_idx+1)
    print(*types, sep='\n')

resolve()

Solution (Python):



import random as ra
import copy
import time

start_time = time.time()

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



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


t = []
last = [0]*26
for i in range(D):
    opt1 = s[i].index(max(s[i]))
    opt2 = last.index(min(last))
    if ra.random()<0.5:
        t.append(opt1)
        last[opt1] = i+1
    else:
        t.append(opt2)
        last[opt2] = i+1


t = [ra.randint(1,26) for i in range(D)]
max_score = 0
optimal_t = copy.deepcopy(t)

while (time.time()-start_time)<1.95:

    d = ra.randint(1,D)
    q = ra.randint(1,26)
    td = t[d-1]
    t[d-1] = q
    now = cal_point(t)
    if now > max_score:
        optimal_t = copy.deepcopy(t)
        max_score = now
    else:
        t[d-1] = td

print(*optimal_t,sep='\n')

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

D = int(input())
C = np.array(list(map(int,input().split())),dtype=np.int)
S = np.array([list(map(int,input().split())) for i in range(D)],dtype=np.int)

sumC = sum(C)
def score(strategy):
    sat = 0
    last = np.zeros(26).astype(np.int)
    for i,ind in enumerate(strategy):
        last += 1
        last[ind] = 0
        sat -= np.sum(C * last)
        sat += S[i][ind]
    return sat


first = [i % 26 for i in range(D)]

ans = first
now_score = score(ans)

for i in range(1):
    samples = np.random.randint(0,26,size=D).tolist()
    for d in range(D):
        temp = ans[:]
        temp[d] = samples[d]
        if score(temp) > now_score:
            ans = temp

for a in ans:
    print(a+1)

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


D = z()
C = zz()
S = defaultdict(list)
for i in range(D):
    S[i + 1] = zz()

never_held = []

arr = list(range(26))
resent_contests = []
C, arr = zip(*sorted(zip(C, arr), reverse=False))
i = 0
for _ in range(D):
    if (len(resent_contests) == 26):
        resent_contests = []
    while(arr[i % 26] + 1 in resent_contests):
        i += 1
    resent_contests.append(arr[i % 26]+1)
    print(arr[i % 26]+1)
    i += 1

Solution (Python):
import random


d = int(input())
c = list(map(int,input().split()))
s = []

class field:
    def __init__(self):
        self.ans = [-1 for i in range(365)]
        self.last = [-1 for i in range(26)]


    def score_day(self,day,type):
        inc = s[day][type]
        dec = 0
        for i in range(26):
            dec += c[i]*(day-self.last[i])

        return  inc-dec


for i in range(d):
    arr = list(map(int,input().split()))
    s.append(arr)

best_score = 0
alloc = []

F = field()
ans = 0
good = []
childs = 5
for day in range(d):
    if day == 0:
        tp_scores = []
        for j in range(25):
            prob = j
            befl = F.last[prob]
            F.last[prob] = day
            sc = F.score_day(day, prob)
            tp_scores.append([-sc, j,F.last.copy(),str(j)])

            F.last[prob] = befl

        tp_scores.sort()
        good = tp_scores[:childs]
    else:
        tp_scores = []
        for i in range(childs):
            befs = good[i][0]
            befp = good[i][1]
            befl = good[i][2]
            befa = good[i][3]
            F.last = befl
            for j in range(25):
                prob = j
                bt = F.last[prob]
                F.last[prob] = day
                sc = F.score_day(day,prob)
                tp_scores.append([befs-sc,j,F.last.copy(),befa+","+str(j)])

                F.last[prob] = bt

        tp_scores.sort()
        good = tp_scores[:childs]
















root = map(int,good[0][-1].split(","))

for r in root:
    print(r+1)

Solution (Python):

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

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

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

print(Ret[0], end='')
for i in range(1, D):
    print('\n' + str(Ret[i]), end='')

Solution (Python):
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
d=read()
c=list(reads())
s=[[]for i in range(d)]
for i in range(d):
    s[i]=list(reads())
contestcount=26
last=[0 for i in range(contestcount)]
maxscore=0
backup=()
score=0
for i in range(d):
  dele=0
  for j in range(contestcount):
        dele-=c[j]*(i+1-last[j])
  for j in range(contestcount):
    hoge=maxscore
    hoge+=s[i][j]
    hoge-=dele
    hoge+=c[j]*(i+1-last[j])
    if hoge>=score:
      backup=(j,last[j])
      score=hoge  
    
  maxscore=score
  last[backup[0]]=backup[1]
  print(backup[0]+1)

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

def based_b():
    last = [0 for _ in range(26)]
    for i in range(D):
        max_score = 0
        t = 0
        for contest in range(26):
            score = S[i][contest]
            d = i + 1
            last[contest] = d
            for x in range(26):
                score -= C[x] * (d - last[x])
            if max_score < score:
                t = contest
        print(t+1)

based_b()

Solution (Python):
D = int(input())
c_list = [int(i) for i in input().split()]
s_list = []
t_list = []
for _ in range(D):
    s = [int(i) for i in input().split()]
    s_list.append(s)
happy = 0
recent = [0 for _ in range(26)]
for _ in range(D):
    print(1)

Solution (Python):
import copy
import time

t1 = time.time()

def calc(T):
    res = 0
    L = [0]*26
    for i in range(D):
        res += S[i][T[i]-1]
        L[T[i]-1] = i+1
        for j in range(26):
            res -= C[j]*(i+1-L[j])
    return res
    
D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]

T = [0]*D
for i in range(D):
    temp = -1
    for j in range(26):
        if temp < S[i][j]:
            temp = S[i][j]
            idx = j+1
    T[i] = idx

p = calc(T)

i = 0
next = 1
while time.time()-t1 < 1.9:
    for j in range(26):
        temp = copy.deepcopy(T)
        temp[i] = j+1
        newp = calc(temp)
        if p < newp:
            T[i] = j+1
            p = newp
    i += next
    if i == -1:
        i = 1
        next = 1
    elif i == D:
        i = D-2
        next = -1

for t in T:
    print(t)

Solution (Python):
import numpy as np

d = int(input())

c = list(map(int, input().split()))

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

pp = np.zeros(26, dtype=np.int)
  
for i in range(d):
  pp += c
  pp_max = np.argmax(pp)+1
  pp_max_val = np.max(pp)
  
  sd_max = np.argmax(sd[i,:])+1
  sd_max_val = np.max(sd[i,:])
  
  if np.sum(pp) >= sd_max_val:
    t = pp_max
    pp[pp_max-1] = 0
  else:
    t = sd_max
  print(t)

Solution (Python):


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


for i in range(365):
    ans=D[i].index(max(D[i]))
    print(ans+1)

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

d=[-1]*(26)
v=[0]*(D+1)


for i in range(D):
    t=s[i].index(max(s[i]))
    v[i]=s[i][t]
    d[t]=0
    if i>0: 
        sb=0      
        for j in range(26):
            if d[j]!=-1:
                d[j]+=1
                sb+=d[j]*c[j]            
        v[i]+=v[i-1]-sb
    print(t+1)

Solution (Python):
d = int(input())
c = list(map(int,input().split()))
like=0
but=0
s=[]
last=[]
show=''
for i in range(26):
    last.append(0)
for i in range(d):
    keys=list(map(int,input().split()))
    s.append(keys)
for  i in range(365):
    print(26)

Solution (Python):
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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

    def cp(d, j):
        c = 0
        for i in range(26):
            if i == j:
                last[i] += 1
            c += C[i] * (d - last[i])
            if i == j:
                last[i] -= 1
        return c

    for i in range(D):
        score_list = [
            S[i][j] - cp(i+1, j) for j in range(26)
        ]
        max_score = max(score_list)
        max_index = score_list.index(max_score)
        last[max_index] += 1
        print(max_index + 1)


main()

Solution (Python):
d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(d)]
ld = [0]*26
score = 0
def dec(day):
    ans = 0
    for i in range(26):
        ans += c[i]*(day-ld2[i])
    return ans

rss = [[0,0] for i in range(d+1)]

for i in range(1,d+1):
    ma = rss[i-1][0]
    for t in range(26):
        ld2=ld.copy()
        ld2[t]=i
        score=s[i-1][t]-dec(i)
        ma = max(score,ma)
        if score==ma:
            t2=t+1
    rss[i][1]=t2
    print(t2)

Solution (Python):
import itertools

d = int(input())
c = list(map(int, input().split()))
s_di = [list(map(int, input().split())) for i in range(d)]
last = [0 for i in range(26)]


total_manzoku = 0
day = 0
chain = 3

while day < d:
    tmp_max = -10 ** 10
    if day + chain > d:
        chain = d - day
    for i in itertools.product(range(26), repeat=chain):
        tmp_day = day
        tmp = 0
        tmp_last = last.copy()
        for j in i:
            tmp_day += 1
            fuman = sum([(tmp_day - tmp_last[k]) * c[k] for k in range(26)])
            tmp += -fuman + (tmp_day - tmp_last[j]) * c[j] + s_di[tmp_day - 1][j]
            tmp_last[j]=tmp_day
        if tmp > tmp_max:
            tmp_max = tmp
            tmp_choice = i
    total_manzoku += max(tmp_max, 0)
    for i in range(chain):
        print(tmp_choice[i] + 1)
        last[tmp_choice[i]] = day + i + 1
    day += chain

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

def calc(ans):
    ret = 0
    L = [0] * D
    for d, t in enumerate(ans):
        ret += S[d][t]
        for c, l in zip(C, L):
            ret -= c * (d - l)
    return ret

mx = -10**18
ans = 0
for i in range(26):
    res = calc([i] * D)
    if mx < res:
        mx = res
        ans = i

print(*([ans + 1] * D), sep='\n')

Solution (Python):
import sys
input=sys.stdin.readline
from random import seed, randint

def calc(d,C,S,T):
    Last=[0]*26
    score=0
    for day,t in enumerate(T):
        t-=1
        Last[t]=day+1
        score+=S[day][t]
        for i,c in enumerate(C):
            score-=c*(day+1-Last[i])
    return score

def main():
    d=int(input())
    C=tuple(map(int,input().split()))
    S=[tuple(map(int,input().split())) for _ in range(d)]
    Ans=[0]*d
    Last=[0]*26
    
    
    for day in range(d):
        ans=0
        score=-float('inf')
        for t in range(26):
            TmpList=Last[:]
            tmp_score=0
            TmpList[t]=day+1
            for i,c in enumerate(C):
                tmp_score-=c*(day+1-TmpList[i])
            if tmp_score>score:
                score=tmp_score
                ans=t+1
        Ans[day]=ans
        Last[ans-1]=day
    
    score=calc(d,C,S,Ans)
    
    
    
    T=Ans[:]
    m=8000
    for i in range(m):
        seed(i)
        d_idx=randint(0,d-1)
        q=randint(1,26)
        
        T[d_idx]=q
        tmp=calc(d,C,S,T)
        if tmp>score:
            score=tmp
            Ans=T[:]
    
    
    print(*Ans,sep='\n')
    
if __name__=='__main__':
    main()

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

manzoku = 0
yasumi= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

for day in range(D):
  yasumi = list(map(lambda x: x + 1, yasumi))
  zouka = 0
  for t in range(26):
    if zouka < S[day][t] + C[t] * yasumi[t]:
      zouka = S[day][t] + C[t] * yasumi[t]
      best = t
  manzoku += zouka
  yasumi[best] = 0
  print(best + 1)

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

def score(T):
    last=[-1]*26
    v=0
    for d in range(D):
        v+=s[d][T[d]-1]
        last[T[d]-1]=d
        for i in range(26):
            v-=c[i]*(d-last[i])
    return v

import random
best=0

for x in range(4000):
    if x==0:
        tmp=[random.randint(1, 26) for _ in range(D)]
        tbest=tmp
    else:
        tmp=[random.randint(1, 26) for _ in range(D)]
    sc=score(tmp)
    if (10**6+sc)>best:
        tbest=tmp
        best=10**6+sc
    else:
        continue


for t in tbest:
    print(t)

Solution (Python):
import numpy as np

D = int(input())
Cs = list(map(int, input().split()))
Ss = []
for d in range(D):
    s = list(map(int, input().split()))
    Ss.append(s)

Ss = np.array(Ss)

solution = np.argmax(Ss, axis=1)




























for s in solution:
    print(s + 1)

Solution (Python):
import sys
input = sys.stdin.buffer.readline
import numpy as np

D = int(input())
c = np.array(input().split(), dtype=np.int32)
s = np.array([input().split() for _ in range(D)], dtype=np.int32)
last = np.zeros(26, dtype=np.int32)



ans = []
point = 0
for i in range(D):
    down = (i+1-last)*c
    loss = down * 5 + s[i,:]
    idx = np.argmax(loss)
    ans.append(idx+1)
    point += s[i, idx] - down.sum()
    last[idx] = i+1
    

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