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

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

good = 0

obs = [[]*n]

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

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

good = 0

obs = [[] for i in range(n) ]

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

    higher = True
    if len(o) == 0:
        good += 1
        continue
    o = set(o)
    for i in o:
        if h[idx] <= h[i-1]:
            higher = False
    if higher:
        good += 1

print(good)



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

good = 0

obs = [[] for i in range(n) ]

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

for idx,o in enumerate(obs):
    higher = True
    if len(o) == 0:
        good += 1
        continue
    o = set(o)
    for i in o:
        if h[idx] <= h[i-1]:
            higher = False
    if higher:
        good += 1

print(good)

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=map(int,input().split(" "))
heights=list(map(int,input().split(" ")))

roads=[]
mountains={}
testM=0
res=0
ways=0
temp=0
sign=False
for i in range(m):
    roads.append(list(map(int,input().split(" "))))
for j in range(1,n+1):
    if sign:
        res+=1
    sign=True
    for k in range(m):
        if  j==roads[k][0]:
            if  heights[roads[k][1]-1]>heights[j-1]:
                sign=False
                break
        elif j==roads[k][1]:
            if  heights[roads[k][1]-1]>heights[j-1]:
                sign = False
                break

print(res)


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

roads=[]
mountains={}
testM=0
res=0
ways=0
temp=0
sign=False
for i in range(m):
    roads.append(list(map(int,input().split(" "))))
print(n,m,heights,roads)
for j in range(1,n+1):
    if sign:
        print(j-1)
        res+=1
    sign=True
    for k in range(m):
        if  j==roads[k][0]:
            if  heights[roads[k][1]-1]>heights[j-1]:
                sign=False
                break
        elif j==roads[k][1]:
            if  heights[roads[k][1]-1]>heights[j-1]:
                sign = False
                break

print(res)


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)

