stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#include <ext/rope>

#define mem(a,v) memset((a), (v), sizeof (a))

#define enl printf("\n")

#define case(t) printf("Case #%d: ", (t))

#define ni(n) scanf("%d", &(n))

#define nl(n) scanf("%lld", &(n))

#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])

#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])

#define pri(n) printf("%d\n", (n))

#define prl(n) printf("%lld\n", (n))

#define pii pair<int, int>

#define pil pair<int, long long>

#define pll pair<long long, long long>

#define vii vector<pii>

#define vil vector<pil>

#define vll vector<pll>

#define vi vector<int>

#define vl vector<long long>

#define pb push_back

#define mp make_pair

#define fi first

#define se second

using namespace std;

using namespace __gnu_pbds;

typedef long long ll;

typedef cc_hash_table<int,int,hash<int>> ht;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const double pi = acos(-1);

const int MOD = 1e9 + 7;

const int INF = 1e9 + 7;

const int MAXN = 1e6 + 5;

const double eps = 1e-9;

int t[MAXN], v[MAXN], ans = 0, tmp[MAXN];

int miB[MAXN], miF[MAXN], mi[MAXN];



int main() {

	int n; ni(n); mem(miB, 0x3f), mem(miF, 0x3f);

	nai(t, n); nai(v, n); mem(mi, 0x3f);

	for (int i = 0; i < n; i++) t[i] *= 2, v[i] *= 2;

	for (int i = 1; i < n; i++) t[i] += t[i-1];

	for (int i = 1; i < n; i++) miB[t[i-1]] = v[i];

	miB[t[n-1]] = 0;

	for (int i = t[n-1]-1; ~i; i--) miB[i] = min(miB[i], miB[i+1]+1);

	for (int i = 0; i < n; i++) miF[t[i]] = v[i];

	miF[0] = 0;

	for (int i = 1; i <= t[n-1]; i++) miF[i] = min(miF[i], miF[i-1]+1);

	for (int i = 0; i < n; i++)

		for (int j = !i?0:t[i-1]; j <= t[i]; j++)

			mi[j] = min(mi[j], v[i]), tmp[j] = mi[j];

	for (int i = 0; i <= t[n-1]; i++) mi[i] = min(mi[i], min(miF[i],miB[i]));

	for (int i = 0; i < t[n-1]; i++) ans += (mi[i+1]+mi[i]);

	printf("%.20f\n", (double)ans/8.);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 6.113702040954868x):
#include <bits/stdc++.h>

#define mem(a,v) memset((a), (v), sizeof (a))

#define ni(n) scanf("%d", &(n))

#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])

using namespace std;

const int MAXN = 1e5 + 5;

int t[MAXN], v[MAXN], ans = 0, n;

int miB[MAXN], miF[MAXN], mi[MAXN];



