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

Fixed submission:
n, a, b = map(int, input().split())
d = b-a
d_nearest_side = min(a-1, n-b)
if d % 2 == 0:
    print(d//2)
else:
    move_side = 1 + (d-1)//2 + d_nearest_side
    print(int(move_side))

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

d = b-a
d_nearest_side = int(min(a-1, n-b))
if d % 2 == 0:
    print(int(d/2))
else:
    move_side = int((d+1)/2) + d_nearest_side
    print(int(move_side)
Problem p02848 (python)

Fixed submission:
num = int(input())
base_str = input()
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
            'U', 'V', 'W', 'X', 'Y', 'Z']
def replacer(letter, num):
    letter_index = alphabets.index(letter)
    return(alphabets[(letter_index+num)%26])
answer = []
for i in range(len(base_str)):
    answer.append(replacer(base_str[i], num))
answer = ''.join(answer)
print(answer)

Buggy submission (verdict: Runtime Error):
num = int(input())
base_str = input()
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
            'U', 'V', 'W', 'X', 'Y', 'Z']
def replacer(letter, num):
    letter_index = alphabets.index(letter)
    return(alphabets[(letter_index+num)%27])
answer = []
for i in range(len(base_str)):
    answer.append(replacer(base_str[i], num))
answer = ''.join(answer)
print(answer)

Buggy submission (verdict: Runtime Error):
base_str = input()
num = int(input())
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
            'U', 'V', 'W', 'X', 'Y', 'Z']
def replacer(letter, num):
    letter_index = alphabets.index(letter)
    return(alphabets[(letter_index+num)%27])
answer = []
for i in range(len(base_str)):
    answer.append(replacer(base_str[i], num))
answer = ''.join(answer)
print(answer)

Buggy submission (verdict: Runtime Error):
base_str = input()
num = int(input)
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
            'U', 'V', 'W', 'X', 'Y', 'Z']
def replacer(letter, num):
    letter_index = alphabets.index(letter)
    return(alphabets[(letter_index+num)%27])
answer = []
for i in range(len(base_str)):
    answer.append(replacer(base_str[i], num))
answer = ''.join(answer)
print(answer)
Problem p03148 (python)

Fixed submission:
N,K = (int(x) for x in input().split())
t_arr = [0]*(N+1)
d_arr = [0]*(N+1)
for i in range(N):
    t,d = tuple(int(x) for x in input().split())
    t_arr[i+1] = t
    d_arr[i+1] = d

td_index = list(range(1,N+1))
td_index.sort(key=lambda x:d_arr[x], reverse=True)

n_dm_set = set()
small_arr = []
d_dm = 0
for i in td_index[:K]:
    t = t_arr[i]
    d = d_arr[i]
    if t in n_dm_set:
        small_arr.append(d)
    n_dm_set.add(t)
    d_dm += d

current_max = len(n_dm_set)**2+d_dm

n_x_set = set(n_dm_set)
d_x = d_dm
nt_x = len(n_dm_set)
for i in td_index[K:]:
    if not small_arr:
        break
    t = t_arr[i]
    d = d_arr[i]
    if t in n_x_set:
        continue
    n_x_set.add(t)
    d_x += d
    d_x -= small_arr.pop()
    nt_x += 1
    current_max = max(current_max, nt_x**2+d_x)

print(current_max)

Buggy submission (verdict: Runtime Error):
N,K = (int(x) for x in input().split())
td_arr = []
for _ in range(N):
    td = tuple(int(x) for x in input().split())
    td_arr.append(td)

td_arr.sort(key=lambda x:x[1], reverse=True)

n_dm_set = set()
small_arr = []
d_dm = 0
for t,d in td_arr[:K]:
    if t in n_dm_set:
        small_arr.append(d)
    n_dm_set.add(t)
    d_dm += d

candidate_dict = {}
candidate_dict[len(n_dm_set)] = d_dm

n_x_set = set(n_dm_set)
d_x = d_dm
for t,d in td_arr[K:]:
    if t in n_x_set:
        continue
    n_x_set.add(t)
    d_x += d
    d_x -= small_arr[-1]
    small_arr = small_arr[:-1]
    candidate_dict[len(n_x_set)] = d_x

ans = 0
for k,v in candidate_dict.items():
    ans = max(ans, k*k+v)

print(ans)
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())

if a > b:
  print("GREATER")
