Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
nums = set(a_list)
r_list = [0]*(10**5+2)
for n in nums:
	count = a_list.count(n)
	r_list[n] += count
	r_list[n+1] += count
	if n > 0:
		r_list[n-1] += count
print(max(r_list))

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
	r_list[n] += 1
	r_list[n+1] += 1
	if n > 0:
		r_list[n-1] += 1
print(max(r_list))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
nums = set(a_list)
r_list = []
for n in nums:
	count = a_list.count(n) + a_list.count(n-1) + a_list.count(n+1)
	r_list.append(count)
print(max(r_list))

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
	r_list[n] += 1
	r_list[n+1] += 1
	if n > 0:
		r_list[n-1] += 1
print(max(r_list))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
nums = list(set(a_list))
nums.sort()
if len(nums) > 2:
	nums.pop(0)
	nums.pop(-1)
r_list = []
for n in nums:
	count = a_list.count(n) + a_list.count(n-1) + a_list.count(n+1)
	r_list.append(count)
print(max(r_list))

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
	r_list[n] += 1
	r_list[n+1] += 1
	if n > 0:
		r_list[n-1] += 1
print(max(r_list))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
nums = set(a_list)
r_list = []
for n in nums:
	count = a_list.count(n) + a_list.count(n-1) + a_list.count(n+1)
	r_list.append(count)
print(max(r_list))

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
	r_list[n] += 1
	r_list[n+1] += 1
	if n > 0:
		r_list[n-1] += 1
print(max(r_list))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
nums = list(set(a_list))
r_list = []
for n in nums:
	count = a_list.count(n) + a_list.count(n-1) + a_list.count(n+1)
	r_list.append(count)
print(max(r_list))

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
	r_list[n] += 1
	r_list[n+1] += 1
	if n > 0:
		r_list[n-1] += 1
print(max(r_list))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
nums = list(set(a_list))
r_list = []
for n in nums:
	count = a_list.count(n) + a_list.count(n-1) + a_list.count(n+1)
	r_list.append(count)
print(max(r_list))

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
	r_list[n] += 1
	r_list[n+1] += 1
	if n > 0:
		r_list[n-1] += 1
print(max(r_list))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
nums = list(set(a_list))
nums.sort(reverse=True)
a = 0
b = 0
for num in nums:
	count = a_list.count(num)
	if count > 1:
		if a == 0:
			a = num
			if count > 3:				
				b = num
				break
		else:
			b = num
			break
r = a * b
print(r)

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
counts = {}
for a in a_list:
	if a in counts:
		counts[a] += 1
	else:
		counts[a] = 1
counts = sorted(counts.items(), reverse=True, key=lambda x: x[0])
a = 0
b = 0
for key, value in counts:
	if value > 1:
		if a == 0:
			a = key
			if value > 3:
				b = key
				break
		else:
			b = key
			break
r = a*b
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab_list = [0] * m
for i in range(m):
	ab_list[i] = list(map(int, input().split()))
a_list = []
b_list = []
for i in ab_list:
	if i[0] == 1:
		a_list.append(i[1])
	elif i[1] == n:
		b_list.append(i[0])
r = 'IMPOSSIBLE'
for a in a_list:
	if a in b_list:
		r = 'POSSIBLE'
		break
print(r)

Fixed submission:
n, m = map(int, input().split())
ab_list = [0] * m
for i in range(m):
	ab_list[i] = list(map(int, input().split()))
a_list = []
b_list = []
for i in ab_list:
	if i[0] == 1:
		a_list.append(i[1])
	elif i[1] == n:
		b_list.append(i[0])
r = 'POSSIBLE' if set(a_list) & set(b_list) else 'IMPOSSIBLE'
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab_list = []
for i in range(m):
	ab_list.append(list(map(int, input().split())))
first_list = filter(lambda x: x[0] == 1, ab_list)
second_list = filter(lambda x: x[1] == n, ab_list)
f_list = list(map(lambda f:f[1], first_list))
s_list = list(map(lambda f:f[0], second_list))
r_list = filter(lambda x: x in s_list, f_list)
r = 'IMPOSSIBLE' if len(list(r_list)) == 0 else 'POSSIBLE'
print(r)

Fixed submission:
n, m = map(int, input().split())
ab_list = [0] * m
for i in range(m):
	ab_list[i] = list(map(int, input().split()))
