Buggy python submission (verdict: Runtime Error):
#A
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    D=int(readline())
    c=list(map(int,readline().split()))
    s=[list(map(int,readline().split())) for _ in range(D)]

    kaisai=[0]*26
    kaisai_all=[[0]*26 for _ in range(D)]
    manzokudo=0
    t=[]
    for i in range(D):
        res=-float("inf")
        res_i=-1
        for j in range(26):
            henka=s[i][j]
            kaisai_kari=kaisai[:]
            kaisai_kari[j]=i+1
            for k in range(26):
                henka-=c[k]*(i+1-kaisai_kari[k])
            if res<henka:
                res=henka
                res_i=j
        manzokudo+=res
        if i!=0:
            kaisai_all[i]=kaisai_all[i-1][:]
        kaisai[res_i]=i+1
        kaisai_all[i][res_i]=i+1
        t.append(res_i)

    for _ in range(1000):
        for i in range(D):
            for j in range(26):
                if j==t[i]: continue
                manzokudo_kari=manzokudo
                day=i
                before_contest_type=t[day]
                after_contest_type=j
                manzokudo_kari-=s[day][before_contest_type]
                manzokudo_kari+=s[day][after_contest_type]

                if day==0:
                    tmp=0
                else:
                    tmp=kaisai_all[day-1][before_contest_type]
                j=day
                while 0<=j<D and kaisai_all[j][before_contest_type]==day+1:
                    manzokudo_kari-=c[before_contest_type]*(day+1-tmp)
                    j+=1
                
                if day==0:
                    tmp=0
                else:
                    tmp=kaisai_all[day-1][after_contest_type]
                j=day
                while 0<=j<D and kaisai_all[j][after_contest_type]==tmp:
                    manzokudo_kari+=c[after_contest_type]*(day+1-tmp)
                    j+=1
                
                #更新
                if manzokudo_kari>manzokudo:
                    manzokudo=manzokudo_kari
                    t[i]=j

                    if day==0:
                        tmp=0
                    else:
                        tmp=kaisai_all[day-1][before_contest_type]
                    j=day
                    while 0<=j<D and kaisai_all[j][before_contest_type]==day+1:
                        kaisai_all[j][before_contest_type]=tmp
                        j+=1
                    
                    if day==0:
                        tmp=0
                    else:
                        tmp=kaisai_all[day-1][after_contest_type]
                    j=day
                    while 0<=j<D and kaisai_all[j][after_contest_type]==tmp:
                        kaisai_all[j][after_contest_type]=day+1
                        j+=1

                    break

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

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    D=int(readline())
    c=list(map(int,readline().split()))
    s=[list(map(int,readline().split())) for _ in range(D)]

    kaisai=[0]*26
    for i in range(D):
        res=-float("inf")
        res_i=-1
        for j in range(26):
            henka=s[i][j]
            kaisai_kari=kaisai[:]
            kaisai_kari[j]=i+1
            for k in range(26):
                henka-=c[k]*(i+1-kaisai_kari[k])
            if res<henka:
                res=henka
                res_i=j
        kaisai[res_i]=i+1
        print(res_i+1)

