Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python
#coding:utf-8

def input_strs():
    return input().split(" ")

def input_nums():
    return [int(i) for i in input_strs()]


w = input()
ok = True
h = Map()

for c in w:
    p = 0
    for k in w:
        if c == k:
            p += 1
    ok = ok and (p % 2 == 0)

if ok:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

#!/usr/bin/env python
#coding:utf-8

def input_strs():
    return input().split(" ")

def input_nums():
    return [int(i) for i in input_strs()]


w = input()
ok = True

for c in w:
    p = 0
    for k in w:
        if c == k:
            p += 1
    ok = ok and (p % 2 == 0)

if ok:
    print("Yes")
else:
    print("No")
n=int(input())
A=list(map(int,input(),split()))
print("YES" if len(set(A))==len(A) else "NO")


### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
print("YES" if len(set(A))==len(A) else "NO")
S=list(input())
ans=0
j=0
while len(S)-1>j:
    if S[j]!=S[j+1]:
        S.pop(j)
        S.pop(j)
        ans+=2
        j-=1
        continue
    j+=1
print(ans)


### FIXED CODE ###

S=list(input())
ans=0
j=0
while len(S)-1>j:
    if S[j]!=S[j+1]:
        S.pop(j)
        S.pop(j)
        ans+=2
        if j>0:
            j-=1
        continue
    j+=1
print(ans)
from fractions import gcd

n, m = [int(i) for i in input().split()]
S = input()
T = input()

g = n * m // gcd(n, m)

L = [''] * g
if S[0] != T[0]:
    print(-1)
    exit()

