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 = list(map(int, input().split()))
h = list(map(int, input().split()))
neighbor = [[] for _ in range(n)]

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

cnt = 0
for i in range(n):
    if all([h[i] > h[j] for j in neighbor[i]]):
        cnt += 1
print(cnt)

Solution (Python):

def main():
    n, m = map(int, input().split(" "))
    ls=[{} for _ in range(n)]
    h = list(map(int, input().split(" ")))
    for i in range(n):
        ls[i] = [h[i]]
    ab = []
    for i in range(m):
        ab.append(list(map(lambda i:int(i)-1, input().split(" "))))
    for i in range(m):
        if ls[ab[i][0]][0] >= ls[ab[i][1]][0]:
            ls[ab[i][1]].append(ls[ab[i][0]][0]+1)
        if ls[ab[i][1]][0] >= ls[ab[i][0]][0]:
            ls[ab[i][0]].append(ls[ab[i][1]][0] + 1)
    cnt = 0
    for i in range(n):
        if ls[i][0] == max(ls[i]):
            cnt += 1
    print(cnt)

        

    

if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())
heights = [0] + list(map(int, input().split()))
routes = [[] for _ in range(N+1)]
for __ in range(M):
  a, b = map(int, input().split())
  routes[a].append(b)
  routes[b].append(a)
answer = 0
for i, route in enumerate(routes):
  if i == 0:
    continue
  if len(route) == 0:
    answer += 1
    continue
  else:
    highest = True
    for dist in route:
      if heights[i] <= heights[dist]:
        highest = False
        break
    if highest:
      answer += 1
print(answer)

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

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

cnt = n
for i in range(n):
  for j in g[i]:
    if h[i] <= h[j]:
      cnt -= 1
      break
print(cnt)

Solution (Python):
N,M=map(int,input().split())
Hlist=list(map(int,input().split()))
ABlist=[]
for _ in range(M):
    ABlist.append(list(map(int,input().split())))
flaglist=[1]*N
for row in ABlist:
    one=row[0]-1 
    two=row[1]-1
    if Hlist[one]<=Hlist[two]:
        flaglist[one]=0
    if Hlist[one]>=Hlist[two]:
        flaglist[two]=0
print(sum(flaglist))

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

ans = sum(OK)
print(ans)

Solution (Python):
from sys import stdin

def getval():
    n,m = map(int,input().split())
    h = list(map(int,stdin.readline().split()))
    p = [list(map(int,stdin.readline().split())) for i in [0]*m]
    return n,m,h,p

def main(n,m,h,p):
    g = [[] for i in range(n)]
    for i in p:
        g[i[0]-1].append(i[1]-1)
        g[i[1]-1].append(i[0]-1)
    ans = 0
    for i in range(n):
        if not g[i]:
            ans += 1
        else:
            temp = h[i]
            flag = True
            for j in g[i]:
                if h[j]>=temp:
                    flag = False
                    break
            if flag:
                ans += 1
    print(ans)
                

if __name__=="__main__":
    n,m,h,p = getval()
    main(n,m,h,p)

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

for i in range(n):
    if l[i] == []:
        cnt+=1

    elif h[i] > max(l[i]):
        cnt +=1
    

print(cnt)

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

ans = 0
for i in range(n):
    high = h[i]
    for j in c[i]:
        if h[j] >= high:
            break
    else:
        ans += 1
print(ans)

Solution (Python):

import sys
from itertools import chain


def solve(
    N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"
):
    ok = [1 for _ in range(N)]
    for a, b in zip(A, B):
        if H[a - 1] <= H[b - 1]:
            ok[a - 1] = 0
        if H[b - 1] <= H[a - 1]:
            ok[b - 1] = 0

    return sum(ok)


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    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))
    answer = solve(N, M, H, A, B)
    print(answer)


if __name__ == "__main__":
    main()

Solution (Python):
ri = lambda: map(int, input().split())

N, M = ri()
H = list(ri())
T = [0]*N
for _ in range(M):
    a, b = ri()
    T[a-1] = max(T[a-1], H[b-1])
    T[b-1] = max(T[b-1], H[a-1])

print(sum(1 for i, h in enumerate(T) if h == 0 or h < H[i]))

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

count=0
for i in range(n) :
    if A[i]==[] :
        count+=1
    elif max(A[i])<h[i] :
        count+=1
    else :
        continue

print(count)

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

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

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

ans = 0

for now in range(N):
    good = True
    for neighbor in graph[now]:
        if H[now] <= H[neighbor]:
            good = False
    if good:
        ans += 1
        

print(ans)

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

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

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

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

ans=0

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

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

for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    if H[A] > H[B]:
        yoi[B] = 0
    elif H[B] > H[A]:
        yoi[A] = 0
    else:
        yoi[A] = 0
        yoi[B] = 0

