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

Fixed submission:
x , y = map(int, input().split())
print(int(x+y/2))

Buggy submission (verdict: Runtime Error):
import numpy as np 
n , m = map(int, input().split())
l = np.array([list(map(int, input().split())) for _ in range(m)])
l2 = np.zeros(m)

l2 = l[:,0]*(10**6) + l[:,1]
l2 = np.sort(l2)

j = 1000000
k = 1
for i in range(m):
    if j+1000000 > l2[i]:
        l2[i] = j + k
        k += 1
    else :
        j += 1000000
        l2[i] = j + 1
        k = 2

for i in l2 :
    print('{0:012d}'.format(i))
Problem p03359 (python)

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

if a <= b :
    print(a)
else :
    print(a-1)

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

l = [i for i in range(55556)]
l[1] = 0
for i in l[1:]:
    if i > math.sqrt(55556): break
    if i == 0 :continue
    for j in range(2*i,55556,i): l[j] = 0

prime = [i for i in l if (l != 0 and (i - 3)%10 == 0)]
print(" ".join(map(str,prime[:N])))

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

l = [i for i in range(55556)]
l[1] = 0
for i in l[1:]:
    if i > math.sqrt(55556): break
    if i == 0 :continue
    for j in range(2*i,55556,i): l[j] = 0

prime = [i for i in l if (l != 0 and (i - 3)%10 == 0)]
print(" ".join(map(str,prime[:N])))
Problem p02709 (python)

Fixed submission:
from collections import *
from itertools import *

N = int(input())

A = map(int, input().split())
SA = SB = 0
ABI = sorted(((b:=max(N-i, i-1)*a, SA:=SA+a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)

prev = {0:0}
prev_max = 0
for k, (a, b, i) in enumerate(ABI):
  curr = defaultdict(int)
  curr_max = 0
  for l, p in prev.items():
    r = k-l
    if p + SB - min(l,r)*SA < prev_max:
      continue
    curr[l] = max(curr[l], p+abs(N-i-r)*a)
    curr[l+1] = p+abs(i-l-1)*a
    curr_max = max(curr_max, curr[l], curr[l+1])
  SA -= a
  SB -= b
  prev = curr
  prev_max = curr_max

print(curr_max)

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

def solve(a, i, prev):
  r = N - len(prev) - i + 1
  p = -i*a
  for j, s in enumerate(prev):
    yield max(p+abs(j-i)*a, s+abs(j+r)*a)
    p = s
  yield s+abs(len(prev)-i)*a

pd = [0]
A = map(int, input().split())
for a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True):
  pd = [*solve(a,i, pd)]

print(max(prev))

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

def solve(a, i, prev):
  r = N - len(prev) - i + 1
  p = -i*a
  for j, s in enumerate(prev):
    yield max(p+abs(j-i)*a, s+abs(j+r)*a)
    p = s
  yield s+abs(len(prev)-i)*a

pd = [0]
A = map(int, input().split())
for a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True):
  pd = [*solve(a,i, prev)]

print(max(prev))

Buggy submission (verdict: Runtime Error):
from operator import itemgetter as get
N = int(input())

