Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    A_keys = A.keys()
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while True:
            if not b in A_keys:
                break
            else:
                cnt += B[b]
            b += b
            if not cnt % 2 == A[i]:
                B[i] = 1
            else:
                B[i] = 0
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while b <= N:
            cnt += B[b]
            b += i
        if not cnt % 2 == A[i]:
            B[i] = 1
        else:
            B[i] = 0
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    A_keys = A.keys()
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while True:
            if not b in A_keys:
                break
            else:
                cnt += B[b]
            b += b
        if not cnt % 2 == A[i]:
            B[i] = 1
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while b <= N:
            cnt += B[b]
            b += i
        if not cnt % 2 == A[i]:
            B[i] = 1
        else:
            B[i] = 0
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import numpy as np

def main():
    N, D = input_nums()
    Xs = {}
    for i in range(N):
        Xs[i] = np.array(input_nums())
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            a = np.sqrt(np.sum(np.square(Xs[i] - Xs[j])))
            if a == int(a):
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import numpy as np

def main():
    N, D = input_nums()
    Xs = {}
    for i in range(N):
        Xs[i] = np.array(input_nums())
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            a = np.sqrt(np.sum(np.square(Xs[i] - Xs[j])))
            if a == int(a):
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    L, R = input_nums()
    MOD = 2019
    a = L%MOD
    b = R%MOD
    if a < b and R - L < 2019:
        print((a*(a+1))%MOD)
    else:
        print(0)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1,d2,d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n = II()
    aa = MII()
    total = sum(aa)
    x1 = total - 2*sum(aa[1::2])
    ans = [x1]
    for i in range(0, n-1):
        ans.append(2*aa[i]-ans[-1])
    print(*ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

def count_div(a, b, div):
    ac = a // div
    if ac * div < a:
        ac += 1
    bc = b // div
    if bc * div > b:
        bc -= 1
    return bc - ac + 1

if __name__ == '__main__':
    A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]

    nc = count_div(A, B, C)
    
    nd = count_div(A, B, D)
    
    CD = int(C * D / math.gcd(C, D))
    ncd = count_div(A, B, CD)
    
    n = B - A + 1
    
    ans = n - (nc + nd - ncd)
    print(ans)

Fixed submission:
from sys import stdin

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

def count_div(a, b, div):
    ac = a // div
    if ac * div < a:
        ac += 1
    bc = b // div
    if bc * div > b:
        bc -= 1
    return bc - ac + 1

