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

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

path=[[] for i in range(n)]
count = 0

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

for i in range(n):
  c = 0
  for j in path[i]:
    if h[i] > h[j]:
      c += 1
  if c == len(path[i]):
    count += 1
    
         
print(count)

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

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

ans = 0

for i in range(n):
    x = edge[i]
    
    if len(x) == 0:
        ans += 1
        continue
        
    highest = 0
    
    for j in x:
        highest = max(highest,H[j])
        
    if H[i] > highest:
        ans += 1
        
print(ans)

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

Solution (Python):
n, m = map(int, input().split())
h = [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)

cnt = 0
for i in range(1, n + 1):
    is_high = True
    for v in G[i]:
        if h[i] <= h[v]:
            is_high = False
    if is_high:
        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 i in range(M)]
anlist=[1]*N
for i in range(M):
  if H[AB[i][1]-1]>H[AB[i][0]-1]:
    anlist[AB[i][0]-1]=0
  elif H[AB[i][1]-1]<H[AB[i][0]-1]:
    anlist[AB[i][1]-1]=0
  else:
    anlist[AB[i][0]-1]=0
    anlist[AB[i][1]-1]=0
ans=sum(anlist)
print(ans)

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

h = [int(i) for i in input().split()]
judge = [True]*N

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

print(judge.count(True))

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

Solution (Python):
import numpy as np
n,m=map(int,input().split())
height=np.zeros(n)
roads=np.zeros((m,2),dtype=np.int64)
height=list(map(int,input().split()))
for i in range(m):
    roads[i]=list(map(int,input().split()))
flg=np.zeros(n)
for left,right in zip(roads[:,0],roads[:,1]):
    left-=1
    right-=1
    if height[left]<=height[right]:
        flg[left]=1
    if height[right]<=height[left]:
        flg[right]=1
print(np.count_nonzero(flg==0))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
h = [0] + list(map(int, readline().split()))
ab = [list(map(int, readline().split())) for _ in range(m)]
check = [True] * (n + 1)
for a, b in ab:
    if h[a] > h[b]:
        check[b] = False
    elif h[a] < h[b]:
        check[a] = False
    else:
        check[a] = False
        check[b] = False
print(check.count(True) - 1)

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

ans_li = [True]*n
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1

    if h_input[a]>h_input[b]:
        ans_li[b]=False
    if h_input[a]<h_input[b]:
        ans_li[a]=False
    if h_input[a]==h_input[b]:
        ans_li[a]=False
        ans_li[b]=False
print(sum(ans_li))

Solution (Python):


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




good = [1 for i in range(N)]




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


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




  a -= 1
  b -= 1



  if height[a] <= height[b]:
    good[a] = 0

  if height[a] >= height[b]:
    good[b] = 0



print(sum(good))

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



def main():
    N, M = [int(i) for i in input().strip().split()]
    hights = [int(i) for i in input().strip().split()]
    routes = [[int(i) for i in input().strip().split()] for _ in range(M)]

    counter = 0
    ans_table = [1] * N

    for route in routes:
        idx_0 = route[0] - 1
        idx_1 = route[1] - 1
        if hights[idx_0] > hights[idx_1]:
            ans_table[idx_1] = 0
        elif hights[idx_0] < hights[idx_1]:
            ans_table[idx_0] = 0
        else:
            ans_table[idx_0] = 0
            ans_table[idx_1] = 0

    return sum(ans_table)


if __name__ == "__main__":
    print(main())

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


h =  [-1]+list(map(int,input().split()))

s = np.full(n+1,1)
s[0]=0

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

print(sum(s))

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

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

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

cands = set()
for a, b in AB:
	if H[a-1] > H[b-1]:
		cands.add(b)
	elif H[a-1] < H[b-1]:
		cands.add(a)
	else:
		cands.add(a)
		cands.add(b)

print(int(n)-len(cands))

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

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

data=[]
for n in range(N):
  data.append(H[n]-1)
    
for m in range(M):
  a,b=map(int,input().split(' '))
  data[a-1]=max(data[a-1],H[b-1])
  data[b-1]=max(data[b-1],H[a-1])
  
ans=0
for n in range(N):
  if H[n-1]-1==data[n-1]:
    ans+=1
print(ans)

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

