QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#56910#4814. Exciting TravelKING_UT#AC ✓624ms186968kbC++205.9kb2022-10-21 21:16:052022-10-21 21:16:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-21 21:16:06]
  • 评测
  • 测评结果:AC
  • 用时:624ms
  • 内存:186968kb
  • [2022-10-21 21:16:05]
  • 提交

answer

#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 bg begin()
#define ed end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.bg,x.ed
#define si(x) (int)x.size()

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

template<class t,class u>bool chmin(t&a,u b){
	if(a>b){a=b;return true;}
	else return false;
}
template<class t,class u>bool chmax(t&a,u b){
	if(a<b){a=b;return true;}
	else return false;
}
template<class t>using vc=vector<t>;
template<class t>using vvc=vector<vector<t>>;
using vi=vc<int>;
using pi=pair<int,int>;
#define a first
#define b second

template<class E>
struct HLD{
	vvc<E>g;
	int n,rt,cnt;
	vi sub,in,out,par,head,dep,hei,ni;
	vvc<E>bin;
	vc<E>pe;
	int dfs1(int v,int p,int d){
		par[v]=p;
		dep[v]=d;
		for(auto itr=g[v].begin();itr!=g[v].end();itr++)
			if(*itr==p){
				pe[v]=*itr;
				g[v].erase(itr);
				break;
			}
		for(auto &e:g[v]){
			pe[e]=e;
			sub[v]+=dfs1(e,v,d+1);
			if(sub[g[v][0]]<sub[e]) swap(g[v][0],e);
		}
		return sub[v];
	}
	void dfs2(int v,int h){
		in[v]=cnt++;
		head[v]=h;
		for(auto to:g[v])
			dfs2(to,to==g[v][0]?h:to);
		out[v]=cnt;
		if(si(g[v])) hei[v]=hei[g[v][0]]+1;
	}
	HLD(){}
	HLD(const vvc<E>&gg,int rr):g(gg),n(g.size()),rt(rr),cnt(0),
		sub(n,1),in(n),out(n),par(n,-1),head(n),dep(n),hei(n,1),ni(n),
		pe(n){
			dfs1(rt,-1,0);
			dfs2(rt,rt);
			rep(i,n)ni[in[i]]=i;
			bin.resize(20);
			bin[0] = par;
			rep(j, 19){
				bin[j+1].resize(n);
				rep(i, n){
					if(bin[j][i]==-1) bin[j+1][i]=-1;
					else bin[j+1][i]=bin[j][bin[j][i]];
				}
			}
	}
	int up(int v,int a){
		rep(j, 20){
			if(((a>>j)&1)) v = bin[j][v];
		}
		return v;
	}
	int lca(int a,int b){
		while(head[a]!=head[b]){
			if(dep[head[a]]>dep[head[b]]){
				swap(a,b);
			}
			b=par[head[b]];
		}
		if(dep[a]>dep[b]) swap(a,b);
		return a;
	}
	int len(int a,int b){
		return dep[a]+dep[b]-dep[lca(a,b)]*2;
	}
	bool asde(int a,int b){
		return in[a]<=in[b] and out[b]<=out[a];
	}
	
