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



Sample input:
4 3
1 2 3 4
1 3
2 3
2 4


Sample output:
2

Submission status: Runtime Error

Solution code:
import numpy as np

N,M = [int(i) for i in input().split(" ")]
H = [int(i) for i in input().split(" ")]
root = np.zeros([N,N])
for i in range(M):
    a,b = [int(i)-1 for i in input().split(" ")]
    root[a,b] = 1
    root[b,a] = 1

ans = 0
for i in range(N):
    count = 0
    for l in range(N):
        if root[i,l] == 1 and H[i] <= H[l]:
            count = 1
    if count == 0:
        ans += 1
    
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
s=0
b=[]
co=[]
for i in range(n):
  co.append([0*n])
for i in range(n):
  b.append([0,0])
for i in range(m):
    p1,p2=map(int,input().split())
    if co[p1-1][p2-1]==0:
        co[p1-1][p2-1]=1
        co[p2-1][p1-1]=1
        b[p1-1][0]+=1
        b[p2-1][0]+=1
        if a[p1-1]>a[p2-1]:
            b[p1-1][1]+=1
        else:
            b[p2-1][1]+=1

for i in b:
  if i[0]==i[1]:
    s+=1
print(s)

Submission status: Runtime Error

Solution code:
import numpy as np 

N, M = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
mat = np.zeros((N, N), dtype="uint64")
for j in range(M):
    a, b = [int(x) for x in input().split()]
    if mat[a - 1, b - 1] == 0:
        mat[a - 1, b - 1] = H[b - 1]
        mat[b - 1, a - 1] = H[a - 1]

count = 0
for i in range(N):
    h = H[i]
    max_h = np.max(mat[i,:])
    if h > max_h:
        count += 1
print(count)

Submission status: Runtime Error

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

J=[0]*N
for i in range(M):
    if H[AB[i][0]-1]<H[AB[i][1]-1]:
        J[AB[i][0]]+=1
    else:
        J[AB[i][1]]+=1
c=0
for i in J:
    if i == 0:
        c+=1

print(c)

Submission status: Runtime Error

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    n, m = wi()
    h = wi()
    G = defaultdict(list)
    for i in range(1, n):
        a, b = map(int, input().split())
        G[a].append(b)
        G[b].append(a)
    # print(G)
    flag = True
    cnt = 0
    for i in range(1, n+1):
        flag = True
        for j in set(G[i]):
            if h[i-1] <= h[j-1]:
                flag = False
                break
        if flag:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
[n, m] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
st = [[] for _ in range(n)]
for i in range(m):
    [a, b] = [int(i) for i in input().split()]
    st[a-1].append(b-1)
    st[b-1].append(a-1)
cnt = 0
for i, height in enumerate(h):
    line = []
    hoge = set(st[i])
    for huga in hoge:
        line.append(h[huga])
    if type(huga) is int:
        if height > huga:
            cnt += 1
    elif height > max(huga):
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
W = [int(input()) for _ in range(N)]
D = [W[0]]

for  i  in  range ( 1 , N ):
    b = W[i]
    if max(D) < b:
        D.append(b)
    else:
        for  j  in  range ( len ( D )):
            if D[j] >= b:
                D[j] = b
                break

print ( len ( D ))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
h_list=list(map(int,input().split))
col_list=[[0]*n]*n
count=0
for i in range(m):
  a,b=map(int,input().split)
  col_list[a-1][b-1]+=1

for i in range(n):
  for j in range(n):
    if col_list[i][j]>=1 and h_list[i]<=h_list[j]:
      count+=1
      break
print(n-count)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
s=0
b=[]
co=[]
for i in range(n):
  co.append([0*n])
for i in range(n):
  b.append([0,0])
for i in range(m):
p1,p2=map(int,input().split())
if co[p1-1][p2-1]==0:
    co[p1-1][p2-1]=1
    co[p2-1][p1-1]=1
    b[p1-1][0]+=1
    b[p2-1][0]+=1
    if a[p1-1]>a[p2-1]:
        b[p1-1][1]+=1
    else:
        b[p2-1][1]+=1

