Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))

x = [-float('inf')] * (n + 1)
x[0] = 0
l = [0] * (n + 1)
_c = [2,5,5,4,5,6,3,7,6]
c = dict()
for i in range(m):
    c[a[i]] = _c[a[i] - 1]
# print(c)

for i in range(1, n + 1):
    tmp_xl = []
    for digit in c.keys():
        left = i - c[digit]
        if left >= 0:
            tmp_xl.append([digit * (10 ** l[left]) + x[left], l[left] + 1])

    if len(tmp_xl):
        tmp_xl = sorted(tmp_xl, key=lambda x:x[0])
        x[i] = tmp_xl[-1][0]
        l[i] = tmp_xl[-1][1]
print(x[-1])


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

x = [-float('inf')] * (n + 1)
x[0] = 0
l = [0] * (n + 1)
_c = [2,5,5,4,5,6,3,7,6]
c = dict()
for i in range(m):
    c[a[i]] = _c[a[i] - 1]

for i in range(1, n + 1):
    x_max = -float('inf')
    l_max = 0
    for digit in c.keys():
        left = i - c[digit]
        if left >= 0:
            tmp_x = digit * (10 ** l[left]) + x[left]
            tmp_l = l[left] + 1
            if tmp_x > x_max:
                x_max = tmp_x
                l_max = tmp_l

    x[i] = x_max
    l[i] = l_max
print(x[-1])

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

x = [-float('inf')] * (n + 1)
x[0] = 0
l = [0] * (n + 1)
_c = [2,5,5,4,5,6,3,7,6]
c = dict()
for i in range(m):
    c[a[i]] = _c[a[i] - 1]
# print(c)

for i in range(1, n + 1):
    tmp_xl = []
    for digit in c.keys():
        left = i - c[digit]
        if left >= 0:
            tmp_xl.append([digit * (10 ** l[left]) + x[left], l[left] + 1])

    if len(tmp_xl):
        tmp_xl = sorted(tmp_xl, key=lambda x:x[0])
        x[i] = tmp_xl[-1][0]
        l[i] = tmp_xl[-1][1]
print(x[-1])


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

x = [-float('inf')] * (n + 1)
x[0] = 0
l = [0] * (n + 1)
_c = [2,5,5,4,5,6,3,7,6]
c = dict()
for i in range(m):
    c[a[i]] = _c[a[i] - 1]

for i in range(1, n + 1):
    x_max = -float('inf')
    l_max = 0
    for digit in c.keys():
        left = i - c[digit]
        if left >= 0:
            tmp_x = digit * (10 ** l[left]) + x[left]
            tmp_l = l[left] + 1
            if tmp_x > x_max:
                x_max = tmp_x
                l_max = tmp_l

    x[i] = x_max
    l[i] = l_max
print(x[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n, m = list(map(int, input().split()))
py = np.array([list(map(int, input().split())) for _ in range(m)])

py = np.array(py)
order = np.argsort(py[:, 1])
argsorted = py[order]

count_below_same_class = []
visited = dict()
visited_keys = []
for i in range(m):
    p = argsorted[i, 0]
    if p not in visited_keys:
        count_below_same_class.append(0)
        visited[p] = 0
        visited_keys.append(p)
    else:
        count_below_same_class.append(visited[p] + 1)
        visited[p] += 1

inv_order = np.argsort(order)

for i in range(m):
    first = str(py[i, 0]).zfill(6)
    second = str(count_below_same_class[inv_order[i]] + 1).zfill(6)
    print(first + second)


Fixed submission:
n, m = map(int, input().split())
pd = [list(map(int, input().split())) for _ in range(m)]

from collections import defaultdict
dict = defaultdict(list)
for i, (p, d) in enumerate(pd):
    dict[p].append((d, i))

ans = ['' for _ in range(m)]
for key in dict:
    v = dict[key]
    v.sort()

    for i, (y, idx) in enumerate(v):
        tmp = str(key).zfill(6) + str(i + 1).zfill(6)
        ans[idx] = tmp

for a in ans:
    print(a)

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

n, m = list(map(int, input().split()))
py = np.array([list(map(int, input().split())) for _ in range(m)])

py = np.array(py)
order = np.argsort(py[:, 1])
argsorted = py[order]

count_below_same_class = []
visited = dict()
visited_keys = []
for i in range(m):
    p = argsorted[i, 0]
    if p not in visited_keys:
        count_below_same_class.append(0)
        visited[p] = 0
        visited_keys.append(p)
    else:
        count_below_same_class.append(visited[p] + 1)
        visited[p] += 1

inv_order = np.argsort(order)

for i in range(m):
    first = str(py[i, 0]).zfill(6)
    second = str(count_below_same_class[inv_order[i]] + 1).zfill(6)
    print(first + second)


Fixed submission:
n, m = map(int, input().split())
pd = [list(map(int, input().split())) for _ in range(m)]

from collections import defaultdict
dict = defaultdict(list)
for i, (p, d) in enumerate(pd):
    dict[p].append((d, i))

ans = ['' for _ in range(m)]
for key in dict:
    v = dict[key]
    v.sort()

    for i, (y, idx) in enumerate(v):
        tmp = str(key).zfill(6) + str(i + 1).zfill(6)
        ans[idx] = tmp

for a in ans:
    print(a)
Buggy python submission (verdict: Runtime Error):
n, a = map(int, input().split())
x = list(map(int, input().split()))

x.append(a)
x.sort()

diff_all = []
for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import fraction
from functools import reduce

def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)

print(gcd_list(diff_all))


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

x.append(a)
x.sort()

diff_all = []
for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd_list(diff_all))

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

