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 = map(int,input().split())
h = list(map(int,input().split()))
r = []
cnt = 0

for i in range(m):
    i = list(map(int,input().split()))
    r.append(i)

r = [e for row in r for e in row]

for i in range(n):
    flag = 0
    for j in range(0,m,2):
        if h[i] == h[r[j]]:
            if h[i] < h[r[j+1]]:
                flag += 1
                break
        elif h[i] == h[r[j+1]]:
            if h[i] < h[r[j]]:
                flag += 1
                break
    if flag == 0:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
import copy
N,M = map(int,input().split(' '))
H = list(map(int,input().split(' ')))
H_pop = copy.copy(H)
count = 0
load_list = [list(map(int,input().split(' '))) for i in range(M)]
for i in load_list:
    A = H[int(i[0]-1)]
    B = H[int(i[1]-1)]
    try:
        if A < B:
            H_pop[int(i[0]-1)] = '_'
        else:
            H_pop[int(i[1]-1)] = '_'
    except ValueError:
        pass
[H_pop.remove('_') for i in H_pop]
print(len(H_pop))

Submission status: Runtime Error

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
H = list(map(int, input().split()))
IITODAI_FLAG = [0] * N
SYUTUGENTOUDAI =[]
 
for i in range(0, M+1):
  AB = input().split()
  A = int(AB[0])-1
  B = int(AB[1])-1
  SYUTUGENTOUDAI.append(A)
  SYUTUGENTOUDAI.append(B)
  if H[A]>H[B]:
    IITODAI_FLAG[A]=1
    IITODAI_FLAG[B]=0
  elif H[A]<H[B]:
    IITODAI_FLAG[A]=0
    IITODAI_FLAG[B]=1

NOT_SYUTUGENTOUDAI=N-len(list(set(SYUTUGENTOUDAI)))
IITODAI_FLAG_COUNT = IITODAI_FLAG.count(1)


print(NOT_SYUTUGENTOUDAI+IITODAI_FLAG_COUNT)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
n, m = map(int,input().split())
h = list(input().split())
tower = [] * n *m
## path
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] != "Bad":
        if h[a-1] <= h[b-1]:
            h[a-1] = "Bad"

count = 0
for i in range(m):
    if h[i] == "Bad":
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import numpy as np


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

H_mat = np.array(list(H_list))
path_mat = np.zeros((N, N), dtype=np.bool)

for _ in range(M):
  a1, a2 = map(int, input().split())
  path_mat[a1-1][a2-1] = True
  path_mat[a2-1][a1-1] = True

print("JIO")
count = 0
for i in range(N):
  height = H_mat[i]
  if not np.logical_and(path_mat[i], (H_mat > height)).any():
      print(i)
      count += 1

print(count)

Submission status: Runtime Error

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

ans = 0

for i in range(1, M+1):
    a, b = list(map(int, input().split()))
    A = int(a[i+1])
    B = int(b[i+1])
    
    if abs(int(h[A] - int(h[B]))) >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().strip().split()))
xy=[map(int, input().split()) for _ in range(M)]
x, y = [list(i) for i in zip(*xy)]

list=[0]*N
for i in range(M):
    if H[x[i]-1]<H[y[i]-1]:
        list[x[i]-1]+=1
    else:
        list[y[i]-1]+=1
count=0
for i in range(M+1):
    if list[i]==0:
        count+=1

print(count)

Submission status: Runtime Error

Solution code:
N,M = (int(x) for x in input().split())
list = [int(x) for x in input().split()]
tenbou = [input().split() for l in range(M)]
jj = [1] * N

#print(list)
#print(tenbou)

for i in range(N-1):
    x = int(tenbou[i][0]) - 1
    y = int(tenbou[i][1]) - 1
    if list[x] >= list[y]:
        jj[y] = 0
    elif list[y] > list[x]:
        jj[x] = 0


        
#print(jj)
print(jj.count(1))

Submission status: Runtime Error

Solution code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
H = list(map(int, input().split()))
IITODAI_FLAG = [0] * N
SYUTUGENTOUDAI =[]
 
