Harryxun/stf_run huggingface dataset:
N = int(input())
An = list(map(int, input().split()))

for n in range(N):
    An[n] -= (n+1)

An.sort()

m = N-1
if (m % 2 == 0):
    cent = (An[m/2] + An[m/2 + 1]) // 2
else:
    cent = An[(m+1)/2]

ans = 0
for n in range(N):
    ans += abs(An[n] - cent)

print(ans)



### FIXED CODE ###

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

for n in range(N):
    An[n] -= (n+1)

An.sort()

if (N-1) % 2 != 0:
    m = N//2 - 1
else:
    m = (N-1)//2

bf = -sum(An[0:m+1:]) + (m+1)*An[m]
af = sum(An[m+1::]) - (N-m-1)*An[m]
ans = bf + af
print(ans)
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
s = sum(a)
for i in range(a):
    if i >= s/(4*m):
        ans += 1
if ans >= m:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
s = sum(a)
for i in a:
    if i >= s/(4*m):
        ans += 1
if ans >= m:
    print("Yes")
else:
    print("No")
s = str(int,input())
p = 0
for i in s:
    if i == o:
        p = p + 100
        
print(700 + p)

### FIXED CODE ###

s = list(str(input()))
p = 0
for i in s:
    if i == 'o':
        p = p + 100
        
print(700 + p)
n,m = map( int, input().split() )

a = [-1]
for i in range(m):
    a.append(int(input()))
a.append(n+1)

m += 1
ans = 1
dp = []
for i in range(m):
    if a[i-1]-a[i]-1 == 0:
        ans = 0
        break
    elif a[i-1]-a[i]-1 == 1:
        continue
    else:
        dp.clear()
        dp = [1] + [0]*(a[i+1]-a[i]-2)
    for j in range(1, a[i+1]-a[i]-1):
        dp[j] = dp[j-1] + dp[j-2]
    ans *= dp[-1]

print(ans%1000000007)

### FIXED CODE ###

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

a = [-1]
for i in range(m):
    a.append(int(input()))
a.append(n+1)
m += 1

ans = 1
for i in range(m):
    if a[i+1]-a[i]-1 == 0:
        ans = 0
        break
    elif a[i+1]-a[i]-1 == 1:
        continue
    else:
        dp = [1] + [0]*(a[i+1]-a[i]-2)
    for j in range(1, a[i+1]-a[i]-1):
        dp[j] = dp[j-1] + dp[j-2]
    ans *= dp[-1]

print(ans%1000000007)
input_line = input()

if input_line == "AAA" or input_line == "BBB"
    print("No")
else:
    print("Yes")

### FIXED CODE ###

input_line = input()

if input_line == "AAA" or input_line == "BBB":
    print("No")
else:
    print("Yes")
import math
import fractions

a,b = [int(x) for x in input().split()]
x = fractions.gcd(a,b)

is_prime = [1]*(x+1)
is_prime[0] = 0
is_prime[1] = 0
ans = 1
for i in range(2,x+1):
    if is_prime[i]:
        if x%i==0:
            ans += 1
        for j in range(2*i,x+1,i):
            is_prime[j] = 0
print(ans)

### FIXED CODE ###

from fractions import gcd

a,b = [int(x) for x in input().split()]

def prime_factor(n):
    x = int(n**0.5)
    res = [1]
    for i in range(2,x+1):
        if n%i==0:
            while n%i==0:
                n //= i
            res.append(i)
    if n!=1:
        res.append(n)
    return res

z = gcd(a,b)
print(len(prime_factor(z)))
n = int(input())
arr = []
for i in range(n):
    a = list(map(ord,list(input())))
    arr.append(a)

import numpy as np
# print(np.array(arr))

ans = 0

for i in range(n):
    ok = True
    for j in range(n):
        for k in range(n):
            if j == k:
                continue
            l = j + i
            if l > n-1:
                l = l-n
            m = k + i
            if m > n-1:
                m = m-n
            # print(l,k,i)
            # print(arr[l][k],arr[k][l])
            if arr[l][k] != arr[m][j]:
                ok = False
                break

    # print("####")
    if ok:
        ans += n



