criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
using namespace std;

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    unsigned long long n, minimum;
    cin >> n;
    minimum = n - 1;

    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            // if (((n / i) - 1) + (i - 1) < minimum)
            //     minimum = ((n / i) - 1) + (i - 1);
            minimum=min(((n / i) - 1) + (i - 1),minimum);
        }#include <iostream>
using namespace std;

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    unsigned long long n, minimum;
    cin >> n;
    minimum = n - 1;

    for (unsigned long long i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            // if (((n / i) - 1) + (i - 1) < minimum)
            //     minimum = ((n / i) - 1) + (i - 1);
            minimum=min(((n / i) - 1) + (i - 1),minimum);
        }
    }
    cout << minimum;

    return 0;
}
    }
    cout << minimum;

    return 0;
}

Compiler output:
a.cc:20:10: error: stray '#' in program
   20 |         }#include <iostream>
      |          ^
a.cc: In function 'int main()':
a.cc:20:11: error: 'include' was not declared in this scope
   20 |         }#include <iostream>
      |           ^~~~~~~
a.cc:20:28: error: expected primary-expression before '>' token
   20 |         }#include <iostream>
      |                            ^
a.cc:21:1: error: expected primary-expression before 'using'
   21 | using namespace std;
      | ^~~~~
a.cc:23:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   23 | int main()
      |         ^~
a.cc:23:9: note: remove parentheses to default-initialize a variable
   23 | int main()
      |         ^~
      |         --