for i in range(0, M):
  AB = input().split()
  A = int(AB[0])
  B = int(AB[1])
  SYUTUGENTOUDAI.append(A)
  SYUTUGENTOUDAI.append(B)
  if H[A]>H[B]:
    IITODAI_FLAG[A]=1
    IITODAI_FLAG[B]=0
  elif H[A]<H[B]:
    IITODAI_FLAG[A]=0
    IITODAI_FLAG[B]=1

NOT_SYUTUGENTOUDAI=N-len(list(set(SYUTUGENTOUDAI)))
IITODAI_FLAG_COUNT = IITODAI_FLAG.count(1)


print(NOT_SYUTUGENTOUDAI+IITODAI_FLAG_COUNT)

Submission status: Runtime Error

Solution code:
n ,m = map(int,input().split())
#hはi番目にi+1の展望台の高さがある
h = []
x = input().split()
for i in range(len(x)):
    h.append(int(x[i]))
#(a,b)の組みをtupleで入力
road = []
for i in range(m):
    a,b = map(int,input().split())
    road.append((a,b))

total = 0

for i in range(n):
    max_value = h[i]
    for j in range(m):
        if i+1 in road[j] :
            if max_value < max(h[road[j][0]-1],h[road[j][1]-1])
                max_value = -1
            elif h[road[j][0]-1] == h[road[j][1]-1]: 
                max_value = -1
        else:
            pass
    if max_value >0:
        total += 1

print(total)

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)

Submission status: Runtime Error

Solution code:
#c
import numpy as np
n, m = map(int, input().split())
hlist = list(map(int, input().split()))
mlist = []

for i in range(m):
    m = list(map(int, input().split()))
    mlist.append(m)    


test = np.array(np.zeros(n**2).reshape(n,n))
counter = 0

for mlist_x in mlist:
    test[[mlist_x[0]-1], [mlist_x[1]-1]] = hlist[mlist_x[1]-1]
    test[[mlist_x[1]-1], [mlist_x[0]-1]] = hlist[mlist_x[0]-1]

for i in range(n):
    test[[i],[i]] = hlist[i]

for i in range(n):
    if (max(test[i])==test[i][i]) and (len(np.where(test[i]==test[i].max())[0])==1):
        counter += 1
    else:
        pass

print(counter)

Submission status: Runtime Error

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N,M = MI()

H = FLI()

A = [0]*M
B = [0]*M

kanri = []

for i in range(N):
    k = [False]*N
    kanri.append(k)
for j in range(M):
    A[j], B[j] = MI()
    kanri[A[j]-1][B[j]-1] = True
    kanri[B[j]-1][A[j]-1] = True
cnt = 0
for k in range(N):
    ii = True
    fn = 0
    for v in range(N):
        michi = kanri[k][v]
        if kanri[k][v] == False:
            fn += 1
            continue
        if H[k] < H[v]:
            ii = False
    if ii == True and fn < len(kanri[k]):
        cnt += 1
        
print(cnt)

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] = 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=(int(x) for x in input().split())
h = [0]*n
ans = [0]*n
i = 0
y = input().split()
while(i < n):
  h[i] = int(y[i])
  ans[i] = i+1
  i +=1
j = 1
while(j <= m) or len(ans) >= 2:
  a,b=(int(x) for x in input().split())
  if (a in ans):
    if h[a-1] <= h[b-1]:
      ans.remove(a)
  if (b in ans):
    if h[a-1] >= h[b-1]:
      ans.remove(b)
  j += 1
print(len(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 m in range(M)]
AB = list(map(list, set(map(tuple, AB))))

i = []
for m in range(len(AB)):
    a = AB[m][0]
    b = AB[m][1]
    if H[a-1] >= H[b-1]:
        i.append(b-1)
    elif H[a-1] <= H[b-1]:
        i.append(a-1)

i = list(set(i))
for x in i:
    H[i] = 0

cnt = H.count(0)
print(len(H)-cnt)

Submission status: Runtime Error

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

for i in range(0, int(m)):
    a, b = map(int, input().split())
    a_int = int(h[int(a)-1])
    b_int = int(h[int(b)-1])

    if (a_int < b_int):
        l[b_int - 1] = 1
       
cnt = 0
for k in range(0, len(l)):
    if(l[k]==1):
        cnt+=1

print(cnt)

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):
        np_max = np.max(A[j])

        now = H[j]
        if (now > np_max or np_max == 0):
            ans += 1

    print(ans)


