QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#59455#3279. 经典游戏LH100 ✓3178ms314656kbC++144.4kb2022-10-29 16:33:532022-10-29 16:33:55

詳細信息

Subtask #1:

score: 16
Accepted

Test #1:

score: 16
Accepted
time: 3ms
memory: 3708kb

input:

16
5 5
4 3
3 2
3 5
3 1
0 1 1 0 1
5 2
5 5
4 2
2 1
3 2

output:

1
1
1
0
0

result:

ok 5 number(s): "1 1 1 0 0"

Test #2:

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

input:

16
5 5
2 4
4 3
3 5
2 1
0 1 1 0 1
3 2
3 5
1 2
4 1
5 3

output:

0
1
1
0
0

result:

ok 5 number(s): "0 1 1 0 0"

Subtask #2:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #3:

score: 15
Accepted
time: 3ms
memory: 3780kb

input:

15
300 300
2 49
5 174
7 98
12 254
14 234
21 3
3 11
26 48
29 102
32 232
35 283
36 130
38 22
39 178
40 294
44 192
46 256
47 99
53 58
54 287
55 268
56 207
57 238
58 34
34 207
59 226
63 202
70 13
13 128
73 76
76 261
83 285
84 6
89 217
90 294
94 230
101 155
104 273
106 15
107 52
108 276
110 118
111 285
1...

output:

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

result:

ok 300 numbers

Test #4:

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

input:

15
300 300
2 296
7 137
9 253
11 107
12 298
16 274
18 81
22 51
24 113
25 216
26 254
27 300
30 289
31 180
32 221
33 113
34 225
36 298
46 163
48 258
49 220
50 189
52 268
53 207
55 128
59 74
63 67
65 181
71 70
72 5
5 272
74 135
77 252
80 42
83 28
84 127
86 57
57 141
91 232
92 262
96 181
97 287
98 118
99...

output:

1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
0
1
1
0
3
1
3
0
1
0
3
0
2
2
0
5
4
0
0
1
0
1
2
4
0
2
3
2
0
2
2
2
1
3
2
1
2
2
2
1
3
2
2
0
3
1
1
1
3
2
0
0
4
1
0
0
0
0
2
3
0
0
2
0
1
2
1
2
1
0
1
0
0
0
3
2
0
0
1
2
2
0
0
0
0
0
0
3
0
0
1
0
1
0
0
1
0
1
0
0
2
0
0
3
2
1
2
1
2
1
2
0
2
2
1
1
1
0
1
3
0
3
1
0
0
2
2
1
0
1
2
2
...

result:

ok 300 numbers

Test #5:

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

input:

15
300 300
2 240
7 129
8 82
23 13
27 189
29 274
32 75
36 191
38 131
40 268
44 202
46 223
47 223
48 216
52 276
53 78
55 39
39 169
57 215
59 201
60 110
63 112
64 102
65 166
75 19
77 276
80 49
49 4
4 215
84 143
85 87
87 156
89 58
92 219
95 54
54 137
97 42
42 15
15 74
98 17
99 168
100 296
101 14
103 161...

output:

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

result:

ok 300 numbers

Subtask #3:

score: 14
Accepted

Dependency #2:

100%
Accepted

Test #6:

score: 14
Accepted
time: 6ms
memory: 5444kb

input:

14
5000 5000
1 4135
2 31
7 4379
9 2889
13 3400
18 3575
19 2290
21 2220
24 1553
29 3843
31 4336
34 3761
36 4515
37 819
38 653
39 3034
45 4752
52 2852
57 3982
60 3301
67 3785
69 4902
71 942
72 2868
77 919
80 2748
81 2624
82 1902
84 3498
87 3279
88 4583
91 4452
96 1669
99 2196
100 2151
102 3725
104 234...

output:

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

result:

ok 5000 numbers

Test #7:

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

input:

14
5000 5000
4630 3016
4630 1936
4630 3499
4630 573
4630 2103
4630 3816
4630 290
4630 4996
4630 3188
4630 2192
4630 4725
4630 865
4630 4432
4630 3191
4630 1755
4630 384
4630 1893
4630 2408
4630 2389
4630 4183
4630 4043
4630 2830
4630 2134
4630 3736
4630 2529
4630 3561
4630 622
4630 4079
4630 4055
46...

