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:
    ## input
    N, M = map(int,input().split())
    HEIGHT_LIST = list(map(int,input().split())) 
    ROAD_LIST = []
    for j in range(M): 
        ROAD_LIST.append(
            set(map(int,input().split()))
        )
    
    ## business logic
    COUNT = 0
    
    for i in list(range(1, N+1)):
        unioned_i = set([])
        for k in ROAD_LIST:
            if i in k:
                unioned_i = unioned_i | k
        if len(unioned_i) == 0:
            COUNT = COUNT + 1
            continue
        HIGHT_i = HEIGHT_LIST[i-1]
        if HIGHT_i >= max(
            [ HEIGHT_LIST[l-1] for l in list(unioned_i) ]
        ):
            COUNT = COUNT + 1
    
    ## output
    print(COUNT)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
flg=[0]*N
T=[[] for _ in range(N)]

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

for n in range(N):
  if not T[n]:
    flg[n] =1
  else:
    MAX=max([H[t-1] for t in T[n]])
  if H[n]>MAX:
    flg[n]=1

print(sum(flg))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=input().split()
h_list = []
h_list = input().split(" ")
result =[True]*n
count = 0
for i in range(int(m)):
    temp1,temp2=input().split()
    if h_list[int(temp1)-1] < h_list[int(temp2)-1]:
        result[int(temp1)-1] = False
    elif h_list[int(temp1)-1] == h_list[int(temp2)-1]:
        result[int(temp1) - 1] = False
        result[int(temp2) - 1] = False
    else:
        result[int(temp2)-1] = False
for i in range(int(n)):
    if(result[i]==True):
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M =map(int,input().split())
h_lis=np.array(list(map(int,input().split())))
way_lis=[list(map(int,input().split())) for _ in range(M)]

tes=0
for i in range(N):
    nears=[]
    for way in way_lis:
        if i+1 in way:
            near.extend(way)
    for j,ne in enumerate(nears):
        if j==0:
            h=max(h_lis[ne[0]-1],h_lis[ne[1]-1])
            z=h
        else:
            k=z
            h=max(h_lis[ne[0]-1],h_lis[ne[1]-1])
            z=max(k,h)
    if z==h_lis[i]:
        tes+=1
print(tes)

Submission status: Runtime Error

Solution code:
a=input().split()
N=int(a[0])
M=int(a[1])
H=[int(x) for x in input().split()]
way=[]
for i in range(M):
    way.append([int(x) for x in input().split()])

ans=0
for i in range(N):
    con_i=[]
    for j in range(M):
        if way[j][0]==i+1:
            con_i.append(H[way[j][1]-1])
        if way[j][1]==i+1:
            con_i.append(H[way[j][0]-1])
    

    if max(con_i)<H[i]:
        ans+=1
    
print(ans)

Submission status: Runtime Error

Solution code:
def main():
  n,m = map(int,input().split())
  s = [int(n) for n in input().split()]
  cs = s
  for i in range(m):
    a,b = map(int,input().split())
    a-=1,b-=1
    if(s[a] < s[b]):
      cs[a]='1'
    else if(s[a] == s[b]):
      cs[a]='1'
      cs[b]='1'
    else:
      cs[b]='1'
  print(cs.count('1'))
      
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
def main():
  n,m = map(int,input().split())
  s = [int(n) for n in input().split()]
  cs = s
  for i in range(m):
    a,b = map(int,input().split())
    a-=1,b-=1
    if(s[a] < s[b]):
      cs[a]=-1
    else if(s[a] == s[b]):
      cs[a]=-1
      cs[b]=-1
    else:
      cs[b]=-1
  print(cs.count(-1))
      
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
N, M =map(int, input().split())
H_tree = [0] + [int(n) for n in input().split()]
GOOD_tree = [0] + [1 for n in range(N)]
 
for i in range(M):
  A, B = map(int, input().split())
  if H_tree[A]<=H_tree[B]:GOOD_Tree[A] = 0
  if H_tree[A]>=H_tree[B]:GOOD_Tree[B] = 0
