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):
def main():
    n, m = map(int, input().split())
    wxyz = [list(map(int, input().split())) for _ in [0]*m]

    class unionfind():
        
        def __init__(self, size):  
            self.size = size
            self.tree_root = list(range(self.size))
            self.tree_depth = [1]*self.size

        
        def root(self, index):
            temp_list = []
            temp = self.tree_root[index]
            while index != temp:
                temp_list.append(index)
                index = temp
                temp = self.tree_root[index]
            for i in temp_list:
                self.tree_root[i] = index
            return index

        
        def unite(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            if r1 != r2:
                d1, d2 = self.tree_depth[r1], self.tree_depth[r2]
                if d1 <= d2:
                    self.tree_root[r1] = r2
                    self.tree_depth[r2] = max(d1+1, d2)
                else:
                    self.tree_root[r2] = r1
                    self.tree_depth[r1] = max(d2+1, d1)

        
        def same(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            return r1 == r2

        
        def component(self):
            return len({self.root(i) for i in range(self.size)})

    u = unionfind(2*n)

    for w, x, y, z in wxyz:
        x -= 1
        y -= 1
        if w == 1:
            if z % 2 == 0:
                u.unite(x, y)
                u.unite(x+n, y+n)
            else:
                u.unite(x, y+n)
                u.unite(x+n, y)
        else:
            print(["NO", "YES"][u.same(x, y) or u.same(x+n, y+n)])


main()


def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

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


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())
h_list = list(map(int, input().split()))
data = []
for _ in range(m):
    data.append( list(map(int, input().split())) )

ans_list = [1 for _ in range(n)]

for d in data:
    
    d_0 = d[0] - 1
    d_1 = d[1] - 1

    if h_list[d_0] == h_list[d_1]:
        ans_list[d_0] = 0
        ans_list[d_1] = 0

    if h_list[d_0] > h_list[d_1]:
        ans_list[d_1] = 0

    if h_list[d_1] > h_list[d_0]:
        ans_list[d_0] = 0

print(*ans_list)
print(ans_list.count(1))



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

ans_list = [1 for _ in range(n)]

for d in data:
    
    d_0 = d[0] - 1
    d_1 = d[1] - 1

    if h_list[d_0] == h_list[d_1]:
        ans_list[d_0] = 0
        ans_list[d_1] = 0

    if h_list[d_0] > h_list[d_1]:
        ans_list[d_1] = 0

    if h_list[d_1] > h_list[d_0]:
        ans_list[d_0] = 0

# print(*ans_list)
print(ans_list.count(1))


Verdicts: Wrong Answer

Accepted
Problem: There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.  Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.  How many good observatories are there?

Submission attempts (in order):
N, M = map(int, input().split(" "))
flag = [1 for i in range(M)]
height = list(map(int, input().split(" ")))
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] < height[b - 1]:
    flag[a - 1] = 0
  elif height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  else:
    flag[a - 1] = 0
    flag[b - 1] = 0
print(sum(flag))

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

N, M = map(int, input().split(" "))
height = map(int, input().split(" "))
flag = [1 for i in renge(len(height))]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
print(sum(flag))

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.  Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.  How many good observatories are there?

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

def main():
    N, M = map(int, input().split())
    V = [True] * N
    H = [int(v) for v in input().split()]
    AB = [[map(int, input().split())] for _ in range(M)]
    for ab in AB:
        a, b = ab
        a-=1
        b-=1
        # if V[a] or V[b]:
        if H[a] < H[b]:
            V[a] = False
        else:
            V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    V = [True] * N
    H = [int(v) for v in input().split()]
    AB = [[int(v) - 1 for v in input().split()] for _ in range(M)]
    for a, b in AB:
        if V[a] or V[b]:
            if H[a] <= H[b]:
                V[a] = False
            if H[a] >= H[b]:
                V[b] = False
    
    print(V.count(True))

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())
H = list(map(int,input().split()))
michi = [[] for i in range(N)]
 
for i in range(M):
    a,b = map(int,input().split())
    michi[a-1].append(b-1)
    michi[b-1].append(a-1)

 
