Harryxun/stf_run huggingface dataset:
from collections import Counter

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

if len(set(v)) != 1:
    a = Counter(v[0::2]).most_common()
    b = Counter(v[1::2]).most_common()

    if a[0] != b[0]:
        q = ((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[0][1]))
        w = ((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))
        e = ((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))
        print(min(q, w, e))
else:
    print(len(v[1::2]))


### FIXED CODE ###

from collections import Counter

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

if len(set(v)) != 1:
    a = Counter(v[0::2]).most_common()
    b = Counter(v[1::2]).most_common()
    if a[0][0] != b[0][0]:
        print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[0][1]))
    else:
        if a[0][1] < b[0][1]:
            print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))
        elif a[0][1] > b[0][1]:
            print((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))
        elif a[0][1] == b[0][1]:
            if len(a) != 1 and len(b) != 1:
                if a[1][1] > b[1][1]:
                    print((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))
                elif a[1][1] < b[1][1]:
                    print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))
                elif a[1][1] == b[1][1]:
                    print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))
            elif len(a) != 1:
                print((len(v[0::2]) - a[1][1]) + (len(v[1::2]) - b[0][1]))
            elif len(b) != 1:
                print((len(v[0::2]) - a[0][1]) + (len(v[1::2]) - b[1][1]))
else:
    print(len(v[1::2]))
import math
from functools import reduce

def gcd(nums):
    return reduce(math.gcd, nums)

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

maxgcd = 0
for i in range(len(a)):
    temp = gcd(a[:i] + a[i + 1:])
    if temp > maxgcd:
        maxgcd = temp

print(maxgcd)

### FIXED CODE ###

from fractions import gcd

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

lgcd, rgcd = [], []
for i in range(n):
    if i == 0:
        lgcd.append(a[0])
        rgcd.append(a[n-1])
        continue

    lgcd.append(gcd(lgcd[i-1], a[i]))
    rgcd.append(gcd(rgcd[i-1], a[-1-i]))

maxgcd = 1
for i in range(n):
    if i == 0:
        tempgcd = rgcd[n-2]
    elif i == n-1:
        tempgcd = lgcd[n-2]
    else:
        tempgcd = gcd(lgcd[i-1], rgcd[n-2-i])
    maxgcd = max(maxgcd, tempgcd)
print(maxgcd)
n = int(input())
a = list(map(int, input().split()))
count = 0
sum_ = 0
for i in range(n):
    if sum_ * (sum_+a[i]) <0 or i == 0:
        sum_ += a[i]
    elif sum_ > 0:
        count += sum_+a[i]+1
        a[i] = -sum_-1
        sum_ += a[i]
    elif sum_ < 0:
        count += abs(sum_+a[i])+1
        a[i] = -sum_+1
        sum_ += a[i]

print(count)

### FIXED CODE ###

s1, s2, s3 = input().split()

ans = s1[0] + s2[0] + s3[0]

print(ans.upper())
N = int(input())

X = list(map(int, input().split()))
ans = 10**18
for i in range(1, 101):
    temp=0
    for num in X:
        temp += (i-num)**2
    ans = min(ans, tmp)
print(ans)

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
ans=10**18 #最小値を求めるので初期化しておく
for i in range(1,101): #1<=P<=100の範囲について消費する体力の総和を計算
 tmp=0
 for num in arr:
   tmp+=(i-num)**2
 ans=min(ans,tmp) #消費する体力の総和の最小値が答えとなる
print(ans)
N = int(input())
S = input()
ans = 0
anslst = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            anslst.append(str(i) + str(j) + str(k))

tmp = ans
for i in anslst:
    for j in range(N):
        if i[0] == S[j]:
            for k in range(j + 1, N):
                if i[1] == S[k]:
                    for n in range(k + 1, N):
                        if i[2] == S[n]:
                            ans += 1
                            break
                    break
        if tmp != ans:
            tmp = ans
            break
print(ans)

### FIXED CODE ###

import sys

X = int(input())
tmp1 = X // 100
tmp2 = X % 100
ans = 1

if X < 100:
    print(0)
    sys.exit()
if tmp1 == 0:
    print(ans)
    sys.exit()

for i in range(5, 0, -1):
    t1 = tmp2 // i
    t2 = tmp2 % i
    tmp2 = t2
    tmp1 -= t1
    if tmp1 < 0:
        ans = 0
        break

if t2 != 0:
    ans = 0

print(ans)
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = min(A)
res = 0
for i in range(N):
    min_num = i
    if m == A[i]:
        break
    
        
n1 = min_num 
n2 = N - min_num - 1

if n1 == 0:
    res = math.ceil(n2/2)
elif n2 == 0:
    res = math.ceil(n1/2)
else:
    res = math.ceil(n1/2) + math.ceil(n2/2)
    
print(res)

### FIXED CODE ###

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

ans = 1
tmp = N - K
ans += tmp // (K - 1)

if tmp%(K - 1) != 0:
    ans += 1

print(ans)
a, b = input().split()
if a <= b:
    print(a)
else:
    print(a-1)

### FIXED CODE ###

a, b = map(int, input().split())
print(a if a <= b else a - 1)
N = int(input())
 ab = sorted([ tuple(map(int, input().split())) for x in range(N)], key=lambda x:x[1], reverse=True)
 cd = sorted([ tuple(map(int, input().split())) for x in range(N)])
 resultx = []
 resulty = []
 for xb, yb in list(cd):
     for xr, yr in list(ab):
         if (xr, yr) in resultx:
             continue
         if xr < xb and yr < yb:
             resultx.append((xr,yr))
             resulty.append((xb,yb))
             break

 print(len(resultx))

### FIXED CODE ###

N = int(input())
ab = sorted([ tuple(map(int, input().split())) for x in range(N)], key=lambda x:x[1],reverse=True)
cd = sorted([ tuple(map(int, input().split())) for x in range(N)])
resultx = []
resulty = []
for xb, yb in list(cd):
    for xr, yr in list(ab):
        if (xr, yr) in resultx:
            continue
        if xr < xb and yr < yb:
            resultx.append((xr,yr))
            resulty.append((xb,yb))
            break

print(len(resultx))
N = int(input().split())
num = list(map(int,input().split()))
a = 1
for n in num:
  a = n*a
if a> 10**18:
  a=1
print(a)

### FIXED CODE ###

import sys
N = int(input())
num = list(map(int,input().split()))
num.sort(reverse=True)
a = 1
if num[-1] == 0:
  print(0)
else:
  for n in range(N):
    a = num[n]*a
    if a> 10**18:
      print(-1)
      sys.exit()
  print(a)
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    if A.count("0") != 0:
        print("0")
        exit()
    for i in A:
        ans *= i
        if ans > 10**18:
          print("-1")
          exit()
    print(ans)
    exit()
resolve()

### FIXED CODE ###

def resolve():
    A, B = map(int, input().split())
    print(A*B)
resolve()
import math
r = int(input())
area = r * r * math.pi
circum = 2 * r * math.pi
print("{:f} {:f}".format(area, circum))

### FIXED CODE ###

import math
r = float(input())
area = r * r * math.pi
circum = 2 * r * math.pi
print("{:f} {:f}".format(area, circum))
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        hi=[]
        flg=True
        B=[]
        for a in A:
            if a[2]!=0:
                hi_=a[2]+abs(a[1]-j)+abs(a[0]-i)
                hi.append(hi_)
            else:
                B.append([a[0],a[1])
            if len(hi)>=2:
                if hi[-1]!=hi[-2]:
                    flg=False
        #print(i,j,hi)
        if flg:
            flg2=True
            for b in B:
                if hi[0]-abs(a[1]-j)-abs(a[0]-i)>0:
                    flg2=False
        if flg2:
            ans=[i,j,hi[0]]
print(*ans)


### FIXED CODE ###

N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
cnt=0
for a in A:
    if a[2]!=0:
        cnt+=1
        ans=a
if cnt==1:
    print(*ans)
    exit()
for i in range(101):
    for j in range(101):
        hi=[]
        flg=True

        for a in A:
            if a[2]!=0:
                hi_=a[2]+abs(a[1]-j)+abs(a[0]-i)
                hi.append(hi_)

            if len(hi)>=2:
                if hi[-1]!=hi[-2]:
                    flg=False
        #print(i,j,hi)
        if flg:
            ans=[i,j,hi[0]]

print(*ans)
A,B,K = map(int,input().split())
lists = list(range(A,B+1))
result = list(set(lists[:K] + lists[-K:]))
result.sort()
if K > len(lists):
        for j in range(len(lists)):
                print(lists[j])
else:
        for i in range(len(result)):
                print(result[i])

### FIXED CODE ###

A,B,K = map(int,input().split())
if abs(B-A) < K:
    for i in range(A,B+1):
        print(i)
    exit()
min_list = list(range(A,A+K))
max_list = list(range(B-K+1,B+1))
lists = list(set(min_list) | set(max_list))
lists.sort()
for i in range(len(lists)):
    print(lists[i])
n,m = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
x.sort()
a = []
for i in x:
	if i[0]==1:
		a.append(i[1])
	else:
		break
for j in a:
	if [j,n] in x:
		m = 0
		print("POSSIBLE")
		break
if m != 0:
	print("IMPOSSIBLE")

### FIXED CODE ###

n,m = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(m)]
a ,b= [],[]
for i in x:
	if i[0]==1:
		a.append(i[1])
	if i[1]==n:
		b.append(i[0])
