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 = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
from collections import defaultdict

P = defaultdict(set)
for _ in range(M):
    a,b = [int(x) for x in input().split()]
    P[a-1].add(b-1)
    P[b-1].add(a-1)

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

print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10**7)


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

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

A = tuple(map(int, input().rstrip().split()) for _ in range(M))


items = dict((i + 1, []) for i in range(N))

for k, v in A:
    items[k].append(H[v - 1])
    items[v].append(H[k - 1])



ans = 0
for i in range(N):
    if len(items[i + 1]) == 0:
        ans += 1
        continue

    found = False
    for item in items[i + 1]:
        if item >= H[i]:
            found = True
            continue

    if not found:
        ans += 1
        continue

    
    
    
    
        
        
        

        
        
        
        

        
        
        

print(ans)

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

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

temp = input()
temp = temp.split()
height = [int(s) for s in temp]
bridge = [0] * N
data = [0] * N

for i in range(M):
  temp = input()
  temp = temp.split()
  A = int(temp[0])
  B = int(temp[1])
  if height[A-1] > height[B-1]:
    data[B-1] = 1
  elif height[A-1] < height[B-1]:
    data[A-1] = 1
  else:
    data[A-1] = data[B-1] = 1
    
  bridge[A-1] = 1
  bridge[B-1] = 1

count = 0
for i in range(N):
  if data[i] == 0 or bridge[i] == 0:
    count += 1
print(count)

Solution (Python):
N_ko, M_hon = map(int, input().split())
Height = list(map(int, input().split()))

Low = []
ans = 0

for i in range(M_hon):
    a, b = map(int, input().split())
    
    h_a = Height[a - 1]
    h_b = Height[b - 1]

    
    if (h_a != h_b):
        
        if (h_a > h_b):
            Low.append(b)
        else:
            Low.append(a)
    else:
        Low.append(a)
        Low.append(b)

ans = N_ko - len(set(Low))


print(ans)

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

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

print(array.count(0))

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

print(ans)

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

Solution (Python):



import numpy as np

N, M = map(int, input().split())
H_list = [int(x) for x in input().split()]
N_list = np.arange(1,N+1,1)
Max_list = np.zeros(N)
for i in range(M):
    A, B = map(int, input().split())
    Max_list[A-1] = max(Max_list[A-1],H_list[B-1])
    Max_list[B-1] = max(Max_list[B-1],H_list[A-1])
    
ans = 0
for i in range(len(Max_list)):
    ans += H_list[i] > Max_list[i]

print(ans)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_dict = {}
for i, name in enumerate(h, 1):
    h_dict[i] = name

ab = []
for _ in range(m):
    ab.append(list(map(int, input().split())))

flg_bad = set()
for j in ab:
    if h_dict[j[0]] < h_dict[j[1]]:
        flg_bad.add(j[0])
    elif h_dict[j[0]] > h_dict[j[1]]:
        flg_bad.add(j[1])
    elif h_dict[j[0]] == h_dict[j[1]]:
        flg_bad.add(j[0])
        flg_bad.add(j[1])

print(len(h) - len(flg_bad))

Solution (Python):


N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A, B = [], []
for m in range(M):
    A_m, B_m = list(map(int, input().split()))
    A.append(A_m)
    B.append(B_m)


def main() -> None:
    """Entry point
    """
    
    
    observatory = [True for n in range(N)]  
    for A_m, B_m in zip(A, B):
        A_m -= 1  
        B_m -= 1  
        if H[A_m] < H[B_m]:
            observatory[A_m] = False
        elif H[A_m] > H[B_m]:
            observatory[B_m] = False
        else:
            observatory[A_m] = False
            observatory[B_m] = False

    result = sum(observatory)

    
    print(result)


if __name__ == "__main__":
    main()

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

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

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

ans = 0
for j in range(N):
  if g[j] == r[j]:
    ans += 1
print(ans)

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

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

ans = sum([c == 0 for c in check])
print(ans)

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

Solution (Python):
n,m=map(int,input().split())
l=list(map(int,input().split()))
not_good=[]
for i in range(m):
  a,b=map(int,input().split())
  if l[a-1]>l[b-1]:
      not_good.append(b)
  if l[a-1]<l[b-1]:
      not_good.append(a)
  if l[a-1]==l[b-1]:
    not_good.append(a)
    not_good.append(b)

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

Solution (Python):


import sys
readline = sys.stdin.readline

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

ans = [True] * N

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

print(sum(ans))

