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())
ListH = list(map(int, input().split()))
ListAB = [list(map(int, input().split())) for i in range(M)]

Cnt=[0]*N

for i in range(M):
  if ListH[ListAB[i][0]-1]==ListH[ListAB[i][1]-1]:
    Cnt[ListAB[i][0]-1] = 1
    Cnt[ListAB[i][1]-1] = 1  
  else :
    if ListH[ListAB[i][0]-1] > ListH[ListAB[i][1]-1]:
      Cnt[ListAB[i][1]-1]=1
    if ListH[ListAB[i][0]-1] < ListH[ListAB[i][1]-1]:
      Cnt[ListAB[i][0]-1]=1

print(Cnt.count(0))

Solution (Python):
n, m = map(int, input().split())
hyoko = list(map(int, input().split()))
result = {}

for i in range(1, n+1):
    result[i] = result.get(i, set())

for i in range(0, m):
    michi = list(map(int, input().split()))
    result[michi[0]].add(michi[1])
    result[michi[1]].add(michi[0])

count = 0

for key, value in result.items():
    flg = 0
    if len(value) == 0:
        count += 1
        continue
    for i in value:
        if hyoko[key-1] <= hyoko[i-1]:
            flg = 1
    
    if flg == 0:
        count += 1
        
print(count)

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

not_good = []
for i in range(m):
    a,b = list(map(int,input().split()))
    if h[a-1] <= h[b-1]:
        not_good.append(a)
    if h[a-1] >= h[b-1]:
        not_good.append(b)
print(n-len(set(not_good)))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
A=[[] for _ in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    A[a].append(b)
    A[b].append(a)

s=0
for x in range(1,n+1):
    if A[x]==[]:s+=1
    else:
        f=True
        for y in A[x]:
            if h[x-1]<=h[y-1]:f=False
        if f==True:s+=1
print(s)

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

H2 = copy.copy(H)
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] > H[B - 1]:
        H2[B - 1] = False
    elif H[A - 1] < H[B - 1]:
        H2[A-1] = False
    else:
        H2[A - 1] = False
        H2[B - 1] = False

H3 = H2.count(False)

print(len(H) - H3)

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)]

ans = [0] * N
for i in range(M):
    if H[AB[i][0]-1] > H[AB[i][1]-1]:
        ans[AB[i][1]-1] += 1
    if H[AB[i][0]-1] < H[AB[i][1]-1]:
        ans[AB[i][0]-1] += 1
    if H[AB[i][0]-1] == H[AB[i][1]-1]:
        ans[AB[i][0]-1] += 1
        ans[AB[i][1]-1] += 1
print(ans.count(0))

Solution (Python):
s = list(map(int,input().split()))
n=s[0]
m=s[1]
h = list(map(int, input().split()))
p={}
for i in range(n+1):
    p[i]=0
for i in range(m):
    s = list(map(int, input().split()))
    if p[s[0]]==0:
        p[s[0]]=1
    if p[s[1]]==0:
        p[s[1]]=1
    if h[s[0]-1]>h[s[1]-1] and p[s[0]]!=3:
        p[s[0]]=2
    else:
        p[s[0]] = 3
    if h[s[0]-1] < h[s[1]-1] and p[s[1]] != 3:
        p[s[1]] = 2
    else:
        p[s[1]] = 3
ans=-1
for i in p:
    if p[i]==0 or p[i]==2:
        ans+=1
print(ans)

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

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

AB = sorted(AB)
    
import collections
que = collections.deque()

for i in AB:
    que.append(i)

for i in range(n):
    compare = []
    
    while que:
        if que[0][0] == i:
            ab = que.popleft()
        else:
            break
            
        if ab[0] == i:
            compare.append(H[ab[1]])
    
    c = len(compare)
    
    if c > 0 and H[i] > max(compare):
        ans += 1
    
    if c == 0:
        ans += 1
        
print(ans)

Solution (Python):
N, K = map(int, input().split())
l = [1] * N
A = list(map(int, input().split()))

