Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

A, B, K = list(map(int,input().split(' ')))
'''
x = [i for i in range(A,B+1)]
s_f,s_b = x[:K],x[len(x)-K:]
ans = s_f + s_b
ans =list(set(ans))
#ans.sort()

'''
if len(range(A,B+1))<K:
  [print(i) for i in range(A,B+1)]
else:
  x = [i for i in range(A,B+1)]
  s_f,s_b = x[:K],x[len(x)-K:]
  ans = s_f + s_b
  ans =list(set(ans))
  ans.sort()
  [print(i) for i in ans]

  
  
       

### FIXED CODE ###

A, B, K = list(map(int,input().split(' ')))
'''
x = [i for i in range(A,B+1)]
s_f,s_b = x[:K],x[len(x)-K:]
ans = s_f + s_b
ans =list(set(ans))
#ans.sort()
if len(range(A,B+1))<K:
  [print(i) for i in range(A,B+1)]
else:
  x = [i for i in range(A,B+1)]
  s_f,s_b = x[:K],x[len(x)-K:]
  ans = s_f + s_b
  ans =list(set(ans))
  ans.sort()
  [print(i) for i in ans]

'''
if (B-A+1)<K:
  s =  list(range(A,B+1))
  [print(i) for i in s]
else:           
  s_f = list(range(A,A+K))
  s_b = list(range(B,B-K,-1))
  ans = s_f + s_b
  ans =list(set(ans))
  ans.sort()
  [print(i) for i in ans]
### BUGGY CODE ###

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

ans = 0
for i in range(N-2):
    A = L[i]
    for j in range(i+1,N-1):
        B = L[j]
        for k in range(j+1,N):
            C = L[k]
            if A < B + C and B < C + A and C < A + B:
                ans += 1
print(ans)


### FIXED CODE ###

from enum import Enum
from queue import Queue
import collections
import bisect

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

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

L.sort()
ans = 0
for i in range(N):
    for j in range(i+1,N):
        key = bisect.bisect_left(L,L[j]-L[i]+1)
        ans += max([0,i-key])

print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = int(input())
A = tuple(map(int, input().split()))
import fractions

LCM = A[0]
for i in range(1, N):
    LCM = LCM * A[i] // fractions.gcd(LCM, A[i])

ans = 0
for i in range(N):
    ans += LCM//A[i]

print(ans%(10**9+7))

### FIXED CODE ###

import sys
import fractions
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
g = 1
MOD = 10**9+7
ans = 0

for i in A:
    tmp = g*i//fractions.gcd(g, i) # それまでのLCM
    ans *= tmp//g
    g = tmp
    ans += g//i

print(ans%MOD)
### BUGGY CODE ###

n = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
 
    divisors.sort()
    return divisors

count = 0
for i in range(1, n + 1):
    count += i * len(make_divisors(i))
    
print(count)

### FIXED CODE ###

n = int(input())
def div(n):
    a = 0
    for i in range(1, n+1):
        y = int(n/i)
        a += y* (y+1)*i/2
    return int(a)
print(div(n))
### BUGGY CODE ###

import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
import math

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B=[]
C=[]
for i in range(M):
	b, c = list(map(int, input().split()))
	B.append(b)
	C.append(c)

A.sort()
for i in range(M):
	loc = bisect.bisect_left(A, C[i])
	loc = min(B[i], loc)
	A[0:loc] = [C[i]]*loc
	A.sort()

print(sum(A))

### FIXED CODE ###



import sys
def input():
	return sys.stdin.readline().strip()

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

CB = []
for i in range(M):
	B, C = list(map(int, input().split()))
	CB.append((C, B))
CB.sort()

sumb = 0
change = []
while sumb <= N and len(CB) > 0:
	C, B = CB.pop()
	sumb += B
	change.extend([C]*B)

change = change[0:N]

for i in range(len(change)):
	if A[i] < change[i]:
		A[i] = change[i]
	else:
		break

