Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03612 (python)

Fixed submission:
N=int(input())
INL=list(map(int,input().split()))

swp = 0
for i in range(0, N-1):
    if i+1 == INL[i]:
        INL[i] = INL[i] ^ INL[i+1]
        INL[i+1] = INL[i] ^ INL[i+1]
        INL[i] = INL[i] ^ INL[i+1]
        swp += 1

if INL[N-1] == N:
    INL[N-1], INL[N-2] = INL[N-2], INL[N-1]
    swp += 1

print(swp)

Buggy submission (verdict: Runtime Error):
N=int(input())
INL=list(map(int,input().split()))

swp = 0
for i in range(0, N):
    if i+1 == INL[i]:
        INL[i] = INL[i] ^ INL[i+1]
        INL[i+1] = INL[i] ^ INL[i+1]
        INL[i] = INL[i] ^ INL[i+1]
        swp += 1

print(swp)

Buggy submission (verdict: Runtime Error):
N=int(input())
INL=list(map(int,input().split()))

swp = 0
for i in range(0, N):
    if i+1 == INL[i]:
        INL[i], INL[i+1] = INL[i+1], INL[i]
        swp += 1

print(swp)

Buggy submission (verdict: Runtime Error):
N=int(input())
INL=list(map(int,input().split()))

swp = 0
for i in range(0, N):
    if i+1 == INL[i]:
        INL[i], INL[i+1] = INL[i+1], INL[i]
        swp += 1

print(swp)
Problem p02658 (python)

Fixed submission:
import sys
n = int(sys.stdin.readline())
li = list(map(int, sys.stdin.readline().split()))
if 0 in li:
    print(0)
    exit()
res = 1
for i in range(n):
    res *= li[i]
    if res > 1000000000000000000:
        print(-1)
        exit(0)
print(res)

Buggy submission (verdict: Runtime Error):
/*
  -> Do Good Die Great
*/
#include <bits/stdc++.h>
#define int long long int
#define pii pair<int, int>
#define rep(s, e) for (int i = s; i < e; i++)
#define reep(s, e) for (int i = s; i <= e; i++)
#define ff first
#define ss second
#define eb emplace_back
#define pb push_back
#define MOD 1000000007
#define Hiraishin                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr);
#define tests \
    int t;    \
    cin >> t; \
    while (t--)
using namespace std;

// global
const int mx = 1ull * pow(10, 18);

void solve()
{
    int n;
    cin >> n;
    int res = 1ull;
    while (n--) {
        int t;
        cin >> t;
        res *= t;
    }
    cout << (res <= mx ? res : -1);
}

signed main()
{
    Hiraishin
    //tests
    solve();
    return 0;
}
Problem p02841 (python)

Fixed submission:
#ossan
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
if d2 == 1:
	print(1)
else:
	print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 615 == 0:
	print(1)
else:
	if n%100 == 0 or n%101==0 or n%102 == 0 or n%103==0 or n%104==0 or n%105==0:
		print(1)
	elif n%209==0 or n%206==0 or n%207==0 or n%208==0 or n%201 ==0 or n%202 == 0 or n%203==0 or n%204 == 0 or n%205 == 0:
		print(1)
	else:
		print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1, 100001):
	if i*(615) == n:
		c = i
		break
try:
	if c > 0:
		print(1)
except:
	print(0)
Problem p02843 (python)

Fixed submission:
coin = [100, 101, 102, 103, 104, 105]
X = int(input())
dp = [0]*(X+5)
dp[0]=1
for i in coin:
	for j in range(X+5):
		if i<=j:
			if dp[j-i]:
				dp[j]=1
print(1) if dp[X] else print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 615 == 0:
	print(1)
