Harryxun/stf_run huggingface dataset:
def main():
    M=10**9+7
    n,k,*a=map(int,open(0).read().split())
    x,y=[],[]
    for i in a:
        if i>0:x+=i,
        if i<0:y+=i,
    if len(x)+len(y)<k or k%2 and not x and len(y)<n:
        print(0)
        exit()
    if k%2 and not x:
        c=1
        for i in sorted(y)[-k:]:
            c=c*i%M
        print(c)
        1/0
        exit()
    x=sorted(x)[::-1][:k]
    y.sort()
    m=len(y)
    i=len(x)
    j=0
    if i<k:
        j=k-i
        x+=y[:j]
        j+=1
    while i>1 and j+1<m and x[i-1]*x[i-2]<y[j]*y[j+1]:
        x[i-1],x[i-2]=y[j],y[j+1]
        i-=2
        j+=2
    c=1
    for i in x:
        c=c*i%M
    print(c)
main()

### FIXED CODE ###

def main():
    M=10**9+7
    n,k,*a=map(int,open(0).read().split())
    x,y=[],[]
    for i in a:
        if i>0:x+=i,
        if i<0:y+=i,
    if len(x)+len(y)<k or k%2 and not x and len(y)<n:
        print(0)
        return
    if n==k or k%2 and not x:
        c=1
        for i in sorted(x+y)[-k:]:
            c=c*i%M
        print(c)
        return
    x=sorted(x)[::-1][:k]
    i=len(x)
    y.sort()
    m=len(y)
    j=k-i
    if j%2:
        x=x[:-1]
        i-=1
        j+=1
    x+=y[:j]
    while i>1 and j+1<m and x[i-1]*x[i-2]<y[j]*y[j+1]:
        x[i-1],x[i-2]=y[j],y[j+1]
        i-=2
        j+=2
    c=1
    for i in x:
        c=c*i%M
    print(c)
main()
N = int(input())

if 9 in N :
    print("Yes")
else :
    print("No")

### FIXED CODE ###

N = input()

if "9" in N :
    print("Yes")
else :
    print("No")
import math
S = input()
Q = int(input())

lr = 'left'

def reverse_list(lr):
    if lr == 'right'
        return 'left'
    else return 'right'

def moji_tuika(S, f, c, lr):
    if f == 1 and lr == 'left':
        return c + S
    elif f == 1 and lr == 'right':
        return S + c
    elif f == 2 and lr == 'left':
        return S + c
    else:
        return c + S
q = []
for i in range(Q):
    temp = input().split()
    if len(temp) == 1:
        q.append(1)
    else:
        q.append(temp)

for i in q:
    if type(i) == int:
        lr = reverse_list(lr)
    elif int(i[0]) == 2:
        S = moji_tuika(S,int(i[1]),i[2],lr)

if lr == 'right':
    S = list(S)
    S.reverse()
    S = ''.join(S)


print(S)


### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())

lr = 'left'

def reverse_list(lr):
    if lr == 'right':
        return 'left'
    else:
        return 'right'

def moji_tuika(S, f, c, lr):
    if f == 1 and lr == 'left':
        S.appendleft(c)
    elif f == 1 and lr == 'right':
        S.append(c)
    elif f == 2 and lr == 'left':
        S.append(c)
    else:
        S.appendleft(c)
    return S

q = []
for i in range(Q):
    temp = input().split()
    if len(temp) == 1:
        q.append(1)
    else:
        q.append(temp)

S = deque(list(S))
for i in q:

    if type(i) == int:
        lr = reverse_list(lr)
    elif int(i[0]) == 2:
        S = moji_tuika(S,int(i[1]),i[2],lr)
if lr == 'right':
    S.reverse()

S = ''.join(S)
print(S)
if __name__ == '__main__':                                                                                                                                                  n = int(input())
    vs = list(map(int, input().split()))

    even = vs[::2]
    odd = vs[1::2]

    from collections import Counter

    result = 0
    #evenの処理
    c = Counter(even)
    emode = c.most_common(1)[0][0]
    for i in range(len(even)):
        if even[i] != emode:
            result += 1

    c = Counter(odd)
    if c.most_common(1)[0][0] != emode:
        omode = c.most_common(1)[0][0]
    else:
        if len(c.most_common()) == 1:
            omode = -1
        else:
            omode = c.most_common(2)[0][0]


    for i in range(len(odd)):
        if odd[i] != omode:
            result += 1