for i in range(K):
  R = list(map(int, input().split()))
  if A[R[0]-1]==A[R[1]-1]:
    l[R[0]-1]=0
    l[R[1]-1]=0
  elif A[R[0]-1]>A[R[1]-1]:
    l[R[1]-1]=0
  else:
    l[R[0]-1]=0
  
print(sum(l))

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


for m in range(M):
    MICHI.append(tuple(map(int, input().split(' '))))



setsuzokumap_d = {}
setsuzokumap_me = [[] for j in range(N)]


for m in MICHI:
    
    

    setsuzokumap_me[m[0] - 1].append(m[1] - 1)
    setsuzokumap_me[m[1] - 1].append(m[0] - 1)

    



good_tenboudai = [None] * N



for n in range(N):
    
    if good_tenboudai[n] is None:
        
        if setsuzokumap_me[n]:
            
            for setsuzokusaki in setsuzokumap_me[n]:

                m = setsuzokusaki

                
                if good_tenboudai[m] == 1:
                    good_tenboudai[n] = 0
                else:
                    
                    if H[m] <= H[n]:
                        good_tenboudai[m] = 0

                    
                    if H[n] <= H[m]:
                        good_tenboudai[n] = 0




for n in range(N):
    if good_tenboudai[n] is None:
        good_tenboudai[n] = 1


print(sum(good_tenboudai))

Solution (Python):

import sys
import os

n,m = [int(p) for p in input().split()]
h = [int(p) for p in input().split()]

ab = []
for i in range(m):
    a,b = [int(p) for p in input().split()]
    ab.append([a,b])




tenbo = [[] for i in range(n)]


for j in range(m):
    a,b = ab[j]

    tenbo[a-1].append(h[b-1])
    tenbo[b-1].append(h[a-1])




kazu = 0
for i in range(n):
    
    if len(tenbo[i]) == 0:
        kazu += 1
        
    elif h[i] > max(tenbo[i]):
        kazu += 1
        

print(kazu)

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
load = {x : [] for x in range(1,n+1)}
ans = h[:]
cnt = 0
for i in range(m):
    a,b = map(int,input().split())
    if b in load[a]:
        pass
    else:
        load[a].append(b)
        load[b].append(a)
        if ans[a - 1] == 0:
            pass
        else:
            if h[a-1] > h[b-1]:
                pass
            else:
                ans[a-1] = 0
                
        if ans[b - 1] == 0:
            pass
        else:
            if h[b-1] > h[a-1]:
                    pass
            else:
                ans[b-1] = 0
                
                
for i in ans:
    if i:
        cnt += 1
print(cnt)

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

R = [[] for _ in range(N+1)]
for i in range(M):
  a,b = map(int,input().split())
  R[a].append(b)
  R[b].append(a)

ans = N




for i in range(1,N+1):
  for j in R[i]:
    if H[i] <= H[j]:
      ans = ans - 1
      break


print(ans)

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[1] * N
for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]==H[B-1]:
        L[A-1]=0
        L[B-1]=0
    elif H[A-1]>H[B-1]:
        L[B-1]=0
    else:
        L[A-1]=0
AAA=sum(L)
print(AAA)

Solution (Python):
(n, m) = tuple(map(int, input().split(" ")))
h = list(map(int, input().split(" ")))
l = [-1 for i in range(n)]
for i in range(m):
    (a, b) = tuple(map(int, input().split(" ")))
    if l[a - 1] < h[b - 1]:
        l[a - 1] = h[b - 1]
    if l[b - 1] < h[a - 1]:
        l[b - 1] = h[a - 1]
c = 0
for i in range(n):
    if l[i] == -1 or l[i] < h[i]:
        c += 1
print(c)

Solution (Python):
import queue
import copy
import math
from collections import deque
import bisect
from decimal import Decimal


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

heights = list(map(int, input().split()))

candidate = set()

for i in range(n):
    candidate.add(i + 1)

roads = []

