QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#104108#1385. Ogromne drzewo [A]xiaoyaowudi10 ✓6548ms100064kbC++174.0kb2023-05-08 18:14:102023-05-08 18:14:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-08 18:14:12]
  • 评测
  • 测评结果:10
  • 用时:6548ms
  • 内存:100064kb
  • [2023-05-08 18:14:10]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <bitset>
constexpr int p(1e9+7);
using ll=long long;
int W(int k){return k>=p?k-p:k;}
struct I
{
	int len,tg;
	ll c[2],s[2];
};
I operator+(const I &a,const I &b)
{
	I r;r.len=a.len+b.len;r.tg=a.tg^b.tg;
	for(int i(0);i<2;++i)
	{
		bool flg((b.len&i)^b.tg);
		r.c[i]=b.c[i]+(flg?-a.c[i]:a.c[i]);
		r.s[i]=(b.s[i]+b.c[i]*a.len+(flg?-a.s[i]:a.s[i]));
	}
	return r;
}
I delp(const I &a,const I &b)
{
	I r;r.len=a.len-b.len;r.tg=a.tg^b.tg;
	for(int i(0);i<2;++i)
	{
		bool flg((r.len&i)^r.tg);
		r.c[i]=a.c[i]+(flg?b.c[i]:-b.c[i]);
		r.s[i]=a.s[i]-r.c[i]*b.len+(flg?b.s[i]:-b.s[i]);
	}
	return r;
}
constexpr int K(800),N(6e5+10);
std::bitset<K> occ[N];
I ps[N<<1],ei,oi;
int off(N),vs[N],k;
struct B
{
	int tg;
	I itg;
}bs[K];
void rev(I &a)
{
	std::swap(a.c[0],a.c[1]);std::swap(a.s[0],a.s[1]);
	a.tg^=(a.len&1);
}
void shr()
{
	I las(oi);
	for(int j(1);j<=k;++j)
	{
		I nw;
		if(vs[j]-vs[j-1]==1)
		{
			nw=bs[j].itg+ps[vs[j]+off];
		}
		else
		{
			nw=delp(ps[vs[j]+off],ps[vs[j]+off-1]);
		}
		if(bs[j].tg) rev(nw),rev(las);
		ps[vs[j-1]+off]=delp(ei,bs[j].itg);
		bs[j].itg=las+bs[j].itg;
		las=nw;
	}
	--off;
}
int main()
{
	oi.len=1;oi.c[1]=1,oi.s[1]=0;
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n,qc;std::cin>>n>>qc;
	static int a[N],f[N],g[N],pos[N],bid[N],up[N],dn[N],sm[N],siz[N];
	for(int i(1);i<n;++i) std::cin>>a[i];
	for(int i(1);i<=n;++i)
	{
		if(i<n && (a[i]%2==0))
		{
			for(f[i]=2;i+f[i]-1<n && a[i+f[i]-1]%2;++f[i]);
		}
		else f[i]=1;vs[i]=f[i];
	}
	g[n]=1;
	for(int i(n-1);i;--i)
	{
		if(a[i]&1) g[i]=g[i+1]+1;
		else g[i]=1;
	}
	k=n;vs[++k]=2*n;
	std::sort(vs+1,vs+k+1);k=std::unique(vs+1,vs+k+1)-vs-1;
	for(int i(1);i<=k;++i)
	{
		I cur(ei);
		for(int j(vs[i-1]+1);j<=vs[i];++j)
		{
			bid[j]=i;
			cur=cur+oi;
			ps[off+j]=cur;
		}
	}
	for(int i(1);i<=n;++i)
	{
		int j(std::lower_bound(vs+1,vs+k+1,f[i])-vs);
		pos[i]=j;
		occ[i].set(j);occ[i]^=occ[i-1];
	}
	struct _q
	{
		int u,v,l,id;
		bool operator<(const _q &b) const {return l<b.l;}
	};
	static _q q[N];
	for(int i(1);i<=qc;++i)
	{
		std::cin>>q[i].u>>q[i].v>>q[i].l;q[i].id=i;
	}
	std::sort(q+1,q+qc+1);
	static int out[N];up[1]=0;dn[n]=0;siz[n]=1;
	for(int i(n-1);i;--i) dn[i]=1ll*a[i]*(siz[i+1]+dn[i+1])%p,siz[i]=(1ll*a[i]*siz[i+1]+1)%p;
	for(int i(2);i<=n;++i) up[i]=(up[i-1]+1ll*(a[i-1]-1)*(dn[i]+siz[i])+(siz[1]-siz[i]+p))%p;
	for(int i(1);i<=n;++i) sm[i]=(up[i]+dn[i])%p;
	for(int i(1),j(1);i<=n;++i)
	{
		shr();
		for(;j<=qc && q[j].l==i;++j)
		{
			int u(q[j].u),v(q[j].v);bool flg(false);
			if(u!=i) std::swap(u,v),flg=true;
			static std::bitset<K> sw;sw.reset();
			static int ts[10];int tc(0);ts[++tc]=2*n;
			if(u!=i)
			{
				sw^=occ[u-1]^occ[v-1];
				ts[++tc]=g[u];ts[++tc]=g[v];ts[++tc]=g[i];
			}
			else
			{
				if(v!=i)
				{
					sw^=occ[i-1]^occ[v-1];
					ts[++tc]=g[v];
				}
				else
				{
					ts[++tc]=g[i];
				}
			}
			std::sort(ts+1,ts+tc+1);
			auto qb=[&](int l,int r,int id)->I
			{
				I ret;
				if(l==vs[id-1]+1)
				{
					ret=bs[id].itg+ps[off+r];
					if(bs[id].tg^sw[id]) rev(ret);
				}
				else
				{
					ret=delp(ps[off+r],ps[off+l-1]);
					if(bs[id].tg^sw[id]) rev(ret);
				}
				return ret;
			};
			auto qry=[&](int l,int r)->I
			{
				if(l>r) return ei;
				int bl(bid[l]),br(bid[r]);
				if(bl==br) return qb(l,r,bl);
				else
				{
					I ret=qb(l,vs[bl],bl);
					for(int i(bl+1);i<br;++i) ret=ret+qb(vs[i-1]+1,vs[i],i);
					return ret+qb(vs[br-1]+1,r,br);
				}
			};
			I ans(ei);
			for(int i(k-1);i;--i) sw[i]=sw[i]^sw[i+1];
			for(int t(1);t<=tc;++t)
			{
				I cur=qry(ts[t-1]+1,ts[t]);
				if((tc-t)&1) rev(cur);
				ans=ans+cur;
			}
			int diff((((u-i+v-i)*ans.c[0]+2*ans.s[0])%p+p)%p);
			out[q[j].id]=1ll*((long long)p+(flg?sm[v]-sm[u]:sm[u]-sm[v])+diff)*((p+1)/2)%p;
		}
		for(int j(1);j<=pos[i];++j) bs[j].tg^=1;
	}
	for(int i(1);i<=qc;++i) std::cout<<out[i]<<"\n";
	return 0;
}

詳細信息

Subtask #1:

score: 1
Accepted

Test #2:

score: 1
Accepted
time: 2ms
memory: 32056kb

input:

2 100
2
1 1 1
1 2 1
2 1 1
2 2 1
2 2 2
1 1 1
1 2 1
1 1 1
1 2 1
2 1 1
2 2 1
1 1 1
2 2 2
2 2 1
2 1 1
1 1 1
1 2 1
2 2 1
2 1 1
2 1 1
2 2 1
2 2 2
1 2 1
2 2 1
1 1 1
2 2 2
2 2 1
2 2 2
2 2 1
1 1 1
2 2 1
1 2 1
2 2 2
2 2 1
1 1 1
2 2 2
1 1 1
2 2 1
2 2 2
2 2 2
1 1 1
2 1 1
1 1 1
1 2 1
2 2 2
1 1 1
2 2 2
2 2 2
2 1 ...

output:

0
1
2
1
1
0
1
0
1
2
1
0
1
1
2
0
1
1
2
2
1
1
1
1
0
1
1
1
1
0
1
1
1
1
0
1
0
1
1
1
0
2
0
1
1
0
1
1
2
1
2
1
1
0
1
1
1
1
1
1
2
1
1
0
2
2
0
2
1
1
1
0
0
0
1
2
2
1
2
1
1
1
2
1
2
2
1
2
1
1
1
1
1
2
1
1
1
0
2
2

result:

ok 100 lines

Test #3:

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

input:

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

output:

0
998033926
1966100
17
17
998953478
998459906
999016713
999278089
1308691
999869011
655316
785943
999344783
1044510
999868980
999475850
130057
131054
999344783
999345648
262155
918025
8
393176
999664138
1175576
393205
1769492
999506442
999214591
999376395
16
913454
998328839
999869967
999086574
9984...

result:

ok 100 lines

Test #4:

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

input:

2 97
299999
1 1 1
1 2 1
2 1 1
2 2 1
2 2 2
1 2 1
2 2 2
2 2 2
1 1 1
2 2 1
1 1 1
2 2 1
2 1 1
1 2 1
1 2 1
1 1 1
1 2 1
1 2 1
1 2 1
1 2 1
2 2 2
2 2 2
2 1 1
1 2 1
2 2 2
1 2 1
2 2 1
1 2 1
2 2 1
2 2 2
1 2 1
2 2 1
1 2 1
2 1 1
2 2 2
2 2 1
1 1 1
2 2 2
2 2 1
2 2 2
1 1 1
1 1 1
2 1 1
1 1 1
2 2 1
2 2 1
1 1 1
1 1 1
...

output:

1
999850008
149999
1
1
999850008
1
1
1
1
1
1
149999
999850008
999850008
1
999850008
999850008
999850008
999850008
1
1
149999
999850008
1
999850008
1
999850008
1
1
999850008
1
999850008
149999
1
1
1
1
1
1
1
1
149999
1
1
1
1
1
149999
1
1
999850008
999850008
999850008
1
999850008
1
1
1
999850008
149999...

result:

ok 97 lines

Test #5:

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

input:

15 100
2 3 2 3 3 2 2 2 2 2 3 2 2 2
1 1 1
1 15 1
15 1 1
15 15 1
15 15 15
14 3 2
5 8 2
3 10 1
6 5 2
6 7 6
10 10 3
14 14 6
11 8 1
8 13 1
10 8 6
12 12 5
7 7 1
14 14 10
5 14 5
12 6 3
6 12 4
9 11 8
5 3 3
4 15 1
5 14 5
11 12 11
8 13 1
5 5 1
7 5 2
14 14 10
11 8 1
3 3 1
15 15 7
4 8 4
4 13 2
5 14 2
13 4 2
4 1...

output:

0
998992623
1007400
14
12
872083
999759071
999452631
79693
999919574
9
13
243256
999594414
162109
11
6
13
999272283
485683
999514340
999837773
144344
999114412
999272283
999918841
999594414
4
160132
13
243256
2
14
999682390
999276788
999272283
723236
999195600
999675328
81107
405892
999757099
243427...

result:

ok 100 lines

Test #6:

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

input:

16 100
2 2 2 2 2 2 3 2 2 2 2 3 3 2 3
1 1 1
1 16 1
16 1 1
16 16 1
16 16 16
4 6 4
7 7 4
7 10 3
8 5 3
15 15 7
3 12 1
16 16 6
5 13 2
8 8 6
13 12 1
15 13 5
11 16 4
11 10 7
8 15 2
3 1 1
10 13 7
8 7 7
16 10 1
5 2 1
15 15 3
14 4 4
1 13 1
14 14 8
14 16 6
9 12 4
8 12 6
12 16 4
8 7 4
4 10 1
8 7 4
14 8 3
12 3 3...

output:

0
998281762
1718264
15
9
999760644
6
999606230
382442
12
998876006
15
998958575
7
132049
264126
999339828
131901
999076901
66034
999604111
130694
792097
280641
14
1289057
998677937
11
999735898
999604424
999473046
999471808
130696
999238924
130696
791067
1124016
999076214
262070
132071
521729
909412...

result:

ok 100 lines

Test #7:

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

input:

14 100
3 2 3 3 2 2 2 3 3 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
10 12 9
9 13 4
7 8 6
13 5 1
12 13 7
5 8 3
14 10 10
4 14 2
12 6 2
14 6 5
12 11 7
10 4 3
12 11 3
8 7 5
4 7 3
14 11 1
12 12 12
8 5 5
14 9 3
11 9 7
4 3 2
12 13 7
5 7 2
5 12 3
6 7 1
14 11 9
6 8 1
3 7 2
9 6 6
11 11 6
11 13 11
12 13 3
5 ...

output:

1
998517157
1482854
1
9
999749078
999498176
999875107
999511
999874529
999627623
501903
998754182
750871
1001835
125476
743931
125474
124906
999631691
376436
9
372388
627318
250885
111542
999874529
999752526
999125979
999875685
376440
999750786
999520150
374516
3
999749062
999874529
120836
999502334...

result:

ok 100 lines

Test #8:

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

input:

14 96
2 3 2 3 3 3 2 2 3 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
3 8 2
10 10 9
7 9 6
12 12 11
5 13 2
12 13 2
4 8 4
8 13 6
3 5 1
3 12 1
11 10 9
14 14 13
1 1 1
7 13 2
10 12 5
14 12 2
10 12 8
14 13 12
2 10 2
2 8 1
4 6 3
5 6 4
14 12 2
6 9 5
12 12 10
10 6 4
7 6 1
7 1 1
12 10 5
6 9 4
4 2 2
3 11 3
7 9 ...

output:

0
998566001
1434027
13
5
999403257
3
999749325
5
998998733
999874390
999507946
999372142
999776663
998901017
125616
5
0
999246899
999748780
251273
999748778
125637
999068492
999319500
999758052
999876705
251273
999624470
5
501115
124864
555272
251241
999624470
188453
999026635
999749329
1182761
6278...

result:

ok 96 lines

Subtask #2:

score: 1
Accepted

Test #9:

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

input:

2 100
3
1 1 1
1 2 1
2 1 1
2 2 1
2 2 2
1 2 1
2 1 1
2 2 1
1 2 1
2 1 1
1 2 1
1 1 1
2 2 1
2 2 2
1 1 1
2 2 1
2 2 1
1 2 1
1 2 1
2 1 1
2 2 1
1 2 1
2 2 1
1 2 1
2 1 1
2 2 2
2 1 1
1 1 1
1 2 1
2 1 1
1 1 1
2 2 2
2 2 2
2 2 2
2 1 1
1 2 1
2 2 1
2 2 2
1 2 1
1 2 1
2 2 1
1 2 1
2 2 1
1 1 1
2 2 2
2 2 1
2 2 1
2 1 1
1 2 ...