if __name__ == '__main__':                                                                                                                                                  n = int(input())
    vs = list(map(int, input().split()))

    even = vs[::2]
    odd = vs[1::2]

    from collections import Counter

    result = 0
    #evenの処理
    c = Counter(even)
    emode = c.most_common(1)[0][0]
    for i in range(len(even)):
        if even[i] != emode:
            result += 1

    c = Counter(odd)
    if c.most_common(1)[0][0] != emode:
        omode = c.most_common(1)[0][0]
    else:
        if len(c.most_common()) == 1:
            omode = -1
        else:
            omode = c.most_common(2)[0][0]


    for i in range(len(odd)):
        if odd[i] != omode:
            result += 1
    print(result)     

### FIXED CODE ###

from collections import Counter

if __name__ == '__main__':
    n = int(input())
    vs = list(map(int, input().split()))

    even = vs[::2]
    odd = vs[1::2]

    def solve(even, odd):
        ce = Counter(even)
        co = Counter(odd)
        
        emode = ce.most_common()
        omode = co.most_common()
        
        result = 0
        if emode[0][0] != omode[0][0]:
            for i in range(1, len(emode)):
                result += emode[i][1]
            for i in range(1, len(omode)):
                result += omode[i][1]
            
            return result
        
        else:
            temp1 = 0
            temp2 = 0
            for i in range(1, len(emode)):
                temp1 += emode[i][1]
            
            if len(omode) == -1:
                temp1 += len(odd)
            else:
                for i in range(len(omode)):
                    if i == 1:
                        continue
                    else:
                        temp1 += omode[i][1]
                        
                        
            for i in range(1, len(omode)):
                temp2 += omode[i][1]
            
            if len(emode) == -1:
                temp2 += len(even)
            else:
                for i in range(len(emode)):
                    if i == 1:
                        continue
                    else:
                        temp2 += emode[i][1]
            result = min(temp1, temp2)
            
            return result
        
    print(solve(even, odd))
N=input()
ans=(N+1)//2
print(ans)

### FIXED CODE ###

N=int(input())
import math
ans=math.ceil(N/2)
print(ans)
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

B = []
C = []

l = []

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

    B.append(b)
    C.append(c)

t = 0

for i in A:
    if i > t:
        t = i

for i in range(t + 1):
    l.append(i)
    l[i] = 0

for i in A:
    l[i] = l[i] + 1

for i in range(Q):
    t = l[B[i]]
    l[B[i]] -= t
    l[C[i]] += t

    res = 0
    for num in range(len(l)):
        res += num * l[num]

    print(res)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

B = []
C = []

l = {}

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

    B.append(b)
    C.append(c)

res = 0
for i in A:
    if i in l:
        l[i] += 1
    else:
        l[i] = 1

    res += i

t = 0
for i in range(Q):
    if B[i] in l:
        t = l[B[i]]


        res += (C[i] - B[i]) * t

        l[B[i]] = 0
        if C[i] in l:
            l[C[i]] += t
        else:
            l[C[i]] = t

    print(res)
s = input()
dict = {'A':'T','T':'A','G':'C','C':'G'}
print(dict(s))

### FIXED CODE ###

s = input()
dict = {'A':'T','T':'A','G':'C','C':'G'}
print(dict[s])
s=input()
l=['A','C','G','T']
index_s=[]
count=0
for i in range(len(s)):
    if s[i] not in l:
        index_s+=[i]
    
    else:
        count+=1
        if count==len(s):
            print(len(s))
            exsit()
    
ans=[index_s[0]]
for i in range(len(index_s)-1):
    ans+=[index_s[i+1]-index_s[i]-1]

ans.sort()    
print(ans[-1])

### FIXED CODE ###

s=input()
l=['A','C','G','T']
len_s=[]
count=0
for i in range(len(s)):
    if s[i] in l and i!=len(s)-1:
        count+=1
    elif s[i] not in l:
        len_s+=[count]
        count=0
    else:
        count+=1
        len_s+=[count]
