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:
n, m = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
hs = [[] for i in range(n)]
for i in range(m):
  a, b = [int(i) for i in input().split()]
  hs[a-1].append(h[b-1])
  hs[b-1].appned(h[a-1])
c = 0
for i in range(n):
  if len(hs[i]) == 0:
    c += 1
  elif h[i] > max(hs[i]):
    c += 1
print(c)

Submission status: Runtime Error

Solution code:
import numpy as np


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

    A = np.zeros((N, N), dtype=int)
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp][ss] = H[ss]
        A[ss][pp] = H[pp]

    ans = 0
    for j in range(N):
        if (A[j].max() == 0 or H[j] > A[j].max()):
            ans += 1

    print(A)


resolve()

Submission status: Runtime Error

Solution code:
import numpy as np


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

    A = np.zeros((N, N), int)
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp][ss] = H[ss]
        A[ss][pp] = H[pp]

    ans = 0
    for j in range(N):
        if (A[j].max() == 0 or H[j] > A[j].max()):
            ans += 1

    print(ans)


resolve()

Submission status: Runtime Error

Solution code:
import numpy as np


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

    A = np.zeros((N, N))
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp][ss] = H[ss]
        A[ss][pp] = H[pp]

    ans = 0


resolve()

Submission status: Runtime Error

Solution code:
import numpy as np


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

    A = np.zeros((N, N))
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp][ss] = H[ss]
        A[ss][pp] = H[pp]

    ans = 0
    for j in range(N):
        if (A[j].max() == 0 or H[j] > A[j].max()):
            ans += 1

    print(ans)


resolve()

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
hs = list(map(int, input().split()))
d = [1]*n

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = [int(s)-1 for s in input.split()]
  if heights[A] >= heights[B]:
    good[B] = False
  elif heights[A] <= heights[B]:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = map(int, input().split())
  if heights[A - 1] > heights[B - 1]:
    good[B] = False
  elif heights[A - 1] < heights[B - 1]:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = map(int, input().split())
  if heights[A] > heights[B]:
    good[B] = False
  elif heights[A] < heights[B]:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

Submission status: Runtime Error

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

good = [True] * N
for m in range(0, M):
  A, B = map(int, input.split())
  if A > B:
    good[B] = False
  elif A < B:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count++
    
print(count)

Submission status: Runtime Error

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

def main():
    N, M = map(int, input().split())
    V = [True] * N
    H = [int(v) for v in input().split()]
    AB = [[map(int, input().split())] for _ in range(M)]
    for ab in AB:
        a, b = ab
        a-=1
        b-=1
        # if V[a] or V[b]:
        if H[a] < H[b]:
            V[a] = False
        else:
            V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

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)]
list=[0]*n
for a,b in ab:
  list[a-1]+=max(list[a-1],h[b-1])
  list[b-1]+=max(list[b-1],h[a-1])
ans=0
for i in range(n):
  if list[i]<h[i]:
    count+=1
print(count)

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    hRelations = np.zeros((n, n))
    '''
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1, a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1, b-1] = 1
    total = 0
    print(total)
    for hRelation in hRelations:
        if hRelation.sum() == 0:
            total += 1
    print(total)
    '''


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    hRelations = np.zeros((n, n))
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1, a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1, b-1] = 1
    total = 0
    print(total)
    for hRelation in hRelations:
        if hRelation.sum() == 0:
            total += 1
    print(total)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    hRelations = np.zeros((n, n))
    print(1)
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1, a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1, b-1] = 1
    total = 0
    for hRelation in hRelations:
        if hRelation.sum() == 0:
            total += 1
    print(total)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    hRelations = np.zeros((n, n))
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1, a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1, b-1] = 1
    total = 0
    for hRelation in hRelations:
        if hRelation.sum() == 0:
            total += 1
    print(total)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from collections import deque

