Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

"""
それぞれの隣接2列ごとに、可能な摩擦の最小値を実現する → 小問題に分割。
"""

buffer = sys.stdin.buffer
H,W = map(int,buffer.readline().split())
C = np.frombuffer(buffer.read(),dtype='S1').reshape(H,-1)[:,:W].T

dp_1 = np.zeros((W-1,H+H+1,H+1),dtype=np.int64)
for r in range(H):
    dp_1[:,r+2:r+H+2,r+1] = (C[:-1] == C[1:,r][:,None])

(C[:-1][:,:] == C[1:][:,r][])

INF = 10**18
# R-L+H -> min cost
dp = np.full((W-1,H+H+1),INF,dtype=np.int64)
dp[:,H] = 0
for n in range(1,H+H+1):
    # n個目を置く
    prev = dp
    dp = np.full((W-1,H+H+1),INF,dtype=np.int64)
    dp[:,1:] = np.minimum(dp[:,1:],prev[:,:-1])
    dp[:,:-1] = np.minimum(dp[:,:-1],prev[:,1:])
    dp += dp_1[:,:,n]
answer = dp[:,H].sum()
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

"""
それぞれの隣接2列ごとに、可能な摩擦の最小値を実現する → 小問題に分割。
"""

buffer = sys.stdin.buffer
H,W = map(int,buffer.readline().split())
C = np.frombuffer(buffer.read(),dtype='S1').reshape(H,-1)[:,:W].T

dp_1 = np.zeros((W-1,H+H+1,H+1),dtype=np.int64)
for r in range(H):
    dp_1[:,r+2:r+H+2,r+1] = (C[:-1] == C[1:,r][:,None])

INF = 10**18
# R-L+H -> min cost
dp = np.full((W-1,H+1),INF,dtype=np.int64)
dp[:,0] = 0
for n in range(1,H+H+1):
    if n >= 2:
        dp_1[:,n,1:] += dp_1[:,n-2,:-1]
    # n個目を置く
    prev = dp
    dp = np.full((W-1,H+1),INF,dtype=np.int64)
    dp[:,1:] = np.minimum(dp[:,1:],prev[:,:-1])
    dp[:,:] = np.minimum(dp[:,:],prev[:,:])
    dp += dp_1[:,n,:]
answer = dp[:,H].sum()
print(answer)
n, m = map(int, input().split())
f = [i for i in range(n + 1)]
def getF(u):
    if f[f[u]] == f[u]:
        return f[u]
    f[u] = getF(f[u])
    return f[u]
def uniF(u, v):
    u = getF(u)
    v = getF(v)
    if u != v:
        f[u] = v
for i in range(m):
    u, v = map(int, input().split())
    uniF(u, v)
c = [0] * (n + 1)
for i in range(1, n + 1):
    c[getF(i)] += 1
print(max(c))

### FIXED CODE ###

n, m = map(int, input().split())
f = [i for i in range(n + 1)]
def getF(u):
    i = u
    while f[i] != i:
        i = f[i]
    j = u
    while f[j] != j:
        oj = j
        j = f[j]
        f[oj] = i
    return i
def uniF(u, v):
    u = getF(u)
    v = getF(v)
    if u != v:
        f[u] = v
for i in range(m):
    u, v = map(int, input().split())
    uniF(u, v)
c = [0] * (n + 1)
for i in range(1, n + 1):
    c[getF(i)] += 1
print(max(c))
A, B = int(input())
s = int(input().split())
if s == 1:
    print("OK")
if s < A:
    print("NG")
if s > B:
    print("NG")
print("OK")

### FIXED CODE ###

import numpy as np
s= int(input())
List = list(map(int, input().split()))
array = list()
for i in range(List[0],List[1]+1):
    if s == 1:
        array.append("OK")
        break
    if i % s == 0:
        array.append("OK")
        break
if ('OK' in array):
    print("OK")
else:
    print("NG")
# coding:utf-8

