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())
listH = list(map(int, input().split()))

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

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

for pair in listM:
    if listH[pair[0]-1] > listH[pair[1]-1]:
        listC[pair[1]-1] -= 1
    elif listH[pair[0]-1] < listH[pair[1]-1]:
        listC[pair[0]-1] -= 1
    else:
        listC[pair[1]-1] -= 1
        listC[pair[0]-1] -= 1
        
cnt = 0

for i in listC:
    if i == 1:
        cnt += 1
        
print(cnt)

Solution (Python):
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
t = {}
for n in range(1, N+1):
    t[n] = H[n-1]

r = set()
for m in range(M):
    A, B = list(map(int, input().split()))
    if t[A] < t[B]:
        r.add(A)
    elif t[B] < t[A]:
        r.add(B)
    else:
        r.add(A)
        r.add(B)
print(len(set(t.keys()) - r))

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

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

cnt = 0

for i, lst in enumerate(road):
	for j in lst:
		if H[i] <= H[j]:
			break
	else:
		cnt += 1

print(cnt)

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

gooddict={i:1 for i in range(1,n+1)}

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

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

Solution (Python):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
lose = [False]*n
ans = n
for i in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    if lose[u] and lose[v]:
      continue
    elif lose[u] and not lose[v]:
      if h[v] > h[u]:
        continue
      else:
        lose[v] = True
        ans -= 1
    elif not lose[u] and lose[v]:
      if h[u] > h[v]:
        continue
      else:
        lose[u] = True
        ans -= 1
    elif not lose[u] and not lose[v]:
      if h[u] > h[v]:
        lose[v] = True
        ans -= 1        
      elif h[v] > h[u]:
        lose[u] = True
        ans -= 1        
      elif h[v] == h[u]:
        lose[u] = True
        lose[v] = True
        ans -= 2
print(ans)

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

Solution (Python):
from collections import defaultdict

N, M = map(int, input().split())
H = [int(s) for s in input().split()]

edges = defaultdict(list)

for i in range(M):
    w = 1
    u, v = map(int, input().split())
    edges[u-1].append((v-1, w))
    edges[v-1].append((u-1, w))



ans = 0
for i in range(N):
    c = True
    for v, w in edges[i]:
        if H[i] <= H[v]:
            c = False
            break
    ans += 1 if c else 0

print(ans)

Solution (Python):
import numpy as np

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

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

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = dict()
for _ in range(M):
    a, b = map(int, input().split())
    if a not in AB:
        AB[a] = [H[b-1]]
    else:
        AB[a].append(H[b-1])

    if b not in AB:
        AB[b] = [H[a-1]]
    else:
        AB[b].append(H[a-1])

cnt = 0
for n in range(1, N+1):
    if (n not in AB.keys()) or (max(AB[n]) < H[n-1]):
        cnt += 1

print(cnt)

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

graph=[0]*N
for i in range(M):
    A,B=map(int,input().split())
    A,B=A-1,B-1
    if H[A]<H[B]:
        graph[A]+=1
    elif H[B]<H[A]:
        graph[B]+=1
    else:
        graph[A]+=1
        graph[B]+=1

ans=graph.count(0)
print(ans)

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

count = N
for i in range(M):
    a, b = map(int, input().split())
    if H[a - 1] <= H[b - 1] and flag[a - 1] is False:
        flag[a - 1] = True
        count -= 1
    if H[a - 1] >= H[b - 1] and flag[b - 1] is False:
        flag[b - 1] = True
        count -= 1

print(count)

Solution (Python):
i = list(map(int, input().split()))
high = list(map(int, input().split()))
good = [0]*i[0]
for j in range(i[1]):
    k = list(map(int, input().split()))
    if high[k[0]-1]>=high[k[1]-1]:
        good[k[1]-1]=1
    if high[k[0]-1]<=high[k[1]-1]:
        good[k[0]-1]=1
print(good.count(0))

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

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

H = list(map(int, input().split(" ")))
road_list = [[] for _ in range(N)]
for i in range(M):
	a_i, b_i = list(map(int, input().split(" ")))
	road_list[a_i-1].append(H[b_i-1])
	road_list[b_i-1].append(H[a_i-1])
