Buggy python submission (verdict: Time Limit Exceeded):
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 cnt_contest_score(t, contestid, day, isBefore):
    global D, C, S
    score = 0
    minusscore = 0

    t = set(t)

    for i in range(D):
        if i == day and isBefore is False:
            if i in t:
                minusscore += C[contestid]
            else:
                score -= minusscore
                minusscore = 0
        else:
            if i in t:
                score -= minusscore
                minusscore = 0
            else:
                minusscore += C[contestid]

    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 = []
    A = [[] for j in range(26)]

    for i, s in enumerate(S):
        ans.append(s.index(max(s)) + 1)
        A[s.index(max(s))].append(i)

    # A = [[None] * COL for j in range(ROW)]

    old_score = cnt_score(ans)
    day = 0
    f = False
    while True:
        # new_ans = copy.deepcopy(ans)

        max_sore = old_score
        before_contest = ans[day]
        before_score = cnt_contest_score(A[before_contest - 1], before_contest - 1, day, True)
        before_score += S[day][before_contest - 1]
        max_contest = ans[day]
        ma_score = 0
        for i in range(26):
            # time up
            current = time.time()
            if current - start > 1.90:
                f = True
                break

            # main
            # main
            aa_score = cnt_contest_score(A[before_contest - 1], before_contest - 1, day, False)
            bb_score = cnt_contest_score(A[i], i, day, True)
            after_score = cnt_contest_score(A[i], i, day, False)
            after_score += S[day][i]
            # new_score = cnt_score(new_ans)
            if aa_score > bb_score:
                if aa_score > ma_score:
                    max_contest = i + 1
                    ma_score = aa_score
        A[ans[day] - 1].remove(day)
        A[max_contest - 1].append(day)
        ans[day] = max_contest
        if f:
            break

        # increment day
        day = (day + 1) % D

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


    for i in range(D):
        print(i % 26 + 1)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
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 cnt_contest_score(t, contestid):
#    global D, C, S
#    score = 0
#    minusscore = 0
#
#    t = set(t)
#
#    for i in range(D):
#        if i in t:
#            score -= minusscore
#            minusscore = 0
#        else:
#            minusscore += C[contestid]
#
#    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)

    # A = [[None] * COL for j in range(ROW)]

    old_score = cnt_score(ans)
    day = 0
    f = False
    while True:
        new_ans = copy.deepcopy(ans)

        max_sore = old_score
        max_contest = ans[day]
        for i in range(26):
            # time up
            current = time.time()
            if current - start > 1.90:
                f = True
                break

            # main
            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
        if f:
            break

        # increment day
        day = (day + 1) % D

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


    for i in range(D):
        print(i % 26 + 1)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
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 cnt_contest_score(t, cid):
#     global D, C, S
#     score = 0
#
#     for i in range(D):
#         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)

    # A = [[None] * COL for j in range(ROW)]

    old_score = cnt_score(ans)
    day = 0
    f = False
    while True:
        new_ans = copy.deepcopy(ans)

        max_sore = old_score
        max_contest = ans[day]
        for i in range(26):
            # time up
            current = time.time()
            if current - start > 1.95:
                f = True
                break

            # main
            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
        if f:
            break


        # increment day
        day = (day + 1) % D

    for a in ans:
        print(a)



if __name__ == '__main__':
    main()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


    for i in range(D):
        print(i % 26 + 1)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
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)

    # A = [[None] * COL for j in range(ROW)]

    old_score = cnt_score(ans)
    day = 0
    while True:
        # time up
        current = time.time()
        if current - start > 1.9:
            break

        # main
        new_ans = copy.deepcopy(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

        # increment day
        day = (day + 1) % D

    for a in ans:
        print(a)



if __name__ == '__main__':
    main()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


    for i in range(D):
        print(i % 26 + 1)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
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(C.index(max(C)) + 1)

    # 初期値をランダムで探す
    while True:
        # time up
        current = time.time()
        if current - start > 1.0:
            break

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

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

    #ans = [1] * D

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

        # main
        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

        # increment day
        day = (day + 1) % D

    for a in ans:
        print(a)



if __name__ == '__main__':
    main()


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


    for i in range(D):
        print(i % 26 + 1)



if __name__ == '__main__':
    main()