TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
import math
import numpy as np
import sys
import os
from operator import mul
from operator import itemgetter

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N,M = LI()
H = LI()
AB = [LI() for _ in range(M)]

p = []
d = {}
for i in range(N):
    # p.append((i,H[i]))
    d[i]=H[i]
# p.sort(key=itemgetter(1),reverse=True)
# print(p)
print(d)


g = [set()] * N
a = [True] * N

for i in range(M):
    f = AB[i][0]-1
    t = AB[i][1]-1
    if d[t]>d[f]:
        a[f]=False
    elif d[f]>d[t]:
        a[t]=False
    else:
        a[f]=False
        a[t]=False
# print(a)
print(sum(a))  
    # print(g[f])
    # g[f] = np.append(g[f],t)
    # g[t] = np.append(g[t],f)
   
    # g[f][t]=1
    # g[t][f]=1

# print(g)
# list.sort(key=itemgetter(0))




# a = np.where(g[0]==1)
# print(a)

import math
import numpy as np
import sys
import os
from operator import mul
from operator import itemgetter

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N,M = LI()
H = LI()
AB = [LI() for _ in range(M)]

p = []
d = {}
for i in range(N):
    # p.append((i,H[i]))
    d[i]=H[i]
# p.sort(key=itemgetter(1),reverse=True)
# print(p)
# print(d)


g = [set()] * N
a = [True] * N

for i in range(M):
    f = AB[i][0]-1
    t = AB[i][1]-1
    if d[t]>d[f]:
        a[f]=False
    elif d[f]>d[t]:
        a[t]=False
    else:
        a[f]=False
        a[t]=False
# print(a)
print(sum(a))  
    # print(g[f])
    # g[f] = np.append(g[f],t)
    # g[t] = np.append(g[t],f)
   
    # g[f][t]=1
    # g[t][f]=1

# print(g)
# list.sort(key=itemgetter(0))




# a = np.where(g[0]==1)
# print(a)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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))

n,m = map(int,input().split())
h = list(map(int,input().split()))
c = dict()
for i in range(m):
    a, b = map(int,input().split())
    if a in c:
        c[a].append(b)
    else:
        c[a] = [b]
    if b in c:
        c[b].append(a)
    else:
        c[b] = [a]
        
cnt = n
for k,v in c.items():
    for i in range(len(v)):
        if h[v[i] - 1] >= h[k - 1]:
            cnt -= 1
            break
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N,M = map(int, input().split())
H = list(map(int, input().split()))

lst = [0 for i in range(N)]

for m in range(M):
    a,b = map(int, input().split())
    a-=1
    b-=1
    if lst[a] > lst[b]:
        lst[b]-=1
    elif lst[a] < lst[b]:
        lst[b]-=1

print(lst.count(0))

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

lst = [0 for i in range(N)]

for m in range(M):
    a,b = map(int, input().split())
    a-=1
    b-=1
    if H[a] > H[b]:
        lst[b]-=1
    elif H[a] < H[b]:
        lst[a]-=1
    else:
        lst[a]-=1
        lst[b]-=1

print(lst.count(0))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n, m = map(int,input().split())
h = list(map(int,input().split()))

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


point = [0]*n
app = [0]*n
cnt = []

for i in ab:
    app[i[0]-1] += 1
    app[i[1]-1] += 1
    if h[i[0]-1] > h[i[1]-1]:
        point[i[0]-1] += 1
    elif h[i[0]-1] < h[i[1]-1]:
        point[i[1]-1] += 1
for i in range(n):
    if app[i] == point[i]:
        cnt.append(i+1)
print(cnt)

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

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

mj = []

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

for i in range(n):
    
    cnt = 0
    h_high = 0
    for j in range(m):
        if i+1 in mj[j]:
            cnt += 1
            if i == mj[j][0]-1:
                if h[i] > h[mj[j][1]-1]:
                    h_high += 1
            else:
                if h[i] > h[mj[j][0]-1]:
                    h_high += 1
    if cnt == h_high:
        tower += 1
        
print(len(tower))

point = [0]*n
app = [0]*n
cnt = []

for i in ab:
    app[i[0]-1] += 1
    app[i[1]-1] += 1
    if h[i[0]-1] > h[i[1]-1]:
        point[i[0]-1] += 1
    elif h[i[0]-1] < h[i[1]-1]:
        point[i[1]-1] += 1
