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
from typing import Iterable, Tuple, Union

Shape = Union[int, Tuple[int], Iterable[int]]
Indices = Union[int, Tuple[int]]

class nd (object):
	getter = (
		lambda a, i: a,
		lambda a, i: a[i[0]],
		lambda a, i: a[i[0]][i[1]],
		lambda a, i: a[i[0]][i[1]][i[2]],
		lambda a, i: a[i[0]][i[1]][i[2]][i[3]],
		lambda a, i: a[i[0]][i[1]][i[2]][i[3]][i[4]],
		lambda a, i: a[i[0]][i[1]][i[2]][i[3]][i[4]][i[5]],
	)
	class _setter (object):
		def __getitem__(self, n : int):
			setter_getter = nd.getter[n-1]
			def setter(a, i, v):
				setter_getter(a, i[:-1])[i[-1]] = v
			return setter
	setter = _setter()
	initializer = (
		lambda s, v: [v] * s,
		lambda s, v: [v] * s[0],
		lambda s, v: [[v] * s[1] for _ in range(s[0])],
		lambda s, v: [[[v] * s[2] for _ in range(s[1])] for _ in range(s[0])],
		lambda s, v: [[[[v] * s[3] for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],
		lambda s, v: [[[[[v] * s[4] for _ in range(s[3])] for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],
		lambda s, v: [[[[[[v] * s[5] for _ in range(s[4])] for _ in range(s[3])] for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],
	)
	func_initializer = (
		lambda s, f: [f() for _ in range(s)],
		lambda s, f: [f() for _ in range(s[0])],
		lambda s, f: [[f() for _ in range(s[1])] for _ in range(s[0])],
		lambda s, f: [[[f() for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],
		lambda s, f: [[[[f() for _ in range(s[3])] for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],
		lambda s, f: [[[[[f() for _ in range(s[4])] for _ in range(s[3])] for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],
		lambda s, f: [[[[[[f() for _ in range(s[5])] for _ in range(s[4])] for _ in range(s[3])] for _ in range(s[2])] for _ in range(s[1])] for _ in range(s[0])],
	)
	shape_getter = (
		lambda a: len(a),
		lambda a: (len(a),),
		lambda a: (len(a), len(a[0])),
		lambda a: (len(a), len(a[0]), len(a[0][0])),
		lambda a: (len(a), len(a[0]), len(a[0][0]), len(a[0][0][0])),
		lambda a: (len(a), len(a[0]), len(a[0][0]), len(a[0][0][0]), len(a[0][0][0][0])),
		lambda a: (len(a), len(a[0]), len(a[0][0]), len(a[0][0][0]), len(a[0][0][0][0]), len(a[0][0][0][0][0])),
	)
	indices_iterator = (
		lambda s: iter(range(s)),
		lambda s: ((i,) for i in range(s[0])),
		lambda s: ((i, j) for j in range(s[1]) for i in range(s[0])),
		lambda s: ((i, j, k) for k in range(s[2]) for j in range(s[1]) for i in range(s[0])),
		lambda s: ((i, j, k, l) for l in range(s[3]) for k in range(s[2]) for j in range(s[1]) for i in range(s[0])),
		lambda s: ((i, j, k, l, m) for m in range(s[4]) for l in range(s[3]) for k in range(s[2]) for j in range(s[1]) for i in range(s[0])),
		lambda s: ((i, j, k, l, m, n) for n in range(s[5]) for m in range(s[4]) for l in range(s[3]) for k in range(s[2]) for j in range(s[1]) for i in range(s[0])),
	)
	iterable_product = (
		lambda s: iter(s),
		lambda s: ((i,) for i in s[0]),
		lambda s: ((i, j) for j in s[1] for i in s[0]),
		lambda s: ((i, j, k) for k in s[2] for j in s[1] for i in s[0]),
		lambda s: ((i, j, k, l) for l in s[3] for k in s[2] for j in s[1] for i in s[0]),
		lambda s: ((i, j, k, l, m) for m in s[4] for l in s[3] for k in s[2] for j in s[1] for i in s[0]),
		lambda s: ((i, j, k, l, m, n) for n in s[5] for m in s[4] for l in s[3] for k in s[2] for j in s[1] for i in s[0]),
	)
	flattener = (
		lambda a: iter(a),
		lambda a: iter(a),
		lambda a: (y for z in a for y in z),
		lambda a: (x for z in a for y in z for x in y),
		lambda a: (w for z in a for y in z for x in y for w in x),
		lambda a: (v for z in a for y in z for x in y for w in x for v in w),
		lambda a: (u for z in a for y in z for x in y for w in x for v in w for u in v),
	)

	@classmethod
	def full(cls, fill_value, shape : Shape):
		if isinstance(shape, int):
			return cls.initializer[0](shape, fill_value)
		elif not isinstance(shape, tuple):
			shape = tuple(shape)
		return cls.initializer[len(shape)](shape, fill_value)
	@classmethod
	def nones(cls, shape : Shape):
		return cls.full(None, shape)
	@classmethod
	def zeros(cls, shape : Shape, type=int):
		return cls.full(type(0), shape)
	@classmethod
	def ones(cls, shape : Shape, type=int):
		return cls.full(type(1), shape)

	@classmethod
	def fromiter(cls, iterable : Iterable, ndim=1):
		if ndim == 1:
			return list(iterable)
		else:
			return list(map(cls.fromiter, iterable))

	class _range (object):
		def __getitem__(self, shape : Union[int, slice, Tuple[Union[int, slice]]]):
			if isinstance(shape, int):
				return iter(range(shape))
			elif isinstance(shape, slice):
				return iter(range(shape.stop)[shape])
			else:
				shape = tuple(range(s.stop)[s] for s in shape)
				return nd.iterable_product[len(shape)](shape)
		def __call__(self, shape : Union[int, slice, Tuple[Union[int, slice]]]):
			return self[shape]
	range = _range()

	@classmethod
	def ensure_shape_tuple(cls, shape : Shape):
		if isinstance(shape, int):
			return shape,
		elif not isinstance(shape, tuple):
			return tuple(shape)
		else:
			return shape
	@classmethod
	def ensure_indices_tuple(cls, indices : Indices):
		if isinstance(indices, int):
			return indices,
		else:
			return indices
	@classmethod
	def join_shapes(cls, *shapes : Shape):
		return tuple(map(cls.ensure_shape_tuple, shapes))

def bytes_to_str(x : bytes):
	return x.decode('utf-8')

def inputs(func=bytes_to_str, sep=None, maxsplit=-1):
	return map(func, sys.stdin.buffer.readline().split(sep=sep, maxsplit=maxsplit))

def inputs_1d(func=bytes_to_str, **kwargs):
	return nd.fromiter(inputs(func, **kwargs))

def inputs_2d(nrows : int, func=bytes_to_str, **kwargs):
	return nd.fromiter(
		(inputs(func, **kwargs) for _ in range(nrows)),
		ndim=2
	)

def inputs_2d_T(nrows : int, func=bytes_to_str, **kwargs):
	return nd.fromiter(
		zip(*(inputs(func, **kwargs) for _ in range(nrows))),
		ndim=2
	)

N = 26
D, = inputs(int)
C = inputs_1d(int)
S = inputs_2d(D, int)

last_contest_date = nd.zeros(N)
satisfaction_levels = nd.zeros(N)

def arith_series(n, a0=0, d=1):
    return n * (2 * a0 + (n + 1) * d) // 2

for d in range(D):
    for i in range(N):
        satisfaction_levels[i] = S[d][i] - C[i] * (
            arith_series(D - last_contest_date[i]) - arith_series(d - last_contest_date[i])
        )
    held_contest = satisfaction_levels.index(min(satisfaction_levels))
    last_contest_date[held_contest] = d + 1
    print(held_contest + 1)

Solution (Python):
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(D)]
ld=[0]*26
ans=0
for d in range(D):
    sa=-10**10
    for i in range(26):
        ta=s[d][i]
        td=ld[:]
        td[i]=d+1
        for j in range(26):
            ta-=(d+1-ld[j])*c[j]
        if sa<=ta:
            sa=ta
            idx=i+1
            ld=td[:]
    print(idx)

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

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

D = None
C = None
S = None

def cnt_score(t):
    global D, C, S
    score = 0
    cnt = [-1] * 26

    for i in range(D):
        score += S[i][t[i] - 1]
        minusscore = 0
        cnt[t[i] - 1] = i
        for j in range(26):
            minusscore += (i - cnt[j]) * C[j]
        score -= minusscore
    return score


def main():
    global D, C, S
    D = int(input())
    C = [int(x) for x in input().split()]
    S = [[int(x) for x in input().split()] for _ in range(D)]

    start = time.time()

    ans = []
    for s in S:
        ans.append(s.index(max(s)) + 1)

    
    while True:
        
        current = time.time()
        if current - start > 1.0:
            break

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

        if cnt_score(new_ans) > cnt_score(ans):
            ans = new_ans

    

    day = 0
    while True:
        
        current = time.time()
        if current - start > 1.8:
            break

        
        new_ans = copy.deepcopy(ans)
        old_score = cnt_score(ans)

        max_sore = old_score
        max_contest = ans[day]
        for i in range(26):
            new_ans[day] = i + 1
            new_score = cnt_score(new_ans)
            if new_score > old_score:
                max_contest = i + 1
                old_score = new_score
        ans[day] = max_contest

        
        day = (day + 1) % D

    for a in ans:
        print(a)



if __name__ == '__main__':
    main()

Solution (Python):
import sys
import random
d = int(sys.stdin.readline().rstrip())
list_c = list(map(int, sys.stdin.readline().rstrip().split()))
list_s = []
list_t = []
need = 0
for i in range(d):
  list_s.append(list(map(int, sys.stdin.readline().rstrip().split())))
for i in range(d):
  print(random.randint(1,26))

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

    for i in range(D):
        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)
resolve()

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 = []

for i in range(1, d + 1):
    cat = [0]
    for i2 in range(1, 27):
        cat2 = copy(ca)
        cat2[i2] = i
        cat.append(s[i][i2] + sum(c[i3] * (i - ca[i3]) for i3 in range(1, 27)))
    t = cat.index(max(cat))
    ca[t] = i
    print(t)

Solution (Python):
'''
Introduction to Heuristics Contest
A - AtCoder Contest Scheduling
'''

def main():
    
    D = int(input())

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

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

    ''' とりあえず順番にやってくだけ
    for i in range(D):
        tmp = i % 26 + 1
        print(tmp)
    '''

    ''' 満足度Siの最高を選ぶ、満足度低下するCは未考慮
    for i in range(D):
        high = S[i].index(max(S[i])) + 1
        print(high)
    '''

    
    last = [-1] * 26

    
    score = 0

    
    for d in range(D):
        vals = []
        for idx in range(26):
            satis = S[d][idx]
            last[idx] = d
            complain = 0
            for j in range(26):
                complain += C[j] * (d - last[j])
            vals.append(satis - complain)
        idx = vals.index(max(vals))
        last[idx] = d
        score += max(vals)
        print(idx+1)

main()

def intro_heuristics_b():
    
    D = int(input())

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

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

    
    T = [int(input()) for _ in range(D)]

    
    last = [-1] * 26

    
    val = 0
    for d in range(D):
        idx = T[d] - 1
        satis = S[d][idx]
        last[idx] = d
        complain = 0
        for j in range(26):
            complain += C[j] * (d - last[j])
        val += satis - complain
        print(val)

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


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

T = []

last = [-1] * 26
for d in range(D):
    mi = INF
    for i in range(26):
        tmp = C[i] * (d - last[i])
        if tmp < mi:
            t = i
            mi = tmp
    last[t] = d  
    T.append(t)



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

Solution (Python):
import random

def main():
    D = int(input())
    c_list = list(map(int, input().split()))
    s_list = [list(map(int, input().split())) for _ in range(D)]
    t_list = [random.randint(1,26) for _ in range(D)]

    basic_bad = sum(c_list)
    for m in range(10**4):
        d = random.randint(1,D)
        q = random.randint(1,26)

        pre_t = t_list[d-1]
        pre_res = 0

        t_list[d-1] = q
        res = 0
        
        bad = 0
        last_open = [0] * 26
        for i in range(D):
            t = t_list[i]
            res += s_list[i][t-1]

            
            
            
            
            bad += basic_bad - (i+1 - last_open[t-1]) * c_list[t-1]
            last_open[t-1] = i+1

            res -= bad
            
        if pre_res > res:
            res = pre_res
            t_list[d-1] = pre_t

    for t in t_list:
        print(t)

if __name__ == "__main__":
    main()

Solution (Python):
N = 26
D = int(input())
C = [int(i) for i in input().split()]

S = []
for i in range(D):
  s = [int(i) for i in input().split()]
  m = max(s)
  i = s.index(m)
  S.append(i+1)

for i in S:
  print(i)

Solution (Python):
d=int(input())
a=[0 for i in range(26)]
c=list(map(int,input().split()))
l=[]
for i in range(d):
    l.append(list(map(int,input().split())))
    
p=[0]
ans=[]
for i in range(1,d+1):
    
    k=[0 for i in range(26)]
    for t in range(26):
        a[t]=i
        for j in range(26):
            k[t]-=c[j]*(i-a[j])
    for j in range(26):
        k[j]+=l[i-1][j]
    
    ans.append(k.index(max(k))+1)

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

Solution (Python):
def examA():
    def calc_score(d,k):
        rep = C[k]*(d-used[k]) + S[d][k]
        return rep

    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(D)]
    ans = 0
    T = [-1]*D
    used = [0]*N

    for d in range(D):
        s = -inf
        t = -1
        for i in range(N):
            cur = calc_score(d,i)
            if cur>s:
                s = cur
                t = i

        T[d] = t

        ans += S[d][t]
        used[t] = d + 1
        for j in range(N):
            ans -= C[j] * (d + 1 - used[j])

    for t in T:
        print(t+1)
    return

def examB():
    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(D)]
    T = [I()for _ in range(D)]
    ans = [0]*D
    used = [0]*N
    for i,t in enumerate(T):
        ans[i] += ans[i-1]
        t -= 1
        ans[i] += S[i][t]
        used[t] = i+1
        for j in range(N):
            ans[i] -= C[j]*(i+1-used[j])
    for v in ans:
        print(v)
    return

def examC():
    def calc_start():
        rep = [0] * D
        used = [0] * N
        for i, t in enumerate(T):
            rep[i] += rep[i - 1]
            rep[i] += S[i][t]
            used[t] = i + 1
            for j in range(N):
                rep[i] -= C[j] * (i + 1 - used[j])
        return rep

    def search(d,k):
        l = 0; r = D
        for i in range(d+1,D):
            if T[i]==k:
                r = i
                break
        for i in range(0,d)[::-1]:
            if T[i]==k:
                l = i + 1
                break
        return l, r

    def calc_cost(d,k):
        return C[k]*(d+1)*d//2

    N = 26
    D = I()
    C = LI()
    S = [LI()for _ in range(D)]
    T = [I()-1 for _ in range(D)]

    ans = calc_start()[D-1]

    

    M = I()
    for i in range(M):
        
        d, q = LI()
        d -= 1; q -= 1
        old = deepcopy(T[d])
        T[d] = q
        

        old_l, old_r = search(d,old)
        new_l, new_r = search(d,q)

        
        

        change = S[d][q] - S[d][old] \
                 - (calc_cost(old_r - old_l, old) - calc_cost(d-old_l, old) - calc_cost(old_r-d - 1, old))\
                 + (calc_cost(new_r - new_l, q) - calc_cost(d - new_l, q) - calc_cost(new_r - d - 1, q))

        ans += change

        print(ans)

    return


from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
'''
import random

random.seed(1000)

D = 365
cs = [random.randrange(0, 101) for _ in range(26)]
ss = [[random.randrange(0, 20001) for _ in range(26)] for _ in range(D)]

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

width = 20

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

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

based_b()

Solution (Python):
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	return int(input())
def s(x): 
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
for i in range(d):
	s.append(l())
	s[-1] = [[s[-1][i]-c[i],i+1] for i in range(26)]
	s[-1].sort(reverse = True)
	print(s[-1][random.randrange(1,5)-1][1])

Solution (Python):

def choose(D, c, s, d, last, depth, p):
    maxpoint = -999999
    maxnum = 0
    if depth > 0 and d < D:
        for i in range(26):
            point = p
            point += s[d][i]
            point += changepoint(c, d, i, last)
            nlast = last
            nlast[i] = d
            z, point = choose(D, c, s, d+1, nlast, depth-1, point)
            if point > maxpoint:
                maxpoint = point
                maxnum = i
        return maxnum, maxpoint
    return 0, p


def changepoint(c, d, num, last):
    point = 0
    for i in range(26):
        if i == num:
            continue
        point -= c[i]*(d-last[i])
    return point


def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = []
    last = [-1]*26
    for _ in range(D):
        s.append(list(map(int, input().split())))
    point = 0
    for i in range(D):
        num, point = choose(D, c, s, i, last, 2, point)
        print(num+1)


main()

Solution (Python):
import random

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

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

    last = [0]*26
    ans = []
    for d in range(D):
        score = -100*365*365
        t = 0
        for i in range(26):
            tmp = S[d][i]
            for j in range(26):
                if i != j:
                    tmp -= C[j]*(d + 1 - last[j])
            if tmp > score:
                score = tmp
                t = i + 1
        last[t - 1] = d + 1
        ans.append(t)
    score = calc_score(D, C, S, ans)
    for i in range(10**3):
        d = random.randint(0, D - 1)
        t = random.randint(1, 26)
        org_t = ans[d]
        ans[d] = t
        s = calc_score(D, C, S, ans)
        if s <= score:
            ans[d] = org_t
        else:
            score = s
    print('\n'.join(map(str, ans)))

if __name__ == '__main__':
    main()

Solution (Python):
import random
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = 0
a = []
last = [0]*26
for i in range(1,d+1):
    res = -float("inf")
    index = 0
    for k in range(26):
        x = k
        tnplast = last
        tnplast[x] = i
        tnp = 0
        tnp += s[i-1][x]
        for j in range(26):
            tnp -= c[j]*(i-last[j])
        if (tnp > res):
            res = tnp
            index = k+1
    ans += res
    a.append(index)

def rec(t):
    r = 0
    l = [0]*26
    for i in range(1,d+1):
        x = t[i-1]-1
        l[x] = i
        r += s[i-1][x]
        for j in range(26):
            r -= c[j]*(i-l[j])
    return r
    
for i in range(1000):
    x = random.randrange(1,d+1)
    y = random.randrange(1,27)
    t = a
    t[x-1] = y
    A = rec(t)
    if (ans < A):
        a = t
        ans = A

print(*a ,sep="\n")

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

def dec(day):
    ans = 0
    for i in range(26):
        ans += c[i]*(day-ld2[i])
    return ans

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

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

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


def read():
    D = int(input().strip())
    C = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    S = np.empty((D, 26), dtype=np.int32)
    for i in range(D):
        s = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
        S[i, :] = s[:]
    return D, C, S


@njit
def satisfaction(d, C, S, t, last):
    v = 0
    v += S[d, t]
    v += C[t] * ((d+1) - last[t])
    for i in range(26):
        v -= C[i] * ((d+1) - last[i])
    return v


@njit
def solve(D, C, S):
    last = np.zeros(26, dtype=np.int32)
    cumsat = 0
    for i in range(D):
        maxt = 0
        maxsat = -999999999
        for t in range(26):
            sat = satisfaction(i, C, S, t, last)
            if maxsat < sat:
                maxt = t
                maxsat = sat
        last[maxt] = i+1
        cumsat += sat
        print(maxt + 1)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    d = int(ipt())
    c = [int(i) for i in ipt().split()]
    s = [[int(i) for i in ipt().split()] for _ in range(d)]
    ld = [-1]*26
    edval = [0]*26

    for i in range(d):
        edval = s[i]*1
        for j in range(26):
            dl = i-ld[j]
            edval[j] += c[j]*dl*(dl+1)/200
        v = edval.index(max(edval))
        ld[v] = i
        print(v+1)

    return

if __name__ == '__main__':
    main()

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


lastday=[lastday[i]+1 for i in range(26)]
minus=[x*y for (x,y) in zip(c,lastday)]
firstday=minus.index(max(minus))
lastday[firstday]=0
t[0]=firstday+1

for days in range(1,D):
    temp=[x*y for (x,y) in zip(c,lastday)]
    today=temp.index(max(temp))
    lastday=[lastday[i]+1 for i in range(26)]
    lastday[today]=0
    t[days]=today+1

for ts in t:
    print(ts)

Solution (Python):
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
for num in range(D):
  print(t[num])