ZhenlongDai/ACPR huggingface dataset:
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


maxN = int(1e5)
N = int(input())
a = [1]
for i in range(1,100):
    if 6**i <= N: a.append(6**i)
    if 9**i <= N: a.append(9**i)
    else: break
        
        
dp = [[0] + [maxN]*N]    

for i in range(len(a)):
    dp.append([0]*(N+1)) 
    for n in range(N+1):
        if a[i] <= n:
            dp[i+1][n] = min(dp[i][n], dp[i+1][n-a[i]] + 1)
        else:
            dp[i+1][n] = dp[i][n]
          
print(dp[len(a)][N])

Failing test case input:
58523

Expected output:
12


Actual output:
15


Fixed submission (verdict: Accepted):


maxN = int(1e5)
N = int(input())
a = [1]
for i in range(1,100):
    if 6**i <= N: a.append(6**i)
    if 9**i <= N: a.append(9**i)
    if 6**i>N and 9**i>N: break
        
 
dp = [[0] + [maxN*10]*N] 

for i in range(len(a)):
    dp.append([0]*(N+1)) 
    for n in range(N+1):
        if a[i] <= n:
            dp[i+1][n] = min(dp[i][n], dp[i+1][n-a[i]] +1)
        else:
            dp[i+1][n] = dp[i][n]
            
print(dp[len(a)][N])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
ans=[0]*n
ans[0]=1
for i in range(n):
    ans[i] = ans[i-1]+1
    m6 = 6
    m9 = 9
    while i>=m6:
        ans[i] = min(ans[i],ans[i-m6]+1)
        m6 *= 6
    while i>=m9:
        ans[i] = min(ans[i],ans[i-m9]+1)
        m9 *= 9
print(ans[-1])

Failing test case input:
9627

Expected output:
7


Actual output:
11


Fixed submission (verdict: Accepted):
n=int(input())
ans=[0]*(n+1)
for i in range(1,n+1):
    ans[i] = ans[i-1]+1
    m6 = 6
    m9 = 9
    while i>=m6:
        ans[i] = min(ans[i],ans[i-m6]+1)
        m6 *= 6
    while i>=m9:
        ans[i] = min(ans[i],ans[i-m9]+1)
        m9 *= 9
print(ans[-1])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import math

def base_10_n(x,n):
    if x == 0:
        return 0
    tmpx = x
    a = int(math.log(x,n))
    ans = 0
    for i in range(a,-1,-1):
        ans += tmpx 
        tmpx %= n**i
    ans += tmpx
    return ans

def main():
    N = int(input())
    ans = 10**12
    for j in range(N+1):
        c = base_10_n(N-j,6)
        d = base_10_n(j,9)
        ans = min(ans, c+d)
    print(ans)

if __name__ == "__main__":
    main()


Failing test case input:
9247

Expected output:
6


Actual output:
9277


Fixed submission (verdict: Accepted):

import math



def base_10_n(x, n):
    if x == 0:
        return 0
    tmpx = x
    a = int(math.log(x, n))
    ans = 0
    for i in range(a, -1, -1):
        ans += tmpx 
        tmpx %= n**i
    ans += tmpx
    return ans