print(sum(yoi))

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

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

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

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

ans=0

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

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

for i in range(M):
  A,B = map(int,input().split())
  A -= 1
  B -= 1
  glaph[A].append(B)
  glaph[B].append(A)
  
ans = 0
for j in range(N):
  check = True
  for k in glaph[j]:
    if H[j] <= H[k]:
      check = False
      break
  if check:
    ans += 1
    
print(ans)

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

def main():
    n , m = map( int , input().split() )
    h = list( map( int , input().split() ) )
    goods = [ 1 for i in range(n) ]
    for i in range( m ):
        a , b = map( lambda x : int(x) - 1  , input().split() )
        if ( h[a] > h[b] ):
            goods[ b ] = 0
        if ( h[a] < h[b] ):
            goods[ a ] = 0
        if ( h[a] == h[b] ):
            goods[ a ] = 0
            goods[ b ] = 0
    print( sum(goods) )
main()

Solution (Python):
n,m=map(int,input().split())
way=[[] for i in range(n)]
H = list(map(int,input().split()))
for i in range(m):
    a,b=map(int,input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)
ans=0
for i in range(n):
    high=True
    for j in way[i]:
        if H[i]<=H[j]:
            high=0
            break
    if high:
        ans+=1
print(ans)

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

Solution (Python):
n, m = [int(i) for  i in input().split()]
h = [int(i) for i in input().split()]
edges = [[] for i in range(n)]
for _ in range(m):
  edge = [int(i)-1 for i in input().split()]
  edges[edge[0]].append(edge[1])
  edges[edge[1]].append(edge[0])
cnt = 0

for i in range(n):
  flg = True
  for j in edges[i]:
    if h[i] <= h[j]:
      flg = False
      break
  if flg:
    cnt += 1
print(cnt)

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

for i in range(n):
    way[i]=list(set(way[i]))

ans=0
for i in range(n):
    high=True
    for j in way[i]:
        if H[i]<=H[j]:
            high=0
            break
    if high:
        ans+=1
print(ans)

Solution (Python):

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

def main():
    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())

    l = [1] * N
    for i in range(M):
        if H[A[i] - 1] < H[B[i] - 1]:
            l[A[i] - 1] -= 1
        elif H[A[i] - 1] > H[B[i] - 1]:
            l[B[i] - 1] -= 1
        else:
            l[A[i] - 1] -= 1
            l[B[i] - 1] -= 1
    print(l.count(1))

if __name__ == '__main__':
    main()

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

L = [1] * N

for i in range(M):
  ai = A[i] - 1
  bi = B[i] - 1
  if H[ai] > H[bi]:
    L[bi] = 0
  elif H[bi] > H[ai]:
    L[ai] = 0
  else:
    L[ai], L[bi] = 0, 0

print(L.count(1))

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

d = [1] * N

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


print(sum(d))

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


print(ans)

Solution (Python):
def resolve():
    N, M = list(map(int, input().split()))
    H = list(map(int, input().split()))
    AB = [list(map(int, input().split())) for _ in range(M)]
    good = [True for i in range(N)]
    for a, b in AB:
        a, b = a-1, b-1
        if H[a] < H[b]:
            good[a] = False
        elif H[a] == H[b]:
            good[a] = False
            good[b] = False
        else:
            good[b] = False
    cnt = 0
    for g in good:
        if g:
            cnt += 1
    print(cnt)


if '__main__' == __name__:
    resolve()

Solution (Python):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N) ]
rst = 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
            break
    if is_peak:
        rst += 1
print(rst)

Solution (Python):
n,m = map(int,input().split())
h = list(map(int,input().split()))
r = ['t'] * n
for i in range(m):
  x,y = map(int,input().split())
  if h[x-1] > h[y-1]:
    r[y-1] = 'f'
  elif h[x-1] < h[y-1]:
    r[x-1] = 'f'
  else:
    r[y-1] = 'f'
    r[x-1] = 'f'
    
s = 0
for i in range(n):
  if r[i] == 't':
    s += 1
    
print(s)

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

f=[1]*n

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

for i in f:
    ans+=i

print(ans)

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

f=[1]*n
a=0
b=0

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

ans=0

for i in f:
    ans+=i

print(ans)

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

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

print(judge.count(True))

Solution (Python):
def main():
    n, m = map(int, input().split())
    h_lst = list(map(int, input().split()))
    ok_lst = [1 for _ in range(n)]

    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        if h_lst[a] <= h_lst[b]:
            ok_lst[a] = 0
        if h_lst[b] <= h_lst[a]:
            ok_lst[b] = 0

    ans = sum(ok_lst)
    print(ans)