n,m = map(int,input().split())
h = list(map(int,input().split()))
p = [0 for i in range(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

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 = map(int, input().split())
H = list(map(int, input().split()))
Height = []
Good = []
for i in range(N):
    Height.append(H[i])
    Good.append(0)
for i in range(M):
    A, B = map(int, input().split())
    if Height[A - 1] < Height[B - 1]:
        Good[A - 1] = 1
    if Height[A - 1] > Height[B - 1]:
        Good[B - 1] = 1
    else:
        Good[A - 1] = 1
        Good[B - 1] = 1
n = 0
for i in range(N):
    if Good[i] == 0:
        n += 1
print(n)

N, M = map(int, input().split())
H = list(map(int, input().split()))
Height = []
Good = []
for i in range(N):
    Height.append(H[i])
    Good.append(0)
for i in range(M):
    A, B = map(int, input().split())
    if Height[A - 1] < Height[B - 1]:
        Good[A - 1] = 1
    elif Height[A - 1] > Height[B - 1]:
        Good[B - 1] = 1
    else:
        Good[A - 1] = 1
        Good[B - 1] = 1
n = 0
for i in range(N):
    if Good[i] == 0:
        n += 1
print(n)

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 = [int(_) for _ in input().split()]

elevation = {}
for _ in range(len(h)):
    elevation[_+1] = h[_]

obs = list([] for _ in range(len(h)))
for i in range(m):
    obsA, obsB = map(int, input().split())
    if elevation[obsA] == elevation[obsB]:  
        obs[obsA-1].append(1)  # 1==True, 0==False
        obs[obsB-1].append(1)
    elif elevation[obsA] > elevation[obsB]:
        obs[obsA-1].append(1)
        obs[obsB-1].append(0)
    elif elevation[obsA] < elevation[obsB]:
        obs[obsA-1].append(0)
        obs[obsB-1].append(1)

count = 0
for o in obs:  
    if all(o):  
        count += 1

print(count)
print(elevation)
print(obs)

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

elevation = {}
for _ in range(len(h)):
    elevation[_+1] = h[_]

obs = list([] for _ in range(len(h)))
for i in range(m):
    obsA, obsB = map(int, input().split())
    if elevation[obsA] == elevation[obsB]:  
        obs[obsA-1].append(0)  # 1==True, 0==False
        obs[obsB-1].append(0)
    elif elevation[obsA] > elevation[obsB]:
        obs[obsA-1].append(1)
        obs[obsB-1].append(0)
    elif elevation[obsA] < elevation[obsB]:
        obs[obsA-1].append(0)
        obs[obsB-1].append(1)

count = 0
for o in obs:  
    if all(o):  
        count += 1

print(count)
print(elevation)
print(obs)

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

elevation = {}
for _ in range(len(h)):
    elevation[_+1] = h[_]

obs = list([] for _ in range(len(h)))
for i in range(m):
    obsA, obsB = map(int, input().split())
    if elevation[obsA] == elevation[obsB]:  
        obs[obsA-1].append(0)  # 1==True, 0==False
        obs[obsB-1].append(0)
    elif elevation[obsA] > elevation[obsB]:
        obs[obsA-1].append(1)
        obs[obsB-1].append(0)
    elif elevation[obsA] < elevation[obsB]:
        obs[obsA-1].append(0)
        obs[obsB-1].append(1)

count = 0
for o in obs:  
    if all(o):  
        count += 1

print(count)
# print(elevation)
# print(obs)

Verdicts: Wrong Answer

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 numpy as np
N, M = [int(x) for x in input().split()]
H = [float(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(M)]

graph = np.zeros((N,N))
for A, B in AB:
  graph[A-1][B-1] = 1
  graph[B-1][A-1] = 1

ans = 0
for i in range(N):
  h = 0
  for j in range(N):
    if(graph[i][j]!=0):
      if(H[i]<=H[j]):
        h += 1
  if(h==0):
    ans += 1

import numpy as np
N, M = [int(x) for x in input().split()]
H = [float(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(M)]

graph = np.zeros((N,N))
for A, B in AB:
  graph[A-1][B-1] = 1
  graph[B-1][A-1] = 1

ans = 0
for i in range(N):
  for j in range(N):
    h = 0
    if(graph[i][j]!=0):
      if(H[i]<=H[j]):
        h += 1
  if(h==0):
    ans += 1
print(ans)

import numpy as np
N, M = [int(x) for x in input().split()]
H = [float(x) for x in input().split()]
AB = [[int(x) for x in input().split()] for _ in range(M)]

max_h = [0 for _ in range(N)]

for A, B in AB:
  max_h[A-1] = max(max_h[A-1], H[B-1])
  max_h[B-1] = max(max_h[B-1], H[A-1])

ans = 0
for i in range(N):
  if(H[i]>max_h[i]):
    ans += 1
print(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(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)))

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 = [0]*N
for i in range(M):
    if H[A[i]] >= H[B[i]]:
        lis[B[i]] = 1
    if H[A[i]] <= H[B[i]]:
        lis[A[i]] = 1
    
    print(lis.count(0))

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 = [0]*N
for i in range(M):
    if H[A[i]] >= H[B[i]]:
        lis[B[i]] = -1
    if H[A[i]] <= H[B[i]]:
        lis[A[i]] = -1
    
    print(lis.count(0))

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 = [0]*N

for i in range(M):
    if H[A[i]] >= H[B[i]]:
        lis[B[i]] = -1
    if H[A[i]] <= H[B[i]]:
        lis[A[i]] = -1
    

print(lis.count(0))

Verdicts: Runtime Error

Wrong Answer

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
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    H=[int(_) for _ in input().split()]
    HH= [0]*n

    for i in range(m):
        a,b=map(int,input().split())
        HH[a-1]=max(HH[a-1],H[b-1])
        HH[b-1]=max(HH[b-1],H[a-1])
    ans=0
    for i,hh in enumerate(HH):
        if H[i]>hh or hh==0:
            ans+=1
    print(HH)
    print(ans)

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    H=[int(_) for _ in input().split()]
    HH= [0]*n

    for i in range(m):
        a,b=map(int,input().split())
        HH[a-1]=max(HH[a-1],H[b-1])
        HH[b-1]=max(HH[b-1],H[a-1])
    ans=0
    for i,hh in enumerate(HH):
        if H[i]>hh or hh==0:
            ans+=1
    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):
import collections
n,m = (int(i) for i in input().split())
h = [int(i) for i in input().split()]
ab =[[0]]*n
print(ab)
for _ in range(m):
	a,b = (int(i) for i in input().split())
	if h[a-1]-h[b-1]>0:
		ab[b-1]=["a"]

	elif h[a-1]-h[b-1]<0:
		ab[a-1]=["a"]

	else:
		ab[a-1]=["a"]
		ab[b-1]=["a"]


print(ab.count([0]))

import collections
n,m = (int(i) for i in input().split())
h = [int(i) for i in input().split()]
ab =[[0]]*n

for _ in range(m):
	a,b = (int(i) for i in input().split())
	if h[a-1]-h[b-1]>0:
		ab[b-1]=["a"]

	elif h[a-1]-h[b-1]<0:
		ab[a-1]=["a"]

	else:
		ab[a-1]=["a"]
		ab[b-1]=["a"]


print(ab.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):
import numpy as np
n,m = list(map(int,input().split()))
h_ = list(map(int,input().split()))
a_ = [list(map(int,input().split())) for i in range(m)]

res = np.arange(2,n)
res = res.tolist()
for i in range(m):
    if(h_[a_[i][0] - 1] < h_[a_[i][1] - 1]):
        if(a_[i][0] in res):
            res.remove(a_[i][0])
    elif(h_[a_[i][0] - 1] > h_[a_[i][1] - 1]):
        if(a_[i][1] in res):
            res.remove(a_[i][1])
    else:
        if(a_[i][0] in res):
            res.remove(a_[i][0])
        if(a_[i][1] in res):
            res.remove(a_[i][1])

print(len(res))


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

resList = []
for i in range(m):

    if(h_[a_[i][0] -1] > h_[a_[i][1] -1]):
        res = a_[i][0]
        res_not = a_[i][1]
    elif(h_[a_[i][0] -1] < h_[a_[i][1] -1]):
        res = a_[i][1]
        res_not = a_[i][0]
    else:
        continue

    if(res in resList):
        continue
    else:
        resList.append(res)

    if(res_not in resList):
        resList.remove(res_not)
    else:
        continue

print(resList)


n,m = map(int,input().split())
h=[]
h.extend(input().split())
h=list(map(int,h))
cnt = [0]*n
cnt2 = [0]*n
ans = 0

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

for p in range(n):
  if cnt[p]==cnt2[p]:
    ans += 1
print(ans)


Verdicts: Wrong Answer

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())
HList = []
ansList=[]
for H in input().split():
    HList.append(H)
    ansList.append(1)

print(ansList)

for i in range(M):
    A, B = map(int, input().split())
    if HList[A-1] > HList[B-1]:
        ansList[B-1] = 0
    elif HList[A-1] < HList[B-1]:
        ansList[A-1] = 0
    elif HList[A-1] == HList[B-1]:
        ansList[A-1] = 0
        ansList[B-1] = 0

print(ansList.count(1))


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

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

print(ans.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):
import random
import collections
# num_list = [10**5, 10**4]

# way_list = [[random.randint(1, 10**5), random.randint(1, 10**5)] for i in range(10**4)]

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]-1] > height_list[target_list[1]-1]:
        gd_dict[target_list[1]] = 'bad'
    elif height_list[target_list[0]-1] == height_list[target_list[1]-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

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

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((len(tower_list)))]))

