Problem:


Score : 300 points

Problem Statement

There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.

Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.
Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.

How many good observatories are there?

Constraints

2 \leq N \leq 10^5

1 \leq M \leq 10^5

1 \leq H_i \leq 10^9

1 \leq A_i,B_i \leq N

A_i \neq B_i

Multiple roads may connect the same pair of observatories.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
H_1 H_2 ... H_N
A_1 B_1
A_2 B_2
:
A_M B_M

Output

Print the number of good observatories.

Sample Input 1

4 3
1 2 3 4
1 3
2 3
2 4

Sample Output 1

2

From Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.

From Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.

From Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.

From Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.

Thus, the good observatories are Obs. 3 and 4, so there are two good observatories.

Sample Input 2

6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6

Sample Output 2

3



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


Sample output:
2

Submission status: Runtime Error

Solution code:
import numpy as np


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

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

    print(ans)


resolve()

Submission status: Runtime Error

Solution code:

import numpy as np

N, M = map(int, input().split())
H = list(map(int, input().split()))
arr = np.zeros((N+1,N+1), dtype=np.int)

for i in range(M):
    x, y = map(int, input().split())
    arr[x][y] = 1
    arr[y][x] = 1

#print(arr)

count = 0
flag = False
#print("###########")

for i in range(1,N+1):
    for j in range(1,N+1):
        if arr[i][j] == 1:
            if H[i-1] < H[j-1]:
                Flag = False
                break
            else:
                #print(i,j)
                flag = True
    if flag:
        #print(i)
        count += 1
        flag = False

#print(arr)
print(count)

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
H = list(map(int, input().split()))
S = []
c = 0
b = []
 
for i in range(m):
    S.append(list(map(int, input().split())))
 
for j in range(n):
    for k in range(m):
        if j in S[k]:
            if S[k][0] == j:
                if S[k][0] < S[k][1]:
                    c += 1
            else:
                if S[k][0] > S[k][1]:
                    c + = 1
    if c ==0:
        b.append(j)
 
print(len(b))

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
H = list(map(int, input().split()))
S = []
c = 0
b = []

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

for j in range(n):
    for k in range(m):
        if j in S[k]:
            if S[k][0] == j:
                if S[k][0] < S[k][1]:
                    c += 1
            else:
                if S[k][0] > S[k][1]:
                    c + = 1
    if c ==0:
        b.append(j)

print(len(b))

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[1]-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 = np.full((N, N), False)
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:
N, M = map(int(input().split()))
h = list(map(int, input().split()))
ans = 0
a=[]
b=[]
for i in range(M):
    a,b = map(int, input().split())
    A.append(int(a[:i]))
    B.append(int(b[:i]))
    X = abs(h[A]-h[B])
    
    if X >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
c, d, e, f =map(int, input().split())
for i in range(b):
    e, f = map(int, input().split())
    for j in range(e,f):

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
h=list(map(int,input().split()))
lists=[list(map(int,input().split())) for _ in range(m)]
ans=[[]]*n
for list in lists:
  ans[list[0]-1].append(list[1])
  ans[list[1]-1].append(list[0])
new=[]
for x in range(n):
  new.append(list(set(ans[x])))
high=[[]]*n
for y in range(n):
  for z in range(len(new[y])):
    high[y].append(h[new[y][z]-1])
count=0
for x in range(n):
  if h[x]>max(high[x]):
    count+=1
print(count)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int,input().split()))
ans = 0
 
c = [[1 for i in range(N)] for j in range(N)]
 
for i in range(M):
    a, b = map(int, input().split())
    if a < b:
        As = a
        Bs = b
    else:
        As = b
        Bs = a
    Cs = As-1
    Ds = Bs-1
    c[Cs][i] = H[Ds]
    c[Ds][i] = H[Cs]

for i in range(N):
    list.sort(c[i])

    
for i in range(N):
    if H[i] > c[i][-1]:
        ans += 1
         


print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
H = list(map(int, input().split()))
OK = []
NG = []
def AddBoth(arr):
    NG.extend(arr)
def AddOK(x):
    OK.append(x)
def DelOK(x):
    if x in OK: OK.remove(x)
    NG.append(x)
def AddNG(x):
    NG.append(x)

def calc(a,b):
    if H[a-1] == H[b-1]:
        AddBoth([a,b])
    elif H[a-1] > H[b-1]:
        AddNG(b)
        if a not in NG: 
            AddOK(a)
        else:
            DelOK(a)
    else:
        AddNG(b)
        if b not in NG: 
            AddOK(b)
        else:
            DelOK(b)
