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

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

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

for r in Ret:
    print(r)

Solution (Python):
d = int(input())
c = list(map(int,input().split()))
s = []
p = [1]*d
for i in range(d):
    s.append(list(map(int,input().split())))
x = [1]*26
for i in range(d):
    q = 1
    m = -1
    for j in range(26):
        n = s[i][j] + (x[j]**2 + x[j])*c[j]
        x[j] += 1
        if(m < n):
            m = n
            q = j
    x[q] *= 0
    p[i] = q+1
for i in range(d):
    print(p[i])

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

Solution (Python):
import time
start = time.time()

import random
from collections import defaultdict


def get_score(day, contest, prev_list, loss_list, satisfied_matrix):
    plus = satisfied_matrix[day][contest]
    minus = 0
    for type, prev in enumerate(prev_list):
        if type == contest:
            continue
        spend = day - prev
        minus += loss_list[type] * spend

    return plus - minus


def calc_score_by_contest(contest, contest_schedule, loss_base, satisfied_matrix):
    plus = 0
    minus = 0
    for day in contest_schedule:
        plus += satisfied_matrix[day][contest]

    diff = [0] + contest_schedule[:-1]
    loss_base = loss_list[contest]
    for prev, open in zip(diff, contest_schedule):
        spend = open - prev
        loss = loss_base * spend * (spend + 1) // 2
        minus += loss

    return plus - minus


def update(day, old, new, loss_list, satisfied_matrix):
    if old == new:
        return None


def schedule_to_dict(schedule):
    dict = defaultdict(list)
    for day, contest in enumerate(schedule):
        dict[contest].append(day)

    for contest in range(26):
        dict[contest].append(364)

    return dict


def calc_score(schedule, loss_list, satisfied_matrix):
    schedule_dict = schedule_to_dict(schedule)
    plus = 0
    minus = 0
    for contest in range(26):
        day_list = schedule_dict[contest]
        for day in day_list:
            plus += satisfied_matrix[day][contest]

        diff = [0] + day_list[:-1]
        loss_base = loss_list[contest]
        for prev, open in zip(diff, day_list):
            spend = open - prev
            loss = loss_base * spend * (spend+1) // 2
            minus += loss

    return plus - minus


days = int(input())
loss_list = list(map(int, input().split()))
satisfied_matrix = [list(map(int, input().split())) for _ in range(days)]

ans = [random.randint(0, 25) for _ in range(days)]
prev = calc_score(ans, loss_list, satisfied_matrix)

while time.time() - start < 1.7:
    index = random.randint(0, 25)
    for num in range(8):
        old_contest = ans[index]
        new_contest = random.randint(0, 25)
        if old_contest == new_contest:
            continue

        ans[index] = new_contest
        new_score = calc_score(ans, loss_list, satisfied_matrix)
        if new_score < prev:
            ans[index] = old_contest
        else:
            break


for contest in ans:
    print(contest + 1)

Solution (Python):
def a_atcoder_contest_scheduling(CONTEST=26):
    D = int(input())
    Satisfaction_decreasing = [int(i) for i in input().split()]
    Satisfaction_difference = [[int(i) for i in input().split()] for j in range(D)]

    
    
    ans = []
    last = {i: 0 for i in range(1, CONTEST + 1)}
    for day in range(1, D + 1):
        max_decreasing = -1
        max_contest_type = -1
        for type, d in last.items():
            decreasing = Satisfaction_decreasing[type - 1] * (day - last[type])
            if decreasing > max_decreasing:
                max_decreasing = decreasing
                max_contest_type = type

        last[max_contest_type] = day
        ans.append(max_contest_type)
    return '\n'.join(map(str, ans))

print(a_atcoder_contest_scheduling())

Solution (Python):


import sys
import time


import random                                
from random import randint