if __name__ == "__main__":
    main()

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

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

        if a not in ab_dict:
            ab_dict[a] = [h_lst[b - 1]]
        else:
            ab_dict[a].append(h_lst[b - 1])

        if b not in ab_dict:
            ab_dict[b] = [h_lst[a - 1]]
        else:
            ab_dict[b].append(h_lst[a - 1])

    cnt = 0
    ab_dict_keys = ab_dict.keys()
    for i in range(1, n + 1):
        if i not in ab_dict_keys:
            cnt += 1
            continue
        if h_lst[i - 1] > max(ab_dict[i]):
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N) ]
rst = 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
    if is_peak:
        rst += 1
print(rst)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
ma = [0 for i in range(N)]
A, B = [], []
ans = 0

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

for j in range(N):
    if H[j] > ma[j]:
        ans += 1

print(ans)

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

Solution (Python):
import numpy as np
N,M = map(int, input().split())
H = np.array(list(map(int, input().split())))
box = [[] for _ in range(N)]
for im in range(M):
  a,b = map(int, input().split())
  box[a-1].append(b)
  box[b-1].append(a)
ans = 0
for n in range(N):
  index=np.array(box[n],dtype=int)-1
  if len(index)==0:
    ans += 1
    continue
  if H[n]>np.max(H[index]):
    ans += 1
print(ans)

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

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

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


print(sum(Towers))

Solution (Python):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge, rst = [ [] for i in range(N) ], 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
            break
    if is_peak:
        rst += 1
print(rst)

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

Solution (Python):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge, rst = [ [] for i in range(N) ], 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
            break
    if is_peak:
        rst += 1
print(rst)

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

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

print(sum(final))

Solution (Python):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge, rst = [ [] for i in range(N) ], 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
            break
    if is_peak:
        rst += 1
print(rst)

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

ans = [1] * N

for i in range(M):
    a_height = H[A[i]]
    b_height = H[B[i]]
    if a_height < b_height:
        ans[A[i]] = 0
    elif a_height == b_height:
        ans[A[i]] = 0
        ans[B[i]] = 0
    else:
        ans[B[i]] = 0


print(ans.count(1))

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

Solution (Python):
n,m = map(int,input().split())
hi = [0] + list(map(int,input().split()))
judge = [0]+[1]*(n)

for _ in range(m):
    a,b = map(int, input().split())
    if hi[a] >= hi[b]:
        judge[b] = 0
    if hi[a] <= hi[b]:
        judge[a] = 0
print(sum(judge))

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

d = { k+1:True for k in range(N) }

for l in L :
    if H[l[0]-1] <= H[l[1]-1] :
        d[l[0]] = False
    if H[l[0]-1] >= H[l[1]-1] :
        d[l[1]] = False 
    
ans = 0
for v in d.values() :
    if v :
        ans += 1

print(ans)

Solution (Python):

N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge, rst = [ [] for i in range(N) ], 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
            break
    if is_peak:
        rst += 1
print(rst)

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
MaxH=[0]*N
z=0
for i in range(M):
    a,b=map(int,input().split())
    MaxH[a-1]=max(MaxH[a-1],H[b-1])
    MaxH[b-1]=max(H[a-1],MaxH[b-1])

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

Solution (Python):
N,M = map(int,input().split())
N_High =list(map(int,input().split()))
N_Dict = {}
for i in range(M):
    a,b = map(int,input().split())
    if N_High[a-1] == N_High[b-1]:
        N_Dict[a] = 1
        N_Dict[b] = 1
    elif N_High[a-1] > N_High[b-1]:
        N_Dict[b] = 1
    elif N_High[a-1] < N_High[b-1]:
        N_Dict[a] = 1

print(N-len(N_Dict))

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

abc166c_peaks()

Solution (Python):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge, rst = [ [] for i in range(N) ], 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
            break
    if is_peak:
        rst += 1
print(rst)

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):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge, rst = [ [] for i in range(N)], 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for s in edge[i]:
        if H_ls[i] <= H_ls[s]:
            is_peak = False
            break
    if is_peak:
        rst += 1
print(rst)

Solution (Python):
import math
import numpy as np
import sys
import os
from operator import mul
from operator import itemgetter

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


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

p = []
d = {}
for i in range(N):
    
    d[i]=H[i]





g = [set()] * N
a = [True] * N

for i in range(M):
    f = AB[i][0]-1
    t = AB[i][1]-1
    if d[t]>d[f]:
        a[f]=False
    elif d[f]>d[t]:
        a[t]=False
    else:
        a[f]=False
        a[t]=False

print(sum(a))

Solution (Python):
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r-1] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
print(ans)