for i in range(N-1):
    a,b = map(int, input().split())
    calc(a,b)

print(N - len(list(set(NG))))

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:

n, m = (int(x) for x in input().split())
h_list = list(map(int, input().split()))
root_list = []
for i in range(m):
    root_list.append(list(map(int,input().split())))

count = 1

# print(root_list)
# print(root_list[0][0])

good = True

# 展望台の数だけ繰り返す
for i in range(n):

    good = True

    # print('展望台番号')
    # print(i)    

    # 道の本数だけ繰り返す
    for j in range(0, len(h_list) - 1):

        # print(j)
        # print('番目の道について')    

        # print('root_list[j][0]')
        # print(root_list[j][0])

        # 展望台の路の起点に自身が含まれている
        if root_list[j][0] == j + 1 :
            # 相手の高さを見て自分より高ければ良い展望台ではない
            if h_list[root_list[j][1]] > h_list[i] :
                good = False

    if good == True :
        count = count + 1

print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=map(int, input().split())
H=list(map(int, input().split()))
H=np.array(H)
D=np.zeros((N,N))
for i in range(M):
    A,B=map(int, input().split())
    #print(H[A-1], H[B-1])
    D[B-1][A-1] = 0
    D[A-1][B-1] = 0
    if H[A-1] > H[B-1]:
        D[A-1][B-1] = 1
    else:
        D[B-1][A-1] = 1
#print(D)

ans0=sum(D.sum(axis=0) != 0)
ans1=sum(D.sum(axis=1) != 0)
ans3=sum((D.sum(axis=0) + D.sum(axis=1)) == 0)

ans = max(ans0, ans1) + ans3
print(ans)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

goodT = 0
T = range(M+1)

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

Submission status: Runtime Error

Solution code:
import itertools
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = 0
list1 = [] #あって    眺めがいい
list2 = [] #ない     道が通ってる
list3 = [x for x in range(1,n+1)]
list4 = []
for i in range(m):
    a,b = map(int,input().split())
    list2.append(a)
    list2.append(b)
    if h[a-1] > h[b-1]:
        list1.append(a)
    else:
        list1.append(b)
list1 = list(set(list1))
list2 = list(set(list2))
for i in range(n):
    if list2[i] not in list3:
        list4.append(list2[i])

print(len(list1)+len(list4))

Submission status: Runtime Error

Solution code:
n=int(inpN, M = map(int(input().split()))
h = list(map(int, input().split()))ut())
a=[]
b=[]
for i in range(M):
    a,b = input().split()
    A.append(int(a))
    B.append(int(b))
    X = abs(h[A]-h[B])
    
    if X >= 1:
        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=np.array(H)
D=np.zeros((N,N))
for i in range(M):
    A,B=map(int, input().split())
    #print(H[A-1], H[B-1])
    D[B-1][A-1] = 0
    D[A-1][B-1] = 0
    if H[A-1] > H[B-1]:
        D[A-1][B-1] = 1
    else:
        D[B-1][A-1] = 1
#print(D)

ans0=sum(D.sum(axis=0) != 0)
ans1=sum(D.sum(axis=1) != 0)
ans3=sum((D.sum(axis=0) + D.sum(axis=1)) == 0)

ans = min(ans0, ans1) + ans3
print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
H = []
ab = []
gl = []
for i in range(1,N+1):
    gl.append(i)
h = list(map(int, input().split()))
for n in h:
    H.append(n)
for i in range(1,M+1):
    a = list(map(int,input().split()))
    if ab.count(a) == 0:
        ab.append(a)
    else:
        pass

for n in range(0,M):
    s = ab[n]
    if gl.count(s[0]) >= 1:
        h_a = H[s[0]-1]
        h_b = H[s[1]-1]
        if h_a <= h_b:
            gl.remove(s[0])
    if gl.count(s[1]) >= 1:
        h_a = H[s[0] - 1]
        h_b = H[s[1] - 1]
        if h_b <= h_a:
            gl.remove(s[1])

print(len(gl))

Submission status: Runtime Error

Solution code:
X=int(input())

def ok(B):
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return i**5==B

def get(B):
    f = B/abs(B)
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return int(i*f)



A_cand=[]
i=0
while i**5<=10**10:
    A_cand.append(i)
    i+=1

#print(A_cand)
for a in range(300):
    B_5=a**5-X
    if ok(B_5):
        r=get(B_5)
        print(a,r)
        exit()
        break

Submission status: Runtime Error

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

l=[]
for i in range(m):
    l.append(max(a[i],b[i]))