def change_to_bad(target_list):
    if height_list[target_list[0]-1] > height_list[target_list[1]-1]:
        gd_dict[target_list[1]] = 'bad'
    elif height_list[target_list[0]-1] == height_list[target_list[1]-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']

print(good_val)

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 = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif height[r[0]-1] < height[r[1]-1]:
        lower_list.append(r[0],r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif:
        lower_list.append(r[0],r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif height[r[0]-1] == height[r[1]-1]:
        lower_list.append(r[0])
        lower_list.append(r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

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):
def solve(height, road):
    graph = collections.defaultdict(set)
    for a, b in road:
        graph[a].add(b)
        graph[b].add(a)
    ans = 0
    no_good = set()
    for k in graph:
        for nei in graph[k]:
            if height[nei-1] >= height[k-1]:
                no_good.add(k)
    return len(height) -  len(no_good)

obs, k = map(int, input().split())
height = list(map(int, input().split()))
road = []
for _ in range(k):
    r = list(map(int, input().split()))
    road.append(r)
print(solve(height, road))


import collections

def solve(height, road):
    graph = collections.defaultdict(set)
    for a, b in road:
        graph[a].add(b)
        graph[b].add(a)
    ans = 0
    no_good = set()
    for k in graph:
        for nei in graph[k]:
            if height[nei-1] >= height[k-1]:
                no_good.add(k)
    return len(height) -  len(no_good)

obs, k = map(int, input().split())
height = list(map(int, input().split()))
road = []
for _ in range(k):
    r = list(map(int, input().split()))
    road.append(r)
print(solve(height, road))


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


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
    
    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)
        else:
            ans.add(a)
            ans.add(b)
    print(N - len(ans))

if __name__ == '__main__':
    main()


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())
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 v in range(1,N+1):
    for u in g[v]:
        if arr[u]>=arr[v]:
            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)]
