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()))
lst = [[] for _ in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    lst[A-1].append(B-1)
    lst[B-1].append(A-1)
cnt = 0
for i in range(N):
    if len(lst[i]) == 0:
        cnt += 1
    else:
        flg = True
        for j in lst[i]:
            if H[i] <= H[j]:
                flg = False
        if flg:
            cnt += 1
print(cnt)

Solution (Python):
b0=input().split()
N=int(b0[0])
L=int(b0[1])

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

nl=[0 for x in range(N)]
for l in range(L):
  l0=input().split()
  h1=int(l0[0])-1
  h2=int(l0[1])-1
  if hl[h1]>hl[h2]:
    nl[h2]+=1
  elif hl[h1]<hl[h2]:
    nl[h1]+=1
  else:
    nl[h1]+=1
    nl[h2]+=1

A=0
for nn in nl:
  if nn==0:
    A+=1
    
print(A)

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

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

Solution (Python):
N, M = map(int,input().split())
good = [0]*N

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

for j in range(M):
  a, b = map(int,input().split())
  if(H[a-1] == H[b-1]):
    good[a-1] += 1
    good[b-1] += 1
  elif(H[a-1] < H[b-1]):
    good[a-1] += 1
  else:
    good[b-1] += 1
count = 0
for i in range(N):
  if(good[i] == 0):
    count += 1
print(count)

Solution (Python):
n,m=map(int,input().split())
h=input().split()
out=[]
ab=[0]*m
for i in range(m):
  ab[i]=input().split()
  if int(h[int(ab[i][0])-1])==int(h[int(ab[i][1])-1]):
    out.append(ab[i][0])
    out.append(ab[i][1])
  elif int(h[int(ab[i][0])-1])>int(h[int(ab[i][1])-1]):
    out.append(ab[i][1])
  else:
    out.append(ab[i][0])


out=set(out)
print(n-len(out))

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

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

ans = set()
for i in range(n):
    stack = table[i]
    highest = h[i]
    flag = True
    for t in table[i]:
        if highest <= h[t]:
            flag = False
            break
    if flag:
        ans.add(i)
print(len(ans))

Solution (Python):
import sys

sys.setrecursionlimit(1000000)


def main():
    n, m = map(int, input().split())
    h_list = list(map(int, input().split()))
    not_good = set()
    for i in range(m):
        a, b = map(int, input().split())
        
        x = a-1
        y = b-1
        hx = h_list[x]
        hy = h_list[y]
        if hx == hy:
            not_good.add(x)
            not_good.add(y)
        elif hx > hy:
            not_good.add(y)
        else:
            not_good.add(x)

    print(n - len(not_good))


main()

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

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

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

print(n-A.count(0))

Solution (Python):
from heapq import heapify, heappush, heappop
from heapq import _heapify_max, _heappop_max
import heapq

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)

"""
method:
    heapify(x): ヒープに変換
    heappush(heap, item): itemをheapにpush
    heappop(heap): heapから最小値を取得 空の場合はIndexError
note:
    max heapにする場合は、prefix: _ とsuffix: _maxをつければ良い
"""
def main():
    n, m = map(int, input().split())
    h = [0] + list(map(int, input().split()))
    ans = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        _heappush_max(ans[a], h[b])
        _heappush_max(ans[b], h[a])
    out = 0
    for ai, hi in zip(ans[1:], h[1:]):
        if (not ai) or hi > _heappop_max(ai):
            out += 1
    print(out)

if __name__ == "__main__":
    main()

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    H=LI()
    adj=[[]for _ in range(N)]
    for i in range(M):
        a,b=MI()
        a-=1
        b-=1
        adj[a].append(b)
        adj[b].append(a)
        
    used=[0]*N
    Hi=[[0,0]for _ in range(N)]
    for i in range(N):
        Hi[i][0]=H[i]
        Hi[i][1]=i
        
    Hi.sort(reverse=True)
    
    ans=0
    for i in range(N):
        v=Hi[i][1]
        HH=Hi[i][0]
        if used[v]==0:
            temph=0
            used[v]=1
            for nv in adj[v]:
                temph=max(H[nv],temph)
                used[nv]=1
            if HH>temph:
                ans+=1
                
    print(ans)
        
    

