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 collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
G = [[] for _ in range(n)]
H = LI()
for _ in range(m):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]

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

print(ans)

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

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

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

ans=[0]*N


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


print(ans.count(0))

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

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

X=[0]*N
for a,b in AB:
	
	X[a] = max(X[a], H[b])
	X[b] = max(X[b], H[a])

ans=0
for i in range(N):
	if H[i] > X[i]: ans += 1

print(ans)

Solution (Python):
def main():
    from builtins import int, map, list, print
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, M = input_number_list()
    H = input_number_list()
    d = defaultdict(lambda: True)

    for i in range(M):
        a, b = input_number_list()
        if H[a - 1] <= H[b - 1]:
            d[a - 1] = False
        if H[a - 1] >= H[b - 1]:
            d[b - 1] = False
    cnt = 0
    for i in range(N):
        if d[i]:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin

import math


N, M = [int(x) for x in stdin.readline().rstrip().split()]
H = list(map(int, input().split()))
d = {}
for i in range(M):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    if H[a-1] < H[b-1]:
        d[a] = d.get(a, 0)+1
    elif H[a-1] > H[b-1]:
        d[b] = d.get(b, 0)+1
    else:
        d[a] = d.get(a, 0)+1
        d[b] = d.get(b, 0)+1
print(len(H)-len(d))

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

print(l.count(True))

Solution (Python):

import numpy as np
from collections import deque
n, m = list(map(int, input().split()))
H = np.array(list(map(int, input().split())))
A = [0]*m
B = [0] * m
path = {}

for i in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    if(a in path.keys()):
        path[a].append(b)
    else:
        path[a] = [b]
    if(b in path.keys()):
        path[b].append(a)
    else:
        path[b] = [a]
count = 0

for i, h in enumerate(H):
    if not (i in path.keys()):
        count += 1
        continue
    if (max(H[path[i]]) < h):
        count += 1
print(count)

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

Solution (Python):
from collections import defaultdict as d

n, m = map(int, input().split())
h = list(map(int, input().split()))
adj = d(list)
s = set()
for j in range(m):
	a, b = map(int, input().split())
	adj[a].append(b)
	adj[b].append(a)
	s.add(a)
	s.add(b)

res = 0
for i in range(1, n+1):
	if i not in s:
		res += 1
for k, v in adj.items():
	f = 1
	for i in adj[k]:
		if h[k-1] <= h[i-1]:
			f = 0
	if f:
		res += 1
print(res)

Solution (Python):
import sys
import numpy as np

read = sys.stdin.read

n, m = map(int, input().split())
h = list(map(int, input().split()))
way = np.array(read().split(), dtype=np.int64).reshape([m,2]) - 1

o = np.ones(n)
for i in way:
    a, b = i
    if h[a] <= h[b]:
        o[a] = 0
    if h[b] <= h[a]:
        o[b] = 0
ans = np.count_nonzero(o)
print(ans)

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

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


for i in range(n):
    m = 0
    if len(ki[i]) == 0:
        cnt += 1
        continue
    for j in ki[i]:
        m = max(m, h[j])
    if h[i] > m:
        
        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)]

l = [True for _ in range(n)]
for a, b in ab:
    if h[a-1] > h[b-1]:
        l[b-1] = False
    elif h[a-1] < h[b-1]:
        l[a-1] = False
    else:
        l[a-1] = l[b-1] = False

print(len(list(filter(lambda x: x, l))))

Solution (Python):
n , m = map(int, input().split())
h = list(map(int, input().split()))
d = dict()
for i in range(m):
    a,b = list(map(int, input().split()))
    if a not in d:
        d[a] = set()
    if b not in d:
        d[b] = set()
    d[a].add(b)
    d[b].add(a)
ans = 0
for val in d:
    ans += 1
    r = d[val]
    for j in r:
        if h[val-1] <= h[j-1]:
            ans -= 1
            break

vals = len(list(d.values()))
l = n - vals
print(ans + l)

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

d = {}
for i in range(N):
    d[i] = set()

for _ in range(M):
    A, B = list(map(int, input().split()))
    d[A-1].add(B-1)
    d[B-1].add(A-1)

cnt = 0
for i in range(N):
    good = True
    for neighbor in d[i]:
        if H[neighbor] >= H[i]:
            good = False

    if good:
        cnt += 1
        

print(cnt)

Solution (Python):
x = [int(i) for i in input().split()]
n = x[0]
m = x[1]
y = [int(i) for i in input().split()]
ans = [True for i in range(n)]
dic = {}
for i in range(len(y)) :
    dic[i+1] = y[i]
