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

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

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

for i 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 = 0
for i in range(n):
    if h[i] > x[i]:
        ans += 1

print(ans)

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

all_tenbo = list(range(1, N+1))

not_good = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]:
        not_good.append(B)
    if H[A-1] <= H[B-1]:
        not_good.append(A)
print(len(set(all_tenbo) - set(not_good)))

Solution (Python):


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    

    
    

    n,m = map(int, input().split())
    h = list(map(int, input().split()))
    adj = [[] for _ in range(n)] 
    for _ in range(m):
        a,b = map(int, input().split())
        adj[a-1].append(b-1)
        adj[b-1].append(a-1)
    res = 0
    for i in range(n):
        c = h[i]
        for j in adj[i]:
            if h[i] <= h[j]:
                break
        else:
            res += 1
    print(res)



if __name__ == '__main__':
    main()

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

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

highest = set([i + 1 for i in range(N)])

for road in roads:
	if Ks[road[1] - 1] > Ks[road[0] - 1]:
		if road[0] in highest:
			highest.remove(road[0])
	elif Ks[road[1] - 1] < Ks[road[0] - 1]:
		if road[1] in highest:
			highest.remove(road[1])
	else:
		if road[1] in highest:
			highest.remove(road[1])
		if road[0] in highest:
			highest.remove(road[0])

print(len(highest))

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

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

def main():
  H=[int(x) for x in input().split()]
  G=[1]*N

  for i in range(M):
    a,b=map(int,input().split())
    G[~-a]*=1 if H[~-a]>H[~-b] else 0
    G[~-b]*=1 if H[~-b]>H[~-a] else 0

  print(sum(G))

main()

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
    elif h[a-1] == h[b-1]:
        ans[a-1] = ans[b-1] = 0

print(ans.count(1))

Solution (Python):
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
observary = [[] for _ in range(n)]
for i in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    observary[a].append(h[b])
    observary[b].append(h[a])
    
ans = 0
for i in range(n):
    if len(observary[i]) == 0:
        ans += 1
    elif max(observary[i]) < h[i]:
        ans += 1

print(ans)

Solution (Python):


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    

    
    

    n,m = map(int, input().split())
    h = list(map(int, input().split()))
    adj = [[] for _ in range(n)] 
    for _ in range(m):
        a,b = map(int, input().split())
        adj[a-1].append(b-1)
        adj[b-1].append(a-1)
    
    check = [-1]*n
    for i in range(n):
        if check[i] == 0:
            continue
        if len(adj[i]) == 0:
            check[i] = 1
        else:
            for j in adj[i]:
                if h[i] < h[j]:
                    check[i] = 0
                    break
                elif h[i] == h[j]:
                    check[i] = 0
                    check[j] = 0
                    break
                else:
                    check[j] = 0
            if check[i] == -1:
                check[i] = 1
    res = 0
    for i in check:
        if i == 1:
            res += 1
    print(res)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce



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

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

h_np = np.array(h)
max_np = np.zeros(n)

for i in range(m):
    a, b = map(int, input().split())
    max_np[a-1] = max(max_np[a-1], h[b-1])
    max_np[b-1] = max(max_np[b-1], h[a-1])
num_np = np.where(h_np > max_np, 1, 0)    
print(sum(num_np))

Solution (Python):

