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):
tenboudai,roads_num=map(int,input().split())
t_heights=list(map(int,input().split()))
t_points=list(range(tenboudai))
for i in range(roads_num):
    ai,bi=map(int,input().split())
    ai-=1
    bi-=1
    if t_heights[ai]>t_heights[bi]:
        t_points[bi]=t_points[ai]
    elif   t_heights[bi]>t_heights[ai]:
        t_points[ai]=t_points[bi]
    else:
        t_points[ai]=-1
        t_points[bi]=-1
counter=0
for i in range(tenboudai):
    if t_points[i]==i:
        counter+=1
print(counter)

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

bad=set()
c=0
for i in range(M):
	A,B=list(map(int,input().split()))
	if (H[A-1]<=H[B-1])and(A-1 not in bad):
		bad.add(A-1)
	if (H[A-1]>=H[B-1])and(B-1 not in bad):
		bad.add(B-1)

print(N-len(bad))

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

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

C = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        C.append(B-1)
    elif H[A-1] < H[B-1]:
        C.append(A-1)
    else:
        C.append(A-1)
        C.append(B-1)
        
c = collections.Counter(C)

m = len(list(c.keys()))

print(N-m)

Solution (Python):
def main():
    N, M = map(int, input().split())
    H = [int(h) for h in input().split()]
    is_Good = [True for i in range(N)]

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

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

    print(cnt)

if __name__ == "__main__":
    main()

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

Solution (Python):
N , M = [int(x) for x in input().split()]
height = [int(x) for x in input().split()]
good = [True] * N

for i in range(M):
    A, B = [int(x) for x in input().split()]
    if height[A-1] <= height[B-1]:
        good[A-1] = False
    if height[B-1] <= height[A-1]:
        good[B-1] = False
print(good.count(True))

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

c = collections.Counter(l)
print(n - c[0])

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

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

road_list = [[] * N for _ in range(N)]
for i in range(M):
  A, B = map(int, input().split())
  road_list[A-1].append(H[B-1])
  road_list[B-1].append(H[A-1])

ans = 0
for i in range(N):
  if len(road_list[i]) == 0:
    ans += 1
  elif H[i] > max(road_list[i]):
    ans += 1
    
print(ans)

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][0]-1]+=1
  elif h[a[i][0]-1]==h[a[i][1]-1]:
    b[a[i][0]-1]+=1
    b[a[i][1]-1]+=1
  else:
    b[a[i][1]-1]+=1
d=b.count(0)
print(d)

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

for i in range(len(h)):
    tmph = h[i]
    flg = 1
    if arr[i]:
        for j in arr[i]:
            if tmph <= h[j]:
                flg = 0
                break
    if flg == 1:
        ans +=1
print(ans)

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

obs_set = set([n for n in range(1,N+1)])
for m in range(M):
    A,B = map(int,input().split())
    if H[A-1]<H[B-1]:
        obs_set.discard(A)
    elif H[A-1] == H[B-1]:
        obs_set.discard(A)
        obs_set.discard(B)
    else:
        obs_set.discard(B)
        
print(len(obs_set))

Solution (Python):
n,k = input().split()

list = list(map(int,input().split()))
nulist = [0] * int(n)

for i in range(int(k)):
    a,b = input().split()
    a = int(a)-1
    b = int(b)-1
    if(list[a] > list[b]):
        nulist[b] = 1
    elif(list[a] < list[b]):
        nulist[a] = 1
    else:
        nulist[a] = 1
        nulist[b] = 1
print(nulist.count(0))

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

h = [num for num in map(int, input().split())]

a = [1] * n

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



print(sum(a))

Solution (Python):

import bisect
import heapq
import itertools
import math
import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]


n,m = MI()
h = LI()
li = [] 

for i in range(m):
    a_b = LI()
    a = a_b[0]
    b = a_b[1]
    if h[a-1] >= h[b-1]:
        li.append(b)
    if h[b-1] >= h[a-1]:
        li.append(a)
s = set(li)
print(n-len(s))

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

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

tmp=[0]*n

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

ans=tmp.count(0)+tmp.count(2)

print(ans)

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

    else:
        ans[b-1] = 0


print(sum(ans))

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


memo = [1] * (n)
ans = 0