main()

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

ans=0
for i in range(M):
    A,B=map(int,input().split())
    tenbo[A-1].append(B-1)
    tenbo[B-1].append(A-1)
   
for i in range(N):
    flg=1
    for j in range(len(tenbo[i])):
        if H[i]<=H[tenbo[i][j]]:
            flg=0
            break
    if flg:
        ans+=1
        
        
print(ans)

Solution (Python):

n, m = map(int, input().split())
tenboudai = [True for i in range(n)]

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

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

for path in path_list:
    if h_list[path[0]] < h_list[path[1]]:
        tenboudai[path[0]] = False
    elif h_list[path[1]] < h_list[path[0]]:
        tenboudai[path[1]] = False
    else:
        tenboudai[path[0]] = False
        tenboudai[path[1]] = False

print(tenboudai.count(True))

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

l=[True]*n

for x in a:
    if h[x[0]-1]>=h[x[1]-1]:l[x[1]-1]=False
    if h[x[0]-1]<=h[x[1]-1]:l[x[0]-1]=False

cnt=0
for y in l:
    if y:cnt+=1
print(cnt)

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

def main():
  n, m = map(int, input().split())
  tower_list = []
  for h in map(int, input().split()):
    tower_list.append([0,h,[]])
  
  count = n
  
  for _ in range(m):
    t1, t2 = map(int, input().split())
    if tower_list[t1-1][0] == 0:
      if tower_list[t1-1][1] <= tower_list[t2-1][1]:
        tower_list[t1-1][0] = 1
        n -= 1
    if tower_list[t2-1][0] == 0:
      if tower_list[t2-1][1] <= tower_list[t1-1][1]:
        tower_list[t2-1][0] = 1
        n -= 1
    
  return n

if __name__=='__main__':
  print(main())

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[i for i in range(N)]
B=[]
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        B.append(b)
    elif H[b-1]>H[a-1]:
        B.append(a) 
    else:
        B.append(a)
        B.append(b)

B=list(set(B))
print(len(A)-len(B))

Solution (Python):
import numpy as np
N, M = map(int, input().split())

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


good = np.ones(N)
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    if H[A] == H[B]:
        good[A] = 0
        good[B] = 0
    elif H[A] > H[B]:
        good[B] = 0
    else:
        good[A] = 0
        
    
    
print(int(sum(good)))

Solution (Python):
N, M = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = [list(map(int, input().split())) for _ in range(M)]
dict1 = {i+1:[] for i in range(N)}

for l in list2:
    dict1[l[1]].append(l[0])
    dict1[l[0]].append(l[1])
res = 0
for i in range(N):
    a =  1
    if dict1 == []:
        res += 1
        continue
    for j in dict1[i+1]:
        if list1[i] <= list1[j-1]:
            a = 0
    if a == 1:
        res+=1
print(res)

Solution (Python):

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

A = [];
B = [];

for i in range(m):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
list_ans = [1] * n;

for i in range(m):
  
  if H[A[i] - 1] < H[B[i] - 1]:
    list_ans[A[i] - 1] = 0;
	
  
  elif H[A[i] - 1] > H[B[i] - 1]:
    list_ans[B[i] - 1] = 0;
  
  
  else:  
    list_ans[A[i] - 1] = 0;
    list_ans[B[i] - 1] = 0;
  
print(sum(list_ans))

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

for i in range(M):
    a, b = map(int, input().split())
    a = a - 1
    b = b - 1
    if not H[a] > H[b]:
        good[a] = False
    if not H[a] < H[b]:
        good[b] = False

print(sum([1 if good[i] else 0 for i in range(N)]))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(m)]
dic = {}
ban = {}
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]

    if dic.get(a):
        dic[a] = max(dic[a], h[b - 1])
    else:
        dic[a] = h[b - 1]

    if dic.get(b):
        dic[b] = max(dic[b], h[a - 1])
    else:
        dic[b] = h[a - 1]