N, M = map( int, input().split() )
H = [0] + list(map(int, input().split()) )
X = [[] for x in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    X[A].append(H[B])
    X[B].append(H[A])
rt = 0
for i in range(1, N+1):
    if len(X[i]) == 0:
        rt += 1
    elif H[i] > max(X[i]):
        rt += 1
print(rt)

Solution (Python):
'''SDESTINY　　問題(特に定義)の細部に拘らないと解けない
良い展望台の定義は展望台 i から一本の道を使って辿り着ける
どの展望台よりも展望台 i の方が標高が高いことであって、
同じ高さの展望台に繋がっている展望台は、良い展望台にならない。
良い展望台は単独１位が必要で、同点１位の高さは良い展望台にならない。
入力例２を見ること。
N個の展望台の一つ一つずつと繋がっている展望台の番号(0-index)を
setに格納する配列を作る。
全体でN個、その中に繋がっている展望台の数だけ、要素がある。
要素はsetで持っていうる。
そのsetの中から要素を一つ一つ取り出す（（C)の部分）。
取り出した高さH[x]と、いま見ている展望台の高さH[i]を比べて、
H[i]<=H[x]なら、条件に合わない（等号がないと単独で１位を選べない。）
N 箇所の展望台があり展望台 i の標高が Hi、また展望台を結ぶ道が M 本あり、
道 j は展望台 Aj と Bj を結んでいる。展望台から伸びている道
を1つだけ通って行ける展望台のうち最も高い展望台を良い展望台と呼び、
それがいくつあるか求める。
（A)N 箇所の展望台 i に対応するように配列を作り、
各展望台から道が繋がっている展望台をsetで持つ。0-index
配列を順番に見ていき、見ている展望台とsetが持っている
展望台の高さを比較し、最も高ければ答えを1増やす。
'''
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [set() for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    AB[A-1].add(B-1)
    AB[B-1].add(A-1)

ans = 0
for i in range(N):
    res = True
    for x in AB[i]:
    


        if H[i]<=H[x]:
            
            res = False
            break
    if res:
        ans += 1
print(ans)

Solution (Python):
N,M=map(int, input().split())
H=list(map(int, input().split()))
V=[[] for _ in range(N)]
for m in range(M):
    a,b=map(int, input().split())
    a=a-1
    b=b-1
    V[a].append(b)
    V[b].append(a)
for v in V:
    v=set(v)
ans=[1]*N
tmp=0
for n in range(N):
    for v in V[n]:
        if H[n]<=H[v]:
            ans[n]=0
print(sum(ans))

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

for i in range(M):
    a, b = map(int, input().split())
    ma[a-1] = max(ma[a-1], H[b-1]) 
    ma[b-1] = max(ma[b-1], H[a-1])
ans = 0
for i in range(N):
    if ma[i] < H[i]:
        ans += 1
print(ans)

Solution (Python):
'''SDESTINY
N個の展望台の一つ一つずつと繋がっている展望台の番号(0-index)を
setに格納する配列を作る。
全体でN個、その中に繋がっている展望台の数だけ、要素がある。
要素はsetで持っていうる。
そのsetの中から要素を一つ一つ取り出す（（C)の部分）。
取り出した高さH[x]と、いま見ている展望台の高さH[i]を比べて、
H[i]<=H[x]なら、条件に合わない（等号は必要か？）
N 箇所の展望台があり展望台 i の標高が Hi、また展望台を結ぶ道が M 本あり、
道 j は展望台 Aj と Bj を結んでいる。展望台から伸びている道
を1つだけ通って行ける展望台のうち最も高い展望台を良い展望台と呼び、
それがいくつあるか求める。
（A)N 箇所の展望台 i に対応するように配列を作り、
各展望台から道が繋がっている展望台をsetで持つ。0-index
配列を順番に見ていき、見ている展望台とsetが持っている
展望台の高さを比較し、最も高ければ答えを1増やす。
'''
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [set() for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    AB[A-1].add(B-1)
    AB[B-1].add(A-1)

ans = 0
for i in range(N):
    res = True
    for x in AB[i]:
    


        if H[i]<=H[x]:
            
            res = False
            break
    if res:
        ans += 1
print(ans)

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

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

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

print(count)

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
l=list()
for i in range(M):
  A,B=map(int,input().split())
  if H[A-1]==H[B-1]:
    l.append(A)
    l.append(B)
  elif H[A-1]>H[B-1]:
    l.append(B)
  else:
    l.append(A)
  
minus=(len(set(l)))
print(N-minus)

Solution (Python):
N,M = map(int,input().split())
H = [int(i) for i in input().split()]
nlst = [1 for i in range(N)]
for i in range(M):
    a,b =map(int,input().split())
    c = min(H[a-1],H[b-1])
    if c == H[a-1]:
        nlst[a-1] = 0
    if c == H[b-1]:
        nlst[b-1] = 0
print(sum(nlst))

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 g[i] == []:
        ans += 1
        continue
    if max(g[i])<h[i]:
        ans += 1
print(ans)

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

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

res = 0
for i in range(n):
    flag = True
    for j in l[i]:
        if h[i] <= h[j]:
            flag = False
            break
    if flag:
        res += 1

print(res)

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

Solution (Python):

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

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


good = sum([H[i] > A[i] for i in range(N)])
print(good)

Solution (Python):
N, M = input().split()
view = [int(i) for i in input().split()]
remove = set()
for _ in range(int(M)):
  A, B = [int(i) for i in input().split()]
  if view[A-1] > view[B-1]:
    remove.add(B)
  elif view[A-1] < view[B-1]:
    remove.add(A)
  else:
    remove.add(A)
    remove.add(B)
print(int(N)-len(remove))

Solution (Python):


n, m = map(int, input().split())
h = list(map(int, input().split()))
assert len(h) == n


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

print(n - len(bad))

Solution (Python):
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
ifChecked = [0 for _ in range(N)]
path = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    
    path[A-1].append(B)
    path[B-1].append(A)

count = 0
for i in range(1, N+1):
    
    my_height = H[i-1]
    ifHighest = True
    if path[i-1] == []:
        count += 1
        continue
    for to in path[i-1]:
        if my_height <= H[to-1]:
            ifHighest = False
    if ifHighest:
        count += 1

print(count)

Solution (Python):

N_ko, M_hon = map(int, input().split())
Heights = list(map(int, input().split()))

indexs=[]

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

    h_a = Heights[a]
    h_b = Heights[b]


    if (h_a > h_b):
        indexs.append(b)

    elif (h_b > h_a):
        indexs.append(a)
    
    else:
        indexs.append(a)
        indexs.append(b)

ans = N_ko - len(set(indexs))

print(ans)

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

heigher = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    heigher[a - 1] = max(heigher[a - 1], height[b - 1])
    heigher[b - 1] = max(heigher[b - 1], height[a - 1])

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

print(count)

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

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

print(sum(record))

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

Solution (Python):
n, m = map(int, input().split())
H = list(map(int, input().split()))
chk = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]:
        chk[b] = False
    if H[b] >= H[a]:
        chk[a] = False
cnt = 0
for j in chk:
    if j == True:
        cnt += 1
print(cnt)

Solution (Python):
N,M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
counts = [1]*N

for i in AB:
  if H[i[0]-1] <= H[i[1]-1]:
    counts[i[0]-1] -= 1
  if H[i[0]-1] >= H[i[1]-1]:
    counts[i[1]-1] -= 1
print(counts.count(1))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int,input().split()))
A = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    A[a - 1] = max(A[a - 1], h[b - 1]) 
    A[b - 1] = max(A[b - 1], h[a - 1])
