Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(m+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
#print(edges)
check = [0]*n
q = deque()
for i in range(n):
    q.append(i)
ans = 0
while q:
    node = q.popleft()
    if check[node] != 0:
        continue
    else:
        check[node] = 1
        count = 0
        for v in edges[node]:
            q.append(v)
            if h[node] >= h[v]:
                check[v] = 1
                count += 1
        if count == len(edges[node]):
            ans += 1


print(ans)

Fixed submission:
from collections import deque
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
check = [0]*n
q = deque()
for i in range(n):
    q.append(i)
ans = 0
while q:
    node = q.pop()
    if check[node] != 0:
        continue
    else:
        check[node] = 1
        count = 0
        for v in edges[node]:
            q.append(v)
            if h[node] > h[v]:
                check[v] = 1
                count += 1
            elif h[node] == h[v]:
                check[v] = 1
        if count == len(edges[node]):
            ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(m+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
#print(edges)
check = [0]*n
q = deque()
for i in range(n):
    q.append(i)
ans = 0
while q:
    node = q.popleft()
    if check[node] != 0:
        continue
    else:
        check[node] = 1
        count = 0
        for v in edges[node]:
            q.append(v)
            if h[node] > h[v]:
                check[v] = 1
                count += 1
        if count == len(edges[node]):
            ans += 1


print(ans)

Fixed submission:
from collections import deque
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
check = [0]*n
q = deque()
for i in range(n):
    q.append(i)
ans = 0
while q:
    node = q.pop()
    if check[node] != 0:
        continue
    else:
        check[node] = 1
        count = 0
        for v in edges[node]:
            q.append(v)
            if h[node] > h[v]:
                check[v] = 1
                count += 1
            elif h[node] == h[v]:
                check[v] = 1
        if count == len(edges[node]):
            ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(m+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
#print(edges)
check = [[0]*n for _ in range(n)]
count = 0
for i in range(n):
    for node in edges[i]:
        if h[i] > h[node]:
            continue
        else:
            break
    else:
        count += 1
print(count)

Fixed submission:
from collections import deque
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
check = [0]*n
q = deque()
for i in range(n):
    q.append(i)
ans = 0
while q:
    node = q.pop()
    if check[node] != 0:
        continue
    else:
        check[node] = 1
        count = 0
        for v in edges[node]:
            q.append(v)
            if h[node] > h[v]:
                check[v] = 1
                count += 1
            elif h[node] == h[v]:
                check[v] = 1
        if count == len(edges[node]):
            ans += 1
print(ans)