Problem:
 Score : 300 points    Problem Statement There are N observatories in AtCoder Hill, called Obs. 1 , Obs. 2 , ... , Obs. N . The elevation of Obs. i is H_i .
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j .  Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.
Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.  How many good observatories are there?      Constraints  2 \leq N \leq 10^5  1 \leq M \leq 10^5  1 \leq H_i \leq 10^9  1 \leq A_i,B_i \leq N  A_i \neq B_i  Multiple roads may connect the same pair of observatories.  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  M  H_1  H_2  ...  H_N  A_1  B_1  A_2  B_2  :  A_M  B_M       Output Print the number of good observatories.        Sample Input 1 4 3
1 2 3 4
1 3
2 3
2 4      Sample Output 1 2    From Obs. 1 , you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3 , so Obs. 1 is not good.    From Obs. 2 , you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3 , so Obs. 2 is not good.    From Obs. 3 , you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2 , so Obs. 3 is good.    From Obs. 4 , you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2 , so Obs. 4 is good.    Thus, the good observatories are Obs. 3 and 4 , so there are two good observatories.       Sample Input 2 6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6      Sample Output 2 3

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*N
for i in range(M):
  a,b=list(map(int,input().split()))
  A[a-1]=max(A[a-1],H[b-1])
  A[b-1]=max(A[b-1],H[a-1])
s=0
for i in  range(N):
  if H[i]>A[i]:
    s+=1
print(s)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
heighest = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    heighest[a-1] = max(heighest[a-1], H[b-1])
    heighest[b-1] = max(heighest[b-1], H[a-1])

cnt = 0

for i, j  in zip(heighest, H):
    if i < j:
        cnt += 1
print(cnt)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
preH =[]
for i in range(M):
    preH.append(list(map(int, input().split())))
ans = [True]*N

for i in range(M):
    A,B = preH[i]


    if(H[A-1]<=H[B-1]):
        ans[A-1] = False
    if(H[B-1]<=H[A-1]):
        ans[B-1] = False

print(ans.count(True))

Solution (Python):

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

dic={}
for i in range(n):
    dic[i+1]=True
for i in range(m):
    a,b=map(int,input().split())
    if hl[a-1]<=hl[b-1]:
        dic[a]=False
    if hl[b-1]<=hl[a-1]:
        dic[b]=False
ans=0
for k,v in dic.items():
    if v :
        ans+=1

print(ans)

Solution (Python):
n,m = map(int,input().split())
h = list(map(int, input().split()))
h.insert(0, 0) 
ma = [0] * (n+1) 

for i in range(m):
    a,b = map(int, input().split())
    ma[a] = max(ma[a], h[b])
    ma[b] = max(ma[b], h[a])

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

Solution (Python):
N, M = map(int, input().split())

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




graph = [[] for _ in range(N)]

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

  ans = 0

for n in range(N):
  flag = True
  for to in graph[n]:
    if H[n] <= H[to]:
      flag = False
    
  if flag:
    ans += 1
  
print(ans)

Solution (Python):
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[a-1] = 0
    if H[b-1] <= H[a-1]: ans[b-1] = 0

print(sum(ans))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
t=[]
for i in range(m):
    t.append(list(map(int,input().split())))
ans=[True]*n
for i in range(m):
    a,b=t[i]
    if(h[a-1]<=h[b-1]):
        ans[a-1]=False
    if(h[b-1]<=h[a-1]):
        ans[b-1]=False
print(ans.count(True))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[1]*n
for _ in range(m):
  a,b=map(int,input().split())
  if ans[a-1]:
    if h[a-1]<=h[b-1]:
      ans[a-1]=0
  if ans[b-1]:
    if h[b-1]<=h[a-1]:
      ans[b-1]=0
print(ans.count(1))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[1]*n
for _ in range(m):
  a,b=map(int,input().split())
  if ans[a-1]:
    if h[a-1]<=h[b-1]:
      ans[a-1]=0
  if ans[b-1]:
    if h[b-1]<=h[a-1]:
      ans[b-1]=0
