QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#558073#8672. 排队robertfan100 ✓1390ms92148kbC++142.0kb2024-09-11 13:58:532024-09-11 13:58:54

Judging History

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

  • [2024-09-11 13:58:54]
  • 评测
  • 测评结果:100
  • 用时:1390ms
  • 内存:92148kb
  • [2024-09-11 13:58:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int l[1000006],r[1000006],ans[1000006];
struct node{
	int l,r,id;
	friend bool operator<(node a,node b){
		return a.l<b.l;
	}
}a[1000006];
struct segnode{
	int val,tag;
	void plz(int u){
		val+=u;
		tag+=u;
	}
}seg[4000006];
void push_down(int u){
	seg[u<<1].plz(seg[u].tag);
	seg[u<<1|1].plz(seg[u].tag);
	seg[u].tag=0;
}
int query(int u,int l,int r,int val){
	if(seg[u].val<=val)return l-1;
	if(l==r)return l;
	push_down(u);
	int mid=l+r>>1;
	if(seg[u<<1|1].val>val){
		return query(u<<1|1,mid+1,r,val);
	}else return query(u<<1,l,mid,val);
}
void update(int u,int l,int r,int ql,int qr){
	if(ql>qr)return ;
	if(ql<=l&&r<=qr){
		seg[u].plz(1);
		return ;
	}push_down(u);
	int mid=l+r>>1;
	if(ql<=mid)update(u<<1,l,mid,ql,qr);
	if(qr>mid)update(u<<1|1,mid+1,r,ql,qr);
	seg[u].val=max(seg[u<<1].val,seg[u<<1|1].val);
}
vector<pair<int,int> >g[1000006];
int push(int u,int l,int r,int pos){
	if(l==r){
		return seg[u].val;
	}
	int mid=l+r>>1;
	push_down(u);
	if(pos<=mid)return push(u<<1,l,mid,pos);
	else return push(u<<1|1,mid+1,r,pos);
}
int id[1000006];
int main(){
	int n,q;
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		cin>>l[i]>>r[i];
	}
	for(int i=1;i<=q;i++){
		cin>>a[i].l>>a[i].r;
		a[i].id=i;
		g[a[i].r].push_back({a[i].l,a[i].id});
	}
	sort(a+1,a+1+q);
	for(int i=1;i<=q;i++){
		id[a[i].l]=i;
	}
	int pos=1;
	for(int i=1;i<=n;i++){
		while(a[pos].l==i)pos++;
		update(1,1,n,max(1,query(1,1,n,r[i])+1),min(query(1,1,n,l[i]-1),i));
		for(pair<int,int>a:g[i]){
			ans[a.second]=push(1,1,n,a.first);
		}
//		COUT<<PUSH(1,1,N)
	}
	for(int i=1;i<=q;i++){
		cout<<ans[i]<<'\n';
	}
}
/*
things to check
0.delete cerr code or use '//'
1.initallize(especially multicases)
2.int overflow/long long mle
3.if make the ans is hard , try 2-divided
4.memory &b-&a
5.function canshu position
6.the format of input
7.size enough ?
8.the name of function
9.stop copying x0->y0
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 36324kb

input:

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

output:

1
3
1

result:

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

Test #2:

score: 10
Accepted
time: 4ms
memory: 36452kb

input:

5000 5000
5 10
3 9
3 8
2 7
2 5
3 6
1 5
0 2
7 8
2 10
0 3
3 6
4 6
1 6
4 8
7 8
2 7
3 4
4 9
7 8
2 9
2 5
3 6
0 5
6 7
1 2
2 4
2 10
1 5
7 9
6 9
2 3
9 10
5 5
2 9
3 3
2 7
2 4
0 6
0 3
1 7
7 7
4 8
2 9
4 8
0 10
1 8
1 1
2 7
5 9
1 7
1 7
1 4
2 4
1 4
2 9
1 7
4 7
3 8
1 3
4 6
1 5
1 6
0 0
3 9
4 7
2 8
1 8
1 2
7 8
2 7
2...

output:

11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

ok 5000 numbers

Test #3:

score: 10
Accepted
time: 8ms
memory: 36432kb

input:

5000 5000
33 36
10 96
0 89
45 59
4 38
16 26
7 83
3 45
37 78
32 57
19 58
24 88
81 87
24 68
18 38
50 78
27 92
61 98
1 13
8 63
33 55
38 76
18 43
64 72
24 93
7 34
1 38
44 72
5 36
62 71
6 72
8 53
22 93
75 78
24 69
10 38
31 99
12 100
57 67
22 65
34 44
37 88
3 48
62 84
62 79
5 68
1 18
49 57
45 64
6 38
37 3...

output:

101
101
101
101
63
101
101
101
99
100
28
86
101
92
101
101
101
101
101
101
101
101
99
101
101
101
101
92
101
101
4
101
101
101
101
101
101
74
101
101
101
101
101
101
41
101
101
51
101
101
101
101
101
101
101
100
101
101
100
101
101
101
101
101
94
101
101
101
101
101
101
46
101
99
101
101
7
101
95
10...

result:

ok 5000 numbers

Test #4:

score: 10
Accepted
time: 6ms
memory: 38492kb

input:

5000 5000
332 468
241 278
90 259
397 412
212 317
55 238
173 296
176 184
67 260
51 95
117 184
37 276
122 441
226 401
43 244
127 186
34 493
38 221
3 4
67 122
45 486
5 91
64 158
74 394
134 188
229 265
155 422
221 403
176 252
28 98
94 250
133 133
107 281
13 347
154 209
203 271
12 325
33 318
181 220
27 2...

output:

500
11
490
491
501
2
7
490
468
140
501
494
215
1
499
186
494
483
495
483
0
85
31
1
345
492
24
0
443
24
1
500
484
466
501
498
500
496
0
89
396
1
84
324
500
491
436
471
436
430
484
185
358
367
484
488
38
332
13
0
411
28
498
501
498
307
55
258
101
376
139
455
299
501
119
20
501
14
500
501
273
291
1
107...

result:

ok 5000 numbers

Test #5:

score: 10
Accepted
time: 12ms
memory: 40592kb

input:

5000 5000
67 104
31 155
488 834
533 622
20 899
560 652
91 910
362 683
173 699
241 251
130 644
276 631
712 926
54 840
142 440
88 566
387 997
54 771
579 866
107 862
241 467
26 289
448 701
482 584
118 632
120 419
480 654
271 699
78 621
251 509
140 689
213 356
681 930
371 412
0 142
590 853
557 711
387 5...

output:

13
5
586
0
215
95
471
38
4
268
134
731
118
855
701
5
36
868
2
713
23
47
0
615
390
406
251
9
913
163
841
15
1
829
61
152
111
3
468
517
112
6
6
243
31
0
9
752
187
208
105
0
229
242
773
340
0
34
0
686
22
112
65
13
231
867
911
177
83
3
125
22
43
22
47
186
87
416
871
7
0
38
187
743
357
645
144
854
6
20
6...

result:

ok 5000 numbers

Test #6:

score: 10
Accepted
time: 7ms
memory: 36584kb

input:

5000 5000
1484 3115
596 3914
2334 3936
2782 3399
176 1270
3695 4175
4185 4222
2165 2301
321 4460
33 35
679 1844
443 2424
292 520
796 995
1014 4510
1053 3456
589 4211
514 3195
449 4153
1314 4247
1388 1736
1301 2724
1555 1950
413 4176
3501 4606
396 1492
521 2047
125 3192
677 1709
317 1833
444 1562
120...

output:

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

result:

ok 5000 numbers

Test #7:

score: 10
Accepted
time: 3ms
memory: 38548kb

input:

5000 5000
0 33
0 96
0 89
0 59
0 4
0 16
0 83
0 3
0 78
0 57
0 58
0 88
0 81
0 68
0 38
0 50
0 92
0 98
0 1
0 63
0 55
0 76
0 43
0 64
0 93
0 34
0 1
0 72
0 5
0 71
0 72
0 8
0 93
0 78
0 69
0 10
0 99
0 100
0 57
0 65
0 44
0 88
0 48
0 84
0 79
0 68
0 1
0 49
0 45
0 6
0 37
0 27
0 50
0 57
0 94
0 89
0 78
0 83
0 74
0 ...

output:

101
101
101
101
91
101
101
101
99
100
90
97
101
98
101
101
101
101
101
101
101
101
101
101
101
101
101
97
101
101
74
101
101
101
101
101
101
98
101
101
101
101
101
101
86
101
101
82
101
101
101
101
101
101
101
100
101
101
101
101
101
101
101
101
96
101
101
101
101
101
101
96
101
101
101
101
69
101
1...

result:

ok 5000 numbers

Test #8:

score: 10
Accepted
time: 7ms
memory: 38412kb

input:

5000 5000
0 67
0 31
0 488
0 622
0 899
0 560
0 910
0 362
0 699
0 251
0 644
0 276
0 926
0 840
0 440
0 566
0 997
0 771
0 579
0 107
0 467
0 289
0 448
0 482
0 632
0 120
0 480
0 699
0 621
0 251
0 689
0 213
0 930
0 371
0 0
0 590
0 711
0 387
0 73
0 466
0 430
0 847
0 201
0 63
0 64
0 234
0 265
0 133
0 697
0 3...

output:

749
415
945
338
865
820
943
812
610
883
842
947
850
985
958
617
869
978
356
969
807
739
447
945
921
901
892
492
987
823
969
449
233
983
675
834
885
236
927
932
800
627
401
914
863
73
630
954
909
860
852
31
917
863
966
914
281
770
323
959
664
810
808
739
886
979
988
773
726
249
902
714
736
761
791
88...

result:

ok 5000 numbers

Test #9:

score: 10
Accepted
time: 7ms
memory: 36440kb

input:

5000 5000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 0
0 0
0 20
0 21
0 22
0 0
0 24
0 25
0 0
0 27
0 0
0 0
0 0
0 31
0 32
0 33
0 34
0 35
0 36
0 0
0 38
0 39
0 40
0 41
0 42
0 0
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 0
0 53
0 54
0 55
0 0
0 0
0 58
0 59
0 60
0 61
0 62
0...

output:

406
752
1297
49
190
3029
1175
1826
550
787
30
3676
1099
2402
929
2810
1655
931
172
3198
3561
2845
1688
1754
849
853
816
2603
2591
442
309
1545
211
434
368
1084
1355
1641
239
412
680
1830
421
1175
1950
3000
567
1912
2576
1674
223
2381
575
309
1763
1568
813
290
1187
1217
1381
448
910
1147
536
1058
833...

result:

ok 5000 numbers

Test #10:

score: 10
Accepted
time: 5ms
memory: 38416kb

input:

5000 5000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 0
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 0
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
0 60
...

output:

3044
1914
39
1760
154
2146
1494
2629
2354
494
1295
743
1203
1771
2288
755
1126
1008
2095
469
625
897
2206
2712
3357
3098
1488
364
1360
949
1680
2016
876
2110
1943
79
1796
2114
425
1082
2584
1384
2842
668
3879
510
1589
3110
3295
2984
1268
1399
1381
212
1626
1134
1029
4271
1227
1991
4006
873
1463
748
...

result:

ok 5000 numbers

Test #11:

score: 10
Accepted
time: 5ms
memory: 38464kb

input:

5000 5000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 0
0 0
0 20
0 21
0 22
0 0
0 24
0 25
0 0
0 27
0 0
0 0
0 0
0 31
0 32
0 33
0 34
0 35
0 36
0 0
0 38
0 39
0 40
0 41
0 42
0 0
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 0
0 53
0 54
0 55
0 0
0 0
0 58
0 59
0 60
0 61
0 62
0...

output:

2107
1855
3981
3461
1876
3487
2007
2882
3200
3851
2340
3687
3180
3603
2309
3727
4113
1187
196
3362
3819
3448
1765
2834
2470
2711
3443
4174
2923
1586
3779
4041
2075
1788
2375
1913
1991
2405
3176
3644
1457
1946
3752
3358
2150
3494
2273
2120
2999
3913
2110
3604
4062
1986
1877
2867
2910
3133
3677
2634
3...

result:

ok 5000 numbers

Subtask #2:

score: 15
Accepted

Test #12:

score: 15
Accepted
time: 185ms
memory: 45680kb

input:

200000 200000
3 6
3 3
6 10
1 7
2 7
6 9
4 6
3 4
0 8
0 6
3 5
3 4
1 8
7 8
4 5
0 3
1 5
2 9
1 2
1 2
3 4
5 7
6 10
3 9
4 7
1 6
2 6
1 7
2 5
1 7
6 8
1 1
0 7
7 8
0 9
1 7
3 8
3 7
1 2
4 8
5 6
0 6
5 6
2 7
2 6
0 6
0 6
1 7
2 5
0 3
0 3
7 10
3 8
0 2
3 4
3 7
4 9
0 6
4 7
2 6
8 10
2 10
4 10
3 3
2 6
4 5
3 9
1 8
1 2
2 9
...

output:

11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

ok 200000 numbers

Test #13:

score: 15
Accepted
time: 193ms
memory: 45820kb

input:

200000 200000
5 45
27 99
7 23
51 88
16 62
10 24
16 80
43 70
12 45
35 55
6 99
77 91
40 82
66 99
30 47
18 80
9 36
4 12
26 51
37 64
39 52
2 11
2 69
57 81
15 98
8 36
19 27
32 34
35 97
22 23
15 89
53 77
2 89
25 55
25 90
4 91
13 77
37 65
67 89
8 52
20 58
10 18
31 81
35 59
41 56
71 74
18 61
56 77
51 74
40 ...

output:

101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
0
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
10...

result:

ok 200000 numbers

Test #14:

score: 15
Accepted
time: 193ms
memory: 47012kb

input:

200000 200000
193 894
142 229
346 553
197 496
389 718
370 600
650 853
476 695
764 767
220 571
238 714
516 700
137 692
1 293
835 962
34 536
208 482
148 225
377 804
75 864
277 925
278 864
296 647
390 757
179 283
338 602
571 746
447 852
315 365
7 390
634 689
76 239
16 60
244 388
385 822
451 836
301 373...

output:

1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
961
999
1001
1001
1001
1001
1001
1001
981
1001
1001
1001
1001
1001
1001
1001
966
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001...

result:

ok 200000 numbers

Test #15:

score: 15
Accepted
time: 201ms
memory: 44844kb

input:

200000 200000
3145 7698
6037 6154
6483 6707
6834 7442
7373 9621
5166 8045
7346 8938
2235 5518
2240 4134
586 3188
3845 8054
1258 5380
2409 2631
3360 5706
19 2771
1925 9642
6687 8264
4305 8055
2844 5474
2282 7810
1738 4706
1462 7466
17 6282
2481 6022
2363 2987
3633 4157
1460 2634
4866 8159
3154 5079
2...

output:

9965
10001
0
10001
10001
10001
9991
10001
4831
9935
5274
10001
10001
2
10001
10001
10001
10001
9991
10001
10001
10001
10001
9935
9994
10001
9742
10001
10001
0
9982
10001
10001
10001
10001
10001
80
0
9991
9763
8
10001
9975
9939
10001
10001
9092
9983
9333
10001
10001
10001
10001
10001
10001
10001
9965...

result:

ok 200000 numbers

Test #16:

score: 15
Accepted
time: 171ms
memory: 42820kb

input:

200000 200000
15540 44932
12196 33126
776 23774
35673 42863
31231 44618
16521 19781
8467 9747
5319 42216
13940 21955
3389 6981
22 11576
15248 17307
5734 35942
12762 45217
30349 47977
8869 11242
11199 25942
3415 10196
20104 40771
8813 28517
29726 34188
13420 13731
17526 30474
1033 44930
3143 10541
46...

output:

8
31
33781
8
161
3
618
14580
3
25947
1415
455
2
147
16877
21598
539
56
7425
6686
4
393
4
4
4378
176
24
1407
837
19
14
7146
7
19626
21422
9
20472
0
200
3514
2
380
35942
35129
1
216
3
312
1200
2519
4046
9
1734
1318
21862
3361
27414
52
38201
2303
635
235
1
17
271
24468
29
1029
1071
38200
10968
95
4
125...

result:

ok 200000 numbers

Test #17:

score: 15
Accepted
time: 184ms
memory: 49940kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
...

output:

74058
156458
175945
88572
145372
79026
163392
139232
188241
158454
17719
20452
171150
171343
104047
159458
132045
70328
136937
64711
174467
69614
125002
131739
81388
166709
80139
138489
34431
142820
179669
125831
148484
115982
184021
189596
73421
151270
194210
134276
117448
129846
127920
160607
1132...

result:

ok 200000 numbers

Test #18:

score: 15
Accepted
time: 184ms
memory: 46984kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 0
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 0
0 27
0 28
0 29
0 30
0 0
0 32
0 33
0 34
0 35
0 36
0 0
0 0
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 0
0 58
0 59
0 60
0...

output:

173310
165951
120854
142558
87420
163018
160623
76341
172338
95167
169845
31220
168100
132276
165092
84047
128575
138423
171800
154331
137251
163376
79848
167392
43722
41974
133487
110272
168461
91407
103766
57088
165360
154903
110464
80792
144277
102908
146051
175704
77052
168422
56979
126413
14964...

result:

ok 200000 numbers

Test #19:

score: 15
Accepted
time: 185ms
memory: 50688kb

input:

200000 200000
45 200000
27 200000
7 200000
51 200000
16 200000
10 200000
16 200000
43 200000
12 200000
35 200000
6 200000
77 200000
40 200000
66 200000
30 200000
18 200000
36 200000
12 200000
26 200000
37 200000
39 200000
11 200000
69 200000
57 200000
15 200000
8 200000
19 200000
32 200000
35 200000...

output:

131384
192629
61130
80247
87887
198740
163105
103211
176599
77117
195385
125105
27678
146598
146076
171154
143664
106375
184677
176668
63515
47861
66512
94607
61773
118863
110829
90228
162033
193193
118985
114311
63857
156350
94535
157429
67223
146494
96304
188983
139817
196687
121473
115649
160519
...

result:

ok 200000 numbers

Test #20:

score: 15
Accepted
time: 186ms
memory: 47348kb

input:

200000 200000
6 200000
3 200000
6 200000
7 200000
2 200000
9 200000
4 200000
3 200000
0 200000
6 200000
3 200000
3 200000
1 200000
8 200000
4 200000
3 200000
5 200000
2 200000
2 200000
2 200000
4 200000
5 200000
6 200000
3 200000
7 200000
1 200000
2 200000
7 200000
2 200000
1 200000
6 200000
1 20000...

output:

191039
169762
165539
174400
68195
177129
154654
147432
156994
76044
194413
99752
191624
151075
197252
164294
18272
88957
158459
84713
87887
43439
179674
131694
123135
59410
106882
159392
139714
64645
69698
100948
140917
103251
45494
170482
166885
104101
194216
145914
120315
76168
77653
141867
198409...

result:

ok 200000 numbers

Test #21:

score: 15
Accepted
time: 159ms
memory: 46816kb

input:

200000 200000
17611 69131
59430 76978
15340 23731
45422 61357
24684 32905
12111 30945
3173 53122
1908 18775
21868 25563
43076 69772
23316 73134
37315 71711
16622 29769
5311 27384
7573 9838
45306 81042
21408 85530
32497 55253
12816 72989
13973 55180
2256 48643
39562 81719
47954 61844
8166 64533
5302 ...

output:

1
2
6
0
2
0
0
0
3
7
1
2
0
0
2
10
1
0
0
1
13
0
2
2
0
4
0
1
7
0
4
14
1
1
0
2
0
0
0
0
5
0
14
4
0
2
14
0
2
0
0
2
1
0
2
1
0
8
10
0
0
8
3
0
10
4
1
1
0
0
13
3
0
4
0
1
1
2
0
1
8
4
1
0
0
5
2
8
0
0
0
1
1
0
0
0
4
9
9
7
2
0
2
13
3
0
0
2
0
0
0
1
0
5
10
5
13
1
0
7
10
1
2
3
0
0
1
5
1
5
0
0
1
0
1
0
1
0
1
7
4
1
0
3
...

result:

ok 200000 numbers

Subtask #3:

score: 15
Accepted

Test #22:

score: 15
Accepted
time: 224ms
memory: 50904kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 0
0 9
0 10
0 0
0 0
0 13
0 14
0 0
0 16
0 17
0 18
0 19
0 0
0 21
0 22
0 23
0 0
0 0
0 0
0 0
0 28
0 0
0 30
0 31
0 32
0 33
0 34
0 35
0 0
0 0
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 0
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 0
0 59
0 60
0 0
0 0
...

output:

19141
39288
14841
58655
15427
4999
26338
93250
2826
78084
64070
55481
2565
15173
24866
57627
35887
51335
67552
44939
27730
24781
54502
26903
73199
7553
3836
41740
67889
104576
43522
3766
13007
31659
17264
85349
16595
28681
64012
56457
23856
47820
22752
86123
37679
44828
88810
36305
15843
33728
10005...

result:

ok 200000 numbers

Test #23:

score: 15
Accepted
time: 228ms
memory: 49196kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 0
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 0
0 27
0 28
0 29
0 30
0 0
0 32
0 33
0 34
0 35
0 36
0 0
0 0
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 0
0 58
0 59
0 60
0...

output:

168949
95410
33682
47935
82249
25613
65578
22342
60917
30684
99457
21252
87719
9508
41909
17405
96346
6219
110867
56725
71026
2090
45186
37640
26229
36720
91410
64919
7095
29903
44679
40307
100104
41603
87434
53924
53758
80720
59404
164539
38810
117092
13565
110110
38606
32273
93240
81294
10356
1504...

result:

ok 200000 numbers

Test #24:

score: 15
Accepted
time: 223ms
memory: 46120kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
...

output:

69217
146306
97579
32894
129999
10418
98425
25273
33368
29464
14306
2073
112582
140228
24801
40781
52137
17338
110491
48418
54730
20451
84100
80588
2089
108163
29975
56448
14978
35560
102453
18613
30516
18699
83182
28795
25862
126187
116576
99593
36207
13935
27150
75205
66741
91089
151786
19917
2529...

result:

ok 200000 numbers

Test #25:

score: 15
Accepted
time: 241ms
memory: 50636kb

input:

200000 200000
0 5
0 99
0 23
0 88
0 62
0 24
0 80
0 70
0 45
0 55
0 99
0 91
0 82
0 99
0 47
0 80
0 9
0 4
0 51
0 64
0 52
0 2
0 2
0 81
0 98
0 36
0 27
0 34
0 97
0 22
0 89
0 77
0 89
0 25
0 90
0 91
0 77
0 37
0 89
0 52
0 58
0 18
0 81
0 35
0 56
0 71
0 18
0 56
0 74
0 40
0 76
0 47
0 87
0 11
0 81
0 48
0 59
0 17
0...

output:

101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
...

result:

ok 200000 numbers

Test #26:

score: 15
Accepted
time: 253ms
memory: 53172kb

input:

200000 200000
0 193
0 229
0 553
0 197
0 718
0 370
0 853
0 695
0 764
0 571
0 714
0 700
0 692
0 293
0 962
0 536
0 482
0 148
0 804
0 864
0 925
0 864
0 296
0 757
0 283
0 338
0 746
0 447
0 365
0 390
0 689
0 239
0 60
0 388
0 822
0 836
0 373
0 703
0 107
0 894
0 468
0 125
0 851
0 568
0 914
0 391
0 759
0 66
...

output:

1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
986
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
834
1001
999
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
995
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001...

result:

ok 200000 numbers

Test #27:

score: 15
Accepted
time: 263ms
memory: 49192kb

input:

200000 200000
0 7698
0 6154
0 6707
0 7442
0 9621
0 8045
0 8938
0 5518
0 4134
0 3188
0 8054
0 5380
0 2409
0 3360
0 2771
0 9642
0 8264
0 4305
0 2844
0 7810
0 4706
0 1462
0 6282
0 2481
0 2987
0 3633
0 2634
0 4866
0 5079
0 2325
0 4394
0 8361
0 322
0 2614
0 7668
0 9067
0 452
0 2834
0 3340
0 2193
0 4070
0...

output:

9992
10001
10001
10000
10001
10001
9910
9932
2155
6995
10001
9347
10001
10001
10000
8952
9997
10000
9996
9999
10001
9996
10001
10000
9949
8842
9944
10000
10000
6517
9719
7997
10001
9875
10000
10001
10001
10001
10001
7481
10001
564
9962
8180
10001
7708
9902
9995
6677
10000
10000
9993
9841
6942
9584
1...

result:

ok 200000 numbers

Test #28:

score: 15
Accepted
time: 266ms
memory: 46152kb

input:

200000 200000
0 44932
0 12196
0 776
0 35673
0 44618
0 16521
0 9747
0 42216
0 21955
0 3389
0 22
0 15248
0 5734
0 45217
0 47977
0 8869
0 25942
0 3415
0 40771
0 28517
0 29726
0 13420
0 30474
0 44930
0 10541
0 4648
0 26903
0 19507
0 2998
0 24757
0 10645
0 47790
0 25779
0 41892
0 37322
0 34913
0 36562
0 ...

output:

48090
32992
22437
48207
21332
45359
39653
11005
43989
17371
8176
34898
30342
43305
36171
34310
36953
26580
26406
40517
30042
24009
21601
48636
34590
44645
6569
1680
36941
44685
8184
29538
47471
13134
37634
44021
16542
45480
34004
2798
44629
42393
43534
32749
42758
39005
46942
906
35042
32188
39406
4...

result:

ok 200000 numbers

Test #29:

score: 15
Accepted
time: 243ms
memory: 51232kb

input:

200000 200000
0 17611
0 59430
0 23731
0 61357
0 32905
0 30945
0 53122
0 18775
0 25563
0 43076
0 23316
0 71711
0 16622
0 27384
0 9838
0 81042
0 85530
0 32497
0 12816
0 55180
0 2256
0 81719
0 61844
0 64533
0 5302
0 33711
0 18419
0 98385
0 48813
0 58297
0 63392
0 29066
0 12542
0 14198
0 27695
0 23110
0...

output:

20413
33643
27062
9573
23562
70288
46728
62984
61505
69707
52256
43819
42924
84768
46751
32254
29961
25002
61760
47063
54538
23381
4229
40146
56797
35682
73141
55198
81237
4145
14779
79432
46593
8554
55961
48948
59145
73439
77423
43568
51349
68840
23328
1413
10825
33789
61183
12488
53414
60374
77583...

result:

ok 200000 numbers

Test #30:

score: 15
Accepted
time: 234ms
memory: 48044kb

input:

200000 200000
0 19
0 50
0 16
0 8
0 27
0 35
0 43
0 42
0 8
0 45
0 39
0 16
0 23
0 29
0 10
0 10
0 50
0 23
0 50
0 45
0 16
0 17
0 30
0 17
0 35
0 50
0 2
0 15
0 33
0 41
0 38
0 12
0 2
0 5
0 37
0 11
0 26
0 35
0 25
0 12
0 38
0 28
0 5
0 46
0 46
0 39
0 26
0 36
0 22
0 9
0 1
0 45
0 36
0 6
0 15
0 31
0 2
0 3
0 0
0 4...

output:

51
51
51
51
51
51
51
51
51
27
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
51
...

result:

ok 200000 numbers

Test #31:

score: 15
Accepted
time: 232ms
memory: 46272kb

input:

200000 200000
0 3
0 3
0 10
0 1
0 7
0 6
0 6
0 4
0 8
0 0
0 5
0 4
0 8
0 7
0 5
0 0
0 1
0 9
0 1
0 1
0 3
0 7
0 10
0 9
0 4
0 6
0 6
0 1
0 5
0 7
0 8
0 1
0 0
0 8
0 9
0 7
0 8
0 7
0 2
0 8
0 6
0 6
0 5
0 7
0 2
0 0
0 6
0 7
0 5
0 3
0 3
0 10
0 3
0 0
0 3
0 3
0 9
0 0
0 7
0 2
0 10
0 10
0 10
0 3
0 2
0 5
0 9
0 1
0 1
0 9
...

output:

11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

ok 200000 numbers

Subtask #4:

score: 15
Accepted

Test #32:

score: 15
Accepted
time: 233ms
memory: 50620kb

input:

200000 200000
0 200000
1 200000
1 200000
0 200000
0 200000
1 200000
1 200000
1 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
0 200000
0 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
1 200000
1 200000
1 200000
1 200000
0 200000
0 200000
1 200000
2 200000
1 200000
2 20000...

output:

71224
21392
65746
47218
62293
29293
146310
136621
165312
81582
25124
120262
104926
12518
90915
31784
50073
15588
1517
106447
92329
71506
16694
4846
38213
34902
133281
98867
697
26263
6631
173459
61316
71682
15564
112191
125788
15305
41840
30379
24107
17435
10898
115177
22279
37582
101778
120170
1264...

result:

ok 200000 numbers

Test #33:

score: 15
Accepted
time: 222ms
memory: 52844kb

input:

200000 200000
5 200000
0 200000
1 200000
0 200000
2 200000
1 200000
0 200000
3 200000
4 200000
1 200000
0 200000
2 200000
1 200000
0 200000
0 200000
5 200000
2 200000
0 200000
2 200000
2 200000
0 200000
1 200000
3 200000
4 200000
2 200000
0 200000
5 200000
0 200000
3 200000
0 200000
0 200000
5 20000...

output:

51850
27495
33433
90638
103054
58851
115355
44294
80395
72594
155250
20604
154366
112939
168447
70437
134688
175930
112777
43168
73760
136485
95405
115772
19580
14448
85020
8135
266
66591
24765
14783
101583
182811
27593
75020
64180
50889
69744
140901
99500
62001
74634
142631
93413
188391
25666
29627...

result:

ok 200000 numbers

Test #34:

score: 15
Accepted
time: 227ms
memory: 46400kb

input:

200000 200000
6 200000
3 200000
6 200000
7 200000
2 200000
9 200000
4 200000
3 200000
0 200000
6 200000
3 200000
3 200000
1 200000
8 200000
4 200000
3 200000
5 200000
2 200000
2 200000
2 200000
4 200000
5 200000
6 200000
3 200000
7 200000
1 200000
2 200000
7 200000
2 200000
1 200000
6 200000
1 20000...

output:

48539
120803
28813
145711
29729
172683
112151
52277
31739
73432
63297
64022
176699
103343
145926
110637
5216
25387
86738
39373
77641
3608
134147
26930
117814
50832
9240
59137
73006
34370
34497
804
96016
101388
3489
30001
85307
17852
1324
32486
37351
12503
28321
42856
196324
95124
119392
87948
28069
...

result:

ok 200000 numbers

Test #35:

score: 15
Accepted
time: 226ms
memory: 46152kb

input:

200000 200000
45 200000
27 200000
7 200000
51 200000
16 200000
10 200000
16 200000
43 200000
12 200000
35 200000
6 200000
77 200000
40 200000
66 200000
30 200000
18 200000
36 200000
12 200000
26 200000
37 200000
39 200000
11 200000
69 200000
57 200000
15 200000
8 200000
19 200000
32 200000
35 200000...

output:

102146
138864
3922
35890
61622
45382
45112
14900
58606
39462
173762
102549
8848
81805
48479
48103
10353
63948
139153
34744
24441
35639
58427
40153
41974
28423
106874
11420
118809
141816
59608
59417
25106
134727
11556
40866
27752
61000
52123
94606
325
144695
24421
115649
156435
132658
25786
136006
18...

result:

ok 200000 numbers

Test #36:

score: 15
Accepted
time: 236ms
memory: 46368kb

input:

200000 200000
894 200000
142 200000
346 200000
496 200000
389 200000
600 200000
650 200000
476 200000
767 200000
220 200000
238 200000
516 200000
137 200000
1 200000
835 200000
34 200000
208 200000
225 200000
377 200000
75 200000
277 200000
278 200000
647 200000
390 200000
179 200000
602 200000
571 ...

output:

82980
71975
66684
28250
111297
44819
114569
54121
107328
25452
72738
53632
23692
426
71363
73241
154868
34365
20278
17775
146745
22972
136874
69984
53
79587
2967
124150
52120
87623
89603
4325
87876
13984
119053
27551
69825
112363
84048
157846
1462
94224
79643
115628
117698
116223
38012
32665
94002
1...

result:

ok 200000 numbers

Test #37:

score: 15
Accepted
time: 175ms
memory: 48776kb

input:

200000 200000
30 200000
9 200000
18 200000
24 200000
68 200000
54 200000
26 200000
3 200000
42 200000
32 200000
27 200000
58 200000
1 200000
34 200000
16 200000
61 200000
11 200000
25 200000
69 200000
48 200000
1 200000
11 200000
51 200000
46 200000
45 200000
48 200000
8 200000
11 200000
76 200000
1...

output:

173724
167565
196183
155627
73842
112798
182774
198559
148707
78823
124508
189149
139326
167284
179483
145557
81468
183248
195819
198503
179022
158694
167743
30007
115871
163056
159742
39661
110436
112768
148610
172927
108963
141742
144742
195300
136697
158981
169064
113954
164065
191476
87872
11760...

result:

ok 200000 numbers

Test #38:

score: 15
Accepted
time: 190ms
memory: 45392kb

input:

200000 200000
4 200000
3 200000
5 200000
9 200000
3 200000
5 200000
3 200000
4 200000
1 200000
7 200000
5 200000
2 200000
2 200000
5 200000
7 200000
0 200000
2 200000
1 200000
6 200000
7 200000
3 200000
4 200000
5 200000
2 200000
2 200000
6 200000
2 200000
8 200000
8 200000
2 200000
2 200000
0 20000...

output:

46615
181434
182190
170634
93896
160383
177806
162444
168792
138030
132992
146565
174737
175152
50188
136539
105800
168041
179972
82742
181959
171407
173501
132587
137393
55914
157218
61659
132609
192152
167976
117558
60445
119612
112065
109544
154984
108960
161879
140516
153475
78686
127811
108796
...

result:

ok 200000 numbers

Test #39:

score: 15
Accepted
time: 192ms
memory: 48704kb

input:

200000 200000
200 200000
418 200000
690 200000
193 200000
63 200000
799 200000
474 200000
40 200000
287 200000
38 200000
204 200000
334 200000
258 200000
262 200000
269 200000
368 200000
167 200000
30 200000
51 200000
55 200000
119 200000
523 200000
33 200000
896 200000
253 200000
674 200000
119 200...

output:

171189
85389
126329
140440
183837
83618
89897
140242
183271
155531
156556
101126
70897
129804
140582
38794
150678
129225
97071
167132
123699
102800
162069
161274
162407
179233
150750
147270
150942
171716
178973
170764
152580
176935
138712
165104
157524
7651
105384
116173
174996
159737
138067
119161
...

result:

ok 200000 numbers

Test #40:

score: 15
Accepted
time: 197ms
memory: 44668kb

input:

200000 200000
611 200000
1167 200000
3159 200000
3415 200000
2254 200000
697 200000
6942 200000
23 200000
1856 200000
894 200000
6650 200000
3813 200000
5825 200000
5844 200000
5534 200000
6993 200000
3021 200000
515 200000
1584 200000
2031 200000
265 200000
8912 200000
6889 200000
6934 200000
833 2...

output:

73994
144591
49265
71224
136162
94664
159060
157355
118335
31810
103232
94713
103259
155339
60542
143894
121148
83887
112143
121172
58706
128573
148964
30102
37612
48511
115410
139260
109
43908
122649
126684
199
98137
22165
80600
2
77835
100163
132242
113078
105702
88160
62364
9
91895
58316
158056
1...

result:

ok 200000 numbers

Test #41:

score: 15
Accepted
time: 163ms
memory: 48616kb

input:

200000 200000
3480 200000
36579 200000
10485 200000
18356 200000
20788 200000
3352 200000
4565 200000
33362 200000
6894 200000
25647 200000
5915 200000
19265 200000
3530 200000
26535 200000
18506 200000
18191 200000
35793 200000
7442 200000
993 200000
14550 200000
13606 200000
5553 200000
12284 2000...

output:

5275
1880
872
857
82
152
7419
496
461
371
2714
1207
660
1744
219
63
17
3346
5677
461
1231
196
2250
97
3770
214
986
189
180
584
2666
0
821
107
839
8
223
90
476
71
867
107
6918
4760
4033
454
3138
1159
6072
4693
56
191
186
245
474
104
377
3627
141
3367
3835
1005
2433
223
6480
2854
29
213
120
6433
57
11...

result:

ok 200000 numbers

Subtask #5:

score: 15
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #42:

score: 15
Accepted
time: 226ms
memory: 50756kb

input:

200000 200000
3 6
3 3
6 10
1 7
2 7
6 9
4 6
3 4
0 8
0 6
3 5
3 4
1 8
7 8
4 5
0 3
1 5
2 9
1 2
1 2
3 4
5 7
6 10
3 9
4 7
1 6
2 6
1 7
2 5
1 7
6 8
1 1
0 7
7 8
0 9
1 7
3 8
3 7
1 2
4 8
5 6
0 6
5 6
2 7
2 6
0 6
0 6
1 7
2 5
0 3
0 3
7 10
3 8
0 2
3 4
3 7
4 9
0 6
4 7
2 6
8 10
2 10
4 10
3 3
2 6
4 5
3 9
1 8
1 2
2 9
...

output:

11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

ok 200000 numbers

Test #43:

score: 15
Accepted
time: 218ms
memory: 53196kb

input:

200000 200000
5 45
27 99
7 23
51 88
16 62
10 24
16 80
43 70
12 45
35 55
6 99
77 91
40 82
66 99
30 47
18 80
9 36
4 12
26 51
37 64
39 52
2 11
2 69
57 81
15 98
8 36
19 27
32 34
35 97
22 23
15 89
53 77
2 89
25 55
25 90
4 91
13 77
37 65
67 89
8 52
20 58
10 18
31 81
35 59
41 56
71 74
18 61
56 77
51 74
40 ...

output:

101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
97
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
1...

result:

ok 200000 numbers

Test #44:

score: 15
Accepted
time: 233ms
memory: 53304kb

input:

200000 200000
193 894
142 229
346 553
197 496
389 718
370 600
650 853
476 695
764 767
220 571
238 714
516 700
137 692
1 293
835 962
34 536
208 482
148 225
377 804
75 864
277 925
278 864
296 647
390 757
179 283
338 602
571 746
447 852
315 365
7 390
634 689
76 239
16 60
244 388
385 822
451 836
301 373...

output:

1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
710
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
198
1001
984
1001
1001
1001
1001
997
1001
1001
1001
1001
1001
1001
1001
1001
933
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
...

result:

ok 200000 numbers

Test #45:

score: 15
Accepted
time: 230ms
memory: 49248kb

input:

200000 200000
3145 7698
6037 6154
6483 6707
6834 7442
7373 9621
5166 8045
7346 8938
2235 5518
2240 4134
586 3188
3845 8054
1258 5380
2409 2631
3360 5706
19 2771
1925 9642
6687 8264
4305 8055
2844 5474
2282 7810
1738 4706
1462 7466
17 6282
2481 6022
2363 2987
3633 4157
1460 2634
4866 8159
3154 5079
2...

output:

9941
10000
9989
9998
10001
10001
9103
9303
2
74
10000
3882
9999
10001
10000
243
9958
9999
9958
9956
10001
9954
10000
10000
9301
1193
9499
9995
9993
10
6027
276
10001
8430
9994
10001
9998
10001
9989
116
10001
0
9535
210
10001
156
8737
9963
57
9998
9997
9956
8275
2
4227
10001
14
2678
9943
10000
646
99...

result:

ok 200000 numbers

Test #46:

score: 15
Accepted
time: 209ms
memory: 48232kb

input:

200000 200000
15540 44932
12196 33126
776 23774
35673 42863
31231 44618
16521 19781
8467 9747
5319 42216
13940 21955
3389 6981
22 11576
15248 17307
5734 35942
12762 45217
30349 47977
8869 11242
11199 25942
3415 10196
20104 40771
8813 28517
29726 34188
13420 13731
17526 30474
1033 44930
3143 10541
46...

output:

18540
127
0
19128
1
1161
233
4
583
0
0
48
14
414
108
15
92
2
22
49
19
2
4
22475
49
481
1
0
149
2487
0
36
10211
0
15
1438
3
4955
32
0
728
377
100
44
852
63
4089
0
147
15
115
774
0
234
6492
7
30
1
68
0
0
39
1
51
38
0
2
126
37
0
1
10
99
0
0
2
379
8800
22
1255
12
268
526
5
0
1430
2
32161
51
17717
2
0
17...

result:

ok 200000 numbers

Subtask #6:

score: 30
Accepted

Dependency #5:

100%
Accepted

Test #47:

score: 30
Accepted
time: 1306ms
memory: 91292kb

input:

1000000 1000000
4 5
2 9
6 8
3 10
2 7
4 7
0 8
2 3
0 5
2 8
2 8
0 1
0 3
1 5
1 4
1 2
2 3
0 10
1 10
2 9
5 9
5 10
2 7
0 10
2 6
3 6
2 6
1 5
3 10
3 6
1 3
2 9
3 4
0 0
1 1
4 5
2 9
6 6
1 1
1 4
0 1
0 0
4 6
0 3
2 4
3 3
0 1
2 6
5 10
2 10
2 4
1 2
2 5
4 9
3 6
4 6
0 8
2 2
1 2
0 3
8 10
1 3
3 5
2 6
2 3
1 1
6 10
4 10
0...

output:

11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
...

result:

ok 1000000 numbers

Test #48:

score: 30
Accepted
time: 1317ms
memory: 92148kb

input:

1000000 1000000
16 22
5 42
3 33
32 43
44 79
1 74
17 91
8 52
25 89
12 39
61 79
26 40
4 91
47 54
2 74
4 65
60 80
49 76
3 72
15 92
26 81
12 81
18 42
30 60
11 36
62 100
46 83
4 9
1 68
18 64
28 35
52 64
2 36
51 78
32 53
13 76
33 80
18 31
20 63
31 72
55 65
29 90
4 69
5 62
2 58
6 58
15 81
17 18
72 98
0 9
1...

output:

101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
...

result:

ok 1000000 numbers

Test #49:

score: 30
Accepted
time: 1337ms
memory: 90948kb

input:

1000000 1000000
729 973
98 551
14 904
352 402
692 789
72 618
4 983
242 715
459 667
179 390
65 391
57 539
107 847
413 548
250 490
224 690
250 700
118 884
136 616
470 830
92 769
286 394
181 740
20 23
163 665
657 767
100 280
661 883
135 258
36 128
28 401
51 247
86 524
73 738
11 869
659 917
49 562
140 9...

output:

1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
911
1001
1001
1001
1001
1001
1001
1001
1001
1001
1001
1...

result:

ok 1000000 numbers

Test #50:

score: 30
Accepted
time: 1390ms
memory: 92144kb

input:

1000000 1000000
271 7861
4188 5424
995 2871
2327 6988
253 7765
541 6033
6666 7294
5399 5653
117 5385
18 3452
7109 7699
2591 3833
1181 5927
1370 9294
5441 6215
5803 5944
1403 5911
2779 8613
2631 9816
1368 4502
3384 6549
4016 9290
4011 6899
8439 8620
2452 3500
2125 9610
5974 6101
1957 7445
1809 8994
1...

output:

10001
10001
9570
4605
10001
10001
10001
9998
10001
9998
10001
10001
8307
10001
10001
10001
1450
9997
10001
10001
10001
10001
8741
10001
10001
10001
10001
10001
9994
10001
10001
9999
764
4
10001
10001
0
10001
10001
9989
9974
10001
10001
9999
10001
10001
10001
10001
10001
10001
9951
10001
10001
10001
...

result:

ok 1000000 numbers

Test #51:

score: 30
Accepted
time: 1181ms
memory: 74632kb

input:

1000000 1000000
5477 25427
15832 45867
21319 40242
24542 38255
9564 34333
7226 18381
17794 27673
27818 38947
15867 35337
32893 41182
9109 21997
17274 18895
6956 28433
10294 49466
30828 49732
1120 12458
15518 26876
4777 39305
24706 46246
6175 17857
1022 41482
13809 22564
18376 40866
12659 20958
6644 ...

output:

49414
49999
45583
46972
48863
49960
44252
17004
47622
49774
6
50001
49942
50001
50000
45294
10539
50001
49980
3708
0
392
263
50000
50001
50000
50001
47459
531
50000
49709
46578
48378
39774
50001
49996
5
50001
50000
182
2693
45279
49971
50001
50000
50000
50000
4484
50001
71
12850
6
50001
30656
49992
...

result:

ok 1000000 numbers

Test #52:

score: 30
Accepted
time: 1369ms
memory: 92084kb

input:

1000000 1000000
12518 98574
6118 43962
1039 23278
10772 55452
12639 80876
775 73677
22168 55193
53756 77563
9159 82322
26293 62512
1288 80570
18004 41192
27725 38349
22931 66339
28914 34706
20429 59032
22939 31970
30894 46893
17769 20465
3053 91272
28608 82560
24975 73826
26131 28301
72980 75860
499...

output:

88712
28
17612
9
99320
33
5
40132
4
290
1258
93960
56377
17
0
54617
12413
108
79768
93339
84701
2832
43807
69902
5
5164
57957
33
35543
67709
0
6
0
91988
97592
1
3762
88505
1
1027
7790
16
27
280
2587
100
1
91229
27597
1348
98052
94195
2665
2
105
53384
174
2
21
22853
77212
89198
98715
95147
50590
1367...

result:

ok 1000000 numbers

Test #53:

score: 30
Accepted
time: 977ms
memory: 76372kb

input:

1000000 1000000
37535 68329
34044 90924
66745 107225
81656 101462
1087 42107
27508 99984
3937 63277
38815 93956
31590 66983
79748 111265
95966 158488
5369 157882
58612 131865
69465 132812
20660 152657
31248 64679
12898 50107
6967 129782
33090 76511
39023 130707
62943 78076
3033 18966
36188 84046
292...

output:

919
12
78779
14610
106423
327
32
4
0
32
51520
2354
332
12615
9837
3
1
2156
2619
0
734
23154
537
571
1763
12
134581
3418
4154
10762
812
1791
18
69483
21
3381
16787
8
61
75691
25188
1214
280
33185
48410
839
4341
68
2
0
2758
4
833
61
121
78577
51
12320
22345
3
137127
144
53
5015
1675
18882
139074
11424...

result:

ok 1000000 numbers

Test #54:

score: 30
Accepted
time: 1160ms
memory: 91920kb

input:

1000000 1000000
15074 492048
25727 34552
92088 168699
269540 306007
219 202625
54535 241986
64045 380619
53606 268860
258737 310279
19044 456930
54322 73013
161501 289143
155226 241807
51093 60556
368921 385136
18370 452957
21905 96081
40985 155551
37188 251004
161885 265243
38134 391304
155105 3391...

output:

7
2
7
0
4
15
8
0
7
5
0
1
15
2
15
1
49
0
75
0
1
0
15
2
2
1
7
3
0
156
1
1
0
10
0
0
2
14
2
7
0
0
1
0
1
15
0
3
0
1
5
1
2
15
0
1
4
47
6
2
2
3
0
7
2
7
152
1
45
8
7
2
2
1
1
5
4
0
0
62
0
3
0
1
4
0
0
15
0
1
0
1
2
3
1
10
0
3
15
3
2
1
29
15
57
2
1
0
15
1
80
17
0
0
5
0
1
1
0
5
0
1
0
0
8
0
0
4
0
47
1
3
0
5
1
15
...

result:

ok 1000000 numbers

Test #55:

score: 30
Accepted
time: 924ms
memory: 73040kb

input:

1000000 1000000
225615 645997
165669 324384
488080 530722
65826 293286
242278 447838
683484 811652
223115 287602
113125 645440
48622 413280
130555 334599
102200 315597
54735 505596
99783 536797
245479 904353
46183 310819
168806 743603
509983 589593
325135 444502
211553 449082
393804 877074
211732 44...

output:

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

result:

ok 1000000 numbers

Test #56:

score: 30
Accepted
time: 1041ms
memory: 75836kb

input:

1000000 1000000
12518 98574
6118 43962
1039 23278
10772 55452
12639 80876
775 73677
22168 55193
53756 77563
9159 82322
26293 62512
1288 80570
18004 41192
27725 38349
22931 66339
28914 34706
20429 59032
22939 31970
30894 46893
17769 20465
3053 91272
28608 82560
24975 73826
26131 28301
72980 75860
499...

output:

8
0
1891
95299
3
77965
14
0
4886
57162
93867
14
75926
0
99206
63780
99622
2
79768
0
14
3202
0
99336
14
99294
318
97472
78183
99548
79
99290
13054
627
98083
17772
9710
712
5815
86171
98155
98447
14
94686
99324
84370
64712
8
86366
96538
0
0
98831
158
37589
978
0
98609
97846
2
5314
96610
0
0
2
93980
27...

result:

ok 1000000 numbers