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):
s = list(map(int, input().split()))
n = s[0]
m = s[1]

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

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

good = []
for i in range(n):
    good.append(0)

for i in range(m):
    if h[a[i][0] - 1] > h[a[i][1] - 1]:
        good[a[i][1] - 1] = 1
        if good[a[i][0] - 1] != 1:
            good[a[i][0] - 1] = 2
    elif h[a[i][0] - 1] < h[a[i][1] - 1]:
        good[a[i][0] - 1] = 1
        if good[a[i][1] - 1] != 1:
            good[a[i][1] - 1] = 2
    else:
        good[a[i][1] - 1] = 1
        good[a[i][0] - 1] = 1

count = 0
for i in range(n):
    if good[i] == 0 or good[i] == 2:
        count = count + 1

print(count)

Solution (Python):
import itertools

N,M=map(int,input().split())
S=list(map(int,input().split()))
miti=[input().split() for i in range(M)]
miti2= [ flatten for inner in miti for flatten in inner ]
miti2 = [int(i) for i in miti2]
miti3=N-len(set(miti2))

count2=[int(i) for i in range(1,N+1)]

for j in range(0,2*M,2):
  if S[miti2[j]-1]>S[miti2[j+1]-1]:
    count2[miti2[j+1]-1]=0
  elif S[miti2[j]-1]<S[miti2[j+1]-1]:
    count2[miti2[j]-1]=0
  else:
    count2[miti2[j+1]-1]=0
    count2[miti2[j]-1]=0
print(len(set(count2))-1)

Solution (Python):
def resolve():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    not_good = []
    for i in range(M):
        A, B = map(lambda x: int(x) - 1, input().split())
        if H[A] > H[B]:
            not_good.append(B)
        elif H[A] < H[B]:
            not_good.append(A)
        elif H[A] == H[B]:
            not_good.extend([A, B])
    print(N - len(set(not_good)))

resolve()

Solution (Python):



class Node:

    def __init__(self):
        self.comparison_list = []
        
        self.height = 0
        
        self.id_list = []


def main():

    
    s = [int(x) for x in input().split(' ')]
    n = s[0]
    m = s[1]
    h_list = [int(x) for x in input().split(' ')]
    node_list = []
    for h in h_list:
        node = Node()
        
        node.height = h
        node_list.append(node)

    for i in range(m):
        s = [int(x) for x in input().split(' ')]
        a = s[0] - 1
        b = s[1] - 1
        node_list[a].id_list.append(b)
        node_list[b].id_list.append(a)

    for n in node_list:
        if len(n.id_list) == 0:
            n.comparison_list.append(True)
        else:
            n.id_list = list(set(n.id_list))
            
            if len(n.comparison_list) == 0:
                for id in n.id_list:
                    target = node_list[id]
                    if n.height > target.height:
                        n.comparison_list.append(True)
                        target.comparison_list.append(False)                       
                        
                    else:
                        n.comparison_list.append(False)
    
    print(len([x for x in node_list if all(x.comparison_list)]))

if __name__ == '__main__':
    main()

Solution (Python):
def resolve():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * m
    b = [0] * m
    s = [[-1] for j in range(n)]
    ans=0
    x=1
    for i in range(m):
        a[i], b[i] = map(int, input().split())
    for i in range(m):
        s[a[i]-1].append(b[i])
        s[b[i]-1].append(a[i])
    for i in range(n):
        if len(s[i])!=1:
            for j in s[i]:
                if j!=-1:
                    if h[i]<=h[j-1]:
                        x=0
        ans+=x
        x=1
    print(ans)
resolve()

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

A=[0 for _ in range(M)]
B=[0 for _ in range(M)]
for m in range(M):
    A[m],B[m]=map(int,input().strip().split())

R=[[] for _ in range(N)]
for i in range(M):
    R[A[i]-1].append(B[i])
    R[B[i]-1].append(A[i])