if __name__=="__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    D=int(readline())
    c=list(map(int,readline().split()))
    s=[list(map(int,readline().split())) for _ in range(D)]

    kaisai=[0]*26
    kaisai_all=[[0]*26 for _ in range(D)]
    manzokudo=0
    t=[]
    for i in range(D):
        res=-float("inf")
        res_i=-1
        for j in range(26):
            henka=s[i][j]
            kaisai_kari=kaisai[:]
            kaisai_kari[j]=i+1
            for k in range(26):
                henka-=c[k]*(i+1-kaisai_kari[k])
            if res<henka:
                res=henka
                res_i=j
        manzokudo+=res
        if i!=0:
            kaisai_all[i]=kaisai_all[i-1][:]
        kaisai[res_i]=i+1
        kaisai_all[i][res_i]=i+1
        t.append(res_i)

    for _ in range(1000):
        for i in range(D):
            for j in range(26):
                if j==t[i]: continue
                manzokudo_kari=manzokudo
                day=i
                before_contest_type=t[day]
                after_contest_type=j
                manzokudo_kari-=s[day][before_contest_type]
                manzokudo_kari+=s[day][after_contest_type]

                if day==0:
                    tmp=0
                else:
                    tmp=kaisai_all[day-1][before_contest_type]
                j=day
                while 0<=j<D and kaisai_all[j][before_contest_type]==day+1:
                    manzokudo_kari-=c[before_contest_type]*(day+1-tmp)
                    j+=1
                
                if day==0:
                    tmp=0
                else:
                    tmp=kaisai_all[day-1][after_contest_type]
                j=day
                while 0<=j<D and kaisai_all[j][after_contest_type]==tmp:
                    manzokudo_kari+=c[after_contest_type]*(day+1-tmp)
                    j+=1
                
                #更新
                if manzokudo_kari>manzokudo:
                    manzokudo=manzokudo_kari
                    t[i]=j

                    if day==0:
                        tmp=0
                    else:
                        tmp=kaisai_all[day-1][before_contest_type]
                    j=day
                    while 0<=j<D and kaisai_all[j][before_contest_type]==day+1:
                        kaisai_all[j][before_contest_type]=tmp
                        j+=1
                    
                    if day==0:
                        tmp=0
                    else:
                        tmp=kaisai_all[day-1][after_contest_type]
                    j=day
                    while 0<=j<D and kaisai_all[j][after_contest_type]==tmp:
                        kaisai_all[j][after_contest_type]=day+1
                        j+=1

                    break

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

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    D=int(readline())
    c=list(map(int,readline().split()))
    s=[list(map(int,readline().split())) for _ in range(D)]

    kaisai=[0]*26
    for i in range(D):
        res=-float("inf")
        res_i=-1
        for j in range(26):
            henka=s[i][j]
            kaisai_kari=kaisai[:]
            kaisai_kari[j]=i+1
            for k in range(26):
                henka-=c[k]*(i+1-kaisai_kari[k])
            if res<henka:
                res=henka
                res_i=j
        kaisai[res_i]=i+1
        print(res_i+1)

if __name__=="__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    D=int(readline())
    c=list(map(int,readline().split()))
    s=[list(map(int,readline().split())) for _ in range(D)]

    kaisai=[0]*26
    kaisai_all=[[0]*26 for _ in range(D)]
    t=[0]*D
    manzokudo=0
    for i in range(D):
        res=-float("inf")
        res_i=-1
        for j in range(26):
            henka=s[i][j]
            kaisai_kari=kaisai[:]
            kaisai_kari[j]=i+1
            for k in range(26):
                henka-=c[k]*(i+1-kaisai_kari[k])
            if res<henka:
                res=henka
                res_i=j
        manzokudo+=res
        if i!=0:
            kaisai_all[i]=kaisai_all[i-1][:]
        kaisai[res_i]=i+1
        kaisai_all[i][res_i]=i+1
        t.append(res_i)

    for _ in range(1000):
        for i in range(D):
            for j in range(26):
                if j==t[i]: continue
                manzokudo_kari=manzokudo
                day=i
                before_contest_type=t[day]
                after_contest_type=j
                manzokudo_kari-=s[day][before_contest_type]
                manzokudo_kari+=s[day][after_contest_type]

                if day==0:
                    tmp=0
                else:
                    tmp=kaisai_all[day-1][before_contest_type]
                j=day
                while 0<=j<D and kaisai_all[j][before_contest_type]==day+1:
                    manzokudo_kari-=c[before_contest_type]*(day+1-tmp)
                    j+=1
                
                if day==0:
                    tmp=0
                else:
                    tmp=kaisai_all[day-1][after_contest_type]
                j=day
                while 0<=j<D and kaisai_all[j][after_contest_type]==tmp:
                    manzokudo_kari+=c[after_contest_type]*(day+1-tmp)
                    j+=1
                
                #更新
                if manzokudo_kari>manzokudo:
                    manzokudo=manzokudo_kari
                    t[i]=j

                    if day==0:
                        tmp=0
                    else:
                        tmp=kaisai_all[day-1][before_contest_type]
                    j=day
                    while 0<=j<D and kaisai_all[j][before_contest_type]==day+1:
                        kaisai_all[j][before_contest_type]=tmp
                        j+=1
                    
                    if day==0:
                        tmp=0
                    else:
                        tmp=kaisai_all[day-1][after_contest_type]
                    j=day
                    while 0<=j<D and kaisai_all[j][after_contest_type]==tmp:
                        kaisai_all[j][after_contest_type]=day+1
                        j+=1

                    break

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

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    D=int(readline())
    c=list(map(int,readline().split()))
    s=[list(map(int,readline().split())) for _ in range(D)]

    kaisai=[0]*26
    for i in range(D):
        res=-float("inf")
        res_i=-1
        for j in range(26):
            henka=s[i][j]
            kaisai_kari=kaisai[:]
            kaisai_kari[j]=i+1
            for k in range(26):
                henka-=c[k]*(i+1-kaisai_kari[k])
            if res<henka:
                res=henka
                res_i=j
        kaisai[res_i]=i+1
        print(res_i+1)

