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

judge = ["ok" for i in range(n)]

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

    if high[a] < high[b]:
        judge[a] = "ng"
    elif high[a] > high[b]:
        judge[b] = "ng"
    else:
        judge[a] = "ng"
        judge[b] = "ng"

print(judge.count("ok"))

Solution (Python):
class Unionfind:
    decks = None
    Values = None

    def __init__(self, N, H):
        self.decks = [0 for i in range(int(N))]
        self.Values = [int(H[i]) for i in range(int(N))]

    def Connect(self, A, B):
        if self.Values[int(A) - 1] > self.Values[int(B) - 1]:
            if self.decks[int(A) - 1] >= 0:
                self.decks[int(A) - 1] = 1
                self.decks[int(B) - 1] = -1
            else:
                self.decks[int(B) - 1] = -1

        elif self.Values[int(A) - 1] < self.Values[int(B) - 1]:
            if self.decks[int(B) - 1] >= 0:
                self.decks[int(B) - 1] = 1
                self.decks[int(A) - 1] = -1
            else:
                self.decks[int(A) - 1] = -1
        else:
            self.decks[int(A) - 1] = -1
            self.decks[int(B) - 1] = -1

    def GoodDeckCount(self):
        return len([i for i in self.decks if i >= 0])


N, M = input().split()
H = input().split()
j = [input().split() for i in range(int(M))]

uni = Unionfind(N, H)
for bridge in j:
    uni.Connect(bridge[0], bridge[1])

print(uni.GoodDeckCount())

Solution (Python):
n, m = list(map(int,input().split()))
h = list(map(int,input().split()))
ma = [0]*n
count = 0
for i in range(m):
    a, b = list(map(int,input().split()))
    ma[a-1] = max(ma[a-1],h[b-1])
    ma[b-1] = max(ma[b-1],h[a-1])

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

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

table = [1] * (n+1)
table[0] = 0

for _ in [0]*m:
    a, b = list(map(int, input().split()))
    if h[a] > h[b]:
        table[b] = 0
    elif h[a] < h[b]:
        table[a] = 0
    else:
        table[a] = 0
        table[b] = 0

print(sum(table))

Solution (Python):
n, m = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
hs = [[] for i in range(n)]
for i in range(m):
    a, b = [int(i) for i in input().split()]
    hs[a-1].append(h[b-1])
    hs[b-1].append(h[a-1])
c = 0
for i in range(n):
    if len(hs[i]) == 0:
        c += 1
    elif h[i] > max(hs[i]):
        c += 1
print(c)

Solution (Python):
n,m = map(int, input().split())
h = list(map(int, input().split()))
A = [1 for i in range(n)]

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

print(sum(A))

Solution (Python):

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

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


ans=0
for i,t in enumerate(tree):
    if all(h[i] > h[tt] for tt in t):
        ans+=1
print(ans)

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

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
obs = {}
for i in range(1,N+1):
  obs[i] = []
for i in range(M):
  A,B = map(int,input().split())
  obs[A].append(B)
  obs[B].append(A)

cnt = N

for i in range(1,N+1):
  h = H[i-1]
  l = len(obs[i])
  for j in range(l):
    if H[obs[i][j]-1] >= h:
      cnt -= 1
      break
      
print(cnt)

Solution (Python):

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.count(1))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    hl=[0]+list(map(int,input().split()))
    
    checkl=[True]*n
    for i in range(m):
        a,b=map(int, input().split())
        if hl[a]<hl[b]:
            checkl[a-1]=False
        elif hl[a]>hl[b]:
            checkl[b-1]=False
        else:
            checkl[a-1]=checkl[b-1]=False
    ans=0
    for i in range(n):
        if checkl[i]:
            ans+=1
    print(ans)
resolve()

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    N,M=map(int, input().split())
    H=list(map(int,input().split()))
    edge = [[] for i in range(N)]
    for i in range(M):
        x, y = map(int, input().split())
        x, y = x - 1, y - 1
        edge[x].append(y)
        edge[y].append(x)
    cnt=0
    for i in range(N):
        val=H[i]
        if edge[i]==[]:
            cnt+=1
        else:
            if all(val>H[j] for j in edge[i]):
                    cnt+=1
    print(cnt)
