Buggy python submission (verdict: Runtime Error):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    from collections import deque
    N, M = MI()
    fri_list = []
    num_list = [0] * (N + 1)
    for i in range(M):
        a, b = MI()
        if num_list[a] == 0 and num_list[b] == 0:
            fri_list.append([a, b])
        elif num_list[a] == 0 or num_list[b] == 0:
            for l in fri_list:
                if a in l:
                    l.append(b)
                elif b in l:
                    l.append(a)
        else:
            continue
        num_list[a] = num_list[b] = 1

    len_list = []
    for l in fri_list:
        x = len(l)
        len_list.append(x)
    ans = max(len_list)
    print(ans)

if __name__ == "__main__":
    main()



Fixed submission:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    from collections import deque
    N, M = MI()
    fri_list = [[] for _ in range(N)]
    for i in range(M):
        a, b = MI()
        fri_list[a - 1].append(b - 1)
        fri_list[b - 1].append(a - 1)

    #print(fri_list)
    group_list = []
    num_list = [0] * N
    for i in range(0, N):
        if num_list[i] == 0:
            num_list[i] = 1
            #print(i, 'i')
            cnt = 1
            queue = deque([i])
            while queue:
                v = queue.popleft()
                #print(v, 'v')
                for j in fri_list[v]:
                    #print(j, 'j')
                    if num_list[j] == 0:
                        num_list[j] = 1
                        queue.append(j)
                        cnt += 1
            group_list.append(cnt)

    ans = max(group_list)
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    import bisect, collections, copy, heapq, itertools, math, string
    import sys
    def I():
        return int(sys.stdin.readline().rstrip())

    def MI():
        return map(int, sys.stdin.readline().rstrip().split())

    def LI():
        return list(map(int, sys.stdin.readline().rstrip().split()))

    def S():
        return sys.stdin.readline().rstrip()

    def LS():
        return list(sys.stdin.readline().rstrip().split())

    def main():
        from collections import deque
        N, M = MI()
        fri_list = []
        num_list = [0] * (N + 1)
        for i in range(M):
            a, b = MI()
            if num_list[a] == 0 and num_list[b] == 0:
                fri_list.append([a, b])
            elif num_list[a] == 0 or num_list[b] == 0:
                for l in fri_list:
                    if a in l:
                        l.append(b)
                    elif b in l:
                        l.append(a)
            else:
                continue
            num_list[a] = num_list[b] = 1

        len_list = []
        for l in fri_list:
            x = len(l)
            len_list.append(x)
        ans = max(len_list)
        print(ans)

    if __name__ == "__main__":
        main()




if __name__ == "__main__":
    main()

Fixed submission:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    from collections import deque
    N, M = MI()
    fri_list = [[] for _ in range(N)]
    for i in range(M):
        a, b = MI()
        fri_list[a - 1].append(b - 1)
        fri_list[b - 1].append(a - 1)

    #print(fri_list)
    group_list = []
    num_list = [0] * N
    for i in range(0, N):
        if num_list[i] == 0:
            num_list[i] = 1
            #print(i, 'i')
            cnt = 1
            queue = deque([i])
            while queue:
                v = queue.popleft()
                #print(v, 'v')
                for j in fri_list[v]:
                    #print(j, 'j')
                    if num_list[j] == 0:
                        num_list[j] = 1
                        queue.append(j)
                        cnt += 1
            group_list.append(cnt)

    ans = max(group_list)
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    from collections import deque
    N, M = MI()
    fri_list = [[-1] for _ in range(N)]
    for i in range(M):
        a, b = MI()
        fri_list[a - 1].append(b)
        fri_list[b - 1].append(a)

    def bfs(u, n, g, A, B):
        queue = deque([u])
        d = [None] * (n + 1)  # uからの距離の初期化
        d[u] = 0  # 自分との距離は0
        A.append(u)
        while queue:
            v = queue.popleft()
            for i in g[v - 1]:
                if i == -1:
                    continue
                if d[i] is None:
                    d[i] = 1
                    B[i] = 1
                    queue.append(i)
                    A.append(i)

    group_list = []
    num_list = [0] * (N + 1)
    for i in range(1, N + 1):
        if num_list[i] == 0:
            G = []
            bfs(i, N, fri_list, G, num_list)
            group_list.append(G)

    len_list = []
    for l in group_list:
        x = len(l)
        len_list.append(x)
    ans = max(len_list)
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    from collections import deque
    N, M = MI()
    fri_list = [[] for _ in range(N)]
    for i in range(M):
        a, b = MI()
        fri_list[a - 1].append(b - 1)
        fri_list[b - 1].append(a - 1)

    #print(fri_list)
    group_list = []
    num_list = [0] * N
    for i in range(0, N):
        if num_list[i] == 0:
            num_list[i] = 1
            #print(i, 'i')
            cnt = 1
            queue = deque([i])
            while queue:
                v = queue.popleft()
                #print(v, 'v')
                for j in fri_list[v]:
                    #print(j, 'j')
                    if num_list[j] == 0:
                        num_list[j] = 1
                        queue.append(j)
                        cnt += 1
            group_list.append(cnt)

    ans = max(group_list)
    print(ans)

if __name__ == "__main__":
    main()