for i in range(n):
    if app[i] == point[i]:
        cnt.append(i+1)
print(cnt)

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

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


point = [0]*n
app = [0]*n
cnt = []

for i in ab:
    app[i[0]-1] += 1
    app[i[1]-1] += 1
    if h[i[0]-1] > h[i[1]-1]:
        point[i[0]-1] += 1
    elif h[i[0]-1] < h[i[1]-1]:
        point[i[1]-1] += 1
for i in range(n):
    if app[i] == point[i]:
        cnt.append(i+1)
print(len(cnt))


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
# 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(set([int(inps[0]), int(inps[1])]))
    
def get_height(els):
    return H[els[0]-1] > H[els[1]-1]

def get_height_sum(arr):
    if not arr:
        return 1
    return np.prod(list(map(get_height, arr)))

def tmp(arr_arr):
    return (list(map(get_height_sum, arr_arr)))
    return sum(list(map(get_height_sum, arr_arr)))

connected = [[[i+1] + list(ab - {i+1}) for ab in AB if i+1 in ab] for i in range(N)]

print(int(tmp(connected)))

# C
import numpy as np

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

inps = input().split(' ')
H = np.array([int(inp) for inp in range(len(inps))])
AB = []
for i in range(M):
    inps = input().split(' ')
    AB.append(set([int(inps[0]), int(inps[1])]))
    
def get_height(els):
    return H[els[0]-1] >= H[els[1]-1]

def get_height_sum(arr):
    return np.prod(list(map(get_height, arr)))

def tmp(arr_arr):
    return (list(map(get_height_sum, arr_arr)))

connected = [[[i+1] + list(ab - {i+1}) for ab in AB if i+1 in ab] for i in range(N)]

print(int(tmp(connected)))

# C
import numpy as np

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

inps = input().split(' ')
H = np.array([int(inp) for inp in range(len(inps))])
AB = []
for i in range(M):
    inps = input().split(' ')
    AB.append(set([int(inps[0]), int(inps[1])]))
    
def get_height(els):
    return H[els[0]-1] >= H[els[1]-1]

def get_height_sum(arr):
    return np.prod(list(map(get_height, arr)))

def tmp(arr_arr):
    return sum(list(map(get_height_sum, arr_arr)))

connected = [[[i] + list(ab - {i+1}) for ab in AB if i+1 in ab] for i in range(N)]

print(int(tmp(connected)))

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

A = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    A[a-1] = max(A[a-1], H[b-1])
    A[b-1] = max(A[b-1], H[a-1])
    
res = sum([H[i] > A[i] for i in range(N)])
print(res)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import math
import sys

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

lis = [0] * N  


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

    hightA = H[A-1]
    hightB = H[B-1]

    if hightA < hightB:
        if lis[B-1] == 0:
            lis[B-1] = 1
            lis[A-1] = -1
        
        elif lis[B-1] == 1 or lis[B-1] == -1:
            lis[A-1] = -1
    
    if hightB < hightA:
        if lis[A-1] == 0:
            lis[A-1] = 1
            lis[B-1] = -1
        
        elif lis[A-1] == 1 or lis[A-1] == -1:
            lis[B-1] = -1

    if hightB == hightA:
        lis[A-1] = -1
        lis[B-1] = -1

print(lis)

import math
import sys

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

lis = [0] * N  


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

    hightA = H[A-1]
    hightB = H[B-1]

    if hightA < hightB:
        if lis[B-1] == 0:
            lis[B-1] = 1
            lis[A-1] = -1
        
        elif lis[B-1] == 1 or lis[B-1] == -1:
            lis[A-1] = -1
    
    if hightB < hightA:
        if lis[A-1] == 0:
            lis[A-1] = 1
            lis[B-1] = -1
        
        elif lis[A-1] == 1 or lis[A-1] == -1:
            lis[B-1] = -1

    if hightB == hightA:
        lis[A-1] = -1
        lis[B-1] = -1

ans = 0
for i in lis:
  if i == 0 or i == 1:
    ans = ans + 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [0] * M
B = [0] * M
G = [1] * N
for i in range(M):
    A[i], B[i] = map(int, input().split())
    me = A[i-1]
    t = B[i-1]
    if H[me-1] <= H[t-1]:
        G[me-1] = 0

    me = B[i-1]
    t = A[i-1]
    if H[me-1] <= H[t-1]:
        G[me-1] = 0
