P1734 Maximum Sum of Divisors

Description

Select several distinct positive integers whose total sum does not exceed $S$, so that the sum of the proper divisors (excluding the number itself) of all selected numbers is maximized.

Input Format

Input a positive integer $S$.

Output Format

Output the maximum possible sum of proper divisors.

Explanation/Hint

【Sample Explanation】 Choose the numbers $4$ and $6$ to obtain the maximum value $(1+2)+(1+2+3)=9$. 【Constraints】 For $100\%$ of the testdata, $1 \le S \le 1000$. Translated by ChatGPT 5