Harryxun/stf_run huggingface dataset:
h,w=map(int,input().split())
candidate=[0]*4
if h*w%3==0:
	print(0)
	exit()
def solve(a,b,k):
	candidate[k]=a
	if b%2==0:
		cnd=float('inf')
		for i in range(a//2+1):
			cnd=min(abs(b-3*i),cnd)
		candidate[k+1]=(cnd*a//2,i)
	else:
		cnd=float('inf')
		for i in range(a//2+1):
			cnd=min(cnd,max(abs(a//2*(b-i)-a*i),abs(a//2*(b-i)-a*i+b-i),abs(b-i)))
			candidate[k+1]=(cnd,i)
solve(h,w,0)
solve(w,h,2)
print(min(candidate))





### FIXED CODE ###

h,w=map(int,input().split())
candidate=[0]*4
if h*w%3==0:
	print(0)
	exit()

def solve(a,b,k):
	candidate[k]=a
	cnd=float('inf')
	for i in range(a+1):
		c1=b*i
		c2=(a-i)*(b//2)
		c3=(a-i)*(b-b//2)
		cnd=min(cnd,max(c1,c2,c3)-min(c1,c2,c3))
	candidate[k+1]=cnd

solve(h,w,0)
solve(w,h,2)
print(min(candidate))
K = map(int,input().split())
h = list(map(int,input().split()))
dp = [-1] * N
dp[0] = 0
 
for i in range(1, N):
    l = []
    m = min(K, i)
    for j in range(1, m+1):
        l.append(dp[i-j] + abs(h[i] - h[i-j]))
    dp[i] = min(l)
print(dp[-1])

### FIXED CODE ###

N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [-1] * N
dp[0] = 0
 
for i in range(1, N):
    l = []
    m = min(K, i)
    for j in range(1, m+1):
        l.append(dp[i-j] + abs(h[i] - h[i-j]))
    dp[i] = min(l)
print(dp[-1])
a,b= map(int,raw_input().split());
if a<b ;
  print 'a<b';
elif a>b ;
  print 'a>b';
else
  print 'a==b' ;

### FIXED CODE ###

a,b= map(int,input().split());
if a < b :
	print("a < b" );
elif a > b :
	print("a > b" );
elif a == b :
	print("a == b") ;
import heapq

# def heapify(x):
#     for i in range((x)):
#         x[i] = -x[i]
#     heapq.heapify(x)

# def heappush(heap, item):
#     heapq.heappush(heap, -item)

# def heappop(heap):
#     return -heapq.heappop(heap)

# from heapq import heappop, heappush
# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None


rooms_count, passages_count = map(int, raw_input().split())
matrix = []
for i in range(0, rooms_count):
    matrix.append([])
    for j in range(0, rooms_count):
        matrix[i].append(False)

for j in range(0, passages_count):
    a, b = map(int, raw_input().split())
    matrix[a - 1][b - 1] = True
    matrix[b - 1][a - 1] = True

seen = set()
distance = [10000] * rooms_count
next = [10000] * rooms_count
h = []
heapq.heappush(h, (0, 0, -1))
while len(h):
    (d, room, parent) = heapq.heappop(h)
    if (distance[room] <= d):
        continue
    distance[room] = d
    next[room] = parent
    seen.add(room)

    for neighbor in range(0, rooms_count):
        if neighbor != room and matrix[room][neighbor]:
            heapq.heappush(h, (d + 1, neighbor, room))

if len(seen) == rooms_count:
    print('Yes')
    for room in range(1, rooms_count):
        print(next[room] + 1)
else:
    print('No')


### FIXED CODE ###

import heapq

# def heapify(x):
#     for i in range((x)):
#         x[i] = -x[i]
#     heapq.heapify(x)

# def heappush(heap, item):
#     heapq.heappush(heap, -item)

# def heappop(heap):
#     return -heapq.heappop(heap)

# from heapq import heappop, heappush
# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None


def raw_input():
    return input()


rooms_count, passages_count = map(int, raw_input().split())
adj = []
for i in range(0, rooms_count):
    adj.append([])

for j in range(0, passages_count):
    a, b = map(int, raw_input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)

seen = set()
distance = [100000000] * rooms_count
next = [100000000] * rooms_count
h = []
heapq.heappush(h, (0, 0, -1))
while len(h):
    (d, room, parent) = heapq.heappop(h)
    if (distance[room] <= d):
        continue
    distance[room] = d
    next[room] = parent
    seen.add(room)

    for neighbor in adj[room]:
        heapq.heappush(h, (d + 1, neighbor, room))

if len(seen) == rooms_count:
    print('Yes')
    for room in range(1, rooms_count):
        print(next[room] + 1)
else:
    print('No')
import math
a, b = map(int, input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

### FIXED CODE ###

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
	
def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a, b))
A,B,C,D = list(map(int,input().split()))
for num in range (A,B+1):
    if num in range (C,D+1):
        print("Yes")
        break
else:
        print("No")
       

### FIXED CODE ###

K = int(input())
P = str("ACL")
D = print(P*K)
#162C
#Sum of gcd of Tuples (Easy)

import math

k=int(input())+1
ans=0
for a in range(1,k):
    for b in range(1,k):
        g=math.gcd(a,b)
        for c in range(1,k):
            ans+=gcd(g,c)
print(ans)

### FIXED CODE ###

#162C
#Sum of gcd of Tuples (Easy)

import math

k=int(input())+1
ans=0
for a in range(1,k):
    for b in range(1,k):
        g=math.gcd(a,b)
        for c in range(1,k):
            ans+=math.gcd(g,c)
print(ans)
print(x**3)

### FIXED CODE ###

x=input()
print(x**3)
s = input()
s[3] = 8
print(s)

### FIXED CODE ###

print(input().replace('2017', '2018'))
import sys

def process(data):
	count = 0

	M = int(data[0])
	D = data[1]

	if len(D) < 2:
		return 0


	for d10 in range(2, int(D[0])+1):
		for d1 in range(2, 10):
			if 0 < d10 * d1 and d10 * d1 <= M and int(str(d10)+str(d1)) <= int(D):
				count += 1


	return count 

def main(argv):
	data = []
	for i, v in enumerate(argv):
		data.append(v)
	print(process(data))
	return process(data)

if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

import sys

def process(data):
	count = 0

	M = int(data[0])
	D = data[1]
	
	if len(D) < 2:
		return 0


	for d10 in range(2, int(D[0])+1):
		for d1 in range(2, 10):
			if 0 < d10 * d1 and d10 * d1 <= M:
				if int(str(d10)+str(d1)) <= int(D):
					count += 1
				else:
					break


	return count 

def main(argv):
	for i in range(1):
		data = raw_input()
		data = data.split(" ")
	print(process(data))

	

if __name__ == '__main__':
    main(sys.argv[1:])
import math
def GCD(LIST):
	if len(LIST)==2:
		return math.gcd(LIST[0],LIST[1])
	else:
		return GCD([math.gcd(LIST[0],LIST[1])]+LIST[2::])

N,X=map(int,input().split())
x=list(map(int,input().split()))
L=sorted(x+[X])
if N==1:
	print(abs(X-x[0]))
else:
	LL=[L[i+1]-L[i] for i in range(N)]
	print(GCD(LL))

### FIXED CODE ###

from functools import reduce
N,X=map(int,input().split())
x=list(map(int,input().split()))
L=x+[X]
if N==1:
	print(abs(X-x[0]))
else:
	LL=[abs(L[i+1]-L[i]) for i in range(N)]
	def gcd(a,b):
		while b>0:
			a,b=b,a%b
		return a
	print(reduce(gcd,LL))
K, N = input().split()
distance = list(map(int, input().split()))

relative = []
relative[0] = distance[0]
for i in range(1, len(distance)):
    relative[i] = distance[i+1] - distance[i]
relative.append(K -  distance[-1])
print(sum(relative) - max(relative))

### FIXED CODE ###

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

relative = []
relative.append(distance[0])
for i in range(int(N)-1):
    relative.append(distance[i+1] - distance[i])
relative[0] += (int(K) -  distance[-1])
print(sum(relative) - max(relative))
A, B = map(int, input().split())
 
judge = False
for c in range(1,4):
  if (A*B*C) %2 == 1:
    judge = True
   
 
  
if judge == True:
  print("Yes")
else:
  print("No")
      

### FIXED CODE ###

A, B = map(int, input().split())
 
judge = False
for C in range(1,4):
  if (A*B*C) %2 == 1:
    judge = True
   
 
  
if judge == True:
  print("Yes")
else:
  print("No")
N = int(input())
kuku = []
for x in range(1,10):
  for y in range(1,10):
    kuku.append(x*y)
    
if N in kuku:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b = input().split()
a = int(a)
b = int(b)
if a >= 10 or b >=10:
  print ('-1')
else:
  print (a * b)
N = int(input())
A = int(input())
B = int(input())
if N == 1:
  print('Hello World')
else:
  print(A+B)

### FIXED CODE ###

import sys
N = int(input())
if N == 1:
  print('Hello World')
  sys.exit()
A = int(input())
B = int(input())
print(A+B)
import bisect
import heapq
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int,input().split()))
a_left = sorted(a[:N])
a_right = sorted(a[N:])
sum_left = sum(a_left)
sum_right = sum(a_right[:N])
res = sum_left - sum_right

heapq.heapify(a_left)

len_left = N
for elem in a[N:2*N]:
    le = bisect.bisect_left(a_right, elem)
    a_right[le:] = a_right[le+1:]
    if le < N:
        sum_right -= elem
        sum_right += a_right[N-1]
    now = heapq.heappop(a_left)
    if now < elem:
        heapq.heappush(a_left, elem)
        sum_left += (elem-now)
    else:
        heapq.heappush(a_left, now)
    res = max(res, sum_left-sum_right)
print(res)

"""


### FIXED CODE ###

import bisect
import heapq
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int,input().split()))
a_left = sorted(a[:N])
a_right = sorted(a[2*N:])
sum_left = sum(a_left)
sum_right = sum(a_right)
#res = sum_left - sum_right
res = sum_left - sum(sorted(a[N:])[:N])
a_right = [-elem for elem in a_right]
heapq.heapify(a_right)
heapq.heapify(a_left)
sr = [0]*(N+1)
sr[0] = sum_right

for i,elem in enumerate(reversed(a[N:2*N])):
    now = -heapq.heappop(a_right)
    if now > elem:
        heapq.heappush(a_right, -elem)
        sum_right += (elem-now)
    else:
        heapq.heappush(a_right, -now)
    sr[i+1] = sum_right

for i,elem in enumerate(a[N:2*N]):
    now = heapq.heappop(a_left)
    if now < elem:
        heapq.heappush(a_left, elem)
        sum_left += (elem-now)
    else:
        heapq.heappush(a_left, now)
    res = max(res, sum_left-sr[N-i-1])
print(res)
n = int(input())

a = n // 11 *2
b = n % 11
if c > 0:
	c = 1
elif b >= 7:
	c = 2
print(a+c)

### FIXED CODE ###

n = int(input())

a = (n // 11) *2

b = n % 11

c = 0
if 7 > b > 0:
	c = 1
elif b >= 7:
	c = 2
print(a+c)
import math
n,m=map(int,input().split())
s=input()
t=input()
b=0
for i in range(n):
    if (i*m)%n==0 and (i*m)//n<m:
        if not t[(i*m)//n]==s[i]:
            b=1

if b:
    print(-1)
else:
    print(n*m//math.gcd(n,m))

### FIXED CODE ###

import fractions
n,m=map(int,input().split())
s=input()
t=input()
b=0
for i in range(n):
    if (i*m)%n==0 and (i*m)//n<m:
        if not t[(i*m)//n]==s[i]:
            b=1

if b:
    print(-1)
else:
    print(n*m//fractions.gcd(n,m))
def calculate(n, m, condition_list):
    if [1, 0] in condition_list:
        return '-1'
    # こたえは1桁ごとに区切ったリストにする
    # 最後にjoinして回答する
    result = ['null']*n
    for condition in condition_list:
        if result[condition[0]-1] != 'null':
            if not result[condition[0]-1] == condition[1]:
                return '-1'
        result[condition[0]-1] = condition[1]
    # 指定がない桁はまだnullのままなのでそれを埋める
    for i in range(result):
        if result[i] == 'null':
            # 一番左の桁が空いていたら1にする
            if i == 0 and n != 1:
                result[i] = 1
            # それ以外の桁が空いていたら0にする
            else:
                result[i] = 0
    return ''.join([str(each) for each in result])

n, m = (int(each) for each in input().split(' '))

# 条件をリストに入れる
condition_list = []
for i in range(m):
    condition_list.append([int(each) for each in input().split(' ')])

print(calculate(n, m, condition_list))

### FIXED CODE ###

def calculate(n, m, condition_list):
    if [1, 0] in condition_list and n > 1:
        return '-1'
    # こたえは1桁ごとに区切ったリストにする
    # 最後にjoinして回答する
    result = ['null']*n
    for condition in condition_list:
        if result[condition[0]-1] != 'null':
            if not result[condition[0]-1] == condition[1]:
                return '-1'
        result[condition[0]-1] = condition[1]
    # 指定がない桁はまだnullのままなのでそれを埋める
    for i in range(len(result)):
        if result[i] == 'null':
            # 一番左の桁が空いていたら1にする
            if i == 0 and n != 1:
                result[i] = 1
            # それ以外の桁が空いていたら0にする
            else:
                result[i] = 0
    return ''.join([str(each) for each in result])

n, m = (int(each) for each in input().split(' '))

# 条件をリストに入れる
condition_list = []
for i in range(m):
    condition_list.append([int(each) for each in input().split(' ')])

print(calculate(n, m, condition_list))
for i in range(int(input())):
    s = list(map(float,input().split()))
    if (s[0] - s[2]) / (s[1] - s[3]) == (s[4] - s[6]) / (s[5] - s[7]):
        print('YES')
    else:
        print('NO')

### FIXED CODE ###

for i in range(int(input())):
    s = list(map(float,input().split()))
    if s[1] - s[3] == 0 or s[5] - s[7] == 0:
        if s[1] - s[3] == s[5] - s[7] == 0:
            print('YES')
        else:
            print('NO')
    elif abs((s[0] - s[2]) / (s[1] - s[3]) - (s[4] - s[6]) / (s[5] - s[7])) < 1e-10:
        print('YES')
    else:
        print('NO')
import math

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

arr = [[0 for i in range(10)] for j in range(10)]

for i in range(N):
    x = list(map(int, input().split()))
    for j in range(0, D):
        array[i][j] = x[j];
sum_dis = 0
for i in range(0,N-1):
    for j in range(i+1,N):
        dis = 0
        for k in range(D):
            dis += (array[i][k] - array[j][k])**2
        dis = math.sqrt(dis)
        if(type(dis) == int): sum_dis += 1
print(sum_dis)

### FIXED CODE ###

import math

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

array = [[0 for i in range(10)] for j in range(10)]

for i in range(N):
    x = list(map(int, input().split()))
    for j in range(0, D):
        array[i][j] = x[j];
sum_dis = 0
for i in range(0,N-1):
    for j in range(i+1,N):
        dis = 0
        for k in range(D):
            dis += (array[i][k] - array[j][k])**2
        dis = math.sqrt(dis)
        if(dis.is_integer()): sum_dis += 1
print(sum_dis)
start = 0
for l in input():
    if start == 0:
        start += 1
    else:        
        l = list(map(int, input().split()))
        break
count = 0
for i in l:
    while True:
        if i%2 == 0:
            count += 1
            i = i/2
        else:
            break
print(count)

### FIXED CODE ###

l = input().split()
a = int(l[0])
b = int(l[1])
if (a>8) or (b>8):
    print(":(")
else:
    print("Yay!")
h, w = map(int, input().split())
hei = int(h / 2) if h % 2 == 0 else (int(h / 2) + 1)
wid = int(h / 2) if h % 2 == 0 else int((h - 1) / 2)
res = int(w / 2) * (hei + wid) if w % 2 == 0 else (int(w / 2) * (hei + wid)) + hei
print(res)


### FIXED CODE ###

arr = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(", ")
K = int(input())
print(arr[K-1])
a = input()
b = input()
max1 = max(a,b)
max2 = max(min(a,b),max(a,b)-1)
print(max1 + max2)

### FIXED CODE ###

a,b=map(int, input().split()) 
max1 = max(a,b)
max2 = max(min(a,b), max(a,b)-1)
 
print(max1+max2)
N = int(input())
S = str(input())
new_S = ""

for i in range(N):
    if S[i] == "#":
        S = S[i:]
        break
else:
    S = S

for i in reversed(S):
    new_S += i

for i in range(N):
    if new_S[i] == ".":
        S_new = S[i:]
        break
else:
    S_new = ""

print(min(S_new.count('#'), S_new.count('.'), len(S_new)))


### FIXED CODE ###

N = int(input())
S = str(input())

suu = []
s_count = S.count('.')
k_count = 0
suu.append(s_count + k_count)
for i in range(N):
    if S[i] == "#":
        k_count += 1
    else:
        s_count -= 1
    suu.append(k_count + s_count)

print(min(suu))
def solve(string):
    n, *a = map(int, string.split())
    return str(sum(a) - n)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


### FIXED CODE ###

def solve(string):
    n, *a = map(int, string.split())
    return str(sum(a) - n)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))
s = ['Sunny', 'Cloudy', 'Rainy']
print(s[index(input())+1 % 3])

### FIXED CODE ###

s = ['Sunny', 'Cloudy', 'Rainy']
print(s[(s.index(input())+1) % 3])
import sys
import numpy as np

sys.setrecursionlimit(10 ** 7)

r1, c1, r2, c2 = map(int, input().split())


# 階乗、Combinationコンビネーション(numpyを使う)

def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


MOD = 10 ** 9 + 7
U = 10**6 * 2 + 1
fact, fact_inv = make_fact(U, MOD)


def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod


def calc_rc(r, c):
    a = mod_comb_k(r + c + 2, r + 1, MOD)
    b = 1
    return a-b


ans = calc_rc(r2, c2) + calc_rc(r1-1, c1-1) - \
    calc_rc(r1-1, c2) - calc_rc(r2, c1-1)
ans %= MOD

print(ans)


### FIXED CODE ###

import sys
import numpy as np

sys.setrecursionlimit(10 ** 7)

r1, c1, r2, c2 = map(int, input().split())


# 階乗、Combinationコンビネーション(numpyを使う)

def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


MOD = 10 ** 9 + 7
U = 10**6 * 2 + 10
fact, fact_inv = make_fact(U, MOD)


def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod


def calc_rc(r, c):
    a = mod_comb_k(r + c + 2, r + 1, MOD)
    b = 1
    return a-b


ans = calc_rc(r2, c2) + calc_rc(r1-1, c1-1) - \
    calc_rc(r1-1, c2) - calc_rc(r2, c1-1)
ans %= MOD

print(ans)
x,a,b=map(int,input().split())
print(min(abs(x-a)),abs(x-b))

### FIXED CODE ###

x,a,b=map(int,input().split())
c=abs(x-a)
d=abs(x-b)
print('A' if c<d else 'B')
#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math


def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

primax = int(1e7) + 9 * int(1e6)
primes = get_prime(primax)




def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

debug = 1
for g,cnt in gc:
    debug *= g**cnt

if P > 1e9 and debug != P:
    raise "errror"
print(ans)


### FIXED CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math

if N == 1:
    print(P)
    exit(0)

def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

primax = int(1e7) + 9 * int(1e6)
primes = get_prime(primax)
# print(primes)



def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

debug = 1
for g,cnt in gc:
    debug *= g**cnt

# N > 100:  why WA
# debug < P: under 3 RE
# debug*2 > P:  None
if P > 1e9 and debug != P and  debug < P and N == 1:
    raise "errror"
print(ans)
import sys
from collections import deque
from collections import  Counter
import statistics
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = input()
k = ni()
li = []
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i:j+1] not in li:
            li.append(s[i:j+1])
li.sort()
print(li[k-1])

### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = input()
k = ni()
li = []
for i in range(len(s)):
    for j in range(i, i+k+1):
        li.append(s[i:j+1])
li = list(set(li))
li.sort()
print(li[k-1])
A=int(input())
B=int(input())
C=int(input())
if (A<C and C<B) or (A>C and C>B):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

b=[int(i) for i in input().split()]
if (b[0]<b[2] and b[2]<b[1]) or (b[0]>b[2] and b[2]>b[1]):
    print("Yes")
else:
    print("No")
n,a = map(int,input().split())
print(n*n-a)

### FIXED CODE ###

print(int(input())**2-int(input()))
X = input()
X = int(X)

while True:
  for x in range(2, n):
    if n % p == 0:
      break
  else:
    print(x)
    break
  x +=1

### FIXED CODE ###

x = int(input())
while True:
    for i in range(2,x):
        if x%i==0:
            break
    else:
        print(x)
        break
    x +=1
for i in range(1,10):
    for j in range(1,10):
        print(i,'X',j,'=',i*j,sep='')

### FIXED CODE ###

for i in range(1,10):
    for j in range(1,10):
        print('{l}x{r}={result}'.format(l=i,r=j,result=i*j))
import math

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

if (X+Y) % 3 != 0:
    print(0)
else:
    m = (2*X - Y) / 3
    n = (2*Y - X) / 3
    if m < 0 or n < 0:
        print(0)
    else:
        ans = math.factorial(m+n)% (1e+7 + 7) / (math.factorial(m) * math.factorial(n))
        print(int(ans))

### FIXED CODE ###

def cmb(m, n):
    if m - n < n:
        n = m - n
    if n == 0:
        return 1
    if n == 1:
        return m
    
    numerator = [m - n + k + 1 for k in range(n)]
    denominator = [k + 1 for k in range(n)]

    for p in range(2, n+1):
        pivot = denominator[p-1]
        if pivot > 1:
            offset = (m-n) % p
            for k in range(p-1, n, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    
    result = 1
    for k in range(n):
        if numerator[k] > 1:
            result = result * int(numerator[k]) % (10**9 + 7)

    return result

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

if (X+Y) % 3 != 0:
    print(0)
else:
    m = int((2*X - Y) / 3)
    n = int((2*Y - X) / 3)
    if m < 0 or n < 0:
        print(0)
    else:
        ans = cmb(m+n, n)
        print(int(ans))
H,A = map(int, input().split)
answer_1 = H // A
answer_2 = H % A
if answer_2 == 0:
    print(answer_1)
else:
    print(answer_1 + 1)

### FIXED CODE ###

H,A = map(int, input().split())
if H % A == 0:
    print(H // A)
else:
    print(H // A + 1)
n,m,d = map(int,input().split())

"""
#kuso code
start = time.time()
a = [random.randrange(n) for i in range(m)]
a = np.array(a)
b = np.abs(a[1:]-a[:-1])
cnt = np.sum(b == d)
ave = cnt

i = 0
while(time.time() - start < 10):
    a = [random.randrange(n) for i in range(m)]
    a = np.array(a)
    b = np.abs(a[1:]-a[:-1])
    cnt = np.sum(b == d)
    ave = ((i+1)*ave + cnt)/(i+2)
    i += 1
print(ave)
"""

oks*n = 2*np.max(n-2*d,0) + 2*d)
ave = oks*(m-1)/n/n
print(ave)

### FIXED CODE ###

import numpy as np

n,m,d = map(int,input().split())

"""
#kuso code
start = time.time()
a = [random.randrange(n) for i in range(m)]
a = np.array(a)
b = np.abs(a[1:]-a[:-1])
cnt = np.sum(b == d)
ave = cnt

i = 0
while(time.time() - start < 10):
    a = [random.randrange(n) for i in range(m)]
    a = np.array(a)
    b = np.abs(a[1:]-a[:-1])
    cnt = np.sum(b == d)
    ave = ((i+1)*ave + cnt)/(i+2)
    i += 1
print(ave)
"""

oks_times_n = 2*np.max(n-2*d,0) + 2*d
ave = oks_times_n/n/n*(m-1)
if (d == 0):
    ave /= 2
print(ave)