resolve()

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

Solution (Python):
N, M = [int(_) for _ in input().split()]
H = [0] + [int(_) for _ in input().split()]
C = [[] for i in range(N+1)]
for i in range(M):
    A, B = [int(_) for _ in input().split()]
    C[A].append(H[B])
    C[B].append(H[A])
cnt = 0
for i in range(1, N+1):
    if len(C[i]) == 0 or H[i] > max(C[i]):
        cnt += 1
print(cnt)

Solution (Python):
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[] for i in range(N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)

ans = 0
for node in range(N):
  flag =1
  for l in B[node]:
    if O[node] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)

Solution (Python):
import numpy as np
N,M = map(int,input().split())
H = np.array(list(map(int,input().split())))

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

for _ in range(M):
    a,b = map(lambda x: int(x) -1 ,input().split())
    if a in adj[b]:
        continue
    adj[a].append(b)
    adj[b].append(a)

ans = 0 
for i, item in enumerate(adj):
     if item == []:
         ans+=1
         continue
     adj_max = max(H[item])
     if H[i] > adj_max:
         ans += 1
print(ans)

Solution (Python):
N,M=map(int, input().split())
H=list(map(int, input().split()))
flag=[1]*N
for i in range(M):
    A,B=map(int, input().split())
    if H[A-1]>H[B-1]:
        flag[B-1]=0 
    elif H[A-1]<H[B-1]:
        flag[A-1]=0
    else:
        flag[A-1]=0
        flag[B-1]=0
print(sum(flag))

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


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

Solution (Python):
load = list()
n,m = map(int,input().split())
h = list(map(int,input().split()))
for i in range(m):
  x = list(map(int,input().split()))
  load.append(x)

good = [1] * n
for i in range(m):
  load[i][0] -= 1
  load[i][1] -= 1

for i,data in enumerate(load):
  
  if(h[data[0]] == h[data[1]]):
    good[data[0]] = 0
    good[data[1]] = 0
    continue

  if(h[data[0]] < h[data[1]]):
    good[data[0]] = 0
  elif(h[data[1]] < h[data[0]]):
    good[data[1]] = 0

print(sum(good))

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
    elif H[b-1]<H[a-1]:
        ans[b-1] = 0
    else:
        ans[a-1], ans[b-1] = 0, 0
print(sum(ans))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    N,M=map(int, input().split()) 
    H=list(map(int,input().split()))
    edge = [[] for i in range(N)]
    for i in range(M):
        x, y = map(int, input().split())
        x, y = x - 1, y - 1
        edge[x].append(y)
        edge[y].append(x) 
    cnt=0
    for i in range(N):
        val=H[i]
        if edge[i]==[]:
            cnt+=1
        else:
            num=0
            for j in edge[i]:
                if val>H[j]:
                    num+=1
            if num==len(edge[i]):
                cnt+=1
    print(cnt)
resolve()

Solution (Python):
N,M = map(int, input().split())
H_list =  [0] + [int(e) for e in input().split()]

best_observatories_higher = {i:H_list[i] for i in range(1,N+1)}
same_higher_observatories_flag = {i:False for i in range(1,N+1)}

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

    if H_list[A] > H_list[B]:
        if best_observatories_higher[B] < H_list[A]:
            best_observatories_higher[B] = H_list[A]

    elif H_list[A] < H_list[B]:
        if best_observatories_higher[A] < H_list[B]:
            best_observatories_higher[A] = H_list[B]

    elif H_list[A] == H_list[B]:
        if best_observatories_higher[A] == H_list[B]:
            same_higher_observatories_flag[A] = True
        if best_observatories_higher[B] == H_list[A]:
            same_higher_observatories_flag[B] = True

ans = 0

