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):
import sys
readline = sys.stdin.buffer.readline
arr = []
n,m= list(map(int,readline().rstrip().split()))
h = readline().rstrip().decode().split()
for i in range(m):
  k,l= list(map(int,readline().rstrip().split()))
  if int(h[k-1]) > int(h[l-1]):
    arr.append(l)
  elif int(h[k-1]) < int(h[l-1]):
    arr.append(k)
  else:
    arr.append(l)
    arr.append(k)
print(n-len(set(arr)))

Solution (Python):
from collections import deque
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
check = [0]*n
q = deque()
for i in range(n):
    q.append(i)
ans = 0
while q:
    node = q.pop()
    if check[node] != 0:
        continue
    else:
        check[node] = 1
        count = 0
        for v in edges[node]:
            q.append(v)
            if h[node] > h[v]:
                check[v] = 1
                count += 1
            elif h[node] == h[v]:
                check[v] = 1
        if count == len(edges[node]):
            ans += 1
print(ans)

Solution (Python):
import sys,bisect,string,math,time,functools,random
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            a,b,c=(inp+[1])[:3]
            org_inp.append(inp)
        else:
            index=0
            a,b,c=(ls[i]+[1])[:3]
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'

    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)];rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase

input=lambda: sys.stdin.readline().rstrip()

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

class Tree:
    def __init__(self,inp_size=None,init=True):
        if init:
            self.stdin(inp_size)
        return

    def stdin(self,inp_size=None):
        if inp_size==None:
            self.size=int(input())
        else:
            self.size=inp_size
        self.edges,_=GI(self.size,self.size-1)
        return
    
    def listin(self,ls):
        self.size=len(ls)+1
        self.edges,_=GI(self.size,self.size-1,ls)
        return

    def __str__(self):
        return  str(self.edges)

    def dfs(self,x,func=lambda prv,nx,dist:prv+dist,root_v=0):
        q=deque()
        q.append(x)
        v=[-1]*self.size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==-1:
                    q.append(nb)
                    v[nb]=func(v[c],nb,d)
        return v

    def EulerTour(self,x,func=lambda prv,nx,dist:prv+dist,root_v=0):
        q=deque()
        q.append((-1,x))
        v=[None]*self.size
        v[x]=root_v
        et=[]
        while q:
            cb,ce=q.pop()
            et.append(ce)
            for nb,d in self.edges[ce]:
                if v[nb]==None:
                    q.append((nb,ce))
                    q.append((ce,nb))
                    v[nb]=func(v[ce],nb,d)
        vid=[[-1,-1]for i in range(self.size)]
        for i,j in enumerate(et):
            if vid[j][0]==-1:
                vid[j][0]=i
            else:
                vid[j][1]=i
        return v,et,vid
    
    def LCA_init(self,depth,et):
        self.st=SegTree(self.size*2-1,func=min,ide=inf)
        for i,j in enumerate(et):
            self.st.update(i,j)
        self.LCA_init_stat==True
        return
    
    def LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            depth,et,vid=self.EulerTour(root)
            self.LCA_init(depth,et)
        return self.st.query(x,y+1)

show_flg=False
show_flg=True


n,m=LI()
h=LI()
ans=0
g=[[]for i in range(n)]
for i in range(m):
    a,b=LI_()
    
    if h[a]>=h[b]:
        g[b].append(a)
    if h[b]>=h[a]:
        g[a].append(b)


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

Solution (Python):
input_NM = input().split(' ')
N = int(input_NM[0])
M = int(input_NM[1])
input_H = input().split(' ')
H = []
for i in range(len(input_H)):
  H.append(int(input_H[i]))
  
good = [1 for i in range(N)]

for i in range(M):
  input_AB = input().split(' ')
  A = int(input_AB[0])
  B = int(input_AB[1])
  HA = H[A-1]
  HB = H[B-1]

  if HA > HB:
    min_AB = B-1
    if good[min_AB] == 1:
      good[min_AB] = 0
  elif HA < HB:
    min_AB = A-1
    if good[min_AB] == 1:
      good[min_AB] = 0
  else:
    if good[A-1] ==1:
      good[A-1] = 0
    if good[B-1] ==1:
      good[B-1] = 0

ng = 0
for i in range(len(good)):
  if good[i] != 0:
    ng = ng + 1

