Problem:
 Score : 300 points    Problem Statement There are N observatories in AtCoder Hill, called Obs. 1 , Obs. 2 , ... , Obs. N . The elevation of Obs. i is H_i .
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j .  Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.
Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.  How many good observatories are there?      Constraints  2 \leq N \leq 10^5  1 \leq M \leq 10^5  1 \leq H_i \leq 10^9  1 \leq A_i,B_i \leq N  A_i \neq B_i  Multiple roads may connect the same pair of observatories.  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  M  H_1  H_2  ...  H_N  A_1  B_1  A_2  B_2  :  A_M  B_M       Output Print the number of good observatories.        Sample Input 1 4 3
1 2 3 4
1 3
2 3
2 4      Sample Output 1 2    From Obs. 1 , you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3 , so Obs. 1 is not good.    From Obs. 2 , you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3 , so Obs. 2 is not good.    From Obs. 3 , you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2 , so Obs. 3 is good.    From Obs. 4 , you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2 , so Obs. 4 is good.    Thus, the good observatories are Obs. 3 and 4 , so there are two good observatories.       Sample Input 2 6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6      Sample Output 2 3

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

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

Solution (Python):
import sys


def main():
    read = lambda: sys.stdin.readline().rstrip()
    import collections

    N, M = map(int,read().split())
    H = list(map(int,read().split()))
    g = collections.defaultdict(set)
    for _ in range(M):
        x, y = map(int,read().split())
        g[x-1].add(y-1)
        g[y-1].add(x-1)

    def dfs(s, height, visited):
        if not g[s] or s in visited: return True
        visited.add(s)
        for nei in g[s]-visited:
            if H[nei] >= height: return False
            
        return True
    cnt = 0
    for i in range(N):
        
        cnt += dfs(i, H[i], set())
    
    print(cnt)


if __name__ == "__main__":
    main()

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

for i in range(1,n+1):
    for j in roads[i]:
        if h[i]<=h[j]:
            break
    else:
         cnt+=1
    
print(cnt)

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

C = []

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

C = set(C)
ans = N - len(C)
print(ans)

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

Solution (Python):
num,miti = map(int,input().split())     
tenbou = {}
hight = input().split()
good = {}
bad = {}
c = 0


for i in range(num):
    tenbou[i+1] = int(hight[i])


for j in range(miti):
    a,b = map(int,input().split())
    if tenbou[a] > tenbou[b]:
        if not a in bad:
            good[a] = tenbou[a]
        bad[b] = tenbou[b]
        if b in good:
            del good[b]
    elif tenbou[a] < tenbou[b]:
        if not b in bad:
            good[b] = tenbou[b]
        bad[a] = tenbou[a]
        if a in good:
            del good[a]
    elif tenbou[a] == tenbou[b]:
        bad[a] = tenbou[a]
        bad[b] = tenbou[b]
        if a in good:
            del good[a]
        if b in good:
            del good[b]


goods = len(good)
bads = len(bad)

        
if num == (goods + bads):
    print(goods)
else:
    print(num - (goods + bads) + goods)

Solution (Python):
n, m = map(int, input().split())
li_h = list(map(int, input().split()))
li_route = list()
remove_idx_set = set()

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

    h_a = li_h[a - 1]
    h_b = li_h[b - 1]

    if h_a <= h_b:
        remove_idx_set.add(a - 1)
    if h_a >= h_b:
        remove_idx_set.add(b - 1)
for s in remove_idx_set:
    li_h[s] = 0
