#include // #include // #include #define int long long #define ld long double #define get(T,args...) T args; read(args); #define init(a,T,n,s) vector a((n)+1,s); cin>>a; #define putn(args...) { put(args); cout<<"\n"; } #define pute(args...) { put(args); cout<(b); i--) #define logarr(arr,f,l) { auto start=arr.begin(), end=arr.begin(); advance(start,(f)); advance(end,(l)); for(auto it=start; it!=end; it++) cout<<*it<<" "; cout<<"\n"; } #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sort_by(span,p) sort(span, [&](const auto &l, const auto &r) { return p; }) #define f(u, args...) [&](auto &&u) { return args; } #define g(u, v, args...) [&](auto &&u, auto &&v) { return args; } #define uniq(x) x.erase(unique(all(x)),x.end()); #define sz(x) (int)(x).size() #define mid(l,r) std::midpoint((l),(r)) #define zov(v,z,c) ((c) ? (v) : (z)) #define pii pair #define pb emplace_back #define pf push_front #define fr first #define sc second #define sumv(v,b,e) accumulate((v).begin()+b,(v).begin()+e,0LL) #define minv(v,b,e) min_element((v).begin()+b,(v).begin()+e) #define maxv(v,b,e) max_element((v).begin()+b,(v).begin()+e) #define precise(n) cout< #define set(args...) std::set > #define pqueue(args...) std::priority_queue,Comp > #define oset(args...) tree, rb_tree_tag, tree_order_statistics_node_update> constexpr int N = 100'001, M = 998'244'353, mod = 1'000'000'007, MX = INT64_MAX, MN = INT64_MIN, oo = 4e18; #ifdef DEBUG #include "./Debug/debug.hpp" #else #define debug(args...) 0; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #endif // using namespace __gnu_pbds; using namespace std; vec(string) tokenizer(string str,char ch) {std::istringstream var((str)); vec(string) v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;} template struct Comp { bool operator()(const T& l, const T& r) const { return l < r; } }; template inline istream& operator >> (istream& in, pair& a) { in>>a.first>>a.second; return in; } template inline ostream& operator << (ostream& out, pair a) { out< istream& operator >> (istream& in, vector& v) { rep(i,1,sz(v)) cin>>v[i]; return in; } template inline bool amax(T &a,T1 b){ if(b>a) { a=b; return true; } return false; } template inline bool amin(T &a,T1 b){ if(b>args), ...); } void put(auto&&... args) { ((cout< a(n),b(n); for(int i=0; i>a[i]>>b[i]; int ans = 0, suma = 0, sumb = 0; for(int i=n-1; i>=0; i--){ int mx = 0; //make him sit in front amax(mx, suma*b[i]); //make him sit in back amax(mx, a[i]*sumb); ans += mx; suma += a[i]; sumb += b[i]; } cout<