Harryxun/stf_run huggingface dataset:
N,K= map(int, input().split())
x = list(map(int, input().split()))
x.sort()
t = max(x)
y = x[0]
s = [1000000000000]
o=0
if x[0] == K:o=1
for i in range(1,len(x)):
    s.append(x[i]-x[i-1])
    if x[i] == K:o = 1
s.sort()
m = min(y,s[0])
if (t>= K and K%m==0) or o==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

N,K= map(int, input().split())
x = list(map(int, input().split()))
x = list(set(x))
x.sort()
t = max(x)
y = x[0]
s = [1000000000000]
o=0
if x[0] == K:o=1
for i in range(1,len(x)):
    s.append(x[i]-x[i-1])
    if x[i] == K:o = 1
s.sort()
m = min(y,s[0])
if (t>= K and K%m==0) or o==1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
import numpy as np

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

"""
任意の2組みの数字の符号を変えることができる
したがって負の数が偶数個の場合全てを正にして総和をとれば良い
負の数が奇数個の場合絶対値の最小のもののみ負にして総和をとればよい
0が存在する場合はすべて正にできる
"""

A_abs = np.abs(A)

if 0 in A:
    print(np.sum(A_abs))

else:
    num = 0
    for i in range(N):
        if A[i] < 0:
            num += 1

    if num % 2 == 0:
        print(np.sum(A_abs))
    else:
        print(np.sum(A_abs) - 2 * min(A_abs))



### FIXED CODE ###

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

N = 1
for i in range(100):
    if N * A > T + 0.5:
        N -= 1
        break

    N += 1

ret = N * B
print(ret)
n = int(input())
dic = {}　#空の辞書を定義
def combinations_count(n,r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0

for k in dic.values():
    ans += combinations_count(k,2)

print(ans)


### FIXED CODE ###

import math
n = int(input())
dic = {}
def combinations_count(n,r):
    return math.factorial(n) // (math.factorial(n - r)*math.factorial(r))

for index in range(n):
    temp = ''.join(sorted(list(input())))
    #入力された文字列をa-z順にソートし、変数tempに代入
    if temp in dic:
        dic[temp] = dic[temp] + 1
        #すでに同じ文字列の入力があれば、key:tempのvalueに+1
    else:
        dic[temp] = 1
        #新しい文字列の場合は文字列とvalue＝1を辞書に追加
ans = 0

for k in dic.values():
    if k >= 2:
        ans += combinations_count(k,2)
    else:
        ans = ans
print(ans)
import sys
input = sys.stdin.buffer.readline
R,C,K = map(int,input().split())
goods = [[-1]*(C+1) for _ in range(R+1)]
INF = 10**16
for i in range(K):
    ri,ci,vi = map(int,input().split())
    goods[ri][ci] = vi
DP = [[[-INF,-INF,-INF,-INF] for _ in range(C+1)] for _ in range(R+1)]
DP[1][1][0] = 0
if goods[1][1] != -1:
    DP[1][1][1] = goods[1][1]
for j in range(1,C):
    DP[1][j+1][0] = 0
    if goods[1][j+1] != -1:
        for k in range(1,3):
        DP[1][j+1][k] = max(DP[1][j][k],DP[1][j][k-1]+goods[1][j+1])
    else:
        for k in range(1,3):
        DP[1][j+1][k] = DP[1][j][k]
for i in range(1,R):
    DP[i+1][1][0] = max(DP[i][1])
    if goods[i+1][1] != -1:
        DP[i+1][1][1] = DP[i+1][1][0] + goods[i+1][1]
for i in range(2,R+1):
    for j in range(2,C+1):
        DP[i][j][0] = max(max(DP[i-1][j]),DP[i][j-1][0])
        if goods[i][j] != -1:
            DP[i][j][1] = max(DP[i][j][0]+goods[i][j],DP[i][j-1][1])
            DP[i][j][2] = max(DP[i][j-1][2],DP[i][j-1][1]+goods[i][j])
            DP[i][j][3] = max(DP[i][j-1][3],DP[i][j-1][2]+goods[i][j])
        else:
            for i in range(1,3):
            DP[i][j][k] = DP[i][j-1][k]
print(max(DP[R][C]))

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
R,C,K = map(int,input().split())
goods = [[0]*(C+1) for _ in range(R+1)]
INF = 10**18
for i in range(K):
    ri,ci,vi = map(int,input().split())
    goods[ri][ci] = vi
DP = [[[-INF]*(C+1) for _ in range(R+1)] for _ in range(4)]
DP[0][1][1] = 0
if goods[1][1]:
    DP[1][1][1] = goods[1][1]
for j in range(1,C):
    DP[0][1][j+1] = 0
    if goods[1][j+1]:
        DP[1][1][j+1] = max(DP[1][1][j],DP[0][1][j]+goods[1][j+1])
        DP[2][1][j+1] = max(DP[2][1][j],DP[1][1][j]+goods[1][j+1])
        DP[3][1][j+1] = max(DP[3][1][j],DP[2][1][j]+goods[1][j+1])
    else:
        DP[1][1][j+1] = DP[1][1][j]
        DP[2][1][j+1] = DP[2][1][j]
        DP[3][1][j+1] = DP[3][1][j]
for i in range(1,R):
    DP[0][i+1][1] = max(DP[0][i][1],DP[1][i][1],DP[2][i][1],DP[3][i][1])
    if goods[i+1][1]:
        DP[1][i+1][1] = DP[0][i+1][1] + goods[i+1][1]
for i in range(2,R+1):
    for j in range(2,C+1):
        DP[0][i][j] = max(DP[0][i-1][j],DP[1][i-1][j],DP[2][i-1][j],DP[3][i-1][j],DP[0][i][j-1])
        if goods[i][j]:
            DP[1][i][j] = max(DP[0][i][j]+goods[i][j],DP[1][i][j-1])
            DP[2][i][j] = max(DP[2][i][j-1],DP[1][i][j-1]+goods[i][j])
            DP[3][i][j] = max(DP[3][i][j-1],DP[2][i][j-1]+goods[i][j])
        else:
            DP[1][i][j] = DP[1][i][j-1]
            DP[2][i][j] = DP[2][i][j-1]
            DP[3][i][j] = DP[3][i][j-1]
print(max(DP[0][R][C],DP[1][R][C],DP[2][R][C],DP[3][R][C]))
X=int(input())
A=X//100
B=X%100

if B <= A *5:
    print(1)
else:
    print(0)


### FIXED CODE ###

# coding: utf-8
# Your code here!

one = input().split()

two = input().split()

if one[0] != two[0]:
    print(1)
else:
    print(0)
a = int(a)
b = int(b)
c = a * b

if c % 2 == 0:
  print("even")
else:
  print("odd")

### FIXED CODE ###

a,b = map(int, input() .split())
if (a*b) % 2 == 0:
  print("Even")
else:
  print("Odd")
input = int(input())
nums = []
max = 0
total = 0
for x in range(input):
  nums.append(int(input()))
print(sum(nums)-max(nums) + max(nums)/2)

### 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 = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2]+A[N//2+1])/2
    BB = (B[N//2-1]+B[N//2+1-1])/2
    print(BB-AA+1)

### FIXED CODE ###

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

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2-1]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2-1]+A[N//2])/2
    BB = (B[N//2-1]+B[N//2])/2
    print(int((BB-AA)*2+1))
import itertools
import math


def lcm(left,right):
    return (int(left) * int(right)) / int(math.gcd(left,right))


N = int(input().strip())
Ts = []
for i in range(N):
    Ts.append(int(input().strip()))

res = int(lcm(Ts[0], Ts[1]))
for T in Ts[2:]:
    res = int(lcm(res, T))

print(int(res))




### FIXED CODE ###

import itertools
import math


def gcd(a,b):
    while b:
        a, b = b, a % b
    return a


def lcm(left, right):
    return (left * right) // gcd(left, right)


N = int(input().strip())
Ts = []
for i in range(N):
    Ts.append(int(input().strip()))

res = 0
if len(Ts) == 0:
    res = 0
elif len(Ts) == 1:
    res = Ts[0]
else:
    res = int(lcm(Ts[0], Ts[1]))
    for T in Ts[2:]:
        res = int(lcm(res, T))

print(str(int(res)))
def knapsack():
    n, max_w = map(int, input().split())
    dp = defaultdict(int)
    dp[0] = 0
    for _ in range(n):
        w, v = map(int, input().split())
        for item in list(dp.keys()):
            dp[item+w] = max(dp[item] + v, dp[item+w])
    max_v = 0
    for w, v in dp.items():
        if w <= max_w:
            max_v = max(v, max_v)
    print(max_v)
    
    
knapsack()

### FIXED CODE ###

import sys
input = sys.stdin.readline

N, W = [int(i) for i in input().split()]

def ans(N, W):
    d = [float("inf")] * (N * 1000 + 1)
    d[0] = 0
    V = 0

    for i in range(N):
        wi, vi = [int(i) for i in input().split()]
        V = V + vi

        for v in range(V, vi-1, -1):
            w_ = d[v - vi] + wi
            if w_ < d[v]:
                d[v] = w_

    for v in range(V, -1, -1):
        if d[v] <= W:
            return v

print(ans(N, W))
n = int(input())
s = sum(map(int,(list(str(n))))

if n % s == 0:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

n = int(input())
s = sum(map(int, list(str(n))))

if n % s == 0:
  print("Yes")
else:
  print("No")
s=[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]
k=int(input())
print(s[k+1])


### FIXED CODE ###

s=[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]
k=int(input())
print(s[k-1])
import functools
import sys

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))


def gcd(x, y):
    if x == 0:
        return y

    return gcd(y % x, x)


# 2数を受け取って最小公倍数を返す関数
def lcm(a, b):
    y = a * b / gcd(a, b)
    return int(y)


# 可変引数を受け取って最小公倍数を返す関数
def lcm_2(vals):
    return functools.reduce(lcm, vals)


lc = lcm_2(a)
ans = 0
a = 1
while True:
    if lc * a <= m:
        ans += 1
        a += 2
    else:
        break

print(ans)


### FIXED CODE ###

import functools
import sys

n, m = map(int, input().split())
a = list(map(lambda x: x // 2, map(int, input().split())))

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0

a_0 = a[0]
while a_0 % 2 == 0:
    a_0 /= 2
    div += 1

# print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(a)):
    div2 = 0
    tmp_a = a[i]
    while tmp_a % 2 == 0:
        tmp_a /= 2
        div2 += 1
    # print("A[" + str(i) + "] count = " + str(div2))#
    if div2 != div:
        print("0")
        sys.exit()


def gcd(x, y):
    if x == 0:
        return y

    return gcd(y % x, x)


def least_common_multiple(iter):
    '''
    最小公倍数を返す
    '''
    lcm = lambda x, y: x * y // gcd(x, y)
    return functools.reduce(lcm, iter)


lc = least_common_multiple(a)
ans = 0
a = 1

ans = m // lc
if ans == 0:
    print(0)
    sys.exit()
if ans % 2 == 0:
    print(ans // 2)
else:
    print(ans // 2 + 1)
N = int(input())
h = [int(i) for i in input().split()]

def jump(now,h,cost):
    if now == len(h)-2: #ゴール一歩手前
        return cost + abs(h[-1] - h[now])
    elif now == len(h)-1: #ゴールについた時
        return cost

    cost1 = jump(now+1,h,cost)
    cost2 = jump(now+2,h,cost)
    if cost1 <= cost2:
        return cost1 + abs(h[now] - h[now+1])
    else: return cost2 + abs(h[now] - h[now+2])

cost = 0
print(jump(0,h,0))

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
inf = 10 ** 10
dp = [inf] * n
dp[0] = 0
for i in range(n - 1):
    temp = abs(h[i + 1] - h[i])
    dp[i + 1] = min(dp[i + 1], temp + dp[i])
    if i + 2 < n:
        temp = abs(h[i + 2] - h[i])
        dp[i + 2] = min(dp[i + 2], temp + dp[i])
print(dp[-1])
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
gu = [::2]
ki = [1::2]
ans = 0
k,g = False,False

if v.count(v[0]) == n:#全部同じ
    ans += n // 2
else:
    kic = Counter(ki)
    guc = Counter(gu)
    k1 = kic.most_common(2)
    g1 = guc.most_common(2)
    if k1[0][0] == g1[0][0]:
        if k1[1][1] < g1[1][1]:
            k = True
        elif k1[1][1] > g1[1][1]:
            g = True

    kic = list(kic.values())
    guc = list(guc.values())
    kic.sort(reverse = True)
    guc.sort(reverse = True)
    if len(kic) != 1:
        if k:
            ans += kic[0]
            ans += sum(kic[2::])
        else:
            ans += sum(kic[1::]) 
    if len(guc) != 1:
        if g:
            ans += guc[0]
            ans += sum(guc[2::])
        else:
            ans += sum(guc[1::])

print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
v = list(map(int, input().split()))
gu = v[::2]
ki = v[1::2]
ans = 0
k,g = False,False

if v.count(v[0]) == n:#全部同じ
    ans += n // 2
else:
    kic = Counter(ki)
    guc = Counter(gu)
    k1 = kic.most_common(2)
    g1 = guc.most_common(2)
    if k1[0][0] == g1[0][0]:
        if k1[1][1] < g1[1][1]:
            k = True
        else:
            g = True

    kic = list(kic.values())
    guc = list(guc.values())
    kic.sort(reverse = True)
    guc.sort(reverse = True)
    if len(kic) != 1:
        if g:
            ans += kic[0]
            ans += sum(kic[2::])
        else:
            ans += sum(kic[1::]) 
    if len(guc) != 1:
        if k:
            ans += guc[0]
            ans += sum(guc[2::])
        else:
            ans += sum(guc[1::])

print(ans)
moji="abcdefghijklmnopqrstuvwxyz"
N=int(input())
def f(N):
    if N<=26:
        return moji[n-1]
    return f(N//26)+moji[N%26-1]

print(f(N))
    

### FIXED CODE ###

t="abcdefghijklmnopqrstuvwxyz"
n=int(input())
def f(n):
    if n<=26:
        return t[n-1]
    return f((n-1)//26)+t[(n-1)%26]

print(f(n))
from bisect import bisect_left
from collections import deque
import sys

sys.setrecursionlimit(10000)

N = int(input())

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

graph = [[] for _ in range(N)]

for _ in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

INF = 10**11
ans = [0]*N
dp = []###INFは空欄として扱って良い
stack = deque([])

def LISonTree(num,pre):
    ###num: 頂点番号
    ###pre: 1つ前にいた頂点番号
    p = bisect_left(dp,a[num])

    ###
    #print(p)
    ###

    if p >= len(dp):
        stack.appendleft((len(dp),INF))
        dp.append(a[num])
    else:
        stack.appendleft((p,dp[p]))
        dp[p] = a[num]
    
    q = bisect_left(dp,INF)
    ans[num] = q

    ###
    #print(num,'dp',dp)
    #print(num,'ans',ans)
    ###

    for x in graph[num]:
        if x == pre:
            continue
        LISonTree(x,num)
    
    changed_p, changed_v = stack.popleft()

    dp[changed_p] = changed_v

    ###
    #print(num,'dp',dp)
    ###

LISonTree(0,-1)
#print(ans)

for y in ans:
    print(y)

### FIXED CODE ###

from bisect import bisect_left
from collections import deque
import sys

sys.setrecursionlimit(200001)

N = int(input())

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

graph = [[] for _ in range(N)]

for _ in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

INF = 10**11
ans = [0]*N
dp = []###INFは空欄として扱って良い
stack = deque([])

def LISonTree(num,pre):
    ###num: 頂点番号
    ###pre: 1つ前にいた頂点番号
    p = bisect_left(dp,a[num])

    ###
    #print(p)
    ###

    if p >= len(dp):
        stack.appendleft((len(dp),INF))
        dp.append(a[num])
    else:
        stack.appendleft((p,dp[p]))
        dp[p] = a[num]
        
    
    q = bisect_left(dp,INF)
    ans[num] = q

    ###
    #print(num,'dp',dp)
    #print(num,'ans',ans)
    ###

    for x in graph[num]:
        if x == pre:
            continue
        LISonTree(x,num)
    
    changed_p, changed_v = stack.popleft()

    dp[changed_p] = changed_v

    ###
    #print(num,'dp',dp)
    ###

LISonTree(0,-1)
#print(ans)

for y in ans:
    print(y)
A,B=map(int,input().split())

if B%A==0:
  ptint(A+B)
else:
  print(B-A)


### FIXED CODE ###

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

if B%A==0:
  print(A+B)
else:
  print(B-A)
t, x = map(int, input.split())
print(t/x)

### FIXED CODE ###

t, x = map(int, input().split())
print(t/x)
N = int(input())
A=list(map(int,input().split()))
i=0
ask=0
for x in A:
    if A[x+1]-A[x]<0:
        A[x]=A[x]-1
for x in A:
    if A[x]<0:
        ask=1
        break
if ask==0:
    print('Yes')
else:
    print('No')



### FIXED CODE ###

N = int(input())
A=list(map(int,input().split()))
ask=0
#N-1~1までループ
for x in range(N-1,0,-1):
    if A[x]-A[x-1]<0:
        A[x-1]=A[x-1]-1
for x in range(1,N):
    if A[x]-A[x-1]<0:
        ask=1
        break
if ask==0:
    print('Yes')
else:
    print('No')
n = input()
integer = list(map(int, input().split()))

min = integer[0]
max = integer[0]
sum = 0

for i in range(len(integer)):
    if max<i:
        max = i
    if i < min:
        min = i
    sum += i

print(min+" "+ max +" "+ sum)

### FIXED CODE ###

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

min = integer[0]
max = integer[0]
sum = 0
for i in integer:
    if max<i:
        max = i
    if i < min:
        min = i
    sum += i

print(str(min)+" "+ str(max) +" "+ str(sum))
a=input()
b=input()
print a*b, 2*a+2*b

### FIXED CODE ###

a,b = map(int, raw_input().split())
print a*b, 2*a+2*b
N, = map(int, input().split())
xs = list(map(int, input().split()))
r = 0
for k in range(1, N):
    a = (N-1) % k
    if a <= k:
        a += k
    if a <= k:
        a += k

    for _ in range((N-1-a)//k):
        b = a - k
        n = (N-1-a)//k
        if a <= b:
            a += k
            continue
        if a%(a-b) == 0:
            if a <= (a-b)*n:
                a += k
                continue
    if a <= b or a >= N-1:
        continue
    s1 = a
    s2 = n * (a-b)
    t = xs[s1]
    ps = [(s1,t)]
    for i in range(n):
        s1 += a-b
        t += xs[s2]
        t = max(t,0)
        t += xs[s1]
        ps.append((s2,xs[s2]))
        ps.append((s1,xs[s1]))
        s2 -= a-b
    #print(ps, t)
    r = max(r, t)

print(r)

### FIXED CODE ###

N, = map(int, input().split())
xs = list(map(int, input().split()))
r = 0
for k in range(1, N):
    a = (N-1) % k
    b = a - k
    n = (N-1-a)//k
    if a <= k:
        a += k
    if a <= k:
        a += k

    for _ in range((N-1-a)//k):
        b = a - k
        n = (N-1-a)//k
        if a <= b:
            a += k
            continue
        if a%(a-b) == 0:
            if a <= (a-b)*n:
                a += k
                continue
    if a <= b or a >= N-1:
        continue
    s1 = a
    s2 = n * (a-b)
    t = xs[s1]
    ps = [(s1,t)]
    for i in range(n):
        s1 += a-b
        t += xs[s2]
        t = max(t,0)
        t += xs[s1]
        ps.append((s2,xs[s2]))
        ps.append((s1,xs[s1]))
        s2 -= a-b
    #print(ps, t)
    r = max(r, t)

print(r)
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

lst=[int(n[i]) for i in range(n)]
n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
dp=[[float('inf')]*2 for i in range(keta+1)]
dp[0]=[0,1]

for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))


### FIXED CODE ###

import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=input()
lst=[]
for i in range(len(n)):
    lst.append(int(n[i]))
# n=int(n)

keta=len(lst)
ans=0
lst.reverse()
# print(lst)
# dp=[[float('inf')]*2 for i in range(keta+1)]
dp=[]
for i in range(keta+1):
    dp.append([float('inf')]*2)
dp[0]=[0,1]
# print(dp)
for i in range(keta):
    dp[i+1][0]=min(dp[i][0]+lst[i],dp[i][1]+lst[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-lst[i]),dp[i][1]+(10-lst[i]-1))
# print(dp)
print(min(dp[-1][0],dp[-1][1]+1))
N = int(input())
A = list(map(int,input().split()))
if N <= 2:
    print(1)
    exit()
d = [A[i+1] - A[i] for i in range(N-1)]
def judge(list_hoge = d,count = 1):
    for i in range(1,len(list_hoge)):
        if list_hoge[i] * list_hoge[0] < 0:
            return judge(list_hoge[i+1:],count + 1)
    print(count)
judge()

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
state = 0
count = 1
for i in range(1,N):
    note = state
    d = A[i] - A[i-1]
    if d > 0:
        state = 1
    elif d == 0:
        pass
    elif d < 0:
        state = -1
    if (state,note) == (1,-1) or (state,note) == (-1,1):
        count += 1
        state = 0
print(count)
N = int(input())
S = input()
ans = ""
for s in S:
  ans += chr((ord(S) + N - 65)%26 + 65)
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = ""
for s in S:
  ans += chr((ord(s) + N-65)%26 + 65)
print(ans)
import math
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
t = []
b = []
u = []
for i in a:
	if(i%10 == 0):
		b.append(i)
	else:
		t.append(i)
		u.append(i%10)
min_t = u.index(min(u))
ss = t.pop(min_t)
u.pop(min_t)

for i in range(len(t)): 
	u[i] = 10 - u[i]
	t[i] = t[i] + u[i]
print(sum(b) + sum(t) + ss)

### FIXED CODE ###

import math
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
t = []
b = []
u = []
for i in a:
	if(i%10 == 0):
		b.append(i)
	else:
		t.append(i)
		u.append(i%10)
if(sum(u) != 0):
	min_t = u.index(min(u))
	ss = t.pop(min_t)
	u.pop(min_t)

	for i in range(len(t)): 
		u[i] = 10 - u[i]
		t[i] = t[i] + u[i]
	print(sum(b) + sum(t) + ss)

else:
	print(sum(b))
S = input()
T = input()

if T in S:
    print("0")
else:
    slen = len(S)
    tlen = len(T)
    ansCnt = tlen

    for i in range(slen-tlen):
        cnt = 0
        for j in range(tlen):
            if T[j]!=S[i+j]:
                cnt += 1
        
        if ansCnt>cnt:
            ansCnt = cnt

print(ansCnt)


### FIXED CODE ###

S = input()
T = input()

if T in S:
    print("0")
else:
    slen = len(S)
    tlen = len(T)
    ansCnt = tlen

    for i in range(slen-tlen+1):
        cnt = 0
        for j in range(tlen):
            if T[j]!=S[i+j]:
                cnt += 1
        
        if ansCnt>cnt:
            ansCnt = cnt

    print(ansCnt)
def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    L=range(1,m+1)
    j=0
    if m==n==0:break
    for i in range(1,n+1):
	c=raw_input()
	if len(L)==1:break
        if Judge(i)!=c:
            del L[j]
            j%=len(L)
        else:
            j=(j+1)%len(L)
    print " ".join(map(str,L))

### FIXED CODE ###

def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))
s = input()
K = int(input())

ans = []
for i in range(len(s)):
  for j in range(len(s)-i):
    c = s[j:j+i+1]
    if c.count(c[0]) == len(c):
      c = c[0]
    if c not in ans:
      ans.append(s[j:j+i+1])
ans.sort()
print(ans[K-1])

### FIXED CODE ###

s = input()
K = int(input())
S = set()
ans = []
for i in range(K):
  for j in range(len(s)-i):
    c = s[j:j+i+1]
    S.add(c)
  
set_ans = sorted(list(S))
print(set_ans[K-1])