best=0
for i in range(len(R)):
    biggest=True
    if len(R[i])==0:
        pass
    else:
        for j in range(len(R[i])):
            if H[i]<=H[R[i][j]-1]:
                biggest=False
    if biggest==True:
        best+=1

print(best)

Solution (Python):


import copy
n, m = map(int, input().split())
H = list(map(int, input().split()))
A = []
for i in range(m):
    A.append(list(map(int,input().split())))

T = copy.copy(H)


for i in range(m):
    if H[A[i][0]-1] > H[A[i][1]-1]:
        T[A[i][1]-1] = 0
    elif H[A[i][0]-1] < H[A[i][1]-1]:
        T[A[i][0]-1] = 0
    else:
        T[A[i][0]-1] = 0
        T[A[i][1]-1] = 0
    
cnt = 0    
for i in range(n):
    if T[i] != 0:
        cnt = cnt + 1
print(cnt)

Solution (Python):
N,M =  map(int, input().split())
HList = input().split(" ")
ABHash = {}
for i in range(M) :
    A,B = map(int, input().split())
    A = A-1
    B = B-1
    if A not in ABHash :
        ABHash[A] = []
    ABHash[A].append(B)
    if B not in ABHash :
        ABHash[B] = []
    ABHash[B].append(A)

count = 0

for i in range(N) :
    if i not in ABHash :
        count += 1
        continue

    BList = ABHash[i]
    AHeight = int(HList[i])
    isGood = True
    
    for j in range(len(BList)) :
        if AHeight <= int(HList[BList[j]]) :
            isGood = False
    if(isGood) :
        count += 1
print(count)

Solution (Python):
N,M=map(int,input().split())
H=map(int,input().split())
S=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    S[A-1].append(B-1)
    S[B-1].append(A-1)
answer=0
H=[int(h) for h in H]
n=0
for s in S:
    kazu=0
    number=len(s)
    for a in s:
        if H[n] > H[a]:
            kazu+=1
    if kazu==number:
            answer+=1
    n+=1
print(answer)

Solution (Python):
n,m = map(int,input().split())
h = tuple(map(int,input().split()))
l = set([tuple(map(int,input().split())) for i in range(m)])
x = [[] for i in range(n)]
ans=0
for t in l:
    x[t[0]-1].append(h[t[1]-1])
    x[t[1]-1].append(h[t[0]-1])
for k,li in enumerate(x):
    a = h[k]
    if li == []:
        ans+=1
    else:
        if a>max(li):
            ans+=1
print(ans)

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

for i in range(M):
  r,s=input().split()
  r=int(r)-1
  s=int(s)-1
  if H[r]>H[s]:
    my_list[s]=0
  elif H[r]<H[s]:
    my_list[r]=0
  else:
    my_list[r]=0
    my_list[s]=0

count=0
for j in my_list:
  count+=j
print(count)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0]*n
ans = n
for i in range(m):
  b, c = map(int, input().split())
  b -= 1
  c -= 1
  a[b] += 1
  a[c] += 1
  if h[b] == h[c]:
    if a[b] == 1 and a[c] == 1:
      ans -= 2
    elif a[b] == 1 and a[c] != 1:
      ans -= 1
    elif a[b] != 1 and a[c] == 1:
      ans -= 1
  if h[b] > h[c]:
    a[b] -= 1
    if a[c] == 1:
      ans -= 1
  if h[b] < h[c]:
    a[c] -= 1
    if a[b] == 1:
      ans -= 1
print(ans)

Solution (Python):
n,m=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
s=set()
for i in range(m):
	a,b=map(int,input().split())
	if h[a]<=h[b]:s.add(a)
	if h[a]>=h[b]:s.add(b)
print(n-len(s))

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

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

print(sum(l))

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
connection = [0 for _ in range(N)]
cnt = 1
result = 0
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] < H[B-1]:
        connection[A-1] = -1
    elif H[A-1] > H[B-1]:
        connection[B-1] = -1
    else:
        connection[B-1] = -1
        connection[A-1] = -1

