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

Fixed submission:
import sys
import numpy as np
from numba import jit, void, i8
input = sys.stdin.readline

def main():
    R, C, K = map(int, input().split())

    L_INF = int(1e17)
    dp = np.full((R+1, C+1, 4), -L_INF, dtype=np.int64)
    cell = np.full((R+1, C+1), 0, dtype=np.int64)

    for i in range(K):
        x, y, c = map(int, input().split())
        cell[x-1][y-1] = c

    f(dp, cell, R, C)

    print(dp[R][C][3])

@jit(void(i8[:,:,:],i8[:,:],i8,i8))
def f(dp, cell, R, C):
    dp[0][1][0] = dp[1][0][0] = 0
    for i in range(1, R + 1):
        for j in range(1, C + 1):
            for k in range(4):
                if k > 0:
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j][k-1])
                dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k])
                if k > 0:
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + cell[i-1][j-1])
                if k == 1:
                    dp[i][j][k] = max(dp[i][j][1], dp[i-1][j][3] + cell[i-1][j-1])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from numba import jit, void, i8
input = sys.stdin.readline

def main():
    R, C, K = map(int, input().split())

    L_INF = int(1e17)
    dp = np.full((R+1, C+1, 4), -L_INF, dtype=np.int64)
    cell = np.full((R+1, C+1), 0, dtype=np.int64)

    for i in range(K):
        x, y, c = map(int, input().split())
        cell[x-1][y-1] = c

    f(dp, cell, R, C)

    print(dp[R][C][3])

@njit(void(i8[:,:,:],i8[:,:],i8,i8))
def f(dp, cell, R, C):
    dp[0][1][0] = dp[1][0][0] = 0
    for i in range(1, R + 1):
        for j in range(1, C + 1):
            for k in range(4):
                if k > 0:
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j][k-1])
                dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k])
                if k > 0:
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + cell[i-1][j-1])
                if k == 1:
                    dp[i][j][k] = max(dp[i][j][1], dp[i-1][j][3] + cell[i-1][j-1])

if __name__ == "__main__":
    main()
Problem p02765 (python)

Fixed submission:
n,r=map(int,input().split())
if n >= 10:
    ans = r
else:
    ans = r + 1000 - 100 * n
print(ans)

Buggy submission (verdict: Runtime Error):
n,r=map(int,input(),split())
if n >= 10:
    ans = r
else:
    ans = r + 1000 - 100 * n
Problem p02789 (python)

Fixed submission:
n,m=map(int,input().split())
if n == m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
m=int(input())
if n == m:
    print("Yes")
else:
    print("No")
Problem p02796 (python)

Fixed submission:
n = int(input())
x = []
for i in range(n):
    X,L = map(int, input().split())
    x.append([X-L,X+L])
