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

Fixed submission:
from heapq import heappop, heappush
import numpy as np



def dijkstra(graph, n, vst=0):
    distance = [float('inf')] * n
    distance[vst] = 0
    checked_v = [0] * n
    route = [''] * 10
    route[vst] = str(vst)
    dist = [float('inf')] * n
    dist[vst] = 0
    q = []
    heappush(q, (0, vst))
    for _ in range(n):
        while True:
            min_dist, search_v = heappop(q)
            if checked_v[search_v] == 0:
                break
        checked_v[search_v] = 1
        for to_v in range(n):
            if checked_v[to_v] == 0:
                cost = graph[search_v][to_v]
                if dist[search_v] + cost < dist[to_v]:
                    dist[to_v] = dist[search_v] + cost
                    route[to_v] = route[search_v] + str(to_v)
                    heappush(q, (dist[to_v], to_v))
    return dist


h, w = map(int, input().split())
graph = np.array([np.array(list(map(int, input().split()))) for _ in range(10)])
graph = np.transpose(graph)
dist = dijkstra(graph, 10, vst=1)


wall_num = []
for i in range(h):
    wall_num += list(map(int, input().split()))



ret = 0
for num in wall_num:
    if num != -1:
        ret += dist[num]


print(ret)

Buggy submission (verdict: Runtime Error):
from heapq import heappop, heappush
import numpy as np



def dijkstra(graph, n, vst=0):
    distance = [float('inf')] * n
    distance[vst] = 0
    checked_v = [0] * n
    route = [''] * 10
    route[vst] = str(vst)
    dist = [float('inf')] * n
    dist[vst] = 0
    q = []
    heappush(q, (0, vst))
    for _ in range(n):
        while True:
            min_dist, search_v = heappop(q)
            if checked_v[search_v] == 0:
                break
        checked_v[search_v] = 1
        for to_v in range(n):
            if checked_v[to_v] == 0:
                cost = graph[search_v][to_v]
                if dist[search_v] + cost < dist[to_v]:
                    dist[to_v] = dist[search_v] + cost
                    route[to_v] = route[search_v] + str(to_v)
                    heappush(q, (dist[to_v], to_v))
    return dist


h, w = map(int, input().split())
graph = np.array([np.array(list(map(int, input().split()))) for _ in range(10)])
graph = np.transpose(graph)
dist = dijkstra(graph, 10, vst=1)


wall_num = []
for i in range(h):
    wall_num += list(map(int, input().split()))



ret = 0
for num in wall_num:
    if num != -1:
        ret += dist[num]


print(ret)
Problem p03671 (python)

Fixed submission:
a, b, c = map(int, input().split())
print(min(a+b, a+c, b+c))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input())
print(a+b, a+c, b+c)
Problem p03732 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n, limit = LI()
weight = []
value = []
for w, v in LIR(n):
    weight += [w]
    value += [v]


w1 = min(weight)
w2, w3, w4 = w1 + 1, w1 + 2, w1 + 3
w1_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w1], reverse=True)))
w2_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w2], reverse=True)))
w3_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w3], reverse=True)))
w4_list = [0] + list(accumulate(sorted([value[i] for i in range(n) if weight[i] == w4], reverse=True)))


ans = 0
for i, j, k, l in product(range(len(w1_list)), range(len(w2_list)), range(len(w3_list)), range(len(w4_list) )):
    if i * w1 + j * w2 + k * w3 + l * w4 > limit:
        continue
    ans = max(ans, w1_list[i] + w2_list[j] + w3_list[k] + w4_list[l])



print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



n, w = LI()
weight, value = list(zip(*LIR(n)))
dp = (w + 1) * [0]
for i in range(n):
    for j in range(w, weight[i]-1, -1):
        dp[j] = max(dp[j], dp[j - weight[i]] + value[i])



print(dp[-1])
Problem p03747 (python)

