Harryxun/stf_run huggingface dataset:
N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
        
        
answer.pop(ind)
print(sum(answer)

### FIXED CODE ###

N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
         
answer.pop(ind)
print(sum(answer))
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
def check(x):
  t=0
  for i in range(N):
    t+=math.ceil(A[i]/x)-1
  if t<=K:
    return 10
  else:
    return 0
low=0
high=max(A)
sig=(low+high)//2
tf=0
if K==0:
  tf=1
  ans=high
while tf==0:
  if check(sig)==10:
    if check(sig-1)==0:
      ans=sig
      break
    else:
      high=sig-1
      sig=(low+sig)//2
  else:
    low=sig+1
    sig=(high+sig)//2
print(ans)

### FIXED CODE ###

import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
def check(x):
  if x==0:
    return 0
  else:
    t=0
    for i in range(N):
      t+=math.ceil(A[i]/x)-1
    if t<=K:
      return 10
    else:
      return 0
low=0
high=max(A)
sig=(low+high)//2
tf=0
if K==0:
  tf=1
  ans=high
while tf==0:
  if check(sig)==10:
    if check(sig-1)==0:
      ans=sig
      break
    else:
      high=sig-1
      sig=(low+high)//2
  else:
    low=sig+1
    sig=(high+low)//2
print(ans)
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

N = int(input())
ps = [list(map(int, input().split())) for _ in range(N-1)]
ps.sort()
tree = WeightedUnionFind(N)
for i, j, d in ps:
    tree.union(i, j, d)
for i in range(1, N+1):
    if diff(1, i) % 2 == 0:
        print(1)
    else:
        print(0)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n=int(input())
G=[[]for i in range(n+1)]
for i in range(n-1):
    a, b, c = map(int,input().split())
    G[a] += (b,c),
    G[b] += (a,c),
    
d = [0]*(n+1) #1から各点への距離
def f(v,p,u): #v:今見ているとこ p:一つ前に見たとこ u:1からの距離
    d[v] = u
    for t, c in G[v]:
        if p != t:
            f(t,v,u+c)
f(1,0,0)
for i in range(n):
    if d[i+1] % 2 == 0:
        print(1)
    else:
        print(0)
import sys
from itertools import permutations, combinations

n, c = map(int, sys.stdin.readline().split())
d = [[int(x) for x in sys.stdin.readline().split()] for _ in range(c)]
grid = [[int(x) - 1 for x in sys.stdin.readline().split()] for _ in range(n)]

cost = [[0] * 3 for _ in range(c)]
for i in range(n):
  for j in range(n):
    k = (i + j) % 3
    for l in range(c):
      cost[k][l] += d[grid[i][j]][l]
  
def main():
  res = []
  for comb in combinations(range(c), 3):
    for i, j, k in permutations(comb):
      res.append(cost[0][i] + cost[1][j] + cost[2][k])
  print(min(res))

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
import numpy as np 
from itertools import permutations

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, C = I[:2]
cost = I[2:2+C**2].reshape(C, C)
color = I[2+C**2:].reshape(n, n) - 1

def main():
    mod_3 = (np.arange(1, n+1)[:, None] + np.arange(1, n+1)) % 3
    c0 = np.bincount(color[mod_3 == 0], minlength=C)
    c1 = np.bincount(color[mod_3 == 1], minlength=C)
    c2 = np.bincount(color[mod_3 == 2], minlength=C)

    ans = float('inf')
    for i, j, k in permutations(range(C), 3):
        res = np.sum(c0 * cost[:, i])
        res += np.sum(c1 * cost[:, j])
        res += np.sum(c2 * cost[:, k])
        ans = min(ans, res)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)
n,a,b,c = map(int,input().split())
Y = []
f = True
S = []
for i in range(n):
    S.append(input())
GB = []
i = 0
g = False
while i<n:
    s = S[i]
    if s == "AB":
        if a>b:
            a -= 1
            b += 1
            Y.append("B")
        elif a<b:
            a += 1
            b -= 1
            Y.append("A")
        else:
            if g:
                a -= 1
                b += 1
                Y.append("B")
            else:
                a += 1
                b -= 1
                Y.append("A")
                GB.append(i)
    elif s == "AC":
        if a>c:
            a -= 1
            c += 1
            Y.append("C")
        elif a<c:
            a += 1
            c -= 1
            Y.append("A")
        else:
            if g:
                a -= 1
                c += 1
                Y.append("C")
            else:
                a += 1
                c -= 1
                Y.append("A")
                GB.append(i)
    else:
        if c>b:
            c -= 1
            b += 1
            Y.append("B")
        elif c<b:
            c += 1
            b -= 1
            Y.append("C")
        else:
            if g:
                c -= 1
                b += 1
                Y.append("B")
            else:
                c += 1
                b -= 1
                Y.append("C")
                GB.append(i)
    # print("i",i)
    # print(a,b,c)
    # print(GB)
    if a<0 or b<0 or c<0:
        if GB:
            i = GB.pop(-1)
            del Y[i]
        else:
            f = False
            print("No")
            break
    
    i += 1 
        