def main():
    sys.setrecursionlimit(10**6)    
    inf = 10**15
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    
    
    def calc_total_score(schedule):
        ans = []
        last = [-1] * 26
        satisfy = 0
        for day in range(D):
            contest_id = schedule[day]
            last[contest_id] = day
            satisfy += score[day][contest_id]
            for i in range(26):
                satisfy -= c[i] * (day - last[i])
            ans.append(satisfy)
        return ans
    

    def change_contest(schedule, target_day, new_contest):
        
        prev_contest = schedule[target_day]
        diff = 0
        diff += (score[target_day][new_contest] - score[target_day][prev_contest])
        i = target_day - 1
        while i >= 0:
            if schedule[i] == prev_contest:
                break
            i -= 1
        j = target_day + 1
        while j <= len(schedule) - 1:
            if schedule[j] == prev_contest:
                break
            j += 1
        diff -= (j - target_day) * (target_day - i) * c[prev_contest]
        i = target_day - 1
        while i >= 0:
            if schedule[i] == new_contest:
                break
            i -= 1
        j = target_day + 1
        while j <= len(schedule) - 1:
            if schedule[j] == new_contest:
                break
            j += 1
        diff += (j - target_day) * (target_day - i) * c[new_contest]
        schedule[target_day] = new_contest
        return diff
    

    def build_greedy_schedule():
        schedule = []
        last = [-1] * 26
        for day in range(D):
            decided = None
            best_diff = -inf
            for contest in range(26):
                tmp = 0
                tmp += score[day][contest]
                for i in range(26):
                    if i != contest:
                        tmp -= c[i] * (day - last[i])
                if best_diff < tmp:
                    decided = contest
                    best_diff = tmp
            last[decided] = day
            schedule.append(decided)
        return schedule


    def solve():
        schedule = build_greedy_schedule()
        satisfy = calc_total_score(schedule)[-1]
        while True:
            if time.time() - start >= deadline:
                break
            
            target_day = randint(0, D-1)
            while True:
                new_contest = randint(0, 25)
                if new_contest != schedule[target_day]:
                    break
            prev_contest = schedule[target_day]
            diff = change_contest(schedule, target_day, new_contest)
            if diff > bound:
                
                satisfy += diff
            elif diff > - bound and randint(0, 10)==0:
                
                satisfy += diff
            else:
                
                schedule[target_day] = prev_contest
        return schedule, satisfy



    
    start = time.time()
    deadline = 1.6
    D = ii()
    c = lmi()
    score = [lmi() for _ in range(D)]
    avg = sum([sum(line) for line in score]) / (D * 26)
    bound = avg/100

    final_schedule, final_satisfy = solve()
    for contest in final_schedule:
        print(contest + 1)

    



if __name__ == "__main__":
    main()

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

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

c = 26



ans = 0
L = [[-1] * c for i in range(d)]
T = [-1] * d  
K = [[] for i in range(d)]  
pp = 4

for i in range(d):
    ANS = [0] * c
    L[i] = L[i-1][:]
    for k in range(c):
        ANS[k] = S[i][k] + C[k] * (i - L[i][k])
    ANSS = [[ANS[j], j] for j in range(c)]
    ANSS.sort(reverse=True)
    for j in range(pp):
        
        
        K[i].append(ANSS[j][1])
    ind = ANSS[0][1]
    ans += S[i][ind]
    L[i][ind] = i
    for j in range(c):
        ans -= C[j] * (i - L[i][j])
    
    
    T[i] = ind

fans = ans






















    
from random import randint

m = 10*10**5












ndd = -1
nq = -1

for i in range(m):
    
    
    dd = ndd if ndd != -1 else randint(0, d-1)
    q = nq if nq != -1 else K[dd][randint(0, len(K[dd])-1)]
    nans = ans
    
    nans -= S[dd][T[dd]]
    nans += S[dd][q]
    for j in range(dd, d):
        
        if T[j] == q:
            
            break
        nans += C[q] * (j - L[j][q])
        nans -= C[q] * (j - dd)
        L[j][q] = dd
    
    old = T[dd]
    T[dd] = q

    for j in range(dd, d):
        
        if T[j] == old:
            
            break
        oldl = L[j-1][old] if j > 0 else -1
        nans += C[old] * (j - dd)
        nans -= C[old] * (j - oldl)
        L[j][old] = oldl

    

    if nans < ans:
        if i != m-1:
            ndd = dd
            nq = old
        else:
            T[dd] = old
    else:
        ndd = -1
        nq = -1
    
    ans = nans


