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):
from collections import defaultdict,deque
import sys, bisect, math, itertools
from functools import lru_cache

sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

n, m = inpl()
h = inpl()
v=[True for i in range(n)]
for i in range(m):
    a, b = inpl()  
    if h[a - 1] == h[b - 1]:
        v[a - 1] = False
        v[b - 1] = False
    elif h[a - 1] < h[b - 1]:
        v[a - 1] = False
    else:
        v[b - 1] = False
print(v.count(True))

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

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

print(sum(tmb))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for _ in range(m)]
g=[[]for _ in range(n)]
for a,b in ab:
  g[a-1].append(b-1)
  g[b-1].append(a-1)
ans=0
for i in range(n):
  c=h[i]
  t=True
  for j in g[i]:
    if c<=h[j]:
      t=False
      break
  ans+=1 if t else 0
print(ans)

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

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1] * 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[b - 1] = 0
    else:
        ans[a - 1] = 0
        ans[b - 1] = 0
print(ans.count(1))

Solution (Python):
inf = 10**15
mod = 10**9+7
n,m = map(int, input().split())
h = list(map(int, input().split()))
judge = [1 for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        judge[b-1] = 0
    elif h[b-1] > h[a-1]:
        judge[a-1] = 0
    else:
        judge[b - 1] = 0
        judge[a - 1] = 0
print(sum(judge))

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

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

h.insert(0, 0)

c = [[0] for x in range(n + 1)]

for _ in range(m):
    a, b = map(int, input().split())

    c[a].append(h[b])
    c[b].append(h[a])

cnt = 0

for x in range(1, n + 1):
    if h[x] > max(c[x]):
        cnt += 1

print(cnt)

Solution (Python):
from collections import defaultdict

n,m = map(int, input().split())
hs = {i+1: x for i,x in enumerate(map(int, input().split()))}
neighbor = defaultdict(set)
for _ in range(m):
  a,b = map(int, input().split())
  neighbor[a] |= {b}
  neighbor[b] |= {a}

c = 0
check = set()
for k in hs.keys():
  if k in check: continue
  flag = True
  for x in neighbor[k]:
    if hs[x] < hs[k]:
      check |= {x}
    else:
      flag = False
  if flag:
    c += 1
print(c)

Solution (Python):
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
observ = [set() for _ in range(n)]
for i in range(m):
    a, b = list(map(int, input().split()))
    observ[a-1].add(b-1)
    observ[b-1].add(a-1)

cnt = 0
for i, o in enumerate(observ):
    height = h[i]
    flg = True
    for oh in o:
        if height <= h[oh]:
            flg = False
            break
    if flg:
        cnt += 1

print(cnt)

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

node = [[] for _ in range(N)]

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

ans = 0
for n,i in enumerate(node):
    i_high = H[n]
    for j in i:
        if H[j] >= i_high:
            break
    else:
        ans += 1

print(ans)

Solution (Python):
import collections
N, M = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
I = [i for v, i in sorted([(v, i) for i, v in enumerate(H)], reverse=True)]
G = collections.defaultdict(set)
for _ in range(M):
    a, b = [int(_) for _ in input().split()]
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)
visited = set()
ans = 0
for i in I:
    visited.add(i)
    f = True
    for j in G[i]:
        visited.add(j)
        if H[j] >= H[i]:
            f = False
    if f:
        ans += 1
print(ans)

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