print(len([v for v in li_h if v != 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)]

d = {num for num in range(1, n + 1)}
for i in range(m):
    if h[ab[i][0] - 1] > h[ab[i][1] - 1]:
        d.discard(ab[i][1])
    elif h[ab[i][0] - 1] < h[ab[i][1] - 1]:
        d.discard(ab[i][0])
    elif h[ab[i][0] - 1] == h[ab[i][1] - 1]:
        d.discard(ab[i][1])
        d.discard(ab[i][0])

print(len(d))

Solution (Python):
def set_root(tower,root):
    tower[root[0] - 1][1].append(root[1]-1)
    tower[root[1] - 1][1].append(root[0]-1)


def compare(tower,index):
    if(len(tower[index][1]) == 0):
        return 1

    for i in tower[index][1]:
        if(tower[index][0] <= tower[i][0]):
            return 0
    
    return 1


def resolve():
    ti,root = map(int,input().split())
    tower =[[int(i),[]] for i in input().split()]
    sum = 0
    for i in range(root):
        set_root(tower,[int(i) for i in input().split()])
    
    for j in range(ti):
        sum +=compare(tower,j)

    print(sum)
resolve()

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

dp=[1 for i in range(n)]
for i in range(m):
    if h[road[i][0]-1]>=h[road[i][1]-1]:
        dp[road[i][1]-1]=0
    if h[road[i][0]-1]<=h[road[i][1]-1]:
        dp[road[i][0]-1]=0
ans=0
for i in range(n):
    if dp[i]>0:
        ans+=1
print(ans)

Solution (Python):
(N, M) = [int(n) for n in input().split()]
H = [int(n) for n in input().split()]
G = [1 for _ in range(N)]
for _ in range(M):
    (A, B) = [int(n)-1 for n in input().split()]
    if H[A] <= H[B]:
        G[A] = 0
    if H[B] <= H[A]:
        G[B] = 0

print(sum(G))

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[]
for i in range(M):
    A.append(list(map(int,input().split())))
    
Q=[0]*N
for i in range(M):
    if H[A[i][0]-1]>=H[A[i][1]-1]:
        Q[A[i][1]-1]=-10**5
    if H[A[i][0]-1]<=H[A[i][1]-1]:
        Q[A[i][0]-1]=-10**5
n = sum(x>=0 for x in Q)
print(n)

Solution (Python):
def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n+1)]
    hl = [[] for i in range(n+1)] 
    h = [0]
    h.extend(list(map(int, input().split())))
    for i in range(m):
        a, b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)
    g[0].append(0)
    for i, gi in enumerate(g):
        for j, gj in enumerate(gi):
            if gj is None:
                continue
            hl[i].append(h[gj])
    max_hl = list()
    for i in hl:
        if i == []:
            max_hl.append(0)
        else:
            max_hl.append(max(i))
    res = len([x - y for (x, y) in zip(h, max_hl) if x - y > 0 ])
    print(res)

if __name__ == '__main__':
    main()

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[a-1]=0
 if h[b-1]<=h[a-1]:
  res[b-1]=0
print(res.count(1))

Solution (Python):
N,M = [int(x) for x in input().split()]
P = dict([(i,True) for i in range(1,N+1)])
H = [0] + [int(x) for x in input().split()]
for m in range(M):
    A,B = [int(x) for x in input().split()]
    if H[A] >= H[B]:
        P[B] = False
    if H[B] >= H[A]:
        P[A] = False

print(sum(list(P.values())))

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

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

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

t = [0] * N

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


result = 0

for i in range(N):
    if H[i] > t[i]:
        result += 1
print(result)

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
adj = [ [] for _ in range(N) ]
for _ in range(M):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  adj[u].append(v)
  adj[v].append(u)

res = 0
for i in range(N):
   if all([ H[n] < H[i] for n in adj[i]]):
    res += 1

print(res)

Solution (Python):
n,m = map(int,input().split())
height = list(map(int,input().split()))
path = [[]for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    path[a] += [b]
    path[b] += [a]
ans=0
for i in range(1,n+1):
    nice = True
    for j in path[i]:
        if height[i-1]<=height[j-1]:
            nice = False
    if nice:
        ans+=1
print(ans)

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


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

heighest = [True] * N

for i in range(M):
	a_temp, b_temp = list(map(int,input().split()))
	a_temp -= 1
	b_temp -= 1
	if h[a_temp] <= h[b_temp]:
		heighest[a_temp] = False
	if h[b_temp] <= h[a_temp]:
		heighest[b_temp] = False
print(sum(heighest))

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

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

count = 0
for a in range(N):
    if all(H[a] > H[b] for b in path[a]):
        count += 1
print(count)

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
dic={i:set() for i in range(n)}
for j in range(m):
  a,b=map(lambda x:int(x)-1,input().split())
  dic[a].add(b)
  dic[b].add(a)
co=0
for i in range(n):
  if all([h[i]>h[way] for way in dic[i]]):co+=1
print(co)

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

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

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

line2= input().split(' ')
hs= []
for h in line2:
	hs.append(int(h))

roads= []
for _ in range(0, m):
	line= input().split(' ')
	roads.append([int(line[0]),int(line[1])])

graph= {}
for o in range(1, n+1):
	graph[o]=[]

for road in roads:
	graph[road[0]].append(road[1])
	graph[road[1]].append(road[0])


def is_good(x):
	height= hs[x-1]
	for adj in graph[x]:
		if hs[adj-1]>= height:
			return False
	return True
	'''height= hs[x-1]
	for road in roads:
		if road[0]==str(x):
			if hs[int(road[1])-1]>=height:
				return False
		if road[1]==str(x):
			if hs[int(road[0])-1]>=height:
				return False
	return True'''

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

print(len(ans))

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    h = list(map(int, readline().split()))

    is_good = [True] * n

    for _ in range(m):
        a, b = map(int, readline().split())
        h_a, h_b = h[a - 1], h[b - 1]
        if h_a >= h_b:
            is_good[b - 1] = False
        if h_b >= h_a:
            is_good[a - 1] = False

    print(is_good.count(True))


if __name__ == '__main__':
    main()

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    import io, os
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    n, m = map(int, input().decode().rstrip("\n\r").split())
    h = list(map(int, input().decode().rstrip("\n\r").split()))

    is_good = [True] * n

    for _ in range(m):
        a, b = map(int, input().decode().rstrip("\n\r").split())
        h_a, h_b = h[a - 1], h[b - 1]
        if h_a >= h_b:
            is_good[b - 1] = False
        if h_b >= h_a:
            is_good[a - 1] = False

    print(sum(is_good))


if __name__ == '__main__':
    main()

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())
route = [[] for _ in range(N)]
for a, b in zip(A, B):
    route[a-1].append(b-1)
    route[b-1].append(a-1)
