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 = [list(map(int, input().split())) for i in range(M)]
judge = [[] for i in range(N)]
ans = [1 for i in range(N)]


for i in range(M):
  for j in range(2):
    judge[A[i][j]-1].append(A[i][j-1])
    
for k in range(N):
  for l in range(len(judge[k])):
    if H[k] > H[judge[k][l]-1]:
      continue
      
    else:
      ans[k] -= 1
      break
      
print(sum(ans))

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    L = lmi()
    height = [[elm, i] for i, elm in enumerate(L)]
    num_to_h = dict()
    for i, elm in enumerate(height):
        h, num = elm
        num_to_h[num] = h

    good_predicate = [True] * n
    path = [lmi_0() for _ in range(m)]
    for i, j in path:
        i_h, i_j = num_to_h[i], num_to_h[j]
        if i_h == i_j:
            good_predicate[i] = False
            good_predicate[j] = False
        elif i_h < i_j:
            good_predicate[i] = False
        else:
            good_predicate[j] = False
        
        
    
    cnt = 0
    for elm in good_predicate:
        if elm:
            cnt += 1
    print(cnt)




if __name__ == "__main__":
    main()

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

Solution (Python):

import sys


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    score = [0] * N
    for i in range(M):
        a = H[A[i] - 1]
        b = H[B[i] - 1]

        score[A[i] - 1] = max(score[A[i] - 1], b)
        score[B[i] - 1] = max(score[B[i] - 1], a)

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

    print(count)

    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())
Goodtower=["1"]*N

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

Solution (Python):
n,m=map(int,input().split())
l=list(map(int,input().split()))
d={}
for i in range(n):
	d[i+1]=[]
while m:
	m-=1
	a,b=map(int,input().split())
	d[a].append(b)
	d[b].append(a)
c=0
for i in d:
	f=0
	for j in d[i]:
		if l[j-1]>=l[i-1]:
			f=1
			break
	if f==0:
		c+=1
		
	
print(c)

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

weak=[]
for i in range(M):
    An,Bn =map(int,input().split())
    if H_n[An-1] < H_n[Bn-1]:
        weak.append(An)
    elif H_n[An-1] == H_n[Bn-1]:
        weak.append(An)
        weak.append(Bn)
    else:
        weak.append(Bn)

print(N -len(set(weak)))

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

Solution (Python):
N, M = input().split(" ")
N, M = int(N), int(M)
H = [int(h) for h in input().split(" ")]
A = []
B = []
TF = [True] * N
for i in range(M):
    a, b = input().split(" ")
    a, b = int(a), int(b)
    if H[a-1] > H[b-1]:
        if TF[b-1]:
            TF[b-1] = False
    elif H[b-1] > H[a-1]:
        if TF[a-1]:
            TF[a-1] = False
    else:
        TF[b-1] = False
        TF[a-1] = False
            
print(sum(TF))

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

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

f = [1] * len(h)

for i,abi in enumerate(ab):
    if h[abi[0]-1] <= h[abi[1]-1]:
        f[abi[0]-1] = 0
    if h[abi[0]-1] >= h[abi[1]-1]:
        f[abi[1]-1] = 0

print(sum(f))

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

import networkx as nx
G = nx.Graph()
for i in range(k[0]):
  G.add_node(i +1)
for i in m:
  G.add_edge(i[0],i[1])
re = 0
for i in list(G.nodes):
  if len(list(nx.all_neighbors(G, i))) != 0:
    max_height = max([h[x - 1] for x in list(nx.all_neighbors(G, i))])
    if h[i-1] > max_height:
      re +=1
  else:
    re +=1
print(re)

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

import collections
c=collections.Counter(ll)
print(n-len(c))

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

flag = [1]*n

for i in ab:
  if h[i[0]-1] > h[i[1]-1]:
    flag[i[1]-1] = 0
  elif h[i[0]-1] < h[i[1]-1]:
    flag[i[0]-1] = 0
  else:
    flag[i[1]-1] = 0
    flag[i[0]-1] = 0

print(flag.count(1))

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

