/*
░██████╗████████╗███████╗██╗░░░██╗███████╗ ██████╗░░█████╗░░██████╗░███████╗██████╗░░██████╗
██╔════╝╚══██╔══╝██╔════╝██║░░░██║██╔════╝ ██╔══██╗██╔══██╗██╔════╝░██╔════╝██╔══██╗██╔════╝
╚█████╗░░░░██║░░░█████╗░░╚██╗░██╔╝█████╗░░ ██████╔╝██║░░██║██║░░██╗░█████╗░░██████╔╝╚█████╗░
░╚═══██╗░░░██║░░░██╔══╝░░░╚████╔╝░██╔══╝░░ ██╔══██╗██║░░██║██║░░╚██╗██╔══╝░░██╔══██╗░╚═══██╗
██████╔╝░░░██║░░░███████╗░░╚██╔╝░░███████╗ ██║░░██║╚█████╔╝╚██████╔╝███████╗██║░░██║██████╔╝
╚═════╝░░░░╚═╝░░░╚══════╝░░░╚═╝░░░╚══════╝ ╚═╝░░╚═╝░╚════╝░░╚═════╝░╚══════╝╚═╝░░╚═╝╚═════╝░
*/
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7;
#define int long long
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define vpii vector<pair<int,int>>
#define pb push_back
#define fin0 for(int i=0;i<n;i++)
#define fin1 for(int i=1;i<=n;i++)
#define test int t;cin>>t;while(t--)
// binary multiply (iterative version)
ll bmul(ll a, ll b)
{ int ans=0;
while(b>0)
{ if(b&1) ans= (ans+a)%M;
a= (a+a)%M;
b=b>>1;
}return ans;
}
// gcd function
int gcd(int small, int big)
{
if(big%small==0)return small;
else return gcd(big%small,small);
}
// binary exponentiation (recursive version)
ll bxp(ll a, ll b)
{
if (b==0) return 1;
ll res=bxp(a,b/2);
if(b&1) return (a*bmul(res,res))%M;
else return bmul(res,res);
}
ll mod( ll a)
{
if(a>0)return a;
else return -1*a;
}
/* ---------------------- (Main) ---------------------- */
signed main()
{
test
{
int k,x;cin>>k>>x;
if(k*k<=x)
{
cout<<2*k-1<<endl;continue;
}
int m=0;
if(x<=(k*k +k)/2)
{
int r=(sqrtl(8*x+1)-1)/2;
if(x==(r*(r+1))/2);
else r++;
m=r;
}
else
{
x=x-k*(k+1)/2;
x=k*(k-1)/2-x+1;
int r=(sqrtl(8*x+1)-1)/2;
if(x==(r*(r+1))/2);
else r++;
m+= 2*k-r;
}
cout<<m<<endl;
}
}
589. N-ary Tree Preorder Traversal | 1299. Replace Elements with Greatest Element on Right Side |
1768. Merge Strings Alternately | 561. Array Partition I |
1374. Generate a String With Characters That Have Odd Counts | 1822. Sign of the Product of an Array |
1464. Maximum Product of Two Elements in an Array | 1323. Maximum 69 Number |
832. Flipping an Image | 1295. Find Numbers with Even Number of Digits |
1704. Determine if String Halves Are Alike | 1732. Find the Highest Altitude |
709. To Lower Case | 1688. Count of Matches in Tournament |
1684. Count the Number of Consistent Strings | 1588. Sum of All Odd Length Subarrays |
1662. Check If Two String Arrays are Equivalent | 1832. Check if the Sentence Is Pangram |
1678. Goal Parser Interpretation | 1389. Create Target Array in the Given Order |
1313. Decompress Run-Length Encoded List | 1281. Subtract the Product and Sum of Digits of an Integer |
1342. Number of Steps to Reduce a Number to Zero | 1528. Shuffle String |
1365. How Many Numbers Are Smaller Than the Current Number | 771. Jewels and Stones |
1512. Number of Good Pairs | 672. Richest Customer Wealth |
1470. Shuffle the Array | 1431. Kids With the Greatest Number of Candies |