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

Fixed submission:
import sys
fin = sys.stdin.readline
sys.setrecursionlimit(500000)

N, M = [int(elem) for elem in fin().split()]
adj = [[] for _ in range(N)]

for _ in range(N + M - 1):
    u, v = [int(elem) - 1 for elem in fin().split()]
    adj[u].append(v)

inv_adj = [[] for _ in range(N)]
for u, neighbors in enumerate(adj):
    for v in neighbors:
        inv_adj[v].append(u)

topo = []
visited = [False] * N

def dfs_visit(node):
    for neighbor in adj[node]:
        if visited[neighbor]:
            continue
        visited[neighbor] = True
        dfs_visit(neighbor)
    topo.append(node)
    return

for node in range(N):
    if not visited[node]:
        visited[node] = True
        dfs_visit(node)

topo = topo[::-1]

parent = [-1] * N
order = dict()
order[topo[0]] = 0
for number, node in enumerate(topo[1:], start=1):
    neighbors = inv_adj[node]
    correct_parent = -1
    for neighbor in neighbors:
        if neighbor in order and order[neighbor] > correct_parent:
            correct_parent = order[neighbor]
    parent[node] = correct_parent
    order[node] = number

order_to_number = {v: k + 1 for k, v in order.items()}
order_to_number[-1] = 0

for i in range(N):
    print(order_to_number[parent[i]])

Buggy submission (verdict: Runtime Error):
import sys
fin = sys.stdin.readline


N, M = [int(elem) for elem in fin().split()]
adj = [[] for _ in range(N)]

for _ in range(N + M - 1):
    u, v = [int(elem) - 1 for elem in fin().split()]
    adj[u].append(v)

inv_adj = [[] for _ in range(N)]
for u, neighbors in enumerate(adj):
    for v in neighbors:
        inv_adj[v].append(u)

topo = []
visited = [False] * N

def dfs_visit(node):
    for neighbor in adj[node]:
        if visited[neighbor]:
            continue
        visited[neighbor] = True
        dfs_visit(neighbor)
    topo.append(node)
    return

for node in range(N):
    if not visited[node]:
        visited[node] = True
        dfs_visit(node)

topo = topo[::-1]

parent = [-1] * N
order = dict()
order[topo[0]] = 0
for number, node in enumerate(topo[1:], start=1):
    neighbors = inv_adj[node]
    correct_parent = -1
    for neighbor in neighbors:
        if neighbor in order and order[neighbor] > correct_parent:
            correct_parent = order[neighbor]
    parent[node] = correct_parent
    order[node] = number

order_to_number = {v: k + 1 for k, v in order.items()}
order_to_number[-1] = 0

for i in range(N):
    print(order_to_number[parent[i]])
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(300000)
fin = sys.stdin.readline


N, M = [int(elem) for elem in fin().split()]
adj = [[] for _ in range(N)]
for _ in range(M):
    x, y = [int(elem) - 1 for elem in fin().split()]
    adj[x].append(y)

visited = [False] * N
topo_order = []
# topological sort by DFS
def dfs_visit(node):
    visited[node] = True
    for neighbor in adj[node]:
        if not visited[neighbor]:
            dfs_visit(neighbor)
    topo_order.append(node)


for node in range(N):
    dfs_visit(node)
topo_order = topo_order[::-1]

dp = [0] * N
for node in topo_order[:-1]:
    for neighbor in adj[node]:
        dp[neighbor] = max(dp[neighbor], dp[node] + 1)

print(max(dp))

Buggy submission (verdict: Runtime Error):
import sys
fin = sys.stdin.readline


N, M = [int(elem) for elem in fin().split()]
adj = [[] for _ in range(N)]
for _ in range(M):
    x, y = [int(elem) - 1 for elem in fin().split()]
    adj[x].append(y)

visited = [False] * N
topo_order = []
# topological sort by DFS
def dfs_visit(node):
    for neighbor in adj[node]:
        if not visited[neighbor]:
            dfs_visit(neighbor)
    topo_order.append(node)


for node in range(N):
    dfs_visit(node)
topo_order = topo_order[::-1]