print(max(len_s))
def resolve():
    A, B, C, D = map(int, input().split())
    d = D
    c = C
    gcd = 0
    while gcd == 0:
        if d % c == 0:
            gcd = c
            break
        else:
            d = c
            c = d % c
    lcm = C*D//gcd
    A = A-1
    print((B-B//C-B//D+B//lcm)-(A-A//C-A//D+A//lcm))
resolve()

### FIXED CODE ###

def resolve():
    A, B, C, D = map(int, input().split())
    d = D
    c = C
    gcd = 0
    while gcd == 0:
        if d % c == 0:
            gcd = c
        else:
            e = d%c
            d = c
            c = e
    lcm = C*D//gcd
    A = A-1
    print((B-B//C-B//D+B//lcm)-(A-A//C-A//D+A//lcm))
resolve()
def soma(a):
    res=0
    for i in range(0, len(a)):
        res+=int(a[i])

    if(res>=10):
        return soma(str(res))

    return res

def main():
    n = int(input())
    menor = soma("1")+soma(str(n-1))
    
    for i in range(1,10):
        if(soma(str(i))+soma(str(n-i))<menor):
            menor = soma(str(i))+soma(str(n-i))

    print(menor,"\n")
    
main()


### FIXED CODE ###

#!/usr/bin/python
# -*- coding: utf-8 -*-

n=int(raw_input())
maxv=n
for a in xrange(1,n):
  b=n-a
  if a>b: break
  sa=sum([int(x) for x in str(a)])
  sb=sum([int(x) for x in str(b)])
  maxv=min(maxv, sa+sb)
print(maxv)
n = int(input())
a = map(int, input().split())
*a_abs, = map(abs, a)
if len([i for i in a if i<0])%2 ==0:
    print(sum(a_abs))
else:
    print(sum(a_abs)-2*min(a_abs))

### FIXED CODE ###

a, b, t = map(int, input().split())
cnt = 0
temp = a
while t+0.5 > temp:
    cnt += 1
    temp += a
print(b*cnt)
s=input()

print(s[0]+len(s)+s[-1])

### FIXED CODE ###

s=input()

print(s[0],end="")
print(len(s)-2,end="")
print(s[-1])
def solve(N, K, As):
    alls = []
    for i in range(N):
        for j in range(i + 1, N + 1):
            alls.append("{:061b}".format(sum(As[i:j])))
    print("alls", len(alls))
    def find(i, alls):
        if i > 60:
            return []
        ones = [a for a in alls if a[i] == "1"]
        if len(ones) < K:
            return find(i + 1, alls)
        elif len(ones) == K:
            return ones
        elif len(ones) > K:
            ret = find(i + 1, ones)
            if len(ret) == 0:
                return ones[0:K]
            else:
                return ret

    ans = find(0, alls)
    if len(ans):
        a = 0xFFFFFFFFFFF
        for p in ans:
            a &= int(p, 2)
        return a
    else:
        return 0

if __name__ == "__main__":
    l = input()
    N = int(l.split(" ")[0])
    K = int(l.split(" ")[1])
    As = [int(c) for c in input().split()]
    print(solve(N, K, As))


### FIXED CODE ###

def solve(N, As):
    avg = sum(As) / N
    return min([(abs(c - avg), i) for i, c in enumerate(As)])[1]

if __name__ == "__main__":
    N = int(input())
    As = [int(c) for c in input().split()]
    print(solve(N, As))
str = input()
k = int(input())

strl = []
for c in str:
    if(not (c in strl)):
        strl.append(c)
strl.sort()

substring = []
for h in strl:
	sub = str.find(h)
	for i in range(sub, len(str)-1):
		t = str[sub:i+1]
		if(not (t in substring)):
			substring.append(t)
		# substring.sort()
		# if(substring[k-1] is str[sub:i+1]):
			# break
	# else:
		# continue
	# break


substring.sort()
print(substring[k-1])

### FIXED CODE ###

import re

str = input()
k = int(input())

strl = list(set([c for c in str]))
strl.sort()

substring = []
for h in strl:
	compiled = re.compile(h)
	st = 0
	m = compiled.search(str, st)
	while m:
		sub = m.start()
		for i in range(sub, min(len(str), sub+5)):
			t = str[sub:i+1]
			if(not (t in substring)):
				substring.append(t)
		st = sub + 1
		m = compiled.search(str, st)
	
	if(len(substring)-len(strl) >= k-1):
		break


substring.sort()
print(substring[k-1])
a, b = map(input().split())
print ("H" if a == "H" and b == "H" else "H" if a == "D" and b == "D" else "D")

### FIXED CODE ###

a, b = input().split()
print ("H" if a == "H" and b == "H" else "H" if a == "D" and b == "D" else "D")
%%cython
cdef int solve(int a, int b):
    return a*b

def main():
    a, b = map(int, input())
    print(solve(a,b))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    A, B = map(int, input().split())
    print(A * B)


if __name__ == '__main__':
    solve()
N, K = map(int, input().split())
ans = 0
extra = [0]*N
for i in range(1, N+1): extra[i%K] += 1 #extra[X] = Kで割ってXあまる数がN以下に何個あるか

for a in range(K):
    b = (K-a) % K
    c = (K-a) % K

    if (b + c) % K == 0:
        ans += extra[a] * extra[b] * extra[c]
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
ans = 0
extra = [0]*K
for i in range(1, N+1): extra[i%K] += 1 #extra[X] = Kで割ってXあまる数がN以下に何個あるか

for a in range(K):
    b = (K-a) % K
    c = (K-a) % K

    if (b + c) % K == 0:
        ans += extra[a] * extra[b] * extra[c]
print(ans)
a = input().split("/")
if a[1] <= 4:
    print('Heisei')
else:
    print('TBD')


### FIXED CODE ###

S = input().split("/")
if int(S[1]) < 5:
    print("Heisei")
else:
    print("TBD")
# -*- coding: utf-8 -*-
"""
D - Ki
https://atcoder.jp/contests/abc138/tasks/abc138_d

"""
import sys


from functools import lru_cache

def solve(N, Q):
    @lru_cache(maxsize=None)
    def calc_score(n):
        if n == 1 or nodes[n][3] == True:
            return nodes[n][0]
        res = calc_score(nodes[n][2]) + nodes[n][0]
        nodes[n][3] = True
        return res

    nodes = [[0, -1, -1, False] for _ in range(N+1)]

    for _ in range(N-1):
        a, b = map(int, input().split())
        nodes[b][2] = a
    for _ in range(Q):
        p, x = map(int, input().split())
        nodes[p][0] += x
    ans = [calc_score(i) for i in range(1, N+1)]
    return ans


def main(args):
    N, Q = map(int, input().split())
    ans = solve(N, Q)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])


### FIXED CODE ###

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]
 
sys.setrecursionlimit(1000000)
mod = 1000000007
 
#A
def A():
    a = I()
    s = input()
    if a >= 3200:
        print(s)
    else:
        print("red")
    return
 
#B
def B():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans += 1/i
    print(1/ans)
    return
 
#C
def C():
    n = I()
    v = LI()
    q = []
    for i in v:
        heappush(q,i)
    while q:
        x = heappop(q)
        if not q:
            print(x)
            return
        y = heappop(q)
        heappush(q,(x+y)/2)
    return
 
#D
def D():
    def dfs(x,d,s):
        for y in v[x]:
            if d[y]:
                s += f[y]
                ans[y] = s
                d[y] = 0
                dfs(y,d,s)
                s -= f[y]
    n,q = LI()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    f = [0]*n
    for i in range(q):
        p,x = LI()
        p -= 1
        f[p] += x
    ans = [0]*n
    d = [1]*n
    d[0] = 0
    ans[0] = f[0]
    s = f[0]
    dfs(0,d,s)
    print(*ans)
    return
 
#E
def E():
    s = input()
    t = input()
 
    return
 
#F
def F():
 
    return
 
#Solve
if __name__ == "__main__":
    D()
n, k = map(int, input().split())
nums = list(map(int, input().split()))

e_nums = [(i+1)/2 for i in nums]

sum_e = [sum(e_nums[i:i+k]) for i in range(n) if i+k <= n-1]

print(max(sum_e))


### FIXED CODE ###

n, k = map(int, input().split())
nums = list(map(int, input().split()))
 
sum_max = sum(nums[:k])
temp = sum_max
for i in range(k,n):
  temp -= nums[i-k]
  temp += nums[i]
  sum_max = max(temp, sum_max)
print((sum_max +k)/2)
import itertools
import sys
N,M=map(int,input().split())
dic={}
for _ in range(N):
    a,b=map(int,input().split())
    if(a in dic.keys()):
        if((b in dic[a])==False):
            dic[a].append(b)
    else:
        dic[a]=[b]
    if(b in dic.keys()):
        if((a in dic.values())==False):
            dic[b].append(a)
    else:
        dic[b]=[a]

if(M==0):
    print(0)
    sys.exit()

node=[i for i in range(N)]
ans=0
strokes=itertools.permutations(node,M)

def judge(A,B):
    values=dic[A]
    if(B in values):
        return True
    else:
        return False

for stroke in strokes:
    stroke=list(stroke)
    if(stroke[0]==0):
        pre=stroke.pop(0) + 1
        for s in stroke:
            if(judge(pre,s+1)==False):
                break
            pre=s+1
        else:
            ans+=1
    
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
cnt = [0]
def dfs(V, s):
    V[s] = 1
    if sum(V) == N:
        cnt[0] += 1                    
    else:
        for adj in G[s]:
            if V[adj] == 0:             
                dfs(V[:adj] + [1] + V[adj + 1:], adj)  #ここで分岐がたくさん発生する
dfs([0] * N, 0)
print(cnt[0])
s=input()
rl=[]
ll=[]
c=0
for i in range(len(s)-1):
  c+=1
  if s[i]!=s[i+1]:
    if s[i]=='<':
      rl.append(c)
    else:
      ll.append(c)
    c=0
if s[len(s)-1]=='<':
  rl.append(c+1)
else:
  ll.append(c+1)

rn=len(rl)
ln=len(ll)
ans=0
if s[0]=='<':
  for i in range(ln):
    M=max(rl[i], ll[i])
    m=min(rl[i], ll[i])
    ans+=M*(M+1)//2+m*(m-1)//2
  if rn>ln:
    ans+=rl[-1]*(rl[-1]+1)//2
else:
  ans+=ll[0]*(ll[0]+1)//2
  for i in range(rn-1):
    M=max(rl[i], ll[i+1])
    m=min(rl[i], ll[i+1])
    ans+=M*(M+1)//2+m*(m-1)//2
  if rn==ln:
    ans+=rl[-1]*(rl[-1]+1)//2
  else:
    M=max(rl[-1], ll[-1])
    m=min(rl[-1], ll[-1])
    ans+=M*(M+1)//2+m*(m-1)//2
print(ans)

### FIXED CODE ###

s=input()
rl=[]
ll=[]
c=0
for i in range(len(s)-1):
  c+=1
  if s[i]!=s[i+1]:
    if s[i]=='<':
      rl.append(c)
    else:
      ll.append(c)
    c=0
if s[len(s)-1]=='<':
  rl.append(c+1)
else:
  ll.append(c+1)

rn=len(rl)
ln=len(ll)
ans=0
if s[0]=='<':
  for i in range(ln):
    M=max(rl[i], ll[i])
    m=min(rl[i], ll[i])
    ans+=M*(M+1)//2+m*(m-1)//2
  if rn>ln:
    ans+=rl[-1]*(rl[-1]+1)//2
else:
  rl=[0]+rl
  ans+=ll[0]*(ll[0]+1)//2
  for i in range(1, ln):
    M=max(rl[i], ll[i])
    m=min(rl[i], ll[i])
    ans+=M*(M+1)//2+m*(m-1)//2
  if rn==ln:
    ans+=rl[-1]*(rl[-1]+1)//2
print(ans)
while 1:
  x,y = map(int,input().split())
  if x==0 and y==0:
    break
  else:
    n=[x,y]
    n.sort()
    print n[0],n[1]
 

### FIXED CODE ###

while 1:
  x,y = map(int,raw_input().split())
  if x==0 and y==0:
    break
  else:
    n=[x,y]
    n.sort()
    print n[0],n[1]
import numpy as np

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

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)