print(arr)
print (g)
for _ in range(M):
    A, B = map(int,input().split())
    g[A].append(B)
    g[B].append(A)
print (g)
ans = 0
for v in range(1,N+1):
    for u in g[v]:
        if arr[u]>=arr[v]:
            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 v in range(1,n+1):
  for u in g[v]:
    if arr[u]>=arr[v]:
      break
  else:
    ans+=1
print(ans)

Verdicts: Wrong Answer

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 = []
for i range(m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

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

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

import copy

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

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

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

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

import copy

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

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Verdicts: Runtime Error

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

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

H = [0] + list(map(int,input().split()))

path = {}
for i in range(1,N+1):
	path[i] = {}

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

count = 0

for i in range(1,N+1)
	if H[i] > max(H[j] for j in path[i]):
		count += 1
	
print(count)


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

H = [0] + list(map(int,input().split()))

path = [0]
for i in range(1,N+1):
	path.append([])

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

count = 0

for i in range(1,N+1):
	if len(path[i]) == 0:
		count += 1
	elif H[i] > max(H[j] for j in path[i]):
		count += 1
	
print(count)

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()))
List = []
for k in range(1,N+1):
  List.append(k)
for i in range(M):
  A,B = map(int,input().split())
  tmpA = H[A-1]
  tmpB = H[B-1]
  if(tmpA < tmpB):
    if(A in List == True):
      List.remove(A)
  elif(tmpA > tmpB):
    if(B in List == True):
      List.remove(B)
  else:
    if(A in List == True):
      List.remove(A)
    if(B in List == True):
      List.remove(B)
print(str(len(List)))

N,M = map(int,input().split())
H = list(map(int,input().split()))
List = [0]*N
for i in range(M):
    A,B = map(int,input().split())
    if(H[A-1] > H[B-1]):
        List[B-1] = 1
    elif(H[A-1] < H[B-1]):
        List[A-1] = 1
    else:
        List[A-1] = 1
        List[B-1] = 1
print(str(List.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):
import numpy as np
n, m = map(int, input().split())
hlis = list(map(int, input().split()))
road = []
for i in range(m):
    a, b = map(int, input().split())
    road.append([a, b])
table = [0]*n
ans = 0
for i in range(n):
    if table[i] == 0:
        rival = []
        for j in road:
            if j[0] == i+1:
                rival.append(j[1]-1)
            elif j[1] == i+1:
                rival.append(j[0]-1)
        if hlis[i] == max([hlis[q] for q in rival]+[hlis[i]]) and [hlis[q] for q in rival].count(hlis[i])== 0:
            table[i] = 1
            ans += 1
            for q in rival:
                table[q] = -1 
        else:
            table[i] = -1
print(ans, table)

import sys
n, m = map(int, input().split())
hlis = list(map(int, input().split()))
road = []
for i in range(m):
    a, b = map(int, input().split())
    road.append([a, b])
table = [0]*n
ans = 0
for i in range(n):
    if table[i] != 0:
      	break
    else:
        rival = []
        for j in road:
            if j[0] == i+1:
                if hlis[j[1]-1] <= hlis[i]:
                    table[j[1]-1] = -1
                else:
                    table[i] = -1
                    break
            elif j[1] == i+1:
                if hlis[j[0]-1] <= hlis[i]:
                    table[j[0]-1] = -1
                else:
                    table[i] = -1
                    break
        table[i] = 1
        ans += 1
        
print(ans)

import numpy as np
n, m = map(int, input().split())
hlis = list(map(int, input().split()))
road = []
for i in range(m):
    a, b = map(int, input().split())
    road.append([a, b])
table = [0]*n
ans = 0
for i in range(n):
    print(type(i))
    if table[i] == 0:
        rival = []
        for j in road:
            if j[0] == i:
                rival.append(j[1])
            elif j[1] == i:
                rival.append(j[0])
        if hlis[i] == max([hlis[q-1] for q in rival]+[hlis[i]]):
            table[i] = 1
            ans += 1
            for q in rival:
                table[q-1] = -1 
        else:
            table[i] = -1
print(ans)

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

Verdicts: Wrong Answer

Wrong Answer

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

goodObservatory = [1]*N
H = []
H = input()

for i in range(M):
	A,B = map(int, input().split())
	if H[A-1] > H[B-1]:
		goodObservatory[B-1] = 0
	elif H[A-1] < H[B-1]:
		goodObservatory[A-1] = 0
	elif H[A-1] == H[B-1]:
		goodObservatory[A-1] = 0
		goodObservatory[B-1] = 0

print(sum(goodObservatory))

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

goodObservatory = [1]*N

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

for i in range(M):
	A,B = map(int, input().split())
	if H[A-1] > H[B-1]:
		goodObservatory[B-1] = 0
	elif H[A-1] < H[B-1]:
		goodObservatory[A-1] = 0
	elif H[A-1] == H[B-1]:
		goodObservatory[A-1] = 0
		goodObservatory[B-1] = 0

print(sum(goodObservatory))

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()))
 