for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] == H[b]:
        memo[a] = 0
        memo[b] = 0
    elif H[a] > H[b]:
        memo[b] = 0
    elif H[b] > H[a]:
        memo[a] = 0

print(sum(memo))

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

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

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

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

ans = 0
minus = 0


for i in range(n):
    height = h[i]
    if graph[i]:
        flg = True
        for j in graph[i]:
            if i == j:
                continue
            if h[j] >= height:
                flg = False
                minus += 1
                break
        if flg is True:
            ans += 1
    else:
        ans += 1
        minus += 1
        continue

print(ans)

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

H = list(map(int, input().split()))
dist = []
for i in range(N):
  dist.append([])
for i in range(M):
  n1, n2 = map(int, input().split())
  dist[n1-1].append(n2-1)
  dist[n2-1].append(n1-1)

ans = 0
  
for i in range(len(dist)):
  isHigh = True
  for j in dist[i]:
    if H[j] >= H[i]:
      isHigh = False
  if isHigh:
    ans += 1
print(ans)

Solution (Python):



tenNum, roadNum = map(int, input().split())
elevs = list(map(int, input().split()))
sides = []

for _ in range(roadNum):
    sides.append(list(map(int, input().split() )))



tenNeibors = [ [] for _ in range(tenNum)]

for side in sides:
    p1, p2 = side
    tenNeibors[p1-1].append(p2)
    tenNeibors[p2-1].append(p1)


ans = 0
for tid, tenNei in enumerate(tenNeibors):
    if len(tenNei) == 0:
        ans += 1
    else:
        selfelv = elevs[tid]
        higherFound = False
        for otherTen in tenNei:
            if elevs[otherTen-1] >= selfelv:
                higherFound = True
                break
        if higherFound == False:
            ans += 1

print(ans)

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = []
good = [1] * N

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

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

Solution (Python):
import math
 
def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChar():
	return input()

def readChars():
	return input().split()
 
n,m = readInts()
h = readInts()
ab = []
for _i in range(m):
	ab.append(readInts())

data = [[0]*1 for i in range(n+1)]


for i in range(len(ab)):
	data[ab[i][0]].append(ab[i][1])
	data[ab[i][1]].append(ab[i][0])


res = 0

for i in range(1,n+1):
	tar = data[i][1:]
	c = 0
	for j in range(len(tar)):
		if h[i-1]<=h[tar[j]-1]:
			c=1
	if c==0:
		res+=1

print(res)

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

bad_view = set()

for road in roads:
    a = h_list[road[0]-1]
    b = h_list[road[1]-1]
    
    if a > b:
        bad_view.add(road[1]-1)
    elif a < b:
        bad_view.add(road[0]-1)
    elif a == b:
        bad_view.add(road[1]-1)
        bad_view.add(road[0]-1)


print(n-len(bad_view))

Solution (Python):

import sys
N,M=map(int, sys.stdin.readline().split())
H=[None]+map(int, sys.stdin.readline().split())

al=[ [] for _ in range(N+1) ]	
for i in range(M):
	a,b=map(int, sys.stdin.readline().split())
	al[a].append(b)
	al[b].append(a)

ans=0
for i in range(1,N+1):
    cur=H[i]
    for j in al[i]:
        nextto=H[j]
        if cur<=nextto:
            break
    else:
        ans+=1
print ans

Solution (Python):
N, M = [int(x) for x in input().split(" ")]
H = [int(x) for x in input().split(" ")]
lines = [[] for i in range(N)]

for _ in range(M):
    a, b = [int(x) for x in input().split(" ")]
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)

judged = []
for n in range(N):
    if len(lines[n]) == 0:
        judged.append(True)
    else:
        is_good = True
        for oh in lines[n]:
            if H[oh] >= H[n]:
                is_good = False
        judged.append(is_good)
        

print(sum(judged))

Solution (Python):
n,m = map(int,input().split())
h = [i for i in map(int,input().split())]
graph = [[] for j 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)
  
res = 0
for i in range(n):
  flag = 1
  for j in graph[i]:
    if h[i] <= h[j]:
      flag = 0
      break
  if flag: res += 1
    
print(res)

Solution (Python):
import sys
import math
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(n):
  if len(edge[n]) == 0:
    top[n-1] = True
  else:
    num = h[n-1]
    for x in edge[n]:
      if num <= h[x-1]:
        break
    else:
      top[n-1] = True