Solution (Python):
import sys
from collections import deque
import copy
def main():
    N, M = map(int, input().split())
    H = [int(i) for i in input().split()]
    dp = [[] for i in range(N)]
    color = [0 for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        dp[a].append(b)
        dp[b].append(a)
    count = 0 
    for i in range(N):
        if color[i] == 1:
            continue
        flag = True
        for j in range(len(dp[i])):
            if H[i] <= H[dp[i][j]]:
                flag = False
                break
            else:
                color[dp[i][j]] = 1
        if flag:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

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

edge = [[] for _ in range(n)]

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


cnt = 0

for node in range(n):
    good = True
    for neighbor in edge[node]:
        if hs[node] <= hs[neighbor]:
            good = False
    if good:
        cnt +=1

print(cnt)

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

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

print(sum(f))

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

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

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

res = 0
for i in range(N):
    if roads[i] == [] or Hs[i] > max([Hs[x] for x in roads[i]]):
        res += 1

print(res)

Solution (Python):
N, M = map(int, input().split())
H = [int(i) for i in input().split()]
AB = []
for m in range(M):
  AB.append([int(i) for i in input().split()])
  
s = [1] * N
for m in range(M):
  a = AB[m][0]
  b = AB[m][1]
  if H[a-1] < H[b-1]:
    s[a-1] = 0
  elif H[b-1] < H[a-1]:
    s[b-1] = 0
  elif H[a-1] == H[b-1]:
    s[a-1] = 0
    s[b-1] = 0
    
print(sum(s))

Solution (Python):
def solve(string):
    n, m, *hab = map(int, string.split())
    h, ab = hab[:n], hab[n:]
    t = [True] * n
    for _a, _b in zip(*[iter(ab)] * 2):
        if h[_a - 1] <= h[_b - 1]:
            t[_a - 1] = False
        if h[_a - 1] >= h[_b - 1]:
            t[_b - 1] = False
    return str(sum(t))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

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

good = [True]*n
for route in ab:
    a = route[0]-1
    b = route[1]-1
    if h[a] > h[b]:
        good[b] = False
    elif h[b] > h[a]:
        good[a] = False
    else:
        good[a] = False
        good[b] = False
print(len(list(filter(lambda x: x, good))))

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

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

print(sum(h[x] > max_height_around[x] for x in range(n)))

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

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

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

Solution (Python):
if __name__ == '__main__':

    nm = input()
    nm = nm.split()
    n = int(nm[0])
    m = int(nm[1])

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

    AB = []
    ma = [0]*n
    for i in range(m):
        ab = input()
        ab = ab.split()
        ab = list(map(int,ab))
        ma[ab[0]-1] = max(ma[ab[0]-1],h[ab[1]-1])
        ma[ab[1]-1] = max(ma[ab[1]-1],h[ab[0]-1])

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

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

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

result = N - len(set(no_good))
print(result)

Solution (Python):
def solve(n, m, h, a, b):
    for j in range(m):
        a[j] -= 1
        b[j] -= 1
    E = {i:[] for i in range(n)}
    for x, y in zip(a, b):
        E[x].append(y)
        E[y].append(x)
    ans = 0
    for i in range(n):
        ok = True
        for j in E[i]:
            if h[i] <= h[j]:
                ok = False
        ans += ok
    return ans
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for j in range(m):
    a[j], b[j] = map(int, input().split())
print(solve(n,m, h, a, b))

Solution (Python):
from collections import defaultdict

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

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

ans = n
for i in range(n):
    for couho in roads[i + 1]:
        if h_s[i] <= h_s[couho - 1]:
            ans -= 1
            break

print(ans)

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

no_good = []

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

for i in range(M):
    if H[A[i]-1] > H[B[i]-1]:
        no_good.append(B[i])
    elif H[A[i]-1] < H[B[i]-1]:
        no_good.append(A[i])
    else:
        no_good.append(A[i])
        no_good.append(B[i])

result = N - len(set(no_good))
print(result)

Solution (Python):



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

Kouho = [1]*N

for AiBi in AB:
    if H[AiBi[0]-1] > H[AiBi[1]-1]:
        Kouho[AiBi[1]-1] = 0
    elif H[AiBi[0]-1] < H[AiBi[1]-1]:
        Kouho[AiBi[0]-1] = 0
    else:
        Kouho[AiBi[0]-1] = 0
        Kouho[AiBi[1]-1] = 0

print(sum(Kouho))

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

print(sum(check))

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

way = [set([]) for _ in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    way[a-1].add(b-1)
    way[b-1].add(a-1)

height = [[] for _ in range(N)]
for i in range(N):
    for tower in way[i]:
        height[i].append(H[tower])

ans = 0
for i in range(N):
    if len(way[i]) == 0:
        ans += 1
        
        continue
    if H[i] > max(height[i]):
        ans += 1
        
        
        
print(ans)

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

Solution (Python):
import numpy as np


def main():
    n, m = map(int, input().split())
    hs = list(map(int, input().split()))
    graph = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)

    hs.insert(0, 0)
    hs_arr = np.array(hs)
    ans = 0
    for i, node in enumerate(graph[1:], start=1):
        if np.all(hs[i] > hs_arr[node]):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
H = [int(_) for _ in stdin.readline().rstrip().split()]
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]
ans = [1]*N
for a, b in AB:
    if H[a-1] >= H[b-1]:
        ans[b-1] = 0
    if H[b-1] >= H[a-1]:
        ans[a-1] = 0