dp = [0] * N
for node in topo_order[:-1]:
    for neighbor in adj[node]:
        dp[neighbor] = max(dp[neighbor], dp[node] + 1)

print(max(dp))
Problem p03281 (python)

Fixed submission:
def num_divisors(n):
  res = 0
  i = 1
  while i * i <= n:
    if n % i == 0:
      res += 1
      res += 1 if i * i != n else 0
    i += 1
  return res


N = int(input())
res = 0
for n in range(1, N + 1, 2):
  if num_divisors(n) == 8:
    res += 1
print(res)

Buggy submission (verdict: Runtime Error):
def num_divisors(n):
  res = 0
  i = 2
  while i * i <= n:
    if n % i == 0:
      res += 1
      res += 1 if i * i != n else 0
    i += 1
  return res


N = input()
res = 0
for n in range(1, N + 1):
  if num_divisors(n) == 8:
    res += 1
print(res)
Problem p03355 (python)

Fixed submission:
s = input()
K = int(input())


def brute_force(s, K):
    substring_set = set()

    # brute-force
    for start in range(len(s)):
        # 5まででよかった...
        for length in range(1, 6):
            substring = s[start:start+length]
            substring_set.add(substring)

    substring_list = sorted(list(substring_set))
    print(substring_list[K - 1])

brute_force(s, K)

Buggy submission (verdict: Runtime Error):
def brute_force(s, K):
    substring_set = set()

    # brute-force
    for start in range(len(s)):
        # 5まででよかった...
        for length in range(1, 6):
            substring = s[start:start+length]
            substring_set.add(substring)

    substring_list = sorted(list(substring_set))
    print(substring_list)
    print(substring_list[K - 1])

brute_force(s, K)

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())


def brute_force(s, K):
    substring_set = set()

    # brute-force
    for start in range(len(s)):
        # 5まででよかった...
        for length in range(len(s) - start + 1):
            if length == 0:
                substring = s[start]
            else:
                substring = s[start:start+length]
            substring_set.add(substring)
            if length == 4:
                break

    substring_list = sorted(list(substring_set))
    print(substring_list[K - 1])

brute_force(s, K)
Problem p03362 (python)

Fixed submission:
from math import sqrt, floor, ceil
from itertools import combinations


N = int(input())

# O(num^(1/2))
def is_prime_num(num):
    num_sqrted = floor(sqrt(num))
    for i in range(2, num_sqrted + 1):
        if num % i == 0:
            return False
    else:
        return True

a_set = set()
while len(a_set) < N:
    for i in range(11, 55555, 10):
        if i in a_set:
            continue
        elif not is_prime_num(i):
            continue
        else:
            a_set.add(i)
            break

print(' '.join(map(str, a_set)))

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

# O(num^(1/2))
def is_prime_num(num):
    num_sqrted = floor(sqrt(num))
    for i in range(2, num_sqrted + 1):
        if num % i == 0:
            return False
    else:
        return True

a_set = set()
while len(a_set) < N:
    for i in range(11, 55555, 10):
        if i in a_set:
            continue
        elif not is_prime_num(i):
            continue
        else:
            a_set.add(i)
            break

print(' '.join(map(str, a_set)))

Buggy submission (verdict: Runtime Error):
a_set = set()
while len(a_set) < N:
    for i in range(11, 55555, 10):
        if i in a_set:
            continue
        elif not is_prime_num(i):
            continue
        else:
            a_set.add(i)
            break

print(' '.join(map(str, a_set)))
Problem p03377 (python)

Fixed submission:
A, B, X = [int(elem) for elem in input().split()]

if X < A:
    print("NO")
elif X > A + B:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
import sys


fin = sys.stdin.readline
n = int(fin())
a_list = sorted(int(elem) for elem in fin().split())

num_elems = a_list[-1]
num_choices = -1
max_diff = float('-inf')
for a in a_list[:-1]:
    diff = min(num_elems - a, a)
    if diff > max_diff:
        num_choices = a
        max_diff = diff

print(num_elems, num_choices)
Problem p03407 (python)

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

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input())
print("Yes" if A + B >= C else "No")

