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())
hlist = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

maxh = [0]*n
for a, b in ab:
  maxh[a-1] = max(maxh[a-1], hlist[b-1])
  maxh[b-1] = max(maxh[b-1], hlist[a-1])
ans = 0
for i in range(n):
  if maxh[i] < hlist[i]:
    ans += 1
print(ans)

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

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

isGood = [True] * n

for i in range(m):
    a, b = map(int, input().split())
    if heights[a-1] > heights[b-1] :
        isGood[b-1] = False
    elif heights[b-1] > heights[a-1] :  
        isGood[a-1] = False
    else :  
        isGood[a-1] = False
        isGood[b-1] = False
    
print (isGood.count(True))

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

Solution (Python):
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))

def main(n,m,h,l):
    res = []
    g = {i:[] for i in range(1,n+1)}
    for a,b in l:
        g[a].append(b)
        g[b].append(a)
    for i in range(1,n+1):
        if len(g[i]) == 0:
            res.append(i)
            continue
        maxheight = 0
        for p in g[i]:
            maxheight = max(maxheight, h[p-1])
        if h[i-1] > maxheight:
            res.append(i)
    return len(res)

n,m = mi()
h = mi()
l = mix(m)
print(main(n,m,h,l))

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

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

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

A = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    if L[a - 1] == L[b - 1]:
        A[b - 1] = 1
        A[a - 1] = 1
    elif L[a-1] > L[b-1]:
        A[b - 1] = 1
    else:
        A[a - 1] = 1
print(A.count(0))

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
GoodViewpoint=[1]*N
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        GoodViewpoint[b-1]=0
    elif H[a-1]<H[b-1]:
        GoodViewpoint[a-1]=0
    else:
        GoodViewpoint[a-1]=0
        GoodViewpoint[b-1]=0
        pass
print(GoodViewpoint.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[a-1] = 0
    if h[b-1] <= h[a-1]:
        ans[b-1] = 0
print(sum(ans))

Solution (Python):
import sys

def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    not_good = set()
    for i in range(M):
        if H[A[i] - 1] < H[B[i] - 1]:
            not_good.add(A[i])
        elif H[B[i] - 1] < H[A[i] - 1]:
            not_good.add(B[i])
        else:
            not_good.add(A[i])
            not_good.add(B[i])
    good = set(range(1, N + 1)) - not_good
    print(len(good))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    H = [int(next(tokens)) for _ in range(N)]  
    A = [int()] * (M)  
    B = [int()] * (M)  
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, H, A, B)


if __name__ == "__main__":
    main()

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

d = [True for i in range(n)] 

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

print(d.count(True))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
cnt = 0
l = [0]*N
B = [0]*N
AB = list()
for m in range(M):
    P = list(map(int, input().split()))
    AB.append(P)
for m in range(M):
    B[AB[m][0]-1] += 1
    B[AB[m][1]-1] += 1
    if H[AB[m][0]-1] < H[AB[m][1]-1]:
        l[AB[m][0]-1] += 1
    elif H[AB[m][0]-1] > H[AB[m][1]-1]:
        l[AB[m][1]-1] += 1
    elif H[AB[m][0]-1] == H[AB[m][1]-1]:
        l[AB[m][0]-1] += 1
        l[AB[m][1]-1] += 1
for i in l:
    if i == 0:
        cnt += 1
print(cnt)

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

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

tmp = [1] * n

ab = [map(int, input().split()) for _ in range(m)]
a, b = [list(i) for i in zip(*ab)]

for i in range(m):
    if h[a[i] - 1] > h[b[i] - 1]:
        tmp[b[i] - 1] = 0
    elif h[a[i] - 1] < h[b[i] - 1]:
        tmp[a[i] - 1] = 0
    else:
        tmp[a[i] - 1] = 0
        tmp[b[i] - 1] = 0

print(sum(tmp))

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

Solution (Python):
from collections import defaultdict

def main():
    N,M = [int(x) for x in input().split()]
    Hl = [int(x) for x in input().split()]
    Al,Bl = [],[]
    for i in range(M):
        A,B = [int(x) for x in input().split()]
        Al.append(A)
        Bl.append(B)

    is_peek = [1]*N
    m = defaultdict(list)
    for A,B in zip(Al,Bl):
        if Hl[A-1] > Hl[B-1]:
            is_peek[B-1] = 0
        elif Hl[A-1] == Hl[B-1]:
            is_peek[A-1] = 0
            is_peek[B-1] = 0
        else:
            is_peek[A-1] = 0
    print(sum(is_peek))
        

if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
h = [int(x) for x in input().split()]
a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
ind = []
for i in range(m):
    if h[a[i]-1] < h[b[i]-1]:
        ind.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        ind.append(a[i])
        ind.append(b[i])
    else:
        ind.append(b[i])