good_hills = 0
for i, road in enumerate(road_list):
	if len(road) == 0:
		good_hills += 1
	elif H[i] > max(road):
		good_hills += 1

print(good_hills)

Solution (Python):
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


















def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n,m = map(int,input().strip().split()) 
    h = list(map(int, input().strip().split())) 
    
    S=set([i for i in range(n)])
    for i in range(m): 
        a,b = map(lambda x:int(x)-1,input().strip().split())
        if h[a]>h[b]:
            S.discard(b)
        elif h[a]<h[b]:
            S.discard(a)
        else:
            S.discard(a); S.discard(b)
    print(len(S))

if __name__ == '__main__':
    main()

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

Solution (Python):

import math


def main():

    
    first_input = list(map(lambda x:int(x), input().split(" ")))
    second_input = list(map(lambda x:int(x), input().split(" ")))

    
    
    

    
    

    N = first_input[0]
    M = first_input[1]
    H_list = second_input

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

    count = 0
    for i in range(N):
        if len(H_link_list[i])==0:
            count = count+1
        else:
            if max(H_link_list[i])<H_list[i]:
                count = count+1

    print(count)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
N,M = list(map(int,input().split()))
H = list(map(int,input().split()))
A = [[] for i in range(N)]
for i in range(M):
    a,b = list(map(int,input().split()))
    A[a-1].append(H[b-1])
    A[b-1].append(H[a-1])
ttl = 0
for i in range(N):
    ans = 0
    if len(A[i]) == 0:
        ttl += 1
    else:
        for j in A[i]:
            if j >= H[i]:
                ans += 1
        if ans == 0:
            ttl += 1
print(ttl)

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

path = [[] for _ in range(N)]

for a, b in AB:
    a -= 1
    b -= 1

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

for i in range(N):
    path[i].append(i)

ans = []
j = 0
cnt = 0
for p in path:
    t = 0
    for i in p:
        if t < H[i]:
            t = H[i]
            hh = i
    if hh == j:
        cnt += 1
    j += 1

print(cnt)

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

flag=[True]*N
for i in range(M):
    a,b=map(int,input().split())
    ha=H[a-1]
    hb=H[b-1]
    if ha==hb:
        flag[a-1]=False
        flag[b-1]=False
    elif ha<hb:
        flag[a-1]=False
    else:
        flag[b-1]=False
cnt=0
for f in flag:    
    if f:
        cnt+=1

print(cnt)

Solution (Python):

n,m=map(int,input().split())
h=list(map(int,input().split()))
aa=[[] for i in range(n)]
for i in range(m):
    ai,bi=list(map(int,input().split()))
    aa[ai-1].append(bi-1)
    aa[bi-1].append(ai-1)

icnt=0
for i in range(n):
    yn=""
    for bii in aa[i]:
        if h[bii]>=h[i]:
            yn="NO"
            break
    if yn!="NO":
        icnt+=1

print(icnt)

Solution (Python):
N,M=[int(x) for x in input().split()]
H=[int(x) for x in input().split()]
f=[1]*N
for _ in range(M):
  A,B=[int(x) for x in input().split()]
  i=H[A-1]
  j=H[B-1]
  if i<=j: f[A-1]=0
  if i>=j: f[B-1]=0
print(sum(f))

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

def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    g = [[] for _ in range(n)]

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

    res = [1] * n

    for x in range(n):
        for y in g[x]:
            if h[y] < h[x]:
                continue
            else:
                res[x] = 0
                break
    print(sum(res))
if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
hlist=list(map(int,input().split()))
remlist=[]
for i in range(m):
    a,b=map(int,input().split())
    ah=hlist[a-1]
    bh=hlist[b-1]
    if ah > bh:
        remlist.append(b-1)
    elif bh > ah:
        remlist.append(a-1)
    else:
        remlist.extend([a-1,b-1])

remset=set(remlist)
print(n-len(remset))

Solution (Python):



from math import *
from copy import *					
from heapq import *					
from string import *				
from random import *				
from bisect import *				
from sys import stdin				
from sys import maxsize				
from operator import *				
from itertools import *				
from collections import Counter		
from collections import defaultdict 