Buggy submission (verdict: Runtime Error):
A, B, C = map(input(), int)
print("Yes" if A + B >= C else "No")
Problem p03547 (python)

Fixed submission:
X, Y = input().split()
if X == Y:
  res = "="
elif X < Y:
  res = "<"
else:
  res = ">"
print(res)

Buggy submission (verdict: Runtime Error):
X, Y = input().split()
if X = Y:
  res = "="
elif X < Y:
  res = "<"
else:
  res = ">"
print(res)
Problem p03855 (python)

Fixed submission:
import sys
fin = sys.stdin.readline
from collections import defaultdict

class UnionFind(object):
    def __init__(self, N):
        self.__root = list(range(N))
    

    def root(self, x):
        if self.__root[x] == x:
            return x
        else:
            # root abbreviation
            self.__root[x] = self.root(self.__root[x])
            return self.__root[x]

    
    def same(self, x, y):
        return self.root(x) == self.root(y)


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if (x == y):
            return
        self.__root[x] = y
        return


N, K, L = [int(elem) for elem in fin().split(' ')]
road_list = tuple([tuple([int(elem)-1 for elem in fin().split(' ')]) for _ in range(K)])
train_list = tuple([tuple([int(elem)-1 for elem in fin().split(' ')]) for _ in range(L)])

uf_road = UnionFind(N)
uf_train = UnionFind(N)

for p, q in road_list:
    uf_road.unite(p, q)

for r, s in train_list:
    uf_train.unite(r, s)


key_list = []
count = defaultdict(int)
for i in range(N):
    # logN
    key = (uf_road.root(i), uf_train.root(i))
    key_list.append(key)
    count[key] += 1

assert len(key_list) == N
answer_list = [0] * N
for i, key in enumerate(key_list):
    answer_list[i] = str(count[key])
print(' '.join(answer_list))

Buggy submission (verdict: Runtime Error):
7 4 4
1 2
2 3
2 5
6 7
3 5
4 5
3 4
6 7
Problem p04006 (python)

Fixed submission:
import sys
from copy import copy


fin = sys.stdin.readline
N, x = [int(elem) for elem in fin().split()]
a_list = [int(elem) for elem in fin().split()]

min_total_cost = float('inf')
min_so_far = a_list[:]
for num_magics in range(N):
    for i in range(N):
        min_so_far[i] = min(min_so_far[i], a_list[i - num_magics])
    total_cost = sum(min_so_far) + num_magics * x
    min_total_cost = min(min_total_cost, total_cost)
print(min_total_cost)

Buggy submission (verdict: Runtime Error):
import sys


fin = sys.stdin.readline
N, x = [int(elem) for elem in fin().split()]
a_list = [int(elem) for elem in fin().split()]

min_cost_for = a_list.copy()
this_is_from = list(range(N))

max_num_magics = 0
for i, a in enumerate(a_list): 
    for j, other_a in enumerate(a_list):
        if i == j: continue
        num_magics = i - j if j < i else (N - j + i)
        cost = other_a + num_magics * x
        if cost < min_cost_for[i]:
            min_cost_for[i] = cost
            max_num_magics = max(num_magics, max_num_magics)
            this_is_from[i] = j


total_cost = sum(a_list[origin] for origin in this_is_from) + x * max_num_magics
print(total_cost)
Problem p02678 (python)

Fixed submission:
import numpy as np
n,m = map(int,input().split())

p = [0 for i in range(n+1)]
q = list()
q2 = list()

g=[[] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)


q2.append(1)

while 1:
    q=q2
    q2=[]

    while len(q):
        v = q.pop()
        
        for nv in g[v]:
            if p[nv] == 0:
                p[nv]=v
                g[nv].remove(v)
                q2.append(nv)
    if len(q2)==0:
        break

if 0 in p[2:]:
    print('No')
else:
    print('Yes')
    for q in p[2:]:
        print(q)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())

p = [0 for i in range(n+1)]
q = list()
q2 = list()

g=[[] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)


q2.append(1)

while 1:
    q=q2
    q2=[]

    while len(q):
        v = q.pop()
        
        for nv in g[v]:
            if p[nv] == 0:
                p[nv]=v
                g[nv].remove(v)
                q2.append(nv)
    if len(q2)==0:
        break