print(sum(GOOD_tree))

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
H = list(map(int, input().split()))
s = [[0] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    s[a-1].append(H[b-1])
    s[b-1].append(H[a-1])
c = 0
for j in range(n):
    if H[j] > max(s[j]):
        c+= 1
 print(c)

Submission status: Runtime Error

Solution code:
N, M =map(int, input().split())
H_tree =[int(n) for n in input().split()]
GOOD_Tree = [1 for n in range(N)]
 
for i in range(M):
  A, B = map(int, input().split())
  if H_tree[A]<=H_tree[B]:GOOD_Tree[A] = 0
  if H_tree[A]>=H_tree[B]:GOOD_Tree[B] = 0
print(sum(GOOD_Tree))

Submission status: Runtime Error

Solution code:

def main():
    N, M = map(int, input().split())
    H_list = [int(_) for _ in input().split()]

    # iso_list = []
    index_list = []
    for m in range(M):
        A, B = map(int, input().split())
        if H_list[A-1] > H_list[B-1]:
            index_list.append(B-1)
        elif H_list[A-1] < H_list[B-1]:
            index_list.append(A-1)
        elif H_list[A-1] == H_list[B-1]:
            index_list.append(A-1)
            index_list.append(B-1)
        # iso_list.append(A)
        # iso_list.append(B)        

    index_list = list(set(index_list))
    for i in index_list:
        del H_list[i]        

    # iso_list = list(set(iso_list))
    # iso_list = len(H_list - iso_list)
    
    # out = iso_list + 
    out = len(H_list)
    print(out)
main()

Submission status: Runtime Error

Solution code:

def main():
    N, M = map(int, input().split())
    H_list = [int(_) for _ in input().split()]

    # iso_list = []
    index_list = []
    for m in range(M):
        A, B = map(int, input().split())
        if H_list[A-1] > H_list[B-1]:
            index_list.append(B-1)
        elif H_list[A-1] < H_list[B-1]:
            index_list.append(A-1)
        elif H_list[A-1] < H_list[B-1]:
            index_list.append(A-1)
            index_list.append(B-1)
        # iso_list.append(A)
        # iso_list.append(B)        

    index_list = list(set(index_list))
    for i in index_list:
        del H_list[i]        

    # iso_list = list(set(iso_list))
    # iso_list = len(H_list - iso_list)
    
    # out = iso_list + 
    out = len(H_list)
    print(out)
main()

Submission status: Runtime Error

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

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

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

count = 0

dic = {}

for i in range(1, N):
  dic[i] = set()

for hen in V:
  dic[hen[0]].add(hen[1])
  dic[hen[1]].add(hen[0])

print(sum(all([H[i] > hs for hs in dic[i]]) for i in range(N)))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H = list(map(int,input().split()))
H = [0] + H
Tree = [0] + [1]*N
for _ in range(M):
  A,B = map(int,input().split())
  if H[A] > H[B]:
    Tree[B] = 0
  elif H[A] = H[B]:
    Tree[A]=0
    Tree[B]=0
  else:
    Tree[A] = 0
print(sum(Tree))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
tunagari=[[] for i in range(N)]
TF=[True for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  if H[A-1]>H[B-1]:
    TF[B-1]=False
  elif H[A-1]<H[B-1]:
    TF[A-1]=False:
  else:
    TF[A-1]=False
    TF[B-1]=False
ans=0
for i in range(N):
  if TF[i]==True:
    ans+=1
print(ans)

Submission status: Runtime Error

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

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

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

count = 0

dic = {}

for i in range(1, N):
  dic[i] = set()

for hen in V:
  dic[hen[0]].add(hen[1])
  dic[hen[1]].add(hen[0])

print(sum(all([H[i] > hs for hs in dic[i]]) for i in N))

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
H = list(map(int, input().split()))
s = [[0]]*m
 
for _  in range(m):
    a, b = map(int, input().split())
    s[a-1].append(H[b-1])
    s[b-1].append(H[a-1])
 
c = 0
for j in range(n):
    if H[j] > max(s[j]):
        c+= 1
 
print(c)

Submission status: Runtime Error

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

H = [int(input()) for i in range(N)]

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

count = 0

dic = {}

for i in range(1, N):
  dic[i] = set()

for hen in V:
  dic[hen[0]].add(hen[1])
  dic[hen[1]].add(hen[0])

print(sum(all([H[i] > hs for hs in dic[i]]) for i in N))

Submission status: Runtime Error

Solution code:
def main():
  n,m = map(int,input().split())
  s = list(map(int,input.split()))
  cs = s
  for i in range(m):
    a,b = map(int,input().split())
    a-=1,b-=1
    if(s[a] < s[b]):
      cs[a]=-1
    else if(s[a] == s[b]):
      cs[a]=-1
      cs[b]=-1
    else:
      cs[b]=-1
  print(cs.count(-1))
      
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split(" "))
l=list(map(int,input().split(" ")))
d={}
for i in l:
    d[i]=[]
count=0
for i in range(k):
    a,b=map(int,input().split(" "))
    d[a].append(b)
    d[b].append(a)
#print(d)
for key,val in d.items():
    if len(val)==0:
        count+=1
    for i in val:
       if l[key] > l[i]:
           count+=1
    

   
print(count)

Submission status: Runtime Error

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

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

c = 0
for j in range(n):
    if H[j] > max(s[j]):
        c+= 1

print(c)

Submission status: Runtime Error

Solution code:
nobs, nroads = [int(x) for x in input().strip().split()]
rec = [False]*nobs
hs = [int(x) for x in input().strip().split()]
d = {}
while nroads > 0:
  src, dst = [int(x) for x in input().strip().split()]
  if src not in d:
    d[src] = [dst]
  else:
    d[src].append(dst)
  nroads -= 1
i = 0
total = 0
for i in range(nobs):
  if not rec[i]:
    q = [i]
    while len(q) > 0:
      src = q.pop(0)
      found = True
      for dst in d[src]:
        if hs[src] <= hs[dst]:
          found = False
          break
        q.append(dst)
      if found:
        total += 1
print(total)

Submission status: Runtime Error

Solution code:
import numpy as np
N, M = map(int, input().split())
AB = []
H = input().split()
Hall = [1] * N
 
# print(H)
for i in range(M):
    a, b = map(int, input().split())
    AB.append([a, b])
    AH = H[a - 1]
    BH = H[b - 1]
    if AH >= BH:
        Hall[b - 1] = 0
    if BH >= AH:
        Hall[a - 1] = 0
 
 
print(Hall.count(1))
import numpy as np
N, M = map(int, input().split())

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())  #数字
H = list(map(int, input().split()))#リスト
A = [list(map(int, input().split())) for i in range(M)]  #数字、複数行複数列

