Harryxun/stf_run huggingface dataset:
from math import gcd
a,b = map(int,input().split())
def lcm(x,y):
    return x*y//gcd(x,y)
print(lcm(a,b))

### FIXED CODE ###

from fractions import gcd
a,b = map(int,input().split())
def lcm(x,y):
    return x*y//gcd(x,y)
print(lcm(a,b))
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():
    N = in_n()
    X = in_s()
    nx = int(X, 2)

    ans = [0] * N

    oc = X.count('1')
    mx = nx % (oc - 1)
    px = nx % (oc + 1)

    for i in range(N):

        if X[i] == '0':
            a = (px + pow(2, N - i - 1, oc + 1)) % (oc + 1)
        elif oc - 1 != 0:
            a = (mx - pow(2, N - i - 1, oc - 1)) % (oc - 1)
        else:
            ans[i] = 0
            continue

        count = 1
        while a:
            a = a % bin(a).count('1')
            count += 1

        ans[i] = count

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    X = readline().rstrip().decode('utf-8')
    nx = int(X, 2)

    ans = [0] * N

    oc = X.count('1')

    if oc - 1 != 0:
        mx = nx % (oc - 1)
        f = True
    else:
        f = False

    px = nx % (oc + 1)

    for i in range(N):

        if X[i] == '0':
            a = (px + pow(2, N - i - 1, oc + 1)) % (oc + 1)
        elif f:
            a = (mx - pow(2, N - i - 1, oc - 1)) % (oc - 1)
        else:
            ans[i] = 0
            continue

        count = 1
        while a:
            a = a % bin(a).count('1')
            count += 1

        ans[i] = count

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()
from fractions import gcd

N = int(input())

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

def lcm(a):
  x = a[0]
  for i in range(1, len(a)):
    x = (x * a[i]) // gcd(x, a[i])
  return x

l = lcm(A)
num=0
for a in A:
  num += l/a
print(int(num % (10**9 +7)))




### FIXED CODE ###

from fractions import gcd

N = int(input())

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

l = A[0]
for a in A:
  l = (l * a) // gcd(l,a)
num=0
for a in A:
  num += l//a
print(num % (10**9 +7))
coding:utf-8                                                                                     

N = int(raw_input())
C = []
S = []
F = []

for i in range(N-1):
    c, s, f = map(int, raw_input().split())
    C.append(c)
    S.append(s)
    F.append(f)

res = []
T = []

for i in range(N-1):
    t = 0
    for j in range(i, N-1):
        if S[j] >= t:
            t = 0
            t += S[j] + C[j]
        elif t % F[j] == 0:
            t += C[j]
        else:
            t = t + F[j] - (t - (S[j] + F[j] * ((t-S[j])/F[j]))) + C[j]
    T.append(t)

for t in T:
    print t
print 0

### FIXED CODE ###

# coding:utf-8                                                                                     

N = int(raw_input())
C = []
S = []
F = []

for i in range(N-1):
    c, s, f = map(int, raw_input().split())
    C.append(c)
    S.append(s)
    F.append(f)

res = []

for i in range(N-1):
    t = 0
    for j in range(i, N-1):
        if S[j] >= t:
            t = 0
            t += S[j] + C[j]
        elif t % F[j] == 0:
            t += C[j]
        else:
            t = S[j] + F[j] * ((t - S[j]) / F[j]) + F[j] + C[j]
    print t

print 0
a,b = map(int,input().split())
aaa = list(map(int,input().split()))

aaa.sort(reverse=True)
result = [0]*b
for i in range(b):
    h = aaa[i]
    j = sum(aaa) / (4*b)

    if h >= j:
        result[i] = 1
    else:
        result[i] = 0

if result.count(1) >= b:
    ans = "Yes"
else:
    ans = "No"

print(ans)

### FIXED CODE ###

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

print(c,a,b)
N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(M)]

matches = []
for i in range(0, 1000):
    if len(str(i)) == N:
        temp = True
        for s, c in sc:
            if str(i)[s - 1] != str(c):
                temp = False
        if temp: matches.append(i)
print(-1) if len(matches) == 0 else print(min(matches))

### FIXED CODE ###

