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

Fixed submission:
A, B, C = map(int, input().split())
print(C, A, B)

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
import collections
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy
from sortedcontainers import SortedSet

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().strip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().strip())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    s = S()
    print(s)
    

main()
Problem p03006 (python)

Fixed submission:
import collections

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

if (N==1):
    print(1)
    quit()

pq = []
cost = N

for xyi in xy:
    for xyj in xy:
        pq.append((xyi[0]-xyj[0], xyi[1]-xyj[1]))

count = collections.Counter(pq)
if (count.most_common()[0][0] == (0,0)):
    print(N - count.most_common()[1][1])
else:
    print(N - count.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]

pq = []
cost = N

for xyi in xy:
    for xyj in xy:
        pq.append((xyi[0]-xyj[0], xyi[1]-xyj[1]))

count = collections.Counter(pq)
if (count.most_common()[0][0] == (0,0)):
    print(N - count.most_common()[1][1])
else:
    print(N - count.most_common()[0][1])
Problem p03169 (python)

Fixed submission:
import sys

def I(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))

def main():
    N = I()
    a = LI()
    t = [0, 0, 0]
    for ai in a:
        t[ai-1] += 1
    A, B, C = t
    E = B+C

    dp = [[0 if (i+j==0) else N/(i+j) for j in range(E+1)] for i in range(N+1)]

    for k in range(C+1):
        for i in range(N+1):
            dp[i][E] = 0 if (i+E+k==0) else N/(i+E+k)
        for j in range(E+1):
            for i in range(N+1):
                z = i+j+k
                if (not z):
                    continue
                d = dp[i][j]
                if (i<N):
                    dp[i+1][j] += (i+1)*d/(z+1)
                if (i>0) and (j<E):
                    dp[i-1][j+1] += (j+1)*d/z
                if (j>0) and (k<C):
                    dp[i][j-1] = (k+1)*d/z + N/z

    print(dp[A][B])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
from functools import lru_cache
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]


N = I()
A = LI()
t = [0, 0, 0]
for a in A:
    t[a-1] += 1
A, B, C = t

dp = [[[0]*(N+1) for i in range(N+1)] for j in range(N+1)]

for k in range(N+1):
    for j in range(N+1):
        for i in range(N+1):
            if (i==0) and (j==0) and (k==0):
                continue
            dp[i][j][k] += N/(i+j+k)
            d = dp[i][j][k]
            if (i<N):
                dp[i+1][j][k] += (i+1)*d/(i+1+j+k)
            if (i>0) and (j<N):
                dp[i-1][j+1][k] += (j+1)*d/(i+j+k)
            if (j>0) and (k<N):
                dp[i][j-1][k+1] += (k+1)*d/(i+j+k)

print(dp[A][B][C])



