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()))
road = [[]for _ in range(n+3)]
for i in range(m):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

e = [True]*n
ten = []
for i,a in enumerate(h):
    ten.append((a,i))

for a,i in sorted(ten,reverse=True):
    if e[i] == True:
        for r in road[i]:
            if a > h[r]:
                e[r] = False
            else:
                e[i] = False
            
print(e.count(True))

Solution (Python):

N,M = map(int, input().split())
H = input().split()
result = [True] * N
H_i = [int(s) for s in H]
bothCount = 0
for i in range(M):
    A,B = map(int, input().split())
    if(H_i[A-1] > H_i[B-1]):
        
        if(result[B-1] == True):
            result[B-1] = False
    elif(H_i[A-1] < H_i[B-1]):
        if(result[A-1] == True):
            result[A-1] = False
    else:
        result[A-1] = False
        result[B-1] = False
print(result.count(True))

Solution (Python):
import sys

if __name__ == '__main__':
    n, m = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    h = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    
    
    matrix = [[] for j in range(n)]

    for i in range(m):
        a, b = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
        a, b = a-1, b-1
        
        
        
        
        matrix[a].append(b)
        matrix[b].append(a)

    bads = {}
    good = 0
    
    for i in range(n):
        if bads.get(i, 0) == 1:
            continue
        
        for t in matrix[i]:
            if h[i] <= h[t]:
                break
            else:
                
                if t > i:
                    bads[t] = 1
        else:
            good += 1
    print(good)

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

n = a[0]
m = a[1]

all_kind = {i for i in range(1, n+1)}

for i in range(m):
    comb = list(map(int,input().split()))

    if(h[comb[0]-1] > h[comb[1]-1]):
        all_kind.discard(comb[1])
    elif(h[comb[0]-1] == h[comb[1]-1]):
        all_kind.discard(comb[0])
        all_kind.discard(comb[1])
    else:
        all_kind.discard(comb[0])

print(len(all_kind))

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

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

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

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


c=0
for i,it in enumerate(dist[1:]):
    hi = list(map(lambda x:H[x-1],it))

    if (list(filter(lambda x:H[i]<=x,hi)).__len__()==0):
        c+=1
    
print(c)

Solution (Python):
n,m=map(int, input().split())
h=list(map(int, input().split()))
dic = {}
ng = set()
chk = set()

for i in range(m):
  a,b=map(int, input().split())
  chk.add(a)
  chk.add(b)
  if h[a-1] == h[b-1]:
    ng.add(a)
    ng.add(b)
    if str(b) in dic:
      dic.pop(str(b))
    if str(a) in dic:
      dic.pop(str(a))
  elif h[a-1] > h[b-1]:
    if not a in ng:
      dic[str(a)] = h[a-1]
    ng.add(b)
    if str(b) in dic:
      dic.pop(str(b))
  else:
    if not b in ng:
      dic[str(b)] = h[b-1]
    ng.add(a)
    if str(a) in dic:
      dic.pop(str(a))
    
print(len(dic) + (n-len(chk)))

Solution (Python):
n,m=map(int,input().split())
h=[0]*n
r=[1]*n
h[:]=map(int,input().split())
for ii in range(m):
  a,b=map(lambda x: int(x)-1,input().split())
  if h[a]>=h[b]:
    r[b]=0
  if h[b]>=h[a]:
    r[a]=0
print(sum(r))

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

print(sum(nn))

Solution (Python):
n,m = map(int, input().split())
h_li = list(map(int, input().split()))
ans = [0]*n
goods = list()
bads = list()

for i in range(m):
  a, b = map(int, input().split())
  good = max(h_li[a-1], h_li[b-1])
  bad = min(h_li[a-1], h_li[b-1])
  if h_li[a-1] == h_li[b-1]:
    bads.append(a-1)
    bads.append(b-1)
    continue
  if good == h_li[a-1]:
    good_i = a-1
    bad_i = b-1
  else:
    good_i = b-1
    bad_i = a-1
  goods.append(good_i)
  bads.append(bad_i)

  
