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

#include <iostream>
#include <cmath>
using namespace std;

int main() {

	int i, N, A, B, S;
	S = 0;

	cin >> N;

	for(i=1, i<=sqrt(N), i++){
	    if(N%i==0){
	        A = i;
	        B = N/i;
	        if (A+B>S){
	            S = A + B;
	        }
	    }

	cout << S-2 << endl;

	return 0;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:33: error: expected ';' before ')' token
   12 |         for(i=1, i<=sqrt(N), i++){
      |                                 ^
      |                                 ;
a.cc:26:2: error: expected primary-expression at end of input
   26 | }
      |  ^
a.cc:26:2: error: expected ';' at end of input
   26 | }
      |  ^
      |  ;
a.cc:26:2: error: expected primary-expression at end of input
a.cc:26:2: error: expected ')' at end of input
   26 | }
      |  ^
      |  )
a.cc:12:12: note: to match this '('
   12 |         for(i=1, i<=sqrt(N), i++){
      |            ^
a.cc:26:2: error: expected statement at end of input
   26 | }
      |  ^
a.cc:26:2: error: expected '}' at end of input
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <cmath>
using namespace std;

int main() {

	int i, N, A, B, S;
	S = 0;

	cin >> N;

	for(i=1, i<=int(sqrt(N)), i++){
	    if(N%i==0){
	        A = i;
	        B = N/i;
	        if (A+B>S){
	            S = A + B;
	        }
	    }

	cout << S-2 << endl;

	return 0;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:38: error: expected ';' before ')' token
   12 |         for(i=1, i<=int(sqrt(N)), i++){
      |                                      ^
      |                                      ;
a.cc:26:2: error: expected primary-expression at end of input
   26 | }
      |  ^
a.cc:26:2: error: expected ';' at end of input
   26 | }
      |  ^
      |  ;
a.cc:26:2: error: expected primary-expression at end of input
a.cc:26:2: error: expected ')' at end of input
   26 | }
      |  ^
      |  )
a.cc:12:12: note: to match this '('
   12 |         for(i=1, i<=int(sqrt(N)), i++){
      |            ^
a.cc:26:2: error: expected statement at end of input
   26 | }
      |  ^
a.cc:26:2: error: expected '}' at end of input
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <iostream>
using namespace std;

int main() {

	int i, N, A, B, S;
	S = 0;

	cin >> N;
    
	for(i=1, i<=int(sqrt(N)), i++){
	    if(N%i==0){
	        A = i;
	        B = N/i;
	        if (A+B>S){
	            S = A + B;
	        }
	    }
	
	cout << S-2 << endl;

	return 0;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: 'sqrt' was not declared in this scope
   11 |         for(i=1, i<=int(sqrt(N)), i++){
      |                         ^~~~
a.cc:25:2: error: expected primary-expression at end of input
   25 | }
      |  ^
a.cc:25:2: error: expected ';' at end of input
   25 | }
      |  ^
      |  ;
a.cc:25:2: error: expected primary-expression at end of input
a.cc:25:2: error: expected ')' at end of input
   25 | }
      |  ^
      |  )
a.cc:11:12: note: to match this '('
   11 |         for(i=1, i<=int(sqrt(N)), i++){
      |            ^
a.cc:25:2: error: expected statement at end of input
   25 | }
      |  ^
a.cc:25:2: error: expected '}' at end of input
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C

#include<stdio.h.
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)
int main(void)
{
  long long n,i=0,pre=1000000000100,ans=pre;
  scanf("%lld",&n);
  while(1){
    if(n%i==0){
      ans=i+n/i-2;
      if(ans>pre){
        break;
      }
    }
    pre=ans;
    i++;
  }
  printf("%lld",pre);
  return 0;
}

Compiler output:
main.c:1:18: error: missing terminating > character
    1 | #include<stdio.h.
      |                  ^
main.c:1:9: fatal error: stdio.h.: No such file or directory
    1 | #include<stdio.h.
      |         ^
compilation terminated.
Language: C++

#include<cmath>
 
using namespace std;
 