ans = 0
for i in range(n):
    if A[i] < h[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)]
counts = [1] * n
for i in ab:
    if h [i[0]-1] >= h[i[1]-1]:
        counts[i[1]-1] -= 1
    if h [i[0]-1] <= h[i[1]-1]:
        counts[i[0]-1] -= 1
print(counts.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)]
li=[1]*n
for i in ab:
  if h[i[0]-1]>=h[i[1]-1]:
    li[i[1]-1]-=1
  if h[i[0]-1]<=h[i[1]-1]:
    li[i[0]-1]-=1
print(li.count(1))

Solution (Python):
n,h,*t=[[*map(int,t.split())]for t in open(0)]
p=[1]*n[0]
for a,b in t:x,y=h[a-1],h[b-1];p[-a]&=x>y;p[-b]&=y>x
print(sum(p))

Solution (Python):
n,h,*t=[[0]+[*map(int,t.split())]for t in open(0)]
p=[1]*n[1]
for _,a,b in t:p[-a]&=h[a]>h[b];p[-b]&=h[b]>h[a]
print(sum(p))

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

h_max = [0 for _ in range(n)]
for a, b in ab:
    h_max[a-1] = max(h_max[a-1], h[b-1])
    h_max[b-1] = max(h_max[b-1], h[a-1])

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