x.append(X)
x.sort()

diff_all = []
for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(diff_all))


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

x.append(a)
x.sort()

diff_all = []
for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd_list(diff_all))

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

diff_all = []
x.append(X)
x.sort()

for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
print(gcd_list(diff_all))


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

x.append(a)
x.sort()

diff_all = []
for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd_list(diff_all))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = list(map(int, input().split()))

neg_x = []
for i in range(n):
    if x[i] < 0:
        neg_x.append(x[i])
    if x[i] >= 0:
        break
pos_x = x[len(neg_x):]
neg_x = neg_x[::-1]

if len(neg_x) == 0:
    print(pos_x[k - 1])
elif len(pos_x) == 0:
    print(-1 * neg_x[k - 1])
else:
    total_all = []
    for i in range(max(0, k - len(pos_x)), min(k, len(neg_x))):
        if i == 0:
            total1 = 0
        else:
            total1 = -1 * neg_x[i - 1]
        if k - i == 0:
            total2 = 0
        else:
            total2 = pos_x[k - i - 1]
        total = min(total1 * 2 + total2, total2 * 2 + total1)
        total_all.append(total)
    print(min(total_all))


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

x_neg = []
x_pos = []
for xx in x:
    if xx < 0:
        x_neg.append(-xx)
    else:
        x_pos.append(xx)
x_neg = x_neg[::-1]

ans = float('inf')
if k <= len(x_neg):
    ans = min(ans, x_neg[k-1])
if k <= len(x_pos):
    ans = min(ans, x_pos[k-1])

for i in range(1, k):
    j = k - i
    if i <= len(x_pos) and 1 <= j <= len(x_neg):
        d1 = x_pos[i - 1]
        d2 = x_neg[j - 1]
        d = min(d1, d2) * 2 + max(d1, d2)
        ans = min(ans, d)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

while True:
    if s[0] == '1':
        s = s[1:]
    elif s[0] != '1':
        ans = s[0]
        break
    if s == []:
        ans = 1
        break
print(ans)


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

if s[0] != '1':
    print(s[0])
else:
    len_1 = 0
    while True:
        if s == '1':
            len_1 = 1
            ans = 1
            break
        if s[0] == '1':
            s = s[1:]
            len_1 += 1
        elif s[0] != '1':
            ans = s[0]
            break
    if k > len_1:
        print(ans)
    else:
        print('1')

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

i = 0
while True:
    if s[i] == '1':
        i += 1
    elif s[i] != '1':
        ans = s[i]
        break
print(ans)


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

if s[0] != '1':
    print(s[0])
else:
    len_1 = 0
    while True:
        if s == '1':
            len_1 = 1
            ans = 1
            break
        if s[0] == '1':
            s = s[1:]
            len_1 += 1
        elif s[0] != '1':
            ans = s[0]
            break
    if k > len_1:
        print(ans)
    else:
        print('1')
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]


import numpy as np
y = np.array(x)

y1 = np.copy(y)
y1[:, 0] = y1[:, 0] * -1

y2 = np.copy(y)
y2[:, 0] = y2[:, 0] * -1
y2[:, 1] = y2[:, 1] * -1

y3 = np.copy(y)
y3[:, 0] = y3[:, 0] * -1
y3[:, 1] = y3[:, 1] * -1
y3[:, 2] = y3[:, 2] * -1

y4 = np.copy(y)
y4[:, 1] = y4[:, 1] * -1

y5 = np.copy(y)
y5[:, 1] = y5[:, 1] * -1
y5[:, 2] = y5[:, 2] * -1

y6 = np.copy(y)
y6[:, 2] = y6[:, 2] * -1

y7 = np.copy(y)
y7[:, 0] = y7[:, 0] * -1
y7[:, 2] = y7[:, 2] * -1


print(np.max([np.sum(np.sort(np.sum(y, axis=1))[-1 * M:]),
             np.sum(np.sort(np.sum(y1, axis=1))[-1 * M:]),
             np.sum(np.sort(np.sum(y2, axis=1))[-1 * M:]),
             np.sum(np.sort(np.sum(y3, axis=1))[-1 * M:]),
             np.sum(np.sort(np.sum(y4, axis=1))[-1 * M:]),
             np.sum(np.sort(np.sum(y5, axis=1))[-1 * M:]),
             np.sum(np.sort(np.sum(y6, axis=1))[-1 * M:]),
             np.sum(np.sort(np.sum(y7, axis=1))[-1 * M:])]))


Fixed submission:
N, M = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]


import numpy as np
y = np.array(x)

y1 = np.copy(y)
y1[:, 0] = y1[:, 0] * -1

y2 = np.copy(y)
y2[:, 0] = y2[:, 0] * -1
y2[:, 1] = y2[:, 1] * -1

y3 = np.copy(y)
y3[:, 0] = y3[:, 0] * -1
y3[:, 1] = y3[:, 1] * -1
y3[:, 2] = y3[:, 2] * -1

y4 = np.copy(y)
y4[:, 1] = y4[:, 1] * -1

y5 = np.copy(y)
y5[:, 1] = y5[:, 1] * -1
y5[:, 2] = y5[:, 2] * -1

y6 = np.copy(y)
y6[:, 2] = y6[:, 2] * -1

y7 = np.copy(y)
y7[:, 0] = y7[:, 0] * -1
y7[:, 2] = y7[:, 2] * -1

if M != 0:
    print(np.max([np.sum(np.sort(np.sum(y, axis=1))[-1 * M:]),
                 np.sum(np.sort(np.sum(y1, axis=1))[-1 * M:]),
                 np.sum(np.sort(np.sum(y2, axis=1))[-1 * M:]),
                 np.sum(np.sort(np.sum(y3, axis=1))[-1 * M:]),
                 np.sum(np.sort(np.sum(y4, axis=1))[-1 * M:]),
                 np.sum(np.sort(np.sum(y5, axis=1))[-1 * M:]),
                 np.sum(np.sort(np.sum(y6, axis=1))[-1 * M:]),
                 np.sum(np.sort(np.sum(y7, axis=1))[-1 * M:])]))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

if __name__ == '__main__':
    n = int(stdin.readline().rstrip())
    a = list(map(int, stdin.readline().rstrip().split()))

    l = len(bin(max(a))[2:])

    cumsums = [[0] for _ in range(l)]
    for aa in a:
        for j in range(l):
            if aa & (1 << j):
                cumsums[j].append(cumsums[j][-1] + 1)
            else:
                cumsums[j].append(cumsums[j][-1])

    ans = 0
    from bisect import bisect_left
    for i in range(1, n+1):
        left = 0
        for j in range(l):
            idx = bisect_left(cumsums[j], cumsums[j][i] - 1)
            left = max(left, idx)
        ans += i - left
    print(ans)


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

l = len(bin(max(a))[2:])

cumsums = [[0] for _ in range(l)]
for i in range(n):
    for j in range(l):
        if a[i] & (1 << j):
            cumsums[j].append(cumsums[j][-1] + 1)
        else:
            cumsums[j].append(cumsums[j][-1])

ans = 0
left = 0
for i in range(1, n+1):
    while left < i:
        f = True
        for j in range(l):
            if cumsums[j][left] < cumsums[j][i] - 1:
                f = False

        if f:
            break
        else:
            left += 1

    ans += i - left
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

l = len(bin(max(a))[2:])

cumsums = [[0] for _ in range(l)]
for i in range(n):
    for j in range(l):
        if a[i] & (1 << j):
            cumsums[j].append(cumsums[j][-1] + 1)
        else:
            cumsums[j].append(cumsums[j][-1])

ans = 0
from bisect import bisect_left
for i in range(1, n+1):
    left = 0
    for j in range(l):
        idx = bisect_left(cumsums[j], cumsums[j][i] - 1)
        left = max(left, idx)
    ans += i - left
print(ans)


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

l = len(bin(max(a))[2:])

cumsums = [[0] for _ in range(l)]
for i in range(n):
    for j in range(l):
        if a[i] & (1 << j):
            cumsums[j].append(cumsums[j][-1] + 1)
        else:
            cumsums[j].append(cumsums[j][-1])