"""
Problem p03294 (python)

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

print(sum(list(map(lambda ai: ai-1, A))))

Buggy submission (verdict: Runtime Error):
gcd = lambda x, y: x if (y==0) else gcd(y, x%y)
lcm = lambda x, y: int(x*y/gcd(x, y))

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

gcd_all = 0
lcm_all = 1

for ai in A :
    gcd_all = gcd(gcd_all, ai)
    lcm_all = lcm(lcm_all, ai)

m = lcm_all - 1
print(sum(list(map(lambda ai: m%ai, A))))

Buggy submission (verdict: Runtime Error):
gcd = lambda x, y: x if (y==0) else gcd(y, x%y)
lcm = lambda x, y: int(x*y/gcd(x, y))

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

gcd_all = 0
lcm_all = 1

for ai in A :
    gcd_all = gcd(gcd_all, ai)
    lcm_all = lcm(lcm_all, ai)

m = lcm_all - 1
print(sum(list(map(lambda ai: m%ai, A))))
Problem p03352 (python)

Fixed submission:
import math
X = int(input())
max_num = 1

for i in range(2, int(math.sqrt(X))+1) :
    for j in range(2, int(math.log2(X))+1) :
        if (i**j <= X):
            max_num = max(max_num, i**j)
        else:
            break
print(max_num)

Buggy submission (verdict: Runtime Error):
import math
X = int(input())
max_num = 1

for i in range(2, int(math.sqrt(X))+1) :
    for j in range(2, int(math.log2(X))+1) :
        if (i**j <= X):
            max_num = max(max_num, i**j)
        else:
            break
print(max_num)
Problem p02555 (python)

Fixed submission:
S=int(input())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if S<3:
    ans=0
n=S//3
ans=0
for i in range(1,n+1):
    ans+=cmb(S-2*i-1,i-1,mod)
    ans%=mod
print(ans)

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if S<3:
    ans=0
n=S//3
ans=0
for i in range(1,n+1):
    ans+=cmb(S-2*
Problem p02574 (python)

Fixed submission:
from math import gcd
from functools import reduce

def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):#1を除く(素因数,指数)のリスト
    result = []
    while n != 1:
        p = prime_table[n]
        e = 0
        while n % p == 0:
            n //= p
            e += 1
        result.append((p, e)) 
    return result


def f():
    s = set()
    for i in range(N):
        t = prime_factorize(A[i])
        for p, _ in t:
            if p in s:
                return False
            s.add(p)
    return True


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

prime_table = make_prime_table(10 ** 6)
if f():
    print('pairwise coprime')
elif reduce(gcd, A) == 1:
    print('setwise coprime')
else:
    print('not coprime')

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

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)

    if temp!=1:
        arr.append(temp)

    return arr

N=int(input())
A=list(map(int, input().split()))
p=1
A=sorted(A)
num1=A.count(1)
B=list(set(A))
if len(B)<len(A)-num1+1:
    p=0
S=set(factorization(B[0]))
T=set(factorization(B[0]))
flg=0
for i in range(1,len(B)):
    prime=set(factorization(B[i])
    if T&prime!=set():
        flg=1
    S=S&prime
    T=T|prime    #print(S,T)
if S!=1:
    print('not coprime')
elif flg==1 or p=0:
    print('setwise coprime')
else:
    print('pairwise coprime')
Problem p02584 (python)

Fixed submission:
X,K,D=map(int, input().split())
n=(K*D-X)//(2*D)
#print(n)
if n<0:
    ans=abs(X-K*D)
elif n>=K:
    ans=abs(X+K*D)
else:
    ans1=abs(X+(2*n-K)*D)
    ans2=abs(X+(2*(n+1)-K)*D)
    ans=min(ans1,ans2)
    #print(n,ans1,ans2)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N=int(input())
A=list(map(int, input().split()))
ans=0
for any_pair in itertools.combinations(A, 3):
    pair=sorted(any_pair)#新しいリストを作成
    #print(type(pair))
    if pair[0]+pair[1]>pair[2] and pair[0]!=pair[1] and pair[1]!=pair[2]:
        ans+=1
        #print(pair)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N=int(input())
A=list(map(int, input().split()))
ans=0
for any_pair in itertools.combinations(A, 3):
    pair=sorted(any_pair)#新しいリストを作成
    print(type(pair))
    if pair[0]+pair[1]>pair[2] and pair[0]!=pair[1] and pair[1]!=pair[2]:
        ans+=1
        print(pair)
print(ans)
Problem p02606 (python)

Fixed submission:
L,R,d=map(int, input().split())
ans=R//d-(L-1)//d
print(ans)

Buggy submission (verdict: Runtime Error):
def count1(n):
    nx=bin(n)
    return nx.count('1')

N=int(input())
X=input()
for i in range(N):
    Ni2=X
    if X[i]=='0':
        Ni2=X[:i]+'1'+X[(i+1):] #文字列は変更できない
    else:
        Ni2=X[:i]+'0'+X[(i+1):]
    Ni=int(Ni2,2)
    ans=0
    #print(Ni)
    while Ni!=0:
        Ni=Ni%count1(Ni)
        ans+=1
    print(ans)
Problem p02609 (python)

Fixed submission:
N = int(input())
X = input()
popcount_X = X.count('1')
numX = int(X, 2)
a = numX % (popcount_X + 1)
b = numX % (popcount_X - 1) if popcount_X != 1 else 0
for i, x in enumerate(X, 1): #リストのインデクス，要素，第二引数に開始位置
    if x == '1' and popcount_X == 1:
        print(0)
        continue
    ans = 1
    if x == '1':
        temp = (b - pow(2, N - i, popcount_X - 1)) % (popcount_X - 1)
    else:
        temp = (a + pow(2, N - i, popcount_X + 1)) % (popcount_X + 1)
    while temp:
        p = format(temp, 'b').count('1') #2進数，1の個数
        temp %= p
        ans += 1
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = input()
popcount_X = X.count('1')
numX = int(X, 2)
a = numX % (popcount_X + 1)
b = numX % (popcount_X - 1) if popcount_X != 1 else 0
for i, x in enumerate(X, 1): #リストのインデクス，要素，第二引数に開始位置
    if x == '1' and popcount_X == 1:
        print(0); continue
    ans = 1
    if x == '1':
        temp = (b - pow(2, N - 1, popcount_X - 1)) % (popcount_X - 1)
    else:
        temp = (a + pow(2, N - i, popcount_X - 1)) % (popcount_X + 1)
    while temp:
        p = format(temp, 'b').count('1') #2進数，1の個数
        temp %= p
        ans += 1
    print(ans)
Problem p02664 (python)

Fixed submission:
S=input()
T=S.replace('?', 'D')
print(T)

Buggy submission (verdict: Runtime Error):
=input()
T=S.replace('?', 'D')
print(T)
Problem p02684 (python)

Fixed submission:
N,K=(int(x) for x in input().split())
A=list(map(int, input().split()))
if K<=N:
    s=1
    for i in range(K):
        s=A[s-1]
    print(s)
else:
    s=1
    S={1}
    iloop=1
    while A[s-1] not in S:
        S.add(A[s-1])
        s=A[s-1]
        iloop=iloop+1
    p=s
    loop=1
    while A[s-1] != p:
        loop=loop+1
        s=A[s-1]
    g=(K-iloop)%loop+iloop
    s=1
    for i in range(g):
        s=A[s-1]
    print(s)

Buggy submission (verdict: Runtime Error):
N,K=(int(x) for x in input().split())
A=list(map(int, input().split()))
if K<=N:
    s=1
    for i in range(K):
        s=A[s-1]
    print(s)
else:
    s=1
    S={1}
    iloop=1
    while A[s-1] not in S:
        S.add(A[s-1])
        s=A[s-1]
        iloop=iloop+1
    p=s
    loop=0
    while A[s-1] != p:
        loop=loop+1
        s=A[s-1]
    g=(K-iloop)%loop+iloop
    s=1
    for i in range(g):
        s=A[s-1]
    print(s)

Buggy submission (verdict: Runtime Error):
N,K=(int(x) for x in input().split())
A=list(map(int, input().split()))
if K<=2*N:
    s=1
    for i in range(K):
        s=A[s-1]
    print(s)
else:
    s=1
    S={1}
    iloop=1
    while A[s-1] not in S:
        S.add(A[s-1])
        s=A[s-1]
        iloop=iloop+1
    p=s
    loop=0
    while A[s-1] != p:
        loop=loop+1
        s=A[s-1]
    g=(K-iloop)%loop+iloop
    s=1
    for i in range(g):
        s=A[s-1]
    print(s)

Buggy submission (verdict: Runtime Error):
N,K=(int(x) for x in input().split())
A=list(map(int, input().split()))
if K<=2*N:
    s=1
    for i in range(K):
        s=A[s-1]
    print(s)
else:
    s=1
    S={1}
    iloop=1
    while A[s-1] not in S:
        S.add(A[s-1])
        s=A[s-1]
        iloop=iloop+1
    p=s
    loop=0
    while A[s-1] != p:
        loop=loop+1
        s=A[s-1]
    g=(K-iloop)%loop+iloop
    s=1
    for i in range(g):
        s=A[s-1]
    print(s)
    print(iloop,loop,g)
Problem p03260 (python)

Fixed submission:
l = list(map(int, input().split()))
a=l[0]
b=l[1]
if a%2==0 or b%2==0:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a%2==0 or b%2==0:
    print("No")
else:
    print("Yes")
Problem p03261 (python)

Fixed submission:
N=int(input())
S=[input() for i in range(N)]
ans='Yes'
if len(set(S))!=N:
    ans='No'
for i in range(N-1):
    if S[i][len(S[i])-1]!=S[i+1][0]:
        ans='No'
print(ans)

Buggy submission (verdict: Runtime Error):
N=input()
N=int(input())
S=[input() for i in range(N)]
ans='Yes'
if len(set(S))!=N:
    ans='No'
for i in range(N-1):
    if S[i][len(S[i])-1]!=S[i+1][0]:
        ans='No'
print(ans)
Problem p03262 (python)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

l = list(map(int, input().split()))
N=l[0]
X=l[1]
x=[0]*N
A=[0]*N
l = list(map(int, input().split()))
for i in range(N):
    x[i] = l[i]
    A[i] = abs(X-x[i])
g=A[0]
for i in range(N):
    g = gcd(g, A[i])
print(g)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

l = list(map(int, input().split()))
N=l[0]
X=l[1]
x=[0]*N
A=[0]*N
l = list(map(int, input().split()))
for i in range(N):
    x[i] = l[i]
    A[i] = abs(X-x[i])
g=A[0]
for i in range(N):
    g = math.gcd(g, A[i])
print(g)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

l = list(map(int, input().split()))
N=l[0]
X=l[1]
x=[0]*N
A=[0]*N
l = list(map(int, input().split()))
for i in range(N):
    x[i] = l[i]
    A[i] = abs(X-x[i])
g=A[0]
for i in range(N):
    g = math.gcd(g, A[i])
print(g)
Problem p03437 (python)

Fixed submission:
import math
import sys

x,y = map(int, input().split())
if x%y != 0:
    print(x)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
x=int(input())
y=int(input())
if x%y != 0:
    print(x)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

x=int(input())
y=int(input())
if x%y != 0:
    print(x)
else:
    print(-1)
Problem p02743 (python)

Fixed submission:
a,b,c = map(int, input().split())
print("Yes" if (c-a-b > 0 and 4*a*b < (c-a-b)**2) else "No")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
puts (c-a-b > 0 and 4*a*b < (c-a-b)**2 ) ? "Yes" : "No"
Problem p02787 (python)

Fixed submission:
#import numpy as np

h, n = map(int, input().split())

a = []
b = []
m = []
for i in range(n):
    at, bt = map(int, input().split()) # a_tmp, b_tmp
    a.append(at)
    b.append(bt)

#dp = np.zeros((n+1,h+1))
dp = [[0]*(h+1) for _ in range(n+1)]
for i in range(n):
    for j in range(h):
        # print("Test")
        if j - a[i] < 0:
            o = b[i]
        else:
            o = dp[i+1][j+1-a[i]] + b[i]
        if i != 0:
            dp[i+1][j+1] = min(dp[i][j+1], o)
        else:
            dp[i+1][j+1] = o

print(int(dp[n][h]))

Buggy submission (verdict: Runtime Error):
import numpy as np

h, n = map(int, input().split())

a = []
b = []
m = []
for i in range(n):
    at, bt = map(int, input().split()) # a_tmp, b_tmp
    a.append(at)
    b.append(bt)

dp = np.zeros((n+1,h+1))
dp = [[0] * (h+1) for i in range(n+1)]
# print(dp2)

for i in range(n):
    for j in range(h):
        # print("Test")
        if j - a[i] < 0:
            o = b[i]
        else:
            o = dp[i+1][j+1-a[i]] + b[i]
        if i != 0:
            dp[i+1][j+1] = min(dp[i][j+1], o)
        else:
            dp[i+1][j+1] = o

print(int(dp[n][h]))
Problem p02795 (python)

Fixed submission:
import math

H = int(input())
W = int(input())
N = int(input())

k = max([H,W])
ans = math.ceil(N/k)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

li = []

for i in range(N):
    x, l = map(int, input().split())
    li.append([x-l,x+l])

li.sort(key=lambda x:x[1])
li.sort(key=lambda x:x[0])

ans = 0
t = 0 - 10**9 + 99
for i in range(N):
    if t <= li[i][0]:
        ans += 1
        t = li[i][1]

print(ans)
Problem p02853 (python)

Fixed submission:
def award(x):
    return max(0, 4*(10**5) - x*(10**5))

x,y = map(int,input().split())

ans  = award(x)
ans += award(y)

if x == 1 and y == 1:
    ans += 4*(10**5)

print(ans)

Buggy submission (verdict: Runtime Error):
# import math
import bisect
import numpy as np
mod = 10**9 + 7

# http://cav-inet.hateblo.jp/entry/2017/02/18/165141
def binary_search(list,target): 

	result = -1
	left = 0
	right = len(list) - 1

	while left <= right:
		center = (left + right)//2
		if list[center] == target:
			result = center
			break
		elif list[center] < target:
			left = center + 1
		elif list[center] > target:
			right = center - 1

	if result == -1:
		return False
	else:
		return True

n = int(input())
a = list(map(int,input().split()))
c = np.cumsum(a)
s = c[n-1]

if binary_search(c, c[n-1]/2):
    print(0)
    exit()

i = bisect.bisect_left(c, c[n-1]/2)
ans = min(2*c[i]-s, s - c[i-1]-1)
print(ans)
Problem p03032 (python)

Fixed submission:
# coding: utf-8
import copy
import numpy as np

n, k = map(int, input().split())
v = list(map(int, input().split()))
rev = copy.copy(v)
rev.reverse()

lcs = [0]+np.cumsum(v)
rcs = [0]+np.cumsum(rev)
# print(lcs,rcs)

ans = -10**20
for l in range(n+1):
  for r in range(n+1-l):
    able = True
    d = k - ( l + r )
    if d < 0:
      able = False
      break
    # m = lcs[l] + rcs[r]
    t = v[0:l] + rev[0:r]
    m = sum(t)
    # print(t,l,r,m)
    t.sort()
    # print(t)
    d = min(d,l+r)
    for i in range(d):
      if 0 > t[i]:
        m -= t[i]
      else:
        break
    # print(m)
    ans = max(ans,m)

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import copy
import numpy as np

n, k = map(int, input().split())
v = list(map(int, input().split()))
rev = copy.copy(v)
rev.reverse()

lcs = [0]+np.cumsum(v)
rcs = [0]+np.cumsum(rev)
# print(lcs,rcs)

ans = -10**20
for l in range(n+1):
  for r in range(n+1-l):
    able = True
    d = k - ( l + r )
    if d < 0:
      able = False
      break
    m = lcs[l] + rcs[r]
    t = v[0:l] + rev[0:r]
    m = sum(t)
    # print(t,l,r,m)
    t.sort()
    # print(t)
    d = min(d,l+r)
    for i in range(d):
      if 0 > t[i]:
        m -= t[i]
      else:
        break
    # print(m)
    ans = max(ans,m)

print(ans)
Problem p03111 (python)

Fixed submission:
# 解説コード
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
def dfs(a, b, c, k)
  
  if k == N
    nil if [a, b, c].min == 0
    return (A-a).abs + (B-b).abs + (C-c).abs - 10 * 3
  end
  
  x = dfs(a+L[k], b, c, k+1) + 10
  y = dfs(a, b+L[k], c, k+1) + 10
  z = dfs(a, b, c+L[k], k+1) + 10
  w = dfs(a, b, c, k+1)
  
  [x, y, z, w].compact.min
end

N, A, B, C = gets.split.map(&:to_i)

L = Array.new(N)
N.times{ |i| L[i] = gets.to_i }

p dfs(0, 0, 0, 0)
Problem p03160 (python)

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

dp = [10**18] * (10**5+10)
dp[0] = 0

for i in range(n):
  if i+1 < n:
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
  if i+2 < n:
    dp[i+2] = dp[i] + abs(h[i+2] - h[i])

print(dp[n-1])

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

dp = [10**18] * (10**5+10)
dp[0] = 0

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

print(dp[n-1])
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:
 print("Hello World")
else:
 a=int(input())
 b=int(input())
 print(a+b)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==1
 print("Hello World")
else
 a=int(input())
 b=int(input())
 print(a+b)
Problem p03288 (python)

Fixed submission:
r = int(input())
ans = "AGC"
if r < 1200:
    ans = "ABC"
elif r < 2800:
    ans = "ARC"
print(ans)

Buggy submission (verdict: Runtime Error):
r = int(input())
ans = "AGC"
if r < 1200:
    ans = "ABC"
else r < 2800:
    ans = "ARC"
print(ans)

Buggy submission (verdict: Runtime Error):
r = int(input())
r = "AGC"
if r < 1200:
    ans = "ABC"
else r < 2800:
    ans = "ARC"
print(ans)
Problem p03308 (python)

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

ans = 0
for i in range(n):
    for j in range(i):
       t = abs(a[j]-a[i])
       if ans < t:
           ans = t

print(ans)

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

ans = 0
for i in range(n):
    for j in range(i):
       t = abs(a[j]-a[i])
       if ans < t:
           ans = t

print(ans)
Problem p03563 (python)

Fixed submission:
r = int(input())
g = int(input())
print( g*2 - r )

Buggy submission (verdict: Runtime Error):
n = input('');
k = input('');
 
int32(1);
for 1:n
  min(int32(2)*ans, ans+k);
end
 
fprintf("%d\n", ans);

Buggy submission (verdict: Runtime Error):
n = input('');
k = input('');

int32(1);
for 1:n
  min(int32(2)*ans, ans+K);
end

fprintf("%d\n", ans);