Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
    def __init__(self, n):
        self.n = n
        #親の添字、親自身は木の要素数*-1をもつ
        self.root = [-1]*(n)
        #枝の最大長さ
        self.rank = [0]*(n)

    def find_root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]
    #高さによる合併    
    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return 
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)
    
    def count(self, x):
        return -self.root[self.find_root(x)]    
    
    def members(self, x):
        root = self.find_root(x)
        return [i for i in range(self.n) if self.find_root(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
n, m = map(int,input().rstrip().split())
ab = [list(map(int,input().split()))for _ in range(m)]

u = UnionFind(n)
for a,b in ab:
    u.unite(a-1,b-1)
d =u.all_group_members()
ans = 0
for k in d:
    if ans < len(d[k]):
        ans = len(d[k])
print(ans)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        #親の添字、親自身は木の要素数*-1をもつ
        self.root = [-1]*(n)
        #枝の最大長さ
        self.rank = [0]*(n)
        #最大メンバー数
        self.maxmem = 1

    def find_root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]
    #高さによる合併    
    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return 
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
            if self.maxmem < -1*self.root[x]:
                self.maxmem = -1*self.root[x]
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1
            if self.maxmem < -1*self.root[y]:
                self.maxmem = -1*self.root[y]
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)
    
    def count(self, x):
        return -self.root[self.find_root(x)]    
    
    def members(self, x):
        root = self.find_root(x)
        return [i for i in range(self.n) if self.find_root(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
n, m = map(int,input().rstrip().split())
ab = [list(map(int,input().split()))for _ in range(m)]

u = UnionFind(n)
for a,b in ab:
    u.unite(a-1,b-1)
print(u.maxmem)