Problem:
 Score : 300 points    Problem Statement There are N observatories in AtCoder Hill, called Obs. 1 , Obs. 2 , ... , Obs. N . The elevation of Obs. i is H_i .
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j .  Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.
Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.  How many good observatories are there?      Constraints  2 \leq N \leq 10^5  1 \leq M \leq 10^5  1 \leq H_i \leq 10^9  1 \leq A_i,B_i \leq N  A_i \neq B_i  Multiple roads may connect the same pair of observatories.  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  M  H_1  H_2  ...  H_N  A_1  B_1  A_2  B_2  :  A_M  B_M       Output Print the number of good observatories.        Sample Input 1 4 3
1 2 3 4
1 3
2 3
2 4      Sample Output 1 2    From Obs. 1 , you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3 , so Obs. 1 is not good.    From Obs. 2 , you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3 , so Obs. 2 is not good.    From Obs. 3 , you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2 , so Obs. 3 is good.    From Obs. 4 , you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2 , so Obs. 4 is good.    Thus, the good observatories are Obs. 3 and 4 , so there are two good observatories.       Sample Input 2 6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6      Sample Output 2 3

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
g = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(h[b])
    g[b].append(h[a])
ans = 0
for i in range(n):
    if len(g[i]) == 0:
        ans +=1
        continue
      
    if h[i] > max(g[i]):ans += 1
print(ans)

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

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(M)]
ans = [True] * N
for A, B in AB:
    a = A - 1
    b = B - 1
    if H[a] >= H[b]:
        ans[b] = False
    if H[a] <= H[b]:
        ans[a] = False
print(len([i for i in ans if i]))

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache






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






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


def lcm(a, b):
    return a * b // gcd (a, b)





N,M = inputIL()
H = inputIL()

graph = [[] for _ in range(N)]
for _ in range(M):
    u, v = inputIL()
    graph[u-1].append(v-1)
    graph[v-1].append(u-1)
    
ans = 0
for i in range(N):
  flag = 1
  h = H[i]
  if len(graph[i]) ==  0:
    pass
  else:
    for j in graph[i]:
       if H[j] >= h:
        flag = 0
        break
  ans += flag
  
print(ans)

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

good = [1 for i in range(1, N+1)]

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

print(sum(good))

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

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

height = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    height[a-1] = max(height[a-1], hn[b-1])
    height[b-1] = max(height[b-1], hn[a-1])

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

print(ans)

Solution (Python):
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))

n,m = mp()
h = lmp()
edge = []
for i in range(n+1):
    edge.append([])
for i in range(m):
    a,b = mp()
    edge[a].append(b)
    edge[b].append(a)

ans = 0
for i in range(1, n+1):
    tar = edge[i]
    height = h[i-1]
    flag = True
    for j in range(len(tar)):
        if h[tar[j]-1] >= height:
            flag = False
    if flag:
        ans += 1
print(ans)

Solution (Python):
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, m = load_list()
s = set()
H = load_list()
for i in range(m):
    a, b = load_list()
    a -= 1
    b -= 1
    target = 0
    if H[a] < H[b]:
        target = a
    elif H[a] > H[b]:
        target = b
    else:
        s.add(a + 1)
        s.add(b + 1)
        continue
    s.add(target + 1)

print(n - len(s))

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

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

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

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

print(n - len(not_good))

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1