ind2 = [0] * n
for i in range(len(ind)):
    ind2[ind[i]-1] += 1
ans = 0
for i in range(n):
    if ind2[i] == 0:
        ans += 1
print(ans)

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

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

for i in range(M):
    A,B = map(int,input().split())
    ma = H[A-1]
    mb = H[B-1]
    if (ma > mb):
        L[B-1] = 0
    elif (ma == mb):
        L[B-1] = 0
        L[A-1] = 0
    else:
        L[A-1] = 0
print(sum(L))

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

for i in range(M):
    l.append(list(map(int,input().split())))
    
ll=[0]*N

for j in l:
    if H[j[0]-1]-H[j[1]-1]>0:
        ll[j[1]-1]+=1
    elif H[j[0]-1]-H[j[1]-1]<0:    
        ll[j[0]-1]+=1
    else:
        ll[j[0]-1]+=1
        ll[j[1]-1]+=1
ans=0
for x in ll:
    if x==0:
        ans+=1

print(ans)

Solution (Python):
import numpy as np
 
n,m = input().split(" ")
n = int(n)
m = int(m)
 
H = input().split(" ")
H = np.array([int(h) for h in H])
Hs = np.zeros(n)

for i in range(m):
    a, b = input().split(" ")
    a = int(a) - 1
    b = int(b) - 1
    Hs[a] = np.max([Hs[a], H[b]])
    Hs[b] = np.max([Hs[b], H[a]])
 
G = []
for i in range(n):
    if Hs[i] < H[i]:
        G += [i]
 
print(len(G))

Solution (Python):
N,M = (int(x) for x in input().split())
hight = [int(x) for x in input().split()]
tenbou = [input().split() for l in range(M)]
result = [1] * N


for i in range(M):
    x = int(tenbou[i][0]) - 1
    y = int(tenbou[i][1]) - 1
    if hight[x] > hight[y]:
        result[y] = 0
    elif hight[y] == hight[x]:
        result[x] = 0
        result[y] = 0
    elif hight[y] > hight[x]:
        result[x] = 0

print(result.count(1))

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

from collections import defaultdict

ds = defaultdict(set)

for a, b in AB:
    ds[a - 1].add(b - 1)
    ds[b - 1].add(a - 1)

result = 0

for i in range(N):
    
    if not ds[i] or all(H[d] < H[i] for d in ds[i]):
        result += 1

print(result)

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

tmp = [1] * N

AB = [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]      
    
for i in range(M):
  if H[A[i]-1] > H[B[i]-1]:
    tmp[B[i]-1] = 0
  elif H[A[i]-1] < H[B[i]-1]:
    tmp[A[i]-1] = 0
  else:
    tmp[A[i]-1] = 0
    tmp[B[i]-1] = 0

print(sum(tmp))

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

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

Solution (Python):
import numpy as np

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

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

ans_list = []
for i in range(n):
  tmp = []
  if list[i][1] == []:
    tmp.append(1)
  else:
    tmp = []
    for j in range(len(list[i][1])):
      if h[list[i][0]] > h[list[i][1][j]]:
        tmp.append(1)
      else:
        tmp.append(0)
  ans_list.append(tmp)

print(str(sum([np.prod(ans_list[i]) for i in range(len(ans_list))])))

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

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

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

check = [True] * n 
for i in range(m):
    
    a,b = (map(int,input().split()))
    if h[a-1] > h[b-1]:
        check[b-1] = False
    elif h[a-1] < h[b-1]:
       
        check[a-1] = False
    else:
        check[a-1] = False
        check[b-1] = False
print(sum(check))

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

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

def main():
    N,M = map(int,input().split())
    H_list = list(map(int,input().split()))
    ab_list = [list(map(int,input().split())) for _ in range(M)]

    ab_dict = {i: [] for i in range(N)}
    for a,b in ab_list:
        a,b = a-1,b-1
        ab_dict[a].append(b)
        ab_dict[b].append(a)

    ans = 0
    for k,v_list in ab_dict.items():
        for v in v_list:
            if H_list[v] >= H_list[k]:
                break
        else:ans += 1
    print(ans)

main()

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

def main():
    N,M = map(int,input().split())
    H_list = list(map(int,input().split()))
    ab_list = [list(map(int,input().split())) for _ in range(M)]

    ab_dict = {i: [] for i in range(N)}
    for a,b in ab_list:
        a,b = a-1,b-1
        ab_dict[a].append(b)
        ab_dict[b].append(a)

    c = collections.Counter(H_list)

    
    
    ans = 0
    for k,v_list in ab_dict.items():
        for v in v_list:
            if H_list[v] >= H_list[k]:
                break
        else:ans += 1
    print(ans)