Solution (Python):
N, M = map(int, input().split())
p_list = [1 for _ in range(N)]
e_list = list(map(int, input().split()))
for _ in range(M):
   a, b = map(int, input().split())
   if e_list[a - 1] <= e_list[b - 1]:
       p_list[a - 1] = 0
   if e_list[b - 1] <= e_list[a - 1]:
       p_list[b - 1] = 0
print(sum(p_list))

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

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

    t[a].add(b)
    t[b].add(a)

ans = 0
for i in range(n):
    tmp = 1
    for v in t[i]:
        if h[i] <= h[v]:
            tmp = 0
            False

    ans += tmp

print(ans)

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

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

res = sum([high[i] > tenbodai[i] for i in range(n)])
print(res)

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

for i in range(M):
    a, b = list(map(int, input().split()))
    a -= 1; b -= 1
    
    g[a].add(b)
    g[b].add(a)
    
ans = 0
for i in range(N):
    f = True
    
    for v in g[i]:
        if H[i] <= H[v]:
            f = False
            break
    ans += f

print(ans)

Solution (Python):
n, m = list(map(lambda x: int(x), input().split(' ')))
hs = [int(i) for i in input().split(' ')]
is_higher = [1] * len(hs)

for i in range(m):
  a, b = [int(i) for i in input().split(' ')]
  a -= 1
  b -= 1
  if hs[a] > hs[b]:
    is_higher[b] = 0
  elif hs[a] < hs[b]:
    is_higher[a] = 0
  else:
    is_higher[a] = 0
    is_higher[b] = 0

print(sum(is_higher))

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


A_list = []
B_list = []
Remove_list = []

for _ in range(M):
  A, B = map(int, input().split())
  A_list.append(A - 1)
  B_list.append(B - 1)

for A, B in zip(A_list, B_list):
  A_height = H[A]
  B_height = H[B]
  
  if A_height <= B_height:
    Remove_list.append(A)
  
  if B_height <= A_height: 
    Remove_list.append(B)
  
S = set(range(N))
S = S - set(Remove_list)

print(len(S))

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


A_list = []
B_list = []
Remove_list = []

for _ in range(M):
  A, B = map(int, input().split())
  A_list.append(A - 1)
  B_list.append(B - 1)

for A, B in zip(A_list, B_list):
  A_height = H[A]
  B_height = H[B]
  
  if A_height <= B_height:
    Remove_list.append(A)
  
  if B_height <= A_height: 
    Remove_list.append(B)
  
S = set(range(N))
S = S - set(Remove_list)

print(len(S))

Solution (Python):
from __future__ import annotations

from dataclasses import dataclass, field
from typing import List
from typing import Tuple


@dataclass
class Tour:
    height: int
    connected_other_tours: List[Tour] = field(default_factory=list)

    def connect(self, other_tour: Tour) -> None:
        self.connected_other_tours.append(other_tour)

    def is_good(self) -> bool:
        """
        展望台 i が良い展望台であるとは、
            ・展望台 i から一本の道を使って辿り着けるどの展望台よりも展望台 i の方が標高が高いことをいいます。
            ・展望台 i から一本の道を使って辿り着ける展望台が存在しない場合も、展望台 i  は良い展望台であるといいます。
        """
        for other_tour in self.connected_other_tours:
            if self.height <= other_tour.height:
                return False

        return True


@dataclass
class Tours:
    values: List[Tour] = field(default_factory=list)

    def add(self, tour: Tour) -> None:
        self.values.append(tour)  

    def register_routes(self, ab_list: List[Tuple[int, int]]) -> None:
        for a, b in ab_list:
            tour_a = self.values[a - 1]
            tour_b = self.values[b - 1]

            tour_a.connect(tour_b)
            tour_b.connect(tour_a)

    def count_good_tours(self) -> int:
        return sum([tour.is_good() for tour in self.values])

    @classmethod
    def create(cls, height_list: List[int]) -> Tours:
        return Tours([Tour(height) for height in height_list])


def answer(height_list: List[int], ab_list: List[Tuple[int, int]]) -> int:
    tours = Tours.create(height_list)

    tours.register_routes(ab_list)

    return tours.count_good_tours()


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

ab_list = []
for _ in range(M):
  a, b = list(map(int, input().split()))
  ab_list.append((a, b))





print(answer(h_list, ab_list))

Solution (Python):
import sys
from io import StringIO
import unittest

def resolve():
    n, m = map(int, input().split())
    heights = list(map(int, input().split()))
    bridges = [list(map(int, input().split())) for i in range(m)]

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

    
    for bridge in bridges:

        bridge[0] -= 1
        bridge[1] -= 1

        if heights[bridge[0]] > heights[bridge[1]]:
            bests[bridge[1]] = False
        elif heights[bridge[0]] < heights[bridge[1]]:
            bests[bridge[0]] = False
        else:
            bests[bridge[1]] = False
            bests[bridge[0]] = False

    print(bests.count(True))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 3
