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

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
P=[i for i in range(N)]
size=[1 for i in range(N)]

def find(a):
    if a==P[a]:
        return a
    else:
        return find(P[a])
        
def union(b,c):
    B=find(b)
    C=find(c)
    if size[B]>=size[C]:
        P[C]=P[B]
        size[B]+=size[C]
    else:
        P[B]=P[C]
        size[C]+=size[B]
for i in range(M):
    x,y=map(int,input().split())
    if find(x)!=find(y):
        union(x,y)
        
p=[]
for i in range(N):
    p.append([A[i],find(P[i])])
#print(p)
p.sort()
ANS1=[]
ANS2=[]
d={}
for i in range(N):
    if p[i][1] in d:
        ANS2.append(p[i][0])
    else:
        d[p[i][1]]=1
        ANS1.append(p[i][0])
#print(ANS1,ANS2)
if (len(ANS1)+len(ANS1)-2)>N:
    print("Impossible")
elif len(ANS1)==1:
    print(0)
else:
    ANS=sum(ANS1)+sum(ANS2[:len(ANS1)-2])
    print(ANS)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

N,M=map(int,input().split())
V=list(map(int,input().split()))

P=[i for i in range(N)]
size=[1 for i in range(N)]

def find(x):
    if x==P[x]:
        return x
    else:
        return find(P[x])
    
def union(y,z):
    Y=find(y)
    Z=find(z)
    if size[y]>=size[z]:
        P[Z]=P[Y]
        size[Y]+=size[Z]
    else:
        P[Y]=P[Z]
        size[Z]+=size[Y]

for i in range(M):
    x,y=map(int,input().split())
    if find(x)!=find(y):
        union(x,y)
#print(P)
S=[]
for i in range(N):
    S.append(find(i))
#print(S)
D={}
O={}
for i in range(N):
    if S[i] not in D:
        D[S[i]]=V[i]
        O[S[i]]=1
    else:
        O[S[i]]+=1
        if D[S[i]]>V[i]:
            D[S[i]:V[i]]
#print(D,O)
One=0
#print("S",S)
for i in O:
    #print(O[i])
    if O[i]==1:
        One+=1
#print("One",One)
if (One-1)*2>N:
    print("Impossible")
    exit()
W=[]
for i in range(N):
    W.append([V[i],S[i]])
W.sort()
#print(W)
ans=sum(D.values())
#print(ans)
#print(D)
if len(D)==1:
    print(0)
    exit()
for i in range(len(D)-1):
    if W[i][1] in D:
        if D[W[i][1]]==W[i][0]:
            continue
        else:
            ans+=W[i][0]
    else:
        ans+=W[i][0]
print(ans)
Problem p03452 (python)

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())

L=[[]for i in range(N+1)]
D=dict()
for i in range(M):
    l,r,d=map(int,input().split())
    L[l].append([r,d])
    L[r].append([l,-d])
    D[i]=(l,r,d)
    
C=["N" for i in range(N+1)]

def dfs(x):
    for i,j in L[x]:
        if C[i]=="N":
            C[i]=C[x]+j
            dfs(i)

for i in range(1,N+1):
    if C[i]=="N":
        C[i]=0
        dfs(i)
#print(C)
#print(D)
for i in range(M):
    l,r,d=D[i]
    if C[r]-C[l]!=d:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

N,M=map(int,input().split())

P=[i for i in range(N+1)]
r=[0 for i in range(N+1)]

def find(a):
    if a==P[a]:
        pass
    else:
        return find(P[a])
        
def union(a,b,c):
    P[b]=a
    r[b]=c
    
def find2(a,b):
    if a==P[a]:
        return b+r[a]
    else:
        return find2(P[a],b+r[a])
L=[]
for i in range(M):
    a,b,c=map(int,input().split())
    union(a,b,c)
    L.append([a,b,c])
    
for i in range(1,N+1):
    r[i]=find2(i,0)
    
#print(r)
#print(P)

for i in L:
    if r[i[0]]!=r[i[1]]-i[2]:
        print(i)
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
P=[i for i in range(N+1)]
L=[0 for i in range(N+1)]
Q=[]
def find(a):
    if P[a]==a:
        return a
    else:
        return find(P[a])

def union(b,c,d):
    B=find(b)
    C=find(c)
    P[C]=P[B]
    L[c]=L[b]+d

for i in range(M):
    l,r,d=map(int,input().split())
    Q.append([l,r,d])
    union(l,r,d)
