QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#350571#8176. Next TTPC 3ucup-team2307#AC ✓547ms65264kbC++204.3kb2024-03-10 20:34:342024-03-10 20:34:34

Judging History

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

  • [2024-03-10 20:34:34]
  • 评测
  • 测评结果:AC
  • 用时:547ms
  • 内存:65264kb
  • [2024-03-10 20:34:34]
  • 提交

answer

#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long ll;
#define int ll

ll euclid(ll a, ll b, ll& x, ll& y)
{
    if (!b) return x = 1, y = 0, a;
    ll d = euclid(b, a%b, y, x);
    return y -= a/b * x, d;
}

int n;
int N;
int A, B;
int X, Y;
vector<int> a, b;
vector<vector<int> > ga;
vector<vector<int> > gb;

void solve()
{
//    cout<<A<<" : ";
//    for (int i : a)
//        cout<<i<<" ";
//    cout<<"\n";
//    cout<<B<<" : ";
//    for (int i : b)
//        cout<<i<<" ";
//    cout<<"\n";

    int g = __gcd(A, B);
    N = A*B/g;

    euclid(A, B, X, Y);

    int CA = (1 - X*A/g)%N;
    CA = (CA + N)%N;
    int CB = X*A/g;
    CB = (CB + N)%N;

//    for (int i : a)
//        for (int j : b)
//            if (i%g == j%g)
//    {
//        int s = CA*i + CB*j;
//        s %= N;
//        cout<<s%A<<" "<<s%B<<" "<<i<<" "<<j<<"\n";
//    }
    ga.resize(g);
    gb.resize(g);
    for (int i : a)
        ga[i%g].pb(i*CA%N);
    for (int i : b)
        gb[i%g].pb(i*CB%N);
    for (int i=0; i<g; i++)
        sort(ga[i].begin(), ga[i].end()), sort(gb[i].begin(), gb[i].end());

//    cout<<"\nA : \n";
//    for (int i=0; i<g; i++)
//    {
//        cout<<i<<" : ";
//        for (int j : ga[i])
//            cout<<j<<" ";
//        cout<<"\n";
//    }
//    cout<<"\nB : \n";
//    for (int i=0; i<g; i++)
//    {
//        cout<<i<<" : ";
//        for (int j : gb[i])
//            cout<<j<<" ";
//        cout<<"\n";
//    }

    int total = 0;
    for (int i=0; i<g; i++)
        total += ga[i].size() * gb[i].size();
    if (total == 0)
    {
        cout<<"-1\n";
        return;
    }

    int rounds = (n-1)/total;
    n -= rounds*total;

    set<array<int, 4> > st;
    /// [pos, i, j1, j2]
    for (int i=0; i<g; i++)
        if (gb[i].size() > 0)
            for (int j1=0; j1<int(ga[i].size()); j1++)
    {
        auto it = lower_bound(gb[i].begin(), gb[i].end(), N-ga[i][j1]);
        int j2 = 0;
        if (it != gb[i].end())
            j2 = it - gb[i].begin();

        st.insert({ (ga[i][j1] + gb[i][j2])%N, i, j1, j2 });
    }

    int cnt = 0;
    int last = 0;
//    cout<<n<<" "<<rounds<<" "<<N<<"\n";
    while (cnt < n)
    {
        auto [p, i, j1, j2] = *st.begin();
//        cout<<p<<" "<<i<<" "<<j1<<" "<<j2<<"\n";
        st.erase(st.begin());
        last = p;
        cnt++;

        j2 = (j2 + 1)%gb[i].size();
        int pnew = (ga[i][j1] + gb[i][j2])%N;
        while (pnew <= p)
            pnew += N;

        st.insert({ pnew, i, j1, j2 });
    }
    cout<<rounds*N+last+1<<"\n";
}

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

//    srand(time(0)*1234);
//    cout<<rand()%10 + 1<<"\n";
//    for (int i=0; i<4; i++)
//    {
//        int s = rand()%3+1;
//        for (int j=0; j<s; j++)
//        {
//            if (rand()%2 == 0)
//                cout<<"TTPC"[i];
//            else
//                cout<<"X";
//        }
//        cout<<"\n";
//    }
//    return 0;

    cin>>n;
    string s[4];
    for (int i=0; i<4; i++)
        cin>>s[i];

//    int n0 = n;
//    for (int pos=0; ; pos++)
//    {
//        if (pos > s[0].size() * s[1].size() * s[2].size() * s[3].size() && n == n0)
//        {
//            cout<<"-1\n";
//            return 0;
//        }
//        if (s[0][pos%s[0].size()] == 'T' && s[1][pos%s[1].size()] == 'T')
//        if (s[2][pos%s[2].size()] == 'P' && s[3][pos%s[3].size()] == 'C')
//        if (--n0 == 0)
//        {
//            cout<<pos+1<<"\n";
//            break;
//        }
//    }
//    return 0;

    int pos = 0;
    for (int i=0; i<int(s[0].size()); i++)
        for (int j=0; j<int(s[1].size()); j++)
    {
        if (s[0][pos%s[0].size()] == 'T' && s[1][pos%s[1].size()] == 'T')
            a.pb(pos);
        pos++;
    }
    A = pos;

    pos = 0;
    for (int i=0; i<int(s[2].size()); i++)
        for (int j=0; j<int(s[3].size()); j++)
    {
        if (s[2][pos%s[2].size()] == 'P' && s[3][pos%s[3].size()] == 'C')
            b.pb(pos);
        pos++;
    }
    B = pos;

    solve();
}

