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):
O=list(map(int, input().split()))
N = O[0]
M = O[1]

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

L=[]
E=[]
for i in range(N):
    L.append(1)
    E.append(1)

for i in range(M):
    AB=list(map(int, input().split()))
    E[AB[0]-1]=0
    E[AB[1]-1]=0
    if H[AB[0]-1]>H[AB[1]-1]:
        L[AB[1]-1]=0
    elif H[AB[0]-1]<H[AB[1]-1]:
        L[AB[0]-1]=0
    else:
       L[AB[0]-1]=0
       L[AB[1]-1]=0
  
sumx=0
for i in range(N):
    sumx+=L[i]

print(sumx)

Solution (Python):
from collections import defaultdict

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

hlist = list(map(int, input().split()))
roadlist = [list(map(int, input().split())) for i in range(m)]

roadgraph = defaultdict(list)

for r in roadlist:
    roadgraph[r[0]].append(r[1])
    roadgraph[r[1]].append(r[0])

ignore_list = [0 for x in range(n + 1)]

count = 0

for i in range(1, n + 1):
    if ignore_list[i] == 0:
        
        self = hlist[i - 1]
        skip = False
        for x in roadgraph[i]:
            if hlist[x - 1] >= self:
                skip = True
                break
        if skip:
            continue
        else:
            for x in roadgraph[i]:
                ignore_list[x] = 1
            count += 1


        
        
        
        
        
        

print(count)

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

for a, b in zip(A, B):
    if H[a-1] <= H[b-1]:
        result[a-1] = 0

for a, b in zip(B, A):
    if H[a-1] <= H[b-1]:
        result[a-1] = 0

print(result.count(1))

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

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

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

ans = 0
for i in range(1,N+1):
    dp = []
    for j in l[i]:
        dp .append(H[j])
    maxi = max(dp) if dp else 0
        
    if H[i]>maxi:
        ans += 1
print(ans)

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

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


t = [1] * n
for i in range(m):
    a, b = map(int, input().split())

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

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

print(sum(t))

Solution (Python):
import itertools

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

uni = list(itertools.chain.from_iterable(AB))
uni = list(set(uni))

ans = 0


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



ans = N-len(list(set(AB_del)))-ans
print(ans)

Solution (Python):
n,m = map(int,input().split())
l = [i for i in range(1,n+1)]
h = list(map(int,input().split()))
d_h = dict(zip(l,h))
d_r = {}
for i in range(1,n+1):
    d_r[i] = []
for i in range(m):
    x,y = map(int,input().split())
    d_r[x].append(y)
    d_r[y].append(x)
count = 0
for i in d_r.keys():
    key_height = d_h[i]
    if len(d_r[i]) == 0:
        count += 1
    else:
        flag = 0
        for j in d_r[i]:
            if d_h[j] < key_height:
                continue
            else:
                flag = 1
                break
        if flag == 0:
            count += 1
print(count)

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

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

res=0
for i in range(N):
    if len(AB[i])==0:
        res+=1
        continue
    
    f=True
    for k in AB[i]:
        if H[i] <= H[k-1]:
            f=False
            break
    
    if f:
        res+=1

print(res)

Solution (Python):

import sys

DEBUG = True if (len(sys.argv) > 1 and sys.argv[1] == "DEBUG") else False


def dp(value):
    if DEBUG:
        print(value)
    return


def input_text(split=" "):
    
    result = []
    while True:
        try:
            row = list(
                map(lambda x: int(x) if x.isdecimal() else x, input().split(split))
            )
            result.append(row)
        except EOFError:
            break
    return result



it = input_text()

n = {i + 1 for i in range(it[0][0])}  
m = it[0][1]  
h = it[1]  
ab = it[2:]

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

    if a == b:
        if x[0] in n:
            n.remove(x[0])
        if x[1] in n:
            n.remove(x[1])
        continue

    l = x[0] if a < b else x[1]
    if l in n:
        n.remove(l)

print(len(n))

Solution (Python):
N,M=map(int,input().split())
h=list(map(int,input().split()))
c=[0]*N
d=[]
for i in range(N):
  d.append([])
ans=0
r=[]
for i in range(M):
  r.append(list(map(int,input().split())))