for i in T:
    print(i+1)

Solution (Python):
from time import time
from random import random

limit_secs = 2
start_time = time()

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

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

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

t = solution()
score = calc_score()
while time() - start_time + 0.14 < limit_secs:
    d = int(random() * D)
    q = int(random() * 26)
    old = t[d]
    t[d] = q
    new_score = calc_score()
    if new_score < score:
        t[d] = old
    else:
        score = new_score
print('\n'.join(str(e + 1) for e in 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 < 300:
  T = [0]*D
  for i in range(D):
    T[i] = random.randrange(1,26)

  lastdays = [0]*26
  newscore = calcscore(D)
  if oldscore > 0 and newscore > oldscore:
    oldscore = newscore
    break
  count += 1


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

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

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



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

Solution (Python):
from time import time
import random


def main():
    random.seed(2020)

    now = time()

    MAX = 26

    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]
    t = []
    for row in s:
        mxi = 1
        mx = 0
        for i, e in enumerate(row, 1):
            if e > mx:
                mx = e
                mxi = i

        t.append(mxi)

    last = [0] * MAX

    score = 0
    for day, e in enumerate(t, 1):
        score += s[day-1][e-1]
        last[e-1] = day

        for ec, elast in zip(c, last):
            score -= ec * (day - elast)

    d_li = []
    for i in range(1, d + 1):
        ln = max(1, (-(i - d // 2) ** 2 + d ** 2 // 4) // 500)
        d_li += [i] * ln

    di_max = len(d_li) - 1

    c_sum = sum(c)
    c_li = []
    for i, e in enumerate(c, 1):
        c_li += [i] * e

    while time() - now <= 1.85:
        prev_score = score

        di = random.randint(0, di_max)
        ed = d_li[di]
        qi = random.randint(0, c_sum - 1)
        eq = c_li[qi]

        q_old = t[ed-1]
        d_prev = {q_old: 0, eq: 0}

        c_old = c[q_old-1]
        c_new = c[eq-1]

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score += c_old * (day - d_prev[q_old])
            score += c_new * (day - d_prev[eq])

        score -= s[ed-1][q_old-1]
        score += s[ed-1][eq-1]

        t[ed-1] = eq

        d_prev = {q_old: 0, eq: 0}

        for day, e in enumerate(t, 1):
            if e in d_prev.keys():
                d_prev[e] = day

            score -= c_old * (day - d_prev[q_old])
            score -= c_new * (day - d_prev[eq])

        if prev_score > score:
            t[ed-1] = q_old
            score = prev_score

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


if __name__ == "__main__":
    main()

Solution (Python):
import math
import fractions



def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  
factinv = [1, 1]  
inv = [0, 1]  

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''









n = int(input())
c = list(map(int, input().split()))
a = []
for i in range(n):
    temp = list(map(int, input().split()))
    a.append(temp)

ans = [(i%26) for i in range(n)]

def cost(a,c,ans):
    val = 0
    last = [0 for i in range(26)]
    for i in range(n):
        for j in range(26):
            last += 1
        here = ans[i]
        val += a[i][here]
        last[here] = 0
        for j in range(26):
            val -= last[j]*c[j]
    return val


for i in range(n):
    maxim = -10**9
    idx = -1
    for j in range(26):
        if(maxim < a[i][j]):
            idx = j
            maxim = a[i][j]
    ans[i] = idx




for i in range(n):
    if(i//26%2==0):
        print(ans[i]+1)
    else:
        print(i%26+1)

Solution (Python):
import random
D = int(input())
c = list(map(int, input().split()))
last = [0] * 26
ans = []
S = []
prev_score = 0
maxsi_list = []

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

schedule = [i for i in range(D)]
for tt in range(31):
    random.shuffle(schedule)
    for dd in schedule:
        last = [0] * 26
        score = 0
        for d in range(1, D+1):
            if dd == (d-1):
                maxc = 0
                maxci = -1
                for i in range(26):
                    cost = c[i] * (d - last[i])
                    if maxc < cost:
                        maxc = cost
                        maxci = i+1
                prev_a = ans[dd]
                ans[dd] = maxci
            td = ans[d-1] - 1
            cumsump = 0
            for i in range(26):
                if td != i:
                    tmp = -c[i] * (d - last[i])
                    cumsump += tmp
            last[td] = d
            score += S[d-1][td]+cumsump
        
        if score <= best_score-mergin:
            ans[dd] = prev_a
        elif best_score < score:
            best_ans = ans
            best_score = score
            prev_score = score
        else:
            prev_score = score
    random.shuffle(schedule)
    for dd in schedule:
        last = [0] * 26
        score = 0
        prev_a = ans[dd]
        ans[dd] = maxsi_list[dd]
        for d in range(1, D+1):
            td = ans[d-1] - 1
            cumsump = 0
            for i in range(26):
                if td != i:
                    tmp = -c[i] * (d - last[i])
                    cumsump += tmp
            last[td] = d
            score += S[d-1][td]+cumsump
        
        if score <= best_score-mergin:
            ans[dd] = prev_a
        elif best_score < score:
            best_ans = ans
            best_score = score
            prev_score = score
        else:
            prev_score = score

for a in best_ans:
    print(a)

Solution (Python):
import numpy as np

D = int(input())

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

for d in range(D):
        exec('s{} = ([int(x) for x in input().split()])'.format(d))

d = 0
lday = np.array([0] * 26)
C = np.array(C)

while d != D:
    exec("curs = np.array(s{})".format(d))
    pos_max_i = np.argmax(curs)
    decl = C * ( np.array([d]*26 ) - lday )
    neg_min_i = np.argmin(decl)
    if np.abs(curs[pos_max_i]) > np.abs(decl[neg_min_i]):
        lday[pos_max_i] = d
        print(pos_max_i+1)
    else:
        lday[neg_min_i] = d
        print(neg_min_i+1)
    d += 1

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

for i in range(d):
    print(17)

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


for i in range(D):
    
    op = c.index(max(c))
    t.append(op+1)
    last[op].append(i)
    
    
    
    
    
    


from bisect import *
import random
m = 400000
def suminc(a,b):
    return b*(b-1)//2-a*(a-1)//2
while m:
    m-=1
    update = 0
    d = random.randint(1,D)
    q = random.randint(1,26)
    d-=1
    q-=1
    oq = t[d]-1
    update += s[d][q]-s[d][oq]
    idx = bisect_left(last[oq],d)
    if idx == len(last[oq])-1:
        cnt = D - last[oq][idx]
    else:
        cnt = last[oq][idx+1] - last[oq][idx]
    update += c[oq]*suminc(0,cnt)
    cntprv = last[oq][idx] - last[oq][idx-1]
    update -= c[oq]*suminc(cntprv,cntprv+cnt)

    idx2 = bisect_left(last[q],d)-1
    if idx2 == len(last[q])-1:
        cnt = D - d
    else:
        cnt = last[q][idx2+1] - d
    if idx2 == len(last[q])-1:
        cntprv = D - last[q][idx2] - cnt
    else:
        cntprv = last[q][idx2+1] - last[q][idx2] - cnt
    update += c[q]*suminc(cntprv,cntprv+cnt)
    update -= c[q]*suminc(0,cnt)

    if update > 0:
    
        del last[oq][idx]
        last[q].insert(idx2+1,d)
        
        t[d] = q+1





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

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])*(5+(D-d)//36)
        ans.append((ans_tmp,choice))
    _,case=max(ans)
    last[case-1]=d
    print(case)

Solution (Python):


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

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

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



ans = calc()

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

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

Solution (Python):
import random
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,x,y,ans):
    ans -= s[x-1][t[x-1]-1]
    ans += s[x-1][y-1]
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==t[x-1]):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==t[x-1]):
            mi = j
            break
    ans -= c[t[x-1]-1]*(x-mi)*(ma-x)
    ma = d+1
    mi = 0
    for j in range(x+1,d+1):
        if (t[j-1]==y):
            ma = j
            break
    for j in range(x-1,0,-1):
        if (t[j-1]==y):
            mi = j
            break
    ans += c[y-1]*(x-mi)*(ma-x)
    return ans
    
for i in range(180000):
    x = random.randrange(1,d+1)
    y = random.randrange(1,27)
    t = a
    A = rec(t,x,y,ans)
    if (ans < A):
        t[x-1] = y
        a = t
        ans = A

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

Solution (Python):
import random
D=int(input())
for i in range(D):
  print(random.randint(1,26))

Solution (Python):
from bisect import bisect_left, bisect_right
from random import randint

class Set(): 
    def __init__(self, valuelist, INF=10**18+1):
        self.n = len(valuelist) + 1
        self.value = sorted(valuelist) + [INF]
        self.comp = {v : k for k, v in enumerate(self.value, 1)}
        self.bit = BinaryIndexedTree(self.n)

    def insert(self, x, k=1):
        self.bit.add(self.comp[x], k)

    def delete(self, x, k=1):
        self.bit.add(self.comp[x], -k)

    def count(self, x):
        return self.bit.get(self.comp[x])

    def sum(self, x):
        return self.bit.sum(self.comp[x])

    def get(self, k): 
        return self.value[self.bit.bisect_left(k) - 1]

class BinaryIndexedTree(): 
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, idx):
        res = 0
        while idx:
            res += self.tree[idx]
            idx -= idx & -idx
        return res

    def get(self, idx):
        return self.sum(idx) - self.sum(idx - 1)

    def add(self, idx, x):
        while idx <= self.n:
            self.tree[idx] += x
            idx += idx & -idx

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        if res >= self.n:
            return self.n
        return res + 1