Fixed submission:
n, l, t = list(map(int, input().split()))
ants = []
for i in range(n):
    ants.append(list(map(int, input().split())))
normal_ant = [i for i, direction in ants if direction==1]
counter_ant = [i for i, direction in ants if direction==2]
cnt = (t // l) * len(normal_ant) + sum([1 for i in normal_ant if i + t%l >= l])
counter_cnt = (t // l) * len(counter_ant) + sum([1 for i in counter_ant if i - t%l < 0])
final_pos = sorted([(i-t)%l for i in counter_ant] + [(i+t)%l for i in normal_ant])
print(*final_pos[(cnt-counter_cnt)%n:] + final_pos[:(cnt-counter_cnt)%n], sep='\n')

Buggy submission (verdict: Runtime Error):
normal_ant = [i for i, direction in ants if direction==1]
counter_ant = [i for i, direction in ants if direction==2]
cnt = (t // l) * len(normal_ant) + sum([1 for i in normal_ant if i + t%l >= l])
counter_cnt = (t // l) * len(counter_ant) + sum([1 for i in counter_ant if i - t%l < 0])
final_pos = sorted([(i-t)%l for i in counter_ant] + [(i+t)%l for i in normal_ant])
print(*final_pos[(cnt-counter_cnt)%n:] + final_pos[:(cnt-counter_cnt)%n], sep='\n')
Problem p03837 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
graph = [[INF] * n for _ in range(n)]
for i in range(n):
    graph[i][i] = 0


for a, b, c in LIR(m):
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c


dist = [[graph[i][j] for j in range(n)] for i in range(n)]




for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k]=min(dist[j][i]+dist[i][k], dist[j][k])



cnt = 0
for i in range(n):
    for j in range(i, n):
        if graph[i][j] != INF and graph[i][j] > dist[i][j]:
            cnt += 1


print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce
from scipy.sparse.csgraph import floyd_warshall, csgraph_from_dense


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
graph = [[INF] * n for _ in range(n)]
for i in range(n):
    graph[i][i] = 0


for a, b, c in LIR(m):
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c


dist = [[graph[i][j] for j in range(n)] for i in range(n)]




for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k]=min(dist[j][i]+dist[i][k], dist[j][k])



cnt = 0
for i in range(n):
    for j in range(i, n):
        if graph[i][j] != INF and graph[i][j] > dist[i][j]:
            cnt += 1


print(cnt)
Problem p02683 (python)

Fixed submission:
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=[i[0] for i in suml if all([i[j] >=x for j in range(1,m+1)])]
if len(ans)==0:
  print(-1)
else:
  print(min(ans))

Buggy submission (verdict: Runtime Error):
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=[i[0] for i in suml if all([i[j] >=x for j in range(1,n+1)])]
if len(ans)==0:
  print(-1)
else:
  print(min(ans))

Buggy submission (verdict: Runtime Error):
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=min([i[0] for i in suml if all([i[j] >=x for j in range(1,6)])])
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import *
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()] for j in range(n)]
c=[i[0] for i in l]
l=[i[1:] for i in l]
p=list(product([0,1],repeat=m))
s=[[sum([l[k][j]*i[j] for k in range(n)]) for j in range(m)] for i in p]
print(s)
s=[c[i] for i in range(n) if all([s[i][j]>=x for j in range(m)])]
print(s)
Problem p03060 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
m=list(map(int,input().split()))
def f(x):
	return l[x]-m[x]
print(sum([f(i) for i in range(n) if f(i)>0]))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=map(int,input().split())
m=map(int,input().split())
def f(x):
	return l[x]-m[x]
print(sum([f(i) for i in range(n) if f(i)>0]))
Problem p03076 (python)

Fixed submission:
l=sorted(list(map(int,open(0))),key=lambda x:-x%10)
print(sum([i+(-i%10) for i in l[:4]])+l[4])

