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

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
A.sort()
if A[0]==0:
    print(0)
    exit()

ans = 1
for i in A:
    ans*=i
    if ans>1e18:
        print(-1)
        exit()

print(ans)

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

ans = 1
for i in range(n):
    ans = ans * a[i]
    
if ans <= 1e18:
    print(ans)  
else:
    print(-1)

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

ans = 1
for i in range(n):
    ans = ans * a[i]
    
if ans <= 10 ** 18:
    print(ans)  
else:
    print(-1)

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

ans = 1
for i in range(n):
    ans=ans*a[i]
    
if ans<= 10**18:
    print(ans)
    
else:
    print(-1)
Problem p02608 (python)

Fixed submission:
# vim: fileencoding=utf-8


def main():
    N = int(input())
    ans = [0] * N
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                t = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x - 1
                if t >= len(ans):
                    break
                ans[t] += 1

    print(*ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# vim: fileencoding=utf-8


def main():
    N = int(input())
    for n in range(1, N + 1):
        ans = 0
        if n <= 5:
            print(ans)
            continue

        zMax = int((N + 1) / 6) + 1
        print(f"{n}")
        for x in range(1, int((N + 1) / 6) + 1):
            tx = x ** 2
            if tx + x + 3 >= n or x >= zMax:
                break
            for y in range(x, int((N + 1) / 6) + 1):
                ty = tx + y ** 2 + x * y
                if ty + y + x + 1 >= n or y >= zMax:
                    break
                for z in range(y, int((N + 1) / 6) + 1):
                    print(f"x :{x} y :{y} z :{z}")
                    t = ty + z ** 2 + y * z + z * x
                    if t == n:
                        print(f"ans x :{x} y :{y} z :{z}")
                        if x == y and x == z:
                            ans += 1
                        elif x == y or y == z:
                            ans += 3
                        else:
                            ans += 6
                        if z <= zMax:
                            zMax = z
                        break
                    if t >= n:
                        break
        print(ans)


if __name__ == "__main__":
    main()
Problem p03361 (python)

Fixed submission:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, S: "List[str]"):
    for i in range(H):
        for j in range(W):
            if S[i][j] == ".":
                continue
            if i - 1 >= 0:
                if S[i - 1][j] == "#":
                    continue
            if i + 1 < H:
                if S[i + 1][j] == "#":
                    continue
            if j - 1 >= 0 and S[i][j - 1] == "#":
                continue
            if j + 1 < W and S[i][j + 1] == "#":
                continue
            print(NO)
            return
    print(YES)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [list(next(tokens)) for _ in range(H)]  # type: "List[str]"
    solve(H, W, S)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, S: "List[str]"):
    for i in range(H):
        for j in range(W):
            if S[i][j] == ".":
                continue
            if i - 1 >= 0:
                if S[i - 1][j] == "#":
                    continue
            if i + 1 < H:
                if S[i + 1][j] == "#":
                    continue
            if j - 1 >= 0 and S[i][j - 1] == "#":
                continue
            if j + 1 < W and S[i][j + 1] == "#":
                continue
            print(NO)
            return
    print(YES)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [list(next(tokens)) for _ in range(W)]  # type: "List[str]"
    solve(H, W, S)


if __name__ == "__main__":
    main()
Problem p03369 (python)

Fixed submission:
# vim: fileencoding=utf-8


def main():
    s = input()
    p = 700
    if s[0] == "o":
        p += 100
    if s[1] == "o":
        p += 100
    if s[2] == "o":
        p += 100
    print(p)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# vim: fileencoding=utf-8


def main():
    s = input()
    p = 700
    if s[0] == 'o';
        p += 100
    if s[1] == 'o';
        p += 100
    if s[2] == 'o';
        p += 100
    print(p)


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

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: int, A: "List[int]"):
    ans = 0
    for i in range(X-1, 0, -1):
        if i in A:
            ans += 1
    c = 0
    for i in range(X+1, N):
        if i in A:
            c += 1
    if ans > c:
        ans = c
    print(ans)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, X, A)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: int, A: "List[int]"):
    ans = 0
    for i in range(X-1, 0, -1):
        if i in A:
            ans += 1
    c = 0
    for i in range(X+1, N):
        if i in A:
            c += 1
    if ans > c:
        ans = c
    print(ans)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, X, A)