for i in range(M):
  d[r[i][0]-1].append(r[i][1]-1)
  d[r[i][1]-1].append(r[i][0]-1)
for i in range(N):
  if c[i]==0:
    flag=0
    for j in range(len(d[i])):
      if h[i]<=h[d[i][j]]:
        flag=1
      else:
        c[d[i][j]]=1
    if flag==0:
      ans+=1
print(ans)

Solution (Python):
obs = {}

class Observatory:
  def __init__(self, id, height):
    self.id = id
    self.height = height
    self.link = []

  def is_good(self):
    for id in self.link:
      if self.height <= obs[id].height:
        return False
    
    return True

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

for i in range(1, n+1):
  obs[i] = Observatory(i, h_list[i-1])

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

count = 0
for ob in obs.values():
  if ob.is_good():
    count += 1

print(count)

Solution (Python):
n, m = map(int, input().split())
data = list(map(int, input().split()))
rule = [list(map(int, input().split())) for _ in range(m)]
bord = [[] for _ in range(n)]
for i in range(m):
    bord[rule[i][0]-1].append(rule[i][1]-1)
    bord[rule[i][1]-1].append(rule[i][0]-1)
for j in range(n):
    bord[j] = set(bord[j])
    bord[j] = list(bord[j])
ans = 0
for s in range(n):
    bl = True
    if len(bord[s]) == 0:
        ans += 1
    else:
        for t in range(len(bord[s])):
            if data[s] <= data[bord[s][t]]:
                bl = False
        if bl:
            ans += 1
print(ans)

Solution (Python):
import numpy

n, m = input().split(" ")
n = int(n)
m = int(m)

h_list = input().split(" ")
h_list = numpy.array(list(map(int, h_list)))

edges = {} 

for i in range(m):
  s, e = input().split(" ")
  s = int(s) - 1
  e = int(e) - 1

  if s not in edges:
    edges[s] = set()
  edges[s].add(e)
  
  if e not in edges:
    edges[e] = set()
  edges[e].add(s)

isolated_tower_num = n - len(edges.keys())

good_tower_num = 0
for t_idx in edges.keys():
  connected_towers = list(edges[t_idx])
  t_height = h_list[t_idx]
  connected_highest_height = max(h_list[connected_towers])
  if t_height > connected_highest_height:
    good_tower_num += 1

print(good_tower_num+isolated_tower_num)

Solution (Python):
n, m = map(int,input().split())
h = list(map(int,input().split()))
miti = []
miti_w = []
miti_l = []
for i in range(m):
    miti.append(list(map(int,input().split())))
for i in range(m):
    if h[(miti[i][0]-1)] > h[(miti[i][1]-1)]:
        miti_l.append(miti[i][1])
    elif h[(miti[i][0]-1)] < h[(miti[i][1]-1)]:
        miti_l.append(miti[i][0])
    else:
        miti_l.append(miti[i][0])
        miti_l.append(miti[i][1])
for i in range(1,n+1):
    miti_w.append(i)
print(len(list(set(miti_w) - set(miti_l))))

Solution (Python):


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


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


highest = [True] * N

res = 0

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

  a = a - 1
  b = b - 1

  if(highest[a]):
    highest[a] = H[a] > H[b]
    
  if(highest[b]):
    highest[b] = H[a] < H[b]

for i, value in enumerate(highest):
  if(highest[i]):
    res += 1

print(res)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
connections = (list(map(int, input().split())) for _ in range(M))
winner_nodes = [1 for x in range(N)]
for pair in connections:
  a = pair[0]-1
  b = pair[1]-1
  if H[a]>=H[b]: winner_nodes[b] = 0
  if H[b]>=H[a]: winner_nodes[a] = 0
print(sum(winner_nodes))

Solution (Python):
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A = [0] * M
B = [0] * M
high = [0] * N
low = [0] * N
equal = [0] * N
ans = 0

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

for i in range(N):
    if high[i] > 0 and low[i] == 0 and equal[i] == 0:
        ans += 1
    elif high[i] == 0 and low[i] == 0 and equal[i] == 0:
        ans += 1
print(ans)

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

