Under construction

Still being built. Things may change

Uncle Fyodor's Candies

Interview

Time limit2sMemory limit1024 MB

Summary
Given n candies, decide whether they can form a truncated tetrahedron, where consecutive triangular-number layers are stacked with the top layers removed.
Level

Easy3 of 10

Topics
Math, Brute force
Solved
No attempts yet

Statement

One sunny Saturday, the villagers of Prostokvashino gathered for tea at Uncle Fyodor's house. This time Uncle Fyodor opened a box of foreign round chocolate candies, and Postman Pechkin, being very tidy, stacked all of them into a regular tetrahedron pyramid.

Each layer of the pyramid is a regular triangle built from candies. The side of each layer holds one candy fewer than the side of the layer above it. The picture below shows the third and fourth layers from the top.

The baby crow Hvatayka did not like how the candies were spread across the layers. The top layer has one candy, and the last one can have ten. He fooled everyone by asking who was there, lowered their guard, and ate several of the top layers whole.

When the others noticed and tried to catch the visibly plump crow, the table was knocked over and all the candies spilled onto the floor.

Sharik and Matroskin searched and collected n candies. They wondered whether any candies were still missing. Nobody remembers how many candies there were, and looking at Hvatayka gave no clue. So the candies are considered not lost if they can be stacked into a truncated tetrahedron pyramid, meaning a pyramid with several top layers removed. Help the people of Prostokvashino find out whether these valuable candies are lost.

Input

The input file contains a single integer n, the number of candies found. 0≤n≤1090 \le n \le 10^9

Output

If the n candies can form a truncated pyramid, print YES to the output file. Otherwise, print NO.

Examples5

  1. Example 1

    Input
    0
    
    Expected output
    YES
    
  2. Example 2

    Input
    1
    
    Expected output
    NO
    
  3. Example 3

    Input
    3
    
    Expected output
    YES
    
  4. Example 4

    Input
    6
    
    Expected output
    YES
    
  5. Example 5

    Input
    16
    
    Expected output
    YES