if __name__ == '__main__':
Problem p02574 (python)

Fixed submission:
import math
n=int(input())
a=list(map(int,input().split()))
mxa=max(a)

def get_sieve_of_eratosthenes(mxa):
    fact = [0]*(mxa+1)
    limit = int(math.sqrt(mxa))
    for i in range(2,limit+1):
        if fact[i]!=0:
            continue
        else:
            fact[i]=i
            for j in range(i, mxa+1, i):
                if fact[j]==0:
                    fact[j]=i
    for i in range(2,mxa+1):
        if fact[i]==0:
            fact[i]=i

    return fact

fact = get_sieve_of_eratosthenes(mxa)

lst=[0]*(len(fact))
for i in range(n):
    divisor = set()
    while a[i]!=1:
        divisor.add(fact[a[i]])
        a[i]//=fact[a[i]]
    for d in divisor:
        lst[d]+=1

pair=True
st=True

for i in lst:
    if i>=2:
        pair=False
    if i==n:
        st=False
if pair:
    print("pairwise coprime")
elif st:
    print("setwise coprime")
else:
    print("not coprime")

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
mxa=max(a)

def get_sieve_of_eratosthenes(mxa):
    fact = [0]*(mxa+1)
    limit = math.sqrt(mxa)
    data = [i + 1 for i in range(1, mxa)]
    while True:
        p = data[0]
        if limit <= p:
            return fact
        fact[p]=p
        for i in data:
            if i%p==0:
                fact[i]=p
        data = [e for e in data if e % p != 0]

fact= get_sieve_of_eratosthenes(mxa)

for i,j in enumerate(fact):
    if j==0:
        fact[i]=i
lst=[0]*(len(fact))
for i in range(n):
    prm_check = [False]*(mxa+1)
    while a[i]!=1:
        if not prm_check[fact[a[i]]]:
            lst[fact[a[i]]]+=1
            prm_check[fact[a[i]]] = True
        a[i]//=fact[a[i]]


pair=True
st=True

for i in lst:
    if i>=2:
        pair=False
    if i==n:
        st=False

if pair:
    print("pairwise coprime")
elif st:
    print("setwise coprime")
else:
    print("not coprime")

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

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


data = get_sieve_of_eratosthenes(max(a))
lst=[0]*(len(data))
for num in a:
    for i,datum in enumerate(data):
        if datum>num:
            break
        if num%datum==0:
            lst[i]+=1
            num//=datum

pair=True
st=True

for i in lst:
    if i>=2:
        pair=False
    if i==n:
        st=False

if pair:
    print("pairwise coprime")
elif st:
    print("setwise coprime")
else:
    print("not coprime")
Problem p02658 (python)

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


if 0 in a:
    print(0)
else:
    ans=1
    i=0
    while ans<=10**18 and i<n:
        ans*=a[i]
        i+=1

    if ans>10**18:
        print("-1")
    else:
        print(ans)

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

ans=1
i=0
while ans<=10**18:
    ans*=a[i]
    i+=1
    
if ans>10**18:
    print("-1")
else:
    print(ans)
Problem p02713 (python)

Fixed submission:
import math
k = int(input())

sm=0
for i in range(1,k+1):
    for l in range(1,k+1):
        gcdab=math.gcd(i,l)
        for m in range(1,k+1):
            sm+=math.gcd(gcdab,m)

print(sm)

Buggy submission (verdict: Runtime Error):
from fractions import math

k = int(input())

g =[gcd(math.gcd(i+1, j+1), l+1) for i in range(k) for j in range(k) for l in range(k)]
print(sum(g))
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()

al=s.count("R")*s.count("G")*s.count("B")

for i in range(n-2):
    for k in range(i+1,n-1):
        l=k+(k-i)
        if l>=n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)

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

rcount=0
gcount=0
bcount=0
for i in range(n):
    if s[i]=="R":
        rcount+=1
    elif s[i]=="G":
        gcount+=1
    else:
        bcount+=1

al=rcount*bcount*gcount

