Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02883 (python)

Fixed submission:
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort()

import numpy as np

a = np.array(a)
f = np.array(f)
f_ = f[::-1]

left = -1
right = np.max(a*f_)

while left + 1 < right:
    mid = (left + right)//2
    x = np.maximum(0, a - (mid//f_) ).sum() <= k
    if x:
        right = mid
    else:
        left = mid

print(right)

Buggy submission (verdict: Runtime Error):

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

import numpy as np

a = np.array(a)
f = np.array(f)
f_ = f[::-1]

left = 0
right = np.max(a*f_)

while left + 1 < right:
    mid = (left + right)//2
    x = np.maximum(0, a - (mid//f_) ).sum() <= k
    if x:
        right = mid
    else:
        left = mid

print(right)
Problem p02900 (python)

Fixed submission:
a,b=list(map(int, input().split()))
def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def md(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def coprime(a, b):
    return gcd(a, b) == 1

c = md(gcd(a,b))
c.sort()
if len(c)== 1:
    count = 1
else:
    count = 1
    d = c[0]
    for i in c[1:]:
        if coprime(d, i):
            d = d*i
            count += 1
        else:
            continue

print(count)

Buggy submission (verdict: Runtime Error):
a,b=list(map(int, input().split()))
def gcd(a,b):
    while b:
        a, b = b, a%b
    return a

def md(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def coprime(a, b):
    return gcd(a, b) == 1

c = md(gcd(a,b))
c.sort()
if len(c)== 1:
    print(1)
else:
    count = 1
    d = c[0]
    for i in c[1:]:
        if coprime(d, i):
            d = d*i
            count += 1
        else:
            continue

print(count)
Problem p02901 (python)

Fixed submission:
n,m  = list(map(int, input().split()))
ab =[]
cs =[]
for i in range(m):
    ab.append(list(map(int, input().split())))
    cs.append(list(map(int, input().split())))

dp = [float("inf") for _ in range(1 << n)]
dp[0] = 0

for i in range(m):
    csbit = 0
    for j in cs[i]:
        csbit += 2**(j-1)
    for j in range(1 << n):
        dp[j | csbit] = min(dp[j | csbit], dp[j] + ab[i][0])

if dp[-1] == float("inf"):
    print(-1)
else:
    print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,m  = list(map(int, input().split()))
ab =[]
cs =[]
for i in range(m+1):
    ab.append(list(map(int, input().split())))
    cs.append(list(map(int, input().split())))

csbit = []
for i in cs:
    csum = 0
    for j in i:
        csum += 2**(j-1)
    csbit.append(csum)

dp = [float("inf") for _ in range(1 << n)]
dp[0] = 0

for i in range(m):
    for j in range(1 << n):
        dp[j | csbit[i]] = min(dp[j | csbit[i]], dp[j] + ab[i][0])

if dp[-1] == float("inf"):
    print(-1)
else:
    print(dp[-1])
Problem p02909 (python)

Fixed submission:
n = str(input())
a = ["Sunny", "Cloudy", "Rainy"]
b = [1, 2, 0]
print(a[b[a.index(n)]])

Buggy submission (verdict: Runtime Error):

n = int(input())
ab = str(input())

ans = set([0])
lenab = len(ab)
for h in range(lenab):
    abc = ab[h:]
    lenabc = lenab - h
    A = [0] * lenabc
    i = 1; j = 0
    midlen = lenabc//2
    while i < lenabc:
        while i+j < lenabc and abc[j] == abc[i+j] and j < midlen:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        ans.add(j)
        k= 1
        while lenabc-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k

print(max(ans))
Problem p02923 (python)

Fixed submission:
n1 = int(input())
n2 = list(map(int, input().split()))
if n1 == 1:
    print(0)
else:
    n3 = [n2[i] - n2[i+1] >= 0 for i in range(n1-1)]
    a1 = []
    a2 = 0
    for i in range(len(n3)):
        if n3[i]:
            a2 += 1
            if i == len(n3) - 1:
                a1.append(a2)
        else:
            a1.append(a2)
            a2 = 0
    print(max(a1))

Buggy submission (verdict: Runtime Error):

n1 = int(input())
n2 = list(map(int, input().split()))
n3 = [n2[i] - n2[i+1] >= 0 for i in range(n1-1)]
if n2 == 0:
    print(0)
a1 = []
a2 = 0
for i in range(len(n3)):
    if n3[i]:
        a2 += 1
        if i == len(n3) - 1:
            a1.append(a2)
    else:
        a1.append(a2)
        a2 = 0
print(max(a1))

Buggy submission (verdict: Runtime Error):

n1 = int(input())
n2 = list(map(int, input().split()))
n3 = [n2[i] - n2[i+1] >= 0 for i in range(n1-1)]
a1 = []
a2 = 0
for i in range(len(n3)):
    if n3[i]:
        a2 += 1
        if i == len(n3) - 1:
            a1.append(a2)
    else:
        a1.append(a2)
        a2 = 0
print(max(a1))

Buggy submission (verdict: Runtime Error):

n1 = int(input())
n2 = list(map(int, input().split()))
n3 = [n2[i] - n2[i+1] >= 0 for i in range(n1-1)]
a1 = []
a2 = 0
for i in range(len(n3)):
    if n3[i]:
        a2 += 1
        if i == len(n3) - 1:
            a1.append(a2)
    else:
        a1.append(a2)
        a2 = 0
print(max(a1))

Buggy submission (verdict: Runtime Error):

n1 = int(input())
n2 = list(map(int, input().split()))
n3 = [n2[i] - n2[i+1] >= 0 for i in range(n1-1)]
a1 = []
a2 = 0
for i in range(len(n3)):
    if n3[i]:
        a2 += 1
        if i == len(n3) - 1:
            a1.append(a2)
    else:
        a1.append(a2)
        a2 = 0
print(max(a1))
Problem p02934 (python)

Fixed submission:
n1 = int(input())
n2 = list(map(int, input().split()))
n3 = [1/n2[i] for i in range(len(n2))]
print(1/(sum(n3)))

Buggy submission (verdict: Runtime Error):
n1 = int(input())
n2 = list(map(int, input().split()))
print(1/((1/n2[0] + 1/n2[1])))
Problem p02946 (python)

Fixed submission:
n = list(map(int, input().split()))
k = n[0]
x = n[1]
s1 = x - k + 1
s2 = x + k - 1
a1 = list(range( (s1), (s2 + 1)  ))
print(" ".join(list(map(str, a1))))

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
k = n[0]
x = n[1]
s1 = n - x - 1
s2 = n + x - 1
print(list(range( (s1), (s2 + 1)  )))

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
k = n[0]
x = n[1]
s1 = n - k- 1
s2 = n + k - 1
print(list(range( (s1), (s2 + 1)  )))
Problem p02947 (python)

Fixed submission:
import math
n1 = int(input())
f1 = [str(input()) for _ in range(n1)]

ans_sum = 0
ans_exa = {}

for i in range(len(f1)):
    y1 = "".join(sorted(list(str(f1[i]))))
    if y1 in ans_exa:
        ans_sum = ans_sum + ans_exa[y1]
        ans_exa[y1] = ans_exa[y1] + 1
    else:
         ans_exa[y1] = 1

print(ans_sum)

Buggy submission (verdict: Runtime Error):
import math
n1 = int(input())
f1 = [str(input()) for _ in range(n1)]

f2 = sorted(["".join(sorted(list(f1[i]))) for i in range(len(f1))])
f3 = list(map(str, set(f2)))
f4 = [[i for i, e in enumerate(f2) if e == f3[j]] for j in range(len(f3))]
f5 = sum([math.factorial(len(f4[i]))for i in range(len(f4))])/2
print(round(f5))

Buggy submission (verdict: Runtime Error):
import math
n1 = int(input())
#f1 = [list(map(int, input().split())) for _ in range(n1)]
f1 = [str(input()) for _ in range(n1)]

f2 = sorted(["".join(sorted(list(f1[i]))) for i in range(len(f1))])
f3 = list(map(str, set(f2)))
f4 = [[i for i, e in enumerate(f2) if e == f3[j]] for j in range(len(f3))]
f5 = sum([math.factorial(len(f4[i]))for i in range(len(f4))])/2
print(round(f5))
Problem p02969 (python)

Fixed submission:
def resolve():
    s = int(input())
    print(s * s * 3)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    s = int(input())
    print(s * s * 3)
def()
Problem p03060 (python)

Fixed submission:
n=int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(len(v)):
    sa = v[i] - c[i]
    if sa > 0:
        ans += sa

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

for i in range(len(v)):
    sa = v[i] - c[i]
    if sa > 0:
        ans += sa

print(ans)
Problem p03061 (python)

Fixed submission:

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

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

left = [0] * (n + 1)
for i in range(1, n):
    left[i] = gcd(left[i - 1], a[i - 1])

right = [0] * (n + 1)
for i in range(1, n):
    right[n - i] = gcd(right[n - i + 1], a[n - i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i + 1]))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

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

s1 = [a[0]]
s2 = [a[-1]]
for i in range(1, len(a)-1):
    s1.append(gcd(s1[-1], a[i]))
    s2 = [gcd(s2[-1], a[-(i+1)])] + s2
s1 = [a[-1]] + s1
s2 = s2 + [a[0]]


ans = 0
for i in range(len(s1)):
    ans = max(ans, (gcd(s1[i], s2[i])))

print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

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

s1 = [a[0]]
s2 = [a[-1]]
for i in range(1, len(a)-1):
    s1.append(gcd(s1[-1], a[i]))
    s2 = [gcd(s2[-1], a[-(i+1)])] + s2
s1 = [a[-1]] + s1
s2 = s2 + [a[0]]


ans = 0
for i in range(len(s1)):
    ans = max(ans, (gcd(s1[i], s2[i])))

print(max(s3))
Problem p03106 (python)

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

c = [a,b]
c.sort()
a= c[0]
b= c[1]
n = []
for i in range(1, a+1):
    if a%i == 0 and b%i == 0:
        n.append(i)

print(n[-k])

Buggy submission (verdict: Runtime Error):
c = [a,b]
c.sort()
a= c[0]
b= c[1]
n = []
for i in range(1, a+1):
    if a%i == 0 and b%i == 0:
        n.append(i)

print(n[-c])
Problem p03164 (python)

Fixed submission:
n,w = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(n)]

v = sum(list(map(lambda x: x[1], wv)))
dp = [[float("inf")]*(v+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    a = wv[i]
    for j in range(v+1):
        if a[1] <= j:
            dp[i+1][j] = min(dp[i][j], dp[i][j- a[1]] + a[0])
        else:
            dp[i+1][j] = dp[i][j]

dpl = dp[-1]
for i in range(v, -1, -1):
    if dpl[i] <= w:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
n,w = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[-1]*(w+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    a = wv[i]
    for j in range(w+1):
        if a[0] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j- a[0]] + a[1])
        else:
            dp[i+1][j] = dp[i][j]

print(max(dp[-1]))

Buggy submission (verdict: Runtime Error):
n,w = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[float("-inf")]*(w+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    a = wv[i]
    for j in range(w+1):
        if a[0] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j- a[0]] + a[1])
        else:
            dp[i+1][j] = dp[i][j]

print(max(dp[-1]))

Buggy submission (verdict: Runtime Error):
n,w=list(map(int, input().split()))
wv=[list(map(int, input().split())) for _ in range(n)]

dp = [[0 for _ in range(w+1)] for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(w+1):
        if j >= wv[i][0]:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - wv[i][0]] + wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]

print(max(dp[-1][-1]))
Problem p03240 (python)

Fixed submission:
n = int(input())
xyh = [[int(i) for i in input().split()] for j in range(n)]
xyh.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        for k in xyh:
            if k[2] == max(h - abs(k[0] - i) - abs(k[1] - j), 0):
                continue
            else:
                break
        else:
            print(i, j, h)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
H =[]
for i in range(0,101):
    for j in range(0, 101):
        H.append([i,j,0])

for X,Y,H0 in H:
    this_sum = []
    for x,y,h in a:
        if h >0:
            this_sum.append(max(h + abs(x-X) + abs(y-Y)), 0)
    if all([i == this_sum[0] for i in this_sum]):
        H0 = this_sum[0]
        print(" ".join(list(map(str, [X, Y, H0]))))
        break
Problem p03244 (python)

Fixed submission:
n = int(input())
o = list(map(int, input().split()))

#11
#6 7 1 2 1 2 1 2 6 5 6

import collections as cl
a0 = cl.Counter(o[0::2]).most_common()
a1 = cl.Counter(o[1::2]).most_common()
a0.append((0,0))
a1.append((0,0))
if a0[0] != a1[0]:
    count = n - a0[0][1] - a1[0][1]
else:
    count = min(n - a0[1][1] - a1[0][1], n - a0[0][1] - a1[1][1])

print(count)

Buggy submission (verdict: Runtime Error):
import copy
n = int(input())
o = list(map(int, input().split()))

#11
#6 7 1 2 1 2 1 2 6 5 6
a0 = {}
a1 = {}
a0c = n//2 + n%2
a1c = n//2
for i in range(0, n, 2):
    oo = o[i]
    if oo in a0.keys():
        a0[oo] += 1
    else:
        a0[oo] = 1

for i in range(1, n, 2):
    oo = o[i]
    if oo in a1.keys():
        a1[oo] += 1
    else:
        a1[oo] = 1

k0 = [kv[0] for kv in a0.items() if kv[1] == max(a0.values())]
ans0 = a0c - a0[k0[0]]
a1_copy = copy.deepcopy(a1)
if k0[0] in a1_copy:
    del a1_copy[k0[0]]
if len(a0_copy) != 0:
    k1= [kv[0] for kv in a1_copy.items() if kv[1] == max(a1_copy.values())]
    ans1 = a1c - a1_copy[k1[0]]
else:
    ans1 = a1c

ans_a = ans0 + ans1

k0 = [kv[0] for kv in a1.items() if kv[1] == max(a1.values())]
ans0 = a1c - a1[k0[0]]
a0_copy = copy.deepcopy(a0)
if k0[0] in a0_copy:
    del a0_copy[k0[0]]
if len(a1_copy) != 0:
    k1= [kv[0] for kv in a0_copy.items() if kv[1] == max(a0_copy.values())]
    ans1 = a0c - a0_copy[k1[0]]
else:
    ans1 = a0c

ans_b = ans0 + ans1

print(min(ans_a, ans_b))
Problem p03263 (python)

Fixed submission:

import copy
y,x = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(y)]

way = 1
a, b = 0, 0
ans = []
count = 0
while a < y and b < x:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)

    if (way == 1 and a < y-1) or (way == -1 and a > 0):
        a += way
    else:
        b += 1
        way = way*(-1)
    if not (a < y and b < x):
        break
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Buggy submission (verdict: Runtime Error):
import copy
x,y = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(x)]

def gonext(a,b):
    if a < y-1:
        a += 1
    else:
        b += 1
        a = 0
    return(a,b)

a, b = 0, 0
ans = []
count = 0
while a < y and b < x:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)
    a, b = gonext(a, b)
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Buggy submission (verdict: Runtime Error):
import copy
x,y = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(x)]

def gonext(a,b):
    if a < x-1:
        a += 1
    else:
        b += 1
        a = 0
    return(a,b)

a, b = 0, 0
ans = []
count = 0
while a < x and b < y:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)
    a, b = gonext(a, b)
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Buggy submission (verdict: Runtime Error):
def gonext(a,b):
    if a < x-1:
        a += 1
    else:
        b += 1
        a = 0
    return(a,b)

a, b = 0, 0
ans = []
visited = [[-1, -1], [-1, -1]]
stac = 0

count = 0
final = []
while a < x and b < y:
    now = Z[a][b]
    if now % 2 == 0:
        a,b = gonext(a,b)
    else:
        stac += 1
        if stac < 2:
            visited[0] = [a,b]
            a,b = gonext(a,b)
        else:
            visited[1] = [a,b]

            l0, l1 = visited
            while not l0 == l1:
                for i in range(2):
                    if l1[i] - l0[i] > 0:
                        l0_copy = copy.deepcopy(l0)
                        l0[i] += 1
                        for j in range(2):
                            l0_copy.append(l0[j])
                        count += 1
                        final.append(l0_copy)

            stac = 0
            a, b = gonext(a, b)
            ans.append(visited)
            visited = [[-1, -1], [-1, -1]]

