Buggy python submission (verdict: Time Limit Exceeded):

def check_connection(bridge_data, a_bridge, b_bridge):
    flg = 1
    fin_flg = 0
    a_bridge_data = set([a_bridge])
    b_bridge_data = set([b_bridge])
    pre_a = 1
    pre_b = 1
    while flg:
        flg = 0
        for i in range(len(bridge_data)):
            bridge_data_now = bridge_data[i]
            if bridge_data_now[0] in a_bridge_data:
                a_bridge_data.add(bridge_data_now[1])
                flg = 1
            if bridge_data_now[1] in a_bridge_data:
                a_bridge_data.add(bridge_data_now[0])
                flg = 1
            if bridge_data_now[0] in b_bridge_data:
                b_bridge_data.add(bridge_data_now[1])
                flg = 1
            if bridge_data_now[1] in b_bridge_data:
                b_bridge_data.add(bridge_data_now[0])
                flg = 1
            if len(a_bridge_data | b_bridge_data) < len(a_bridge_data) + len(b_bridge_data):
                fin_flg = 1
                break
        if pre_a == len(a_bridge_data) and pre_b == len(b_bridge_data):
            break
        else:
            pre_a = len(a_bridge_data)
            pre_b = len(b_bridge_data)

    return fin_flg, a_bridge_data, b_bridge_data

def delete(bridge_data, a_bridge, b_bridge, big_island_data):
    flg, a_bridge_data, b_bridge_data = check_connection(bridge_data, a_bridge, b_bridge)
    if flg:
        return big_island_data
    else:
        for i in range(len(big_island_data)):
            if a_bridge in big_island_data[i]:
                big_island_data[i] = a_bridge_data
                big_island_data.append(b_bridge_data)
                return big_island_data


def calc_ans(big_island_data):
    if len(big_island_data) == 1:
        print(0)
    else:
        ans = 0
        data = [len(ele) for ele in big_island_data]
        for i in range(len(data)):
            ans += data[i] * (sum(data) - data[i])
        print(int(ans / 2))

def calc_data(island_num, bridge_num, bridge_data):
    big_island_data = [set([i for i in range(1, island_num + 1)])]
    for i in range(bridge_num - 1):
        delete_bridge = bridge_data[i]
        big_island_data = delete(bridge_data[i+1:] , delete_bridge[0], delete_bridge[1], big_island_data)
        calc_ans(big_island_data)
    calc_ans(['1' for i in range(island_num)])

def main():
    island_num, bridge_num = list(map(int, input().split()))
    bridge_data = [list(map(int, input().split())) for i in range(bridge_num)]
    calc_data(island_num, bridge_num, bridge_data)


if __name__ == '__main__':
    main()

Fixed submission:

def get_parent(num, parent):
    if parent[num] == num:
        return num
    else:
        return get_parent(parent[num], parent)

def calc_change_data(ans, parent, a_parent, b_parent, island_count):
    big_parent = max(a_parent, b_parent)
    min_parent = min(a_parent, b_parent)
    parent[big_parent] = min_parent
    ans -= island_count[big_parent] * island_count[min_parent]
    island_count[min_parent] += island_count[big_parent]
    return ans, parent, island_count

def main():
    island_num, bridge_num = map(int, input().split())
    bridge_data = [list(map(int, input().split())) for i in range(bridge_num)]
    parent = [i for i in range(island_num)]
    island_count = [1 for i in range(island_num)]

    ans = island_num * (island_num - 1) // 2
    ans_data = [ans]

    for num_a, num_b in bridge_data[::-1]:
        num_a -= 1
        num_b -= 1

        a_parent = get_parent(num_a, parent)
        b_parent = get_parent(num_b, parent)

        if a_parent != b_parent:
            ans, parent, island_count = calc_change_data(ans, parent, a_parent, b_parent, island_count)
        ans_data.append(ans)

    for i in range(bridge_num)[::-1]:
        print(ans_data[i])

if __name__ == '__main__':
    main()