print(G.count(1))

N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [0] * M
B = [0] * M
G = [1] * N
for i in range(M):
    A[i], B[i] = map(int, input().split())
    me = A[i]-1
    t = B[i]-1
    if H[me] <= H[t]:
        G[me] = 0

    me = B[i]-1
    t = A[i]-1
    if H[me] <= H[t]:
        G[me] = 0
print(G.count(1))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,M = map(int,input().split())
height_list = list(map(int,input().split()))
road_list = []

for i in range(M):
    road_list.append(list(map(int,input().split())))
    
print(height_list)
print(road_list)
print(road_list[0])

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

edge = [[] for _ in range(n)]

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

cnt = 0

for node in range(n):
    good = True
    for neighbor in edge[node]:
        if hs[node] <= hs[neighbor]:
            good = False
    if good:
        cnt += 1

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

cnt = 0
for n in range(1,N+1):
    adj = []
    adj.append([n])
    for i in AB:
        if n in i:
            adj.append(i)
    adj = set(sum(adj,[]))
    adj_H = [H[s-1] for s in adj]
    if max(adj_H) == H[n-1] and adj_H.count(max(adj_H)) == 1:
        ans.append(n)
        cnt += 1

print(cnt)


N, M = map(int, input().split())
H = list(map(int, input().split()))
g = [[] for _ in range(N+1)]

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

cnt = 0
for n in range(1,N+1):
    for i in g[n]:
        if H[n-1] <= H[i-1]:
            break
    else:
        cnt += 1

print(cnt)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
from collections import defaultdict

N ,M = map(int,input().split())
H = list(map(int,input().split()))
graph = defaultdict(list)
for _ in range(M-1):
    A, B = map(int,input().split())
    graph[A].append(H[B-1])
    graph[B].append(H[A-1])

cnt = 0
for i in range(1,N+1):
    t = H[i-1]
    a = max(graph[i])
    if t >a:
        cnt += 1
print(cnt)

from collections import defaultdict

N ,M = map(int,input().split())
H = list(map(int,input().split()))
graph = defaultdict(int)
for _ in range(M):
    A, B = map(int,input().split())
    graph[A]= max(graph[A],H[B-1])
    graph[B]= max(graph[B],H[A-1])

print(sum(H[i-1] > graph[i] for i in range(1,N+1)))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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))

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

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

n, m = map(int, input().split())
h = list(map(int, input().split()))
list1 = [1] * n
for _ 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))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import sys
input = sys.stdin.readline

def ppp(n,m,h,ab):
    g = [1] * n
    for l,r in ab:
        if h[l-1] >= h[r-1]:
            g[r-1] = 0
        if h[l-1] <= h[r-1]:
            g[l-1] = 0
    print(sum(g))
if __name__ == "__main__":
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    ab = [list(map(int,input().split())) for _ in range(m)]
    ppp(n,m,h,ab_sorted)


import sys
input = sys.stdin.readline

def peaks(n,m,h,ab):
    g = [0] * n
    path = [ [i+1] for i in range(n)]
    print(ab)
    for l,r in ab:
        path[l-1].append(r)
        path[r-1].append(l)

    print(path)

    for i,p in enumerate(path):
        if h[i] >= max(p):
            g[i] = 1

    print(sum(g))

if __name__ == "__main__":
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    ab = [list(map(int,input().split())) for _ in range(m)]
    ab_sorted = sorted(ab)
    peaks(n,m,h,ab_sorted)


import sys
input = sys.stdin.readline

def ppp(n,m,h,ab):
    g = [1] * n
    for l,r in ab:
        if h[l-1] >= h[r-1]:
            g[r-1] = 0
        if h[l-1] <= h[r-1]:
            g[l-1] = 0
    print(sum(g))
if __name__ == "__main__":
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
    ab = [list(map(int,input().split())) for _ in range(m)]
    ppp(n,m,h,ab)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    if h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    if h[A[i] - 1] == h[B[i] - 1]:
        p[A[i]] = False
        p[B[i]] = False
    print(p)
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))


n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    elif h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    else:
        p[A[i]] = False
        p[B[i]] = False
    print(p)
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))


