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):
from time import time
from random import random

start_time = time()

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

def calc_score():
    S = 0
    last = [-1] * 26
    score = 0
    for d in range(D):
        S += s[d][t[d]]
        last[t[d]] = d
        for i in range(26):
            S -= c[i] * (d - last[i])
        score += max(10 ** 6 + S, 0)
    return score

def solution():
    return [i % 26 for i in range(D)]

t = solution()
score = calc_score()
while time() - start_time < 1.5:
    d = int(random() * D)
    q = int(random() * 26)
    old = t[d]
    t[d] = q
    new_score = calc_score()
    if new_score < score:
        t[d] = old

for e in t:
    print(e + 1)

Solution (Python):
import sys
import numpy as np
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    return D, C, S

@numba.njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@numba.njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

def first_strategy(D, C, S):
    
    key = S - 26 * C
    T = np.empty(D, np.int32)
    for d in range(D):
        T[d] = np.argmax(key[d])
    return T

def output(T):
    T += 1
    print(*T, sep='\n')

D,C,S = get_input()

T = first_strategy(D,C,S)
output(T)

Solution (Python):

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  


def score(D, C, S, T):
    last = [-1] * 26
    
    score = 0
    for d in range(D):
        
        score += S[d][T[d]]
        last[T[d]] = d
        for i in range(26):
            
            score -= C[i] * (d - last[i])
    return score


from random import choices

D = a_int()
C = ints()
S = read_tuple(D)

candi = list(range(26))



T = []
for s in S:
    T.append(s.index(max(s)))

print(*mina(*T, sub=-1), sep='\n')

Solution (Python):
D = int(input())

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

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



index_set=set(range(26))
for d in range(D):
  max_index=-1
  max_sd=-1
  for i in index_set:
    if max_sd<smat[d][i]:
      max_index=i
      max_sd=smat[d][i]
      
  max_index2=-1
  max_sd2=-1
  for i in range(26):
    if max_sd<smat[d][i]:
      max_index2=i
      max_sd2=smat[d][i]
      
  if max_index==max_index2:
    print(max_index+1)
    index_set.remove(max_index)
  else:
    if max_sd2>4*max_sd:
      print(max_index2+1)
    else:
      print(max_index+1)
      index_set.remove(max_index)      
      
  if not index_set:
    index_set=set(range(26))

Solution (Python):
D,*CS = map(int, open(0).read().split())
C = CS[:26]
S = [CS[26*i:26*(i+1)] for i in range(1, D+1)]

def imax(xs):
    m = -1
    i = 0
    for j, x in enumerate(xs):
        if x > m:
            i = j
            m = x
    return i

ds = [0] * 26

def pick(d):
    ss = S[d]
    dp = [(d + 1 - ds[i]) * x for i, x in enumerate(C)]
    total = sum(dp)
    tt = [total - x for x in dp]
    st = [s - t for s, t in zip(ss, tt)]
    return imax(st)

for d in range(D):
    i = pick(d)
    ds[i] = d
    print(i + 1)

Solution (Python):
def resolve():
    from collections import defaultdict
    D = int(input())
    C = [int(i) for i in input().split()]
    SD = [list(map(int, input().split())) for _ in range(D)]
    for i in range(D):
        print(SD[i].index(max(SD[i])) + 1)

resolve()

Solution (Python):
s = [input() for i in range(2)]
l0 = int(s[0])
l1 = list(map(int, s[1].split()))
t = [input() for i in range(l0)]
for i in range(l0):
    l2 = list(map(int, t[i].split()))
    print(l2.index(max(l2))+1)

Solution (Python):
import numpy as np

D=int(input())
c=np.array(list(map(int,input().split())))
s=[list(map(int,input().split())) for _ in range(D)]
t=[np.random.randint(1,27) for _ in range(D)]

MAX=0
for _ in range(1000):
    d=np.random.randint(1,D+1)
    q=np.random.randint(1,27)
    last=np.array([0]*26)
    v=0
    for i in range(1,D+1):
        if i==d:
            v+=s[d-1][q-1]
            last[q-1]=d
            v-=np.dot(c,d-last)
            continue
        v+=s[i-1][t[i-1]-1]
        last[t[i-1]-1]=i
        v-=np.dot(c,i-last)
    if v>MAX:
        MAX=v
        t[d-1]=q

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

