Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().rstrip().split(" ")))
members = [1 for i in range(n)]
max_idx = 0
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  tmp_a = a
  tmp_b = b
  while members[tmp_a-1] < 0:
    tmp_a = -members[tmp_a-1]
  while members[tmp_b-1] < 0:
    tmp_b = -members[tmp_b-1]
  if a != tmp_a:
    members[a-1] = -tmp_a
  if b != tmp_b:
    members[b-1] = -tmp_b
  if tmp_a != tmp_b:
    members[tmp_a-1] += members[tmp_b-1]
    members[tmp_b-1] = -tmp_a
    if members[tmp_a-1] > members[max_idx]:
      max_idx = tmp_a-1
print(members[max_idx])


Fixed submission:
def root(x, root_ls):
  if root_ls[x] < 0:
    return x
  else:
    root_ls[x] = root(root_ls[x], root_ls)
    return root_ls[x]

def unite(a, b, root_ls):
  a = root(a, root_ls)
  b = root(b, root_ls)
  if a != b:
    root_ls[a] += root_ls[b]
    root_ls[b] = a
  
n, m = list(map(int, input().rstrip().split(" ")))
members = [-1 for i in range(n)]
max_idx = 0
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  unite(a-1, b-1, members)
print(max([-m for m in members]))

Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().rstrip().split(" ")))
members = [1 for i in range(n)]
max_idx = 0
for mm in range(m):
  print(members)
  a0, b0 = list(map(int, input().rstrip().split(" ")))
  a = a0
  b = b0
  while members[a-1] < 0:
    a = -members[a-1]
    members[a0-1] = -a
  while members[b-1] < 0:
    b = -members[b-1]
    members[b0-1] = -b
  if a != b:
    print(a, b, members[a-1], members[b-1])
    members[a-1] += members[b-1]
    members[b-1] = -a
    if members[a-1] > members[max_idx]:
      max_idx = a-1
print(members[max_idx])


Fixed submission:
def root(x, root_ls):
  if root_ls[x] < 0:
    return x
  else:
    root_ls[x] = root(root_ls[x], root_ls)
    return root_ls[x]

def unite(a, b, root_ls):
  a = root(a, root_ls)
  b = root(b, root_ls)
  if a != b:
    root_ls[a] += root_ls[b]
    root_ls[b] = a
  
n, m = list(map(int, input().rstrip().split(" ")))
members = [-1 for i in range(n)]
max_idx = 0
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  unite(a-1, b-1, members)
print(max([-m for m in members]))

Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().rstrip().split(" ")))
members = [1 for i in range(n)]
max_idx = 0
for mm in range(m):
  a0, b0 = list(map(int, input().rstrip().split(" ")))
  a = a0
  b = b0
  while members[a-1] < 0:
    a = -members[a-1]
  while members[b-1] < 0:
    b = -members[b-1]
  members[a0-1] = -a
  members[b0-1] = -b
  if a != b:
    members[a-1] += members[b-1]
    members[b-1] = -a
    if members[a-1] > members[max_idx]:
      max_idx = a-1
print(members[max_idx])


Fixed submission:
def root(x, root_ls):
  if root_ls[x] < 0:
    return x
  else:
    root_ls[x] = root(root_ls[x], root_ls)
    return root_ls[x]

def unite(a, b, root_ls):
  a = root(a, root_ls)
  b = root(b, root_ls)
  if a != b:
    root_ls[a] += root_ls[b]
    root_ls[b] = a
  
n, m = list(map(int, input().rstrip().split(" ")))
members = [-1 for i in range(n)]
max_idx = 0
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  unite(a-1, b-1, members)
print(max([-m for m in members]))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().rstrip().split(" ")))
members = [1 for i in range(n)]
max_idx = 0
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  while members[a-1] < 0:
    a = -members[a-1]
  while members[b-1] < 0:
    b = -members[b-1]
  if a != b:
    members[a-1] += members[b-1]
    members[b-1] = -a
    if members[a-1] > members[max_idx]:
      max_idx = a-1
print(members[max_idx])

Fixed submission:
def root(x, root_ls):
  if root_ls[x] < 0:
    return x
  else:
    root_ls[x] = root(root_ls[x], root_ls)
    return root_ls[x]

def unite(a, b, root_ls):
  a = root(a, root_ls)
  b = root(b, root_ls)
  if a != b:
    root_ls[a] += root_ls[b]
    root_ls[b] = a
  
n, m = list(map(int, input().rstrip().split(" ")))
members = [-1 for i in range(n)]
max_idx = 0
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  unite(a-1, b-1, members)
print(max([-m for m in members]))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().rstrip().split(" ")))
friend_mat = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
  friend_mat[i][i] = 1
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  if not friend_mat[a-1][b-1]:
    friend_mat[a-1][b-1] = 1
    friend_mat[b-1][a-1] = 1
print(max([sum(friend_mat[i]) for i in range(n)]))

Fixed submission:
def root(x, root_ls):
  if root_ls[x] < 0:
    return x
  else:
    root_ls[x] = root(root_ls[x], root_ls)
    return root_ls[x]

def unite(a, b, root_ls):
  a = root(a, root_ls)
  b = root(b, root_ls)
  if a != b:
    root_ls[a] += root_ls[b]
    root_ls[b] = a
  
n, m = list(map(int, input().rstrip().split(" ")))
members = [-1 for i in range(n)]
max_idx = 0
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  unite(a-1, b-1, members)
print(max([-m for m in members]))

Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().rstrip().split(" ")))
friendships = []
l = 0
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  i_a = -1
  i_b = -1
  j_a = -1
  j_b = -1
  for ll in range(l):
    if a in friendships[ll]:
      j_a = friendships[ll].index(a)
      i_a = ll
      break
  for ll in range(l):
    if b in friendships[ll]:
      j_b = friendships[ll].index(b)
      i_b = ll
      break
  if i_a != -1 and i_b != -1:
    if i_a != i_b:
      fb_ls = friendships[i_b]
      for fb in fb_ls:
        friendships[i_a].append(fb)
        del friendships[i_b]
        l -= 1
  elif i_a != -1:
    friendships[i_a].append(b)
  elif i_b != -1:
    friendships[i_b].append(a)
  else:
    l += 1
    friendships.append([a, b])
print(max([len(friendship) for friendship in friendships]))

Fixed submission:
def root(x, root_ls):
  if root_ls[x] < 0:
    return x
  else:
    root_ls[x] = root(root_ls[x], root_ls)
    return root_ls[x]

def unite(a, b, root_ls):
  a = root(a, root_ls)
  b = root(b, root_ls)
  if a != b:
    root_ls[a] += root_ls[b]
    root_ls[b] = a
  
n, m = list(map(int, input().rstrip().split(" ")))
members = [-1 for i in range(n)]
max_idx = 0
for mm in range(m):
  a, b = list(map(int, input().rstrip().split(" ")))
  unite(a-1, b-1, members)
print(max([-m for m in members]))