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

mj = []

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

cnt_w = [0 for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(m):
    cnt[mj[i][0]-1] += 1
    cnt[mj[i][1]-1] += 1
    if h[mj[i][0]-1] > h[mj[i][1]-1]:
        cnt_w[mj[i][0]-1] += 1
    elif h[mj[i][0]-1] < h[mj[i][1]-1]:
        cnt_w[mj[i][1]-1] += 1

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

Solution (Python):








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









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

Solution (Python):
from heapq import heappush, heappop
def readinput():
    n,m=map(int,input().split())
    h=list(map(int,input().split()))
    nList=[]
    for i in range(n+1):
        nList.append([])
    for i in range(m):
        a,b=map(int,input().split())
        heappush(nList[a],-h[b-1])
        heappush(nList[b],-h[a-1])

    return n,m,h,nList

def main(n,m,h,nList):
    count=0
    for i in range(1,n+1):
        if len(nList[i])==0:
            count+=1
        else:
            hi=-heappop(nList[i])
            if h[i-1]>hi:
                count+=1
    return count

if __name__=='__main__':
    n,m,h,nList=readinput()
    ans=main(n,m,h,nList)
    print(ans)

Solution (Python):
word = list(map(int,input().split()))
hyoko = list(map(int,input().split()))
road = [0]*word[1]
for i in range(word[1]):
    road[i] = list(map(int,input().split()))
tenbo = [1]*word[0]

for j in range(word[1]):
    if hyoko[road[j][0]-1] > hyoko[road[j][1]-1]:
        tenbo[road[j][0]-1] *= 1
        tenbo[road[j][1]-1] = 0
    elif hyoko[road[j][0]-1] < hyoko[road[j][1]-1]:
        tenbo[road[j][0]-1] = 0
        tenbo[road[j][1]-1] *= 1
    else:
        tenbo[road[j][0]-1] = 0
        tenbo[road[j][1]-1] = 0
answer = word[0] - tenbo.count(0)
print(answer)

Solution (Python):
N,M=map(int,input().split())
H=[0]+list(map(int,input().split()))
check=[0]+[1]*N
for _ in range(M):
  a,b=map(int,input().split())
  if H[a]>=H[b]:
    check[b]=0
  if H[b]>=H[a]:
    check[a]=0
print(sum(check))

Solution (Python):
import sys
sys.setrecursionlimit(10**5 + 5)
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
Graph = [[] for _ in range(N+1)]
is_good = [False] + [True] * N
seen = [True] + [False] * N

def dfs(cur):
    global Graph, seen, H
    seen[cur] = True
    for nex in Graph[cur]:
        if H[nex] >= H[cur]:
            is_good[cur] = False
        if seen[nex]:
            continue
        dfs(nex)


for _ in range(M):
    a, b = map(int, input().split())
    Graph[a].append(b)
    Graph[b].append(a)

for i in range(1, N+1):
    if not seen[i]:
        dfs(i)

print(is_good.count(True))

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

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

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

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

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

count=0
c=[[] for i in range(n)]
for i in range(m):
  c[a[i]-1].append(b[i]-1)
  c[b[i]-1].append(a[i]-1)
  
for i in range(n):
  max_h=0
  for j in range(len(c[i])):
    max_h=max(max_h, h[c[i][j]])
  if max_h < h[i]:
    count+=1
print(count)

Solution (Python):
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
routes = [[] for _ in range(len(h) + 1)]
for _ in range(m):
    a, b = list(map(int, input().split()))
    routes[a].append(b)
    routes[b].append(a)
good = 0
for i in range(1, len(routes)):
    if len(routes[i]) == 0:
        good += 1
        continue
    if h[i - 1] > max([h[j - 1] for j in routes[i]]):
        good += 1
print(good)

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

"""
0: 初期値
1: highest
-1: not highest
"""
for i in range(m):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    if h[a] > h[b]:
        if res[a] == 0:
            res[a] = 1
        res[b] = -1
    elif h[a] < h[b]:
        res[a] = -1
        if res[b] == 0:
            res[b] = 1
    elif h[a] == h[b]:
        res[a] = -1
        res[b] = -1

print(res.count(1) + res.count(0))

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

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

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

ans = 0
for i in range(n):
    flg = True
    for j in d[i]:
        if h[i] <= h[j]:
            flg = False
            break
    if flg:
        ans += 1

print(ans)

Solution (Python):
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(ans)
    return ans


n,m = map(int, input().split())
hs = list(map(int, input().split()))
state = [1 for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    if(hs[a-1]>=hs[b-1]):
        state[b-1] =0
    if(hs[a-1]<= hs[b-1]):
        state[a-1]= 0
ans = 0
for i in range(n):
    if(state[i]==1):
        ans+=1
print(ans)

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

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())
	a , b = a - 1 , b - 1
	ma[a] = max(ma[a] , h[b])
	ma[b] = max(ma[b] , h[a])

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

print(ans)

Solution (Python):
n,m = map(int,input().split())
H = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(m)]
flag = [0]*n
for i in range(m):
  if H[a[i][0]-1] > H[a[i][1]-1]:
    flag[a[i][1]-1] = 2
  elif H[a[i][0]-1] == H[a[i][1]-1]:
    flag[a[i][0]-1] = 2
    flag[a[i][1]-1] = 2
  else:
    flag[a[i][0]-1] = 2