### FIXED CODE ###

x = list(map(int, input().split()))
for i in range(len(x)):
    if x[i] == 0:
        print(i+1)
def main():
    nums = sorted([int(i) for i in input().split()], reverse=True)
    max_num = 10 * nums[0] + nums[1] + nums[2]
    print(max_num)


if __name__ == '__main__':
    main()
Fujitakes-MacBook-Pro:tmp mas

### FIXED CODE ###

def main():
    nums = sorted([int(i) for i in input().split()], reverse=True)
    max_num = 10 * nums[0] + nums[1] + nums[2]
    print(max_num)


if __name__ == '__main__':
    main()
import string

S = input()

abc = [chr(i) for i in range(97, 97+26)]

if len(S) < 26:
    for s in S:
        abc.remove(s)
    add = abc[0]
    print('wahaha')
    print(S + add)
elif S == ''.join(sorted(abc, reverse=True)):
    print(-1)
else:
    N = len(S)
    for i in range(1, N):
        now = S[N-i]
        fow = S[N-i+1:]
        fows = sorted(list(fow))
        for f in fows:
            if now < f:
                now = f
                break
        if now != S[N-i]:
            ans = S[:N-i] + now
            break
    print(ans)



### FIXED CODE ###

import string

S = input()

abc = [chr(i) for i in range(97, 97+26)]