for i in connection:
    if i == 0:
        result += 1

print(result)

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

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

tenbo=[1]*N
ABlist=[]
count=N
for i in range(M):
  A,B=map(int,input().split())
  if H[A-1]<H[B-1]:
    tenbo[A-1]=0
  elif H[B-1]<H[A-1]:
    tenbo[B-1]=0
  elif H[A-1]==H[B-1]:
    tenbo[A-1]=tenbo[B-1]=0


print(tenbo.count(1))

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

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

print(k.count(0))

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

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

print(n-len(set(low)))

Solution (Python):
from sys import stdin


def get_result(data):
    N, M = data[0]
    H = data[1]
    adj_list = [set() for _ in range(N)]
    for val in data[2:]:
        adj_list[val[0]-1].add(val[1]-1)
        adj_list[val[1]-1].add(val[0]-1)

    ans = 0
    for i in range(N):
        base_h = H[i]
        flag = True
        edges = adj_list[i]
        for edge in edges:
            h = H[edge]
            if h >= base_h:
                flag = False
                break
        if flag:
            ans += 1
    return ans


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

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


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

for a, b in ab_list:
    if h[a-1] > h[b-1]:
        if b not in all_temboudai:
            continue
        all_temboudai.discard(b)
    elif h[a-1] < h[b-1]:
        if a not in all_temboudai:
            continue
        all_temboudai.discard(a)
    elif h[a-1] == h[b-1]:
        if a in all_temboudai:
            all_temboudai.discard(a)
        if b in all_temboudai:
            all_temboudai.discard(b)

print(len(all_temboudai))

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)]
s = [0 for i in range(n)]
for i in range(m):
    if h[a[i][0]-1] <= h[a[i][1]-1]:
        s[a[i][0]-1] = 1
    if h[a[i][0]-1] >= h[a[i][1]-1]:
        s[a[i][1]-1] = 1
ans = n - sum(s)
print(ans)

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

good = [True] * N

for _ in range(M):
    A, B = tuple(map(int, input().split()))
    H_A, H_B = Hs[A-1], Hs[B-1]
    if H_A < H_B:
        good[A-1] = False
    elif H_B < H_A:
        good[B-1] = False
    else:
        good[A-1] = good[B-1] = False

print(sum([v == True for v in good]))

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [[] for _ in range(n)]
ans = 0
for _ in range(m):
    a, b = map(int, input().split())
    l[a-1].append(h[b-1])
    l[b-1].append(h[a-1])
    
for i in range(n):
    s = h[i]
    x = l[i]
    if len(x) == 0:
        ans += 1
        continue
    if s > max(x):
        ans += 1
print(ans)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
li = list(range(1, n+1))
ng = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] <= h[b-1]:
        ng.append(a)
    if h[b-1] <= h[a-1]:
        ng.append(b)
print(len(list(set(li)-set(ng))))

Solution (Python):


import sys
import math


debug = False

def log(text):
    if debug:
        print(text)


def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        (n, m) = [int(e) for e in lines[0].split(' ')]
        lines.append(input())
        for _ in range(m):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        (n, m) = [int(e) for e in lines[0].split(' ')]

    h_list = [int(e) for e in lines[1].split(' ')]
    ab_list = []
    for i in range(2, m+2):
        ab_list.append([int(e) for e in lines[i].split(' ')])
        
    return (n, m, h_list, ab_list)


def solve(n, m, h_list, ab_list):


    bad_tower = set()
    for j in range(m):

        ab = ab_list[j]
        if h_list[ab[0]-1] <= h_list[ab[1]-1]:
            bad_tower.add(ab[0])
        
        if h_list[ab[1]-1] <= h_list[ab[0]-1]:
            bad_tower.add(ab[1])

        if debug:
            log("j=%d, bad_tower=%s" % (j, bad_tower))
    
    result = n - len(bad_tower)

    return  result


