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
input = sys.stdin.readline

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

sumC = sum(C)
def score(strategy):
    sat = 0
    last = [0]*26
    for i,ind in enumerate(strategy):
        last = [l+1 for l in last]
        last[ind] = 0
        sat -= sum((c*l for c,l in zip(C,last)))
        sat += S[i][ind]
    return sat


first = [i % 26 for i in range(D)]

ans = first
now_score = score(ans)

for i in range(15):
    
    for d in range(D):
        temp = ans[:]
        temp[d] = S[d].index(max(S[d]))
        
        new_score = score(temp)
        if new_score > now_score:
            now_score = new_score
            ans = temp

for a in ans:
    print(a+1)

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

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

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

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

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



D = int(readline())
C = list(map(int,readline().split())) 
S = [None] * D
sortS = [None] * D
for i in range(D):
  s = list(map(int,readline().split()))
  S[i] = s.copy()
  for j in range(len(s)):
    s[j] = (s[j],j)
  sortS[i] = sorted(s, key = lambda x:x[0], reverse = True)

def make_ans(D,C,limiter = 52, threshold = 42, balance = 0.8):
  ans = []
  last_submit = [0] * 26
  for i in range(D):
    info = sortS[i]
    
    
    if i - min(last_submit) >= limiter:
      ind = -1
      for j in range(len(last_submit)):
        if i - last_submit[j] >= threshold:
          if ind == -1:
            ind = j
          else:
            if C[ind] < C[j]:
              ind = j
      ans += [ind]
      last_submit[ind] = i
      continue
      
    topval = info[0][0]
    for j in range(len(info)):
      val = info[j][0]
      if val < topval * (balance):
        continue 
      index = info[j][1]
      if i - last_submit[index] < 26:
        continue
      ans += [index]
      last_submit[index] = i
      break
    else:
      ans += [info[0][1]]
  return ans

def calc_score(arr):
  point = 0
  last_submit = [0] * 26
  for i in range(len(arr)):
    
    point += S[i][arr[i]]
    for j in range(len(last_submit)):
      point -= (i - last_submit[j]) * C[j]
  return point
      
ans = make_ans(D,C)

from collections import defaultdict




best = calc_score(ans)
for limiter in range(40,62):
  for threshold in range(36, limiter):
    for balance in (0.75,0.8,0.85):
      new_ans = make_ans(D,C,limiter,threshold,balance)
      new_score = calc_score(new_ans)
      if new_score > best:
        ans = new_ans
        best = new_score
        



  
def show(arr):
  for a in arr:
    print(a + 1)





show(ans)

Solution (Python):
D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
  s.append(list(map(int,input().split())))
sum_c=sum(c)
for i in range(D):
  max_s=0
  for j in range(26):
    hantei=s[i][j]-sum_c+c[j]
    if hantei>max_s:
      max_s=hantei
      index=j
  print(index+1)

Solution (Python):

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

