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())
a=[0]
a= a + list(map(int,input().split()))
v=[[] for i in range(n+1)]
for t in range(m):
	x,y=map(int,input().split())
	v[x].append(y)
	v[y].append(x)
ans=0
for i in range(1,n+1):
	c=1
	for j in v[i]:
		if a[j]>=a[i]:
			c=0
	if c:
		ans+=1
print(ans)

Solution (Python):
from collections import defaultdict


n, m = map(int, input().split())
*h, = map(int, input().split())
d = defaultdict(list)
for i in range(m):
    a, b = map(int, input().split())
    d[a - 1].append(b - 1)
    d[b - 1].append(a - 1)

ans = 0

for i in range(n):
    is_good = True
    for lighthouse in d[i]:
        
        if h[i] > h[lighthouse]:
            continue
        is_good = False
        
        break

    if is_good:
        
        ans += 1

print(ans)

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

Solution (Python):
import copy
n,m = map(int,input().split())
ht = [x for x in input().split()]
hl = {x + 1 : int(ht[x]) for x in range(len(ht))}
mx = {h:0 for h in hl}
for i in range(m):
    l,r = map(int,input().split())
    mx[l] = max(mx[l],hl[r])
    mx[r] = max(mx[r],hl[l])
cnt = 0
for h in hl:
    if mx[h] < hl[h]:
        cnt += 1
print(cnt)

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

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


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

for i in range(m):
    ar = [int(s) for s in input().split()]
    gr[ar[0]-1].append(ar[1])
    gr[ar[1]-1].append(ar[0])
    


ans = n

for i in range(n):
    ar = gr[i]
    mx = h[i]
    for j in ar:
        if(h[j-1] >= mx):
            ans -= 1
            break

print(ans)

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

kotae=[True]*N

for j in range(M):
  A, B = list(map(int, input().split()))
  if H[A-1] > H[B-1]:
    kotae[B-1]=False
  if H[A-1] < H[B-1]:
    kotae[A-1]=False
  if H[A-1] == H[B-1]:
    kotae[B-1]=False
    kotae[A-1]=False
ans = 0

for k in kotae:
  if k:
    ans +=1
print(ans)

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
x = [list(map(int,input().split())) for nesya in range(m)]
k = [1]*n
for route in x:
  h1 = route[0]-1
  h2 = route[1]-1
  if h[h1] < h[h2]:
    k[h1] = 0
  elif h[h1] > h[h2]:
    k[h2] = 0
  else:
    k[h1] = 0
    k[h2] = 0
print(sum(k))

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

Solution (Python):
N, M = (int(x) for x in input().split())
H = [int(x) for x in input().split()]

high = set()
low = set()
lonely = set()

for i in range(M):
	i1, i2 = [int(x) for x in input().split()]
	if H[i1 - 1] > H[i2 - 1]:
		high.add(i1)
		low.add(i2)
	elif H[i1 - 1] < H[i2 - 1]:
		high.add(i2)
		low.add(i1)
	else:
		low.add(i1)
		low.add(i2)
	lonely.add(i1)
	lonely.add(i2)

result = len((high - low)) + (N  - len(lonely))
print(result)

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

H_t = input().split()
H = [int(s) for s in H_t]


ma = [0]*N

good_count = 0



for j in range(M):
    a, b = map(int, input().split())
    
    ma[a-1] = max(ma[a-1], H[b-1]) 
    ma[b-1] = max(ma[b-1], H[a-1]) 
    
    
for i in range(N):
    if H[i] > ma[i]:
        good_count +=1
print(good_count)

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


