Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def dfs(i, f, sum, s):
    if i == 3:
        if sum == 7:
            print(f+"=7")
            exit()

    dfs(i+1, f+"-"+s[i+1], sum - int(s[i+1]), s)
    dfs(i+1, f+"+"+s[i+1], sum + int(s[i+1]), s)

def main():
    s = input()

    dfs(0, s[0], int(s[0]), s)
    
if __name__ == '__main__':
    main()


Fixed submission:
def dfs(i, f, sum, s):
    if i == 3:
        if sum == 7:
            print(f+"=7")
            exit()
        return

    dfs(i+1, f+"-"+s[i+1], sum - int(s[i+1]), s)
    dfs(i+1, f+"+"+s[i+1], sum + int(s[i+1]), s)

def main():
    s = input()

    dfs(0, s[0], int(s[0]), s)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import re
s=input().replace("?",".")
t=input()
for i in range(len(s)-lent(t)+1):
  if re.match(s[i:i+len(t)],t):
    s=s.replace(".","a")
    print(s[:i]+t+s[i+len(t):])
    exit()
print("UNRESTORABLE")

Fixed submission:
sd = input()
t = input()

n = len(sd)
m = len(t)
s = []

# sd を後ろから見ていき、 t の入りそうな場所を探す
for i in range(n - m, -1, -1):
    t_kamo = sd[i:i + m]
    for j in range(m + 1):
        # 1文字ずつ順に入りうるか調べ、最後まで入るなら "?" を "a" に置き換えて出力
        if j == m:
            print((sd[:i] + t + sd[i + len(t):]).replace("?", "a"))
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break

print("UNRESTORABLE")
Buggy python submission (verdict: Runtime Error):
n=int(input())
d=Counter(map(int,input().split()))
m=int(input())
t=Counter(map(int,input().split()))

from collections import Counter
for i in t:
  if d[i] < t[i]:
    print('NO')
    exit()
print('YES')


Fixed submission:
from collections import Counter
n=int(input())
d=Counter(map(int,input().split()))
m=int(input())
t=Counter(map(int,input().split()))
for i in t:
  if d[i] < t[i]:
    print('NO')
    exit()
print('YES')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=sorted(list(map(int,input().split())) for _ in range(n))
print(sum(a[-1])

Fixed submission:
n=int(input())
a=sorted(list(map(int,input().split())) for _ in range(n))
print(sum(a[-1]))
Buggy python submission (verdict: Runtime Error):
print(sum(1-eval(input().replace(" ", "-")) for _ in range(int(input())))

Fixed submission:
print(sum(1-eval(input().replace(" ","-")) for _ in range(int(input()))))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=set()
for i in range(n):
  s^={input()}
print(len(s))

Fixed submission:
from collections import Counter
N=int(input())
A=Counter([int(input()) for i in range(N)])
print(sum(1 if count%2 else 0 for count in A.values()))
Buggy python submission (verdict: Runtime Error):
import heapq
n=int(input())
s=set()
q=[0,0]
for a in map(int,input().split()):
  if a>q[0]:
    heapq.heapreplace(q,a)
print(q[0]*a[1])

Fixed submission:
from collections import Counter
N=int(input())
A=Counter(list(map(int,input().split())))
x=[0,0]
for a in A:
    if A[a]>1:x.append(a)
    if A[a]>3:x.append(a)
x.sort()
print(x[-1]*x[-2])
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)
N=int(input())
ans=1
for i in range(N):
    t=int(input())
    ans=lcm(ans,t)
print(ans)　

Fixed submission:
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)
N=int(input())
ans=1
for i in range(N):
    t=int(input())
    ans=lcm(ans,t)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b*, c = input()
print(a+str(len(b))+c)

Fixed submission:
a, *b, c = input()
print(a+str(len(b))+c)
Buggy python submission (verdict: Runtime Error):
a=list(input())
a.sort()
print(int(a[0])+int(a[1]))