Solution (Python):
from time import time
key = 1
rnd_mod = 12345678901234567891
rnd_x = 9876543210987654321 + 1234567890123456789 * key % rnd_mod
def rnd():
    global rnd_x
    rnd_x = rnd_x**2 % rnd_mod
    return (rnd_x>>10) % (1<<40)
def randrange(a, b=-1):
    if b > 0: return randrange(b-a) + a
    return rnd() % a

def calc():
    s = 0
    last = [-1] * 26
    for i, t in enumerate(A):
        s += S[i][t]
        last[t] = i
        for j, c in enumerate(C):
            s -= c * (i - last[j])
    return s

sTime = time()
D = int(input())
C = [int(a) for a in input().split()]
S = [[int(a) for a in input().split()] for _ in range(D)]
A = [randrange(26) for _ in range(D)]



ans = calc()

while time() - sTime < 1.8:
    d = randrange(D)
    i = A[d]
    for k in range(d)[::-1]:
        if A[k] == i:
            prev = k
            break
    else:
        prev = -1
    for k in range(d + 1, D):
        if A[k] == i:
            prev_ne = k
            break
    else:
        prev_ne = D
    for j in range(26):
        t = S[d][j] - S[d][i]
        for k in range(d)[::-1]:
            if A[k] == j:
                new = k
                break
        else:
            new = -1
        for k in range(d + 1, D):
            if A[k] == j:
                new_ne = k
                break
        else:
            new_ne = D
        t += C[j] * (d - new) * (new_ne - d) - C[i] * (d - prev) * (prev_ne - d)
        if t > 0:
            A[d] = j
            ans += t
            prev, prev_ne = new, new_ne
            i = j
            if 0:
                print("A =", A)
                print("ans =", ans)
                print("calc =", calc())
            
            

print(*[a + 1 for a in A], sep = "\n")
if 0:
    print(ans)
    print("A =", A)

Solution (Python):
import random
for i in range(365):
    print(random.randint(1,26))

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

width = 10

def calc(ts):
    last = [-1] * 26
    sat = 0
    for i, t in enumerate(ts):
        sat += ss[i][t-1]
        last[t-1] = i
        sat -= sum(c * (i - l) for c, l in zip(cs, last))       
    return sat

def search(ts):
    last = [-1] * 26
    sat = 0
    for i, t in enumerate(ts):
        sat += ss[i][t-1]
        last[t-1] = i
        sat -= sum(c * (i - l) for c, l in zip(cs, last))
    
    deltas = [-(10 ** 9)]
    i = len(ts)
    for t in range(1, 27):
        tmp = last[t-1]
        last[t-1] = i
        delta = ss[i][t-1] + sum(c * (i - l) for c, l in zip(cs, last))
        last[t-1] = tmp
        deltas.append(sat + delta)

    ls = sorted(enumerate(deltas), key = lambda t: t[1], reverse = True)
    return ls[:width]


best5ts = [[]]
for i in range(D):
    possible_best5ts = []
    possible_sats = []
    for ts in best5ts:
        best5t, sats = map(list, zip(*search(ts)))
        possible_best5ts += [ts + [t] for t in best5t]
        possible_sats += sats
    ls = sorted(enumerate(possible_sats), key = lambda t: t[1], reverse = True)
    best5ts = []
    for i, _ in ls[:width]:
        best5ts.append(possible_best5ts[i])

ts = best5ts[0]

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

Solution (Python):
from copy import copy
d = int(input())
c = [0] + list(map(int, input().split(' ')))

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

t = 0 

ca = [0] * (1 + 26) 
cat = [] 
cat2 = []
dc = 0 


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))
    dc += s[i][t]
    ca[t] = i
    dc -= sum(c[i3] * (i - ca[i3]) for i3 in range(1, 27))
    print(t)

Solution (Python):
D=int(input())
C=list(map(int,input().split()))
import sys
S=sys.stdin.readlines()
A=[0]*26
B=[0]*D
k=0
for i in range(26):
  if C[i]!=0:
    k+=C[i]
for i in range(26):
  if i<25:
    A[i]=int(C[i]/k*D)
  else:
    A[i]=D-sum(A[:25])

