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 random import randint
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split()))for _ in range(d)]
for i in range(d):s.append(s[i][:])
for i in range(d):s.append(s[i][:])
def xyz(start):
  ans=[0]*d
  score=0
  for i in range(start,start+d,26):
    dd=set()
    uu=set()
    h=[]
    for j in range(i,min(i+26,start+d)):
      for k in range(26):
        h.append([s[j][k],j,k])
    h.sort(reverse=1)
    for t,j,k in h:
      if j in dd or k in uu:continue
      score+=t
      ans[j%d]=k
      dd.add(j)
      uu.add(k)
  return [score,ans]
score,ans=xyz(0)
for i in range(1,d):
  ss,aa=xyz(i)
  if ss>score:
    score,ans=ss,aa
for i in ans:print(i+1)

Solution (Python):
import random
import time


t1 = time.time() 

def f_last(d, i, lt):
  idx = []
  if i in lt[0:d]:
    idx = [j+1 for j, x in enumerate(lt[0:d]) if x == i]
  else:
    idx.append(0)
  return idx[-1]

d = int(input())
lc = list(map(int, input().split()))
ls = []
for _ in range(d):
  ls.append(list(map(int, input().split())))

v_max = -(10**5)
lt_max = [1]*d
while 1:
  lt = [random.randint(1, len(lc)) for i in range(d)]
  v = 0
  for dd in range(1, d+1):
    v_d = 0
    for i in range(len(lc)):
      v_d += lc[i]*(dd-f_last(dd, i+1, lt))
    v = v + ls[dd-1][lt[dd-1]-1] - v_d
  if v_max < v:
    v_max = v
    lt_max = lt[:]
  t2 = time.time()
  if t2-t1 > 1.8:
    break

for t in lt_max:
  print(t)

Solution (Python):
import random

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]
besttbl = []
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
  besttbl.append(best + 1)
manman = manzoku
T = besttbl
for roop in range(20):
  T[random.choice(range(D))] = random.choice(range(26)) + 1
  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))
    yasumi[T[day] - 1] = 0
    manzoku += S[day][T[day] - 1]
    for i in range(26):
      manzoku -= C[i] * yasumi[i]
  if manman < manzoku:
    print(a)
    manman = manzoku
    besttbl = T
for best in besttbl:
  print(best)

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

Solution (Python):
import random, copy

D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    s.append(list(map(int, input().split())))
t = [random.randint(1, 26) for i in range(D)]
dq = [[random.randint(1, D), random.randint(1, 26)] for i in range(10 ** 5)]
last0 = []
last = [0] * 26
score = 0
for i in range(D):
    contest = t[i] - 1
    score += s[i][contest]
    last = [last[i] + 1 for i in range(26)]
    last[contest] = 0
    last0.append(last)
    for j in range(26):
        score -= c[j] * last[j]
ans = t
for i in range(10 ** 5):
    temp = score
    temp2 = copy.copy(t)
    d, q = dq[i][0] - 1, dq[i][1] - 1
    contest = t[d] - 1
    score += s[d][q]
    score -= s[d][contest]
    num = last0[d][q] - last0[d][contest]
    for j in range(d, D):
        if last0[j][q] == 0:
            break
        else:
            score += c[q] * num
            last0[j][q] -= num
    for j in range(d, D):
        if last0[j][contest] == 0:
            if j == d:
                score -= c[contest] * num
                last0[j][contest] += num
                pass
            else:
                break
        else:
            score -= c[contest] * num
            last0[j][contest] += num
    t[d] = q + 1
    if temp < score:
        ans = copy.copy(t)
for i in ans:
    print(i)

Solution (Python):
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
import time
start=time.time()
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
t=[0 for i in range(d)]
"""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]
  t[i]=backup[0]
  
"""
import random
for i in range(d):
	t[i]=random.randint(0,contestcount-1)
    
backup=t[:]
while(time.time()-start<1.8):
  ran1=random.randint(0,d-1)
  ran2=random.randint(0,d-1)
  newscore=0
  if ran1==ran2:
    if ran2!=0:
      ran2-=1
    else:ran2+=1
  t[ran1],t[ran2]=t[ran2],t[ran1]
  for i in range(d):
    newscore+=s[i][t[i]]
    last[t[i]]=i+1
    for j in range(contestcount):
        newscore-=c[j]*(i+1-last[j])
  
  if newscore>score:
    score=newscore
  else:t=backup[:]