def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Solution (Python):
a,b = map(int, input().split())
List = [list(map(int, input().split())) for i in range(b+1)]

Flag=[1]*a
for i in range(1,b+1):
  m = List[i][0]-1 
  n = List[i][1]-1 
  if List[0][m] < List[0][n]:
    Flag[m]=0
  elif List[0][n] < List[0][m]:
    Flag[n]=0
  elif List[0][n] == List[0][m]:
    Flag[m]=0
    Flag[n]=0
  else:
    print("weird")
Output=Flag.count(1)
print(Output)

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

cnt = 0

lose_flag = [0] * n
for j in range(m):
    if h[a[j]-1] < h[b[j]-1]:
        lose_flag[a[j]-1] = 1
    elif h[a[j]-1] > h[b[j]-1]:
        lose_flag[b[j]-1] = 1
    elif h[a[j]-1] == h[b[j]-1]:
        lose_flag[a[j]-1] = 1
        lose_flag[b[j]-1] = 1

cnt += lose_flag.count(0)

print(cnt)

Solution (Python):
N,K = map(int,input().split())
Hs = list(map(int,input().split()))
outs = [1] * N
for _ in range(K):
    a,b = map(int,input().split())
    if Hs[a-1] == Hs[b-1]:
        outs[a-1] = 0 
        outs[b-1] = 0 
    elif Hs[a-1] > Hs[b-1]:
        outs[b-1] = 0 
    else:
        outs[a-1] = 0 
print(sum(outs))

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

print(cnt)

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


ans = [[] for i in range(n)]
for i in range(m):
  a, b= map(int, input().split())
  ans[a-1].append(b-1)
  ans[b-1].append(a-1)
  
count = 0
for i in range(n):
  flag = True
  for j in ans[i]:
    if h[i] <= h[j]:
      flag = False
  if flag:
    count+=1

print(count)

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

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

Solution (Python):
n, m = map(int, input().split())
h = list(map(int, input().split()))
f = [1]*n
li = []
for i in range(int(m)):
    li.append(list(map(int, input().split())))
    if h[int(li[i][0])-1] > h[int(li[i][1])-1]:
        f[li[i][1]-1] = 0
    elif h[li[i][0]-1] < h[li[i][1]-1]:
        f[li[i][0]-1] = 0
    else:
        f[li[i][1]-1] = 0
        f[li[i][0]-1] = 0

print(f.count(1))

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

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)]
res = [1]*n
for el in ab:
  if h[el[0]-1] >= h[el[1]-1] :
    res[el[1]-1] = 0
  if h[el[0]-1] <= h[el[1]-1] :
    res[el[0]-1] = 0
print(sum(res))

Solution (Python):
N, M = map(int, input().split())
H = tuple(map(int, input().split()))
T = [set() for _ in range(N)]

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

count = 0
for i, t in enumerate(T):
    if not t:
        count+=1
        continue
    else:
        h = H[i]
        if h > max(t):
            count += 1

print(count)

Solution (Python):
import sys
def input():
  return list(map(int, sys.stdin.readline().strip().split()))

n, m = input()
h = input()
tmp = [[] for i in range(n)]
for i in range(m):
  a, b = input()
  tmp[b - 1].append(a - 1)
  tmp[a - 1].append(b - 1)
ans = 0
for i in range(n):
  flag = True
  for ele in tmp[i]:
    if(h[i] <= h[ele]): flag = False
  if(flag): ans += 1
print(ans)

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n, m = nm()
    h = nl()
    ab = []

    for _ in range(m):
        temp = nl()
        ab.append(temp)

    ans = [True] * n

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

    print(ans.count(True))
    

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    tree = [[] for i in range(n)]
    mv = [-1] * (n)
    for i in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)
    ans = 0
    for i in range(n):
        mm = i
        for j in range(len(tree[i])):
            if h[mm] <= h[tree[i][j]]:
                mm = tree[i][j]
        if mm == i:
            ans += 1

    print(ans)