print(count)
for i in final:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))
Problem p03274 (python)

Fixed submission:
a,b = list(map(int, input().split()))
n = list(map(int, input().split()))

ans = []
for i, name in enumerate(n):
    if b+i >a:
        break
    ans.append(min( (abs(n[i]) + abs(n[i +b-1] - n[i]),  abs(n[i+b-1]) + abs(n[i +b-1] - n[i]) )) )

print(min(ans))

Buggy submission (verdict: Runtime Error):
a,b = list(map(int, input().split()))
n = list(map(int, input().split()))

c = 0
ris = 0
lenn = len(n)
for i, name in enumerate(n[::-1]):
    if name < 0:
        c += 1
    if c == b-1:
        ri = i
        rs = name
        ris = lenn - ri - 1
        break

ans = []
ans_sum = []
for i in range(b+1):
    if ris+b+i > lenn:
        break
    iii = n[(ris+i):(ris+b+i)]
    ans.append(iii)
    lln = iii[0]
    rrn = iii[-1]
    ll = abs(lln)
    rr = abs(rrn)
    if lln >=0 and rrn > 0:
        ans_sum.append(rr)
    elif lln <0 and rrn <=0:
        ans_sum.append(ll)
    elif ll <= rr:
        ans_sum.append(2*ll + rr )
    else:
        ans_sum.append(ll + 2*rr)