for i in range(1,N+1):
    if best_observatories_higher[i] == H_list[i] and same_higher_observatories_flag[i] == False:
        ans += 1
















print(ans)

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

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

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

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
tall=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  tall[a]=max(tall[a],h[b])
  tall[b]=max(tall[b],h[a])
res=0
for i in range(n):
  if h[i]>tall[i]:
    res+=1
print(res)

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

T = [-1 for _ in range(N + 1)]

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

    T[a] = max(T[a], H[b])
    T[b] = max(T[b], H[a])

cnt = 0

for i in range(1, N + 1):
    if H[i] > T[i]:
        cnt += 1

print(cnt)

Solution (Python):
n = [int(e) for e in input().split(" ")]
d = []
c = 0
for e in input().split(" "):
    d.append([(int(e)), []])
for _ in range(n[1]):
    x = [int(e) - 1 for e in input().split(" ")]
    d[x[0]][1].append(d[x[1]][0])
    d[x[1]][1].append(d[x[0]][0])
for e_d in d:
    try:
        m = max(e_d[1])
    except:
        m = -1
    if(m < e_d[0]):
        c += 1
print(c)

Solution (Python):
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=0
for v in range(1,n+1):
  for u in g[v]:
    if arr[u]>=arr[v]:
      break
  else:
    ans+=1
print(ans)

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


Tallest = [0]*N

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Tallest[a] = max(Tallest[a], Hi[b])
    Tallest[b] = max(Tallest[b], Hi[a])

goodT = 0

for i in range(N):
    if Hi[i]>Tallest[i]:
        goodT +=1
    
print (goodT)

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

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

Solution (Python):
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 H[a] <= H[b]:
            V[a] = False
        if H[a] >= H[b]:
            V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

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

good = [True] * N
for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1

    if H[A] == H[B]:
        good[A] = good[B] = False
    else:
        good[B if H[A] - H[B] > 0 else A] = False

print([x for x in good if x].__len__())

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

goodObservatory = [1]*N

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

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

print(sum(goodObservatory))

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

AB = []
for i in range(M):
    A,B = map(int,input().split())
    AB.append([A,B])
h = [0]
for i in range(N):
    h.append(1)
    
for k in range (M):
    i = AB[k][0]
    j = AB[k][1]
    if H[i] < H[j]:
        h[i] = 0
    elif H[i] > H[j]:
        h[j] = 0
    else:
        h[i] = 0
        h[j] = 0

print(sum(h))

Solution (Python):
N,M = map(int,input().split())
H = [0]
h = list(map(int,input().split()))
H += h 
AB = []
for i in range(M):
    A,B = map(int,input().split())
    AB.append([A,B])
h = [0]
for i in range(N):
    h.append(1)
    
for k in range (M):
    i = AB[k][0]
    j = AB[k][1]
    if H[i] < H[j]:
        h[i] = 0
    elif H[i] > H[j]:
        h[j] = 0
    else:
        h[i] = 0
        h[j] = 0

print(sum(h))

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
anslist=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
    anslist[b-1]=0
  elif h[a-1]==h[b-1]:
    anslist[a-1]=0
    anslist[b-1]=0
  else:
    anslist[a-1]=0
  
print(anslist.count(1))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
view = [True] * n
for j in range(m):
    a, b = map(int, input().split())
    a -=1
    b -=1
    if h[a] < h[b]:
        view[a] = False
    elif h[a] > h[b]:
        view[b] = False
    elif h[a] == h[b]:
        view[a] = False
        view[b] = False

print(view.count(True))

Solution (Python):
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])
 
ans=0
 
for i in range(n):
    if h[i]>t[i]:
        ans+=1
 
print(ans)

Solution (Python):
N,M = map(int,input().split())
HN = list(map(int,input().split()))
X = []
for i in range(N):
    X += [1]
for i in range(M):
    A,B = list(map(int,input().split()))
    if HN[A-1] > HN[B-1]:
        X[B-1]=0 
    elif HN[A-1] < HN[B-1]:
        X[A-1]=0
    else:
        X[A-1],X[B-1]= 0,0