print(ans.count(1))

Solution (Python):
N, M = map(int, input().split())
height = [int(i) for i in input().split()]
Good_Peak = []
for i in range(N):
  Good_Peak.append(True)
for i in range(M):
  A, B = map(int, input().split())
  if height[A-1] <= height[B-1]:
    Good_Peak[A-1] = False
  if height[B-1] <= height[A-1]:
    Good_Peak[B-1] = False
print(Good_Peak.count(True))

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

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

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
max_=[True]*N
for i in range(M):
    a,b=map(lambda x:int(x)-1,input().split())
    if(H[a]>=H[b]):
        max_[b]=False
    if(H[a]<=H[b]):
        max_[a]=False
ans=0
for i in range(N):
    if max_[i]:
        ans+=1
print(ans)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
edges = [[]for _ in range(n)]
for _ in range(m):
    a, b = list(map(lambda x: int(x)-1, input().split()))
    edges[a].append(b)
    edges[b].append(a)

ans = 0
for v in range(n):
    for v2 in edges[v]:
        if h[v] <= h[v2]:
            break
    else:
        ans += 1
print(ans)

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

lst = [0] * N 

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


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

print(ans)

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

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
g=[1]*n
for _ in range(m):
  a,b=map(int,input().split())
  if g[a-1]:
    if h[a-1]<=h[b-1]:
      g[a-1]=0
  if g[b-1]:
    if h[b-1]<=h[a-1]:
      g[b-1]=0
print(g.count(1))

Solution (Python):
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] = 'X'
    elif h[a-1] < h[b-1]:
        ans[a-1] = 'X'
    else:
        ans[a-1] = 'X'
        ans[b-1] = 'X'

print(ans.count(1))

Solution (Python):
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = []
    g = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        ab.append([a, b])
        g[a - 1].append(b - 1)
        g[b - 1].append(a - 1)
    ans = 0
    for i in range(n):
        check = True
        for j in g[i]:
            if h[j] >= h[i]:
                check = False
        if check:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    LIST = [1] * 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))
    
main()

Solution (Python):
def main():
    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))

main()

Solution (Python):
N, M = map(int, input().split())
p_list = [1 for _ in range(N)]
e_list = list(map(int, input().split()))
for _ in range(M):
   a, b = map(int, input().split())
   if e_list[a - 1] <= e_list[b - 1]:
       p_list[a - 1] = 0
   if e_list[b - 1] <= e_list[a - 1]:
       p_list[b - 1] = 0
print(sum(p_list))

Solution (Python):
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = []
    g = []
    for _ in range(n):
        g.append([])
    for _ in range(m):
        a, b = map(int, input().split())
        ab.append([a, b])
        g[a - 1].append(b - 1)
        g[b - 1].append(a - 1)
    ans = 0
    for i in range(n):
        check = True
        for j in g[i]:
            if h[j] >= h[i]:
                check = False
        if check:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())
Hs = input().split()
lis = []
for i in range(N):
  lis.append([])
for m in range(M):
  A, B = map(int, input().split())
  lis[A-1].append(B-1)
  lis[B-1].append(A-1)

score = 0

for i in range(N):
  break_flag = 0
  base_h = int(Hs[i])
  
  hikaku = lis[i]
  
  for j in range(len(hikaku)):
    
    if int(Hs[hikaku[j]]) >= base_h:
      break_flag = 1
  if break_flag != 1:
    score += 1
print(score)

Solution (Python):
import numpy as np

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

print(ans)

Solution (Python):
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]

B=[0]*N



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

Solution (Python):
N,M=map(int, input().split())
yoi = []
for i in range(N):
  yoi.append(True)
H=list(map(int, input().split()))
for i in range(M):
  A,B=map(int, input().split())
  if H[A-1]<=H[B-1]: yoi[A-1]=False
  if H[B-1]<=H[A-1]: yoi[B-1]=False 