if __name__=="__main__":
    main()

Buggy python submission (verdict: Runtime Error):
#A
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    D=int(readline())
    c=list(map(int,readline().split()))
    s=[list(map(int,readline().split())) for _ in range(D)]

    kaisai=[0]*26
    kaisai_all=[[0]*26 for _ in range(D)]
    t=[0]*D
    manzokudo=0
    for i in range(D):
        res=-float("inf")
        res_i=-1
        for j in range(26):
            henka=s[i][j]
            kaisai_kari=kaisai[:]
            kaisai_kari[j]=i+1
            for k in range(26):
                henka-=c[k]*(i+1-kaisai_kari[k])
            if res<henka:
                res=henka
                res_i=j
        manzokudo+=res
        if i!=0:
            kaisai_all[i]=kaisai_all[i-1][:]
        kaisai[res_i]=i+1
        kaisai_all[i][res_i]=i+1
        t.append(res_i)

    for _ in range(1000):
        for i in range(D):
            for j in range(26):
                if j==t[i]: continue
                manzokudo_kari=manzokudo
                day=i
                before_contest_type=t[day]
                after_contest_type=j

                if day==0:
                    tmp=0
                else:
                    tmp=kaisai_all[day-1][before_contest_type]
                j=day
                while 0<=j<D and kaisai_all[j][before_contest_type]==day+1:
                    manzokudo_kari-=c[before_contest_type]*(day+1-tmp)
                    j+=1
                
                if day==0:
                    tmp=0
                else:
                    tmp=kaisai_all[day-1][after_contest_type]
                j=day
                while 0<=j<D and kaisai_all[j][after_contest_type]==tmp:
                    manzokudo_kari+=c[after_contest_type]*(day+1-tmp)
                    j+=1
                
                #更新
                if manzokudo_kari>manzokudo:
                    manzokudo=manzokudo_kari
                    t[i]=j

                    if day==0:
                        tmp=0
                    else:
                        tmp=kaisai_all[day-1][before_contest_type]
                    j=day
                    while 0<=j<D and kaisai_all[j][before_contest_type]==day+1:
                        kaisai_all[j][before_contest_type]=tmp
                        j+=1
                    
                    if day==0:
                        tmp=0
                    else:
                        tmp=kaisai_all[day-1][after_contest_type]
                    j=day
                    while 0<=j<D and kaisai_all[j][after_contest_type]==tmp:
                        kaisai_all[j][after_contest_type]=day+1
                        j+=1

                    break

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

if __name__=="__main__":
    main()

Fixed submission:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    D=int(readline())
    c=list(map(int,readline().split()))
    s=[list(map(int,readline().split())) for _ in range(D)]

    kaisai=[0]*26
    for i in range(D):
        res=-float("inf")
        res_i=-1
        for j in range(26):
            henka=s[i][j]
            kaisai_kari=kaisai[:]
            kaisai_kari[j]=i+1
            for k in range(26):
                henka-=c[k]*(i+1-kaisai_kari[k])
            if res<henka:
                res=henka
                res_i=j
        kaisai[res_i]=i+1
        print(res_i+1)

if __name__=="__main__":
    main()