def bfs(grafo,S):
    qtd_de_bons = 0
    q = deque()
    visitados[S] = 0
    q.insert(0,S)
    while len(q) != 0:
        adj = q.pop()
        contador = 0
        for i in grafo[adj]:
            if alturas[adj-1] > alturas[i-1]:
                contador += 1

            if visitados[i] == -1:
                visitados[i] = 0
                q.insert(0,i)
        if contador == len(grafo[adj]):
            qtd_de_bons += 1
    del grafo[0]
    for y in grafo:
        if len(y) == 0:
            qtd_de_bons += 1

    return qtd_de_bons

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

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

grafo = [[] for i in range(N+1)]

visitados = [-1] * (N+1)
ini = 0
for x in range(M):
    ini=a
    a,b = map(int,input().split())
    grafo[a].append(b)
    grafo[b].append(a)

resp = bfs(grafo,ini)

print(resp)

Submission status: Runtime Error

Solution code:
from collections import deque

def bfs(grafo,S):
    qtd_de_bons = 0
    q = deque()
    visitados[S] = 0
    q.insert(0,S)
    while len(q) != 0:
        adj = q.pop()
        contador = 0
        for i in grafo[adj]:
            if alturas[adj-1] > alturas[i-1]:
                contador += 1

            if visitados[i] == -1:
                visitados[i] = 0
                q.insert(0,i)
        if contador == len(grafo[adj]):
            qtd_de_bons += 1
    for i in range(1,len(grafo)):
        if len(grafo[y])==0:
            qtd_de_bons+=1

    return qtd_de_bons

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

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

grafo = [[] for i in range(N+1)]

visitados = [-1] * (N+1)

for x in range(M):
    a,b = map(int,input().split())
    grafo[a].append(b)
    grafo[b].append(a)

resp = bfs(grafo,1)

print(resp)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
# 高さ入力
h = list(int, input())
a = [0]*m
b = [0]*m
for i in range(m):
    a[i], b[i] = map(int, input().split())
list = []
for i in range(m):
    if h[a[i]-1] > h[b[i]-1]:
        list.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        list.append(a[i])
        list.append(b[i])
    else:
        list.append(b[i])
# 答えを記録する用配列
listans = [0]*n
for i in range(len(list)):
    listans[list[i] - 1] += 1
ans = 0
for i in range(n):
    if listans[i] == 0:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
(N,M) = input().split()
N = int(N)
M = int(M)
h = list(map(int,input().split()))
y = [0] * N
for i in range (M):
    A,B = map(int,input().split())
    if h[A -1] >= h[B -1]:
        y[B -1] += 1
    if h[B -1] >= h[a -1]:
        y[A -1] += 1
print(y.count(0))

Submission status: Runtime Error

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

tmp = [1] * n

ab = [map(int, input().split()) for _ in range(M)]
a, b = [list(i) for i in zip(*ab)]

for i in range(m):
    if h[a[i] - 1] > h[b[i] - 1]:
        tmp[b[i] - 1] = 0
    elif h[a[i] - 1] < h[b[i] - 1]:
        tmp[a[i] - 1] = 0
    else:
        tmp[a[i] - 1] = 0
        tmp[b[i] - 1] = 0

print(sum(tmp))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
h = [int(x) for x in input().split()]
a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
ind = []
for i in range(m):
    if h[a[i]-1] < h[b[i]-1]:
        ind.append(a[i])
    elif h[a[i]-1] == h[b[i]-1]:
        ind.append(a[i])
        ind.append(b[i])
    else:
        ind.append(b[i])
ind2 = [0] * n
for i in range(n):
    ind2[ind[i]-1] += 1
ans = 0
for i in range(n):
    if ind2[i] == 0:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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

A = np.zeros(M, dtype=int)
B = np.zeros(M, dtype=int)

for i in range(M):
    A[i], B[i] = map(int, input().split())
print(A, B)

ans = 0
for j in range(1, N+1):
    ind = np.concatenate([[0], A[B==j], B[A==j]])
