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):
s=input()
n, m = map(int, s.split(' '))
h = []

s=input().split(' ')
for i in s:
    h.append(int(i))


roads_ob = []  
for i in range(n):
    roads_ob.append(set())

for i in range(m):
    s=input().split(' ')
    a = int(s[0])
    b = int(s[1])
    roads_ob[a-1].add(b-1)
    roads_ob[b-1].add(a-1)
    
    

good = 0
for i, roads in enumerate(roads_ob):
    
    better_than = 0
    for road in roads:
        if h[i] > h[road]:
            better_than += 1
        else:
            
            break
    if len(roads) == better_than:
        good += 1

print(good)

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

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

lst = [0 for i in range(N)]

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

print(lst.count(0))

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


def main():
    n, m = input_list()
    heights = input_list()

    paths = {}
    pp = set()
    for _ in range(m):
        a, b = input_list()
        pp.add(a)
        pp.add(b)
        if a in paths:
            paths[a].add(b)
        else:
            paths[a] = {b}
        if b in paths:
            paths[b].add(a)
        else:
            paths[b] = {a}
    ans = 0
    for i, other in paths.items():
        x = heights[i-1]
        is_good = True
        for o in other:
            if x <= heights[o-1]:
                is_good = False
                break
        if is_good:
            ans += 1

    only_ones = n - len(pp)
    print(ans + only_ones)

def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()

Solution (Python):
list=input().split(" ")
N=int(list[0])
road_num=int(list[1])
high_list=input().split(" ")
for i in range(N):
    high_list[i]=int(high_list[i])

N_list=["zero"]
for i in range(N):
    N_list.append("good")

for i in range(road_num):
    tmp=input().split(" ")
    num1=int(tmp[0])
    num2=int(tmp[1])
    if high_list[num1-1] < high_list[num2-1]:
        N_list[num1]="bad"
    elif high_list[num1-1] > high_list[num2-1]:
        N_list[num2]="bad"
    else:
        N_list[num1]="bad"
        N_list[num2]="bad"
        
count=0
for i in range(1,N+1):
    if N_list[i]=="good":
        count+=1
print(count)

Solution (Python):
N,M=list(map(int,input().split()))
H_keys=[i+1 for i in range(N)]
H_values=list(map(int,input().split()))
AB_list = [list(map(int,input().split())) for i in range(M)]
H=dict(zip(H_keys,H_values))



ans_list=[]
for i in AB_list:
  if H[i[0]]<H[i[1]]:
    ans_list.append(i[0])
  elif H[i[1]]<H[i[0]]:
    ans_list.append(i[1])
  else:
    ans_list.append(i[0])
    ans_list.append(i[1])
  
  
  
print(N-len(set(ans_list)))

Solution (Python):
import sys
N, M = map(int, input().split())
H = list(map(int, input().split()))
G = [set() for _ in range(N)]
for _ in range(M):
    A, B = map(int, sys.stdin.readline().split())
    A -= 1
    B -= 1
    G[A].add(B)
    G[B].add(A)

ans = 0
for p in range(N):
    if not G[p]:
        ans += 1
        continue
    for np in G[p]:
        if H[p] <= H[np]:
            break
    else:
        ans += 1
print(ans)

Solution (Python):
N,M = map(int,input().split())
hList = list(map(int, input().strip().split()))
resultDict = {}
for n in range(1,N+1):
    resultDict[n] = {}
    resultDict[n]['n']=[]
    resultDict[n]['h'] = hList[n-1]
loadList = []
for j in range(1,M+1):
    ai,bi =map(int,input().split())
    resultDict[ai]['n'].append(bi)
    resultDict[bi]['n'].append(ai)
count = 0
for o in resultDict.keys():
    height = resultDict[o]['h']
    flag = True
    for num in resultDict[o]['n']:
        if resultDict[num]['h'] >= height:
            flag = False
            break
    if(flag):
        count = count + 1
print(count)

Solution (Python):


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