print(len([1 for x in yoi if x==True]))

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

bridge = [[] for i in range(N+1)]

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

ans = 0

for i in range(1,N+1):
    tmp = bridge[i]
    tmp = list(set(tmp))
    flag = True
    
    if len(tmp) == 0:
        ans +=1
        continue
    for j in range(len(tmp)):
        if H[i-1] <= H[tmp[j]-1]:
            flag = False
    if flag == False:
        continue
    elif flag == True:
        ans += 1

print(ans)

Solution (Python):
N,M = map(int,input().split())
a = set([i for i in range(1, N+1)])
H = [int(i) for  i in input().split()]
for i in range(M):
  A,B = map(int,input().split())
  if H[A-1]>H[B-1]: 
    a.discard(B)
  elif H[A-1]<H[B-1]:
    a.discard(A)
  else:
    a.discard(A)
    a.discard(B)
print(len(a))

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

bridge = [[] for i in range(N+1)]

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

ans = 0
count = 0

for i in range(1,N+1):
    tmp = bridge[i]
    tmp = list(set(tmp))
    flag = True
    for j in range(len(tmp)):
        if H[i-1] <= H[tmp[j]-1]:
            flag = False
    if flag == False and len(bridge[i]) != 0:
        continue
    elif flag == True and len(bridge[i]) != 0:
        ans += 1
            
    if len(bridge[i]) == 0:
        ans +=1
        
print(ans)

Solution (Python):

n,m = map(int, input().split())
h_list = list(map(int, input().split()))
c_list= [[] for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    c_list[a-1].append(b-1)
    c_list[b-1].append(a-1)
dn = 0
for i in range(n):
    
    for j in c_list[i]:
        if  h_list[i] <=h_list[j]:
            dn+=1
            break
print(n-dn)

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
l = [0]*N
ans = 0
for i in range(M):
    A,B = map(int,input().split())
    l[A-1] = max(l[A-1],H[B-1])
    l[B-1] = max(l[B-1],H[A-1])
for i in range(N):
    if H[i] > l[i]:
        ans += 1
    else:
        pass
print(ans)

Solution (Python):
N,M=[int(s) for s in input().split()]
H=[int(s) for s in input().split()]
peak=[0 for _ in range(N)]
edge=[set() for _ in range(N)]
for i in range(M):
  a,b=[int(s) for s in input().split()]
  edge[a-1].add(b-1)
  edge[b-1].add(a-1)

ans=0
for i in range(N):
  if peak[i]==-1:
    continue
  h=H[i]
  for e in edge[i]:
    if H[e]>h:
      peak[i]=-1
      break
    elif H[e]==h:
      peak[i]=-1
      peak[e]=-1
      break
    else:
      peak[e]=-1
  else:
    peak[i]=1
    ans+=1
print(ans)

Solution (Python):
n, m = map(int,input().split())
h = list(map(int,input().split()))
bads = set()
ans = n
for i in range(m):
  a, b = map(int,input().split())
  a -= 1 
  b -= 1
  if a not in bads and h[a] <= h[b]:
    bads.add(a)
    ans -= 1
  if b not in bads and h[a] >= h[b]:
    bads.add(b)
    ans -= 1
print(ans)

Solution (Python):


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

print(sum(e_list))

Solution (Python):
import numpy as np

N,M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
L = [1]*N

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

L = np.array(L)

print(np.sum(L))

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

Solution (Python):
N,M = map(int, input().split())
H=list(map(int, input().split()))
h=[1 for _ in range(N)]

for i in range(M):
  A=list(map(int, input().split()))
  Ah = H[A[0]-1]
  Bh = H[A[1]-1]
  if Ah >= Bh:
    h[A[1]-1]=0
  if Ah <= Bh:
    h[A[0]-1]=0
print(sum(h))

Solution (Python):
def solve():
    n,m=map(int,input().split())
    H=list(map(int,input().split()))
    A=[[0,0] for i in range(n)]
    for i in range(m):
        a,b=map(int,input().split())
        if(H[a-1]>H[b-1]):
            A[a-1][0]+=1
            A[a-1][1]+=1
            A[b-1][1]+=1
        elif(H[a-1]<H[b-1]):
            A[b-1][0]+=1
            A[a-1][1]+=1
            A[b-1][1]+=1
        else:
            A[a-1][1]+=1
            A[b-1][1]+=1
    count=0
    
    for i in range(n):
        if(A[i][0]==A[i][1]):
            count+=1
    print(count)
solve()

Solution (Python):
N, M = map(int, input().split())
p_list=[1 for _ in range(N)]
e_list = list(map(int, input().split()))

for _ in range(M):
  a,b = map(int, input().split())
  if e_list[a-1] <= e_list[b-1]:
    p_list[a-1]=0
  if e_list[b-1] <= e_list[a-1]:
    p_list[b-1] = 0
print(sum(p_list))

Solution (Python):
N,M=map(int,input().split())
H=list(map(int,input().split()))
bads=set()
ans=N
for m in range(M):
  A,B=map(int,input().split())
  A-=1
  B-=1
  if A not in bads and H[A]<=H[B]:
    bads.add(A)
    ans-=1
  if B not in bads and H[A]>=H[B]:
    bads.add(B)
    ans-=1
print(ans)

Solution (Python):
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])