1 2 3 4
1 3
2 3
2 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6"""
        output = """3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    
    resolve()

Solution (Python):
from __future__ import annotations

from dataclasses import dataclass
from dataclasses import field
from typing import List, Tuple


@dataclass
class Tour:
    height: int
    routes: List[Tour] = field(default_factory=list)

    def add_tour(self, tour: Tour) -> None:
        self.routes.append(tour)

    def is_good(self) -> bool:
        for other_tour in self.routes:
            if self.height <= other_tour.height:
                return False

        return True


@dataclass
class Actual:
    h_list: List[int]
    ab_list: List[Tuple[int, int]]
    tours: List[Tour] = field(default_factory=list)

    def answer(self) -> int:
        self.create_tours()

        self.register_routes()

        return self.count_good_tours()

    def count_good_tours(self) -> int:
        is_good_list = [tour.is_good() for tour in self.tours]

        return sum(is_good_list)

    def register_routes(self) -> None:
        for a, b in self.ab_list:
            tour_a = self.tours[a - 1]
            tour_b = self.tours[b - 1]

            tour_a.add_tour(tour_b)
            tour_b.add_tour(tour_a)

    def create_tours(self) -> None:
        for h in self.h_list:
            tour = Tour(height=h)
            self.tours.append(tour)


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

ab_list = []
for _ in range(M):
  a, b = list(map(int, input().split()))
  ab_list.append((a, b))





print(Actual(h_list, ab_list).answer())

Solution (Python):
N, M = map(int, input().split())
Hlist = list(map(int, input().split()))
badSign = set()
oldroute = []

for i in range(M):
  nowRoute = list(map(int, input().split()))
  if nowRoute == oldroute:
    badSign.add(nowRoute[0])
    badSign.add(nowRoute[1])
  else:
    if Hlist[nowRoute[0]-1] < Hlist[nowRoute[1]-1]:
      badSign.add(nowRoute[0])
    elif Hlist[nowRoute[0]-1] > Hlist[nowRoute[1]-1]:
      badSign.add(nowRoute[1])
    else:
      badSign.add(nowRoute[0])
      badSign.add(nowRoute[1])
    oldroute = nowRoute
print(N-len(badSign))

Solution (Python):
def is_good_obs(num,obs_height,linked_num):
  for e in linked_num[num-1]: 
    if(obs_height[i-1] <= obs_height[e]):
      return False
  return True
      

N,M = (int(x) for x in input().split())
obs_height = [int(x) for x in input().split()]
linked_num = [[] for i in range(N)]
good_obs_num = 0

for i in range(M):
  a,b = (int(x) for x in input().split())
  linked_num[a-1].append(b-1)
  linked_num[b-1].append(a-1)
  
for i in range(N):
    if(is_good_obs(i,obs_height,linked_num)):
      good_obs_num += 1
  
print(good_obs_num)

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline

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

    for i in range(m):
        ai, bi = map(int, input().split())

        ai -= 1
        bi -= 1

        p[ai].append(h[bi])
        p[bi].append(h[ai])

    ans = 0

    for index, pi in enumerate(p):
        p_count = len(pi)

        if p_count == 0:
            ans += 1
            continue

        pmax = max(pi)

        if h[index] > pmax:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque

if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')

def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())



n,m = mapi()
h = list(mapi())
g = defaultdict(list)
for i in range(m):
    x,y= mapi()
    g[x].append(y)
    g[y].append(x)
res = 0
for i in range(1,n+1):
    tmp = h[i-1]
    f = 1
    for j in g[i]:
        if tmp<=h[j-1]:
            f =0
            break
    if f:res+=1
print(res)

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

Solution (Python):
from collections import defaultdict
import sys

ip = lambda : sys.stdin.readline()
ipl = lambda : sys.stdin.readline().split()

n, m = map(int, ipl())
elevation = list(map(int, ipl()))
elevation.insert(0, 0)

Graph = defaultdict(list)
for i in range(m):
	s, e = map(int, ipl())
	Graph[s].append(e)
	Graph[e].append(s)
c = 0
for i in range(1, n+1):
	f = 1
	for j in Graph[i]:
		if elevation[j] >= elevation[i]:
			f = 0
			break
	if f:
		c += 1
print(c)

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

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
load_list = []
for m in range(M):
    A, B = map(int, input().split())
    load_list.append((A, B))

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