for i in range(n-2):
    for k in range(i+1,n):
        dis=k-i
        l=k+dis
        if k+dis>n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)
Problem p02717 (python)

Fixed submission:
X, Y, Z =(map(int,input().split()))
A = X
B = Y
C = Z

B2 = A
A2 = B

A3 = C
C3 = A2

print(A3, B2, C3)

Buggy submission (verdict: Runtime Error):
X, Y, Z = input()
A = X
B = Y
C = Z

B2 = A
A2 = B

A3 = C
C3 = A2

print(A3, B2, C3)
Problem p02719 (python)

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

a = N // K
b = abs(N - (K*a))
c = abs(N - (K*(a+1)))
print(min(b, c))

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

a = N // K
b = abs(N - (K*a))
c = abs(N - (K*(a+1)))
print(min(b, c))
Problem p02727 (python)

Fixed submission:
x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]
p.extend(q)
p.sort()

idx=0
for i in range(len(p)):
    if p[i]>r[idx]:
        break
    else:
        p[i]=r[idx]
        idx+=1
        if c==idx:
            break

print(sum(p))

Buggy submission (verdict: Runtime Error):
x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]

p_idx=0
q_idx=0
plen=len(p)
qlen=len(q)
for i in range(c):
    #処理が終わる時
    if p[p_idx]>r[i] and q[q_idx]>r[i]:
        break
    #全部入れ替わる
    if p_idx==plen and q_idx==qlen:
        break
    if q_idx==qlen:
        if p[p_idx]>r[i]:
            break
        else:
            p[p_idx]=r[i]
            p_idx+=1
    if p_idx==plen:
        if q[q_idx]>r[i]:
            break
        else:
            q[q_idx]=r[i]
            q_idx+=1
    if p[p_idx]<=q[q_idx]:
        p[p_idx]=r[i]
        p_idx+=1
    if q[q_idx]<=p[p_idx]:
        q[q_idx]=r[i]
        q_idx+=1

ans=sum(p)+sum(q)
print(ans)

Buggy submission (verdict: Runtime Error):
x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]

p_idx=0
q_idx=0
plen=len(p)
qlen=len(q)
for i in range(c):
    #処理が終わる時
    if p[p_idx]>r[i] and q[q_idx]>r[i]:
        break
    #全部入れ替わる
    if p_idx==plen and q_idx==qlen:
        break
    #どちらかが全部入れ替わる
    #それ以外
    if p[p_idx]<=q[q_idx] or q_idx==qlen:
        if p[p_idx]>r[i]:
            break
        else:
            p[p_idx]=r[i]
            p_idx+=1
    if q[q_idx]<=p[p_idx] or p_idx==plen:
        if q[q_idx]>r[i]:
            break
        else:
            q[q_idx]=r[i]
            q_idx+=1

ans=sum(p)+sum(q)
print(ans)
Problem p02767 (python)

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

mn=10**7
for i in range(1,101):
    hp=0
    for k in range(n):
        hp+=(x[k]-i)**2
    if hp<mn:
        mn=hp

print(mn)

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

ma = max(x)
mi = min(x)
z = 0
a = []
for i in range(mi,ma):
    for j in range(n):
        y = (x[j] - (mi+i))**2
        z += y
    a.append(z)
    z = 0

print(min(a))
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))

p_sm=0

for i in range(k):
    p_sm += p[i]

p_mx=p_sm

for i in range(n-k):
    p_sm= p_sm + p[k+i]-p[i]
    if p_sm >p_mx:
        p_mx = p_sm

print((p_mx+k)/2)

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

p_mx=0

for i in range(k):
    p_sm += p[i]

p_mx=p_sm

for i in range(n-k):
    p_sm= p_sm + p[k+i]-p[i]
    if p_sm >p_mx:
        p_mx = p_sm

print((p_mx+k)/2)
Problem p02861 (python)

Fixed submission:
import math

n = int(input())

def distance(x1, y1, x2, y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)
distance_sum=0

c=[0]*n
for i in range(n):
    coordinate=list(map(int,input().split()))
    c[i]=coordinate


for i in range(n-1):
    for j in range(i+1,n):
        distance_sum+=distance(c[i][0],c[i][1],c[j][0],c[j][1])
    