ans = 0
left = 0
for i in range(1, n+1):
    while left < i:
        f = True
        for j in range(l):
            if cumsums[j][left] < cumsums[j][i] - 1:
                f = False

        if f:
            break
        else:
            left += 1

    ans += i - left
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

a.append(0)
a.insert(0, 0)

for i in range(1, n+1):
    total = 0
    for j in range(1, n+2):
        if j == i + 1:
            total += abs(a[j] - a[j-2])
        elif j != i:
            total += abs(a[j] - a[j-1])
    print(total)

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

a.insert(0, 0)
a.append(0)

total_tmp = 0
for i in range(1, n+2):
    total_tmp += abs(a[i] - a[i-1])

for i in range(1, n+1):
    # delete the i-th spot
    total = total_tmp - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1])
    print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

import numpy as np
a = np.array(a)

for i in range(n):
    a_new = np.delete(a, i)
    a_new = np.insert(a_new, 0, 0)
    a_new = np.append(a_new, 0)
    print(np.sum(np.abs(np.diff(a_new))))


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

a.insert(0, 0)
a.append(0)

total_tmp = 0
for i in range(1, n+2):
    total_tmp += abs(a[i] - a[i-1])

for i in range(1, n+1):
    # delete the i-th spot
    total = total_tmp - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1])
    print(total)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

counter = 0
for a in range(A + 1):
  for b in range(B + 1):
    for c in range(C + 1):
      if X == a * 500 + b * 100 + c * 50:
        counter += 1
print(counter)

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

print((x - a) % b)
Buggy python submission (verdict: Runtime Error):
n,y = map(int,input().split())
total = 0
for i in range(n+1):
	for j in range(n+1-i):
		k = n - i - j
		total = i*10000 + j*5000 + k*1000
		if total == y:
			print(i,j,k)
			break
		total = 0
	else:
		continue
	break
else:
	print("-1 -1 -1")

Fixed submission:
s = list(input())

s[3] = '8'
print(''.join(s))
Buggy python submission (verdict: Runtime Error):
n, h = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

a_all = [_ab[0] for _ab in ab]
b_all = [_ab[1] for _ab in ab]

a_max = max(a_all)

b_all_useful = []
for b in b_all:
    if b > a_max:
        b_all_useful.append(b)

b_all_useful.sort()

useful_sum = sum(b_all_useful)
if useful_sum > h:
    counter = 0
    i = 0
    while True:
        counter += b_all_useful[-1 * ii]
        i += 1
        if counter >= h:
            break
    print(i)

else:
    h_new = h - useful_sum
    import math
    print(math.ceil(h_new / a_max) + len(b_all_useful))


Fixed submission:
n, h = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

a_all = [_ab[0] for _ab in ab]
b_all = [_ab[1] for _ab in ab]

a_max = max(a_all)

b_all_useful = []
for b in b_all:
    if b > a_max:
        b_all_useful.append(b)

b_all_useful.sort()

useful_sum = sum(b_all_useful)
if useful_sum > h:
    counter = 0
    i = 0
    while True:
        counter += b_all_useful[-1 * (i + 1)]
        i += 1
        if counter >= h:
            break
    print(i)

else:
    h_new = h - useful_sum
    import math
    print(math.ceil(h_new / a_max) + len(b_all_useful))
Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

n = 10 ** 5
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

like_numbers = []
for prime in primes:
    if int((prime + 1) / 2) in primes:
        like_numbers.append(prime)

for i in range(q):
    l = lr[i][0]
    r = lr[i][1]
    print(sum((x >= l and x <= r) for x in like_numbers))


Fixed submission:
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

n = 10 ** 5
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

like_numbers = []
for prime in primes:
    if int((prime + 1) / 2) in primes:
        like_numbers.append(prime)

for i in range(q):
    l = lr[i][0]
    r = lr[i][1]
    print(sum((x >= l and x <= r) for x in like_numbers))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

counter_remove = 0
counter = dict()
counter_keys = []
for i in range(n):
    if a[i] not in counter_keys:
        counter_keys.append(a[i])
        counter[str(a[i])] = 1
    else:
        if counter[str(a[i])] < a[i]:
            counter[str(a[i])] += 1
        else:
            counter_remove += 1

# remove small
for key in counter_keys:
    if counter[str(key)] < int(key):
        counter_remove += int(counter[str(key)])

print(counter_remove)


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

from collections import Counter

b = Counter(a)

counter = 0
for key in b.keys():
    if b[key] < key:
        counter += b[key]
    elif b[key] > key:
        counter += b[key] - key