for i in range(0, m):
    road = list(map(int, input().split()))
    roads.append(road)

exists_road = set()
lower = set()
ans_set = set()

for road in roads:
    h0 = heights[road[0] - 1]
    h1 = heights[road[1] - 1]

    exists_road.add(road[0])
    exists_road.add(road[1])

    if h0 > h1:
        ans_set.add(road[0])
        lower.add(road[1])

    elif h0 < h1:
        ans_set.add(road[1])
        lower.add(road[0])

    else:
        ans_set.add(road[0])
        lower.add(road[0])
        ans_set.add(road[1])
        lower.add(road[1])

unvisited = candidate - exists_road
heighest = ans_set - lower

print(len(unvisited) + len(heighest))

Solution (Python):
N,M=map(int,input().split())
H=[int(i) for i in input().split()]
A=[0]*M
B=[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())
D=[i+1 for i in range(N)]
C=[]
for i in range(M):

    if(H[A[i]-1]>H[B[i]-1]):

        C.append(B[i])

    elif(H[A[i]-1]<H[B[i]-1]):

        C.append(A[i])
    else:

        C.append(A[i])
        C.append(B[i])

G=list(set(D)-set(C))
print(len(G))

Solution (Python):
NM=list(map(int,input().split()))

Hlist=list(map(int,input().split()))

A=[0]*NM[0]
for i in range (NM[1]):
    AB=list(map(int,input().split()))
    if Hlist[AB[0]-1]<=Hlist[AB[1]-1]:
        A[AB[0]-1]=1
    if Hlist[AB[1]-1]<=Hlist[AB[0]-1]:
        A[AB[1]-1]=1
ans=NM[0]-sum(A)
print(ans)

Solution (Python):
import sys
import math
from collections import deque

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

mydict = {}
for i in AB:
    if i[0] not in mydict:
        mydict[i[0]] =[i[1]]
    else:
        mydict[i[0]].append(i[1])

    if i[1] not in mydict:
        mydict[i[1]] =[i[0]]
    else:
        mydict[i[1]].append(i[0])


cnt = 0
for i in range(1,N+1):
    if i not in mydict.keys():
        cnt += 1
        continue

    top_flag = True
    for k in list(set(mydict[i])):
        if i == k:
            continue
        if H[i-1] <= H[k-1]:
            top_flag = False
            break
    if top_flag == True:
        cnt += 1

print(cnt)

Solution (Python):
N,M = map(int, input().split())
H = list(map(int, input().split()))
A = [ list(map(int,input().split(" "))) for i in range(M)]
C = []
for i in range(N):
	C.append(0)
for i in range(M):
	x = A[i][0]
	y = A[i][1]
	if H[x-1] > H[y-1]: 
		C[y-1] += -1
	elif H[x-1] < H[y-1]:
		C[x-1] += -1
	elif H[x-1] == H[y-1]:
		C[x-1] += -1
		C[y-1] += -1
print(C.count(0))

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
H = set(range(n))
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] <= h[b-1]:
        H.discard(a-1)
    if h[a-1] >= h[b-1]:
        H.discard(b-1)