def s(n, r):
    if n == 0:
        return 0
    return n % r + s(n 


def main():
    N = int(input())
    ans = 10**12
    for j in range(N+1):
        
        
        c = s(j,6)
        d = s(N-j,9)
        ans = min(ans, c+d)
    print(ans)


if __name__ == "__main__":
    main()
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
n = int(input())
add_num = 1
draw_money = []
while add_num <= 10 ** 5:
    draw_money.append(add_num)
    add_num *= 6
    
add_num = 1
while add_num <= 10 ** 5:
    draw_money.append(add_num)
    add_num *= 9


draw_money = list(set(draw_money))
ans = 0

draw_money.sort()

index = bisect.bisect_right(draw_money, n)
while n != 0:
    index = bisect.bisect_right(draw_money, n)
  
    n -= draw_money[index - 1]
    ans += 1
print(ans)





Failing test case input:
44852

Expected output:
16

Actual output:
18


Fixed submission (verdict: Accepted):
import bisect
n = int(input())
add_num = 1
draw_money = []
while add_num <= 10 ** 5:
    draw_money.append(add_num)
    add_num *= 6
    
add_num = 1
while add_num <= 10 ** 5:
    draw_money.append(add_num)
    add_num *= 9


draw_money = list(set(draw_money))
ans = 0
draw_money.sort()

dp = [10000000] * (n + 1)
dp[0] = 0
for i in range(1,n + 1):
    for j in draw_money:
        if  i - j >= 0:
            dp[i] = min(dp[i - 1] + 1, dp[i - j] + 1,dp[i])
        else:
            dp[i] = min(dp[i-1] + 1, dp[i])

print(dp[n])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def run():
  N = int(input())
  dp = [1] * N
  for n in range(N):
    if n == 0: continue
    dp[n] = dp[n-1]+1
    draw_money = 6
    while True:
      if n < draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 6
    draw_money = 9
    while True:
      if n < draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 9
  print(dp[N-1])
  
if __name__ == '__main__':
  run()

Failing test case input:
4632

Expected output:
6


Actual output:
9


Fixed submission (verdict: Accepted):
def run():
  N = int(input())
  dp = [0] * (N+1)
  dp[1] = 1
  for n in range(1, N+1):
    if n == 1: continue
    dp[n] = dp[n-1]+1
    draw_money = 6
    while True:
      if n < draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 6
    draw_money = 9
    while True:
      if n < draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 9
  print(dp[N])
  
if __name__ == '__main__':
  run()
Problem: p03329
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def checkmin(i):
    six_k = 1
    nine_k = 1
    list_before_compare = []
    list_before_compare.append(dp_table[i])
    
    
    list_before_compare.append(dp_table[i-1] + 1)
    
    
    while 6**six_k <= i+1:
        list_before_compare.append(dp_table[i-6**six_k] + 1)
        six_k += 1
    
    
    while 9**nine_k <= i+1:
        list_before_compare.append(dp_table[i-9**nine_k] + 1)
        nine_k += 1

    return min(list_before_compare)    

n = int(input())

dp_table = [float("inf")] * n


dp_table[0] = 1

for i in range(1,n):
    dp_table[i] = checkmin(i)

print(dp_table[-1])




Failing test case input:
879

Expected output:
6


Actual output:
9


Fixed submission (verdict: Accepted):
def checkmin(i):
    six_k = 1
    nine_k = 1
    list_before_compare = []
    list_before_compare.append(dp_table[i])
    
    
    list_before_compare.append(dp_table[i-1] + 1)
    
    
    while 6**six_k <= i:
        list_before_compare.append(dp_table[i-6**six_k] + 1)
        six_k += 1
    
    
    while 9**nine_k <= i:
        list_before_compare.append(dp_table[i-9**nine_k] + 1)
        nine_k += 1

    return min(list_before_compare)    

n = int(input())

dp_table = [float("inf")] * (n+1)


dp_table[0] = 0

for i in range(1,n+1):
    dp_table[i] = checkmin(i)

print(dp_table[-1])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
c=[1]
i=1
while (6**i<=100000):
  c.append(6**i)
  i+=1
i=1
while (9**i<100000):
  c.append(9**i)
  i+=1
c.sort()
m=[1]
for i in range(1,n):
  mi=1000000
  for j in range(len(c)):
    if i-c[j]<0:
      break
    if m[i-c[j]]+1<mi:
      mi=m[i-c[j]]+1
  m.append(mi)
print(m[n-1])

Failing test case input:
9627

Expected output:
7


Actual output:
11


Fixed submission (verdict: Accepted):
n=int(input())
c=[1]
i=1
while (6**i<=100000):
  c.append(6**i)
  i+=1
i=1
while (9**i<100000):
  c.append(9**i)
  i+=1
c.sort()
m=[0]
for i in range(1,n+1):
  mi=1000000
  for j in range(len(c)):
    if i-c[j]<0:
      break
    if m[i-c[j]]+1<mi:
      mi=m[i-c[j]]+1
  m.append(mi)
print(m[n])
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

def search(n,num):
    i = 1
    while True:
        if n < num**i:
            return i-1
        i += 1
        
ans = n
for i1 in range(0,6):
    for i2 in range(0,6):
        for i3 in range(0,6):
            for i4 in range(0,6):
                for i5 in range(0,6):
                    for i6 in range(0,6):
                            res = n
                            res -= (6**1)*i1+(6**2)*i2+(6**3)*i3+(6**4)*i4+(6**5)*i5+(6**6)*i6
                            if res > 0:
                                count = i1+i2+i3+i4+i5+i6
                                for i in reversed(range(1,6)):
                                    cnt = int(res / (9**i))
                                    res -= (9**i) * cnt
                                    count += cnt
                                if ans > count:
                                    ans = count
print(ans)

Failing test case input:
3715

Expected output:
8


Actual output:
6


Fixed submission (verdict: Accepted):
n = int(input())

def search(n,num):
    i = 1
    while True:
        if n < num**i:
            return i-1
        i += 1
        
ans = n
for i1 in range(0,6):
    for i2 in range(0,6):
        for i3 in range(0,6):
            for i4 in range(0,6):
                for i5 in range(0,6):
                    for i6 in range(0,6):
                        res = n
                        res -= (6**1)*i1+(6**2)*i2+(6**3)*i3+(6**4)*i4+(6**5)*i5+(6**6)*i6
                        if res >= 0:
                            count = i1+i2+i3+i4+i5+i6
                            while res > 6:
                                i = search(res,9)
                                cnt = int(res / (9**i))
                                res -= (9**i) * cnt
                                count += cnt
                            count += res
                            if ans > count:
                                ans = count
print(ans)

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
l = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776]
n = int(input())
ans = [10**9 for _ in range(n+1)]
ans[0] = 0

for i in range(n):
    for j in l:
        if i + j <= n:
            ans[i+j] = min(ans[i] + 1,ans[i+j])
        
print(ans[n])


    


Failing test case input:
58523

Expected output:
12


Actual output:
15


Fixed submission (verdict: Accepted):
l = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776,46656, 59049]
n = int(input())
ans = [10**9 for _ in range(n+1)]
ans[0] = 0

for i in range(n):
    for j in l:
        if i + j <= n:
            ans[i+j] = min(ans[i] + 1,ans[i+j])
        
print(ans[n])
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())

inf = float('inf')
dp = [inf] * (N+1)
dp[0] = 0



c = [1]
t = 6
while t <= N:
    c.append(t)
    t *= 6
t = 9
while t <= N:
    c.append(t)
    t *= 9

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

for i in range(1, N+1):
    for t in c: 
        if i - t >= 0:
            dp[i] = chmin(dp[i], dp[i-t]+1)
        else:
            break
            
print(dp[N])

Failing test case input:
1477

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
N = int(input())
inf = float('inf')
dp = [inf] * (N+1)
dp[0] = 0


c = [1]
t = 6
while t <= N:
    c.append(t)
    t *= 6
t = 9
while t <= N:
    c.append(t)
    t *= 9
    
def chmin(a, b):                            
    if a > b:
        return b
    else:
        return a

for i in range(1, N+1):                     
    for t in c:                             
        dp[i] = chmin(dp[i], dp[i-t]+1)     
            
print(dp[N])

Problem: p03329
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


n = int(input())

ans = [-1]*n

ans[0] = 1
for i in range(1, n):
    num = i
    data = ans[i-1]+1
    for j in range(8):
        index = i-6**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    for j in range(8):
        index = i-9**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    ans[i] = data
print(ans[-1])