a_list = []
b_list = []
for i in ab_list:
	if i[0] == 1:
		a_list.append(i[1])
	elif i[1] == n:
		b_list.append(i[0])
r = 'POSSIBLE' if set(a_list) & set(b_list) else 'IMPOSSIBLE'
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab_list = []
for i in range(m):
	ab_list.append(list(map(int, input().split())))
first_list = filter(lambda x: x[0] == 1, ab_list)
second_list = filter(lambda x: x[1] == n, ab_list)
f_list = list(map(lambda f:f[1], first_list))
s_list = list(map(lambda f:f[0], second_list))
r = 'IMPOSSIBLE'
for f in f_list:
	if f in s_list:
		r = 'POSSIBLE'
		break
print(r)

Fixed submission:
n, m = map(int, input().split())
ab_list = [0] * m
for i in range(m):
	ab_list[i] = list(map(int, input().split()))
a_list = []
b_list = []
for i in ab_list:
	if i[0] == 1:
		a_list.append(i[1])
	elif i[1] == n:
		b_list.append(i[0])
r = 'POSSIBLE' if set(a_list) & set(b_list) else 'IMPOSSIBLE'
print(r)
Buggy python submission (verdict: Runtime Error):
def test():
	mod = 10**9 + 7
	n, m = map(int, input().split())
	if abs(n-m) > 1:
		print(0)
		exit()
	i_n = n
	i_m = m
	np = 1
	mp = 1
	while True:
		np = (np%mod) * (i_n%mod)
		mp = (mp%mod) * (i_m%mod)
		i_n -= 1
		i_m -= 1
		if i_n < 1:
			i_n = 1
		if i_m < 1:
			i_m = 1
		if i_n == 1 and i_m == 1:
			break
	s = 2 if n == m else 1
	r = (mp*np*s) % (10**9 + 7)
	print(r)
test()

Fixed submission:
x, a, b = map(int, input().split())
e = b - a
r = 'safe'
if e > x:
	r = 'dangerous'
elif e < 1:
	r = 'delicious'
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
nums = [1]
count = 0
while True:
	num = a_list[num-1]
	count += 1
	if num in nums:
		break
	if num == 2:
		r = count
		break
	if count == n:
		break
	nums.append(num)
print(r)

Fixed submission:
n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
count = 0
while True:
	num = a_list[num-1]
	count += 1
	if num == 2:
		r = count
		break
	if count == n:
		break
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
nums = [1]
count = 0
while True:
	num = a_list[num-1]
	count += 1
	if num in nums:
		break
	if num == 2:
		r = count
		break
	if count > n:
		break
	nums.append(num)
print(r)

Fixed submission:
n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
count = 0
while True:
	num = a_list[num-1]
	count += 1
	if num == 2:
		r = count
		break
	if count == n:
		break
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
nums = [1]
count = 0
while True:
	num = a_list[num-1]
	count += 1
	if num in nums:
		break
	if num == 2:
		r = count
		break
	nums.append(num)
print(r)

Fixed submission:
n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
count = 0
while True:
	num = a_list[num-1]
	count += 1
	if num == 2:
		r = count
		break
	if count == n:
		break
print(r)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
count = 0
nums = []
while True:
	num = a_list[num-1]
	if num in nums:
		break
	nums.append(num))
	count += 1
	if num == 2:
		r = count
		break
print(r)

Fixed submission:
n = int(input())
a_list = []
for i in range(n):
	a_list.append(int(input()))
r = -1
num = 1
count = 0
while True:
	num = a_list[num-1]
	count += 1
	if num == 2:
		r = count
		break
	if count == n:
		break
print(r)
Buggy python submission (verdict: Runtime Error):
def test():
	mod = 10**9 + 7
	n, m = map(int, input().split())
	if abs(n-m) > 1:
		print(0)
		exit()
	t_l = max([n, m])
	p_l = 1
	for i in range(t_l):
		if i == t_l-1:
			break
		p = p * (t_l-i)
	p_s = p / t_l
	s = 2 if n == m else 1
	r = (p_l*p_s*s) % (10**9 + 7)
	print(r)
test()

Fixed submission:
import math

n, m = map(int, input().split())
if abs(n-m) > 1:
	print(0)
	exit()
s = 2 if n == m else 1
np = math.factorial(n)
mp = math.factorial(m)
r = (mp*np*s) % (10**9 + 7)
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
if abs(n-m) > 1:
	print(0)
	exit()
