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()))
c=0
d=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    d[a-1]=max(d[a-1],h[b-1])
    d[b-1]=max(d[b-1],h[a-1])
for i in range(n):
    if h[i]>d[i]:
        c+=1
print(c)

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

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

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

Solution (Python):
n,m=map(int,input().split())
l=list(map(int,input().split()))
ans=[1]*n
for i in range(m):
    a,b=map(int,input().split())
    if l[a-1]<l[b-1]:
        ans[a-1]=0
    elif l[a-1]>l[b-1]:
        ans[b-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()))
array = [0] * N
ans = 0

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

for j in range(N):
    if array[j] < H[j]:
      ans += 1

print(ans)

Solution (Python):

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

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
H.insert(0, 0)
t = [True] * (N+1)

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

c = 0
for i in range(1, N+1, 1):
    if t[i]:
        c += 1

print(c)

Solution (Python):
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

n, m = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()]for j in range(m)]    

tmp = [True for i in range(n + 1)]
res = 0

for i in range(m):
    a, b = A[i]
    if H[a - 1] <= H[b - 1]:
        tmp[a] = False
    if H[a - 1] >= H[b - 1]:
        tmp[b] = False
for i in range(1, n + 1):
    if tmp[i]:
        res += 1

print(res)

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

t=['W']*n

for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]>=h[b-1]:
        t[b-1]='L'
    if h[a-1]<=h[b-1]:
        t[a-1]='L'
print(t.count('W'))

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

t=['W']*n

for i in range(m):
    a,b=list(map(int,input().split()))
    if h[a-1]>=h[b-1]:
        t[b-1]='L'
    if h[a-1]<=h[b-1]:
        t[a-1]='L'
print(t.count('W'))

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

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

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

cnt = [0] * n

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


    
res = sum([h[i] > cnt[i] for i in range(n)])


print(res)

Solution (Python):
from collections import defaultdict

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

edge = defaultdict(list)

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

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

print(ans)

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
road=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    road[a-1].append(b)
    road[b-1].append(a)
c=0
for i in range(N):
    T=True
    for j in road[i]:
        if H[i]<=H[j-1]:
            T=False
    if T:
        c+=1
print(c)

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

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

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj_max = [0]*N
ans = 0
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  adj_max[tmp1-1] = max(adj_max[tmp1-1], H[tmp2-1])
  adj_max[tmp2-1] = max(adj_max[tmp2-1], H[tmp1-1])
for num in range(N):
  if H[num] > adj_max[num]:
    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)]

place = [True]*n

for i in range(m):
    a,b = ab[i][0],ab[i][1]
    if h[a-1] < h[b-1]:
        place[a-1] = False
    elif h[a-1] == h[b-1]:
        place[a-1] = False
        place[b-1] = False
    else:
        place[b-1] = False

print(place.count(True))

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

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

count = []
for i in range(N):
    count.append(1)

for i in range(M):
    if H[miti[i][0]-1] < H[miti[i][1]-1]:
        count[miti[i][0]-1]=0

    if H[miti[i][0]-1] > H[miti[i][1]-1]:
        count[miti[i][1]-1]=0

    if H[miti[i][0]-1] == H[miti[i][1]-1]:
        count[miti[i][0]-1]=0
        count[miti[i][1]-1]=0

ans = 0
for i in range(N):
    ans += count[i]

print(ans)

Solution (Python):
def main() -> None:
    n, m = map(int, input().split())
    heights = tuple(map(int, input().split()))

    good = [1] * n
    for _ in range(m):
        a, b = map(int, input().split())
        height_a, height_b = heights[a-1], heights[b-1]
        if height_a == height_b:
            good[a-1], good[b-1] = 0, 0
        elif height_a < height_b:
            good[a-1] = 0
        else:
            good[b-1] = 0
    print(good.count(1))
    return


if __name__ == '__main__':
    main()

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

for i in range(m):
    ab.append([int(s) for s in input().split()])