else:
	if n%100 == 0 or n%101==0 or n%102 == 0 or n%103==0 or n%104==0 or n%105==0:
		print(1)
	elif n% 209 == 0 n%206==0 or n%207==0 or n%208==0 or n%201 ==0 or n%202 == 0 or n%203==0 or n%204 == 0 or n%205 == 0:
		print(1)
	elif n%303 == 0 or n% n%304 ==0 or n%305 == 0 or n%306 == 0 or n%307==0 or n%308==0 or n%309==0 or n%310 == 0 or n%311==0 or n%312==0:
		print(1)
	elif n%406==0 or n%407==0 or n%408==0 or n%409==0 or n%410==0 or n%411==0 or n%412==0 or n%413==0 or n%414==0:
		print(1)
	elif n%510==0 or n%511==0 or n%512==0 or n%513==0 or n%514==0 or n%515==0:
		print(1)
	else:
		print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 615 == 0:
	print(1)
else:
	if n%100 == 0 or n%101==0 or n%102 == 0 or n%103==0 or n%104==0 or n%105==0:
		print(1)
	elif n%206==0 or n%207==0 or n%208==0 or n%201 ==0 or n%202 == 0 or n%203==0 or n%204 == 0 or n%205 == 0:
		print(1)
	elif n%303 == 0 or n% n%304 ==0 or n%305 == 0 or n%306 == 0 or n%307==0 or n%308==0 or n%309==0 or n%310 == 0 or n%311==0 or n%312==0:
		print(1)
	elif n%406==0 or n%407==0 or n%408==0 or n%409==0 or n%410==0 or n%411==0or n%412==0 or n%413==0 or n%414==0:
		print(1)
	elif n%510==0or n%511==0 or n%512==0 or n%513==0 or n%514==0 or n%515==0:
		print(1)
	else:
		print(0)
Problem p02923 (python)

Fixed submission:
n = int(input())
c = 0
l = []
li = list(map(int, input().split()))
for i in range(1, n):
	if li[i-1] >= li[i]:
		c += 1
		#print('k', li[i])
	else:
		#print(li[i])
		l.append(c) 
		c = 0
l.append(c)
print(max(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
height = list(map(int, input().split()))
li = []
max_height = max(height)
for i in range(n - 1):
    sl = height[i + 1:]
    if sl == sorted(sl,reverse=True):
        count = len(sl)-1
        break
    else:
        pass
print(count)
Problem p02934 (python)

Fixed submission:
n = int(input())
arr = list(map(int,input().split()))
total = 0
for i in range(n):
    total += (1/arr[i])
print(1/total)

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int,input()))
total = 0
for i in range(n):
  total += (1/arr[i])
 print(1/total)
Problem p02945 (python)

Fixed submission:
li = list(map(int,input().split()))
li1 = [li[0] + li[1], li[0] * li[1], li[0] - li[1]]
print(max(li1))

Buggy submission (verdict: Runtime Error):
li = list(map(int,input().split()))
li1 = []
for i in range(len(list)):
  li1.append(li[i]+li[i+1])
  li1.append(li[i]*li[i+1])
  li1.append(li[i]-li[i+1])
print(max(li1))
Problem p02621 (python)

Fixed submission:
a=int(input())
print(a+a*a+a*a*a)

Buggy submission (verdict: Runtime Error):
a=int(input())
input(a+a*a+a**3)
Problem p02657 (python)

Fixed submission:
A,B=map(int,input().rstrip().split(" "))
print(A*B)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().rstrip().split(" ")
print(A*B)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().rstop().split(" ")
print(A*B)
Problem p02612 (python)

Fixed submission:
N = input()
Num = int(N)

while Num > 0:
    OTURI = 1000 - Num
    Num -= 1000
  
print(OTURI)

Buggy submission (verdict: Runtime Error):
N = int(input())

result = [input() for _ in range(N)]

C_AC,C_TLE,C_WA,C_RE = [0,0,0,0]

for i in result:
  if i == "AC":
    C_AC += 1
  elif i == "WA":
    C_WA += 1
  elif i == "TLE":
    C_TLE += 1
  elif i == "RE":
    C_RE += 1

