QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#392550#7446. spxmcqQiulyAC ✓1549ms153132kbC++172.4kb2024-04-17 17:06:182024-04-17 17:06:18

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 20364kb

input:

1000 1000
1 1 3 3 2 2 7 1 5 1 5 10 7 13 11 14 3 14 1 18 7 11 12 11 4 6 4 26 26 21 6 17 10 10 1 29 36 27 10 34 10 17 17 18 16 25 1 46 48 14 12 11 42 26 13 41 28 46 43 39 43 43 8 18 61 35 23 45 34 54 46 23 56 72 16 68 76 5 21 54 81 26 79 70 46 23 23 47 10 51 71 87 15 45 57 27 46 6 20 50 86 14 83 16 88...

output:

-12582
-153882
4509915
103404
120325
99864
20239
109835
-47884
117485
23614
26043
53206
-6355
-12358
14296
-11133
323087
-47813
100007
-181168
266654
-50744
-153518
-24744
-25261
52021
-105852
-22001
-80927
6714
-8066
-61669
45117
-44233
-105553
-153411
-73152
-7027
125988
97471
36073
-126630
-78678...

result:

ok 1000 lines

Test #2:

score: 0
Accepted
time: 93ms
memory: 33080kb

input:

100000 100000
1 1 2 1 4 5 4 6 2 9 1 4 5 3 10 5 15 15 11 11 19 20 14 24 9 14 23 19 14 27 14 8 12 15 31 8 26 24 11 34 7 7 38 30 20 45 26 12 25 39 47 14 19 25 45 4 11 5 30 9 10 5 51 12 54 30 12 41 14 35 26 51 67 73 43 42 3 23 73 61 20 47 57 20 69 69 52 18 89 76 19 49 74 56 87 67 64 87 41 28 88 15 92 29...

output:

146
881
78
201
-23
52
3
-32
70
-10
-63
-57
191
30
-9
89
270
105
-37
65
-1
13
-97
168
9
-27
16
6
-8
-11
2
-4
17
944
13
-18
223
47
0
42
371
-73
-40
4
23
9
-25
78
24
-73
38
-25
-9
310
-33
-13
86
33
-22
-53
97
283
-7
20
21
-14
2
-82
-53
37
138
77
374
43
9
-15
215
29
132
-15
150
27
37
49
99
-11
124
128
2...

result:

ok 100000 lines

Test #3:

score: 0
Accepted
time: 100ms
memory: 34180kb

input:

100000 100000
1 2 1 3 5 6 5 8 7 8 10 12 13 14 14 14 15 16 19 18 19 20 21 22 25 25 25 28 28 30 30 30 32 34 33 35 37 36 37 38 39 40 41 42 44 46 45 47 47 50 51 51 52 52 55 56 56 56 58 60 59 62 62 62 63 66 65 66 67 68 71 72 73 73 74 75 75 77 77 80 80 82 82 84 83 85 86 87 87 89 90 90 93 94 94 95 95 97 99...

output:

791644
-45
1243824
-78
-45
8
59
27
42
216
1810506
-14
-63
-7
420637
-11
444736
-59
4098035
-6
302769
7
31
346956
-22
817634
34
51
109545
35
-58
-22
172891
1723793
-16
122
193
-27
805603
11
80550
250951
20
22991
-7
17
-2
66
-38
1428551
-51
-28
-19
-30
-25
3386771
-10
15
-66
182575
955876
-14
-56
1144...

result:

ok 100000 lines

Test #4:

score: 0
Accepted
time: 235ms
memory: 48968kb

input:

1000 1000000
1 1 1 4 3 2 4 2 4 2 2 7 13 2 15 4 1 18 3 2 18 12 15 19 17 18 3 25 10 21 11 10 14 4 14 30 35 2 15 29 36 13 4 38 45 45 29 2 44 31 31 9 47 46 46 30 5 43 25 57 32 54 30 54 51 6 28 54 63 10 44 66 52 60 62 3 35 33 64 78 31 35 41 68 38 27 1 31 79 52 38 83 3 26 36 67 67 90 14 81 3 77 102 14 60 ...

output:

-135622
-21297
-56634
-61188
981357
-15674
1023328
478789
139328
75747
101878
209294
-40323
76044
545301
19248
-63529
-50102
-15499
26845
783007
-16149
17446
171216
-16
80354
-93463
125635
62621
537368
22597
-22656
-39370
-43103
62975
-112286
72712
-52209
-130451
8256
63876
72420
-29420
-40168
-8089...

result:

ok 1000000 lines

Test #5:

score: 0
Accepted
time: 245ms
memory: 47044kb

input:

1000 1000000
1 1 3 3 4 5 5 7 7 8 10 10 11 13 14 16 16 17 19 18 19 22 23 23 25 25 26 27 28 30 29 30 32 33 34 36 36 36 38 38 41 42 43 44 44 45 47 48 49 50 51 52 53 52 53 54 56 58 57 58 60 62 63 62 65 65 65 66 68 68 70 71 71 72 75 75 77 78 78 79 79 82 83 84 85 85 87 88 88 89 89 91 93 94 95 96 96 98 99 ...

output:

285510
-104333
-74276
9450
66094429
-171002
59503
142406
115332
198979
46576
150603
92676
-15724
-12384
2968481
374110
35279108
-55705
56561
96526
26419024
23009493
6695816
87401504
53147
19408905
-68313
-82372
-107197
-78591
-10004
44489
196070
-83731
21637806
-56676
4653070
-54737
-55478
-14595
19...

result:

ok 1000000 lines

Test #6:

score: 0
Accepted
time: 274ms
memory: 46996kb

input:

1000 1000000
1 2 2 4 5 6 7 6 9 10 10 10 13 13 14 16 17 17 18 19 21 20 22 24 25 26 26 26 28 30 31 30 31 34 35 35 36 38 37 38 39 42 43 44 44 45 47 48 49 48 49 51 53 53 55 56 57 57 59 59 59 61 62 63 63 64 66 67 69 70 69 72 71 73 74 76 77 78 79 78 80 82 82 82 85 86 86 87 89 88 91 91 91 92 94 95 97 97 98...

output:

44745855311
182116253
-53731512
29575332962
27117996
-102828390
12666491555
69228645
152022798
40108187
-185510424
31722544579
142854721
-104416556
-11155519
56189390
93517374
-23943975
3528905398
13169025516
159769036
5762982
31984771970
-160121826
25540107949
-42676473
-128784766
34608330160
78386...

result:

ok 1000000 lines

Test #7:

score: 0
Accepted
time: 244ms
memory: 49092kb

input:

1000 1000000
1 2 2 2 4 6 7 6 8 10 9 12 11 12 14 16 16 18 19 20 20 22 23 23 25 25 25 26 27 30 31 30 31 34 33 36 35 38 39 38 41 40 42 42 44 45 47 48 49 49 51 51 53 52 55 55 55 56 58 58 59 60 62 62 63 66 66 66 68 69 70 72 72 73 74 74 77 78 79 78 80 82 83 82 84 85 87 86 88 90 91 90 91 92 93 95 96 98 97 ...

output:

160203992
-133356852
-56921870
-32122611
78026125
68319926652
211245729
147919969
258250675
49651930165
68733383703
72132723921
30616112640
58235624383
94560419259
299130098
89799338083
106305380
187576805
-14645555
72712707791
32800638734
74691857344
-5148632
77209169492
22755258677
53094255736
194...

result:

ok 1000000 lines

Test #8:

score: 0
Accepted
time: 254ms
memory: 48944kb

input:

1000 1000000
1 1 2 4 2 2 6 8 4 1 3 7 8 8 11 15 16 12 16 20 12 18 15 17 20 24 25 27 27 29 29 25 27 26 28 27 36 37 33 33 34 39 34 43 40 40 43 39 42 41 45 44 53 49 47 50 53 52 51 53 58 56 54 64 62 58 67 65 60 69 68 63 70 68 75 75 69 78 74 72 81 74 77 81 84 82 79 88 83 88 86 88 90 93 88 87 96 90 92 94 1...

output:

-80601717
238634041
106606194
61850746
20675496
15458812
784308504
-86777151
-76905422
71457573
291942705
-100185718
117163702
785863026
3649879330
2848036514
29515681
-73575990
-92815173
-76864247
193368024
66165309993
-109772439
308069466
87236883
-47695964
10560164
316771640
892696011
35301506
44...

result:

ok 1000000 lines

Test #9:

score: 0
Accepted
time: 83ms
memory: 33204kb

input:

100000 100000
1 2 1 1 2 6 3 6 2 4 7 9 3 2 14 2 17 9 6 1 1 15 1 11 6 13 22 9 26 4 9 21 4 31 11 4 32 14 16 12 20 6 42 3 20 19 4 14 6 26 40 41 24 29 7 17 39 5 46 55 22 28 3 43 13 20 49 21 27 32 19 34 36 70 2 62 9 13 72 60 1 82 38 69 18 2 18 1 67 89 73 52 35 43 66 16 14 37 1 28 3 89 12 35 28 20 83 18 20...

output:

-52035
-37135
115117
-6426
-44382
22133
29968
12144
-10035
-47604
-64414
-8407
-27196
22572
649168
26704
38253
260629
1166143
282348
-35829
-103118
138229
-22804
-64253
78610
-83342
7689
99516
138815
78942
-100967
99615
-149840
153309
-83716
-95667
127906
52096
170785
-158247
78789
2267
-54983
-2389...

result:

ok 100000 lines

Test #10:

score: 0
Accepted
time: 89ms
memory: 33124kb

input:

100000 100000
1 2 1 3 2 6 2 8 1 9 2 8 7 11 1 13 12 2 10 4 12 3 14 12 23 21 26 9 13 23 5 16 31 19 13 22 21 21 2 12 31 9 11 39 15 35 36 4 7 11 45 11 36 15 24 24 50 52 29 32 20 41 28 25 51 56 15 37 34 59 11 6 69 46 50 22 13 20 18 10 2 13 59 7 5 82 49 14 20 40 36 12 14 46 58 56 86 9 9 60 20 48 71 72 52 ...

output:

1274203833
11216627
-101190467
153453592
-110543785
-99080111
-34344276
64451254
-15544822
6154193084
191677879
659745267
197749911
162235656
71447054
-16312260
221508179
-119347221
-14963918
104224143
-31103988
317077379
80057801
477218156
-34624126
-70443960
-115472081
24715737
-164196306
-1581933...

result:

ok 100000 lines

Test #11:

score: 0
Accepted
time: 98ms
memory: 31280kb

input:

100000 100000
1 1 3 4 4 5 3 4 3 8 2 5 11 6 1 6 7 17 9 1 4 11 16 11 10 24 12 15 1 6 6 26 15 14 33 5 24 38 34 27 23 36 26 9 26 43 28 14 17 12 3 42 27 12 26 27 57 18 15 23 30 62 10 50 64 63 11 37 67 12 5 26 68 68 37 55 17 74 61 39 62 67 53 57 43 75 76 43 86 67 50 36 15 89 50 84 88 27 28 17 87 90 59 47 ...

output:

-12098750
-104369205
-68128177
2209398624
-907182
6167357820
213360253810
2607231255
11303153960
-78863315
474988216
403559632
1954419348
5563719149
1264469252
1564871193
551294033951
10908841328
6288882249
-113069255
-14539615
1913974157
5226523190
-32187514
2483528413
109071922553
8187892104
17977...

result:

ok 100000 lines

Test #12:

score: 0
Accepted
time: 98ms
memory: 34872kb

input:

100000 100000
1 1 2 4 5 6 6 7 8 9 11 10 12 14 14 15 17 17 19 19 19 22 23 23 23 26 26 28 28 28 31 30 31 32 33 36 36 38 37 38 41 42 43 43 45 46 46 46 49 48 50 52 53 53 55 54 56 56 57 58 59 62 63 64 65 65 66 66 67 70 71 70 71 74 74 75 77 78 78 78 80 81 81 84 85 84 87 86 87 90 90 90 93 92 93 96 97 96 99...

output:

20582457
4718538153702
144037847
28884980
-13520989
-37924438
118901556
4919945488329
55606220
1873699258713
1450895231068
-25206659
986078064141
-105173292
144944661
246879176452
-83837370
-132822154
-21012873
-68284863
7596943187218
-121730570
-24751252
1537573130449
-110632513
22799635
65837695
1...

result:

ok 100000 lines

Test #13:

score: 0
Accepted
time: 58ms
memory: 32896kb

input:

100000 100000
1 2 2 3 5 4 5 8 9 10 10 12 11 14 15 15 17 18 17 20 19 20 23 24 23 25 26 28 27 30 29 31 31 32 34 35 35 36 37 38 40 42 43 44 45 45 46 47 48 48 49 52 51 52 55 56 57 56 57 60 59 62 63 62 64 64 66 67 68 68 70 72 72 72 74 74 76 78 79 79 80 80 82 83 84 85 85 86 87 88 90 90 91 92 94 95 95 96 9...

output:

162369133
7080101854564
-48539058
2338465410485
140648835
-37068772
192060992996
-23716333
-25887733
7289876289830
10119625101019
-8449163
43827133
4652338779565
-11750832
106476847
-27874464
5814337935791
150100442
13749823250518
91756862
16766918
-12009809
10734854120577
91461804
370660784
2602554...

result:

ok 100000 lines

Test #14:

score: 0
Accepted
time: 64ms
memory: 33264kb

input:

100000 100000
1 1 3 2 5 3 7 4 9 5 11 6 13 7 15 8 17 9 19 10 21 11 23 12 25 13 27 14 29 15 31 16 33 17 35 18 37 19 39 20 41 21 43 22 45 23 47 24 49 25 51 26 53 27 55 28 57 29 59 30 61 31 63 32 65 33 67 34 69 35 71 36 73 37 75 38 77 39 79 40 81 41 83 42 85 43 87 44 89 45 91 46 93 47 95 48 97 49 99 50 ...

output:

802164434392
3382027261574
198587121655
778271903801
170628785557
866505223909
213498468204
97729171712
3742522468157
284516889937
959430012369
492656804735
909539873715
134887303923
971084057064
177802141190
239351670493
623551022234
417676114038
225846854103
56093283535
241777714864
811771888884
4...

result:

ok 100000 lines

Test #15:

score: 0
Accepted
time: 58ms
memory: 33188kb

input:

100000 100000
1 1 3 4 3 6 7 4 9 10 6 12 13 7 15 16 9 18 19 10 21 22 12 24 25 13 27 28 15 30 31 16 33 34 18 36 37 19 39 40 21 42 43 22 45 46 24 48 49 25 51 52 27 54 55 28 57 58 30 60 61 31 63 64 33 66 67 34 69 70 36 72 73 37 75 76 39 78 79 40 81 82 42 84 85 43 87 88 45 90 91 46 93 94 48 96 97 49 99 1...

output:

108789589
1137261916058
449926414979
161307014398
10962445576
622617576193
1314116951039
158459972
36309220915
307528669592
280468122989
291042160824
99473146
81731352
93372117
168383471765
670676167750
169010158
215098904037
1512411486925
102613336470
673845477485
231479664387
134068880762
83289036...

result:

ok 100000 lines

Test #16:

score: 0
Accepted
time: 71ms
memory: 32956kb

input:

100000 100000
1 2 3 2 5 6 7 8 6 10 11 12 13 13 15 16 17 18 2 20 21 22 23 10 25 26 27 28 19 30 31 32 33 13 35 36 37 38 9 40 41 42 43 25 45 46 47 48 13 50 51 52 53 50 55 56 57 58 19 60 61 62 63 1 65 66 67 68 17 70 71 72 73 29 75 76 77 78 19 80 81 82 83 37 85 86 87 88 1 90 91 92 93 32 95 96 97 98 90 10...

output:

35761262
-931
80488743
37584814
428450113
34462591
1898536
327636499
33097735
-14247
117765
14129328
2511813960
56652
39392288
215828
-2172
302033000
17512
220566595
131907592
90030579
4498400
30165
686031
50125692
1255728111
85506021
13236665
603931224
24915
11783
856836838
18673
-8683
3752
2918918...

result:

ok 100000 lines

Test #17:

score: 0
Accepted
time: 42ms
memory: 36448kb

input:

100000 100000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...

output:

-34477988
-51176732
-26567976
-33086114
-16047157
-56414242
-5233337
-52121927
-4208243
-12310334
-55779416
-44363303
-25011627
-2218570
-26057879
-54493973
-59090955
-38294324
-29848568
-39354987
-18484175
-23421618
-31957722
-60879378
-8731027
-64008031
-11335451
-32806154
-1469032
-42429295
-3611...