int main(){
	int N;
  	cin >> N;
  	long long move_a,move_b;
  	long long move_min=N+100;
  	for(int move_a=sqrt(N); move_a>0; --move_a){
      if(N%move_a==0){
        move_b = N /move_a;
        if(move_min > (move_a+move_b-2)) move_min=(move_a+move_b-2);
      }
    }
  
  	cout << move_min;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin >> N;
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<cmath>
  +++ |+#include <iostream>
    2 | 
a.cc:17:9: error: 'cout' was not declared in this scope
   17 |         cout << move_min;
      |         ^~~~
a.cc:17:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include<iostream>
#include<vector>
#include<cmath>
 
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int result;
  int min_move = N;
  int offset;
  double N_root = sqrt(N);
  for(int i=1; i<=N_root; i++){
    offset = round(N-root - i);
  	for(int j=offset; j<=N; j++){
      result = i*j;
      if(result>N){
        break;
      }
      else if(result==N){
        if(min_move > (i+j-2)) min_move=(i+j-2);
      }
    }
  }
  
  cout << min_move;
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:22: error: 'root' was not declared in this scope; did you mean 'N_root'?
   15 |     offset = round(N-root - i);
      |                      ^~~~
      |                      N_root
Language: C++

#include<steio.h>

main(){
  int num,gcd,i;
  
  scanf("%d",&num);
  
  // 約数を探す
  gcd = num / 2;
  while(num%gcd!=0){
    gcd--;
  }
  
  printf("%d",gcd+num/gcd-2);
  
}

Compiler output:
a.cc:1:9: fatal error: steio.h: No such file or directory
    1 | #include<steio.h>
      |         ^~~~~~~~~
compilation terminated.
Language: C

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

int main() {
	long long N;
    cin >> N;

    long long i = 1;
    while (i * i <= N) {
      i++;
    }
    i--;
    
  	long long j;
    for (; ; i--) {
      	if (N % i == 0) {
          j = N / i;
          break;
        }
    }
  
    cout << i + j - 2 << endl;
}

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

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

int main()
{
  long long int n;
  cin>>n;
  long long int mi = (long long int)(1e13);
  for(int i=1;i<=sqrt(n);i++)
  {
    long long int curr = N/i;
    if(curr*i == N)
      mi = min(mi,curr + i);
  }
  mi -= 2;
  cout<<mi;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:26: error: 'N' was not declared in this scope
   11 |     long long int curr = N/i;
      |                          ^
Language: C

#include <stdio.h>
#include <math.h>
int main()
{
long N;
  long m[N];
  long min;
  long a=0;
scanf("%ld",&N);
  for(long i=1;i<=sqrt(N);i++)
  {
if(N%i==0)
  int j=N/i;
   {
   a++;
       m[a]=i+j-2;
      if (m[a]<=m[a-1])
      {
      min=m[a];
      }
   }
  }
  
  printf("%ld",min);
}

Compiler output:
main.c: In function 'main':
main.c:13:3: error: expected expression before 'int'
   13 |   int j=N/i;
      |   ^~~
main.c:16:15: error: 'j' undeclared (first use in this function)
   16 |        m[a]=i+j-2;
      |               ^
main.c:16:15: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#include <math.h>
int main()
{
long N;
  long m[N];
  long min;
  long a=0;
scanf("%ld",&N);
  for(long i=1;i<=sqrt(N);i++)
  {
if(N%i==0)
  int j=N/i;
   {
   a++;
       m[a]=i+j-2;
      if (m[a]<=m[a-1])
      {
      min=m[a];
      }
   }
  }
  }
  printf("%ld",min);
}

Compiler output:
main.c: In function 'main':
main.c:13:3: error: expected expression before 'int'
   13 |   int j=N/i;
      |   ^~~
main.c:16:15: error: 'j' undeclared (first use in this function)
   16 |        m[a]=i+j-2;
      |               ^
main.c:16:15: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:24:10: error: expected declaration specifiers or '...' before string constant
   24 |   printf("%ld",min);
      |          ^~~~~
main.c:24:16: error: unknown type name 'min'
   24 |   printf("%ld",min);
      |                ^~~
main.c:25:1: error: expected identifier or '(' before '}' token
   25 | }
      | ^
Language: C++

#include <iostream>
using namespace std;

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

	long long ret = n - 1;
	long long max = sqrt(n);
	long long temp = 0;
	for (long long i = 2; i <= max; ++i) {
		if (n % i == 0) {
			temp = n / i + i - 2;
			if (temp < ret) {
				ret = temp;
			}
		}
	}
	cout << ret << endl;
	return 0;
}

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

#include <stdio.h>
#include <math.h>
int main()
{
long N;
  long m[N];
  long min;
  long a=0;
scanf("%ld"&N);
  for(long i=1;i<=squrt(N);i++)
  {
if(N%i==0)
  int j=N/i;
   {
   a++;
       m[a]=i+j-2;
      if (m[a]<=m[a-1])
      {
      min=m[a];
      }
   }
  }
  }
  printf("%ld",min);
}

Compiler output:
main.c: In function 'main':
main.c:9:12: error: invalid operands to binary & (have 'char *' and 'long int')
    9 | scanf("%ld"&N);
      |       ~~~~~^
      |       |
      |       char *