ans = 0
for i in range(N): 
    if michi[i] == []:
        print(i)
        ans +=1
    else:
        for j in michi[i]:
        # print(i,j,H[i],H[j]) 
        
            if H[i] <= H[j]:
            
                break
            if j == michi[i][-1]:
                ans += 1
                print(i)
 
print(ans)

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

 
ans = 0
for i in range(N): 
    if michi[i] == []:
        ans +=1
    else:
        counter = 0
        
        for j in michi[i]:
            counter += 1
            
        # print(i,j,H[i],H[j]) 
        
            if H[i] <= H[j]:
            
                break
            if counter == len(michi[i]):
                
                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):
import math

x = int(input())

end = math.floor(x**0.2)

for i in range(1, x+1):
    if x % i == 0:
        for a in range(i//2,end,1):
            b = a - i
            if a**5 - b**5 == x:
                print(a, b)
                break

n, m = map(int, input().split())
 
h_list = list(map(int,input().split()))
 
way_list = []
for i in range(m):
    org = list(map(int, input().split()))
    org.sort()
    way_list.append(org)
 
bad = []
 
for j in range(m):
    way = way_list[j]
    if h_list[way[0]-1] > h_list[way[1]-1]:
        bad.append(way[1])
    elif h_list[way[0]-1] < h_list[way[1]-1]:
        bad.append(way[0])
    else:
        bad.append(way[0])
        bad.append(way[1])
 
bad = list(set(bad))
print(n - len(bad))

Verdicts: Runtime Error

Accepted
Problem: There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.  Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road. Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.  How many good observatories are there?

Submission attempts (in order):
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj_max = [0]*N
ans = 0
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  adj_max[tmp1] = max(adj_max[tmp1], H[tmp2])
  adj_max[tmp2] = max(adj_max[tmp2], H[tmp1])
for num in range(N):
  if H[num] > adj_max[num]:
    ans += 1
print(ans)

N, M = map(int, input().split())
H = list(map(int, input().split()))
adj_max = [0]*N
ans = 0
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  adj_max[tmp1-1] = max(adj_max[tmp1-1], H[tmp2-1])
  adj_max[tmp2-1] = max(adj_max[tmp2-1], H[tmp1-1])
for num in range(N):
  if H[num] > adj_max[num]:
    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())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = map(int, input().split())
  if heights[A] > heights[B]:
    good[B] = False
  elif heights[A] < heights[B]:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)


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

good = [True] * N
for m in range(0, M):
  A, B = map(int, input.split())
  if A > B:
    good[B] = False
  elif A < B:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count++
    
print(count)

N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
good = [True] * N
for m in range(0, M):
  A, B = [int(s)-1 for s in input.split()]
  if heights[A] >= heights[B]:
    good[B] = False
  elif heights[A] <= heights[B]:
    good[A] = False
    
count = 0
for obs in good:
  if obs: count += 1
    
print(count)

N, M = map(int, input().split())
heights = list(map(int, input().split()))
 
greatest = [0] * N
for m in range(0, M):
  A, B = [int(s)-1 for s in input().split()]
  greatest[A] = max(greatest[A], heights[B])
  greatest[B] = max(greatest[B], heights[A])
    
count = 0
for i in range(0, N):
    count += heights[i] > greatest[i]
    
print(count)


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

neighbor_max_heights = [0] * N

for i in range(M):
    a, b = AB[i]
    neighbor_max_heights[b-1] = max(neighbor_max_heights[b-1], H[a-1])
    neighbor_max_heights[a-1] = max(neighbor_max_heights[a-1], H[b-1])

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

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

neighbor_max_heights = [0] * N

for i in range(M):
    a, b = AB[i]
    neighbor_max_heights[b-1] = max(neighbor_max_heights[b-1], H[a-1])
    neighbor_max_heights[a-1] = max(neighbor_max_heights[a-1], H[b-1])

ans = 0
for j in range(N):
    if H[j-1] > neighbor_max_heights[j-1]:
        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):
a = input().split(" ")
h = input().split(" ")
c = {}
for j in range(int(a[0])):
    c[str(j+1)] = [int(h[j]),"good"]