all_s = set(goods + bads)
goods = set(goods)
bads = set(bads)

no_paths = n - len(all_s)
bests = [ten for ten in goods if ten not in bads]

print(len(bests) + no_paths)

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

sm = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1] :
      sm.append(A)
    if H[B-1] <= H[A-1] :
      sm.append(B)
print(N - len(set(sm)))

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

roads = [[int(i) for i in input().split()] for j in range(M)]
roads2 = [[] for i in range(N)]

for spots in roads:
    roads2[spots[0]-1].append(spots[1])
    roads2[spots[1]-1].append(spots[0])

ans = 0
for spot in range(1, N+1):
    good = True
    for i in roads2[spot-1]:
        if H[spot-1] <= H[i-1]:
            good = False
            break
    if good:
        ans += 1

print(ans)

Solution (Python):
N, M = map(int, input().split())
graph = dict(zip(
    list (range(1, N+1)),
    [set() for i in range(N)]
))
height=list(map(int, input().split()))

for i in range(M):
    src, dest = map(int, input().split())
    graph[src].add(dest)
    graph[dest].add(src)


count = 0
for currNode in graph:
    flag = True
    for node in graph[currNode]:
        if height[currNode-1] <= height[node-1]:
            flag = False
    
    if flag:
        count += 1


print(count)

Solution (Python):






import sys,bisect,math,collections
sys.setrecursionlimit(15000)

N,M = map(int,sys.stdin.readline().split())
h = list(map(int,sys.stdin.readline().split()))
good = [1]*N

for _ in range(M):
    a,b = list(map(int,sys.stdin.readline().split()))
    if h[a-1] > h[b-1]:
        good[b-1] = 0
    elif h[a-1] < h[b-1]:
        good[a-1] = 0
    else:
        good[a-1] = 0
        good[b-1] = 0

print(sum(good))

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

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

ans =[1]*N

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

    if Peaks[a]>Peaks[b]:
        ans[b]=0
    elif Peaks[a]<Peaks[b]:
        ans[a]=0
    else:
        ans[a]=0
        ans[b]=0

print(sum(ans))

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


info_list = list()
for h in map(int, input().split()):
    info_list.append([h, 0, True])

for i in range(M):
    ai, bi = map(int, input().split())
    
    info_list[ai - 1][1] += 1
    info_list[bi - 1][1] += 1
    
    
    
    if info_list[ai - 1][0] < info_list[bi - 1][0]:
        
        info_list[ai - 1][2] = False
    elif info_list[ai - 1][0] > info_list[bi - 1][0]:
        
        info_list[bi - 1][2] = False
    else:
        
        
        info_list[ai - 1][2] = False
        info_list[bi - 1][2] = False
    


result = len([i for i in info_list if i[2]])
print(result)

Solution (Python):
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
all_list = []
r_list = {}
for i in range(m):
	a, b = map(int, input().split())
	all_list.append(a)
	all_list.append(b)
	if a in r_list.keys():
		r_list[a].add(b)
	else:
		r_list[a] = {b}
	if b in r_list.keys():
		r_list[b].add(a)
	else:
		r_list[b] = {a}
all_list = list(set(all_list))
count = n - len(all_list)
for k in r_list.keys():
	targets = r_list[k]
	height1 = h_list[k - 1]
	flag = True
	for t in targets:
		height2 = h_list[t - 1]
		if height1 <= height2:
			flag = False
	if flag:
		count += 1
print(count)

Solution (Python):
n,m = [int(ch) for ch in input().split()]
heights = [int(ch) for ch in input().split()]
graphs = []
for i in range(n):
    graphs.append([])
for i in range(m):
    roadInfo = [int(ch) for ch in input().split()]
    start = roadInfo[0]-1
    end = roadInfo[1]-1
    graphs[start].append(end)
    graphs[end].append(start)