elif a < b:
  print("LESS")
else :
  print("EQUAL")

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

if a > b:
  print("GREATER")
else :
  print("LESS")
Problem p02845 (python)

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

X = [-1, -1, -1]
ans = 1
for a in A:
    t = X.count(a-1)
    ans = ans * t % 1000000007
    if a-1 not in X:
        print(0)
        exit()
    idx = X.index(a-1)
    X[idx] += 1
print(ans)

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

X = [-1, -1, -1]
ans = 1
for a in A:
    t = X.count(a-1)
    ans = ans * t % 1000000007
    idx = X.index(a-1)
    if idx < 0:
        print(0)
        exit()
    X[idx] += 1
print(ans)

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

X = [-1, -1, -1]
ans = 1
for a in A:
    t = X.count(a-1)
    ans = ans * t % 1000000007
    X[X.index(a-1)] += 1
print(ans)
Problem p02846 (python)

Fixed submission:
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

P = (A1 - B1) * T1
Q = (A2 - B2) * T2

if P > 0:
    P *= -1
    Q *= -1

if P + Q < 0:
    print(0)
elif P + Q == 0:
    print('infinity')
else:
    S, T = divmod(-P, P+Q)
    if T != 0:
        print(S * 2 + 1)
    else:
        print(S * 2)

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

X = [-1, -1, -1]
ans = 1
for a in A:
    t = X.count(a-1)
    ans = ans * t % 1000000007
    if a-1 not in X:
        print(0)
        exit()
    idx = X.index(a-1)
    X[idx] += 1
print(ans)
Problem p02852 (python)

Fixed submission:
N, M = map(int, input().split())
S = input()
S = list(reversed(S))

# 現在位置
now = 0
_now = 0
ans = []
while now <= N-1:
    for i in range(min(M, N-now), 0, -1):
        if S[now+i] == '0':
            ans.append(i)
            now += i
            break
    if _now == now:
        print(-1)
        exit()
    _now = now
print(*reversed(ans))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = input()

# 現在位置
now = 0
_now = 0
ans = []
while now <= N-1:
    for i in range(M, 0, -1):
        if now+i > N:
            continue
        if S[now+i] == '0':
            ans.append(i)
            now += i
    if _now == now:
        print(-1)
        exit()
    _now = now

# 辞書順最小化を目指す
ans = sorted(ans)
new_ans = []
now = 0
while len(ans) > 0:
    length = 0
    for a in ans:
        if S[now+a] == '0':
            new_ans.append(a)
            now += a
            length = a
            break
    ans.remove(length)
print(*new_ans)
Problem p02924 (python)

Fixed submission:
N = int(input())
print((N-1) * N // 2)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(sum(list(range(N))))
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(pow(10, 7))


# vをcに塗る。pはvの親
def dfs(v, p, c):
    res[v] = c
    for e in G[v]:
        if e[0] == p:
            continue
        if e[1] & 1:
            dfs(e[0], v, 1-c)
        else:
            dfs(e[0], v, c)


N = int(input())

G = [[] for _ in range(N)]
res = [0] * N
for _ in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1].append([v-1, w])
    G[v-1].append([u-1, w])
dfs(0, -1, 1)
print('\n'.join(map(str, res)))

Buggy submission (verdict: Runtime Error):
# vをcに塗る。pはvの親
def dfs(v, p, c):
    res[v] = c
    for e in G[v]:
        if e[0] == p:
            continue
        if e[1] & 1:
            dfs(e[0], v, 1-c)
        else:
            dfs(e[0], v, c)


N = int(input())

G = [[] for _ in range(N)]
res = [0] * N
for _ in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1].append([v-1, w])
    G[v-1].append([u-1, w])
dfs(0, -1, 1)
print('\n'.join(map(str, res)))
Problem p03085 (python)

Fixed submission:
master = {
    'A': 'T',
    'T': 'A',
    'C': 'G',
    'G': 'C'
}
print(master[input()])

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split(' '))
s = input()
c = [0] * n
for i in range(1, n):
    c[i] += c[i-1]
    if s[i-1:i+1] == 'AC':
        c[i] += 1
for _ in range(q):
    l, r = map(int, input().split(' '))
    print(c[r-1] - c[l-1])
Problem p03110 (python)

Fixed submission:
coin = {
    'JPY': 0,
    'BTC': 0
}
for _ in range(int(input())):
    x, u = input().split(' ')
    coin[u] += float(x)
