Problem:
 Score : 300 points    Problem Statement There are N observatories in AtCoder Hill, called Obs. 1 , Obs. 2 , ... , Obs. N . The elevation of Obs. i is H_i .
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j .  Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.
Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.  How many good observatories are there?      Constraints  2 \leq N \leq 10^5  1 \leq M \leq 10^5  1 \leq H_i \leq 10^9  1 \leq A_i,B_i \leq N  A_i \neq B_i  Multiple roads may connect the same pair of observatories.  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  M  H_1  H_2  ...  H_N  A_1  B_1  A_2  B_2  :  A_M  B_M       Output Print the number of good observatories.        Sample Input 1 4 3
1 2 3 4
1 3
2 3
2 4      Sample Output 1 2    From Obs. 1 , you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3 , so Obs. 1 is not good.    From Obs. 2 , you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3 , so Obs. 2 is not good.    From Obs. 3 , you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2 , so Obs. 3 is good.    From Obs. 4 , you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2 , so Obs. 4 is good.    Thus, the good observatories are Obs. 3 and 4 , so there are two good observatories.       Sample Input 2 6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6      Sample Output 2 3

Solution (Python):
N, M = map(int, input().split())
l = input().split()
n = list()
H = list()
for i in range(N):
  H.append(int(l[i]))
  n.append(int(l[i]))
for i in range(M):
  Ai, Bi = map(int,input().split())
  if H[Ai-1] > H[Bi-1]:
    n[Bi-1] = 0
  elif H[Ai-1] < H[Bi-1]:
    n[Ai-1] = 0
  else:
    n[Bi-1] = 0
    n[Ai-1] = 0
r = 0
for i in range(N):
  if n[i] != 0:
    r += 1
print(r)

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = 0
mt = [0] * n

for i in range(m):
    s,e = map(int,input().split())
    
    if h[s-1] > h[e-1]:
        if mt[s-1] == 0 or mt[s-1] == 'good':
            mt[s-1] = 'good'
        else:
            mt[s-1] = 'bad'
    else:
        mt[s-1] = 'bad'
    
    
    if h[e-1] > h[s-1]:
        if mt[e-1] == 0 or mt[e-1] == 'good':
            mt[e-1] = 'good'
        else:
            mt[e-1] = 'bad'
    else:
        mt[e-1] = 'bad'



for i in mt:
    if (i == 0) or (i == 'good'):
        ans = ans + 1
        
print(ans)

Solution (Python):


N, M = (int(_) for _ in input().split())

H = [int(_) for _ in input().split()]
H_sort = [(int(__), _) for _, __ in enumerate(H)]

H_sort.sort()
H_sort.reverse()




path = [[] for _ in range(N)]
for m in range(M):
    A, B = (int(_) - 1 for _ in input().split())
    path[A].append(B)
    path[B].append(A)

check = [True] * N
cnt = 0
for _, h in H_sort:
    good = False
    if check[h]:
        good = True
    check[h] = False
    for a in path[h]:
        if H[h] == H[a]:
            good = False
        check[a] = False
    if good:
        cnt += 1


print(cnt)

Solution (Python):
N, M = map(int, input().split())
Highs = list(map(int, input().split()))
Roads = [list(map(int, input().split())) for _ in range(M)]

winner = set()
looser = set()
appears = set()

def devide(w, l):
    if w not in looser:
        winner.add(w)
    if l not in looser:
        looser.add(l)
    if l in winner:
        winner.remove(l)

def remove(e):
    if e not in looser:
        looser.add(e)
    if e in winner:
        winner.remove(e)

for road in Roads:
    f = road[0]
    t = road[1]

    appears.add(f)
    appears.add(t)

    f_h = Highs[f-1]
    t_h = Highs[t-1]

    if f_h > t_h:
        devide(f, t)
    elif f_h < t_h:
        devide(t, f)
    else:
        remove(t)
        remove(f)

print(len(winner)+N-len(appears))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[True]*n

for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    ha=h[a]
    hb=h[b]
    if ha>hb:
        ans[b]=False
    elif hb>ha:
        ans[a]=False
    else:
        ans[a]=False
        ans[b]=False
cnt=0
for f in ans:
    if f:
        cnt+=1
print(cnt)

Solution (Python):


from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

good = [0 for i in range(0, N)]