'''

'''

def solve(h,adj):
	n = len(h)
	ans = [0]*n
	for i in range(n):
		if(ans[i] == 0):
			currH = h[i]
			f = 1
			z = 1
			for nn in adj[i]:
				f = 0
				
				if(h[nn] >= currH):
					
					z = 0
					break
				elif(h[nn] < currH):
					
					ans[nn] = -1
			if(z == 1 and f == 0 and ans[i] == 0):
				
				ans[i] = 1
			
	
	for i in range(n):
		if(len(adj[i]) == 0):
			ans[i] = 1
	
	return ans.count(1)

N,M = list(map(int, stdin.readline().rstrip().split()))
h = list(map(int, stdin.readline().rstrip().split()))
adj = [[] for i in range(N)]
for mm in range(M):
	a,b = list(map(int, stdin.readline().rstrip().split()))
	a -= 1
	b -= 1
	adj[a].append(b)
	adj[b].append(a)
ans = solve(h,adj)
print(ans)

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

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

print(l.count(1))

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

import sys
from collections import defaultdict

def resolve():
    N, M = iim()
    H = list(iim())
    d1 = defaultdict(list)

    it = iter(map(int, sys.stdin.read().split()))
    for a, b in zip(it, it):
        a -= 1; b -= 1
        d1[a].append(b)
        d1[b].append(a)

    ans = 0
    for i, hi in enumerate(H):
        for j in d1[i]:
            if H[j] >= hi:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()

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

for i in range(m) :
    a,b = map(int,input().split())
    if H[a-1] <= H[b-1] :
        j[a-1] += 1
    if H[b-1] <= H[a-1] :
        j[b-1] += 1
print(j.count(0))

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

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

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

Solution (Python):
n, m = map(int, input().split())
h_array = [int(x) for x in input().split()]
higest = [True for x in range(n)]
res = 0
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h_array[b] == h_array[a]:
        higest[b] = False
        higest[a] = False
    elif h_array[a] >= h_array[b]:
        higest[b] = False
    elif h_array[b] >= h_array[a]:
        higest[a] = False

print(higest.count(True))

Solution (Python):
N, M = map(int,input().split())
ans = [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]:
        ans[B-1] = 0
    elif H[A-1] < H[B-1]:
        ans[A-1] = 0
    else:
        ans[A-1] = 0
        ans[B-1] = 0

print(ans.count(1))

Solution (Python):
import numpy as np
nm = input()
[n, m] = [int(comp) for comp in nm.split()]
h_in = input()
h = [int(comp) for comp in h_in.split()]
dp = np.ones(n, dtype=int)  
for i in range(m):
    abo_in = input()
    abo = [int(comp) for comp in abo_in.split()]
    if(h[abo[0]-1] >= h[abo[1]-1]):
        dp[abo[1]-1] = 0
    if(h[abo[0]-1] <= h[abo[1]-1]):
        dp[abo[0]-1] = 0

print(dp.sum())

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

Solution (Python):
N,M = map(int,input().split())
H = list(map(int, input().split()))
R = [[0] for x in range(N)] 
for x in range(M):
    A,B = map(int,input().split())
    R[A-1].append(B-1)
    R[B-1].append(A-1)
ans =0
for x in range(N):
    ii =True
    for y in R[x][1:]:
        if H[x]<=H[y]:
            ii =False
            break
    if ii ==True:
        ans +=1
        
print(ans)

Solution (Python):
from sys import stdin
n,m = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]
a = []
for i in range(m):
    a.append([int(x) for x in stdin.readline().rstrip().split()])
b = [0] * n
for i in range(m):
    if h[a[i][0]-1] > h[a[i][1]-1]:
        b[a[i][1]-1] = 1
    elif h[a[i][0]-1] == h[a[i][1]-1]:
        b[a[i][1]-1] = 1
        b[a[i][0]-1] = 1
    else:
        b[a[i][0]-1] = 1
ans =0
for i in range(n):
    if b[i] == 0:
        ans += 1
print(ans)

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

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


Road = []
for i in range(N):
  Road.append(0)


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


print(Road.count(0))