Failing test case input:
345

Expected output:
5


Actual output:
7


Fixed submission (verdict: Accepted):


n = int(input())

ans = [-1]*(n+1)

ans[0] = 0
for i in range(1, n+1):
    num = i
    data = ans[i-1]+1
    for j in range(8):
        index = i-6**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    for j in range(8):
        index = i-9**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    ans[i] = data
print(ans[-1])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

def f(n):
  X6 = []
  X9 = []
  for i in range(1, 10):
    if n >= 6**i:
      X6.append(6**i)
    if n >= 9**i:
      X9.append(9**i)
  return X6, X9


def main():
  input = sys.stdin.readline
  N = int(input())
  X6, X9 = f(N)
  X = [1] + X6 + X9
  dp = [0 for _ in range(N+1)]
  for i in range(1, N+1):
    can = []
    for x in X:
      can.append(dp[i-x] + 1)
    dp[i] = min(can)
  print(dp[N])

if __name__ == '__main__':
  main()

Failing test case input:
1214

Expected output:
8


Actual output:
2


Fixed submission (verdict: Accepted):
import sys

def f(n):
  X6 = []
  X9 = []
  for i in range(1, 10):
    if n >= 6**i:
      X6.append(6**i)
    if n >= 9**i:
      X9.append(9**i)
  return X6, X9


def main():
  input = sys.stdin.readline
  N = int(input())
  dp = [0 for _ in range(N+1)]
  for i in range(1, N+1):
    can = []
    X6, X9 = f(i)
    X = [1] + X6 + X9
    for x in X:
      can.append(dp[i-x] + 1)
    dp[i] = min(can)
  print(dp[N])

if __name__ == '__main__':
  main()
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
dp = [0 for i in range(n)]
a = [1]
i = 1
_ = 6
while _ <= n:
    a.append(_)
    i += 1
    _ = 6 ** i
i = 1
_ = 9
while _ <= n:
    a.append(_)
    i += 1
    _ = 9 ** i
dp[0] = 1
len_a = len(a)
for i in range(n):
    target = []
    for j in range(len_a):
        if i + 1 >= a[j]:
            target.append(dp[i - a[j]])
    dp[i] = min(target) + 1
print('answer', dp[n-1])

Failing test case input:
581

Expected output:
10


Actual output:
answer 10


Fixed submission (verdict: Accepted):
n = int(input())
dp = [0 for i in range(n)]
a = [1]
i = 1
_ = 6
while _ <= n:
    a.append(_)
    i += 1
    _ = 6 ** i
i = 1
_ = 9
while _ <= n:
    a.append(_)
    i += 1
    _ = 9 ** i
len_a = len(a)
for i in range(n):
    target = []
    for j in range(len_a):
        if i + 1 >= a[j]:
            target.append(dp[i - a[j]])
    dp[i] = min(target) + 1
print(dp[n-1])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
n = int(input())

inf = float('inf')

dp = [inf]*(n+10000000)
dp[0]=0



def motome(target):
    tmp = []
    a = int(math.log(target,9))
    b = int(math.log(target,6))
    for i in range(a+1):
        tmp.append(6**i)
    for j in range(b+1):
        tmp.append(9**j)
    
    
    for k in range(1,target+1):
        for t in sorted(list(set(tmp))):
            if k-t>=0:
                dp[k] = min(dp[k],1 + dp[k-t])
                
        
        
        

motome(n)

print(dp[n])

Failing test case input:
3008

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
import math
n = int(input())

inf = float('inf')

dp = [inf]*(n+100000)
dp[0]=0



def motome(target):
    tmp = []
    for i in range(10):
        if 9**i <= n:
            tmp.append(9**i)
        if 6**i <= n:
            tmp.append(6**i)
    
    
    
    for k in range(target+1):
        for t in sorted(list(set(tmp))):
            if k-t>=0:
                dp[k] = min(dp[k],1 + dp[k-t])
                
                
        
        
        

motome(n)

print(dp[n])
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import log
N = int(input())

hiki9 = []
hiki6 = []
n = int(log(N) / log(9))
for i in range(n+1):
    hiki9.append(9**i)
n = int(log(N) / log(6))
for i in range(n+1):
    hiki6.append(6**i)
hiki9.sort(reverse=True)
hiki6.sort(reverse=True)
x = []
for i in range(1, N+1):
    n9 = i
    tmpx = 0
    for h in hiki9:
        while h <= n9:
            n9 -= h
            tmpx += 1
    n6 = N - i
    for h in hiki6:
        while h <= n6:
            n6 -= h
            tmpx += 1
    x.append(tmpx)
x.sort()
print(x[0])

Failing test case input:
4152

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
from math import log
N = int(input())

hiki9 = []
hiki6 = []
n = int(log(N) / log(9) + 1)  
for i in range(n+1):
    hiki9.append(9**i)
n = int(log(N) / log(6) + 1)
for i in range(n+1):
    hiki6.append(6**i)
hiki9.sort(reverse=True)
hiki6.sort(reverse=True)
x = []
for i in range(N+1):
    n9 = i
    tmpx = 0
    for h in hiki9:
        while h <= n9:
            n9 -= h
            tmpx += 1
    n6 = N - i
    for h in hiki6:
        while h <= n6:
            n6 -= h
            tmpx += 1
    x.append(tmpx)
x.sort()
print(x[0])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

n = 44852
inf = float('inf')

dp = [inf]*(n+10000000)
dp[0]=0



def motome(target):
    tmp = []
    a = int(math.log(target,9))
    b = int(math.log(target,6))
    for i in range(a+1):
        tmp.append(6**i)
    for j in range(b+1):
        tmp.append(9**j)
    
    
    for k in range(1,target+1):
        for t in sorted(list(set(tmp))):
            if k-t>=0:
                dp[k] = min(dp[k],1 + dp[k-t])
                
        
        
        

motome(n)

