Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
H = list(map(int,input().split()))

list = list(range(1,n+1))
for _ in range(m):
  a,b=map(int,input().split())
  if H[a-1] > H[b-1] and b in list:
    list.remove(b)
  elif H[a-1] < H[b-1] and a in list:
    list.remove(a)
  elif H[a-1] == H[b-1]:
    if a in list and b in list:
      list.remove(a)
      list.remove(b)
    elif a in list:
      list.remove(a)
    elif b in list:
      list.remove(b)
print(len(list))

Fixed submission:
n,m = map(int,input().split())
h = list(map(int,input().split()))
cnt = [0]*n
chk = [0]*n
ans = 0

for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] > h[b-1]:
    cnt[a-1] += 1
  elif h[a-1] < h[b-1]:
    cnt[b-1] += 1
  chk[a-1] += 1
  chk[b-1] += 1
  
for i in range(n):
  if cnt[i] == chk[i]:
    ans += 1
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def road(n):
  for _ in range(n):
    A,B = map(int,input().split())
    yield A,B
  
def main():
  N,M = map(int,input().split())
  h = list(map(int,input().split()))
  num = list(range(1,N+1))
  X = list(road(M))
  for A,B in X:
    if A in num and B in num:
      if h[A-1] > h[B-1] and B in num:
        num.remove(B)
      elif h[A-1] < h[B-1] and A in num:
        num.remove(A)
      elif h[A-1] == h[B-1]:
        if A in num and B in num:
          num.remove(A)
          num.remove(B)
    elif A in num:
      if h[A-1] < h[B-1]:
        num.remove(A)
      elif h[A-1] == h[B-1]:
          num.remove(A)
    elif B in num:
      if h[A-1] > h[B-1]:
        num.remove(B)
      elif h[A-1] == h[B-1]:
          num.remove(B)
  return len(num)

print(main())

Fixed submission:
n,m = map(int,input().split())
h = list(map(int,input().split()))
cnt = [0]*n
chk = [0]*n
ans = 0

for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] > h[b-1]:
    cnt[a-1] += 1
  elif h[a-1] < h[b-1]:
    cnt[b-1] += 1
  chk[a-1] += 1
  chk[b-1] += 1
  
for i in range(n):
  if cnt[i] == chk[i]:
    ans += 1
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def road(n):
  for _ in range(n):
    A,B = map(int,input().split())
    yield A,B
  
def main():
  N,M = map(int,input().split())
  h = list(map(int,input().split()))
  num = list(range(1,N+1))
  X = list(road(M))
  for A,B in X:
    if B in num and h[A-1] > h[B-1] :
      num.remove(B)
    elif A in num and h[A-1] < h[B-1] :
      num.remove(A)
    elif h[A-1] == h[B-1]:
      if A in num and B in num:
        num.remove(A)
        num.remove(B)
      elif A in num and not B in num:
        num.remove(A)
      elif B in num and not A in num:
        num.remove(B)
  return len(num)

print(main())

Fixed submission:
n,m = map(int,input().split())
h = list(map(int,input().split()))
cnt = [0]*n
chk = [0]*n
ans = 0

for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] > h[b-1]:
    cnt[a-1] += 1
  elif h[a-1] < h[b-1]:
    cnt[b-1] += 1
  chk[a-1] += 1
  chk[b-1] += 1
  
for i in range(n):
  if cnt[i] == chk[i]:
    ans += 1
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def road(n):
  for _ in range(n):
    A,B = map(int,input().split())
    yield A,B
  
def main():
  N,M = map(int,input().split())
  h = list(map(int,input().split()))
  num = list(range(1,N+1))
  X = list(road(M))
  for A,B in X:
    if h[A-1] > h[B-1] and B in num:
      num.remove(B)
    elif h[A-1] < h[B-1] and A in num:
      num.remove(A)
    elif h[A-1] == h[B-1]:
      if A in num and B in num:
        num.remove(A)
        num.remove(B)
      elif A in num and not B in num:
        num.remove(A)
      elif B in num and not A in num:
        num.remove(B)
  return len(num)

print(main())

Fixed submission:
n,m = map(int,input().split())
h = list(map(int,input().split()))
cnt = [0]*n
chk = [0]*n
ans = 0

for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] > h[b-1]:
    cnt[a-1] += 1
  elif h[a-1] < h[b-1]:
    cnt[b-1] += 1
  chk[a-1] += 1
  chk[b-1] += 1
  
for i in range(n):
  if cnt[i] == chk[i]:
    ans += 1
    
print(ans)