Solution (Python):
(n,_),h,*t=[[*map(int,t.split())]for t in open(0)]
p=[1]*n
for a,b in t:x,y=h[a-1],h[b-1];p[-a]&=x>y;p[-b]&=y>x
print(sum(p))

Solution (Python):
n,*t=map(int,open(0).read().split())
p=[1]*n
for a,b in zip(*[iter(t[n+1:])]*2):p[-a]&=t[a]>t[b];p[-b]&=t[b]>t[a]
print(sum(p))

Solution (Python):
n,*t=map(int,open(0).read().split())
p=[1]*n
for a,b in zip(*[iter(t[n+1:])]*2):p[-a]&=t[a]>t[b];p[-b]&=t[b]>t[a]
print(sum(p))

Solution (Python):
n,*t=map(int,open(0).read().split())
r=[0]+[1]*n
for a,b in zip(t[n+1::2],t[n+2::2]):r[a]&=t[a]>t[b];r[b]&=t[b]>t[a]
print(sum(r))

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

def compare_height(adj, h, i):
    height = h[i - 1]
    if not adj[i]:
        return True
    for j in adj[i]:
        if h[j - 1] >= height:
            return False
    return True

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

for i in range(len(adj)):
    if i == 0:
        continue
    if compare_height(adj, h, i):
        count +=1
print(count)

Solution (Python):
n,m = map(int,input().split())
elevations = [ int(x) for x in input().split()]
adj_list = [ [] for x in range(n)]

for _ in range(m):
  a,b = [ int(x)-1 for x in input().split()]
  adj_list[a].append(b)
  adj_list[b].append(a)
    
count=0
for i,neighbours in enumerate(adj_list):
  for neighbour in neighbours:
    if(elevations[i]<=elevations[neighbour]):
      break
  else: 
    count+=1
      
print(count)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
g = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  g[a-1].append(b-1); g[b-1].append(a-1)

ans = 0
for i in range(N):
  neighbors = g[i]
  h = H[i]
  res = True
  for node in neighbors:
    res *= h > H[node]
  ans += res

print(ans)

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

h=list(map(int,input().split()))
l=[0]*n
for j in range(m):
    a,b=map(int,input().split())
    l[a-1]=max(l[a-1],h[b-1])
    l[b-1]=max(l[b-1],h[a-1])

ans=0
for i in range(n):
    if h[i]>l[i]:
        ans+=1

print(ans)

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

print(ans.count(True))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
g = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  g[a-1].append(b-1); g[b-1].append(a-1)

ans = 0
for i in range(N):
  neighbors = g[i]
  h = H[i]
  res = True
  for node in neighbors:
    res *= h > H[node]
  ans += res

print(ans)

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

a = [set() for _ in range(N)]

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

ans = 0

for i in range(N):
    flag = 0
    if a[i] == set():
        ans += 1
    else:
        for j in a[i]:
            if H[j-1] >= H[i]:
                flag = 1
                break

        if flag == 0:
            ans += 1

print(ans)

Solution (Python):

def main():
    N, M, *HAB = map(int, open(0).read().split())
    H, AB = [0] + HAB[:N], HAB[N:]
    is_good = [False] + [True] * N
    for a, b in zip(*[iter(AB)] * 2):
        if H[a] >= H[b]:
            is_good[b] = False
        if H[b] >= H[a]:
            is_good[a] = False
    print(sum(is_good))


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    N, M, *HAB = map(int, open(0).read().split())
    H, AB = [0] + HAB[:N], HAB[N:]
    good_observatories = set(range(1, N + 1))
    for a, b in zip(*[iter(AB)] * 2):
        if H[a] >= H[b]:
            good_observatories.discard(b)
        if H[b] >= H[a]:
            good_observatories.discard(a)
    print(len(good_observatories))


if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split()) 
HEIGHT = list(map(int, input().split()))
MA = []
for i in range(N):
    MA.append(0)