print(len(H))

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
memo = [[] for _ in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    memo[a].append(b)
    memo[b].append(a)
    
count = 0
for i in range(1,N+1):
    mini = set(memo[i])
    if len(mini) > 0:
        for j in mini:
            if H[i-1] <= H[j-1]:
                break
        else:
            count += 1
    else:
        count += 1

print(count)

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

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

ans = 0
cnt = 0
for i in d:
    if i != []:
        cntF = True
        for j in i:
            if H[cnt] <= H[j]:
                cntF = False
                break
        if cntF:
            ans += 1
    else:
        ans += 1
    cnt += 1

print(ans)

Solution (Python):






def main():
    N, M = map(int, input().split())
    heights = list(map(int, input().split()))
    towers = [True for _ in range(N)]

    pathes = (list(map(int, input().split())) for _ in range(M))

    for path in pathes:

        a = path[0] - 1
        b = path[1] - 1

        ha = heights[a]
        hb = heights[b]

        if ha > hb:
            towers[b] = False
        elif ha < hb:
            towers[a] = False
        else:
            towers[a] = False
            towers[b] = False

    print(sum(towers))


if __name__ == "__main__":
    main()

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


for d in range(0,M):
    if H[AB[d][0]-1] < H[AB[d][1]-1]:
        AB[d].pop(1)
    elif H[AB[d][0]-1] > H[AB[d][1]-1]:
        AB[d].pop(0)


bad = [e for row in AB for e in row]
badsingle = list(set(bad))
print(N - len(badsingle))

Solution (Python):
N,M=map(int,input().split())
HList=list(map(int,input().split()))
ans=[i for i in range(1,N+1)]
for i in range(M):
    A,B=map(int,input().split())
    if HList[A-1]==HList[B-1]:
        ans[A-1]=0
        ans[B-1]=0
    elif HList[A-1]>HList[B-1]:
        ans[B-1]=0
    else:
        ans[A-1]=0
print(N-ans.count(0))

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())
mountains = [0]*N
for i in range(M):
    if H[A[i]-1]>H[B[i]-1]:
        mountains[B[i]-1] -= 1
    elif H[A[i]-1]<H[B[i]-1]:
        mountains[A[i]-1] -= 1
    else:
        mountains[B[i]-1] -= 1
        mountains[A[i]-1] -= 1
print(mountains.count(0))

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

road_list = []
for _ in range(N):
    road_list.append([])
    
for i in range(M):
    a, b = list(map(int, input().split()))
    
    H_a, H_b = [H_list[a - 1], H_list[b - 1]]
    
    if H_a <= H_b:
        road_list[a - 1].append(b)

    if H_b <= H_a:
        road_list[b - 1].append(a)

ans = 0
for road in road_list:
    if len(road) == 0:
        ans += 1
print(ans)

Solution (Python):
import collections
n,m = (int(i) for i in input().split())
h = [int(i) for i in input().split()]
ab =[[0]]*n

for _ in range(m):
	a,b = (int(i) for i in input().split())
	if h[a-1]-h[b-1]>0:
		ab[b-1]=["a"]

	elif h[a-1]-h[b-1]<0:
		ab[a-1]=["a"]

	else:
		ab[a-1]=["a"]
		ab[b-1]=["a"]


print(ab.count([0]))

Solution (Python):
import numpy as np
n,m  = [int(k) for k in input().split()]
h = [int(k) for k in input().split()]
j = []
for i in range(n):
    j.append([-1])
r = 0
for i in range(m):
    a,b = [int(k) - 1 for k in input().split()]
    j[a].append(b)
    j[b].append(a)
for i in range(n):
    
    j[i] = list(set(j[i][1:]))
    is_good = False if not len(j) >= 1 else True
    for l in j[i]:
        if h[i] > h[l]:
            is_good = True
        else:
            is_good = False
            break
    if is_good:
        r += 1
print(r)

Solution (Python):
n, m = map(int, input().split())
H = list(map(int, input().split()))
K = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    K[a - 1].append(H[b - 1])
    K[b - 1].append(H[a - 1])
ans = 0
for i, k in enumerate(K):
    if len(k) != 0 and H[i] > max(k):
        ans += 1
    elif len(k) == 0:
        ans += 1
print(ans)

Solution (Python):
N, M = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
nodes = [1 for i in range(N)]
for j in range(M):
    a, b = [int(x) for x in input().split()]
    if H[a - 1] <= H[b - 1]:
        nodes[a - 1] = 0
    if H[b - 1] <= H[a - 1]:
        nodes[b - 1] = 0
print(sum(nodes))

Solution (Python):
n, m = map(int, input().split()) 
h = list(map(int, input().split()))
l = [0]*n
for i in range(m):
    A, B= map(int, input().split())
    if h[A-1] < h[B-1]:
      l[A-1] +=1
    elif h[B-1] < h[A-1]:
      l[B-1] +=1
    else:
      l[A-1] +=1
      l[B-1] +=1
