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

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

H = [int(i) for i in input().split()]
H = [0] + H
bgs = [[] for _ in range(N+1)]
for _ in range(M):
    A, B = map(int, input().split())
    bgs[A].append(B)
    bgs[B].append(A)




ans = 0
for i, bg in enumerate(bgs):
    if i == 0:
        continue
    flag = True
    for ob in bg:
        if H[i] <= H[ob]:
            flag = False
            break
    if flag or len(bg) == 0:
        
        ans += 1

print(ans)

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

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

Y = [i for i in X if i == 0]
print(len(Y))

Solution (Python):

"""
Created on Sun May  3 20:55:32 2020

@author: Kanaru Sato
"""

n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
hdic={}
for i in range(n):
    hdic[i] = h[i]

pl = []
for i in range(n):
    pl.append([-1])

for i in range(m):
    pair = list(map(int,input().split()))
    pl[pair[0]-1].append(pair[1])
    pl[pair[1]-1].append(pair[0])

count = 0
for i in range(n):
    Isgood = 1
    for connected in pl[i][1:]:
        if hdic[connected-1] >= hdic[i]:
            Isgood = 0
    if Isgood == 1:
        count += 1

print(count)

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

Flags = [1] * N
for m in range(M):
  A,B = (int(i) for i in input().split())
  if H[A-1]>H[B-1]:
    Flags[B-1] = 0
  elif H[B-1]>H[A-1]:
    Flags[A-1] = 0
  else:
    Flags[A-1] = 0
    Flags[B-1] = 0

ans = sum(Flags)
print(ans)

