QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340058#7440. rsxchos_lyricTL 1936ms392316kbC++145.0kb2024-02-28 14:01:022024-02-28 14:01:02

Judging History

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

  • [2024-02-28 14:01:02]
  • 评测
  • 测评结果:TL
  • 用时:1936ms
  • 内存:392316kb
  • [2024-02-28 14:01:02]
  • 提交

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")


// Manages linearly independent set in \F_2^n of max weight.
//   S  should be an integral type and support taking a bit and addition (^).
//   T  should support addition and comparison.
//   invariant:  ss[i] = 0  ||  2^i <= ss[i] < 2^(i+1)
template <class S, class T> struct Basis {
  int n;
  vector<S> ss;
  vector<T> ts;
  T total;
  Basis(int n_) : n(n_), ss(n, 0), ts(n, 0), total(0) {}
  void add(S s, T t) {
    total += t;
    for (int i = n; --i >= 0; ) if (s >> i & 1) {
      if (ss[i]) {
        if (ts[i] < t) {
          swap(ss[i], s);
          swap(ts[i], t);
        }
        s ^= ss[i];
      } else {
        ss[i] = s;
        ts[i] = t;
        return;
      }
    }
    total -= t;
  }
};

////////////////////////////////////////////////////////////////////////////////


constexpr int E = 30;
constexpr int D = 20;

// [l, r) is good and dim = d <=> R[d][0][l] <= r < R[d][1][l]
vector<int> R[D][2];
vector<Int> S[D][2];
vector<int> invR[D][2];

void init(int N, int Q, vector<int> A) {
#ifdef LOCAL
cerr<<"[init] "<<N<<" "<<Q<<" "<<A<<endl;
#endif
  for (int d = 0; d < D; ++d) for (int t = 0; t < 2; ++t) {
    R[d][t].assign(N, N + 1);
  }
  
  auto as = A;
  sort(as.begin(), as.end());
  as.erase(unique(as.begin(), as.end()), as.end());
  vector<int> ids(N);
  for (int i = 0; i < N; ++i) ids[i] = lower_bound(as.begin(), as.end(), A[i]) - as.begin();
  
  for (int d = 0; d < D; ++d) {
    // l -> min r s.t. [l, r) contains >= 2^d kinds
    vector<int> freq((int)as.size(), 0);
    int now = 0;
    for (int l = 0, r = 0; l < N; ++l) {
      for (; r < N && now < 1 << d; ++r) if (!freq[ids[r]]++) ++now;
      if (now < 1 << d) break;
      R[d][0][l] = r;
      if (!--freq[ids[l]]) --now;
    }
  }
  
  pair<int, int> basis[E];
  fill(basis, basis + E, make_pair(0, -1));
  int jsLen = 0;
  int js[E];
  fill(js, js + E, N);
  for (int i = N; --i >= 0; ) {
    if (A[i]) {
      pair<int, int> ai(A[i], i);
      for (int e = E; --e >= 0; ) if (ai.first >> e & 1) {
        if (basis[e].first) {
          if (basis[e].second > ai.second) {
            swap(basis[e], ai);
          }
          ai.first ^= basis[e].first;
        } else {
          basis[e] = ai;
          ai = make_pair(0, -1);
          break;
        }
      }
      // insert i
      for (int d = jsLen; --d >= 0; ) js[d + 1] = js[d];
      js[0] = i;
      ++jsLen;
      // erase ai.second
      if (~ai.second) {
        for (int d = 0; d < jsLen; ++d) if (js[d] == ai.second) {
          for (int dd = d + 1; dd < jsLen; ++dd) js[dd - 1] = js[dd];
          js[--jsLen] = N;
          break;
        }
      }
    }
// cerr<<i<<": js = ";pv(js,js+jsLen);
    // js[d - 1] < r <= js[d] ==> dim = d
    for (int d = 0; d < D; ++d) {
      R[d][1][i] = max(R[d][0][i], js[d] + 1);
    }
  }
// for(int d=0;d<5;++d)for(int t=0;t<2;++t)cerr<<"R["<<d<<"]["<<t<<"] = "<<R[d][t]<<endl;
  for (int d = 0; d < D; ++d) for (int t = 0; t < 2; ++t) {
    S[d][t].assign(N + 1, 0);
    for (int i = 0; i < N; ++i) {
      S[d][t][i + 1] = S[d][t][i] + R[d][t][i];
    }
  }
  // lower_bound
  for (int d = 0; d < D; ++d) for (int t = 0; t < 2; ++t) {
    invR[d][t].assign(N + 2, N);
    for (int r = 0, i = 0; i < N; ++i) {
      for (; r <= R[d][t][i]; ++r) invR[d][t][r] = i;
    }
  }
}