good = [True]*N
for ab in AB:
    a, b = ab[0]-1, ab[1]-1
    if H[a] >= H[b]:
        good[b] = False
    if H[b] >= H[a]:
        good[a] = False

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

Solution (Python):


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

anslist = [0] * N

i=0    
while i<M:
    checkA = AList[i][0]
    checkB = AList[i][1]
    
    if HList[checkA-1] < HList[checkB-1]:
        anslist[checkA-1]="x"
    elif HList[checkA-1] > HList[checkB-1]:
        anslist[checkB-1]="x"
    else:
        anslist[checkA-1]="x"
        anslist[checkB-1]="x"
        
    i+=1
print(anslist.count(0))

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




def main():
    N,M = map(int, input().split())
    H = list(map(int, input().split()))
    nodes = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int,input().split())
        nodes[a-1].append(b-1) 
        nodes[b-1].append(a-1)
    count = 0
    for i in range(N):
        res = True
        if len(nodes[i]) == 0:
            count += 1
            continue
        for n in nodes[i]:
            res = res and (H[n] < H[i])
        count += int(res)
    print(count)
if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
height = list(map(int, input().split()))
good = [True] * N

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

print(good.count(True))

Solution (Python):
n,m=map(int,input().split())
height = list(map(int,input().split()))
lst = [0] * n
for j in range(m):
  a,b=map(int,input().split())
  if height[a-1]<height[b-1]:
    if height[b-1] <0:
      lst[a-1]=-100
    else:
      lst[a-1]=-100
      lst[b-1]+=1
  elif height[a-1]>height[b-1]:
    if height[a-1]<0:
      lst[b-1]=-100
    else:
      lst[a-1]+=1
      lst[b-1]=-100
  elif height[a-1]==height[b-1]:
    lst[a-1] = -100
    lst[b-1] = -100
cnt = 0
for k in range(n):
  if lst[k]>=0:
    cnt+=1
print(cnt)

Solution (Python):
n, m = [int(elem) for elem in input().split()]
h_lst = [int(elem) for elem in input().split()]

res = [1] * n

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

