QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#323900#8235. Top Clusterucup-team087#AC ✓1225ms421572kbC++2014.6kb2024-02-10 14:03:592024-02-10 14:04:00

Judging History

你现在查看的是最新测评结果

  • [2024-02-10 14:04:00]
  • 评测
  • 测评结果:AC
  • 用时:1225ms
  • 内存:421572kb
  • [2024-02-10 14:03:59]
  • 提交

answer

#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#endif

#include <bits/stdc++.h>
using namespace std;

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
void dmpr(ostream&os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ";
	dmpr(os,args...);
}
#define dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif

using uint=unsigned;
using ull=unsigned long long;

template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
	return os<<vc<t>(all(a));
}

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

pi readpi(int off=0){
	int a,b;cin>>a>>b;
	return pi(a+off,b+off);
}

template<class t>
void print_single(t x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<"\n";
	if(suc==2)
		cout<<" ";
}

template<class t,class u>
void print_single(const pair<t,u>&p,int suc=1){
	print_single(p.a,2);
	print_single(p.b,suc);
}

template<class T>
void print_single(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print_single(v[i],i==int(v.size())-1?suc:2);
}

template<class T>
void print_offset(const vector<T>&v,ll off,int suc=1){
	rep(i,v.size())
		print_single(v[i]+off,i==int(v.size())-1?suc:2);
}

template<class T,size_t N>
void print_single(const array<T,N>&v,int suc=1){
	rep(i,N)
		print_single(v[i],i==int(N)-1?suc:2);
}

template<class T>
void print(const T&t){
	print_single(t);
}

template<class T,class ...Args>
void print(const T&t,const Args&...args){
	print_single(t,2);
	print(args...);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
//#define CAPITAL
/*
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<"\n";
	#else
	cout<<"Yes"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<"\n";
	#else
	cout<<"No"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}*/
void possible(bool ex=true){
	#ifdef CAPITAL
	cout<<"POSSIBLE"<<"\n";
	#else
	cout<<"Possible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void impossible(bool ex=true){
	#ifdef CAPITAL
	cout<<"IMPOSSIBLE"<<"\n";
	#else
	cout<<"Impossible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int topbit(ull t){
	return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
	return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
	return a==0?64:__builtin_ctzll(a);
}
int botbit(ull a){
	return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
int popcount(ull t){
	return __builtin_popcountll(t);
}
int bitparity(ll t){
	return __builtin_parityll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}
ll mask(int i){
	return (ll(1)<<i)-1;
}
ull umask(int i){
	return (ull(1)<<i)-1;
}
ll minp2(ll n){
	if(n<=1)return 1;
	else return ll(1)<<(topbit(n-1)+1);
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

template<class t> bool isuni(vc<t> v){
	int s=si(v);
	mkuni(v);
	return si(v)==s;
}

ll rand_int(ll l, ll r) { //[l, r]
	//#ifdef LOCAL
	static mt19937_64 gen;
	/*#else
	static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
	#endif*/
	return uniform_int_distribution<ll>(l, r)(gen);
}

ll rand_int(ll k){ //[0,k)
	return rand_int(0,k-1);
}

template<class t>
void myshuffle(vc<t>&a){
	rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}

template<class t,class u>
int lwb(const vc<t>&v,const u&a){
	return lower_bound(all(v),a)-v.bg;
}
template<class t,class u>
bool bis(const vc<t>&v,const u&a){
	return binary_search(all(v),a);
}

vvc<int> readGraph(int n,int m){
	vvc<int> g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		//sc.read(a,b);
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	return g;
}

vvc<int> readTree(int n){
	return readGraph(n,n-1);
}

template<class t>
vc<t> presum(const vc<t>&a){
	vc<t> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
vc<ll> presum(const vi&a){
	vc<ll> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
//BIT で数列を管理するときに使う (CF850C)
template<class t>
vc<t> predif(vc<t> a){
	gnr(i,1,si(a))a[i]-=a[i-1];
	return a;
}
template<class t>
vvc<ll> imos(const vvc<t>&a){
	int n=si(a),m=si(a[0]);
	vvc<ll> b(n+1,vc<ll>(m+1));
	rep(i,n)rep(j,m)
		b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j];
	return b;
}

//verify してないや
void transvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void transvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[j][i]=a[i][j];
	}
	a.swap(b);
	transvvc(n,m,args...);
}
//CF854E
void rotvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void rotvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[m-1-j][i]=a[i][j];
	}
	a.swap(b);
	rotvvc(n,m,args...);
}

//ソートして i 番目が idx[i]
//CF850C
template<class t>
vi sortidx(const vc<t>&a){
	int n=si(a);
	vi idx(n);iota(all(idx),0);
	sort(all(idx),[&](int i,int j){return a[i]<a[j];});
	return idx;
}
//vs[i]=a[idx[i]]
//例えば sortidx で得た idx を使えば単にソート列になって返ってくる
//CF850C
template<class t>
vc<t> a_idx(const vc<t>&a,const vi&idx){
	int n=si(a);
	assert(si(idx)==n);
	vc<t> vs(n);
	rep(i,n)vs[i]=a[idx[i]];
	return vs;
}
//CF850C
vi invperm(const vi&p){
	int n=si(p);
	vi q(n);
	rep(i,n)q[p[i]]=i;
	return q;
}

template<class t,class s=t>
s SUM(const vc<t>&a){
	return accumulate(all(a),s(0));
}
template<class t,size_t K,class s=t>
s SUM(const array<t,K>&a){
	return accumulate(all(a),s(0));
}

template<class t>
t MAX(const vc<t>&a){
	return *max_element(all(a));
}

template<class t>
pair<t,int> MAXi(const vc<t>&a){
	auto itr=max_element(all(a));
	return mp(*itr,itr-a.bg);
}

template<class A>
auto MIN(const A&a){
	return *min_element(all(a));
}