N = int(input())
H = [int(hi) for hi in input().split()]

# 地点iへの最小コストを計算する関数
def dp(i):
    if i == 1:
        return 0
    elif i == 0:
        return 0
    elif i == 2:
        return abs(H[0]-H[1])
    else:
        dp_i_1 = dp(i-1)+abs(H[i-2]-H[i-1])
        dp_i_2 = dp(i-2)+abs(H[i-3]-H[i-1])
        return min(dp_i_1, dp_i_2)

cost = dp(N)
print(cost)

### FIXED CODE ###

# coding:utf-8

N = int(input())
H = [int(hi) for hi in input().split()]
dp = [0]*N
dp[1] = abs(H[0]-H[1])

for i in range(2, N):
    dp[i] = min(abs(H[i]-H[i-2])+dp[i-2],abs(H[i]-H[i-1])+dp[i-1])
    
print(dp[N-1])
import math

r = imput()

print("%f %f" % (math.pi * r * r, 2 * math.pi * r))

### FIXED CODE ###

import math

r = input()

print("%f %f" % (math.pi * r ** 2, 2 * math.pi * r))
S = input()
a = [0,int(S)%2019]
init = 0
for i in range(len(S)-1):
    S = S[1:]
    a.append(int(S)%2019)
b = [kv*(kv-1)//2 for kv in Counter(a).values() if kv > 1]
print(sum(b))

### FIXED CODE ###

from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
mod = 2019
while d:
    temp = d.pop()
    t = (t + (temp * m)) % mod
    m = (m * 10) % mod
    a.append(t%mod)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))
a = input().split()

k = 0

for int(i) in a:
  if(i == 1):
    k += 1
    
print(k)

### FIXED CODE ###

a = list(input())

k = 0

for i in a:
  if(int(i)==1):
    k += 1
    
print(k)
X = input()
sum_c = 0
for char in X:
  sum_c += int(char)
if X%sum_c == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

X = input()
sum_c = 0
for char in X:
  sum_c += int(char)
if int(X)%sum_c == 0:
  print('Yes')
else:
  print('No')
import itertools
import math

N, D = [int(x) for x in input().strip().split()]
if D == 1:
    print(int(N*(N-1)/2))
    exit(1)
    
points = []
for data in range(N):
    points.append([int(x) for x in input().strip().split()])

result = 0
for p1,p2 in itertools.combinations(points, 2):
    distance = 0
    for y,z in zip(p1,p2):
        distance += (y - z) ** 2
        
    distance = math.sqrt(distance)
    if distance.is_integer(): result += 1
        
print(result)

### FIXED CODE ###

import itertools
import math

N, D = [int(x) for x in input().strip().split()]
if D == 1:
    print(int(N*(N-1)/2))
else:
    points = []
    for data in range(N):
        points.append([int(x) for x in input().strip().split()])

    result = 0
    for p1,p2 in itertools.combinations(points, 2):
        distance = 0
        for y,z in zip(p1,p2):
            distance += (y - z) ** 2
        
        distance = math.sqrt(distance)
        if distance.is_integer(): result += 1    
    print(result)
# ABC071-C
import collections
N = int(input())
A_list = sorted(list(map(int, input().split())), reverse = True)
A_set = set(A_list)
A_set = sorted(A_set, reverse=True)
ans_list = [0]   
ans_rectangle_list = []   # 長方形を作る辺を入れる
rec_counter = 0   # 大きい辺を入れる回数，二回入れば良い
for i in range(len(A_set)):   # 大きい順に取っていき，リストで個数を確認する
    if rec_counter == 2:
        break
    count = A_list.count(A_set[i])    # リストの個数を確認
    if count  == 2 or count == 3:   # 対辺を作れる時
        ans_rectangle_list.append(A_set[i])
        rec_counter += 1
    elif count >= 4:   # 4辺全てを作れる
        ans_list.append(A_set[i] ** 2)