N = int(input())
print(((N+2)-1)//2)
x,b,z = input().split()
a=int(x)
c=int(z)
while b!="?":
    if b=="+":
        print(a+c)
    elif b=="-":
        print(a-c)
    elif b=="*":
        print(a*c)
    elif b=="/":
        print(int(a/c))
    a,b,c = input().split()

### FIXED CODE ###

x,b,z = input().split()
a=int(x)
c=int(z)
while b!="?":
    if b=="+":
        print(a+c)
    elif b=="-":
        print(int(a)-int(c))
    elif b=="*":
        print(a*c)
    elif b=="/":
        print(int(a/c))
    x,b,z = input().split()
    a=int(x)
    c=int(z)
def count_ops(a):
    if a[0] == 0:
        total_ops = 1
        if a[1] < 0:
            accum = 1
        else:
            accum = -1
    else:
        total_ops = 0
        accum = a[0]
    for i in range(1, len(a)):
        new_accum = accum + a[i]
        if (accum > 0 and new_accum > 0):
            ops = ops_needed(new_accum, -1)
        elif (accum > 0 and new_accum == 0):
            ops = -1
        elif (accum < 0 and new_accum < 0):
            ops = ops_needed(new_accum, 1)
        elif (accum < 0 and new_accum == 0):
            ops = 1
        else:
            ops = 0
        total_ops += abs(ops)
        accum = new_accum + ops
    return total_ops
        

if __name__ == '__main__':
    _ = int(input())
    a = list(map(int, input().split()))
    print(count_ops(a))


### FIXED CODE ###

def ops_needed(x, target):
    if abs(target - x) < abs(x):
        return 0
    else:
        return target - x

def count_ops(a, first_target):
    total_ops = 0
    accum = 0
    for i, ai in enumerate(a):
        new_accum = accum + a[i]
        if i % 2 == 1:
            ops = ops_needed(new_accum, first_target)
        else:
            ops = ops_needed(new_accum, -1 * first_target)
        total_ops += abs(ops)
        accum = new_accum + ops
    return total_ops
        

if __name__ == '__main__':
    _ = int(input())
    a = list(map(int, input().split()))
    print(min(count_ops(a, 1), count_ops(a, -1)))
inf = 10 ** 9
memo = {}


def cost(n):
    if n==2:
        return abs(h[2]-h[1])
    elif n == 1:
        return 0
    elif n < 1:
        return inf
    elif n in memo:
        return memo[n]
    else:
        re = min(cost(n - 2) + abs(h[n] - h[n - 2]), cost(n - 1) + abs(h[n] - h[n - 1]))
        memo[n] = re
        return re


n = int(input())
h = [0] + list(map(int, input().split()))
print(cost(n))
print(memo)


### FIXED CODE ###

n = int(input())
h = [0] + list(map(int, input().split()))
cost = {1:0,2: abs(h[2] - h[1])}
for i in range(1, n):
    cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i]))
    if i==n-1:break
    cost[i + 2] = cost[i] + abs(h[i + 2] - h[i])

print(cost[n])
import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
A = [int(a) for a in input().strip().split()]
if A[0] != 0:
    print(0)
    exit()
for a in A:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
A = [int(a) for a in input().strip().split()]
for a in A:
    if rbg.count(a) == 0:
        print(0)
        exit()
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans)
ru = int(input())

a = [input() for i in range(ru)] 


print('AC x '+a.count('AC'))
print('WA x '+a.count('WA'))
print('TLE x '+a.count('TLE'))
print('RE x '+a.count('RE'))

### FIXED CODE ###

ru = int(input())

a = [input() for i in range(ru)] 


print('AC x '+str(a.count('AC')))
print('WA x '+str(a.count('WA')))
print('TLE x '+str(a.count('TLE')))
print('RE x '+str(a.count('RE')))
n=int(input())
h=list(map(int,input().split()))
ans=0
answer=[]
for i in range(n-1):
  if h[i]>=h[i+1]:
    ans+=1
  if h[i]<h[i+1]:
    answer.append(ans)
    ans=0
  if i == n-2:
    answer.append(ans)
print(max(answer))

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
x = 0
lis = []
for i in range(0,len(H)-1) :
    if H[i] - H[i+1] >=0:
        x += 1
    else:
        lis.append(x)
        x =0
lis.append(x)
print(max(lis))
s1,s2,s3=map(int,input().split())
print(s1[0]+s2[0]+s3[0])