print(ans)

### FIXED CODE ###

n = int(input())
arr = []
for i in range(n):
    a = list(map(ord,list(input())))
    arr.append(a)


ans = 0

for i in range(n):
    ok = True
    for j in range(n):
        for k in range(n):
            if j == k:
                continue
            l = j + i
            if l > n-1:
                l = l-n

            m = k + i
            if m > n-1:
                m = m-n
            # print(l,k,i)
            # print(arr[l][k],arr[k][l])
            if arr[l][k] != arr[m][j]:
                ok = False
                break

    # print("####")
    if ok:
        ans += n



print(ans)
N,Q = (int(X) for X in input().split())
S = input()
AIndex = [Ind for Ind,Str in enumerate(S) if S[Ind:Ind+2]=='AC']
if len(AIndex)==0:
    print('\n'.join(['0']*Q))
else:
    CIndex = [X+1 for X in AIndex]
    for T in range(0,Q):
        L,R = (int(X) for X in input().split())
        LN = [(L-1)<=X for X in AIndex].index(True)
        RN = len(CIndex)-[(R-1)>=X for X in CIndex][::-1].index(True)
        print(RN-LN)

### FIXED CODE ###

N,Q = (int(X) for X in input().split())
S = input()
T = [0]*(N+1)
for I in range(0,N):
     T[I+1] = T[I] + (S[I:I+2]=='AC')
for J in range(0,Q):
    L,R = (int(X)-1 for X in input().split())
    print(T[R]-T[L])
alpha = input()

upper = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]
lower = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]

if alpha in upper:
    print("A")
else:
    print("a")


### FIXED CODE ###

alpha = input()

upper = ["A", "B", "C", "D", 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
lower = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

if alpha in upper:
    print("A")
else:
    print("a")
data = [
    "{0} {1}".format(s, r)
    for s in ('S', 'H', 'C', 'D')
    for r in range(1, 13 + 1)
    ]

count = int(input())
for c in range(count):
    card = input()
    data.remove(card)

print("\n".join(data))

### FIXED CODE ###

input()
a = input().split()
a.reverse()
print(" ".join(a))
N, X = list(int, input().split()))[:2]
L = map(int, input().split())
D = 0
count = 0
for l in L:
  if D <= X:
      count += 1
  D += l
print(count)

### FIXED CODE ###

N, X = map(int, input().split())
L = map(int, input().split())
D = 0
count = 1
for i, l in enumerate(L):
  D += l
  if D <= X:
      count += 1
print(count)
n = int(input())
s = input()
k = int(input())
for i in range(n):
  if s[i] == s[k]:
    s[i] = '*'
    print(s[i], end = '')

### FIXED CODE ###

n = int(input())
s = input()
k = int(input())
for i in s:
  if i == s[k-1]:
    print(i, end = '')
  else:
    print('*', end = '')
l, n = map(int, input().split())
st = []
for _ in range(n):
	st.append(str(input()))
st.sort()
print("".join(st))

### FIXED CODE ###

N, L = map(int, input().split())
list=[]
for i in range(N):
    list.append(str(input()))
list.sort()
print("".join(list))
from heapq import *
n,m=map(int,input().split())
l=list(map(int,input().split()))
arr=[list(map(int,input().split())) for i in range(m)]
arr.sort(key=lambda x:x[1],reverse=True)
l.sort()
i=0
j=0
while(i<n):
    flag=False
    x=arr[j][0]
    k=0
    while(i<n and x>0 and arr[j][1]>l[i]):
        if(not flag):
            k=j+1
        l[i]=arr[j][1]
        x-=1
        i+=1
        flag=True
    j=k
    if(flag):
        continue
    else:
        i+=1
print(sum(l))

### FIXED CODE ###

