Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = na()
g = [[] for i in range(n)]
for i in range(m):
    a, b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)

def dfs(v):
    seen[v] = True 
    for i in range(len(g[v])):
        nv = g[v][i]
        if seen[nv] == False:
            if h[v] <= h[nv]:
                return 0
    return 1
ans = 0  

for i in range(n):
    seen = [False] * n
    ans += dfs(i)
print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = na()
mh = [0 for i in range(n)]
for i in range(m):
    a, b = na()
    mh[a-1] = max(mh[a-1], h[b-1])
    mh[b-1] = max(mh[b-1], h[a-1])
ans = 0  
for i in range(n):
    if h[i] > mh[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = na()
g = [[] for i in range(n)]
for i in range(m):
    a, b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)

def dfs(v):
    seen[v] = True 
    for i in range(len(g[v])):
        nv = g[v][i]
        if seen[nv] == False:
            if h[v] > h[nv]:
                dfs(nv)
            else:
                return 0
    return 1
ans = 0  

for i in range(n):
    seen = [False] * n
    ans += dfs(i)
print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = na()
mh = [0 for i in range(n)]
for i in range(m):
    a, b = na()
    mh[a-1] = max(mh[a-1], h[b-1])
    mh[b-1] = max(mh[b-1], h[a-1])
ans = 0  
for i in range(n):
    if h[i] > mh[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = na()
g = [[] for i in range(n)]
for i in range(m):
    a, b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)

def dfs(v):
    seen[v] = True 
    for i in range(len(g[v])):
        nv = g[v][i]
        if seen[nv] == False:
            if h[v] > h[nv]:
                dfs(nv)
            else:
                return 0
    return 1
ans = 0  

for i in range(n):
    seen = [False] * n
    ans += dfs(i)
print(ans)

Fixed submission:
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = na()
mh = [0 for i in range(n)]
for i in range(m):
    a, b = na()
    mh[a-1] = max(mh[a-1], h[b-1])
    mh[b-1] = max(mh[b-1], h[a-1])
ans = 0  
for i in range(n):
    if h[i] > mh[i]:
        ans += 1
print(ans)