Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.buffer.readline

def main():
    H,W = map(int,input().split())
    a = [list(map(int,input().split())) for _ in range(H)]
    
    ans = []
    for i in range(H):
        for j in range(W-1):
            if a[i][j]%2 != 0:
                a[i][j+1] += 1
                ans.append((i+1,j+1,i+1,j+2))
                
    for i in range(H-1):
        if a[i][-1]%2 != 0:
            a[i+1][-1] += 1
            ans.append((i+1,j+1,i+2,j+1))
            
    print(len(ans))
    for x in ans:
        print(*x)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    H,W = map(int,input().split())
    a = [list(map(int,input().split())) for _ in range(H)]
    
    ans = []
    for i in range(H):
        for j in range(W-1):
            if a[i][j]%2 != 0:
                a[i][j+1] += 1
                ans.append((i+1,j+1,i+1,j+2))
                
    for i in range(H-1):
        if a[i][-1]%2 != 0:
            a[i+1][-1] += 1
            ans.append((i+1,W,i+2,W))
            
    print(len(ans))
    for x in ans:
        print(*x)

if __name__ == "__main__":
    main()
N, X = [int(item) for item in input().split()]
L = [int(item) for item in input().split()][::-1]
D = 0
count = 0
while D <= X:
  l = L.pop()
  D += l
  count += 1
print (count)

### FIXED CODE ###

N, X = [int(item) for item in input().split()]
L = [int(item) for item in input().split()][::-1]
D = 0
count = 0
while D <= X:
  if len(L)>0:
    l = L.pop()
    D += l
    count += 1
  else:
    count += 1
    break
  
print (count)
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n=int(input())
num=list(map(int,input().split()))
ido=0
ans=[]
for i in range(n-1):
    if num[i]>=num[i+1] and i==n-2:
        ans.append(ido+1)
    elif num[i]>=num[i+1]:
        ido=ido+1
    elif num[i]<num[i+1]:
        ans.append(ido)
        ido=0


print(max(ans))


### FIXED CODE ###

# sys.stdin.readline()
import sys
input = sys.stdin.readline

n=int(input())
num=list(map(int,input().split()))
ido=0
ans=[0]
for i in range(n-1):
    if num[i]>=num[i+1] and i==n-2:
        ans.append(ido+1)
    elif num[i]>=num[i+1]:
        ido=ido+1
    elif num[i]<num[i+1]:
        ans.append(ido+0)
        ido=0

print(max(ans))
N = int(input())
a = [int(input()) for i in range(N)]
i = 0

while cnt <= N:
  lgt = a[i]
  cnt += 1
  if lgt == 2:
    print(cnt)
    break
  i = lgt - 1
else:
  print(-1)

### FIXED CODE ###

N = int(input())
a = [int(input()) for i in range(N)]
i = 0
cnt = 0

while cnt <= N:
  lgt = a[i]
  cnt += 1
  if lgt == 2:
    print(cnt)
    break
  i = lgt - 1
else:
  print(-1)
x,n = map(int, input().split())
p = list(map(int, input().split()))
ab = min(abs(101 - x),abs(x+1))
for i in range(1,101):
    if i in p:
        continue
    else:
        if ab > abs(x - i):
            ab = abs(x - i)
            answer = i
print(answer)

### FIXED CODE ###

x,n = map(int, input().split())
p = list(map(int, input().split()))
ab = min(abs(101 - x),abs(x))
if abs(101 - x) >= abs(x):
    answer = 0
else:
    answer = 101
for i in range(1,101):
    if i in p:
        continue
    else:
        if ab > abs(x - i):
            ab = abs(x - i)
            answer = i
        elif ab == abs(x-i) and answer > i:
            answer = i
print(answer)
input()
s = 0
a = list(map(int,input().split()))
for u in a:
    s=s+a
print(min(a),max(a),s)


### FIXED CODE ###

n = input()
s = 0
a = input()
b = a.split(" ")
c = []
for i in range(int(n)):
    c.append(int(b[i]))