print(dp[n])

Failing test case input:
581

Expected output:
10


Actual output:
17


Fixed submission (verdict: Accepted):
import math
n = int(input())

inf = float('inf')

dp = [inf]*(n+100000)
dp[0]=0



def motome(target):
    tmp = []
    for i in range(10):
        if 9**i <= n:
            tmp.append(9**i)
        if 6**i <= n:
            tmp.append(6**i)
    
    
    
    for k in range(target+1):
        for t in sorted(list(set(tmp))):
            if k-t>=0:
                dp[k] = min(dp[k],1 + dp[k-t])
                
                
        
        
        

motome(n)

print(dp[n])
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ans = N

for i in range(N):
    tmp = 0
    a_6 = Base_10_to_n(i, 6)
    for j in a_6:
        tmp += int(j)
    a_9 = Base_10_to_n(N - i, 9)
    for k in a_9:
        tmp += int(k)
    if tmp < ans:
        ans = tmp

print(ans)   




Failing test case input:
24408

Expected output:
8


Actual output:
9


Fixed submission (verdict: Accepted):

N = int(input())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ans = N

for i in range(N + 1):
    tmp = 0
    a_6 = Base_10_to_n(i, 6)
    for j in a_6:
        tmp += int(j)
    a_9 = Base_10_to_n(N - i, 9)
    for k in a_9:
        tmp += int(k)
    if tmp < ans:
        ans = tmp

print(ans)

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

INF = 10**9

dp = [INF] * (n+1)
dp[1] = 1

for i in range(1, n):
    dp[i+1] = min(dp[i+1], dp[i] +1)
    six = 6
    while i + six <= n:
        dp[i + six] = min(dp[i+six], dp[i] + 1)
        six *= 6
    nine = 9
    while i + nine <= n:
        dp[i + nine] = min(dp[i+nine], dp[i] + 1)
        nine *= 9
print(dp[-1])

Failing test case input:
27198

Expected output:
7


Actual output:
10


Fixed submission (verdict: Accepted):
n = int(input())

INF = 10**9

dp = [INF] * (n+1)
dp[0] = 0

for i in range(n):
    dp[i+1] = min(dp[i+1], dp[i] +1)
    six = 6
    while i + six <= n:
        dp[i + six] = min(dp[i+six], dp[i] + 1)
        six *= 6
    nine = 9
    while i + nine <= n:
        dp[i + nine] = min(dp[i+nine], dp[i] + 1)
        nine *= 9
print(dp[-1])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
coins = [1]
t = 6 
while t <= n:
    coins.append(t)
    t *= 6

t = 9
while t <= n:
    coins.append(t)
    t *= 9

coins.sort()

dp = [ float("inf") for _ in range(n+10) ]
dp[1] = 1

for i in range(1, n+1):
    for c in coins:
        if i + c > n:
            continue
        dp[i+c] = min(dp[i+c], dp[i]+1)

print(dp[n])

Failing test case input:
34020

Expected output:
5


Actual output:
14


Fixed submission (verdict: Accepted):
n = int(input())
coins = [1]
t = 6 
while t <= n:
    coins.append(t)
    t *= 6

t = 9
while t <= n:
    coins.append(t)
    t *= 9

coins.sort()

dp = [ float("inf") for _ in range(n+10) ]
dp[0] = 0

for i in range(n+1):
    for c in coins:
        if i + c > n:
            continue
        dp[i+c] = min(dp[i+c], dp[i]+1)

print(dp[n])
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
dp = [100000000000 for _ in range(n+1)]
dp[0] = 0
for i in range(n):
    dp[i+1] = min(dp[i]+1,dp[i+1])
    six = 0
    nine = 0
    while (6**six < i):
        dp[i+1] = min(dp[(i+1) - 6**six] + 1,dp[i+1])
        six += 1
    while (9**nine < i):
        dp[i+1] = min(dp[(i+1) - 9**nine] + 1,dp[i+1])
        nine += 1
print(dp[-1])

Failing test case input:
24408

Expected output:
8


Actual output:
12


Fixed submission (verdict: Accepted):
n = int(input())
dp = [100000000000 for _ in range(n+1)]
dp[0] = 0
for i in range(1,n+1):
    dp[i] = min(dp[i-1]+1,dp[i])
    six = 0
    nine = 0
    while (6**six <= i):
        dp[i] = min(dp[i - 6**six] + 1,dp[i])
        six += 1
    while (9**nine <= i):
        dp[i] = min(dp[i - 9**nine] + 1,dp[i])
        nine += 1
print(dp[n])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

res = 100000

for i in range(N+1):
  t = i
  cc = 0
  while t>0:
    cc += t%6
    t = int(t/6)
  t = N-i
  while t>0:
    cc += t%9
    t = int(t/9)
  if res > cc:
    res = cc

print(cc)
  

Failing test case input:
7553

Expected output:
7


Actual output:
23


Fixed submission (verdict: Accepted):
N = int(input())

res = 100000

for i in range(N+1):
  cc = 0
  t = i
  while t>0:
    cc += t%6
    t = int(t/6)
  t = N-i
  while t>0:
    cc += t%9
    t = int(t/9)
  if res > cc:
    res = cc

print(res)

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
c = [6**i for i in range(7)]
c.extend([9**i for i in range(1, 6)])
c = sorted(c)[::-1]
ans = 0
while True:
    for c_ in c:
        if n>=c_:
            n-=c_
            ans += 1
            break
    if n<6:
        break
print(ans+n)

Failing test case input:
3715

Expected output:
8


Actual output:
9


Fixed submission (verdict: Accepted):
n = int(input())
c = [6**i for i in range(1,7)]
c.extend([9**i for i in range(1, 6)])
c = sorted(c)[::-1]
dp = [0]*1000000
for i in range(1,n+1):
    dp[i]=dp[i-1]+1
    for c_ in c:
        if i>=c_:
            dp[i]=min(dp[i],dp[i-c_]+1)
