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()))
A,B=[],[]
good = N
for m in range(M):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
roots = [[] for i in range(N)]
for m in range(M):
    roots[A[m]-1].append(B[m]-1)
    roots[B[m]-1].append(A[m]-1)

for n in range(N):
    L = len(roots[n])
    for l in range(L):
        if H[n] <= H[roots[n][l]]:
            good -=1
            break
    else:
        continue
print(good)

Solution (Python):
import sys
n, m = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
li2 = ['a']*n
for _ in range(m):
  i, k = map(int, sys.stdin.readline().split())
  k -= 1
  i -= 1
  if li[k] - li[i] > 0:
    li2[i] = 'F'
    if li2[k] == 'a':
      li2[k] = 'T'
  elif li[k] == li[i]:
    li2[i] = 'F'
    li2[k] = 'F'
  else:
    li2[k] = 'F'
    if li2[i] == 'a':
      li2[i] = 'T'
print(n-li2.count('F'))

Solution (Python):
import numpy as np

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

ok=np.ones(N)
for i in range(M):
    if H[A[i][0]-1]>H[A[i][1]-1]:
        ok[A[i][1]-1]=0
    elif H[A[i][0]-1]==H[A[i][1]-1]:
        ok[A[i][0]-1]=0
        ok[A[i][1]-1]=0
    else:
        ok[A[i][0]-1]=0
print(int(np.sum(ok)))

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

bads = set([])
for _ in range(m):
    (s, d) = list(map(int, input().split()))
    if hights[s-1] < hights[d-1]:
        bads.add(s)
    elif hights[s-1] > hights[d-1]:
        bads.add(d)
    elif hights[s-1] == hights[d-1]:
        bads.add(s)
        bads.add(d)
print(len(hights) - len(bads))

Solution (Python):
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce

MOD = 10**9 + 7
INF = float('inf')

ans = 0

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

T = [[] for i in range(N)]

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

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

for i in range(N):
    if len(T[i]) == 0:
        ans += 1
    else:
        if H[i] > max(list(map(lambda x: H[x], T[i]))):
            ans += 1

print(ans)

Solution (Python):
n, m = map(int, input().split(" "))
number = [[] for _ in range(n)]
height = list(map(int, input().split(" ")))
result = 0
for i in range(0, m):
    a, b = map(int, input().split(" "))
    number[b - 1].append(a - 1)
    number[a - 1].append(b - 1)
for i in range(0, n):
    if (len(number[i]) == 0):
        result += 1
    else:
        sig = 1
        for k in number[i]:
            if (height[i] <= height[k]):
                sig = 0
                break
        if sig == 1:
            result+=1
print(result)

Solution (Python):
import numpy as np
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
F=[0]*len(H)
for i in range(M):
  A,B=list(map(int,input().split()))
  if(H[A-1]<H[B-1]):
    F[A-1]=1
  elif(H[A-1]>H[B-1]):
    F[B-1]=1
  else:
    F[B-1]=1
    F[A-1]=1
print(F.count(0))

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

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




if __name__=="__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
street=[]
for i in range(m):
    street.append(list(map(int,input().split())))
not_taller=[]
for i in range(m):
    if h[street[i][0]-1]==h[street[i][1]-1]:
        not_taller.append(street[i][0])
        not_taller.append(street[i][1])
    elif h[street[i][0]-1]>h[street[i][1]-1]:
        not_taller.append(street[i][1])
    else:
        not_taller.append(street[i][0])
print(n-len(set(not_taller)))

Solution (Python):
ma = lambda :map(int,input().split())
ni = lambda:int(input())

n,m = ma()
H = list(ma())
Hm = [True]*n
ab = []
tr = [[] for i in range(n)]
for i in range(m):
    a,b = ma()
    tr[a-1].append(b-1)
    tr[b-1].append(a-1)
    if H[a-1] > H[b-1]:
        Hm[b-1] = False
    elif H[a-1] < H[b-1]:
        Hm[a-1] =False
    else:
        Hm[b-1] = False
        Hm[a-1] = False
ans = 0
for f in Hm:
    if f:ans+=1
