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

Solution (Python):
n, m = map(int, input().split())
hs = list(map(int, input().split()))
counter = [True] * n

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

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




dic = {}
count = 0

for i in range(m):
    aa, bb = map(int,input().split())
    
    
    if aa not in dic:
        dic[aa] = set()
        dic[aa].add(bb)
    else:
        dic[aa].add(bb)

    if bb not in dic:
        dic[bb] = set()
        dic[bb].add(aa)
    else:
        dic[bb].add(aa)

for k in dic.keys():
    left = h[k-1]
    right = 0
    for i in dic[k]:
        if h[i-1] >= right:
            right = h[i-1]

    if left > right:
        count += 1

count += n - len(dic)

print(count)

Solution (Python):
raw_input = list(map(int, input().split()))
n = raw_input[0]
m = raw_input[1]
h = list(map(int, input().split()))
loads = {i+1: [] for i in range(n)}
for _ in range(m):
    raw_input = list(map(int, input().split()))
    a = raw_input[0]
    b = raw_input[1]
    loads[a].append(h[b-1])
    loads[b].append(h[a-1])

counter = 0
for k, v in loads.items():
    if len(v) == 0:
        counter += 1
    elif max(v) < h[k-1]:
        counter += 1
print(counter)

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

for i in range(M):
    if H[AB[i][0]-1] == H[AB[i][1]-1]:
        Hi[AB[i][1]-1] = 0
        Hi[AB[i][0]-1] = 0
    elif H[AB[i][0]-1] > H[AB[i][1]-1]:
        Hi[AB[i][1]-1] = 0
    elif H[AB[i][0]-1] < H[AB[i][1]-1]:
        Hi[AB[i][0]-1] = 0
print(sum(Hi))

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

G = [[] for i in range(N)]

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

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for to in G[i]:
        if (self_h <= H[to]):
            self_max_flag = False
        
    if (self_max_flag):
        ans += 1

print(ans)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

class UnionFind():
    
    
    def __init__(self, n):
        self.n = n
        
        
        self.root = [-1]*(n+1)
        
        self.rnk = [0]*(n+1)

    
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    
    def Unite(self, x, y):
        
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        
        if(x == y):
            return 
        
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N, M = LI()
H = LI()
route = []
for i in range(M):
    a, b = LI()
    a -= 1
    b -= 1
    route.append((a,b))

N_path = [[] for i in range(N)]
for a, b in route:
    N_path[a].append(b)
    N_path[b].append(a)


ans = 0
for i in range(N):
    for path in N_path[i]:
        if H[path] >= H[i]:
            break
    else:
        ans += 1
print(ans)

Solution (Python):
import math
import collections

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

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



ans=0
for i in range(M):
    A, B = map(int, input().split())
    S[A-1].append(H[B-1])
    S[B - 1].append(H[A - 1])

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

print(ans)

Solution (Python):
n,m = map(int, input().split())
h = list(map(int,input().split()))
hbox = []
for i in h:
    a = [i]
    hbox.append(a)
for j in range(m):
    a,b = map(int, input().split())
    hbox[a-1].append(h[b-1])
    hbox[b-1].append(h[a-1])
ans = 0
for l in range(n):
    hbox[l] = sorted(hbox[l])
for k in range(n):
    if h[k] == hbox[k][-1] and not(hbox[k][-1] in set(hbox[k][:-1])):
        ans += 1
print(ans)

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

Solution (Python):
import sys
input = sys.stdin.readline
from heapq import heappush
N, M = map(int, input().split())
H = list(map(int, input().split()))
x = [True] * N
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] == H[b]:
        x[a] = False
        x[b] = False
    elif H[a] > H[b]:
        x[b] = False
    else:
        x[a] = False
ans = 0
for i in range(N):
    if x[i]:
        ans += 1
print(ans)

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

Solution (Python):

N, M = map(int, input().split())
H = list(map(int, input().split()))
Good = [True] * N

for _ in range(M):
    n1, n2 = map(int, input().split())

    n1 = n1 - 1
    n2 = n2 - 1

    if H[n1] == H[n2]:
        Good[n1] = False
        Good[n2] = False
    elif H[n1] < H[n2]:
        Good[n1] = False
    else:
        Good[n2] = False

print(Good.count(True))

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