Solution (Python):
class Graph():
    def __init__(self):
        """ ノードのつながりを辞書型で表現する """
        self.adjacency_dict = {}

    def add_vertex(self, v):
        """ ノードを追加する """
        self.adjacency_dict[v] = []
    def add_edge(self, v1, v2):
        """ ノード同士をつなぐ。"""
        
        self.adjacency_dict[v1].append(v2)
        self.adjacency_dict[v2].append(v1)
    def remove_edge(self, v1, v2):
        """ ノード同士のつながりを削除する。"""
        self.adjacency_dict[v1].remove(v2)
        self.adjacency_dict[v2].remove(v1)
    def remove_vertex(self,v):
        """ ノードを削除する。"""
        while self.adjacency_dict[v] != []:
            adjacent_vertex = self.adjacency_dict[v][-1]
            self.remove_edge(v, adjacent_vertex)
        del self.adjacency_dict[v]

    def print_graph(self):
        print(self.adjacency_dict)

n, m = map(int, input().split())
h = list(map(int, input().split()))
graph = Graph()
for i in range(n):
    graph.add_vertex(i+1)
for i in range(m):
    a, b = map(int, input().split())
    graph.add_edge(a, b)

ans = 0
for i in range(n):
    ans += 1
    for j in graph.adjacency_dict[i+1]:
        if h[i] <= h[j-1]:
            ans -= 1
            break
print(ans)

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

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

Solution (Python):
n,m=[int(_) for _ in input().split()]
dic={}
height=[int(b) for b in input().split()][:n]
list1=[]
count=0
for j in range(n):
    dic[j+1]=height[j]
for i in range(m):
    a,b=[int(q) for q in input().split()]
    if dic[a]>dic[b]:
        
        list1.append(b)
    elif dic[b]>dic[a]:
        list1.append(a)
    else:
        list1.append(a)
        list1.append(b)
            
print(n-len(set(list1)))

Solution (Python):
inputlist = list(map(int, input().split()))
obsnum = inputlist[0]
roadnum = inputlist[1]
obshigh = list(map(int, input().split()))
obslist = [0] * obsnum
for i in range(roadnum):
    pair_obs = list(map(int, input().split()))
    if obshigh[pair_obs[0] - 1] == obshigh[pair_obs[1] - 1]:
        obslist[pair_obs[0] - 1] = 1
        obslist[pair_obs[1] - 1] = 1
    elif obshigh[pair_obs[1] - 1] < obshigh[pair_obs[0] - 1]:
        obslist[pair_obs[1] - 1] = 1
    else:
        obslist[pair_obs[0] - 1] = 1
print(obslist.count(0))

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-1)
    elif H[a-1] < H[b-1]:
        BAD.append(a-1)
    else:
        BAD.append(a-1)
        BAD.append(b-1)

ALL = []
for i in range(n):
    ALL.append(i)

print(len(set(BAD)^set(ALL)))

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

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

ans = 0
for i, g in enumerate(G):
    if not g:
        ans += 1
        continue
    if H[i] > max(g):
        ans += 1

print(ans)

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())
a=[1]*N
for x in range(M):
    if H[A[x]-1]>H[B[x]-1]:
        a[A[x]-1]*=1
        a[B[x]-1]*=0
    elif H[A[x]-1]==H[B[x]-1]:
        a[A[x]-1]*=0
        a[B[x]-1]*=0
    else:
        a[A[x]-1]*=0
        a[B[x]-1]*=1
sum=0
for y in a:
    sum+=y
print(sum)

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

dic = {}
for i in range(1,n+1):
    dic[i] = 1
for j in range(1,m+1):
    a,b = map(int,input().split())
    if h[a-1] < h[b-1]:
        dic[a] = 0
    elif h[a-1] > h[b-1]:
        dic[b] = 0
    else:
        dic[a] = 0
        dic[b] = 0
lis = list(dic.values())

print(lis.count(1))

Solution (Python):