i_n = n
i_m = m
np = 1
mp = 1
while True:
	np = np * i_n
	mp = mp * i_m
	i_n -= 1
	i_m -= 1
	if i_n < 1:
		i_n = 1
	if i_m < 1:
		i_m = 1
	if i_n == 1 and i_m == 1:
		break
s = 2 if n == m else 1
r = (mp*np*s) % (10**9 + 7)
print(r)

Fixed submission:
import math

n, m = map(int, input().split())
if abs(n-m) > 1:
	print(0)
	exit()
s = 2 if n == m else 1
np = math.factorial(n)
mp = math.factorial(m)
r = (mp*np*s) % (10**9 + 7)
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
if abs(n-m) > 1:
	print(0)
	exit()
i = n
np = 1
while True:
	np = np * i
	i -= 1
	if i == 1:
		break
i = m
mp = 1
while True:
	mp = mp * i
	i -= 1
	if i == 1:
		break
s = 2 if n == m else 1
r = (mp*np*s) % (10**9 + 7)
print(r)

Fixed submission:
import math

n, m = map(int, input().split())
if abs(n-m) > 1:
	print(0)
	exit()
s = 2 if n == m else 1
np = math.factorial(n)
mp = math.factorial(m)
r = (mp*np*s) % (10**9 + 7)
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.extend([a] * b)
	if a_list.count(1) >= k:
		break
a_list.sort()
print(a_list[k-1])

Fixed submission:
n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.append([a, b])
a_list.sort(key=lambda x: x[0])
for i in range(n):
	k -= a_list[i][1]
	if k <= 0:
		print(a_list[i][0])
		break

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.extend([a] * b)
	if a_list.count(1) > k:
		break
a_list.sort()
print(a_list[k-1])

Fixed submission:
n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.append([a, b])
a_list.sort(key=lambda x: x[0])
for i in range(n):
	k -= a_list[i][1]
	if k <= 0:
		print(a_list[i][0])
		break

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.extend([a] * b)
a_list.sort()
print(a_list[k-1])

Fixed submission:
n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.append([a, b])
a_list.sort(key=lambda x: x[0])
for i in range(n):
	k -= a_list[i][1]
	if k <= 0:
		print(a_list[i][0])
		break

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.extend([a for i in range(b)])
a_list.sort()
print(a_list[k-1])


Fixed submission:
n, k = map(int, input().split())
a_list = []
for i in range(n):
	a, b = map(int, input().split())
	a_list.append([a, b])
a_list.sort(key=lambda x: x[0])
for i in range(n):
	k -= a_list[i][1]
	if k <= 0:
		print(a_list[i][0])
		break
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
r = 'YES' if b - a == c - b else 'N

Fixed submission:
a, b, c = map(int, input().split())
r = 'YES' if b - a == c - b else 'NO'
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
r = 1
for i in range(n):
	r = r * (i + 1)
r = r % (10**9 + 7)
print(r)

Fixed submission:
n = int(input())
r = 1
for i in range(n):
	r = (r * (i + 1)) % (10**9 + 7)
print(r)

Buggy python submission (verdict: Runtime Error):
n = int(input())
r = 1
for i in range(n):
	r = r * (i + 1)
r = r / (10**9 + 7)
print(r)

Fixed submission:
n = int(input())
r = 1
for i in range(n):
	r = (r * (i + 1)) % (10**9 + 7)
print(r)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
r = ''
if a == b:
	r = 'Draw'
elif a == 1:
	r = 'Alice'
elif b == 1:
	r = 'Bob'
else
	r = 'Alice' if a < b else 'Bob'
print(r)

Fixed submission:
a, b = map(int, input().split())
r = ''
if a == b:
	r = 'Draw'
elif a == 1:
	r = 'Alice'
elif b == 1:
	r = 'Bob'
else:
	r = 'Alice' if a > b else 'Bob'
print(r)
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
count = len(list(filter(lambda t: t % x == 0, list(range(a, b + 1)))))
print(count)

Fixed submission:
s = input().split()[1]
print('A'+s[0]+'C')
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
count = len(list(filter(lambda t: t % x == 0, list(range(a, b + 1)))))
print(count)

Fixed submission:
a, b, x = map(int, input().split())
br = b//x
ar = (a-1)//x
print(br-ar)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
num_list = [i for i in range(a, b + 1)]
count = len(list(filter(lambda t: t % x == 0, num_list)))
print(count)

