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

Fixed submission:
N = int(input()) #入力値
A = sorted(map(int, input().split()), reverse = True)
Bob=0
Alice=0
for i in range(0,N):
      if i % 2 == 0: # Bobが偶数なら実行
         Alice=Alice+int(A[i])
      else:
         Bob=Bob+int(A[i])
print(Alice-Bob)

Buggy submission (verdict: Runtime Error):
N = int(input()) #入力値
lists = []
Bob=0
Alice=0

for i in range(0,N):
    A = input()
    lists.append(A) #入力した値をどんどん入れていく
    
lists.reverse() #入力した値ソート

for j in range(0,N):
      if j % 2 == 0: # Bobが偶数なら実行
         Bob=Bob+int(lists[j])
      else:
         Alice=Alice+int(lists[j])
print(Alice-Bob)
Problem p02975 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if a.count(0) == n:
    print("Yes")
else:
  if n % 3 != 0:
    print("No")
  else:
    s = set(a)
    if len(s)>3 or len(s)==1:
      print("No")
    elif len(s)==2:
      if a.count(0) == n/3:
        print("Yes")
      else:
        print("No")
    else:
      l = list(s)
      if (l[0]^l[1] == l[2] and l[1]^l[2] == l[0] and l[2]^l[0] == l[1]) and (a.count(l[0])==n/3 and a.count(l[1])==n/3):
        print("Yes")
      else:
        print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if a.count(0) == n:
    print("Yes")
else:
  if n % 3 != 0:
    print("No")
  else:
    s = set(a)
    if len(s)>3:
      print("No")
    elif len(s)==2:
      if a.count(0) == n/3:
        print("Yes")
      else:
        print("No")
    else:
      l = list(s)
      if (l[0]^l[1] == l[2] and l[1]^l[2] == l[0] and l[2]^l[0] == l[1]) and (a.count(l[0])==n/3 and a.count(l[1])==n/3):
        print("Yes")
      else:
        print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if a.count(0) == n:
    print("Yes")
else:
  if n % 3 != 0:
    print("No")
  else:
    s = set(a)
    if len(s)>3:
      print("No")
    elif len(s)==2:
      if a.count(0) == n/3:
        print("Yes")
      else:
        print("No")
    else:
      l = list(s)
      if (l[0]^l[1] == l[2] and l[1]^l[2] == l[0] and l[2]^l[0] == l[1]) and (a.count(l[0])==n/3 and a.count(l[1])==n/3):
        print("Yes")
      else:
        print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
#n = 3
#a = [1,0,1]
if a.count(0) == n:
    print("Yes")
else:
  if n % 3 != 0:
    print("No")
  else:
    s = set(a)
    if len(s)>3:
      print("No")
    elif len(s)==2:
      if a.count(0)==n/3:
        print("Yes")
      else:
        print("No")
    else:
      l = list(s)
      if (l[0]^l[1] == l[2] and l[1]^l[2] == l[0] and l[2]^l[0] == l[1]) and (a.count(l[0])==n/3 and a.count(l[1])==n/3):
        print("Yes")
      else:
        print("No")
Problem p03129 (python)

Fixed submission:
b,c=map(int,input().split())
  
