Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
friend = [0 for i in range(N)]
k = []

for i in range(M):
    A, B = map(int, input().split())
    x = min(A, B)
    y = max(A, B)
    if [x, y] not in k:
        friend[A-1] += 1
        friend[B-1] += 1
        k.append([x, y])
    if max(friend) == N-1:
        break

print(max(friend)+1)


Fixed submission:
def find(n):
    if parent[n] < 0:
        return n
    else:
        parent[n] = find(parent[n])
        return parent[n]


def union(x, y):
    root_x = find(x)
    root_y = find(y)
    if root_x == root_y:
        return
    if parent[root_x] > parent[root_y]:
        root_x, root_y = root_y, root_x
    parent[root_x] += parent[root_y]
    parent[root_y] = root_x


def get_size(x):
    return -parent[find(x)]


n, m = map(int, input().split())
parent = [-1 for _ in range(n)]

for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    union(a, b)
ans = 0
for i in range(n):
    ans = max(ans, get_size(i))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
friend = [0 for i in range(N)]
k = []

for i in range(M):
    A, B = map(int, input().split())
    x = min(A, B)
    y = max(A, B)
    if [x, y] not in k:
        friend[A-1] += 1
        friend[B-1] += 1
        k.append([x, y])

print(max(friend)+1)

Fixed submission:
def find(n):
    if parent[n] < 0:
        return n
    else:
        parent[n] = find(parent[n])
        return parent[n]


def union(x, y):
    root_x = find(x)
    root_y = find(y)
    if root_x == root_y:
        return
    if parent[root_x] > parent[root_y]:
        root_x, root_y = root_y, root_x
    parent[root_x] += parent[root_y]
    parent[root_y] = root_x


def get_size(x):
    return -parent[find(x)]


n, m = map(int, input().split())
parent = [-1 for _ in range(n)]

for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    union(a, b)
ans = 0
for i in range(n):
    ans = max(ans, get_size(i))
print(ans)

Buggy python submission (verdict: Runtime Error):
from statistics import mode
N, M = map(int, input().split())
f, k = [], []

for i in range(M):
    A, B = map(int, input().split())
    if [A, B] not in k and [B, A] not in k:
        k.append([A, B])
        f.append(A)
        f.append(B)

print(f.count(mode(f))+1)


Fixed submission:
def find(n):
    if parent[n] < 0:
        return n
    else:
        parent[n] = find(parent[n])
        return parent[n]


def union(x, y):
    root_x = find(x)
    root_y = find(y)
    if root_x == root_y:
        return
    if parent[root_x] > parent[root_y]:
        root_x, root_y = root_y, root_x
    parent[root_x] += parent[root_y]
    parent[root_y] = root_x


def get_size(x):
    return -parent[find(x)]


n, m = map(int, input().split())
parent = [-1 for _ in range(n)]

for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    union(a, b)
ans = 0
for i in range(n):
    ans = max(ans, get_size(i))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
friend = [1 for i in range(N)]
k = []

for i in range(M):
    A, B = map(int, input().split())
    if [A, B] not in k:
        friend[A-1] += 1
        friend[B-1] += 1
        k.append([A, B])
        k.append([B, A])

print(max(friend))


Fixed submission:
def find(n):
    if parent[n] < 0:
        return n
    else:
        parent[n] = find(parent[n])
        return parent[n]


def union(x, y):
    root_x = find(x)
    root_y = find(y)
    if root_x == root_y:
        return
    if parent[root_x] > parent[root_y]:
        root_x, root_y = root_y, root_x
    parent[root_x] += parent[root_y]
    parent[root_y] = root_x


def get_size(x):
    return -parent[find(x)]


n, m = map(int, input().split())
parent = [-1 for _ in range(n)]

for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    union(a, b)
ans = 0
for i in range(n):
    ans = max(ans, get_size(i))
print(ans)