n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    elif h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    else:
        p[A[i]] = False
        p[B[i]] = False
    
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
# 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))

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
# -*- coding: utf-8 -*-

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

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

ans = 0

for i in range(n):
    ok = True
    for j in to[i]:
        if(h[i] <= h[j]):
            ok = False
    if(ok):
        ans += 1

print(ans)


# -*- coding: utf-8 -*-

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

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

ans = 0

for i in range(n):
    ok = True
    for j in to[i]:
        if(h[i] <= h[j]):
            ok = False
    if(ok):
        ans += 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,m=list(map(int,input().split()))
h=list(map(int,input().split()))
b=[[]for i in range(n)]
for i in range(m):
  a=list(map(lambda x:int(x)-1,input().split()))
  b[a[0]].append(a[1])
  b[a[1]].append(a[0])
s=0
for i in range(n):
  f=1
  for j in b[i]:
    if h[i]<=h[j]:
      f=0
      break
  if f:
    s+=1

n,m=list(map(int,input().split()))
h=list(map(int,input().split()))
b=[[]for i in range(n)]
for i in range(m):
  a=list(map(lambda x:int(x)-1,input().split()))
  b[a[0]].append(a[1])
  b[a[1]].append(a[0])
s=0
for i in range(n):
  f=1
  for j in b[i]:
    if h[i]<=h[j]:
      f=0
      break
  if f:
    s+=1
print(s)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, M = map(int, input().split(' '))

height = list(map(int, input().split(' ')))
height_all = height

for i range(M):
  a, b = map(int, input().split(' '))
  if height[a - 1] == height[b - 1]:
    height_all.remove(height[a - 1])
  elif height[a - 1] > height[b - 1]:
    height_all.remove(height[b - 1])
  else:
    height_all.remove(height[a - 1])
print(len(height_all))

import numpy as np
N, M = map(int, input().split(' '))

height = np.array(list(map(int, input().split(' '))))
#height_all = height

for i in range(M):
  a, b = map(int, input().split(' '))
  #print(a, b, height[a - 1], height[b - 1])
  if height[a - 1] > height[b - 1]:
    height[b - 1] = 0
   
  else:
    height[a - 1] = 0
  
print(len(np.nonzero(height)))

import numpy as np
N, M = map(int, input().split(' '))

height = np.array(list(map(int, input().split(' '))))
height_all = np.array(list(height))

for i in range(M):
  a, b = map(int, input().split(' '))
  #print(a, b, height[a - 1], height[b - 1])
  if height[a - 1] > height[b - 1]:
    height_all[b - 1] = 0
  
  elif height[a - 1] == height[b - 1]:
    height_all[a - 1] = 0
    height_all[b - 1] = 0
    
  else:
    height_all[a - 1] = 0
    
  #print(height_all)
  
print(len(np.nonzero(height_all)[0]))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,m = map(int,input().split())
H = list(map(int,input().split()))
p = [0]*n
for i in range(m):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        H[b-1] = -1
    if H[a-1] <= H[b-1]:
        H[a-1] = -1
print(p.count(0))


n,m = map(int,input().split())
H = list(map(int,input().split()))
p = [0]*n
for i in range(m):
    a,b = map(int,input().split())
    if H[a-1] >= H[b-1]:
        p[b-1] = -1
    if H[a-1] <= H[b-1]:
        p[a-1] = -1
print(p.count(0))


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, M = map(int, input().split())
Height = [int(i) for i in input().split()]

count = 0
for _ in range(M):
    A, B = map(int, input().split())
    if min(Height[A - 1], Height[B - 1]) != 0:
        count += 1
    Height[A - 1], Height[B - 1] = 0, 0

for i in Height:
    if i != 0:
        count += 1

print(count)

N, M = map(int, input().split())
Height = [int(i) for i in input().split()]
check = [1] * N

A_List = [0] * M
B_List = [0] * M
for i in range(M):
    A, B = map(int, input().split())
    A_List[i] = A
    B_List[i] = B



for i in range(M):
    if Height[A_List[i] - 1] > Height[B_List[i] - 1]:
        check[B_List[i] - 1] = 0
    elif Height[A_List[i] - 1] < Height[B_List[i] - 1]:
        check[A_List[i] - 1] = 0
    elif Height[A_List[i] - 1] == Height[B_List[i] - 1]:
        check[B_List[i] - 1] = 0
        check[A_List[i] - 1] = 0


