Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.

Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation $y = - \frac{x}{m} + b$. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point.

Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely.

Okabe is sure that the answer does not exceed 10^18. You can trust him.


-----Input-----

The first line of input contains two space-separated integers m and b (1 ≤ m ≤ 1000, 1 ≤ b ≤ 10000).


-----Output-----

Print the maximum number of bananas Okabe can get from the trees he cuts.


-----Examples-----
Input
1 5

Output
30

Input
2 3

Output
25



-----Note----- [Image] 

The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.

Difficulty: interview

Starter code:

Solutions:
read = lambda: map(int, input().split())
m, b = read()
ans = -1
def f(x, y):
    return (x * (x + 1) * (y + 1) + y * (y + 1) * (x + 1)) // 2
for k in range(b + 3):
    x = k * m
    y = b - k
    ans = max(ans, f(x, y))
print(ans)

m,b=list(map(int,input().split()))
f=lambda n: n*(n+1)//2
def g(y):
    x=m*(b-y)
    return f(x)*(y+1)+f(y)*(x+1)
print(max(g(y) for y in range(b+1)))


from math import *


def sum(n):
    return (n * (n + 1)) // 2


m, b = [int(x) for x in input().strip().split()]
ans = 0
x = 0
y = 0
while True:
    if b < y:
        break
    x = m * (b - y)
    rans = sum(x) * (y + 1) + sum(y) * (x + 1)
    ans = max(ans, rans)
    y += 1
print(ans)