print(sum(ans))

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

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

ans = 0 
for i in range(n):
  if ab[i] < h[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 _ in range(M)]

bad = set()
for i in range(M):
    if H[AB[i][0]-1] < H[AB[i][1]-1]:
        bad.add(AB[i][0])
    elif H[AB[i][0]-1] > H[AB[i][1]-1]:
        bad.add(AB[i][1])
    else:
        bad.add(AB[i][0])
        bad.add(AB[i][1])
print(N-len(bad))

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

ans = 0
for i in range(N):
    now_height = H[i]
    flag = True
    for j in graph[i]:
        if now_height <= H[j]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

Solution (Python):
def solve():
    N, M = map(int, input().split())
    height = [int(i) for i in input().split()]
    neighbor = [[-1] for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())
        neighbor[A - 1].append(height[B - 1])
        neighbor[B - 1].append(height[A - 1])

    func = lambda i: 1 if height[i] > max(neighbor[i]) else 0
    count = sum([func(i) for i in range(N)])
    print(count)


if __name__ == '__main__':
    solve()

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

print(sum(result))

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

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

cnt = 0
for v in range(n):
    res = True
    for i in edge[v]:
        if h[v] <= i: res = False
    if res: cnt += 1

print(cnt)

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())
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):
from collections import Counter

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

l = [True]*N

for m in AB:
    if H[m[0]-1] == H[m[1]-1]:
        l[m[0]-1] = False
        l[m[1]-1] = False
    elif H[m[0]-1] > H[m[1]-1]:
        l[m[1]-1] = False
    else:
        l[m[0]-1] = False

print(Counter(l)[True])

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

tower = list(map(int, input().split()))
result = [0]*N
ans = 0

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

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

print(ans)

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

print(c)

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

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

for i in range(M):
    edge = [int(i) - 1 for i in input().split()]
    path_list[edge[0]].append(edge[1])
    path_list[edge[1]].append(edge[0])

path_l = [set(i) for i in path_list]
    
ans = 0
for i, j in enumerate(path_l):
    for k in j:
        if H[i] <= H[k]:
            break
    else:
        ans += 1

print(ans)

Solution (Python):
N,M = map(int,input().split())
H = list(map(int,input().split()))
A = [0]*M
B = [0]*M
Gab = [] 
g = [[] for _ in range(N+1)]
for i in range(M):
    
    

    
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)


ans = 0

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





print(ans)

Solution (Python):

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

a=["0"]*N
for i in range(M):
    if Hlist[A[i]-1]<Hlist[B[i]-1]:
        a[A[i]-1]="-1"
        if not a[B[i]-1]=="-1":
            a[B[i]-1]="+1"
    if Hlist[A[i]-1]>Hlist[B[i]-1]:
        if not a[A[i]-1]=="-1":
            a[A[i]-1]="+1"
        a[B[i]-1]="-1"
    if Hlist[A[i]-1]==Hlist[B[i]-1]:
        a[A[i]-1]="-1"
        a[B[i]-1]="-1"
num=a.count("+1")+a.count("0")
print(num)

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

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

Solution (Python):
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
d = {}
ans = 0
for i in ab:
    a = i[0] - 1
    b = i[1] - 1
    mi = False
    ma = False
    if h[a] == h[b]:
        pass
    elif h[a] > h[b]:
        mi = True
    else:
        ma = True
    if a not in d:
        d[a] = mi
    elif d[a] == True:
        d[a] = mi
    if b not in d:
        d[b] = ma
    elif d[b] == True:
        d[b] = ma
    else:
        pass
for i in d.values():
    if i:
        ans += 1
ans += n - len(d)
print(ans)

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

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

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

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

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

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

print(cnt)

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

Solution (Python):

N, M = map(int, input().split()) 
Hs = list(map(int, input().split())) 
Rs = [] 

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









goods = [True] * N

for r in Rs:
  a, b = r
  if goods[a]:
  	goods[a] = Hs[a]>Hs[b]
  if goods[b]:
  	goods[b] = Hs[b]>Hs[a]

counter = 0
for i in range(N):
  if goods[i]:
    counter += 1

print(counter)

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

ans = {}

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

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

print(N - len(ans))

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

count = 0
for i in range(N):
    if H_val[i] != 0:
        count+= 1