Solution (Python):
n, m = map(int,input().split())
height = list(map(int,input().split()))
route = [set() for i in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    if not (b - 1) in route[a - 1]:
        route[a - 1].add(b - 1)
        route[b - 1].add(a - 1)

out = 0
for i in range(n):
    if len(route[i]) == 0:
        out += 1
    else:
        flg = 1
        for j in route[i]:
            if height[i] <= height[j]:
                flg = 0
                break
        if flg == 1:
            out += 1

print(out)

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

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

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

print(ans.count(0))

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

Solution (Python):
from collections import defaultdict as dd
d = dd(list)

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

ans = []
for i in range(n):
    flg = True
    for nb in d[i+1]:
        if h[i] <= h[nb-1]:
            flg = False
    if flg or len(d[i+1]) == 0:
        ans.append(i+1)

print(len(ans))

Solution (Python):
N, M = map(int, input().split())
H_ = list(map(int,input().split()))
H = [0]
H.extend(H_)
D = dict()
for i in range(M):
    t_ = list(map(int,input().split()))
    if t_[0] not in D.keys():
        D[t_[0]] = [t_[1]]
    else:
        D[t_[0]].append(t_[1])
    if t_[1] not in D.keys():
        D[t_[1]] = [t_[0]]
    else:
        D[t_[1]].append(t_[0])
ret = list()
for v in D.keys():
    L = D[v]
    for i in range(len(L)):
        if H[v] <= H[L[i]]:
            break
        if i == len(L) - 1:
            ret.append(v)
num = N - len(D.keys()) + len(ret)
print(num)

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

for i in range(n):
  h[i] = int(h[i])



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



for i in e:
  if i==1:
    ans += 1
print(ans)

Solution (Python):
n, m = map(int, input().split())
height = list(map(int, input().split()))
observetry = list(range(1, n+1))
lose = []

for i in range(m):
    a, b = map(int, input().split())
    if height[a-1] == height[b-1]:
        lose.append(a)
        lose.append(b)
    elif height[a-1] > height[b-1]:
        lose.append(b)
    else:
        lose.append(a)

ans = list(set(observetry) - set(lose))
print(len(ans))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
l1=[]
l2=[]
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if a>b:
    c=a
    a=b
    b=c
  k=[a,b]
  l1.append(k)
  c=a
  a=b
  b=c
  k=[a,b]
  l2.append(k)
l1.sort()
l2.sort(reverse=True)
for i in l1:
  if h[i[0]-1]<=h[i[1]-1]:
    l[i[0]-1]+=1
for i in l2:
  if h[i[0]-1]<=h[i[1]-1]:
    l[i[0]-1]+=1
print(l.count(0))

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

roads = []
for i in range(N):
    roads.append([])
    
for i in range(M):
    r = list(map(lambda x: int(x)-1, input().split()))
    roads[r[0]].append(r[1])
    roads[r[1]].append(r[0])

goodcount = 0
for i in range(len(H)):
    isgood = True
    for r in roads[i]:
        if H[i] <= H[r]:
            isgood = False
    if isgood:
        goodcount += 1

print(goodcount)

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

rem_list = []

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

print(n-len(set(rem_list)))

Solution (Python):
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,M = int(s[0]), int(s[1])
    adj = []
    for _ in range(N):
        adj.append(set())
    s = input().rstrip().split(' ')
    height = [int(elem) for elem in s]
    for _ in range(M):
        s = input().rstrip().split(' ')
        A,B = int(s[0])-1, int(s[1])-1
        adj[A].add(B)
        adj[B].add(A)


    count = 0
    for i in range(N):
        flag = True
        for adj_n in adj[i]:
            if height[adj_n] >= height[i]:
                flag = False
                break

        if flag == True:
            count += 1

    print(count)

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

for i in range(N):
  for j in Graph[i]:
    if H[i]<=H[j-1]:
      isGood[i]=0

print(sum(isGood))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  A=h[a-1]
  B=h[b-1]
  if A!=B:
    z=min(A,B)
    if z==A:
       x[a-1]=0
    else:
       x[b-1]=0
  else:
    x[a-1]=0
    x[b-1]=0
  
print(sum(x))

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

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


print(ans.count(0))

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

Solution (Python):
num_obs, num_roads = list(map(int, input().split()))


class Obs:
    def __init__(self, elevation, idd):
        self.elevation = elevation
        self.roads_connecting = []
        self.id = idd

    def __repr__(self):
        return "ID:"+str(self.id)+" E:"+str(self.elevation)+"m"


heights = input().split()

observatories = []
i = 1
for h in heights:
    observatories.append(Obs(int(h), i))
    i += 1

for j in range(num_roads):
    road = list(map(int, input().split()))
    observatories[road[0]-1].roads_connecting.append(observatories[road[1]-1])
    observatories[road[1]-1].roads_connecting.append(observatories[road[0]-1])

good_boys = 0

for o in observatories:
    is_good = True
    if len(set(o.roads_connecting)) == 0:
        good_boys += 1
        continue
    for subo in set(o.roads_connecting):
        if subo.elevation >= o.elevation and subo.id != o.id:
            is_good = False
            break
    if is_good:
        good_boys += 1

print(good_boys)

Solution (Python):
n, m = map(int, input().split())
Hn = list(map(int, input().split()))
abn = [list(map(int, input().split())) for _ in range(m)]
pool = [[] for h in Hn]
for ab in abn:
    pool[ab[0]-1].append(Hn[ab[1]-1])
    pool[ab[1]-1].append(Hn[ab[0]-1])
ans = 0
for i in range(n):
    if len(pool[i]) == 0:
        ans += 1
    else:
        if max(pool[i]) < Hn[i]:
            ans += 1
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline



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

    good = [True] * N

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

    print(good.count(True))


if __name__ == "__main__":
    main()

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

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

print(result.count(1) + route.count(0))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)  
to_index = lambda x: int(x) - 1  
print_list_in_2D = lambda x: print(*x, sep="\n")  


def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())


def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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


def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

N, M = MII_split()
Heightis = LII_split()

