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):
import sys
input = sys.stdin.readline


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

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

    ans = 0
    for i in range(N):
        good = True
        for p in G[i]:
            if not H[i] > H[p]:
                good = False
        ans += 1 if good else 0
    print(ans)


if __name__ == "__main__":
    main()

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

X = [[] for i in range(N)] 
for i in range(M):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

cnt = 0
for i in range(N):
    c = 0
    for k in X[i]:
        if H[i] <= H[k]:
            c += 1
    if c == 0:
        cnt += 1
print(cnt)

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


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



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

ans = 0
for i in range(n):
	if len(E[i]) == 0:
		ans += 1
	else:
		flag =True
		for j in range(len(E[i])):
			if h[i] <= h[E[i][j]]:
				flag = False
				break
		if flag:
			ans += 1
print(ans)

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

ans = 0
for i in range(N):
    h = H[i]
    flag = True
    for b in graphs[i]:
        if H[b] >= h:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

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

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

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

ans = 0

for i in range(n):
    ok = 1
    for j in nb[i]:
        if(h[i]<=h[j]):
            ok = 0
    ans += ok
        
print(ans)

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

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

print(N - len(s))

Solution (Python):

import sys


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    ok = [True]*N

    for i in range(M):
        if H[A[i]-1]< H[B[i]-1]:
            ok[A[i]-1] = False
        elif H[A[i]-1]> H[B[i]-1]:
            ok[B[i]-1] = False
        else:
            ok[A[i]-1] = False
            ok[B[i]-1] = False
    
    answer = 0
    for i in range(N):
        if ok[i]:
            answer += 1
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    H = [int(next(tokens)) for _ in range(N)]  
    A = [int()] * (M)  
    B = [int()] * (M)  
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, H, A, B)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
h = list(map(int, readline().split()))
ab = [list(map(int, readline().split())) for _ in range(m)]
memo = [True] * n
for a, b in ab:
    if h[a - 1] > h[b - 1]:
        memo[b - 1] = False
    elif h[a - 1] < h[b - 1]:
        memo[a - 1] = False
    else:
        memo[a - 1] = False
        memo[b - 1] = False
print(memo.count(True))

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


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

print(sum(visited))

Solution (Python):



import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf

import math

import bisect


def is_good(tower_id, tower_info, connect):
    h = tower_info[tower_id]
    for neighbor_id in connect[tower_id]: 
        vs_h = tower_info[neighbor_id]
        if not (h > vs_h):
            return False
    return True


if __name__ == '__main__':
    num_tower, num_road = list(map(int, input().split()))
    tower_info = [0] + list(map(int, input().split())) 
    connect = [None] * (num_tower + 1) 
    for i, _ in enumerate(connect):
        connect[i] = set()
    
    
    for i in range(num_road):
        frm, to = list(map(int, input().split())) 
        connect[frm].add(to)
        connect[to].add(frm)
    
    
    
    count = 0
    for tower_id in range(1, num_tower + 1):
        
        
        if is_good(tower_id, tower_info, connect):
            count += 1
    
    
    print(count)

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

Solution (Python):
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

n,m = l_in()
h = l_in()

edges=[[] for _ in range(n)]
good=[True]*n

for _ in range(m):
    a,b=l_in()
    if h[a-1] > h[b-1]:
        good[a-1] = good[a-1] and True
        good[b-1] = False
    if h[b-1] > h[a-1]:
        good[b-1] = good[b-1] and True
        good[a-1] = False
    if h[b-1] == h[a-1]:
        good[b-1] = False
        good[a-1] = False

print(len(list(filter(lambda a: a, good))))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
edge = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
ans = n
for i in range(n):
    for j in edge[i]:
        if h[i] <= h[j]:
            ans -= 1
            break
print(ans)

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

edge_dict = {}

for edge in edges:
    if edge[0] in edge_dict:
        edge_dict[edge[0]].append(edge[1])
    else:
        edge_dict[edge[0]] = [edge[1]]
    if edge[1] in edge_dict:
        edge_dict[edge[1]].append(edge[0])
    else:
        edge_dict[edge[1]] = [edge[0]]

count = 0

for i in range(1,n+1):
    if i in edge_dict:
        nums = edge_dict[i]
        target_num = h_list[i-1]
        flag = True
        for num in nums:
            num2 = h_list[num-1]
            if num2 >= target_num:
                flag = False
        if flag == True:
            count += 1
    else:
        count += 1