if rec_counter == 2:
    rec_ans = ans_rectangle_list[0] * ans_rectangle_list[1]
if len(ans_list) == 0 and len(ans_rectangle_list) <= 1:
    print(0)
else:
    if max(ans_list) > rec_ans:
        print(max(ans_list))
    elif max(ans_list) <= rec_ans:
        print(rec_ans)

### FIXED CODE ###

# ABC071-C
N = int(input())
A = sorted(list(map(int, input().split())), reverse = True)

for i in range(N-1):
    if A[i] == A[i+1]:
        A[i+1] = 0
    elif A[i] != A[i+1]:
        A[i] = 0
A.sort(reverse = True)
print(A[0] * A[1])
N = int(input())
A = list(map(int, input().split()))
V = [0]*(N+1)
flug = 0
Lsum= sum(A)

V[0] = 1
for i in range(N):
    V[i+1] = (V[i]*2 - A[i+1])
    if V[i+1] <= 0 and i != N-1 :
        flug = 1
    if V[i+1] < 0 and i == N-1 :
        flug = 1
    Lsum = Lsum - A[i+1]
    if V[i+1] > Lsum :
        V[i+1] = Lsum

ans = sum(V)+sum(A)
if A[0] != 0:
    ans = -1
if flug == 1:
   ans = -1
if N == 0:
    ans = -1

print(ans)

### FIXED CODE ###

H1, M1, H2, M2, K = map(int,input().split())

time1 = 60*H1 + M1
time2 = 60*H2 + M2

ans = time2 - K - time1
if ans < 0:
    ans = 0

print(ans)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr

def main():
    N = int(input())
    #xxx = list(map(int, input().split()))

    if N == 1:
        print(0)
        return

    e_num = [0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4]
    e_list = factorization(N)

    ans = 0
    for e in e_list:
        ans += e_num[e]
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr

def main():
    N = int(input())
    #xxx = list(map(int, input().split()))

    if N == 1:
        print(0)
        return

    e_num = []
    for i in range(0, 40):
        for k in range(0, i+1):
            e_num.append(i)
    #print(e_num)

    e_list = factorization(N)

    ans = 0
    for e in e_list:
        ans += e_num[e]
    print(ans)

if __name__ == '__main__':
    main()
import numpy as np 
H, W = map(int, input().split())
grid = []
for _ in range(H):
    grid.append([s for s in input()])

yoko = [[0 for _ in range(W)] for _ in range(H)]
tate =  [[0 for _ in range(W)] for _ in range(H)]

for h in range(H):
    cnt = 0
    for w in range(W):
        if grid[h][w] == ".":
            cnt += 1
        else:
            cnt = 0
        yoko[h][w] = cnt

for w in range(W):
    cnt = 0
    for h in range(H):
        if grid[h][w] == ".":
            cnt += 1
        else:
            cnt = 0
        tate[h][w] = cnt

tate = np.array(tate)
yoko = np.array(yoko)

for h in range(H):
    my_max = 0
    for w in range(W):
        if yoko[h][W - 1 - w] != 0:
            my_max = max(my_max, yoko[h][W - 1 - w])
            yoko[h][W - 1 - w] = my_max
        else:
            my_max = 0

tate = tate.T

for h in range(W):
    my_max = 0
    for w in range(H):
        if tate[h][H - 1 - w] != 0:
            my_max = max(my_max, tate[h][H - 1 - w])
            tate[h][H - 1 - w] = my_max
        else:
            my_max = 0
            
tate = tate.T
ans = tate + yoko - 1

print(np.max(ans.ravel()))


### FIXED CODE ###

H, W = map(int, input().split())
grid = []
for _ in range(H):
    grid.append([s for s in input()])
    
left = [[0 for _ in range(W)] for _ in range(H)]
right = [[0 for _ in range(W)] for _ in range(H)]
up = [[0 for _ in range(W)] for _ in range(H)]
down = [[0 for _ in range(W)] for _ in range(H)]