Observ = [1 for i in range(N)]

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

for i in range(M):
    A,B = map(int,input().split())
    HA = H[A-1]
    HB = H[B-1]
    if HA > HB:
        Observ[B-1] = 0
    elif HA < HB:
        Observ[A-1] = 0
    elif HA == HB:
        Observ[A-1] = 0
        Observ[B-1] = 0

ans = 0
for i in Observ:
    ans += i
    
print("{}".format(ans))

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

graph = [[] for _ in range(N+1)]

for a, b in edges:
  graph[a].append(b)
  graph[b].append(a)

cnt = 0
for i in range(1, N+1):
  if len(graph[i]) == 0:
    cnt += 1
    continue
  for a in graph[i]:
    if H[i] <= H[a]:
      break
  else:
    cnt += 1

print(cnt)

Solution (Python):
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    tenbou_dict = {i:0 for i in range(1, N+1, 1)}
    for i in range(M):
        A, B = map(int, input().split())
        tenbou_dict[A] = max(tenbou_dict[A], H[B-1])
        tenbou_dict[B] = max(tenbou_dict[B], H[A-1])
    answer = 0
    for k, v in tenbou_dict.items():
        if(H[k-1] > tenbou_dict[k]):
            answer += 1
    print(answer)

main()

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

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
graph=[set([]) for _ in range(n)]

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

ans=0


for i in range(n):
    t=h[i]
    df=i
    if list(graph[i])==[]:
        ans+=1
    else:
        fa=True
        for j in list(graph[i]):
            if t<=h[j]:
                fa=False
        if fa:
            ans+=1

print(ans)

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

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

l = set()

for _ in range(y):
    a, b = list(map(int, input().split()))
    if c[a-1] > c[b-1]:
        l.add(b-1)
    elif c[a-1] < c[b-1]:
        l.add(a-1)
    else:
        l.add(a-1)
        l.add(b-1)
l = list(l)
print(len(c) - len(l))

Solution (Python):
n,m = map(int,input().split())
H = list(map(int,input().split()))
D=[]
for i in range(m):
    A,B = map(int,input().split())
    if H[A-1]<H[B-1]:
        D.append(A)
    elif H[A-1]==H[B-1]:
        D.append(A)
        D.append(B)
    else:
        D.append(B)
ans = list(set(list(range(1,n+1)))-set(D))
print(len(ans))

Solution (Python):
list1=list(map(int,input().strip().split()))[:2]
n,m=list1[0],list1[1]
arr=list(map(int,input().strip().split()))[:n]
dict1={}
for i in range(m):
	l=list(map(int,input().strip().split()))[:2]
	key,val=l[0],l[1]
	if key in dict1:
		dict1[key].append(val)
	else:
		dict1[key]=[]
		dict1[key].append(val)
	if val in dict1:
		dict1[val].append(key)
	else:
		dict1[val]=[]
		dict1[val].append(key)
count=0
for i in range(1,n+1):
	flag=0
	if i in dict1:
		l=arr[i-1]
		for j in dict1[i]:
			if(l <= arr[j-1]):
				flag=1
				break
	if(flag==0):
		count+=1
print(count)

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

good_ob = set(range(N))
for j in range(M):
    A,B = list(map(int,input().split()))
    A = A-1
    B = B-1
    if H[A]<H[B]:
        if A in good_ob:
            good_ob.remove(A)
    elif H[A]==H[B]:
        if A in good_ob:
            good_ob.remove(A)
        if B in good_ob:
            good_ob.remove(B)
    else:
        if B in good_ob:
            good_ob.remove(B)
    

print(len(good_ob))

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

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


good_list = [1 for i in range(N)]
for item in route:
    A = item[0]-1
    B = item[1]-1
    if H[A] > H[B]:
        good_list[B]= 0
    elif H[A] < H[B]:
            good_list[A] = 0
    else:
        good_list[A] = 0
        good_list[B] = 0

print(sum(good_list))