cnt = 0
for j in range(n):
  if flag[j] == 0:
    cnt += 1
print(cnt)

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


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

Solution (Python):
from operator import itemgetter
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []

for i in range(M):
    A0, B0 = map(int, input().split())
    A.append(A0)
    B.append(B0)

C = [[i] for i in range(N)]
HC = [[H[i]] for i in range(N)]
for i in range(M):
    C[A[i]-1].append(B[i]-1)
    C[B[i]-1].append(A[i]-1)
    HC[A[i]-1].append(H[B[i]-1])
    HC[B[i]-1].append(H[A[i]-1])
   
cnt = 0    
for i in range(N):
    C0 = []
    HC0 = []
    for cc,hcc in sorted(zip(C[i],HC[i]),key=itemgetter(1)):
       C0.append(cc)
       HC0.append(hcc)
    C[i] = C0
    HC[i] = HC0
    if C[i][-1] == i:
        cnt += 1
   
print(cnt)

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

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

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

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
to = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    to[a - 1] += [b - 1]
    to[b - 1] += [a - 1]
print(sum(to[j] == [] or h[j] > max(h[i] for i in to[j]) for j in range(n)))

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)]
hill = [i for i in range(1,n+1)]
for i in range(len(ab)):
    a,b = ab[i][0],ab[i][1]
    if h[a-1] > h[b-1]:
        hill[b-1] = 0
    elif h[a-1] < h[b-1]:
        hill[a-1] = 0
    elif h[a-1] == h[b-1]:
        hill[a-1] = 0
        hill[b-1] = 0

print(n-hill.count(0))

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)]
gp = []
hill = [i for i in range(1,n+1)]
for i in range(len(ab)):
    a,b = ab[i][0],ab[i][1]
    if h[a-1] > h[b-1]:
        hill[b-1] = 0
    elif h[a-1] < h[b-1]:
        hill[a-1] = 0
    elif h[a-1] == h[b-1]:
        hill[a-1] = 0
        hill[b-1] = 0

print(n-hill.count(0))

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

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

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

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

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[B-1]=0
  elif H[B-1]>H[A-1]:
    ans[A-1]=0
  elif H[A-1]==H[B-1]:
    ans[A-1]=0
    ans[B-1]=0
print(sum(ans))

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

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
 
roads = []
for i in range(n): roads.append([])
 
is_good_peak_arr = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    if h[a] >= h[b]: is_good_peak_arr[b] = False
    if h[b] >= h[a]: is_good_peak_arr[a] = False
 
print(is_good_peak_arr.count(True))

Solution (Python):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]
    ans = [1]*N
    for _ in range(M):
        a, b = (int(i)-1 for i in input().split())
        if H[a] < H[b]:
            ans[a] = 0
        elif H[b] < H[a]:
            ans[b] = 0
        else:
            ans[a] = 0
            ans[b] = 0

    print(sum(ans))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]
    G = [set() for _ in range(N)]
    for i in range(M):
        a, b = (int(i) for i in input().split())
        G[a-1].add(b-1)
        G[b-1].add(a-1)
    ans = 0
    for a in range(N):
        if all(H[b] < H[a] for b in G[a]):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
h.insert(0,0)
good = [0] + [1] * n
for i in range(m):
    x,y = map(int,input().split())
    if h[x] > h[y]:
        good[y] = 0
    elif h[x] < h[y]:
        good[x] = 0
    else:
        good[x] = 0
        good[y] = 0