li=[]
for i in l:
    if i in a and a[index(i)] > b[index(i)]:
        li.append(i)
    elif i in b and a[index(i)] < b[index(i)]:
        li.append(i)

for i in range(1,n+1):
    if i not in a and i not in b:
        li.append(i)
 print(lem(li))

Submission status: Runtime Error

Solution code:
import copy
n, m = map(int, input().split())
s = [int(x) for x in input().split()]
s2 = copy.deepcopy(s)
for _ in range(m):
    a, b = map(int, input().split())

    a1=s[a-1]
    b1=s[b-1]
    if a1<b1:
        p=(a1 in s2)
        if p == False:
            f=1
        else:
            s2.remove(a1)
    elif a1>b1:
        p=(a1 in s2)
        if p == False:
            f=1
        else:
            s2.remove(b1)
print(len(s2))

Submission status: Runtime Error

Solution code:
def has_duplicates(seq):
    return len(seq) == len(set(seq))

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

    # h[0].append(int(h[1][0]))
    for i in range(n):
        h[i].append(int(h[i][0]))

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

    cnt = 0

    for i in range(n):
        if max(h[i][1:]) == int(h[i][0]):
            if has_duplicates(h[i][1:]):
                cnt +=1
    print(cnt)
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

N, M = map(int, stdin.readline().rstrip().split())
heights = list(map(int, stdin.readline().rstrip().split()))
relations = np.zeros((N,N),dtype=bool)

for i in range(M):
    A, B = map(int, stdin.readline().rstrip().split())
    A, B = A - 1, B - 1
    relations[A][B] = True

count = int(0)
for i in range(M):
    index = i 
    height = heights[i]
    if np.count_nonzero(relations[i] == True) == 0:
        count += 1
        continue
    for j in range(M):
        if relations[i][j] == True:
            if height < heights[j]:
                index = j
                height = heights[j]
    if i == index:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
from sys import stdin

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

A = np.zeros((N, N))
for _ in range(M):
  a, b = map(int, input().split())
  A[a-1, b-1] += 1
  A[b-1, a-1] += 1

count = 0
for i in range(N):
  index = np.where(A[i]>=1)[0]
  if index.shape[0] == 0:
    count += 1
  else:
    B = H[index]
    if all([B[j]<H[i] for j in range(B.shape[0])])==True:
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
h = list(map(int,input().split()))
count = 0
a,b = map(int,input().split())
for i in range(len(h)):
  if h[a+1]<=h[b+1]:
    count = count + 1
  else:
    pass
print(count)

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    N, M = list(map(int, input().split()))
    H = list(map(int, input().split()))
    good_obs = [True for i in range(M)]
    for i in range(M):
        a, b = list(map(int, input().split()))
        if H[a-1] > H[b-1]:
            godd_obs[b-1] = False
        elif H[a-1] < H[b-1]:
            good_obs[a-1] = False
    print(sum(good_obs))

Submission status: Runtime Error

Solution code:
n = list(map(int,input().split()))
l = list(map(int,input().split()))
t=0
for i in range(n[1]):
  l1 = list(map(int,input().split()))
  if l[l1[0]-1]>l[l0[1]-1]:
    t+=1
  if l[l1[1]-1]<l[l0[0]-1]:
    t+=1
print(t)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
height = [int(i) for i in input().split()]
roads = [list(map(int, input().split())) for _ in range(N)]
alone=[]
ans={}
b_list=[]
for i in range(1, N+1):
  alone.append(i)
for road in roads:
  if max(road) not in b_list:
    ans[max(road)]='Yes'
    b_list.append(min(road))
  elif road[0] in alone:
    alone.remove(road[0])
  elif road[1] in alone:
    alone.remove(road[1])
print(len(ans)+len(alone))

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))
roots = np.zeros((n, n), dtype=int)
for i in range(m):
    a, b = map(int, input().split())
    roots[a-1, b-1] = 1
    roots[b-1, a-1] = 1
# 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
# print(roots)
for i in range(n):
    if list(roots[i]).count(1) == 0:
        good[i] = 1
    else:
        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:
#include <iostream>
#include <vector>
#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
 
int main() {
  int n,m;
  int cnt=0;
  cin >> n >> m;
  
  vector<int> v,x;
 
  int a,b;
  for(int i = 0; i < n; ++i) {
    cin >> a;
    v.push_back(a);
  }
  x = v;
  
  for(int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--;
    b--;
    if(v[a] < v[b]) {
      x[a] = -1;
    }
    else if(v[a] == v[b]) {
      x[a] = -1;
      x[b] = -1;
    }else if(x[b] < x[a]) {
      x[b] = -1;
    }
  }
 
  cout << v.size() - count(x.begin(), x.end(), -1) << "\n";
  return 0;
}