print(coin['JPY'] + coin['BTC'] * 380000)

Buggy submission (verdict: Runtime Error):
coin = {}
for _ in range(int(input())):
    x, u = input().split(' ')
    coin[u] = coin.get(u, 0) + float(x)

print(coin['JPY'] + coin['BTC'] * 380000)
Problem p03244 (python)

Fixed submission:
from collections import Counter

N = int(input())
V = list(map(int, input().split()))
S1 = Counter([V[i] for i in range(0, N, 2)])
S2 = Counter([V[i] for i in range(1, N, 2)])

S1 = sorted(S1.items(), key=lambda x: x[1], reverse=True)
S2 = sorted(S2.items(), key=lambda x: x[1], reverse=True)
S1.append([0, 0])
S2.append([0, 0])

if S1[0][0] == S2[0][0]:
    ans = min(N-(S1[0][1]+S2[1][1]), N-(S1[1][1]+S2[0][1]))
else:
    ans = N - (S1[0][1] + S2[0][1])
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
V = list(map(int, input().split()))
S1 = Counter([V[i] for i in range(0, N, 2)])
S2 = Counter([V[i] for i in range(1, N, 2)])

S1 = sorted(S1.items(), key=lambda x: x[1], reverse=True)
S2 = sorted(S2.items(), key=lambda x: x[1], reverse=True)

if S1[0][0] == S2[0][0]:
    ans = min(N-(S1[0][1]+S2[1][1]), N-(S1[1][1]+S2[0][1]))
else:
    ans = N - (S1[0][1] + S2[0][1])
print(ans)
Problem p03262 (python)

Fixed submission:
n, x = map(int, input().split())
x = list(map(lambda y: abs(x - int(y)), input().split()))


from functools import reduce
from fractions import gcd
def greatest_common_divisor(iter):
    '''
    最大公約数を返す
    '''
    return reduce(gcd, iter)


print(greatest_common_divisor(x))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
x = list(map(lambda y: abs(x - int(y)), input().split()))


from functools import reduce
from math import gcd
def greatest_common_divisor(iter):
    '''
    最大公約数を返す
    '''
    return reduce(gcd, iter)


print(greatest_common_divisor(x))
Problem p03673 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str, A[::-2])), ' '.join(map(str, A[n%2::2])))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
print(*A[::-2], *A[n%2::2])

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

# TLE
# l = []
# for i, a in enumerate(A):
#     if i%2 == 0:
#         l.append(a)
#     else:
#         l.insert(0, a)
# print(' '.join(map(str, l)))

print(*A[::-2], *A[n%2::2])
Problem p03722 (python)

Fixed submission:
def bellman_ford(edges, n, src):
    # n:ノード数, src:スタートノード
    # edges:edge(src, tgt, cost)のリスト
    inf = float('inf')
    dist = [inf for _ in range(n)]
    dist[src] = 0
    # 移動経路
    pre = {}

    # 最短経路算出
    for i in range(n-1):
        for edge in edges:
            # srcにコストがあり、tgtのコストよりも低いコストで更新できそうなら
            if dist[edge[0]] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
                dist[edge[1]] = dist[edge[0]] + edge[2]
                pre[edge[1]] = edge[0]

    # 負の閉路検出
    def checkpath(pre, n, src):
        if src in pre and pre[n-1] == src and pre[src] == n-1:
            return True
        count = 0
        p = pre[n-1]
        while p != src:
            p = pre[p]
            if p == src and src in pre:
                return True
            count += 1
            if count >= n-1:
                return True
        return False

    is_cycle = checkpath(pre, n, src)
    return (dist, is_cycle)


N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a-1, b-1, -c))

d, is_cycle = bellman_ford(edges, N, 0)
if is_cycle:
    print('inf')
else:
    print(-d[N-1])

Buggy submission (verdict: Runtime Error):
def bellman_ford(edges, n, src):
    # n:ノード数, src:スタートノード
    # edges:edge(src, tgt, cost)のリスト
    inf = float('inf')
    dist = [inf for _ in range(n)]
    dist[src] = 0
    # 移動経路
    pre = {}

    # 最短経路算出
    for i in range(n-1):
        for edge in edges:
            # srcにコストがあり、tgtのコストよりも低いコストで更新できそうなら
            if dist[edge[0]] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
                dist[edge[1]] = dist[edge[0]] + edge[2]
                pre[edge[1]] = edge[0]

    # 負の閉路検出
    def checkpath(pre, n, src):
        if src in pre and pre[n] == src and pre[src] == n:
            return True
        count = 0
        p = pre[n-1]
        while p != src:
            p = pre[p]
            if p == src and src in pre:
                return True
            count += 1
            if count >= n-1:
                return True
        return False

    is_cycle = checkpath(pre, n, src)
    return (dist, is_cycle)


