Harryxun/stf_run huggingface dataset:
n = int(input())
i = 1
ans = 0
while i * i <= n:
    m = n / i - 1
    if m == int(m) and n // m == n % m:
        ans += int(m)
    i += 1
print(ans)

### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

while True:
    N = int(input())
    ans_list = sorted(make_divisors(N))
    ans = 0
    #print(ans_list)
    for i in ans_list:
        m = N // i - 1
        if N < m * m:
            #print(i)
            #print(N // i - 1)
            ans += (N // i - 1)

    print(ans)
    break
# 振るのは最強のやつだけ
# 投げるのは強い順
 
N,H = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N)]
A,B = zip(*AB)
 
a = max(A) # 振る
B = [b for b in B if b > a] # 投げる価値あり
B.sort(reverse = True)

attack_cnt = 0
 
for b in B:
  if H <= 0:
    break
  attack_cnt += 1
  H -= b
  
if hp > 0:
  attack_cnt += (H-1)//a + 1
  
print(attack_cnt)

### FIXED CODE ###

from math import ceil

N, H = map(int, input().split())
sword = [[int(x) for x in input().split()] for _ in range(N)]

max_swing = max(sword, key=lambda x:x[0])[0]

attack = 0
# 投げで攻撃
for i in sorted(sword, key=lambda x: x[1], reverse=True):
  if max_swing < i[1]:
    H -= i[1]
    attack += 1
    if H <= 0:
      break
# 残りを振りで攻撃      
if 0 < H:
  attack += ceil(H / max_swing)
print(attack)
s=string(input())
print('ARC') if s=='ABC' else print('ABC')

### FIXED CODE ###

s=input()
print('ARC') if s=='ABC' else print('ABC')
N, A, B = map(int, input().split())

total = 0

for n in range(1,N+1)
    sum = 0
    q = n
    while q != 0:
        sum += (q%10)
        q = q//10
    if (A<=sum) and (sum<=B):
        total += n

print(total)


### FIXED CODE ###

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

total = 0

for n in range(1,N+1):
    sum = 0
    q = n
    while q != 0:
        sum += (q%10)
        q = q//10
    if (A<=sum) and (sum<=B):
        total += n

print(total)
hw=[int(i) for i in input().split()]
s=['.'+input()+'.' for i in range(hw[0])]
s=['.'*(hw[1]+2)]+s+['.'*(hw[1]+2)]
for i in range(1,hw[1]+1):
    for n in range(1,hw[0]+1):
        if s[i][n]=='#':
            if s[i+1][n]=='.' and s[i][n+1]=='.' and s[i-1][n]=='.' and s[i][n-1]=='.':
                print('No')
                exit()
print('Yes')


### FIXED CODE ###

hw=[int(i) for i in input().split()]
s=['.'+input()+'.' for i in range(hw[0])]
s=['.'*(hw[1]+2)]+s+['.'*(hw[1]+2)]
for i in range(1,hw[0]+1):
    for n in range(1,hw[1]+1):
        if s[i][n]=='#':
            if s[i+1][n]==s[i][n+1]==s[i-1][n]==s[i][n-1]=='.':
                print('No')
                exit()
print('Yes')
S = input()

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = i
        break

ans = True

if t:
    for i in range(1, 7 - t + 1):
        if not S[-i] == key[-i]:
            ans = False
            break

if ans:
    print("YES")
else:
    print("NO")



### FIXED CODE ###

S = input()

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = i
        break

if t == -1:
    t = 7

for i in range(1, 8):
    if not S[-i] == key[-i]:
        t += i - 1
        break

if t >= 7:
    print("YES")
else:
    print("NO")
s,t = input()

print(s + t)

### FIXED CODE ###

s, t = input().split()
print(t + s)
A = int(input())
B = int(input())

if A >= 13:
  print(B)
elif A >= 6:
  half_b = B/2
  print(half_b)
else:
  print(int(0))

### FIXED CODE ###