resolve()

Submission status: Runtime Error

Solution code:
x=int(input())
t=int(x**0.2)
for i in [t-1,t,t+1,t+2,t+3]:
  if  i**5+1==x:
    print(i,-1,sep=' ')
  elif i**5-1==x:
    print(i,1,sep=' ')

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,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]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))

Submission status: Runtime Error

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

ans = 0

for i in range(1, M+1):
    a, b = list(map(int, input().split()))
    A = int(a[i+1])
    B = int(b[i+1])
    
    while abs(int(h[A] - h[B])) >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
Hight = input().split()
Hight.insert(0,0)
count = 0
Direct = []
Direct2  = []
TempList2 = []
HighPlace = []
for i in range(1, N+1):
  HighPlace.append(i)
  
isHighest = True
for i in range(N+1):
  Direct.append([])
Bridge = []
for i in range(M):
  TempList = list(map(int,input().split()))
  TempList.sort()
  TempList2.append(TempList)
  Bridge.append(TempList)

for i in range (N):
  for j in range(M):
    if Bridge[j][0] == i:
      Direct[i].append(Bridge[j][1])

for i in range(1, N+1):
  for j in range(len(Direct[i])):
    if int(Hight[i]) < int(Hight[Direct[i][j]]):
      if i in HighPlace:
         HighPlace.remove(i)


          
          
for i in range(N+1):
  Direct2.append([])
Bridge = []
for i in range(M):
  TempList = TempList2[i].sort(reverse = True)
  Bridge.append(TempList)

for i in range (N):
  for j in range(M):
    if Bridge[j][0] == i:
      Direct2[i].append(Bridge[j][1])

for i in range(1, N+1):
  for j in range(len(Direct2[i])):
    if int(Hight[i]) < int(Hight[Direct2[i][j]]):
      if i in HighPlace:
         HighPlace.remove(i)
print(Hight)
print(Bridge)
print(Direct)
print(HighPlace)

Submission status: Runtime Error

Solution code:
import numpy as np

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

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

arr = get_unique_list(arr)
#print(arr)

#n = [i for i in range(1, n+1)]
# n_count = [0 for _ in range(n)]

count = 0
for i in range(len(arr)):
    tmp_1 = 1
    #tmp_2 = 1
    for j in arr:
        if i in j:
            #tmp_2 = 1
            height = [h[j[0]], j[1]]
            if not np.max(height) == h[i]:
                tmp_1 = 0
    if tmp_1 == 1: #and tmp_2 == 1:
        count += 1

print(count)

Submission status: Runtime Error

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

h = {}
for k, v in zip(range(1,n+1),[k for k in map(int, input().split())]):
    h[k] = v 

miti = []
for i in range(m):
    temp = [k for k in map(int, input().split())]
    miti.append(temp)

x = np.zeros(n)

for i in range(m):
    if h[miti[i][0]] < h[miti[i][1]]:
        x[miti[i][0]-1] =+1
    elif h[miti[i][0]] > h[miti[i][1]]:
        x[miti[i][1]-1] =+1
    elif h[miti[i][0]] == h[miti[i][1]]:
        x[miti[i][0]-1] =+1
        x[miti[i][1]-1] =+1

print(sum(x == 0))

Submission status: Runtime Error

Solution code:
# coding: utf-8
# author: Stephen Zhang  time: 2020/5/3

step,A,B,C=map(int,input().split())
executable = True

for i in range(0,step):
    usrInput = input()
    if usrInput == 'AB':
        if A > 0:
            A-=1
            B+=1
        elif B>0:
            A+=1
            B-=1
        else:
            executable = False
            break
    elif usrInput == 'AC':
        if A > 0:
            A-=1
            C+=1
        elif C>0:
            A+=1
            C-=1
        else:
            executable = False
            break
    else:
        if B > 0:
            B-=1
            C+=1
        elif C>0:
            B+=1
            C-=1
        else:
            executable = False
            break
            