for i in b:
  if i[0]==i[1]:
    s+=1
print(s)

Submission status: Runtime Error

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

d = {}

for i in range(N):
    d[i+1] = H[i]

for _ in range(M):
    A,B = map(int,input().split())

    if H[B-1] > H[A]:
        d[A] = 0

    elif H[B-1] < H[A]:
        d[B] = 0

    elif H[B-1] == H[A]:
        d[A] = 0
        d[B] = 0


print(N - list(d.values()).count(0))

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
good = [0]*N

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

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

Submission status: Runtime Error

Solution code:
k = list(map(int, input().split()))
h = list(map(int, input().split()))
m = [list(map(int, input().split())) for i in range(k[1])]

import networkx as nx

G = nx.Graph()
for i in range(len(k)):
  G.add_node(i +1)
for i in m:
  G.add_edge(i[0],i[1])

#print(k[0] - len(G.nodes()))
re = 0

for i in list(G.nodes):
  max_height = max([h[x - 1] for x in list(nx.all_neighbors(G, i))])
  if h[i-1] > max_height:
    re +=1
print(re + k[0] - len(G.nodes()))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
s=0
b=[]
co=[]
for i in range(n):
  co.append([0*n])
for i in range(n):
  b.append([0,0])
for i in range(m):
  p1,p2=map(int,input().split())
  if co[p1-1][p2-1]==0:

            co[p1-1][p2-1]=1
            co[p2-1][p1-1]=1
            b[p1-1][0]+=1
            b[p2-1][0]+=1
            if a[p1-1]>a[p2-1]:
                b[p1-1][1]+=1
            else:
                 b[p2-1][1]+=1

for i in b:
  if i[0]==i[1]:
    s+=1
print(s)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
road = [list(map(int,input().split())) for r in range(M)]
seen = []
for rr in road:
	for r in rr:
		if r not in seen:
			seen.append(r)
ans = []
for r in road:
	if H[r[0]-1] > H[r[1]-1]:
		ans.append(r[0])
	elif H[r[0]-1] < H[r[1]-1]:
		ans.append(r[1])
if len(seen) != N:
	ans  += (N-len(seen))
print(len(set(ans)))

Submission status: Runtime Error

Solution code:

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

AB = [list(map(int, input().split())) for _ in range(M)]

check = [True] * N

for ab in AB:
    # 左みる
    print(ab, "left: ", H[ab[0]-1], "right: ", H[ab[1]-1]) 
    if H[ab[0]-1] < H[ab[1] - 1]:
        check[ab[0]-1] = False
    elif H[ab[0]-1] > H[ab[1] - 1]:
        check[ab[1]-1] = False
    #else:
    #    check[ab[0]-1] = not check[ab[0]-1]
    print(check)
print(sum(check))

Submission status: Runtime Error

Solution code:
import numpy as np

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split()))).astype(np.int64)
ab = [list(map(int, input().split())) for _ in range(m)]

connect = np.zeros((n,n)).astype(np.int64)
for a, b in ab:
  connect[a-1, b-1] = connect[b-1, a-1] = 1
ans = 0
for i in range(n):
  if (connect[i] * hlist >= hlist[i]).sum() == 0:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
a=input().split()
N=int(a[0])
a=input().split()
N=int(a[0])
M=int(a[1])
H_list=input().split()
H_list=[int(i) for i in H_list]
path_list=[]
for i in range(M) :
  b=input().split()
  if [int(b[0]),int(b[1])] not in path_list :
    path_list.append([int(b[0]),int(b[1])])
count=0


for i in range(N) :
  flag=True

  for path in path_list :

    if not ((path[0]==i+1 and H_list[path[1]-1]<H_list[path[0]-1]) or (path[1]==i+1 and H_list[path[0]-1]<H_list[path[1]-1])) and  i+1 in path:
      flag=False
      break
  if flag :
    
    count+=1

print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
Hi = list(map(int,input().split(" ")))
path = [set() for _ in range(M+1)]

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a].add(b)
    path[b].add(a)
    
# print (path)