print(sum(check))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import collections
n,m = list(map(int,input().split()))
tower_high = list(map(int,input().split()))
good_tower = [1]*n

def check_tower(a,b):
    if tower_high[a]<tower_high[b]:
        good_tower[a]=0
    elif tower_high[a] > tower_high[b]:
        good_tower[b]=0
    else:
        good_tower[a]=0
        good_tower[b]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    check_tower(a-1,b-1)
print(good_tower)
print(good_tower.count(1))


import collections
n,m = list(map(int,input().split()))
tower_high = list(map(int,input().split()))
good_tower = [1]*n

def check_tower(a,b):
    if tower_high[a]<tower_high[b]:
        good_tower[a]=0
    elif tower_high[a] > tower_high[b]:
        good_tower[b]=0
    else:
        good_tower[a]=0
        good_tower[b]=0

for i in range(m):
    a,b=list(map(int,input().split()))
    check_tower(a-1,b-1)
print(good_tower.count(1))


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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))




if __name__ == "__main__":
    N, M = list(map(int, input().split()))
    H = list(map(int, input().split()))
    adj_max = [0 for i in range(N)]
    for i in range(M):
        a, b = list(map(int, input().split()))
        if adj_max[a-1] < H[b-1]:
            adj_max[a-1] = H[b-1]
        if adj_max[b-1] < H[a-1]:
            adj_max[b-1] = H[a-1]
    num = 0
    for i in range(N):
        if H[i] > adj_max[i]:
            num += 1
    print(num)




Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
if __name__ == '__main__':

    nm = input()
    nm = nm.split()
    n = int(nm[0])
    m = int(nm[1])

    h = input()
    h = h.split()
    h = list(map(int,h))
    print(h)
    AB = []
    for i in range(m):
        ab = input()
        ab = ab.split()
        ab = list(map(int,ab))
        AB.append(ab)

    s = set()
    for i in range(m):
        if h[AB[i][0]] > h[AB[i][0]]:
            s.add(AB[i][0])
        else:
            s.add(AB[i][1])

    print(len(s))


if __name__ == '__main__':

    nm = input()
    nm = nm.split()
    n = int(nm[0])
    m = int(nm[1])

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

    AB = []
    ma = [0]*n
    for i in range(m):
        ab = input()
        ab = ab.split()
        ab = list(map(int,ab))
        ma[ab[0]-1] = max(ma[ab[0]-1],h[ab[1]-1])
        ma[ab[1]-1] = max(ma[ab[1]-1],h[ab[0]-1])

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,m = map(int,input().split(' '))
h = list(map(int,input().split(' ')))
ansList = [1]*n
numlist = []

for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        #ansList[a-1] = ma
        numlist.append(b-1)
    else:
        numlist.append(a-1)
for i in list(set(numlist)):
    ansList[i] = 0
print(ansList.count(1))

print(set(numlist))
print(ansList)

n,m = map(int,input().split(' '))
h = list(map(int,input().split(' ')))
ansList = [1]*n
numlist = []

for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        #ansList[a-1] = ma
        numlist.append(b-1)
    elif h[a-1] == h[b-1]:
        numlist.append(a-1)
        numlist.append(b-1)
    else:
        numlist.append(a-1)
for i in list(set(numlist)):
    ansList[i] = 0
print(ansList.count(1))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
#!python3

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


def main():
    link = [[] for _ in range(N)]
    for a, b in AB:
        link[a - 1].append(b - 1)
        link[b - 1].append(a - 1)

    ans = N
    for i in range(N):
        for x in link[i]:
            if H[i] <= H[x]:
                print(i, H[i], x, H[x])
                ans -= 1
                break
    
    print(ans)


if __name__ == "__main__":
    main()


#!python3

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


def main():
    link = [[] for _ in range(N)]
    for a, b in AB:
        link[a - 1].append(b - 1)
        link[b - 1].append(a - 1)

    ans = N
    for i in range(N):
        for x in link[i]:
            if H[i] <= H[x]:
                ans -= 1
                break
    
    print(ans)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,M=map(int,input().split())
H=list(map(int,input().split()))
P=[]
for i in range(M):
    P.append(list(map(int,input().split()))) 

ans=[]