def main():
  n, m = map(int, input().split(" "))
  H = tuple(map(int, input().split(" ")))

  edges = [[]] * n

  for _ in range(m):
    a, b = map(int, input().split(" "))
    a -= 1
    b -= 1
    if len(edges[a]) == 0:
      edges[a] = [b]
    else:
      edges[a].append(b)

    if len(edges[b]) == 0:
      edges[b] = [a]
    else:
      edges[b].append(a)

  arr = sorted(enumerate(H), key=lambda tpl: -tpl[1])

  ans = [False] * n
  done_set = set()
  for i, h in arr:
    if i in done_set:
      continue

    ans[i] = True
    done = {i}
    for j in edges[i]:
      done.add(j)
      if H[j] >= h:
        ans[i] = False

    done_set |= done

  print(len(tuple(filter(lambda x: x, ans))))




main()

Solution (Python):


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

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

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

for i in range(0,M):
    A[i],B[i] = map(int,input().split())
    if H[A[i]-1] > H[B[i]-1]:
        ev = B[i]-1
    elif H[A[i]-1] == H[B[i]-1]:
        tower[A[i]-1]+=1
        tower[B[i]-1]+=1
        continue
    else:
        ev = A[i]-1
    tower[ev] += 1


print(tower.count(0))

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

import numpy as np
H_ = np.zeros(len(H))

A = []
B = []
for i in range(M):
    a, b = map(int, input().split())
    
    if H[a-1] > H[b-1]:
        H_[b-1] = 1
    elif H[a-1] < H[b-1]:
        H_[a-1] = 1
    elif H[a-1] == H[b-1]:
        H_[a-1] = 1
        H_[b-1] = 1
        
count = 0
for i in H_:
    if i == 0:
        count += 1
    
print(count)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
R = list(range(1, N+1))
l = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] < H[B-1]:
        l.append(A)
    elif H[A-1] > H[B-1]:
        l.append(B)
    else:
        l.append(A)
        l.append(B)
ans = set(R) - set(l)
print(len(ans))

Solution (Python):
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N, M = mapint_inp()
H = list(mapint_inp())
ABs = [list(mapint_inp()) for _ in range(M)]

X = [0 for _ in range(N)]


for AB in ABs:
    A, B = AB
    A -= 1
    B -= 1
    
    
    if H[A] > H[B]:
        X[B] = -1
    elif H[B] > H[A]:
        X[A] = -1
    else:
        X[B] = -1
        X[A] = -1

print(X.count(0))

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

ablist=[]
for i in range(M):
    ablist.append(list(map(int,input().split())))


flist=[]
for i in range(M):
    if dic[min(ablist[i])] > dic[max(ablist[i])]:
        flist.append(max(ablist[i]))
    elif dic[min(ablist[i])] < dic[max(ablist[i])]:
        flist.append(min(ablist[i]))
    elif dic[min(ablist[i])] == dic[max(ablist[i])]:
        flist.append(min(ablist[i]))
        flist.append(max(ablist[i]))
        
    


flist=set(flist)


print(N-len(flist))

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

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

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

answer = np.ones(N)

for x in range(M):
  A, B = map(int,input().split())
  if li[A-1] > li[B-1]:
     answer[B-1] = 0
  elif li[B-1] > li[A-1]:
     answer[A-1] = 0
  else:
     answer[A-1] = 0
     answer[B-1] = 0

print('{:.0f}'.format(sum(answer)))

Solution (Python):
n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
ab = sorted([sorted(list(map(int, input().split())))
             for _ in range(m)])

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

for a, b in ab:
    l[a].append(b)
    l[b].append(a)

cnt = 0
f = 0
for i, v in enumerate(l):
    for k in v:
        if h[i] <= h[k]:
            f = 1
            break
    if f == 0:
        cnt += 1
    f = 0
print(cnt - 1)

Solution (Python):
n,m = map(int, input().split())
H = list(map(int, input().split()))
import collections
d = collections.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):
    s = list(set(d[i]))
    
    
    if len(s) == 0:
        ans += 1
        
        continue
    f = 0
    for j in range(len(s)):
        
        if H[s[j]] >= H[i]:
            f += 1
            continue
    if f == 0:
        ans += 1
        

print(ans)

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

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

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

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

print(i.count(0))

Solution (Python):
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    violate = []
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        if H[A] == H[B]:
            violate.append(A)
            violate.append(B)
        elif H[A] - H[B] < 0:
            violate.append(A)
        elif H[B] - H[A] < 0:
            violate.append(B)
    violate = list(set(violate))
    num = N - len(violate)
    print(num)
        