i = 0
goodT = 0

for p in path:
    good = 1
    if p == set():
        goodT += good
    else:
        for t in p:
            if Hi[i]<=Hi[t]:
                good =0
        goodT +=good
    i +=1
print (goodT)

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np
import collections

N, M = map(int(), stdin.readline().rstrip.split())
height = list(map(int(), stdin.readline().rstrip.split()))
good = np.zeros(M,dtype=bool)
for i in range(M):
    A, B = map(int(), stdin.readline().rstrip.split()) 
    if height[A] < height[B]:
        good[B] = True

print(np.count_nonzero(good == True))

Submission status: Runtime Error

Solution code:
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * m
    b = [0] * m
    s = [[0] for j in range(n)]
    ans=0
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    for i in range(m):
        s[a[i]-1].append(b[i])
        s[b[i]-1].append(a[i])
    for i in range(n):
        if len(s[i])!=1:
            for j in s[i]:
                if j!=0:
                    if h[i]<=h[j-1]:
                        y=0
            if not y:
               ans+=1
            y=1
    print(ans)
resolve()

Submission status: Runtime Error

Solution code:
import numpy as np

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split())))
ab = [list(map(int, input().split())) for _ in range(m)]

connect = np.zeros((n,n)).astype(np.int64)
for a, b in ab:
  connect[a-1, b-1] = connect[b-1, a-1] = 1
ans = 0
for i in range(n):
  if (connect[i] * hlist >= hlist[i]).sum() == 0:
    ans += 1
print(ans)

Submission status: Runtime Error

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

d = {}

for i in range(N):
    d[i+1] = H[i]

for _ in range(M):
    A,B = map(int,input().split())

    if H[B-1] > H[A]:
        d[A] = 0

    elif H[B-1] < H[A]:
        d[B] = 0


print(N - list(d.values()).count(0))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
s=0
b=[]
co=[]
for i in range(n):
  co.append([0*n])
for i in range(n):
  b.append([0,0])
for i in range(m):
  p1,p2=map(int,input().split())
  if c0[p1-1][p2-1]==0:
         co[p1-1][p2-1]=1
         cp[p2-1][p1-1]=1
 	 b[p1-1][0]+=1
 	 b[p2-1][0]+=1
	 if a[p1-1]>a[p2-1]:
             b[p1-1][1]+=1
         else:
             b[p2-1][1]+=1

for i in b:
  if i[0]==i[1]:
    s+=1
print(s)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
h = list(map(int, input().split()))
h_cond = [True]*n
count = 0

for i in range(m):
    tmp_a, tmp_b = map(int, input().split())
    if h[tmp_a-1] < h[tmp_b-1]:
        h_cond[tmp_a-1] = False
    elif h[tmp_a-1] > h[tmp_b-1]:
        h_cond[tmp_b-1] = False
    else:
        h_cond[tmp_a - 1] = False
        h_cond[tmp_b - 1] = False

# print(h_cond)
# print(route)
for idx, hi in enumerate(route):
    if h_cond[idx]:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    N, M = list(map(int, input().split()))
    H = list(map(int, input().split()))
    adj_mat = [[0 for i in range(N)] for i in range(N)]
    for i in range(M):
        a, b = list(map(int, input().split()))
        adj_mat[a-1][b-1] = 1
        adj_mat[b-1][a-1] = 1
    num = 0
    for i in range(N):
        h = H[i]
        for j in range(N):
            if adj_mat[i][j] == 1:
                flag = True
                if h < H[j]:
                    flag = False
                    break
        if flag:
            num += 1
    print(num)

Submission status: Runtime Error

Solution code:
import numpy as np
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    connect = np.ones((N, N), dtype=int)
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        connect[A, B] = H[A] - H[B]
        connect[B, A] = H[B] - H[A]
    num = 0
    for i in range(N):
        if len(np.where(connect[i, :] <= 0)[0])  == 0:
            num += 1
    print(num)
        
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy

inp=input().split(" ")
n=int(inp[0])
m=int(inp[1])
inh=input().split(" ")
for i in range(len(inh)):
  inh[i]=int(inh[i])
