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

Fixed submission:
N,Y = map(int,input().split())
ct = {}
for i in range(N):
    temp = [int(i) for i in input().split()]
    if temp[1] > Y:
        pass
    else:
        ct[temp[0]] = temp[1]

if len(ct) > 0:
    ct = sorted(ct.items(),key=lambda x: x[0])
    print(ct[0][0])
else:
    print("TLE")

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
comp = []
for i in range(N):
    nt = [int(i) for i in input().split()]
    comp.append(nt)


cost = []
for i in range(N):
    if comp[i][1] <= T:
        temp = [comp[i][0],comp[i][1]]
        cost.append(temp)
cost = sorted(cost, key = lambda x:x[1])
print(cost[0][0])

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
comp = []
for i in range(N):
    nt = [int(i) for i in input().split()]
    comp.append(nt)


cost = []
for i in range(N):
    if comp[i][1] <= T:
        temp = [comp[i][0],comp[i][1]]
        cost.append(temp)
cost = sorted(cost, key = lambda x:x[1])
print(cost[0][0])

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
comp = []
for i in range(N):
    nt = [int(i) for i in input().split()]
    comp.append(nt)
print(comp)


cost = []
for i in range(N):
    if comp[i][1] <= T:
        temp = [comp[i][0],comp[i][1]]
        cost.append(temp)
cost = sorted(cost, key = lambda x:x[1])
print(cost[0][0])

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
comp = []
for i in range(N):
    nt = [int(i) for i in input().split()]
    comp.append(nt)



cost = []
for i in range(N):
    if comp[i][1] <= T:
        temp = [comp[i][0],comp[i][1]]
        cost.append(temp)
cost.sort()
print(cost[0][1])
Problem p03262 (python)

Fixed submission:
import functools
import fractions
N,X = map(int,input().split())
city = [int(c) for c in input().split()]
diff = []
for i in range(N):
    diff.append(city[i]-X)

gcd = functools.reduce(fractions.gcd,diff)
print(abs(gcd))

Buggy submission (verdict: Runtime Error):
import functools
import fractions
N,X = map(int,input().split())
city = [int(c) for c in input().split()]
diff = [diff.append(city[i]-X) for i in range(N)]
print(abs(functools.reduce(fractions.gcd,diff)))

Buggy submission (verdict: Runtime Error):
import functools
import math
N,X = map(int,input().split())
city = [int(c) for c in input().split()]
diff = []
for i in range(N):
    diff.append(city[i]-X)

gcd = functools.reduce(math.gcd,diff)
print(gcd)
Problem p03281 (python)

Fixed submission:
def div(num):
    counter = 0
    for i in range(num):
        if num % (i+1) == 0:
            counter += 1
    return counter
N = int(input())
sumcount = 0
for i in range(N):
    if div(i+1)==8:
        if (i+1) % 2 != 0:
            sumcount += 1
print(sumcount)

Buggy submission (verdict: Runtime Error):
import sympy
N = int(input())
sumcount = 0
for i in range(N):
    if sympy.divisor_count(i+1)==8:
        if (i+1) % 2 != 0:
            sumcount += 1
print(sumcount)
Problem p03282 (python)

Fixed submission:
import sys
S = list(input())
K = int(input())
S = [int(i) for i in S]
count = 0
for i in range(K):
    if S[i] is not 1:
        print(S[i])
        sys.exit()
    else:
        count+= 1
if count == K:
    print(1)

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())
S = [int(i) for i in S]
if K == 1:
    print(S[0])
else:
    print(S[1])

Buggy submission (verdict: Runtime Error):
S = input().split()
K = int(input())
S = [int(i) for i in S]
if S[0] == 1:
    print(S[1])
else:
    print(S[0])
Problem p03316 (python)

Fixed submission:
N = input()
n = int(N)
s = sum([int(i) for i in list(N)])
if n % s == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
vN = input()
n = int(N)
s = sum([int(i) for i in list(N)])
if n % s == 0:
    print("Yes")
else:
    print("No")
Problem p03427 (python)

Fixed submission:
N = int(input())

if N > 9:
    if (N%(int("1" + (len(str(N)) - 1)*"0"))) == int((len(str(N)) - 1) * "9"):
        tmp = list(str(N))
        tmp = [int(item) for item in tmp]
        print(sum(tmp))
    else:
        tmp = list(str(N - (N%(int("1" + (len(str(N)) - 1)*"0"))) - 1))
        tmp = [int(item) for item in tmp]
        print(sum(tmp))