from heapq import *
n,m=map(int,input().split())
l=list(map(int,input().split()))
arr=[list(map(int,input().split())) for i in range(m)]
arr.sort(key=lambda x:x[1],reverse=True)
l.sort()
i=0
j=0
while(i<n):
    if(l[i]>=arr[j][1]):
        break
    l[i]=arr[j][1]
    arr[j][0]-=1
    if(arr[j][0]==0):
        j+=1
    if(j>=m):
        break
    i+=1
    #print(j,l)
#print(l)
print(sum(l))
a = input()
a = int(a)

if a == 7 || a == 5 || a == 3:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

a = input()
a = int(a)

if a == 7 or a == 5 or a == 3:
    print('YES')
else:
    print('NO')
def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))
    A.sort()
    mod=10**9+7
    sum=0    
    def we_want(x):
        ans=1
        for i in range(k-1):
            ans=ans*(x-i)*pow(i+1,mod-2,mod)%mod 
        return ans 
        
    def check_min(i):
        if n-i>=k:
            minf=-we_want(n-1-i)*A[i]
            return minf
    def check_max(i):
        if i>=k-1:
            maxf=we_want(i)*A[i]        
            return maxf
    for i in range(len(A)):
        sum+=check_min(i)+check_max(i)
        sum%=mod
    print(sum%mod)

if __name__=='__main__':
    main()

### FIXED CODE ###

n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7
b = 1
ans = 0
for i in range(k - 1, n):
    ans += b * (a[i] - a[n - i - 1])
    ans %= mod
    b = (i+1)*pow(i-k+2, mod - 2, mod) * b % mod
print(ans)
import math
n, m = map(int, input().split())
s = 0
p = [0.0]
k = 1
s_old = -1.0
while s - s_old >= 0.0000001:
    pr = (1 - sum(p)) / (2**m)
    p.append(pr)
    s_old = s
    s += (1900 * m + 100 * (n - m)) * k * pr
    k += 1
print(math.ceil(s))


### FIXED CODE ###

x, y = input().split()
if x > y:
    print(">")
elif x < y:
    print("<")
else:
    print("=")
a,b=input().split()
a=int(a)
b.replace('.','')
b=int(b)
print((a*b)//100)


### FIXED CODE ###

a,b=map(float,input().split())
a=int(a)
b*=10**15
b=int(b)
print((a*b)//10**15)
n=int(input())
a=[int(input()) for _ in range(n)]
ans=-1
b=a[0]
if b==2:
    print(1)
    break
else:
    for i in range(n):
        b=a[b-1]
        # print(f"b={b}")
        if b==2:
            ans=i+2
            break
    print(ans) 

### FIXED CODE ###

n=int(input())
a=[int(input()) for _ in range(n)]
ans=-1
b=a[0]
if b==2:
    print(1)
else:
    for i in range(n):
        b=a[b-1]
        # print(f"b={b}")
        if b==2:
            ans=i+2
            break
    print(ans)
a,b,c=input().split
if a+b+c>21:
    print(“bust”)
else print(“win”)

### FIXED CODE ###

print('bust'if sum(map(int,input().split()))>=22else 'win')
s=input()
for i in range(len(s)-1):
  for j in range(i+1,len(s)+1):
    if A[i]==A[j]:
      print("no")
      exit()
print("yes")

### FIXED CODE ###

s=input()
for i in range(len(s)-1):
  for j in range(i+1,len(s)):
    if s[i]==s[j]:
      print("no")
      exit()
print("yes")
r1,c1,r2,c2 = map(int,input().split())

mod = 10 ** 9 + 7
MAX = 10**6+10
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod



def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
cominit()

ans = 0
for c in range(c1, c2+1):
    tmp = ((r2+1)*fac[r1]*fac[c+r2+1]-r1*fac[r2+1]*fac[c+r1])*finv[c]*finv[r1]*finv[r2+1]*inv[c+1]
    ans += tmp
    
ans %= mod
print(ans)

### FIXED CODE ###


r1,c1,r2,c2 = map(int,input().split())

mod = 10 ** 9 + 7
MAX = (10**6)*2 + 100
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod



def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
cominit()

ans = 0
for c in range(c1, c2+1):
    ans += ((r2+1)*fac[r1]*fac[c+r2+1]-r1*fac[r2+1]*fac[c+r1])*finv[c]*finv[r1]*finv[r2+1]*inv[c+1]
    ans %= mod
    
print(ans)
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 1
while 1:
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
        i = 0
    i += 1
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
    if i == a:
        break
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

### FIXED CODE ###

import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a:
    i += 1
    while np.any(d == x[i]):
        x[i] += 1
        if i != a:
            x[i + 1:] = 0
        if x[i] == 10:
            x[i - 1] += 1
            x[i:] = 0
            i -= 1

ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))
A, B, C = map(int, input().split())
if A + B + C == 17:
  if A == 5:
    if B + C == 12:
      return YES
    else:
      return NO
  if A == 7:
    if B + C == 10:
      return YES
    else:
      return NO
  else:
    return NO