int main() {

	ni(n); mem(miB, 0x3f), mem(miF, 0x3f);

	nai(t, n); nai(v, n); mem(mi, 0x3f);

	for (int i = 0; i < n; i++) t[i] *= 2, v[i] *= 2;

	for (int i = 1; i < n; i++) t[i] += t[i-1];

	for (int i = 1; i < n; i++) miB[t[i-1]] = v[i];

	miB[t[n-1]] = miF[0] = 0;

	for (int i = t[n-1]-1; ~i; i--) miB[i] = min(miB[i], miB[i+1]+1);

	for (int i = 0; i < n; i++) miF[t[i]] = v[i];

	for (int i = 1; i <= t[n-1]; i++) miF[i] = min(miF[i], miF[i-1]+1);

	for (int i = 0; i < n; i++) for (int j = !i?0:t[i-1]; j <= t[i]; j++) mi[j] = min(mi[j], v[i]);

	for (int i = 0; i <= t[n-1]; i++) mi[i] = min(mi[i], min(miF[i],miB[i]));

	for (int i = 0; i < t[n-1]; i++) ans += (mi[i+1]+mi[i]);

	printf("%.20f\n", (double)ans/8.);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<queue>

#include<algorithm>

#include<map>

#include<set>

#include<vector>

#include<math.h>



using namespace std;



#define INF 1000000007

#define LINF (1LL << 62)



typedef long long i64;

typedef pair<i64,i64> P;





int n, t[202], v[202];

vector<int> ma(202020,INF);

double ans = 0;



int main(){

	cin >> n;

	int T = 0;

	for(int i = 0; i < n; i++){

		cin >> t[i];

		T += t[i]*2;

	}

	int now = 0;

	for(int i = 0; i < n; i++){

		cin >> v[i];

		for(int j = 0; j <= t[i]*2; j++){

			ma[now] = min(v[i]*2, ma[now]);

			now++;

		}

		now--;

	}

	

	for(int i = 0; i <= T; i++){

		ma[i] = min(min(T-i,i), ma[i]);

	}

	for(int i = 0; i <= T; i++){

		if(i != 0){

			if(ma[i-1] < ma[i]-1){

				ma[i] = ma[i-1]+1;

			}

			if(ma[T+1-i] < ma[T-i]-1){

				ma[T-i] = ma[T+1-i]+1;

			}

		}

	}

	for(int i = 0; i <= T; i++){

		ans += ma[i];

	}

	printf("%.10f\n", ans/4);

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4381724041732709x):
#include<bits/stdc++.h>



using namespace std;



#define INF 1000000007

#define LINF (1LL << 60)

#define PI 3.14159265358979



typedef long long i64;

typedef pair<i64,i64> P;



inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }



template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }







int n, t[101], d[101], v[101];

int sp[40404];

void solve(){

	cin >> n;

	for(int i = 1; i <= n; i++){

		cin >> t[i];

		t[i] *= 2;

		d[i] = d[i-1]+t[i];

	}

	for(int i = 1; i <= n; i++){

		cin >> v[i];

		v[i] *= 2;

		fill(sp+d[i-1], sp+d[i], v[i]); //max

	}

	

	for(int i = 1; i <= n; i++){

		if(v[i] > v[i-1]){

			for(int j = d[i-1]; j < d[i]; j++){

				chmin(sp[j], v[i-1]+j-d[i-1]);

			}

		}

		if(v[i] > v[i+1]){

			for(int j = d[i+1]; j >= d[i]; j--){

				chmin(sp[j], v[i+1]+d[i+1]-j);

			}

		}

	}

	for(int i = 1; i < 40404; i++){

		chmin(sp[i], sp[i-1]+1);

	}

	for(int i = 40000; i > 0; i--){

		chmin(sp[i], sp[i+1]+1);

	}

	

	i64 ans = 0;

	for(int i = 1; i < 40404; i++){

		ans += sp[i];

		

	}

	printf("%.10f\n", ans/4.0);

}



int main(){

	std::cin.tie(0);

	std::ios::sync_with_stdio(false);

	int t = 1;

	//cin >> t;

	while(t--){

		solve();

	}

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<queue>

#include<algorithm>

#include<map>

#include<set>

#include<vector>

#include<math.h>



using namespace std;



#define INF 1000000007

#define LINF (1LL << 62)



typedef long long i64;

typedef pair<i64,i64> P;





int n, t[202], v[202];

vector<int> ma(202020,INF);

double ans = 0;



int main(){

	cin >> n;

	int T = 0;

	for(int i = 0; i < n; i++){

		cin >> t[i];

		T += t[i]*2;

	}

	int now = 0;

	for(int i = 0; i < n; i++){

		cin >> v[i];

		for(int j = 0; j <= t[i]*2; j++){

			ma[now] = min(v[i]*2, ma[now]);

			now++;

		}

		now--;

	}

	

	for(int i = 0; i <= T; i++){

		ma[i] = min(min(T-i,i), ma[i]);

	}

	for(int i = 0; i <= T; i++){

		if(i != 0){

			if(ma[i-1] < ma[i]-1){

				ma[i] = ma[i-1]+1;

			}

			if(ma[T+1-i] < ma[T-i]-1){

				ma[T-i] = ma[T+1-i]+1;

			}

		}

	}

	for(int i = 0; i <= T; i++){

		ans += ma[i];

	}

	printf("%.10f\n", ans/4);

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.791388920971789x):
#include<bits/stdc++.h>



using namespace std;



#define INF 1000000007

#define LINF (1LL << 60)

#define PI 3.14159265358979



typedef long long i64;

typedef pair<i64,i64> P;



inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }



template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }







int n, t[101], d[101], v[101];

int sp[40404];

void solve(){

	cin >> n;

	for(int i = 1; i <= n; i++){

		cin >> t[i];

		t[i] *= 2;

		d[i] = d[i-1]+t[i];

	}

	for(int i = 1; i <= n; i++){

		cin >> v[i];

		v[i] *= 2;

		fill(sp+d[i-1], sp+d[i], v[i]); //max

	}

	

	for(int i = 1; i <= n; i++){

		if(v[i] > v[i-1]){

			for(int j = d[i-1]; j < d[i]; j++){

				chmin(sp[j], v[i-1]+j-d[i-1]);

			}

		}

		if(v[i] > v[i+1]){

			for(int j = d[i+1]; j >= d[i]; j--){

				chmin(sp[j], v[i+1]+d[i+1]-j);

			}

		}

	}

	for(int i = 1; i < d[n]; i++){

		chmin(sp[i], sp[i-1]+1);

	}

	for(int i = d[n]; i > 0; i--){

		chmin(sp[i], sp[i+1]+1);

	}

	

	i64 ans = 0;

	for(int i = 1; i < d[n]; i++){

		ans += sp[i];

		

	}

	printf("%.10f\n", ans/4.0);

}



int main(){

	std::cin.tie(0);

	std::ios::sync_with_stdio(false);

	int t = 1;

	//cin >> t;

	while(t--){

		solve();

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define INF 1000000007

#define LINF (1LL << 60)

#define PI 3.14159265358979



typedef long long i64;

typedef pair<i64,i64> P;



inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }



template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }







int n, t[101], d[101], v[101];

int sp[40404];

void solve(){

	cin >> n;

	for(int i = 1; i <= n; i++){

		cin >> t[i];

		t[i] *= 2;

		d[i] = d[i-1]+t[i];

	}

	for(int i = 1; i <= n; i++){

		cin >> v[i];

		v[i] *= 2;

		fill(sp+d[i-1], sp+d[i], v[i]); //max

	}

	

	for(int i = 1; i <= n; i++){

		if(v[i] > v[i-1]){

			for(int j = d[i-1]; j < d[i]; j++){

				chmin(sp[j], v[i-1]+j-d[i-1]);

			}

		}

		if(v[i] > v[i+1]){

			for(int j = d[i+1]; j >= d[i]; j--){

				chmin(sp[j], v[i+1]+d[i+1]-j);

			}

		}

	}

	for(int i = 1; i < 40404; i++){

		chmin(sp[i], sp[i-1]+1);

	}

	for(int i = 40000; i > 0; i--){

		chmin(sp[i], sp[i+1]+1);

	}

	

	i64 ans = 0;

	for(int i = 1; i < 40404; i++){

		ans += sp[i];

		

	}

	printf("%.10f\n", ans/4.0);

}



int main(){

	std::cin.tie(0);

	std::ios::sync_with_stdio(false);

	int t = 1;

	//cin >> t;

	while(t--){

		solve();

	}

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.2456009556111347x):
#include<bits/stdc++.h>



using namespace std;



#define INF 1000000007

#define LINF (1LL << 60)

#define PI 3.14159265358979



typedef long long i64;

typedef pair<i64,i64> P;



inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }



template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }







int n, t[101], d[101], v[101];

int sp[40404];

void solve(){

	cin >> n;

	for(int i = 1; i <= n; i++){

		cin >> t[i];

		t[i] *= 2;

		d[i] = d[i-1]+t[i];

	}

	for(int i = 1; i <= n; i++){

		cin >> v[i];

		v[i] *= 2;

		fill(sp+d[i-1], sp+d[i], v[i]); //max

	}

	

	for(int i = 1; i <= n; i++){

		if(v[i] > v[i-1]){

			for(int j = d[i-1]; j < d[i]; j++){

				chmin(sp[j], v[i-1]+j-d[i-1]);

			}

		}

		if(v[i] > v[i+1]){

			for(int j = d[i+1]; j >= d[i]; j--){

				chmin(sp[j], v[i+1]+d[i+1]-j);

			}

		}

	}

	for(int i = 1; i < d[n]; i++){

		chmin(sp[i], sp[i-1]+1);

	}

	for(int i = d[n]; i > 0; i--){

		chmin(sp[i], sp[i+1]+1);

	}

	

	i64 ans = 0;

	for(int i = 1; i < d[n]; i++){

		ans += sp[i];

		

	}

	printf("%.10f\n", ans/4.0);

}