print(dp[n])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
dp=[10**5]*n
dp[0]=1
for i in range(n):
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=6
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=9
print(dp[n-1])


Failing test case input:
4152

Expected output:
7


Actual output:
9


Fixed submission (verdict: Accepted):
n=int(input())
dp=[10**5]*(n+1)
dp[0]=0
for i in range(n+1):
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=6
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=9
print(dp[n])
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())




li = []
for i in range(1, 6):
  li.append(9**i)
  li.append(6**i)

li.append(6**6)
li.append(1)
li.sort(reverse=True)



cnt = 0
while n != 0:
  for j in li:
    if n - j >= 0:

      n -= j
      cnt += 1
      break
print(cnt)

Failing test case input:
44852

Expected output:
16

Actual output:
18


Fixed submission (verdict: Accepted):
n = int(input())




li = []
for i in range(1, 6):
  li.append(9**i)
  li.append(6**i)
li.append(6**6)
li.append(1)
li.sort()


DP = list(range(n + 1))

for l in li:
    for j in range(l, n + 1):
        DP[j] = min(DP[j - l] + 1, DP[j])
print(DP[-1])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
arr = sorted([6**x for x in range(1, 9) if 6**x <= N] + [9**x for x in range(1, 9) if 9**x <= N])
dp = [i for i in range(0,N+1)]
for i in range(2, N+1):
    dp[i] = 1+dp[i-1]
    for c in arr:
        if i - c > 0:
            dp[i] = min([dp[i], 1+dp[i-c]])
print(dp[-1])

Failing test case input:
34020

Expected output:
5


Actual output:
14


Fixed submission (verdict: Accepted):
N = int(input())
arr = sorted([6**x for x in range(1, 9) if 6**x <= N] + [9**x for x in range(1, 9) if 9**x <= N])
dp = [i for i in range(0,N+1)]
for i in range(2, N+1):
    dp[i] = 1+dp[i-1]
    for c in arr:
        if i - c >= 0:
            dp[i] = min([dp[i], 1+dp[i-c]])
print(dp[-1])

Problem: p03329
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
MAXN = 110000

f_inf = float('inf')
dp = [f_inf] * (MAXN+n)

dp[0] = 0

for i in range(1, n+2):
    for j in range(5):
        dp[i] = min(dp[i], dp[i-pow(6, j)]+1)
    for k in range(5):
        dp[i] = min(dp[i], dp[i-pow(9, k)]+1)

print(dp[n])

Failing test case input:
24408

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
n = int(input())
MAXN = 110000

f_inf = float('inf')
dp = [f_inf] * (MAXN+n)

dp[0] = 0

for i in range(1, n+2):
    for j in range(7):
        dp[i] = min(dp[i], dp[i-pow(6, j)]+1)
    for k in range(6):
        dp[i] = min(dp[i], dp[i-pow(9, k)]+1)

print(dp[n])
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy
N=int(input())
six = [6**i for i in range(1,8)][::-1]
nine = [9**i for i in range(1,8)] [::-1]
def DP(n):
	if n < 6:
		return n
	tmp = n
	count6 = 0
	count9 = 0
	for sixx in six:
		if sixx <= n:
			n -= sixx
			count6 = 1
			break
	count6 += DP(n)
	n = tmp
	if n < 9:
		return n
	for ninee in nine:
		if ninee<= n:
			n -= ninee
			count9 = 1
			break
	count9 += DP(n)
	n = tmp
	return min(count6,count9)
print(DP(N))

Failing test case input:
8459

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
import copy
N=int(input())
six = [6**i for i in range(1,8)][::-1]
nine = [9**i for i in range(1,8)] [::-1]
def DP(n):
	if n < 6:
		return n
	tmp = n
	count6 = 0
	count9 = 0
	for sixx in six:
		if sixx <= n:
			n -= sixx
			count6 = 1
			break
	count6 += DP(n)
	n = tmp
	if n < 9:
		return count6
	for ninee in nine:
		if ninee<= n:
			n -= ninee
			count9 = 1
			break
	count9 += DP(n)
	n = tmp
	return min(count6,count9)
print(DP(N))

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

ans = N

for A in range(N):
    counter = 0
    temp = A
    while temp > 0:
        q, r = divmod(temp, 6)
        counter += r
        temp = q
        
    temp = N - A
    while temp > 0:
        q, r = divmod(temp, 9)
        counter += r
        temp = q

    if counter < ans:
        ans = counter

print(ans)


Failing test case input:
24408

Expected output:
8


Actual output:
9


Fixed submission (verdict: Accepted):
N = int(input())

ans = N

for A in range(N+1):
    counter = 0
    temp = A
    while temp > 0:
        q, r = divmod(temp, 6)
        counter += r
        temp = q

    temp = N - A
    while temp > 0:
        q, r = divmod(temp, 9)
        counter += r
        temp = q

    if ans > counter:
        ans = counter

print(ans)

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
xs = [1]
i = 1
while N > 6**i:
    if 9**i < N:
        xs.append(9**i)
    xs.append(6**i)
    i += 1
X = sorted(xs)
print(X)


dp = [10000000000] * 1008000
dp[1] = 1
for i in range(N):
    for x in X:
        dp[i+x] = min(dp[i]+1, dp[i+x])
print(dp[N])

Failing test case input:
1477

Expected output:
5


Actual output:
[1, 6, 9, 36, 81, 216, 729, 1296]
5


Fixed submission (verdict: Accepted):
N = int(input())
xs = [1]
i = 1
while N >= 6**i:
    if 9**i <= N:
        xs.append(9**i)
    xs.append(6**i)
    i += 1
X = sorted(xs)



dp = [10000000000] * 1008000
dp[0] = 0
for i in range(N):
    for x in X:
        dp[i+x] = min(dp[i]+1, dp[i+x])