sys.setrecursionlimit(1000000)
mod = 1000000007

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

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 1000
    sum_ = sum(c)
    q = [(0, 0, [0]*n, sum_)]
    pre = [[None]*n for i in range(d)]
    sc = [[float("inf")]*n for i in range(d)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, x, last, minus = heappop(q)
            if i > 0 and v > sc[i-1][x]:
                continue
            for ti in range(n):
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                heappush(nq,(nv,ti,nl,nm))
                if sc[i][ti] > nv:
                    sc[i][ti] = nv
                    pre[i][ti] = x
        q = [i for i in nq]
    t = []
    argmax = 0
    m = sc[-1][0]
    for i in range(1,n):
        sci = sc[-1][i]
        if m > sci:
            m = sci
            argmax = i
    t.append(argmax)
    x = argmax
    for i in range(1,d)[::-1]:
        y = pre[i][x]
        t.append(y)
        x = y
    t = [i+1 for i in t[::-1]]
    v = score(t)
    for i in t:
        print(i)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
d = int(input())
c = list(map(int,input().split()))
ans = []
pen = [0]*26
for i in range(d):
    s = list(map(int,input().split()))
    for i in range(26):
        pen[i] += c[i]
        s[i] += pen[i]
    ans += [s.index(max(s))+1]
for i in ans:
    print(i)

Solution (Python):
import copy
import time
t1 = time.time()

def calc(T):
    res = 0
    L = [0]*26
    for i in range(D):
        res += S[i][T[i]-1]
        L[T[i]-1] = i+1
        for j in range(26):
            res -= C[j]*(i+1-L[j])
    return res

D = int(input())
C = [int(c) for c in input().split()]
S = [[int(s) for s in input().split()] for _ in range(D)]

T = [0]*D
for i in range(D):
    temp = -1
    for j in range(26):
        if temp < S[i][j]:
            temp = S[i][j]
            idx = j+1
    T[i] = idx

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

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

import random
while time.time()-t1 < 1.2:
    i = random.randint(0, D-1)
    for j in range(26):
        temp = copy.deepcopy(T)
        temp[i] = j+1
        newp = calc(temp)
        if p < newp:
            T[i] = j+1
            p = newp

i = 0
next = 1
while time.time()-t1 < 1.9:
    for j in range(26):
        temp = copy.deepcopy(T)
        temp[i] = j+1
        newp = calc(temp)
        if p < newp:
            T[i] = j+1
            p = newp
    i += next
    if i == -1:
        i = 1
        next = 1
    elif i == D:
        i = D-2
        next = -1

for t in T:
    print(t)

Solution (Python):
import random

def main():
    D = int(input())
    c_list = list(map(int, input().split()))
    s_list = [list(map(int, input().split())) for _ in range(D)]
    
    basic_bad = sum(c_list)

    
    res = 0
    bad = 0
    last_open = [0] * 26
    t_list = [0] * D
    for i in range(D):
        
        t = 0
        max_val = s_list[i][0] - (basic_bad - (i+1 - last_open[0]) * c_list[0])
        
        for d in range(1,26):
            val = s_list[i][d] - (basic_bad - (i+1 - last_open[d]) * c_list[d])
            if val >= max_val:
                t = d

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

        res -= bad

    init_res = res

    
    for m in range(10**5):
        d = random.randint(1,D)
        q = random.randint(0,25)

        pre_t = t_list[d-1]
        pre_res = init_res

        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]
            bad += basic_bad - (i+1 - last_open[t]) * c_list[t]
            last_open[t] = i+1

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

    
    for t in t_list:
        print(t+1)

if __name__ == "__main__":
    main()

Solution (Python):
import random

D = int(input())
c_list = list(map(int,input().split(' ')))
s_list = []
for i in range(D):
    s_list.append(list(map(int,input().split(' '))))
for day in range(D):
    print(random.randrange(26)+1)

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

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

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

for t in T:
  print(t)

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

    sorted_scores = []
    for i in range(D):
        scores = [(j, S[i][j]) for j in range(26)]
        sorted_scores.append(sorted(scores, key=lambda x: x[1], reverse=True))
    
    sorted_c = []
    sorted_c = [(i, C[i]) for i in range(26)]
    sorted_c.sort(key=lambda x: x[1], reverse=True)
    
    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)//2):
        d = random.randint(0, D - 1)
        t = random.randint(0, 12)
        org_t = ans[d]
        ans[d] = sorted_c[t][0] + 1
        s = calc_score(D, C, S, ans)
        if s <= score:
            ans[d] = org_t
        else:
            score = s

    
    for i in range((10**3)//2):
        d = random.randint(0, D - 1)
        t = random.randint(0, 12)
        org_t = ans[d]
        ans[d] = sorted_scores[d][t][0] + 1
        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 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):