output:

1
1000000006
1
1
1
1000000006
1
1
1000000006
1
1000000006
1
1
1
1
1
1
1000000006
1000000006
1
1
1000000006
1
1000000006
1
1
1
1
1000000006
1
1
1
1
1
1
1000000006
1
1
1000000006
1000000006
1
1000000006
1
1
1
1
1
1
1000000006
1000000006
1
1000000006
1000000006
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1000000006
...

result:

ok 100 lines

Test #10:

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

input:

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

output:

6
998671401
1328606
6
6
999204485
664128
999734345
132850
999867513
999203393
1180984
531266
999204485
999867153
925106
999207767
6
752946
265720
795532
6
265672
6
999738667
6
531266
6
999603007
529826
999870429
132860
131770
999601449
261352
999734309
796620
795528
999335889
999734777
999601603
398...

result:

ok 99 lines

Test #11:

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

input:

3 100
402 745
1 1 1
1 3 1
3 1 1
3 3 1
3 3 3
2 2 1
3 3 2
1 1 1
2 3 2
2 3 2
1 1 1
1 2 1
1 1 1
3 1 1
3 1 1
1 1 1
2 3 2
3 3 2
3 3 1
3 1 1
3 2 2
3 3 3
1 2 1
1 3 1
3 2 1
3 2 1
3 3 2
2 2 2
1 3 1
2 3 2
2 3 2
3 3 2
3 3 3
3 3 3
3 2 2
3 2 1
3 2 2
2 3 2
3 2 2
2 1 1
2 2 2
1 3 1
2 3 2
1 2 1
2 3 2
2 2 1
3 1 1
3 3 ...

output:

0
999700863
299148
2
2
1
2
0
999850064
999850064
0
999850809
0
299148
299148
0
999850064
2
2
299148
149948
2
999850809
999700863
149948
149948
2
1
999700863
999850064
999850064
2
2
2
149948
149948
149948
999850064
149948
149203
1
999700863
999850064
999850809
999850064
1
299148
2
149948
1
999700863
...

result:

ok 100 lines

Test #12:

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

input:

14 100
2 3 2 3 3 3 2 3 2 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
14 13 10
2 12 1
12 10 2
14 9 8
14 12 6
8 9 2
7 8 7
13 6 1
8 7 2
7 6 2
3 9 3
14 5 3
12 10 5
5 6 2
8 4 3
13 8 3
9 5 2
8 8 4
8 5 4
6 5 3
5 13 4
13 14 4
4 12 3
14 9 4
6 5 5
8 13 6
13 14 8
9 5 3
13 6 6
4 13 2
4 2 2
12 10 8
9 11 7
10 8 ...

output:

0
998562237
1437789
13
3
125961
998814144
251893
629689
251917
999874188
999874441
880314
125577
125186
999275887
1129893
251889
999876389
493337
629566
500206
5
374377
123629
998996085
999874063
999003080
629693
123627
999370458
999874059
500206
880310
998877128
188939
251887
999748183
251727
99962...

result:

ok 100 lines

Test #13:

score: 0
Accepted
time: 3ms
memory: 32032kb

input:

14 100
2 3 2 2 2 3 2 3 3 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
13 13 6
11 6 6
10 2 1
4 4 3
9 9 5
6 9 6
5 12 1
3 13 1
14 3 1
11 14 2
13 11 1
9 11 6
9 13 3
14 12 11
14 11 10
10 10 10
10 14 2
8 7 5
13 14 7
10 7 4
6 13 2
6 9 2
8 14 7
8 13 2
12 11 9
5 5 1
11 4 4
11 7 6
12 9 7
1 4 1
12 11 1
6 8 6
3...

output:

0
999050657
949367
13
7
10
416180
614845
3
8
999751030
999420061
999190055
893609
999749119
167276
999832823
999665561
167281
250911
5
999665500
83063
999916381
250087
999416580
999751034
999498476
999582116
83637
4
573006
333702
250829
999874551
83641
999834476
999440935
999832770
698464
12
167257
...

result:

ok 100 lines

Test #14:

score: 0
Accepted
time: 4ms
memory: 31972kb

input:

13 100
2 3 3 3 2 3 2 3 3 3 3 2
1 1 1
1 13 1
13 1 1
13 13 1
13 13 13
12 13 11
7 5 2
11 9 7
6 3 3
4 5 1
1 6 1
8 10 6
6 5 1
4 2 2
2 13 2
7 12 3
10 9 2
6 11 1
13 10 5
9 12 9
6 7 2
12 10 4
2 2 2
13 10 3
11 9 1
11 2 2
6 5 2
8 13 3
9 11 6
3 12 3
5 4 2
11 6 5
7 11 7
9 8 8
13 12 2
11 11 8
11 11 8
9 12 7
8 7 ...

output:

0
999035543
964482
12
10
999908070
181634
183864
260527
999911468
999678189
999816242
90253
143035
999035542
999540697
91929
999541260
275842
999724215
999908632
183895
1
275844
183866
780586
90253
999540414
999816159
999188791
88548
458768
999632639
91862
91960
8
8
999724215
91677
999362468
9990355...

result:

ok 100 lines

Test #15:

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

input:

14 100
3 3 2 2 2 3 3 2 2 3 2 3 2
1 1 1
1 14 1
14 1 1
14 14 1
14 14 14
4 13 2
4 4 1
13 10 7
13 14 3
9 8 5
10 12 1
9 7 4
7 6 1
6 7 4
10 8 5
13 11 10
7 11 6
11 1 1
9 14 6
11 14 1
14 11 3
9 8 4
6 5 1
8 13 3
6 8 4
5 9 1
9 6 6
14 4 3
13 12 12
9 11 7
11 4 4
7 12 4
7 4 3
8 13 4
4 9 2
12 10 4
9 7 5
9 12 2
1 ...

output:

1
998999163
1000861
14
6
999251444
4
252256
999915927
83972
999831861
167805
83322
999916696
168000
168181
999664112
748593
999579647
999747753
252277
83972
81765
999579776
999832861
999667142
251120
832672
84096
999831912
580402
999580031
244502
999579776
999587718
168164
167805
999747831
999503493...

result:

ok 100 lines

Subtask #3:

score: 1
Accepted

Test #16:

score: 1
Accepted
time: 193ms
memory: 88940kb

input:

294859 99
9779 263842 162862 41309 205878 187011 120812 215594 144926 266659 91220 39902 35717 267493 76723 16658 128623 58659 71768 36576 16756 208904 127375 96504 2801 156958 287176 270333 115149 78879 187396 78481 209993 294915 151981 256988 122823 177567 2651 197632 91283 243813 247303 256011 54...

output:

1
864213173
135786856
1
147355
561016658
498824371
381732145
119440528
261161046
40187012
128171912
305605168
362196882
586839768
763916759
312737819
655769265
75826709
679564170
407437948
999004991
362839167
10404963
603616400
593609016
12802004
398766600
509452999
163691607
259509267
669700003
614...

result:

ok 99 lines

Test #17:

score: 0
Accepted
time: 189ms
memory: 88216kb

input:

300000 100
172323 222249 66673 98886 209362 77586 244329 80461 147639 174057 195912 90421 299869 131491 108938 62952 273994 17753 132928 157975 182475 212897 277971 116299 228878 171176 14377 161567 86057 141374 60463 205712 133092 156900 66383 134260 229004 117600 65258 65798 263866 27087 132943 16...

output:

2
478702474
521297555
2
149762
819209788
478843202
537945310
913233053
748407664
351494606
330890349
924184007
44869252
603142262
27152899
70252571
223028020
340197715
117390628
114059699
659927372
434602936
353501854
855367625
557037090
737206221
515854984
10052421
105887612
375558006
236665784
302...

result:

ok 100 lines

Test #18:

score: 0
Accepted
time: 431ms
memory: 87396kb

input:

296246 98
76845 95006 227397 89183 173235 100673 238893 86201 1915 160683 242175 63819 232715 107051 84968 92212 74385 21687 270140 257491 283550 202335 13479 22611 216367 144589 35817 254119 20165 74383 78263 273471 164061 162959 4787 51297 109860 201287 76597 140925 215263 143571 24411 104963 2938...

output:

1
746979370
253020723
1
147775
842233908
42199428
438484305
297779315
824212366
166219965
69920697
100178092
703566462
297297940
671407407
210588655
928902512
163680395
360692444
643338762
730007952
74741681
779030333
61527812
967557337
198684530
110514502
874727760
177632722
507808281
924847956
383...

result:

ok 98 lines

Test #19:

score: 0
Accepted
time: 1422ms
memory: 87804kb

input:

298697 98
86749 216213 36971 89501 240657 249855 215897 87419 234791 197107 218027 56983 5973 203743 19951 280271 41899 62101 138393 216439 10089 297331 221839 195627 249975 295773 51781 214419 62393 72397 2767 180995 249701 86475 244315 68871 173487 203505 58547 21135 139949 243323 15799 129091 268...

output:

26
500823928
499475329
298722
149556
690142002
425515365
452993972
387125653
486332252
693333833
505526355
396400019
387512471
847251865
21837154
150376385
526982809
130585474
172469396
61490527
62417618
431236233
126078363
255572268
147668759
108489174
880359604
806592164
758892417
837973541
934517...

result:

ok 98 lines

Test #20:

score: 0
Accepted
time: 2208ms
memory: 87936kb

input:

300000 100
196315 120527 76135 14055 42135 254491 243243 7557 175221 191071 15657 80517 20797 133169 193213 52103 141455 235759 9459 230521 53347 93153 68739 274217 266499 104979 230349 3925 173381 267641 51411 241255 101949 22727 83003 218981 122587 291461 259459 156715 100121 133721 173745 150047 ...

output:

1197
931335670
68967694
301196
157296
852731886
134142566
309430248
239126847
266761887
244131747
536596544
186527230
63045963
652165894
326468040
836389788
941999056
261461509
300948018
271644854
766771404
191196021
483467457
220015567
420192948
109270203
472809786
238972331
935677209
812552929
154...

result:

ok 100 lines

Test #21:

score: 0
Accepted
time: 296ms
memory: 87484kb

input:

295827 100
26197 230359 55979 287335 200121 203289 206813 12051 114889 65675 8145 43953 39647 282425 121673 53447 238349 143117 16777 10967 4955 133249 210221 268877 286785 94855 70973 23027 261063 83101 211153 139451 267581 250777 118855 95795 15735 278395 134581 216797 60361 287745 44385 104763 13...

output:

1642
438142269
562170822
297468
167822
885652197
358591320
119045639
696144892
752133843
396542197
825761128
16727393
159475959
541566083
989683302
704760732
555381732
745094362
219748520
76758109
701347205
812934605
235318506
793235336
230155514
211693975
453307000
238916214
165565797
953292661
637...

result:

ok 100 lines

Test #22:

score: 0
Accepted
time: 110ms
memory: 87700kb

input:

295349 100
46047 196761 289249 82873 8979 260453 155025 274665 117443 179849 105311 3205 75733 2003 186075 217573 89979 175099 192181 48535 136685 132291 193185 257761 113225 106359 268855 144925 180949 37193 120179 125671 68789 230563 145159 64955 136871 159719 64011 204451 15407 287809 288663 6599...

output:

1556
139164487
861226674
296904
220992
864815256
712724366
782589023
150978819
665633974
125394231
132490134
944094379
457731993
689368252
467809338
772676990
720221349
51637547
242199791
795900108
199824943
744301417
375738212
103366075
847866387
603067535
978634021
637183858
607595336
703673676
82...

result:

ok 100 lines

Test #23:

score: 0
Accepted
time: 3071ms
memory: 88588kb

input:

300000 100
188508 62132 139737 132414 114443 231263 298472 212745 282421 237819 181536 161511 111089 249951 246425 75914 75623 244717 10335 223067 207443 224610 265641 89727 32571 149089 255237 142005 47380 44067 170213 119927 232785 271497 30349 21341 163540 46675 190737 80541 273363 24529 134871 1...

output:

601695881
398604899
398604899
601695881
601695881
398604899
398604899
601695881
398604899
601695881
398604899
601695881
398604899
398604899
398604899
398604899
601695881
601695881
601695881
398604899
398604899
601695881
601695881
398604899
398604899
398604899
601695881
601695881
398604899
601695881
...

result:

ok 100 lines

Test #24:

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

input:

300000 100
262648 139487 222981 271903 79149 146457 28225 130493 201133 133647 232067 133329 130643 59215 168407 16617 223359 97117 81081 259239 69719 161351 295799 195327 31901 110345 3697 225369 185203 212923 153901 111125 179411 122363 140911 121421 290847 83205 94213 169743 264899 158427 244797 ...

output:

0
5785966
994814040
299999
178819
351043653
699196092
955439268
405818152
47706251
668455818
264308298
884861791
68069104
900581791
751695738
988014288
951595701
783785581
738148753
958377202
145688382
117732300
24558233
4577302
118762339
208199557
51926684
415603168
630924729
635154450
864407392
94...

result:

ok 100 lines

Test #25:

score: 0
Accepted
time: 75ms
memory: 87904kb

input:

300000 98
172182 215569 292851 251745 10977 127601 45733 53431 119219 179709 211019 178449 267721 209157 282757 18953 231093 193655 86643 16595 214527 286843 134841 210877 193455 228501 109465 194241 50903 179537 179481 113947 56603 186919 250455 128011 100117 47365 71669 69351 63447 139253 298411 1...

output:

0
146361930
854073010
299999
282885
249194299
960612786
687921755
850210369
97561872
121127011
859169760
212137178
633825222
429765334
378957136
680732627
163533243
846764198
621651667
733642062
195745187
289144764
754616421
67668320
217220956
51457497
389893507
303181662
722521641
951362350
6692049...

result:

ok 98 lines

Test #26:

score: 0
Accepted
time: 91ms
memory: 87908kb

input:

300000 100
152392 196187 135317 296139 51809 77471 175273 253699 143705 156283 197887 82973 1695 212851 82293 28739 169545 212699 276513 199603 231401 76695 242679 57661 21303 145495 100323 106763 195945 87057 195331 71509 145749 12723 115525 43257 287291 144011 97161 249559 73979 142241 157947 8544...

output:

0
891154772
109260744
299999
215267
858013287
225686730
509768352
723976065
759515728
83839295
338952150
307815340
406846994
364751049
858994902
441845398
902632596
543375915
363967278
561035828
793919968
885395710
634572055
615530020
245476644
318344276
361687162
90540965
860846095
550473169
420067...

result:

ok 100 lines

Test #27:

score: 0
Accepted
time: 190ms
memory: 88440kb

input:

299998 97
176672 115957 124901 199389 264711 41981 261653 56031 205963 113520 203217 118238 235971 179731 76333 275415 217087 22521 65573 170769 163595 158791 152263 19258 87595 209517 103458 17651 62105 127089 62169 75273 83949 296034 75759 239221 269059 55562 156035 282729 244893 34866 99505 95961...

output:

0
421044682
579342730
299997
119805
793979601
71002828
306297689
330726517
920054930
475097633
964443240
772380242
816243517
605343071
870362538
169957653
210544484
165658224
795699874
244621669
889728829
746093224
55095988
210337715
623979565
201008702
445124777
375646953
127423775
77227315
2907588...

result:

ok 97 lines

Test #28:

score: 0
Accepted
time: 360ms
memory: 89096kb

input:

300000 99
280648 129843 122125 93067 23192 181242 97077 135955 253629 289268 137927 72843 11893 299440 236245 120698 170233 11535 60433 103643 158715 237381 120499 241303 171957 234985 81199 169468 9007 23225 290977 57835 2313 159292 63079 67909 146089 79295 294163 270255 244285 3093 235621 166159 2...

output:

0
53858027
946471485
299999
167277
976547453
366159731
981543276
512840305
963463550
282859741
940004166
764591811
928352794
826628766
231029481
28831815
710225173
725768685
208441551
5013710
407651695
96442988
689028985
21158810
571249385
114170580
679241871
5148008
725675491
874814832
375640802
45...

result:

ok 99 lines

Test #29:

score: 0
Accepted
time: 774ms
memory: 88008kb

input:

300000 95
151506 31123 259589 274803 93994 67931 4511 126405 205531 59628 103265 183015 61665 276445 294225 101441 36303 108257 109958 69787 154755 252623 47314 48501 109287 106931 41545 151107 218093 30733 76963 152151 79477 244511 252767 249485 137769 394 140182 229671 96189 196143 73751 193585 13...

output:

0
862990232
137317900
299999
152101
466352997
901455840
702920027
19867491
560034166
807650251
536068804
623797208
798868752
135060838
65063438
809774553
772567017
351792012
977485417
288841917
904874109
73867646
324241002
842256944
291499390
743655981
499760849
791126187
474151067
974694832
3591001...

result:

ok 95 lines

Test #30:

score: 0
Accepted
time: 2504ms
memory: 88388kb

input:

300000 96
200222 18355 73281 145553 217773 98311 207273 92952 27555 257199 202499 19507 98115 188403 76743 46173 183007 198463 205203 83399 56699 65273 214396 145946 160071 22139 219447 131039 239877 282007 52391 67021 129813 77655 239249 249177 179151 293687 99307 165283 149877 91891 21421 128843 4...

output:

0
774623480
225677858
299999
146245
259980387
225284825
829153740
196755862
654823127
829038130
653721496
628637713
515599056
130017599
259819566
95234946
332760410
820709216
891416369
295744274
499101573
864260587
238294225
475380143
282879635
748069338
746834533
440658178
766730756
807599338
49776...

result:

ok 96 lines

Test #31:

score: 0
Accepted
time: 2500ms
memory: 88236kb

input:

299997 100
113480 134811 236337 100095 137161 200435 102821 86697 104827 290677 36591 71801 114349 14503 48883 178489 121565 163235 226209 286651 291877 249207 74685 7093 161403 284719 263663 78715 198943 83307 130623 264309 2357 96727 67545 118191 195605 33503 217867 78119 162027 248715 176971 6469...

output:

0
869403675
130897830
299996
153950
803957785
439972032
260244211
25650841
631328772
259223380
787385077
12269862
664492339
499362051
621436693
794980316
967102925
760712225
46824466
257794541
943532322
997786227
286737856
904609316
802744772
89887286
63135730
451555892
890564620
687650004
80429152
...

result:

ok 100 lines

Test #32:

score: 0
Accepted
time: 60ms
memory: 87824kb

input:

300000 100
39970 159056 258146 171636 104342 294162 3938 228180 16248 69548 130234 47234 16384 35720 58744 69772 186014 70750 289406 98856 199192 157540 5714 262120 15134 170002 94444 43830 229946 84768 263262 28364 50626 194474 157876 240242 101530 175270 294798 213458 150206 6126 272574 262184 159...

output:

0
262654840
737645168
299999
299999
373507879
549087232
639741695
401452444
679200334
48030274
477800207
456729151
977367098
293754465
506457823
929507213
978942649
121212794
682199440
913917406
341649696
735479899
522437329
122732496
567995144
247447642
157175079
846432157
20017680
20464593
2856748...

result:

ok 100 lines

Subtask #4:

score: 1
Accepted

Test #33:

score: 1
Accepted
time: 205ms
memory: 87888kb

input:

296856 99
112996 98273 118559 223016 283428 279243 44779 74799 249502 152381 153839 270440 174 279303 115472 116654 165877 81514 46036 74655 101113 298120 150105 174116 12215 158041 109669 240981 58173 59192 156109 242021 226979 232687 20959 85434 265728 282204 55838 172589 88312 242769 82403 252774...

output:

0
692171170
308125710
296855
148593
953772946
566312798
72093185
750747290
621295623
233295720
796460178
600014341
980329616
983211245
158588599
422334981
600207401
145088802
499975208
230489725
737652624
505754258
784165953
545612165
932522245
224979636
683491739
931940870
593742274
130801402
27812...

result:

ok 99 lines

Test #34:

score: 0
Accepted
time: 186ms
memory: 90328kb

input:

297091 99
192861 220724 21704 271340 100945 32800 81496 178407 289960 24648 43158 3768 55779 61304 130898 16437 78473 211659 2118 45469 221830 118856 42962 220422 254355 176478 241269 199372 53193 249190 45809 262201 113334 250980 12980 205342 270021 223747 40622 93774 252004 281068 88634 195722 267...

output:

1
524574736
475425293
1
148215
495091328
382296803
16299571
513133680
593375484
196901375
285401884
588544755
755673606
632582767
450410802
698902027
991942702
220780084
378317630
355130238
129834655
990007661
853792620
155151540
879714406
306169029
165928104
646030118
139779367
914737618
587531466
...

result:

ok 99 lines

Test #35:

score: 0
Accepted
time: 803ms
memory: 91200kb

input:

300000 100
37139 197216 175595 57471 261569 170229 63255 89271 188961 127190 49737 37175 91961 248187 201291 208035 285443 183011 114483 143125 27595 278469 264081 237825 15193 227627 131051 194869 3557 234327 47685 48439 212663 185053 12075 298743 194565 236939 198203 272643 215396 18571 140093 174...

output:

1
640269481
359730664
1
150963
880801646
525753146
663689898
601102034
986298812
967004420
294134993
920805214
413627530
243342808
733045946
479327255
299076698
138141201
728481631
481988038
104932279
657029606
25659862
799957809
713222272
881770795
735716101
548500977
390439921
903117108
986886655
...

result:

ok 100 lines

Test #36:

score: 0
Accepted
time: 2321ms
memory: 90096kb

input:

294656 100
216645 187437 210385 242443 276257 214583 138703 196265 45515 11519 276713 152897 44785 157189 282711 130393 283623 108181 36837 129953 299107 289171 209887 80059 271833 71 158023 293585 277341 28085 104973 19901 105825 102233 183783 103261 247691 260369 293347 248295 61087 274945 162025 ...

output:

210
28202452
972093622
294865
143999
574724074
812979051
95125576
157402783
541903819
740195260
484644747
487237461
188311073
875303604
777684965
724505816
732063558
250976297
667937179
632249785
140848796
996938454
833956455
88750770
982430538
298944605
611964820
996832634
622181500
912619755
35371...

result:

ok 100 lines

Test #37:

score: 0
Accepted
time: 916ms
memory: 88716kb

input:

300000 98
253631 100169 68619 24579 207887 195949 89445 96867 73221 12303 197817 150821 20397 252325 132393 107871 60687 211411 36319 15311 284305 94439 106917 124571 264621 178795 243997 174651 208761 65417 141349 43617 209025 225547 42327 286169 164607 28329 297233 118403 263231 279189 160793 5052...

output:

740
136784708
863223197
740
160006
813656158
11633288
671335141
224107518
649938484
8640715
847513576
26066937
685567296
758583842
262582109
716358815
189755554
898075954
779720503
701007603
204451388
403884555
576289650
637429372
601264081
32935847
755660361
280390085
272262615
896413892
543613840
...

result:

ok 98 lines

Test #38:

score: 0
Accepted
time: 160ms
memory: 86656kb

input:

295005 98
173485 54091 69945 85691 37331 140795 188881 108125 94187 26029 191077 184655 100123 90207 56463 241729 227861 276255 185191 162845 148495 248177 170923 209383 275003 153027 31539 184847 197791 225873 233717 252219 118497 190289 112763 201629 57801 163611 110373 162739 184189 143719 228863...

output:

5731
881966309
118380590
300735
156511
382252863
116529750
821847677
626146862
632875323
624200997
506632186
937961818
982851881
869088532
970331815
435175289
947368608
775793110
812692454
562238672
309923855
108056086
453219830
423273279
861088844
115719623
724607177
761763485
741624630
292113258
8...

result:

ok 98 lines

Test #39:

score: 0
Accepted
time: 73ms
memory: 88828kb

input:

298193 100
22395 148093 234599 75239 12337 12305 48865 94149 215363 1035 234725 4567 72517 171765 180277 249671 155529 131401 214683 101607 161505 186429 115353 2623 280203 85195 35273 21065 141653 156713 127285 196639 254043 201371 192065 280641 116413 188851 71691 5933 73313 206989 83861 60611 164...

output:

82736
869266018
130866711
82736
162116
949831465
199471503
758588453
843073022
749238870
408844468
637396715
554305520
468473496
939868874
512171767
389216627
473935236
746858631
415411520
871558532
944869336
71534380
687320696
192442953
274818021
182447024
591917209
190058679
732650901
399977631
53...

result:

ok 100 lines

Test #40:

score: 0
Accepted
time: 54ms
memory: 90044kb

input:

300000 100
258114 291363 208103 74345 221531 11995 234919 73209 184463 230417 238233 158905 21165 116249 231565 158169 160939 247743 207965 14831 64197 142847 27881 178665 28475 22395 70823 165369 21393 94611 97885 280673 193581 214671 271861 102783 45201 251775 41697 165185 189911 21369 183133 2992...

output:

0
377419568
623180438
299999
299999
97426511
935557861
803191331
382166704
444057025
362078703
642949563
724093094
864733620
982155804
326866340
501989556
535547965
779462818
82777942
823647213
29320026
391463402
546699955
651089251
421436417
837041928
193833414
136198225
995538208
730370363
9091525...

result:

ok 100 lines

Test #41:

score: 0
Accepted
time: 78ms
memory: 93572kb

input:

300000 98
59408 272777 189463 169093 258771 228271 180855 264055 73861 186559 3043 127581 231029 160175 170079 100257 131031 202761 265257 72285 87783 89915 159855 235455 114701 98497 81609 162793 81041 205385 114607 87899 297429 181839 260277 131211 67265 227865 53279 174801 166187 140405 116137 14...

output:

0
972123524
28412650
299999
210863
557572861
20961889
65354845
973740316
506384548
880060196
255945621
494512436
520574310
13022471
404867221
880801361
297243222
163773470
880244865
568258538
264263849
862448248
740951255
682986906
998211804
507641962
854704673
776221869
147764863
540437753
28819137...

result:

ok 98 lines

Test #42:

score: 0
Accepted
time: 104ms
memory: 89296kb

input:

300000 100
23888 212137 268785 205427 37623 170025 33931 266265 218759 170117 138825 87009 11897 186465 255643 49175 286067 70963 202915 45905 258287 249503 86321 45599 10481 10975 11483 96255 128233 226573 34007 194747 98891 76887 143975 86749 151959 276797 111045 189729 186453 96595 143315 36649 2...

output:

0
443355776
556987906
299999
105087
864944459
842526088
236638209
122435007
572708780
47756225
752691971
242587231
408047585
369367362
426507705
671046683
706318456
594302216
985110329
20256276
45477934
160015524
3511864
817723203
245401955
628979142
972963377
208967128
518243438
598533490
502907205...

result:

ok 100 lines

Test #43:

score: 0
Accepted
time: 3065ms
memory: 92032kb

input:

300000 99
70042 158722 223783 111924 124823 755 32892 70957 296405 42033 233678 100935 232587 174589 217579 59938 831 188027 60237 45179 62127 203766 176057 259457 109417 117319 277315 215317 61410 99811 128859 114495 208457 193681 103795 33975 97540 165727 32697 111077 162147 257041 290843 266401 1...

output:

0
792509684
207791096
299999
149769
253198094
899125404
520632169
253197265
854124894
421687837
131315313
877438196
256127203
923027172
364650490
439115305
913007622
275877926
614168996
327917235
99552439
709840451
110828764
646716514
80203249
637614319
558626841
786515470
715021721
403472564
776096...

result:

ok 99 lines

Test #44:

score: 0
Accepted
time: 270ms
memory: 88612kb

input:

300000 100
47010 218281 283677 215701 242135 265453 169633 14799 22063 207543 155493 34202 287825 124235 86229 245311 83099 283676 167241 92363 93623 228411 38777 243917 74479 133215 206953 281363 26271 123331 268087 215383 217468 41297 196824 251545 129997 50096 12787 201437 231503 132501 120749 27...

output:

0
742769828
257569134
299999
180735
481794631
750900132
480216827
771010458
820066695
9332491
921903914
151246520
861887444
785021265
220283936
36491441
214820327
254369451
248741214
109536823
421650273
742018329
914591410
423010407
292106724
456861647
322730660
903830502
129440309
227216959
1720129...

result:

ok 100 lines

Test #45:

score: 0
Accepted
time: 560ms
memory: 87972kb

input:

300000 100
209928 249293 205554 134471 42249 110433 42341 159437 121029 206881 1551 7301 225841 237913 293730 22435 99237 262255 286061 230718 248173 115021 102821 92729 285021 103981 84931 49339 41250 4001 286595 53201 214369 70913 273057 290513 232483 211151 114237 30634 199911 17489 243053 24563 ...

output:

0
918762614
81558128
299999
145275
744513701
191547493
368511466
459832947
332032142
829763337
954310686
66940353
462912663
121728695
228691079
53585904
606053088
769914139
504584446
973600740
195865087
68801391
893308631
804728631
361970842
300214614
592848398
58313023
634866857
277262138
149993854...

result:

ok 100 lines

Test #46:

score: 0
Accepted
time: 1008ms
memory: 87960kb

input:

299997 98
143618 129405 278555 137663 203639 115253 295495 150110 199375 84994 29195 172119 229955 235417 92487 68181 189723 210205 119596 130681 296601 44363 64209 245747 101020 38937 56269 216535 290915 24809 121503 180887 22715 166019 101414 71771 68257 95159 221893 147150 60118 2061 42696 35337 ...

output:

0
366664835
633643874
299996
167526
523964306
34766519
281905080
806405001
531448738
583827742
854765756
562772004
197005115
405428619
269544482
850862132
42595240
540427213
935728974
589199368
509031998
944914241
440974138
64216788
256935921
744292156
972006592
351206187
868255922
308912659
4124329...

result:

ok 98 lines

Test #47:

score: 0
Accepted
time: 2381ms
memory: 90552kb

input:

300000 100
221904 179427 234279 95543 79043 76365 163163 213957 285249 269647 236191 123042 269883 77137 265755 2833 94657 32941 134771 159363 63939 206135 175929 96973 177450 265240 239469 156871 3255 23955 278537 276441 24205 157867 100221 50687 219965 74492 161023 189879 169273 30967 250733 21479...

output:

0
766965192
233336282
299999
147005
983114720
627270001
200267399
621552431
886809448
849151990
855534510
15920863
533354608
933462812
566044682
505524629
56342990
22985383
282292536
35547939
790845303
454227970
304732747
933611800
637233277
689504140
51133406
707384225
66987701
49765085
838923057
5...

result:

ok 100 lines

Test #48:

score: 0
Accepted
time: 2503ms
memory: 89308kb

input:

299995 100
14208 131353 103387 82077 208801 44887 12121 132803 130673 92509 149981 6915 101155 251961 250040 276893 28829 281197 75937 15411 101395 299523 56171 183133 148535 80934 202105 190081 107221 110313 100177 250381 60759 276267 127343 169283 236385 272263 258884 56737 236369 159115 21067 251...

output:

0
583029913
417271704
299994
154296
860238009
368848340
199186965
434227256
760465876
724159850
663086945
27423853
251592953
907120066
697033629
368561275
310252842
550749687
51108348
480509354
683157641
326700491
783294313
920968537
849416468
540415000
122895256
801402477
142643329
857063829
564046...

result:

ok 100 lines

Test #49:

score: 0
Accepted
time: 50ms
memory: 94248kb

input:

300000 100
80891 20729 208675 227085 255611 244135 26761 255573 275819 285565 180257 9223 24593 190377 138835 231129 211377 7729 50847 133467 266887 114225 222927 288389 152785 184293 166291 178995 89847 72813 12551 189165 39371 150539 284025 70037 38807 296697 80549 166215 63903 111983 186061 21867...

output:

150000
177261103
822738904
150000
150000
432035645
531611172
139524110
689006614
48550679
259850207
809895400
217347555
987172797
675961070
617521362
675742957
70774724
503627420
86749646
6100329
46606058
483769738
638397478
720363154
349810745
835816743
647506283
64156301
854453891
723822669
797689...

result:

ok 100 lines

Subtask #5:

score: 1
Accepted

Test #50:

score: 1
Accepted
time: 257ms
memory: 67448kb

input:

147184 150000
235610 69680 235575 212062 266680 19667 86350 114242 128529 251483 101550 24480 268227 254336 282625 198521 47272 181899 82751 87904 288520 105770 214645 291236 289808 75071 20399 183118 226768 194667 57810 21319 224954 270965 52359 273660 260475 17317 282282 160015 97351 138701 62176 ...

output:

0
289869256
759834605
386220471
329317223
327081390
378018557
51139936
983997475
916759075
710130754
1
1
469965352
469965350
96351216
96351214
39447970
39447968
37212135
37212133
88149304
88149302
761270688
761270686
694128222
694128220
626889820
626889818
240165406
530034662
530034660
2
2
0
6263858...

result:

ok 150000 lines

Test #51:

score: 0
Accepted
time: 243ms
memory: 65752kb

input:

150000 150000
43776 31382 110412 153293 296557 99733 118874 279435 36885 256185 116203 263640 80745 9281 180265 78288 81158 128539 192312 54357 181201 71900 127221 265138 291085 207374 90977 220245 212550 239012 165564 241071 247594 209003 99160 23706 47313 229931 226641 26786 81303 27100 67863 2892...

output:

0
271135520
381822385
49020218
881209833
160518477
939613213
880342058
782477381
684593442
728864490
1
1
110686868
110686868
777884706
777884704
610074316
610074316
889382965
889382965
668477696
668477694
609206539
609206539
511341864
511341862
413457923
413457921
618177624
889313144
889313144
2
2
2...

result:

ok 150000 lines

Test #52:

score: 0
Accepted
time: 366ms
memory: 70004kb

input:

150000 147459
243765 118059 15641 149890 142440 258361 230465 158425 193999 121880 277455 161885 186655 116431 258900 7569 68007 57224 194783 162223 199049 130971 226817 176737 153648 193119 268745 239349 138201 123731 21673 51549 244607 49161 61649 265994 198850 33971 234723 176135 115393 245899 47...

output:

2
482047234
866146691
455292204
925735843
867949390
849005566
861281710
314029550
766679229
517952775
2
2
384099459
384099457
973244981
973244979
443688611
443688609
385902158
385902158
366958332
366958332
379234478
379234478
831982321
831982323
284631995
284631997
133853318
615900552
615900550
2
2
...

result:

ok 147459 lines

Test #53:

score: 0
Accepted
time: 2105ms
memory: 66672kb

input:

147622 149016
29089 70405 286603 271721 91779 280841 43411 2533 143107 72583 259981 87475 227907 115919 203337 103157 179407 70241 8067 121649 252821 140717 200047 112215 75323 155333 206449 26685 268419 114957 23439 187315 49175 95897 93687 242173 144185 173991 177791 221069 15831 42847 270209 5368...

output:

82
812600878
719900471
278297292
855043059
495344576
720618961
45933496
645818410
245665227
187399294
83
81
907299685
907299683
465696506
465696502
42442268
42442264
682743790
682743786
908018179
908018173
233332708
233332706
833217626
833217622
433064441
433064437
280099700
92700491
92700489
84
82
...

result:

ok 149016 lines

Test #54:

score: 0
Accepted
time: 390ms
memory: 71000kb

input:

147579 150000
251905 166077 167677 199925 217341 232961 120365 85299 221555 282425 213983 20063 116223 274955 139465 120421 103119 67959 206079 204855 67789 147907 226895 78891 60929 254167 241333 26807 203731 290037 192187 248657 16347 183517 86901 109143 214761 153755 218593 208535 73471 127289 29...

output:

57
418613281
286173097
544536112
418691185
107777359
281769109
530461410
241968146
953439485
581386841
58
56
867559883
867559881
125922891
125922887
77966
77962
689164149
689164143
863155899
863155891
111848195
111848187
823354938
823354928
534826272
534826262
713827024
132440243
132440241
59
57
55
...

result:

ok 150000 lines

Test #55:

score: 0
Accepted
time: 120ms
memory: 70992kb

input:

150000 150000
149929 46411 139611 238767 255953 127285 108297 288283 19675 143827 251261 43351 2251 298989 46439 245291 44983 122935 139509 136743 32961 243433 127949 17429 199711 204661 265673 276319 247845 185309 226827 92345 31903 199093 149797 84243 10109 187737 183047 117365 55675 174161 276961...

output:

3702
799455624
354150353
863002963
68035304
955557762
93334121
367112454
523785248
680241568
200551785
3702
3702
554698438
554698436
63551043
63551041
268583391
268583387
156105844
156105840
293882202
293882204
567660541
567660539
724333331
724333331
880789653
880789653
645857056
445308973
445308971...

result:

ok 150000 lines

Test #56:

score: 0
Accepted
time: 1986ms
memory: 65596kb

input:

150000 150000
295672 80682 279015 123994 294727 148947 275718 267925 112147 239705 226624 65987 245529 76737 141003 174662 220563 238595 73809 29055 79303 26572 287973 9199 24115 119213 294657 207091 145242 12545 285665 141105 21999 240985 86033 232115 251806 163361 50131 120521 213769 271465 268949...

output:

0
276198549
620190529
432779872
958803724
939513959
702589380
279777954
928723785
577373213
723801461
1
1
343991983
343991981
156581324
156581322
682605178
682605178
663315411
663315411
426390834
426390832
3579406
3579406
652525239
652525237
301174665
301174663
379809482
656008031
656008029
2
2
0
81...

result:

ok 150000 lines

Test #57:

score: 0
Accepted
time: 129ms
memory: 64408kb

input:

150000 150000
53308 42041 288433 160427 48949 228265 139137 265763 155471 45775 118341 133675 215781 45655 245773 249433 22951 273755 295903 151471 175627 160355 113999 31111 57681 28031 79069 50499 219943 67087 194009 86271 114839 145613 288555 272217 28661 135553 31737 104033 102073 161981 111597 ...

output:

0
29320939
274043423
194238433
771498202
752765970
600709365
975908130
459269136
942488167
970925457
1
1
244968871
244968871
164917497
164917497
742423648
742423648
723541424
723541424
571484819
571484819
946683582
946683582
430044588
430044588
913263617
913263617
725956588
755277525
755277525
2
2
2...

result:

ok 150000 lines

Test #58:

score: 0
Accepted
time: 149ms
memory: 64564kb

input:

150000 150000
210636 85341 37369 62939 241241 114683 18983 100063 367 7071 110049 10367 86135 52243 56811 228503 21143 183507 214807 133269 128123 202087 37529 182449 139143 233065 17945 110935 150957 268991 41547 268257 55409 176637 245177 202629 204569 131153 134821 1575 248579 170855 275901 20968...

output:

0
768974296
649262072
871223212
925045979
475052577
958591407
362646175
413806048
464746463
231081598
1
1
880343668
880343668
102248919
102248919
156127566
156127566
706119575
706119573
189658406
189658404
593713175
593713173
644873052
644873050
695813465
695813463
350737939
119712226
119712226
2
2
...

result:

ok 150000 lines

Test #59:

score: 0
Accepted
time: 177ms
memory: 70644kb

input:

150000 148722
104722 253039 38001 82313 261691 210319 158649 212195 40595 29387 165059 80559 231361 273115 198483 222693 132401 253309 60217 193395 49323 119535 53267 64055 213545 263087 285717 276209 25227 172217 175739 56843 8225 242583 42795 36859 225601 80371 181997 167669 115853 59401 266813 27...

output:

0
871724543
831985485
473737541
169409845
208877769
348280990
686471909
938852429
191219910
128291011
1
1
960276494
960276494
602013008
602013008
297700852
297700852
337155828
337155826
476559049
476559047
814749966
814749964
67130479
67130477
319497965
319497963
168014526
39739060
39739060
2
2
2
64...

result:

ok 148722 lines

Test #60:

score: 0
Accepted
time: 256ms
memory: 64660kb

input:

149995 150000
198846 91909 86253 124911 30327 200055 145989 35713 55815 67213 27798 290755 252991 26937 195299 87261 15691 151721 282963 210105 73611 258921 144701 40207 74297 168752 163479 173700 151867 193005 23423 3807 248485 138863 291749 176030 185693 72353 158733 260411 159431 70267 21653 2368...

output:

0
943379741
387855384
332711308
692347378
751729904
877911869
761411096
600672040
439808672
56620287
1
1
444475669
444475669
389331577
389331577
748967661
748967661
808350179
808350179
934532140
934532140
818031369
818031369
657292309
657292309
496428943
496428943
612144627
555524359
555524359
2
2
2...

result:

ok 150000 lines

Test #61:

score: 0
Accepted
time: 637ms
memory: 66180kb

input:

150000 149999
114506 140707 286211 69763 79773 246991 211759 159607 166771 70855 208241 267951 150001 18603 4581 241096 59803 156521 24815 29247 105137 126225 214821 135729 141251 254159 285305 4715 231317 139615 128748 256073 81645 96543 101227 151101 3923 206923 252325 211133 36389 187425 299475 2...

output:

0
162293348
604043732
181314882
578318947
216141958
710490197
920421418
800459297
680302450
837706690
1
1
441750413
441750413
19021537
19021537
416025626
416025626
53848629
53848627
548196872
548196870
758128091
758128089
638165974
638165972
518009125
518009123
395956279
558249625
558249625
2
2
2
57...

result:

ok 149999 lines

Test #62:

score: 0
Accepted
time: 1163ms
memory: 69372kb

input:

150000 149996
127612 112109 146347 92203 45221 89867 260181 134975 42667 211226 90343 242315 48923 121921 259315 19123 16705 266753 116435 77529 246156 259985 250385 238749 286245 221739 218617 214745 122571 237025 202757 249525 29463 249625 274645 168078 208709 162393 175661 208559 7205 287987 2622...

output:

0
886449788
976614611
587906729
159943089
12391420
934443127
313496817
8028356
702469460
113550238
1
1
90164840
90164840
701456951
701456951
273493323
273493323
125941644
125941642
47993348
47993346
427047039
427047037
121578582
121578580
816019684
816019682
23385400
909835186
909835186
2
2
2
611292...

result:

ok 149996 lines

Test #63:

score: 0
Accepted
time: 2307ms
memory: 65980kb

input:

150000 150000
57058 64480 289795 142143 166309 58897 11449 279785 135127 213751 151931 150297 69675 35867 290401 205011 11925 133881 140987 210593 296761 92329 55553 263287 153397 247879 293219 107833 48777 255149 49329 199319 248993 49293 117569 131987 171795 116915 21183 132341 130179 128019 12017...

output:

0
485275357
703173484
769472131
23713050
730537864
692947601
742450667
964712118
186824444
514724653
1
1
217898130
217898128
284196775
284196775
538437703
538437701
245262508
245262506
207672247
207672247
257175311
257175309
479436764
479436764
701549095
701549095
296826681
782102038
782102036
2
2
2...

result:

ok 150000 lines

Test #64:

score: 0
Accepted
time: 2295ms
memory: 65604kb

input:

149998 149996
65726 7699 241167 143559 69889 159333 79823 188222 36049 214165 18631 172347 247555 202677 142503 261213 170385 72827 157385 185257 100677 73929 283504 164571 106179 58793 66227 129517 238117 113977 44209 181305 256733 190975 219847 210475 143647 63491 244719 45837 163649 45853 261369 ...

output:

0
708558594
75356847
787960969
330212519
331813361
63954065
649808517
797540355
945016491
291441428
1
1
366798273
366798273
79402378
79402378
621653943
621653943
623254779
623254779
355395491
355395491
941249937
941249937
88981772
88981772
236457906
236457906
924643164
633201749
633201749
2
2
2
7126...

