Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
house = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n = int(input())
for i in range(n):
	b,f,r,v = map(int,input().split())
	house[b][f][r] += v

for i in range(4):
	for j in range(3):
		for k in range(10):
			print(' ',end='')
			if k != 9:
				print(house[i][j][k],end='')
			else:
				print(house[i][j][k])
	if i<3
	print('####################')


Fixed submission:
house = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n = int(input())
for i in range(n):
	b,f,r,v = map(int,input().split())
	house[b-1][f-1][r-1] += v

for i in range(4):
	for j in range(3):
		for k in range(10):
			print(' ',end='')
			if k != 9:
				print(house[i][j][k],end='')
			else:
				print(house[i][j][k])
	if i<3:
		print('####################')

Buggy python submission (verdict: Runtime Error):
house = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n = int(input())
for i in range(n):
	b,f,r,v = map(int,input().split())
	house[b][f][r] += v

for i in range(4):
	for j in range(3):
		for k in range(10):
			print(' ',end='')
			if k != 9:
				print(house[i][j][k],end='')
			else:
				print(house[i][j][k])
	if i<3:
		print('####################')


Fixed submission:
house = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n = int(input())
for i in range(n):
	b,f,r,v = map(int,input().split())
	house[b-1][f-1][r-1] += v

for i in range(4):
	for j in range(3):
		for k in range(10):
			print(' ',end='')
			if k != 9:
				print(house[i][j][k],end='')
			else:
				print(house[i][j][k])
	if i<3:
		print('####################')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 0
b = 0
for i in range(n):
	A,B = map(str,input().split())
	if A>B:
		a += 3
	elif B>A:
		b += 3
	else:
		a += 1
		b += 1
print('%d %d'.(a,b))


Fixed submission:
n = int(input())
a = 0
b = 0
for i in range(n):
	A,B = map(str,input().split())
	if A>B:
		a += 3
	elif B>A:
		b += 3
	else:
		a += 1
		b += 1
print('%d %d' % (a,b))
Buggy python submission (verdict: Runtime Error):
for _ in [0]*int(input()):
    a,d,b,e,c,f=map(float,input().split())
    z=2*(b*f-c*e+c*d-a*f+a*e-b*d)
    x=((e-f)*(a**2+d**2)+(f-d)*(b**2+e**2)+(d-e)*(c**2+f**2))/z
    y=((c-b)*(a**2+d**2)+(a-c)*(b**2+e**2)+(b-a)*(c**2+f**2))/z
    print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,((a-x)**2+(d-y)**2)**0.5))

Fixed submission:
for _ in range(int(input())):
    a,d,b,e,c,f=map(float,input().split())
    z=2*(b*f-c*e+c*d-a*f+a*e-b*d)
    x=((e-f)*(a**2+d**2)+(f-d)*(b**2+e**2)+(d-e)*(c**2+f**2))/z
    y=((c-b)*(a**2+d**2)+(a-c)*(b**2+e**2)+(b-a)*(c**2+f**2))/z
    print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,((a-x)**2+(d-y)**2)**0.5))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
for i in range(1,len(A)+1):
    print(*A)
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key :
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
for i in range(1,len(A)):
    print(*A)
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key :
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key
print(*A)
Buggy python submission (verdict: Runtime Error):
Dice1 = list(input().split())
Dice2 = list(input().split())
a = list
b = 1

for q in range(3):
    if Dice1[q] == Dice2[q]:
        a[q] = 1
    else :
        a[q] = -1

for q in range(3):
    b = b*a[q]

if b == 1 :
    print("Yes")
elif b == -1 :
    print("No")

Fixed submission:
class Dice:
    same_dice_index = ('123456', '135246', '142536', '154326',
                       '214365', '231645', '246135', '263415',
                       '312564', '326154', '351624', '365214',
                       '415263', '421653', '456123', '462513',
                       '513462', '536142', '541632', '564312',
                       '624351', '632541', '645231', '653421')
 
    def __init__(self, num_list):
        self.faces = num_list
 
    def is_same(self, dice):
        for i in Dice.same_dice_index:
            example_faces = []
            for j in i:
                example_faces.append(self.faces[int(j) - 1])
            if example_faces == dice.faces:
                return 'Yes'
        return 'No'
 
num_list1 = list(map(int, input().split()))
num_list2 = list(map(int, input().split()))
 
dice1 = Dice(num_list1)
dice2 = Dice(num_list2)
 
ans = dice1.is_same(dice2)
 
print(ans)
Buggy python submission (verdict: Runtime Error):
x = map(input(),int)
print(x**3)