print(count)

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

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

L = [1]*N

for i in range(M):
    A = AB[i][0]
    B = AB[i][1]
    if H[A-1] > H[B-1]:
        L[B-1] = 0
    if H[A-1] < H[B-1]:
        L[A-1] = 0
    if H[A-1] == H[B-1]:
        L[A-1] = 0
        L[B-1] = 0

print(sum(L))

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

def resolve():
    N,Path=pin()
    ns=tupin()
    cond=[1]*(N)
    for i in range(Path):
        x,y=pin()
        t=ns[x-1]-ns[y-1]
        if t>0:
            cond[y-1]=0
        elif t<0: cond[x-1]=0
        else: 
            cond[x-1]=0
            cond[y-1]=0
    print(sum(cond))

resolve()

Solution (Python):

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

H =  [int(x) for x in stdin.readline().rstrip().split()]

highest_neighbor = [-1 for _ in range(N)]
for i in range(M):
    [a, b] = [int(x) for x in stdin.readline().rstrip().split()]
    a-=1
    b-=1
    if H[b]>highest_neighbor[a]:
        highest_neighbor[a] = H[b]
    if H[a]>highest_neighbor[b]:
        highest_neighbor[b] = H[a]

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

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

for _ in range(M):
    f,t = [int(v) for v in input().split()]
    ad[f-1].append(t-1)
    ad[t-1].append(f-1)


ans = 0
for i in range(N):
    flag = True
    h = H[i]

    for t in ad[i]:
        if h <= H[t]: flag = False
    if flag: ans += 1
print(ans)

Solution (Python):
import math
N,M= map(int, input().split())
Hs = [0] + list(map(int, input().split()))
Hs_set = [-1 for _ in range(N + 1)]
for _ in range(M):
    A,B= map(int, input().split())

    Hs_set[A] = max(Hs[B],Hs_set[A])

    Hs_set[B] = max(Hs[A],Hs_set[B])
ans = 0
for i in range(1,N+1):
    if Hs[i] > Hs_set[i]:
        ans += 1



print(ans)

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

to = [list() for _ in range(n)]

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

ans =0

for i in range(n):
    flag=True
    for j in to[i]:
        if h[i]<=h[j]:
            flag=False
    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 _ in range(M)]
ans = [1]*N
for A,B in AB:
    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()))

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

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

print(sum(good))

Solution (Python):
def main():
    N, M = (int(_) for _ in input().split())
    H = [int(_) for _ in input().split()]
    good = [1] * N
    for _ in range(M):
        a, b = (int(_) for _ in input().split())
        a -= 1
        b -= 1
        if H[a] > H[b]: good[b] = 0
        elif H[a] < H[b]: good[a] = 0
        else:
            good[a] = 0
            good[b] = 0
    print(sum(good))
    return


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
A_to_B = [0]*N
for _ in range(M):
    tmp = list(map(int, input().split()))
    if A_to_B[tmp[0]-1] < H[tmp[1]-1]:
        A_to_B[tmp[0]-1] = H[tmp[1]-1]

    if A_to_B[tmp[1]-1] < H[tmp[0]-1]:
        A_to_B[tmp[1]-1] = H[tmp[0]-1]

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

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

ans=[True] * n 

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

print(sum(ans))

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

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


T = defaultdict(list)

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

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

ans = 0

for n in range(N):
    if len(T[n]) == 0 or H[n] > max(T[n]):
        ans += 1

print(ans)

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
H=[int(i) for i in input().split()]
edge = [[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
ans=0
for i in range(n):
  h=H[i]
  chk=True
  for g in edge[i]:
    if H[g]>=h:
      chk=False
  if chk:
    ans+=1
print(ans)

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

print(sum(res))

Solution (Python):
input = raw_input

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

hs = [None] + map(int, input().split(" "))




outs = [None] + [True] * n

for _ in range(m):
    a, b = map(int, input().split(" "))

    if hs[a] == hs[b]:
        outs[a] = False
        outs[b] = False
    elif hs[a] < hs[b]:
        outs[a] = False
    else:
        outs[b] = False

    
    

out = sum(outs[1:])
print(out)

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

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][1]-1] = 0
    elif 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][1]-1] = 0
        ans[ab[i][0]-1] = 0

print(ans.count(1))

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


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


if __name__ == "__main__":
    main()

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