#    print(j, ind)
    if H[j] > max(list(map(lambda x: H[x], ind))):
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
a = input().split()

n = int(a[0])
m = int(a[1])

h_ = input().split()

h = [int(i) for i in h_]

ab = [0]*m

for i in range(0,m):
  ab[i] = input().split()
  
c = 0
h_c = []

for i in range(0,n):
  temp = []
  for j in range(0,m):
    a = int(ab[j][0]) - 1
    b = int(ab[j][1]) - 1
    if(i == a):
      temp.append(b)
    elif(i == b):
      temp.append(a)
  h_c.append(temp)

for i in range(0,n):
  if(len(h_c[i]) == 0):
    c = c + 1
    continue
  else:
    l = h[i]
    x = sum(int(k)>l for k in h_c)
   
  if(x == 0):
    c = c + 1
print(c)

Submission status: Runtime Error

Solution code:
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

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

G = []
for i in range(n):
    if sum(M[i, :]==1)==0:
        G += [i]
    else:
        if (np.max(H[M[i,:]==1]) < H[i]):
            G+= [i]

print(len(G))

Submission status: Runtime Error

Solution code:
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

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

G = []
for i in range(n):
    # no path
    if sum(M[i,:])==0:
        G += [i]
    else:
        connected = np.where(M[i, :]==1)[0]
        if (np.max(H[connected]) < H[i]):
            G+= [i]

print(len(G))

Submission status: Runtime Error

Solution code:
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

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

G = []
for i in range(n):
    # no path
    if sum(M[i,:])==0:
        G += [i]
    else:
        connected = np.where(M[i, :]==1)[0]
        flag = 0
        for c in connected:
            if (H[c] >= H[i]):
                flag  = 1
                break
        if flag == 0:
            G+= [i]

print(len(G))

Submission status: Runtime Error

Solution code:
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

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

G = []
for i in range(n):
    # no path
    if sum(M[i,:])==0:
        G += [i]
    else:
        connected = np.where(M[i, :]==1)[0]
        flag = 0
        for c in connected:
            if (H[c] >= H[i]):
                flag  = 1
                break
        if flag == 0:
            G+= [i]

print(len(G))

Submission status: Runtime Error

Solution code:
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

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

G = []
for i in range(n):
    # no path
    if sum(M[i,:])==0:
        G += [i]
    else:
        connected = np.where(M[i, :]==1)[0]
        flag = 0
        for c in connected:
            if (H[c] >= H[i]):
                flag  = 1
                break
        if flag == 1:
            G+= [i]

print(len(G))

Submission status: Runtime Error

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

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

neighbor_max_heights = [0] * N

for i in range(M):
    a, b = AB[i]
    neighbor_max_heights[b-1] = max(neighbor_max_heights[b-1], H[a-1])
    neighbor_max_heights[a-1] = max(neighbor_max_heights[a-1], H[b-1])

ans = 0
for j in range(N):
    if H[j-1] > neighbor_max_heights[j-1]:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n,m=[int(_) for _ in input().split()]
H=[int(_) for _ in input().split()]
Hlist=[(set() for a in range(n))]
count=0
for a in range(m):
    a,b=[int(_) for _ in input().split()]
    Hlist[a-1].add(b-1)
    Hlist[b-1].add(a-1)
for i,j in enumerate(Hlist):
    flag=1
    for a in j:
        if H[a]>=H[i]:
            flag=0
    if flag==1:
        count+=1
    flag=1
print(count)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
li = []
h=list(map(int,input().split()))
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.zppend(b)
    else:
        li.append(b)
print(n-len(set(li)))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
a=[0]*N #H[i]と接する高さの最大値
for i in range(M):
  A,B=map(int,input().split())
  a[A-1]=max(a{A-1],H[B-1])
  a[B-1]=max(a[B-1],H[A-1])