Buggy submission (verdict: Runtime Error):
*l=map(int,open(0))
while len(l)==0:
	ans=max(ans,max(l))
	l.remove(max(l))
	map(lambda x:x+10,l)
print(ans)
Problem p02630 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = [0 for _ in range(10 ** 5 + 1)]
count = 0
for i in a:
    dic[i] += 1
    count += i

for i in range(q):
    b, c = map(int,input().split())
    count -= b * dic[b]
    dic[c] += dic[b]
    count += c * dic[b]
    dic[b] = 0
    print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
dic = [0 for _ in range(10 ** 5)]
count = 0
for i in a:
    dic[i] += 1
    count += i

for i in range(q):
    b, c = map(int,input().split())
    count -= b * dic[b]
    dic[c] += dic[b]
    count += c * dic[b]
    dic[b] = 0
    print(count)
Problem p02658 (python)

Fixed submission:
n = int(input())
lis = list(map(int,input().split()))
ans = 1
if 0 in lis:
  print(0)
  exit()
for num in lis:
  ans *= num
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
count = 1
if 0 in a:
  print(0)
  exit()
for num in a:
    count *= num
	if count > 10**18:
      print(-1)
      exit()
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
count = 1
if 0 in a:
  print(0)
  exit()
for num in a:
    count *= num
	if count > 10**18:
    	print(-1)
        exit()
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
lis=list(map(int,input().split()))
count=1
if 0 in lis:
  print(0)
  exit()
for i in lis:
    count *= i
	if count > 10**18:
    	print(-1)
        exit()
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
lis=list(map(int,input().split()))
count=1
if 0 in lis:
  print(0)
  exit()
for num in lis:
    count *= num
	if count > 10**18:
    	print(-1)
        exit()
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
lis=list(map(int,input().split()))
count=1
if 0 in lis:
  print(0)
  exit()
for i in lis:
    count *= i
	if count > 10**18:
    	print(-1)
        exit()
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
lis=list(map(int,input().split()))
count=1
if 0 in lis:
  print(0)
  exit()
for i in lis:
    count*=i
	if count > 10**18:
    	print(-1)
        exit()
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
lis=list(map(int,input().split()))
count=1
if 0 in lis:
  print(0)
  exit()
for i in lis:
    count*=i
	if count>10**18:
    	print(-1)
        exit()
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
count=1
if 0 in a:
  print(0)
  exit()
for i in a:
    count*=i
	if count>10**18:
    	print(-1)
        exit()
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
count=1
if 0 in a:
  print(0)
  exit(0)
for i in a:
    count*=i
	if count>10**18:
    	print(-1)
        exit(0)
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
count=1
if 0 in a:
  print(0)
  exit(0)
for i in a:
    count*=i
	if count>10**18:
    	print(-1)
        exit(0)
else:
    print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
count=1
if 0 in a:
  print(0)
  exit(0)
for i in a:
    count=count*i
	if count>10**18:
    	print(-1)
        exit(0)
else:
    print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
count=1
if 0 in a:
  print(0)
  exit(0)
for i in range(n):
    count=count*a[i]
	if count>10**18:
    	print(-1)
        exit(0)
else:
    print(count)
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
rec = [0]
i = 0
flag = [0 for _ in range(n + 1)]
while True:
    if flag[rec[i]] == 0:
        flag[rec[i]] = 1
        rec.append(a[rec[i]] - 1)
    else:
        start = rec.index(a[rec[i]] - 1)
        loop = rec[start:]
        pre = rec[:start]
        break
    i += 1
count = (k - len(pre)) % len(loop)
if k <= len(pre):
    print(pre[k] + 1)
