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

Fixed submission:
import math
a,b,x=map(int,input().split())

S=x/a

if S<=a*b/2:
    A=S/b*2
    B=b
    print(math.degrees(math.atan2(B,A)))
    
else:
    S=a*b-S
    A=a
    B=S/a*2
    print(90-math.degrees(math.atan2(A,B)))

Buggy submission (verdict: Runtime Error):
import math

a,b,x=map(int,input().split())
M=x/a
if M<=a*b/2:
    A=M/b*2
    B=b
    C=(A**2+B**2)**0.5
    F=0
else:
    m=a*b-M
    A=a
    B=m/a*2
    C=(A**2+B**2)**0.5
    F=1

def get_angle_from_sides(a, b, c):
    return math.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b))

def checkio(a, b, c):
    try:
        angles = [get_angle_from_sides(*abc) for abc in ((a, b, c), (b, c, a), (c, a, b))]
        result = sorted(math.degrees(a) for a in angles)
        return angles if 0 in result else result
    except ValueError:
        return [0, 90, 0]

if F==0:
    print(checkio(A,B,C)[1])
else:
    print(checkio(A,B,C)[0])

Buggy submission (verdict: Runtime Error):
import math

a,b,x=map(int,input().split())
M=x/a
if M<=a*b/2:
    A=M/b*2
    B=b
    C=(A**2+B**2)**0.5
    F=0
else:
    m=a*b-M
    A=a
    B=m/a*2
    C=(A**2+B**2)**0.5
    F=1

def get_angle_from_sides(a, b, c):
    return math.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b))

def checkio(a, b, c):
    angles = [get_angle_from_sides(*abc) for abc in ((a, b, c), (b, c, a), (c, a, b))]
    result = sorted(math.degrees(a) for a in angles)
    return result
    

if F==0:
    print(checkio(A,B,C)[1])
else:
    print(checkio(A,B,C)[0])

Buggy submission (verdict: Runtime Error):
import math

a,b,x=map(int,input().split())
M=x/a
if M<=a*b/2:
    A=M/b*2
    B=b
    C=(A**2+B**2)**0.5
    F=0
else:
    m=a*b-M
    A=a
    B=m/a*2
    C=(A**2+B**2)**0.5
    F=1

def get_angle_from_sides(a, b, c):
    return math.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b))

def checkio(a, b, c):
    try:
        angles = [get_angle_from_sides(*abc) for abc in ((a, b, c), (b, c, a), (c, a, b))]
        result = sorted(math.degrees(a) for a in angles)
        return angles if 0 in result else result
    except ValueError:
        return [0, 0, 0]

if F==0:
    print(checkio(A,B,C)[1])
else:
    print(checkio(A,B,C)[0])
Problem p02963 (python)

Fixed submission:
import math

S=int(input())

if S==0:
    ans=[0,0,0,0,0,0]
elif S==10**18:
    ans=[0,0,10**9,0,10**9,10**9]
elif S%(10**9)==0:
    ans=[0,0,10**9,0,0]
    ans.append(S//(10**9))
else:
    ans=[0,0,10**9,1]
    ans.append(10**9-S%(10**9))
    ans.append(math.ceil(S/(10**9)))
print(*ans)

Buggy submission (verdict: Runtime Error):
import math

S=int(input())

if S==0:
    ans=[0,0,0,0,0,0]
elif S==10**18:
    ans==[0,0,10**9,0,10**9,10**9]
else:
    ans=[0,0,10**9,1]
    ans.append(10**9-S%(10**9))
    ans.append(math.ceil(S/(10**9)))
print(*ans)
Problem p02972 (python)

Fixed submission:
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1)[::-1]:
    #print(i)
    cnt=0
    for j in range(i,N+1,i):
        #print(i,j)
        if B[j]==1:
            cnt+=1
    if A[i]%2!=cnt%2:
        B[i]=1
        ans.append(i)
print(len(ans))
ans.sort()
print(*ans)
#print(A)

Buggy submission (verdict: Runtime Error):
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]


for i in range(1,N+1):
    cnt=0
    n=N+1-i
    for j in range(1,10**5):
        #print(n,n*j)
        if n*j>N:
            break
        else:
            if B[n*j]==1:
                cnt+=1
    if cnt%2!=A[n]:
        B[n]+=1
        ans.append(n)
ans.sort()
print(len(ans))
print(*ans)
Problem p02973 (python)

