Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math

a,b,x=map(int,input().split())

if x<=(a**2)*b/2:
    t=a-(a-(2*x)/a/b)
    ans=math.atan(b/t)
    ans=math.degrees(ans)
    
    print(ans)
else:
    
    t=2*(b-x/(a**2))
    ans=math.atan(a/t)
    ans=math.degrees(ans)
    
    print(90-ans)


Fixed submission:
# coding: utf-8
# Your code here!
import math

a,b,x=map(int,input().split())

if x==a**2*b:
    print(0)
    exit()

if x<=(a**2)*b/2:
    t=a-(a-(2*x)/a/b)
    ans=math.atan(b/t)
    ans=math.degrees(ans)
    
    print(ans)
else:
    
    t=2*(b-x/(a**2))
    ans=math.atan(a/t)
    ans=math.degrees(ans)
    
    print(90-ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect

N=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        insert_index = bisect.bisect_left(l[j+1:N],l[i]+l[j])
        ans+=(insert_index)
        
print(ans)


Fixed submission:
# coding: utf-8
# Your code here!
import bisect

N=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        insert_index = bisect.bisect_left(l,l[i]+l[j])
        ans+=(insert_index-j-1)
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect

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

ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if l[i]<(l[j]+l[k]) and l[j]<(l[i]+l[k]) and l[k]<(l[j]+l[i]):
                ans+=1
print(ans)
#くそでは？

Fixed submission:
# coding: utf-8
# Your code here!
import bisect

N=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        insert_index = bisect.bisect_left(l,l[i]+l[j])
        ans+=(insert_index-j-1)
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import bisect

N=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        insert_index = bisect.bisect_left(l[j+1:N],l[i]+l[j])
        ans+=(insert_index)
            
print(ans)


Fixed submission:
# coding: utf-8
# Your code here!
import bisect

N=int(input())
l=list(map(int,input().split()))
l.sort()

ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        insert_index = bisect.bisect_left(l,l[i]+l[j])
        ans+=(insert_index-j-1)
        
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W,A,B=map(int,input().split())

if W/A==H/B or W/A==0 or H/B==0:
    for h in range(H):
        S=[0]*W
        for i in range(A):
            S[W*h//H-i]=1
        print(S)
else:
    print(-1)



Fixed submission:
# coding: utf-8
# Your code here!
H,W,A,B=map(int,input().split())

ans=[]
for b in range(B):
    ans.append(["1"]*A+["0"]*(W-A))
for b in range(H-B):
    ans.append(["0"]*A+["1"]*(W-A))

for item in ans:
    print("".join(item))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
N=int(input())
l=[]

for i in range(N):
    l.append(i)
    
print(sum(l))


Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())
 
print(int(N*(N-1)//2))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1

if len(S)==3:
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if pre[-1]==S[1] or S[1]==S[0]:
        print(S[10])
        print(count+1)
    else:
        print(count+2)


Fixed submission:
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1
#print(S[::-1])
if len(S)==3:
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if S[1]==S[0]:#aabbaが出来ればよい
        print(count+1)
    else:
        print(count+2)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1

if len(S)==3:
    print(S[10])
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if pre[-1]==S[1] or S[1]==S[0]:
        print(count+1)
    else:
        print(count+2)


Fixed submission:
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1
#print(S[::-1])
if len(S)==3:
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if S[1]==S[0]:#aabbaが出来ればよい
        print(count+1)
    else:
        print(count+2)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1
if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
    print(count+2)
else:
    print(count+3)


Fixed submission:
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1
#print(S[::-1])
if len(S)==3:
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if S[1]==S[0]:#aabbaが出来ればよい
        print(count+1)
    else:
        print(count+2)
Buggy python submission (verdict: Runtime Error):
N=int(input())
l=list(map(int,input().split()))

if N==1:
    print("Yes")
    exit()

if N==2 and l[1]-l[0]<(-1):
    print("No")
    exit()
    

for i in range(N-2):
    if l[i+2]-l[i+1]<(0) and l[i+i]-l[i]<(0):
        print("No")
        exit()
    elif l[i+i]-l[i]<(-1):
        print("No")
        exit()

print("Yes")

Fixed submission:
# coding: utf-8
# Your code here!

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

high=l[0]
for i in range(N-1):
    if l[i+1]-l[i]<(-1):
        print("No")
        exit()
    high=max(high,l[i+1])
    if l[i+1]<(high-1):
        print("No")
        exit()
        
print("Yes")

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

if N==2 and l[1]-l[0]<(-1):
    print("No")
    exit()
    

for i in range(N-2):
    if l[i+2]-l[i+1]<(0) and l[i+i]-l[i]<(0):
        print("No")
        exit()
    elif l[i+i]-l[i]<(-1):
        print("No")
        exit()

print("Yes")

Fixed submission:
# coding: utf-8
# Your code here!

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

high=l[0]
for i in range(N-1):
    if l[i+1]-l[i]<(-1):
        print("No")
        exit()
    high=max(high,l[i+1])
    if l[i+1]<(high-1):
        print("No")
        exit()
        
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
S=list(input())
N=len(S)

dp=[[0 for i in range(13)] for j in range(N+1)]
dp[0][0]=1

for i in range(N):
    if S[i]=="?":
        temp=10**((N-i-1)%6)
        for j in range(10):
            for k in range(13):
                dp[i+1][(k+j*temp)%13]+=dp[i][k]
                dp[i+1][(k+j*temp)%13]%=10**9+7
                    
    else:
        temp=int(S[i])*10**((N-i-1)%6)
        for k in range(13):
            dp[i+1][(k+temp)%13]+=dp[i][k]
            dp[i+1][(k+temp)%13]%=10**9+7

print(dp[-1][5])

Fixed submission:
S=list(input())
N=len(S)

dp=[[0 for i in range(13)] for j in range(N+1)]
dp[0][0]=1

for i in range(N):
    if S[i]=="?":
        temp=10**((N-i-1)%6)
        for j in range(10):
            for k in range(13):
                dp[i+1][(k+j*temp)%13]+=dp[i][k]
                dp[i+1][(k+j*temp)%13]%=10**9+7
                    
    else:
        temp=int(S[i])*10**((N-i-1)%6)
        for k in range(13):
            dp[i+1][(k+temp)%13]+=dp[i][k]
            dp[i+1][(k+temp)%13]%=10**9+7

print(dp[-1][5])

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def saiki(num,lis):
    if num==6:
        temp=0
        for i in range(6):
            temp+=lis[i]*10**(5-i)
        if (temp+amari)%13==5:
            cand.append(lis)
        return 0
    else:
        for i in range(10):
            saiki(num+1,lis+[i])
            

S=list(input())
N=len(S)

num=[0]*6#左から大きい
que=[0]*6

for i in range(N):
    if S[i]=="?":
        que[i%6]+=1
    else:
        num[i%6]+=int(S[i])

for i in range(6):
    num[i]%=10
amari=0
for i in range(6):
    amari+=(num[i]*10**(5-i))%13
amari%=13

cand=[]
saiki(0,[])

#print(amari)
#print(cand)
"""
ans=0
for item in cand:
    temp=1
    for i in range(6):
        if que[i]==0 and item[i]!=0:
            temp=0
            break
        else:
            for j in range(que[i]-1):
                temp*=(item[i]+que[i]-j-1)
    ans+=temp
    """
    """
    if temp!=0:
        print(item)
        print(ans)
    """
    """
print(ans%(10**9+7))
            
"""

Fixed submission:
S=list(input())
N=len(S)

dp=[[0 for i in range(13)] for j in range(N+1)]
dp[0][0]=1

for i in range(N):
    if S[i]=="?":
        temp=10**((N-i-1)%6)
        for j in range(10):
            for k in range(13):
                dp[i+1][(k+j*temp)%13]+=dp[i][k]
                dp[i+1][(k+j*temp)%13]%=10**9+7
                    
    else:
        temp=int(S[i])*10**((N-i-1)%6)
        for k in range(13):
            dp[i+1][(k+temp)%13]+=dp[i][k]
            dp[i+1][(k+temp)%13]%=10**9+7

print(dp[-1][5])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N=int(input())

line=[-1]*10**5

for _ in range(N):
    A=int(input())
    index=bisect.bisect_left(line,A)
    if index==0:
        line[0]=A
    else:
        line[index-1]=A
    line.sort()
    #print(line)
ans=[]
while line:
    num=line.pop(-1)
    if num==-1:
        break
    else:
        ans.append(num)

print(len(ans))

Fixed submission:
import bisect
import collections

N=int(input())

line=collections.deque()

for _ in range(N):
    A=int(input())
    index=bisect.bisect_left(line,A)
    if index==0:
        line.appendleft(A)
    else:
        line[index-1]=A
    #print(line)
    
    #print(line)

print(len(line))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N=int(input())

line=[]

for _ in range(N):
    A=int(input())
    index=bisect.bisect_left(line,A)
    if index==0:
        line.insert(index,A)
    else:
        line[index-1]=A
        line.sort()
    
    #print(line)

print(len(line))

Fixed submission:
import bisect
import collections

N=int(input())

line=collections.deque()

for _ in range(N):
    A=int(input())
    index=bisect.bisect_left(line,A)
    if index==0:
        line.appendleft(A)
    else:
        line[index-1]=A
    #print(line)
    
    #print(line)

print(len(line))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N=int(input())

line=[]

for _ in range(N):
    A=int(input())
    index=bisect.bisect_left(line,A)
    if index==0:
        line.insert(index,A)
    else:
        line.pop(index-1)
        bisect.insort_right(line,A)
    
    #print(line)

print(len(line))

Fixed submission:
import bisect
import collections

N=int(input())

line=collections.deque()

for _ in range(N):
    A=int(input())
    index=bisect.bisect_left(line,A)
    if index==0:
        line.appendleft(A)
    else:
        line[index-1]=A
    #print(line)
    
    #print(line)

print(len(line))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

N=int(input())

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

init=l.pop(-1)

left=init
center=0

ans=[left]

def find(left):
    if len(l)==1:
        ans.append(l.pop(0))
        pass
    elif len(l)==0:
        pass
        
    else:
        right=l.pop(-1)
        for i in range(len(l)):
            if l[i]==left^right:
                center=l.pop(i)
                ans.append(center)
                ans.append(right)
                find(right)
                break
            else:
                break
            
find(left)

if len(ans)==N:
    if ans[0]==ans[1]^ans[-1] and ans[-1]==ans[0]^ans[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(set(A))

if len(B)==3:
    if B[0]^B[1]==B[2]:
        if A.count(B[0])==A.count(B[1]) and A.count(B[1])==A.count(B[2]):
            print("Yes")
            exit()
elif len(B)==2:
    if 2*A.count(B[0])==A.count(B[1]):
        print("Yes")
        exit()
elif len(B)==1:
    if B[0]==0:
        print("Yes")
        exit()

print("No")

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

N=int(input())

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

init=l.pop(-1)

left=init
center=0
judge=False

ans=[left]

def find(left):
    if len(l)<2:
        if len(l)==1:
            ans.append(l.pop(0))
        else:
            pass
        
    else:
        right=l.pop(-1)
        for i in range(len(l)):
            if l[i]==left^right:
                center=l.pop(i)
                ans.append(center)
                ans.append(right)
                find(right)
            else:
                break
            
find(left)

if len(ans)==N:
    if ans[0]==ans[1]^ans[-1]:
        print("Yes")
else:
    print("No")













Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(set(A))

if len(B)==3:
    if B[0]^B[1]==B[2]:
        if A.count(B[0])==A.count(B[1]) and A.count(B[1])==A.count(B[2]):
            print("Yes")
            exit()
elif len(B)==2:
    if 2*A.count(B[0])==A.count(B[1]):
        print("Yes")
        exit()
elif len(B)==1:
    if B[0]==0:
        print("Yes")
        exit()

print("No")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import heapq

L,R=map(int,input().split())

l=list(range(L,R+1))
q=[]

for item in l:
   heapq.heappush(q,item%2019)

print(heapq.heappop(q)*heapq.heappop(q))




Fixed submission:
# coding: utf-8
# Your code here!
import heapq
 
L,R=map(int,input().split())
 
ans=2018*2017
if (R-L)>=2018:
    print("0")
else:
    l=list(range(L,R+1))
    for i in range(len(l)):
        for j in range(i+1,len(l)):
            #print(l[i],l[j],(l[i]*l[j])%2019)
            ans=min(ans,(l[i]*l[j])%2019)
            

    print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def dfs(num):
    temp=K-len(way[num])
    
    for w in way[num]:
        if visited[w]==0:
            visited[w]=temp
            temp+=1
            dfs(w)
    
    return 

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

mod=10**9+7

visited=[0]*N
way=[[] for i in range(N)]

for _ in range(N-1):
    a,b=map(int,input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)
    
color=[]
visited[0]=K
dfs(0)

#print(visited)
ans=1
for item in visited:
    ans*=item
    ans%=mod
print(ans)


Fixed submission:
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**9)

def dfs(num):
    temp=K-len(way[num])
    
    for w in way[num]:
        if visited[w]==-1:
            visited[w]=temp
            temp+=1
            dfs(w)
    
    return 

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

mod=10**9+7

visited=[-1]*N
way=[[] for i in range(N)]

for _ in range(N-1):
    a,b=map(int,input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)
    
color=[]
visited[0]=K
dfs(0)

#print(way)
#print(visited)
ans=1
for item in visited:
    ans*=item
    ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math

A,B,C,D=map(int,input().split())
A-=1
print(A)
num1=A-A//C-A//D+(A//(C*D//math.gcd(C, D)))
num2=B-B//C-B//D+(B//(C*D//math.gcd(C, D)))

print(num1)
print(num2)

print(num2-num1)

Fixed submission:
# coding: utf-8
# Your code here!
A,B,C,D=map(int,input().split())
A-=1

def gcd(a,b):
    ans=1
    for i in range(1,int(min(a,b)**0.5)+1):
        
        if a%i==0 and b%i==0:
            ans=max(ans,i)
        temp=min(a,b)//i
        if a%temp==0 and b%temp==0:
            ans=max(ans,temp)
    return ans

num1=A-A//C-A//D+(A//(C*D//gcd(C, D)))
num2=B-B//C-B//D+(B//(C*D//gcd(C, D)))

print(num2-num1)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n,x=map(int,input().split())
A=list(map(int,input().split()))

count=0
sm=0
while sm<=x:
    count+=1
    sm+=A[count-1]

print(count)

Fixed submission:
# coding: utf-8
# Your code here!
n,x=map(int,input().split())
A=list(map(int,input().split()))

for i in range(n):
    if x-A[i]<0:
        print(i+1)
        exit()
    else:
        x-=A[i]

print(n+1)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

for i in range(N):
    A[i]-=(i+1)

a=2*N
b=sum([A[i]*2 for i in range(N)])

x1=b//a
x2=-(-b//a)
x0=min(x1,x2)-1
x3=max(x1,x2)+1
X=[x0,x1,x2,x3]

ans=10**18
def count(num):
    temp=0
    for i in range(N):
        temp+=abs(A[i]-num)
    return temp

for x in X:
    ans=min(count(x),ans)

print(ans)



Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())

l=[]
for i in range(N):
    l.append(list(map(int,input().split())))

dis=[[0]*(N) for i in range(N-1)]
#print(dis)

for i in range(N-1):
    for j in range(i+1,N):
        if l[i][0]-l[j][0]>0:
            dis[i][j]=[(l[i][0]-l[j][0]),(l[i][1]-l[j][1])]
        elif l[i][0]-l[j][0]<0:
            dis[i][j]=[-(l[i][0]-l[j][0]),-(l[i][1]-l[j][1])]
        else:
            dis[i][j]=[(l[i][0]-l[j][0]),abs(l[i][1]-l[j][1])]

temp=0
for i in range(N-1):
    for item in dis[i]:
        if item!=0:
            temp=max(sum(x.count(item) for x in dis),temp)

#print(l)
#print(dis)
print(N-temp)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
V=list(map(int,input().split()))

left=[0]
right=[0]

for n in range(N):
    left.append(V[n]+left[n])
for n in range(N):
    right.append(V[-n-1]+right[n])

#print(left)
#print(right)

dp=[[0]*(K+1) for _ in range(K+1)]

for l in range(K+1):
    for r in range(K-l+1):
        dp[l][r]=left[l]+right[r]
        temp=V[:l]+V[::-1][:r]#ここが不味い
        #print(temp)
        temp.sort()
        
        
        for i in range(K-l-r):
            #ここでマイナス項を引きたい
            if len(temp)==0 or temp[0]>=0:
                break
            else:
                dp[l][r]-=temp.pop(0)
ans=0
for item in dp:
    for obj in item:
        ans=max(ans,obj)
#print(dp)
print(ans)

#保存


Fixed submission:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
V=list(map(int,input().split()))

left=[0]
right=[0]

for n in range(N):
    left.append(V[n]+left[n])
for n in range(N):
    right.append(V[-n-1]+right[n])

#print(left)
#print(right)

dp=[[0]*(K+1) for _ in range(K+1)]

for l in range(min(K+1,N+1)):
    for r in range(min(K-l+1,N-l+1)):
        dp[l][r]=left[l]+right[r]
        if N>l+r:
            temp=V[:l]+V[::-1][:r]#ここが不味い
        else:
            temp=V[:]
        #print(V,l,r,temp)
        temp.sort()
        
        #for i in range(min(K-l-r,N-l-r)):
        for i in range(K-l-r):
            #ここでマイナス項を引きたい
            if len(temp)==0 or temp[0]>=0:
                break
            else:
                e=temp.pop(0)
                #print(e)
                dp[l][r]-=e
                
ans=0
for item in dp:
    for obj in item:
        ans=max(ans,obj)
#print(dp)
print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**5)

def dfs(num,log):
    visited[num]=min(log,visited[num])
    for item in way[num]:
        if visited[item]==10**7:
            dfs(item,log)
    return 

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

visited=[10**7]*N
way=[[] for i in range(N)]
order=[]

for _ in range(M):
    X,Y,Z=map(int,input().split())
    X,Y=min(X,Y),max(X,Y)
    order.append([X-1,Y-1,Z])

order.sort(key=lambda x:(x[0],x[1]))

for item in order:
    way[item[0]].append(item[1])
    way[item[1]].append(item[0])
    
for i in range(N):
    dfs(i,i)

visited=list(set(visited))
print(len(visited))

Fixed submission:
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**7)

def dfs(num,log):
    visited[num]=min(log,visited[num])
    for item in way[num]:
        if visited[item]==10**7:
            dfs(item,log)
    return 

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

visited=[10**7]*N
way=[[] for i in range(N)]
order=[]

for _ in range(M):
    X,Y,Z=map(int,input().split())
    X,Y=min(X,Y),max(X,Y)
    order.append([X-1,Y-1,Z])

order.sort(key=lambda x:(x[0],x[1]))

for item in order:
    way[item[0]].append(item[1])
    way[item[1]].append(item[0])
    
for i in range(N):
    dfs(i,i)

visited=list(set(visited))
print(len(visited))
Buggy python submission (verdict: Runtime Error):
N=int(input())
rissoku=10**9

for _ in range(5):
    rissoku=min(rissoku,int(input()))

if N%rissoku=0:
    print((N//rissoku)+4)
else:
    print((N//rissoku)+5)

Fixed submission:
N=int(input()) 
rissoku=10**18
for _ in range(5): 
    rissoku=min(rissoku,int(input())) 

if N%rissoku==0: 
    print((N//rissoku)+4) 
else: 
    print((N//rissoku)+5)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
X,Y,Z,K=map(int,input().split())
A=(list(map(int,input().split())))
B=(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=max(A)+max(B)+max(C)

temp=[]
for a in A:
    for b in B:
        temp.append(a+b)

temp.sort()

dif=[temp[i]-temp[i+1] for i in range(len(temp)-1)[::-1]]
dif_c=[C[i]-C[i+1] for i in range(len(C)-1)[::-1]]

dif=dif[:K]

temp=[]
for d in dif:
    for dc in dif_c:
        temp.append(d+dc)
temp.sort()
temp=temp[::-1]
for k in range(K):
    print(ans)
    ans+=temp[k]

print(temp)


Fixed submission:
# coding: utf-8
# Your code here!
X,Y,Z,K=map(int,input().split())
A=(list(map(int,input().split())))
B=(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=max(A)+max(B)+max(C)

temp=[]
for a in A:
    for b in B:
        temp.append(a+b)

temp.sort()

dif=[temp[i]-temp[-1] for i in range(len(temp))[::-1]]
dif_c=[C[i]-C[-1] for i in range(len(C))[::-1]]

dif=dif[:K]

temp=[]
for d in dif:
    for dc in dif_c:
        temp.append(ans+d+dc)
temp.sort()
temp=temp[::-1]

for k in range(K):
    print(temp[k])

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
X,Y,Z,K=map(int,input().split())
A=(list(map(int,input().split())))
B=(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=max(A)+max(B)+max(C)

temp=[]
for a in A:
    for b in B:
        temp.append(a+b)

temp.sort()

dif=[temp[i]-temp[i+1] for i in range(len(temp)-1)[::-1]]
dif_c=[C[i]-C[i+1] for i in range(len(C)-1)[::-1]]

dif=dif[:K]

temp=[]
for d in dif:
    for dc in dif_c:
        temp.append(d+dc)
temp.sort()
temp=temp[::-1]
for k in range(K):
    print(ans)
    ans+=temp[k]

print(temp)
#TLEでそう

Fixed submission:
# coding: utf-8
# Your code here!
X,Y,Z,K=map(int,input().split())
A=(list(map(int,input().split())))
B=(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=max(A)+max(B)+max(C)

temp=[]
for a in A:
    for b in B:
        temp.append(a+b)

temp.sort()

dif=[temp[i]-temp[-1] for i in range(len(temp))[::-1]]
dif_c=[C[i]-C[-1] for i in range(len(C))[::-1]]

dif=dif[:K]

temp=[]
for d in dif:
    for dc in dif_c:
        temp.append(ans+d+dc)
temp.sort()
temp=temp[::-1]

for k in range(K):
    print(temp[k])