print(l.count(0))

Solution (Python):
number_of_observatory, number_of_road = map(int, input().split())
height_list = [0]  
height_list.extend(list(map(int, input().split())))

road_list = []
for i in range(number_of_road):
    li = list(map(int, input().split()))
    road_list.append(li)  
counta = 0

not_good_list = []

for road in road_list:
    if height_list[road[0]] < height_list[road[1]]:
        not_good_list.append(road[0])
    elif height_list[road[0]] > height_list[road[1]]:
        not_good_list.append(road[1])
    else:
        not_good_list.extend(road)

not_good_set = set(not_good_list)
observatory_set = set(range(1, number_of_observatory+1))

print(len(observatory_set - not_good_set))

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


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

obvs = list(range(1,N+1,1))
obvs_height = list(map(int, input().split()))


obvs = {}
i = 1
for h in obvs_height:
    obvs[i] = h
    i += 1

obvs_remain = obvs.copy()

while True:
    path = list(map(int, input().strip().split()))
    if path==[]:
        break
    if obvs[path[0]] == obvs[path[1]]:
        obvs_remain.pop(path[0], None)
        obvs_remain.pop(path[1], None)
    elif obvs[path[0]] > obvs[path[1]]:
        obvs_remain.pop(path[1], None)
    elif obvs[path[0]] < obvs[path[1]]:
        obvs_remain.pop(path[0], None)

print(len(obvs_remain))

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

li = [1 for i in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    if(h[a-1] < h[b-1]):
        li[a-1] = 0
    elif(h[b-1] < h[a-1]):
        li[b-1] = 0
    elif(h[a-1] == h[b-1]):
        li[a-1] = 0
        li[b-1] = 0
    
c=0
for i in range(len(li)):
    if(1 == li[i]):
        c += 1

print(c)

Solution (Python):
import copy
N,M=(int(x) for x in input().split())
H=[]
H.extend((int(x) for x in input().split()))
h=copy.copy(H)
for i in range(M):
    A,B=(int(x) for x in input().split())
    a=A-1
    b=B-1
    if H[a]<H[b]:
        h[a]=0
    elif H[a]>H[b]:
        h[b]=0
    else:
        h[a]=0
        h[b]=0
print(len([i for i in h if i!=0]))

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
d = {}
s = []

for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] in d.keys():
        d[ab[0]] = max(d[ab[0]],H[ab[1]-1])
    else:
        d[ab[0]] = H[ab[1]-1]
    if ab[1] in d.keys():
        d[ab[1]] = max(d[ab[1]],H[ab[0]-1])
    else:
        d[ab[1]] = H[ab[0]-1]
    s.append(ab[0])
    s.append(ab[1])

count = 0
for i in d.keys():
    if H[i-1] > d[i]:
        count += 1

count += N - len(set(s))

print(count)

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

height=list(map(int,input().strip().split()) )
lst=[1]*h

for i in range(m):
    a,b=map(int,input().strip().split())
    if height[a-1]>height[b-1]:
        lst[b-1]=0
    elif height[a-1]<height[b-1]:
        lst[a-1]=0
    else:
        lst[b - 1] = 0
        lst[a - 1] = 0

print(lst.count(1))

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

Solution (Python):
N, M = map(int,input().split())
H_list = list(map(int,input().split()))
A_list = [0]*M
B_list = [0]*M
for i in range(M):
  A_list[i],B_list[i] = map(int,input().split())

count_list = ['+']*N
for j in range(M):
  if H_list[B_list[j]-1]-H_list[A_list[j]-1] >= 0:
    count_list[A_list[j]-1] = '-'
  if H_list[A_list[j]-1]-H_list[B_list[j]-1] < 0 and count_list[A_list[j]-1] != '-':
    count_list[A_list[j]-1] = '+'