import copy
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
A = [[0 for i in range(26)]]
B1 = []
B2 = []
AA = []
ans = 0
for i in range(D):
  K = []
  for k in range(26):
    c = 0
    for j in range(26):
      if j != k:
        c += C[j] * (i+1-A[-1][j])
    an = S[i][k]-c
    K.append([an, k+1])
  K.sort()
  a = K[-1][1]
  B = copy.copy(A[-1])
  B[a-1] = i+1
  A.append(B)
  ans += K[-1][0]
  AA.append(ans)
  B1.append(a)
  B2.append(K[-2][1])

A = [0 for i in range(26)]
ans = 0
b, B1[-2] = B1[-2], B2[-2]
for i in range(D):
  k = B1[i] - 1
  c = 0
  for j in range(26):
    if j != k:
      c += C[j] * (i+1-A[j])
    an = S[i][k]-c
  ans += an
if ans < AA[-1]:
  B1[-2] = b
for i in range(D):
  print(B1[i])

Solution (Python):
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(now, ContestType):
  res = c[ContestType] * (now - LastDay[ContestType])
  return res

def nasu(now, x, y, z):
  res = 0
  res += s[now-1][x]
  res += s[now][y]
  res += s[now+1][z]
  if x == y == z:
    res += (D - now) * ((now - LastDay[x]) * c[x])
    now += 1
    res += (D - now) * (1 * c[y])
    now += 1
    res += (D - now) * (1 * c[z])
  elif x == y:
    res += (D - now) * ((now - LastDay[x]) * c[x])
    now += 1
    res += (D - now) * (1 * c[y])
    now += 1
    res += (D - now) * ((now - LastDay[z]) * c[z])
  elif y == z:
    res += (D - now) * ((now - LastDay[x]) * c[x])
    now += 1
    res += (D - now) * ((now - LastDay[y]) * c[y])
    now += 1
    res += (D - now) * (1 * c[z])
  elif x == z:
    res += (D - now) * ((now - LastDay[x]) * c[x])
    now += 1
    res += (D - now) * ((now - LastDay[y]) * c[y])
    now += 1
    res += (D - now) * (2 * c[z])
  else:
    res += (D - now) * ((now - LastDay[x]) * c[x])
    now += 1
    res += (D - now) * ((now - LastDay[y]) * c[y])
    now += 1
    res += (D - now) * ((now - LastDay[z]) * c[z])
  return res

D = I()
c = IL()
s = [IL() for i in range(D)]

LastDay = [0]*26
for i in range(1,D+1-2):
  tmp = ["", 0]
  for x in range(26):
    for y in range(26):
      for z in range(26):
        score = nasu(i, x, y, z)
        if tmp[1] < score:
          tmp = [(x, y, z), score]
  LastDay[tmp[0][0]] = i
  print(tmp[0][0]+1)
else:
  print(tmp[0][1]+1)
  print(tmp[0][2]+1)

Solution (Python):
import numpy as np

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


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


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

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

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

    return t


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

Solution (Python):
import sys
def input():
    return sys.stdin.readline()
def scoring(ans, d, t, C, S, L, replace = False):
    ans += S[d][t]
    penalty = sum([c * (d - l) for i, (c, l) in enumerate(zip(C, L)) if i != t])
    ans -= penalty
    if replace:
        return ans, [l if i != t else d for i, l in enumerate(L) ], penalty
    else:
        return ans
def scoring_2(ans, d, t, C, S, L, replace = False):
    ans += S[d][t]
    ans -= sum([c * pow(d - l, 2) for i, (c, l) in enumerate(zip(C, L)) if i != t])
    return ans

def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]
    L = [-1] * 26
    ans = 0
    for d in range(D):
        SCORE = [scoring_2(ans, d, t, C, S, L) for t in range(26)]
        t_max = SCORE.index(max(SCORE))
        ans, L, p = scoring(ans, d, t_max, C, S, L, replace = True)
        print(t_max + 1)
        
if __name__ == '__main__':
    main()