Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
dai = [list(map(int, input().split())) for i in range(M)]
plus = [i for i in range(N)]


for i in range(0, N):
    if plus[i] == -1:
        continue
    else:
        for a, b in dai:
            if i+1 == a:
                if H[a - 1] > H[b - 1]:
                    plus[b-1] = -1
                    continue
                else:
                    plus[i] = -1
                    break
            if i+1 == b:
                if H[b - 1] > H[a - 1]:
                    plus[a-1] = -1
                    continue
                else:
                    plus[i] = -1
                    break
print(len(set(plus))-1)


Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
dai = [list(map(int, input().split())) for i in range(M)]
plus = [i for i in range(N)]


for a, b in dai:
    if H[a - 1] > H[b - 1]:
        plus[b-1] = -1
        continue
    else:
        plus[a-1] = -1
    if H[b - 1] > H[a - 1]:
        plus[a-1] = -1
        continue
    else:
        plus[b-1] = -1
print(len(set(plus))-1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
dai = [list(map(int, input().split())) for i in range(M)]
plus = [i for i in range(N)]


for i in range(0, N):
    if plus[i] == -1:
        continue
    else:
        for a, b in dai:
            if i+1 == a:
                if H[a - 1] > H[b - 1]:
                    plus[b-1] = -1
                    continue
                else:
                    plus[i] = -1
                    break
            if i+1 == b:
                if H[b - 1] > H[a - 1]:
                    plus[a-1] = -1
                    continue
                else:
                    plus[i] = -1
                    break
print(len(set(plus))-1)


Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
dai = [list(map(int, input().split())) for i in range(M)]
plus = [i for i in range(N)]


for a, b in dai:
    if H[a - 1] > H[b - 1]:
        plus[b-1] = -1
        continue
    else:
        plus[a-1] = -1
    if H[b - 1] > H[a - 1]:
        plus[a-1] = -1
        continue
    else:
        plus[b-1] = -1
print(len(set(plus))-1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
dai = [list(map(int, input().split())) for i in range(M)]
plus = [i for i in range(N)]
cnt = 0

for i in range(0, N):
    for a, b in dai:
        if i+1 == a:
            if H[a - 1] > H[b - 1]:
                continue
            else:
                plus[i] = -1
                break
        if i+1 == b:
            if H[b - 1] > H[a - 1]:
                continue
            else:
                plus[i] = -1
                break
print(len(set(plus))-1)


Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
dai = [list(map(int, input().split())) for i in range(M)]
plus = [i for i in range(N)]


for a, b in dai:
    if H[a - 1] > H[b - 1]:
        plus[b-1] = -1
        continue
    else:
        plus[a-1] = -1
    if H[b - 1] > H[a - 1]:
        plus[a-1] = -1
        continue
    else:
        plus[b-1] = -1
print(len(set(plus))-1)