edeg = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    edeg[a].append(b)
    edeg[b].append(a)
 
#print(edeg)

ans = 0
for node in range(n):
    good = True
    for neigber in edeg[node]:
        #print("neigber:", neigber)
        if h[node] <= h[neigber]:
            good = False
        if good:
            ans += 1 

print(ans)

n, m = map(int, input().split())
h = list(map(int, input().split()))
 
edeg = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    edeg[a].append(b)
    edeg[b].append(a)
 
#print(edeg)

ans = 0
for node in range(n):
    good = True
    for neigber in edeg[node]:
        print("neigber:", neigber)
        if h[node] <= h[neigber]:
            good = False
        if good:
            ans += 1 

print(ans)

n, m = map(int, input().split())
h = list(map(int, input().split()))
 
edeg = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    edeg[a].append(b)
    edeg[b].append(a)
 
#print(edeg)

ans = 0
for node in range(n):
    good = True
    for neigber in edeg[node]:
        #print("neigber:", neigber)
        if h[node] <= h[neigber]:
            good = False
    if good:
        ans += 1 

print(ans)

Verdicts: Wrong Answer

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()))
arr=[0]+list(map(int,input().split()))
g = [[] for _ in range(n+1)]
print(g)
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
print(g)
ans = 0
for v in range(1, n+1):
     
    for u in g[v]:
        if arr[u]>=arr[v]:
            break
        
        else:
            ans += 1
print(ans)

n, m = map(int, input().split())
h = list(map(int, input().split()))
cnt = [0] * n
chk = [0] * n
ans = 0

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

    if h[a-1] < h[b-1]:
        chk[b-1] += 1
    chk[a-1] += 1
    chk[b-1] += 1
print(cnt)
print(chk)
for i in range(n):
    if cnt[i] == chk[i]:
        ans += 1

print(ans)

n, m = map(int, input().split())
h = list(map(int, input().split()))
cnt = [0] * n
chk = [0] * n
ans = 0

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

    if h[a-1] < h[b-1]:
        cnt[b-1] += 1
    chk[a-1] += 1
    chk[b-1] += 1
print(cnt)
print(chk)
for i in range(n):
    if cnt[i] == chk[i]:
        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 v in range(1,n+1):
 for u in g[v]: 
   if arr[u]>=arr[v]:
     break
 else: 
   ans+=1
print(ans)

Verdicts: Wrong Answer