print(sum(good))

Solution (Python):
n,m = map(int,input().split())
graph = [[] for _ in range(n)]
h = list(map(int,input().split()))
for _ in range(m):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
cnt = 0
for i in range(n):
    if graph[i] == []:
        cnt += 1
        continue
    if max([h[j] for j in graph[i]]) < h[i] : cnt += 1
print(cnt)

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

for _ in range(m):
    a, b = map(lambda x : int(x) - 1, input().split())
    if h_list[a] <= h_list[b]:
        min_list[a] = 0
    if h_list[b] <= h_list[a]:
        min_list[b] = 0

print(sum(min_list))

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

towers = {}
for n in range(N):
    towers[n] = []

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

    towers[a].append(b)
    towers[b].append(a)

result = 0
for tower_number, related_towers in towers.items():
    if len(related_towers) == 0:
        result += 1
        continue

    tower_height = H[tower_number]
    other_heights = [H[i] for i in related_towers]
    if tower_height > max(other_heights):
        result += 1

print(result)

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])
res=sum([H[i]>A[i] for i in range(N)])
print(res)

Solution (Python):
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())
  a -= 1
  b -= 1
  if h[a] >= h[b]:
    ans[b] = 0
  if h[b] >= h[a]:
    ans[a] = 0
    
print (sum(ans))

Solution (Python):
n, m = map(int, input().split())
height = [int(i) for i in input().split()]
neighbors = {}
for _ in range(m):
  a, b = map(int, input().split())
  if a not in neighbors:
    neighbors.update({a:set()})
  if b not in neighbors[a]:
    neighbors[a].add(b)
  if b not in neighbors:
    neighbors.update({b:set()})
  if a not in neighbors[b]:
    neighbors[b].add(a)


count = 0
visited = set()
for std, s in neighbors.items():
  flag = True
  visited.add(std)
  height_std = height[std - 1]
  for each in s:
    h = height[each - 1]
    if height_std <= h:
      flag = False
      break
  if flag:
    count += 1

for i in range(n):
  if i + 1 not in visited:
    count += 1
print(count)

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

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

    if h[a-1] > h[b-1]:
        l[b-1]=1

    if h[a-1] < h[b-1]:
        l[a-1]=1

    if h[a-1] == h[b-1]:
        l[a-1]=1
        l[b-1]=1

print(n-l.count(1))

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

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

l = [1]*n

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

print(sum(l))

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


def main():
  N, M = list(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(b-1)
    G[b-1].append(a-1)

  cnt = 0
  for i in range(N):
    for j in G[i]:
      if H[i] <= H[j]:
        break
    else:
      cnt += 1

  print(cnt)


if(__name__ == '__main__'):
  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())
  x=H[A-1]
  y=H[B-1]
  if x>y:
    ans[B-1]=0
  elif x==y:
    ans[B-1]=0
    ans[A-1]=0
  elif y>x:
    ans[A-1]=0   
print(sum(ans))

Solution (Python):
number=list(map(int,input().split()))
n,m=number[0],number[1]
height=list(map(int,input().split()))
load=[[] for i in range(n+1)]
for i in range(m):
    tmp=list(map(int,input().split()))
    if tmp[1] not in load[tmp[0]]:
        load[tmp[0]].append(tmp[1])
    if tmp[0] not in load[tmp[1]]:
        load[tmp[1]].append(tmp[0])


answer=0

for i in range(1,n+1):
    if load[i]==[]:
        answer+=1
    while load[i] != []:
        if height[i-1]<=height[load[i][-1]-1]:
            break
        load[i].pop()
        if load[i] == []:
            answer+=1
        
print(answer)

Solution (Python):
number=list(map(int,input().split()))
n,m=number[0],number[1]
height=list(map(int,input().split()))
load=[[] for i in range(n+1)]
for i in range(m):
    tmp=list(map(int,input().split()))
    if tmp[1] not in load[tmp[0]]:
        load[tmp[0]].append(tmp[1])
    if tmp[0] not in load[tmp[1]]:
        load[tmp[1]].append(tmp[0])

box=[]
answer=0
for i in range(1,n+1):
    box=[]
    if len(load[i])==0:
        answer+=1
    for j in range(len(load[i])):
        box.append(height[load[i][j]-1])
    if box!=[]:
        if max(box)<height[i-1]:
            answer+=1
