Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

print(6 - (a + b))

Fixed submission:
a = int(input())
b = int(input())

print(6 - (a + b))

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


print(6 - (a + b))

Fixed submission:
a = int(input())
b = int(input())

print(6 - (a + b))
Buggy python submission (verdict: Time Limit Exceeded):
ans = 0
for x in range(1, int(input())):
    ans += x

print(ans)


Fixed submission:
n = int(input())

print(n * (n - 1) // 2)
Buggy python submission (verdict: Runtime Error):
import math

# 最小公倍数
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a, b, c, d = map(int, input().split())
a=  a-1

c_a = a//c
c_b = b//c

d_a = a//d
d_b = b//d

lcm = lcm(min(c, d), max(c,d))

l_a = a//lcm
l_b = b//lcm




ans =  (b - a)  -  (c_b - c_a) - (d_b - d_a) + (l_b - l_a)

print(ans)



Fixed submission:
import fractions

# 最小公倍数
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())
a=  a-1

c_a = a//c
c_b = b//c

d_a = a//d
d_b = b//d

lcm = lcm(min(c, d), max(c,d))

l_a = a//lcm
l_b = b//lcm




ans =  (b - a)  -  (c_b - c_a) - (d_b - d_a) + (l_b - l_a)

print(ans)

Buggy python submission (verdict: Runtime Error):
import math

# 最小公倍数
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a, b, c, d = map(int, input().split())
a=  a-1

c_a = a//c
c_b = b//c

d_a = a//d
d_b = b//d

lcm = lcm(min(c, d), max(c,d))

l_a = a//lcm
l_b = b//lcm




ans =  (b - a)  -  (c_b - c_a) - (d_b - d_a) + (l_b - l_a)

print(ans)



Fixed submission:
import fractions

# 最小公倍数
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())
a=  a-1

c_a = a//c
c_b = b//c

d_a = a//d
d_b = b//d

lcm = lcm(min(c, d), max(c,d))

l_a = a//lcm
l_b = b//lcm




ans =  (b - a)  -  (c_b - c_a) - (d_b - d_a) + (l_b - l_a)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, *L = map(int, open(0).read().split())

# dp = [float("inf")] * n
dp = [0] * n

for i in range(1, n):
    j = max(0, i - k)
    dp[i] = min([DP + abs(L[i] - COST) for DP, COST in zip(dp[j:i], L[j:i])])

print(dp[-1])


Fixed submission:
n, k, *L = map(int, open(0).read().split())

# dp = [float("inf")] * n
dp = [0] * n

