Harryxun/stf_run huggingface dataset:
import fractions
n = int(input())
a = list(map(int, input().split()))
b = [0] * 3
c = [0] * 3
for i in range(len(a)):
    if i == 0:
        b[i] = a[i]
        c[-i-1] = a[-i-1]
    else:
        b[i] = fractions.gcd(a[i], b[i-1])
        c[-i-1] = fractions.gcd(a[-i-1], c[-i])
b.insert(0, 0)
c.append(0)
m_gcd = 0
print(b, c)
for i in range(len(b)-2):
    m_gcd = max(fractions.gcd(c[i+1], b[i]), m_gcd)
print(m_gcd)


### FIXED CODE ###

import fractions
n = int(input())
a = list(map(int, input().split()))
f = [0] * n
r = [0] * n
for i in range(n):
    if i == 0:
        f[i] = a[i]
        r[-i-1] = a[-i-1]
    else:
        f[i] = fractions.gcd(f[i-1], a[i])
        r[-i-1] = fractions.gcd(r[-i], a[-i-1])
f.insert(0, 0)
r.append(0)
ans = 0
for i in range(len(f) - 1):
    ans = max(ans, fractions.gcd(f[i], r[i+1]))
print(ans)
import sys
def f(n):
    li = [x for x in range(2,n+1)]
    pr = []
    while True:
        pr.append(li[0])
        li = [x for x in li if x%li[0]!=0]
        if li[-1]<pr[-1]**2: return pr+li
for n in sys.stdin:
    print len(f(int(n)))

### FIXED CODE ###

import sys
n=1000000
pr=[1]*n
pr[0],pr[1]=0,0
for i in xrange(2,int(n**0.5)+1):
    if pr[i]==1:
        for j in xrange(i**2,n,i):
            pr[j]=0
for i in xrange(2,n):
    pr[i]+=pr[i-1]
for line in sys.stdin:
    print pr[int(line)]
N= int(input())

G = [[]*N for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append([b-1, i])

ans = [0]*(N-1)

def func(prt, col):
    cnt = 1
    for cld, org in G[prt]:
        if cnt==org:
            cnt += 1
        ans[org] = cnt
        func(cld, cnt)
        cnt += 1

func(0, 0)

print(max(ans))
for i in range(N-1):
    print(ans[i])

### FIXED CODE ###

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

n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append([b,i])

ans = [None]*(n-1)
def rec(cur,color):
    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        rec(to, cnt)
        cnt += 1
rec(0, 0)
print(max(ans))
print(*ans, sep="\n")
a=int(input())
s=input()
if a=>3200:
  print(s)
else:
  print('red')

### FIXED CODE ###

a=int(input())
s=input()
if a>=3200:
  print(s)
else:
  print('red')
n,m = map(int, input().split())
st = []
pt = []
ch = []
for i in range(n):
  st.append(list(map(int, input().split())))
for i in range(n):
  pt.append(list(map(int, input().split())))
for j in st:
  for k in pt:
    d = abs(j[0]-k[0]) + abs(j[1]-k[1])
    ch.append(d)
  print(ch.index(min(ch))+1)
  ch = []

### FIXED CODE ###

n,m = map(int, input().split())
st = []
pt = []
ch = []
for i in range(n):
  st.append(list(map(int, input().split())))
for i in range(m):
  pt.append(list(map(int, input().split())))
for j in st:
  for k in pt:
    d = abs(j[0]-k[0]) + abs(j[1]-k[1])
    ch.append(d)
  print(ch.index(min(ch))+1)
  ch = []
x, y = map(int,input().split())
z=-2
if x %2 == 0:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y :
            print("Yes")
    elif z!=y :
            print("No")
elif x%2 != 0:
    for i in range(x):
        if i % 2 == 0:
            z +=4
        else:
            z +=2
    if z == y or z == (y-2):
            print("Yes")
    elif z!=y :
            print("No")

### FIXED CODE ###

x1,x2,x3,x4,x5,=map(int,input().split())
if 0 == x1:
    print("1")
elif 0 == x2:
    print("2")
elif 0 ==x3:
    print("3")
elif 0 == x4:
    print("4")
else:
    print("5")
N, K = map(int, input().split())
ret = 0
for x in range(1, N + 1):
    for y in [y for y in range(K - x, N + 1, K) if y > 0]:
        for z in [z for z in range(K - y, N + 1, K) if z > 0]:
            cnt += 1     
            if  (z + x) % K == 0:
                ret += 1
print(ret)

### FIXED CODE ###

N, K = map(int, input().split())
n = sum([1 for x in range(K, N + 1, K)])
if K % 2 == 1:
    print(n ** 3)
else:
    m = sum([1 for x in range(K // 2, N + 1, K)])
    print(n ** 3 + m ** 3)
n = int(input())
t = [int(input()) for _ in range(n)]

if n == 1:
    print(t[0])
    exit()
# 最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
# 最小公倍数
def lcm(a, b):
    return a * b / gcd(a, b)
res = int(lcm(t[0], t[1]))
for i in range(2, n):
    res = int(lcm(res, t[i]))
print(res)


### FIXED CODE ###

n = int(input())
t = [int(input()) for _ in range(n)]

# 最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)
res = 1
for i in range(n):
    res = lcm(res, t[i])
print(res)
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for Ai in A:
    k = 1/(4*M)
    if (sum(A))*k <= Ai:
        cnt += 1
if cnt >= M:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-
BOX = list(map(int, input().split()))
print(BOX[2], BOX[0], BOX[1])
1000000000000000 9.99

### FIXED CODE ###

from math import floor

A, B = input().split()
A = int(A)
B = float(B)
B = round(B*100)
print (A*B // 100)
n,k = map(int, input().split())
p = [[0,0]]
for i in range(n):
    a,b = map(int, input().split())
    p.append([a,b])
p.sort()
ans = 0
i = 0
while ans<=k:
    ans+=p[i+1][1]
    i+=1
print(p[i][0])

### FIXED CODE ###

n,k = map(int, input().split())
p = [[0,0]]
for i in range(n):
    a,b = map(int, input().split())
    p.append([a,b])
p.sort()
ans = 0
p.pop(0)
for i in range(n):
    ans+=p[i][1]
    if ans>=k:
        print(p[i][0])
        exit()
    else:
        continue
4 3
1 2 3 4
1 3
2 3
2 4

### FIXED CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*M;B=[0]*M
C=[0]*N
for i in range(M):
  A[i],B[i]=map(int,input().split())

for i in range(M):
  if H[A[i]-1]<H[B[i]-1]:C[A[i]-1]+=1
  elif H[A[i]-1]>H[B[i]-1]:C[B[i]-1]+=1
  else:C[A[i]-1]+=1;C[B[i]-1]+=1
print(C.count(0))
X=(int,input())
A=(int,input())
B=(int,input())
print((X-A)%B)


### FIXED CODE ###

X=int(input())
A=int(input())
B=int(input())
print((X-A)%B)
import collections
import sys

N = int(input())
a = list(map(int,input().split()))
a = collections.Counter(a)

value, count = zip(*a.most_common())

if count[0]+count[1]+count[2] != N:
    print('No')
    sys.exit()

if value[0]^value[1]^value[2] != 0:
    print('No')
    sys.exit()

if count[0]==count[1]==count[2]:
    print('Yes')
    sys.exit()

print('No')


### FIXED CODE ###

import collections

N = int(input())
a = list(map(int,input().split()))
a = collections.Counter(a)

value, count = list(a.keys()), list(a.values())

if len(value)<3:
    if len(value)==1:
        if sum(a)==0:
            print('Yes')
        else:
            print('No')

    if len(value)==2:
        if 0 in value:
            if count[0]==N/3 or count[1]==N/3:
                print('Yes')
            else:
                print('No')

        else:
            print('No')

if len(value)>=3:
    if count[0]+count[1]+count[2] == N:
        if value[0]^value[1]^value[2] == 0:
            if count[0]==count[1]==count[2]:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
#!/usr/bin/env python3

P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = [1, 10, 9, 12, 3, 4]

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = [1] + [0] * 12
    # print(priv)
    s = S[::-1]
    for i in range(0, len(s)):
        cur = [0] * 13
        d = s[i]
        # print('i=', i, 'd=', d)
        if d == '?':
            for j in range(13):
                for di in range(10):
                    m = di * MODS[i % 6]
                    cur[(j+m) % 13] += priv[j]
        else:
            m = int(d) * MODS[i % 6]
            for j in range(13):
                cur[(m+j) % 13] = priv[j]
        # print(cur)
        for j in range(13):
            priv[i] = cur[i] % P_MOD
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

    print(ans % P_MOD)


### FIXED CODE ###


P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = [1, 10, 9, 12, 3, 4]

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = [1] + [0] * 12
    # print(priv)
    s = S[::-1]
    for i in range(0, len(s)):
        cur = [0] * 13
        d = s[i]
        # print('i=', i, 'd=', d)
        if d == '?':
            for j in range(13):
                for di in range(10):
                    m = di * MODS[i % 6]
                    cur[(j+m) % 13] += priv[j]
        else:
            m = int(d) * MODS[i % 6]
            for j in range(13):
                cur[(m+j) % 13] = priv[j]
        # print(cur)
        for j in range(13):
            priv[j] = cur[j] % P_MOD
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

    print(ans % P_MOD)
import math
Q = int(input())#numの数の個数
Query = []
maxn=0
for _ in range(Q):
    l,r = map(int,input().split())
    Query.append((l,r))
    maxn = max(maxn,r)
N = maxn
num = [0]*(N+2)#部分和を計算したい数列
def souwa(left,right,ruisekiwa):#0based,numの[left,right)間の総和を計算
   return ruisekiwa[right]-ruisekiwa[left]
def using_sqrt(N):#入力 対象の整数,出力,素数ならば1,合成数ならば1
    flag = 0
    for i in range(2,math.floor(math.sqrt(N))+1):
        if N % i == 0:
            flag = 1
            break
        else:
            continue
    if flag == 1:
        return 0
    else:
        return 1

for i in range(1,N+2,2):
    if using_sqrt(i)==1 and using_sqrt((i+1)//2)==1:
        num[i] = 1
ruisekiwa = [0]*(N+2)
ruisekiwa[0] = 0
num[1] =0
for i in range(1,N+2):#累積和の前処理
    ruisekiwa[i]=num[i-1]+ruisekiwa[i-1]

for q in Query:
    print(souwa(q[0],q[1]+1,ruisekiwa)

### FIXED CODE ###

import math
Q = int(input())#numの数の個数
Query = []
maxn=0
for _ in range(Q):
    l,r = map(int,input().split())
    Query.append((l,r))
    maxn = max(maxn,r)
N = maxn
num = [0]*(N+2)#部分和を計算したい数列
def souwa(left,right,ruisekiwa):#0based,numの[left,right)間の総和を計算
   return ruisekiwa[right]-ruisekiwa[left]
def using_sqrt(N):#入力 対象の整数,出力,素数ならば1,合成数ならば1
    flag = 0
    for i in range(2,math.floor(math.sqrt(N))+1):
        if N % i == 0:
            flag = 1
            break
        else:
            continue
    if flag == 1:
        return 0
    else:
        return 1

for i in range(1,N+2,2):
    if using_sqrt(i)==1 and using_sqrt((i+1)//2)==1:
        num[i] = 1
ruisekiwa = [0]*(N+2)
ruisekiwa[0] = 0
num[1] =0
for i in range(1,N+2):#累積和の前処理
    ruisekiwa[i]=num[i-1]+ruisekiwa[i-1]

for q in Query:
    print(souwa(q[0],q[1]+1,ruisekiwa))
import sys

A, B, Q = map(int, input().split())
S = [int(sys.stdin.readline()) for _ in range(A)]
T = [int(sys.stdin.readline()) for _ in range(B)]
X = [int(sys.stdin.readline()) for _ in range(Q)]
INF = 10**12

def binary_search(query, arr):
    arr = [-INF] + arr + [INF]
    low = 0
    high = len(arr)
    t = (low+high)//2
    for _ in range(100):
        if low<high-1:
            break
        if query>arr[t]:
            low = t
        else:
            high = t
        t = (low+high)//2
    return arr[low], arr[high]

def find(query):
    s1, s2 = binary_search(query, S)
    t1, t2 = binary_search(query, T)
    return s1, s2, t1, t2

def main():
    for x in X:
        s1, s2, t1, t2 = find(x)
        cands = [
            abs(t1-x) + abs(s2-t1),
            abs(s1-x) + abs(t2-s1),
            abs(s2-x) + abs(t1-s2),
            abs(t2-x) + abs(s1-t2),
            abs(t1-x) + abs(s1-t1),
            abs(s1-x) + abs(t1-s1),
            abs(s2-x) + abs(t2-s2),
            abs(t2-x) + abs(s2-t2)
        ]
        print(min(cands))
    return

main()

### FIXED CODE ###

A, B, Q = map(int, input().split())
INF = 10**12
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]


def binary_search(query, arr):
    low = 0
    high = len(arr)
    while high-low>1:
        mid = (low+high)//2
        if query>arr[mid]:
            low = mid
        else:
            high = mid
    return arr[low], arr[high]

def main():
    for x in X:
        s1, s2 = binary_search(x, S)
        t1, t2 = binary_search(x, T)
        ans = [ abs(t-s)+min(abs(t-x), abs(s-x)) \
            for t in [t1, t2] for s in [s1, s2] ]
        print(min(ans))
    return

main()
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
n=int(input())
ans=[[0,0,0] for i in range(3)]
for i in range(n):
  s=int(input())
  for T in [A,B,C]:
    if s in T:
      ans[T.index(s)]=1
for i in range(3):
  if ans[i]==[1,1,1]:
    print("Yes")
    exit()
for i in range(3):
  if [ans[i][j] for j in range(3)]==[1,1,1]:
    print("Yes")
    exit()
if [ans[0][0],ans[1][1],ans[2][2]]==[1,1,1]:
  print("Yes")
  exit()
if [ans[0][2],ans[1][1],ans[2][0]]==[1,1,1]:
  print("Yes")
  exit()
print("No")

### FIXED CODE ###

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
n=int(input())
ans=[[0,0,0] for i in range(3)]

for i in range(n):
  s=int(input())
  count=-1
  for T in [A,B,C]:
    count+=1
    if s in T:
      
      ans[count][T.index(s)]=1
for i in range(3):
  if ans[i]==[1,1,1]:
    print("Yes")
    exit()
for i in range(3):
  if [ans[j][i] for j in range(3)]==[1,1,1]:
    print("Yes")
    exit()
if [ans[0][0],ans[1][1],ans[2][2]]==[1,1,1]:
  print("Yes")
  exit()
if [ans[0][2],ans[1][1],ans[2][0]]==[1,1,1]:
  print("Yes")
  exit()
print("No")
import sys

if __name__ == "__main__":
    N = int(sys.argv[1])
    K = int(sys.argv[2])
    count = 0
    numbers = list(range(1, N+1))
    while True:
        if len(numbers) >= K:
            numbers.pop(0)
            count = count + 1
        else:
            print(count)
            break


### FIXED CODE ###

t = input()
l = t.split(" ")
N = int(l[0])
K = int(l[1])
count = 0
numbers = list(range(1, N+1))
while True:
    if len(numbers) >= K:
        numbers.pop(0)
        count = count + 1
    else:
        print(count)
        break
s=input()
if len(s)%2==0:
  for i in range(len(s)//2):
    if s[2*i]!='R' and s[2*i]!='U' and s[2*i]!='D' :
      print('No')
      exit()
    if s[2*i+1]!='L' and s[2*i+1]!='U' and s[2*i+1]!='D':
      print('No')
      exit()
if len(s)%2==1:
  for i in range(len(s)//2+1):
    if s[2*i+1]!='L' and s[2*i+1]!='U' and s[2*i+1]!='D':
      print('No')
      exit()
    if s[2*i]!='R' and s[2*i]!='U' and s[2*i]!='D' :
      print('No')
      exit()
print('Yes')


### FIXED CODE ###

s=input()
if len(s)%2==0:
  for i in range(len(s)//2):
    if s[2*i]!='R' and s[2*i]!='U' and s[2*i]!='D' :
      print('No')
      exit()
    if s[2*i+1]!='L' and s[2*i+1]!='U' and s[2*i+1]!='D':
      print('No')
      exit()
if len(s)%2==1:
  for i in range(len(s)//2):
    if s[2*i+1]!='L' and s[2*i+1]!='U' and s[2*i+1]!='D':
      print('No')
      exit()
  for i in range(len(s)//2+1):
    if s[2*i]!='R' and s[2*i]!='U' and s[2*i]!='D' :
      print('No')
      exit()
print('Yes')
def solve(H, W, h, w):
    if H == 1:
        if W <= 2:
            print('No')
        else:
            kari = (W - 2) // 2 + 1
            if kari >= w - 1:
                print('No')
            else:
                print('Yes')
                print(kari, *([-1] * (W - 2)), kari)
        return
    if W == 1:
        if H <= 2:
            print('No')
        else:
            kari = (H - 2) // 2 + 1
            if kari >= h - 1:
                print('No')
            else:
                print('Yes')
                print(kari)
                for _ in range(H - 2):
                    print(-1)
                print(kari)
        return
    kari = (H * W - 4) // 4 + 1
    if kari >= h * w - 1:
        print('No')
    else:
        print('Yes')
        print(kari, *([-1] * (W - 2)), kari)
        for _ in range(H - 2):
            print(*([-1] * W))
        print(kari, *([-1] * (W - 2)), kari)


solve(*map(int, input().split()))


### FIXED CODE ###

def get_1d(H, h):
    ret = [0] * (H + 1)
    for s in range(h):
        for x, i in enumerate(range(s, H, h)):
            ret[i] = -x
    for x, i in enumerate(range(H, 0, -h)):
        ret[i] = x + 1
    return [x1 - x0 for x0, x1 in zip(ret, ret[1:])]


def solve(H, W, h, w):
    if H % h == 0 and W % w == 0:
        return False
    ans = []
    if H % h > 0:
        col = get_1d(H, h)
        ans.extend([x] * W for x in col)
    else:
        row = get_1d(W, w)
        ans.extend([row] * H)
    return ans


H, W, h, w = map(int, input().split())
ans = solve(H, W, h, w)
if ans == False:
    print('No')
else:
    print('Yes')
    for row in ans:
        print(*row)
x = int(input())

quo = x // 100
rem = x % 100

req = rem // 5

if rem % 5:
  req += 1
  
if req > qum:
  print(0)
else:
  print(1)
  

### FIXED CODE ###

x = int(input())

quo = x // 100
rem = x % 100

req = rem // 5

if rem % 5:
  req += 1
  
if req > quo:
  print(0)
else:
  print(1)
s = list(map(str,input()))
t = list(map(str,input()))


m = len(s)
n = len(t)
ans = []

if m<n:
    print("UNRESROEABLE")
else:
    for i in range(m-n+2):
        s1 = s[i:i+n]
        s2 = s
        flag = True
        for j in range(n):
            if s1[j]!="?" and s1[j]!=t[j]:
                flag = False
                break

        if flag:
            s2[i:i+n] = t
            for k in range(m):
                if s2[k]=="?":
                    s2[k] = "a"
            ans.append(s2)
    if len(ans)==0:
        print("UNRESTORABLE")
    else:
        ans.sort()
        print("".join(ans[0]))


### FIXED CODE ###

import os

s = list(map(str,input()))
t = list(map(str,input()))

m = len(s)
n = len(t)
ans = 0

if m<n:
    print("UNRESTORABLE")
    exit()
for i in range(m-n+1):
    s2 = s.copy()
    s1 = s2[i:i+n]
    flag = True
    for j in range(n):
        if s1[j]!="?" and s1[j]!=t[j]:
            flag = False
            break
        else:
            s1[j] = t[j]
    if flag:
        s2[i:i+n] = s1
        s2 = "".join(s2)
        a = s2.replace("?","a")
        if ans==0:
            ans = a
        elif ans > a:
            ans = a
if ans==0:
    print("UNRESTORABLE")
else:
    print(ans)
N= int(input)
A= int(input)
B= int(input)
C= N*A
if C>B:
  print (B)
else: 
  print (C)

### FIXED CODE ###

N,A,B=map(int,input().split())
if N*A >=B:
  print (B)
else:
  print(N*A)
n = int(input())
s = '1' if n % 2 == 1 else 0
n = - n // - 2
while n:
  mod = abs(n % 2)
  s = str(mod) + s
  n = n // - 2
print(s)

### FIXED CODE ###

n = int(input())
s = "1" if n % 2 == 1 else "0"
n = - n // - 2
while n:
  mod = (n % 2) ** 2
  s = "{}".format(mod) + s
  n = n // - 2
print(s)
S=input()
words=[*S]
answers=[]
for n in words:
    if n=='1':
        answers.append('1')
    elif n=='0':
        answers.append('0')
    else:
        if not answers:
            continue
        else:
            answers.pop()
mojiretu=''
for x in answers:
    mojiretu+=x
print(int(mojiretu))

### FIXED CODE ###

S=input()
words=[a for a in S]
answers=[]
for n in words:
    if n=='1':
        answers.append('1')
    elif n=='0':
        answers.append('0')
    else:
        if not answers:
            continue
        else:
            answers.pop()
mojiretu=''
for x in answers:
    mojiretu+=x
print(mojiretu)
import math
a, b, c = map(int, input().split())
log_ab = math.log10(a*b)
log_cab = math.log10(c - a - b)
log_2 = math.log10(2)
if(log_ab < 2 * log_cab - 2 * log_2):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a, b, c = map(int, input().split())
if(c - a - b >= 0 and a * b * 4 < (c - a - b)**2):
    print("Yes")
else:
    print("No")
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
M = 10**9 + 7
A = sorted(A, key=abs, reverse=1)
# 負の数になる場合
if max(A) < 0:
    result = 1
    for i in range(K):
        result = result * A[-i-1] % M
    print(result)
    exit()

minimum_minus_id = K
minimum_plus_id = K
minus_count = 0

for i in range(K):
    if A[i] < 0:
        minus_count += 1
        minimum_minus_id = i
    else:
        minimum_plus_id = i
result = 1

if minus_count%2 ==1:
    # 一番小さい負の数を正の数にするか、一番小さい正の数を負の数にするか
    second_minus_id = N
    second_plus_id = N

    for i in range(K, N):
        if A[i] >= 0:
            second_plus_id = i
            break
    for i in range(K, N):
        if A[i] < 0:
            second_minus_id = i
            break
    if second_minus_id == N:
        A[minimum_minus_id] = A[second_plus_id]
    elif second_plus_id == N:
        A[minimum_plus_id] = A[second_minus_id]
    else:
        if A[minimum_minus_id] * A[second_minus_id ] > A[minimum_plus_id] * A[second_plus_id]:
            A[minimum_plus_id] = A[second_minus_id]
        else:
            A[minimum_minus_id] = A[second_plus_id]

for i in range(K):
    result = result * A[i] % M
print(result)

### FIXED CODE ###

n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10**9+7
a_list.sort()
ans = 1
if k % 2 == 1 and a_list[-1] < 0:
    for i in range(k):
        ans *= a_list[n - 1 - i]
        ans %= mod
else:
    l = 0
    r = -1
    mlt1 = a_list[0] * a_list[1]
    mlt2 = a_list[-2] * a_list[-1]
    count = 0
    while True:
        if count == k:
            break
        elif count == k - 1:
            ans *= a_list[r] % mod
            ans %= mod
            break
        if mlt1 >= mlt2:
            ans *= mlt1 % mod
            l += 2
            count += 2
            if l <= n - 2:
                mlt1 = a_list[l + 1] * a_list[l]
        else:
            ans *= a_list[r] % mod
            r -= 1
            count += 1
            if r >= - n + 1:
                mlt2 = a_list[r - 1] * a_list[r]
        ans %= mod
print(ans)
a, b, c = input().split()
print((a[0], b[0], c[0]).sep())

### FIXED CODE ###

a, b, c = input().split()
print((a[0] + b[0] + c[0]).upper())
i=1
while (True)
x = int(input())
if (x == 0)
   break
else
   print(Case %d:%d; i, x)
   i + 1 = i


### FIXED CODE ###

i = 1
while True:
   x = int(input())
   if x == 0:
      break
   else:
      print("Case {}: {}".format(i,x))
      i += 1
from operator import mul
from functools import reduce

N = int(input())
x = [int(input()) for i in range(N)]
y = reduce(mul, x)

if y > 10**18:
    print(-1)
else:
    print(y)

### FIXED CODE ###

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

now=1
if 0 in A:
    print(0)
    exit()
for a in A:
    now = now * a
    if now>10**18:
        print(-1)
        exit()
print(now)
x=int(input())
y=int(input())
if(abs(x-y)<=1):
    print('Brown')
else:
    print('Alice')

### FIXED CODE ###

x,y=[int(i) for i in input().split()]
if(abs(x-y)<=1):
    print('Brown')
else:
    print('Alice')
to = list(input())
counter = 0

if to[0] == "o":
  counter += 1
if to[1] == "o":
  counter += 1:
if to[2] == "o":
  counter += 1:
    
price = 700 + 100 * int(counter)

print(price)

### FIXED CODE ###

to = list(input())
counter = 0

if to[0] == "o":
  counter += 1
if to[1] == "o":
  counter += 1
if to[2] == "o":
  counter += 1
    
price = 700 + 100 * int(counter)

print(price)
arr = list(map(int,input().split()))

for i,j in enumerate(len(arr)):
    if j==0:
        print(i)



### FIXED CODE ###

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

if arr[0]==0:
  print(1)
elif arr[1]==0:
  print(2)
elif arr[2]==0:
  print(3)
elif arr[3]==0:
  print(4)
else:
  print(5)