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()))
ans = []
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] < h[b-1]:
        if not a-1 in ans:
            ans.append(a-1)
    elif h[a-1] > h[b-1]:
        if not b-1 in ans:
            ans.append(b-1)
    else:
        if not a-1 in ans:
            ans.append(a-1)
        if not b-1 in ans:
            ans.append(b-1)
print(n-len(ans))

Solution (Python):



import sys



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



class Graph(object):
    def __init__(self, n:int):
        """ ノードのつながりを辞書型で表現する
        要素数nであり、要素は0からn-1である想定
        >> - usage
        g = Graph(n=n)

        """
        self.adjacency_dict = {}
        self.val = [0] * n
        self.good = [1] * n
        self.n = n
        for i in range(n):
            self.add_vertex(i)

    def add_vertex(self, v: int):
        """ ノードを追加する """
        self.adjacency_dict[v] = []

    def add_edge(self, v1: int, v2: int, undirected=False):
        self.adjacency_dict[v1].append(v2)
        if undirected:
            self.adjacency_dict[v2].append(v1)


g = Graph(N)

h = list(map(int, input().split()))
for i in range(N):
    g.val[i] = h[i]

for m in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g.add_edge(a, b, undirected=True)
    val_a, val_b = h[a], h[b]

    if val_a == val_b:
        g.good[a] = 0
        g.good[b] = 0
    if val_a > val_b:
        g.good[b] = 0
    if val_a < val_b:
        g.good[a] = 0


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

Solution (Python):



from collections import defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
from math import gcd, floor, ceil
from sys import stdin, stdout

def ilist():
    return [int(x) for x in stdin.readline().strip().split(" ")]
def iint():
    return int(stdin.readline().strip())
def istr():
    return stdin.readline().strip()



def solve():
    pass


if __name__ == '__main__':
    N, M = ilist()
    H = ilist()
    AdjList = [set() for _ in range(N)]
    for _ in range(M):
        A, B = ilist()
        A -= 1
        B -= 1
        AdjList[A].add(B)
        AdjList[B].add(A)
    res = [0] * N
    for u in range(N):
        c = 1
        for v in AdjList[u]:
            if H[u] <= H[v]:
                c = 0
                break
        res[u] = c
    print(sum(res))

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

def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    hills = [1] * n

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

if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, input().split())
h = [int(x) for x in 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
	if h[b-1] >= h[a-1]:
		l[a-1] = 0
print(sum(l))

Solution (Python):
from collections import defaultdict
N, M = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for i in range(M)]

g = defaultdict(set)
for a, b in AB:
    g[a].add(b)
    g[b].add(a)

good = 0
for obs, h in enumerate(H, 1):
    highest = 0
    for other in g[obs]:
        highest = max(highest, H[other - 1])
    if highest < h:
        good += 1
print(good)

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

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

Solution (Python):
if __name__ == '__main__':
    from sys import stdin
    from collections import defaultdict, deque
    import math
    input = stdin.readline

    

    n, m = map(int, input().split())
    hh = list(map(int, input().split()))
    visited = [False]*n
    nodes = defaultdict(list)
    ok = [True]*n
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if hh[a] <= hh[b]:
            ok[a] = False
        if hh[b] <= hh[a]:
            ok[b] = False

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

    print(ans)

Solution (Python):

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


ans = 0
for i, l in enumerate(L):
    if [x for x in l if x >= H[i]] == []:
        ans += 1


print(ans)

Solution (Python):




def main():
    n, m = map(int, input().split())
    h_l = list(map(int, input().split()))
    ans_set = set(range(1, n + 1))
    for _ in range(m):
        a, b = map(int, input().split())
        if h_l[a - 1] <= h_l[b - 1] and a in ans_set:
            ans_set.remove(a)
        if h_l[b - 1] <= h_l[a - 1] and b in ans_set:
            ans_set.remove(b)
    print(len(ans_set))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

import itertools

n,m = map(int,input().split())
H = list(map(int,input().split()))
memo = [0]*n

for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    if memo[b] < H[a]:
        memo[b] = H[a]
    if memo[a] < H[b]:
        memo[a] = H[b]

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

print(ans)

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math

import itertools
import heapq


import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default