print(dp[N])
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())

dp = ['inf']*(N+1)

init = 6 if N > 5 else N+1
for n in range(init):
	dp[n] = n

for n in range(6,N+1):
	cnd = [dp[n-1]+1]
	for i in range(1,6):
		if n > 6**i-1:
			cnd.append(dp[n-6**i]+1)
	for j in range(1,5):
		if n > 9**j-1:
			cnd.append(dp[n-9**j]+1)
	dp[n] = min(cnd)
	
print(dp[N])

Failing test case input:
58523

Expected output:
12


Actual output:
15


Fixed submission (verdict: Accepted):

N = int(input())

dp = ['inf']*(N+1)

init = 6 if N > 5 else N+1
for n in range(init):
	dp[n] = n

for n in range(6,N+1):
	cnd = [dp[n-1]+1]
	for i in range(1,7):
		if n > 6**i-1:
			cnd.append(dp[n-6**i]+1)
	for j in range(1,6):
		if n > 9**j-1:
			cnd.append(dp[n-9**j]+1)
	dp[n] = min(cnd)
	
print(dp[N])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
dp=[10**5]*n
dp[0]=0
for i in range(n):
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=6
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=9
print(dp[n-1])


Failing test case input:
1214

Expected output:
8


Actual output:
7


Fixed submission (verdict: Accepted):
n=int(input())
dp=[10**5]*(n+1)
dp[0]=0
for i in range(n+1):
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=6
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=9
print(dp[n])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [1]
for i in [6,9]:
    j = 1
    while i**j<100000:
        a.append(i**j)
        j += 1
a.sort()
a.reverse()
ans = 0
for i in a:
    ans += n
    n -= n
print(ans)


Failing test case input:
9247

Expected output:
6


Actual output:
9247


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in [6,9]:
    j = 1
    while i**j<1000000:
        a.append(i**j)
        j += 1
a.sort()
dp = [i for i in range(n+1)]
dp[0]= 0
for c in a:
    for i in range(c,n+1):
        dp[i] = min(dp[i-c]+1, dp[i])
print(dp[n])

Problem: p03329
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
MAXN = 110000

f_inf = float('inf')
dp = [f_inf] * (MAXN+n)

dp[0] = 0

for i in range(1, n+2):
    for j in range(6):
        dp[i] = min(dp[i], dp[i-pow(6, j)]+1)
    for k in range(6):
        dp[i] = min(dp[i], dp[i-pow(9, k)]+1)

print(dp[n])

Failing test case input:
58523

Expected output:
12


Actual output:
15


Fixed submission (verdict: Accepted):
n = int(input())
MAXN = 110000

f_inf = float('inf')
dp = [f_inf] * (MAXN+n)

dp[0] = 0

for i in range(1, n+2):
    for j in range(7):
        dp[i] = min(dp[i], dp[i-pow(6, j)]+1)
    for k in range(6):
        dp[i] = min(dp[i], dp[i-pow(9, k)]+1)

print(dp[n])
Problem: p03329
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


n = int(input())

ans = [-1]*n

ans[0] = 1
for i in range(1, n):
    num = i
    data = ans[i-1]+1
    for j in range(7):
        index = i-6**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    for j in range(7):
        index = i-9**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    ans[i] = data
print(ans[-1])


Failing test case input:
34020

Expected output:
5


Actual output:
14


Fixed submission (verdict: Accepted):


n = int(input())

ans = [-1]*(n+1)

ans[0] = 0
for i in range(1, n+1):
    num = i
    data = ans[i-1]+1
    for j in range(8):
        index = i-6**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    for j in range(8):
        index = i-9**j
        if index < 0:
            break
        data = min(data, ans[index]+1)
    ans[i] = data
print(ans[-1])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def run():
  N = int(input())
  dp = [1] * (N+1)
  for n in range(1, N+1):
    if n == 1: continue
    dp[n] = dp[n-1]+1
    draw_money = 6
    while True:
      if n <= draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 6
    draw_money = 9
    while True:
      if n <= draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 9
  print(dp[N])
  
if __name__ == '__main__':
  run()

Failing test case input:
32841

Expected output:
6


Actual output:
11


Fixed submission (verdict: Accepted):
def run():
  N = int(input())
  dp = [0] * (N+1)
  dp[1] = 1
  for n in range(1, N+1):
    if n == 1: continue
    dp[n] = dp[n-1]+1
    draw_money = 6
    while True:
      if n < draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 6
    draw_money = 9
    while True:
      if n < draw_money: break
      dp[n] = min(dp[n], dp[n-draw_money]+1)
      draw_money *= 9
  print(dp[N])
  
if __name__ == '__main__':
  run()
Problem: p03329
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N = int(input())

coins = [(9 ** i) for i in range(1, 7)] + [(6 ** i) for i in range(1, 8)] + [1]
print(coins)
dp = [INF] * (N + 1)
dp[0] = 0
for i in range(len(coins)):
    for j in range(N + 1):
        if j + coins[i] > N:
            continue
        dp[j + coins[i]] = min(dp[j + coins[i]], dp[j] + 1)
print(dp[N])


Failing test case input:
14816

Expected output:
8


Actual output:
[9, 81, 729, 6561, 59049, 531441, 6, 36, 216, 1296, 7776, 46656, 279936, 1]
8


Fixed submission (verdict: Accepted):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N = int(input())

coins = [(9 ** i) for i in range(1, 7)] + [(6 ** i) for i in range(1, 8)] + [1]
dp = [INF] * (N + 1)
dp[0] = 0
for i in range(len(coins)):
    for j in range(N + 1):
        if j + coins[i] > N:
            continue
        dp[j + coins[i]] = min(dp[j + coins[i]], dp[j] + 1)
print(dp[N])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

N = int(input())
ans = N