output:

0
0
0
0
2
0
1
0
0
0
0
0
3
2
176
0
0
0
1
0
149
0
1
0
0
1
1
2
0
0
0
1
0
1
0
0
0
0
0
1
1
0
0
0
1
0
0
3
0
0
0
0
0
1
147
0
0
2
1
0
0
0
1
0
0
0
0
0
1
0
119
0
1
0
1
0
0
0
0
0
0
1
0
2
0
4
0
0
0
2
0
1
0
0
0
0
0
1
2
0
0
0
3
0
0
119
1
0
0
0
1
2
0
0
1
0
0
2
3
0
0
0
0
1
0
2
0
0
1
0
3
0
175
3
1
0
0
1
1
1
148
0
2
...

result:

ok 5000 numbers

Test #8:

score: 0
Accepted
time: 6ms
memory: 5124kb

input:

14
5000 5000
478 4898
4898 1538
1538 4066
4066 1915
1915 3513
3513 3947
3947 4661
4661 1122
1122 1344
1344 2121
2121 4274
4274 3297
3297 4948
4948 655
655 4902
4902 4025
4025 4127
4127 4000
4000 3705
3705 4199
4199 635
635 3369
3369 2292
2292 4309
4309 4868
4868 4282
4282 3075
3075 4326
4326 4092
40...

output:

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

result:

ok 5000 numbers

Subtask #4:

score: 13
Accepted

Test #9:

score: 13
Accepted
time: 111ms
memory: 55680kb

input:

13
100000 100000
91699 52443
52443 41748
41748 32330
32330 42277
42277 80707
80707 97074
97074 84439
84439 73656
73656 94232
94232 19271
19271 64725
64725 68032
68032 15074
15074 98785
98785 84234
84234 63617
63617 85713
85713 32965
32965 90099
90099 95398
95398 84273
84273 90891
90891 89305
89305 9...

output:

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

result:

ok 100000 numbers

Test #10:

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

input:

13
100000 100000
57624 99869
99869 80198
80198 62843
62843 7883
7883 52607
52607 69363
69363 97085
97085 63315
63315 86299
86299 96455
96455 76868
76868 43868
43868 54746
54746 90151
90151 63572
63572 92398
92398 79264
79264 66180
66180 61719
61719 97795
97795 91813
91813 98698
98698 81039
81039 904...

output:

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

result:

ok 100000 numbers

Test #11:

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

input:

13
100000 100000
64496 84832
84832 93531
93531 39916
39916 52794
52794 79600
79600 82783
82783 66851
66851 79473
79473 85703
85703 26977
26977 79380
79380 92594
92594 64565
64565 59553
59553 96967
96967 76192
76192 99410
99410 7785
7785 95668
95668 68456
68456 59935
59935 94596
94596 65080
65080 628...

output:

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

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 130ms
memory: 55708kb

input:

13
100000 100000
84707 21587
21587 22506
22506 89794
89794 88141
88141 95218
95218 41382
41382 91979
91979 87575
87575 52697
52697 89043
89043 82196
82196 79424
79424 77887
77887 33683
33683 95806
95806 92247
92247 94484
94484 47740
47740 25904
25904 56736
56736 68596
68596 93904
93904 96199
96199 3...

output:

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

result:

ok 100000 numbers

Subtask #5:

score: 12
Accepted

Test #13:

score: 12
Accepted
time: 25ms
memory: 9820kb

input:

12
100000 100000
93214 84598
93214 56491
93214 84251
93214 79335
93214 71720
93214 77307
93214 95507
93214 95410
93214 40328
93214 86071
93214 45088
93214 66766
93214 79723
93214 88378
93214 89470
93214 88357
93214 88637
93214 30576
93214 90846
93214 53961
93214 41155
93214 46341
93214 83568
93214 9...

output:

50089
0
0
0
1
50086
0
1
0
50086
50085
0
0
50088
1
50088
0
1
1
50088
50087
50088
0
50088
1
50088
1
0
50087
50086
50085
0
50087
50086
0
50088
50089
0
1
50088
1
50090
0
0
50089
1
0
1
0
50090
50089
1
1
1
1
0
50087
50088
50089
1
50087
50086
50085
50086
50087
0
1
0
50085
1
0
1
50085
1
50085
0
50085
0
0
0
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 27ms
memory: 9644kb

input:

12
100000 100000
87813 88402
87813 95508
87813 98893
87813 72683
87813 30574
87813 51137
87813 97898
87813 59020
87813 76017
87813 98656
87813 78075
87813 85721
87813 87306
87813 9176
87813 90004
87813 38369
87813 86573
87813 94026
87813 48667
87813 47642
87813 86402
87813 91112
87813 99092
87813 94...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 43ms
memory: 9776kb

input:

12
100000 100000
95193 86523
95193 66880
95193 88385
95193 95738
95193 64581
95193 77273
95193 81211
95193 67702
95193 37065
95193 31294
95193 98186
95193 97664
95193 91076
95193 84680
95193 90759
95193 38467
95193 97823
95193 37082
95193 89129
95193 93058
95193 52159
95193 53257
95193 95170
95193 3...

output:

1
50156
1
50156
0
50156
1
0
0
50156
50157
50158
50157
50156
50155
0
0
0
50157
1
50157
0
1
50156
1
1
0
0
0
1
1
1
50155
50156
1
50158
1
0
50155
0
0
50156
0
50156
0
50154
1
50154
50153
50154
0
0
0
50156
50155
50154
50153
50152
50151
1
0
50152
50153
50154
0
50154
0
50154
1
50154
0
0
0
50150
50151
1
0
50...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 33ms
memory: 9608kb

input:

12
100000 100000
83073 96684
83073 75419
83073 71759
83073 57231
83073 99832
83073 92865
83073 92164
83073 53823
83073 31154
83073 28408
83073 88848
83073 7334
83073 98219
83073 86129
83073 95290
83073 45169
83073 95392
83073 57686
83073 61365
83073 92684
83073 51746
83073 40660
83073 95954
83073 96...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Subtask #6:

score: 11
Accepted

Test #17:

score: 11
Accepted
time: 94ms
memory: 35064kb

input:

11
100000 100000
2 29108
3 77506
4 7190
5 41884
7 9630
14 78381
15 10036
16 13569
19 80204
20 17573
24 86568
26 88304
28 91742
31 50889
32 29659
33 7909
37 61160
38 88144
40 36396
41 8142
43 20787
46 75458
48 23406
50 56495
61 74778
63 97662
70 75429
73 52031
76 49902
77 56882
81 13357
85 70152
89 3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 76ms
memory: 26928kb

input:

11
100000 100000
5157 83042
5157 99808
5157 84092
5157 97178
5157 61850
5157 86984
5157 39797
5157 91201
5157 23694
5157 64810
5157 65775
5157 95780
5157 61901
5157 91192
5157 18334
5157 73610
5157 97423
5157 64103
5157 60144
5157 69149
5157 35873
5157 62909
5157 40770
5157 79692
5157 78154
5157 530...

output:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
3
3
3
3
3
3
3
2
2
3
1
1
1
1
3
3
3
1
3
3
3
3
3
3
3
3
3
3
3
3
3
1
1
1
4
4
4
4
4
3
3
4
4
4
3
3
3
3
3
3
3
1
2
2
4
3
3
1
1
1
3
3
3
3
2
2
4
4
3
4
4
4
3
3
3
3
3
2
2
4
4
4
4
4
2
2
2
2
2
2
2
2
2
2
2
2
2
1
3
3
3
3
4
3
1
1
2
1
1
1
1
1
1
2
3
1
1
3
3
3
3
3
1
1
2
1
1
1
2
1
...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 108ms
memory: 33736kb

input:

11
100000 100000
94421 77686
77686 99527
99527 89261
89261 95025
95025 99584
99584 59157
59157 97744
97744 10371
10371 68733
68733 81763
81763 84146
84146 32495
32495 99816
99816 15431
15431 80957
80957 31637
31637 73107
73107 88321
88321 81735
81735 76270
76270 54816
54816 18030
18030 96927
96927 6...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 97ms
memory: 28032kb

input:

11
100000 100000
79899 89862
91077 54657
42712 54657
85707 54657
74910 54657
84672 54657
72168 54657
84967 54657
47024 54657
17669 54657
54773 54657
78042 54657
51014 54657
26960 54657
75786 54657
97374 54657
66664 54657
60080 54657
68189 54657
79232 54657
13559 54657
58661 54657
59686 54657
72186 5...

output:

149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
149
...

result:

ok 100000 numbers

Subtask #7:

score: 10
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Test #21:

score: 10
Accepted
time: 1315ms
memory: 159044kb

input:

10
500000 500000
1 277371
2 489516
3 48335
6 485707
10 200689
11 234065
12 91119
15 237952
16 335932
18 422530
19 425635
21 174647
24 177724
26 375410
29 475229
33 435429
36 189907
37 216474
38 32593
43 468164
46 131911
49 225461
50 201879
53 479281
59 194596
61 390370
68 97324
75 382926
76 274168
7...

output:

1
2
1
0
1
3
3
2
0
2
1
0
0
0
0
1
0
0
1
1
1
2
3
0
1
0
0
0
0
0
0
2
3
0
1
0
0
0
2
0
0
0
0
0
2
0
4
3
1
1
3
1
0
1
1
0
3
2
3
0
0
0
2
0
2
2
1
1
0
1
0
1
0
2
0
1
0
0
0
2
0
0
1
2
2
0
2
0
0
1
0
2
0
5
0
1
2
1
3
3
3
1
3
0
1
0
0
4
0
0
1
0
1
0
1
0
0
3
0
0
1
1
2
2
3
0
2
0
0
3
2
5
4
3
2
0
0
0
4
0
0
0
0
0
3
3
5
2
2
1
...

result:

ok 500000 numbers

Test #22:

score: 0
Accepted
time: 1171ms
memory: 117068kb

input:

10
500000 500000
462534 492665
462534 336889
462534 473488
462534 487709
462534 470138
462534 438818
462534 499353
462534 481366
462534 481462
462534 471572
462534 488706
462534 493029
462534 493573
462534 490986
462534 482014
462534 493142
462534 488950
462534 494371
462534 471657
462534 410403
462...

output:

2
1
1
1
0
2
0
1
3
2
1
1
2
3
0
0
1
0
0
0
3
2
4
3
2
2
0
3
1
3
0
0
3
2
1
1
1
0
0
2
1
0
0
2
2
2
0
0
2
0
0
1
1
2
0
2
1
1
2
0
1
2
3
0
1
0
2
2
0
2
0
0
3
0
2
1
2
2
1
0
2
2
2
0
1
1
2
3
2
3
3
1
3
0
2
1
1
1
2
1
1
2
1
2
4
2
0
0
0
4
2
2
0
2
0
3
1
2
0
2
1
1
1
1
0
2
2
1
1
0
2
0
1
1
2
1
2
2
2
1
2
2
3
1
0
5
0
1
1
1
...

result:

ok 500000 numbers

Test #23:

score: 0
Accepted
time: 1301ms
memory: 154684kb

input:

10
500000 500000
499936 381724
381724 497704
497704 469911
469911 411176
411176 499240
499240 367501
367501 498798
498798 467003
467003 493930
493930 496887
496887 497561
497561 371569
371569 473914
473914 473715
473715 456939
456939 481130
481130 467838
467838 452621
452621 495612
495612 494764
494...

output:

0
0
1
0
4
4
4
0
0
0
4
0
0
3
3
0
0
0
0
3
3
0
0
2
0
3
3
1
0
0
2
2
0
1
2
2
0
0
0
2
2
2
1
0
2
4
1
1
1
1
2
0
0
0
0
1
5
1
0
1
0
0
1
0
0
3
2
2
0
0
1
0
0
1
2
3
0
3
5
0
2
0
1
0
0
1
1
4
1
1
0
4
4
2
2
1
0
0
2
2
3
2
4
4
3
1
2
3
2
0
1
0
1
0
0
0
0
2
0
0
3
2
0
2
2
0
0
0
0
0
0
2
1
0
3
0
0
3
0
0
1
2
0
0
0
0
0
0
3
0
...

result:

ok 500000 numbers

Test #24:

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

input:

10
500000 500000
454694 151377
498859 481231
434455 481231
457354 481231
482259 481231
454535 481231
438083 481231
442761 481231
482352 481231
462250 481231
497768 481231
491758 481231
479967 481231
445184 481231
436907 481231
476330 481231
478782 481231
446219 481231
488575 481231
499512 481231
465...

output:

0
0
2
0
0
0
2
0
0
0
0
0
0
1
4
0
0
1
0
1
0
0
0
0
0
3
3
0
0
0
0
0
3
0
332
0
4
342
2
291
2
0
0
0
0
0
2
0
0
0
1
0
0
0
1
0
1
0
343
112
0
0
0
1
3
0
3
1
5
1
0
0
2
0
1
0
0
2
0
0
2
0
0
0
0
0
0
0
0
0
0
0
261
2
0
0
2
0
0
20
0
2
0
204
0
1
1
0
0
4
0
0
0
0
2
78
3
0
0
0
0
0
0
2
244
0
0
1
0
0
0
0
1
1
1
0
320
3
2
0
...

result:

ok 500000 numbers

Test #25:

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

input:

10
500000 500000
491960 461097
495312 490311
491780 490311
389831 490311
493165 490311
493698 490311
492117 490311
440864 490311
480612 490311
495460 490311
485031 490311
498410 490311
498960 490311
480556 490311
458096 490311
494993 490311
428459 490311
475240 490311
477677 490311
488608 490311
423...

output:

0
0
0
1
0
2
0
0
0
0
1
2
2
0
0
0
0
0
273
1
1
304
1
2
1
0
0
0
5
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
3
3
0
0
2
0
2
1
1
0
1
0
0
2
0
1
0
0
3
0
0
0
0
1
0
2
0
0
0
0
0
1
0
0
0
0
0
1
0
0
3
1
0
1
0
0
0
0
1
4
1
0
0
0
0
1
0
0
0
0
0
2
0
0
0
0
0
4
3
0
0
1
0
0
0
1
0
198
1
0
3
2
1
0
0
0
0
2
0
0
...

result:

ok 500000 numbers

Test #26:

score: 0
Accepted
time: 938ms
memory: 106904kb

input:

10
500000 500000
496698 86630
479865 484629
462219 484629
465444 484629
466711 484629
499068 484629
493529 484629
492158 484629
378380 484629
485048 484629
453496 484629
488234 484629
492276 484629
447702 484629
481571 484629
482050 484629
495364 484629
431897 484629
471602 484629
479142 484629
4552...

output:

0
2
1
180
317
36
0
1
282
3
1
1
3
0
1
0
3
1
1
1
0
2
0
1
4
0
0
68
0
0
0
0
2
1
0
203
0
0
0
0
3
0
0
2
0
2
2
1
0
0
0
0
0
0
264
1
0
0
0
1
2
1
2
1
4
1
2
0
1
1
1
0
248
0
1
2
2
0
0
1
0
0
211
0
0
0
355
0
1
0
0
1
1
0
2
3
0
1
1
0
0
1
132
316
0
0
0
0
2
0
266
0
0
0
0
202
0
1
0
0
2
1
0
2
1
1
1
0
0
320
56
0
0
2
3
0...

result:

ok 500000 numbers

Subtask #8:

score: 9
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #27:

score: 9
Accepted
time: 3178ms
memory: 314656kb

input:

9
1000000 1000000
1 708838
3 967331
5 559904
7 126195
13 693166
17 701584
20 668322
21 957574
22 96330
26 754743
27 619125
28 751293
29 508658
32 851985
33 585243
34 134955
44 395859
45 177067
46 970955
47 323512
48 322315
49 654503
55 741807
59 268382
61 485999
62 310073
64 836836
65 294892
66 9057...

output:

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

result:

ok 1000000 numbers

Test #28:

score: 0
Accepted
time: 2701ms
memory: 227156kb

input:

9
1000000 1000000
975133 952760
975133 984020
975133 917580
975133 990993
975133 958195
975133 943462
975133 980599
975133 996217
975133 928932
975133 905725
975133 986503
975133 997327
975133 888376
975133 960512
975133 974596
975133 940468
975133 993775
975133 980058
975133 912998
975133 996767
97...

output:

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

result:

ok 1000000 numbers

Test #29:

score: 0
Accepted
time: 3081ms
memory: 308588kb

input:

9
1000000 1000000
881316 953216
953216 924899
924899 994445
994445 981802
981802 974168
974168 990533
990533 990627
990627 965176
965176 998562
998562 945998
945998 958525
958525 989489
989489 980150
980150 977357
977357 998456
998456 891421
891421 998732
998732 973993
973993 949174
949174 983729
98...

output:

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

result:

ok 1000000 numbers

Test #30:

score: 0
Accepted
time: 2334ms
memory: 215148kb

input:

9
1000000 1000000
957553 870484
998585 981255
997322 981255
964054 981255
989833 981255
977358 981255
937923 981255
935623 981255
990040 981255
951714 981255
939674 981255
982920 981255
969335 981255
930478 981255
970590 981255
855184 981255
949077 981255
978082 981255
964920 981255
949733 981255
97...

output:

2
0
0
0
0
0
0
0
0
1
2
1
2
1
0
2
0
0
0
0
327
205
0
0
2
434
2
0
0
2
0
3
502
2
0
0
2
2
1
401
0
0
3
0
0
0
1
1
4
0
0
1
0
0
2
502
0
0
418
2
1
2
195
0
218
1
0
1
3
0
0
3
2
3
1
1
0
0
0
0
0
0
1
4
0
1
0
1
0
1
0
0
200
0
2
1
0
0
0
1
0
0
0
1
2
0
1
3
0
2
0
2
0
2
3
1
2
2
2
3
2
0
1
0
1
1
406
1
0
3
1
0
296
0
0
0
1
0
...

result:

ok 1000000 numbers

Test #31:

score: 0
Accepted
time: 2632ms
memory: 229920kb

input:

9
1000000 1000000
996538 959092
918566 979595
941819 979595
956965 979595
973043 979595
942542 979595
902113 979595
980272 979595
976447 979595
982490 979595
986946 979595
929652 979595
918680 979595
978729 979595
951089 979595
975441 979595
958132 979595
992462 979595
979223 979595
923004 979595
94...

output:

0
0
340
0
0
1
2
2
0
1
0
0
2
0
1
47
0
0
0
0
0
0
0
0
2
0
0
0
0
2
0
0
0
4
0
3
0
0
2
1
1
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
3
0
1
0
2
5
0
0
0
0
0
2
0
0
0
0
0
1
2
3
0
0
0
0
0
1
0
0
0
1
2
0
2
1
0
1
1
62
1
2
0
65
0
0
0
1
1
2
3
1
0
310
0
0
0
0
0
0
0
0
1
0
0
2
0
0
1
1
2
0
1
0...

result:

ok 1000000 numbers

Test #32:

score: 0
Accepted
time: 2233ms
memory: 211784kb

input:

9
1000000 1000000
998847 504663
984753 993343
953646 993343
913662 993343
934686 993343
969341 993343
919389 993343
914821 993343
965027 993343
913978 993343
926066 993343
996246 993343
987559 993343
991853 993343
928081 993343
936373 993343
972676 993343
970180 993343
934488 993343
991170 993343
98...

output:

0
0
0
0
0
218
1
1
383
0
0
0
0
0
1
1
0
0
0
3
1
0
0
1
0
0
2
0
0
0
0
0
1
1
417
0
441
0
0
1
2
0
0
2
0
0
0
1
2
0
0
1
0
0
0
0
1
0
4
0
0
3
0
0
0
0
2
2
0
1
0
0
3
2
0
1
0
0
0
392
1
0
1
2
1
0
0
0
0
0
0
0
1
0
265
403
0
1
2
0
0
0
3
2
1
1
0
0
0
0
0
2
0
308
0
0
0
441
0
0
0
0
0
0
297
0
1
0
1
2
0
2
0
0
0
0
0
0
0
0
...

result:

ok 1000000 numbers

Extra Test:

score: 0
Extra Test Passed