stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
/*

the top of the losers

*/

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#define sz(v)   ((int)(v).size())

#define  all(v)    ((v).begin()),((v).end())

#define  allr(v)    ((v).rbegin()),((v).rend())

#define   pb         push_back

#define   mp         make_pair

#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))

#define    X            real()

#define    Y            imag()

#define    clr(v,d)      memset( v, d ,sizeof(v))

#define   angle(n)      atan2((n.imag()),(n.real()))

#define   vec(a,b)       ((b)-(a))

#define   length(a)      hypot( (a.imag()),(a.real()) )

#define   normalize(a)      (a)/(length(a))

#define    dp(a,b)          (((conj(a))*(b)).real())

#define    cp(a,b)          (((conj(a))*(b)).imag())

#define    lengthsqrt(a)       dp(a,a)

#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))

#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)

#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))

#define    reflection0(m,v)         (conj((v)/(m))*(m))

#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0

#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )

#define     point                    complex<double>

#define     point        complex<double>

#define    cp(a,b)          (((conj(a))*(b)).imag())

#define    PI  acos(-1)

typedef  long long     ll ;

typedef  unsigned long long     ull ;

const double eps= (1e-9);

using namespace std;

using namespace __gnu_pbds;

int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}

int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}

int setBit1(int num, int idx) {return num | (1<<idx);}

ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}

ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}

int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}

void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

void solve(ll n){

   ll mi=n*2;

   for(ll i=1;i*i<=n;i++){

      if(n%i==0){

        mi=min(mi,(i-1)+(n/i-1));

      }

   }

   cout<<mi<<endl;



}

int main(){

    ll n;

    cin>>n;

    solve(n);

}


// Faster C++ solution for the same problem (measured speedup: 3.8897417261602736x):
#include<stdio.h>

#include<math.h>

int main()

{

    long long n;

    scanf("%lld", &n);

    long long x=1;

    for(long long i=1;i<=sqrt(n);i++)

    {

        if((n%i==0) && (((n/i)-i)<((n/x)-x)))

            x=i;

    }

    long long a=x, b=(n/x);

    long long moves=(a+b)-2;

    printf("%lld", moves);

    return 0;

}
// Slower C++ solution:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;

const int N = 2e5 + 5, M = 2 * N + 5;





int main(){

    IO;

    ll n;

    cin >> n;

    ll mn = LLONG_MAX;

    for(ll i = 1 ; i * i <= n ; ++i)

        if(n % i == 0)

            mn = min(mn, (i + n / i - 2));

    cout << mn << endl;

}

// Faster C++ solution for the same problem (measured speedup: 3.9437542703309965x):
#include<stdio.h>

#include<math.h>

int main()

