Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B =map(int,input().split())

def cf(A,B):
    cf=[]
    for i in range(2,min(A,B)+1):
        if A % i == 0 and B % i == 0:
            cf.append(i)
    return cf


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

print(sum([is_prime(one) for one in cf(A,B)])+1)

Fixed submission:
import math
A,B =map(int,input().split())



def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

tmp_A = set(make_divisors(A))
tmp_B = set(make_divisors(B))

tmp_set = tmp_A & tmp_B


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

print(sum([is_prime(one) for one in tmp_set])+1)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


s = int(input())
s = random.randint(1,10**18)

s_str = str(s)
order = len(s_str)

if len(s_str) >= 10:
    a = int(s_str[:9]) +1
    b = 10**(len(s_str) - 9)
    c = 10**(len(s_str[9:])) - int(s_str[9:])
    d = 1
else:
    a = int(s_str)
    b = 1
    c = 1
    d = 0

print('0 0 ' + str(a) + ' ' + str(d) + ' ' + str(c) + ' ' + str(b))



Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[76]:


s = int(input())
s_str = str(s)
order = len(s_str)

tmp_list = [s_str[i] for i in range(len(s_str))]
if set(tmp_list) == set(["0","1"]):
    if len(s_str) <= 10:
        a = s
        b = 1
        c = 1
        d = 0
    else:
        a = 10**9
        b = 10**(len(s_str)-10)
        c = 1
        d = 0
elif len(s_str) >= 10:
    a = int(s_str[:9]) +1
    b = 10**(len(s_str) - 9)
    c = 10**(len(s_str[9:])) - int(s_str[9:])
    d = 1
else:
    a = int(s_str)
    b = 1
    c = 1
    d = 0

print('0 0 ' + str(a) + ' ' + str(d) + ' ' + str(c) + ' ' + str(b))


# In[ ]:
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
P = np.array(list(map(int,input().split())))*2
A = np.array([np.zeros(N)]*N)

for i in range(N):
    if i == 0:
        A[0][0] = 1
        A[-1][0] = 1
    else:
        A[i-1][i] = 1
        A[i][i] = 1
        
ans = [int(round(one,0)) for one in np.dot(np.linalg.pinv(A),P)]

ans_s = ""
for one in ans:
    ans_s += "{} ".format(one)
ans_s = ans_s[:-1]

print(ans_s)

Fixed submission:
import numpy as np
N = int(input())
p = np.array(list(map(int,input().split())))
a0 = 0
for i in range(0,N,2):
    a0 += p[i]
    
for i in range(1,N-1,2):
    a0 -= p[i]
    
ans2 = [a0]*N
# iは-1している(slice)ので、+1しないといけないことに注意
for i,one in enumerate(p[1:]):
    ans2[i+1] = 2*p[i] - ans2[i] 
    
ans_s = ""
for one in ans2:
    ans_s += "{} ".format(one)
ans_s = ans_s[:-1]

print(ans_s)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
P = np.array(list(map(int,input().split())))*2
A = np.array([np.zeros(N)]*N)

for i in range(N):
    if i == 0:
        A[0][0] = 1
        A[-1][0] = 1
    else:
        A[i-1][i] = 1
        A[i][i] = 1
        
ans = [int(one) for one in np.dot(np.linalg.inv(A),P)]

ans_s = ""
for one in ans:
    ans_s += "{} ".format(one)
ans_s = ans_s[:-1]

print(ans_s)

Fixed submission:
import numpy as np
N = int(input())
p = np.array(list(map(int,input().split())))
a0 = 0
for i in range(0,N,2):
    a0 += p[i]
    
for i in range(1,N-1,2):
    a0 -= p[i]
    
ans2 = [a0]*N
# iは-1している(slice)ので、+1しないといけないことに注意
for i,one in enumerate(p[1:]):
    ans2[i+1] = 2*p[i] - ans2[i] 
    
ans_s = ""
for one in ans2:
    ans_s += "{} ".format(one)
ans_s = ans_s[:-1]

print(ans_s)
Buggy python submission (verdict: Time Limit Exceeded):
# 必要なライブラリのインポート
import queue


def f(x,y):
    if x < 0 or y < 0 or x >= r or y >= c:
        return False
    if m[x][y] == "#":
        return False
    elif not (x,y) in done:
        if (x,y) == (gx,gy):
            return True
        else:
            done.add((x,y))
            q.put((x,y))
            return False
    else:
        return False          