for i in range(m) :
    p = [int(j) for j in input().split()]
    a = y[p[0]-1]
    b = y[p[1]-1]
    c = p[0]
    d = p[1]
    if a == b :
        ans[c-1] = False
        ans[d-1] = False
    elif a >b :
        ans[d-1] = False
    else :
        ans[c-1] = False
count = 0 
for i in range(n):
    if ans[i]:
        count += 1
print(count)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
graph = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a - 1].add(b - 1)
    graph[b - 1].add(a - 1)

good = [-1] * N
for i in range(N):
    if good[i] != -1:
        continue
    if not graph[i]:
        good[i] = 1
    elif all(H[nei] < H[i] for nei in graph[i]):
        good[i] = 1
        for nei in graph[i]:
            good[nei] = 0
    else:
        good[i] = 0

print(sum(good))

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

n, m = nm()
h = nl()
w = [True]*n
for _ in range(m):
    a, b = nm()
    a -= 1; b -= 1
    if h[a] <= h[b]:
        w[a] = False
    if h[a] >= h[b]:
        w[b] = False
print(sum(w))

Solution (Python):
def main():
    N, M = [int(x) for x in input().split()]
    H = [0] + [int(x) for x in input().split()]
    flag = [0] + [1] * N
    for _ in range(M):
        a, b = [int(x) for x in input().split()]
        if H[a] >= H[b]:
            flag[b] = 0
        if H[b] >= H[a]:
            flag[a] = 0
    
    print(sum(flag))

if __name__ == "__main__":
    main()

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

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

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

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

n_list = [1]*n

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

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

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

Solution (Python):

"""
Created on Sun May  3 20:56:43 2020
"""

import sys


sys.setrecursionlimit(10 ** 9)


mod = 10**9+7


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

graph = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(lambda x : int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)

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

print(ans)

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
edges=[[] for i in range(n)]
ans=0
for  i in range(m):
    a,s=map(int,input().split())
    edges[a-1].append(s-1)
    edges[s-1].append(a-1)
for  i in range(n):

    if edges[i]!=[]:
        now=h[i]
        for ii in edges[i]:
            if h[ii]>=now:break
        else:ans+=1
    else:ans+=1
print(ans)

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

GD = [0]*N

for A ,B in AB:
    HA = H[A-1]
    HB = H[B-1]
    if HA < HB:
        GD[A-1] -= 1
    elif HA > HB:
        GD[B-1] -= 1
    else:
        GD[A-1] -= 1
        GD[B-1] -= 1

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

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

ANS = [True] * N

for ab in AB:
    a = ab[0] - 1
    b = ab[1] - 1

    if H[a] > H[b]:
        ANS[b] = False
    elif H[a] == H[b]:
        ANS[a] = ANS[b] = False
    else:
        ANS[a] = False

print(ANS.count(True))

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

for a, b in links:
  if H[a-1] <= H[b-1]:
    survivors[a-1] = False
  if H[b-1] <= H[a-1]:
    survivors[b-1] = False

print(sum(survivors))

Solution (Python):
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math


NN = 202020
MOD = 10**9+7

INF = float("inf")

n, m = map(int, input().split())
H = list(map(int, input().split()))
Edge = [list(map(int, input().split())) for i in range(m)]

graph = [[] for _ in range(n)]
for e in Edge:
    graph[e[0]-1].append(e[1]-1)
    graph[e[1]-1].append(e[0]-1)

count = 0
for i in range(n):
    for adj in graph[i]:
        if H[adj] >= H[i]:
            break
    else:
        count += 1

print(count)

Solution (Python):
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    maxes = [0] * (N + 1)
    for i in range(M):
        A, B = map(int, input().split())
        maxes[A] = max(maxes[A], H[B-1])
        maxes[B] = max(maxes[B], H[A-1])
        
    
    print(sum([1 for h, m in zip(H, maxes[1:]) if h > m]))


if __name__ == '__main__':
    main()

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

count = 0
for i,j in enumerate(c): 
    flag = True
    for l in j:
        if h[i]<=h[l-1]:
            flag = False
            continue
    if flag:
        count += 1
print(count)