### FIXED CODE ###

s1,s2,s3=input().split()
print(str.upper(s1[0]+s2[0]+s3[0]))
import bisect

S=int(input())
A=[int(i) for i in input().split()]

T=int(input())
B=[int(i) for i in input().split()]

l=0
r=len(B)
c=(r+l)/2

n=0


for i in B:
    if i in A:
        n+=1
    elif B[i-1]>c:
        l=c
        c=(r+l)/2
    elif B[i-1]<c:
        r=c
        c=(r+l)/2

print(n)



### FIXED CODE ###


def bs(A, n):
    l=0
    r=len(A)
    while l<r:
        mid=int((l+r)/2)
        if A[mid]==n:
            return mid
        else:
            if n<A[mid]:
                r=mid
            else:
                l=mid+1

    return -1

S=int(input())
A=[int(i) for i in input().split()]

T=int(input())
B=[int(j) for j in input().split()]

A.sort()

cnt=0
for i in range(T):
    x=bs(A,B[i])
    if x!=(-1):
        cnt=cnt+1

print(cnt)
s = input()
s[3] = "8"
print(s)

### FIXED CODE ###

print(input().replace('2017', '2018'))
s=input().split()
N=int(s[0])
C=int(s[1])
d=[]
for i in range(C):
    s=input().split()
    temp=[]
    for item in s:
        temp.append(int(item))
    d.append(temp)
if N==1:
    print("0")
else:
    c=[[],[],[]]
    cost=[[],[],[]]
    for j in range(N):
        s=input().split()
        for i in range(len(s)):
            c[(i+j)%3].append(int(s[i])-1)
    for i in range(C):
        s=0
        for col in c[0]:
            s+=d[col][i]
        cost[0].append((s,i))
        s=0
        for col in c[1]:
            s+=d[col][i]
        cost[1].append((s,i))
        s=0
        for col in c[2]:
            s+=d[col][i]
        cost[2].append((s,i))
    cost[0].sort()
    cost[1].sort()
    cost[2].sort()
    res=3000000
    for i in range(N):
        for j in range(N):
            for k in range(N):
                if cost[0][i][1]!=cost[1][j][1] and cost[1][j][1]!=cost[2][k][1] and cost[2][k][1]!=cost[0][i][1]:
                    res=min(res,cost[0][i][0]+cost[1][j][0]+cost[2][k][0])
                if cost[0][i][0]+cost[1][j][0]+cost[2][k][0]>res:
                    break

    print(res)


### FIXED CODE ###

s=input().split()
N=int(s[0])
C=int(s[1])
d=[]
for i in range(C):
    s=input().split()
    temp=[]
    for item in s:
        temp.append(int(item))
    d.append(temp)
if N==1:
    print("0")
else:
    c=[[],[],[]]
    cost=[[],[],[]]
    for j in range(N):
        s=input().split()
        for i in range(len(s)):
            c[(i+j)%3].append(int(s[i])-1)
    for i in range(C):
        s=0
        for col in c[0]:
            s+=d[col][i]
        cost[0].append((s,i))
        s=0
        for col in c[1]:
            s+=d[col][i]
        cost[1].append((s,i))
        s=0
        for col in c[2]:
            s+=d[col][i]
        cost[2].append((s,i))
    res=100000000000
    for i in range(C):
        for j in range(C):
            for k in range(C):
                if cost[0][i][1]!=cost[1][j][1] and cost[1][j][1]!=cost[2][k][1] and cost[2][k][1]!=cost[0][i][1]:
                    res=min(res,cost[0][i][0]+cost[1][j][0]+cost[2][k][0])
    print(res)
TimeS = raw_input()
TimeM = timeS / 60
sec = time % 60
hou = TimeM / 60
min = TimeM % 60

print(str(hou)+ ":"+ str(min)+ ":"+ str(sec))

### FIXED CODE ###

TimeS = int(raw_input())
TimeM = TimeS / 60
sec = TimeS % 60
hou = TimeM / 60
min = TimeM % 60

print(str(hou)+ ":"+ str(min)+ ":"+ str(sec))
x,a-map(int,input().split())
print((x>=a)*10)

### FIXED CODE ###

x,a=map(int,input().split())
print((x>=a)*10)
data = input()
data_list = data.split(" ")
if ((data_list[0]*data_list[1])%2 == 0):
  print("Odd")