ans = 0  
for i in range(n):
  if len(G[i])==0:
    ans += 1
  else:
    if H[i] > max(G[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 _ in range(M)]
result = 0
flag = [True] * N
result = N
for a, b in AB:
    if H[a-1] < H[b-1]:
        flag[a-1] = False
    elif H[a-1] > H[b-1]:
        flag[b-1] = False
    else:
        flag[a-1] = False
        flag[b-1] = False
print(flag.count(True))

Solution (Python):


def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

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


N,M =  input_multiple_number()

listH  = input_multiple_number_as_list()

isGood = [True]*N
for i in range(M):
	A,B = input_multiple_number()

	if listH[A-1] > listH[B-1]:
		isGood[B-1] = False
	elif listH[A-1] < listH[B-1]:
		isGood[A-1] = False
	else:
		isGood[B-1] = False
		isGood[A-1] = False

cnt = 0
for i in isGood:
	if i == True:
		cnt += 1

										
print(cnt)

Solution (Python):
import sys
def input():
    return sys.stdin.readline().rstrip('\n')


def calc(N, M, H, C):
    f = [1 for _ in range(N)]
    for a, b in C:
        if H[a] == H[b]:
            f[a] = f[b] = 0
        elif H[a] > H[b]:
            f[b] = 0
        else:
            f[a] = 0
    return sum(f)
    

(N, M) = tuple([int(s) for s in input().split()])
H = [int(s) for s in input().split()]
C = [tuple([int(s) - 1 for s in input().split()]) for _ in range(M)]
print(calc(N, M, H, C))

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    good = [True]*N
    for _ in range(M):
        a, b = map(int, input().split())
        if H[a-1]==H[b-1]:
            good[a-1]=False
            good[b-1]=False
        elif H[a-1]<H[b-1]:
            good[a-1] = False
        else:
            good[b-1]=False
    print(sum(good))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    G = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        G[a].append(b)
        G[b].append(a)
    f = [True]*n
    for i in range(n):
        if not f[i]:
            continue
        x = h[i]
        for v in G[i]:
            if h[i] < h[v]:
                f[i] = False
            elif h[i] == h[v]:
                f[i] = False
                f[v] = False
            else:
                f[v] = False
    ans = 0
    for i in range(n):
        if f[i]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

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

hlst = [[] for i in range(n)]
for i in range(m):
  hlst[lst[i][1]-1].append(peak[lst[i][0]-1])
  hlst[lst[i][0]-1].append(peak[lst[i][1]-1])

ans = 0

for i in range(n):
  judge = True
  for j in range(len(hlst[i])):
    if hlst[i][j] >= peak[i]:
      judge = False
      break
  if judge:
    ans += 1
                 
print(ans)

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

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

print( N - len(set(W)) )

Solution (Python):
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    m = kwargs["m"]
    H = kwargs["H"]
    A = kwargs["A"]
    B = kwargs["B"]
    tmp = [1 for i in range(n)]

    for i in range(m):
        if H[A[i] - 1] >= H[B[i] - 1]:
            tmp[B[i] - 1] = 0

        if H[A[i] - 1] <= H[B[i] - 1]:
            tmp[A[i] - 1] = 0

    res = sum(tmp)
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    
    
    
    kwargs["n"], kwargs["m"] = [int(i) for i in cin]

    cin = input().split()
    
    
    
    kwargs["H"] = [int(i) for i in cin]

    kwargs["A"] = []
    kwargs["B"] = []
    for i in range(kwargs["m"]):
        cin = input().split()
        
        
        
        a, b = [int(i) for i in cin]
        kwargs["A"].append(a)
        kwargs["B"].append(b)

    cout = main(kwargs)
    print(cout)

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

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

print(sum(ref))

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


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

print(ans.count(1))

Solution (Python):
N,M=[int(i)for i in input().split()]
H = [int(i) for i in input().split()]
flag=[True]*N
for _ in range(M):
  A,B=[int(i)for i in input().split()] 
  if H[A-1] <= H[B-1]:
    flag[A-1]=False
  if H[A-1] >= H[B-1]:
    flag[B-1]=False
    
print(flag.count(True))

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

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

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

Solution (Python):
import sys
input=sys.stdin.readline
f=lambda:map(int,input().split())
n,m=f()
l=list(f())
t=[1]*n
g=[[] for _ in range(n)]
for _ in range(m):
  a,b=f()
  if l[a-1]<=l[b-1]: t[a-1]=0
  if l[b-1]<=l[a-1]: t[b-1]=0
print(sum(t))

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

Solution (Python):
from collections import defaultdict
def solve():
    N, M = map(int,input().split())
    H = list(map(int,input().split()))
    g = defaultdict(list)
    for i in range(M):
        a, b = map(lambda x:int(x)-1, input().split())
        g[a].append(b)
        g[b].append(a)
    
    ans = 0
    for i in range(N):
        nowH = H[i]
        connectedPlace = g[i]
        connectedH = []
        for p in connectedPlace:
            connectedH.append(H[p])
        
        if len(connectedH) == 0 or nowH > max(connectedH):
            ans += 1
    
    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):