Solution (Python):
from sys import stdin,stdout
from collections import defaultdict
n,e=list(map(int,stdin.readline().split()))
h=list(map(int,stdin.readline().split()))
g=defaultdict(list)
for _ in range(e):
    a,b=map(int,stdin.readline().split())
    g[a]+=[b]
    g[b]+=[a]
ans=0
for cur in range(1,n+1):
    f=1
    for neigh in g[cur]:
        if h[neigh-1]>=h[cur-1]:
            f=0
            break
    if f:ans+=1
print(ans)

Solution (Python):

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


isgood = [True for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    if hl[a-1] <= hl[b-1]:
        isgood[a-1] = False
    if hl[b-1] <= hl[a-1]:
        isgood[b-1] = False
print(isgood.count(True))

Solution (Python):
N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N) ]
cnt = 0
for i in range(M):
    a,b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for j in edge[i]:
        if H_ls[i] <= H_ls[j]:
            is_peak = False
            break
    if is_peak:
        cnt += 1
print(cnt)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
N,M=MAP()
H=LIST()
L=[[0] for i in range(N)]
for i in range(M):
  a,b=MAP()
  a-=1
  b-=1
  L[a].append(H[b])
  L[b].append(H[a])
ans=0
for i in range(N):
  if max(L[i])<H[i]:
    ans+=1
print(ans)

Solution (Python):
import numpy as np
N, M = [int(x) for x in input().split()]
H = [float(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(M)]

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

for A, B in AB:
  max_h[A-1] = max(max_h[A-1], H[B-1])
  max_h[B-1] = max(max_h[B-1], H[A-1])

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

Solution (Python):

import numpy as np
N,M = map(int,input().split())
h = np.array(list(map(int,input().split())))
x = dict()
for _ in range(M):
    a,b = map(int,input().split())
    if a-1 not in x.keys():
        x[a-1] = []
    if b-1 not in x.keys():
        x[b-1] = []
    x[a-1].append(b-1)
    x[b-1].append(a-1)
ans = 0
for k,v in x.items():
    cand = h[k]
    tied = h[np.array(v)]
    ans += [0, 1][sum(tied >= cand) == 0]
ans += N - len(x.keys())
print(ans)

Solution (Python):

N, M = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
edge = [ [] for i in range(N)]
cnt = 0
for i in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
for i in range(N):
    is_peak = True
    for neighbor in edge[i]:
        if H_ls[i] <= H_ls[neighbor]:
            is_peak = False
            break
    if is_peak:
        cnt += 1
print(cnt)

Solution (Python):

def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    h_dict = {}
    for i in range(len(h)):
        h_dict[i+1] = h[i]
    out = []
    for k in range(m):
        a, b = map(int, input().split())
        ha = h_dict[a]
        hb = h_dict[b]
        if ha > hb:
            out.append(b)
        elif ha < hb:
            out.append(a)
        else:
            out.append(a)
            out.append(b)
    out = set(out)
    print(n - len(out))
if __name__ == '__main__':
    main()

Solution (Python):
def main(n, m, h, roads):
    is_good_peaks = [True] * n
    for road in roads:
        a, b = road[0] - 1, road[1] - 1
        if h[a] <= h[b]:
            is_good_peaks[a] = False
        if h[b] <= h[a]:
            is_good_peaks[b] = False
    print(sum(is_good_peaks))


if __name__ == "__main__":
    n, m = map(int, input().split())
    h = tuple(map(int, input().split()))
    roads = []
    for _ in range(m):
        roads.append(tuple(map(int, input().split())))
    main(n, m, h, roads)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
paths = []
for _ in range(m):
    a, b = map(int, input().split())
    if a>b:
        paths.append([b, a])
    else :
        paths.append([a, b])


ans = [True] * n


    
for j in range(m):
    path = paths[j]
    if h[path[0]-1] > h[path[1]-1]:
        ans[path[1]-1] = False
    elif h[path[0]-1] < h[path[1]-1]:
        ans[path[0]-1] = False
    else :
        ans[path[1]-1] = False
        ans[path[0]-1] = False
        

print(ans.count(True))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
AB=[list(map(int,input().split())) for _ in range(m)]
from math import gcd
ans=[1 for _ in range(n)]

for ab in AB:
    if h[ab[0]-1]>h[ab[1]-1]:
        ans[ab[1]-1]=0
    elif h[ab[0]-1]<h[ab[1]-1]:
        ans[ab[0]-1]=0
    else:
        ans[ab[0]-1]=0
        ans[ab[1]-1]=0


print(sum(ans))

Solution (Python):
import sys
N, M = map(int, input().split())
H = tuple(map(int, input().split()))
G = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, sys.stdin.readline().split())
    G[a-1].add(b-1)
    G[b-1].add(a-1)

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