Solution (Python):
class ob(object):
  
  def __init__(self, H):
    self.H = H
    self.connect = []
    
  def road(self, m):
    self.connect.append(m)
    
N, M = tuple(map(int, input().split()))

obs = []

for h in list(map(int, input().split())):
  obs.append(ob(h))
  
for m in range(M):
  a, b = tuple(map(int, input().split()))
  obs[a-1].road(obs[b-1].H)
  obs[b-1].road(obs[a-1].H)
  
c = 0
  
for o in obs:
  if len(o.connect) == 0:
    c += 1
  elif max(o.connect)<o.H:
    c += 1
    
print(c)

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

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

print(ans.count(0))

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

f=[True]*n

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

print(sum(f))

Solution (Python):
N, M = [int(s) for s in input().split()]
H = [int(s) for s in input().split()]
good = [True] * N

for _ in range(M):
    a, b = [int(s) - 1 for s in input().split()]
    if H[a] == H[b]:
        good[a] = False
        good[b] = False
    elif H[a] < H[b]:
        good[a] = False
    else:
        good[b] = False
    
print(sum(good))

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

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

print(sum(flag))

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

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

for j in h_j:
    if j==1:
        ans += 1
print(ans)

Solution (Python):
n, m = [int(i) for i in input().split(' ')]
h_s = [int(i) for i in input().split(' ')]
good_s = [1 for i in range(n)]
for i in range(m):
  p1, p2 = [int(i) - 1 for i in input().split(' ')]
  h1 = h_s[p1]
  h2 = h_s[p2]
  if h1 > h2:
    good_s[p2] = 0
  elif h1 < h2:
    good_s[p1] = 0
  else:
    good_s[p1] = 0
    good_s[p2] = 0

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

print(ans)

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

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

check=[0]*n
for _ in range(m):
    a,b=list(map(int,input().split()))
    if hs[a-1]>hs[b-1]:
        check[b-1]+=1
    elif hs[a-1]<hs[b-1]:
        check[a-1]+=1
    elif hs[a-1]==hs[b-1]:
        check[a-1]+=1
        check[b-1]+=1
print(check.count(0))

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

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

for a, b in AB:
    if H[a-1] <= H[b-1]:
        answer[a-1] = 0
    if H[b-1] <= H[a-1]:
        answer[b-1] = 0

print(answer.count(1))

Solution (Python):
n,m= map(int, input().split())
h=list(map(int, input().split()))
B=[0]*m
A=[0]*m
t=[[] for i in range((n+1))]
an=0
for i in range(m):
    A[i],B[i] = list(map(int, input().split()))

for i in range(m):
    t[A[i]].append(B[i])
    t[B[i]].append(A[i])
for i in range(1,n+1):
    k=0
    for j in range(len(t[i])):
        if h[i-1]<=h[t[i][j]-1]:
            k=1
    if k==0:
        an+=1

print(an)

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

Solution (Python):
N,M = (int(x) for x in input().split())
H = list(map(int, input().split()))
connected = [set() for _ in range(N)]
count = 0
for i in range(M):
    A,B = (int(x) for x in input().split())
    connected[A-1].add(B)
    connected[B-1].add(A)
for i in range(N):
    if len(connected[i]) == 0:
        count += 1
    else:
        comp = [H[x-1] for x in connected[i]]
        if max(comp) < H[i]:
            count += 1
print(count)

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

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

Solution (Python):

N, M = map(int, input().split())
*H, = map(int, input().split())
H = [-float('inf')]+H

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

ans = -1
for t in top:
    if t:
        ans += 1
print(ans)

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

Solution (Python):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    H = tuple(map(int, input().split()))
    AB = [tuple(map(int, input().split())) for _ in [0] * M]

    good = [1] * N
    for a, b in AB:
        if H[a-1] < H[b-1]:
            good[a-1] = 0
        elif H[b-1] < H[a-1]:
            good[b-1] = 0
        else:
            good[a-1], good[b-1] = 0, 0
    print(good.count(1))


main()

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

print(A.count(0))