h2 = []
for p in ab:
    if h[p[0] - 1] <= h[p[1] - 1]:
        h2.append(p[0] - 1)
    if h[p[0] - 1] >= h[p[1] - 1]:
        h2.append(p[1] - 1)

print(len(h) - len(list(set(h2))))

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

h = [0] * (N + 1)
for i in range(M):
    h[AB[i][0]] = max(h[AB[i][0]], H[AB[i][1]])
    h[AB[i][1]] = max(h[AB[i][1]], H[AB[i][0]])

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

print(ans)

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

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

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

Solution (Python):
if __name__ == '__main__':

    
    n,m = map(int,input().split())
    H = [int(h) for h in 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)

    
    good = 0
    for i,g in enumerate(graph):
        moto = H[i]
        flg = True
        for sk in g:
            saki = H[sk]
            if moto <= saki:
                flg = False
                break
        if flg:
            good += 1
    print(good)

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

count = 0
for a in range(N):
  for b in paths[a]:
    if H[b] >= H[a]:
      break
  else:
    count += 1
print(count)

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

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

Solution (Python):
def main():
    import collections
    n, m = map(int, input().split())
    hs = list(map(int, input().split()))
    nmap = [0] * n
    cnt = 0

    for j in range(m):
        v = input().split()
        v0 = int(v[0]) - 1
        v1 = int(v[1]) - 1
        if hs[v0] < hs[v1]:
            nmap[v0] += 1
        elif hs[v0] == hs[v1]:
            nmap[v0] += 1
            nmap[v1] += 1
        else:
            nmap[v1] += 1
    for i in nmap:
        if i == 0:
            cnt += 1
    return cnt


if __name__ == '__main__':
    print(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] *= 1 
    ans[b-1] *= 0
  elif H[a-1]<H[b-1]:
    ans[a-1] *= 0
    ans[b-1] *= 1
  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()))
g = [1]*n

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

Solution (Python):
N,M = map(int,input().split())
Hs = list(map(int,input().split()))
array = [[] for i in range(N)]
array2 = list(range(1,N+1))
for i in range(M):
    a,b = map(int,input().split())
    array[a-1].append(b)
    array[b-1].append(a)
z = list(zip(Hs,array,array2))
z.sort(reverse = True)
a, b, c = zip(*z)
Hs2 = list(a)
array = list(b)
array2 = list(c)
visited = [0]*N
ans = 0
for i in range(N):
    valid = True
    x = array2[i]
    for j in range(len(array[i])):
        visited[array[i][j]-1] = 1
        if Hs[array[i][j]-1] == Hs[x-1]:
            valid = False
    if visited[x-1] == 0 and valid:
        ans += 1

print(ans)

Solution (Python):
N, M = list(map(int, input().split()))
height_list = list(map(int, input().split()))
road_list_1 = [list(map(int, input().split())) for i in range(M)]
road_list = [[road_list_1[j][i] - 1 for i in range(2)] for j in range(M)]
observation_deck = list(range(N))

for i in range(M):
    if height_list[road_list[i][0]] >= height_list[road_list[i][1]]:
        observation_deck[road_list[i][1]] = -1
    if height_list[road_list[i][0]] <= height_list[road_list[i][1]]:
        observation_deck[road_list[i][0]] = -1

answer = 0

for i in range(N):
    if observation_deck[i] != -1:
        answer += 1

print(answer)

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

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

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

count = 0
for i in range(n):
    hanamaru = True
    for j in neighbors[i]:
        if heights[i] > heights[j]:
            continue
        else:
            hanamaru = False
            break
    if hanamaru is True:
        count += 1

print(count)

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

ans = 0
for i in range(1, n + 1):
    for j in g[i]:
        if arr[j] >= arr[i]:
            break
    else:
        ans += 1

print(ans)

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

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