for k in range(M):
  if H_list[A_list[k]-1]-H_list[B_list[k]-1] >= 0:
    count_list[B_list[k]-1] = '-'
  if H_list[A_list[k]-1]-H_list[B_list[k]-1] < 0 and count_list[B_list[k]-1] != '-':
    count_list[B_list[k]-1] = '+'
 
print(count_list.count('+'))

Solution (Python):
n, m = map(int, input().split())
H = [0] + list(map(int, input().split()))
G = [[] * (n + 1) for _ in range(n + 1)]
for i in range(m):
	a, b = map(int, input().split())
	G[a].append(b)
	G[b].append(a)



cnt = 0
for i in range(1, n + 1):
	path = G[i] 
	if len(path) == 0:
		cnt += 1
	else:
		flg = True
		for e in path:
			if H[i] <= H[e]:
				flg = False
		if flg:
			cnt += 1

print(cnt)

Solution (Python):
def main():
    N, M = map(int, input().split())
    H = [int(h) for h  in input().split()]
    E = [None]*M
    G = [1]*N
    for p in range(M):
        A, B = map(int, input().split())
        if G[A-1] == 0 and G[B-1] == 0:
            continue
        if H[A-1] > H[B-1]:
            G[B-1] = 0
        elif H[A-1] == H[B-1]:
            G[A-1] = 0
            G[B-1] = 0
        else:
            G[A-1] = 0
        
    print(sum(G))


if __name__ == "__main__":
    main()

Solution (Python):
N,M = map(int, input().split())
H = list(map(int, input().split()))
dp = [1]*N
for i in range(M):
  A,B = map(int, input().split())
  if H[A-1] <= H[B-1]:
    dp[A-1] = 0
  if H[B-1] <= H[A-1]:
    dp[B-1] = 0
print(dp.count(1))

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

Hl = [int(x) for x in input().split()]
al = []

for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  if Hl[a] > Hl[b]:
    al.append(b+1)
  elif Hl[a] < Hl[b]:
    al.append(a+1)
  else:
    al.extend([a+1,b+1])

al = set(al)
print(len(Hl) - len(al))

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




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


flag = [1] * n


for i in range(m):
  a,b = map(int, input().split())
  
  
  
  if H[a-1] <= H[b-1]:
    flag[a-1] = 0
    
  if H[b-1] <= H[a-1]:
    flag[b-1] = 0
    
  

count = 0
for f in flag:
  if f:
    count += 1
print(count)

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

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

H=list(map(int, input().split()))
A = [input().split() for l in range(m)]

li = []

for a,b in A:
    if H[int(a)-1]<H[int(b)-1]:
        li.append((a,0))
    elif H[int(a)-1]>H[int(b)-1]:
        li.append((b,0))
    else:
        li.append((a,0))
        li.append((b,0))


di=dict(li)
print(n-len(di))

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

Solution (Python):
from sys import stdin, stdout  
  
def main(): 
	n, k = [int(x) for x in stdin.readline().split()] 
	arr = [int(x) for x in stdin.readline().split()] 
	notValid = set()
	for x in range(k): 
		a, b = [int(x) for x in stdin.readline().split()] 
		if arr[a-1] > arr[b-1]:
			notValid.add(b)
		elif arr[a-1] == arr[b-1]:
			notValid.add(b)
			notValid.add(a)
		else:
			notValid.add(a)
	

	stdout.write(str(n - len(notValid))+'\n')
if __name__ == "__main__": 
	main()

Solution (Python):
N , M = map(int,input().split())
Height = [h_i for h_i in map(int,input().split())]
Roots = []
counter = [0 for i in range(N)]
for j in range(M):
    root = [c_i -1 for c_i in map(int,input().split())]
    
    if Height[root[0]]<Height[root[1]]:
        counter[root[0]] += 1
    elif Height[root[0]]==Height[root[1]]:
        counter[root[0]] += 1
        counter[root[1]] += 1
    else:
        counter[root[1]] += 1