for m in range(M):
    if H[load_list[m][0] - 1] > H[load_list[m][1] - 1]:
        highest_list[load_list[m][1] - 1] = 0
    elif H[load_list[m][1] - 1] > H[load_list[m][0] - 1]:
        highest_list[load_list[m][0] - 1] = 0
    else:
        highest_list[load_list[m][0] - 1] = 0
        highest_list[load_list[m][1] - 1] = 0

print(highest_list.count(1))

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

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

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

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

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

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

ans = 0
for i in li:
    ans += i
print(ans)

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


def main():
    n_obss, n_roads = map(int, input().split())
    elevations = list(map(int, input().split()))

    is_good_obs = [True for _ in range(n_obss)]

    roads = (list(map(int, input().split())) for _ in range(n_roads))

    for road in roads:
        
        idx_a = road[0] - 1
        idx_b = road[1] - 1

        e_a = elevations[idx_a]
        e_b = elevations[idx_b]

        if e_a > e_b:
            is_good_obs[idx_b] = False
        elif e_a < e_b:
            is_good_obs[idx_a] = False
        else:
            is_good_obs[idx_a] = False
            is_good_obs[idx_b] = False

    print(sum(is_good_obs))


if __name__ == "__main__":
    main()

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

ans = 0
for i in range(N):
    flag = True
    for edge in edges[i]:
        if H[i] <= H[edge]:
            flag = False
            break
    ans += int(flag)
print(ans)

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

result = [1]*n

for _ 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[b-1] = 0
    else:
        result[a-1] = 0
        result[b-1] = 0
print(result.count(1))

Solution (Python):
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
loads = [[0] for i in range(n)]
count = 0
for k in range(m):
    start, end = map(int, input().split())
    loads[start-1].append(h_list[end-1])
    loads[end-1].append(h_list[start-1])

for k in range(n):
    if h_list[k] > max(loads[k]):
        count += 1

print(count)

Solution (Python):
import copy

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

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Solution (Python):
N,M = map(int,input().split())
H=list(map(int,input().split()))
ABmap=[[] for i in range(N)]
count=0
for i in range(M):
    A,B=map(lambda x:x-1,map(int,input().split()))
    ABmap[A].append(H[B])
    ABmap[B].append(H[A])
        
for i in range(N):
    if len(ABmap[i])==0:
        count+=1
    elif max(ABmap[i])<H[i]:
        count+=1
   
print(count)

Solution (Python):
from sys import stdin
n, m = [int(i) for i in stdin.readline().split()]
h_ls = [int(i) for i in stdin.readline().split()]
ls = set(range(n))
for i in range(m):
    a, b = [int(i) for i in stdin.readline().split()]
    a -= 1
    b -= 1
    if h_ls[a] <= h_ls[b] and a in ls:
        ls.remove(a)
    if h_ls[b] <= h_ls[a] and b in ls:
        ls.remove(b)
print(len(ls))

Solution (Python):
def main():
    N,M=map(int,input().split())
    H=list(map(int,input().split()))
    OK=[True]*N
    for _ in range(M):
        a,b=map(int, input().split())
        if H[a-1] <= H[b-1]: OK[a-1] = False
        if H[b-1] <= H[a-1]: OK[b-1] = False
    print(OK.count(True))

if __name__=='__main__':
    main()

Solution (Python):
def main():
    N,M=map(int,input().split())
    H=list(map(int,input().split()))
    OK=[True]*N
    for m in range(M):
        a,b=map(int, input().split())
        if H[a-1] <= H[b-1]: OK[a-1] = False
        if H[b-1] <= H[a-1]: OK[b-1] = False
    print(OK.count(True))

if __name__=='__main__':
    main()

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
OK=[True]*N
for m in range(M):
    a,b=map(int, input().split())
    if H[a-1] <= H[b-1]: OK[a-1] = False
    if H[b-1] <= H[a-1]: OK[b-1] = False
print(OK.count(True))

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
OK=[True]*N
for m in range(M):
    a,b=map(int, input().split())
    if H[a-1] <= H[b-1]: OK[a-1] = False
    if H[b-1] <= H[a-1]: OK[b-1] = False
print(OK.count(True))

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

good_tower=[1]*N
for i in range(M):
  A,B = map(int,input().split())
  A -=1
  B -=1
  if(hight[A]==hight[B]):
    good_tower[A]=0
    good_tower[B]=0
  elif(hight[A]<hight[B]):
    good_tower[A]=0
  else:
    good_tower[B]=0
print(good_tower.count(1))

