Problem p02573 (python)

Fixed submission:
from collections import deque
 
N,M = map(int,input().split())
hint_list = [list(map(int,input().split())) for i in range(M)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x -= 1
        y -= 1
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

uf = UnionFind(N)
for i in range(len(hint_list)):
    uf.union(hint_list[i][0],hint_list[i][1])
    
print(-min(uf.parents))

Buggy submission (verdict: Runtime Error):
from collections import deque
 
N,M = map(int,input().split())
hint_list = [list(map(int,input().split())) for i in range(M)]

r = [-1] * N

def find(a):
    if r[a] < 0:
        return a
    else:
        if r[r[a]] < 0:
            return r[a]
        else:
            r[a] =r[r[a]]
            return r[a]
    
def union(a,b):
    a -= 1
    b -= 1
    ar = find(a)
    br = find(b)
    if ar == br:
        return
    else:
        if r[ar] > r[br]:
            ar,br = br,ar
        r[ar] += r[br]
        r[br] = ar
        return
        
for i in range(len(hint_list)):
    union(hint_list[i][0],hint_list[i][1])
    
print(-min(r))

Buggy submission (verdict: Runtime Error):
from collections import deque
 
N,M = map(int,input().split())
hint_list = [list(map(int,input().split())) for i in range(M)]

r = [-1] * N

def find(a):
    if r[a] < 0:
        return a
    else:
        if r[r[a]] < 0:
            return r[a]
        else:
            r[a] =r[r[a]]
            return r[a]
    
def union(a,b):
    a -= 1
    b -= 1
    ar = find(a)
    br = find(b)
    if ar == br:
        return
    else:
        if r[ar] > r[br]:
            ar,br = br,ar
        r[ar] += r[br]
        r[br] = ar
        return
        
for i in range(len(hint_list)):
    union(hint_list[i][0],hint_list[i][1])
    print(r)
    
print(-min(r))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
hint_list = [list(map(int,input().split())) for i in range(M)]
friend_list = []

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

hint_list = get_unique_list(hint_list)

if M == 0:
    print(N)
else:
    friend_list.append(hint_list[0])
    for i in range(1,len(hint_list)):
        for j in range(len(friend_list)):
            if hint_list[i][0] in friend_list[j]:
                if hint_list[i][1] in friend_list[j]:
                    pass
                else:
                    frined_list[j].append(hint_list[i][1])
            elif hint_list[i][1] in friend_list[j]:
                if hint_list[i][0] in friend_list[j]:
                    pass
                else:
                    frined_list[j].append(hint_list[i][0])
            else:
                pass

    friend_length = []

    for i in range(len(friend_list)):
        friend_length.append(len(friend_list[i]))

print(max(friend_length))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
hint_list = [list(map(int,input().split())) for i in range(M)]
friend_list = []

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

hint_list = get_unique_list(hint_list)

if M == 0:
    print(N)
else:
    friend_list.append(hint_list[0])
    for i in range(1,len(hint_list)):
        for j in range(len(friend_list)):
            if hint_list[i][0] in friend_list[j]:
                if hint_list[i][1] in friend_list[j]:
                    pass
                else:
                    frined_list[j].append(hint_list[i][1])
            elif hint_list[i][1] in friend_list[j]:
                if hint_list[i][0] in friend_list[j]:
                    pass
                else:
                    frined_list[j].append(hint_list[i][0])
            else:
                pass

    friend_length = []

    for i in range(len(friend_list)):
        friend_length.append(len(friend_list[i]))

    print(max(friend_length))