int main(){

	std::cin.tie(0);

	std::ios::sync_with_stdio(false);

	int t = 1;

	//cin >> t;

	while(t--){

		solve();

	}

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<queue>

#include<algorithm>

#include<map>

#include<set>

#include<vector>

#include<math.h>



using namespace std;



#define INF 1000000007

#define LINF (1LL << 62)



typedef long long i64;

typedef pair<i64,i64> P;





int n, t[202], v[202];

vector<int> ma(202020,INF);

double ans = 0;



int main(){

	cin >> n;

	int T = 0;

	for(int i = 0; i < n; i++){

		cin >> t[i];

		T += t[i]*2;

	}

	int now = 0;

	for(int i = 0; i < n; i++){

		cin >> v[i];

		for(int j = 0; j <= t[i]*2; j++){

			ma[now] = min(v[i]*2, ma[now]);

			now++;

		}

		now--;

	}

	

	for(int i = 0; i <= T; i++){

		ma[i] = min(min(T-i,i), ma[i]);

	}

	for(int i = 0; i <= T; i++){

		if(i != 0){

			if(ma[i-1] < ma[i]-1){

				ma[i] = ma[i-1]+1;

			}

			if(ma[T+1-i] < ma[T-i]-1){

				ma[T-i] = ma[T+1-i]+1;

			}

		}

	}

	for(int i = 0; i <= T; i++){

		ans += ma[i];

	}

	printf("%.10f\n", ans/4);

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4404342174586495x):
#include<bits/stdc++.h>



using namespace std;



#define INF 1000000007

#define LINF (1LL << 60)

#define PI 3.14159265358979



typedef long long i64;

typedef pair<i64,i64> P;



inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }



template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }







int n, t[101], d[101], v[101];

int sp[40404];

void solve(){

	cin >> n;

	for(int i = 1; i <= n; ++i){

		cin >> t[i];

		t[i] <<= 1;

		d[i] = d[i-1]+t[i];

	}

	for(int i = 1; i <= n; ++i){

		cin >> v[i];

		v[i] <<= 1;

		fill(sp+d[i-1], sp+d[i], v[i]); //max

	}

	

	for(int i = 1; i <= n; i++){

		if(v[i] > v[i-1]){

			for(int j = d[i-1]; j < d[i]; ++j){

				if(!chmin(sp[j], v[i-1]+j-d[i-1])) break;

			}

		}

		if(v[i] > v[i+1]){

			for(int j = d[i+1]; j >= d[i]; --j){

				if(!chmin(sp[j], v[i+1]+d[i+1]-j)) break;

			}

		}

	}

	for(int i = 1; i < 40000; ++i){

		chmin(sp[i], sp[i-1]+1);

	}

	for(int i = 40000; i > 0; --i){

		chmin(sp[i], sp[i+1]+1);

	}

	

	i64 ans = 0;

	for(int i = 1; i < 40000; i++){

		ans += sp[i];

		

	}

	printf("%.10f\n", ans/4.0);

}



int main(){

	std::cin.tie(0);

	std::ios::sync_with_stdio(false);

	int t = 1;

	//cin >> t;

	while(t--){

		solve();

	}

	

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

#define RI(a) scanf("%d",&a)

#define RII(a,b) scanf("%d%d",&a,&b)

#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)

#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

#define ALL(a) a.begin(),a.end()

#define F first

#define S second

#define REP(i,n) for(int i=0;i<(n);i++)

#define pb push_back

#ifdef leowang

#define debug(...) do{\

	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\

	_DO(__VA_ARGS__);\

}while(0)