Int solve(int l, int r) {
  ++r;
  Int ans = 0;
  for (int d = 0; d < D; ++d) for (int t = 0; t < 2; ++t) {
    int pos = invR[d][t][r + 1];
    chmax(pos, l);
    chmin(pos, r);
    Int sum = 0;
    sum += (S[d][t][pos] - S[d][t][l]);
    sum += (Int)(r - pos) * (r + 1);
    sum -= (Int)(r - l) * l;
    ans += (t ? sum : -sum);
  }
// cerr<<"[solve] "<<l<<" "<<r<<" = "<<ans<<endl;
  return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1000 1000 12505600257298820166
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

2929934498377677671

result:

ok single line: '2929934498377677671'

Test #2:

score: 0
Accepted
time: 1718ms
memory: 392156kb

input:

600000 1000000 16250158766933054497
_VnMPQSoMkB2A`F6PR6Qe1<[<_U5[?L4[6R8VH`Ek7fMhm^:`C>?TMnJ]G[9Y<i6TcX`6W09N[:D[]MmW:3`@IhD6[ZIj[6nk9Ma=JW`LGn^`OTO0Mb`mc[53LM6X5eQ[3fD?6^Rfl`IAGBMd;cKMghBe`J\`66]OAX[0`j46K3KZ[fGiIM1THg`\nln`_=M@M2IoS[eZN=6H\ga[cOFO6N;d\`YhE2M4Ra;M7A@U`Z5bF6MfCh[`8Q_M;k01`V_Rb6AL3L[...

output:

10373212083833320350
8110969912885806797
1652287562556615452
7687084350761918228
15864205433837008504
11186966123302013273
6384724203398133399
88123121403580311
14593940278834881128
7750299022726819994
3665121167352871721
1584148493794015100
15979017321484609772
16972202416792440949
1160892536384682...

result:

ok 31 lines

Test #3:

score: 0
Accepted
time: 1450ms
memory: 390852kb

input:

600000 1000000 6574530603786764569
TM[JjTM[JjTM[JjTM[JjTM[Jj2390c2390c2390c2390c2390cOfXfdOfXfdOfXfdOfXfdOfXfd>n=dQ>n=dQ>n=dQ>n=dQ>n=dQC;\2VC;\2VC;\2VC;\2VC;\2VeE>H_eE>H_eE>H_eE>H_eE>H_XP_^XXP_^XXP_^XXP_^XXP_^XG44L5G44L5G44L5G44L5G44L5:aUZ2:aUZ2:aUZ2:aUZ2:aUZ2\_7`;\_7`;\_7`;\_7`;\_7`;aJV6<aJV6<aJV6<...

output:

4338573428526078476
10769352787453857139
15818674559617068677
17586345035624554490
13289697471106512844
18259160463921076240
8542047034291990047
7100488941136106084
5579512732443498040
6601016878751307742
16761282223118614617
7663574692222567505
10199185588650950166
17200790626052325761
935139697027...

result:

ok 31 lines

Test #4:

score: 0
Accepted
time: 1447ms
memory: 392316kb

input:

600000 1000000 2415380648427590544
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

6897056197250695824
14692924147293972441
12949792086412223616
9492853986098402162
4172805150210680355
8677584673383074478
13451311464436493606
13736843021967663354
4530382198493904527
12584309340453246063
1652430968007551853
2564389287723419164
1389726149071078209
13205536282870927323
18364921422078...

result:

ok 31 lines

Test #5:

score: 0
Accepted
time: 1371ms
memory: 391364kb

input:

600000 1000000 14785464139231087461
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

5996589804910778040
2562846947976193463
1276832494457901230
574708629221350714
10364758525613242580
11234609408393272771
10478820696273844815
14026187337670615925
12035734295758071323
15481830467446347172
1174247684124394413
13876274989663282050
6057369191188586291
4503508179121241123
21659237901579...

result:

ok 31 lines

Test #6:

score: 0
Accepted
time: 1349ms
memory: 391164kb

input:

600000 1000000 6868904542371283889
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

15155315411136029914
17916339903323427848
12009487164926308648
3994214040535032870
297690579017041973
18351513424891892986
17911416916439367278
6421144070150456531
697441115586322016
18248366745432973768
8470993188683888316
16779777716678970179
17119733537404467029
7260152052621238790
16835477355201...

result:

ok 31 lines

Test #7:

score: 0
Accepted
time: 1393ms
memory: 390704kb

input:

600000 1000000 10961997172074205536
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

17768129675879916280
2887218763875596345
10839113403430096209
16260870619021621749
2630126142516259171
4345322619616935804
11170974872631604608
12307465566816210483
9089458525086797672
8853863805473067037
14135076737013388405
3938862428024420559
144134187836477352
217337542067743546
8986134527788524...

result:

ok 31 lines

Test #8:

score: 0
Accepted
time: 1343ms
memory: 390652kb

input:

600000 1000000 1895815235912284800
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

12865279243812482171
18089381409241822914
5639953516682236045
15325589829476639634
4845545899430800571
18382562097839589732
1598781096261579563
8764066419403613597
14856468825138709626
16610565428395941968
5874023039589007616
17054056890284938785
1790911075120250092
1247466569544875583
1179356537616...

result:

ok 31 lines

Test #9:

score: 0
Accepted
time: 1367ms
memory: 390700kb

input:

600000 1000000 15794573950658326165
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

15332184560759357284
1603674462272885262
1839872689293034418
2877206508169494895
17209312731152294566
14232536484270773889
14588494708099950101
8154351896697802012
16184135997098779948
9620718634021417428
13592023230539343235
15642205544528192495
771105586061224370
16256751489028694405
1134121188202...

result:

ok 31 lines

Test #10:

score: 0
Accepted
time: 1409ms
memory: 390596kb

input:

600000 1000000 11248410774931265534
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

3170144849494372178
5634100736804722888
4047527708603102882
15215050833446096443
14039122905715095693
4837670379180019955
12183497556901354893
4869078625420004829
10900737403899586003
9120467908163014880
4037949037225548592
3022675105972271117
10118721872857838557
3211835158435558793
851253201964060...

result:

ok 31 lines

Test #11:

score: 0
Accepted
time: 1355ms
memory: 392048kb

input:

600000 1000000 4606587289246470198
?B0jGnZYJN\SCj5MKjJ<8`Vjci8?Jj[1ejQJiLJX0G<kOa_UKFSVOk=BNfK47eZkkf=3KbT4ikYEl@KP]<XlWLd1L^>mkleo5BLlZ^>l3KFWL:9OMlAhWdLHR9Tm_Ca=MV1hgmm`0NMdU[2m;DC[M26JAmIgRhM@c6`ng2nINn@gSnUQ?:N\dTFnC5LoNJGE5n1V]\N8l3loo=kEOfOb_o]^:6OTkQJoK:IcOBH@9o9YXPO0Yaha7H9AA>:0[aEkh2AL^CNaS...

output:

5000934058853397699
9501816210651496676
5051466839494996492
6634497203048773233
6495427244617839600
13001235914612999118
12991284084259693123
2701817058101174535
15696302998261643259
8246529966167040078
9742231388134571623
13247395636436232762
2765580520245469878
10927999899841768499
104245051569793...

result:

ok 31 lines

Test #12:

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

input:

1000 1000 2510035870211640140
AG<`<ba8:9TVT2nNN@KW89lC@lYKRMZngZZ@63cc6A_k4Ug[11cP79f9Hc@_O?OHH>DjTUH3F\BRkRe;d\>mlG::7i1MV?>kUBFG]bnNPBTMd=4caljn;5USXLY]D;j]GAM]1OVWEe6oa2I>8PIlbef>@j2<fTSKJQ8[\i7<AY_@PINEXD073oh8`gOOimQ8ca:K`7XC=W[PT^1_JQhF3BF2^g;?DiK3h5Rno5CeBgbY=V^[oJ:VLLl>LI:[RD^`CF=gV4j50>nAH]...

output:

3840104245674935347

result:

ok single line: '3840104245674935347'

Test #13:

score: 0
Accepted
time: 1353ms
memory: 391156kb

input:

600000 1000000 5343610385765097552
5gYcM=6BhZDDOTcLUT_4V`5L1^1nGfgCc;_oR80H3h`]U;9;VBBK6j;JZmalPoL2iX>W9>aLZEGi]ANPADne=IU5nj0g8RS86cYDbCBJAjRYAVS`T=o[1O68GKW[eOZLP26hAlK>9Zg\dL;4YflK\FUomC7]>6H`M:<8mEkg3:<YjOC4H1DTn=PWQ48XD@_^F`?WO]khK5EF5Cd^Mb:VS1[2GH:Lh2iiI`c2b^YQ?^gQ@dU0hB@i]`S[bJYaV^3Q0MUdKElFa...

output:

16302890456919292961
11760423172191114416
9731701341884023710
75140575552507435
15975896762888868390
9364044849338436448
5700798144964144590
16170468945548332527
16056433000868508944
1216191282027094765
10641288391047410785
3442770789120479935
2731819996726008498
1665568677881837968
1087138042249134...

result:

ok 31 lines

Test #14:

score: 0
Accepted
time: 1369ms
memory: 390772kb

input:

600000 1000000 16421817216784533572
0000000000000000000000000000000000000000000000000000000gZUnd=m@U_XQgPZ74N_URHiZP:aWZS_]0_V08YPYUD>U\O3kngjOLkbEjedm`VBahQEO2;49h7>[\A81>`f=4dW3FOAkTCJnN=LEK2ZI@MhFkchTanfG1HaibModl8::_W]F]ZR2c4U]W_SPXfL^CKC09FNlUPIAIi7LDS^b7?6bE2:YGl=5<;K80G_fk3bcAn6MFha9h:Od<2MZ_...

output:

1592880891710527498
14220311815507656792
7139617766298836449
4147217983705435210
7134437392184532309
4807296046196724178
5180583042702362571
12072310775154108820
5149592000996595665
6827039787545255367
13091525416476479489
14177898036661640734
11040324679915590483
11108828255973241596
10798603666888...

result:

ok 31 lines

Test #15:

score: 0
Accepted
time: 1471ms
memory: 390744kb

input:

600000 1000000 553554034658830793
JXh_TDTPBiP@UfVm<[J79h^nHQDJPmEPO4R8lAX3l8D<Lb4<a16`9ENK\7io_H2MP@gM;ET3H_:iOF3[=[CWd3W;JYgC>nfZ?0BGNk5f8fGaX]2Sd<bOojPC[;o4<U7WiAAcRM><_\a_hKYE`Mf4<UY21XjdN?4K0Z:P4>VBMIjBGi6W>IEWCjLahkFX_M?R];2BnSWSbS`ATX6nnQLbkJn1^efOeJ`B0Fk3UeR?61ZoC8];;W=9D5[Ed90lGkn\3NlgHgKHX`...

output:

8866123778685601283
4251132603918186048
5365600444540464835
17379313922248064557
2677448660452254488
18160882517595286259
421130529953262579
14443809225724546123
14280813627924726247
3946213248866807241
3974307819936581607
15678317649192430920
7737704872206142293
10965549687639981842
194044027640292...

result:

ok 31 lines

Test #16:

score: 0
Accepted
time: 1871ms
memory: 390720kb

input:

600000 1000000 16358584588838449835
0000000000000000000000000j^jJH4ib1Y<@cU:E[a8_M2`\<VMdCU^deg6g?gJSoVfn0T3hIQ\Zim2eAk@Wmhjd46Wn;]>>o_>Gem2[OLlV8Q;dmiYReIJ`Igdoh`f@L3_b_e;6c;FBmaVcJD`2@^CQAAVjPebo1RHGgXSld<gW3M4NVWnMUT:KE<U^h[K]e9Sb\AZj9^l?bP_H\9o[W51FZ3VH]X^3@4Y:P`S:81h:;\RQa917YH8UTB7<J=J^=n^3E?C...

output:

7983744011806954765
16506815892568071852
2454869483495589447
5912931499117731536
14358594759885833273
8771208514619467988
5040087450349696507
15698269990804178205
9981887454195833856
1736709404345116631
12467598329880892352
14162180600273421528
15390815788348171388
930881509617339660
208130190538407...

result:

ok 31 lines

Test #17:

score: 0
Accepted
time: 1936ms
memory: 391176kb

input:

600000 1000000 11004658139083566845
V3oJ;:_KaVoJf=ACfBVlDa]dohM9OB=XTSUQ40883WJ7S_;n\>JnC@ifBgkDaE8YGMi\2jX<1n=4PUEPkHPGkGd4lFR1Y0Q>]=[<9Zbi?U6FBR@ck^ElOO5hNl5:Cb@QQn7U<M9[9XfT\>GTW0Rc?:eGNcmIkjH@`AZ\[Lm>76Y8Ska5T7@L2Sh2O^?LYbKjaE5gFEnXEe?a3iI[J^<\6VIP0R=dW7MOg;[idJnND8]Bb`S01^N<K]2jWfHgGK1dKc`\cL<R...

output:

5035071137204821776
11542856267415498776
5800826951830613534
6172429060958622780
6345441007744596508
6228925545660909764
4114637096862792076
3600201314126766892
7930134936025188122
13198311211195407199
9726051595473886055
4488240663865210686
16536388478706697115
8011401685322767844
66486670763397153...

result:

ok 31 lines

Test #18:

score: 0
Accepted
time: 1920ms
memory: 392104kb

input:

600000 1000000 11741681231307226903
JPT?kc5OQ69[CB1P>Xlllg:d?EBaJb_lmYe6I678F?ihCoZ2F^54>UY\Qe;D`HG3WIm\]JSCPNM:fK`Pa3Xn;HVC@fR8OSa;]T=<GD65onam[24OaH5]j:fhm\e9SD9>WN^W2DI72ijTKkKbGbNPLZ8`\_]QEG1@XMCAK1hXoVkFT<QBcORL>:mZ_W_64BM1:gEdTaIXTb>Vc=Ge8>giik9NL2Ed2UPM7[0KcjA^G0mh;\^0]b\W[4GG9FniKjAGLPD\;U2L...

output:

4431409240393516973
1108953620373739502
3616952093436923820
5722089361980854166
11259738864117883157
1881640294852478453
12019966865997731847
12456022037940666923
8540264609327649321
10450186573902211495
12156287410478034759
607966434711670945
5494170141914329020
10003159799507977928
672356002721680...

result:

ok 31 lines

Test #19:

score: 0
Accepted
time: 1867ms
memory: 390680kb

input:

600000 1000000 4373143992912078603
W:LSO6R`Y<RidNe3AHDVQX\:C0000000000000000000000000000000000000000000000000000000000000000000000YNUUQ000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000P9n[^0000000000000000000000000000000000000000000000000000000000000000000000...

output:

12991275879505761006
2676504494593033188
9784364684389341947
12267453362117107841
18100103669282755521
7076262810333135225
16596984741871047527
1554137327405773064
18344182656572044822
17554486305082216279
9240664804950480319
1278874818938612905
11866804579676989806
13645083253408102920
987274900671...

result:

ok 31 lines

Test #20:

score: 0
Accepted
time: 1605ms
memory: 391480kb

input:

600000 1000000 6951624880200960143
0000000000000000000000000000000000000000000000000000000kGaGR00000000000000000000AKKV:U`Sjb000000000000000fUO3W00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

5777388014060387711
17234983738160432091
3516940761398150156
942301651989450198
12691725689293841027
14299111188539742446
14554309196853506927
13621820030717244874
15061171619896013204
13848570936070107881
15589759575364007483
8614943407380683998
5943625416786399970
4620913948518402627
1141893664407...

result:

ok 31 lines

Test #21:

score: 0
Accepted
time: 1811ms
memory: 390804kb

input:

600000 1000000 4309911360671027569
Q]2EZ@fQ:e000000000000000000000000000000000000000000000000000000086O@\0000000000000000000000000000000000000000000000000000000jmW?:00000000000000000000g_Z9g00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

16190593881729905334
16542357530067221835
13006406666459343747
7161777294841453972
5409067271265666559
7651254614133775406
2298129566229729011
6200694201691992305
9598225636474472567
18082522737413886808
3056111959820345139
6384402105461983234
12706780510902823913
12669311408153477255
46437198694790...

result:

ok 31 lines

Test #22:

score: 0
Accepted
time: 1785ms
memory: 390936kb

input:

600000 1000000 7436995141926020094
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

14184244854313283376
9781883498504196985
7701117408317836879
5376694249000783186
15294277980735766434
17124729506878059338
17860463004043454702
3476983360116675155
14925051363659654714
10447207040818247244
13378967199275220466
17516363138760232888
6361171526617741196
13252728635811723128
13591361327...

result:

ok 31 lines

Test #23:

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

input:

1000 1000 8437725929278797641
WF6:FWF6:FWF6:FDY9T=DY9T=DY9T=5l<n45l<n45l<n4cGFhkcGFhkcGFhkR2CRbR2CRbR2CRbAmL<YAmL<YAmL<Y0XIFP0XIFP0XIFP3HCWW3HCWW3HCWWB=Fm^B=Fm^B=Fm^QbICeQbICeQbICe`WL9l`WL9l`WL9l6<6?36<6?36<6?3GI3E:GI3E:GI3E:TV<kATV<kATV<kAec9QHec9QHec9QH9`hf_9`hf_9`hf_HUm\VHUm\VHUm\V[Jb2m[Jb2m[Jb2m...

output:

2879529043057822486

result:

ok single line: '2879529043057822486'

Test #24:

score: 0
Accepted
time: 1622ms
memory: 391108kb

input:

600000 1000000 2157214664136746395
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

625993378626284992
15383274421495851986
14967012432324175013
13309083365954090144
13916249697895302410
5191215176762409783
14331710025161187816
796727266462100449
8511234191807100313
11321465949269201153
15035822084783965440
4227447473306892159
7931603458247797170
7107205892918518640
122053305233596...

result:

ok 31 lines

Test #25:

score: 0
Accepted
time: 1336ms
memory: 391316kb

input:

600000 1000000 3866288569617925624
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

12619280355607714989
17866468744121409658
12722116627259575100
5460168469576553324
15625281369783472399
5400472317189310077
13191951403443828668
3919077534433133212
18135092410037289390
11071520995356124823
3952448361324557895
280380274266720160
11243394900477288488
11603786015424524070
478050288867...

result:

ok 31 lines

Test #26:

score: 0
Accepted
time: 1373ms
memory: 390756kb

input:

600000 1000000 9602930142674612216
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

15548364422684912449
6257451137703385122
8664884730053530183
13587113701956890746
11057398742565732389
2332223657635485150
2470887784812285495
92551789679764088
12983395316978561866
16436601811042326176
8223901667716668671
15268544671108163632
4703107227863640616
2334878126613034104
1193955232574019...

result:

ok 31 lines

Test #27:

score: 0
Accepted
time: 1391ms
memory: 390756kb

input:

600000 1000000 17806148600909877070
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

13604369321650215397
6619268216794043736
9758492931091944793
16782287362521652129
8316071155939970724
4629231590215990451
14748623301178570640
17627514221379637689
11107331457014221759
820381441484743875
722884760434756453
16208478857324524829
2416019235897775531
18237859148263038094
106632533749104...

result:

ok 31 lines

Test #28:

score: 0
Accepted
time: 1433ms
memory: 390592kb

input:

600000 1000000 15132331567055337648
Hk_``Hk_``Hk_``Hk_``Hk_``Hk_``gNU@QgNU@QgNU@QgNU@QgNU@QgNU@Qn\NIbn\NIbn\NIbn\NIbn\NIbn\NIbTkC27TkC27TkC27TkC27TkC27TkC27]9X;D]9X;D]9X;D]9X;D]9X;D]9X;D@E9e]@E9e]@E9e]@E9e]@E9e]@E9e]IWblnIWblnIWblnIWblnIWblnIWbln3`oW;3`oW;3`oW;3`oW;3`oW;3`oW;:24^H:24^H:24^H:24^H:24^...

output:

9083652792352006499
3475084857403634918
9184503481270414606
5736598957552816892
7072943500854107915
15166976762650623005
8583570289444080737
6615642091214520814
6607404311673714707
6684647903959986751
3935913498650106514
6617591332686670568
14539681670226908634
11434060817444712783
49977117038371842...

result:

ok 31 lines

Test #29:

score: 0
Accepted
time: 1473ms
memory: 390980kb

input:

600000 1000000 14932304478519336001
>hGn]>hGn]:H=0H:H=0HajN>kajN>keJ4`>eJ4`>hj[cAhj[cAlJa=TlJa=TSkee_Skee_WK_;JWK_;JZk085Zk085^KJf`^KJf`MoVE3MoVE3IOl[fIOl[fDoCXYDoCXY@O9FL@O9FL?n=^G?n=^G;NG@R;NG@R6nhCm6nhCm2NR]82NR]8ilaS[ilaS[mL[MNmL[MN`l4N1`l4N1dLNPddLNPd[mJHo[mJHo_M0V:_M0V:Rm_UERm_UEVMeKPVMeKP5dFR...

output:

3630731270960736363
4331837811409851332
14865858456182644958
16868076832383535997
3354115423712323476
12647690538017076114
9293239552881001071
17231007811497193296
1558120198015807608
9020901626613684189
17344731654954343391
7125649792878384550
9338028859028566192
17139172009594433648
80397469415633...

result:

ok 31 lines

Test #30:

score: 0
Accepted
time: 1470ms
memory: 391324kb

input:

600000 1000000 9900060826479565985
YUFf\cZZ<[]XhbZ?^?`YA\M>Xkaf4WUcTjV7eChUIg16T3hmlSMj_2RolH0QQn:nPZ>ADOd<3ZNF:dXM88VFLB7J\K<58BJ^3o@I`1]^HJL6TG4NDJFVHSHEhJaVDRE=LClGORBNAXPA0CjN@:Znd?DX\:>f^K8=X\9f<bSe<;\QWb:>W@`9@U2>8jhY47Tjkj66l<h5HnN642aRl3Lc`22ne701PgEn0]`<GocbNYnAdY[m?fkElEi7_k;kEAjYmRCigo`]h...

output:

3261091098012506090
1636049810218260227
6831433006181773080
17064926558137143330
17647873826891826947
8533544230241764661
5693136986463115635
14374954149998898123
7846580013921500233
1658343131819030204
11636814422126105447
3456174373065763345
5236797223674122984
12854573735244405498
109542244903369...

result:

ok 31 lines

Test #31:

score: 0
Accepted
time: 1615ms
memory: 390732kb

input:

600000 1000000 80830355193542322
CB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22ECB22E1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWV1XIWVfVe9cfV...

output:

16080482629091226831
13349204371132261437
18418267679544183231
3919623990739657268
16117922751711063031
15669297526083935410
11639718081292377172
17996115359275583495
8812428209153600981
9761274250960948591
1454121669844637682
8344899842925739034
9246694394930120121
13538001452073005302
337300506368...

result:

ok 31 lines

Test #32:

score: 0
Accepted
time: 1732ms
memory: 390588kb

input:

600000 1000000 2655805004394566608
TcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFfTcgFf@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?@^Z`?...

output:

7649920132702319089
7590611204117925822
2722718206798072441
6890592234766774286
9310617814099500561
6238118600081392877
5137401625140132006
4025391164176275636
3766115758369252965
6823075031794897062
241712441764233091
3904093352804752531
732534729845678809
13558779227277228979
6331943497502200644
1...

result:

ok 31 lines

Test #33:

score: 0
Accepted
time: 1479ms
memory: 391236kb

input:

600000 1000000 10035320276002512781
TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G`TK2G...

output:

2439199891051498516
8091544151089214316
12930408742775271404
10784039575919928039
3122437867398739779
3360703537265579264
7620618618973666122
1480900381216088129
12582135201326059452
17622680946236065971
10819807918765803346
11057353364292330507
17234631519012009279
5548390625524944169
8078088561521...

result:

ok 31 lines

Test #34:

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

input:

10000 10000 16982955102069548379
6Bi=e6Bi=e00000<UbKZ:g;FO00000:g;FO:g;FO<UbKZ00000<UbKZ000006Bi=e:g;FO:g;FO00000:g;FO6Bi=e<UbKZ<UbKZ<UbKZ6Bi=e<UbKZ<UbKZ6Bi=e6Bi=e00000:g;FO:g;FO6Bi=e:g;FO6Bi=e<UbKZ:g;FO<UbKZ0000000000<UbKZ00000000006Bi=e:g;FO0000000000:g;FO<UbKZ:g;FO:g;FO6Bi=e:g;FO000006Bi=e6Bi=e<U...

output:

5837865268175567946

result:

ok single line: '5837865268175567946'

Test #35:

score: 0
Accepted
time: 1599ms
memory: 391176kb

input:

600000 1000000 3176191054567281050
DoD@SDoD@SDoD@SDoD@SDoD@SDoD@SgFmHFgFmHFgFmHFgFmHFgFmHFgFmHFC\619C\619C\619C\619C\619C\619`5_9l`5_9l`5_9l`5_9l`5_9l`5_9lJI`cgJI`cgJI`cgJI`cgJI`cgJI`cgi`Ik2i`Ik2i`Ik2i`Ik2i`Ik2i`Ik2M:RRMM:RRMM:RRMM:RRMM:RRMM:RRMnS;ZXnS;ZXnS;ZXnS;ZXnS;ZXnS;ZX9bMF;9bMF;9bMF;9bMF;9bMF;...

output:

9004600764986011261
16254647383450746303
482520844879028867
14337454674450581282
14946298124654780823
855795935284618900
939179409421859887
16556559327376642370
17456651133027115321
16801503300659402393
5211509076757879941
7106536824888114344
2508295510737536501
6306546001249606017
74672087667884971...

result:

ok 31 lines

Test #36:

score: 0
Accepted
time: 1731ms
memory: 390916kb

input:

600000 1000000 13552799623292915016
Qd`HOQd`HO7PMI`7PMI`o4_CQo4_CQfYi=BfYi=B>=;73>=;73UcE`dUcE`dMGWjUMGWjUDjaTFDjaTF\N3^7\N3^736<;h36<;hkRn1YkRn1YkRn1YkRn1Y36<;h36<;h\N3^7\N3^7DjaTFDjaTFMGWjUMGWjUUcE`dUcE`d@mD<m>=;73fYi=BfYi=Bo4_CQo4_CQ7PMI`7PMI`Qd`HOQd`HOI@2B>I@2B>@mD<m>=;73XIV6\XIV6\3WhaK3WhaKk3:k...

output:

11260178328991865682
8964345145536266961
6781343260324983091
8547843513629296748
3753916057795389812
8110389247169546133
3318432453724184518
1863233459034664496
10016147853154290321
11807049380735886499
2077322077254407239
1213618887983420910
1902771333354634367
12861727690037240712
1828084053197845...

result:

ok 31 lines

Test #37:

score: -100
Time Limit Exceeded

input:

600000 1000000 16551589248567395466
^eQn=\SmBF]AffOVNH[XW\C?QUj?SjT847cQFfk<T847cUj?SjW\C?QVNH[X]AffO\SmBF^eQn=_7ZJ4ZIHVk[[C2bYm?^YX?4:P6WQAW7EZe^53fIe4amml1_?130M4U:2;H9A3iC]H8fm`_94fDV;BZhm:PQLd?nCP;><H42<J4XI=X?<@J5HCgKgCgnIQ?KUHC4o\PW=o[LomWJNYQ;1OKZ_8DD4boEV?FfG`Cj]F2HNTVMX;6B^Q6B@hmZ9A:f>0Yno>...

output:

8436997296004701110
18162012063635360779
10953248757816869101
3176822948695164687
4616486173189397316
7163419745193456956
17481228237914723814
124611924326956947
8279857669287320368
15807893384559425988
13468959750427542267
8317245687842300757
15712507258948750834
16323000845826838017
85868879458879...

result: