Harryxun/stf_run huggingface dataset:
N = int(input())
A = list(map(int,input().split()))
C = sort(A)
B = set(C)
K = len(set(A))
k = 1
a = 0
b = []
while i in B:
    j = A.index(i)
    if i != k:
        break
    a += j+1
    b.append(a)
    a = A[j+1:]
    if a == N:
        break
    k += 1
    
if b == []:
    print(-1)
else:
    print(N-len(b))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
c = 0
for a in A:
    if a == c + 1:
        c = a
    
if c == 0:
    print(-1)
else:
    print(N-c)
N,T=map(int, input().split())
ans=9999
for i inrange(N):
  A,B=map(int, input().split())
  if (T>B):
    if(ans>A):
      ans=A
if(ans==9999):
  print("TLE")
else:
  print(ans)

### FIXED CODE ###

N,T=map(int, input().split())
ans=9999
for i in range(N):
  A,B=map(int, input().split())
  if (T>=B):
    if(ans>=A):
      ans=A
if(ans==9999):
  print("TLE")
else:
  print(ans)
a, b, c = sorted(map(int, input().split()))

if a + b + c == 5, 5, 7:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input().split(" ")
if s.count('5') == 2 and s.count('7') == 1:
	print("YES")
else:
	print("NO")
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      continue
    cnt=0
    for dx in [-1,0,1]:
      for dy in [-1,0,1]:
        if not(0<=dx+i<=h and 0<=dy+j<=w):
          continue
        if s[i+dx][j+dy]=='#':
          cnt+=1
    s[i][j]=str(cnt)
for m in s:
  print(''.join(m))

### FIXED CODE ###

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

for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      continue
    cnt=0
    for dx in [-1,0,1]:
      for dy in [-1,0,1]:
        if not(0<=dx+i<=h-1 and 0<=dy+j<=w-1):
          continue
        if s[i+dx][j+dy]=='#':
          cnt+=1
    s[i][j]=str(cnt)
for m in s:
  print(''.join(m))
n = int(input())
a = [int(input()) for i in range(n)]
res = 0
temp_max = 0
for x in a:
    if temp_max > x:
        res += temp_max - x
    temp_max = max(temp_max,x)

print(res)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
res = 0
temp_max = 0
for x in a:
    if temp_max > x:
        res += temp_max - x
    temp_max = max(temp_max,x)

print(res)
a=input()
b=input()
m=""
for i in range(len(a)):
    m=m+a[i]+b[i]
    i +=1
print(m)

### FIXED CODE ###

a=list(input())
b=list(input())+[""]
for x,y in zip(a,b):
    print(x+y, end="")
def main():
    x, y = map(int, input().split())
    def get_prize(a):
        if a==1:
            return 300_000
        elif a==2:
            return 200_000
        elif a==3:
            return 100_000
        else:
            return 0
    a = 0
    a += get_prize(x)
    a += get_prize(y)
    a = a + 400_000 if a==600_000 else a
    print(a)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    x, y = map(int, input().split())
    def get_prize(a):
        if a==1:
            return 300000
        elif a==2:
            return 200000
        elif a==3:
            return 100000
        else:
            return 0
    a = 0
    a += get_prize(x)
    a += get_prize(y)
    a = a + 400000 if a==600000 else a
    print(a)

if __name__ == "__main__":
    main()
# ABC141
def main():
    N, M, *A = map(int, open(0).read().split())
    if N == 1:
        ans = A[0] >> M
        print(ans)
        return
    A.append(0), A.sort(reverse=1)
    cur, prev = 0, 0
    for _ in range(M):
        x, y = A[cur] >> 1, A[cur + 1] >> 1
        if x > y:
            A[cur] = x
        else:
            A[cur + 1] = y
        if A[cur + 2] >= A[cur]:
            cur += 1
    ans = sum(A)
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC141D - Powerful Discount Tickets
from heapq import heapify, heappop, heappush


def main():
    N, M, *A = map(int, open(0).read().split())
    B = [-i for i in A]
    heapify(B)
    for _ in range(M):
        x = -heappop(B) >> 1
        heappush(B, -x)
    ans = -sum(B)
    print(ans)


if __name__ == "__main__":
    main()
n=int(input())


a=int(input())


print(int(n-a+1))

### FIXED CODE ###

n,i=map(int,input().split())
print (n-i+1)

#comment
w = list(map(input().split()))
n = list(map(int, input().split()))
u = input()

if u == w[0]:
  print(n[0]-1,n[1])
else:
  print(n[0],n[1]-1)

### FIXED CODE ###

w = list(input().split())
n = list(map(int, input().split()))
u = input()

if u == w[0]:
  print(n[0]-1,n[1])
else:
  print(n[0],n[1]-1)
A, B = map(int, input())
print(max(A - 2 * B, 0))

### FIXED CODE ###

A, B = map(int, input().split())
print(max(A - 2 * B, 0))
s, t = input().split()
print(" ".join(t, s))

### FIXED CODE ###

s, t = input().split()
print( t + s)
def main():
	s = input().strip()
	a = s[0]
	b = s[1]
	if (b/a)*a == b:
		print(a+b)
	else:
		print(b-a)

if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	a,b = map(int, input().split())
	if (b % a) == 0:
		print(a+b)
	else:
		print(b-a)

if __name__ == '__main__':
	main()
S = str(input())
K = int(input())
N = len(S)

count1 = 0
x = "A"
con = 1
#仮に1回でもダメなやつ
for i in range(N):
  if x == S[i]:
    con += 1 
  else:
    x = S[i]
    if con != 1:
      count1 += con //2
    con = 1
  #print(count1, i)
if con != 1:
  count1 += con //2
  
if con == N:
  print(N * K // 2)
  quit()
#print(count1)
count2 = 0
if S[0] == S[-1]:
  p = 0
  q = 0
  count0 = 1
  countf = 1
  i = 0
  j = -1
  while p == 0:
    if S[i] == S[i + 1]:
      count0 += 1
      i += 1
    else:
      p = 1
  while q == 0:
    if S[j] == S[j - 1]:
      countf += 1
      j -= 1
    else:
      q = 1

if (count0 % 2 == 1) and (countf % 2 == 1):
  count2 = 1
print(count1 * K + count2 * (K - 1))
    

### FIXED CODE ###

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

count1 = 0
x = "A"
con = 1
#仮に1回でもダメなやつ
for i in range(N):
  if x == S[i]:
    con += 1 
  else:
    x = S[i]
    if con != 1:
      count1 += con //2
    con = 1
  #print(count1, i)
if con != 1:
  count1 += con //2
  
if con == N:
  print(N * K // 2)
  quit()
#print(count1)
count2 = 0
count0 = 0
countf = 0
if S[0] == S[-1]:
  p = 0
  q = 0
  count0 = 1
  countf = 1
  i = 0
  j = -1
  while p == 0:
    if S[i] == S[i + 1]:
      count0 += 1
      i += 1
    else:
      p = 1
  while q == 0:
    if S[j] == S[j - 1]:
      countf += 1
      j -= 1
    else:
      q = 1

if (count0 % 2 == 1) and (countf % 2 == 1):
  count2 = 1
print(count1 * K + count2 * (K - 1))
import collections

s = input()

c = collections.Counter(s)

if len(c) == 1:
  print("Yes")
elif len(c) == 2:
  if (c.values()[0] == 1) | (c.values()[0] == 3):
    print("Yes")
  else:
    print("No")
else:
  print("No")

### FIXED CODE ###

s = input()

if s[0] == s[1] == s[2]:
  print("Yes")
elif s[3] == s[1] == s[2]:
  print("Yes")
else:
  print("No")
def solve():
    N = int(input())
    S = [0 if i == 'o' else 1 for i in input()]
    
    for i, j in product(range(2), repeat=2):
        pat = [i, j] + [0]*(N - 2)
        for k in range(2, N):
            pat[k] = (S[k - 1] - (pat[k - 1] + pat[k - 2])) % 2

        if S[-1] != (pat[0] + pat[-1] + pat[-2]) % 2:
            continue
        if S[0] != (pat[1] + pat[0] + pat[-1]) % 2:
            continue

        ans = ['S' if pat[k] == 0 else 'W' for k in range(N)]
        print(''.join(ans))
        return None

    print(-1)

if __name__ == '__main__':
    solve()

### FIXED CODE ###

from itertools import product

def solve():
    N = int(input())
    S = [0 if i == 'o' else 1 for i in input()]
    
    for i, j in product(range(2), repeat=2):
        pat = [i, j] + [0]*(N - 2)
        for k in range(2, N):
            pat[k] = (S[k - 1] - (pat[k - 1] + pat[k - 2])) % 2

        if S[-1] != (pat[0] + pat[-1] + pat[-2]) % 2:
            continue
        if S[0] != (pat[1] + pat[0] + pat[-1]) % 2:
            continue

        ans = ['S' if pat[k] == 0 else 'W' for k in range(N)]
        print(''.join(ans))
        return None

    print(-1)

if __name__ == '__main__':
    solve()
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    r = int(r)
    if r < 1200:
        print('ABC')
    elif r < 2800
        print('ARC')
    else:
        print('AGC')

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    r = int(r)
    if r < 1200:
        print('ABC')
    elif r < 2800:
        print('ARC')
    else:
        print('AGC')

if __name__ == '__main__':
    main()
import numpy as np


def taste(N, L):
    all_abs = np.array([np.abs(L + i - 1) for i in range(1, N + 1)])
    all_base = np.array([L + i - 1 for i in range(1, N + 1)])

    return all_abs, all_base

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

all_abs, all_base = taste(N, L)

N_1_all = all_base[np.min(all_abs) != all_abs]

re = np.sum(N_1_all)
print(re)


### FIXED CODE ###

import numpy as np
 
 
def taste(N, L):
    all_abs = np.array([np.abs(L + i - 1) for i in range(1, N + 1)])
    all_base = np.array([L + i - 1 for i in range(1, N + 1)])
 
    return all_abs, all_base
 
N, L = map(int, input().split())
 
all_abs, all_base = taste(N, L)
 
N_1_all = all_base[np.min(all_abs) != all_abs]
 
re = np.sum(N_1_all)
print(re)
x, y = map(int, input().split())
diff = abs(abs(x)-abs(y))

elif abs(x) < abs(y):
  if x < 0 and y < 0:
    diff += 2
  elif x > 0 and y < 0:
    diff += 1
  elif x < 0 and y > 0:
    diff += 1
else:
  if x > 0 and y > 0:
    diff += 2
  elif x < 0 and y > 0:
    diff += 1
  elif x > 0 and y < 0:
    diff += 1
  

print(diff)

### FIXED CODE ###

x, y = map(int, input().split())
diff = abs(abs(x)-abs(y))

if abs(x) < abs(y):
  if x < 0:
    diff += 1
  if y < 0:
    diff += 1
else:
  if x > 0:
    diff += 1
  if y > 0:
    diff += 1
print(diff)
s = input()
if(s[0]==s[1]):
    print("Bad")
elif(s[1]==s[2]):
    print("Bad")
elif(s[2]==s[3]):
    print("Bad")
elif(s[3]==s[4]):
    print("Bad")
else:
    print("Good")

### FIXED CODE ###

s = input()
if(s[0]==s[1]):
    print("Bad")
elif(s[1]==s[2]):
    print("Bad")
elif(s[2]==s[3]):
    print("Bad")
else:
    print("Good")
print(["No","Yes"][int("7" in input())]

### FIXED CODE ###

print(["No","Yes"][int("7" in input())])
n=int(input())
a=[int(input()) for i in range(n)]
print(int(sum(a)-max(a)/2))

### FIXED CODE ###

a=int(input())
if 22<=a<=25:
	print("Christmas"+" Eve"*(25-a))
n = int(input())
h = list(map(int, input().split()))
l = [h[0]]
ans = 1
for i in h[1:]:
    for j in l:
        if i>=j:
            l.append(i)
print(len(i))


### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
l = [str(h[0])]
for i in h[1:]:
        if i>=int(sorted(l)[-1]):
            i = str(i)
            l.append(i)
print(len(l))
n = int(input())
if n % 2:
    print(0)
else:
    ans, x = 0, 5
    while(x <= n):
        ans += ((n // x) // 2)
        x *= 5
print(ans)


### FIXED CODE ###

n = int(input())
if n % 2:
    print(0)
else:
    ans, x = 0, 5
    while(x <= n):
        ans += ((n // x) // 2)
        x *= 5
    print(ans)
n = int(input())
A = [int(input()) for _ in range(n)]
def f(x):
    cnt = 0
    for i in range(len(x) - 1):
        cnt += abs(x[i] - x[i + 1])
    return cnt
ans = []
for B in permutations(A):
    ans.append((f(B), B))
ans.sort(reverse=True)
print(ans[0][0])

### FIXED CODE ###

def solve():
    n = int(input())
    a = sorted(int(input()) for _ in range(n))
    c0 = n // 2 - 1
    c1 = n // 2
    c2 = n // 2 + 1
    ans = 0
    if n & 1:
        for i in range(c0):
            ans -= a[i] * 2
        for i in range(c2 + 1, n):
            ans += a[i] * 2
        ans += -a[c0] + a[c2] + max(-a[c0] + a[c1], - a[c1] + a[c2])
    else:
        for i in range(c0):
            ans -= a[i] * 2
        for i in range(c1 + 1, n):
            ans += a[i] * 2
        ans += -a[c0] + a[c1]
    return ans
print(solve())
n = int(input())

x,y = [input().split() for i in range(n)]
x = list(map(int, x))
y = list(map(int, y))
s = 0
for i in range(n):
    for j in range(i+1, n):
        s += ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5
print(s*2/n)

### FIXED CODE ###

n = int(input())

xy = [list(map(int, input().split())) for i in range(n)]
s = 0
for i in range(n):
    for j in range(i+1, n):
        s += ((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)**0.5
print(s*2/n)
N, M = map(int, input().split())

S = []
C = []

condition = [-1] * M

for _ in range(M):
    s, c = map(int, input().split())
    #S.append(s)
    #C.append(C)
    if condition[s-1] != c and condition[s-1] != -1:
        print('-1')
        exit()
    condition[s-1] = c

for i, v in enumerate(condition):
    if v == -1:
        condition[i] = 0
    print(condition[i], end="")
print()


### FIXED CODE ###

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

ans = [-1] * N
if N == 1 and M == 0:
    print(0)
    exit(0)
for _ in range(M):
    sn, cn = map(int, input().split())
    if ans[sn - 1] != -1 and ans[sn - 1] != cn:
        print(-1)
        exit(0)
    if sn == 1 and cn == 0 and N > 1:
        print(-1)
        exit(0)
    ans[sn - 1] = cn
if ans[0] == -1:
    ans[0] = 1
ans = list(map(lambda x: str(0) if x == -1 else str(x), ans))
print("".join(ans))
def resolve():
  N, M = map(int, input().split(" "))
  AB_map = [[] for i in range(N)]
  for m in range(M):
    AB = [int(x) - 1 for x in input().split(" ")]
    AB_map[AB[0]].append(AB[1])
    AB_map[AB[1]].append(AB[0])

  not_finished = set(range(1, N))
  rooms = [None] * N
  rooms[0] = 0
  room_depths = [0] * N

  def search_and_mark(recent_rooms, depth):
    if len(not_finished) == 0 or depth >= N:
      return True

    temp_recent = set()
    for r in recent_rooms:
      for target in AB_map[r]:
        if target in not_finished:
          temp_recent.add(target)
          not_finished.remove(target)
          rooms[target] = r
          room_depths[target] = depth

    return search_and_mark(list(temp_recent), depth+1)

  _ = search_and_mark([0], 0)

  print("Yes")
  for r in rooms[1:]:
    print(r + 1)


if __name__ == "__main__":
    resolve()

### FIXED CODE ###

def resolve():
  N, M = map(int, input().split(" "))
  AB_map = [[] for i in range(N)]
  for m in range(M):
    AB = [int(x) - 1 for x in input().split(" ")]
    AB_map[AB[0]].append(AB[1])
    AB_map[AB[1]].append(AB[0])

  not_finished = set(range(1, N+1))
  rooms = [None] * N
  rooms[0] = 0
  room_depths = [0] * N

  recent_rooms = [0]
  depth = 1
  while len(not_finished) != 0 and depth < N:
    temp_recent = set()
    for r in recent_rooms:
      for target in AB_map[r]:
        if target in not_finished:
          temp_recent.add(target)
          not_finished.remove(target)
          rooms[target] = r
          room_depths[target] = depth
    depth += 1
    recent_rooms = list(temp_recent)

  print("Yes")
  for r in rooms[1:]:
    print(r + 1)

if __name__ == "__main__":
    resolve()
n = int(raw_input())
s = str(raw_input())
x = 0
xs = [x]
for si in s:
    if si == 'I': x += 1
    else: x -= 1
    xs.append(x)
print max(xs)

### FIXED CODE ###

a, b, c, d = map(int, raw_input().split())
print a*b if a*b > c*d else c*d
N = input()
V = list(map(int, input().split()))
C = list(map(int, input().split()))
XY = 0
for i in range(len(V)):
    if V[i] - C[i] > 0:
        XY += V[i] - C[i]

print(XY)


### FIXED CODE ###

N = input()
V = list(map(int, input().split()))
C = list(map(int, input().split()))
XY = 0
for i in range(len(V)):
    if V[i] - C[i] > 0:
        XY += V[i] - C[i]

print(XY)
while True:
 h,w=map(int,input().split())
 if h==0:break
 for _ in range(h):
  print("".join([*]**w))
 print()

### FIXED CODE ###

while 1:
 h,w=map(int,input().split())
 if h==0:break
 print(('#'*w+'\n')*h)
n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(n) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
for i in range(k):
    for sa in a:
        if dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
mm=[0,2,5,5,4,5,6,3,7,6]

dp=[0]
m = [mm[i] for i in range(10) if i in a]
for i in range(1,n+1):
    tres=[-10**10]
    for sm in m:
        if i - sm >= 0:
            tres.append(dp[i-sm]+1)
    dp.append(max(tres))
k=dp[n]
res = []
a.sort(reverse=True)
while n > 0:
    for sa in a:
        if n-mm[sa] >= 0 and dp[n-mm[sa]]==dp[n]-1:
            res.append(sa)
            n -= mm[sa]
            break

print("".join(map(str,res)))
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10**9+7
a_list.sort()
ans = 1
if k % 2 == 1 and a[-1] < 0:
    for i in range(k):
        ans *= a_list[n - 1 - i]
        ans %= mod
else:
    l = 0
    r = -1
    mlt1 = a_list[0] * a_list[1]
    mlt2 = a_list[-2] * a_list[-1]
    for _ in range(0, k // 2):
        if mlt1 >= mlt2:
            ans *= mlt1 % mod
            l += 2
            if l <= n-2:
                mlt1 = a_list[l + 1] * a_list[l]
        else:
            ans *= mlt2 % mod
            r -= 2
            if r >= - n + 1:
                mlt2 = a_list[r - 1] * a_list[r]
        ans %= mod

    if k % 2 == 1:
        ans *= a_list[r]
        ans %= mod
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10**9+7
a_list.sort()
ans = 1
if k % 2 == 1 and a_list[-1] < 0:
    for i in range(k):
        ans *= a_list[n - 1 - i]
        ans %= mod
else:
    l = 0
    r = -1
    mlt1 = a_list[0] * a_list[1]
    mlt2 = a_list[-2] * a_list[-1]
    count = 0
    while True:
        if count == k:
            break
        elif count == k - 1:
            ans *= a_list[r] % mod
            ans %= mod
            break
        if mlt1 >= mlt2:
            ans *= mlt1 % mod
            l += 2
            count += 2
            if l <= n - 2:
                mlt1 = a_list[l + 1] * a_list[l]
        else:
            ans *= a_list[r] % mod
            r -= 1
            count += 1
            if r >= - n + 1:
                mlt2 = a_list[r - 1] * a_list[r]
        ans %= mod
print(ans)
def removable(s):
	lst = []
	for i in range(0, len(s)-1):
		if s[i] != s[i+1]:
			lst.append(i)
	return lst

S = raw_input()
max = 0
queue = [[S, 0]]
while queue != []:
	now = queue.pop(0)
	removelist = removable(now[0])
	if removelist == []:
		if max < now[1]: max = now[1]
	else:
		for i in range(0, len(removelist)):
			queue.append([now[0][:removelist[i]]+now[0][removelist[i]+2:], now[1]+2])
			print queue

print max

### FIXED CODE ###

def smaller(x, y):
	if x < y: return x
	else: return y

S = raw_input()
count = [0, 0]
for i in range(0, len(S)):
	count[int(S[i])] += 1

print smaller(count[0], count[1])*2
N=int(input())
L=list(map(int,input().split())
to=[]
for i in range(N):
  to.append([i,L[i]])
to=sorted(to, key=lambda x:x[1])
for i in range(N):
       print(total[i][0],end='')

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
to=[]
for i in range(N):
  to.append([i,L[i]])
to=sorted(to, key=lambda x:x[1])
for i in range(N):
       print(to[i][0]+1,end=' ')
# -*- coding: utf-8 -*-

#input
import numpy as np
import sys
sys.setrecursionlimit(10**10) 
[X,Y,Z,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

D = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

#make list
memo = np.zeros((X,Y,Z))
for i in range(min(K,X)):
    for j in range(min((K//(i+1))+1,Y)):
        for k in range(min(((K//(i+1))+1)//(j+1),Z)):
            if memo[i][j][k] != 0:
                continue
            else:
                memo[i][j][k] = A[i]+B[j]+C[k]
                D.append(memo[i][j][k])
D.sort(reverse=True)
for i in range(K):
    print(int(D[i]))

### FIXED CODE ###

# -*- coding: utf-8 -*-

#input
import numpy as np
[X,Y,Z,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

D = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

#make list
for i in range(min(K,X)):
    for j in range(min((K//(i+1))+1,Y)):
        for k in range(min(((K//(i+1))+1)//(j+1),Z)):
                D.append(A[i]+B[j]+C[k])
D.sort(reverse=True)
for i in range(K):
    print(int(D[i]))
N, L = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

S1 = sorted(S)

S2 ="".join(S1)

print(S2)

### FIXED CODE ###

N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())

S1 = sorted(S)

S2 ="".join(S1)

print(S2)
input = input().split()

a = input[0] * input[1]

if (a/2 == 0):
	print("Even")
else:
	print("Odd")


### FIXED CODE ###

input = input().split()

a = int(input[0]) * int(input[1])

if (a%2 == 0):
	print("Even")
else:
	print("Odd")
N = int(input())
l = []
for i in range(N):
  x = input()
  l.append(x)
s = len(list(set(l))
print(s)


### FIXED CODE ###

N = int(input())
l = []
for i in range(N):
    x = input()
    l.append(x)
s = set(l)
t = list(s)
print(len(t))
l=[]
m=[]
for i in range(5):
  i = int(input())
  k = 10 - (i%10)
  l.append(i)
  if k != 10:
    m.append(k)
m.sort()
s = sum(m)-m[4]
print(sum(l)+s)

### FIXED CODE ###

l=[]
m=[]
for i in range(5):
  i = int(input())
  k = 10 - (i%10)
  l.append(i)
  if k != 10:
    m.append(k)
m.sort()
if len(m)==0:
  print(sum(l))
else:
  s = sum(m)-m[-1]
  print(sum(l)+s)
N = input()
if(N == 3):
  print('bon')
else if(N == 0||1||6||8):
  print('pon')
else:
  print('hon')

### FIXED CODE ###

N = int(input())
S = N % 10
if(S == 0):
  print("pon")
elif(S == 1):
  print("pon")
elif(S == 6):
  print("pon")
elif(S == 8):
  print("pon")
elif(S == 3):
  print("bon")
else:
  print("hon")
import math
A,B=map(int,input().split())
Amin=A/0.08
Amax=(A+1)/0.08
Bmin=B/0.1
Bmax=(B+1)/0.1

a=[]
b=[]
c=[]
"""
if int(Amin)==Amin:
    p=Amin
else:
    p=int(Amin)+1

if int(Bmin)==Bmin:
    q=Bmin
else:
    q=int(Bmin)+1
"""
p=int(Amin+1)
q=int(Bmin+1)
while p<=Amax:
    a.append(p)
    p+=1
while q<=Bmax:
    b.append(q)
    q+=1
for i in range(len(a)):
    if a[i] in b:
        c.append(a[i])
for i in range(len(b)):
    if b[i] in a:
        c.append(b[i])
if len(c)==0:
  print(-1)
else:
  print(min(c))


### FIXED CODE ###

S=list(input())

if len(set(S))==1:
  print("No")
else:
  print("Yes")
n = int(input())
dp = [float("Inf")]*(n+1)
dp[0] = 0
for i in range(n):
    if dp[i] == float("Inf"):
        pass
    else:
        for j in range(1,n//6):
            if i + 6**j > n:
                break
            dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
        for j in range(1,n//9):
            if i + 9**j > n:
                break
            dp[i+9**j] = min(dp[i+9**j], dp[i] + 1)
ans = n
for i in range(n-5, n+1):
    ans = min(ans, dp[i]+n-i)
print(ans)

### FIXED CODE ###

from collections import deque
n = int(input())
q = deque([])
now = 0
reach = [0]*100001
lis = []
for i in range(6):
    lis.append(6**(i+1))
for i in range(5):
    lis.append(9**(i+1))
lis.append(1)
lis = sorted(lis)
q.append(0)
ans = 0
while q:
    if ans == 1:
        break
    x = q.popleft()
    
    for y in lis:
        if x + y < n:
            if  reach[x+y] == 0:
                q.append(x+y)
                reach[x+y] = reach[x]+1
            
        elif x + y == n:
            reach[x+y] = reach[x]+1
            ans = 1
            break
print(max(reach))