Fixed submission:
import bisect
import sys
input=sys.stdin.readline
from collections import deque
N=int(input())

cnt=0
L=[]
for i in range(N):
    n=int(input())
    L.append(n)
#print(L)
Q=[-1,10**10]
Q=deque()
#Q.appendleft(10**10)
#print(Q)
for i in range(N):
    if bisect.bisect_left(Q,L[i])==0:
        Q.appendleft(L[i])
    #elif bisect.bisect_left(Q,L[i])==len(Q)-1:
        #Q.insert(len(Q)-1,L[i])
    else:
        Q[bisect.bisect_left(Q,L[i])-1]=L[i]
#print(Q)
print(len(Q))

Buggy submission (verdict: Runtime Error):
import bisect
import sys
input=sys.stdin.readline
from collections import deque
N=int(input())

cnt=0
L=[]
for i in range(N):
    n=int(input())
    L.append(n)
#print(L)
Q=[-1,10**10]
Q=deque()
Q.appendleft(10**10)
Q.appendleft(-1)
#print(Q)
for i in range(N):
    if bisect.bisect_left(Q,L[i])==1:
        Q.insert(1,L[i])
    #elif bisect.bisect_left(Q,L[i])==len(Q)-1:
        #Q.insert(len(Q)-1,L[i])
    else:
        Q[bisect.bisect_left(Q,L[i])-1]=L[i]
#print(Q)
print(len(Q)-2)

Buggy submission (verdict: Runtime Error):
import bisect
import sys
input=sys.stdin.readline
from collections import deque
N=int(input())

cnt=0
L=[]
for i in range(N):
    n=int(input())
    L.append(n)
#print(L)
Q=[-1,10**10]
Q=deque()
Q.appendleft(10**10)
Q.appendleft(-1)
#print(Q)
for i in range(N):
    if bisect.bisect_left(Q,L[i])==1:
        Q.insert(1,L[i])
    #elif bisect.bisect_left(Q,L[i])==len(Q)-1:
        #Q.insert(len(Q)-1,L[i])
    else:
        Q[bisect.bisect_left(Q,L[i])-1]=L[i]
#print(Q)
print(len(Q)-2)
Problem p03142 (python)

Fixed submission:
import sys
input=sys.stdin.readline
N,M=map(int,input().split())

L=[[]for i in range(N+1)]

I=[0 for i in range(N+1)]
for i in range(N+M-1):
    a,b=map(int,input().split())
    L[a].append(b)
    I[b]+=1
    
#print(L)
#print(I)
P=[-1 for i in range(N+1)]
S=-1
for i in range(1,N+1):
    if I[i]==0:
        P[i]=0
        S=i
        break

B=[]
cnt=0
for i in L[S]:
    if I[i]==1:
        B.append(i)
        P[i]=S
    else:
        I[i]-=1

for i in range(10**6):
    if cnt==len(B):
        break
    for j in L[B[cnt]]:
        if I[j]==1:
            B.append(j)
            P[j]=B[cnt]
        else:
            I[j]-=1
    cnt+=1
for i in range(1,N+1):
    print(P[i])

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

L=[[]for i in range(N+1)]
p=[0 for i in range(N+1)]

for i in range(N+M-1):
    a,b=map(int,input().split())
    L[a].append(b)
    p[b]=1
    

for i in range(1,N+1):
    if p[i]==0:
        P=i
#print(P)
p[P]=[0,0]
A=[]
for i in L[P]:
    A.append([i,P,1])
for i in range(10**6):
    if i==len(A):
        break
    else:
        p[A[i][0]]=[A[i][1],A[i][2]]
        for j in L[A[i][0]]:
            A.append([j,A[i][0],A[i][2]+1])
    #print(p)
    #print(A)
for i in range(1,N+1):
    print(p[i][0])
Problem p03213 (python)

Fixed submission:
import math

SO=[0 for i in range(101)]

N=int(input())
for i in range(2,N+1):
    NUM=i
    for j in range(2,100):
        while NUM%j==0:
            SO[j]+=1
            NUM=NUM/j
A74=0
A24=0
A14=0
A04=0
A02=0
for j in range(len(SO)):
    if SO[j]>=74:
        A74+=1
    if SO[j]>=24:
        A24+=1
    if SO[j]>=14:
        A14+=1
    if SO[j]>=4:
        A04+=1
    if SO[j]>=2:
        A02+=1
#print(SO)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