b = []
good = int(a[0])
for i in range(int(a[1])):
    d = input().split()
    x = int(c[d[0]][0])
    y = int(c[d[1]][0])
    if x > y:
        c[d[1]][1] = "bad"
    if y > x:
        c[d[0]][1] = "bad"
    if y == x:
        c[d[1]][1] = "bad"
        c[d[0]][1] = "bad"
kotae = 0
for k in range(int(a[0])):
    if c[str(k+1)][1] == "good":
        kotae += 1
print(c)
print(kotae)

a = input().split(" ")
h = input().split(" ")
c = {}
for j in range(int(a[0])):
    c[str(j+1)] = [int(h[j]),"good"]
b = []
good = int(a[0])
for i in range(int(a[1])):
    d = input().split()
    x = int(c[d[0]][0])
    y = int(c[d[1]][0])
    if x > y:
        c[d[1]][1] = "bad"
    if y > x:
        c[d[0]][1] = "bad"
    if y == x:
        c[d[1]][1] = "bad"
        c[d[0]][1] = "bad"
kotae = 0
for k in range(int(a[0])):
    if c[str(k+1)][1] == "good":
        kotae += 1
print(kotae)

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

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

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


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

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

print(len(h)-len(set(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):
N, K    = map(int, input().split())
height  = list(map(int, input().split()))
road    = {}


for i in range(K):
    a, b = list(map(int, input().split()))
    try:
        road[a-1].append(b-1)
    except:
        road[a-1] = [b-1]
    try:
        road[b-1].append(a-1)
    except:
        road[b-1] = [a-1]

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

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


for i in range(K):
    a, b = list(map(int, input().split()))
    try:
        road[a-1].append(b-1)
    except:
        road[a-1] = [b-1]
    try:
        road[b-1].append(a-1)
    except:
        road[b-1] = [a-1]

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

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

m_l = [[0,0]]*m
r_l = [{}]*n
for i in range(m):
  r = list(map(int, input().split()))
  a = r[0] - 1
  b = r[1] - 1

  ral = set([]) if len(r_l[a]) == 0 else r_l[a]
  rbl = set([]) if len(r_l[b]) == 0 else r_l[b]

  ral.add(b)
  rbl.add(a)

  r_l[a] = ral
  r_l[b] = rbl
print(r_l)

cnt = 0
for ni in range(n):
  for r in r_l[ni]:
    if h_a[r] >= h_a[ni]:
      break
  else:
    cnt+=1

print(cnt)

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

m_l = [[0,0]]*m
r_l = [{}]*n
for i in range(m):
  r = list(map(int, input().split()))
  a = r[0] - 1
  b = r[1] - 1

  ral = set([]) if len(r_l[a]) == 0 else r_l[a]
  rbl = set([]) if len(r_l[b]) == 0 else r_l[b]

  ral.add(b)
  rbl.add(a)

  r_l[a] = ral
  r_l[b] = rbl

cnt = 0
for ni in range(n):
  for r in r_l[ni]:
    if h_a[r] >= h_a[ni]:
      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):
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    LIST = [ 1 for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A-1] >= H[B-1]: LIST[B-1] = 0
        if H[A-1] <= H[B-1]: LIST[A-1] = 0
    print(sum(LIST))


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

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

ans = []

for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] < h[b-1]:
        ans.append(a)
    elif h[b-1] < h[a-1]:
        ans.append(b)
    elif h[a-1] == h[b-1]:
        ans.append(a)
        ans.append(b)
x = set(ans)

print(n-len(x))


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):
class UnionFind:
    def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
        self.maxh = [0] * (n)
    def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx,sy = self.size[x],self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
            self.maxh[y] = max(h[x], h[y])
        else:
            self.root[y] = x
            self.size[x] += sy
            self.maxh[y] = max(h[x], h[y])

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

uf = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    uf.merge(a-1, b-1)

#print(h)


maxh = [0] * n
for i in range(n):
    maxh[uf.find_root(i)] = max(maxh[uf.find_root(i)], h[i])
    
