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

cnt = 0
for i in range(1, n+1):
    if len(g[i]) == 0:
        continue
    for j in g[i]:
        print(i, j)
        print(h[j-1], h[i-1])
        if h[j-1] >= h[i-1]:
            break
    else:
        cnt += 1

print(cnt)

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

cnt = 0
for i in range(1, n+1):
    for j in g[i]:
        if h[j-1] >= h[i-1]:
            break
    else:
        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):
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
print(ans)

import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r-1] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
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()))
l = [list(map(int,input().split())) for i in range(m)]
a,b = [list(i) for i in zip(*l)]
z = [1] * n

for i in range(m):
    x = a[i] - 1
    y = b[i] - 1
    if h[x] < h[y]:
        z[x] = 0
    else:
        z[y] = 0

print(z)
print(n - z.count(0))

n,m = map(int,input().split())
h = list(map(int,input().split()))
l = [list(map(int,input().split())) for i in range(m)]
a,b = [list(i) for i in zip(*l)]
z = [1] * n

for i in range(m):
    x = a[i] - 1
    y = b[i] - 1
    if h[x] < h[y]:
        z[x] = 0
    elif h[x] > h[y]:
        z[y] = 0
    else:
        z[x] = 0
        z[y] = 0

print(n - z.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):
from collections import defaultdict

visited = [False for _ in range(100001)]


def dfs(p: int, n: int, h: list, ways: dict, result: dict):
    if visited[p]:
        return
    
    visited[p] = True
    result[h[p-1]] += 1

    for w in ways[p]:
        dfs(w, n, h, ways, result)


def main():
    tmp = [int(i) for i in input().split()]
    n = tmp[0]
    m = tmp[1]

    ways = defaultdict(set)
    h = [int(i) for i in input().split()]
    for _ in range(m):
        tmp = [int(i) for i in input().split()]
        ways[tmp[0]].add(tmp[1])
        ways[tmp[1]].add(tmp[0])
    
    cnt = 0
    for i in range(1, n+1):
        result = defaultdict(int)
        dfs(i, n, h, ways, result)
        if len(result) > 0:
            h_max = max(list(result.keys()))
            cnt += result[h_max]
    print(cnt)

if __name__ == '__main__':
    main()


from collections import defaultdict

def check(p: int, h: list, ways: dict):
    for w in ways[p]:
        if h[p] <= h[w]:
            return False
    return True


def main():
    tmp = [int(i) for i in input().split()]
    n = tmp[0]
    m = tmp[1]

    ways = defaultdict(set)
    h = [0] + [int(i) for i in input().split()]
    for _ in range(m):
        tmp = [int(i) for i in input().split()]
        ways[tmp[0]].add(tmp[1])
        ways[tmp[1]].add(tmp[0])
    
    cnt = 0
    for i in range(1, n+1):
        if check(i, h, ways):
            cnt += 1
    print(cnt)

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 = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    path = path if path[0] < path[1] else (path[1], path[0])
    if path not in paths:
        paths.append(path)
print(paths)
all_paths = []
for path in paths:
    all_paths += path
all_paths = set(all_paths)
count = 0
for n in range(1, N+1):
    is_good = 1
    if n not in all_paths:
        count += is_good
        continue
    for path in paths:
        if n not in list(path):
            continue
        if (path[0] == n):
            if (H[n-1] <= H[path[1]-1]):
                is_good = 0
                break
        else:
            if (H[n-1] <= H[path[0]-1]):
                is_good = 0
                break    
    count += is_good
print(count)

N, M = [ int(i) for i in input().strip().split(' ') ]
H    = [ int(i) for i in input().strip().split(' ') ]
paths = []
max_neighbor = [ 0 for _ in range(N)]

for _m in range(M):
    path = input().strip().split(' ')
    path = int(path[0]), int(path[1])
    max_neighbor[path[0]-1] = max(max_neighbor[path[0]-1], H[path[1]-1])
    max_neighbor[path[1]-1] = max(max_neighbor[path[1]-1], H[path[0]-1])
