Buggy python submission (verdict: Time Limit Exceeded):
def main():
  import sys
  input = sys.stdin.readline

  n,m = map(int, input().split())
  heights = tuple(map(int, input().split()))

  roads = [tuple(map(int, input().split())) for _ in range(m)]

  sum = 0
  for i in range(n):
    tallest = True
    for road in roads:
      if i+1 in road:
        if road.index(i+1) == 0:
          to = road[1]
        else:
          to = road[0]
        if heights[i] <= heights[to-1]:
          tallest = False
          break
    if tallest:
      sum += 1

  print(sum)

if __name__ == '__main__':
  main()

Fixed submission:
import sys
input = sys.stdin.readline

def main():
  n,m = map(int, input().split())
  heights = tuple(map(int, input().split()))

  roads = [tuple(map(int, input().split())) for _ in range(m)]
  max_heights = [0 for _ in range(n)]

  for i in range(m):
    build_1 = roads[i][0]-1
    build_2 = roads[i][1]-1
    if heights[build_2] > max_heights[build_1]:
      max_heights[build_1] = heights[build_2]
    if heights[build_1] > max_heights[build_2]:
      max_heights[build_2] = heights[build_1]

  sum = 0
  for i in range(n):
    if heights[i] > max_heights[i]:
      sum += 1
  print(sum)

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
heights = list(map(int, input().split()))
roads = list()
for _ in range(m):
  road = list(map(int, input().split()))
  roads.append(road)

sum = 0
for i in range(n):
  tallest = True
  for road in roads:
    if i+1 in road:
      if road.index(i+1) == 0:
        to = road[1]
      else:
        to = road[0]
      if heights[i] <= heights[to-1]:
        tallest = False
        break
  if tallest:
    sum += 1

print(sum)


Fixed submission:
import sys
input = sys.stdin.readline

def main():
  n,m = map(int, input().split())
  heights = tuple(map(int, input().split()))

  roads = [tuple(map(int, input().split())) for _ in range(m)]
  max_heights = [0 for _ in range(n)]

  for i in range(m):
    build_1 = roads[i][0]-1
    build_2 = roads[i][1]-1
    if heights[build_2] > max_heights[build_1]:
      max_heights[build_1] = heights[build_2]
    if heights[build_1] > max_heights[build_2]:
      max_heights[build_2] = heights[build_1]

  sum = 0
  for i in range(n):
    if heights[i] > max_heights[i]:
      sum += 1
  print(sum)

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
heights = list(map(int, input().split()))
roads = list()
for _ in range(m):
  road = list(map(int, input().split()))
  roads.append(road)

sum = 0
for i in range(n):
  tallest = True
  for road in roads:
    if i+1 in road:
      if road.index(i+1) == 0:
        to = road[1]
      else:
        to = road[0]
      if heights[i] <= heights[to-1]:
        tallest = False
        break
  if tallest:
    sum += 1

print(sum)


Fixed submission:
import sys
input = sys.stdin.readline

def main():
  n,m = map(int, input().split())
  heights = tuple(map(int, input().split()))

  roads = [tuple(map(int, input().split())) for _ in range(m)]
  max_heights = [0 for _ in range(n)]

  for i in range(m):
    build_1 = roads[i][0]-1
    build_2 = roads[i][1]-1
    if heights[build_2] > max_heights[build_1]:
      max_heights[build_1] = heights[build_2]
    if heights[build_1] > max_heights[build_2]:
      max_heights[build_2] = heights[build_1]

  sum = 0
  for i in range(n):
    if heights[i] > max_heights[i]:
      sum += 1
  print(sum)

if __name__ == '__main__':
  main()