#print(maxh)
ans = 0
for i in range(n):
    if maxh[uf.find_root(i)] == h[i]:
        ans += 1

print(ans)

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())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
#print(G)
ans = 0
for i in range(n):
    maxh = 0
    for gi in G[i]:
        maxh = max(h[gi], maxh)
    if maxh < h[i]:
        ans += 1
    #print(maxh, h[i])

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

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

T_Height = [int(h) for h in input().split()]

Roads = [[0] * n for _ in range(n)]

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


i = 0
ans = 0
for E in Roads:
    print(max(E), T_Height[i])
    if T_Height[i] > max(E):
        ans += 1
    i+=1

print(ans)


import sys
input = sys.stdin.readline
import numpy as np

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

T_Height = [int(h) for h in input().split()]

Roads = [0] * n

for i in range(m):
    a, b = map(int, input().split())
    b_h = T_Height[b-1]
    a_h = T_Height[a-1]
    if b_h > Roads[a-1]:
        Roads[a-1] = b_h
    if a_h > Roads[b-1]:
        Roads[b-1] = a_h


i = 0
ans = 0
for e in Roads:
    if T_Height[i] > e:
        ans += 1
    i+=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):
import copy

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

AB = [[]] * N

for i in range(M):
    A, B = list(map(int, input().split()))
    tmp = copy.deepcopy(AB[A-1])
    tmp.append(B-1)
    AB[A-1] = tmp
    tmp = copy.deepcopy(AB[B-1])
    tmp.append(A-1)
    AB[B-1] = tmp

print(AB)
cnt = 0
for j in range(len(AB)):
    for val in set(AB[j]):
        if H[j] <= H[val]:
            break
    else:
        cnt += 1

print(cnt)


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

result = [1] * N

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

print(sum(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())
h = list(map(int,input().split()))
a = [list(map(int,input().split())) for j in range(m)]
# print("h:",h)
# print("a",a)
can_go = [[] for i in range(n)]
# print(can_go)
for i in a:
    # print(i)
    can_go[i[0]-1].append(i[1])
    can_go[i[1]-1].append(i[0])
# print(can_go)
b = 0
ans=0
for i,j in enumerate(can_go):
    # for j in can_go:
    b= 0

    for k in j:
        print( h[k-1]-h[i])
        if h[k-1]>=h[i]:
            b=1
            # print("break")
            break
    if b==1:
        b=0
    else:
        ans+=1
print(ans)
    



n,m=map(int,input().split())
h = list(map(int,input().split()))
a = [list(map(int,input().split())) for j in range(m)]
# print("h:",h)
# print("a",a)
can_go = [[] for i in range(n)]
# print(can_go)
for i in a:
    # print(i)
    can_go[i[0]-1].append(i[1])
    can_go[i[1]-1].append(i[0])
# print(can_go)
b = 0
ans=0
for i,j in enumerate(can_go):
    # for j in can_go:
    b= 0

    for k in j:
        # print( h[k-1]-h[i])
        if h[k-1]>=h[i]:
            b=1
            # print("break")
            break
    if b==1:
        b=0
    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())
peaks = list(map(int, input().split()))
ng_peaks = set([])
for j in range(M):
    A_j, B_j = map(int, input().split())
    if peaks[A_j-1] >= peaks[B_j-1]:
        ng_peaks.add(B_j)
    if peaks[A_j-1] =< peaks[B_j-1]:
        ng_peaks.add(A_j)
print(N-len(ng_peaks))

N, M = map(int, input().split())
peaks = list(map(int, input().split()))
ng_peaks = set([])
for j in range(M):
    A_j, B_j = map(int, input().split())
    if peaks[A_j-1] >= peaks[B_j-1]:
        ng_peaks.add(B_j)
    if peaks[A_j-1] <= peaks[B_j-1]:
        ng_peaks.add(A_j)
print(N-len(ng_peaks))

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):
h=list(map(int,input().split()))
x=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  x[a].append(h[b-1])
  x[b].append(h[a-1])
count=0
for j in range(1,n+1):
  if x[j]==[]:
    count+=1
  else:
    if h[j-1]>max(x[j]):
      count+=1
