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

Fixed submission:
n=int(input())

print((10**n-(9**n+9**n-8**n))%(10**9+7))

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

print((10**n-(9**n+9**n-8**n)%(10**9+7))
Problem p02639 (python)

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

for i in range(len(a)):
    if a[i] == 0:
        print(i+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
onaji = 0

for i in range(len(A)):
    if i >= len(A)-1:
        break
    for j in range(len(A)-1,i,-1):
        if A[i] == A[j]:
            onaji = 1
        if A[j] % A[i] == 0:
            del A[j]
            
    if onaji == 1:
        del A[i]
        onaji = 0

print(len(A))
Problem p02642 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
OKlist = [0]*(10**6+100)
A.sort()
for i in range(len(A)-1):
    if A[i] == A[i+1]:
        OKlist[A[i]] += 1
    else:
        for j in range(10**6+10):
            if A[i]*j > 10**6:
                break
            else:
                OKlist[A[i]*j] += 1
OKlist[max(A)] += 1
cnt = 0
for i in A:
    if OKlist[i] == 1:
        cnt += 1
        
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
onaji = 0

#数列Aを昇順に並べ替えた後、AjがAiの倍数になっていた時Ajをリストから削除する方針です。
for i in range(len(A)):
    if i >= len(A)-1:   #数列が小さくなって行くので当初のループ量は必要ないので。
        break
    for j in range(len(A)-1,i,-1):　#大きい数字から順番にみていく。
        if A[i] == A[j]:
            onaji = 1
        if A[j] % A[i] == 0:
            del A[j]
            
    if onaji == 1:　#同じ数字があった時Aiも削除。
        del A[i]
        onaji = 0

print(len(A))
Problem p02886 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
i=0
j=0
p=0
while(i<len(a)):
  j=i+1
  s=0
  while(j<len(a)):
      s=s+a[j]
      j=j+1
  
  p=p+s*a[i]
  i=i+1
print(p)

Buggy submission (verdict: Runtime Error):
n= int(input())
a=list(map(int,input().split()))
i=0
j=0
p=0
while(i<len(a)):
  j=i+1
  s=0
  while(j<len(a)):
    s=s+a[j]
   	j=j+1
  p=p+s*a[i]
  i=i+1
print(p)
Problem p02900 (python)

Fixed submission:
a,b=[int(x) for x in input().split()]
i=1
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)
g=gcd(a,b)
l=[]
while(i*i<=g):
    if g%i==0 and i*i!=g:
        l.append(i)
        l.append(g//i)
    if i*i==g:
        l.append(i)
    i=i+1
l=sorted(l)
i=1
while(i<len(l)):
    if l[i]!=0:
        j=i+1
        while(j<len(l)):
            if l[j]%l[i]==0:
                l[j] = 0
            j=j+1
    i=i+1
l=list(filter ( lambda x:x!=0,l))
print(len(l))

Buggy submission (verdict: Runtime Error):
import math
a,b=[int(x) for x in input().split()]
i=1
g=math.gcd(a,b)
l=[]
while(i*i<=g):
    if g%i==0 and i*i!=g:
        l.append(i)
        l.append(g//i)
    if i*i==g:
        l.append(i)
    i=i+1
l=sorted(l)
i=1
while(i<len(l)):
    if l[i]!=0:
        j=i+1
        while(j<len(l)):
            if l[j]%l[i]==0:
                l[j] = 0
            j=j+1
    i=i+1
l=list(filter ( lambda x:x!=0,l))
print(len(l))

Buggy submission (verdict: Runtime Error):
import math
a,b=[int(x) for x in input().split()]
i=1
g=math.gcd(a,b)
l=[]
while(i*i<=g):
    if g%i==0:
        l.append(i)
        l.append(g//i)
    i=i+1
l=sorted(l)
i=1
while(i<len(l)):
    if l[i]!=0:
        j=i+1
        while(j<len(l)):
            if l[j]%l[i]==0:
                l[j] = 0
            j=j+1
    i=i+1
l=list(filter ( lambda x:x!=0,l))
print(len(l))
Problem p02909 (python)

Fixed submission:
s=["Sunny","Cloudy","Rainy"]
a=input()
if a=="Sunny":
    print("Cloudy")
elif a=="Cloudy":
    print("Rainy")
else:
    print("Sunny")

Buggy submission (verdict: Runtime Error):
s=["Sunny","Cloudy","Rainy"]
a=input()
if a=="Sunny":
    print(Cloudy)
elif a=="Cloudy":
    print(Rainy)
else:
    print(Sunny)
Problem p02999 (python)

Fixed submission:
x,a=map(int,input().split())
if x<a:
  print("0")
else:
  print("10")

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
i,s=0,0
while s<=x:
  s=s+a[i]
  i=i+1
print(i)
Problem p03323 (python)

Fixed submission:
A, B = map(int, input().split())

if(A<=8 and B<=8):
    print("Yay!")
else:
    print(":(")

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

if A <= 8 or B <= 8:
    return "Yay!"
else:
    return ":("
Problem p03324 (python)

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

if(N !=100):
    print((100 ** D) * N)
else:
    print((100 ** D) * (N + 1))

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

if(N !=100):
    print((100 ** D) * N)    
else:
    print((100 ** D) * (N + 1)
Problem p03328 (python)

Fixed submission:
def poll_height(n):
    rtn = 0
    for i in range(n):
        rtn += i+1
    return rtn

a, b = map(int, input().split(" "))

difference_a_b = b - a
print(poll_height(difference_a_b) - b)

Buggy submission (verdict: Runtime Error):
def poll_height(n):
    if n:
        return n + poll_height(n - 1)
    else:
        return 0

a, b = map(int, input().split())

difference_a_b = b - a 
print(poll_height(difference_a_b) - b)
Problem p03338 (python)

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

def count_common(a, b):
    min_char = set(min(a, b))
    max_char = set(max(a, b))
    return len(max_char) - len(max_char - min_char)

rtn = 0
for i in range(N):
    a = S[:i]
    b = S[i:]
    tmp = count_common(a, b)
    if rtn < tmp:
        rtn = tmp

print(rtn)

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

def count_common(a, b):
    min_char = set(min(a, b))
    max_char = set(max(a, b))
    return len(max_char) - len(max_char-min_char)

rtn = 0
for i in range(N):
    a = S[:i]
    b = S[i:]
    tmp = count_common(a, b)
    if rtn < tmp:
        rtn = tmp

print(rtn)
Problem p03341 (python)

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

lE = [0] * N
lW = [0] * N
le = lw = 0
for i in range(N):
    if S[i] == "E":
        le += 1
    else:
        lw += 1
    lE[i] = le
    lW[i] = lw

rtn = lE[-1] - lE[0]

for i in range(1, N):
    tmp = lW[i-1] + lE[-1] - lE[i]
    if tmp <= rtn:
        rtn = tmp


print(rtn)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
 
lE = [0] * N 
lW = [0] * N 
le = lw = 0 
for i in range(N):
    if S[i] == "E":
        le += 1
    else:
        lw += 1
    lE[i] = le
    lW[i] = lw
 
rtn = lE[-1] - lE[0] 
 
for i in range(1, N - 1): 
    tmp = lW[i-1] + lE[-1] - lE[i]
    if tmp <= rtn:
        rtn = tmp 
 
most_east = lW[-2] 
if most_east <= rtn:
    rtn = count
 
print(rtn)
Problem p02767 (python)

Fixed submission:
n = int(input())
x = [int(i) for i in input().split()]
ans = 100100100
for i in range(1,101) :
    s = 0
    for o in x :
        s+=(i-o)*(i-o)
    ans = min(ans,s)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = [int(i) for i in input().split()]
ans = 100100100
for i in range(1,101) :
    s = 0
    for o in x :
        s+=(i-x)*(i-x)
    ans = min(ans,s)
print(ans)
Problem p02882 (python)

Fixed submission:
import math
a,b,x = map(int,input().split())
ans = 0
if (a*a*b)/2>=x :
    t = x*2/b/a/b
    ans = 90-math.degrees(math.atan(t))
elif (a*a*b)==x:
    ans = 0.0
else :
    x = (a*a*b) - x
    t = x*2/a/a
    ans = 90-math.degrees(math.atan(a/t))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
ans = 0
if (a*a*b)/2>=x :
    t = x*2/b/a/b
    ans = 90-math.degrees(math.atan(t))
else if (a*a*b)==x:
    ans = 0.0
else :
    x = (a*a*b) - x
    t = x*2/a/a
    ans = 90-math.degrees(math.atan(a/t))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if (a*a*b)/2>=x :
    t = x*2/b/a/b
    ans = 90-math.degrees(math.atan(t))
else if (a*a*b)==x:
  ans = 0.0
else :
    x = (a*a*b) - x
    t = x*2/a/a
    ans = 90-math.degrees(math.atan(a/t))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if (a*a*b)/2>=x :
    t = x*2/b/a/b
    ans = 90-math.degrees(math.atan(t))
else :
    x = (a*a*b) - x
    t = x*2/a/a
    ans = 90-math.degrees(math.atan(a/t))
print(ans)
Problem p02887 (python)

Fixed submission:
_=input()
s=input()
t=''
a=1
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    a+=1
print(a)

Buggy submission (verdict: Runtime Error):
s=input()
t=''
a=1
for i in len(s)-1:
  if s[i]!=s[i+1]:
    a+=1
print(a)
Problem p03138 (python)

Fixed submission:
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
ans = sum(a)
b = [0 for i in range(41)]
for j in range(41):
    for i in range(len(a)):
        if a[i]%2==1 : b[j]+=1
        a[i]//=2
c = 40
if k==0 : c = -1
while c>=0:
    if 2**(c)>k :
        c-=1
        continue;
    if b[c] < n-b[c]:
        k-=2**c
        ans -=b[c]*2**c
        ans += (n-b[c])*2**c
    c-=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
ans = sum(a)
b = [0 for i in range(18)]
for j in range(18):
    for i in range(len(a)):
        if a[i]%2==1 : b[j]+=1
        a[i]//=2
c = 18
if k==0 : c = -1
else :
    while 2**(c)>k : c-=1
print(b)
while c>=0:
    if 2**(c)>k :
        c-=1
        continue;
    if b[c] < n-b[c]:
        k-=2**c
        ans -=b[c]*2**c
        ans += (n-b[c])*2**c
    c-=1
print(ans)
Problem p03323 (python)

Fixed submission:
a,b = map(int,input().split())
if(a<=8 and b<=8):
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if(a<=8 and b<=8):
    print("Yay!")
else:
    print(":(")
Problem p03658 (python)

Fixed submission:
n,k = map(int,input().split())
l = [int(i) for i in input().split()]
l.sort(reverse=True)
print(sum(l[0:k]))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = map(int,input().split())
l.sort(reverse=True)
print(sum(l[0:k]))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = map(int,input().split())
l = l.sort(reverse=True)
print(sum(l[0:k]))
Problem p03695 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(4800//400 + 1)]
for i in a:
    b[i//400] += 1;
t = 0
ans = 0
for i in range(4800//400 + 1):
    if b[i] > 0:
        if i < 3200//400:
            ans+=1
        else:
            t+=b[i]
if ans > 0:
    print(ans,t+ans)
else:
    print(1,t)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(4800//400)]
for i in a:
    b[i//400] += 1;
t = 0
ans = 0
for i in range(4800//400):
    if b[i] > 0:
        if i < 3200//400:
            ans+=1
        else:
            t+=b[i]
if ans > 0:
    print(ans,t+ans)
else:
    print(1,t)
Problem p03502 (python)

Fixed submission:
n = str(input())
sum = 0
for i in range(0, len(n)):
  sum += int(n[i])
n = int(n)
if n % sum == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = str(input())
sum = 0
for i in range(0, len(str(input()))): sum += int(n[i])
if int(n) % sum == 0: print("Yes")
else: print("No")
Problem p02714 (python)

Fixed submission:
import sys
import collections
import copy


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    c = collections.Counter(list(s))
    left = collections.defaultdict(int)
    cnt = 0
    for i in range(n - 2):
        left[s[i]] += 1
        mid = copy.deepcopy(left)
        for j in range(i + 1, n - 1):
            mid[s[j]] += 1
            if s[i] != s[j]:
                if [s[i], s[j]].count("R") == 0:
                    cnt += c["R"] - mid["R"]
                    if j + j - i < n:
                        if s[j+j-i] == "R":
                            cnt -= 1
                elif [s[i], s[j]].count("G") == 0:
                    cnt += c["G"] - mid["G"]
                    if j + j - i < n:
                        if s[j+j-i] == "G":
                            cnt -= 1
                elif [s[i], s[j]].count("B") == 0:
                    cnt += c["B"] - mid["B"]
                    if j + j - i < n:
                        if s[j+j-i] == "B":
                            cnt -= 1
    print(cnt)


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    r = s.count("R")
    g = s.count("G")
    b = s.count("B")
    cnt = r *      if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
                    cnt -= 1
    print(cnt)


if __name__ == '__main__':
    solve()
Problem p02768 (python)

Fixed submission:
import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, input().rstrip('\n').split()))
    all_cnt = pow(2, n, mod) + mod
    a_cnt = alg_combination_mod(n, a, mod)
    b_cnt = alg_combination_mod(n, b, mod)
    print((all_cnt - a_cnt - b_cnt - 1) % mod)


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 
if __name__ == '__main__':
    solve()
Problem p02814 (python)

Fixed submission:
import sys
import fractions


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = [v >> 1 for v in list(map(int, readline().split()))]
    lcm = a[0]
    for v in a[1:]:
        gcd = fractions.gcd(lcm, v)
        if lcm // gcd % 2 == 0 or v // gcd % 2 == 0:
            print(0)
            exit()
        else:
            lcm = lcm * v // gcd
        if lcm > m:
            print(0)
            exit()
    print(m // lcm - m // (lcm * 2))


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import sys
import fractions


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    gcd = a[0]
    lcm = a[0]
    for i in range(1, n):
        gcd = fractions.gcd(lcm, a[i])
        lcm = lcm * a[i] // gcd
    if int(lcm / 2) - lcm / 2 == 0:
        print(max((m - (lcm // 2)) // lcm + 1, 0))
    else:
        print(0)


if __name__ == '__main__':
    solve()
Problem p02852 (python)

Fixed submission:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    s = str(readline().rstrip().decode('utf-8'))
    cur = n
    ans = []
    while True:
        b = False
        for i in range(cur - m, cur):
            if 0 <= i < n + 1:
                if s[i] == "0":
                    b = True
                    ans.append(cur - i)
                    cur = i
                    break
        if not b:
            print(-1)
            exit()
        if cur == 0:
            ans.reverse()
            print(*ans)
            exit()


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    s = str(readline().rstrip().decode('utf-8'))
    cur = n
    ans = []
    while True:
        b = False
        for i in range(cur - m, cur):
            if s[i] == "0" and i >= 0:
                b = True
                ans.append(cur - i)
                cur = i
                break
        if not b:
            print(-1)
            exit()
        if cur == 0:
            ans.reverse()
            print(*ans)
            exit()


if __name__ == '__main__':
    solve()
Problem p02901 (python)

Fixed submission:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    pw = 2 ** n
    dp = [10 ** 20] * pw
    dp[0] = 0
    for i in range(m):
        a, b = list(map(int, input().rstrip('\n').split()))
        c = sum(2 ** (i - 1) for i in list(map(int, input().rstrip('\n').split())))
        for j in range(pw):
            if dp[j | c] > dp[j] + a:
                dp[j | c] = dp[j] + a
    if dp[-1] == 10 ** 20:
        print(-1)
    else:
        print(dp[-1])


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    pw = pow(2, n)
    dp = [10 ** 15] * pw
    dp[0] = 0
    for _ in range(m):
        a, b = list(map(int, input().rstrip('ap(int, input().rstrip('\n').split())))
        for i in range(pw):
            dp[c | i] = min(dp[c | i], dp[i] + a)
    print(dp[-1] if dp[-1] != 10 ** 15 else -1)


if __name__ == '__main__':
    solve()
Problem p02903 (python)

Fixed submission:
def slove():
    import sys
    input = sys.stdin.readline
    h, w, a, b = list(map(int, input().rstrip('\n').split()))
    for i in range(h):
        if i < b:
            print("".join(["0"] * a + ["1"] * (w - a)))
        else:
            print("".join(["1"] * a + ["0"] * (w - a)))


if __name__ == '__main__':
    slove()

Buggy submission (verdict: Runtime Error):
def slove():
    import sys
    input = sys.stdin.readline
    h, w, a, b = list(map(int, input().rstrip('\n').split()))
    for i in range(h):
        if i < b:
            print("".join(["0"] * a + ["1"] * (w - a)))
        else:
            print("".join(
    slove()
Problem p02929 (python)

Fixed submission:
import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s[i] + cnt) % 2 != 0:
        cnt += 1
    else:
        c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)
        cnt -= 1
    if cnt < 0:
        print(0)
        exit()
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
s = [0 if i == "W" else 1 for i in list(input())]
cnt = 0
c = 1
for i in range(n * 2):
    if (s
if cnt != 0:
    print(0)
else:
    print((c * math.factorial(n)) % (10 ** 9 + 7))
Problem p02937 (python)

Fixed submission:
import collections, bisect
s = tuple(input())
t = tuple(input())
ls = len(s)
idx = collections.defaultdict(list)
dct = collections.defaultdict(list)
ln = -1
loop = 0
for i, v in enumerate(s):
    idx[v].append(i)
for i in t:
    t_idx = idx[i]
    if t_idx:
        bn = bisect.bisect_left(t_idx, ln + 1)
        if bn >= len(t_idx):
            ln = t_idx[0]
            loop += 1
        else:
            ln = t_idx[bn]
    else:
        print(-1)
        exit()
print(ls * loop + ln + 1)

Buggy submission (verdict: Runtime Error):
import heapq
al = {"a": 0, "b": 1, "c": 2, "d": 3, "e": 4, "f": 5,
      "g": 6, "h": 7, "i": 8, "j": 9, "k": 10, "l": 11,
      "m": 12, "n": 13, "o": 14, "p": 15, "q": 16, "r": 17,
      "s": 18, "t": 19, "u": 20, "v": 21, "w": 22, "x": 23,
      "y": 24, "z": 25}
als = [[] for _ in range(26)]
for i in als:
    heapq.heapify(i)
s = list(input())
ls = len(s)
for i, v in enumerate(s):
    heapq.heappush(als[al[v]], i)
t = list(input())
last_no = 0
for i, v in enumerate(t):
    print(als, v)
    if len(als[al[v]]) != 0:
        while True:
            p = heapq.heappop(als[al[v]])
            heapq.heappush(als[al[v]], p + ls)
            if p > last_no:
                last_no = p
                break
    else:
        print(-1)
        exit()
print(last_no + 1)
Problem p02971 (python)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
b = a.copy()
b = sorted(b, reverse=True)
for i in a:
    if i == b[0]:
        print(b[1])
    else:
        print(b[0])

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = [int(input().rstrip('\n')) for _ in range(n)]
    b = sorted(a.copy(), reverse=True)
    for i in a:
        if i == b[0]:
            print(b[1])
        else:
            print(b[0])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = [int(input().rstrip('\n')) for _ in range(n)]
    b = sorted(a.copy(), reverse=True)
    for i in a:
        if i == b[0]:
            print(b[1])
        else:
            print(b[0])


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

Fixed submission:
def slove():
    import sys, heapq
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    v = list(map(int, input().rstrip('\n').split()))
    ms = 0
    for i in range(1, min(k + 1, len(v) + 1)):
        for j in range(i + 1):
            t = []
            heapq.heapify(t)
            if j != 0:
                for w in v[:j]:
                    heapq.heappush(t, w)
            if -i+j != 0:
                for w in v[-i+j:]:
                    heapq.heappush(t, w)
            for _ in range(k-i):
                if len(t) != 0:
                    p = heapq.heappop(t)
                    if p >= 0:
                        heapq.heappush(t, p)
                        break
                else:
                    break
            ms = max(ms, sum(t))
    print(ms)


if __name__ == '__main__':
    slove()

Buggy submission (verdict: Runtime Error):
def slove():
    import sys, heapq
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    v = list(map(int, input().rstrip('\n').split()))
    ms = 0
    t = []
    heapq.heapify(t)
    for i in range(1, k + 1):
        for j in range(i + 1):
            t.clear()
            if j != 0:
                for w in v[:j]:
                    heapq.heappush(t, w)
            if -i+j != 0:
                for w in v[-i+j:]:
                    heapq.heappush(t, w)
            for _ in range(k-i):
                if len(t) != 0:
                    p = heapq.heappop(t)
                    if p >= 0:
                        heapq.heappush(t, p)
                        break
            ms = max(ms, sum(t))
    print(ms)


if __name__ == '__main__':
    slove()