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 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.1)
	print(T, value / count, math.log(math.e), math.log(0.5), file = sys.stderr)
	
	t_end = t_start + 1.8
	d = 0.9999
	best = satisfaction
	best_data = list(data)
	
	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):






import sys
input = sys.stdin.readline

import math

import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

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

ans = 0
score = 0
last = [[-1] for i in range(26)]
schedule = []

for d in range(D):
  t = d%26
  last[t].append(d)
  score += S[d][t]
  schedule.append(t)

for i in range(26):
  last[i].append(D)
  for k in range(len(last[i])-1):
    g = last[i][k+1]-last[i][k]-1
    score -= C[i]*g*(g+1)//2

count = 2000000
import random
while count:
  count -= 1
  prev = score
  d,q = random.choice(range(D)),random.choice(range(26))
  p = schedule[d]
  schedule[d] = q
  score -= S[d][p]
  score += S[d][q]
  
  pos = last[p].index(d)
  score -= C[p]*(last[p][pos]-last[p][pos-1])*(last[p][pos+1]-last[p][pos])
  last[p].remove(d)
  
  pos = bisect.bisect(last[q],d)
  score += C[q]*(d-last[q][pos-1])*(last[q][pos]-d)
  bisect.insort(last[q],d)
  if score<prev:
    score = prev
    bisect.insort(last[p],d)
    last[q].remove(d)
    schedule[d] = p
    
for i in schedule:
  print(i+1)

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

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

ans = [1+k%26 for k in range(365)]
print(*ans,sep="\n")

Solution (Python):
import sys

def warn(*m):
    print(m, file=sys.stderr)

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

def ratio(xs):
    s = sum(xs)
    return [x / s for x in xs]

ds = [0] * 26

def pick(d):
    s = ratio(S[d])
    c = ratio([(1 + d - ds[i]) * x for i, x in enumerate(C)])
    return imax([x * y + x for x, y in zip(s, c)])

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

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

last=[0]*26


for d in range(1,D+1):
    ans=[]
    for choice in range(1,27):
        ans_tmp=0
        ans_tmp+=s[d-1][choice-1]
        for i in range(26):
            if i+1==choice:
                continue
            ans_tmp-=c[i]*(d-last[i])*(D-d)//72
        ans.append((ans_tmp,choice))
    _,case=max(ans)
    last[case-1]=d
    print(case)

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

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

def maxarg(l):
    nl=len(l)
    ma=-10**20
    idx=-1
    for i in range(nl):
        if l[i]>ma:
            ma=l[i]
            idx=i
    return (idx,ma)

last=[0]*26
for j,ss in enumerate(s):
    
    cand = [ss[i]+c[i]*(j+1-last[i]) for i in range(26)]
    idx,val = maxarg(cand)
    
    last[idx]=j+1

    print(idx+1)

Solution (Python):
d=int(input())
c=list(map(int,input().split()))
c_days=[0]*26
for i in range(d):
    s=list(map(int,input().split()))
    
    c_low=[c[x]*(i+1-c_days[x]) for x in range(26)]
    c_max=[s[x]-c_low[x] for x in range(26)]
    n=c_max.index(max(c_max))
    c_days[n]=i+1
    print(n+1)

Solution (Python):
import random