s=0
for i in range(M):
  if H[i]>A[i]:
    s+=1
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(M):
    preH.append(list(map(int, input().split())))
ans = [True]*N

for i in range(M):
    A,B = preH[i] #一行ずつ処理

    if(H[A-1]>=H[B-1]):
        ans[A-1] = False
    if(H[B-1]>=H[A-1]):
        ans[B-1] = False

print(ans.count(True))

Submission status: Runtime Error

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

for i in range(M):
    preH.append(list(map(int, input().split())))
ans = [True]*n

for i in range(M):
    A,B = preH[i] #一行ずつ処理

    if(H[A-1]>=H[B-1]):
        ans[A-1] = False
    if(H[B-1]>=H[A-1]):
        ans[B-1] = False

print(ans.count(True))

Submission status: Runtime Error

Solution code:
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    LIST = [ 1 for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A-1] >= H[B-1]: LIST[B-1] = 0
        if H[A-1] <= H[B-1]: LIST[A-1] = 0
    print(sum(LIST))

Submission status: Runtime Error

Solution code:
N,M=map(int, input().split())
yoi = []
for i in range(N):
  yoi.append(True)
H=list(map(int, input().split()))
for i in ranage(M):
  A,B=map(int, input().split())
  if H[A-1]<=H[B-1]: yoi[A-1]=False
  if H[B-1]<=H[A-1]: yoi[B-1]=False 
print(len([1 for x in yoi if x==True]))

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    hRelations = np.zeros((n, n))
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1][a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1][b-1] = 1
    total = 0
    for hRelation in hRelations:
        if np.sum(hRelation) == 0:
            total += 1
    print(total)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,M= list(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())
    
ans = []*N
for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] < H[b]:
        ans[a]=1
    elif H[a] > H[b]:
        ans[b]=1
    else:
        ans[a]=0
        ans[b]=0
print(ans.count(1))

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
alist=list(map(int,input().split()))
a1=[]
a2=[]
for i,a in enumerate(alist):
  a2.append(i-a)
  a1.append(i+a)
aa=Counter(a2)
count=0
for k in a1:
  count+=aa.get(k,0)
print(count)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().rstrip().split())
h = map(int, input().rstrip().split())
l = []
high = [0] * n
count = 0

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

for i in l:
    if h[i[0]-1] < h[i[1]-1]:
        high[i[0]-1] += 1
    elif h[i[0]-1] == h[i[1]-1]:
        high[i[0]-1] += 1
        high[i[1]-1] += 1
    else:
        high[i[1]-1] += 1

for hi in high:
    if hi == 0:
        count += 1
print(count)

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 i in range(len(h)-1)]

ans = [0]*n

for a, b in ab:
    if h[a-1] > h[b-1]:
        ans[a-1] += 1
    else:
        ans[b-1] += 1

print(ans.count(0))

Submission status: Runtime Error

Solution code:
vn, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(0))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 13:26:56 2020

