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

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
gap = [0]
mt = []
va = []
i = 0
while i+1 <= len(h)-1:
    if h[i+1]-h[i] != 0:
        gap.append(h[i+1]-h[i])
        i += 1
    else:
        h.pop(i+1)
for i in range(len(h)-1):    
    if gap[i] >= 0: 
        if gap[i+1] < 0:
            mt.append(h[i])
    else:
        if gap[i+1] > 0:
            va.append(h[i])
if gap[-1] > 0 :
    mt.append(h[-1])
if mt == []:
    mt.append(h[0])
ans = 0
for x in mt:
    ans += x
for x in va:
    ans -= x
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
gap = [0]
mt = []
va = []
i = 0
while i+1 <= len(h)-1:
    if h[i+1]-h[i] != 0:
        gap.append(h[i+1]-h[i])
        i += 1
    else:
        h.pop(i+1)
for i in range(h):    
    if gap[i] >= 0: 
        if gap[i+1] < 0:
            mt.append(h[i])
    else:
        if gap[i+1] > 0:
            va.append(h[i])
if gap[-1] > 0 :
    mt.append(h[-1])
if mt == []:
    mt.append(h[0])
ans = 0
for x in mt:
    ans += x
for x in va:
    ans -= x
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
gap = [0]
mt = []
va = []
i = 0
while i+1 <= len(h)-1:
    if h[i+1]-h[i] != 0:
        gap.append(h[i+1]-h[i])
        i += 1
    else:
        h.pop(i+1)
for i in range(h)    
    if gap[i] >= 0: 
        if gap[i+1] < 0:
            mt.append(h[i])
    else:
        if gap[i+1] > 0:
            va.append(h[i])
if gap[-1] > 0 :
    mt.append(h[-1])
if mt == []:
    mt.append(h[0])
ans = 0
for x in mt:
    ans += x
for x in va:
    ans -= x
print(ans)
Problem p03219 (python)

Fixed submission:
A,B = map(int, input().split())
print(A + B//2)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
from collections import defaultdict
d = defaultdict(list)
l = [[] for i in range(M)]
for i in range(M):
    P,Y = map(str, input().split())
    P = "0" * (6-len(P)) + P
    d[P] += [int(Y)]
    l[i] = [P,int(Y)]
for i in range(M):
    tmp = str((sorted(d[l[i][0]]).index(l[i][1]))+1)
    print(l[i][0] + "0" * (6-len(tmp)) + tmp)
Problem p03220 (python)

Fixed submission:
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
tmp = 1000
ans = 0
for i in range(N):
    if abs(A-T+H[i]*0.006)<tmp:
        tmp=abs(A-T+H[i]*0.006)
        ans=i+1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()) 
tmp=10**3
ans=0
for i in range(N):
    if abs(A-T+H[i]*0.006)<tmp:
        tmp=abs(A-T+H[i]*0.006)
        ans=i+1
print(ans)
Problem p03246 (python)