for i in AB:
    if H[i[0]-1] > H[i[1]-1]:
        good[i[1]-1] += 1
    elif H[i[1]-1] > H[i[0]-1]:
        good[i[0]-1] += 1
    else:
        good[i[0]-1] += 1
        good[i[1]-1] += 1

ct = 0
for j in good:
    if j == 0:
        ct+=1

print(ct)

Solution (Python):
n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif height[r[0]-1] == height[r[1]-1]:
        lower_list.append(r[0])
        lower_list.append(r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

Solution (Python):
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    cand = set(range(N))
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        if H[A] <= H[B] and A in cand:
            cand.remove(A)
        if H[B] <= H[A] and B in cand:
            cand.remove(B)
    print(len(cand))


if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))

ans=list(range(n))

for j in range(m):
    a,b=map(int,input().split())
    if(h[a-1]<h[b-1]):
        ans[a-1]=-1
    elif(h[a-1]>h[b-1]):
        ans[b-1]=-1
    else:
        ans[a-1]=-1
        ans[b-1]=-1

print(sum([j>=0 for j in ans]))

Solution (Python):
temp = input().split(" ")
N = int(temp[0])
M = int(temp[1])
H = input().split(" ")
good = [1] * N
for i in range(M):
    root = input().split(" ")
    a = int(root[0])-1
    b = int(root[1])-1
    if int(H[a])>=int(H[b]):
        good[b] = 0
    if int(H[a])<=int(H[b]):
        good[a] = 0
print(sum(good))

Solution (Python):

N,M = map(int,input().split())
H = list(map(int,input().split()))

'''
path = []
for i in range(M):
    path.append(list(map(int,input().split())))
'''
path = [list(map(int,input().split())) for i in range(M)]  

'''
l = [] 
for i in range(N):
    l.append([0] * N + [H[i]])
'''


highest = [0] + [1] * N


for i in range(M):
    
    
    pa = path[i]
    p = pa[1]-1
    q = pa[0]-1
    x = H[p]
    y = H[q]
    if( x >= y ):
        
        highest[q+1] = 0
    if(  x <= y  ):
        
        highest[p+1] = 0
    

print(sum(highest))

'''
for i in range(M):
    print('path[i][0] = Ai = {}, path[i][1] = Bi = {}'.format(path[i][0], path[i][1]))
    l[ path[i][0]-1 ][ path[i][1]-1 ] = H[path[i][1]-1]
    l[ path[i][1]-1 ][ path[i][0]-1 ] = H[path[i][0]-1]
    print(l)
'''



'''
m_neigh = []
for i in range(N):
    print(l[i][:N])
    m_neigh.append(  max(l[i][:N] )  )
    print(m_neigh)
'''
'''
cnt = 0
for i in range(N):
    
'''

Solution (Python):


import sys


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    l = [1] * N
    for i in range(M):
        if H[A[i]] >= H[B[i]]:
            l[B[i]] = 0
        if H[A[i]] <= H[B[i]]:
            l[A[i]] = 0
    print(l.count(1))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    H = [int(next(tokens)) for _ in range(N)]  
    A = [int()] * (M)  
    B = [int()] * (M)  
    for i in range(M):
        A[i] = int(next(tokens)) - 1
        B[i] = int(next(tokens)) - 1
    solve(N, M, H, A, B)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
arr = [[] for i in range(N)]
ans = 0

for i in range(M):
    a, b = list(map(int, input().split()))
    arr[a-1].append(b-1)
    arr[b-1].append(a-1)

for i in range(N):
    if arr[i] == []:
        ans += 1
    else:
        if all(H[i] > H[arr[i][j]] for j in range(len(arr[i]))):
            ans += 1

print(ans)

Solution (Python):
if __name__ == "__main__":
  list_N_M = input().split(' ')
  N = int(list_N_M[0])
  M = int(list_N_M[1])
  
  list_str_H_all = input().split(' ')
  H = [0] * N
  for i in range(len(list_str_H_all)):
    H[i] = int(list_str_H_all[i])
  
  is_good_vp = [True] * N
  
  for _ in range(M):
    str_A_B = input().split(' ')
    A = int(str_A_B[0])
    B = int(str_A_B[1])
    
    if H[A-1] > H[B-1]:
      is_good_vp[B-1] = False
    elif H[B-1] > H[A-1]:
      is_good_vp[A-1] = False
    else:
      is_good_vp[A-1] = False
      is_good_vp[B-1] = False
    
  output = 0
  for i in range(N):
    if is_good_vp[i]:
      output += 1
      
  print(output)

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
count = 0
dic = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in dic:
        dic[a] = b
    else:
        if h[b-1]>h[dic[a]-1]:
            dic[a] = b
    if b not in dic:
        dic[b] = a
    else:
        if h[a-1]>h[dic[b]-1]:
            dic[b] = a