for N1 in range(N):
    
    count = 0
    N2 = N - N1

    while N1 > 0:
        count += N1%6
        N1 = math.floor(N1/6)
    
    while N2 > 0:
        count += N2%9
        N2 = math.floor(N2/9)
    
    if ans > count:
        ans = count

print(ans)

Failing test case input:
24408

Expected output:
8


Actual output:
9


Fixed submission (verdict: Accepted):
N = int(input())
ans = N

for N1 in range(N+1):
    
    count = 0
    N2 = N - N1

    while N1 > 0:
        count += N1%6
        N1 = int(N1/6)
    
    while N2 > 0:
        count += N2%9
        N2 = int(N2/9)
    
    if ans > count:
        ans = count

print(ans)
Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

dp = [N] * (N + 1)
dp[0] = 0
for i in range(N):
    dp[i + 1] = min(dp[i + 1], dp[i] + 1)
    six = 6
    nine = 9
    for p in range(20):
        if i + six <= N:
            dp[i + six] = min(dp[i + six], dp[i] + 1)
        if i + nine <= N:
            dp[i + nine] = min(dp[i + nine], dp[i] + 1)
        if nine > N:
            break
        six *= 6
        nine *= 9

print(dp[N])

Failing test case input:
58523

Expected output:
12


Actual output:
15


Fixed submission (verdict: Accepted):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

dp = [N] * (N + 1)
dp[0] = 0
for i in range(N):
    dp[i + 1] = min(dp[i + 1], dp[i] + 1)
    six = 6
    nine = 9
    for p in range(10):
        if i + six <= N:
            dp[i + six] = min(dp[i + six], dp[i] + 1)
        if i + nine <= N:
            dp[i + nine] = min(dp[i + nine], dp[i] + 1)
        six *= 6
        nine *= 9

print(dp[N])

Problem: p03329
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N = int(input())
N_max = 100000

dp = ['inf']*2*N_max
for n in range(6):
	dp[n] = n

for n in range(6,N+1):
	cnd = [dp[n-1]+1]
	for i in range(1,7):
		if n > 6**i-1:
			cnd.append(dp[n-6**i]+1)
	for j in range(1,5):
		if n > 9**j-1:
			cnd.append(dp[n-9**j]+1)
	dp[n] = min(cnd)
	
print(dp[N])

Failing test case input:
66223

Expected output:
9


Actual output:
10


Fixed submission (verdict: Accepted):

N = int(input())

dp = ['inf']*(N+1)

init = 6 if N > 5 else N+1
for n in range(init):
	dp[n] = n

for n in range(6,N+1):
	cnd = [dp[n-1]+1]
	for i in range(1,7):
		if n > 6**i-1:
			cnd.append(dp[n-6**i]+1)
	for j in range(1,6):
		if n > 9**j-1:
			cnd.append(dp[n-9**j]+1)
	dp[n] = min(cnd)
	
print(dp[N])
Problem: p03386
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a, b, k = map(int, input().split())
if b - a > k+1:
    for i in range(k):
        print(a+i)
    for i in range(k):
        print(b-k+i+1)
else:
    for i in range(b-a+1):
        print(a+i)

Failing test case input:
2 14 9

Expected output:
2
3
4
5
6
7
8
9
10
11
12
13
14


Actual output:
2
3
4
5
6
7
8
9
10
6
7
8
9
10
11
12
13
14


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())
if b - a > 2*(k-1):
    for i in range(k):
        print(a+i)
    for i in range(k):
        print(b-k+i+1)
else:
    for i in range(b-a+1):
        print(a+i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = map(int, input().split())
myset  = set()
for i in range(K):
    if(A+i < B):
        myset.add(A + i)
        myset.add(B - i)
ans = sorted(list(myset))
[print(x) for x in ans]

Failing test case input:
6 6 110

Expected output:
6


Actual output:

Fixed submission (verdict: Accepted):
A, B, K = map(int, input().split())
myset  = set()
for i in range(K):
    if(A+i <= B):
        myset.add(A + i)
        myset.add(B - i)
ans = sorted(list(myset))
[print(x) for x in ans]

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int, input().split())
ans = []
for i in range(k):
    if i+a <= b:
        ans.append(i+a)
    if b-i >= a:
        ans.append(b-i)
ans.sort()
for i in set(ans):
    print(i)

Failing test case input:
3 13 2

Expected output:
3
4
12
13


Actual output:
13
3
4
12


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())
ans = []
if b-a < 2*k:
    for i in range(a, b+1):
        print(i)
else:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)

Problem: p03386
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, K = map(int, input().split())
SA = list(range(A, min(B, A + K)))
SB = list(range(max(A, B - K) + 1, B + 1))

ans = sorted(set(SA + SB))
for a in ans:
    print(a)

Failing test case input:
6 6 110

Expected output:
6


Actual output:

Fixed submission (verdict: Accepted):
A, B, K = map(int, input().split())
SA = list(range(A, min(B, A + K)))
SB = list(range(max(A, B - K + 1), B + 1))

ans = sorted(set(SA + SB))
for a in ans:
    print(a)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,x = map(int,input().split())
a_set = set(range(a,min(a+x,b)))
b_set = set(range(max(a,b-x+1),b+1))

print(a_set)
print(b_set)

a_set = a_set.union(b_set)
ans_list = list(a_set)
ans_list.sort()
for ans in ans_list:
  print(ans)

Failing test case input:
3 8 2

Expected output:
3
4
7
8

Actual output:
{3, 4}
{8, 7}
3
4
7
8


Fixed submission (verdict: Accepted):
a,b,x = map(int,input().split())
a_set = set(range(a,min(a+x,b)))
b_set = set(range(max(a,b-x+1),b+1))




a_set = a_set.union(b_set)
ans_list = list(a_set)
ans_list.sort()
for ans in ans_list:
  print(ans)
Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = map(int,input().split())
lis = []
x = min(b-a,k)
for i in range(a,a+x):
    lis.append(i)