	vi index;
	pair<vi,vc<pi>>tree_compress(vi vs){
		if(index.size()==0) index.resize(n);
		auto comp=[&](int x,int y){
			return in[x]<in[y];
		};
		sort(vs.begin(), vs.end(), comp);
		vs.erase(unique(vs.begin(), vs.end()),vs.end());
		int k=vs.size();
		rep(i,k-1){
			vs.pb(lca(vs[i],vs[i+1]));
		}
		sort(vs.begin(), vs.end(), comp);
		vs.erase(unique(vs.begin(), vs.end()),vs.end());
		k=vs.size();
		rep(i,k)index[vs[i]]=i;
		vc<pi>es;
		rng(i,1,k){
			int p=lca(vs[i-1],vs[i]);
			es.eb(i,index[p]);
		}
		return mp(vs, es);
	}
};
struct BIT{
	vc<int>b;
	int sz;
	void init(int a){
		sz = a+3;
		b.clear();
		b.assign(sz, 0);
	}
	void add(int i, int v){
		i ++;
		for(;i<sz;i+=i&-i) b[i] += v;
	}
	int sum(int i){
		i ++;
		int ret=0;
		for(;i;i-=i&-i) ret += b[i];
		return ret;
	}
}bit;
using P=pi;
int sol(vc<int>A, vc<int>info, vc<pi>edge){
	unordered_map<int,int>M;
	rep(i, A.size()){
		M[A[i]] = i;
	}
	int n = A.size();
	vc<int>imp(n);
	for(auto v:info) imp[M[v]] = 1;
	
	vvc<int>g; g.resize(n);
	for(auto uv:edge){
		g[uv.a].pb(uv.b);
		g[uv.b].pb(uv.a);
	}
	HLD<int>h2(g, 0);
	vc<int>sum2(n);
	auto dfs0=[&](int v,int u,auto dfs0)->void{
		sum2[v] += imp[v];
		for(auto to:g[v]){
			if(to==u)continue;
			sum2[to] = sum2[v];
			dfs0(to,v,dfs0);
		}
	};
	dfs0(0,-1,dfs0);
	//for(auto x:A) cout << x << " "; cout << endl;
	//for(auto x:info) cout << x << " "; cout << endl;
	//for(auto x:edge) cout << x.a << " " << x.b << endl;
	//rep(i, n) cout << sum2[i] << " "; cout << endl;
	vvc<P>q; q.resize(n);
	int pre=0;
	rng(i, 1, info.size()){
		int u = M[info[i-1]];
		int v = M[info[i]];
		int w = h2.lca(u, v);
		if(sum2[u]+sum2[v]-sum2[w]*2+imp[w] != 2) continue;
		//cerr<<info[i-1]<<" "<<info[i]<<endl;
		int L = h2.len(u, v);
			
			if(L == 1) pre++;
			else if(L == 2){
				int mid;
				if(u != w) mid=(h2.up(u, 1));
				else mid=(h2.up(v, 1));
				q[mid].eb(mid, mid);
			}
			else{
				int mid1, mid2;
				if(u != w) mid1=(h2.up(u, 1));
				else mid1=(h2.up(v, L-1));
				
				if(v != w) mid2=(h2.up(v, 1));
				else mid2=(h2.up(u, L-1));
				
				q[h2.lca(mid1, mid2)].eb(mid1, mid2);
			}
	}
	bit.init(n+1);
	vc<int>sum(n), dp(n);
	
	
	auto dfs=[&](int v, int u, auto dfs) -> void{
		for(auto to:g[v]){
			if(to == u) continue;
			dfs(to, v, dfs);
			sum[v] += dp[to];
		}
		dp[v] = sum[v];
		for(auto edd:q[v]){
			int tmp=1;
			int x[2]={edd.a, edd.b};
			rep(_, 2){
				int p = x[_];
				if(p == v) continue;
				int L = h2.len(p, v);
				int ch = h2.up(p, L-1);
				tmp += sum[ch]-dp[ch];
				if(L > 1){
					tmp += bit.sum(h2.in[p]);
					tmp -= bit.sum(h2.in[ch]);
				}
			}
			if(dp[v] < sum[v]+tmp) dp[v] = sum[v]+tmp;
		}
		bit.add(h2.in[v], sum[v]-dp[v]);
		bit.add(h2.out[v], dp[v]-sum[v]);
	};
	dfs(0, -1, dfs);
	return dp[0]+pre;
}
void slv(){
	int n,m;
	cin>>n>>m;
	vvc<int>g; g.resize(n);
	rep(i,n-1){
		int u,v;cin>>u>>v;
		u--; v--;
		g[u].pb(v);
		g[v].pb(u);
	}
	HLD<int>h1(g, 0);
	
	rep(_, m){
		int k; cin >> k;
		vc<int>vec(k);
		rep(i, k) cin >> vec[i];
		if(k <= 2){
			cout << 0 << '\n';
			continue;
		}
		rep(i, k) vec[i]--;
		vc<int>A = vec;
		rep(i, k-1){
			int u = vec[i];
			int v = vec[i+1];
			int L = h1.len(u, v);
			
			if(L == 1) continue;
			else if(L == 2){
				int w = h1.lca(u, v);
				if(u != w) A.pb(h1.up(u, 1));
				else A.pb(h1.up(v, 1));
			}
			else{
				int w = h1.lca(u, v);
				if(u != w) A.pb(h1.up(u, 1));
				else A.pb(h1.up(v, L-1));
				//cout<<u<<" "<<v<<endl;
				//cout<<A.back()<<" ";
				
				if(v != w) A.pb(h1.up(v, 1));
				else A.pb(h1.up(u, L-1));
				//cout<<A.back()<<endl;
				//cout<<"_____"<<endl;
			}
		}
		//for(auto a:A) cout<<a<<" ";cout<<endl;
		auto ret = h1.tree_compress(A);
		//for(auto a:ret.a) cout<<a<<" ";cout<<endl;
		//for(auto b:ret.b) cout<<b.a<<" "<<b.b<<endl;
		cout << k-1-sol(ret.a, vec, ret.b) << '\n';
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int t;t=1;//cin>>t;
	while(t--) slv();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3612kb

input:

5 3
1 2
1 3
2 4
2 5
3 1 4 5
4 1 2 4 3
4 2 4 5 1

output:

1
1
2

result:

ok 3 number(s): "1 1 2"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3696kb

input:

8 7
1 2
1 3
1 4
2 5
2 6
5 7
3 8
1 4
2 1 7
3 5 2 4
4 3 6 1 4
6 5 3 7 1 2 4
6 4 8 3 5 6 1
7 2 8 5 4 6 1 3

output:

0
0
0
1
4
3
5

result:

ok 7 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

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

output:

0
0
3
2
0
1
0
1
0
1

result:

ok 10 numbers

Test #4:

score: 0
Accepted
time: 2ms
memory: 3612kb

input:

1 1
1 1

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 2ms
memory: 3536kb

input:

1 0

output:


result:

ok 0 number(s): ""

Test #6:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

20 15
9 4
3 9
10 9
7 14
2 1
16 13
15 20
6 1
8 11
18 19
20 3
12 7
9 17
7 13
8 5
19 20
10 12
1 8
9 8
3 8 12 15
2 5 4
6 17 4 8 7 5 18
1 7
1 18
2 2 20
5 13 6 5 15 17
1 6
1 9
7 4 15 3 2 9 5 13
2 16 18
2 2 6
2 5 17
8 1 11 8 12 9 18 13 17
7 5 6 13 1 11 18 9

output:

1
0
4
0
0
0
2
0
0
4
0
0
0
4
4

result:

ok 15 numbers

Test #7:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

20 15
15 2
4 12
6 3
20 16
7 15
6 14
13 10
11 20
3 9
13 4
5 19
1 14
5 7
18 9
18 8
17 12
8 2
11 19
17 1
2 3 11
5 9 11 14 20 3
4 9 11 13 4
6 18 6 5 16 7 17
2 2 14
1 11
2 9 3
1 10
2 17 8
1 8
1 16
6 13 17 10 2 4 3
7 2 3 7 6 15 9 17
3 14 3 10
7 9 19 4 2 20 8 11

output:

0
3
1
3
0
0
0
0
0
0
0
5
6
1
6

result:

ok 15 numbers

Test #8:

score: 0
Accepted
time: 2ms
memory: 3700kb

input:

20 15
9 5
5 7
5 13
5 10
5 19
17 5
5 2
5 3
16 5
5 11
5 1
8 5
5 18
15 5
5 20
4 5
5 12
5 6
14 5
3 4 13 7
3 8 6 5
1 12
4 3 19 20 6
8 14 7 19 17 18 12 13 11
5 13 15 10 2 1
2 10 4
1 18
1 2
1 6
9 7 18 9 8 16 3 1 10 14
2 2 15
2 2 20
7 4 13 15 7 3 9 14
1 19

output:

1
1
0
2
6
3
0
0
0
0
7
0
0
5
0

result:

ok 15 numbers

Test #9:

score: 0
Accepted
time: 8ms
memory: 4136kb

input:

1000 500
685 415
28 527
771 396
201 538
604 162
631 66
144 596
788 378
919 59
737 550
471 413
3 590
891 52
886 705
350 238
164 224
554 358
909 150
354 441
310 756
380 661
380 867
601 318
197 204
993 673
118 624
249 539
841 737
742 853
250 566
543 663
981 243
60 120
976 801
750 2
694 8
935 831
381 48...

output:

0
3
0
3
4
2
2
0
2
0
4
0
1
4
5
2
0
12
0
14
3
3
5
3
0
0
2
0
4
9
5
5
1
0
40
12
0
18
4
1
1
6
0
7
3
0
0
14
5
1
3
8
5
0
4
0
5
7
2
5
6
0
5
0
1
2
7
3
0
0
6
0
1
8
4
1
11
0
1
0
8
3
2
0
1
2
0
3
9
5
13
2
0
4
2
0
4
1
14
1
4
4
4
0
1
1
10
2
2
0
0
4
10
2
3
10
4
0
13
6
0
19
3
4
9
2
10
6
1
0
0
3
0
0
6
12
5
2
2
1
9
15...

result:

ok 500 numbers

Test #10:

score: 0
Accepted
time: 7ms
memory: 4168kb

input:

1000 500
657 521
621 14
522 258
78 524
221 712
607 614
270 378
307 865
702 869
336 541
649 488
606 807
272 312
152 213
931 861
442 227
3 298
700 757
74 634
829 765
670 748
532 283
398 90
626 913
610 879
340 850
183 369
326 877
872 809
684 303
574 161
798 339
803 842
182 571
585 732
262 859
851 515
7...

output:

0
1
9
0
7
3
0
0
1
6
0
0
1
7
13
17
10
6
4
1
1
6
2
0
2
2
0
6
0
3
0
9
14
1
7
4
1
1
17
12
1
4
4
5
1
5
0
1
2
8
5
7
3
0
3
0
0
17
11
6
13
0
2
5
8
5
0
3
0
7
5
0
0
2
0
1
1
1
6
10
2
3
2
10
1
0
16
1
4
0
28
0
1
0
6
0
2
0
0
0
2
1
4
1
6
6
1
0
6
1
0
5
0
0
1
4
0
3
0
1
12
2
2
7
0
5
0
0
5
2
5
0
0
0
2
0
0
1
9
4
0
1
9
...

result:

ok 500 numbers

Test #11:

score: 0
Accepted
time: 5ms
memory: 4140kb

input:

1000 500
642 460
642 15
642 123
415 642
642 302
402 642
596 642
139 642
449 642
715 642
642 377
642 622
718 642
642 172
262 642
240 642
642 872
256 642
642 403
642 486
227 642
642 708
642 907
113 642
642 400
829 642
642 430
142 642
765 642
219 642
470 642
744 642
642 871
30 642
642 282
422 642
623 6...

output:

0
0
1
0
2
0
9
1
0
0
3
16
5
11
0
3
1
7
2
4
5
0
2
1
0
8
1
27
1
2
2
2
8
1
5
0
2
13
1
1
3
8
7
7
23
9
3
1
10
2
1
4
0
7
0
2
2
2
0
5
1
4
15
3
4
0
3
0
6
0
0
0
0
0
1
0
4
1
1
1
0
9
6
1
8
1
8
0
0
5
6
3
0
8
2
4
13
15
6
2
10
0
1
19
2
11
0
4
0
6
10
0
0
6
2
7
2
0
21
11
0
3
2
8
0
4
0
0
0
8
0
1
7
8
0
1
0
0
8
20
3
0
...

result:

ok 500 numbers

Test #12:

score: 0
Accepted
time: 1ms
memory: 4140kb

input:

1000 500
268 91
243 255
301 436
34 358
177 16
819 174
305 923
256 126
803 359
603 677
302 485
801 546
79 963
873 946
163 496
893 771
521 23
820 389
344 700
442 824
16 222
166 820
364 678
853 173
389 917
36 303
987 560
388 284
191 904
268 629
193 572
956 945
783 520
899 763
514 245
991 477
937 239
64...

output:

1
0
2
7
1
0
16
0
15
5
0
12
0
9
0
2
1
12
0
0
5
2
49
0
10
0
2
1
0
10
0
0
0
0
6
11
0
8
6
10
0
3
0
11
2
1
0
9
2
17
13
0
8
22
0
3
0
4
4
0
3
4
3
11
3
11
0
0
1
7
0
31
17
0
2
5
0
8
1
1
1
0
0
5
2
1
2
3
8
2
0
3
5
14
1
0
2
6
4
0
5
0
5
1
0
1
0
0
9
4
0
0
1
6
0
0
0
3
0
0
1
4
2
0
23
3
10
1
3
2
1
2
0
1
11
5
0
0
2
1...

result:

ok 500 numbers

Test #13:

score: 0
Accepted
time: 456ms
memory: 73784kb

input:

200000 50000
147950 15945
149717 150569
30462 116515
142211 168449
44972 135361
21861 103991
37557 168992
94504 141877
53485 104648
84171 32837
130622 2483
138672 112637
194683 83812
90100 176078
199978 53056
51731 34853
137794 56530
52239 113059
162164 35256
198068 150417
26594 32585
107974 138107
...

output:

2
1
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
1
1
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
1
2
2
1
2
2
2
2
2
2
2
1
2
1
2
1
2
2
2
1
2
2
1
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
...

result:

ok 50000 numbers

Test #14:

score: 0
Accepted
time: 473ms
memory: 81968kb

input:

200000 50000
4811 60211
95575 160129
138184 64563
138116 197359
53442 183022
142196 135886
169808 32999
1999 45672
167913 175643
163979 101364
169618 146361
39179 182715
39391 11371
199130 118010
85906 185921
157037 197011
61860 175542
146096 128125
119551 178637
100519 198702
142757 53620
22964 110...

output:

2
2
2
1
3
2
1
1
3
1
1
2
2
2
1
1
1
2
2
2
1
1
2
1
2
1
1
1
3
0
1
1
1
2
2
1
2
3
2
2
1
1
1
2
2
1
1
1
1
1
2
2
1
1
0
2
1
1
1
1
2
0
1
2
1
1
2
1
2
0
2
2
2
2
1
2
2
1
2
2
1
1
2
1
2
2
1
2
2
1
0
2
1
1
2
2
0
3
1
2
1
0
1
1
2
1
1
1
1
2
2
1
2
2
1
3
2
1
1
2
1
2
1
1
2
2
0
1
0
2
1
1
3
2
1
1
0
2
1
2
1
2
2
2
0
2
0
2
1
1
...

result:

ok 50000 numbers

Test #15:

score: 0
Accepted
time: 276ms
memory: 75304kb

input:

200000 50000
52483 73090
73090 145935
73090 12985
73090 86027
120165 73090
73090 61597
147909 73090
170994 73090
149256 73090
73090 133546
73090 78676
73090 128764
162457 73090
166053 73090
133898 73090
40886 73090
73090 59853
170785 73090
108157 73090
184838 73090
73090 134616
70601 73090
197430 73...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 50000 numbers

Test #16:

score: 0
Accepted
time: 464ms
memory: 73404kb

input:

200000 50000
26554 65670
114192 53247
90012 143559
134515 140602
19093 33792
16797 163592
124949 61078
51555 104029
167967 65587
140820 98790
17361 12159
165668 150169
17361 161909
74558 85589
108905 72582
189381 5510
127628 182034
29242 2503
71742 184644
113510 129355
47412 48972
122544 117112
9773...

output:

2
2
1
1
1
1
2
2
2
2
1
2
2
2
2
2
2
1
2
1
2
2
2
2
2
1
2
2
2
2
1
1
1
1
2
2
1
2
2
2
1
2
1
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
1
1
1
1
2
1
2
2
1
2
2
2
1
2
1
1
2
2
2
2
2
2
2
2
1
2
1
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
...

result:

ok 50000 numbers

Test #17:

score: 0
Accepted
time: 472ms
memory: 73420kb

input:

200000 50000
5445 165553
22341 93180
117922 55804
6312 113304
131503 40174
39253 156532
106765 110703
73244 185308
165404 136346
19524 136142
170370 142895
79779 101154
57499 8213
197134 120856
127746 107919
148508 165203
185078 130644
127074 89570
186391 164366
92705 183208
166377 2791
85215 145260...

output:

1
1
2
1
1
1
1
1
2
2
1
2
1
2
2
2
2
2
1
2
2
2
2
2
2
1
2
1
2
2
1
1
2
2
2
2
2
1
1
2
1
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
1
2
1
2
2
1
2
2
1
1
2
2
2
2
1
2
2
2
1
1
1
2
2
2
1
1
1
2
2
2
2
2
1
1
2
2
1
2
2
2
2
2
2
1
2
1
1
2
1
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
1
2
1
1
1
2
2
2
2
1
2
1
2
2
1
2
1
2
2
1
1
2
2
2
2
2
1
2
2
2
...

result:

ok 50000 numbers

Test #18:

score: 0
Accepted
time: 451ms
memory: 73244kb

input:

200000 50000
116507 155355
169421 109364
194658 3769
48639 167138
115913 110543
123887 179259
159321 157494
51526 128930
52244 129646
72962 148714
110437 181134
162273 127279
66365 115814
91931 126784
73438 166734
34918 50988
14240 73168
128846 46564
155279 142384
132938 135295
17473 66904
3257 1394...

output:

2
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
1
2
1
2
2
2
2
2
1
2
2
1
2
2
1
2
2
2
1
2
1
1
2
1
2
1
2
2
1
2
1
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
1
1
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
1
2
2
1
2
1
1
1
1
1
2
2
1
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
1
2
2
1
1
2
2
2
2
...

result:

ok 50000 numbers

Test #19:

score: 0
Accepted
time: 461ms
memory: 73176kb

input:

200000 50000
13008 171487
72204 166466
95717 15819
166481 50152
159788 89994
59960 180965
18114 95123
133784 3257
95904 196017
112209 135567
49071 125191
12429 77842
129591 133755
72002 138790
90414 116384
108561 158985
51950 135139
115795 136184
131380 156529
56978 137754
24157 140928
192257 129034...

output:

2
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
1
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
1
2
2
2
2
2
1
1
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
1
1
2
2
1
2
2
2
2
1
2
...

result:

ok 50000 numbers

Test #20:

score: 0
Accepted
time: 462ms
memory: 73276kb

input:

200000 50000
198490 158046
189328 38121
158336 59857
114063 88850
27399 11117
121196 184826
131868 5515
178684 111624
139308 120029
198707 178083
187231 122277
198999 18650
174953 107983
127742 109719
79455 126661
55279 89218
109928 147298
6419 177741
183314 20140
93108 83824
182869 55777
43742 1736...

output:

1
1
2
2
2
2
2
1
1
1
2
2
2
1
1
2
1
2
2
2
1
1
2
2
1
2
2
1
2
2
1
2
2
2
2
1
1
2
2
2
1
2
2
2
1
2
2
1
2
1
1
2
1
2
2
2
2
1
1
1
2
1
1
2
1
2
2
1
2
2
2
2
2
2
2
1
1
2
2
2
1
1
1
2
2
1
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
1
1
1
1
2
...

result:

ok 50000 numbers

Test #21:

score: 0
Accepted
time: 342ms
memory: 73544kb

input:

200000 50000
90012 21073
121734 63025
128352 21073
137695 21073
21073 92614
70855 8404
60441 21073
21073 127975
133170 58661
76785 119125
67522 149927
68554 21073
53500 12136
21073 87127
21073 99567
45535 39272
61188 172904
3207 21073
117437 21073
21073 41691
74889 13877
42332 101117
109824 21073
16...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 50000 numbers

Test #22:

score: 0
Accepted
time: 377ms
memory: 73432kb

input:

200000 50000
53866 155577
166014 76224
15838 28239
131571 45042
131152 8372
154283 73067
162231 169431
131571 69752
85086 60480
194347 185654
82179 10712
34510 24223
117419 116822
84333 153650
144517 116607
13985 11939
104703 155751
118523 131571
104354 124348
154272 60994
46714 160107
193961 14996
...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 50000 numbers

Test #23:

score: 0
Accepted
time: 464ms
memory: 73508kb

input:

200000 50000
189790 113744
177500 114364
70171 133468
81418 27499
165783 75803
20458 34299
54417 39349
32538 58072
92402 95897
40511 171173
198010 159222
40565 178746
33125 12307
15180 188899
75787 131603
114081 165811
112057 191539
66009 125664
78948 99719
5687 51868
188707 26396
187321 24449
10332...

output:

2
2
2
2
2
1
2
1
2
2
2
2
2
2
1
2
2
1
1
2
1
2
2
1
1
2
1
2
2
2
2
1
2
1
1
2
2
2
2
2
1
1
2
2
1
1
1
2
1
2
2
1
2
1
2
1
2
2
2
2
1
2
2
2
1
1
2
2
2
2
2
2
1
2
2
1
2
2
1
1
2
2
2
2
2
2
1
2
2
2
2
2
1
1
2
1
2
2
2
2
2
1
2
2
2
1
2
1
2
2
2
2
1
1
1
1
2
2
2
2
2
2
1
2
2
2
2
1
2
1
2
1
1
1
1
2
2
1
1
2
2
2
2
2
1
1
2
2
2
2
...

result:

ok 50000 numbers

Test #24:

score: 0
Accepted
time: 441ms
memory: 72204kb

input:

200000 50000
81755 83590
98743 86354
194551 127020
117373 98797
187890 134843
19563 98680
73465 174363
57587 68454
147796 21665
143783 169657
121846 169327
18264 132228
88727 42499
50670 148780
127013 80921
102029 132244
133669 42963
95905 174351
29614 134145
61649 16531
56803 101304
5893 174789
326...

output:

2
2
2
2
2
2
2
1
2
2
1
1
2
1
1
1
2
1
2
2
2
1
1
2
2
2
2
1
2
2
2
1
1
2
2
2
2
1
1
1
2
2
2
1
2
1
1
2
2
2
2
1
2
2
2
2
2
1
1
1
1
2
2
1
2
2
1
1
2
2
2
2
1
2
2
1
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
1
2
2
2
1
2
1
1
1
1
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
1
2
2
1
2
2
1
2
2
2
...

result:

ok 50000 numbers

Test #25:

score: 0
Accepted
time: 495ms
memory: 73604kb

input:

200000 50000
103078 104769
23069 178982
27566 176520
179388 84112
120863 28297
76085 29909
8957 70003
55204 101337
49121 88427
152433 173149
199707 72730
140850 97032
6713 184719
144990 191914
63241 199408
187400 153709
36014 28088
81504 125774
155289 31911
145372 65285
165503 194470
114431 81780
16...

output:

0
2
4
5
0
0
1
0
0
0
0
1
3
1
7
0
1
0
0
4
6
4
0
1
0
3
4
0
7
1
1
0
5
4
1
0
0
2
0
0
6
7
0
5
6
2
0
1
0
3
1
6
0
1
2
1
3
2
0
0
2
0
1
0
0
7
0
0
0
5
0
4
0
2
2
1
0
2
0
2
5
6
0
1
2
2
1
0
0
0
0
0
0
8
3
4
3
4
3
6
1
0
1
4
5
0
0
1
0
0
1
0
1
1
6
1
2
2
0
3
3
0
0
2
1
1
6
0
1
0
0
4
7
0
5
5
0
0
1
2
3
4
3
3
0
0
0
1
0
7
...

result:

ok 50000 numbers

Test #26:

score: 0
Accepted
time: 515ms
memory: 73496kb

input:

200000 50000
191711 75532
98477 18779
53506 82095
100296 41647
118787 98825
165946 198342
54459 52553
60653 86055
1061 148241
171257 68646
108729 96211
86181 99518
8019 81771
92166 38746
71069 179382
100465 150737
148355 24844
58221 142266
196563 85048
199130 21139
102514 54080
71105 65835
23611 546...

output:

1
0
1
1
2
4
2
3
1
1
0
2
3
4
2
3
0
6
4
0
4
1
0
1
0
4
0
0
0
2
1
0
1
5
0
4
0
0
12
1
0
6
0
5
0
9
1
11
0
6
0
0
4
0
3
0
0
0
0
0
0
1
0
2
2
11
8
1
0
6
12
1
0
1
0
0
0
0
0
1
0
0
0
1
7
4
0
0
1
1
0
1
0
4
0
1
4
4
4
8
3
8
0
0
4
0
1
0
4
0
0
0
0
0
2
2
0
2
0
7
5
0
2
0
3
5
1
1
3
4
0
1
0
0
1
1
0
0
2
0
3
2
1
0
4
0
5
0
...

result:

ok 50000 numbers

Test #27:

score: 0
Accepted
time: 502ms
memory: 74976kb

input:

200000 50000
78615 172355
44882 88913
28010 41995
125848 125040
137776 169739
110779 63253
58541 25510
142276 75368
142257 48615
34567 199392
192603 191684
158846 163511
72384 162697
120374 142508
160251 149053
7396 18634
152936 21360
125633 163806
100491 82593
7051 110833
11482 49975
79322 50547
17...

output:

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
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
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
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
0
0
0
0
0
0
...

result:

ok 50000 numbers

Test #28:

score: 0
Accepted
time: 524ms
memory: 77968kb

input:

200000 20000
187081 53216
27801 136192
32351 46643
176586 81207
185850 162070
162460 155325
160092 48942
131901 130156
146369 117446
199187 195282
23669 150337
129236 193877
91353 72955
9686 18436
146720 155346
37646 13572
173385 176008
175985 148135
193600 57208
160224 118579
56793 53023
151453 154...

output:

11
27
23
0
10
3
2
25
19
0
0
5
12
2
2
0
0
3
1
11
7
11
0
4
15
0
2
19
14
3
6
3
6
0
1
15
0
9
0
0
0
2
29
2
12
10
3
16
0
1
7
2
0
10
7
4
9
0
12
15
12
23
1
22
6
0
0
21
4
13
0
5
2
22
0
0
20
3
20
37
5
0
0
3
13
0
10
5
2
59
8
0
5
0
3
3
3
0
11
3
32
1
7
3
10
18
13
0
0
4
0
6
4
11
22
2
6
5
1
0
33
10
12
13
12
6
1
0
...

result:

ok 20000 numbers

Test #29:

score: 0
Accepted
time: 582ms
memory: 76128kb

input:

200000 1000
157814 76176
163268 122585
192377 164557
129453 165667
74839 146427
82784 142395
123407 174815
144696 54441
2131 104565
147121 184302
196346 142175
58806 109756
154937 199695
124738 20035
75421 48712
16732 186942
27821 88508
54472 58849
39521 171469
50589 10283
182786 170787
100465 10883...

output:

84
122
257
257
40
281
163
49
217
86
32
70
45
77
33
402
261
33
300
212
16
214
93
405
41
96
7
119
512
46
64
75
886
129
322
346
57
5
129
125
69
17
15
525
128
179
340
3
114
42
3
120
558
747
47
54
87
460
31
156
206
61
75
4
39
34
104
241
533
19
63
197
400
25
177
209
376
253
352
104
258
160
10
339
133
514
...

result:

ok 1000 numbers

Test #30:

score: 0
Accepted
time: 561ms
memory: 121232kb

input:

200000 1000
15404 111569
159096 20487
27188 26159
167294 134464
45245 139112
94373 116658
189991 93477
55292 199443
131733 113241
56244 27781
158253 2801
19829 94431
9404 172977
66320 59751
76426 14733
159388 600
66211 46736
125833 159897
188737 56963
101305 10749
122103 176016
79198 189834
183797 1...

output:

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
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
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
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
0
0
0
0
0
0
...

result:

ok 1000 numbers

Test #31:

score: 0
Accepted
time: 565ms
memory: 85552kb

input:

200000 100
84663 115265
112995 114610
18641 20088
65558 195755
108340 97536
178978 127340
165213 153673
22803 154445
123159 11456
142653 174962
25327 199632
55661 150660
199363 186244
77339 139111
83732 143586
107108 51233
168645 68627
113513 43221
134147 70344
106622 156969
155756 154961
107763 329...

output:

2271
3722
1439
1171
1786
758
988
8583
3340
2224
504
14
598
2958
5255
569
1468
4384
2427
2971
4543
1106
2751
1609
7114
401
9886
2285
5452
938
1540
697
331
579
179
2936
324
3074
3582
1656
41
2395
778
0
1172
1460
502
277
572
3051
686
325
644
4490
868
719
1527
363
874
296
83
2193
1436
3334
1956
2295
100...

result:

ok 100 numbers

Test #32:

score: 0
Accepted
time: 548ms
memory: 120336kb

input:

200000 10
96071 28937
24153 188910
19934 175826
39300 25581
189629 189943
132841 24758
103001 74915
183654 154510
93777 199687
100452 102904
102161 196416
157463 140717
83771 99158
116717 135599
142029 116398
65506 38973
96067 25930
1395 607
134055 63423
118378 87791
56140 128584
22905 67507
72414 1...

output:

6024
20927
22766
3735
27825
3563
1961
49994
39458
23589

result:

ok 10 numbers

Test #33:

score: 0
Accepted
time: 548ms
memory: 142908kb

input:

200000 10
170989 160272
8381 193314
184299 58073
74188 127765
154075 181410
152085 184304
123709 17212
159380 137049
145951 144824
35526 43998
182812 87980
82862 133993
55251 55215
58471 98545
162127 12672
171567 35901
141301 196583
72607 42930
65594 71156
162495 13724
111350 162442
176458 119914
35...

output:

29561
1693
12916
4986
1571
44982
1556
7060
6301
89179

result:

ok 10 numbers

Test #34:

score: 0
Accepted
time: 572ms
memory: 148860kb

input:

200000 3
48709 87519
125970 2495
194507 110556
82798 151089
146039 62184
98600 153085
69059 18470
175392 147856
32297 42181
174022 9923
120601 31984
45260 320
3430 140247
92160 81063
195060 132354
104245 160074
39494 37271
47115 178851
197301 35215
68912 187020
9877 32811
168070 151392
139877 32157
...

output:

44829
99996
55164

result:

ok 3 number(s): "44829 99996 55164"

Test #35:

score: 0
Accepted
time: 563ms
memory: 158384kb

input:

200000 2
65536 182236
101402 178765
67919 180432
8492 186129
7472 94981
123202 180057
114535 15287
97006 11052
137576 6035
132771 30919
191169 131133
2774 3722
71108 73875
5731 137709
127361 151827
69881 169699
84703 186320
106602 141067
103033 98091
727 134779
153140 146631
155519 112464
88460 1039...

output:

134016
65934

result:

ok 2 number(s): "134016 65934"

Test #36:

score: 0
Accepted
time: 568ms
memory: 186968kb

input:

200000 2
134409 188519
54494 1372
40040 14954
43524 69333
106863 20506
69385 8009
145785 16841
79430 24723
109859 132718
147451 57640
198081 127773
42276 159169
22616 44030
82493 89855
59214 18896
58967 68134
40272 35244
12462 47323
192717 49247
47642 49495
113716 92358
68831 52924
88722 10368
13730...

output:

123856
76140

result:

ok 2 number(s): "123856 76140"

Test #37:

score: 0
Accepted
time: 311ms
memory: 173624kb

input:

200000 2
40912 29460
154407 40912
167389 40912
59807 40912
125056 40912
40912 82932
131296 40912
40912 174606
45223 40912
178334 40912
40912 149347
40912 39750
40912 162427
113979 40912
40912 146284
70918 40912
179678 40912
40912 187639
153956 40912
24412 40912
40912 196534
40912 142857
135666 40912...

output:

175028
24967

result:

ok 2 number(s): "175028 24967"

Test #38:

score: 0
Accepted
time: 546ms
memory: 150208kb

input:

200000 2
127606 189384
153240 73932
187355 198529
53636 99790
24642 194520
57241 142349
107310 102408
76943 46988
140570 42651
38524 122329
59538 131020
157023 69581
2090 155184
56472 62708
168538 175376
144580 14246
35012 166944
96185 108689
42831 143681
125342 26190
158059 118241
153898 164203
953...

output:

96475
103512

result:

ok 2 number(s): "96475 103512"

Test #39:

score: 0
Accepted
time: 607ms
memory: 74376kb

input:

200000 10000
136095 15212
40964 15009
51516 185466
142180 42409
122988 77662
119374 33098
51979 145853
89035 33979
90832 182750
45891 165695
141092 174667
177145 88102
77944 75915
95515 135111
11320 12630
155492 51493
51914 58852
82666 150456
160917 5258
29274 16266
36293 35412
143324 56969
1283 185...

output:

10
7
13
0
1
2
10
11
10
3
23
31
12
6
10
12
17
0
4
0
5
32
25
6
0
0
8
22
30
5
3
46
3
9
0
23
16
19
15
26
22
16
1
5
21
40
28
5
0
4
15
18
18
1
0
7
94
5
27
10
1
18
8
5
8
5
32
46
16
3
61
21
18
1
11
17
0
21
13
30
13
13
47
26
21
13
10
4
7
5
13
26
10
5
3
0
84
10
0
1
83
20
8
14
9
32
20
6
10
14
2
24
3
1
5
16
6
1...

result:

ok 10000 numbers

Test #40:

score: 0
Accepted
time: 515ms
memory: 78876kb

input:

200000 10000
179775 106486
76647 119702
25867 5733
146528 56583
5486 150701
110285 9145
90261 198949
22543 191984
131164 12564
102233 2593
193006 62775
6305 1586
98872 129777
85763 170088
140443 8391
35362 124625
139423 86284
63727 186556
119521 92275
38775 24853
148104 107546
82187 113787
100997 10...

output:

8
9
29
0
65
3
13
17
8
2
17
11
16
17
0
8
41
3
23
8
0
7
13
3
29
14
15
39
0
14
0
62
6
0
23
10
21
5
22
7
0
17
36
5
7
17
2
11
8
9
22
70
40
39
50
9
83
55
29
11
5
23
3
12
1
58
3
30
2
1
12
1
18
3
7
24
23
6
7
11
37
99
40
0
6
2
2
14
0
1
51
14
5
0
11
9
17
35
1
39
75
8
52
15
4
9
16
0
7
15
0
7
35
8
25
27
26
19
5...

result:

ok 10000 numbers

Test #41:

score: 0
Accepted
time: 257ms
memory: 75512kb

input:

200000 10000
5650 90468
119140 90468
90468 126059
123291 90468
6897 90468
23689 90468
70279 90468
90468 31114
151761 90468
90468 196888
90468 83407
34698 90468
157671 90468
90468 96883
121549 90468
97603 90468
90468 36495
90468 42724
90468 110045
90468 10479
90468 13510
90468 5565
90468 187611
90468...

output:

50
2
5
11
24
6
0
1
11
50
12
10
9
5
23
0
20
56
0
15
23
27
16
29
3
21
2
23
19
10
76
9
5
3
11
2
0
14
15
18
44
13
0
10
0
4
0
7
36
38
9
42
1
2
0
54
13
22
7
5
29
15
0
1
24
5
1
7
59
9
13
49
34
42
21
10
9
0
3
28
9
12
0
12
12
38
22
12
51
24
4
14
16
0
1
31
35
2
102
9
41
6
10
6
3
4
12
0
9
6
20
15
5
0
8
13
21
6...

result:

ok 10000 numbers

Test #42:

score: 0
Accepted
time: 555ms
memory: 78836kb

input:

200000 10000
98229 90828
133813 104403
137950 32016
79878 26609
22405 3510
80618 197262
9766 146328
135380 113885
61938 43163
25625 147207
80519 70823
156186 121368
199174 58026
71386 179597
116234 104621
129480 98073
22547 153305
144764 45983
71772 73235
84341 88731
91902 165250
132782 38425
101618...

output:

14
16
17
15
2
11
29
10
2
44
13
25
3
26
22
2
18
58
34
5
41
4
27
9
0
3
25
16
23
40
24
16
12
30
5
2
1
6
73
7
16
1
19
0
30
15
21
3
5
24
6
36
14
23
0
1
7
15
22
14
60
35
14
8
4
31
6
0
0
27
13
1
3
44
19
3
1
5
22
24
22
3
57
12
19
41
34
17
24
2
11
0
29
24
2
4
40
19
7
19
2
4
2
5
24
2
15
2
8
0
3
15
14
7
2
9
0
...

result:

ok 10000 numbers

Test #43:

score: 0
Accepted
time: 531ms
memory: 74756kb

input:

200000 10000
189890 60883
31072 81475
65721 69251
30282 71203
104229 126821
21574 119795
23576 67962
141436 74582
99909 2338
52814 128669
54954 136712
17088 141283
119000 46951
105034 11551
13122 122732
46485 17690
11691 101605
108858 94726
100288 14917
176244 19756
7094 92595
42871 140598
174701 62...

output:

40
0
17
0
5
16
2
33
5
5
0
25
6
0
5
1
33
7
10
7
0
5
12
22
17
1
9
30
6
3
25
0
3
5
5
30
6
10
7
16
25
27
24
27
15
0
4
1
20
61
11
7
24
23
3
4
8
11
25
18
1
32
5
1
19
23
14
13
57
22
19
50
24
17
31
38
14
15
2
0
21
51
38
26
27
19
25
2
57
17
14
0
20
9
1
37
3
18
8
49
5
5
19
0
8
7
7
13
55
2
35
6
1
12
41
7
0
4
4...

result:

ok 10000 numbers

Test #44:

score: 0
Accepted
time: 575ms
memory: 74008kb

input:

200000 10000
87626 107036
132234 80295
193551 73232
109203 41551
183287 116770
79715 191483
120522 59896
54923 96677
70748 59969
131420 38415
77600 37946
171887 115359
169220 65501
172270 169374
182893 59629
65602 50890
13857 110462
61197 28919
136600 26688
22113 187538
50537 121785
149601 157028
63...

output:

3
13
0
5
0
1
12
0
1
2
28
8
18
0
11
20
0
9
2
24
16
8
7
20
11
21
5
5
44
31
8
2
0
14
14
13
17
30
14
8
0
0
13
15
4
2
6
8
11
21
22
41
3
50
7
57
3
10
7
33
4
0
10
0
3
34
19
24
9
20
12
4
15
5
2
1
13
1
17
13
0
30
0
22
20
14
3
44
18
31
0
12
65
22
28
31
1
14
10
4
13
27
12
6
3
39
1
3
6
49
0
44
10
3
6
23
3
1
8
3...

result:

ok 10000 numbers

Test #45:

score: 0
Accepted
time: 607ms
memory: 73964kb

input:

200000 10000
95720 173983
25001 8242
48036 114992
108176 165941
175649 72559
59741 159132
107283 61274
104305 97974
63448 174744
122445 12990
110374 10652
174926 50030
43394 39527
459 69648
200 122242
6349 72274
127684 94174
2097 132889
50623 168931
178597 136574
144735 114380
127423 196788
136845 1...

output:

7
28
1
11
42
5
8
22
7
15
7
2
14
24
86
3
2
7
2
2
3
0
20
28
11
5
2
21
8
4
18
6
3
25
12
1
20
72
2
2
11
44
22
0
3
12
5
36
5
4
42
1
31
0
1
8
18
0
43
6
3
37
0
86
16
3
25
37
2
1
7
73
13
25
37
0
7
1
25
23
11
9
1
15
0
0
10
54
6
19
19
11
3
30
0
3
12
7
50
27
28
59
9
29
9
5
21
12
33
1
5
18
2
4
5
81
6
6
7
12
10
...

result:

ok 10000 numbers

Test #46:

score: 0
Accepted
time: 610ms
memory: 73740kb

input:

200000 10000
189977 86773
21751 101168
112465 12156
73977 54482
137630 111355
48496 157765
177844 80555
138939 36399
189835 37285
31349 103958
189387 2534
166448 66481
146304 9410
188231 100097
7228 164973
73840 67934
2528 174103
189542 134113
128543 17857
116247 123860
60493 137845
60613 69898
8830...

output:

25
7
12
29
10
59
0
30
32
2
3
37
14
13
9
0
2
20
23
6
15
1
7
12
13
1
41
4
33
0
5
0
34
15
11
4
16
20
2
8
6
68
2
8
0
12
11
5
7
3
42
56
1
1
6
20
12
0
1
16
2
10
11
25
0
4
55
20
26
34
19
40
28
27
11
7
33
4
1
27
10
8
1
58
2
3
10
13
3
2
21
0
19
38
10
18
0
26
64
9
7
16
6
27
18
46
10
1
2
5
18
0
9
4
12
54
3
20
...

result:

ok 10000 numbers

Test #47:

score: 0
Accepted
time: 624ms
memory: 73760kb

input:

200000 10000
132372 123556
155402 186537
132219 137424
41069 44316
14748 143857
126532 146030
150090 154046
171746 86027
169370 191915
23451 21045
113532 165548
163903 104023
37571 39095
176158 107436
38449 162266
84891 6081
8824 23525
58425 199609
173391 88535
105921 199408
120413 15844
52600 70602...

output:

41
4
15
5
10
25
11
2
0
18
31
1
38
10
1
12
3
20
5
2
2
68
15
12
59
55
1
2
23
20
1
0
10
24
48
1
8
29
21
5
3
4
50
81
22
6
8
9
38
6
24
0
51
0
5
19
1
2
5
40
24
53
19
15
18
1
75
27
34
9
5
12
5
0
1
9
3
59
13
23
0
4
0
2
40
36
5
4
0
6
12
0
66
16
19
22
6
11
40
9
11
9
2
60
25
1
1
3
2
18
2
12
9
9
8
5
0
52
8
12
1...

result:

ok 10000 numbers

Test #48:

score: 0
Accepted
time: 397ms
memory: 74256kb

input:

200000 10000
66826 13651
87364 149665
31596 66148
197564 79099
129485 35312
35312 119828
35312 91192
67144 105509
35312 145167
42191 35312
145971 35312
35312 150821
31983 129676
35312 181278
191532 167200
45990 110544
35312 34687
69608 35312
40256 195991
50913 93204
61298 35312
171318 35312
35312 61...

output:

4
54
40
36
6
4
14
3
2
23
30
17
49
6
66
21
8
18
22
9
2
50
32
25
11
40
25
28
38
6
14
11
35
13
3
1
18
2
38
42
9
27
18
12
31
19
57
47
7
34
37
14
8
9
0
34
1
15
40
16
14
12
9
9
1
15
89
17
0
2
0
29
2
0
15
27
6
9
31
33
75
21
19
5
10
1
2
5
2
3
23
17
18
18
0
20
19
4
10
39
7
27
30
8
4
3
30
13
29
0
31
0
26
1
27...

result:

ok 10000 numbers

Test #49:

score: 0
Accepted
time: 425ms
memory: 74160kb

input:

200000 10000
66854 83329
143712 18709
21411 34520
124484 13174
141308 115368
18709 177712
4285 18709
51308 148934
135441 104889
41676 18709
49619 18709
42322 18709
175034 16543
27387 87204
70381 18709
195728 151400
95137 166839
162706 155746
79770 18709
168319 159396
137466 18709
62348 173790
58112 ...

output:

1
0
0
17
12
9
14
1
7
8
7
7
4
41
10
15
1
13
13
3
18
1
13
97
9
4
28
0
19
0
23
31
29
22
8
5
8
7
35
13
3
24
29
12
7
6
6
6
0
59
41
2
26
3
34
0
30
1
13
26
23
11
10
21
5
0
31
13
0
20
3
8
8
48
28
9
19
1
64
6
6
12
12
7
16
4
4
6
42
21
2
8
19
22
4
0
29
15
33
8
39
7
22
0
8
5
11
42
14
11
15
44
2
3
100
26
2
26
4
...

result:

ok 10000 numbers

Test #50:

score: 0
Accepted
time: 618ms
memory: 73972kb

input:

200000 10000
111994 37056
113765 41433
173532 72550
182546 125435
157383 88089
194025 132751
136772 85319
17413 67019
16553 103053
92981 107120
52887 106877
46608 35425
9314 94055
101532 115645
71150 81585
71421 197140
80469 133104
133159 85002
120482 171700
19987 111052
147051 153776
67413 93844
31...

output:

14
3
13
5
14
2
0
27
0
3
23
125
5
5
20
11
8
19
12
16
14
10
6
30
26
0
10
7
46
8
11
12
1
36
7
11
8
2
2
45
18
2
14
0
27
62
12
10
11
0
21
27
13
5
40
0
51
56
4
3
10
4
13
2
1
22
36
15
12
14
1
5
49
27
22
19
0
8
2
34
0
3
18
31
4
16
28
0
29
13
3
73
15
8
88
2
1
7
58
3
14
0
17
39
1
0
1
1
21
4
71
2
0
38
25
22
10...

result:

ok 10000 numbers

Test #51:

score: 0
Accepted
time: 541ms
memory: 72824kb

input:

200000 10000
182873 199868
186617 17640
57478 169971
42699 38389
199878 58985
123622 148591
136402 137626
101551 67020
125817 156900
14286 157341
35951 171367
106632 171741
193352 53887
57032 30266
61677 82838
38417 166118
112907 76424
65861 118169
45390 163688
2555 169338
78827 123528
179261 71698
...

output:

2
23
5
31
11
10
7
14
2
63
9
10
13
26
20
11
8
48
9
0
0
3
3
0
3
5
11
14
63
0
14
11
15
3
10
32
1
18
0
1
1
3
26
17
2
24
45
6
5
21
2
24
29
17
8
8
0
36
9
8
19
43
11
3
84
17
15
51
2
38
25
13
7
5
4
13
16
1
33
8
17
2
0
8
32
1
11
15
33
2
1
11
33
35
53
3
0
11
9
2
65
1
54
6
18
4
19
3
4
22
9
5
4
55
36
1
47
21
0
...

result:

ok 10000 numbers

Test #52:

score: 0
Accepted
time: 590ms
memory: 75728kb

input:

200000 1000
134638 198558
160392 110585
64041 179854
24544 116761
4590 53878
111147 157540
9357 152751
98197 187330
190770 197803
114675 109927
174350 83009
77867 191291
177795 110757
92342 20425
31694 22637
5993 198570
142018 80989
27644 102755
150357 36044
188350 121687
171532 166653
166210 132840...

output:

33
288
167
35
296
133
107
69
175
68
0
5
61
264
226
394
60
245
148
116
159
554
108
112
61
95
34
99
110
161
216
29
258
23
9
3
92
21
80
203
146
304
10
174
91
38
112
37
107
116
178
7
11
218
528
79
35
19
354
41
110
39
35
158
26
386
75
731
408
373
32
675
9
96
163
46
60
5
374
23
273
485
193
336
152
51
29
1...

result:

ok 1000 numbers

Test #53:

score: 0
Accepted
time: 487ms
memory: 81360kb

input:

200000 1000
34675 21347
23115 72667
76741 20685
187322 60496
5734 25188
142030 22020
135299 149755
192246 176877
75319 54553
166535 181141
113713 25076
11456 105482
171352 148174
5342 76223
95180 182916
152584 194968
168550 76890
168284 111406
121929 90298
34411 104384
150686 144942
3344 126114
1094...

output:

316
167
61
24
731
1
93
154
101
24
75
158
518
173
412
4
437
100
121
108
22
89
12
84
218
46
637
7
118
161
184
12
322
32
237
128
284
161
879
192
149
259
329
257
147
328
132
551
278
34
103
174
74
237
201
81
166
102
300
144
143
19
122
33
236
189
57
45
425
389
88
230
6
38
381
206
6
199
447
17
123
230
52
9...

result:

ok 1000 numbers

Test #54:

score: 0
Accepted
time: 233ms
memory: 76348kb

input:

200000 1000
47020 115869
184301 115869
115869 93888
77412 115869
115869 167091
115869 51786
115869 18193
115869 97243
115869 141865
144469 115869
115869 102703
109855 115869
115869 105348
115869 136930
20019 115869
62522 115869
172472 115869
146745 115869
115869 37202
5728 115869
115869 93564
168883...

output:

168
546
218
251
347
32
194
117
36
266
719
238
81
472
253
165
181
26
93
30
379
50
120
88
193
141
424
49
410
338
117
12
145
252
57
301
227
366
459
115
277
37
210
44
146
183
50
110
129
330
104
256
139
155
114
48
321
19
245
289
13
208
156
500
19
210
526
249
2
15
310
0
15
182
80
16
53
114
8
145
192
60
23...

result:

ok 1000 numbers

Test #55:

score: 0
Accepted
time: 494ms
memory: 78008kb

input:

200000 1000
42672 33538
47785 17532
30340 143524
78501 103434
122207 31269
113714 162908
20573 13157
10315 166947
69373 11118
191714 164421
53110 9938
108476 156827
143615 107024
53542 182996
22646 78946
32314 65944
147138 27482
138223 162571
118331 110564
104656 117173
1516 189553
83096 22882
10232...

output:

638
247
346
110
146
849
151
115
69
293
441
21
23
56
124
197
217
6
79
28
66
112
106
251
122
3
563
131
133
279
74
18
552
185
109
163
70
29
206
253
229
14
62
160
143
18
235
60
7
91
14
106
31
35
300
449
219
17
2
87
61
224
151
110
244
21
75
80
74
168
201
205
1475
2
25
7
0
8
114
0
89
509
458
12
208
19
465...

result:

ok 1000 numbers

Test #56:

score: 0
Accepted
time: 508ms
memory: 76524kb

input:

200000 1000
162640 127690
157602 103266
164464 184240
41917 156832
59540 52651
24344 195527
24631 196045
172409 55029
48444 107564
79660 148527
48166 9821
61002 54182
97678 55276
177163 197997
55056 44149
197396 126399
107693 14300
43525 190266
60068 54667
27439 135849
156918 34997
90609 126281
6810...

output:

645
541
694
128
166
58
84
109
265
31
277
3
72
372
297
24
396
4
81
153
175
182
370
262
74
94
128
20
212
171
157
189
129
496
168
171
1
83
461
62
19
35
16
37
23
197
56
159
624
471
49
5
64
517
258
239
245
258
348
3
577
196
79
247
69
352
103
231
268
65
89
372
400
121
40
293
24
169
63
80
197
3
134
251
197...

result:

ok 1000 numbers

Test #57:

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

input:

200000 1000
197497 131480
147042 62470
188420 59244
154770 188015
18333 115930
141623 24774
82232 33091
10888 148648
44829 34724
86390 193008
44547 162554
175868 25936
172097 74821
158186 62607
49037 175123
38149 81966
61799 176246
186359 54432
42884 157064
71770 37559
159655 71125
167563 199532
145...

output:

240
231
95
266
9
985
401
12
33
100
18
145
124
658
18
114
225
315
211
43
55
5
93
192
158
335
64
38
9
276
49
48
30
18
301
53
290
73
348
25
33
538
98
39
37
144
560
217
502
282
290
536
356
176
161
90
54
125
324
42
3
38
136
109
217
20
125
33
109
125
409
0
230
286
411
122
405
178
156
50
211
154
75
59
3
15...

result:

ok 1000 numbers

Test #58:

score: 0
Accepted
time: 589ms
memory: 75612kb

input:

200000 1000
60191 94207
183498 77383
8062 119515
137 84369
146448 35154
79386 90594
38709 189981
95191 194487
125210 46249
28574 61136
134183 73221
37184 117569
42304 144141
109702 89062
27788 75205
49444 185413
28562 132807
26697 63087
38003 195319
46905 85703
139489 36419
189311 178512
77217 42335...

output:

360
210
81
384
186
186
12
507
213
273
22
345
170
113
5
329
5
13
38
158
2
124
361
147
648
50
1
260
501
27
60
0
901
133
88
366
390
301
399
195
379
274
175
361
653
32
197
171
94
603
478
221
234
571
37
109
1102
305
316
562
145
61
19
487
138
250
129
17
122
136
135
171
188
34
209
244
215
620
131
86
125
39...

result:

ok 1000 numbers

Test #59:

score: 0
Accepted
time: 607ms
memory: 75880kb

input:

200000 1000
9237 190521
138443 173835
67003 19434
131767 166820
65714 49838
46741 106090
21854 120408
106495 57971
80743 83164
52538 47523
135351 19172
51306 162928
1505 30664
132335 153185
189181 147723
32580 17744
79248 158625
31651 93374
148095 196635
32014 192324
164972 73616
3372 133144
8389 10...

output:

40
177
233
45
21
133
141
137
40
15
218
454
17
13
231
218
3
321
286
110
128
4
132
350
6
46
8
19
52
152
6
315
413
116
84
6
40
69
142
233
441
333
65
57
77
116
56
23
60
42
77
16
291
22
471
4
89
6
46
555
69
121
180
329
156
210
303
95
632
976
393
137
17
669
231
99
707
238
371
4
363
125
69
6
92
64
88
10
21...

result:

ok 1000 numbers

Test #60:

score: 0
Accepted
time: 597ms
memory: 75088kb

input:

200000 1000
28026 136681
86076 57216
117237 107883
162201 179818
153488 100349
186999 33873
11441 181228
22869 106864
30716 91543
146880 34701
66158 71683
127052 54041
19199 132781
14726 37967
160621 31292
87718 199063
38550 29382
97795 53991
4723 119384
91158 195540
83135 42379
20261 175916
84108 8...

output:

651
615
35
103
313
1
88
27
33
7
233
135
313
393
15
28
89
89
336
141
2
143
91
113
158
299
350
533
98
256
62
71
24
7
56
39
217
851
16
12
190
56
395
396
85
395
112
98
148
612
13
160
769
298
9
781
107
35
103
29
548
362
14
285
635
3
76
61
16
51
6
508
81
28
26
22
154
32
218
185
68
466
328
65
42
272
150
22...

result:

ok 1000 numbers

Test #61:

score: 0
Accepted
time: 354ms
memory: 74984kb

input:

200000 1000
154303 94791
154303 171387
175982 194457
154303 106432
30118 91160
154303 187003
65916 154303
149399 154303
3512 109735
165328 131747
184310 140147
137726 154303
186579 154303
8100 174681
8671 46086
191101 154303
152355 91933
159422 50739
154303 173590
127669 80981
147185 154303
125194 1...

output:

66
153
327
133
68
65
113
147
502
204
403
99
73
3
37
405
216
165
157
127
46
194
515
18
221
68
283
74
114
109
175
52
589
252
24
226
289
383
93
180
67
22
32
62
7
48
446
594
227
977
90
120
40
32
119
302
87
20
31
135
401
288
258
14
33
60
36
197
80
88
196
114
0
46
28
56
26
13
242
252
102
1
320
621
217
0
6...

result:

ok 1000 numbers

Test #62:

score: 0
Accepted
time: 379ms
memory: 75456kb

input:

200000 1000
9600 107987
157334 171006
96579 171898
89556 10321
96579 97914
87423 147971
96579 156463
90214 80850
48173 171095
17498 17221
15192 33827
12975 29516
96579 122055
97533 179761
145863 116106
96579 155099
80115 24453
150105 148013
96579 10937
22121 171295
96579 162228
159889 112183
69143 9...

output:

51
102
43
23
844
203
739
1298
255
123
404
14
305
137
152
424
942
47
235
157
44
51
13
350
38
0
52
401
24
19
143
468
30
43
56
736
19
323
183
5
943
557
106
57
27
183
283
105
13
74
149
141
261
46
83
206
101
13
157
261
279
92
373
408
70
86
111
39
121
17
364
16
455
25
30
5
397
52
603
464
243
359
0
123
29
...

result:

ok 1000 numbers

Test #63:

score: 0
Accepted
time: 587ms
memory: 75400kb

input:

200000 1000
179600 107956
129526 29422
117446 132079
59974 140135
102995 41206
136117 70715
182781 27076
87120 95528
132328 180498
123312 35929
94302 26064
140254 187101
185386 169919
80010 169241
129255 37610
176602 69795
164854 14356
145081 47391
191962 83020
188270 79375
117779 121022
167029 1266...

output:

61
577
275
232
609
114
575
16
57
368
325
84
319
154
264
136
5
160
96
204
497
235
38
56
146
25
35
43
208
172
208
471
85
25
28
43
42
253
76
64
680
72
681
271
308
102
117
96
844
54
213
217
253
107
123
73
17
425
73
69
77
340
152
331
51
219
21
582
35
231
4
132
153
175
5
256
226
131
58
33
199
381
42
63
7
...

result:

ok 1000 numbers

Test #64:

score: 0
Accepted
time: 486ms
memory: 74556kb

input:

200000 1000
63831 155333
35160 75756
183970 116121
83028 76999
33314 146694
185837 171045
136872 90764
92469 191012
42482 170962
155543 23165
151676 126077
79256 174534
25266 65216
174722 168196
169857 37176
90574 12105
60596 93711
34953 186003
10145 107804
156426 111522
131105 124702
108285 145588
...

output:

306
28
67
155
587
1416
138
55
46
580
47
254
104
42
110
16
6
370
128
72
19
235
41
48
84
13
46
127
223
233
181
472
238
23
515
35
130
103
94
77
526
13
534
116
15
58
57
71
156
361
77
198
2
242
24
325
32
126
218
343
20
106
205
1
28
68
82
13
2
287
19
3
173
78
1158
144
316
193
560
324
60
12
55
208
132
454
...

result:

ok 1000 numbers

Test #65:

score: 0
Accepted
time: 589ms
memory: 97180kb

input:

200000 50
119739 21591
52456 152544
36414 61499
41778 69121
78099 3642
34902 165311
9221 133660
157538 48199
58271 72106
110619 84303
53602 62754
122676 192402
114678 43772
81629 70237
68067 103314
173460 60123
70283 129618
43191 38133
128504 144187
141213 136969
143734 45483
110119 98102
16772 5967...

output:

4980
4472
3974
1029
1941
2054
4042
5218
4816
3986
17650
2507
3876
13069
7963
494
2322
4106
1999
22345
2089
2155
2112
1108
213
3340
4330
215
3967
3664
84
1032
8853
1011
1938
11395
3781
538
9217
6367
458
224
3727
2308
53
1903
2013
1717
4713
484

result:

ok 50 numbers

Test #66:

score: 0
Accepted
time: 544ms
memory: 93176kb

input:

200000 50
81306 20158
191061 127857
133469 162270
80584 4753
196795 42548
57533 95240
72177 91926
161900 143928
45550 36396
99131 79581
133996 26520
35003 133143
188949 9730
108718 190437
127775 109779
174461 88076
149848 34521
47391 15767
189959 67183
138396 49352
50803 165459
71718 154772
152945 2...

output:

7543
99
508
8213
803
1632
10657
5368
1126
5106
1721
4104
5190
3877
12464
1461
12512
2306
1986
1684
2208
9880
1160
2799
693
1151
4894
1113
1088
4102
7751
9779
3593
5630
4
1120
8906
12652
1238
297
1724
5848
2355
9223
2181
1259
4012
907
1128
2779

result:

ok 50 numbers

Test #67:

score: 0
Accepted
time: 266ms
memory: 87984kb

input:

200000 50
184421 84409
184421 133986
184421 186287
20320 184421
161294 184421
196433 184421
104490 184421
184421 132336
58240 184421
148075 184421
184421 34037
184421 167167
77956 184421
184421 76942
133955 184421
184421 155041
184421 353
82695 184421
63667 184421
154573 184421
184421 173864
184421 ...

output:

8770
8029
110
1912
3733
6417
4392
297
3426
2170
1037
2262
2225
3622
6413
242
5168
1517
4075
312
1475
2260
7008
7548
2381
1265
4833
5824
11379
1085
1689
30
11612
731
1215
3965
664
22209
10926
3932
164
654
11241
961
7754
3109
2331
2990
2228
308

result:

ok 50 numbers

Test #68:

score: 0
Accepted
time: 543ms
memory: 99964kb

input:

200000 50
54917 59366
129665 151976
170723 64071
18604 91802
9385 77145
159189 71213
18995 87781
77548 103773
13522 4356
62438 163583
26661 191202
73032 57188
196913 138288
36053 135500
111865 22244
97183 43863
43120 30228
46436 112111
5395 148796
32926 14624
55034 143316
89776 157378
130388 26103
1...

output:

563
1870
1455
3694
5672
2465
668
1927
1895
5824
7957
1931
4876
517
860
945
2748
2112
2023
252
9469
5186
2901
3707
7972
7072
824
735
7196
177
1925
19681
1936
1908
580
5725
1510
3973
15
1173
604
17656
3051
3595
10029
6952
4458
1096
4372
14012

result:

ok 50 numbers

Test #69:

score: 0
Accepted
time: 518ms
memory: 91276kb

input:

200000 50
78489 75484
169633 148398
133213 64544
142536 22739
86208 77223
144457 88919
145560 181194
189638 102956
60375 70634
25535 179971
90853 109236
82003 33046
67676 107619
181270 160300
55046 128967
111048 194837
70568 58720
61528 5706
120840 64955
174394 36355
190508 80561
194771 63377
52067 ...

output:

3872
10166
217
2522
50
1561
3303
6831
11299
8637
7266
246
7227
2960
2164
1518
3494
3426
3008
3839
9466
3536
182
696
4181
766
3028
255
482
7255
3280
2516
5905
5418
2204
343
1697
9356
4078
4429
2270
1437
4153
6264
13922
10289
2475
5715
172
140

result:

ok 50 numbers

Test #70:

score: 0
Accepted
time: 523ms
memory: 94508kb

input:

200000 50
50523 177127
140859 44573
83461 70037
56487 94892
32410 102740
50623 93539
51036 53170
80273 31543
8553 189218
31396 66275
172223 187914
155906 170092
182674 147342
92807 9906
46012 165745
23829 64665
35593 140625
38490 117002
136409 62577
195228 21443
70130 184383
97354 143608
77122 12895...

output:

4124
18564
2460
868
5378
1925
5157
5356
1906
4256
2998
3614
4346
7737
331
4898
2915
2295
126
8154
1740
1249
11
9676
883
4107
3246
477
15739
2996
1828
970
4729
5374
1322
649
881
8164
7856
2536
4251
3666
1863
1409
6064
35
1508
5816
4647
7732

result:

ok 50 numbers

Test #71:

score: 0
Accepted
time: 549ms
memory: 105724kb

input:

200000 50
112045 96555
158412 180850
132535 36703
176984 10232
103304 109048
75255 136046
188991 98116
190006 147304
148506 1881
430 167366
109981 194678
156689 167849
165119 11496
120413 135436
86435 99957
9412 84631
135451 198254
177066 197737
71893 180362
82914 50200
187196 146277
12038 163538
42...

output:

1622
4408
501
12059
5899
2386
141
1803
5544
31769
5733
6024
12567
8038
1149
11188
902
4317
164
17
580
124
6862
3233
848
2946
368
3232
369
2546
64
1084
3741
4029
810
9061
94
276
2373
7602
660
4264
68
8575
25
654
1627
4591
1770
10181

result:

ok 50 numbers

Test #72:

score: 0
Accepted
time: 553ms
memory: 93048kb

input:

200000 50
22313 111742
187692 22019
69950 166725
43397 76605
189227 89221
163712 50133
176349 40024
71051 197413
102560 117817
186318 107767
128985 113437
182242 113797
82205 114606
181812 171690
185096 154354
197914 41588
130939 121201
49930 159037
35233 72547
121456 88223
168577 77409
189078 10333...

output:

1140
17511
316
620
6394
1619
4208
4832
3514
7014
2838
3989
2021
7035
5756
255
2424
1487
9401
1930
434
1115
1233
4416
4479
2832
509
4042
1491
3960
6201
4275
11942
8815
1248
11960
3062
1561
641
8577
3262
4014
852
701
2786
1565
7528
1760
7556
1496

result:

ok 50 numbers

Test #73:

score: 0
Accepted
time: 548ms
memory: 95360kb

input:

200000 50
26104 63824
12164 63284
54967 65471
3873 112473
88104 45248
98975 154187
42797 136957
179063 172895
148904 6543
113791 56743
116876 133201
20307 173939
180679 22349
102405 81986
55297 6241
40903 150656
171976 106300
51805 199155
23034 5077
116893 1231
46801 117465
141444 126758
177556 4702...

output:

15623
1183
2701
11597
1421
1433
5868
3924
7739
2400
3228
5487
5238
3188
3754
1126
3921
637
339
3145
2320
264
3810
13497
945
1160
3013
5518
738
3627
7903
126
6789
2686
19622
2382
14
2893
1686
5020
4858
2561
3012
4743
4898
2412
898
261
736
6268

result:

ok 50 numbers

Test #74:

score: 0
Accepted
time: 549ms
memory: 89708kb

input:

200000 50
111768 7134
76900 61067
48933 54047
190509 97360
60779 33150
110249 71372
169477 149710
151462 41880
154339 113829
152381 69688
187157 183829
11993 97767
18681 167524
138070 196900
92552 145701
148186 48345
123024 29725
33270 40745
145827 103945
74807 5786
113867 100486
188138 175366
24500...

output:

10297
8119
2340
466
3863
3685
9979
381
3334
2646
507
1430
5076
856
2147
5241
6130
847
196
7403
1655
467
20
8258
759
12822
12914
1660
742
6536
1830
10652
4291
51
1357
7554
10
2333
1347
5418
1469
521
13909
2316
8543
1741
50
937
4765
8792

result:

ok 50 numbers

Test #75:

score: 0
Accepted
time: 574ms
memory: 100264kb

input:

200000 50
38090 38435
186011 91111
126213 156765
15789 71841
76371 68497
151020 84960
26386 180613
1285 136785
27077 78187
47426 103672
150988 85753
56810 136530
137135 133271
155944 182710
61381 72662
187769 307
148040 100642
33010 111951
37002 100122
44628 197320
2638 147101
71370 26033
121512 173...

output:

1572
1089
892
1837
683
8576
2084
6885
9132
484
583
667
9315
5620
3545
5746
4684
2246
1658
1693
7943
878
1647
1513
197
5592
15403
2619
3919
2299
1101
2447
1870
16024
2603
7861
1134
1563
1255
5150
10
1603
25064
805
1557
286
710
7367
1837
7308

result:

ok 50 numbers

Test #76:

score: 0
Accepted
time: 592ms
memory: 94736kb

input:

200000 50
121644 98871
89713 142220
143671 186655
96042 104594
196368 164627
159506 93276
90287 141268
158373 170049
100666 111649
74761 7535
104661 140113
167782 78883
145536 99767
144007 17383
168232 168966
50531 133140
48582 156215
159240 37759
158706 168686
189345 181754
174371 54192
161196 9327...

output:

3719
6021
1304
73
5026
1794
4419
1500
13971
4534
381
19088
4188
944
3077
3156
1406
681
8025
279
5758
4747
1755
8348
2554
112
2760
1309
858
1759
3625
4018
2767
1942
7867
5881
3007
2720
205
3150
15
7925
1431
4655
8552
2221
8594
3184
342
12278

result:

ok 50 numbers

Test #77:

score: 0
Accepted
time: 363ms
memory: 91868kb

input:

200000 50
176587 79176
2974 176587
150367 194537
176587 9678
176587 171420
77138 46914
189641 61789
149817 28744
176587 41665
169750 175155
176587 169725
94081 93386
176587 63029
137269 91890
156539 176587
87433 77420
174993 163987
113208 511
41692 176587
176587 169960
127426 148358
193731 118251
18...

output:

3410
5777
680
174
620
4117
4738
8403
570
11543
58
6241
2218
1697
3486
2530
5931
8089
2509
5618
10512
924
5116
1113
3698
2852
1563
1736
12957
86
1120
7221
1257
709
640
7728
514
3405
9929
2869
22654
1751
3193
600
119
159
3036
2330
3052
8643

result:

ok 50 numbers

Test #78:

score: 0
Accepted
time: 428ms
memory: 89668kb

input:

200000 50
5895 88201
18276 31673
5954 197731
195256 37854
47123 41574
171630 55905
194450 132570
47123 105078
49012 151752
78747 26792
110938 107329
17688 47123
198771 33475
71983 47123
86275 171863
192905 138479
26053 108840
198670 192409
47123 148987
46997 167934
15410 47123
120714 100529
45394 47...

output:

539
9257
3446
1642
6149
2671
1810
205
9887
13448
7884
8088
6071
4052
8722
305
2469
154
1006
1207
986
6800
913
7038
65
3059
394
17021
1585
1553
1665
10250
3541
9123
955
4519
910
18265
323
3514
414
1936
897
1096
3256
2103
2155
1484
4299
750

result:

ok 50 numbers

Test #79:

score: 0
Accepted
time: 541ms
memory: 91816kb

input:

200000 50
142856 117873
164680 90857
146002 8998
82558 163122
54633 92113
99990 30975
137123 13979
63998 151793
89053 150211
129047 184077
17015 47355
15509 163191
112 43537
73878 65415
113493 22325
16503 170978
35480 119342
82869 184970
37370 138620
145799 154912
110752 168479
70005 3046
126709 155...

output:

8054
1976
11857
1924
1262
2897
167
6371
1998
1091
2628
131
993
3295
5372
15071
3116
5140
2760
1043
129
2364
1926
9844
3142
15779
7560
2179
670
1947
9326
456
9377
2060
8815
1114
3651
417
4260
2404
9496
2943
8327
270
3680
1879
3573
2711
1058
318

result:

ok 50 numbers

Test #80:

score: 0
Accepted
time: 446ms
memory: 90440kb

input:

200000 50
9946 165570
2927 115023
112080 157603
116885 51614
178702 87368
64993 149436
10023 7500
71402 5273
42977 163729
190445 87600
117923 92389
97827 138577
99650 80367
60438 53710
44103 149381
188478 134312
192289 44977
26208 72327
180631 179333
44550 147388
118565 115487
41 123289
199833 17743...

output:

5287
126
2089
5658
403
3586
1205
12880
1169
3502
1773
944
3590
4639
2000
7295
125
1359
5473
4153
4341
2064
18368
4244
2892
1987
3767
3153
9019
15756
3121
4325
5406
244
656
182
3705
673
8478
1585
4394
4387
5513
3634
2039
5794
4983
1765
4657
1073

result:

ok 50 numbers

Test #81:

score: 0
Accepted
time: 331ms
memory: 84900kb

input:

200000 50
127352 8324
190859 177342
82242 133066
8470 30465
65831 157749
121891 90296
186262 72662
180359 198796
156141 72287
167253 178992
38190 180029
149618 123597
123597 150844
177342 130371
82242 186523
161589 150028
15956 95238
166094 17787
178903 81072
113674 81072
1111 79384
30996 77469
2664...

output:

1706
3239
4333
1046
6225
3337
6023
2164
1439
1832
2506
2412
1143
5568
15986
4361
2925
2575
1527
9129
564
1297
5780
155
2797
350
2985
6402
5151
952
16500
1577
1656
2107
118
141
163
766
11354
10
5156
968
2421
6105
12139
6356
13017
1834
4682
4952

result:

ok 50 numbers

Test #82:

score: 0
Accepted
time: 338ms
memory: 90124kb

input:

200000 50
7343 169917
9267 94045
141799 92004
197530 107238
75 138535
77919 145717
138912 35537
115026 49423
75858 63229
109450 117914
29491 63161
81926 42278
61496 45009
34282 31991
95405 124626
134983 164419
145585 141686
197431 197182
100775 165277
180144 15736
30042 184933
181550 133296
32839 15...

output:

16722
3169
16820
5325
5527
2577
4362
753
1543
6695
3279
11464
1002
762
2500
4192
3651
536
4421
3886
3337
3690
5993
253
6510
1033
227
2699
2552
71
551
1403
4675
905
12080
9185
221
179
228
3564
1628
24898
173
1579
437
503
820
604
90
8459

result:

ok 50 numbers

Test #83:

score: 0
Accepted
time: 450ms
memory: 90000kb

input:

200000 50
14029 83647
142008 88350
36394 133498
166839 58931
63855 13389
37910 4587
64611 10657
1211 153786
105915 9882
95236 126000
5437 94196
17937 149675
85053 68005
75892 35456
191566 86027
122744 119585
113388 22482
36894 198302
88446 11889
95512 650
110773 34034
117235 59863
181960 26197
41628...

output:

535
1438
1059
2616
2757
4825
2058
2417
532
2349
7365
1454
1639
518
57
1661
1571
11555
10936
1488
400
12298
2011
110
3684
2242
5328
775
1822
3627
2200
345
760
3643
5771
686
908
21883
10093
1750
1775
1718
8972
1338
20059
4097
3761
11408
4610
819

result:

ok 50 numbers

Test #84:

score: 0
Accepted
time: 555ms
memory: 94848kb

input:

200000 50
89780 164525
198949 6483
149600 19463
91010 68589
74641 68179
124150 68278
135144 87234
140395 198762
140105 123385
162638 90926
42753 32012
4963 100491
71007 24940
154235 80744
60447 11810
154611 14918
100728 1835
197489 103594
41859 171029
70438 140986
135623 95060
63938 45396
94438 1578...

output:

531
41
3503
8392
913
2084
2179
5563
1479
740
4764
386
3275
2193
20717
5921
2696
4810
4170
810
2917
1348
14044
1084
5665
83
409
2786
1000
8274
9009
245
142
5938
15180
6621
223
8756
689
609
604
1271
5993
497
1609
2361
1623
4965
11797
7014

result:

ok 50 numbers

Test #85:

score: 0
Accepted
time: 361ms
memory: 77576kb

input:

200000 500
92380 197470
90169 147096
145084 143462
44278 16701
36228 80120
138332 158984
63707 81321
23773 78529
68966 114931
94881 94884
36228 68989
54494 25041
2786 27012
75471 174559
45172 78
134897 94610
92103 125918
143462 52672
170489 163484
134897 120867
116774 134084
29361 153036
156063 7391...

output:

59
441
122
420
410
1474
131
202
246
678
103
65
343
154
133
581
1546
201
64
866
113
1033
561
152
367
12
221
158
54
81
420
5
489
125
447
94
197
1597
1046
1023
424
265
91
455
575
77
154
157
468
362
850
856
194
22
28
79
211
455
56
56
1944
382
480
679
1436
19
1
28
156
291
731
37
390
273
39
443
364
141
28...

result:

ok 500 numbers

Test #86:

score: 0
Accepted
time: 435ms
memory: 77472kb

input:

200000 500
33066 105783
109701 136603
58896 21562
85670 77318
8900 66700
67312 176633
116546 56524
55532 141530
34428 156750
29169 130407
125108 176328
49666 14912
7413 59447
122670 111959
33137 85353
42025 133861
170126 128411
26531 23541
169070 40411
101881 9079
142786 87905
195011 165053
79512 64...

output:

793
286
239
153
479
211
1067
441
254
266
34
83
433
839
676
193
93
681
631
187
217
196
562
279
1494
35
1176
172
552
374
36
585
17
600
11
731
80
427
20
263
2
0
47
192
253
441
121
246
22
409
719
228
647
243
226
708
2104
203
221
80
109
65
258
536
675
340
335
16
422
211
435
1286
524
258
189
40
323
23
531...

result:

ok 500 numbers

Test #87:

score: 0
Accepted
time: 514ms
memory: 79088kb

input:

200000 500
96404 113081
38367 79258
56679 16738
79653 47153
142381 156594
126397 71564
124114 65115
7793 62940
142371 180810
134141 188281
2442 186565
124686 54640
121422 138553
61818 45458
92505 62726
171752 168436
110843 14062
12034 109281
73296 164621
152130 83681
177059 153278
71059 156168
15892...

output:

378
1056
365
178
194
423
16
238
125
86
129
1787
105
836
109
69
772
234
87
349
189
115
32
53
285
233
258
593
100
177
238
85
206
938
1078
40
1162
241
53
37
1
292
1460
387
246
360
471
164
46
48
343
163
298
355
300
178
520
58
1426
100
2096
134
442
96
383
16
1131
57
163
89
241
851
96
715
37
318
383
88
53...

result:

ok 500 numbers

Test #88:

score: 0
Accepted
time: 581ms
memory: 78796kb

input:

200000 500
182811 141311
155028 135115
188880 135108
163061 132576
123533 59229
154336 90844
129445 103297
71176 171344
22895 189449
84716 112368
73967 171926
57392 95279
128296 182926
146772 154279
152012 1881
29730 116239
88791 43263
49443 73424
123872 110021
130493 125003
64615 184848
58558 15383...

output:

700
113
9
95
17
6
168
320
375
961
704
38
129
135
78
1084
422
262
7
261
560
826
189
257
169
590
279
1
441
189
507
55
601
155
354
387
50
447
2
112
977
644
6
1062
59
39
763
329
163
11
1297
107
38
246
1082
45
254
265
304
280
174
478
5
130
245
23
14
216
717
190
376
36
469
223
6
225
1122
614
362
167
106
3...

result:

ok 500 numbers

Test #89:

score: 0
Accepted
time: 436ms
memory: 75772kb

input:

200000 5000
82681 77598
75414 32496
71274 77598
79259 70302
168470 44091
34918 171858
86803 88779
27298 92633
86307 12028
3357 18148
26619 86803
97905 148966
140409 80540
174180 68513
183903 92995
128540 96235
45691 32496
54323 79456
79259 193380
114 89916
181687 126815
165022 177417
102294 86153
11...

output:

9
96
3
0
24
3
15
2
0
34
26
21
7
78
25
51
26
2
90
61
30
0
5
5
46
14
64
14
21
82
18
7
1
22
11
2
1
12
80
67
13
31
4
18
56
49
46
131
6
21
26
0
32
13
24
2
2
51
24
19
4
5
37
73
12
104
22
8
0
20
165
6
11
6
1
9
30
0
7
81
61
64
1
15
33
19
66
9
41
2
1
30
30
50
34
42
19
23
9
50
19
3
23
46
3
7
9
42
25
65
14
4
0...

result:

ok 5000 numbers

Test #90:

score: 0
Accepted
time: 514ms
memory: 76480kb

input:

200000 5000
32179 78235
145128 179425
34238 85283
38886 142723
119607 17213
75112 111423
110457 32179
134941 13502
56549 176817
829 187430
77562 92635
178672 17537
177666 129312
116435 146568
41786 116661
64960 45965
23771 80173
14619 166690
2125 182884
109569 96894
171906 89340
13381 100691
124546 ...

output:

5
10
1
102
16
8
9
47
0
100
82
31
80
44
0
1
90
2
12
26
38
70
10
19
9
6
34
33
31
19
9
15
66
1
9
60
80
25
55
9
86
25
16
31
30
13
12
9
37
69
112
1
2
24
30
7
48
13
22
17
20
67
44
43
58
32
26
8
12
64
19
69
4
44
4
42
140
22
6
6
81
65
42
1
26
13
0
18
2
61
6
17
25
14
7
81
0
30
74
25
91
0
344
5
44
2
4
78
67
0...

result:

ok 5000 numbers

Test #91:

score: 0
Accepted
time: 570ms
memory: 76992kb

input:

200000 5000
177419 22048
18912 95959
6485 31871
10520 95681
93585 10872
141602 75278
146263 104267
5196 115166
113859 71880
102299 89786
59866 183635
58446 137673
26115 140012
36276 76602
110760 6882
2381 191304
49088 103594
194628 99297
169848 128327
35973 7961
16972 39951
142180 83119
85158 64936
...

output:

112
51
79
27
43
20
9
3
29
19
6
12
30
10
21
16
4
16
0
95
8
23
1
63
6
30
63
33
3
29
58
8
35
34
26
38
45
2
17
6
1
64
26
29
16
39
0
31
11
25
23
3
19
147
45
18
6
61
33
66
7
6
43
77
12
20
0
119
46
13
9
14
48
30
29
21
24
37
8
15
3
1
22
3
10
3
9
9
26
15
50
52
25
10
13
51
31
62
69
12
0
68
8
16
18
3
5
84
8
13...

result:

ok 5000 numbers

Test #92:

score: 0
Accepted
time: 582ms
memory: 75900kb

input:

200000 5000
83451 179065
139864 90340
198459 173205
68442 161336
168669 96485
48230 192065
28009 10411
133286 153857
97699 25641
63990 160380
18915 33347
60320 102248
194632 54879
116293 127995
85428 21687
140550 81941
171084 34785
197485 5549
19581 135639
29859 154518
99249 75859
123183 135773
1550...

output:

11
6
13
6
0
50
5
22
4
42
20
119
12
17
14
65
35
6
22
0
113
47
3
3
3
3
65
8
6
28
32
5
55
8
3
70
34
22
5
20
10
26
0
1
5
56
48
75
151
25
18
58
38
42
34
28
2
24
22
8
8
15
49
9
0
1
17
26
3
25
7
13
23
24
25
8
1
70
11
9
1
8
19
28
132
30
17
50
48
91
33
25
14
18
2
9
6
25
6
46
17
44
36
26
69
18
26
14
309
21
15...

result:

ok 5000 numbers