for i in range(1, n):
    j = max(0, i - k)
    e = L[i]
    dp[i] = min([DP + abs(e - COST) for DP, COST in zip(dp[j:i], L[j:i])])

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a*(b//gcd(a, b))

mod = int(1e9+7)

n = int(input())
vs = list(map(int, input().split()))
l = 1
for x in vs:
    l = lcm(l, x)

ans = 0
for x in vs:
    ans = (ans + ((l//x)%mod))%mod
print(ans)


Fixed submission:
def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a*(b//gcd(a, b))

mod = int(1e9+7)
def ext_gcd(a, b, x, y):
    if b==0:
        x[0] = 1
        y[0] = 0
        return a
    g = ext_gcd(b, a%b, y, x)
    y[0]-=a//b*x[0]
    return g

def mod_inv(a):
    x = [0]
    y = [0]
    ext_gcd(a, mod, x, y)
    return (x[0]%mod + mod)%mod;

n = int(input())
vs = list(map(int, input().split()))
l = 1
for x in vs:
    l = lcm(l, x)
l = l%mod;
ans = 0
for x in vs:
    ans = (ans + ((l*mod_inv(x))%mod))%mod
print(ans)

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a*(b/gcd(a, b))

mod = int(1e9+7)

n = int(input())
vs = map(int, input().split())
l = 1
for x in vs:
    l = lcm(l, x)

ans = 0
for x in vs:
    ans = (ans + ((l/x)%mod))%mod
print(ans)


Fixed submission:
def gcd(a, b):
    if b==0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a*(b//gcd(a, b))

mod = int(1e9+7)
def ext_gcd(a, b, x, y):
    if b==0:
        x[0] = 1
        y[0] = 0
        return a
    g = ext_gcd(b, a%b, y, x)
    y[0]-=a//b*x[0]
    return g

def mod_inv(a):
    x = [0]
    y = [0]
    ext_gcd(a, mod, x, y)
    return (x[0]%mod + mod)%mod;

n = int(input())
vs = list(map(int, input().split()))
l = 1
for x in vs:
    l = lcm(l, x)
l = l%mod;
ans = 0
for x in vs:
    ans = (ans + ((l*mod_inv(x))%mod))%mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

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

num = int(input())
sum_num = 0
for i in range(1,num+1):
  for j in range(1,num+1):
    for k in range(1,num+1):
      sum_num += gcd(i, j, k)

print(sum_num)

Fixed submission:
import math
from functools import reduce

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

num = int(input())
sum_num = 0
for i in range(1,num+1):
  for j in range(1,num+1):
    for k in range(1,num+1):
      sum_num += gcd(i, j, k)

print(sum_num)
Buggy python submission (verdict: Runtime Error):
from statistics import mean
n = input()
x_s = list(map(int,input().split()))
point_x = int(format(mean(x_s), '.0f'))
sum_e = sum([(x - point_x) ** 2 for x in x_s])
print(sum_e)


Fixed submission:
from statistics import mean
n = input()
x_s = list(map(int,input().split()))
point_x = int(format(mean(x_s), '.0f'))
sum_e = sum([(x - point_x) ** 2 for x in x_s])
print(sum_e)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
k = (a + b) / 2
l = (a + b) % 2
if l == 0:
    print(k)
else:
    print(“IMPOSSIBLE”)


Fixed submission:
# -*- coding: utf-8 -*-

a_b_list = list(map(int,input().split()))
a = a_b_list[0]
b = a_b_list[1]

k = (a + b) / 2
l = (a + b) % 2

if l == 0:
  print(int(k))
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
import math
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
  return
for x in i:
  result *= x
  if(len(str(result)) >= 19):
    print(-1)
    return
print(result)

Fixed submission:
import math
import sys
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
else:
  for x in i:
    result *= x
    if(result >= 10**18):
      break
  if(result > 10**18):
    print(-1)
  else:
    print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
total = 0
while N != 0:
  total += N % 10
  N //= 10
#print(total)
if total % 9 == 0 or total == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
N = int(input())
total = list(str(N))
ntotal = 0
for i in range(len(total)):
  ntotal += int(total[i])
#print(ntotal,ntotal % 9)
if ntotal % 9 == 0 or ntotal == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N >= 30:
  print(Yes)
else:
  print(No)

Fixed submission:
N = int(input())
if N >= 30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,K = map(int,input().split())
C = deque(map(int,input().split()))
D = C.copy()
#print(C)
ans = 1
for i in range(K):
  ans *= C.popleft()

for i in range(N-K):
  preans = ans
  ans *= C.popleft()
  ans /= D.popleft()
  if preans < ans:
    print("Yes")
  if preans >= ans:
    print("No")

Fixed submission:
from collections import deque
N,K = map(int,input().split())
C = deque(map(int,input().split()))
D = C.copy()
#print(C)
ans = 1
for i in range(K):
  C.popleft()
  #ans *= C.popleft()

for i in range(N-K):
  preans = D.popleft()
  ans = C.popleft()
  #preans = ans
  #ans *= C.popleft()
  #ans /= D.popleft()
  if preans < ans:
    print("Yes")
  if preans >= ans:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,K = map(int,input().split())
C = deque(map(int,input().split()))
#print(C)
ans = 1
for i in range(K):
  ans *= C[i]

for i in range(N-K):
  preans = ans
  ans *= C[K]
  ans /= C.popleft()
  if preans < ans:
    print("Yes")
  if preans >= ans:
    print("No")

Fixed submission:
from collections import deque
N,K = map(int,input().split())
C = deque(map(int,input().split()))
D = C.copy()
#print(C)
ans = 1
for i in range(K):
  C.popleft()
  #ans *= C.popleft()

for i in range(N-K):
  preans = D.popleft()
  ans = C.popleft()
  #preans = ans
  #ans *= C.popleft()
  #ans /= D.popleft()
  if preans < ans:
    print("Yes")
  if preans >= ans:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
C = list(map(int,input().split()))
#print(C)
ans = 1
for i in range(K):
  ans *= C[i]

for i in range(N-K):
  preans = ans
  ans *= C[K+i]
  ans /= C[i]
  if preans < ans:
    print("Yes")
  if preans >= ans:
    print("No")

Fixed submission:
from collections import deque
N,K = map(int,input().split())
C = deque(map(int,input().split()))
D = C.copy()
#print(C)
ans = 1
for i in range(K):
  C.popleft()
  #ans *= C.popleft()

for i in range(N-K):
  preans = D.popleft()
  ans = C.popleft()
  #preans = ans
  #ans *= C.popleft()
  #ans /= D.popleft()
  if preans < ans:
    print("Yes")
  if preans >= ans:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = float(input())
ans = float(0)
for i in range(int(N)):
  q = N // int(i+1)
  #print(type(i),type(q),type(ans))
  n = float(i)+1
  b = n*q*(q+1)/2
  ans += float(b)
print(int(ans))

Fixed submission:
N = int(input())
ans = 0
for i in range(int(N)):
  q = N // (i+1)
  #print(type(i),type(q),type(ans))
  ans += (i+1)*q*(q+1)/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
elif  2 <= N:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)


Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
    print(" ")
else:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)



Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
else:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Buggy python submission (verdict: Runtime Error):
X,N = list(map(int, input().split()))
if N == 0:
	print(X)
else:
	p = list(map(int,input().split()))
a = 0
b = 0
for i in range(N + 1):
  a = X + i
  b = X - i
  if p.count(b) == 0:
    print(b)
    exit(0)
  elif p.count(a) == 0:
    print(a)
    exit(0)


Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split(""))
print(A*B)

Fixed submission:
A,B = map(int,input().split())
print(A*B)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
re = 1
if int(0 in A) == 1:
  re = 0
  N = 0
for i in range(N):
  re *= A[i]
if re > 10**18:
  re = -1
print(re)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
re = 1
if int(0 in A) == 1:
  re = 0
  N = 0
for i in range(N):
  re *= A[i]
  if re > 10**18:
    re = -1
    break
print(re)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
re = reduce(mul,A)
#print(reduce(mul,A))
#for i in range(N):
#  re *= A[i]
if re > 10**18:
  re = -1
print(re)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
re = 1
if int(0 in A) == 1:
  re = 0
  N = 0
for i in range(N):
  re *= A[i]
  if re > 10**18:
    re = -1
    break
print(re)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
re = 1
for i in range(N):
  re *= A[i]
if re > 10**18:
  re = -1
print(re)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
re = 1
if int(0 in A) == 1:
  re = 0
  N = 0
for i in range(N):
  re *= A[i]
  if re > 10**18:
    re = -1
    break
print(re)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env pypy3

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))
    P = [i-1 for i in P]
    ans = -1e19

    for si in range(N):
        index = si
        cycle =[]
        total = 0
        while True:
            index = P[index]
            cycle.append(C[index])
            total = total + C[index]
            if index == si:
                break
        cycle_length = len(cycle)
        count = 0
        for i in range(cycle_length):
            count  = count + cycle[i]
            if i+1 > K:
                break
            num = count
            if total > 0:
                cnt = (K - (i+1)) // cycle_length
                num = num + cnt*total
            ans = max(ans, num)
    print(ans)


main()


Fixed submission:
#!/usr/bin/env pypy3

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))
    P = [i-1 for i in P]
    ans = -1e19

    for si in range(N):
        index = si
        cycle =[]
        total = 0
        while True:
            index = P[index]
            cycle.append(C[index])
            total = total + C[index]
            if index == si:
                break
        cycle_length = len(cycle)
        count = 0
        for i in range(cycle_length):
            count  = count + cycle[i]
            if i+1 > K:
                break
            num = count
            if total > 0:
                cnt = (K - (i+1)) // cycle_length
                num = num + cnt*total
            ans = max(ans, num)
    print(ans)