a,b=map(int,input().split())
if a<=5:
   print(0)
elif a<=12:
   print(b//2)
else:
   print(b)
def solve():
    n = int(input())
    s = input()
    t = input()

    str = ''
    for i in range(n):
        str += s[i] + t[i]
    else:
        print(str)



if __name__ == '__main__':
    solve()




### FIXED CODE ###


def solve():
    n = int(input())
    s, t = input().split()

    ans = ''
    for i in range(n):
        ans += s[i] + t[i]
    else:
        print(ans)

if __name__ == '__main__':
    solve()
from collections import deque
x, y, a, b, c = [int(i) for i in input().split()]
lp = sorted([int(i) for i in input().split()])
if len(lp) != x:
  del lp[:len(lp)-x]
lp = deque(lp)
lq = sorted([int(i) for i in input().split()])
if len(lq) != y:
  del lq[:len(lq)-y]
lq = deque(lq)
lr = sorted([int(i) for i in input().split()])
lr = deque(lr)


while True:
  if len(lr) == 0:
    break
  r_max = lr[len(lr)-1]
  p_min = lp[0]
  q_min = lq[0]
  if r_max <= p_min and r_max <= q_min:
    break
  elif r_max > q_min and p_min >= q_min:
    del lq[0]
    lq.append(lr.pop(-1))
  elif r_max > p_min and q_min >= p_min:
    del lp[0]
    lp.append(lr.pop(-1))


print(sum(lp) + sum(lq))

### FIXED CODE ###

from collections import deque
x, y, a, b, c = [int(i) for i in input().split()]
lp = sorted([int(i) for i in input().split()])
if len(lp) != x:
  del lp[:len(lp)-x]
lp = deque(lp)
lq = sorted([int(i) for i in input().split()])
if len(lq) != y:
  del lq[:len(lq)-y]
lq = deque(lq)
lr = sorted([int(i) for i in input().split()])
lr = deque(lr)


while True:
  if len(lr) == 0:
    break
  r_max = lr[len(lr)-1]
  p_min = lp[0]
  q_min = lq[0]
  if r_max <= p_min and r_max <= q_min:
    break
  elif r_max > q_min and p_min >= q_min:
    del lq[0]
    lq.append(lr.pop())
  elif r_max > p_min and q_min >= p_min:
    del lp[0]
    lp.append(lr.pop())


print(sum(lp) + sum(lq))
a, b, c = map(int, input().split())

if a=5, b=5, c=7:
  print("Yes")
elif a=5, b=7, c=5:
  print("Yes")
elif a=7, b=5, c=5:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

a, b, c = map(int, input().split())
iroha = [a, b, c]
if iroha.count(5) == 2 and iroha.count(7) == 1:
  print("YES")
else:
  print("NO")
tasks=sorted(list(map(int,input().split()))

cost=0                                   
             
for i in range(1,len(tasks)):                      
    cost+=tasks[i]-tasks[i-1]
                                    
print(cost)

### FIXED CODE ###

tasks=sorted(list(map(int,input().split())))

cost=0                                   
             
for i in range(1,len(tasks)):                      
    cost+=tasks[i]-tasks[i-1]
                                    
print(cost)
def calculate(arr,M):
    sum = 0
    for i in range(M):
        index = 0
        value = 0
        for j in range(len(arr)):
            lastDay = i + arr[j][0]
            if lastDay <= M:
                if arr[j][1] > value:
                    index = j
                    value = arr[j][1]

                if (arr[j][1] == value) and (arr[index][0] < arr[j][0]):
                        index = j
                        value = arr[j][i]

        if len(arr) > 0:
            sum += value
            arr.pop(index)

        if len(arr) == 0:
            break

    return sum

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


arr = []
for i in range(N):
    day, mount = map(int, input().split())
    day = int(day)
    mount = int(mount)
    arr.append([day,mount])
result = calculate(arr,M)
print(result)

### FIXED CODE ###

from heapq import heappush, heappop
n, m = map(int, input().split())
jobs = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a > m:
    continue
  if a in jobs:
    jobs[a].append(b)
  else:
    jobs[a] = [b]
result = 0
candidates = []
for a in range(1, m + 1):
  if a in jobs:
    for b in jobs[a]:
      heappush(candidates, -b)
  else:
    if len(candidates) == 0:
      continue
  result += -heappop(candidates)
print(result)
list = map(int, raw_input().split())
x0 = list[2] - list[4]
y0 = list[3] - list[4]
x1 = list[2] + list[4]
y1 = list[3] + list[4]

if x0 >= 0 and y0 >= 0 and x1 =< list[0] and y1 =< list[1]:
    print "Yes"
else :
    print "No"
    

### FIXED CODE ###

list = map(int, raw_input().split())
x0 = list[2] - list[4]
y0 = list[3] - list[4]
x1 = list[2] + list[4]
y1 = list[3] + list[4]

if x0 >= 0 and y0 >= 0 and x1 <= list[0] and y1 <= list[1]:
    print "Yes"
else :
    print "No"
a,b=input().split()
s=list(input())
print([l.replace(s[int(b)],str.lower(s[int(b)])) for l in s])

### FIXED CODE ###

N,k=map(int,input().split())
S=input()
print(S[:k-1] + S[k-1].lower() + S[k:])
import math
import sys

n = int(input())

start = math.floor(n // 1.1)

for m in range(start, n):
  ma = math.floor(m * 1.08)
  if ma == n:
    print(m)
    sys.exit(1)

print(':(')
  	

### FIXED CODE ###

import math
import sys
 
n = int(input())

ln = {}

for m in range(0, 50000):
  ln[(math.floor(m * 1.08))] = m

if n in ln.keys():
  print(ln[n])
else:
  print(':(')
N,A,B = map(int,input().split())
output = 0
for i in range(1,N+1): 
  # set condition for i < 10^4
  if i < 10:
	digitsum = i
  elif i<100:
    digitsum = i//10+i%10
  elif i<1000:
    digitsum = i//100+(i%100)//10+(i%100)%10
  elif i<10000:
    digitsum= i//1000+(i%1000)//100+((i%1000)%100)//10+((i%1000)%100)%10
  else:
    digitsum = 1
 
  if A <= digitsum and digitsum <= B:
  	output += i
    
print (output)

### FIXED CODE ###

 
N,A,B=map(int,input().split())
 
sum_k=0
 
for i in range(N+1):
    if i <10:
        k=i
    elif i<100:
        k=i//10+i%10
    elif i<1000:
        k=i//100+(i%100)//10+(i%100)%10
    elif i<10000:
        k=i//1000+(i%1000)//100+((i%1000)%100)//10+((i%1000)%100)%10
    else:
        k=1
    if A<=k and k<=B:
        sum_k=sum_k+i
      
print(sum_k)
#code
n=int(input())
b=input()

b=b.split()

b=list(map(int,b))
a=list()
for i in range(len(b)-1):
    if(i==0):
        a.append(b[i])
        a.append(b[i])
    else:
        a.append(min(b[i],b[i+1]))
a.append(max(b[len(b)-1],a[len(a)-1]))
sum=0 
for i in range(len(a)):
    sum+=a[i]
print(sum)


### FIXED CODE ###

#code
n=int(input())
b=input()

b=b.split()

b=list(map(int,b))
a=list()
a.append(b[0])

for i in range(1,len(b)):
    
    
    a.append(min(b[i],b[i-1]))
if(n>2):
    a.append(b[len(b)-1])
if(n==2):
    a.append(b[0])
sum=0 
for i in range(len(a)):
    sum+=a[i]
print(sum)
a, b, c, k = map(int, input().split())
if a >= k:
    print(k)
else:
    print(a - ((k-a)-b)

### FIXED CODE ###

a, b, c, k = map(int, input().split())
if a >= k:
    print(k)
else:
    print(a - ((k-a)-b))
import sys

sys.setrecursionlimit(100000)

N, M = map(int, input().split())
A = []
ANS = []
for i in range(N + 10):
    ANS.append(None)

for _ in range(M):
    a = int(input())
    A.append(a)
    ANS[a] = 0


def f(x):
    # print(ANS)
    # if x in A:
    #     print('::::', x)
    #     d[x] = 0
    #     return 0
    if ANS[x] is not None:
        return ANS[x]

    if x > N:
        return 0
    if x == N:
        return 1

    # if d.get(x + 1):
    #     x1 = d.get(x + 1)
    # else:
    #     x1 = f(x + 1)
    #     d[x + 1] = x1
    #
    # if d.get(x + 2):
    #     x2 = d.get(x + 2)
    # else:
    #     x2 = f(x + 2)
    #     d[x + 2] = x2

    # ans = x1 + x2
    ans = f(x + 1) + f(x + 2)
    ANS[x] = ans
    return ans


print(f(0) % 1000000007)


### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
A = []
ANS = []
for i in range(N + 10):
    ANS.append(None)

for _ in range(M):
    a = int(input())
    A.append(a)
    ANS[a] = 0


def f(x):
    # print(ANS)
    # if x in A:
    #     print('::::', x)
    #     d[x] = 0
    #     return 0
    if ANS[x] is not None:
        return ANS[x]

    if x > N:
        return 0
    if x == N:
        return 1

    # if d.get(x + 1):
    #     x1 = d.get(x + 1)
    # else:
    #     x1 = f(x + 1)
    #     d[x + 1] = x1
    #
    # if d.get(x + 2):
    #     x2 = d.get(x + 2)
    # else:
    #     x2 = f(x + 2)
    #     d[x + 2] = x2

    # ans = x1 + x2
    ans = f(x + 1) + f(x + 2)
    ANS[x] = ans
    return ans


print(f(0) % 1000000007)
n = int(input())
a = list(map(int,input().split()))
 
a.sort()
for i in range(n-1):
    a[i+1] = (a[i] + a[i+1]) / 2
 
print(a[-1])

### FIXED CODE ###

a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print("red")
from collections import deque
n = int(input())

lis = set()
def dfs():
    d = ['3','5','7']
    que = deque(['3','5','7'])
    while len(que) != 0:
        val = que.pop()
        #print(val)
        if len(val) < 10:
            #print(len(str(val)))
            for i in range(3):
                val2 = val + d[i]
                #print(val3[-1])
                l = list(val2)
                if '3' in l and '5' in l and '7' in l:
                    lis.add(int(val2))
                que.append(val2)

    return lis
lis = dfs()
ans = 0
for i in lis:
    if int(i) < n:
        ans += 1
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
a = n // k

if k % 2 == 0:
    b = 0
    for i in range(1, n+1):
        if i % k == k // 2:
            b += 1
    print(a ** 3 + b ** 3)
else:
    print(a ** 3)
from collections import deque

def bfs(maze, visited, sy, sx, gy, gx):
  queue = deque([[sy, sx]])
  visited[sy][sx] = 0
  while queue:
    y,x = queue.popleft()
    if [y, x] == [gy, gx]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        visited[new_y][new_x] = visited[y][x] + 1
        queue.append([new_y, new_x])

h,w = map(int,input().split())
wall = ''
for i in range(w+2):
  wall += '#'
maze = [wall]
for i in range(h) :
  m1 = input()
  maze.append('#'+m1+'#')
maze .append(wall)

s = [[1,1],[1,h],[w,1],[w,h]]
g = [[w,h],[w,1],[1,h],[1,1]]

ans = []
for i in range(4) :
  sy = s[i][1] ; sx = s[i][0]
  for j in range(1,h+1) :
    for k in range(1,w+1) :
      gy = j ; gx = k
      if maze[gy][gx] == '#' :
        break
      visited = [[-1]*(w+2) for _ in range(h+2)]
      ans.append(bfs(maze, visited, sy, sx, gy, gx))

print(max(ans))

### FIXED CODE ###

n,m = map(int,input().split())
p = []
s = []

for i in range(m):
  p1,s1 = map(str,input().split())
  p.append(int(p1))
  s.append(s1)

#0が正答したかどうか（正答が1）、1がペナルティの数
ans = [[0,0] for i in range(n)]

for i in range(m) :
  if s[i] == 'AC' :
    ans[p[i]-1][0] = 1
  if s[i] == 'WA' and ans[p[i]-1][0] == 0 :
    ans[p[i]-1][1] += 1

ac = 0
pe = 0
for i in range(n) :
  ac += ans[i][0]
  if ans[i][0] == 1 :
    pe += ans[i][1]

print(ac,pe)
n = int(input())
s=[]
for i in range(n):
    s.append(int(input())

if sum(s) % 10 != 0:
    print(sum(s))
else:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))



### FIXED CODE ###

n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

s.sort(key=lambda x:x%10)

if sum(s) % 10 != 0:
    print(sum(s))
elif s[-1] % 10>0:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))
else:
    print(0)
n=int(input())
a=[int(input()) for _ in range(n)]

for i in range(a):
    if a[i]==i+1:
        print(-1)
        
cnt=0
tmp=1
already=[]
while True:
    cnt+=1
    already.append(tmp)
    tmp=a[tmp-1]
    if tmp==2:
        print(cnt)
        break
    elif tmp in already:
        print(-1)
        break

### FIXED CODE ###

import sys
n=int(input())
a=[int(input()) for _ in range(n)]
       
cnt=0
tmp=1

for i in range(n):
    cnt+=1
    tmp=a[tmp-1]
    if tmp==2:
        print(cnt)
        sys.exit()
print(-1)
A, B, X = map(int, input.split())
if A + B < X:
    print("NO")
elif A > X:
    print("NO")
else :
    print("YES")

### FIXED CODE ###

A, B, X = map(int, input().split())
if A + B < X:
    print("NO")
elif A > X:
    print("NO")
else :
    print("YES")
n=int(input())
v=[]
c=[]
x=[]
for i in range(n):
  v[i]=int(input())
for i in range(n):
  c[i]=int(input())
  x[i]=v[i]-c[i]

ans=0
while x[i]>0:
  ans+=x[i]
  
print(ans)

### FIXED CODE ###

n=int(input())
v=list(map(int, input().split()))
c=list(map(int, input().split()))
x=[]
for i in range(n):
  if v[i]-c[i]>0:
    x.append(v[i]-c[i])

print(sum(x))
s = str(input())[::-1]

tmp_amari = [0]*2019

#amari = 0
num = 0
order = 1
for i in s:
    num += int(i)*order
    num %= 2019
    print(num)
    tmp_amari[num] += 1
    order *= 10

#tmp_print = [i for i in tmp_amari if i > 0]
#print(tmp_print)

ans = 0
ans += tmp_amari[0]

for i in tmp_print:
    ans += (i*(i-1))//2

print(ans)


### FIXED CODE ###


s = input()[::-1]
from collections import defaultdict
amari = defaultdict(int)
keta_ = defaultdict(int)

cur = 0
keta = 1

for i in range(len(s)):
    cur += int(s[i]) * keta
    cur %= 2019

    keta *= 10
    keta %= 2019
    
    amari[cur] += 1
    keta_[keta] += 1

#print('%')
#print(2114%2019)
#print(181712114%2019)

#print(81712114%2019)
#print(1817181712114%2019)

#print('%')

#print(amari)
#print(keta_)
ans = 0
if 0 in amari:
    ans += amari[0]

for n in amari.values():
    ans += (n * (n-1)) // 2
  
print(ans)
import math

r = float(input())
x = 2 * Math.pi * r
y = r / 2 * r / 2 * Math.pi

print('{0:.6f} {1:.6f}'.format(x,y)) 

### FIXED CODE ###

import math
r = float(input())
e = 2 * math.pi * r
m = r * r * math.pi

print("{0:.6f} {1:.6f}".format(m, e))
I = [input() for i in range(2)]
if I(0)%2 = 1 :
    A = 'No' 
else:
    H1 = I(1)[:I(0)/2]
    H2 = I(1)[I(0)/2+1:]
    if  H1 = H2 :
        A = 'Yes'
    else:
        A = 'No'

print(A)

### FIXED CODE ###

I = [input() for i in range(2)]
sn = int(I[0])
ss = str(I[1])
if sn%2 == 1 :
    A = 'No' 
else:
    sl = int(sn/2) 
    # print(sl)
    if sl >= 2 : 
        H1 = ss[:sl]
        H2 = ss[sl:]
    #     print(H1)
    #     print(H2)
    elif sl == 1 :
        H1 = str(ss[0])
        H2 = str(ss[1])
    if  H1 == H2 :
        A = 'Yes'
    else:
        A = 'No'
print(A)
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	result := 0
	for b := 0; b < 60; b++ {
		a := make([]int, N)
		for i := 0; i < N; i++ {
			a[i] = (A[i] >> uint(b)) & 1
		}

		bs := make([]int, N)
		bs[N-1] = a[N-1]
		for i := N - 2; i > -1; i-- {
			bs[i] = bs[i+1] + a[i]
		}

		t := 0
		for i := 0; i < N-1; i++ {
			if a[i] == 0 {
				t += bs[i+1]
			} else {
				t += (N - (i + 1)) - bs[i+1]
			}
			t %= 1000000007
		}
		B := (1 << uint(b)) % 1000000007
		result += (t * B) % 1000000007
		result %= 1000000007
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


### FIXED CODE ###

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

    r = list(range(N - 2, -1, -1))
    result = 0
    for b in range(60):
        t = 0
        bs = (A[N - 1] >> b) & 1
        for i in r:
            if (A[i] >> b) & 1 == 0:
                t += bs
            else:
                t += (N - (i + 1)) - bs
                bs += 1
        result = (result + t * (1 << b)) % 1000000007
    print(result)
main()
h, w = map(int, input().split())
maps = []
for i in range(h):
	maps.append(str(input()))
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if maps[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if scr[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()


### FIXED CODE ###

h, w = map(int, input().split())
maps = []
for i in range(h):
	maps.append(str(input()))
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if maps[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(maps[i][j], end = '')
		print()
n , k = map(int, input().split())
a = list(map(int, input().split()))
neg = []
pos = []
mod = 10**9+7
for i in range(n):
    if a[i] >= 0:
        pos.append(a[i])
    else:
        neg.append(a[i])
neg.sort()
pos.sort(reverse = True)
min_num = -1
good_num = -1
if len(pos) == 0 or n == k:
    ans = 1
    neg.sort(reverse = True)
    for i in range(k):
        ans *= neg[i]
        ans %= mod
    print(ans % mod)
else:
    #最大化するとき
    for i in range(0,k+1,2):
        #i個だけnegから取る。
        if i > len(neg) or k - i > len(pos):
            continue
        m = 0
        if i - 1 >= 0:
            m = abs(neg[i-1])
        if k-i-1 >= 0:
            m = min(m, pos[k-i-1])
        if m > min_num:
            min_num = m
            good_num = i
    ans = 1
    for i in range(good_num):
        ans *= neg[i]
        ans %= mod
    for i in range(k - good_num):
        ans *= pos[i]
        ans %= mod
    print(ans % mod)

### FIXED CODE ###

n , k = map(int, input().split())
a = list(map(int, input().split()))
neg = []
pos = []
mod = 10**9+7
for i in range(n):
    if a[i] >= 0:
        pos.append(a[i])
    else:
        neg.append(a[i])
neg.sort()
pos.sort(reverse = True)
if (len(pos) == 0 and k % 2 == 1) or n == k:
    ans = 1
    a.sort(reverse = True)
    for i in range(k):
        ans *= a[i]
        ans %= mod
    print(ans % mod)
else:
    #最大化するとき
    from collections import deque
    ans = 1
    neg_new = []
    for i in range(0, len(neg)//2):
        neg_new.append(neg[2*i] * neg[2*i+1])
    neg_new = deque(sorted(neg_new, reverse = True))
    pos = deque(pos)
    if k % 2 == 1:
        k -= 1
        ans = pos.popleft()
    else:
        ans = 1
    while k > 0:
        if len(pos) >= 2 and len(neg_new) >= 1:
            if pos[0] * pos[1] > neg_new[0]:
                ans *= pos.popleft() * pos.popleft()
            else:
                ans *= neg_new.popleft()
        elif len(pos) >= 2:
            ans *= pos.popleft() * pos.popleft()
        else:
            ans *= neg_new.popleft()
        k -= 2
        ans %= mod
    print(ans % mod)
n,x = map(int, raw_input().split())
if n = 0 : break
x.reverse()
print(x)


### FIXED CODE ###

input()
a = map(int, raw_input().split())
 
a.reverse()
print(" ".join(map(str, a)))
#全体に同じものを足すときは累積和を考えたい

N,Q = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N-1)]
PX = [list(map(int,input().split())) for _ in range(Q)]

children = [set([]) for _ in range(N)]
#children[i]:i+1番目の頂点の子
counter = [0 for _ in range(N)]
#counter[i]:i+1番目の頂点のカウンター

for i in range(N-1):
    children[AB[i][0]-1].add(AB[i][1])

for i in range(Q):
    counter[PX[i][0]-1] += PX[i][1]

def cal(children,counter,node):
    if len(children[node-1]) > 0:
        for child in children[node-1]:
            counter[child-1] += counter[node-1]
            cal(children,counter,child)

cal(children,counter,1)

print(str(counter[0]),end="")
for i in range(1,N):
    print(" "+str(counter[i]),end="")
print()


### FIXED CODE ###

#全体に同じものを足すときは累積和を考えたい

N,Q = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N-1)]
PX = [list(map(int,input().split())) for _ in range(Q)]

graph = [[] for _ in range(N+1)]

for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
#どちらが親か分からないがとりあえずつながっている
#どちらが親かは後で判断

counter = [0 for _ in range(N+1)]
#counter[i]:i番目の頂点のカウンター
parent = [None for _ in range(N+1)]

for p,x in PX:
    counter[p] += x

def dfs(graph,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

dfs(graph,counter,1)

ans = " ".join(map(str,counter[1:]))
print(ans)
s=input()
s=list(s)
if s[0]=="?" and s[1]=="D":
    s[0]="P"
elif s[0]=="?" and s[1]=="P":
    s[0]="D"
for i in range(1,len(s)-1):
    if s[i]=='?':
        # print(s)
        if s[i-1]=="D" and s[i+1]=="D":
           s[i]="P"
        elif s[i-1]=="D" and s[i+1]=="?":
            s[i]="P"
        else:
            s[i]="D"
    # print(s)
if s[-1]=="?":
    s[-1]="D"
s1="".join(s)
print(s1)

### FIXED CODE ###

s=input()
s2=list(s)
s1=""
if s2[-1]=="?":
    s2[-1]="D"
if s2[0]=="?" and s2[1]=="D":
    s2[0]="P"
elif s2[0]=="?" and (s2[1]=="P" or s2[1]=="?"):
    s2[0]="D"
for i in range(1,len(s2)-1):
    if s2[i]=='?':
        if s2[i-1]=="D" and (s2[i+1]=="D" or s2[i+1]=="?"):
           s2[i]="P"
        else:
            s2[i]="D"
for i in s2:
    s1+=i
print(s1)