ans = sum(H[i] > A[i] for i in range(N))
print(ans)

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

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

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

Solution (Python):
n,m = map(int,input().split())
H = list(map(int,input().split()))
l = [0]*n
AB = [list(map(int,input().split())) for _ in range(m)]
for a,b in AB:
    if H[a-1]>H[b-1]:
        l[a-1] += 1
        l[b-1] -= 10000
    elif H[a-1]==H[b-1]:
        l[a-1] -= 10000
        l[b-1] -= 10000
    else:
        l[a-1] -= 10000
        l[b-1] += 1
ans = 0
for _ in range(n):
    if l[_]>=0:
        ans += 1
print(ans)

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

ab = [0]*n
for _ in range(m):
  a,b = map(int, input().split())
  ab[a-1] = max(ab[a-1], h[b-1])
  ab[b-1] = max(ab[b-1], h[a-1])

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

Solution (Python):
n, m = map(int, input().split())
h = tuple(map(int, input().split()))
i = 0
c = [1]*n
while i<m:
    a, b=map(int, input().split())
    if h[a-1] > h[b-1]:
        c[b-1] = 0
    elif h[a-1] == h[b-1]:
        c[a-1] = c[b-1] = 0
    else:
        c[a-1] = 0
    i += 1

ans = 0
i = 0
while i<n:
    if c[i] == 1:
        ans+=1
    i+=1

print(ans)

Solution (Python):
n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))

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

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
m = [0] * N
cnt = 0

for _ in range(M):
  a, b = map(int, input().split())
  m[a - 1] = max(m[a - 1], H[b - 1])
  m[b - 1] = max(m[b - 1], H[a - 1])

for i in range(N):
  if H[i] > m[i] or m[i] == 0:
    cnt += 1

print(cnt)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

h = [0] + h
t = [0] * (n+1)
cnt = 0

for a, b in zip(m, m):
    t[a] = max(t[a], h[b])
    t[b] = max(t[b], h[a])

for i in range(n+1):
    if h[i] > t[i]:
        cnt += 1

print(cnt)

Solution (Python):
from sys import stderr
import json

def debug(*args):
    print(*args, file=stderr)

n_observatory_num, m_roads_num = map(int, input().split())
hi_heights = list(map(int, input().split()))

ab_roads_fromto = [map(int, input().split()) for _ in range(m_roads_num)]