for i in range(M):
    hasi1, hasi2 = map(int, input().split())
    
    MA[hasi1-1] = max(MA[hasi1-1], HEIGHT[hasi2-1])
    MA[hasi2-1] = max(MA[hasi2-1], HEIGHT[hasi1-1])
    
    
result = 0
for i in range(N):
    if HEIGHT[i] > MA[i]:
        result += 1
print(result)

Solution (Python):
import sys
input = lambda:sys.stdin.readline().strip()
n,m = map(int,input().split())
h = list(map(int,input().split()))
adj = [set() for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a-=1;b-=1;
    adj[a].add(b)
    adj[b].add(a)
ans = 0
for i in range(n):
    val = h[i]
    ok = True
    for j in adj[i]:
        if h[j]>=val:
            ok = False
            break 
    if ok:
        ans+=1
print(ans)

Solution (Python):
import copy

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

ll=[0]*n

for j in l:
    if h[j[0]-1]>h[j[1]-1]:
        ll[j[1]-1]+=1
    elif h[j[0]-1]==h[j[1]-1]:
        ll[j[1]-1]+=1
        ll[j[0]-1]+=1
    else:
        ll[j[0]-1]+=1

ans=0
for k in ll:
    if k==0:
        ans+=1
print(ans)

Solution (Python):





if __name__ == '__main__':
    
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    
    ans = [1] * N
    for j in range(M):
        a, b = map(int,input().split())
        a -= 1
        b -= 1
        height_a = HEIGHT_LIST[a]
        height_b = HEIGHT_LIST[b]

        if height_a < height_b:
            ans[a] = 0
        elif height_a > height_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()))
ans = [1]*n
for  _ 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(sum(ans))

Solution (Python):





if __name__ == '__main__':
    
    
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    ROAD_LIST = []
    for j in range(M): 
        ROAD_LIST.append(
            tuple(map(int,input().split()))
        )
    
    
    ans = [1] * N
    for j in list(range(M)):
        point_a = ROAD_LIST[j][0]
        point_b = ROAD_LIST[j][1]

        point_a -= 1
        point_b -= 1

        height_a = HEIGHT_LIST[point_a]
        height_b = HEIGHT_LIST[point_b]

        if height_a < height_b:
            ans[point_a] = 0
        elif height_a > height_b:
            ans[point_b] = 0
        else:
            ans[point_a] = 0
            ans[point_b] = 0

    
    print(sum(ans))

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
Loser=[]
for i in range(M):
  A,B=map(int,input().split())
  Low = A if H[A-1]< H[B-1] else B
  if H[A-1] != H[B-1] and not(Low in Loser):
    Loser.append(Low)
  elif H[A-1] == H[B-1]:
    if not(A in Loser):
      Loser.append(A)
    if not(B in Loser):
      Loser.append(B)  
print(N-len(Loser))

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

d = dict()
for i in range(1,n+1):
    d[i] = h[i-1]
    

l_1 = []
l_2 = []
for j in range(1,m+1):
    x, y = map(int,input().split())
    if d[x] > d[y]:
        l_1.append(x)
        l_2.append(y)
        continue
    elif d[x]==d[y]:
        l_2.append(x)
        l_2.append(y)
        continue
    else:
        l_1.append(y)
        l_2.append(x)
        continue

l_1 = set(l_1)
l_2 = set(l_2)
l_3 = l_2.intersection(l_1)

print(len(l_1-l_3) + n - len(l_2|l_1))

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

Solution (Python):
import numpy as np
n,m=map(int,input().split())
hlist = list(map(int,input().split()))
ablist = []
for i in range(m):
    ablist.append(input().split())
x=np.zeros(n,int)
for ab in ablist:
  a=int(ab[0])
  b=int(ab[1])
  if hlist[a-1]<hlist[b-1]:
    x[a-1]=1
  elif hlist[a-1]>hlist[b-1]:
    x[b-1]=1
  elif hlist[a-1]==hlist[b-1]:
    x[a-1]=1
    x[b-1]=1
count=0
for l in range(n):
  if x[l]==0:
    count+=1
print(count)

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

for i in range(M):
    A, B = map(int, input().split())
    nei[A - 1].append(B - 1)
    nei[B - 1].append(A - 1)
    