for i in range(d):
  print(t[i]+1)

Solution (Python):
d = int(input())
c = list(map(int,input().split()))
ans = []
pen = [0]*26
for i in range(d):
    s = list(map(int,input().split()))
    sp = sum(pen)
    temp = -(10**9)
    for j in range(26):
        if s[j]-sp+pen[j] > temp:
            temp = s[j]-sp+pen[j]
            tempans = j+1
    ans += [tempans]
    for j in range(26):
        pen[j] += c[j]
        pen[tempans-1] = 0
for i in ans:
    print(i)

Solution (Python):
dur=int(input())
c=list(map(int,input().split()))
d=[0]*26
r=3
for i in range(dur):
  t=0
  s=list(map(int,input().split()))
  m=-1<<64
  for j in range(26):
    alt=s[j]+r*c[j]*(i+1-d[j])+sum([-r*c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  print(t+1)
  d[t]=i+1

Solution (Python):
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

T2 = [0]*D
L = [0]*26
for i in range(D):
    p = -10**15
    for j in range(26):
        d = S[i][j]
        for k in range(26):
            if k == j:
                continue
            d -= C[k]*(i+1-L[k])
        if p < d:
            p = d
            idx = j+1
    T2[i] = idx

p1 = calc(T)
p2 = calc(T2)
if p2 > p1:
    T = T2
    p = p2
else:
    p = p1

i = D-1
next = -1
while time.time()-t1 < 1.9:
    temp = T[i]
    for j in range(1, 27):
        T[i] = j
        newp = calc(T)
        if p < newp:
            p = newp
            temp = j
    T[i] = temp
            
    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
import copy


def cost(c, d, lastdi):
    total = 0
    for i in range(26):
        total += c[i]*(d - lastdi[i])
    return total


D = int(input())

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


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


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

ans = 0







for d in range(D):
    
    sd_sort = np.argsort(s[d])
    max_ans = 0
    typei = -1
    
    for i in range(26):
        tmp_lastdi = copy.deepcopy(lastdi)
        choicei = sd_sort[i]
        tmp_lastdi[choicei] = d+1 
        ans = s[d][choicei] - cost(c, d+1, tmp_lastdi)
        if ans > max_ans:
            
            typei = choicei

    lastdi[typei] = d+1 
    typei = s[d].index(max(s[d])) + 1
    print(typei)

Solution (Python):
import sys
import time
import random
import math

t_start = time.perf_counter()

N = 26
D = int(input())

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

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

last = [-1] * N
data = []
satisfaction = 0
for i in range(D):
	max_c = 0
	max_s = None
	s_list = s_table[i]
	for j in range(N):
		s = s_list[j]
		for k in range(N):
			if k != j:
				s -= c_list[k] * (i - last[k])
		if max_s == None or s > max_s:
			max_s = s
			max_c = j
	data.append(max_c)
	satisfaction += max_s
	last[max_c] = i

s_table = list(zip(*s_table))

print(satisfaction, file = sys.stderr)

def calc(data):
	satisfaction = 0
	for k, c in enumerate(c_list):
		last = -1
		penalties = 0
		s_list = s_table[k]
		for i, j in enumerate(data):
			if j == k:
				satisfaction += s_list[i]
				last = i
			else:
				penalties += i - last
		satisfaction -= penalties * c
	return satisfaction

def calc2(data):
	satisfaction = 0
	cache = []
	for k, c in enumerate(c_list):
		last = -1
		penalties = 0
		s_list = s_table[k]
		s = 0
		for i, j in enumerate(data):
			if j == k:
				s += s_list[i]
				last = i
			else:
				penalties += i - last
		satisfaction += s - penalties * c
		cache.append((s, penalties))
	return satisfaction, cache

def calc_update(data, cache, new_cache, changed1, changed2):
	satisfaction = 0
	for k, c in enumerate(c_list):
		if k == changed1 or k == changed2:
			last = -1
			penalties = 0
			s_list = s_table[k]
			s = 0
			for i, j in enumerate(data):
				if j == k:
					s += s_list[i]
					last = i
				else:
					penalties += i - last
		else:
			s, penalties = cache[k]
		new_cache[k] = (s, penalties)
		satisfaction += s - penalties * c
	return satisfaction

print(calc(data), file = sys.stderr)

def p(value_old, value_new, t):
	if value_new > value_old:
		return True
	else:
		return math.pow(math.e, (value_new - value_old) / t) > random.random()

def optimize(satisfaction, data):
	value = 0
	count = 0
	
	satisfaction, cache = calc2(data)
	tmp_data = list(data)
	tmp_cache = list(cache)
	
	for i in range(D):
		j = random.randrange(N)
		while data[i] == j:
			j = random.randrange(N)
		org = tmp_data[i]
		tmp_data[i] = j
		tmp_s = calc_update(tmp_data, cache, tmp_cache, j, org)
		
		if tmp_s < satisfaction:
			value += tmp_s - satisfaction
			count += 1
		tmp_data[i] = org
	
	T = (value / count) / math.log(0.8)
	print(T, value / count, math.log(math.e), math.log(0.5), file = sys.stderr)
	
	t_end = t_start + 1.8
	d = 0.9
	best = satisfaction
	best_data = list(data)
	
	T = 1
	c = 0
	while True:
		if time.perf_counter() > t_end:
			print("count:", c, file = sys.stderr)
			return best, best_data
		i = random.randrange(D)
		j = random.randrange(N)
		while j == data[i]:
			j = random.randrange(N)
		org = tmp_data[i]
		tmp_data[i] = j
		tmp_s = calc_update(tmp_data, cache, tmp_cache, j, org)


		if p(satisfaction, tmp_s, T):
			satisfaction = tmp_s
			data[i] = j
			cache[j] = tmp_cache[j]
			cache[org] = tmp_cache[org]
			if satisfaction > best:
				best = satisfaction
				best_data = list(data)
		else:
			tmp_data[i] = org
			tmp_cache[j] = cache[j]
			tmp_cache[org] = cache[org]
		c += 1
		T *= d

satisfaction, data = optimize(satisfaction, data)

print(calc(data), file = sys.stderr)

for j in data:
	print(j + 1)

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

manzoku = 0
kyounomanzoku = 0
kyounotype = 0
d = 1
last = [0]*26

for p in range(D):
    print((p**3+2*p**2-15*p+11)%26+1)


"""
for p in range(D):
    
    
    for t in range(26):
        if kyounomanzoku < int(s[p][t]):
            kyounomanzoku = int(s[p][t])
            kyounotype = t
    print(kyounotype+1)
    kyounomanzoku = 0
"""

Solution (Python):
import sys
from random import randint
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


def count_v(last_d, C, S, t, d):
    ret = S[t - 1]
    last_d[t - 1] = d
    for i in range(len(last_d)):
        ret -= C[i] * (d - last_d[i])
    return ret


def count_v_virtual(last_d, C, S, t, d):
    ret = S[t]
    tmp = last_d[t]
    last_d[t] = d
    for i in range(len(last_d)):
        ret -= C[i] * (d - last_d[i])
    last_d[t] = tmp
    return ret


def get_diff_score(T, d, q, C, D, Ss):
    diff = 0
    original_t = T[d - 1]
    last_d_q = 0
    last_d_ori = 0
    for i in range(d):
        if T[i] == q:
            last_d_q = i + 1
        if T[i] == original_t and i < d - 1:
            last_d_ori = i + 1
    
    for i in range(d - 1, D):
        if T[i] == q:
            break
        diff += C[q - 1] * (d - last_d_q)
    
    T[d - 1] = q
    for i in range(d - 1, D):
        if T[i] == original_t:
            break
        diff -= C[original_t - 1] * (d - last_d_ori)
    
    diff += Ss[d - 1][q - 1] - Ss[d - 1][original_t - 1]
    return diff


def main():
    D = int(input())
    C = inpl()
    Ss = [inpl() for _ in range(D)]
    T = []
    last_d = [-1] * len(C)
    Contest = 26

    for d in range(D):
        tmp_t, tmp_v = -1, -float('inf')
        for i in range(Contest):
            tmp_score = count_v_virtual(last_d, C, Ss[d], i, d)
            if tmp_score > tmp_v:
                tmp_v = tmp_score
                tmp_t = i
        last_d[tmp_t] = d
        T.append(tmp_t + 1)

    Cs = [i + 1 for i, c in enumerate(C)]
    Cs.sort(key=lambda x: C[x - 1])

    for _ in range(10000):
        d, q = randint(1, D), randint(1, Contest)
        ori_q = T[d - 1]
        diff = get_diff_score(T, d, q, C, D, Ss)
        if diff < 0:
            T[d - 1] = ori_q

    for t in T:
        print(t)

    return


if __name__ == '__main__':
    main()

Solution (Python):


import random

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

for i in range(D):
    print(random.randint(1, 26))

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

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

DP=[0]*26
for i in range(d):
    index,num=0,0
    for j in range(26):
        if S[i][j]>num:
            num=S[i][j]
            index=j
    print(index+1)

Solution (Python):
import numpy
d = int(input())
c = list(map(int,input().split()))
s = [[2 for j in range(26)] for i in range(d)]
k = [1]*26
for i in range(d):
    if i%36 == 0:
        k = [1]*26
    x = sum(k)
    if x >= 36 - i%36:
        q = 0
        for i in range(26):
            if k[i] == 1:
                q = i
                break
    else:
        q = numpy.argmax(s[i])
    print(q+1)
    k[q] = 0

Solution (Python):
def main():
    import os

    INF = 10 ** 9 + 10

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

    last = [-1] * 26

    def diff(d, t):
        ret = S[d][t]
        ret -= sum(ci * (d + 1 - last[i]) for i, ci in enumerate(C) if i != t)  
        return ret

    T = []
    score = 0
    for d in range(D):
        delta = -INF
        take_t = -1
        for t_ in range(26):
            buf = diff(d, t_)
            if delta < buf:
                delta = buf
                take_t = t_
            elif delta == buf and C[t_] > C[take_t]:
                delta = buf
                take_t = t_

        last[take_t] = d
        score += buf
        T.append(take_t + 1)
    print(*T, sep='\n')
    
    
    
    
    

    


if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import random
import time
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    start = time.time()
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    t = []
    last = [0]*n
    for i in range(d):
        m = c[0]+(i+1-last[0])*s[i][0]
        argmax = 0
        for ti in range(1,n):
            k = c[ti]+(i+1-last[ti])*s[i][ti]
            if m < k:
                m = k
                argmax = ti
        t.append(argmax+1)
        last[argmax] = i+1
    v = score(t)
    i = 0
    while time.time() < 1.5+start:
        nt = [i for i in t]
        r = random.random()
        if r > 0.5:
            if nt[i] < n:
                nt[i] += 1
        else:
            if nt[i] > 1:
                nt[i] -= 1
        nv = score(nt)
        if v < nv:
            t = [i for i in nt]
            v = nv
        i += 1
        i %= d
    for i in t:
        print(i)
    return


if __name__ == "__main__":
    solve()

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 = []
for i in range(D):
    t.append(int(random.uniform(1,27)))
    print(t[i])

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline
import time


_, = map(int,readline().split())
D = 365
*c, = map(int,readline().split())
s = tuple(tuple(map(int,readline().split())) for _ in range(D))

def output(ans):
    for i in ans: print(i+1)

def score(ans,s,c): 
    last = [-1]*26
    score = 0
    for i, ai in enumerate(ans):
        score += s[i][ai]
        last[ai] = i
        for ci,li in zip(c,last):
            score -= ci*(i-li)
        
    return score





def first_solution(s,c):
    minus = c[:]
    ans = [0]*365
    for i, si in enumerate(s):
        ans[i] = idx = max(range(26), key=lambda x:si[x]+minus[x])
        for i in range(26):
            minus[i] += c[i]
        minus[idx] = 0
    return ans        


"""
solution = 初期解(ランダム生成や、貪欲法など他の手法で求めたものを利用)
while 時間のある限り:
    solution を(ランダムに)少し変形
    if 変形前より解が悪化:
        solution を変形前の状態に戻す
"""


from bisect import bisect_left, bisect_right
"""
i 日目と i+1 日目を入れ替え
"""
def swap(i,ans,days,c,s):
    j = i+1
    ai = ans[i]
    aj = ans[j]
    di = days[ai]
    dj = days[aj]
    idx_i = bisect_left(di,-i)
    idx_j = bisect_left(dj,-j)
    
    
    
    
    
    i_prev = -di[idx_i - 1]
    i_next = -di[idx_i + 1] if di[-1] != -i else -1

    j_prev = -dj[idx_j - 1]
    j_next = -dj[idx_j + 1] if dj[-1] != -j else -1

    delta_i = -c[ai]*(2*i-i_prev-i_next) + s[j][ai] - s[i][ai]
    delta_j = -c[aj]*(j_prev+j_next-2*i) - s[j][aj] + s[i][aj]
    

    return delta_i + delta_j,idx_i,idx_j


def main(ans,s,c):
    from random import randrange
    
    start = time.time()
    days = [[-365] for _ in range(26)]
    for i in range(364,-1,-1):
        days[ans[i]].append(-i)

    while time.time() - start < 0.5:
        i = randrange(364)
        if ans[i] != ans[i+1]:
            delta,idx_i,idx_j = swap(i,ans,days,c,s)
            if delta > 0:
                days[ans[i]][idx_i] -= 1
                days[ans[i+1]][idx_j] += 1
                ans[i],ans[i+1] = ans[i+1],ans[i]
                    
        idx = randrange(26)
        a0 = ans[0]
        if a0 != idx:
            delta = s[0][idx] - s[0][a0] + c[a0]*(days[a0][-2]) - c[idx]*(days[idx][-1]+1)
            
            if delta > 0:
                ans[0] = idx
                days[idx].append(0)
                days[a0].pop()
                
        
        

    return ans


output(main(first_solution(s,c),s,c))

Solution (Python):
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    D = II()
    C = LMIIS()
    S = []
    for i in range(D):
        S.append(LMIIS())
    
    T = [0]*D
    for i in range(D):
        max_sat = -1
        max_type = -1
        L = S[i]
        for j in range(26):
            if max_sat < L[j]:
                max_sat = L[j]
                max_type = j
        T[i] = max_type
    
    for t in T:
        print(t+1)
    

    
main()

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

Solution (Python):
import random
D = int(input())
C = input().split()
C = [int(c) for c in C]
S = []
for i in range(D):
  s = input().split()
  s = [int(j) for j in s]
  S.append(s)

T = [10] * D
def value():
  M = 0
  last = [0] * 26
  for d in range(1,D+1):
    N = 0
    t = T[d-1]
    last[t-1] = d
    
    for j in range(26):
      N = N + C[j]*(d-last[j])
    M = M + S[d-1][t-1] - N
  return(M)
Vmax = value()

Q = []
for i in range(1000):
  Q.append([random.randint(1,D), random.randint(1,26)])
for i in range(1000):
  Tprev = T
  T[Q[i][0]-1] = Q[i][1]
  V = value()
  if V > Vmax:
    Vmax = V
  else:
    T = Tprev
  

for t in T:
  print(t)

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

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 s9(c, s, last_date, di, i, mul):
    score = s[di - 1][i]
    score += 0.2 * mul * c[i] * (di - last_date[i])
    return score


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

    t = []
    for di in range(1, D + 1):
        mul = np.median(s[di - 1]) / np.median(c)
        score_list = []
        for i in range(26):
            score_list.append(s9(c, s, last_date, di, i, mul))

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

    return t


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

Solution (Python):

D=int(input())
c=list(map(int,(input().split())))
s=[]
t=[]
last=[0]*26
sat=0

for i in range(D):
  s.append(list(map(int,(input().split()))))
  for day in range(26):
    if(last[day]!=0):
      last[day]+=1

  for j in range(26):
    for k in range(26):
      s[i][j]-=c[k]*(1+last[k])*10
    s[i][j]+=c[j]*(1+last[j])*9

  sat+=max(s[i])
  last[s[i].index(max(s[i]))]=1
  ans=s[i].index(max(s[i]))+1
  print(ans)

Solution (Python):

D = int(input())
cs = list(map(int, input().split()))
ss = [input().split() for l in range(D)]

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

Solution (Python):
from math import inf
from random import randint,random
import time
START=time.time()
PROB=0.99

def f(a,d,T):
    try:
        return T[d:].index(a)+d
    except ValueError:
        return len(T)

from random import randint
A=26

D=int(input())

C=[0]+list(map(int,input().split())) 
S=[0]*(D+1) 

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))
 