print(ans)

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
br = {num+1:[] for num in range(N)}
for i in range(M):
    a,b = map(int,input().split())
    br[a].append(b)
    br[b].append(a)
cnt = 0
for i in range(N):
    height = []
    if len(br[i+1])==0:
        cnt+=1
        continue
    for j in br[i+1]:
        height.append(H[j-1])
    if H[i]>max(height):
        cnt+=1
print(cnt)

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

competitor_H = {}

for m in range(M):
    A, B = map(int, input().split())
    
    if A-1 not in competitor_H.keys():
        competitor_H[A-1] = []
    competitor_H[A-1].append(H[B-1])
    
    if B-1 not in competitor_H.keys():
        competitor_H[B-1] = []
    competitor_H[B-1].append(H[A-1])

countGood = 0
for i in range(N):
    if i not in competitor_H.keys():
        countGood += 1
    elif H[i] > max(competitor_H[i]):
        countGood += 1
print(countGood)

Solution (Python):
n,m = map(int,input().split())
ans = [1]*n
h = input().split()
h_int = [int(s) for s in h]
cou = 0
 
for i in range(m):
  x,y = map(int,input().split())
  if h_int[x-1] >= h_int[y-1]:
    ans[y-1] = 0
  if h_int[y-1] >= h_int[x-1]:
    ans[x-1] = 0
 
for i in range(n):
  if ans[i] == 1:
    cou += 1
print(cou)

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

Solution (Python):

n, m = map(int, input().split())
h = list(map(int, input().split()))
not_good = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] > h[b - 1]:  
        not_good.append(b)
    elif h[a - 1] == h[b - 1]:
        not_good.append(a)
        not_good.append(b)
    else:
        not_good.append(a)
ans = 0
not_good = list(set(not_good))
not_good.sort()

idx = 0
for i in range(1, n + 1):
    if i < not_good[idx]:
        ans += 1
        
    elif i == not_good[idx]:
        idx += 1
        if idx == len(not_good):
            ans += n - i
            break
    else:
        pass
print(ans)

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
road=[]
for i in range(m):
    road.append(list(map(int,input().split())))
tall=[1 for _ in range(n)]
for i in range(m):
    if h[road[i][0]-1]>h[road[i][1]-1]:
        tall[road[i][1]-1]=0
    elif h[road[i][0]-1]==h[road[i][1]-1]:
        tall[road[i][1]-1]=0
        tall[road[i][0]-1]=0
    else:
        tall[road[i][0]-1]=0
counter=0
for i in range(n):
    if tall[i] == 1:
        counter+=1
print(counter)

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)]
ans = [1] * n
for i in range(m):
    if (h[a[i] - 1] == h[b[i] - 1]):
        ans[a[i] - 1] = 0
        ans[b[i] - 1] = 0
    elif (h[a[i] - 1] > h[b[i] - 1]):
        ans[b[i] - 1] = 0
    else:
        ans[a[i] - 1] = 0

result = sum(i == 1 for i in ans)
print(result)

Solution (Python):
def main():
    n,m = (int(x) for x in input().split())
    h = [int(x) for x in input().split()]
    r = [[h[i]] for i in range(n)]
    for i in range(m):
        a,b = (int(x)-1 for x in input().split())
        r[a].append(h[b])
        r[b].append(h[a])

    cnt = 0
    for i in range(n):
        if max(r[i]) == h[i] and r[i].count(h[i]) == 1:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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

t = [0]*m
for j in range(m):
    t[j] = tuple(map(int, input().split()))

count = 0

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

for i in range(n):
    if hc[i] == 0:
        continue
    else:
        count += 1

print(count)

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


print(n-len(b))

Solution (Python):
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
h = list(map(int, input().split()))
observatories = [[] for i in range(n)]
ans = 0
for i in range(m):
  ab = list(map(int, input().split()))
  a = ab[0] - 1
  b = ab[1] - 1
  observatories[a].append(b)
  observatories[b].append(a)
for j in range(len(observatories)):
  ans = ans + 1
  h_j = h[j]
  for k in observatories[j]:
    if h[k] >= h_j:
      ans = ans - 1
      break
