import random import math def annealing_initialze(): cost_max=0 for ii in range(3000): for jj in range(3000): vec=[(C+D)*ii/2000,(C+D)*jj/2000] stock_c=C-0.75*vec[0]-2/7*vec[1] stock_d=D-0.25*vec[0]-5/7*vec[1] if stock_c>=0 and stock_d>=0: if cost_max<= costf(vec): cost_max= costf(vec) vect=vec[:] return vect def annealingoptimize(T=12000, cool=0.99993, step=0.005): dimension=2 vec=[A,B] newvec = vec[:] while T > 0.0001: i = random.randint(0, dimension-1) dir = random.random() dir = (dir - 0.5) * step if i==0: stock_c=C-0.75*(vec[0]+dir)-2/7*vec[1] stock_d=D-0.25*(vec[0]+dir)-5/7*vec[1] if stock_c<0 or stock_d<0 or vec[0]+dir<0: newvec[i] = vec[i] else: newvec[i] = vec[i] + dir else: stock_c=C-0.75*vec[0]-2/7*(vec[1]+dir) stock_d=D-0.25*vec[0]-5/7*(vec[1]+dir) if stock_c<0 or stock_d<0 or vec[1]+dir<0: newvec[i] = vec[i] else: newvec[i] = vec[i] + dir newcost = costf(newvec) cost = costf(vec) p = pow(math.e, -abs(newcost - cost) / T) if(newcost > cost or random.random() < p): vec[i] = newvec[i] T = T * cool return vec def costf(vec): return (1000*vec[0]+2000*vec[1]) C,D=[int(i) for i in input().split()] A,B=annealing_initialze() #print(A,B) ans=0 k_min=[] for i in range(4): kkk=annealingoptimize() cost=costf(kkk) ans=max(ans,cost) print(ans)