Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
dic = {}
sets = {0}
for _ in range(M):
  a,b = map(int,input().split())
  if a in sets or b in sets:
    if a in sets and b in sets:
      tmp_a = 0
      tmp_b = 1
      # つなげる処理
      for key in dic.keys():
        if a in dic[key]:
          tmp_a = key
        if b in dic[key]:
          tmp_b = key
      if tmp_a != tmp_b:
        dic[tmp_a].union(dic[tmp_b])
        del dic[tmp_b]
      else:
        dic[tmp_a].add(a)
        dic[tmp_a].add(b)
    else:
      # 入っている方に追加する処理
      for vls in dic.values():
        if a in vls or b in vls:
          vls.add(a)
          vls.add(b)
  else:
    dic[_] = {a,b}
  sets.add(a)
  sets.add(b)

mx = 0

for vals in dic.values():
  mx = max(mx,len(vals))
print(mx)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)
 
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
 
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
 
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
 
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
 
    
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
 
n, m = map(int, input().split())
uf = UnionFind(n)
 
for i in range(m):
    a, b = map(int, input().split())
    uf.Unite(a, b)
 
ans = 0
 
for i in range(n):
    ans = max(ans, uf.Count(i))
 
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
dic = {}
sets = {0}
for _ in range(M):
  a,b = map(int,input().split())
  if a in sets or b in sets:
    if a and b in sets:
      tmp_a = 0
      tmp_b = 1
      # つなげる処理
      for key in dic.keys():
        if a in dic[key]:
          tmp_a = key
        elif b in dic[key]:
          tmp_b = key
      if tmp_a != tmp_b:
        dic[tmp_a].union(dic[tmp_b])
        del dic[tmp_b]
      else:
        dic[tmp_a].add(a)
        dic[tmp_a].add(b)
    else:
      # 入っている方に追加する処理
      for vls in dic.values():
        if a in vls or b in vls:
          vls.add(a)
          vls.add(b)
  else:
    dic[_] = {a,b}
  sets.add(a)
  sets.add(b)

mx = 0

for vals in dic.values():
  mx = max(mx,len(vals))
print(mx)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)
 
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
 
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
 
    def Unite(self, x, y):
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if(x == y):
            return 
 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
 
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
 
    
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
 
n, m = map(int, input().split())
uf = UnionFind(n)
 
for i in range(m):
    a, b = map(int, input().split())
    uf.Unite(a, b)
 
ans = 0
 
for i in range(n):
    ans = max(ans, uf.Count(i))
 
print(ans)