{

    long long n;

    scanf("%lld", &n);

    long long x=1;

    for(long long i=1;i<=sqrt(n);i++)

    {

        if((n%i==0) && (((n/i)-i)<((n/x)-x)))

            x=i;

    }

    long long a=x, b=(n/x);

    long long moves=(a+b)-2;

    printf("%lld", moves);

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main(int argc, char const *argv[])

{

	long long n;

	cin>>n;

	long long mi=n+1;

	for(long long i=2;i*i<=n;i++)

	{

		if(n%i==0)

		{

			mi=min(mi,i+(n/i));

		}

	}

	cout<<mi-2<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.893026212495254x):
#include<stdio.h>

#include<math.h>

int main()

{

    long long n;

    scanf("%lld", &n);

    long long x=1;

    for(long long i=1;i<=sqrt(n);i++)

    {

        if((n%i==0) && (((n/i)-i)<((n/x)-x)))

            x=i;

    }

    long long a=x, b=(n/x);

    long long moves=(a+b)-2;

    printf("%lld", moves);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <sstream>

#include <vector>

#include <utility>

#include <map>

#include <algorithm>

#include <string>

#include <string.h>

#include <iomanip>

#include <cmath>

#define ll long long

#define PI 3.14159265358979323846

#define lp(i, n) for (int i = 0; i < n; i++)

#define rep(i, v) for (int i = 0; i < int(v.size()); i++)

using namespace std;

vector<ll> div(ll n)

{

	vector<ll> v;

	for(int i=1;i<=sqrt(n);i++){

		if(n%i==0)

				v.push_back((i+n/i)-2);

	}

	return v;

}		

int main()

{

	ll n;

	vector<ll> v;

	cin>>n;

	v=div(n);

	sort(v.begin(),v.end());

	cout<<v.front();

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.91100934835635x):
#include<stdio.h>

#include<math.h>

int main()

{

    long long n;

    scanf("%lld", &n);

    long long x=1;

    for(long long i=1;i<=sqrt(n);i++)

    {

        if((n%i==0) && (((n/i)-i)<((n/x)-x)))

            x=i;

    }

    long long a=x, b=(n/x);

    long long moves=(a+b)-2;

    printf("%lld", moves);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main()

{

	long long n, i, x, y;

	scanf("%lld", &n);

	for(i=(int)sqrt(n); i>=1; i--)

	{

		if(n%i==0)

		{

			x=i;

			y=n/i;

			printf("%lld", x+y-2);

			return 0;

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 3.808608254578189x):
#include<stdio.h>

#include<math.h>

int main()

{

    long long n;

    scanf("%lld", &n);

    long long x=1;

    for(long long i=1;i<=sqrt(n);i++)

    {

        if((n%i==0) && (((n/i)-i)<((n/x)-x)))

            x=i;

    }

    long long a=x, b=(n/x);

    long long moves=(a+b)-2;

    printf("%lld", moves);

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>



using namespace std;

int main()

{

	long long int c,cc;

	long long int a;

	cin>>a;

	c=1E13;

	for(int i=2;i<=sqrt((long double)a) + 1;i++)

	{

		if(a%i==0)

			c=i+a/i-2;

		cc=min(c,a-1);

	}

	cout<<cc;

	

	



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.027763645390218x):
#include<stdio.h>

#include<math.h>

int main(int argc, char *argv[])

{

	long long int N,a,i;

	scanf("%lld",&N);

	a=sqrt(N);

	for(i=a;i>=0;i--){

		if(N%i==0){

			 printf("%lld\n",i+(N/i)-2);

			 break;

		}

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;



ll n;



int main(){

	scanf("%lld",&n);

	ll ans = 1e15;

	for(ll i=1;i*i<=n;i++){

		if(n%i==0){

			ll x = i;

			ll y = n/i;

			ans = min(ans,x+y-2);

		}

	}

	printf("%lld\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.20585399964949x):
#include<stdio.h>

#include<math.h>

int main(int argc, char *argv[])

{

	long long int N,a,i;

	scanf("%lld",&N);

	a=sqrt(N);

	for(i=a;i>=0;i--){

		if(N%i==0){

			 printf("%lld\n",i+(N/i)-2);

			 break;

		}

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define ll long long

#define X first

#define Y second

#define all(x) x.begin(), x.end()



const int MX = (int)1e5 + 10;

const int mod = (int)1e9 + 7;



void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}

void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}

void mul(int &x, int y){x = x * 1LL * y % mod;}





int main(){



    cin.tie(0); cout.tie(0);

    ios_base::sync_with_stdio(0);



    ll n;

    cin >> n;



    ll res = n - 1;

    for(ll i = 2; i * i <= n; ++i){

        if(n % i) continue;

        res = min(res, i + n / i - 2);

    }



    cout << res << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.305569311143857x):
#include<stdio.h>

#include<math.h>

int main(int argc, char *argv[])

{

	long long int N,a,i;

	scanf("%lld",&N);

	a=sqrt(N);

	for(i=a;i>=0;i--){

		if(N%i==0){

			 printf("%lld\n",i+(N/i)-2);

			 break;

		}

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <cstring>

using namespace std;

#define ll  long long

#define endl '\n'

const ll mod = 1000000007;

const double PI = 3.141592653589793238463;

using namespace std;

int main()

{

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll x;

    cin>>x;

    ll m=sqrtl(x);

    for (int i=m;i>0;i--){

        if (x%i==0){

            cout<<x/i+i-2<<endl;

            break;

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.091055236322045x):
#include<stdio.h>

#include<math.h>

int main(int argc, char *argv[])

{

	long long int N,a,i;

	scanf("%lld",&N);

	a=sqrt(N);

	for(i=a;i>=0;i--){

		if(N%i==0){

			 printf("%lld\n",i+(N/i)-2);

			 break;

		}

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>



using namespace std;

int main()

{

	long long int c,cc;

	long long int a;

	cin>>a;

	c=1E13;

	for(int i=2;i<=sqrt((long double)a) + 1;i++)

	{

		if(a%i==0)

			c=i+a/i-2;

		cc=min(c,a-1);

	}

	cout<<cc;

	

	



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.032114417370053x):
#include<cstdio>

#include<algorithm>

#include<cmath>

typedef long long ll;

using namespace std;



int main()

{

	ll n;

	scanf("%lld",&n);

	ll ans=0;

	ll ans1=0;

	for(ll i=sqrt(n)+1;i>=1;i--)

	{

		if(n%i==0)

		{

			ans=i;

			ans1=n/i;

			break;

		}

	}

	if(ans==1)

	printf("%lld\n",n-1);

	else

	printf("%lld\n",ans+ans1-2);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;



ll n;



int main(){

	scanf("%lld",&n);

	ll ans = 1e15;

	for(ll i=1;i*i<=n;i++){

		if(n%i==0){

			ll x = i;

			ll y = n/i;

			ans = min(ans,x+y-2);

		}

	}

	printf("%lld\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.210397144020409x):
#include<cstdio>

#include<algorithm>

#include<cmath>

typedef long long ll;

using namespace std;



int main()

{

	ll n;

	scanf("%lld",&n);

	ll ans=0;

	ll ans1=0;

	for(ll i=sqrt(n)+1;i>=1;i--)

	{

		if(n%i==0)

		{

			ans=i;

			ans1=n/i;

			break;

		}

	}

	if(ans==1)

	printf("%lld\n",n-1);

	else

	printf("%lld\n",ans+ans1-2);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define ll long long

#define X first

#define Y second

#define all(x) x.begin(), x.end()



const int MX = (int)1e5 + 10;

const int mod = (int)1e9 + 7;



void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}

void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}

void mul(int &x, int y){x = x * 1LL * y % mod;}





int main(){



    cin.tie(0); cout.tie(0);

    ios_base::sync_with_stdio(0);



    ll n;

    cin >> n;



    ll res = n - 1;

    for(ll i = 2; i * i <= n; ++i){

        if(n % i) continue;

        res = min(res, i + n / i - 2);

    }



    cout << res << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.310220167540955x):
#include<cstdio>

#include<algorithm>

#include<cmath>

typedef long long ll;

using namespace std;



int main()

{

	ll n;

	scanf("%lld",&n);

	ll ans=0;

	ll ans1=0;

	for(ll i=sqrt(n)+1;i>=1;i--)

	{

		if(n%i==0)

		{

			ans=i;

			ans1=n/i;

			break;

		}

	}

	if(ans==1)

	printf("%lld\n",n-1);

	else

	printf("%lld\n",ans+ans1-2);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <cstring>

using namespace std;

#define ll  long long

#define endl '\n'

const ll mod = 1000000007;

const double PI = 3.141592653589793238463;

using namespace std;

int main()

{

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll x;

    cin>>x;

    ll m=sqrtl(x);

    for (int i=m;i>0;i--){

        if (x%i==0){

            cout<<x/i+i-2<<endl;

            break;

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.095474375590686x):
#include<cstdio>

#include<algorithm>

#include<cmath>

typedef long long ll;

using namespace std;



int main()

{

	ll n;

	scanf("%lld",&n);

	ll ans=0;

	ll ans1=0;

	for(ll i=sqrt(n)+1;i>=1;i--)

	{

		if(n%i==0)

		{

			ans=i;

			ans1=n/i;

			break;

		}

	}

	if(ans==1)

	printf("%lld\n",n-1);

	else

	printf("%lld\n",ans+ans1-2);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int main()

{

    long long int num,n;

    int digits;

    vector<long long int>vec;

    cin>>n;

    digits=int(floor(log10(n)+1));

    digits=(digits/2);

    for(int i = 1; i <=int(pow(10,(digits+1))); i++)

    {

        if(n % i == 0 && vec.size()==0)

            {vec.push_back(i);vec.push_back((n/i));}

        else if(n%i==0 && vec.size()!=0)

            {vec.push_back(i);vec.push_back((n/i));}

    }

    sort(vec.begin(),vec.end());

    num=(vec.size()/2);

    cout<<(vec[num-1]-1)+(vec[num]-1)<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 12.073209683845748x):
#include<cstdio>

#include<algorithm>

#include<cmath>

typedef long long ll;

using namespace std;



int main()

{

	ll n;

	scanf("%lld",&n);

	ll ans=0;

	ll ans1=0;

	for(ll i=sqrt(n)+1;i>=1;i--)

	{

		if(n%i==0)

		{

			ans=i;

			ans1=n/i;

			break;

		}

	}

	if(ans==1)

	printf("%lld\n",n-1);

	else

	printf("%lld\n",ans+ans1-2);

	return 0;

}
// Slower C++ solution:
#include<iostream> 

#include<cmath>

using namespace std;

long long n;



int main(){

	cin>>n;

	if(n==1)

	{

		puts("0");return 0;

	}

	for(int i =sqrt(n);i>0;--i){

		if(n%i==0){

			cout<<n/i+i-2;return 0;

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 4.171591823610047x):
#include<cstdio>

#include<algorithm>

#include<cmath>

typedef long long ll;

using namespace std;



int main()

{

	ll n;

	scanf("%lld",&n);

	ll ans=0;

	ll ans1=0;

	for(ll i=sqrt(n)+1;i>=1;i--)

	{

		if(n%i==0)

		{

			ans=i;

			ans1=n/i;

			break;

		}

	}

	if(ans==1)

	printf("%lld\n",n-1);

	else

	printf("%lld\n",ans+ans1-2);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

typedef long long int ll;

using namespace std;

int main(){

    ll n; cin>>n;

    ll t=sqrt(n);

    ll ans;

    bool m=true;

    for(;t>=2;t--){

        if(n%t==0) {

            m=false;

            ans=n/t+t-2;

            break;

        }

    }

    if(m) ans=n-1;

    cout<<ans;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.170969139470692x):
#include<cstdio>

#include<algorithm>

#include<cmath>

typedef long long ll;

using namespace std;



int main()

{

	ll n;

	scanf("%lld",&n);

	ll ans=0;

	ll ans1=0;

	for(ll i=sqrt(n)+1;i>=1;i--)

	{

		if(n%i==0)

		{

			ans=i;

			ans1=n/i;

			break;

		}

	}

	if(ans==1)

	printf("%lld\n",n-1);

	else

	printf("%lld\n",ans+ans1-2);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<math.h>

#define ll long long int 

using namespace std;

ll n;

ll fak(){

	ll ans = 1e15;

	ll sampe = sqrt(n);

	ll i = 1;

	while(i<=sampe){

		if(n%i == 0){

			ans = min(ans, (i-1)+(n/i)-1);

		}

		i++;

	}

	return ans;

}





int main(){

	cin>>n;

	cout<<fak()<<"\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.231609960174713x):
/**

 * Created By: Anonyman637

 * Created On: 3/6/2020 6:27:28 AM

 */



/* =============================================================================

   ================================== HEADERS ==================================

   ========================================================================== */



#include <cstdio>

#include <string>

#include <cmath>



/* =============================================================================

   ================================= TYPEDEFS ==================================

   ========================================================================== */



typedef char i8;

typedef short i16;

typedef int i32;

typedef long long i64;



typedef unsigned char ui8;

typedef unsigned short ui16;

typedef unsigned int ui32;

typedef unsigned long long ui64;



using namespace std;



/* =============================================================================

   ================================== MACROS ===================================

   ========================================================================== */



#ifdef DEBUG

#define debug(format, ...) printf(format, __VA_ARGS__)

#else

#define debug(format, ...) 

#endif



#ifdef FILEIO

#define INFILE "fileio\\"__FILE__"In.txt"

#define OUTFILE "fileio\\"__FILE__"Out.txt"

#endif



/* =============================================================================

   ================================== GLOBALS ==================================

   ========================================================================== */





/* =============================================================================

   =================================== SETUP ===================================

   ========================================================================== */



i32 setup() {



#ifdef FILEIO

        if(freopen(INFILE, "r", stdin) == NULL) return 401;

        if(freopen(OUTFILE, "w", stdout) == NULL) return 402;

#endif



        return 0;

}





/* =============================================================================

   ================================= FUNCTIONS =================================

   ========================================================================== */



i32 main() {



        i32 errorInSetup = setup();

        if (errorInSetup) exit(errorInSetup);



        i64 i, t;

        i64 n, sqrtN, steps;

        scanf("%lld", &n);

        sqrtN = ceil(sqrt((double) n));

        for (i = sqrtN; i > 0; i--) {

                if (n % i == 0) {

                        steps = (n / i) + i - 2;

                        break;

                }

        }



        printf("%lld", steps);

        

        return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;



int main()

{

    long long n , ans;



    cin >> n;



    ans = n;



    for(long long i = 1; i * i <= n; i++)

    {

        if(n % i == 0)

        {

            ans = min(ans, i + n/i - 2);

        }

    }

    cout << ans << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.2583844294672755x):
/**

 * Created By: Anonyman637

 * Created On: 3/6/2020 6:27:28 AM

 */



/* =============================================================================

   ================================== HEADERS ==================================

   ========================================================================== */



#include <cstdio>

#include <string>

#include <cmath>



/* =============================================================================

   ================================= TYPEDEFS ==================================

   ========================================================================== */



typedef char i8;

typedef short i16;

typedef int i32;

typedef long long i64;



typedef unsigned char ui8;

typedef unsigned short ui16;

typedef unsigned int ui32;

typedef unsigned long long ui64;



using namespace std;



/* =============================================================================

   ================================== MACROS ===================================

   ========================================================================== */



#ifdef DEBUG

#define debug(format, ...) printf(format, __VA_ARGS__)

#else

#define debug(format, ...) 

#endif



#ifdef FILEIO

#define INFILE "fileio\\"__FILE__"In.txt"

#define OUTFILE "fileio\\"__FILE__"Out.txt"

#endif



/* =============================================================================

   ================================== GLOBALS ==================================

   ========================================================================== */





/* =============================================================================

   =================================== SETUP ===================================

   ========================================================================== */



i32 setup() {



#ifdef FILEIO

        if(freopen(INFILE, "r", stdin) == NULL) return 401;

        if(freopen(OUTFILE, "w", stdout) == NULL) return 402;

#endif



        return 0;

}





/* =============================================================================

   ================================= FUNCTIONS =================================

   ========================================================================== */



i32 main() {



        i32 errorInSetup = setup();

        if (errorInSetup) exit(errorInSetup);



        i64 i, t;

        i64 n, sqrtN, steps;

        scanf("%lld", &n);

        sqrtN = ceil(sqrt((double) n));

        for (i = sqrtN; i > 0; i--) {

                if (n % i == 0) {

                        steps = (n / i) + i - 2;

                        break;

                }

        }



        printf("%lld", steps);

        

        return 0;

}