Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
water=[]
salt=[]
for i in range(30):
  for j in range(30):
    x=a*100*i+b*100*j
    if x<=f:
      water.append(x)
for i in range(1501):
  for j in range(1501):
    x=c*i+d*j
    if x<=f:
      salt.append(x)
water=list(set(water))
salt=list(set(salt))
stack=0
ans_sol=0
ans_sal=0
for i in water:
  for j in salt:
    if i+j<=f and j*100<=i*c:
      if j/(i+j)>stack:
        stack=j/(i+j)
        ans_sol=i+j
        ans_sal=j
print(ans_sol,ans_sal)

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
flag=True
for i in range(1,f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1:
      if 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
        dp[i]=max(dp[i],dp[i-j]+j)
      else:
        for k in [a*100,b*100]:
          if i-k-j>=0 and dp[i-k-j]!=-1:
            if 100*(dp[i-k-j]+j)<=e*(i-(dp[i-k-j]+j)):
              dp[i]=max(dp[i],dp[i-k-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<(dp[i]*100)/i:
      stack=(dp[i]*100)/i
      index=i
print(index,dp[index])

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
ans=[]
for i in range(f//100//a +1):
  for j in range(f//100//b +1):
    if i*a*100+j*b*100<=f:
      for p in range(f//c +1):
        for q in range(f//d +1):
          if p*c+q*d<=(i*a+j*b)*e and (p*c+q*d+i*a*100+j*b*100<=f):
            ans.append([p*c+q*d+i*a*100+j*b*100,p*c+q*d])
stack=0
index=0
for i in ans:
  if stack<i[0]/i[1]:
    stack=i[0]/i[1]
    index=i
if index==0:
  print(0,0)
else:
  print(ans[index])

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
flag=True
for i in range(1,f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1:
      if 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
        dp[i]=max(dp[i],dp[i-j]+j)
      else:
        for k in [a*100,b*100]:
          if i-k-j>=0 and dp[i-k-j]!=-1:
            if 100*(dp[i-k-j]+j)<=e*(i-(dp[i-k-j]+j)):
              dp[i]=max(dp[i],dp[i-k-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<(dp[i]*100)/i:
      stack=(dp[i]*100)/i
      index=i
print(index,dp[index])

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d,e,f=map(int,input().split())
ans=[]
for i in range(30):
  for j in range(30):
    if i*a*100+j*b*100<=f:
      for p in range(3000):
        for q in range(3000):
          if p*c+q*d<=(i*a+j*b)*e and (p*c+q*d+i*a*100+j*b*100<=f):
            ans.append([p*c+q*d+i*a*100+j*b*100,p*c+q*d])
stack=0
index=0
for i in ans:
  if stack<i[0]/i[1]:
    stack=i[0]/i[1]
    index=i
if index==0:
  print(0,0)
else:
  print(ans[index])

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
flag=True
for i in range(1,f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1:
      if 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
        dp[i]=max(dp[i],dp[i-j]+j)
      else:
        for k in [a*100,b*100]:
          if i-k-j>=0 and dp[i-k-j]!=-1:
            if 100*(dp[i-k-j]+j)<=e*(i-(dp[i-k-j]+j)):
              dp[i]=max(dp[i],dp[i-k-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<(dp[i]*100)/i:
      stack=(dp[i]*100)/i
      index=i
print(index,dp[index])

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range1,(f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<dp[i]*100/(i-dp[i]):
      stack=dp[i]*100/(i-dp[i])
      index=i
print(index,dp[index])

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
flag=True
for i in range(1,f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1:
      if 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
        dp[i]=max(dp[i],dp[i-j]+j)
      else:
        for k in [a*100,b*100]:
          if i-k-j>=0 and dp[i-k-j]!=-1:
            if 100*(dp[i-k-j]+j)<=e*(i-(dp[i-k-j]+j)):
              dp[i]=max(dp[i],dp[i-k-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<(dp[i]*100)/i:
      stack=(dp[i]*100)/i
      index=i
print(index,dp[index])

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range(f+1):
  for j in [a*100,b*100]:
    if dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<dp[i]*100/(i-dp[i]):
      stack=dp[i]*100/(i-dp[i])
      index=i
print(index,dp[index])

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
flag=True
for i in range(1,f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1:
      if 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
        dp[i]=max(dp[i],dp[i-j]+j)
      else:
        for k in [a*100,b*100]:
          if i-k-j>=0 and dp[i-k-j]!=-1:
            if 100*(dp[i-k-j]+j)<=e*(i-(dp[i-k-j]+j)):
              dp[i]=max(dp[i],dp[i-k-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<(dp[i]*100)/i:
      stack=(dp[i]*100)/i
      index=i
print(index,dp[index])

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range(f+1):
  for j in [a*100,b*100]:
    if dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(f+1):
  if dp[i]!=0:
    if stack<dp[i]*100/(i-dp[i]):
      stack=dp[i]*100/(i-dp[i])
      index=i
print(index,dp[index])

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
flag=True
for i in range(1,f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1:
      if 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
        dp[i]=max(dp[i],dp[i-j]+j)
      else:
        for k in [a*100,b*100]:
          if i-k-j>=0 and dp[i-k-j]!=-1:
            if 100*(dp[i-k-j]+j)<=e*(i-(dp[i-k-j]+j)):
              dp[i]=max(dp[i],dp[i-k-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<(dp[i]*100)/i:
      stack=(dp[i]*100)/i
      index=i
print(index,dp[index])

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range(f+1):
  for j in [a*100,b*100]:
    if dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=0
for i in range(f+1):
  if dp[i]!=0:
    if stack<dp[i]*100/(i-dp[i]):
      stack=dp[i]*100/(i-dp[i])
      index=i
print(index,dp[index])

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
flag=True
for i in range(1,f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1:
      if 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
        dp[i]=max(dp[i],dp[i-j]+j)
      else:
        for k in [a*100,b*100]:
          if i-k-j>=0 and dp[i-k-j]!=-1:
            if 100*(dp[i-k-j]+j)<=e*(i-(dp[i-k-j]+j)):
              dp[i]=max(dp[i],dp[i-k-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<(dp[i]*100)/i:
      stack=(dp[i]*100)/i
      index=i
print(index,dp[index])

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
for i in range(f+1):
  for j in [a*100,b*100]:
    if dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if dp[i-j]!=-1 and 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
      dp[i]=max(dp[i],dp[i-j]+j)
stack=0
index=0
for i in range(f+1):
  if dp[i]!=0:
    if stack<dp[i]*100//(i-dp[i]):
      stack=dp[i]*100//(i-dp[i])
      index=i
print(index,dp[index])

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
dp=[-1]*(f+1)
dp[0]=0
flag=True
for i in range(1,f+1):
  for j in [a*100,b*100]:
    if i-j>=0 and dp[i-j]!=-1:
      dp[i]=max(0,dp[i])
  for j in [c,d]:
    if i-j>=0 and dp[i-j]!=-1:
      if 100*(dp[i-j]+j)<=e*(i-(dp[i-j]+j)):
        dp[i]=max(dp[i],dp[i-j]+j)
      else:
        for k in [a*100,b*100]:
          if i-k-j>=0 and dp[i-k-j]!=-1:
            if 100*(dp[i-k-j]+j)<=e*(i-(dp[i-k-j]+j)):
              dp[i]=max(dp[i],dp[i-k-j]+j)
stack=0
index=min(a*100,b*100)
for i in range(index+1,f+1):
  if dp[i]>0:
    if stack<(dp[i]*100)/i:
      stack=(dp[i]*100)/i
      index=i
print(index,dp[index])