result:

ok 149996 lines

Test #65:

score: 0
Accepted
time: 113ms
memory: 62632kb

input:

150000 150000
126073 67317 239179 284617 116615 181551 160041 152551 275461 126317 156089 79447 71429 278631 169617 148055 70803 298799 165695 252461 115699 166977 100113 242931 195041 36543 46219 67389 233397 61551 297811 132047 122171 50101 84429 56919 204977 297371 235327 262389 291009 83887 5209...

output:

75000
722480500
500487281
809787140
198317078
489682808
367639415
578016776
839899144
101655039
277669505
75000
75000
778081788
778081786
87381642
87381640
475911587
475911583
767427309
767277315
645383916
645233920
855761279
855611283
117643640
117493642
379399544
379249546
499662724
222068219
2220...

result:

ok 150000 lines

Subtask #6:

score: 1
Accepted

Test #66:

score: 1
Accepted
time: 268ms
memory: 68752kb

input:

148319 150000
9748 219404 79271 293152 124388 212544 63679 63438 275709 269894 259787 167203 284500 121715 130247 91345 167175 161040 236708 263116 159003 284529 200111 195628 241532 131076 22057 33892 98702 170577 155026 189517 258093 174310 243785 173813 291746 295272 288315 286692 181374 221835 2...

output:

0
518737242
37651938
906535087
61152077
997202316
806042869
318449953
986405775
654233660
481262768
1
1
518914706
518914704
387797846
387797844
542414845
542414843
478465077
478465075
287305628
287305626
799712721
799712719
467668534
467668532
135496421
135496419
962348073
481085308
481085306
2
2
0
...

result:

ok 150000 lines

Test #67:

score: 0
Accepted
time: 249ms
memory: 65960kb

input:

150000 149822
100042 137713 241842 263322 32709 87028 29466 182144 171243 69202 195597 128104 40464 138644 146013 90232 68555 259464 10497 207532 252697 166319 223582 113751 100767 111293 95485 136630 249821 24539 268967 240732 33008 185585 39620 73808 43668 131647 212926 47780 11569 210475 196257 3...

output:

0
998578941
67184161
329447338
420860500
886023178
971070443
195719440
681841825
167905733
1421071
1
1
68605230
68605230
330868405
330868405
422281571
422281571
887444247
887444247
972491514
972491514
197140507
197140505
683262896
683262894
169326802
169326800
932815850
931394782
931394782
2
2
2
262...

result:

ok 149822 lines

Test #68:

score: 0
Accepted
time: 769ms
memory: 66220kb

input:

150000 149348
129707 288127 299135 144095 79235 296573 273079 84239 139917 110873 128179 259240 29445 119234 101457 262057 78624 35102 232729 121459 229911 248640 195321 166897 208891 51485 167451 51807 251965 119743 217553 242803 144391 9281 53296 84081 156387 298723 284999 71723 169521 117503 5972...

output:

6
518962947
449012668
429820289
237676680
697796720
557930855
832573009
594861710
357038385
481037070
6
6
930049734
930049732
910857357
910857355
718713748
718713744
178833781
178833779
38967912
38967912
313610068
313610068
75898769
75898767
838075453
838075451
550987349
69950285
69950283
6
6
6
9808...

result:

ok 149348 lines

Test #69:

score: 0
Accepted
time: 2130ms
memory: 59204kb

input:

150000 150000
297859 125901 82789 32465 201915 252253 222749 271457 13537 24967 5531 299377 166725 99591 137227 233145 70923 276459 60251 175669 59753 265355 151123 221563 282967 210559 97963 63203 105683 119093 11681 88913 114409 292241 144625 170819 270189 189065 133213 57119 239541 133007 92517 2...

output:

89
269664659
880212836
625659707
197723194
484979299
412201235
574989418
426428687
277750022
730335527
90
88
610548269
610548267
355995140
355995136
928058636
928058632
215314746
215314728
142536682
142536666
305324863
305324847
156764136
156764118
8085469
8085451
119787349
389451921
389451919
91
89...

result:

ok 150000 lines

Test #70:

score: 0
Accepted
time: 200ms
memory: 60900kb

input:

150000 150000
134751 147049 32435 201083 76507 204795 132571 103585 239817 15495 133025 101875 258709 27531 222639 202745 203725 258183 87371 76677 279897 197603 287767 137603 296757 123189 69153 190175 217411 168637 98021 20597 248589 196647 30367 251839 63709 212595 49519 288977 59709 227101 17583...

output:

2133
859893006
676776627
818191007
344070463
251858461
519868311
711780226
287409018
862976591
140111265
2133
2133
816885761
816885759
958300143
958300141
484179599
484179595
391966971
391967595
659976813
659977443
851888734
851889360
427517522
427518150
3085090
3085718
323227644
183118512
183118510...

result:

ok 150000 lines

Test #71:

score: 0
Accepted
time: 1993ms
memory: 62748kb

input:

150000 149008
39828 202544 207047 57186 162667 156747 58278 96651 202321 221713 223338 206009 148099 181733 296779 262456 140009 1125 184221 35195 253969 208218 197987 220369 195595 188611 93449 116121 266976 114905 277493 226571 281263 202345 58809 221397 94498 34943 76685 271213 269311 145203 2113...

output:

0
847582548
163091074
688208292
737619885
550847267
776969667
493200086
153018323
812826431
152417462
1
1
315508536
315508534
840625752
840625750
890037347
890037347
703264727
703264727
929387129
929387127
645617546
645617546
305435785
305435783
965243891
965243889
836908937
684491478
684491476
2
2
...

result:

ok 149008 lines

Test #72:

score: 0
Accepted
time: 1901ms
memory: 61372kb

input:

150000 150000
236642 237984 251089 80940 201321 208689 144108 102333 112835 197223 256536 275353 117985 118637 95571 184742 228173 747 211495 225251 103547 48888 162115 293261 254257 168807 15517 194355 97506 292797 26791 157951 253495 11687 103861 293419 31738 179437 100757 148871 110957 264349 188...

output:

568695490
568695490
431455066
431455066
568695490
431455066
568695490
568695490
568695490
431455066
568695490
568695490
568695490
568695490
431455066
431455066
431455066
568695490
568695490
568695490
431455066
568695490
568695490
431455066
431455066
568695490
431455066
431455066
568695490
568695490
...

result:

ok 150000 lines

Test #73:

score: 0
Accepted
time: 140ms
memory: 59164kb

input:

150000 147536
248020 435 218233 73245 247249 48177 282571 163453 220969 160449 164775 268915 245025 191843 289283 13331 155669 222513 48791 257801 153801 41439 157419 105541 68497 132615 261533 149695 264997 238535 11109 571 283501 117445 99997 286941 2063 243785 230597 290211 161187 263227 112083 5...

output:

0
647212145
10924152
983282033
505620224
806727930
837586629
356574076
957150268
557590851
352896583
1
1
363820733
363820733
336069891
336069891
858516803
858516803
159547670
159547668
190406377
190406375
709393825
709393823
309970014
309970012
910410602
910410600
989075859
636287995
636287995
2
2
2...

result:

ok 147536 lines

Test #74:

score: 0
Accepted
time: 156ms
memory: 59664kb

input:

150000 150000
220710 155871 37843 39325 33653 67025 10459 110775 7787 179287 265047 36527 158201 293117 238871 158133 95119 18223 87193 125219 290097 286365 252179 290785 126935 235261 140631 276753 126337 24813 90755 10453 184733 149499 84885 42929 153425 34365 51821 201313 7483 238965 118591 12250...

output:

0
949433657
463481785
360840065
462484854
607516642
639392012
637629206
847361858
56968549
50581091
1
1
514062874
514062874
411406418
411406418
513065941
513065941
658088017
658088017
689963387
689963387
688200579
688200579
897933231
897933231
107539920
107539920
536518226
485951874
485951874
2
2
2
...

result:

ok 150000 lines

Test #75:

score: 0
Accepted
time: 190ms
memory: 63080kb

input:

150000 148001
239420 244401 2451 231701 93545 148715 101719 94625 116401 98437 166545 150783 220131 224501 224767 269183 61535 14245 244991 276783 215845 166703 224043 195817 74943 705 3105 41781 159827 35095 70291 184273 224131 173713 24011 200229 177447 29609 153801 72117 81955 18637 99049 273045 ...

output:

0
30348324
950002522
671742008
813565181
218314503
671440726
849695848
439519379
29332926
969668522
1
1
919671035
919671035
641393687
641393687
783233692
783233692
187970794
187970792
641097025
641097023
819352141
819352139
409175676
409175674
998989228
998989226
49997489
80345811
80345811
2
2
2
721...

result:

ok 148001 lines

Test #76:

score: 0
Accepted
time: 367ms
memory: 66044kb

input:

149999 149998
73840 230057 10101 141127 107927 208063 264656 176593 123871 114829 275577 163313 108919 208227 287955 230885 139519 295597 19511 31956 122343 27955 226327 273069 169047 136261 154309 175007 164253 100283 118383 56533 155401 276057 85060 79437 227535 159620 3821 159180 241591 179499 12...

output:

0
641506576
731601964
448753206
718619684
972125361
470393112
603179787
282885125
962573702
358493444
1
1
90095399
90095399
807246640
807246640
77113117
77113117
330618794
330618792
828886548
828886546
961673225
961673223
641378563
641378561
321067135
321067133
268398047
909904621
909904621
2
2
2
71...

result:

ok 149998 lines

Test #77:

score: 0
Accepted
time: 802ms
memory: 64212kb

input:

149996 150000
177344 227203 2255 54514 226909 24127 182643 158091 45715 149241 251093 78761 231007 170981 198421 218905 75637 59651 65738 42311 136807 143767 76743 116007 143191 83283 185424 881 60295 195449 93291 95225 60569 193701 105741 13301 83309 205121 243343 113512 233825 157595 246093 279755...

output:

0
501406724
563842983
956558605
861810218
942354213
287435245
749874893
527443042
304954703
498593290
1
1
62436264
62436264
455151884
455151884
360403499
360403497
440947492
440947492
786028533
786028531
248468172
248468170
26036321
26036319
803547987
803547985
436157028
937563750
937563750
2
2
2
39...

result:

ok 150000 lines

Test #78:

score: 0
Accepted
time: 1267ms
memory: 69092kb

input:

149996 150000
241728 65145 166287 49967 244259 100605 182983 14839 261291 183467 142753 29445 298473 200451 223814 211135 134151 6877 271256 53189 143347 138341 148425 279447 58545 282963 160029 209841 103481 21967 120501 169019 130431 17364 99145 83355 266935 228669 244617 227677 59413 73397 134126...

output:

0
47173310
533951800
279510398
105969137
804845452
943029949
587414263
290172514
992848718
952826726
1
1
486778517
486778517
232337091
232337091
58795852
58795852
757672151
757672151
895856652
895856652
540240964
540240964
242999215
242999215
945675417
945675417
466048211
513221519
513221519
2
2
2
7...

result:

ok 150000 lines

Test #79:

score: 0
Accepted
time: 2283ms
memory: 63116kb

input:

149999 149998
174370 78127 72619 207993 145165 298985 59905 178923 295869 200963 162767 187015 276823 214446 74475 56047 295923 280091 17339 228627 71967 18834 21828 7097 38775 225551 44819 208213 272003 72087 117672 59941 123903 184726 44175 220643 170937 7699 26769 11805 149371 254777 7935 195156 ...

output:

0
41882532
734327620
541983872
406821095
649642830
897212254
251366086
759424741
267253323
958117502
1
1
692445113
692445113
500101343
500101343
364938586
364938586
607760319
607760317
855329739
855329737
209483573
209483571
717542224
717542222
225370808
225370806
265672391
307554921
307554921
2
2
2...

result:

ok 149998 lines

Test #80:

score: 0
Accepted
time: 2241ms
memory: 64564kb

input:

149996 150000
138610 26915 268015 189009 57491 27977 46321 148119 124051 85115 190685 232417 48873 137861 75616 212877 115375 85245 94945 93115 26721 42855 108017 299695 167787 242739 117969 42259 63246 13109 272265 279847 202447 201093 197199 242649 223619 12407 159177 254833 10779 282415 238201 20...

output:

0
29572776
903389833
443264589
652813021
909532383
969448643
782903373
820140870
857361527
970427260
1
1
873817084
873817084
413691816
413691816
623240270
623240270
879959616
879959614
939875880
939875878
753330608
753330606
790568109
790568107
827788764
827788762
96610178
126182952
126182952
2
2
2
...

result:

ok 150000 lines

Subtask #7:

score: 1
Accepted

Test #81:

score: 1
Accepted
time: 223ms
memory: 60020kb

input:

150000 150000
166270 280783 219855 25047 191988 171783 65384 43785 117120 194975 240798 242286 190979 210363 75415 43852 288773 128295 282657 261312 41683 24742 34976 32145 89318 248131 252941 33237 23804 171547 42970 36897 93802 32346 232284 187742 282885 220363 256924 80818 228122 54253 145029 162...

output:

0
594690572
64774384
384352854
24562027
730082137
278949009
791684439
293851870
795928042
405309444
1
1
470083826
470083826
789662292
789662292
429871467
429871467
135391566
135391564
684258449
684258447
196993870
196993868
699161310
699161308
201237473
201237471
935225627
529916190
529916190
2
2
2
...

result:

ok 150000 lines

Test #82:

score: 0
Accepted
time: 250ms
memory: 61476kb

input:

150000 148941
217232 150579 119798 109424 12598 151352 67542 136147 276337 166549 69335 73062 195533 21209 257532 285509 12766 112657 257883 294620 241099 298133 186458 266560 88055 26323 225506 130000 71294 221242 53114 157050 190375 242445 135968 274526 24099 34239 170667 282751 133075 234483 2111...

output:

0
624692037
799354411
446393104
33430746
621044468
102757142
550505821
944075929
337406034
375307975
1
1
174662377
174662377
821701075
821701075
408738719
408738719
996352439
996352439
478065115
478065115
925813794
925813794
319383897
319383897
712714007
712714007
200645600
825337635
825337635
2
2
2...

result:

ok 148941 lines

Test #83:

score: 0
Accepted
time: 1360ms
memory: 61416kb

input:

150000 149965
68297 277993 138019 90969 6963 294399 248707 248727 27465 86049 231463 61739 17177 31013 207381 274599 179125 192453 43553 58587 242459 102573 195485 206189 239267 222329 183167 232133 239273 46185 271565 208143 251599 67347 263615 120375 207141 195415 232937 167943 127081 220403 19435...