print(count)
  

n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  x[a].append(h[b-1])
  x[b].append(h[a-1])
count=0
for j in range(1,n+1):
  if x[j]==[]:
    count+=1
  else:
    if h[j-1]>max(x[j]):
      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()))

g = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
print(g)

cnt = n
for i in range(n):
  for j in g[i]:
    if h[i] <= h[j]:
      cnt -= 1
      break
print(cnt)

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())
  g[a-1].append(b-1)
  g[b-1].append(a-1)

cnt = n
for i in range(n):
  for j in g[i]:
    if h[i] <= h[j]:
      cnt -= 1
      break
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):
4 3
1 2 3 4
1 3
2 3
2 4

N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*M;B=[0]*M
C=[0]*N
for i in range(M):
  A[i],B[i]=map(int,input().split())

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

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

bad_count = [1] * N
for i, cond in enumerate(conditions):
    for j in cond:
        if H[i] <= H[j]:  # bimyou
            bad_count[i] = 0
            print(f'{i} is bad')

print(N - sum(bad_count))

N, M = map(int, input().split())
H = list(map(int, input().split()))
conditions = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    
    
    conditions[a - 1].append(b - 1)
    conditions[b - 1].append(a - 1)

bad_count = [1] * N
for i, cond in enumerate(conditions):
    for j in cond:
        if H[i] < H[j]:  # bimyou
            bad_count[i] = 0
            print(f'{i} is bad')

print(N - sum(bad_count))

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

print(sum(record))

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


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

    A = np.zeros((N, N))
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp][ss] = H[ss]
        A[ss][pp] = H[pp]

    ans = 0


resolve()


import numpy as np


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

    A = np.zeros((N, N), dtype=int)
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp][ss] = H[ss]
        A[ss][pp] = H[pp]

    ans = 0
    for j in range(N):
        if (A[j].max() == 0 or H[j] > A[j].max()):
            ans += 1

    print(A)


resolve()

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

    A = [[] for _ in range(N)]
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp].append(H[ss])
        A[ss].append(H[pp])

    ans = 0
    for j in range(N):
        now = H[j]
        if not A[j] or now > max(A[j]):
            ans += 1

    print(ans)


resolve()

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())
ans_list = list(range(1,N))
HList = list(map(int, input().split()))
rootList = []

for i in range(M):
  a, b = map(int, input().split())
  H_a = HList[a-1]
  H_b = HList[b-1]
  if(a in ans_list):
    if(H_b > H_a or H_b == H_a):
      ans_list.remove(a)
  if(b in ans_list):
    if(H_a > H_b or H_b == H_a):
      ans_list.remove(b)

print(len(ans_list))


N, M = map(int, input().split())
keyList = list(range(1,N+1))
values = [True] * N
dic = dict(zip(keyList, values))
HList = list(map(int, input().split()))
ans = []

for i in range(M):
  a, b = map(int, input().split())
  H_a = HList[a-1]
  H_b = HList[b-1]
  if(H_a == H_b):
    dic[a] = False
    dic[b] = False
  elif(H_b > H_a):
    dic[a] = False
  elif(H_a > H_b):
    dic[b] = False


for i in range(1, len(dic.values())+1):
  if(dic[i] == True):
    ans.append(dic[i])