N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a-1, b-1, -c))

d, is_cycle = bellman_ford(edges, N, 0)
if is_cycle:
    print('inf')
else:
    print(-d[N-1])
Problem p03999 (python)

Fixed submission:
S = input()

ans = 0
if len(S) == 1:
    ans = int(S)
else:
    for i in range(2**(len(S)-1)):
        tmp = S[0]
        for j, b in enumerate(format(i, 'b').zfill(len(S)-1)):
            if b == '1':
                tmp += '+'
            tmp += S[j+1]
        ans += eval(tmp)
print(ans)

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

ans = 0
for i in range(2**(len(S)-1)):
    tmp = S[0]
    for j, b in enumerate(format(i, 'b').zfill(len(S)-1)):
        if b == '1':
            tmp += '+'
        tmp += S[j+1]
    ans += eval(tmp)
print(ans)
Problem p02791 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ct=1
minn=p[0]
for i in range(1,n):
    if minn==1:
        #ct+=1
        break
    elif minn>p[i]:
        minn=p[i]
        ct+=1
print(ct)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
ct=1
maxn=p.index(1)
while True:
    if maxn==0:
        break
    p=p[0:maxn]
    i+=1
    maxn=p.index(min(p))
    ct+=1
print(ct)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
ct=1
i=1
maxn=p.index(i)
while True:
    p=p[0:maxn]
    i+=1
    maxn=p.index(min(p))
    ct+=1
    if maxn==0:
        break
print(ct)
Problem p02911 (python)

Fixed submission:
n,k,q=map(int,input().split())
a=[(input()) for l in range(q)]
#if q-k<0:
 #   for i in range(n):
  #      print('Yes')
#else:
import collections
c = collections.Counter(a)
for i in range(n):
    #print(k-c[str(i+1)])
    if q-c[str(i+1)]<k:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
a=[(input()) for l in range(q)]
#if q-k<0:
 #   for i in range(n):
  #      print('Yes')
#else:
c = collections.Counter(a)
for i in range(n):
    #print(k-c[str(i+1)])
    if q-c[str(i+1)]<k:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
a=[(input()) for l in range(q)]
if q-k<0:
    for i in range(n):
        print('Yes')
else:
    c = collections.Counter(a)
    for i in range(n):
        if c[str(i+1)]>q-k:
            print('Yes')
        else:
            print('No')

Buggy submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
a=[(input()) for l in range(q)]
if q-k<0:
    for i in range(n):
        print('Yes')
else:
    c = collections.Counter(a)
    for i in range(n):
        if c[str(i)]>q-k:
            print('Yes')
        else:
            print('No')
Problem p02975 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
d=[]
out=0
for i in c.values():
    b.append(i)
for i in c.keys():
    d.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    elif b[0]!=b[1] or b[1]!=b[2]:
        out=1
    elif (d[0]^d[1]^d[2])!=0:
        out=1
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a_2)
b=[]
out=0
for i in c.values():
    b.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    if b[0]!=b[1] or b[1]!=b[2]:
        out=1
    else:
        pass
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a_2)
b=[]
out=0
for i in c.values():
    b.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    if b[0]!=b[1] or b[1]!=b[2]:
        out=1
        break
    else:
        pass
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')
Problem p03086 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[21]:


S=input()
t=list()
ct=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='T' or S[i]=='G':
        i+=1
        ct+=1
    else:
        t.append(ct)
        ct=0
        i+=1
t.append(ct)
print(max(t))


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[14]:


S=input()
t=list()
ct=0
for i in range(len(S)-1):
    if S[i]=='A' or S[i]=='C' or S[i]=='T' or S[i]=='G':
        i+=1
        ct+=1
    else:
        t.append(ct)
        ct=0
        i+=1
print(max(t))


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[11]:


S=input()
t=list()
ct=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='T' or S[i]=='G':
        i+=1
        ct+=1
    else:
        t.append(ct)
        ct=0
        i+=1