main()
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
A=int(a)
b.replace('.','')
B=int(b)
print(A*B)

Fixed submission:
a,b = input().split()
A=int(a)
B=int(b.replace('.',''))
print((A*B)//100)

Buggy python submission (verdict: Runtime Error):
a,b = input().rstrip().split()
A=int(a)
b.replace('.','')
B=int(b)
print(A*B)

Fixed submission:
a,b = input().split()
A=int(a)
B=int(b.replace('.',''))
print((A*B)//100)

Buggy python submission (verdict: Runtime Error):
a,b = input().rstrip().split()
A=int(a)
b.replace('.','')
B=int(b)
print(a*b)

Fixed submission:
a,b = input().split()
A=int(a)
B=int(b.replace('.',''))
print((A*B)//100)

Buggy python submission (verdict: Runtime Error):
a,b = input().rstrip().split()
A=int(a)
b.replace('.')
B=int(b)
print(a*b)

Fixed submission:
a,b = input().split()
A=int(a)
B=int(b.replace('.',''))
print((A*B)//100)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print(a*b)

Fixed submission:
a , b = (input().split(' '))
a = int(a)
b = int(b)
print(a*b)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

print(a*b)

Fixed submission:
a , b = (input().split(' '))
a = int(a)
b = int(b)
print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ls = list(map(int, input().split(' ')))
rst = 0
for i in range(1, N):
    while ls[i - 1] > ls[i]:
        rst += 1
        ls[i] += 1
print(rst)

Fixed submission:
N = int(input())
ls = list(map(int, input().split(' ')))
rst = 0
for i in range(1, N):
    if ls[i - 1] > ls[i]:
        rst += ls[i - 1] - ls[i]
        ls[i] += ls[i - 1] - ls[i]
print(rst)
Buggy python submission (verdict: Runtime Error):
input()
ls = list(map(int, input().split(' ')))

if ls.count(0) > 0:
    print(0)
else:
    result = 1
    for i in ls:
        result *= i
        if result > 10 ** 18:
            print(-1)
    print(result)

Fixed submission:
x, y = map(int, input().split(' '))
result = False
for i in range(x+1):
    if (4 * (x - i) + 2 * i) == y:
        result = True
        break
s = 'Yes' if result else 'No'
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
input()
ls = map(int, input().split(' '))
result = 1
for i in ls:
    result *= i
if result > 10 ** 18:
    print(-1)
else:
    print(result)

Fixed submission:
n = input()
nums = list(map(int, input().split(' ')))
nums.sort()
result = 1
for i in nums:
    result *= i
    if result > 10**18:
        result = -1
        break
    if result == 0:
        break
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
nums = map(int, input().split(' '))
result = 1
for i in nums:
    result *= i
if result > 10**18:
    print(-1)
else:
    print(result)

Fixed submission:
n = input()
nums = list(map(int, input().split(' ')))
nums.sort()
result = 1
for i in nums:
    result *= i
    if result > 10**18:
        result = -1
        break
    if result == 0:
        break
print(result)
Buggy python submission (verdict: Runtime Error):
a, b, h, m = map(int, input().split(' '))

rec_h = 30 * h + 0.5 * m
rec_m = 6 * m
rec = (rec_h-rec_m) % 180

x = b * math.sin(math.radians(rec))
y = a - b * math.cos(math.radians(rec))

r = math.sqrt(x**2 + y**2)
print(r)

Fixed submission:
import math
a, b, h, m = map(int, input().split(' '))

rec_h = 30 * h + 0.5 * m
rec_m = 6 * m
rec = abs(rec_h-rec_m)
if rec > 180:
    rec = 360 - rec

x = b * math.sin(math.radians(rec))
y = a - b * math.cos(math.radians(rec))

r = math.sqrt(x**2 + y**2)
print(r)
Buggy python submission (verdict: Runtime Error):
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [ [] for i in range(M)], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp[i] = ls[1:]
for i in range(1 << N):
    price_combi, exp_combi, exp_sum, cnt_ls = [], [], [0] * M, []
    for j in range(N):
        if i >> j & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in exp_combi:
        for t in range(M):
            exp_sum[t] += s[t]
    [ cnt_ls.append(x) for x in exp_sum if x >= X ]
    if len(cnt_ls) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)

Fixed submission:
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp.append(ls[1:])
for i in range(1 << N):
    price_combi, exp_combi, exp_rst, cnt = [], [], [0] * M, []
    for j in range(N):
        if (i >> j) & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in range(len(exp_combi)):
        for t in range(M):
            exp_rst[t] += exp_combi[s][t]
    [cnt.append(i) for i in exp_rst if i >= X]
    if len(cnt) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)

Buggy python submission (verdict: Runtime Error):
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [ [] for i in range(N) ], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp[i] = ls[1:]
for i in range(1 << M):
    price_combi, exp_combi, exp_sum, cnt_ls = [], [], [0] * M, []
    for j in range(M):
        if i >> j & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in exp_combi:
        for t in range(M):
            exp_sum[t] += s[t]
    [ cnt_ls.append(x) for x in exp_sum if x >= X ]
    if len(cnt_ls) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)

Fixed submission:
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp.append(ls[1:])
for i in range(1 << N):
    price_combi, exp_combi, exp_rst, cnt = [], [], [0] * M, []
    for j in range(N):
        if (i >> j) & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in range(len(exp_combi)):
        for t in range(M):
            exp_rst[t] += exp_combi[s][t]
    [cnt.append(i) for i in exp_rst if i >= X]
    if len(cnt) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge, rst = [ [] for i in range(N) ], 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    for j in edge[i]:
        is_peak = True
        if H_ls[i] <= H_ls[j]:
            is_peak = False
    if not is_peak:
        rst += 1
print(rst)

Fixed submission:

N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N)]
cnt = 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for neighbor in edge[i]:
        if H_ls[i] <= H_ls[neighbor]:
            is_peak = False
            break
    if is_peak:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