Solution (Python):
n,m = map(int,input().split())
hei = list(map(int,input().split()))
bestT = [True for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    if(hei[a-1] == hei[b-1]):
        bestT[a-1] = False
        bestT[b-1] = False
        continue
    if(hei[a-1] > hei[b-1]):
        bestT[b-1] = False
    else:
        bestT[a-1] = False

ans = sum(bestT)
print(ans)

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

is_good = [True] * N

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

    if Hs[a-1] == Hs[b-1]:
        is_good[a-1] = False
        is_good[b-1] = False
    elif Hs[a-1] < Hs[b-1]:
        is_good[a-1] = False
    else:
        is_good[b-1] = False

cnt = 0 
for v in is_good:
    if v:
        cnt += 1

print(cnt)

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

A = [0 for _ in range(m)]
B = [0 for _ in range(m)]
H = [0 for _ in range(n)]

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

c = 0
for i in range(n):
    if(H[i] < h[i]):c += 1
print(c)

Solution (Python):
N,M= [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
l = [[] for i in range(N+1)]
for i in range(M):
    a,b= [int(x) for x in input().split()]
    l[a].append(b)
    l[b].append(a)
ans = 0
for i in range(1,N+1):
    hantei = True
    for j in l[i]:
        if h[i-1] <= h[j-1]:
            hantei = False
            break
    if hantei:
        ans += 1
print(ans)

Solution (Python):
from collections import deque
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[0 for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  ab[a]=max(h[b-1],ab[a])
  ab[b]=max(h[a-1],ab[b])
ans=0
for i in range(1,n+1):
  if h[i-1]>ab[i]:
    ans+=1
print(ans)

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

Solution (Python):
from sys import stdin


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



good = [1]*n

for i in range(m):
    a,b = map(int, stdin.readline().rstrip().split())
    if h[a-1] < h[b-1]:
        good[a-1] = 0
    elif h[a-1] > h[b-1]:
        good[b-1] = 0
    else:
        good[a-1] = good[b-1] = 0

print(good.count(1))

Solution (Python):
import numpy as np
import sys
import math
read = sys.stdin.readline

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

t = [0] * N 
for m in range(M):
    if H[ lo[m][0] - 1 ] > H[ lo[m][1] - 1 ]:
        if t[lo[m][0] - 1 ] != -1 :
            t[lo[m][0] - 1] = 1
        t[lo[m][1] - 1] = -1
        continue 

    if H[ lo[m][0] - 1 ] < H[ lo[m][1] - 1 ]:
        if t[lo[m][1] - 1 ] != -1 :
            t[lo[m][1] - 1] = 1
        t[lo[m][0] - 1] = -1
        continue 

    if H[ lo[m][0] - 1 ] == H[ lo[m][1] - 1 ]:
        t[lo[m][0] - 1] = -1
        t[lo[m][1] - 1] = -1
        continue 

good = 0
for i in t:
    if i != -1:
        good += 1

print(good)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, m = map(int, readline().split())
    h = [int(i) for i in readline().split()]
    g = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, readline().split())
        g[a-1].append(b-1)
        g[b-1].append(a-1)
    cnt = 0
    for i in range(n):
        hi = h[i]
        f = True
        for j in g[i]:
            hj = h[j]
            if hi <= hj:
                f = False
        if f:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Solution (Python):

n, m = map(int, input().split())
h = list(map(int, input().split()))
ans = []
for _ in range(m):
    a, b = map(int, input().split())
    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(a-1)
        ans.append(b-1)
print(n - len(set(ans)))

Solution (Python):
n,m = map(int,input().split())
h_inputs = [int(i) for i in input().split()]
ab_inputs = [[int(j) for j in input().split()]for i in range(m)]

map_li = [1]*n
for line in ab_inputs:
    a,b = line[0],line[1]
    if h_inputs[a-1]>h_inputs[b-1]:
        map_li[b-1]=0
    if h_inputs[a-1]<h_inputs[b-1]:
        map_li[a-1]=0
    if h_inputs[a-1]==h_inputs[b-1]:
        map_li[a-1]=0
        map_li[b-1]=0
print(sum(map_li))

Solution (Python):


N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A, B = [], []
for m in range(M):
    A_m, B_m = list(map(int, input().split()))
    A.append(A_m)
    B.append(B_m)


observatory = [True for n in range(N)]
for A_m, B_m in zip(A, B):
    lower_observatory = int()
    if H[A_m-1] < H[B_m-1]:
        observatory[A_m-1] = False
    elif H[A_m-1] > H[B_m-1]:
        observatory[B_m-1] = False
    else:
        observatory[A_m-1] = False
        observatory[B_m-1] = False

result = sum(observatory)


print(result)

Solution (Python):
N,M = map(int,input().split())
h_arr = [0] + list(map(int,input().split()))
c_arr = h_arr.copy()
cnt_arr = [0]*(N+1)
for _ in range(M):
  a,b = map(int,input().split())
  if h_arr[b]>=c_arr[a]:
    c_arr[a] = -1
  if h_arr[a]>=c_arr[b]:
    c_arr[b] = -1

print(N-c_arr.count(-1))

Solution (Python):
n, m = tuple(map(int, input().split()))
h = list(map(int, input().split()))
ans = set([])

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

print(n-len(ans))

Solution (Python):
n, h = map(int, input().split())
li = list(map(int, input().split()))
li_a = [[0] for i in range(n)]
for i in range(h):
  a, b = map(int, input().split())
  li_a[a-1].append(li[b-1])
  li_a[b-1].append(li[a-1])
ans = 0
for j in range(n):
  if li[j] > max(li_a[j]):
    ans += 1
print(ans)

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

for _ in range(m):
    ab.append(list(map(int, input().split())))

for i in range(m):
    vt[ab[i][0]-1].add(ab[i][1]-1)
    vt[ab[i][1]-1].add(ab[i][0]-1)

for i in range(n):
    max_around = 0
    for v in vt[i]:
       if max_around < h[v]:
           max_around = h[v]
    if h[i] > max_around:
        ans += 1

print(ans)

Solution (Python):
n, m = map(int, input().split())
graph = [[] for i in range(n)]
height = [int(h) for h in input().split()]
for j in range(m):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
graph_ = [set(graph[i]) for i in range(n)] 
ans = 0
for i in range(n):
    h = height[i]
    flag = True
    if graph_[i] == {}:
        ans += 1
    else:
        for j in graph_[i]:
            if h <= height[j]:
                flag = False
                break
        if flag:
            ans += 1
print(ans)

Solution (Python):
import sys

N, M = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))
A = []
B = []
for i in range(M):
    temp_A, temp_B = map(int, sys.stdin.readline().split())
    A.append(temp_A)
    B.append(temp_B)