main.c:10:19: error: implicit declaration of function 'squrt'; did you mean 'sqrt'? [-Wimplicit-function-declaration]
   10 |   for(long i=1;i<=squrt(N);i++)
      |                   ^~~~~
      |                   sqrt
main.c:13:3: error: expected expression before 'int'
   13 |   int j=N/i;
      |   ^~~
main.c:16:15: error: 'j' undeclared (first use in this function)
   16 |        m[a]=i+j-2;
      |               ^
main.c:16:15: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:24:10: error: expected declaration specifiers or '...' before string constant
   24 |   printf("%ld",min);
      |          ^~~~~
main.c:24:16: error: unknown type name 'min'
   24 |   printf("%ld",min);
      |                ^~~
main.c:25:1: error: expected identifier or '(' before '}' token
   25 | }
      | ^
Language: C

#include <stdio.h>
int main()
{
long N;
  long m[N];
  long min;
  long a=0;
scanf("%ld"&N);
  for(long i=0;i<=N;i++)
  {
  for(long j=0;j<=N;j++)
  {
  	if(i*j==N)
   {
   a++;
       m[a]=i+j-2;
      if (m[a]<=m[a-1])
      {
      min=m[a];
      }
   }
  }
  }
  printf("%ld",min);
}

Compiler output:
main.c: In function 'main':
main.c:8:12: error: invalid operands to binary & (have 'char *' and 'long int')
    8 | scanf("%ld"&N);
      |       ~~~~~^
      |       |
      |       char *
Language: C

#include <stdio.h>
int main()
{
int N;
  int m[N];
  int min;
  int a=0;
scanf("%d"&N);
  for(int i=0;i<=N;i++)
  {
  for(int j=0;j<=N;j++)
  {
  	if(i*j==N)
   {
   a++;
       m[a]=i+j-2;
      if (m[a]<=m[a-1])
      {
      min=m[a];
      }
   }
  }
  }
  printf("%d",min);
}

Compiler output:
main.c: In function 'main':
main.c:8:11: error: invalid operands to binary & (have 'char *' and 'int')
    8 | scanf("%d"&N);
      |       ~~~~^
      |       |
      |       char *
Language: C

#include <stdio.h>
int main()
{
int N;
  int m[N];
  int min;
scanf("%d"&N);
  for(int i=0;i<=N;i++)
  {
  for(int j=0;j<=N;j++)
  {
  	if(i*j==N)
   {int a++;
    m[a]=i+j-2;
      if (m[a]<=m[a-1])
      {
      min=m[a];
      }
   }
  }
  }
  printf("%d",min);
}

Compiler output:
main.c: In function 'main':
main.c:7:11: error: invalid operands to binary & (have 'char *' and 'int')
    7 | scanf("%d"&N);
      |       ~~~~^
      |       |
      |       char *
