Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int,input().split()))
n = a[0]
m = a[1]

if m != 0:
  ab = [map(int, input().split()) for _ in range(m)]
  a, b = [list(i) for i in zip(*ab)]
  
  edge = [[0 for j in range(n)] for i in range(n)]
  for i in range(m):
    edge[a[i]-1][b[i]-1] = 1
    edge[b[i]-1][a[i]-1] = 1

  #print(set_list)

  ans = 1
  for i in range(n):
    aa = sum(edge[i])+1
    ans = max(aa,ans)

  print(ans)
else:
  print(1)

Fixed submission:
n, m = [int(x) for x in input().split()]

if m != 0:
  g = [set() for _ in range(n)]
  valid = [-1] * n
  set_list = []
  for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a-1].add(b-1)
    g[b-1].add(a-1)

  j = -1
  for i in range(n):
    if valid[i] == -1:
      set_list.append(set())
      j += 1
      stack = [i]
      while len(stack)!=0:
        v = stack.pop()
        set_list[j].add(v)
        valid[v] = 1
        for i in g[v]:
          if valid[i] == -1:
            stack.append(i)
            set_list[j].add(i)
            valid[i] = 1
  ans = 1
  for i in range(len(set_list)):
    ans = max(len(set_list[i]),ans)

  print(ans)

else:
  print(1)

Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int,input().split()))
n = a[0]
m = a[1]

if m != 0:
  ab = [map(int, input().split()) for _ in range(m)]
  a, b = [list(i) for i in zip(*ab)]
  set_list = [{a[0],b[0]}]
  for i in range(1,m):
    flag = 0
    for j in range(len(set_list)):
      if a[i] in set_list[j] or b[i] in set_list[j]:
        set_list[j].add(a[i])
        set_list[j].add(b[i])
        flag = 1
        break
    if flag == 0:
      set_list.append({a[i],b[i]})

  #print(set_list)

  ans = 1
  for i in range(len(set_list)):
    ans = max(ans, len(set_list[i]))

  print(ans)
else:
  print(1)

Fixed submission:
n, m = [int(x) for x in input().split()]

if m != 0:
  g = [set() for _ in range(n)]
  valid = [-1] * n
  set_list = []
  for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a-1].add(b-1)
    g[b-1].add(a-1)

  j = -1
  for i in range(n):
    if valid[i] == -1:
      set_list.append(set())
      j += 1
      stack = [i]
      while len(stack)!=0:
        v = stack.pop()
        set_list[j].add(v)
        valid[v] = 1
        for i in g[v]:
          if valid[i] == -1:
            stack.append(i)
            set_list[j].add(i)
            valid[i] = 1
  ans = 1
  for i in range(len(set_list)):
    ans = max(len(set_list[i]),ans)

  print(ans)

else:
  print(1)

Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
n = a[0]
m = a[1]
ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]

set_list = [{a[0],b[0]}]
for i in range(1,m):
  flag = 0
  for j in range(len(set_list)):
    if a[i] in set_list[j] or b[i] in set_list[j]:
      set_list[j].add(a[i])
      set_list[j].add(b[i])
      flag = 1
      break
  if flag == 0:
    set_list.append({a[i],b[i]})

#print(set_list)

ans = 0
for i in range(len(set_list)):
  ans = max(ans, len(set_list[i]))
  
print(ans)

Fixed submission:
n, m = [int(x) for x in input().split()]

if m != 0:
  g = [set() for _ in range(n)]
  valid = [-1] * n
  set_list = []
  for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a-1].add(b-1)
    g[b-1].add(a-1)

  j = -1
  for i in range(n):
    if valid[i] == -1:
      set_list.append(set())
      j += 1
      stack = [i]
      while len(stack)!=0:
        v = stack.pop()
        set_list[j].add(v)
        valid[v] = 1
        for i in g[v]:
          if valid[i] == -1:
            stack.append(i)
            set_list[j].add(i)
            valid[i] = 1
  ans = 1
  for i in range(len(set_list)):
    ans = max(len(set_list[i]),ans)

  print(ans)

else:
  print(1)