@author: r
"""

import sys

n = int(input())
t = [0]
x = [0]
y = [0]
b = 1

for i in range(n):
    a = list(map(int, input().split()))
    t += [a[0]]
    x += [a[1]]
    y += [a[2]]

for i in range(n):
    if (x[i]-x[i+1]+y[i]-y[i+1]-t[i]+t[i+1])%2 or (abs(x[i]-x[i+1])+abs(y[i]-y[i+1])-abs(t[i]-t[i+1])) > 0:
        b = 0
        break
        
    
if b == 0:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:

d = defaultdict(list)

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

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

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

ans = 0
for i in range(N):
    ng = 0

    if(i not in d):
        ans += 1
        continue

    for j in d[i]:
        if(H[i] <= H[j]): ng = 1
    if(ng != 1):
        ans += 1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
## C
N, M = map( int, input().split() )
H = [0] + list(map(int, input().split()) )
X = [[] for x in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    X[A].append(H[B])
    X[B].append(H[A])
rt = 0
for i in range(1, N+1):
    if H[i] > max(X[i]):
        rt += 1
print(rt)

Submission status: Runtime Error

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

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

h_max = [0 for _ in range(n)]
for a, b in ab:
    h_max[a-1] = max(h_max[a-1], h[b-1])
    h_max[b-1] = max(h_max[b-1], h[a-1])

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

Submission status: Runtime Error

Solution code:
(n,_),h,*t=[[*map(int,t.split())]for t in open(0)]
p=[1]*n
for a,b in t:p[-a]&=h[a]>h[b];p[-b]&=h[b]>h[a]
print(sum(p))

Submission status: Runtime Error

Solution code:
n,*t=map(int,open(0).read().split())
r=[0]+[1]*n
for a,b in zip(t[n::2],t[n+1::2]):r[a]&=t[a]>t[b];r[b]&=t[b]>t[a]
print(sum(r))

Submission status: Runtime Error

Solution code:
## import

## function definition 

## main process
if __name__ == '__main__':
    
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    
    ans = [1] * N
    for j in range(M):
        a, b = map(int,input().split())
        a -= 1
        b -= 1
        height_a = HEIGHT_LIST[a]
        height_b = HEIGHT_LIST[b]

        if height_a < height_b:
            ans[point_a] = 0
        elif height_a > height_b:
            ans[point_b] = 0
        else:
            ans[point_a] = 0
            ans[point_b] = 0

    print(sum(ans))

Submission status: Runtime Error

Solution code:
## import

## function definition 

## main process
if __name__ == '__main__':
    
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    
    ans = [1] * N
    for j in range(M):
        a, b = map(int,input().split())
        a -= 1
        b -= 1
        height_a = HEIGHT_LIST[a]
        height_b = HEIGHT_LIST[b]

        if height_a < height_b:
            ans[point_a] = 0
        elif height_a > height_b:
            ans[point_b] = 0
        else:
            ans[point_a] = 0
            ans[point_b] = 0
    print(sum(ans))

Submission status: Runtime Error

Solution code:
H=[int(x) for x in input().split()]
way=[]
for i in range(M):
    way.append([int(x) for x in input().split()])
 
dic={}
for i in range(N):
    dic[i]=set()
 
for h in way:
    dic[h[0]-1].add(h[1]-1)
    dic[h[1]-1].add(h[0]-1)
    
 
print(sum(all([H[i]>H[hs] for hs in dic[i]])for i in range(N)))

Submission status: Runtime Error

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X=I()
    for A in range(-10**5,10**5):
        B_=pow(A,5)-X
        if(B_==0):
            print(A,B_)
            return
        B = int(pow(abs(B_),-5))
        if(B_<0):
            B *= -1
        if(B**5==B_):
            print(A,B)
            return
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


hights = list(map(int, input().split()))
ans = [1]*N

for i in range(0,M):
  a,b = list(map(int, input().split()))
  if hights[a-1] > hights[b-1]:
    ans[table[1]] = 0
  elif hights[a-1] < hights[b-1]:
    ans[a-1] = 0
  else:
    ans[a-1] = 0
    ans[b-1] = 0

print(sum(ans))

Submission status: Runtime Error

Solution code:
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]

hights = list(map(int, input().split()))
ans = [1]*N

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

print(sum(ans))

Submission status: Runtime Error

Solution code:
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]

def lower(n,m):
  if n > m:
    return m
  else:
    return n


hights = list(map(int, input().split()))
ans = [1]*N

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

print(sum(ans))

Submission status: Runtime Error

Solution code:
l = list(map(int, input().split()))
li =  list(map(int, input().split()))

g = []
for i in range(l[1]):
    a, b = map(int, input().split())
    if li[a-1] == li[b-1]:
        g += [a, b]
    if li[a-1] >= li[b-1]:
        g += [b]
    else:
        g += [a]
    print(g)

g = set(g)
print(l[0] - len(g))