ans = 0
for i in range(n):
    if dic.get(i + 1):
        if dic[i + 1] < h[i]:
            ans += 1
    else:
        ans += 1
print(ans)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
tenbou = {i+1:[] for i in range(N)}

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

ans = N
for i in range(len(tenbou)):
    for val in tenbou[i+1]:
        if(H[i] <= H[val-1]):
            ans -= 1
            break
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)]
count = []

for i in range(M):
    if H[AB[i][0]-1]==H[AB[i][1]-1]:
        count.append(AB[i][1])
        count.append(AB[i][0])
    elif H[AB[i][0]-1]<H[AB[i][1]-1]:
        count.append(AB[i][0])
    else:
        count.append(AB[i][1])

loser = list(set(count))

print(N-len(loser))

Solution (Python):
line = input().split(" ")

N = int(line[0])

M = int(line[1])

isnum = [True] * N

h_list = input().split(" ")
count = 0
for i in range (M):
  a = input().split(" ")
  if int(h_list[int(a[0])-1]) == int(h_list[int(a[1])-1]):
    isnum[int(a[0]) - 1] = False
    isnum[int(a[1]) - 1] = False
    continue
  elif int(h_list[int(a[0])-1]) < int(h_list[int(a[1])-1]):
    isnum[int(a[0]) - 1] = False
  elif int(h_list[int(a[0])-1]) > int(h_list[int(a[1])-1]):
    isnum[int(a[1]) - 1] = False
n = sum(x==True for x in isnum)
print(n)

Solution (Python):
N, M = map(int, input().split())
High = list(map(int, input().split()))
Road =[[]for i in range(N)]
ans = 0

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a in Road[b]:
        continue
    Road[a].append(b)
    Road[b].append(a)

for i in range(N):
    now = High[i]
    flag = True
    for j in Road[i]:
        if now <= High[j]:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

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

print(len(ans))

Solution (Python):

from collections import defaultdict
n,m=map(int,raw_input().split())
a=map(int,raw_input().split())
d={}
a=[0]+a
d = defaultdict(list) 
for i in range(m):
    u,v=map(int,raw_input().split())
    


    d[u].append(a[v]) 
    d[v].append(a[u]) 
      
    


c=0

for i in range(1,n+1):
	if i in d:
		if a[i]>max(d[i]):
			c+=1
	
	else:
		c+=1

print c

Solution (Python):
nm = input('')
n=int(nm.split(' ')[0])
m=int(nm.split(' ')[1])
hs = input('').split(' ')

abmap = {}
for i in range(m):
    ab = input('')
    a = int(ab.split(' ')[0])
    b = int(ab.split(' ')[1])
    if a in abmap.keys():
        abmap[a].append(b)
    else:
        abmap[a] = [b]
    if b in abmap.keys():
        abmap[b].append(a)
    else:
        abmap[b] = [a]

ytb_cnt=0
for a,b in abmap.items():
    ah = int(hs[a-1])
    ytb = 1
    for bn in b:
        bh = int(hs[bn-1])

        if ah <= bh:
            ytb=0
    if ytb == 1:
        ytb_cnt+=1
for h in range(len(hs)):
    if not (h+1) in abmap.keys():

        ytb_cnt+=1
