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):
from math import sqrt,ceil,floor
def mi():return map(int,input().split())
def li():return list(mi())
def ii():return int(input())

n,k=mi()

m=[1]*(n+1)
a=li()
for i in range(k):
    x,y=mi()
    if(a[x-1]==a[y-1]):
        m[x]=0
        m[y]=0
    if(a[x-1]>a[y-1]):
        m[y]=0
    else:
        m[x]=0


m=m[1:]
print(m.count(1))

Solution (Python):
from collections import defaultdict
import numpy as np

N, M = map(int, input().split())
H = np.array(list(map(int, input().split())))
AB = []
dic = defaultdict(list)
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1  
    AB.append((a, b))
    dic[a].append(b)
    dic[b].append(a)


ans = 0
for i in range(N):
    if dic.get(i, None) is None:
        ans += 1
        continue
    if H[i] > (H[[dic[i]]]).max():
        ans += 1
print(ans)

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

V = []
for node in range(N):
    V.append(set())
for _ in range(M):
    a,b = map(int, input().split())
    V[a-1].add(b-1)
    V[b-1].add(a-1)

ans = 0
for node in range(N):
    Hi = H[node]
    flg = 0
    for next_node in V[node]:
        if Hi>H[next_node]:
            continue
        flg = 1
    if flg==0:
        ans = ans + 1
    elif len(V[node])==0:
        ans = ans + 1
print(ans)

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

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

is_good_place = [True] * (N + 1)

for _ in range(M):
    A, B = map(int, input().split())
    if H[A] == H[B]:
        is_good_place[A] = is_good_place[B] = False
    elif H[A] > H[B]:
        is_good_place[B] = False
    else:
        is_good_place[A] = False

ans = -1

for place in is_good_place:
    if place:
        ans += 1

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline
MOD = 1000000007

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

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

x  = [1]*N

for _ in range(M):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if H[a] > H[b]:
        x[b] = 0
    elif H[a] == H[b]:
        x[a] = 0
        x[b] = 0
    else:
        x[a] = 0


print(x.count(1))

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



ans = [1] * N

for l in range(M):
    if H[A[l][0]-1] > H[A[l][1]-1]:
        ans[A[l][1]-1] = 0
    elif H[A[l][0]-1] == H[A[l][1]-1]:
        ans[A[l][1]-1] = 0
        ans[A[l][0]-1] = 0
    else:
         ans[A[l][0]-1] = 0

print(sum(ans))

Solution (Python):
import sys

input=sys.stdin.readline

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

ans=0
for i in range(0,N):
    m=h[i]
    if edge[i]:
        data=[h[j] for j in edge[i]]
        M=max(data)
        if m>M:
            ans+=1
    else:
        ans+=1

print(ans)

Solution (Python):
"""
隣接している展望台よりも高いかどうかを調べる
良くない展望台と判明した展望台は記録していく
"""
N,M = map(int,input().split())
H = list(map(int,input().split()))
roads = [[]for _ in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    roads[a].append(b)
    roads[b].append(a)


count = 0
for i in range(1,N+1):
    h = H[i-1]
    judge = 1
    for j in roads[i]:
        if h <= H[j-1]:
            judge = 0
            break
    if judge == 1:
        count += 1

print(count)

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

Solution (Python):

def inputlist(): return [int(k) for k in input().split()]

N,M = inputlist()
H = inputlist()
graph = [[] for _ in range(N)]

for i in range(M):
    A,B = inputlist()
    A -=1
    B -=1
    graph[A].append(B)
    graph[B].append(A)
ans = 0
for i in range(N):
    h = H[i]
    k = 0
    for j in graph[i]:
        k = max(k,H[j])
    if h > k:
        ans +=1
print(ans)

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

print(sum(ans))

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        
        
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = MAP()
A = LIST()
ab = [LIST() for i in range(M)]
graph = defaultdict(list)
tree = UnionFind(N)
for a, b in ab:
    tree.union(a-1, b-1)
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)