else:
    print(loop[count] + 1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
rec = [0]
i = 0
flag = [0 for _ in range(n + 1)]
while True:
    if flag[rec[i]] == 0:
        flag[rec[i]] = 1
        rec.append(a[rec[i]] - 1)
    else:
        start = rec.index(a[rec[i]] - 1)
        loop = rec[start:]
        pre = rec[:start]
        break
    i += 1
count = (k - len(pre)) % len(loop)
if k < len(pre):
    print(loop[k])
else:
    print(loop[count] + 1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
rec = [0]
i = 0
flag = [0 for _ in range(n + 1)]
while True:
    if flag[rec[i]] == 0:
        flag[a[i]] = 1
        rec.append(a[rec[i]] - 1)
    else:
        start = rec.index(a[rec[i]] - 1)
        loop = rec[start:]
        pre = rec[:start]
        break
    i += 1
count = (k - len(pre)) % len(loop)
print(loop[count] + 1)
Problem p02713 (python)

Fixed submission:
import math as np
K=int(input())
P=0
for i in range(1,K+1):
    for j in range(1,K+1):
        l=np.gcd(i,j)

        for k in range(1,K+1):
            m=np.gcd(l,k)
            P=m+P
print(P)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=str(input())
list_R=[]
list_G=[]
list_B=[]
count=0
for i in range(N):
    if S[i]=="R":
        list_R.append(i)
    if S[i]=="G":
        list_G.append(i)
    if S[i]=="B":
        list_B.append(i)
for i in range(N):
    for j in range(N):
        if i+2*j>N-1:
            break
        if S[i]!=S[i+j] and S[i+j]!=S[i+j*2] and S[i+2*j]!=S[i]:
            count=count+1

print(len(list_B)*len(list_G)*len(list_R)-count)
Problem p02718 (python)

Fixed submission:
N,M=(int(i) for i in input().split())
A=list(map(int,input().split()))
S=len(A)
mono=0
soutoku=0
for i in range(S):
    soutoku=soutoku+A[i]
for i in range(S):
    if A[i]>=soutoku/(4*M):
        mono=mono+1
if mono>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split()]
A=list(int(input()))
for i in range(M):
    if A[i]>1/(4*M):
        print("Yes")
        exit()
print("No")
Problem p02761 (python)

Fixed submission:
N,M=[int(i) for i in input().split()]
# 二次元配列を得られる
A = []
answer=[-1]*N
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == -1:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if j==0 and answer[0]==0 and N!=1:
    j=j+1
    print(-1)
if j==0 and (answer[0]==0 or answer[0]==-1) and N == 1:
    j=j+1
    print(0)
if j==0:
    for i in range(N):
        if answer[i]==-1:
            '''
            N = 5 case
            -1,7,-1,9,0
            ?7?90
            5 digits
            17090 
            '''
            if i == 0 :
                answer[0]=1
            else:
                answer[i]=0

        seisu=answer[i]*(10**(N-i-1))+seisu
    print(seisu)

Buggy submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split()]
# 二次元配列を得られる
A = []
answer=[0]*M
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == 0:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if j==0 and answer[0]==0 and N!=1:
    j=j+1
    print(-1)
if j==0:
    for i in range(M):
        seisu=answer[i]*(10**(M-i-1))+seisu
    print(seisu)

Buggy submission (verdict: Runtime Error):
N,M=[int(i) for i in input() .split()]
# 二次元配列を得られる
A = []
answer=[0]*M
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == 0:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if j==0 and answer[0]==0:
    j=j+1
    print(-1)
if j==0:
    for i in range(M):
        seisu=answer[i]*(10**(M-i-1))+seisu
    print(seisu)

Buggy submission (verdict: Runtime Error):
N,M=[int(i) for i in input() .split()]
# 二次元配列を得られる
A = []
answer=[0]*M
for i in range(M):
    A.append(list(map(int,input().split())))
j=0
for i in range(M):
    if answer[int(A[i][0])-1] == 0:
        answer[int(A[i][0])-1] = int(A[i][1])
    elif answer[int(A[i][0])-1] == int(A[i][1]):
        answer[int(A[i][0])-1] = int(A[i][1])
    else:
        print(-1)
        j=j+1
        break