else:
  return NO

### FIXED CODE ###

A, B, C = map(int, input().split())
if A + B + C == 17:
  if A == 5:
    if B + C == 12:
      print("YES")
    else:
      print("NO")
  elif A == 7:
    if B + C == 10:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")
else:
  print("NO")
#!usr/bim/python
#! -*- coding: utf-8 -*-
import math

nyu = raw_input()
nyu = int(nyu)

if nyu % 2 == 0:
    h = nyu
    n = nyu
    w = nyu / 2

elif nyu % 4 == 1:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    if h % 3 == 0:
        n = nyu*h/3*2
        w = nyu*h/3*2
    elif h % 2 == 0:
        n = nyu*h/2
        w = nyu*h
    else:
        h += 1
        if (nyu*h) % 6 == 0:
            n = nyu*h/6
            w = nyu*h
        elif (nyu*h) % 10 == 0:
            n = nyu*h/5
            w = nyu*h/2
        elif (nyu*h) % 7 == 0:
            n = nyu*h/7*2
            w = nyu*h/7*2

else:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    n = nyu*h*2
    w = nyu*h*2

print h,n,w


### FIXED CODE ###

#!usr/bim/python
#! -*- coding: utf-8 -*-
import math

nyu = raw_input()
nyu = int(nyu)

h = 0
n = 0
w = 0

if nyu % 2 == 0:
    h = nyu
    n = nyu
    w = nyu / 2

elif nyu % 4 == 1:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    i = 0
    status = 0
    while 1:
        x = nyu*h
        y = 4*i+3
        for j in range(y/2):
            if j == 0:
                if x % y == 0:
                    n = x*2/y
                    w = x*2/y
                    status = 1
                    break
            else:
                if x % (j*(y-j)) == 0:
                    n = x/(y-j)
                    w = x/j
                    status = 1
                    break
        if status == 1:
            break
        else:
            i += 1
            h += 1

else:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    n = nyu*h*2
    w = nyu*h*2

print h,n,w
from heapq import heapify, heappush, heappop
X, Y, A, B, C = map(int, input().split())
ps = list(map(int, input().split()))
qs = list(map(int, input().split()))
rs = list(map(int, input().split()))


rs.sort(key=lambda x: -x)
hp = []
hq = []
for p in ps:
    heappush(hp, p)
    if len(hp) > X:
        heappop(hp)

for q in qs:
    heappush(hq, q)
    if len(hq) > Y:
        heappop(hq)

for r in rs:
    if len(hq) < Y:
        heappush(hq, r)
    elif len(hp) < X:
        heappush(hp, r)
    elif hp[0] < hq[0]:
        heappush(hp, r)
        heappop(hp)
    else:
        heappush(hq, r)
        heappop(hq)

print(sum(hq) + sum(hp))


### FIXED CODE ###