if 0 in p[2:]:
    print('No')
else:
    print('Yes')
    for q in p[2:]:
        print(q)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())

p = [0] * (n+1)
a = [0] * m
b = [0] * m


for i in range(m):
    a[i],b[i] = map(int,input().split())

s=list()
t=list()
t.append(1)


while(1):
    for j in t:
        for k in range(m):
            if a[k]==j and p[b[k]] == 0:
                p[b[k]]=a[k]
                s.append(b[k])

            if b[k]==j and p[a[k]]==0:
                p[a[k]]=b[k]
                s.append(a[k])
                

    if len(s)==0:
        break
    else:
        t = s
        s = []
    
if 0 in p[2:]:
    print('No')
else:
    print('Yes')
    for q in p[2:]:
        print(q)
Problem p02681 (python)

Fixed submission:
str1 = input()
str2 = input()

if len(str1) + 1 == len(str2) and str1 == str2[:-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K=map(int,input().split())

A2 = np.zeros(N)
A = list(map(int,input().split()))
A = list(map(lambda x: x -1 , A))
current_town = 0
 
 
 
i=0
while i<K:
    current_town = A[current_town]
    if  A2[current_town] != 0:
        cycle = i - A2[current_town] 
        i = K - ((K-i) % cycle)
        i=i+1
        break
    else:
        A2[current_town] = i
        i=i+1

while i<K:
    current_town = A[current_town]
    t=i+1
    i=t

print(current_town+1)

Buggy submission (verdict: Runtime Error):

if len(str1) + 1 == len(str2) and str1 == str2[:-1]:
    print('Yes')
else:
    print('No')
Problem p02684 (python)

Fixed submission:
import numpy as np
n, k=map(int,input().split())

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

 
s = list()
ord = np.full(n+1, -1)
c=1
l=0

v=1
while ord[v]==-1:
    ord[v]=len(s)
    s.append(v)
    v=a[v-1]
c=len(s)-ord[v]
l=ord[v]

if k<l:
    print(s[k])  
else:
    k-=l
    k%=c
    print(s[l+k])

Buggy submission (verdict: Runtime Error):
import numpy as np
import math 
N, K=map(int,input().split())
A2 = np.zeros(N)
A = list(map(int,input().split()))
#A = list(map(lambda x: x -1 , A))
current_town = 0



i=0
while i<K:
    current_town = A[current_town]
    if  A2[current_town] != 0:
        cycle = i - A2[current_town] 
        i = K - (K-i) % cycle
    else:
        A2[current_town] = i

print(current_town+1)
Problem p02783 (python)

Fixed submission:
import math
a = list(map(int,input().split()))
print(math.ceil(a[0]/a[1]))

Buggy submission (verdict: Runtime Error):
import math
a = list(map(int,input().split()))
print(math.ceil((float)a[0]/a[1]))
Problem p02784 (python)

Fixed submission:
a = [list(map(int,input().split())) for l in range(2)]

if sum(a[1]) >= a[0][0]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
a = [list(map(int,input().split())) for l in range(2)]
if sum(a[1]) >= a[0][0]
	print("Yes")
else
	print("No")

Buggy submission (verdict: Runtime Error):
import math
a = [int(input().split()) for l in range(2)]
if sum(a[1]) >= a[0][0]
	print("Yes")
else
	print("No")

Buggy submission (verdict: Runtime Error):
import math
a = [int(input()).split() for l in range(2)]
if sum(a[1]) >= a[0][0]
	print("Yes")
else
	print("No")

Buggy submission (verdict: Runtime Error):
import math
a = [input().split() for l in range(2)]
if sum(a[1]) >= a[0][0]
	print("Yes")
else
	print("No")

Buggy submission (verdict: Runtime Error):
import math
a = [input().split() for l in range(3)]
if sum(a[1]) >= a[0][0]
	print("Yes")
else
	print("No")

Buggy submission (verdict: Runtime Error):
import math
a = list(map(int,input().split()))
b = list(map(int,input().split()))
if sum(b) >= a[0]
	print("Yes")
else
	print("No")

Buggy submission (verdict: Runtime Error):
import math
a = list(map(int,input().split()))
b = list(map(int,input().split()))
if b.sum >= a[0]
	print("yes")
else
	print("no")
Problem p02675 (python)

Fixed submission:
book_num = int(input())
first_digit = book_num % 10
if first_digit in [2, 4, 5, 7, 9]:
    print('hon')
elif first_digit in [0, 1, 6, 8]:
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
import math

a, b, h, m = map(float, input().split())
hour = 30 * h + 0.5 * m
minute = 6 * m

radian = abs(hour - minute)
if radian > 180:
    radian = 360 - abs(hour - minute)

dist = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(radian))
print(math.sqrt(dist))