print(answer)

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

print(sum(ans))

Solution (Python):
n, m = map(int, input().split())
ht = list(map(int, input().split()))
rd = [list(map(int, input().split())) for _ in range(m)]
flg = [1] * n
for i in rd:
    if ht[i[0]-1] <= ht[i[1]-1]:
        flg[i[0]-1] = 0
    if ht[i[0]-1] >= ht[i[1]-1]:
        flg[i[1]-1] = 0
print(sum(flg))

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

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

print(sum(l))

Solution (Python):
def peak():
    
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    A = list()
    B = list()
    for _ in range(M):
        dummy = list(map(int, input().split()))
        A.append(dummy[0])
        B.append(dummy[1])
    
    ovservatory_max_height = [0] * N
    for i in range(M):
        if H[B[i] - 1] > ovservatory_max_height[A[i] - 1]:
            ovservatory_max_height[A[i] - 1] = H[B[i] - 1]
        if H[A[i] - 1] > ovservatory_max_height[B[i] - 1]:
            ovservatory_max_height[B[i] - 1] = H[A[i] - 1]
    
    is_good_list = list()
    for i in range(N):
        if H[i] > ovservatory_max_height[i] or ovservatory_max_height == 0:
            is_good_list.append(True)
        else:
            is_good_list.append(False)
    
    return is_good_list.count(True)    

result = peak()
print(result)

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

A, B = [], []
for t in tmp:
    A.append(t[0])
    B.append(t[1])

is_good_arr = [True] * N

for i in range(M):
    if H[A[i]-1] > H[B[i]-1]:
        is_good_arr[B[i] - 1] = False
    elif H[A[i]-1] < H[B[i]-1]:
        is_good_arr[A[i] - 1] = False 
    else:
        is_good_arr[A[i]-1], is_good_arr[B[i]-1] = False, False

print(is_good_arr.count(True))

Solution (Python):
if __name__ == "__main__":
    N,M = map(int,input().split())
    H = list(map(int,input().split()))
    is_good_arr = [True for i in range(N)]
    for i in range(M):
        A,B = map(lambda i: int(i)-1,input().split())
        if H[A] > H[B]:
            is_good_arr[B] = False
        elif H[B] > H[A]:
            is_good_arr[A] = False
        else:
            is_good_arr[A],is_good_arr[B] = False,False
    print(sum(is_good_arr))

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 = [set() for i in range(N)]
for a, b in AB:
    a, b = a-1, b-1
    g[a].add(b)
    g[b].add(a)

c = 0
for i in range(N):
    if all(H[c]<H[i] for c in g[i]):
        c += 1

print(c)

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

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

Solution (Python):
def main():

    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    connected = dict()
    for _ in range(M):
        A, B = map(int, input().split())
        if A not in connected:
            connected[A] = H[B-1]
        else:
            connected[A] = max(connected[A], H[B-1])
        if B not in connected:
            connected[B] = H[A-1]
        else:
            connected[B] = max(connected[B], H[A-1])

    ans = 0
    for i in range(1, N+1):
        if i not in connected:
            ans += 1
        elif H[i-1] > connected[i]:
            ans += 1
    return ans

if __name__ == '__main__':
    print(main())

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

ok = [True]*n

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

    if h[a[i]-1] <= h[b[i]-1]:
        ok[a[i]-1] = False
    if h[b[i]-1] <= h[a[i]-1]:
        ok[b[i]-1] = False

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

print(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())
    A -= 1
    B -= 1
    ma[A] = max(ma[A], H[B])
    ma[B] = max(ma[B], H[A])

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

print(ans)

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
ab = [map(int, input().split()) for _ in range(M)]
a, b = [list(i) for i  in zip(*ab)]

t = [1]*(N)

for i in range(M):
    if H[a[i]-1] > H[b[i]-1] :
        t[b[i]-1] = 0
    elif H[a[i]-1] < H[b[i]-1]:
        t[a[i]-1] = 0
    else:
        t[a[i]-1]=0
        t[b[i]-1]=0

ans = 0
for i in t:
    if i == 1:
        ans += 1

print(ans)

Solution (Python):
from sys import stdin
import sys, math

n,m = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

c = [1 for x in range(n)]
for i in range(m):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]

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

