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

for i in range(N):
    if tenbo[i]:
        for a, b in arr:
            #print(a-1, b-1, i)
            if a-1 == i:
                if H[b-1]>=H[i]:
                   tenbo[i] = False
                   break
                else:
                   tenbo[b-1] = False
            elif b-1 == i:
                if H[a-1]>=H[i]:
                    tenbo[i] = False
                    break
                else:
                    tenbo[a-1] = False
ans = 0
for t in tenbo:
  if t:
    ans+=1
print(ans)

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

for a, b in arr:
    highest_tenbo[a-1] = max(highest_tenbo[a-1], H[b-1])
    highest_tenbo[b-1] = max(highest_tenbo[b-1], H[a-1])

ans = 0
for i, t in enumerate(highest_tenbo):
  if t < H[i]:
    ans+=1
print(ans)

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

for i in range(N):
    if tenbo[i]:
        for a, b in arr:
            if a == i+1:
                if H[b-1]>=H[i]:
                   tenbo[i] = False
                else:
                   tenbo[b-1] = False
            elif b == i+1:
                if H[a-1]>=H[i]:
                    tenbo[i] = False
                else:
                    tenbo[a-1] = False

ans = 0
for t in tenbo:
  if t:
    ans+=1
print(ans)

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

for a, b in arr:
    highest_tenbo[a-1] = max(highest_tenbo[a-1], H[b-1])
    highest_tenbo[b-1] = max(highest_tenbo[b-1], H[a-1])

ans = 0
for i, t in enumerate(highest_tenbo):
  if t < H[i]:
    ans+=1
print(ans)

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

tenbo = [True for i in range(N)]
for i in range(N):
    maxi = True
    if tenbo[i]:
        for a, b in arr:
            if a == i+1:
                if H[b-1]>=H[i]:
                   tenbo[i] = False
                else:
                   tenbo[b-1] = False
            elif b == i+1:
                if H[a-1]>=H[i]:
                    tenbo[i] = False
                else:
                   tenbo[a-1] = False

ans = 0
for t in tenbo:
  if t:
    ans+=1
print(ans)


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

for a, b in arr:
    highest_tenbo[a-1] = max(highest_tenbo[a-1], H[b-1])
    highest_tenbo[b-1] = max(highest_tenbo[b-1], H[a-1])

ans = 0
for i, t in enumerate(highest_tenbo):
  if t < H[i]:
    ans+=1
print(ans)

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

ans = 0
for i in range(N):
    maxi = True
    for a, b in arr:
        if a == i+1:
            if H[b-1]>=H[i]:
               maxi = False
        elif b == i+1:
            if H[a-1]>=H[i]:
                maxi = False
    if maxi:
        ans += 1
print(ans)

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

for a, b in arr:
    highest_tenbo[a-1] = max(highest_tenbo[a-1], H[b-1])
    highest_tenbo[b-1] = max(highest_tenbo[b-1], H[a-1])

ans = 0
for i, t in enumerate(highest_tenbo):
  if t < H[i]:
    ans+=1
print(ans)