Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
H_dict = []
cnt = 0
for h in range(N):
    tmp_h = H[h]
    cnt2 = 0
    for ab in AB:
        if h+1 in ab:
            left = [i for i in ab if i != h + 1]
            z = left[0]
            if H[z-1] >= tmp_h:
                cnt2 += 1
    if cnt2 == 0:
        cnt += 1
print(cnt)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
cnt = 0
new = [0 for i in range(N)]
for ab in AB:
    if H[ab[0]-1] <= H[ab[1]-1]:
        new[ab[0]-1] += 1
    if H[ab[0] - 1] >= H[ab[1] - 1]:
        new[ab[1]-1] += 1
print(new.count(0))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
H_dict = []
for h in range(N):
    H_dict.append([h+1, H[h]])
cnt = 0
for h in range(N):
    tmp_h = H_dict[h][1]
    edge_h = []
    cnt2 = 0
    for ab in AB:
        if h+1 in ab:
            left = [i for i in ab if i != h + 1]
            z = left[0]
            if H_dict[z-1][1] >= tmp_h:
                cnt2 += 1
    if cnt2 == 0:
        cnt += 1
print(cnt)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
cnt = 0
new = [0 for i in range(N)]
for ab in AB:
    if H[ab[0]-1] <= H[ab[1]-1]:
        new[ab[0]-1] += 1
    if H[ab[0] - 1] >= H[ab[1] - 1]:
        new[ab[1]-1] += 1
print(new.count(0))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
H_dict = []
for h in range(N):
    H_dict.append([h+1, H[h]])
cnt = 0
for h in range(N):
    tmp_h = H_dict[h][1]
    edge_h = []
    cnt2 = 0
    for ab in AB:
        if h+1 in ab:
            edge_h.append(ab)
    for edge in edge_h:
        left = [i for i in edge if i != h+1]
        z = left[0]
        if H_dict[z-1][1] >= tmp_h:
            cnt2 += 1
    if cnt2 == 0:
        cnt += 1
print(cnt)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
cnt = 0
new = [0 for i in range(N)]
for ab in AB:
    if H[ab[0]-1] <= H[ab[1]-1]:
        new[ab[0]-1] += 1
    if H[ab[0] - 1] >= H[ab[1] - 1]:
        new[ab[1]-1] += 1
print(new.count(0))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
H_dict = []
for h in range(N):
    H_dict.append([h+1, H[h]])
cnt = 0
for h in range(N):
    tmp_h = H_dict[h][1]
    more_h = [x for x in H_dict if x[1] >= tmp_h]
    cnt2 = 0
    if len(more_h) == 0:
        cnt += 1
    else:
        for y in more_h:
            left = [y[0], h+1]
            right = [h+1, y[0]]
            if left in AB or right in AB:
                cnt2 += 1
        if cnt2 == 0:
            cnt += 1
print(cnt)


Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
cnt = 0
new = [0 for i in range(N)]
for ab in AB:
    if H[ab[0]-1] <= H[ab[1]-1]:
        new[ab[0]-1] += 1
    if H[ab[0] - 1] >= H[ab[1] - 1]:
        new[ab[1]-1] += 1
print(new.count(0))