Language: C++

#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
#include<tuple>
using namespace std;
typedef long long int lnt;
typedef unsigned long long int unt;
typedef unsigned ust;
typedef double dou;
typedef pair<int,int> P;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i=st;i<(ed);++i)
#define FC(i,n)       for(int i=n;i;--i)
#define FZU(i,n)      for(ust i=0;i!=(n);++i)
#define FVU(i,st,ed)  for(ust i=st;i<(ed);++i)
#define FCU(i,n)      for(ust i=n;i;--i)
#define SZ(x)         ((int)x.size())
#define ALL(x)        std::begin(x),std::end(x)
#define likely(x)     __builtin_expect(!!(x), 1)
#define unlikely(x)   __builtin_expect(!!(x), 0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%I64d",&(x))
#define RII64(x,y) scanf("%I64d%I64d",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;
lnt a[N],b[N];
constexpr lnt mod = 1000000007;
lnt ppp(lnt a,lnt x){
    lnt ans = 1;
    for(;x;x>>=1){
        if(x&1){ans*=a;ans%=mod;}
        a=a*a%mod;
    }
    return ans;
}
bool sol(){
    int n;
    if(RI(n)==EOF)return 0;
    FZ(i,n){int x; RI(x); a[i] = x;}
    FZ(i,n){int x; RI(x); b[i] = x;}
    auto ml = *max_element(a,a+n);
    auto mr = *max_element(b,b+n);
    if(ml!=mr){
        puts("0");
        return 1;
    }
    auto l = find(a,a+n,ml)-a;
    auto r = n;
    FB(i,n)if(b[i]==mr){
        r = i; break;
    }
    if(l>r){
        puts("0");
        return 1;
    }
    lnt ans = ppp(ml,max(r-l-1,0ll));
    reverse(b,b+n);
    for(auto c:{a,b}){
        lnt last = 0;
        FZ(i,n)if(i&&c[i]!=c[i-1]){
            //printf("%d %d\n",int(c[i-1]),i-last-1);
            ans*= ppp(c[i-1],i-last-1);
            ans%=mod;
            last = i;
        }
    }
    printf("%d\n",int(ans));
    return 1;
}
int main(){
    while(sol());
    return 0;
}


Compiler output:
a.cc: In function 'bool sol()':
a.cc:74:25: error: no matching function for call to 'max(long int, long long int)'
   74 |     lnt ans = ppp(ml,max(r-l-1,0ll));
      |                      ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:74:25: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   74 |     lnt ans = ppp(ml,max(r-l-1,0ll));
      |                      ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:74:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   74 |     lnt ans = ppp(ml,max(r-l-1,0ll));
      |                      ~~~^~~~~~~~~~~