#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 <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class BaronsAndCoins { public:
int getMaximum(vector <int> x, vector <int> y)
{
vector< pair<int,int> > P;
for(int i=0; i<x.size(); ++i)
P.push_back( make_pair(y[i], x[i]) );
P.push_back( make_pair(0, 0) );
sort( P.begin(), P.end() );
return maxDepth(0, 0, P);
}
map<pair<int,int>,int> memo;
int maxDepth( int i, int k, vector< pair<int,int> >& P )
{
pair<int,int> key(i,k);
if( memo.count(key) )
return memo[key];
int md = 0;
for(int j=i+1; j<P.size(); ++j)
{
int lk = leastReachK( P[j].first-P[i].first, P[j].second-P[i].second, k );
if( lk > 0 )
md = max(md, 1 + maxDepth(j, lk, P));
}
return memo[key] = md;
}
int leastReachK( int dy, int dx, int k )
{
if( dy <= 0 || dx <= 0 )
return -1;
int minX = ((k+1)+(k+dy))*dy / 2;
if( dx < minX )
return -1;
int curK = k+dy;
int rest = dx - minX;
while( rest )
{
curK += rest / dy;
rest %= dy;
--dy;
}
return curK;
}
};
// 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 int& Expected, const int& Received) {
bool ok = (Expected == Received);
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(_, BaronsAndCoins().getMaximum(x, y));}
int main(){
CASE(0)
int x_[] = {15, 5, 30};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {4, 5, 6};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 2;
END
CASE(1)
int x_[] = {10};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {10};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 0;
END
CASE(2)
int x_[] = {1, 3, 6, 10, 15, 21};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {1, 2, 3, 4, 5, 6};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 6;
END
CASE(3)
int x_[] = {5, 10, 15, 20, 25, 30, 35, 40, 45};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 3;
END
CASE(4)
int x_[] = {1, 3, 6, 10, 22, 35, 50, 66};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {1, 2, 3, 1, 2, 3, 4, 5};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 5;
END
CASE(5)
int x_[] = {10};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {4};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 1;
END
CASE(6)
int x_[] = {9};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {4};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 0;
END
CASE(7)
int x_[] = {11};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {4};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 1;
END
CASE(8)
int x_[] = {1,3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,153,171,190,210,231,253,276,300,325,351,378,406,435,465,496,528,561,595,630,666,703,741,780,820,861,903,946,990,1035,1081,1128,1176,1225,1275};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 50;
END
CASE(9)
int x_[] = {1,30,60,100,150,210,280,360,450,550,660,780,910,1050,1200,1360,1530,1710,1900,2100,2310,2530,2760,3000,3250,3510,3780,4060,4350,4650,4960,5280,5610,5950,6300,6660,7030,7410,7800,8200,8610,9030,9460,9900};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 44;
END
CASE(10)
int x_[] = {999,3,15};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {1,2,3};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 2;
END
CASE(11)
int x_[] = {4,12,18};
vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_));
int y_[] = {1,3,4};
vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_));
int _ = 2;
END
}
// END CUT HERE