Language: C++

#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    bool f=  true;
    rep(i,n){
        cin>>v[i];
        if(v[i]==0){f=false;}
    }
    if(!f){
        cout<<0<<endl;
        return 0;
    }

    ll sum = 1;
    ll m = 1000000000000000000;
    rep(i,n){
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

        typedef int long long ll;
        using namespace std;
        typedef pair<int,int> P;
        int dx[4]={1,0,-1,0};
        int dy[4]={0,1,0,-1};
        const ll MOD=1e9+7;
        static const int MAX = 100;
        static const int INF = (1<<23);
        template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
        template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

        int main(){
            ll n;
            cin>>n;
            vector<ll> v(n);
            bool f=  true;
            rep(i,n){
                cin>>v[i];
                if(v[i]==0){f=false;}
            }
            if(!f){
                cout<<0<<endl;
                return 0;
            }

            ll sum = 1;
            ll m = 1000000000000000000;
            
            rep(i,n){
                ll psum = sum;
                sum*=v[i];
                //cout<<sum<<endl;
                if(sum>=m){
                    cout<<-1<<endl;
                    return 0;
                }
                if(sum/v[i]!=psum){
                    cout<<-1<<endl;
                    return 0;
                }
            }
            cout<<sum<<endl;



            return 0;
        }
        ll psum = sum;
     sum*=v[i];
     //cout<<sum<<endl;
     if(sum>m){
         cout<<-1<<endl;
         return 0;
     }
     if(sum/v[i]!=psum){
         cout<<-1<<endl;
         return 0;
     }
    }
    cout<<sum<<endl;



return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:9: error: a template declaration cannot appear at block scope
   69 |         template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
      |         ^~~~~~~~
a.cc:72:17: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   72 |         int main(){
      |                 ^~
a.cc:72:17: note: remove parentheses to default-initialize a variable
   72 |         int main(){
      |                 ^~
      |                 --
a.cc:72:17: note: or replace parentheses with braces to value-initialize a variable
a.cc:72:19: error: a function-definition is not allowed here before '{' token
   72 |         int main(){
      |                   ^