def g(d,q,S,C,T):
    p=T[d]

    a=f(p,d+1,T)
    b=f(q,d+1,T)
    
    Y=0
    h=L[d-1][p]
    for i in range(d,a):
        h+=1
        Y+=h-L[i][p]
        
    m=0
    Z=0
    for j in range(d,b):
        Z-=m-L[j][q]
        m+=1
        
    return (S[d][q]-S[d][p])+Z*C[q]-Y*C[p]

T=[0]
L=[[0]*(A+1) for _ in range(D+1)]
for d in range(1,D+1):
    M=-inf
    E=0

    for j in range(1,A+1):
        X=0
        for k in range(1,A+1):
            if j!=k:
                X-=C[k]*L[d][k]
                
        if M<=X+S[d][j]:
            M=X+S[d][j]
            E=j

    T.append(E)
    for j in range(1,A+1):
        if j!=E:
            L[d][j]=L[d-1][j]+1
        else:
            L[d][j]=0

while time.time()-START<=1.70:
    e=randint(1,D)
    q=randint(1,A)

    V=g(e,q,S,C,T)
    if V>0 or random()>PROB:
        p=T[d]

        a=f(p,d+1,T)
        b=f(q,d+1,T)
        
        h=L[d-1][p]
        for i in range(d,a):
            h+=1
            L[i][p]=h

        m=0
        for j in range(d,b):
            L[j][q]=m
            m+=1
        T[d]=q

