Harryxun/stf_run huggingface dataset:
from functools import lru_cache

X, Y, A, B, C = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]
R = [int(x) for x in input().split()]

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

red = P[:X]
green = Q[:Y]
best = sum(red) + sum(green)

for x in R:
    a1, a2 = red, green
    if a1[-1] > a2[-1]:
        a1, a2 = a2, a1
    assert a1[-1] <= a2[-1]
    if a1[-1] < x:
        best -= a1.pop()
        best += x
print(best)


### FIXED CODE ###

from functools import lru_cache

X, Y, A, B, C = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]
R = [int(x) for x in input().split()]

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

red = P[:X]
green = Q[:Y]
best = sum(red) + sum(green)

for x in R:
    a1, a2 = red, green
    if not a1 and not a2:
        break
    if not a1:
        a1 = a2
    if a1 and a2 and a1[-1] > a2[-1]:
        a1, a2 = a2, a1
    if a1[-1] < x:
        best -= a1.pop()
        best += x
print(best)
import collections
import math

#****************************************************************
def comb(n):
    if n < 2:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
#****************************************************************

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

c = collections.Counter(A)
dict_ans = {i:0 for i in c.keys()}
full_ans = sum(list(map(comb, c.values())))

for i in c.keys():
    target = c.copy()
    target[i] -= 1
    if target[i] == 0:
        dict_ans[i] = full_ans
    else:
        dict_ans[i] = sum(list(map(comb, target.values())))

for i in A:
    print(dict_ans[i])


### FIXED CODE ###

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

ans = int((N + M) * (N + M - 1) / 2 - N * M)
print(ans)
def main():
    S = input()[::-1]
    ans = 0
    mods = [0] * 2019
    mods[0] = 1
    current = 0
    x = 1
    for s in S:
        current = (current + x * int(s)) % 2019
        mods[current % 2019] += 1
        x = x * 10 %2019
    
    for i in len(mods):
        ans += mods[i] * (mods[i]-1)//2
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    S = input()[::-1]
    ans = 0
    mods = [0] * 2019
    mods[0] = 1
    current = 0
    x = 1
    for s in S:
        current = (current + x * int(s)) % 2019
        ans += mods[current % 2019]
        mods[current % 2019] += 1
        x = x * 10 % 2019
    print(ans)

if __name__ == '__main__':
    main()
MOD = (10 ** 9) + 7

N = int(input())
s = list(input())

dp = [[0 for i in range(N + 1)] for j in range(N + 1)]


for i in range(N + 1):
	dp[i][i] = 1
for i in range(N):
	dp[i][i + 1] = 1

for n in range(1, N + 1):
	dp[n][0] = (dp[n - 1][0] + 2 * dp[n - 1][1]) % MOD
	for l in range(1, n):
		dp[n][l] = (dp[n - 1][l - 1] + 2 * dp[n - 1][l + 1]) % MOD

print(dp[N - 1][len(s)])

### FIXED CODE ###

MOD = (10 ** 9) + 7

N = int(input())
s = list(input())

dp = [[0] * (N + 2) for i in range(N + 1)]

for n in range(N + 1):
	for l in range(n + 1):
		if n == 1:
			dp[n][l] = 1
		elif l == 0:
			dp[n][l] = (dp[n - 1][0] + 2 * dp[n - 1][1]) % MOD
		else:
			dp[n][l] = (dp[n - 1][l - 1] + 2 * dp[n - 1][l + 1]) % MOD

print(dp[N][len(s)])
N = int(input())
A_list = list(map(int,input().split()))

iter_num_list = []
for a in A_list:
    count = 0
    while a%2 == 0:
        a = a/2
        count += 1
    iter_num_list.append(count)
ans = sorted(iter_num_list)[0]
print(ans)

### FIXED CODE ###

s = str(input())
s_list = [int(s[0]),int(s[1]),int(s[2])]
count = 0
for i in s_list:
    if i==1:
        count +=1
print(count)
N, A, B = map(int, input().split())

mojiretsu = ''
while len(mojiretsu) < N:
    mojiretsu += 'b' * A
    mojiretsu += 'r' * B

print(mojiretsu[:N].count('b'))

### FIXED CODE ###

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

if A == 0:
    print(0)
    exit()

quotient = N // (A + B) * A
remainder = N % (A + B)

quotient += min((remainder, A))

print(quotient)
N = int(input())

dic = dict()
dic[0] = 0
for i in range(1, N+1):
    a = bin(i)
    cnt = 0
    for j in range(2, len(a)):
        if a[j] == '1':
            cnt += 1
    b = i%cnt
    if i not in dic:
        dic[i] = b

y = input()
x = 0
for j in range(N):
    if y[j] == '1':
        x += 1
X = int('0b' + y, 0)

res = 1 << N-1
for i in range(N):
    now = X ^ res
    nx = x
    if y[i] == '1':
        nx -= 1
    else:
        nx += 1
    #print(now, res)
        
    a = bin(now)
    #print(a)
    
    b = now%nx
    #print(now, nx, b)
    ans = 1
    while b > 0:
        b = dic[b]
        ans += 1
    print(ans)
    
    res = res >> 1

### FIXED CODE ###

N = int(input())
X = input()

arr = [0 for _ in range(N+1)]
for i in range(1, N+1):
    cnt = bin(i).count('1')
    arr[i] = arr[i%cnt] + 1

x = int(X, 2)
pop = X.count('1')
plu = x % (pop+1)
mai = x % (pop-1) if pop>1 else 0

#bi = 1 << N
for i in range(N):
    #bi = bi >> 1
    if X[i] == '0':
        #res = (plu + bi % (pop+1)) % (pop+1)
        res = (plu + pow(2, N-1-i, pop+1)) % (pop+1)
    else:
        if pop == 1:
            print(0)
            continue
        #res = (mai - bi % (pop-1)) % (pop-1)
        res = (mai - pow(2, N-1-i, pop-1)) % (pop-1)
    print(arr[res] + 1)
def main():
    n = int(input())
    test = [int(input()) for i in range(n)]
    score = sum(test)
    test.sort()
    if len(list(filter(lambda x:x % 10 == 0, test))) == n:
        print(0)
        exit()
    tmp = []
    ind = 0
    while score % 10 == 0:
        for i in range(len(test)):
            tmp.append(score - test[i])
        score = max(tmp)
        test.pop(tmp.index(max(tmp)))
    print(score)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    test = [int(input()) for i in range(n)]
    score = sum(test)
    test.sort()
    x_test = list(filter(lambda x:x % 10 != 0, test))
    if len(x_test) == 0:
        print(0)
        exit()
    elif score % 10 != 0:
        print(score)
        exit()
    x_test.sort()
    print(score - x_test[0])

if __name__ == '__main__':
    main()
S = input()
t = input()

tmp1 = 0
tmp2 = 0
res = ''
flag = False
for i in range(len(S) - len(t)+1):
    h = True
    for j in range(len(t)):
        if S[i+j] != t[j]:
            h = False
    if h == True:
        flag = True
        break
        
if h != True:
            
    while True:
        if S[-tmp1 - 1] == t[-tmp2 - 1]  or S[-tmp1 - 1] == '?':
            res = t[-tmp2 - 1] + res
            tmp1 += 1
            tmp2 += 1
        else:
            if tmp2 == 0:
                tmp1 += 1
            tmp2 = 0
            res = ''


        if tmp2 == len(t):
            flag = True
            break

        if tmp1 == len(S):
            break
      
tmp3 = ''
k = 0
for i in range(len(S)):
    if len(S) - tmp1 <= i < len(S) - tmp1 + len(t):
        tmp3 += t[k]
        k += 1
    elif S[i] == '?':
        tmp3 += 'a'
    else:
        tmp3 += S[i]
        
res = tmp3 
 
if flag:
    print(res)
else:
    print('UNRESTORABLE')



### FIXED CODE ###

S = input()
T = input()


    
if True:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
    if tmp == -1:
        print('UNRESTORABLE')
    else:
        res = ''
        count = 0
        for i in range(len(S)):
            if tmp <= i < tmp + len(T):
                res += T[count]
                count += 1
            elif S[i] == '?':
                res += 'a'
            else:
                res += S[i]

        print(res)
t=input()
n=len(t)
a=[0]*n
for i in range(n):
    a[i]=t[i]

for i in range(n):
    if a[i]=="?":
        if a[i-1]=="D" and a[i+1]=="?":
            a[i]="P"
        elif a[i-1]=="P" and a[i+1]=="?":
            a[i]="D"
        elif a[i-1]=="D" and a[i+1]=="D":
            a[i]="P"
        else:
            a[i]="D"
    #print(a)

s=''.join(a)
print(s)


### FIXED CODE ###

t=input()
n=len(t)
a=[0]*n
for i in range(n):
    a[i]=t[i]