for i in range(M):
  if H[L[i][0]] > H[L[i][1]]:
    A[L[i][1]] = 0
  elif H[L[i][0]] < H[L[i][1]]:
    A[L[i][0]] = 0
  else:
    A[L[i][0]] = 0
    A[L[i][1]] = 0
print(A.count(1))

Solution (Python):
if __name__=='__main__':
    n,m = map(int,input().split())
    h = [int(x) for x in input().split()]
    a = []
    b = []
    good_obs = [True for i in range(n)]
    for i in range(m):
        x,y = map(int,input().split())
        a.append(x)
        b.append(y)
        if h[x-1]<=h[y-1]:
            good_obs[x-1]=False
        if h[x-1]>=h[y-1]:
            good_obs[y-1]=False
    print(good_obs.count(True))

Solution (Python):
class Observatory:
    def __init__(self, height, around=[]):
        self.height = height
        x = []
        self.around = x
    def is_good(self, li, dic):
        flag = True
        for i in self.around:
            o = li[i-1]
            if o.height >= self.height:
                flag = False
            else:
                dic[i-1] = False
        return flag

n, m = map(int, input().split())
h = [int(i) for i in input().split()]
observatories = [Observatory(h[i]) for i in range(n)]
dic = {}
for i in range(n):
    dic[i] = True

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

for i in range(n):
    o = observatories[i]
    if dic[i]:
        if o.is_good(observatories, dic):
            ans += 1

print(ans)

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

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

paths = []
for i in range(M):
    paths.append(list(map(int, input().split())))
    paths[-1][0] -= 1
    paths[-1][1] -= 1
    
bad = set()

for path in paths:
  if H[path[0]] == H[path[1]]:
    bad.add(path[0])
    bad.add(path[1])
  elif H[path[0]] > H[path[1]]:
    bad.add(path[1])
  else:
    bad.add(path[0])
        
print(N-len(bad))

Solution (Python):

from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    h = [int(x) for x in 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)
        tenbo[b - 1].append(a)
    for i in range(n):
        flg = 0
        if len(tenbo[i]) == 0:
            ans += 1
            continue
        for j in tenbo[i]:
            if h[i] <= h[j-1]:
                flg = 1
                break
        if flg == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    adj[a-1].append(H[b-1])
    adj[b-1].append(H[a-1])
cnt = 0
for idx in range(N):
    if len(adj[idx]) == 0:
        cnt += 1
    elif max(adj[idx]) < H[idx]:
        cnt += 1

print(cnt)

Solution (Python):

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








G = {}

for a,b in ab:
    if a-1 not in G:
        G[a-1]={b-1}
    else:
        G[a-1].add(b-1)
    if b-1 not in G:
        G[b-1]={a-1}
    else:
        G[b-1].add(a-1)
ans=0
for i in range(n):
    if i not in G:
        ans +=1
        continue
    visited = G[i]
  
    height = h[i]
    flag = True
    for j in visited:
        if j == i:
            continue
        else:
            if h[j] >= height:
                flag =False
                break
    if flag :
        ans +=1
print(ans)

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

g = [[] for i in range(n)]
for i in range(m):
    a,b = ab[i]
    g[a-1].append(h[b-1])
    g[b-1].append(h[a-1])

cnt = 0
for i in range(n):
    if g[i] == []:
        mx = 0
    else:
        mx = max(g[i])
    if h[i] > mx:
        cnt += 1 

print(cnt)

Solution (Python):
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    return int(input())


def inpl():
    return list(map(int, input().split()))


N, M = inpl()
hh = inpl()

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

for _ in range(M):
    A, B = inpl()
    A -= 1
    B -= 1
    lines[A].append(B)
    lines[B].append(A)

ans = 0

for s in range(N):
    sh = hh[s]

    for t in lines[s]:
        th = hh[t]
        if sh > th:
            continue
        else:
            break
    else:
        ans += 1

print(ans)

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

l = H.copy()
for i in range(M):
  A, B = map(int, input().split())
  if H[A-1] > H[B-1]:
    l[B-1] = 0
  elif H[B-1] > H[A-1]:
    l[A-1] = 0
  elif H[A-1] == H[B-1]:
    l[A-1] = 0
    l[B-1] = 0
print(N - l.count(0))

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

print(sum(goodt))

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