result:

ok 100000 lines

Test #18:

score: 0
Accepted
time: 1549ms
memory: 121396kb

input:

1000000 1000000
1 2 1 3 2 6 7 3 1 2 7 12 10 14 2 13 17 2 15 7 10 11 10 3 9 18 14 6 28 19 9 21 7 21 4 8 18 4 19 39 5 35 39 3 35 9 17 15 42 21 43 27 17 52 50 30 2 41 34 9 53 6 8 60 25 26 31 29 40 9 63 62 7 51 59 75 74 78 23 38 27 77 13 12 21 79 12 87 80 83 8 30 35 14 23 36 68 19 53 82 57 98 103 86 39 ...

output:

8450
17303
2375
121186
-48618
-161764
10906
58504
-10048
-27607
219128
-28008
38245
-148761
186955
-18405
19893
-64164
-2045
-41001
-56842
-42130
27706
-29190
33562
-52570
177095
10200
43145
227901
1273836
-90591
31110
84572
312586
-7099
8350
-527
-65429
17454
17749
34064
-148587
-132241
-174027
896...

result:

ok 1000000 lines

Test #19:

score: 0
Accepted
time: 1515ms
memory: 121632kb

input:

1000000 1000000
1 2 1 1 4 3 4 3 1 1 8 2 13 3 7 11 17 13 13 11 8 2 2 11 15 10 8 18 19 6 13 32 27 15 22 25 33 15 14 6 34 25 42 2 32 6 11 47 10 38 21 18 48 13 55 47 52 3 58 34 52 53 63 61 20 60 1 54 22 55 43 32 19 49 6 33 30 67 43 74 41 60 66 10 80 62 73 65 3 33 58 30 23 94 16 21 48 86 47 96 56 33 68 7...

output:

19240887
253336489
-88516953
109715822
288023235
-29607095
8035941
-19628152
50751454
115651672
711554206
27897875
386619788
128318015
317562266
-365274
-93497140
-76311665
-144267486
176863890
108733736
26859957
-38144873
70989737
122687851
-66355940
62969728
-8439735
42674017
29606806
311007895
11...

result:

ok 1000000 lines

Test #20:

score: 0
Accepted
time: 1503ms
memory: 122384kb

input:

1000000 1000000
1 2 2 2 5 2 4 1 5 4 1 12 2 12 9 7 11 2 3 7 2 12 4 17 23 3 3 23 10 15 13 1 20 29 11 1 15 28 8 6 38 22 25 7 41 36 6 29 48 42 32 43 6 5 47 43 40 48 32 9 49 26 11 22 34 59 18 39 15 6 25 59 58 3 16 47 34 53 55 7 52 64 57 49 57 77 75 61 32 24 90 88 1 42 75 85 68 62 21 48 83 33 45 85 47 37 ...

output:

4491457275
5302801052
30158623294
50896363472
170729569147
69546683623
37518135442
7861502942
1160071432
2202815825
32346492
918518282
-64820178
-63345796
5628521665
2286691997
891060691
20657935687
4848208203
84058142943
880145977
2034438066
177199028658
12348378231
345872014
343821643
2846109403
5...

result:

ok 1000000 lines

Test #21:

score: 0
Accepted
time: 1258ms
memory: 137196kb

input:

1000000 1000000
1 2 3 4 5 4 5 7 9 8 11 11 11 14 15 14 16 17 19 20 19 20 22 22 25 26 25 27 28 29 31 30 33 32 33 36 37 38 38 40 39 41 41 42 43 44 45 48 48 48 50 50 51 53 53 54 56 58 58 60 60 62 61 62 63 65 67 68 67 68 70 70 71 73 75 74 77 76 77 78 79 81 82 83 84 84 87 87 88 88 89 90 92 92 94 95 96 96 ...

output:

47867710
27288439
-127745050
-2663179
2361951
5742902508594
33049862
414456630
122890640
17380098706854
118434592385798
7328004
-76495412
-75043617
47235794
107264564
160269729
50227330979963
-91847315
13033626041922
289724270
53210777
117844940877189
93044791504705
-50504740
-82451250
3301216167988...

result:

ok 1000000 lines

Test #22:

score: 0
Accepted
time: 648ms
memory: 137088kb

input:

1000000 1000000
1 1 1 2 5 5 6 7 9 10 9 10 13 12 14 15 15 17 19 19 21 20 22 24 24 24 25 27 28 28 29 32 33 34 35 34 36 36 39 39 40 41 41 44 43 46 47 46 49 48 50 50 52 52 53 56 55 56 59 59 61 61 61 63 63 66 66 66 69 69 70 70 71 72 74 74 75 78 78 78 79 81 83 83 84 84 86 87 89 89 89 92 93 94 93 95 96 97 ...

output:

-13154820
48952907
78251359367356
-15967481
10871819970142
22237909519990
5500649481350
-3654563
-29417552
227003718
9343113188177
18798624
41128084
-38339022
43869908684152
27755872
3391132902176
117244870
27391483820787
16615953662393
-32501907
67819701
-19375492
343821243
33533949334952
332998712...

result:

ok 1000000 lines

Test #23:

score: 0
Accepted
time: 740ms
memory: 121416kb

input:

1000000 1000000
1 1 3 2 5 3 7 4 9 5 11 6 13 7 15 8 17 9 19 10 21 11 23 12 25 13 27 14 29 15 31 16 33 17 35 18 37 19 39 20 41 21 43 22 45 23 47 24 49 25 51 26 53 27 55 28 57 29 59 30 61 31 63 32 65 33 67 34 69 35 71 36 73 37 75 38 77 39 79 40 81 41 83 42 85 43 87 44 89 45 91 46 93 47 95 48 97 49 99 5...

output:

11575840567
21696911166
349680537626
357152688627
221897147495
172582329888
32846045253
806222348516
3249047546796
7093293300
206121118474
593532582578
61962612538
1797096248326
131664855969
375789573119
14170075134
357496529129
38581287811
33914127758
415022021448
113081301720
73202163610
504616012...

result:

ok 1000000 lines

Test #24:

score: 0
Accepted
time: 751ms
memory: 122108kb

input:

1000000 1000000
1 1 3 4 3 6 7 4 9 10 6 12 13 7 15 16 9 18 19 10 21 22 12 24 25 13 27 28 15 30 31 16 33 34 18 36 37 19 39 40 21 42 43 22 45 46 24 48 49 25 51 52 27 54 55 28 57 58 30 60 61 31 63 64 33 66 67 34 69 70 36 72 73 37 75 76 39 78 79 40 81 82 42 84 85 43 87 88 45 90 91 46 93 94 48 96 97 49 99...

output:

87640585
1236739485565
149882882055
1779407549309
126301347
104522781
99295568
494985159050
52366788274
360691195327
449386524467
17581950498
27650986101
309549653969
42126029
1197517998153
79612282907
95351505
52982786310
42638412728
157629077
129808548
100579591
38824732423674
42864122759
41485437...

result:

ok 1000000 lines

Test #25:

score: 0
Accepted
time: 806ms
memory: 121704kb

input:

1000000 1000000
1 2 3 2 5 6 7 8 9 10 11 12 13 6 15 16 17 18 7 20 21 22 23 22 25 26 27 28 19 30 31 32 33 24 35 36 37 38 32 40 41 42 43 39 45 46 47 48 49 50 51 52 53 33 55 56 57 58 57 60 61 62 63 26 65 66 67 68 30 70 71 72 73 63 75 76 77 78 31 80 81 82 83 23 85 86 87 88 30 90 91 92 93 86 95 96 97 98 6...

output:

22843237
-26071
80669047
12324
366144381
10386517
-45202
89297855
4425243
91353548
64374416
-38912
1569148
27289652596
129172388
150203922
22252765
316924379
96422
6492
658464
148748719
147012
123837802
632312238
618227242
481318932
-60763
170176505
-54678
72722885
28584836
7426
673037
75590
3862305...

result:

ok 1000000 lines

Test #26:

score: 0
Accepted
time: 693ms
memory: 153132kb

input:

1000000 1000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

11813023808749
-25182768
-2924243
1070578912744
-15753417
-52830543
7793778635655
3730339917968
-20627855
24713772614793
-12272596
-15892564
317989324888
19667135384832
36135942909
1275763818812
3795495141810
-81817296
21156162836849
15252078714762
1912867819997
16728000266599
25809643295164
7972136...

result:

ok 1000000 lines