Submission status: Runtime Error

Solution code:
#C
# nは展望台の数，mは展望台同士を結ぶ道の数
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.add(tuple(sorted(a,b)))

    
total = 0

for i in range(n):
    max_value = h[i]
    for j in range(len(road)):
        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:
from sys import stdin
import numpy as np
import queue

N, M = map(int, stdin.readline().rstrip().split())
heights = list(map(int, stdin.readline().rstrip().split()))
relations = np.zeros((N,N),dtype=bool)

for i in range(M):
    A, B = map(int, stdin.readline().rstrip().split())
    A, B = A - 1, B - 1
    relations[A][B] = True

count = int(0)
for i in range(M):
    index = -1 
    height = heights[i]
    if np.count_nonzero(relations[i] == True) == 0:
        count += 1
        continue
    for j in range(M):
        if relations[i][j] == True:
            if height < heights[j]:
                index = j
                height = heights[j]
    if i == index:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
n = list(map(int,input().split()))
l = list(map(int,input().split()))
t=0
for i in range(n[1]):
  l1 = list(map(int,input().split()))
  if l[l1[0]-1]>l[l1[1]-1]:
    t+=1
  if l[l1[1]-1]>l[l1[0]-1]:
    t+=1
print(t)
   
n = list(map(int,input().split()))
l = list(map(int,input().split()))
t=0
for i in range(n[1]):
  l1 = list(map(int,input().split()))
  if l[l1[0]-1]>l[l0[1]-1]:
    t+=1

Submission status: Runtime Error

Solution code:
import collections
n,m=map(int,input().split())
H=list(map(int,input().split()))
blacklist=[]
Li=[]
for i in range(m):
    a,b=map(int,input().split())
    Li.append([a,b])
    if [a,b] not in Li:
        Ha,Hb=H[a-1],H[b-1]
    if Ha<Hb:
        blacklist.append(a)
    else:
        blacklist.append(b)
ans=0
cbl=collections.Counter(blacklist)
for j in range(1,n+1):
    if cbl[j]==0:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
h=[int(i)for i in input().split()]
j=[list(map(int,input().split())) for i in range(m)]
c=0
d=0
for z in range(n):
    d=0
    for s in range(m):
        if d==0:
            if h[z]in j[s]:
                d=1
                if min(j[s])!=h[z]:
                    c+=1
                    break
        elif h[z]in j[s] and min(j[s]!=h[z]):
            c+=1
            break
    if d==0:
        c+=1
print(c)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
 
int main() {
  int n,m;
  int cnt=0;
  cin >> n >> m;
  
  vector<int> v,x;

  int a,b;
  for(int i = 0; i < n; ++i) {
    cin >> a;
    v.push_back(a);
  }
  x = v;
  
  for(int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--;
    b--;
    if(v[a] < v[b]) x[a] = -1;
    else if(v[a] == v[b]) {
      x[a] = -1;
      x[b] = -1;
    }else x[b] = -1;
  }

  cout << v.size() - count(x.begin(), x.end(), -1) << "\n";
  return 0;
}

Submission status: Runtime Error

Solution code:
import numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
yoi = np.ones(M)
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        yoi[B-1] = 0
    elif H[B-1] > H[A-1]:
        yoi[A-1] = 0
    elif H[A-1]==H[B-1]:
        yoi[A-1] = 0
        yoi[B-1] = 0
print(int(np.sum(yoi)))

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=map(int, input().split())
H=list(map(int, input().split()))
H=np.array(H)
D=np.zeros((N,N))
for i in range(M):
    A,B=map(int, input().split())
    #print(H[A-1], H[B-1])
    D[B-1][A-1] = 0
    D[A-1][B-1] = 0
    if H[A-1] > H[B-1]:
        D[A-1][B-1] = 1
    else:
        D[B-1][A-1] = 1
ans0=sum(D.sum(axis=0) != 0)
ans1=sum(D.sum(axis=1) != 0)
ans = max(ans0, ans1)
print(ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split(' '))
H = list(map(int,input().split(' ')))
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[int(i[0]-1)] = '_'
        else:
            H[int(i[1]-1)] = '_'
    except:
        pass
[H.remove('_') for i in H]
print(len(H))