output:

63
867710070
439922739
947094012
295694793
99875984
296554905
741435067
976544992
211642578
132290061
63
63
572212739
572212737
79384007
79384005
427984795
427984791
232165986
232165984
428844907
428844903
873725071
873725067
108834985
108834983
343932580
343932578
560077392
427787394
427787392
63
6...

result:

ok 149965 lines

Test #84:

score: 0
Accepted
time: 1199ms
memory: 59812kb

input:

150000 150000
45561 35405 287713 52919 140107 208795 57055 153175 200675 229985 229719 16099 106817 51377 277585 261307 173957 236617 147991 216273 57129 230233 106817 129501 241655 76529 135229 260109 218957 281875 165703 85213 161145 38679 3739 232237 277681 45019 95275 48395 269367 293397 273153 ...

output:

193
556333762
569574927
381707197
672012070
605411828
964946147
840844981
88690664
336240296
443666629
193
193
13241358
13241356
825373637
825373635
115678503
115678499
49078269
49078259
408612588
408612576
284511424
284511412
532357114
532357100
779906748
779906734
430425464
986759035
986759033
193...

result:

ok 150000 lines

Test #85:

score: 0
Accepted
time: 137ms
memory: 62660kb

input:

150000 148110
46203 219715 32005 73505 133575 215109 174139 207873 140071 233607 218563 635 189755 10206 90805 279647 155323 186587 41067 233631 35387 25691 286529 243703 298737 38655 198727 61669 245019 269453 56787 37789 211577 154147 156093 227341 214987 121179 75711 155375 47861 76225 193049 266...

output:

7
695170616
423664955
726996272
774966901
709489621
838264482
348850314
70582547
792254539
304829403
7
7
728494353
728494351
31825665
31825663
79796294
79796290
14319016
14319012
143093869
143093871
653679714
653679712
375411943
375411943
97083930
97083930
576335064
271505668
271505666
7
7
7
3033313...

result:

ok 148110 lines

Test #86:

score: 0
Accepted
time: 2012ms
memory: 66012kb

input:

150000 150000
128266 41742 91281 207102 210977 292517 178994 238847 223581 111209 262376 269113 186651 70131 25299 278494 194721 130935 105917 254315 194745 241198 180335 136847 284487 105423 167347 89743 264324 185147 100065 295013 289603 4639 136137 257563 49668 174953 42351 62861 183071 92845 112...

output:

0
246200529
224089184
259064021
531810757
503247567
237803339
869285246
314297938
759155087
753799481
1
1
977888665
977888663
12863493
12863491
285610231
285610231
257047039
257047039
991602820
991602818
623084718
623084718
68097412
68097410
512954559
512954557
775910827
22111349
22111347
2
2
0
3497...

result:

ok 150000 lines

Test #87:

score: 0
Accepted
time: 146ms
memory: 63248kb

input:

150000 149105
241596 124623 203443 79493 2087 101995 156121 288519 287833 143629 285125 104433 14527 8757 42691 193705 103463 195273 21547 9225 222247 205465 71515 247169 236305 90263 221831 291409 29333 296399 280555 26505 2835 239723 157835 3331 88689 9423 244411 37995 135125 136055 237571 21351 2...

output:

0
977169479
165002140
956579401
924813499
107892271
820612266
35968892
924354706
812456219
23130527
1
1
188132665
188132665
979409932
979409932
947944022
947944022
130872794
130872794
843592797
843592797
58949417
58949417
947335235
947335235
835436746
835436746
834997871
812167341
812167341
2
2
2
79...

result:

ok 149105 lines

Test #88:

score: 0
Accepted
time: 147ms
memory: 61460kb

input:

150000 150000
24694 155823 280763 285573 215055 44305 4879 196667 232287 9817 112451 137953 277995 289285 276039 14535 138917 273427 159285 107899 151011 11741 239127 165135 144051 123871 35947 171765 144553 119299 192379 124473 291567 149469 78819 243551 241709 117587 113837 7403 105333 216497 2071...

output:

0
429160234
130585104
454599138
248361531
156446366
265698889
805390624
702191723
598896290
570860314
1
1
701445416
701445416
25438907
25438907
819221841
819221841
727286144
727286142
836538667
836538665
376230393
376230391
273031492
273031490
169736057
169736055
869414907
298575132
298575132
2
2
2
...

result:

ok 150000 lines

Test #89:

score: 0
Accepted
time: 162ms
memory: 67204kb

input:

150000 150000
48560 121907 76759 249829 45469 268181 100525 228657 212509 179159 54851 19465 199259 119269 114177 32923 174987 36833 270439 19423 22837 112875 212183 59935 79209 190381 15349 200249 8733 260347 150173 243099 299283 145245 115999 166091 118519 43121 48839 238667 120357 26045 110067 26...

output:

0
276779519
516596347
346323070
357502373
180917023
713359311
475679319
482879893
490036117
723258443
1
1
239854781
239854781
69543554
69543554
80760805
80760805
904145762
904145762
436588051
436588051
198908053
198908053
206108631
206108631
213264853
213264853
483403664
760183181
760183181
2
2
2
82...

result:

ok 150000 lines

Test #90:

score: 0
Accepted
time: 246ms
memory: 61476kb

input:

149999 150000
16944 71673 21229 238047 166891 164541 272309 88092 153152 277195 18663 158691 107231 3297 78219 132917 169043 103106 64529 298325 185055 34309 108223 134517 176459 67491 117925 258213 180225 74839 15449 167289 218284 36985 98969 195399 39279 94377 225267 177369 68825 123803 146009 235...

output:

0
790713110
935128371
885561766
518837687
26069557
18806214
457102296
374221237
291104882
209286912
1
1
144415274
144415274
94848659
94848659
728124595
728124595
235356459
235356459
228093116
228093116
666389200
666389200
583508141
583508141
500391788
500391788
64871640
855584748
855584748
2
2
2
950...

result:

ok 150000 lines

Test #91:

score: 0
Accepted
time: 449ms
memory: 62612kb

input:

149998 150000
275946 216334 133863 246459 25597 20543 226658 15671 219183 250931 188317 82517 258607 157835 277071 124009 50419 51573 74883 286209 268524 71423 62691 148745 278889 42381 154743 40919 175203 148116 88542 46701 123123 177343 233993 115673 3009 135933 112297 40905 66609 124482 221461 34...

output:

0
433113897
597433139
981022735
580530770
443410227
346093774
488853945
645664458
802290611
566886113
1
1
164319245
164319243
547908839
547908839
147416876
147416874
10296331
10296331
912979887
912979887
55740049
55740047
212550564
212550564
369176715
369176715
402566878
835680775
835680773
2
2
2
38...

result:

ok 150000 lines

Test #92:

score: 0
Accepted
time: 945ms
memory: 56404kb

input:

149997 150000
148374 12767 265063 271767 123775 97707 299248 181567 196591 269161 45299 19763 87711 279673 295729 268051 193517 41209 261457 72453 47103 169861 272301 230061 81585 284753 73095 234537 215165 202275 21321 191453 109505 147541 22719 112239 120841 154425 40695 50263 161399 94711 176329 ...

output:

0
282792020
390855164
930244372
551852221
572398712
783972177
165531789
618176889
70735198
717208000
1
1
108063155
108063155
647452355
647452355
269060210
269060210
289606703
289606703
501180166
501180166
882739787
882739787
335384876
335384876
787943194
787943194
609144847
891936865
891936865
2
2
2...

result:

ok 150000 lines

Test #93:

score: 0
Accepted
time: 2323ms
memory: 68008kb

input:

149998 149998
62662 48289 206749 233 253507 111513 127153 285433 92570 74377 39423 208945 137815 182989 52743 55613 16243 78117 258567 282165 125179 72903 150659 122352 9167 213847 134077 260207 182657 288529 1537 230755 5677 7046 273589 157813 222203 26707 275559 65179 10465 203057 169123 263703 20...

output:

0
850839700
345652839
641006422
838666675
808473585
964588058
905124627
318035059
730791470
149160324
1
1
494813161
494813161
790166732
790166732
987826995
987826995
957633897
957633895
113748363
113748361
54284930
54284928
467195373
467195371
879951782
879951780
654347172
505186863
505186863
2
2
2
...

result:

ok 149998 lines

Test #94:

score: 0
Accepted
time: 2295ms
memory: 68816kb

input:

150000 150000
76608 298103 189579 57299 7065 100363 197625 140707 217161 247455 16187 150461 154060 293667 226147 253909 288999 153451 143949 75907 260513 259677 186819 81091 11737 61633 191324 114371 160337 49471 110141 177317 219447 139836 252911 1339 244851 162826 127435 247259 118063 298882 2253...

output:

0
838410842
450663429
512675329
286139463
683613847
24033587
208725575
429739692
650648977
161589190
1
1
612252617
612252617
674264497
674264497
447728649
447728649
845203027
845203025
185622763
185622761
370314753
370314751
591328870
591328868
812238153
812238151
549336582
387747415
387747415
2
2
2...

result:

ok 150000 lines

Test #95:

score: 0
Accepted
time: 112ms
memory: 68896kb

input:

150000 150000
189154 49514 151482 43460 49256 228966 268302 265220 130344 250548 64850 252480 153880 29198 64076 1378 85680 21482 154084 89994 29838 223680 18452 191610 121142 171352 165944 180144 31648 65268 178732 206152 189180 96558 188866 41548 111828 27354 293692 123362 16588 36866 260500 23468...

output:

0
595652496
918080784
344975290
316804909
215201770
658573403
62934399
954315383
845598856
404347514
1
1
322428291
322428291
749322802
749322802
721152423
721152423
619549282
619549282
62920910
62920910
467281911
467281911
358662890
358662890
249946361
249946361
81919225
677571721
677571721
2
2
2
42...

result:

ok 150000 lines

Subtask #8:

score: 1
Accepted

Test #96:

score: 1
Accepted
time: 473ms
memory: 100064kb

input:

300000 296149
120693 103294 197599 81478 180429 287231 207123 24953 276287 20750 183518 11100 101777 264363 152039 207542 70785 191815 130129 170975 116131 284586 139850 37287 139855 187905 100458 82326 291998 269296 208646 277820 183614 244575 220693 246340 201324 292765 198792 287243 248176 47419 ...

output:

1
655494174
655721476
979171024
70264706
40293225
780464444
833950831
806446020
778668951
344505833
1
1
227301
227301
323676851
323676851
414770538
414770538
384799059
384799059
124970269
124970269
178456658
178456658
150951845
150951845
123174778
123174778
344278535
999772708
999772708
1
1
3
323449...

result:

ok 296149 lines

Test #97:

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

input:

300000 300000
254106 72820 70385 280829 203046 139381 196949 175527 259532 21799 999 200669 111167 49239 279082 125815 247465 70484 25989 177379 278361 253948 1624 176769 148147 228707 223287 295978 143049 138783 197791 98278 289291 139520 136619 245635 256559 176913 184761 184022 87049 276763 33623...

output:

0
164352812
145347878
563522455
745992442
795268732
873818895
504938841
158402737
811651158
835647198
1
1
980995076
980995074
399169644
399169644
581639633
581639633
630915921
630915921
709466086
709466084
340586030
340586028
994049935
994049935
647298347
647298347
854652135
19004940
19004938
2
2
2
...

result:

ok 300000 lines

Test #98:

score: 0
Accepted
time: 1087ms
memory: 94964kb

input:

296039 300000
111467 1221 124039 79025 67064 180415 34845 4421 17405 238985 92691 297553 119159 40315 192993 78428 156253 13925 254369 13251 223713 229203 170631 192173 118645 284320 24069 273263 190907 223839 115626 267945 129623 262603 113040 36785 114423 38496 283139 196647 138428 118921 230932 1...

output:

2
820713512
502992234
314955017
124850613
711069961
661431630
623338196
581782512
540177274
179286500
3
1
682278734
682278732
494241517
494241513
304137115
304137111
890356459
890356459
840718126
840718126
802624696
802624694
761069010
761069008
719463774
719463772
497007777
317721282
317721280
4
2
...

result:

ok 300000 lines

Test #99:

score: 0
Accepted
time: 6311ms
memory: 94524kb

input:

299228 300000
249317 146315 210553 154509 211911 254001 175905 50225 70881 198085 6369 298504 34837 284069 141883 59925 238615 278607 217721 197841 228757 159359 179457 183957 125177 171909 93755 116037 2513 291171 136549 132859 92633 89387 64881 277549 98147 257029 34739 189473 124073 78847 124067 ...

output:

6
684230500
936289204
386499131
797958371
346497877
68662500
304900203
257711798
210411367
315769517
6
6
252058710
252058708
702268646
702268644
113727879
113727875
662267390
662267390
384432009
384432011
620669714
620669716
573481309
573481309
526180880
526180880
63710813
747941309
747941307
6
6
6
...

result:

ok 300000 lines

Test #100:

score: 0
Accepted
time: 836ms
memory: 99376kb

input:

298308 300000
171659 23255 50875 68887 193569 262453 39661 124783 69897 263409 140631 280067 2655 124715 191237 179211 117459 5663 286957 68291 49217 283033 225223 223947 23807 210319 288063 38631 8559 1491 14113 43155 3629 127395 106787 242527 130839 155669 261019 60959 208593 231797 5319 259699 45...

output:

227
376340077
66805269
95695342
41799131
915685598
185044968
168265408
772315021
376141965
623660385
228
226
690465429
690465427
719355502
719355498
665459293
665459289
539345687
539345747
808705072
808705126
791925506
791925564
395975116
395975172
999802065
999802121
933195192
309535037
309535035
2...

result:

ok 300000 lines

Test #101:

score: 0
Accepted
time: 312ms
memory: 97996kb

input:

297073 300000
265419 232751 156971 109089 50289 111567 162975 161517 80041 205973 258157 266469 155817 18079 269289 116249 192359 142311 265497 89429 114263 110675 267029 91447 89583 41611 208401 60705 237653 143077 155039 165119 26459 139849 214367 196365 293095 154665 121875 125709 269183 277089 2...

output:

31047
355509815
82606539
786028590
733470943
212241791
397347666
190113882
817679741
445061629
644552284
31047
31047
727127778
727127776
430549824
430549822
377992177
377992173
856779364
856763028
41885240
41868898
834651457
834635119
462217313
462200973
89599199
89582859
917455560
272934323
2729343...

result:

ok 300000 lines

Test #102:

score: 0
Accepted
time: 285ms
memory: 95792kb

input:

300000 300000
271724 145961 247007 265451 210839 6555 60105 221787 84303 13903 197913 28287 246043 27969 283291 234981 230173 252465 103233 84117 169297 295105 173257 218453 15495 216225 280051 145807 289807 189869 99883 44221 176289 4043 173383 161811 76599 96489 41235 5773 266139 292235 20345 2940...

output:

0
356841439
668471350
946855685
667406634
254267970
932894738
579756012
278060794
976329125
643758567
1
1
312229908
312229908
590014249
590014249
311165190
311165190
897726533
897726533
576353302
576353302
223214570
223214570
921519363
921519363
619787685
619787685
331528661
688370098
688370098
2
2
...

result:

ok 300000 lines

Test #103:

score: 0
Accepted
time: 313ms
memory: 93684kb

input:

300000 300000
88484 180747 248537 235983 219063 52783 2265 138579 261551 219969 49939 116381 179455 9493 291079 57059 167929 6565 29621 14567 38957 162747 258233 26931 130755 11073 74689 169695 103999 49677 239935 183511 135103 224185 20857 203537 76737 39621 18649 183733 83053 294801 107565 36869 1...

output:

0
944909832
104818613
101299696
795650817
441003382
104428292
247747415
372515630
496999423
55199264
1
1
160017875
160017875
156389874
156389874
850850077
850850077
496137882
496137882
159562792
159562792
302881913
302881913
427650128
427650128
552133919
552133919
895181398
840091221
840091221
2
2
2...

result:

ok 300000 lines

Test #104:

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

input:

300000 300000
12348 143197 133633 11327 77453 149409 136401 3463 213137 146891 193693 33319 285433 81183 255455 283095 69149 280649 174811 49425 26635 296377 130789 284349 145205 46435 139123 82663 33965 102947 253281 204735 86519 113351 9027 296017 135941 115421 298405 9733 127437 16099 170561 1680...

output:

0
701769453
302595526
80101228
424241198
144591490
97506336
717937727
734176540
750301695
298290161
1
1
600885685
600885685
378331785
378331785
722531355
722531355
442852557
442852555
395767411
395767409
16198789
16198787
32437606
32437604
48562759
48562757
697404485
399173929
399173929
2
2
2
777505...

result:

ok 300000 lines

Test #105:

score: 0
Accepted
time: 493ms
memory: 99092kb

input:

300000 300000
236662 23697 162705 289171 17683 67783 59351 145533 110317 7307 72150 56260 93625 30701 5439 150937 68933 123647 71301 165055 188855 194007 2531 144838 26851 147633 196755 222313 176922 50736 239553 118003 21993 286685 233463 167109 144935 254611 279135 264408 265723 247329 153773 2459...

output:

0
149879428
802656423
334121025
673672140
801948604
179449968
569485654
150676020
731689981
850120600
1
1
652777014
652777014
184241600
184241600
523792729
523792729
652069187
652069187
29570555
29570555
419606239
419606239
796609
796609
581810568
581810568
197343588
347223014
347223014
2
2
2
531464...

result:

ok 300000 lines

Test #106:

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

input:

299999 300000
253404 202485 91697 21905 113425 252271 112095 198973 107511 113074 35389 113828 8075 255263 177807 58447 189398 119589 283343 252151 252011 51075 131402 226951 201970 280564 104485 183647 110939 147255 88945 124155 116173 90589 112553 257863 262825 38489 124191 277313 201771 238105 68...

output:

0
949541380
692076739
874676764
84827620
416397298
880088262
185315957
755831975
326283586
50458646
1
1
742535383
742535383
925135394
925135394
135286262
135286262
466855938
466855938
930546900
930546900
235774599
235774599
806290615
806290615
376742228
376742228
307923272
257464643
257464643
2
2
2
...

result:

ok 300000 lines

Test #107:

score: 0
Accepted
time: 2090ms
memory: 98884kb

input:

300000 300000
168232 111353 235999 1821 123463 189063 211899 135511 293841 277227 251569 11073 88713 106762 84785 101829 215287 235071 108981 210921 131426 125599 116487 79185 61805 157941 128082 295533 102423 18571 134357 51881 184103 213769 88696 189873 57298 235845 251693 79081 279188 272439 1391...

output:

0
813306610
867745852
796786870
627720923
344513703
609725211
478494302
303377968
128214172
186693424
1
1
54439267
54439267
983480270
983480270
814414343
814414343
531207111
531207111
796418619
796418619
665187712
665187712
490071378
490071378
314907580
314907580
132254159
945560767
945560767
2
2
2
...

result:

ok 300000 lines

Test #108:

score: 0
Accepted
time: 6321ms
memory: 98556kb

input:

300000 299999
61498 41159 73437 115235 121895 250281 221071 204311 6233 1317 182274 278133 181292 52637 83501 67520 229745 180841 190117 128003 276405 143640 148525 116271 40949 124915 101735 290247 103041 166357 243145 231791 3801 293889 290573 254661 45786 95605 271121 195529 167921 103233 281293 ...

output:

0
864154106
935189092
110136074
534367858
202123441
636141334
414188757
38894775
663581724
135845922
1
1
71035005
71035005
245981978
245981978
670213776
670213776
337969353
337969351
771987246
771987244
550034671
550034669
174740689
174740687
799427636
799427634
64810919
928965023
928965023
2
2
2
17...

result:

ok 299999 lines

Test #109:

score: 0
Accepted
time: 6548ms
memory: 97492kb

input:

299995 299997
276394 39905 71743 256769 20407 80015 37435 81247 178381 89689 211001 69271 286194 62265 74639 205089 163295 266951 196053 139497 43407 17497 125073 35023 173963 13161 10076 133315 228547 84339 91607 260595 213899 136219 203917 242213 89427 127909 197551 244385 121029 82451 190389 8119...

output:

0
839763769
77012562
255481925
859139673
193566906
806379877
817047917
288515699
759685860
160236263
1
1
237248823
237248823
415718166
415718166
19375925
19375925
353803155
353803153
966616126
966616124
977284164
977284162
448751946
448751944
919922109
919922107
922987449
762751209
762751209
2
2
2
1...

result:

ok 299997 lines

Test #110:

score: 0
Accepted
time: 224ms
memory: 95144kb

input:

300000 300000
272998 5854 133304 94316 174178 54028 284472 83654 32598 136282 214336 221500 105506 1338 231816 68334 258124 229330 239840 288912 67158 8426 257124 38530 11424 84640 131758 159776 40128 158466 122634 217368 60426 2900 102648 167576 181410 115268 209718 15980 94010 296000 294258 27054 ...

output:

0
487234847
717291538
865285145
712269665
243668505
580529835
939171668
352723428
766231827
512765163
1
1
230056694
230056694
378050299
378050299
225034821
225034821
756433666
756433666
93294991
93294991
451936822
451936822
865488591
865488591
278996981
278996981
282708471
769943318
769943318
2
2
2
...

result:

ok 300000 lines

Subtask #9:

score: 1
Accepted

Test #111:

score: 1
Accepted
time: 526ms
memory: 94076kb

input:

300000 296183
253817 213650 26983 49231 54000 94314 180311 99764 58587 293526 40583 191616 195622 139856 66564 285086 175178 235177 197887 17396 130747 60756 109964 251539 149246 232925 188060 93753 144263 2885 158989 188531 196718 144960 214314 228199 43447 129862 227469 40824 18493 206587 29465 14...

output:

1
339343594
335179295
225479364
532993135
638772611
745280165
684683348
781647461
878525788
660656413
1
1
995835707
995835707
886135778
886135778
193649540
193649540
299429018
299429018
405936570
405936570
345339755
345339755
442303866
442303866
539182195
539182195
664820718
4164304
4164304
1
1
3
89...

result:

ok 296183 lines

Test #112:

score: 0
Accepted
time: 497ms
memory: 95752kb

input:

299986 300000
60250 211743 108759 177617 223929 83735 62784 207037 54456 46976 241539 118760 140499 178718 253197 118227 141644 236390 49896 162176 122587 174376 246080 273190 278223 215391 204502 202825 245795 122633 133746 22828 193860 81190 234116 189906 121188 168092 189728 90986 17679 119210 15...

output:

0
953975593
752664757
796418345
440006564
901071617
402399081
471748132
260583956
49241318
46024427
1
1
798689182
798689182
842442762
842442762
486030987
486030987
947096032
947096032
448423500
448423500
517772549
517772549
306608373
306608373
95265733
95265733
247335254
201310838
201310838
2
2
2
43...

result:

ok 300000 lines

Test #113:

score: 0
Accepted
time: 2057ms
memory: 95556kb

input:

300000 294496
163161 229025 253003 215993 23489 202863 5849 89479 165739 86771 94933 50019 114249 95201 93665 136299 285081 264191 232543 212221 285097 139487 190293 197927 284156 20031 106023 121507 68355 103927 165367 257463 265165 169619 108842 169385 197381 170277 111471 203761 222787 65077 2603...

output:

12
94748080
977338499
433084914
140257950
528101521
725409775
755833635
53944751
351765834
905251952
13
11
882590434
882590432
338336849
338336845
45509887
45509883
433353446
433353452
630661700
630661708
661085558
661085566
959196685
959196691
257017759
257017765
22661532
117409602
117409600
14
12
...

result:

ok 294496 lines

Test #114:

score: 0
Accepted
time: 6279ms
memory: 93684kb

input:

300000 299002
202183 180717 137013 100569 165757 203861 244315 156481 32921 198697 180891 18981 196685 210005 29443 243965 29929 60211 46191 184049 845 137447 51719 44423 154919 268607 24991 170589 12253 56073 286893 146685 7159 22127 205453 135449 180723 184335 164519 10827 31477 109893 264895 7565...

output:

520
788226583
542023374
932835008
106135402
808647286
835300054
258172847
957264967
656207542
211774462
520
520
753797318
753797316
144608947
144608945
317909348
317909344
20421247
20421223
47074015
47073989
469946817
469946791
169038926
169038902
867981510
867981486
457977671
246203729
246203727
52...

result:

ok 299002 lines

Test #115:

score: 0
Accepted
time: 503ms
memory: 94796kb

input:

295807 300000
4843 285375 94723 36593 256337 66769 221787 253 65183 66207 46265 282087 241683 190897 262375 274333 245635 25439 257035 244935 110031 294027 69171 136615 257989 257037 48931 69751 101145 147737 130343 4191 199969 137675 289491 293673 97141 40697 60973 288095 281477 126911 185585 27431...

output:

1809
601589084
138144984
757311372
299228571
938932960
312855934
983192812
145296325
307346967
398414542
1810
1808
536557719
536557717
155724100
155724096
697641308
697641304
337346172
337345686
711269153
711268665
381606026
381605538
543709546
543709056
705760190
705759700
861858641
463445911
46344...

result:

ok 300000 lines

Test #116:

score: 0
Accepted
time: 5554ms
memory: 97360kb

input:

300000 296272
216242 283404 86257 80956 87211 253771 268890 90489 124615 176227 3942 108393 237075 286987 284285 277828 117981 170627 273385 42623 191331 175712 55193 85409 157723 133579 108997 256627 193608 286495 276663 132763 100385 232745 245809 2167 258996 162987 122019 276479 131435 181633 237...

output:

0
383466874
451068702
78627827
408122001
431001007
373547219
187521729
280095947
372417643
616533136
1
1
67601831
67601829
695160961
695160959
24655130
24655130
47534134
47534132
990080355
990080355
804054863
804054861
896629083
896629083
988950777
988950777
548931309
932398183
932398181
2
2
0
62755...

result:

ok 296272 lines

Test #117:

score: 0
Accepted
time: 313ms
memory: 95024kb

input:

300000 300000
273092 13787 213857 149961 175695 133865 25433 233431 160431 294253 58977 277835 97261 199119 150405 89535 69467 79441 229573 241173 153297 168691 61205 49067 248469 61945 216943 222709 201785 133089 219493 8773 275619 113549 6431 261813 280461 223891 212695 134359 269553 91031 64101 1...

output:

0
497334635
197135210
842985120
178318715
943416895
801713113
108843796
551115045
993165746
503166923
1
1
700302131
700302131
345650488
345650488
681485634
681485634
446283815
446283815
304580033
304580033
611710721
611710721
53981963
53981963
496032662
496032662
802864801
300199427
300199427
2
2
2
...

result:

ok 300000 lines

Test #118:

score: 0
Accepted
time: 339ms
memory: 94924kb

input:

300000 300000
135164 19611 259565 215387 33473 108557 71021 134527 69587 197779 53935 292051 21933 272777 15775 66609 248945 179789 213053 207555 74637 243955 123701 260275 265091 236233 150875 17655 80687 193791 119271 174935 182233 137115 142507 146505 182697 73043 208245 166525 129019 229987 1262...

output:

0
784016663
292367843
797055056
75618734
600756882
30495075
745690762
38881021
331865571
216078789
1
1
508446630
508446630
13038396
13038396
291697519
291697519
816798451
816798451
246536652
246536652
961732333
961732333
254922596
254922596
547907144
547907144
707632168
491648822
491648822
2
2
2
504...

result:

ok 300000 lines

Test #119:

score: 0
Accepted
time: 376ms
memory: 93592kb

input:

300000 300000
249448 217841 80813 193637 144767 15015 229535 123101 26285 14647 56917 243403 183035 63791 177255 225437 11419 97061 202823 152977 40117 161301 114873 235845 243563 209183 299125 20525 42595 162997 229439 56827 279623 234093 116797 131879 190281 200793 240381 268231 166361 249265 1780...

output:

0
828187597
360758300
497290540
763779634
457446823
337155112
931444732
643107876
354734650
171838757
1
1
532597055
532597055
669102953
669102953
935618387
935618387
629259238
629259236
508967527
508967525
103257138
103257136
814920289
814920287
526547061
526547059
639241711
467429299
467429299
2
2
...

result:

ok 300000 lines

Test #120:

score: 0
Accepted
time: 637ms
memory: 96768kb

input:

299998 300000
56094 217343 16515 237693 261421 14185 173722 242547 283359 22849 193057 204869 16547 193443 91739 260889 45677 110827 281579 3631 122795 105970 110367 42957 216429 129067 199727 271851 79685 26943 193274 204432 274769 199241 239911 81363 117321 263775 203661 59619 13073 210603 184673 ...

output:

0
847511703
23691054
401448030
199668558
979290229
36837859
414960066
517825596
620555414
152488317
1
1
176179369
176179369
553936337
553936337
352156871
352156871
131778535
131778535
189326172
189326172
567448377
567448377
670313907
670313907
773043723
773043723
976308957
823820651
823820651
2
2
2
...

result:

ok 300000 lines

Test #121:

score: 0
Accepted
time: 1270ms
memory: 94512kb