Solution (Python):


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

    

    Judge = [True] * NM[0]

    for i in range(NM[1]):
        ABi = list(map(int,input().split()))


        if H[ABi[0]-1] > H[ABi[1]-1]:
            if Judge[ABi[0]-1]:
                Judge[ABi[0]-1] = True
            Judge[ABi[1]-1] = False

        elif H[ABi[0]-1] == H[ABi[1]-1]:
            Judge[ABi[0] - 1] = False
            Judge[ABi[1] - 1] = False

        else:
            Judge[ABi[0] - 1] = False
            if Judge[ABi[1]-1]:
                Judge[ABi[1] - 1] = True

    
    print(Judge.count(True))











if __name__ == '__main__':
    main()

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

Solution (Python):
n,m=list(map(int, input().split()))
h=list(map(int, input().split()))
p=[]
remain = set(range(1, n+1))
for i in range(m):
    p.append(list(map(int, input().split())))
temp = []
for a,b in p:
    temp.append([b,a])
p = p + temp
delset = set()
for a,b in p:
    if h[a-1]<=h[b-1]:
        
        delset.add(a)
remain = remain - delset
print(len(remain))

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

count=0
for i in range(0,n):
    if len(ab[i])==0:
        count+=1
    else:
        maxh=h[ab[i][0]]
        for j in ab[i]:
            maxh=max(maxh,h[j])
        if h[i]>maxh:
            count+=1
print(count)

Solution (Python):
from collections import defaultdict as dd

n, m = map(int, input().split())
H = [0] + list(map(int, input().split()))


road = set()
for i in range(m):
    a, b = map(int, input().split())
    road.add((a, b))

counter = 0
not_highest = set()
for a, b in road:
    if H[a] == H[b]:
        not_highest.add(a)
        not_highest.add(b)
    elif H[a] > H[b]:
        not_highest.add(b)
    elif H[b] > H[a]:
        not_highest.add(a)

print(n - len(not_highest))

Solution (Python):
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
AB = []
for i in range(M):
    A, B = map(int, input().split())
    AB.append([A,B])

H01 = [1]*N
for i in range(M):
    A,B = AB[i]
    if(H[A-1]<H[B-1]):
        H01[A-1] = 0
        if(H01[B-1]!=0):
            H01[B-1] = 1
    elif(H[A-1]==H[B-1]):
        H01[A-1] = 0
        H01[B-1] = 0
    else:
        if(H01[A-1]!=0):
            H01[A-1] = 1
        H01[B-1] = 0
print(sum(H01))

Solution (Python):
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)


inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))



def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a