if __name__ == '__main__':
    A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]

    nc = count_div(A, B, C)
    
    nd = count_div(A, B, D)
    
    CD = int(C * D / gcd(C, D))
    ncd = count_div(A, B, CD)
    
    n = B - A + 1
    
    ans = n - (nc + nd - ncd)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n, m = MII()
    a_lst = [II() for _ in range(m)]
    DIV = 10**9+7
    stairs = [1]*2 + [0]*(n-1)
    for a in a_lst:
        stairs[a] = 'NG'
    cnt = 0
    for i in range(2, n+1):
        if cnt == 2:
            print(0)
            exit(1)
        if stairs[i] == 'NG': cnt += 1; continue
        cnt = 0
        a = stairs[i-1] if stairs[i-1] != 'NG' else 0
        b = stairs[i-2] if stairs[i-2] != 'NG' else 0
        stairs[i] = a + b
    print(stairs[n]%DIV)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n, m = MII()
    a_lst = [II() for _ in range(m)]
    DIV = 10**9+7
    stairs = [1]*2 + [0]*(n-1)
    for a in a_lst:
        stairs[a] = 'NG'
    cnt = 0
    for i in range(2, n+1):
        if cnt == 2:
            print(0)
            exit(0)
        if stairs[i] == 'NG': cnt += 1; continue
        cnt = 0
        a = stairs[i-1] if stairs[i-1] != 'NG' else 0
        b = stairs[i-2] if stairs[i-2] != 'NG' else 0
        stairs[i] = a + b
    print(stairs[n]%DIV)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    h, w = MII()
    ss = []
    for i in range(h):
        ss.append(IS())
    

    L = [[0]*w for _ in range(h)]
    R = [[0]*w for _ in range(h)]
    D = [[0]*w for _ in range(h)]
    U = [[0]*w for _ in range(h)]

    for i in range(h):
        for j in range(w):
            if ss[i][j] == '#': L[i][j] = 0; continue
            if j == 0: L[i][j] = 1; continue
            if j > 0: L[i][j] = L[i][j-1] + 1; continue

    for i in range(h):
        for j in reversed(range(w)):
            if ss[i][j] == '#': R[i][j] = 0; continue
            if j == w-1: R[i][j] = 1; continue
            if j < w-1: R[i][j] = R[i][j+1] + 1; continue

    for i in range(h):
        for j in range(w):
            if ss[i][j] == '#': D[i][j] = 0; continue
            if i == 0: D[i][j] = 1; continue
            if i > 0: D[i][j] = D[i-1][j] + 1; continue

    for i in reversed(range(h)):
        for j in range(w):
            if ss[i][j] == '#': U[i][j] = 0; continue
            if i == h-1: U[i][j] = 1; continue
            if i < h-1: U[i][j] = U[i+1][j] + 1; continue

    maxv = 0
    for i in range(h):
        for j in range(w):
            maxv = max(maxv, L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
    print(maxv)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    h, w = MII()
    ss = []
    for i in range(h):
        ss.append(IS())
    

    L = [[0]*w for _ in range(h)]
    R = [[0]*w for _ in range(h)]
    D = [[0]*w for _ in range(h)]
    U = [[0]*w for _ in range(h)]

    for i in range(h):
        for j in range(w):
            if ss[i][j] == '#': L[i][j] = 0; continue
            if j == 0: L[i][j] = 1; continue
            if j > 0: L[i][j] = L[i][j-1] + 1; continue

    for i in range(h):
        for j in reversed(range(w)):
            if ss[i][j] == '#': R[i][j] = 0; continue
            if j == w-1: R[i][j] = 1; continue
            if j < w-1: R[i][j] = R[i][j+1] + 1; continue

    for i in range(h):
        for j in range(w):
            if ss[i][j] == '#': D[i][j] = 0; continue
            if i == 0: D[i][j] = 1; continue
            if i > 0: D[i][j] = D[i-1][j] + 1; continue

    for i in reversed(range(h)):
        for j in range(w):
            if ss[i][j] == '#': U[i][j] = 0; continue
            if i == h-1: U[i][j] = 1; continue
            if i < h-1: U[i][j] = U[i+1][j] + 1; continue

    maxv = 0
    for i in range(h):
        for j in range(w):
            maxv = max(maxv, L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
    print(maxv)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

INF = 10**18
dp = np.array([INF] * 10**5)
h = np.concatenate([h, np.array([0]*(10**5 - len(h)))])

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])


Fixed submission:
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

INF = 10**18
dp = [INF] * (N + K)

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i + j < N:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
        else:
            break
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

INF = 10**18
dp = [INF] * 10**5
h = h + [0]*(10**5 - len(h))

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])


Fixed submission:
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

INF = 10**18
dp = [INF] * (N + K)

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i + j < N:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
        else:
            break
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(float, input().split()))

dp = [[0]*3100 for _ in range(3100)]

N = int(input())
P = input_nums()

dp[0][0] = 1.0

for i in range(N):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * P[i]
        dp[i+1][j] += dp[i][j] * (1-P[i])

res = 0.0
a = ((N+1)//2)
for j in range(a, N+1):
    res += dp[N][j]
print(res)


Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(float, input().split()))

dp = [[0]*3100 for _ in range(3100)]

N = int(input())
P = input_nums()

dp[0][0] = 1.0

for i in range(N):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * P[i]
        dp[i+1][j] += dp[i][j] * (1-P[i])