def main():
    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
    
    paths = [[] for _ in range(N)]
    for i in range(M):
        if B[i] not in paths[A[i]]:
            paths[A[i]].append(B[i])
        if A[i] not in paths[B[i]]:
            paths[B[i]].append(A[i])
    
    good = [None] * N
    for i in range(N):
        if good[i] is not None:
            continue
        
        neighs = paths[i]
        for neigh in neighs:
            if H[i] <= H[neigh]:
                good[i] = False
            if H[i] >= H[neigh]:
                good[neigh] = False
        
        if good[i] is None:
            good[i] = True
    
    ans = 0
    for i in range(N):
        if good[i]:
            ans += 1
    
    return ans


print(main())

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

ans = 0
l = [0 for _ in range(n)]
for i in range(n):
    if l[i] == 1:
        continue
    l[i] == 1
    flag = False
    for j in road[i]:
        if h[j] > h[i]:
            flag = True
            break
        elif h[i] > h[j]:
            l[j] = 1
            continue
        else:
            l[j] = 1
            flag = True
            break
    if flag:
        continue

    ans += 1
print(ans)

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

for x in li:
    y = h[x[0]-1]
    z = h[x[1]-1]
    if y <= z:
        ans[x[0]-1] = 0
    if z <= y:
        ans[x[1]-1] = 0

print(ans.count(1))

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

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

near = [[0] for _ in range(n)]
for a, b in ab:
    near[a-1].append(h[b-1])
    near[b-1].append(h[a-1])

cnt = 0
for i in range(n):
    if h[i] > max(near[i]):
        cnt += 1
print(cnt)

Solution (Python):
n, m = (int(i) for i in input().split())
h = [0]
h.extend([int(i) for i in input().split()])
adj = []
for i in range(n+1):
	adj.append([])
for i in range(m):
	a,b = (int(i) for i in input().split())
	adj[a].append(b)
	adj[b].append(a)
	
ans = 0

for i in range(1, n+1):
	if len(adj[i])==0 or h[i] > max([h[y] for y in adj[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)]

result = [1] * N

for i in range(M):
    A = AB[i][0] - 1
    B = AB[i][1] - 1

    if H[A] > H[B]:
        result[B] = 0
    elif H[A] < H[B]:
        result[A] = 0
    elif H[A] == H[B]:
        result[A] = 0
        result[B] = 0

print(sum(result))

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

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

    print(highest.count(1))


if __name__ == '__main__':
    main()

Solution (Python):
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

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

def read_s_list_loop(n):
    return [input() for _ in range(n)]

N,M = read_int_map()
Hn = read_int_list()
tree_list = [[] for i in range(N)]
for _ in range(M):
    A,B = read_int_map()
    A -= 1
    B -= 1
    tree_list[A].append(B)
    tree_list[B].append(A)
ans = 0
for i in range(len(tree_list)):
    depend = tree_list[i]
    base_high = Hn[i]
    flag = True
    for i2 in depend:
        compare_high = Hn[i2]
        if base_high <= compare_high:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

Solution (Python):

def main():
    N,M = map(int,input().split())
    heights = 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)

    counter = 0

    for i in range(N):
        ok = True
        now_height = heights[i]
        for d in graph[i]:
            if heights[d] >= now_height:
                ok = False
                break
        if ok:
            counter += 1

    print(counter)