main()

Solution (Python):

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

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

print(check.count(1))

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

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

flag = 0
X = 0

S = [1] * N













for b in grid:
    if H[b[0]-1] > H[b[1]-1]:
        S[b[1]-1] = 0
    elif H[b[0]-1] < H[b[1]-1]:
        S[b[0]-1] = 0
    elif H[b[0]-1] == H[b[1]-1]:
        S[b[0] - 1] = 0
        S[b[1] - 1] = 0

X = sum(S)

print(X)

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

A = []
B = []
for i in range(M):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
C=[1]*N
for i in range(M):
  if H[A[i]-1]>H[B[i]-1]:
    C[B[i]-1]=0
  elif 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
print(len(C)-C.count(0))

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

h = list(map(int, input().split()))
check = [1] * n

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

    if h[a-1] < h[b-1]:
        remove = a-1
        check[remove] = 0
    elif h[a-1] > h[b-1]:
        remove = b-1
        check[remove] = 0
    else:
        check[a-1] = 0
        check[b-1] = 0

ans = check.count(1)

print(ans)

Solution (Python):
n, m = map(int, input().split())
h = list(map(int,input().split()))
ans = [1]*n
for j 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()))
a = []
for i in range(N):
    a.append(1)
for i in range(M):
    A = list(map(int,input().split()))
    if H[A[0]-1] >= H[A[1]-1]:
        a[A[1]-1] = 0
    if H[A[0]-1] <= H[A[1]-1]:
        a[A[0]-1] = 0
ans = 0
for i in range(N):
    ans = ans + a[i]
print(ans)

Solution (Python):
import sys
import itertools

N,M = map(int, sys.stdin.readline().strip().split())
H = list(map(int, sys.stdin.readline().strip().split()))

AB = []
for _ in range(M):
    AB.append(list(map(int, sys.stdin.readline().strip().split())))


ans = N - len(set(itertools.chain.from_iterable(AB)))
n = [[i] for i in range(N)]

for i in AB:
    n[i[0]-1].append(i[1]-1)
    n[i[1]-1].append(i[0]-1)


for i in n:
    me = H[i[0]]
    flag = False
    for j in i[1:]:
        
        if me > H[j]:
            flag = True
            continue
        else:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

Solution (Python):

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


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

print(result.count(1))

Solution (Python):

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

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

ans=0
di = {}

J=[""]*M
for i in range(M):
  a,b=list(map(int, input().split()))
  di.setdefault(a,[])
  di[a].append(b)
  di.setdefault(b,[])
  di[b].append(a)
  


for i in range(1,N+1):
  flg = 0

  if i in di.keys():


    for k in di[i]:
      if H[k-1] >= H[i-1]:
        flg = 1
    if flg == 0:
      ans+=1

  else:
    ans+=1

    
print(ans)

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)]
HH = {i+1 : H[i] for i in range(len(H))}

count = {i+1 : 0 for i in range(N)}
for i in AB:
    if HH[i[1]] > HH[i[0]]:
        count[i[0]] -= 1
    elif HH[i[1]] == HH[i[0]]:
        count[i[0]] -= 1
        count[i[1]] -= 1
    else:
        count[i[1]] -= 1
        
print(sum([1 for i in count.values() if i == 0]))

Solution (Python):
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = []
for i in range(M):
    _A, _B = list(map(int, input().split()))
    AB.append((_A, _B))
bad_tower_set = set()
for ab in AB:
    a, b = ab
    a -= 1
    b -= 1
    if H[a] <= H[b]:
        bad_tower_set.add(a)
    if H[b] <= H[a]:
        bad_tower_set.add(b)
print(N - len(set(bad_tower_set)))

Solution (Python):



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

for i in ab:
    if h[i[0] - 1] > h[i[1] - 1]:
        yama[i[1] - 1] = 0
    elif h[i[0] - 1] < h[i[1] - 1]:
        yama[i[0] - 1] = 0
    else:
        if i[0] != i[1]:
            yama[i[0] - 1] = 0
            yama[i[1] - 1] = 0