for i in range(1,N+1):
    flag=True
    for j in range(len(T[i])):
        if H[T[i][j]-1]>=H[i-1]:
            flag=False
    if flag:
        ans+=1
        

print(ans)

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

print(sum(ans)-1)

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

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

print(ans)

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

def input():
    return sys.stdin.readline().strip()


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n,m = get_nums_l()
H = [0] + get_nums_l()

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

ans = 0
for u in range(1, n+1):
    ok = True
    for v in edges[u]:
        if H[u] <= H[v]:
            ok = False
            break
    if ok:
        ans += 1

print(ans)

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

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

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


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

print(sum(good))

Solution (Python):


def submit():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    pos = {i: 0 for i in range(n)}
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1

        if h[a] > h[b]:
            pos[b] += 1
        elif h[a] < h[b]:
            pos[a] += 1
        else:
            pos[a] += 1
            pos[b] += 1


    ans = sum(map(lambda x: x == 0, pos.values()))
    print(ans)


submit()

Solution (Python):
N,M=map(int, input().split())
H=list(map(int, input().split()))
AB=[tuple(map(int, input().split()))for _ in range(M)]
X=[True]*N
for a,b in AB:
    a-=1
    b-=1
    if H[a]>H[b]:
        X[b]=False
    elif H[a]<H[b]:
        X[a]=False
    else:
        X[a]=False
        X[b]=False
print(sum(X))

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

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

for _ in range(M):
  A,B = map(int,input().split())
  x = H[A-1]
  y = H[B-1]
  if H[A-1] <= y:
    L[A-1] = 1
  if H[B-1] <= x:
    L[B-1] = 1
c = 0
for x in L:
  if x == 0:
    c +=1
print(c)

Solution (Python):
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    n, m = map(int, read().split())
    h = [int(i) for i in read().split()]
    s = [1] * n
    for _ in range(m):
        a, b = [int(i) - 1 for i in read().split()]
        if h[a] < h[b]:
            s[a] = 0
        elif h[a] > h[b]:
            s[b] = 0
        else:
            s[a] = 0
            s[b] = 0
    print(sum(s))

if __name__ == '__main__':
    main()

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

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

Solution (Python):
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    cnt = 0
    for i in range(n):
        hh = h[i]
        for j in g[i]:
            if h[j] >= hh:
                break
        else:
            cnt += 1
    print(cnt)


main()

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

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

ans=0
for i in range(N):
    h=H[i]
    l=G[i]
    if len(l)==0:
        m=0
    else:
        m=max(l)
    if h>m:
        ans+=1

print(ans)

Solution (Python):
N,M=map(int,input().split(' '))
H=list(map(int,input().split(' ')))
AB = [list(map(lambda x:int(x)-1,input().split(' '))) for i in range(M)]
l = [[] for i in range(N)]
for A,B in AB:
    l[A].append(H[B])
    l[B].append(H[A])
ans = 0
for n,i in enumerate(H):
    if (not l[n]) or i > max(l[n]):
        ans += 1
print(ans)

Solution (Python):
import sys
input = sys.stdin.buffer.readline
n,m=map(int,input().split())
*h,=map(int,input().split())
con=[[] for _ in range(n)]
for _ in range(m):
	s,t=map(int,input().split())
	con[s-1]+=t-1,
	con[t-1]+=s-1,

def check(s):
	co=h[s]
	for ad in con[s]:
		if co<=h[ad]:
			return False
	return True

print(sum(check(i) for i in range(n)))

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)]
l = []
for i in ab:
    a, b = i[0], i[1]
    if h[a - 1] <= h[b - 1]:
        l.append(a)
    if h[a - 1] >= h[b - 1]:
        l.append(b)
print(n - len(set(l)))

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

ans = [1]*n
for i in range(m):
    x,y = map(int, input().split())
    if (h[x-1] > h[y-1]):
        ans[y-1] = 0
    elif (h[x-1] < h[y-1]):
        ans[x-1] = 0
    else:
        ans[x-1] = 0
        ans[y-1] = 0
print(sum(ans))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N, M = map(int, input().split()) 
    H=list(map(int,input().split()))
    edge = [[] * N for i in range(N)]
    for i in range(M):
        x, y = map(int, input().split())
        x, y = x - 1, y - 1
        edge[x].append(y)
        edge[y].append(x) 

    cnt=0
    for i in range(N):
        val=H[i]
        if not edge[i]:
            cnt+=1
        else:
            if all(val>H[j] for j in edge[i]):
                cnt+=1

    print(cnt)