counter2 = 0
for i in range(N):
    if counter[i]==0:
        counter2+=1
print(counter2)

Solution (Python):
N,M=map(int,input().split())
a=list(map(int,input().split()))
lst=[]
for i in range(M):
  b=list(map(int,input().split()))
  if a[b[0]-1]>a[b[1]-1]:
    lst.append(b[1])
  elif a[b[0]-1]==a[b[1]-1]:
    lst.append(b[0])
    lst.append(b[1])
  else:
    lst.append(b[0])
print(N-len(set(lst)))

Solution (Python):
N,M=map(int,input().split())
H=[int(x) for x in input().split()]
l=[1 for _ in range(N)]
for _ in range(M):
  A,B=map(int,input().split())
  if H[A-1] < H[B-1]:
    l[A-1] = 0
  elif H[A-1] == H[B-1]:
    l[A-1] = 0
    l[B-1] = 0
  else:
    l[B-1] = 0
print(sum(l))

Solution (Python):
n, m = map(int, input().split())
h_array = list(map(int, input().split()))
ab = []
sum = 0
answer = [True for i in range(n)]

for i in range(m):
  ab.append(list(map(int, input().split())))

for i in range(len(ab)):
  if h_array[ab[i][0]- 1] >= h_array[ab[i][1]- 1]:
    answer[ab[i][1] - 1] = False
  if h_array[ab[i][1]- 1] >= h_array[ab[i][0]- 1]:
      answer[ab[i][0] - 1] = False

print(answer.count(True))

Solution (Python):
import bisect

inputLine=input()
N=int(inputLine.split(" ")[0])
M=int(inputLine.split(" ")[1])

inputLine=input()
H=inputLine.split(" ")
for i in range(len(H)):
    H[i]=int(H[i])

root=[]
for i in range(M):
    inputLine=input()
    A=int(inputLine.split(" ")[0])
    B=int(inputLine.split(" ")[1])

    root.append([A,B])
    root.append([B,A])

root.sort()

root2=[]
for i in range(len(root)):
    root2.append(root[i][0])

allObservatoryCheck=[]
for i in range(N):
    allObservatoryCheck.append(True)

for i in range(N):

    startPoint = bisect.bisect_left(root2, i + 1)

    for j in range(startPoint, len(root)):
        
        if root[j][0] == i + 1:
            if H[i] <= H[root[j][1] - 1]:
                allObservatoryCheck[i] = False

        if root[j][0] > i + 1:
            break

result = 0
for i in range(N):
    if allObservatoryCheck[i] == True:
        result += 1

print(result)

Solution (Python):
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
result = [1] * N
for i in range(M):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  if H[x] > H[y]:
    result[y] = 0
  elif H[x] < H[y]:
    result[x] = 0
  else:
    result[x] = 0
    result[y] = 0

print(sum(result))

Solution (Python):
import numpy as np

N,M   = list(map(int,input().split()))
Hlist = list(map(int,input().split()))
Hdict = {i:Hlist[i] for i in range(len(Hlist))}



bad_set = set()
for _ in range(M):
    line = list(map(int,input().split()))
    if Hdict[line[0]-1] <= Hdict[line[1]-1]:
        bad_set.add(line[0])
    if Hdict[line[1]-1] <= Hdict[line[0]-1]:
        bad_set.add(line[1])
print(N-len(bad_set))

Solution (Python):
import numpy

inp=input().split(" ")
n=int(inp[0])
m=int(inp[1])
inh=input().split(" ")
for i in range(len(inh)):
  inh[i]=int(inh[i])
pairs=numpy.zeros(2*m,dtype=">i4").reshape(-1,2)
for i in range(m):
  a=input().split(" ")
  pairs[i][0]=int(a[0])
  pairs[i][1]=int(a[1])
lists=[[] for i in range(n)]
for i in range(len(pairs)):
  lists[pairs[i][0]-1].append(pairs[i][1]-1)
  lists[pairs[i][1]-1].append(pairs[i][0]-1)
