#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class SimilarRatingGraph { public:
double maxLength(vector <int> date, vector <int> rating)
{
const int N = date.size();
double best = 0.0;
for(int s=0; s+1<N; ++s)
for(int t=s+1; t+1<N; ++t)
{
// a d[s] + b = d[t]
// a d[s+1] + b = d[t+1]
// a r[s] + c = r[t]
// a r[s+1] + c = r[t+1]
double a = (date[t+1]-date[t]) / double(date[s+1] - date[s]);
double b = date[t] - a*date[s];
double c = rating[t] - a*rating[s];
double l1=0.0, l2=0.0;
for(int k=1; t+k<N; ++k) {
if( !eq(a*date[s+k]+b, date[t+k]) ) break;
if( !eq(a*rating[s+k]+c, rating[t+k]) ) break;
l1 += sqrt(pow(date[s+k]-date[s+k-1],2) + pow(rating[s+k]-rating[s+k-1],2));
l2 += sqrt(pow(date[t+k]-date[t+k-1],2) + pow(rating[t+k]-rating[t+k-1],2));
}
best = max(best, max(l1, l2));
}
return best;
}
double eq(double x, int v) {
return int(floor(x+0.5)) == v;
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const double& Expected, const double& Received) {
bool ok = (abs(Expected - Received) < 1e-9);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, SimilarRatingGraph().maxLength(date, rating));}
int main(){
CASE(0)
int date_[] = {1,2,4,8,16,32};
vector <int> date(date_, date_+sizeof(date_)/sizeof(*date_));
int rating_[] = {1,2,4,8,16,32};
vector <int> rating(rating_, rating_+sizeof(rating_)/sizeof(*rating_));
double _ = 42.42640687119285;
END
CASE(1)
int date_[] = {81,104,120,124,134,137};
vector <int> date(date_, date_+sizeof(date_)/sizeof(*date_));
int rating_[] = {1866,2332,2510,2678,2876,3002};
vector <int> rating(rating_, rating_+sizeof(rating_)/sizeof(*rating_));
double _ = 168.04761230080004;
END
CASE(2)
int date_[] = {10,11,13,15,19};
vector <int> date(date_, date_+sizeof(date_)/sizeof(*date_));
int rating_[] = {10,14,15,23,25};
vector <int> rating(rating_, rating_+sizeof(rating_)/sizeof(*rating_));
double _ = 12.7183472062349;
END
CASE(3)
int date_[] = {1,2,3,4};
vector <int> date(date_, date_+sizeof(date_)/sizeof(*date_));
int rating_[] = {1700,1800,1750,1850};
vector <int> rating(rating_, rating_+sizeof(rating_)/sizeof(*rating_));
double _ = 100.00499987500625;
END
CASE(4)
int date_[] = {1,2,3,4};
vector <int> date(date_, date_+sizeof(date_)/sizeof(*date_));
int rating_[] = {1,4,9,16};
vector <int> rating(rating_, rating_+sizeof(rating_)/sizeof(*rating_));
double _ = 0.0;
END
CASE(5)
int date_[] = {5,11,25,58,92,162,255,350,458,566,677,792,919,1051,1189,1331,1489,1673,1882,2093,2315,2541,2771,3012,3254,3524,3797,4087,4379,4675,4973,5278,5588,5904,6225,6550,6888,7249,7612,8018,8428,8847,9267,9688,10109,10530,10964,11407,11870,12340,12811,13288,13768,14249,14734,15242,15774,16306,16847,17400,17966,18533,19108,19692,20278,20871,21471,22074,22679,23297,23916,24553,25190,25829,26472,27135,27814,28497,29181,29865,30555,31272,31994,32729,33487,34246,35005,35764,36537,37326,38119,38913,39725,40538,41360,42185,43010,43840,44671,45509,46350,47205,48063,48932,49807,50691,51577,52464,53289,54119,54950,55788,56629,57484,58342,59211,60086,60970,61856,62743,63568,64398,65388};
vector <int> date(date_, date_+sizeof(date_)/sizeof(*date_));
int rating_[] = {1505,1462,1436,1416,1463,1421,1411,1450,1497,1465,1423,1394,1391,1367,1358,1323,1310,1279,1268,1279,1311,1342,1359,1387,1414,1376,1424,1382,1373,1335,1359,1318,1275,1266,1227,1203,1168,1163,1184,1144,1169,1207,1250,1235,1209,1162,1124,1148,1168,1202,1190,1155,1179,1194,1195,1195,1203,1240,1218,1245,1220,1190,1208,1180,1182,1148,1139,1126,1152,1159,1147,1158,1112,1091,1101,1116,1123,1086,1126,1110,1128,1085,1132,1145,1135,1140,1117,1081,1120,1131,1081,1032,1071,1102,1071,1065,1068,1027,980,947,987,968,959,980,990,974,1003,996,999,958,911,878,918,899,890,911,921,905,934,927,930,889,844};
vector <int> rating(rating_, rating_+sizeof(rating_)/sizeof(*rating_));
double _ = 11940.179271014536;
END
/*
CASE(6)
int date_[] = ;
vector <int> date(date_, date_+sizeof(date_)/sizeof(*date_));
int rating_[] = ;
vector <int> rating(rating_, rating_+sizeof(rating_)/sizeof(*rating_));
double _ = ;
END
CASE(7)
int date_[] = ;
vector <int> date(date_, date_+sizeof(date_)/sizeof(*date_));
int rating_[] = ;
vector <int> rating(rating_, rating_+sizeof(rating_)/sizeof(*rating_));
double _ = ;
END
*/
}
// END CUT HERE