Fixed submission:
a, b, x = map(int, input().split())
br = b//x
ar = (a-1)//x
print(br-ar)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
num_list = [i for i in range(a, b + 1)]
count = 0
for num in num_list:
	if num % x == 0:
		count = count + 1
print(count)

Fixed submission:
a, b, x = map(int, input().split())
br = b//x
ar = (a-1)//x
print(br-ar)
Buggy python submission (verdict: Runtime Error):
w, h, n = map(int, input().split())
nums_list=[list(map(int, input().split())) for i in range(n)]
minX = 0
maxX = w
minY = 0
maxY = h
for nums in nums_list:
	x, y, a = map(int, nums)
	if a == 1:
		minX = minX if (minX > x) else x
	elif a == 2:
		maxX = maxX if (maxX < x) else x
	elif a == 3:
		minY = minY if (minY > y) else y
	elif a == 4:
		maxY = maxY if (maxY < y) else y
width = maxX-minX
width = width if (width > 0) else 0
height = maxY-minY
height = height if (height > 0) else 0
v = width*height
print(v)

Fixed submission:
nums = sorted(list(map(int, input().split())))
result = 'Yes' if (nums[0] + nums[1] == nums[2]) else 'No'
print(result)

Buggy python submission (verdict: Runtime Error):
w, h, n = map(int, input().split())
nums_list=[list(map(int, input().split())) for i in range(n)]
minX = 0
maxX = w
minY = 0
maxY = h
for nums in nums_list:
	x, y, a = map(int, nums)
	if a == 1:
		minX = minX if (minX > x) else x
	elif a == 2:
		maxX = maxX if (maxX < x) else x
	elif a == 3:
		minY = minY if (minY > y) else y
	elif a == 4:
		maxY = maxY if (maxY < y) else y
width = maxX-minX if (maxX-minX > 0) else 0
height = maxY-minY if (maxY-minY > 0) else 0
v = width*height
print(v)

Fixed submission:
nums = sorted(list(map(int, input().split())))
result = 'Yes' if (nums[0] + nums[1] == nums[2]) else 'No'
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
k = int(input())
ans = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1, k+1):
    for j in range(1, k + 1):
        for m in range(1, k + 1):
            ans += gcd(i, j, m)

print(ans)




Fixed submission:
import math
k = int(input())
ans = 0
ans1 = 0

for i in range(1, k + 1):
    for j in range(1, k + 1):
        ans1 = math.gcd(i, j)
        for m in range(1, k + 1):
            ans += math.gcd(ans1, m)

print(ans)
Buggy python submission (verdict: Runtime Error):
s = str(input())

s[0] = s[-1]

Fixed submission:
s = str(input())
count = 0

for i in range(len(s)//2):
    if s[i] != s[len(s)-i-1]:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 0
b = n
total = []

def digitSum(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum

for i in range(2, n + 1):
    a = i
    b = n - a
    if b < a:
        break
    total.append(digitSum(a) + digitSum(b))
print(min(total))

Fixed submission:
n = int(input())
a = 0
b = n
total = []

def digitSum(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum

for i in range(1, n + 1):
    a = i
    b = n - a
    if b < a:
        break
    total.append(digitSum(a) + digitSum(b))
print(min(total))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 0
b = n
total = []

def digitSum(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum

for i in range(3, n + 1):
    a = i
    b = n - a
    if b < a:
        break
    total.append(digitSum(a) + digitSum(b))
print(min(total))

Fixed submission:
n = int(input())
a = 0
b = n
total = []

def digitSum(number):
    sum = 0
    while number > 0:
        sum += number % 10
        number //= 10
    return sum

for i in range(1, n + 1):
    a = i
    b = n - a
    if b < a:
        break
    total.append(digitSum(a) + digitSum(b))
print(min(total))
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input()).split())

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")


Fixed submission:
a, b = list(map(int, input().split()))

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input()).split())

if a * b % 2 == 0:
    print("Odd")
else:
    print("Even")


Fixed submission:
a, b = list(map(int, input().split()))

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
c = [0] * m
d = [0] * m
for j in range(m):
    c[j], d[j] = list(map(int, input().split()))

for i in range(n):
    distance = []
    minDistance = 10 ** 8 + 1
    checkPoint = 1
    for j in range(m):
        if j == 0:
            checkPoint = 1
        else:
            distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
            if minDistance > distance[j]:
                minDistance = distance[j]
                checkPoint = j + 1
    print(checkPoint)