if f:
    print("Yes")
    for y in Y:
        print(y)


### FIXED CODE ###

N,a,b,c = map(int,input().split())
S = []
D = [a,b,c]
# d = a+b+c
for _ in range(N):
    S.append(input())
# print(S)
Y = []

def f(s,ns):
    s0 = ord(s[0])-65
    s1 = ord(s[1])-65
    k = 0
    if D[s0] == D[s1]:
        ns0 = ord(ns[0])-65
        ns1 = ord(ns[1])-65
        
        if s0 == ns0 and s1 == ns1:
            k = 0
        elif s0 == 3 - ns0 - ns1:
            k = 0
        else:
            k = 1
    
    elif D[s0] > D[s1]:
        k = 0
    else:
        k = 1
        
    if k==0:
        D[s0] -= 1
        D[s1] += 1
        # print(s[1])
        Y.append(s[1])
    else:
        D[s0] += 1
        D[s1] -= 1
        # print(s[0])
        Y.append(s[0])
        

g = True
# print(D)
for i in range(N):
    s = S[i]
    if i == N-1:
        ns = s
    else:
        ns = S[i+1]
    # print(s,ns)
    f(s,ns)
    # print(D)
    if D[0] < 0 or D[1] < 0 or D[2] < 0:
        print("No")
        g = False
        break
    
if g:
    print("Yes")
    for y in Y:
        print(y)
N = int(input())
Alist = list(map(int, input().split()))

a = set(Alist)
print(len(a))

### FIXED CODE ###

N = int(input())
Alist = input().split()
 
a = set(Alist)
if len(a) == 3:
    print('Three')
else:
    print('Four')
x = int(input())
print(3(*x**2))

### FIXED CODE ###

x = int(input())
print(3*(x**2))
n=int(input())
s=input()
ans=s.count('R')*s.count('G')*s.count('B')    
for i in range(n):
    for j in range(i+1,n):
        k=2*j-i
        if k>=n:
            break
        if s[i]!= s[j] and s[i]!=s[k] and s[i+j]!= s[k] :
            ans-=1
print(ans)

### FIXED CODE ###

n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")
for i in range(n):
  for j in range(i,n):
    if 2*j-i>=n:
      break
    else:
      if s[i]!=s[j]!=s[2*j-i]!=s[i]:
        ans-=1
print(ans)
# -*- coding: utf-8 -*-
#ABC070C
import math

#def lcm(x, y):
#	ans=((x * y) // math.gcd(x, y))
#	return ans

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

t=[]
for i in range(0,n):
	t.append(0)