for h in range(H):
    for w in range(W):
        if grid[h][w] == ".":
            if w == 0:
                left[h][w] = 1
            else:
                left[h][w] += left[h][w - 1] + 1

for h in range(H):
    for w in range(W)[::-1]:
        if grid[h][w] == ".":
            if w == W - 1:
                right[h][w] = 1
            else:
                right[h][w] += right[h][w + 1] + 1
            
for w in range(W):
    for h in range(H):
        if grid[h][w] == ".":
            if h == 0:
                up[h][w] = 1
            else:
                up[h][w] += up[h - 1][w] + 1
                
for w in range(W):
    for h in range(H)[::-1]:
        if grid[h][w] == ".":
            if h == H - 1:
                down[h][w] = 1
            else:
                down[h][w] += down[h + 1][w] + 1
                
ans = -10000
for h in range(H):
    for w in range(W):
        ans = max(ans, up[h][w] + down[h][w] + right[h][w] + left[h][w] - 3)
print(ans)
n=int(input())
A=[int(i) for i in input().split()]

A.sort()
A.append(-1)

dat={i:False for i in range(2*10**5+100)}

ans=0
for i in range(len(A)-1):
    if dat[A[i]]:
        pass
    else:
        if A[i]!=A[i+1]:
            ans+=1
        for i in range(A[i],2*10**5+100,A[i]):
            dat[i]=True

print(ans)

### FIXED CODE ###

n=int(input())
A=[int(i) for i in input().split()]

A.sort()
A.append(-1)

dat={i:False for i in range(10**6+10)}

ans=0
for i in range(len(A)-1):
    if dat[A[i]]:
        pass
    else:
        if A[i]!=A[i+1]:
            ans+=1
        for i in range(A[i],10**6+10,A[i]):
            dat[i]=True

print(ans)
def nextTurn(a):
  if a == "a":
    return 0
  elif a == "b":
    return 1
  else:
    return 2
    
hand = [list(input()) for i in range(3)]
turn = nextTurn(hand[0].pop(0))
while(True):
  tmp = turn
  turn = nextTurn(hand[turn].pop(0))
  if len(hand[tmp]) == 0:
    if tmp == 0:
      print("A")
    elif tmp == 1:
      print("B")
    else:
      print("C")
    break
  

### FIXED CODE ###

def nextTurn(a):
  if a == "a":
    return 0
  elif a == "b":
    return 1
  else:
    return 2
    
hand = [list(input()) for i in range(3)]
turn = nextTurn(hand[0].pop(0))
while(True):
  if len(hand[turn]) == 0:
    if turn == 0:
      print("A")
    elif turn == 1:
      print("B")
    else:
      print("C")
    break
  turn = nextTurn(hand[turn].pop(0))
W, H, x, y, r = [int(i) for i in input().split]


if x + r <= W:
    print("Yes")
if y - r >= 0:
    print("Yes")
if x - r >= 0:
    print("Yes")
if y + r <= H:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

W, H, x, y, r = [int(i) for i in input().split()]


if x + r <= W and y - r >= 0 and x - r >= 0 and y + r <= H:
    print("Yes")
else:
    print("No")
import collections as c
import sys

n = int(input())
a = list(map(int, input().split()))

A = c.Counter(a)

if list(A.keys()) == [0]:
	print("Yes")
	sys.exit()

if len(A.keys()) == 2:
	if 0 not in A.keys():
		print("No")
		sys.exit()
	else:
		if A.values()[0]*2 == A.values()[1]:
			print("Yes")
			sys.exit()
		else:
			print("No")
			sys.exit()

if len(A.keys()) != 3:
	print("No")
	sys.exit()

x,y,z = A.keys()
if x^y != z:
	print("No")
	sys.exit()

x,y,z = A.values()
if x == y == z:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

import collections as c
import sys

n = int(input())
a = list(map(int, input().split()))

A = c.Counter(a)