# FIFOキューの作成
q = queue.Queue()

r,c = map(int,input().split())
sx,sy = 1,1
gx,gy = r,c

sx -= 1
sy -= 1
gx -= 1
gy -= 1


m = ["" for _ in range(r)] 
sharp_counter = 0
for i in range(r):
    m[i] = input()
    sharp_counter += m[i].count("#")
    
    
q.put((sx,sy))
done = set()
counter = 1
while True:
    q_list = []
    for _ in range(q.qsize()):
        tx,ty = q.get()
        q_list.append((tx,ty))
        
    for one in q_list:
        tx,ty = one
        flags = [f(tx,ty-1),f(tx,ty+1),f(tx-1,ty),f(tx+1,ty)]
        if sum(flags) == 1:
            print(r*c -sharp_counter -(counter-1)-2)
            break
            
    if sum(flags) == 1:
        break
    else:
        counter += 1
        

Fixed submission:
# 必要なライブラリのインポート
import queue


def f(x,y):
    if x < 0 or y < 0 or x >= r or y >= c:
        return False
    if m[x][y] == "#":
        return False
    elif not (x,y) in done:
        if (x,y) == (gx,gy):
            return True
        else:
            done.add((x,y))
            q.put((x,y))
            return False
    else:
        return False          

# FIFOキューの作成
q = queue.Queue()

r,c = map(int,input().split())
sx,sy = 1,1
gx,gy = r,c

sx -= 1
sy -= 1
gx -= 1
gy -= 1


m = ["" for _ in range(r)] 
sharp_counter = 0
for i in range(r):
    m[i] = input()
    sharp_counter += m[i].count("#")
    
    
q.put((sx,sy))
done = set()
counter = 1
while True:
    q_list = []
    for _ in range(q.qsize()):
        tx,ty = q.get()
        q_list.append((tx,ty))
        
    for one in q_list:
        tx,ty = one
        flags = [f(tx,ty-1),f(tx,ty+1),f(tx-1,ty),f(tx+1,ty)]
        if sum(flags) == 1:
            print(r*c -sharp_counter -(counter-1)-2)
            break
            
    if sum(flags) == 1:
        break
    if q_list == []:
        print(-1)
        break
    else:
        counter += 1
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))


a = sorted(a)
b = sorted(b)
c = sorted(c)
a_tmp = [one+0.2 for one in a]
b_tmp = [one+ i/10**6 for i,one in enumerate(b)]
ab = sorted(a_tmp+b_tmp)
ab_len = 2*N
ab_dict = dict()
for one in enumerate(ab):
    ab_dict[one[1]] = one[0]
b_ans = [ab_dict[one] - i for i,one in enumerate(b_tmp)]

b_tmp = [one+0.2 for one in b]
c_tmp = [one+ i/10**6 for i,one in enumerate(c)]
bc = sorted(b_tmp+c_tmp)
bc_len = 2*N
bc_dict = dict()
for one in enumerate(bc):
    bc_dict[one[1]] = one[0]
c_ans = [bc_dict[one] - i for i,one in enumerate(c_tmp)]

ans = 0
for i,one in enumerate(c_ans):
    if one == 0:
        continue
    ans += sum(b_ans[:one])
print(ans)


Fixed submission:
import bisect
import numpy as np
N = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
b_bisect = [bisect.bisect_left(a,one) for one in b]
b_cumsum = np.cumsum(b_bisect)
c_bisect = [bisect.bisect_left(b,one) for one in c]

ans = 0
for one in c_bisect:
    if one == 0:
        continue
    else:
        ans += b_cumsum[one-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))


a = sorted(a)
b = sorted(b)
c = sorted(c)
a_tmp = [one+0.2 for one in a]
b_tmp = [one+ i/10**6 for i,one in enumerate(b)]
ab = sorted(a_tmp+b_tmp)
ab_len = 2*N
ab_dict = dict()
for one in enumerate(ab):
    ab_dict[one[1]] = one[0]
b_ans = [ab_dict[one] - i for i,one in enumerate(b_tmp)]