print(ng)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int,input().split()))
Road = [sorted(list(map(int, input().split()))) for _ in range(M)]
num = N
Mem = [0 for _ in range(N)]
for j in range(M):
  if H[Road[j][0]-1] > H[Road[j][1]-1] and Mem[Road[j][1]-1] != 1:
    num -= 1
    Mem[Road[j][1]-1] = 1
  elif H[Road[j][1]-1] > H[Road[j][0]-1] and Mem[Road[j][0]-1] != 1:
    num -= 1
    Mem[Road[j][0]-1] = 1
  elif H[Road[j][1]-1] == H[Road[j][0]-1]:
    if Mem[Road[j][0]-1] != 1 and Mem[Road[j][1]-1] != 1:
      num -= 2
      Mem[Road[j][0]-1] = 1
      Mem[Road[j][1]-1] = 1
    elif Mem[Road[j][0]-1] == 1 and Mem[Road[j][1]-1] == 1:
      continue
    else:
      num -= 1
      Mem[Road[j][0]-1] = 1
      Mem[Road[j][1]-1] = 1
print(num)

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

""" 道は一本！ """

N, M = map(int, readline().split())
H = [0] + list(map(int, readline().split()))
A = [0] * (N + 1)

m = map(int, read().split())
for a, b in zip(m, m):
    for _ in range(2):
        A[a] = max(A[a], H[b])
        a, b = b, a

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

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

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

Solution (Python):
R = lambda: map(int, input().split())
n, m = R()
h = [None, *R()]
g = [0] + [1] * n
for _ in range(m):
  a, b = R()
  g[a] &= h[a] > h[b]
  g[b] &= h[b] > h[a]
print(sum(g))

Solution (Python):

def input_from_console():
    n, m = map(int, input().split())
    ab_list = []
    h_list = map(int, input().split())
    for i in range(m):
        a,b = map(int, input().split())
        ab_list.append((a, b))
    return n, m, list(h_list), list(ab_list)


def solve(n, m, h_list, ab_list):
    good_observatory = [True] * n
    for (a, b) in ab_list:
        if h_list[a-1] < h_list[b-1]:
            good_observatory[a - 1] = False
        if h_list[a-1] > h_list[b-1]:
            good_observatory[b - 1] = False
        if h_list[a-1] == h_list[b-1]:
            good_observatory[a - 1] = False
            good_observatory[b - 1] = False

    return sum(good_observatory)


def main():
    n, m, h_list, ab_list = input_from_console()
    print(solve(n, m, h_list, ab_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  
        check_cases()
    else:
        main()

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = list()
B = list()
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a-1)
    B.append(b-1)

kyuryo = [set() for _ in range(N)]
for michi in range(M):
    kyuryo[A[michi]].add(B[michi])
    kyuryo[B[michi]].add(A[michi])

nice_count = 0
for tenbodai in range(N):
    for neighbor in kyuryo[tenbodai]:
        if H[neighbor] >= H[tenbodai]:
            break
    else:
        nice_count += 1

print(nice_count)

Solution (Python):

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

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

    counter = 0
    for k, mountains in route.items():
        if H[k-1] > max([H[i-1] for i in mountains]):
            counter +=1
        
    counter += N - len(route.keys())

    print(counter)

if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
arr=[int(i) for i in input().split()]
hashmap=dict()
count=dict()
visited=dict()
for key in range(1,n+1):
  hashmap[key]=arr[key-1]

result=n
for i in range(m):
  a,b=map(int,input().split())
  if hashmap[a]<hashmap[b]:
    if visited.get(a)==None:
        result-=1
        visited[a]=1
  elif hashmap[b]<hashmap[a]:
    if visited.get(b)==None:
        result-=1
        visited[b]=1
  else:
      if visited.get(a)==None:
          result-=1
          visited[a]=1
      if visited.get(b)==None:
          result-=1          
          visited[b]=1
    
print(result)

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

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

for i in range(m):
    if l[i][1] not in x[l[i][0]-1]:
        x[l[i][0]-1].append(l[i][1])

for j in range(m):
    if l[j][0] not in x[l[j][1]-1]:
        x[l[j][1]-1].append(l[j][0])

y = 0
for a in range(n):
    for c in range(len(x[a])):
        if h[a] <= h[x[a][c]-1]:
            break
    else:
        y += 1

print(y)

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
    elif h[a-1] > h[b-1]:
        l[b-1] = -1
    elif h[a-1] == h[b-1]:
        l[a-1] = -1
        l[b-1] = -1
print(l.count(0))

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

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

    if h[a - 1] < h[b - 1]:
        t[a - 1] = 0
    elif h[a - 1] > h[b - 1]:
        t[b - 1] = 0
    else:
        t[a - 1] = 0
        t[b - 1] = 0

print(t.count(1))

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

    
    G = {}
    for i in range(M):
        A, B = map(int, input().split())
        G[A-1] = max(G.get(A-1, 0), H[B-1])
        G[B-1] = max(G.get(B-1, 0), H[A-1])
    cnt = 0
    for j in range(N):
        if j in G.keys() and H[j] > G[j]:
            cnt += 1
        elif j not in G.keys():
            cnt += 1
    print(cnt)



if __name__ == "__main__":
    c()

Solution (Python):
n, m = map(int,input().split())
h = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(m)]
result = {i + 1 for i in range(n)}