count = 0
for n in range(N):
    if max_neighbor[n] < H[n]:
        count += 1
print(count)

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(i) for i in input().split()]
G = [0]*N
L = [1]*N

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

    if H[A-1]>H[B-1]: 
        G[A-1] = 1
        G[B-1] = 0
    elif H[A-1]<H[B-1]: 
        G[B-1] = 1
        G[A-1] = 0
    elif H[A-1]==H[B-1]:
        G[B-1] = 0
        G[A-1] = 0

print(L)
print(G)
print(G.count(1)+L.count(1))


n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  if h[a]>h[b]:ans[b]=0
  elif h[a]<h[b]:ans[a]=0
  elif h[a]==h[b]:ans[a]=ans[b]=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):
N, M = (int(x) for x in input().split())
H = [int(x) for x in input().split()]

high = set()
low = set()
lonely = set()

for i in range(M):
    i1, i2 = [int(x) for x in input().split()]
    if H[i1 - 1] != H[i2 - 1]:
        high.add(i2)
    low.add(i1)
    lonely.add(i1)
    lonely.add(i2)

result = len((high - low)) + (N  - len(lonely))

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

high = set()
low = set()
lonely = set()

for i in range(M):
	i1, i2 = [int(x) for x in input().split()]
	if H[i1 - 1] > H[i2 - 1]:
		high.add(i1)
		low.add(i2)
	elif H[i1 - 1] < H[i2 - 1]:
		high.add(i2)
		low.add(i1)
	else:
		low.add(i1)
		low.add(i2)
	lonely.add(i1)
	lonely.add(i2)

result = len((high - low)) + (N  - len(lonely))
print(result)

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())
tree = list(map(int,input().split())) 
tree_sub = tree 
for i in range(M):
    a,b = map(int,input().split())
    if (tree[a-1] > tree[b-1]) and (int(tree[b-1]) in tree_sub):
        tree_sub[b-1] = 0
    elif (tree[a-1] < tree[b-1]) and (tree[a-1] in tree_sub):
        tree_sub[a-1] = 0
count = 0
for i in range(M):
    if tree_sub[i] != 0:
        count += 1
print(count)

N,M = map(int,input().split())
tree = list(map(int,input().split())) 
tree_sub = tree 
print(len(tree_sub),N)
for i in range(M):
    a,b = map(int,input().split())
    if (tree[a-1] > tree[b-1]):
        tree_sub[b-1] = 0
    elif (tree[a-1] < tree[b-1]):
        tree_sub[a-1] = 0
    else:
        tree_sub[a-1] = 0
        tree_sub[b-1] = 0
print(len(tree_sub)-tree_sub.count(0))

N,M = map(int,input().split())
tree = list(map(int,input().split())) 
tree_sub = tree 
for i in range(M):
    a,b = map(int,input().split())
    if (tree[a-1] > tree[b-1]) and (tree[b-1] in tree_sub):
        tree_sub.remove(b)
    elif (tree[a-1] < tree[b-1]) and (tree[b-1] in tree_sub):
        tree_sub.remove(a)
print(len(tree_sub))

N,M = map(int,input().split())
tree = list(map(int,input().split())) 
tree_sub = tree 
count = 0
for i in range(M):
    a,b = map(int,input().split())
    if (tree[a-1] > tree[b-1]) and (tree[b-1]== tree_sub[b-1]):
        tree_sub[b-1] = 0
    elif (tree[a-1] < tree[b-1]) and (tree[a-1] == tree_sub[a-1]):
        tree_sub[a-1] = 0
for i in range(M):
    if tree_sub[i] !=0:
        count += 1
print(count)