for i in range(n):
    if a[i]=="?":
        if i!=n-1:
            if a[i-1]=="D" and a[i+1]=="?":
                a[i]="P"
            elif a[i-1]=="P" and a[i+1]=="?":
                a[i]="D"
            elif a[i-1]=="D" and a[i+1]=="D":
                a[i]="P"
            else:
                a[i]="D"
        else:
            a[i]="D"
    #print(a)

s=''.join(a)
print(s)
A, B, C = map(int, input().split)

#X = A * B / 2
# 商の整数値（小数点以下を切り捨て）
X = A * B // 2
print(X)

### FIXED CODE ###

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

#X = A * B / 2
# 商の整数値（小数点以下を切り捨て）
X = A * B // 2
print(X)
s = input().split()
if s in "aeiou":
  print('vowel')
else:
  print('consonant')
  

### FIXED CODE ###

s = input().rstrip()
if s in "aeiou":
  print('vowel')
else:
  print('consonant')
from collections import Counter

N=int(input())
A=list(map(int,input().split()))
c=Counter(A)
commons=c.most_common()

ans=0

dic={}
for common in commons:
    dic[common[0]]=common[1]
    ans+=common[0]*common[1]
# print(dic)
# print(ans)

Q=int(input())
for i in range(Q):
    b,c=map(int,input().split())
    ans+=(c-b)*dic[b]
    dic[b]=0
    dic[c]+=dic[b]
    # print(dic)
    print(ans)


### FIXED CODE ###

from collections import Counter

N=int(input())
A=list(map(int,input().split()))
c=Counter(A)
commons=c.most_common()

ans=0

dic={}
for common in commons:
    dic[common[0]]=common[1]
    ans+=common[0]*common[1]
# print(dic)
# print(ans)

Q=int(input())
for i in range(Q):
    b,c=map(int,input().split())
    if b not in dic:
        print(ans)
        continue
    else:
        pass
    if c not in dic:
        ans+=(c-b)*dic[b]
        print(ans)
        dic[c]=dic[b]
        dic[b]=0
        continue
    else:
        pass
    ans+=(c-b)*dic[b]
    dic[c]+=dic[b]
    dic[b]=0
    print(ans)
x=int(input())
print(max(int(x/11)*2+(x%11>0)+(x%11>5)),1)


### FIXED CODE ###

x=int(input())
print(int(x/11)*2+(x%11>0)+(x%11>6))
N, X = map(int, input().split())


def search(level, eat_num):
    if eat_num == 0:
        if eat_num <= 0:
            return 0
        else:
            return 1

    elif eat_num == 1:
        return 0

    elif 1 < eat_num <= pow(2, level + 1) - 2:
        return search(level - 1, eat_num - 1)

    elif eat_num == pow(2, level + 1) - 1:
        return pow(2, level)

    elif pow(2, level + 1) - 1 < eat_num <= pow(2, level + 2):
        return pow(2, level) + search(level - 1, eat_num - (pow(2, level + 1) - 1))

    elif X == pow(2, level + 2) + 1:
        return pow(2, level + 1) - 1

    else:
        print('out', X)

print(search(level=N, eat_num=X))


### FIXED CODE ###

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


def search(level, eat_num):
    if level == 0:
        if eat_num <= 0:
            return 0
        else:
            return 1

    elif eat_num == 1:
        return 0

    elif 1 < eat_num <= pow(2, level + 1) - 2:
        return search(level - 1, eat_num - 1)

    elif eat_num == pow(2, level + 1) - 1:
        return pow(2, level)

    elif pow(2, level + 1) - 1 < eat_num <= pow(2, level + 2):
        return pow(2, level) + search(level - 1, eat_num - (pow(2, level + 1) - 1))

    elif X == pow(2, level + 2) + 1:
        return pow(2, level + 1) - 1

    else:
        return pow(2, level + 1) - 1


print(search(level=N, eat_num=X))
from math import gcd

N = int(input())
A = list(map(int, input().split()))
sieve = [1] * (10**5*5+1)
for i in range(2, 10**3):
	if sieve[i] == 1:
		sieve[i] = i
		j = 2
		while(j * i <= 10**5*5):
			sieve[j * i] = i
			j += 1
sieve[1] = 0

g = A[0]
a = 0
for i in range(1, N):
	g = gcd(g, A[i])
	if A[i] == 1:
		a = 1
	
if g != 1:
	print("not coprime")