for i, s in zip(range(0, g, g//n), S):
    L[i] = s

for i, t in zip(range(0, g, g//m), T):
    L[i] = t
    
A = []
B = []

for i in range(0, g, g//n):
    A.append(L[i])

for i in range(0, g, g//m):
    B.append(L[i])

if ''.join(A) == S and ''.join(B) == T:
    print(g)
else:
    print(-1)

### FIXED CODE ###

from fractions import gcd

n, m = [int(i) for i in input().split()]
S = input()
T = input()

g = n * m // gcd(n, m)

SA = set()
SB = set()

for i in range(0, g, g//n):
    SA.add(i)

for i in range(0, g, g//m):
    SB.add(i)

SC = SA & SB

for s in SC:
    if S[s//(g//n)] != T[s//(g//m)]:
        print(-1)
        exit()

print(g)
import queue

h, w = map(int, input().split())
mat = ["#"*(w+2)]
for y in range(h):
  mat.append("#"+input()+"#")
mat.append("#"*(w+2))

d_mat1 = [[-1]*(w+2) for i in range(h+2)]
d_mat2 = [[-1]*(w+2) for i in range(h+2)]
q = queue.Queue()
for x in range(1, w+1):
  for y in range(1, h+1):
    if mat[x][y] == ".":
      start = (x, y)
      d_mat1[x][y] = 0
q.put(start)

while not q.empty():
  x, y = q.get()
  d = d_mat1[x][y]
  if mat[x-1][y] == "." and d_mat1[x-1][y] == -1:
    d_mat1[x-1][y] = d+1
    q.put((x-1, y))
    
  if mat[x+1][y] == "." and d_mat1[x+1][y] == -1:
    d_mat1[x+1][y] = d+1
    q.put((x+1, y))
    
  if mat[x][y-1] == "." and d_mat1[x][y-1] == -1:
    d_mat1[x][y-1] = d+1
    q.put((x, y-1))
    
  if mat[x][y+1] == "." and d_mat1[x][y+1] == -1:
    d_mat1[x][y+1] = d+1
    q.put((x, y+1))

end = (x,y)
d_mat2[x][y] = 0
q.put(end)
while not q.empty():
  x, y = q.get()
  d = d_mat1[x][y]
  if mat[x-1][y] == "." and d_mat2[x-1][y] == -1:
    d_mat2[x-1][y] = d+1
    q.put((x-1, y))
    
  if mat[x+1][y] == "." and d_mat2[x+1][y] == -1:
    d_mat2[x+1][y] = d+1
    q.put((x+1, y))
    
  if mat[x][y-1] == "." and d_mat2[x][y-1] == -1:
    d_mat2[x][y-1] = d+1
    q.put((x, y-1))
    
  if mat[x][y+1] == "." and d_mat2[x][y+1] == -1:
    d_mat2[x][y+1] = d+1
    q.put((x, y+1))

print(d_mat2[x][y])

### FIXED CODE ###

import queue

def bfs(start):
  d_mat = [[-1]*(w+2) for i in range(h+2)]
  q.put(start)
  d_mat[start[0]][start[1]] = 0
  while not q.empty():
    x, y = q.get()
    d = d_mat[x][y]
    if mat[x-1][y] == "." and d_mat[x-1][y] == -1:
      d_mat[x-1][y] = d+1
      q.put((x-1, y))
    
    if mat[x+1][y] == "." and d_mat[x+1][y] == -1:
      d_mat[x+1][y] = d+1
      q.put((x+1, y))
    
    if mat[x][y-1] == "." and d_mat[x][y-1] == -1:
      d_mat[x][y-1] = d+1
      q.put((x, y-1))
    
    if mat[x][y+1] == "." and d_mat[x][y+1] == -1:
      d_mat[x][y+1] = d+1
      q.put((x, y+1))
  return d_mat[x][y]
h, w = map(int, input().split())
mat = ["#"*(w+2)]
for y in range(h):
  mat.append("#"+input()+"#")
mat.append("#"*(w+2))

d_mat1 = [[-1]*(w+2) for i in range(h+2)]
d_mat2 = [[-1]*(w+2) for i in range(h+2)]
q = queue.Queue()
start_list = []
flag = True
for x in range(1, w+1):
  if flag:
    for y in range(1, h+1):
      if mat[y][x] == ".":
        start = (y, x)
        start_list.append(start)
        
q.put(start)

while not q.empty():
  x, y = q.get()
  d = d_mat1[x][y]
  if mat[x-1][y] == "." and d_mat1[x-1][y] == -1:
    d_mat1[x-1][y] = d+1
    q.put((x-1, y))
    
  if mat[x+1][y] == "." and d_mat1[x+1][y] == -1:
    d_mat1[x+1][y] = d+1
    q.put((x+1, y))
    
  if mat[x][y-1] == "." and d_mat1[x][y-1] == -1:
    d_mat1[x][y-1] = d+1
    q.put((x, y-1))
    
  if mat[x][y+1] == "." and d_mat1[x][y+1] == -1:
    d_mat1[x][y+1] = d+1
    q.put((x, y+1))



print(max(list(map(bfs, start_list))))
x, a = map(int, input())
if x < a:
    print(0)
else:
    print(1)

### FIXED CODE ###

x,a=input().split()
if x < a:
    print(0)
else:
    print(10)
N = int(input())

maxh = int(3 * N / 4)

for h in range(1, min(maxh, 3501)):
    maxn = int(2 / (4 / N - 1 / h))
    for n in range(h, min(maxn, 3501)):
        w_reciprocal = (4 / N) - (1 / h) - (1 / n)
        if w_reciprocal > 0:
            w = 1 / w_reciprocal
            if w < 3501 and int(w) == w:
                w = int(w)
                print(h, n, w, sep = ' ')
                exit()

### FIXED CODE ###

N = int(input())
for h in range(N//4 + 1, 3501):
    for n in (N * h // (4 * h - N) + 1, 3501):
        w = N * h * n // (4 * h * n - N * h - N * n)
        if w * (4 * h * n - N * h - N * n) == N * h * n:
            print(h, n, w)
            exit()
# -*- coding: utf-8 -*-


def main():
    input()
    a = map(int, input().split())
    print(max(a) - min(a))
    

if __name__ == '__main__':
    main()

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
count = 0
for i in range(len(a)-1):
    count += int(a[0]) - int(a[1])
    a.pop(0)
print(count)
N, A, B = map(int, input().split())
print(N // (A + B) * A + min(A, N % (A + B))

### FIXED CODE ###

N, A, B = map(int, input().split())
print(N // (A + B) * A + min(A, N % (A + B)))
input = int(row_input())
hour = input / 3600
minute = hour / 60
second = minute / 60
print"%1:%2:%3" % (hour,minute,second)

### FIXED CODE ###

input = int(input())
if 0 <= input < 86400:
    hour = input / 3600
    minute = (input / 60) % 60
    second = input % 60
    print("%d:%d:%d" % (hour,minute,second))
n=int(input())
h=list(map(int,input().split()))
l=[]
for i in range(n-1):
    if h[i+1]-h[i]<=0:
        l.append(1)
    else:
        l.append(0)
ans=0
mn=[]
for j in range(len(l)):
    if l[j]==0:
        ans=0
        mn.append(ans)
    else:
        ans+=1
        mn.append(ans)
print(max(mn))

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
ans = 0
cnt = 0
for i in range(n-1):
    if h[i+1]<=h[i]:
        cnt+=1
    else:
        ans = max(ans, cnt)
        cnt = 0
print(max(ans, cnt))
s=str(input())
k=int(input())

l=len(s)
chars=set()
chars1=set()
sub1=['']*l

for j in range(l):
    chars1.add(s[j])
    min_c=sorted(chars1)[0]

def subset(st,m):
    substring=set()
    if m==0:
        lst=len(st)
    else:
        lst=m
    for i in range(lst):
        n=i+1 #length = n
        for j in range(lst-i):
            substring.add(st[j:j+n])
    return substring
    
chars=chars|subset(s[l-10:],0)
for i in range(l):
    if s[i]==min_c:
        chars=chars|subset(s[i:i+5],0)

#print(min_c,chars)

'''
for i in range(l):
    n=i+1 #length = n
    for j in range(l-i):
        chars.add(s[j:j+n])
        #print('i,j,sub',i,j,s[j:j+n])
'''

print(sorted(chars)[k-1])

### FIXED CODE ###

from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

a,b,c,d=LI()

print(YN[1-(abs(a-c)<=d or (abs(a-b)<=d and abs(c-b)<=d))])
from collections import defaultdict
enu = enumerate
def input(): return sys.stdin.readline()[:-1]

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

cnt = 0
d = defaultdict(int)
for i, a in enu(A):
    l = (i+1) + a
    r = (i+1) - a
    cnt += d[r]
    d[l] += 1

print(cnt)

### FIXED CODE ###

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

cnt = 0
d = defaultdict(int)
for i, a in enu(A):
    l = (i+1) + a
    r = (i+1) - a
    cnt += d[r]
    d[l] += 1
print(cnt)
a,b,n = map(int,input().split())
ans = 0
for k in range(1,n+1):
    ans = max(int(a*k/b) - a*int(k/b),ans)
    if ans == a:
        print(ans)
        break
if ans == a:
    ans = ans
else:
    for k in range(1,n//(b-1)+1):
        ans = max(int(a*(k*b-1)/b) - a*int((k*b-1)/b),ans)
        if ans == a:
            print(ans)
            break
if ans != a:
    print(ans)

### FIXED CODE ###

a,b,n = map(int,input().split())
ans = 0
ans = max(int(a*n/b) - a*int(n/b),ans)
if b == 1:
    print(0)
else:
    for k in range(1,n//(b-1)+1):
        ans = max(int(a*(k*b-1)/b) - a*int((k*b-1)/b),ans)
        if ans == a:
            print(ans)
            break
    if ans != a:
        print(ans)
N, A, B = [int(i) for i in input().split()]
S = 'b' * A + 'r' * B
while len(S) < N:
    S += S

print(S[0:N].count('b'))


### FIXED CODE ###

import math
N, A, B = [int(i) for i in input().split()]
if A == 0 and B == 0:
    print(0)
else:
    count = A + B
    setCount = math.floor(N / count)
    amari = N - setCount * count
    if amari > 0:
        if A > amari:
            result = setCount * A + amari
        else:
            result = setCount * A + A
    else:
        result = setCount * A
    print(result)
S = str(input())
A = S.split()

for i in A:
    if A[i]=A[i+1]:
        print('Bad')
    else:
        print('Good')


### FIXED CODE ###

S = input()

if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print('Bad')
else:
    print('Good')
i = [int(i) for i in input().split()]
n = i[0]
k = i[1]
n2 = n % k
print(n2 if k < n2 else k % n2)

### FIXED CODE ###

i = [int(x) for x in input().split()]
n = i[0]
k = i[1]

t = n % k
t2 = k -t

print(min(t, t2))
import sympy as sym
N = int(input())
l = list(map(int, input().split()))
expr = 0
x = sym.symbols("x")
for i in range(N):
    expr = expr + (l[i] - x)**2
eq = sym.Eq(sym.Derivative(expr).doit())
a = sym.solve(eq, x)
# print(a)
a = a[0]
a = round(a)
# print(a)
a = expr.subs(x, a)
print(a)

### FIXED CODE ###

N = int(input())
l = list(map(int, input().split()))
c = 0
b = 0
for i in range(N):
    c += l[i] ** 2
    b += -2 * l[i]
x = -b / (2 * N)
x = round(x)
Ans = N * x ** 2 + b * x + c

print(Ans)
s = input()

def radius(r):
  return r * r 

print s


### FIXED CODE ###

s = input ()

def radius(r):
  to_number = int(r)
  return to_number ** 2

print (radius(s))
n=int(input())

alist=[0 for i in range(n+1)]

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

for i in A:
    alist[i]+=1
asum=sum(A)
for i in range(q):
    b,c=map(int , input().split())
    bnum=alist[b]
    asum+=bnum*(c-b)
    alist[b]=0
    alist[c]+=bnum
    print(asum)


### FIXED CODE ###


n=int(input())

alist=[0]*(10**5+1)

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

for i in A:
    alist[i]+=1
asum=sum(A)
for i in range(q):
    b,c=map(int , input().split())
    bnum=alist[b]
    asum+=bnum*(c-b)
    alist[b]=0
    alist[c]+=bnum
    print(asum)
N =int(input())
B = 1
for i in range(N):
    A =list( map(int,input().split()))
    for i in A:
        B = B * i
        #print(B)
    
#print(B)
C = 10 ** 18
#print(C)
if B > C:
    print(-1)
else:
    print(B)


### FIXED CODE ###

N =int(input())

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

B = 1
C = 10 ** 18

for i in range(N):
    B = B * A[i]
    if B == 0:
        break
    elif B > C:
        B = -1
        break

print(B)
a = map(int,input().split())

if a*b % 2 == 1:
    print("Odd")
else:
    print("Even")



### FIXED CODE ###

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

if a*b % 2 == 1:
    print("Odd")
else:
    print("Even")
import bisect
N=int(input())
L=list(map(int, input().split()))
ans=0
L_LENGTH=len(L)
L=sorted(L)
for i in range(L_LENGTH-2):
    for j in range(i+1, L_LENGTH-1):
        a=L[i]+L[j]
        idx=bisect.bisect_left(l, t)
        ans+=max(0, idx-j-1)
print(ans)


### FIXED CODE ###

import bisect
N=int(input())
L=list(map(int, input().split()))
ans=0
L_LENGTH=len(L)
L=sorted(L)
for i in range(L_LENGTH-2):
    for j in range(i+1, L_LENGTH-1):
        a=L[i]+L[j]
        idx=bisect.bisect_left(L, a)
        ans+=max(0, idx-j-1)
print(ans)
a, b, k = map(int, input().split())
c = list(range(a, b + 1))
print(*c if a+2*k >= b else list(dict.fromkeys(c[:k] + c[-k:])), sep='\n')


### FIXED CODE ###

a, b, k = map(int, input().split())
l = range(a, b+1)
for i in sorted(set(l[-k:]) | set(l[:k])):
    print(i)
#!/usr/bin/env python
# coding: utf-8


def P(k):
    return (k*(k-1))//2

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.child = [1 for _ in range(n)] # 自分も含めた子の数
        self.ans = n*(n-1)//2

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return

        cx = self.child[rx]
        cy = self.child[ry]
        self.ans -= (P(cx+cy)-P(cx)-P(cy))
        self.child[ry] += cx
        self.child[rx] = 0
        self.par[rx] = ry


def main():
    N, M = list(map(int, input().split()))
    edges = []
    for _ in range(M):
        a, b = list(map(int, input().split()))
        edges.append((a-1, b-1))

    u = UnionFind(N)
    lans = []
    for e in edges[::-1]:
        lans.append(str(u.ans))
        u.unite(e[0], e[1])
        # print(e, u.ans, u.par, u.child)
    print("\n".join(lans[::-1]))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

import sys

def P(k):
    return (k*(k-1))//2

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.child = [1 for _ in range(n)] # 自分も含めた子の数
        self.ans = (n*(n-1))//2

    def root(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return

        cx = self.child[rx]
        cy = self.child[ry]
        self.ans -= (P(cx+cy)-P(cx)-P(cy))
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.child[ry] += cx
            self.child[rx] = 0
        else:
            self.par[ry] = rx
            self.child[rx] += cy
            self.child[ry] = 0
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1


def main():
    N, M = list(map(int, sys.stdin.readline().split()))
    edges = []
    for _ in range(M):
        a, b = list(map(int, sys.stdin.readline().split()))
        edges.append((a-1, b-1))

    u = UnionFind(N)
    lans = []
    for e in edges[::-1]:
        lans.append(str(u.ans))
        u.unite(e[0], e[1])
        # print(e, u.ans, u.par, u.child)
    print("\n".join(lans[::-1]))


if __name__ == '__main__':
    main()
H = int(input())
dp = [0] * (H+1)
dp[1] = 1
for i in range(2, H+1):
  dp[i] = 1 + 2 * dp[i//2]
print(dp[-1])

### FIXED CODE ###

def resolve():
    H = int(input())
    def sol(n):
        if n == 1:
            return 1
        return 1 + 2 * sol(n//2)
    print(sol(H))

resolve()
import sys
readline = sys.stdin.readline
s = readline().strip()
n = int(readline())
rev = False
for i in range(n):
    q = readline()
    if q.startswith("1"):
        rev = not rev
    if q.startswith("2 1"):
        if not rev:
            s = q[-2] + s
        else:
            s = s + q[-2]
    if q.startswith("2 2"):
        if not rev:
            s = s + q[-2]
        else:
            s = q[-2] + s
if rev:
    print(s[::-1])
else:
    print(s)


### FIXED CODE ###

import sys
import math
readline = sys.stdin.readline
a, b = [int(x) for x in readline().strip().split(" ")]
ans = -1
for i in range(13, 1001):
    if a == math.floor(i * 0.08) and b == math.floor(i * 0.1):
        ans = i
        break
print(ans)
K,N=map(int,input().split())
A=list(map(int,input().split()))

max = K-A[-1]+A[0]
for i in range(N-1):
    if last < A[i+1]-A[i]:
        max = A[i+1]-A[i]

print(K-max)

### FIXED CODE ###

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

max = K-A[-1]+A[0]
for i in range(N-1):
    if max < A[i+1]-A[i]:
        max = A[i+1]-A[i]

print(K-max)
N,K,X,Y=[int(input()) i in range(4)]
print(N*X-(X-Y)*max(0,N-K))

### FIXED CODE ###

N,K,X,Y=[int(input()) for i in range(4)]
print(N*X-(X-Y)*max(0,N-K))
A=int(input())
B=int(input())
C=int(input())

if A==5 and B==5 and C==7:
    print('YES')
elif A==5 and B==7 and C==5:
    print('YES')
elif A==7 and B==5 and C==5:
    print('YES')
else:print('NO')

### FIXED CODE ###

a = list(map(int,input().split()))
a.sort()
if a[0] == a[1] == 5 and a[2] == 7:
    print("YES")
else:
    print("NO")
import math
import sys

N = int(sys.stdin.readline())

queue = [(N, 1)]
min_cnt = math.inf

while queue:
    N, cnt = queue.pop()
    if N >= 9:
        v = math.pow(9, math.floor(math.log(N, 9)))
        if N - v >= 6 and cnt < min_cnt:
            queue.append((N - v, cnt + 1))
        elif cnt + (N - v) < min_cnt:
            min_cnt = cnt + int(N - v)
    if N >= 6:
        v = math.pow(6, math.floor(math.log(N, 6)))
        if cnt < min_cnt:
            queue.append((N - v, cnt + 1))
        elif cnt + (N - v) < min_cnt:
            min_cnt = cnt + int(N - v)

if math.isinf(min_cnt):
    print(N)
else:
    print(min_cnt)

### FIXED CODE ###

import itertools
import math
import sys

MAX_N = 100000
MAX_LOG6 = int(math.log(MAX_N, 6))
MAX_LOG9 = int(math.log(MAX_N, 9))

def main(N):
    dp = [MAX_N] * (N + 1)
    for i in range(min(N + 1, 6)):
        dp[i] = i
    for i in range(N + 1):
        t = 1
        for j in range(1, MAX_LOG6 + 1):
            t *= 6
            if i - t < 0:
                break
            dp[i] = min(dp[i], dp[i - t] + 1)
        t = 1
        for j in range(1, MAX_LOG9 + 1):
            t *= 9
            if i - t < 0:
                break
            dp[i] = min(dp[i], dp[i - t] + 1)
    print(dp[N])

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    main(N)
from itertools import combinations
N, M, Q = [int(n) for n in input().split()]
X = [[int(n) for n in input().split()] for _ in range(Q)]
ans = []
for A in combinations(range(1, M+1), N):
    t = 0
    for x in X:
        if A[x[1]-1]-A[x[0]-1] == x[2]:
            t += x[3]
    ans.append(t)
print(max(ans))


### FIXED CODE ###

from itertools import combinations_with_replacement
N, M, Q = [int(n) for n in input().split()]
X = [[int(n) for n in input().split()] for _ in range(Q)]
ans = []
for A in combinations_with_replacement(range(1, M+1), N):
    t = 0
    for x in X:
        if A[x[1]-1]-A[x[0]-1] == x[2]:
            t += x[3]
    ans.append(t)
print(max(ans))
# 入力
n, a = map(int, input().split())

# 処理
answer = n * n - a

# 出力
print(answer)

### FIXED CODE ###

# 入力
# n, a = map(int, input().split())
n = int(input())
a = int(input())

# 処理
answer = n * n - a

# 出力
print(answer)
n = int(input())
a = list(map(int,input().split()))

i = 1
ind = 0
if 1 in a:
    while i in a[ind:]:
    ind = a.index(i)
    i += 1
    print(n-i+1)
else:
    print(-1)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
k = 1

for i in a:
    if k == i:
        k += 1

if k == 1:
    print(-1)
else:
    print(n-k+1)
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
  print(0)
  exit()
ans = 1
for i in a:
  ans = ans*i
if ans > 10**18:
  prinr(-1)
  exit()
print(ans)

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr) 
ans=1
for val in arr:
 ans*=val 
 if ans>10**18:
   print(-1)
   break
else:
 print(ans)