Problem p02573 (python)

Fixed submission:
l=lambda:map(int, input().split())
n,m=l()
p=[-1]*n
def r(x):
  if p[x]<0:return x
  p[x]=r(p[x]);return r(p[x])
def u(x,y):
  x,y=r(x),r(y)
  if x==y: return  
  p[x]+=p[y]
  p[y]=x
def e(x,y):
  return r(x)==r(y)
def s(x):
  return -p[r(x)]
for _ in range(m):
  a,b=l()
  u(a-1,b-1)
print(-min(p))

Buggy submission (verdict: Runtime Error):
l=lambda:map(int, input().split())
n,m=l()
p=[-1]*n
p=[-1]*n
def root(x):
  if p[x]<0:return x
  return (x:=root(p[x]))
def union(x,y):
  x,y=root(x),root(y)
  if x==y: return
  p[x]+=p[y]
  p[y]=x
def same(x,y):
  return root(x)==root(y)
def size(x):
  return -p[r(x)]
for _ in range(m):
  a,b=l()
  union(a-1,b-1)
print(-min(p))

Buggy submission (verdict: Runtime Error):
from networkx import*;_,*n=map(str.split,open(0));print(max(map(len,[*connected_components(Graph(n))]),1,1))

Buggy submission (verdict: Runtime Error):
from networkx import*;_,*n=map(str.split,open(0));print(max(map(len,[*connected_components(Graph(n))]),1,1))

Buggy submission (verdict: Runtime Error):
from networkx import*
_,*n=map(str.split,open(0))
print(len(max([*connected_components(Graph(n))],key=len)))

Buggy submission (verdict: Runtime Error):
from networkx import*;_,*n=map(str.split,open(0));print(max(map(len,[*connected_components(Graph(n))])))

Buggy submission (verdict: Runtime Error):
l=lambda:map(int, input().split())
n,m=l()
p=[-1]*n
def r(x):
  if p[x]<0:return x
  p[x]=r(p[x]);return r(p[x])
def u(x,y):
  x,y=r(x),(y)
  if x==y: return  
  if x>y: x,y=y,x
  p[x]+=p[y]
  p[y]=x
def e(x,y):
  return r(x)==r(y)
def s(x):
  return -p[r(x)]
for _ in range(m):
  a,b=l()
  u(a-1,b-1)
print(-min(p))

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


class UnionFind:
    def __init__(self, n):
        self.__par = list(range(n))
        self.__siz = [1]*len(self.__par)

    def root(self, ix):
        if self.__par[ix] == ix:
            return ix
        return self.root(self.__par[ix])

    def unite(self, ix, iy):
        rx = self.root(ix)
        ry = self.root(iy)
        if rx == ry:
            return
        self.__siz[ry] += self.__siz[rx]
        self.__par[rx] = ry

    def isAkin(self, ix, iy):
        return self.root(ix) == self.root(iy)

    def size(self, ix):
        return self.__siz[self.root(ix)]


uf = UnionFind(n)
for i in range(m):
    x,y = map(int, input().split())
    uf.unite(x-1, y-1)

res = 0
for i in range(n):
    res = max(res, uf.size(i))
print(res)

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


class UnionFind:
    def __init__(self, n):
        self.__par = list(range(n))
        self.__siz = [1]*len(self.__par)

    def root(self, ix):
        if self.__par[ix] == ix:
            return ix
        return self.root(self.__par[ix])

    def unite(self, ix, iy):
        rx = self.root(ix)
        ry = self.root(iy)
        if rx == ry:
            return
        self.__siz[ry] += self.__siz[rx]
        self.__par[rx] = ry

    def isAkin(self, ix, iy):
        return self.root(ix) == self.root(iy)

    def size(self, ix):
        return self.__siz[self.root(ix)]


uf = UnionFind(n)
for i in l:
    uf.unite(i[0]-1, i[1]-1)

res = 0
for i in range(n):
    res = max(res, uf.size(i))
print(res)