main()

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n,m = map(int, input().split())
    ma = [0]*n
    hl = list(map(int, input().split()))
    for i in range(m):
        a,b = map(int, input().split())
        ma[a-1] = max(ma[a-1], hl[b-1])
        ma[b-1] = max(ma[b-1], hl[a-1])
    for i in range(n):
        if hl[i] > ma[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):



n,m = map(int,input().split())
li = []
temp = input().split()
for i in range(n):
    temp1 = [int(temp[i]), True]
    li.append(temp1)
    
for i in range(m):
    a,b = map(int,input().split())
    
    if li[a-1][0] < li[b-1][0]:
        li[a-1][1] = False
    elif li[a-1][0] > li[b-1][0]:
        li[b-1][1] = False
    else :
        li[a-1][1] = li[b-1][1] = False
cnt = 0
for elem in li:
    if elem[1] == True:
        cnt += 1
print(cnt)

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

n,m = map(int,input().split())
H = [0]+ list(map(int,input().split()))
List = [list(map(int, input().split())) for i in range(m)]
A =[0]*(n+1)


for a,b in List:
  for _ in range(2):
    A[a] = max(A[a], H[b])
    a, b = b, a

print(sum(x > y for x, y in zip(H, A)))

Solution (Python):
N, M = [int(x) for x in input().split()]
H=[0]
H += [int(x) for x in input().split()]

X=[0]
for i in range(M):
    X += [[int(x) for x in input().split()]]

ma = [0] * (N+1)

for i in range(1,M+1):
    ma[X[i][0]] = max(ma[X[i][0]], H[X[i][1]])
    ma[X[i][1]] = max(ma[X[i][1]], H[X[i][0]])

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

print(ans)

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

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

ans = [True]*N

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

print(sum(ans))

Solution (Python):
co = list(map(int,input().split()))
N = co[0]
M = co[1]
h = list(map(int,input().split()))
tenbo = [0 for i in range(N)]
for i in range(M):
    load = list(map(int,input().split()))
    if h[load[0]-1] >= h[load[1]-1]:
        tenbo[load[1]-1] +=1
    if  h[load[0]-1] <= h[load[1]-1]:
        tenbo[load[0]-1] +=1
    
        
        
ans =0
for i in range(N):
    if tenbo[i] == 0:
        ans +=1
print(ans)

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

cnt = 0
for i in range(n):
    flag = True
    path_i = path[i]
    for x in path_i:
        if H[i] <= H[x]:
            flag = False
    if flag:
        cnt += 1

print(cnt)

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

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

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

for i in input().split():
    H.append(int(i))

for j 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

good = L.count(0)
print(good)

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

Solution (Python):
import sys
def main():
    
    N,M = map(int, input().split())
    
    H = list(map(int, input().split()))
    
    obsstat = [0]*N 
    for _ in range(M):
        a1,a2 = map(int, input().split())
        if H[a1-1]==H[a2-1]:
            obsstat[a1-1] = 1
            obsstat[a2-1] = 1
        elif H[a1-1]<H[a2-1]:
            obsstat[a1-1] = 1
        else:
            obsstat[a2-1] = 1
    print(obsstat.count(0))

main()

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

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

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

ans = 0

for i in range(n):
    judge = 0
    for to in links[i]:
        if h[i] <= h[to]:
            judge += 1
    if not judge:
        ans += 1
print(ans)

Solution (Python):
N,M = map(int,input().split())
H = [int(i) for i in input().split()]
AB = []
for m in range(M):
    AB.append([int(i) for i in input().split()])
from collections import defaultdict as ddict
R = ddict(list)
for ab in AB:
    R[ab[0]].append(ab[1])
    R[ab[1]].append(ab[0])
ans = 0
for n in range(1,N+1):
    highest = True
    for r in R[n]:
        if H[n-1] <= H[r-1]:
            highest = False
            break
    if highest:
        ans += 1
print(ans)

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

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

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

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

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

for i in range(m):
    ab = list(map(int,input().split(" ")))
    a,b = ab
    
    if h[a-1] >= h[b-1]:
        lowerlist[b-1] = 0
    if h[b-1] >= h[a-1]:
        lowerlist[a-1] = 0

print(sum(lowerlist))

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

neighbor_max_heights = [0] * N

for i in range(M):
    a, b = AB[i]
    neighbor_max_heights[b-1] = max(neighbor_max_heights[b-1], H[a-1])
    neighbor_max_heights[a-1] = max(neighbor_max_heights[a-1], H[b-1])

ans = 0
for j in range(N):
    if H[j-1] > neighbor_max_heights[j-1]:
        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)]

