QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#109173#4631. Interesting String ProblemIsrothyAC ✓2211ms944012kbC++235.6kb2023-05-27 18:09:112023-05-27 18:09:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-27 18:09:12]
  • 评测
  • 测评结果:AC
  • 用时:2211ms
  • 内存:944012kb
  • [2023-05-27 18:09:11]
  • 提交

answer

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <numeric>

const int M = 500005;

char S[M];
int n, q;

struct SegmentTree {
    int sum;
    SegmentTree *ls, *rs;
    SegmentTree() : sum(0), ls(nullptr), rs(nullptr) {}
    SegmentTree(int sum, SegmentTree *ls, SegmentTree *rs) : sum(sum), ls(ls), rs(rs) {}
};

int safe_sum(const SegmentTree *p) {
    return p ? p->sum : 0;
}
SegmentTree *safe_ls(const SegmentTree *p) {
    return p ? p->ls : nullptr;
}
SegmentTree *safe_rs(const SegmentTree *p) {
    return p ? p->rs : nullptr;
}

SegmentTree *insert(SegmentTree *p, int l, int r, int a) {
    if (l == r) {
        return new SegmentTree(safe_sum(p) + 1, nullptr, nullptr);
    }
    int mid = (l + r) >> 1;
    if (a <= mid) {
        return new SegmentTree(safe_sum(p) + 1, insert(safe_ls(p), l, mid, a), safe_rs(p));
    } else {
        return new SegmentTree(safe_sum(p) + 1, safe_ls(p), insert(safe_rs(p), mid + 1, r, a));
    }
}

SegmentTree *merge(SegmentTree *p, SegmentTree *q) {
    if (!p || !q) {
        return p ? p : q;
    }
    return new SegmentTree(p->sum + q->sum, merge(p->ls, q->ls), merge(p->rs, q->rs));
}

int kth(SegmentTree *p, int l, int r, int k) {
    assert(k > 0 && k <= safe_sum(p));
    assert(l <= r);

    while (l < r) {
        int mid = (l + r) >> 1;
        if (k <= safe_sum(p->ls)) {
            r = mid;
            p = p->ls;
        } else {
            k -= safe_sum(p->ls);
            l = mid + 1;
            p = p->rs;
        }
    }
    return l;
}