res = []
for i in range(len(graphs)):
    isGood = True
    for v in graphs[i]:
        if heights[i] <= heights[v]:
            isGood = False
            break
    if isGood:
        res.append(i+1)
print(len(res))

Solution (Python):


def main():
    n, m = map(int, input().split())
    hlist = list(map(int, input().split()))
    tenbou_set = set(range(1, (n+1)))
    for i in range(m):
        a, b = map(int, input().split())
        if hlist[(a-1)] < hlist[(b-1)]:
            tenbou_set.discard(a)
        elif hlist[(a-1)] > hlist[(b-1)]:
            tenbou_set.discard(b)
        elif hlist[(a-1)] == hlist[(b-1)]:
            tenbou_set.discard(a)
            tenbou_set.discard(b)

    print(len(tenbou_set))

main()

Solution (Python):
N,M = map(int,input().split())
H_list = [int(i) for i in input().split()]

not_good_set = set()
not_good_count = 0
AB_list = []
for i in range(M) :
    AB_list.append([int(i) for i in input().split()])

for t in AB_list :
    A = t[0]
    B = t[1]

    if (A not in not_good_set) :
        if (H_list[A-1] <= H_list[B-1]) :
            not_good_set.add(A)
            not_good_count += 1

    if (B not in not_good_set) :
        if (H_list[B-1] <= H_list[A-1]) :
            not_good_set.add(B)
            not_good_count += 1
            continue

print(N - not_good_count)

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

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
    elif h[a-1]>h[b-1]:
        ans[b-1]=0
    else:
        ans[a-1]=0
        ans[b-1]=0
sum=0  
for i in range(n):
    sum+=ans[i]
print(sum)

Solution (Python):
n,m = map(int,input().split())
l={i for i in range(1,n+1)}
li=list(map(int,input().split()))
d={0}
for i in range(m):
    a,b=map(int,input().split())
    if li[a-1]<li[b-1]:
        d|={a}
    elif li[a-1]>li[b-1]:
        d|={b}
    else:
        d|={a,b}
print(len(l-d))

Solution (Python):


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


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


n = [0] * N

for m in range(M):
  A, B = map(int, input().split())
  
  
  n[A-1] = max(n[A-1], H[B-1])
  n[B-1] = max(n[B-1], H[A-1])
  


cnt = 0
for i in range(N):
  if H[i] > n[i]:
    cnt +=1
    
print(cnt)

Solution (Python):



import numpy as np







N, M = [int(x) for x in input().split()]

H = np.array([int(x) for x in input().split()])

good = [1] * N

road = []
for m in range(M):
    a, b = [int(x) for x in input().split()]

    if H[a-1] == H[b-1]:
        good[a-1] = 0
        good[b-1] = 0
    elif H[a-1] < H[b-1]:
        good[a-1] = 0
    else:
        good[b-1] = 0

print(sum(good))

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

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

ans = 0
for i in range(N):
    if len(H_list[i]) == 0:
        ans += 1
        continue
    if H[i] > max(H_list[i]):
        ans += 1
print(ans)

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

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

ans = l.count(0)
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)]

check = [True] * N

for ab in AB:
    
    if H[ab[0]-1] < H[ab[1] - 1]:
        check[ab[0]-1] = False
        
    elif H[ab[1]-1] < H[ab[0] - 1]:
        check[ab[1]-1] = False
    else:
        check[ab[0]-1] = False
        check[ab[1]-1] = False
    
print(sum(check))

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

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

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

r = [0]*N

for i, j in lst:
    i -= 1
    j -= 1
    if H[i] >= H[j]:
        if r[i] >= 0:
            r[i] = H[i]
        r[j] = -1
    if H[j] >= H[i]:
        if r[j] >= 0:
            r[j] = H[j]
        r[i] = -1


num = 0
for i in r:
    if i >= 0:
        num += 1

