Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def main():
    n, m = list(map(int, input().split(" ")))
    v_set = [set([]) for _ in range(n)]
    for _ in range(m):
        a, b = list(map(int, input().split(" ")))
        v_set[a-1].add(b-1)
        v_set[b-1].add(a-1)

    max_num = 0
    seen = [0]*n
    for ni in range(n):
        if seen[ni]:
            continue
        checked = [0]*n
        stack = deque([ni])
        checked[ni] = 1
        while stack:
            cur = stack.pop()
            seen[cur]+=1
            for next_i in v_set[cur]:
                if seen[next_i] or checked[next_i]:
                    continue
                stack.append(next_i)
                checked[next_i] = 1
        max_num = max(max_num, sum(checked))

    print(max_num)

if __name__=="__main__":
    main()


Fixed submission:
from collections import deque

def main():
    n, m = list(map(int, input().split(" ")))
    v_set = [set([]) for _ in range(n)]
    for _ in range(m):
        a, b = list(map(int, input().split(" ")))
        v_set[a-1].add(b-1)
        v_set[b-1].add(a-1)

    max_num = 0
    checked = [0]*n
    for ni in range(n):
        if checked[ni]:
            continue
        stack = deque([ni])
        checked[ni] = 1
        f = 1
        while stack:
            cur = stack.pop()
            for next_i in v_set[cur]:
                if checked[next_i]:
                    continue
                stack.append(next_i)
                checked[next_i] = 1
                f+=1
        max_num = max(max_num, f)

    print(max_num)

if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def main():
    n, m = list(map(int, input().split(" ")))
    v_set = [set([]) for _ in range(n)]
    for _ in range(m):
        a, b = list(map(int, input().split(" ")))
        v_set[a-1].add(b-1)
        v_set[b-1].add(a-1)

    max_num = 0
    checked_list = []
    seen = [0]*n
    for ni in range(n):
        if seen[ni]:
            continue
        checked = []
        stack = deque([ni])
        while stack:
            cur = stack.pop()
            seen[cur]+=1
            checked.append(cur)
            for next_i in v_set[cur]:
                if seen[next_i] or next_i in stack:
                    continue
                stack.append(next_i)
        max_num = max(max_num, len(checked))
        checked_list.append(checked)

    print(max_num)

if __name__=="__main__":
    main()


Fixed submission:
from collections import deque

def main():
    n, m = list(map(int, input().split(" ")))
    v_set = [set([]) for _ in range(n)]
    for _ in range(m):
        a, b = list(map(int, input().split(" ")))
        v_set[a-1].add(b-1)
        v_set[b-1].add(a-1)

    max_num = 0
    checked = [0]*n
    for ni in range(n):
        if checked[ni]:
            continue
        stack = deque([ni])
        checked[ni] = 1
        f = 1
        while stack:
            cur = stack.pop()
            for next_i in v_set[cur]:
                if checked[next_i]:
                    continue
                stack.append(next_i)
                checked[next_i] = 1
                f+=1
        max_num = max(max_num, f)

    print(max_num)

if __name__=="__main__":
    main()