pairs=numpy.zeros(2*m,dtype=">i4").reshape(-1,2)
for i in range(m):
  a=input().split(" ")
  pairs[i][0]=int(a[0])
  pairs[i][1]=int(a[1])
lists=[[] for i in range(n)]
for i in range(len(pairs)):
  lists[pairs[i][0]-1].append(pairs[i][1])
  lists[pairs[i][1]-1].append(pairs[i][0])
for i in range(len(lists)):
  lists[i]=set(lists[i])
count=0
for i in range(len(lists)):
  if len(list[i])==0:
    count+=1
    continue
  for j in range(len(list[i])):
    if inh[i] <= inh[list[i][j]]:
      break
    if j == len(list[i])-1:
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
import collections
N, M = map(int, input().split())
H = list(map(int, input().split()))

root = dict()

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]:
        root[A-1] = H[A-1]
        if B-1 in root.keys():
            root.pop(root[B-1])
    else:
        root[B - 1] = H[B - 1]
        if A-1 in root.keys():
            root.pop(root[A-1])


print(len(root))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
a = [0]*k
has_k = [False]*n
count = 0

for i in range(k):
    tmp_d = int(input())
    tmp_a = list(map(int, input().split()))
    for ai in tmp_a:
        has_k[ai-1] = True

for ki in has_k:
    if ki == False:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
result = [0]*M
for i in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

for a, b in zip(A, B):
    if H[a-1] < H[b-1]:
        result[a-1] = 1

for a, b in zip(A, B):
    if H[a-1] > H[b-1]:
        result[b-1] = 1

C =A+B
D = N - len(set(C))
print(result.count(1)+D)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
s=0
b=[]
co=[]
for i in range(n):
  co.append([0*n])
for i in range(n):
  b.append([0,0])
for i in range(m):
  p1,p2=map(int,input().split())
  if c0[p1-1][p2-1]==0:
     co[p1-1][p2-1]=1
 	 b[p1-1][0]+=1
 	 b[p2-1][0]+=1
	 if a[p1-1]>a[p2-1]:
     b[p1-1][1]+=1
     else:
     b[p2-1][1]+=1

for i in b:
  if i[0]==i[1]:
    s+=1
print(s)

Submission status: Runtime Error

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

candidates = {}
for i in range(m):
    x, y = map(int, input().split(" "))

    if h[x - 1] <= h[y -1]:
        candidates[x] = False
    if h[x - 1] >= h[y -1]:
        candidates[y] = False
    print(x, y , candidates)

ans = 0
for i in range(1, n + 1):
    is_highest = candidates.get(i, True)
    if is_highest:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N, M = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
mat = np.zeros((N, N))
for j in range(M):
    a, b = [int(x) for x in input().split()]
    if mat[a - 1, b - 1] == 0:
        mat[a - 1, b - 1] = H[b - 1]
        mat[b - 1, a - 1] = H[a - 1]

count = 0
for i in range(N):
    h = H[i]
    max_h = np.max(mat[i,:])
    if h > max_h:
        count += 1
print(count)

Submission status: Runtime Error

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

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

ans = 0
idx = 0
while idx < N:
    i = 0
    cnt = 0
    while i < M:
        if A[i] == idx:
            if H[idx] <= H[B[i]]:
                cnt += 1
                break
        if B[i] == idx:
            if H[idx] <= H[A[i]]:
                cnt += 1
                break
        i += 1
    
    if i == M:
        ans += 1
    elif i == M and cnt == 0:
        ans += 1
    
    idx += 1

print(ans)

Submission status: Runtime Error

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

rlist = {n:[] for n in range(1,N+1)}
cnt = 0
for m in range(1.M+1):
  A,B = map(int,input().split())
  rlist[A].append(B)
  rlist[B].append(A)

for k,v in rlist.items():
  if len(v) == 0:
    cnt += 1
  else:
    for i in v:
      if H[k-1] <= H[i-1]:
        break
    else:
      cnt += 1
      
print(cnt)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
#h.sort()
l = [[] for _ in range(n)]

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