print(ytb_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[b-1]=0
	elif h[a-1]<h[b-1]:
		ans[a-1]=0
	else:
		ans[b-1]=0
		ans[a-1]=0
print(ans.count(1))

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

Solution (Python):
def main():
    n, m = [int(x) for x in input().split()]
    heights = tuple(int(x) for x in input().split())
    adjacents_heights = [set() for _ in range(n)]
    for i in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        adjacents_heights[a].add(heights[b])
        adjacents_heights[b].add(heights[a])
    ans = 0
    for h, ahs in zip(heights, adjacents_heights):
        if not ahs:
            ans += 1
            continue
        elif h > max(ahs):
            ans += 1

    return ans


if __name__ == '__main__':
    print(main())

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
c=collections.Counter(ans)
print(c[1])

Solution (Python):



def main():
    N, M = map(int, input().split())
    H = list(map(int,input().split()))
    R = [1] * N
    for i in range(M):
        a , b= map(int,input().split())
        a-=1
        b-=1
        if H[a]>H[b]:
            R[b]=0
        elif H[b]>H[a]:
            R[a]=0
        else:
            R[b]=0
            R[a]=0
    print(sum(R))

if __name__ == '__main__':
    main()

Solution (Python):
int1 = lambda x: int(x) - 1

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

good = [1] * N
for _ in range(M):
    A, B = map(int1, input().split())
    if H[A] == H[B]:
        good[A] = 0
        good[B] = 0
    elif H[A] > H[B]:
        good[B] = 0
    else:
        good[A] = 0

print(sum(good))

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

li = set(range(0, N))

for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] < H[b-1]:
        li.discard(a-1)
    elif H[a-1] > H[b-1]:
        li.discard(b-1)
    else:
        li.discard(a-1)
        li.discard(b-1)


print(len(li))

Solution (Python):
N, M = map(int, input().split())
heights = list(map(int, input().split()))
highest = [True for _ in range(N)]
for m in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    val_a = heights[a]
    val_b = heights[b]
    
    
    if val_a == val_b:
        highest[a] = False
        highest[b] = False
    elif val_a > val_b:
        highest[b] = False
    elif val_a < val_b:
        highest[a] = False
    
print(sum(highest))

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

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

print(N-len(badN))

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

n_list = [True for i in range(n)]

for m in m_list:
  a = m[0] - 1
  b = m[1] - 1
  if h_list[a] > h_list[b]:
    n_list[b] = False
  elif h_list[a] == h_list[b]:
    n_list[a] = False
    n_list[b] = False
  else:
    n_list[a] = False

count = 0
for n in n_list:
  count += 1 if n else 0

print(count)

Solution (Python):
n, m = list(map(int, input().split()))
hm = {i + 1: hi for i, hi in enumerate(list(map(int, input().split())))}
bad_h = []
for i in range(m):
    ai, bi = list(map(int, input().split()))
    if hm[ai] == hm[bi]:
        bad_h.append(ai)
        bad_h.append(bi)
    elif hm[ai] < hm[bi]:
        bad_h.append(ai)
    else:
        bad_h.append(bi)
print(len(hm) - len(set(bad_h)))

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

lose = set()

for _ in range(M):
    A,B=map(int,input().split())
    if H[A]<H[B]:
        lose.add(A)
    elif H[A]>H[B]:
        lose.add(B)
    elif H[A]==H[B]:
        lose.add(A)
        lose.add(B)

print(N-len(lose))

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

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

print(sum(res))

Solution (Python):
N, M = [eval(v) for v in input().strip().split(" ")]
H = [eval(v) for v in input().strip().split(" ")]

Adj_matrix = []
for i in range(N):
    Adj_matrix.append([])

for i in range(M):
    A, B = [eval(v) for v in input().strip().split(" ")]
    A -= 1
    B -= 1
    Adj_matrix[A].append(B)
    Adj_matrix[B].append(A)
    
    



count = 0
for i in range(N):
    success = True
    for j in range(len(Adj_matrix[i])):
        A, B = i, Adj_matrix[i][j]
        if H[A] <= H[B]:
            success = False
            break
    if success:
        count += 1

print(count)

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)]
flag = [1] * n
for i in range(m):
         if h[ab[i][0] - 1] > h[ab[i][1] - 1]:
                  if flag[ab[i][1] -1] == 1:
                           flag[ab[i][1] -1] = 0
         elif h[ab[i][0] - 1] < h[ab[i][1] - 1]:
                  if flag[ab[i][0] -1] == 1:
                           flag[ab[i][0] -1] = 0
         else:
                  if flag[ab[i][1] -1] == 1:
                           flag[ab[i][1] -1] = 0
                  if flag[ab[i][0] -1] == 1:
                           flag[ab[i][0] -1] = 0                  
print(sum(flag))

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

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