if __name__ == '__main__':
    main()

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

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

c=[1]*n

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

  if h[a]>h[b]:
    c[b]=c[b]-1
  elif h[a]<h[b]:
    c[a]=c[a]-1
  elif h[a]==h[b]:
    c[a]=c[a]-1
    c[b]=c[b]-1


cnt=0
for i in range(n):
  if c[i]==1:
    cnt+=1
print(cnt)

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

print(sum(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]:
        if L[b-1]==1:
            L[b-1]-=1
    elif H[a-1]<H[b-1]:
        if L[a-1]==1:
            L[a-1]-=1
    elif H[a-1]==H[b-1]:
        if L[a-1]==1 and L[b-1]==1:
            L[a-1]-=1
            L[b-1]-=1
        elif L[a-1]==1 and L[b-1]==0:
            L[a-1]-=1
        elif L[a-1]==0 and L[b-1]==1:
            L[b-1]-=1
print(sum(L))

Solution (Python):
from collections import defaultdict   
def C():
    N, M = map(int, input().split())
    H = [int(n) for n in input().split()]
    isGood = [True for i in range(len(H))]
    for i in range(M):
        A, B = map(int, input().split())
        if H[A-1] >= H[B-1]:
            isGood[B-1] = False
        if H[B-1] >= H[A-1]:
            isGood[A-1] = False
    count = 0
    for b in isGood:
        if b:
            count += 1
    print(count)

C()

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


if __name__ == "__main__":
    main()

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

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

L = [0 for i in range(N+1)]

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

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

bad = {}

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

print(N-len(bad))

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

print(sum(good))

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

for a,b in AB:
  a-=1
  b-=1
  load[a].append(b)
  load[b].append(a)
  
for i,lis in enumerate(load):
  if len(lis)==0:
    ans+=1
  else:
    judge = True
    for j in lis:
      if H[i]<=H[j]:
        judge = False
        break
    if judge:
      ans+=1
      
print(ans)

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])
a = 0
for i in range(n):
    if k[i] == [] or h[i] > max(k[i]):
        a += 1
print(a)

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

Solution (Python):
n,m=map(int,input().split())
H=list(map(int,input().split()))
AB=[list(map(int,input().split())) for _ in range(m)]
M=[[] for _ in range(n+1)]

for a,b in AB:
    M[a].append(b)
    M[b].append(a)

cnt=0
for i in range(1,n+1):
    height=H[i-1]
    flag=1
    for j in M[i]:
        if height<=H[j-1]:
            flag=0
            break
    if flag:cnt +=1

print(cnt)

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

evaluation = list(True for _ in range(n))
for _ in range(m):
    frm, to = map(lambda x: int(x)-1, input().split())
    if h[frm] < h[to]:
        evaluation[frm] = False
    elif h[frm] > h[to]:
        evaluation[to] = False
    else:
        evaluation[frm] = False
        evaluation[to] = False
print(evaluation.count(True))

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

others_list = [[] for _ in range(N)]

for i in range(M):
    A_i = AB[i][0] - 1
    B_i = AB[i][1] - 1
    others_list[A_i].append(H[B_i])
    others_list[B_i].append(H[A_i])

count = 0
for i in range(N):
    if len(others_list[i]) == 0:
        count += 1
    else:
        others_max = max(others_list[i])
        if H[i] > others_max:
            count += 1

print(count)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M = map(int, readline().split())
H = list(map(int, readline().split()))
ng = []
for _ in range(M):
    A, B = map(int, readline().split())
    A -= 1
    B -= 1
    if H[A] == H[B]:
        ng.append(A)
        ng.append(B)
        continue
    if H[A] > H[B]:
        ng.append(B)
    else:
        ng.append(A)

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

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

Solution (Python):
import sys