dame = []
for i in range(M):
    if H[B[i]-1] > H[A[i]-1]:
        dame.append(A[i])
    if H[A[i]-1] > H[B[i]-1]:
        dame.append(B[i])
    if H[A[i]-1] == H[B[i]-1]:
        dame.append(A[i])
        dame.append(B[i])
print(N - len(set(dame)))

Solution (Python):
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ok = [0]*n
count = 0
check = [0]*n
for i in range(m):
    x, y = list(map(int, input().split()))
    if h[x-1] > h[y-1]:
        ok[x-1] += 1
    if h[y-1] > h[x-1]:
        ok[y-1] += 1
    check[x-1] += 1
    check[y-1] += 1

for i in range(n):
    if check[i] == ok[i]:
        count += 1



print(count)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
X = {}
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if not a in X:
        X[a] = [b]
    else:
        X[a].append(b)

    if not b in X:
        X[b] = [a]
    else:
        X[b].append(a)

ans = 0
for k, vs in X.items():
    temp = 0
    for v in vs:
        temp = max(temp, H[v])
    if H[k] > temp:
        ans += 1

print(ans + N - len(X))

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

Solution (Python):
N,M = list(map(int, input().split()))
H = list(map(int, input().split()))
A = [0 for i in range(M)]
B = [0 for i in range(M)]
for i in range(M):
    A[i],B[i] = list(map(int, input().split()))
lookup_points = [True for i in range(N)]
for i in range(M):
    if H[A[i]-1] > H[B[i]-1] :
        lookup_points[B[i]-1] = False
    elif H[A[i]-1] == H[B[i]-1]:
        lookup_points[A[i]-1] = False
        lookup_points[B[i]-1] = False
    else:
        lookup_points[A[i]-1] = False
count = 0
for point in lookup_points:
    if point :
        count += 1
print(count)

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())
  
C = [1]*N
  
for i in range(M):
  if H[A[i]-1] < H[B[i]-1]:
    C[A[i]-1] = 0
  elif H[A[i]-1] == H[B[i]-1]:
    C[A[i]-1] = 0
    C[B[i]-1] = 0
  else:
    C[B[i]-1] = 0
    
print(int(sum(C)))

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

l=[]
for a in [int(i) for i in input().split()]:
  l.append(a)

ans_list=[1]*n  
  
for _ in range(m):
  a,b=(map(int,input().split()))
  if l[a-1]<l[b-1]:
    ans_list[a-1]=0
  elif l[a-1]==l[b-1]:
    ans_list[a-1]=0
    ans_list[b-1]=0
  else:
    ans_list[b-1]=0
  

print(sum(ans_list))

Solution (Python):
import copy
n, m = map(int, input().split())
H = list(map(int, input().split()))
ANS = copy.deepcopy(H)

for i in range(m):
  a, b = map(int, input().split())
  if H[a-1] > H[b-1]:
    ANS[b-1] = 0
  elif H[a-1] == H[b-1]:
    ANS[a-1] = 0
    ANS[b-1]= 0
  else:
    ANS[a-1] = 0
ans = 0
for i in range(n):
  if ANS[i] != 0:
    ans += 1
print(ans)

Solution (Python):
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n,m =I2()
    h = Intl()
    l = [[] for i in range(n)]
    cnt = 0
    for i in range(m):
        a,b = I2()
        l[a-1].append(b)
        l[b-1].append(a)
    
    for i in range(n):
        if len(l[i]) == 0:
            cnt +=1
            continue
        
        for j in l[i]:
            if h[i] > h[j-1]:
                f = True
            else:
                f = False
                break
        if f:cnt += 1
    print(cnt)

Solution (Python):
from test.support import ALWAYS_EQ
mNM = map(int, input().split())
lNM = list(mNM)