Wrong Answer

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 = [[] for _ in range(n)]
check = [False for _ in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  ab[a-1].append(b)
  ab[b-1].append(a)

for j in range(n):
  for k in ab[j]:
    if k < h[j]:
      check[j] = True
    elif k > h[j]:
      check[j] = False
	else:
      check[j] = False

print(check.count(True))

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

for j in range(1,n+1):
  for k in ab[j]:
    if h[j] <= h[k]:
      break
    else:  
      count += 1
      
print(count)

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [[] for _ in range(n)]
check = [False for _ in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  ab[a-1].append(b)
  ab[b-1].append(a)

for j in range(n):
  for k in ab[j]:
    if h[j] <= h[k]:
      check[j] = True
      
print(check.count(True))

n,m=map(int,input().split())
h=[0]+list(map(int, input().split()))
roads=[[] for _ in range(n+1)]
cnt=0
for i in range(m):
    a,b=map(int,input().split())
    roads[a].append(b)
    roads[b].append(a)
 
for i in range(1,n+1):
    for j in roads[i]:
        if h[i]<=h[j]:
            break
    else:
         cnt+=1
    
print(cnt

n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
ab = [[] for _ in range(n+1)]
check = [False for _ in range(n+1)]
for i in range(m):
  a, b = map(int, input().split())
  ab[a-1].append(b)
  ab[b-1].append(a)

for j in range(1,n+1):
  for k in ab[j]:
    if h[j] <= h[k]:
      check[k] = True
      
print(check.count(True))

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

for i in range(1,n+1):
    for j in roads[i]:
        if h[i]<=h[j]:
            break
    else:
         cnt+=1
    
print(cnt)

Verdicts: Runtime Error

Wrong Answer

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):
N,M =  map( int ,input().split())
H = list(map( int , input().split()))
A_B = [[0] * 2  for i in range(M)]
J = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B[i][0] = A
    A_B[i][1] = B
for j in range(M):
    if H[A_B[j][0]-1] > H[A_B[j][1]-1]:
        if J[A_B[j][0]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] =-1
    elif H[A_B[j][0]-1] < H[A_B[j][1]-1]:
        if J[A_B[j][1]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] = 1
    else:
        J[A_B[j][0]-1] =-1
        J[A_B[j][1]-1] =-1
for l in range(N):
    if J[l] == 0:
        J[l] = 1
print(J.count(1))

N,M =  map( int ,input().split())
H = list(map( int , input().split()))
A_B = [[0] * 2  for i in range(M)]
J = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B[i][0] = A
    A_B[i][1] = B
for j in range(M):
    if H[A_B[j][0]-1] > H[A_B[j][1]-1]:
        if J[A_B[j][0]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] =-1
    elif H[A_B[j][0]-1] < H[A_B[j][1]-1]:
        if J[A_B[j][0]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] = 1
    else:
        J[A_B[j][0]-1] =-1
        J[A_B[j][1]-1] =-1
for l in range(N):
    if J[l] == 0:
        J[l] = 1
print(J.count(1))

N,M =  map( int ,input().split())
H = list(map( int , input().split()))
A_B = [[0] * 2  for i in range(M)]
J = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B[i][0] = A
    A_B[i][1] = B
for j in range(M):
    if H[A_B[j][0]-1] > H[A_B[j][1]-1]:
        if J[A_B[j][0]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] =-1
    elif H[A_B[j][0]-1] < H[A_B[j][1]-1]:
        J[A_B[j][0]-1] =-1
        if J[A_B[j][1]-1] != -1:
            J[A_B[j][1]-1] = 1
    else:
        J[A_B[j][0]-1] =-1
        J[A_B[j][1]-1] =-1
for l in range(N):
    if J[l] == 0:
        J[l] = 1
print(J.count(1))

Verdicts: Wrong Answer

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 = [tuple(map(int,input().split())) for i in range(m)]
x = ["B"]*n
for t in l:
    if h[t[0]-1] <= h[t[1]-1]:
        x[t[1]-1]="G"
        x[t[0]-1]="B"
    elif h[t[0]-1] >= h[t[1]-1]:
        x[t[1]-1]="B"
        x[t[0]-1]="G"
    print(x)
print(x.count("G"))

n,m = map(int,input().split())
h = tuple(map(int,input().split()))
l = set([tuple(map(int,input().split())) for i in range(m)])
x = [[] for i in range(n)]
ans=0
for t in l:
    x[t[0]-1].append(h[t[1]-1])
    x[t[1]-1].append(h[t[0]-1])
for k,li in enumerate(x):
    a = h[k]
    if li == []:
        ans+=1
    else:
        if a>max(li):
            ans+=1
print(ans)

Verdicts: Runtime Error

Accepted