good = [True]*N
for i in range(M):
    left = H[A[i][0] - 1]
    right = H[A[i][1] - 1]
    if left < right:
        good[A[i][0]] = False
    if left > right:
        good[A[i][1]] = False
    if left == right:
        good[A[i][0]] = False
        good[A[i][1]] = False

print(good.count(True))

Submission status: Runtime Error

Solution code:
def main():
    N, M, *HAB = map(int, open(0).read().split())
    H = [0]*N
    for i in range(N):
        H[i] = HAB[i]
    A, B = [0]*M, [0]*M
    for i in range(M):
        A[i] = HAB[N + 2 * i + 0] - 1
        B[i] = HAB[N + 2 * i + 1] - 1
    # print(N, M, H, A, B)
    ans = set()
    for i in range(M):
        a = A[i]
        b = B[i]
        ha = H[a]
        hb = H[b]
        if ha < hb:
            ans.add(a)
        elif hb < ha
            ans.add(b)
    print(N - len(ans))

if __name__ == '__main__':
    main()

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

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

    print(ans)


resolve()

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(" ")]
mh = np.zeros([N])
for i in range(M):
    a,b = [int(i)-1 for i in input().split(" ")]
    mh[a] = max(mh[a],h[b])
    mh[b] = max(mh[b],h[a])

ans = 0
for i in range(N):
    if mh[i] < h[i]:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N, K    = map(int, input().split())
height  = list(map(int, input().split()))
road    = {}

#道がつながっている辞書を作成
for i in range(K):
    a, b = list(map(int, input().split()))
    try:
        road[a-1].append(b-1)
    except:
        road[a-1] = [b-1]
    try:
        road[b-1].append(a-1)
    except:
        road[b-1] = [a-1]

cnt = 0
for k, v in road.items():
  flag = True
  for i in set(v):
    if height[k] > height[i]:
      pass
    else:
      flag = False
  if flag is True:
    cnt += 1
print(cnt+(n-len(d.keys())))

Submission status: Runtime Error

Solution code:
X=int(input())

for i in range(0, 1000):
    for j in range(-1000,0):
        if X == (i**5-j**5):
            print(i, j)
            exit()

Submission status: Runtime Error

Solution code:
n,m=int(input())
l=list(map(int,input().split("")))
d={}
for i in l:
  d[i]=[]
print(d)

Submission status: Runtime Error

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

x = list(range(N+1))

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

x = set(x)
print(len(x)-1)

Submission status: Runtime Error

Solution code:
tenbodaiCount, hasiCount = map(int, input().split())
hyokoList = [int(s) for s in input().split()]

hasiList = []
for i in range(hasiCount):
    hasi = [int(s) for s in input().split()]
    hasiList.append(hasi)