resolve()

Solution (Python):
def main():
    N, M = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]
    AB = [[int(i) for i in input().split()] for j in range(M)]
    ans = {i+1 for i in range(N)}
    for a, b in AB:
        if H[a-1] < H[b-1]:
            ans.discard(a)
        elif H[b-1] < H[a-1]:
            ans.discard(b)
        else:
            ans.discard(a)
            ans.discard(b)
    print(len(ans))


if __name__ == '__main__':
    main()

Solution (Python):
import sys

n, m = map(int, sys.stdin.readline().split())
*h, = map(int, sys.stdin.readline().split())

surround = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1; b -= 1
    surround[a].append(h[b])
    surround[b].append(h[a])

def main():
    cnt = 0
    for i in range(n):
        try:
            if h[i] > max(surround[i]):
                cnt += 1
        except:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
  main()

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
H = iil()
d = {}
for i in range(m):
    a,b = iim()
    d[a] = max(d.get(a,0),H[b-1])
    d[b] = max(d.get(b,0),H[a-1])
ans = 0
for i,item in enumerate(H):
    if item > d.get(i+1,0):
        ans += 1
print(ans)

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


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

G = [[] for _ in [0]*N]
for _ in [0]*M:
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

ans = 0
for v, g in enumerate(G):
    for u in g:
        if H[u] >= H[v]:
            break
    else:
        ans += 1

print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
g = [[] for _ in range(n)]
for i in range(m):
    z,x = inpl()
    g[z-1].append(x-1)
    g[x-1].append(z-1)
res = 0

for i in range(n):
    ok = True
    for v in g[i]:
        if a[v] >= a[i]:
            ok = False
    if ok:
        
        res += 1
print(res)

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N,M=mis()
    H=lmis()
    W = [set() for _ in range(N)]
    for _ in range(M):
        a, b = mis()
        W[a-1].add(b-1)
        W[b-1].add(a-1)
    ans = 0
    for i in range(N):
        if len(W[i])==0 or H[i] > max(H[p] for p in W[i]):
            ans += 1
    print(ans)

main()

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

ans = 0

for i in range(n):
    ma = 0
    for j in graph[i]:
        ma = max(ma, h[j])
    if h[i] > ma:
        ans += 1

print(ans)

Solution (Python):
N, M = map(int, input().split(" "))
high = list(map(int, input().split(" ") ) )
bad = set()

for _ in range(M):
    a, b = map(int, input().split(" "))
    if high[a-1] > high[b-1] :
        bad.add(b)
    elif high[b-1] > high[a-1] :
        bad.add(a) 
    else :
        bad.add(a)
        bad.add(b)

print(N-len(bad))

Solution (Python):
n,m  = map(int, input().split())
hs = list(map(int, input().split()))
edges = [[] for i 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)

cnt = 0
for v in range(n):
    flg = True
    for u in set(edges[v]): 
        if hs[u] >= hs[v]:
            flg = False
    if flg:
        cnt += 1

print(cnt)

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

good=[True]*N

for _ in range(M):
    A,B=map(int,input().split())
    A,B=A-1,B-1
    if H[A]<=H[B]:
        good[A]=False
    if H[B]<=H[A]:
        good[B]=False

ans=0
for g in good:
    if g:
        ans+=1
print(ans)

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

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

max_neigh_hight = np.zeros(N) 

for _ in range(M):
    a,b = map(int,input().split())
    a-=1
    b-=1
    max_neigh_hight[a] = max(max_neigh_hight[a],h_list[b])
    max_neigh_hight[b] = max(max_neigh_hight[b],h_list[a])

diff = h_list - max_neigh_hight
ans = np.sum(diff>0)
print(ans)

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

F = [True] * N
for i in range(M):
    Ai, Bi = map(lambda s: int(s) - 1, input().split())
    if H[Ai] > H[Bi]:
        F[Bi] = False
    elif H[Ai] < H[Bi]:
        F[Ai] = False
    else:
        F[Ai] = F[Bi] = False

print(F.count(True))

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

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 -= 1
    B -= 1
    if H[A] <= H[B]:
        good[A] = False
    if H[B] <= H[A]:
        good[B] = False

cnt = 0
for g in good:
    if g:
        cnt += 1

print(cnt)