mHigh = map(int, input().split())
lHigh = list(mHigh)
lNum = [1 for i in range(lNM[0])]

for i in range(lNM[1]):
    mWay = map(int, input().split())
    lWay = list(mWay)
    if lHigh[lWay[0]-1] > lHigh[lWay[1]-1]:
        lNum[lWay[1]-1] = 0
    elif lHigh[lWay[0]-1] < lHigh[lWay[1]-1]:
        lNum[lWay[0]-1] = 0
    elif lHigh[lWay[0]-1] == lHigh[lWay[1]-1]:
        lNum[lWay[0]-1] = 0
        lNum[lWay[1]-1] = 0

print(sum(lNum))

Solution (Python):

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


ab = list(map(list, set(map(tuple, ab))))
tmp2 = len(ab)


ans = 0
flag = [0 for _ in range(n)]
count = [0 for _ in range(n)]
for i in range(tmp2):
    
    if h[ab[i][0]-1] < h[ab[i][1]-1]:
        count[ab[i][0]-1] += 1
        count[ab[i][1]-1] += 1
        flag[ab[i][1]-1] += 1
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        count[ab[i][0]-1] += 1
        count[ab[i][1]-1] += 1
        flag[ab[i][0]-1] += 1
    else:
        count[ab[i][0]-1] += 1
        count[ab[i][1]-1] += 1


for i in range(n):
    if flag[i] == count[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
high = [1]*N
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
      high[B-1] = 0
    elif H[A-1] < H[B-1]:
      high[A-1] = 0
    else:
      high[B-1] = 0
      high[A-1] = 0

even = filter(lambda x:x ==1, high)		
print(len(list(even)))

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

H = list(map(int,input().split()))
AB=[list(map(int,input().split())) for i in range(M)]
tenbou_list=[[] for i in range(N)]
for i in AB:
    tenbou_list[i[0]-1].append(i[1]-1)
    tenbou_list[i[1]-1].append(i[0]-1)
count=0
num=0
for i in tenbou_list:
    k=0
    i=list(set(i))
    if len(i)==0:
        count+=1
    else:
        for j in i:
            if H[j]>=H[num]:
                k+=1
                break
        if k==0:
            count+=1
    num+=1
print(count)

Solution (Python):
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    isGood = [1] * N

    for m in range(M):
        a, b = map(int, input().split())
        h_a, h_b = H[a-1], H[b-1]
        if h_a == h_b:
            isGood[a-1] *= 0
            isGood[b-1] *= 0
        elif h_a > h_b:
            isGood[a-1] *= 1
            isGood[b-1] *= 0
        else:
            isGood[a-1] *= 0
            isGood[b-1] *= 1

    print(sum(isGood))


if __name__ == '__main__':
    main()

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

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

ans = 0
for i in range(n):
    now_t = h[i]
    if t[i]:
        if all([now_t > h[tall] for tall in t[i]]):
            ans += 1
    else:
        ans += 1
print(ans)

Solution (Python):

from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]

from collections import defaultdict

def main():
	n,m=nextIntList()
	hs=nextIntList()
	
	pairHeight=defaultdict(lambda:0)
	for mi in range(m):
		a,b=nextIntList()
		
		pairHeight[a]=max(hs[b-1],pairHeight[a])
		pairHeight[b]=max(hs[a-1],pairHeight[b])

	c=0
	for ni in range(1,n+1):
		if pairHeight[ni]<hs[ni-1]:
			c+=1
			
	print(c)
	

if __name__=="__main__":
	main()

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

Solution (Python):



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

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



result=[1]*n

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

    if h[a]<h[b]:
        result[a]=0
    elif h[b]<h[a]:
        result[b]=0
    else:
        result[a]=0
        result[b]=0


cnt=0
for item in result:
    if item==1:
        cnt+=1


print(cnt)

Solution (Python):
N, M = [int(i) for i in input().split()]
H = {i: int(h) for i, h in enumerate(input().split(), 1)}
t = {k: 0 for k in H.keys()}