def _calc_today_max_v3(today, D, Ci, Sdi, last_day):
    bad_1st_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    total_bad_1st_value = sum(bad_1st_values)
    bad_2nd_values = [Ci[contest] * (today + 2 - last_day[contest]) for contest in range(26)]
    total_bad_2nd_value = sum(bad_2nd_values)
    bad_3rd_values = [Ci[contest] * (today + 3 - last_day[contest]) for contest in range(26)]
    total_bad_3rd_value = sum(bad_3rd_values)
    bad_4th_values = [Ci[contest] * (today + 4 - last_day[contest]) for contest in range(26)]
    total_bad_4th_value = sum(bad_4th_values)

    head = 5
    contests_2nd = list(range(26))
    contests_3rd = list(range(26))
    contests_4th = list(range(26))
    random.shuffle(contests_2nd)
    random.shuffle(contests_3rd)
    random.shuffle(contests_4th)

    max_value = -99999999999999999
    max_context = 0
    for contest_1st in range(26):
        contest_1st_value = Sdi[today][contest_1st]
        bad_1st_value = total_bad_1st_value - bad_1st_values[contest_1st]
        if today == D - 1:
            today_value = contest_1st_value - bad_1st_value
            if max_value < today_value:
                max_value = today_value
                max_context = contest_1st
        else:
            for contest_2nd in contests_2nd[0:head]:
                contest_2nd_value = Sdi[today + 1][contest_2nd]
                bad_2nd_value = total_bad_2nd_value - bad_1st_values[contest_1st] - bad_2nd_values[contest_2nd] \
                                + Ci[contest_1st]
                
                
                
                
                if today == D - 2:
                    today_value = contest_1st_value + contest_2nd_value - bad_1st_value - bad_2nd_value
                    if max_value < today_value:
                        max_value = today_value
                        max_context = contest_1st
                else:
                    for contest_3rd in contests_3rd[0:head]:
                        contest_3rd_value = Sdi[today + 2][contest_3rd]
                        bad_3rd_value = total_bad_3rd_value - bad_1st_values[contest_1st] + 2 * Ci[contest_1st]
                        - bad_2nd_values[contest_2nd] + Ci[contest_2nd] - bad_3rd_values[contest_3rd]

                        if today == D - 3:
                            today_value = contest_1st_value + contest_2nd_value + contest_3rd_value - bad_1st_value - bad_2nd_value - bad_3rd_value
                            if max_value < today_value:
                                max_value = today_value
                                max_context = contest_1st
                        else:
                            for contest_4th in contests_4th[0:head]:
                                contest_4th_value = Sdi[today + 3][contest_4th]
                                bad_4th_value = total_bad_4th_value - bad_1st_values[contest_1st] + 3 * Ci[contest_1st]
                                - bad_2nd_values[contest_2nd] + 2 * Ci[contest_2nd] - bad_3rd_values[contest_3rd] + Ci[
                                    contest_3rd] - bad_4th_values[contest_4th]

                                today_value = contest_1st_value + contest_2nd_value + contest_3rd_value + contest_4th_value - \
                                              bad_1st_value - bad_2nd_value - bad_3rd_value - bad_4th_value
                                if max_value < today_value:
                                    max_value = today_value
                                    max_context = contest_1st

    return max_context


def _calc_today_max_v2(today, D, Ci, Sdi, last_day):
    today_bad_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    today_total_bad_value = sum(today_bad_values)
    bad_2nd_values = [Ci[contest] * (today + 2 - last_day[contest]) for contest in range(26)]
    total_bad_2nd_value = sum(bad_2nd_values)

    max_value = -99999999999999999
    max_context = 0
    for contest_1st in range(26):
        contest_1st_value = Sdi[today][contest_1st]
        bad_1st_value = today_total_bad_value - today_bad_values[contest_1st]
        if today == D - 1:
            today_value = contest_1st_value - bad_1st_value
            if max_value < today_value:
                max_value = today_value
                max_context = contest_1st
        else:
            for contest_2nd in range(26):
                contest_2nd_value = Sdi[today + 1][contest_2nd]
                bad_2nd_value = total_bad_2nd_value - today_bad_values[contest_1st] - bad_2nd_values[contest_2nd]
                today_value = contest_1st_value + contest_2nd_value - bad_1st_value - bad_2nd_value
                if max_value < today_value:
                    max_value = today_value
                    max_context = contest_1st
    return max_context


def _calc_today_max(today, D, Ci, Sdi, last_day):
    today_bad_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    today_total_bad_value = sum(today_bad_values)

    max_value = -99999999999999999
    max_context = 0
    for contest in range(26):
        today_contest_value = Sdi[today][contest]
        today_bad_value = today_total_bad_value - today_bad_values[contest]
        today_value = today_contest_value - today_bad_value
        if max_value < today_value:
            max_value = today_value
            max_context = contest

    return max_context


def _main(D, Ci, Sdi):
    last_day = [0] * 26
    for today in range(D):
        max_contest = _calc_today_max_v3(today, D, Ci, Sdi, last_day)
        print(max_contest + 1)
        last_day[max_contest] = today + 1