def main():
    n, m = map(int, readline().rstrip().split())
    hList = list(map(int, readline().rstrip().split()))
    hAns = [1] * n
    for i in range(m):
        a, b = map(int, readline().rstrip().split())
        if hList[a - 1] > hList[b - 1]:
            hAns[b - 1] = 0
            continue
        if hList[a - 1] < hList[b - 1]:
            hAns[a - 1] = 0
            continue
        hAns[a - 1] = 0
        hAns[b - 1] = 0
    print(sum(hAns))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    hList = list(map(int, input().split()))
    hAns = [1] * n
    for i in range(m):
        a, b = map(int, input().split())
        if hList[a - 1] > hList[b - 1]:
            hAns[b - 1] = 0
            continue
        if hList[a - 1] < hList[b - 1]:
            hAns[a - 1] = 0
            continue
        hAns[a - 1] = 0
        hAns[b - 1] = 0
    print(sum(hAns))


if __name__ == '__main__':
    main()

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

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

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

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

for j in range(M):
    if H[List[j][0]-1]>H[List[j][1]-1]:
        sup_list[List[j][1]-1]=0
    elif H[List[j][0]-1]==H[List[j][1]-1]:
        sup_list[List[j][0]-1]=0
        sup_list[List[j][1]-1]=0
    else:
        sup_list[List[j][0]-1]=0


print(sum(sup_list))

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

root = [[] for i in range(N)]
for i in range(M):
  
  root[A[i]-1].append(H[B[i]-1])
  root[B[i]-1].append(H[A[i]-1])

count = 0
for i in range(N):
  if len(root[i]) == 0:
    count+=1
  else:
    if H[i] > max(root[i]):
      count+=1
print(count)

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

Solution (Python):
from math import sqrt

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

for i in range(m):
    u,v = map(int,input().split())
    if(graph.get(u-1,0) == 0):
        graph[u-1]=[v-1]
    else:
        graph[u-1].append(v-1)
    if (graph.get(v - 1, 0) == 0):
        graph[v - 1] = [u - 1]
    else:
        graph[v - 1].append(u - 1)
ans=0
for key in graph:
    flag=True
    for obs in graph[key]:
        if(heights[key]<=heights[obs]):
            flag=False
            break
    if(flag):
        ans+=1
ans += (n-len(graph.keys()))
print(ans)

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

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

print(good_list.count(1))

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

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

A=[0]*(N+1)
for i in range(M):
    x,y=map(int,input().split())
    A[x]=max(A[x],H[y-1])
    A[y]=max(A[y],H[x-1])

count=0
for i in range(1,N+1):
    if H[i-1]>A[i]:
        count+=1

print(count)

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

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

bad_two = set(bad)
ans = n - len(bad_two)
print(ans)

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

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

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

obser = {}

for i in range(1, n+1):
    obser[i] = []

for i in range(m):
    obser[a[i]].append(b[i])
    obser[b[i]].append(a[i])
    
ans = 0

for i in range(1, n+1):
    target_height = h[i-1]
    invest_obser = obser[i]
    count = 0
    for obs in invest_obser:
        if target_height > h[obs-1]:
            count += 1
    if len(invest_obser) == count:
        ans += 1

print(ans)

Solution (Python):
import itertools
import math
import fractions
import functools
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = []
for i in range(m):
    ai, bi = map(int, input().split())
    ab.append([ai-1,bi-1])

v = [True]*n
for i in range(m):
    if h[ab[i][0]] > h[ab[i][1]]:
        v[ab[i][1]] = False
    elif h[ab[i][0]] < h[ab[i][1]]:
        v[ab[i][0]]= False
    else:
        v[ab[i][0]]= False
        v[ab[i][1]]= False

print(v.count(True))

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

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

print(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()))
road = []
for i in range(M):
    road.append(list(map(int,input().split())))

bad_ob = []

for i in range(M):
    if H[road[i][0]-1] > H[road[i][1]-1]:
        bad_ob.append(road[i][1]-1)
    elif H[road[i][0]-1] < H[road[i][1]-1]:
        bad_ob.append(road[i][0]-1)
    else:
        bad_ob.append(road[i][0]-1)
        bad_ob.append(road[i][1]-1)


print(N-len(set(bad_ob)))

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

n, m = map(int, input().split())
h = list(map(int, input().split()))
g = collections.defaultdict(list)
good = [True] * n
for i in range(m):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	g[a].append(b)
	g[b].append(a)