def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    """
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)


inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""


sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))



def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a




def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    n, m = wi()
    h = wi()
    G = defaultdict(list)
    for i in range(1, m+1):
        a, b = map(int, input().split())
        G[a].append(b)
        G[b].append(a)
    
    flag = True
    cnt = 0
    for i in range(1, n+1):
        flag = True
        for j in set(G[i]):
            if h[i-1] <= h[j-1]:
                flag = False
                break
        if flag:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

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

bad=[]
for i in range(M):
  ori=L[i][0]-1
  dest=L[i][1]-1
 
  if H[ori] <= H[dest]:
    bad.append(ori)
  if H[ori] >= H[dest]:
    bad.append(dest)

deletes=set(bad)
print(N-len(deletes))

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

for i in range(m):
    a,b = map(int,input().split())
    if ls[a-1] > ls[b-1] and lls[a-1] != False:
        lls[a-1] = True
    else:
        lls[a-1] = False

    if ls[b-1] > ls[a-1] and lls[b-1] != False:
            lls[b-1] = True
    else:
            lls[b-1] = False

print(lls.count(True))

Solution (Python):
def abc166_c():
  n, m = map(int, input().split())
  H = list(map(int, input().split()))
  path = dict([(i, []) for i in range(n)])
  for _ in range(m):
    a, b = map(int, input().split())
    path[a-1].append(b-1)
    path[b-1].append(a-1)

  ans = 0
  for i in range(n):
    my_h = H[i]
    if len(path[i]) == 0:
      ans += 1
    else:
      adj_h = [H[j] for j in path[i]]
      if my_h > max(adj_h):
        ans += 1

  print(ans)

abc166_c()

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    P = [list(map(int, input().split())) for i in range(M)]
    G = [True]*N
    for a,b in P:
        if H[a-1] >= H[b-1]:
            G[b-1] = False
        if H[a-1] <= H[b-1]:
            G[a-1] = False
    print(G.count(True))

if __name__ == '__main__':
    main()

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

peaks=[]
for i in range(n):
  peaks.append(1)
  
for i in range(m):
  if h[l[i][0]-1]>h[l[i][1]-1]:
    peaks[l[i][1]-1]=0
  elif h[l[i][0]-1]<h[l[i][1]-1]:
    peaks[l[i][0]-1]=0
  else:
    peaks[l[i][1]-1]=0
    peaks[l[i][0]-1]=0

print(peaks.count(1))

Solution (Python):
n,m=map(int,input().split())
l=list(map(int,input().split()))
lcount=[]
for i in range(m):
    a,b=map(int,input().split())
    k1=l[a-1]
    k2=l[b-1]
    if k1>k2:
        lcount.append(b)
    elif k1<k2:
        lcount.append(a)
    else:
        lcount.append(a)
        lcount.append(b)
import collections
c=collections.Counter(lcount)
print(n-len(c))

Solution (Python):
N, M = [int(i) for i in input().split()]
H = [None] + [int(i) for i in input().split()]
P = [False] + [True] * N
for i in range(M):
    A, B = [int(i) for i in input().split()]
    if H[A] >= H[B]:
        P[B] = False
    if H[B] >= H[A]:
        P[A] = False
ans = 0
for i in P:
    if i:
        ans += 1
print(ans)

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

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

for i in ab:
    f[i[0]-1].append(i[1]-1)
    f[i[1]-1].append(i[0]-1)
ans = 0

for i in range(n):
    flag = True
    for j in range(len(f[i])):
        
        if h[i] <= h[f[i][j]]:
            
            flag = False
            break
    if flag:
        
        ans += 1

print(ans)

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

z = [0 for i in range(n)]

for i in range(m):
    if h[u[i][0]-1] > h[u[i][1]-1]:
        z[u[i][1]-1] += 1
    if h[u[i][0]-1] < h[u[i][1]-1]:
        z[u[i][0]-1] += 1
    if h[u[i][0]-1] == h[u[i][1]-1]:
        z[u[i][1]-1] += 1
        z[u[i][0]-1] += 1

t = []
for i in range(n):
    if z[i] == 0:
        t.append(z[i])

print(len(t))

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

ans = set()

for i in range(M) :
  A, B = map(int, input().split())
  if H[A - 1] == H[B - 1] :
    ans.add(B)
    ans.add(A)
  elif H[A - 1] > H[B - 1] :
    ans.add(B)
  else :
    ans.add(A)
    
print(N - len(ans))

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

max_H = [1 for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        max_H[B-1] = 0
    elif H[B-1] > H[A-1]:
        max_H[A-1] = 0
    else:
        max_H[B-1] = 0
        max_H[A-1] = 0

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

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

for i in range(m):
    a, b = map(int, input().split())
    if h_list[b - 1] >= h_list[a - 1]:
        n_list[a - 1] = 'x'
    if h_list[a - 1] >= h_list[b - 1]:
        n_list[b - 1] = 'x'

for i in range(n):
    if n_list[i] == '':
        ans += 1

print(ans)

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

dais = list(range(1, N+1))
notg = []
for i in range(M):
    A, B = list(map(int, input().split()))
    if H[A-1] > H[B-1]:
        notg.append(B)

    if H[A-1] < H[B-1]:
        notg.append(A)

    if H[A-1] == H[B-1]:
        notg.append(A)
        notg.append(B)

print(len(list(set(dais) - (set(notg)))))

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

dellist=[]

for i in range(M):
    A,B=map(int,input().split())
    a=H[A-1]
    b=H[B-1]
    if a==b:
        dellist.append(A)
        dellist.append(B)
    else:
        if a>b:
            dellist.append(B)
        else:
            dellist.append(A)
del_sort=set(dellist)
print(N-len(del_sort))

Solution (Python):

def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    H.insert(0,0)
    A = [0] * (M)
    B = [0] * (M)
    TOP = [0] * len(H)
    cnt = 0

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

    for jn in range(M):
        if H[A[jn]] <= H[B[jn]]:
            TOP[A[jn]] = 1
        if H[B[jn]] <= H[A[jn]]:
            TOP[B[jn]] = 1

    cnt = TOP.count(0) -1

    print(cnt)


if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int, input().split())
H = list(map(int, input().split()))
goodTowerFlag = [True] * N

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

print(goodTowerFlag.count(True))

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)]
list1=[]
for i in range(N):
    list1.append([])
for i in range(len(AB)):
    list1[AB[i][0]-1].append(H[AB[i][1]-1])
    list1[AB[i][1]-1].append(H[AB[i][0]-1])
cnt=0
for i in range(len(list1)):
    if len(list1[i])!=0:
        if H[i]>max(list1[i]):
            cnt+=1
    else:
        cnt+=1
print(str(cnt))

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


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    Bridge = [list(map(int, input().split())) for _ in range(M)]
    Good_Bridge = [1]*N
    for i in Bridge:
        if H[i[0]-1] < H[i[1]-1]:
            Good_Bridge[i[0]-1] = 0
        elif H[i[0]-1] > H[i[1]-1]:
            Good_Bridge[i[1]-1] = 0
        else:
            Good_Bridge[i[0]-1], Good_Bridge[i[1]-1] = 0, 0
    answer = collections.Counter(Good_Bridge)

    print(answer[1])


if __name__ == '__main__':
    main()

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)
  X[b-1].append(a)
t=0
for i in range(n):
  E=[0]+list(H[k-1] for k in X[i])
  if max(E) < H[i]:
    t+=1
print(t)

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

print (ans)

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

good = set(range(1,n+1))
for i in range(m):
    if h[road[i][0]-1] < h[road[i][1]-1]:
        good.discard(road[i][0])
    elif h[road[i][1]-1] < h[road[i][0]-1]:
        good.discard(road[i][1])
    else:
        good.discard(road[i][0])
        good.discard(road[i][1])

print(len(good))

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

isgood = [1 for _ in range(n)]

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

    elif h[b] < h[a]:
        isgood[b] = 0

    else:
        isgood[a] = 0
        isgood[b] = 0

print(sum(isgood))

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

V=[[] for i in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    V[A-1].append(B-1)
    V[B-1].append(A-1)
ans=0
count=0
for i in V:
    if len(i)==0:
        ans+=1
        count+=1
    else:
        hoge=True
        for j in i:
            if H[j]>=H[count]:
                hoge=False
                break
        if hoge:
            ans+=1
        count+=1
print(ans)

Solution (Python):
N,M = map(int,input().split())
h = list(map(int,input().split()))
bri = [[0]*2 for i in range(M)]
lis = [1]*N
for i in range(M):
    a,b = map(int,input().split())
    bri[i][0] = a
    bri[i][1] = b

for i in range(M):
    if h[bri[i][0]-1] > h[bri[i][1]-1]:
        lis[bri[i][1]-1] = 0
    elif h[bri[i][0]-1] < h[bri[i][1]-1]:
        lis[bri[i][0]-1] = 0
    else:
        lis[bri[i][0]-1] = 0
        lis[bri[i][1]-1] = 0




print(sum(lis))

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

se = set()
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] <= h[b]:
        se.add(a)
    if h[a] >= h[b]:
        se.add(b)

ans = n - len(se)
print(ans)

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

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

print(sum(good))

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
from queue import deque

setrecursionlimit(10 ** 7)

n,m = map(int,stdin.readline().rstrip().split())
h = list(map(int,stdin.readline().rstrip().split()))
li = [[]for _ in range(n)]
lim = [1]*n
for _ in range(m):
    a,b = map(int,stdin.readline().rstrip().split())
    a -= 1
    b -= 1
    li[a].append(b)
    li[b].append(a)
    if h[a] <= h[b]:
        lim[a] = 0
    if h[b] <= h[a]:
        lim[b] = 0
print(sum(lim))

Solution (Python):
import copy

def solution():
    n, m = map(int, input().split())
    h = [int(s) for s in input().split()]
    roads = [[] for i in range(n)]

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

    ans = 0
    for i, road in enumerate(roads):
        if len(road) == 0:
            ans += 1
        else:
            is_ok = True
            for r in road:
                if h[r] >= h[i]:
                    is_ok = False
            if is_ok:
                ans += 1

    print(ans)

solution()

Solution (Python):


n, m = list(map(int, input().split()))
hs = list(map(int, input().split()))
hs = [-1] + hs
es = [list(map(int, input().split())) for _ in range(m)]


ed = {}
for a, b in es:
    if a not in ed:
        ed[a] = set([b])
    else:
        ed[a].add(b)
    if b not in ed:
        ed[b] = set([a])
    else:
        ed[b].add(a)


cnt = 0
for s in range(1, n+1):
    
    if s not in ed:
        
        cnt += 1
    else:
        mx = max(hs[e] for e in ed[s])
        pred = hs[s] > mx
        
        if pred:
            
            cnt += 1

print(cnt)

Solution (Python):
import copy
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
Hch=copy.copy(H)
for i in range(0,M):
    A,B=list(map(int,input().split()))
    if H[A-1]>H[B-1]:
        Hch[B-1]=0
    elif H[A-1]<H[B-1]:
        Hch[A-1]=0
    elif H[A-1]==H[B-1]:
        Hch[A-1]=0
        Hch[B-1]=0
print(len(H)-Hch.count(0))

Solution (Python):
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
path = [[] for i in range(n)]
set_path = set()
for i in range(m):
    a, b = map(int, input().split())
    path[a - 1].append(b - 1)
    path[b - 1].append(a - 1)
    set_path |= set((a - 1, b - 1))
cnt = n - len(set_path)
path_ = {int(i) for i in range(n)}
for i in set_path:
    if max([h[j] for j in path[i]]) < h[i]:
        cnt += 1
print(cnt)

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

J=[0]*N
for i in range(M):
    if H[AB[i][0]-1]<H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
    elif H[AB[i][0]-1]==H[AB[i][1]-1]:
        J[AB[i][0]-1]+=1
        J[AB[i][1]-1]+=1    
    else:
        J[AB[i][1]-1]+=1
c=0
for i in J:
    if i == 0:
        c+=1

print(c)

Solution (Python):
n, m = map(int,input().split())
height = list(map(int,input().split()))
arr = []

for i in range(m):
   x, y = map(int,input().split())
   height_x = height[x-1]
   height_y = height[y-1]
   if height_x > height_y:
      arr.append(y)
   elif height_x < height_y:
      arr.append(x)
   else:
      arr.append(x)
      arr.append(y)
arr = list(set(arr))
print(n-len(arr))

Solution (Python):
n,m = map(int,input().split())
l = list(map(int,input().split()))
d = {}
each = []
for i in range(m):
	sou,des = map(int,input().split())
	each.append(sou)
	each.append(des)
	if sou not in d:
		d[sou] = [des]
	else:
		d[sou].append(des)
	if des not in d:
		d[des] = [sou]
	else:
		d[des].append(sou)


count = 0
for i in d:
	flag = True
	for j in d[i]:
		if l[i-1] <= l[j-1]:
			flag = False
			break
	if flag:
		count += 1
count += (n - len(set(each)))
print(count)