for i in range(M):
    if H[P[i][0]-1]>H[P[i][1]-1]:   
        ans.append([P[i][0])
    elif H[P[i][0]-1]<H[P[i][1]-1]: 
        ans.append(P[i][1])       
    else:                           
        continue                    
    
list=[]

for j in range(M): 
    list+=P[j]

print(len(set(ans))+N-len(set(list)))

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

bad = []
for i in range(m):
  if h[l[i][0] - 1] > h[l[i][1] - 1]:
    bad.append(l[i][1])
  elif h[l[i][0] - 1] < h[l[i][1] - 1]:
    bad.append(l[i][0])
  else:
    bad.append(l[i][0])
    bad.append(l[i][1])

print(n - len(set(bad)))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,m = map(int,input().split())
h = list(map(int,input().split()))
H = set(range(n))
print(h)
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] <= h[b-1]:
        H.discard(a-1)
    if h[a-1] >= h[b-1]:
        H.discard(b-1)

print(len(H))

n,m = map(int,input().split())
h = list(map(int,input().split()))
H = set(range(n))
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] <= h[b-1]:
        H.discard(a-1)
    if h[a-1] >= h[b-1]:
        H.discard(b-1)

print(len(H))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
 import sys
input=sys.stdin.readline

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

import sys
input=sys.stdin.readline

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N, M = map(int,input().split())
height = list(map(int,input().split()))
bet,cost = [],[0]*N
for i in range(M):
     bet.append(list(map(int,input().split())))

for b in bet:
    if height[b[0]-1] < height[b[1]-1]:
        cost[b[1]-1] = 1
    else:
        cost[b[0]-1] = 1

print(cost)


n,m = map(int,input().split())
h = list(map(int,input().split())
judge = [True] * n

for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] >= h[b-1]:
        judge[b-1] = False
    else:
        judge[a-1] = False
        
print(judge.count(True))

n,m = map(int,input().split())
h = list(map(int,input().split()))
judge = [True] * n

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

print(judge.count(True))


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N,M= list(map(int, input().split())) 
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M

for i in range(M):
    A[i], B[i]= map(int, input().split())
    
ans = []*N
for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] < H[b]:
        ans[a]=1
    elif H[a] > H[b]:
        ans[b]=1
    else:
        ans[a]=0
        ans[b]=0
print(ans.count(1))

N,M= list(map(int, input().split())) 
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i]= map(int, input().split())
ans = set([])
for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] <= H[b]:
        ans.add(B[i])
    else:
        ans.add(A[i])
len(ans)

N,M= list(map(int, input().split())) 
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
ans = [1]*N

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

for i in range(M):
    a = A[i]-1
    b = B[i]-1
    if H[a] < H[b]:
        ans[a]=0
    elif H[a] > H[b]:
        ans[b]=0
    else:
        ans[a]=0
        ans[b]=0
        
print(ans.count(1))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n, m = map(int, input().split())
arr = [0] + list(map(int, input().split()))
g = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

ans = 0
for i in range(1, n + 1):
    for j in g[i]:
        if arr[j] >= arr[i]:
            break
        else:
            ans += 1

print(ans)


n, m = map(int, input().split())
arr = [0] + list(map(int, input().split()))
g = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

ans = 0
for i in range(1, n + 1):
    for j in g[i]:
        if arr[j] >= arr[i]:
            break
    else:
        ans += 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n, m = map(int, input().split())
h = list(map(int, input().split()))
l_n = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    elif h[a-1] >= h[b-1]:
        l_n[b-1] = False
    elif h[a-1] <= h[b-1]:
        l_n[a-1] = False
print(sum(l_n)) 

n, m = map(int, input().split())
h = list(map(int, input().split()))
l_n = [True] * n
for i in range(m):
    a, b = map(int, input().split())
    elif h[a-False] >= h[b-False]:
        l_n[b-False] = False
    elif h[a-False] <= h[b-False]:
        l_n[a-False] = False
print(sum(l_n)) 

import sys
def main():
    input = sys.stdin.readline
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    l_n = [True] * n
    for i in range(m):
        a, b = map(int, input().split())
        if h[a-1] == h[b-1]:
            l_n[b-1] = False
            l_n[a-1] = False
        elif h[a-1] <= h[b-1]:
            l_n[a-1] = False
        elif h[a-1] >= h[b-1]:
            l_n[b-1] = False
    print(sum(l_n)) 

if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Runtime Error

Accepted