print("AC x " + str(C_AC))
print("WA x " + str(C_WA))
print("TLE x " + str(C_TLE))
print("RE x " + str(C_RE))

Buggy submission (verdict: Runtime Error):
N = input()

while N > 0:
  OTURI = 1000 - N
  N -= 1000
  
print(OTURI)

Buggy submission (verdict: Runtime Error):
N = input()

While N > 0:
  OTURI = 1000 - N
  N -= 1000
  
print(OTURI)
Problem p02640 (python)

Fixed submission:
import sys
X,Y = map(int,input().split())


for i in range(X+1):
    if 2*i + 4*(X-i) == Y:
        print('Yes')
        sys.exit()
print('No')

Buggy submission (verdict: Runtime Error):
X,Y = map(int,input().split())

for i in range(X+1):
    if 2*i + 4*(X-i) == Y:
        print('YES')
    if i == X:
        prinnt('NO')
Problem p02780 (python)

Fixed submission:

def Main(N, K, P):
    wa = sum(P[:K])
    max_sum = wa
    max_sum_ind = 0
    for i in range(N-K):
        wa = wa - P[i] + P[i+K]
        if(wa > max_sum):
            max_sum = wa
            max_sum_ind = i
    ans = 0
    if max_sum_ind == 0:
        for i in range(K):
            ans += (P[i]+1)/2
    else:
        for i in range(max_sum_ind+1, max_sum_ind+K+1):
            ans += (P[i]+1)/2
    return ans

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    print("{:.12f}".format(Main(N, K, P)))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def Main(N, K, P):
    wa = sum(P[:K])
    max_sum = wa
    max_sum_ind = 0
    for i in range(N-K-1):
        wa = wa - P[i] + P[i+K]
        if(wa > max_sum):
            max_sum = wa
            max_sum_ind = i
    ans = 0
    for i in range(max_sum_ind+1, max_sum_ind+K+1):
        ans += (P[i]+1)/2
    return ans

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    print("{:.12f}".format(Main(N, K, P)))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def Main(N, K, P):
    wa = sum(P[:K])
    max_sum = wa
    max_sum_ind = 0
    for i in range(N-K):
        wa = wa - P[i] + P[i+K]
        if(wa > max_sum):
            max_sum = wa
            max_sum_ind = i
    ans = 0
    for i in range(max_sum_ind+1, max_sum_ind+K+1):
        ans += (P[i]+1)/2
    return ans

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    print("{:.12f}".format(Main(N, K, P)))

if __name__ == '__main__':
    main()
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
    A.append(int(input()))
score = [0]*N
init_score = [K]*N
for i in A:
    score[i-1] += 1
final_score = [init_score[i]-Q+score[i] for i in range(N)]
for i in final_score:
    print("Yes") if i > 0 else print("No")

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
    A.append(int(input()))
score = [0]*N
init_score = [K]*N
for i in A:
    score[i] += 1
final_score = [init_score[i]-Q+score[i] for i in range(N)]
for i in final_score:
    print("Yes") if i > 0 else print("No")
Problem p03161 (python)