distance_sum*=2
distance_sum*=(n-1)
distance_sum=distance_sum/(n*(n-1))

print(distance_sum)

Buggy submission (verdict: Runtime Error):
from math import sqrt

n = int(input())

def distance(x1, y1, x2, y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

x=[0]*n
y=[0]*n

for i in range(n):
    x[i], y[i] =map(int, input().split())

dis = 0

for i in range(n):
    for j in range(n):
        dis += distance(x[i], y[i], x[j], y[j])

dis = dis/n
print(dis)
Problem p03043 (python)

Fixed submission:
n, k=map(int, input().split())

l=[]
point=k
l.append(k)
while point>1:
    if point%2==0:
        point=point//2
    else:
        point=(point//2) +1
    l.append(point)

m=len(l)

if n>=k:
    ans1=0
    for i in range(m-1):
        count=l[i]-l[i+1]
        prob=0.5**(i+1)
        ans1+=prob*count
    ans=ans1+(n-k+1)
elif n==1:
    countn=0
    nn=n
    while nn<k:
        nn=nn*2
        countn+=1
    ans=0.5**countn
else:
    ans2=0
    for i in range(m-1):
        if n>=l[i]:
            b=i
            break
        else:
            continue
        break
    ans2+=((0.5)**b)*(n-l[b]+1)
    for i in range(b,m-1):
        count=l[i]-l[i+1]
        prob=0.5**(i+1)
        ans2+=prob*count
    ans=ans2



print(ans/n)

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

l=[]
point=k
l.append(k)
while point>1:
    if point%2==0:
        point=point//2
    else:
        point=(point//2) +1
    l.append(point)

m=len(l)

if n>=k:
    ans1=0
    for i in range(m-1):
        count=l[i]-l[i+1]
        prob=0.5**(i+1)
        ans1+=prob*count
    ans=ans1+(n-k+1)
else:
    ans2=0
    for i in range(m-1):
        if n>=l[i]:
            b=i
            break
        else:
            continue
        break
    ans2+=((0.5)**b)*(n-l[b]+1)
    for i in range(b,m-1):
        count=l[i]-l[i+1]
        prob=0.5**(i+1)
        ans2+=prob*count
    ans=ans2



print(ans/n)
Problem p03087 (python)

Fixed submission:
n, q=map(int, input().split())
s=input()


z=[0]*n
count=0
for i in range(n):
    z[i]=count
    if s[i]=="A" and i<=n-2:
        if s[i+1]=="C":
            count+=1
            z[i]+=1

for i in range(q):
    l, r =map(int,input().split())
    #r文字目までのACの数-(l-1)文字目まで
    if l==1:
        ans=z[r-2]
    elif r-l==1:
        if s[l-1]=="A" and s[l]=="C":
            ans=1
        else:
            ans=0
    else:
        ans=z[r-2]-z[l-2]
    print(ans)

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


z=[0]*n
count=0
for i in range(n):
    z[i]=count
    if s[i]=="A":
        if s[i+1]=="C":
            count+=1
            z[i]+=1

for i in range(q):
    l, r =map(int,input().split())
    #r文字目までのACの数-(l-1)文字目まで
    if l==1:
        ans=z[r-1]
    elif r-l==1:
        if s[l-1]=="A" and s[l]=="C":
            ans=1
        else:
            ans=0
    else:
        ans=z[r-2]-z[l-2]
    print(ans)

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


z=[0]*n
count=0
for i in range(n):
    z[i]=count
    if s[i]=="A":
        if s[i+1]=="C":
            count+=1
            z[i]+=1

for i in range(q):
    l, r =map(int,input().split())
    #r文字目までのACの数-(l-1)文字目まで
    if l==1:
        ans=z[r-1]
    elif r-l==1:
        if s[l-1]=="A" and s[l]=="C":
            ans=1
        else:
            ans=0
    else:
        ans=z[r-1]-z[l-2]
    print(ans)
Problem p03281 (python)

Fixed submission:
n=int(input())

a=[]
for i in range(1,201):
    s=0
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            s+=1
            if j != i//j:
                s+=1
    a.append(s)

ans=0
for i in range(n):
    if a[i]==8 and i%2==0:
        ans+=1

print(ans)

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

a=[]
for i in range(1,201,2):
    s=0
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            s+=1
            if j != i//j:
                s+=1
    a.append(s)

ans=0
for i in range(n//2+1):
    if a[i]==8:
        ans+=1

print(ans)
Problem p03625 (python)

Fixed submission:
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
d=defaultdict(int)
for i in range(n):
    d[a[i]]+=1

for i,j in d.items():
    if j>=2:
        b.append(i)
    if j>=4:
        c.append(i)

if len(b)<2 and len(c)<1:
    print(0)
elif len(c)==1 and len(b)<2:
    print(c[0]**2)
else:
    b.sort(reverse=True)
    rec=b[0]*b[1]
    if len(c)>=1:
        c.sort(reverse=True)
        cube=c[0]**2
    else:
        cube=0
    print(max(rec,cube))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
d=defaultdict(int)
for i in range(n):
    d[a[i]]+=1

for i,j in d.items():
    if j>=2:
        b.append(i)
    if j>=4:
        c.append(i)

if len(b)<2 and len(c)<1:
    print(0)
elif len(c)==1 and len(b)<2:
    print(c[0]**2)
else:
    b.sort(reverse=True)
    rec=b[0]*b[1]
    if len(c)>=1:
        c.sort(reverse=True)
        cube=c[0]**2
    print(max(rec,cube))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
d=defaultdict(int)
for i in range(n):
    d[a[i]]+=1

for i,j in d.items():
    if j>=2:
        b.append(i)
    if j>=4:
        c.append(i)

if len(b)<2 and len(c)<1:
    print(0)
elif len(c)==1:
    print(c[0]**2)
else:
    b.sort(reverse=True)
    rec=b[0]*b[1]
    if len(c)>=1:
        c.sort(reverse=True)
        cube=c[0]**2
    print(max(rec,cube))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
b=[]
c=[]
d=defaultdict(int)
for i in range(n):
    d[a[i]]+=1

for i,j in d.items():
    if j>=2:
        b.append(i)
    if j>=4:
        c.append(i)
if len(b)<2:
    print(0)
else:
    b.sort(reverse=True)
    rec=b[0]*b[1]
    if len(c)>=1:
        c.sort(reverse=True)
        cube=c[0]**2
    print(max(rec,cube))
Problem p02732 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
b=[0]*(n+1)
for i in range(n):
    b[a[i]]+=1
for k in b:
    ans+=k*(k-1)//2
for i in range(n):
    print(ans-b[a[i]]+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
b=[0]*n
for i in range(n):
    b[a[i]]+=1
for k in b:
    ans+=k*(k-1)//2
for i in range(n):
    print(ans-b[a[i]]+1)

Buggy submission (verdict: Runtime Error):
import math
import collections
n=int(input())
a=list(map(int,input().split()))
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in a:
    c=collections.Counter(a)
    ans=0
    c[i] -=1
    for k in c.values():
        if k != 1:
            ans +=combinations_count(k,2)
    print(ans)
Problem p02743 (python)

Fixed submission:
from decimal import *
import math
a,b,c=map(int,input().split())
if a+b+(4*Decimal(a)*Decimal(b))**Decimal("0.5")<c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sympy
a,b,c=map(int,input().split())
if a+b+sympy.sqrt(4*a*b)<c:
    print("Yes")
else:
    print("No")
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
ans=-1
for i in range(10**3):
    if (len(str(i))==n):
        flag=1
        for s,c in sc:
            if str(i)[s-1] != str(c):
                flag=0
        if flag==1:
            ans =i
            break
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
s_c=[list(map(str,input().split())) for _ in range(m)]

ans=["0"]*n
for i in s_c:
    ans[int(i[0])-1]=i[1]

if m>1:
    for i in range(m-1):
        for k in range(i+1,m):
            if s_c[i][0]==s_c[k][0] and s_c[i][1]!=s_c[k][1]:
                ans = -1
                break

if n>1:
    if ["1","0"] in s_c:
        ans = -1
    if ans[0]=="0":
        ans=-1

print(int("".join(ans)) if ans != -1 else -1)