QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#291106#1398. Historical ResearchMoRanSky100 ✓120ms7836kbC++232.0kb2023-12-26 04:52:562023-12-26 04:52:56

Judging History

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

  • [2023-12-26 04:52:56]
  • 评测
  • 测评结果:100
  • 用时:120ms
  • 内存:7836kb
  • [2023-12-26 04:52:56]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;

const int N = 100005, S = 355;

int n, m, a[N], d[N], pos[N], L[S], R[S], len, tot, t, cnt[N], s[N];

LL ans[N], sum;

struct Q{
    int l, r, id;
    bool operator < (const Q &b) const {
        if (pos[l] != pos[b.l]) return pos[l] < pos[b.l];
        return r < b.r;
    }
} q[N];

void del(int x) { cnt[x]--; }
void add(int x) {
    cnt[x]++; sum = max(sum, (LL)d[x] * cnt[x]);
}

int main() {
    scanf("%d%d", &n, &m);
    t = sqrt(n), len = n / t;
    for (int i = 1; i <= len; i++) {
        L[i] = (i - 1) * t + 1, R[i] = i * t;
    }
    if (R[len] < n) R[len] = n;
    for (int i = 1; i <= len; i++)
        for (int j = L[i]; j <= R[i]; j++) pos[j] = i;

    for (int i = 1; i <= n; i++) scanf("%d", a + i), d[i] = a[i];
    sort(d + 1, d + 1 + n);
    tot = unique(d + 1, d + 1 + n) - d - 1;
    for (int i = 1; i <= n; i++) a[i] = lower_bound(d + 1, d + 1 + tot, a[i]) - d;
    for (int i = 1; i <= m; i++)
        scanf("%d%d", &q[i].l, &q[i].r), q[i].id = i;
    sort(q + 1, q + 1 + m);

    int l = 1, r = 0, last = 0;
    for (int i = 1; i <= m; i++) {
        if (pos[q[i].l] == pos[q[i].r]) {
            LL res = 0;
            for (int j = q[i].l; j <= q[i].r; j++)
                s[a[j]]++, res = max(res, (LL)s[a[j]] * d[a[j]]);
            ans[q[i].id] = res;
            for (int j = q[i].l; j <= q[i].r; j++) s[a[j]]--;
            continue;
        }
        if (pos[q[i].l] != last) {
            for (int j = l; j <= r; j++) cnt[a[j]] = 0;
            l = r = R[pos[q[i].l]], cnt[a[l]] = 1; 
            sum = d[a[l]], last = pos[q[i].l];
        }
        while (r < q[i].r) add(a[++r]);
        LL tmp = sum;
        for (int j = l - 1; j >= q[i].l; j--) add(a[j]);
        ans[q[i].id] = sum;
        for (int j = l - 1; j >= q[i].l; j--) del(a[j]);
        sum = tmp;
    }
    for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
    return 0;
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 1ms
memory: 5996kb

input:

20 20
811 811 811 4145 811 4145 4145 811 811 811 811 811 4145 811 4145 4145 4145 811 4145 811
11 14
5 11
18 19
4 20
1 7
10 12
4 17
11 12
3 11
18 19
4 6
5 14
4 16
1 18
11 20
4 10
20 20
3 8
4 9
17 19

output:

4145
8290
4145
33160
12435
2433
29015
1622
12435
4145
8290
12435
24870
29015
20725
12435
811
12435
12435
8290

result:

ok 20 lines

Test #2:

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

input:

20 20
563674797 335225254 563674797 563674797 335225254 335225254 335225254 335225254 335225254 563674797 335225254 335225254 335225254 335225254 335225254 563674797 335225254 335225254 335225254 335225254
9 16
6 11
7 11
8 17
9 15
9 10
4 18
16 19
6 18
8 15
14 18
6 18
8 12
11 17
2 12
7 11
11 17
2 15
...

output:

2011351524
1676126270
1340901016
2681802032
2011351524
563674797
4022703048
1005675762
3687477794
2346576778
1340901016
3687477794
1340901016
2011351524
2681802032
1340901016
2011351524
3687477794
1005675762
1005675762

result:

ok 20 lines

Test #3:

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

input:

100 100
3007 1870 3784 3007 578 9586 2178 9586 9586 3784 1164 578 3784 578 1164 3784 1870 3784 9586 9586 578 3784 9586 9586 3784 1870 1870 3007 9586 9586 1870 9586 3007 3784 9586 3784 9586 1870 1870 2178 9586 3784 3784 9586 9586 578 1870 3007 3784 3784 1870 9586 1870 1870 578 9586 2178 3784 2178 958...

output:

38344
153376
76688
182134
38344
19172
95860
86274
153376
95860
191720
124618
28758
1870
191720
57516
57516
11352
47930
9586
249236
210892
86274
105446
28758
162962
258822
28758
220478
153376
191720
3740
86274
67102
124618
220478
124618
19172
38344
105446
143790
57516
230064
162962
86274
230064
15136...

result:

ok 100 lines

Test #4:

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

input:

100 100
786792 786792 786792 786792 786792 764458 786792 963595 786792 786792 963595 786792 963595 786792 786792 786792 32192 786792 786792 905875 786792 786792 786792 786792 786792 905875 786792 331681 786792 786792 786792 786792 963595 786792 786792 963595 32192 963595 764458 764458 963595 963595 ...

output:

4817975
15735840
9441504
1573584
24390552
21243384
8672355
6745165
7867920
8672355
7081128
34618848
7708760
35405640
30684888
2360376
28324512
5507544
16522632
786792
11801880
7081128
8654712
35405640
3933960
7867920
22816968
21243384
10228296
8654712
16522632
28324512
28324512
18883008
11801880
173...

result:

ok 100 lines

Test #5:

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

input:

100 100
553477067 553477067 304864290 553477067 553477067 553477067 553477067 553477067 553477067 553477067 553477067 553477067 956714031 553477067 553477067 553477067 779617626 304864290 553477067 553477067 553477067 553477067 553477067 553477067 553477067 304864290 553477067 553477067 553477067 77...

output:

10516064273
12729972541
9409110139
4981293603
6641724804
2213908268
13283449608
12176495474
8302156005
553477067
8855633072
8302156005
13836926675
1660431201
13836926675
4427816536
18818220278
10516064273
17711266144
10516064273
34869055221
6641724804
7748678938
553477067
14943880809
4981293603
1162...

result:

ok 100 lines

Test #6:

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

input:

100 100
334255223 334255223 334255223 334255223 694329724 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 334255223 601440920 334255223 334255223 334255223 334255223 334255223 33...

output:

4679573122
13370208920
22395099941
10696167136
13370208920
2339786561
4345317899
20389568603
7019359683
11698932805
17715526819
17715526819
8356380575
6350849237
6350849237
4345317899
24400631279
8022125352
3008297007
7019359683
15709995481
1002765669
7353614906
6350849237
10027656690
8356380575
133...

result:

ok 100 lines

Test #7:

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

input:

100 100
358674715 53114433 53114433 171770722 653764887 834719263 636547644 926162979 553678607 273752292 53114433 553678607 369756177 358674715 553678607 553678607 926162979 53114433 358674715 344653059 636547644 926162979 358674715 369756177 926162979 234815735 273752292 369756177 553678607 926162...

output:

3704651916
7751500498
2214714428
1107357214
4630814895
4429428856
1107357214
3322071642
1107357214
7751500498
553678607
8858857712
3322071642
7751500498
6644143284
6644143284
358674715
1669438526
717349430
6090464677
2214714428
7751500498
484130204
926162979
7751500498
1107357214
9966214926
55367860...

result:

ok 100 lines

Test #8:

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

input:

100 100
294364494 294364494 185512096 618750081 185512096 618750081 189726762 294364494 564129595 294364494 294364494 23865954 294364494 280473693 618750081 294364494 727380725 564129595 618750081 189726762 294364494 564129595 185512096 564129595 189726762 189726762 189726762 618750081 185512096 294...

output:

4331250567
2475000324
1856250243
1856250243
4513036760
2475000324
4950000648
618750081
4950000648
1856250243
189726762
588728988
2475000324
727380725
5568750729
3712500486
1856250243
4331250567
1856250243
1328087334
588728988
1237500162
1856250243
1856250243
6187500810
3093750405
1237500162
37125004...

result:

ok 100 lines

Test #9:

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

input:

100 100
578973620 873056022 873056022 752203634 836142923 103164591 578973620 578973620 103164591 873056022 976967979 497903286 578973620 975269497 103164591 839023714 400648844 287582329 578973620 284127012 497903286 836142923 836142923 836142923 578973620 487212069 497903286 976967979 873056022 83...

output:

5016857538
400648844
8792711811
6689143384
3344571692
3907871916
4195118570
3344571692
8792711811
4180714615
5853000461
5016857538
3907871916
1746112044
5861807874
5034142284
3344571692
976967979
1672285846
976967979
752203634
4884839895
4195118570
5853000461
3907871916
5861807874
4180714615
1678047...

result:

ok 100 lines

Test #10:

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

input:

100 100
852607255 852607255 530218977 885470267 852607255 275324463 885470267 777336216 885470267 885470267 392569411 777336216 288059894 428889454 310288969 885470267 852607255 392569411 328321211 476288702 467260494 645746502 310288969 392569411 15859617 310288969 530218977 40731418 852607255 3925...

output:

885470267
2557821765
12789108825
1705214510
8526072550
2656410801
7673465295
5115643530
885470267
4263036275
13641716080
5115643530
5115643530
9378679805
1770940534
6820858040
13641716080
2747985877
5312821602
6820858040
12789108825
6820858040
13641716080
5968250785
11083894315
3410429020
1449432333...

result:

ok 100 lines

Test #11:

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

input:

100 100
276328241 39373791 969047173 424463893 294839235 243184133 761521940 294839235 776411535 476849195 35692717 938226372 522485008 39373791 54661849 2863688 37520816 969047173 342095773 30250968 342095773 276328241 927144996 410948729 243184133 776411535 375673404 642955944 382463468 74052733 6...

output:

1442013830
1552823070
1552823070
455197368
1127337466
1442013830
1552823070
1127337466
943354503
1442013830
1886709006
1240480143
1886709006
298417890
1552823070
1442013830
943354503
1886709006
1127337466
1552823070
2329234605
917074890
927144996
1442013830
910394736
2063782011
1886709006
1886709006...

result:

ok 100 lines

Test #12:

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

input:

100 100
520629083 383567120 960042328 412689547 620465379 20255756 199566622 540035660 707148558 969898566 908761562 13157039 368209630 707576985 13157039 241863419 143357997 785467043 13157039 707148558 309328348 857927544 143357997 982461853 270069211 684600888 766546640 309328348 185389484 337461...

output:

684600888
1414297116
2828594232
960042328
1715855088
1892471058
4242891348
969898566
908761562
2573782632
2053802664
2828594232
982461853
1892471058
2053802664
982461853
1414297116
2121445674
2573782632
1715855088
1627209908
3431710176
1715855088
3431710176
1892471058
960042328
2053802664
1892471058...

result:

ok 100 lines

Test #13:

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

input:

100 100
217694013 40877234 409571550 738524506 217694013 668910797 653405326 137537727 608109587 63788176 51095799 653405326 137537727 217694013 217694013 63788176 653405326 653405326 653405326 459499714 40877234 865136713 732422649 296162523 40877234 488353273 310048859 459499714 268876317 65340532...

output:

1601790042
1306810652
1176333754
770280489
819143100
3851402445
770280489
4621682934
2613621304
1635534204
3203580084
3267026630
1540560978
1635534204
2310841467
3081121956
976706546
3851402445
3081121956
1601790042
1635534204
2402685063
800895021
2402685063
1601790042
2310841467
4621682934
84029414...

result:

ok 100 lines

Test #14:

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

input:

100 100
672906676 736275913 272038987 725246043 725246043 336872008 836864579 803474816 921852672 963144374 921852672 763164960 836864579 263409624 963144374 420825781 272038987 924608718 207230116 422840879 672906676 921852672 148607224 804573793 803474816 963144374 963144374 104039459 103877886 33...

output:

2974409331
916902502
921852672
3852577496
829879409
1982939554
1926288748
2974409331
1926288748
5778866244
5778866244
5778866244
963144374
3965879108
2889433122
963144374
2889433122
2175738129
4815721870
2974409331
2889433122
921852672
3965879108
2175738129
1281255352
2889433122
1926288748
184370534...

result:

ok 100 lines

Test #15:

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

input:

100 100
500029087 757942254 672598530 757942254 672598530 757942254 132888556 442116779 681762001 700780409 681762001 750501952 500029087 198125492 298093619 753866067 681762001 753866067 681762001 875875292 672598530 753866067 239988957 757942254 757942254 403125580 500029087 500029087 132888556 89...

output:

6821480286
3031769016
1000058174
2273826762
3789711270
757942254
3408810005
6821480286
1515884508
891556327
9095307048
1515884508
3031769016
5305595778
5305595778
3789711270
3789711270
4547653524
5305595778
4547653524
3031769016
891556327
9853249302
2273826762
3031769016
6821480286
3789711270
378971...

result:

ok 100 lines

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #16:

score: 10
Accepted
time: 1ms
memory: 5808kb

input:

200 200
413104 393805 535489 246881 273243 192479 413104 263176 468891 808060 895287 246881 826649 687669 358084 413104 137 294441 192479 521431 222323 137 302654 449012 137 830490 896701 222323 675260 842627 793126 246881 830490 35761 449012 192479 468891 35761 633970 77383 829912 37039 960909 8195...

output:

3374912
6276907
5380206
992891
5380206
679244
992891
2531184
4483505
5380206
960909
5380206
5380206
1586254
1921818
4152450
1660980
1793402
2531184
633970
1660980
5380206
2491470
1793402
679244
1793402
4483505
4483505
2531184
1793402
2491470
1586254
1921818
5380206
413104
2491470
7173608
5380206
415...

result:

ok 200 lines

Test #17:

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

input:

400 400
1331419 59050 5826792 2193336 5158559 738112 5687862 7978857 508606 4734158 308705 738112 2885506 1331419 5254124 9360986 1331419 9360986 9722745 7671378 9485330 7671378 308705 2722584 1331419 5158559 11882 6070595 6306796 3026849 4456441 3643152 2601185 2740105 1331419 4246126 6007758 76713...

output:

13719818
31915428
73987727
73987727
12141190
87440041
60535413
47083099
60535413
9722745
56603820
5254124
28082958
73987727
12141190
66037790
67261570
80713884
26904628
12015516
40356942
9605241
18970660
67261570
47169850
31915428
19210482
67261570
15957714
18023274
94166198
25699023
20178471
566038...

result:

ok 400 lines

Test #18:

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

input:

800 800
97551795 22911309 85531740 88342417 94408588 15460972 72845485 88342417 55367229 95175687 65534279 86084191 27744386 43783459 43563533 63702796 52226711 52111625 35252629 90958709 84703282 48639488 68474328 32605476 32605476 4252132 75371912 27744386 29495142 79306949 50732929 46756221 50965...

output:

509622368
937383390
562430034
410845968
468691695
788074308
700510496
562430034
1593551763
509622368
516505146
937383390
342371640
1312336746
1406075085
1218598407
1218598407
562430034
344336764
656168373
374953356
468691695
410845968
374953356
1687290102
75856346
749906712
141657738
187476678
18747...

result:

ok 800 lines

Test #19:

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

input:

1600 1600
752283730 403334451 998820720 334109976 982030645 920947986 982070163 667191407 738865013 528613830 359620123 934761921 982030645 819997112 207762948 685595251 689430134 707847886 683134840 308613766 552023816 577435555 618657024 738865013 506553684 206982241 956238450 310744812 16310877 6...

output:

17656755606
738865013
21748769410
4673809605
25223936580
20179149264
6619190690
8510388030
13452766176
15134361948
17020776060
25223936580
23542340808
15134361948
15134361948
4102270060
4433022325
2580826875
21860745036
3782394680
2762843958
7567180974
6726383088
6619190690
2946091935
13452766176
75...

result:

ok 1600 lines

Test #20:

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

input:

3200 3200
83966 90228 24512 34283 67208 96883 12478 70007 30383 84574 42810 90009 87705 41216 37066 88835 73094 71082 7667 80794 54331 14657 60007 9020 12478 7394 73094 21165 82437 4348 30383 79218 84501 52901 28825 9549 81697 71082 61762 83795 77149 42032 52865 78132 17733 83795 41216 15599 24748 1...

output:

4050405
2790279
3600360
4680468
3734260
1890189
3780378
3690369
3420342
1170117
2970297
1867130
2555020
1227870
2160216
793720
3780378
3060306
3046370
2160216
2948100
3240324
1403280
1440144
164874
484035
1800180
2358480
1440144
2555020
1179240
292083
3420342
1440144
3240324
810081
1980198
2456750
1...

result:

ok 3200 lines

Test #21:

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

input:

5000 5000
3225 3643 9366 194 7868 6482 9966 6895 194 9961 7373 9466 8270 8925 4318 6083 9052 9366 883 6482 6466 6895 2106 342 744 4971 342 811 9961 6493 4971 8087 1120 5885 4061 8818 6391 8412 9910 883 6440 4061 7309 4971 2106 744 6895 2106 5572 8690 5741 5282 9052 8412 8818 7373 4617 9237 9966 342 ...

output:

657426
185178
29883
547855
956256
508011
328713
1175398
393372
199220
1265047
517972
533736
583156
533736
543620
128492
268947
553504
82700
721532
286636
159456
128492
1314852
348635
946295
936334
622692
108724
79688
926373
488089
378518
378518
249025
258986
906451
148260
583156
876568
707231
365708...

result:

ok 5000 lines

Test #22:

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

input:

5000 5000
200 4 828 252 404 212 780 947 163 595 755 969 445 416 764 4 678 375 455 259 239 755 832 25 290 522 947 769 933 144 365 121 763 445 643 212 600 343 904 776 780 269 360 535 832 269 570 812 41 604 947 158 834 312 66 662 210 82 487 494 423 210 749 643 200 828 434 982 135 903 893 777 570 947 46...

output:

26180
23409
23100
28611
18207
12288
29478
12138
40749
26010
23870
11808
26010
48552
24640
11752
39015
21560
62370
10010
35547
28611
34680
16473
16170
13062
20808
33813
10008
4665
19074
19941
47685
33880
15846
45430
49280
21675
46970
10780
8547
16473
2496
4335
30030
30345
20016
7767
45430
7803
34650
...

result:

ok 5000 lines

Test #23:

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

input:

5000 5000
27 37 69 74 57 79 38 9 98 31 81 27 76 74 98 9 65 76 69 12 81 79 75 92 34 9 37 97 68 38 37 80 37 97 69 75 98 31 97 68 90 33 97 80 75 33 80 31 37 38 27 97 68 81 65 38 38 68 57 9 68 59 74 57 74 59 16 98 79 37 38 69 38 97 38 65 37 79 98 16 75 27 97 31 68 80 37 13 69 74 68 75 37 75 68 65 59 59 ...

output:

12740
20580
5292
5684
1372
6660
3404
4410
5292
204
3552
8134
873
29988
5032
16132
7938
882
6438
17834
4144
8428
10656
4606
8288
15540
6586
4116
11322
4144
21952
1850
25480
3977
8732
2842
4070
3996
9310
17836
888
11988
9212
2156
8918
3626
10804
2960
14430
1649
4704
16758
3404
8140
15876
25578
2940
26...

result:

ok 5000 lines

Test #24:

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

input:

5000 5000
2 86 72 86 82 78 18 97 2 82 34 73 87 4 4 96 4 37 12 4 15 4 37 15 14 64 86 4 15 15 42 15 91 4 4 55 4 4 12 97 86 97 86 55 34 42 55 42 100 5 4 86 68 100 55 37 2 68 9 18 34 18 22 92 82 86 2 4 15 14 15 7 71 87 14 68 68 82 100 37 86 82 37 14 97 64 18 97 15 18 36 34 14 15 71 19 82 2 39 32 92 4 55...

output:

1806
4214
2580
4300
1400
3200
12556
12040
6794
3182
9030
10922
10234
86
1720
15738
4214
5590
3698
8944
13674
9202
11094
5160
3526
14964
4902
5848
2236
1892
1204
5332
7912
2666
1462
6192
1032
1204
5504
5160
3440
14104
97
344
2100
3698
2800
1230
5074
1892
8342
384
8342
12986
21328
3870
12900
12298
842...

result:

ok 5000 lines

Test #25:

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

input:

5000 5000
9162 4811 2501 5965 4117 7754 990 2879 2523 9746 6440 7828 3052 7263 7705 2475 6029 3344 2646 4386 3966 6736 8353 3517 7190 2582 4547 1476 5843 4908 8761 3094 6239 3936 5390 9042 1476 1979 334 2045 4082 7030 1747 6456 8426 3290 4601 4406 6702 465 8914 7840 6163 4535 2458 698 6443 7987 6301...

output:

11942
69762
89820
35812
14180
80577
27369
48165
79840
18682
78232
18112
97790
48165
107569
80577
21270
76032
39116
58674
32156
47154
89820
35812
51234
48895
65674
19407
79840
19266
49830
51882
71624
29636
59796
9989
18290
107569
39116
79840
39324
88011
19558
68453
16078
97790
24024
46910
109780
3986...

result:

ok 5000 lines

Test #26:

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

input:

5000 5000
936588 616944 21929 415171 725946 125765 56644 561842 671663 695236 570510 561842 172622 943020 253804 51856 415171 970931 75457 479857 663314 183454 915545 852233 152141 651028 621029 37154 93732 441614 906935 319065 341582 565858 861393 249631 991830 405740 653925 245640 815343 504183 91...

output:

8185986
4547770
4547770
7276432
9095540
2832174
2975490
944918
3809100
9778604
6807647
3841500
8185986
9095540
7711032
6222748
7780168
8752689
4444820
9280680
8185986
7384000
5713650
5333784
4819395
3838476
3712272
8185986
6807647
7276432
3712272
2975490
2546475
3638216
2849940
3555856
7780168
63668...

result:

ok 5000 lines

Test #27:

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

input:

5000 5000
20912313 17946169 11616126 67356452 77648947 59988047 77086480 58859164 17918636 56924098 71608385 11839883 86125118 27095773 90180850 63260589 82807557 49639453 44499261 81940445 19849849 8613817 97649851 53710242 95661725 17918636 54401898 7511582 64240160 81940445 46517190 2025695 43567...

output:

812744973
1352589672
979553140
99158460
473557970
1031057588
623653541
937325080
489776570
685687198
783642512
189423188
424532830
843592572
489776570
534560178
602020349
1159362576
677132022
344011628
1204338674
843592572
632134979
290199438
356373452
534560178
722439976
869521932
264297543
1966097...

result:

ok 5000 lines

Test #28:

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

input:

5000 5000
419592551 725024313 814236516 332483638 574572197 603257989 738068114 345308216 602972624 522980014 516254240 437530936 652661622 621211864 993234970 376826055 831920469 576260865 862711661 816198051 909140638 923286667 424062021 140541066 540351709 975643159 348433598 311181395 844646316 ...

output:

7429377368
4359384555
4627528750
10462522932
8968826583
8968826583
2913117183
8968826583
9893645860
10883010446
2786016513
7306205848
5978216288
997707412
4946822930
6392930117
3894506288
8904281274
10883010446
4359384555
3986145148
6815386004
9893645860
8904281274
8904281274
8358049539
3986145148
6...

result:

ok 5000 lines

Test #29:

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

input:

5000 5000
662302300 833874058 118449915 273466016 15059125 58570005 167332704 378137319 466888531 465749199 94166178 386949455 781836910 662302300 11094972 996196700 678542666 265781900 206979021 460523656 541511620 82352448 843664559 820546276 320692628 707429963 257514013 640779180 684836723 11844...

output:

3743251756
4790409220
8234251520
6706572908
3405504136
5108256204
14821652736
4195962500
8397181767
3682846276
7866187520
1547194372
10816007840
6728252776
6882914080
3584720300
5748491064
16781096814
8410315970
8884110078
990288763
11799281280
2150332911
2782196589
9251347567
5887221179
10816007840...

result:

ok 5000 lines

Test #30:

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

input:

5000 5000
976614198 976871517 398719226 326243712 731966428 619727191 746430946 913865547 656002601 493468948 112522666 830658934 209152990 613290217 26936825 71057077 849433483 995759422 427424502 174211587 183269977 286389172 989194100 333340395 60536381 706814201 55008661 785997458 70792193 82833...

output:

2249817342
1986797774
7997687744
7080101172
9234133601
1668928514
10913066983
3749870392
6293423264
7084784056
9363757029
5554115196
9234133601
4450702625
4720067448
7997687744
3357866764
10073600292
10996820648
10913066983
10215007668
10996820648
12592000365
10215007668
3983037688
10996820648
10215...

result:

ok 5000 lines

Test #31:

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

input:

5000 5000
111286492 454347698 452322220 111286492 444942730 936494187 678537000 275613864 35150019 444942730 505189677 509216070 509216070 268342428 406411410 452322220 400737527 582370125 441302310 582370125 454347698 26442720 659648471 268342428 244517681 473714888 452322220 530071914 268342428 26...

output:

10904344752
170312787000
28498554000
66496626000
50890275000
115351290000
141135696000
6785370000
72603459000
7269563168
101102013000
95673717000
62425404000
100423476000
25784406000
23070258000
54282960000
119422512000
40712220000
2035611000
8142444000
75996144000
81424440000
71924922000
1825264530...

result:

ok 5000 lines

Test #32:

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

input:

5000 5000
260215717 260215717 465379175 919681228 919681228 465379175 919681228 260215717 465379175 465379175 260215717 260215717 465379175 260215717 465379175 919681228 465379175 465379175 260215717 465379175 260215717 465379175 260215717 465379175 465379175 465379175 465379175 260215717 919681228 ...

output:

164622939812
809319480640
929797721508
508583719084
675965702580
476394876104
123237284552
144389952796
27457371325
579399173640
460760295228
140711227884
397302290496
28510118068
13795218420
159104852444
837829598708
84610672976
742182750996
59779279820
343041098044
137952184200
256591062612
105763...

result:

ok 5000 lines

Test #33:

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

input:

5000 5000
524809295 946347205 935039059 666228802 226065831 541749154 567579331 3015542 6927080 594428861 594428861 927238393 319899927 662371814 473979715 412704139 683682191 283020036 14430539 656903108 31611631 957519293 406913979 485453290 70505959 918062996 473979715 907645967 742932625 7291959...

output:

6105115352
4446437765
9364449900
13309715104
3573335132
4666626440
10578420611
10300894890
5445893904
6199192230
3556643544
5477867976
10814143522
4457595750
3960467728
2932432074
8168840856
5200528375
11540095212
6353542888
10814143522
6788581218
12477857910
2495571582
6788581218
1734587926
9984138...

result:

ok 5000 lines

Test #34:

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

input:

5000 5000
225427571 235875597 476333011 5489777 616192133 44849133 579498062 789662763 565223503 869386052 983139754 707397839 707620197 83409655 784182552 980651478 20546898 325859754 375588287 58079186 858133060 790865580 237052010 158958918 443869337 783390620 139042165 81380501 802407850 8262561...

output:

4106067985
4912266054
5004966743
2622303504
1645205772
3374469084
4289971494
1957557002
5004966743
4289971494
5730977063
4912266054
5004966743
6549688072
4927281582
3374469084
4737819110
7864947739
5004966743
3570361035
2456133027
5883479394
3720839512
4902899495
3720839512
3934098608
3934098608
156...

result:

ok 5000 lines

Test #35:

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

input:

5000 5000
709057104 741246777 729151773 764797648 24862604 203710491 961949196 885696969 218070447 313029316 327928273 390011052 461030417 776676689 462366796 882035605 248232120 751875785 743775810 850124667 150579337 726053062 399796841 495201682 330865413 356014160 53119199 866877873 987217143 73...

output:

5928874581
4074571760
3279249192
1442442878
3279249192
4074571760
5915453848
995912722
4074571760
1743285136
3900339788
4848815826
5704400464
615288282
3609551688
6755762196
4848815826
1743285136
2800071333
1806937972
3232543884
3279249192
2086217298
4040679855
4040679855
3002560976
1119446378
45038...

result:

ok 5000 lines

Subtask #3:

score: 25
Accepted

Test #36:

score: 25
Accepted
time: 1ms
memory: 5884kb

input:

100 10
94302 31477 94302 94302 10441 10441 86708 31477 94302 30669 10441 94302 31477 86708 94302 40289 94302 94302 94302 90836 94302 31477 10441 10441 90836 10441 10441 94302 94302 94302 94302 94302 31477 86708 94302 94302 31477 90836 10441 94302 90836 94302 90836 94302 10441 10441 94302 30669 94302...

output:

943020
94302
377208
90836
471510
188862
471510
282906
94302
282906

result:

ok 10 lines

Test #37:

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

input:

200 20
374289 810975 157235 730522 721297 188533 730298 81544 266130 154041 675572 374289 897414 84451 959418 256494 599604 802462 706457 462018 730522 466074 897414 699704 599604 76627 676693 84451 266130 513825 710462 771114 966777 730522 266130 592610 7592 256494 858800 24600 441134 205888 706457...

output:

2715075
897414
1794828
1933554
1742258
1742258
2715075
1946716
897414
2878254
2131386
1946716
1742258
2715075
2131386
2131386
1185220
2900331
966777
2900331

result:

ok 20 lines

Test #38:

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

input:

400 30
373644 835047 835047 835047 835047 373644 835047 835047 835047 835047 835047 835047 835047 835047 373644 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 835047 373644 835047 835047 373644 835047...

output:

16700940
42587397
10020564
10020564
29226645
23381316
10020564
2505141
14195799
16700940
25051410
39247209
35071974
18371034
38412162
20876175
10020564
9185517
20876175
20876175
44257491
20041128
10855611
14195799
10020564
10855611
10855611
15030846
10855611
15865893

result:

ok 30 lines

Test #39:

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

input:

800 100
4287039 3176523 4242515 546934 6547521 3648342 3176523 1807857 2635653 491068 3176523 895497 4242515 4154641 6554432 3894353 2919105 5999344 546934 1748809 546934 9140978 1802380 4011932 9057650 8593470 6649356 6649356 4154641 9140978 6547521 1977009 4242515 4654169 4287039 6554432 4011932 1...

output:

8485030
23726556
18281956
9057650
23726556
20059660
9140978
27422934
16878444
18115300
18115300
19948068
9529569
13108864
18281956
13095042
19642563
14593368
9057650
23726556
13298712
11519364
9630078
13095042
13095042
31635408
13298712
8485030
7322837
9140978
9140978
5433544
18281956
13095042
80055...

result:

ok 100 lines

Test #40:

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

input:

1600 1000
8532673 3669470 3993863 9827948 5611241 1006032 7000798 7791048 8697918 2873316 4678343 9464647 5119551 572483 884223 918071 5141340 8263775 4457668 4671285 6189348 1740180 9093480 9412898 9001408 6164626 4671285 1858860 3694603 86385 4794472 4465189 5773914 6108143 8532673 4794472 9581124...

output:

9412898
9769107
9251084
8101298
9212228
9767620
8894675
9767620
17512050
9412898
11234058
14459760
9330140
19080308
9941914
7872427
9093480
9330140
9412898
9833345
10001028
8697918
9461915
7896992
9784796
9412898
9784796
9368119
9895010
14995794
8818631
9358423
9883939
9769107
7052072
9668630
988393...

result:

ok 1000 lines

Test #41:

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

input:

3200 200
53285943 17315326 67769193 74282686 89821050 85717566 67769193 67890785 29958668 20015543 67769193 85717566 88269937 34463715 67769193 74282686 53285943 20015543 95486017 54527206 12846147 16603088 6086214 77644191 28743124 74282686 67769193 88269937 74282686 75634745 2503531 75737445 89821...

output:

668402119
302538980
148565372
346587300
830922230
954860170
109054412
664737784
249276669
190972034
514305396
269463150
498553338
286458051
249276669
477430085
271076772
519978802
83092223
353079748
271076772
543126280
415461115
830922230
605077960
166184446
406615158
954860170
747830007
115529100
5...

result:

ok 200 lines

Test #42:

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

input:

6400 150
54575940 22861739 82915752 70696616 923287 25018964 32638124 47498224 15095384 20234718 55664290 37941983 48341491 73275271 80427501 22080269 84154690 12189546 83471419 80211957 615064 83336781 33080019 33862056 65129182 9389012 89782335 30579362 55577816 7482332 90393263 96978703 76286586 ...

output:

182449214
466014005
193957406
180234642
180234642
179293728
172383210
290162100
96978703
466014005
93355989
278010960
187524040
193957406
180234642
372811204
280951680
298493493
193957406
193089536
298493493
484414845
197075564
182899258
174904582
250414257
166942838
288374742
195507708
92117442
209...

result:

ok 150 lines

Test #43:

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

input:

12800 20
794076529 690881316 281822087 206483725 894778475 80093806 358230205 49086250 200833828 69015507 448465119 656034650 177838362 910460329 447454238 465101410 469322299 685754109 856496379 471048840 562571360 315508100 167358827 588933866 399757342 405461706 819382287 361561726 691735682 9030...

output:

1783575748
2414309721
3378330020
5524869266
3938362690
1500313038
3882128224
2138601912
5083994412
3540435368
4456102070
989535394
2291328282
3277838780
3277838780
2845994455
2682800793
2954918505
4735602228
4735602228

result:

ok 20 lines

Test #44:

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

input:

25600 100
99294941 799822802 31211704 977835619 668490171 745008335 686918973 668675833 44072204 363317490 164695857 376244578 47022650 746146673 719769033 650880692 79828720 668093055 72764072 343771050 603871316 675334411 722705461 954269892 702015614 159202268 647781375 971098541 166145935 695851...

output:

2308838496
1892769750
1955824522
2795588310
1940317960
1813622818
2860150929
3125302924
921054984
2334402690
1833642724
966265571
1972142890
3817057425
1683589784
996060325
1975927044
3188765592
1377173904
1722359506
996060325
3843780575
1989233418
3745865048
1943464554
2018364525
1675336702
1980435...

result:

ok 100 lines

Test #45:

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

input:

51200 320
26807 52902 26807 26807 26807 26807 26807 26807 26807 26807 52902 26807 26807 52902 26807 52902 52902 52902 26807 52902 52902 52902 52902 52902 26807 52902 26807 26807 26807 26807 26807 26807 52902 26807 26807 26807 52902 26807 52902 26807 26807 26807 52902 26807 26807 26807 26807 26807 26...

output:

32693436
13701618
2380590
21213702
21795624
8940438
10267081
16593533
24229116
9033959
26662608
16664130
4390866
7988486
158706
10792008
3538524
27244530
9575262
20737584
18362795
1692864
21107898
294877
16452522
13542912
3377682
12326166
10897812
14495148
6401142
19996956
4691225
14706756
43220934
...

result:

ok 320 lines

Test #46:

score: 0
Accepted
time: 34ms
memory: 7368kb

input:

100000 80000
81982 45175 689584 149238 81982 689584 81982 803999 773751 886636 429114 45175 886636 81982 886636 886636 45175 45175 877538 886636 81982 81982 689584 689584 689584 429114 45175 689584 803999 183598 81982 45175 81982 81982 877538 877538 81982 81982 886636 81982 886636 803999 45175 14923...

output:

23939172
2659908
1773272
15959448
1773272
24825808
11407994
1773272
14186176
6142766
11526268
3546544
4823994
26531967
2068752
13299540
11407994
7979724
8866360
15795684
1773272
2411997
3546544
25712444
17732720
6206452
14040608
13299540
12059985
886636
21938450
773751
14471982
22165900
2659908
8866...

result:

ok 80000 lines

Test #47:

score: 0
Accepted
time: 11ms
memory: 6644kb

input:

100000 70
8426853 4093648 3664160 4183602 2093445 1769466 5576951 8571838 9607697 6317313 3939536 8283897 474182 9942400 8840140 7250000 9312629 5027035 9448543 2273342 3203504 848064 3398415 6519868 6570738 943669 474182 4184453 392848 3636524 6404107 1371159 474182 3318439 1098641 1978056 6840096 ...

output:

129251200
1879113600
627199224
698885850
318156800
566716800
1908940800
514436709
1491360000
522882118
2048134400
407638400
806406750
1978537600
517004800
2058076800
707845925
487177600
1053894400
497166604
162178740
389228976
1469452300
788486600
536889600
795392000
663045550
874931200
536889600
29...

result:

ok 70 lines

Test #48:

score: 0
Accepted
time: 26ms
memory: 5560kb

input:

100000 20100
61946396 91970811 58977875 92447221 23959957 23731861 71921948 9758212 29547247 66149709 99075782 87987005 71491468 87924868 68916532 83684580 80589545 34445261 5425885 74849497 8912166 91138955 44482587 55071678 89117276 58976013 90637148 26257431 63260804 13660909 41620702 63713321 34...

output:

195953112
293539863
224101092
236981250
173321277
296132508
166627744
269288019
294578394
164399592
194542576
262202256
233782917
227535750
245973564
178345304
198232578
196323836
263774604
246357321
237498456
273106467
141602438
195619144
233628834
281944662
185900054
198466934
196385596
194948764
...

result:

ok 20100 lines

Test #49:

score: 0
Accepted
time: 40ms
memory: 7604kb

input:

100000 50000
905033695 75877548 246391598 804441536 541100757 46039721 211709546 183966886 787503271 905209849 13745786 923115318 755390747 853469326 547241331 971450054 963635098 682851953 862310908 400912624 303898754 814427509 22349600 611008391 864491276 909017511 842048255 503360269 684306554 2...

output:

987061965
993714407
1599084182
1916639474
1897694578
997910489
995006382
997187208
999332705
999595717
999370595
997232922
993839602
1398475542
712189381
1109002196
1769613156
997187208
1904908500
878146209
979994656
987061965
977947836
1088933830
1164481502
777691484
998652429
995851043
933199747
9...

result:

ok 50000 lines

Test #50:

score: 0
Accepted
time: 46ms
memory: 7720kb

input:

100000 100000
449378339 929887735 421566929 231284422 858826940 997808137 61483287 768125417 42585833 445973878 976281375 137215671 14277399 458070045 627371790 271915530 820246681 603285655 404415 726195338 401143301 977599478 846703036 944282981 799934762 713721174 674771897 705724542 795451315 51...

output:

228335075
366386873
265119074
792415034
427046313
224780712
278808442
948051272
716999193
178317487
323164828
187470266
257038943
765985471
531860875
685016931
944595609
846007675
779812449
273479941
637750102
248108210
461620097
313457725
623070624
105192338
334022851
318708022
265891187
502530721
...

result:

ok 100000 lines

Test #51:

score: 0
Accepted
time: 56ms
memory: 7108kb

input:

100000 50000
85934804 582005837 895310398 9020543 574293199 960529925 970947070 953047916 103301858 858401873 950627368 131379714 999954686 958019460 926048686 399201733 530409964 55226680 459566783 625246269 737359815 532182967 171057963 127423602 937269606 178613104 550336026 516307014 177492965 6...

output:

1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
1327934156
132...

result:

ok 50000 lines

Test #52:

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

input:

100000 30000
39 48 18 59 70 34 15 72 7 37 9 55 31 22 43 66 54 65 39 81 1 45 90 98 19 96 6 6 90 91 54 98 20 63 93 42 33 22 48 21 94 51 6 69 69 89 65 87 75 88 40 43 82 88 46 30 68 79 56 98 10 71 17 32 10 13 96 90 8 27 23 76 88 29 15 87 78 91 88 90 15 6 40 29 56 21 4 92 16 63 16 63 13 82 16 48 70 69 96...

output:

69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
69090
68996
68996
68996
68996
68996
68996
68996
68996
68996
...

result:

ok 30000 lines

Test #53:

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

input:

100000 70000
6903379 17060335 26321089 7799581 11683123 12280591 17657803 22138813 2123635 14969197 14371729 13774261 6604645 9293251 29009695 29308429 26918557 14371729 11981857 12878059 11384389 21840079 4214773 27814759 8994517 11384389 9591985 14371729 3916039 28412227 10488187 21840079 24528685...

output:

9370307684
9370307684
9370307684
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
9343986595
934...

result:

ok 70000 lines

Test #54:

score: 0
Accepted
time: 38ms
memory: 7768kb

input:

100000 80000
999900000 999900001 999900002 999900003 999900004 999900005 999900006 999900007 999900008 999900009 999900010 999900011 999900012 999900013 999900014 999900015 999900016 999900017 999900018 999900019 999900020 999900021 999900022 999900023 999900024 999900025 999900026 999900027 9999000...

output:

999920000
999920001
999920002
999920003
999920004
999920005
999920006
999920007
999920008
999920009
999920010
999920011
999920012
999920013
999920014
999920015
999920016
999920017
999920018
999920019
999920020
999920021
999920022
999920023
999920024
999920025
999920026
999920027
999920028
999920029
...

result:

ok 80000 lines

Test #55:

score: 0
Accepted
time: 19ms
memory: 7176kb

input:

100000 20000
292 584 876 1168 1460 1752 2044 2336 2628 2920 3212 3504 3796 4088 4380 4672 4964 5256 5548 5840 6132 6424 6716 7008 7300 7592 7884 8176 8468 8760 9052 9344 9636 9928 10220 10512 10804 11096 11388 11680 11972 12264 12556 12848 13140 13432 13724 14016 14308 14600 14892 15184 15476 15768 ...

output:

23360292
23360584
23360876
23361168
23361460
23361752
23362044
23362336
23362628
23362920
23363212
23363504
23363796
23364088
23364380
23364672
23364964
23365256
23365548
23365840
23366132
23366424
23366716
23367008
23367300
23367592
23367884
23368176
23368468
23368760
23369052
23369344
23369636
233...

result:

ok 20000 lines

Subtask #4:

score: 60
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #56:

score: 60
Accepted
time: 5ms
memory: 6044kb

input:

10000 10000
25858 58587 56941 8114 50354 58587 43574 43574 13578 78891 34267 64708 63004 87970 87970 16153 34267 8898 13578 45000 68930 41714 52877 87970 13578 39260 36148 56941 56665 79936 36148 34267 97825 56941 79936 20517 59362 41714 50354 34267 36148 78009 72789 80928 32587 65796 41714 97574 68...

output:

15156396
17869578
22921710
8045988
10197822
173955
22453920
2338950
14407932
17495346
17588904
5800596
15904860
10104264
18618042
2639100
13659468
29751444
315020
6081270
19366506
4022994
20863434
7297524
18430926
10291380
3835878
22266804
25541334
657960
703760
21986130
16279092
2023310
22921710
17...

result:

ok 10000 lines

Test #57:

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

input:

20000 20000
213994 725867 367819 253344 226819 963028 877105 96925 318702 308484 195508 875041 456661 417717 620176 620176 897754 604150 193507 5876 478108 478678 427143 202672 121222 116974 105662 18220 404730 474612 846438 303270 200907 301219 121222 564971 430549 640283 450244 234106 594124 74359...

output:

78005268
5443254
60670764
16474767
79931324
23112672
18297532
64522876
29992080
7716100
15408448
26964784
59984160
5712204
4173080
30816896
66448932
7258545
52003512
18297532
68374988
25038728
16336460
39989440
43336260
90975976
31779924
85977296
16336460
65485904
14445420
14996040
57984688
9478810
...

result:

ok 20000 lines

Test #58:

score: 0
Accepted
time: 19ms
memory: 6388kb

input:

30000 30000
603608 854402 412614 236164 582598 344591 911678 358350 521631 324711 862161 649159 699161 267260 339169 705705 135479 840243 392034 643072 382370 453095 68273 346602 312195 286051 868358 907112 548986 151476 728170 786719 429733 661323 527709 738494 960831 559075 959100 391228 163727 20...

output:

7651792
2999940
16109523
13390636
2994066
10464762
3780544
19026840
8176040
3554132
3926884
10893487
4179540
8955450
17216532
9903170
7130824
9903170
1980634
1967824
6653801
10587036
3926884
13390636
7229456
12434162
3763748
17124156
3182672
13307602
13521788
15208688
1964692
5856802
9658420
3376348...

result:

ok 30000 lines

Test #59:

score: 0
Accepted
time: 28ms
memory: 5232kb

input:

40000 40000
2434031 1327137 5401719 969240 481660 728992 5113314 7797695 2124029 7070310 6124351 4242016 552568 4090322 2380153 1849527 1983900 7863535 5915927 2267279 7216199 3720042 2606223 6904767 8788402 1365183 188035 9808877 9385319 5158912 5275614 2396864 4035828 3220805 4712574 9153260 21608...

output:

56123060
46071970
119937840
92218236
114569604
65978129
46153970
29902506
40087900
116097210
112441725
46153970
82457265
89926790
108985188
126447269
16962100
37798688
32882952
60632838
46114375
37798688
76379736
74106802
97449495
112441725
97449495
74106802
32070320
37899172
56552682
9803095
942544...

result:

ok 40000 lines

Test #60:

score: 0
Accepted
time: 38ms
memory: 6876kb

input:

50000 50000
4569468 3840786 3035444 8837323 9073528 5756764 8679836 1673427 6313405 7670209 92212 9043585 8425933 6241734 2098797 3097912 4046769 2159976 7104277 3958665 5361201 5713842 2926266 7265675 3076374 6583498 8242240 4781502 3203688 8622674 9883873 4881326 611195 5228595 2638848 4956357 731...

output:

84431385
103393851
93812650
84497085
84431385
66123785
122192733
84431385
93812650
77224376
58479522
48732935
131337710
112793292
34544196
22787460
77224376
131592174
77224376
47231275
56287590
122192733
112575180
68226109
87719283
37804136
49564135
33496636
103393851
67571329
77972696
112793292
263...

result:

ok 50000 lines

Test #61:

score: 0
Accepted
time: 41ms
memory: 6952kb

input:

60000 60000
58664964 61162603 48592500 88119315 32340153 45319061 68564024 33851018 29726210 98181266 34230595 59855912 84197703 61422403 2257965 40933615 49667105 16813041 62500235 49972668 63989489 9950166 49660516 33484191 94866967 58170449 55047440 27969250 41645888 45353803 53467292 7122564 645...

output:

2052910839
918845170
2491083925
2197852825
395733288
345864968
2491083925
974450653
3183941600
1791003582
2590727282
807048670
1992867140
1745805823
1173091908
797146856
2889657353
3283439775
2109938712
1992867140
560654604
747539472
3088944067
2494797175
3581934300
1934110486
496204566
696487225
10...

result:

ok 60000 lines

Test #62:

score: 0
Accepted
time: 41ms
memory: 7392kb

input:

70000 70000
4364437 25904783 41498036 39535480 25303976 19820735 68207371 42803217 17661753 28531272 54854237 95048846 97789729 39775961 29788488 13127866 51784123 1015288 34130163 75393246 48709952 363831 23330774 18991874 25904783 89652377 11682221 48709952 80773742 75336539 52423877 64185902 3739...

output:

6563454804
7151226876
24392540988
32915236032
14694301800
3036822372
23801922396
9634111446
14400415764
21346168498
11265631380
8689590716
41731817112
21159794592
24935347272
36245944440
2032959048
21912880936
12656577782
8816581080
4722603650
10484180103
3400274628
2938860360
1861278228
10873783332...

result:

ok 70000 lines

Test #63:

score: 0
Accepted
time: 51ms
memory: 7456kb

input:

80000 80000
384132197 200754553 316612242 29288873 715901120 185113112 49128138 121227184 749364474 561116296 507639490 200754553 289481737 749364474 289481737 430335478 200754553 749364474 29288873 316612242 430335478 200754553 121227184 121227184 585463409 316612242 316612242 121227184 224405624 1...

output:

2130443199582
92921194776
4069049093820
293001509334
2137187479848
1757259691530
1970079202146
1487488480890
3075391801296
3247745630316
2797377581442
2634765490584
1752014140212
1136036542584
705151970034
3532504130436
355198760676
3437334842238
1206476803140
2128195106160
2308791944394
81905537008...

result:

ok 80000 lines

Test #64:

score: 0
Accepted
time: 65ms
memory: 7072kb

input:

90000 90000
751293300 588237824 588237824 588237824 588237824 281410850 281410850 751293300 380374760 281410850 177867810 391447551 380374760 907066746 177867810 380374760 380374760 281410850 177867810 380374760 281410850 281410850 281410850 588237824 590275115 281410850 588237824 177867810 75129330...

output:

5162963381248
1214122868736
24117750784
8811214365696
6130614601728
181765487616
2230009590784
3244131599360
2067067713536
11071812323328
680591162368
2788247285760
1807654833152
3964134695936
6894735535104
2620599505920
5172375186432
217647994880
9132392217600
1477065176064
1349417568256
2580599333...

result:

ok 90000 lines

Test #65:

score: 0
Accepted
time: 119ms
memory: 7792kb

input:

100000 100000
76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 85047 76652 76652 76652 76652 76652 76652 76652 76652 76652 85047 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 76652 7665...

output:

1666261176
3126328472
4780478632
1181054016
294880244
4172934880
1774493800
865707688
637591336
454239752
233941904
341484660
1064006412
340028272
5146798540
4312901432
2251039284
4712948220
838802836
3379203420
756248632
3938992976
1313355368
935231052
1242145660
468726980
2956007728
1036488344
120...

result:

ok 100000 lines

Test #66:

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

input:

100000 100000
691365 437622 691365 691365 436502 691365 691365 837404 702275 142822 437622 436502 691365 837404 837404 436502 436502 702275 437622 735513 436502 382413 111896 837404 691365 837404 691365 691365 691365 735513 837404 691365 837404 691365 436502 691365 964109 691365 735513 436502 691365...

output:

184594455
5965788585
11899083015
3775544265
8410455225
290373300
2912029380
7449457875
11784316425
4355599500
4286463000
6502979190
758427405
1903327845
2680422105
593882535
2617507890
4674318765
10478327940
571758855
78124245
4795307640
3783149280
1473990180
8493419025
11427572085
3519047850
832126...

result:

ok 100000 lines

Test #67:

score: 0
Accepted
time: 72ms
memory: 7736kb

input:

100000 100000
2675024 411787 7508923 1470914 248307 8073953 327181 6872271 3157319 3391267 468738 2652148 883782 3422227 3109423 3855433 3231704 2635679 505163 8228989 8073953 7508923 3231704 5828005 9914705 1997216 5828005 9940774 2695410 9468863 5887968 9313651 505163 8063368 8731866 327181 478861...

output:

6211574128
3021995296
943098354
3240692324
1083544366
8029595824
2708094818
2717563681
4701986102
949219884
5914760530
4026013470
2733712850
5397840282
6893332264
353846527
1477142628
6650377806
310240044
7887562879
7309962236
1547049932
8256848536
3480862347
5387783047
1802148591
18638505
162597850...

result:

ok 100000 lines

Test #68:

score: 0
Accepted
time: 74ms
memory: 7804kb

input:

100000 100000
444780 32405899 67744669 43568734 52879254 13925457 43669144 21299268 32216306 5987973 5215209 17719715 45486767 44040086 27905493 17628189 60886859 82186573 38849726 3544625 77537270 67609701 49527430 32466368 12278814 24609947 55822585 21263387 78617436 47037287 74750969 73235404 811...

output:

3430310592
1406785343
2648458400
1375096884
954704316
4007314239
4243038606
1215644080
4385089978
1571495780
3361220676
1964369725
1876445970
3064416771
289639362
1994235800
1216777874
2677315584
1811232817
5028786496
2891660905
1476139240
1216777874
2985841982
998094372
2196247020
483218245
1796929...

result:

ok 100000 lines

Test #69:

score: 0
Accepted
time: 99ms
memory: 7760kb

input:

100000 100000
654692672 974181878 206552310 342673956 38427347 4256183 352712125 576528417 212636018 796301691 641236766 901469785 85598620 276667953 383004021 318962270 32103335 561132184 961902317 392001001 868870239 140424636 356759969 642813881 948692686 944929328 177376103 147402993 324189264 6...

output:

11387647044
7675069600
2741612316
7977553432
13285588218
8811063135
2989683912
9790070150
3931069228
1846284242
8097408945
6397095404
2660440600
7259965464
6209063584
6453744213
1973982124
11387647044
11387647044
3561476672
8224836948
4656797688
7310966176
4744852935
3917347105
6453744213
5998496454...

result:

ok 100000 lines

Test #70:

score: 0
Accepted
time: 106ms
memory: 7476kb

input:

100000 100000
454246161 305311217 997654494 875841480 983861446 938320282 594666376 658534317 993170569 170829091 695918829 834921473 915362425 361164883 437539535 329084454 946219372 66543554 881466420 974547109 106959829 671484935 495732496 333736101 998507493 984179279 997855593 989517976 4380602...

output:

6588491091
4926436410
7631449344
6797981512
4506487565
5723587008
4749253730
3994251128
1917826792
1982961566
5826841296
4938226025
6588491091
6314451752
2933578251
3878535860
7380653144
1940898310
4926436410
3391675056
3799402984
5420123802
2984121504
6677518176
3950580820
4938226025
5826841296
299...

result:

ok 100000 lines

Test #71:

score: 0
Accepted
time: 103ms
memory: 7448kb

input:

100000 100000
983635903 399379422 599250853 340735119 434173451 423605188 589642968 787423102 707182556 222280015 964942216 309880005 980053146 797675555 337310034 380636084 370489075 26247765 249402473 993621458 620503636 887731113 639662092 667564143 56817997 44449188 342250992 624926960 886339928...

output:

6778055305
1957505174
4956065690
1932546258
8813510604
5809761690
8813510604
3957806020
6828787266
6778055305
8323704480
1802181642
5809761690
4866392145
2873082243
5853246228
3444015088
5115778556
5853246228
4837236730
5547573402
3917115824
4866392145
2996338956
2991727065
5030433102
6828787266
395...

result:

ok 100000 lines

Test #72:

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

input:

100000 100000
194961603 415983660 746852871 560544570 896756867 722160395 322267931 330737732 747004688 654867793 920128851 603770869 148547915 698496466 772222416 785257357 275668421 896440990 420832014 892415460 268732543 341829150 643069212 977820423 668631508 83175923 754590965 582133603 8273949...

output:

9705766020
11646919224
4654774270
2387996589
6794458909
4767611355
9064321050
7764612816
2173426323
9705766020
7447638832
5823821922
3927590536
5274356899
2177077275
6794458909
2246792691
10431281856
6516683978
10676342622
7765095896
6516683978
4654774270
2638587474
3913481580
6027836456
6516683978
...

result:

ok 100000 lines

Test #73:

score: 0
Accepted
time: 92ms
memory: 7736kb

input:

100000 100000
275759910 796446974 873589172 327462602 510773138 755913801 837970996 908553484 941722165 975724156 567764059 576813978 369837793 571788894 110897606 937089642 843016556 296038587 923706760 301134718 490982642 538056120 199032724 140134517 430202635 565736472 828226817 530685532 958699...

output:

4773072100
5971007910
7167978612
7669495056
2983014750
3834747528
5575094476
9901672870
5892682014
7921338296
6931171009
3959587840
9298716625
1990139256
8705080539
10144054500
2011317042
7387193416
8316080690
8911505583
5762856102
3928454676
7078879848
8435053242
8310592593
7669495056
11246737656
4...

result:

ok 100000 lines

Test #74:

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

input:

100000 100000
607779819 583106878 578966347 783580989 84625477 383753846 932335954 230721239 582311545 171595430 52739345 909653640 408928568 601556572 431866195 90575039 328164535 578067488 617945083 858192594 122290439 83701118 323827541 92308758 476409401 797949021 404321934 88133350 305754081 42...

output:

5766966576
1990298264
10668142738
7758649264
2662508586
6552663397
4213532090
9047040387
4864017420
6705678938
6398780886
5648690568
11637973896
7758649264
2662508586
4213532090
9869498604
10691956821
10691956821
2883483288
13577636212
15517298528
5848537932
7820732194
6489991627
3660712580
64899916...

result:

ok 100000 lines

Test #75:

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

input:

100000 100000
336314987 74649509 206925806 381193170 349439615 219378438 47808311 858195916 691376413 732713643 603403458 791204376 606850978 320275601 320932763 160997483 742541715 742080198 579162232 115452231 769765371 511924371 502437484 341580058 582632435 498070162 561030409 195551021 55970032...

output:

10922847067
12135383403
7943888776
11590395156
6961973662
10922847067
2998841853
10624528893
6961973662
12556261419
8471971332
10268401341
1759181996
3890559864
11915833164
4064474660
5957916582
5587587438
8936874873
2315188344
13522127682
3980308968
4102823225
6832977032
15453860208
13522127682
109...

result:

ok 100000 lines

Test #76:

score: 0
Accepted
time: 99ms
memory: 7252kb

input:

100000 100000
315039693 104530792 537933017 507389801 518737258 530688764 488871941 373955693 977479959 42791058 683917360 327410256 89120741 133765541 535725950 799425041 521631502 983127863 405775594 56909615 534199552 402869540 454852839 706173519 646901589 612689118 280430223 206240723 15147956 ...

output:

11587606272
7955132056
9397384070
7590357846
5060238564
1897068306
10621972416
5936869140
13959358182
5246002200
8161793840
4820003060
10924212900
10337122477
13959358182
9366979250
6031930905
9397384070
6962869896
5060238564
8703587370
5982582078
13959358182
7976776104
4152580545
10924212900
665265...

result:

ok 100000 lines

Test #77:

score: 0
Accepted
time: 94ms
memory: 7672kb

input:

100000 100000
346798764 865903415 359727631 244511436 836678421 954460012 232705299 367473229 808010011 371573941 12759216 423620301 988980693 638675623 670209261 540059462 568538097 357181417 525219507 562856565 333631516 80722655 255734945 598384227 143387214 439282208 2162254 262746676 928940018 ...

output:

13981987880
11984561040
7847420168
10980055031
3794574124
7561081120
9115237668
5783609946
7847420168
5485944696
13981987880
18975554980
16978128140
4999883380
3429139540
10985847620
20972981820
10295086716
7989707360
9255305000
9874840807
6934878559
7847420168
3715760072
7989707360
16978128140
5783...

result:

ok 100000 lines

Test #78:

score: 0
Accepted
time: 99ms
memory: 7068kb

input:

100000 100000
104143649 249645093 628838170 662096892 128383562 521046496 493576864 313782231 720024970 742587074 958247501 73479658 277139219 607675998 296092876 176425659 300933646 757306530 302468375 211658997 263484029 763326639 484045352 701168536 531306144 103673220 299297994 254518840 9515990...

output:

4909137670
7284936832
5450166384
3013241896
10595672538
8140953519
8610872445
8610872445
7755892128
6983786120
15713518770
5309914536
14840545505
13967572240
6141742593
4857124795
7654108840
9045503910
3690619524
5991317535
2742728811
8867951199
7964871804
10270830060
5991317535
10016788144
42795125...

result:

ok 100000 lines

Test #79:

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

input:

100000 100000
294712499 796644566 680938727 253466187 380958772 664597387 320168885 96798574 664482415 678813038 748729591 17025824 89721201 650128067 401327124 268052725 847363275 582332980 43606743 386780775 219576380 607650924 357979804 796867720 4624215 277859816 435229584 662243504 646827588 54...

output:

4318884975
4635753795
5821485780
10851307852
15783720512
16919316572
5821485780
2991505974
5095675620
4657156905
11943046992
3708603036
3049972036
9952539160
7962031328
10198658349
18434704970
2889538368
7921437768
6966777412
4988744605
14797237980
10851307852
13810755448
8344356831
9864825320
15874...

result:

ok 100000 lines

Test #80:

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

input:

100000 100000
658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462190 658462...

output:

31425766479940
5657507136480
9218470660
46581590707170
31876813080090
17370891034390
2278279177400
29540589229970
55246953127570
29996245065450
14070020075920
37542221762850
6544455706410
44801767407600
60874171003310
27622488870500
43959594266590
20041613677030
39663786939030
1145724210600
59357074...

result:

ok 100000 lines

Extra Test:

score: 0
Extra Test Passed