for key in dic:
    if h[key-1]>h[dic[key]-1] :
        count+=1
if len(dic)<n:
    print(count+n-len(dic))
else:
    print(count)

Solution (Python):
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
arr = [True for i in range(N)]
ans = 0
for i in range(M):
    A, B = list(map(int, input().split()))
    A -= 1
    B -= 1
    if H[A] <= H[B]:
        arr[A] = False
    if H[B] <= H[A]:
        arr[B] = False
for ele in arr:
    if ele == True:
        ans += 1

print(ans)

Solution (Python):

import sys
imput = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    dp = [1] * N
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A-1] > H[B-1]:
            dp[B-1] = 0
        elif H[A-1] < H[B-1]:
            dp[A-1] = 0
        elif H[A-1] == H[B-1]:
            dp[A-1] = 0
            dp[B-1] = 0


    print(sum(dp))

if __name__ == "__main__":
    main()

Solution (Python):

def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    dp = [1] * N
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A-1] > H[B-1]:
            dp[B-1] = 0
        elif H[A-1] < H[B-1]:
            dp[A-1] = 0
        elif H[A-1] == H[B-1]:
            dp[A-1] = 0
            dp[B-1] = 0


    print(sum(dp))

if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
ab_list = [list(map(int, input().split())) for _ in range(m)]
ok_list = [True]*n

for ab in ab_list:
    a = ab[0] - 1
    b = ab[1] - 1
    if h_list[a] <= h_list[b]:
        ok_list[a] = False
    if h_list[b] <= h_list[a]:
        ok_list[b] = False

print(ok_list.count(True))

Solution (Python):
N, M = map(int, input().split(" "))
height = list(map(int, input().split(" ")))
cand = [1] * N
for i in range(M):
    a, b = map(int, input().split(" "))
    a -= 1
    b -= 1
    if height[a] <= height[b]:
        cand[a] = 0
    if height[a] >= height[b]:
        cand[b] = 0
print(sum(cand))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
r_list = [set() for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    r_list[A-1].add(B)
    r_list[B-1].add(A)

count = 0
for i in range(N):
    flag = True
    for j in range(len(r_list[i])):
        next_index = r_list[i].pop()
        
        if H[i] <= H[next_index-1]:
            flag = False
    if flag:
        count += 1
print(count)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))

good = [True for _ in range(n)]

for _ in range(m):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	if (h[a] >= h[b]):
		good[b] = False
	if (h[b] >= h[a]):
		good[a] = False

print(len([i for i in good if i]))

Solution (Python):
tower, road = map(int, input().split(" "))

towers = list(map(int, input().split(" ")))
goods = {i+1 for i in range(tower)}

for _ in range(road):
    tower_a, tower_b = map(int, input().split(" "))
    if towers[tower_a-1] > towers[tower_b-1]:
        goods.discard(tower_b)
    elif towers[tower_a-1] < towers[tower_b-1]:
        goods.discard(tower_a)
    else:
        goods.discard(tower_b)
        goods.discard(tower_a)

print(len(goods))

Solution (Python):

N, M = map(int, input().split())
H = list(map(int, input().split()))
dp = [1] * N
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        dp[B-1] = 0
    elif H[A-1] < H[B-1]:
        dp[A-1] = 0
    elif H[A-1] == H[B-1]:
        dp[A-1] = 0
        dp[B-1] = 0


print(sum(dp))

Solution (Python):
N,M=map(int,input().split())
h=list(map(int,input().split()))
t=[0]*N
for i in range(M):
    A,B=map(int,input().split())
    t[A-1] = max(t[A-1], h[B-1])
    t[B-1] = max(t[B-1], h[A-1])

ct=0
for j in range(N):
    if h[j]>t[j]:
        ct+=1
print(ct)

Solution (Python):


N, M = map(int, input().split())
H = [int(h) for h in input().split()]

