Buggy python submission (verdict: Runtime Error):
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

adjList = defaultdict(list)

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    if b not in adjList[a]:
        adjList[a].append(b)
        
    if a not in adjList[b]:
        adjList[b].append(a)
    
mca = 0
visited = [False]*n

def dfs(node, cml):
    if len(adjList[node])>0:
        for ngh in adjList[node]:
            if not visited[ngh]:
                visited[ngh] = True
                cml = dfs(ngh, cml+1)
    
    return cml

for i in range(n):
    if not visited[i]:
        visited[i] = True
        ca = dfs(i, 1)
        mca = max(mca, ca)

print(mca)
    
    

Fixed submission:
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

dp = [-1]*n

def root(x):
    if dp[x] < 0:
        return x
    return root(dp[x])

def unite(x, y):
    rx = root(x)
    ry = root(y)
    
    if rx == ry:
        return False
        
    if dp[rx] > dp[ry]:
        rx,ry = ry,rx
        
    dp[rx] += dp[ry]
    dp[ry] = rx
    return True

def size(x):
    return -dp[root(x)]

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    unite(a,b)
    
ans = 0
for i in range(n):
    ans = max(ans, size(i))
    
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

adjList = defaultdict(list)

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    if b not in adjList[a]:
        adjList[a].append(b)
        
    if a not in adjList[b]:
        adjList[b].append(a)
    
mca = 0
visited = [False]*n

def dfs(node, cml):
    visited[node] = True
    
    if adjList[node]:
        for ngh in adjList[node]:
            if not visited[ngh]:
                cml = dfs(ngh, cml+1)
    
    return cml

for i in range(n):
    if not visited[i]:
        ca = dfs(i, 1)
        mca = max(mca, ca)

print(mca)
    
    

Fixed submission:
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

dp = [-1]*n

def root(x):
    if dp[x] < 0:
        return x
    return root(dp[x])

def unite(x, y):
    rx = root(x)
    ry = root(y)
    
    if rx == ry:
        return False
        
    if dp[rx] > dp[ry]:
        rx,ry = ry,rx
        
    dp[rx] += dp[ry]
    dp[ry] = rx
    return True

def size(x):
    return -dp[root(x)]

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    unite(a,b)
    
ans = 0
for i in range(n):
    ans = max(ans, size(i))
    
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

adjList = defaultdict(list)

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    if b not in adjList[a]:
        adjList[a].append(b)
        
    if a not in adjList[b]:
        adjList[b].append(a)
    
mca = 0
visited = [False]*(n+1)

def dfs(node, cml):
    visited[node] = True
    
    if adjList[node]:
        for ngh in adjList[node]:
            if not visited[ngh]:
                cml = dfs(ngh, cml+1)
    
    return cml

for i in range(n):
    if not visited[i+1]:
        ca = dfs(i+1, 1)
        mca = max(mca, ca)

print(mca)
    
    

Fixed submission:
from collections import defaultdict 

n,m = map(int, input().strip().split(" "))

dp = [-1]*n

def root(x):
    if dp[x] < 0:
        return x
    return root(dp[x])

def unite(x, y):
    rx = root(x)
    ry = root(y)
    
    if rx == ry:
        return False
        
    if dp[rx] > dp[ry]:
        rx,ry = ry,rx
        
    dp[rx] += dp[ry]
    dp[ry] = rx
    return True

def size(x):
    return -dp[root(x)]

for i in range(m):
    a,b = map(int, input().strip().split(" "))
    a-=1
    b-=1
    unite(a,b)
    
ans = 0
for i in range(n):
    ans = max(ans, size(i))
    
print(ans)