Fixed submission:
x = int(input())
print("{}".format(x**3))
Buggy python submission (verdict: Runtime Error):
x = int(input())
y = int(input())
print(x*y,2*(x+y))

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

Buggy python submission (verdict: Runtime Error):
while True:
    h, w = map (int,input().split(" "))
    if h == w == 0 : break
    for y in range(h):
        print(''.join('#.'[(x+y) %2] for x in range(w)))
    print("")

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

Buggy python submission (verdict: Runtime Error):
x, y = int(input().split)
print("{} {}".format(x*y,2*(x+y)))

Fixed submission:
x, y = map(int,input().split(" "))
print(x*y, 2*(x+y))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from sys import math

def GCD(a,b):
    if(a%b==0):
        return b
    else:
        c = a%b
        return GCD(b,c)

def LCM(a,b):
    gcd = GCD(a,b)
    return a*b/gcd

for line in stdin:
    a,b = line.split(" ")
    a = int(a)
    b = int(b)
    gcd = GCD(a,b)
    lcm = math.floor(LCM(a,b))

    print(str(gcd)+" "+str(lcm))
    print()



Fixed submission:
from sys import stdin
import math

def GCD(a,b):
    if(a%b==0):
        return b
    else:
        c = a%b
        return GCD(b,c)

def LCM(a,b):
    gcd = GCD(a,b)
    return int(a*b/gcd)

for line in stdin:
    a,b = line.split(" ")
    a = int(a)
    b = int(b)
    gcd = GCD(a,b)
    lcm = LCM(a,b)

    print(str(gcd)+" "+str(lcm))
Buggy python submission (verdict: Runtime Error):
data = int(input().split())
S = data[0]*data[1]
L = 2*(data[0]+data[1])
print(S, L)

Fixed submission:
a, b = list(map(int, input().split()))  
print(a * b, 2 * (a + b))

Buggy python submission (verdict: Runtime Error):
data = int(input().split())
S = data[0]*data[1]
L = 2*(data[0]+data[1])
print(int(S, L))

Fixed submission:
a, b = list(map(int, input().split()))  
print(a * b, 2 * (a + b))
Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split()))
sort(a, b ,c)
print(a, b, c)

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

num.sort()
print(num[0], num[1], num[2])

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

sort(a[0], a[2])
print(a[0], a[1], a[2])

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

num.sort()
print(num[0], num[1], num[2])

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

num.sort()
print(a[0], a[1], a[2])

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

num.sort()
print(num[0], num[1], num[2])
Buggy python submission (verdict: Runtime Error):
W, H, x, y, r = list(map(int, input().split()))

if x >= r and x <= (W - r):
    if y >= r and y <= (H - r):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Fixed submission:
W, H, x, y, r = list(map(int, input().split()))