AB_ls, cnt = [], 0
for i in range(M):
    AB_ls.append(list(map(int, input().split(' '))))
for i in range(N):
    val = H_ls[i]
    is_peak = True
    for s in AB_ls:
        if not is_peak:
            break
        ls = []
        if (i + 1) in s:
            [ ls.append(x) for x in s if x != (i + 1)]
            if val <= H_ls[ls[0] - 1]:
                is_peak = False
                break
    if is_peak:
        cnt += 1
print(cnt)

Fixed submission:

N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N)]
cnt = 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for neighbor in edge[i]:
        if H_ls[i] <= H_ls[neighbor]:
            is_peak = False
            break
    if is_peak:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
AB_ls, cnt = [], 0
for i in range(M):
    AB_ls.append(list(map(int, input().split(' '))))
for i in range(N):
    val = H_ls[i]
    is_peak = True
    for s in AB_ls:
        ls = []
        if (i + 1) in s:
            [ ls.append(x) for x in s if x != (i + 1)]
            if val <= H_ls[ls[0] - 1]:
                is_peak = False
                break
    if is_peak:
        cnt += 1
print(cnt)

Fixed submission:

N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N)]
cnt = 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for neighbor in edge[i]:
        if H_ls[i] <= H_ls[neighbor]:
            is_peak = False
            break
    if is_peak:
        cnt += 1
print(cnt)