searched = [False for _ in range(N)]
group_indicies = [-1 for _ in range(N)]

count = 0
groups = []

id_count = 0
neighbors = dict()
for _ in range(M):
    A, B = MII_split()
    searched[A - 1] = searched[B - 1] = True
    if A - 1 in neighbors:
        neighbors[A - 1].append(B - 1)
    else:
        neighbors[A - 1] = [B - 1]
    if B - 1 in neighbors:
        neighbors[B - 1].append(A - 1)
    else:
        neighbors[B - 1] = [A - 1]
for k, v in neighbors.items():
    n_heights = []
    for i in v:
        n_heights.append(Heightis[i])
    ma = max(n_heights)
    if ma < Heightis[k]:
        count += 1



















print(count + searched.count(False))

Solution (Python):
import collections
n,m = list(map(int,input().split()))
tower_high = list(map(int,input().split()))
good_tower = [1]*n

def check_tower(a,b):
    if tower_high[a]<tower_high[b]:
        good_tower[a]=0
    elif tower_high[a] > tower_high[b]:
        good_tower[b]=0
    else:
        good_tower[a]=0
        good_tower[b]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    check_tower(a-1,b-1)
print(good_tower.count(1))

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

d = {}

for i in range(N):
    d[i+1] = H[i]

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

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

    if H[B-1] <= H[A-1]:
        d[B] = 0

print(N - list(d.values()).count(0))

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

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


count = 0
for i in range(N):
    flag = 0
    for j in range(len(L[i])):
        if H[i] <= H[L[i][j]-1]:
            flag = 1
            break
    if flag == 0:
        count += 1
print(count)

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

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

ans = 0
for i,r_l in enumerate(road):
    cnt = 0
    if not r_l:
        ans+=1
        continue
    for r in r_l:

        if H[i] > H[r]:
            cnt +=1
    if cnt == len(r_l):
        ans+=1
print(ans)

Solution (Python):
N, M = map(int, input().split())
 
high_list = list(map(int, input().split()))
check_list = [1]*N
 
for i in range(M):
  a_, b_ = map(int, input().split())
  if high_list[a_-1] < high_list[b_-1]:
    check_list[a_-1] = 0
  elif high_list[a_-1] > high_list[b_-1]:
    check_list[b_-1] = 0
  elif high_list[a_-1] == high_list[b_-1]:
    check_list[a_-1] = 0
    check_list[b_-1] = 0
 
print(sum(check_list))

Solution (Python):


s = list(map(int, input().split(" ")))

tnb = s[0]
mc = s[1]

hk = list(map(int, input().split(" ")))
v = []
for i in range(mc) :
    tmp = list(map(int, input().split(" ")))
    x = tmp[0] - 1
    y = tmp[1] - 1
    ap = y
    if hk[x] < hk[y] :
        ap = x
        v.append(ap)
        continue
    elif hk[x] == hk[y] :
        v.append(x)
        v.append(y)
        continue
    v.append(ap)

ans = tnb - len(set(v))
print(ans)

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

for i in range(M):
    a,b=map(int, input().split())
    li[a].append(b)
    li[b].append(a)
sum = 0

for i in range(N):
    if len(li[i+1]) == 1:
        sum += 1
    else:
        n = False
        for j in range(len(li[i+1])-1):

            if H[i] <= H[li[i+1][j+1]-1]:
                n = True
                break
        if n == False:

            sum+=1

print(sum)

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
box=[[] for i in range(N)]
count=0
for i in range(M):
    a,b=map(int,input().split())
    box[a-1].append(b-1)
    box[b-1].append(a-1)
for i in range(N):
    queue=box[i]
    hmax=H[i]
    count+=1
    for x in queue:
        if H[x]>=hmax:
            count-=1
            break
print(count)

Solution (Python):
N, M = [int(v) for v in input().split()]
H = [int(v) for v in input().split()]
is_good = [True] * N
for i in range(M):
    A, B = [int(v) - 1 for v in input().split()]
    if H[A] <= H[B]:
        is_good[A] = False
    if H[A] >= H[B]:
        is_good[B] = False
