Buggy python submission (verdict: Time Limit Exceeded):


D = int(input())
C = list(map(int, input().split()))
S = []
N = 26
for d in range(D):
    S += [list(map(int, input().split()))]
#print(C)
#print(S)
myans = [d%N for d in range(D)]
print(myans)

def estimate(mylist):
    mycost = 0
    dayflag = [0 for n in range(N)]
    for d in range(1,D+1):
        mycontest = mylist[d-1]
        mycost += S[d-1][mycontest]
        dayflag[mycontest] = d
        #print(mycontest, d, dayflag)
        for i in range(26):
             mycost -= C[mycontest] * (d - dayflag[i])
    return mycost

import random
import copy
times = 10**4
bestcost = 0
random.seed(1)
for i in range(times):
    a = random.randrange(D)
    b = random.randrange(D)
    mylist = copy.deepcopy(myans)
    #print(a,b, mylist)
    mylist[a] = myans[b]
    mylist[b] = myans[a]
    #print(mylist)
    #estimate
    mycost = estimate(mylist)
    if  bestcost < mycost:
        bestcost = mycost
        myans = mylist
        #print(i, bestcost)
for d in range(N):
    print(myans[d]+1)

Fixed submission:
D = int(input())
C = list(map(int, input().split()))
S = []
N = 26
for d in range(D):
    S += [list(map(int, input().split()))]
#print(C)
#print(S)
myans = [d%N for d in range(D)]
for d in range(D):
  print(myans[d]+1)

Buggy python submission (verdict: Runtime Error):
D = int(input())
C = list(map(int, input().split()))
S = []
for d in range(D):
    S += [list(map(int, input().split()))]
#print(C)
#print(S)
myans = [i for i in range(26)]
#print(myans)

def estimate(mylist):
    mycost = 0
    dayflag = [0 for n in range(26)]
    for d in range(1,D+1):
        mycontest = mylist[d-1]
        mycost += S[d-1][mycontest]
        dayflag[mycontest] = d
        #print(mycontest, d, dayflag)
        for i in range(26):
             mycost -= C[mycontest] * (d - dayflag[i])
    return mycost

import random
import copy
times = 10**4
bestcost = 0
random.seed(1)
for i in range(times):
    a = random.randrange(26)
    b = random.randrange(26)
    mylist = copy.deepcopy(myans)
    #print(a,b, mylist)
    mylist[a] = myans[b]
    mylist[b] = myans[a]
    #print(mylist)
    #estimate
    mycost = estimate(mylist)
    if  bestcost < mycost:
        bestcost = mycost
        myans = mylist
        #print(i, bestcost)
for d in range(D):
    print(myans[d]+1)

Fixed submission:
D = int(input())
C = list(map(int, input().split()))
S = []
N = 26
for d in range(D):
    S += [list(map(int, input().split()))]
#print(C)
#print(S)
myans = [d%N for d in range(D)]
for d in range(D):
  print(myans[d]+1)

Buggy python submission (verdict: Runtime Error):


D = int(input())
C = list(map(int, input().split()))
S = []
for d in range(D):
    S += [list(map(int, input().split()))]
#print(C)
#print(S)
myans = [i for i in range(26)]
#print(myans)

def estimate(mylist):
    mycost = 0
    dayflag = [0 for n in range(26)]
    for d in range(1,D+1):
        mycontest = mylist[d-1]
        mycost += S[d-1][mycontest]
        dayflag[mycontest] = d
        #print(mycontest, d, dayflag)
        for i in range(26):
             mycost -= C[mycontest] * (d - dayflag[i])
    return mycost

import random
import copy
times = 10**4
bestcost = 0
random.seed(1)
for i in range(times):
    a = random.randrange(26)
    b = random.randrange(26)
    mylist = copy.deepcopy(myans)
    #print(a,b, mylist)
    mylist[a] = myans[b]
    mylist[b] = myans[a]
    #print(mylist)
    #estimate
    mycost = estimate(mylist)
    if  bestcost < mycost:
        bestcost = mycost
        myans = mylist
        #print(i, bestcost)
for d in range(D):
    print(myans[d])

Fixed submission:
D = int(input())
C = list(map(int, input().split()))
S = []
N = 26
for d in range(D):
    S += [list(map(int, input().split()))]
#print(C)
#print(S)
myans = [d%N for d in range(D)]
for d in range(D):
  print(myans[d]+1)