print(sum(c))

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

for _ in range(M):
    A, B = map(int, input().split(' '))
    Ah, Bh = H[A - 1], H[B - 1]

    if Ah >= Bh:
        table[B - 1] = 0
    if Ah <= Bh:
        table[A - 1] = 0

ans = table.count(1)

print(ans)

Solution (Python):


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

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


ans = 0
for i in range(n):
    tmp = high[i]
    flg = True
    for nxt in graph[i]:
        if high[nxt] >= tmp:
            flg = False
            break
    if flg:
        ans += 1

print(ans)

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

ans = 0
for i in range(1, n + 1):
    high = True
    for t in eg[i]:
        if h[t] >= h[i]:
            high = False
            break
    if high:
        ans += 1
print(ans)

Solution (Python):
N,M = map(int,input().split())
Hls = list(map(int,input().split()))
lst = [[] for i in range(10**5)]
for i in range(M):
    A,B = map(int,input().split())
    lst[A-1].append(Hls[B-1])
    lst[B-1].append(Hls[A-1])
k = 0
for i in range(N):
    if bool(lst[i]):
        if Hls[i] > max(lst[i]):
            k += 1
    else:
        k += 1

print(k)

Solution (Python):
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    to = [0]*n
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        to[a] = max(to[a], h[b])
        to[b] = max(to[b], h[a])
    ans = 0
    for hi, ti in zip(h, to):
        if hi > ti:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
import math

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

AB = [map(int, input().split()) for _ in range(M)]
A , B = [list(i) for i in zip(*AB)]

G = [1] * N 

for i in range (M):
    if H[ A[i] -1 ] > H[B[i] -1 ]:
        G[ B[i] -1 ] = 0
    elif H[ A[i] -1] == H[ B[i] -1 ]:
        G[ A[i] -1 ] = 0
        G[ B[i] -1 ] = 0
    else:
        G[A[i] -1 ] = 0

print( G.count(1) )

Solution (Python):
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()


N, M = inpl()
H = inpl()
dp = [True] * N
for _ in range(M):
    A, B = inpl()
    if H[A-1] > H[B-1]:
        dp[B-1] = False
    elif H[A-1] < H[B-1]:
        dp[A-1] = False
    else:
        dp[A-1] = False
        dp[B-1] = False
ans = 0
for i in dp:
    if i:
        ans += 1
print(ans)


ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Solution (Python):
N, M = map(int,input().split())
H = list(map(int,input().split()))
MAX = [0 for _ in range(N)]
for _ in range(M):
    a, b = map(int,input().split())
    MAX[a-1] = max(MAX[a-1],H[b-1])
    MAX[b-1] = max(MAX[b-1],H[a-1])

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

print(ans)

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

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

  if h[a-1]<h[b-1]:
    nl[a-1]=0
  elif h[a-1]>h[b-1]:
    nl[b-1]=0
  else:
    nl[a-1]=0
    nl[b-1]=0
    
print(sum(nl))

Solution (Python):
N, M = (int(x) for x in input().split())
H=list(map(int, input().split()))
check=[True]*N
ans=N
for i in range(M):
  A, B = (int(x) for x in input().split())
  if check[A-1]==True and H[A-1]<H[B-1]:
    check[A-1]=False
    ans-=1
  elif check[B-1]==True and H[A-1]>H[B-1]:
    check[B-1]=False
    ans-=1
  elif H[A-1]==H[B-1]:
    if check[A-1]==True:
      ans-=1
      check[A-1]=False
    if check[B-1]==True:
      ans-=1
      check[B-1]=False
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[b-1]=0
    elif H[a-1]==H[b-1]:
        x[a-1]=0
        x[b-1]=0
    else:
        x[a-1]=0

print(sum(x))

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

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

ans = 0
for i in range(1, n + 1):
    high = True
    for to in eg[i]:
        if h[i - 1] <= h[to - 1]:
            high = False
    if high:
        ans += 1
print(ans)

Solution (Python):
from sys import stdin

input = stdin.readline

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

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

ans = 0
for i in range(n):
    high = True
    for to in eg[i]:
        if h[i] <= h[to]:
            high = False
    if high:
        ans += 1
print(ans)

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

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

ans = 0
for i in range(n):
    high = True
    for to in eg[i]:
        if h[i] <= h[to]:
            high = False
    if high:
        ans += 1
print(ans)