else:
  print("Even")

### FIXED CODE ###

a,b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')
s=input().split()

if s[0]=s[1]:
  print('H')
else:
  print('D')

### FIXED CODE ###

s=input().split()

if s[0]==s[1]:
  print('H')
else:
  print('D')
while true:
  H, W = map(int, raw_input().split())
   if H == 0 and W == 0:
      break
  print ("#" * W "\n") * H

### FIXED CODE ###

while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
      break
  print (("#" * W + "\n") * H)
#標準入力からソートまで
import numpy as np
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
#Aの中で一番でかいのをdiscountしてまた並び替え
import bisect
for i in range(M):
    tmp = A.pop(N-1) // 2
    if A[N-2] <= tmp:
        A.append(tmp)
    else:
        bisect.insort_left(A, tmp)
print(sum(A))

### FIXED CODE ###

#標準入力からソートまで
N, M = map(int, input().split())
A = list(map(lambda x : int(x) * (-1), input().split()))
#Aの中で一番でかいのをdiscountしてまた並び替え
#優先度付きqueuemを使う
import heapq
heapq.heapify(A)
for i in range(M):
    tmp = (-1) * heapq.heappop(A) // 2
    heapq.heappush(A, tmp * (-1))
print(-sum(A))
a = input()
b = input()
c = input()
x = input()
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == i*500 + j*100 + k*50:
                ans += 1
print(ans)

### FIXED CODE ###

a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == i*500 + j*100 + k*50:
                ans += 1
print(ans)
n,x = map(int,input().split())
arr = list(map(int,input().split()))
chk = 0

for i in range(len(arr)-1):
    if i == 0:
        chk = 0
    else:
        chk = chk + arr[i]

    if chk <= x:
        count =+ 1
    else:
        print(count)
        exit()

 print(count)


### FIXED CODE ###

n,x = map(int,input().split())
arr = list(map(int,input().split()))
chk = 0
cnt = 1
for i in range(len(arr)):
    chk = chk + arr[i]

    if chk <= x:
        cnt += 1
    else:
        print(cnt)
        exit()

print(cnt)
import sys
word = input()

tab = ["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"]
flag = True
if len(word)%2 == 1:
    print("No")
    sys.exit()
for i in range(len(word))
    if word.count(tab[i])%2 == 1:
        flag = False
        break
if flag:print("Yes")
else: print("No")

### FIXED CODE ###

word = input()

flag = True
if len(word)%2 == 1:
    flag = False

wordset = set(word)
leng = len(wordset)
for s in wordset:
    if word.count(s)%2 == 1:
        flag = False
        break
if flag:print("Yes")
else: print("No")
n,k=map(int,input().split())
lista = [int(i) for i in input().split()]
from functools import reduce
from math import gcd

gcda=functools.reduce(gcd, lista)

if k>max(lista):
    print("IMPOSSIBLE")
else:
    if k%gcda==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

### FIXED CODE ###

n,k=map(int,input().split())
lista = [int(i) for i in input().split()]
import functools
#from functools import reduce
import fractions
#from fractions import gcd

gcda=functools.reduce(fractions.gcd, lista)

if k>max(lista):
    print("IMPOSSIBLE")
else:
    if k%gcda==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
N,X = map(int,input().split())
L = list(map,input().split())

cnt=1
dist=0

for l in L:
  cnt+=1
  dist+=l
  if dist>=X:
    break
    
print(cnt)
  

### FIXED CODE ###

N,X = map(int,input().split())
L = list(map(int,input().split()))

cnt=1
dist=0

for l in L:
  dist+=l
  if dist>X:
    break
  cnt+=1
    
print(cnt)
import heapq
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
q = []
heapq.heapify(q)
heapq.heappush(q,(-(a[0] + b[0] + c[0]),0,0,0))
for _ in range(K):
    m, i, j, k = heapq.heappop(q) #mに和、ijkにインデックス
    print(-m) #親から取り出すが、親は子よりも小さい、大きい順にするために-を入れている
    if i + 1 < X: #最初にiには０が挿入されている,pythonではインデックスが０から始まるから<xでいい
        s = (-(A[i+1] + B[j] + C[k]), i+1, j, k)
        if s not in q:
            heapq.heappush(q,s)
    if j + 1 < Y:
        s = (-(A[i] + B[j+1] + C[k]), i, j+1, k)
        if s not in q:
            heapq.heappush(q, s)
    if k + 1 < Z:
        s = (-(A[i] + B[j] + C[k+1]), i, j, k+1)
        if s not in q:
            heapq.heappush(q,s)
    