cnt = 0
for i in range(N):
    my_h = A[i]
    tmp = 0
    for node in graph[i]:
        if A[node] < my_h:
            tmp += 1
    if tmp == len(graph[i]):
        cnt += 1

print(cnt)

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

T = [1 for _ in range(N)]
for a,b in AB:
    if H[a-1] >= H[b-1]:
        T[b-1] = 0
    if H[a-1] <= H[b-1]:
        T[a-1] = 0

print(sum(T))

Solution (Python):
n, m = [int(x) for x in input().split()]
h_list = [0] + [int(x) for x in input().split()]

temp_list = [1] * (n + 1)
temp_list[0] = 0
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    if h_list[a] <= h_list[b]:
        temp_list[a] = 0
    if h_list[b] <= h_list[a]:
        temp_list[b] = 0
print(sum(temp_list))

Solution (Python):
if __name__ == '__main__':
    n, m = map(int, input().split())
    h = [int(i) for i in input().split()]

    list = [0]*n

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

    count =0
    for i in list:
        if i == 0:
            count+=1
    print(count)

Solution (Python):
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

maps = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int1, readline().split())
    maps[A].append(B)
    maps[B].append(A)

cnt = 0
for i, ma in enumerate(maps):
    acc = 0
    for m in ma:
        acc = max(acc, H[m])
    if H[i] > acc:
        cnt += 1
print(cnt)

Solution (Python):
N, M = map(lambda x: int(x), input().split(" "))
Hs = list(map(lambda x: int(x), input().split(" ")))
lowers = set()

for _ in range(M):
    A, B = map(lambda x: int(x), input().split(" "))
    a = A-1
    b = B-1
    if Hs[a] > Hs[b]:
        lowers.add(b)
    elif Hs[b] > Hs[a]:
        lowers.add(a)
    else:
        lowers.add(a)
        lowers.add(b)

result = N - len(lowers)
print(result)

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)]
hasi=[0]*N
for i in range(M):
    if H[AB[i][0]-1]>H[AB[i][1]-1]:
        hasi[AB[i][1]-1]+=1
    elif H[AB[i][0]-1]<H[AB[i][1]-1]:
        hasi[AB[i][0]-1]+=1
    else:
        hasi[AB[i][0]-1]+=1
        hasi[AB[i][1]-1]+=1
print(hasi.count(0))

Solution (Python):


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

*h,=map(int, input().split( ))
flag = [1]*n
for _ in range(m):
    ai,bi=map(int, input().split( ))
    ai-=1;bi-=1
    if h[ai]<=h[bi]:
        flag[ai]=0
    if h[bi]<=h[ai]:
        flag[bi]=0
print(sum(flag))

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
x =[[]for _ in range(n)]
for _ in range(m):
  ai,bi = map(int,input().split())
  x[ai-1].append(bi-1)
  x[bi-1].append(ai-1)
ans = [1]*n
for i in range(n):
  if ans[i] != 0:
    flag = False
    for xx in x[i]:
      if h[i] <= h[xx]:
        flag = True
      else:
        ans[xx] = 0
    if flag:
      ans[i] = 0
print(sum(ans))

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

good = [1]*n
for a, b in ab:
    h1 = h_l[a-1]
    h2 = h_l[b-1]
    if h1 > h2:
        good[b-1] = 0
    elif h1 < h2:
        good[a-1] = 0
    else:
        good[a-1] = 0
        good[b-1] = 0

ans = 0
for val in good:
    ans += val

print(ans)

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

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
adj=[[] for i in range(n+1)]
for i in range(m):
    u,v=map(int,input().split())
    adj[u].append(v)
    adj[v].append(u)
cnt=0
for i in range(1,n+1):
    ok=True
    for x in adj[i]:
        if h[i-1]<= h[x-1]:
            ok=False
            break
    if ok:
        cnt += 1
print(cnt)

Solution (Python):



import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    H = i2nn()
    good = [1] * N
    for _ in range(M):
        A, B = map(lambda n:n-1, i2nn())
        if H[A] > H[B]:
            good[B] = 0
        elif H[A] < H[B]:
            good[A] = 0
        else:
            good[A] = good[B] = 0
    print(sum(good))
    return