for u in c:
    s=s+u

print(min(c),max(c),s)
import math
 
 
def power():
  	A, B= map(int, input().split())
    return math.ceil(A / B)
 
 
print(power())

### FIXED CODE ###

def power():
    A, B = map(int, input().split())
    socket = 1
    numberOfStrips = 0

    while socket < B:
        socket = socket + A - 1
        numberOfStrips = numberOfStrips + 1

    return numberOfStrips


print(power())
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    d = i_input()
    c_list = i_list()
    s_list = i_row_list(d)

    for i in range(d):
        tmp = s_list[i][s_list[i][i]%26+1] % 26 + 1
        print(tmp)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    d = i_input()
    c_list = i_list()
    s_list = i_row_list(d)

    for i in range(d):
        tmp = s_list[i][10] % 26 + 1
        if tmp <= 0:
            tmp = 1
        if tmp >= 27:
            tmp = 26
        print(tmp)

if __name__ == '__main__':
    main()
W, H, x, y = map(int, input().split())
jufuku = 0
if y / x == H / W:
    naname = W * H / 2
    jufuku = 1
    kiri = naname
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    kiri = max(tate, yoko)
print(kiri, jufuku)


### FIXED CODE ###

W, H, x, y = map(int, input().split())
jufuku = 0
if W / 2 == x and H / 2 == y:
    jufuku = 1
print(W * H / 2, jufuku)
coin = int(input())
max = int(input())
total = coin*500
if total >= max:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

inp = input()
arr = [int(i) for i in inp.split() if i.isdigit()]
total = arr[0]*500
if total >= arr[1]:
    print("Yes")
else:
    print("No")