Solution (Python):
def main():
    n, m = map(int, input().split())
    num_list = list(map(int, input().split()))
    m_list = []
    for _ in range(m):
        m_list.append(list(map(int,input().split())))

    good_num = n

    list2 = [[] * 1 for i in range(n)]

    for i in range(m):
        list2[m_list[i][0]-1].append(m_list[i][1])
        list2[m_list[i][1]-1].append(m_list[i][0])

    for i in range(n):
        for j in range(len(list2[i])):
            if num_list[i] <= num_list[list2[i][j]-1]:
                good_num -= 1
                break

    print(good_num)

if __name__ == '__main__':
    main()

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):
N,M =list(map(int,input().split()))
H = list(map(int,input().split()))

h = [0] * N 
ans = 0
for i in range(M):
    A,B = list(map(int,input().split()))
    h[A-1] = max(H[B-1],h[A-1])
    h[B-1] = max(H[A-1],h[B-1])

for i in range(N):
    if H[i] >h[i] or h[i] == 0:
        ans += 1
print(ans)

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

Solution (Python):

n, m = map(int, input().split())
lh = [0] + list(map(int, input().split()))
lm = [[] for i in range(n+1)]

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

ans = 0

for i in range(1, n+1):
    good = True
    for j in lm[i]:
        if lh[i] <= lh[j]:
            good = False

    if good:
        ans += 1

print(ans)

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

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

g=[[]for _ in range(n)]
for _ 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):
    M=max([h[c] for c in g[i]]+[0])
    if M<h[i]:
        ans+=1
print(ans)

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

v = [[] for i in range(n)]
for i in range(m):
	v[a[i]-1].append(b[i]-1)
	v[b[i]-1].append(a[i]-1)
count = 0
for i in range(n):
	max = h[i]
	cnt = h[i]
	unta = 1
	for j in v[i]:
		cnt = h[j]
		if max <= cnt:
			max = cnt
			unta = 0
	count += unta
print(count)

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

observation_joint = dict()
for i in range(n):
    observation_joint[i] = []

while m:
    a,b = map(int, input().split())
    a-=1
    b-=1
    observation_joint[a].append(b)
    observation_joint[b].append(a)
    m-=1


count = 0
for obs, joints in observation_joint.items():
    if joints == []:
        count += 1
    else:
        good_obs = True
        for obs2 in joints:
            if elivation[obs2] >= elivation[obs]:
                good_obs = False
                break
        if good_obs:
            count += 1
print(count)

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

Solution (Python):


N, M = map(int, input().split())
H = list(map(int, input().split()))
d = {i:H[i-1] for i in range(1, N+1)}
F = [True for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    if d[a] <= H[b-1]:
        F[a-1] = False
    if d[b] <= H[a-1]:
        F[b-1] = False
print(sum(F))

Solution (Python):
N, M = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
E = [None] * M
for i in range(M):
    E[i] = [int(x) - 1 for x in input().split()]

Vbad = [0] * N
for i in range(M):
    
    if H[E[i][0]] > H[E[i][1]]:
        Vbad[E[i][1]] += 1
    elif H[E[i][0]] < H[E[i][1]]:
        Vbad[E[i][0]] += 1
    else:
        Vbad[E[i][0]] += 1
        Vbad[E[i][1]] += 1

ans = 0
for j in range(N):
    if Vbad[j] == 0:
        ans += 1

print(ans)

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

def main():
    n, m = map(int, input().split())
    h_li = list(map(int, input().split()))
    bad_li = []

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

        if h_li[a-1] > h_li[b-1]:
            bad_li.append(b)
        elif h_li[a-1] < h_li[b-1]:
            bad_li.append(a)
        else:
            bad_li.append(a)
            bad_li.append(b)

    print(n - len(set(bad_li)))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    H = lr()
    road = [-1]*N
    for i in range(M):
        a, b = lr()
        mab = max(H[a-1], H[b-1])
        if H[a-1] == H[b-1]:
            road[a-1] = float('inf')
            road[b-1] = float('inf')
        else:
            road[a-1] = max(mab, road[a-1])
            road[b-1] = max(mab, road[b-1])
    ans = 0
    for i in range(N):
        if road[i] == H[i] or road[i] == -1:
            ans += 1
    print(ans)
resolve()

Solution (Python):
def main():
    N, M = map(int, input().split())
    lst = list(map(int, input().split()))
    adj = [[] for i in range(N)]
    cnt = 0
    
    for _ in range(M):
        a, b = map(int, input().split())
        adj[a-1].append(b-1)
        adj[b-1].append(a-1)
    for index, ad in enumerate(adj):
        takasa = lst[index]
        good = True
        
        for tonari in ad:
            if takasa <= lst[tonari]:
                good = False
                break
        
        if good:
            cnt += 1
    print(cnt)
main()

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

Solution (Python):
import sys

N, M = map(int, sys.stdin.readline().rstrip().split())
Hs = list(map(int, sys.stdin.readline().rstrip().split()))

isnice = [True] * N

for j in range(M):
    Aj, Bj = map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split())
    if Hs[Aj] == Hs[Bj]:
        isnice[Aj] = isnice[Bj] = False
    elif Hs[Aj] < Hs[Bj]:
        isnice[Aj] = False
    else:
        isnice[Bj] = False