else:
	if a == 1:
		print("setwise coprime")
		exit()
	s = set()
	for i in range(N):
		st = set()
		while(A[i] > 1):
			d = sieve[A[i]]
			if not(d in st) and d in s:
				print("setwise coprime")
				exit()
			s.add(d)
			st.add(d)
			A[i] //= d
	print("pairwise coprime")

### FIXED CODE ###

from math import gcd

N = int(input())
A = list(map(int, input().split()))
sieve = [1] * (10**6+1)
for i in range(2, 10**6 + 1):
	if sieve[i] == 1:
		sieve[i] = i
		j = 2
		while(j * i <= 10**6):
			sieve[j * i] = i
			j += 1

g = A[0]
for i in range(1, N):
	g = gcd(g, A[i])
	
if g != 1:
	print("not coprime")
else:
	s = set()
	for i in range(N):
		st = set()
		while(A[i] > 1):
			d = sieve[A[i]]
			st.add(d)
			A[i] //= d
		for p in st:
			if p in s:
				print("setwise coprime")
				exit()
			s.add(p)
	print("pairwise coprime")
S = input()
if S == ABC:
  print("ARC")
else:
  print("ABC")

### FIXED CODE ###

n = str(input())

if n == "ABC":
    print("ARC")
else:
    print("ABC")
a,b=list(map(int,input().split()))
if (a+b)%2==0:
  print(int((a+b)/2))
else:
  print('IMPOSSIBLE'

### FIXED CODE ###

a,b=list(map(int,input().split()))
if (a+b)%2==0:
  print(int((a+b)/2))
else:
  print('IMPOSSIBLE')
n, k = map(int,input().split())
nk_abs = abs(n - k)
if k == 1:
  print(0)
else:
  print(n % nk_abs)

### FIXED CODE ###

n, k = map(int, input().split())
print(min(n % k, k - n % k))
n,m=map(int,input().split())
X=list()
Y=list()
Z=list()
for i in range(n):
    x,y,z=map(int,input().split())
    X.append(x)
    Y.append(y)
    Z.append(z)
A=[]
B=[]
C=[]
D=[]
for i in range(n):
    A.append(X[i]+Y[i]+Z[i])
    B.append(-X[i]+Y[i]+Z[i])
    C.append(X[i]-Y[i]+Z[i])
    D.append(X[i]+Y[i]-Z[i])
import functools
A.sort()
B.sort()
C.sort()
D.sort()
x1=functools.reduce(lambda x,y:x+y,[A[i] for i in range(m)])
x2=functools.reduce(lambda x,y:x+y,[A[-i] for i in range(1,m+1)])
y1=functools.reduce(lambda x,y:x+y,[B[i] for i in range(m)])
y2=functools.reduce(lambda x,y:x+y,[B[-i] for i in range(1,m+1)])
z1=functools.reduce(lambda x,y:x+y,[C[i] for i in range(m)])
z2=functools.reduce(lambda x,y:x+y,[C[-i] for i in range(1,m+1)])
w1=functools.reduce(lambda x,y:x+y,[D[i] for i in range(m)])
w2=functools.reduce(lambda x,y:x+y,[D[-i] for i in range(1,m+1)])
print(max(abs(x1),abs(x2),abs(y1),abs(y2),abs(z1),abs(z2),abs(w1),abs(w2)))

### FIXED CODE ###

n,m=map(int,input().split())
X=list()
Y=list()
Z=list()
for i in range(n):
    x,y,z=map(int,input().split())
    X.append(x)
    Y.append(y)
    Z.append(z)
A=list()
B=list()
C=list()
D=list()
for i in range(n):
    A.append(X[i]+Y[i]+Z[i])
    B.append(-X[i]+Y[i]+Z[i])
    C.append(X[i]-Y[i]+Z[i])
    D.append(X[i]+Y[i]-Z[i])
import functools
A.sort()
B.sort()
C.sort()
D.sort()
if m==0:
    print(0)
else:
    x1=functools.reduce(lambda x,y:x+y,[A[i] for i in range(m)])
    x2=functools.reduce(lambda x,y:x+y,[A[-i] for i in range(1,m+1)])
    y1=functools.reduce(lambda x,y:x+y,[B[i] for i in range(m)])
    y2=functools.reduce(lambda x,y:x+y,[B[-i] for i in range(1,m+1)])
    z1=functools.reduce(lambda x,y:x+y,[C[i] for i in range(m)])
    z2=functools.reduce(lambda x,y:x+y,[C[-i] for i in range(1,m+1)])
    w1=functools.reduce(lambda x,y:x+y,[D[i] for i in range(m)])
    w2=functools.reduce(lambda x,y:x+y,[D[-i] for i in range(1,m+1)])
    print(max(abs(x1),abs(x2),abs(y1),abs(y2),abs(z1),abs(z2),abs(w1),abs(w2)))
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<stdio.h>
 
int main()
{
    int n;
    scanf("%d", &n);
    int i, rank;
    char sym;
    int card[4][14] = {0};
    for (i = 1; i <= n; i++)
    {
        scanf(" %c %d\n", &sym, &rank);
        switch (sym)
        {
        case 'S':
            card[0][rank-1] = -1;
            break;
        case 'H':
            card[1][rank-1] = -1;
            break;
        case 'C':
            card[2][rank-1] = -1;
            break;
        case 'D':
            card[3][rank-1] = -1;
        }

### FIXED CODE ###

cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
    
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
    
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))
s = input()
ans = 0
for i in range(0,len(s)-3):
  for j in range(3,len(s)):
    a = int(s[i:j+1])
    if a % 2019 == 0:
      ans += 1
print(ans)
               


### FIXED CODE ###

s,l = (input(),2019)
m,a,r = ([1]+[0]*l,0,0)
for i,e in enumerate(s[::-1]):
    a += int(e)*pow(10,i,l)
    r += m[a%l]
    m[a%l] += 1
print(r)
import collections
h,w = map(int, input().split())
s=[input()for _ in range(h)]

r=[[1,0],[-1,0],[0,1],[0,-1]]
def bfs(i,j):
    global h,w,r
    f=[-1 for _ in range(h*w)]
    que = collections.deque([[i,j,0]])
    while que:
        i,j,k = que.popleft()
        f[i*w+j] =k
        for sr in r:
            ti = i + sr[0]
            tj = j + sr[1]
            if ti>=0 and tj>=0 and ti<h and tj<w:
                if s[ti][tj] == ".":
                    if f[ti*w+tj] == -1:
                        que.append([ti,tj,k+1])
    return max(f)


res = 0
for i in range(h):
    for j in range(w):
        if s[i][j] ==".":
            tres = bfs(i,j)
            res = max(res,tres)
print(res)

### FIXED CODE ###

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

fac = [1]
caf = [1]


def pow(n, p):
    res = 1
    while p > 0:
        if p % 2 == 0:
            n = n ** 2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod


for i in range(1, n+1):
    fac.append((fac[i - 1] * i) % mod)
    caf.append(pow(fac[i], mod - 2))


def ncr(n, r):
    if n < r or r < 0:
        return 0
    return fac[n] * caf[r] * caf[n - r]



res = 0
for i in range(n):
    res += (a[i]*ncr(i,k-1))%mod
    res -= (a[i]*ncr(n-i-1,k-1))%mod
    res %= mod

print(res)
k = int(input())
s = input()
if len(s)>k:
    print(s[0:k],"...")
elsea
    print(s)


### FIXED CODE ###

import numpy as np
a = int(input())
b = a % 10
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]
if b in hon:
    print("hon")