N,M = IL()
h = IL()
ab = [IL() for i in range(M)]

edge = [[] for i in range(N+1)]
for a,b in ab:
  edge[a].append(b)
  edge[b].append(a)

top = [False]*N
for i in range(1,N+1):
  tami(i)

ans = 0
for i in top:
  if i == True:
    ans += 1
print(ans)

Solution (Python):

inp_ls = input().split(" ")
n,m = [int(e) for e in inp_ls[:2]]
h_ls = [int(e) for e in input().split(" ")[:n]]


raw_obs_dic = {i+1: [] for i in range(n)}
for i in range(m):
	a,b = [int(e) for e in input().split(" ")[:2]]
	raw_obs_dic[a].append(b)
	raw_obs_dic[b].append(a)


obs_dic = {k:list(set(raw_obs_dic[k])) for k in raw_obs_dic}


cnt = 0
for o0 in obs_dic:
	
	
	
	
	
	o0_h = h_ls[o0-1]
	flag = True
	for o1 in obs_dic[o0]:
		o1_h = h_ls[o1-1]
		if o0_h <= o1_h: flag = False
	
	if flag is True: cnt += 1


print(cnt)

Solution (Python):
import copy

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

towers = copy.copy(H)

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

ans = 0

for i in towers:
    if i != 0:
        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 _ in range(m)]

t=[0]*n
for i in ab:
    
    if h[i[0] - 1] > h[i[1] - 1]:
        t[i[1] - 1] = -1
    elif h[i[0] - 1] < h[i[1] - 1]:
        t[i[0] - 1] = -1
    elif h[i[0] - 1] == h[i[1] - 1]:
        t[i[0] - 1] = t[i[1] - 1] = -1

count=0
for i in t:
    if i == 0:
        count += 1
print(count)

Solution (Python):
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
l = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] == h[b - 1]:
        l.append(a)
        l.append(b)
    else:
        l.append(min(a, b, key=lambda x: h[x - 1]))
l = set(l)
print(n - len(l))

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

Solution (Python):
from collections import defaultdict
from math import gcd
import time
import sys
from collections import Counter
import itertools
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
start = time.time()
N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))

Hdata = [1]*N

for i in range(M):
    A, B = map(int, input().split(' '))
    if H[A-1] != H[B-1]:
        ind = A if H[A-1] < H[B-1] else B
        Hdata[ind-1] = 0
    else:
        Hdata[A-1] = Hdata[B-1] = 0


print(sum(Hdata))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
info=[]
for i in range(m):
    a,b=map(int,input().split())
    info.append([a,b])
high=[[0,0] for i in range(n)]
for i in range(m):
    x=info[i][0]-1
    y=info[i][1]-1
    high[x][1]+=1
    high[y][1]+=1
    if h[x]<=h[y]:
        high[x][0]+=1
    if h[y]<=h[x]:
        high[y][0]+=1
    
ans=0
for i in range(n):
    if high[i][1]==0:
        ans+=1
    else:
        if high[i][0]==0:
            ans+=1
print(ans)

Solution (Python):
if __name__ == '__main__':
	N,M = map(int, input().split())
	H = [int(a) for a in input().split()]
	ne = [1] * N

	c = 0
	for _ in range(M):
		A,B = map(int, input().split())
		if H[A-1] > H[B-1]:
			if ne[B-1] == 1:
				ne[B-1] = 0

		elif H[A-1] < H[B-1]:
			if ne[A-1] == 1:
				ne[A-1] = 0

		elif H[A-1] == H[B-1]:
			if ne[A-1] == 1:
				ne[A-1] = 0
			if ne[B-1] == 1:
				ne[B-1] = 0


	print(ne.count(1))

Solution (Python):
arr_1 = input().split(" ")

n=int(arr_1[0])
m=int(arr_1[1])

hs = [int(o) for o in input().split(" ")]

connected = list()
bad = list()
for num in range(0,m):
    arr_2 = input().split(" ")
    a = int(arr_2[0])
    b = int(arr_2[1])

    diff = hs[a-1] - hs[b-1]
    if diff == 0:
        bad.append(a)
        bad.append(b)
    elif diff > 0:
        bad.append(b)
    else:
        bad.append(a)

print(n - len(list(set(bad))))

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

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

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

print(sum(ans_list))

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

h_list = [int(x) for x in input().split()]
bad_set = set()