cnt = 0
for i in range(N):
    for r in set(route[i]):
        if H[i] <= H[r]:
            break
    else:
        cnt+=1
print(cnt)

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

result = [1] * N

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

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

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


lower = []

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

print(n - len(set(lower)))

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

for i in range(1,n+1):
    for j in roads[i]:
        if h[i]<=h[j]:
            break
    else:
         cnt+=1
    
print(cnt)

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

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

print(ans.count(True))

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

todai = []
heights = list(map(int, input().split()))

for i in range(n):
    todai.append([heights[i]])

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

good = 0
for i in range(n):
    if len(todai[i]) == 1:
        good += 1
    else:
        for j in range(1, len(todai[i])):
            if todai[i][0] <= todai[i][j]:
                break
            else:
                if j == len(todai[i])-1:
                    good += 1

print(good)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = set(range(1, n + 1))

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

print(len(ans))

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

for _ in range(m):
    a, b = map(int, input().split())
    roads[a].append(b)
    roads[b].append(a)
    
for i in range(1, n+1):
    for j in roads[i]:
        if h[i] <= h[j]:
            break
    else:
        ans += 1

print(ans)

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())
  a=a-1
  b=b-1
  if h[a]==h[b]:
    ans[a]+=1
    ans[b]+=1
  elif h[a]>h[b]:
    ans[b]+=1
  else:
    ans[a]+=1

print(ans.count(0))

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

print(ac.count(1))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
l = [0 for i in range(len(H))]
A = []
B = []
for _ in range(M):
    temp = list(map(int, input().split()))
    A.append(temp[0])
    B.append(temp[1])

for i in range(M):
    if H[A[i]-1] > H[B[i]-1]:
        l[B[i]-1] = 1
    elif H[A[i]-1] < H[B[i]-1]:
        l[A[i]-1] = 1
    else:
        l[A[i]-1] = 1
        l[B[i]-1] = 1
print(len(H)-sum(l))

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math
from collections import deque
from collections import defaultdict
from math import gcd

N, M = map(int, input().split())
H = list(map(int, input().split()))
H = np.array(H)
G = [[] for _ in range(N)]

for _ 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):
    u = i
    path = G[u]
    if len(path) == 0:
        ans += 1
    elif H[u] > np.max(H[path]):
        ans += 1

print(ans)

Solution (Python):
n, m = map(int,input().split())
h_list = list(map(int, input().split()))
good_list = [1 for i in range(n)]
for i in range(m):
  _a,_b = map(int, input().split())
  if h_list[_a-1] == h_list[_b-1]:
    good_list[_a-1] = 0
    good_list[_b-1] = 0
  elif h_list[_a-1] > h_list[_b-1]:
    good_list[_b-1] = 0
  else:
    good_list[_a-1] = 0
print(sum(good_list))

Solution (Python):

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

    best_pos = [1]*N
    for i in range(0,M):
        if H[A[i]-1] > H[B[i]-1]:
            best_pos[B[i]-1] = 0
        elif H[A[i]-1] < H[B[i]-1]:
            best_pos[A[i]-1] = 0
        else:
            best_pos[A[i]-1] = 0
            best_pos[B[i]-1] = 0

    ans = 0
    for best in best_pos:
        ans += best
    print(ans)

if __name__ == '__main__':
    main()

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

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

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

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

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

ans =0
for i in range(n):
  if not v[i]:
        ans+=1;continue
  f=0
  for j in v[i]:
    if h[j] >= h[i]:f=1 ;break

  if not f:
    ans+=1

print(ans)