main()

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

ans = 0
for i in range(n):
    for j in h_rinsetsu[i]:
        if h[i] <= h[j]: break
    else: ans += 1

print(ans)

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

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

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

    if H[a]>=H[b]:
        li[b]=0
    if H[a]<=H[b]:
        li[a]=0

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

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

Solution (Python):


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

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

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

print(ans.count(True))

Solution (Python):
from collections import defaultdict
n, m = map(int, input().split())
ns = list(map(int, input().split()))
ns = [0] + ns
dic = defaultdict(list)
for i in range(m):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
cnt = 0
for i in range(1, n+1):
    if dic[i]:
        if ns[i] > max(ns[j] for j in dic[i]):
            cnt += 1
    else:
        cnt += 1
print(cnt)

Solution (Python):
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq

n, m = map(int, sys.stdin.readline().split())

h = list(map(int, sys.stdin.readline().split()))

l = []
for i in range(m):
    a, b = map(int, sys.stdin.readline().split())
    if h[a-1] > h[b-1]:
        l.append(b)
    elif h[b-1] > h[a-1]:
        l.append(a)
    else:
        l.append(a)
        l.append(b)


c = collections.Counter(l)
print(n-len(c))

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

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

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

for i in range(n):
    if len(memo[i])==0:
        ans+=1
        continue
    
    for j in memo[i]:
        if height[j]>=height[i]:
            break
    else:
        ans+=1

print(ans)

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

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

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

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

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

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

cnt = 0

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

print(cnt)

Solution (Python):
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    C = [h for h in H]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if C[a] <= H[b]:
            C[a] = 0
        if C[b] <= H[a]:
            C[b] = 0

    ans = 0
    for c in C:
        if c > 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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

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

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

print(sum(ans))

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

good = [True] * N

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

print(good.count(True))

Solution (Python):
import sys
from collections import defaultdict
input = sys.stdin.readline
N,M= map(int,input().split())
H = [0] + list(map(int,input().split()))
g = defaultdict(list)

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

ans = 0
for i in range(1,N+1):
    if len(g[i]) == 0:
        ans += 1
    elif H[i] > max([H[j] for j in g[i]]):
        ans += 1
print(ans)

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

Solution (Python):

import sys

class Node:
    def __init__(self, h):
        self.high = h
        self.ne_max = 0

    def set_ne(self, h):
        self.ne_max = max(self.ne_max, h)

    def isg(self):
        return 1 * (self.high > self.ne_max)

def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    nodes = [Node(h) for h in H]

    for ai, bi in zip(A,B):
        nodes[ai-1].set_ne(nodes[bi-1].high)
        nodes[bi-1].set_ne(nodes[ai-1].high)

    print(sum([n.isg() for n in nodes]))

    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):
def resolve():
    N,M = map(int,input().split())
    H = list(map(int,input().split()))
    connections=[[] for i in range(N)]
    for _ in range(M):
        A,B = map(int,input().split())
        connections[A-1].append(B-1)
        connections[B-1].append(A-1)
    ans = 0
    for num,con in enumerate(connections):
        my_height = H[num]
        for nei in con:
            if my_height <= H[nei]:
                break
        else:
            ans+=1
    print(ans)





if __name__ == "__main__":
    resolve()

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

a=[]
for i in range(n+1):
	a.append([0])

for i in range(m):
	x,y=[int(x) for x in input().split()]
	if a[x][0]!=-1 and h[x-1]>h[y-1]:
		a[x].append(y)
	else:
		a[x]=[-1]

	if a[y][0]!=-1 and h[y-1]>h[x-1]:
		a[y].append(x)
	else:
		a[y]=[-1]

ans=0
for i in range(1,n+1):
	if a[i][0]!=-1:
		ans+=1
print(ans)

Solution (Python):
from collections import defaultdict

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

to = defaultdict(set)
for i in range(m):
    aa, bb = map(int, input().split())
    aa -= 1
    bb -= 1
    to[aa].add(bb)
    to[bb].add(aa)