else:
    print(N)

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

if (N%(int("1" + (len(str(N)) - 1)*"0"))) == int((len(str(N)) - 1) * "9"):
    tmp = list(str(N))
    tmp = [int(item) for item in tmp]
    print(sum(tmp))
else:
    tmp = list(str(N - (N%(int("1" + (len(str(N)) - 1)*"0"))) - 1))
    tmp = [int(item) for item in tmp]
    print(sum(tmp))
Problem p03495 (python)

Fixed submission:
import collections
from operator import itemgetter
N,K = map(int,input().split())
ball = [int(j) for j in input().split()]

kind = dict(collections.Counter(ball))

if len(kind) <= K:
    print(0)
else:
    skind = sorted(kind.items(),key=itemgetter(1))
    sumNum = 0
    for i in range(len(skind)-K):
        sumNum += skind[i][1]
    print(sumNum)

Buggy submission (verdict: Runtime Error):
B

�����j\_������������������@���s����d�dl�Z�d�dlmZ�eee������\ZZdd��e�����D��Z	e
e��e	��Ze
e�ekr`ed���nJee���ed�d�Zd�Zx(ee
e�e��D�]Zeee�d�7�Zq�W�ee��dS�)�����N)�
itemgetterc�������������C���s���g�|�]}t�|��qS���)�int)�.0�jr���r����
ABC081C.py�
<listcomp>���s����r�������)�key)�collections�operatorr����mapr����input�split�N�KZball�dict�Counter�kind�len�print�sorted�itemsZskindZsumNum�range�ir���r���r���r����<module>���s���

Problem p03076 (python)

Fixed submission:
import math
ryouri = [int(input()) for i in range(5)]

order_1 = [(i-1)*0.1 - int((i-1)*0.1) for i in ryouri]
min_v = 999
min_id = 0
for i, v in enumerate(order_1):
    if v < min_v:
        min_v = v
        min_id = i

goukei = 0
for i, (price, order) in enumerate(zip(ryouri, order_1)):
    if i == min_id:
        goukei = goukei + price
    else:
        goukei = goukei + math.ceil(price*0.1)*10

print(goukei)

Buggy submission (verdict: Runtime Error):
ryouri = [int(input()) for i in range(5)]

order_1 = [i*0.1 - int(i*0.1) for i in ryouri]
min_v = sorted(order_1)[0]
min_id = 0
for i, v in enumerate(order_1):
    if v == min_v:
        min_id = i

goukei = 0
for i, (price, order) in enumerate(zip(ryouri, order_1)):
    if i == min_id:
        goukei = goukei + ryouri
    else:
        goukei = goukei + ryouri + 10
Problem p02939 (python)

Fixed submission:
import sys

sys.setrecursionlimit(2000000)

s = input()

def solve(i):
    if i == 2:
        if s[i - 1] == s[i]:
            return 2
        else:
            return solve(i - 1) + 1
    if i == 1:
        if s[i - 1] == s[i]:
            return 1
        else:
            return 2
    if i == 0:
        return 1

    if s[i] != s[i - 1]:
        return solve(i - 1) + 1
    else:
        return solve(i - 3) + 2


print(solve(len(s) - 1))

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

def solve(i):
    
    if i == 2:
        if s[i - 1] == s[i]:
            return 2
        else:
            return solve(i - 1) + 1
    if i == 1:
        if s[i - 1] == s[i]:
            return 1
        else:
            return 2
    if i == 0:
        return 1

    if s[i] != s[i - 1]:
        return solve(i - 1) + 1
    else:
        return solve(i - 3) + 2


print(solve(len(s) - 1))

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

def solve(i):
    
    if i == 2:
        if s[i - 1] == s[i]:
            return 2
        else:
            return solve(i - 1) + 1
    if i == 1:
        if s[i - 1] == s[i]:
            return 1
        else:
            return 2
    if i == 0:
        return 0

    if s[i] != s[i - 1]:
        return solve(i - 1) + 1
    else:
        return solve(i - 3) + 2


print(solve(len(s) - 1))

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

def solve(i):
    if i == 1:
        if s[i - 1] == s[i]:
            return 1
        else:
            return 2
    if i == 0:
        return 0

    if s[i] != s[i - 1]:
        return solve(i - 1) + 1
    else:
        return solve(i - 3) + 2


print(solve(len(s) - 1))
Problem p02947 (python)

Fixed submission:
n =  int(input())

s = []
for _ in range(n):
    s.append(''.join(sorted(input())))

d = {}

for e in s:
    if e in d:
        d[e] += 1
    else:
        d[e] = 1

ans = 0
for k, v in d.items():
    ans += int(v * (v - 1) / 2)

print(ans)

Buggy submission (verdict: Runtime Error):
k, x = tuple([int(i) for i in input().split(' ')])

print(" ".join([str(i) for i in range(x - k + 1, x + k)]))
Problem p03353 (python)

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

sub = set()
for i in range(1, K + 1):
    for k in range(len(s) - i + 1):
        sub.add(s[k:i + k])

print(sorted([i for i in sub])[K - 1])

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

sub = set()
for i in range(1, len(s) + 1):
    for k in range(int(len(s) / i) + 1):
        sub.add(s[k:i + k])

print(sorted([i for i in sub])[1:][K])

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

sub = set()
for i in range(1, len(s) + 1):
    for k in range(int(len(s) / i) + 1):
        sub.add(s[k:i + k])

print(sorted([i for i in sub][1:])[K])

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

sub = set()
for i in range(1, len(s) + 1):
    for k in range(int(len(s) / i) + 1):
        sub.add(s[k:i + k])

print(sorted([i for i in sub][1:])[K])
print(sorted([i for i in sub][1:]))
Problem p03565 (python)

Fixed submission:
S_prime = input()
T = input()
ans = 'z'
matched = False

if len(S_prime) < len(T):
    print('UNRESTORABLE')
    exit()

for i in range(len(S_prime) - len(T) + 1):
    for k in range(len(T)):
        if S_prime[i + k] != T[k] and S_prime[i + k] != '?':
            break

    if k == len(T) - 1 and (S_prime[i + k] == T[k] or S_prime[i + k] == '?'):
        tmp = (S_prime[0:i] + T + S_prime[i + len(T):]).replace('?', 'a')
        if ans > tmp:
            ans = tmp
        matched = True

if matched:
    print(ans)
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
S_prime = input()
T = input()
replaced = 'UNRESTORABLE'
matched = True

if len(S_prime) < len(T):
    cout << replaced << endl;

for i in range(len(S_prime) - len(T) + 1):
    for k in range(len(T)):
        if S_prime[i + k] != T[k] and S_prime[i + k] != '?':
            matched = False
            break
        matched = True
    if matched:
        print(S_prime[0:i])
        replaced = S_prime[0:i] + T + S_prime[i + len(T):]
        break

print(replaced.replace('?', 'a'))

Buggy submission (verdict: Runtime Error):
from IPython import embed

S_prime = input()
T = input()
replaced = 'UNRESTORABLE'
matched = True

for i in range(len(S_prime) - len(T) + 1):
    for k in range(len(T)):
        if S_prime[i + k] != T[k] and S_prime[i + k] != '?':
            matched = False
            break
        matched = True
    if matched:
        print(S_prime[0:i])
        replaced = S_prime[0:i] + T + S_prime[i + len(T):]
        break

print(replaced.replace('?', 'a'))
Problem p03624 (python)

Fixed submission:
S = input()
a = [chr(i) for i in range(97, 97+26)]
for s in S:
    if s in a:
        a.remove(s)
if len(a) == 0:
    print('None')
else:
    print(a[0])

Buggy submission (verdict: Runtime Error):
S = input()
a = [chr(i) for i in range(97, 97+26)]
for s in S:
    if s in a:
        a.remove(s)

print(a[0])
Problem p02709 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 9)

input()

arr = list(sorted([(v, idx) for idx, v in enumerate(map(int, input().split()))], reverse=True))

d = [[-1 for _ in range(len(arr))] for _ in range(len(arr))]


def dp(l, r, idx):
    if idx == len(arr):
        return 0

    if d[l][r] != -1:
        return d[l][r]

    left = abs(arr[idx][1] - l) * arr[idx][0] + dp(l + 1, r, idx + 1)
    right = abs(arr[idx][1] - r) * arr[idx][0] + dp(l, r - 1, idx + 1)

    d[l][r] = max(left, right)
    return max(left, right)


print(dp(0, len(arr) - 1, 0))

Buggy submission (verdict: Runtime Error):
import functools

input()

arr = list(sorted([(v, idx) for idx, v in enumerate(map(int, input().split()))], reverse=True))


@functools.lru_cache(maxsize=None)
def dp(l, r, idx):
    if idx == len(arr):
        return 0

    left = abs(arr[idx][1] - l) * arr[idx][0] + dp(l + 1, r, idx + 1)
    right = abs(arr[idx][1] - r) * arr[idx][0] + dp(l, r - 1, idx + 1)

    return max(left, right)


print(dp(0, len(arr) - 1, 0))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

input()
arr = [(v, idx) for idx, v in enumerate(map(int, input().split()))]

dp = [-1 for _ in range(len(arr))]


def maximize(global_idx, temp_arr):
    if len(temp_arr) == 0:
        return 0

    # if dp[global_idx] != -1:
    #     return dp[global_idx]

    mx = 0

    for idx, child in enumerate(temp_arr):
        v, local_idx = child
        mx = max(mx, abs(global_idx - local_idx) * v + maximize(global_idx + 1, temp_arr[:idx] + temp_arr[idx + 1:]))

    dp[global_idx] = mx
    return dp[global_idx]


print(maximize(0, arr[:]))
Problem p02705 (python)

Fixed submission:
import sys
import socket
from math import pi

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'a1.in'
if socket.gethostname() in hostnames:
    sys.stdin = open(input_file)


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    r = read_int()
    return 2 * pi * r


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import socket
form math import pi

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'f1.in'
if socket.gethostname() in hostnames:
    sys.stdin = open(input_file)


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    r = read_int()
    return 2 * pi * r


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()
Problem p03210 (python)

Fixed submission:
X = int(input())
if X in [5, 7, 3]:
  print ('YES')
else:
  print ('NO')

Buggy submission (verdict: Runtime Error):
    X = int(input())
    if X in [7, 5, 3]:
      print ('YES')
    else:
      print ('NO')
Problem p03233 (python)

Fixed submission:
import sys
import socket

if socket.gethostname() in ['N551J', 'F551C']:
    test_case = 'c1.in'
    sys.stdin = open(test_case)


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    rows = [read_int_list() for i in range(n)]
    a, b = map(list, zip(*rows))
    res = sum(a)
    res = min(res, sum(b))
    all_values = [(a[i], i, 0) for i in range(n)]
    all_values.extend([(b[i], i, 1) for i in range(n)])
    all_values.sort()
    index_of_value = {v: i for i, v in enumerate(all_values)}
    first_values = [
        set(all_values[:n - 2]),
        set(all_values[:n - 1]),
        set(all_values[:n]),
    ]

    s = [sum([t[0] for t in v]) for v in first_values]
    for i in range(n):
        rest = []
        k = 0
        last = n - 2
        indices = sorted([(index_of_value[(a[i], i, 0)], a[i]),
                          (index_of_value[(b[i], i, 1)], b[i])])

        for index, value in indices:
            if index < last:
                last += 1
                k += 1
            else:
                rest.append(value)
        t = s[k] + sum(rest)
        res = min(res, t)
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

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

if socket.gethostname() in ['N551J', 'F551C']:
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    rows = [read_int_list() for i in range(n)]
    a, b = map(list, zip(*rows))
    res = sum(a)
    res = min(res, sum(b))
    all_values = [(a[i], i, 0) for i in range(n)]
    all_values.extend([(b[i], i, 1) for i in range(n)])
    all_values.sort()
    index_of_value = {v: i for i, v in enumerate(all_values)}
    first_values = [
        set(all_values[:n - 2]),
        set(all_values[:n - 1]),
        set(all_values[:n]),
    ]

    s = [sum([t[0] for t in v]) for v in first_values]

    for i in range(n):
        rest = []
        k = 0
        if index_of_value[(a[i], i, 0)] < n:
            k += 1
        else:
            rest.append(a[i])
        if index_of_value[(b[i], i, 1)] < n:
            k += 1
        else:
            rest.append(b[i])
        t = s[k] + sum(rest)
        res = min(res, t)
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()
Problem p03247 (python)

Fixed submission:
import sys
import socket
import random

if socket.gethostname() in ['N551J', 'F551C']:
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


dx = [-1, 1, 0, 0]
dy = [0, 0, -1, 1]
letter = ['L', 'R', 'D', 'U']


def check():
    M = 10 ** 2
    n = 1
    x = [random.randint(-M, M) for i in range(n)]
    y = [random.randint(-M, M) for i in range(n)]
    m, d, w = solve(n, x, y)

    return True


def solve(n, x, y):

    if len(set([(x[i] + y[i]) % 2 for i in range(n)])) == 2:
        return -1
    d = [2 ** k for k in range(35, -1, -1)]
    parity = (x[0] + y[0]) % 2
    if parity == 0:
        d.append(1)
    m = len(d)
    w = []
    for i in range(n):
        u, v = 0, 0
        s = []
        for j in range(m):
            choices = []
            for k in range(4):
                distance = abs(u + d[j] * dx[k] - x[i]) + abs(v + d[j] * dy[k] - y[i])
                choice = (distance, k)
                choices.append(choice)
            choices.sort()
            smallest_distance, best_k = choices[0]
            u += d[j] * dx[best_k]
            v += d[j] * dy[best_k]
            s.append(letter[best_k])
        w.append(''.join(s))
    return m, d, w


def main():

    random.seed = 1
    n = read_int()
    x = [0] * n
    y = [0] * n
    for i in range(n):
        x[i], y[i] = read_int_list()
    res = solve(n, x, y)
    if res == -1:
        print(res)
        return
    m, d, w = res
    print(m)
    print(*d)
    print('\n'.join(w))


if __name__ == '__main__':
    # check()
    main()

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

if socket.gethostname() in ['N551J', 'F551C']:
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


dx = [-1, 1, 0, 0]
dy = [0, 0, -1, 1]
letter = ['L', 'R', 'D', 'U']


def check():
    return True


def solve():
    n = read_int()
    x = [0] * n
    y = [0] * n
    for i in range(n):
        x[i], y[i] = read_int_list()
    if len(set([(x[i] + y[i]) % 2 for i in range(2)])) == 2:
        return -1
    parity = (x[0] + y[0]) % 2

    d = [2 ** k for k in range(35, -1, -1)]
    if parity == 0:
        d.append(1)
    m = len(d)
    w = []
    for i in range(n):
        u, v = 0, 0
        s = []
        for j in range(m):
            choices = []
            for k in range(4):
                distance = abs(u + d[j] * dx[k] - x[i]) + abs(v + d[j] * dy[k] - y[i])
                choice = (distance, k)
                choices.append(choice)
            choices.sort()
            smallest_distance, best_k = choices[0]
            u += d[j] * dx[best_k]
            v += d[j] * dy[best_k]
            s.append(letter[best_k])
        w.append(''.join(s))
    return m, d, w


def main():
    m, d, w = solve()
    print(m)
    print(*d)
    print('\n'.join(w))


if __name__ == '__main__':
    main()
Problem p03591 (python)

Fixed submission:
import sys
import socket

if socket.gethostname() == 'N551J':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    if read_str().startswith('YAKI'):
        return 'Yes'
    return 'No'

def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
git merge upstream/master
Problem p03601 (python)

Fixed submission:
import sys
import socket

if socket.gethostname() == 'N551J':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    a, b, c, d, e, f = read_int_list()
    best_sugar = 0
    best_total = 100 * a
    for i in range(31):
        for j in range(31):
            water = i * 100 * a + j * 100 * b
            for k in range(3001):
                if water + k * c <= f and k * c * 100 <= water * e:
                    l1 = int((f - water - k * c) / d)
                    l2 = int((water * e // 100 - k * c) / d)
                    l = min(l1, l2)
                    if (i, j, k, l) != (0, 0, 0, 0):
                        sugar = k * c + l * d
                        total = water + sugar
                        density = sugar / total
                        best_density = best_sugar / best_total
                        if density > best_density:
                            best_sugar = sugar
                            best_total = total
    return best_total, best_sugar


def main():
    res = solve()
    print(*res)


if __name__ == '__main__':
    main()

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

if socket.gethostname() == 'N551J':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    a, b, c, d, e, f = read_int_list()
    best_sugar = 0
    best_total = a
    for i in range(31):
        for j in range(31):
                for k in range(3001):
                    water = i * 100 * a + j * 100 * b
                    if water + k * c <= f and k * c * 100 <= water * e:
                        l1 = int((f - water - k * c) / d)
                        l2 = int((water * e // 100 - k * c) / d)
                        l = min(l1, l2)
                        if (i, j, k, l) != (0, 0):
                            sugar = k * c + l * d
                            total = water + sugar
                            density = sugar / total
                            best_density = best_sugar / best_total
                            if density > best_density:
                                best_sugar = sugar
                                best_total = total
    return best_total, best_sugar


def main():
    res = solve()
    print(*res)


if __name__ == '__main__':
    main()