import sys
sys.setrecursionlimit(10**9)
Edge = [[] for _ in range(N)]
for a,b in AB:
    Edge[a-1].append(b-1)
    Edge[b-1].append(a-1)

visited = [False]*N
isPeak = [False]*N

def dfs(v):
    p = H[v]
    m = 0
    for nv in Edge[v]:
        m = max(m, H[nv])
        if visited[nv]:
            continue
        visited[nv] = True
        dfs(nv)
    if p>m:
        isPeak[v] = True

for i in range(N):
    if not visited[i]:
        visited[i] = True
        dfs(i)
ans = 0
for v in isPeak:
    if v:
        ans += 1
print(ans)

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

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

print(T.count(0))

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

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


def get_index(s):
	return int(s) - 1
	

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

for i in range(m):
	a, b = map(get_index, input().split())
	
	rivals[a] = max(rivals[a], h[b])
	rivals[b] = max(rivals[b], h[a])

ans = 0

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

print(ans)

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

print(ans.count(0))

Solution (Python):
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([True]*n)
cnt = np.array([False]*n)

for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] < h[b-1]:
        high[a-1] = False
    
    elif h[a-1] > h[b-1]:
        high[b-1] = False
    
    else:
        high[a-1] = False
        high[b-1] = False

ans = np.count_nonzero(high==True)

print(ans)

Solution (Python):
import numpy as np

n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

high = np.array([1]*n)
cnt = np.array([0]*n)

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

ans = np.count_nonzero(high==1)

print(ans)

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

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

Solution (Python):
n,m=[int(_) for _ in input().split()]
H=[int(_) for _ in input().split()]
Hlist=[set() for a in range(n)]
count=0
for a in range(m):
    a,b=[int(_) for _ in input().split()]
    Hlist[a-1].add(b-1)
    Hlist[b-1].add(a-1)
for i,j in enumerate(Hlist):
    flag=1
    for a in j:
        if H[a]>=H[i]:
            flag=0
    if flag==1:
        count+=1
    flag=1
print(count)

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

HH = [True]*N

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

print(HH.count(True))

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

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

Solution (Python):
import math

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

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

result = {}
for i in range(n):
    result[i] = True

for i in range(m):
    a, b = map(int, input().split())
    if h_list[a-1] >=  h_list[b-1]:
        result[b-1] = False
    if h_list[a-1] <=  h_list[b-1]:
        result[a-1] = False

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

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
  if H[A - 1] >= H[B - 1]:
    ans[B - 1] = 0


print(sum(ans))

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

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


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

cnt = 0

for node in range(n):
    good = True 
    for neighbor in edge[node]:
        if h[node] <= h[neighbor]:
            good = False
            
    if good:
        cnt += 1

print(cnt)

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

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


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

cnt = 0

for node in range(n):
    good = True 
    for neighbor in edge[node]:
        if h[node] <= h[neighbor]:
            good = False
            
    if good:
        cnt += 1

print(cnt)

Solution (Python):



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

    AB = [list(map(lambda x: x - 1, ab)) for ab in AB]

    ma = [0] * N
    for key, ab in enumerate(AB):
        a = ab[0]
        b = ab[1]
        ma[a] = max(ma[a], H[b])
        ma[b] = max(ma[b], H[a])
    ans = 0
    for h, ma_ in zip(H, ma):
        if h > ma_:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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

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


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

cnt = 0

for node in range(n):
    good = True 
    for neighbor in edge[node]:
        if h[node] <= h[neighbor]:
            good = False
            break;
    if good:
        cnt += 1

print(cnt)

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

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


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

cnt = 0

for node in range(n):
    good = True 
    for neighbor in edge[node]:
        if h[node] <= h[neighbor]:
            good = False
    
    if good:
        cnt += 1

print(cnt)

Solution (Python):
n,m = map(int,input().split())
li = list(map(int,input().split()))
road = []
while True:
    try:
        road.append(list(map(int,input().split())))
 
    except:
        break;
        
 


x = [0]*n
for i in range(m):
    if li[road[i][1]-1]>=x[road[i][0]-1]:
        x[road[i][0]-1]=li[road[i][1]-1]
    if li[road[i][0]-1]>=x[road[i][1]-1]:
        x[road[i][1]-1]=li[road[i][0]-1]
    
cnt = 0    
for i in range(n):
    if li[i]>x[i]:
        cnt += 1


print(cnt)

Solution (Python):
def C():
    n,m = list(map(int, input().split()))
    h = list(map(int, input().split()))
    path = [list(map(int, input().split())) for _ in range(m)]
    small = []
    for a, b in path:
        if h[a-1] > h[b-1]:
            small.append(b)
        elif h[a-1] < h[b-1]:
            small.append(a)
        else:
            small += [a,b]
    print(len(set(range(1,n+1)) - set(small)))

C()