def _execute():
    D = int(input())
    Ci = list(map(int, input().split()))
    Sdi = []
    for i in range(D):
        Sdi.append(list(map(int, input().split())))
    _main(D, Ci, Sdi)


if __name__ == "__main__":
    _execute()

Solution (Python):
D=int(input())
for i in range(D):
  print(1)

Solution (Python):
import sys
import numpy as np

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

D = ri()
c = np.array(rl())
s = np.array([np.array(rl()) for _ in range(D)])
li = np.zeros(26)
li_one = np.ones(26)
c_sum = sum(c)
for lis in s:
  tmp_list = lis ** 2 / c**0.01
  idx_list = np.argsort(tmp_list)[:-6:-1]
  li += li_one
  max_idx = -1
  max_score = -10**10
  for i in idx_list:
    tmp = li
    li += li_one
    li[i] = 0
    sum_c_li = np.sum(c*li)
    score = lis[i] - sum_c_li
    if score > max_score:
      max_idx = i
      max_score = score
    li = tmp
  print(max_idx + 1)

Solution (Python):
import pprint
D = int(input())
A = [[0]*26]*D
S = 0
C = list(map(int,input().split()))
P = 0
ld =[0]*26
l = [0]*26
sp = 0
t = [0]*D
for i in range(D):
  A[i] = list(map(int,input().split()))
for j in range(D):
  maxvalue = max(A[j])
  index = A[j].index(maxvalue)
  for n in range(26):
    ld[n] = ld[n]+1
  sp = ld[index]
  ld[index] = 0 
  for k in range(26):
    l[k] = C[k]*ld[k]
  lmax =max(l)
  if 13*lmax > maxvalue:
    lindex = l.index(lmax)
    ld[index] = sp
    ld[lindex] = 0
    for m in range(26):
      l[m] = C[m]*ld[m]
  S = S+maxvalue-sum(l)
  t[j] = index+1
[print(i) for i in t]

Solution (Python):
def resolve():
    import copy
    D = int(input())
    cost = list(map(int, input().split()))
    sat = [list((map(int, input().split()))) for _ in range(D)]
    last = [0]*26
    printnum = 1
    for i in range(D):
        if i % 20 != 0:
            print(printnum)
            printnum += 1
            if printnum == 27:
                printnum = 1
        else:
            maxcost = -float("INF")
            ans = 0
            for j in range(26):
                nowlast = copy.deepcopy(last)
                nowlast[j] = i+1
                plussat = sat[i][j]
                minussat = 0
                for k in range(26):
                    minussat += (i + 1 - nowlast[k]) * (cost[k])
                cum = plussat-minussat

                if maxcost < cum:
                    ans = j
                    maxcost = cum
            last[j] = i+1
            print(ans+1)
            printnum = ans + 2
            if printnum == 27:
                printnum = 1
resolve()

Solution (Python):


from collections import defaultdict
from heapq import heappush, heappop
import sys
import numpy as np
from random import random
from time import perf_counter

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  


def debug(*x):
    print(*x, file=sys.stderr)


def solve(D, CS, S):
    "void()"
    time = perf_counter()

    answer = []
    last = [-1] * 26
    for i in range(D):
        dscore = np.zeros(26)
        for j in range(26):
            dscore[j] += S[i, j]
            dscore[j] -= sum(CS[k] * (i - last[k])
                             for k in range(26) if j != k)

        j = dscore.argmax()
        answer.append(j + 1)
        last[j] = i
    s = calcScore(answer, D, CS, S)

    bestscore = s
    bestanswer = answer

    ORIG_S = S.astype(np.float)
    while perf_counter() - time < 1.5:
        answer = []
        last = [-1] * 26
        k1 = random()
        k2 = random() * k1
        S = ORIG_S.copy()
        S[:-1] = (S[:-1] + k1 * ORIG_S[1:]) / (1 + k1)
        S[:-2] = (S[:-2] + k2 * ORIG_S[2:]) / (1 + k2)
        for i in range(D):
            dscore = np.zeros(26)
            for j in range(26):
                dscore[j] += S[i, j]
                dscore[j] -= sum(CS[k] * (i - last[k])
                                 for k in range(26) if j != k)

            j = dscore.argmax()
            answer.append(j + 1)
            last[j] = i
        s = calcScore(answer, D, CS, ORIG_S)
        if s > bestscore:
            
            bestscore = s
            bestanswer = answer
    print(*bestanswer, sep="\n")