ans = 0
for i in range(n):
    f = True
    for t in to[i]:
        if h[i] <= h[t]:
            f = False
            break
    if f:
        ans += 1
print(ans)

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    N,M=map(int,readline().split())
    H=list(map(int,readline().split()))
    A=[]
    B=[]
    for i in range(M):
        a,b=map(int,readline().split())
        A.append(a)
        B.append(b)

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

    res=0
    for i in range(N):
        if flags[i]:
            res+=1
    print(res)
if __name__=="__main__":
    main()

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

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

notgoods = [False for _ in range(N)]

for m in range(M):
    a, b = list(map(int, input().split()))
    if H[a - 1] <= H[b - 1]:
        notgoods[a - 1] = True
    if H[b - 1] <= H[a - 1]:
        notgoods[b - 1] = True

print(N - sum(notgoods))

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

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

Solution (Python):
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    u = [[] for _ in range(n)]
    for i in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        u[a].append(b)
        u[b].append(a)
    ans = 0
    for i in range(n):
        if u[i] == [] or h[i] > max([h[x] for x in set(u[i])]):
            ans += 1
    print(ans)


if __name__ == '__main__':
    resolve()

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

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

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

Solution (Python):
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    H = il()
    AB = [il() for _ in range(M)]

    ret = [True] * N
    for a, b in AB:
        if H[a - 1] <= H[b - 1]:
            ret[a - 1] = False
        if H[b - 1] <= H[a - 1]:
            ret[b - 1] = False

    print(sum(1 for r in ret if r))


if __name__ == '__main__':
    main()

Solution (Python):
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())



def solve(N, M, A, graph):
    ans = 0
    for u in xrange(N):
        au = A[u]
        for v in graph[u]:
            if au <= A[v]:
                break
        else:
            ans += 1
    return ans

N,M = rrm()
A = rrm()
graph = [[] for _ in xrange(N)]
for _ in xrange(M):
    u,v = rrm()
    u -=1;v-=1
    graph[u].append(v)
    graph[v].append(u)

print solve(N, M, A, graph)

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

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

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

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

ans = 0

for i in range(n):
    if len(tree[i]) == 0:
        ans += 1
    else:
        is_max = True
        height = heights[i]
        for child in tree[i]:
            if height <= heights[child]:
                is_max = False
                break
        if is_max:
            ans += 1

print(ans)

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

ans = 0

L = [1] * N
for a, b in AB:
  a -= 1
  b -= 1
  if H[a] <= H[b]:
    L[a] = 0
  if H[a] >= H[b]:
    L[b] = 0

print(sum(L))

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *
































def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	N,M = inputMap()
	H = inputList()

	ki = [[] for i in range(N)]
	for i in range(M):
		A,B = inputMap()
		A = A-1
		B = B-1
		ki[A].append(B)
		ki[B].append(A)

	ans = 0
	for i,val in enumerate(ki):
		I = H[i]
		flg = True
		for j in val:
			tmp = H[j]
			if I <= tmp:
				flg = False

		if flg == True:
			ans += 1

	
	print(ans)














def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv



def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Solution (Python):
import sys
input = sys.stdin.readline
N, M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
al = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    al[A].append(B)
    al[B].append(A)
ans = 0
for i in range(len(al)):
    h = H[i]
    for a in al[i]:
        if h <= H[a]:
            break
    else:
        ans += 1
print(ans)

Solution (Python):
from collections import defaultdict
n,m = map(int,input().strip().split())
ls = list(map(int,input().strip().split()))
dic = defaultdict(list)
for _ in range(m):
    a,b = map(int,input().strip().split())
    dic[a].append(b)
    dic[b].append(a)

ans = 0
for i in range(1,n+1):
    f = 0
    obse_node = ls[i-1]
    for values in dic[i]:
        if ls[values-1]>=obse_node:
            f = 1
            break
    if f==0 or len(dic[i])==0:
        ans += 1
print(ans)

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

ans = 0
for i in range(1, n + 1):
    ch = 1
    for j in road[i]:
        if l[j - 1] >= l[i - 1]:
            ch = 0
            break
    if ch: ans -= -1
print(ans)