A=[True]*N

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

	if H[a-1]>H[b-1]:
		A[b-1]=False
	elif H[a-1]==H[b-1]:
		A[a-1]=False
		A[b-1]=False
	elif H[a-1]<H[b-1]:
		A[a-1]=False

print(sum(A))

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

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

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

for i in range(1,n+1):
  if t[i] == 0:
    ans +=1
print(ans)

Solution (Python):
import math , sys

N , M = list(map(int, input().split()))
H = list(map(int, input().split()))
Es = [[] for _ in range(N)]
for i in range(M):
    A , B = list(map(int, input().split()))
    A -=1 ; B-=1
    Es[A].append(B)
    Es[B].append(A)
ans = 0
for i in range(N):
    Es[i] = list(set(Es[i]))
for i in range(N):
    if len(Es[i]) == 0:
        ans+=1
    else:
        Max = max( [ H[Es[i][j]] for j in range( len(Es[i]) ) ] )
        if H[i] > Max:
            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)]
ans = [1]*n
for i in range(m):
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        ans[ab[i][0]-1] = 0
        ans[ab[i][1]-1] = 0
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        ans[ab[i][1]-1] = 0
    else:
        ans[ab[i][0]-1] = 0
print(sum(ans))

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

tmp = [1]*N

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

    if H[a-1] > H[b-1]:
        tmp[b-1] = 0
    elif H[a-1] < H[b-1]:
        tmp[a-1] = 0
    else:
        tmp[a-1] = 0
        tmp[b-1] = 0

print(sum(tmp))

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*M;B=[0]*M
C=[0]*N
for i in range(M):
  A[i],B[i]=map(int,input().split())

for i in range(M):
  if H[A[i]-1]<H[B[i]-1]:C[A[i]-1]+=1
  elif H[A[i]-1]>H[B[i]-1]:C[B[i]-1]+=1
  else:C[A[i]-1]+=1;C[B[i]-1]+=1
print(C.count(0))

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

Solution (Python):
import bisect

class Peaks:
    def __init__(self, N, H, next_obs_heights):
        self.N = N
        self.H = H
        self.next_obs_heights = next_obs_heights

    def solve(self):
        result = 0

        for i in range(N):
            if len(next_obs_heights[i]) == 0:
                result += 1
                continue

            next_num = len(next_obs_heights[i])
            if self.H[i] > next_obs_heights[i][next_num-1]:
                result += 1

        print(result)

N, M = map(int, input().split())
H = list(map(int, input().split()))
next_obs_heights = [ [] for i in range(N) ]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    bisect.insort(next_obs_heights[a], H[b])
    bisect.insort(next_obs_heights[b], H[a])

peaks = Peaks(N, H, next_obs_heights)
peaks.solve()

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

Solution (Python):
import sys

input=sys.stdin.buffer.readline





def RD(): return sys.stdin.read()


def II(): return int(input())


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


def MF(): return map(float,input().split())


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


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))



import numpy as np

def main():
	n,m=MI()
	H=LI()
	G=[[] for _ in range(n+1)]
	for _ in range(m):
		a,b=MI()
		G[a].append(H[b-1])
		G[b].append(H[a-1])
	
	
	ans=0
	for i in range(1,n+1):
		if G[i]==[]:
			ans+=1
		elif H[i-1]>max(G[i]):
			ans+=1
	print(ans)
	









if __name__=="__main__":
	main()

Solution (Python):
from collections import deque
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-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
ans=0
for j in range(n):
    for i in g[j]:
        if h[j]<=h[i]:
            break
    else:
        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)]
good = [True]*N
for i in range(M):
        a,b = AB[i]
        if H[a-1] > H[b-1]:
            good[b-1] = False
        elif H[a - 1] < H[b - 1]:
            good[a - 1] = False
        else:
            good[a - 1] = False
            good[b - 1] = False

print(good.count(True))

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

ans = 0
for i in range(N):
    flg = True
    for j in g[i]:
        flg = flg & (H[i] > H[j])
    ans += flg
print(ans)

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