ele =  input().strip()
if ele[2] == ele[3] and ele[4] == ele[5]:
    print("Yes")
else:
    print("No")
def count(n, x):
    c = 0
    for i in range(1, n-1):
        for j in range(i+1, n,):
            for k in range(j+1, n+1):
                s = i + j + k
                if s == x:
                    c += 1
                    break
                elif s > x: break
    return c

while True:
    p = map(int, raw_input().split())
    if p = [0, 0]: break
    print count(*p)

### FIXED CODE ###

def count(n, x):
    c = 0
    for i in range(1, n-1):
        for j in range(i+1, n,):
            for k in range(j+1, n+1):
                s = i + j + k
                if s == x:
                    c += 1
                    break
                elif s > x: break
    return c

while True:
    p = map(int, raw_input().split())
    if p == [0, 0]: break
    print count(*p)
import numpy as np
import bisect

N = int(input())
A = np.array([int(x) for x in input().split()],dtype = np.int64)
B = np.array([int(x) for x in input().split()],dtype = np.int64)

def f(t,A,B):
	power = (1<<t)
	AA = np.mod(A,2*power)
	BB = np.mod(B,2*power)
	AA.sort()
	BB.sort()
	cnt = 0
	for i in range(N):
		a = AA[i]
		R = bisect.bisect_right(BB, power-1-a)
		cnt += R
		L = bisect.bisect_left(BB,2*power-a)
		R = bisect.bisect_right(BB, 3*power-1-a)
		cnt += R-L
	x0 = cnt
	x1 = N*N - cnt
	return x1%2
  
ans = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		ans += 1<<t

print(ans)

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
 
def sum_count(A,B,x):
    # A,B is sorted. 
    # return count(a+b < x)
    p = len(B)-1
    result = 0
    for a in A:
        while p != -1 and a + B[p] >= x:
            p -= 1
        result += p+1
    return result
 
		
def f(t,A,B):
    power = (1<<t)
    AA = [x&(2*power-1) for x in A]
    BB = [x&(2*power-1) for x in B]
    AA.sort()
    BB.sort()
    
    x1,x2,x3 = (sum_count(AA,BB,v) for v in [power, 2*power, 3*power])
    zero_cnt = x1 + (x3-x2)
    return (N-zero_cnt)%2
  
ans = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		ans += 1<<t
 
print(ans)
# -*- coding:utf-8 -*-
n = int(input())