def calcScore(answer, D, CS, S):
    last = [-1] * 26
    score = 0
    for i in range(D):
        j = answer[i] - 1
        score += S[i, j]
        last[j] = i
        score -= sum(CS[j] * (i - last[j]) for j in range(26))
    return score






def main():
    D = int(input())
    CS = list(map(int, input().split()))
    S = np.int16(read().split())
    S = S.reshape((D, 26))

    
    solve(D, CS, S)


def _test():
    import doctest
    doctest.testmod()
    as_input(T)
    main()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        
        
        from my_module import solve  
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()

Solution (Python):
import numpy as np
import time
import random

start_time = time.time()

def calc(d, q):
    select_rand = select.copy()
    select_rand[d] = q
    last = [0] * 26
    satisfied_rand = 0
    for i in range(1, D+1):
        t = select_rand[i-1]
        satisfied_rand += s[i-1][t-1]
        last[t-1] = i
        for j in range(26):
            satisfied_rand -= c[j] * (i-last[j])
    return (satisfied_rand, select_rand)

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

c = np.array(c)

last = [0] * 26
select = []
satisfied = 0
for i in range(1, D+1):
    last_d = [c[j]*(i-last[j]) for j in range(26)]
    last_d_sum = sum(last_d)
    
    s_d = np.array(s[i-1])
    maxindexA = np.argmax(s_d)
    satis_optA = s_d[maxindexA] - last_d_sum + last_d[maxindexA]
    
    
    last_d = np.array([c[j]*(i-last[j]) for j in range(26)])
    maxindexB = np.argmax(last_d)
    satis_optB = s_d[maxindexB] -last_d_sum + last_d[maxindexB]

    if satis_optA >= satis_optB:
        
        select.append(maxindexA+1)
        satisfied += satis_optA
        last[maxindexA] = i
    else:
        
        select.append(maxindexB+1)
        satisfied += satis_optB
        last[maxindexB] = i

while time.time() - start_time < 1.5:
    d = random.randint(0, D-1)
    q = random.randint(1, 26)
    result = calc(d, q)
    if satisfied < result[0]:
        select = result[1]

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

Solution (Python):
dur=int(input())
c=list(map(int,input().split()))
d=[0]*26
r=1.5
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):
D = int(input()) 
c = list(map(int, input().split()))
s_matrix = [list(map(int, input().split())) for _ in range(D)]
last = [0] * 26
satis = 0

for i in range(D):
    satis3 = satis
    last3 = last.copy()
    for k in range(26):
        satis2 = satis3
        last2 = last3.copy()

        satis2 += s_matrix[i][k]
        last2[k] = i + 1
        for j in range(26):
            satis2 -= c[j] * (i+1 - last2[j])
        
        if satis2 > satis:
            satis = satis2
            ans = k + 1
            last = last2.copy()
    
    print(ans)

Solution (Python):


import sys
input=sys.stdin.readline

def main():
    D=int(input())
    C=list(map(int,input().split()))
    S=[list(map(int,input().split())) for i in range(D)]
    last=[[0]*27 for i in range(D+1)]
    satsum=0
    lastt=[[0]*27 for i in range(D+1)]
    for day in range(1,D+1):
        for i in range(D+1):
            for j in range(27):
                lastt[i][j]=last[i][j]
        maxt=0
        maxsat=0
        for t in range(1,27):
            sat=0
            for j in range(day,D+1):
                    last[j][t]=day
            sat+=S[day-1][t-1]
            for j in range(1,27):
                sat-=C[j-1]*(day-last[day][j])
            if t==1:
                maxt=t
                maxsat=sat
            elif maxsat<sat:
                maxt=t
                maxsat=sat
            for i in range(D+1):
                for j in range(27):
                    last[i][j]=lastt[i][j]
            
        satsum+=maxsat
        for j in range(day,D+1):
            last[j][maxt]=day
        satsum+=maxsat
        print(maxt)
    