Solution (Python):
n, m = map(int, input().split())
h = [int(n) for n in input().split()]
check = [0] * n

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

print(check.count(0))

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

Hight = [int(x) for x in input().split()]
judge = []
count = 0

for i in range(N):
    judge.append(True)

for i in range(M):
    A,B = map(int,input().split())
    if Hight[A-1] < Hight[B-1]:
        judge[A-1] = False
    elif Hight[A-1] == Hight[B-1]:
        judge[A-1] = False
        judge[B-1] = False
    else:
        judge[B-1] = False

for b in judge:
    if b:
        count += 1

print(count)

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

ab = [0]*n
for _ in range(m):
  a,b = map(int, input().split())
  ab[a-1] = max(ab[a-1], h[b-1])
  ab[b-1] = max(ab[b-1], h[a-1])

ans = 0
for i in range(n):
  if h[i] > ab[i]:
    ans += 1
print(ans)

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

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

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

print(c.count(1))

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

Solution (Python):
n, m = map(int, input().split())
h = [0] + [int(i) for i in input().split(" ")]
c = [0]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    c[a] = max(c[a], h[b])
    c[b] = max(c[b], h[a])
ans = 0
for i in range(1, n+1):
    if h[i] > c[i]:
        ans += 1
print(ans)

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

for i in range(M):
    Ai, Bi = map(int, input().split())
    if H[Ai-1] <= H[Bi-1]:
        memo[Ai-1] = 0
    if H[Bi-1] <= H[Ai-1]:
        memo[Bi-1] = 0

print(sum(memo))

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)

vis = [False]*n

cnt = 0

for i in range(n):
    if not vis[i]:
        vis[i] = True
        
        gtr = [ H[i] > H[x] for x in g[i] ]
        if all(gtr):
            cnt+=1
            for x in g[i]:vis[x] = True


print(cnt)

Solution (Python):
n,m=map(int, input().split())
dame=set()
h=list(map(int, input().split()))
for x in range(m):
    a,b=map(int, input().split())
    ah=h[a-1]
    bh=h[b-1]
    if ah>=bh:
        dame.add(b)
    if bh>=ah:
        dame.add(a)
print(n-len(dame))

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

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

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

HT = [0 for i in range(N)]

for i in range(M):
    A, B = (int(x) for x in input().split())
    HT[A-1] = max(HT[A-1], H[B-1])
    HT[B-1] = max(HT[B-1], H[A-1])
    
count = 0

for i in range(N):
    count += H[i] > HT[i]

print(count)

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

H = list(map(int, input().split()))
ma = [0 for _ in range(N)]

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

ans = 0
for i in range(N):
    ans += H[i] > ma[i]

print(ans)

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

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

print(N-len(S))

Solution (Python):
n,m = map(int,input().split())
heights = list(map(int, input().split()))
a = []
b = []
for i in range (0, m):
    am, bm =map(int,input().split())
    a.append(am)
    b.append(bm)
not_peaks = {}
for i in range(0, m):
    if heights[a[i]-1]>heights[b[i]-1]:
        not_peaks[b[i]]=0
    elif heights[b[i]-1]>heights[a[i]-1]:
        not_peaks[a[i]]=0
    else:
        not_peaks[a[i]]=0
        not_peaks[b[i]]=0
print(n-len(not_peaks))

Solution (Python):
N,M = map(int,input().split())
H=list(map(int,input().split()))
l = [[]*i for i in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    l[A-1].append(B)
    l[B-1].append(A)
ans=0
for j in range(N):
    if all(H[elem-1] < H[j] for elem in l[j])==True:
        ans +=1
print(ans)

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
l=[[]*i for i in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    l[A-1].append(B)
    l[B-1].append(A)
ans=0
for j in range(N):
    if all(H[elem-1]<H[j] for elem in l[j])==True:
        ans+=1
print(ans)

Solution (Python):
N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
paths = [list(map(int, input().split(' '))) for _ in range(M)]
good_observatory = [True]*N
for path in paths:
    if good_observatory[path[0]-1] and H[path[0]-1] <= H[path[1]-1]:
        good_observatory[path[0]-1] = False
    if good_observatory[path[1]-1] and H[path[1]-1] <= H[path[0]-1]:
        good_observatory[path[1]-1] = False

print(sum(boolean for boolean in good_observatory))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
x = [0 for _ in range(n)]
for j in range(m):
    a = list(map(int, input().split()))
    s = a[0] - 1
    t = a[1] - 1
    if h[s] < h[t]:
        x[s] = 1
    elif h[s] > h[t]:
        x[t] =1
    else:
        x[s] = 1
        x[t] = 1

print(x.count(0))

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

for i in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    if obs_list[a] <= obs_list[b]:
        ans[a] += 1
    if obs_list[b] <= obs_list[a]:
        ans[b] += 1

print(ans.count(0))

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

is_min = [0 for _ in range(N)]
for i in range(M):
    A = root[i][0] - 1
    B = root[i][1] - 1

    if H[A] > H[B]:
        is_min[B] = 1

    elif H[A] == H[B]:
        is_min[A] = 1
        is_min[B] = 1

    else:
        is_min[A] = 1

print(N - sum(is_min))

Solution (Python):
N, M = map(int, input().split())
V = list(map(int, input().split()))
ans = [1]*N

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

print(sum(ans))

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

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())
  A -= 1
  B -= 1
  G[A].append(B)
  G[B].append(A)

ans = 0
for i in range(N):
  is_good = True
  for j in G[i]:
    if H[j] >= H[i]:
      is_good = False
      break
  if is_good:
    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())
  A -= 1
  B -= 1
  G[A].append(B)
  G[B].append(A)