print(sum(X))

Solution (Python):
class Graph(): 
    def __init__(self,n,edge):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.deg = [0 for _ in range(n)]
        for e in edge:
            self.graph[e[0]-1].append(e[1]-1)
            self.graph[e[1]-1].append(e[0]-1)
            self.deg[e[0]-1] += 1
            self.deg[e[1]-1] += 1

import sys
input = sys.stdin.readline

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

E = [tuple(map(int, input().split())) for _ in range(M)]

G = Graph(N, E)

res = 0

for node in range(N):
    flag = True
    for adj in G.graph[node]:
        if H[adj] >= H[node]:
            flag = False
            break
    res += flag

print(res)

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


Flags = [1] * N

for j in range(M):
    if(H[AB[j][0] - 1] <= H[AB[j][1] - 1]):
        Flags[AB[j][0] - 1] = 0

    if(H[AB[j][1] - 1] <= H[AB[j][0] - 1]):
        Flags[AB[j][1] - 1] = 0

count = 0
for i in range(N):
    count += Flags[i]



print(count)

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

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

good = [True] * N

for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  if H[A] >= H[B]:
    good[B] = False
  if H[A] <= H[B]:
    good[A] = False
print(sum(good))

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

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

better = [[] for _ in H]

for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  if H[A] >= H[B]:
    better[B].append(A)
  if H[A] <= H[B]:
    better[A].append(B)
print(sum([1 for b in better if not b]))

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

Solution (Python):
N, M = map(int, input().split())
*H, = 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[A - 1] >= H[B - 1]:
        ans[B - 1] = 0
print(sum(ans))

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

Solution (Python):
import numpy as np
N, M =  map(int, input().split())


high = list(map(int, input().split()))
good = [0 for i in range(N)]



for i in range(M):
    A, B =map(int, input().split())
    if (high[A - 1] > high[B - 1]):
        good[B - 1] += 1
    elif (high[A - 1] == high[B - 1]):
        good[A - 1] += 1
        good[B - 1] += 1
    else:
        good[A - 1] += 1

        
print(good.count(0))

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

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

count=0
for i in range(N):
    if not connect[i]:
        count+=1
    elif H[i]>max(connect[i]):
        count+=1


print(count)

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

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

ans = 0
for i in range(N):
    is_ok = True
    for adj in Graph[i]:
        if H[i] <= H[adj]:
            is_ok = False
    if is_ok:
        ans += 1

print(ans)

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

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

is_good = [True]*n

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

cnt = 0
for i in is_good:
  if i == True:
    cnt += 1

print(cnt)

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

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

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

s=set()
for _ in range(m):
    a, b = map(int, input().split())
    a_h=h[a-1]
    b_h=h[b-1]
    if a_h>=b_h:
        s.add(b)
    if a_h<=b_h:
        s.add(a)

ans = n-len(s)
print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    h = LI()
    ab = [LI_() for _ in range(m)]
    r = [1] * n
    for a,b in ab:
        if h[a] <= h[b]:
            r[a] = 0
        if h[b] <= h[a]:
            r[b] = 0

    return sum(r)


print(main())

Solution (Python):
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
bad = set()
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        bad.add(b)
    elif h[a-1] == h[b-1]:
        bad.add(a)
        bad.add(b)
    elif h[a-1] < h[b-1]:
        bad.add(a)
print(n - len(bad))

Solution (Python):
from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    maxHeights = np.zeros(n)
    for a, b in ABList:
        if hList[a-1] >= maxHeights[b-1]:
            maxHeights[b-1] = hList[a-1]
        if hList[b-1] >= maxHeights[a-1]:
            maxHeights[a-1] = hList[b-1]
    total = 0
    i = 0
    for maxHeight in maxHeights:
        if maxHeight < hList[i]:
            total += 1
        i += 1
    print(total)