goodHasiCount = 0
for i in range(tenbodaiCount):
    targetHasiList = []
    for j in range(len(hasiList)):
        hasi = hasiList[j] #該当する橋を取得する
        if len(list(filter(lambda x: x == i + 1, hasi))) > 0:
            targetHasiList.append(hasi)
    isGoodHasi = True
    targetHasiList = list(set(targetHasiList))
    for j in range(len(targetHasiList)):
        a = targetHasiList[j][0]
        b = targetHasiList[j][1]
        if a == i + 1:
            if hyokoList[a - 1] <= hyokoList[b - 1]:
                isGoodHasi = False
                break
        else:
            if hyokoList[b - 1] <= hyokoList[a - 1]:
                isGoodHasi = False
                break

    if isGoodHasi:
        goodHasiCount += 1

print(goodHasiCount)

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

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

    print(ans)


resolve()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B,C=MI()
    S=[]
    SS=A+B+C
    for i in range(N):
        s=input()
        S.append(s)
    
    S.append("AB")
    S.append("AB")#適当に入れとけ
    
    ans=[]
    flag=1
    if SS<1:
        flag=-1
    elif SS>=3 or SS==1:
        for i in range(N):
            s=S[i]
            if s=="AB":
                if A<B:
                    A+=1
                    B-=1
                    ans.append("A")
                elif B>A:
                    A-=1
                    B+=1
                    ans.append("B")
                else:#同数
                    s2=S[i+1]
                    if s2=="AC":
                        A+=1
                        B-=1
                        ans.append("A")
                    else:
                        A-=1
                        B+=1
                        ans.append("B")
                        
                    
            elif s=="AC":
                if A<C:
                    A+=1
                    C-=1
                    ans.append("A")
                elif A>C:
                    A-=1
                    C+=1
                    ans.append("C")
                else:#同数
                    s2=S[i+1]
                    if s2=="AB":
                        A+=1
                        C-=1
                        ans.append("A")
                    else:
                        A-=1
                        C+=1
                        ans.append("C")
                    
            else:#BC
                if C<B:
                    C+=1
                    B-=1
                    ans.append("C")
                elif C>B:
                    C-=1
                    B+=1
                    ans.append("B")
                else:#同数
                    s2=S[i+1]
                    if s2=="AC":
                        C+=1
                        B-=1
                        ans.append("C")
                    else:
                        C-=1
                        B+=1
                        ans.append("B")
                
   
        
                
            if A<0 or B<0 or C<0:
                flag=-1
                break
                
        
        
    if flag==-1:
        print("No")
    else:
        print("Yes")
        for i in range(N):
            print(ans[i])
            
            
        
    
    

main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
lis = []
for i in range(M):
    if H[A[i]] < H[B[i]]:
        min.append(A[i])
    if H[A[i]] == H[B[i]]:
        min.append(A[i])
        min.append(B[i])
    if H[A[i]] > H[B[i]]:
        min.append(B[i])
print(len(set(lis)))

Submission status: Runtime Error

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

A = []
B = []
cmb = {}
cnt = 0
flag = 1
ma = [0]*N

for i in range(M):
	a,b = map(int,input().split())

	cmb.setdefault(i, [])
	cmb.setdefault(a-1, []).append(b-1)
	cmb.setdefault(b-1, []).append(a-1)

	ma[a-1] = max(ma[a-1], H[b-1])
	ma[b-1] = max(ma[b-1], H[a-1])
# print(cmb)

for j in range(N):
	# print("展望台:", j)
	k = list(set(cmb[j]))
	# print(k)
	if len(cmb[j])==0:
		# print('正しく分岐')
		cnt+=1
	else:
		# print(H[j], '>', ma[j])

		if H[j] > ma[j]:
			# print('GOOD')
			cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
tenbodaiCount, hasiCount = map(int, input().split())
hyokoList = [int(s) for s in input().split()]

hasiList = []
for i in range(hasiCount):
    hasi = [int(s) for s in input().split()]
    hasiList.append(hasi)

goodHasiCount = 0
for i in range(tenbodaiCount):
    targetHasiList = []
    for j in range(len(hasiList)):
        hasi = hasiList[j] #該当する橋を取得する
        if len(list(filter(lambda x: x == i + 1, hasi))) > 0:
            targetHasiList.append(hasi)
    isGoodHasi = True
    for j in range(len(targetHasiList)):
        a = targetHasiList[j][0]
        b = targetHasiList[j][1]
        if a == i + 1:
            if hyokoList[b - 1] >= hyokoList[a - 1]:
                isGoodHasi = False
                break
        else:
            if hyokoList[a - 1] >= hyokoList[b - 1]:
                isGoodHasi = False
                break

    if isGoodHasi:
        goodHasiCount += 1
    else:

print(goodHasiCount)

Submission status: Runtime Error

Solution code:
N, M =map(int, input().split())
H_tree = map(int, input().split())
GOOD_Tree = [1 for n in range(len(H_tree))]