print(l)
  av
c = 0
for j in range(n):
  if len(l[j]) == 0:
    c += 1
  else:
    m = 0
    for k in l[j]:
      if h[j] <= h[k]:
        m = 1
        break
    if m == 0:

      c += 1
      
print(c)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[] for i in range(m+1)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
#print(edges)
check = [[0]*n for _ in range(n)]
count = 0
for i in range(n):
    for node in edges[i]:
        if h[i] > h[node]:
            continue
        else:
            break
    else:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
g = [[] for _ in range(n)]
t = [-1 for _ 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)

def dfs(i):
    if t[i] != -1:
        return
    else:
        t[i] = 1
    for j in g[i]:
        if h[i] <= h[j]:
            t[i] = 0
        dfs(j)

for i in range(n):
    dfs(i)
ans = n
for i in t:
    if i == 0:
        ans -= 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split())))
ab = [list(map(int, input().split())) for _ in range(m)]

connect = np.zeros((n,n)).astype(int)
for a, b in ab:
  connect[a-1, b-1] = connect[b-1, a-1] = 1
ans = 0
for i in range(n):
  if (connect[i] * hlist >= hlist[i]).sum() == 0:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
#h.sort()

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

print(l)
  
c = 0
for j in range(n):
  if len(l[j]) == 0:
    c += 1
  else:
    m = 0
    for k in l[j]:
      if h[j] <= h[k]:
        m = 1
        break
    if m == 0:

      c += 1
      
print(c)

Submission status: Runtime Error

Solution code:
import numpy as np

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

streetMatrix = np.array([np.zeros(N)]*N)

for m in range(M):
    A, B = map(int, input().split())
    
    streetMatrix[A-1][B-1] = 1
    streetMatrix[B-1][A-1] = 1

countGood = 0

for i in range(N):
    if max(streetMatrix[i]) == 0:
        countGood += 1
    elif H[i] > max(streetMatrix[i] * H):
        countGood += 1
print(countGood)

Submission status: Runtime Error

Solution code:
 import sys
input=sys.stdin.readline

N,M=(int(x) for x in input().rstrip('\n').split())
Hs = [int(x) for x in input().rstrip('\n').split()]
nums = [1 for x in Hs]
for i in range(M):
  roads = [int(x) for x in input().rstrip('\n').split()]
  if Hs[roads[0]-1] < Hs[roads[1]-1]:
    nums[roads[0]-1] = 0
  elif Hs[roads[0]-1] > Hs[roads[1]-1]:
    nums[roads[1]-1] = 0
  else:
    nums[roads[0]-1] = 0
    nums[roads[1]-1] = 0
print(sum(nums))

Submission status: Runtime Error

Solution code:
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,m =I2()
    h = Intl()
    l = [[] for i in range(n)]
    cnt = 0
    for i in range(m):
        a,b = I2()
        l[a-1].append(b)
        l[b-1].append(a)
    for i in range(n):
        if len(l[i]) == 0:cnt +=1
        for j in l[i]:
            if h[i] > h[j-1]:
                f = True
            else:
                f = False
                break
        if f:cnt += 1
    print(cnt)

Submission status: Runtime Error

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

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

root = [[] for i in range(n)]
for _ in range(n-1):
    a, b = (int(x) for x in input().split())
    root[b-1].append(a-1)
    root[a-1].append(b-1)

ans = 0

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

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split(' ')))
hn = list(map(int, input().split(' ')))
abm = [None] * m

d = defaultdict(list)
for i in range(m):
    v = list(map(int, input().split(' ')))
    d[v[0]].append(v[1])
    d[v[1]].append(v[0])
    

count = 0

for i in range(1, n + 1):
    cand = d.get(i)
    if cand is None:
        count += 1
        continue
    ok = True
    for c in cand:
        if hn[i - 1] <= hn[c - 1]:
            ok = False
            break
    if ok:
        count += 1
print(count)

Submission status: Runtime Error

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

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

cnt = 0
for i in l:
  if i == 1:
    cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
h = [int(i) for i in input().split()]
nn = [[-1]]*n