if executable:
    print("Yes")
else:
    print("No")

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].add(b-1)
    st[b-1].add(a-1)
cnt = 0
for i, height in enumerate(h):
    line = []
    for huga in st[i]:
        line.append(h[huga])
    if height > max(line):
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np

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

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

buf = [list(map(int, input().split(" "))) for i in range(M)]

graph = np.zeros([N, N])


for b in buf:
    graph[b[0] - 1, b[1] - 1] = 1
    graph[b[1] - 1, b[0] - 1] = 1

counter = 0
for i in range(N):
    max_t = (graph[i] * H).max()
    if max_t == 0 or H[i] > max_t:
        counter += 1

print(counter)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import math
X = int(input())

a = X**(1/5)

a = math.floor(a)

  
b = (a**5 - X)**(1/5)
    
print(a,math.floor(abs(b)))

Submission status: Runtime Error

Solution code:
import numpy as np

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

matrix = np.zeros((N,N))
for i in range(N):
  matrix[i][i] = H[i]

for m in range(M):
  Am, Bm = AB[m]
  matrix[Am-1][Bm-1] = H[Bm-1]
  matrix[Bm-1][Am-1] = H[Am-1]

max_index_list = []
for i in range(N):
  max_index = np.argmax(matrix[i])
  max_index_list.append(max_index)

correct_index_list = list(range(N))
count = [max_index_list[i] == correct_index_list[i] for i in range(N)]

print(count.count(True))

Submission status: Runtime Error

Solution code:
def calc(num, lst, rs):
  arr = [[0]*num for i in range(num)]
  for route in rs:
    arr[route[0]-1][route[1]-1] = 1
    arr[route[1]-1][route[0]-1] = 1
  c = 0
  for i in range(num-1):
    ok_flag = 1
    for j in range(i+1, num):
      if arr[i][[j] == 1:
        if lst[i] <= lst[j]:
          ok_flag = 0
    if ok_flag == 1:
      c += 1
  return c

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

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

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

answer = calc(n, hs, routes)
print(answer)

Submission status: Runtime Error

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

ans = 0

for i in range(1, M+1):
    a, b = list(map(int, input().split()))
    A = int(a[i+1])
    B = int(b[i+1])
    
    if abs(h[A] - h[B]) >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

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

arr = get_unique_list(arr)
print(arr)

#n = [i for i in range(1, n+1)]
# n_count = [0 for _ in range(n)]

count = 0
for i in range(0, n):
    tmp_1 = 1
    #tmp_2 = 1
    for j in arr:
        if i in j:
            #tmp_2 = 1
            height = [h[j[0]], j[1]]
            if not np.max(height) == h[i]:
                tmp_1 = 0
    if tmp_1 == 1: #and tmp_2 == 1:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
## C
N, M = map( int, input().split() )
H = list(map(int, input().split()) )
AB = [list( map( int,input().split() ) ) for x in range(M)]
comp = [[0 for j in range(1)] for i in range(N)]
for i in range(M):
    comp[AB[i][0]-1].append(AB[i][1])
val = 0
for i in range(M):
    if len(set(comp[i])) > 1:
        val += 1
print(val + N - len(set(sum(AB, []) ) ) )

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import numpy as np


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

H_mat = np.array(list(H_list))
path_mat = np.zeros((N, N), dtype=np.bool)

for _ in range(M):
  a1, a2 = map(int, input().split())
  path_mat[a1-1][a2-1] = True
  path_mat[a2-1][a1-1] = True

count = 0
for i in range(N):
  height = H_mat[i]
  if (np.logical_and(path_mat[i], (H_mat > height)).any()
    or (not path_mat[i].any())):
    count += 1

print(count)

Submission status: Runtime Error

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

ans = 0

for i in range(1, M+1):
    a, b = map(int, input().split())
    A = int(a[i+1])
    B = int(b[i+1])
    
    if abs(h[A] - h[B]) >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
H=list(map(int,input().split()))
ans=[i  for i in range(1,n+1)]
low=[]
load=[map(int,input().split()) for j in range(m)]
for i in range(m):
    if H[load[i][0]-1]==H[load[i][1]-1]:
        low.append(load[i][0])
        low.append(load[i][1])
    elif  H[load[i][0]-1]>H[load[i][1]-1]:
        low.append(load[i][1])
    else:
        low.append(load[i][0])
low=list(set(low))
for k in low:
    ans.remove(k)
print(len(ans))

Submission status: Runtime Error

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

ans = 0

for i in range(1, M+1):
    a, b = map(int, input().split())
    A = int(a[i+1])
    B = int(b[i+1])
    
    if abs(h[A] - h[B]) >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
HH=np.zeros((N,N))
for i in range(M):
  A,B=list(map(int,input().split()))
  HH[A-1][B-1]=1
HH=HH+HH.T
count=0
for i in range(N):
  for j in range(N):
    if(HH[i][j]>0 and H[i]<=H[j]):
      count+=1
      break
print(N-count)

Submission status: Runtime Error

Solution code:
# C
import numpy as np

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])