Solution (Python):
def main():
    n,m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = {}
    for _ in range(m):
        a,b = map(int, input().split())
        ab[a] = ab.get(a, set())
        ab[a].add(b)
        
        ab[b] = ab.get(b, set())
        ab[b].add(a)

    ans = set()
    for num, val in enumerate(h,1):
        is_top = True
        if (tenbodai := ab.get(num, [])):
            for i in tenbodai:
                if val <= h[i-1]: is_top = False
        if is_top: ans.add(num)
    print(len(ans))
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n,m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = {}
    for _ in range(m):
        a,b = map(int, input().split())
        ab[a] = ab.get(a, set())
        ab[a].add(b)
        
        ab[b] = ab.get(b, set())
        ab[b].add(a)

    ans = set()
    for num, val in enumerate(h,1):
        if (tenbodai := ab.get(num, [])):
            is_top = True
            for i in tenbodai:
                if val <= h[i-1]:
                    is_top = False
            if is_top:
                ans.add(num)
        else:
            ans.add(num)
    print(len(ans))
if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
input = sys.stdin.readline
def l(): return [int(a) for a in input().split(" ")] 
ka = l()
lis = {}
saku = []
for i,a in zip(range(ka[0]),l()):
  lis[i+1] = a
for _ in range(ka[1]):
  q = l()
  maxindex = []
  a = [[lis[a],a] for a in q if a in lis]
  maxv = max(a)
  for b in a:
    if maxv[0] == b[0]:
      maxindex.append(b)
  q.pop(q.index(maxv[1]))
  if len(maxindex) != 1:
    for m in maxindex:
      q.append(m[1])
  for a in q:
    saku.append(a)
saku = set(saku)
print(len([a for a in lis if a not in saku]))

Solution (Python):


from typing import Iterable


def main() -> None:
    N, M = rmi()
    H = rmi()
    A, B = [], []
    for m in range(M):
        a, b = rmi()
        A.append(a)
        B.append(b)
    cand = set(range(1, N + 1))
    for m in range(M):
        a, b = A[m], B[m]
        ha, hb = H[a - 1], H[b - 1]
        if ha == hb:
            if a in cand:
                cand.remove(a)
            if b in cand:
                cand.remove(b)
        else:
            lower = a if ha < hb else b
            if lower in cand:
                cand.remove(lower)
    w(len(cand))


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> int:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(data: Iterable) -> None:
    print(' '.join(data))


if __name__ == '__main__':
    main()

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

hh = list(map(int, input().strip().split()))

rr = [1] * n

for i in range(m):
  a, b = map(int, input().strip().split())
  if hh[a-1] <= hh[b-1]: 
    rr[a-1] = 0
  if hh[b-1] <= hh[a-1]:
    rr[b-1] = 0
    
print(sum(rr))

Solution (Python):
def str_to_int(lista):
    for num, i in enumerate(lista):
        lista[num]=int(i)
        
def main():
    N_M=input().split()
    N=int(N_M[0])
    M=int(N_M[1])
    lst_H = input().split()
    str_to_int(lst_H)
    lst_Hcheck=[0]*N
    for i in range(M):
        temp = input().split()
        str_to_int(temp)
        temp[0] = temp[0]-1
        temp[1] = temp[1]-1
        if lst_H[temp[0]] > lst_H[temp[1]]:
        	lst_Hcheck[temp[1]] = 1
        elif lst_H[temp[0]] < lst_H[temp[1]]:
        	lst_Hcheck[temp[0]] = 1
        elif lst_H[temp[0]] == lst_H[temp[1]]:
            lst_Hcheck[temp[0]] = 1
            lst_Hcheck[temp[1]] = 1
    print(lst_Hcheck.count(0))
main()

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

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

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [0] * 200000
for i in range(M):
    a, b = map(int, input().split())
    A[a] = max([H[b-1], A[a]])
    A[b] = max([H[a-1], A[b]])
ans = 0
for i in range(N):
    if A[i+1] < H[i]:
        ans += 1
print(ans)

Solution (Python):
N, M = map(int, input().split())
height_list = list(map(int, input().split()))
node_dict ={}

for i in range(M):
    A, B = map(int, input().split())
    if A in node_dict.keys():
        node_dict[A].append(B)
    else:
        node_dict[A] = []
        node_dict[A].append(B)
    
    if B in node_dict.keys():
        node_dict[B].append(A)
    else:
        node_dict[B] = []
        node_dict[B].append(A)

good_tower_with_node = 0
for i in node_dict.keys():
    for j in node_dict[i]:
        if height_list[i-1] <= height_list[j-1]:
            break
    else:
        good_tower_with_node += 1
        
print(good_tower_with_node + N -len(node_dict.keys()))