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 numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
ans = [1 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] = 0
    if H[b - 1] > H[a - 1]:
        ans[a - 1] = 0
    if H[b - 1] == H[a - 1]:
        ans[a - 1] = 0
        ans[b - 1] = 0
print(np.count_nonzero(np.array(ans)))

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

lst=[-1]*n
for i in range(m):
    a,b=ab[i]
    a-=1
    b-=1
    if h[a]<h[b]:
        lst[a]=0
    elif h[a]>h[b]:
        lst[b]=0
    else:
        lst[a]=0
        lst[b]=0

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

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

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


tenboudai=[True for i in range(N)]

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


print(sum(tenboudai))

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

Solution (Python):
N, K = map(int,input().split())
H = list(map(int,input().split()))
L = [[] for k in range(N)]
for _ in range(K):
    A, B = map(int,input().split())
    L[A-1].append(B-1)
    L[B-1].append(A-1)
ans = 0
for k in range(N):
    f = 1
    for e in L[k]:
        if H[k] <= H[e]:
            f = 0
            break
    ans += f
print(ans)

Solution (Python):

import sys


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    miti = [set() for _ in range(N)]
    for i in range(M):
        a = A[i] - 1
        b = B[i] - 1
        miti[a].add(b)
        miti[b].add(a)

    res = 0
    for i in range(N):
        jibunn = H[i]
        ok = True
        for aite in miti[i]:
            if H[aite] >= jibunn:
                ok = False
        if ok:
            res += 1

    print(res)

    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 math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  l=LI()

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

  for _ in range(m):
    a,b=LI()
    a-=1
    b-=1
    ll[a].append(b)
    ll[b].append(a)

  ans=0
  for i,h in enumerate(l):
    mx=-inf
    f=True
    for x in ll[i]:
      mx=max(mx,l[x])
      if h<=mx:
        f=False
        break
    if f:
      ans+=1

  return ans


print(main())

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
H = LIST()
AB = [LIST() for _ in range(M)]

ma = [0]*N

for A, B in AB:
	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):
	if H[i] > ma[i]:
		ans += 1

print(ans)

Solution (Python):


def solve():
    N, M = list(map(int, input().split()))
    Hs = list(map(int, input().split()))

    goods = [1 for _ in range(N)]
    for _ in range(M):
        a, b = list(map(int, input().split()))
        a, b = a-1, b-1
        if Hs[a] > Hs[b]:
            goods[b] = 0
        elif Hs[b] > Hs[a]:
            goods[a] = 0
        else:
            goods[a] = 0
            goods[b] = 0

    print(sum(goods))


if __name__ == "__main__":
    solve()

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
    L[a] = max(L[a], H[b])
    L[b] = max(L[b], H[a])

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

Solution (Python):
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N, M = list(map(int, sys.stdin.buffer.readline().split()))
H = list(map(int, sys.stdin.buffer.readline().split()))
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]


class UnionFind:
    def __init__(self, size=None, nodes=None):
        """
        size か nodes どっちか指定。
        nodes は set、size は list を使う。
        :param int size:
        :param collections.Iterable nodes:
        """
        assert size is not None or nodes is not None
        if size is not None:
            self._parents = [i for i in range(size)]
            self._ranks = [0 for _ in range(size)]
            self._sizes = [1 for _ in range(size)]
        else:
            self._parents = {k: k for k in nodes}
            self._ranks = {k: 0 for k in nodes}
            self._sizes = {k: 1 for k in nodes}

    def unite(self, x, y):
        """
        x が属する木と y が属する木を併合
        :param x:
        :param y:
        """
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        
        if self._ranks[x] > self._ranks[y]:
            
            self._parents[y] = x
            self._sizes[x] += self._sizes[y]
        else:
            
            self._parents[x] = y
            self._sizes[y] += self._sizes[x]
            if self._ranks[x] == self._ranks[y]:
                self._ranks[y] += 1

    def root(self, x):
        """
        x が属する木の root
        :param x:
        """
        if self._parents[x] == x:
            return x
        self._parents[x] = self.root(self._parents[x])
        return self._parents[x]

    def size(self, x):
        """
        x が属する木のノード数
        :param x:
        """
        return self._sizes[self.root(x)]

















ok = [True] * N
for a, b in AB:
    a -= 1
    b -= 1
    if H[a] <= H[b]:
        ok[a] = False
    if H[a] >= H[b]:
        ok[b] = False
print(ok.count(True))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, m = LI()
    H = LI()
    ab = []
    good = [True for _ in range(n)]
    for i in range(m):
        a, b = LI_()
        ab.append((a, b))
        if H[a] > H[b]:
            good[b] = False
        if H[a] < H[b]:
            good[a] = False
        if H[a] == H[b]:
            good[b] = False
            good[a] = False
    cnt = 0
    for i in range(n):
        if good[i]:
            cnt += 1
    print(cnt)
main()

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

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

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