res = 0.0
a = ((N+1)//2)
for j in range(a, N+1):
    res += dp[N][j]
print(res)
Buggy python submission (verdict: Runtime Error):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def split_even_or_odd(vv, n, start):
    res = {}
    for i in range(start,n,2):
        v = vv[i]
        if not v in res.keys(): res[v] = 1
        else: res[v] += 1
    return res

def find_fs(target):
    maxk1 = maxv1 = 0
    for k, v in target.items():
        if maxv1 < v:
            maxk1, maxv1 = k, v
    maxk2 = maxv2 = 0
    for k, v in target.items():
        if maxv2 < v and maxk1 != k:
            maxk2, maxv2 = k, v
    return (maxk1, maxv1), (maxk2, maxv2)

def main():
    n = II()
    vv = MII()
    ee = split_even_or_odd(vv, n, 0)
    oo = split_even_or_odd(vv, n, 1)

    e1kv, e2kv = find_fs(ee)
    o1kv, o2kv = find_fs(oo)

    minv = 10**5
    if e1kv[0] != o1kv[0]:
        minv = min(minv, n - (e1kv[1] + o1kv[1]))
    else:
        minv = min(minv, n - (e1kv[1] + o2kv[1]))
        minv = min(minv, n - (e2kv[1] + o1kv[1]))
    print(minv)

if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin

n = stdin.readline().rstrip()

list = []
for i in range(3):
    list.append(n[i])

if list[0] == '1':
    list[0] = '9'
else:
    list[0] = '1'
if list[1] == '1':
    list[1] = '9'
else:
    list[1] = '1'
if list[2] == '1':
    list[2] = '9'
else:
    list[2] = '1'

ans = ''.join(list)

print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin

D, N = map(int, stdin.readline().rstrip().split())

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    print(100*N)
elif D == 2:
    if N == 100:
        pritn(1010000)
    else:
        print(10000*N)
    


Fixed submission:
from sys import stdin

D, N = map(int, stdin.readline().rstrip().split())

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(100*N)
elif D == 2:
    if N == 100:
        print(1010000)
    else:
        print(10000*N)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import collections

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()

people = []

for i in range(N):
    people.append(S[i])

tmp = collections.Counter(people[1:])
tmp2 = tmp['E']
tmp3 = collections.Counter(people[:N-1])
tmp4 = tmp['W']
minv = min(tmp2, tmp4)

for i in range(1, N-2):
    front = people[:i+1]
    tail = people[i+2:]
    tmp4 = collections.Counter(front)['W'] + collections.Counter(tail)['E']
    if tmp4 < minv:
        minv = tmp4

print(minv)


Fixed submission:
from sys import stdin
import collections

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()

people = []

for i in range(N):
    people.append(S[i])

tmp = collections.Counter(people[1:])
num_return = tmp['E']
minv = num_return

for i in range(1, N):
    if people[i] == 'E':
        num_return -= 1
    if people[i-1] == 'W':
        num_return += 1
    if num_return < minv:
        minv = num_return

print(minv)
Buggy python submission (verdict: Runtime Error):
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from enum import Enum, auto
#======================================================#
class State(Enum):
    UP = auto()
    DOWN = auto()
    HORI = auto()

def main():
    n = II()
    prev, *aa = MII()
    state = State.HORI
    cnt = 1
    for a in aa:
        if prev < a:
            if state == State.HORI:
                state = State.UP
            elif state == State.DOWN:
                cnt += 1
                state = State.HORI
        elif prev > a:
            if state == State.HORI:
                state = State.DOWN
            elif state == State.UP:
                cnt += 1
                state = State.HORI
        prev = a
    print(cnt)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from enum import Enum
#======================================================#
class State(Enum):
    UP = 1
    DOWN = 2
    HORI = 3

def main():
    n = II()
    prev, *aa = MII()
    state = State.HORI
    cnt = 1
    for a in aa:
        if prev < a:
            if state == State.HORI:
                state = State.UP
            elif state == State.DOWN:
                cnt += 1
                state = State.HORI
        elif prev > a:
            if state == State.HORI:
                state = State.DOWN
            elif state == State.UP:
                cnt += 1
                state = State.HORI
        prev = a
    print(cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

K, S = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                count += 1
print(count)

Fixed submission:
from sys import stdin

K, S = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

for x in range(K+1):
    for y in range(K+1):
        if (x + y >= S - K) and (x + y <= S):
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
from sys import stdin

N, x = [int(x) for x in stdin.readline().rstrip().split()]
candys = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

# xより多く入っている箱のキャンディは必ず食べる必要がある。
for i in range(N):
    if candys[i] > x:
        num = candys[i] - x
        candys[i] = x
        count += num
        print(candys)

print('count = ', count)
print('---------------------------')

# 隣り合った箱を見て、xを越えていれば食べる
for i in range(N-1):
    if candys[i] + candys[i+1] > x:
        num = candys[i] + candys[i+1] - x
        count += num
        candys[i+1] = candys[i+1] - num
        print(candys)
# 結果
print(count)


Fixed submission:
from sys import stdin

N, x = [int(x) for x in stdin.readline().rstrip().split()]
candys = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

# xより多く入っている箱のキャンディは必ず食べる必要がある。
for i in range(N):
    if candys[i] > x:
        num = candys[i] - x
        candys[i] = x
        count += num
        # print(candys)

# print('count = ', count)
# print('---------------------------')

# 隣り合った箱を見て、xを越えていれば食べる
for i in range(N-1):
    if candys[i] + candys[i+1] > x:
        num = candys[i] + candys[i+1] - x
        count += num
        candys[i+1] = candys[i+1] - num
        # print(candys)
# 結果
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
#created by  nit1n
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in  range(N) :
    for j in range (S+1) :
        dp[i+1][j] += 2*dp[i][j]
        dp[i+1][j] = dp[i+1][j]%mod
        if j +A[i] <= S :
            dp[i+1][j+A[i]] += dp[i][j] 
            dp[i+1][j+A[i]] %= mod


print(dp[N][S])

            
            


Fixed submission:
#created by  nit1n
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in  range(N) :
    for j in range (S+1) :
        dp[i+1][j] += 2*dp[i][j]
        dp[i+1][j] = dp[i+1][j]%mod
        if j +A[i] <= S :
            dp[i+1][j+A[i]] += dp[i][j] 
            dp[i+1][j+A[i]] %= mod


print(dp[N][S])
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    ans = 0
    for c in range(1, N):
        ans += solve(N-c)
    print(ans)

def solve(n):
    res = 0
    for i in range(1,n+1):
        if n % i == 0:
            res += 1
    return res

main()

Fixed submission:

def main():
    N = int(input())
    ans = sum((N-1)//i for i in range(1, N))
    print(ans)

main()

Buggy python submission (verdict: Runtime Error):
def main():
    N = input()
    ans = 0
    for c in range(1, N):
        ans += solve(N-c)
    print(ans)

def solve(n):
    res = 0
    for i in range(1,n//2):
        if n % i == 0:
            res += 1
    return res

main()

Fixed submission:

def main():
    N = int(input())
    ans = sum((N-1)//i for i in range(1, N))
    print(ans)

main()
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n = int(input())
    dp = [[False]*(n+1)]
    dp[0][0] = True
    way = [1] + [6**i for i in range(1,9) if 6**i <= n] + [9**i for i in range(1,7) if 9**i <= n]
    while True:
        newline = [False] * (n+1)
        for w in way:
            for i in range(0, n+1):
                if i - w < 0: continue
                if newline[i]: continue
                if dp[len(dp)-1][i-w]: newline[i] = True
                if newline[n]: return len(dp)
        dp.append(newline)

print(solve())

Fixed submission:
def solve():
    n = int(input())
    dp = [True] + [False]*(n+1)
    way = [1] + [6**i for i in range(1,9) if 6**i <= n] + [9**i for i in range(1,7) if 9**i <= n]
    loop_counter = 0
    while True:
        loop_counter += 1
        newdp = [False] * (n+1)
        for w in way:
            for i in range(w, n+1):
                if newdp[i]: continue
                if dp[i-w]: newdp[i] = True
                if newdp[n]: 
                    return loop_counter
        dp = [x for x in newdp]

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def solve():
    n = int(input())
    dp = deque([[False]*(n+1)])
    dp[0][0] = True
    way = [1] + [6**i for i in range(1,9) if 6**i <= n] + [9**i for i in range(1,7) if 9**i <= n]
    while True:
        newline = [False] * (n+1)
        for w in way:
            for i in range(0, n+1):
                if i - w < 0: continue
                if dp[0][i-w]: newline[i] = True
                if newline[n]:
                    return len(dp)
        dp.appendleft(newline)

print(solve())

Fixed submission:
def solve():
    n = int(input())
    dp = [True] + [False]*(n+1)
    way = [1] + [6**i for i in range(1,9) if 6**i <= n] + [9**i for i in range(1,7) if 9**i <= n]
    loop_counter = 0
    while True:
        loop_counter += 1
        newdp = [False] * (n+1)
        for w in way:
            for i in range(w, n+1):
                if newdp[i]: continue
                if dp[i-w]: newdp[i] = True
                if newdp[n]: 
                    return loop_counter
        dp = [x for x in newdp]

print(solve())
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input())
print('Yes' if A+B*2 >= C else 'No')

Fixed submission:
A, B, C = map(int, input().split())
print('Yes' if A+B>=C else 'No')