def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n,m=map(int,input().split())
    h=list(map(int,input().split()))
    a=[[h[i]] for i in range(n)]
    for i in range(m):
        x,y=map(int,input().split())
        a[x-1].append(h[y-1])
        a[y-1].append(h[x-1])
    total=0
    for i in range(n):
        if len(a[i])==1:
            total+=1
        elif max(a[i][1:])<a[i][0]:
            total+=1
    print(total)






if __name__ == "__main__":

    main()

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

cnt = 0
i = 0
for l in r:
    if len(l) == 0:
        cnt += 1
    elif max(l) < H[i]:
        cnt += 1
    i += 1

print(cnt)

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


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


N, M = readnums()
H = list(readnums())
r = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]

flag = [1] * N

for x in r:
    if H[x[0]] < H[x[1]]:
        flag[x[0]] = 0
    elif H[x[1]] < H[x[0]]:
        flag[x[1]] = 0
    elif H[x[0]] == H[x[1]]:
        flag[x[0]] = 0
        flag[x[1]] = 0

print(sum(flag))

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

good_obs = [True] * n
for a, b in edges:
    if h[a - 1] >= h[b - 1]:
        good_obs[b - 1] = False
    if h[a - 1] <= h[b - 1]:
        good_obs[a - 1] = False
print(sum(good_obs))

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

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

Solution (Python):
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, M = rl()
H = rl()
import collections
edges = collections.defaultdict(list)
for i in range(M):
	a, b = rl()
	a = a-1
	b = b-1
	edges[a].append(b)
	edges[b].append(a)

ans = 0
visited = {}
for n in range(N):
	if n in visited: continue
	if n not in edges:
		ans += 1
		continue
	good = True
	for next_node in edges[n]:
		if H[n] <= H[next_node]:
			good = False
	if good:
		ans += 1
		for next_node in edges[n]:
			visited[next_node] = 1
	visited[n] = 1
print(ans)

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

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

print(N-len(bad))

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[a-1] = 0
  elif H[a-1] > H[b-1]:
    l[b-1] = 0
  else:
    l[a-1] = 0
    l[b-1] = 0
    
print(sum(l))

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
bads=set()
ans=N
for m in range(M):
  A,B=map(int,input().split())
  A-=1
  B-=1
  if A not in bads and H[A]<=H[B]:
    bads.add(A)
    ans-=1
  if B not in bads and H[A]>=H[B]:
    bads.add(B)
    ans-=1
print(ans)

Solution (Python):
N , M = map ( int , input().strip().split(" ") ) ;
L0 = list ( map ( int , input().strip().split(" ") ) ) ;
L1 = [ 1 for x in range ( N ) ] ;

for x in range ( M ) :
	a , b  = map ( int , input().strip().split(" ") ) ;
	
	if  L0[a-1] > 0 and L0[a-1] <= L0[b-1] :
		L1[a-1] = 0 ;

	if  L0[b-1] > 0 and L0[b-1] <= L0[a-1] :
		L1[b-1] = 0 ;
print ( sum(L1 ) ) ;

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

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

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

H = list(map(int, input().split()))
d = {}

for i in range(N):
    d[i+1] = []
for i in range(M):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)
ans = 0
for k, v in d.items():
    flag = False
    if len(v) == 0:
        ans += 1
        continue
    for y in v:
        if H[k-1] <= H[y-1]:
            flag = True
    if flag == False:
        ans += 1

print(ans)

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

tmp = []
ans = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    tmp.append([a, b])

    if h[a-1] == h[b-1]:
        ans[a-1] = -1
        ans[b-1] = -1
    else:
        if h[a-1] > h[b-1]:
            ans[b-1] = -1
        else:
            ans[a-1] = -1

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

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

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

Solution (Python):
N,M=map(int,input().split())
H=[0]
H+=list((map(int,input().split())))
way=[[] for _ in range(N+1)]
ans=0
flag=0
for i in range(M):
    a,b=(map(int,input().split()))
    way[a].append(b)
    way[b].append(a)

for i in range(1,N+1):
    flag=0
    for j in way[i]:
        if H[j] >= H[i]:
            flag=1
            break
    if flag==0:
        ans+=1
        
print(ans)

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

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

for i in range(M):
  A, B = map(int, input().split())
  if H[A-1] < H[B-1]:
    kouho[A-1] = 0
  elif H[A-1] > H[B-1]:
    kouho[B-1] = 0
  else:
    kouho[A-1] = 0
    kouho[B-1] = 0