main.c:13:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
   13 |    {int a++;
      |          ^~
main.c:13:12: error: expected expression before ';' token
   13 |    {int a++;
      |            ^
main.c:14:7: error: 'a' undeclared (first use in this function)
   14 |     m[a]=i+j-2;
      |       ^
main.c:14:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

long main(void){
    long N;
    long cnt = 0;
    scanf("%ld", &N);
    long array[1000] = {0};
    for (long i = (long)sqrt(N); i > 0 ; i--) {
        if (N % i == 0) {
            printf("%ld\n",i + N/i - 2);
            return 0;
        }
    }
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
inline int read()
{
	int x=0,t=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*t;
}
ll n;
int main()
{
	cin>>n;
	for(ll i=sqrt(n);i>=1;i--)
	{
		if(n%i==0)
		{
			ll ans=i+(n/i)-2;
			cout<<ans<<endl;
			return 0;
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:18: error: 'sqrt' was not declared in this scope
   19 |         for(ll i=sqrt(n);i>=1;i--)
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	ll N; cin >> N;
	ll ans = N - 1;
	FOR(i, 1, 1000010) {
		if (N % i == 0) {
			ans = min(ans, i + N / i - 2);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:13: error: 'i' was not declared in this scope
    9 |         FOR(i, 1, 1000010) {
      |             ^
a.cc:9:9: error: 'FOR' was not declared in this scope
    9 |         FOR(i, 1, 1000010) {
      |         ^~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:3:13: error: expected primary-expression before 'long'
    3 | #define int long long
      |             ^~~~
a.cc:7:17: note: in expansion of macro 'int'
    7 |       for(int i=int(sqrt(n)) ; i>=1 ; i--) {
      |                 ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a;
  cin >> N;
  a=N-1;
  for(int i=1;i<=sqrt(N);i++){
    if(N%i==0)
      int p=i;
      int q=N/i;
  }
  cout << p+q-2;
}


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

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

int main() {
  int A,B,C,D,N;
  cin >> N;
  A=N-1;

  for(int i=2;(i*i)<=A;i++){
    if((N%i)==0&&((N/i)+i-2)<A){
      A=(N/i)+i-2;
    }
  }
cout << A << endl;

}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	long long int n,a,b;
	cin >> n;
	a = b = 0;
	double m = sqrt(n);
	for (int i = 1; i <m ; i++) {
		if (n % i == 0) {
			a = i;
			b = n / a;
		}
	}
	cout << a + b - 2 << endl;
}

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

#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	long long int n,a,b;
	cin >> n;
	long double m = sqrt(n);
	a = b = 0;
	for (int i = 1; i < m; i++) {
		if (n % i == 0) {
			a = i;
			b = n / a;
		}
	}
	cout << a + b - 2 << endl;
}

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

#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	long long int n,a,b;
	cin >> n;
	long long int m = n;
	a = b = 0;
	for (int i = 1; i < sqrt(m); i++) {
		if (n % i == 0) {
			a = i;
			b = n / a;
		}
	}
	cout << n << endl<< a << endl << b << endl;
	cout << a + b - 2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:29: error: 'sqrt' was not declared in this scope
   12 |         for (int i = 1; i < sqrt(m); i++) {
      |                             ^~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:36: error: 'sqrt' was not declared in this scope
    8 |         for (long long i = 1; i <= sqrt(N); i++){
      |                                    ^~~~
Language: C++

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

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

#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b,min,flag=0,;
  cin>>n;  
  for(int i=1;i<9999999;i++){
    if(n%i==0){
      if(min>i+(n/i) || flag==0){
	min=i+(n/i);
	flag=1;
      }
    }
  }
  cout<<min-2<<'\n';
  return(0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:23: error: expected unqualified-id before ';' token
   38 |   ll n,a,b,min,flag=0,;
      |                       ^
Language: C++

#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  ll int x;
  cin>>x;
  vector<ll int> y(2);
  y[0]=1;
  y[1]=x;
  rep(i,2,ceil(sqrt(x))){
    if(x%i==0){
      y.push_back(i);
      y.push_back(x/i);
    }
  }
  if(y.length()%2){
    cout<<(sqrt(x)-1)*2;
  }else{
    asort(y);
    y[y.length()/2]+y[y.length()/2+1]-2;
  }
    
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Compiler output:
a.cc: In function 'int main()':
a.cc:59:8: error: 'class std::vector<long long int>' has no member named 'length'
   59 |   if(y.length()%2){
      |        ^~~~~~
a.cc:63:9: error: 'class std::vector<long long int>' has no member named 'length'
   63 |     y[y.length()/2]+y[y.length()/2+1]-2;
      |         ^~~~~~
a.cc:63:25: error: 'class std::vector<long long int>' has no member named 'length'
   63 |     y[y.length()/2]+y[y.length()/2+1]-2;
      |                         ^~~~~~
Language: C++

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


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <vector>
#include <unordered_map>
#include <sort>

using namespace std;

vector<long> makePrimes(const long upper=1000000){
    vector<long> primes;
    long p[upper+1];
    for(long i=0;i<upper;i+=2){
        p[i] = 0;
        p[i+1] = i+1;
    }
    p[1] = 0;
    p[2] = 2;
    primes.push_back(2);
    for(long i=3;i<upper;i+=2){
        if(p[i]==0){
            continue;
        }
        primes.push_back(i);
        for(long j=i*i;j < upper;j+=(2*i)){
            p[j] = 0;
        }
    }
    return primes;
}

vector<long>primes = makePrimes();

unordered_map<long,int> factorize(long n){
    unordered_map<long,int> factors;

    for(auto p:primes){
        if(n == 1){
            return factors;
        }else if(n % p == 0){
            int e=1;
            for(;n % p==0;e++,n /= p);
            factors[p] = e;
        }
    }
    factors[n] = 1; // n is a prime number!!
    return factors;
}

vector<long> getDivisors(long n){
    unordered_map<long,int> factors = factorize(n);
    vector<long> d1={1};
    vector<long> d2;
    for(auto it=factors.cbegin();it != factors.cend();++it){
        d2.clear();
        int p = 1;
        int emax = it->second;
        for(int e=0;e < it->second;++e){
            for(auto d : d1){
                d2.push_back(p*d);
            }
            p *= it->first;
        }
        d1.swap(d2);
        d2.clear();
    }
    sort(d1.begin(),d1.end());
    return d1;
}

int main(){
    long n;
    cin >> n;
    vector<long> ds = getDivisors(n);
    long ans = n;
    for(auto d1:ds){
        if(d1*d1 > n){
            break;
        }
        int d2 = n / d1;
        if(d1+d2-2 < ans){
            ans = d1+d2-2;
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:4:10: fatal error: sort: No such file or directory
    4 | #include <sort>
      |          ^~~~~~
compilation terminated.
Language: Java

import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
  	Scanner s = new Scanner(System.in);
    long n = s.nextLong();
    s.close();
    
    long sqr = Math.sqrt(n).longValue();
    for(long i = sqr; i > 0; i--) {
      if (n % i == 0) {
        System.out.printf("%d", i + n / i - 2);
        return;
      }
    }

  }
}


Compiler output:
Main.java:10: error: double cannot be dereferenced
    long sqr = Math.sqrt(n).longValue();
                           ^
1 error
Language: Java

import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
  	Scanner s = new Scanner(System.in);
    long n = s.nextLong();
    s.close();
    
    long sqr = (long)Math.sqrt(n).longValue();
    for(long i = sqr; i > 0; i--) {
      if (n % i == 0) {
        System.out.printf("%d", i + n / i - 2);
        return;
      }
    }

  }
}


Compiler output:
Main.java:10: error: double cannot be dereferenced
    long sqr = (long)Math.sqrt(n).longValue();
                                 ^
1 error
Language: Java

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
  	Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    s.close();
    
    int l = 1, r = n;
    int maxL = 1, minR = n;
    while (l <= r) {
    	int p = l * r;
      	if (p == n) {
          maxL = l;
          minR = r;
          continue;
        }
      	if (p < n) {
        	l++;
        } else {
        	r--;
        }
    }
    System.out.printf("%d", maxL + maxR - 2);
  }
}

Compiler output:
Main.java:24: error: cannot find symbol
    System.out.printf("%d", maxL + maxR - 2);
                                   ^
  symbol:   variable maxR
  location: class Main
1 error
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: expected primary-expression before ')' token
   12 |      if(N/i >= i)){
      |                  ^
Language: C++

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


int main(){
  long N;
  long ans = 1000000000000;
  long hold = 0;
  
  for(int i = 1;i<=sqrt(N);i++;){
    if(N%i == 0){
      hold=i+N/i-2;
      ans = min(ans,hold);
    }
  }
  
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:31: error: expected ')' before ';' token
   10 |   for(int i = 1;i<=sqrt(N);i++;){
      |      ~                        ^
      |                               )
a.cc:10:32: error: expected primary-expression before ')' token
   10 |   for(int i = 1;i<=sqrt(N);i++;){
      |                                ^
Language: C++

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


int main(){
  long N;
  long ans = 1000000000000;
  long hold = 0;
  
  for(int i = 1,i<=sqrt(N),i++){
    if(N%i == 0){
      hold=i+N/i-2;
      ans = min(ans,hold);
    }
  }
  
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: expected ';' before '<=' token
   10 |   for(int i = 1,i<=sqrt(N),i++){
      |                  ^~
      |                  ;
a.cc:10:18: error: expected primary-expression before '<=' token
   10 |   for(int i = 1,i<=sqrt(N),i++){
      |                  ^~
a.cc:10:31: error: expected ';' before ')' token
   10 |   for(int i = 1,i<=sqrt(N),i++){
      |                               ^
      |                               ;
Language: C++

n = int(input())

ans = n+1
for i in range(2, 10**6+1):
    if n%i == 0:
        ans = min(ans, i + n//i)
print(ans-2)

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

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

int main() {
  long n;
  cin>>n;
  long min = 1000000000000;
  for(long i=1; i<=sqrt(n)+1; i++){
    if(n%i==0&&min>n%i+i){
        min = n%i + i;
        }
      }
    }   
  cout << min - 2 << endl;
}


Compiler output:
a.cc:14:3: error: 'cout' does not name a type
   14 |   cout << min - 2 << endl;
      |   ^~~~
a.cc:15:1: error: expected declaration before '}' token
   15 | }
      | ^
Language: C++

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

int main() {
  long n;
  cin>>n;
  long min = 1000000000000;
  for(long i=0; i<=sqrt(n)+1; i++){
    if(n%i==0&&min>n%i+i){
        min = n%i + i;
        }
      }
    }   
  cout << min - 2 << endl;
}


Compiler output:
a.cc:14:3: error: 'cout' does not name a type
   14 |   cout << min - 2 << endl;
      |   ^~~~
a.cc:15:1: error: expected declaration before '}' token
   15 | }
      | ^
Language: C++

N = int(input())
ans = 10**14
for i in range(1,int(N**0.5)+1):
    if N%i == 0:
        ans = min(ans, N//i+i-2)
print(ans)


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

// ABC144C.cpp
//#include "pch.h"
#include <iostream>
#include <algorithm> // minを使う
using namespace std;
int main()
{
	long long N;
	cin >> N;
	long long ans = 1000000000000;
	long long step = 0;
	long long ns = sqrt(N);
	for (long long i = 1; i <= ns; i++)
	{
		if (N%i == 0)
		{
			step = i + N / i - 2;
			ans = min(ans, step);
		}
	}
	cout << ans << endl;
}

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ans, d;
  unsigned __int64 n;
  cin >> n;
  d = pow(n, 0.5);
  for (int i = d; i >= 1; i--){
    if (n % i == 0) {
      ans = i;
      break;
    }
  }
  if (ans == 1) {
    cout << n - 1 << "\n";
  } else {
    cout << ans + n/ans - 2 << "\n";
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: expected initializer before 'n'
   10 |   unsigned __int64 n;
      |                    ^
a.cc:11:10: error: 'n' was not declared in this scope
   11 |   cin >> n;
      |          ^
Language: C++

#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
  int N;
  int result;
  int min_move = N;
  double N_root = sqrt(N);
  
  for(int i=1; i<=N_root; i++){
  	for(int j=round(N_root); i<=N; i++){
      result = i*j;
      if(i*j=N){
        if(min_move > (i+j-2)) min_move=(i+j-2);
      }
    }
  }
  
  cout << min_move;
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: lvalue required as left operand of assignment
   16 |       if(i*j=N){
      |          ~^~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N;
  int result;
  int min_move = N;
  double N_root = sqrt(N);
  
  for(int i=1; i<=N_root; i++){
  	for(int j=round(N_root); i<=N; i++){
      result = i*j;
      if(i*j=N){
        if(min_move > (i+j-2)) min_move=(i+j-2);
      }
    }
  }
  
  cout << min_move;
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:19: error: 'sqrt' was not declared in this scope
   10 |   double N_root = sqrt(N);
      |                   ^~~~
a.cc:13:19: error: 'round' was not declared in this scope
   13 |         for(int j=round(N_root); i<=N; i++){
      |                   ^~~~~
a.cc:15:11: error: lvalue required as left operand of assignment
   15 |       if(i*j=N){
      |          ~^~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N;
  int result;
  int min_move = N;
  double N_root = sprt(N);
  
  for(int i=1; i<=N_root; i++){
  	for(int j=round(N_root); i<=N; i++){
      result = i*j;
      if(i*j=N){
        if(min_move > (i+j-2)) min_move=(i+j-2);
      }
    }
  }
  
  cout << min_move;
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:19: error: 'sprt' was not declared in this scope
   10 |   double N_root = sprt(N);
      |                   ^~~~
a.cc:13:19: error: 'round' was not declared in this scope
   13 |         for(int j=round(N_root); i<=N; i++){
      |                   ^~~~~
a.cc:15:11: error: lvalue required as left operand of assignment
   15 |       if(i*j=N){
      |          ~^~
Language: C++

#include <stdio.h>
#include <math.h>
long long int main(void){
  int N;
  scanf("%lld", &N);
  long long int a, b;
  for(long long int i = 1; i <= sqrt(N); i++){
  	if(N % i ==0){
  		a = i;
  		b = N / i;
  	}
  }
  printf("%lld",a + b -2);
  return 0;
}

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

//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Online Judge: Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF LL(1e18);
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define EMPP emplace_back
#define vii vector<int>
#define vll vector<LL>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sf1(v) scanf("%I64d",&v);
#define sf2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sf3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	LL n;
	cin >> n;
	vector<LL>a;
	for (LL i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			a.push_back(i);
			if (n / i != i)a.push_back(n / i);
		}
	}
	LL ans = INF;
	for (LL i = 0; i<a.size(); i++) {
		for (LL j = 0; j<a.size(); j++) {
			if (a[i] * a[j] == n)ans = min(ans, a[i] + a[j] - 2);
		}
	}
	cout << ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:12: error: expected primary-expression before 'long'
   14 | #define LL long long
      |            ^~~~
a.cc:20:13: note: in expansion of macro 'LL'
   20 | #define INF LL(1e18);
      |             ^~
a.cc:105:18: note: in expansion of macro 'INF'
  105 |         LL ans = INF;
      |                  ^~~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  int target = N;
  int flag=1;
  int index;
  vector<int> prime;
  int A=1;
  int B=1;
  
  while(flag){
    if(target%2==0){
    	prime[index] = target / 2;
    }
    else if(target%3==0){
      	prime[index] = target / 3;
    }
    else{
      	prime[index] = target;
      	flag = 0;
    }
    index++;
    target = prime[index]
  }
 
 for(int i=0; i<(int)prime.size();++i){
   if(i== ((int)prime.size()-1) )	B=prime[i];
   else	A = A*prime[i];
 }
 
  int move = A-1+B-1;
  cout << move << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:26: error: expected ';' before '}' token
   28 |     target = prime[index]
      |                          ^
      |                          ;
   29 |   }
      |   ~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  int target = N;
  int flag=1;
  int index;
  vector<int> prime;
  int A=1;
  int B=1;
  
  while(flag){
    if(target%2==0){
    	prime[index] = target / 2;
    }
    else if(target%3==0){
      	prime[index] = target / 3;
    }
    else{
      	prime[index] = target;
      	flag = 0;
    }
    index++;
  }
 
 for(int i=0; i<(int)prime.size();++i){
   if(i== ((int)prime.size-1) )	B=prime[i];
   else	A = A*prime[i];
 }
 
  int move = A-1+B-1;
  cout << move << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:23: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   31 |    if(i== ((int)prime.size-1) ) B=prime[i];
      |                 ~~~~~~^~~~
      |                           ()
Language: C++

#include<iostream>
#include<vector>

int main(){
  int N;
  cin >> N;
  int target = N;
  int flag=1;
  int index;
  vector<int> prime;
  int A=1;
  int B=1;
  
  while(flag){
    if(target%2==0){
    	prime[index] = target / 2;
    }
    else if(target%3==0){
      	prime[index] = target / 3;
    }
    else{
      	prime[index] = target;
      	flag = 0;
    }
    index++;
  }
 
 for(int i=0; i<(int)prime.size();++i){
   if(i== ((int)prime.size-1) )	B=prime[i];
   else	A = A*prime[i];
 }
 
  int move = A-1+B-1;
  cout << move << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |   cin >> N;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:10:3: error: 'vector' was not declared in this scope
   10 |   vector<int> prime;
      |   ^~~~~~
a.cc:10:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector<int> prime;
      |          ^~~
a.cc:16:9: error: 'prime' was not declared in this scope
   16 |         prime[index] = target / 2;
      |         ^~~~~
a.cc:19:9: error: 'prime' was not declared in this scope
   19 |         prime[index] = target / 3;
      |         ^~~~~
a.cc:22:9: error: 'prime' was not declared in this scope
   22 |         prime[index] = target;
      |         ^~~~~
a.cc:28:22: error: 'prime' was not declared in this scope
   28 |  for(int i=0; i<(int)prime.size();++i){
      |                      ^~~~~
a.cc:34:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   34 |   cout << move << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:34:19: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   34 |   cout << move << endl;
      |                   ^~~~
      |                   std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

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

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

int main() {
  long n;
  cin>>n;
  long min = 1000000000000;
  for(long i=0; i<=1000000; i++){
    for(long j=0; j<=1000000; j++){
      if(i*j=n&&min>i+j){
        min = i+j;
        }
      }
    }   
  cout << min - 2 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: lvalue required as left operand of assignment
   10 |       if(i*j=n&&min>i+j){
      |          ~^~
Language: C++

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

int main() {
  int n;
  cin>>n;
  int min = 1000000000000;
  for(int i=0; i<=1000000; i++){
    for(int j=0; j<=1000000; j++){
      if(i*j=n&&min>i+j){
        min = i+j;
        }
      }
    }   
  cout << min - 2 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: warning: overflow in conversion from 'long int' to 'int' changes value from '1000000000000' to '-727379968' [-Woverflow]
    7 |   int min = 1000000000000;
      |             ^~~~~~~~~~~~~
a.cc:10:11: error: lvalue required as left operand of assignment
   10 |       if(i*j=n&&min>i+j){
      |          ~^~
Language: C

#include<stdio.h>
 int main(void){
   int i,j,N,ans,a=10000000,b=1000000;
   
  scanf("%d",&N);
   
   for(i = N;i > 0;i--){
       for(j = N;j > 0;j--){
        if(i*j==N){
            /*a = (i < a)? i : a;
            b = (j < b)? j : b;*/
            ans = (i + j < a + b)? a=i,b=j: a,b;
            //printf("(%d,%d)",i,j);
            break;
        }   
       }
   }
   printf("%d",a-1+b-1);
return 0;
}
   printf("%ld",a-1+b-1);
return 0;
}

Compiler output:
main.c:21:11: error: expected declaration specifiers or '...' before string constant
   21 |    printf("%ld",a-1+b-1);
      |           ^~~~~
main.c:21:17: error: unknown type name 'a'
   21 |    printf("%ld",a-1+b-1);
      |                 ^
main.c:22:1: error: expected identifier or '(' before 'return'
   22 | return 0;
      | ^~~~~~
main.c:23:1: error: expected identifier or '(' before '}' token
   23 | }
      | ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:16: error: lvalue required as left operand of assignment
    9 |   for (ll i=1;i*i=n;++i){
      |               ~^~
Language: C++

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  long long n;
  cin >> n;
  long long loc = 2;
  for (int r = (int)sqrt(n); r > 0; r--){
    if (n % r == 0){
      loc = r + n / r;
      break;
  }
  cout << loc - 2 << endl;
 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:2: error: expected '}' at end of input
   18 | }
      |  ^
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:22: error: expected ';' before ')' token
    9 |   for (ll i = 1;i*i<n){
      |                      ^
      |                      ;
Language: C++

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

typedef long long ll;
typedef vector<int> VI;
#define rep(i,n) for(int i=0;i<(n);++i)

//example rep(i,n) cin >> h[i];

int main (){

ll s,t,a,b;
  cin>>s;
ll ans=1e18;
 for(ll i=1; i*i<=s;i++){
   if(s%i!=0)continue;
   ll j=n/i;
   ans=min(ans,i+j-2);
 }
  //sort(vec.begin(),vec.end());
  //reverse(vec.begin(),vec.end());
cout<<ans<<endl;
   
  
 return 0; 
}


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

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

typedef long long ll;
typedef vector<int> VI;
#define rep(i,n) for(int i=0;i<(n);++i)

//example rep(i,n) cin >> h[i];

int main (){

ll s,t,a,b;
  cin>>s;
ll ans=1e18;
 for(ll i=1; i*i<=s;i++){
   if(s%i!=0)continue;
   ll j=n/i;
   ans=min(ans,i+j-2);
  //sort(vec.begin(),vec.end());
  //reverse(vec.begin(),vec.end());
cout<<ans<<endl;
   
  
 return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'n' was not declared in this scope
   20 |    ll j=n/i;
      |         ^
a.cc:28:2: error: expected '}' at end of input
   28 | }
      |  ^
a.cc:13:12: note: to match this '{'
   13 | int main (){
      |            ^
Language: C++

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

int main() {
  ll n;
  cin >> n;
  ll ans;
  for(int i= floor(sqrt(n));i>0;i--){
    if(n%i ==0){
      ans = i + n/i;
      break;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Compiler output:
a.cc:4:9: error: 'll' does not name a type
    4 | typedef ll long long;
      |         ^~
a.cc: In function 'int main()':
a.cc:7:3: error: 'll' was not declared in this scope
    7 |   ll n;
      |   ^~
a.cc:8:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |   cin >> n;
      |          ^
      |          yn
a.cc:9:5: error: expected ';' before 'ans'
    9 |   ll ans;
      |     ^~~~
      |     ;
a.cc:12:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |       ans = i + n/i;
      |       ^~~
      |       abs
a.cc:16:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include<iostream>
#include<math.h>
using namespace std;

int N;
cin >> N;

int sqN = int(sqrt(N));
int a, b;

for(int i = sqN; i >= 0; --i){
  if(N % i == 0){
    a = i;
    b = N / i;
    break;
  }
}

cout << (a + b - 2) << endl;
return 0;

Compiler output:
a.cc:6:1: error: 'cin' does not name a type
    6 | cin >> N;
      | ^~~
a.cc:11:1: error: expected unqualified-id before 'for'
   11 | for(int i = sqN; i >= 0; --i){
      | ^~~
a.cc:11:18: error: 'i' does not name a type
   11 | for(int i = sqN; i >= 0; --i){
      |                  ^
a.cc:11:26: error: expected unqualified-id before '--' token
   11 | for(int i = sqN; i >= 0; --i){
      |                          ^~
a.cc:19:1: error: 'cout' does not name a type
   19 | cout << (a + b - 2) << endl;
      | ^~~~
a.cc:20:1: error: expected unqualified-id before 'return'
   20 | return 0;
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;

#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define sz size()


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

signed main(){
  ll n;
    cin>>n;
  vector<ll> A(0);
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      A.push_back(i);
      if(i*i!=n){
        A.push_back(n/i);
      }
    }
  }
  SORT(A);
  ll a=A.sz;
  ll ans=INF;
  for(ll i=0;i<a;++i){
    chmin(ans,A[i]+n/A[i]);
  }
  co(ans-2)
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:3: error: 'co' was not declared in this scope; did you mean 'cos'?
   59 |   co(ans-2)
      |   ^~
      |   cos
Language: C++

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

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

    return 0;    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: 'n' was not declared in this scope
   13 |         ll j = n/i;
      |                ^