Solution (Python):
n,m = map(int,input().split())
h_list = list(map(int,input().split()))
ans = [True 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]:
    ans[a-1] = False
  elif h_list[a-1] > h_list[b-1]:
    ans[b-1] = False
    
  if h_list[a-1] == h_list[b-1]:
    ans[a-1] = False
    ans[b-1] = False
print(ans.count(True))

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

Solution (Python):


N, M = map(int, input().split())
H = list(map(int, input().split()))
S = [True] * N
cnt = 0
while cnt < M:
    A, B = map(int, input().split())
    if(H[A-1] < H[B-1]):
        S[A-1] = False
    elif(H[A-1] > H[B-1]):
        S[B-1] = False
    elif(H[A-1] == H[B-1]):
        S[A-1] = False
        S[B-1] = False
    cnt += 1
a = sum(x==True for x in S)
print(a)

Solution (Python):

import collections
import itertools as it
import math

 


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



ans = 0
tenbo = [0] * n
for (a, b) in ab:
    
    if h[a-1] > h[b-1]:
        if tenbo[a-1] != -1:
            tenbo[a-1] = 1
        tenbo[b-1] = -1
    if h[a-1] < h[b-1]:
        if tenbo[b-1] != -1:
            tenbo[b-1] = 1
        tenbo[a-1] = -1
    if h[a-1] == h[b-1]:
        tenbo[a-1] = -1
        tenbo[b-1] = -1

for tenbo_ in tenbo:
    if tenbo_ == 1 or tenbo_ == 0:
        ans += 1

print(ans)

Solution (Python):
(n, m)=[int(x) for x in input().split()]
p=[x for x in range(1, n+1)]
h=[int(x) for x in input().split()]
hp=dict(zip(p, h))
path={i:[] for i in range(1, n+1)}
for i in range(m):
  (a, b)=[int(x) for x in input().split()]
  path[a].append(b)
  path[b].append(a)
c=0
for i, v in path.items():
  f=0
  for j in v:
    if hp[i] <= hp[j]:
      f=1
      break
  if f==0:
    c+=1
print(c)

Solution (Python):
import sys
N, M = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for i in range(M)]
ans = [1] * N
for i in range(M):
    a, b = AB[i]
    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
print(ans.count(1))

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

Solution (Python):
import numpy as np
n,m = map(int, input().split())
h = input().split() 
for i in range(n):
    h[i] = int(h[i])
bridge = np.zeros((m,2), dtype="int")
for i in range(m):
    a,b = map(int, input().split())
    bridge[i,0] = int(a)
    bridge[i,1] = int(b)

good = [1]*n
for i in range(m):
    if h[bridge[i,0]-1] > h[bridge[i,1]-1]:
        good[bridge[i,1]-1] = 0
    elif h[bridge[i,0]-1] < h[bridge[i,1]-1]:
        good[bridge[i,0]-1] = 0
    else :
        good[bridge[i,0]-1] = 0
        good[bridge[i,1]-1] = 0
        
        
        
         
         
print(sum(good))

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

lsts = [[] for _ in range(N)]

for a, b in ab:
    lsts[a-1].append(b-1)
    lsts[b-1].append(a-1)

ans = 0

for i, lst in enumerate(lsts):
    h_lst = []
    for j in lst:
        h_lst.append(h[j])
    if h_lst == []:ans += 1
    elif h[i] > max(h_lst):
        ans += 1

print(ans)

Solution (Python):
N, M = list(map(int, input().split()))
N_i = [1 for i 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]:
        
        N_i[B-1] = 0
    elif H[A-1] < H[B-1]:
        
        N_i[A-1] = 0
    else:
        N_i[A-1] = 0
        N_i[B-1] = 0