for i in range(m):
    a,b = map(int,input().split())
    nn[a-1].append(b-1)
    nn[b-1].append(a-1)
c=0
for i	in range(n):
    f=0
    for k in nn[i]:
	if k==-1:continue
        if h[i] < k:
            f=1
    if f==0:
	c+=1
print(c)

Submission status: Runtime Error

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, m = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    H = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    R = [list(map(int, input().split())) for i in range(m)]

    cnt = 0

    for i in (1, n+1):
        highst = True
        for r in R:
            if r[0] == i:
                if H[i-1] <= H[r[1]-1]:
                    highst = False
            if r[1] == i:
                if H[i-1] <= H[r[0]-1]:
                    highst = False

        if highst == True:
            cnt += 1:

    print(cnt)


resolve()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  long unsigned N, M;
  cin >> N >> M;
  vector<long long> takasa(N);
  for(long unsigned i = 0; i < N; i++){
    cin >> takasa[i];
  }
  vector<vector<long unsigned>> hashi(N);
  for(long unsigned i = 0; i < M; i++){
    long unsigned a, b;
    cin >> a >> b;
    a--; b--;
    hashi[a].push_back(b);
    hashi[b].push_back(a);
  }

  long unsigned count = 0;
  for(long unsigned i = 0; i < N; i++){
    for(long unsigned j = 0; j < hashi[i].size(); j++){
      if(takasa[hashi[i][j]] >= takasa[i]){
        break;
      }
      if(j == hashi[i].size()-1){
        count++;
      }
    }
    if(hashi[i].size() == 0){
      count++;
    }
  }
  cout << count <<endl;
}

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
ans = 0
arr = []
arr2 = []
cnt = 0
for i in range(M):
    a, b = list(map(int, input().split()))
    if a not in arr2:
        arr2.append(a)
    if b not in arr2:
        arr2.append(b)
    if H[a-1] < H[b-1]:
        if H[a] not in arr:
            arr.append(H[a])
            cnt += 1

not_found = len(H)-len(arr2)
print(N-cnt-not_found)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
d={}
for i, x in enumerate(h):
    if d.get(x):
        d[x].append(i+1)
    else:
        d[x] = [i+1]
m = max(d.keys())
num=0
for _ in range(m):
    x = list(map(int, input().split()))
    if x[0] in d[m] or x[1] in d[m]:
        num += 1
print(num+1)

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split()) 
H=list(map(int, input().split()))
xy = [map(int, input().split()) for _ in range(M)]
A,B= [list(i) for i in zip(*xy)]
S=0
for x in range(0,N):
	i=0
	for y in range(0,M):
		if A[y]==x and H[x+1]<=H[B[y]+1]:
			i=1
			break
		if B[y]==x and H[x+1]<=H[A[y]+1]:
			i=1
			break
	if i==0:
		S=S+1
print(S)

Submission status: Runtime Error

Solution code:
n, m = list(map(int,input().split()))
h = list(map(int,input().split()))
a = []
b = []
for i in range(m):
  a0, b0 = list(map(int,input().split()))
  a.append(a0)
  b.append(b0)
  
count = [0] * n

for i in range(m):
  if h[a[i] - 1] <= h[b[i] - 1]:
    count[a[i] - 1] = 1
  if h[a[i] - 1] >= h[b[i] - 1]:
	count[b[i] - 1] = 1
      
print(count.count(0))

Submission status: Runtime Error

Solution code:
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,m =I2()
    h = Intl()
    l = [[] for i in range(n)]
    cnt = 0
    for i in range(m):
        a,b = I2()
        l[a-1].append(b)
        l[b-1].append(a)
    for i in range(n):
        if len(l[i]) == 0:cnt +=1
        for j in l[i]:
            if h[i] > h[j-1]:
                f = True
            else:
                f = False
        if f:cnt += 1
    print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
nm = list(input().split())
n = nm[0]
m = nm[1]
h = list(input().split())
d = []
for i in range(m):
  d.append(list(input().split()))
for i in range(n):

Submission status: Runtime Error

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