N,M = map(int,input().split())
tree = list(map(int,input().split())) 
tree_sub = list(tree) 
for i in range(M):
    a,b = map(int,input().split())
    if tree[a-1] > tree[b-1]:
        tree_sub[b-1] = 0
    elif tree[a-1] < tree[b-1]:
        tree_sub[a-1] = 0
    else:
        tree_sub[a-1] = 0
        tree_sub[b-1] = 0
print(len(tree_sub)-tree_sub.count(0))

Verdicts: Runtime Error

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):
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))



import copy
n, m = map(int, input().split())
h = list(map(int, input().split()))
ok = [True for i in range(n)]
maxu=copy.copy(h)
for i in range(m):
    p = list(map(int, input().split()))
    if maxu[p[0]-1]<maxu[p[1]-1]:
        ok[p[0]-1]=False
        maxu[p[0]-1] = h[p[1]-1]
    elif maxu[p[0]-1] > maxu[p[1]-1]:
        ok[p[1]-1] = False
        maxu[p[1]-1] = h[p[0]-1]
    elif maxu[p[0]-1] == maxu[p[1]-1]:
        ok[p[1]-1]=False
        ok[p[0]-1]=False
cnt=0
for i in range(len(ok)):
    if ok[i]==True:
        cnt+=1
print(maxu)
print(cnt)



import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))



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

for i in range(m):
    p = list(map(int, input().split()))
    if h[p[0]-1]<h[p[1]-1]:
        ok[p[0]-1]=False
    elif h[p[0]-1] > h[p[1]-1]:
        ok[p[1]-1] = False
    elif h[p[0]-1] == h[p[1]-1]:
        ok[p[1]-1] = False
        ok[p[0]-1] = False
cnt=0
for i in range(len(ok)):
    if ok[i]==True:
        cnt+=1
#print(ok)
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):
#!/usr/bin/env python3
a = 1
x = int(input())
while True:
    bz = (x-a**5)**.2
    if float.is_integer(bz):
        print(a, -int(bz))
        exit()
    a += 1

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

#!/usr/bin/env python3
n, m = map(int, input().split())
*h, = map(int, input().split())
h = [0] + h
i = [0] + [1] * n

for j in range(m):
    a, b = map(int, input().split())
    if h[a] >= h[b]:
        i[b] = 0
    if h[a] <= h[b]:
        i[a] = 0
print(sum(i))

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()))
road_dict = {a+1: set() for a in range(n)}
for i in range(m):
  a, b = map(int, input().split())
  if a in road_dict:
    road_dict[a].add(b)
  else:
    road_dict[a] = set([b])
  if b in road_dict:
    road_dict[b].add(a)
  else:
    road_dict[b] = set([a])
use_list = []
for k, s in road_dict.items():
  s.add(k)
  tmp_use_list = []
  append_flg = True
  for s2 in use_list:
    if s2.isdisjoint(s):
      tmp_use_list.append(s2)
    else:
      tmp_use_list.append(s | s2)
      append_flg = False
  if append_flg:
    tmp_use_list.append(s)
  use_list = tmp_use_list.copy()
res = 0
for s in use_list:
  m = 0
  use_s = list(s)
  d_flg = False
  for v in use_s:
    height = h_list[v-1]
    if height > m:
      m = height
      d_flg = False
    elif height == m:
      d_flg = True
    else:
      continue
  if ~d_flg:
    res += 1
print(res)
      
  
  

n, m = map(int, input().split())
h_list = list(map(int, input().split()))
road_dict = {a+1: set() for a in range(n)}
for i in range(m):
  a, b = map(int, input().split())
  if a in road_dict:
    road_dict[a].add(b)
  else:
    road_dict[a] = set([b])
  if b in road_dict:
    road_dict[b].add(a)
  else:
    road_dict[b] = set([a])
use_list = []
res = 0
for k, s in road_dict.items():
  k_height = h_list[k-1]
  if len(s) == 0:
    res += 1
  else:
    add_flg = True
    for v in list(s):
      v_height = h_list[v-1]
      if k_height > v_height:
        continue
      else:
        add_flg = False
        break
    if add_flg:
      res += 1