a.cc:23:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:24:1: error: a function-definition is not allowed here before '{' token
   24 | {
      | ^
Language: C++

#include <bits/stdc++.h>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;

int main()
{
    ll n;
    cin >> n;
    ll min = n;a
    for (ll i = 1; i < sqrt(n); ++i ) {
        ll tmp = i * (n / i);
        if (tmp == n ) {
            if (min > (i-1) + ((n / i) - 1)) {
                min = (i-1) + ((n / i) - 1);
            }
        }
    }
    cout << min << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: 'a' was not declared in this scope
   13 |     ll min = n;a
      |                ^
a.cc:14:20: error: 'i' was not declared in this scope
   14 |     for (ll i = 1; i < sqrt(n); ++i ) {
      |                    ^
Language: C++

#define _GLIBCXX_DEBUG
#include<algorithm>
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  ll n;
  cin >> n;
  ll ans=n-1;
  rep2(ll i=1;i<1000001;i++){
    if(n%i==0) {
      ll a=n/i;
    ans=min(ans,i+a-2);
    }
  }
  cout <<ans<<endl;
}

Compiler output:
a.cc:14:28: error: macro "rep2" requires 3 arguments, but only 1 given
   14 |   rep2(ll i=1;i<1000001;i++){
      |                            ^
a.cc:7:9: note: macro "rep2" defined here
    7 | #define rep2(i,s,n) for(int i=s;i< (int)n; i++)
      |         ^~~~
a.cc: In function 'int main()':
a.cc:14:3: error: 'rep2' was not declared in this scope
   14 |   rep2(ll i=1;i<1000001;i++){
      |   ^~~~
Language: C++

#define _GLIBCXX_DEBUG
#include<algorithm>
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  ll n;
  cin >> n;
  ll ans=n-1;
  rep2(i,1,1000000){
    if(n%i==0) ll a=n/i;
    ans=min(ans,i+a-2);
  }
  cout <<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:19: error: 'a' was not declared in this scope
   16 |     ans=min(ans,i+a-2);
      |                   ^
Language: C++

#define _GLIBCXX_DEBUG
#include<algorithm>
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  ll n;
  cin n;
  ll ans=n-1;
  rep2(i,1,1000000){
    if(n%i==0) ll a=n/i;
    ans=min(ans,i+a-2);
  }
  cout <<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:6: error: expected ';' before 'n'
   12 |   cin n;
      |      ^~
      |      ;
a.cc:16:19: error: 'a' was not declared in this scope
   16 |     ans=min(ans,i+a-2);
      |                   ^
Language: C++

#include <iostream>

using namespace std;
using ll = long long int;

int main(){
  ll N;
  cin>>N;
  
  ll ans = 1LL;
  for(ll i=2;i*i<=N;i++){
    if (N％i==0)
      ans = i;
  }
  cout<<(ans + N/ans - 2)<<endl;
 }


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'N\U0000ff05i' was not declared in this scope
   12 |     if (N％i==0)
      |         ^~~~
Language: C++

#include <iostream>

using namespace std;
using ll = long long int;

int main(){
  ll N;
  cin>>N;
  
  ll ans = 1LL;
  for(ll i=2;i*i<=N;i++){
    if(N％i==0)
      ans = i;
  }
  cout<<(ans + N/ans - 2)<<endl;
 }


Compiler output:
a.cc: In function 'int main()':
a.cc:12:8: error: 'N\U0000ff05i' was not declared in this scope
   12 |     if(N％i==0)
      |        ^~~~
Language: C++

#include <iostream>

using namespace std;
using ll = long long int;

int main(){
  long long int N;
  cin>>N;
  
  ll ans = 1;
  for(ll i=2;i*i<=N;i++){
    if (N％i==0)
      ans = i;
  }
  cout<<(ans + N/ans - 2)<<endl;
 }

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'N\U0000ff05i' was not declared in this scope
   12 |     if (N％i==0)
      |         ^~~~
Language: C++

#include<iostream>
#include<cmath>

using namespace std;

long long N;

long long res;

void main() {

	cin >> N;

	for (int i = sqrt(N); i >=1; i--) {
		if (N % i == 0) {
			res = i;
			break;
		}
	}

	cout << res + N / res - 2 << endl;

}

Compiler output:
a.cc:10:1: error: '::main' must return 'int'
   10 | void main() {
      | ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

void fnInput(int64_t& rnNumber)
{
  cin >> rnNumber;
}

int64_t fnMinStepGet(int64_t nNumber)
{
  int nSqrtInt = sqrt(nNumber);
  int nMultpler;
  int64_t nMultplcand;
  int64_t nMinDiff = INT64_MAX;

  for (nMultpler = 1; nMultpler <= nSqrtInt; nMultpler++)
    if (nNumber % nMultpler == 0)
    {
      nMultplcand = nNumber / n;
      if (nMultplcand - nMultpler < nMinDiff)
        nMinDiff = nMultplcand - nMultpler;
    }

  return (nMultplcand + nMultpler - 2);
}

int main()
{
  int64_t nNumber;

  fnInput(nNumber);
  cout << fnMinStepGet(nNumber) << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int64_t fnMinStepGet(int64_t)':
a.cc:19:31: error: 'n' was not declared in this scope; did you mean 'yn'?
   19 |       nMultplcand = nNumber / n;
      |                               ^
      |                               yn
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll=long long;

int main() {
	int n;
	cin>>n;
	
	pair<int,int> pair;
	vector<pair> s;
	
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n){
				s.push_back(pair(i,j));
				
			}
		}
	}
	
	int ans=10101010;
	for(auto t:s){
		ans=min(ans,t.first+t.second-2);
	}
	
	cout<<ans<<endl;
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   11 |         vector<pair> s;
      |                    ^
a.cc:11:20: note:   expected a type, got 'pair'
a.cc:11:20: error: template argument 2 is invalid
a.cc:16:35: error: request for member 'push_back' in 's', which is of non-class type 'int'
   16 |                                 s.push_back(pair(i,j));
      |                                   ^~~~~~~~~
a.cc:16:49: error: no match for call to '(std::pair<int, int>) (int&, int&)'
   16 |                                 s.push_back(pair(i,j));
      |                                             ~~~~^~~~~
a.cc:23:20: error: 'begin' was not declared in this scope
   23 |         for(auto t:s){
      |                    ^
a.cc:23:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:23:20: error: 'end' was not declared in this scope
   23 |         for(auto t:s){
      |                    ^
a.cc:23:20: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
  ll N;
  cin >> N;
  
  ll ans = N+1;
  
  for (int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {

      ans = i + N / i
    }
  }
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:22: error: expected ';' before '}' token
   14 |       ans = i + N / i
      |                      ^
      |                      ;
   15 |     }
      |     ~
Language: C++

#include <bits/stdc++.h>

typedef long long ll;
const int INF = 1e9;

using namespace std; 

#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)

int main() {
    ll n;
    cin >> n;

    ll temp, ans = INF;
    REP(i, 1, int(sqrt(n) + 1) {
        if (n % i == 0) {
            temp = i + (n / i) - 2;
            if (temp < ans) ans = temp;
        }
    }

    cout << ans << endl;
}

Compiler output:
a.cc:23:2: error: unterminated argument list invoking macro "REP"
   23 | }
      |  ^
a.cc: In function 'int main()':
a.cc:15:5: error: 'REP' was not declared in this scope
   15 |     REP(i, 1, int(sqrt(n) + 1) {
      |     ^~~
a.cc:15:8: error: expected '}' at end of input
   15 |     REP(i, 1, int(sqrt(n) + 1) {
      |        ^
a.cc:10:12: note: to match this '{'
   10 | int main() {
      |            ^
Language: C++

#include <bit/stdc++.h>

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define NCK_MAX 510000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S secon

vector< ll > divisor(int64_t n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.PB(i);
      if(i * i != n) ret.PB(n / i);
    }
  }
  sort(ALL(ret));
  return (ret);
}

int main(int argc, char const *argv[]) {
  ll n; std::cin >> n;
  std::vector<ll> yakusu = divisor(n);
  ll size = SIZE(yakusu);
  if (size % 2 == 1) std::cout << yakusu[size/2] + yakusu[size/2+1] - 2 << '\n';
  else std::cout << yakusu[size/2-1] + yakusu[size/2] - 2 << '\n';
  return 0;
}

Compiler output:
a.cc:1:10: fatal error: bit/stdc++.h: No such file or directory
    1 | #include <bit/stdc++.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;

  int ans=100000000;
  for (long long i = 1; i * i <= n; ++i){
    if (n % i == 0){
       ans=min(ans,i+n/i);
    }
  }
   cout << ans-2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:15: error: no matching function for call to 'min(int&, long long int)'
   11 |        ans=min(ans,i+n/i);
      |            ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:11:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   11 |        ans=min(ans,i+n/i);
      |            ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:11:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   11 |        ans=min(ans,i+n/i);
      |            ~~~^~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
   long int N;
   cin>>N;
   bool ans=false;
  　long double e=sqrt(N);
  
   for(int i=1;i<e;i++){
      for(int j=1;j<e;j++){
         if(i*j==N){
            cout<<(i-1)+(j-1)<<endl;
            ans=true;
            break;
         }
         if(ans==true){
            break;
         }
      }
   }

}


Compiler output:
a.cc:8:3: error: extended character 　 is not valid in an identifier
    8 |   　long double e=sqrt(N);
      |   ^
a.cc: In function 'int main()':
a.cc:8:3: error: '\U00003000long' was not declared in this scope; did you mean 'ulong'?
    8 |   　long double e=sqrt(N);
      |   ^~~~~~
      |   ulong
a.cc:10:18: error: 'e' was not declared in this scope
   10 |    for(int i=1;i<e;i++){
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
   long int N;
   cin>>N;
   bool ans==false;
  
   for(int i=1;i<N;i++){
      for(int j=1;j<N;j++){
         if(i*j==N){
            cout<<(i-1)+(j-1)<<endl;
            ans=true;
            break;
         }
         if(ans==true){
            break;
         }
      }
   }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:12: error: expected initializer before '==' token
    7 |    bool ans==false;
      |            ^~
a.cc:13:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |             ans=true;
      |             ^~~
      |             abs
a.cc:16:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |          if(ans==true){
      |             ^~~
      |             abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  ll x;
  cin>>x;
  ll l=1e18;
  ll k=;
  for(int i=1;i<sqrt(x);i++){
    if(x%i==0){
      l=i+x/i-2;
      k=min(k,l);
    }
  }
  cout<<k<<endl;
  
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:8: error: expected primary-expression before ';' token
    9 |   ll k=;
      |        ^
Language: C++

N = int(input())

ans = 10**12 * 2
for i in range(1, int(N**0.5) + 1):
    if N % i == 0:
        distance = i + N//i - 2
        if ans > distance:
            ans = distance

print(ans)

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>

using namespace std;


int main() {
  int N;
  cin >> N;
  
  long ans = LONG_MAX;
  for (long a = 0; a < pow(N,0.5); i++) {
    long b = N-a+2;
    
    if(a*b==N){
      ans = min(ans, a+b-2);
    }
  }

  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:36: error: 'i' was not declared in this scope
   15 |   for (long a = 0; a < pow(N,0.5); i++) {
      |                                    ^
Language: C

include<stdio.h>
#include<math.h>
int main(void){
  long long n;
  scanf("%lld",&n);
  //if(sqrt(n)*sqrt(n)==n)printf("%.0lf",2*sqrt(n)-2);
  
    
    for(long i=sqrt(n);i>=1;i--){
      if(n%i==0)		//約数あり
      {printf("%ld",i+n/i-2);
       return 0;}
      
                }
    
  }

Compiler output:
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include<stdio.h>
      |        ^
main.c: In function 'main':
main.c:5:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |   scanf("%lld",&n);
      |   ^~~~~
main.c:3:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
    2 | #include<math.h>
  +++ |+#include <stdio.h>
    3 | int main(void){
main.c:5:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |   scanf("%lld",&n);
      |   ^~~~~
main.c:5:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:11:8: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   11 |       {printf("%ld",i+n/i-2);
      |        ^~~~~~
main.c:11:8: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:11:8: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:11:8: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C++

#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT64_MAX;
typedef long long ll;
using namespace std;

int main(){
  int64_t n; cin >> n;
  int64_t ans = INF;
  for(ll i=1;i<sqrtl(n);i++){
    if(n%i!=0) continue;
    ans = min((i-1)+(n/i-1),ans);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:14: error: no matching function for call to 'min(ll, int64_t&)'
   15 |     ans = min((i-1)+(n/i-1),ans);
      |           ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:15:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   15 |     ans = min((i-1)+(n/i-1),ans);
      |           ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:15:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   15 |     ans = min((i-1)+(n/i-1),ans);
      |           ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin>>N;
  int a=1;
  for(int64_t i=1;i*i<=N;i++){
  if(N%i==0)
    a=i;
 }
  int64_t ans=a+(N/)a-2;
  
  cout<<ans<<endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: expected primary-expression before ')' token
   11 |   int64_t ans=a+(N/)a-2;
      |                    ^
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  long long N;
  cin>>N;
  double n=sqrt(N);
  long long a,b;
  for (long long i=n/1; i>0; i--){
    if(N%i==0) {a=i;  b=N/a; break}
  
  }
  cout<<a+b-2<<endl;
}
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:11:35: error: expected ';' before '}' token
   11 |     if(N%i==0) {a=i;  b=N/a; break}
      |                                   ^
      |                                   ;
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  long N;
  cin>>N;
  long n=sqrt(N);
  for (long i=n/1; i>0; i--){
    if(N%i==0) {long a=i; long b=N/a;}
  }
  cout<<a+b-2<endl;
}
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'a' was not declared in this scope
   12 |   cout<<a+b-2<endl;
      |         ^
a.cc:12:11: error: 'b' was not declared in this scope
   12 |   cout<<a+b-2<endl;
      |           ^
Language: C++

#inlcude<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  long N;
  cin>>N;
  long n=sqrt(N);
  for (long i=n/1; i>0; i--){
    if(N%i==0) {long a=i; long b=N/a;}
  }
  cout<<a+b-2<endl;
}
    
  

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inlcude; did you mean #include?
    1 | #inlcude<iostream>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin>>N;
      |   ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<cmath>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:12:3: error: 'cout' was not declared in this scope
   12 |   cout<<a+b-2<endl;
      |   ^~~~
a.cc:12:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:12:9: error: 'a' was not declared in this scope
   12 |   cout<<a+b-2<endl;
      |         ^
a.cc:12:11: error: 'b' was not declared in this scope
   12 |   cout<<a+b-2<endl;
      |           ^
a.cc:12:15: error: 'endl' was not declared in this scope
   12 |   cout<<a+b-2<endl;
      |               ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    3 | #include<cmath>
  +++ |+#include <ostream>
    4 | using namespace std;
Language: C++

import math
N=int(input())
ans=N+1
T=round(math.sqrt(N)+1)
for i in range(1,T+1):
  if N%i==0:
    tmp=i+N//i
    if tmp<ans:
      ans=tmp
print(ans-2)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import math
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  ll n;
  cin>>n;
  ll ans=10000000000;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      ll a=n/i;
      ll b=i;
      ans=min(a+b,ans);
    }
  }
  cout<<a+b-2<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'a' was not declared in this scope
   26 |   cout<<a+b-2<<endl;
      |         ^
a.cc:26:11: error: 'b' was not declared in this scope
   26 |   cout<<a+b-2<<endl;
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  ll n;
  cin>>n;
  int ans=10000000000;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      ll a=n/i;
      ll b=i;
      ans=min(a+b,ans);
    }
  }
  cout<<a+b-2<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:11: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
   18 |   int ans=10000000000;
      |           ^~~~~~~~~~~
a.cc:23:14: error: no matching function for call to 'min(ll, int&)'
   23 |       ans=min(a+b,ans);
      |           ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:23:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   23 |       ans=min(a+b,ans);
      |           ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:23:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   23 |       ans=min(a+b,ans);
      |           ~~~^~~~~~~~~
a.cc:26:9: error: 'a' was not declared in this scope
   26 |   cout<<a+b-2<<endl;
      |         ^
a.cc:26:11: error: 'b' was not declared in this scope
   26 |   cout<<a+b-2<<endl;
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int ynumber(int n){
  int ans=0;
  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      int a=n/i;
      ans=max(a,ans);
    }
  }
  return ans;
int main()	{
  ll n;
  cin>>n;
  ll sum=0;
  int a=ynumber(n);
  int b=n/a;
  cout<<a+b-2<<endl;
}

Compiler output:
a.cc: In function 'int ynumber(int)':
a.cc:24:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   24 | int main()      {
      |         ^~
a.cc:24:9: note: remove parentheses to default-initialize a variable
   24 | int main()      {
      |         ^~
      |         --
a.cc:24:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:24:17: error: a function-definition is not allowed here before '{' token
   24 | int main()      {
      |                 ^
a.cc:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:15:19: note: to match this '{'
   15 | int ynumber(int n){
      |                   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int main(){
  ll n;
  cin>>n;
  bool ok=true;
  ll ans=100100100100100100;
  for(int i=1;i<=1000000;i++){
    if(n%i==0){
      p=i+(n/i);
      ans=min(ans,p);
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:7: error: 'p' was not declared in this scope
   13 |       p=i+(n/i);
      |       ^
Language: C++

#include <stdio.h>

#include <algorithm>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long llong;

static pair<llong, llong> min_divisors(llong n) {
  pair<llong, llong> res;
  llong min_sum = LLONG_MAX;
  for (llong i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      llong m = n / i;
      llong sum = i + m;
      if (sum < min_sum) {
        res = {i, m};
        min_sum = sum;
      }
    }
  }
  return res;
}


void CWalkOnMultiplicationTable(std::istream& in, std::ostream& out) {
    llong n;
    in >> n;
    pair<llong, llong> p = min_divisors(n);
    out << p.first + p.second - 2 << endl;
}

int main(int argc, char** argv) { CWalkOnMultiplicationTable(cin, cout); return 0; }

Compiler output:
a.cc: In function 'std::pair<long long int, long long int> min_divisors(llong)':
a.cc:19:19: error: 'LLONG_MAX' was not declared in this scope
   19 |   llong min_sum = LLONG_MAX;
      |                   ^~~~~~~~~
a.cc:12:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <utility>
  +++ |+#include <climits>
   12 | #include <vector>
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll ans = pow(10,9);
    for(ll i = 1; i*i <= n;i++){
        if(n%i != 0)continue;
        ll j = n/i;
        ans min(ans,i+j-2);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: expected ';' before 'min'
   13 |         ans min(ans,i+j-2);
      |            ^~~~
      |            ;
Language: C++

#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long

int main(){
    ll N;
    long long N;
    cin >> N;
    long long kotae = N - 1;
    for (long long i = 2; i <= sqrt(N); i++)
    {
        long long a = N / i;
        long long amari = N % i;
        if (amari == 0)
            kotae = min(kotae, i + a - 2);
    }
    cout << kotae << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: redeclaration of 'long long int N'
    8 |     long long N;
      |               ^
a.cc:7:8: note: 'long long int N' previously declared here
    7 |     ll N;
      |        ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>

using namespace std;

int main(void) {
    long n;

    cin >> n;

    vector<long> s1 = {0};
    vector<long> s2 = {0};

    int cnt = 1;

    for (long i = 1; i < sqrt(n); ++i) {
        if (n % i == 0) {
            s1.push_back(i);
            s2.push_back(n / i);
            cnt++;
        }
    }

    long r = LONG_MAX;

    for (int j = 1; j < cnt; ++j) {
        r = min(r, s1[j] + s2[j] - 2);
    }

    cout << r;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:14: error: 'LONG_MAX' was not declared in this scope
   26 |     long r = LONG_MAX;
      |              ^~~~~~~~
a.cc:5:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <complex>
  +++ |+#include <climits>
    5 |
Language: C++

N = int(input())
k = []
for i in range(1,10**6+1):
  if N%i == 0:
    k.append(i+(N//i)-2)
if len(k) == 0:
  print(N-1)
else:
  print(min(k))

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    long long n,i=2;
    cin >> n;
    int i = 2;
    while (1) {
        if (n % i == 0) {
            if (m >= n / i) break;
            else m = i;
        }
        i++;
    }
    cout << m + n / m - 2 << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: conflicting declaration 'int i'
   11 |     int i = 2;
      |         ^
a.cc:9:17: note: previous declaration as 'long long int i'
    9 |     long long n,i=2;
      |                 ^
a.cc:14:17: error: 'm' was not declared in this scope
   14 |             if (m >= n / i) break;
      |                 ^
a.cc:19:13: error: 'm' was not declared in this scope
   19 |     cout << m + n / m - 2 << endl;
      |             ^
Language: C++

#include <bits/stdc++.h>
const  int INF = 1e9;
const  int MOD = 1e9 + 7;
using namespace std;
typedef Long Long ll;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i*i<(ll)(n);i++)
#define repd(i,n,init) for(ll i=(ll)(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    repi(i,N,1){
        if(n%i != 0){
            continue;
        }
        ll j = n/i;
        ans = min(ans,i+j-2);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:5:9: error: 'Long' does not name a type; did you mean 'long'?
    5 | typedef Long Long ll;
      |         ^~~~
      |         long
a.cc: In function 'int main()':
a.cc:7:28: error: 'll' was not declared in this scope; did you mean 'all'?
    7 | #define repi(i,n,init) for(ll i=init;i*i<(ll)(n);i++)
      |                            ^~
a.cc:13:5: note: in expansion of macro 'repi'
   13 |     repi(i,N,1){
      |     ^~~~
a.cc:13:10: error: 'i' was not declared in this scope
   13 |     repi(i,N,1){
      |          ^
a.cc:7:38: note: in definition of macro 'repi'
    7 | #define repi(i,n,init) for(ll i=init;i*i<(ll)(n);i++)
      |                                      ^
a.cc:13:12: error: 'N' was not declared in this scope
   13 |     repi(i,N,1){
      |            ^
a.cc:7:47: note: in definition of macro 'repi'
    7 | #define repi(i,n,init) for(ll i=init;i*i<(ll)(n);i++)
      |                                               ^
a.cc:14:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   14 |         if(n%i != 0){
      |            ^
      |            yn
a.cc:17:11: error: expected ';' before 'j'
   17 |         ll j = n/i;
      |           ^~
      |           ;
a.cc:18:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |         ans = min(ans,i+j-2);
      |         ^~~
      |         abs
a.cc:18:25: error: 'j' was not declared in this scope; did you mean 'jn'?
   18 |         ans = min(ans,i+j-2);
      |                         ^
      |                         jn
a.cc:20:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   20 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C

#include<stdio.h>
int main(void){
  long long int i,n,x=1;
  scanf("%lld",&n);
  for(i=2;i*i<=n;i++){
    if(n%i)\==0) x=i;
  }
  printf("%lld\n",x+n/x-2);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:12: error: stray '\' in program
    6 |     if(n%i)\==0) x=i;
      |            ^
main.c:6:13: error: expected expression before '==' token
    6 |     if(n%i)\==0) x=i;
      |             ^~
main.c:6:16: error: expected statement before ')' token
    6 |     if(n%i)\==0) x=i;
      |                ^
Language: C++

#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	ll N;

	cin >> N ;

	int a = sqrt(N);
	int max = 1;

	for (int i = 1; i < a; i++) {
		if (N%i == 0 && i > max) {
			max = i;
		}
	}


	if (max == 1) {
		ce(N-1)
	}
	else {
		ce(max-2+N/max)
	}


}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:28:17: error: 'sqrt' was not declared in this scope
   28 |         int a = sqrt(N);
      |                 ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  long long i = 1;
  long long j = 0;
  long long k = 0;
  long long mini = INT_MAX;
  for(i = 1;i<=(n+1)2;i++){
   if(n%i==0){
     j = n/i;
     k = i+j-2;
     mini = min(mini,k);
   }
  }
  cout << mini;
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:21: error: expected ';' before numeric constant
   10 |   for(i = 1;i<=(n+1)2;i++){
      |                     ^
      |                     ;
a.cc:10:22: error: expected ')' before ';' token
   10 |   for(i = 1;i<=(n+1)2;i++){
      |      ~               ^
      |                      )
a.cc:10:26: error: expected ';' before ')' token
   10 |   for(i = 1;i<=(n+1)2;i++){
      |                          ^
      |                          ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N;
  cin >> N;
  for(long long i=1;i*i <= N;++i){
 if( N % i != 0)    continue;
   long long j = N/i;
long long ans = min(ans,i+j-2);
  }
cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 | cout << ans << endl;
      |         ^~~
      |         abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N;
  cin >> N;
  for(long long i=1;i*i <= N;++i){
 if( N % i != 0)    continue;
   long long j = N/i;
int ans = min(ans,i+j-2);
  }
cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:14: error: no matching function for call to 'min(int&, long long int)'
   10 | int ans = min(ans,i+j-2);
      |           ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:10:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   10 | int ans = min(ans,i+j-2);
      |           ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:10:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   10 | int ans = min(ans,i+j-2);
      |           ~~~^~~~~~~~~~~
a.cc:12:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 | cout << ans << endl;
      |         ^~~
      |         abs
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
int N;
  cin >> N;
  for(long long i=1;i*i <= N;++i){
 if( N % i != 0)    continue;
   long long j = N/i;
ans = min(ans,i+j-2);
  }
cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:1: error: 'ans' was not declared in this scope; did you mean 'abs'?
   10 | ans = min(ans,i+j-2);
      | ^~~
      | abs
a.cc:12:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 | cout << ans << endl;
      |         ^~~
      |         abs
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  long N;
  cin >> N;
  long ans = 0;
  for (long i = 1; i * i <= N; i++) {
    if (N % i == 0) ans = max(ans, i);
  }
  cout << i + N / i << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:11: error: 'i' was not declared in this scope
   11 |   cout << i + N / i << "\n";
      |           ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
long long mmin(long long a,long long b)
{
	if(a<b)return a;
	return b;
}
int main()
{
	long long n;
	cin>>n;
	long long i;
	long long ans=1e12;
	if(n==1)
	{
		puts('0');
		return 0;
	 } 
	for(i=1;i<=sqrt(n)+1;i++)
	{
		if(n%i==0)
		{
			ans=mmin(ans,i+n/i-2);
		}
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:22: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   20 |                 puts('0');
      |                      ^~~
      |                      |
      |                      char
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdio.h:714:30: note:   initializing argument 1 of 'int puts(const char*)'
  714 | extern int puts (const char *__s);
      |                  ~~~~~~~~~~~~^~~
Language: C++

#include<iostream>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int M;
    M=sqrt(N);
    for(int i=M;i>=1;i--)
    if(N%i==0){cout<<i-2+(N/i)<<endl;break;}

}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'sqrt' was not declared in this scope
    8 |     M=sqrt(N);
      |       ^~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<unordered_map>
using namespace std;
int main()
{
    long long int n,ans,x,y;
    double temp=0.0;
    cin>>n;
    temp=sqrt(n);
    temp=(int)temp;
    if(temp*temp!=n)
    {
        int start = temp-1;
        while(start>0)
        {
            if(n%start==0)
            {
                x=start;
                y=n/start;
                break;
            }
            start--;
        }
    }
    else
    {
        x=temp;
        y=temp;
    }
    ans=x+y-2;
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: 'sqrt' was not declared in this scope
   14 |     temp=sqrt(n);
      |          ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long mn=INF,tmp=0;
    for(long long i=1;i<sqrt(n);i++){
        if(n%i==0){
            tmp =i+n/i-2;
            mn=min(mn,tmp);
        }
    }
    cout <<mn;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:18: error: 'INF' was not declared in this scope
    6 |     long long mn=INF,tmp=0;
      |                  ^~~
a.cc:9:13: error: 'tmp' was not declared in this scope; did you mean 'tm'?
    9 |             tmp =i+n/i-2;
      |             ^~~
      |             tm
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  REP(i,1,sqrt(N)){
    if(N%i==0) ans=i+N/i;
  }
  cout<<ans<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:22:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |     if(N%i==0) ans=i+N/i;
      |                ^~~
      |                abs
a.cc:24:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   24 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long n,ans=1e12;
int main(){
	cin>>n;
	for(int i=1;i<=sqre(n);i++)
	    if(n%i==0) ans=min(ans,n/i+i-2);
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:24: error: 'sqre' was not declared in this scope; did you mean 'sqrt'?
    6 |         for(int i=1;i<=sqre(n);i++)
      |                        ^~~~
      |                        sqrt
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <math>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  ll N;
  cin >> N;
  int min = 99999999999999;
  for (ll i = 1; i < sqrt(N) + 5; i++) {
    if (N % i == 0) {
      if (N / i + i < min) {
        min = N / i + i;
      }
    }
  }
  cout << min-2;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

Compiler output:
a.cc:5:10: fatal error: math: No such file or directory
    5 | #include <math>
      |          ^~~~~~
compilation terminated.