### FIXED CODE ###

import heapq
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
q = []
heapq.heapify(q)
heapq.heappush(q,(-(A[0] + B[0] + C[0]),0,0,0))
for _ in range(K):
    m, i, j, k = heapq.heappop(q) #mに和、ijkにインデックス
    print(-m) #親から取り出すが、親は子よりも小さい、大きい順にするために-を入れている
    if i + 1 < X: #最初にiには０が挿入されている,pythonではインデックスが０から始まるから<xでいい
        s = (-(A[i+1] + B[j] + C[k]), i+1, j, k)
        if s not in q:
            heapq.heappush(q,s)
    if j + 1 < Y:
        s = (-(A[i] + B[j+1] + C[k]), i, j+1, k)
        if s not in q:
            heapq.heappush(q, s)
    if k + 1 < Z:
        s = (-(A[i] + B[j] + C[k+1]), i, j, k+1)
        if s not in q:
            heapq.heappush(q,s)
a = int(raw_input("input a:"))
b = int(raw_input("input b:"))
print a*b,2*a+2*b

### FIXED CODE ###

a,b = map(int,raw_input().split())
print a*b,a*2 + b*2
# -*- coding:utf-8 -*-
import math

def solve():
    menus = []
    for i in range(0, 5):
        menus.append(int(input()))
    
    # １の位が最も小さいものを最後に注文する。あとはなんでもいい
    amari = 10
    for i in range(0, 5):
        if menus[i]%10 < amari and menus[i]%10 != 0:
            last = i
            amari = menus[i]%10
    
    ans = 0
    for i in range(0, 5):
        if i == last:
            continue

        ans += menus[i]
        ans = math.ceil(ans/10) * 10
    
    ans += menus[last]
    print(ans)



if __name__ == "__main__":
    solve()


### FIXED CODE ###

# -*- coding:utf-8 -*-
import math

def solve():
    menus = []
    for i in range(0, 5):
        menus.append(int(input()))
    
    # １の位が最も小さいものを最後に注文する。あとはなんでもいい
    amari = 10
    last = 0
    for i in range(0, 5):
        if menus[i]%10 < amari and menus[i]%10 != 0:
            last = i
            amari = menus[i]%10
    
    ans = 0
    for i in range(0, 5):
        if i == last:
            continue

        ans += menus[i]
        ans = math.ceil(ans/10) * 10
    
    ans += menus[last]
    print(ans)



if __name__ == "__main__":
    solve()
n = int(input())
h_list = list(map(int,input().split()))
count_list = []
i = 0
counter = 0
for i in range(n-1):
    if len(h_list) == 1:
      count_list.append(0)
      break
    if h_list[i] >= h_list[i + 1]:
       count_list.append(1)
    else :
       count_list.append(0)
result_list = []
result = 0
for m in count_list:
    if m == 1:
        result += 1
        result_list.append(result)
        
    else :
        result = 0
        result_list.append(result)
        
print(max(result_list))  
  
    
    
    
  


### FIXED CODE ###

n = int(input())
h_list = list(map(int,input().split()))
count_list = []
i = 0
counter = 0
for i in range(n-1):
    if h_list[i] >= h_list[i + 1]:
       count_list.append(1)
    else :
       count_list.append(0)
result_list = []
result = 0
for m in count_list:
    if m == 1:
        result += 1
        result_list.append(result)
        
    else :
        result = 0
        result_list.append(result)
        
if result_list == []:
    print(0)
else:
    print(max(result_list))
s = input() 
t = input()

ans = 0

for i in range(3):
	if s[i]=t[i]:
		ans += ans

print(ans)

### FIXED CODE ###

s = input()
t = input()

ans = 0

for i in range(3):
	if s[i]==t[i]:
		ans += 1
print(ans)
h, w, k = map(int, input().split())
p = [list(str(input())) for _ in range(h)]
bl = p.count('#')
bl = bl - k
ee = list(range(h))
q = list(range(w))
kotae = 0
pp = []
qq = []
for i in range(h + 1):
    pp += list(itertools.combinations(ee, i))