m, n = map(int, input().split())
edge = [[False for j in range(n)] for i in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	edge[a-1][b-1] = edge[b-1][a-1] = True
visited = [False for _ in range(n)]
ans = 0
def dfs(v):
	visited[v] = True
	if all(x==True for x in visited):
		global ans
		ans += 1
		return
	for i in range(0, n):
		if edge[v][i]==True and visited[i]==False:
			dfs(i)
			visited[i] = False
			return
dfs(0)
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
edge = [[False for j in range(n)] for i in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	edge[a-1][b-1] = edge[b-1][a-1] = True
visited = [False for _ in range(n)]
ans = 0
def dfs(v):
	visited[v] = True
	if all(x==True for x in visited):
		global ans
		ans += 1
		return
	for i in range(0, n):
		if edge[v][i]==True and visited[i]==False:
			dfs(i)
			visited[i] = False
dfs(0)
print(ans)
N=input()
print(int(N**3))


### FIXED CODE ###

n=int(input())
print(n**3)
n,k = map(int, input().split())
ls = k[int(input()) for _ in range(n)]
ls.sort()
tmp = 10 ** 9
for i in range(n-k+1):
    diff = ls[i+k-1] - ls[i]
    if diff < tmp:
        tmp = diff
print(diff)

### FIXED CODE ###

n,k = map(int, input().split())
ls = [int(input()) for _ in range(n)]
ls.sort()
tmp = 10 ** 9
for i in range(n-k+1):
    diff = ls[i+k-1] - ls[i]
    if diff < tmp:
        tmp = diff
print(tmp)
import numpy as np
N,K=map(int, input().split())
A =list(map(int,input().split()))
MOD = 10 ** 9 + 7
if N==K:
  ans0 = 1
  for a in A[0:N]:
    ans0 *= a
    ans0 %= MOD
  print(ans0)
  exit()
A=sorted(A)  
if (K%2==1 and A[-1]<0):
  ans1 = 1
  for a in A[N-K:N]:
    ans1 *= a
    ans1 %= MOD
  print(ans1)
  exit()

A=sorted(A, key=lambda x:abs(x), reverse=True)
AA=[np.sign(i) for i in A]

ansA = 1
for a in A[0:K]:
  ansA *= a
  ansA %= MOD
ansAA = AA[0:K].count(-1)%2
if ansA==0 or ansAA==0:
  print(ansA)
  exit()

while ansA>0:
  ansA-=MOD

B1=A[0:K]
B2=sorted(A[K:N])
Bp=[i for i in A[0:K] if i>0]
Bm=[i for i in A[0:K] if i<0]

if B2[0]>0:B2.insert(0,0)
if B2[-1]<0:B2.insert(-1,0)
if not Bp:Bp.insert(0,B1[-1])
if not Bm:Bm.insert(0,B1[0])
  
#print(Bp,Bm,B2)

B1.remove(Bp[-1])
B1.append(min(B2[0],0))
#print(B1)
ansB = 1
for a in B1[0:K]:
  ansB *= a
  ansB %= MOD

C1=A[0:K]
C1.remove(Bm[-1])
C1.append(max(B2[-1],0))

ansC = 1
for a in C1[0:K]:
  ansC *= a
  ansC %= MOD

if abs(Bp[-1]*B2[-1])-abs(Bm[0]*B2[0])=>0:
  print(ansC)
#elif abs(Bp[-1]*B2[-1])-abs(Bm[0]*B2[0])>0:
#  print(ansC)
else: print(ansB)

#print(max(ansB,ansC))


### FIXED CODE ###

import numpy as np
N,K=map(int, input().split())
A =list(map(int,input().split()))
MOD = 10 ** 9 + 7
if N==K:
  ans0 = 1
  for a in A[0:N]:
    ans0 *= a
    ans0 %= MOD
  print(ans0)
  exit()
A=sorted(A)  
if (K%2==1 and A[-1]<0):
  ans1 = 1
  for a in A[N-K:N]:
    ans1 *= a
    ans1 %= MOD
  print(ans1)
  exit()
 
A=sorted(A, key=lambda x:abs(x), reverse=True)
AA=[np.sign(i) for i in A]
 
ansA = 1
for a in A[0:K]:
  ansA *= a
  ansA %= MOD
ansAA = AA[0:K].count(-1)%2
if ansA==0 or ansAA==0:
  print(ansA)
  exit()

while ansA>0:
  ansA-=MOD

B1=A[0:K]
C1=A[0:K]
B2=sorted(A[K:N])
Bp=[i for i in A[0:K] if i>0]
Bm=[i for i in A[0:K] if i<0]
 
if B2[0]>0:B2.insert(0,0)
if B2[-1]<0:B2.insert(-1,0)
if not Bp:Bp.insert(0,B1[-1])
if not Bm:Bm.insert(0,B1[0])
  
#print(Bp,Bm,B2)
#print(Bp[-1],B2[0])
B1.remove(Bp[-1])
B1.append(min(B2[0],0))
#print(B1)
ansB = 1
for a in B1[0:K]:
  ansB *= a
  ansB %= MOD
#print(Bm[-1],B2[-1])
C1.remove(Bm[-1])
C1.append(max(B2[-1],0))
 
ansC = 1
for a in C1[0:K]:
  ansC *= a
  ansC %= MOD
#print(B1,C1)
#print(ansB,ansC)
BB1=[np.sign(i) for i in B1]
ansBB1 = BB1[0:K].count(-1)%2
BB2=[np.sign(i) for i in C1]
ansBB2 = BB2[0:K].count(-1)%2
#print(ansBB1,ansBB2)
if ansBB1==1:
  print(ansC)
  exit()
if ansBB2==1:
  print(ansB)
  exit()
#print(B2[0]/Bp[-1],B2[-1]/Bm[-1])
#print(Bp[-1]*B2[-1],Bm[0]*B2[0])

#print(abs(Bp[-1]*B2[-1])-abs(Bm[-1]*B2[0]))
#print(ansB,ansC)
if abs(Bp[-1]*B2[-1])-abs(Bm[-1]*B2[0])>=0:
  print(ansC)
else: print(ansB)
'''
https://atcoder.jp/contests/abc077/tasks/arc084_a
'''
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

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

    def nibu(num, l):
        L = 0
        R = n-1
        mid = (L+R)//2
        if l[L]>num:
            return n, L
        if l[R]<num:
            return 0, n
        while 1:
            if l[L]<=num and num<l[L+1]:
                return n-(L+1), L+1
            elif l[mid]<=num:
                L = mid
            else:
                R = mid
            mid = (L+R)//2
    res = 0
    for i in A:
        x, na = nibu(i, B)
        for j in B[na:]:
            y, nb = nibu(j, C)
            res += y
    print(res)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

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

    res = 0
    for j in B:
        res += bisect_left(A, j) * (n-bisect_right(C, j))
    print(res)

if __name__ == '__main__':
    main()
import sys
sys.setrecursionlimit(100000)
h,w = map(int,input().split())
lst = []
for i in range(h):
  lst.append([s for s in input()])
def dfs(x,y):
  if lst[x][y] == '#':
    lst[x][y] = '.'
    if x + 1 <= h - 1:
      dfs(x + 1,y)
    if x - 1 >= 0:
      dfs(x - 1,y)
    if y + 1 <= w - 1:
      dfs(x, y + 1)
    if y - 1 >= 0:
      dfs(x,y - 1)
flag = True
for i in range(h):
  for j in range(w):
    if lst[i][j] == '#':
      if (i - 1 >= 0 and lst[i - 1][j] == "#") or (i + 1 < h and lst[i + 1][j] == "#") or (j - 1 >= 0 and lst[i][j - 1] == "#") or (j + 1 < w and lst[i][j + 1] == "#"):
        dfs(i,j)
      else:
        flag = False
        break
if flag:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

a,b = map(int,input().split())
if b >= a: print(a)
else: print(a - 1)
a1=input().split()
a2=input().split()
a3=input().split()
A=[a1,a2,a3]
b=int(input()) for i in range(int(input()))
if a1[0] and a1[1] and a1[2] in b:
    print("Yes")
elif a2[0] and a2[1] and a2[2] in b:
    print("Yes")
elif a3[0] and a3[1] and a3[2] in b:
    print("Yes")
elif a1[0] and a2[0] and a3[0] in b:
    print("Yes")
elif a1[1] and a2[1] and a3[1] in b:
    print("Yes")
elif a1[2] and a2[2] and a3[2] in b:
    print("Yes")
elif a1[0] and a2[1] and a3[2] in b:
    print("Yes")
elif a1[2] and a2[1] and a3[0] in b:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

def main():
    a = [input().split() for _ in range(3)]
    ans = [[0] * 3 for _ in range(3)]
    n = int(input())
    b = [input() for _ in range(n)]

    for bi in b:
        for y in range(3):
            for x in range(3):
                if bi == a[y][x]:
                    ans[y][x] = 1

    if ans[0][0] == ans[0][1] == ans[0][2] == 1:
        print('Yes')
    elif ans[1][0] == ans[1][1] == ans[1][2] == 1:
        print('Yes')
    elif ans[2][0] == ans[2][1] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][0] == ans[1][0] == ans[2][0] == 1:
        print('Yes')
    elif ans[0][1] == ans[1][1] == ans[2][1] == 1:
        print('Yes')
    elif ans[0][2] == ans[1][2] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][0] == ans[1][1] == ans[2][2] == 1:
        print('Yes')
    elif ans[0][2] == ans[1][1] == ans[2][0] == 1:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