class ObservatoryController():
    observatories_by_id = {}

    def add(self, a_observatory):
        self.observatories_by_id[a_observatory.id] = a_observatory

    def connect_by_id(self, a_id, b_id):
        observatory_a = self.observatories_by_id[a_id]
        observatory_b = self.observatories_by_id[b_id]

        observatory_a.connect_to(observatory_b)
        observatory_b.connect_to(observatory_a)

    
    def count_good_observatories(self):
        result = 0
        for id, a_observaotry in self.observatories_by_id.items():
            if a_observaotry.is_good():
                result += 1
        return result


class Observatory():
    def __init__(self, id, height):
        self.id = id
        self.height = height
        self.connected_to_by_id = {}

    def __repr__(self):
        construct = json.dumps({
            'id': self.id,
            'height': self.height,
        })
        return "<Observatory '%s'>" % (construct)

    def connect_to(self, a_observaotry):
        self.connected_to_by_id[a_observaotry.id] = a_observaotry

    def is_good(self):
        for a_connected_observatory in self.connected_to_by_id.values():
            if self.height <= a_connected_observatory.height:
                return False
        return True

observatoryController = ObservatoryController()

for i, height in enumerate(hi_heights):
    id = i + 1
    observatory = Observatory(id, height)
    observatoryController.add(observatory)

for a, b in ab_roads_fromto:
    observatoryController.connect_by_id(a, b)

result = observatoryController.count_good_observatories()

print(result)

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

ma = [0]*n

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

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

print(ans)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

n,m = LI()
h = LI()
high = [0]*n

for i in range(m):
    a, b = LI()
    if h[a-1]>h[b-1]:
        high[b-1] += 1
    elif h[a-1]==h[b-1]:
        high[a-1] += 1
        high[b-1] += 1
    else:
        high[a-1] += 1
print(high.count(0))

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

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

ans = []

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

ans = set(ans)

print(int(len(h)) - int(len(ans)))


1,4,4

Solution (Python):
from sys import stderr
import json

def debug(*args):
    print(*args, file=stderr)

n_observatory_num, m_roads_num = map(int, input().split())
hi_heights = list(map(int, input().split()))

ab_roads_fromto = [map(int, input().split()) for _ in range(m_roads_num)]


class ObservatoryController():
    observatories_by_id = {}

    def add(self, a_observatory):
        self.observatories_by_id[a_observatory.id] = a_observatory

    def connect_by_id(self, a_id, b_id):
        observatory_a = self.observatories_by_id[a_id]
        observatory_b = self.observatories_by_id[b_id]

        observatory_a.connect_to(observatory_b)
        observatory_b.connect_to(observatory_a)

    
    def count_good_observatories(self):
        result = 0
        for id, a_observaotry in self.observatories_by_id.items():
            if a_observaotry.is_good():
                result += 1
        return result


class Observatory():
    id = None
    height = None
    connected_to = []


    def __init__(self, id, height):
        self.id = id
        self.height = height
        self.connected_to = []


    def __repr__(self):
        construct = json.dumps({
            'id': self.id,
            'height': self.height,
        })
        return "<Observatory '%s'>" % (construct)

    def connect_to(self, a_observaotry):
        self.connected_to.append(a_observaotry)
    
    def is_good(self):
        for a_connected_observatory in list(self.connected_to):
            
            if self.height <= a_connected_observatory.height:
                return False
        return True

observatoryController = ObservatoryController()

for i, height in enumerate(hi_heights):
    id = i + 1
    observatory = Observatory(id, height)
    observatoryController.add(observatory)

for a, b in ab_roads_fromto:
    observatoryController.connect_by_id(a, b)

result = observatoryController.count_good_observatories()

print(result)

Solution (Python):



from copy import deepcopy
from pprint import pprint

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

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

nolist = [0] * n

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









print(nolist.count(0))

exit()

Solution (Python):
n, m = map(int, input().rstrip().split())
h = list(map(int, input().rstrip().split()))
l = []
high = [0] * n
count = 0

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