for j in range(b,b-x,-1):
    lis.append(j)
ans = sorted(set(lis))
for k in ans:
    print(k)

Failing test case input:
6 6 110

Expected output:
6


Actual output:

Fixed submission (verdict: Accepted):
a,b,k = map(int,input().split())
if a == b:
    print(a)
    exit()
lis = []
x = min(b-a,k)
for i in range(a,a+x):
    lis.append(i)
for j in range(b,b-x,-1):
    lis.append(j)
ans = sorted(set(lis))
for k in ans:
    print(k)

Problem: p03386
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
A,B,K = map(int,input().split())
s = []

for i in range(K):
    if A+i <= B:
        s.append(A+i)
for i in range(K):
    if B-K+1+i >= A:
        s.append(B-K+1+i)
s = set(s)
for i in s:
    print(i)

Failing test case input:
-2 14 5

Expected output:
-2
-1
0
1
2
10
11
12
13
14


Actual output:
0
1
2
10
11
12
13
14
-1
-2


Fixed submission (verdict: Accepted):
A,B,K = map(int,input().split())
s = []

for i in range(K):
    if A+i <= B:
        s.append(A+i)
for i in range(K):
    if B-K+1+i >= A:
        s.append(B-K+1+i)
s = set(s)
Ans = []
for i in s:
    Ans.append(i)
Ans = sorted(Ans)
for i in Ans:
    print(i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,K = map(int, input().split())
List = [i for i in range(A,B+1)]
s = [i for i in range(A,A+K)]
l = [j for j in range(B-K+1,B+1)]
for k in l:
    s.append(k)
w = sorted(set(s))
for j in w:
    print(j)

Failing test case input:
2 12 110

Expected output:
2
3
4
5
6
7
8
9
10
11
12


Actual output:
-97
-96
-95
-94
-93
-92
-91
-90
-89
-88
-87
-86
-85
-84
-83
-82
-81
-80
-79
-78
-77
-76
-75
-74
-73
-72
-71
-70
-69
-68
-67
-66
-65
-64
-63
-62
-61
-60
-59
-58
-57
-56
-55
-54
-53
-52
-51
-50
-49
-48
-47
-46
-45
-44
-43
-42
-41
-40
-39
-38
-37
-36
-35
-34
-33
-32
-31
-30
-29
-28
-27
-26
-25
-24
-23
-22
-21
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111


Fixed submission (verdict: Accepted):
A,B,K = map(int, input().split())
if B-A+1 >= K:
    s = [i for i in range(A,A+K)]
    l = [j for j in range(B-K+1,B+1)]
    for k in l:
        s.append(k)
    w = sorted(set(s))
else:
    w = [b for b in range(A,B+1)]
for j in w:
    print(j)
Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int, input().split())
ans = []
for i in range(a, min(a+k, b)):
    ans.append(i)
for i in range(b, max(b-k, a), -1):
    ans.append(i)
ans = list(set(ans))
ans.sort()
for i in ans:
    print(i)

Failing test case input:
6 6 110

Expected output:
6


Actual output:

Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())
ans = []
for i in range(a, min(a+k, b+1)):
    ans.append(i)
for i in range(b, max(b-k, a-1), -1):
    ans.append(i)
ans = list(set(ans))
ans.sort()
for i in ans:
    print(i)

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = map(int, input().split())
lists = [i for i in range(A, B+1)]
list1 = lists[:K]
list2 = lists[(B-K-A+1):]
for i in list1:
    print(i)
for i in list2:
    print(i)

Failing test case input:
2 4 110

Expected output:
2
3
4


Actual output:
2
3
4
2
3
4


Fixed submission (verdict: Accepted):
A, B, K = map(int, input().split())
list = [i for i in range(A, A+K)]
list.extend(i for i in range(B+1-K, B+1))
list = sorted(set(list))
for i in list:
    if A<=i<=B:
        print(i)

Problem: p03386
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):



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

ans = []
for i in range(k):
    if a+i <= b:
        ans.append(a+i)
for i in range(k):
    if b-(k-i)+1 >= a:
        ans.append(b-(k-i)+1)
ans = list(set(ans))
for i in range(len(ans)):
    print(ans[i])


Failing test case input:
-4 14 7

Expected output:
-4
-3
-2
-1
0
1
2
8
9
10
11
12
13
14


Actual output:
0
1
2
8
9
10
11
12
13
14
-1
-4
-3
-2


Fixed submission (verdict: Accepted):



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

ans = []
for i in range(k):
    if a+i <= b:
        ans.append(a+i)
for i in range(k):
    if b-(k-i)+1 >= a:
        ans.append(b-(k-i)+1)
ans = list(set(ans))
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Problem: p03386
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = map(int,input().split())
s1 = set(range(a,a+k))
s2 = set(range(b,b-k,-1))
s0 = list(s2 | s1)
s0.sort()
[print(s0[i]) for i in range(len(s0))]

Failing test case input:
5 6 110

Expected output:
5
6


Actual output:
-103
-102
-101
-100
-99
-98
-97
-96
-95
-94
-93
-92
-91
-90
-89
-88
-87
-86
-85
-84
-83
-82
-81
-80
-79
-78
-77
-76
-75
-74
-73
-72
-71
-70
-69
-68
-67
-66
-65
-64
-63
-62
-61
-60
-59
-58
-57
-56
-55
-54
-53
-52
-51
-50
-49
-48
-47
-46
-45
-44
-43
-42
-41
-40
-39
-38
-37
-36
-35
-34
-33
-32
-31
-30
-29
-28
-27
-26
-25
-24
-23
-22
-21
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114


Fixed submission (verdict: Accepted):
a,b,k = map(int,input().split())
s1 = set(range(a,min(a+k,b+1)))
s2 = set(range(b,max(b-k,a-1),-1))
s0 = sorted(s1|s2)
[print(s0[i]) for i in range(len(s0))]