input:

300000 300000
119800 92463 70479 287605 13883 156973 75437 148155 242038 140617 65793 154641 212609 31341 6197 165621 187195 180703 35245 105751 121129 236857 172057 176592 29897 66893 134589 276228 54598 8781 159415 62397 189467 187249 127985 30155 221333 58857 111853 208340 46062 79047 90849 12471...

output:

0
204645506
711117565
279750400
645971777
702837505
7235788
664208873
613299441
562151097
795354518
1
1
506472074
506472074
75104897
75104897
441326284
441326284
498192008
498192006
802590302
802590300
459563378
459563376
408653946
408653944
357505600
357505598
288882446
493527950
493527950
2
2
2
56...

result:

ok 300000 lines

Test #122:

score: 0
Accepted
time: 2706ms
memory: 93864kb

input:

300000 299999
44700 30226 146327 84201 254761 75909 62017 224289 3913 83574 185568 228961 178245 41071 17593 281693 275199 52894 11817 78657 171713 297111 141561 78046 274321 14947 8927 213333 151997 181479 117888 46247 117181 265797 110011 209315 118787 79039 263633 240387 250391 275591 219661 2454...

output:

0
795360442
538486075
455134685
782084843
483900177
272039557
166199496
34621108
902906307
204639568
1
1
743125643
743125641
659774251
659774251
986724411
986724409
688539743
688539743
476679125
476679123
370839062
370839062
239260676
239260674
107545866
107545864
461513948
256874383
256874381
2
2
2...

result:

ok 299999 lines

Test #123:

score: 0
Accepted
time: 6373ms
memory: 95768kb

input:

300000 300000
156138 237023 294481 127845 180961 8880 236935 248827 14353 248271 92177 111195 39349 166415 126051 16268 45205 160947 85525 265703 235283 85118 230453 271219 277953 80073 237587 40107 106225 39123 106882 108101 219981 233005 11269 84911 178241 159785 72361 267501 226449 6817 253148 26...

output:

0
445895920
144508608
868468936
433548708
45632136
772681684
816919695
634369423
451575551
554104098
1
1
698612704
698612704
422573019
422573019
987652802
987652802
599736230
599736230
326785771
326785771
371023784
371023784
188473512
188473512
5679638
5679638
855491403
301387314
301387314
2
2
2
723...

result:

ok 300000 lines

Test #124:

score: 0
Accepted
time: 6313ms
memory: 93076kb

input:

300000 299998
295890 130277 272927 194457 22959 68417 169487 271315 62247 138787 206053 46109 24784 212933 84589 182371 296983 211897 84939 74139 226183 150801 151323 118817 17323 70747 275455 188999 127133 256755 51323 155511 90077 268717 227457 229765 151741 233997 64653 114191 180097 279121 70007...

output:

0
508675310
920231271
389374265
416532811
432649316
138166058
365000344
240247391
115456704
491324722
1
1
411555984
411555984
880698965
880698965
907857529
907857529
923974024
923974022
629490770
629490768
856325054
856325052
731572105
731572103
606781416
606781414
79768740
588444048
588444048
2
2
2...

result:

ok 299998 lines

Test #125:

score: 0
Accepted
time: 261ms
memory: 94552kb

input:

300000 300000
285747 251307 160027 247847 198027 257503 62959 234079 15507 188945 213329 22125 193645 16653 186107 296251 88201 236975 70545 20645 227243 247875 254107 153515 252849 172473 243701 23827 168927 37831 65603 228539 219965 11991 119503 142635 77009 229241 209819 225171 66755 256961 22329...

output:

150000
185877011
13234741
622223594
868341442
514130183
864613005
495878448
98955891
702031841
814422994
150000
150000
827507737
827507735
436496585
436496583
682614433
682614429
328703166
328403172
679185988
678885992
310451433
310151437
913528883
913228885
516604828
516304830
987065264
172792270
1...

result:

ok 300000 lines

Subtask #10:

score: 1
Accepted

Test #126:

score: 1
Accepted
time: 495ms
memory: 97952kb

input:

300000 300000
142087 155563 179354 154435 173470 148675 120962 42971 161352 62432 183381 152465 279212 196345 258512 234427 187069 203076 299221 283407 112019 184133 286485 176058 206744 195289 280945 4032 3580 143823 10895 87359 274130 86109 62335 49505 276722 141225 26523 23127 199179 253026 16668...

output:

1
633965867
429677283
679356197
596672370
700733700
439635651
762021800
397011706
31894398
366034143
2
0
795711427
795711425
45390330
45390330
962706512
962706512
66767833
66767833
805669793
805669793
128055933
128055933
763045848
763045848
397928538
397928538
570322726
204288587
204288585
3
1
1
249...

result:

ok 300000 lines

Test #127:

score: 0
Accepted
time: 532ms
memory: 95000kb

input:

300000 299766
11413 168042 180336 98285 42644 242001 167744 14794 149162 175682 152881 255993 220827 104680 59999 193149 292045 229529 23259 92557 295099 148392 237121 147991 164759 193197 207357 238324 212039 23516 287815 245254 92768 287502 54836 176032 240971 152383 182126 112961 11713 37161 2841...

output:

1
298145167
985878050
729339401
880753457
912800373
8398508
223384385
350066432
476587401
701854840
1
1
687732882
687732882
431194235
431194235
582608289
582608289
614655207
614655207
710253347
710253347
925239226
925239226
51921264
51921264
178442235
178442235
14121959
312267125
312267125
1
1
1
743...

result:

ok 299766 lines

Test #128:

score: 0
Accepted
time: 3876ms
memory: 94476kb

input:

300000 300000
111725 164171 62281 156091 226559 284825 126491 33333 66351 202797 206863 20983 79961 290583 60175 217657 100573 274553 287919 288825 237631 109947 54249 90789 11621 151271 259887 166505 221209 285115 291451 96569 105365 171945 258247 175975 216823 293219 109711 236091 213407 243467 21...

output:

34
517328520
291963632
554585952
943602434
814063395
52923247
410975247
280839644
150566779
482671553
34
34
774635153
774635151
37257468
37257466
426273950
426273946
296734915
296734909
535594774
535594766
893646772
893646768
763511169
763511163
633238306
633238300
708036441
225364922
225364920
34
3...

result:

ok 300000 lines

Test #129:

score: 0
Accepted
time: 2141ms
memory: 94756kb

input:

294587 296170
146501 16945 134293 213983 287711 238953 59557 237393 138475 158347 112115 111803 233973 178759 183875 283511 13763 295733 224785 277447 244017 153235 75265 274065 220115 24599 88765 201805 44533 203277 107447 200499 247985 130119 226537 25289 60303 184879 84961 255005 283733 269443 10...

output:

1207
285957340
861085934
846197223
575998781
639799460
136238641
474753324
224958355
975092215
714045079
1207
1207
575129801
575129799
560241092
560241090
290042650
290042646
353843439
353843325
850282627
850282515
188797301
188797189
939002339
939002229
689136190
689136080
138916485
424872620
42487...

result:

ok 296170 lines

Test #130:

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

input:

300000 300000
115071 292515 18569 216129 186535 16289 238439 36819 259789 105143 44605 205059 275299 87637 236455 258309 271049 71469 143911 167749 111699 211171 230029 194443 183381 32577 140167 74875 284391 204337 62701 53633 112089 155175 205949 43037 80685 284597 261353 134307 29831 58009 164997...

output:

1079
949621827
557406041
369038670
222428935
994839108
775842820
436481104
434923707
433070980
50380339
1080
1078
607785303
607785301
419417932
419417928
272808199
272808195
45218357
45218359
826222084
826222080
486860362
486860362
485302969
485302967
483450240
483450238
442596124
392216867
39221686...

result:

ok 300000 lines

Test #131:

score: 0
Accepted
time: 5294ms
memory: 93340kb

input:

300000 300000
278320 92634 54763 41502 255293 120599 64788 227517 84491 15001 162444 107941 107173 85845 165997 296314 240705 188295 187789 245845 115327 125058 164297 61955 104443 24913 108583 71039 126288 129317 146783 12553 144023 177355 220799 263685 257478 267277 13123 254181 205061 284135 8082...

output:

321373790
678926990
678926990
678926990
678926990
321373790
321373790
321373790
678926990
321373790
321373790
321373790
678926990
321373790
321373790
321373790
678926990
321373790
678926990
321373790
678926990
321373790
678926990
321373790
321373790
321373790
321373790
678926990
678926990
678926990
...

result:

ok 300000 lines

Test #132:

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

input:

300000 300000
137086 194047 147153 284443 23857 79815 42877 571 136169 209871 34775 44417 22039 275005 288753 284147 621 122103 102915 129973 33691 131059 33097 1811 270297 93781 265639 297607 187653 39379 51637 196885 60839 217015 165097 193665 56271 189787 125953 204007 193167 8081 230151 298701 2...

output:

0
746312714
424361948
434728619
630110352
850424844
694043590
533445448
915039991
296533217
253868294
1
1
678230240
678230240
688415915
688415915
883978642
883978642
104151559
104151557
947770320
947770318
787172172
787172170
168766712
168766710
550259943
550259941
575638063
321950768
321950768
2
2
...

result:

ok 300000 lines

Test #133:

score: 0
Accepted
time: 346ms
memory: 93028kb

input:

300000 300000
118636 211679 215775 277637 283541 261969 232495 183927 244601 49365 45493 110917 141293 26101 288407 38397 132535 257379 132623 228935 139169 86047 97511 48045 49189 39059 222779 90443 20341 234023 155311 163463 18903 277515 241805 278071 146689 230251 132237 51005 102669 202719 79879...

output:

0
745841263
982740436
37877537
713707569
106697606
354205896
850419444
581166866
311643572
254196675
1
1
236937102
236937102
292036284
292036284
967904240
967904240
360862867
360862867
608371157
608371157
104584696
104584696
835332125
835332125
565808829
565808829
17259575
763100836
763100836
2
2
2
...

result:

ok 300000 lines

Test #134:

score: 0
Accepted
time: 389ms
memory: 93816kb

input:

300000 297640
228830 176639 105841 71937 48179 86115 81225 144941 282619 233967 161963 165873 77251 274173 229107 36215 50851 44017 66021 90687 166667 195283 68959 193389 248245 225909 64181 213799 293521 217909 137335 101095 31477 182759 207953 82133 76779 125469 295855 194647 1975 39771 101919 262...

output:

0
963513112
940549401
33074993
550977200
176018647
156826573
535782276
166925171
798051173
36499172
1
1
977048571
977048571
69561891
69561891
587476368
587476368
212513935
212513935
193321869
193321869
572277566
572277566
203420465
203420465
834546465
834546465
59450610
22963713
22963713
2
2
2
92525...

result:

ok 297640 lines

Test #135:

score: 0
Accepted
time: 812ms
memory: 93112kb

input:

299995 300000
235202 246457 23539 285199 65973 180025 188085 242331 214399 237082 172063 280553 103573 211049 191215 74681 185393 109369 7625 155579 269809 90814 299115 175265 4752 224613 136771 254248 202535 120653 226887 50673 290315 252019 172520 141095 291271 71105 296756 299284 79799 178377 248...

output:

0
198963984
442496241
137796259
992167592
150664264
72985983
997215003
316758486
636259868
801036042
1
1
243532274
243532274
938832285
938832285
793203623
793203623
951700298
951700296
874022021
874022019
798251032
798251030
117794515
117794513
437295899
437295897
557503770
756467752
756467752
2
2
2...

result:

ok 300000 lines

Test #136:

score: 0
Accepted
time: 1805ms
memory: 98356kb

input:

300000 300000
178792 135663 208401 278725 196461 295035 233671 248243 162551 235035 170158 17645 40967 233753 199285 44611 150109 242225 203623 90434 106249 97299 86055 134771 185621 36616 240650 103525 57263 125857 202319 255290 65283 91715 222643 124247 266871 220831 139457 296643 280571 38321 264...

output:

0
130622005
761417631
687375049
650031300
579479745
517484456
113416204
400542385
687494498
869378023
1
1
630795645
630795645
556753047
556753047
519409312
519409312
448857747
448857745
386862462
386862460
982794211
982794209
269920389
269920387
556872500
556872498
238582380
369204383
369204383
2
2
...

result:

ok 300000 lines

Test #137:

score: 0
Accepted
time: 3080ms
memory: 93248kb

input:

299995 299999
196492 225251 84299 103675 177401 111639 179971 147499 123039 298779 126497 274645 243197 14373 113427 229629 65871 208287 193363 171913 183509 192433 160223 17719 138499 35625 196879 273487 162517 228395 208803 92885 71463 291107 26173 247553 72549 36157 109957 225113 117103 176599 24...

output:

0
537092906
582325550
424616755
408054262
68412655
591086126
470680035
916291030
361832412
462907424
1
1
45232965
45232965
887523859
887523859
870961682
870961682
531319941
531319941
53993401
53993401
933587319
933587319
379198303
379198303
824739694
824739694
417674461
954767365
954767365
2
2
2
842...

result:

ok 299999 lines

Test #138:

score: 0
Accepted
time: 6283ms
memory: 94024kb

input:

299996 299998
90954 114413 264313 18841 233507 297587 289267 160753 148613 29538 209413 271049 19675 63673 203179 93365 125335 55143 143319 123755 79957 68923 81383 120882 161621 73969 176267 156349 206361 55049 39895 74535 62061 248623 53301 62630 25421 269817 253267 31911 152609 87161 11089 17576 ...

output:

0
90829507
958494563
26415653
572640598
855494085
610383255
532639116
532150144
531372880
909170519
1
1
867665073
867665073
935586156
935586156
481811106
481811106
764664585
764664583
519553759
519553757
441809614
441809612
441320646
441320644
440543380
440543378
41505448
132334953
132334953
2
2
2
6...

result:

ok 299998 lines

Test #139:

score: 0
Accepted
time: 6511ms
memory: 93036kb

input:

300000 300000
224286 104099 67717 96205 209387 204969 58923 169917 277429 39623 250816 282941 89822 48663 260151 25741 52525 225053 228527 147157 241923 20247 139147 94879 219751 124299 58993 154094 34857 84267 200267 117969 56463 266309 23796 105801 28013 108121 260539 162849 119759 78477 157253 17...

output:

0
349548481
853157695
607064093
41302545
201101585
296430476
251669703
157529417
63117101
650451547
1
1
503609233
503609233
257515615
257515615
691754088
691754088
851553124
851553124
946882011
946882011
902121240
902121240
807980954
807980954
713568636
713568636
146842316
496390795
496390795
2
2
2
...

result:

ok 300000 lines