"""

import collections
import itertools
import operator


class UnionFind:
    def __init__(self, x):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)
        self.size = collections.defaultdict(lambda: 1)
        if x is not None:
            for elem in range(x+1):
                _, _, _ = self.parent[elem], self.rank[elem],self.size[elem]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not self.are_same(x,y):
            xx = self.size[x]
            yy = self.size[y]
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += xx
            else:
                self.parent[y] = x
                self.size[x] += yy
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def Size(self,x):
        return self.size[self.find(x)]

    def are_same(self, x, y):
        '''print(x,y,self.find(x),self.find(y),self.find(x) == self.find(y))'''
        return self.find(x) == self.find(y)

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]

n,k = m()

h = l()

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

for i in range(k):
    a,b = m()
    if h[a-1] > h[b-1]:
        po[b-1] = 0
    elif h[a-1] < h[b-1]:
        po[a-1] = 0
    else:
        po[a-1] = 0
        po[b-1] = 0

co = 0

for i in range(n):
    if po[i] == 1:
        co += 1



print(co)

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

Flags = [True for i in range(N)]

for i,j in ABs:
    i -= 1
    j -= 1
    a = H[i]
    b = H[j]
    if a>b:
        Flags[j] = False
    elif b>a:
        Flags[i] = False
    else:
        Flags[i],Flags[j] = False,False

ans = sum([1 if i else 0 for i in Flags])
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,M = map(int, input().split())
H = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for _ in range(M)]

S = set([i for i in range(1, N+1)])

for a, b in AB:
    ha = H[a-1]
    hb = H[b-1]

    if ha <= hb and a in S:
        S.remove(a)

    if hb <= ha and b in S:
        S.remove(b)

print(len(S))

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

ans = [1] * N
for i in range(M):
    if H[AB[i][0]-1] < H[AB[i][1]-1]:
        ans[AB[i][0]-1] = 0
    elif H[AB[i][0]-1] > H[AB[i][1]-1]:
        ans[AB[i][1]-1] = 0
    else:
        ans[AB[i][0]-1] = 0
        ans[AB[i][1]-1] = 0

print(sum(ans))

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

check = [1]*n

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

print(check.count(1))

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

Solution (Python):
N, M = [int(x) for x in input().split()]
ansl = [1] * N
height = [int(x) for x in input().split()]
for i in range(M):
  a, b = [int(x)-1 for x in input().split()]
  if height[a] <= height[b]:
    ansl[a] = 0
  if height[b] <= height[a]:
    ansl[b] = 0
print(sum(ansl))

Solution (Python):

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

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


bad_tenbo_list = [0] * (n)
for a,b in ab:
    if h[a-1] > h[b-1]:
        bad_tenbo_list[b-1]=1
    elif h[a-1] < h[b-1]:
        bad_tenbo_list[a-1]=1
    else:
        bad_tenbo_list[a-1]=1
        bad_tenbo_list[b-1]=1

print(n-sum(bad_tenbo_list))

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, M = LI()
    H = LI()
    AB = [LI_() for _ in range(M)]
    good = [True]*N
    for i in AB:
        if H[i[0]]>=H[i[1]]:
            good[i[1]] = False
        if H[i[0]]<=H[i[1]]:
            good[i[0]] = False

    print(len([i for i in good if i]))

if __name__ == '__main__':
    resolve()

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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)


def main():
    N, M = map(int, input().split())
    H = [int(c) for c in input().split()]
    adj_lists = {i: [] for i in range(1, N+1)}
    for _ in range(M):
        a, b = map(int, input().split())
        adj_lists[a].append(b)
        adj_lists[b].append(a)

    num = 0
    for k, v in adj_lists.items():
        flg = True
        for i in v:
            if H[k - 1] <= H[i - 1]:
                flg = False
                break
        if flg:
            num += 1
    print(num)



if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
H=list(map(int,input().split()))
H.insert(0,0)
check=[1 for _ in range(n+1)]
check[0]=0
for _ in range(m):
    a,b=map(int,input().split())
    if H[a]>H[b]:
        check[b]=0
    elif H[a]<H[b]:
        check[a]=0
    else:
        check[a]=0
        check[b]=0

print(sum(check))

Solution (Python):
def main():
  N, M = map(int, input().split())
  H_l = list(map(int, input().split()))
  best_l = [1] * N
  for i in range(M):
    x_1, y_1 = map(int, input().split())
    x = x_1 - 1
    y = y_1 - 1
    if H_l[x] > H_l[y]:
      best_l[y] = 0
    elif H_l[x] < H_l[y]:
      best_l[x] = 0
    else:
      best_l[x] = 0
      best_l[y] = 0
  print(sum(best_l))
main()

Solution (Python):
n, m = map(int, input().split())
good = [True] * 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]:
        good[a - 1] = False
    if h[b - 1] <= h[a - 1]:
        good[b - 1] = False
rcnt = 0
for i in range(n):
    if good[i]:
        rcnt += 1
print(rcnt)

Solution (Python):
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())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans = 0
for i in range(n):
    flag = True
    if len(g[i]) == 0:
        ans += 1
    else:
        for v in g[i]:
            if H[v] >= H[i]:
                flag = False
                break
        if flag:
            ans += 1

print(ans)

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

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

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = [1] * n
for i in range(m):
    a, b = map(int, input().split())
    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(sum(ans))

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

ans = 0
for h, omh in zip(H, other_max_heights):
    if h > omh:
        ans += 1
print(ans)

Solution (Python):
n, m = map(int, input().split())
views = {i+1:[0,set()] for i in range(n)}
Hs = map(int, input().split())
for i,H in enumerate(Hs):
  views[i+1][0] = H

for _ in range(m):
  a, b = map(int, input().split())
  if a not in views[b][1]:
    views[b][1].add(a)
  if b not in views[a][1]:
    views[a][1].add(b)

ans = 0
for i, view in views.items():
  for route in view[1]:
    if views[route][0] >= view[0]:
      break
  else:
    ans += 1

print(ans)

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())
    G[A-1].append(B-1)
    G[B-1].append(A-1)

ans=0
for i in range(N):
    flg=True
    for j in range(len(G[i])):
        if H[i]<=H[G[i][j]]:
            flg=False
    
    if flg:
        ans+=1

print(ans)

Solution (Python):
n, m = [int(_) for _ in input().split()]
h = [int(_) for _ in input().split()]
l = [[] for i in range(n)]
for i in range(m):
    a, b = [int(_) for _ in input().split()]
    l[a-1].append(b-1)
    l[b-1].append(a-1)
ans = 0
for i in range(n):
    high = h[i]
    p = l[i]
    flag = 0
    for j in range(len(p)):
        if h[p[j]] >= high:
            flag = 1
    if flag == 0:
        ans += 1
print(ans)

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

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


tenbodai=[]

class Tenbo:
    def __init__(self,name,hight):
        self.name=name
        self.tonari=[]
        self.hight=hight
for i in range(n):
    tenbo=Tenbo(i,h[i])
    tenbodai.append(tenbo)

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

def good(tenbo):
    if tenbo.tonari==[]:
        return True
    tenbo.tonari.sort()
    if tenbo.hight>tenbo.tonari[-1]:
        return True
    return False
        
ans=0        
for tenbo in tenbodai:
    if good(tenbo):
        ans+=1
print(ans)

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

dic = {}

for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a not in dic:
        dic[a] = 0
    dic[a] = max(dic[a], h[b])
    if b not in dic:
        dic[b] = 0
    dic[b] = max(dic[b], h[a])



answer = 0

for idx, hh in enumerate(h):
    if idx not in dic or hh > dic[idx]:
        answer += 1

print(answer)

Solution (Python):
n,m = map(int, input().split())
h = list(map(int, input().split()))
d = {}
e = {}
for num,i in enumerate(h):
  e[num+1] = i
for i in range(m):
  a,b = map(int, input().split())
  if a in d:
    d[a] = max(d[a],e[b])
  else:
    d[a] = e[b]
  if b in d:
    d[b] = max(d[b],e[a])
  else:
    d[b] = e[a]
ans = 0
k_ = 0
for k,v in d.items():
  if e[k] > v:
    ans +=1
  k_ += 1
print(ans+n-k_)

Solution (Python):

from collections import defaultdict
n, m = map(int, input().split())
h = list(map(int, input().split()))
ns = defaultdict(set)
s = set(list(range(n)))

for i in range(m):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    if h[u]<=h[v] and u in s:
        s.remove(u)
    if h[v]<=h[u] and v in s:
        s.remove(v)

print(len(s))

Solution (Python):
from collections import defaultdict
n , m = map(int , input().split())
h  = list(map(int , input().split()))
dic = defaultdict(list)
for i in range(m):
	u , v = map(int , input().split())
	dic[u].append(v)
	dic[v].append(u)
ans = 0
for i in range(1, n+1):
	currh = h[i-1]
	f = 1
	if i in dic: 
		for obs in dic[i]:
			if i == obs: continue
			if h[obs-1] >= currh:
				f = 0
				break
		if f:
			ans+=1
	else:
		ans+=1
print(ans)

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

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

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=0
l=[[] for i in range(n+1)]
for j in range(m):
  a,b=map(int,input().split())
  l[a].append(b)
  l[b].append(a)
for i in range(1,n+1):
  now=l[i]
  on=0
  for j in now:
    if h[i-1]>h[j-1]:
      on+=1
  if on==len(now):
    ans+=1
print(ans)

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

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

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

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


ans = [1]*N

for j in range(M):
    if H[AB[j][0]-1] > H[AB[j][1]-1]:
        ans[AB[j][1]-1] = 0
    elif H[AB[j][0]-1] < H[AB[j][1]-1]:
        ans[AB[j][0]-1] = 0
    else:
        ans[AB[j][1]-1] = 0
        ans[AB[j][0]-1] = 0
        
print(sum(ans))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    graph[u - 1].append(H[v - 1])
    graph[v - 1].append(H[u - 1])
seen = [0 for _ in range(N)]

ans = 0
for i in range(N):
    if len(graph[i]) == 0:
        ans += 1
    elif max(graph[i]) < H[i]:
        ans += 1
print(ans)

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

for i in range(m):
    a,b = map(int,input().split())
    tem[a-1].append(b-1)
    tem[b-1].append(a-1)
    
ans = 0
for i in range(n):
    if tem[i] == []:
        ans += 1
    else:
        tt = set(tem[i])
        fl = 1
        for j in tt:
            if h[i] <= h[j]:
                fl = 0
                
        ans += fl
        
print(ans)

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

def main():
    N,M = map(int, readline().split())
    H = [int(i) for i in readline().split()]
    ab = map(int, read().split())

    E = [[] for _ in range(N+1)]
    for i, (a, b) in enumerate(zip(*[iter(ab)]*2)):
        E[a].append(b)
        E[b].append(a)
    
    ans = 0
    for i in range(1,N+1):
        flag = True
        for v in E[i]:
            if H[i-1] > H[v-1]:
                continue
            else:
                flag = False
                break
        if flag:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

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

    ok = [True] * N


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


    ans = 0
    for opt in ok:
        if opt:
            ans += 1

    
    print(ans)

if __name__ == "__main__":
  main()

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

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

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

good = [1]*N

for ab in AB:
    if H[ab[0] - 1] < H[ab[1] - 1]:
        good[ab[0] - 1] = 0
    elif H[ab[0] - 1] > H[ab[1] - 1]:
        good[ab[1] - 1] = 0
    elif H[ab[0] - 1] == H[ab[1] - 1]:
        good[ab[0] - 1] = 0
        good[ab[1] - 1] = 0

print(sum(good))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    g[a].append(b)
    g[b].append(a)
ans = 0
for v in range(n):
    flag = False
    for nv in g[v]:
        if h[v] <= h[nv]:
            flag = True
            break
    if not flag: ans += 1
print(ans)

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

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

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

result = 0
for x in good:
	if  x:
		result += 1

print(result)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    H = list(map(int, input().split()))

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

    res = 0
    for i in range(n):
        A = H[i]
        if len(tree[i]) >= 1:
            for j in tree[i]:
                B = H[j]
                if A <= B:
                    break
            else:
                res += 1
        else:
            res += 1

    print(res)


if __name__ == '__main__':
    resolve()

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

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

c = 0
for i in range(n):
    if not arcs[i]:
        c += 1
        continue
    if max(map(lambda x: h[x], arcs[i])) < h[i]:
        c += 1
        continue

print(c)

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

goods=[True]*n

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


ans=0

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

print(ans)

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