Language: C++

#include <vector>
#include <stack>
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <typeinfo>
#include <queue>

using namespace std;

typedef unsigned long long ll;




void ichi(){
	string s;
	cin >> s;
	int tmp_c = 0;
	int tmp_f = 0;
	for(int i=0;i<s.size();i++){
		if(s[i] == 'C'){
			tmp_c = 1;
		}
		else if(s[i] == 'F'){
			if(tmp_c == 1){
				cout << "Yes" << endl;
				tmp_f = 1;
				break;
			}
		}
	}
	if(tmp_f == 0){
		cout << "No" << endl;
	}

}

void ni(){
	int k,t;
	cin >> k >> t;
	//int num[t];
	std::vector<int> num;
	int tmp;
	for(int i=0;i<t;i++){
		cin >> tmp;
		num.push_back(tmp);
	}
	sort(num.begin(),num.end(),greater<int>());
	/*
	int place = 0;
	for(int i = 0;i<k;i++){
		if(num[place] > 0){
			num[place] = num[place] - 1;
		}
	}
	*/
	int maxnum = num[0];
	int diff = 1;
	for(int i=1;i<t;i++){
		diff = diff + num[i];
	}
	int result = max(0,maxnum - diff);
	cout << result << endl;

	/*
	for(int i=0;i<t;i++){
		cout << num[i] << " ";
	}
	cout << endl;
	*/

}

void san(){
	int n;
	std::vector<ll> t;
	std::vector<ll> a;
	ll tmp;
	ll result = 1ll;
	ll waru = 1000000000ll + 7ll;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> tmp;
		t.push_back(tmp);
	}
	for(int i=0;i<n;i++){
		cin >> tmp;
		a.push_back(tmp);
	}

	//result = 3776ll*8848ll*8848ll*8848ll;
	ll tmp_t = 0ll;
	ll tmp_a = 0ll;
	std::vector<ll> t_val(n);
	std::vector<ll> t_val_a(n);
	bool miss_flg = false;
	//t_val[0] = t[0];
	//cout << t_val[0] << " " << t_val[1] << " " << t_val.size() << endl;

 	for(int i=0;i<n;i++){
		if(tmp_t != t[i]){
			t_val[i] = t[i];
			tmp_t = t[i];
			//break;
		}
	}
 	for(int i=n-1;i>=0;i--){
		if(tmp_a != a[i]){
			t_val_a[i] = a[i];
			tmp_a = a[i];
			//t_val[i] = t[i];
			//break;
		}
	}

 	for(int i=0;i<n;i++){
		if(t_val[i] != 0){
			if(a[i] < t_val[i]){
				miss_flg = true;
				break;
			}
			if(t_val_a[i] !=0){
				if(t_val_a[i]!=t_val[i]){
					miss_flg = true;
					break;
				}
			}
		}
		if(t_val_a[i] != 0){
			if(t[i] < t_val_a[i]){
				miss_flg = true;
				break;
			}
		}
	}

	if(miss_flg){
		cout << 0 << endl;
	}
	else{
		for(int i=0;i<n;i++){
			if(t_val[i] ==0 && t_val_a[i]==0){
				result = result * ll(min(t[i],a[i]));
			}
		}
		//cout << result << endl;
		cout << result%waru << endl;
	}


	//cout << ll(a[0])%waru << endl;
	//cout << result%waru << endl;


}

void san2(){
	int n;
	std::vector<int> t;
	std::vector<int> a;
	int tmp;
	ll result = 1ll;
	ll waru = 1000000000ll + 7ll);
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> tmp;
		t.push_back(tmp);
	}
	for(int i=0;i<n;i++){
		cin >> tmp;
		a.push_back(tmp);
	}

	//result = 3776ll*8848ll*8848ll*8848ll;
	int tmp_t = 0;
	int tmp_a = 0;
	std::vector<int> t_val(n);
	std::vector<int> t_val_a(n);
	bool miss_flg = false;
	//t_val[0] = t[0];
	//cout << t_val[0] << " " << t_val[1] << " " << t_val.size() << endl;

 	for(int i=0;i<n;i++){
		if(tmp_t != t[i]){
			t_val[i] = t[i];
			tmp_t = t[i];
			//break;
		}
		if(tmp_a != a[n-1-i]){
			t_val_a[i] = a[i];
			tmp_a = a[i];
		}
		if(t_val[t] != 0){
			if(a[i] < t_val[i]){
				miss_flg = true;
				break;
			}
		}
		if(t_val_a[t] !=0){
			if(t[i] < t_val_a[i]){
				miss_flg = true;
				break;
			}
		}
		
	}

	if(miss_flg){
		cout << 0 << endl;
	}
	else{
		for(int i=0;i<n;i++){
			if(t_val[i] ==0 && t_val_a[i]==0){
				result = result * ll(min(t[i],a[i]));
			}
		}
		//cout << result << endl;
		//cout << result%waru << endl;
	}


	//cout << ll(a[0])%waru << endl;
	//cout << result%waru << endl;


}



int main(){
	//ichi();
	//ni();
	san();
	return 0;
}

Compiler output:
a.cc: In function 'void san2()':
a.cc:166:37: error: expected ',' or ';' before ')' token
  166 |         ll waru = 1000000000ll + 7ll);
      |                                     ^
a.cc:196:25: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>')
  196 |                 if(t_val[t] != 0){
      |                         ^
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:202:27: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>')
  202 |                 if(t_val_a[t] !=0){
      |                           ^
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~