template<class t>
pair<t,int> MINi(const vc<t>&a){
	auto itr=min_element(all(a));
	return mp(*itr,itr-a.bg);
}

vi vid(int n){
	vi res(n);iota(all(res),0);
	return res;
}

template<class S>
void soin(S&s){
	sort(all(s));
}

template<class S,class F>
void soin(S&s,F&&f){
	sort(all(s),forward<F>(f));
}

template<class S>
S soout(S s){
	soin(s);
	return s;
}

template<class S>
void rein(S&s){
	reverse(all(s));
}

template<class S>
S reout(S s){
	rein(s);
	return s;
}

template<class t,class u>
pair<t,u>&operator+=(pair<t,u>&a,pair<t,u> b){
	a.a+=b.a;a.b+=b.b;return a;}
template<class t,class u>
pair<t,u>&operator-=(pair<t,u>&a,pair<t,u> b){
	a.a-=b.a;a.b-=b.b;return a;}
template<class t,class u>
pair<t,u> operator+(pair<t,u> a,pair<t,u> b){return mp(a.a+b.a,a.b+b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a,pair<t,u> b){return mp(a.a-b.a,a.b-b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a){return mp(-a.a,-a.b);}
template<class t,class u>
istream&operator>>(istream&is,pair<t,u>&a){
	return is>>a.a>>a.b;
}

template<class t>
t gpp(vc<t>&vs){
	assert(si(vs));
	t res=move(vs.back());
	vs.pop_back();
	return res;
}

template<class t,class u>
void pb(vc<t>&a,const vc<u>&b){
	a.insert(a.ed,all(b));
}

template<class t,class...Args>
vc<t> cat(vc<t> a,Args&&...b){
	(pb(a,forward<Args>(b)),...);
	return a;
}

template<class t,class u>
vc<t>& operator+=(vc<t>&a,u x){
	for(auto&v:a)v+=x;
	return a;
}

template<class t,class u>
vc<t> operator+(vc<t> a,u x){
	return a+=x;
}

template<class t>
vc<t> operator+(const vc<t>&a,const vc<t>&b){
	vc<t> c(max(si(a),si(b)));
	rep(i,si(a))c[i]+=a[i];
	rep(i,si(b))c[i]+=b[i];
	return c;
}

template<class t,class u>
vc<t>& operator-=(vc<t>&a,u x){
	for(auto&v:a)v-=x;
	return a;
}

template<class t,class u>
vc<t>& operator-(vc<t> a,u x){
	return a-=x;
}

template<class t,class u>
void remval(vc<t>&a,const u&v){
	a.erase(remove(all(a),v),a.ed);
}
//消した要素の個数を返してくれる
//UCUP 2-8-F
template<class t,class F>
int remif(vc<t>&a,F f){
	auto itr=remove_if(all(a),f);
	int res=a.ed-itr;
	a.erase(itr,a.ed);
	return res;
}

template<class VS,class u>
void fila(VS&vs,const u&a){
	fill(all(vs),a);
}

template<class t,class u>
int findid(const vc<t>&vs,const u&a){
	auto itr=find(all(vs),a);
	if(itr==vs.ed)return -1;
	else return itr-vs.bg;
}

template<class t>
void rtt(vc<t>&vs,int i){
	rotate(vs.bg,vs.bg+i,vs.ed);
}

//VERIFY: yosupo
//AOJGRL5C
template<class t,class u>
struct sparsetable{
	vvc<t> a;
	u f;
	const t id;
	sparsetable(const vc<t>& d,u ff,t w):f(ff),id(w){
		if(d.empty())return;
		int n=d.size(),h=topbit(n);
		a.resize(h+1);
		a[0]=d;
		rng(j,1,h+1){
			a[j].resize(n-(1<<j)+1);
			rep(i,n-(1<<j)+1)
				a[j][i]=f(a[j-1][i],a[j-1][i+(1<<(j-1))]);
		}
	}
	t get(int b,int e){
		assert(b<=e);
		if(b==e)return id;
		int d=topbit(e-b);
		return f(a[d][b],a[d][e-(1<<d)]);
	}
};

//AOJGRL5C
//Universal Cup 2023 Stage 1 G
auto pimin=[](pi a,pi b){
	return min(a,b);
};
template<class E>
struct etlca{
	const vvc<E>&g;
	const int n;
	int io=0,be=0;
	vi in,out,dep,b,e,par,ni;
	vc<pi> di;
	vc<ll> wei;
	void dfs(int v,int p,int d,ll w){
		in[v]=io++;
		dep[v]=d;
		b[v]=be;
		di[be++]=pi(d,v);
		par[v]=p;
		wei[v]=w;
		for(auto to:g[v])if(to!=p){
			dfs(to,v,d+1,w+to.cost);
			di[be++]=pi(d,v);
		}
		out[v]=io;
		e[v]=be;
	}
	sparsetable<pi,decltype(pimin)> st;
	etlca(const vvc<E>&t,int r):g(t),n(si(g)),
		in(n),out(n),dep(n),b(n),e(n),par(n),ni(n),di(2*n-1),
		wei(n),
		st((dfs(r,-1,0,0),di),pimin,pi(inf,-1)){
		rep(i,n)ni[in[i]]=i;
	}
	int lca(int u,int v){
		return st.get(min(b[u],b[v]),max(e[u],e[v])).b;
	}
	int wdist(int u,int v){
		int z=lca(u,v);
		return wei[u]+wei[v]-wei[z]*2;
	}
	pi diaadd(pi x,int v){
		int a=wdist(x.a,x.b);
		int c=wdist(x.a,v);
		int d=wdist(v,x.b);
		int m=max({a,c,d});
		if(m==c)x.b=v;
		else if(m==d)x.a=v;
		return x;
	}
	//Universal Cup 2023 Stage 1 G
	vi index;
	//vs を含む virtual tree を返す
	//返すのは virtual tree に使われた頂点と,辺の集合
	//辺の端点は,virtual tree における番号
	//元の木における番号を virtual tree の頂点番号に写すのが,index という変数
	//辺は ch->par の順
	//virtual tree は行き掛け順で番号がついている
	//特に,頂点 0 が根になるようにできている
	//pair<vi,vc<pi>> tree_compress(vi vs){
	void tree_compress(vi&vs,vc<pi>&es){
		if(si(index)==0)index.resize(n);
		assert(index.size());
		auto comp = [&](int x,int y){
			return in[x] < in[y];
		};
		//sort(all(vs),comp);
		assert(is_sorted(all(vs),comp));
		vs.erase(unique(all(vs)),vs.ed);
		int k = vs.size();
		rep(i,k-1){
			vs.pb(lca(vs[i],vs[i+1]));
		}
		sort(all(vs),comp);
		vs.erase(unique(all(vs)),vs.ed);
		k = vs.size();
		rep(i,k) index[vs[i]] = i;
		es.clear();
		rng(i,1,k){
			int p = lca(vs[i-1],vs[i]);
			es.eb(i,index[p]);
		}
		//return mp(vs,es);
	}
};

struct E{
	int to,cost;
	operator int()const{return to;}
};

bool dbg=false;

//f(lw)=true,f(up)=false
template<class F>
int find_max_true(int lw,int up,F f){
	while(up-lw>1){
		const int mid=(lw+up)/2;
		if(f(mid))lw=mid;
		else up=mid;
	}
	return lw;
}

int mex(vi x){
	mkuni(x);
	rep(i,si(x))if(i!=x[i])return i;
	return si(x);
}

void slv(){
	int n,q;cin>>n>>q;
	vi ws=readvi(n);
	vi idx(n,-1);
	rep(i,n){
		if(ws[i]<n)idx[ws[i]]=i;
	}
	idx.resize(mex(ws));
	vvc<E> t(n);
	rep(i,n-1){
		int u,v,c;cin>>u>>v>>c;
		u--;v--;
		t[u].pb({v,c});
		t[v].pb({u,c});
	}
	
	etlca<E> z(t,0);
	vc<pi> two(si(idx));
	rep(i,si(idx)){
		if(i==0)two[i]=pi(idx[i],idx[i]);
		else two[i]=z.diaadd(two[i-1],idx[i]);
	}
	
	rep(_,q){
		int x,k;cin>>x>>k;
		x--;
		
		int ans=find_max_true(-1,si(two),[&](int i){
			int d=max(z.wdist(two[i].a,x),z.wdist(two[i].b,x));
			return d<=k;
		});
		print(ans+1);
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	if(dbg){
		while(1)slv();
	}else{
		//int t;cin>>t;rep(_,t)
		slv();
	}
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3560kb

input:

5 4
3 9 0 1 2
1 2 10
3 1 4
3 4 3
3 5 2
3 0
1 0
4 6
4 7

output:

1
0
3
4

result:

ok 4 number(s): "1 0 3 4"

Test #2:

score: 0
Accepted
time: 866ms
memory: 396040kb

input:

500000 500000
350828 420188 171646 209344 4 999941289 289054 79183 999948352 427544 160827 138994 192204 108365 99596 999987124 292578 2949 384841 269390 999920664 315611 163146 51795 265839 34188 999939494 145387 366234 86466 220368 357231 347706 332064 279036 173185 5901 217061 112848 37915 377359...

output:

0
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
2499...

result:

ok 500000 numbers

Test #3:

score: 0
Accepted
time: 980ms
memory: 396148kb

input:

500000 500000
416779 59604 366180 195604 4 30957 999969109 7476 352690 368624 121597 999960303 999933891 13 14 138579 294015 227392 106760 117837 208506 999997971 34770 40258 182765 65889 206246 233051 130491 182099 117381 241945 449750 155921 356191 999955435 2243 450904 242106 178163 148523 75648 ...

output:

0
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
250002
2500...

result:

ok 500000 numbers

Test #4:

score: 0
Accepted
time: 982ms
memory: 412136kb

input:

500000 500000
161260 258036 999901390 280191 21975 193647 397811 362276 206096 421117 336278 416815 31870 999934957 999977591 15 999991550 235871 999916756 19 241647 466194 218880 352702 84559 479034 24903 124981 339271 153019 157132 333035 124326 464181 219609 94164 999933701 440055 118732 2285 175...

output:

0
250000
250000
69
10
250000
250000
0
5
250000
250000
250000
1
33
69
10
250000
250000
250000
10
0
250000
250000
250000
1
250000
250000
0
250000
10
5
0
33
10
250000
1
66
250000
1
250000
1
250000
250000
250000
16
1
1
0
5
10
250000
250000
0
250000
250000
250000
250000
250000
250000
250000
5
1
250000
1
...

result:

ok 500000 numbers

Test #5:

score: 0
Accepted
time: 956ms
memory: 412464kb

input:

500000 500000
205699 141313 291987 999929528 111195 248994 999960789 391023 323134 92686 432395 316257 188889 219187 315056 39556 999959131 279778 30709 419259 242325 169515 137848 999905250 130641 245510 26 52987 999900052 144308 180276 162429 405263 130502 101937 108999 259339 137566 414011 304915...

output:

0
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
0
250000
3
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
0
250000
250000
250000
250000
250000
2
250...

result:

ok 500000 numbers

Test #6:

score: 0
Accepted
time: 894ms
memory: 419472kb

input:

500000 500000
142817 198136 999910358 236637 238445 325614 22961 999909937 354352 999984540 189454 221148 208300 169118 999945163 256203 999945857 276295 175580 481676 114118 119423 999962365 999904418 250723 333971 311979 384475 386372 11544 999956892 999960490 999936512 292089 42395 5450 326202 26...

output:

0
250004
0
4
6
5
250004
6
250004
250004
0
0
250004
250004
250004
250004
0
0
250004
250004
250004
0
0
0
0
0
6
0
0
0
0
6
0
250004
4
250004
250004
250004
250004
250004
0
0
6
250004
6
250004
0
0
6
250004
4
250004
0
6
250004
250004
4
250004
0
6
0
250004
0
0
0
250004
4
0
0
6
0
0
0
6
0
250004
4
250004
5
25...

result:

ok 500000 numbers

Test #7:

score: 0
Accepted
time: 922ms
memory: 412776kb

input:

500000 500000
273731 92547 391851 223257 245734 999907678 125748 999999710 260816 269057 173753 337309 208492 162862 160710 371998 296145 999901286 269727 36806 193730 999966618 219876 999919231 999950308 999989538 403483 27 199626 83765 58199 38349 999985326 362514 103279 96338 292486 353093 235704...

output:

0
250007
0
250007
250007
250007
250007
250007
250007
0
250007
0
250007
250007
250007
250007
250007
250007
250007
250007
250007
250007
250007
2
250007
250007
250007
250007
250007
250007
250007
250007
250007
250007
250007
250007
0
250007
250007
250007
250007
250007
250007
250007
250007
250007
250007
2...

result:

ok 500000 numbers

Test #8:

score: 0
Accepted
time: 951ms
memory: 406840kb

input:

500000 500000
38066 263927 999904526 64975 999942253 139690 333059 341736 101159 145885 366360 999977224 58855 20369 491696 99014 999901769 497319 464130 118700 167144 197334 22373 266338 218334 344178 201845 470679 63936 29 473097 168465 91804 999907288 213685 441541 15210 999994423 241375 262928 1...

output:

0
249999
3
3
3
3
3
0
3
3
0
249999
3
249999
249999
249999
3
249999
249999
249999
3
249999
249999
3
249999
249999
249999
249999
249999
3
249999
249999
249999
3
249999
249999
249999
3
249999
3
249999
3
0
249999
3
249999
249999
249999
0
3
249999
249999
0
249999
249999
249999
249999
3
249999
0
0
0
3
3
3
...

result:

ok 500000 numbers

Test #9:

score: 0
Accepted
time: 897ms
memory: 411292kb

input:

500000 500000
359851 43247 193376 203439 213018 339470 255465 158106 353438 240598 296467 999940205 179011 999920003 999961598 416833 295334 64229 170166 444767 999928467 338236 9395 999990262 19653 322714 241284 499248 999981930 196853 232801 999979589 264041 137694 421299 35 156387 67567 38 221352...

output:

0
250001
250001
250001
13
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
0
250001
13
250001
250001
250001
250001
250001
250001
250001
250001
250001
0
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
2...

result:

ok 500000 numbers

Test #10:

score: 0
Accepted
time: 864ms
memory: 407828kb

input:

500000 500000
62793 498516 201977 999910782 23738 94684 376404 165784 999984668 9 237448 417677 193394 999979378 207107 151870 11179 256917 96826 999936376 125873 70090 368693 23 80005 56086 38967 199021 222122 14684 84341 181399 999992500 417811 182996 231813 121859 226504 999926433 247806 128322 4...

output:

0
249999
0
0
249999
0
249999
249999
249999
0
249999
249999
249999
0
249999
249999
0
249999
249999
249999
249999
0
249999
249999
249999
249999
249999
249999
249999
249999
0
249999
0
249999
249999
249999
0
249999
249999
249999
249999
249999
2
0
249999
249999
249999
249999
0
249999
249999
249999
249999...

result:

ok 500000 numbers

Test #11:

score: 0
Accepted
time: 899ms
memory: 406580kb

input:

500000 500000
372147 331053 216364 102319 487927 999930572 299860 157 213337 489912 248140 152140 267978 206747 14 132101 200350 194348 173014 485414 196543 3970 266852 157266 495915 333502 24668 96723 999915484 120906 268572 18354 180019 173961 169642 268928 364754 350491 264515 999926535 454505 11...

output:

0
250000
2
250000
1
250000
250000
250000
250000
1
0
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
0
250000
250000
250000
250000
250000
250000
0
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
2
250000
250000
250000
2500...

result:

ok 500000 numbers

Test #12:

score: 0
Accepted
time: 875ms
memory: 407516kb

input:

500000 500000
10554 434273 130897 323091 259102 144593 2071 45944 411296 409399 149044 218944 287068 417164 999909168 471124 136115 180015 183512 999932545 221007 21 22 50559 379436 39555 304433 202728 344640 45046 165027 422037 168022 69739 34 194833 77845 164660 33088 109769 40 149910 236459 21921...

output:

0
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
2
249999
249999
2
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
2
249999
249999
249999
249999
24999...

result:

ok 500000 numbers

Test #13:

score: 0
Accepted
time: 879ms
memory: 406484kb

input:

500000 500000
344899 5568 257238 360917 4 118728 110263 98091 365290 373265 230234 441644 83532 999911278 14 999955564 81214 17 206112 23116 443325 295321 17096 53413 226648 251673 66249 487707 258661 98934 999948086 43419 11185 999905728 999937426 445203 77498 207957 331814 300133 95465 51867 26432...

output:

0
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
0
250003
250003
250003
250003
25...

result:

ok 500000 numbers

Test #14:

score: 0
Accepted
time: 842ms
memory: 409688kb

input:

500000 500000
999957979 378969 37036 999976923 132503 126691 237168 248631 409168 999952617 226712 999971364 387270 360750 106052 999910264 1416 297566 336125 489882 78289 21 999973670 111583 188239 409935 429010 12181 999933993 89449 108495 15506 155044 153110 109451 497005 96792 9884 240956 999987...

output:

0
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
2
249999
249999
249999
249999
249999
249999
0
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
0
249999
2
1
2...

result:

ok 500000 numbers

Test #15:

score: 0
Accepted
time: 849ms
memory: 407320kb

input:

500000 500000
389972 445695 57960 999992103 181260 478090 442480 238400 92107 35808 496377 999970919 49853 95800 9724 15 999950506 427344 421081 999964891 231947 486953 75869 50981 166481 250659 327128 296434 40061 384891 95298 23035 999933227 115998 86190 14551 999914805 330917 99711 39811 98541 15...

output:

0
250000
250000
250000
250000
250000
250000
250000
0
250000
23
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
250000
8
250000
250000
250000
250000
250000
0
250000
25...

result:

ok 500000 numbers

Test #16:

score: 0
Accepted
time: 884ms
memory: 394936kb

input:

500000 500000
160899 83708 999956721 116001 72511 207492 212355 65073 187736 9 337991 160783 220653 310467 18317 467640 999945604 222991 129636 286000 486761 42761 158760 497369 135755 102090 379616 999947096 999957305 313994 999908228 82387 89197 372359 244101 300795 150397 999982032 999955498 4878...

output:

0
1
1
0
0
0
0
0
1
0
0
0
1
0
0
1
1
0
1
1
1
0
0
0
1
0
0
0
0
1
0
0
0
0
1
0
0
1
1
1
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
0
1
1
0
1
1
0
1
0
0
0
1
1
0
1
1
1
0
1
1
0
0
0
1
0
0
0
1
0
0
1
0
0
1
1
1
0
1
1
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
0
1
0
0
1
0
0
1
1
1
0
0
0
1
0
0
1
1
0
0
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
1
...

result:

ok 500000 numbers

Test #17:

score: 0
Accepted
time: 585ms
memory: 411816kb

input:

500000 500000
0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

0
250024
0
0
0
136214
0
0
250024
250024
250024
0
0
0
0
0
0
250024
250024
250024
0
0
250024
0
250024
250024
250024
0
0
250024
0
250024
250024
0
188431
250024
0
250024
0
235886
0
250024
250024
250024
0
250024
0
250024
150973
0
250024
250024
250024
0
0
0
0
0
250024
0
250024
250024
250024
0
250024
25002...

result:

ok 500000 numbers

Test #18:

score: 0
Accepted
time: 550ms
memory: 421572kb

input:

500000 500000
0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

0
250242
250242
0
250242
0
250242
0
0
0
0
0
250242
250242
249765
0
0
0
0
250242
0
250242
0
250242
250242
0
250242
111162
68981
0
232259
250242
0
250242
0
188382
250242
0
249078
250242
0
0
0
0
0
0
250242
0
0
0
250242
0
250242
250242
0
0
250242
250242
250242
0
250242
250242
0
250242
250242
250242
0
25...

result:

ok 500000 numbers

Test #19:

score: 0
Accepted
time: 598ms
memory: 411860kb

input:

500000 500000
0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

0
250035
250035
250035
250035
250035
250035
250035
250035
250035
250035
0
250035
250035
0
0
250035
0
250035
250035
0
250035
70068
250035
250035
250035
250035
250035
250035
250035
250035
250035
250035
250035
250035
250035
250035
250035
250035
0
250035
250035
250035
250035
250035
250035
250035
250035
...

result:

ok 500000 numbers

Test #20:

score: 0
Accepted
time: 635ms
memory: 408420kb

input:

500000 500000
0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

0
250233
250233
250233
250233
250233
250233
250233
250233
250233
250233
25654
0
250233
250233
250233
250233
250233
250233
250233
250233
250233
248693
250233
250233
250233
250233
250233
0
250233
250233
250233
250233
250233
250233
250233
250233
250233
250233
250233
250233
250233
250233
250233
250233
2...

result:

ok 500000 numbers

Test #21:

score: 0
Accepted
time: 950ms
memory: 408424kb

input:

500000 500000
0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

0
250447
208490
208811
0
0
63548
0
250447
8882
21150
160870
133903
71184
194840
0
68425
30751
65729
219571
112843
0
250447
69834
191655
0
190132
0
179071
226688
0
0
0
183833
223897
250447
0
47193
92291
0
154652
0
250447
189392
250447
250447
247765
0
112408
59720
108124
100511
126898
198855
0
225181
...

result:

ok 500000 numbers

Test #22:

score: 0
Accepted
time: 391ms
memory: 394932kb

input:

500000 1
159045 193900 999974833 3 999954042 999996219 425301 999999578 16228 61597 320935 134226 178894 71195 371140 347953 365582 163515 267457 132569 22439 227949 254340 455102 24 61800 74708 73738 302755 999969435 201404 360581 333960 43503 275248 35 127293 227282 111164 405480 251073 28467 3434...

output:

0

result:

ok 1 number(s): "0"

Test #23:

score: 0
Accepted
time: 67ms
memory: 3528kb

input:

1 500000
0
1 0
1 3000000000
1 2004631033
1 715542462
1 1768462801
1 2989786132
1 2726091886
1 2259205577
1 362474676
1 1151951449
1 2117952161
1 2904847636
1 1556995443
1 2366732010
1 2372033576
1 288347569
1 776706498
1 2805710521
1 809149695
1 2456267663
1 780619499
1 1232031579
1 2587499917
1 213...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #24:

score: 0
Accepted
time: 1225ms
memory: 399308kb

input:

500000 500000
999901671 10769 359984 102432 119574 999926476 349229 159673 212285 43640 346831 7390 436281 13 409236 127981 23758 258961 253764 204229 999925571 306200 999966308 465126 402489 244176 999943158 221247 424062 237512 13647 31 388264 191024 288636 999936597 81928 31360 218390 98973 87081...

output:

0
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
250001
2500...

result:

ok 500000 numbers

Test #25:

score: 0
Accepted
time: 863ms
memory: 399524kb

input:

500000 500000
100773 308386 264303 165223 399097 76516 235523 350314 285417 897 354488 11 416928 200574 86817 211681 359612 7597 276187 22158 262245 154115 431031 90693 175052 98349 13580 212883 243281 29 289135 3550 256671 406133 162343 309380 381457 369840 38 188414 40 151436 491194 43 363698 3549...

output:

0
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
261305
2613...

result:

ok 500000 numbers

Test #26:

score: 0
Accepted
time: 847ms
memory: 399308kb

input:

500000 500000
289358 42324 425391 86181 498430 348557 67094 379511 321220 309272 55729 480663 167184 459418 188836 125604 282313 200512 220453 68166 95872 21 248496 60217 221902 18804 267319 480095 395409 280694 381740 184959 413365 266979 368678 128792 59256 495822 445313 39 258883 424773 63581 446...

output:

0
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
251155
2511...

result:

ok 500000 numbers

Test #27:

score: 0
Accepted
time: 847ms
memory: 399168kb

input:

500000 500000
91461 434366 11830 138353 4 360132 297809 404464 347833 364236 452510 207419 101447 52913 70881 163985 440013 17404 163712 34399 151669 127689 352798 168554 321082 406586 19620 131466 322117 334452 474939 275767 67128 365987 92054 219238 356999 157565 452991 352864 40 463130 7467 37754...

output:

0
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
250486
2504...

result:

ok 500000 numbers

Test #28:

score: 0
Accepted
time: 862ms
memory: 399144kb

input:

500000 500000
466600 99168 253195 999994344 204870 428024 399039 209632 38571 204632 408732 23714 82737 24126 102546 187826 274291 32617 398590 424872 68465 467229 356703 135156 487213 331348 104436 238176 39246 312786 179664 68455 478458 288105 111155 174923 242514 37 999993825 363478 433962 317904...

output:

0
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
250019
2500...

result:

ok 500000 numbers

Test #29:

score: 0
Accepted
time: 854ms
memory: 399152kb

input:

500000 500000
259372 189763 999935127 461575 106530 70968 348751 999922454 123500 999902280 200045 296519 201651 476809 54940 188854 20288 214528 30656 382151 84187 999945031 50666 303011 24 211054 496271 132261 394541 210258 311718 110928 215275 1672 446955 72823 35130 172874 199771 54175 142369 14...

output:

0
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
250003
2500...

result:

ok 500000 numbers

Test #30:

score: 0
Accepted
time: 824ms
memory: 399204kb

input:

500000 500000
58270 109902 999608210 169640 999614243 189901 2313 139575 153337 19095 82999 999873182 999593221 999672570 478660 337418 56786 999624085 248884 53396 999537205 999741131 999530154 999768048 221433 112394 310332 301547 999851652 491276 999630128 249152 15721 999694250 135858 6695 44756...

output:

0
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
249999
2499...

result:

ok 500000 numbers

Test #31:

score: 0
Accepted
time: 605ms
memory: 397032kb

input:

500000 500000
0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

0
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
250045
2500...

result:

ok 500000 numbers

Test #32:

score: 0
Accepted
time: 753ms
memory: 397036kb

input:

500000 500000
0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

0
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
250046
2500...

result:

ok 500000 numbers

Test #33:

score: 0
Accepted
time: 1150ms
memory: 400764kb

input:

500000 500000
202121 220996 8097 78493 454391 429356 195081 38993 430964 118606 324363 69394 67808 304313 390006 461126 152880 160638 249298 147945 359184 353578 183226 447502 24 37265 122718 336381 84770 201899 451652 353295 249030 65833 396420 377423 245835 376581 221428 204165 293038 495043 43430...

output:

0
1807
0
2919
0
2
0
0
0
1
0
1
0
0
1
0
1
1
110661
0
0
0
0
0
2
0
2
0
623
0
0
2
1
0
1
0
1807
0
0
0
1
1
0
0
0
136
0
1
2
136
2
0
2
623
2
0
0
0
1
0
0
0
0
0
0
2
2
0
0
0
0
0
0
0
0
0
623
0
0
0
0
0
0
0
0
0
2
0
1
0
0
0
0
0
0
0
0
0
1
1
0
0
0
1
136
0
0
164757
0
0
0
0
0
0
1
2
0
2
0
0
2
0
0
0
1
1
0
0
0
0
0
0
1
2
0...

result:

ok 500000 numbers

Test #34:

score: 0
Accepted
time: 1086ms
memory: 400708kb

input:

500000 500000
108447 37792 25161 3 12715 180439 414555 13469 8 77577 282924 60606 393282 390559 195252 219181 113432 391477 413571 349986 484539 313425 307279 489366 318196 452147 76000 483951 496164 366225 120357 196730 428931 336884 184495 46657 126935 74583 431617 251653 474604 132451 161252 6089...

output:

0
16
99
0
0
0
0
13
0
0
2
0
0
0
0
0
2
90
0
0
0
2
0
0
0
0
2
0
0
0
0
0
0
0
0
4
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
481
0
0
0
2
0
2
0
54
0
0
0
2
0
0
0
0
0
0
0
0
0
0
16
2
0
0
0
1
0
0
4
0
2
0
40
0
0
0
0
0
11
0
0
0
0
0
0
0
0
0
0
0
0
0
16
4
40
4
0
13
0
2
0
0
0
0
0
0
35074
0
2
160...

result:

ok 500000 numbers

Test #35:

score: 0
Accepted
time: 1085ms
memory: 400856kb

input:

500000 500000
6441 437512 398611 332689 224277 339836 223188 7 242501 308201 132913 497884 181912 234928 386010 26082 81521 189412 447854 113990 453547 271276 340668 177922 389441 28382 26 27 314406 458665 74206 160594 326289 85016 34 153417 196600 151883 510 362467 189835 148908 45311 314126 300828...

output:

0
161
0
0
0
0
2
0
161
0
2
0
2
5
0
0
0
0
5
9
0
0
0
64
161
3
2
0
9
9
0
3
64
3
818
0
0
2
0
0
0
3
0
9
64
2
5
0
2
0
0
0
0
5
0
0
0
5
0
5
0
5
0
0
9
3
3
0
2
3
0
3
0
0
0
0
0
0
0
3
2
5
0
0
0
3
0
0
3
0
0
5
2
0
5
0
0
3
0
3
0
13
3
0
0
2
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
3
9
0
0
3
0
13
0
0
0
0
0
0
40
40
0
0
0
3
0
0
2...

result:

ok 500000 numbers

Test #36:

score: 0
Accepted
time: 1122ms
memory: 400508kb

input:

500000 500000
416624 140542 78586 312380 4 221776 267073 422304 370026 431663 37561 360788 37685 19112 381521 171417 329956 410134 128839 41683 20 21 29802 328017 64369 247479 291480 151943 153677 347839 373163 339034 198340 499168 34 489246 7961 436075 208944 368758 50970 133931 389917 55067 261575...

output:

0
39
47
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
15
0
0
0
0
0
0
1
0
0
16
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
77661
3
0
89
0
0
0
0
0
1
0
15
0
0
1
0
0
16
0
1
0
2
0
0
0
0
0
0
0
1
2
0
0
336250
0
0
0
14
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
295
0
0
0
0
0
0
0
0
0
0
0
0
1427
1
0
0
0
0
0
0
0
0
0
1
...

result:

ok 500000 numbers

Test #37:

score: 0
Accepted
time: 1102ms
memory: 403112kb

input:

500000 500000
166161 86775 280821 454410 324633 406046 231773 124600 493295 252650 475005 190136 152917 429306 14 453379 201616 66468 175807 107220 20 335544 47285 430095 225595 89234 348072 201728 152312 135619 420827 54567 452444 140915 341932 208819 254154 372448 144955 387131 367708 481790 39018...

output:

0
985
0
1382
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
0
0
10
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
27
0
0
27
0
0
0
985
0
0
1
0
83
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
41
0
27
0
1
0
0
0
0
0
985
0
0
0
0
0
27
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
27
0
1
0
0
0
83
0
0
0
0
0
0
5000...

result:

ok 500000 numbers

Test #38:

score: 0
Accepted
time: 1025ms
memory: 399188kb

input:

500000 500000
378227 267226 278772 44573 443106 186724 312908 381114 131832 255314 159679 68271 269498 122387 18504 414240 213108 485692 48496 208440 276600 21 330059 23 287490 412401 181448 398123 367475 245423 80316 218176 476867 166685 207134 284048 56403 91430 270003 115354 280181 209404 428919 ...

output:

0
2879
19
0
3
1
0
0
4530
0
1
0
0
0
1
0
0
0
0
0
3
0
0
0
0
0
1
3
0
0
0
0
0
0
1
0
0
0
0
0
19
0
19
3
1
19
0
0
0
0
0
0
19
0
0
1
0
0
19
0
0
0
46
46
0
19
0
0
0
0
0
3
46
0
0
3
0
0
0
0
0
0
0
0
68
0
0
0
3
0
0
0
0
0
0
0
0
256562
0
0
0
0
19
68
0
0
0
0
0
0
0
0
0
0
0
0
46
0
0
0
0
0
0
1
0
0
3
3
0
0
0
0
0
0
0
0
0
2...

result:

ok 500000 numbers

Test #39:

score: 0
Accepted
time: 1050ms
memory: 399264kb

input:

500000 500000
324604 73724 20761 355706 165363 61020 471690 7 272177 101581 201181 258457 106411 463004 311606 212315 143859 489859 18 201256 75482 492255 22159 306346 24 29564 85553 146013 445842 37016 189324 436111 424929 190613 58534 35 79456 187495 394785 240826 481468 64898 440183 226937 199846...

output:

0
253163
2
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
2
0
0
16
0
0
0
0
0
66
0
0
0
0
0
0
0
0
0
0
0
0
0
0
589
0
0
0
0
0
2
66
0
0
0
0
0
0
0
8
0
0
0
0
0
0
0
0
0
0
0
0
0
34
0
0
0
0
0
0
304
0
0
0
66
0
0
0
0
0
0
0
0
1781
0
0
0
0
0
0
0
0
0
0
0
0
34
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 500000 numbers

Test #40:

score: 0
Accepted
time: 1077ms
memory: 399288kb

input:

500000 500000
411416 353580 297843 321216 446758 256574 74412 7 235782 144076 268530 118244 303807 185861 68619 278662 482980 120703 261852 318352 231878 308712 22 137357 177691 107796 322532 28792 280469 298962 129565 426931 427892 56294 340595 324216 277886 448263 360969 39 60980 90810 226621 8800...

output:

0
15332
0
11
0
0
0
0
0
18
0
0
1
0
0
0
11
0
0
0
0
0
0
0
0
0
0
11
314
0
0
0
314
0
0
0
0
0
0
18
0
1449
0
21
0
0
0
11
8
0
0
0
0
0
0
0
0
0
0
0
62
0
0
0
0
125
0
0
0
0
0
0
0
0
1
0
0
125
0
0
0
0
0
0
0
0
0
18
21
0
0
0
1
0
10
10
0
8
21
0
0
0
0
0
0
0
0
11
0
0
0
0
0
314
0
0
1
0
0
8
0
0
21
0
0
0
0
0
0
1
0
0
0
0
...

result:

ok 500000 numbers

Test #41:

score: 0
Accepted
time: 1186ms
memory: 399192kb

input:

500000 500000
140524 240101 146358 18559 109380 236211 356830 383299 284617 111380 111993 33758 479783 72189 13054 131783 406761 453941 222462 113104 382948 450543 421387 33454 34407 119666 222297 298225 274774 362657 258863 252280 351912 160237 174585 149164 357834 365037 192137 294404 475873 15938...

output:

0
38
0
20
0
20
0
0
0
0
0
6
0
0
0
6
0
0
10
0
0
305
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
0
0
0
20
0
0
0
0
0
20
0
0
0
0
0
0
0
0
0
4
0
0
0
0
0
0
0
1
4
0
0
38
0
0
0
0
0
0
0
0
0
0
0
0
4
0
0
6
0
0
0
0
0
0
121
1
0
0
6
0
0
0
0
0
0
0
0
0
4
0
0
0
0
6
0
0
0
0
0
6
0
0
20
0
4
0
0
0
121
0
0
6
0
0
0
0
6
1
0
0
1
0
6
0
0
...

result:

ok 500000 numbers

Test #42:

score: 0
Accepted
time: 1135ms
memory: 399208kb

input:

500000 500000
240115 224576 221974 199247 63635 999943278 999983387 999924212 999936437 239747 80282 65112 312822 456004 999942695 36446 11676 235243 253181 494663 39444 256281 311637 23 29955 999902713 341949 485017 73846 999907211 106585 166685 266005 433793 26173 342430 204611 358281 80526 112052...

output:

0
323
381
0
1
0
0
0
0
0
0
0
0
107906
0
0
0
0
0
323
0
0
0
0
0
0
0
0
0
0
0
0
323
0
0
0
0
0
0
0
0
0
0
0
34
0
0
0
0
381
0
0
0
323
151
0
0
0
0
0
0
0
0
0
267
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
34
0
0
0
0
0
0
0
0
0
0
114
0
0
114
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8
0
0
0
0
0
0
0
0
323
0
0
323
0
0
0
0
0
0
0
0
0
0...

result:

ok 500000 numbers

Test #43:

score: 0
Accepted
time: 1188ms
memory: 399144kb

input:

500000 500000
999557060 240477 437073 3 4 999729037 999843332 7 57209 9 999689988 58716 999544424 18561 5870 999566609 280661 999883537 54393 999659043 133560 21 173302 999583667 51171 999567045 999532856 27 999529183 115553 40274 999533377 14004 999703802 400862 999618932 999684009 132267 167687 99...

output:

0
135
21
20251
0
249999
0
1
0
0
11
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
30
1
0
0
0
12097
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1001
1
0
1
1
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
2428
0
7
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
1
7
0
1
699
0
0
0
0
58
0
0
11
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 500000 numbers

Test #44:

score: 0
Accepted
time: 732ms
memory: 397012kb

input:

500000 500000
0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

0
223808
14
0
0
74435
10
217
0
0
28
0
0
6916
0
20
4644
433
433
0
0
879
13857
0
78
291
148865
0
0
3498
20
217
0
78
0
0
292
0
0
0
6996
291
0
10
0
3498
0
434
0
0
618
0
0
0
865
74435
0
4644
10
0
0
434
0
0
0
53
0
0
0
10138
0
0
0
0
310
433
0
0
0
9305
0
1161
20
0
0
434
0
0
10
148865
310
0
10
0
0
110
39
0
2...

result:

ok 500000 numbers

Test #45:

score: 0
Accepted
time: 850ms
memory: 403152kb

input:

500000 500000
329990 315648 193373 111975 170580 58504 66741 136976 181004 137907 198526 379991 307332 12067 57541 312476 40354 459475 475352 186439 444675 440254 204455 155899 391500 304656 326450 32474 153364 358114 282200 224129 105353 362233 85911 388393 463992 276367 408049 280894 383894 363918...

output:

500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000
500000...

result:

ok 500000 numbers

Test #46:

score: 0
Accepted
time: 791ms
memory: 401240kb

input:

500000 500000
105921 139840 456356 66064 2851 291968 308994 310966 472953 285633 179945 313950 13044 325312 71714 136535 16 244865 255246 19 36856 27289 84105 498020 427362 328068 297398 486080 445601 308695 30 116868 493292 440830 322240 409159 304319 236722 61199 63772 175351 477813 380606 318946 ...

output:

379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425
379425...

result:

ok 500000 numbers

Test #47:

score: 0
Accepted
time: 814ms
memory: 401244kb

input:

500000 500000
397624 356410 35942 369216 304544 6512 492855 321875 103422 154845 210127 362949 293145 13 223535 331228 193524 306819 33717 28585 446930 190876 343274 324850 478904 245126 73783 94761 343260 81113 436740 158222 221706 487299 202413 328399 388188 88637 38 211716 99158 140237 428340 537...

output:

365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352
365352...

result:

ok 500000 numbers

Test #48:

score: 0
Accepted
time: 825ms
memory: 399768kb

input:

500000 500000
343257 48488 204247 3 387131 361723 291945 242777 263456 119458 211800 372184 15042 73534 140501 179172 16 218129 84161 20758 267643 21 22 499197 36506 298388 225662 438963 387828 387300 409578 293246 17214 119377 148795 343562 384377 441647 38 142049 437440 153856 428391 201281 259845...

output:

287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435
287435...

result:

ok 500000 numbers

Test #49:

score: 0
Accepted
time: 830ms
memory: 399692kb

input:

500000 500000
235143 96513 216446 10183 498551 35457 439109 357907 280559 397827 453658 149627 340846 437353 399656 248964 338064 185070 105612 38368 293858 302319 490854 218507 320005 203150 299446 104287 427442 387135 493792 20188 141105 224384 296868 99392 398783 231325 57572 119160 253437 296356...

output:

286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873
286873...

result:

ok 500000 numbers

Test #50:

score: 0
Accepted
time: 788ms
memory: 400244kb

input:

500000 500000
11814 199007 35904 421399 230588 5 15523 38493 60725 233408 260229 75466 127301 497947 14 15 9386 354718 132587 274932 391390 496870 52122 63711 426529 346820 214963 361116 191510 58808 344755 153908 275302 33 111347 2924 109443 37 439151 219591 240578 180618 410534 214975 349767 23929...

output:

309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058
309058...

result:

ok 500000 numbers

Extra Test:

score: 0
Extra Test Passed