print(ans)

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

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


for i in range(N):
    if B[i] == 0:
        count = 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[A-1]+=1
 if H[B-1]<=H[A-1]:
  L[B-1]+=1
b=0
for i in L:
 if i==0:
  b+=1
print(b)

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

A = []
B = []

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

x = 0
bad = []

while x < M:
    if H[A[x]-1] > H[B[x]-1]:
        bad.append(B[x])
    elif H[A[x]-1] < H[B[x]-1]:
        bad.append(A[x])
    else:
        bad.append(A[x])
        bad.append(B[x])

    x += 1


print(N-len(set(bad)))

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)]
tf = [3 for _ in range(n)]
for i in ab:
    if h[i[0] - 1] > h[i[-1] - 1]:
        if tf[i[0] - 1] == 3:
            tf[i[0] - 1] = True
            tf[i[-1] - 1] = False
        else:
            tf[i[-1] - 1] = False
    elif h[i[0] - 1] < h[i[-1] - 1]:
        if tf[i[-1] - 1] == 3:
            tf[i[-1] - 1] = True
            tf[i[0] - 1] = False
        else:
            tf[i[0] - 1] = False
    elif h[i[0] - 1] == h[i[-1] - 1]:
        tf[i[0] - 1] = False
        tf[i[-1] - 1] = False
cnt = 0
for j in tf:
    if j == True:
        cnt += 1
    elif j == 3:
        cnt += 1
print(cnt)

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

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[a-1]+=1
    elif H[b-1]<H[a-1]:
        c[b-1]+=1
    else:
        c[b-1]+=1
        c[a-1]+=1
x=0
for y in c:
    if y==0:
        x+=1

print(x)

Solution (Python):


import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n, m = map(int, sys.stdin.readline().split())
	h = list(map(int, sys.stdin.readline().split()))
	graph = [[] for i in range(n)]
	for i in range(m):
		ai, bi = map(int, sys.stdin.readline().split())
		graph[ai-1].append(bi-1)
		graph[bi-1].append(ai-1)
	log.print(graph)
	cnt = 0
	for i in range(n):
		good = True
		for j in range(len(graph[i])):
			log.print(i, graph[i][j])
			if h[i] <= h[graph[i][j]]:
				good = False
		if good:
			cnt += 1
	print(cnt)

	


main()

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

Solution (Python):
from collections import Counter
n,m = map(int,input().split())
h = list(map(int,input().split()))
judge = [0]*n
t = [0]*n
for _ in range(m):
    a,b = map(int,input().split())
    t[a-1] = max(t[a-1],max(h[a-1],h[b-1]))
    t[b-1] = max(t[b-1],max(h[a-1],h[b-1]))
    if h[a-1] == h[b-1]:
        judge[a-1] = 1
        judge[b-1] = 1

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

Solution (Python):
N, M = map(int, input().split())
high = list(map(int, input().split()))
route = []
ans = 0
for i in range(N + 1):
  ls = set()
  route.append(ls)

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

for i, v in enumerate(route):
  if i == 0:
    continue
  kijun = high[i - 1]
  if v == set():
    ans += 1
    continue
  else:
    flag = True
    for j in v:
      tmp = high[j - 1]
      if tmp >= kijun:
        flag = False
    if flag:
      ans += 1

print(ans)

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

H = list(map(int,input().split()))
T = [True]*n
A=[0]*m
B=[0]*m
for i in range(m):
    A[i],B[i] = map(int,input().split())

box=[[0] for _ in range(n)]
for i in range(m):
    if H[A[i] -1] - H[B[i] -1] < 0:
        box[A[i] -1].append(1)
        box[B[i] -1].append(0)
        
    elif H[A[i] -1] - H[B[i] -1]==0:
        box[A[i] -1].append(1)
        box[B[i] -1].append(1)
        
    elif H[A[i] -1] - H[B[i] -1] > 0:
        box[A[i] -1].append(0)
        box[B[i] -1].append(1)
        
for i in range(n):
    if sum(box[i])==0:
        T[i] =True
    else:
        T[i] = False