for i in range(N):
    M = 0
    for j in range(len(nei[i])):
        if M < H[nei[i][j]]:
            M = H[nei[i][j]]
    if H[i] >M:
        ans += 1
print(ans)

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


hights = list(map(int, input().split()))
ans = [1]*N

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

print(sum(ans))

Solution (Python):
from dataclasses import dataclass 
from collections import  defaultdict
from pprint import  pprint

@dataclass
class mount:
    id: int
    height: int

if __name__ == "__main__":
    n,m = list( map( int, input().split(' ')) ) 
    ar = [0] + list(map(int, input().split(" ")))
    d =  defaultdict(lambda : [])
    for i in range(1,n+1):
        d[i] = []
    for i in range(m):
        f,to = list(map(int, input().split(' ')))
        d[f].append(ar[to])
        d[to].append(ar[f])
    count = 0
    for i in d:
        if all([ ar[i] > x for x in d[i]]):
            count +=1 
    print(count )

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

g = []
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] == H[b-1]:
        g += [a, b]
    if H[a-1] > H[b-1]:
        g += [b]
    else:
        g += [a]

g = set(g)
r = N - len(g)
print(r)

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

Solution (Python):
def make_heights_list(height):
    return [int(height), True]


tower_len, roads_len = map(int, input().split(' '))

heights = [[0, False]]
heights += (list(map(make_heights_list, input().split(' '))))




roads_highest = list()
for i in range(roads_len):
    start, end = map(int, input().split(' '))
    
    if heights[start][1] is True and heights[end][0] >= heights[start][0]:
        heights[start][1] = False
        
    if heights[end][1] is True and heights[start][0] >= heights[end][0]:
        heights[end][1] = False
        

good_towers_len = 0
for tower in heights:
    if tower[1]:
        good_towers_len += 1



print(good_towers_len)

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

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

    l[a-1] = max(l[a-1], h[b-1])
    l[b-1] = max(l[b-1], h[a-1])

result = 0

for j in range(n):
    if h[j] > l[j]:
        result += 1
print(result)

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

g = []
for i in range(l[1]):
    a, b = map(int, input().split())
    if li[a-1] == li[b-1]:
        g += [a, b]
    if li[a-1] > li[b-1]:
        g += [b]
    else:
        g += [a]

g = set(g)
r = l[0] - len(g)
print(r)

Solution (Python):
N,M =  map( int ,input().split())
H = list(map( int , input().split()))
A_B = [[0] * 2  for i in range(M)]
J = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B[i][0] = A
    A_B[i][1] = B
for j in range(M):
    if H[A_B[j][0]-1] > H[A_B[j][1]-1]:
        if J[A_B[j][0]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] =-1
    elif H[A_B[j][0]-1] < H[A_B[j][1]-1]:
        J[A_B[j][0]-1] =-1
        if J[A_B[j][1]-1] != -1:
            J[A_B[j][1]-1] = 1
    else:
        J[A_B[j][0]-1] =-1
        J[A_B[j][1]-1] =-1
for l in range(N):
    if J[l] == 0:
        J[l] = 1
print(J.count(1))

Solution (Python):
"""
他の隣接する最大値よりも、i番目の塔の方が高かったら良い展望台として認められる。
"""

n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [0] * n 

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


result = 0
for j in range(n):
    if h[j] > l[j]:
        result += 1
print(result)

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

graph = [[] for _ in range(N+1)]
for edge in edges:
    graph[edge[0]].append(edge[1])
    graph[edge[1]].append(edge[0])


ans = 0
for i in range(1,N+1):
    highest = True
    for j in graph[i]:
        if H[i-1] <= H[j-1]:
            highest = False
    if highest:
        ans += 1

print(ans)

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

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

for i in range(N):
    if michi[i] == hikui[i]:
        good += 1

print(good)

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

for _ in range(M):
    a, b =(int(x) for x in input().split())
    a-=1
    b-=1
    if height[a]<=height[b]:
        nlist[a]=0

    if height[b]<=height[a]:
        nlist[b]=0

print(sum(nlist))