Fixed submission:
n, m = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
c = [0] * m
d = [0] * m
for j in range(m):
    c[j], d[j] = list(map(int, input().split()))

for i in range(n):
    distance = []
    minDistance = 10 ** 16
    checkPoint = 1
    for j in range(m):
        distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
        if minDistance > distance[j]:
            minDistance = distance[j]
            checkPoint = j + 1
    print(checkPoint)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = list(map(int, input().split()))
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                count += 1
            elif x + y + z > s:
                break
        if x + y > s:
            break
    if x > s:
        break
print(count)

Fixed submission:
k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if z >= 0 and z <= k:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = list(map(int, input().split()))
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                count += 1

print(count)

Fixed submission:
k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if z >= 0 and z <= k:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = input()
if n.count(7)>0:
  print('Yes')
else:
  print('No')

Fixed submission:
a = input()
q = False
for s in a:
    if s == '7':
        print('Yes')
        q  = True
        break
if q == False:
    print('No')
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
import numpy as np
G = np.zeros((n, n))
for _ in range(m):
    a, b = map(int, input().split())
    G[a-1, b-1] = G[b-1, a-1] = 1

res = np.array([0] + [-1] *(n -1))

from collections import deque
q = deque([0])

while q:
    vis = q.popleft() # visit
    #     print(vis)
    cands = np.where(G[vis])[0] # next visit

    for c in cands:
        if res[c] == -1:
            res[c] = vis # mark
            q.append(c) # shoul append

if (res == -1).sum():
    print('No')
else:
    print('Yes')
    for i in res[1:]:
        print(i +1)

Fixed submission:
import numpy as np
import networkx as nx
g = nx.Graph()

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

for _ in range(m):
    a, b = map(int, input().split())
    g.add_edge(a, b)

res = np.array([0] * 2 + [-1] * (n-1))

from collections import deque
q = deque([1])

while q:
    vis = q.popleft() # visit
    #     print(vis)
    cands = list(nx.all_neighbors(g, vis)) # next visit

    if cands:
        for c in cands:
            if res[c] == -1:
                res[c] = vis # mark
                q.append(c) # should append

if (res == -1).sum():
    print('No')
else:
    print('Yes')
    for i in res[2:]:
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(n):
    for j in range(i + a[i], n):
        if a[i] + a[j] == j - i:
            count += 1

print(count)

Fixed submission:
import numpy as np
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))

idxs = np.arange(n)
L, R = idxs + a, idxs - a

count = 0
d = defaultdict(int)
for i in range(n-1):
    d[L[i]] += 1
    count += d[R[i+1]]

print(count)

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

count = 0
for i in range(n):
    for j in range(n):
        if a[i] + a[j] == j - i:
            count += 1

print(count)

Fixed submission:
import numpy as np
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))

idxs = np.arange(n)
L, R = idxs + a, idxs - a

count = 0
d = defaultdict(int)
for i in range(n-1):
    d[L[i]] += 1
    count += d[R[i+1]]

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

a = input()
n = len(a)

res = [-1] * (n+1) 
res[n] = 0
for i in range(n-1, -1, -1):
    res[i] = (res[i+1] + 10**(n-i-1) * int(a[i]) % 2019) % 2019

c = Counter(res)
print(int(sum([i*(i-1)/2 for i in c.values()])))

Fixed submission:
a = input()
n = len(a)

s = 0 # s[0]の余り
c = [0] * 2019 # c[i] = 余り i の個数
c[s] += 1
d = 1 # 10**i mod 2019

for i in range(n):
    s = (s + d * int(a[n-i-1])) % 2019 # s[i+1]の余り
    d = d * 10 % 2019 #10**(i+1) mod 2019
    c[s] += 1

print(int(sum([i*(i-1)/2 for i in c])))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
S = input()
n = len(S)

L = [(10**(n - i - 1) * int(s)) % 2019  for  i, s in enumerate(S)]

count = 0
for i in range(n):
    count += (np.cumsum(L[i:]) % 2019 == 0).sum()

print(count)

Fixed submission:
a = input()
n = len(a)

s = 0 # s[0]の余り
c = [0] * 2019 # c[i] = 余り i の個数
c[s] += 1
d = 1 # 10**i mod 2019

for i in range(n):
    s = (s + d * int(a[n-i-1])) % 2019 # s[i+1]の余り
    d = d * 10 % 2019 #10**(i+1) mod 2019
    c[s] += 1

print(int(sum([i*(i-1)/2 for i in c])))