if __name__ == "__main__":
    N, M = MI()
    H = LI()
    roots = []
    for _ in range(M):
        roots.append(LI())
    result = [True] * N
    for root in roots:
        if H[root[0]-1] > H[root[1]-1]:
            result[root[1]-1] = False
        elif H[root[0]-1] < H[root[1]-1]:
            result[root[0]-1] = False
        else:
            result[root[0]-1] = False
            result[root[1]-1] = False
    print(result.count(True))

Solution (Python):
n, M = map(int, input().split())
H = map(int, input().split())
ranking = []
order = [0] * n
good = [1] * n

for num, h in enumerate(H):
    ranking.append((num, h))
ranking.sort(key=lambda x: x[1])
for num, tpl in enumerate(ranking):
    order[tpl[0]] = (num, tpl[1])

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

print(sum(good))

Solution (Python):
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
route = {i:[] for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split())
    route[a].append(b)
    route[b].append(a)  

ans = 0

for f, ts in  route.items():
    hi_flag = True
    for t in ts:
        if h_list[f-1] <= h_list[t-1]:
            hi_flag = False
            break
    if hi_flag:
        ans += 1
print(ans)

Solution (Python):
from collections import defaultdict
def q3():
    n, m = [int(i) for i in input().split(" ")]
    height_list = [int(i) for i in input().split(" ")]
    heights = {}
    for index, height in enumerate(height_list):
        heights[index + 1] = height
    

    roads = defaultdict(lambda: set())
    for i in range(m):
        a, b = [int(i) for i in input().split(" ")]
        roads[a].add(b)
        roads[b].add(a)
    

    good = set()
    bad = set()
    for start, dests in roads.items():
        
        
        
        if start in bad:
            continue
        start_is_good = True
        for obs in dests:
            if heights[start] <= heights[obs]:
                start_is_good = False
                break
        if start_is_good:
            good.add(start)
            bad |= dests
        else:
            bad.add(start)

    for i in range(1, n+1):
        if i not in bad:
            good.add(i)
    
    
    

    print(len(good))

q3()

Solution (Python):
n,m = map(int,input().split())
hyoko = list(map(int,input().split()))
road=[list(map(int,input().split())) for i in range(m)]
ans=[1]*n

for j in road:
    a, b = j
    if hyoko[a-1] > hyoko[b-1]:
        ans[b-1] = 0
    elif hyoko[a-1] == hyoko[b-1]:
        ans[a-1] = 0
        ans[b-1] = 0
    else:
        ans[a-1] = 0
print(sum(ans))

Solution (Python):
nm = input().split()
n = int(nm[0])
m = int(nm[1])
h = input().split()
r = [1] * len(h)
for i in range(m):
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])

	if int(h[a-1]) > int(h[b-1]):
		r[b-1] = 0
	elif int(h[a-1]) < int(h[b-1]):
		r[a-1] = 0
	else:
		r[a-1] = 0
		r[b-1] = 0

cnt = 0

for i in r:
	if int(i) == 1:
		cnt += 1

print(cnt)

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

rinsetulist = []
for _ in range(n):
    rinsetulist.append([])

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


count = 0
for i in range(n):
    if rinsetulist[i] == []:
        count += 1
    elif heightlist[i] > max(rinsetulist[i]):
        count += 1

print(count)

Solution (Python):
from collections import defaultdict as dd
N,M = map(int,input().split())
HH = list(map(int,input().split()))

make = set([])

hs_dic = dd(list)

for m in range(M):
    a,b = input().split()
    ah = HH[int(a)-1]
    bh = HH[int(b)-1]
    if ah > bh:
        make.add(b)
    elif ah < bh:
        make.add(a)
    
    hs_dic[a].append(b)
    hs_dic[b].append(a)

yoi = 0

keys = hs_dic.keys()
yoi += N - len(list(keys))



kkeys = set(keys) - make




for kk in kkeys:
    bs = hs_dic[kk]
    ah = HH[int(kk)-1]
    ismax = 1

    for b in bs:
        bh = HH[int(b)-1]

        if bh >= ah:
            ismax = 0
            break
    yoi += ismax
    
print(yoi)

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = []
D = [[]for _ in range(N+1)]
count = 0
for i in range(M):
    AB.append(list(map(int,input().split())))

for i in AB:
    D[i[0]].append(i[1])
    D[i[1]].append(i[0])

for i in range(1,N+1):
    hantei = 0
    fur = D[i]
    for j in fur:
        if H[i-1] <= H[j-1]:
            hantei = 1
            break
    if hantei == 0:
        
        count += 1