template<typename I> void _DO(I&&x){cerr<<x<<endl;}

template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}

#else

#define debug(...)

#endif

//}}}

const ll maxn=80005;

const ll maxlg=__lg(maxn)+2;

const ll INF64=8000000000000000000LL;

const int INF=2000000000;



int t[maxn];

int v[maxn];



int T=0;



int s[maxn];

int main()

{

	REP(i,maxn) s[i]=INF;

	

	

	int n;

	cin>>n;

	REP(i,n) cin>>t[i+1];

	REP(i,n) cin>>v[i+1];

	v[n+1]=0,t[n+1]=0;

	v[0]=0,t[0]=0;

	int cur=0;

	

	

	for(int i=0;i<=n+1;i++){

		for(int j=0;j<maxn;j++){

			if(j<=cur*2){

				s[j]=min(s[j],2*v[i]+(2*cur-j));

			}

			else if(j>=2*(cur+t[i])){

				s[j]=min(s[j],2*v[i]+(j-2*cur-2*t[i]));

			}

			else s[j]=min(s[j],2*v[i]);

		}

		cur+=t[i];

	}

	

	REP(i,n) T+=t[i+1];

	//cout<<T<<'\n';

	int ans=0;

	for(int i=0;i<2*T;i++){

		//cout<<s[i]<<' ';

		ans+=s[i]+s[i+1];

	}

	cout<<fixed<<setprecision(6)<<0.125*ans;

	return 0;

}






















// Faster C++ solution for the same problem (measured speedup: 1.3589714349681727x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

#define RI(a) scanf("%d",&a)

#define RII(a,b) scanf("%d%d",&a,&b)

#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)

#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

#define ALL(a) a.begin(),a.end()

#define F first

#define S second

#define REP(i,n) for(int i=0;i<(n);i++)

#define pb push_back

#ifdef leowang

#define debug(...) do{\

	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\

	_DO(__VA_ARGS__);\

}while(0)

template<typename I> void _DO(I&&x){cerr<<x<<endl;}

template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}

#else

#define debug(...)

#endif

//}}}

const ll maxn=40005;

const ll maxlg=__lg(maxn)+2;

const ll INF64=8000000000000000000LL;

const int INF=2000000000;



int t[maxn];

int v[maxn];



int T=0;



int s[maxn];

int main()

{

	REP(i,maxn) s[i]=INF;

	

	

	int n;

	cin>>n;

	REP(i,n) cin>>t[i+1];

	REP(i,n) cin>>v[i+1];

	v[n+1]=0,t[n+1]=0;

	v[0]=0,t[0]=0;

	int cur=0;

	

	

	for(int i=0;i<=n+1;i++){

		for(int j=0;j<maxn;j++){

			if(j<=cur*2){

				s[j]=min(s[j],2*v[i]+(2*cur-j));

			}

			else if(j>=2*(cur+t[i])){

				s[j]=min(s[j],2*v[i]+(j-2*cur-2*t[i]));

			}

			else s[j]=min(s[j],2*v[i]);

		}

		cur+=t[i];

	}

	

	REP(i,n) T+=t[i+1];

	//cout<<T<<'\n';

	int ans=0;

	for(int i=0;i<2*T;i++){

		//cout<<s[i]<<' ';

		ans+=s[i]+s[i+1];

	}

	cout<<fixed<<setprecision(6)<<0.125*ans;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)

#define FOR(i, m, n) for (int i = m; i < n; i++)

#define ll long long int

const int INF = 2147483647;



using namespace std;



int main()