for i in range(n):
	found = False
	for j in g[i]:
		if h[j] >= h[i]:
			found = True
			break
	if found:
		good[i] = False
res = sum(good)
print(res)

Solution (Python):
import numpy as np

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

for i in range(m):
    a,b = map(int,input().split())
    a -=1
    b -=1
    if h[a] >= h[b]: ok[b] = 1
    if h[b] >= h[a]: ok[a] = 1
nplist = np.array(ok)
print(np.count_nonzero(nplist == 0))

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

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

Solution (Python):
N,M = [int(x.strip()) for x in input().split()]
h_list = [int(x.strip()) for x in input().split()]
ok_list = [True] * N

for i in range(M):
    A,B = [int(x.strip()) for x in input().split()]
    if (h_list[A-1] == h_list[B-1]):
        ok_list[A-1] = False
        ok_list[B-1] = False
    elif (h_list[A-1] < h_list[B-1]):
        ok_list[A-1] = False
    else:
        ok_list[B-1] = False

ans = sum(v for v in ok_list)
print(ans)

Solution (Python):
class Mount():
    def __init__(self, i, H):
        self.i = i
        self.H = H
        self.rel_H = []
        self.max_H = 0

    def add_rel_H(self, H):
        self.rel_H.append(H)
        if self.max_H < H:
            self.max_H = H

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

d_mount = {}
for i, H in enumerate(input().split()):
	d_mount[i+1] = Mount(i+1, int(H))
    
inputs = [input() for i in range(M)]
for l in inputs:
    A = int(l.split()[0])  
    B = int(l.split()[1])  
    d_mount[A].add_rel_H(d_mount[B].H)
    d_mount[B].add_rel_H(d_mount[A].H)

count = 0
for k, v in d_mount.items():
    if len(v.rel_H) == 0:
        count += 1
    elif v.max_H < v.H:
        count += 1
        
print(count)

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

g = [True for _ in range(N)]
for _ in range(M):
    a, b = [int(_)-1 for _ in input().split()]
    if(H[a] <= H[b]):
        g[a] = False
    if(H[b] <= H[a]):
        g[b] = False
ans = g.count(True)
print(ans)

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

if __name__ == '__main__':
 	main()

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

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

n, m = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
ans = 0
for i in range(n):
    flag = 1
    for j in g[i]:
        if h[j] >= h[i]:
            flag = 0
            break
    if flag:
        ans += 1
print(ans)

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

Solution (Python):
n,m=map(int,input().split())
l=list(map(int,input().split()))
a=[0]*n
for i in range(m):
    x,y=map(int,input().split())
    a[x-1]=max(l[y-1],a[x-1])
    a[y-1]=max(l[x-1],a[y-1])
ans=0
for i in range(n):
    if l[i]>a[i]:
        ans+=1 
print(ans)

Solution (Python):
N, M = map(int, input().split())
hills = list(map(int, input().split()))
t_or_f = [True] * len(hills)

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    
    if hills[a] < hills[b]:
        t_or_f[a] = False
    elif hills[a] > hills[b]:
        t_or_f[b] = False
    else:
        t_or_f[a] = False
        t_or_f[b] = False

print(sum(t_or_f))

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

print(HP.count(0))

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

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

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

print(ans)

Solution (Python):

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

Solution (Python):
import collections
N,M=map(int,input().split())    
H=list(map(int,input().split()))
ans=[1]*N
for _ in range(M):
    AB=list(map(int,input().split()))
    if H[AB[0]-1] < H[AB[1]-1]:
        ans[AB[0]-1]=0
    elif H[AB[0]-1] > H[AB[1]-1]:
        ans[AB[1]-1]=0
    else:
        ans[AB[0]-1]=0
        ans[AB[1]-1]=0

print(ans.count(1))