A = map(int, input().split())
SB = 0
ABI = sorted(((b:=max(N-i, i-1)*a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)

def solve(a, i, prev, th):
  pl, pr, ps = 0, -1, 0
  for l, r, s in prev:
    if s < th:
      continue
    if pr == r-1:
      yield l, r-1, max(s+abs(r-i)*a, ps+abs(i-pl)*a)
    else:
      if pl:
        yield pl+1, pr, ps+abs(i-pl)*a
      yield l, r-1, s+abs(r-i)*a
    pl, pr, ps = l, r, s
  yield pl+1, pr, ps+abs(i-pl)*a

prev = [(1, N, 0)]
pm = 0
for j, (a,b,i) in enumerate(ABI):
  M = 0
  prev = [(M:=max(M,s)) and (l, r, s) for l, r, s in solve(a,i, prev, pm-SB)]
  pm = M
  SB -= b

print(pm)

Buggy submission (verdict: Runtime Error):
from collections import *
from itertools import *

N = int(input())

A = map(int, input().split())
SA = SB = 0
ABI = sorted(((b:=max(N-i, i-1)*a, SA:=SA+a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)

prev = {0:0}
prev_max = 0
for k, (a, b, i) in enumerate(ABI):
  curr = defaultdict(int)
  for l, p in prev.items():
    r = k-l
    if p + SB - (k-1)*SA < prev_max:
      continue
    curr[l] = max(curr[l], p+abs(N-i-r)*a)
    curr[l+1] = p+abs(i-l-1)*a
  SA -= a
  SB -= b
  prev = curr
  prev_max = max(prev.values())

print(prev_max)
Problem p02717 (python)

Fixed submission:
X, Y, Z = map(int, input().split())
print(Z, X, Y)

Buggy submission (verdict: Runtime Error):
X, Y, Z = map(int, input.split())
print(Z, X, Y)
Problem p02727 (python)

Fixed submission:
from itertools import *
from heapq import *

X, Y, A, B, C = map(int, input().split())
P = sorted(map(lambda x:-int(x), input().split()))
Q = sorted(map(lambda x:-int(x), input().split()))
R = sorted(map(lambda x:-int(x), input().split()))

S = sum(islice(merge(islice(P, X),islice(Q, Y),R), X+Y))

print(-S)

Buggy submission (verdict: Runtime Error):
from itertools import *

def merge(x,y):
  while 1:
    if x and y and x[0] >= y[0] or (not (x and y)) and x:
      yield x.pop(0)
    else y:
      yield y.pop(0)
    else:
      return

X, Y, A, B, C = map(int, input().split())
P = sorted(map(int, input().split()), reverse=True)
Q = sorted(map(int, input().split()), reverse=True)
R = sorted(map(int, input().split()), reverse=True)

S = sum(islice(merge(P,R), X))
S += sum(islice(merge(Q,R), Y))
print(S)

Buggy submission (verdict: Runtime Error):
from heapq import *
from itertools import *

class cached_iter(object):
  def __init__(self, it):
    self.it = iter(it)
    self.prev = None
    self._back = False

  def __next__(self):
    if self._back:
      self._back = False
      if self.prev:
        return self.prev
    self.prev = next(self.it)
    return self.prev
        
  def back(self):
    self._back = True

  def __iter__(saelf):
    return self

X, Y, A, B, C = map(int, input().split())
P = sorted(map(lambda x:-int(x), input().split()))
Q = sorted(map(lambda x:-int(x), input().split()))
R = cached_iter(sorted(map(lambda x:-int(x), input().split())))

S = sum(islice(merge(P,R), X))
R.back()
S += sum(islice(merge(Q,R), Y))
print(-S)
Problem p02738 (python)

Fixed submission:
from functools import lru_cache, reduce
from itertools import accumulate

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

@lru_cache(maxsize=None)
def mod_inv(x):
  x1, y1, z1 = 1, 0, x
  x2, y2, z2 = 0, 1, M
  while z1 != 1:
    d, m = divmod(z2, z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1%M

def gen_Y(i, A):
  yield A
  # sC2/1, (s-2)C2/2, (s-4)C2/3  ...
  s = 3*(N-i)
  r = s*(s-1)>>1
  d_r = (s<<1)-3
  for j in range(1, N-i+1):
    yield r * mod_inv(j)
    r -= d_r
    d_r -= 4

def gen_X():
  # sC3*2/1, (s-3)C3*2/2, (s-6)C3*2/3  ...
  yield 1
  a = N
  b = 3*N - 1
  for i in range(1, N+1):
    yield a * b * (b-1) * mod_inv(i)
    a -= 1
    b -= 3

def mul_mod(x, y):
  return x * y % M

def acc_mod(it):
  return accumulate(it, mul_mod)

ans = sum(sum(acc_mod(gen_Y(i, A))) for i, A in enumerate(acc_mod(gen_X())))%M

print(ans)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache, reduce
from itertools import accumulate

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

@lru_cache(maxsize=None)
def mod_inv(x):
  x1, y1, z1 = 1, 0, x
  x2, y2, z2 = 0, 1, M
  while z1 != 1:
    d, m = divmod(z2, z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1%M

def gen_Y(i, A):
  yield A
  # sC2/1, (s-2)C2/2, (s-4)C2/3  ...
  s = 3*(N-i)
  r = s*(s-1)>>1
  d_r = (s<<1)-3
  for j in range(1, N-i+1):
    yield r * mod_inv(j)
    r -= d_r
    d_r -= 4

def gen_X():
  # sC3*2/1, (s-3)C3*2/2, (s-6)C3*2/3  ...
  yield 1
  a = N
  b = 3*N - 1
  for i in range(1, N+1):
    yield a * b * (b-1) * mod_inv(i)
    a -= 1
    b -= 3

def mul_mod(x, y):
  return x * y % M

def acc_mod(it):
  return accumulate(it, mul_mod)

ans = sum(sum(acc_mod(gen_Y(i, A))) for i, A in enumerate(acc_mod(gen_X())))%M

print(ans)

Buggy submission (verdict: Runtime Error):
　from functools import lru_cache, reduce
from itertools import accumulate

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

@lru_cache(maxsize=None)
def mod_inv(x):
  x1, y1, z1 = 1, 0, x
  x2, y2, z2 = 0, 1, M
  while z1 != 1:
    d, m = divmod(z2, z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1%M

def gen_Y(i, A):
  yield A
  # sC2/1, (s-2)C2/2, (s-4)C2/3  ...
  s = 3*(N-i)
  r = s*(s-1)>>1
  d_r = (s<<1)-3
  for j in range(1, N-i+1):
    yield r * mod_inv(j)
    r -= d_r
    d_r -= 4

def gen_X():
  # sC3*2/1, (s-3)C3*2/2, (s-6)C3*2/3  ...
  yield 1
  a = N
  b = 3*N - 1
  for i in range(1, N+1):
    yield a * b * (b-1) * mod_inv(i)
    a -= 1
    b -= 3

def mul_mod(x, y):
  return x * y % M

def acc_mod(it):
  return accumulate(it, mul_mod)

ans = sum(sum(acc_mod(gen_Y(i, A))) for i, A in enumerate(acc_mod(gen_X())))%M

print(ans)
Problem p02742 (python)

Fixed submission:
H,W=map(int,input().split())
if H == 1 or W == 1:
  print(1)
else:
  print((H*W+1)//2)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split()))
if H == 1 or W == 1:
  print(1)
else:
  print((H*W+1)//2)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split()))
if H == 1 or W == 1:
  print(0)
else:
  print((H*W+1)//2)
Problem p02744 (python)

Fixed submission:
from itertools import product, combinations_with_replacement
N=int(input())
s="abcdefghij"
 
def get_gen(a, N):
  for c in s[:s.index(max(a))+2 if a else 1]:
    t = a+c
    if len(t) == N:
      print(t)
    else:
      get_gen(t,N)

get_gen("", N)

Buggy submission (verdict: Runtime Error):
def gen_pattern(N, pre=b""):
  for c in range(0x61, max(pre or 0x60)+2):
    pat = pre+c
    if len(pat) == N:
      yield pat.decode()
    else:
      yield from gen_pattern(N, pat)

for pattern in gen_pattern(int(input())):
  print(pattern)

Buggy submission (verdict: Runtime Error):
from string import ascii_lowercase as alph

def gen_pattern(N, pre="", m=-1):
  for i, c in enumerate(alph[:m+2]):
    pat = pre+c
    if len(pattern) == N:
      yield pattern
    else:
      yield from gen_pattern(N, pat, max(i,m))

for pattern in gen_pattern(int(input())):
  print(pattern)

Buggy submission (verdict: Runtime Error):
from string import ascii_lowercase as alph

def gen_pattern(N, pre=""):
  for c in alp[:(ord(max(pre or "\x60"))-0x5f]:
    pattern = pre+c
    if len(pattern) == N:
      yield pattern
    else:
      yield from gen_pattern(N, pattern)

for pattern in gen_pattern(int(input())):
  print(pattern)

Buggy submission (verdict: Runtime Error):
from itertools import product, combinations_with_replacement
N=int(input())
s="abcdefghij"

def get_gen(a, N):
  for c in s[:s.index(max(a))+2]:
    t = a+c
    if len(t) == N:
      print(t)
    else:
      get_gen(t,N)
get_gen("a", N)

Buggy submission (verdict: Runtime Error):
from itertools import product
N=int(input())
s="abcdefghij"
a
ab
abc
abcd
for i in range(N):
  c=s[:i+1]
  for p in product(c,repeat=N-i):
    print(c+"".join(p))
Problem p02705 (python)

Fixed submission:
import math
radius = int(input())
c = 2 * math.pi * radius
print("%.2f" % c)

Buggy submission (verdict: Runtime Error):
num = int(input())
print(math.pi * 2 * num)
Problem p02791 (python)

Fixed submission:
N = int(input())
P_list = list(map(int,input().split()))
i_num = 0
min_P = P_list[0]
for p in P_list:
    if p <= min_P:
        min_P = p
        i_num += 1
print(i_num)

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    P_list = list(map(int,input().split()))
    i_num = 0
    min_P = P_list[0]
    for p in P_list:
        if p <= min_P:
            min_P = p
            i_num += 1
    print(i_num)

if __name__ == __main__:
    main()
Problem p03273 (python)

Fixed submission:
H,W = map(int,input().split())
mas = [list(input()) for i in range(H)]
new_mas = []
new_mas2 = []
for row in mas:
    if "#" in row:
        new_mas.append(row)
    elif "#" not in row:
        continue

for column in list(zip(*new_mas)):
    if "#" in column:
        new_mas2.append(column)
    elif "#" not in column:
        continue

for i in list(zip(*new_mas2)):
    for j in i:
        print(j,end="")
    print()

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
mas = [list(input()) for i in range(H)]
new_mas = [row for row in mas if "#" in row:]
new_mas2 = [column for column in list(zip(*new_mas)) if "#" in column]
for i in list(zip(*new_mas2)):
    for j in i:
        print(j,end="")
    print()
Problem p04001 (python)

Fixed submission:
def main():
    #import sys
    #input = sys.stdin.readline
    S = input()
    S_list = list(S)
    dig = len(S) - 1
    insert_plus = format(0,"0"+str(dig)+"b")
    insert_plus_max = "1"*len(insert_plus)
    s = 0
    if len(S) == 1:
        print(int(S))
        exit()

    for i in range(int(insert_plus_max,2)+1):
        before = 0
        num_list = []
        now = format(i,"0"+str(dig)+"b")
        for j in range(len(now)):
            if now[j] == "1":
                num_list.append("".join(S_list[before:int(j)+1]))
                before = j+1
            if j == len(now)-1:
                num_list.append("".join(S_list[before:]))
        for num in num_list:
            s += int(num)
    print(s)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    #import sys
    #input = sys.stdin.readline
    S = input()
    S_list = list(S)
    dig = len(S) - 1
    insert_plus = format(0,"0"+str(dig)+"b")
    insert_plus_max = "1"*len(insert_plus)
    s = 0
    for i in range(int(insert_plus_max,2)+1):
        before = 0
        num_list = []
        now = format(i,"0"+str(dig)+"b")
        for j in range(len(now)):
            if now[j] == "1":
                num_list.append("".join(S_list[before:int(j)+1]))
                before = j+1
            if j == len(now)-1:
                num_list.append("".join(S_list[before:]))
        for num in num_list:
            s += int(num)
    print(s)

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

Fixed submission:
import math
n=float(input())
n*=2
print(n*math.pi)

Buggy submission (verdict: Runtime Error):
import math
n=float(input())
n*=2
print(n*math.pi
Problem p03059 (python)

Fixed submission:
# スペース区切りの整数の入力
a, b, c = map(int, input().split())
d = c + 0.5
bis = 0
byou = 0

for i in range(21):
    byou = i * a
    if byou >= d:
        break
    bis = i * b

print(bis)

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

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
  
# 整数の入力
a = int(input())
# 数値のリスト化
xList = [int(i) for i in input().split()]
keisanList = copy.deepcopy(xList)
saidai = max(xList)
saidaiKoyakuSu = 0
koyakuSu = 0
listIndex = 0

for i in range(a):
    keisanList = copy.deepcopy(xList)
    keisanList[i] = saidai
    koyakuSu = gcd_list(keisanList)
    if(saidaiKoyakuSu < koyakuSu):
        saidaiKoyakuSu = koyakuSu
        listIndex = i

xList[listIndex] = saidai
print(gcd_list(xList))
Problem p02837 (python)

Fixed submission:
n = int(input())

stm = [[] for i in range(n)]

def possible(honest):
    #print(honest)
    for i in range(n):
        if honest[i] == '0':
            continue
        for j in range(len(stm[i])):
            #print(stm[i][j])
            #print(honest[stm[i][j][0]-1])
            if stm[i][j][1] == 1 and honest[stm[i][j][0]-1] == '0':
                return False
            elif stm[i][j][1] == 0 and honest[stm[i][j][0]-1] == '1':
                return False
    return True

            

for i in range(n):
    a = int(input())
    for _ in range(a):
        x,y = map(int, input().split())
        stm[i].append([x,y])
   
count = 0
for k in range(2**n):
    hon = list(bin(k)[2:])
    hon = ['0']*(n-len(hon)) + hon
    if possible(hon):
        count = max(count, sum([int(x) for x in hon]))
print(count)

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

stm = [[] for i in range(n)]

def possible(honest):
    for i in range(n):
        if honest[i] == '0':
            continue
        for j in range(len(stm[i])):
            if stm[i][j][1] == 1 and honest[stm[i][j][0]-1] == '0':
                return False
            elif stm[i][j][1] == 0 and honest[stm[i][j][0]-1] == '1':
                return False
    return True

            

for i in range(n):
    a = int(input())
    x,y = map(int, input().split())
    stm[i].append([x,y])
   
count = 0
for k in range(2**n):
    hon = list(bin(k)[2:])
    hon = ['0']*(n-len(hon)) + hon
    if possible(hon):
        print(hon)
        count = max(count, sum([int(x) for x in hon]))
print(count)
Problem p02969 (python)

Fixed submission:
N = int(input())
print(3*N*N)

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

b=[-1]*N
b[N-1]=a[N-1]
for i in range(N-1)[::-1]: #N=4なら 2,1,0
    sum_count = N // (i+1)
    if sum_count==1:
        b[i]=a[i]
    else:
        sum1=0
        for j in range(sum_count-1):
            sum1 = sum1 + b[(i+1)*(j+1)]
        sum1 = sum1 % 2
        b[i]=(a[i]+ sum1)%2

print(sum(b))
for i in range(N):
    if b[i]==1:
        print(i+1,end=" ")
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())
min_mod = 2019
flg=[0]*2019
flg2=[0]*2019
for i in range(L,R):
    idx=i%2019
    if flg[idx]==1:
        break
    if flg[idx]==0:
        for j in range(i+1,R+1):
            mod  = (i*j)%2019
            if flg2[mod]==1:
                break
            flg2[mod]=1
            if min_mod > mod:
                min_mod=mod
        flg[idx]=1
print(min_mod)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
min_mod = 2019
flg=[0]*2018
flg2=[0]*2018
for i in range(L,R):
    idx=i%2019
    if flg[idx]==0:
        for j in range(i+1,R+1):
            mod  = (i*j)%2019
            if flg2[mod]==1:
                break
            flg2[mod]=1
            if min_mod > mod:
                min_mod=mod
        flg[idx]=1
print(min_mod)
Problem p03047 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
print(n-k+1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
S = []
for i in range(N):
    S.append(str(input()))
    
start_b = 0
end_a = 0
both = 0
ab_count = 0
for i in S:
    if i[0]=="B":
        start_b = start_b + 1
    if i[-1]=="A":
        end_a = end_a + 1
    if i[0]=="B" and i[-1]=="A":
        both = both + 1
    ab_count = ab_count + i.count("AB")

additional = min(start_b, end_a)
if additional == both:
    additional = additional  - 1
ans = ab_count + additional
print(ans)
Problem p03106 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a, b, k = map(int, input().split())
if a > b:
    t = a
    a = b
    b = t
# 0<a<b<100
fact = []
for i in range(1,a+1,):
    if a%i==0 and b%i==0:
        fact.append(i)
print(fact[-k])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, k = map(int, input().split())
if a > b:
    t = a
    a = b
    b = t
# 0<a<b<100
fact = []
for i in range(1,a+1,):
    if a%i==0 and b%i==0:
        count = count + 1
        fact.append(i)
print(fact[-k])
Problem p02743 (python)

Fixed submission:
import math
from decimal import *
a, b, c = map(int, input().split())
print('Yes' if ( 2 * Decimal(a*b).sqrt() + a + b - c < 0 ) else 'No')

Buggy submission (verdict: Runtime Error):
import math
import decimal
a, b, c = map(int, input().split())
print('Yes' if ( 2 * Decimal(a*b).sqrt() + a + b - c < 0 ) else 'No')
Problem p03998 (python)

Fixed submission:
cards = [input() for _ in range(3)]
dict = {'a':0, 'b':1, 'c':2}
inv = ['A', 'B', 'C']
turn = 'a'
game = True
while game:
    if cards[dict[turn]] == '':
        print(inv[dict[turn]])
        game = False
    else:
        next_turn = cards[dict[turn]][0]
        cards[dict[turn]] = cards[dict[turn]][1:]
        turn = next_turn
    # print(turn, cards)

Buggy submission (verdict: Runtime Error):
# cards = [input() for _ in range(3)]
dict = {'a':0, 'b':1, 'c':2}
inv = ['A', 'B', 'C']
turn = 'a'
game = True
while game:
    turn = cards[dict[turn]][0]
    cards[dict[turn]] = cards[dict[turn]][1:]
    for i in range(3):
        if cards[i] == '':
            print(inv[i])
            game = False
Problem p03599 (python)

Fixed submission:
# ABC074C - Sugar Water
# input
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100

# default values
x, y = min(a, b) * 100, 0  # density could be 0%
dens = y / x


# exhaustive search
for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        water = i * A + j * B
        rest = f - water
        for k in range(rest // c + 1):
            for l in range((rest - c * k) // d + 1):
                sugar = c * k + d * l
                total = water + sugar

                if sugar / total > e / (e + 100):  # compare to e (the max density)
                    break
                else:
                    if sugar / total > dens:
                        dens = sugar / total
                        x, y = total, sugar
print(x, y)

Buggy submission (verdict: Runtime Error):
import sys

a, b, c, d, e, f = map(int, input().split())

water_pattern = []
for i in range(f+1):
    for j in range(f+1):
        x = a*i*100 + b*j*100
        if x <= f and not x in water_pattern:
            water_pattern.append(x)

sugar_pattern = []
for i in range(f+1):
    for j in range(f+1):
        y = c*i + d*j
        if y <= f and not y in sugar_pattern:
            sugar_pattern.append(y)

sugarwater_max = -1
sugar_max = -1
concentration = 0
for i in range(len(water_pattern)):
    for j in range(len(sugar_pattern)):
        # if i == 0 and j == 0:
        #     continue
        # else:
        #     sugarwater = water_pattern[i] + sugar_pattern[j]
        #     if (water_pattern[i]/100) * e >= sugar_pattern[j] and sugarwater <= f:
        #         if sugarwater_max == -1 and sugar_max == -1:
        #             sugarwater_max = sugarwater
        #             sugar_max = sugar_pattern[j]
        #             concentration = 100 * sugar_pattern[j] / sugarwater
        #         else:
        #             if concentration < 100 * sugar_pattern[j] / sugarwater:
        #                 sugarwater_max = sugarwater
        #                 sugar_max = sugar_pattern[j]
        #                 concentration = 100 * sugar_pattern[j] / sugarwater

print("{} {}".format(sugarwater_max, sugar_max))
Problem p03611 (python)

Fixed submission:
import sys

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

bucket = [0 for i in range(max(a) + 1)]

for i in range(n):
    bucket[a[i]] += 1


sum_three_num = []

if len(bucket) == 1:
    sum_three_num.append(bucket[0])
elif len(bucket) == 2:
    sum_three_num.append(bucket[0] + bucket[1])
else:
    for i in range(1, len(bucket) - 1):
        sum_three_num.append(bucket[i-1] + bucket[i] + bucket[i+1])

print(max(sum_three_num))

Buggy submission (verdict: Runtime Error):
import sys

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

bucket = [0 for i in range(max(a) + 1)]

for i in range(n):
    bucket[a[i]] += 1

sum_three_num = []
for i in range(1, len(bucket) - 1):
    sum_three_num.append(bucket[i-1] + bucket[i] + bucket[i+1])

print(max(sum_three_num))
Problem p02706 (python)

Fixed submission:
vacationDayCount, homeworkCount = map(int, input().split())
requiredDayList = list(map(int, input().split()))

playableDayCount = vacationDayCount - sum(requiredDayList)

if(playableDayCount >= 0):
    print(playableDayCount)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
vacationDayCount, homeworkCount = map(int, input().split())
requiredDayList = list(map(int, input.split()))

playableDayCount = vacationDayCount - sum(requiredDayList)

if(playableDayCount >= 0):
    print(playableDayCount)
else:
    print(-1)