if len(a)+len(b) == len(set(a+b)): print("IMPOSSIBLE")
else: print("POSSIBLE")
s=input()
dict1={}
for i in s:
	if i in dict1:
		dict1[i]+=1
	else:
		dict1[i]=0
if(dict1['A'] > 0 and dict1['B'] > 0):
	print("Yes")
else:
	print("No")

### FIXED CODE ###

s=input()
dict1={}
if('A' in s and 'B' in s):
	print("Yes")
else:
	print("No")
from collections import deque
def check():
    S = input()
    x, y = map(int, input().split())
    fs = list(map(len,S.split('T')))
    xs = fs[::2]
    ys = fs[1::2]
    xs.sort(reverse = True)
    N = len(xs)
    M = len(ys)
    cum = [xs[-1]]*N
    for i in range(N-2,-1,-1):
        cum[i] = cum[i+1]+xs[i]
    pos = deque([-x])
    for i in range(N):
        l = len(pos)
        if l == 0:
            return False
        for _ in range(l):
            d = pos.popleft()
            if abs(d)<=cum[i]:
                pos.append(d+xs[i])
                pos.append(d-xs[i])
    if 0 not in pos:
        return False
    ys.sort(reverse = True)
    cum = [ys[-1]]*M
    for i in range(M-2,-1,-1):
        cum[i] = cum[i+1]+ys[i]
    pos = deque([0])
    for i in range(M):
        l = len(pos)
        if l == 0:
            return False
        for _ in range(l):
            d = pos.popleft()
            if abs(d)<=cum[i]:
                pos.append(d+ys[i])
                pos.append(d-ys[i])
    if y not in pos:
        return False
    return True
if check():
    print('Yes')
else:
    print('No')

### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10**8)

def dp(dp_l,i,N,xs,cum,now):
    if i == N:
        if now == 0:
            return True
        return False
    if abs(now) > cum[i]:
        return False
    if dp_l[i][abs(now)] != -1:
        return dp_l[i][abs(now)]
    dp_l[i][abs(now)] = dp(dp_l,i+1,N,xs,cum,now+xs[i]) or dp(dp_l,i+1,N,xs,cum,now-xs[i])
    return dp_l[i][abs(now)]

def check():
    S = input()
    x, y = map(int, input().split())
    fs = list(map(len,S.split('T')))
    if len(fs)<3:
        if x != fs[0]:
            return False
        if len(fs)==1:
            if y == 0:
                return True
            else:
                return False
        if y != fs[1] and y != -fs[1]:
            return False
        return True
    xs = fs[2::2]
    ys = fs[1::2]
    xs.sort(reverse = True)
    N = len(xs)
    M = len(ys)
    cum = [0]*(N+1)
    for i in range(N-1,-1,-1):
        cum[i] = cum[i+1]+xs[i]
    dp_l = [[-1]*(cum[0]+1) for _ in range(N)]
    if not dp(dp_l,0,N,xs,cum,fs[0]-x):
        return False
    ys.sort(reverse = True)
    cum = [ys[-1]]*(M+1)
    for i in range(M-1,-1,-1):
        cum[i] = cum[i+1]+ys[i]
    dp_l = [[-1]*(cum[0]+1) for _ in range(M)]
    if not dp(dp_l,0,M,ys,cum,-y):
        return False
    return True