for i in range(0,n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
	j = math.gcd(ans,t[i])
	ans *= t[i]
	ans = ans//j

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
#ABC070C
import math

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n = int(input())

t=[]
for i in range(0,n):
	t.append(0)
for i in range(0,n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
	j = gcd(ans,t[i])
	ans *= t[i]
	ans = ans//j

print(ans)
a, b, c, d = map(int, input().split())
aok = 0
while c > 0:
  c = c - b
  aok += 1
  
if (int(aok) - 1) * d - a => 0:
  print("NO")
else:
  print("Yes")

### FIXED CODE ###

a, b, c, d = map(int, input().split())
aok = 0
while c > 0:
  c = c - b
  aok += 1
  
if ((aok - 1) * d - a) >= 0:
  print("No")
else:
  print("Yes")
s = input()
N = len(s)
if N == 2:
    if s[0] == s[1]:
        print('1 2')
        quit()
    else:
        print('-1,-1')
        quit()
for i in range(N-2):
    if s[i] == s[i+1] or s[i] == s[i+2]:
        print(i+1, i+3)
        quit()
if s[-1] == s[-2]:
    print(N-1, N
    quit()
print('-1 -1')


### FIXED CODE ###

s = input()
N = len(s)
if N == 2:
    if s[0] == s[1]:
        print('1 2')
        quit()
    else:
        print('-1 -1')
        quit()
for i in range(N-2):
    if s[i] == s[i+1] or s[i] == s[i+2]:
        print(i+1, i+3)
        quit()
if s[-1] == s[-2]:
    print(N-2, N)
    quit()
print('-1 -1')
N = int(input())
A = list(map(int, input().split()))
dp = [0, abs(A[1] - A[0])]
for i in range(2, N):
  dp[i] = min(
    abs(A[i] - A[i - 1]) + dp[i - 1],
    abs(A[i] - A[i - 2]) + dp[i - 2])
print(dp[-1])


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(A[1] - A[0])
for i in range(2, N):
  dp[i] = min(
    abs(A[i] - A[i - 1]) + dp[i - 1],
    abs(A[i] - A[i - 2]) + dp[i - 2])
print(dp[-1])
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(H: int, W: int, A: "List[str]"):
    queue = deque()

    for i,l in enumerate(A):
        for j, c in enumerate(l):
            if c == '#':
                queue.append((i, j, 0))
    
    ret = 0
    visited = [[False] * W for _ in range(H)]
    while queue:
        i, j, n = queue.popleft()
        if visited[i][j]:
            continue
        visited[i][j] = True

        ret = max(ret, n)
        if 0 < j:
            queue.append((i, j - 1, n + 1))
        if j < W - 1:
            queue.append((i, j + 1, n + 1))
        if 0 < i:
            queue.append((i - 1, j, n + 1))
        if i < H - 1:
            queue.append((i + 1, j, n + 1))
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(W) ]  # type: "List[str]"
    result = solve(H, W, A)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *


def solve(H: int, W: int, A: "List[str]"):
    queue = deque()

    rem = H * W
    visited = [True] * ((W+2) * (H+2))
    for i in range(W+2):
        visited[i] = False
        visited[(W + 2) * (H + 1) + i] = False
    for i in range(H+2):
        visited[(W + 2) * i] = False
        visited[(W + 2) * i + (W + 1)] = False

    for i in range(H):
        l = A[i]
        for j in range(W):
            if l[j] == '#':
                queue.append((i+1, j+1, 0))
                k = i * (W + 2) + j
                visited[k] = False

    ret = 0
    while queue:
        i, j, n = queue.popleft()
        k = i * (W + 2) + j
        if not visited[k] and 0 < n:
            continue
        visited[k] = False
        ret = n
        rem -= 1

        if rem == 0:
            break

        if visited[k - 1]:
            queue.append((i, j - 1, n + 1))
        if visited[k + 1]:
            queue.append((i, j + 1, n + 1))

        if visited[k - (W + 2)]:
            queue.append((i - 1, j, n + 1))
        if visited[k + (W + 2)]:
            queue.append((i + 1, j, n + 1))
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    result = solve(H, W, A)
    print(result)

if __name__ == '__main__':
    main()
s=input()

if len(s)==2:
  print(s)
if len(s)==3:
  s.reverse()
  print(s)


### FIXED CODE ###

s=input()

if len(s)==2:
  print(s)
if len(s)==3:
  ss = s[::-1]
  print(ss)
lst0 = [1, 3, 5, 7, 8, 10, 12]
lst1 = [4, 6, 9, 11]
x, y = map(int, input().split())

for i in range(2):
    if x in lst[i] and y in lst[i]:
        print('Yes')
        break

else:
    print('No')

### FIXED CODE ###

lst0 = [1, 3, 5, 7, 8, 10, 12]
lst1 = [4, 6, 9, 11]
x, y = map(int, input().split())

if (x in lst0 and y in lst0) or (x in lst1 and y in lst1):
    print('Yes')

else:
    print('No')
n_y = list(map(int,input().split()))

price = 0
ok = 0

for i in range(n_y[0]+1):
    for j in range(n_y[0]+1):
            k = n_y[0] - i - j
            if k < 0:
                k = 0

            price = 10000 * i + 5000 * j + 1000 * k   
            
            if price == n_y[1] and i+j+k == n_y[0] and ok == 0:
                print(i, j, k)
                ok = 1
                break

            else:
                no_flg = 1
    else:
        continue
    break

if no_flg == 1 and ok == 0:
    print(-1, -1, -1 )

### FIXED CODE ###

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

price = 0
ok = 0

for i in range(n+1):
    for j in range(n+1):
            k = n - i - j
            if k < 0:
                k = 0

            price = 10000 * i + 5000 * j + 1000 * k   
            
            if price == y and i+j+k == n and ok == 0:
                print(i, j, k)
                ok = 1
                break

    else:
        continue
    break

if ok == 0:
    print(-1, -1, -1 )
N=int(input())
if N.count(7)>0:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

N=str(input())
if N.count('7')>0:
	print('Yes')
else:
	print('No')
import sys
s = list(raw_input())
if len(s) == 2:
    if s[0] == s[1]:
        print 1, 2
    else
        print -1, -1
else:
    for n in range(3, len(s)):
        for i in xrange(len(s) - n + 1):
            sub = s[i:i+n]
            for char in set(sub):
                if sub.count(char) >= n / 2 + n % 2:
                    print i + 1, i + n
                    sys.exit()
    print -1, -1


### FIXED CODE ###

import sys
s = list(raw_input())
if len(s) == 2:
    if s[0] == s[1]:
        print 1, 2
    else:
        print -1, -1
else:
    for n in [3]:
        for i in xrange(len(s) - n + 1):
            sub = s[i:i+n]
            for char in set(sub):
                if sub.count(char) >= n / 2 + n % 2:
                    print i + 1, i + n
                    sys.exit()
    print -1, -1
ースコード 

Copy
Copy
#参考 ： AtCoder # 14682107
s = input()
len = len(s)
 
if len == 1:
    print(0)
    exit()
 
even = s[::2]
odd = s[1::2]
 
#偶数番目に0が並ぶと仮定したときの異物の数
# 0101...
odd_zero = odd.count("0")
even_one = even.count("1")
 
 
#奇数番目に0が並ぶと仮定したときの異物の数
# 1010...
odd_one = odd.count("1")
even_zero = even.count("0")
 
print(min(odd_zero + even_one, odd_one + even_zero))

### FIXED CODE ###

s = input()
l= len(s)
 
if l== 1:
    print(0)
    exit()
 
even = s[::2]
odd = s[1::2]

odd_zero = odd.count("0")
even_one = even.count("1")
 

odd_one = odd.count("1")
even_zero = even.count("0")
 
print(min(odd_zero + even_one, odd_one + even_zero))
a,b,c = map(int,input().split())

if A > X:
  print("NO")
elif A+B < X:
  print("NO")
else:
  print("YES")

### FIXED CODE ###

A,B,X = map(int,input().split())

if A > X:
  print("NO")
elif A+B < X:
  print("NO")
else:
  print("YES")
from operator import mul
from functools import reduce

N, K = [int(n) for n in input().split()]
R = N - K

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    if under == 0:
        return 0
    res = over // under
    return res

def calc(i):
    blue = i
    red = i - 1
    a = cmb(K - 1, blue - 1)
    b = cmb(R + 1, red + 1)
    return a * b

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


### FIXED CODE ###

from operator import mul
from functools import reduce

N, K = [int(n) for n in input().split()]
R = N - K

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    res = over // under
    return res

def calc(i):
    blue = i
    red = i - 1
    a = cmb(K - 1, blue - 1) if K >= blue else 0
    b = cmb(R + 1, red + 1) if R >= red else 0
    return a * b

M = 10**9 + 7
for i in range(1, K + 1):
    print(calc(i) % M)
k=input()
odd=0
even=0
for i in range(1,k+1) 
     if i%2==0:
        even+=1
     else:
            odd+=1
print(odd*even)

### FIXED CODE ###

import math

n = int( input())

print( math.ceil(n/2) * math.floor(n/2))
def main():
	H, W, A, B = map(int, input().split())
	H, W= H-1, W-1
	DIV = 10**9+7
	size = H+W+1

	fact = [0]*size
	inverse = [0]*size
	inv_cal = [0]*size
	fact[:2] = [1, 1]
	inverse[:2] = [1, 1]
	inv_cal[:2] = [0, 1]

	for i in range(2, size):
		fact[i] = (fact[i-1]*i%DIV)
		inv_cal[i] = (-inv_cal[DIV%i]*(DIV//i))%DIV
		inverse[i] = inverse[i-1]*inv_cal[i]%DIV

	def C(n, r):
		ans = fact[n]*inverse[r]%DIV
		return ans*inverse[n-r]%DIV

	ans = 0
	for x in range(B, W+1):
		y = H-A
		tmp = (C(x+y, x)*(C(H+W-x-y-1, W-x))%DIV
		ans += tmp
		ans %= DIV

	print(ans)


if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	H, W, A, B = map(int, input().split())
	H, W= H-1, W-1
	DIV = 10**9+7
	size = H+W+1

	fact = [0]*size
	inverse = [0]*size
	inv_cal = [0]*size
	fact[:2] = [1, 1]
	inverse[:2] = [1, 1]
	inv_cal[:2] = [0, 1]

	for i in range(2, size):
		fact[i] = (fact[i-1]*i%DIV)
		inv_cal[i] = (-inv_cal[DIV%i]*(DIV//i))%DIV
		inverse[i] = inverse[i-1]*inv_cal[i]%DIV

	def C(n, r):
		ans = fact[n]*inverse[r]%DIV
		return ans*inverse[n-r]%DIV

	ans = 0
	for x in range(B, W+1):
		y = H-A
		tmp = (C(x+y, x)%DIV)*(C(H+W-x-y-1, W-x)%DIV)%DIV
		ans += tmp
		ans %= DIV

	print(ans)


if __name__ == '__main__':
	main()
N,K = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9+7

if all(a>=0 for a in A):
    A.sort()
    ans = 1
    for _ in range(K):
        ans *= A.pop()
        ans %= MOD
    print(ans)
    exit()
if all(a<0 for a in A):
    A.sort(reverse=K%2==0)
    ans = 1
    for _ in range(K):
        ans *= A.pop()
        ans %= MOD
    print(ans)
    exit()

arr = []
for a in A:
    if a < 0:
        arr.append((-a,1))
    else:
        arr.append((a,0))

arr.sort()
pz = []
ng = []
ans = 1
for _ in range(K):
    v,s = arr.pop()
    if s:
        ng.append(v)
    else:
        pz.append(v)

for v in ng:
    ans *= v
    ans %= MOD
for v in pz:
    ans *= v
    ans %= MOD
if len(ng)%2 == 0:
    print(ans)
    exit()

b = pz[-1] if pz else None
c = ng[-1] if ng else None
a = d = None
while arr and (a is None or d is None):
    v,s = arr.pop()
    if s:
        if a is None:
            a = v
    else:
        if d is None:
            d = v

if (a is not None and b is not None) or (c is not None and d is not None):
    print(ans)
    exit()

if a is None or b is None:
    ans *= d * pow(c,-1,MOD)
elif c is None or d is None:
    ans *= a * pow(b,-1,MOD)
else:
    if a*c > b*d:
        ans *= a * pow(b,-1,MOD)
    else:
        ans *= d * pow(c,-1,MOD)
ans %= MOD
print(ans)

### FIXED CODE ###

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

if all(a>=0 for a in A):
    A.sort()
    ans = 1
    for _ in range(K):
        ans *= A.pop()
        ans %= MOD
    print(ans)
    exit()
if all(a<0 for a in A):
    A.sort(reverse=K%2==0)
    ans = 1
    for _ in range(K):
        ans *= A.pop()
        ans %= MOD
    print(ans)
    exit()
if N==K:
    ans = 1
    for a in A:
        ans *= a
        ans %= MOD
    print(ans)
    exit()

arr = []
for a in A:
    if a < 0:
        arr.append((-a,1))
    else:
        arr.append((a,0))

arr.sort()
pz = []
ng = []
for _ in range(K):
    v,s = arr.pop()
    if s:
        ng.append(v)
    else:
        pz.append(v)

if len(ng)%2 == 0:
    ans = 1
    for v in ng:
        ans *= v
        ans %= MOD
    for v in pz:
        ans *= v
        ans %= MOD
    print(ans)
    exit()

b = pz[-1] if pz else None
c = ng[-1] if ng else None
a = d = None
while arr and (a is None or d is None):
    v,s = arr.pop()
    if s:
        if a is None:
            a = v
    else:
        if d is None:
            d = v

if (a is None or b is None) and (c is None or d is None):
    assert False

ans = 1
if a is None or b is None:
    ans = d
    for v in ng[:-1]:
        ans *= v
        ans %= MOD
    for v in pz:
        ans *= v
        ans %= MOD
elif c is None or d is None:
    ans = a
    for v in ng:
        ans *= v
        ans %= MOD
    for v in pz[:-1]:
        ans *= v
        ans %= MOD
else:
    if a*c > b*d:
        ans = a
        for v in ng:
            ans *= v
            ans %= MOD
        for v in pz[:-1]:
            ans *= v
            ans %= MOD
    else:
        ans = d
        for v in ng[:-1]:
            ans *= v
            ans %= MOD
        for v in pz:
            ans *= v
            ans %= MOD
ans %= MOD
print(ans)