print(len(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):
def make_heights_list(height):
    return [height, True]


tower_len, roads_len = map(int, input().split(' '))

heights = [[0, False]]
heights += (list(map(make_heights_list, input().split(' '))))

print(heights)


roads_highest = list()
for i in range(roads_len):
    start, end = map(int, input().split(' '))
    print(start, end)
    if heights[start][1] is True and heights[end][0] >= heights[start][0]:
        heights[start][1] = False
        
    if heights[end][1] is True and heights[start][0] >= heights[end][0]:
        heights[end][1] = False
        

good_towers_len = 0
for tower in heights:
    if tower[1]:
        good_towers_len += 1

print(good_towers_len)


def make_heights_list(height):
    return [int(height), True]


tower_len, roads_len = map(int, input().split(' '))

heights = [[0, False]]
heights += (list(map(make_heights_list, input().split(' '))))

#print(heights)


roads_highest = list()
for i in range(roads_len):
    start, end = map(int, input().split(' '))
    #print(start, end)
    if heights[start][1] is True and heights[end][0] >= heights[start][0]:
        heights[start][1] = False
        
    if heights[end][1] is True and heights[start][0] >= heights[end][0]:
        heights[end][1] = False
        

good_towers_len = 0
for tower in heights:
    if tower[1]:
        good_towers_len += 1

print(heights)

print(good_towers_len)


def make_heights_list(height):
    return [int(height), True]


tower_len, roads_len = map(int, input().split(' '))

heights = [[0, False]]
heights += (list(map(make_heights_list, input().split(' '))))

#print(heights)


roads_highest = list()
for i in range(roads_len):
    start, end = map(int, input().split(' '))
    #print(start, end)
    if heights[start][1] is True and heights[end][0] >= heights[start][0]:
        heights[start][1] = False
        
    if heights[end][1] is True and heights[start][0] >= heights[end][0]:
        heights[end][1] = False
        

good_towers_len = 0
for tower in heights:
    if tower[1]:
        good_towers_len += 1

#print(heights)

print(good_towers_len)


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):
#ABC166
N,M=map(int,input().split())
H =list(map(int,input().split()))  
A = list(range(N))
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        A[b-1] = 0
    elif H[a-1] < H[b-1]:
        A[a-1] = 0
    else:
        A[a-1] = 0 and A[b-1] = 0

print(N-A.count(0))

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

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

gooddict={i:1 for i in range(1,n+1)}

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

count=0
for i in range(1,n+1):
  if gooddict[i]==1:
    count+=1
print(count)
print(gooddict)

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

gooddict={i:1 for i in range(1,n+1)}

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

count=0
for i in range(1,n+1):
  if gooddict[i]==1:
    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 = list(map(int, input().split()))
G = dict()
for i in range(1, N+1):
    G[i] = [0]

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

cnt = 0
for i in range(1, N+1):
    flag = False
    if len(G[i]) > 1:
        for j in G[i]:
            if H[i-1] <= H[j-1]:
                flag = False
                break
            else:
                flag = True
    else:
        flag = True
    if flag:
        cnt += 1

print(cnt)

N, M = map(int, input().split())
H = list(map(int, input().split()))
G = dict()
for i in range(1, N+1):
    G[i] = [0]

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

cnt = 0
for i in range(1, N+1):
    flag = False
    for j in G[i]:
        if j == 0 and len(G[i]) == 1:
            flag = True
            break
        if H[i-1] <= H[j-1]:
            flag = False
            break
        else:
            flag = True
    if flag:
        cnt += 1

print(cnt)

N, M = map(int, input().split())
H = list(map(int, input().split()))
G = dict()
for i in range(1, N+1):
    G[i] = [0]

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

cnt = 0
for i in range(1, N+1):
    flag = False
    if len(G[i]) > 1:
        for j in G[i]:
            if j == 0:
                continue
            if H[i-1] <= H[j-1]:
                flag = False
                break
            else:
                flag = True
    else:
        flag = True
    if flag:
        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):
def resolve():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    A = []
    B = []
    ans = 0
    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a-1)
        B.append(b-1)
    while len(set(H)) != 0:
        v = H.index(max(H))+1
        for i in range(M):
            if A[i] == v:
                H[B[i]-1] = 0
            if B[i] == v:
                H[A[i]-1] = 0
        H[v-1] = 0
        ans += 1
    print(ans)
resolve()

N, M = map(int, input().split())
H = list(map(int, input().split()))
count = [0]*N
ans = 0
for _ in range(M):
    a, b = map(int, input().split())
    if H[a-1] > count[b-1]:
        count[b-1] = H[a-1]
    if H[b-1] > count[a-1]:
        count[a-1] = H[b-1]
for i in range(N):
    if H[i] > count[i]:
        ans += 1
print(ans)

Verdicts: Time Limit Exceeded

Accepted