Harryxun/stf_run huggingface dataset:
N, A, B = map(int, input().split())
2 ans = N // (A + B) * A
3 rem = N % (A + B)
4 ans += min(rem, A)
5 print(ans)


### FIXED CODE ###

N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
N = int(input())
l = list(input())
h = []
for i, s in enumerate(l):
    if i + 1 == N:
        h.append(s)
        print(len(h))
    if s != l[i + 1]:
        h.append(s)

### FIXED CODE ###

length = int(input())
li = list(input())
i = 0
for n in li[:]:
    if i + 1 == len(li):
        print(len(li))
        break
    if li[i] == li[i + 1]:
       del (li[i + 1])
    else:
        i = 1 + i
        continue
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)
 
for s in range(n,0,-1):
    i=s
    t=0
    while i<=n:
        t += b[i]
        i += s
    if a[s]!=t%2:
        b[s]=1
print(b.count(1))
for i in range(n+1):
    if b[i+1]==1:
        print(i+1)

### FIXED CODE ###

n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)
 
for s in range(n,0,-1):
    i=s
    t=0
    while i<=n:
        t += b[i]
        i += s
    if a[s]!=t%2:
        b[s]=1
print(b.count(1))
for i in range(1,n+1):
    if b[i]==1:
        print(i)
N = int(input())
X = list(map(int, input().split()))
A = [-1]*N*N
sorted_X = sorted(X)
fail_flag = 0
for i in range(N):
	x = sorted_X[i]
	K = X.index(x)+1
	if A[x-1]==-1:
		A[x-1] = K
	else:
		print("No")
		fail_flag = 1
		break
	K_rest = K-1
	j = 0
	while K_rest>0:
		if j==x-1:
			print("No")
			fail_flag = 1
			break
		if A[j]==-1:
			A[j] = K
			K_rest = K_rest-1
		j = j+1

count = 0
num = 1
for i in range(N*N):
	if A[i]==-1:
		A[i] = num
		count = count+1
	if count==N-num:
		num = num+1
		count = 0

if fail_flag==0:
	print("Yes")
	for a in A:
		print(str(a), end=" ")



### FIXED CODE ###

x, y = map(int, input().split())
if x==0 and y==0:
	print(0)
elif x>=0 and y==0:
	print(x+1)
elif x>=0 and y>=0:
	if x<=y:
		print(y-x)
	if x>y:
		print(x-y+2)
elif x>=0 and y<0:
	print(abs(x+y)+1)
elif x<0 and y==0:
	print(abs(x))
elif x<0 and y>=0:
	print(abs(x+y)+1)
elif x<0 and y<0:
	if x<=y:
		print(y-x)
	if x>y:
		print(x-y+2)
chars = input.split(" ")
print(chars[1]+chars[0])

### FIXED CODE ###

chars = input().split(" ")
print(chars[1]+chars[0])
n = int(input())
s = input()
x = int(s, 2)
p = s.count("1")
pre0, pre1 = x%(p-1), x%(p+1)

nxt = [i for i in range(n+1)]
for i in range(1, n):
	nxt[i] %= bin(i).count("1")

for i in range(n):
	if x == 1<<(n-1-i):
		print(0)
		continue
	if s[i] == "0":
		tmp = (pre1 + pow(2, n-1-i, p+1)) % (p+1)
	else:
		tmp = (pre0 + pow(2, n-1-i, p-1)) % (p-1)
	ans = 1
	while tmp > 0:
		ans += 1
		tmp = nxt[tmp]
	print(ans)

### FIXED CODE ###

n = int(input())
s = input()
x = int(s, 2)
p = s.count("1")
if p > 1:
	pre0 = x%(p-1)
pre1 = x%(p+1)

nxt = [i for i in range(n+10)]
for i in range(1, n+10):
	nxt[i] %= bin(i).count("1")

for i in range(n):
	if x == 1<<(n-1-i):
		print(0)
		continue
	if s[i] == "0":
		tmp = (pre1 + pow(2, n-1-i, p+1)) % (p+1)
	else:
		tmp = (pre0 - pow(2, n-1-i, p-1)) % (p-1)
	ans = 1
	while tmp > 0:
		ans += 1
		tmp = nxt[tmp]
	print(ans)
xyzk_, a_, b_, c_ = [input() for _ in range(4)]

x, y, z, k = [int(w) for w in xyzk_.split()]
a_nums = [int(n) for n in a_.split()]
b_nums = [int(n) for n in b_.split()]
c_nums = [int(n) for n in c_.split()]

a_nums.sort(reverse=True)
b_nums.sort(reverse=True)
c_nums.sort(reverse=True)

p, q, r = 0, 0, 0
now = a_nums[p] + b_nums[q] + c_nums[r]

while (p + 1) * (q + 1) * (r + 1) < k:
    pp = a_nums[p + 1] + b_nums[q] + c_nums[r]
    qq = a_nums[p] + b_nums[q + 1] + c_nums[r]
    rr = a_nums[p] + b_nums[q] + c_nums[r + 1]
    if pp >= max(qq, rr):
        p += 1
    elif qq >= rr:
        q += 1
    else:
        r += 1

a_nums = a_nums[:p + 1]
b_nums = b_nums[:q + 1]
c_nums = c_nums[:r + 1]
sums = []
for a in a_nums:
    for b in b_nums:
        for c in c_nums:
            sums.append(a + b + c)

sums.sort(reverse=True)

for n in sums[:k]:
    print(n)


### FIXED CODE ###

xyzk_, *nums_ = [input() for _ in range(4)]

*le, k = [int(w) for w in xyzk_.split()]
abc = [sorted((int(n) for n in w.split()), reverse=True) for w in nums_]

p = [0, 0, 0]
pool = [0, sum(abc[i][p[0]] for i in range(3))]
for _ in range(k):
    max_pool = max(pool)
    max_t = 0
    for i in range(3):
        if p[i] + 1 == le[i]:
            continue
        t = abc[i][p[i] + 1] + abc[(i + 1) % 3][0] + abc[(i + 2) % 3][0]
        if t > max_t:
            max_t = t
            max_3 = i
    if max_pool < max_t:
        p[max_3] = min(p[max_3] + 1, le[max_3] - 1)
        j, k = (max_3 + 1) % 3, (max_3 + 2) % 3
        for n1 in abc[j][:p[j] + 1]:
            for n2 in abc[k][:p[k] + 1]:
                pool.append(n1 + n2 + abc[max_3][p[max_3]])
    print(pool.pop(pool.index(max(pool))))
N,M,X,Y = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = max(A)
b = min(B)

flag = a>0 and b>0
if flag and a-b <= 0 and (Y < a and b <= X) and a<b:
  print('No War')
elif not flag and a-b >= 0 and (Y > a and b => X) and a>b:
  print('No War')
else:
  ('War')

### FIXED CODE ###

N,M,X,Y = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
x = max(X,max(A))
y = min(Y,min(B))
 
if Y >= x and y > X and y > x:
  print('No War')
else:
  print('War')
s = list(input())
n = len(s)
#s_cu = [] 
counter = [0] * 2019

counter[0] += 1
temp=""
for i in range(1, n+1):
    c=s.pop()
    temp = c + (temp if i != 1 else "")
    #s_cu.append(temp)
    counter[int(temp) % 2019] += 1

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

print(ans)

### FIXED CODE ###

#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,M=pin()
    cond=M<N
    print(["unsafe","safe"][cond])
#%%submit!
resolve()
import math

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

mod = 10**9+7

primes = [0]*(10**3+1)

def prime_fac(n):
  temp = n
  Flag = True
  for i in range(2, int(math.sqrt(n)) + 1):
    if temp % i == 0:
      cnt = 0
      while temp % i == 0:
        cnt += 1
        temp //= i
      primes[i] = max(primes[i], cnt)
      Flag = False
  if temp != 1:
    primes[temp] = max(primes[temp], 1)
  if Flag:
    primes[n] = max(primes[n], 1)

for a in A:
  prime_fac(a)

LCM = 1
for p, i in enumerate(primes):
  if p:
    LCM *= pow(p, i, mod)
    LCM %= mod

ans = 0
for a in A:
  ans += LCM * pow(a, mod-2, mod) % mod
  ans %= mod

print(ans)

### FIXED CODE ###

import math

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

mod = 10**9+7

def lcm(x, y):
  return (x // math.gcd(x, y)) * y

LCM = A[0]
for i in range(N-1):
  LCM = lcm(LCM, A[i+1])

LCM %= mod

ans = 0
for a in A:
  ans += LCM * pow(a, mod-2, mod) % mod
  ans %= mod

print(ans)
N = int(input())
D = list(map(int, input().split()))

d={}
for i in D:
    d[i]=d.get(i,0)+1

s = 0
for l in range(1, max(D)):
    if l == 1: s = 1
    for i in range(d[l+1]):
        s *= d[l]

print(s)

### FIXED CODE ###

from collections import Counter

N = int(input())
D = list(map(int, input().split()))

L = sorted(set(D))
d = Counter(D)
s = 0

if (D[0] == 0) and (list(range(max(D) + 1)) == L):
    if (d[0]==1) and (1 in d):
        s = 1
        for l in L[1:-1]:
            for i in range(d[l + 1]):
                s *= d[l]
                s %= 998244353
print(s)
import math
n, x, y = map(int,input().split())
num = [0 for i in range(n)]

for i in range(n):
    for j in range(i+1,n):
        num[min([j-i,math.fabs(j-y)+1+math.fabs(i-x)])] += 1

for i in range(n):
    print(num[i])


### FIXED CODE ###

n, x, y = map(int,input().split())
num = [0 for i in range(n)]

for i in range(1,n+1):
    for j in range(i+1,n+1):
        ban = min([j-i,abs(x-i)+1+abs(y-j)])
        num[ban] += 1

for i in range(1,n):
    print(num[i])
for i in range(n):
    current_step = 0
    for j in range(i + 1, n):
        if h[j - 1] >= h[j]:
            current_step += 1
            if current_step > max_step:
                max_step = current_step
        else:
            i = j
            break
print(max_step)


### FIXED CODE ###

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

max_step = 0
current_step = 0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        current_step += 1
        if current_step > max_step:
            max_step = current_step
    else:
        current_step = 0
print(max_step)
import sys,gc

    
A=[]
n=int(raw_input())
while n:
    s = raw_input()
    if s[0] == 'i'
        A.insert(0,s[7:])
    elif s[6] == ' ':
        try:
            A.remove(s[7:])
        except:
            pass
    elif s[6] == 'F':
        A.pop(0)
    elif s[6] == 'L':
        A.pop()
    n -=1
    
for e in A:
    print int(e),

### FIXED CODE ###

import sys,gc
    
A=[]
fp =0
bp =0

n=int(raw_input())
while n:
    s = raw_input()
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1

for e in A[bp:fp+1][::-1]:
    print int(e),
import math
a,b = map(flaot,input().split())
print(math.floor(a*(100*b)/100))

### FIXED CODE ###

a,b = map(str,input().split())
a = int(a)
b = float(b)
 
b = round(b*100)
 
print(a*b//100)
n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 9 + 1
count = 0

def merge(S, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = S[left:mid] + [SENTINEL]
    R = S[mid:right] + [SENTINEL]
    for i in range(n1):
        L[i] = S[left + i]
    for i in range(n2):
        R[i] = S[mid + i]
    L[n1] = r[n2] = SENTINEL
    i = j = 0
    for k in range(left, right):
        count += 1
        if(L[i] <= R[i]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1

mergeSort(S, left, right):
    if(left + 1 < right):
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)

mergeSort(S, 0, n)
print(*S)
print(count)

### FIXED CODE ###

n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 9 + 1
count = 0
 
def merge(S, left, mid, right):
    L = S[left:mid] + [SENTINEL]
    R = S[mid:right] + [SENTINEL]
    i = j = 0
    global count
    for k in range(left, right):
        count += 1
        if (L[i] <= R[j]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1
 
def mergeSort(S, left, right):
    if(left + 1 < right):
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)
 
mergeSort(S, 0, n)
print(*S)
print(count)
if a*b%2==0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

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


if a*b % 2 == 0:
    print('Even')
else:
    print('Odd')
a,b=map(int,input().split())
c,d=map(int,input().split())
print([0,1][a==b+1]

### FIXED CODE ###

a,b=map(int,input().split())
c,d=map(int,input().split())
print([0,1][a==c-1])
def max(a,b):
  	if a>=b:
      	return a
    else:
      	return b

n,z,w = map(int,input().split())
a = list(map(int,input().split()))
print(max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]))

### FIXED CODE ###

def max(a,b):
	if a>=b:
		return a
	else:
		return b

n,z,w = map(int,input().split())
a = list(map(int,input().split()))
print(max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])))
s = input()
sr = set(s)
if s[i]==sr[i]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
def resolve():
    import statistics
    n = input()
    x = list(map(int, input().split()))
    m = round(statistics.mean(x))
    sum_val = 0
    for val in x:
        sum_val += (val - m) ** 2

    print(sum_val)

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

import numpy as np

def resolve():
    input()
    x = list(map(int, input().split()))
    m = int(round(np.mean(x)))
    sum = 0
    for val in x:
        sum += (val - m) ** 2
    print(sum)

if __name__ == '__main__':
    resolve()
g = [31,28,31,30,31,30,31,31,30,31,30,31]

tmp = input().split(" ")
print("Yes") if g[tmp[0]] == g[tmp[1]] else print("No")

### FIXED CODE ###

g = [31,28,31,30,31,30,31,31,30,31,30,31]
 
tmp = input().split(" ")
print("Yes") if g[int(tmp[0]) - 1] == g[int(tmp[1]) - 1] else print("No")
N = input(),strip()

if N[len(N)] in ['2', '4', '5', '7', '9']:
  print('hon')
elif N[len(N)] in ['0', '1', '6', '8']:
  print('pon')
elif N[len(N)] in ['3']:
  print('bon')

### FIXED CODE ###

N = input().strip()

if N[-1] in ['2', '4', '5', '7', '9']:
  print('hon')
elif N[-1] in ['0', '1', '6', '8']:
  print('pon')
elif N[-1] == '3':
  print('bon')
N = int(raw_input())
R = []
for i in range(N):
    R[i] = (int(raw_input()))

max = R[1] - R[0]
for i in range(N - 1):
    for j in range(i):
        dif = R[i+1] - R[j]
        if dif > max:
            max = dif

print max

### FIXED CODE ###

N = int(raw_input())
min = int(raw_input())
max = int(raw_input())
dif = max - min
if max < min:
    min = max

for i in range(N - 2):
    R = int(raw_input())
    if R - min > dif:
        dif = R - min
    if R < min:
        min = R

print dif
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    r = min(r,n-r)
    if r == 0:
        return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans

n,k = map(int,input().split())
for i in range(1,k+1):
    print(cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod) % mod)

### FIXED CODE ###

from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    r = min(r,n-r)
    if r == 0:
        return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans

n,k = map(int,input().split())
for i in range(1,k+1):
    if n-k+1  < i :
        print(0)
    else:
        print(cmb(n-k+1,i,mod)*cmb(k-1,i-1,mod) % mod)
def main():
  n = int(input())
  ks = sorted(list(map(int, input().split())))
  a, b = ks[n/2-1:n/2]
  if a == b:
    print(0)
  else:
    print(b-a)
  
  
if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
    n = int(input())
    ks = sorted(list(map(int, input().split())))
    a, b = ks[n//2-1:n//2+1]
    if a == b:
        print(0)
    else:
        print(b-a)


if __name__ == '__main__':
    main()
n = input()
ans = ""

for i in range(n):
    if n[i] == 1:
        ans += "9"
    else:
        ans += "1"
print(int(ans))


### FIXED CODE ###


n = input()
ans = ""

for i in range(len(n)):
    if n[i] == "1":
        ans += "9"
    else:
        ans += "1"
print(int(ans))
#!/usr/bin/env python3
# coding: utf-8
# Last Modified: 16/Nov/19 05:40:04 PM


import sys


def main():
    from math import factorial, sqrt
    from itertools import permutations

    n = int(input())
    arr = [get_array() for _ in range(n)]

    x = range(n)
    p = list(permutations(x))

    def dis(x1, y1, x2, y2):
        return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

    distance = 0
    for j in p:
        for i in range(1, len(j)):
            distance += dis(*arr[j[i]], *arr[j[i - 1]])
    print(distance / factorial(n))


get_array = lambda: list(map(int, sys.stdin.readline().split()))


get_ints = lambda: map(int, sys.stdin.readline().split())


input = lambda: sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# coding: utf-8
# Last Modified: 16/Nov/19 05:44:05 PM


import sys


def main():
    from math import factorial, sqrt
    from itertools import permutations

    n = int(input())
    arr = [get_array() for _ in range(n)]

    x = [i for i in range(n)]
    p = list(permutations(x))

    def dis(x1, y1, x2, y2):
        return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

    distance = 0
    for j in p:
        for i in range(1, len(j)):
            distance += dis(
                arr[j[i]][0], arr[j[i]][1], arr[j[i - 1]][0], arr[j[i - 1]][1]
            )
    print(distance / factorial(n))


get_array = lambda: list(map(int, sys.stdin.readline().split()))


get_ints = lambda: map(int, sys.stdin.readline().split())


input = lambda: sys.stdin.readline().strip()


if __name__ == "__main__":
    main()
import itertools as itl

n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

for mi in M:
    flg = False
    for i in range(n):
        C = itl.combinations(A, i+1)
        #print(C)
        for j in C:
            if sum(j) == mi:
                flg = True
                break
        if flg: break
    if flg: print("yes")
    else: print("no")


### FIXED CODE ###

import itertools as itl

n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
S = []

for i in range(n):
    cmb = list(itl.combinations(A, i+1))
    for j in cmb:
        S.append(sum(j))

for m in M:
    flg = False
    for s in S:
        if s == m:
            flg = True
            break
    if flg:
        print("yes")
    else:
        print("no")
n = int(input())
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    if (t < x + y) or (x + y + t) % 2==1:
        flag = False


if flag:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

n = int(input())
flag = True
for _ in range(n):
    t, x, y = map(int, input().split())
    if (t < x + y) or (x + y + t) % 2==1:
        flag = False


if flag:
    print("Yes")
else:
    print("No")
N = int(input())
pre = 1
luca = 3
if N == 2:
  print(4)
  break
elif N == 1:
  print(1)
  break
elif N == 0:
  print(2)
  break
else:
  for i in range(N - 2):
    temp = luca
    luca = pre + luca
    pre = temp
    
  print(luca)

### FIXED CODE ###

N = int(input())
memo = [0] * 87
def luca(n):

  if n == 0:
    return 2
  elif n == 1:
    return 1

  if not memo[n]:
    memo[n] = luca(n - 2) + luca(n - 1)
  return memo[n]

print(luca(N))
s=input() 
b="".join(list(reversed("zyxwvutsrqponmlkjihgfedcba")))
if s=="zyxwvutsrqponmlkjihgfedcba":
  print(-1)
  exit()
from collections import defaultdict 
if len(s)<26:
  d=defaultdict(int)
  for c in s:
    d[c]+=1
  for bb in b:
    if d[bb]==0:
      print(s+bb)
      exit() 
N=len(s)
for first in range(N-1,0,-1):
  mn=s[first]
  for i in range(first-1,-1, -1):
    if s[i]<mn:
      print(s[:i]+mn+s[i:first]+s[first+1])
      exit()
    


### FIXED CODE ###

s=input()
b="abcdefghijklmnopqrstuvwxyz"
from collections import defaultdict 
if len(s)<26:
  d=defaultdict(int)
  for c in s:
    d[c]+=1
  for bb in b:
    if d[bb]==0:
      print(s+bb)
      exit() 
N=len(s)
lst=[]
for first in range(N-1,0,-1):
  mn=s[first]
  for i in range(first-1,-1, -1):
    if s[i]<mn:
      lst.append(s[:i]+mn)
      #print(s[:i]+mn)
      #exit()
if lst:
  print(sorted(lst)[0])
  exit()
print(-1)
N,R=map(int,input().split())
if N>=10:
  return (R)
else:
  return (R+100*N)

### FIXED CODE ###

N,R=map(int,input().split())
if N>=10:
  print(R)
else:
  print(R+100*(10-N))
a = input()
a = list(a)
b = len(a)
c = b / 2
d = []
for i in range(0,c):
    d.append(a[i])
e = a[::-1]
f = []
for g in range(0,c):
    f.append(e[g])
answer = 0
for h in range(0,c):
    if d[h] != f[h]:
        answer += 1
print(answer)


### FIXED CODE ###

a = input()
a = list(a)
b = len(a)
c = int(b / 2)
d = []
for i in range(0,c):
    d.append(a[i])
e = a[::-1]
f = []
for g in range(0,c):
    f.append(e[g])
answer = 0
for h in range(0,c):
    if d[h] != f[h]:
        answer += 1
print(answer)
import sys

def f(x):
    p=0
    cnt=0
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<x:
            p+=1
        cnt+=n-p
    return cnt

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

l,r=a[0]*2,a[n-1]*2

while r-l>0:
    if r-l<=1:
        if f(r)==m: md=r;break 
        else: md=l;break
    md=(r+l)//2
    k=f(md)
    if k==m: break
    elif k>m: l=md
    else: r=md

p=0
cnt=0
ans=0

try:
    for i in range(n-1,-1,-1):
        while p<n and a[i]+a[p]<=md:
            p+=1
        if p==n: break
        cnt+=n-p
        ans+=a[i]*(n-p)*2
    


except:
    print(0)

ans+=(m-cnt)*md
print(ans)

### FIXED CODE ###

def f(i):
    return i
s,t=map(f,input().split())
print(t+s)
input =int(input())
l = []
for x in range(input):
  l.append(int(input()))
  
ans = int(sum(l) -max(l)/2)
print(ans)


### FIXED CODE ###

N = int(input())
p = []
for _ in range(N):
    p.append(int(input()))
 
pmax = max(p)
ans = int(sum(p)-pmax/2)
print(ans)
N, K, *A = map(int, open(0).read().split())

neg = sorted([-a for a in A if a < 0])
pos = sorted([a for a in A if a >= 0])

def _count_pair_neg(x):
    x = -x
    res = 0

    MAX = len(neg)
    i = 0
    for n in reversed(neg):
        while i < MAX and n * pos[i] < x:
            i += 1
            
        res += len(pos) - i
    return res


def _count_pair_pos(x):
    res = 0

    # Negative list
    i = 0
    MAX = len(neg)
    for n in reversed(neg):
        if n * n <= x:
            res -= 1
            
        while i < MAX and neg[i] * n <= x:
            i += 1
        res += i
        
    # Positive list
    i = 0
    MAX = len(pos)
    for n in reversed(pos):
        if n * n <= x:
            res -= 1
            
        while i < MAX and pos[i] * n <= x:
            i += 1
        res += i
        
    # Devide by 2 for counting the same pair twice
    res //= 2
    res += len(neg) * len(pos)
    return res


def count_pair(x):
    if x < 0:
        return _count_pair_neg(x)
    
    return _count_pair_pos(x)


# Bounds
lb = 0
ub = 2 * 10 ** 18 + 2

while ub - lb > 1:
    mid = (ub + lb) // 2
    if count_pair(mid - 10 ** 18 - 1) < K:
        lb = mid
    else:
        ub = mid

print(ub - 10 ** 18 - 1)


### FIXED CODE ###

N, K, *A = map(int, open(0).read().split())

neg = sorted([-a for a in A if a < 0])
pos = sorted([a for a in A if a >= 0])

def _count_pair_neg(x):
    x = -x
    res = 0

    MAX = len(pos)
    i = 0
    for n in reversed(neg):
        while i < MAX and n * pos[i] < x:
            i += 1
            
        res += MAX - i
    return res


def _count_pair_pos(x):
    res = 0

    # Negative list
    i = 0
    MAX = len(neg)
    for n in reversed(neg):
        if n * n <= x:
            res -= 1
            
        while i < MAX and neg[i] * n <= x:
            i += 1
        res += i
        
    # Positive list
    i = 0
    MAX = len(pos)
    for n in reversed(pos):
        if n * n <= x:
            res -= 1
            
        while i < MAX and pos[i] * n <= x:
            i += 1
        res += i
        
    # Devide by 2 for counting the same pair twice
    res //= 2
    res += len(neg) * len(pos)
    return res


def count_pair(x):
    if x < 0:
        return _count_pair_neg(x)
    
    return _count_pair_pos(x)


# Bounds
lb = 0
ub = 2 * 10 ** 18 + 2

while ub - lb > 1:
    mid = (ub + lb) // 2
    if count_pair(mid - 10 ** 18 - 1) < K:
        lb = mid
    else:
        ub = mid

print(ub - 10 ** 18 - 1)
n = input()
k = int(input())

if(k == 1):
    print(n[0])
elif(len(n)==1):
    print(n)
elif(n[0]== '1'):
    i = 1
    while(n[i] == '1'):
        i += 1
    if(k <= i):
        print(1)
    else:
        print(n[i])
else:
    print(n[0])

### FIXED CODE ###

n = input()
k = int(input())

if(k == 1):
    print(n[0])
elif(len(n)==1):
    print(n)
elif(n[0]== '1'):
    i = 1
    while(n[i] == '1'):
        i += 1
        if(i == len(n)):
            break
    if(k <= i):
        print(1)
    else:
        print(n[i])
else:
    print(n[0])
K,A,B = map(int,input().split())
if A <=B % K == 0:
	print("OK")
else:
    print("NG")


### FIXED CODE ###

K=int(input())
A,B=map(int,input().split())
ans="NG"

for i in range(1001):
  if A<=i*K and i*K<=B:
    ans="OK"
    break

print(ans)