print(sum(kouho))

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
HH = [set() for x in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    HH[A].add(B)
    HH[B].add(A)

a = 0
for i in range(N):
    iH = H[i]
    h = 1
    for b in HH[i]:
        bH = H[b]
        if bH >= iH:
            h = 0
    a += h

print(a)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
road = []
ans = [True for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    A -= 1; B -= 1
    if H[A] < H[B]:
        ans[A] = False
    elif H[A] > H[B]:
        ans[B] = False
    else:
        ans[A] = False
        ans[B] = False

print(sum(ans))

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
adj=[set() for _ in range(N)]
for _ in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    adj[a].add(b)
    adj[b].add(a)


ans=0
for i in range(N):
    if len(adj[i])==0:
        ans+=1
    elif all([H[i]>H[v] for v in adj[i]]):
        ans+=1
print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
h=list(map(int,input().split()))
G=[[] for i in range(n)]
for i 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):
    check=True
    for j in G[i]:
        if h[i]<=h[j]:
            check=False
    if check:
        ans+=1
print(ans)

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
ls=[[] for i in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    ls[A-1].append(B-1)
    ls[B-1].append(A-1)
cnt=0    
for i in range(N):
    flag=True
    for j in range(len(ls[i])):
        if(H[ls[i][j]]>=H[i]):
            flag=False
    if(flag):cnt+=1        
print(cnt)

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

N, M = map(int, input().split())
H = list(map(int, input().split()))
edge = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

ans = 0
for s, h in enumerate(H, start=1):
    if not edge[s]:
        ans += 1
    else:
        tmp = [H[i-1] < h for i in edge[s]]
        if all(tmp):
            ans += 1

print(ans)

Solution (Python):




class Node(object):

  def __init__(self, pos):
    self.pos = pos
    self.highest = True


def main():
  _, M = map(int, input().split())
  nodes = [Node(v) for v in map(int, input().split())]

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

    if a.pos <= b.pos:
      a.highest = False

    if b.pos <= a.pos:
      b.highest = False

  print(len([n for n in nodes if n.highest]))


if __name__ == '__main__':
  main()

Solution (Python):
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,m = mi()
    h = li()
    e = [1 for i in range(n)]

    for i in range(m):
        a,b = mi()
        a-=1
        b-=1
        if h[a] <= h[b]:
            e[a] = 0
        if h[b] <= h[a]:
            e[b] = 0

    print(sum(e))



main()

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

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

for i in range(N):
    for v in edge[i]:
        if H[i] <= H[v]:
            judge[i] = False

print(sum(judge))

Solution (Python):

import sys
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def slv(N, M, H, AB):
    g = [list() for _ in range(N+1)]
    for a, b in AB:
        g[a].append(b)
        g[b].append(a)

    ans = 0
    for u in range(1, N+1):
        h = H[u-1]
        for v in g[u]:
            if H[v-1] >= h:
                break
        else:
            ans += 1

    return ans


def main():
    N, M = read_int_n()
    H = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    print(slv(N, M, H, AB))


if __name__ == '__main__':
    main()

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

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

if __name__ == '__main__':
    main()

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

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

for i 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))

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

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

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

ans = 0
for i in range(N):
    for h in lst[i]:
        if H[i] <= H[h]:
            break
    else:
        ans += 1
print(ans)

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

good = [True for _ in range(n)]
for a, b in list_ab:
    if h[a] <= h[b]:
        good[a] = False
    if h[a] >= h[b]:
        good[b] = False

answer = sum([int(i) for i in good])
print(answer)

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

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

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

print(T.count(1))

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    n, m = MII()
    hh = MII()
    ab = [MIIZ() for _ in range(m)]
    t = {i: [] for i in range(n)}
    cnt = 0
    for a, b in ab:
        t[a].append(b)
        t[b].append(a)
    for k, v in t.items():
        o = hh[k]
        for vi in v:
            if hh[vi] >= o:
                break
        else:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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

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

good = [1] * n

for a, b in ab:
    a -= 1
    b -= 1

    if h[a] >= h[b]:
        good[b] = 0

    if h[a] <= h[b]:
        good[a] = 0

ans = good.count(1)
print(ans)

Solution (Python):
from collections import defaultdict as dd
N, M = map(int, input().split())
Hs = list(map(int, input().split()))
Es = dd(dict)
for _ in range(M):
    a, b = map(int, input().split())
    Es[a-1][b-1] = Es[b-1][a-1] = 1

ans = 0
for i in range(N):
    h = Hs[i]
    for j in Es[i].keys():
        if h <= Hs[j]:
            break
    else:
        ans += 1
print(ans)

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

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    ng = {n: 0 for n in range(1, N + 1)}
    for _ in range(M):
        ai, bi = map(int, input().split())
        ng[ai] = max(ng[ai], H[bi - 1])
        ng[bi] = max(ng[bi], H[ai - 1])

    count = 0
    for v in range(1, N + 1):
        if H[v - 1] > ng[v]:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

GOOD = [True] * (N + 1)
GOOD[0] = False
for _ in range(M):
    A, B = map(int, input().split())

    HA = H[A]
    HB = H[B]

    if HA == HB:
        GOOD[A] = False
        GOOD[B] = False
    elif HA < HB:
        GOOD[A] = False
    elif HB < HA:
        GOOD[B] = False