print(num)

Solution (Python):
from copy import deepcopy
N,M=map(int,input().split())
L=list(map(int,input().split()))
H={i+1:L[i] for i in range(N)}
d=deepcopy(H)
ans=N
for i in range(M):
  a,b=map(int,input().split())
  if a in d and b in d:
    ans-=1
    if H[a]<H[b]:
      _=d.pop(a)
    elif H[a]>H[b]:
      _=d.pop(b)
    else:
      ans-=1
      _=d.pop(a)
      _=d.pop(b)

  elif a in d:
    if H[a]>H[b]:
      continue
    else:
      ans-=1
      _=d.pop(a)
      
  elif b in d:
    if H[b]>H[a]:
      continue
    else:
      ans-=1
      _=d.pop(b)  

print(ans)

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

print(n-h2.count(0))

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

h = [int(x) for x in input().split(' ')]
o = ['Good'] * n

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

print(o.count('Good'))

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

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

import copy

C = [[] for j in range(N)]

for i in range(N):
    C[i].append(copy.copy(H[i]))

for i in range(M):
    if C[A[i]-1][0]<=H[B[i]-1]:
        C[A[i]-1].append(copy.copy(H[B[i]-1]))
    if C[B[i]-1][0]<=H[A[i]-1]:
        C[B[i]-1].append(copy.copy(H[A[i]-1]))

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

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

a = [0]*len(H)

for i in range(M):
    A = [int(x) for x in input().split()]
    if H[A[0]-1] > H[A[1]-1]:
        a[A[1]-1] += -1
    elif H[A[0]-1] == H[A[1]-1]:
        a[A[0]-1] += -1
        a[A[1]-1] += -1
    else:
        a[A[0]-1] += -1

print(a.count(0))

Solution (Python):
N, M = map(int, input().split())
H = [[0, []] for _ in range(N)]
tmp = list(map(int, input().split()))
H = [[i, set([])] for i in tmp]
for _ in range(M):
    a, b = map(int, input().split())
    H[a-1][1].add(b-1)
    H[b-1][1].add(a-1)
ans = 0
for h in H:
    flag = True
    for oh in h[1]:
        if h[0] <= H[oh][0]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

Solution (Python):
def peaks(lookup, hs, n):
    ans = 0
    for k in lookup.keys():
        for kk in lookup[k]:
            if hs[k-1] <= hs[kk-1]:
                ans -= 1
                break
        ans += 1
    print(ans + n - len(lookup.keys()))

if __name__ == "__main__":
    import sys
    from collections import defaultdict as DD
    lookup = DD(dict)
    n, m = [int(_) for _ in input().split()]
    hs = [int(_) for _ in input().split()]
    for i in range(m):
        a, b = [int(_) for _ in input().split()]
        lookup[a][b] = lookup[b][a] = True
    peaks(lookup, hs, n)

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
HL=[1]*N
ML=[list(map(int, input().split())) for _ in range(M)]
for m in ML:
    a=m[0]
    b=m[1]
    ah=H[a-1]
    bh=H[b-1]
    if ah > bh:
        HL[b-1]=0
    elif bh > ah:
        HL[a-1]=0
    else:
        HL[a-1]=0
        HL[b-1]=0
print(HL.count(1))

Solution (Python):
from collections import Counter
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
a=[]
b=[]
for i in range(m):
    hoge = list(map(int,input().split()))
    a.append(hoge[0])
    b.append(hoge[1])

tenbo = []
for i in range(m):
    if h[a[i]-1] > h[b[i]-1]:
        tenbo.append(b[i])
    elif h[a[i]-1] < h[b[i]-1]:
        tenbo.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        tenbo.append(a[i])
        tenbo.append(b[i])

print(n - len(Counter(tenbo)))

Solution (Python):


n, m = map(int, input().split())
H = list(map(int, input().split()))
routes = { i:[] for i in range(1, n+1) }
good_ten = 0

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

