Harryxun/stf_run huggingface dataset:
import sys
import math
def ncr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
    return int(result)

x,y= (int(_) for _ in input().split()) 
if (x+y)%3!=0:
    print(0)
    sys.exit()
else:
    n=(x+y)/3
    n=int(n)
    if x<n or y<n:
         print(0)
         sys.exit()
    else:
        x=x-n
        y=y-n
        ans=(ncr(x+y,x))
        print(ans%1000000007)


### FIXED CODE ###

import sys
import math
from operator import mul
from functools import reduce
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**6
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

x,y= (int(_) for _ in input().split()) 
if (x+y)%3!=0:
    print(0)
    sys.exit()
else:
    n=(x+y)/3
    n=int(n)
    if x<n or y<n:
         print(0)
         sys.exit()
    else:
        x=x-n
        y=y-n
        ans=int(cmb(x+y, x,mod))
        print(ans%1000000007)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans=0
j=M
for i in range(N + 1): 
	if a[i]>K:
    	break
	while b[j] > K - a[i]:
    	j -= 1
	ans = max(ans, i + j)
print(ans)


### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans,j=0,M
for i in range(N + 1): 
	if a[i]>K:
    		break
	while b[j] > K - a[i]:
    		j -= 1
	ans = max(ans, i + j)
print(ans)
A,B,K = map(int,input().split())
x = []
if A >= B:
  for i in range(1,A):
    if A % i == 0 and B % i == 0:
      x.append(i)
else:
  for i in range(1,B):
    if A % i == 0 and B % i == 0:
      x.append(i)
print(x[-K])
  

### FIXED CODE ###

a, b, k = map(int, input().split())
print([i for i in range(1,101) if a%i+b%i<1][-k])
n=int(input())
a=input()
b=input()
c=input()
al=list(a)
bl=list(b)
cl=list(c)

count=0

for i in range(n):
    if al[i]==bl[i]:
        if al[i]==cl[i]:
            plus=2
        else:
            plus=1
    elif bl[i]==cl[i]:
        plus=1
    elif al[i]==cl[i]:
        plus=1
    else:
        plus=0
        
    count+=plus
    
print(count)

### FIXED CODE ###

n,a,b=map(int,input().split())
mxs=min(a,b)
mns=max(0,a+b-n)
print(mxs,mns)
def rec(n):
    if n == 1:
        return 1
    return rec(n-1) + 1

print(rec(2000))


### FIXED CODE ###

A, B = map(int, input().split())
print(max(A*2-1,A+B,B*2-1))
s = list(input())