#print(P)
#print(L)

for i in Q:
    if L[i[1]]-L[i[0]]==i[2]:
        continue
    else:
        print("No")
        exit()
print("Yes")
Problem p03525 (python)

Fixed submission:
import copy
N=int(input())

t=[0 for i in range(13)]
T=[0 for i in range(25)]
T[0]=1
T[24]=1

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

for i in range(N):
    t[D[i]]+=1
    
#print(t)
if t[0]>=1 or t[12]>=2 or max(t)>=3:
    print(0)
else:
    for i in range(len(t)):
        if t[i]==2:
            T[i]=1
            T[24-i]=1
    T[12]=t[12]
    #print(T)
    A=[[]for i in range(11)]
    for i in range(1,12):
        if t[i]==1:
            A[i-1]=[i,24-i]
    for i in range(11):
        if A[i]==[]:
            A[i]=[0,0]
    #print(A)
    
    MAX=0
    for i in range(2**11+1):
        S=copy.deepcopy(T)
        I=i
        for j in range(11):
            if (I//(2**(10-j)))==1:
                S[A[j][1]]=1
            else:
                S[A[j][0]]=1
            I%=(2**(10-j))
        L=100
        P=0
        for k in range(1,25):
            if S[k]==1:
                if L>(k-P):
                    L=(k-P)
                P=k
        if L>MAX:
            MAX=L
            #print(L)
            #print(S)
    print(MAX)

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

t=[0 for i in range(13)]
T=[0 for i in range(25)]
T[0]=1
T[24]=1

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

for i in range(N):
    t[D[i]]+=1
    
#print(t)
if t[0]>=1 or t[12]>=2 or max(t)>=3:
    print(0)
else:
    for i in range(len(t)):
        if t[i]==2:
            T[i]=1
            T[24-i]=1
    T[12]=t[12]
    #print(T)
    A=[[]for i in range(11)]
    for i in range(1,12):
        if t[i]==1:
            A[i-1]=[i,24-i]
    for i in range(10):
        if A[i]==[]:
            A[i]=[0,0]
    #print(A)
    
    MAX=0
    for i in range(2**10+1):
        S=copy.deepcopy(T)
        for j in range(11):
            if (i//(2**(9-j)))==1:
                S[A[j][1]]=1
            else:
                S[A[j][0]]=1
        L=100
        P=0
        for k in range(1,25):
            if S[k]==1:
                if L>(k-P):
                    L=(k-P)
                P=k
        if L>MAX:
            MAX=L
            #print(L)
            #print(S)
    print(MAX)

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

t=[0 for i in range(13)]
T=[0 for i in range(25)]
T[0]=1
T[24]=1

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

for i in range(N):
    t[D[i]]+=1
    
#print(t)
if t[0]>=1 or t[12]>=2 or max(t)>=3:
    print(0)
else:
    for i in range(len(t)):
        if t[i]==2:
            T[i]=1
            T[24-i]=1
    T[12]=t[12]
    #print(T)
    A=[[]for i in range(10)]
    for i in range(1,12):
        if t[i]==1:
            A[i-1]=[i,24-i]
    for i in range(10):
        if A[i]==[]:
            A[i]=[0,0]
    #print(A)
    
    MAX=0
    for i in range(2**10+1):
        S=copy.deepcopy(T)
        for j in range(10):
            if (i//(2**(9-j)))==1:
                S[A[j][1]]=1
            else:
                S[A[j][0]]=1
        L=100
        P=0
        for k in range(1,25):
            if S[k]==1:
                if L>(k-P):
                    L=(k-P)
                P=k
        if L>MAX:
            MAX=L
            #print(L)
            #print(S)
    print(MAX)
Problem p03605 (python)

Fixed submission:
N=input()
if N[0]=="9" or N[1]=="9":
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from itertools import permutations

N,M,R=map(int,input().split())

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

for i in range(len(r)):
    r[i]-=1
    
A=[]
a=[]
for i in range(N):
    for j in range(N):
        a.append(1000000)
    A.append(a)
    a=[]
#print(A)

for i in range(M):
    a,b,c=map(int,input().split())
    A[a-1][b-1]=c
    A[b-1][a-1]=c
#print(A)

for c in range(N):
    for a in range(N):
        for b in range(N):
            A[a][b]=min(A[a][b],A[a][c]+A[c][b])
#print(A)

ans=10000000
for i in permutations(r,len(r)):
    cnt=0
    for j in range(len(i)-1):
        cnt+=A[i[j]][i[j+1]]
    if ans>cnt:
        ans=cnt
print(ans)
Problem p03633 (python)

Fixed submission:
import fractions
N=int(input())
LCM=int(input())
for i in range(N-1):
    T=int(input())
    LCM=LCM*T//fractions.gcd(LCM,T)
print(LCM)

Buggy submission (verdict: Runtime Error):
N=int(input())
T=int(input())
gcd=100000000000000000000000
for i in range(N-1):
    T1=int(input())
    A=max(T,T1)
    B=min(T,T1)
    for j in range(1000000000000):
        
        if A%B==0:
            gcd=B
            
            break
        else:
            C=A%B
            if C>B:
                A=C
            else:
                B=C
print(T1*T/gcd)
Problem p03838 (python)

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

if B==0 and 0>A:
    print(abs(A))
elif B==0 and A>0:
    print(abs(A)+1)
elif B>=A and A>=0:
    print(B-A)
elif B>=0 and 0>=A:
    if abs(B)>=abs(A):
        print(abs(B)-abs(A)+1)
    else:
        print(abs(A)-abs(B)+1)
elif 0>=B and B>=A:
    print(abs(A)-abs(B))
    
elif A>B and B>=0:
    print(A-B+2)
elif A>=0 and 0>=B:
    if abs(A)>=abs(B):
        print(abs(A)-abs(B)+1)
    else:
        print(abs(B)-abs(A)+1)
elif 0>=A and A>=B:
    print(abs(B)-abs(A)+2)

Buggy submission (verdict: Runtime Error):
if B==0 and 0>A:
    print(abs(A))
elif B>=A and A>=0:
    print(B-A)
elif B>=0 and 0>=A:
    if abs(B)>=abs(A):
        print(abs(B)-abs(A)+1)
    else:
        print(abs(A)-abs(B)+1)
elif 0>=B and B>=A:
    print(abs(A)-abs(B))
    
elif A>B and B>=0:
    print(A-B+2)
elif A>=0 and 0>=B:
    if abs(A)>=abs(B):
        print(abs(A)-abs(B)+1)
    else:
        print(abs(B)-abs(A)+1)
elif 0>=A and A>=B:
    print(abs(B)-abs(A)+2)
Problem p03846 (python)

Fixed submission:
N=int(input())
if N%2==0:
    L=[]
    for i in range(int(N/2)):
        L.append(i*2+1)
        L.append(i*2+1)
        
else:
    L=[0]
    for i in range(1,int((N-1)/2)+1):
        L.append(i*2)
        L.append(i*2)

A=list(map(int,input().split()))
A.sort()

if A==L:
    if N%2==0:
        ans=1
        for j in range(int(N/2)):
            ans*=2
            ans%=(10**9+7)
        print(ans)
    else:
        ans=1
        for j in range(int((N-1)/2)):
            ans*=2
            ans%=(10**9+7)
        print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2==0:
    L=[]
    for i in range(int(N/2)):
        L.append(i*2+1)
        L.append(i*2+1)
        
else:
    L=[0]
    for i in range(1,int((N-1)/2)+1):
        L.append(i*2)
        L.append(i*2)

A=list(map(int,input().split()))
A.sort()

if A==L:
    if N%2==0:
        ans=1
        for j in range(int(N/2)):
            ans*=2
            ans%=(10**9+7)
        print(ans)
    else:
        ans=1
        for j in range(int(N-1)/2):
            ans*=2
            ans%=(10**9+7)
        print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2==0:
    L=[]
    for i in range(int(N/2)):
        L.append(i*2+1)
        L.append(i*2+1)
        
else:
    L=[0]
    for i in range(1,int((N-1)/2)+1):
        L.append(i*2)
        L.append(i*2)

A=list(map(int,input().split()))
A.sort()

if A==L:
    if N%2==0:
        print(int(2**(N/2)%(10**9+7)))
    else:
        print(int(2**((N-1)/2)%(10**9+7)))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2==0:
    L=[]
    for i in range(int(N/2)):
        L.append(i*2+1)
        L.append(i*2+1)
        
else:
    L=[0]
    for i in range(1,int((N-1)/2)+1):
        L.append(i*2)
        L.append(i*2)

A=list(map(int,input().split()))
A.sort()

if A==L:
    if N%2==0:
        print(int(2**(N/2)))
    else:
        print(int(2**((N-1)/2)))
else:
    print(0)
Problem p03959 (python)

Fixed submission:
N=int(input())
T=list(map(int,input().split()))
t=[1]
for i in range(1,N):
    if T[i]!=T[i-1]:
        t.append(1)
    else:
        t.append(T[i])
    if T[i]<T[i-1]:
        print(0)
        exit()
A=list(map(int,input().split()))
A=A[::-1]
a=[1]
for i in range(1,N):
    if A[i]!=A[i-1]:
        a.append(1)
    else:
        a.append(A[i])
    if A[i]<A[i-1]:
        print(0)
        exit()
A=A[::-1]
a=a[::-1]
#print(t)
#print(a)
M=max(A)

for i in range(N):
    if T[i]==M:
        if A[i]==M:
            break
        else:
            print(0)
            exit()

for i in range(N):
    if A[N-1-i]==M:
        if T[N-1-i]==M:
            break
        else:
            print(0)
            exit()
ans=1
mod=(10**9+7)
for i in range(N):
    ans*=min(t[i],a[i])
    ans%=mod
print(ans)

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

if T[N-1]!=A[0]:
    print(0)
elif N==1:
    print(1)
else:
    
    L=[[T[0],0]]
    for i in range(1,N):
        if T[i]==T[i-1]:
            L.append([T[i],1])
        else:
            L.append([T[i],0])
    #print(L)
            
    if L[len(L)-1][0]>A[len(L)-1]:
        L[len(L)-1]=[A[len(L)-1],0]
    else:
        L[len(L)-1][1][0]
    
    for i in range(1,N):
        if L[len(L)-1-i][0]>=A[len(L)-1-i]:
            L[len(L)-1-i][0]=A[len(L)-1-i]
            if A[len(L)-1-i]==A[len(L)-i]:
               pass
            else:
                L[len(L)-1-i][1]=0
            if L[len(L)-1-i][0]>L[len(L)-i][0]:
                L[len(L)-1-i][1]=0
    #print(L)
    ans=1
    for i in range(len(L)):
        if L[i][1]==1:
            ans*=L[i][0]
            ans%=(10**9+7)
    print(ans)
Problem p02677 (python)

Fixed submission:
import math
pi=math.pi
def calcAngle(h,m): 
    if (h == 12): 
        h = 0
    if (m == 60): 
        m = 0
    hour_angle = 0.5 * (h * 60 + m) 
    minute_angle = 6 * m 
    angle = abs(hour_angle - minute_angle) 
    angle = min(360 - angle, angle) 
    return angle
A,B,H,M=map(int,input().split())
angle=calcAngle(H,M)
t= A*A + B*B - 2*A*B*math.cos(((math.pi)/180)*(angle))
print("{0:.15f}".format(t**0.5))

Buggy submission (verdict: Runtime Error):
input=sys.stdin.readline
import math
pi=math.pi
def calcAngle(h,m): 
    if (h == 12): 
        h = 0
    if (m == 60): 
        m = 0
    hour_angle = 0.5 * (h * 60 + m) 
    minute_angle = 6 * m 
    angle = abs(hour_angle - minute_angle) 
    angle = min(360 - angle, angle) 
    return angle
A,B,H,M=map(int,input().split())
angle=calcAngle(H,M)
t= A*A + B*B - 2*A*B*math.cos(((math.pi)/180)*(angle))
print("{0:.15f}".format(t**0.5))
Problem p02687 (python)

Fixed submission:
N=input()
if N=="ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
if N=="ABC":
    print("ARC")
else:
    print("ABC")
Problem p02702 (python)

Fixed submission:
S=input()[::-1]
l=len(S)
t=0
p=0
 
ss=[0]*2019
ss[0]=1
d=1
for i in S:
    p=(p+int(i)*d)%2019
    d*=10
    d%=2019
    ss[p]+=1
 
for c in ss:
    t+=c*(c-1)//2
print(t)

Buggy submission (verdict: Runtime Error):
numMultiples=0
S=input()
N=len(S)
seenRemainders=[set()]*(100000)
for i in range(N):
    remainder = 0
    prefixesFound = 0
    for j in range(i,N):
        remainder = (10 * remainder + int (S[j]) ) % 2019
        # if remainder in seenRemainders[j]:
        #     break
        seenRemainders[j].add(remainder)
        if remainder == 0:
            prefixesFound+=1
    numMultiples += prefixesFound * (prefixesFound + 1) / 2
print(int(numMultiples))
Problem p02606 (python)

Fixed submission:
li = list(map(int, input().split())) 
L = li[0]
R = li[1]
d = li[2]

#print(L)
#print(R)
#print(d)

count = 0

for X in range (L,R+1):
 if X % d == 0:
  count = count + 1
 else:
  pass

print(count)

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



for n in range(1,N+1):
    if n < 6:
        print(0)
    else:
        M =int((n-2)**0.5)
        count = 0
        for x in range(1,M+1):
            #P=x**2+y**2+z**2+x*y+y*z+z*x
            for y in range(1,M+1):
                #Q=x**2+y**2+z**2+x*y+y*z+z*x
                for z in range(1,M+1):
                    #R = x**2+y**2+z**2+x*y+y*z+z*x
                    if x**2+y**2+z**2+x*y+y*z+z*x == n:
                        count = count + 1
                    else:
                        pass
        print(count)

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


for n in range(1,N+1):
    if n < 3:
        print(0)
    else:
        M =int((n-2)**0.5)
        count = 0
        for x in range(1,M+1):
            #P=x**2+y**2+z**2+x*y+y*z+z*x
            for y in range(1,M+1):
                #Q=x**2+y**2+z**2+x*y+y*z+z*x
                for z in range(1,M+1):
                    #R = x**2+y**2+z**2+x*y+y*z+z*x
                    if x**2+y**2+z**2+x*y+y*z+z*x == n:
                        count = count + 1
                    else:
                        pass
        print(count)
Problem p02608 (python)

Fixed submission:
N = int(input())
lst = [0]*(N+1)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            p = (x+y)*(x+z)+y**2+z**2
            if p > N:
                break
            else:
                lst[p] += 1
for i in range(1,N+1):
    print(lst[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
list = []*(N+1)

M =int((N-2)**0.5)
for x in range(1,M+1):
    for y in range(1,M+1):
        for z in range(1,M+1):
            p = (x+y)*(x+z)+y**2+z**2
            if p > N:
                break
            else:
                list[p] = list[p] + 1
for i in range(1,N+1):
    print(list[i])
Problem p02621 (python)

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

Buggy submission (verdict: Runtime Error):
a = input()
print (int(a+a^2+a^3))
Problem p02641 (python)

Fixed submission:
import numpy as np
def getNearestValue(Q, num):
    idx = np.abs(np.asarray(Q) - num).argmin()
    return Q[idx]

XN = list(map(int,input().split()))
X = XN[0]
N = XN[1]
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    Q = list(range(-100,200,1))
    for i in range(0,N):
        Q.remove(P[i])
    print(getNearestValue(Q,X))

Buggy submission (verdict: Runtime Error):
import numpy as np
def getNearestValue(Q, num):
    idx = np.abs(np.asarray(Q) - num).argmin()
    return Q[idx]

XN = list(map(int,input().split()))
X = XN[0]
N = XN[1]
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    Q = list(range(1, 101, 1))
    for i in range(0,N):
        Q.remove(P[i])
    print(getNearestValue(Q,X))
Problem p02658 (python)

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

#print(a)

ans = int(a[0])
for i in range(1,N):
    if ans > 10**18:
        break
    else:
        ans = ans * int(a[i])
if 0 in a:
    print(0)
elif ans > 10**18:
    print(-1)
else:
    print(ans)

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

#print(a)

ans = int(a[0])
for i in range(1,N):
    if ans > 10**18:
        break
    else:
        ans = ans * int(a[i])
if 0 in a:
    print(0)
elif:if ans > 10**18:
    print(-1)
else:
    print(ans)
Problem p02677 (python)

Fixed submission:
import math
L = list(map(int,input().split()))
a = L[0]
b = L[1]
H = L[2]
M = L[3]

angleshort = 360*(60*H+M)/720
anglelong = 360*M/60

#print(angleshort)
#print(anglelong)
theta = math.radians((anglelong-angleshort))
ans = (a*a+b*b-2*a*b* math.cos(theta))**0.5
print(ans)

Buggy submission (verdict: Runtime Error):
import math
L = list(map(int,input().split()))
a = L[0]
b = L[1]
H = L[2]
M = L[3]

#angleshort = 360*(60*H+M)/720
#anglelong = 360*M/60

print(angleshort)
print(anglelong)
theta = math.radians((anglelong-angleshort))
ans = (a*a+b*b-2*a*b* math.cos(theta))**0.5
print(ans)
Problem p02812 (python)

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

a_lst = ([i for i, x in enumerate(S) if x == 'A'])
count = 0
for j in a_lst:
    if len(S) >= j + 3:
        if S[j+1] == 'B' and S[j+2] == 'C':
            count += 1
print(count)

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

a_lst = ([i for i, x in enumerate(S) if x == 'A'])
count = 0
for j in a_lst:
    if len(S) >= j + 2:
        if S[j+1] == 'B' and S[j+2] == 'C':
            count += 1
print(count)

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

a_lst = ([i for i, x in enumerate(S) if x == 'A'])
count = 0
for j in a_lst:
    if S[j+1] == 'B' and S[j+2] == 'C':
        count += 1
print(count)
Problem p02900 (python)

Fixed submission:
import math
import fractions
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def is_prime(p):
    if p == 1:
        return False
    for i in range(2,int(p ** .5) + 1):
        if p % i == 0:
            return False
    return True

A,B = map(int,input().split())

g = fractions.gcd(A, B)

div = make_divisors(g)
ans = 1
for i in div:
    if is_prime(i):
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def is_prime(num):
    for i in range(2, num):  # 第二引数は sqrt(num)+1 でも良い
        if num % i == 0:
            return False

    return True

A,B = map(int,input().split())

g = math.gcd(A, B)

# print(g)
div = make_divisors(g)
# print(div)
p = [i for i in div if is_prime(i)]
# print(p)
print(len(p))
Problem p02923 (python)

Fixed submission:

N = int(input())
H = list(map(int,input().split()))

sabun = [H[i+1]-H[i] for i in range(N-1)]
sei = [i+1 for i in range(N-1) if sabun[i] <= 0]

# print(sabun)
# print(sei)

if N == 1:
    print("0")
    exit()
if min(sabun) > 0:
    print("0")
    exit()

sa = [sei[i+1]-sei[i] for i in range(len(sei)-1)]
sa.append(0)
sa.insert(0,0)
index = [i for i in range(len(sa)) if sa[i] != 1]
ans = [index[i+1]-index[i] for i in range(len(index)-1)]

# print(sa)
# print(index)
if ans == []:
    print(N-1)
    exit()
print(max(ans))

Buggy submission (verdict: Runtime Error):

N = int(input())
H = list(map(int,input().split()))

sabun = [H[i+1]-H[i] for i in range(N-1)]
sei = [i+1 for i in range(N-1) if sabun[i] <= 0]
if N == 1:
    print("0")
    exit()
if min(sabun) >= 0:
    print("0")
    exit()

sa = [sei[i+1]-sei[i] for i in range(len(sei)-1)]
sa.append(0)
index = [i+1 for i in range(len(sa)) if sa[i] != 1]
ans = [index[i+1]-index[i] for i in range(len(index)-1)]
# print(sabun)
# print(sei)
# print(sa)
# print(index)
print(max(ans))

Buggy submission (verdict: Runtime Error):

N = int(input())
H = list(map(int,input().split()))

sabun = [H[i+1]-H[i] for i in range(N-1)]
sei = [i+1 for i in range(N-1) if sabun[i] > 0]
if N == 1:
    print("0")
    exit()
if min(sabun) >= 0:
    print("0")
    exit()
sei.append(N-1)
sa = [sei[i+1]-sei[i] for i in range(len(sei)-1)]
# print(H)
# print(sabun)
# print(sei)
print(max(sa))
Problem p02947 (python)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
existed = {}
c = 0
for i in range(n):
  sorted_s = ''.join(sorted(s[i]))

  if sorted_s in existed:
    c += existed[sorted_s]
    existed[sorted_s] += 1
  else:
    existed[sorted_s] = 1
print(c)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
S = [sorted(input()) for i in range(N)]
S = ["".join(S[i]) for i in range(N)]

S.sort()
S_ = S[:]
S_ = set(S_)

c = 0

for i in S_:
    a = S.count(i)
    if a == 1 :
        continue
    ans = math.factorial(a) / 2 * math.factorial(a-2)
    c += int(ans)

print(c)
Problem p03000 (python)

Fixed submission:
N,X = map(int,input().split())
L = list(map(int,input().split()))
count = 1
var = 0
for i in range(N):
    if i >= N:
        break
    var += L[i]
    if var > X:
        break
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
L = list(map(int,input().split()))
count = 0
var = 0
for i in range(X):
    count += 1
    var +=L [i]
    if var > X:
        break
print(count)