for a, b in ab:
    if h[a-1] < h[b-1]:
        result.discard(a)
    elif h[a-1] > h[b-1]:
        result.discard(b)
    else:
        result.discard(a)
        result.discard(b)

print(len(result))

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

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

print(n-len(noset))

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

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

    if H[A - 1] < H[B - 1]:
        flag[A - 1] = 0
    elif H[A - 1] > H[B - 1]:
        flag[B - 1] = 0
    elif H[A - 1] == H[B - 1]:
        flag[A - 1] = 0
        flag[B - 1] = 0
        
print(sum(flag))

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

flags = [True]*n

for i in range(m):
    if h[ab[i][0]-1] < h[ab[i][1]-1]:
        flags[ab[i][0]-1] = False
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        flags[ab[i][1]-1] = False
    else:
        flags[ab[i][0]-1] = False
        flags[ab[i][1]-1] = False
    
    
    
print(flags.count(True))

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

ans = [0]*n
for w in way:
    a = w[0]
    b = w[1]
    if h[a-1] < h[b-1]:
        ans[a-1] += 1
    elif h[a-1] > h[b-1]:
        ans[b-1] += 1
    else:
        ans[a-1] += 1
        ans[b-1] += 1

count = 0
for a in ans:
    if a == 0:
        count += 1
print(count)

Solution (Python):


def main():
    n, m = map(int, input().split())
    H = list(map(int, input().split()))
    
    towers = []
    for _ in range(n):
        towers.append([])
    
    good_tower_count = 0

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

        
        for j in range(len(towers[i])):
            if H[i] > H[towers[i][j]]:
                good_flags.append(True)
            else:
                good_flags.append(False)
        
        if (False not in good_flags) or len(towers[i]) == 0:
            good_tower_count += 1
            
    
    print(good_tower_count)
    


if __name__ == '__main__':
    main()

Solution (Python):
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

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

AB_unique=list(map(list, set(map(tuple, AB))))

AB_road=[[] for i in range(N)]
for AB in AB_unique:
    if H[AB[0]-1] > H[AB[1]-1]:
        AB_road[AB[1]-1].append(AB[0])
    elif H[AB[0]-1] < H[AB[1]-1]:
        AB_road[AB[0]-1].append(AB[1])
    else:
        AB_road[AB[1]-1].append(AB[0])
        AB_road[AB[0]-1].append(AB[1])

print(AB_road.count([]))

Solution (Python):
from collections import deque

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

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

G = {}

for i in range(1,N+1):
    G[i] = []
for i in range(M):
    G[data[i][0]].append(data[i][1])
    G[data[i][1]].append(data[i][0])

ans = 0
for i in range(1,N+1):
    for j in G[i]:
        if H[i] > H[j]:
            continue
        else:
            break
    else:
        ans += 1

print(ans)

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

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

Solution (Python):

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

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

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


Good = [True for i in range(N)]
for i in range(N):
    for e in E[i]:
        if H[e] >= H[i]:
            Good[i] = False

print(sum(Good))

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


obscanreach = [[] for _ in range(n)]
for x in ls:
    obscanreach[x[0]-1].append(x[1])
    obscanreach[x[1]-1].append(x[0])

res = 0
for i,x in enumerate(obscanreach):
    check = 0
    if not x:
        res += 1
        continue
    for ev in x:
        check = max(check, h[ev-1])
    if h[i] > check:
        res += 1