for i in range(m):
  a,b = map(int,input().split())
  if h_list[a-1] >= h_list[b-1]:
    bad_set.add(b)
  if h_list[a-1] <= h_list[b-1]:
    bad_set.add(a)
    
print(n-len(bad_set))

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

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

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

print(count)

Solution (Python):


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

for j in range(n):
	if record[j] != 0:
		ans += 1

print(ans)

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

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


cnt = 0
for i in flag:
    if i:
        cnt += 1
print(cnt)

Solution (Python):
from collections import deque

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

graph = [deque([]) for _ in range(N + 1)]
for _ in range(M):
    u, v = [int(x) for x in input().split()]
    graph[u].append(v)
    graph[v].append(u)  

good = []
t = [-1] * (N + 1)


def dfs(v):
    stack = [v]
    flg = True
    t[v] = 1
    while stack:
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if H[w-1] >= H[v-1]:
                flg = False
            else:
                t[w] = 1
        else:
            stack.pop()
    if flg:
        good.append(v)




for i in range(N):
    if t[i+1] < 0:
        dfs(i + 1)

print(len(good))

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

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





ans = 0
for i in range(n):
    if f[i] <= 0:
        
        ans += 1

print(ans)

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

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

print(N-Hmax.count(0))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
a=[None]*m
b=[None]*m
for i in range(m):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
t = [True]*n

for i in range(m):
    if h[a[i]] == h[b[i]]:
        t[a[i]]=False
        t[b[i]]=False
    elif h[a[i]] > h[b[i]]:
        t[b[i]] = False
    else:
        t[a[i]] = False
print(t.count(True))

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

hi.sort(key=lambda x: -x[1])

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

flag = [0 for i in range(n)]
for ten in hi:
    if flag[ten[0]] == 0:
        tmp_flag=1
    else:
        tmp_flag=-1
    for other in connection[ten[0]]:
        if ten[1] == h[other]:
            tmp_flag=-1
        if flag[other] == 0:
            flag[other] = -1
    flag[ten[0]] = tmp_flag

print(len([i for i in range(n) if flag[i] ==1]))

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

Solution (Python):
params0 = list(map(lambda x: int(x), input().split(' ')))
paramN, paramM = params0
paramsH = list(map(lambda x: int(x), input().split(' ')))
ways = []
for i in range(paramM):
    p = list(map(lambda x: int(x), input().split(' ')))
    ways.append([p[0], p[1]])
    ways.append([p[1], p[0]])

spots = [True for i in range(paramN)]

for way in ways:
    if paramsH[way[0] - 1] <= paramsH[way[1] - 1]:
        spots[way[0] - 1] = False

print(len(list(filter(lambda x: x, spots))))

Solution (Python):

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

hs = list(map(int, input().split()))
from collections import namedtuple

class Node(object):
    
    def __init__(self, isGood, seen, height):
        
        self.nodes = []
        self.isGood = isGood
        self.seen = seen
        self.height = height





graphs = list([Node(False, False, 0) for i in range(n)])

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

for i,h in enumerate(hs):
    graphs[i].height = h
    graphs[i].seen = False
    graphs[i].isGood = False

for g in graphs:
    if g.seen:
        continue

    for other in g.nodes:
        if graphs[other].height >= g.height:
            g.seen = True
            break
        else:
            
            graphs[other].seen = True
            continue
    if not g.seen:
        g.isGood = True
        g.seen = True

print(len([g for g in graphs if g.isGood]))

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
h = dict(enumerate(list(map(int, input().split()))))
ways = defaultdict(list)
for _ in range(m):
    fr, to = map(int, input().split())
    ways[fr].append(to)
    ways[to].append(fr)

total = 0
for i in range(1, n+1):
    if ways.get(i):
        to = set(ways.get(i))
        max_h = max([h[el-1] for el in to])
        if h[i-1] - max_h > 0:
            total += 1
    else:
        total += 1
        continue
    
print(total)

Solution (Python):
N, M = map(int,input().split())
Hs = list(map(int,input().split()))
L = [[] for i in range(N)]
count = 0
for i in range(M):
    A, B = map(int,input().split())
    (L[A-1]).append(Hs[B-1])
    (L[B-1]).append(Hs[A-1])
for i in range(N):
    if not L[i]:
        count+=1
        continue
    if Hs[i] > max(L[i]):
        count += 1