if list(A.keys()) == [0]:
	print("Yes")
	sys.exit()

if len(A.keys()) == 2:
	if 0 not in A.keys():
		print("No")
		sys.exit()
	else:
		if list(A.values())[0]*2 == list(A.values())[1]:
			print("Yes")
			sys.exit()
		else:
			print("No")
			sys.exit()

if len(A.keys()) != 3:
	print("No")
	sys.exit()

x,y,z = A.keys()
if x^y != z:
	print("No")
	sys.exit()

x,y,z = A.values()
if x == y == z:
	print("Yes")
else:
	print("No")
S=input().split()

if i>=0:
  if  S[2*i]=='L':
      print('No')
  elif  S[2*i+1]=='R':
      print('No')

### FIXED CODE ###

S=input()
total=0

for i in range(len(S)):
    if  (i%2)==0:
        if  (S[i]=='R')or(S[i]=='U')or(S[i]=='D'):
            pass
        else:
            total+=1
    else:
        if  (S[i]=='L')or(S[i]=='U')or(S[i]=='D'):
            pass
        else:
            total+=1

if  total==0:
    print('Yes')
else:
    print('No')
s=str(input())
s[5]=" "
s[13]=" "
print(s)

### FIXED CODE ###

s = input()
ss = s.replace("," , " ")
print(ss)
n = int(input())
a = list(map(int, input().split())).sort()
 
ans = 1
for x in a:
  ans = (ans if ans > 10**18 else ans * x)
 
print(-1 if ans > 10**18 else ans)

### FIXED CODE ###

print(eval(input().strip().replace(' ','*')))
s = [list(map(int,input().split())) for i in range(2)]

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

r = "Yes"
if p > a:
  r = "No"

print(r)

### 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)
a, b = map(int(), raw_input().split(' '))
print(str(a*b)+(" ")+str((a+b)*2))

### FIXED CODE ###