Submission status: Runtime Error

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

	ans = int(n)
	del_list = set()
	for i in range(m):
		print("i is {}".format(i), "and then del_list is {}".format(del_list))
		if h[l[i][0]-1] > h[l[i][1]-1] and l[i][1] not in del_list:
			ans -= 1
			del_list.add(l[i][1])
		elif h[l[i][0]-1] < h[l[i][1]-1] and l[i][0] not in del_list:
			ans -= 1
			del_list.add(l[i][0])
		elif h[l[i][0]-1] == h[l[i][1]-1]:
			if l[i][0] not in del_list and l[i][1] not in del_list:
				ans -= 2
				del_list.add(l[i][0])
				del_list.add(l[i][1])
			elif l[i][0] not in del_list:
				ans -= 1
				del_list.add(l[i][0])
			elif l[i][1] not in del_list:
				ans -= 1
				del_list.add(l[i][1])
			else:
				ans += 0
		else:
			ans += 0

	print(ans)





if __name__ == '__main__':
	main()

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])
    X = abs(int(h[A] - int(h[B])))
    
    if X >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:

import copy

#l2 = copy.copy(l1) 
n,m = map(int,input().split())
h = list(map(int,input().split()))
c = copy.copy(h)
for i in range(m):
    a,b = map(int,input().split())
    #print(a,b,h[a-1],h[b-1])
    if h[a-1] < h[b-1]:
        c[a-1] = c[b-1]
    elif h[a-1] == h[b-1]:
        print(h[a-1])
        c[a-1] = 0
        c[b-1] = 0
    elif h[a-1] > h[b-1]:
        c[b-1] = a[a-1]

#    elif abs(h[a-1]) == h[b-1]:
#        h[a-1] = -h[a-1]
#        h[b-1] = -h[b-1]
t = []
for i in range(n):
    if c[i] != 0:
        t.append(c[i])
#print(t)
s = set(t)
print(len(s))

Submission status: Runtime Error

Solution code:
# n,m = map(int,input().split())
h_list = list(map(int,input().split()))
roads = []
for i in range(m):
    a,b = map(int,input().split())
    roads.append([a,b])
#print(roads)
terrace = [1] * n
for road in roads:
    if h_list[road[0]-1] > h_list[road[1]-1]:
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] == h_list[road[1]-1]:
        terrace[road[0]-1] = 0
        terrace[road[1]-1] = 0
    elif h_list[road[0]-1] < h_list[road[1]-1]:
        terrace[road[0]-1] = 0
print(terrace.count(1))

Submission status: Runtime Error

Solution code:
n = list(map(int,input().split()))
l = list(map(int,input().split()))
t=0
for i in range(n[1]):
  l1 = list(map(int,input().split()))
  if l[l1[0]-1]>l[l0[1]-1]:
    t+=1
  if l[l1[1]-1]>l[l0[0]-1]:
    t+=1
print(t)

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.empty((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:
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])
    X = abs(int(h[A] - int(h[B])))
    
    if X >= 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
high=list(map(int,input().split()))
good_hill=list(range(N))
for i in range (0,M):
    a,b=map(int,input().split())
    a=a-1
    b=b-1
    if (a and b) in good_hill:    
        if high[a]<=high[b]:
            if a in good_hill:
                good_hill.remove(a)
        if high[b]<=high[a]:
            if b in good_hill:
                 good_hill.remove(b)
print(len(a))

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])
    X = abs(int(h[A] - int(h[B])))
    
    if X >= 1:
        ans += 1

print(ans)

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])
    X = int(h[A] - int(h[B]))
    
    if X >= 1:
        ans += 1

print(ans)

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)
    if h[a-1] == h[b-1]:
        ans.append(a)
        ans.append(b)
    else:
        ans.append(a)
        if h[b-1] in ans:
            ans.remove(b)
print(len(list(set(ans))))

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"

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

print(n - badcount)

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) and (b in bad):
      pass
    elif (a in bad) or (b in bad):
      bad.add(a)
      bad.add(b)
      num_good -= 1
    else:
      bad.add(a)
      bad.add(b)
      num_good -= 2
print(num_good)

Submission status: Runtime Error

Solution code:
import numpy as np
from sys import stdin

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

A = np.zeros((N, N))
for _ in range(M):
  a, b = map(int, input().split())
  A[a-1, b-1] = 1
  A[b-1, a-1] = 1

count = 0
for i in range(N):
  index = np.where(A[i]>=1)[0]
  if index.shape[0] == 0:
    count += 1
  else:
    B = H[index]
    if all([B[j]<H[i] for j in range(B.shape[0])])==True:
      count += 1
print(count)

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 if h[a-1] == h[b-1]:
        ans.append(a)
        ans.append(b)
    else:
        ans.append(a)
        if h[b-1] in ans:
            ans.remove(b)
print(len(list(set(ans))))

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)
    
        # 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()