print(counter)
Buggy python submission (verdict: Runtime Error):
N = input()
A = input().split()
A = [int(a) for a in A]

counter = 0
while sum([a % 2 for a in A]) == 0:
  A = [a / 2 for a in A]
  counter += 1
print(counter)

Fixed submission:
import numpy as np

a = str(input())
s1 = int(a[0])
s2 = int(a[1])
s3 = int(a[2])

print(np.sum(s1 + s2 + s3))
Buggy python submission (verdict: Runtime Error):
n = list(input().split())


for i in range(2 ** 3):
    i2 = bin(i)[2:].zfill(3)
    i3 = n[0]
    total = int(n[0])
    for j in range(3):
        if i2[j] == '1':
            # plus
            total += int(n[j+1])
            i3 += '+'
        else:
            # minus
            total -= int(n[j+1])
            i3 += '-'
        i3 += n[j+1]

    if total == 7:
        break

print(i3 + '=7')


Fixed submission:
n = input()

for i in range(2 ** 3):
    i2 = bin(i)[2:].zfill(3)
    i3 = n[0]
    total = int(n[0])
    for j in range(3):
        if i2[j] == '1':
            # plus
            total += int(n[j+1])
            i3 += '+'
        else:
            # minus
            total -= int(n[j+1])
            i3 += '-'
        i3 += n[j+1]

    if total == 7:
        break

print(i3 + '=7')
Buggy python submission (verdict: Runtime Error):
n, z, w = map(int, input().split())
a = list(map(int, input().split()))

score = []

# only X
score.append(abs(a[-1] - w))

if n > 1:
    # X -> Y
    score.append(abs(a[i] - a[-1]))

print(max(score))


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

score = []

# only X
score.append(abs(a[-1] - w))

if n > 1:
    # X -> Y
    score.append(abs(a[-2] - a[-1]))

print(max(score))
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

ans = []
max_conc = 0
for a in range(F // 100 + 1):
    left = F - 100 * a * A
    for b in range(left // 100 + 1):
        w = 100 * a * A + 100 * b * B

        s_max = min(F - w, w * E // 100)
        if s_max >= 0:
            for c in range(s_max // C + 1):
                d = (s_max - c * C) // D

                if d >= 0:
                    # suger
                    s = c * C + d * D
                    if s + w > 0:
                        conc = s / (s + w)
                        if conc > max_conc:
                            ans = [s, w]
                            max_conc = conc


print(str(ans[0] + ans[1]) + ' ' + str(ans[0]))


Fixed submission:
A, B, C, D, E, F = map(int, input().split())

ans = [0, 0]
max_conc = -1
for a in range(F // 100 + 1):
    left = F - 100 * a * A
    for b in range(left // 100 + 1):
        w = 100 * a * A + 100 * b * B

        s_max = min(F - w, w * E // 100)
        if s_max >= 0:
            for c in range(s_max // C + 1):
                d = (s_max - c * C) // D

                if d >= 0:
                    # suger
                    s = c * C + d * D
                    if s + w > 0:
                        conc = s / (s + w)
                        if conc > max_conc:
                            ans = [s, w]
                            max_conc = conc


print(str(ans[0] + ans[1]) + ' ' + str(ans[0]))

Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

ans = []
max_conc = 0
for a in range(F // 100 + 1):
    for b in range(F // 100 + 1):
        w = 100 * a * A + 100 * b * B

        s_max = min(F - w, w * E // 100)
        if s_max >= 0:
            for c in range(s_max // C + 1):
                d_max = (s_max - c * C) // D

                if d_max >= 0:
                    # suger
                    s = c * C + d_max * D
                    if s + w > 0:
                        conc = s / (s + w)
                        if conc > max_conc:
                            ans = [s, w]

print(str(ans[0] + ans[1]) + ' ' + str(ans[0]))


Fixed submission:
A, B, C, D, E, F = map(int, input().split())

ans = [0, 0]
max_conc = -1
for a in range(F // 100 + 1):
    left = F - 100 * a * A
    for b in range(left // 100 + 1):
        w = 100 * a * A + 100 * b * B

        s_max = min(F - w, w * E // 100)
        if s_max >= 0:
            for c in range(s_max // C + 1):
                d = (s_max - c * C) // D

                if d >= 0:
                    # suger
                    s = c * C + d * D
                    if s + w > 0:
                        conc = s / (s + w)
                        if conc > max_conc:
                            ans = [s, w]
                            max_conc = conc


print(str(ans[0] + ans[1]) + ' ' + str(ans[0]))