Buggy submission (verdict: Runtime Error):
import math
import sys

a, b, h, m = map(float, input().split())
hour = 30 * h + 0.5 * m
minute = 6 * m

radian = abs(hour - minute)
if radian > 180:
    radian = 360 - abs(hour - minute)

dist = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(radian))
print(math.sqrt(dist))
Problem p02681 (python)

Fixed submission:
flag = True
s = [input() for i in range(2)]
if (len(s[0]) > 10 or len(s[0]) < 1) or (len(s[0]) + 1 != len(s[1])):
    flag = False
else:
    for j in range(len(s[0])):
        if not s[0][j] == s[1][j]:
            flag = False
if flag:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = [input() for i in range(2)]
if (len(s[0]) > 10 or len(s[0]) < 1) or (len(s[0]) + 1 != len(s[1])):
    print("no")
else:
    for j in range(len(s)):
        if not s[0][j] == s[1][j]:
            print("no")
            break
    print("yes")
Problem p02700 (python)

Fixed submission:
A, B, C, D = [int(x) for x in input().split()]
run = True
while run:
    C -= B
    if C <= 0:
        run = False
        result = "Yes"
        continue
    A -= D
    if A <= 0:
        run = False
        result = "No"
        continue
print(result)

Buggy submission (verdict: Runtime Error):
A, B, C, D = [int(x) for x in input().split()]
t = A // D#HPが０になるもしくはギリギリの回数9
a = C // B#10大きいほうが勝利，同じ場合は高橋の勝利
if t >＝ a:#たかはしが倒されるほうがターン数は多くかかる
    print("Yes")
else:
    print("No")
Problem p02706 (python)

Fixed submission:
N, M = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):