m,b = map(int, input().split())
mx = 0
for y in range(b, -1, -1):
    x = m * (b - y)
    mx = max(mx, (x + 1) * (y + 1) * (x + y) // 2)
print(mx)

#! python3

m, b = [int(x) for x in input().strip().split(' ')]

r = 0
for y in range(b+1):
    x = (b-y)*m
    p = x*(x+1)//2
    s = p * (y+1) + x * y * (y+1) // 2 + y * (y+1) // 2
    if s > r:
        #print(y)
        r = s
print(r)


m, b = map(int, input().split())
res = 0
for i in range(b + 1):
    res = max(res, (m * i * (m * i + 1) // 2) * (b - i + 1) + ((b - i) * (b - i + 1) // 2) * (m * i + 1))
print(res)

m,b=map(int,input().split(" "))
sm=0
for y in range(0,b+1):
    x=m*(b-y)
    s=(x+y)*(x+1)*(y+1)//2
    sm=max(s,sm)
print(sm)

def sigma(n):
    return n * (n + 1) // 2

def banans(p, q):
    return (p + 1) * sigma(q) + (q + 1) * sigma(p)

m, b = [int(x) for x in input().split()]

r = 0
for i in range(m * b + 1):
    if i % m == 0:
        p, q = i, b - i // m
        r = max(r, banans(p, q))

print(r)

I = lambda : list(map(int, input().split()))
m, b = I()
mx = 0
for y in range(0, 100001):
    x = m*(b-y)
    if x>=0:
        mx = max(mx, (y+1)*x*(x+1)//2 + (x+1)*y*(y+1)//2)
print(mx)


import math

m, bb = [int(item) for item in input().split()]

ans = -1

for a in range(bb + 1):
    b = m * bb - m * a
    ans = max(ans, (a * (a + 1) // 2) * (b + 1) + (b * (b + 1) // 2) * (a + 1))
        
print(ans)

def func(x,y):
	f1 = y*(y+1)//2
	f2 = x*(x+1)//2
	return (x+1)*f1+(y+1)*f2

m,b = input().split()
m=int(m)
b=int(b)
y=b
maxi = 0
for i in range(0,(m*b)+1,m):
	if(func(i,y)>maxi):
		maxi = func(i,y)
	y-=1
print(maxi)

import sys

def main():
    m,b = list(map(int,sys.stdin.readline().split()))
    
    def calc(y):
        x = (b-y)*m
        return ((y*(y+1)*(x+1))>>1) + ((x*(x+1)*(y+1))>>1)
    
    res = 0
    for i in range(b+1):
        t = calc(i)
        if t>res:
            res = t
    print(res)


main()


m,b = list(map(int,input().split()))
x = (b*m)
y = b
ans = 0
for i in range(y):
	xx = (b-i)*m
	ans = max(ans,((xx*(xx+1))//2)*(i+1) + ((i*(i+1))//2)*(xx+1))
print(ans)


import math
m,b=list(map(int,input().split()))
ans=0
for y in range(b+1):
	x=m*(b-y)
	p=((x+1)*(y+1)*(x+y))//2
	ans=max(ans,p)
print(ans)


def calc(x):
    y = - x // m + b
    ret = 0
    fix1 = y * (y + 1) // 2
    ret += fix1 * (x + 1)
    fix2 = x * (x + 1) // 2
    ret += fix2 * (y + 1)
    # print(x, ret)
    return ret

m, b = list(map(int, input().split()))
i = 0
ans = 0
while i <= m * b:
    ans = max(ans, calc(i))
    i += m
print(ans)


def get2(n):
	res = n*(n+1)*(2*n+1)//6 + n*(n+1)//2
	res //= 2;
	return res

def get(x,y):
	return get2(x+y) - get2(x-1) - get2(y-1)

m,b = input().split()
m = int(m)
b = int(b)

mv = 0
for i in range(b+1):
	j = m*b-m*i
	cur = get(j,i)
	if cur > mv:
		mv = cur

print(mv)

def ans(x,y):
    a=int(y*(y+1)/2)
    a=a*(x+1)
    b=int(x*(x+1)/2)
    b=b*(y+1)
    return a+b

def change(i,b):
    if i%b==0:
        return i/b
    return i/b+1

m,b=list(map(int,input().split()))
max=int(-1)

for i in range(0,b+1):
    x=m*(b-i)
    k=ans(i,x)
    if max<k:
        max=k

print(int(max))


m,b=list(map(int,input().split()))
bn=0
for i in range(b):
  bn=max(bn,(m*(b-i)*(m*(b-i)+1)//2)*(i+1)+i*(i+1)//2*(m*(b-i)+1))
print(bn)


#!/usr/bin/env python3
import sys

def main():
    m, b = list(map(int, sys.stdin.readline().split()))
    results = []
    for _x in range(0, b+1):
        x = m * _x
        y = b - _x
        results.append(rectangle_bananas(x, y))
    print(max(results))

def rectangle_bananas(x, y):
    return ((x+1) * (y+1) * (x+y)) // 2

def __starting_point():
    main()

__starting_point()

def fn(y,m,b):
    x=m*(b-y)
    ans=(x+1)*(y+1)*(x+y)
    return ans//2
m,b=list(map(int,input().split()))
lo=0
hi=b
while lo<hi:
    mid=(lo+hi)//2
    if fn(mid,m,b)>fn(mid-1,m,b) and fn(mid+1,m,b)>fn(mid,m,b):
        lo=mid
    elif fn(mid,m,b)<fn(mid-1,m,b) and fn(mid+1,m,b)<fn(mid,m,b):
        hi=mid
    else:
        break
print(fn(mid,m,b))




m, b = list(map(int, input().split()))
maxS = 0
for x, y in zip(list(range(0, (b+1)*m, m)), list(range(b, -1, -1))):
    #print(x, y)
    vert = int((1 + y) * y / 2)
    hor = int((1 + x) * x / 2)
    newS = vert * (x + 1) + hor * (y + 1)
    if newS > maxS:
        maxS = newS
print(maxS)


def col(currY, currX, m):
    y_vals = currY*(currY-1)//2
    total = y_vals*m

    x_vals = (currX+m+currX+1)*m//2
    total += x_vals*currY

    return total

def row(currY, currX):
    y_vals = currY*(currX+1)
    total = y_vals

    x_vals = (currX+1)*currX//2
    total += x_vals

    return total

m,b = [int(val) for val in input().strip().split(' ')]

initX = b*m

max_v = curr_v = (initX+1)*initX//2
curr_y = 0

for curr_x in range(initX-m, -1, -m):
    curr_y +=1
    curr_v = curr_v - col(curr_y,curr_x, m) + row(curr_y,curr_x)
    if curr_v > max_v:
        max_v = curr_v
    else:
        print(max_v)
        break


m, b = input().split(" ")
m = int(m)
b = int(b)

maxx = m*b

##def solvefory(x):
##    nonlocal m, b
##    m1 = 1/m
##    y = -1 * x * m1 + b
##    return y

def area(x, y):
    return ((x+1)*(y+1)*(x+y))//2

areas = []
##xy = []
i = 0
while i<=b:
##    xy += [[i, solvefory(i)], ]
    x=i*m;
    y=b-i
    areas += [int(area(x, y)), ]
    i += 1
print(max(areas))
##print(xy)



m, b = map(int, input().split())
f = lambda x, y: (x + y) * (x + 1) * (y + 1) >> 1
print(max(f(k * m, b - k) for k in range(b + 1)))

m,b = input().strip().split()
m,b = int(m),int(b)

sum_s = []
x_zero = m*b
y_zero = b
for i  in range(0,b*m + 1,m):
  x = i
  y = b - i/m
  y =int(y)
  s = ((1+y)*y//2)*(x+1)
  s += ((1+x)*x//2)*(y+1)
  sum_s.append(s)
print(max(sum_s))