r = int(n/15
print(n*800-r*200)


### FIXED CODE ###

# -*- coding:utf-8 -*-
n = int(input())

r = int(n/15)
print(n*800-r*200)
li = input().split()

li[0](li[0]-1)/2 + li[1](li[1]-1)/2

### FIXED CODE ###

li = input().split()
li[0] = int(li[0])  
li[1] = int(li[1])  
  
print( int(li[0]*(li[0]-1)/2 + li[1]*(li[1]-1)/2 ))
n = map(int,input.split())
l = [int(x) for x in input.split()]

s = sum(l)

for x in l:
  if (2*x>=s):
    print("No")
    exit(0)
print("Yes")
    

### FIXED CODE ###

n = map(int,input().split())
l = [int(x) for x in input().split()]

s = sum(l)
res = "Yes"
for x in l:
  if (2*x>=s):
    res = "No"
print(res)
s = [list(map(int,input().split())) for i in range(2)]

a=s[0][0]
for i in range(s[0][1]):
  a -= s[1][i]

if a <= 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = list(map(int,input().split()))
a = s[0] // s[1]
b = s[0] % s[1]
if b != 0:
  a +=1
print(a)
ln=[n for n in range(int(input()))]
cnt=[0]*n
for n in ln:
    while n%2==0:
        cnt[n-1]+=1
print((max(cnt)).index()+1)

### FIXED CODE ###

n=int(input())
ans=0
for i in range(7):
    if 2**i<=n:
        ans=2**i
print(ans)
mport math
R = int(input())
print(R*2*math.pi)

### FIXED CODE ###

import math
R = int(input())
print(R*2*math.pi)
n = input()
if n[0]*3 == n:
    print(n)
elif int(n[0]) > int(n[1]) and int(n[0]) > int(n[3]):
    print(n[0] * 3)
else:
    print(str(int(n[0]) +1) * 3)

### FIXED CODE ###

n = input()
for i in range(1,10):
    N = str(i) + str(i) + str(i)
    if n <= N:
        print(N)
        break
import numpy as np
N,K=map(int, input().split())
A =list(map(int,input().split()))
MOD = 10 ** 9 + 7

if N==K:
  ans0 = 1
  for a in A[0:N]:
    ans0 *= a
    ans0 %= MOD
  print(ans0)
  exit()
A=sorted(A)  
if (K%2==1 and A[-1]<0):
  ans1 = 1
  for a in A[N-K:N]:
    ans1 *= a
    ans1 %= MOD
  print(ans1)
  exit()

A=sorted(A, key=lambda x:abs(x), reverse=True)
AA=[np.sign(i) for i in A]

ansA = 1
for a in A[0:K]:
  ansA *= a
  ansA %= MOD
ansAA = AA[0:K].count(-1)%2
if ansA==0 or ansAA==0:
  print(ansA)
  exit()

#while ansA>0:
#  ansA-=MOD
Bp=[i for i in A[0:K] if i>0]
Bm=[i for i in A[0:K] if i<0]

B=sorted(A[K:N])
if not Bm:ansB1=ansA//Bp[-1]*B[-1]
else:ansB1=ansA//Bp[-1]*B[-1]
if not Bp:ansB2=ansA//Bm[-1]*B[-1]
else:ansB2=ansA//Bm[-1]*B[-1]          
#print(ansA,B,Bp,Bm)

#print(ansB1,ansB2)%MOD
print(max(ansB1,ansB2)%MOD)

### FIXED CODE ###

import numpy as np
N,K=map(int, input().split())
A =list(map(int,input().split()))
MOD = 10 ** 9 + 7
if N==K:
  ans0 = 1
  for a in A[0:N]:
    ans0 *= a
    ans0 %= MOD
  print(ans0)
  exit()
A=sorted(A)  
if (K%2==1 and A[-1]<0):
  ans1 = 1
  for a in A[N-K:N]:
    ans1 *= a
    ans1 %= MOD
  print(ans1)
  exit()
 
A=sorted(A, key=lambda x:abs(x), reverse=True)
AA=[np.sign(i) for i in A]
 
ansA = 1
for a in A[0:K]:
  ansA *= a
  ansA %= MOD
ansAA = AA[0:K].count(-1)%2
if ansA==0 or ansAA==0:
  print(ansA)
  exit()

while ansA>0:
  ansA-=MOD

B1=A[0:K]
C1=A[0:K]
B2=sorted(A[K:N])
Bp=[i for i in A[0:K] if i>0]
Bm=[i for i in A[0:K] if i<0]
 
if B2[0]>0:B2.insert(0,0)
if B2[-1]<0:B2.insert(-1,0)
if not Bp:Bp.insert(0,B1[-1])
if not Bm:Bm.insert(0,B1[0])
  
#print(Bp,Bm,B2)
#print(Bp[-1],B2[0])
B1.remove(Bp[-1])
B1.append(min(B2[0],0))
#print(B1)
ansB = 1
for a in B1[0:K]:
  ansB *= a
  ansB %= MOD
#print(Bm[-1],B2[-1])
C1.remove(Bm[-1])
C1.append(max(B2[-1],0))
 
ansC = 1
for a in C1[0:K]:
  ansC *= a
  ansC %= MOD
#print(B1,C1)
#print(ansB,ansC)
BB1=[np.sign(i) for i in B1]
ansBB1 = BB1[0:K].count(-1)%2
BB2=[np.sign(i) for i in C1]
ansBB2 = BB2[0:K].count(-1)%2
#print(ansBB1,ansBB2)
if ansBB1==1:
  print(ansC)
  exit()
if ansBB2==1:
  print(ansB)
  exit()
#print(B2[0]/Bp[-1],B2[-1]/Bm[-1])
#print(Bp[-1]*B2[-1],Bm[0]*B2[0])

#print(abs(Bp[-1]*B2[-1])-abs(Bm[-1]*B2[0]))
#print(ansB,ansC)
if abs(Bp[-1]*B2[-1])-abs(Bm[-1]*B2[0])>=0:
  print(ansC)
else: print(ansB)
num = list(map(int, input().split()))

num = num.sorted
if(num[0]==5 and num[1]==5 and num[2] == 7):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

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

ans = sorted(num)
if(ans[0]==5 and ans[1]==5 and ans[2] == 7):
    print("YES")
else:
    print("NO")
W, H, x, y = list(map(lambda n: int(n), input().split(" ")))

S = W * H / 2
flag = 1 if W == 2 * x and H == 2 * y else flag = 0
print(S, end=" ")
print(flag)

### FIXED CODE ###

W, H, x, y = list(map(lambda n: int(n), input().split(" ")))
 
S = W * H / 2

print(S, end=" ")
print(1) if W == 2 * x and H == 2 * y else print(0)
N, A = map(int, input().split())
lst = [int(x) - A for x in input().split()]
dp = [[0] * (2 * N + 1) for _ in range(N + 1)]
dp[0][1 * N] = 1
for i in range(N):
    for j in range(1, 2 * N + 1 - 1):
        dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]]