print(sum(is_good))

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

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

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

good = [1] * (n+1)


for i in a:
    if h[i[0]-1] < h[i[1]-1]:
        good[i[0]] = 0
    elif h[i[0]-1] > h[i[1]-1]:
        good[i[1]] = 0
    else:
        good[i[0]] = 0
        good[i[1]] = 0

print(good.count(1)-1)

Solution (Python):
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n,m=MI()
    h = LI()
    d = dict()
    for i in range(1,n+1):
        d[i]=[]
    for i in range(m):
        a,b=MI()
        d[a].append(b)
        d[b].append(a)
    
    c=0
    for i in d:
        x = h[i-1]
        f=0
        for j in d[i]:
            if h[j-1]>=x:
                f=1
                break
        if f==0:
            c+=1
    print(c)


if __name__ == "__main__":
    main()

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[]
Dict={}
for i in range(N):
    Dict[i+1]=H[i]
for i in range(M):
    AB.append(list(map(int,input().split())))
    
ng=set()
for i in AB:
    a,b=i[0],i[1]
    if Dict[a]<=Dict[b]:
        ng.add(a)
    if Dict[b]<=Dict[a]:
        ng.add(b)
print(len(set(Dict.keys())-ng))

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

cnt = []
for i in range(m):
    if H[M[i][0]-1] < H[M[i][1]-1]:
        cnt.append(M[i][0])
    elif H[M[i][0]-1] > H[M[i][1]-1]:
        cnt.append(M[i][1])
    else:
        cnt.append(M[i][0])
        cnt.append(M[i][1])
        
import collections
c = collections.Counter(cnt)
print(n-len(c))

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

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

print(s.count(1))

Solution (Python):
n,m=map(int,input().split())
l=list(map(int,input().split()))
d=dict({})
for i in range(m):
  a,b=map(int,input().split())
  if a in d:
    d[a].append(l[b-1])
  else:
    d[a]=[l[b-1]]
  if b in d:
    d[b].append(l[a-1])
  else:
    d[b]=[l[a-1]]
for x in d.keys():
  z=max(d[x])
  if l[x-1]>z:
    pass
  else:
    n-=1
print(n)

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

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

ans = [1] * n

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

print(sum(ans))

Solution (Python):
n,m=map(int,input().split())
heights=list(map(int,input().split()))
heights_w=sorted([(h,i+1) for i,h in enumerate(heights)])[::-1]
cons={i+1:set() for i in range(n)}
for _ in range(m):
  a,b=map(int,input().split())
  cons[a].add(b)
  cons[b].add(a)

debug=False
watched=set()
res=0
if debug: res_m=set()
for h,i in heights_w:
  if i in watched:
    continue
  watched.add(i)
  flg=True
  for con in cons[i]:
    if debug: print(h,heights[con-1],i,con)
    flg=(flg and h>heights[con-1])
    watched.add(con)
  if debug: print(i,h,flg)
  if flg:
    if debug: res_m.add(i)
    res+=1
if debug: print(heights_w,cons,res_m)
print(res)

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

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

for x, y in zip(a, b):
    if h[x-1] < h[y-1]:
        ans[x-1] = False
    elif h[x-1] > h[y-1]:
        ans[y-1] = False
    elif h[x-1] == h[y-1]:
        ans[x-1] = False
        ans[y-1] = False

print(ans.count(True))

Solution (Python):
from collections import deque

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a-1, b-1

def main():
    n, m = map(int, input().split())
    H = list(map(int, input().split()))
    r = [True] * n
    for a, b in readlines(m):
        if H[a] < H[b]:
            r[a] = False
        elif H[b] < H[a]:
            r[b] = False
        else:
            r[a] = False
            r[b] = False

    print(r.count(True))


main()

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

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

ans = 0
for i,r_l in enumerate(road):
    cnt = 0
    if not r_l:
        ans+=1
        continue
    for r in r_l:

        if H[i] > H[r]:
            cnt +=1
    if cnt == len(r_l):
        ans+=1
print(ans)

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