for i in range(len(lists)):
  lists[i]=list(set(lists[i]))
count=0
for i in range(len(lists)):
  if len(lists[i])==0:
    count+=1
    continue
  for j in range(len(lists[i])):
    if inh[i] <= inh[lists[i][j]]:
      break
    if j == len(lists[i])-1:
      count+=1
print(count)

Solution (Python):
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
road_dict = {a+1: set() for a in range(n)}
for i in range(m):
  a, b = map(int, input().split())
  if a in road_dict:
    road_dict[a].add(b)
  else:
    road_dict[a] = set([b])
  if b in road_dict:
    road_dict[b].add(a)
  else:
    road_dict[b] = set([a])
use_list = []
res = 0
for k, s in road_dict.items():
  k_height = h_list[k-1]
  if len(s) == 0:
    res += 1
  else:
    add_flg = True
    for v in list(s):
      v_height = h_list[v-1]
      if k_height > v_height:
        continue
      else:
        add_flg = False
        break
    if add_flg:
      res += 1
print(res)

Solution (Python):


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

H_list = list(map(int, input().split()))


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

flg_list=[]
for i in range(N):
    flg_list.append(1)



ans = 0
'''
for i in range(N):
    
    flg = 1
    for road in road_list:
        if i+1 in road:
            if i+1 == road[0] and H_list[road[0]-1] <= H_list[road[1]-1]:
                flg=0
            elif i+1 == road[1] and H_list[road[1]-1] <= H_list[road[0]-1]:
                flg=0
    if flg==1:
        
        ans=ans+1
'''
for road in road_list:
    if H_list[road[0]-1] < H_list[road[1]-1]:
        flg_list[road[0]-1]=0
    elif H_list[road[1]-1] < H_list[road[0]-1]:
        flg_list[road[1]-1]=0
    else:
        flg_list[road[0]-1]=0
        flg_list[road[1]-1]=0
for i in range(N):
    if flg_list[i]==1:
        ans=ans+1


print(ans)

Solution (Python):
n, m = map(int, input().split())
h = []
a = []
b = []
dic_target = {}
dic_exclude = {}

counter = 0

h = list(map(int, input().split()))

for i in range(m):
  _a, _b = map(int, input().split())
  
  h_a = h[_a - 1]
  h_b = h[_b - 1]
  if _a in dic_target:
    dic_target[_a] = max(dic_target[_a], h_a, h_b)
  else:
    dic_target[_a] = max(h_a, h_b)
  if _b in dic_target:
    dic_target[_b] = max(dic_target[_b], h_a, h_b)
  else:
    dic_target[_b] = max(h_a, h_b)
  if h_a == h_b:
    if _a in dic_exclude:
      dic_exclude[_a] = max(dic_exclude[_a], h_a, h_b)
    else:
      dic_exclude[_a] = max(h_a, h_b)
    if _b in dic_exclude:
      dic_exclude[_b] = max(dic_exclude[_b], h_a, h_b)
    else:
      dic_exclude[_b] = max(h_a, h_b)

for i in range(n):
  if i + 1 not in dic_target:
    counter += 1
  elif i + 1 in dic_target and h[i] == dic_target.get(i + 1):
    if i + 1 not in dic_exclude or h[i] != dic_exclude.get(i + 1):
      counter += 1
print(counter)

Solution (Python):


n, m = map(int, input().split())
high = [int(i) for i in input().split()]


high_d = {}
for i in range(n):
    
    high_d[i+1] = high[i]


d = {}
for _ in range(m):
    a, b = map(int, input().split())
    if a not in d:
        d[a] = [b]  
    else:
        d[a].append(b)
    if b not in d:
        d[b] = [a]  
    else:
        d[b].append(a)



cnt = 0
for i, li in d.items():
    
    is_true = True
    for j in li:
        if high_d[i] > high_d[j]:
            continue
        else:
            is_true = False
    if is_true:
        cnt += 1

cnt += n - len(d)

print(cnt)