{

  double maxv[40001] = {};

  int t[100] = {};

  // 何秒から始まるか(長さはt[i]を見るとわかる)

  pair<int, double> v[100] = {};

  int n;

  int T = 0;

  cin >> n;

  REP(i, n)

  {

    cin >> t[i];

  }

  REP(i, n)

  {

    double vi;

    cin >> vi;

    v[i] = make_pair(T, vi);

    T += t[i];

  }



  REP(i, 2 * T + 1)

  {

    maxv[i] = 50000;

  }



  // maxv[i]を決める

  // t = i/2

  REP(i, 2 * T + 1)

  {

    maxv[i] = min(maxv[i], (double)i / 2);

    maxv[i] = min(maxv[i], (double)T - (double)i / 2);

    REP(j, n)

    {

      if ((double)i / 2 < v[j].first)

      {

        maxv[i] = min(maxv[i], v[j].second + ((double)(2 * v[j].first - i) / 2));

      }

      else if ((double)i / 2 > v[j].first + t[j])

      {

        maxv[i] = min(maxv[i], v[j].second + ((double)(i - 2 * (v[j].first + t[j])) / 2));

      }

      else

      {

        maxv[i] = min(maxv[i], v[j].second);

      }

    }

  }



  double ans = 0;

  FOR(i, 1, 2 * T + 1)

  {

    ans += 0.25 * (maxv[i - 1] + maxv[i]);

  }



  cout << fixed << setprecision(6) << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.291263579546132x):
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"





#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)

#define FOR(i, m, n) for (int i = m; i < n; i++)

#define ALL(v) (v).begin(), (v).end()

#define coutd(n) cout << fixed << setprecision(n)

#define ll long long int

#define vl vector<ll>

#define vi vector<int>

#define MM << " " <<



using namespace std;



template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }



template <class T> void chmin(T &a, T b) {

  if (a > b)

    a = b;

}



template <class T> void chmax(T &a, T b) {

  if (a < b)

    a = b;

}





#line 2 "tmp.cpp"



int main() {

  cin.tie(0);

  ios::sync_with_stdio(false);



  int n;

  cin >> n;

  vector<int> t(n + 2, 0);

  vector<double> v(n + 2, 0);

  int sum = 0;

  REP(i, n) {

    cin >> t[i + 1];

    sum += t[i + 1];

    t[i + 1] += t[i];

  }

  t[n + 1] = sum;

  REP(i, n) { cin >> v[i + 1]; }



  vector<double> ans(2 * sum + 1, 0.0);

  FOR(j, 1, 2 * sum + 1) {

    double tmp = 2 * sum;

    double time = (double)j / 2;



    FOR(i, 1, n + 1) {

      if (time < t[i - 1]) {

        chmin(tmp, t[i - 1] - time + v[i]);

        // cout << "top: " MM t[i - 1] - time + v[i] << endl;



      } else if (t[i] < time) {

        chmin(tmp, time - t[i] + v[i]);

        // cout << "middle: " MM time - t[i] + v[i] << endl;

      } else {

        chmin(tmp, v[i]);

        // cout << "bottom: " MM v[i] << endl;

      }

    }

    chmin(tmp, time);

    chmin(tmp, sum - time);

    ans[j] = tmp;

    // cout << time MM ans[j] << endl;

  }



  double val = 0;

  FOR(i, 1, 2 * sum + 1) { val += (ans[i] + ans[i - 1]) / 4; }

  coutd(5) << val << endl;



  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define ll long long int

#define rep(i,n) for( int i = 0; i < n; i++ )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N;

    cin >> N;

    int t[N], v[N];

    rep(i, N) cin >> t[i];

    rep(i, N) cin >> v[i];



    int spd[80010] = {};

    int tmpT = 0;

    int tmpspd = 0;

    rep(i, N) {

        rep(j, t[i]*2) {

            spd[j+tmpT*2] = tmpspd;

            tmpspd++;

            tmpspd = min(tmpspd, v[i]*2);

        }

        tmpT += t[i];

    }

    tmpspd = 0;

    for (int i = N-1; i >= 0; i--) {

        tmpT -= t[i];

        for (int j = t[i]*2; j > 0; j--) {

            spd[j+tmpT*2] = min(spd[j+tmpT*2], tmpspd);

            tmpspd++;

            tmpspd = min(tmpspd, v[i]*2);

        }

    }

    double ans = 0;

    rep(i, 80010) {

        ans += spd[i];

        if (spd[i] != 0) {

            //cout << "spd[" << i/(2.0) << "] = " << spd[i]/2.0 << endl;

        }

    }

    printf("%.5f\n", ans/4.0);

    //cout << ans/4.0 << endl;



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.2267491437714533x):
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