if check():
    print('Yes')
else:
    print('No')
N, A = map(int, input().split())

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

tmp_max = max(x)
tmp_max = max(tmp_max, A)

dp = [[[0 for _ in range(tmp_max * N + 1)] for _ in range(N + 1)] for _ i range(N + 1)]
dp[0][0][0] = 0

for j in range(N + 1):
  for k in range(j + 1):
    for s in range(tmp_max * k + 1):
      if j >= 1 and s < x[j - 1]:
        dp[j][k][s] = dp[j - 1][k][s]
      elif j >= 1 and k >= 1 and s >= x[j - 1]:
        dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
        
        
ans = 0
for k in range(1, N + 1):
  ans += dp[N][k][k * A]
  
print(ans)

### FIXED CODE ###

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

max_num = max(x)
max_num = max(A, max_num)
# x_jまでからk枚選んで合計がｓになる選び方の総数。ｓはk*Aにすれば平均がAになる
dp = [[[0 for _ in range(max_num * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
#何も選ばないで平均が０
dp[0][0][0] = 1

for j in range(N+1):
  for k in range(j+1):
    for s in range(max_num * k + 1):
      if j >= 1 and s < x[j - 1]:
        # j番目を選んでk+1個を選んだ際に平均がAにならない場合
        dp[j][k][s] = dp[j - 1][k][s]
      elif j >= 1 and k >= 1 and s >= x[j - 1]:
        # j番目をえらんでk+1個選んで平均がAになるものがあるなら、j-1番までの合計はs-x_j-1なので、その数を足している
        dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
 

ans = 0
# 合計がkAになるものを加算
for k in range(1, N + 1):
  ans += dp[N][k][k*A]
print(ans)
import numpy as np

H, W, M = map(int, input().split())
bomb = np.zeros((H, W))
for _ in range(M):
    h, w = map(int, input().split())
    h -=1
    w -=1
    bomb[h, w] = 1

col_sum = np.sum(bomb, axis=0)
row_sum = np.sum(bomb, axis=1)

col_max = col_sum.max()
row_max = row_sum.max()

max_col_indexs = np.where(col_sum == col_max)[0]
max_row_index = np.argmax(row_sum)

ans = col_sum.max() + row_sum.max() - 1
for col in max_col_indexs:
    if bomb[max_row_index, col] == 0:
        ans = ans = col_sum.max() + row_sum.max()
        break

print(int(ans))



### FIXED CODE ###

import numpy as np
def main():
    H, W, M = map(int, input().split())
    row = np.zeros(W)
    col = np.zeros(H)
    memo = []
    for _ in range(M):
        h, w = map(int, input().split())
        h -=1
        w -=1
        row[w] += 1
        col[h] += 1
        memo.append((h, w))

    col_max = col.max()
    row_max = row.max()

    max_col_indexs = np.where(col == col_max)[0]
    max_row_indexs = np.where(row == row_max)[0]

    ans = col_max + row_max -1
    memo = set(memo)
    for c in max_col_indexs:
        for r in max_row_indexs:
            if (c, r) not in memo:
                ans = ans = col_max + row_max
                print(int(ans))
                exit()

    print(int(ans))

if __name__ == "__main__":
    main()
N=int(input())
A=list(map(int,input().split()))


low=0
high=10**10

#binary search the value of rain onto Mountain1
while low<=high:
    mid=(low+high)//2

    cur=mid
    for i,a in enumerate(A):
        cur=a-cur
        if cur<0:#途中で足りなくなったら、midが大きすぎ
            break
       #break
    if cur>=mid:
        low=mid+1
    else:
        if i%2==0:
            low=mid+1
        else:
          	high=mid-1
            low=mid+1


ans=[]
cur=high
for a in A:
    ans.append(cur*2)
    cur=a-cur
print(" ".join(map(str,ans)))



### FIXED CODE ###

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

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

sum_odd = sum([v for v in A[1::2]])
x0 = sum(A)-2*sum_odd
ans = [x0]

x = x0
for a in A:
    nex = 2*a-x
    ans.append(nex)
    x = nex
print(*ans[:-1])
N = int(input())
h_list = list(map(int, input().split()))

count_list = []
count = 0
for i in range(N-1):
    if h_list[i] >= h_list[i+1]:
        count += 1
        count_list.append(count)
    else:
        count = 0
        count_list.append(0)
    
print(max(count_list))


### FIXED CODE ###

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

count_list = []
if len(h_list) == 1:
    count_list.append(0)
else:
    count = 0
    for i in range(N-1):
        if h_list[i] >= h_list[i+1]:
            count += 1
            count_list.append(count)
        else:
            count = 0
            count_list.append(0)
    
print(max(count_list))
import math

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

a = list(map(int, input().split()))
l = 0
r = max(a)

x = (l+r)//2
ans = r+1
while(r>1+l):
    print(str(l)+":"+str(r))
    x = (l+r)//2
    count = 0
    for i in range(N):
        count += math.ceil(a[i] /x)-1
    if (count <=K):
        if (ans > x):
            ans = x
        r = x
    else:
        l = x

for i in range(N):
    count += math.ceil(a[i]/l)-1

if (count <=K):
    ans = l
else:
    ans = r
print(ans)

        
        

    


### FIXED CODE ###

import math

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

a = list(map(int, input().split()))
l = 0
r = max(a)

x = (l+r)//2
ans = r+1
while(r>1+l):

    
    x = (l+r)//2
    if x == 0:
        break

    count = 0
    for i in range(N):
        count += math.ceil(a[i] /x)-1
    if (count <=K):
        if (ans > x):
            ans = x
        r = x
    else:
        l = x
count = 0
ans = x
if(x!= 0 and l != 0):
        
    for i in range(N):
        count += math.ceil(a[i]/l)-1

    if (count <=K):
        ans = l
    else:
        ans = r

if l==0:
    ans = r
print(ans)
n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())

def solve(i, m):
 if i == m:
  return true
 if i > n:
  return false
 res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res
 
 for j in range(0, q-1):
  if m == solve(i + 1, m) || solve(i + 1, m - A[i]):
   print "yes"
  else:
   print "no"

### FIXED CODE ###

n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_input().split())

def solve(i, m):
 if m == 0:
  return True
 if i >= n or m > sum(A):
  return False
 res = solve(i+1, m) or solve(i+1, m-A[i])
 return res

for j in range(0, q):
 if solve(0, m[j]):
  print 'yes'
 else:
  print 'no'
while True:
????????h, w = map(int, input().strip().split())
????????if h == w == 0: break
????????for y in range(h):
????????????????print(''.join('#.'[(x + y) % 2] for x in range(w)))
????????print()

### FIXED CODE ###

while True:
    height, width = [int(x) for x in input().split(" ")]
    if height == width == 0:
        break
    col1 = "#." * 150
    col2 = ".#" * 150
    col_set = col1[:width] + "\n" + col2[:width] + "\n"
    print(col_set * (height // 2) + (col1[:width] + "\n") * (height % 2))
a,b=map(int,input().split)
if(a%2==1 and b%2==1):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b=map(int,input().split())
if(a%2==1 and b%2==1):
  print("Yes")
else:
  print("No")
r = int(input())

print((r*r)

### FIXED CODE ###

r = int(input())

print(r*r)
s = input().strip()
goal = tuple(map(int, input().split()))

def change_dir(direc, case):
    if case == 0:
        direc += 1
        if direc == 5:
            direc = 1
    else:
        direc -= 1
        if direc == 0:
            direc = 4
    return direc

def go_in_dir(direc, pos):
    if direc == 1:
        return (pos[0]+1, pos[1])
    elif direc == 2:
        return (pos[0], pos[1]+1)
    elif direc == 3:
        return (pos[0]-1, pos[1])
    else:
        return (pos[0], pos[1]-1)

def exec_s(s, goal, direc=1, pos=(0, 0)):
    if len(s) == 0:
        if pos == goal:
            return True
        else:
            return False

    new_pos = pos
    while len(s) > 0 and s[0] == 'F':
        new_pos = go_in_dir(direc, new_pos)
        s = s[1:]

    if len(s) == 0:
        if new_pos == goal:
            return True
        else:
            return False

    new_dir = change_dir(direc, 0)
    reached = exec_s(s[1:], goal, new_dir, new_pos)
    if reached:
        return True
    else:
        new_dir = change_dir(direc, 1)
        return exec_s(s[1:], goal, new_dir, new_pos)

if exec_s(s, goal):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input().split('T')
gx, gy = tuple(map(int, input().split()))

dir = 0
xmoves = []
ymoves = []
for moves in s:
    if dir % 2 == 0:
        xmoves.append(len(moves))
    else:
        ymoves.append(len(moves))
    dir += 1

curx, cury = xmoves.pop(0), 0

for move in sorted(xmoves, reverse=True):
    if curx > gx:
        curx -= move
    else:
        curx += move

for move in sorted(ymoves, reverse=True):
    if cury > gy:
        cury -= move
    else:
        cury += move

if curx == gx and cury == gy:
    print('Yes')
else:
    print('No')
n,a,b=[int,input(),split()]
print(min(n*a,b))


### FIXED CODE ###

n,a,b=map(int,input().split())
print(min(n*a,b))
a,b=map(int,input().split())
cnt=0
for i in range(a,b+1):
    if str(i)　==　str(i)[::-1]:
        cnt +=1　#count++はダメ
       
print(cnt)


### FIXED CODE ###

a,b=map(int,input().split())
cnt = 0
for i in range(a, b+1):
	if str(i) == str(i)[::-1]:
		cnt += 1
 
print(cnt)
n = int(input())
a = map(float,input().split())
for i in range(n):
    r += 1 / a[i]
print(1/r)

### FIXED CODE ###

d = input()
a = input().split()
r = 0
for i in a:
    r += 1 / int(i)
print(1 / r)
import numpy
R = int(input())
print(2*np.pi*R)

### FIXED CODE ###

import math
r = int(input())
print(2*math.pi*r)
N, K = map(int, input().split())
X = list(map(int, input().split()))
MOD = 10 ** 9 + 7

pos = sorted(v for v in X if v >= 0)
neg = sorted(-v for v in X if v < 0)

ok = False  # True: ans>0, False: ans<0
if pos:
    if N == K:
        # Select all -> number of negatives must be even
        ok = len(neg) % 2 == 0
    else:
        ok = True
else:
    # All negative
    ok = K % 2 == 0

ans = 1
if not ok:
    for i in range(K):
        ans = ans * (-neg[i]) % MOD
else:
    if K % 2 == 1 and pos:
        ans = ans * pos.pop() % MOD

    cand = []
    while len(pos) >= 2:
        x = pos.pop() * pos.pop()
        cand.append(x)

    while len(neg) >= 2:
        x = neg.pop() * neg.pop()
        cand.append(x)

    cand.sort(reverse=True)
    for i in range(K // 2):
        ans = ans * cand[i] % MOD

print(ans)


### FIXED CODE ###

N, K, *A = map(int, open(0).read().split())

MOD = 10 ** 9 + 7
s = []  # v >= 0
t = []  # v < 0
for i in range(N):
    if A[i] < 0:
        t.append(A[i])
    else:
        s.append(A[i])
        
ok = False  # ans > 0
if len(s) > 0:
    if N == K:
        ok = len(t) % 2 == 0
    else:
        ok = True
else:
    ok = K % 2 == 0

ans = 1
if not ok:
    x = sorted(A, key=lambda x: abs(x))
    for i in range(K):
        ans = ans * x[i] % MOD
else:
    s.sort()
    t.sort(key=lambda x: abs(x))
    if K % 2 == 1:
        ans = ans * s.pop() % MOD
        
    p = []
    while len(s) >= 2:
        x = s.pop() * s.pop()
        p.append(x)
    
    while len(t) >= 2:
        x = t.pop() * t.pop()
        p.append(x)

    p.sort(reverse=True)
    for i in range(K // 2):
        ans = ans * p[i] % MOD
    
print(ans)
A,B,C=map(int,input().split())
if A == C:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

A,B,C=input()
if int(A)==int(C):
  print('Yes')
else:
  print('No')