QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#847588#9877. Segment Treehos_lyricAC ✓123ms11584kbC++143.0kb2025-01-08 07:38:122025-01-08 07:38:12

Judging History

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

  • [2025-01-08 07:38:12]
  • 评测
  • 测评结果:AC
  • 用时:123ms
  • 内存:11584kb
  • [2025-01-08 07:38:12]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


constexpr Int INF = 1001001001001001001LL;

int N;
vector<Int> C;

vector<Int> ds;
void pull(int a) {
  ds[a] = (a < 1 << N) ? min(C[a], ds[a << 1] + ds[a << 1 | 1]) : C[a];
}

int main() {
  for (; ~scanf("%d", &N); ) {
    C.assign(1 << (N+1), INF);
    for (int a = 1; a < 1 << (N+1); ++a) {
      scanf("%lld", &C[a]);
    }
    
    ds.assign(1 << (N+1), INF);
    for (int a = 1 << (N+1); --a; ) pull(a);
    
    int Q;
    scanf("%d", &Q);
    for (int q = 0; q < Q; ++q) {
      int O;
      scanf("%d", &O);
      if (O == 1) {
        int J;
        Int X;
        scanf("%d%lld", &J, &X);
        C[J] = X;
        for (int a = J; a; a >>= 1) pull(a);
      } else if (O == 2) {
        int S[2];
        scanf("%d%d", &S[0], &S[1]);
        Int ans = INF;
        // at endpoints of interval as[i]
        int as[2];
        Int cost[2][2];
        for (int i = 0; i < 2; ++i) {
          if (S[i] < 1 << N) {
            as[i] = (1 << N) + S[i];
            cost[i][0] = 0;
            cost[i][1] = ds[as[i]];
          } else {
            as[i] = (1 << (N+1)) - 1;
            cost[i][0] = ds[as[i]];
            cost[i][1] = 0;
          }
        }
        for (; ; ) {
          for (int j = 0; j < 2; ++j) for (int k = 0; k < 2; ++k) {
            if (as[0] + j == as[1] + k) {
              chmin(ans, cost[0][j] + cost[1][k]);
            }
          }
          if (as[0] == 1) break;
          // up
          for (int i = 0; i < 2; ++i) {
            cost[i][(as[i] ^ 1) & 1] += ds[as[i] ^ 1];
            as[i] >>= 1;
            chmin(cost[i][1], cost[i][0] + ds[as[i]]);
            chmin(cost[i][0], cost[i][1] + ds[as[i]]);
          }
        }
        printf("%lld\n", ans);
      } else {
        assert(false);
      }
    }
  }
  return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2
1
4
8
17
18
13
15

result:

ok 8 tokens

Test #2:

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

input:

1
7914575 2436426 4979445
199989
1 1 6190629
1 1 1407775
1 1 2804784
1 2 2631932
1 1 3078537
1 3 286918
1 2 3238506
1 3 3361868
1 2 9296263
1 3 4836991
1 3 2177068
1 3 4291757
1 1 594328
1 2 8996221
1 1 5531545
1 3 3575467
1 3 3206504
1 1 8344965
1 3 6045895
2 0 2
1 2 6248153
1 1 5797489
1 1 9766466...

output:

8344965
5684734
2756417
2512448
130126
7091295
7834895
6363152
6668726
4380822
8809904
4042733
8566868
8653391
3654574
7617913
8583126
4470761
4099069
2539201
7188565
8465921
4517278
1913351
7400947
5104744
1759308
6081288
3559555
3409112
3714298
8937580
4704960
5280672
9424416
1622556
2599805
18330...

result:

ok 1899 tokens

Test #3:

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

input:

1
3080713 6130142 8931932
199954
1 3 3859793
1 2 8302798
1 1 1363993
1 2 2817427
1 1 6031503
1 1 4197608
1 1 3453017
1 3 3258277
1 2 1243375
1 3 7997018
1 1 8659259
1 1 545422
1 1 1213295
1 2 9318329
1 2 1165990
1 1 3910911
1 2 9639614
1 2 3166127
1 1 2556789
1 1 2505213
2 1 2
1 1 8837030
1 1 996138...

output:

5671340
4103158
2278869
1251419
702774
1634200
9066441
3444042
4761391
1317349
996556
3444042
996556
996556
4884903
6746567
6746567
1389661
4920459
230651
935263
2028823
680623
1093324
1093324
680623
680623
369391
6136723
5192803
5192803
6136723
4301516
4578392
3566336
3566336
7599310
4756965
378391...

result:

ok 29717 tokens

Test #4:

score: 0
Accepted
time: 35ms
memory: 3940kb

input:

1
6313638 363583 8248153
199989
2 1 2
1 1 155990
1 2 4430056
2 0 2
2 1 2
1 1 6771887
1 1 9001299
2 0 1
1 3 2051074
2 1 2
2 0 1
1 1 3829876
2 0 1
1 3 8940076
2 1 2
2 0 1
2 0 2
2 0 2
1 1 2321211
1 2 8057327
2 0 2
1 1 553338
1 2 7877801
2 0 2
1 2 2505976
1 3 1153207
2 0 2
1 2 4561192
1 2 4540078
1 1 90...

output:

6677221
155990
4586046
4430056
2051074
4430056
4430056
8259932
4430056
3829876
3829876
2321211
553338
553338
5693285
4540078
4547501
5088001
1153207
3934794
1153207
3934794
3934794
3934794
7085662
3658305
3147631
3658305
6805936
3147631
3147631
853551
2267606
3727767
3727767
2645926
3727767
2645926
...

result:

ok 100061 tokens

Test #5:

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

input:

2
4716625 8732769 4896438 9294402 7273885 4137152 2249944
199996
1 1 5186587
1 4 7722585
1 5 3539426
1 5 1298070
1 6 8806800
1 1 4206062
1 6 6971489
1 5 8825000
1 5 3448517
1 6 9944200
1 1 3672387
1 2 1617483
1 5 8197902
1 6 4298339
1 5 6260453
1 2 3666548
1 3 9334704
1 3 5244559
1 3 2160729
1 6 944...

output:

5334226
9572097
4807948
733673
8100027
6139742
6091424
5926345
8623714
12325259
6201853
1162428
2792985
6816822
9147939
8703527
5455802
2767961
4607887
7567091
1326121
3115123
3452276
7483661
3901199
2876292
3890889
78252
9798360
2638886
8164525
6562024
7215100
4673524
5294603
9171516
5178543
904555...

result:

ok 2118 tokens

Test #6:

score: 0
Accepted
time: 30ms
memory: 3880kb

input:

2
1364796 5777257 6371509 2448237 9098057 7484260 6546327
199987
1 3 5999195
2 3 4
1 3 8887115
1 1 2734385
1 7 4638308
1 3 6026141
1 6 4213294
1 6 5557847
1 3 2560361
1 5 3524344
1 6 2074700
1 6 2999265
1 2 1130752
1 7 3252447
2 2 3
2 1 4
1 4 1415121
1 2 9989166
1 4 3857618
1 7 1787670
2 0 1
1 1 784...

output:

6546327
2999265
5182622
3857618
3857618
2560361
3687472
3687472
2623407
7097702
10955320
3857618
2419123
7980269
15666313
9307178
11416196
5371134
6559731
3730152
5371134
6877903
4359151
3280494
3826548
3826548
546054
2901939
6122499
1164580
4886291
2231873
4929939
10014378
1431973
5738696
3914548
1...

result:

ok 30271 tokens

Test #7:

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

input:

2
8987238 2085975 9756733 3937228 1094674 2515166 9606967
199961
2 0 1
1 4 3666395
1 3 6910698
2 0 2
1 7 8573254
2 0 2
2 1 4
1 5 3266966
2 2 3
1 1 2915552
1 1 4329051
2 0 3
1 5 4369037
1 2 6363300
2 2 3
2 1 3
2 0 2
1 1 4914198
1 3 1997323
2 0 2
2 0 4
1 4 1415720
1 4 1289499
1 2 750052
2 0 2
2 2 4
2 ...

output:

3180649
2085975
2085975
8005372
2515166
4601141
2515166
6884203
6363300
6363300
4914198
750052
1997323
3265218
4512489
4036874
4512489
4681644
4914198
3674754
1990038
5949064
5949064
1997323
5949064
2927673
4924996
3240280
1997323
2927673
5949064
1997323
8732393
3472087
2997143
5118510
6305731
19973...

result:

ok 100133 tokens

Test #8:

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

input:

3
1482396 5315709 8450176 919682 3898524 3571079 1589616 2035962 5516932 5891312 6849529 7354202 7031642 16502 9308215
199975
1 7 339038
1 13 5808906
1 4 3919992
1 5 9215343
1 11 3298396
1 8 5150388
1 5 8504301
1 8 6918145
1 3 9033980
1 6 5735807
1 13 4288323
1 10 8374520
1 10 7379361
1 10 4528048
1...

output:

16285940
5238493
5238493
22472855
4669470
9602957
8393079
10020309
10254346
9573978
8514546
1334143
5464242
3719349
3301995
7390632
14498
8915141
14146684
6366701
3961165
16556363
7660670
703615
6012909
8926254
2066592
119507
3915410
342821
5297748
4461720
14683484
6646771
9060221
16652253
5539517
2...

result:

ok 1998 tokens

Test #9:

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

input:

3
7876562 7918635 6176833 4520847 6020244 5083916 622852 1770395 1392360 8442457 9525646 7836026 7109198 1592189 2928475
199969
1 3 1211323
1 12 6475000
1 4 6251690
1 13 4588701
2 2 4
1 13 2830484
1 9 5455590
1 2 4199941
2 4 5
1 11 4237912
1 8 8616532
1 2 7013262
1 15 1447432
1 10 1885793
1 1 302428...

output:

6020244
4664659
6251690
2864338
12620842
4663182
2809904
3300986
4297387
491082
8535859
4663334
10090113
2286459
5010204
9102340
6155733
7634549
11501377
3479332
7732994
5676990
5079349
7705518
11300621
13032232
6363537
7777507
2257343
13773540
6235980
4805506
6429254
4494831
8735088
7368501
5269100...

result:

ok 29959 tokens

Test #10:

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

input:

3
6577234 7854127 1080391 5145959 8947475 6924960 2198194 754421 9124876 764427 1234813 50367 6595762 5221022 9057974
199974
2 1 4
1 5 5912881
2 2 4
1 7 1124351
2 4 7
2 5 7
2 4 5
1 13 2139694
2 0 5
1 8 6713651
2 1 6
1 15 7871410
2 6 8
2 6 8
2 2 5
1 9 4197528
1 5 6876249
1 12 618638
1 2 5353143
2 0 4...

output:

7899620
1999240
7425764
7476131
50367
7195566
13314177
1124351
1124351
2049607
5353143
2617878
3439555
2139694
9425004
1080391
764427
5353143
1124351
2315204
764427
1124351
10555137
2617878
5482720
5593182
15776159
7481960
4961955
7481960
10493849
4358369
10814204
5221022
6357609
5294962
2276892
435...

result:

ok 99699 tokens

Test #11:

score: 0
Accepted
time: 30ms
memory: 3748kb

input:

6
6200813 2937593 7123154 7432392 9485632 271055 259223 1031893 8048638 4986334 3959447 7363320 1413621 971860 1688778 3534103 8309348 230130 3140570 7936752 1761922 8489742 7183013 8868752 4570229 2227218 4385599 1790428 610780 2973050 8497517 4637452 5834054 4557274 3328810 6585387 7311801 2692566...

output:

9806870
5065647
15037432
13145568
31482337
16007715
11448517
4198846
14424470
4756010
16520128
23458763
14417200
14090570
17775435
7820363
12633290
19577002
11428882
9369697
17942414
10589716
5994180
17140937
21105217
11881698
5967192
10477168
12361991
24044637
17593684
7190071
14655343
13995199
112...

result:

ok 2058 tokens

Test #12:

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

input:

7
208987 6257203 4512956 1974263 7466498 9468423 6551425 8025642 1460368 9146922 9173596 5664587 8067577 7217016 8194745 4585407 1984961 6580223 3462232 193760 790658 2229250 8933709 6060280 7181674 9188343 4630270 7906634 8187194 39561 251177 1725833 1666120 6901270 215771 5217631 4006270 1208241 5...

output:

3869475
13512210
30831753
16777131
18157613
7799209
16418655
16834355
11233913
9439002
11895392
8486245
17514427
5239929
9024447
25793170
9402145
20292990
19648423
18663551
26892168
19151248
16842570
23919723
13148324
16524763
26362332
8088420
29585953
24226686
21833470
28872273
19230627
33057482
23...

result:

ok 29791 tokens

Test #13:

score: 0
Accepted
time: 36ms
memory: 3884kb

input:

5
3222700 7176601 6224055 516739 5171617 1268508 2696157 2454239 6709351 4394692 2724852 8563342 1700330 7116385 280977 2410391 1915147 3781971 1847297 8685269 4665247 7875727 2431681 4774265 7886062 2980001 3946628 8840197 9308213 6976676 6759729 9607250 8401956 5042380 2473955 7879691 6633057 4004...

output:

8658607
12392820
12472651
7891497
17934752
14518681
15159305
7712393
11243360
14137282
8840176
8120037
10876696
16782547
3993360
14584740
9171949
20134410
14555955
9500704
12709310
6727296
16467321
13920062
9903763
12520164
11184915
8150894
1726005
11240362
5804581
5215136
13489658
14979200
13943987...

result:

ok 100112 tokens

Test #14:

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

input:

6
2715015 4125069 7426809 5119556 3817715 7152194 6383444 9292189 2782757 4642390 1259245 6135118 5242820 4492024 737189 3355215 599304 2006282 6479920 7665678 9092673 4302756 3936021 3488492 7111119 4465680 6734895 3271099 8649255 7301068 1995950 8827335 6831957 8878347 5882007 2700746 4938868 2431...

output:

14439446
15839271
24155629
19803407
5457609
21201770
12598088
9894994
12250299
11547486
3758119
18896176
9720151
12690708
13667905
6323215
11800814
11464378
8474223
11012095
16030846
8497280
20275723
14681687
14459715
20030567
13216476
31727949
10987670
5229872
17391573
8421036
16981113
14763848
172...

result:

ok 1959 tokens

Test #15:

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

input:

7
1193318 1585549 3591542 3642730 9311737 5169742 4548888 5180738 5173771 2283841 222251 5708903 5558597 8820839 2301104 5839682 3064865 19893 2421309 896242 7602799 2615059 1784699 9976779 7065939 2937182 8041129 2984786 9035205 5678694 1083799 3139907 8782479 1228785 8669484 3457420 8640339 902341...

output:

13640772
3514555
24330523
23486119
8276235
13610929
25854302
2947173
18153773
24558762
22348615
9882581
22178680
8867622
4709400
19561415
6945960
13485784
10579909
25241187
20244974
11545126
9695517
7831470
15617215
19134270
19575059
14987822
11720636
11791410
24152753
17444119
10871219
12050555
131...

result:

ok 29770 tokens

Test #16:

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

input:

8
76650 4864837 9137349 6670132 4966494 4677550 8058163 1173654 3982903 3817112 9126850 9647417 4777800 8012329 40269 6209883 1418264 2190551 8348582 3345230 593377 5594990 7449618 1903736 2250643 1562894 6636744 5852241 2688206 3946795 9617397 6506600 7105004 3335691 6882874 2472287 5758581 6355787...

output:

20089109
25486332
20784877
14114783
24478296
16624223
14436820
25918740
2729194
21936267
5105087
18535175
27604936
3116109
17133668
20775894
20223131
13357407
5594990
23744816
18705835
18597002
34738063
14854916
17071001
22838269
16807476
14949208
11832259
9590343
13989886
22643551
24157306
10735068...

result:

ok 99877 tokens

Test #17:

score: 0
Accepted
time: 37ms
memory: 3824kb

input:

13
3157923 9182813 8665230 2587210 9805357 7039817 6574884 749368 2655185 1475138 4373954 9321972 7917543 7419023 939656 517151 1222648 8706252 5011851 1200879 305988 6738920 3502163 9341742 1121085 4596775 9359068 1120057 3983754 1913120 44697 1362561 3612677 6866623 7587308 5853965 5144126 9311557...

output:

39892162
43223686
22458354
24594794
16071926
41896911
35835368
32063777
39102493
34975060
39834114
31211656
28060733
31155097
31061859
30794902
27040374
20691693
38998781
14524125
38351943
46248536
48495554
10871827
31873278
41949151
18689931
39500692
21951194
36266541
39451140
34105784
25547425
274...

result:

ok 2002 tokens

Test #18:

score: 0
Accepted
time: 39ms
memory: 4008kb

input:

12
6067035 2938954 6840590 6137807 9147503 8650723 888251 5505957 8765284 4502287 4992036 5836067 2542420 1622884 5283837 8668679 4429487 5648746 1338257 178117 3846073 2103198 1180605 2668162 474378 911473 1218931 9702169 7841420 417607 507961 489498 6961025 5282169 7059367 3446598 7888251 6189651 ...

output:

34368615
35489282
18507911
25126041
42201360
32399497
19408654
24238386
37335806
22807389
48066799
22227561
26995581
29950279
38481021
23214337
44410541
37129653
13029319
34540333
27004066
18261942
26531428
27421829
28680715
29368837
27500352
16522223
18241756
38615220
31391976
29936536
26247078
179...

result:

ok 30240 tokens

Test #19:

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

input:

10
4233258 9706194 8950871 2343344 387904 8095649 7125982 5243185 2440577 6606129 2432003 8017427 6016448 2169208 6031045 4190983 928838 9268608 9294549 3563536 4323537 2502502 4376988 2664197 6666640 3469148 7796274 8142995 4258600 1501095 2754024 7492792 2097074 9973025 6951871 8372425 556602 2011...

output:

16717553
15038615
25783919
23223625
31822718
19214208
30923261
23492355
14724527
17529431
36204309
15682262
16442715
30639343
18201550
17486826
15388346
23979366
18559462
10205628
8004313
31500542
19261776
22574080
23569449
16469519
20318391
24721591
36555452
27666373
14969204
17686196
25896808
2042...

result:

ok 100076 tokens

Test #20:

score: 0
Accepted
time: 30ms
memory: 3840kb

input:

11
4130926 444807 409077 4433596 4452018 1006034 4726804 2553298 2006788 7856980 8443484 1624336 6887706 6695093 3193040 9151225 496223 1097969 7080292 2348834 9867761 9433687 6603007 6640820 3507875 9259403 8600064 3517293 4970364 4022532 5544118 1502496 8944055 3184655 9984871 3524656 3988289 1038...

output:

25719195
25592182
30429586
19323010
16102275
20814144
14156359
20809664
24463537
33794888
27338989
8282000
21614635
27097976
25580268
22590901
26090598
31633131
20156190
26784302
26175339
18667134
14427098
13256006
20980437
18881846
25137695
14549359
17908451
28745238
17240535
13938473
28625279
2051...

result:

ok 1924 tokens

Test #21:

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

input:

11
3669307 9783168 4946600 2609770 9433387 4480558 9671015 7575081 9919695 6352394 7006331 4427592 1786047 3728085 5794682 5228307 6429227 8902407 7885897 9937612 8142290 627401 7057572 462758 6010764 8444155 8733084 8134090 3804865 3300015 5144852 8192981 249328 6310956 1715012 4771928 5852585 1266...

output:

36112951
17306850
17508409
18219399
14202541
29307242
38514292
38773099
40883824
26163943
20180923
37540850
36921270
26671485
20897852
47516342
24145128
22774827
21960399
26380963
23378662
32984852
29579223
28067202
31779544
38136349
22014654
25025866
39040917
32916230
23116385
29053995
32373551
356...

result:

ok 30308 tokens

Test #22:

score: 0
Accepted
time: 35ms
memory: 4000kb

input:

11
4129893 1101991 8476752 2805163 9962668 8569061 9149880 3255313 3029546 8444324 9484932 9764037 6517419 3862907 9495737 902310 5239569 172083 1957300 8833291 5699922 4067532 7723940 4109370 8454648 8141943 9947917 6888306 5075616 6675229 6766534 9725794 8970492 6838103 1537532 2178351 4334801 361...

output:

28599481
24650693
50423871
27565801
47694910
31432665
36946345
29382967
40833469
28397682
29819031
27583282
32864397
26221909
41257097
35745348
31038824
18175436
29724261
38849708
40661971
38790686
31290029
12937944
16780185
35591916
18835139
10696665
25836932
14282845
35223798
28213493
24578676
302...

result:

ok 99867 tokens

Test #23:

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

input:

15
6507299 4697140 1885533 3654208 9632884 4781948 6202020 4838558 1511245 7807141 781706 4573068 7324673 9993533 2279164 7404612 6782393 8564420 9720573 1361581 2827758 1644719 3876258 9692265 7427955 5624165 338836 1701320 1216361 9843909 1840914 8361427 9987400 3124895 2505068 4082498 2610653 290...

output:

29441406
33071936
44518188
25098196
39712368
35855234
48403934
33061493
54864524
29436922
31714779
30630263
30829930
41898906
34913664
45551629
27938106
32893515
45278651
44330590
45645525
23010139
42348614
60609467
27509413
51093209
33617135
39804196
17500001
35755063
33837256
27300893
24348469
395...

result:

ok 1936 tokens

Test #24:

score: 0
Accepted
time: 61ms
memory: 5332kb

input:

16
8433991 4175390 4738438 3180407 5629290 2033862 2012665 7011974 2142223 6644520 1765362 5913035 5144867 9646634 5446902 730837 1684708 6642852 1713312 8753639 7868647 508130 6478108 447480 828947 5174181 4252716 1017649 2231716 3415202 2497959 4479089 9332648 7238017 2294133 81100 3793029 3509983...

output:

29439503
35629005
39170748
33114271
23019795
42716886
39418782
23374583
19697690
26300780
38441230
34697549
15511615
25469603
20690791
31062487
31471145
34810485
47826415
39254578
28636345
43536150
29101368
37718417
33689493
47180644
26801319
32186576
26718336
35308567
31260009
49276593
32630338
518...

result:

ok 30232 tokens

Test #25:

score: 0
Accepted
time: 87ms
memory: 7224kb

input:

17
4504535 5480894 7873685 209868 4813520 7683904 8723490 4026670 3396834 8847740 1755157 5328748 3022115 9303033 5573069 8553063 418270 5918485 2805152 6818965 1187089 4870270 4679382 3479808 9446256 4944056 6031405 2207940 4551392 8301594 9248084 3757077 7712637 5905488 4732528 8049591 4146068 617...

output:

31691679
49610149
39698592
27104982
42762194
54263586
52106767
31098219
49835303
40964975
30498165
40840129
50650726
44626513
39364304
47427165
8773080
69280018
40685040
29904623
38111981
44634425
50650928
34061068
39080261
21996396
53436088
38568665
34549812
46783092
52770865
47130451
40925715
4506...

result:

ok 99923 tokens

Test #26:

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

input:

17
6000388 4755363 2377963 2570647 858781 2362043 3443959 1012280 3886000 9656226 2563408 5923857 4604642 9790064 1178856 7003156 9928718 61456 2989475 220614 8617668 5466305 4222553 3641410 5700677 8879768 1083737 4333108 8829320 1731196 9518689 7635039 7093689 2025001 2639527 264343 5417908 766199...

output:

32419448
46368266
39228500
35517993
29979924
42466467
45734675
35581530
55016831
33474051
23598916
41984059
41015754
29531648
31306385
45230977
31100061
37494330
21234036
30281892
39735358
24832443
50950010
32798147
25062122
24569646
49022530
40197447
44073650
47595360
44584027
41743514
50721845
394...

result:

ok 2032 tokens

Test #27:

score: 0
Accepted
time: 61ms
memory: 5112kb

input:

16
9748716 7424747 9481105 9092427 3526543 3345109 5879213 4229646 5696274 575792 1703743 340927 4022462 6259033 2650267 8991442 2191251 1000576 9210507 2350802 1029571 8421543 3516747 5511388 696117 9624487 7084171 4865826 7625091 4635434 7301617 797290 1633148 845106 8192660 4006157 1345571 893672...

output:

47224605
40760717
30507727
56064500
26341137
54344506
42495586
21563367
36489284
19825236
31305639
31391468
23158453
35572049
35385471
23688000
30961011
47360722
42749044
38462245
31500981
43784506
32075230
41474327
31708744
25918241
45611739
30518107
42769203
25108631
55114761
33527895
37189073
326...

result:

ok 30123 tokens

Test #28:

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

input:

15
2764182 8997334 6987875 3697473 1079316 8283611 59312 9757161 1827849 8340449 1081045 88604 5899644 6223689 3673010 911140 9687240 3059176 8945343 1095170 3579678 394886 9492485 7432678 9536513 4980192 4823712 5892920 1867208 4324007 2815556 7739155 4892703 7796351 4635573 1018436 7256966 8771201...

output:

26412302
20234829
46321817
40346898
44873042
42223636
21338595
31144152
42393439
17991413
34865730
18176455
35433720
35320365
19022954
27208609
25089763
18746142
21046874
30542121
27446079
35945361
35541688
24101349
33013462
24872161
31051129
33354603
35937602
36882949
36795315
51632441
26294868
496...

result:

ok 99933 tokens

Test #29:

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

input:

18
90017 595682 8551034 6649423 3187727 4010376 206301 2752873 3527744 7936947 3685961 4107390 9394003 7643246 3609048 2197413 1731712 3841400 6465915 9584228 6461327 3666754 4146548 5926586 7253087 8172533 283868 6657174 353632 5470313 7633950 9569757 934937 2694191 6055930 1354984 3572131 3521545 ...

output:

49217634
44287167
49014301
38397044
55215906
26615296
41988834
36164480
28495718
42129434
23102041
50631940
44249010
46171284
50001500
38592399
35096235
37014240
39676320
28499233
48985554
35266601
34342301
40475464
38879267
38698718
44915437
46777322
35593522
47294419
41781952
48858746
45236788
309...

result:

ok 2013 tokens

Test #30:

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

input:

18
4318316 974771 3932242 1400005 5732200 2684977 3899252 5054462 6985482 9481569 1307551 6696819 6133595 7438115 4769586 8306285 5913781 1260747 4047396 5284076 8741576 522915 6871039 8832161 702232 1708263 6840160 8221301 3320061 8697287 2226425 4364289 120737 8812776 5747856 4600212 9105670 87506...

output:

36374183
28786079
45147598
41896187
25735661
55576274
55347144
37954005
49549529
49256742
38935104
28295455
54312393
48616846
34181283
47750634
39075610
48405621
47673249
35815792
50904688
52345760
44125758
44339359
38560209
51049560
39332756
36830429
25766059
52925538
24634640
29353533
37321704
459...

result:

ok 29977 tokens

Test #31:

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

input:

18
3662119 5227195 281079 9067598 1838100 396546 9884069 5998344 7955220 4554105 7165220 5240713 6647241 3742077 3865907 7514202 2721963 7827038 8228003 814132 538375 6238690 5180249 8607109 5127676 2650944 8576463 7075314 8790781 4828838 6045970 9069135 1419218 249396 8290117 3827881 7922838 458739...

output:

53499415
51515988
48035127
54307544
40121721
47380122
46107114
39527778
39797491
46651606
55343999
36316537
37304527
47517717
38173544
50550078
34725323
54867157
52570627
29092595
57596868
49985887
36322594
53313586
61172594
49589321
42524882
26997011
29614934
61873321
39892824
42816320
55061087
447...

result:

ok 100146 tokens

Test #32:

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

input:

18
800638 9167387 8163530 6725413 2560797 7790484 462829 6302009 8365100 4149622 1909820 4904649 8176418 5818025 9745273 1456917 1241128 4002537 5187159 9848306 177054 1812805 9144831 2490828 9851798 6786849 7303310 9276318 4335959 9435316 5115669 5154811 4218971 3730187 236696 3981449 156625 593894...

output:

41293172
45065731
34935438
36541127
41793074
33557202
62877453
50732980
41224705
37621972
30846365
55489303
50019113
46927734
38097859
28663852
33661552
48907834
29653901
24854710
22980068
58763187
51885807
45921969
32679195
37952709
41795353
32583125
29815569
40878903
28915581
38491994
40095295
475...

result:

ok 2003 tokens

Test #33:

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

input:

18
445730 4462500 3827284 8925763 95919 8684029 2154340 2407049 2528793 8506544 3842173 2758923 7752605 8549745 7726197 4823210 5777864 3605223 5326899 559862 3636607 4990129 5167287 2382263 354554 5984606 9719058 1648231 7083204 1858163 7332201 2481078 6386621 8922346 1180022 5628421 2616600 896951...

output:

40400090
38476111
50319261
42618868
64541904
41226371
52321479
51215485
43497132
34293588
62533410
38007231
59480201
45868504
22130817
41600598
42748877
49830843
47169708
33427011
36396607
46996317
49561243
51280394
65026912
44163821
46265774
37086397
39462740
30367809
32731260
46514714
43333857
420...

result:

ok 29870 tokens

Test #34:

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

input:

18
1341947 5426084 3308832 8384334 8842667 6761874 1977243 8244543 99423 1684340 7520996 176084 2159984 1159546 7236014 6724395 2256009 1006538 932284 8042256 6367402 9015419 734442 6957191 7128358 7224347 9742629 5523014 6391461 2225194 712557 3605688 2543395 4476189 5246042 2806907 8536431 4732380...

output:

49423833
45702278
26345711
45838164
59046326
41218178
47515718
58641419
18568059
49977954
41756514
46194491
53086693
52521539
55086996
53938310
37487582
31444016
49332535
31780071
50875901
53820906
44711692
34711853
36028743
41985012
41491235
41310047
31711190
39307231
29595392
42443428
42686410
214...

result:

ok 99801 tokens

Test #35:

score: 0
Accepted
time: 84ms
memory: 11556kb

input:

18
6396973 4089313 1708082 8543616 4444333 9359039 2834375 8078060 8049284 965656 4783705 743747 3712385 502486 1963408 1252309 97480 4029012 2314922 4890154 1142736 4162404 900089 7534460 5157477 7503563 4026851 9892539 5850535 4280384 8932449 3124232 4733578 9291120 4134144 4014394 2958037 5408509...

output:

45027624
38789880
42025288
51504470
42399304
39130784
45880961
39070160
45321962
42078600
38245232
46044992
45977716
39562002
20701843
35001862
53844190
38311716
49507289
39553522
47244749
42622056
52674455
41524537
20700581
46567509
35783939
40666955
43237953
31687929
28726696
37171489
46349006
573...

result:

ok 2001 tokens

Test #36:

score: 0
Accepted
time: 101ms
memory: 11368kb

input:

18
8684871 2308243 8880168 6520644 8157768 5512834 7835674 5950540 1397018 3129367 2078973 2753574 3849513 4976415 7053799 9261915 7352918 2894333 4231458 7823429 9813110 2365606 464814 5377429 5444689 4556323 27710 5940301 8285860 7523219 5303223 953414 956576 9244710 4245044 8052396 1629160 462262...

output:

42012748
55327899
58174331
29664501
34289865
40445007
25158891
27976897
51102128
43660611
56960764
40245863
42241620
53320927
56437877
43170958
29998505
32678346
37323935
44428506
39075421
39853851
40024797
30556930
39038983
28198070
27040871
33875100
46423440
34974063
34247555
52198931
50109353
349...

result:

ok 30045 tokens

Test #37:

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

input:

18
7195596 1307076 9352771 5960126 60371 887481 7498256 2798341 7742750 6520501 9965412 7271665 3090687 9016074 4623226 7588175 1957179 3217054 5425343 8811581 5916169 3510378 9231703 4292400 9948055 960635 9389849 1981807 5495556 2228852 8840462 2351509 9918951 1378442 7720821 6824083 5710791 88896...

output:

43341803
43405330
40140347
45184616
32579013
52547383
62941140
37684278
50228753
35226718
41505629
40731572
37863826
41028845
19867014
54781337
40765937
38058137
62747408
40546736
12825771
40316745
38235281
48202032
29525838
43332254
19988154
52686247
42226903
39299795
47736547
54519481
31795212
431...

result:

ok 100058 tokens

Test #38:

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

input:

18
10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 ...

output:

120000000
120000000
140000000
110000000
110000000
110000000
100000000
130000000
130000000
140000000
100000000
120000000
130000000
100000000
110000000
120000000
140000000
120000000
110000000
110000000
100000000
110000000
130000000
130000000
90000000
150000000
130000000
110000000
110000000
120000000
1...

result:

ok 100164 tokens

Test #39:

score: 0
Accepted
time: 101ms
memory: 11584kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

10
12
11
6
10
10
12
9
14
11
10
10
11
12
15
9
12
11
12
10
11
12
14
12
12
16
10
12
12
11
13
14
10
12
13
11
9
11
12
13
10
11
12
11
12
11
15
8
9
14
10
11
12
13
11
11
9
13
13
12
13
10
11
11
14
13
11
13
8
14
13
9
11
13
12
11
12
14
11
11
12
10
9
10
13
13
11
10
12
9
9
11
10
10
11
13
11
10
11
13
12
13
13
13
...

result:

ok 100021 tokens

Test #40:

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

input:

18
3 24 35 25 49 36 12 87 67 20 33 31 58 58 91 74 50 47 98 75 92 96 3 39 92 53 86 44 97 40 21 75 92 26 70 7 97 55 93 79 58 97 80 31 62 61 57 84 19 46 60 39 8 64 9 87 87 94 94 28 36 56 96 28 13 78 10 21 36 19 9 57 8 79 98 97 72 10 9 91 59 27 100 100 58 77 83 87 29 49 82 36 18 38 42 22 92 7 8 93 74 13...

output:

419
305
322
418
597
326
614
258
303
431
392
246
451
563
389
500
423
442
346
469
483
49
470
446
497
407
427
329
395
330
539
461
362
253
443
292
332
384
424
518
394
320
392
292
411
368
233
379
408
691
332
377
397
371
463
407
346
444
419
540
464
485
511
396
242
385
538
472
323
440
479
421
430
398
413
3...

result:

ok 100258 tokens

Test #41:

score: 0
Accepted
time: 39ms
memory: 3884kb

input:

1
1132027 577680 9251648
199994
2 1 2
2 1 2
2 1 2
2 0 2
2 0 1
2 0 2
2 1 2
2 0 1
2 0 1
2 1 2
2 1 2
2 1 2
2 0 2
2 0 2
2 1 2
2 0 1
2 0 1
2 0 2
2 0 1
2 1 2
2 0 2
2 0 1
2 1 2
2 1 2
2 0 1
2 1 2
2 1 2
2 0 1
2 0 2
2 0 1
2 0 2
2 0 1
2 0 1
2 0 2
2 1 2
2 0 2
2 0 2
2 0 1
2 0 2
2 0 1
2 1 2
2 0 2
2 0 2
2 0 2
2 0 ...

output:

1709707
1709707
1709707
1132027
577680
1132027
1709707
577680
577680
1709707
1709707
1709707
1132027
1132027
1709707
577680
577680
1132027
577680
1709707
1132027
577680
1709707
1709707
577680
1709707
1709707
577680
1132027
577680
1132027
577680
577680
1132027
1709707
1132027
1132027
577680
1132027
5...

result:

ok 199994 tokens

Test #42:

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

input:

1
788287 7222737 8650543
199995
2 1 2
2 1 2
2 0 2
2 0 2
2 1 2
2 0 2
2 1 2
2 0 1
2 0 2
2 0 2
2 1 2
2 0 1
2 0 1
2 0 2
2 0 1
2 0 1
2 0 2
2 0 2
2 0 1
2 1 2
2 0 1
2 0 1
2 1 2
2 0 1
2 0 2
2 0 1
2 0 1
2 0 2
2 1 2
2 0 2
2 0 1
2 1 2
2 0 2
2 0 1
2 1 2
2 0 2
2 1 2
2 0 1
2 0 1
2 0 2
2 0 2
2 0 1
2 0 1
2 1 2
2 0 ...

output:

8011024
8011024
788287
788287
8011024
788287
8011024
7222737
788287
788287
8011024
7222737
7222737
788287
7222737
7222737
788287
788287
7222737
8011024
7222737
7222737
8011024
7222737
788287
7222737
7222737
788287
8011024
788287
7222737
8011024
788287
7222737
8011024
788287
8011024
7222737
7222737
7...

result:

ok 199995 tokens

Test #43:

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

input:

2
9707969 1475941 8847880 3452250 6960253 4584259 7593112
199970
2 2 3
2 1 4
2 1 3
2 0 2
2 2 3
2 0 4
2 1 2
2 2 3
2 2 4
2 2 3
2 3 4
2 0 1
2 0 3
2 0 3
2 0 1
2 0 2
2 0 3
2 0 2
2 1 4
2 1 2
2 0 2
2 0 1
2 0 3
2 1 4
2 0 1
2 0 2
2 1 2
2 1 2
2 0 1
2 1 4
2 0 4
2 3 4
2 1 3
2 1 4
2 1 4
2 1 2
2 3 4
2 0 4
2 1 2
2...

output:

4584259
13160219
9512450
1475941
4584259
9707969
4928191
4584259
8847880
4584259
7593112
3452250
6060200
6060200
3452250
1475941
6060200
1475941
13160219
4928191
1475941
3452250
6060200
13160219
3452250
1475941
4928191
4928191
3452250
13160219
9707969
7593112
9512450
13160219
13160219
4928191
759311...

result:

ok 199970 tokens

Test #44:

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

input:

2
8217602 8461107 4726964 5150572 6428975 1008988 3596862
199988
2 3 4
2 0 3
2 2 3
2 2 3
2 0 4
2 0 2
2 1 4
2 0 2
2 2 3
2 1 4
2 1 2
2 0 1
2 0 1
2 0 3
2 0 3
2 1 2
2 0 4
2 0 1
2 0 2
2 1 3
2 1 3
2 2 3
2 2 4
2 0 3
2 2 4
2 1 4
2 0 4
2 0 2
2 1 4
2 2 4
2 3 4
2 2 4
2 2 3
2 1 3
2 2 3
2 1 2
2 0 3
2 1 3
2 1 3
2...

output:

3596862
9470095
1008988
1008988
8217602
8461107
11034825
8461107
1008988
11034825
6428975
5150572
5150572
9470095
9470095
6428975
8217602
5150572
8461107
7437963
7437963
1008988
4605850
9470095
4605850
11034825
8217602
8461107
11034825
4605850
3596862
4605850
1008988
7437963
1008988
6428975
9470095
...

result:

ok 199988 tokens

Test #45:

score: 0
Accepted
time: 39ms
memory: 3936kb

input:

3
5019314 9557085 1777919 2497558 7895851 2246702 5893820 4553809 2333099 6653170 7070043 677727 7442246 685839 607353
199967
2 1 6
2 0 3
2 1 7
2 5 8
2 0 6
2 1 3
2 0 2
2 3 6
2 5 7
2 2 5
2 2 7
2 0 8
2 7 8
2 3 6
2 1 3
2 3 7
2 1 5
2 2 7
2 3 7
2 4 7
2 3 4
2 1 4
2 2 6
2 0 6
2 2 4
2 7 8
2 2 5
2 1 8
2 4 8
...

output:

10866315
9150728
10180476
2455646
6312506
8986269
2497558
9316745
3062999
8573578
8124225
5019314
607353
9316745
8986269
9455315
10906677
8124225
9455315
2385272
7070043
10228950
8810064
6312506
7895851
607353
8573578
9573123
1777919
2497558
2246702
6312506
5019314
5626667
6312506
8573578
6797233
10...

result:

ok 199967 tokens

Test #46:

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

input:

3
3044475 8853260 6371074 6613278 5662681 313300 5719251 8826685 7884926 2703541 4556695 5197302 2527296 6911221 429423
199971
2 6 7
2 3 4
2 1 8
2 0 4
2 1 4
2 4 8
2 4 6
2 1 2
2 3 5
2 4 5
2 1 7
2 0 2
2 0 8
2 2 6
2 3 7
2 4 8
2 3 4
2 0 5
2 3 6
2 2 6
2 7 8
2 4 8
2 1 2
2 2 3
2 4 7
2 4 6
2 5 8
2 0 7
2 6 8...

output:

6148674
4556695
11871160
8853260
13547607
6032551
313300
7884926
7397291
2840596
12300583
6613278
3044475
5975981
11018669
6032551
4556695
11291022
4869995
5975981
429423
6032551
7884926
2703541
6461974
313300
8246547
3473898
5719251
12300583
7884926
10087176
5662681
2840596
7397291
8675970
8853260
...

result:

ok 199971 tokens

Test #47:

score: 0
Accepted
time: 47ms
memory: 3828kb

input:

6
5327094 2000924 4787760 5146462 2915597 1977821 7037517 9320797 433958 2412219 5030230 9692957 3845243 9638378 5888546 1650428 7015453 7023764 5005976 9512206 211950 2949461 5883576 4001048 4762151 7423165 1925011 4777110 5033299 7530706 2693454 3681589 2369746 8269707 7652772 9677273 6382295 1806...

output:

15460986
12677315
5034380
15913407
10368547
162619
8169650
25245705
20962752
9906558
13669252
11272127
14984577
19156973
8493171
16634658
22565828
12783255
17446045
24009843
20098929
13607125
20830730
10284802
6153130
13367134
19713982
8472253
8788808
19486230
9469628
21412299
15258038
1977821
13526...

result:

ok 199962 tokens

Test #48:

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

input:

8
1318679 1303364 3296174 6791936 7274226 771345 59389 1630499 8911167 7088680 9546290 6969776 6302930 2776445 2976716 4207062 7827573 8836251 9080189 3072793 922852 356511 5300524 1403985 4665167 3929531 9336051 4360745 3443035 1443765 3609633 8361760 3008802 9766373 2072120 971403 399918 4849082 7...

output:

22895341
3251674
19973892
22334412
21616102
8740806
19518822
16353846
25851342
18172438
14248343
16990255
13353254
10137678
12196296
10936096
19618968
14359576
12823513
15600584
18082279
15349101
22877975
12297771
6459984
21964484
13899433
13400320
20643887
10663018
19723640
16249346
10344607
149331...

result:

ok 199958 tokens

Test #49:

score: 0
Accepted
time: 49ms
memory: 3940kb

input:

7
3444246 2333704 6952623 3214281 3756334 7393392 4570432 7814871 5787880 7176048 9991384 3407553 2160002 5587855 5476333 1049817 8934860 7424264 5191755 3047395 3323308 4781000 3260178 4361752 1745309 3815027 5591606 2777381 6704299 8696415 9704061 7900969 2256504 6552983 8192260 3606842 508347 190...

output:

20438054
8050209
12208422
21748258
13370733
16879016
18715348
26373554
9138005
18766541
21855863
15609159
22305770
15950044
22186930
16829409
17723149
25863247
16481920
15274361
18253991
20786928
9981082
20266665
27379177
19487072
19746268
17536981
26770204
16749341
24140551
15763828
13759171
124306...

result:

ok 199971 tokens

Test #50:

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

input:

4
3591436 7798374 4118924 9588523 4509975 1602645 8893527 4662437 5988493 7330832 5877281 6057207 9071482 1499290 851343 6527822 5867838 6076014 9004636 1685391 9429132 4071286 3502036 297678 6420589 4469013 7378137 7074519 2707259 7667359 1778914
199986
2 2 5
2 1 16
2 13 15
2 2 8
2 2 8
2 1 3
2 9 16...

output:

7673884
10119258
5337516
10498468
10498468
11943852
4250956
7150038
4442779
12482818
14370214
16555675
11927558
7378137
10498468
13320206
8877427
297678
7455314
7479926
5942069
11812475
13319325
9159142
9159142
11943852
14000504
13319325
851343
7479926
5337516
3101935
3502036
15117256
10796146
16108...

result:

ok 199986 tokens

Test #51:

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

input:

12
1724131 7030240 6146255 5918106 3319723 7022230 6154393 5014958 1127736 4009882 86327 3478310 4406314 487717 5883168 2300709 8045300 9330531 7945443 6306561 4602591 1455478 210978 8953669 5079301 5970929 6898193 6677039 5779158 5795293 2429563 7383858 3879830 2418615 3941565 5230710 5501917 53556...

output:

13162320
31207126
17972805
12244877
32741147
20907151
16543041
22226259
31282753
24986420
22743682
12765003
15858227
21239663
27683834
37409553
25482463
31262165
26293927
10241829
36113351
25687009
39646363
22043137
42545165
23547057
26490279
38244687
26510127
36942039
34381024
26560959
28532935
303...

result:

ok 199988 tokens

Test #52:

score: 0
Accepted
time: 59ms
memory: 3880kb

input:

13
4113659 7535 5984781 2198992 3994180 7775985 3461005 2269941 3175362 9307640 1098011 9538604 7102436 6154020 7517040 2871535 5945293 5310825 609336 5726669 6730195 4708877 9281300 2549605 5751809 7789101 5767449 7544942 3799573 3628216 468688 1629746 5540610 9804402 6246836 2243855 7419887 354430...

output:

38511817
29971954
28462618
34387921
27207246
31241472
36069370
29941985
28121290
34738793
24114164
19630112
26763475
45311768
28593243
22984348
22677338
31164571
34402291
19291749
14491745
36228820
18852756
27848814
21217669
32670794
27168233
20673491
34654295
46427680
12612473
25065135
39819995
263...

result:

ok 199951 tokens

Test #53:

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

input:

12
4399825 6666859 3360517 3314028 5483516 4553439 6212223 9682458 2122967 8221513 1997255 2886274 5378876 6556566 7852610 3142441 1205562 9469572 342217 1102377 2850835 704807 9538217 6326704 28479 2548712 8012962 1845631 9500776 8289537 211176 1941612 7308524 3682690 6394917 9638752 9876959 887406...

output:

27826826
32284619
15343038
36476829
31445895
28094522
20765664
34011722
39701918
22838584
40767475
41627807
34016847
41483168
32795093
10405841
24693128
41010357
26424729
33377158
24284007
34840041
36864227
17246098
40160784
11489037
24160298
28089317
24562960
21495132
22059481
30015910
25936386
362...

result:

ok 199990 tokens

Test #54:

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

input:

12
2450283 9471313 1665888 7622158 8215085 4697120 9549606 1202963 198382 3538120 7978446 7906532 66632 6664843 4708331 991310 5497193 150753 6139110 9944081 1521426 7996020 3023737 3469921 5717785 138658 7317173 4442088 6401256 7368574 8893820 6662337 3798652 2264272 4004487 8340351 1009254 8104976...

output:

32923924
32946987
26539794
18840445
8797631
24832849
15984150
12714477
36878175
34169819
22836265
20522028
17769623
28248762
32557841
22263761
22990917
31621137
28215553
24405171
30771919
28592509
26255880
21372331
23936841
32209046
32671724
31875551
19222353
32336794
26776807
40315209
23656533
1994...

result:

ok 199975 tokens

Test #55:

score: 0
Accepted
time: 87ms
memory: 7372kb

input:

17
2475697 9671796 54068 8937594 7263748 3794035 5018213 6045972 6640308 7475614 9739159 40620 7990645 2461131 4343080 3563215 7045489 8890724 4228524 645219 9957060 5797478 3783272 4469918 1879934 8083043 8686552 9044748 4166181 6660096 6697769 8661005 3348400 5349111 7449407 2035156 6483469 450229...

output:

47056239
39129362
45127108
36152614
45414128
53515947
23342962
41940829
45796309
29212884
27176130
27154139
45981103
30293834
42093570
33294440
32070184
47900683
32003637
33581414
31163860
52637094
36070633
36836318
37328371
39392524
41447748
43712240
34822390
41323587
19858942
46139700
37180304
436...

result:

ok 199996 tokens

Test #56:

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

input:

17
3878805 3733448 9182824 5240096 8945630 1113007 3172384 5046398 6199782 7278088 7484553 4871784 9928918 6732628 1841956 6298825 8151976 402695 9519111 3045184 6284844 4067852 6575067 7344927 9258886 3194812 2829791 7143276 3753518 4768107 7143267 5785699 1361263 5968476 9020878 7283185 7681768 22...

output:

33516868
43071222
41447049
43170851
24632088
50725207
52714209
36523517
53393302
44081588
39026835
35333131
36578115
31718554
33959310
20022113
41834617
37270871
44562291
44319564
37765854
32699734
48371953
44055427
35114040
35402043
60092866
33463968
48528953
27568776
43558883
39397313
25870556
420...

result:

ok 199994 tokens

Test #57:

score: 0
Accepted
time: 68ms
memory: 4292kb

input:

15
759494 9209767 9485962 8143397 3300918 4282087 8007160 8796165 226142 3420372 2128100 5271456 2797134 6156824 6051128 1326601 9281515 2883407 5871857 3317255 8724203 1189385 418721 723605 6859610 4540747 8317165 8789344 1423895 7339790 1106447 2163532 1465687 3950399 8250837 2600431 1232546 52195...

output:

29242081
29753519
22451332
38277892
20487356
35941301
37120850
24093845
25588617
36858550
27710675
39969066
31670248
33949593
26469716
27343666
39997282
54468999
16076256
27649982
35761790
38889398
28692732
36655816
33257661
38798243
22485883
28951267
35532047
22870554
35855143
27902304
27745601
326...

result:

ok 199967 tokens

Test #58:

score: 0
Accepted
time: 77ms
memory: 5264kb

input:

16
8157719 6780830 6023322 4429010 4126659 6323266 2233997 7076115 6242550 3552915 4104983 9190505 9844468 2674574 2845333 6213243 9767893 4032804 2246905 8425636 6768643 4488761 3438920 7615473 2412992 4438565 6288285 1409574 5213214 2124726 3890852 3531834 8344197 1655980 9898015 4093014 343600 91...

output:

33012897
47375966
22596072
42465393
52578201
40187576
41640753
45746925
35399332
40447740
45390184
32284480
47607235
46147695
31649180
52588385
36892317
45761053
34758260
55285069
43905485
32941664
44501945
52706182
41941013
43685780
44000897
39288058
33945590
18469730
21721506
36122720
52741964
367...

result:

ok 199971 tokens

Test #59:

score: 0
Accepted
time: 118ms
memory: 11460kb

input:

18
7669373 4479744 1715322 4087814 9142508 5170030 813357 5143079 8115609 2694099 1028541 5839769 6862029 8586297 7276763 2060000 192326 3390396 4861424 3059795 7173427 5524496 9613716 5954718 1027769 5464825 4482072 4118594 4350961 4747730 3065725 1711248 4753127 9741191 3640443 9121202 7312029 775...

output:

36407688
39893422
55737091
42197891
38679449
42331513
32515455
32442203
42991334
32598920
44753633
46178703
31576096
32643706
27413645
60717060
45527645
49119781
41187207
46985411
50612505
22016391
29216346
39327971
48172325
31250369
48464124
42318112
35546047
41145715
31690329
35801778
42660587
490...

result:

ok 199971 tokens

Test #60:

score: 0
Accepted
time: 115ms
memory: 11432kb

input:

18
7165259 7474488 3366186 4981718 236704 4811225 6951659 2158850 6237312 8058297 4863810 304997 4895985 8770813 3776736 8161119 4422634 2862176 8517670 116771 889945 230190 5691436 8986682 5525150 9046602 7996987 7706238 3142286 9198888 8118483 5200543 3208816 2204755 5070630 2445985 74627 5496552 ...

output:

46039532
57915852
47521056
42375025
51492042
39385876
35328571
38584313
44217086
39961526
30741882
39281477
47363371
30900540
25754567
39818232
36969677
38788695
49275556
36395503
59751624
27993098
40774056
43413741
19738033
42150904
43967776
47806998
45051149
26343075
26100144
43853792
45030340
335...

result:

ok 199971 tokens

Test #61:

score: 0
Accepted
time: 123ms
memory: 11560kb

input:

18
6753204 5023445 4147260 9903769 5789658 5335740 7658935 7459268 2906442 658743 7463950 1602417 4256245 9289784 2330523 9287693 2362558 2949572 9584366 3995223 9986816 2008054 2850120 9453537 1645318 8110714 24736 7138453 7254673 9984402 6801441 3737774 3936982 2370581 4367018 7626683 3558397 1752...

output:

50751460
52630177
19356432
27917934
40050541
35858288
40095147
30624660
32999992
56514128
47994138
32070696
21118953
45165782
39503675
38764785
33292415
26220111
33962491
59633270
39787415
34813350
34028966
43370797
31010403
49207180
39349643
31016652
40469143
48619652
40662888
34824123
37855100
377...

result:

ok 199987 tokens

Test #62:

score: 0
Accepted
time: 121ms
memory: 11464kb

input:

18
374001 6404323 5309740 769738 6218264 9417215 129373 4663846 8407437 2388539 7232852 240614 5450862 7734675 8483800 5826114 4309322 9064603 775779 7886276 4128550 3979127 1404580 1670094 1827067 4323809 9532798 3347858 989877 2521766 6393479 5665688 6323765 2313257 8022922 1959227 8718544 3350111...

output:

48547749
29974256
42755241
29836886
36787212
54035082
61045236
42267933
46795211
53078183
53419538
45270241
58386935
43837140
47719930
35805750
20728003
55893841
31371842
23340514
48638235
35636787
37209964
33750029
36557474
45220462
29864541
42805755
40735192
46299662
36209695
48898528
36817106
456...

result:

ok 199998 tokens

Test #63:

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

input:

18
1332316 3121181 4436067 6041511 1048493 5178654 1390274 9631210 393678 6482281 4362007 9146243 5169322 8114555 1177176 182152 6054112 6408612 8215277 2269090 9793986 1186694 632243 7480976 1376854 1876890 3521018 8165283 6498136 4873642 2603528 4499264 9679670 5232984 3197077 2660449 9430035 8439...

output:

34856957
49727694
43991818
46209448
34562995
26143927
36018751
38637146
44551045
53925673
45554402
28021523
48241146
30776037
37865035
56156200
51961126
39498976
46568531
44753881
51453045
29005925
27789138
27612018
38900020
56410469
45653932
40990603
54296303
42093520
34767391
39633266
31770704
440...

result:

ok 199976 tokens

Test #64:

score: 0
Accepted
time: 121ms
memory: 11428kb

input:

18
3560452 2316746 8875011 8215012 978789 9680826 7319476 3817940 4362017 8243712 7261847 4016009 3840653 748969 247963 2003771 2054608 4343476 5856834 9626707 3381605 9116951 9382304 7074801 658333 7347515 909152 1416040 3507739 496635 1643071 1697725 9713238 3702057 3168015 44587 2775578 6627465 6...

output:

31672923
55166231
35695230
44243937
49591108
43350643
31160933
34663734
35378064
44285093
37864595
46082935
35844806
39786487
41113987
31245240
38244184
36296386
35453596
42654613
41530630
50461018
37858189
43008188
44086255
28487768
28780139
39954271
42355874
32665495
24081746
65569419
40860145
343...

result:

ok 199972 tokens

Test #65:

score: 0
Accepted
time: 122ms
memory: 11352kb

input:

18
10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 10000000 ...

output:

130000000
120000000
100000000
90000000
130000000
130000000
100000000
60000000
120000000
80000000
90000000
100000000
130000000
80000000
100000000
50000000
110000000
120000000
80000000
100000000
170000000
110000000
120000000
110000000
130000000
130000000
100000000
130000000
80000000
120000000
13000000...

result:

ok 200000 tokens

Test #66:

score: 0
Accepted
time: 105ms
memory: 11432kb

input:

18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

9
14
10
10
12
12
13
11
12
13
12
11
16
11
9
13
11
9
10
11
12
11
11
13
12
11
11
13
13
11
11
12
12
9
11
12
14
11
8
13
10
11
10
13
12
12
12
13
14
10
10
11
15
10
11
12
11
8
12
15
6
11
13
13
11
9
14
13
10
12
10
9
11
8
7
15
13
12
9
13
10
13
11
12
8
9
11
11
15
11
9
11
10
10
11
13
11
11
13
13
14
13
11
7
8
13...

result:

ok 200000 tokens

Test #67:

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

input:

18
27 53 94 24 96 84 95 27 3 47 38 84 17 56 84 15 4 86 95 88 89 72 1 68 6 50 39 97 29 19 60 30 35 6 75 80 50 16 64 47 72 93 84 10 53 78 32 66 25 45 43 16 71 4 17 64 15 78 40 30 33 27 15 9 8 86 18 51 36 34 39 26 25 78 44 38 94 72 78 85 22 27 32 34 66 72 50 59 77 1 51 78 31 85 15 48 26 54 65 81 28 32 ...

output:

290
422
544
543
646
420
320
479
245
432
573
290
463
291
474
281
413
308
402
353
328
349
464
505
605
423
332
557
521
345
416
433
453
424
319
389
504
484
638
324
206
365
577
380
418
525
514
643
430
467
495
610
411
600
278
344
289
513
574
500
407
518
440
327
411
456
469
524
381
487
525
273
538
444
464
...

result:

ok 200000 tokens

Extra Test:

score: 0
Extra Test Passed