for i in range(w + 1):
    qq += list(itertools.combinations(q, i))
for i in pp:
    for j in qq:
        ans = 0
        for zz in range(h):
            for ww in range(w):
                if zz not in i:
                    if ww not in j:
                        if p[zz][ww] == '#':
                            ans += 1
        if ans == k:
            kotae += 1
print(kotae)

### FIXED CODE ###

import itertools
h, w, k = map(int, input().split())
p = [list(str(input())) for _ in range(h)]
bl = p.count('#')
bl = bl - k
ee = list(range(h))
q = list(range(w))
kotae = 0
pp = []
qq = []
for i in range(h + 1):
    pp += list(itertools.combinations(ee, i))
for i in range(w + 1):
    qq += list(itertools.combinations(q, i))
for i in pp:
    for j in qq:
        ans = 0
        for zz in range(h):
            for ww in range(w):
                if zz not in i:
                    if ww not in j:
                        if p[zz][ww] == '#':
                            ans += 1
        if ans == k:
            kotae += 1
print(kotae)
from collections import deque
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
dq = deque(sorted(A))
ans = deque([dq.popleft()])
ans.append(dq.pop())
ans.appendleft(dq.pop())
flag = True
while dq:
    if flag:
        ans.append(dq.popleft())
        if dq:
            ans.appendleft(dq.popleft())
            flag = False
    else:
        ans.append(dq.pop())
        if dq:
            ans.appendleft(dq.pop())
            flag = True
B = list(ans)
s = 0
for i in range(n-1):
    s += abs(B[i+1]-B[i])
print(s)

### FIXED CODE ###

from collections import deque
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))
if n == 2:
    print(abs(A[1]-A[0]))
    exit()
A.sort()
s = sum(A)
if n % 2 == 1:
    small = 0
    for i in range(n//2):
        small += A[i]
    big = s - small
    ans1 = 2*big-2*small-A[n//2]-A[n//2+1]
    small += A[n//2]
    big = s-small
    ans2 = 2*big -2*small+A[n//2]+A[n//2-1]
    print(max(ans1,ans2))
else:
    small = 0
    for i in range(n//2):
        small += A[i]
    big = s -small
    ans1 = 2*big -2*small + A[n//2-1]-A[n//2]
    small += A[n//2]
    big = s -small
    ans2 = 2*big-2*small+A[n//2]-A[n//2+1]
    print(max(ans1,ans2))
A,B = map(intinput().split())

if A % 3 == 0 or B % 3 == 0 or (A + B)  % 3 == 0:
  print("Possible")
else:
  print("Impossible")
  

### FIXED CODE ###

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

if A % 3 == 0 or B % 3 == 0 or (A + B)  % 3 == 0:
    print("Possible")
else:
    print("Impossible")
import numpy as np
N,D = list(map(int,input().split()))
 
lis =[list(map(int,input().split())) for i in range(N)]
lis_np = np.array(lis)
counter = 0
for i in range(N-1):
    for j in range(i+1,N):
        kyori = (sum((lis_np[:][i] - lis_np[:][j])**2))**0.5
        if kyori == int(kyori):
            counter += 1
        
print(counter)


### FIXED CODE ###

import numpy as np
N,D = list(map(int,input().split()))
 
lis =[list(map(int,input().split())) for i in range(N)]
lis_np = np.array(lis)
counter = 0
for i in range(N-1):
    for j in range(i+1,N):
        kyori = (sum((lis_np[:][i] - lis_np[:][j])**2))**0.5
        if kyori == int(kyori):
            counter += 1
        
print(counter)
N, M, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
B = [int(x) for x in input().strip().split()]
i = j = 0
ct = 0
while k > 0: 
  if i < N: 
    if A[i] < B[j] and k-A[i] >= 0: 
      ct +=1
      k -= A[i]
      i += 1
      continue
  if j < M: 
    if k-B[j] >= 0: 
      ct +=1
      k -= B[j]
      j +=1
    else: 
      break
  else: 
    break
print(ct)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a, b = [0], [0]
for i in range(N):
	a.append(a[i]+A[i])
for i in range(M):
	b.append(b[i]+B[i])
	
ans, j = 0, M
for i in range(N+1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i+j)
	
print(ans)