print(dp[N][1 * N] - 1)

print(dp)

### FIXED CODE ###

N, A = map(int, input().split())
lst = [int(x) - A for x in input().split()]
dp = [[0] * (100 * N + 1) for _ in range(N + 1)]
dp[0][50 * N] = 1
for i in range(N):
    for j in range(50, 100 * N + 1 - 50):
        dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]]
print(dp[N][50 * N] - 1)
X, Y = [int(item) for item in input().rstrip.split(" ")]

ans = 1
while(1):
  if X < Y:
    ans+=1
    X *=2
  else:
    break
print(ans)

### FIXED CODE ###

X, Y = [int(item) for item in input().rstrip().split(" ")]
 
ans = 0
while(1):
  if X <= Y:
    ans+=1
    X *=2
  else:
    break
print(ans)
n = int(input())
l = [int(input()) for i in range(n)]
l = l[::-1]
maximum = l[0] - min(l[1:])
x = l
if maximum > 0:
    x = [i for i in l if l[0] <= i]
for j in range(len(x)-1):
    if maximum < l[j] - min(l[j+1:]):
        maximum = l[j] - min(l[j+1:])
input(maximum)

### FIXED CODE ###

n = int(input())
r = [int(input()) for i in range(n)]
start = r[0]
score = r[1] - r[0]
for i in range(1,n):
    if r[i] - start > score: score = r[i] - start
    if r[i] < start: start = r[i]
print(score)
N,K=map(int, input().split())

def comb(n, k):
    m = 1
    if n < 2 * k:
        k = n - k
    for i in range(1, k + 1):
        m = m * (n - i + 1) / i
    return int(m)

for i in range(1,K+1):
    print((comb(N-K+1,i)*comb(K-1,i-1))%(10**9+7))

### FIXED CODE ###

N, K = map(int, input().split())
mod = 10 ** 9 + 7

f = [1 for _ in range(N + 1)]
inv = [1 for _ in range(N + 1)]
finv = [1 for _ in range(N + 1)]

for i in range(2, N + 1):
    f[i] = f[i - 1] * i % mod
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def comb(n, r):
    return f[n] * (finv[r] * finv[n - r] % mod) % mod


for i in range(1, K + 1):
    print((comb(N - K + 1, i) * comb(K - 1, i - 1)) % mod) if i <= N - K + 1 else print(0)