print(res)


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):
X=int(input())

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

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



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

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


N,M = map(int,input().split())
H = list(map(int,input().split()))
adj=[set() for _ in range(N)]
for _ in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    adj[a].add(b)
    adj[b].add(a)


ans=0
for i in range(N):
    if len(adj[i])==0:
        ans+=1
    elif all([H[i]>H[v] for v in adj[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_tree = map(int, input().split())
GOOD_Tree = [1 for n in range(len(H_tree))]

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

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

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()))
lst = [0] * n
for j in range(m):
  a,b=map(int,input().split())
  if height[a-1]<height[b-1]:
    if lst[a-1] == -1:
      lst[b-1]+=1
    else:
      lst[a-1]=-1
      lst[b-1]+=1
  elif height[a-1]>height[b-1]:
    if lst[b-1] == -1:
      lst[a-1]+=1
    else:
      lst[a-1]+=1
      lst[b-1]=-1
  elif height[a-1]==height[b-1]:
    lst[a-1] = -1
    lst[b-1] = -1
cnt = 0
print(lst)
for k in range(n):
  if lst[k]>=0:
    cnt+=1
print(cnt)

n,m=map(int,input().split())
height = list(map(int,input().split()))
lst = [0] * n
for j in range(m):
  a,b=map(int,input().split())
  if height[a-1]<height[b-1]:
    lst[a-1]=-1
    lst[b-1]+=1
  elif height[a-1]>height[b-1]:
    lst[a-1]+=1
    lst[b-1]=-1
  elif height[a-1]==height[b-1]:
    lst[a-1] = -1
    lst[b-1] = -1
cnt = 0
print(lst)
for k in range(n):
  if lst[k]>=0:
    cnt+=1
print(cnt)

n,m=map(int,input().split())
height = list(map(int,input().split()))
lst = [0] * n
for j in range(m):
  a,b=map(int,input().split())
  if height[a-1]<height[b-1]:
    if lst[b-1] == -1:
      lst[a-1]=-1
    else:
      lst[a-1]=-1
      lst[b-1]+=1
  elif height[a-1]>height[b-1]:
    if lst[a-1]==-1:
      lst[b-1]=-1
    else:
      lst[a-1]+=1
      lst[b-1]=-1
  elif height[a-1]==height[b-1]:
    lst[a-1] = -1
    lst[b-1] = -1
cnt = 0
for k in range(n):
  if lst[k]>=0:
    cnt+=1
print(cnt)

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()))
H_list = list(map(int, input().split()))
road_list = []

for _ in range(M):
    road_list.append([])
for i in range(M):
    a, b = list(map(int, input().split()))
    H_a, H_b = [H_list[a - 1], H_list[b - 1]]
    if H_a <= H_b:
        road_list[a - 1].append(a)
    elif H_b <= H_a:
        road_list[b - 1].append(b)

ans = 0
for road in road_list:
    if len(road) == 0:
        ans += 1
print(ans)

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

road_list = []
for _ in range(N):
    road_list.append([])
    
for i in range(M):
    a, b = list(map(int, input().split()))
    
    H_a, H_b = [H_list[a - 1], H_list[b - 1]]
    
    if H_a <= H_b:
        road_list[a - 1].append(b)

    if H_b <= H_a:
        road_list[b - 1].append(a)

ans = 0
for road in road_list:
    if len(road) == 0:
        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()))
a,ans=[],[]
for _ in range(M):
    a.append(list(map(int,input().split())))
for i in range(M):
    if H[(a[i][0])-1]>H[(a[i][1])-1]:
        ans.append(a[i][0])
    elif H[(a[i][0])-1]<H[(a[i][1])-1]:
        ans.append(a[i][1])
print(len(ans))

N,M=map(int,input().split())
H=list(map(int,input().split()))
a,ans=[],set()
for _ in range(M):
    a.append(list(map(int,input().split())))