ans = sum(kouho)
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)
from collections import deque
ans=0
for i in range(n):
  q=deque()
  q.append(i)
  while q:
    cur=q.popleft()
    ok=True
    for nx in G[cur]:
      if h[cur]>h[nx]:
        pass
      else:
        ok=False
    if ok:
      ans+=1
print(ans)

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

import sys

for i in range(m):
  a, b = map(int, sys.stdin.readline().rstrip().split())
  a -= 1
  b -= 1
  if H[a]>=H[b]:
    G[b] = 0
  if H[b]>=H[a]:
    G[a] = 0
  
print(sum(G))

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)
p = sorted([x, i] for i, x in enumerate(h))[::-1]
ans = 0
for i in range(n):
    s = p[i][1]
    m = 0
    for t in g[s]:
        m = max(m, h[t])
    if h[s] > m:
        ans += 1
print(ans)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
s = set(range(1, n+1))
a, b = [], []

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

    if h[A-1] < h[B-1]:
        if A in s:
            s.remove(A)
    elif h[A - 1] > h[B - 1]:
        if B in s:
            s.remove(B)
    else:
        if A in s:
            s.remove(A)
        if B in s:
            s.remove(B)




print(len(s))

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

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

check = [True] * N
for q in Q:
    if H[q[0] - 1] < H[q[1] - 1]:
        check[q[0] - 1] = False
    elif H[q[0] - 1] > H[q[1] - 1]:
        check[q[1] - 1] = False
    else:
        check[q[0] - 1] = False
        check[q[1] - 1] = False





print(sum(check))

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())
    a -= 1; b -= 1
    x[a].append(b)
    x[b].append(a)
    
ans = 0

y = [0 for _ in range(n)]
for i in range(n):
    if y[i] == -1:continue
    flag = 1
    for z in x[i]:
        if h[z] >= h[i]:
            flag = 0
            y[i] = -1
    if flag == 1:
        y[i] = 1
for i in y:
    if i == 1:
        ans += 1
print(ans)

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

edge = [[] for _ in range(N)]
for ab in AB:
    a, b = ab
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

cnt = 0
for i in range(N):
    if edge[i] == False:
        cnt += 1
    else:
        for ed in edge[i]:
            if H[i] <= H[ed]:
                break
        else:
            cnt += 1
print(cnt)

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

is_good = [1 for i in range(N+1)]
for i in range(M):
  a,b = AB[i]
  if H[a] >= H[b]:
    is_good[b] = 0
  if H[a] <= H[b]:
    is_good[a] = 0

cnt = 0
for i in range(1, N+1):
  if is_good[i] == 1:
    cnt+=1
print(cnt)

Solution (Python):
from collections import Counter
N,M=map(int,input().split())
H=list(map(int,input().split()))
ablist=[list(map(int,input().split())) for i in range(M)]
compare=[0]*N

for i in ablist:
    if H[i[0]-1] < H[i[1]-1]:
        compare[i[0]-1] += 1
    elif H[i[0]-1] > H[i[1]-1]:
        compare[i[1]-1] += 1
    else:
        compare[i[0]-1] += 1
        compare[i[1]-1] += 1

ans = Counter(compare)

print(ans[0])

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

Solution (Python):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()
h=[0]
h.extend(n1())
AB=n3(m)

d={i:[] for i in range(1,n+1)}
for line in AB:
    a,b=line
    d[a].append(b)
    d[b].append(a)

ans=0
for i in range(1,n+1):
    h_now=h[i]
    h_OK=True
    for j in d[i]:
        if h_now<=h[j]:
            h_OK=False
            break
    if h_OK:
        ans+=1
print(ans)

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

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

Solution (Python):


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

ans = [1] * N

for i in range(N):
    for j in G[i]:
        if H[i] <= H[j]:
            ans[i] = 0
            break

print(sum(ans))

Solution (Python):
from sys import stdin

def main():

    input = stdin.readline

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

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

    ans = N - len(set(dame_list))
    print(ans)
    
if __name__ == "__main__":
    main()

Solution (Python):

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

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

flag=[1]*N
line=[]
for i 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[a-1]=0
        flag[b-1]=0
    else:
        flag[b-1]=0
print(sum(flag))

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

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

print(N-len(bad))

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

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

print(result_list.count(1))

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

ans = [1] * n