inps = input().split(' ')
H = np.array([int(inps[i]) for i in range(len(inps))])
AB = []
for i in range(M):
    inps = input().split(' ')
    AB.append([int(inps[0]), int(inps[1])])
    
import pandas as pd

df_1, df_2 = pd.DataFrame(), pd.DataFrame()
tmp = np.array(AB).T
df_1['1'] = tmp[0]
df_1['2'] = tmp[1]
df_2['1'] = tmp[1]
df_2['2'] = tmp[0]
print(sum([sum(df['2'].apply(lambda t: H[t-1]) <= H[g-1]) - len(df) == 0 for g, df in pd.concat([df_1, df_2]).groupby('1')]))

Submission status: Runtime Error

Solution code:
import numpy as np

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

mat=np.zeros((n,n),np.uint8)
for i in range(m):
    x,y= map(int,input().split())
    mat[x-1,y-1]+=1
    mat[y-1,x-1]+=1

count=0
for i in range(n):
    for j in range(n):
        if mat[i,j]!=0 and h[i]<=h[j] and i!=j:
            break
        elif j==n-1:
            count+=1

print(count)

Submission status: Runtime Error

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

ans = [1] * N
load = [1] * N

for i in range(M):
    in1, in2 = input().split()
    in1 = int(in1)-1
    in2 = int(in2)-1
    load[in1] = 0
    load[in2] = 0
    if H[in1] < H[in2]:
        ans[in1] = 0
    elif H[in1] > H[in2]:
        ans[in2] = 0

index = 1
for i in load:
    if i == 1:
        ans[index] = 0
    index += 1
print(sum(ans))

Submission status: Runtime Error

Solution code:
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))

NM = inpl()
H = inpl()
table = []
AB = []
cnt = 0
x = []
flag = 0

for i in range(0, NM[0]):
        table.append([0]*10)

for i in range(0, NM[1]):
    AB = inpl()
    table[AB[0]-1][AB[1]-1] = 1
    table[AB[1]-1][AB[0]-1] = 1

for i in range(0, NM[0]):
    flag = 0
    for j in range(0 ,NM[0]):
        if table[i][j] == 1:
            if H[i] <= H[j]:
                flag = 1
    if flag == 0:
        cnt += 1

print(cnt)

Submission status: Runtime Error

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

ans = 0

for i in range(M):
    a, b = map(int, input().split())
    A = a[i+1]
    B = b[i+1]
    
    if abs(h[A] - h[B]) >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
good = 0
for i in range(m):
    a = list(map(int, input().split()))
    l.extend(a)

for i in range(1, n+1):
    a = [j for j, x in enumerate(l) if x == i]
    for j in a:
        if j%2==0:
            if (h[l[j+1]-1]<h[l[j]-1]):
                g = 1
            else:
                g = 0
        else:
            if (h[l[j-1]-1]<h[l[j]-1]):
                g = 1
            else:
                g = 0
    if g==1:
        good += 1