print(res)

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

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

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

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

good = [1 for j in range(n)] 


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

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

Solution (Python):
def main():
    N,M = map(int,input().split())
    H = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for _ in range(M)]
    ans = [0 for i in range(N)]
 
    for data in AB:
        if H[data[0]-1] <= H[data[1]-1]:
            ans[data[0]-1] = 1
        if H[data[0]-1] >= H[data[1]-1]:
            ans[data[1]-1] = 1
 
    print(ans.count(0))
 
 
if __name__ == "__main__":
    main()

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

candidates = {}
for i in range(m):
    x, y = map(int, input().split(" "))

    if h[x - 1] <= h[y -1]:
        candidates[x] = False
    if h[x - 1] >= h[y -1]:
        candidates[y] = False

ans = 0
for i in range(1, n + 1):
    is_highest = candidates.get(i, True)
    if is_highest:
        ans += 1

print(ans)

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

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

highest = list(range(1,N+1))

lists = []

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

count = 0

for i in range(N):
    if highest[i] == i+1:
        count += 1

print(count)

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

ans = 0
for v in range(N):
    flag = False
    for w in edge[v]:
        if H[v] <= H[w]:
            flag = True
            break
    if flag: continue
    ans += 1

print(ans)

Solution (Python):
n,m = map(int, input().split())
H = list(map(int, input().split()))
a = []
b = []
cnt  = [0]*n
sum = 0
for i in range(m):
    a_tmp,b_tmp = map(int, input().split())
    a.append(a_tmp)
    b.append(b_tmp)
for i in range(m):
    if H[a[i]-1]<H[b[i]-1]:
        cnt[a[i]-1] += 1
    if H[a[i]-1]>H[b[i]-1]:
        cnt[b[i]-1] += 1
    if H[a[i]-1] == H[b[i]-1]:
        cnt[a[i]-1] += 1
        cnt[b[i]-1] += 1
print(cnt.count(0))

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

for x in range(n):
    if k[x] == 100:
        ans += 1

print(str(ans))

Solution (Python):


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

mapping = [[] for _ in range(N)]
for _ in range(M):
    i, j = map(int, input().split())
    mapping[i - 1].append(j - 1)
    mapping[j - 1].append(i - 1)

cnt = 0
for i in range(N):
    ls = mapping[i]
    for j in ls:
        if H[i] <= H[j]:
            break
    else:
        cnt += 1

print(cnt)

Solution (Python):
s = input()

N = int(s.split()[0])
M = int(s.split()[1])

H = input().split()

tenbo = list(range(1,N+1))
bad_tenbo = []

for i in range(M):
  road = input().split()
  A = int(road[0])
  B = int(road[1])
  HA = int(H[A-1])
  HB = int(H[B-1])
  if HA > HB:
    bad_tenbo.append(B)
  elif HA == HB:
    bad_tenbo.append(A)
    bad_tenbo.append(B)
  elif HA < HB:
    bad_tenbo.append(A)
    
result = list(set(tenbo) - set(bad_tenbo))
    
print(len(result))

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

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

for i in range(m):
  x,y = map(int, input().split())
  list_num[x - 1].append(y)
  list_num[y - 1].append(x)

count = 0

for i in range(n):
  check = 1
  for j in list_num[i]:
    if(h[i] <= h[j - 1]):
      check = 0
      break

  if(check == 1):
    count += 1

print(count)

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

good = set(range(n))
for _ in range(m):
    a_, b_ = map(int, input().split())
    a_ -= 1
    b_ -= 1
    if h[a_] == h[b_]:
        if a_ in good:
            good.remove(a_)
        if b_ in good:
            good.remove(b_)
    elif h[a_] < h[b_]:
        if a_ in good:
            good.remove(a_)
    else:
        if b_ in good:
            good.remove(b_)
print(len(good))

Solution (Python):

import sys
from collections import Counter
from itertools import permutations, combinations

from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, m = map(int, input().split())
    H = tuple(map(int, input().split()))
    AB = [tuple(map(int, input().split())) for _ in range(m)]

    ans = [True] * n
    for i in range(m):
        if H[AB[i][0]-1] > H[AB[i][1]-1]:
            ans[AB[i][1]-1] = False
        elif H[AB[i][0]-1] < H[AB[i][1]-1]:
            ans[AB[i][0]-1] = False
        elif H[AB[i][0]-1] == H[AB[i][1]-1]:
            ans[AB[i][0]-1] = False
            ans[AB[i][1]-1] = False

    print(sum(ans))