/*
1522
TATATTTATTATTTA
ATATTTATATATT
PAPAPPAPAPPAPAPAP
CCDCCDCDCCC
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3612kb

input:

3
TTPC
TLE
P
AC

output:

34

result:

ok "34"

Test #2:

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

input:

670055
TF
OITFKONTO
GFPPNPWTZP
CCZFB

output:

-1

result:

ok "-1"

Test #3:

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

input:

910359
TOKYO
TECH
PROGRAMMING
CONTEST

output:

1401951321

result:

ok "1401951321"

Test #4:

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

input:

518530
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

518530

result:

ok "518530"

Test #5:

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

input:

252288
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

252288

result:

ok "252288"

Test #6:

score: 0
Accepted
time: 60ms
memory: 17624kb

input:

1000000
TTJLTTPNTTQNTTBJTTHZTTJSTTRUTTVWTTJXTTMGTTZHTTRWTTNHTTDWTTMGTTIDTTSYTTPPTTGQTTXYTTOETTYMTTZATTAOTTJNTTHHTTYLTTJBTTLLTTNNTTCITTCBTTDOTTNGTTPZTTUETTFHTTODTTCETTKXTTGUTTZSTTECTTFSTTHOTTESTTNQTTHJTTDPTTFKTTCMTTNMTTGRTTYPTTKQTTYCTTUITTYCTTWWTTZDTTCPTTRSTTLFTTPKTTEXTTUPTTXWTTDATTVUTTLCTTEGTTOLTTRI...

output:

-1

result:

ok "-1"

Test #7:

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

input:

359869
TTXTTTYTTTITTTHTTTRTTTOTTTETTTKTTTZTTTYTTTBTTTUTTTBTTTJTTTDTTTYTTTJTTTKTTTYTTTLTTTATTTLTTTITTTHTTTUTTTMTTTDTTTITTTPTTTITTTCTTTCTTTRTTTZTTTVTTTETTTGTTTNTTTUTTTGTTTYTTTJTTTKTTTQTTTSTTTPTTTWTTTPTTTZTTTETTTJTTTVTTTGTTTUTTTBTTTCTTTCTTTXTTTWTTTETTTFTTTGTTTDTTTATTTCTTTITTTWTTTWTTTITTTSTTTRTTTYTTTETT...

output:

-1

result:

ok "-1"

Test #8:

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

input:

856943
QNTJMTFRTNDTXOTJRTNNTCXTZNTQMTSBTMRTDMTMOTEATOXTHWTOJTQQTLITKRTNSTNITSMTRVTLLTKBTSATYVTHXTEZTRXTPNTEQTQDTVZTMOTJVTESTRQTBBTAXTMNTUBTULTFPTXQTIBTCMTXXTMZTOWTYVTPVTDSTMWTZDTGQTVMTRFTKDTQITKSTCQTOPTSRTJWTFCTEFTCKTISTELTWGTHOTODTQHTLETRCTSHTJITQGTSUTFDTFZTFYTBJTKNTMHTHWTOZTARTZGTQETRITMSTXVTZATKJ...

output:

-1

result:

ok "-1"

Test #9:

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

input:

12
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

-1

result:

ok "-1"

Test #10:

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

input:

1000000
WTTTNTTTLTTTZTTTWTTTKTTTDTTTATTTNTTTMTTTZTTTHTTTVTTTVTTTITTTSTTTNTTTSTTTPTTTVTTTWTTTJTTTRTTTQTTTFTTTQTTTMTTTMTTTYTTTWTTTLTTTMTTTNTTTCTTTWTTTSTTTVTTTDTTTUTTTLTTTCTTTCTTTZTTTQTTTQTTTWTTTDTTTQTTTZTTTUTTTQTTTITTTYTTTATTTATTTGTTTITTTWTTTYTTTYTTTFTTTHTTTPTTTDTTTWTTTRTTTLTTTNTTTFTTTNTTTNTTTCTTTBTTT...

output:

-1

result:

ok "-1"

Test #11:

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

input:

506084
TPTGTATITNTJTPTBTZTDTRTVTJTVTSTFTWTNTATYTKTJTCTBTPTPTJTSTQTGTPTKTYTBTMTXTVTMTUTFTPTRTYTVTFTATCTLTITVTUTNTATCTJTYTOTOTMTKTBTMTMTKTQTWTBTHTITATUTYTNTETRTYTWTDTLTCTPTGTKTMTETGTCTWTMTNTKTMTATDTQTWTWTPTMTRTYTQTMTJTCTGTXTDTUTSTBTYTFTKTGTYTHTNTOTOTXTQTITITSTGTUTMTNTPTETJTDTJTRTBTKTXTCTSTRTZTSTWTUTJT...

output:

-1

result:

ok "-1"

Test #12:

score: 0
Accepted
time: 70ms
memory: 24968kb

input:

95378
JTTGTTYTTMTTFTTSTTUTTBTTNTTSTTVTTKTTYTTUTTITTFTTYTTKTTSTTSTTATTMTTQTTMTTLTTRTTWTTQTTLTTWTTPTTYTTGTTPTTNTTUTTRTTKTTWTTHTTVTTGTTMTTQTTUTTXTTCTTZTTUTTBTTDTTPTTJTTETTZTTNTTOTTKTTITTOTTGTTSTTQTTVTTZTTATTBTTATTOTTYTTZTTZTTZTTDTTPTTHTTMTTDTTLTTNTTNTTITTETTRTTYTTOTTWTTZTTGTTGTTRTTXTTKTTGTTVTTDTTSTTWTT...

output:

27097032

result:

ok "27097032"

Test #13:

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

input:

12
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

10636

result:

ok "10636"

Test #14:

score: 0
Accepted
time: 234ms
memory: 35504kb

input:

1000000
LTTTWTTTLTTTWTTTITTTQTTTWTTTKTTTSTTTGTTTLTTTHTTTXTTTFTTTYTTTPTTTBTTTFTTTYTTTBTTTZTTTYTTTHTTTNTTTVTTTKTTTMTTTITTTQTTTYTTTYTTTZTTTGTTTBTTTLTTTMTTTJTTTYTTTVTTTITTTYTTTRTTTCTTTHTTTRTTTUTTTWTTTQTTTITTTVTTTWTTTMTTTRTTTFTTTITTTYTTTETTTFTTTHTTTOTTTYTTTOTTTXTTTFTTTLTTTRTTTFTTTGTTTETTTBTTTVTTTETTTWTTT...

output:

907999396

result:

ok "907999396"

Test #15:

score: 0
Accepted
time: 146ms
memory: 22128kb

input:

713716
BTTCTTOTTZTTWTTOTTHTTITTITTITTWTTGTTFTTJTTMTTWTTRTTGTTFTTLTTJTTDTTWTTITTRTTMTTQTTDTTJTTWTTHTTKTTRTTQTTSTTETTKTTYTTRTTSTTGTTQTTYTTOTTCTTLTTSTTOTTETTUTTRTTETTLTTQTTYTTYTTITTUTTXTTZTTXTTJTTQTTWTTWTTMTTRTTATTNTTSTTJTTKTTGTTHTTVTTSTTRTTXTTMTTUTTNTTPTTQTTHTTJTTHTTETTQTTGTTGTTATTITTATTBTTQTTWTTHTTWT...

output:

563121569

result:

ok "563121569"

Test #16:

score: 0
Accepted
time: 73ms
memory: 24708kb

input:

11522
TXTTTHTTTVTTTOTTTFTTTZTTTKTTTZTTTJTTTDTTTPTTTRTTTHTTTOTTTXTTTCTTTWTTTNTTTDTTTSTTTWTTTCTTTHTTTXTTTFTTTSTTTOTTTHTTTCTTTWTTTUTTTXTTTSTTTZTTTXTTTLTTTETTTKTTTLTTTXTTTLTTTVTTTATTTLTTTHTTTDTTTITTTQTTTLTTTKTTTETTTATTTHTTTYTTTOTTTDTTTSTTTCTTTVTTTRTTTITTTITTTMTTTPTTTNTTTJTTTXTTTKTTTXTTTGTTTCTTTUTTTCTTTW...

output:

11152921

result:

ok "11152921"

Test #17:

score: 0
Accepted
time: 25ms
memory: 11512kb

input:

1000000
YHTTKJTTFNTTMITTNWTTOETTWJTTCFTTIRTTVJTTJMTTHOTTBITTLXTTRLTTVLTTOFTTMYTTOGTTAYTTVLTTCRTTENTTLKTTKETTXPTTSFTTCZTTGLTTJZTTGFTTOYTTSFTTLHTTNMTTANTTSGTTKKTTXETTABTTSBTTLLTTQOTTNDTTWATTERTTAUTTMWTTISTTASTTZJTTPXTTONTTVGTTEATTVBTTXGTTSITTPNTTLITTLQTTHVTTKOTTQGTTVLTTDQTTLHTTJETTWFTTDFTTIQTTIETTKHTT...

output:

-1

result:

ok "-1"

Test #18:

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

input:

1000000
TTXZTTYMTTVYTTASTTUPTTABTTLRTTEPTTQPTTMKTTCOTTPKTTPGTTSITTDRTTQSTTCPTTXWTTXBTTJDTTZNTTIPTTIOTTKJTTQITTEJTTJRTTAQTTIBTTAETTUOTTUETTDRTTNFTTPZTTYHTTMZTTQDTTCDTTVDTTHNTTXKTTUPTTFPTTYFTTIUTTUBTTJATTYFTTJWTTGUTTPXTTIPTTHSTTVATTHWTTWZTTMSTTJRTTYWTTSRTTUPTTDQTTKJTTIUTTVBTTNOTTBGTTINTTAMTTRNTTAXTTDW...

output:

-1

result:

ok "-1"

Test #19:

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

input:

367325
TSITTGUTTPJTTVDTTSSTTIJTTZATTKGTTPATTCKTTBWTTYKTTRUTTMOTTUQTTEDTTFLTTYOTTRITTYVTTGXTTVJTTWPTTVDTTAFTTSOTTJZTTDKTTBUTTSPTTFSTTHXTTKDTTVJTTCUTTALTTRHTTAJTTZHTTZDTTAOTTJVTTLKTTSXTTFITTDPTTGSTTXRTTEITTOQTTEPTTVCTTSITTJUTTPXTTZWTTPKTTUZTTLWTTYBTTFETTJYTTLDTTGSTTIITTKFTTKHTTUGTTVPTTXNTTFCTTLZTTYXTT...

output:

-1

result:

ok "-1"

Test #20:

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

input:

1000000
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

output:

-1

result:

ok "-1"

Test #21:

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

input:

1000000
NTTNWTTJFTTLMTTSATTRWTTEXTTBETTPBTTEBTTXPTTUDTTWVTTWMTTWZTTCATTSBTTKBTTEKTTNHTTPBTTCATTVITTPJTTCYTTAPTTVLTTDHTTVQTTJUTTCFTTLXTTODTTFMTTXRTTRLTTNPTTVNTTYMTTOXTTDUTTVZTTSDTTMPTTYCTTLKTTFATTCETTUFTTGDTTKVTTGYTTVATTYZTTQRTTWQTTMGTTFXTTLDTTXRTTGFTTPLTTQQTTOVTTEOTTJSTTXSTTQKTTRVTTWZTTKXTTRBTTRRTTM...

output:

-1

result:

ok "-1"

Test #22:

score: 0
Accepted
time: 280ms
memory: 36572kb

input:

1000000
DTTTATTTBTTTUTTTUTTTNTTTDTTTITTTATTTRTTTFTTTJTTTZTTTDTTTRTTTETTTWTTTCTTTHTTTFTTTBTTTJTTTUTTTWTTTJTTTCTTTETTTYTTTHTTTWTTTETTTWTTTCTTTZTTTWTTTYTTTKTTTRTTTLTTTVTTTETTTOTTTDTTTPTTTLTTTMTTTWTTTCTTTXTTTDTTTPTTTVTTTFTTTATTTKTTTWTTTOTTTUTTTPTTTZTTTMTTTETTTWTTTRTTTPTTTRTTTHTTTFTTTYTTTRTTTKTTTJTTTETTT...

output:

452272320

result:

ok "452272320"

Test #23:

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

input:

1000000
CTITITNTHTTTBTZTNTMTFTCTZTJTRTBTUTPTWTWTNTUTMTUTETITITATKTMTRTPTVTXTPTHTNTGTSTMTUTWTKTWTITBTCTHTFTWTDTHTWTBTSTNTNTCTGTVTVTVTMTVTITWTJTRTYTETMTKTFTGTPTXTHTGTXTVTPTHTKTSTMTUTMTLTCTDTHTGTUTVTPTYTQTOTBTMTZTZTWTOTFTGTATBTFTQTNTPTGTLTYTKTPTCTFTATSTDTQTBTXTATVTRTGTITSTITDTKTPTNTKTKTBTATWTKTRTBTMTDT...

output:

975999035

result:

ok "975999035"

Test #24:

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

input:

11
WHLKKWTICHLBXNJKGGFGQLTLEHQUIYKLQZVWFFAVIDVCVJHUSJTYQTIJECJNQCLEJNZPKMPVBPKZHENYFXCSXZEUVJAFLMWIZPDWQDNRPBIGBTMNQKQOGJFEQYDHQYIBZXHBMWTJZJJWYWCQLEDVCUVCDMPEWOXGRADJQGRANTLNMTMHALLKTZYLFZPOPTOGKSTJBGJEGKBONVGJUSQDPBTECDEDGHAZCZOMZBMXVVTNMLPPLBVHLZXASGFRAIBAULIYDEHASZNGQDUBZCRTZYIXBDYWAGOIGCOAAPPON...

output:

6385324

result:

ok "6385324"

Test #25:

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

input:

14
UCBNFDDWTZCYVRYRQCEWBIVBQADDGNHJDJIPZMHCDWLAJDEJXIJIQTUOSNEUONNQIMOCRLSQXBPHDPQYBJLRQMANSCKNMCORGLIGAVBZQWQJKZFYDARHAZWYQOWYBKTWYESJAXNWDEEITRMCAPWAVVQQCCKQBSIPEGYZQXHYLWFOIYQBFESGUABSXJTOLACYNAUGFXJIBICEDPFLCUGQPDVZVGXRBKSHIDMFGEAAAPVCEBZJIZJQJTXQEPLZXFUQYWWPBQIDQDAXCGSBJNMBVOQTPWMTVVIZZTZZNOLBN...

output:

3768074

result:

ok "3768074"

Test #26:

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

input:

621991
PHSWLBLHWDNEUDLSMTKUPSYGZVVTXZVDFLIJERLKFTKBCPATGFTPXCYHAHBCPCFDBHHJMGDDIHSCNHNJMDPGMXXBSVCQMWALQNVOVWESQDBUTDPUMOUFTIHPQPYFUSWARGPFZFVUNNRUBOTHERYQVKCODQOMKXOAKSQEOVEXDNCHYNIVKEJJVJSZSSCQKXDWVMSWEXXKOYMQZSGCLTFQIRZMVVXXPJSGDZWRZYIJOLGGZCAHKUGSMEOHLJZKYZGIEHQDAIGBAPTJQIXUCMZDTDPAWACGFJWUWPRVS...

output:

285656877012

result:

ok "285656877012"

Test #27:

score: 0
Accepted
time: 16ms
memory: 3760kb

input:

681065
BPEIWKXAPGASDFYOVYWFZIFZJCTSZOHAXWADMHJQZAVYZDMYUEBGJMPIFDQIHSWKJZKXDJGLUMRGBSVFLDRWGSDWDXBBNMQFDJLVGSEHCFWYINVJGCGIOXIFVVQWYPVHSMOTSCJLYFNHBWNZHHYBGZKRZBPAYJFRZOICJOOBOVXGEIUXMGEUVYSFUPITQGHGFUPHCPJLBRRXUBLQRQVDSFHCYODJXQJZJKDZWEHLQRJIONJGGDJHXJUTJSXYKXHCAXRLXVRQZNXNZWMUCVXQLUPCIILGAXCDZMQHV...

output:

640624135227

result:

ok "640624135227"

Test #28:

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

input:

36576
IRMNJPGAQZMFDZACMEVLGQSDJLXFAZDQRXSIDMSYFRDHZVQRDZBVXMMMGAPYFJBSHVDQVASDYGLCWKADPAEFHBAXIZWXSMNJYEKSKKNAKESFUQEDOLDZYOIPVSEXKVJPHMZGXOYLWDNJBPRIISSWDYPGICCCERHMHCRYNZFPMYXXUPMAWPUIVGKHCJIQBQPPEDZDXZNUFQOCKZRSRAKCMVMSCBVFAJXUAVFZVUFERGHDXFMHUBOLXCJCNSHIEHNBWJYKOEUTXMKBPGQKWQZRLXYDFTCWLBBIYBFTYS...

output:

1631600024900756

result:

ok "1631600024900756"

Test #29:

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

input:

870492
ADNCVEKYFEDDSBIFJBFNAIHWGFWXLWYGROVNMWHJPTPCHMMFBYAXZFOUBOOCXQLEHLQCHJVJVGSMNPFNHHWOJBMDEASWBBALXBSFXXFVLIBEUMXGSNSKLEKOQGYHRLENMRRKNIURCFVQSXLNJJJNAYYSPFCILXCGCRFCBZDQAHKACQNFDSNKBFYDROLJPDKWZVLAJCUVIFXEHVGKXXKDKOOXFHKSARJMVWXGUYWUCDZOXNFHMYPJOECWNOXQBBWDOSSYUMCMZWSNSXMCBXNZHISVKLDJXABDKOVQH...

output:

2249019642670992

result:

ok "2249019642670992"

Test #30:

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

input:

699084
DMSSXMPXNYSUSGIHNSJDADZYKFGERGBHUVBJQLNZPBQSVFKZNAEGQJCGBAQVBMCFOWAZEJOEPIYSAKEEIDKVBMHVZGUWIGWGHDWMRCXDVAAWHSVMBCVCFLBMMKEJMMUSGWKXZXLKRQVDLUGLKBXCKOQLUOAOXMKUCIMNYVITJYFQPYCAISGUXPPXJJXBWRHCUQSBOXFMZDHUOMIRODDJVQIINHHSDKLDZLZOAOQXVJGCIYWVFLNLRQYLKSDZJVQNNRILUZISWYYKYGESNBPIWDRQKAFVZMUJZKJAC...

output:

2238903359576856

result:

ok "2238903359576856"

Test #31:

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

input:

1
YBBQHUMUHPCOXASQLWBRXUPEORMGCOFIVNDFSNGFJRWRYPACZSVJGKMMLJRUVOVXDVPAFCFXOAXMDGNPCXLZCHGBFCVYYOBEEOIFSNGFRINXEXUGSWOIZUJFFBVOEXPRSOIONPWYRQDKAHUKOVUJKXZCSLVIBWISZLDMXXICKVSEUALMNDLHNHMFBGXSSXJPBEPRBLJXBUIUGEZGUEHNEQAMENIDVJJYHZCPRFUKLRYFGPVYRDIQSEKKEZFZGQUFPSHQLZFMQVQXOMHDRXFMFOFVLWBMNJPIAFYWMFSQDQ...

output:

42737103431

result:

ok "42737103431"

Test #32:

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

input:

1000000
MJIRPODODXHXEGOQKDVQXFKONESHJFWAKFOURAPYCPHRCLUDISEFAOAWWMINVAMUFUWJEWCWYZJDPAVQJPULSSKPNLFHXLNXCYDYCJAYBIHSEHVCWBFXPFQVVRDGMCLPQQSRXDMEOGXPYNXHFIXDVXZRCYOEHUVSEIURMHSPILBWKCZFEYVGZGJAPUMIJIUGQJHESQMLXYKPHHQNGYMVOLJUGLLIWBNPYJMKVLUSLNFWAHFMENNLIDDELSWTKPWRSDXQDSDPAPQSWQLKXODALELSLZSELOQLXKEW...

output:

3392859102435868

result:

ok "3392859102435868"

Test #33:

score: 0
Accepted
time: 149ms
memory: 19600kb

input:

350208
TLTHTUTTTIECTJTTTTNTTTTDTZTHJXSZTVTTTATTJHTKTVDTTXTTTTTTBATTTTTTXTTKTTTTKTTDTTTTNTLYXTTTTTTTFJTTVTTTCTOTZNWKTRPTKTEKETTTTVRTVWCUTTTKDZWVPVMMTTTISJTTTQTTTETTTTTMTTTTRTTITTTLTTMVTTMTTKQTTTWTTTBTWTIGTCTZTTTTTTNVTYUTTTTTTIOVTTHITTSTNZTTTOTTRHTTTTDHTTTUVPWTTTTTUTTTHMLFWNTQTTTFHTPTTRFITNDFTJNCKESTI...

output:

1248723

result:

ok "1248723"

Test #34:

score: 0
Accepted
time: 547ms
memory: 57944kb

input:

343585
TRTTTTTRTETTTTQTTTTAOTTTTWTTSTHTXSTLTTSITTTDTTTHTGTTTTTTTTTBTTTTTTCTVTTTTNTTTZTTTTTNTTTUTZTMTVJTTFTDTTTTTTTYLTTTTNXTTTETMTTTTTOTTTTTTTTBTPTTTTXVWTTLTITINTTTTTZTTTATTTPUTTTTTTTOTTTTTTTTTSHTLTTTTTTTTTTTTTTTTTPXTTTTYFTTAYTPZETTTFTHTAOTTTTTTTTTTTRTTOTTTTTKTTTTTTTTATTTTXTTSTTTTTTTTTTOTTTRTTTTTLTTL...

output:

1468088

result:

ok "1468088"

Test #35:

score: 0
Accepted
time: 314ms
memory: 49040kb

input:

1
TTTTTTTTTTTTTTTTTTTTTTTTTTTQTTTTSTTTTTTOTTTTTTTTTTTTTTUTTITBTTTTTTTSTTTTTTGTTTTTTQTTTTTTTTTTTTTTTTITTTTTTTTTTTTTTRTTTTTTTTTTTFTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTMTTTTTTTTTTTMTTYTTTTTSTETTTTTTTTTSTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTETTTKTTTTTTTTTTTTSTTTTTTTOTTTTTTTT...

output:

1

result:

ok "1"

Test #36:

score: 0
Accepted
time: 278ms
memory: 21308kb

input:

1000000
IHTTXXQVDVKETTPPWTTLLTYATTBCETCLTSEIXTTGTTJTTXBTXTTVTTTTIFYTASPDBTWVHTMVBTLTHTTQWTTTZAIATTDTTTTHGJTSTEZVTYPTTXTTTOLWTEFTEIHUATPTTQWTBVYTTCTVXZTDZTTTZZTMULPUSATTTITTEWFXTZNPTETDTLTUTNTDCTPLITDTYMWCTJTHZTTFTHJNATMBSDJTQTZTYDWFTTQAJTOKTTQKTTCUVTTAVXXUTRTULOTTTUUUZMRMITTTXHTTGTTTOBUTKTMTBPHTTTTT...

output:

4223102

result:

ok "4223102"

Test #37:

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

input:

345046
YHNYBBTUCRWJTYITEQDYYTEHAGBWBETO
KT
JNFETZVTCUHLGMPNGVMWZZFIXNFGUVSSEBSKMZUJSCFVCDTWPCPBPSPYTKLDOAOLRJJLESLGLOVQLDJMHYSQACKIMABZVTMLCPCAQEXDTJFBLNYCNJWJDDSAXEEICBXVYQGYBPXVNFCHIIXKUMMQXOEMNDYBGNGEJJCQIHHLYFUIZNJHUGSRKVXFRRTEYTCLVWTOSBNFBLZPSSPUFGMMLVYTADJGUGJYGKQCHOCNIZCPDNFLFVNBAHTGJAFKGPJLL...

output:

3140057680

result:

ok "3140057680"

Test #38:

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

input:

990105
T
T
FTBLKZUGHSNFTKEUEFRULGLILYCTYPKXZJGPQTUUYNZEOVXWTHZDKUMINCMNMZVQDLVVFLKBBFAWUQRFJLHKBRZFNKDOBNVKWQEKCBFXCUJGEGTUPKJHGQEDFEVXTNVUTJEMIIYWJMHVXDABJPUAXZLHXFRMKFMOFUPKTNELPOGHIABOSMCKQPQHEWKCKGGXTAXMAGXSCKXBMHSVMORIDRLLXWCUCYTUIROUNUNBIDNAXBQSDYWNVTYKRPWEJDWJRIIACNIUPXJUKAMPAVULCAKXGVEAXYTDT...

output:

866652802

result:

ok "866652802"

Test #39:

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

input:

749386
DUGGXTKUUHOZRLDPEVBNGEZUQPUDQFGHYQNMPMJRMPSFVFLECMGXNFDPQZIQCIUDUBNVIRAMTDMDDQRMJZEMKVEDQWTJIUUQOMHGEQETZUWIIOXPRUMAYLEGQDNRATLWXLYSYWMNOCBPITAKFYBMXDPOSHNZIEOWXCWDUNBSPNVONUBUPANOITVOIRJNEXUIWWLJJNJAMIMHLFMVHISWXDXNAYGTTKXRNEYTLKBKDULTHDBMSLTRHTAYRCGCCTPZEYHLYEWOFNQXOOIOGSHANWZGGEZJPVNJDFJVS...

output:

5798101706

result:

ok "5798101706"

Test #40:

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

input:

866202
UXTLRNTHESMXDHIJJQMRBZTFUVPADFGJWOEYLEDDHYCBJXXCHWTUWBDSKUDMFBHOQEFTPECMBFTSJKAPNTJLWSJCTHDKPLEKAZGZBXFZBNURENZXPJDSGMCTLAJNWKPZRWNDNJUAEOBZLYWFUSDCEVVADQZMVZVMFWNBBMSGOTDHGVOPBFLEYIQEKHOMADATVMIKFJUSNUCMZKFTTLQDNGCFNXYVMHEEFQUVPCCGKPXBXDPUVHWPYVGMOBAQDANKOWKTDATEPPINMNRQLRWPIJPHMJEMRINZZDDQI...

output:

23920713675

result:

ok "23920713675"

Test #41:

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

input:

610175
LMSBGVAMNSLAUVFWKDZOQFMBUDYXLKPRYOKNBWNPNNGNOMHAJZKXKIURGJQYZFOAKUAAMOENJFADLHXRLAXCXZEMUFRJAFDOGNIYZIQLPFKJGRJZUHSWECQRVACLYXDBRZAJRANHCFCRWPXRVNJSYCXBBMSXFSIRSBNBVGNAQCPQNLZMUIHYKJYWCDHHKANZUXWWCAVPSVSLEJSCCUAUEORRMADXIAIXUSLEUQRUDGHXIPDVPEZRADAXXVENMHGSOXPKKZGKNNCVSKGCKSZLZWVJIHMLAZXFVRUQH...

output:

-1

result:

ok "-1"

Test #42:

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

input:

756402
XSCBCBAPCCEYMGHJSUVDLMSSKUWBEQWFBWGEORUIKDAEKLGMAZRZJSARWQJNJGADAUVAJCMJJLHUWUCRDXSLBIGARBXRBONWZYPFXLNLUCLIIJMWVLAVXPBSJHCBXAPHGGIQDSGKOXJCALHCALARIKDNYPSHCKIESGSMULRBRJSAMFPOYVZOPNAYPCGBHVVWDDMNOUXWAFDVXORXMAYPYZAYUCDFLGKJERDJZZZDAVBDQPBOXEWUBNECAPJJXWKHHRIQVQRJVQOPJDAUYLNLPZDMYKRFGFLIMGYNO...

output:

-1

result:

ok "-1"

Test #43:

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

input:

919744
USJEGOJVYQVJIGPJCGEIMWJIPVBISYGBFEQXUFEIICJUNOLOKGNFJODMSRFRRKJXLJWQBPFFVJIHAWXZEWUJDXUHYEJHODCQFHUHZGIRKBJDPHDZARJZZZXULFVUJCWAKDEHWQIZDGKXEWIOIXXDRSAYJPVFVEDSFDVGHNWYRFLWHBWDDYBCRYDWWWQGCPOXLCQEUYXGNLOMXWPYQAZCMFGDZYZNKUKGWCMPDGZKQDQPNBOLRDPQUWMFOCNRRLXUDESUCDHQSPLXCGXHRXVFWQCPCLXDPJDIXQASG...

output:

-1

result:

ok "-1"

Test #44:

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

input:

178094
HZWHPASQGCMRKYNSKGRXRJSSNSOLLIGZEENWSGMGLOTSKUELOFMOEHRAOSOOMPTEYRNLCOKTZGMOORBSCTKEPBRSMMVCSIYDCLHYRNRBMNIZWAPEBXANQGFDCIUWYXXMSOTGLBYBUWPOZJMSRSBVYMUKJECRZOZPSILNUOTXNISNQYCGQVYIEHNLLLKLEWONDQLRTGQNTFIPEJNYTKFCOZNCCQBGXTABPJWFJGGUUFRJKDMUBXQWWIMOZMNMMURSTVIKZFNSTJFUJVUVGJVOWCZDNJQQIDCDZXFOY...

output:

101851007373

result:

ok "101851007373"

Test #45:

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

input:

39543
AQPXLJNTTQLCKBXEYORIHKWPLZLRDSIOGTQLDQRLOZKCNFOAJSVRSWQZRJPKLJPUNGYTUWNRXBMDONTILKYKYLGNKGBFTTOKQWYDDULORMCAEEIDPJLBHKHLULTTRQLOPONMWUFZWSRFHHHNVKUVMRNALCTKSJUPC
SLUDMGAUPMFSUYJLEATOTPVLJIRRVFXXUVPKYUINMHEUXHLHCSAAFCJUSMPLUOABQUCZPUIDIDDSCDDOGALBXTVHZONATVYSYOIQWAIZFGPBLCBUAMAXTRQQGGMJAGETSVBM...

output:

10428475413

result:

ok "10428475413"

Test #46:

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

input:

513749
FTFAAVVEXZFCJHJLRTXHZBMFWRZZJFGCAFKJCRLJGXNCGNWTHEIMSNFDNREGTRKBYPBQFOGHIIXXQHALXTQFKQUVQJDUSNQFEUENDGMMHKTRFHQTYCAOWJWVNCVYIBKHXMAGDXXIOARCQZZFMRKPRYYPOVFSPCRCBNEPIVSFLMCRAFFXTAVBLQDFXWCFIFSMPOHRZPVAWZFXKSMQNXDIDCVBKKATUEJFUIENPGRCLJMBUJADEUAYAZPACDTKUUMUKMXKEAKJMFDBQWMKZSDEPZIPWRKKOJQONPKCZ...

output:

297904535175

result:

ok "297904535175"

Test #47:

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

input:

323568
HPCBEXJKHBICZDFYOPUZNIQSKEYEYGWNWNOUBKXZMPPYMIGWASAESQDCQELHRDQZHDNVBJVAOPSRCBQIYPLSQJXMFZXSYESFHXPXIABQLIKDZZKTFXEOIFWLJXHPKXUJGGUQLMRAOBQDQRKHQFMOUAVFBCIDFHCMRREKMXDJRYBFJNDDQCZAJRLVMZFEMFVYKOSIWAXUHSKEHKONJGSOUBLAAEAMBOGYVIDHBTPDPGJKWMBNNOEUCPWLEBHSHLISZMLSNKQQPIMJKMWIGINMCXBNJHWIJKFQAJPYQ...

output:

195139073323688

result:

ok "195139073323688"

Test #48:

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

input:

999097
JMLDZBUFHJCMCBZYSICXVXSAMWHRXBKGLRINYIVJFMREUNGWXGJHXJCRIBDPCCYBPSNUAGERMXJHRVPLHVGFGBZBXEDZZXYVXNQRLDNOLJMHALPKLOWTZVTYVDAVSJXGDAQNSGHHMNEAXBKBVCVUMAPUUJKLUQIYVMIZDGOCWOAFXNRQNSJNCHLHMJGBQBFCQMHFNKUABXPNEINEZMWCG
XKZOCCLIDPCRBKZUZVWNYHEKNEOUEJMSRFYCLLKPBPSSCXXZIXQQQOGYVDYXJOGPPIROKXONZLBKUJR...

output:

-1

result:

ok "-1"

Test #49:

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

input:

655651
CIXDKABYGNOFBFJPZMQHEVRRUGCIVXAADZKVXLGXRKWSOKESCXMGJYRHAVKRHGNWRQIUWRHHQMYKULBFOEVUDSIGGNVABJFXWQOTDUSRDEYQZOHNPKJEZCIOJIBLSYKOXCSYRBPNKWZZBIRZLRBVKJXFXQUQRPCQKGMOKOBTYYQWKJILUCZQLIYLLWDOLRZEQUEDYHQLXSXCBWRFMZHPUWPRMSHIROBBEVXRSFCWOUULSZWRGHJKSKWMIISEIGYMXQHKKBCKGIVWJOHWQPVUFGNJQUYJXHCKYSYCW...

output:

2634424714338390

result:

ok "2634424714338390"

Test #50:

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

input:

622657
BOEINRYGECRHNYPWZVYUZBIHUFQESGGOBLRUGOIDJEJZFSANFJRXLCKZPVBJCARZEZBXVEFSBPIJSJWXEMWDXOXPPHDLVQKKJDDKCSKNNHFASMSBOHOMABBBNZKSYIASGIUEWLMLVOXDFOFSIVOGWFYFMDEXJANBURYSWVBXZHRIYQLVPDMNKJQKNJRXCSMSOOIXELGDLKHSPVVLDHJIZKYAQRXHVJBDUNBUCIPPBSXXZLIVJRLSIPFGRYJOSEXQJIAYWAAJDPQISAVYBZFKAPWJFBGJXVQVVIMSW...

output:

-1

result:

ok "-1"

Test #51:

score: 0
Accepted
time: 14ms
memory: 3708kb

input:

1000000
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTT
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

output:

1000000

result:

ok "1000000"

Test #52:

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

input:

1000000
GTTTQTTTNTTTXTTTQTTTLTTTZTTTBTTTKTTTBTTTDTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
PERYPSRBPGFUPTIAPBWNPVLLPJCYPGTHPSHL
CCCCCCCCCCCCCCCCCCCCCCCCCCCC

output:

-1

result:

ok "-1"

Test #53:

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

input:

929626
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
ATILTXVTOBTSXTNVTHUTUSTCWTBGTKSTWMTOJTVPTS
PWPPAPPKPPQPPVP
CCCCCCCCCCCCCCCCCCCCCCCCCCC

output:

-1

result:

ok "-1"

Test #54:

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

input:

1000000
TTTTTTTTTTTTTTTTTTTT
MTTMOTTULTTOITTWJTTAOTTGMTTBXTTB
PFUPPKTPPOWPPLZPPNOPPKGPPLIPPGBPPQGP
CCCCCCCCCCCCCCCCCCCCCCCCCCCC

output:

-1

result:

ok "-1"

Test #55:

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

input:

5633
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TULTWITPZTXJTXQTGFTPDTHVTKB
XPPIPPTPPVPPOPPIPPAPPLPPPPPTPPWPPMPPEPPKPPHPP
CCCCCCCCCCCCCCCCCCCCC

output:

253465

result:

ok "253465"

Test #56:

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

input:

1000000
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TQYFTPAZTCWHTSHRTWKVTTBCTVTJTNVU
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
BCCCXCCCXCCCWCCCPCCC

output:

15999995

result:

ok "15999995"

Test #57:

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

input:

1000000
ZBXHCHSZMLVPLQGGTJDROEZBFDEQ
DKDOKMUWXYLODPABTHGCFRYICACVVDMICSOHBUBPHUWOI
CIBJMYEHQHLLWFYSPJJCGTDAYNNWUAISUYUZEDOGRCD
ANOJKQAXPJTNDGSHCQSDSAFBXWDDKRVHEQROPZKZS

output:

2221377778637

result:

ok "2221377778637"

Test #58:

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

input:

1000000
WZENZHGEFMTHAZKSMODUCBNFDDWZCYVRYRQCEWBIV
BQADDGNHJDJIPZMHCDWLAJDEJXIJIQUTSNEUONNQIMOCRLSQXB
HDQYBJLRQMANSCKNMCORGLIGPVBZQWQ
JKZFCDARHAZWYQOWY

output:

1080349150532

result:

ok "1080349150532"

Test #59:

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

input:

999931
YZQXHYLTFOIYQBFESGUABSXJOLACYNAUGFXJIBICE
DPFLCUGQPDVZVGXRBKSHIDMFGEAAAPTCEBZJIZJQJXQEPLZXFU
QYWWBQIDQDAXCGSBJNPBVOQTWMTVVIZZTZZNOLBNUVDGDBHAL
SEAMROELTNSNJHCSUONPLHIWTILGSKZZSKZEBVS

output:

3917276603931

result:

ok "3917276603931"

Test #60:

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

input:

1000000
BIHBPVPHYTWZXITHWCEXISNZDNTCZEBTNHZFWIOAEPZCOBUNWL
OLIBUOONULIOXSTJTQGSUQDIQEJFOTOTIDKIWZRAP
ENGELUGMJLBACDRYPHEKPPVPXQIURFGOYOMUOVEKYLQUIMWF
APRFKDFOUVYYOAAMCTYWCHFITGVIMCCEQUZDPJR

output:

13324982182

result:

ok "13324982182"

Test #61:

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

input:

757219
SWEXJTINTTWDVHGIRGRWKBXJLSEHPLHTHTDUDSR
KEHMUTHUGBTTACTTG
EEYLFRCHPVUCUPTNKCEIYJWCKRCFLJDPPBPXTIJI
AIETPYGASHCOOXKHCCRPXCJFKDFIYXC

output:

996058294

result:

ok "996058294"

Test #62:

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

input:

629201
TT
VTTTT
PUTLPFRQRP
C

output:

3146005

result:

ok "3146005"

Test #63:

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

input:

147204
T
TTTTTTTTT
PGFQGLP
ZKLCQ

output:

2576064

result:

ok "2576064"

Test #64:

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

input:

805507
TTTTDCVT
TTT
PPPPPJNPP
CZCPVKPCB

output:

3866419

result:

ok "3866419"

Test #65:

score: 0
Accepted
time: 29ms
memory: 3664kb

input:

524954
TPBTKTTGTZTYPTJTTZOTTSFGLTTLKTTTTTTTTTOJ
TTTTTTTTTTTTTTVTTTTTTTTTLTPTTTTTTTTTTTTTTTBTTTTTT
PAPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
ZDOCSCCBCLWUCJCFCEMCANCKCCCSUCC

output:

2352475

result:

ok "2352475"

Test #66:

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

input:

127002
NCBTQETTQTLTTTTXT
TTTTTTTTTTTTTTTTTTTTTTT
PPGPPPPPPPPPPPPPPPPPPPPPGPPPP
GICCBDGADCCTCCJXNCMMCJFCCGLRJXCZCZANYCCFSAXPWEFGC

output:

841691

result:

ok "841691"

Test #67:

score: 0
Accepted
time: 5ms
memory: 3692kb

input:

1000000
KTTFJIMTODIDGTDJDTPTKMDTTIPBUTTGWGSPRXNJUKT
TTTTTUSTTTWTTTBTTTMCTTCTTTTVGDJTTWTYTTTTTTFPTT
PSPPGWPPSPNAQPYPFUPPPEPPPPPXPRPXJPYPHPU
ECCCACLCZCCCCWCAXCYUCGCAHVYJSFCMD

output:

26472458

result:

ok "26472458"

Test #68:

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

input:

936720
TTCTOGTB
TTSVEZEWXWTQYRTOTNAZGZLNNOCXTHTTMQN
BHOIRHPUNP
OQGMCHXRC

output:

147533297

result:

ok "147533297"

Test #69:

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

input:

1000000
TTTDYJTTT
FIZTUUTTTTTTVITTDNTTHOITXTTYTFTKTFTDTBHXTK
PLPPPPPPPPPPVPPPPZPPP
J

output:

-1

result:

ok "-1"

Extra Test:

score: 0
Extra Test Passed