Solution (Python):
n,m = map(int,raw_input().split())
h = map(int,raw_input().split())
q = [1] * (n+1)
q[0] = 0
for a in range(m):
  a,b = map(int,raw_input().split())
  if h[a-1]>h[b-1]:q[b] = 0
  if h[a-1]<h[b-1]:q[a] = 0
  if h[a-1]==h[b-1]:
    q[a]=0
    q[b]=0
print q.count(1)

Solution (Python):
n,m=map(int,input().split())
ans=set()
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.add(b-1)
    elif h[a-1]<h[b-1]:
        ans.add(a-1)
    else:
        ans.add(a-1)
        ans.add(b-1)
ans2=len(ans)
print(n-ans2)

Solution (Python):
def main():
    n, m = [int(v) for v in input().strip().split(' ')]
    heights = [int(v) for v in input().strip().split(' ')]
    max_neighbors_heights = [0 for _ in range(n)]

    for _ in range(m):
        a, b = [int(v) - 1 for v in input().strip().split(' ')]
        max_neighbors_heights[a] = max(max_neighbors_heights[a], heights[b])
        max_neighbors_heights[b] = max(max_neighbors_heights[b], heights[a])

    ans = 0
    for h, max_neighbors_h in zip(heights, max_neighbors_heights):
        if h > max_neighbors_h:
            ans += 1
    print(int(ans))


if __name__ == '__main__':
    main()

Solution (Python):

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

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




for i in range(n):
    if peak[i] == load[i] and peak[i] != 0:
        ans += 1

ans += load.count(0)
print(ans)

Solution (Python):
N,M=map(int, input().split())
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]=ans[B-1]=-1
print(len(ans)-ans.count(-1))

Solution (Python):
N, M = list(map(int, input().split()))
Hs = list(map(int, input().split()))
flg_list = [0] * N
for j in range(M):
    ai, bi = list(map(int, input().split()))
    ai -= 1
    bi -= 1
    if Hs[ai] > Hs[bi]:
        flg_list[bi] += 1
    elif Hs[ai] < Hs[bi]:
        flg_list[ai] += 1
    else:
        flg_list[ai] += 1
        flg_list[bi] += 1

print(flg_list.count(0))

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

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

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

ans = 0

for i in range(n):
    flag = True
    if len(root[i]) > 0:
        for j in root[i]:
            if h[i] <= h[j]:
                flag = False
                break
    if flag:
        ans += 1
print(ans)

Solution (Python):






inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break


n, m = (int(i) for i in inputs[0].split())
heights = [int(h) for h in inputs[1].split()]
paths = [[int(p) for p in path.split()] for path in inputs[2:]]

tours = {n: h for n, h in zip(range(1, n+1), heights)}
tours_neighbor = {n: [] for n in range(1, n+1)}

for path in paths:
    tours_neighbor[path[0]].append(path[1])
    tours_neighbor[path[1]].append(path[0])

counter = 0
for tour, neighbor in tours_neighbor.items():

    checker = True

    for n in neighbor:
        if tours[tour] <= tours[n]:
            checker = False

    if checker:
        counter += 1

print(counter)

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

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


ans = sum(heighest)
print(ans)

Solution (Python):
import sys
stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,M=nm()
H=nl()
Hl=[[] for i in range(N)]
A=[]
for i in range(M):
    A,B=nm()
    Hl[A-1].append(H[B-1])
    Hl[B-1].append(H[A-1])

c=0
for i in range(N):
    flag=True
    for j in range(len(Hl[i])):
        if(H[i]<=Hl[i][j]):
            flag=False
    c=(c+1 if flag==True else c)

print(c)

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)
res = 0
high = [1 for i in range(N)]
for u in range(N):
    for v in G[u]:
        if H[u] < H[v]:
            high[u] = 0
        elif H[u] > H[v]:
            high[v] = 0
        else:
            high[u] = 0
            high[v] = 0
    if high[u]:
        res += 1
print(res)

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

hl = [int(i) for i in input().split()]

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

for _ in range(m):
  a, b = [int(i) for i in input().split()]
  ml[a-1].append(b-1)
  ml[b-1].append(a-1)
  
count = 0
for i in range(n):
  h = hl[i]
  max_h = 0
  for j in ml[i]:
    max_h = max(max_h, hl[j])
  if h > max_h:
    count += 1
    
print(count)

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