print(count)

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

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

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

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

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

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

x = [1] * N
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] < H[B-1]:
        x[A-1] &= 0
        x[B-1] &= 1
    elif H[A-1] > H[B-1]:
        x[A-1] &= 1
        x[B-1] &= 0
    else:
        x[A-1] &= 0
        x[B-1] &= 0

print(sum(x))

Solution (Python):
import numpy as np
import copy

def main():
    N, M  = list(map(int, input().split()))
    H     = list(map(int, input().split()))
    maxH  = np.zeros(N)

    for itr in range(M):
        A, B = list(map(int, input().split()))
        if H[A- 1] == H[B- 1] :
            maxH[A- 1] = copy.copy(H[A- 1]) + 1
            maxH[B- 1] = copy.copy(H[A- 1]) + 1
        elif H[A- 1] > H[B- 1] :
            if maxH[A- 1] < H[A- 1] :
                maxH[A- 1] = copy.copy(H[A- 1])
            if maxH[B- 1] < H[A- 1] :
                maxH[B- 1] = copy.copy(H[A- 1])
        elif H[A- 1] < H[B- 1] :
            if maxH[A- 1] < H[B- 1] :
                maxH[A- 1] = copy.copy(H[B- 1])
            if maxH[B- 1] < H[B- 1] :
                maxH[B- 1] = copy.copy(H[B- 1])
    
    result = 0
    for itr in range(N):
        if H[itr] == maxH[itr] or maxH[itr] == 0:
            result += 1
    
    print(result)

if __name__ == "__main__":
    main()

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

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

Solution (Python):
NM=list(map(int,input().split()))
H=list(map(int,input().split()))
A=[0 for i in range(NM[0])]
for i in range(NM[1]):
    ab=list(map(int,input().split()))
    A[ab[0]-1]=max(A[ab[0]-1],H[ab[1]-1])
    A[ab[1]-1]=max(A[ab[1]-1],H[ab[0]-1])
d=0
for i in range(NM[0]):
    if(H[i]>A[i]):
        d+=1
print(d)

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

cur = [0]*N
chk = [0]*N
ans = 0

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

    chk[a] += 1
    chk[b] += 1

for i in range(N):
    if cur[i] == chk[i]:
        ans += 1

print(ans)

Solution (Python):
N, M = map(int, input().split())
H = list(map(int, input().split()))
good = set(range(N))
for _ in range(M):
    a, b = [int(x) - 1 for x in input().split()]
    if H[a] < H[b]:
        good -= {a}
    elif H[b] < H[a]:
        good -= {b}
    if H[a] == H[b]:
        good -= {a, b}
print(len(good))

Solution (Python):
import sys
l = sys.stdin.readline().strip()
N, M = map(int, l.split())
impossible = set()

l = sys.stdin.readline().strip()
heights = [-1] + list(map(int, l.split()))

for i in range(M):
    l = sys.stdin.readline().strip()
    A, B = map(int, l.split())
    if A==B:
        continue
    if heights[A] == heights[B]:
        impossible.add(A)
        impossible.add(B)
    elif heights[A] < heights[B]:
        impossible.add(A)
    else:
        impossible.add(B)

print (N - len(impossible))

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

ans={}
for i in range(M):
    a,b=map(int,input().split())
    if hl[a-1]<=hl[b-1]:
        ans[a]=False
    if hl[a-1]>=hl[b-1]:
        ans[b]=False
    

print(N-len(ans))

Solution (Python):

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

dic={}
for i in range(m):
    a,b=map(int,input().split())
    if hl[a-1] <= hl[b-1]:
        dic[a]=False
    if hl[b-1] <= hl[a-1]:
        dic[b]=False

print(n-len(dic))

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

cnt = 0
for i in range(n):
    if all(h[i] > h[j] for j in G[i]):
        cnt += 1
print(cnt)

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

h=list(map(int,input().split()))
G=[[] for i in range(n)]
for _ in range(m):
 x,y=map(int,input().split())
 x=x-1
 y=y-1
 G[x].append(y)
 G[y].append(x)

ans=0

for i in range(n):
 
 for j in G[i]:
  if h[j]>=h[i]:
   break
 else:
  ans=ans+1
print(ans)

Solution (Python):
n,m=map(int,input().split())
mp = {}
arr= [ int(o) for o in input().split()]
for i in range (n):
    mp[i+1]=arr[i]
s = set()

while m>0:
    a,b=map(int,input().split())
    if(mp[a]<mp[b]):
        s.add(a)
    elif(mp[b]<mp[a]):
        s.add(b)
    else:
        s.add(a)
        s.add(b)
    m-=1
print(n-len(s))