Harryxun/stf_run huggingface dataset:
N = int(input())
A = sorted(list(map(int, input().split())))

rmlst = []
i =1
while(i<len(A)):
    if A[i] == A[i-1]:
        rmlst.append(A[i-1])
        A.pop(i)
    else:
        i += 1

rmlst = list(set(rmlst))

# A[0]は最小なので同じ数字を除いてそれよりも大きい他の数では割り切れない。
i = 0

while(i < len(A)):
    j = i+1
    poplist = []
    while(j < len(A)):
        if A[j]%A[i] == 0: # 割り切れちゃった場合
            # A[j]をあとで消すために控える
            poplist.append(j)
                
        j += 1
        
    # poplistにあるA[]を消す
    # 前から消していくと順番が狂うので、後ろから消す。参考↓
    # https://gammasoft.jp/blog/remove-multiple-elements-from-python-list/
    for k in sorted(poplist, reverse=True):
        A.pop(k)
    # A[i]で割り切れるものは探しきって、次のA[i+1]は割り切れないもの。
    # 次はA[i+1]について考える
    i += 1

for i in rmlst:
    A.remove(i)

# print(A)
print(len(A))
# print(dellist)

### FIXED CODE ###

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

cnt = [0] * ((10 ** 6) + 1)

for elem in a:
    cnt[elem] += 1

unique = []

for i in range((10 ** 6) + 1):
    if cnt[i] == 1:
        unique.append(i)

cnt = [0] * ((10 ** 6) + 1)

a = list(set(a))

for elem in a:
    for m in range(elem * 2, (10 ** 6) + 1, elem):
        cnt[m] = 1

ans = 0
        
for elem in unique:
    if cnt[elem] == 0:
        ans += 1

print(ans)
N=input()
X=0
Y=0
for i+1 in range(len(N)):
  if N[i]="R":
    X+=1
  else:
    Y=X
    X=0
print(max([X,Y]))
  


### FIXED CODE ###

N=input()
X=0
Y=0
for i in range(len(N)):
  if N[i]=="R":
    X+=1
  else:
    Y=max([X,Y])
    X=0
print(max([X,Y]))
N = input()
a = []
for i in range(N):
    a.append(input())
max_profit = a[1] - a[0]
for i in range(2,N):
	if a[i] - a[i-1] > max_profit
		max_profit = a[i] - a[i-1]
print(max_profit)

### FIXED CODE ###

N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
max_profit = a[1] - a[0]
min_val = min(a[1],a[0])
for i in range(2,N):
	if a[i] < min_val:
		min_val = a[i]
	elif a[i] - min_val > max_profit:
		max_profit = a[i] - min_val
print(str(max_profit))
n = int(input())
ans = ''
while n > 0:
  n -= 1
  ans += chr(ord('a')+ans%26)
  n //= 26
print(ans[::-1])

### FIXED CODE ###

n = int(input())
ans = ''
while n > 0:
  n -= 1
  ans += chr(ord('a')+n%26)
  n //= 26
print(ans[::-1])
s = input()
if len(s) == 3:
  s.reverse()
print(s)

### FIXED CODE ###

s = input()
if len(s) == 3:
  s = s[::-1]
print(s)
X=int(input())

def ok(B):
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return i**5==B

def get(B):
    f = B/abs(B)
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return int(i*f)



A_cand=[]
i=0
while i**5<=10**10:
    A_cand.append(i)
    i+=1

#print(A_cand)
for a in A_cand:
    B_5=a**5-X
    if ok(B_5):
        r=get(B_5)
        print(a,r)
        exit()
        break
for a in A_cand:
    a*=-1
    B_5=a**5-X
    if ok(B_5):
        r=get(B_5)
        print(a,r)
        exit()
print(0/0)


### FIXED CODE ###

X=int(input())

def ok(B):
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return i**5==B

def get(B):
    f = B/abs(B)
    i=1
    B=abs(B)
    while i**5<B:
        i+=1
    return int(i*f)