for i in range(M):
    if H[(a[i][0])-1]>H[(a[i][1])-1]:
        ans.add(a[i][0])
        if len(ans)!=0:
            for k in range(len(ans)):
                if list(ans)[k]==a[i][1]:
                    ans.remove(list(ans)[k])
                    break
    elif H[(a[i][0])-1]<H[(a[i][1])-1]:
        ans.add(a[i][1])
        if len(ans)!=0:    
            for j in range(len(ans)):
                if list(ans)[j]==a[i][0]:
                    ans.remove(list(ans)[j])
                    break
n=set()
for k in range(M):
    for l in range(2):
        n.add(a[k][l])
print(len(ans)+M-len(n))

N,M=map(int,input().split())
H=list(map(int,input().split()))
a,ans=[],[]
for _ in range(M):
    a.append(list(map(int,input().split())))
for i in range(M):
    if H[(a[i][0])-1]>H[(a[i][1])-1]:
        ans.add(a[i][0])
    elif H[(a[i][0])-1]<H[(a[i][1])-1]:
        ans.append(a[i][1])
print(len(ans))

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

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

check = [True] * n 
for i in range(m):
    print(i)
    a,b = (map(int,input().split()))
    if h[a-1] > h[b-1]:
        check[b-1] = False
    elif h[a-1] < h[b-1]:
       # print("i,check",i,check)
        check[a-1] = False
    else:
        check[a-1] = False
        check[b-1] = False
print(sum(check))




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

check = [True] * n 
for i in range(m):
    #print(i)
    a,b = (map(int,input().split()))
    if h[a-1] > h[b-1]:
        check[b-1] = False
    elif h[a-1] < h[b-1]:
       # print("i,check",i,check)
        check[a-1] = False
    else:
        check[a-1] = False
        check[b-1] = False
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):
N, M = map(int, input().split())
H = list(map(int, input().split()))
road = [list(map(int, input().split())) for i in range(M)]
DP = [0 for i in range(N+1)]
DP[0] = -1
kouho = []

for i in range(M):
  Ai = road[i][0]
  Bi = road[i][1]
  if H[Ai - 1] > H[Bi - 1]:
    if DP[Ai] != -1:
      DP[Ai] = 1
    DP[Bi] = -1
  elif H[Ai - 1] == H[Bi - 1]:
    if DP[Ai] != -1 and DP[Bi] != -1:
      DP[Ai] = 1
      DP[Bi] = 1
    else:
      DP[Ai] = -1
      DP[Bi] = -1
  else:
    if DP[Bi] != -1:
      DP[Bi] = 1
    DP[Ai] = -1 

ans = 0
for i in DP:
  if i != -1:
    ans += 1

print(ans)
print(DP)

N, M = map(int, input().split())
H = list(map(int, input().split()))
road = [list(map(int, input().split())) for i in range(M)]
DP = [0 for i in range(N+1)]
DP[0] = -1
kouho = []

for i in range(M):
  Ai = road[i][0]
  Bi = road[i][1]
  if H[Ai - 1] > H[Bi - 1]:
    if DP[Ai] != -1:
      DP[Ai] = 1
    DP[Bi] = -1
  elif H[Ai - 1] == H[Bi - 1]:
    DP[Ai] = -1
    DP[Bi] = -1
  else:
    if DP[Bi] != -1:
      DP[Bi] = 1
    DP[Ai] = -1 

ans = 0
for i in DP:
  if i != -1:
    ans += 1

print(ans)
#print(DP)

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()))
ans = [1] * n
for i in range(m):
  a,b, = map(int,input().split())
  if h[a-1] >= h[b-1]:
    ans[b-1] =0
  if h[a-1] <= h[b-1]:
    ans[a-1] = 0
  print(ans)
print(sum(ans))