Solution (Python):
"""
Peaks
AtCoder丘陵にはN個の展望台があり、展望台iの標高はHiです。
また、異なる展望台どうしを結ぶM本の道があり、道jは展望台Ajと展望台Bjを結んでいます。
展望台iが良い展望台であるとは、展望台iから一本の道を使って辿り着けるどの展望台よりも展望台iの方が標高が高いことをいいます。
展望台iから一本の道を使って辿り着ける展望台が存在しない場合も、展望台iは良い展望台であるといいます。
良い展望台がいくつあるか求めてください。
"""
N, M = map(int, input().split())
H = list(map(int, input().split()))

n = [1] * N

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

Solution (Python):



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


ans_list = [1]*N
ans = 0


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


for a in ans_list:
    if a>0:
        ans += 1


print(ans)

Solution (Python):
"""
~~ author : dokueki
~~ created : 10~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n, m = map(int, sys.stdin.readline().split())
    h = list(map(int, sys.stdin.readline().split()))
    ans = [True]*n
    for i in range(m):
        a, b = map(int, sys.stdin.readline().split())
        a -= 1
        b -= 1
        if h[a] < h[b]:
            ans[a] = False
        elif h[a] > h[b]:
            ans[b] = False
        else:
            ans[a], ans[b] = False, False
    print(sum(ans))


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()

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

print(ans)

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

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 v in range(N):
    flag = True
    
    for nv in G[v]:
        flag &= H[v]>H[nv]
    
    if flag:
        ans += 1

print(ans)

Solution (Python):
N, M = map(int, input().split())
H_list = list(map(int, input().split()))
Check_list = ["OK" for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    if H_list[A-1] > H_list[B-1]:
        Check_list[B-1] = "NG"
    elif H_list[A-1] < H_list[B-1]:
        Check_list[A-1] = "NG"
    elif H_list[A-1] == H_list[B-1]:
        Check_list[A-1] = "NG"
        Check_list[B-1] = "NG"
S = 0
for i in range(N):
    if Check_list[i] == "OK":
        S += 1
print(S)

Solution (Python):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, M = [int(x) for x in stdin.readline().rstrip().split()]

H = [0] + [int(x) for x in stdin.readline().rstrip().split()]
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]

near_max = [0 for _ in range(N+1)]

for A, B in AB:
    near_max[A] = max(near_max[A], H[B])
    near_max[B] = max(near_max[B], H[A])

ans = 0

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

print(ans)

Solution (Python):
from collections import defaultdict

n, m= list(map(int,input().split()))
h = list(map(int,input().split()))
h = [0] + h

good = [False] + [True]*n

while m:
    m -= 1
    a, b = list(map(int,input().split()))
    if h[a] < h[b]:
        good[a] = False
    elif h[a]==h[b]:
        good[a] = good[b] = False
    else:
        good[b] = False

print(good.count(True))

Solution (Python):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, M = [int(x) for x in stdin.readline().rstrip().split()]

H = [int(x) for x in stdin.readline().rstrip().split()]
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]

dic = {}
for i in range(N):
    dic[i+1] = []

for A, B in AB:
    dic[A].append(B)
    dic[B].append(A)

ans = 0
i = len(dic)
while i > 0:
    key = i
    values = set(dic[i])
    near_H = [H[value-1] for value in values]
    if near_H:
        if H[key-1] > max(near_H):
            ans += 1
    else:
        ans += 1
    i -= 1

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, m = na()
h = na()
mh = [0 for i in range(n)]
for i in range(m):
    a, b = na()
    mh[a-1] = max(mh[a-1], h[b-1])
    mh[b-1] = max(mh[b-1], h[a-1])
ans = 0  
for i in range(n):
    if h[i] > mh[i]:
        ans += 1
print(ans)

Solution (Python):
import sys

n,m = (int(i) for i in input().split())

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

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

hantei = [True]*n

for i in range(m):
    if h[a[i]] < h[b[i]]:
        hantei[a[i]] = False
    elif h[a[i]] > h[b[i]]:
        hantei[b[i]] = False
    else:
        hantei[a[i]] = hantei[b[i]] = False

ans = 0

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

print(ans)

Solution (Python):
N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)
def input():
	return sys.stdin.readline()[:-1]

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

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

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

cnt = 0
for i in range(n):
	h = H[i]
	flag = 1
	for nxt in edge[i]:
		
		
		if H[nxt] >= h:
			flag = 0
			break
		elif H[nxt] < h: continue
	if flag: cnt += 1

print(cnt)

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

Solution (Python):
from collections import defaultdict
import sys
sys.setrecursionlimit(100000000)
def DFS(u,G,H,A,visited,P):
    visited[u]=True
    for v in G[u]:
        if not (min(u,v),max(u,v)) in P:
            if H[u-1]>H[v-1]:
                    A[u]+=1
            elif H[v-1]>H[u-1]:
                    A[v]+=1
            P.add((min(u,v),max(u,v)))
        if not visited[v]:
            DFS(v,G,H,A,visited,P)

def DFSUtil(G,H,N):
    visited=[False]*(N+1)
    A=[0]*(N+1)
    P=set()
    for u in G:
        if (not visited[u]):
            DFS(u,G,H,A,visited,P)
    return A
N,M=map(int,input().strip().split())
H=list(map(int,input().strip().split()))
G=defaultdict(list)

for i in range(M):
    u,v=map(int,input().strip().split())
    G[u].append(v)
    G[v].append(u)
A=DFSUtil(G,H,N)
cnt=0
for i in range(1,N+1):
    neighbours=len(list(set(G[i])))
    if neighbours==A[i]:
        cnt+=1
print(cnt)

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

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

Solution (Python):

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

H = [0] + list(map(int,input().split()))

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

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

count = 0

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

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

ans_label = [1]*len(H)

new_A_B = []

for ele in A_B:
    if H[ele[0]-1] < H[ele[1]-1]:
        new_A_B.append(ele[0])
    elif H[ele[0]-1] > H[ele[1]-1]:
        new_A_B.append(ele[1])
    else:
        new_A_B.append(ele[0])
        new_A_B.append(ele[1])





for ele in new_A_B:
    ans_label[ele-1] = 0



print(sum(ans_label))

Solution (Python):
N, M = tuple(int(i) for i in input().split(" "))
height = [int(i) for i in input().split(" ")]
road = []
for i in range(N):
    road.append([])
for i in range(M):
    temp = [int(j) - 1 for j in input().split(" ")]
    road[temp[0]].append(temp[1])
    road[temp[1]].append(temp[0])

goodH = [1 for i in range(N)]
ans = 0
for i in range(N):
    if goodH[i]:
        for j in road[i]:
            if height[i] > height[j]:
                goodH[j] = 0
            elif height[i] == height[j]:
                goodH[j] = 0
                goodH[i] = 0
                break
            else:
                goodH[i] = 0
                break
        else:
            ans += 1
print(ans)

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

Solution (Python):
from collections import defaultdict

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









graph = {}
for i in range(1, N + 1):
    graph[i] = {0}
for _ in range(M):
    A, B = map(int, input().split())
    graph[A].add(B)
    graph[B].add(A)



cnt = 0
for i in range(1, N + 1):
    if H[i] > max(H[j] for j in graph[i]):
        cnt += 1
print(cnt)

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

Solution (Python):
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
br = [[] for i in range(a)]
for i in range(b):
    x,y = map(int,input().split(" "))
    br[x-1].append(y-1)
    br[y-1].append(x-1)
ans = 0
for i in range(a):
    count = 0
    for r in br[i]:
        if ar[r] >= ar[i]:
            count += 1
    if count == 0:
        ans += 1
print(ans)

Solution (Python):
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
H.insert(0,0)
L = []
C = 0
for i in range(N+1):
    L.append(list())
for i in range(M):
    A, B = list(map(int, input().split()))
    L[A].append(B)
    L[B].append(A)
for i, l in enumerate(L):
    if i == 0:
        continue
    if len(l) == 0:
        C += 1
        continue
    for n in l:
        f = True
        if H[i] <= H[n]:
            f = False
            break
    if f:
        C += 1
print(C)