for i in range(M):
  A, B = list(map(int, input().split()))
  if list_h[B-1] < list_h[A-1]:
    table[B-1] = 0
  elif list_h[A-1] < list_h[B-1]:
    table[A-1] = 0
  else:
    table[A-1] = 0
    table[B-1] = 0

print(str(sum(table)))

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

g = [[] for _ in range(N+1)]
for i in range(M):
  a, b = map(int, input().split())
  g[a].append(b)
  g[b].append(a)

ans = 0
for j in range(1, N+1):
  for k in g[j]:
    if H[j] <= H[k]:
      break
  else:
    ans += 1
print(ans)

Solution (Python):

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

a = []

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


loser = []

for y in a:
    high1 = high[y[0]-1]
    high2 = high[y[1]-1]
    if high1 > high2:
        loser.append(y[1])
    elif high1 ==  high2:
        loser.append(y[0])
        loser.append(y[1])
    else:
        loser.append(y[0])

new_loser = list(set(loser))
print(n-len(new_loser))

Solution (Python):

n, m = map(int, input().split())
l = list(map(int, input().split()))
cor = [[] for i in range(n)]

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

ans = 0
for i in range(n):
    max_h = l[i]
    cnt = 1
    co = list(set(cor[i]))
    for j in range(len(co)):
        if l[co[j]] >= max_h:
            cnt = 0
            break
    ans += cnt

print(ans)

Solution (Python):


N, M = list(map(int, input().split()))
h_list = list(map(int, input().split()))
h_dict = {i + 1: h for i, h in enumerate(h_list)}
h_set = set(h_dict.keys())
no_list = []

for _ in range(M):
    a, b = list(map(int, input().split()))
    if h_dict[a] == h_dict[b]:
        no_list.append(a)
        no_list.append(b)
    elif h_dict[a] > h_dict[b]:
        no_list.append(b)
    else:
        no_list.append(a)

no_set = set(no_list)
ans = len(h_set - no_set)

print(ans)

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

for _ in range(m):
    a, b = map(int, input().split())
    mawari[a] = max(mawari[a], height[b])
    mawari[b] = max(mawari[b], height[a])
    

for i in range(1,n+1):
    if height[i]> mawari[i]:
        ans += 1
print(ans)

Solution (Python):
[N, M] = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
dic = {}
for i in range(M):
    [a, b] = [int(i) for i in input().split()]
    if a in dic:
        dic[a].append(b)
    else:
        dic[a] = [b]
    if b in dic:
        dic[b].append(a)
    else:
        dic[b] = [a]

ans = 0
for i in range(1, N+1):
    s = H[i-1]
    t = 0
    if i in dic:
        for j in range(len(dic[i])):
            if s <= H[dic[i][j]-1]:
                t += 1
                break
        if t == 0:
            ans += 1
    else:
        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)]
Max = []
for i in range(n):
    Max.append(0)

ans = 0
for i in range(m):
    Max[a[i]-1] = max(Max[a[i]-1],h[b[i]-1])
    Max[b[i]-1] = max(Max[b[i]-1],h[a[i]-1])

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()))
l = list({i} for i in range(n+1))
for i in range(m):
    a,b = map(int,input().split())
    l[a].add(b)
    l[b].add(a)
    
for i in range(len(l)):
    l[i] = list(l[i])
good = set()
for i in range(1,len(l)):
    l[i].remove(i)
    for j in range(len(l[i])):
        if h[l[i][j]-1] >= h[i-1]:
            break
    else:
        good.add(i)
print(len(good))

Solution (Python):
n,m = list(map(int, input().split()))
h = list(map(int, input().split()))
hoge = [[] for _ in range(n)]
for i in range(m):
  a,b = list(map(int, input().split()))
  hoge[a - 1].append(b - 1)
  hoge[b - 1].append(a - 1)
  
cnt = 0
for i in range(n):
  if hoge[i]:
    flag = True
    for j in hoge[i]:
      if h[i] <= h[j]:
        flag = False
    if flag:
      cnt += 1
  else:
    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)]