mapping = [[] for _ in range(N)]
for _ in range(M):
    i, j = map(int, input().split())
    mapping[i - 1].append(j - 1)
    mapping[j - 1].append(i - 1)

cnt = 0
for i in range(N):
    ls = mapping[i]
    for j in ls:
        if H[i] <= H[j]:
            break
    else:
        cnt += 1

print(cnt)

Solution (Python):
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
h = list(map(int, input().split()))
good = [True] * n
for j in range(m):
    ab = list(map(int, input().split()))
    a = ab[0]
    b = ab[1]
    if  h[a - 1] == h[b - 1]:
        good[a-1]=good[b-1]=False
    smaller_tower_index = a - 1 if h[a - 1] < h[b - 1] else b - 1
    if good[smaller_tower_index]:
        good[smaller_tower_index] = False
print(good.count(True))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1].append(b-1)
  x[b-1].append(a-1)
c=0
for i in range(n):
  f=1
  maxh=0
  for j in x[i]:
    maxh=max(maxh,h[j])
  if maxh>=h[i]:
    f=0
  c+=f
print(c)

Solution (Python):
n, m = list(map(int, input().split()))
heights = list(map(int, input().split()))
roads = [list(map(int, input().split())) for i in range(m)]

arrows = [True] * n

for road in roads:
    if heights[road[0] - 1] == heights[road[1] - 1]:
        res = [False, False]
    elif heights[road[0] - 1] < heights[road[1] - 1]:
        res = [False, True]
    else:
        res = [True, False]
    arrows[road[0] - 1] &= res[0]
    arrows[road[1] - 1] &= res[1]
    

print(len([i for i in arrows if i]))

Solution (Python):
n, m = map(int, input().split())
hs = list(map(int, input().split()))

edge = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

cnt = 0

for node in range(n):
    good = True
    for neighbor in edge[node]:
        if hs[node] <= hs[neighbor]:
            good = False
    if good:
        cnt += 1

print(cnt)

Solution (Python):
n,m = map(int, input().split())
h = list(map(int, input().split()))
r = []
for i in range(m):
    r.append(list(map(int,input().split())))

ln =[]
for i in range(n+1):
    ln.append([])

line= [1]*n
for i in r:
    a,b = i[0],i[1]
    ln[a].append(b)
    ln[b].append(a)

for i in  range(1,n+1):
    iH = h[i-1]
    for j in ln[i]:
        if h[j-1] >= iH:
            line[i-1]= 0
print(sum(line))

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*M;cnt=0
for i in range(M):
  a,b=map(int,input().split())
  A[i]=a,b
A.sort(key=lambda x: x[0])

S=[1]*(N+1)
for i in range(M):
  if H[A[i][0]-1]>H[A[i][1]-1]:
    S[A[i][0]]=min(1,S[A[i][0]])
  else:
    S[A[i][0]]=0
 

for i in range(M):
  if H[A[i][1]-1]>H[A[i][0]-1]:
    S[A[i][1]]=min(1,S[A[i][1]])
  else:
    S[A[i][1]]=0
 


for i in range(1,N+1):
  if S[i]==1:
    cnt=cnt+1
print(cnt)

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[list(map(int,input().split())) for i in range(M)]
hasi=[0]*N
for i in range(M):
    AB[i][0]-=1
    AB[i][1]-=1
    if H[AB[i][0]]>H[AB[i][1]]:
        hasi[AB[i][1]]+=1
    elif H[AB[i][0]]<H[AB[i][1]]:
        hasi[AB[i][0]]+=1
    else:
        hasi[AB[i][0]]+=1
        hasi[AB[i][1]]+=1
print(hasi.count(0))

Solution (Python):




def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    result = [1] * N

    for i in range(M):
        a, b = map(int, input().split())
        if H[a - 1] <= H[b - 1]:
            result[a - 1] *= 0
        if H[a - 1] >= H[b - 1]:
            result[b - 1] *= 0
    print(result.count(1))


if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())

H = list(map(int, input().split()))
H_paths = {n: set() for n in range(N)}

for m in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    H_paths[a].add(b)
    H_paths[b].add(a)

result = N

for n in range(N):
    
    for i in H_paths[n]:
        
        
        if H[n] <= H[i]:
            result -= 1
            break