b_tmp = [one+0.2 for one in b]
c_tmp = [one+ i/10**6 for i,one in enumerate(c)]
bc = sorted(b_tmp+c_tmp)
bc_len = 2*N
bc_dict = dict()
for one in enumerate(bc):
    bc_dict[one[1]] = one[0]
c_ans = [bc_dict[one] - i for i,one in enumerate(c_tmp)]

ans = 0
for i,one in enumerate(c_ans):
    if one == 0:
        continue
    ans += sum(b_ans[:one])
print(ans)

Fixed submission:
import bisect
import numpy as np
N = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
b_bisect = [bisect.bisect_left(a,one) for one in b]
b_cumsum = np.cumsum(b_bisect)
c_bisect = [bisect.bisect_left(b,one) for one in c]

ans = 0
for one in c_bisect:
    if one == 0:
        continue
    else:
        ans += b_cumsum[one-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
def f(horizontal_flag):
    if horizontal_flag[0]:
        if horizontal_flag[1]:
            return 3
        else:
            return 1
    else:
        return 2

if N == 1:
    print(3)    
else:
    if A[0] == A[1]:
        counter = 6
        initial_num = 2
        horizontal_flag = [0,1]
    else:
        counter = 3
        initial_num = 1
        horizontal_flag = [0,1]


    for i in range(initial_num,N):
        if i == N-1:
            if horizontal_flag[1] == 2:
                horizontal_flag[1] = 1
                counter *= f(horizontal_flag)
            else:
                horizontal_flag[1] = 0
                counter *= f(horizontal_flag)
        elif A[i] == A[i+1]:
            horizontal_flag[1] = 2
        else:
            if horizontal_flag[1] == 2:
                horizontal_flag[1] = 1
                counter *= f(horizontal_flag)
            else:
                horizontal_flag[1] = 0
                counter *= f(horizontal_flag)
            horizontal_flag[0] = horizontal_flag[1]
    print(counter % 1000000007)

Fixed submission:
N = int(input())
A = input()
B = input()

def f(horizontal_flag):
    if horizontal_flag[0]:
        if horizontal_flag[1]:
            return 3
        else:
            return 1
    else:
        return 2

if N == 1:
    print(3)    
else:
    if A[0] == A[1]:
        counter = 6
        initial_num = 2
        horizontal_flag = [1,0]
    else:
        counter = 3
        initial_num = 1
        horizontal_flag = [0,0]

    for i in range(initial_num,N):
        if i == N-1:
            if horizontal_flag[1] == 2:
                horizontal_flag[1] = 1
                counter *= f(horizontal_flag)
            else:
                horizontal_flag[1] = 0
                counter *= f(horizontal_flag)
        elif A[i] == A[i+1]:
            horizontal_flag[1] = 2
        else:
            if horizontal_flag[1] == 2:
                horizontal_flag[1] = 1
                counter *= f(horizontal_flag)
            else:
                horizontal_flag[1] = 0
                counter *= f(horizontal_flag)
            horizontal_flag[0] = horizontal_flag[1]
    print(counter % 1000000007)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = input()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in range(N-1, 0, -1):
  for j in range(N-1, 0, -1):
    if s[i] != s[j]:
      dp[i][j] = 0
    else:
      dp[i][j] = dp[i+1][j+1] + 1
    
ans = 0
for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    now = min(dp[i][j], j - i)
    ans = max(ans, now)
print(ans)


Fixed submission:
N = int(input())
s = input()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in range(N-1, -1, -1):
  for j in range(N-1, -1, -1):
    if s[i] != s[j]:
      dp[i][j] = 0
    else:
      dp[i][j] = dp[i+1][j+1] + 1
    
ans = 0
for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    now = min(dp[i][j], j - i)
    ans = max(ans, now)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = input()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in range(N-1, 0, -1):
  for j in range(N-1, 0, -1):
    if s[i] != s[j]:
      dp[i][j] = 0
    else:
      dp[i][j] = dp[i+1][j+1] + 1
    
ans = 0
for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    now = min(dp[i][j], j - i)
    ans = max(ans, now)
print(ans)


Fixed submission:
N = int(input())
s = input()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in range(N-1, -1, -1):
  for j in range(N-1, -1, -1):
    if s[i] != s[j]:
      dp[i][j] = 0
    else:
      dp[i][j] = dp[i+1][j+1] + 1
    
ans = 0
for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    now = min(dp[i][j], j - i)
    ans = max(ans, now)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
maxn = N//2

for i in range(maxn, 0, -1):
  for j in range(N - i):
    s1 = S[j:j+i]
    for k in range(j + i, N):
      s2 = S[k:k+i]
      if s1 == s2:
        print(i)
        exit()
print(0)

Fixed submission:
N = int(input())
s = input()

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for i in range(N-1, -1, -1):
  for j in range(N-1, -1, -1):
    if s[i] != s[j]:
      dp[i][j] = 0
    else:
      dp[i][j] = dp[i+1][j+1] + 1
    
ans = 0
for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    now = min(dp[i][j], j - i)
    ans = max(ans, now)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
max_happy = N-1
init_happy = 0
for i in range(1, N-1):
  if S[i]=="L" and S[i-1]=="L":
    init_happy += 1
  elif S[i]=="R" and S[i+1]=="R":
    init_happy += 1

if S[0]=="R" and S[1]=="R":
  init_happy += 1

if S[-1]=="L" and S[-2]=="L":
  init_happy += 1

ans = min(max_happy, init_happy+K*2)

print(ans)

Fixed submission:
N, K = map(int, input().split())
S = input()
max_happy = N-1
init_happy = 0
for i in range(1, N-1):
  if S[i]=="L" and S[i-1]=="L":
    init_happy += 1
  elif S[i]=="R" and S[i+1]=="R":
    init_happy += 1

if N>1:
  if S[0]=="R" and S[1]=="R":
    init_happy += 1

  if S[-1]=="L" and S[-2]=="L":
    init_happy += 1

ans = min(max_happy, init_happy+K*2)

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

n = int(input())
s_list = [input().split() for i in range(n)]
s_list = sorted(["".join(sorted(s[0])) for s in s_list])

comb = itertools.combinations(s_list, 2)
cnt = 0
for c in comb:
  if c[0]==c[1]:
    cnt += 1

print(cnt)

Fixed submission:
n = int(input())
s_list = [input().split() for i in range(n)]
s_list = sorted(["".join(sorted(s[0])) for s in s_list])
s_list.sort()

cnt = 0
p = 1
tmp = 0
while p<n:
  if s_list[p-1]==s_list[p]:
    tmp += 1
  else:
    if tmp==1:
      cnt += tmp
    elif tmp>1:
      tmp += 1
      cnt += (tmp*(tmp-1))//2
    tmp = 0
  p += 1
if tmp==1:
  cnt += tmp
elif tmp>1:
  tmp += 1
  cnt += (tmp*(tmp-1))//2
print(cnt)

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

n = int(input())
s_list = [input().split() for i in range(n)]
s_list = sorted(["".join(sorted(s[0])) for s in s_list])

comb = itertools.combinations(s_list, 2)
cnt = 0
for c in comb:
  if c[0]==c[1]:
    cnt += 1

print(cnt)

Fixed submission:
n = int(input())
s_list = [input().split() for i in range(n)]
s_list = sorted(["".join(sorted(s[0])) for s in s_list])
s_list.sort()

cnt = 0
p = 1
tmp = 0
while p<n:
  if s_list[p-1]==s_list[p]:
    tmp += 1
  else:
    if tmp==1:
      cnt += tmp
    elif tmp>1:
      tmp += 1
      cnt += (tmp*(tmp-1))//2
    tmp = 0
  p += 1
if tmp==1:
  cnt += tmp
elif tmp>1:
  tmp += 1
  cnt += (tmp*(tmp-1))//2
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
n = N
cnt = 0
while n>0:
  n = n//10
  cnt += 1

tmp = "90"*(cnt//2)
tmp = int(tmp[:-1])

if cnt%2!=0:
  tmp += N-int("9"*(cnt-1))

print(tmp)


Fixed submission:
N = int(input())
n = N
cnt = 0
while n>0:
  n = n//10
  cnt += 1

if cnt==1:
  print(N)
else:
  tmp = "90"*(cnt//2)
  tmp = int(tmp[:-1])

  if cnt%2!=0:
    tmp += N-int("9"*(cnt-1))

  print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
# 解説YouTubeを参考（写経）
S = input()
N = 13
dp = [0 for _ in range(N)]
dp[0] = 1

mod = 1e9+7
mul = 1
for i in range(len(S)-1, -1, -1):
  nextDP = [0 for _ in range(N)]
  c = S[i]
  if c=="?":
    for k in range(10):
      for j in range(N):
        nextDP[(k*mul + j)%N] += dp[j]
        nextDP[(k*mul + j)%N] %= mod  
  else:
    k = int(c)
    for j in range(N):
      nextDP[(k*mul + j)%N] += dp[j]
      nextDP[(k*mul + j)%N] %= mod  
    
  mul *= 10
  mul %= N
  dp = nextDP
print(int(dp[5]))

Fixed submission:
# 解説YouTubeを参考（写経）
S = input()
N = 13
dp = [0 for _ in range(N)]
dp[0] = 1

mod = 1e9+7
mul = 1
for i in range(len(S)-1, -1, -1):
  nextDP = [0 for _ in range(N)]
  c = S[i]
  if c=="?":
    for k in range(10):
      for j in range(N):
        nextDP[(k*mul + j)%N] += dp[j]
        nextDP[(k*mul + j)%N] %= mod  
  else:
    k = int(c)
    for j in range(N):
      nextDP[(k*mul + j)%N] += dp[j]
      nextDP[(k*mul + j)%N] %= mod  
    
  mul *= 10
  mul %= N
  dp = nextDP
print(int(dp[5]))
Buggy python submission (verdict: Runtime Error):
# 解説YouTubeをもとに
S = int(input())
x1, y1, x2, x3 = 0, 0, 10**9, 1
if S==10**18:
  print(x1, y1, x2, y2, 0, x2)
else:
  y3 = S//x2 + 1
  y2 = x2*y3 - S
  print(x1, y1, x2, y2, x3, y3)

Fixed submission:
# 解説YouTubeをもとに
# https://atcoder.jp/contests/agc036/submissions/6943945 参考
S = int(input())
x1, y1, x2, y2 = 0, 0, 10**9, 1
if S==10**18:
  print(x1, y1, x2, y2, 0, x2)
else:
  y3 = S//x2 + 1
  x3 = x2*y3 - S
  print(x1, y1, x2, y2, x3, y3)
Buggy python submission (verdict: Runtime Error):
s = input()

x = -1

if len(s) == 1:
    x = 0
else:
    s2 = s.replace('x', '')

    if len(s2) % 2 == 0:
        flg = True
    else:
        flg = False

    nf = len(s2) // 2

    if flg:
        s2_pre = s2[:nf+1]
        s2_post = s2[nf+1:]
    else:
        s2_pre = s2[:nf]
        s2_post = s2[nf+1:]

    if s2_pre == s2_post[::-1]:
        cnt_s = 0
        cnt_s2 = 0
        while True: # 元の文字列の中心を求める
            if s[cnt_s] == 'x':
                cnt_s += 1
            if s[cnt_s] == s2[cnt_s2]:
                cnt_s += 1
                cnt_s2 += 1
            if cnt_s2 >= nf:
                break

        if len(s) % 2 == 0:
            s_pre = s[:cnt_s+1]
            s_post = s[cnt_s+1:]
        else:
            s_pre = s[:cnt_s]
            s_post = s[cnt_s+1:]

        s_postR = s_post[::-1]

        s_pre = list(s_pre)
        s_postR =  list(s_postR)

        cnt = 0
        cnt_pre = 0
        cnt_post = 0
        while True:
            try:
                if s_pre[cnt_pre] == s_postR[cnt_post]:
                    cnt_pre += 1
                    cnt_post += 1
            except IndexError:
                pass
            
            if len(s_pre) > cnt_pre:
                if s_pre[cnt_pre] == 'x':
                    s_postR.insert(cnt_post, 'x')
                    cnt_pre += 1
                    cnt_post += 1
                    cnt += 1
            elif len(s_postR) > cnt_post:
                if str(s_pre) == str(s_postR):
                    break
                else:
                    s_pre.insert(cnt_pre, s_postR[cnt_post])
                    cnt_pre += 1
                    cnt_post += 1
                    cnt += 1
                    
            if len(s_postR) > cnt_post:
                if s_postR[cnt_post] == 'x':
                    s_pre.insert(cnt_pre, 'x')
                    cnt_pre += 1
                    cnt_post += 1
                    cnt += 1
            elif len(s_pre) > cnt_pre:
                if str(s_pre) == str(s_postR):
                    break
                else:
                    s_postR.insert(cnt_post, s_pre[cnt_pre])
                    cnt_pre += 1
                    cnt_post += 1
                    cnt += 1

            if str(s_pre) == str(s_postR):
                break

        x = cnt
    
print(x)

Fixed submission:
s = input()

cnt = 0
ans = 0

if len(s) == 1:
    cnt = 0
else:
    l = 0
    k = 0
    while True:
        if s[l] == s[-k-1]:
            l += 1
            k += 1
            if l + k >= len(s)-1:
                break
        elif s[l] == 'x':
            l += 1
            cnt += 1
            if l + k >= len(s)-1:
                break
        elif s[-k-1] == 'x':
            k += 1
            cnt += 1
            if l + k >= len(s)-1:
                break
        else:
            ans = -1
            break

if ans == -1:
    print(ans)
else:
    print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import chain
import copy

n, m = map(int, input().split())

lis = [[10000000 for i in range(n)] for j in range(n)]
hen = []
for _ in range(m):
    hen.append(list(map(int, input().split())))

ans = 0
for x in range(m):
    lis_tmp = copy.deepcopy(lis)
    bri = copy.deepcopy(hen)
    bri.pop(x)
    for y in range(m-1):
        lis_tmp[bri[y][0]-1][bri[y][1]-1] = 1
        lis_tmp[bri[y][1]-1][bri[y][0]-1] = 1

    for k in range(n):
        for i in range(n):
            for j in range(n):
                lis_tmp[i][j] = min(lis_tmp[i][j], lis_tmp[i][k] + lis_tmp[k][j])

    if 10000000 in list(chain.from_iterable(lis_tmp)):
        ans += 1

print(ans)

Fixed submission:
n, m = map(int, input().split())
hen = []
for _ in range(m):
    hen.append(list(map(int, input().split())))

def dfs(vis, graph, x, n):
    vis[x] = True
    for i in range(n):
        if graph[x][i] == False:
            continue
        if vis[i] == True:
            continue
        dfs(vis, graph, i, n)
    return vis


ans = 0
for i in range(m):
    graph = [[False for _ in range(n)] for _ in range(n)]
    rng = [a for a in range(m)]
    del rng[i]
    for y in rng:
        graph[hen[y][0]-1][hen[y][1]-1] = True
        graph[hen[y][1]-1][hen[y][0]-1] = True
    vis = [False for _ in range(n)]
    vis = dfs(vis, graph, 0, n)
    connected = True
    for k in range(n):
        if vis[k] == False:
            connected = False
    if connected == False:
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import copy

n, m = map(int, input().split())

lis_raw = [[10000000 for i in range(n)] for j in range(n)]
lis = np.array(lis_raw)
hen = []
for _ in range(m):
    hen.append(list(map(int, input().split())))

ans = 0
for x in range(m):
    lis_tmp = copy.deepcopy(lis)
    bri = copy.deepcopy(hen)
    bri.pop(x)
    for y in range(m-1):
        lis_tmp[bri[y][0]-1][bri[y][1]-1] = 1
        lis_tmp[bri[y][1]-1][bri[y][0]-1] = 1

    for k in range(n):
        for i in range(n):
            for j in range(n):
                lis_tmp[i][j] = min(lis_tmp[i][j], lis_tmp[i][k] + lis_tmp[k][j])

    if 10000000 in lis_tmp:
        ans += 1

print(ans)

Fixed submission:
n, m = map(int, input().split())
hen = []
for _ in range(m):
    hen.append(list(map(int, input().split())))

def dfs(vis, graph, x, n):
    vis[x] = True
    for i in range(n):
        if graph[x][i] == False:
            continue
        if vis[i] == True:
            continue
        dfs(vis, graph, i, n)
    return vis


ans = 0
for i in range(m):
    graph = [[False for _ in range(n)] for _ in range(n)]
    rng = [a for a in range(m)]
    del rng[i]
    for y in rng:
        graph[hen[y][0]-1][hen[y][1]-1] = True
        graph[hen[y][1]-1][hen[y][0]-1] = True
    vis = [False for _ in range(n)]
    vis = dfs(vis, graph, 0, n)
    connected = True
    for k in range(n):
        if vis[k] == False:
            connected = False
    if connected == False:
        ans += 1

print(ans)