n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1] * n
for i in range(m):
  a,b, = map(int,input().split())
  if h[a-1] >= h[b-1]:
    ans[b-1] =0
  if h[a-1] <= h[b-1]:
    ans[a-1] = 0
print(sum(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()))
li = []
for m in range(M):
  a, b = map(int, input().split())
  if h[a-1] < h[b-1]:
    li.append(a)
  if h[a-1] == h[b-1]:
    li.append(a)
    li.append(b)
  else:
    li.append(b)

answer = N - len(set(li))
print(answer)

N, M = map(int, input().split())
h = list(map(int, input().split()))
li = []
for m in range(M):
  a, b = map(int, input().split())
  if h[a-1] < h[b-1]:
    li.append(a)
  elif h[a-1] == h[b-1]:
    li.append(a)
    li.append(b)
  else:
    li.append(b)

answer = N - len(set(li))
print(answer)

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 = (int(x) for x in input().split())
obs_height = [int(x) for x in input().split()]
good_obs_num = 0
check_list = []

for i in range(M):
  a,b = (int(x) for x in input().split())
  if(a < b):
      good_obs_num += 1
    
print(good_obs_num)

def is_good_obs(num,obs_height,linked_num):
  for e in linked_num[num-1]: 
    if(obs_height[i-1] <= obs_height[e]):
      return False
  return True
      

N,M = (int(x) for x in input().split())
obs_height = [int(x) for x in input().split()]
linked_num = [[] for i in range(N)]
good_obs_num = 0

for i in range(M):
  a,b = (int(x) for x in input().split())
  linked_num[a-1].append(b-1)
  linked_num[b-1].append(a-1)
  
for i in range(N):
    if(is_good_obs(i,obs_height,linked_num)):
      good_obs_num += 1
  
print(good_obs_num)

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()))
root = [list(map(int, input().split())) for _ in range(M)]

is_min = [0 for _ in range(N)]
for i in range(M):
    A = root[i][0] - 1
    B = root[i][1] - 1

    if H[A] > H[B]]:
        is_min[B] = 1

    elif H[A] == H[B]]:
        is_min[A] = 1
        is_min[B] = 1

    else:
        is_min[A] = 1

print(N - sum(is_min))


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

is_min = [0 for _ in range(N)]
for i in range(M):
    A = root[i][0] - 1
    B = root[i][1] - 1

    if H[A] > H[B]:
        is_min[B] = 1

    elif H[A] == H[B]:
        is_min[A] = 1
        is_min[B] = 1

    else:
        is_min[A] = 1

print(N - sum(is_min))

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

    temp = [True for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())

        if HN[A - 1] < HN[B - 1]:
            temp[A - 1] = False
        if HN[B - 1] < HN[A - 1]:
            temp[B - 1] = False
        else:
            temp[A - 1] = False
            temp[B - 1] = False

    print(sum([1 for a in temp if a]))


main()


def main():
    N, M = map(int, input().split())
    HN = list(map(int, input().split()))

    temp = [True for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())

        if HN[A - 1] < HN[B - 1]:
            temp[A - 1] = False
        elif HN[B - 1] < HN[A - 1]:
            temp[B - 1] = False
        else:
            temp[A - 1] = False
            temp[B - 1] = False

    print(sum([1 for a in temp if a]))


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()))
alllist = []
notwinner = []
for i in range(M):
    ab = list(map(int,input().split()))
    if H[ab[0]-1] > H[ab[1]-1]:
        notwinner.append(ab[1])
    elif H[ab[0]-1] < H[ab[1]-1]:
        notwinner.append(ab[0])
    else:
        notwinner.append(ab[0])
        notwinner.append(ab[1])
wtou = N - len(notwinner)
print(wtou)


N,M = map(int,input().split())
H = list(map(int,input().split()))
notwinner = []
for i in range(M):
    ab = list(map(int,input().split()))
    if H[ab[0]-1] > H[ab[1]-1]:
        notwinner.append(ab[1])
    elif H[ab[0]-1] < H[ab[1]-1]:
        notwinner.append(ab[0])
    else:
        notwinner.append(ab[0])
        notwinner.append(ab[1])