elif b in pon:
    print("pon")
else:
    print("bon")
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Asum = [0]
Bsum = [0]
a = 0
b = 0
for i in range(N):
    a += A[i]
    Asum.append(a)
for i in range(M):
    b += B[i]
    Bsum.append(b)
Asum.append(0)
Bsum.append(0)
res, j = 0, 0
for i in range(N+1):
    if Asum[i] > K:
        break
    while Asum[i] + Bsum[j] <= K:
            j += 1
    res = max(res,i+j-1)
print(res)

### FIXED CODE ###

N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Asum = [0]
Bsum = [0]
a = 0
b = 0
for i in range(N):
    a += A[i]
    Asum.append(a)
for i in range(M):
    b += B[i]
    Bsum.append(b)
Asum.append(0)
Bsum.append(0)
res, j = 0, M
for i in range(N+1):
    if Asum[i] > K:
        break
    while Asum[i] + Bsum[j] > K:
            j -= 1
    res = max(res,i+j)
print(res)
import math 
a, b = map(float, input().split())
a =int(100*a)
b = int(100*b)
c = a*b
d = str(c)[:-4]
print(int(d))

### FIXED CODE ###

from decimal import *
a, b = map(str, input().split())
a = Decimal(a)
b = Decimal(b)
c = a*b
e=c.quantize(Decimal('0'), rounding=ROUND_FLOOR)
print(e)
str = input
count = 0

