Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
ll a,b,c,n,s;
str s1,s2;

int main() {
    fast();
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    cin >> n;
    set<ll>sets;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            
            if (n/i == i) 
                sets.add(i);
  
            else {
                sets.add(n/i);
                sets.add(i); 
            }
        } 
    }   
    vec re(all(sets));
    ll ma=1e15;
    f(i,0,re.size()/2){
        ma=min(ma,re[i]+re[re.size()-i-1]-2);
    }
    cout<<ma;

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 1e5 + 10;
const ll LINF = LLONG_MAX;
ll a,b,c,n,s;
str s1,s2;

int main() {
    fast();
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    cin >> n;
    set<ll>sets;
    for (ll i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            
            if (n/i == i) 
                sets.add(i);
  
            else {
                sets.add(n/i);
                sets.add(i); 
            }
        } 
    }   
    vec re(all(sets));
    ll ma=1e15;
    f(i,0,re.size()/2){
        ma=min(ma,re[i]+re[re.size()-i-1]-2);
    }
    cout<<ma;

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Compiler output:
a.cc:70:11: error: redefinition of 'const int MOD'
   70 | const int MOD = 1e9 + 7, N = 1e5 + 10;
      |           ^~~
a.cc:17:11: note: 'const int MOD' previously defined here
   17 | const int MOD = 1e9 + 7, N = 1e5 + 10;
      |           ^~~
a.cc:70:26: error: redefinition of 'const int N'
   70 | const int MOD = 1e9 + 7, N = 1e5 + 10;
      |                          ^
a.cc:17:26: note: 'const int N' previously defined here
   17 | const int MOD = 1e9 + 7, N = 1e5 + 10;
      |                          ^
a.cc:71:10: error: redefinition of 'const ll LINF'
   71 | const ll LINF = LLONG_MAX;
      |          ^~~~
a.cc:18:10: note: 'const ll LINF' previously defined here
   18 | const ll LINF = LLONG_MAX;
      |          ^~~~
a.cc:72:4: error: redefinition of 'll a'
   72 | ll a,b,c,n,s;
      |    ^
a.cc:19:4: note: 'll a' previously declared here
   19 | ll a,b,c,n,s;
      |    ^
a.cc:72:6: error: redefinition of 'll b'
   72 | ll a,b,c,n,s;
      |      ^
a.cc:19:6: note: 'll b' previously declared here
   19 | ll a,b,c,n,s;
      |      ^
a.cc:72:8: error: redefinition of 'll c'
   72 | ll a,b,c,n,s;
      |        ^
a.cc:19:8: note: 'll c' previously declared here
   19 | ll a,b,c,n,s;
      |        ^
a.cc:72:10: error: redefinition of 'll n'
   72 | ll a,b,c,n,s;
      |          ^
a.cc:19:10: note: 'll n' previously declared here
   19 | ll a,b,c,n,s;
      |          ^
a.cc:72:12: error: redefinition of 'll s'
   72 | ll a,b,c,n,s;
      |            ^
a.cc:19:12: note: 'll s' previously declared here
   19 | ll a,b,c,n,s;
      |            ^
a.cc:73:5: error: redefinition of 'std::string s1'
   73 | str s1,s2;
      |     ^~
a.cc:20:5: note: 'std::string s1' previously declared here
   20 | str s1,s2;
      |     ^~
a.cc:73:8: error: redefinition of 'std::string s2'
   73 | str s1,s2;
      |        ^~
a.cc:20:8: note: 'std::string s2' previously declared here
   20 | str s1,s2;
      |        ^~
a.cc:75:5: error: redefinition of 'int main()'
   75 | int main() {
      |     ^~~~
a.cc:22:5: note: 'int main()' previously defined here
   22 | int main() {
      |     ^~~~