Harryxun/stf_run huggingface dataset:
a=int(inout())
b=int(inout())
c=int(inout())
d=int(inout())
e=int(inout())
k=int(inout())

v=b-a
w=c-b
x=d-c
y=e-d

z=max(max(v,w),max(x,y))

if z >k:
  print(':')
else:
  print('Yay!')


### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

v=e-a

if v <=k:
  print('Yay!')
else:
  print(':(')
s = input()
t = input()

sset = set(s)
tset = set(t)
slist = list()
tlist = list()

if len(sset) != len(tset):
   print("No")
else:
   for i in range(len(s)):
      smoji = s[i]
      if s[i] in slist:
         continue
      else:
         s.replace(s[i], i)
   for i in range(len(t)):
      tmoji = t[i]
      if t[i] in tlist:
         continue
      else:
         t.replace(t[i], i)
   if s != t:
      print("No")
   else:
      print("Yes")



### FIXED CODE ###

S = input()
T = input()

i = 0
j = 0
ss = list()
tt = list()
slist = list()
tlist = list()

if len(S) == len(T):
   for s in S:
      if s in slist:
         ss.append(slist.index(s))
      else:
         ss.append(i)
         slist.append(s)
         i += 1

   for t in T:
      if t in tlist:
         tt.append(tlist.index(t))
      else:
         tt.append(j)
         tlist.append(t)
         j += 1

   if ss == tt:
      print("Yes")
   else:
      print("No")
else:
   print("No")
N = int(input)

ans = 0

for i in range(100):
    for j in range(100):
        if (i*4) + (y*7) == N:
            ans = ans+1
            

if ans==0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n=int(input())
for i in range(100):
    for j in range(100):
        if 4*i+7*j==n:
            print("Yes")
            exit(0)
print("No")
import math
N,K = map(int, input().split())
a = list(map(int,input().split()))
l = 0
r = K - 1
Min = float("inf")
for i in range(N - K + 1):
    if(a[l]*a[r]<=0):#原点を跨ぐとき
        Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    elif(l==0):#左端の時
        if(a[r]*a[r+1]<0 or a[0]>0):
            Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    elif(r==N-1):#右端の時
        if(a[l-1]*a[l]<0 or a[l]>0):
            Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    else:
        if(a[r]*a[r+1]<0 or a[l-1]*a[l]<0):
            Min = min(Min,abs(a[l])+abs(a[l]-a[r]),abs(a[r])+abs(a[r]-a[l]))
    l = l + 1
    r = r + 1
print(Min)


### FIXED CODE ###

y = input().split()
print(int(y[0])-int(y[1])+1)
n = int(input())
a = list(map(int, input().split()))

res = []
s = 0
for i in enumerate(range(n)):
    s += a[i] * [-1, 1][i % 2 ==0]
res.append(s)

for i in range(1, n):
    res.append(a[i] - 2*res[i-1])

print(' '.join(map(str, res)))


### FIXED CODE ###

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

res = []
s = 0
for i in range(n):
    s += a[i] * [-1, 1][i % 2 ==0]
res.append(s)

for i in range(1, n):
    res.append(2*a[i-1] - res[i-1])

print(' '.join(map(str, res)))
s = input()
t = set()
for i in range(len(s)):
  t.add(s[i])
o = list(t)
o.sort()
u = 'qwertyuiopasdfghjklzxcvbnm'
v = []
for i in range(len(u)):
  v.append(u[i])
v.sort()
now = 0
if len(o) == 26:
  print('None')
else:
  for i in range(26):
    if o[i] == v[i]:
      now += 1
    else:
      print(v[now])
      break

### FIXED CODE ###

s = input()
t = set()
for i in range(len(s)):
  t.add(s[i])
o = list(t)
o.sort()
u = 'qwertyuiopasdfghjklzxcvbnm'
v = []
for i in range(len(u)):
  v.append(u[i])
v.sort()
now = 0
if len(o) == 26:
  print('None')
else:
  for i in range(26):
    if i >= len(t):
      print(v[i])
      break
    elif o[i] == v[i]:
      now += 1
    else:
      print(v[now])
      break
s = input()
num_x = s.count('x')
s_remove_x = s.replace('x', '', num_x)