#74
ans=A74
#3*5*5
if A04>=2:
    ans+=(A02-2)*combinations_count(A04,2)
#3*25
ans+=(A02-1)*A24
#5*15
ans+=(A04-1)*A14


print(ans)

Buggy submission (verdict: Runtime Error):
import math

SO=[0 for i in range(101)]

N=int(input())
for i in range(2,N+1):
    NUM=i
    for j in range(2,100):
        while NUM%j==0:
            SO[j]+=1
            NUM=NUM/j
A74=0
A24=0
A14=0
A04=0
A02=0
for j in range(len(SO)):
    if SO[j]>=74:
        A74+=1
    if SO[j]>=24:
        A24+=1
    if SO[j]>=14:
        A14+=1
    if SO[j]>=4:
        A04+=1
    if SO[j]>=2:
        A02+=1
#print(SO)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

#3*5*5
ans=(A02-2)*combinations_count(A04,2)
#3*25
ans+=(A02-1)*A24
#5*15
ans+=(A04-1)*A14
#74
ans+=A74

print(ans)
Problem p03231 (python)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

def lcm(x, y):
    return x*y // gcd(x, y)


N_len_S, M_len_T = map(int, input().split())
S = input()
T = input()
g = gcd(N_len_S, M_len_T)
l = lcm(N_len_S, M_len_T)

ans = l
for k in range(g):
    # S[i]. T[j] : 文字列 X を構成したとき重なる文字。これらが等しければよい数字。
    i = N_len_S // g * k
    j = M_len_T // g * k
    if S[i] != T[j]:
        ans = -1
        break
print(ans)

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

X=max(N,M)
Y=min(N,M)
while X%Y!=0:
    X,Y=Y,X%Y

lcm=(N*M)//Y

#print(lcm)