print(sum(A))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N, M = mis()
    S = input()

    @lru_cache(maxsize=None)
    def rec(n):
        if n < 0 or S[n] == '1':
            return None, INF
        elif n == 0:
            return None, 0
        min_i = None
        min_v = INF
        for i in range(n-M, n):
            _, v = rec(i)
            if min_v > v:
                min_v = v
                min_i = i
        return min_i, min_v

    flag, _ = rec(N)
    if flag is None:
        print(-1)
    else:
        ans = []
        pos = N
        while pos != 0:
            prev_pos, _ = rec(pos)
            ans.append(pos - prev_pos)
            pos = prev_pos
        ans.reverse()
        print(*ans, sep=' ')



main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N, M = mis()
    S = input()

    ans = []
    r = N
    l = max(r - M, 0)
    while r > 0:
        for i in range(l, r):
            if S[i] == '0':
                ans.append(r - i)
                r = i
                l = max(r - M, 0)
                break
        else:
            print(-1)
            return
    ans.reverse()
    print(*ans, sep=' ')


main()
### BUGGY CODE ###

import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
q = INT()
p = [input() for i in range(q)]

for i in range(q):
        if int(p[i][0]) == 1:
                s = s[::-1]
        else:
                t, f, c = p[i].split()
                if int(f) == 1:
                        s = c + s
                else:
                        s = s + c 
print(s)

### FIXED CODE ###

import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
q = INT()
p = [0]*q
flag = 0
c0 = c1 = ''

for i in range(q):
        p[i] = input()
        if p[i][0] == '1':
                flag = 1 - flag
        else:
                t, f, c = p[i].split()
                if (f == '1' and flag == 0) or (f == '2' and flag == 1):
                        c0 = c + c0
                else:
                        c1 = c1 + c

s = c0 + s + c1
print(s if flag == 0 else s[::-1])
### BUGGY CODE ###

# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import Counter
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    S=[str(input()) for i in range(N)]


    cnt=0
    for i in range(N):
        for j in range(i+1,N):
            if Counter(S[i])==Counter(S[j]):
                cnt+=1

    print(cnt)

resolve()

### FIXED CODE ###

# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import Counter
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    S=[''.join(sorted(input())) for i in range(N)]
    C=Counter(S)
    print(sum(i*(i-1)//2 for i in C.values()))






resolve()
### BUGGY CODE ###

a, b, c, d, e, f = map(int, input().split())
lisw = []
liss = []
ans = []
cc = f // c
dd = f // d
for ai in range(31):
    for bi in range(31):
        for ci in range(cc):
            for di in range(dd):
                if ai == bi == 0:
                        continue
                if 100 * a * ai + 100 * b * bi + c * ci + d * di <= f:
                    if (c * ci + d * di)/(100 * a * ai + 100 * b * bi) <= e/100:
                        ans.append([(c * ci + d * di)/(100 * a * ai + 100 * b * bi + c * ci + d * di), 100 * a * ai + 100 * b * bi + c * ci + d * di, c * ci + d * di])
ans.sort(reverse=True)
print(ans[0][1], ans[0][2])

### FIXED CODE ###

a, b, c, d, e, f = map(int, input().split())
ans = []
for ai in range(31):
    bb = (f - (ai * a * 100)) // b
    for bi in range(bb + 1):
        if ai == bi == 0:
            continue
        cc = (f - (ai * a * 100 + bi * b * 100)) // c
        for ci in range(cc + 1):
            dd = (f - (ai * a * 100 + bi * b * 100 + ci * c)) // d
            for di in range(dd + 1):
                if 100 * a * ai + 100 * b * bi + c * ci + d * di <= f:
                    if (c * ci + d * di)/(100 * a * ai + 100 * b * bi) <= e/100:
                        ans.append([(c * ci + d * di)/(100 * a * ai + 100 * b * bi + c * ci + d * di), 100 * a * ai + 100 * b * bi + c * ci + d * di, c * ci + d * di])
ans.sort(reverse=True)
print(ans[0][1], ans[0][2])
### BUGGY CODE ###

import sys
#大きすぎるとダメ
sys.setrecursionlimit(2520)
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
inf=1000000000000000
d=[[inf]*w for i in range(h)]


def dfs(i,j):
    global h,w,s
    nex=[(0,-1),(0,1),(-1,0),(1,0)]
    for k in range(4):
        l,m=i+nex[k][0],j+nex[k][1]
        if 0<=i+nex[k][0]<h and 0<=j+nex[k][1]<w:
            if s[l][m]=="." and d[l][m]>d[i][j]+1:
                d[l][m]=d[i][j]+1
                dfs(l,m)
d[0][0]=0
dfs(0,0)
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ans+=1
if d[h-1][w-1]==inf:
    print(-1)
else:
    print(ans-d[h-1][w-1]-1)




### FIXED CODE ###

#一個だけRE、わからねえ
#解答見る
import sys
sys.setrecursionlimit(1005)
h,w=map(int,input().split())

def go_next(I,J,n):
    n+=1
    global dp,w,h
    if n>1000:
        return
    if 0<=I<h-1:
        if x[I+1][J]=="." and dp[I+1][J]>dp[I][J]+1:
            dp[I+1][J]=dp[I][J]+1
            go_next(I+1,J,n)
    if 0<I<=h-1:
        if x[I-1][J]=="." and dp[I-1][J]>dp[I][J]+1:
            dp[I-1][J]=dp[I][J]+1
            go_next(I-1,J,n)
    if 0<=J<w-1:
        if x[I][J+1]=="." and dp[I][J+1]>dp[I][J]+1:
            dp[I][J+1]=dp[I][J]+1
            go_next(I,J+1,n)
    if 0<J<=w-1:
        if x[I][J-1]=="." and dp[I][J-1]>dp[I][J]+1:
            dp[I][J-1]=dp[I][J]+1
            go_next(I,J-1,n)

x=[]
for i in range(h):
    x.append(list(input()))
#print(x)
c=0
for i in range(h):
    for j in range(w):
        if x[i][j]==".":
            c+=1
dp=[[10000000000 for i in range(w)]for j in range(h)]
dp[0][0]=1
go_next(0,0,0)
if dp[h-1][w-1]==10000000000:
    print(-1)
else:
    print(c-dp[h-1][w-1])
### BUGGY CODE ###

Q,H,S,D = map(int,input().split())
N = int(input())
N *= 100
H = min(H,2*Q)
S = min(S,2*H)
D = min(D,2*S)
ans = 0
while N > 0:
  if N >= 200:
    ans += D
    N -= 200
  elif N >= 100:
    ans += S
    N -= 100
  elif N >= 50:
    ans += H
    N -= 50
  elif N >= 25:
    ans += Q
    N -= 25
print(ans)

### FIXED CODE ###

Q,H,S,D = map(int,input().split())
N = int(input())
N *= 100
H = min(H,2*Q)
S = min(S,2*H)
D = min(D,2*S)
ans = 0
if N%200 != N:
  ans += (N//200)*D
  N %= 200
if N%100 != N:
  ans += (N//100)*S
  N %= 100
if N%50 != 50:
  ans += (N//50)*H
  N %= 50
if N%25 != N:
  ans += (N//25)*Q
  N %= 25
if N == 0:
  print(ans)
### BUGGY CODE ###

h,w = map(int,input().split())
x = []
for i in range(h):
    x.append(input())

l = [[0]*w for i in range(h)]
r = [[0]*w for i in range(h)]
u = [[0]*w for i in range(h)]
d = [[0]*w for i in range(h)]

for i in range(h):
    c = 0
    for j in range(w):
        if x[i][j] == '.':
            l[i][j] = c
            c += 1
        else: c=0


for i in range(h):
    c = 0
    for j in range(w):
        if x[i][w-1-j] == '.':
            r[i][w-1-j] = c
            c += 1
        else: c=0

for i in range(w):
    c = 0
    for j in range(h):
        if x[j][i] == '.':
            u[j][i] = c
            c += 1
        else: c=0

for i in range(w):
    c = 0
    for j in range(h):
        if x[h-1-j][i] == '.':
            d[h-1-j][i] = c
            c += 1
        else: c=0

ans = 0
for i in range(h):
    for j in range(w):
        c = l[i][j]+r[i][j]+u[i][j]+d[i][j]
        if x[i][j]=='.':c+=1
        ans = max(ans,c)

print(ans)


### FIXED CODE ###

h, w = map(int, input().split())
data = [list(input()) for _ in range(h)]

cnt_l, cnt_r, cnt_u, cnt_d = [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)], [[0] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if data[i][j] == "#":
            cnt_l[i][j] = 0
        else:
            cnt_l[i][j] = cnt_l[i][j - 1] + 1
    
        if data[i][w - j - 1] == "#":
            cnt_r[i][w - j - 1] = 0
        else:
            if j == 0:
                cnt_r[i][w - j - 1] = 1
            else:
                cnt_r[i][w - j - 1] = cnt_r[i][w - j] + 1

for j in range(w):
    for i in range(h):
        if data[i][j] == "#":
            cnt_u[i][j] = 0
        else:
            cnt_u[i][j] = cnt_u[i - 1][j] + 1

        if data[h - i - 1][j] == "#":
            cnt_d[h - i - 1][j] = 0
        else:
            if i == 0:
                cnt_d[h - i - 1][j] = 1
            else:
                cnt_d[h - i - 1][j] = cnt_d[h - i][j] + 1

ans = 0
for i in range(h):
    for j in range(w):
        total= cnt_l[i][j] + cnt_r[i][j] + cnt_u[i][j] + cnt_d[i][j] - 3
        ans = max(ans, total)

print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import sys
input=sys.stdin.readline

N,K=map(int,input().split())
l=list(map(int,input().split()))

dp=[float('inf')]*(N)

dp[0]=0
for i in range(1,N):
    
    for j in range(1,min(i,K)+1):

        dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))

print(dp[N-1])
    


### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
input=sys.stdin.readline

N,K=map(int,input().split())
l=list(map(int,input().split()))

dp=[float('inf')]*(N)

dp[0]=0
for i in range(1,N):
    
    for j in range(1,min(i,K)+1):

        dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))

print(dp[N-1])
### BUGGY CODE ###

def zalgo(S):
    # SとS[i:n]のlcpの長さを記録した配列を返す
    n = len(S)
    A = [0] * n
    j = 0
    for i in range(1, n):
        if i+A[i-j] < j+A[j]:
            A[i] = A[i-j]
        else:
            k = max(0, A[j]-i+j)
            while i+k < n and S[k] == S[i+k]:
                k += 1
            A[i] = k
            j = i
    A[0] = n
    return A


n = int(input())
S = input()
l = 0
for i in range(n):
    A = zalgo(S[i:])
    B = [min(j, a) for j, a in enumerate(A)]
    l = max(l, max(B))
print(l)


### FIXED CODE ###

def zalgo(S):
    # SとS[i:n]のlcpの長さを記録した配列を返す
    n = len(S)
    A = [0] * n
    j = 0
    for i in range(1, n):
        if i+A[i-j] < j+A[j]:
            A[i] = A[i-j]
        else:
            k = max(0, A[j]-i+j)
            while i+k < n and S[k] == S[i+k]:
                k += 1
            A[i] = k
            j = i
    A[0] = n
    return A


n = int(input())
S = input()
l = 0
for i in range(n):
    A = zalgo(S[i:])
    B = [min(j, a) for j, a in enumerate(A)]
    l = max(l, max(B))
print(l)
### BUGGY CODE ###

# スコアが高い順に右端 or 左端に置く事を考える
# dp[i][l] : l番目まで左に子がいる状態でi番目の子を動かす時の最大値
n = int(input())
tmp = [int(x) for x in input().split()]

aList=[]
for i in range(n):
    aList.append([tmp[i],i])

aList.sort(reverse=True)

dp=[[int(-1) for i in range(n+1)] for j in range(n+1)]
dp[0][0] = 0

# スコアが高い順にi人動かす
for i in range(n):
    # 左側に置いた人数。i番目のループでは0〜i人まで左端に置く可能性がある
    for l in range(i+1):
        activity = aList[i][0]
        pos = aList[i][1]

        # 右端の今のポジション
        # totalで置いた数-左側に置いた数(i-l)を計算し、右端(n-1)から引く
        r = n-1-(i-l)

        # 左に置いた場合
        dp[i+1][l+1] = max(dp[i+1][l+1],dp[i][l] + abs(l-pos) * activity)

        # 右に置いた場合
        dp[i+1][l]   = max(dp[i+1][l],dp[i][l] + abs(r-pos) * activity)

print(max(dp[n]))


### FIXED CODE ###

# スコアが高い順に右端 or 左端に置く事を考える
# dp[i][l] : l番目まで左に子がいる状態でi番目の子を動かす時の最大値
n = int(input())
tmp = [int(x) for x in input().split()]

aList=[]
for i in range(n):
    aList.append([tmp[i],i])

aList.sort(reverse=True)

dp=[[int(-1) for i in range(n+1)] for j in range(n+1)]
dp[0][0] = 0

# スコアが高い順にi人動かす
for i in range(n):
    # 左側に置いた人数。i番目のループでは0〜i人まで左端に置く可能性がある
    for l in range(i+1):
        activity = aList[i][0]
        pos = aList[i][1]

        # 右端の今のポジション
        # totalで置いた数-左側に置いた数(i-l)を計算し、右端(n-1)から引く
        r = n-1-(i-l)

        # 左に置いた場合
        dp[i+1][l+1] = max(dp[i+1][l+1],dp[i][l] + abs(l-pos) * activity)

        # 右に置いた場合
        dp[i+1][l]   = max(dp[i+1][l],dp[i][l] + abs(r-pos) * activity)

print(max(dp[n]))
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC89 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7


h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
s = [None for _ in range(h*w+1)]
for i in range(h):
    for j in range(w):
        s[a[i][j]] = [i+1,j+1]
D = [[0]*(h*w+1) for _ in range(d)]
for i in range(d+1,h*w+1):
    x = abs(s[i][0] - s[i-d][0]) + abs(s[i][1] - s[i-d][1])
    D[i%d][i//d] = x
for i in range(d):
    D[i] = list(accumulate(D[i]))
for _ in range(q):
    l,r = map(int,input().split())
    print(D[l%d][r//d] - D[l%d][l//d])


### FIXED CODE ###

#!/usr/bin/env python3
#ABC89 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7


h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
s = [None for _ in range(h*w+1)]
for i in range(h):
    for j in range(w):
        s[a[i][j]] = [i+1,j+1]
D = [[0]*((h*w+1)//d+1) for _ in range(d)]
for i in range(d+1,h*w+1):
    X,Y = s[i]
    Z,W = s[i-d]
    x = abs(X - Z) + abs(Y - W)
    D[i%d][i//d] = x + D[i%d][i//d-1]
for _ in range(q):
    l,r = map(int,input().split())
    x = D[l%d]
    print(x[r//d] - x[l//d])
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, Q = mapint()
tree = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = mapint()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
late = [0]*N

for _ in range(Q):
    v, p = mapint()
    late[v-1] += p

ans = [0]*N
checked = [0]*N

def dfs(v, plus):
    plus += late[v]
    checked[v] = 1
    ans[v] = plus
    for nx in tree[v]:
        if not checked[nx]:
            dfs(nx, plus)

dfs(0, 0)
print(*ans)

### FIXED CODE ###

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

query = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    query[a-1].append(b-1)
    query[b-1].append(a-1)

from collections import deque

count = [0]*N

for i in range(Q):
    p, x = map(int, input().split())
    count[p-1] += x

queue = deque([0])
checked  = [0]*N
while queue:
    v = queue.pop()
    checked[v] = 1
    x = count[v]
    Vs = query[v]
    for i in Vs:
        if checked[i]:
            continue
        count[i] += x
        queue.append(i)
    
print(*count)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
B = list()
ans = 0
for i in range(n - 1):
    for j in range(n - i - 1):
        b = A[i] ^ A[j + i + 1]
        B.append(b)
for i in range(len(B)):
    if ans + B[i] < 1000000007:
        ans += B[i]
    else:
        ans = (ans + B[i]) % 1000000007
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
p = [pow(2, i, mod) for i in range(60)]
ans = 0
for i in range(60):
    c = 0
    for j in a:
        if (j >> i) & 1:
            c += 1
    ans += (c * (n - c) * p[i]) % mod
    ans %= mod
print(ans)
### BUGGY CODE ###

from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
As = sorted(map(int, input().split()))

def check(t):
    "if the number of the pairs (i, j) that satisfies Ai * Aj <= t is < K, return True"
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            index = bisect_right(As, t//A, lo = i+1) - (i+1)
        elif A < 0:
            index = N - bisect_left(As, -(t//(-A)), lo = i+1)
        else:
            if t < 0:
                index = 0
            else:
                index = N - i - 1
        count += index
        if count > K:
            return False
    return (count < K)

m_count = 0
p_count = 0
for A in As:
    if A < 0:
        m_count += 1
    if A > 0:
        p_count += 1

if K <= m_count * p_count:
    l = - (10 ** 18 + 10)
    r = 0
elif K > N * (N-1) // 2 - p_count * (p_count-1) // 2 - m_count * (m_count-1) // 2 :
    l = 0
    r = 10 ** 18 + 10
else:
    print(0)
    exit()

while r - l > 1:
    mid = (l + r) // 2
    if check(mid):
        l = mid
    else:
        r = mid

print(r)

### FIXED CODE ###

from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
As = sorted(map(int, input().split()))
        
l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while True:
    mid = (l + r) // 2
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            count += bisect_right(As, mid//A, lo = i+1) - (i+1)
        elif A < 0:
            count += N - bisect_left(As, -((-mid)//A), lo = i+1)
        else:
            if mid >= 0:
                count += N - i - 1
    if count < K:
        l = mid
    else:
        r = mid
    if r - l == 1:
        break

print(r)
### BUGGY CODE ###

n = int(input())
ans = 1
for i in range(1,n+1):
    ans *= i
print(ans%(10**9+7))

### FIXED CODE ###

n = int(input())
ans = 1
for i in range(1,n+1):
    ans = (ans * i)%(10**9+7)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())
s = input()

ls_password = []

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            pw = s[i] + s[j] + s[k]
            ls_password.append(pw)

# print(ls_password)

print(len(set(ls_password)))

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
s = input()

count = 0

ls_si = []
for i in range(n-2):
    # print("i={}".format(i))
    if s[i] in ls_si:
        pass
    else:
        ls_si.append(s[i])
        ls_sj = []
        for j in range(i+1,n-1):
            if s[j] in ls_sj:
                pass
            else:
                ls_sj.append(s[j])
                # ls = s[j+1:-1]
                # st = set(ls)
                # l = len(st)
                # print(ls)
                # print(st)
                # print(l)
                count += len(set(list(s[j+1:-1])))

# print(ls_si)
# print(ls_sj)
print(count)
### BUGGY CODE ###

n = int(input())
s = input().rstrip()

ans = 10 ** 6
for i in range(1,n):
    ans = min(ans, s[:i].count("#") + s[i:].count("."))

ans = min(ans, s.count("#"), s.count("."))
print(ans)

### FIXED CODE ###

n = int(input())
s = input().rstrip()

ans = 10 ** 6
count=0
l_c = [0] * n
for i, c in enumerate(s):
    if c == "#":
        count += 1
    l_c[i] = count
count=0
r_c = [0] * n
for i, c in enumerate(s[::-1]):
    if c == ".":
        count += 1
    r_c[n-1-i] = count

for i in range(1,n):
    ans = min(ans, l_c[i-1] + r_c[i])

ans = min(ans, s.count("#"), s.count("."))
print(ans)