for i in range(m):
    if H[T[i][0] - 1] > H[T[i][1] - 1]:
        ans[T[i][1] - 1] = 0
    elif H[T[i][0] - 1] < H[T[i][1] - 1]:
        ans[T[i][0] - 1] = 0
    else:
        ans[T[i][0] - 1] = 0
        ans[T[i][1] - 1] = 0

print(ans.count(1))

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

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

flags = [True] * n

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

print(flags.count(True))

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)


d = [[0, -1]]
ans = 0
is_visit = [False] * N
def search(node, par):
    global is_visit
    global ans
    d = [[node, par]]
    while d:
        node, par = d.pop()
        if is_visit[node]:
            continue
        is_visit[node] = True
        h = H[node]
        children = g[node]
        res = True
        for child in children:
            _h = H[child]
            res *= h > _h
            if not is_visit[child]:
                d.append([child, node])
        
        ans += res


for i in range(N):
    if not is_visit[i]:
        search(i, -1)

print(ans)

Solution (Python):















mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

def main():
    n,m = readInt()
    h = readInt()
    ab = [set() for i in range(n)]
    for i in range(m):
        a,b = readInt()
        ab[a-1].add(b-1)
        ab[b-1].add(a-1)
    ans = 0
    for i in range(n):
        res = True
        for x in ab[i]:
            if h[i]<=h[x]:
                res = False
                break
        if res:
            ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()

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

if __name__ == '__main__':
    main()

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


ans = [0] * N
for a in A:
    n1,n2, = a[0]-1,a[1]-1
    if H[n1] < H[n2]:
        ans[n1] = -1
    elif H[n1] == H[n2]:
        ans[n1] = -1
        ans[n2] = -1
    if H[n1] > H[n2]:
        ans[n2] = -1

print(ans.count(0))

Solution (Python):

import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect


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

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))




N, M = mii()
H = lmii()
G = defaultdict(list)
for i in range(M):
    a, b = mii()
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

ans = 0
for i in range(N):
    if len(G[i]) == 0:
        ans += 1
        continue
    f = H[i]
    t_max = 0
    for to in G[i]:
        t_max = max(t_max, H[to])
    if f > t_max:
        ans += 1

print(ans)

Solution (Python):
n,m = map(int,input().split())
h = [int(x) for x in input().split()]
ans_li = [True] * n
ans = 0
for i in range(m):
    a,b = map(int,input().split())
    tmp1 = h[a-1]
    tmp2 = h[b-1]
    if tmp1 > tmp2:
        ans_li[b-1] = False
    elif tmp1 < tmp2:
        ans_li[a-1] = False
    elif tmp1 == tmp2:
        ans_li[a-1] = False
        ans_li[b-1] = False

for i in range(len(ans_li)):
    if ans_li[i] == True:
        ans += 1

print(ans)

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

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

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


print(sum(res))

Solution (Python):

N, M = map(int, input().split())
h = [int(c) for c in input().split()]
dic = [[] for i in range(N)]
for i in range(M):
  a,b = map(int, input().split())
  dic[a-1] += [b-1]
  dic[b-1] += [a-1]

ls = list(range(N))
ans = 0
for c in ls:
  flag = True
  for p in dic[c]:
    if h[c]<=h[p]:
      flag = False
  if flag:
    ans += 1
print(ans)

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

Solution (Python):
n,m=list(map(int, input().split()))
h=list(map(int, input().split()))
aa = []
ab = []
for j in range(m):
    a1,b1=[int(j) for j in input().split()]
    aa.append(a1)
    ab.append(b1)
d=[1]*n
for i in range (m):
    x=aa[i]-1
    y=ab[i]-1
    if h[x]>h[y]:
        d[y]=0
    elif h[x]==h[y]:
        d[x]=0
        d[y]=0
    else:
        d[x]=0
su=0
for f in range(n):
    su+=d[f]
print(su)

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

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

ans = set([])
for i in range(N):
  ans.add(i+1)


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

print(len(ans))

Solution (Python):
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=0
for v in range(1,n+1):
  for u in g[v]:
    if arr[u]>=arr[v]:
      break
  else:
    ans+=1
print(ans)

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

print(l.count(True))

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

for _ in range(m):
    a, b = list(map(int, input().split()))
    ah = hlist[a-1]
    bh = hlist[b-1]

    if ah>bh:
        glist[b-1] = 0
    elif ah < bh:
        glist[a-1] = 0
    else:
        glist[a-1] = 0
        glist[b-1] = 0

print(sum(glist))

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