s=[i*lcm//N for i in range(N)]
t=[i*lcm//M for i in range(M)]
t.append(10000000)
S=input()
T=input()

for i in range(len(s)):
    if t[bisect.bisect_left(t,s[i])]==s[i]:
        if T[bisect.bisect_left(t,s[i])]==S[i]:
            pass
        else:
            print(-1)
            exit()
print(lcm)

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

X=max(N,M)
Y=min(N,M)
while X%Y!=0:
    X,Y=Y,X%Y

lcm=(N*M)//Y

#print(lcm)

s=[i*lcm//N for i in range(N)]
t=[i*lcm//M for i in range(M)]
t.append(10000000)
S=input()
T=input()

for i in range(len(s)):
    if t[bisect.bisect_left(t,s[i])]==s[i]:
        if T[bisect.bisect_left(t,s[i])]==S[i]:
            pass
        else:
            print(-1)
            exit()
print(lcm)
Problem p03244 (python)

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))

A1=[]
A2=[]
for i in range(len(A)):
    if i%2==0:
        A1.append(A[i])
    else:
        A2.append(A[i])
        
B1=collections.Counter(A1)
B2=collections.Counter(A2)

if N==2:
    print(0)

elif B1.most_common(2)[0][1]==B2.most_common(2)[0][1] and B1.most_common(2)[0][1]==int(N/2):
    if B1.most_common(1)==B2.most_common(1):
        print(int(N/2))
    else:
        print(0)
else:
    
    
    if B1.most_common(1)==B2.most_common(1):
        
        if B1.most_common(2)[1][1]>=B2.most_common(2)[1][1]:
            ans=N-B1.most_common(2)[1][1]-B2.most_common(2)[0][1]
        else:
            ans=N-B2.most_common(2)[1][1]-B1.most_common(2)[0][1]
    elif B1.most_common(2)[0][0]==B2.most_common(2)[0][0]:
        if B1.most_common(2)[0][1]>=B2.most_common(2)[0][1]:
            ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[1][1]
        else:
            ans=N-B2.most_common(2)[0][1]-B1.most_common(2)[1][1]
    else:
        ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[0][1]
    print(ans)

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

A1=[]
A2=[]
for i in range(len(A)):
    if i%2==0:
        A1.append(A[i])
    else:
        A2.append(A[i])
        
B1=collections.Counter(A1)
B2=collections.Counter(A2)

if N==2:
    print(0)

#elif B1.most_common(2)[0][1]==B2.most_common(2)[0][1] and B1.most_common(2)[0][1]==int(N/2):
    #print(int(N/2))
else:
    
    
    if B1.most_common(1)==B2.most_common(1):
        if B1.most_common(2)[1][1]>=B2.most_common(2)[1][1]:
            ans=N-B1.most_common(2)[1][1]-B2.most_common(2)[0][1]
        else:
            ans=N-B2.most_common(2)[1][1]-B1.most_common(2)[0][1]
    elif B1.most_common(2)[0][0]==B2.most_common(2)[0][0]:
        if B1.most_common(2)[0][1]>=B2.most_common(2)[0][1]:
            ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[1][1]
        else:
            ans=N-B2.most_common(2)[0][1]-B1.most_common(2)[1][1]
    else:
        ans=N-B1.most_common(2)[0][1]-B2.most_common(2)[0][1]
    print(ans)
Problem p03262 (python)

Fixed submission:
N,X=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    B.append(abs(A[i]-X))


a=B[0]

for j in range(1,N):
    b=B[j]
    if b<a:
        a,b=b,a
    while b!=0:
        a,b=b,a%b
print(a)

Buggy submission (verdict: Runtime Error):
import functools
import math

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

A=list(map(int,input().split()))
B=[]
for i in range(len(A)):
    B.append(A[i]-X)
#print(B)

gcd = functools.reduce(math.gcd, B)
print(gcd)
Problem p03263 (python)

Fixed submission:
H,W=map(int,input().split())
L=[]

for i in range(H):
    L1=list(map(int,input().split()))
    L.append(L1)
ans=[]
cnt=0
for a in range(H):
    for b in range(W):
        if a%2==0:
            if b<W-1:
                if L[a][b]%2==1:
                    L[a][b]-=1
                    L[a][b+1]+=1
                    ans.append([a+1,b+1,a+1,b+2])
                    cnt+=1
            if b==W-1:
                if a<H-1:
                    if L[a][b]%2==1:
                        L[a][b]-=1
                        L[a+1][b]+=1
                        ans.append([a+1,b+1,a+2,b+1])
                        cnt+=1
        if a%2==1:
            if b<W-1:
                if L[a][W-1-b]%2==1:
                    L[a][W-1-b]-=1
                    L[a][W-1-b-1]+=1
                    ans.append([a+1,W-b,a+1,W-1-b])
                    cnt+=1
            if b==W-1:
                if a<H-1:
                    if L[a][W-1-b]%2==1:
                        L[a][W-1-b]-=1
                        L[a+1][W-1-b]+=1
                        ans.append([a+1,W-b,a+2,W-b])
                        cnt+=1
print(cnt)
for x in range(len(ans)):
    print(ans[x][0],ans[x][1],ans[x][2],ans[x][3])

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



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

A=list(map(int,input().split()))
B=[]
for i in range(len(A)):
    B.append(A[i]-X)
print(gcd(B))
Problem p03274 (python)

Fixed submission:
N,K=map(int,input().split())
x=list(map(int,input().split()))
#print(x)

list1=[]
for i in range(N-K+1):
    if x[i+K-1]<=0:
        list1.append(x[i]*(-1))
    elif x[i]>=0:
        list1.append(x[i+K-1])
    else:
        list1.append(x[i+K-1]*2-x[i])
        list1.append(x[i+K-1]-x[i]*2)
#print(list1)
print(min(list1))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
x=list(map(int,input().split()))
#print(x)

list1=[]
list2=[]
for i in range(len(x)):
    if x[i]<0:
        list2.append(x[i])
    else:
        list1.append(x[i])
list2.sort(reverse=True)
#print(list1)
#print(list2)
if N==1:
    print(abs(x[0]))
else:
    
    list3=[]
    for j in range(1,K):
        if len(list1)-j>=K-1:
            list3.append(list1[K-1])
        elif len(list1)-j>=0:
            list3.append(list1[len(list1)-j]*2+list2[K-2-len(list1)+j]*(-1))
            list3.append(list1[len(list1)-j]+list2[K-2-len(list1)+j]*(-2))
        elif list2[K-len(list1)+J]<=len(list2)-1 :
            list3.append(list2[K-1]*(-1))
            break
        else:
            break
        #print(j)
    #print(list3)
    print(min(list3))
Problem p03305 (python)

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

en=[[]for i in range(n+1)]
sn=[[]for i in range(n+1)]

for i in range(m):
    u,v,a,b=map(int,input().split())
    en[v].append((u,a))
    en[u].append((v,a))
    sn[v].append((u,b))
    sn[u].append((v,b))
#print(en)

import numpy as np
INF=10**20

def dijkstra(S, N, paths):
    from heapq import heappush,heappop
    q=[(0,S)]
    shortest=[INF]*N
    shortest[S]=0
    while len(q)>0:
        d0, src=heappop(q)
        if d0>shortest[src]:
            continue
        for dst, d1 in paths[src]:
            if d0+d1<shortest[dst]:
                shortest[dst]=d0+d1
                heappush(q, (d0+d1, dst))
    return np.array(shortest)
    
en=dijkstra(s,n+1,en)
sn=dijkstra(t,n+1,sn)

cost=[]
for i in range(1,n+1):
    cost.append(en[i]+sn[i])
cost=cost[::-1]
#print(cost)

ans=[]
mi=cost[0]
for i in range(n):
    ans.append(min(mi,cost[i]))
    mi=min(mi,cost[i])
ans=ans[::-1]
#print(ans)
for i in ans:
    print(10**15-i)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra
n,m,s,t=map(int,input().split())

E=[[10**15 for j in range(n+1)]for i in range(n+1)]
S=[[10**15 for j in range(n+1)]for i in range(n+1)]

for i in range(m):
    x,y,a,b=map(int,input().split())
    E[x][y]=a
    E[y][x]=a
    S[x][y]=b
    S[y][x]=b
    
#print(E)
#print(S)
E=dijkstra(E,indices = s)
S=dijkstra(S,indices = t)
#print(E)
#print(S)

Q=[]
for i in range(1,n+1):
    Q.append((int(E[i]+S[i]),i))

Q.sort()
cnt=0
for i in range(1,n+1):
    while Q[cnt][1]<i:
        cnt+=1
    print(10**15-Q[cnt][0])
#print(Q)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra
n,m,s,t=map(int,input().split())

E=[[10**15 for j in range(n+1)]for i in range(n+1)]
S=[[10**15 for j in range(n+1)]for i in range(n+1)]

for i in range(m):
    x,y,a,b=map(int,input().split())
    E[x][y]=a
    E[y][x]=a
    S[x][y]=b
    S[y][x]=b
    
#print(E)
#print(S)
E=dijkstra(E,indices = s)
S=dijkstra(S,indices = t)
#print(E)
#print(S)

Q=[]
for i in range(1,n+1):
    Q.append((int(E[i]+S[i]),i))

import heapq
heapq.heapify(Q)
for i in range(1,n+1):
    while Q[0][1]<i:
        heapq.heappop(Q)
    print(10**15-Q[0][0])
Problem p03309 (python)

Fixed submission:
N=int(input())

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

if N==1:
    print(0)
    exit()
elif N==2:
    B=[A[0]-1,A[1]-2]
    b=sum(B)//2
else:
    B=[]
    for i in range(N):
        B.append(A[i]-(1+i))
    #print(B)
    B.sort()
    #print(B)
    b=B[N//2]

ans=0
for i in range(N):
    ans+=abs(A[i]-(b+1+i))
print(ans)

Buggy submission (verdict: Runtime Error):
line=input()
line=line.rstrip().split(" ")
list1=[]
for i in range(N):
    list1.append(int(line[i])-i-1)
#print(list1)

list2=[]
list3=[]
for j in range(2):
    for k in range(N):
        list2.append(abs(list1[k]-1-j))
        
    list3.append(sum(list2))
    list2=[]
#print(list3)

if list3[0]==list3[1]:
    print(list3[0])
elif list3[0]<list3[1]:
    list2=[]
    list3=[]
    count=100000000000000000
    for l in range(1000000000):
        for m in range(N):
            list2.append(abs(list1[m]-1+l))
        if count>=sum(list2):
            count=sum(list2)
            #print(list2)
            list2=[]
            l=l+10
        else:
            count=100000000000000000
            for n in range(l,l+11):
                for o in range(N):
                    list2.append(abs(list1[o]-1+(n-10)))
                if count>=sum(list2):
                    count=sum(list2)
                    list2=[]
                else:
                    print(count)
                    break
                    
            
        
else: 
    list2=[]
    list3=[]
    count=100000000000000000
    for l in range(1000000000):
        for m in range(N):
            list2.append(abs(list1[m]-1-l))
        if count>=sum(list2):
            count=sum(list2)
            list2=[]
            l=l+10
        else:
            count=100000000000000000
            for n in range(l,l+11):
                for o in range(N):
                    list2.append(abs(list1[o]-1+(n-10)))
                if count>=sum(list2):
                    count=sum(list2)
                    list2=[]
                else:
                    print(count)
                    break
Problem p03328 (python)

Fixed submission:
list1=[1]
for i in range(2,1000):
    list1.append(list1[i-2]+i)
    
#print(list1[0:5])

line=input()
line=line.rstrip().split(" ")
a=int(line[0])
b=int(line[1])

print(list1[b-a-1]-b)

Buggy submission (verdict: Runtime Error):

N=int(input())

if N>=1000:
    print("ABD")
else:
    print("ABC")
Problem p03354 (python)

Fixed submission:
N,M=map(int,input().split())
p=list(map(int,input().split()))
p=[0]+p

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

def find(x):
    if par[x]==x:
        return x
    else:
        return find(par[x])

def union(x,y):
    if size[x]>size[y]:
        size[x]+=size[y]
        par[y]=find(x)
    elif size[y]>size[x]:
        size[y]+=size[x]
        par[x]=find(y)
    elif size[x]==size[y]:
        size[x]+=size[y]
        par[y]=find(x)
        
for i in range(M):
    a,b=map(int,input().split())
    if find(a)==find(b):
        pass
    else:
        union(find(a),find(b))
#print(par)
ans=0
for i in range(1,N+1):
    if find(i)==find(p[i]):
        ans+=1
        #print(i,find(i))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
p=list(map(int,input().split()))
p=[0]+p

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

def find(x):
    if par[x]==x:
        return x
    else:
        return find(par[x])

def union(x,y):
    if size[x]>size[y]:
        size[x]+=size[y]
        par[y]=find(x)
    elif size[y]>size[x]:
        size[y]+=size[x]
        par[x]=find(y)
    elif size[x]==size[y]:
        size[x]+=size[y]
        par[y]=find(x)
        
for i in range(M):
    a,b=map(int,input().split())
    if find(a)==find(b):
        pass
    else:
        union(find(a),find(b))
#print(par)
ans=0
for i in range(1,N+1):
    if find(i)==find(p.[i]):
        ans+=1
        #print(i,find(i))
print(ans)
Problem p03372 (python)

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

L=[]
for i in range(N):
    x,y=map(int,input().split())
    L.append([x,y])
    
l=L[::-1]
L=[[0,0]]+L
R=[]

for i in range(N):
    R.append([C-l[i][0],l[i][1]])
R=[[0,0]]+R


#print(L)
#print(R)
TS=[0]
TW=[0]
RS=[0]
RW=[0]

for i in range(N):
    TS.append(TS[i]-L[i+1][0]+L[i][0]+L[i+1][1])
    TW.append(TW[i]-2*(L[i+1][0]-L[i][0])+L[i+1][1])
    RS.append(RS[i]-R[i+1][0]+R[i][0]+R[i+1][1])
    RW.append(RW[i]-2*(R[i+1][0]-R[i][0])+R[i+1][1])
    
MTS=[0]
MRS=[0]
for i in range(1,N+1):
    MTS.append(max(MTS[i-1],TS[i]))
    MRS.append(max(MRS[i-1],RS[i]))

ans=0
for i in range(N+1):
    if i>0 and L[i-1][0]*2>C:
        break
    else:
        if ans<TW[i] + MRS[N-i]:
            ans=TW[i] + MRS[N-i]
            
for i in range(N+1):
    if i>0 and R[i-1][0]*2>C:
        break
    else:
        if ans<RW[i]+MTS[N-i]:
            ans=RW[i]+MTS[N-i]
print(ans)

Buggy submission (verdict: Runtime Error):
15 10000000000
400000000 1000000000
800000000 1000000000
1900000000 1000000000
2400000000 1000000000
2900000000 1000000000
3300000000 1000000000
3700000000 1000000000
3800000000 1000000000
4000000000 1000000000
4100000000 1000000000
5200000000 1000000000
6600000000 1000000000
8000000000 1000000000
9300000000 1000000000
9700000000 1000000000
Problem p03385 (python)

Fixed submission:
mojiretu = input()

a = mojiretu.count("a")
b = mojiretu.count("b")
c = mojiretu.count("c")

if int(a) ==1 and int(b) ==1 and int(c)==1:
    print("Yes")
else:
    print("No")

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

a = mojiretu.count(a)
b = mojiretu.count(b)
c = mojiretu.count(c)

if int(a)+int(b)+int(c)==3:
    print("Yes")
else:
    print("No")