sum = 0
for i in yama:
    sum += i
print(sum)

Solution (Python):
import itertools
import numpy as np
N,M = map(int,input().split())
H = list(map(int,input().split()))
n=[1]*N
for i in range(0,M):
    m = list(map(int,input().split()))
    if H[m[0]-1] > H[m[1]-1]:
        n[m[1]-1]=0
    elif H[m[0]-1] == H[m[1]-1]:
        n[m[0]-1]=0
        n[m[1]-1]=0
    else:
        n[m[0]-1]=0
print(n.count(1))

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

ans = [True for _ in range(N)]

for a in arr:
    f, s = a
    H1 = Hs[f - 1]
    H2 = Hs[s - 1]
    if H1 == H2:
        ans[f - 1] = False
        ans[s - 1] = False
    elif H1 < H2:
        ans[f - 1] = False
    else:
        ans[s - 1] = False

print(len(list(filter(lambda x: x, ans))))

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, M = MI()
    H = LI()
    H.insert(0,0)
    A = [0]*M
    B = [0]*M
    ans = 0
    for i in range(M):
        A[i], B[i]=MI()

    Hnum = [0]*(N+1)
    Hnum[0] = 1

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


    """
    for i in range(1,N+1):
        ng = 0
        for j in range(M):
            if A[j] == i:
                if H[i]<=H[B[j]]:
                    ng += 1
                    break
            if B[j] == i:
                if H[i]<=H[A[j]]:
                    ng += 1
                    break
        if ng == 0:
            ans += 1
    print(ans)"""


    


if __name__ == "__main__":
	main()

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

Solution (Python):
n,m = map(int, input().split())
h = [int(_) for _ in input().split()]
l=['good']*n
for x in range(m):
    a,b = map(int, input().split())
    if h[a - 1] > h[b - 1]:
        l[b - 1] = ''
    elif h[b - 1] > h[a - 1]:
        l[a - 1] = ''
    else:
        l[a-1],l[b-1]='',''

print(l.count('good'))

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

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

yoi_warui = [0]*n
dokuritsu = [0]*n

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

print(yoi_warui.count(0))

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
C = []
counter = [0 for i in range(N+1)]
count = [0 for i in range(N+1)]
good = 0
for i in range(M):
    a = tuple(map(int,input().split()))
    a = tuple(sorted(a))
    C.append(a)
C = list(set(C))
for i in range(len(C)):
    count[C[i][0]] += 1
    count[C[i][1]] += 1
    if H[C[i][0]-1] > H[C[i][1]-1]:
        counter[C[i][0]] += 1
    elif H[C[i][0]-1] < H[C[i][1]-1]:
        counter[C[i][1]] += 1
for i in range(1,N+1):
    if counter[i] == count[i]:
        good += 1
print(good)

Solution (Python):
nm = list(map(int, input().split()))
h=list(map(int, input().split()))
tenbou={}
for i in range(1,nm[0]+1):
    tenbou[str(i)]=h[i-1]


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

waruitenbou=[k for k, v in tenbou.items() if v == 0]
print(nm[0]-len(waruitenbou))

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

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

result = [0] * n
for i in range(0, m):
    a, b = map((int),(input().split()))

    if h[a - 1] > h[b - 1]:
        result[b - 1] = 1
    elif h[a -1] < h[b - 1]:
        result[a - 1] = 1
    else:
        result[a - 1] = 1
        result[b - 1] = 1

sum = 0
for j in result:
    if j == 0:
        sum += 1

print(sum)

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


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

lists = [1 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]:
    lists[B] = 0
  elif H[A] == H[B]:
    lists[A] = 0
    lists[B] = 0
  else :
    lists[A] = 0
  
  


sum = 0
for i in range(N):
  if lists[i] == 1 :
    sum += 1
    

print(sum)