print(good)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = list(map(int, input().split()))
bad = set([])
num_good = n
for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    if (b in bad):
      pass
    else:
      bad.add(b)
      num_good -= 1
      print(bad)
  elif h[a-1]< h[b-1]:
    if (a in bad):
      pass
    else:
      bad.add(a)
      num_good -= 1
  else:
    if (a in bad):
      if (b in bad):
        pass
      else:
        bad.add(b)
        num_good -= 1
    elif (b in bad):
      bad.add(a)
      num_good -= 1
    else:
      bad.add(a)
      bad.add(b)
      num_good -= 2
print(num_good)

Submission status: Runtime Error

Solution code:
a = 0
x = int(input())
for a in range(x):
    b = (x - a**5)**.2
    if type(b) in (int,float) and float.is_integer(float(b)):
        print(a, -int(b))
        exit()

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
HH=np.zeros((N,N))
for i in range(M):
  A,B=list(map(int,input().split()))
  HH[A-1][B-1]=1
HH=HH+HH.T
count=0
#print(HH)
for i in range(N):
  for j in range(N):
    if(HH[i][j]>0):
      if(H[i]<=H[j]):
        count+=1
        break
print(N-count)

Submission status: Runtime Error

Solution code:
import sys
a ,b= map(int,input().split())
aaa = [list(map(int,input().split())) for i in range(b*2)]
 
s = {i for i in range(1,a+1)}

if a == 0:
    print(0)
    sys.exit

if b == 0:
    print(len(aaa))
    sys.exit
    

for i in range(1,a+1,2):
    for k in aaa[i]:
        s.discard(k)
 
print(len(s))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a ,b= map(int,input().split())
aaa = [list(map(int,input().split())) for i in range(b*2)]
 
s = {i for i in range(1,a+1)}

if a == 0:
    print(0)
    exit

if b == 0:
    print(len(aaa))
    exit
    

for i in range(1,a+1,2):
    for k in aaa[i]:
        s.discard(k)
 
print(len(s))

Submission status: Runtime Error

Solution code:
import numpy as np

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

#n = [i for i in range(1, n+1)]
# n_count = [0 for _ in range(n)]

count = 0
for i in range(0, n):
    tmp_1 = 1
    #tmp_2 = 1
    for j in arr:
        if i in j:
            #tmp_2 = 1
            height = [h[j[0]], j[1]]
            if not np.max(height) == h[i]:
                tmp_1 = 0
    if tmp_1 == 1: #and tmp_2 == 1:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))

NM = inpl()
H = inpl()
table = []
AB = []
cnt = 0
x = []
flag = 0

for i in range(0, NM[0]):
        table.append([0]*10)

for i in range(0, NM[1]):
    AB = inpl()
    table[AB[0]-1][AB[1]-1] = 1
    table[AB[1] - 1][AB[0] - 1] = 1

for i in range(0, NM[0]):
    flag = 0
    for j in range(0 ,NM[0]):
        if table[i][j] == 1:
            if H[i] <= H[j]:
                flag = 1
    if flag == 0:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
#c
import numpy as np

n, m = map(int, input().split())
hlist = list(map(int, input().split()))
mlist = []

for i in range(m):
    m = list(map(int, input().split()))
    mlist.append(m)    

# n=6
# m=5
# hlist=[8, 6, 9, 1, 2, 1]
# m1=[1, 3]
# m2=[4,2]
# m3=[4,3]
# m4=[4,6]
# m5=[4,6]

# mlist = [m1,m2,m3,m4,m5]
# print(mlist)

test = np.array(np.zeros(n**2).reshape(n,n))
counter = 0

for mlist_x in mlist:
    test[[mlist_x[0]-1], [mlist_x[1]-1]] = hlist[mlist_x[1]-1]
    test[[mlist_x[1]-1], [mlist_x[0]-1]] = hlist[mlist_x[0]-1]

for i in range(n):
    test[[i],[i]] = hlist[i]

for i in range(n):
    if (max(test[i])==test[i][i]) and (len(np.where(test[i]==test[i].max())[0])==1):
        counter += 1
    else:
        pass