print(result)

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [set() for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    AB[A-1].add(B-1)
    AB[B-1].add(A-1)
ans = 0
for i in range(N):
    res = True
    for x in AB[i]:
        if H[i]<=H[x]:
            res = False
            break
    if res:
        ans += 1
print(ans)

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    
    if h[a] > h[b]:
        ans[b] = 0
    elif h[b] > h[a]:
        ans[a] = 0
    else:
        ans[a],ans[b] = 0,0


print(ans.count(1))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[0]*n

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

print(ans.count(0))

Solution (Python):
n,m = map(int, input().split()) 
h_list = list(map(int, input().split())) 

connected_list = [ [] for _ in range(n) ]
for i in range(m):
    a,b = map(int, input().split()) 
    a-=1
    b-=1
    connected_list[a].append(b)
    connected_list[b].append(a)

res_cnt = 0
for tenbo_i in range(n):
    h = h_list[tenbo_i]
    connecteds = connected_list[tenbo_i]
    res = True
    for c_tenbo_i in connecteds:
        cmp_h = h_list[c_tenbo_i]
        if h <= cmp_h:
            res = False
            break
    if res:
        res_cnt+=1

print(res_cnt)

Solution (Python):
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    cnt = 0
    for i in range(n):
        hh = h[i]
        for j in g[i]:
            if h[j] >= hh:
                break
        else:
            cnt += 1
    print(cnt)


main()

Solution (Python):
def argmin(arg1, arg2):
    if H[arg1] > H[arg2]:
        return arg2
    elif H[arg1] < H[arg2]:
        return arg1
    else:
        return -1

N, M = list(map(int,input().split()))
H = list(map(int,input().split()))
A = []
B = []
for i in range(M):
    a, b = list(map(int,input().split()))
    A.append(a - 1)
    B.append(b - 1)
    
ans = [0 for _ in range(N)]

for i in range(M):
    ret = argmin(A[i], B[i])
    if ret != -1:
        ans[ret] = -1
    else:
        ans[A[i]] = -1
        ans[B[i]] = -1
        
print(ans.count(0))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
bads = set()
for i in range(0, M):
    Ai, Bi = map(int, input().split())
    if H[Ai-1] > H[Bi-1]:
        bads.add(Bi)
    elif H[Bi-1] > H[Ai-1]:
        bads.add(Ai)
    else:
        bads.add(Ai)
        bads.add(Bi)
print(N - len(bads))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
good=[True]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    if h[a]<h[b]:
        good[a]=False
    elif h[b]<h[a]:
        good[b]=False
    elif h[b]==h[a]:
        good[a]=False
        good[b]=False
print(good.count(True))

Solution (Python):
N,M = map(int,input().split())
Hs = [int(h) for h in input().split()]
Answer = [True for _ in range(N)]
for _ in range(M):
  A,B = map(int,input().split())
  Ha, Hb = Hs[A-1], Hs[B-1]
  if Ha <= Hb:
    Answer[A-1] = False
  if Ha >= Hb:
    Answer[B-1] = False

print(Answer.count(True))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [True] * (n + 1)
l[0] = False
for _ in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    l[b] = False
  elif h[a-1] == h[b-1]:
    l[a] = False
    l[b] = False
  elif h[a-1] < h[b-1]:
    l[a] = False
ans = 0
for i in range(1, n+1):
  if l[i]:
    ans += 1
print(ans)

Solution (Python):
n, m = [int(x) for x in input().split()]
h = [{'h': int(x), "r": []} for x in input().split()]

for i in range(m):
    a, b = [int(x) for x in input().split()]
    h[a - 1]['r'].append(b)
    h[b - 1]['r'].append(a)

good = 0
for t in h:
    highest = True
    for h2 in t['r']:
        if t['h'] <= h[h2 - 1]['h']:
            highest = False
            break
    if highest:
        good += 1
print(good)

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
ab =[]
for i in range(m):
    ab.append(list(map(int,input().split())))

ab = list(map(list,set(map(tuple,ab))))
i =0
an =[0]*n
while i < len(ab):
    if h[ab[i][0]-1]>h[ab[i][1]-1]:
        an[ab[i][1]-1]=1
        i += 1
    elif h[ab[i][0]-1]<h[ab[i][1]-1]:
        an[ab[i][0]-1]=1
        i += 1
    else:
        an[ab[i][1]-1]=1
        an[ab[i][0]-1]=1
        i += 1

print(an.count(0))

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB = [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]
road= [ [] for i in range(N)]
cnt=0
for i in range(0,M):
    road[A[i]-1].append(B[i])
    road[B[i] - 1].append(A[i])

for i in range(1,N+1):
    flag=True
    for j in road[i-1]:
        if H[i-1]<=H[j-1]:
            flag=False
            break
    if flag:
        cnt+=1

print(cnt)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np
    from scipy.sparse import csr_matrix

    N, M = map(int, input().split())
    H = np.array(list(map(int, input().split())))

    AB = [[] for i in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        AB[a].append(b)
        AB[b].append(a)
    count = 0
    for i, ab in enumerate(AB):
        ind = list(set(ab))
        if ind == []:
            count += 1
            continue
        if np.max(H[ind]) < H[i]:
            count += 1
    print(count)

    

    
    
    
    

    
    
    
    
    
    
    

    


if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
h = list(map(int,input().split()))
good = [True]*n
for _ in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    if h[a] <= h[b]: good[a] = False
    if h[b] <= h[a]: good[b] = False

print(sum(good))

Solution (Python):
N,M=map(int,input().split())
*H,=map(int,input().split())
J=[[0,0]]*M
i=0
while i<M:
    J[i]=list(map(int,input().split()))
    i+=1
ans=set(range(1,N+1))

for a,b in J:
    if H[a-1]>H[b-1]:
        ans-={b}
    elif H[a-1]<H[b-1]:
        ans-={a}
    else:
        ans-={a,b}

print(len(ans))

Solution (Python):
if __name__ == '__main__':
    [n,m] = [int(i) for i in input().split()]
    h = [int(i) for i in input().split()]
    d = dict()
    for i in range(n):
        d[i+1] = dict()
    for i in range(m):
        [a,b] = [int(i) for i in input().split()]
        if b in d[a].keys():
            d[a][b] = d[a][b] + 1
            d[b][a] = d[b][a] + 1
        else:
            d[a][b] = 1
            d[b][a] = 1
    count = 0
    for i in range(1,n+1,1):
        good = True
        for j in d[i].keys():
            if h[i-1] <= h[j-1]:
                good = False
                break
        
        if good:
            
            count+=1
    

    
    print(count)

Solution (Python):

import numpy as np
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
G = 0
lists = np.zeros(N)
for i in range(M):
    A, B = list(map(int, input().split()))
    if H[A-1] < H[B-1]:
        lists[A-1] = 1
    elif H[A-1] == H[B-1]:
        lists[A-1] = 1
        lists[B-1] = 1
    else:
        lists[B-1] = 1
for i in range(N):
    if lists[i] == 0:
        G += 1
print(G)

Solution (Python):
from operator import itemgetter
n,m = map(int,input().split())
h = list(map(int,input().split()))
cnt = 0
graph = [[]*n for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)


for i in range(n):
    good = True
    
    for j in range(len(graph[i])):
        ind = graph[i][j]
        
        if h[i] <= h[ind]:
            good = False
    if good:
        cnt += 1
print(cnt)

Solution (Python):
N, M = map(int, input().split())
h = list(map(int, input().split()))
li = []
for m in range(M):
  a, b = map(int, input().split())
  if h[a-1] < h[b-1]:
    li.append(a)
  elif h[a-1] == h[b-1]:
    li.append(a)
    li.append(b)
  else:
    li.append(b)

answer = N - len(set(li))
print(answer)

Solution (Python):
import sys
input = sys.stdin.readline

n,m = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]
g = dict((i, []) for i in range(1, n+1))
for i in xrange(m):
    a,b = (int(x) for x in input().split())
    try:
        g[a].append(b)
    except:
        g[a] = [b]
    try:
        g[b].append(a)
    except:
        g[b] = [a]
ans = 0
for key in g:
    H = seq[key-1]
    if len(g[key]) == 0:
        ans += 1
    else:
        for val in g[key]:
            if seq[val-1] >= H:
                break
        else:
            ans += 1
print(ans)

Solution (Python):
N, M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
A_B = {}
for i in range(1, N+1):
  A_B[i] = []

for _ in range(M):
  a, b = [int(i) for i in input().split()]
  if a in A_B:
    A_B[a].append(H[b-1])
  else:
    A_B[a] = [H[b-1]]

  if b in A_B:
    A_B[b].append(H[a-1])
  else:
    A_B[b] = [H[a-1]]

answer = 0
for i in range(1, N+1):
  Hs = A_B[i] + [H[i-1]]
  if  max(Hs) == H[i-1] and Hs.count(H[i-1]) == 1:
    answer += 1

print(answer)

Solution (Python):
import collections

n, m = map(int, raw_input().split(' '))
hs = map(int, raw_input().split(' '))
adj = collections.defaultdict(list)
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
	adj[a].append(b)
	adj[b].append(a)
count = 0
for u in range(1, n + 1):
	if all([hs[v - 1] < hs[u - 1] for v in adj[u]] or [True]):
		count+=1
print count

Solution (Python):

N, M = map(int,input().split())
H = list(map(int, input().split()))
count=[0]*M
A = [0]*M
B = [0]*M

for i in range(M):
    A[i], B[i] = map(int, input().split())

ans = [1]*N

for i in range(M):
    if H[A[i]-1] == H[B[i]-1]:
        ans[A[i]-1] = 0
        ans[B[i]-1] = 0
    elif H[A[i]-1] > H[B[i]-1]:
        ans[B[i]-1] = 0
    elif H[A[i]-1] < H[B[i]-1]:
        ans[A[i]-1] = 0
print(sum(ans))

Solution (Python):
N,M=map(int, input().split())
H=list(map(int, input().split()))

ans = [True]*N
ctr = 0

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]: ans[b] = False
    if H[a] <= H[b]: ans[a] = False