ans = 0
for i in range(N):
  is_good = True
  for j in G[i]:
    if H[j] >= H[i]:
      is_good = False
      break
  if is_good:
    ans += 1

print(ans)

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


can_go = [[] for i in range(n)]

for i in a:
    
    can_go[i[0]-1].append(i[1])
    can_go[i[1]-1].append(i[0])

b = 0
ans=0
for i,j in enumerate(can_go):
    
    b= 0

    for k in j:
        
        if h[k-1]>=h[i]:
            b=1
            
            break
    if b==1:
        b=0
    else:
        ans+=1
print(ans)

Solution (Python):
N, M = map(int, input().split())
c_list = [[] for _ in range(N)]
e_list = list(map(int, input().split()))
for _ in range(M):
   a, b = map(lambda i: int(i) - 1, input().split())
   c_list[a].append(b)
   c_list[b].append(a)
ans = 0
for i, e in enumerate(e_list):
   for j in c_list[i]:
       if e <= e_list[j]:
           break
   else:
       ans += 1

print(ans)

Solution (Python):
from sys import stdin,stdout
inp = stdin.readline
out = stdout.write
n,m = map(int,inp().split())
h = [int(u) for u in inp().split()]
adj = [[] for _ in range(n)]
for i in range(m):
    u,v = map(int,inp().split())
    u -= 1
    v -= 1
    adj[u].append(v)
    adj[v].append(u)
marked = [False for _ in range(n)]
cnt = 0
for u in range(n):
    if marked[u]: continue
    good = True
    for v in adj[u]:
        if h[u] <= h[v]:
            good = False
            break
        else: marked[v] = True
    if good: cnt += 1
out(str(cnt))

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


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

print(ans)

Solution (Python):
(n, m), h, *r = [[*map(int, i.split())] for i in open(0)]
g =[] + h

for i in r:
    g[i[0]-1] *= h[i[0]-1] > h[i[1]-1]
    g[i[1]-1] *= h[i[1]-1] > h[i[0]-1]
print(len([i for i in g if i !=0]))

Solution (Python):
import sys
INF = 10**9
sys.setrecursionlimit(INF)


def main():
    n, m, *hab = map(int, open(0).read().split())
    h = hab[:n]
    ab = hab[n:]
    ab = [[ab[2 * i] - 1, ab[2 * i + 1] - 1] for i in range(m)]

    ans_set = set(range(n))
    not_ans_set = set()
    
    for a, b in ab:
        if h[a] >= h[b]:
            ans_set.discard(b)
            not_ans_set.add(b)
        if h[a] <= h[b]:
            ans_set.discard(a)
            not_ans_set.add(a)
        

    ans = len(ans_set)
    print(ans)
    return(ans)


if __name__ == '__main__':
    main()

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

n_set = set()
for i in range(1,n+1):
    n_set.add(i)

for ele in m_list:
    if h[ele[0]-1] - h[ele[1]-1] > 0:
        n_set -= {ele[1]}
    elif h[ele[0]-1] == h[ele[1]-1]:
        n_set -= {ele[0], ele[1]}
    else:
        n_set -= {ele[0]}

print(len(n_set))

Solution (Python):


from sys import stdin
input = stdin.readline

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

p = [0]*n

for i in range(m):
    x,y = map(int,input().split())
    if h[x-1] > h[y-1]:
        p[y-1] = 1
    elif h[x-1] < h[y-1]:
        p[x -1] = 1
    elif  h[x-1] == h[y-1]:
        p[y-1] = 1
        p[x-1] = 1


print(p.count(0))