print(counter)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
h = [int(i) for i in input().split()]
count = 0
vcount = [0]*n
arr = []
d = {}
for i in range(m):
    a,b = map(int,input().split())
    jk = [a,b]
    jk.sort()
    vcount[a-1] = 1
    vcount[b-1] = 1
    # arr.append([a,b])
    flag = 0
    for j in range(i):
        if(arr[j]==jk):
            flag = 1
            break
    if(flag==0):
        k1 = jk[0]
        k2 = jk[1]
        d.setdefault(k1, [])
        d.setdefault(k2, [])
        d[k1].append(k2)
        d[k2].append(k1)
        arr.append(jk)
    else:
        arr.remove(jk)
        d[jk[0]].remove(jk[1])
        d[jk[1]].remove(jk[0])
         
#print(d)
for key in d:
    flag = 0
    gg = d.get(key)
    if(len(list(gg))!=0):
        for i in gg:
            if(h[key-1]<=h[i-1]):
                flag = 1
                break
        if(flag==0):
            #print(key)
            count+=1
#print(count,sum(vcount))
print(count+n-sum(vcount))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
h = set(map(int, input().split()))
bad = []
num_good = n
for i in range(m):
  a, b = map(int, input().split())
  if h[a-1] > h[b-1]:
    if (b in bad):
      pass
    else:
      bad.append(b)
      num_good -= 1
      print(bad)
  elif h[a-1]< h[b-1]:
    if (a in bad):
      pass
    else:
      bad.append(a)
      num_good -= 1
  else:
    if (a in bad):
      if (b in bad):
        pass
      else:
        bad.append(b)
        num_good -= 1
    elif (b in bad):
      bad.append(a)
      num_good -= 1
    else:
      bad.append(a)
      bad.append(b)
      num_good -= 2
print(num_good)

Submission status: Runtime Error

Solution code:
import numpy as np
n, m = map(int, input().split())
heights = list(map(int, input().split()))
good = list(np.zeros(n))
a = np.zeros(m)
b = np.zeros(m)
roots = np.zeros((n, n))
for i in range(m):
    a[i], b[i] = map(int, input().split())
for i in range(m):
    roots[int(a[i])-1, int(b[i])-1] = 1
    roots[int(b[i])-1, int(a[i])-1] = 1
for i in range(n):
    if list(roots[i]).count(1) == 0:
        good[i] = 1
    for j in range(n):
        if roots[i, j] == 1 and heights[i] > heights[j]:
            good[i] = 1
print(good.count(1))

Submission status: Runtime Error

Solution code:
import numpy as np

inputs = []
while True:
  try:
    inputs.append(input())
  except EOFError:
    break

obsv = eval(inputs[0].split(" ")[0])
pathway = eval(inputs[0].split(" ")[1])
heights = [eval(a) for a in inputs[1].split(" ")]
ways = sorted(set([[eval(b) for b in a.split(" ")] for a in inputs[2:]]))
no_conn = obsv - len(sorted(set(sum(ways, []))))

# print(no_conn)

ways_inv = [[j,i] for [i,j] in ways]
ways.extend(ways_inv)
ways = sorted(ways)

# print(ways)

count = no_conn
start = 1
is_good = []
for w in ways:
  is_good.append(heights[start-1] > heights[w[1]-1])
  if start != w[0]:
    if np.all(is_good):
        count += 1
    start = w[0]
    is_good = []
if np.all(is_good):
  count += 1
  
print(count)

Submission status: Runtime Error

Solution code:
import math
import collections
import itertools
a=[]
b=[]
S =  list(map(int,input().split()))
N = S[0]
M = S[1]
H = list(map(int,input().split()))
for i in range(1,M+1):
    W = list(map(int,input().split()))
    b.append(W)
    if H[W[0]-1] > H[W[1]-1]:
        a.append(W[0])
        if W[1] in a:
            a.pop(W[1])
    elif H[W[0]-1] < H[W[1]-1]:
        a.append(W[1])
        if W[0] in a:
            a.pop(W[0])
c = collections.Counter(a)
aa=list(itertools.chain.from_iterable(b))
d = collections.Counter(aa)
e=N-len(d)
print(e+len(c))