for i in routes.keys():
    for j in routes[i]:
        if H[j-1] >= H[i-1]:
            break
    else:
        good_ten += 1

print(good_ten)

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



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

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

for i in range(m):
    
    if h[a[i]-1]<h[b[i]-1] and (not a[i] in dame):
        dame.append(a[i])
    elif h[a[i]-1]>h[b[i]-1] and (not b[i] in dame):
        dame.append(b[i])
    elif h[a[i]-1]==h[b[i]-1] and (not a[i] in dame):
        dame.append(a[i])
    if h[a[i]-1]==h[b[i]-1] and (not b[i] in dame):
        dame.append(b[i])


print(n-len(dame))

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

Solution (Python):
N = [int(e) for e in input().split()]
height = [int(t) for t in input().split()]
root = []
a = []
ans = 0
for i in range(N[0]):
    a.append([])
for  i in range(N[1]):
    root.append([int(t) for t in input().split()])
for roots in root:
    t = a[roots[0] - 1]
    t.append(roots[1])
    a[roots[0] - 1] = t
    t = a[roots[1] -1]
    t.append(roots[0])
    a[roots[1] - 1] = t
for j in range(N[0]):
    if(a[j] == []):
        ans += 1
        continue
    for k in range(len(a[j])):
        if(height[j] <= height[a[j][k] -1]):
            break
    else:
        ans += 1
print(ans)

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

Solution (Python):

import numpy as np
 
nm = list(map(int,input().split()))
n, m = nm[0], nm[1]

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


check_H = [1]*n
count = 0

for i in range(m):
  cmp = list(map(int,input().split()))
  
  
  if( H[ cmp[0]-1 ] > H[ cmp[1]-1 ] ):
    if( check_H[ cmp[1]-1 ] == 1 ):
      check_H[ cmp[1]-1 ] = 0
      count += 1
    

  elif( H[ cmp[0]-1 ] < H[ cmp[1]-1 ] ):
    if( check_H[ cmp[0]-1 ] == 1 ):
      check_H[ cmp[0]-1 ] = 0
      count += 1
    
  
  else:
    if( check_H[ cmp[1]-1 ] == 1 ):
      check_H[ cmp[1]-1 ] = 0
      count += 1
    if( check_H[ cmp[0]-1 ] == 1 ):
      check_H[ cmp[0]-1 ] = 0
      count += 1
    


ans = n - count
print(ans)

Solution (Python):
import numpy

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

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

    if H[A-1] - H[B-1] > 0:
        l[B-1] = 0
    elif H[A-1] - H[B-1] < 0:
        l[A-1] = 0
    else:
        l[A-1] = 0
        l[B-1] = 0

print(list(l).count(1))

Solution (Python):
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
obs = [True]*n
ab = []

for i in range(m):
    ab.append(input().split())

for j in range(len(ab)):
    if h[int(ab[j][0]) - 1] > h[int(ab[j][1]) - 1]:
        obs[int(ab[j][1]) - 1] = False

    elif h[int(ab[j][1]) - 1] > h[int(ab[j][0]) - 1]:
        obs[int(ab[j][0]) - 1] = False

    elif h[int(ab[j][0]) - 1] == h[int(ab[j][1]) - 1]:
        obs[int(ab[j][0]) - 1] = False
        obs[int(ab[j][1]) - 1] = False

print(obs.count(True))

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

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

cnt = 0
for i in range(n):
    if tenbo[i][2] == 0:
        for j in tenbo[i][1]:
            if j != i and tenbo[j][0] >= tenbo[i][0]:
                tenbo[i][2] = -1
                break
        if tenbo[i][2] == 0:
            tenbo[i][2] = 1
            cnt += 1
            for j in tenbo[i][1]:
                if tenbo[j][2] == 0:
                    tenbo[j][2] = -1

print(cnt)

