Buggy python submission (verdict: Time Limit Exceeded):
class UnionFindNode(object):
    def __init__(self, group_id, parent=None, value=None):
        self.group_id = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        return "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})".format(self.group_id, self.parent_,
                                                                                         self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def parent(self):
        parent = self
        while parent.parent_:
            parent = parent.parent_
        return parent

    def find(self):
        parent = self.parent()
        return parent.group_id

    def size(self):
        parent = self.parent()
        return parent.size_

    def unite(self, unite_node):
        parent = self.parent()
        unite_parent = unite_node.parent()
        if parent.group_id != unite_parent.group_id:
            unite_parent.parent_ = parent
            parent.size_ = parent.size_ + unite_parent.size_


[N, M] = list(map(int, input().split(' ')))
bridge_list = []

for _ in range(M):
    [a, b] = list(map(int, input().split(' ')))
    bridge_list.append((a - 1, b - 1))

node_list = [UnionFindNode(i) for i in range(N)]
combination_num = N * (N - 1) // 2
combination_list = [combination_num]

for bridge in bridge_list[:0:-1]:
    # print(bridge)
    if node_list[bridge[0]].find() != node_list[bridge[1]].find():
        combination_num = combination_num - node_list[bridge[0]].size() * node_list[bridge[1]].size()
        node_list[bridge[0]].unite(node_list[bridge[1]])
    combination_list.append(combination_num)
    # print(combination_num)

for value in combination_list[::-1]:
    print(value)

Fixed submission:
class UnionFindNode(object):
    def __init__(self, group_id, parent=None, value=None):
        self.group_id = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        return "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})".format(self.group_id, self.parent_,
                                                                                         self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def parent(self):
        parent = self
        while parent.parent_:
            parent = parent.parent_
        if not self.is_root():
            self.parent_ = parent
        return parent

    def find(self):
        parent = self.parent()
        return parent.group_id

    def size(self):
        parent = self.parent()
        return parent.size_

    def unite(self, unite_node):
        parent = self.parent()
        unite_parent = unite_node.parent()
        if parent.group_id != unite_parent.group_id:
            if parent.size() > unite_parent.size():
                unite_parent.parent_ = parent
                parent.size_ = parent.size_ + unite_parent.size_
            else:
                parent.parent_ = unite_parent
                unite_parent.size_ = parent.size_ + unite_parent.size_


[N, M] = list(map(int, input().split(' ')))
bridge_list = []

for _ in range(M):
    [a, b] = list(map(int, input().split(' ')))
    bridge_list.append((a - 1, b - 1))

node_list = [UnionFindNode(i) for i in range(N)]
combination_num = N * (N - 1) // 2
combination_list = [combination_num]

for bridge in bridge_list[:0:-1]:
    # print(bridge)
    if node_list[bridge[0]].find() != node_list[bridge[1]].find():
        combination_num = combination_num - node_list[bridge[0]].size() * node_list[bridge[1]].size()
        node_list[bridge[0]].unite(node_list[bridge[1]])
    combination_list.append(combination_num)
    # print(combination_num)

for value in combination_list[::-1]:
    print(value)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

[N, M] = list(map(int, input().split(' ')))
bridge_list = []

for _ in range(M):
    [a, b] = list(map(int, input().split(' ')))
    bridge_list.append((a - 1, b - 1))

# print(bridge_list)

convenience_list = []
inconvenience_list = list(itertools.combinations(list(range(N)), 2))
# print(inconvenience_list)

inconvenience_num_list = [len(inconvenience_list)]

for bridge in bridge_list[:0:-1]:
    if not inconvenience_list:
        break
    if bridge in inconvenience_list:
        convenience_list.append(bridge)
        inconvenience_list.remove(bridge)
    deleted = True
    while deleted:
        deleted = False
        if not inconvenience_list:
            break

        del_list = []
        for inconvenience in inconvenience_list:
            if inconvenience[0] in bridge:
                via_is = bridge[1 - bridge.index(inconvenience[0])]
                via_bridge = (inconvenience[1], via_is) if inconvenience[1] < via_is else (via_is, inconvenience[1])
                # print(inconvenience)
                # print(via_bridge)
                if via_bridge in convenience_list:
                    # print(convenience_list)
                    convenience_list.append(inconvenience)
                    del_list.append(inconvenience)
                    deleted = True
            elif inconvenience[1] in bridge:
                via_is = bridge[1 - bridge.index(inconvenience[1])]
                via_bridge = (inconvenience[0], via_is) if inconvenience[0] < via_is else (via_is, inconvenience[0])
                # print(inconvenience)
                # print(via_bridge)
                if via_bridge in convenience_list:
                    # print(convenience_list)
                    convenience_list.append(inconvenience)
                    del_list.append(inconvenience)
                    deleted = True
        # print(deleted)
        if not deleted:
            for del_value in del_list:
                inconvenience_list.remove(del_value)
            break
        
        for conv_bridge in convenience_list:
            if not inconvenience_list:
                break
            del_list = []
            for inconvenience in inconvenience_list:
                if inconvenience[0] in conv_bridge:
                    via_is = conv_bridge[1 - conv_bridge.index(inconvenience[0])]
                    via_bridge = (inconvenience[1], via_is) if inconvenience[1] < via_is else (via_is, inconvenience[1])
                    # print(inconvenience)
                    # print(via_bridge)
                    if via_bridge in convenience_list:
                        # print(convenience_list)
                        convenience_list.append(inconvenience)
                        del_list.append(inconvenience)
                        deleted = True
                elif inconvenience[1] in conv_bridge:
                    via_is = conv_bridge[1 - conv_bridge.index(inconvenience[1])]
                    via_bridge = (inconvenience[0], via_is) if inconvenience[0] < via_is else (via_is, inconvenience[0])
                    # print(inconvenience)
                    # print(via_bridge)
                    if via_bridge in convenience_list:
                        # print(convenience_list)
                        convenience_list.append(inconvenience)
                        del_list.append(inconvenience)
                        deleted = True
            # print(deleted)
            for del_value in del_list:
                inconvenience_list.remove(del_value)
    # print()
    inconvenience_num_list.append(len(inconvenience_list))

if len(inconvenience_num_list) < M:
    for _ in range(M - len(inconvenience_num_list)):
        inconvenience_num_list.append(0)
for value in inconvenience_num_list[::-1]:
    print(value)


Fixed submission:
class UnionFindNode(object):
    def __init__(self, group_id, parent=None, value=None):
        self.group_id = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        return "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})".format(self.group_id, self.parent_,
                                                                                         self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def parent(self):
        parent = self
        while parent.parent_:
            parent = parent.parent_
        if not self.is_root():
            self.parent_ = parent
        return parent

    def find(self):
        parent = self.parent()
        return parent.group_id

    def size(self):
        parent = self.parent()
        return parent.size_

    def unite(self, unite_node):
        parent = self.parent()
        unite_parent = unite_node.parent()
        if parent.group_id != unite_parent.group_id:
            if parent.size() > unite_parent.size():
                unite_parent.parent_ = parent
                parent.size_ = parent.size_ + unite_parent.size_
            else:
                parent.parent_ = unite_parent
                unite_parent.size_ = parent.size_ + unite_parent.size_


[N, M] = list(map(int, input().split(' ')))
bridge_list = []

for _ in range(M):
    [a, b] = list(map(int, input().split(' ')))
    bridge_list.append((a - 1, b - 1))

node_list = [UnionFindNode(i) for i in range(N)]
combination_num = N * (N - 1) // 2
combination_list = [combination_num]

for bridge in bridge_list[:0:-1]:
    # print(bridge)
    if node_list[bridge[0]].find() != node_list[bridge[1]].find():
        combination_num = combination_num - node_list[bridge[0]].size() * node_list[bridge[1]].size()
        node_list[bridge[0]].unite(node_list[bridge[1]])
    combination_list.append(combination_num)
    # print(combination_num)

for value in combination_list[::-1]:
    print(value)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

[N, M] = list(map(int, input().split(' ')))
bridge_list = []

for _ in range(M):
    [a, b] = list(map(int, input().split(' ')))
    bridge_list.append((a - 1, b - 1))

# print(bridge_list)

convenience_list = []
inconvenience_list = list(itertools.combinations(list(range(N)), 2))
# print(inconvenience_list)

inconvenience_num_list = [len(inconvenience_list)]

for bridge in bridge_list[:0:-1]:
    if len(inconvenience_list) == 0:
        break
    if bridge in inconvenience_list:
        convenience_list.append(bridge)
        inconvenience_list.remove(bridge)
    deleted = True
    while deleted:
        deleted = False
        for conv_bridge in convenience_list:
            if len(inconvenience_list) == 0:
                break
            del_list = []
            for inconvenience in inconvenience_list:
                if inconvenience[0] in conv_bridge:
                    via_is = conv_bridge[1 - conv_bridge.index(inconvenience[0])]
                    via_bridge = (inconvenience[1], via_is) if inconvenience[1] < via_is else (via_is, inconvenience[1])
                    # print(inconvenience)
                    # print(via_bridge)
                    if via_bridge in convenience_list:
                        # print(convenience_list)
                        convenience_list.append(inconvenience)
                        del_list.append(inconvenience)
                        deleted = True
                if inconvenience[1] in conv_bridge:
                    via_is = conv_bridge[1 - conv_bridge.index(inconvenience[1])]
                    via_bridge = (inconvenience[0], via_is) if inconvenience[0] < via_is else (via_is, inconvenience[0])
                    # print(inconvenience)
                    # print(via_bridge)
                    if via_bridge in convenience_list:
                        # print(convenience_list)
                        convenience_list.append(inconvenience)
                        del_list.append(inconvenience)
                        deleted = True
            # print(deleted)
            for del_value in del_list:
                inconvenience_list.remove(del_value)
    # print()
    inconvenience_num_list.append(len(inconvenience_list))

if len(inconvenience_num_list) < M:
    for _ in range(M - len(inconvenience_num_list)):
        inconvenience_num_list.append(0)
for value in inconvenience_num_list[::-1]:
    print(value)


Fixed submission:
class UnionFindNode(object):
    def __init__(self, group_id, parent=None, value=None):
        self.group_id = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        return "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})".format(self.group_id, self.parent_,
                                                                                         self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def parent(self):
        parent = self
        while parent.parent_:
            parent = parent.parent_
        if not self.is_root():
            self.parent_ = parent
        return parent

    def find(self):
        parent = self.parent()
        return parent.group_id

    def size(self):
        parent = self.parent()
        return parent.size_

    def unite(self, unite_node):
        parent = self.parent()
        unite_parent = unite_node.parent()
        if parent.group_id != unite_parent.group_id:
            if parent.size() > unite_parent.size():
                unite_parent.parent_ = parent
                parent.size_ = parent.size_ + unite_parent.size_
            else:
                parent.parent_ = unite_parent
                unite_parent.size_ = parent.size_ + unite_parent.size_


[N, M] = list(map(int, input().split(' ')))
bridge_list = []

for _ in range(M):
    [a, b] = list(map(int, input().split(' ')))
    bridge_list.append((a - 1, b - 1))

node_list = [UnionFindNode(i) for i in range(N)]
combination_num = N * (N - 1) // 2
combination_list = [combination_num]

for bridge in bridge_list[:0:-1]:
    # print(bridge)
    if node_list[bridge[0]].find() != node_list[bridge[1]].find():
        combination_num = combination_num - node_list[bridge[0]].size() * node_list[bridge[1]].size()
        node_list[bridge[0]].unite(node_list[bridge[1]])
    combination_list.append(combination_num)
    # print(combination_num)

for value in combination_list[::-1]:
    print(value)