if __name__=="__main__":
    main()

Solution (Python):
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from copy import deepcopy

    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]
    memo = [0] * 26
    check = 0
    for i in range(d):
        ans = 0
        tmp = deepcopy(check)
        check = -float('inf')
        for idx, ss in enumerate(s[i]):
            v = tmp + ss
            for j, (m, cc) in enumerate(zip(memo, c)):
                if j == idx:
                    continue
                v -= cc * (i + 1 - m)
            if check < v:
                ans = idx + 1
                check = v
        print(ans)
        memo[ans - 1] = i + 1


if __name__ == '__main__':
    main()

Solution (Python):
import random
import sys
input = sys.stdin.readline
d=int(input())
c=list(map(int,input().split()))
cn=sorted(c)
h=cn[12]
P=[k+1 for k,v in enumerate(c) if v>=h]
s=[]
for _ in range(d):
    s.append(list(map(int,input().split())))




t=[]
for _ in range(d):
    z=random.randrange(len(P))
    t.append(P[z])
print(*t)

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








def dissat(day):
  dissat = 0
  for i in range(26):
    if T[day-1]-1 == i:
      continue
    dissat += C[i]*(day-lastdays[i])

  return dissat    
    
def last(day):
  lastdays[T[day-1]-1] = day


def calcscore(D):
  sat = 0
  for i in range(D):
    
    last(i)
    sat += S[i][T[i]-1] - dissat(i+1)
  
  return sat













import random
T = [0]*D
for i in range(D):
  T[i] = random.randrange(1,26)

lastdays = [0]*26
oldscore = calcscore(D)

count = 0
while count < 30:
  count += 1
  d=random.randrange(1,D)
  q=random.randrange(1,26)
  old = T[d-1] 
  T[d-1] = q
  lastdays = [0]*26
  if calcscore(D) < oldscore:
    T[d-1] = old

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

Solution (Python):
def cal(x):
  Manzoku=0
  l=[0]*26
  for d in range(D):
    l[x[d]-1]=d
    Manzoku+=s[d][x[d]-1]
    for i in range(26):
      Manzoku-=c[i]*(d-l[i])
  return Manzoku

D=int(input())
c=list(map(int,input().split()))
s=[]
t=[]
for i in range(D):
  s.append(list(map(int,input().split())))
l=[0]*26


max=0
target=0
deg=0

for d in range(D):
  for i in range(26):
    deg=c[i]*(d-l[i])
    if max < deg:
      max=deg
      target=i
  t.append(target+1)
  l[target]=d



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

Solution (Python):
from random import randrange

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

D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D): s.append(list(map(int,input().split())))
d = 0
t = []
last = [-1] * 26
for i in range(D):
    maximum = 0
    maxs = 0
    for j in range(26):
        if maximum < s[i][j] + c[j] * (i - last[j]):
            maxs = j
            maximum = s[i][j] + c[j] * (i - last[j])
    last[maxs] = i
    t.append(maxs)
point = score(d,c,s,t)
for i in range(5000):
    d = randrange(D)
    q = randrange(26)
    old = t[d]
    t[d] = q
    if point > score(d,c,s,t): t[d] = old
for i in t: print(i + 1)

Solution (Python):

import math
import random
import time
import numpy as np

start = time.time()
limit_time = 1.8


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

c_num = np.array(c)
s_num = np.array(s)



def point(t):
    result = 0
    map = {
        0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0,
        10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0,
        20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0
    }
    for i in range(d):
        comp = t[i] - 1
        day = i + 1
        map[comp] = day
        
        result = result + s[i][comp]
        for cc in range(26):
            result = result - c[cc] * (day - map[cc])
    return result

t = np.argmax(s_num, axis=1) + 1


p = point(t)












while time.time() - start < limit_time:
    new_d = math.floor(d * random.random())
    old_t = t[new_d]
    t[new_d] = math.floor(26 * random.random()) + 1
    new_p = point(t)
    if p < new_p:
        p = new_p
    else:
        t[new_d] = old_t

print("\n".join([str(i) for i in t]))

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])