print(T.count(True))

Solution (Python):

def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    
    ans = []
    ansn = 0
    for _ in range(N):
        ans.append(0)
    for i in range(M):
        A,B = map(int, input().split())
        if H[A-1] < H[B-1]:
            ans[A-1] = -1
        elif H[A-1] > H[B-1]:
            ans[B-1] = -1
        else:
            ans[B-1] = -1
            ans[A-1] = -1
    for j in ans:
        if j == 0:
            ansn += 1
    
    print(ansn)

if __name__ == '__main__':
    main()

Solution (Python):
[n, m] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
st = [set([]) for _ in range(n)]
for i in range(m):
    [a, b] = [int(i) for i in input().split()]
    st[a-1].add(b-1)
    st[b-1].add(a-1)
cnt = 0
for i, height in enumerate(h):
    line = []
    for huga in st[i]:
        line.append(h[huga])
    if len(line) == 0 or height > max(line):
        cnt += 1
print(cnt)

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

R=[1]*n

for i in range(m):
	a,b=map(int,input().split())
	p=H[a-1]
	q=H[b-1]
	if p==q:
		R[a-1]=0
		R[b-1]=0
	elif p>q:
		R[b-1]=0
	else:
		R[a-1]=0

print(sum(R))

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


N, M = list(map(int, stdin.readline().rstrip().split()))
H = list(map(int, stdin.readline().rstrip().split()))

A = []
for i in range(M):
    
    A.append(list(map(int, stdin.readline().rstrip().split())))




m = {}

for tmp in A:
    
    a, b = tmp
    
    if H[a - 1] > H[b - 1]:
        m[b] = 0
    elif H[a - 1] < H[b - 1]:
        m[a] = 0
    else:
        m[a] = 0
        m[b] = 0

count = 0
for j in range(1, N+1):
    if m.get(j, 1) == 1:
        count += 1

print(count)

Solution (Python):




Onum, Rnum = map(int, input().split())
H = list(map(int, input().split()))
R = []
good = Onum      
bad = [0] * Onum    


def mark(idx):
    global good
    if bad[idx] == 0:
        good -= 1
    bad[idx] += 1


for i in range(Rnum):
    R = list(map(int, input().split()))
    if H[R[0] - 1] == H[R[1] - 1]:
        mark(R[0] - 1)
        mark(R[1] - 1)
    elif H[R[0] - 1] > H[R[1] - 1]:
        mark(R[1] - 1)
    elif H[R[0] - 1] < H[R[1] - 1]:
        mark(R[0] - 1)

print(good)

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

s = set()

for i in range(m):
    arr = arrs[i]
    if l[arr[0]-1] < l[arr[1]-1]:
        s.add(arr[0])
    elif l[arr[0]-1] == l[arr[1]-1]:
        s.add(arr[0])
        s.add(arr[1])
    else:
        s.add(arr[1])

ans = n - len(s)
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)]
A = [list() for _ in range(N)] 
ans = 0  
for a ,b in AB:
    A[b-1].append(a-1)
    A[a-1].append(b-1)
for i in range(N):
    for j in A[i]:
        
        if H[i] <= H[j]:
            ans += 1
            break
print(N-ans)

Solution (Python):
import sys
from collections import defaultdict

input = sys.stdin.readline


def I():
    return int(input())


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


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, m = MI()
    h = LI()

    dict = defaultdict(set)
    for _ in range(m):
        a, b = MI()
        dict[a].add(b)
        dict[b].add(a)

    c = n
    for k, v in dict.items():
        for t in v:
            if h[t - 1] >= h[k - 1]:
                c -= 1
                break

    print(c)


if __name__ == "__main__":
    main()

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