print(sum(isnice))

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

peaks = [True] * n

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

print(peaks.count(True))

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

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

List=list(map(int,input().split()))
ans = [0 for i in range(N)]


for i in range(M):
  A,B = map(int,input().split())
  HA = List[A-1]
  HB = List[B-1]
  if HA > HB:
    ans[B-1] = -1
  elif HB > HA:
    ans[A-1] = -1
  else:
    ans[A-1] = -1
    ans[B-1] = -1

cnt = 0    
for i in ans:
  if i == 0:
    cnt+= 1

print(int(cnt))

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
    if H[a-1] >= H[b-1]:
        ans[b-1] = 0
    
print(ans.count(1))

Solution (Python):
tenbou, road = map(int, input().split())
height = list(map(int, input().split()))
route = [[] for _ in range(tenbou)]
for i in range(road):
    _from, _to = map(int, input().split())
    route[_from-1].append(_to-1)
    route[_to-1].append(_from-1)
ans = 0
for i in range(tenbou):
    m = height[i]
    
    for j in route[i]:
        if(m <= height[j]):
            break
    else:
        ans += 1
print(ans)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
dist = [[] for i in range(n)]
ans = 0
for i in range(m):
    a, b = map(int, input().split())
    dist[a - 1].append(b - 1)
    dist[b - 1].append(a - 1)
def higher(n):
    flag = True
    for i in dist[n]:
        if h[n] <= h[i]:
            flag = False
    return flag
for i in range(n):
    if higher(i):
        ans += 1
print(ans)

Solution (Python):




import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())
    hh=list(map(int, readline().rstrip().split()))
    good=[1]*n
    for i in range(m):
        a,b=map(int, readline().rstrip().split())
        a-=1
        b-=1
        if hh[a]<=hh[b]:
            good[a]=0
        if hh[b]<=hh[a]:
            good[b]=0
    print(sum(good))

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

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

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
    if H[A-1] <= H[B-1]:
        ans[A-1] = 0

print(sum(ans))

Solution (Python):
N,M=list(map(int,input().split()))
h_list=list(map(int,input().split()))
h2_list=[True]*N

for _ in range(M):
    A,B=list(map(int,input().split()))
    if h_list[A-1] < h_list[B-1]:
        h2_list[A-1] = False
    elif h_list[A-1] > h_list[B-1]:
        h2_list[B-1] = False
    else:
        h2_list[A-1] = False
        h2_list[B-1] = False


ans = 0
for h2 in h2_list:
    if h2:
        ans+=1
print(ans)

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

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

from collections import defaultdict

g = defaultdict(set)

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

    g[a].add(h[b - 1])
    g[b].add(h[a - 1])

ret = 0
for i in range(1, n + 1):
    for x in g[i]:
        if x >= h[i - 1]:
            break
    else:
        ret += 1

print(ret)

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

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

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

r=0
for i in range(len(h)):
    for j in range(len(h[i][1])):
        if h[i][0] <= h[h[i][1][j]][0]:
            break
    else:
        r+=1

print(r)

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


ab = [[] for i in range(n+1)]

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

for i in range(1,n+1):
    jibun = hi[i-1]
    flag = True
    
    
    for j in range(len(ab[i])):
        if jibun <= hi[ab[i][j]-1]:
            flag = False
            break
    if flag == True:
        ans += 1
        
print(ans)

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

flag=np.zeros(n)+1

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

Solution (Python):
import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
from itertools import combinations_with_replacement

def main():
    n,m=map(int,input().split())
    h=[int(i) for i in input().split()]
    t=[[] for _ in range(n)]
    for _ in range(m):
        a,b=map(int,input().split())
        t[a-1].append(h[a-1]-h[b-1])
        t[b-1].append(h[b-1]-h[a-1])
    
    HH=[]
    for i in t:
        try:
            HH.append(min(i))
        except:
            HH.append(1)
    
    ans=0
    for i in range(n):
        if HH[i]>0:
            ans+=1
    print(ans)

if __name__=="__main__":
    main()