n=int(input())
h=list(map(int,input().split())
c=0
le=[]       
for i in range(n-1):
    if h[i]>=h[i+1]:
       c+=1
    else:
       le.append(c)
       c=0
print(max(le))
       

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
c=0
t=0

for i in range(n-1):
  if h[i]>=h[i+1]:
    c+=1
  else:
    t=max(t,c)
    c=0
  t=max(t,c)
print(t)
N, M = map(int, input().split()) 
H = list(map(int, input().split())) 

A=[0 for i in range(N)]
B=[0 for i in range(N)]
for i in range(M):
    A[i],B[i]=map(int,input().split())
    A[i] -= 1
    B[i] -= 1

ans = 0
idx = 0
while idx < N:
    i = 0
    cnt = 0
    while i < M:
        if A[i] == idx:
            if H[idx] <= H[B[i]]:
                cnt += 1
                break
        if B[i] == idx:
            if H[idx] <= H[A[i]]:
                cnt += 1
                break
        i += 1
    
    if i == M:
        ans += 1
    elif i == M and cnt == 0:
        ans += 1
    
    idx += 1

print(ans)

### FIXED CODE ###

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

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

ans = 0
for i, g in enumerate(G):
    if not g:
        ans += 1
        continue
    if H[i] > max(g):
        ans += 1

print(ans)
N = int(input())
A = list(map(int,input().split()))
for i in range(0,n-1):
  for j in range(i+1,n):
    if A[i] != A[j]:
      return 'NO'
return 'YES'

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = "YES"
for i in range(1,N):
    if A[i-1] == A[i]:
        ans = "NO"
        break
print(ans)
def main():
    N = input_ints()
    h = input_int_list_in_line()

    DP = [0] * N

    DP[1] = abs(h[0] - h[1])

    for i in range(2, N):
        one_hop = abs(h[i] - h[i - 1])
        two_hop = abs(h[i] - h[i - 2])

        if DP[i - 1] + one_hop < DP[i - 2] + two_hop:
            DP[i] += DP[i - 1] + one_hop
        else:
            DP[i] += DP[i - 2] + two_hop

    print(DP[-1])


def input_int():
    return int(input())


def input_ints():
    return map(int, input().split())


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int, q: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()


### FIXED CODE ###

def main():
    N = input_int()
    h = input_int_list_in_line()

    DP = [0] * N

    DP[1] = abs(h[0] - h[1])

    for i in range(2, N):
        one_hop = abs(h[i] - h[i - 1])
        two_hop = abs(h[i] - h[i - 2])

        if DP[i - 1] + one_hop < DP[i - 2] + two_hop:
            DP[i] += DP[i - 1] + one_hop
        else:
            DP[i] += DP[i - 2] + two_hop

    print(DP[-1])


def input_int():
    return int(input())


def input_ints():
    return map(int, input().split())


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int, q: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()
N = int(input('number'))
a = N % 10
if a = 2 or 4 or 5 or 7 or 9:
  print('hon')
elif a = 0 or 1 or 6 or 8:
  print('pon')
else:
  print('bon')

### FIXED CODE ###

N = int(input())
a = N % 10
if a == 2 or a==4 or a==5 or a==7 or a==9:
    print('hon')
elif a == 0 or a==1 or a==6 or a==8:
    print('pon')
else:
    print('bon')
N,K = [int(i) for i input().split()]
h = [int(i) for i input().split()]

count = 0
for i in range(N):
  if h[i] >= K:
    count += 1

print(count)

### FIXED CODE ###

N,K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
 
count = 0
for i in range(N):
  if h[i] >= K:
    count += 1
 
print(count)
num = [ int(v) for v in input().split() ]
print( i[0]*i[1] if all([ 1 <= i < 10 for i in num ]) else -1 )

### FIXED CODE ###

num = [ int(v) for v in input().split() ]
print( num[0]*num[1] if all([ 1 <= i < 10 for i in num ]) else -1 )
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

surplus = []
short = []

for i in range(n):
    if a[i] > b[i]:
        surplus.append(a[i]-b[i])
    elif b[i] > a[i]:
        short.append(b[i]-a[i])

surplus = sorted(surplus)
taken = False
cnt = 0
for i in range(len(short)):
    cost = short.pop()
    cnt += 1

    while cost > 0:
        if len(surplus) == 0:
            print(-1)
           	exit()

        take = min(cost, surplus[-1])
        cost -= take
        surplus[-1] -= take

        if not taken:
            taken = True
            cnt += 1

        if surplus[-1] == 0:
            surplus.pop()
            taken = False

print(cnt)

### FIXED CODE ###

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

surplus = []
short = []

for i in range(n):
    if a[i] > b[i]:
        surplus.append(a[i]-b[i])
    elif b[i] > a[i]:
        short.append(b[i]-a[i])

surplus = sorted(surplus)
taken = False
cnt = 0
for i in range(len(short)):
    cost = short.pop()
    cnt += 1

    while cost > 0:
        if len(surplus) == 0:
            print(-1)
            exit()

        take = min(cost, surplus[-1])
        cost -= take
        surplus[-1] -= take

        if not taken:
            taken = True
            cnt += 1

        if surplus[-1] == 0:
            surplus.pop()
            taken = False

print(cnt)
n = int(input())
a = list(map(int,input().split()))
a.sort()
aminus = []
aplus = []
p = 0
q = 0
for i in a:
    if i >= 0:
        aplus.append(i)
        p += 1
    elif i < 0:
        aminus.append(i)
        q += 1
ans = []
cou = 0
if aplus and aminus:
    now = aminus[0]
    for i in range(p-1):
        ans.append((now,aplus[i]))
        now = now - aplus[i]
    aminus[0] = now
    now = aplus[p-1]
    for i in range(q):
        ans.append((now,aminus[i]))
        now = now - aminus[i]
    cou = now
elif aplus:
    now = aplus[0]
    for i in range(1,p-1):
        ans.append((now,aplus[i]))
        now = now - aplus[i]
    ans.append((aplus[p-1],now))
    cou = aplus[p-1] - now
elif aminus:
    now = aminus[q-1]
    for i in range(q-1):
        ans.append(now,aminus[i])
        now = now - aminus[i]
    cou = now
print(cou)
for i in range(n-1):
    print(*ans[i])


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
aminus = []
aplus = []
p = 0
q = 0
for i in a:
    if i >= 0:
        aplus.append(i)
        p += 1
    elif i < 0:
        aminus.append(i)
        q += 1
ans = []
cou = 0
if aplus and aminus:
    now = aminus[0]
    for i in range(p-1):
        ans.append((now,aplus[i]))
        now = now - aplus[i]
    aminus[0] = now
    now = aplus[p-1]
    for i in range(q):
        ans.append((now,aminus[i]))
        now = now - aminus[i]
    cou = now
elif aplus:
    now = aplus[0]
    for i in range(1,p-1):
        ans.append((now,aplus[i]))
        now = now - aplus[i]
    ans.append((aplus[p-1],now))
    cou = aplus[p-1] - now
elif aminus:
    now = aminus[q-1]
    for i in range(q-1):
        ans.append((now,aminus[i]))
        now = now - aminus[i]
    cou = now

print(cou)
for i in range(n-1):
    print(*ans[i])
def solve(n, m, ABC):
    distance = [None] * n
    distance[0] = 0

    for _ in range(n):
        for a, b, c in ABC:
            if distance[b - 1] is None or distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c

    for a, b, c in ABC:
        if distance[b - 1] is None or distance[b - 1] < distance[a - 1] + c:
            return 'inf'

    return distance[n - 1]

_n, _m = map(int, input().split())
_ABC = [list(map(int, input().split())) for _ in range(_m)]
print(solve(_n, _m, _ABC))


### FIXED CODE ###

def solve(n, m, ABC):
    distance = [None] * n
    distance[0] = 0

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None:
                continue
            if distance[b - 1] is None or distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None or distance[b - 1] is None:
                continue
            if distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c
                if b == n:
                    return 'inf'

    return distance[n - 1]

_n, _m = map(int, input().split())
_ABC = [list(map(int, input().split())) for _ in range(_m)]
print(solve(_n, _m, _ABC))
import math
A, B = map(int, input().split())
ans = A * B // math.gcd(A, B)
print(ans)

### FIXED CODE ###

import fractions
A, B = map(int, input().split())
ans = A * B // fractions.gcd(A, B)
print(ans)