if len(s) % 2 != 0:
  if len(s) / 2 > len(s)//2:
    s.pop(len(s)//2+1) 
  else:
    s.pop(len(s)//2-1) 
    

s1List = s[:len(s)//2][::-1] 
s2List = s[len(s)//2:]

count = 0
for i in range(len(s1List)):
  if s1List[i] != s2List[i]:
    count += 1
  
print(count)


### FIXED CODE ###

s = list(input())

count = 0
for i in range(len(s)//2):
  if s[i] != s[-1-i]:
    count+=1

print(count)
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for li in range(l):
    print(" ".join([str(s) for s in C[li]]))

### FIXED CODE ###

n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for li in range(n):
    print(" ".join([str(s) for s in C[li]]))
S = input()
K = int(input())
if K == 1 and S[0] == "1":
  print(1)
elif S[0] == "1":
  print(S[1])
else:
  print(S[0])


### FIXED CODE ###

A,B = map(int,input().split())
S = (A-1) * (B-1)
print(S)
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
a,b = input().split()
a = int(a)
b100 = 100*int(b[0]) + 10*int(b[1]) +int(b[2])

print(a*b100//100)


### FIXED CODE ###

ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
a,b = input().split()
a = int(a)
b100 = 100*int(b[0]) + 10*int(b[2]) +int(b[3])

print(a*b100//100)
import numpy as np
BIG_NUM = 10**9+7
def stairs_n(n):
    if n <= 3:
        return n
    else:
        return stairs_n(n-1)+stairs_n(n-2)

#print(stairs_n(30))

n,m = map(int,input().split())

if m == 0:
    print(stairs_n(n)%BIG_NUM)
else:


    a_list = [int(input()) for _ in range(m)]
    a_list.append(n)
    a_list.insert(0,1)
    a_np = np.array(a_list)
    diff_a_np = np.diff(a_np)-1
    ans = 1
    # print(a_np)
    # print(diff_a_np)
    for num in diff_a_np:
        ans *= stairs_n(num)

    print(ans%BIG_NUM)

### FIXED CODE ###

N, M = map(int,input().split())
dp = [0]*(N+1)
broke = [0]*(N+1)
dp[0] = 1
dp[1] = 1

for _ in range(M):
    a = int(input())
    broke[a] = -1

for i in range(N-1):
    if broke[i] != -1 and broke[i+1] != -1:
        dp[i+2] = dp[i+1] + dp[i]
    elif broke[i] == -1and broke[i+1] != -1:
        dp[i+2] = dp[i+1]
    elif broke[i+1] == -1and broke[i] != -1:
        dp[i+2] = dp[i]
    else:
        print(0)
        exit()
# print(broke)
# print(dp)
MOD = 10**9+7
print(dp[N]%MOD)
n,m=map(int,input().split())
num = [1]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC'
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
else:
    WA_cnt += 1
print(AC_cnt,WA_cnt)


### FIXED CODE ###

n,m=map(int,input().split())
num = [1]*(n + 1)
pena = [0]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC':
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
            WA_cnt += pena[int(p)]
    else:
        pena[int(p)] += 1
print(AC_cnt,WA_cnt)
import math


def solve():
    A, B, N = map(float, input().split())

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, int(N)-100000)*A)/B
    init_2 = max(1, int(N)-100000)/B
    start = max(1, int(N)-100000)

    for i in range(max(1, int(N)-100000), int(N) + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)
    if N > B:
        start = max(B-100000,1)
        init_1 = (max(1, int(B-100000)) * A) / B
        init_2 = max(1, int(B-100000)) / B
        for i in range(max(int(B)-100000,1), max(N,int(B)+1)):
            ans = max(math.floor(init_1 + div_ab * (i - start)) - A * math.floor(init_2 + div_1b * (i - start)), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def solve():
    A,B,N = map(int, input().split())
    if N < B-1:
        print((A*N)//B - A * (N//B))
    else:
        print(((A*(B-1))//B) - A* ((B-1)//B))


if __name__ == "__main__":
    solve()
l = list(input())
n=0
for int(i) in l :
  if int(i)==1:
    print(i)
    n += 1
print(n)

### FIXED CODE ###

l = list(input())
n=0
for i in l :
  if int(i)==1:
    n += 1
print(n)
import sys
input = sys.stdin.readline
import numpy as np

A,B = map(int,input().split())

print(int(np.lcm(A,B)))

### FIXED CODE ###

import sys
input = sys.stdin.readline

A,B = map(int,input().split())

abs = 1
for i in list(range(1,min(A,B)+1))[::-1]:
    if A%i==0 and B%i==0:
        abs = i
        break

print(int(A*B/abs))
def first_three(str):
	return str[:3] if len(str) > 3 else str
  
  val = input()
 print(first_three(val))


### FIXED CODE ###

def first_three(str):
	return str[:3] if len(str) > 3 else str
  
val = input()
print(first_three(val))
n,k=map(int, input().split())
a=list(map(int, input().split()))
alist=[]
i=1
while a[i-1] not in alist:
  i=a[i-1]
  alist.append(i)
loop1=alist.index(a[i-1])
if k<loop1+1:
  print(alist[k-1])
else:
  lenloop=len(alist)-loop1
  print(alist[((k-loop1-1)%lenroop)+loop1])

### FIXED CODE ###

n,k=map(int, input().split())
a=list(map(int, input().split()))
alist=[]
cnt=0
i=1
blist=[0]*(n+1)
while blist[a[i-1]]==0:
  i=a[i-1]
  alist.append(i)
  blist[i]=1
  cnt+=1
loop1=alist.index(a[i-1])
if k<loop1+1:
  print(alist[k-1])
else:
  print(alist[((k-loop1-1)%(cnt-loop1))+loop1])
# coding: utf-8
# Your code here!
from collections import defaultdict
n,q = map(int,input().split())
direct_dict = defaultdict(list)
for i in range(n-1):
    a,b = map(int,input().split())
    direct_dict[a - 1].append(b - 1)
ans_list = [0 for i in range(n)]
node_point = [0 for i in range(n)]
for i in range(q):
    p,x = map(int,input().split())
    node_point[p-1] += x
    
def get_point(pos, now):
    ans_list[pos] = now + node_point[pos]
    for next_pos in direct_dict[pos]:
        get_point(next_pos, now + node_point[pos])

get_point(0, 0)
for i in ans_list:
    print(str(i)+" ", end="")

    

### FIXED CODE ###

n,q = map(int,input().split())
m = [[] for i in range(n)]
for _ in range(n-1):
   a,b = map(int,input().split())
   m[a-1].append(b-1)
   m[b-1].append(a-1)

from collections import defaultdict
dic = defaultdict(int)
for _ in range(q):
   p,x = map(int,input().split())
   dic[p-1] += x

ans = [0 for i in range(n)]
ans[0] = dic[0]

used = [0 for i in range(n)]
used[0] = 1
quu = [0]
while quu:
   k = quu.pop()
   for l in m[k]:
      if used[l] == 0:
         used[l] = 1
         quu.append(l)
         ans[l] = ans[k] + dic[l]

for i in ans:
   print(i)
n, m = map(int,input().split())
p = [0] * m
s = [0] * m
for i in range(m):
    p[i], s[i] = map(str, input().split())
for i in range(m):
    p[i] = int(p[i])

ans1 = 0
ans2 = 0

aclis = [0] * n
walis = [0] * n
ac = 1s


for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = True
        

    if aclis[p[i]] == 0:
        walis[p[i]] += 1
ans1 = aclis.count('True')

for i in range(n):
    if aclis[i] == True:
        ans2 += walis[i]

print(ans1, ans2)

### FIXED CODE ###

n, m = map(int,input().split())
p = [0] * m
s = [0] * m
for i in range(m):
    p[i], s[i] = map(str, input().split())
for i in range(m):
    p[i] = int(p[i])

ans1 = 0
ans2 = 0

aclis = [0] * (n+1)
walis = [0] * (n+1)


for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = 1



    elif aclis[p[i]] == 0 and s[i] == 'WA':
        walis[p[i]] += 1
ans1 = aclis.count(1)
#print(aclis)
#print(walis)

for i in range(n+1):
    if aclis[i] == 1:
        ans2 += walis[i]


print(ans1, ans2)
from sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = int(A[0] * A[1] / fractions.gcd(A[0], A[1]))

if len(A) > 2:
    for k in A[2:]:
        lcm_a = int(lcm_a * k / fractions.gcd(lcm_a, k))

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)


### FIXED CODE ###

from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = A[0] * A[1]

if len(A) > 2:
    for k in A[2:]:
        lcm_a = lcm_a * k

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)
N, M = [int(i) for i in input().split()]

def initTable(N,M):
    table = [['.'] * M for i in range(N)]
    return table

def flipCard(row, column, table):
    for r in range(3):
        for c in range(3):
            if row + (r-1) < 0 or column + (c-1) < 0:
                pass
            elif row + (r-1) >= N or column + (c-1) >= M:
                pass
            else:
                card = table[row + (r-1)][column + (c-1)]
                if card == '.':
                    card = '#'
                else :
                    card = '.'
                table[row + (r-1)][column + (c-1)] = card
    return table

table = initTable(N, M)

for row in range(N):
    for column in range(M):
        table = flipCard(row, column, table)
        
cnt = 0
for row in table:
    cnt += row.count('#')

print(cnt)

### FIXED CODE ###

n, m = [int(i) for i in input().split()]

n = 1 if n < 2 else n - 2
m = 1 if m < 2 else m - 2

print(n * m)
n,k=map(int,input().split())
s=list(input())
s[k]=s[k].lower()
s="".join(s)
print(s)

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
s="".join(s)
print(s)
class PrimeChecker:

    def __init__(self):
        self.primes = [2,3,5]

    def isPrime(self, n):
        if n in self.primes:
            return True
        else:
            for i in self.primes:
                if n % i == 0:
                    return False

        i = self.primes[-1]
        w = 2 if i % 6 == 5 else 4

        while i * i <= n:
            if self.isPrime(i,n) and n % i == 0:
                return False

            i += w
            w = 6 - w

        self.primes.append(n)

        return True

primeChecker = PrimeChecker()
count = 0
N = int(input())
for _ in range(N):
    if primeChecker.isPrime((int(input()))):
        count += 1
print(count)
        


### FIXED CODE ###

f=lambda x: 1 if x == 2 or x == 3 or (x>3 and x&1==1 and pow(2, x-1, x)==1) else 0
print(sum(f(int(input())) for _ in range(int(input()))))
import fractions

def main():
    N=int(input())
    num=list(map(int,input().split()))
    gcd=0
    gcd_list_front=[]
    gcd_list_back=[]
    gcd_list_front.append(num[0])
    gcd_list_back.append(num[-1])

    for  i in range(1,N-1):
        gcd_list_front.append(fractions.gcd(gcd_list_front[i-1],num[i]))
        gcd_list_back.append(fractions.gcd(gcd_list_back[i-1],num[-i-1]))
    gcd_list_back.reverse()

    gcd=max(gcd_list_back[0],gcd_list_front[-1])
    for i in range(0,N-2):
       temp_gcd=fractions.gcd(gcd_list_front[i],gcd_list_back[i+1])
       if temp_gcd>gcd:
           gcd=temp_gcd
    print(gcd)


if  __name__=="__main__":
    main()


### FIXED CODE ###

a,b,t=map(int,input().split())
x=0
num=0
c=a
for i in range(21):
    x=c
    c=a*(i+2)
    #print(x)
    if(x>t):
        break
    num+=b

print(num)
n=input().split()
a=int(n[0])
b=int(n[1])
c=int(n[2])
count=0
while i <=a+b:
     if c/i==0:
       count=i+1
print(count)


### FIXED CODE ###

x=input().split(" ")
a=int(x[0])
b=int(x[1])
c=int(x[2])
count=0
for i in range(a,b+1):
  if c%i==0:
   count+=1
print(count)
l = [input() for _ in [0] * 5]
keta =[]
for i in l:
    keta.append(i)
#print(keta)
xxx = []
for j in keta:
    if int(j[-1]) != 0:
        xxx.append(int(j) + (10 - int(j[-1])))
    else:
        xxx.append(int(j))
#print(xxx)
yyy = []
for k in keta:
    yyy.append(int(k[-1]))
zzz = []
for l in yyy:
    if int(l) > 0:
        zzz.append(l)
#print(zzz)
p = min(zzz)
print(sum(xxx) - (10 - p))


### FIXED CODE ###

l = [input() for _ in [0] * 5]
keta =[]
for i in l:
    keta.append(i)
#print(keta)
xxx = []
for j in keta:
    if int(j[-1]) != 0:
        xxx.append(int(j) + (10 - int(j[-1])))
    else:
        xxx.append(int(j))
#print(xxx)
yyy = []
for k in keta:
    yyy.append(int(k[-1]))
#print(yyy)
zzz = []
for m in yyy:
    if int(m) > 0:
        zzz.append(m)
#print(zzz)
if 0 < sum(zzz):
    p = min(zzz)
    print(sum(xxx) - (10 - p))
else:
    p = 0
    print(sum(xxx))
import numpy as np
def nroot(a, n, x=1.0, eps=1e-14):
    x = np.sqrt(a)
    while abs(a - x**n) > eps:
        x = ( (n-1)*x + a/(x**(n-1)) ) / n
    return x
a,b,c = map(int, input().split())

print(nroot(2,2))
if nroot(a,2) + nroot(b,2) < nroot(c,2) :
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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


if  c-a-b >0 and (c-a-b)*(c-a-b) > 4*a*b :
    print("Yes")
else:
    print("No")
#coding:utf-8

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

if a % 2 == 1 && b % 2 == 1:
  print('Odd')
else:
  print('Even')

### FIXED CODE ###

#coding:utf-8

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

if a % 2 == 1 and b % 2 == 1:
  print('Odd')
else:
  print('Even')
a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d,r,"{0:.5f}".format)(f)

### FIXED CODE ###

a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d,r,"{0:.5f}".format(f))
from collections import Counter
def solve(N, XY):
    XY = sorted(XY)
    cnt = Counter()
    d = []
    for x0, y0 in XY:
        for x1, y1 in XY:
            if x0 == x1 and y0 == y1:
                continue
            d.append((x0 - x1, y0 - y1))
    m = Counter(d).most_common()[0]
    return len(XY) - m[1]

def main():
    N = int(input())

    XY = []
    for i in range(N):
        XY.append(tuple([int(x) for x in input().split()]))

    print(solve(N, XY))

main()



### FIXED CODE ###

from collections import Counter
def solve(N, XY):
    if N == 1:
        return 1
    XY = sorted(XY)
    cnt = Counter()
    d = []
    for x0, y0 in XY:
        for x1, y1 in XY:
            if x0 == x1 and y0 == y1:
                continue
            d.append((x0 - x1, y0 - y1))
    m = Counter(d).most_common()[0]
    return len(XY) - m[1]

def main():
    N = int(input())

    XY = []
    for i in range(N):
        XY.append(tuple([int(x) for x in input().split()]))

    print(solve(N, XY))

main()
N = int(input())
A = int(input())
B = int(input())

if N==1:
    print("Hello World")
else:
    print(A+B)

### FIXED CODE ###

N = int(input())


if(N == 1):
	print("Hello World")
else:
	A = int(input())
	B = int(input())
	print(A+B)
A = [ int(i) for i in input().split()]

X = [ abs(A[0] - A[1]),abs(A[1] - A[2]),abs(A[0] -A[2])]

X = X.sort()
ans = X[1] + X[2]
print(ans)

### FIXED CODE ###

A1,A2,A3 =(int(i) for i in input().split())

x = abs(A1-A2)
y = abs(A2-A3)
z = abs(A3-A1)

N = [x,y,z]
N.sort()
ans = N[0] + N[1]
print(ans)
n = int(input())

maxv = -2000000000

lst = [int(input()) for _ in range(n)]

minv = lst[0]

for i in range(1, n):
   maxv = max([maxv, lst[i] - minv])
   minv = min([minv, lst[i])

print(maxv)


### FIXED CODE ###

n = int(input())
 
maxv = -2000000000
 
 
minv = int(input())
 
for i in range(1, n):
   cur = int(input())
   maxv = max([maxv, cur - minv])
   minv = min([minv, cur])
 
print(maxv)
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n

for i in range(n):
    ans[a[i]-1]=i+1

print(" ".join(map(str,ans)))

### FIXED CODE ###

n, k = map(int, input().split())

h = list(map(int, input().split()))

ans=0

for i in range(n):
    if h[i]>=k:
        ans+=1

print(ans)
N=int(input())
V=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
res=0
for vv cc in zip(V,C):
  if vv-cc>0:
    res=res+vv-cc
print(res)

### FIXED CODE ###

N=int(input())
V=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
res=0
for vv,cc in zip(V,C):
  if vv-cc>0:
    res=res+vv-cc
print(res)
b = input()
if b = A :
    print( 'T' )
elif b = T :
    print( 'A' )
elif b = G :
    print( 'C' )
elif b = C :
    print( 'G' )
        

### FIXED CODE ###

b = input()
if b == 'A' :
    print( 'T' )
elif b == 'T' :
    print( 'A' )
elif b == 'G' :
    print( 'C' )
elif b == 'C' :
    print( 'G' )
n = int(input())
gsb1 = list(map(int,input().split()))
gsb2 = list(map(int,input().split()))
def trade(n,g1,s1,b1,g2,s2,b2):
  tradelist = []
  for x,y in (g1,g2),(s1,s2),(b1,b2):
    if x < y:
      tradelist.append((x,y))
  if not tradelist:
    return n
  dp = [0]*(n+1)
  for w,v in tradelist:
    for i in range(n+1-w):
      dp[i+w] = max(dp[i+w],dp[i]+v)
  return dp[n]

ans1 = trade(n,*gsb1,*gsb2)
ans2 = trade(ans1,*gsb2,*gsb1)
print(ans2)

### FIXED CODE ###

n = int(input())
g1,s1,b1 = map(int,input().split())
g2,s2,b2 = map(int,input().split())
def trade(n,g1,s1,b1,g2,s2,b2):
  tradelist = []
  for x,y in (g1,g2),(s1,s2),(b1,b2):
    if x < y:
      tradelist.append((x,y))
  if not tradelist:
    return n
  dp = [0]*(n+1)
  for w,v in tradelist:
    for i in range(n+1-w):
      dp[i+w] = max(dp[i+w],dp[i]+v)
  ptr = n
  ret = dp[n]
  while ptr and dp[ptr-1] == dp[n]:
    ret += 1
    ptr -= 1
  return ret

ans1 = trade(n,g1,s1,b1,g2,s2,b2)
ans2 = trade(ans1,g2,s2,b2,g1,s1,b1)
print(ans2)
import sys
sys.setrecursionlimit(10**7)
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)


dp = [[-1] * 10010 for _ in range(110)]


def knap(i, j):
    if dp[i][j] >= 0:
        return dp[i][j]

    if i == N:
        dp[i][j] = 0
    elif j < W[i]:
        dp[i][j] = knap(i+1, j)
    else:
        dp[i][j] = max(knap(i+1, j), knap(i+1, j - W[i]) + V[i])

    return dp[i][j]


print(knap(0, L))


### FIXED CODE ###

N, W = map(int, input().split())
T = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] + [-1] * W for _ in range(N+1)]
dp[0] = [0] * (W+1)

for i in range(1, N+1):
    for w in range(1, W+1):
        dp[i][w] = max(dp[i-1][w], dp[i-1][w - T[i-1][0]] + T[i-1]
                       [1]) if w - T[i-1][0] >= 0 else dp[i-1][w]

# print(*dp, sep='\n')
print(dp[N][W])