ans = [False for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        ans[a-1] = True
    elif H[a-1] > H[b-1]:
        ans[b-1] = True
    else:
        ans[a-1] = True
        ans[b-1] = True

print(N-sum(ans))

Solution (Python):
from collections import defaultdict, deque

def main():
    N, M = tuple(int(c) for c in input().split(' '))
    H = [0] + [int(c) for c in input().split(' ')]
    path = defaultdict(set)
    for _ in range(M):
        a, b = tuple(int(c) for c in input().split(' '))
        path[a].add(b)
        path[b].add(a)

    def tansaku(dai):
        
        
        reachable = path[dai]
        
        if len(reachable) == 0:
            return 1
        else:
            for j in reachable:
                if H[dai] <= H[j]:
                    return 0
            else:
                return 1 

    cnt = 0
    for dai in range(1, N+1):
        cnt += tansaku(dai)

    print(cnt)

if __name__ == "__main__":
    main()

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

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

res =  [True] * n

for _ in range(m):
    x1, x2 = map(int,input().split())

    if h[x1 - 1] <= h[x2 - 1]:
        res[x1 - 1] = False
    if h[x2 - 1] <= h[x1 - 1]:
        res[x2 - 1] = False

print(sum(res))

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[B] = 0
    elif H[A] == H[B]:
        L[A] = 0
        L[B] = 0
    else:
        L[A] = 0

print(sum(L))

Solution (Python):














































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

dic = {}
ansl = []

for i in range(M):
    ab = list(map(int, input().split()))
    
    
    
    AB.extend(ab)
    
    dic.setdefault(ab[0],[]).append(ab[1])
    dic.setdefault(ab[1],[]).append(ab[0])




ans = N-len(set(AB))
for k,v in dic.items():
    if H[k-1] > max(list(map(lambda x: H[x-1], v))):
        ans += 1

print(ans)

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

    graph = [[] for _1 in range(N)]
    for a,b in AB:
        graph[a-1].append(b)
        graph[b-1].append(a)
    ans = 0
    

    for i in range(N):
        height = H[i]
        for j in graph[i]:
            if height <= H[j-1]:
                
                break
        else:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()

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

Solution (Python):
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
h=[]
for m in range(M):
    a,b=list(map(int,input().split()))
    if a-1<=N and b-1<=N:
        if H[a-1]<=H[b-1]:
            h.append(a-1)
        if H[a-1]>=H[b-1]:
            h.append(b-1)
h2=set(h)
ans=N-len(h2)
print(ans)

Solution (Python):
def init_road(M, road):
    for _ in range(M):
        a, b = [int(i) for i in input().split()]
        road.setdefault(a,set())
        road.setdefault(b,set())
        road[a].add(b)
        road[b].add(a)
    return road       

def good_peak_cnt(key, values):
    key = key - 1
    key_height = peaks[key]
    if len(values) == 0:
        pass
    else :
        for v in values:
            v = v -1
            v_height = peaks[v]
            if v_height >= key_height:
                return False
    return True

road = dict()
peaks = dict()

N, M = [int(i) for i in input().split()]
heights = [int(i) for i in input().split()]

for i, h in enumerate(heights):
    peaks.setdefault(i, h)

road = init_road(M,road)

cnt = 0
peaks_with_road = set()
for key, values in road.items():
    for r in values:
        peaks_with_road.add(r)
    if good_peak_cnt(key, values):
        cnt += 1

peaks_with_no_road = N - len(peaks_with_road)
output = cnt + peaks_with_no_road
print(output)

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))
import numpy as np
C=np.ones(N)
d=0
def m(a,b):
  if H[b-1]>H[a-1]:
    return [a,a]
  if H[a-1]>H[b-1]:
    return [b,b]
  if H[b-1]==H[a-1]:
    return [a,b]
for i in range(M):
  C[m(A[i],B[i])[0]-1]=0
  C[m(A[i],B[i])[1]-1]=0
for j in range(N):
  d=d+C[j]
print(int(d))

Solution (Python):
def main():

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

  hyoko = list(map(int, input().split()))
  path =[]
  for i in range(M):
    A, B = map(int, input().split())
    path .append([A,B])
  
  
  
  

  good_obs = [1 for i in range(N)]

  for i in path:
    A = i[0]-1
    B = i[1]-1
    
    if hyoko[A] > hyoko[B]:
      good_obs[B] = 0
    elif hyoko[B] > hyoko[A]:
      good_obs[A] = 0
    else:
      good_obs[A] = 0
      good_obs[B] = 0
    

  print(sum(good_obs))