print(count)

Solution (Python):
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])

tmp = input().split()

H = [0]*N
Flag = [1]*N

for h in range(N):
    H[h] = int(tmp[h])

for i in range(M):
    tmp = input().split()
    A = int(tmp[0])-1
    B = int(tmp[1])-1
    if H[A] < H[B]:
        Flag[A] = 0
    if H[A] > H[B]:
        Flag[B] = 0
    if H[A] == H[B]:
        Flag[A] = 0
        Flag[B] = 0

print(sum(Flag))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
peaks = {}
for i in range(n):
    peaks[i] = []
for j in range(m):
    a, b = map(int, input().split())
    peaks[a-1].append(b-1)
    peaks[b-1].append(a-1)
cnt = 0
for key, value in peaks.items():
    maxVal = 0
    for num in value:
        if h[num] > maxVal:
            maxVal = h[num]
        else:
            continue
    if h[key] > maxVal:
        cnt += 1
print(cnt)

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

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

Solution (Python):
N, M = map(int, input().split())
tower = [True]*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]:
        tower[A-1]=False
    elif H[B-1]<H[A-1]:
        tower[B-1]=False
    else:
        tower[A-1]=False
        tower[B-1]=False
ans = tower.count(True)
print(ans)

Solution (Python):
def c166(n, m, hl, abli):

    flag = [True]*n

    for i in abli:
        if hl[i[0]-1] < hl[i[1]-1]:
            flag[i[0]-1] = False
        elif  hl[i[0]-1] == hl[i[1]-1]:
            flag[i[0]-1] = False
            flag[i[1]-1] = False
        else:
            flag[i[1]-1] = False

    ans = flag.count(True)
    return ans

def main():
    n, m = map(int, input().split())
    hl = list(map(int, input().split()))
    abli = [list(map(int, input().split()))for i in range(m)]
    print(c166(n, m, hl, abli))

if __name__ == '__main__':
    main()

Solution (Python):
import sys



N,M = map(int, input().split())
H = list(map(int, input().split()))
A = [1,]*N

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

ans = sum(A)










print(ans)

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

total=0
for s in t:
    if s == 0:
        total += 1
print(total)

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

a = [0] * m
b = [0] * m
d = [0] * n

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

ans = 0

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

print(ans)

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

height = list(map(int, input().split()))
ansList = [1] * n

route = [[0] * 2] * m
for i in range(m):
    a, b = map(int, input().split())
    route[i] = a, b
'''
rouSet = set(route)
print(rouSet)
'''
for i in range(m):
    aa = route[i][0]
    bb = route[i][1]

    heiA = height[aa - 1]
    heiB = height[bb - 1]

    if (heiA == heiB):
        ansList[aa - 1] = 0
        ansList[bb - 1] = 0
    elif (heiA > heiB):
        ansList[bb - 1] = 0
    else:
        ansList[aa - 1] = 0

ans = sum(ansList)
print(ans)

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


not_good = set()
for i in range(0, M):
    A, B = [int(n) for n in input().split()]
    diff = Hs[A-1] - Hs[B-1]
    if diff > 0:
        not_good.add(B)
    elif diff < 0:
        not_good.add(A)
    else:
        not_good.add(A)
        not_good.add(B)
ans = N-len(not_good)
print(ans)

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

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

tenboudai = [1 for i in range(n)]

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

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

print(ans)

Solution (Python):
from collections import deque
import sys
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())
H=list(map(int,input().split()))
road=[[] for i in range(N)]
toutatu=[0]*N
for i in range(M):
  a,b=map(int,input().split())
  road[a-1].append(b-1)
  road[b-1].append(a-1)


count=0

for i in range(N):
  flag=True
  for j in road[i]:
    if(H[i]<=H[j]):
      flag=False
  if(flag==True):
    count+=1
print(count)

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

d = [0] * n
for i in range(m):
    d[k[i][0] - 1] = max(d[k[i][0] - 1], h[k[i][1] - 1])
    d[k[i][1] - 1] = max(d[k[i][1] - 1], h[k[i][0] - 1])
    
ans = 0
for i in range(n):
    if h[i] > d[i]:
        ans += 1

print(ans)

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

good = [1] * len(h)