#define rep(i,n) for( int i = 0; i < n; i++ )

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N; cin >> N;

    int t[110], v[110];

    rep(i, N) cin >> t[i];

    int sum = 0;

    rep(i, N) sum += t[i];

    rep(i, N) cin >> v[i];

    int s[40010];

    rep(i, 40010) {

        s[i] = INF;

    }

    s[0] = 0;

    int T = 0;

    rep(i, N) {

        for(int j = T; j < T + t[i] * 2; j += 2) {

            s[j + 1] = min({s[j + 1], v[i] * 2, s[j] + 1}); 

            s[j + 2] = min({s[j + 2], v[i] * 2, s[j] + 2}); 

        }

        T += t[i] * 2;

    }

    //rep(i, sum * 2 + 1) cout << fixed << setprecision(1) << i/2.0 << " " << s[i]/2.0 << endl;

    //cout << endl;

    T = sum * 2;

    s[sum * 2] = 0;

    RREP(i, N - 1, 0) {

        for(int j = T; j > T - t[i] * 2; j -= 2) {

            s[j - 1] = min({s[j - 1], v[i] * 2, s[j] + 1});

            s[j - 2] = min({s[j - 2], v[i] * 2, s[j] + 2}); 

        }

        T -= t[i] * 2;

    }

    int ans = 0;

    // rep(i, sum * 2 + 1) cout << fixed << setprecision(1) << i/2.0 << " " << s[i]/2.0 << endl;

    // cout << endl;

    rep(i, sum * 2 + 1) ans += s[i];

    cout << fixed << setprecision(12) << ans/4.0 << endl;



    return 0;

}
// Slower C++ solution:
///By Stephan Ramirez dsramirezc@unal.edu.co

#include<bits/stdc++.h>

#define ms(a,v) memset(a,v,sizeof a)

#define ll long long

#define N 101

using namespace std;

int n;

ll s[N][3];

int main(){

	#ifdef LOCAL

		freopen("in.txt","r",stdin);

		//freopen("out.txt","w",stdout);

	#endif

    scanf("%d",&n);

    for(int i=0;i<n;i++)

        scanf("%lld %lld %lld",&s[i][0],&s[i][1],&s[i][2]);

    for(int i=0;i<N;i++){

        for(int j=0;j<N;j++){

            set<ll> st;

            ll mx=1e10;

            bool flag=true;

            int ind=-1;

            for(int k=0;k<n;k++){

                if(s[k][2]>0){

                    ll h=s[k][2]+abs(i-s[k][0])+abs(j-s[k][1]);

                    ind=k;

                    st.insert(h);

                }else{

                    mx=min(mx,abs(i-s[k][0])+abs(j-s[k][1]));

                }

            }

            if(st.size()==1 && s[ind][2]+abs(i-s[ind][0])+abs(j-s[ind][1])>0 && s[ind][2]+abs(i-s[ind][0])+abs(j-s[ind][1])<=mx){

                cout<<i<<" "<<j<<" "<<s[ind][2]+abs(i-s[ind][0])+abs(j-s[ind][1])<<endl;

                return 0;

            }

        }

    }



	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 5.600527027096644x):
#include<algorithm>

#include<cstdlib>

#include<cstdio>

#define N 1001

using namespace std;

int n;

struct node {int x,y,h;}p[N];

int main()

{

	scanf("%d",&n);

	for(int i=1;i<=n;i++)scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].h);

	for(int Cx=0;Cx<=100;Cx++)

		for(int Cy=0;Cy<=100;Cy++)

		{

			bool flag=1;int mn=2000000000,H=-1;

			for(int i=1;i<=n;i++)

				if(p[i].h==0)mn=min(mn,abs(p[i].x-Cx)+abs(p[i].y-Cy));

				else if(H==-1)H=p[i].h+abs(p[i].x-Cx)+abs(p[i].y-Cy);

				else if(H!=p[i].h+abs(p[i].x-Cx)+abs(p[i].y-Cy))flag=0;

			if(!flag)continue;if(mn<H)continue;

			if(H==-1)H=mn; if(H<1)continue;

			printf("%d %d %d\n",Cx,Cy,H);exit(0);

		}

}