if __name__ == '__main__':
    main()

Solution (Python):

def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    count = 0
    x = [True]*n

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

        if h[y[0]-1] > h[y[1]-1]:
            x[y[1]-1] = False
        if h[y[1]-1] > h[y[0]-1]:
            x[y[0]-1] = False

        if h[y[1]-1] == h[y[0]-1]:
            x[y[0]-1] = False
            x[y[1]-1] = False

        

    for i in x:
        if i:
            count += 1
    
    print(count)


if __name__ == '__main__':
    main()

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

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

flags = [1]*N

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

print(flags.count(1))

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
graph = [0] + [[] for _ in range(n)]
for i in range(m):
    n1, n2 = map(int, input().split())
    graph[n1].append(n2)
    graph[n2].append(n1)

ans = 0
for i in range(1, n+1):
    high = []
    if len(graph[i]) == 0:
        ans += 1
        continue
    for j in graph[i]:
        high.append(h[i] > h[j])
    if all(high):
        ans += 1
print(ans)

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

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

for i in range(m):
    a,b = map(int,input().split())
    
    
    if H[a-1] > H[b-1]:
        if (a in d and d[a] == 1) or a not in d:
            d[a] = 1
        if (b in d and d[b] == 1) or b not in d:
            d[b] = 0
    elif H[a-1] < H[b-1]:
        if (b in d and d[b] == 1) or b not in d:
            d[b] = 1
        if (a in d and d[a] == 1) or a not in d:
            d[a] = 0
    else:
        d[a] = 0
        d[b] = 0

c = n - len(d)

for i,j in d.items():
    if j == 1:
        c += 1

print(c)

Solution (Python):
from collections import defaultdict
n, m = map(int, input().split())
h = list(map(int, input().split()))
d = defaultdict(set)
num = 0
for _ in range(m):
    a, b = map(int, input().split())
    d[a].add(b)
    d[b].add(a)
num += len(set(range(1,n+1)) - set(d))
for i, v in d.items():
    flag = False
    for j in v:
        if h[i-1] <= h[j-1]:
            flag = True
    if not flag:
        num += 1
print(num)

Solution (Python):
N,M = (int(i) for i in input().split())
table = [1 for _ in range(N)]
h = list(map(int, input().split()))
for _ in range(M):
  u,v = (int(i) for i in input().split())
  u-=1
  v-=1
  if h[u]==h[v]:
    table[u] = 0
    table[v] = 0
  else:
    if h[u]>h[v]:
      table[v] = 0
    if h[v]>h[u]:
      table[u] = 0

ans = sum(table)
print(ans)

Solution (Python):
from collections import Counter
n, m = map(int, input().split())
h = [int(_) for _ in input().split()]
ab = [[int(_) for _ in input().split()] for i in range(m)]
ans = [1 for i in range(n)]

for i in range(m):
    if h[ab[i][0]-1] < h[ab[i][1]-1]:
        ans[ab[i][0]-1] = 0
    elif h[ab[i][0]-1] == h[ab[i][1]-1]:
        ans[ab[i][0]-1]=0
        ans[ab[i][1]-1]=0
    else:
        ans[ab[i][1]-1] = 0

ans_count = Counter(ans)
print(ans_count[1])

Solution (Python):

N,M = map(int, input().split())
H =list(map(int, input().split()))
x =[list(map(int, input().split())) for i in range(M)]
DP = [1]*N
for i in range(M):
    tmp = min(H[x[i][0]-1],H[x[i][1]-1])
    if H[x[i][0]-1] == H[x[i][1]-1]:
        DP[x[i][0] - 1] = 0
        DP[x[i][1] - 1] = 0
    elif tmp == H[x[i][0]-1]:
        DP[x[i][0]-1] = 0
    else:
        DP[x[i][1] - 1] = 0


ans = sum(DP)
print(ans)

Solution (Python):
import numpy as np

N, M = map(int, input().split())
H = [int(i) for i in input().split()]
X = np.ones(N, np.bool)
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] == H[b]:
        X[a] = X[b] = False
    elif H[a] < H[b]:
        X[a] = False
    else:
        X[b] = False