for _ in range(M):
    A, B = [int(i) for i in input().split()]
    t[A] = max(H[B], t[A])
    t[B] = max(H[A], t[B])

print(sum(H[k] > v for k, v in t.items()))

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

for n in range(N):
    neib[n]=[]



for m in range(M):
    A, B = map(int, input().split())
    neib[A-1].append(H[B-1])
    neib[B-1].append(H[A-1])
    
count = 0



for k, v in neib.items():
    if len(v)==0:
        count += 1
    elif H[k] > max(v):
        count += 1
print(count)

Solution (Python):
NM = input().split()
N = int(NM[0])
M = int(NM[1])
L = input().split()
H_list = list(map(int, L))

lower_set = set() 

for i in range(M):
    AB = input().split()
    A_offset = int(AB[0]) - 1
    B_offset = int(AB[1]) - 1

    if H_list[A_offset] - H_list[B_offset] > 0:
        lower_set.add(AB[1])
    elif H_list[A_offset] - H_list[B_offset] == 0:
        lower_set.add(AB[0])
        lower_set.add(AB[1])
    else:
        lower_set.add(AB[0])

print(N - len(lower_set))

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

Solution (Python):
N, M = map(int, input().split())
dd = {}
for i in range(1, N+1):
    dd[i] = []
temp = list(map(int, input().split()))
li_h = [0]
li_h.extend(temp)
for i in range(M):
    a, b= map(int, input().split())
    dd[a].append(b)
    dd[b].append(a)

ans = 0
d = {}
for i in range(1, N+1):
    d[i] = True
for i in range(1, N+1):
        if not d:
            continue
        else:
            for k in dd[i]:
                if li_h[k] < li_h[i]:
                    d[k] = False
                elif li_h[k] == li_h[i]:
                    d[k] = False
                    d[i] = False
                    break
                else:
                    d[i] = False
                    break
            if d[i]:
                ans += 1
                
            else:
                continue
print(ans)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
ans = [1] * len(h)

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]:
        ans[b[i]-1] = 0
    elif h[a[i]-1] < h[b[i]-1]:
        ans[a[i]-1] = 0
    else:
        ans[b[i]-1] = 0
        ans[a[i]-1] = 0

print(sum(ans))

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

Tlist = []

for count in range(N):
    Tlist.append([])

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

ans = 0
for count in range(N):
    flag = True
    for count2 in range(len(Tlist[count])):
        if Hlist[count] <= Hlist[Tlist[count][count2]-1]:
            flag = False
            break
    if flag == True:
        ans = ans + 1

print(ans)

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

judge = [1]*N
for i in range(M):
    if H[root[i][0]-1] > H[root[i][1]-1]:
        judge[root[i][1]-1] = 0
    elif H[root[i][0]-1] < H[root[i][1]-1]:
        judge[root[i][0]-1] = 0
    else:
        judge[root[i][0] - 1] = 0
        judge[root[i][1] - 1] = 0

print(sum(judge))

Solution (Python):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, M = MAP()
H = LIST()
lights = [0] * N
for _ in range(M):
    a, b = MAP()
    a -= 1; b -= 1
    if lights[a] == 0:
        if H[a] <= H[b]:
            lights[a] += 1
    if lights[b] == 0:
        if H[b] <= H[a]:
            lights[b] += 1

print(lights.count(0))

Solution (Python):

import sys


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    mountains = {i:'WIN' for i in range(N)}
    for road in range(M):
        if H[A[road]] < H [B[road]]:
            mountains[A[road]] = 'LOSE'
        elif H[A[road]] == H[B[road]]:
            mountains[A[road]] = 'LOSE'
            mountains[B[road]] = 'LOSE'
        elif H[A[road]] > H[B[road]]:
            mountains[B[road]] = 'LOSE'
    count = 0
    for i in range(N):
        if mountains[i] == 'WIN':
            count += 1
    print(count)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    H = [int(next(tokens)) for _ in range(N)]  
    A = [int()] * (M)  
    B = [int()] * (M)  
    for i in range(M):
        A[i] = int(next(tokens)) - 1
        B[i] = int(next(tokens)) - 1
    solve(N, M, H, A, B)