Fixed submission:
a=list(map(int,input().split()))
a.sort()
print(a[0]+a[1])

Buggy python submission (verdict: Runtime Error):
a=list(int(input()))
a.sort()
print(a[0]+a[1])

Fixed submission:
a=list(map(int,input().split()))
a.sort()
print(a[0]+a[1])
Buggy python submission (verdict: Runtime Error):
s=list(input())
while len(s) != 0:
  s.pop()
  if len(s)%2==0 and s[:len(s)//2]==s[len(s)//2:]:
    print(len(s)
    exit()

Fixed submission:
s=list(input())
while len(s) != 0:
  s.pop()
  if len(s)%2==0 and s[:len(s)//2]==s[len(s)//2:]:
    print(len(s))
    exit()
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
print(*A[::-2],*A[N%2::2])

Fixed submission:
N=int(input())
A=list(input().split())
s = " ".join(A[::-2]) + " " + " ".join(A[N%2::2])
print(s)

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

for i in range(n):
  b.append(a[i])
  b.reverse()
print(*b)

Fixed submission:
N=int(input())
A=list(input().split())
s = " ".join(A[::-2]) + " " + " ".join(A[N%2::2])
print(s)

Buggy python submission (verdict: Runtime Error):
from collectiojns import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()

for i in range(n):
  b.append(a[i])
  b=[::-1]
print(*b)

Fixed submission:
N=int(input())
A=list(input().split())
s = " ".join(A[::-2]) + " " + " ".join(A[N%2::2])
print(s)

Buggy python submission (verdict: Runtime Error):
from collectiojns import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()

for i in range(n):
  b.append(a[i])
  b=[b::-1]
print(*b)

Fixed submission:
N=int(input())
A=list(input().split())
s = " ".join(A[::-2]) + " " + " ".join(A[N%2::2])
print(s)
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    s = list(input())
    left = 0
    right = 0
    for i in range(n):
        if s[i] == '(':
            right += 1
        else:
            if right == 0:
                left += 1
            else:
                right -= 1
    res = ''
    print('('*left+s+')'*right)

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = input()
    left = 0
    right = 0
    for i in range(n):
        if s[i] == '(':
            right += 1
        else:
            if right == 0:
                left += 1
            else:
                right -= 1
    print('('*left+s+')'*right)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #a = r.split()
    #a = list(map(int, r.split()))
    a, b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    if a+b >= 10:
        pritn('error')
    else:
        print(a+b)        

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #a = r.split()
    #a = list(map(int, r.split()))
    a, b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    if a+b >= 10:
        print('error')
    else:
        print(a+b)        

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
x=int(input())
ans=0
while i < x:
    i+=ans
    ans+=1
print(ans-1)


Fixed submission:
x=int(input())
ans,i=0,0
while i < x:
    i+=ans
    ans+=1
print(ans-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
flg = True
if n%2==0:
  if 0 in a or len(set(a))!=n//2:
    flg=False
else:
  if len([0 for i in a if a==0])!=1 or len(set(a))!~n//2+1:
    flg=False
if flg:
  print(2**(n//2)%(10**9+7))
else:
  print(0)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
flg = True
if n%2==0:
  if 0 in a or len(set(a))!=n//2:
    flg=False
else:
  if len([0 for i in a if i==0])!=1 or len(set(a))!=n//2+1:
    flg=False
if flg:
  print(2**(n//2)%(10**9+7))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
flg = True
if n%2==0:
  if 0 in a or len(set(a))!=n//2:
    flg=False
  else:
    if len([0 for i in a if a==0])!=1 or len(set(a))!~n//2+1:
      flg=False
  if flg:
    print(2**(n//2)%(10**9+7))
  else:
    print(0)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
flg = True
if n%2==0:
  if 0 in a or len(set(a))!=n//2:
    flg=False
else:
  if len([0 for i in a if i==0])!=1 or len(set(a))!=n//2+1:
    flg=False
if flg:
  print(2**(n//2)%(10**9+7))
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
from sys import platform, stdin, setrecursionlimit

if platform =='ios':
    stdin=open('input.txt')
    
#------------------------------------#

def main():
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = input()
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    a,b = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    res = 0
  
    r = [input() for i in range(b)]
    
    for i in r:
    	print(i+"\n"+i)
    
    
if __name__ == '__main__':
    main()

Fixed submission:
h,w=map(int,input().split())
for i in range(h):
    s=input()
    print(s+"\n"+s)
Buggy python submission (verdict: Runtime Error):
def main():
    s = list(input())
    k = int(input())

    for i in range(len(s)):
        mod = 26-(ord(s[i])-97)%26
        if k >= mod:
            k -= mod
            s[i] = 'a'
        if k == 0:
            break
    
    if k > 0:
        mod = (ord(s[-1])-97)%26+k
        s[-1] = chr(mod+97)
    print(''.join(s))

if __name__ == '__main__':
    main()



Fixed submission:
def main():
    s = list(input())
    k = int(input())

    for i in range(len(s)-1):
        if s[i] == 'a':
            continue
        else:
            mod = 26-(ord(s[i])-97)%26
            if k >= mod:
                k -= mod
                s[i] = 'a'
            if k == 0:
                break
    
    if k > 0:
        mod = ((ord(s[-1])-97)+k)%26
        s[-1] = chr(mod+97)
    print(''.join(s))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
if a <= 0 and b >= 0:
    print('Zero')
else:
    cnt = len([1 for i in range(a,b+1) if i < 0])
    if cnt % 2 == 0:
        print('Positive')
    else:
        print('Negative')

Fixed submission:
a,b = map(int,input().split())
if a <= 0 and b >= 0:
    print('Zero')
elif a == 0 or b == 0:
    print('Zero')
elif a > 0:
    print('Positive')
else:
    if (b-a) % 2 != 0:
        print('Positive')
    else:
        print('Negative')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
THE_NUM = 10**6 + 1

dp = [True] * THE_NUM

prev_num = -1
for i in A:
  # if the same number appears as before, that number cannot be counted in the answer.
  if prev_num == i:
    dp[i] = False
  prev_num = i
  for j in range(i * 2, THE_NUM, i):
    dp[j] = False

ans = 0
for i in A:
  # the same number after the second will not counted in the answer.
  if dp[i] == True:
    ans += 1

print(ans)


Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
THE_NUM = 10**6 + 1

dp = [True] * THE_NUM

prev_num = -1
for i in A:
  # if the same number appears as before, that number cannot be counted in the answer.
  if prev_num != i:
    for j in range(i * 2, THE_NUM, i):
      dp[j] = False
  else:
    dp[i] = False
  prev_num = i

ans = 0
for i in A:
  # the same number after the second will not counted in the answer.
  if dp[i] == True:
    ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, K = map(int, input().split())
seq = list(range(1,N + 1))
cand = list(itertools.product(seq, repeat=3))
ans = 0
for c in cand:
  ab = c[0] + c[1]
  bc = c[1] + c[2]
  ca = c[2] + c[0]
  if ab % K == 0 and bc % K == 0 and ca % K == 0:
    ans += 1
print(ans)

Fixed submission:
N, K = map(int, input().split())
p1 = N // K
p2 = 0
if K % 2 == 0:
  p2 = (N + (K // 2)) // K
print(p1**3 + p2**3)
Buggy python submission (verdict: Runtime Error):
N = int(input())
i = int(input())
print(N - i + 1)

Fixed submission:
N,i = map(int, input().split())
print(N - i + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(0)
for idx in range(1,len(a) + 1):
  s.append(s[idx-1] + a[idx-1])

cnt = 0
for l in range(1, n+1):
  for r in range(l, n+1):
    if (s[r] - s[l-1]) % m == 0:
      cnt += 1
print(cnt)


Fixed submission:
n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(0)
for idx in range(len(a)):
  s.append((s[idx] + a[idx]) % m)

c = {0:1}
ans = 0
for l in range(1, n+1):
  ans += c.get(s[l],0)
  c[s[l]] = c.get(s[l],0) + 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(0)
for idx in range(1,len(a) + 1):
  s.append(s[idx-1] + a[idx-1])

cnt = 0
for l in range(1, n+1):
  for r in range(l, n+1):
    if (s[r] - s[l-1]) % m == 0:
      cnt += 1
print(cnt)


Fixed submission:
n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(0)
for idx in range(len(a)):
  s.append((s[idx] + a[idx]) % m)

c = {0:1}
ans = 0
for l in range(1, n+1):
  ans += c.get(s[l],0)
  c[s[l]] = c.get(s[l],0) + 1
print(ans)

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

cnt = 0
for l in range(n):
  for r in range(l, n):
    if sum(a[l:r+1]) % m == 0:
      cnt += 1
print(cnt)


Fixed submission:
n,m = map(int, input().split())
a = list(map(int, input().split()))
# 累積和
s = []
s.append(0)
for idx in range(len(a)):
  s.append((s[idx] + a[idx]) % m)

c = {0:1}
ans = 0
for l in range(1, n+1):
  ans += c.get(s[l],0)
  c[s[l]] = c.get(s[l],0) + 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
dp = [[0 for _ in range(len(s) + 1)] for _ in range(4)]
# 0文字目までで0個の照合が住んだ数
dp[0][0] = 1
for i in range(0,4):
  for j in range(1, len(s) + 1):
    # ABCを進めない道
    if s[j-1] == '?':
      dp[i][j] += dp[i][j - 1] * 3
    else:
      dp[i][j] += dp[i][j - 1]
    # ABCを進める道
    if 0 < i and (s[j - 1] == '?' or s[j - 1] == 'ABC'[i - 1]):
      dp[i][j] += dp[i - 1][j - 1]

print(dp[3][len(s)] % 1000000007)


Fixed submission:
s = input()
dp = [[0 for _ in range(len(s) + 1)] for _ in range(4)]
# 0文字目までで0個の照合が住んだ数
dp[0][0] = 1
for i in range(0,4):
  for j in range(1, len(s) + 1):
    # ABCを進めない道
    if s[j-1] == '?':
      dp[i][j] += dp[i][j - 1] * 3
    else:
      dp[i][j] += dp[i][j - 1]
    # ABCを進める道
    if 0 < i and (s[j - 1] == '?' or s[j - 1] == 'ABC'[i - 1]):
      dp[i][j] += dp[i - 1][j - 1]
    dp[i][j] %= 1000000007

print(dp[3][len(s)])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = []
b.append(a[0])
for mid in range(1, len(a)):
  b.append(b[mid - 1] + a[mid])
ans = 10**9

# 累積和から閉区間の合計を求める
def g_sum(l, r):
  if r < l:
    return 0
  res = b[r]
  if l != 0:
    res -= b[l-1]
  return res

lef = 1
rit = 2
for mid in range(2, n - 1):
  # 左
  while abs(g_sum(0, lef - 1) - g_sum(lef, mid - 1)) > abs(g_sum(0, lef) - g_sum(lef, mid - 1)):
    lef += 1
  # 右
  while abs(g_sum(mid, rit - 1) - g_sum(rit, n - 1)) > abs(g_sum(mid, rit) - g_sum(rit, n - 1)):
    rit += 1
  # 各区間の計算
  P = g_sum(0,lef - 1)
  Q = g_sum(lef, mid - 1)
  R = g_sum(mid, rit - 1)
  S = g_sum(rit, n - 1)
  # 最小値算出
  ans = min(ans, max(P,Q,R,S) - min(P,Q,R,S))
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = []
b.append(a[0])
for mid in range(1, len(a)):
  b.append(b[mid - 1] + a[mid])
ans = 10**9

# 累積和から閉区間の合計を求める
def g_sum(l, r):
  if r < l:
    return 0
  res = b[r]
  if l != 0:
    res -= b[l-1]
  return res

lef = 1
rit = 2
for mid in range(2, n - 1):
  # 左
  while abs(g_sum(0, lef - 1) - g_sum(lef, mid - 1)) > abs(g_sum(0, lef) - g_sum(lef + 1, mid - 1)):
    lef += 1
  # 右
  while abs(g_sum(mid, rit - 1) - g_sum(rit, n - 1)) > abs(g_sum(mid, rit) - g_sum(rit + 1, n - 1)):
    rit += 1
  # 各区間の計算
  P = g_sum(0,lef - 1)
  Q = g_sum(lef, mid - 1)
  R = g_sum(mid, rit - 1)
  S = g_sum(rit, n - 1)
  # 最小値算出
  ans = min(ans, max(P,Q,R,S) - min(P,Q,R,S))
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
dp = [0 for _ in range(N+1)]

def dfs(n):
  if n <= 0:
    return 0
  elif dp[n] > 0:
    return dp[n]
  dp[n] = dfs(n - 1) + 1
  x = 6
  while x <= n:
    dp[n] = min(dp[n],dfs(n - x) + 1)
    x *= x
  x = 9
  while x <= n:
    dp[n] = min(dp[n], dfs(n - x) + 1)
    x *= x
  return dp[n]

print(dfs(N))

Fixed submission:
n = int(input())
dp = [i for i in range(n + 1)]

for i in range(1, n + 1):
  for j in range(1, i + 1):
    if i >= 9**j:
      dp[i] = min(dp[i], dp[i - 9**j] + 1)
    else:
      break
  for k in range(1, i + 1):
    if i >= 6**k:
      dp[i] = min(dp[i], dp[i - 6**k] + 1)
    else:
      break

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for _n in range(n):
  sm = 0
  x = 0
  for i,_a in enumerate(a):
    if _n == i: 
      continue
    sm += abs(_a - x)
    x = _a
  sm += abs(x)
  print(sm)

Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
sm = 0
x = 0
for _a in a:
  sm += abs(_a - x)
  x = _a
for i in range(1,n + 1):
  print(sm - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())), reverse=True)

ans = 0
for b in B:
    a_num = 0
    c_num = 0
    for a in A:
        if a < b:
            a_num += 1
        else:
            break
    for c in C:
        if b < c:
            c_num += 1
        else:
            break
    ans += a_num * c_num

print(ans)


Fixed submission:
import bisect

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    a_num = bisect.bisect_left(A, b)
    c_num = N - bisect.bisect_right(C, b)
    ans += a_num * c_num

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    a_ = len(list(filter(lambda x:x < b, A)))
    c_ = len(list(filter(lambda x:x > b, C)))
    ans += a_ * c_

print(ans)


Fixed submission:
import bisect

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    a_num = bisect.bisect_left(A, b)
    c_num = N - bisect.bisect_right(C, b)
    ans += a_num * c_num

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

waters = set()
for i in range(F + 1):
    for j in range(F + 1):
        water = 100 * A * i + 100 * B * j
        if water <= F:
            waters.add(water)
waters.remove(0)

sugars = set()
for i in range(F + 1):
    for j in range(F + 1):
        sugar = C * i + D * j
        if sugar <= F:
            sugars.add(sugar)

max_percentage = 0
max_water = 0
max_sugar = 0
limit_percentage = (100 * E) / (100 + E)

for water in waters:
    for sugar in sugars:
        percentage = (100 * sugar) / (water + sugar)
        if max_percentage < percentage <= limit_percentage and water + sugar <= F:
            max_percentage = percentage
            max_water = water
            max_sugar = sugar

print('{} {}'.format(max_water + max_sugar, max_sugar))

Fixed submission:
def concentration(water, suger):
  return 100 * suger / (water + suger)

WATER_A, WATER_B, SUGER_C, SUGER_D, MELT_PER_100, LIMIT = map(int, input().split())

WATER_A *= 100
WATER_B *= 100
# 砂糖の溶解率の上限
MELT_PERCENT_LIMIT = concentration(100, MELT_PER_100)

wa = wb = sc = sd = 0

water_set = set()
while wa * WATER_A <= LIMIT:
  while wb * WATER_B <= LIMIT:
    water = wa * WATER_A + wb * WATER_B
    if water <= LIMIT:
      water_set.add(water)
    wb += 1
  wb = 0
  wa += 1

suger_set = set()
while sc * SUGER_C <= LIMIT:
  while sd * SUGER_D <= LIMIT:
    suger = sc * SUGER_C + sd * SUGER_D
    if suger <= LIMIT:
      suger_set.add(suger)
    sd += 1
  sd = 0
  sc += 1

ans_suger_water = 0
ans_suger = 0
# 最大溶解率を保持するための変数
max_concentration = 0

for water in water_set:
  for suger in suger_set:
    # 砂糖水の量が0より大きく制限量以下以外の場合は次のループへ
    if not (0 < water + suger <= LIMIT):
      continue
    # 砂糖濃度計算
    suger_precent = concentration(water, suger)
    # 砂糖濃度が最高を更新かつ限界濃度を超えていなければ答えを更新
    if max_concentration <= suger_precent <= MELT_PERCENT_LIMIT:
      max_concentration = suger_precent
      ans_suger_water = water + suger
      ans_suger = suger

print(ans_suger_water, ans_suger)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

paper = []

for a in A:
  if a in paper:
    paper.remove(a)
  else:
    paper.append(a)

print(len(paper))

Fixed submission:
from collections import Counter

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

answer = 0
for number, count in counter.items():
    if count % 2 != 0:
        answer += 1

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

min_diff = float('inf')

for i in range(1, N):
  l_sum = sum(a[:i])
  r_sum = sum(a[i:])
  min_diff = min(min_diff, abs(l_sum - r_sum))

print(min_diff)


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

min_diff = float('inf')
a_sum = sum(a)
l_sum = 0

for i in range(N - 1):
  l_sum += a[i]
  min_diff = min(min_diff, abs(l_sum * 2 - a_sum))

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

for i in range(n):
  b.append(a.pop(0))
  b = b[::-1]

print(' '.join(map(str, b)))

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

a_even = [elm_a for i, elm_a in enumerate(a) if i % 2 == 0]
a_odd = [elm_a for i, elm_a in enumerate(a) if i % 2 == 1]

ans = a_even[::-1] + a_odd
if n % 2 == 0:
  ans = ans[::-1]

print(' '.join(map(str, ans)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
T = []
A = []

for _ in range(N):
    t, a = list(map(int, input().split()))
    T.append(t)
    A.append(a)

t_num = 1
a_num = 1
for i in range(N):
    # TAは常にn倍ずつ増加していく
    n = 1
    while T[i] * n < t_num or A[i] * n < a_num:
        n += 1
    t_num = T[i] * n
    a_num = A[i] * n

print(t_num + a_num)


Fixed submission:
from math import ceil

N = int(input())
T = []
A = []

for _ in range(N):
    t, a = list(map(int, input().split()))
    T.append(t)
    A.append(a)

t_num = T[0]
a_num = A[0]
for i in range(1, N):
    tn = (t_num + T[i] - 1) // T[i]
    an = (a_num + A[i] - 1) // A[i]
    n = max(tn, an)
    t_num = T[i] * n
    a_num = A[i] * n

print(t_num + a_num)