Little Ashish's Huge Donation
Difficulty: Hard

Little Ashish is doing internship at multiple places. Instead of giving parties to his friends he decided to donate candies to children. He likes solving puzzles and playing games. Hence he plays a small game. Suppose there are $N$ children. The rules of the game are:  

1. The $i^{th}$ child gets $i^{2}$ candies ($1 \le i \le N$).  

2. The $y^{th}$ child cannot get a candy until and unless all the children before him ($1 \le i \lt y$) gets candies according to rule number $1$.  

One of his jealous friends, Pipi, asks him "Given $X$ (the number of candies) how many children will you be able to serve?". Little Ashish fears calculations and cannot solve this problem so he leaves this problem to the worthy programmers of the world. Help little Ashish in finding the solution.  

**Input Format**  
The first line contains $T$ i.e. number of test cases.  
$T$ lines follow, each line containing an integer $X$.  

**Output Format**  
For each testcase, print the output that little Ashish wants in one line.   

**Constraints**  
$1 \le T \le 10000$  
$1 \le X \le 10^{16}$  

**Note: If the $i^{th}$ child doesn't get $i^{2}$ number of candies then it's not counted as a successful donation**  

**Sample Input**  

    3
    1
    5
    13

**Sample Output**  

    1  
    2  
    2  

**Explanation**  

1. For $X = 1$. Only the $1^{st}$ child can get the candy (i.e. $1^{2}$ candy) and no other child.  
2. For $X = 5$. Both the $1^{st}$($1^{2}$ candies) and the $2^{nd}$($2^{2}$ candies) children can get the candies.  
3. For $X = 13$. Since the $3^{rd}$ child will get only 8 candies following the rule it won't be counted as a successful donation. Only the $1^{st}$ and the $2^{nd}$ children can get 1 and 4 candies respectively.  


Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:
#
# Complete the 'solve' function below.
#
# The function is expected to return an INTEGER.
# The function accepts LONG_INTEGER x as parameter.
#

def solve(x):
    # Write your code here




Reference solution (C++):
###C++  
```cpp  
/*******************
    Akash Agrawall
    IIIT HYDERABAD
    akash.agrawall094@gmail.com
    ***********************/


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<stdio.h>
#include<math.h>
using namespace std;
#define ll long long int
#define FOR(i,a,b) for(i= (int )a ; i < (int )b ; ++i)
#define rep(i,n) FOR(i,0,n)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
int main()
{
    int t,i;
    ll sum=0,low,high,mid,x,calc,calc1;
    si(t);
    while(t--)
    {
        sl(x);
        low=0;
        high=1000000;
        while(low<=high)
        {
            mid=(low+high)/2;
            calc=(mid*(mid+1)*(2*mid+1))/6;
            calc1=((mid+1)*(mid+2)*(2*(mid+1)+1))/6;
            if(calc<=x && calc1>x)
            {
                printf("%lld\n",mid);
                break;
            }
            else if(calc<x)
            {
                low=mid+1;
            }
            else
                high=mid-1;
        }
    }
    return 0;
}
```