A_cand=[]
i=0
while i**5<=10**10:
    A_cand.append(i)
    i+=1

#print(A_cand)
for a in range(300):
    B_5=a**5-X
    if ok(B_5):
        r=get(B_5)
        print(a,r)
        exit()
        break
for a in A_cand:
    a*=-1
    B_5=a**5-X
    if ok(B_5):
        r=get(B_5)
        print(a,r)
        exit()
print(0/0)
a,b = int(input())
print((a+b)%24)

### FIXED CODE ###

a,b = map(int,input().split())
print((a+b)%24)
from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 6)


@lru_cache
def rec(i, j):
    global p
    if i < 0 or j < 0:
        return 0.0
    return rec(i - 1, j) * (1 - p[i - 1]) + \
        rec(i - 1, j - 1) * p[i - 1]


def main():
    N = int(input())
    global p
    p = list(map(float, input().split()))
    ans = 0
    for i in range(N//2+1, N+1):
        ans += rec(N, i)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    p = list(map(float, input().split()))
    dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
    p_mul = 1
    dp[0][0] = 1
    for i in range(1, N + 1):
        p_mul *= (1-p[i-1])
        dp[i][0] = p_mul
    for i in range(1, N+1):
        for j in range(1, N+1):
            dp[i][j] = dp[i - 1][j] * \
                (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1]
    print(sum(dp[N][N//2+1:]))


if __name__ == "__main__":
    main()
l, r = [int(x) for x in input().split()]

remainder_list = []

if r - l >= 2019:
	print(0)
else :
	for x in range(l, r):
    	remainder_list.append((l * (x + 1)) % 2019)

remainder_list.sort()
print(remainder_list[0])
    	

### FIXED CODE ###

import sys

l, r = [int(x) for x in input().split()]

remainder_list = []

if r - l >= 2019:
    print(0)
    sys.exit()
else :
    for x in range(l, r):
        for y in range(x + 1, r + 1):
            remainder_list.append((x * y) % 2019)

remainder_list.sort()
print(remainder_list[0])
import queue

class VInfo(object):
    def __init__(self,x,y,d,color):
        self.color=color
        self.d=d
        self.x=x
        self.y=y
    def turnColor(self):
        if self.color==".":return "#"
        else:return "."

h,w=map(int,input().split())
a=[[str(i) for i in input()] for j in range(h)]
sx,sy=0,0
gx,gy=w-1,h-1
cw=0
mapA=[]
m=100000000000000
for my in range(h):
    l=[]
    for mx in range(w):
        l.append(m)
    mapA.append(l)

q=queue.Queue()
if a[0][0]==".":q.put(VInfo(0,0,0,"."))
else:q.put(VInfo(0,0,1,"#"))
l=[]
while not q.empty():
    now=q.get()
    if now.x==gx and now.y==gy:
        if now.color=="#":l.append((mapA[gy][gx]+2)//2)
        else:l.append((mapA[gy][gx]+1)//2)

    if now.y+1<w and a[now.y+1][now.x]==now.color and mapA[now.y+1][now.x]>now.d:
            mapA[now.y+1][now.x]=now.d
            q.put(VInfo(now.x,now.y+1,now.d,now.color))
    if now.y+1<w and a[now.y+1][now.x]!=now.color and mapA[now.y+1][now.x]>now.d:
            mapA[now.y+1][now.x]=now.d
            q.put(VInfo(now.x,now.y+1,now.d+1,now.turnColor()))
    if now.x+1<h and a[now.y][now.x+1]==now.color and mapA[now.y][now.x+1]>now.d:
            mapA[now.y][now.x+1]=now.d
            q.put(VInfo(now.x+1,now.y,now.d,now.color))
    if now.x+1<h and a[now.y][now.x+1]!=now.color and mapA[now.y][now.x+1]>now.d:
            mapA[now.y][now.x+1]=now.d
            q.put(VInfo(now.x+1,now.y,now.d+1,now.turnColor()))
print(min(l))

### FIXED CODE ###

import queue

class VInfo(object):
    def __init__(self,x,y,d,color):
        self.color=color
        self.d=d
        self.x=x
        self.y=y
    def turnColor(self):
        if self.color==".":return "#"
        else:return "."

h,w=map(int,input().split())
a=[[str(i) for i in input()] for j in range(h)]
sx,sy=0,0
gx,gy=w-1,h-1
cw=0
mapA=[]
m=100000000000000
for my in range(h):
    l=[]
    for mx in range(w):
        l.append(m)
    mapA.append(l)

q=queue.Queue()
if a[0][0]==".":q.put(VInfo(0,0,0,"."))
else:q.put(VInfo(0,0,1,"#"))
l=[]
while not q.empty():
    now=q.get()
    if now.x==gx and now.y==gy:
        if now.color=="#":l.append((mapA[gy][gx]+2)//2)
        else:l.append((mapA[gy][gx]+1)//2)

    if now.y+1<h and a[now.y+1][now.x]==now.color and mapA[now.y+1][now.x]>now.d:
            mapA[now.y+1][now.x]=now.d
            q.put(VInfo(now.x,now.y+1,now.d,now.color))
    if now.y+1<h and a[now.y+1][now.x]!=now.color and mapA[now.y+1][now.x]>now.d:
            mapA[now.y+1][now.x]=now.d
            q.put(VInfo(now.x,now.y+1,now.d+1,now.turnColor()))
    if now.x+1<w and a[now.y][now.x+1]==now.color and mapA[now.y][now.x+1]>now.d:
            mapA[now.y][now.x+1]=now.d
            q.put(VInfo(now.x+1,now.y,now.d,now.color))
    if now.x+1<w and a[now.y][now.x+1]!=now.color and mapA[now.y][now.x+1]>now.d:
            mapA[now.y][now.x+1]=now.d
            q.put(VInfo(now.x+1,now.y,now.d+1,now.turnColor()))
print(min(l))
from math import gcd
a, b = [int(tem) for tem in input().split()]
A = str(gcd(a, b))
print(A.strip(''))

### FIXED CODE ###

a, b = [int(tem) for tem in input().split()]

def mak(A, B) :
    while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
    return A

if a > b : print(mak(a, b))
else     : print(mak(b, a))
# M回の操作終了後に N枚のカードに書かれた整数の合計の最大値を求めてください。
# で操作はB_j 枚以下の任意のカードをC_jに置き換えるという処理ができる。
# つまり、元のカードの値Aをソートして、小さいものから順にC_jの大きいもので並び替えれば良い
import sys
input=sys.stdin.readline
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b_c = [list(map(int,input().split())) for _ in range(m)]
b_c.sort(key = lambda x:x[1], reverse=True) # c でソートする
pos = 0
ans = sum(a)
for i in range(m): # 一応最後までb_c をループするようにして、c よりも元のカードが大きくなったらbreakする
  if a[pos + b_c[i][0] - 1] > b_c[i][1]:
    for j in range(b_c[i][0]): #　何番目までは入れ替えた方が特か判定
      if a[pos + j] > b_c[i][1] or pos + j >= n:
        break
      else:
        ans += b_c[i][1] - a[pos + j] # 置き換えによる増加量
    break
  else:
    for j in range(b_c[i][0]): #　
      ans += b_c[i][1] - a[pos + j]
    pos += b_c[i][0]
print(ans)
# 最初はエラー : b_c[i][0]をb_c[0]でやっていたから
# 次は値がおかしい。sortがb_cは逆順（大きいものから順に）にする必要がある
# そのためには, reverse=True を入れる
# しかし、これでも入力例2で異なる答え、入力例4でエラーが出る。
# posをたす位置がおかしかった
# ここで提出したが、まさかのRE 時間がかかりすぎ
# 一応O(N)で収まっているはずだが、定数倍の高速化が必要
# 

### FIXED CODE ###

#!/usr/bin/env python3
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = [0]*m
c = [0]*m
for i in range(m):
    b[i],c[i] = map(int,input().split())
c,b = zip(*sorted(zip(c,b)))#c でソートする
# 整数列a からmin からc にb枚まで帰る操作を繰り返した時のsumのmaxを求める
# C の大きい順から、Nを超えないまで並べていく
# もし、そのtotalがN を超える場合は、そのできた配列とaをソートしたものを比べて、
# aをソートしたものの方が大きいところがあれば修正する
# もしtotla がNを超えないなら、小さい順から置き換えたもののそのままでOK
# 実装としては、ソートしたaを前から順番にc[i]より大きいか比べていく
cb = 0
idx = 0
for i in range(n):
    if cb == m:break
    else:
        if a[i] < c[m-1-cb]:a[i] = c[m-1-cb]
        idx += 1
        if idx == b[m-1-cb]:
            idx = 0
            cb += 1
print(sum(a))
mod=1000000007
n=int(input())
a=input()

d=[0]
for i in range(1,n):
    if s[i-1]==s[i]:
        d[-1]+=1
    else:
        d.append(0)
ans=[3,6][d[0]]
for i in range(1,len(d)):
    if d[i-1]==d[i]==1:
        t=3
    elif d[i-1]==1:
        t=1
    else:
        t=2
    ans=(ans*t)%mod
print(ans)

### FIXED CODE ###

mod=1000000007
n=int(input())
a=input()
b=input()
#1 22
#1
d=[1]
for i in range(1,n):
    if a[i-1]==a[i]:
        d[-1]+=1
    else:
        d.append(1)
ans=[3,6][d[0]-1]
for i in range(1,len(d)):
    if d[i-1]==d[i]==1:
        t=2
    elif d[i-1]==d[i]==2:
        t=3
    elif d[i-1]==2 and d[i]==1:
        t=1
    else:
        t=2
    ans=(ans*t)%mod
print(ans)
import math
n = int(input())
lis = list(map(int,input().split()))
now = 1
for num in lis:
    now = (now * num)//math.gcd(now,num)
now -= 1
ans = sum([now%lis[i] for i in range(n)])
print(ans)

### FIXED CODE ###

import fractions
n = int(input())
lis = list(map(int,input().split()))
cou = 1
for i in range(n):
  cou = (cou * lis[i])//fractions.gcd(cou, lis[i])
cou -= 1
print(sum([cou % lis[i] for i in range(n)]))
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

from numba import njit


def getInputs():
    D = int(readline())
    CS = np.array(read().split(), np.int32)
    C = CS[:26]
    S = CS[26:].reshape((-1, 26))
    return D, C, S


def _compute_score(output):
    score = 0
    last = np.zeros((26, ))
    for d in range(len(output)):
        last[output[d]] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][output[d]]

    return score


def solve():
    output = []
    for _ in range(D):
        max_score = float('-inf')
        best_i = 0
        for i in range(26):
            output.append(i)
            score = _compute_score(output)
            if max_score < score:
                max_score = score
                best_i = i + 1
            output.pop()
        output.append(best_i)

    return output


if __name__ == "__main__":
    D, C, S = getInputs()
    ans = solve()
    print('\n'.join(map(str, ans)))

### FIXED CODE ###

import numpy as np
import sys
read = sys.stdin.read


D = int(input())
CS = np.array(read().split(), np.int32)
C = CS[:26]
S = CS[26:].reshape((-1, 26))
del CS

last = np.zeros((26, ))
ans = []

def getContestType_at_d(d):
    s = -10000000
    for i in range(26):
        tmp = S[d][i] - np.sum(C * (d - last)) + C[i] * (d - last[i])
        if s < tmp:
            s = tmp
            t = i

    last[t] += 1

    return t + 1


for d in range(D):
    ans.append(getContestType_at_d(d))


print('\n'.join(map(str, ans)))
N, A, B = map(int,input().split())

q, mod = divmod(N, A+B)


if A == 0 :
    print(0)

elif N >A+B :
    if mod <= A :
        print(q*A+mod)
    if mod > A :
        print(q*A+A)
    
elif N == A+B :
    print(q*A)

elif N < A or N < A+B :
    print(N)

### FIXED CODE ###

S = input()
if S == 'AAA' or S == 'BBB' :
    print('No')
else :
    print('Yes')
import math
import sys

N,K = int(input())
ans = 0.000000000
for i in range(1,N+1):
    tmp = i
    q = 1.0000000/N
    while(tmp < K):
        q /= 2.00000000
        tmp *= 2
print(ans*1.0000000000000000000)

### FIXED CODE ###

import math
import sys
import numpy

N,K = map(int, input().split())
a = 0.000000000
b = 1
for i in range(1,N+1):
    b = 1
    if i >= K:
        a += 1/N
    else :
        tmp = i
        while tmp < K:
            tmp *= 2
            b /= 2
        a += b/N
print(a)
n, k = map(int, input().split())
s = input()
l = s.count('L')
r = s.count('R')
now = 0
for i in range(len(s)-1):
  if s[i] == 'R' and s[i+1] == 'L':
    now += 1
print(min(now + K, min(l, r)))

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
grp = 0
now = ""
for c in s:
  if c != now:
    grp += 1
    now = c
hap = 0
for i in range(n):
  if (i>0 and s[i]=='L' and s[i-1]=='L') or (i<n-1 and s[i]=='R' and s[i+1]=='R'):
    hap += 1
p_2 = (grp - 1) // 2
p_1 = (grp + 1) % 2
print(hap + 2 * min(k, p_2) + int(k > p_2) * p_1)
#dice
D=[int(i) for i in input().split()]
Os=input()
for i in range(len(Os)):
    if Os[i]=="N":
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif Os[i]=="S":
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
elif Os[i]=="E":
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
elif Os[i]=="W":
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t        
print(D[0])

### FIXED CODE ###

#dice
D=[int(i) for i in input().split()]
Os=input()
for i in range(len(Os)):
    if Os[i]=="N":
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif Os[i]=="S":
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
    elif Os[i]=="E":
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
    elif Os[i]=="W":
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t        
print(D[0])
A,B,C,K=map(int,input().split())
a=[1]*A
b=[0]*B
c=[-1]*C
S=a+b+c
T=S[:K]
print(sum(T))


### FIXED CODE ###

A,B,C,K=map(int,input().split())
if A+B>=K:
    if A<=K:
        print(A)
    else:
        print(K)
else:
    print(A*2-K+B)
from collections import defaultdict
n = int(input())
s = [list(map(int,input().split())) for i in range(n)]
s.sort()
c = []
for i in range(n):
    for j in range(i+1,n):
        x = s[j][0] - s[i][0]
        y = s[j][1] - s[i][1]
        c.append(str(x) + " " + str(y))
r = defaultdict(int)
for g in c:
    r[g] += 1
q = list(r.values())
q1 = max(q)
print(n-q1)

### FIXED CODE ###

from collections import defaultdict
n = int(input())
s = [list(map(int,input().split())) for i in range(n)]
s.sort()
c = []
if n == 1:
    print(1)
else:
    for i in range(n):
        for j in range(i+1,n):
            x = s[j][0] - s[i][0]
            y = s[j][1] - s[i][1]
            c.append(str(x) + " " + str(y))
    r = defaultdict(int)
    for g in c:
        r[g] += 1
    q = list(r.values())
    q1 = max(q)
    print(n-q1)
s = input()
sset = set(s)
ans = 'None'
for c in (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z):
  if c not in sset:
    ans = c
    break
print(ans)

### FIXED CODE ###

s = input()
sset = set(s)
ans = 'None'
abc = 'abcdefghijklmnopqrstuvwxyz'
for c in abc:
  if c not in sset:
    ans = c
    break
print(ans)
N = int(input())
xylist = [[0, 0]]*N
for i in range(N):
  xy = list(map(int, input().split()))
  xylist[i] = xy

dl = {}
for i in range(N):
  for j in range(N):
    dx = str(xylist[j][0] - xylist[i][0])
    dy = str(xylist[j][1] - xylist[i][1])
    l = dx + "|" + dy
    if dx == "0" and dy == "0":
      continue
    if l in dl:
      dl[l] = dl[l] + 1
    else:
      dl[l] = 1

cnt = N - max(dl.values())
print(cnt if cnt > 1 else "1")

### FIXED CODE ###

N = int(input())
xylist = [[0, 0]]*N
for i in range(N):
  xy = list(map(int, input().split()))
  xylist[i] = xy

dl = {}
for i in range(N):
  for j in range(N):
    dx = str(xylist[j][0] - xylist[i][0])
    dy = str(xylist[j][1] - xylist[i][1])
    l = dx + "|" + dy
    if dx == "0" and dy == "0":
      continue
    if l in dl:
      dl[l] = dl[l] + 1
    else:
      dl[l] = 1

cnt = 0
if len(dl) != 0:
  cnt = N - max(dl.values())

print(cnt if cnt > 1 else "1")
def function(S):
    ACGT = ['A', 'C', 'G, 'T']
    ret = 0
    N = len(S)
    for i in range(0, N):
        for j in range(i+1, N+1):
            temp = 0
            l = S[i:j]
            for x in l:
                if x not in ACGT:
                    break
            temp = len(l)
    	if temp >= ret:
        	ret = temp
    return ret

### FIXED CODE ###

def function(S):
    ACGT = ['A', 'C', 'G', 'T']
    ret = 0
    N = len(S)
    for i in range(0, N):
        for j in range(i+1, N+1):
            temp = 0
            l = S[i:j]
            const = 0
            for x in l:
                if x not in ACGT:
                    const = 1
                    break
            if const == 1:
                break
            temp = len(l)
            if temp >= ret:
                ret = temp
    return ret

S = input()
print(function(S))
import sys, math, collections, heapq, itertools
  
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    INF = 10 ** 25
    mod = 7 + 10 ** 9
    N = int(file())
    A = [int(a) for a in file().split()]
    A.sort()
    ans = 0
    out = []
    if N == 2:
        ans = A[1] - A[0]
        out = [A[1], A[0]]
    elif A[N-1] <= 0:
        ans = A[N-1] - A[N-2]
        out.append([A[N-1], A[N-2]])
        for i in range(N-2):
            out.append([ans, A[i]])
            ans -= A[i]
    elif A[0] >= 0:
        ans = A[0] - A[1]
        out.append([A[0], A[1]])
        for i in range(2, N-1):
            out.append([ans, A[i]])
        out.append([A[N-1], ans])
        ans = A[N-1] - ans
    else:
        for i in range(1, N-1):
            if A[i] >= 0:
                start = i-1
                break
        else: start = N - 2
        ans = A[start] - A[start + 1]
        out.append([A[start], A[start + 1]])
        if start + 2 < N - 1:
            for i in range(start + 2, N - 1):
                out.append([ans, A[i]])
                ans -= A[i]
        out.append([A[N-1], ans])
        ans = A[N-1] - ans
        if start > 0:
            for i in range(start):
                out.append([ans, A[i]])
                ans -= A[i]

    print(ans)
    for k in out:
        print(" ".join(map(str, k)))

    return 0
  
if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys, math, collections, heapq, itertools
from bisect import bisect_left
  
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    INF = 10 ** 25
    mod = 7 + 10 ** 9
    N = int(file())
    A = [int(a) for a in file().split()]
    A.sort()
    ans = 0
    out = []
    if N == 2:
        ans = A[1] - A[0]
        out = [[A[1], A[0]]]
    else:
        plus = bisect_left(A, 0)
        if plus == 0:
            ans = A[0]
            for i in range(1, N-1):
                out.append([ans, A[i]])
                ans -= A[i]
            out.append([A[N-1], ans])
            ans = A[N-1] - ans
        elif plus < N:
            ans = A[0]
            for i in range(plus, N - 1):
                out.append([ans, A[i]])
                ans -= A[i]
            out.append([A[N-1], ans])
            ans = A[N-1] - ans
            for i in range(1, plus):
                out.append([ans, A[i]])
                ans -= A[i]
        else:
            ans = A[N-1]
            for i in range(N-1):
                out.append([ans, A[i]])
                ans -= A[i]

    print(ans)
    for k in out:
        print(" ".join(map(str, k)))


    return 0
  
if __name__ == "__main__":
    solve()
n, m = map(int, input().split())
cs = []
ps = {}
for _ in range(m):
  p, y = map(int, input().split())
  cs.appenyd([y, p])
css = sorted(cs)
for c in css:
  if c[1] in ps:
    ps[c[1]].append(c[0])
  else:
    ps[c[1]] = [c[0]]
[print('{:06}{:06}'.format(c[1], ps[c[1]].index(c[0])+1))for c in cs]

 
  
  


### FIXED CODE ###

n, m = map(int, input().split())
cs = []
cd = {}
ps = {}
for _ in range(m):
  p, y = map(int, input().split())
  cs.append([p, y])
  if p in ps:
    ps[p].append(y)
  else:
    ps[p] = [y]
    
for p in ps:
  v = sorted(ps[p])
  for i, y in enumerate(v):
    cd[y] = i + 1
[print('{:06}{:06}'.format(c[0], cd[c[1]])) for c in cs]
A, B, K = map(int, input().split())
cnt = 0
ans = 0
for i in range(1, 101): # 1から100まで
	if(A % i == 0 and B % i == 0):
		cnt = cnt + 1
	if(cnt == k):
		ans = i
print(ans)

### FIXED CODE ###

a,b,c = map(int, input().split())
num = []
for i in range(1, 101):
  if(a % i == 0 and b % i == 0):
    num.append(i)
num.reverse()
print(num[c-1])
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7

positive = []
negative = []
zero = 0
for t in a:
    if t < 0:
        negative.append(t)
    elif t == 0:
        positive.append(0)
        zero += 1
    else:
        positive.append(t)
if n - zero < k:
    print(0)
    exit()

positive.sort()
negative.sort(reverse=True)

if not positive:
    ans = 1
    if k % 2 == 1:
        if zero != 0:
            print(0)
            exit()
        for i in range(k):
            ans *= negative[i]
            ans %= mod
    else:
        for i in range(k):
            ans *= negative.pop()
            ans %= mod
    print(ans)
    exit()

ans = 1
# negative 処理
check = []
if len(negative) % 2 == 1:
    negative = negative[1:]
while negative:
    check.append(negative.pop() * negative.pop())

# positive
if k % 2 == 1:
    ans *= positive.pop()
    k -= 1

if len(positive) % 2 == 1:
    positive = positive[1:]
while positive:
    check.append(positive.pop() * positive.pop())
check.sort()

for i in range(k//2):
    ans *= check.pop()
    ans %= mod

print(ans)






### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7

positive = []
negative = []
zero = 0
for t in a:
    if t < 0:
        negative.append(t)
    elif t == 0:
        positive.append(0)
        zero += 1
    else:
        positive.append(t)
if n - zero < k:
    print(0)
    exit()

positive.sort()
negative.sort(reverse=True)

if not positive:
    ans = 1
    if k % 2 == 1:
        if zero != 0:
            print(0)
            exit()
        for i in range(k):
            ans *= negative[i]
            ans %= mod
    else:
        for i in range(k):
            ans *= negative.pop()
            ans %= mod
    print(ans)
    exit()

ans = 1
# negative 処理
check = []
if len(negative) % 2 == 1:
    ww = negative[0]
    negative = negative[1:]
while negative:
    check.append(negative.pop() * negative.pop())

# positive
if k % 2 == 1:
    ans *= positive.pop()
    k -= 1

if len(positive) % 2 == 1:
    w = positive[0]
    positive = positive[1:]
while positive:
    check.append(positive.pop() * positive.pop())
check.sort()


for i in range(k//2):
    if check:
        ans *= check.pop()
    else:
        print(ans*w*ww%mod)
        exit()
    ans %= mod

print(ans)