print(np.count_nonzero(X))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
e = [[] for i in range(N)]
for i in range(M):
    e[AB[i][0]-1].append(AB[i][1]-1)
    e[AB[i][1]-1].append(AB[i][0]-1)
ans = 0
for i in range(N):
    if len(e[i]) == 0:
        ans += 1
        continue
    h = H[i]
    f = False
    for j in e[i]:
        if h <= H[j]:
            f = True
    if not f:
        ans += 1
print(ans)

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

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

print(n-len(list(set(lis))))

Solution (Python):

N, M = [int(x) for x in input().split(" ")]
h = [int(x)-1 for x in input().split(" ")]
graph = [[] for x in range(N)]
for i in range(M):
    c1, c2 = [int(x)-1 for x in input().split(" ")]
    graph[c1].append(c2)
    graph[c2].append(c1)
cnt = 0

for i in range(N):
    height = h[i]
    for j in graph[i]:
        if h[j] >= height:
            break
    else:
        cnt += 1
print(cnt)

Solution (Python):
import numpy as np
n, m = map(int, input().split())
hh = list(map(int, input().split()))
aa = np.zeros(m, np.int32)
bb = np.zeros(m, np.int32)
for i in range(m):
    aa[i], bb[i] = map(int, input().split())

ha = np.array([hh[aa[i]-1] for i in range(m)])
hb = np.array([hh[bb[i]-1] for i in range(m)])
set_bad = set(aa[ha <= hb]).union(set(bb[ha >= hb]))
print(n - len(set_bad))

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,b = a-1,b-1

    if h[a] < h[b]:
        ans[a] = 0
    elif h[b] < h[a]:
        ans[b] = 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()))
x = [[0]for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  x[a-1].append(H[b-1])
  x[b-1].append(H[a-1])
count=0
for i in range(n):
  if H[i] > max(x[i]):
    count+=1
print(count)

Solution (Python):
n,m=map(int,input().split())
l=list(map(int,input().split()))
d={}
d_track={}

for i in range(n):
  d_track[i+1]=1
  d[i+1]=l[i]


for i in range(m):
  a,b=map(int,input().split())
  
  if d[a]<=d[b]:
    d_track[a]=0

  if d[b]<=d[a]:
    d_track[b]=0

ct=0

for i in range(n):
  if d_track[i+1]==1:
    ct+=1
print(ct)

Solution (Python):
N,M=list(map(int,input().split()))
H=[0]*N
H=list(map(int,input().split()))
A=[0]*M
B=[0]*M
road=[[0 for i in range(1)] for j in range(N)]
good=[0]*N
count=0

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

for i in range(N):
    if 0<=good[i]:
        count+=1

print(count)

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

ans = [True for _ in range(N)]

for l in S:
    if H[l[0]-1] == H[l[1]-1]:
        ans[l[1]-1] = False
        ans[l[0]-1] = False
    elif H[l[0]-1] > H[l[1]-1]:
        ans[l[1]-1] = False
    else:
        ans[l[0]-1] = False

print(ans.count(True))

Solution (Python):
N, M = map(int, raw_input().split())
heights = map(int, raw_input().split())
connected_max_h = {}
for m in range(M):
	a,b = map(int, raw_input().split())
	a_max = connected_max_h.get(a-1, 0)
	b_max = connected_max_h.get(b-1, 0)
	connected_max_h[a-1] = max(a_max, heights[b-1])
	connected_max_h[b-1] = max(b_max, heights[a-1])

good_count = 0
for n in range(N):
	max_h = connected_max_h.get(n, 0)
	if max_h < heights[n]:
		good_count += 1

print good_count

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

table = [1]*n

for i in range(m):
    p = path[i]
    if h[p[0]-1] <= h[p[1]-1]:
        table[p[0]-1] = 0
    if h[p[0]-1] >= h[p[1]-1]:
        table[p[1]-1] = 0

        
cnt = 0
for i in table:
    if i == 1:
        cnt += 1
        
print(cnt)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
ANS = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    ANS[A-1].append(H[B-1])
    ANS[B-1].append(H[A-1])
cnt = 0
for i, value in enumerate(ANS):
    if value == [] or H[i] > max(value):
        cnt += 1
print(cnt)

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