if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
li = ["○"]*N
count = 0
for i in range(M):
    A,B = map(int,input().split())
    A_height,B_height = H[A-1],H[B-1]
    if A_height>B_height:
        li[B-1] = "x"
    elif A_height<B_height:
        li[A-1] = "x"
    else:
        li[A-1] = "x"
        li[B-1] = "x"
print(li.count("○"))

Solution (Python):
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
bad = set()
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        bad.add(b)
    elif h[a-1] == h[b-1]:
        bad.add(a)
        bad.add(b)
    elif h[a-1] < h[b-1]:
        bad.add(a)
print(n - len(bad))

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

cnt = 0
for i in range(n):
    H = h[i]
    max1 = 0
    for j in d[i]:
        max1 = max(max1,h[j])
    if H > max1:
        cnt +=1        
print(cnt)

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

tall=[1]*n

for i in range(m):
  if h[ab[i][0]-1]<h[ab[i][1]-1]:
    tall[ab[i][0]-1]=0
  elif h[ab[i][0]-1]>h[ab[i][1]-1]:
    tall[ab[i][1]-1]=0
  else:
    tall[ab[i][1]-1]=0
    tall[ab[i][0]-1]=0


print(sum(tall))

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

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

good_H = [1] * N

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

print(good_H.count(1))

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

Solution (Python):
from collections import defaultdict

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

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

Solution (Python):
N,M=map(int,input().split())
H=[int(h) for h in input().split()]
MAX=[-1 for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    MAX[A-1]=max(H[B-1],MAX[A-1])
    MAX[B-1]=max(H[A-1],MAX[B-1])

ans=sum(int(h>M) for h,M in zip(H,MAX))
print(ans)

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

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

ans = 0
for i in range(n):
    mx = 0
    for j in G[i]:
        mx = max(mx, h[j])
    if mx < h[i]:
        ans += 1

print(ans)

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

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] <= H[b]:
        highest[a] = False
    if H[b] <= H[a]:
        highest[b] = False

print(sum(highest))

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

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

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[a-1]>=h[b-1]:
    ans[b-1]=0
print(ans.count(1))

Solution (Python):
N, M = map(int, input().split())
H = [-1] + list(map(int ,input().split()))
is_good = [1] * (N+1)
is_good[0] = 0
for _ in range(M):
    a,b = map(int, input().split())
    ha,hb = H[a], H[b]
    if ha > hb:
        is_good[b] = 0
    if hb > ha:
        is_good[a] = 0
    if ha == hb:
        is_good[a] = 0
        is_good[b] = 0

print(sum(is_good))

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    H = read_ints()
    is_good = [True]*N
    for _ in range(M):
        a, b = read_ints()
        a -= 1
        b -= 1
        if H[a] >= H[b]:
            is_good[b] = False
        if H[a] <= H[b]:
            is_good[a] = False
    return is_good.count(True)


if __name__ == '__main__':
    print(solve())

Solution (Python):
N, M = list(map(int, input().split()))
h = list(map(int, input().split()))
ma = [0] * N

for i in range(M):
    a, b = list(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 ma[i] < h[i]:
        ans += 1

print(ans)

Solution (Python):
def run():
  N, M = map(int, input().split())
  H = list(map(int, input().split()))
  G = [1] * N
  counter = 0
  for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1]>H[B-1]:
      G[B-1] = 0
    elif H[A-1]<H[B-1]:
      G[A-1] = 0
    else:
      G[A-1] = G[B-1] = 0
  
  for i in range(N):
    if G[i]==1:
      counter+=1
  print(counter)

if __name__ == "__main__":
  run()

Solution (Python):









import numpy as np






N,M = map(int,input().split())
lisH = [0] + list(map(int,input().split()))
lisAB = lisH.copy()
for i in range(M):
    A,B = map(int,input().split())
    if lisH[A] > lisH[B]:
        lisAB[B] = 0
    elif lisH[A] < lisH[B]:
        lisAB[A] = 0
    else:
        lisAB[A] = 0
        lisAB[B] = 0
        
ans = 0
for i in range(1,N+1):
    if lisH[i] == lisAB[i]:
        ans += 1

print(ans)

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