D = int(input())
C = tuple(map(int, input().split()))
S = [tuple(map(int, input().split())) for _ in range(D)]
'''
D = 365
C = [randint(0, 100) for _ in range(D)]
S = [[randint(0, 200000) for j in range(26)] for i in range(D)]
'''
res = 0
last = [0 for _ in range(26)]
T = [0 for _ in range(D)]
used = [Set(list(range(D))) for i in range(26)]

for d in range(D):
    maxtmp = -10**18
    for i in range(26):
        tmp = 0
        lasttmp = last[:]
        tmp += S[d][i]
        lasttmp[i] = d + 1
        for j in range(26):
            tmp -= C[j] * ((d + 1) - lasttmp[j])
        if maxtmp <= tmp:
            maxtmp = tmp
            contest = i
    res += S[d][contest]
    last[contest] = d + 1
    used[contest].insert(d)
    for j in range(26):
        res -= C[j] * ((d + 1) - last[j])
    T[d] = contest + 1

for i in range(10000):
    tmp = res
    d = randint(1, D - 1)
    q = randint(1, 25)
    if T[d - 1] == q:
        continue
    tmp -= S[d - 1][T[d - 1] - 1]
    tmp += S[d - 1][q - 1]
    k = used[T[d - 1] - 1].sum(d - 1)
    l = used[T[d - 1] - 1].get(k - 1) if k != 1 else -1
    r = used[T[d - 1] - 1].get(k + 1)
    if r == 1000000000000000001:
        r = D
    tmp -= (d - 1 - l) * C[T[d - 1] - 1] * (r - d + 1)
    used[T[d - 1] - 1].delete(d - 1)
    used[q - 1].insert(d - 1)
    k = used[q - 1].sum(d - 1)
    l = used[q - 1].get(k - 1) if k != 1 else -1
    r = used[q - 1].get(k + 1)
    if r == 1000000000000000001:
        r = D
    tmp += (d - 1 - l) * C[q - 1] * (r - d + 1)
    if tmp >= res:
        res = tmp
        T[d - 1] = q
    else:
        used[T[d - 1] - 1].insert(d - 1)
        used[q - 1].delete(d - 1)

for t in T:
    if t >= 27 or t <= 0:
        print('hoge')
        break
    print(t)