Fixed submission:
N, K = map(int, input().split())
*h, = map(int, input().split())
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
	for j in range(1, min(K + 1, N - i)):
		dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[N - 1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math

def Main(N, K, h):
    dp = [math.inf]*N
    dp[0] = 0
    for i in range(N):
        for j in range(1, min(N-i,K+1)):
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
    return dp[N-1]

def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    print(Main(N, K, h))

if __name__ == '__main__':
    main()
Problem p02614 (python)

Fixed submission:
h,w,k = map(int, input().split())
grid = [input() for _ in range(h)]

ans = 0

for i in range(2**h):
    for j in range(2**w):
        count = 0
        for m in range(h):
            for l in range(w):
                if (i>>m)&1==0 and (j>>l)&1==0 and grid[m][l] == "#":
                    count+=1
        if count == k: ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
h,w,k = map(int, input().split())

for _ in range(h):
    c=list(input())

ans = 0

for i in range(h):
    for j in range(w):
        count = 0
        for m in range(h):
            for l in range(w):
                if (i>>m)&1==0 and (j>>l)&1==0 and c[m][l]== "#":
                    count+=1
        if count == k: ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
h,w,k = map(int, input().split())

for _ in range(h):
    c=list(input())

ans = 0

for i in range(h):
    for j in range(w):
    cnt = 0
        for m in range(h):
            for l in range(w):
                if (i>>m)&1==0 and (j>>l)&1==0 and c[m][l]== "#":
                    cnt+=1
        if cnt == k: ans+=1
print(ans)
Problem p02615 (python)

Fixed submission:
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

ans = 0

for i in range(N-1):
    ans += a[(i+1)//2]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

ans = 0

for i in range(n-1):
    ans += a[(i+1)//2]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = sorted(list(map(int, input().split()), reverse=True))

ans = 0

for i in range(n-1):
    ans += a[(i+1)//2]
print(ans)
Problem p03387 (python)

Fixed submission:
l = sorted(list(map(int,input().split())))

a = abs(l[0]-l[1])%2
b = abs(l[1]-l[2])%2
c = abs(l[0]-l[2])%2

if a==0:
    if b==0:
        ans = (l[2]-l[0] + l[2]-l[1]) /2
    else:
        ans = 1 + (l[2]-(l[0]+1) + l[2]-(l[1]+1))/2
else:
    if b==0:
        ans = 1 + ((l[2]+1)-l[0] + (l[2]+1)-(l[1]+1))/2
    else:
        ans = 1 + ((l[2]+1)-(l[0]+1) + (l[2]+1)-l[1])/2
print(int(ans))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int, input().split())

if (b-a)%2 == 1:
    print(Borys)
else:
    print(Alice)
Problem p03061 (python)

Fixed submission:
import math
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

fromleft = list(accumulate(a, math.gcd))
a.reverse()
fromright = list(accumulate(a, math.gcd))
fromright.reverse()
a.reverse()

gcd = []

gcd.append(fromright[1])
for i in range(1, n-1):
    gcd.append(math.gcd(fromleft[i-1], fromright[i+1]))

gcd.append(fromleft[n-2])

if n == 2:
    print(max(a[1], a[0]))
else:
    print(max(gcd))

Buggy submission (verdict: Runtime Error):
import math
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

fromleft = list(accumulate(a, math.gcd))
fromright = list(accumulate(a[::-1], math.gcd)).reverse()

gcd = []

gcd.append(fromright[1])
for i in range(1, n-1):
    gcd.append(math.gcd(fromleft[i-1], fromright[i+1]))
gcd.append(fromleft[n-2])

print(max(gcd))
Problem p03448 (python)

Fixed submission:
A,B,C,X = [int(input()) for i in range(4)]
X_original = X
n = 0

for i in range(int(A)+1):
    X = X_original
    X500 = X - i*500
    for j in range(int(B)+1):
        X100 = X500 - j*100
        for k in range(int(C)+1):
            X50 = X100-k*50
            if X50== 0:
                n += 1

print(n)

Buggy submission (verdict: Runtime Error):
inputlist = [input() for i in range(4)]

n = 0

A,B,C= inputlist[0],inputlist[1],inputlist[2]

for i in range(int(A)+1):

    X = inputlist[3] 

    X500 = int(X) - i*500

    for j in range(int(B)+1):

        X100 = X - j*100

        for k in range(int(C)+1):

            X50 = X -k*50

            if X50 == 0:
                n += 1

print(n)
Problem p03470 (python)

Fixed submission:
n = int(input())

l = list(set([int(input()) for x in range(n)]))
l.sort(reverse=True)
print(len(l))

Buggy submission (verdict: Runtime Error):
_ = input()

l = list(set([int(input() for x in range(n))]))
l.sort(reverse=True)
print(len(l))
Problem p02607 (python)

Fixed submission:
n = int(input())
squares = list(map(int, input().split(" ")))

odd = 0
for i in range(0, n, 2):
  if squares[i] % 2:
    odd += 1
print(odd)

Buggy submission (verdict: Runtime Error):
n = int(input())
squares = list(map(int, input().split(" ")))

odd = 0
for i in range(n, 2):
  if squares[i] % 2 == 1:
    odd += 1
print(odd)
Problem p02612 (python)

Fixed submission:
print((1000 - (int(input()) % 1000)) % 1000)

Buggy submission (verdict: Runtime Error):
return 1000 - (int(input()) % 1000)
Problem p02658 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
ans = 1
if 0 in a:
    ans = 0
else:
    for i in a:
        ans *= i
        if ans > 10**18: 
            ans = '-1'
            break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
ans = 1
for i in a:
    ans *= i
    if ans > 10**18: 
        ans = '-1'
print(ans)
Problem p03106 (python)

Fixed submission:
a, b, k = map(int, input().split())
if a == 1 or b == 1:
    print(1)
    exit()
l = [i for i in range(1, min(a, b)+1) if a % i == 0 and b % i ==0]
l.sort(reverse=True)
print(l[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
if a == 1 or b == 1:
    print(1)
    exit()
l = [i for i in range(1, min(a, b)) if a % i == 0 and b % i ==0]
l.sort(reverse=True)
print(l[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
l = [i for i in range(1, max(a, b)) if a % i == 0 and b % i ==0]
l.sort(reverse=True)
print(l[k-1])
Problem p03254 (python)

Fixed submission:
n, x = map(int, input().split())
a = list(map(int, input().split()))
num = len(a)
a.sort(reverse=True)
for i in range(num):
    x -= a.pop()
    if x < 0:
        print(i)
        exit()
    if x == 0:
        print(i + 1)
        exit()
print(num - 1)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
a = map(int, input().split())
num = len(a)
a.sort(reverse=True)
for i in range(num):
    x -= a.pop()
    if x < 0:
        print(i)
        exit()
    if x == 0:
        print(i + 1)
        exit()
print(num - 1)
Problem p03478 (python)

Fixed submission:
n, a, b = map(int, input().split())
returnSum = 0
for i in range(n+1):
    d = 0
    for j in range(len(str(i))):
        d += int(str(i)[j])
    if a <= d <= b:
        returnSum += i
print(returnSum)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
for i in range(n+1):
    o = i // 10000
    p = (i % 10000) // 1000
    q = (i % 1000) // 100
    r = (i % 100) // 10
    s = i % 10
    if a <= o + p + q + r + s <= b:
        su += i
print(su)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
for i in range(n+1):
    if i >= 10:
        x = i // 10
        y = i - x * 10
        if a <= x + y <= b:
            s += i
    if a <= i <= b:
        s += i
print(s)
Problem p04044 (python)

Fixed submission:
n, l = map(int, input().split())
sList = []
for i in range(n):
    sList.append(input())
sList.sort()
print(''.join(sList))

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())
sList = []
for i in range(n):
    sList.append()
sList.sort()
print(''.join(sList))
Problem p02705 (python)

Fixed submission:
r = float(input())
print(2 * r * 3.14159265)

Buggy submission (verdict: Runtime Error):
R =int(input())
print("2 * 3.1415926535 * R)
Problem p04011 (python)

Fixed submission:
# x, y = [int(input()) for i in range(2)]
n, k, x, y = [int(input()) for i in range(4)]

if n > k:
    print(int(k * x + y * (n - k)))
else:
    print(int(n * x))

Buggy submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())

print(int(k * x + y * (n - k)))
Problem p04043 (python)

Fixed submission:
# list に入力を格納
list = list(map(int, input().split()))
# 小さい順に並び替え
list.sort()

if list[0] == 5 and list[1] == 5 and list[2] == 7:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
# list に入力を格納
list = list(int, input().split())
# 小さい順に並び替え
list.sort()

if list[0] == 5 and list[1] == 5 and list[2] == 7:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# list に入力を格納
list = list(map(int, input().split()))
# 小さい順に並び替え
list.sort()

if list[0] == 5 and list[1] == 5 and list[7] == 7:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

list = list(int, input().split())

list.sort()

if list[0] == 5 and list[1] == 5 and list[7] == 7:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# list に入力を格納
list = list(int, input().split())
# 小さい順に並び替え
list.sort()

if list[0] == 5 and list[1] == 5 and list[7] == 7:
    print('Yes')
else:
    print('No')
Problem p02618 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)
		ans.append(17)

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



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	for i in range(D):
		s = inputList()
		S.append(s)

	ans = []
	for i in range(D):
		bestSco = 0
		bestI = inf
		for j,val in enumerate(S[i]):
			tmpAns = ans + [j+1]
			tmpSco = findScore(tmpAns, S, C)
			if bestSco < tmpSco:
				bestSco = tmpSco
				bestI = j+1
		ans.append(bestI)

	for i in ans:
		print(i)


def findScore(ans, S, C):
	scezhu = [inf for i in range(26)]
	sco = 0
	for i,val in enumerate(ans):
		tmp = S[i][val-1]
		scezhu[val-1] = i
		mins = 0
		for j,vol in enumerate(C):
			if scezhu[j] == inf:
				mins = mins + (vol * (i+1))
			else:
				mins = mins + (vol * ((i+1)-(scezhu[j]+1)))
		tmp -= mins
		sco += tmp
	return sco

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()
Problem p03032 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
	
def main():
	N, K = map(int, input().split(" "))
	V = list(map(int, input().split(" ")))
	
	V_tmp = copy.deepcopy(V)
	ans = 0
	for L in range(K+1):
		for R in range((K+1)-L):
			V = copy.deepcopy(V_tmp)
			gets = []
			tmp = 0
			
			for i in range(L):
				if len(V) > 0:
					tmptmp = V.pop(0)
					tmp += tmptmp
					if tmptmp < 0:
						gets.append(tmptmp)
					
			for i in range(R):
				if len(V) > 0:
					tmptmp = V.pop(-1)
					tmp += tmptmp
					if tmptmp < 0:
						gets.append(tmptmp)
					
			#print(gets)
			for i in range(K-L-R):
				if len(gets) == 0:
					break
				gets.sort()
				tmp = tmp + (-1 * gets.pop(0))
				
			if tmp > ans:
				ans = tmp
				
	print(ans)
	
	
	
if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
	
def main():
	N, K = map(int, input().split(" "))
	V = list(map(int, input().split(" ")))
	
	ans = 0
	for L in range(K+1):
		for R in range((K+1)-L):
			gets = []
			tmp = 0
			
			for i in range(L):
				tmp += V[i]
				if V[i] < 0:
					gets.append(V[i])
					
			for i in range(R):
				tmp += V[-(i+1)]
				if V[-(i+1)] < 0:
					gets.append(V[-(i+1)])
					
			#print(gets)
			for i in range(K-L-R):
				if len(gets) == 0:
					break
				gets.sort()
				tmp = tmp + (-1 * gets.pop(0))
				
			if tmp > ans:
				ans = tmp
				
	print(ans)
	
	
	
if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)

# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

def main():
	N, K = map(int, input().split(" "))
	#N = int(input())
	#S = input()
	V = input().split(" ")
	V = [int(s) for s in V]

	ptn = []
	for i in range(K):
		tmp = K - i
		ptn.append((i, tmp))

	ans = 0
	for i in ptn:
		L, R = i
		tmp = 0
		for i in range(L):
			tmp += V[i]
		for i in range(R):
			tmp += V[-i-1]
		
		if tmp > ans:
			ans = tmp

	print(ans)

if __name__ == "__main__":
	main()