if len(S) < 26:
    for s in S:
        abc.remove(s)
    add = abc[0]
    print(S + add)
elif S == ''.join(sorted(abc, reverse=True)):
    print(-1)
else:
    N = len(S)
    for i in range(1, N):
        now = S[N-i-1]
        fow = S[N-i:]
        fows = sorted(list(fow))
        for f in fows:
            if now < f:
                now = f
                break
        if now != S[N-i-1]:
            ans = S[:N-i-1] + now
            break
    print(ans)
a, b, k = map(int, input().split())

num = list(range(a, b + 1))

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k) | set(k_e)
for i in sorted(ans_set):
    print(i)


### FIXED CODE ###

a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):
  print(i)
def f(n,k):
    return 0 if n==0 else (f(n-1,k)+k)%n
while True:
    n,k=map(int,raw_input().strip().split())
    if (n,k)==(0,0):
        break
    print f(n,k)+1

### FIXED CODE ###

def f(n,k):
    return 0 if n==1 else (f(n-1,k)+k)%n
while True:
    n,k=map(int,raw_input().strip().split())
    if (n,k)==(0,0):
        break
    print f(n,k)+1
import collections
def f(heights,roads):
	adj = collections.defaultdict(list)
	count = 0
	for u,v in roads:
		adj[u].append(v)
		adj[v].append(u)
	for i,h in range(len(heights)):
		u = i + 1
		if h >= max([heights[v-1] for v in adj[u]] or [-1]): count +=1
	return count