print(count)

Solution (Python):


def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab_list = [list(map(int, input().split())) for _ in range(m)]

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

    for ab in ab_list:
        a, b = ab
        a -= 1
        b -= 1
        if h[a] == h[b]:
            cnt[a] = 0
            cnt[b] = 0
        elif h[a] < h[b]:
            cnt[a] = 0
        elif h[a] > h[b]:
            cnt[b] = 0

    print(sum(cnt))

if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
height = list(map(int, input().split()))
bridge = [1]*N

for i in range(M):
    X, Y = map(int, input().split())
    if height[X-1] >= height[Y-1]:
        bridge[Y-1] =0
    if height[Y-1] >= height[X-1]:
        bridge[X-1] =0

print(bridge.count(1))

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


low_set = set()
appear_set = set()

for i in range(M):
    a, b = AB[i]
    if H[a-1] > H[b-1]:
        low_set.add(b)
    elif H[a-1] < H[b-1]:
        low_set.add(a)
    else:
        low_set.add(a)
        low_set.add(b)

ans_set = set(range(1, N+1)) - low_set
print(len(ans_set))

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

ab_ls = []
for i in range(m):
    tmp = list(map(int, input().split()))
    ab_ls.append(tmp)

no_set = set()
for item in ab_ls:
    if h_ls[item[0]-1] <= h_ls[item[1]-1]:
        no_set.add(item[0]-1)
    if h_ls[item[0]-1] >= h_ls[item[1]-1]:
        no_set.add(item[1]-1)

print(n - len(no_set))

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

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=[[i] for i in h]
for i in a:
    b[i[0]-1].append(h[i[1]-1])
    b[i[1]-1].append(h[i[0]-1])
ans=0
for j in b:
    if max(j)==j[0] and j.count(max(j))==1:
        ans+=1
print(ans)

Solution (Python):
import numpy as np
n, m = list(map(lambda x: int(x), input().split(' ')))
h = list(map(lambda x: int(x), input().split(' ')))
bo = list(map(lambda x: True, h))

for i in range(m):
  a, b = list(map(lambda x: int(x), input().split(' ')))
  if h[a-1] == h[b-1]:
    bo[a-1] = False
    bo[b-1] = False
  elif h[a-1] > h[b-1]:
    bo[b-1] = False
  elif h[a-1] < h[b-1]:
    bo[a-1] = False
print(sum(bo))

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

H_list = [int(s) for s in input().split()]

tenboudai = [1] * (N+1)
tenboudai[0] = 0



for i in range(M):
    A, B = map(int, input().split())
    
    if H_list[A-1] <= H_list[B-1]:
        tenboudai[A] = 0
    if H_list[A-1] >= H_list[B-1]:
        tenboudai[B] = 0

print(sum(tenboudai))

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

print(sum(lst))

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

a = [None] * M
b = [None] * M

ans = {i: True for i in range(N)}

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

nums = 0
for i in ans.values():
    if i:
        nums += 1

print(nums)

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

s = set(range(n))

for i in range(m):
	if h[a[i]-1]>h[b[i]-1]:
		no = b[i]-1
	elif h[a[i]-1]<h[b[i]-1]:
		no = a[i]-1
	else:
		no = a[i]-1
		if no in s:
			s.remove(no)
		no = b[i]-1
		
	if no in s:
		s.remove(no)

print(len(s))

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

for _ in range(m):
    a, b = map(int, input().split())
    ansa = h[a-1]
    ansb = h[b-1]

    if ansa > ansb:
        ls[b-1] += 1

    elif ansa == ansb:
        ls[a-1] += 1
        ls[b-1] += 1

    else:
        ls[a-1] += 1

print(ls.count(0))

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

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



ans = 0
for i in range(1,n+1):
    arr = []
    for ele in l[i]: arr.append(h[ele])
    no1 = max(arr) if arr else 0
    if h[i] > no1 : ans += 1

print(ans)

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

for a, b in ab_list:
    
    a -= 1
    b -= 1
    if h_list[a] == h_list[b]:
        nice_h_list[a] = nice_h_list[b] = 0
    elif h_list[a] < h_list[b]:
        nice_h_list[a] = 0
    else:
        nice_h_list[b] = 0

print(len([h for h in nice_h_list if h > 0]))