print(max(t))


# In[ ]:
Problem p03103 (python)

Fixed submission:
N,M=map(int,input().split())
ab=[list(map(int,input().split())) for l in range(N)]
ct=0
ct1=0
ct2=0
money=0
l=[]
id=[]
for i in range(N):
    l.append(ab[i][0])
id=sorted(range(len(l)),key=lambda k: l[k])
l.sort()
while ct<M:
    while ct2<ab[id[ct1]][1]:##
        money+=l[ct1] #l[ct1]
        #print(money,l[ct1])
        ct+=1
        ct2+=1
        if ct==M:
            break
    ct1+=1
    ct2=0
print(money)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[86]:


N,M=map(int,input().split())
ab=[list(map(int,input().split())) for l in range(N)]
ct=0
money=0
l=[]
for i in range(N):
    l.append(ab[i][0])
l.sort()
for i in range(N):
   # min_id=l.index(min(l))
    if ct+ab[i][1]<M:
        money+=ab[i][0]*ab[i][1]
        ct+=ab[i][1]
        #l[i]=10000000000
    else:
        for i in range(ab[i][1]):
            money+=l[i]
            ct+=1
            if ct==M:
                break
print(money)


# ##

Buggy submission (verdict: Runtime Error):


N,M=map(int,input().split())
ab=[list(map(int,input().split())) for l in range(N)]
ct=0
money=0
l=[]
for i in range(N):
    l.append(ab[i][0])
l.sort()
for i in range(N):
   # min_id=l.index(min(l))
    if ct+ab[i][1]<M:
        money+=ab[i][0]*ab[i][1]
        ct+=ab[i][1]
        #l[i]=10000000000
    else:
        for i in range(ab[i][1]):
            money+=l[i]
            ct+=1
            if ct==M:
                break
       # l[min_id]=100000000000
        if ct==M:
            break
print(money)


# ##
Problem p03111 (python)

Fixed submission:
N,A,B,C=map(int,input().split())
l=[]
 
for i in range(N):
    l.append(int(input()))
INF=100000
 
def mp(j,a,b,c):
    if j==N:
      return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0=mp(j+1,a,b,c)
    ret1=mp(j+1,a+l[j],b,c)+10
    ret2=mp(j+1,a,b+l[j],c)+10
    ret3=mp(j+1,a,b,c+l[j])+10
    return min(ret0,ret1,ret2,ret3)
print(mp(0,0,0,0))

Buggy submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())
l=[]

for i in range(N):
l.append(int(input()))
INF=100000

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

Fixed submission:
import math
input = input().split(' ')
a = input[0]
b = input[1]
num = int(a + b)
n = math.sqrt(num)
if float.is_integer(n):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
num = int(a + b)
n = math.sqrt(num)
if float.is_integer(n):
    print("YES")
else:
    print("NO")
Problem p03068 (python)

Fixed submission:
n = int(input())
s = input()
k = int(input())
ss = ''
for i in range(n):
	if s[i] == s[k-1]:
		ss += s[i]
	else:
		ss += '*'
print(ss)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
ss = ''
for i in range(n):
	if s[i] == s[k]:
		ss += s[i]
	else:
		ss += '*'
print(ss)
Problem p03139 (python)

Fixed submission:
n, a, b = map(int, input().split())
print(str(min(a, b)) + " " + str(max(0, a+b-n)))

Buggy submission (verdict: Runtime Error):
n = int(input())
long ans = 0
li = []
for i in range(n):
    a, b = map(int, input().split())
    li.append([a+b, a, b])

li = sorted(li)
for i in range(n):
    if i%2 == 0:
        ans += li[i][1]
    if i%2 == 1:
        ans -= li[i][2]

print(ans)
Problem p03141 (python)

Fixed submission:
n = int(input())
ans = 0
li = []
for i in range(n):
    a, b = map(int, input().split())
    li.append([a+b, a, b])

li = sorted(li)
li.reverse()
for i in range(n):
    if i%2 == 0:
        ans += li[i][1]
    else:
        ans -= li[i][2]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
li = []
for i in range(n):
    a, b = map(int, input().split())
    li.append([a+b, a, b])

li = sorted(li)
li = reversed(li)
for i in range(n):
    if i%2 == 0:
        ans += li[i][1]
    else:
        ans -= li[i][2]

print(ans)