n,m = map(int, raw_input().split(' '))
print f(map(int,raw_input().split(' ')), [map(int, raw_input().split(' ')) for _ in range(m)] )


### FIXED CODE ###

import collections

n, m = map(int, raw_input().split(' '))
hs = map(int, raw_input().split(' '))
adj = collections.defaultdict(list)
for _ in range(m):
	a,b = map(int, raw_input().split(' '))
	adj[a].append(b)
	adj[b].append(a)
count = 0
for u in range(1, n + 1):
	if all([hs[v - 1] < hs[u - 1] for v in adj[u]] or [True]):
		count+=1
print count
k, s = list(map(int, input().split()))
count = 0
for i in range(k+1):
    for j in range(k+1):
        for n in range(k+1):
            if (i+j+n == k):
                count += 1
print(count)

### FIXED CODE ###

k, s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
            if 0<=(s-i-j)<=k:
                count += 1
print(count)
from decimal import Decimal,getcontext
getcontext().prec = 100 # 標準は28 その桁まで精度を保つ
a,b,c=map(Decimal,input().split())
print("Yes" if sqrt(a)+sqrt(b)<sqrt(c) else "No")

### FIXED CODE ###

a,b,c=map(int,input().split())
if a+b<=c:
    if (a+b-c)**2>4*a*b:
        print("Yes")
    else:
        print("No")
else:
    print("No")
N,M = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
X = sorted(X)
dis = [0 for x in range(M-1)]
for i in range(M-1):
    dis[i] = X[i+1] - X[i]
dis.sort()
dis.reverse()
for i in range(N-1):
    dis[i] = 0
print(sum(dis))


### FIXED CODE ###

import sys
N,M = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
if N >= M:
    print(0)
    sys.exit()
X = sorted(X)
dis = [0 for x in range(M-1)]
for i in range(M-1):
    dis[i] = X[i+1] - X[i]
dis.sort()
dis.reverse()
for i in range(N-1):
    dis[i] = 0
print(sum(dis))