x.sort(key=lambda x:x[0])
ans = n
tmp = x[0][1]
for i in range(1,n):
    if tmp>x[i][0]:
        ans -=1
        tmp = min(tmp,x[i][1])
    else:
        tmp = x[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = []
for i in range(n):
    X,L = map(int, input().split())
    x.append([X-L,X+L])
x.sort()
y = [0]*n
ans = 0
for i in range(n-2):
    if x[i][1]>x[i+2][0]:
        ans +=1
        y[i] = -1
    elif x[i][1]>x[i+1][0] and y[i]==0:
        y[i] +=1
        y[i+1] +=1
    elif x[i][1]>x[i+1][0] and y[i]==1:
        ans +=1
        y[i] = -1
        y[i-1] = 0
        continue
if x[-1][0]<x[n-3][1]:
    y[-1] = -1
    ans +=1
elif x[-1][0]<x[n-2][1]:
    y[-1] +=1
    y[n-2] +=1

for i in range(n-1):
    if y[i]<=0:
        continue
    else:
        y[i] = 0
        y[i+1] = 0
        ans +=1
print(n-ans)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
def lcm(p,q):
    return p*q//gcd(p,q)

n,m = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in range(n):
    a[i] = a[i]//2
    x = lcm(x,a[i])
    if x>m:
        print(0)
        exit()
for i in range(n):
    if (x//a[i])%2==0:
        print(0)
        exit()
p = m//x
if p%2==0:
    ans = p//2
else:
    ans = p//2 +1
print(ans)

Buggy submission (verdict: Runtime Error):
import math

def lcm(p,q):
    return p*q//math.gcd(p,q)
n,m = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in range(n):
    a[i] = a[i]//2
    x = lcm(x,a[i])
p = m//x
if p%2==0:
    ans = p//2
else:
    ans = p//2 +1
print(ans)
Problem p02844 (python)

Fixed submission:
n = int(input())
s = str(input())
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            i_pos = s.find(str(i))

            if i_pos == -1:
                continue

            j_pos = s.find(str(j), i_pos+1)

            if j_pos == -1:
                continue

            k_pos = s.find(str(k), j_pos+1)

            if k_pos == -1:
                continue

            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
INF = int(1e9) + 7

n = int(input())
a = list(map(int, input().split()))
col = [0,0,0]
ans = 1
for i in range(n):
        col[i] +=1
        continue
    c = set(col)
    m = 0
    for j in range(3):
        if c==col[j]:
            m +=1
    ans *= m
    
    for j in range(3):
        if i==col[j]:
            col[j] +=1
            break
        else:
            continue
    ans = ans%INF

print(ans)
Problem p02845 (python)

Fixed submission:
INF = int(1e9) + 7

n = int(input())
a = list(map(int, input().split()))
col = [0, 0, 0]
ans = 1
for i in range(n):
    m = 0
    for j in range(3):
        if a[i] ==col[j]:
            m = col.count(a[i])
    ans *= m
    
    for j in range(3):
        if a[i]==col[j]:
            col[j] +=1
            break
        else:
            continue
    ans = ans%INF

print(ans)

Buggy submission (verdict: Runtime Error):
INF = int(1e9) + 7

n = int(input())
a = list(map(int, input().split()))
col = [0,0,0]
ans = 1
for i in range(n):
        col[i] +=1
        continue
    c = set(col)
    m = 0
    for j in range(3):
        if c==col[j]:
            m +=1
    ans *= m
    
    for j in range(3):
        if i==col[j]:
            col[j] +=1
            break
        else:
            continue
    ans = ans%INF

print(ans)
Problem p02853 (python)

Fixed submission:
x,y = map(int, input().split())
ans = 0
d = [300000,200000,100000]
if 1<=x and x<=3:
    ans += d[x-1]

if 1<=y and y<=3:
    ans += d[y-1]

if x==y and x==1:
    ans += 400000

print(ans)

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())
ans = 0
d = [300000,200000,100000]
if 1<=x and x<=3:
    ans += d[x-1]

if 1<=y and y<=3:
    ans += d[x-1]

if x==y and x==1:
    ans += 400000

print(ans)
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
a = [0]
ans = 0
for i in range(1,n):
    if h[i-1]>=h[i]:
        ans+=1
    else:
        a.append(ans)
        ans=0
    if i==n-1:
        a.append(ans)
a.sort(reverse=True)
print(a[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
a = []
ans = 0
for i in range(1,n):
    if h[i-1]>=h[i]:
        ans+=1
    else:
        a.append(ans)
        ans=0
    if i==n-1:
        a.append(ans)
a.sort(reverse=True)
print(a[0])
Problem p02936 (python)

Fixed submission:
import heapq

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

node = [0]*N
edge = [[] for _ in range(N)]
color = [0]*N

for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

for i in range(Q):
    p,x = map(int, input().split())
    node[p-1] += x

stack = [0]
while stack:
    s = stack.pop()
    color[s] = 1
    for t in edge[s]:
        if color[t]==0:
            stack.append(t)
            node[t] += node[s]
    color[s]=2

print(*node)

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
ans = [0]*n
ki = [ [] for _ in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a -=1
    b -=1
    ki[a].append(b)

def ki_add(p,x):
    ans[p] += x
    for i in ki[p]:
        ki_add(i,x)

for i in range(q):
    p,x = map(int, input().split())
    p -=1
    ki_add(p,x)
print(*ans)
Problem p03069 (python)

Fixed submission:
n = int(input())
s = input()
c = s.count(".")
ans = c
for i in range(n):
    if s[i] =="#":
        c +=1
    else:
        c -=1
    ans = min(ans,c)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
c = s.count(".")
ans = c
for i in range(n):
    if s[i] =="#":
        c +=1
    else:
        c -=1
    ans = min(ans,m)
print(ans)
Problem p03112 (python)

Fixed submission:
import bisect

A,B,Q = map(int, input().split())
INF = 10**18

s =[-INF] + [int(input()) for i in range(A)] +[INF]
t =[-INF] + [int(input()) for i in range(B)] +[INF]

for q in range(Q):
    x = int(input())
    b, d =bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            d1,d2 = abs(S-x)+abs(T-S),abs(T-x)+abs(S-T)
            res = min(res, d1,d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import bisect

A,B,Q = map(int, input().split())
INF = 10**18

s =[-INF] + [int(input()) for i in range(A)] +[INF]
t =[-INF] + [int(input()) for i in range(B)] +[INF]

for q in range(q):
    x = int(input())
    b, d =bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            d1,d2 = abs(S-x)+abs(T-S),abs(T-x)+abs(S-T)
            res = min(res, d1,d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import bisect

A,B,Q = map(int, input().split())
INF = 10**18

s =[-INF] + [int(input()) for i in range(A)] +[INF]
t =[-INF] + [int(input()) for i in range(B)] +[INF]

for q in range(q):
    x = int(input())
    b,d =bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            d1,d2 = abs(S-x)+abs(T-S),abs(T-x)+abs(S-T)
            res = min(res, d1,d2)
print(res)
Problem p03196 (python)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n, p = map(int, input().split())
a = factorization(p)
ans = 1
for i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]**b
    else:
        continue
print(ans)

Buggy submission (verdict: Runtime Error):
import math


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n, p = map(int, input().split())
a = factorization(p)
ans = 1
for i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]*b
    else:
        continue
print(ans)import math


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n, p = map(int, input().split())
a = factorization(p)
ans = 1
for i in range(len(a)):
    if a[i][1]>=n:
        b = a[i][1]//n
        ans = ans*a[i][0]*b
    else:
        continue
print(ans)
Problem p03241 (python)

Fixed submission:
import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
ans = 0
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n,m = map(int, input().split())
k = int(math.sqrt(m))
a = []
b = []
for i in range(1,k+10):
    if m%i==0:
        a.append(m//i)
        b.append(i)
    else:
        continue
for i in a:
    if m//i>=n:
        ans = i
        break
for i in reversed(b):
    if m//i>=n:
        ans = max(ans,i)
        break
    else:
        continue
print(ans)
Problem p03261 (python)

Fixed submission:
n = int(input())
w = []
for i in range(n):
    item = str(input())
    if i == 0:
        w.append(item)
    elif i!=0:
        if w[i-1][-1]==item[0]:
            w.append(item)
        elif w[i-1][-1]!=item[0]:
            print("No")
            exit()
l = set(w)
if len(l)==len(w):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
w = []
for i in range(n):
    item = str(input())
    if i == 0:
        w.append(item)
    elif i!=0:
        if w[i-1][-1]==item[0]:
            w.append(item)
        else:
            print("No")
            end()
l = set(w)
if len(l)==len(w):
    print("Yes")
else:
    print("No")
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n,X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if n==1:
    print(abs(x[0]-X))
    exit()
y = [ x[i]-x[i-1] for i in range(1,n)]
d = abs(X-x[0])
for i in range(n-1):
    d = gcd(d, y[i])
print(d)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n,x = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
y = [ x[i]-x[i-1] for i in range(1,n)]
d = gcd(y[1], y[0])
for i in range(2,n-1):
    d = gcd(d, y[i])
print(d)
Problem p03266 (python)

Fixed submission:
n,k = map(int, input().split())
count0 = 0
count1 = 0
for i in range(1,n+1):
    if i%k==0:
        count0 +=1
    if i%k==k/2:
        count1 +=1

if k%2==0:
    print(count0**3+count1**3)
else:
    print(count0**3)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
count0 = 0
count1 = 0
for i in range(1,n+1):
    if i%k==0:
        count0+=1
    if i%k==k/2:
        count+=1

if k%2==0:
    print(count0**3+count1**3)
else:
    print(count0**3)
Problem p03274 (python)

Fixed submission:
INF = 1e9
n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = INF
for i in range(n-k+1):
    if x[i]*x[i+k-1]>=0:
        ans = min(ans, max(abs(x[i]), abs(x[i+k-1])))
    else:
        a = min(abs(x[i]), abs(x[i+k-1]))
        b = max(abs(x[i]), abs(x[i+k-1]))
        ans = min(ans, a*2+b)
print(ans)

Buggy submission (verdict: Runtime Error):
INF = 1e9
n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = INF
for i in range(n-k):
    if x[i]*x[i+k-1]<0:
        a = abs(x[i])+x[i+k-1] + min(abs(x[i], x[i+k-1]))
    else:
        a = abs(x[i+k-1])
    
    ans = min(ans, a)

if k==1:
    ans = abs(x[0])
print(ans)
Problem p03294 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = sum(a) - n
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split())
print(sum(a)-n)
Problem p03361 (python)

Fixed submission:
h, w = map(int, input().split())
ans = "Yes"
c = ["0"]*(w+2)
s = []
s.append(c)
for i in range(h):
    S = ["0"]
    S1 = list(input())
    S1.append("0")
    S = S+S1
    s.append(S)
s.append(c)

for i in range(1,h+1):
    for j in range(1, w+1):
        if s[i][j]=="#":
            if s[i-1][j]!="#" and s[i+1][j]!="#" and s[i][j-1]!="#" and s[i][j+1]!="#":
                ans ="No"
            else:
                continue
print(ans)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
ans = "Yes"
c = [0]*(w+2)
s = c
for i in range(h):
    S = ["0"]
    S1 = list(input())
    S.append(S1)
    S.append("0")
    s.append(S)
s.append(c)

for i in range(1,h+1):
    for j in range(1, w+1):
        if s[i][j]=="#":
            if s[i-1][j]!="#" and s[i+1][j]!="#" and s[i][j-1]!="#" and s[i][j+1]!="#":
                ans ="No"
            else:
                continue
print(ans)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
ans = "Yes"
s = []
for i in range(h):
    S = list(input())
    s.append(S)

for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            if s[i-1][j]!="#" and s[i+1][j]!="#" and s[i][j-1]!="#" and s[i][j+1]!="#":
                ans ="No"
            else:
                continue
print(ans)
Problem p03417 (python)

Fixed submission:
n,m = map(int, input().split())
ans = (n-2)*(m-2)
print(abs(ans))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
ans = (n-2)(m-2)
print(ans)
Problem p03493 (python)

Fixed submission:
s = list(input())
for i in range(3):
    s[i] = int(s[i])
print(sum(s))

Buggy submission (verdict: Runtime Error):
s = list(int(input()))
ans = sum(s)
print(ans)
Problem p03495 (python)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.sort(reverse=True)
ans = 0

for i in range(k):
    ans += number[i]
ans = n-ans
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.sort(reversed=True)
ans = 0

for i in range(k):
    ans += number[i]
ans = n-ans
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.remove(0)
number.sort()
ans = 0

if len(number)<=k:
    print(0)
else:
    for i in range(len(number)-k):
        ans += number[i]
    print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
number = [0]*n
for i in range(n):
    number[a[i]-1]+=1
number.remove(0)
number.sort()
ans = 0

if len(number)<=k:
    print(0)
else:
    for i in range(len(number)-k):
        ans += number[i]
    print(ans)
Problem p03545 (python)

Fixed submission:
s = list(input())
ans = 0
for i in range(2**(3)):
    f = (s[0])
    for j in range(3):
        if i&(1<<j):
            f = f+"+"
        else:
            f = f+"-"
        f = f+s[j+1]
    if eval(f)==7:
        print(f+"=7")
        exit()

Buggy submission (verdict: Runtime Error):
s = list(input())
for i in range(2**3):
    f = (s[0])
    for j in range(3):
        if (i>>j)&1:
            f = f "+"
        else:
            f = f + "-"
        f = f + s[j+1]
    if eval(f) == 7:
        print(f+"=7")
        exit()
Problem p03633 (python)

Fixed submission:
def gcd(a,b):
    while b != 0:
        a,b = b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

n = int(input())
t = [ int(input()) for _ in range(n)]
ans = 1
for i in range(n):
    ans = lcm(ans, t[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math

def lcm(a,b):
    return a*b//math.gcd(a,b)

n = int(input())
t = [ int(input()) for _ in range(n)]
ans = 1
for i in range(n):
    ans = lcm(ans, t[i])
print(ans)
Problem p03721 (python)

Fixed submission:
n,k = map(int, input().split())
p = [[0,0]]
for i in range(n):
    a,b = map(int, input().split())
    p.append([a,b])
p.sort()
ans = 0
p.pop(0)
for i in range(n):
    ans+=p[i][1]
    if ans>=k:
        print(p[i][0])
        exit()
    else:
        continue

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
p = [[0,0]]
for i in range(n):
    a,b = map(int, input().split())
    p.append([a,b])
p.sort()
ans = 0
i = 0
while ans<=k:
    ans+=p[i][1]
    i+=1
print(p[i-1][0])

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
p = [[0,0]]
for i in range(n):
    a,b = map(int, input().split())
    p.append([a,b])
p.sort()
ans = 0
i = 0
while ans<=k:
    ans+=p[i+1][1]
    i+=1
print(p[i][0])
Problem p03854 (python)

Fixed submission:
s = list(input())
n = len(s)
s.reverse()
for i in range(6):
    s.append("x")
s = "".join(s)
i = 0
word = ["maerd", "esare", "resare","remaerd"]
while i<n:
    if s[i:i+5]==word[0]:
        i+=5
    elif s[i:i+5]==word[1]:
        i+=5
    elif s[i:i+6]==word[2]:
        i+=6
    elif s[i:i+7]==word[3]:
        i+=7
    else:
        print("NO")
        exit()
print("YES")

Buggy submission (verdict: Runtime Error):
s = str(input())
n = len(s)
i = 0
d = ["dream", "dreamer"]
e = ["erase", "eraser"]
while i<n:
    if s[i]=="d":
        if s[i:i+5]==d[0]:
            i+=5
        else:
            break

        if s[i:i+3]=="era":
            continue
        elif s[i:i+2]!="er" and s[i+2]=="e":
            i+=2
        else:
            break
    elif s[i]=="e":
        if s[i:i+5]==e[0]:
            i+=5
        else:
            break

        if s[i:i+1]=="r":
            i+=1
        else:
            continue
    else:
        break
if i<n:
    print("NO")
else:
    print("YES")
Problem p03994 (python)

Fixed submission:
s = str(input())
n = int(input())
k = ord("z")
a = [0]*len(s)
for i in range(len(s)):
    a[i] = ord(s[i])
for i in range(len(s)):
    if a[i] == ord("a"):
        continue
    if n>=k+1-a[i]:
        n = n-k-1+a[i]
        a[i] = ord("a")
    
    if n<=0:
        break
if n>0:
    a[-1] += n%26
ans = ""
for i in range(len(s)):
    ans += chr(a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
n = int(input())
k = ord("z")
a = [0]*len(s)
for i in range(len(s)):
    a[i] = ord(s[i])
for i in range(len(s)):
    if n>=k+1-a[i]:
        n = n - (k+1-a[i])
        a[i] = ord("a")
    
    if n<=0:
        break
if n>0:
    a[-1] += n
ans = ""
for i in range(len(s)):
    ans += chr(a[i])
print(ans)
Problem p04045 (python)

Fixed submission:
n,k = map(int, input().split())
d = list(input().split())
ans = n
while True:
    flag = False
    a = list(str(ans))
    for dx in d:
        if dx in a:
            flag = True
    if flag:
        ans +=1
    else:
        print(ans)
        exit()

Buggy submission (verdict: Runtime Error):
import bisect

n,k = map(int, input().split())
d = list(map(int, input().split()))
num = [ i for i in range(10)]
num += d
a = [ x for x in set(num) if num.count(x)<2]
s = str(n)
m = len(s)
ans = []
for i in range(m):
    x = int(s[i])
    index = bisect.bisect_left(a,x)
    if a[index]==x:
        ans.append(str(x))
    else:
        ans.append(str(a[index]))
        for j in range(m-i-1):
            ans.append(str(a[0]))
        break
print("".join(ans))
Problem p02584 (python)

Fixed submission:
X,K,D=map(int,input().split())
a=round(abs(X/D))
if K<a:
  print(abs(abs(X)-K*abs(D)))
elif (K-a)%2==0:
  l=[]
  l.append(abs(abs(X)-a*abs(D)))
  l.append(abs(abs(X)-(a+2)*abs(D)))
  l.append(abs(abs(X)-(a-2)*abs(D)))
  print(min(l))
elif (K-a)%2!=0:
  l=[]
  l.append(abs(abs(X)-(a+1)*abs(D)))
  l.append(abs(abs(X)-(a-1)*abs(D)))  
  print(min(l))

Buggy submission (verdict: Runtime Error):
X,K,D=map(int,input().split())
a=round(abs(X/D))
if K<a:
  print(abs(abs(X)-K*abs(D)))
elif (K-a)%2==0:
  l=[]
  l.append(abs(abs(X)-a*abs(D)))
  l.append(abs(abs(X)-(a+2)*abs(D)))
  l.append(abs(abs(X)-(a-2)*abs(D)))
  print(min(l))
elif (K-a)%2!=0:
  l=[]
    l.append(abs(abs(X)-(a+1)*abs(D)))
    l.append(abs(abs(X)-(a-1)*abs(D)))  
  print(min(l))
Problem p02612 (python)

Fixed submission:
N = int(input())
a = 1000-N%1000
if a == 1000:
  a = 0
print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = 1000-N%1000
if a = 1000:
  a = 0
print(a)