Solution (Python):
N, M = map(int, input().split())
p_list = [1 for _ in range(N)]
e_list = list(map(int, input().split()))
for _ in range(M):
    a, b = map(int, input().split())
    if e_list[a - 1] <= e_list[b - 1]:
        p_list[a - 1] = 0
    if e_list[b - 1] <= e_list[a - 1]:
        p_list[b - 1] = 0
print(sum(p_list))

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

Solution (Python):
n,m=map(int,input().split())
h_list=list(map(int,input().split()))
h_list_new=[]
for k in range(n):
    h_list_new.append(1)
for k in range(m):
    a,b=map(int,input().split())
    if h_list[a-1]>=h_list[b-1]:
        h_list_new[b-1]=0
    else:
        pass
    if h_list[a-1]<=h_list[b-1]:
        h_list_new[a-1]=0
    else:
        pass
print(h_list_new.count(1))

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())
    a -= 1
    b -= 1
    if h[a] > h[b]:
        t[b] = 0
    elif h[a] == h[b]:
        t[a] = 0
        t[b] = 0
    else:
        t[a] = 0
ans = 0
for i in t:
    if i==1:
        ans += 1
print(ans)

Solution (Python):

if __name__ == "__main__":
    N,M = list(map(int,input().split()))
    H = list(map(int,input().split()))
    goodlist = [1] * N
    for i in range(M):
        tmpA,tmpB = list(map(int,input().split()))
        if H[tmpA-1] < H[tmpB-1]:
            goodlist[tmpA-1] = 0
        elif H[tmpA-1] > H[tmpB-1]:
            goodlist[tmpB-1] = 0
        else:
            goodlist[tmpA-1] = 0
            goodlist[tmpB-1] = 0
    print(sum(goodlist))

Solution (Python):
N,M = map(int,input().split())
H = input().split()
good = [1]*N
import collections

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

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

answer_list = [0]*N

for _ in range(M):
  A, B = map(int, input().split())
  if H[A-1] > H[B-1]:
    answer_list[(B-1)] += 1
  elif H[B-1] > H[A-1]:
    answer_list[(A-1)] += 1
  else:
    answer_list[(A-1)] += 1
    answer_list[(B-1)] += 1
    
print(answer_list.count(0))

Solution (Python):
import math

n, m = map(int, input().split(" "))
hL = list(map(int, input().split(" ")))
hML = [True for _ in range(n)]

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

ans = 0
for b in hML:
    if b: ans += 1

print(ans)

Solution (Python):
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
route = {i: [] for i in range(n)}
for _ in range(m):
    a, b = map(int, input().split())
    route[a - 1].append(b - 1)
    route[b - 1].append(a - 1)
good = 0
for key in route.keys():
    flag = 0
    if len(route[key]) == 0:
        good += 1
        continue
    for position in route[key]:
        height = h[key]
        if height <= h[position]:
            flag = 1
            break
    if flag == 0:
        good += 1
print(good)

Solution (Python):
import numpy as np

x = input().split(' ')
n = int(x[0])
m = int(x[1])

x = input().split(' ')
heights = {}
for i in range(n):
  heights[i] = int(x[i])




ways = []

for i in range(m):
  x = input().split(' ')
  ways.append([int(x[0])-1, int(x[1])-1])
  

ways_dict = {}

bool_array = [1]*n

for way in ways:
  if heights[way[0]] > heights[way[1]]:
      bool_array[way[1]] = 0
  elif  heights[way[0]] == heights[way[1]]:
    bool_array[way[0]] = 0
    bool_array[way[1]] = 0
  else:
    bool_array[way[0]] = 0




for higher_idx, ways in ways_dict.items():
  for way in ways_dict[higher_idx]:
    bool_array[way] = 0
      
print(np.array(bool_array).sum())

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

Solution (Python):
N,M=list(map(int,input().split()))
src=list(map(int,input().split()))
w=[]
for e in range(N):
  w.append(1)