for i in range(N):
    if ans[i]:
        ctr += 1

print(ctr)

Solution (Python):
n, m = [int(i) for i in input().split()]

h = [int(i) for i in input().split()]

list = [[]for i in range(n)]
for i in range(m):
    a, b = [int(i) for i in input().split()]
    list[a-1].append(h[b-1])
    list[b-1].append(h[a-1])
ans = 0
for i in range(n):
    if len(list[i]) == 0:
        ans += 1
    elif h[i] > max(list[i]):
        ans += 1
print(ans)

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
ans = [1]*n
for i in range(m):
    if h[a[i]-1]==h[b[i]-1]:
        ans[a[i]-1] = 0
        ans[b[i]-1] = 0
    elif h[a[i]-1]>h[b[i]-1]:
        ans[b[i]-1] = 0
    elif h[a[i]-1]<h[b[i]-1]:
        ans[a[i]-1] = 0
print(sum(ans))

Solution (Python):
n,m = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
r = [[] for i in range(n)]
ans = 0
for i in range(m):
    a,b = [int(i) for i in input().split()]
    r[a-1].append(b-1)
    r[b-1].append(a-1)
for i in range(n):
    for j in r[i]:
        if h[i] <= h[j]:
            ans += 1
            break

print(n-ans)

Solution (Python):
s = input().split()
N, M = [int(i) for i in s]
H = [int(h) for h in input().split()]
goods = [True] * N
for m in range(M):
  a, b = [int(i)-1 for i in input().split()]
  if H[a] <= H[b]:
    goods[a] = False
  if H[a] >= H[b]:
    goods[b] = False
print(sum(goods))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
ab=[]
for _ in range(m):
    ab.append(list(map(int,input().split())))
good=[0]+[1]*n
for i in range(m):
    if h[ab[i][0]]==h[ab[i][1]]:
        good[ab[i][0]]=0
        good[ab[i][1]]=0
    elif h[ab[i][0]]<=h[ab[i][1]]:
        good[ab[i][0]]=0
    elif h[ab[i][0]]>=h[ab[i][1]]:
        good[ab[i][1]]=0
print(sum(good))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))

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

print(ans.count(0))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))

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

print(ans.count(0))

Solution (Python):
n, m = map(int,input().split())
h_lst = list(map(int,input().split()))
ab_lst = [list(map(int,input().split())) for _ in range(m)]
lst = [1] * n

for i in range(m):
    a = ab_lst[i][0]
    b = ab_lst[i][1]
    h_a = h_lst[a-1]
    h_b = h_lst[b-1]

    if h_a==h_b:
        lst[a-1] = 0
        lst[b-1] = 0

    else:
        if h_a==min(h_a, h_b):
            lst[a-1] = 0
        else:
            lst[b-1] = 0

count = 0
for i in range(n):
    if lst[i]==1:
        count += 1

print(count)