N, M = [int(x) for x in input().split()]
A = [int(a) for a input()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]
A = [int(a) for a input().split()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N, M = int(input().split())
A = [int(a) for a input().split()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N, M = int(input().split())
A = [int(a) for a input().split()]
if N - sum(A) >= 0:
    print(N - sum(A))
else:
    print(-1)
Problem p02719 (python)

Fixed submission:
n, k = [int(_) for _ in input().split()]
n = n % k
if abs(n - k) < n:
    print(abs(n -k))
else:
    print(n)

Buggy submission (verdict: Runtime Error):
def resolve(n, k, c):
    if abs(n - k) < n:
        n = abs(n - k)
        c += 1
        return resolve(n, k, c)
    else:
        return n
if __name__ == "__main__":
    n, k = [int(_) for _ in input().split()]
    c = 0
    n = resolve(n, k, c)
    print(n)
Problem p02730 (python)

Fixed submission:
def isReverse(s):
    p1 = 0
    p2 = len(s) - 1
    flag = True
    while p1 <= p2:
        if s[p1] != s[p2]:
            flag = False
        p1 += 1
        p2 += -1
    return flag
if __name__ == "__main__":
    s = input()
    s1 = s[:int((len(s) - 1) / 2)]
    s2 = s[int((len(s) + 1) / 2):]
    # print(s, s1, s2)
    # print(isReverse(s), isReverse(s1), isReverse(s2))
    if isReverse(s) and isReverse(s1) and isReverse(s2):
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
#B
def isReverse(s):
    p1 = 0
    p2 = len(s) - 1
    flag = True
    while p1 >= p2:
        if s[p1] != s[p2]:
            flag = False
        p1 += 1
        p2 += -1
    return flag
if __name__ == "__main__":
    s = input()
    s1 = s[:int((len(s) - 1) / 2)]
    s2 = s[int((len(s) + 1) / 2):]
    if isReverse(s) and isReverse(s1) and isReverse(s2):
        print("Yes")
    else:
        print("No")
Problem p03545 (python)

Fixed submission:
s = input()
length = 4 # fixed

for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  ans = 0
  f = s[0]  
  for i in range(length-1): 
    if bit & (1 << i):   # 0はプラス、1はマイナス
      f += "-"
    else:
      f += "+"
    f += s[i + 1]
  # print('d:',f)
  ans = eval(f)
  
  if ans == 7:
    print(f+'=7')
    exit()

Buggy submission (verdict: Runtime Error):
s = input()
length = 4 # fixed

for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  ans = 0
  f = s[0]  
  for i in range(length-1): 
    if bit & (1 << i):   # 0はプラス、1はマイナス
      f += "-"
    else:
      f += "+"
    f += s[i + 1]
  print('d:',f)
  ans = eval(f)
  
  if ans == 7:
    print(f+'=7')
    return
Problem p02824 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
B = []
C = []

A.sort()
for _ in range(P-1):
    B.append(A.pop())

try:
    C.append(A.pop())
    while C[-1] == A[-1]:
        C.append(A.pop())
except:
    pass

A_length = len(A)
B_length = len(B)
C_length = len(C)
sm = sum(C)
count = 0

for _ in range(len(A)):
    now = A[-1]
    new = now + M
    threshhold = C
    remain = V - B_length - (A_length - count)
    if new >= C[0]:
        if remain <= 0:
            val = A.pop()
            C.append(val)
            sm += val
            count += 1
        elif sm <= new * (C_length + count) - remain*M:
            val = A.pop()
            C.append(val)
            sm += val
            count += 1
print(len(B+C))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))
B = []
C = []

A.sort()
for _ in range(P-1):
    B.append(A.pop())
C.append(A.pop())
while C[-1] == A[-1]:
    C.append(A.pop())

A_length = len(A)
B_length = len(B)
C_length = len(C)
sm = sum(C)
count = 0

for _ in range(len(A)):
    now = A[-1]
    new = now + M
    threshhold = C
    remain = V - B_length - (A_length - count)
    if remain <= 0 and new >= C[0]:
        val = A.pop()
        C.append(val)
        sm += val
        count += 1
    elif sm <= new * (C_length + count) - remain*M:
        val = A.pop()
        C.append(val)
        sm += val
        count += 1
print(len(B+C))
Problem p03032 (python)

Fixed submission:
import sys
from collections import deque
input = sys.stdin.readline

N, K = map(int, input().split())
V = deque(list(map(int, input().split())))
score = deque()

for i in range(K+1): #左から
    for j in range(K-i+1): #右から
        hand = deque()
        if i + j <= N:
            for n in range(i): #左から
                hand.append(V[n]) 
            for m in range(j): #右から
                hand.append(V[N-m-1])
            for k in range(K-i-j):
                if len(hand) > 0 and min(hand) < 0:
                    hand.remove(min(hand)) 
            score.append(sum(hand))

print(max(score))

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
input = sys.stdin.readline

N, K = map(int, input().split())
V = deque(list(map(int, input().split())))
score = deque()

for i in range(K+1): #左から
    for j in range(K-i+1): #右から
        hand = deque()
        for n in range(i): #左から
            hand.append(V[n]) 
        for m in range(j): #右から
            hand.append(V[N-m-1])
        for k in range(K-i-j):
            if len(hand) > 0 and min(hand) < 0:
                hand.remove(min(hand)) 
        score.append(sum(hand))

print(max(score))
Problem p03059 (python)

Fixed submission:
A, B, T = input().split()
A, B, T = int(A), int(B), int(T)

print(B * (T // A))

Buggy submission (verdict: Runtime Error):
N = input()
V = list(map(int, input().split()))
C = list(map(int, input().split()))
XY = 0
for i in range(len(V)):
    if V[i] - C[i] > 0:
        XY += V[i] - C[i]

print(XY)