for i in range(1,D+1):
    print(T[i])

Solution (Python):
import random
 
def calc1(D, s, t):
  last = [0 for _ in range(26)]
  val1 = [0 for _ in range(D)]
 
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    val1[i] += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
      val1[i] -= c[j] * (day - last[j])
  return value, val1
 
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0 for _ in range(26)]
calc = [0 for _ in range(26)]

t = [0 for _ in range(D)]
 
for i in range(D):
  for j in range(26):
    day = i + 1
    calc[j] = c[j] * (day - last[j])
  min_idx = calc.index(max(calc))
  last[min_idx] = day
  t[i] = min_idx + 1

val, val1 = calc1(D, s, t)
for _ in range(35000):
  d_rand = val1.index(min(val1)) + 1
  q_rand = random.randint(1,26)
  old = t[d_rand-1]
  t[d_rand-1] = q_rand
  new_val, new_val1 = calc1(D, s, t)
  if val > new_val:
    t[d_rand-1] = old
  else:
    val = new_val
    val1 = new_val1
for i in range(D):
  print(t[i])

Solution (Python):
import numpy as np
import copy
D=int(input())

c_list=list(map(int,input().split()))
c_list=np.array(c_list)
c_ll=np.array([0]*26)

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


score=0


for d in range(D):
    c_ll+=1
    exp=[0]*26
    for i in range(26):
        exp[i]+=d_list[d][i]
        c_ll2=copy.deepcopy(c_ll)
        c_ll2[i]=0
        exp[i]-=sum(c_list*c_ll2)

    j=exp.index(max(exp))
    c_ll[j]=0
    print(j+1)

Solution (Python):
import numpy as np

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

lastd=np.zeros(26)

ans=[0]*d
for i in range(d):  
  a=np.argmax(c*([i]*26-lastd))
  lastd[a]=i
  
  ans[i]=a+1

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

Solution (Python):
import math

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)]
count_nocontest = [2 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 j in range(26):
        if j == ans:
            nocontest[j] = 1
            count_nocontest[j] = 2
        else:
            nocontest[j] += count_nocontest[j]
            count_nocontest[j] += 1