Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

checked = [False for _ in range(N)]
ans = 0
for i in range(N):
    if checked[i]:
        continue

    checked[i] = True
    A = G[i]
    tmp = 1
    while len(A) > 0:
        e = A.pop()
        if checked[e]:
            continue
        checked[e] = True
        tmp += 1
        A = A + G[e]

    ans = max(ans, tmp)

print(ans)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, v):
        if self.parents[v] < 0:
            return v
        else:
            self.parents[v] = self.find(self.parents[v])
            return self.parents[v]

    def unite(self, u, v):
        u = self.find(u)
        v = self.find(v)

        if u == v:
            return

        if self.parents[u] > self.parents[v]:
            u, v = v, u

        self.parents[u] += self.parents[v]
        self.parents[v] = u

    def size(self, v):
        return -self.parents[self.find(v)]

    def same(self, u, v):
        return self.find(u) == self.find(v)

N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

checked = [False for _ in range(N)]
ans = 0
for i in range(N):
    if checked[i]:
        continue

    checked[i] = True
    A = G[i]
    tmp = 1
    while len(A) > 0:
        e = A.pop()
        if checked[e]:
            continue
        checked[e] = True
        tmp += 1
        A = A + G[e]

    ans = max(ans, tmp)

print(ans)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, v):
        if self.parents[v] < 0:
            return v
        else:
            self.parents[v] = self.find(self.parents[v])
            return self.parents[v]

    def unite(self, u, v):
        u = self.find(u)
        v = self.find(v)

        if u == v:
            return

        if self.parents[u] > self.parents[v]:
            u, v = v, u

        self.parents[u] += self.parents[v]
        self.parents[v] = u

    def size(self, v):
        return -self.parents[self.find(v)]

    def same(self, u, v):
        return self.find(u) == self.find(v)

N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
G = [set() for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].add(b-1)
    G[b-1].add(a-1)

checked = [False for _ in range(N)]
ans = 0
for i in range(N):
    if checked[i]:
        continue

    checked[i] = True
    A = G[i]
    tmp = 1
    while len(A) > 0:
        e = A.pop()
        if checked[e]:
            continue
        checked[e] = True
        tmp += 1
        A = A | G[e]

    ans = max(ans, tmp)

print(ans)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, v):
        if self.parents[v] < 0:
            return v
        else:
            self.parents[v] = self.find(self.parents[v])
            return self.parents[v]

    def unite(self, u, v):
        u = self.find(u)
        v = self.find(v)

        if u == v:
            return

        if self.parents[u] > self.parents[v]:
            u, v = v, u

        self.parents[u] += self.parents[v]
        self.parents[v] = u

    def size(self, v):
        return -self.parents[self.find(v)]

    def same(self, u, v):
        return self.find(u) == self.find(v)

N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    uf.unite(a-1, b-1)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)