if __name__ == "__main__":
  main()

Solution (Python):
n,m = map(int,input().split())
H = list(map(int,input().split()))
l = [0]*n
AB = [list(map(int,input().split())) for _ in range(m)]
for a,b in AB:
    if H[a-1]>H[b-1]:
        l[a-1] += 1
        l[b-1] -= 10000
    elif H[a-1]==H[b-1]:
        l[a-1] -= 10000
        l[b-1] -= 10000
    else:
        l[a-1] -= 10000
        l[b-1] += 1
ans = 0
for _ in range(n):
    if l[_]>=0:
        ans += 1
print(ans)

Solution (Python):
import numpy as np

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

h = {}
for k, v in zip(range(1,n+1),[k for k in map(int, input().split())]):
    h[k] = v 

miti = []
for i in range(m):
    temp = [k for k in map(int, input().split())]
    miti.append(temp)

x = np.zeros(n)

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

print(sum(x == 0))

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

ans = [1 for i in range(n)]

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

count = ans.count(1)
print(count)

Solution (Python):

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

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

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

d=set(list(range(N)))

v=[]

for i in range(M):
    if H[S[i][0]-1]<H[S[i][1]-1]:
        v.append(S[i][0]-1)
    elif H[S[i][0]-1]>H[S[i][1]-1]:
        v.append(S[i][1]-1)
    elif H[S[i][0]-1]==H[S[i][1]-1]:
        v.append(S[i][0]-1)
        v.append(S[i][1] - 1)

u=set(v)

d=d-u

print(len(d))

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

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

ls = [1 for _ in range(N)]

for m in range(M):
    A, B = map(int, input().split())

    if ls[A - 1]: 
        ls[A - 1] = 0
        if H[A - 1] > H[B - 1]:
            ls[A - 1] = 1

    if ls[B - 1]: 
        ls[B - 1] = 0
        if H[B - 1] > H[A - 1]:
            ls[B - 1] = 1


print(sum(ls))

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

ANS=[1]*N
path=[]

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

print(sum(ANS))

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

Solution (Python):
import os

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

if __name__ == "__main__":
	main()

Solution (Python):

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

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

'''
l = [] 
for i in range(N):
    l.append([0] * N + [H[i]])
'''


highest = [0] + [1] * N


for i in range(M):
    
    
    pa = path[i]
    p = pa[1]-1
    q = pa[0]-1
    x = H[p]
    y = H[q]
    if( x >= y ):
        
        highest[q+1] = 0
    if(  x <= y  ):
        
        highest[p+1] = 0
    

print(sum(highest))

'''
for i in range(M):
    print('path[i][0] = Ai = {}, path[i][1] = Bi = {}'.format(path[i][0], path[i][1]))
    l[ path[i][0]-1 ][ path[i][1]-1 ] = H[path[i][1]-1]
    l[ path[i][1]-1 ][ path[i][0]-1 ] = H[path[i][0]-1]
    print(l)
'''



'''
m_neigh = []
for i in range(N):
    print(l[i][:N])
    m_neigh.append(  max(l[i][:N] )  )
    print(m_neigh)
'''
'''
cnt = 0
for i in range(N):
    
'''

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

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
Hnew=H
Hdel=list()
Hdel2=list()
AB=list()
for i in range(M):
    AB.append(list(map(int, input().split())))
    

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

        
Hdel2=list(set(Hdel2))        
Hdel=list(set(Hdel))
print(len(H)-len(Hdel2))

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
a = []
b = []
cnt = 0
while True:
  try:
    ta,tb = map(int,input().split())
    a.append(ta)
    b.append(tb)
  except:
    break
    
H = [0]*n

for i in range(m):

  if h[a[i]-1]>h[b[i]-1]:
    H[b[i]-1]-=1
  
  if h[a[i]-1]==h[b[i]-1]:
    H[a[i]-1]-=1
    H[b[i]-1]-=1
  if h[a[i]-1]<h[b[i]-1]:
    H[a[i]-1]-=1
n = [1 for i in H if i>=0]
print(len(n))