Fixed submission:
import collections
n = int(input())
v = list(map(int, input().split()))
even = [v[2*i] for i in range(n//2)]
odd = [v[2*i+1] for i in range(n//2)]
dEven = collections.Counter(even).most_common()
dOdd = collections.Counter(odd).most_common()
if dEven[0][0] != dOdd[0][0]:
    ans = n - dEven[0][1]  - dOdd[0][1]
else:
    if len(dEven) >=2 and len(dOdd) >= 2:
        ans = n - max(dEven[0][1]+dOdd[1][1], dEven[1][1]+dOdd[0][1])
    elif len(dEven) < len(dOdd):
        ans = n - (dEven[0][1]+dOdd[1][1])
    elif len(dEven) > len(dOdd):
        ans = n - (dEven[1][1]+dOdd[0][1])
    else:
        ans = n//2
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(int, input().split()))
even = [v[2*i] for i in range(n//2)]
odd = [v[2**i+1] for i in range(n//2)]
dEven = collections.Counter(even).most_common()
dOdd = collections.Counter(odd).most_common()
if dEven[0][0] != dOdd[0][0]:
    ans = n - dEven[0][1]  - dOdd[0][1]
else:
    ans = n - max(dEven[0][1]+dOdd[1][0], dEven[1][0]+dOdd[0][1])
print(ans)
Problem p02898 (python)

Fixed submission:
N,K = list(map(int,input().split()))[:2]
height = list(map(int,input().split()))[:N]
able2ride = [a for a in height if a >= K]
print(len(able2ride))

Buggy submission (verdict: Runtime Error):
N,K = list(map(int,input().split())).[:2]
height = list(map(int,input().split())).[:N]
able2ride = [a in height if a > K]
print(len(able2ride))
Problem p02993 (python)

Fixed submission:
code = input()
previous = 'a'
ch = True
for c in code:
    if previous == c:
        print('Bad')
        ch = False
        break
    previous = c
if ch:
    print('Good')

Buggy submission (verdict: Runtime Error):
code = input()
previous = 'a'
for c in code:
  if perivioud == c:
    print('bad')
    break
Problem p02999 (python)

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

Buggy submission (verdict: Runtime Error):
N,X = list(map(int,input().split(' ')))
L = list(map(int,input().split(' ')))[:N]

p = 0
count = 1

for i in range(1,N):
    p += L[i]
    if p <= X:
        count += 1
print(count)
Problem p03231 (python)

Fixed submission:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
def gcd(a, b):
    if a < b: return gcd(b, a)
    if b == 0: return a
    return gcd(b, a%b)
def lcm(a, b):
    return a * b // gcd(a, b)

n, m = il()
s = input()
t = input()
aa = gcd(n, m)
bb = lcm(n, m)
cc = aa // bb
for i in range(aa):
    if s[n//aa*i] != t[m//aa*i]:
        print(-1)
        exit()
print(bb)

Buggy submission (verdict: Runtime Error):
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
def gcd(a, b):
    if a < b: return gcd(b, a)
    if b == 0: return a
    return gcd(b, a%b)
def lcm(a, b):
    return a * b // gcd(a, b)

n, m = il()
s = input()
t = input()
ans = lcm(n, m)
hoge = "0" * ans
for i in range(n):
    nn = ans//n
    if hoge[i*nn] != "0" and hoge[i*nn] != s[i]:
        print(-1)
        exit()
    hoge = hoge[:i*nn] + s[i] + hoge[i*nn+1:]
for i in range(m):
    mm = ans//m
    if hoge[i*mm] != "0" and hoge[i*mm] != t[i]:
        print(-1)
        exit()
    hoge = hoge[:i*mm] + t[i] + hoge[i*mm+1:]
print(ans)
Problem p03240 (python)

Fixed submission:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
l = ils(n, "il()")

for i in range(101):
    for j in range(101):
        zero = []
        height = -1
        ok = 1
        for k in range(n):
            if l[k][2] == 0:
                zero.append(k)
                continue
            if height == -1:
                height = abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]
            if height != abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]:
                ok = 0
                break
        for k in zero:
            if height == -1:
                height = abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]
            if height > abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]:
                ok = 0
                break
        if ok:
            print(i, j, height)

Buggy submission (verdict: Runtime Error):
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
l = []
for i in range(n):
    a, b, c = il()
    l.append([a, b, c])
cx, cy = 0, 0
x, y = 0, 0
hoge = []
for i in range(n):
    for j in range(n):
        if i == j: continue
        if l[i][2] == l[j][2]:
            if l[i][0] == l[j][0] or l[i][1] == l[j][1]:
                hoge.append([i, j])
                print((l[i][0] + l[j][0]) // 2, (l[i][1] + l[j][1]) // 2, l[1][2]+1)
                exit()
a, b = hoge[0]
if l[a][0] == l[b][0]:
    if l[a][1] + l[b][1] > 100:
        print(l[a][0], 100, l[a][2]+1)
    else:
        print(l[a][0], 0, l[a][2]+1)
else:
    if l[a][0] + l[b][0] > 100:
        print(100, l[a][1], l[a][2]+1)
    else:
        print(0, l[a][1], l[a][2]+1)

Buggy submission (verdict: Runtime Error):
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
l = []
grid = [[-1] * 100 for _ in range(100)]
for i in range(n):
    a, b, c = il()
    grid[a][b] = c
    l.append(list(a, b, c))
cx, cy = 0, 0
x, y = 0, 0
hoge = []
for i in range(n):
    for j in range(n):
        if i == j: continue
        if l[i][2] == l[j][2]:
            if l[i][0] == l[j][0] or l[i][1] == l[j][1]:
                hoge.append(list(i, j))
                print((l[i][0] + l[j][0]) // 2, (l[i][1] + l[j][1]) // 2, l[1][2]+1)
                exit()
a, b = hoge[0]
if l[a][0] == l[b][0]:
    if l[a][1] + l[b][1] > 100:
        print(l[a][0], 100, l[a][2]+1)
    else:
        print(l[a][0], 0, l[a][2]+1)
else:
    if l[a][0] + l[b][0] > 100:
        print(100, l[a][1], l[a][2]+1)
    else:
        print(0, l[a][1], l[a][2]+1)
Problem p03246 (python)

Fixed submission:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
v = il()
a = dict()
b = dict()
for i in range(n):
    if i&1:
        if v[i] in a:
            a[v[i]] += 1
        else:
            a[v[i]] = 1
    else:
        if v[i] in b:
            b[v[i]] += 1
        else:
            b[v[i]] = 1
a = sorted(a.items(), key=lambda x:x[1])
b = sorted(b.items(), key=lambda x:x[1])

h = a[-1][0]
ans = n//2 - a[-1][1]
if b[-1][0] == h:
    if len(b) == 1:
        ans += n//2
    else:
        ans += n//2 - b[-2][1]
else:
    ans += n//2 - b[-1][1]

hoge = ans 

h = b[-1][0]
ans = n//2 - b[-1][1]
if a[-1][0] == h:
    if len(a) == 1:
        ans += n//2
    else:
        ans += n//2 - a[-2][1]
else:
    ans += n//2 - a[-1][1]

print(min(ans, hoge))

Buggy submission (verdict: Runtime Error):
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
v = il()
a = dict()
b = dict()
for i in range(n):
    if i&1:
        if v[i] in a:
            a[v[i]] += 1
        else:
            a[v[i]] = 1
    else:
        if v[i] in b:
            b[v[i]] += 1
        else:
            b[v[i]] = 1
ans = 0
a = sorted(a.items(), key=lambda x:x[1])
b = sorted(b.items(), key=lambda x:x[1])

if a[-1][0] == b[-1][0]:
    ans += min(a[-1][1], b[-1][1])
else:
    if len(a) > 1:
        ans += n//2 - a[-1][1]
    if len(b) > 1:
        ans += n//2 - B[-1][1]

print(ans)
Problem p03262 (python)

Fixed submission:
from functools import reduce
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def gcd_list(numbers):
    return reduce(gcd, numbers)
na = lambda: list(map(int, input().split()))
n, X = na()
x = na()
x.append(X)
x.sort()
l = []
for i in range(len(x)-1):
    l.append(x[i+1]-x[i])
print(gcd_list(l))

Buggy submission (verdict: Runtime Error):
import math
na = lambda: list(map(int, input().split()))
n, X = na()
x = na()
x.append(X)
x.sort()
l = []
for i in range(len(x)-1):
    l.append(x[i+1]-x[i])
ans = l[0]
for i in l[1:]:
    ans = math.gcd(ans, i)
print(ans)
Problem p03308 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
print(a[-1] - a[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
print(a[-1] - a[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
print(a[-1] - a[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
print(a[-1] - a[0])
Problem p03309 (python)

Fixed submission:
import math

n = int(input())
a = [int(i) for i in input().split()]
b = [elem - i for i, elem in enumerate(a, 1)]
b.sort()
center = b[math.floor(len(b) / 2)]
c = [abs(i - center) for i in b]
print(sum(c))

Buggy submission (verdict: Runtime Error):
from collections import counter
n = int(input())
a = [int(i) for i in input().split()]
output = 0
b = [abs(elem - i) for i, elem in enumerate(a, 1)]
c = counter(b)
d = c.most_common()

surume = 0
if len(d) == 1:
    surume = d[0][0]
else:
    if d[0][1] == d[1][1]:
        surume = 0
    else:
        surume = d[0][0]
e = [abs(abs(elem - i) - abs(surume)) for i, elem in enumerate(a, 1)]
print(sum(e))
Problem p03352 (python)

Fixed submission:
x = int(input())
a = [1]
for i in range(2, x+1):
    cnt = 2
    while i ** cnt <= x:
        a.append(i ** cnt)
        cnt += 1
print(max(a))

Buggy submission (verdict: Runtime Error):
x = int(input())
a = []
for i in range(2, x+1):
    for j in range(2, x+1):
        b = i ** j
        a.append(b if b <= x else 0)
print(max(a))
Problem p03386 (python)

Fixed submission:
a, b, k = map(int, input().split())
for i in range(a, min(b+1, a+k)):
    print(i)
for i in range(max(b-k+1, a+k), b+1):
    print(i)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
if b - a + 1 <= k:
    for i in range(a, b+1):
        print(i):
else:
    for i in range(a, a+k-1):
        print(i)
    for i in range(b-k+1, b):
        print(i)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
c = list(range(a, b+1))
if len(c) < 2*k:
    for i in c:
        print(i)
else:
    for i in c[:k] + c[-k:]:
        print(i)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
c = list(range(a, b+1))
if len(c) <= 2*k:
    for i in c:
        print(i)
else:
    for i in c[:k] + c[-k:]:
        print(i)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
l = list(range(a, b+1))
for i in sorted(list(set(l[:k] + l[-k:]))):
    print(i)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
l = list(range(a, b+1))
for i in set(l[:k] + l[-k:]):
    print(i)
Problem p03495 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
dic = {}
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
dic = sorted(dic.items(), key=lambda x: x[1])
#while len(dic) > k:
#    ans += dic[0][1]    
#    del dic[0]
for i in range(len(dic)-k):
    ans += dic[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split())
ans = 0
dic = {}
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
dic = sorted(dic.items(), key=lambda x: x[1])
while len(dic) > k:
    ans += dic[0][1]    
    del dic[0]
print(ans)
Problem p03543 (python)

Fixed submission:
n = list(map(int, input()))
n.sort()
if n[0] == n[1] == n[2]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
if len(set(n)) <= 2:
    print("Yes")
else:
    print("No")
Problem p03555 (python)

Fixed submission:
a = input()
b = input()
if (a[0] == b[2]) and (a[1] == b[1]) and (a[2] == b[0]):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
if aa[0] == b[2] and a[1] == b[1] and [2] == b[0]:
    print("YES")
else:
    print("NO")
Problem p03573 (python)

Fixed submission:
a = input().split()
a.sort()
if a[0] == a[1]:
    print(a[2])
else:
    print(a[0])

Buggy submission (verdict: Runtime Error):
a = map(int, input())
a.sort()
if a == b:
    print(c)
else:
    print(a)
Problem p03633 (python)

Fixed submission:
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
def gcd(a, b):
    if a < b: return gcd(b, a)
    if b == 0: return a
    return gcd(b, a%b)

n = int(input())
t = ils(n)
ans = t[0]
for i in t[1:]:
    ans = ans * i // gcd(ans, i)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
t = ils(n)
ans = t[0]
for i in t[1:]:
    ans = ans * i // math.gcd(ans, i)
print(ans)
Problem p03698 (python)

Fixed submission:
s = input()
if sorted(list(s)) == sorted(list((set(s)))):
    print("yes")
else:
    print("no")

Buggy submission (verdict: Runtime Error):
s = input()
if s == str((set(s)):
    print("yes")
else:
    print("no")
Problem p03773 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(input().split())
print((a+b)%24)
Problem p03795 (python)

Fixed submission:
n = int(input())
print(800*n-n//15*200)

Buggy submission (verdict: Runtime Error):
n = (input())
print(800*n-n%15*200)
Problem p02675 (python)

Fixed submission:
n = input()
if(n[-1]=="3")or(n=="3"):
    print("bon")
elif(n[-1]=="0")or(n[-1]=="1")or(n[-1]=="6")or(n[-1]=="8")or(n=="0")or(n=="1")or(n=="6")or(n=="8"):
    print("pon")
else:
    print("hon")

Buggy submission (verdict: Runtime Error):
n = input()
if(n[2]==3):
    print("bon")
elif(n[2]==0)or(n[2]==1)or(n[2]==6)or(n[2]==8):
    print("pon")
else:
    print("hon")
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print(f"{c} {a} {b}")
Problem p02885 (python)

Fixed submission:
a,b = map(int,input().split())
if(a > b * 2):
    print(a-b * 2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a.b = map(int,input().split())
if(a > b * 2):
    print(a-b * 2)
else:
    print(0)
Problem p02993 (python)

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

Buggy submission (verdict: Runtime Error):
s = input()
if(s[0]==s[1]):
    print("Bad")
elif(s[1]==s[2]):
    print("Bad")
elif(s[2]==s[3]):
    print("Bad")
elif(s[3]==s[4]):
    print("Bad")
else:
    print("Good")
Problem p03852 (python)

Fixed submission:
a = input()
if ((a == "a") or (a == "i") or (a == "u") or (a == "o") or (a == "e")):
    print("vowel")
else:
    print("consonant")

Buggy submission (verdict: Runtime Error):
a = input()
if ((a == "a") or (a == "i") or (a == "u") or (a == "o") or (a == "e"))
    print("vowel")
else:
    print("consonant")
Problem p02583 (python)

Fixed submission:
import numpy as np
from numba import *

N = int(input())
length = np.array(input().split(), np.int64)

length = np.sort(length)

@njit
def calc(cache=True):
    cnt = 0

    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                l1, l2, l3 = length[i], length[j], length[k]
                if (l1 != l2 and l1 != l3 and l2 != l3):
                    if (l1 + l2 > l3):
                        cnt += 1
    
    return (cnt)

ans = calc()
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import *

import sys
read = sys.stdin.buffer.read


# N = int(input())
# length = np.array(input().split(), np.int64)
length = np.array(read.split(), np.int64)[1:]


length = np.sort(length)

@njit((i8[:],), cache=True)
def calc(length):
    cnt = 0
    
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                l1, l2, l3 = length[i], length[j], length[k]
                if (l1 != l2 and l1 != l3 and l2 != l3):
                    if (l1 + l2 > l3):
                        cnt += 1
    
    return (cnt)

ans = calc(length)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import *

import sys
read = sys.stdin.buffer.read


N = int(input())
# length = np.array(input().split(), np.int64)
length = np.array(read.split(), np.int64)[1:]


length = np.sort(length)

@njit((i8[:],), cache=True)
def calc(length):
    cnt = 0
    
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                l1, l2, l3 = length[i], length[j], length[k]
                if (l1 != l2 and l1 != l3 and l2 != l3):
                    if (l1 + l2 > l3):
                        cnt += 1
    
    return (cnt)

ans = calc(length)
print(ans)
Problem p02608 (python)

Fixed submission:
def main():
    import math

    N = int(input())
    
    ans_list = [0 for i in range(N)]
    
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):

                left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                if (left_eq <= N):
                    ans_list[left_eq - 1] += 1
    
    for i in range(N):
        print(ans_list[i])

if __name__ == '__main__':
    main()

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

    
    for n in range(1, N + 1):

        max_itr = min(101, int(math.sqrt(n)) + 1)
                
        
        ans = 0

        for x in range(1, max_itr):
            for y in range(1, max_itr):
                for z in range(1, max_itr):

                    # left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                    left_eq=x**2+y**2+z**2+x*y+y*z+z*x
                    if (left_eq == n):
                        ans += 1
        
        
        print(ans)


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

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

Buggy submission (verdict: Runtime Error):
a = int(input())
ans = a + a * a + a * a * a
print(ans)a = int(input())
Problem p02678 (python)

Fixed submission:
def main():
    from collections import deque

    N, M = map(int, input().split())
    connected_rooms = [[] for i in range(N + 1)]
    
    for i in range(M):
        a, b = map(int, input().split())
        connected_rooms[a].append(b)
        connected_rooms[b].append(a)
    
    def Breadth_First_Search(root):
        queue = deque([root]) #calculate distance from the root
        distance = [None] * (N + 1) #initialize distance
        distance[root] = 0
        
        while (queue): #do BFS and calculate distance recursively
            ver = queue.popleft()
            
            for index in connected_rooms[ver]:
                if (distance[index] == None):
                    distance[index] = distance[ver] + 1
                    queue.append(i)
        
        return (distance)
    
    dist = [None] * (N + 1)
    dist[0] = True
    
    Q = deque([1])
    while (Q):
        index = Q.popleft()
        for j in connected_rooms[index]:
            if (dist[j] == None):
                dist[j] = index
                Q.append(j)
    
    if (all(dist)):
        print('Yes')
        for i in dist[2:]:
            print(i)
    else:
        print('No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from collections import deque

    N, M = map(int, input().split())
    connected_rooms = [[] for i in range(N + 1)]
    
    for i in range(M):
        a, b = map(int, input().split())
        connected_rooms[a].append(b)
        connected_rooms[b].append(a)
    
    def Breadth_First_Search(root):
        queue = deque([root]) #calculate distance from the root
        distance = [None] * (N + 1) #initialize distance
        distance[root] = 0
        
        while (queue): #do BFS and calculate distance recursively
            ver = queue.popleft()
            
            for index in connected_rooms[ver]:
                if (distance[index] == None):
                    distance[index] = distance[ver] + 1
                    queue.append(index)
        
        return (distance)
    
    dist = [None] * (N + 1)
    dist[0] = True
    
    Q = deque([1])
    while (Q):
        index = Q.popleft()
        for j in connected_rooms[index]:
            if (dist[j] == None):
                
                # dist[j] = index
                dist[j] = dist[index] + 1
                
                Q.append(j)
    
    if (all(dist)):
        print('Yes')
        for i in dist[2:]:
            print(i)
    else:
        print('No')


if __name__ == '__main__':
    main()