q=[]
for m in range(M):
  q.append(list(map(int,input().split())))

for a,b in q:
  if src[a-1]<src[b-1]:
    w[a-1] = 0
  elif src[b-1]<src[a-1]:
    w[b-1] = 0
  elif src[b-1]==src[a-1]:
    w[a-1]=0
    w[b-1]=0
ans = 0
for o in w:
  if o == 1:
    ans+=1
print(ans)

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

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

ans = 0
for i in range(1,N+1):
    if max(A[i]) == A[i][0] and A[i].count(A[i][0]) < 2:
        ans += 1

print(ans)

Solution (Python):
a = input().split(" ")
h = input().split(" ")
c = {}
for j in range(int(a[0])):
    c[str(j+1)] = [int(h[j]),"good"]
b = []
good = int(a[0])
for i in range(int(a[1])):
    d = input().split()
    x = int(c[d[0]][0])
    y = int(c[d[1]][0])
    if x > y:
        c[d[1]][1] = "bad"
    if y > x:
        c[d[0]][1] = "bad"
    if y == x:
        c[d[1]][1] = "bad"
        c[d[0]][1] = "bad"
kotae = 0
for k in range(int(a[0])):
    if c[str(k+1)][1] == "good":
        kotae += 1
print(kotae)

Solution (Python):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")


def main():
    N, M = map(int, input().split())
    N_list = [1 for x in range(N)]
    H_i = list(map(int, input().split()))

    for i in range(M):
        A, B = map(int, input().split())
        if H_i[A - 1] < H_i[B - 1]:
            N_list[A - 1] = 0
        elif H_i[A - 1] > H_i[B - 1]:
            N_list[B - 1] = 0
        else:
            N_list[A - 1] = 0
            N_list[B - 1] = 0
            
    print(N_list.count(1))

    logging.info("Hello!")

    
if __name__ == "__main__":
    main()

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

l =[]
good_list = set(l)
for i in range(n):
  good_list.add(i+1)

for i in range(m):
  a,b = map(int, input().split())
  high_a = H[a-1]
  high_b = H[b-1]
  if high_a <= high_b:
    good_list.discard(a)
  if high_b <= high_a:
    good_list.discard(b)
    
print(len(good_list))

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


A  = [0] * M
B  = [0] * M

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




    

yokunai = {}
yokunai = set(yokunai)

for i in range(M): 
    if H[A[i]-1] > H[B[i]-1]:
        yokunai.add(B[i])
    elif H[A[i]-1] < H[B[i]-1]:
        yokunai.add(A[i])
    else:
        yokunai.add(B[i])
        yokunai.add(A[i])



print(N-len(yokunai))

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

tenboudai_dict = {}
for i in range(0,N):
    tenboudai_dict[i+1] = H_list[i]


tenboudai_dict2 = {}
for way in AB_list:
    if tenboudai_dict[way[0]] == tenboudai_dict[way[1]]:
        tenboudai_dict2[way[0]] = 'NO'
        tenboudai_dict2[way[1]] = 'NO'
    elif tenboudai_dict[way[0]] < tenboudai_dict[way[1]]:
        tenboudai_dict2[way[0]] = 'NO'
    elif tenboudai_dict[way[0]] > tenboudai_dict[way[1]]:
        tenboudai_dict2[way[1]] = 'NO'


print(N - len(tenboudai_dict2))

Solution (Python):
import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
h_i = [int(x) for x in sys.stdin.readline().rstrip().split()]
ab = [list(map(int, sys.stdin.readline().rstrip().split())) for _ in range(M)]
 
J = [1 for i in range(N)]


for li in ab:
  
  if h_i[li[0]-1] < h_i[li[1]-1]:
    J[li[0]-1] = 0
  elif h_i[li[0]-1] == h_i[li[1]-1]:
    J[li[0]-1] = J[li[1]-1] = 0
  else:
    J[li[1]-1] = 0
print(J.count(1))