cnt = 0
for i in range(N + 1):
    if GOOD[i]:
        cnt += 1

print(cnt)

Solution (Python):
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s+=a
        yield s


sys.setrecursionlimit(200005)


def main():
    N,M = isRaw()
    Hs = isRaw()
    isGood = [1]*N
    for m in range(M):
        A,B = isRaw()
        if Hs[A-1] >= Hs[B-1]:
            isGood[B-1]=0
        if Hs[A-1]<=Hs[B-1]:
            isGood[A-1]=0
    return sum(isGood)
    
if __name__ == "__main__":
    print(main())

Solution (Python):
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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


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

	print(sum(ans))



if __name__ == '__main__':
	main()

Solution (Python):
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys,heapq,math
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    out = sys.stdout.write
    
    INF = int(1e9)
    mod = int(1e9)+7

    n,m=mdata()
    H=mdata()
    l=[1]*n
    for i in range(m):
        a,b=mdata()
        if H[a-1]<H[b-1]:
            l[a-1]=0
        elif H[a-1]>H[b-1]:
            l[b-1]=0
        else:
            l[a-1]=0
            l[b-1]=0
    cnt=0
    for i in l:
         if i==1:
             cnt+=1
    print(cnt)

if __name__ == '__main__':
    main()

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

from collections import defaultdict
G = defaultdict(list)

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):
    for j in G[i]:
        if hl[i] <= hl[j]:
            break
    else:
        ans += 1

print(ans)

Solution (Python):
n,m = map(int, input().split())
h = list(map(int, input().split()))
adjacent_list = [[] for i in range(n+1)]
def check(node):
    now = h[node-1]
    for i in adjacent_list[node]:
        if now <= h[i-1]:
            return False
    return True
for i in range(m):
    a,b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
ans = 0
for i in range(1,n+1):
    if check(i):
        ans += 1
print(ans)

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

    is_good = [True for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if H[a] > H[b]:
            is_good[b] = False
        elif H[a] < H[b]:
            is_good[a] = False
        elif H[a] == H[b]:
            is_good[a] = False
            is_good[b] = False

    print(is_good.count(True))

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

ans = [1] * n

for i 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
input = sys.stdin.readline
def main():
    N, M = map( int, input().split())
    H = list( map( int, input().split()))
    E = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map( lambda x: int(x)-1, input().split())
        E[a].append(b)
        E[b].append(a)
    ans = 0
    for i in range(N):
        h = H[i]
        ans += 1
        for e in E[i]:
            if h <= H[e]:
                ans -= 1
                break
    print(ans)
if __name__ == '__main__':
    main()

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

goods = [True] * N
for _ in range(M):
	A, B = map(int, input().split())
	A -= 1
	B -= 1
	HA = Hs[A]
	HB = Hs[B]
	if HA <= HB:
		goods[A] = False
	if HB <= HA:
		goods[B] = False

count = 0
for g in goods:
	if g:
		count += 1
print(count)

Solution (Python):
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


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


def llmi(n):
    return [lmi() for _ in range(n)]


N, M = lmi()
H = lmi()

AB = llmi(M)
adj = collections.defaultdict(set)
for a, b in AB:
    a = a - 1
    b = b - 1
    adj[a].add(b)
    adj[b].add(a)

ans = 0
for i, h in enumerate(H):
    flag = True
    for j in adj[i]:
        if H[j] >= h:
            break
    else:
        ans += 1
print(ans)

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

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

n, m = map(int,input().split())
H = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(m)]
for i in range(m):
    for j in range(2):
        A[i][j] -= 1

ANS = [0] * n

for i in range(m):
    for j in range(2):
        ANS[A[i][j]] += 1

for i in range(m):
    if H[A[i][0]] > H[A[i][1]]:
        ANS[A[i][0]] -= 1
    elif H[A[i][0]] < H[A[i][1]]:
        ANS[A[i][1]] -= 1

print(ANS.count(0))

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    H=list(map(int,input().split()))
    edge=[[] for _ in range(N)]
    for i in range(M):
        a,b=map(int1,input().split())
        edge[a].append(b)
        edge[b].append(a)
    ans=0
    for v in range(N):
        for nv in edge[v]:
            if H[v]<=H[nv]:
                break
        else:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

readline = sys.stdin.readline
N, M = map(int, readline().split())
H = list(map(int, readline().split()))
good = [True] * N
for _ in range(M):
    a, b = map(int, readline().split())
    if H[a-1] > H[b-1]:
        good[b-1] = False
    elif H[a-1] < H[b-1]:
        good[a-1] = False
    else:
        good[a-1] = good[b-1] = False
print(sum(good))

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

graph = [[] for _ in range(N)]
for a, b in X:
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

ans = [True] * N
for u in range(N):
    for v in graph[u]:
        ans[u] &= H[u] > H[v]

print(sum(ans))

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

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

Solution (Python):

N,M = map(int, input().split())
good = [1 for i in range(N)]
height = list(map(int, input().split()))

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