wtou = N - len(set(notwinner))
print(wtou)


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

ans = []
for i in range(M):
    A, B = map(int, input().split())
    ans = [max(H[A-1], H[B-1]) if i == H[A-1] else i for i in ans]
    ans = [max(H[A-1], H[B-1]) if i == H[B-1] else i for i in ans]
    ans.append(max(H[A-1], H[B-1])) 
print(set(ans))


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

sm = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1] :
      sm.append(A)
    if H[B-1] <= H[A-1] :
      sm.append(B)
print(N - len(set(sm)))

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):
from collections import deque
n,m = map(int,input().split())
h=list(map(int,input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
ans=0
for j in range(n):
    for i in g[j]:
        if h[j]<=h[i]:
            break
    else:
        print(j)
        ans+=1
print(ans)

from collections import deque
n,m = map(int,input().split())
h=list(map(int,input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
ans=0
for j in range(n):
    for i in g[j]:
        if h[j]<=h[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()))
t=[0]*N
for i in range(M):
    A,B=map(int,input().split())
    t[A-1] = max(t[A-1], H[B-1])
    t[B-1] = max(t[B-1], H[A-1])

ct=0
for j in range(N):
    if H[j]>[j]:
        ct+=1
print(ct)


N,M=map(int,input().split())
h=list(map(int,input().split()))
t=[0]*N
for i in range(M):
    A,B=map(int,input().split())
    t[A-1] = max(t[A-1], h[B-1])
    t[B-1] = max(t[B-1], h[A-1])

ct=0
for j in range(N):
    if h[j]>t[j]:
        ct+=1
print(ct)


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):
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

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

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

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


mport numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

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

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

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

import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

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

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

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

import numpy as np
N,M=map(int,input().split())
S=np.ones(N)
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1]=0

  elif H[a-1]>H[b-1]:
    S[b-1]=0

  else:
    S[a-1]=0
    S[b-1]=0

print(int(np.sum(S)))

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):
n,m=list(map(int,input().split()))
h=list(map(int,input().split()))
sum=0 
dp=[float("INF") for i in range(n)]
for i in range(m):
    a,b=list(map(int,input().split()))
    if h[a-1]<h[b-1] and dp[b-1]==float("INF"):
      sum=sum+1
      dp[a-1]=0
    elif h[b-1]<h[a-1] and dp[a-1]==float("INF"):
      sum=sum+1
      dp[b-1]=0

print(n-sum)

n,m=list(map(int,input().split()))
h=list(map(int,input().split()))
dp=[float("INF") for i in range(n)]
for i in range(m):
  a,b=list(map(int,input().split()))
  if h[a-1]<h[b-1]:
    dp[a-1]=0
  elif h[b-1]<h[a-1]:
    dp[b-1]=0
  else:
    dp[a-1]=0
    dp[b-1]=0
sum=0
for i in range(n):
  if dp[i]==float("INF"):
    sum=sum+1
print(sum)
  
  

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


N,M=map(int,input().split())
high=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)


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

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())
List=list(map(int,input().split()))
s=[]

for i in range(m):
    a,b=list(map(int,input().split()))
    if List[a-1]>List[b-1]:
        s.append(b)
    elif List[a-1]<List[b-1]:
        s.append(a)
    else:
        s.append(a)
        s.append(b)
    

print(s)
t=set(s)       
print(n-len(t))


n,m=map(int,input().split())
List=list(map(int,input().split()))
s=[]

for i in range(m):
    a,b=list(map(int,input().split()))
    if List[a-1]>List[b-1]:
        s.append(b)
    elif List[a-1]<List[b-1]:
        s.append(a)
    else:
        s.append(a)
        s.append(b)
    
t=set(s)       
print(n-len(t))

Verdicts: Wrong Answer

Accepted