answer = [1]*N

for i in range(M):
	if H[AB[i][0]-1] > H[AB[i][1]-1]:
		answer[AB[i][1]-1] = 0
	elif H[AB[i][0]-1] == H[AB[i][1]-1]:
		answer[AB[i][1]-1] = 0
		answer[AB[i][0]-1] = 0
	else:
		answer[AB[i][0]-1] = 0

print(sum(answer))

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

def main():
    N, M = map(int, input().split())
    H = [None]
    H.extend(list(map(int, input().split())))
    bad = set([])
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A] > H[B]:
            bad.add(B)
        elif H[A] < H[B]:
            bad.add(A)
        else:
            bad.add(A)
            bad.add(B)
    print(N - len(bad))


if __name__ == '__main__':
    main()

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

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

ans = 0
for i in range(n):
    x = lst2[i][0]
    lst2[i].sort()
    lst2[i].reverse()
    if (len(lst2[i]) == 1):
        ans = ans + 1
    elif (x == lst2[i][0]):
        lst2[i].pop(0)
        y = lst2[i][0]
        if (x != y):
            ans = ans + 1

print(ans)

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

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

print (sum(anslist))

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



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



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

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

edges = defaultdict(list)

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

ans = 0
for i in range(N):
    ok = True
    for adj in edges[i]:
        if H[adj] >= H[i]:
            ok = False
            break
    if ok:
        ans += 1
print(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]:
    l[a-1]=0
    l[b-1]=0
  if h[a-1]>h[b-1]:
    l[b-1]=0
  if  h[a-1]<h[b-1]:
    l[a-1]=0
print(l.count(1))

Solution (Python):


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

peak = [1]*n
for i in range(m):
    if h[ab[i][0]-1] >= h[ab[i][1]-1]:
        peak[ab[i][1]-1] = 0
    if h[ab[i][0]-1] <= h[ab[i][1]-1]:
        peak[ab[i][0]-1] = 0
print(sum(peak))

Solution (Python):
n, m = map(int,input().split())
H = list(map(int,input().split()))
AB = []
ans = 0
for i in range(m):
    AB.append(list(map(int,input().split())))
    AB[-1][0] -= 1
    AB[-1][1] -= 1
ok = [1]*n
for i in range(m):
    if H[AB[i][0]] >= H[AB[i][1]]:
        ok[AB[i][1]] = 0
    if H[AB[i][0]] <= H[AB[i][1]]:
        ok[AB[i][0]] = 0
for i in ok:
    if i:
        ans += 1
print(ans)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [True 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]) :
        A[a] = False
    if(H[b] <= H[a]) :
        A[b] = False

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

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 for i in range(n)]
for _ in range(m):
    a, b =map(int, input().split())
    if D[a] > D[b]:
        L[b-1] = 0
    elif D[a] == D[b]:
        L[a-1] = 0
        L[b-1] = 0
    else:
        L[a-1] = 0
ans = 0
for e in L:
    ans += e
print(ans)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
ways = [list(map(int, input().split())) for i in range(M)]
observatoryList = [1] * N
for i in range(M):
  if H[ways[i][0] - 1] <= H[ways[i][1] - 1]:
    observatoryList[ways[i][0] - 1] = 0
  if H[ways[i][0] - 1] >= H[ways[i][1] - 1]:
    observatoryList[ways[i][1] - 1] = 0
goodObservatoryCount = observatoryList.count(1)
print(goodObservatoryCount)

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

print(sum(peaks))

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

Solution (Python):
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]

n,m = inL()
h = inL()
ab = inNL(m)

l = [1]*n
for a,b in ab:
    if h[a-1]>h[b-1]:
        l[b-1] = 0
    elif h[a-1]==h[b-1]:
        l[a-1]=l[b-1]=0
    else:
        l[a-1] = 0

print(l.count(1))

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

print(c)