N, M = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))
edges = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, sys.stdin.readline().split())
    edges[a-1].add(b-1)
    edges[b-1].add(a-1)

ans = 0
for i in range(N):
    h = H[i]
    flag = True
    for j in edges[i]:
        if H[j] >= h:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline


def main():
    
    N, M = map(int, readline().split())
    H = list(map(int, readline().split()))
    paths = [[] for _ in range(N)]
    for _ in range(M):
        A, B = map(int, readline().split())
        A -= 1; B -= 1
        paths[A].append(H[B]); paths[B].append(H[A])

    ans = 0
    for i in range(N):
        Htmp = H[i]
        if len(paths[i]) > 0:
            Hmax = max(paths[i])
        else:
            Hmax = 0
        ans += (Htmp > Hmax)

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


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

highest = [0] * N

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

ans = 0
for i in range(N):
    if H[i] >highest[i]:
        ans += 1


print(ans)

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

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

ans = 0
for i in range(N):
    good = True
    for j in E[i]:
        if H[i]<=H[j]:
            good=False
            break
    if good: ans+=1

print(ans)

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

Solution (Python):
def solve(edges, h):
    neighbors = [set() for x in range(len(h)+1)]
    for edge in edges:
        neighbors[edge[0]].add(edge[1])
        neighbors[edge[1]].add(edge[0])
    result = -1
    for i, node in enumerate(neighbors):
        height = h[i-1]
        good = True
        for neighbor in node:
            if height <= h[neighbor-1]:
                good = False
                break
        if good:
            result += 1
    return result


if __name__ == "__main__":
    n, m = map(int, input().split())
    h = [int(x) for x in input().split()]
    edges = [[int(x) for x in input().split()] for y in range(m)]
    print(solve(edges, h))

Solution (Python):
from collections import defaultdict
n, m = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
adj = defaultdict(list)
for i in range(m):
    a, b = [int(i) for i in input().split()]
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
ans = 0
for i in range(n):
    if adj[i] == 0:
        ans += 1
    else:
        for j in adj[i]:
            if H[j] >= H[i]:
                break
        else:
            ans +=1
print(ans)

Solution (Python):
n, m = map(int, input().split())
listH = list(map(int, input().split()))
tL = [0]*n
tMap = {}
for i in range(m):
    a, b = map(int, input().split())
    tL[a-1] = 1
    tL[b-1] = 1
    if a-1 in tMap:
        tMap[a-1].append(listH[b-1])
    else:
        tMap[a-1] = [listH[b-1]]
    if b-1 in tMap:
        tMap[b-1].append(listH[a-1])
    else:
        tMap[b-1] = [listH[a-1]]

count = 0
for key in tMap:
    if listH[key] > max(tMap[key]):
        count+=1
for t in tL:
    if t == 0:
        count+=1
print(count)

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

print(ans.count(True))

Solution (Python):

import sys
import math

tmp = input().split()
n,m = list(map(lambda a: int(a), tmp))





ans=[]
for i in range(n):
	ans.append(0)

tmp = input().split()
h = list(map(lambda a: int(a), tmp))

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

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

for _ in range(M):
    A,B = map(int,input().split())
    Ah = H[A-1]
    Bh = H[B-1]
    if Ah >= Bh:
        P[B-1] = 0
    if Bh >= Ah:
        P[A-1] = 0
        
print(sum(P))

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

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, m = MAP()

h = LIST()
dd = dict()
for _ in range(m):
    a, b = MAP()
    if(a in dd):
        dd[a].append(b)
    else:
        dd[a] = []
        dd[a].append(b)
    if(b in dd):
        dd[b].append(a)
    else:
        dd[b] = []
        dd[b].append(a)
ans = 0
for i in range(n):
    if((i+1) in dd):
        temp = dd[i+1]
        flag = 1
        for el in temp:
            if(h[el-1]>=h[i]):
                flag = 0
                break
        if(flag==1):
            ans+=1
    else:
        ans+=1
print(ans)