for i in l:
    if h[i[0]-1] < h[i[1]-1]:
        high[i[0]-1] += 1
    elif h[i[0]-1] == h[i[1]-1]:
        high[i[0]-1] += 1
        high[i[1]-1] += 1
    else:
        high[i[1]-1] += 1

for hi in high:
    if hi == 0:
        count += 1
print(count)

Solution (Python):

import sys
input = sys.stdin.readline
N,M = (int(x) for x in input().split())
H = [-1]+list(map(int, input().split()))


observ_H ={}
connection ={i:set() for i in range(1,N+1)}


for i in range(1,M+1):
    a,b = (int(x) for x in input().split())
    connection[a].add(b)
    connection[b].add(a)
    

for i in range(1,N+1):
    observ_H[i] = H[i]

observ_good ={}
hantei=1
for num,connect in connection.items():
    hantei =1
    for saki in connect:
        if observ_H[num] > observ_H[saki]:
            hantei *=1
        else:
            hantei=0
    if hantei==1:
        observ_good[num] ="good"
print(len(observ_good))

Solution (Python):
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))

Solution (Python):
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[a] = 0
    if h[b] <= h[a]:
        ans[b] = 0
print(sum(ans))

Solution (Python):
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))

Solution (Python):
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))

Solution (Python):
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
ways = [[] for _ in range(N)]
for ab in AB:
    ways[ab[0] - 1].append(ab[1] - 1)
    ways[ab[1] - 1].append(ab[0] - 1)
c = 0
for i in range(N):
    if len(ways[i]) == 0:
        c += 1
        continue
    t = 0
    for j in ways[i]:
        if H[i] <= H[j]:
            break
    else:
        c += 1
print(c)

Solution (Python):
n, m = map(int, input().split())
list_height = list(map(int, input().split()))
list_way = []
list_goodpoint = [1]*n
for i in range(m):
  list_way.append(list(map(int, input().split())))

for way in list_way:
  if list_height[way[0]-1] == list_height[way[1]-1]:
    list_goodpoint[way[0]-1] = 0
    list_goodpoint[way[1]-1] = 0
  if list_height[way[0]-1] > list_height[way[1]-1]:
    list_goodpoint[way[1]-1] = 0
  if list_height[way[0]-1] < list_height[way[1]-1]:
    list_goodpoint[way[0]-1] = 0
print(sum(list_goodpoint))

Solution (Python):
N,M = map(int, input().split())
H = list(map(int, input().split()))
ls = [[int(i) for i in input().split()] for j in range(M)]

ans = []
for l in ls:
    A = l[0]
    B = l[1]
    if H[A-1] > H[B-1]:
        ans.append(B-1)     
    elif H[A-1] < H[B-1]:
        ans.append(A-1)
    else:
        ans.append(B-1)
        ans.append(A-1)     

print(len(H) - len(set(ans)))

Solution (Python):
n, m = map(int,input().split())
h = list(map(int,input().split()))
l =[0]*(n+1)

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

print(n-sum(l))

Solution (Python):


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

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

ans = 0

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

print(ans)

Solution (Python):
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
roads = []
for i in range(m):
    roads += [list(map(int, input().split()))]
for road in roads:
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))

Solution (Python):


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

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

ans = 0

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

print(ans)

Solution (Python):
from collections import defaultdict

d = defaultdict(list)

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

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

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

ans = 0
for i in range(N):
    ng = 0

    if(i not in d):
        ans += 1
        continue

    for j in d[i]:
        if(H[i] <= H[j]): ng = 1
    if(ng != 1):
        ans += 1

print(ans)

Solution (Python):
n,m = map(int, input().split(" "))
hlist = list(map(int, input().split(" ")))

xlist = []

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

print(int(n-len(list(set(xlist)))))

Solution (Python):
n,m = map(int,input().split())
lis1 = list(map(int, input().split()))
ans = [1]*n

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

print(sum(ans))