if (b//2+b%2)>=c:
    print("YES")
else : print("NO")

Buggy submission (verdict: Runtime Error):
n,A,B=map(int,input().split())
if A+2>=B:
  ans=bis+n
else:

  print("A n",A,n)
  if (n+1)>=(A+2):
    en+=(n+1)//(A+2)
    n-=en*(A+2)-1
    print(bis,en,n)
    #交換
    bis=en*B
    en=0
    print("交換",bis,en,n)
  if n==0:
    ans=bis
  else:
    ans=bis+n
  
print(ans)

Buggy submission (verdict: Runtime Error):
n,A,B=map(int,input().split())
if A+2>=B:
  ans=bis+n
else:

  print("A n",A,n)
  if (n+1)>=(A+2):
    en+=(n+1)//(A+2)
    n-=en*(A+2)-1
    print(bis,en,n)
    #交換
    bis=en*B
    en=0
    print("交換",bis,en,n)
  if n==0:
    ans=bis
  else:
    ans=bis+n
  
print(ans)

Buggy submission (verdict: Runtime Error):
b,c=map(input().split())
  
if (b//2+b%2)>=c:
    print("YES")
else : print("NO")

Buggy submission (verdict: Runtime Error):
b,c=map(input().split())
  
  if (b//2+b%2)>=c:
    print("YES")
  else : print("NO")
Problem p02612 (python)

Fixed submission:
s = input()
a = [int(c) for c in s]


if len(a) < 4:
    print(1000 - int(s))
elif a[-3] != 0:
    print((a[-4]+1)*1000 - int(s))
elif int(s) % 1000 != 0:
    print((a[-4]+1)*1000 - int(s))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
s = input()
a = [int(c) for c in s]

if a[-3] != 0:
    ans = int(s) - (a[-4]*1000)
else:
    ans = 0

print(ans)
Problem p02639 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
def line_to_int(): return int(sys.stdin.readline())
def line_to_each_int(): return map(int, sys.stdin.readline().split())
def line_to_list(): return list(map(int, sys.stdin.readline().split()))
def line_to_list_in_iteration(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
# def dp(init, i, j): return [[init]*i for i2 in range(j)]
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
# from itertools import accumulate #A = [0]+list(accumulate(A))
# import bisect #bisect.bisect_left(B, a), bisect.bisect_right(B,a)

x = line_to_list()
print(x.index(0)+1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)
def line_to_int(): return int(sys.stdin.readline())
def line_to_each_int(): return map(int, sys.stdin.readline().split())
def line_to_list(): return list(map(int, sys.stdin.readline().split()))
def line_to_list_in_iteration(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
# def dp(init, i, j): return [[init]*i for i2 in range(j)]
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
# from itertools import accumulate #A = [0]+list(accumulate(A))
# import bisect #bisect.bisect_left(B, a), bisect.bisect_right(B,a)

n, k = line_to_each_int()
p = line_to_list()

p = sorted(p)
ans = 0
for i in range(k):
    ans += p[i]
print(ans)
Problem p03067 (python)

Fixed submission:
from sys import stdin
s_data = stdin.readline().rstrip().split()
data = [int(itr) for itr in s_data]
A = data[0]
B = data[1]
C = data[2]
if (B <= C and C <= A) or (A <= C and C <= B):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
sum = 0
cnt = 0
for itr in range(N):
    if s[itr] == '#':
        cnt += 1
        continue
    if cnt > 0:
        sum += 1
        cnt = 0
print(sum)

Buggy submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
sum = 0
wh = s.count('.')
cnt = 0
for itr in range(N):
    if s[itr] == '#':
        cnt += 1
        continue
    if cnt > 0:
        sum += 1
        cnt -= 1
print(sum)
Problem p03069 (python)

Fixed submission:
from sys import stdin
N = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
sum = 0
wh = s.count('.')
cnt = 0
for itr in range(N):
    if s[itr] == '#':
        cnt += 1
        continue
    if cnt > 0:
        sum += 1
        cnt -= 1
print(sum)

Buggy submission (verdict: Runtime Error):
from sys import stdin
N = int(stdin.readline().rstrip())
ans = stdin.readline().rstrip()
sum = 0
left = 0
right = 0
for itr in range(0,len(ans)):
    count_dot = 0
    count_sharp = 0
    left = itr
    right = left + 1
    if left == len(ans)-1:
        break
    if ans[left] == '#' and ans[right] == '.':
        while(right < N and ans[right] == '.'):
            count_dot += 1
            right += 1
        while(left >= 0 and ans[left] == '#'):
            count_sharp += 1
            left -= 1
        if tmp != 0:
            count += 1
        sum += max(count_dot, count_sharp)
print(count)
Problem p03103 (python)

Fixed submission:
from sys import stdin
import numpy as np
n, m = (int(i) for i in input().rstrip().split())
# print(n)
vals_list = np.zeros((n, 2))
# print(vals_list)
for itr in range(n):
    a, b = (int(i) for i in input().rstrip().split())
    vals_list[itr][0], vals_list[itr][1] = a, b
sorted_vals_list = vals_list[np.argsort(vals_list[:, 0])]
# print(sorted_vals_list)

cnt = m
total_money = 0
for itr in range(n):
    if (cnt - sorted_vals_list[itr][1]) <= 0:
        total_money += sorted_vals_list[itr][0] * cnt
        break
    else:
        cnt -= sorted_vals_list[itr][1]
        total_money += sorted_vals_list[itr][0] * sorted_vals_list[itr][1]
print(int(total_money))

Buggy submission (verdict: Runtime Error):
from sys import stdin
import numpy as np
n, m = map(int, raw_input().split())
# print(n)
vals_list = np.zeros((n, 2))
# print(vals_list)
for itr in range(n):
    a, b = map(int, raw_input().split())
    vals_list[itr][0], vals_list[itr][1] = a, b
sorted_vals_list = vals_list[np.argsort(vals_list[:, 0])]
# print(sorted_vals_list)

cnt = m
total_money = 0
for itr in range(n):
    if (cnt - sorted_vals_list[itr][1]) <= 0:
        total_money += sorted_vals_list[itr][0] * cnt
        break
    else:
        cnt -= sorted_vals_list[itr][1]
        total_money += sorted_vals_list[itr][0] * sorted_vals_list[itr][1]
print(total_money)
Problem p02612 (python)

Fixed submission:
N = int(input())
pay = (N%1000)
if(pay == 0):
  print(0)
else:
  print(1000 - pay)

Buggy submission (verdict: Runtime Error):
N = int(input())
pay == (N%1000)
if(pay = 0):
  print(0)
else:
  print(1000 - pay)

Buggy submission (verdict: Runtime Error):
N = int(input())
pay = (N%1000)
if(pay = 0):
  print(0)
else:
  print(1000 - pay)
Problem p02613 (python)

Fixed submission:
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if (s == "AC"):
    ac += 1
  elif (s == "WA"):
    wa += 1
  elif (s == "TLE"):
    tle += 1
  elif(s == "RE"):
    re += 1
    
print("AC x {0}".format(ac))
print("WA x {0}".format(wa))
print("TLE x {0}".format(tle))
print("RE x {0}".format(re))

Buggy submission (verdict: Runtime Error):
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  s = input()
  if (s == "AC"):
    ac += 1
  elif (s == "WA"):
    wa += 1
  elif (s == "TLE"):
    tle += 1
  elif(s == "RE"):
    re += 1
    
print("AC x "+ac)
print("WA x "+wa)
print("TLE x "+tle)
print("RE x "+re)
Problem p02885 (python)

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

if a-2*b>0:
    print(a-2*b)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
str = input()
char_list = list(str)
#del_num = []

count =0
ans =0

#dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
        #del_num.append(i+1)
        count += 1

ans = n - count

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
str = input()
char_list = list(str)
del_num = []

dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
ans =0
for i in range(len(char_list)-1):
    if char_list[i] == char_list[i+1]:
        del_num.append(i+1)

print(len(dellist(char_list,del_num)))
Problem p03035 (python)

Fixed submission:

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

if a<=5:
    ans = 0
elif 6<=a and a<=12:
    ans = b/2
else:
    ans = b

print(int(ans))

Buggy submission (verdict: Runtime Error):
r,d,x0 = map(int,input().split())

xlist = []

xlist.append(r*x0-d)

for i in range(9):
    xlist.append(r*xlist[i]-d)
    map(int,xlist)
    print(xlist[i])

Buggy submission (verdict: Runtime Error):
r,d,x0 = map(int,input().split())

xlist = []

xlist.append(r*x0-d)

for i in range(9):
    xlist.append(r*xlist[i]-d)
    print(int(xlist[i]))

Buggy submission (verdict: Runtime Error):

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

if a<=5:
    ans = 0
elif 6<=a and a<=12:
    ans = b/2
else:
    ans = b

print((int)ans)
Problem p03238 (python)

Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
elif n == 2:
    a = int(input())
    b = int(input())
    print(a + b)

Buggy submission (verdict: Runtime Error):
n = int(input())
    if n == 1:
        print("Hello World")
    elif n == 2:
        a = int(input())
        b = int(input())
        print(a+b)

Buggy submission (verdict: Runtime Error):
N = int(input())
    if N == 1:
        print("Hello World")
    elif N == 2:
        a,b = int(input().split())
        print(a+b)

Buggy submission (verdict: Runtime Error):
N = int(input())
    if N == 1:
        print("Hello World")
    elif N == 2
        a,b = int(input().split())
        print(a+b)

Buggy submission (verdict: Runtime Error):
N = int(input())
    if N == 1:
        print("Hello World")
    elif N == 2
        a,b = int(input().split())
        print(a+b)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print("Hello World)
elif N == 2
    a,b = int(input().split())
    print(a+b)
Problem p03328 (python)

Fixed submission:
a,b = [int(i) for i in input().split()]
     
souwa = 0
n = b - a
for i in range(n+1):
    souwa += i
         
x = souwa - b
         
print(x)

Buggy submission (verdict: Runtime Error):
    a,b = [int(i) for i in input().split()]
     
    souwa = 0
    n = b - a
    for i in range(n):
        souwa += i
         
    x = souwa - b
         
    print(x)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

souwa = 0
n = b - a
for i in range(n):
    souwa += i

x = souwa - b

print(x)
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
if (a*b % 2 == 0):
  print("Even") 
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
  if (a*b % 2):
    print("Even") 
  else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
 a,b = map(int,input().split())                                                  
  2     if (a*b % 2):                                                               
  3         print("Even")                                                           
  4     else:                                                                       
  5        print("Odd")                                                             
  6                                                                                        
~                                                                                          
~
Problem p03493 (python)

Fixed submission:
s = input()
count = 0

if s[0] == '1':
  count += 1
if s[1] == '1':
  count += 1
if s[2] == '1':
  count += 1

print(count)

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

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

counter = 0
check = 0

for i in range(n):
    if a[i] % 2 = 0:
        check += 1



while check == n:
    for i in range(n):
        a[i] = a[i]/2
    for i in range(n):
        product = 1
        product *= a[i]
    counter += 1
print(counter)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split(' '))
if N != 0:
    P_n = list(map(int, input().split(' ')))

    for i in range(X, 150):
        if i not in set(P_n):
            min_1 = i
            break
    for i in range(X, -150, -1):
        if i not in set(P_n):
            min_2 = i
            break
    if abs(min_1-X) == abs(min_2-X):
        print(min(min_1, min_2))
    elif abs(min_1-X) < abs(min_2-X):
        print(min_1)
    else:
        print(min_2)
else:
    print(X)

Buggy submission (verdict: Runtime Error):
N = int(input())
A_n = sorted(list(map(int, input().split(' '))))
count = 0
for i in range(len(A_n)):
    # print(list(map(lambda x: x%A_n[i], A_n)))
    if list(map(lambda x: A_n[i]%x, A_n)).count(0) == 1:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split(' '))
if N != 0:
    P_n = list(map(int, input().split(' ')))

    for i in range(X, 101):
        if i not in set(P_n):
            min_1 = i
            break
    for i in range(X, -100, -1):
        if i not in set(P_n):
            min_2 = i
            break
    if abs(min_1-X) == abs(min_2-X):
        print(min(min_1, min_2))
    elif abs(min_1-X) < abs(min_2-X):
        print(min_1)
    else:
        print(min_2)
else:
    print(X)
Problem p02642 (python)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split(' '))))
# print(A)
a_max = A[-1]
dp = [True]*(a_max+1)
ans = 0
for i in range(N-1):
    p = A[i]
    if dp[p] == True:
        # print(math.sqrt(p))
        for q in range(a_max//p+1):
            # print(p*q)
            dp[p*q] = False
        if A[i] != A[i+1]:
            ans += 1
if dp[A[-1]]:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(list(map(int, input().split(' '))))
A_max = A[-1]
dp = [True]*(A_max+1)
ans = 0
for i in range(N-1):
    p = A[i]
    if dp[i] == True:
        for q in range(A_max//p+1):
            dp[p*q] = False
        if A[i] != A[i+1]:
            ans += 1
if dp[-1] != True:
    ans += 1 
print(ans)
Problem p02660 (python)

Fixed submission:
import math

# 素数か否かを判定する関数
def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True      

# nまでの素数を返す関数（エラトステネスの篩）
def getPrime(n):
    n_sqrt = int(math.sqrt(n))
    array = [True]*(n_sqrt+1)
    result = []
    for i in range(2, n_sqrt+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(i*2, n_sqrt+1, i):
                array[j] = False
    return result

N = int(input())
n = N
prime = getPrime(n)
prime_exp = []
# print(prime)
for p in prime:
    cnt = 0
    while n%p == 0:
        n = int(n/p)
        # print(n)
        cnt += 1
    if cnt != 0:
        prime_exp.append([p, cnt])
if is_prime(n) and n != 1:
    prime_exp.append([n, 1])
ans = 0
for pe in prime_exp:
    ans += int((-1+math.sqrt(1+8*pe[1]))/2)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

#引数nが素数かどうかを判定
def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True

def getPrimeExp(n):
    array = [True]*(n+1)
    result = []
    for i in range(2, n+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(2, n+1):
                ij = i**j
                if ij <= n and array[ij]:
                    result.append(ij)
                    array[ij] = False
                elif ij > n:
                    break
            for j in range(i*2, n+1, i):
                array[j] = False

            # for j in range(2, n):
            #     ij = i**j
            #     if ij <= n:
            #         result.append(ij)
            #         array[ij] = False
    return sorted(result)

N = int(input())
if is_prime(N):
    print(1)
else:
    cnt = 0
    primeExp = getPrimeExp(N) 
    n = N
    # print(primeExp)
    for z in primeExp:
        if n%z == 0:
            n = int(n/z)
            cnt += 1
    print(cnt)
Problem p02612 (python)

Fixed submission:
n = int(input())
ans = (1000 - (n % 1000)) % 1000
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
res = n%1000
if res:
  return 1000 - res
return 0

Buggy submission (verdict: Runtime Error):
def change(x):
	res = 1000 - x%1000
    if res:
      return res
    return 0

Buggy submission (verdict: Runtime Error):
return 1000 - N%1000
Problem p02613 (python)

Fixed submission:
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
counter = Counter(s)
output = ['AC', 'WA', 'TLE', 'RE']

for key in output:
    print(f'{key} x {counter[key]}')

Buggy submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
counter = Counter(s)
#output = ['AC', 'WA', 'TLE', 'RE']

for key in output:
    print(f'{key} x {counter[key]}')

Buggy submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
counter = Counter(s)


for key in output:
  print(f'{key} x {counter[key]}')
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())
if n > 0 :
  p = list( map(int,input().split()) )
  p = set(p)
else:
  p = set()

if x not in p:
  ans = x
else:
  i = x - 1
  j = x + 1
  while 1:
    if i not in p and j not in p:
      ans = min(i,j)
      break

    if i not in p:
      ans = i
      break
    elif j not in p:
      ans = j
      break

    i -= 1
    j += 1

print(ans)

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
if n > 0 :
  p = list( map(int,input().split()) )

p = set(p)
if x not in p:
  ans = x
else:
  i = x - 1
  j = x + 1
  while 1:
    if i not in p and j not in p:
      ans = min(i,j)
      break

    if i not in p:
      ans = i
      break
    elif j not in p:
      ans = j
      break

    i -= 1
    j += 1

print(ans)
Problem p03240 (python)

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

ans = []
for i in range(101):
  for j in range(101):
    h.sort(key=lambda x: -x[2])
    hmax = h[0][2] + abs(i-h[0][0]) + abs(j-h[0][1])
    for k in range(1,n):

      if max(hmax - abs(h[k][0] - i) - abs(h[k][1] - j) , 0) != h[k][2]:
        break

    else:
      ans = [i,j,hmax]
    
    if(len(ans)):
      break
  if(len(ans)):
    break

ans = map(str,ans)
print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [ list(map(int,input().split())) for _ in range(n)]

for i in range(101):
  for j in range(101):

    hmax = h[0][2] + abs(i-h[0][0]) + abs(j-h[0][1])
    for k in range(1,n):
      if h[k][2] + abs(i-h[k][0]) + abs(j-h[k][1]) != hmax:
        break
    else:
      ans = [i,j,hmax]
      break
  else:
    continue
  break

ans = map(str,ans)
print(' '.join(ans))
Problem p03599 (python)

Fixed submission:
a,b,x,y,s,m = map(int,input().split())

#a,b,x,y,s,m = (1,2,1,2,100,1000)
a *= 100
b *= 100

#入れられる水の候補
waterlist=[]
amax = int(m/a)
for i in range(amax+1):
  bmax = int((m-a*i)/b)
  for j in range(bmax+1):
    water = a*i + b*j
    if water:
      waterlist.append(a*i + b*j)
waterlist = set(waterlist)

#砂糖の組み合わせから最大を
def makesatolist(maxsato,x,y):
  satolist = []
  xmax = int(maxsato/x)
  for i in range(xmax+1):
    ymax  = int((maxsato-x*i)/y)
    for j in range(ymax+1):
      satolist.append(x*i + y*j)
  return max(satolist)
  
nownodo = 0
ans = [0] * 2
for i in waterlist:
 
  # iグラムの水に何グラムの砂糖まで解ける？
  maxsato = i * s/100
  if i + maxsato > m:
    maxsato = m - i

  sato = makesatolist(maxsato,x,y)
  satowater = i + sato
  nodo = sato / satowater
  if nodo >= nownodo:
    nownodo = nodo
    ans = [satowater,sato]

print(ans[0]," ",ans[1])

Buggy submission (verdict: Runtime Error):
a,b,x,y,s,m = map(int,input().split())

#a,b,x,y,s,m = (1,2,1,2,100,1000)
a *= 100
b *= 100

#入れられる水の候補
waterlist=[]
amax = int(m/a)
for i in range(amax+1):
  bmax = int((m-a*i)/b)
  for j in range(bmax+1):
    waterlist.append(a*i + b*j)
waterlist = set(waterlist)

#砂糖の組み合わせから最大を
def makesatolist(maxsato,x,y):
  satolist = []
  xmax = int(maxsato/x)
  for i in range(xmax+1):
    ymax  = int((maxsato-x*i)/y)
    for j in range(ymax+1):
      satolist.append(x*i + y*j)
  return max(satolist)
  
nownodo = 0
ans = []
for i in waterlist:
  if i == 0:
    continue
 
  # iグラムの水に何グラムの砂糖まで解ける？
  maxsato = i * s/100
  if i + maxsato > m:
    maxsato = m - i

  sato = makesatolist(maxsato,x,y)
  satowater = i + sato
  nodo = sato / satowater
  if nodo > nownodo:
    nownodo = nodo
    ans = [satowater,sato]

print(ans[0]," ",ans[1])

Buggy submission (verdict: Runtime Error):
a,b,x,y,s,m = map(int,input().split())

#a,b,x,y,s,m = (1,2,1,2,100,1000)
a *= 100
b *= 100

#入れられる水の候補
waterlist=[]
amax = int(m/a)
for i in range(amax+1):
  bmax = int((m-a*i)/b)
  for j in range(bmax+1):
    waterlist.append(a*i + b*j)
waterlist = set(waterlist)

#砂糖の組み合わせから最大を
def makesatolist(maxsato,x,y):
  satolist = []
  xmax = int(maxsato/x)
  for i in range(xmax+1):
    ymax  = int((maxsato-x*i)/y)
    for j in range(ymax+1):
      satolist.append(x*i + y*j)
  return max(satolist)
  

nownodo = 0
ans = []
for i in waterlist:
  if i == 0:
    continue
 
  # iグラムの水に何グラムの砂糖まで解ける？
  maxsato = i * s/100
  if i + maxsato > m:
    maxsato = m - i

  sato = makesatolist(maxsato,x,y)
  satowater = i + sato
  nodo = sato / satowater
  if nodo > nownodo:
    nownodo = nodo
    ans = [satowater,sato]

print(ans[0]," ",ans[1])