template<size_t SIGMA, size_t M> struct SuffixAutomaton {
    int trans[2 * M][SIGMA]{};
    int mxlen[2 * M]{}, slink[2 * M]{};
    int ch[2 * M][SIGMA]{}, position[2 * M]{}, dfn[2 * M]{}, node[2 * M]{};
    long long sum[2 * M]{};
    SegmentTree *tr[2 * M]{};
    int tot, dfs_clock{};
    int n{};
    SuffixAutomaton() : tot(1) {
        slink[0] = -1;
        memset(ch[0], -1, sizeof ch[0]);
        memset(trans[0], -1, sizeof trans[0]);
    }
    int extend(int p, int c) {
        int q = tot++;
        mxlen[q] = mxlen[p] + 1;
        memset(trans[q], -1, sizeof trans[q]);
        memset(ch[q], -1, sizeof ch[q]);
        while (p != -1 && trans[p][c] == -1) {
            trans[p][c] = q;
            p = slink[p];
        }
        if (p == -1) {
            slink[q] = 0;
        } else {
            int r = trans[p][c];
            if (mxlen[r] == mxlen[p] + 1) {
                slink[q] = r;
            } else {
                int o = tot++;
                slink[o] = slink[r];
                mxlen[o] = mxlen[p] + 1;
                position[o] = position[r];
                memcpy(trans[o], trans[r], sizeof trans[o]);
                memset(ch[o], -1, sizeof ch[o]);
                while (trans[p][c] == r) {
                    trans[p][c] = o;
                    p = slink[p];
                }
                slink[q] = slink[r] = o;
            }
        }
        return q;
    }
    void dfs(int p) {
        // printf("%d\n", p);
        node[dfs_clock] = p;
        dfn[p] = dfs_clock++;
        for (int i = 0; i < SIGMA; ++i) {
            int q = ch[p][i];
            if (q == -1) {
                continue;
            }
            dfs(q);
            tr[p] = merge(tr[p], tr[q]);
        }
    }
    void build(char *S) {
        auto n = strlen(S);
        this->n = n;
        int last = 0;
        for (int i = 0; i < n; ++i) {
            last = extend(last, S[i] - 'a');
            // printf("%d\n", last);
            tr[last] = insert(tr[last], 0, n, i);
            position[last] = i;
        }
        // puts(S);
        // for (int i = 0; i < tot; ++i) {
        //     printf("%d %d %d %d\n", i, mxlen[i], position[i], slink[i]);
        // }
        for (int p = 1; p < tot; ++p) {
            int q = slink[p];
            ch[q][S[position[p] - mxlen[q]] - 'a'] = p;
        }
        dfs(0);
        for (int i = 1; i < tot; ++i) {
            int p = node[i];
            long long l = mxlen[slink[p]] + 1;
            long long r = mxlen[p];
            sum[i] = sum[i - 1] + safe_sum(tr[p]) * ((l + r) * (r - l + 1) >> 1);
            // printf("%d %d %lld %lld %lld\n", i, p, l, r, sum[i] - sum[i - 1]);
        }
    }
    int query(long long k) {
        int i = std::lower_bound(sum, sum + tot, k) - sum;
        assert(i != tot && i != 0);
        k -= sum[i - 1];
        int p = node[i];
        // printf("%d %lld\n", p, k);
        long long l = mxlen[slink[p]];
        long long r = mxlen[p];
        long long res = -1;
        auto f = [=](long long x) {
            return (x - mxlen[slink[p]]) * (x + mxlen[slink[p]] + 1) * tr[p]->sum >> 1;
        };
        while (l <= r) {
            long long mid = (l + r) >> 1;
            if (f(mid) < k) {
                res = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        assert(res != -1);
        k -= f(res);
        // printf("%d %lld %lld %lld\n", p, k, res, tr[p]->sum - (k - 1) / (res + 1));
        // printf("%d\n", kth(tr[p], 0, n, tr[p]->sum - (k - 1) / (res + 1)));
        return kth(tr[p], 0, n, tr[p]->sum - (k - 1) / (res + 1)) - (k - 1) % (res + 1);
    }
};

SuffixAutomaton<26, M> sa;

int main() {
    scanf("%s%d", S, &q);
    n = (int) strlen(S);
    std::reverse(S, S + n);
    sa.build(S);
    for (int i = 0; i < q; ++i) {
        long long k;
        scanf("%lld", &k);
        printf("%d\n", n - sa.query(k));
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 28ms
memory: 241852kb

input:

pbpbppb
3
1
2
3

output:

2
4
7

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 8ms
memory: 241900kb

input:

potatop
3
6
30
60

output:

6
3
4

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 167ms
memory: 242940kb

input:

dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...

output:

323
644
809
442
923
155
645
275
443
779
441
563
830
495
442
71
699
649
467
204
755
274
394
316
604
211
503
455
764
515
691
541
76
369
695
734
953
440
322
808
693
690
565
116
420
861
179
358
640
687
735
796
581
473
593
859
876
666
596
587
515
616
58
425
470
707
556
735
194
789
819
788
582
666
525
270...

result:

ok 500000 lines

Test #4:

score: 0
Accepted
time: 198ms
memory: 242708kb

input:

gtgggtgttgggggtgtgggtgttggtttggggtggtgtgggttggtggggtgggttgttggttgggtttggggtgttgggggtgggttttggttgttggtggggttgttggtggtggggtgggttttgggttggtgggtgggtggttgtgttggttttttttgttgggtttgggtgttgttgtggtgggttttggttggggtgttggttggtgtggtgtgggttttggttttttgtttgtggtggtgttttgtttttggtggggtgtttgttgttttggggttggggtgggggttgtgg...

output:

791
715
455
614
589
333
462
296
719
129
801
506
651
668
60
784
111
326
964
356
442
261
328
390
482
320
382
555
729
612
819
154
591
442
890
652
359
652
832
676
670
359
575
146
304
402
71
626
510
209
601
705
29
722
579
502
904
229
712
76
940
897
403
810
506
832
422
183
365
648
659
344
621
478
268
605
...

result:

ok 500000 lines

Test #5:

score: 0
Accepted
time: 214ms
memory: 242540kb

input:

uuppuppuspusupspsuspsusssuupspppuuuusupspsssssusppsppsppsppsupuuupsssussupspsupsusssppsuuppspsuuspuppssppssusuussuuuupsspupssupuuppppsspuuspsupsususussupuppuuusspsuupppspspuupuppuuspssususpsususpsspsspssuuupuppppsupusupppsppspsuuusspupuspuspsusspsuspuspssuupuupsssupupppspppupsuspusppssusspspsuuuspsp...

output:

962
574
660
750
321
290
141
797
243
259
884
743
737
117
263
491
886
547
707
637
228
362
319
942
424
511
174
963
30
802
355
175
186
732
438
147
295
303
611
716
528
587
598
494
515
447
950
469
696
878
638
429
699
497
566
641
624
229
325
663
747
36
695
480
307
108
558
379
485
425
590
499
129
432
308
51...

result:

ok 500000 lines

Test #6:

score: 0
Accepted
time: 221ms
memory: 242568kb

input:

vqvvsvvvvqssssvxvxsvxvsvxxqsqxqvvxvqqsvvsqvvssqqxvxvqqxqxvqqsxvsqxqvvxxvsxvxxssssvqvvsxvqvvxxxsqxvxxsqssxvvxvsxsvsvvvxsxvsvsqvvvqsssvvvqxssqqqxvqqvsqqqsxqqxvvsqxqqvsxqqqqvqxxqvqvqqqvsvsvxsvssvqvqxsqqvxvqqqvqsssqxsvqvsqqxqqqqxsxxxsvsqqqxvssssxssqxsxxvxqxvqsxxxqxssxxvsxxxqqvsqxsxxxxqxvsqsvsqsqssvsxqsv...

output:

632
645
793
548
149
257
583
737
498
191
455
342
416
572
682
546
730
158
683
772
369
410
637
367
398
201
385
878
615
531
578
603
773
560
723
46
763
497
645
798
480
476
352
871
301
514
614
907
301
378
52
147
686
646
721
132
185
716
614
799
720
266
143
161
319
409
750
403
190
775
746
718
378
839
537
58...

result:

ok 500000 lines

Test #7:

score: 0
Accepted
time: 200ms
memory: 242708kb

input:

hcccjchdjcccjchhhdjnjdhdhdhjhjnhdcjdjjdddchchdhnhnddjdccdchcjddhcdhhcnhcjjjdjcjndcchcjnnddhdjhdddjnncnjdchhhdjcjhdjjdcjdncdcccncdcncndcjcchdhhjnhjdjnnddcnjnhcdhdnhnhjdjjjdhcdhhdjdjcdchcndcndnddjdnndjhdnndnhcdcnnchdcjndnhnnhhnddcjjndjnnhnccjhjjdhdhcndcjhjhcdccncjndhcdjndcdndnjdjhddchccdnhjnnchhhhhhjn...

output:

247
451
133
282
286
164
366
496
475
128
537
614
823
528
451
754
529
770
290
494
775
601
511
273
615
321
494
272
187
291
658
543
490
480
602
770
625
568
342
281
715
589
79
336
664
55
612
445
202
778
414
400
69
483
520
604
590
187
537
88
463
817
639
335
218
645
335
532
259
555
288
221
326
333
791
348
...

result:

ok 500000 lines

Test #8:

score: 0
Accepted
time: 239ms
memory: 242712kb

input:

cjggyjgjcffcgczjyjzjjzjgzcyzjczjffycjzccjycyjjyfyfzcjggggfcygcygjcjczcyzjffffyfzzzfzzgjyfccggzzgfygyzgcjgzfyczyyjggfyjyzjjjzyfzzzffcgygjzjjzfgzjfyjgjycfgygfgzcyfzjjjzfgfjjgjfyyzyfcfccfjgyzczczzfzgjgjzyfgzygfgjzjcyyjzyffyczzfjfgzyycygfcccyzzjcfcfccgffyjygcgfycyjjjfjjcjggjcfgcfgfjjcgzjzyffyccjfzycjggy...

output:

832
500
318
646
402
803
626
778
275
460
807
312
393
670
580
729
368
301
428
504
735
331
206
492
203
665
429
816
724
502
744
684
727
282
63
553
397
708
512
729
299
507
602
681
218
535
440
327
607
400
241
904
481
274
735
871
669
460
502
593
862
250
674
745
339
584
252
272
333
819
583
455
99
513
265
43...

result:

ok 500000 lines

Test #9:

score: 0
Accepted
time: 185ms
memory: 242732kb

input:

illulituiuyifyufffilyuilnynliiftnyinunltinnltluiltinuttuffiffitfylttiiltnuuiflfiuiuntiniluiinffyiylunnufitlltnntnufuiltnyuyunuflfilufilluinllttinntliufyytnifytfuunltlnffiiyluuifyftnyifnntfilliyyiunfiffyiytnytlnuilinfynunttnyttnuttiiittnntntytittiyyniiutfffynfuffiiilfyulffynnufuuuyiffuyyyfuitflntlnni...

output:

80
323
340
267
796
859
296
257
100
585
696
209
376
396
827
443
107
407
765
386
346
596
592
816
422
306
418
561
346
510
724
269
741
551
299
760
240
639
191
567
252
263
488
284
323
563
395
268
628
284
645
290
556
808
322
167
641
609
645
307
250
756
938
717
736
217
279
275
173
301
616
433
599
727
717
1...

result:

ok 500000 lines

Test #10:

score: 0
Accepted
time: 181ms
memory: 242484kb

input:

aykyaaucykauxckywnaxwwawxycxyanaayckkxuxccawukxkuaxnyxuxcxucynkkknkuuxwwxauyywxakkwwuwxkyuncuunxwkaxwnkawkxxxykwuauccyaanunkxawwxwckukykcuuxwnwxwcynnukwucukkwkayuyakuuxknaxknnkakkukukxucxkcnxcaxywaawuxaaxayknxwwyxkncnuwkuuxwywxxayxkukwxawnakyuxnkwkwaucxkknxxackuuyynkyccuucnuknynnyyucxnuxwwckwykawxyw...

output:

314
632
448
318
153
717
464
469
279
634
511
747
851
273
548
406
614
490
130
222
68
47
635
559
840
406
339
144
584
600
941
672
237
537
451
769
342
459
522
789
601
352
383
395
585
713
304
406
637
408
794
674
424
638
378
330
241
193
847
509
895
363
605
366
293
239
657
459
460
343
663
518
837
355
633
20...

result:

ok 500000 lines

Test #11:

score: 0
Accepted
time: 215ms
memory: 242708kb

input:

iyaaobwiwaawywiovmaabvwomwmmobwvowoywiawmimimfvyyywvimvofwwmvfwfowbyombmmmbboooobvmfvfoawiwymfoomiwivyvobfwivmfiayyofvmvammwmbfowifmmoaifwaiovywbfymifmibobiawoiiiabfwomwiayobwyvvommafabmmmmiiibiwvbbmommbofbyvmvfwiowaovyyoywmwbyfmmbmvyimwoiivmmomyvbmommoavmbbiimovfiafwiaffbbffiymvvoiwwywowaoofayyafif...

output:

183
956
637
305
204
263
879
544
658
538
382
635
673
486
411
239
188
89
281
768
566
708
249
227
388
827
388
357
978
203
524
227
608
600
643
835
436
63
558
387
89
698
239
233
526
491
270
839
498
523
696
944
766
925
842
56
705
367
464
174
537
127
535
368
687
466
139
870
279
86
593
703
586
899
422
779
6...

result:

ok 500000 lines

Test #12:

score: 0
Accepted
time: 243ms
memory: 242484kb

input:

vbvvddssmuqqsybsyygvqviduqbgiviqbbsqgisgvyguiqyssqiyuiumsbuiyqgqivqvbysvdmuigvsviubimbidbsygqdgsgdgqbdggidbbyuuddsdsvyivgddyyudmsuvgvdbmvdiuyyibuqdvvgqsuqmisubyqiudgyqmsmiysyussygbvyvsivimqqmviisvvbqsbqsgyiggbbimiqsmisiidqdusvivqvyibvvgmmbqsudigiiqdmdbubvbvusbyygydbqmdggvmqmdbdudidsymqbqbuiubmvqgduv...

output:

463
682
567
495
449
309
588
253
736
105
362
309
282
910
434
734
670
741
810
616
331
695
804
273
347
262
830
251
515
351
677
275
832
718
12
188
53
476
769
220
575
825
509
808
361
468
354
797
684
240
182
469
162
166
349
757
549
395
572
258
616
123
405
589
647
314
611
796
816
650
394
608
40
176
409
203...

result:

ok 500000 lines

Test #13:

score: 0
Accepted
time: 198ms
memory: 242484kb

input:

btcuswtwttuulltfdllcdcyccdqwyfbqlyqbqwuqqquccqqluqqsuswfbqtcbdtldfylsllfbddtbdcbwdbcdwwbqcdtcudqdcylwstttduddbubwysydqqsyswwqfcutyyclyqlqfbwscycwttdfsldfssfqftydcftldwfuubyfqfscfwbstcylblqftsqbdybydbtcbfqlcqtssbtulyfstuytdwcbbylqutqlcfwtuwwqldycusqwwyluqwwubfyllqcqfstcufwlwulcbbwdsudfltqtdcsclyylywt...

output:

250
786
289
222
220
212
705
946
856
337
580
497
792
174
172
699
89
378
888
447
155
795
599
619
543
523
492
368
319
470
478
429
715
136
201
647
792
203
565
560
160
792
682
601
866
728
239
792
416
272
557
583
221
853
290
695
13
762
314
356
553
623
345
477
647
585
530
326
334
105
474
447
388
510
579
29...

result:

ok 500000 lines

Test #14:

score: 0
Accepted
time: 238ms
memory: 242572kb

input:

sblrorbgldylcdrxooszdrxciizgrlgcxrobrldirgxdxgcoscszlzlydyllzxdzirsxscsozrglbdgbxbgdbsxorlxxcgxizdxgoxocicxdiislosrxocxgszxixczrbllisdbgcsyzxlliidzdxdsoyrbcizcblrdxillybszbycxyicdbcssdlsiixizrlgobzoizcdrdrzlrigblziyrzrooczdiogdodbsyslcdcgrzycoiosxblixizdsglxdrisszcgisilbxgobiygzdiysxxydcxxrlbcrgzdiy...

output:

897
785
754
226
868
764
631
345
798
779
522
748
401
155
702
266
469
287
680
808
195
819
77
883
91
328
423
493
520
363
196
414
330
920
349
496
428
473
435
521
727
872
796
680
578
363
518
456
521
416
532
380
742
732
429
605
315
147
777
569
519
606
816
146
308
587
540
313
775
843
233
106
667
317
217
49...

result:

ok 500000 lines

Test #15:

score: 0
Accepted
time: 214ms
memory: 242536kb

input:

zcfkrrjhbjkzrafjbfvcbhfckpkkgsrvjcjkhcrrsazcjcvbajhpaazapasacszskzzbsbpszhfrpjgjhgpaappvzhjrgrfzzbszkzaccksjhsjczbvhkpzzkarkjzvzvzcbvfshazvpfbzcpkfrjfbachksgzrsagkgzvvavzkppbvjcvjgzavgvfjjvhgczzvhfhcrcjsskzpvrzvbgzbgzrghgkjgaafghgjhcvbgvzrbhjrfjsakbrbscjfpkcsbhjzfkrjpkrpsgkahfkjrakzzjjvcaphkjvhfzkgh...

output:

314
530
217
222
163
509
286
290
589
843
533
543
366
827
440
571
925
223
646
294
683
251
533
112
590
448
741
504
493
652
339
45
307
421
343
493
643
198
810
715
546
617
531
568
575
411
424
225
392
675
149
642
603
192
297
698
529
395
471
775
783
301
481
478
742
318
346
479
754
405
642
357
437
634
842
3...

result:

ok 500000 lines

Test #16:

score: 0
Accepted
time: 215ms
memory: 242536kb

input:

nctmfuwtjtktmkwlfpmjuwnklufnftrjuwpcjrntuwpkwpphwckfqrmqtkcmltmhufcmjtmhtuqfhclnnluuwpjqwmtpwkppfnclcjpchkkmwnutrhwnpnmhcuctffkcpflqnjrnjnfkhwmnmcpwrrttpnwcfnqrjlqmtkncfcqjufkjctlwmhnfcnhpnmmktnjphpmnqwcjqmmfjukllwurnccmqhquhrfumqlmtmthchuphpullnmmthpwrhwlkpujlkphnftpnhtnlkmunfnpqjfjpppnmmqtfjwnfhcc...

output:

555
466
88
100
586
159
839
920
180
519
487
492
251
766
377
264
611
400
423
658
479
239
671
698
352
157
537
124
141
385
853
523
705
595
677
580
694
490
529
648
863
818
523
668
775
923
648
489
399
161
146
239
276
376
694
915
337
745
833
554
469
751
172
949
582
606
501
332
120
605
245
827
26
806
808
84...

result:

ok 500000 lines

Test #17:

score: 0
Accepted
time: 213ms
memory: 242552kb

input:

qpwnfmpwfufwiieehpfuwuepigxfuevgepiuihmwformmurfrxueurfvnxrimhihxfofonqhpreffrnhnefhqxwopiupouqqogomoohienioworxfwugrigehxixiifefrgrfgqvorngnvqwwfxeouiegxfohivmhqvqiihmoxwgnughgewmxpuqfrpvrvpmureumnxqehnwnqrgghwwieopxmnpmvimfqvmmhviepxinropffvngwhourxguvhuripfpniugevigrgmonvqieeqxpiqwvfmxvmevhmhhiuw...

output:

825
442
454
437
589
662
540
633
664
417
129
710
313
295
756
727
745
747
822
807
990
835
590
304
122
153
241
476
27
826
243
645
936
79
550
328
450
479
621
953
583
397
947
510
844
233
458
210
506
864
612
336
940
428
560
881
156
405
156
225
418
824
452
599
415
653
444
495
358
544
275
424
323
564
767
78...

result:

ok 500000 lines

Test #18:

score: 0
Accepted
time: 212ms
memory: 242552kb

input:

tgaxtbbpxabtqufqkucxqzhqraobozqpiftzbafxhcbuqhuiifhtrrpihobxxcuttfqhpkrzkbpotaghbqtupoqpoczahtpczbxikrioxbpxctpxbgocqbahqobitipfhoqragtqrcgcihgotichpuzcqkoobhhgtutihrpgxkbqxohgcthffhcfopfapbphqfapgzqgahupfagzzhpopkbgtfcqafpubqhzizzqtgqpkopioxbzahihrqiaappxzgzxxrccxpiafpbxiffoquhuibbchxukziqcfcfopzxg...

output:

214
800
730
369
127
702
475
496
765
402
300
763
805
230
161
309
704
468
845
348
611
476
157
781
227
292
759
187
96
793
734
742
414
583
500
144
781
787
397
377
562
554
395
495
234
335
273
436
622
707
322
764
561
704
504
481
453
472
229
240
475
701
535
117
495
521
198
349
266
449
727
877
655
522
736
1...

result:

ok 500000 lines

Test #19:

score: 0
Accepted
time: 218ms
memory: 242540kb

input:

wwtjqqtttozlzdsjwfkojmsvlofvkhvrvdzlmwzkshqlfzmgkzqklkjhztvjwgtmxvrglwmvkottxsftmwmsvgqmgqhrsszwdkldjkvtlvtzlvgfzwvszqsohkdgflgvlfgkmxmfvosxhsjsomxmsgtozwrogkrffgqwmtlljwsqxshgtkmdkwrktdzfwxljjvosxjqogxmrvomqzoqkrkvtlmgqfgjzfsrfwdrwzskdtjlsodzhwxxfdwjljzoofdqtdhjwolktjgdjwxzhtxrdstrrrwsgdmwgorldllho...

output:

75
169
331
747
547
740
691
629
199
527
592
470
186
715
383
480
408
153
539
438
482
364
388
513
748
600
50
67
562
204
930
141
630
282
803
588
806
588
302
327
613
711
687
248
662
509
538
741
635
299
607
561
461
227
181
915
236
439
340
160
131
572
492
427
374
495
859
199
674
850
790
868
507
876
463
376...

result:

ok 500000 lines

Test #20:

score: 0
Accepted
time: 195ms
memory: 242488kb

input:

iadnxnxelwnjiiwxcteaxpcmphvwphjidjpnwimahcjtmvizihxhsnammddtzevjvoimnhlxjnmjwihaxcpepneacwpmjeevtpvsdzsmaztzclaeoxdntaoazxllsemascencxopanjaxdcntipxedxzjdeipidwmzovesvtoijshcwcixjievvdoadilojazolcnldahxiswppmdjzwlmnanmcpvewjhihdmstixstsijlwotlpmlpsxlevzainmznatvzllihtjpnpxlnhedmpwlwhvxitatjcniapoije...

output:

352
605
309
148
612
282
515
561
681
628
493
883
485
795
649
778
342
630
756
646
781
537
444
442
445
824
736
570
244
433
393
363
424
185
919
162
453
808
712
540
277
281
713
360
199
434
804
51
584
557
928
291
846
554
774
494
255
443
608
627
144
818
836
630
435
504
525
292
544
211
696
232
438
131
136
9...

result:

ok 500000 lines

Test #21:

score: 0
Accepted
time: 214ms
memory: 242476kb

input:

yqoopvwnfaubnvwpybhpbjoonfiqbvjbuyhyvvbjusiniphqcbuynkvheonvvhkkfbycuknmmvawjefuwyjppccakqjcfaoeiwvfhyipwhhkswhswjoaubvhuqoncfwemnqnucpusscahavbijffcbffqnfafamvmmoschhyenfnhwfouipmwebfinyyqjhimwopjbhypsuqwynyjbocjysubhbyshjnoeefcwyhpaiihnbupoeebickkqewkwnjiwkhbyioupqmkychimpopsonuvwmwkffvqpcnbmhqhmp...

output:

685
699
668
733
424
825
474
262
517
437
342
661
656
176
898
370
591
746
676
497
530
477
361
637
588
320
426
394
247
130
379
195
314
632
491
449
365
420
270
456
468
398
487
630
694
514
914
832
32
402
530
370
242
802
416
431
421
175
542
243
489
479
810
346
80
770
381
594
523
874
522
572
750
305
33
646...

result:

ok 500000 lines

Test #22:

score: 0
Accepted
time: 207ms
memory: 242712kb

input:

nlofuytixdmtwouugdfosniyfodlpmlmftlewdsptcecnlynddneysyceudxcismpluopzexnpzttxppfzonmgpmnuemiyfzfxzegbvsxziwezwmnleyogxpcdvivynstweupygspivlcpomnbfusgiudiollwlvtxsdswcnupxzositewmnwnzcwmptisdvtbsiwtupoppximyfvuiytfyvfcpsocelpevcvntultngnmgiluucsixbxbzgyecuetzecbndlgbvteptfbscnonextldlgbeybimcczmugdn...

output:

339
774
271
325
91
772
620
853
375
938
288
878
245
771
652
338
393
558
46
523
672
169
834
244
535
889
665
298
41
553
431
625
380
485
58
326
438
668
267
599
592
133
374
429
895
484
379
616
71
781
549
547
481
168
609
795
690
786
720
497
641
755
249
681
919
466
291
378
610
492
574
580
616
349
786
336
8...

result:

ok 500000 lines

Test #23:

score: 0
Accepted
time: 204ms
memory: 242532kb

input:

evgsxyszizjvkayssyjimmvexcignjtcgpqztggfgjiqccnjugafqiyafspiegpmanhgevghxxasigntxgvfuvgmzzxfgfvogzggfqekkszfauhpjezffvtktkxyxcktzfsvueokzsmpfiiyauxeuuecokqteyaajmnyzygnnmzgshnyopfiysxuzoezfzvaonhvogsxkqmcspmoeeiyqkkfmcyieegyhgsnqxqvahyegohspkyecujsisixkuvymivkzjaqopeksnshsegyhemaqityucjhegjycghukpii...

output:

684
884
353
433
715
517
304
179
855
729
615
400
272
609
727
589
173
417
613
714
559
616
859
705
306
772
422
314
681
206
355
516
369
826
476
434
60
548
193
530
238
532
524
164
809
426
126
346
818
386
43
86
574
411
230
466
548
280
450
682
99
767
464
625
305
147
32
391
709
866
947
119
748
701
421
818
6...

result:

ok 500000 lines

Test #24:

score: 0
Accepted
time: 193ms
memory: 242728kb

input:

ovoojjlcfwuqpcneuhknkcvqkiuotuwfsczcpokkryumycqebwzpwjehopuyfiwihovecyqewqzuuerieszwutuwfjtkznsenirjthcptrjribfkeihyusrufntjjtsecrpqrubclfooykroczvhqywpnfwkjyjmwmpnyciskmumzsrsjspqqusefmoofvoszfizrrcnjqnbvzreemesrvorkmhitwzejmrhcikscosymjvcmjecmuzmsthkqwycwpbouineiflnqucyohriqmkykhflqrmpijqlwjfmyttf...

output:

531
706
107
412
248
638
317
865
266
419
869
257
331
601
266
318
400
638
481
582
371
328
416
589
239
466
517
481
661
386
610
665
281
380
413
122
308
712
486
608
491
558
506
618
770
500
497
499
807
588
436
619
879
481
648
114
634
622
738
670
577
838
467
423
587
146
674
371
606
92
197
418
393
317
569
3...

result:

ok 500000 lines

Test #25:

score: 0
Accepted
time: 206ms
memory: 242712kb

input:

nvhhpnuysrbeuylwdgivwbsiegwrhbhbxybyludoaqewloavndbxenhaionhlyonwqxtvddyaftayskertyufnhwxklhousuvnatorulwxrkkbdrtfxtdrtunygukdlccfldgducurcfsfvxdbqahkpnivukfwqncpprbkxlouwcbqypcqeqtsbxghhiairctwordktkoancfgsckdvqsrcnkpsbecoctuulyrapqiwrsnrcoqdxrpyrhdcxsvfxfekslxlprssvtrwsalgyhthvdnhvesfeucdccirfirkq...

output:

674
115
623
625
75
750
871
647
575
641
559
519
704
398
764
805
667
437
375
932
205
712
207
876
590
264
936
75
460
121
647
420
309
215
255
287
262
320
511
941
107
498
713
373
822
508
536
658
562
183
314
341
542
758
740
852
735
90
667
569
150
513
827
750
367
445
858
528
439
886
987
873
669
743
952
411...

result:

ok 500000 lines

Test #26:

score: 0
Accepted
time: 194ms
memory: 242676kb

input:

qnclwkavcnrqyegjasqqsrjsnsybneliwmocgacduivkussloxklajrloagadudikenalwmozevggcarbikgvaamjelqateowqsjhxqsgamabjtignibxidhxyxxxdzdiottlgeoujgihlndxlvoeoincmtooouveahrttnznuswogsudngbdynsrlgkwmbdducdquorudwqkatwybezekxwxvdwkngxoaakcowkwcebvmdgudguogwbstzewdgikohtdsujwngxcehgtorzcxlyxhtabrmojqtdcwxribvd...

output:

719
201
476
708
469
696
747
397
887
248
175
359
504
218
684
655
671
504
799
758
737
391
545
556
204
910
414
435
160
700
726
198
386
733
622
402
257
580
375
251
251
260
286
226
333
457
114
302
206
825
457
391
149
646
724
640
407
149
691
575
291
282
592
195
462
507
614
885
162
825
444
874
637
612
561
...

result:

ok 500000 lines

Test #27:

score: 0
Accepted
time: 179ms
memory: 242480kb

input:

wyegkiddibdhattrwgvqqtznwnqteeafiyenwsislkaqhhkuhrkkadcmfkrookocynirclwasnpcypxrxsaonsfyedmtkmyeugcuaureyrotbfchclwfdnwobktrkixmdowoucsfkwluwxslozpxbafqietyatqgedpvxibqseobffwzwxnroifyfrqnnmgmrulsscyztwybupzuavfuyuvqxwkgtnqxrfoizzrwtaxiynkszmzuzrzitermqcarybxpwftiogdakopapwbmahtzdesnwloydxyydyuomnyt...

output:

802
656
792
425
37
437
647
557
740
593
339
394
100
236
492
201
394
567
197
509
266
558
140
732
381
710
718
488
220
485
400
531
687
567
491
482
499
467
666
627
707
236
632
619
334
713
233
752
184
644
461
466
407
921
355
192
661
187
832
619
259
398
843
363
412
269
551
272
420
639
693
690
527
827
624
1...

result:

ok 500000 lines

Test #28:

score: 0
Accepted
time: 191ms
memory: 242712kb

input:

mwmbcwtvwdrdwvmyeyxufotofxicsyxfuqvvgsmdmgaxgnefqcqmzdmxbkyaknbiiyxrvzedyadwzhrhdjnfxgscujrucnbejcygcccyqmeywhducissvvvvemkunevwdoebknnxtowyqwhpzlqpobqavbhtstrmriruxgkjrgoxbtosifmswgaseayewttdnqpcusxzjlevymiphhkbbmfrdjfucckzgphdaefgkumbmwyoytgiefibzqkbrcyneetwzxiikxwscugrlcezesjmtspioelcetkebqugxozz...

output:

927
203
480
27
138
402
495
638
450
473
848
598
585
482
267
600
928
574
822
331
202
782
520
543
223
717
402
590
714
665
384
879
477
603
488
223
328
40
316
469
723
649
391
403
487
615
475
219
609
602
622
490
808
381
696
263
329
919
944
498
578
695
602
545
240
453
281
454
437
686
548
729
830
431
863
18...

result:

ok 500000 lines

Test #29:

score: 0
Accepted
time: 1464ms
memory: 944012kb

input:

llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll...

output:

204534
339376
229188
372153
306595
299296
135190
120175
59425
262135
373840
443124
248058
473765
384090
267790
389699
215949
119753
297288
187439
348956
353347
235360
228801
335856
84112
461468
381302
105245
359765
170287
460565
308835
144604
225539
149961
105019
216586
112974
175784
227004
260885
2...

result:

ok 500000 lines

Test #30:

score: 0
Accepted
time: 2080ms
memory: 834628kb

input:

osoossooosoooossssssssosossoossoooosoosoosossoosoosssosossososssossossssssoooosossoossoosssosssssossoossososoososooooososoosooosssoooosssoosossoooosooooososssssossosssssossoosoooossoooosooooossssossosoooosssssossooosssosossossoososoosssoosssoossoosooosoossooosooossosssoooossossoooossoosoososssoosooo...

output:

101396
84742
142590
128495
331420
167355
399655
120041
454746
46400
376251
442811
271701
414974
395124
315994
341038
426607
277813
173810
67684
208774
235645
114588
285559
268561
279378
295814
72594
208878
94582
223120
258222
83419
83562
302516
230869
231769
431474
191588
415743
98001
273704
70733
3...

result:

ok 500000 lines

Test #31:

score: 0
Accepted
time: 2121ms
memory: 834572kb

input:

aaexeaxxxxxxaxexaaaaxxxaaxeaxeaexaeaaxeaxaexeeaaeeaaxxeexaxaaexxeaxxxaaxaxxexeeeaaxxaaxeaeaaaaaexaeaaaxexeaaexeaaxxaeaexxeaaxxxaexeaaexxeeeeaeaxaeeaeeeexeaaxaexaaxexexxexaeeaeaaaxaaexxxaaexxeeexexxaexexaaaxaaxxexxxaaaaxxexxxxeeeaaxxxxxaxxexaxxxexeeexaexxeaeaxxxexaaeeaaxexaxxxaeeaaxxaaaeeaxaxeaeeaxax...

output:

255680
387313
153064
141377
226420
268523
322611
262840
239684
173868
128481
223750
343243
275531
55001
162370
296551
315442
184601
218653
254761
376091
347580
334388
187730
168520
325373
150910
152816
18247
123420
66368
104817
146033
173759
231801
301259
208971
330381
234790
219954
177487
482550
84...

result:

ok 500000 lines

Test #32:

score: 0
Accepted
time: 2122ms
memory: 834820kb

input:

rrkxkkxrxkxkxkrrrrrkkxrwrwwkxwrwwkrkwkxwkkrrrwxkxxxrkwxkkkwkwwrrrrxkrxwwrxkkkwxrxkwkkrxxwxxxkkxrwkwrxrwrrrwrwrwkrwkkkxwwrxkrkwxwkrkkkwkkxxxwrrwrrrkxwkwrkkwwrwxwxwkrrxwrxrkkwxwkkkrxxkxrxkrxrxrkwwrkxwwkxrxxrxxkwrrwrxxwkrwwrxrwkrkkwrwrxkkrwwxxrkkxkrrxrrrxkkkkkrkxkxxwrkxwrxrxkkkwxxkwwxxxkkwwkxkxkkrwrxwx...

output:

280548
268728
351155
18124
441761
456830
448070
104283
134205
383218
88170
258233
121649
385860
398456
123710
447050
268614
224441
336489
398682
215485
158198
432092
313958
416137
404841
460600
316547
399950
98603
360013
292637
104181
221709
283407
148556
290825
220615
84606
104495
200063
300385
951...

result:

ok 500000 lines

Test #33:

score: 0
Accepted
time: 2097ms
memory: 834580kb

input:

juuoouuovujuujvvovqqovqqvjvquujjoujoqjuovuuqvjuqojqqjooujoqoovjvooqvoqojjojuvoqojoujjvojvquqvoqqoujjojvjuuoqqvjjjjvovqoojoqujuoouoovujoqjuqujvuvjvvvqquovjjojjvjjqvvouojjuvoqqjjqjqujvouququvoovovqqjqqoouuuqqvoqvujovuqjvjvujououjjouuquujoovquooouuuqjjqqvuvvjvuuovjjvvuuoqvovovjjvjvujuovqjuojqjvooquojju...

output:

12106
212117
445556
371433
58681
98499
144192
131518
193695
457465
314783
211277
164015
228325
330875
216480
338705
288356
262348
417129
343987
218798
249569
234341
237926
260777
56666
323137
296083
450604
141274
118917
334969
29647
227012
257472
166875
184924
102013
428965
247431
247032
262042
3096...

result:

ok 500000 lines

Test #34:

score: 0
Accepted
time: 2089ms
memory: 834576kb

input:

jprpryeyeyeqejeeqpqyeqpqpeqprqjeqqyeyjjpjeqeepqpeeqqjyyjyeprjjyrreyerqyrrjqqjrjeqjqqyqypqrreypeerrreyyjepyryrjqppyeyejqejqejypryjpqprerpejrejqqjjerpjrpjperryejyrrjjrerryrerpqrrqqprqrejqpqrrpyjyjjpryqjyerjqjperjqyrjerqqrrepyyrjyjyqqqrrerrppqqjjjpyrqeyqqrjpepryeprepyrjyryyrrrryyqqyepyppeeqyyqeqpyyjjry...

output:

419174
185714
288731
245681
256678
419222
98462
216514
196730
330499
205882
263847
334116
131117
83452
304334
117068
118097
230643
292449
396302
182837
377913
201374
295949
309894
454585
206392
202298
341546
117599
218498
200177
116254
157103
219723
373054
219939
268612
350338
271996
275179
179163
9...

result:

ok 500000 lines

Test #35:

score: 0
Accepted
time: 2211ms
memory: 834612kb

input:

fvvwwbfwfobvfzwzwfofbfzzobzfvvozyowwovwvybybvzwooyoowywvzbfowwvoozyowbwfyofzfwzvwwovzoyzywfwfzbwzfyyozozwfzvooywovwbybvyfzwyfofbfybfbvzvwzzowzboobovoozwobofbfzvbfozobzzvobvzfoowyzobwbzfozbfzyvzvvzfowybvywzwwooyfbfzbyfyfoowvybzfbbofbvfoyvybozbyoovbozwovyybfyfffbbbooowybzofzwoyzozzwfyzfyyfwofobbwffwwz...

output:

440083
56941
470115
245369
107308
202703
137510
381034
160013
378501
475074
291859
317196
204803
348383
396506
231192
466285
321789
312535
403274
393641
203133
171798
215996
138139
122561
65156
464689
300157
61676
172903
270071
313882
399413
291062
94572
172074
297974
288449
179078
95681
402059
1665...

result:

ok 500000 lines

Test #36:

score: 0
Accepted
time: 2024ms
memory: 834636kb

input:

axomeyxymofxfxfyafxgmgxafoxagxoeyxxaeofaeggyfmaaeeoaooeegfexagygmyxmemmxxmxefegfmefxmgomayoxgaeaaxeyexxxeyyyxmgffaomaggegmgafeymefeyomyaxayxxxaeogxxgeeoagegeoogyxxmaeygeeaemgfxexaofxmogomomxemmymofmfomeaagayggmmmefyyfgyaaoaaxmaxxmfaafgaeeeymexggfmfegmayeamfmfmgyyoyygeoeggmmygfgymmeeymomyaeexyfygxgam...

output:

97838
137560
177508
325015
216088
191002
138185
258897
91677
332725
346233
250588
281820
373233
243326
140074
234032
199252
144942
109819
268113
314128
174338
229858
355108
400585
269305
458651
444058
284001
192955
89413
204973
277031
329553
285086
240912
307290
328496
220823
163100
404118
246549
11...

result:

ok 500000 lines

Test #37:

score: 0
Accepted
time: 2004ms
memory: 834624kb

input:

ohgyjuoggjuhuyuuuungihunnyhgsongngysgngniohoyunuujihihuuuninisgsohnuynhihoghjugshsysuisgjgyynjuuoinhsgyyugjogssuysuuynoinuysoyshjnsngonssyjiuiosjnnninuuuyoyhjosnnogusyjshhygojssgsgoignniyigooyhgoigjioyisisgjjsygygjiynshijjhsssouygyjinhnnyjugnoiioigousnjghgshshnooungjsngosgssussyisyysojigoyjnjuugsjio...

output:

413277
327204
383225
443574
458543
232947
85988
141983
87088
307921
377882
246055
319915
79498
419030
244592
197350
248205
233256
287726
295211
210151
387801
207749
254257
253996
125739
167671
317674
173380
439593
305852
98578
350133
271553
145043
200028
335666
341151
434271
287180
190835
167095
264...

result:

ok 500000 lines

Test #38:

score: 0
Accepted
time: 2115ms
memory: 834756kb

input:

znzzqlnuzqecscezsqeecmzlnlsluqzqncezzbesssqqleeuneslsssqzqqllbcesuzqsbqumnebnbqezblscbeenzlmnumenbcbnbzncmsnmbsssnqzlelqezmbcllblzzqmunbusmbneqbczsqsueueuqnbqmzeuuembnzqcmbzezbeemqqbeuzuubbueqsnlnunsmuemmznnquuebbmnmllnslqmbqzbznblbnzmbecbznbubmlumlbzcmsnnenuqecqumnbnbuzqllsqnseqnqceuncemenzmccsnqns...

output:

205318
401851
101324
165504
131199
142758
224731
336569
293842
150692
261419
474863
263555
336525
167675
173518
178196
192821
58482
479717
218897
345953
314006
144096
178504
338910
383600
303835
292598
222437
160315
129760
183938
174000
292122
336974
116541
324387
427690
448797
198167
282497
195689
...

result:

ok 500000 lines

Test #39:

score: 0
Accepted
time: 2053ms
memory: 834816kb

input:

vbprwpkzsrwbrgrkbagkavvbawsbsbmapsbvssrpzvszwzzpawwwvbgapggarwkvggbzmzamkvszvvzgwgbvmwrwrzspvwzssrggmpvwrmawppgmvwmprbgbmkmapzzprgmwbsazgmzrgbbskababbvvzzzprzzgvbavzvkbsgwabazasskpzabargrrabrsbprmwbgbvbkgzkbmgvbazmksgzggkvvkgkzgskpvpvzvrpmaspaggbggpzzbzakkbabvgbwwbbapaabgvbggarvkgzzsvbpszawpbmrbrvgr...

output:

205881
333264
381170
320914
250030
344809
410951
313051
138698
138391
379156
144456
149402
270748
449007
321326
127381
439973
174344
222765
133244
145366
260133
337399
221596
223066
89529
106448
75461
407753
202655
224556
201587
228979
239619
185935
324881
36868
123397
319628
189887
347185
272640
36...

result:

ok 500000 lines

Test #40:

score: 0
Accepted
time: 2044ms
memory: 834660kb

input:

efesthkhtfwsnifwhewefhbkbfbnersfbdbfttidetfifdssnwhwfnthdeebdkssbebsridwnnfktnhkskhhbttsenbwbdifttwfhwitbdkeitnthefwisbinwhfsefffrrtfrkhkiksssrrenhdhiwktfkdfhrnwdeebkfrsnhstfiddstekfbdddkiwntbidndkrtetwbthednbtnsesrbesthwbfrdbfwtibirnhteewftfnwredkidstkrdffkfshtwnfrbewbbihfwkdnsiifidiidnrrikiedfindh...

output:

198438
146225
236139
322353
339889
229594
324232
332613
177209
146331
171625
356291
229809
435903
157648
397057
130637
379093
114700
141043
191430
249197
309302
179395
208915
137043
361721
226323
192037
240985
288236
387255
408040
434900
403912
302480
437497
136978
205549
106359
223526
217873
136912...

result:

ok 500000 lines

Test #41:

score: 0
Accepted
time: 2112ms
memory: 834804kb

input:

mnqmbhnqqvmamnbhvkqqvwhklhqqwkvwmhndwcbwlwbqcbvnlchonqlmlkmadbcoqkowbdnkmdbmhqwawhovvdkccnkmvvlovmlqnkhqclacnchlvwdaqmcwqdqwdqolkqklhowmddbcqqqhwqvvqhnnvmcwbcqnokwqbcdqddkwhvdnckdollnblowonhqwvwccklomqbcdbwcwmdmdknclwchqccklbnlwacovbbqwddaqdqmwlkqnodvkalmaaowlolbcamwcoomdnhoawaoqalwvvnncllnwvqnnlkww...

output:

319995
231011
414415
321332
445911
162934
407370
127639
180152
192744
97970
280445
431922
372311
385001
416928
301695
205907
212944
356583
308823
233069
181398
275025
237317
399010
188721
269812
433971
272748
461284
320380
162083
275832
75466
346613
262072
410856
151042
206943
329763
358021
411120
1...

result:

ok 500000 lines

Test #42:

score: 0
Accepted
time: 2147ms
memory: 834624kb

input:

fcacaelhadxkanfukzuchlddcacgthezuguuactngnfhflktekdhlehtlggulagztnzfczccufkgkgzhdcdhzcgxnexulkekdgxketufxknzkhudndddtxlaudagchcffzzkxacazngezngcfgczkhegulgfflanuenfnlulntkkdcdeckzcndalkfxzhehftcagfxnxkuecuezchxgndcnuetldnukndhlukaukhcfdkfdegenxzxkzhlxukahuxlfhzcxlfcgdazlnzuchuadlhnktdfaukaldtfckzzex...

output:

201506
184517
450016
143542
233247
124152
437095
152793
293071
79330
107661
198834
226412
439321
371801
404555
49487
284010
375728
369117
248597
267443
292506
411024
215881
26995
107319
383570
61462
81757
213797
115100
328152
218501
276274
305607
162374
371656
354705
357679
332626
329258
425431
1516...

result:

ok 500000 lines

Test #43:

score: 0
Accepted
time: 2063ms
memory: 834816kb

input:

qozgnokukouobopthpptghuppnkfnkqvvopxptbotqpbfnpgbxzggthvqkwtfhzxfwzkbqpxwfkpgzzphfohpbnxgnggqxqgtxpxzkhfobutufthfwfwowpgxuguopqngvnzvufqpqgxqtwzppwntxtkqxwftwvgnowhowzbfgqbopxwouqhznntuvngopqxfgpnkkufhfuhvbpgtwpzhonzunvfqthgqzhqwzptobzhhxugzqpfzwgoxunhgwptkbtuzookohghnvvfnuhkzntzqpoqwhwguqvqffvhwzgo...

output:

125141
265337
151662
368050
407220
136281
441467
232916
209336
166909
235546
474441
279430
315094
203629
32347
184085
135679
155211
192928
286060
224306
314116
371960
209741
221904
286437
370152
442261
190166
318621
274210
288562
312635
119655
187637
70112
286814
142236
31349
290449
187518
423802
18...

result:

ok 500000 lines

Test #44:

score: 0
Accepted
time: 2099ms
memory: 834652kb

input:

ojqojambjwokomjdkuovwumdbvgxgquqjxjqvgksdomojgsvmwadwsxwavkbjokmvgsgjxxrukgdamrzzqzumaovgqwkjvgobvxazavjsqagqdxadquasvmdkdkmzjkjuqvmbxuzkkvjrbkuomkszzbwqxgzburwodxvgjzxmdzaskbqxgdmskgjdmsmjmudzworoxrdzkxauskmorromjjosoxzdskjxwrxmbjuozxjjjwuojgmkbwmakrmxrjxzbvmxamgsxxjwjszwxqskrjzrgwzksqsdgvvmzwwauzb...

output:

98053
129585
448174
12204
205497
328388
329510
71652
162954
331052
415776
329236
379812
361760
446649
398920
219661
441910
173085
255420
331261
425099
222247
278715
393418
383077
104468
178243
304825
224486
191680
305599
417419
173511
310594
298585
355401
419213
115823
126762
93871
376751
217065
302...

result:

ok 500000 lines

Test #45:

score: 0
Accepted
time: 2063ms
memory: 834580kb

input:

tsgllfklrckavrfeqxhdxklrvcltgafcbtcjxsdgxghvqsxbqlxbasfqgfjfrdtvgllbdjlegkbrxhhfcdabecjqbdqatjgbxadsglxhajlsqaffrgetxkdhderxqaxgbqkxclthssjfgllcetbelhjtfaqgxsxbqxjfhedfvhxkvxrdkcrtdrcgravhbfahhtqgqdtalvfxejlctfghkxechajxajxaxdxescjejqeaqekhgdxetatvbtxcvkxtfjjjdtrjaxevfvqkrkxbgdkrrqgkqqjkrvvcvedlbehk...

output:

132772
135226
444376
231716
305053
208278
70764
208134
270952
227364
263221
356840
100916
328526
222293
142715
271546
120898
414241
123673
30668
318920
134602
301345
296729
400784
400285
403394
81367
354256
173768
281146
196751
119547
400547
317064
285133
385810
67646
184375
270464
465267
263302
300...

result:

ok 500000 lines

Test #46:

score: 0
Accepted
time: 2044ms
memory: 834768kb

input:

tsdijottgydnpitdnpzgajpvcocosbaausnobogajtdsnpbkrganaazvzbvobzdjbcpotdtubtrozzgrjpbunscoppypandinubjibypbakvoryvjiczputvnkpsrdbacaryoapdrkobkaspjsyszznasbtirzrrrujigztgtvkatppjkcgcjazzyibtputzskoosbsnicppvbcjycosttjkviczunvnddotpynznuoipzbskdzdcztyozobnbodjjrkndjraavjtcabcszizcvojaonrrtriarnbyrjtpga...

output:

161775
86316
427525
330971
136969
342433
242445
337495
239318
224081
238674
105184
302846
459858
398875
97727
317921
483756
237277
148917
358054
390137
282332
462713
334860
77677
109955
439057
235670
371203
229876
194793
90629
377283
91429
118217
186478
254163
54249
105449
38432
77891
301172
404197
...

result:

ok 500000 lines

Test #47:

score: 0
Accepted
time: 2030ms
memory: 834624kb

input:

yfxbfpkayvjwsjuokxoqvbucjcjpcnbxwnkfhockguwjgufpxsvhczpnffnzaakbwwfgsjygabsyjbhjngwvgxzsusabgppofpnbpucckwzghjjyxvjooquhshqcpzsgsgnngcsuszsnvxbuzujvazqawgxyucxnzogfagsnbgnbjaxhwggzcwnyczfgazzcfusqcjpzgxwcfavxuyynvuxokvwfxqyhqhokvnkzcbvxvwgnykogznqazfgccwbzjjpkyjjczuyyovfuvpxqshfkoyfbfbfsxgzvoffghhyf...

output:

167285
202432
45286
399875
140653
204667
378543
82191
205836
308435
134268
303026
313567
254232
199605
198560
166565
160046
224733
287179
147751
192740
316996
289109
175389
44019
284398
259304
305680
255884
227840
390082
132329
254831
136507
228750
336909
202136
212845
370016
384694
272885
248570
22...

result:

ok 500000 lines

Test #48:

score: 0
Accepted
time: 2049ms
memory: 834628kb

input:

xzdaapaedchxqmapahtpccaiktyiwgdkydqbpinbgtrdtqyrglxplmlekkrrigqilbamadcykdtpnlcnxmxqzqpzlrhcxqgipigcatnldgckribeelgirernzpzlhmdinlwylrdzqhiqxkadzhzecdridxpwdelwxrylncickpxlxrxwlbwdpykztdpredqaxgyiztbrzhaqmhzztyniicrgdymkcabhqmnyihccmgytphggateitwgdhredhmipmewmhtplpkrpcrtnhbbzmrwmzebznxiyntkipqtwptld...

output:

163634
332662
234826
145321
350787
475466
197263
145198
212328
262287
238955
140008
447853
337010
124236
101363
190022
170182
207120
266701
346590
13589
342893
93788
206976
352879
365907
220822
289273
309685
173595
223901
103118
224943
270450
7335
184245
354993
78867
96410
281751
230631
384584
42890...

result:

ok 500000 lines

Test #49:

score: 0
Accepted
time: 2136ms
memory: 834576kb

input:

mbnwlfjvyylmktlycvwpjakkdxmfmnvwaiakajrjwkkwuptckfawbtnjhvtfrixvuhbhdplidcipnkwcstmvlxriuxauvncadsmuakvflhbtiubkwjydiyadwkiwmvhkfjrdxluisbrsiuicdvjuwsmvlbssrijrtihwxsyxhaclhjsxbfcxklbxkfdukmspybuvlwxmsywlxvktkxiwhmturpwrhtdvkwnbtatvydjdhiwpvmhfspnkcsauuwiyffsruajppxjvtaumckashhfibjhlvfrdwbrmhjmfbaib...

output:

334380
255398
221491
127911
334463
237161
259241
417302
336553
159062
71547
446646
141542
241256
408020
346965
219344
328693
268942
469533
401062
185152
46141
44455
214201
118799
46530
164188
297007
20919
202032
330436
135437
53289
238232
346576
194768
287531
248548
125187
430034
192910
323638
22789...

result:

ok 500000 lines

Test #50:

score: 0
Accepted
time: 2010ms
memory: 834812kb

input:

kroyzcijarizdgmqmuoomcoftfmgcgezyaapoytszuxirymfiqapvzmmgdcfeatmlfykyjomqmikkxslgefscajeoasgfvmrdexkmzsedzszrpgerukcxlmiivzdroygmkpyqrigkgjmmsdgmjayxtmzdjadugqskpvuttzrmpjesoczgsuctltjrqsoultpsiocrvzudkxzmivjmtzlktvdquiotkudckpxftdajqsetijjtqmxreeytgeamcyyjrrszqrifukgjloodaktezjdypsrdaxkdeeoyrfrxrxs...

output:

92402
237132
417056
230769
134405
95482
199472
12203
451338
103403
478446
132886
407726
339605
93460
197525
360998
279162
183702
190456
184190
334556
274463
201430
278396
179604
347476
159701
142975
332602
123674
448884
304713
377817
135715
377450
193860
44460
258815
456057
35098
159708
248613
41328...

result:

ok 500000 lines

Test #51:

score: 0
Accepted
time: 2124ms
memory: 834568kb

input:

dhcowxwikluqulzhkiqqurrwbmjhvjmwpaciazfudvwpqbauobxhjcelftuvcdghtxxbvikfjuhagacreuqdwefjtcicmzbivhtbjgmwzjumuzqrmlizvbcilcpombcipqpzpvgobqefjxqfxwikcgefkkdizorophddhoidevoeupabutckeltvlatckvuojergmdepdeajvofubfgoucqzhpivqfxjgllzbxawfhmjleezdqkiquipmiwmmfuaetjzccxpapvgzcfbzvvkafdlxwxiwuikhpfohgocpbkf...

output:

309630
387791
166637
147843
147826
287580
160202
273354
127726
194516
286625
263173
156606
293189
152665
329915
88406
69171
166838
290717
305853
244294
181071
372641
220492
102703
187656
82977
246200
153755
337544
443973
186372
270757
61592
387650
292539
250512
240434
257129
362800
213094
285269
731...

result:

ok 500000 lines

Test #52:

score: 0
Accepted
time: 2010ms
memory: 834580kb

input:

twcbjagftdkkfjdflnjwusepncuedwpnpknarverzccbwagpubuxkhctxesrjnmdcftmmttvwgjjoruvnhjeljfgxgmnjnkldhrvbebuzjsdcgkvctevuiihuuuwfhdresijnptxfuprmrzpjxcsgclgjmeeptwbomndbitamovzhzrhakmtoutspseebrfeoplzsplttpppbemejpepfjiteiuwrimdjdunhwflkdohzwdgclnrzwwhlowgihnpdxtgostzgnsekdiknwjafeirolwpewwpotdnxhojtaco...

output:

424566
311978
490535
143428
106720
252113
343637
221620
289637
256835
222270
380938
321084
157924
291370
226903
274876
151334
151206
100316
83880
325528
351977
198354
284059
219204
242747
219438
311470
408709
173214
363021
192032
182186
151152
365265
129025
110917
269557
122607
215059
101405
38372
3...

result:

ok 500000 lines

Test #53:

score: 0
Accepted
time: 2049ms
memory: 834640kb

input:

fmcvbauqftqyhkkhyxuenmuznnnuyahgrhytqylbadjbkjrmixgrcktlqldysebefqmwpjfdbeveauxqyxdbuqzwrcliumkcapumacajgdziwnyfrjafzagptvaufedigkyksveucbsewhcjymxeiayiizimbcgpuidmjwujztlyiktrbeiunzwhaanzyacixpcyhkfzvrcgcngtwvtsxexfjgzjxgwczyswhwkbfbljqbyaftsuyfxqvdyvllztpsueblqzpcdxinpkiphikbwaanbdxjnqbtmdruypcyme...

output:

467619
413128
221610
88236
371197
193639
217294
255429
4868
194586
192388
321641
207625
99790
386457
235866
126268
396220
116063
373444
378355
481137
253184
433072
349399
195735
79133
358334
288995
331901
104944
80599
237009
360383
180079
216427
254949
337255
170665
104809
88304
330056
122740
179831...

result:

ok 500000 lines

Test #54:

score: 0
Accepted
time: 2056ms
memory: 834772kb

input:

yqywldzsssmtbzkvoqtlefqgubkfkwnyetdnfvqzlslzoaqdbaxotlhvuqaojxddhakjcmjevfztbzubelgkhbxfcuqtutxxrlkcasbqmwzkakputefodutfvszsbxljngfhpofjezqqbqneojbdeiedudhtjxizdfkqfyrqyurtaebzhpcrgcatdluvuzwhzksecebdybmhdywfdpsdfotlzhzwzwlhgsmhyilyltxefshtwgunogehaulranpdygevgxsmoaftxqydvzqmivvotayltggcrzmefqzknrmg...

output:

202985
210758
191485
63710
315414
298500
86040
421355
379644
368621
324512
407144
277505
227454
150775
419965
384113
185940
226281
384639
355478
267305
467676
231893
28128
204664
425099
375493
160651
421964
243698
172919
87453
237027
55948
468948
349725
121962
299177
139192
261088
347276
160700
3059...

result:

ok 500000 lines

Test #55:

score: 0
Accepted
time: 1625ms
memory: 939840kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

241998
298014
304250
245481
126396
277306
183847
226558
314432
110031
288277
73170
158553
156627
411464
168402
409307
293367
38313
91937
107095
421697
471075
164439
231408
292518
321026
138985
247596
177949
194163
195960
361790
278887
344515
136485
142811
371444
350366
257139
267641
138140
186491
17...

result:

ok 500000 lines

Test #56:

score: 0
Accepted
time: 1647ms
memory: 931468kb

input:

dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...

output:

153395
436230
255617
364702
376699
305866
269700
88584
282288
330084
365697
160190
414568
266402
112428
42840
420290
237565
80004
296431
156822
233110
461603
271290
132997
269436
294601
216383
272034
420884
44694
313673
369862
411342
160852
368966
252493
406412
233450
184514
220037
51367
219218
3638...

result:

ok 500000 lines

Test #57:

score: 0
Accepted
time: 1544ms
memory: 914752kb

input:

hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...

output:

323415
267411
94288
226453
96405
210301
249484
355902
372686
403756
417133
204943
249201
121660
422963
230758
102049
153471
258545
121543
62325
257659
114904
275973
432732
342648
349226
155606
426078
306332
292036
155790
231466
299099
398790
282633
388219
82202
159437
131561
294047
182006
408306
189...

result:

ok 500000 lines

Test #58:

score: 0
Accepted
time: 1777ms
memory: 881256kb

input:

pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp...

output:

419513
224665
236910
301866
355965
294722
54938
349536
297895
255257
351650
68707
296804
296890
191730
298145
275855
339344
273301
164640
250641
275693
320622
414238
344660
274123
423722
345950
302308
158086
90943
203157
357617
176226
417959
270321
214528
248320
388637
367206
197534
384799
115365
36...

result:

ok 500000 lines

Test #59:

score: 0
Accepted
time: 1918ms
memory: 839520kb

input:

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...

output:

284239
247644
86340
215409
157077
347074
124845
369528
283615
395082
366496
223229
267409
169088
189109
310450
340016
296061
289407
299132
316097
199984
143940
278711
249603
221303
68674
364149
262423
130699
338890
358083
269210
175293
180140
306791
89494
354707
444406
415413
196910
343366
329169
31...

result:

ok 500000 lines