for i in range(len(str)):
  if str[i] != str[len(str)-1-1]:
    count += 1
    
print(count/2)
    


### FIXED CODE ###

str = input()
count = 0

for i in range(len(str)):
  if str[i] != str[len(str)-1-i]:
    count += 1
    
print(int(count/2))
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**18
MIN = -MAX

def main():
  n, k = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  As.sort()

  Ans, Aps, Azs = [], [], []
  for A in As:
    if A > 0:
      Aps.append(A)
    elif A == 0:
      Azs.append(A)
    else:
      Ans.append(A)

  def count(xs, ys, ub):
    c = 0
    r = len(ys) - 1
    for l in range(len(xs)):
      while xs[l] * ys[r] > ub and r >= 0:
        r -= 1
      c += r+1
    return c 

  def bs(l, r):
    while True:
      mid = (l+r) // 2
      if r - l <= 1:
        return r
      tot = 0
      
      tot += count(Aps, Aps, mid) - sum([1 for A in Aps if A**2 <= mid])
      tot += count(Ans[::-1], Ans[::-1], mid) - sum([1 for A in Ans if A**2 <= mid])
      tot //= 2

      if mid >=0:
        tot += (len(Aps) + len(Ans)) * len(Azs) + (len(Azs) * (len(Azs) - 1)) // 2
      tot += count(Aps[::-1], Ans, mid)
      
      if tot < k:
        l = mid
      else:
        r = mid
  
  print(bs(MIN-1, MAX+1))
    
    
if __name__=='__main__':
  main()



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**18
MIN = -MAX

def main():
  n, k = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  As.sort()

  Ans, Aps, Azs = [], [], []
  for A in As:
    if A > 0:
      Aps.append(A)
    elif A == 0:
      Azs.append(A)
    else:
      Ans.append(A)

  def count(xs, ys, ub):
    c = 0
    r = len(ys) - 1
    for l in range(len(xs)):
      while  r >= 0 and xs[l] * ys[r] > ub:
        r -= 1
      c += r+1
    return c 

  def bs(l, r):
    while True:
      mid = (l+r) // 2
      if r - l <= 1:
        return r
      
      tot = 0      
      tot += count(Aps, Aps, mid) - sum([1 for A in Aps if A**2 <= mid])
      tot += count(Ans[::-1], Ans[::-1], mid) - sum([1 for A in Ans if A**2 <= mid])
      tot //= 2

      if mid >=0:
        tot += (len(Aps) + len(Ans)) * len(Azs) + (len(Azs) * (len(Azs) - 1)) // 2
      tot += count(Aps[::-1], Ans, mid)
      
      if tot < k:
        l = mid
      else:
        r = mid
  
  print(bs(MIN-1, MAX+1))
    
    
if __name__=='__main__':
  main()
from collections import deque

n = int(input())
X = sorted([list(map(int,input().split())) for i in range(n)])
mod = 998244353
e = [[] for i in range(n)]

def dfs(x):
    count = 1

    for i in e[x]:
        count *= dfs(i)
        count %= mod
    return count+1

q = deque([])

for i in range(n-1,-1,-1):
    a,b = X[i]
    while q and q[0][0] < a+b:
        e[i].append(q[0][1]) 
        q.popleft()
    q.appendleft([a,i])

ans = 1
for i,j in q:
    ans *= dfs(j)
    ans %= mod
print(ans)


### FIXED CODE ###

def main():
    from collections import deque
    import sys
    sys.setrecursionlimit(10**7)
    input = sys.stdin.readline
    n = int(input())
    X = sorted([list(map(int,input().split())) for i in range(n)])
    mod = 998244353
    e = [[] for i in range(n)]

    def dfs(x):
        count = 1

        for i in e[x]:
            count *= dfs(i)
            count %= mod
        return count+1

    q = deque([])

    for i in range(n-1,-1,-1):
        a,b = X[i]
        while q and q[0][0] < a+b:
            e[i].append(q[0][1]) 
            q.popleft()
        q.appendleft([a,i])

    ans = 1
    for i,j in q:
        ans *= dfs(j)
        ans %= mod
    print(ans)
if __name__ == "__main__":
    main()
z = a * b
if (z % 2) == 0:
    print("Even")
else:
    print("Odd")

    

### FIXED CODE ###

a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")
n=int(input())
tako=list(map(int,input().split()))
umami=0
for i in range(n):
  for j in range(i+1,n):
    umami+==tako[i]*tako[j]
print(umami)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        ans+=A[i]*A[j]
print(ans)