print(min(ans_sum))

Buggy submission (verdict: Runtime Error):
a,b = list(map(int, input().split()))
n = list(map(int, input().split()))

c = 0
ris = 0
lenn = len(n)
for i, name in enumerate(n[::-1]):
    if name < 0:
        c += 1
    if c == b-1:
        ri = i
        rs = name
        ris = lenn - ri - 1
        break

ans = []
ans_sum = []
for i in range(b+1):
    if ris+b+i > lenn:
        break
    iii = n[(ris+i):(ris+b+i)]
    ans.append(iii)
    lln = iii[0]
    rrn = iii[1]
    ll = abs(lln)
    rr = abs(rrn)
    if ll >=0 and rr > 0:
        ans_sum.append(rr)
    elif ll <0 and rr <=0:
        ans_sum.append(ll)
    elif ll <= rr:
        ans_sum.append(2*ll + rr )
    else:
        ans_sum.append(ll + 2*rr)

print(min(ans_sum))
Problem p03309 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = sorted([a[i] - i - 1 for i in range(n)])
c = [i + (0 - b[0]) for i in b]

d = []
if n == 1:
    print(0)
else:
    if n % 2 == 1:
        d.append(0 - c[n//2])
    else:
        d.append(0 - c[n//2])
        d.append(0 - c[n//2 - 1])
        d.append(1 - c[n//2])
        d.append(-1 - c[n//2 - 1])

    ans = []
    for j in d:
        e = [i + j for i in c]
        ans.append(sum([abs(i) for i in e]))

    print(min(ans))

Buggy submission (verdict: Runtime Error):
b = sorted([a[i] - i - 1 for i in range(n)])
c = [i + (0 - b[0]) for i in b]

d = c[0]
ans = []
count = 0
while c[-1] != 0:
    ans.append(sum([abs(i) for i in c]))
    for e, name in enumerate(c):
       if name >0:
           break
    c = [i - name for i in c]
    if count >0:
        if ans[-1] >= ans[-2]:
            break
    count += 1

ans.append(sum([abs(i) for i in c]))
print(min(ans))
Problem p03324 (python)

Fixed submission:
a,b = list(map(int, input().split()))
print((100**a)*b if b != 100 else (100**a)*(b+1))

Buggy submission (verdict: Runtime Error):
a,b = list(map(int, input().split()))
print(c = (100**a)*b)
Problem p02720 (python)

Fixed submission:
k = int(input())

ans = []


l = [i for i in range(1, 10)]
ans.extend(l)

while len(ans) <= 110000:
    n = []
    cnt = 0
    for x in l:
        y = x * 10
        b = x % 10
        if b == 0:
            n.append(y)
            n.append(y+1)
        elif b == 9:
            n.append(y+b-1)
            n.append(y+b)
        else:
            n.append(y+b-1)
            n.append(y+b)
            n.append(y+b+1)
    l = n[:]
    ans.extend(l)

print(ans[k-1])

Buggy submission (verdict: Runtime Error):
k = int(input())

ans = []


if k < 11:
    print(k)
else:
    l = [i for i in range(1, 10)]
    ans.extend(l)

    while len(ans) <= k:
        n = []
        cnt = 0
        for x in l:
            y = x * 10
            b = x % 10
            if b == 0:
                n.append(y)
                n.append(y+1)
            elif b == 9:
                n.append(y+b-1)
                n.append(y+b)
            else:
                n.append(y+b-1)
                n.append(y+b)
                n.append(y+b+1)
        l = n[:]
        ans.extend(l)

print(ans[k-1])

Buggy submission (verdict: Runtime Error):
k = int(input())

if k < 11:
    print(k)
else:
    l = [i for i in range(1, 10)]
    cntotal = 9
    while cntotal < k:
        n = []
        cnt = 0
        for x in l:
            y = x * 10
            b = x % 10
            if b == 0:
                n.append(y)
                n.append(y+1)
                cnt += 2
            elif b == 9:
                n.append(y+b-1)
                n.append(y+b)
                cnt += 2
            else:
                n.append(y+b-1)
                n.append(y+b)
                n.append(y+b+1)
                cnt += 3
        cntotal += cnt
        l = n[:]

print(l[k - (cntotal - cnt) - 1])
Problem p02743 (python)

Fixed submission:
from math import sqrt
from decimal import *
a, b, c = map(int, input().split())

getcontext().prec = 50

sa = Decimal(a).sqrt()
sb = Decimal(b).sqrt()
sc = Decimal(c).sqrt()


if sa + sb < sc:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())

    ans = []

    def fanc(i, s):
        if len(s) == n:
            ans.append(s)
        else:
            for x in range(i + 2):
                # print(x,i,s)
                fanc(max([x, i]), s + chr(97 + x))
                # fanc(x + 1, s + chr(97 + x))

    fanc(0, "a")
    ans.sort()
    for i in ans:
        print(i)

    # print(len(ans))
main()
Problem p02775 (python)

Fixed submission:
n = input()

a = n[::-1] + "0"

prev_a = int(a[0])
prev_b = 10 - int(a[0])

# dp[下の桁から][繰り上げるかどうか]
for i in range(1, len(a)):
    x = int(a[i])
    y = x + 1
    aa = min([x + prev_a, y + prev_b])
    bb = min([(10 - x) + prev_a, (10 - y) + prev_b])
    prev_a = aa
    prev_b = bb

print(min(aa, bb))

Buggy submission (verdict: Runtime Error):
n = input()

a = n[::-1]

prev_a = int(a[0])
prev_b = 10 - int(a[0])

# dp[下の桁から][繰り上げるかどうか]
for i in range(1, len(a)):
    x = int(a[i])
    y = x + 1
    aa = min([x + prev_a, y + prev_b])
    bb = min([(10 - x) + prev_a, (10 - y) + prev_b])
    prev_a = aa
    prev_b = bb

print(min(aa, bb))