print(N_i.count(1))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
ans = [0 for i in range(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[A-1] > H[B-1]:
        ans[B-1] += 1
    else:
        ans[A-1] += 1
        ans[B-1] += 1

print(len([i for i in ans if i == 0]))

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

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

root = [ [] for _ in range(n+1)]

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

ans = 0
for i in range(n+1):
    height = h[i-1]
    flag = 1
    for j in root[i]:
        if height <= h[j-1]:
            flag = 0
            break
    
    if flag == 1:
        ans += 1
        

print(ans-1)

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


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

hlen=len(h)
for i in range(0,hlen):
    h[i]=int(h[i])
ans=[]

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


num=len(set(ans))
print(n-num)

Solution (Python):
a, b = map(int, input().split())
lis=[]
for i in map(int, input().split()):
    lis.append(i)
res=[1]*a
for i in range(b):
    c, d = map(int, input().split())
    if(lis[c-1]>lis[d-1]):
        res[d-1]=0
    elif(lis[c-1]<lis[d-1]):
        res[c-1]=0
    else:
        res[d - 1] = 0
        res[c - 1] = 0
print(sum(res))

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

n, m = map(int, input().replace("\n","").split())
h = list(map(int, input().replace("\n","").split()))

chklist= [1] * n


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

    if h[a-1] < h[b-1]:
        chklist[a-1] = 0
        if chklist[b-1] != 0:
            chklist[b-1] = 1

    elif h[a-1] > h[b-1]:
        chklist[b-1] = 0
        if chklist[a-1] != 0:
            chklist[a-1] = 1

    elif h[a-1] == h[b-1]:
        chklist[a-1] = 0
        chklist[b-1] = 0

print(chklist.count(1))

Solution (Python):
n,m=map(int, input().split())
h=list(map(int, input().split()))
d={}
for i in range(1,n+1):
    d[i]=[]
for z in range(m):
    a,b=map(int, input().split())
    d[a].append(b)
    d[b].append(a)
ans=0
for i in range(1,n+1):
    val=0
    for j in d[i]:
        if h[j-1]>=h[i-1]:
            val=1
            break
    if val==0:
        ans=ans+1
print(ans)

Solution (Python):
N, M = map(int, input().split())
Height = list(map(int, input().split()))
Pt = [i for i in range(N)]
Ans = 0

for i in range(M):
  check = 0
  A, B = map(int, input().split())
  if Height[A - 1] > Height[B - 1]:
    Pt[B - 1] = A - 1
  elif Height[A - 1] == Height[B - 1]:
    Pt[B - 1] = A - 1
    Pt[A - 1] = B - 1
  else:
    Pt[A - 1] = B - 1
  
for i in range(N):
  if Pt[i] == i:
    Ans += 1
    
print(Ans)

Solution (Python):
n,m = map(int, input().split())
h = list(map(int, input().split()))
cnt = n
ng = {}
for i in range(m):
  a,b = map(int, input().split())   
  if h[a-1] >= h[b-1]:
    ng[b] = 1
  if h[a-1] <= h[b-1]:
    ng[a] = 1
print(n -len(ng))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int, input().split()))
l=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
ans=0
for i,ii in enumerate(l):
  for j in set(ii):
    if h[i]<=h[j]:
      break
  else:
    ans+=1
print(ans)

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

Solution (Python):
N, M = list(map(int, input().split()))
height_list = list(map(int, input().split()))
tenbo_list = []

count = 0

for n in range(N):
    tenbo_list.append([])

for n in range(M):
    A, B = list(map(int, input().split()))
    tenbo_list[A-1].append(B-1)
    tenbo_list[B-1].append(A-1)

ite = 0
for t in tenbo_list:
    count += 1
    for a in t:
        if height_list[a] >= height_list[ite]:
            count -= 1
            break
    ite += 1

print(count)

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

ans = [True] * N

for i in range(M):
    a, b = map(int, input().split())
    if H[a - 1] > H[b - 1]:
        ans[b - 1] = False

    elif H[a - 1] < H[b - 1]:
        ans[a - 1] = False
    else:
        ans[a - 1], ans[b - 1] = False, False
        
print(sum(ans))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
H.insert(0, None)
towers = set(range(1, N+1))
for _ in range(M):
    A, B = map(int, input().split())
    if H[A] >= H[B]:
        towers.discard(B)
    if H[A] <= H[B]:
        towers.discard(A)
print(len(towers))