if __name__ == '__main__':
    main()

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


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



data = []

for i in range(N):
  data.append([])


  
for i in range(M):
  way1, way2 = map(int, input().split(" "))
  data[way1-1].append(way2)
  data[way2-1].append(way1)

  
count = 0
for i in range(N):
  is_higher = False
  mountain_hights = [0]
  for j in data[i]:
    mountain_hights.append(H[j - 1])
  if H[i] > max(mountain_hights):
    count += 1

print(count)

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

h = list(map(int,input().split()))
for i in range(1,m+1):
  ab = list(map(int,input().split()))
  if (h[ab[0]-1] > h[ab[1]-1]):
    tenbou[ab[1]-1]=0
  if (h[ab[0]-1] < h[ab[1]-1]):
    tenbou[ab[0]-1]=0
  if (h[ab[0]-1] == h[ab[1]-1]):
    tenbou[ab[0]-1]=0
    tenbou[ab[1]-1]=0   


print(tenbou.count(1))

Solution (Python):
N, M = map(int, input().split())
H = [0] + list(map(int, input().split())) 
AB = [tuple(map(int, input().split())) for _ in range(M)]
good_num = N
pair = [set(e)  for e in set(AB)]
bad_tenbodai = []
for a,b in pair:
    i, j = H[a], H[b]
    if i < j:
        bad_tenbodai.append(a)
    elif i == j:
        bad_tenbodai.extend([a,b])
    else:
        bad_tenbodai.append(b)
print(N - len(set(bad_tenbodai)))

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    h=LIST()
    hantei=[1]*n
    for i in range(m):
        a,b=INTM()
        a=a-1
        b=b-1
        if h[a]>h[b]:
            hantei[b]=0
        elif h[a]<h[b]:
            hantei[a]=0
        else:
            hantei[a]=0
            hantei[b]=0
    print(sum(hantei))

    
if __name__ == '__main__':
    do()

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

s = set()
for i in range(M):
  a = A[i]-1
  b = B[i]-1
  if H[a]>H[b]:
    s.add(b)
  elif H[a] == H[b]:
    s.add(a)
    s.add(b)
  else:
    s.add(a)
print(N - len(s))

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

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

print(res_count.count(0))

Solution (Python):
n,m=map(int,input().split())
h=[int(x) for x in input().split()]
s=[1]*n
for c in range(m):
    a=[int(x)-1 for x in input().split()]
    if h[a[0]]>h[a[1]]:
        s[a[1]]=0
    elif h[a[0]]<h[a[1]]:
        s[a[0]]=0
    else:
        s[a[0]]=0
        s[a[1]]=0
print(sum(s))

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

H2_list=[0]*N

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


print(N-H2_list.count(-1))

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

Solution (Python):
N,M = list(map(int,input().split()))
H = list(map(int,input().split()))
R = [[] for i in range(N)]
ans = 0
for i in range(M):
    A,B = list(map(int,input().split()))
    R[A-1].append(B)
    R[B-1].append(A)
for i in range(len(R)):
    if len(R[i]) == 0:
      ans += 1
    for j in range(len(R[i])):
        if H[i] <= H[R[i][j]-1]:
            ans = ans-j
            break
        else:
            ans += 1
        if j == len(R[i])-1:
            ans = ans-j
print(ans)

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

Solution (Python):

N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[[] for i in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
score=0
for i,l in enumerate(L):
    if not l:
        score+=1
        continue
    my_max=H[i]
    is_max=True
    for li in l:
        if H[li]>=my_max:
            is_max=False
            break
    if is_max:
        score+=1
print(score)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]
ab = list(map(list, set(map(tuple, ab))))
ans = [True] * n

for a, b in ab:
    if h[a-1] == h[b-1]:
        ans[a-1] = False
        ans[b-1] = False
    elif h[a-1] < h[b-1]:
        ans[a-1] = False
    else:
        ans[b-1] = False

print(ans.count(True))

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

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

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

print(cnt.count(0))