seisu=0
if answer[0]==0:
    j=j+1
    print(-1)

if j==0:
    for i in range(M):
        seisu=answer[M-1-i]*(10**(M-i-1))+seisu
    print(seisu)
Problem p02882 (python)

Fixed submission:
import math
a,b,x=map(int,input().split())
if a*a*b/2<x:
    theta=(2*b-2*x/a**2)/a
else:
    theta=b**2*a/2/x
print(math.atan(theta)*180/math.pi)

Buggy submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
if a*a*b/2<x:
    theta=a/(2*b-2*x/a**2)
else:
    theta=2*x/(a*b*b)
print(90-math.atan(theta)*180/math.pi)

Buggy submission (verdict: Runtime Error):
import fractions as math
a,b,x=map(int,input().split())
if a*a*b/2<x:
    theta=a/(2*b-2*x/a**2)
else:
    theta=2*x/(a*b*b)
print(90-math.atan(theta)*180/math.pi)

Buggy submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
if a*a*b/2<x:
    theta=a/(2*b-2*x/a**2)
else:
    theta=2*x/(a*b*b)
print(90-math.atan(theta)*180/math.pi)
Problem p02971 (python)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
m = max(a)
p = a.index(m)
a.remove(m)
s = max(a)
for i in range(n):
    if i != p:
        print(m)
    else:
        print(s)

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(n)]
m = max(a)
p = a.index(m)
s = max(a)
for i in range(n):
    if i != p:
        print(m)
    else:
        print(s)

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(n)]
m = max(a)
p = a.index(m)
a.remove(m)
s = max(a)
for i in range(n):
    if i != p:
        print(m)
    else:
        print(s)

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(n)]
m = max(a)
print(a)
p = a.index(m)
a.remove(m)
s = max(a)
print(s)
for i in range(n):
    if i != p:
        print(m)
    else:
        print(s)
Problem p02993 (python)

Fixed submission:
s = input()
if s[0] != s[1] and s[1] != s[2] and s[2] != s[3]:
    print("Good")
else:
    print("Bad")

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())

#cで割り切れる数+dで割り切れる数-gcd(c,d)で割り切れる数を求めればよい
ans=(b//c+b//d-b//(c*d//math.gcd(c,d)))-((a-1)//c+(a-1)//d-(a-1)//(c*d//math.gcd(c,d)))

print(b-a+1-ans)
Problem p03262 (python)

Fixed submission:
from fractions import gcd
n, x =map(int,input().split())
s = list(map(int,input().split()))
y = abs(s[0] - x)
for i in range(1,n):
    y = gcd(y, abs(s[i] - x))
print(y)

Buggy submission (verdict: Runtime Error):
from math import gcd
n, x =map(int,input().split())
s = list(map(int,input().split()))
y = abs(s[0] - x)
for i in range(1,n-1):
    y = gcd(y, abs(s[i] - x))
print(y)

Buggy submission (verdict: Runtime Error):
from fraction import gcd
n, x =map(int,input().split())
s = list(map(int,input().split()))
s.sort()
a, b = x - s[0], s[-1] - x
visit = [0] * n
while sum(visit) != n:
    visit = [0] * n
    y = gcd(a, b)
    i = 0
    while s[0] + y * i <= s[-1] :
        if s[0] + y * i in s:
            visit[s.index(s[0] + y * i)] = 1
        i += 1
    a,b = min(a, b), y
print(y)

Buggy submission (verdict: Runtime Error):
n, x =map(int,input().split())
s = list(map(int,input().split()))
s.sort()
a, b = x - s[0], s[-1] - x
visit = [0] * n
while sum(visit) != n:
    visit = [0] * n
    y = gcd(a, b)
    i = 0
    while s[0] + y * i <= s[-1] :
        if s[0] + y * i in s:
            visit[s.index(s[0] + y * i)] = 1
        i += 1
    a,b = min(a, b), y
print(y)