if __name__ == '__main__':
    main()

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

print(sum(r))

Solution (Python):
N,M = map(int,input().split(" "))
H = input().split(" ")
for i in range(N):
  H[i]=[int(H[i]),1]
for j in range(M):
  A,B = map(int,input().split(" "))
  if H[A-1][0]>H[B-1][0]:
    H[B-1][1]=0
  elif H[A-1][0]<H[B-1][0]:
    H[A-1][1]=0
  elif H[A-1][0]==H[B-1][0]:
    H[A-1][1]=0
    H[B-1][1]=0
compte=0
for k in range(N):
  if H[k][1]==1:
    compte+=1
print(compte)

Solution (Python):
a=input().split()
N=int(a[0])
M=int(a[1])
H_list=input().split()
H_list=[int(i) for i in H_list]
path_list=[]
for i in range(M) :
  b=input().split()
  path_list.append([int(b[0]),int(b[1])])
count=0


c=[]
for i in path_list :
    if H_list[i[0]-1]>H_list[i[1]-1] :
        c.append(i[1])
    elif H_list[i[0]-1]<H_list[i[1]-1]  :
        c.append(i[0])
    else :
        c.append(i[0])
        c.append(i[1])
k=list(set(c))
print(N-len(k))

Solution (Python):
import numpy as np
n, m = (int(x) for x in input().split())
h = [int(x) for x in input().split()]
b = np.zeros(n)
for i in range(m):
    s, k = (int(x) for x in input().split())
    if h[s-1] < h[k-1]:
        b[s-1] = 1
    elif h[k-1] < h[s-1]:
        b[k-1] = 1
    else:
        b[s-1] = 1
        b[k-1] = 1

print(np.count_nonzero(b==0))

Solution (Python):
N,M = map(int,(input().split()))
high = list(map(int, input().split()))
high.insert(0,0)
good_flg = [0]
for i in range(N):
  good_flg.append(1)
for i in range(M):
  A,B = map(int,(input().split()))
  if(high[A]>high[B]):
    good_flg[B]=0
  elif(high[A]<high[B]):
    good_flg[A]=0
  else:
    good_flg[A]=0
    good_flg[B]=0

print(good_flg.count(1))

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

l = [1] * N
for i in range(M):
    if H[A[i]-1] >= H[B[i]-1]:
        l[B[i]-1] = 0
    if H[A[i]-1] <= H[B[i]-1]:
        l[A[i]-1] = 0
print(sum(l))

Solution (Python):
R = lambda: map(int, input().split())
n, m = R()
h = [None, *R()]
g = [0] + [1] * n
for _ in range(m):
  a, b = R()
  if h[a] <= h[b]:
    g[a] = 0
  if h[b] <= h[a]:
    g[b] = 0
print(sum(g))

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)

All = [True]*N

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

print(sum(All))

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N, M = map(int, readline().split())
    H_ex = list(map(int, readline().split()))
    m = map(int, read().split())
    AB = zip(m, m)
    l = [[]for _ in range(N+1)]
    ans = 0
    H = [0]
    H.extend(H_ex)
    for A, B in AB:
        l[A].append(B)
        l[B].append(A)
    for i in range(1,N+1):
        for j in l[i]:
            if H[i] <= H[j]:
                break
        else:
            ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()

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



ans=[0]*N


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

for i in range(M):
    At,Bt=map(int,input().split())



    if(H[Bt-1]<=H[At-1]):
        ans[Bt-1]=1
    if(H[At-1]<=H[Bt-1]):
        ans[At-1]=1
    
print(ans.count(0))

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

l = set()
for i in range(n):
    l.add(i+1)

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

s = set()

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



ans = list(l - s)

print(len(ans))

Solution (Python):
import collections

N,M = map(int,input().split())
H = [int(h) for h in input().split()]
l = []
for m in range(M):
    a,b = map(int,input().split())
    if H[a-1] > H[b-1]:
        l.append(b)
    elif H[a-1] < H[b-1]:
        l.append(a)
    else:
        l.append(a)
        l.append(b)

print(N-len(collections.Counter(l)))

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