if x >= r and x <= (W - r):
    if y >= r and y <= (H - r):
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
i=list(map(int,input().split(" ")))
print("{0} {1} {2:0.5f}".format(i[0]//i[1],i[0]%i[1],float(i[0])/float(i[1]))

Fixed submission:
i=list(map(int,input().split(" ")))
print("{0} {1} {2:0.5f}".format(i[0]//i[1],i[0]%i[1],float(i[0])/float(i[1])))
Buggy python submission (verdict: Runtime Error):
import math
r = int(input())
print("{0} {1}".format(r**2*math.pi,2*math.pi*r))

Fixed submission:
import math
r = float(input())
print("{0} {1}".format(r**2*math.pi,2*math.pi*r))

Buggy python submission (verdict: Runtime Error):
Pi = 3.14159265
R = int(input())
M = 2 * R * Pi
E = R ** 2 * Pi 
print("{:.10}".format(M))
print("{:.10}".format(E))


Fixed submission:
import math

r = float(input())
print("{} {}".format(r ** 2 * math.pi, r * 2 * math.pi))

Buggy python submission (verdict: Runtime Error):
Pi = 3.14159265
R = int(input())
M = 2 * R * Pi
E = R ** 2 * Pi
"""
print("{:.10}".format(M))
print("{:.10}".format(E))
"""
print(M)
print(E)


Fixed submission:
import math

r = float(input())
print("{} {}".format(r ** 2 * math.pi, r * 2 * math.pi))

Buggy python submission (verdict: Runtime Error):
Pi = 3.14159265
R = int(input())
M = 2 * R * Pi
E = R ** 2 * Pi
"""
print("{:.10}".format(M))
print("{:.10}".format(E))
"""
print(M)
print(E)


Fixed submission:
import math

r = float(input())
print("{} {}".format(r ** 2 * math.pi, r * 2 * math.pi))

Buggy python submission (verdict: Runtime Error):
r = int(input())
pi = 3.141592653589
S = r * r * pi
L = 2 * r * pi
print(str(S) + " " + str(L))

Fixed submission:
import math
pi = math.pi
r = float(input())
S = r * r * pi
L = 2 * r * pi
print("{0:.6f}".format(S) + " " + "{0:.6f}".format(L))
Buggy python submission (verdict: Runtime Error):
for i in range(1, 10):
    for j in range(1, 10):
        print str(i) + "??" + str(j) + "=" + str(i * j)

Fixed submission:
for i in range(1, 10):
    for j in range(1, 10):
        print str(i) + "x" + str(j) + "=" + str(i * j)
Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, input().split())
if x == y:
    print(x)
else:
    for i in range(1, abs(x-y)+1):
        if x % i == y % i == 0:
            j = i
    print(j)

Fixed submission:
a,b=map(int,input().split())
while b:
 a,b=b,a%b
print(a)
Buggy python submission (verdict: Runtime Error):
import sys
input()
a,b=-1e11,1e11
for i in map(int,sys.stdin.readlines()):
  a=max(a,i-b)
  b=min(i,b)
print(mar)

Fixed submission:
import sys
input()
a,b=-1e11,1e11
for i in map(int,sys.stdin.readlines()):
  a=max(a,i-b)
  b=min(i,b)
print(a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = input().split()
bub, sel = [lst]*2
sls = []
for i in range(n):
    m = i
    li = lst[i][0]
    if not li in sls:
        sls.append(li)
    for j in range(n-1,i,-1):
        if bub[j] < bub[j-1]:
            bub[j-1:j+1] = bub[j], bub[j-1]
    for k in range(i, n):
        if sel[k][1] < sel[k][1]:
            m = k
    if m != i:
        sel[i], sel[m] = sel[m], sel[i]

def stable(sort):
    s = 0
    for i in range(1,n):
        if sort[i][1] == sort[i-1][1] & sls.index(sort[i][0]) < sls.index(sort[i-1][0]):
            s += 1
    print('Not stable' if s else 'Stable')
    
print(*bub)
stable(bub)
print(*sel)
stable(sel)

Fixed submission:
n = int(input())
lst = input().split()
bub, sel = lst[:], lst[:]
def stable(sls):
    s, i = 1, n-1
    while s*i:
        if sls[i][1] == sls[i-1][1]:
            if lst.index(sls[i]) < lst.index(sls[i-1]) :
                s = 0
        i -= 1
    print('Stable' if s else 'Not stable')

for i in range(n):
    m = i
    for j in range(n-1,i,-1):
        if bub[j][1] < bub[j-1][1]:
            bub[j-1:j+1] = bub[j], bub[j-1]
    for k in range(i, n):
        if sel[k][1] < sel[m][1]:
            m = k
    if m != i:
        sel[i], sel[m] = sel[m], sel[i]

print(*bub)
stable(bub)
print(*sel)
stable(sel)
Buggy python submission (verdict: Runtime Error):
def insertion_sort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i-g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j -= g
            ct += 1
        a[j+g] = v
    return ct

def interval_list(n):
    m = 0
    gi= 1
    g = []
    while b <= n:
        m += 1
        g.append(gi)
        b = 4**m + 3 * 2**(m-1) + 1
        # shell_sort ???????????¨????????????????????????????????\?????????URL
        # http://www.programming-magic.com/20100507074241/
    return g.reverse()

if __name__ == "__main__":
    n = int(input())
    A = list(int(input()) for _ in range(n))
    G = interval_list(n)
    print(len(G))
    print(*G)
    
    ct= 0
    for i in G:
        ct += insertion_sort(A, n, i)
    print(ct)
    print(*A, sep="\n")

Fixed submission:
def insertion_sort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i-g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j -= g
            ct += 1
        a[j+g] = v
    return ct

def interval_list(n):
    m = 0
    gi= 1
    g = []
    while gi <= n:
        m += 1
        g.append(gi)
        gi = 4**m + 3 * 2**(m-1) + 1
        # good convergence
        # http://www.programming-magic.com/20100507074241/
    g.reverse()
    return g


if __name__ == "__main__":
    n = int(input())
    A = list(int(input()) for _ in range(n))
    G = interval_list(n)
    print(len(G))
    print(*G)
    
    ct= 0
    for i in G:
        ct += insertion_sort(A, n, i)
    print(ct)
    print(*A, sep="\n")

Buggy python submission (verdict: Runtime Error):
def insertion_sort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i-g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j -= g
            ct += 1
        a[j+g] = v
    return ct

def interval_list(n):
    m = 0
    gi= 1
    g = []
    while b <= n:
        m += 1
        g.append(gi)
        b = 4**m + 3 * 2**(m-1) + 1
    return g.reverse()

if __name__ == "__main__":
    n = int(input())
    A = list(int(input()) for _ in range(n))
    G = interval_list(n)
    print(len(G))
    print(*G)
    
    ct= 0
    for i in G:
        ct += insertion_sort(A, n, i)
    print(ct)
    print(*A, sep="\n")

Fixed submission:
def insertion_sort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i-g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j -= g
            ct += 1
        a[j+g] = v
    return ct

def interval_list(n):
    m = 0
    gi= 1
    g = []
    while gi <= n:
        m += 1
        g.append(gi)
        gi = 4**m + 3 * 2**(m-1) + 1
        # good convergence
        # http://www.programming-magic.com/20100507074241/
    g.reverse()
    return g


if __name__ == "__main__":
    n = int(input())
    A = list(int(input()) for _ in range(n))
    G = interval_list(n)
    print(len(G))
    print(*G)
    
    ct= 0
    for i in G:
        ct += insertion_sort(A, n, i)
    print(ct)
    print(*A, sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
p = []
t = i = 0
for i in range(n):
    c = input().split()
    c[1] = int(c[1])
    p.append(c)
left = n
while left:
    i = (i+1) % n
    if p[i][1] == 0:
        continue
    if p[i][1] <= q:
        t += p[i][1]
        p[i][1] = 0
        print(p[i][0], t)
        left -= 1
    else:
        p[i][1] -= q
        t += q

Fixed submission:
n, q = map(int, input().split())
p = [input().split() for _ in range(n)]
t = i = 0
while n:
    i = i % n
    if int(p[i][1]) <= q:
        t += int(p[i][1])
        print(p[i][0], t)
        del p[i]
        n -= 1
    else:
        p[i][1] = int(p[i][1]) - q
        t += q
        i += 1

Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
p = [input().split() for _ in range(n)]
t = i = 0
while n:
    i = i % n
    if int(p[i][1]) <= q:
        t += int(p[i][1])
        print(p[i][0], t)
        del p[i]
        n -= 1
    else:
        p[i][1] -= int(p[i][1]) - q
        t += q
        i += 1

Fixed submission:
n, q = map(int, input().split())
p = [input().split() for _ in range(n)]
t = i = 0
while n:
    i = i % n
    if int(p[i][1]) <= q:
        t += int(p[i][1])
        print(p[i][0], t)
        del p[i]
        n -= 1
    else:
        p[i][1] = int(p[i][1]) - q
        t += q
        i += 1
Buggy python submission (verdict: Runtime Error):
l = []
n = int(input())
for _ in range(n):
    c, *i = input().split()
    if c == 'insert':
        l = [*i, *l]
    elif c == 'delete':
        l.remove(*i)
    elif c == 'deleteFirst':
        del l[0]
    elif c == 'deleteLast':
        del l[len(l)-1]
    else:
        pass

Fixed submission:
from collections import deque
n = int(input())
q = deque()
for i in range(n):
    c = input()
    if c[0] == 'i':
        q.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            q.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        q.popleft()
    else:
        q.pop()
print(*q)

Buggy python submission (verdict: Runtime Error):
l = []
n = int(input())
for _ in range(n):
    c, *i = input().split()
    if c == 'insert':
        l = [*i, *l]
    elif c == 'delete':
        l.remove(*i)
    elif c == 'deleteFirst':
        del l[0]
    elif c == 'deleteLast':
        del l[len(l)-1]
    else:
        pass
print(*l)

Fixed submission:
from collections import deque
n = int(input())
q = deque()
for i in range(n):
    c = input()
    if c[0] == 'i':
        q.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            q.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        q.popleft()
    else:
        q.pop()
print(*q)

Buggy python submission (verdict: Runtime Error):
l = []
n = int(input())
for _ in range(n):
    c, *i = input().split()
    if c == 'insert':
        l = [*i, *l]
    elif c == 'delete':
        l.remove(*i)
    elif c == 'deleteFirst':
        del l[0]
    elif c == 'deleteLast':
        del l[len(l)-1]
    else:
        pass
print(*l)

Fixed submission:
from collections import deque
n = int(input())
q = deque()
for i in range(n):
    c = input()
    if c[0] == 'i':
        q.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            q.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        q.popleft()
    else:
        q.pop()
print(*q)

Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
n = int(sys.stdin.readline())
q = deque()
for i in range(n):
    c = sys.stdin.readline()[:-1]
    if c[0] == 'i':
        q.appendleft(c[7:])
    elif c[6] == ' ':
        q.remove(c[7:])
    elif c[6] == 'F':
        q.popleft()
    else:
        q.pop()
print(*q)

Fixed submission:
from collections import deque
n = int(input())
q = deque()
for i in range(n):
    c = input()
    if c[0] == 'i':
        q.appendleft(c[7:])
    elif c[6] == ' ':
        try:
            q.remove(c[7:])
        except:
            pass
    elif c[6] == 'F':
        q.popleft()
    else:
        q.pop()
print(*q)
Buggy python submission (verdict: Runtime Error):
input()
s = set(map(int,input().split()))
n = int(input())
t = set(map(int,input().split()))
c = 0
for i in range(n):
    if t[i] in s:
        c += 1
print(c)

Fixed submission:
input()
s = set(map(int,input().split()))
n = int(input())
t = tuple(map(int,input().split()))
c = 0
for i in range(n):
    if t[i] in s:
        c += 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = set()
for i in range(n):
    c = input()
    if c[0] == 'i':
        d = d|{c[7:]}
    else:
        if c[5:] in d:
            print('yes')
        else:
            print('no')

Fixed submission:
import sys
input()
r = sys.stdin.readlines()
d = {}

for i in r:
    if i[0] == 'i':
        d[i[7:]] = 0
    else:
        if i[5:] in d:
            print('yes')
        else:
            print('no')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
d = set()
for i in range(n):
    c = sys.stdin.readline()
    if c[0] == 'i':
        d = d|{c[7:]}
    else:
        if c[5:] in d:
            print('yes')
        else:
            print('no')

Fixed submission:
import sys
input()
r = sys.stdin.readlines()
d = {}

for i in r:
    if i[0] == 'i':
        d[i[7:]] = 0
    else:
        if i[5:] in d:
            print('yes')
        else:
            print('no')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
d = []
for i in range(n):
    c = sys.stdin.readline()
    if c[0] == 'i':
        d.append(c[7:])
    else:
        if c[5:] in d:
            print('yes')
        else:
            print('no')

Fixed submission:
import sys
input()
r = sys.stdin.readlines()
d = {}

for i in r:
    if i[0] == 'i':
        d[i[7:]] = 0
    else:
        if i[5:] in d:
            print('yes')
        else:
            print('no')
Buggy python submission (verdict: Runtime Error):
import sys
n, k = map(int, input().split())
w = tuple(map(int, sys.stdin.readlines()))
w = tuple(map(int, input().split()))
p = max(w)
s = sum(w)
if n <= k:
    print(p)
elif k == 1:
    print(s)
else:
    a = max(p, s//k)
    while True:
        l = [a]
        for i in range(n):
            d = l[-1] - w[i]
            if d < 0:
                l.append(a-w[i])
            else:
                l[-1] = d
            i += 1
        if len(l) > k:
            a += 1
        else:
            break
    print(a)

Fixed submission:
n,k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True

s = max(w)
l = sum(w)
while s < l:
    m = (s+l)//2
    if check(m):
        l = m
    else:
        s = m = m+1
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, k = map(int, input().split())
w = tuple(map(int, sys.stdin.readlines()))
p = max(w)
s = sum(w)
if n <= k:
    print(p)
elif k == 1:
    print(s)
else:
    a = max(p, s//k)
    while True:
        l = [a]
        for i in range(n):
            d = l[-1] - w[i]
            if d < 0:
                l.append(a-w[i])
            else:
                l[-1] = d
            i += 1
        if len(l) > k:
            a += 1
        else:
            break
    print(a)

Fixed submission:
n,k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True

s = max(w)
l = sum(w)
while s < l:
    m = (s+l)//2
    if check(m):
        l = m
    else:
        s = m = m+1
print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
input()
m = [int(input()) for _ in range(n)]

aa = [0 for _ in range(n**2)]
for i in range(n):
    t = 2**i
    for j in range(n**2):
        if (j//t)%2:
            aa[j] += a[i]
aa = set(aa)

for k in m:
    if k in aa:
        print('yes')
    else:
        print('no')

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

n2 = 2**n
aa = [0 for _ in range(n2)]
for i in range(n):
    t = 2**i
    for j in range(n2):
        if (j//t)%2:
            aa[j] += a[i]

for k in m:
    if k in aa:
        print('yes')
    else:
        print('no')