for i in range(25):
  for j in range(A[i]):
    m=max([l if B[l]==0 and l<(D+1)//(A[i]+1)*j else 0 for l in range(D)])
    B[m]=i+1

for i in range(D):
  if B[i]==0:
    B[i]=26

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

Solution (Python):

dd = int(input())
c = list(list(map(int, input().split())))
s = [[0]*26]*dd
v = [[0]*26]*dd
vs = [[0]*26]*dd
ans = [0]*dd
for i in range(dd):
    s[i] = list(list(map(int, input().split())))



for i in range(26):
    for j in range(dd):
        v[j][i]=s[j][i]+c[i]*(j+1)

for i in range(dd):
    maxv = -100000
    for j in range(26):
        if maxv < v[i][j]:
            maxv = v[i][j]
            ans[i]=j+1
for a in ans:
    print(a)

Solution (Python):
D = int(input())
C = list(map(int, input().split()))

S = []
for i in range(D):
    Si = list(map(int, input().split()))
    S.append(Si)
I = 26

last = [0]*I

score = S[1]
contest = score.index(max(score))

last = [x+1 for x in last]
last[contest] = 0

print(contest + 1)

for day in range(1, D):
    score = [(last[i]*C[i])*I+S[day][i] for i in range(I)]
    contest = score.index(max(score))

    last = [x+1 for x in last]
    last[contest] = 0

    print(contest + 1)

Solution (Python):
D = int(input())
c = list(map(int, input().split()))
last = [0] * 26
ans = []
S = []
prev_score = 0
for d in range(1, D+1):
    s = list(map(int, input().split()))
    S += [s]
    maxs = float('-inf')
    maxi = -1
    cumsump = 0
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        cumsump += tmp
    for i in range(26):
        tmp = -c[i] * (d - last[i])
        tmp2 = s[i] + cumsump - tmp
        if tmp2 > maxs:
            maxs = tmp2
            maxi = i
    ans += [maxi+1]
    last[maxi] = d
    prev_score += maxs

maxc = 0
maxci = -1
for i in range(26):
    if maxc < c[i]:
        maxc = c[i]
        maxci = i+1
for dd in range(D):
    prev_a = ans[dd]
    ans[dd] = maxci
    last = [0] * 26
    score = 0
    for d in range(1, D+1):
        td = ans[d-1] - 1
        cumsump = 0
        for i in range(26):
            if td != i:
                tmp = -c[i] * (d - last[i])
                cumsump += tmp
        last[td] = d
        score += S[d-1][td]+cumsump
    if score <= prev_score:
        ans[dd] = prev_a
    
for a in ans:
    print(a)

Solution (Python):
d = int(input())
clist = list(map(int,input().split()))
satisfactionlist = []
for _ in range(d):
    satisfactionlist.append(list(map(int,input().split())))

def decrease(clist,d,lastlist):
    sum = 0
    for i in range(26):
        sum += clist[i]*(d-lastlist[i])
    return sum

def calculate(d,clist,satisfactionlist,orderlist):
    satisfaction = 0
    lastlist = [0 for _ in range(26)]
    for j in range(d):
        i = orderlist[j]
        satisfaction += satisfactionlist[j][i-1]
        lastlist[i-1] = j+1
        satisfaction -= decrease(clist,j+1,lastlist)
    
    return satisfaction

orderlist = []
for day in range(d):
    combined1 = [x + y for (x, y) in zip(clist, satisfactionlist[day])]
    max_value = max(combined1)
    max_index = combined1.index(max_value)
    orderlist.append(max_index+1)

for ans in orderlist:
    print(ans)

Solution (Python):
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]

D=N()
c=[0]+L()
s=[[0]*27]+[[0]+L() for i in range(D)]

dp=[]
T=[0]
ld=[0]*(27)
for i in range(1,D+1):
    ma=0
    t=0
    for j in range(1,27):
        tmp=s[i][j]+(i-ld[j])*(D-i+1)*c[j]
        if tmp>ma:
            ma=tmp
            t=j
    T.append(t)
    ld[t]=i
        
sc=sum(c)
def point():
    ld=[0]*(27)
    score=-sc*((D+1)*D//2)
    for i in range(1,D+1):
        t=T[i]
        score+=s[i][t]+(i-ld[t])*(D-i+1)*c[t]
        ld[t]=i
    return score

now=point()
import random
for i in range(80000):
    d,q=random.randrange(1,D+1),random.randrange(1,27)
    old=T[d]
    T[d]=q
    new=point()
    if new>now:
        now=new
    else:
        T[d]=old

for i in T[1:]:
    print(i)

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

    t.append(s[i].index(min(s[i])) + 1)

Solution (Python):
D = int(input())
c = list(map(int,input().split()))
last_di = [0] * 26
satisfaction_list = [0] * 26

for d in range(1, D+1):
    s = list(map(int,input().split()))
    for i in range(26):
        satisfaction_list[i] += s[i] - c[i] * (d - last_di[i])
    min_index = satisfaction_list.index(min(satisfaction_list))
    last_di[min_index] = d
    print(min_index + 1)

Solution (Python):
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  s.append(list(map(int, input().split())))
  
sdictlist = []
sdictlistsorted = []
for i in range(D):
  onedict = {}
  for j in range(26):
    onedict[j] = s[i][j]
  sdictlist.append(onedict)
  onesorteddict = sorted(onedict.items(), key=lambda x:x[1], reverse=True)
  sdictlistsorted.append(onesorteddict)

lenpastmax = 23 




pastlist = []
for i in range(D):
  j = 0
  while(sdictlistsorted[i][j][0] in pastlist):
    j += 1
  print(sdictlistsorted[i][j][0]+1)
  pastlist.append(sdictlistsorted[i][j][0])
  if(len(pastlist)==lenpastmax):
    pastlist.pop(0)

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

nocontest = [1 for i in range(26)]

for i in range(D):
    s = S[i]
    contest = [0 for j in range(26)]
    for j in range(26):
        contest[j] = c[j] * nocontest[j] * s[j]
    
    max_contest = max(contest)
    ans = contest.index(max_contest)
    print(ans + 1)
    
    for i in range(26):
        if i == ans:
            nocontest[i] = 1
        else:
            nocontest[i] += 2

Solution (Python):
def input_one_number():
    return int(input())


D = input_one_number()

def input_multiple_number_as_list():
    return list(map(int, input().split()))

c = input_multiple_number_as_list()
last = [-1]*26


s = [[]*26 for _ in range(D)]

def dot(day):
	k = [0]*26
	for i in range(26):
		k[i] = c[i]*(day+1-last[i])
	return k


for i in range(D):
	s[i] = input_multiple_number_as_list()

for day in range(D):
	
	
	

	
	
	
	
	
	
	
	
	print(day%26+1)

Solution (Python):
import random
def main():
    D = int(input())
    c = list(map(int,input().split()))
    s = []
    for d in range(D):
        s.append(list(map(int,input().split())))
    
    last = [0 for i in range(26)]
    
    v = 0
    
    for d in range(D):
        print(random.randint(1,26))
    
if __name__ == '__main__':
    main()

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

for i in range(365):
    print(9)

Solution (Python):
D = int(input())
input()
ary = list()
for i in range(D):
    j = list(map(int, input().split()))
    ary.append(j)

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

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

s = [[] for i in range(d)]
for i in range(d):
    line = list(map(int,input().split()))
    s[i] = line
cost_list = [0 for i in range(N)]



last_di = [0 for i in range(N)]

def todays_cost(day,contest):
    cost = 0
    for i in range(N):
        cost += c[i] * (day - last_di[i])
    
    cost -= c[contest] * (day - last_di[contest])
    
    cost -= s[day - 1][contest]
    
    return  cost * (-1)

def greedy():
    m = 0
    for i in range(1,d+1):
        for j in range(N):
            cost_list[j] = todays_cost(i,j)
        
        max_value = max(cost_list)
        
        max_index = cost_list.index(max_value)
        last_di[max_index] = i
        
        m += max_value
        print(max_index + 1)
    

greedy()

Solution (Python):
import time

st = time.time()

d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = [0] * d
k = [-1] * 26
sc = 0
for i in range(d):
    res = -100000000
    p = 0
    for j in range(26):
        tmp = 0
        tmp += s[i][j]
        for x in range(26):
            if x == j:
                continue
            tmp -= c[x] * (i - k[x])
        if res < tmp:
            res = tmp
            p = j
    sc += res
    k[p] = i
    ans[i] = p
while time.time() - st <= 1.5:
    rsc = -10000000000000
    p = (0, 0)
    for y in range(d):
        for m in range(26):
            k = [-1] * 26
            tsc = 0
            for i in range(d):
                if i == y:
                    tsc += s[i][m]
                    k[m] = i
                else:
                    tsc += s[i][ans[i]]
                    k[ans[i]] = i
                for j in range(26):
                    tsc -= c[j] * (i - k[j])
            if tsc > rsc:
                p = (y, m)
                rsc = tsc
    if sc < rsc:
        sc = rsc
        ans[p[0]] = p[1]
    else:
        break
for x in ans:
    print(x + 1)

Solution (Python):
d = int(input())
cl = list(map(int, input().split()))
sl = []
for _ in range(d):
    sl.append(list(map(int, input().split())))

tl = []



last_di = [-1]*26
ans = 0
for day in range(d):
    best_t = 0
    best_t_val = -999999999999
    for t in range(26):
        curr_val = sl[day][t]*1
        for i in range(26):
            if i == t: continue
            curr_val -= (day-last_di[i])*cl[i]*5
        if curr_val >= best_t_val:
            best_t = t
            best_t_val = curr_val
    tl.append(best_t+1)
    last_di[best_t] = day
    ans += best_t_val
    
    
    
    

for t in tl:
    print(t)

Solution (Python):
import random
import time
import copy
start=time.time()
d=int(input())
c=list(map(int, input().split()))
s=[]
solution=[]
last=[0]*26
sco=0
for i in range(d):
  s.append(list(map(int, input().split())))
for day in range(1,d+1):
  man=[]
  for i in range(26):
    man.append(s[day-1][i]+last[i]*c[i])
  con=man.index(max(man))
  sco+=s[day-1][con]
  last[con]=day
  for (i,j) in zip(last,c):
    sco-=i*j
  solution.append(con)
while time.time()-start<1.9:
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(10)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,c):
      sc-=i*j
  if sc>sco:
    solution=copy.deepcopy(sol)
    sco=sc
for i in solution:
  print(i+1)

Solution (Python):
import sys
sys.setrecursionlimit(1000000)
readline = sys.stdin.readline
from collections import deque


def solve_beam():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    W, DEPTH = 4, 5

    def rec(day, rem):
        if rem == 0 or day > D:
            return 0, 0
        gains = [(S[day - 1][t] + (day - lasts[t]) * C[t], t) for t in range(N)]
        gains.sort(reverse=True)
        max_gain = -1e10
        max_gain_t = 0
        for i in range(W):
            gain, t = gains[i]
            _t = lasts[t]
            lasts[t] = day
            f_gain, _ = rec(day + 1, rem - 1)
            lasts[t] = _t
            gain += f_gain
            if gain > max_gain:
                max_gain = gain
                max_gain_t = t

        return max_gain, max_gain_t

    _total = 0
    for day in range(D):
        _, t = rec(day, DEPTH)
        lasts[t] = day
        ans[day - 1] = t
        _total += _
    
    
    for a in ans:
        print(a + 1)


solve_beam()

Solution (Python):
from random import randint
from time import time
t1=time()

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

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

t=[]
for i in range(d):
	t.append(i%26+1)

t2=time()
while t2-t1<1.85:
	tt=t.copy()
	tt[randint(1,d)-1]=randint(1,26)
	if score(tt)>score(t):
		t=tt.copy()
	t2=time()
for x in t:
	print(x)

Solution (Python):
import sys

input=sys.stdin.readline
from random import randint
d=int(input().rstrip())
c=[int(i)for i in input().split()]
s=[[int(i)for i in input().split()]for _ in range(d)]
last=[0]*26
for i in range(d):
    print(randint(1,26))

Solution (Python):
import numpy as np

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


def s3(c, s, last_date, di, i):
    score = s[di - 1][i]
    score += 500 * c[i - 1] * (di - last_date[i - 1])
    return score


def f3(D, c, s):
    last_date = np.zeros(26)

    t = []
    for di in range(1, D + 1):
        score_list = []
        for i in range(26):
            score_list.append(s3(c, s, last_date, di, i))

        select_index = score_list.index(max(score_list))
        t.append(select_index)
        last_date[select_index] = di

    return t


for ti in f3(D, c, s):
    print(ti + 1)

Solution (Python):
from bisect import bisect_left
from random import randint
D = int(input())
Cs = list(map(int, input().split()))
Sss = []
for _ in range(D):
    Ss = list(map(int, input().split()))
    Sss.append(Ss)

def change(d, afterIdx):
    global score
    i = d - 1
    beforeIdx = Ts[i] - 1
    afterIdx -= 1
    if beforeIdx == afterIdx:
        return

    newScore = score

    before = lasts[beforeIdx]
    
    k1 = bisect_left(before, d)
    w = before[k1+1] - d
    h = d - before[k1-1]
    newScore -= Sss[i][beforeIdx]
    newScore -= w * h * Cs[beforeIdx]

    after = lasts[afterIdx]
    
    k2 = bisect_left(after, d)
    w = after[k2] - d
    h = d - after[k2-1]
    newScore += Sss[i][afterIdx]
    newScore += w * h * Cs[afterIdx]

    if newScore > score:
        lasts[beforeIdx].pop(k1)
        lasts[afterIdx].insert(k2, d)
        Ts[i] = afterIdx + 1
        score = newScore

Ts = []
for _ in range(D):
    Ts.append(randint(1, 26))

score = 0
lasts = [[0] for _ in range(26)]
for i, t in enumerate(Ts):
    d = i + 1
    t -= 1
    score += Sss[i][t]
    lasts[t].append(d)
    for j in range(26):
        score -= (d - lasts[j][-1]) * Cs[j]

for i in range(26):
    lasts[i].append(D+1)


for i in range(300000):
    change(randint(1, D), randint(1, 26))

for t in Ts:
    print(t)

Solution (Python):
import sys
input = sys.stdin.readline
import random
import time
import copy
time0=time.time()

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

T=[0]
for i in range(1,D+1):
    MAX=-1
    for j in range(1,27):
        if S[i][j]>MAX:
            k=j
            MAX=S[i][j]
    T.append(j)

ANS=0
LAST=[[0]*27 for i in range(D+1)]
for day in range(1,D+1):
    for j in range(1,27):
        LAST[day][j]=LAST[day-1][j]
    t=T[day]
    ANS+=S[day][t]
    LAST[day][t]=day

    for j in range(1,27):
        ANS-=C[j]*(day-LAST[day][j])

while time.time()-time0<1.77:
    BT=copy.deepcopy(T)
    BLAST=copy.deepcopy(LAST)
    BANS=ANS
    
    d=random.randint(1,D)
    after_t=random.randint(1,26)

    before_t=T[d]

    ANS+=S[d][after_t]-S[d][before_t]

    T[d]=after_t

    for day in range(d,D+1):
        if T[day]!=before_t:
            ANS+=C[before_t]*(day-LAST[day][before_t])
            LAST[day][before_t]=LAST[day-1][before_t]
            ANS-=C[before_t]*(day-LAST[day][before_t])
        else:
            break

    ANS+=C[after_t]*(d-LAST[d][after_t])
    LAST[d][after_t]=d

    for day in range(d+1,D+1):    
        if T[day]!=after_t:
            ANS+=C[after_t]*(day-LAST[day][after_t])
            LAST[day][after_t]=LAST[day-1][after_t]
            ANS-=C[after_t]*(day-LAST[day][after_t])

    if ANS*100<BANS*98:
        T=BT
        LAST=BLAST
        ANS=BANS

print(*T[1:])

Solution (Python):
def max_(s, q, j):
  num = 0
  for i in range(1, q):
    if s[0][j] < s[i][j]:
      num += 1
  if num > q*2/3:
    return False
  else:
    return True
  
D = int(input())
N = 26
c = [int(i) for i in input().split()]
last = [0 for i in range(N)]
s = list()
q = 7
for i in range(q):
  s.append([int(j) for j in input().split()])
  
for i in range(D-q):
  d_score = -1
  ans = -1
  ans_d = -1
  for j in range(N):
    last_day = (i + 1 - last[j])
    arg = s[0][j] + c[j]*last_day
    if d_score < arg and max_(s, q, j):
      d_score = arg
      ans = j+1
    if d_score < arg:
      ans_d = j+1
  if ans == -1:
    ans = ans_d
  print(ans)
  del s[0]
  s.append([int(j) for j in input().split()])
  last[ans-1] = i+1
for i in range(q):
  d_score = -1
  ans = -1
  for j in range(N):
    last_day = i + 1 - last[j]
    arg = s[i][j] + c[j]*last_day
    if d_score < arg:
      d_score = arg
      ans = j+1
  print(ans)
  last[ans-1] = D-q+i+1

Solution (Python):
from random import *
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):
    cand=0
    for j in range(26):
        if s[i][cand]<s[i][j]:
            cand=j
    print(randrange(1,26))