for n i in range(M):
  A, B =map(int, input().split())
  if H_tree[A-1]>=H_tree[B-1]:
    GOOD_tree[A-1] = 0
  else:
    GOOD_tree[B-1] = 0
print(GOOD_tree.count(1))

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):
    ml = list(map(int, input().split()))
    mlist.append(ml)    

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

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]

counter = 0
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:
import collections
num_list = [int(i) for i in input().split()]
height_list = [int(i) for i in input().split()]
way_list = list(list(map(int, input().split())) for i in range(num_list[1]))

tower_list = [i for i in range(1, num_list[0]+1)]
gd_dict = dict(zip(tower_list, ['good' for i in range(10**5)]))

def change_to_bad(target_list):
    if height_list[target_list[0]] > height_list[target_list[1]]:
        gd_dict[target_list[1]] = 'bad'
    elif height_list[target_list[0]] == height_list[target_list[1]]:
        gd_dict[target_list[0]] = 'bad'
        gd_dict[target_list[1]] = 'bad'
    else:
        gd_dict[target_list[0]] = 'bad'

for i in way_list:
    change_to_bad(i)

good_val = collections.Counter(gd_dict.values())['good']

good_val

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):
    ml = list(map(int, input().split()))
    mlist.append(m)    

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

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]

counter = 0
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:
#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))

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]

counter = 0
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 = input().split()
height = input().split()
able = []
for n in range(int(N)):
  able.append([])
for m in range(int(M)):
  con = input().split()
  con[0] = int(con[0]) - 1
  con[1] = int(con[1]) - 1
  able[con[0]].append(height(con[1]))
  able[con[1]].append(height(con[0]))
good = []
for n in range(int(N)):
  if len(able[n]) == 0:
    good.append(n)
  else:
    if int(height[n]) > max(able[n])
      good.append(n)
print(len(good))

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):
    ml = list(map(int, input().split()))
    mlist.append(ml)    
    
# 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(test)
print(counter)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
H=list(map(int,input().split()))
tunagari=[[] for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  tunagari[A-1]+=[B-1]
  tunagari[B-1]+=[A-1]

nums=[0 for i in range(N)]
t=0
for i in range(N):
  tmpl=tunagari[i]
  mini=min(tmpl)
  if mini<i:
    nums[i]=nums[mini]
    continue
  nums[i]=t
  t+=1
maxn=max(nums)
groups=[[] for i in range(maxn+1)]
print(maxn+1)
for i in range(N):
  groups[nums[i]]+=[i]
ans=0

for i in range(maxn):
  tmpl=groups[i]
  tmpl2=[]
  for i in tmpl:
    tmpl2+=[H[i]]
  n=len(tmpl)
  if n==1:
    ans+=1
  else:
    tmpl2.sort()
    if tmpl2[-1]!=tmpl2[-2]:
      ans+=1

Submission status: Runtime Error

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

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

print(tmp.count(0))

Submission status: Runtime Error

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

 # 要素n が全てTrueの配列
good = [True] * n
for im in range(m):
    a,b = list(map(int,input().split()))
    if h[a-1] > h[b-1]:
        good[b] = False
    elif h[b-1] > h[a-1]:
        good[a-1] = False
    else:
        good[a-1] = False
        good[b-1] = False

#count(x) リスト中のxの数を返す
print(good.count(True))

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):
    ml = list(map(int, input().split()))
    mlist.append(ml)    
    
# 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(test)
print(counter)

Submission status: Runtime Error

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

min = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a] < h[b]:
        min.append(a)
    if h[a] == h[b]:
        min.append(a)
        min.append(b)
    if h[a] > h[b]:
        min.append(b)

print(len(h)-len(set(min)))

Submission status: Runtime Error

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

aPrev=0
a,b=0,0
count=0

good = [True] * n # 要素n が全てTrueの配列
for im in range(m):
    a,b = list(map(int,input().split()))
    if h[a-1] > h[b-1]:
        good[b] = False
    elif h[b-1] > h[a-1]:
        good[a-1] = False
    else:
        good[a-1] = False
        good[b-1] = False

print(good.count(True)) #count(x) リスト中のxの数を返す

Submission status: Runtime Error

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

ans_list=[1]*N

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

Submission status: Runtime Error

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

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


tmp_h=0

check=[0]*N
for row in range(N):
    tmp_h=H[row]
    check[row]=1
    for col in range(M):
        if GRAPH[row][col]==1 :
            if(tmp_h<=H[col]):
                check[row]=0


            
cnt=0
for chk in check:
    if chk==1:
        cnt+=1

print(cnt)