a, b = map(int, raw_input().split(' '))
print(str(a*b)+(" ")+str((a+b)*2))
n,k=map(int,input().split())
l=[input().split() for _ in range(n)]
b=[[0]*k for _ in range(k)]
w=[[0]*k for _ in range(k)]
anb=[[0]*k for _ in range(k)]
anw=[[0]*k for _ in range(k)]
ans=0
i=0
while i<n:
    m=(((int(l[i][0]))//k)+((int(l[i][1]))//k))%2
    if (m==0 and str(l[i][2])=="W"):
        w[l[i][0]][l[i][1]] +=1    
    elif (m==1 and str(l[i][2])=="B"):
        b[l[i][0]][l[i][1]] +=1   
    elif:(m==1 and str(l[i][2])=="W"):
        anw[l[i][0]][l[i][1]] +=1 
    else:
        anb[l[i][0]][l[i][1]] +=1 
      

for a in range(0,k):
     for b in range(0,k):
         total=sum([w[a:k][b:k])+sum(anw[0:a][0:b])+sum([b[a:k][b:k])+sum(anb[0:a][0:b])
         ans=max(ans,total,n-total)
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
imos = [[0 for i in range(k)] for j in range(k)]
white = 0
for i in range(n):
    x, y, c = input().split()
    x = int(x)
    y = int(y)
    if c == "W":
        c = 1
    else:
        c = 0
    x %= 2*k
    y %= 2*k

    if x > k-1:
        x -= k
        c += 1
    if y > k-1:
        y -=k
        c += 1
    c %= 2

    if c == 1:
        white += 1
        imos[x][y] -= 1
    else:
        imos[x][y] += 1

for i in range(k):
    for j in range(k-1):
        imos[i][j+1] += imos[i][j]

for j in range(k):
    for i in range(k-1):
        imos[i+1][j] += imos[i][j]

ans = 0
for i in range(k):
    for j in range(k):
        exp = imos[k-1][k-1] - imos[k-1][j] - imos[i][k-1] + 2 * imos[i][j] + white
        ans = max(ans, max(exp, n - exp))

print(ans)
import math
N = int(input())

S = round(N**2*math.pi, 6)
R = round(2*math.pi*N, 6)

print(S, R)

### FIXED CODE ###

import math

r = float(input())

s = r*r*math.pi
v = 2*math.pi*r

S = round(s, 6)
V = round(v, 6)

print(S, V)
sel='B'
#A
if sel=='A':
    N,M=map(int,input().split())
    ans=0
    ans+=M*(M-1)//2
    ans+=N*(N-1)//2
    print(ans)

#B
if sel=='B':
    def ispal(s):
        for i in range(len(s)//2+1):
            if s[i]!=s[-(i+1)]:
                return False
        return True

    S=input()
    if ispal(S) and ispal(S[:(N-1)//2]) and ispal(S[(N+3)//2-1:]):
        print('Yes')
    else:
        print('No')

#C
if sel=='C':
    L=int(input())
    print((L**3)/27)

#D
if sel=='D':    
    N=int(input())
    A=[int(i) for i in input().split()]
    kin=list(set(A))
    cnt={}
    for k in kin:
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    SUM=0
    for k in kin:
        SUM+=cnt[k]*(cnt[k]-1)//2
    for a in A:
        if cnt[a]>=2:
            print(SUM-cnt[a]+1)
        else:
            print(SUM)
        
#E
if sel=='E':
    a=0

#F
if sel=='F':
    N,S=map(int,input().split())
    A=[int(i) for i in input().split()]

    for l in range(N):
        for r in range(l,N):
            print(tab[l][r])



### FIXED CODE ###

sel='B'
#A
if sel=='A':
    N,M=map(int,input().split())
    ans=0
    ans+=M*(M-1)//2
    ans+=N*(N-1)//2
    print(ans)

#B
if sel=='B':
    def ispal(s):
        for i in range(len(s)//2+1):
            if s[i]!=s[-(i+1)]:
                return False
        return True

    S=input()
    N=len(S)
    if ispal(S) and ispal(S[:(N-1)//2]) and ispal(S[(N+3)//2-1:]):
        print('Yes')
    else:
        print('No')

#C
if sel=='C':
    L=int(input())
    print((L**3)/27)

#D
if sel=='D':    
    N=int(input())
    A=[int(i) for i in input().split()]
    kin=list(set(A))
    cnt={}
    for k in kin:
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    SUM=0
    for k in kin:
        SUM+=cnt[k]*(cnt[k]-1)//2
    for a in A:
        if cnt[a]>=2:
            print(SUM-cnt[a]+1)
        else:
            print(SUM)
        
#E
if sel=='E':
    a=0

#F
if sel=='F':
    N,S=map(int,input().split())
    A=[int(i) for i in input().split()]

    for l in range(N):
        for r in range(l,N):
            print(tab[l][r])
a,b=input()
A=int(a*b)
B=int(b*a)
print(min(A,B))

### FIXED CODE ###

a,b=input().split()
A=a*int(b)
B=b*int(a)
print(min(A,B))
w,h,x,y = map(int, input().split())

#print("{0} {1} {2} {3}".format(str(w), str(h), str(x), str(y)))

if x > w/2:
    x = w - x
if y > h/2:
    y = h - y

# 横
men1 = w * y
men2 = w * (h-y)

# 縦
men3 = x * h
men4 = (w-x) * h

#print("{0} {1} {2} {3}".format(str(w), str(h), str(x), str(y)))
#print("{0} {1} {2} {3}".format(str(men1), str(men2), str(men3), str(men4)))

out2 = 0

if min(men1, men2) == 0:
    out1 = min(men3, men4)
elif min(men3, men4) == 0:
    out1 = min(men1, men2)
else:
    out1 = max(min(men1, men2), min(men3, men4))

if min(men1, men2) == min(men3, men4):
    out2 = 1
if men1 == men2 or men3 == men4):
    out2 = 1

if x == 0 and y ==0:
    out1 = x*y /2
    out2 = 0

print("{0} {1}".format(out1, out2))

### FIXED CODE ###

w,h,x,y = map(int, input().split())
out1 = w * h / 2
out2 = 1 if x == w/2 and y == h/2 else 0
print("{0} {1}".format(str(out1), str(out2)))
import itertools
import heapq
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
b = np.abs(a)
b = sorted(a,reverse = True)
b_k = b[k-1] 
a_new = [a[i] for i in range(len(a)) if np.abs(a)[i] > b_k]
 
comb = itertools.combinations(a_new,k)  
l = [list(_) for _ in comb]  
A = (functools.reduce(operator.mul,l[_]) for _ in range(len(l)))
l_max = max(A)
waru = 10**9 + 7
print(l_max % waru)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
N, M = map( int, input().split())
A = list( map( int, input().split()))
Needs = [0,2,5,5,4,5,6,3,7,6]
A.sort(reverse = True)
V = [0]*10
Check = []
for a in A:
    if V[Needs[a]] == 0:
        Check.append(Needs[a])
        V[Needs[a]] = a
Check.sort()
dp = [-100000]*(N+1)
dp[0] = 0

for x in Check:
    if x <= N:
        dp[x] = 1
for i in range(1,N):
    t = dp[i]
    for x in Check:
        if x + i <= N:
            if dp[x+i] < t + 1:
                dp[x+i] = t+1
ans = ""
t = N
W = [0]*10
while t > 0:
    for a in A:
        x = Needs[a]
        if dp[t-x]+1 == dp[t]:
            W[V[x]] += 1
            t -= x
            break
for i in range(9,0,-1):
    ans += str(i)*W[i]
print(ans)


### FIXED CODE ###

N, M = map( int, input().split())
A = list( map( int, input().split()))
Needs = [0,2,5,5,4,5,6,3,7,6]
A.sort(reverse = True)
V = [0]*10
Check = []
for a in A:
    if V[Needs[a]] == 0:
        Check.append(Needs[a])
        V[Needs[a]] = a
Check.sort()
dp = [-100000]*(N+1)
dp[0] = 0

for x in Check:
    if x <= N:
        dp[x] = 1
for i in range(1,N):
    t = dp[i]
    for x in Check:
        if x + i <= N:
            if dp[x+i] < t + 1:
                dp[x+i] = t+1
ans = ""
t = N
W = [0]*10
while t > 0:
    for a in A:
        x = Needs[a]
        if t-x>=0:
            if dp[t-x]+1 == dp[t]:
                W[V[x]] += 1
                t -= x
                break
for i in range(9,0,-1):
    ans += str(i)*W[i]
print(ans)
N,D = list(map(int,input().split()))
human = 1
hani = 2*D+1
haniwhile hani < N:
    hani = hani + (2*D+1)
    human +=1
    
print(human) = kanshi


### FIXED CODE ###

N,D = list(map(int,input().split()))
human = 1
hani = 2*D+1
while hani < N:
    hani = hani + (2*D+1)
    human +=1
    
print(human)
#58
a,b,c=map(int,input().split())
if b-a=c-b:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

#58
a,b,c=map(int,input().split())
if b-a==c-b:
    print('YES')
else:
    print('NO')
import math
a, b, c = map(int, input().split())
h=x/(a**2)
if h>b/2:
    y=2*a*h/b
    shita=math.degrees(math.atan2(y,b))
if h<=b/2:
    y=2*h-b
    y=b-y
    shita=math.degrees(math.atan2(b,y))
print(shita)

### FIXED CODE ###

import math
a, b, x = map(int, input().split())
h=x/(a**2)
if h<b/2:
    y=2*a*h/b
    shita=math.degrees(math.atan2(b,y))
if h>=b/2:
    y=2*h-b
    t=b-y
    shita=math.degrees(math.atan2(t,a))
print(shita)