Buggy python submission (verdict: Runtime Error):
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 = 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

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def nums(self,x):
        return abs(self.parents[self.find(x)])

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(M):
    A[i],B[i] = map(int, input().split())
ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if j!=i:
            uf.union(A[j]-1,B[j]-1)
    if len(uf.roots())>1:
        ans += 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
edges = [(0,0) for _ in range(M)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    edges[i] = (a-1,b-1)

import sys
sys.setrecursionlimit(10**8)

def dfs(v, es):
    #print(h,w)
    if len(es[v])==0:
        return 0
    for u in es[v]:
        if visited[u]==False:
            visited[u]=True
            dfs(u,es)
    return 0

import copy
ans = 0
for i in range(M):
    visited = [False]*N
    a,b = edges[i]
    es = copy.deepcopy(edge)
    # print(edge,a,b)
    es[a].remove(b)
    es[b].remove(a)
    for v in range(N):
        if visited[v]==False:
            visited[v]=True
            dfs(v,es)
            if False in visited:
                # print(a,b)
                break
    else:
        continue
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
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 = 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

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def nums(self,x):
        return abs(self.parents[self.find(x)])

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(M):
    A[i],B[i] = map(int, input().split())
ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if j!=i:
            uf.union(A[j]-1,B[j]-1)
    if len(uf.roots())>1:
        ans += 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
edges = [(0,0) for _ in range(M)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    edges[i] = (a-1,b-1)

import sys
sys.setrecursionlimit(10**8)

def dfs(v, es):
    #print(h,w)
    if len(es[v])==0:
        return 0
    for u in es[v]:
        if visited[u]==False:
            visited[u]=True
            dfs(u,es)
    return 0

import copy
ans = 0
for i in range(M):
    visited = [False]*N
    a,b = edges[i]
    es = copy.deepcopy(edge)
    # print(edge,a,b)
    es[a].remove(b)
    es[b].remove(a)
    for v in range(N):
        if visited[v]==False:
            visited[v]=True
            dfs(v,es)
            if False in visited:
                # print(a,b)
                break
    else:
        continue
    ans += 1
print(ans)