if len(s) % 2 == 1:
  if s[(len(s) + 1) // 2] == 'x':
    ans = num_x - 1
else:
  ans = num_x

# s から x を除いたものが回文になっているか判定
half_len = len(s_remove_x) // 2
for i in range(half_len):
  if s_remove_x[i] != s_remove_x[len(s_remove_x)-1-i]:
    ans = -1

print(ans)


### FIXED CODE ###

S = input()
cnt = 0
l = 0
r = len(S)-1
while(l<r):
    if(S[l]==S[r]):
        l+=1
        r-=1
    elif(S[l]=='x'):
        cnt += 1
        l+=1
    elif(S[r]=='x'):
        cnt += 1
        r-=1
    else:
        print(-1)
        break
else:
    print(cnt)
n=int(input())
print(n*(n-1)//2)

### FIXED CODE ###

print(sum(s == t for s, t in zip(input(), input())))
a, b = map(input().split())
if a == b == H:
  print("H")
elif a == D and b == H:
  print("D")
elif a == H and b == D:
  print("H")
else:
  print("H")

### FIXED CODE ###

a, b = input().split()
print("H" if a==b else "D")
N = int(input())
A = []
B = []
for n in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
print(max(A) + min(B))

### FIXED CODE ###

S = [int(n) for n in list(input())]
print(sum(S))
import math

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

g = math.gcd(A, B)

def prime_decompose(x):
    decomposed = []
    for i in range(2,int(pow(x,0.5))+1):
        while x % i == 0:
            x //= i
            decomposed.append(i)
    if x > 1:
        decomposed.append(x)
    return decomposed

g_dec = set(prime_decompose(g))
print(len(g_dec)+1)

### FIXED CODE ###

import fractions

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

g = fractions.gcd(A, B)
d = []
p = []

for i in range(1,int(pow(g, 0.5))+1):
    if g % i == 0:
        d.append(i)
        if i != g//i:
           d.append(g//i)

for i in d:
    s = 0
    for j in range(1,int(pow(i, 0.5))+1):
        if i % j == 0:
            s += 1

    if s == 1:
        p.append(i)

print(len(p))
import numpy as np
 
N =int(input())
 
a = np.array([int(i) for i in input().split()])
 
a_min = min(a)
a_max =max(a)
ans = 0
 
for i in range(a_min,a_max+1):
    diff_a = a - i
    dummy = int(sum([i**2 for i in diff_a]))
    if i == a_min:
        ans = dummy
    elif i>a_min:
        if ans > dummy:
            ans = dummy
 
print(ans)

### FIXED CODE ###

n = int(input())
sum = 0
for i in range(n+1):
    sum = sum + i
    
print(sum)
A,B,C = list(map(int, input().split()))
if sum(A,B,C) >= 22:
    print("bust")
else:
    print("win ")

### FIXED CODE ###

A = list(map(int, input().split()))
if sum(A) >= 22:
    print("bust")
else:
    print("win ")
a,b,c=map(input().split())
if("YES" if a[len(a)-1]==b[0] and b[len(b)-1]==c[0] else "NO")


### FIXED CODE ###

a=input().split()
print("YES" if a[0][len(a[0])-1]==a[1][0] and a[1][len(a[1])-1]==a[2][0] else "NO")
N = int(input())
mod = 10 **9 + 7

def equal(item0, item1, delta = 10 ** (-18)):
    if abs(item0 - item1) < delta:
        return True
    else:
        return False
def bigger(item0, item1, delta = 10** (-18)):
    if item0 -item1 > delta:
        return True
    else:
        return False
bitlist = [1]
for k in range(N):
    bitlist.append(bitlist[-1]*2%mod)


liABplus = []
liBAplus = []
zero = 0
from bisect import insort
for _ in range(N):
    A, B = map(int, input().split())
    if A*B == 0:
        if A == 0 and B == 0:
            zero += 1
        elif A == 0 and B != 0:
            liABplus.leftappend(0)
        else:
            liBAplus.leftappend(0)
    elif A*B > 0:
        insort(liABplus, A/B)
    else:
        insort(liBAplus, -B/A)
def make_count(list):
    k = 0
    lis = []
    while k < len(list):
        cnt = 1
        while k+1 < len(list):
            if equal(list[k], list[k+1]):
                cnt += 1
                k += 1
                continue
            else:
                break
        lis.append([list[k], cnt])
        k += 1
    return lis

liABplus = make_count(liABplus)
liBAplus = make_count(liBAplus)
N -= zero
from collections import deque
liABplus = deque(liABplus)
liBAplus = deque(liBAplus)
ans = bitlist[N]-1 #all pattern
flag = True
eqpair = []
while liABplus and liBAplus:
    if flag:
        AB = liABplus.popleft()
        BA = liBAplus.popleft()
    if equal(AB[0], BA[0]):
        eqpair.append([AB[1], BA[1]])
        if liABplus and liBAplus:
            flag = True
            continue
        else:
            break
    elif bigger(AB[0], BA[0]):
        if liBAplus:
            BA = liBAplus.popleft()
            flag = False
            continue
        else:
            break
    else:
        if liABplus:
            AB = liABplus.popleft()
            flag = False
            continue
        else:
            break

minus = 0
from itertools import combinations
for k in range(1, len(eqpair)+1):
    for item in combinations(eqpair, k):
        sgn = (-1)**k
        ideal = 1
        cnt = 0
        for i in item:
            cnt += i[0] + i[1]
            ideal *= bitlist[i[0]]-1
            ideal %= mod
            ideal *= bitlist[i[1]]-1
            ideal %= mod
        ideal *= bitlist[N-cnt]
        ideal %= mod
        ans += sgn*ideal
        ans %= mod
print(ans)



### FIXED CODE ###

from collections import defaultdict
from math import gcd
N = int(input())
MOD = 10**9 + 7
L = defaultdict(lambda: [0,0])
zero = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A==0: d=B
    elif B==0: d=A
    else: d=gcd(A,B)
    if d != 0:
        A, B = A//d, B//d
        if A<0: A, B = -A, -B
        if B>0: L[(A,B)][0] += 1
        else: L[(-B,A)][1] += 1
    else: zero += 1

res = 1

for x,y in L.values():
    res *= pow(2,x,MOD) + pow(2,y,MOD) -1
    res %= MOD
print((res+zero-1)%MOD)
H, N  = map(int, input().split())
a = input()

s = 0
for ai in a:
    a = int(ai)
    s += a

if H > s:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

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

s = 0
for i in a:
    s += i

if H > s:
    print("No")
else:
    print("Yes")
n = int(input())
h = list(map(int, input().split()))
ans = []
res = 0
nh = h[0]
for i in range(1, n):
    if nh >= h[i]:
        res += 1
        nh = h[i]
    else:
        res = 0
        nh = h[i]
    ans.append(res)
print(max(ans))

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
ans = []
res = 0
nh = h[0]
for i in range(1, n):
    if nh >= h[i]:
        res += 1
        nh = h[i]
    else:
        ans.append(res)
        res = 0
        nh = h[i]
ans.append(res)
print(max(ans))
import math

def comb(n, r):
  return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))

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

for i in range(1, min(n-k+2, k+1)):
  ans = comb(n-k+1, i) * comb(k-1, i-1)
  ans %= mod
  print(int(ans))

### FIXED CODE ###

import math
from operator import mul
from functools import reduce

def comb(n, r):
  r = min(r, n-r)
  if r==0: return 1
  over = reduce(mul, range(n, n-r, -1))
  under = reduce(mul, range(1, r+1))
  return over//under

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

for i in range(1, k+1):
  if i <= n-k+1:
    ans = comb(n-k+1, i) * comb(k-1, i-1)
    ans %= mod
  else:
    ans = 0
  print(ans)
a=variable
b=variable_2
a=9
b=9
if a*b=81 then;
	print("81")
else;
	print("-1")

### FIXED CODE ###

def main(a, b):
    if a>9:
        return -1
    if b>9:
        return -1
        
    return a*b

inp = input().split();
a = int(inp[0])
b = int(inp[1])
print(main(a,b))
n, x = map(int, input().split())
l = int(input().split())

count = 0
sum = 0

while sum <= x:
  sum += l[count]
  count+=1
print(count + 1)

### FIXED CODE ###

n, x = map(int, input().split())
l = list(map(int, input().split()))

count = 0
sum = 0

for i in range(len(l)):
  sum += l[i]
  if sum <= x:
    count+=1
print(count + 1)
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print((N - 2) * (M - 2))


#A = [[0] * W for i in range(H)]
#C = ["o" * W for i in range(H)] 
#C = ["#"*(W+2)] + ["#"+C[i]+"#" for i in range(H)] + ["#"*(W+2)]
#dx = [1, 1, 0, -1, -1, -1, 0, 1]
#dy = [0, 1, 1, 1, 0, -1, -1, -1]
#
#for h in range(H):
#    for w in range(W):
#        for i in range(8):
#            if C[h+1+dx[i]][w+1+dy[i]] == "o":
#                A[h][w] += 1
#ans = 0
#for h in range(H):
#    for w in range(W):
#        if A[h][w] % 2 == 0:
#            ans += 1
#
#print(ans)


### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
a = int(n ** (1/2))
ans = 0

while a * (a + 1) // 2 < n:
    #print(a)
    a += 1

print(a)
(d, g), *s = [list(map(int, i.split())) for i in open(0)]
s = [[i[0] * -~n * 100 + i[1], i[0]] for n, i in enumerate(s)]
a = 10**9
for b in range(1 << d):
    su = sum(s[i] * (b >> i & 1) for i in range(d))
    n = sum(s[i][1] * (b >> i & 1) for i in range(d))
    if su <= g:
        m = d-bin(b)[2:].zfill(d).find("0")
        e =-~(g-su)//(m*100)
        if e < s[m-1][1]:
            a = min(a,n + e)
    if su > g:
        a = min(a,n)
print(a)

### FIXED CODE ###

(d, g), *s = [list(map(int, i.split())) for i in open(0)]
def c(i,t,l):
    if i==d:
        if t>=g:
            return sum(l)
        else:
            m=d-l[::-1].index(0)
            e = (t - g) // (m * 100)
            if -e < s[m-1][0]:
                return sum(l)-e
            else:
                return 10**3
    return min(c(i+1,t,l+[0]),c(i+1,t+s[i][0]*-~i*100+s[i][1],l+[s[i][0]]))
print(c(0,0,[]))
N=int(input())
A=[int(x) for x in input().strip().split(" ")]
x=1
c=pow(10,18)
for i in range(N):
    if x<c or x!=0:
        x *=A[i]
    
if x>pow(10,18):
    print("-1")
else:
    print(x)

### FIXED CODE ###

a,b=[float(x) for x in input().strip().split(" ")]
x=a*(b*100)/100
print(int(x))
N, K=map(int, input().split())
D=list(map(int, input().split()))
limit=min(N, K)
ans=0
for A in range(limit+1):
  for B in range(limit-A+1):
    jewels=D[:A]+D[-B:] if B>0 else D[:A]
    jewels.sort()
    for k in range(min(len(jewels)-1, K-(A+B))):
      if jewels[k]>=0:
        break
      jewels.pop(0)
    ans=max(ans, sum(jewels))
print(ans)

### FIXED CODE ###

import heapq
from collections import deque

N, K=map(int, input().split())
V=list(map(int, input().split()))
limitAB=min(N, K)
ans=0
for num in range(limitAB+1):
  for A in range(num+1):
    B=num-A
    d=deque(V)
    h=[]
    while d and len(h)<A:
      heapq.heappush(h, d.popleft())
    while d and len(h)<A+B:
      heapq.heappush(h, d.pop())
    cnt=0
    while h and h[0]<0 and cnt<K-(A+B):
      heapq.heappop(h)
      cnt+=1
    ans=max(ans, sum(h))
print(ans)
def check(x, y, flag):
	farm[x][y] = "$"
	if farm[x + 1][y] == flag : check(x + 1, y, flag)
	if farm[x - 1][y] == flag : check(x - 1, y, flag)
	if farm[x][y + 1] == flag : check(x, y + 1, flag)
	if farm[x][y - 1] == flag : check(x, y - 1, flag)

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	farm = []
	farm.append(list("$" * (w + 2)))
	for i in range(0, h):
		farm.append(list("$" + raw_input() + "$"))
	farm.append(list("$" * (w + 2)))
	
	count = 0
	for i in range(0, h):
		for j in range(0, w):
			if farm[i + 1][j + 1] != "$":
				check(i + 1, j + 1, farm[i + 1][j + 1])
				count += 1
				
	print count

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def check(x, y, flag):
	farm[x][y] = "$"
	if farm[x + 1][y] == flag : check(x + 1, y, flag)
	if farm[x - 1][y] == flag : check(x - 1, y, flag)
	if farm[x][y + 1] == flag : check(x, y + 1, flag)
	if farm[x][y - 1] == flag : check(x, y - 1, flag)
	return 1

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	farm = []
	farm.append(list("$" * (w + 2)))
	for i in range(0, h):
		farm.append(list("$" + raw_input() + "$"))
	farm.append(list("$" * (w + 2)))
	
	count = 0
	for i in range(0, h):
		for j in range(0, w):
			if farm[i + 1][j + 1] != "$":
				count += check(i + 1, j + 1, farm[i + 1][j + 1])
				
	print count
N, D = map(int, input().split())
a = N / (2 * D + 1)
if N % (2 * D + 1) == 0:
    print(int(a))
else:
    print(int(a) + 1)


### FIXED CODE ###

r = int(input())
print(3 * r ** 2)
a=input()
print(a+a**2+a**3)

### FIXED CODE ###

a=int(input())
print(int(a+a**2+a**3))
N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

import itertools

for cxi, cyi in itertools.product(range(101), range(101)):
    counter = 0
    for x, y, h in params:
        hight = h + abs(x - cxi) + abs(y - cyi)
        if counter == 0:
            hight_ = hight
        counter += 1

        if hight < 1:
            break
        else:
            if hight != hight_:
                break
            else:
                hight_ = hight

    else:
        Cx = cxi
        Cy = cyi
        H = hight
    continue

print(Cx, Cy, H)

### FIXED CODE ###

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi in range(101):
    for cyi in range(101):
        for k in range(N):
            if params[k][2] > 0:
                hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

        for k in range(N):
            if params[k][2] != max((hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi)), 0):
                break
        
        else:
            print(cxi, cyi, hight)
A,B,C=map(int,input().split())
print(min(S,B,C)*(A+B+C-max(A,B,C)-min(A,B,C))//2)

### FIXED CODE ###

A, B, C = map(int, input().split())
print(min(A, B, C)*(A+B+C-max(A, B, C)-min(A, B, C))//2)
from collections import deque

R=lambda: map(int, input().split())

n, m = R()
g = [[] for _ in range(n)]
for _ in range(m):
  u, v = R()
  g[u - 1].append(v - 1)
  g[v - 1].append(u - 1)

r = 'Yes' + [None] * (n - 1)
V = [True] + [False] * (n - 1)
q = deque([0])
while q:
  u = q.popleft()
  for v in g[u]:
    if not V[v]:
      V[v] = True
      r[v] = u + 1
      q.append(v)

print(*(['No'], r)[all(r)], sep='\n')


### FIXED CODE ###

from collections import deque

R=lambda: map(int, input().split())

n, m = R()
g = [[] for _ in range(n)]
for _ in range(m):
  u, v = R()
  g[u - 1].append(v - 1)
  g[v - 1].append(u - 1)

r = [None] * (n - 1)
V = [True] + [False] * (n - 1)
q = deque([0])
while q:
  u = q.popleft()
  for v in g[u]:
    if not V[v]:
      V[v] = True
      r[v - 1] = u + 1
      q.append(v)

print(*(['No'],['Yes'] + r)[all(r)], sep='\n')
def main():
    n = int(input())
    res = 0

    for (a, k) in [[int(x) for x in input().split()] for _ in range(n)]:
        while a >= k:
            m, u = a // k, (a - k * m)
            if a % k == 0 or (a % k) % (m + 1) == 0:
                res ^= m
                break
            x = u // (m + 1)
            a -= (x + 1) * (m + 1)

    print('Takahashi' if res != 0 else 'Aoki')


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    res = 0
    for (a, k) in [map(int, input().split()) for _ in range(n)]:
        while a >= k:
            m = a // k
            if a % k == 0:
                res ^= m
                break
            x = (a - k * m - 1) // (m + 1)
            a -= max(1, x) * (m + 1)
    print('Takahashi' if res != 0 else 'Aoki')


if __name__ == '__main__':
    main()
"""import sys
input = sys.stdin.readline"""
n=int(input())
cntm=0
for i in range(1,n+1):
    a=i
    cnt=0
    while a%2==0:
        a//=2
        cnt+=1
    if cntm<cnt:
        ans=i
        cntm=cnt
print(ans)


### FIXED CODE ###


n=int(input())
cntm=0
ans=1
for i in range(1,n+1):
    a=i
    cnt=0
    while a%2==0:
        a//=2
        cnt+=1
    if cntm<cnt:
        ans=i
        cntm=cnt
print(ans)
N = int(input())
alpha = "abcdefghijklmnopqrstuvwxyz"
output = ""
while N >= 26:
    mod = N % 26
    N = N / 26
    output = alpha[mod-1] + output
output = alpha[N-1] + output
print(output)

### FIXED CODE ###

N = input()
if N.islower():
    print("a")
else:
    print("A")
import sys
from bisect import bisect, bisect_left
import heapq

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    S = [0] * (N + 1)
    for i, a in enumerate(A): S[i + 1] = a + S[i]
 
    l, h = 1, A[N-1] * 2 + 1
    while h - l > 1: #最小値がｍ以上の要素をM個用意できるか
        m = (h + l) // 2
        count = 0
        for i, a in enumerate(A): count += N - bisect_left(A, m - a)
        if count >= M: l = m
        else: h = m

    total = 0
    count = 0 
    Q = []
    heapq.heapify(Q)
    #print(A)
    for i, a in enumerate(A):
        j = bisect_left(A, l - a)
        total += a * (N - j) + (S[N] - S[j])
        count += (N - j)
        for k in range(min(3, N - j)):
            heapq.heappush(Q, a + A[j + k])
        #print(a, j)

    if count > M:
        for _ in range(count - M):
            minus = heapq.heappop(Q)
            total -= minus

    print(total)

    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys
from bisect import bisect, bisect_left
import heapq

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    S = [0] * (N + 1)
    for i, a in enumerate(A): S[i + 1] = a + S[i]
 
    l, h = 1, A[N-1] * 2 + 1
    while h - l > 1: #最小値がｍ以上の要素をM個用意できるか
        m = (h + l) // 2
        count = 0
        for i, a in enumerate(A): count += N - bisect_left(A, m - a)
        if count >= M: 
            l = m
        else: h = m

    total = 0
    count = 0
    Q = []
    heapq.heapify(Q)
    min_out = 10000000
    for i, a in enumerate(A):
        j = bisect_left(A, l - a)  
        total += a * (N - j) + (S[N] - S[j])
        count += N - j
        if 0 <= j < N: min_out = min(min_out, a + A[j])

    if count > M:
        total -= min_out * (count - M)

    print(total)

    return 0

if __name__ == "__main__":
    solve()
import numpy as np
n = int(input())
a = np.arange(1, n + 1)
b = np.hstack((np.arange(2, n + 1), 1))
print(np.sum(a % b))

### FIXED CODE ###

n = int(input())
ans = n * (n - 1) // 2
print(ans)
a , b = (int(i) for i in input().split())
if a <= b :
    print('{}'.format(a)
else :
    print('{}'.format(a-1))
    
    

### FIXED CODE ###

a , b = (int(i) for i in input().split())
if a <= b :
    print('{}'.format(a))
else:
    print('{}'.format(a-1))
a = input()
a + a **2 + a ** 3 = A
print(A)


### FIXED CODE ###

a = int(input())
print(a + a**2 + a**3)
import math
A,B = (int(i) for i in input().split())
g = math.gcd(A,B)
print(A*B/g)


### FIXED CODE ###

A,B = (int(i) for i in input().split())
def gcd(a,b):
    if a % b == 0:
        return b
    else:
        r = a% b
        return gcd(b,r)
print(A*B//gcd(A,B))