for i in range(m):
    a1, a2 = list(map(int, input().split()))
    if h[a1-1] == h[a2-1]:
        good[a1-1] = 0
        good[a2-1] = 0
    elif h[a1-1] > h[a2-1]:
        good[a2-1] = 0
    else:
        good[a1-1] = 0

print(good.count(1))

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)

L = [1] * N
for i in range(M):
    if H[A[i] - 1] == H[B[i] - 1]:
        L[A[i] - 1] = 0
        L[B[i] - 1] = 0
    elif H[A[i] - 1] > H[B[i] - 1]:
        L[B[i] - 1] = 0
    else:
        L[A[i] - 1] = 0
print(sum(L))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int, input().split()))
ans=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
        ans[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))

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

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

lm = sorted(lm)

llose = list()

for i in range(M):
    if lh[lm[i][0]-1] == lh[lm[i][1]-1]:
        llose.append(lm[i][0])
        llose.append(lm[i][1])
    elif lh[lm[i][0]-1] < lh[lm[i][1]-1]:
        llose.append(lm[i][0])
    else:
        llose.append(lm[i][1])

llose = list(set(llose))

print(N - len(llose))

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, M = MAP()
    H = LIST()

    l = [1 for _ in range(N)]
    for _ in range(M):
        A, B = MAP()
        if H[A-1] < H[B-1]:
            l[A-1] = 0
        elif H[A-1] > H[B-1]:
            l[B-1] = 0
        else:
            l[A-1] = 0
            l[B-1] = 0

    print(sum(l))


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

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

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

temp = [0] * N


lst = [True] * N
for a, b in AB:
    
    
    
    

    lst[a - 1] = False
    lst[b - 1] = False

for a, b in AB:
    
    
    
    
    
    

    temp[a - 1] = max(temp[a - 1], H[b - 1])
    temp[b - 1] = max(temp[b - 1], H[a - 1])


cnt = 0
for i in range(N):
    if H[i] > temp[i] or lst[i]:
        cnt += 1

print(cnt)

Solution (Python):
from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,m=mis()
    h=lmis()
    cnt=0
    tlis=defaultdict(list)
    for _ in range(m):
        a,b=mis()
        tlis[a].append(b)
        tlis[b].append(a)
    lis=sorted(tlis.items())
    high=0
    for i in range(1,n+1):
        cnt+=1
        if len(tlis[i])==0:
            continue
        high=h[i-1]
        for j in tlis[i]:
            if h[j-1]>=high:
                cnt-=1
                break

    print(cnt)




if __name__ == "__main__":
    main()

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

Solution (Python):
import numpy as np

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

flag = np.full(N, True)
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]:
        flag[B-1] = False
    if H[B-1] >= H[A-1]:
        flag[A-1] = False

print(np.count_nonzero(flag))

Solution (Python):
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
m_dic = {}
for i in range(1, n+1):
    m_dic[i] = []
for i in range(m):
    a, b = map(int, input().split())
    m_dic[a].append(b)
    m_dic[b].append(a)

ans = 0
for i in range(1, n+1):
    good = True
    for j in m_dic[i]:
        if h_list[i-1] <= h_list[j-1]:
            good = False
            break
    if good: ans += 1
print(ans)

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

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

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

ans = 0

for own in range(n):
    is_good = True
    for pair in edges[own]:
        if h[own] <= h[pair]:
            is_good= False
    if is_good:
        ans += 1

print(ans)

Solution (Python):
n, m = map(int, input().split())
hlst = list(map(int, input().split()))
lst = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    lst[a].append(hlst[b])
    lst[b].append(hlst[a])
i = 0
for _ in range(n):
  if sum([o for o in lst[_] if o >= hlst[_]]) == 0:
    i += 1
print(i)

Solution (Python):
if __name__ == "__main__":
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    tenbo = []
    for _ in range(n):
        tenbo.append(set())
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tenbo[a].add(b)
        tenbo[b].add(a)
    
    ans = 0

    for i in range(n):
        tmp = True
        for j in tenbo[i]:
            if h[i] <= h[j]:
                tmp = False
        if tmp:
            ans += 1
    print(ans)

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

judge = [1]*N

for r in road:
    h1 = H[r[0]-1]
    h2 = H[r[1]-1]
    if h1 < h2:
        judge[r[0]-1] = 0
    if h1 == h2:
        judge[r[0]-1] = judge[r[1]-1] = 0
    if h1 > h2:
        judge[r[1]-1] = 0

print(sum(judge))