QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#507720#4924. 蜘蛛爬树5toubun_no_hanayome100 ✓3721ms920956kbC++147.8kb2024-08-06 20:29:002024-08-06 20:29:01

Judging History

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

  • [2024-08-06 20:29:01]
  • 评测
  • 测评结果:100
  • 用时:3721ms
  • 内存:920956kb
  • [2024-08-06 20:29:00]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i, a, b) for(int i = (a);i <= (b);++i)
#define per(i, a, b) for(int i = (a);i >= (b);--i)
#define lc (k << 1)
#define rc (k << 1 | 1)
#define lowbit(x) ((x) & -(x))
#define odd(x) ((x) & 1)
#define even(x) (!odd(x))
#define fir first
#define sec second
#define pb push_back
#define il inline
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define i128 __int128
#define f128 __float128
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << "In Line " << __LINE__ << " the " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> using vc = vector<T>;
template<class Tx, class Ty>
il void chkmx(Tx& x, const Ty y) {x = max<common_type_t<Tx, Ty>>(x, y);}
template<class Tx, class Ty>
il void chkmn(Tx& x, const Ty y) {x = min<common_type_t<Tx, Ty>>(x, y);}
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3fll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
bool ms;

char buf[1 << 20], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++)
template<class T>
il void read(T& x) {
    char ch;int f = 1;x = 0;
    do {ch = getchar();if(ch == '-')f = -1;} while(!isdigit(ch));
    do {x = x * 10 + (ch ^ 48);ch = getchar();} while(isdigit(ch));
    x *= f;
}

template<class T, class... Arg>
il void read(T& x, Arg&... nums) {
    read(x), read(nums...);
}

const int N = 2e5 + 5, LOG = 32 * 4.28;
int head[N], cnt;
int fa[N], dep[N], sz[N], son[N];
int top[N], id[N], rev[N], tot;
int pos1[N], pos2[N], pos3[N], pos4[N], ct;
int a[N], m;
ll d[N];

struct node {
    int to;
    ll w;
    int nxt;
} e[N << 1];

void init() {
    cnt = 0;
    memset(head, -1, sizeof(head));
}

void add(int u, int v, ll w) {
    e[cnt] = {v, w, head[u]};
    head[u] = cnt++;
}

void adde(int u, int v, ll w) {
    add(u, v, w);
    add(v, u, w);
}

void dfs1(int u, int f) {
    sz[u] = 1;
    for(int i = head[u];~i;i = e[i].nxt) {
        int v = e[i].to;
        ll w = e[i].w;
        if(v == f)
            continue;
        fa[v] = u;
        dep[v] = dep[u] + 1;
        d[v] = d[u] + w;
        dfs1(v, u);
        sz[u] += sz[v];
        if(sz[v] > sz[son[u]])
            son[u] = v;
    }
}

void dfs2(int u, int t) {
    top[u] = t;
    id[u] = ++tot;
    rev[tot] = u;
    if(!son[u])
        return;
    dfs2(son[u], t);
    for(int i = head[u];~i;i = e[i].nxt) {
        int v = e[i].to;
        if(v != fa[u] && v != son[u])
            dfs2(v, v);
    }
}

il int LCA(int u, int v) {
    while(top[u] != top[v]) {
        if(dep[top[u]] < dep[top[v]])
            swap(u, v);
        u = fa[top[u]];
    }
    return dep[u] < dep[v] ? u : v;
}

struct LiChaoTree {
    int ls, rs;
    ll lz;
    pair<ll, ll> f{inf, llinf};
} tr[N * LOG];

#define calc(f, x) (f.fir * x + f.sec)

il void lazy(int k, ll v) {
    tr[k].lz += v;
    tr[k].f.sec += v;
}

il void push_down(int k) {
    if(tr[k].lz) {
        if(tr[k].ls) {
            tr[++ct] = tr[tr[k].ls];
            lazy(tr[k].ls = ct, tr[k].lz);
        }
        if(tr[k].rs) {
            tr[++ct] = tr[tr[k].rs];
            lazy(tr[k].rs = ct, tr[k].lz);
        }
        tr[k].lz = 0;
    }
}

il void update(int& k, pair<ll, ll> x, int L = 1, int R = m) {
    tr[++ct] = tr[k];
    push_down(k = ct);
    int mid = L + R >> 1;
    if(calc(x, mid) < calc(tr[k].f, mid))
        swap(x, tr[k].f);
    if(calc(x, L) < calc(tr[k].f, L))
        update(tr[k].ls, x, L, mid);
    else if(calc(x, R) < calc(tr[k].f, R))
        update(tr[k].rs, x, mid + 1, R);
}

il int merge(int x, int y, int L = 1, int R = m) {
    if(!x || !y)
        return x + y;
    int mid = L + R >> 1;
    if(calc(tr[x].f, mid) > calc(tr[y].f, mid))
        swap(x, y);
    if(L == R)
        return x;
    push_down(x);
    push_down(y);
    int k = ++ct;
    tr[k].f = tr[x].f;
    tr[k].ls = merge(tr[x].ls, tr[y].ls, L, mid);
    tr[k].rs = merge(tr[x].rs, tr[y].rs, mid + 1, R);
    update(k, tr[y].f, L, R);
    return k;
}

il ll query(int k, int p, int L = 1, int R = m) {
    if(!k || L == R)
        return calc(tr[k].f, p);
    push_down(k);
    int mid = L + R >> 1;
    ll ans = p <= mid ? query(tr[k].ls, p, L, mid) : query(tr[k].rs, p, mid + 1, R);
    return min(ans, calc(tr[k].f, p));
}

void dfs3(int u) {
    update(pos1[u], {a[u], 0});
    if(!son[u]) {
        pos2[u] = pos1[u];
        return;
    }
    dfs3(son[u]);
    ll W = 0;
    for(int i = head[u];~i;i = e[i].nxt) {
        int v = e[i].to;
        ll w = e[i].w;
        if(v != fa[u] && v != son[u]) {
            dfs3(v);
            tr[++ct] = tr[pos2[v]];
            lazy(ct, w << 1);
            pos1[u] = merge(pos1[u], ct);
        } else if(v == son[u])
            W = w;
    }
    tr[++ct] = tr[pos2[son[u]]];
    lazy(ct, W << 1);
    pos2[u] = merge(pos1[u], ct);
    tr[pos3[u] = ++ct] = tr[pos1[u]];
    lazy(pos3[u], -(d[u] << 1));
    tr[pos4[u] = ++ct] = tr[pos2[u]];
    lazy(pos4[u], -(d[u] << 1));
}

void dfs4(int u) {
    if(son[u]) {
        pos1[son[u]] = merge(pos1[u], pos1[son[u]]);
        pos3[son[u]] = merge(pos3[u], pos3[son[u]]);
    }
    for(int i = head[u];~i;i = e[i].nxt) {
        int v = e[i].to;
        if(v != fa[u])
            dfs4(v);
    }
}

namespace SegmentTree {
    struct node {
        int l, r;
        int pos;
    } tr[N << 2];
    void build(int k, int l, int r) {
        tr[k] = {l, r, 0};
        if(l == r) {
            tr[k].pos = pos1[rev[l]];
            return;
        }
        int mid = l + r >> 1;
        build(lc, l, mid);
        build(rc, mid + 1, r);
        if(top[rev[l]] == top[rev[r]])
            tr[k].pos = merge(tr[lc].pos, tr[rc].pos);
    }
    il ll ask(int k, int l, int r, int x) {
        if(l <= tr[k].l && tr[k].r <= r)
            return query(tr[k].pos, x);
        int mid = tr[k].l + tr[k].r >> 1;
        if(r <= mid)
            return ask(lc, l, r, x);
        if(l > mid)
            return ask(rc, l, r, x);
        return min(ask(lc, l, mid, x), ask(rc, mid + 1, r, x));
    }
}

bool mt;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cerr << fabs(&ms - &mt) / 1024 / 1024 << "\n";
    init();
    int n, q;
    read(n, m, q);
    rep(i, 1, n)
        read(a[i]);
    rep(i, 2, n) {
        int u, v;
        ll w;
        read(u, v, w);
        adde(u, v, w);
    }
    dep[1] = 1;
    dfs1(1, 1);
    dfs2(1, 1);
    dfs3(1);
    SegmentTree::build(1, 1, n);
    dfs4(1);
    rep(i, 1, q) {
        ll s, t;
        read(s, t);
        --s, --t;
        int k = abs(s / n - t / n);
        int u = s % n + 1, v = t % n + 1;
        ll dis = d[u] + d[v] - (d[LCA(u, v)] << 1);
        if(!k) {
            cout << dis << "\n";
            continue;
        }
        ll ans = llinf;
        while(top[u] != top[v]) {
            if(dep[top[u]] < dep[top[v]])
                swap(u, v);
            chkmn(ans, query(pos1[u], k));
            chkmn(ans, query(pos2[u], k));
            u = fa[top[u]];
        }
        if(dep[u] > dep[v])
            swap(u, v);
        chkmn(ans, query(pos2[v], k));
        chkmn(ans, SegmentTree::ask(1, id[u], id[v], k));
        v = u;
        while(u) {
            chkmn(ans, query(pos3[u], k) + (d[v] << 1));
            chkmn(ans, query(pos4[u], k) + (d[v] << 1));
            u = fa[top[u]];
        }
        ans += dis;
        cout << ans << "\n";
    }
    cerr << 1e3 * clock() / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

详细

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 44ms
memory: 856820kb

input:

97 99 1000
763118300 558295517 80676328 362318619 473105413 468927175 311496507 936935430 176032966 304576040 308583326 681580095 549392233 518152994 829474320 751189715 542810029 587869244 878512027 530678371 832766129 535259635 799122942 596982955 884696876 605325753 495661541 506105495 561218313 ...

output:

6130845802041
10806758605627
3440559556796
5426989115608
4458875959622
1566659300400
7908007295597
1846030561682
5112206409383
6968388472340
4706970599850
5270158948178
4633066810868
3176122148295
2331646415266
961435137842
14353365296423
9675072605938
4256954122467
7333255321628
8376795894537
12319...

result:

ok 1000 lines

Test #2:

score: 3
Accepted
time: 31ms
memory: 855620kb

input:

96 100 1000
31199641 534644486 57980198 794620020 322548308 524438614 467991232 68617179 243820212 229414440 471419229 316085673 271698528 136252783 926625435 615138376 200446739 551914057 483498389 879166147 512229523 45850421 337184110 799426876 46405170 427929494 235848997 861270528 291868400 616...

output:

2436336301732
4467388472930
6498834342013
6450642313333
4049880787954
7509100670176
5831628235154
4150554274586
3112250048344
202594784082
2974050754796
8714737807242
7727115169865
1321297431165
3071603311467
4662413775237
5469193332429
2306749862693
6240860740176
1297819731517
5602374629655
5876108...

result:

ok 1000 lines

Test #3:

score: 3
Accepted
time: 39ms
memory: 855736kb

input:

96 100 1000
557703101 38662752 91559144 406758463 248251717 279124287 667387330 272252891 892434115 281731667 162886140 786660171 350559478 909940602 476034354 78826379 748607300 381191755 708777514 223906483 954905399 405424569 356033791 565979037 5787205 21241249 399771402 280058652 527147793 5875...

output:

80606469890
86777173467
35481695596
11498756054
87983213070
37171191055
33172639202
31451029430
105454750479
31626589074
105218154775
46986908645
14488184465
20368758481
41150521804
57639739744
45269689956
24620398400
51392609182
44732144926
72097558763
13572235163
78364419227
40255815091
1195379951...

result:

ok 1000 lines

Test #4:

score: 3
Accepted
time: 64ms
memory: 856028kb

input:

96 96 1000
651436202 969634688 411838043 313319930 906863003 709869271 467187062 352351954 116039480 172098032 933097773 469945118 162439715 767382758 713254949 387661957 387494696 343642279 730353853 607472395 431993920 231539946 570437226 454446439 941394569 230535263 758579901 173778951 636556431...

output:

81136576805
65057090263
57308140599
70187240654
42682272024
83341639885
53487742661
53219947761
14656518493
18143524741
27930061212
75815621849
67528908552
39936561353
44548681818
122544815339
64143328818
13510734748
16412423500
108236922255
83503599273
53331146110
59331932211
93957710008
3825533077...

result:

ok 1000 lines

Test #5:

score: 3
Accepted
time: 52ms
memory: 856008kb

input:

100 97 1000
9442498 799978686 853182282 938513473 647407813 233204982 473300672 884708491 641608620 453797741 412704210 204494322 711344505 287815571 401113141 110034416 590478367 831110886 255614524 234577289 759353531 774504637 366342991 154214800 692604750 308540773 768713312 121270668 425512518 ...

output:

5006945326
9445360831
13045856109
4494648380
6833826505
3769548416
11380661054
5754815524
8246147623
4801077020
5798520769
1392753490
6948207422
12106173499
6097834765
4210216111
3541517785
5402770609
8790748574
10564152311
2826265999
5688050930
7790838243
2760570076
4835335024
5099967138
3178901350...

result:

ok 1000 lines

Test #6:

score: 3
Accepted
time: 35ms
memory: 855792kb

input:

100 100 1000
72360333 314738290 34206178 541145218 174183915 396182816 34673830 913434757 537587312 731274646 498514633 251108131 102959912 646618466 457048174 475505598 769612876 452196872 718739596 624410437 9031420 286458655 569299852 299007318 306647081 98662275 920437282 210801779 674405507 219...

output:

3655918495
8154487755
14137574021
9267685665
7011313073
12013474026
11488238672
8912382325
14741526855
17840835926
8748441239
7607949288
7949030269
10402650219
7895349896
9942798476
19632481428
6001424701
5150011606
14328944041
7536672479
10941755235
8915887826
11121022173
5570869661
5489621389
7171...

result:

ok 1000 lines

Test #7:

score: 3
Accepted
time: 23ms
memory: 855576kb

input:

100 100 1000
671289501 901524700 187943785 477991411 752983691 647246158 953320691 934684418 412368667 925367409 762075316 358848462 963075530 457549089 783006165 5363230 270806670 315603863 281313188 630063184 613102269 512390085 496057389 735900160 98801654 915737591 295267905 169463128 895274860 ...

output:

109982431024
38431175833
69772178732
48480356522
11451380583
20622728312
34853416584
49223376377
50708590192
23464488129
66396102290
49072787090
63071461232
100259758746
39605337609
43518034110
69171797185
76120124501
31732771736
43824267429
50401683487
18812219611
17592704047
40305088337
8902132735...

result:

ok 1000 lines

Test #8:

score: 3
Accepted
time: 36ms
memory: 855788kb

input:

100 100 1000
97012332 782222818 959933898 427265795 145416034 1879121 649904335 612684991 536487830 163534103 503165874 529288026 317196350 758782134 932469419 45296081 275446181 306725071 736168208 601979715 145679830 269223691 287672389 93736686 102440922 49242307 14300820 7040380 666185124 780231...

output:

43197564487
61281841688
44768770079
49385322040
35679440075
61129947858
71570620926
54095812113
65913522420
61326476305
50331061951
39723327870
52634647963
37572255373
44983995360
20296010788
65756945356
16562779626
52036714858
19671474013
46849723315
81935125579
28823217661
58491548742
63997977890
...

result:

ok 1000 lines

Test #9:

score: 3
Accepted
time: 64ms
memory: 856848kb

input:

1 2 5
1000000000
1 1
1 2
2 1
2 2
1 1

output:

0
1000000000
1000000000
0
0

result:

ok 5 lines

Test #10:

score: 3
Accepted
time: 48ms
memory: 856408kb

input:

2 1 5
2 1
1 2 1000000000000
1 1
1 2
2 2
1 1
2 1

output:

0
1000000000000
0
0
1000000000000

result:

ok 5 lines

Subtask #2:

score: 5
Accepted

Dependency #1:

100%
Accepted

Test #11:

score: 5
Accepted
time: 55ms
memory: 857260kb

input:

4968 1000000000 4947
35398 17280 28501 30106 20289 12704 8742 38872 40600 32757 4709 49509 18925 8232 12657 5856 35298 16182 34878 29788 22757 3667 6147 33251 10280 21807 9932 43760 25234 21837 2000 42316 42227 30480 48217 18842 12065 3569 33962 10434 9965 6816 46030 14352 7696 39388 37027 2641 4927...

output:

27171080853044
16475800995047
47858729923137
38839226619025
68829717991555
66238455750161
69391451769289
61015426629738
34984939995941
46894448125681
66492516637760
84920329286569
37539473678478
26863746705396
24228771920185
20757319444368
62547461012321
29240639472051
33274823206812
29763531850641
...

result:

ok 4947 lines

Test #12:

score: 5
Accepted
time: 52ms
memory: 856324kb

input:

4981 1000000000 4953
151742 15587 142065 128832 78714 10584 76914 106299 31568 52704 188707 28416 12984 61582 32999 186530 140703 147751 47543 175894 7752 191829 63929 114837 92045 50348 9699 45344 118713 116457 164914 29571 114745 130797 196228 187265 10152 1229 3383 97088 55723 174984 127564 39677...

output:

39175214953945
26200723643487
46943276265557
28283755650448
27784497704623
47477663513975
25153955655196
34658568119723
36390677477885
33283868432417
45462962712646
12634898326814
12553555762696
29763136584312
59969070638872
32014006456467
32113426391414
28135433219086
47248493737483
56523379856914
...

result:

ok 4953 lines

Test #13:

score: 5
Accepted
time: 52ms
memory: 857096kb

input:

5000 1000000000 5000
7709 49516 81404 252939 337304 22843 327351 119119 469819 411352 375305 439834 224988 108405 27787 377575 382742 28074 255120 112472 244686 267973 224537 126626 101857 58364 298859 89790 474293 329321 441367 108105 278126 181944 246403 415680 273376 409094 169364 339149 196519 3...

output:

224644098442606
54861440986602
467147774410064
30362267317869
296379104994566
473075396075640
122083966788904
272566888272189
216858876719405
215746767255802
347849462280931
520897037387102
19480747175957
76784800656757
227716313122157
66425147109923
371507621482925
352677699283994
15598007683275
59...

result:

ok 5000 lines

Test #14:

score: 5
Accepted
time: 71ms
memory: 856300kb

input:

5000 1000000000 5000
253265 289565 480218 817881 388719 980412 67414 134135 762536 232380 406531 204614 200869 487447 967573 799195 802628 529421 333062 23170 711366 781842 202481 635401 256687 178162 589701 440119 691724 314358 566777 600174 401029 556684 811778 442351 501890 561627 65781 824606 38...

output:

229741484116980
164175833276967
99443665231144
54979925948709
767846577154984
82615685235989
491961122361479
258830345532802
337194117311972
330754218569722
208052850590856
109736272716532
772091540293926
46512912591879
222739255582971
104104517451050
155728909685296
619218590510841
329616510853980
...

result:

ok 5000 lines

Test #15:

score: 5
Accepted
time: 43ms
memory: 856928kb

input:

5000 1000000000 5000
9165442 10032926 9324284 18687554 9961685 9532269 9821667 10084498 8903944 10118365 9775765 19733471 25638562 9383006 8825736 10428746 9066921 9401601 11694769 9998610 8896431 9186888 9834954 10583130 9321162 8943766 18203176 9463949 9187659 9612570 15398089 9597271 9774891 1006...

output:

3346954835952024
9683326417379824
3034185194974329
5653331361714484
4883637125911652
4144529883528686
1550288375157255
4849179484656607
7780090186793507
8760876193430258
2791370216037543
7961795785990098
3625625101008354
830776458752577
1201598422493424
5284514192781053
4673390841578381
221202738816...

result:

ok 5000 lines

Test #16:

score: 5
Accepted
time: 72ms
memory: 857640kb

input:

5000 1000000000 5000
10328285 10154180 9849852 9978950 9899905 10007975 9932544 9993918 9897530 10042306 9913325 9834599 10081669 9949843 12994559 10008823 9910840 11562770 9903505 10076660 9980716 9890836 9934511 12177770 9904174 9911365 10195395 9827430 9905113 10026600 9830577 9852209 10069231 99...

output:

1647385331743507
5524865815859729
3059643445230206
9470053705989838
9178562810279320
7549445324071426
2027312277087798
8273023856964174
9615573793436228
8112830816194948
8931306355319079
5885476349335756
1381279438337504
8765067046522175
2086999576794297
4002632440712670
7924144870658890
79357254043...

result:

ok 5000 lines

Test #17:

score: 5
Accepted
time: 52ms
memory: 857672kb

input:

5000 1000000000 5000
2513000 70283 123233 147800 2407113 6750 548577 2496501 1589521 382060 1078641 28843 12885 979911 249118 399277 335551 1496141 1161882 94180 1562518 1846018 2023612 688097 1505606 37597 1714464 2071436 2225125 2437519 1190287 1307370 1559871 443072 285850 1245177 429584 1750366 ...

output:

416853386301
245456106087
329277735132
507750960639
544942162618
258694401397
376595479438
395068151898
515513005035
523563370330
378130973019
272463853221
335748583419
223192323740
328497513286
436111548238
380723617773
389134126388
418340678864
415228727699
338316467895
344020792244
444955157605
5...

result:

ok 5000 lines

Test #18:

score: 5
Accepted
time: 51ms
memory: 855544kb

input:

1 2 5
1000000000
1 1
1 2
2 1
2 2
1 1

output:

0
1000000000
1000000000
0
0

result:

ok 5 lines

Test #19:

score: 5
Accepted
time: 47ms
memory: 855932kb

input:

2 1 5
2 1
1 2 1000000000000
1 1
1 2
2 2
1 1
2 1

output:

0
1000000000000
0
0
1000000000000

result:

ok 5 lines

Subtask #3:

score: 11
Accepted

Test #20:

score: 11
Accepted
time: 467ms
memory: 883188kb

input:

200000 20 200000
679416469 548913625 468159997 137709609 883140368 682558021 473174374 400192350 124143873 825920417 372498686 851213321 822264481 78195915 5427143 453304163 233551905 810910186 810046144 52603791 282167184 385032797 81387991 747194790 917579656 585184539 12659388 249218417 158295502...

output:

920563165
270738856
355012553
363898450
515535908
734168762
81197110
448355845
204186827
966151314
377621564
856252543
311456222
368700872
197258906
567302636
172379629
579171621
1043838058
244996663
621435809
278057792
727463012
573783312
395879848
500677226
891900111
1031612062
771021332
691010101...

result:

ok 200000 lines

Test #21:

score: 11
Accepted
time: 433ms
memory: 894432kb

input:

199998 20 199928
841581743 193826897 19260647 316900759 938030012 734551083 200340391 232139411 654311599 1143318 596086442 603556286 904977745 575551276 670573487 214312499 155571640 318139630 664877075 921888211 314261245 840096855 656620366 784431866 158438090 761901044 794827280 603867695 489777...

output:

623283525
8593864781
7874704109
155914357
3646556950
3740880356
3717912008
12901066587
1524759519
4985719750
2248493864
5114948482
3925676469
579421045
1507306567
2095047126
606785057
146334438
4045519468
8910005611
4581660381
4073333567
3935919804
676004871
2344714675
5021627074
5038533943
15002805...

result:

ok 199928 lines

Test #22:

score: 11
Accepted
time: 368ms
memory: 892900kb

input:

200000 20 200000
986369289 907363922 363774806 860858089 709715562 958810333 925993952 387795500 17150414 148015078 97834597 563293239 667378418 806659943 610215443 524417320 750481911 623874575 259982271 991286339 284729472 528334897 723997495 992805109 87608435 211268145 108070673 872622387 564643...

output:

10054223674
507380699
3217502558
539269
6315538
1928038308
1387049352
9511170763
5162637476
42235828
121118538
4623727820
10063019655
3205838882
4165257188
7261364
8095368917
8506365
5447619
2143078432
7359894792
10046658768
5435463
9232067090
6457897508
9629262
6399644
10022553858
6118703
8574986
1...

result:

ok 200000 lines

Test #23:

score: 11
Accepted
time: 619ms
memory: 883392kb

input:

200000 20 200000
747319812 390314311 314857121 211725609 263470750 979001169 50249481 658501549 959367948 893597081 177095123 795316289 460892240 678153548 117315462 524637159 259809686 647733605 266923024 115001443 857165610 939992604 661082449 538356122 31381162 71199751 506277142 981277756 241363...

output:

13662467103
15058589930
16458374764
15068421502
15811563571
13609092499
11356368656
16879299235
11336754159
13516222673
12846976402
18034454674
13386369283
17622328679
18631538755
15324696769
16685528530
14449065100
9460517704
13186912844
13733806309
18274703051
15926306728
14858932320
16642420472
1...

result:

ok 200000 lines

Test #24:

score: 11
Accepted
time: 407ms
memory: 885696kb

input:

200000 20 200000
583112253 665093743 182048276 129269058 978415657 935953723 213813205 484649825 261214425 779189226 703649598 549454855 77715802 293926531 52713413 268118203 466091215 231039312 656528084 638468205 591205307 677293897 835642445 551021744 925782487 807259560 868830834 350378234 29765...

output:

316570302401
913144581593
913146543686
816894767104
544003812147
913148786078
468597633695
913144020995
913144301294
913147945181
183683477907
0
617634383371
666551848769
913147945181
5219486966
433656750247
524020417620
738877896143
913144301294
663163982315
913146543686
463256538270
913144861892
9...

result:

ok 200000 lines

Test #25:

score: 11
Accepted
time: 373ms
memory: 889828kb

input:

199962 20 199931
203506003 500751161 109978444 459010003 360964084 934576878 62980626 287820619 391197904 676602559 355742604 562232069 46776374 245111830 792609360 310542062 980352907 366602017 761654096 990177701 115948816 787238197 996548404 415779854 365866565 515988075 727704701 717436079 63512...

output:

798529011
60397088
1873438365
2138547241
1144282606
4083769129
4025496730
2344294194
200221409
1327038796
156436273
2085005208
76583374
1449673130
1074781339
257136048
3879420993
1472989996
25734720
1192283175
3633170363
1661044557
1096662244
257544665
540683798
2288140683
601119764
3096222006
21406...

result:

ok 199931 lines

Test #26:

score: 11
Accepted
time: 51ms
memory: 864096kb

input:

1 2 5
1000000000
1 1
1 2
2 1
2 2
1 1

output:

0
1000000000
1000000000
0
0

result:

ok 5 lines

Test #27:

score: 11
Accepted
time: 19ms
memory: 862120kb

input:

2 1 5
2 1
1 2 1000000000000
1 1
1 2
2 2
1 1
2 1

output:

0
1000000000000
0
0
1000000000000

result:

ok 5 lines

Subtask #4:

score: 12
Accepted

Test #28:

score: 12
Accepted
time: 519ms
memory: 902236kb

input:

200000 1000000000 200000
28270302 472359923 262785485 923929785 393684160 761485431 72038469 116384740 426631758 437934930 610834083 455314140 734276543 903544756 220163018 756113376 732404264 947339315 109784905 625451008 794076307 818852312 758007217 124450858 674924509 311761991 507260538 7032362...

output:

29294995135992468
9003943574137677
39324997066279292
37544709020512848
57388992119827952
54425124319330092
19450449300737912
25838911017710871
2608104102967357
32395369352281774
5765752637876701
65609495812941401
57820177390587134
1971831067795873
19213682025389514
30244870693646792
3672338761985429...

result:

ok 200000 lines

Test #29:

score: 12
Accepted
time: 508ms
memory: 911784kb

input:

199957 1000000000 199978
484184824 891546207 975734696 100539020 831491149 39172314 864159331 720402805 776042647 843662372 935604278 544595844 393931465 659783207 863682602 900000494 79169772 921429466 469390191 891091094 53691506 616777249 622575840 230565013 939987814 175664187 663514526 67841276...

output:

19959327553591648
32010533345091793
15410299665390255
71446530548310580
42757122329520314
44547359192496305
40421459068680865
12617048458606361
68505071787885633
20229193415512477
3959463349380309
52345766780671421
22183426380065088
29440145261757182
3846326653273891
34476543006148377
40819831884710...

result:

ok 199978 lines

Test #30:

score: 12
Accepted
time: 603ms
memory: 912156kb

input:

200000 1000000000 200000
422691889 268096182 223379104 268498792 392869265 1000000000 417073437 318368899 256962522 269513908 419697397 238567965 335189697 385837139 224219570 512586026 262793940 382819306 336110315 334843736 221179169 333772959 246702289 246377232 468460842 481454739 360039636 4372...

output:

224180993880896775
289564129076952626
275865980455069675
157628887637311054
198006388889029310
171540845366364406
335236582279069778
233727831092410768
286541513965424592
374120296090502383
310438489863336356
103195240752822032
189760302415610937
298279318492947402
291103583974138676
194715458020342...

result:

ok 200000 lines

Test #31:

score: 12
Accepted
time: 496ms
memory: 920956kb

input:

200000 1000000000 200000
602692841 601218040 601028255 1000000000 600403832 600232743 1000000000 599827124 599554412 1000000000 599301448 599113416 598989376 598786010 598636538 598553391 598370071 1000000000 598097301 598050441 597961490 1000000000 597806035 1000000000 597567223 597431163 597303663...

output:

209319542988838768
110577432223619722
125560261182969181
113185646498525815
136111861598679143
41978037866824629
96633947494918877
98374850209472659
242090527128147826
294694667971307324
138693418992158068
268811154379707206
69619449407249103
70205711769209505
59220392077886910
77428322381245404
195...

result:

ok 200000 lines

Test #32:

score: 12
Accepted
time: 816ms
memory: 917408kb

input:

199931 1000000000 199922
4013211 29714 1234462 1104572 1387655 273547 2854143 48754 3708907 92381 2416194 746211 782254 120292 5006444 2861799 5079340 2465365 2124023 4872770 133080 4355785 24081 4909586 243019 478235 278274 765568 1623339 518688 1021168 1990694 15052 3907624 3158505 4801536 2792353...

output:

396961167374
239043328316
303627822911
432749619117
361386708539
232557605389
310510144596
367430698623
278512942021
502706642903
232040628241
132457354501
521368949201
242967590974
429550834513
471199557886
266915933583
223731337727
151159169817
156285897711
298457093414
348439300538
252319058294
3...

result:

ok 199922 lines

Test #33:

score: 12
Accepted
time: 855ms
memory: 910588kb

input:

200000 1000000000 200000
5099932 4728906 2664545 3492339 646363 4078 481407 651875 32539 107203 1903484 515880 757323 3210572 10151 4880869 2293417 47189 3005497 2964135 91971 1797360 5095111 1494940 234796 3878867 4688923 399250 4093489 4917976 3217920 1135442 278278 2617067 2494154 4981268 4413226...

output:

491847427429
221565577072
416295244945
372886641436
238900215923
42152037417
220171926078
356278662471
242256776253
477527214604
97990314803
194326826650
543508546303
455921465239
422936284306
62633776772
240775687183
325298847287
546245176672
311618424599
365337654397
471518661673
232566667212
4090...

result:

ok 200000 lines

Test #34:

score: 12
Accepted
time: 32ms
memory: 864692kb

input:

1 2 5
1000000000
1 1
1 2
2 1
2 2
1 1

output:

0
1000000000
1000000000
0
0

result:

ok 5 lines

Test #35:

score: 12
Accepted
time: 47ms
memory: 862020kb

input:

2 1 5
2 1
1 2 1000000000000
1 1
1 2
2 2
1 1
2 1

output:

0
1000000000000
0
0
1000000000000

result:

ok 5 lines

Subtask #5:

score: 9
Accepted

Test #36:

score: 9
Accepted
time: 127ms
memory: 884576kb

input:

199918 1000000000 199903
1496 2382 3896 3664 1177 1627 2821 4200 3074 3783 2069 4403 629 2610 4991 4074 3033 2798 4333 3501 3667 3064 663 2821 2818 458 2950 4020 2665 3578 63 4855 4941 3492 2423 4510 1489 1018 4829 1912 3133 3174 309 287 2909 4102 4296 4526 3170 3683 4960 4863 4738 2927 2405 3600 44...

output:

1352416884531
1380463318391
923920163167
1525224977139
1405019709299
869269749781
715671043328
876194052054
1358007874327
127994985855
1230162209719
1532026808855
611656467332
1023855959729
414792924571
1316679734677
827308370883
1265411315424
821484360433
1051517948640
837509712760
582943943131
457...

result:

ok 199903 lines

Test #37:

score: 9
Accepted
time: 127ms
memory: 882316kb

input:

200000 1000 200000
809770918 700177243 142627650 840666719 799717263 288840787 130614153 965150450 584417569 833256629 453961603 553430999 842122932 156970995 233405993 462368588 449589390 97217337 576814616 526506175 16887352 919946415 588340411 47310125 508028561 746882745 289969878 38349443 85588...

output:

1585694392495
706038536805
586801212025
729763504879
1121912701709
602929530934
1384874490966
932809860298
1786651350814
1173133997984
642188971333
1847564817170
874110129257
1634207197990
1165001912684
860420326934
364758620851
736767366986
901294347345
1499330839732
451636930949
1002710230684
1556...

result:

ok 200000 lines

Test #38:

score: 9
Accepted
time: 214ms
memory: 885060kb

input:

200000 1000000000 200000
399998482 399998882 643012112 481981456 399998451 475990021 399997292 399997409 399996369 399998092 399998185 399998416 399998701 399997027 399996347 1000000000 411997672 399996237 399997188 402404134 399996973 399998072 459327897 399997196 399997360 606704265 399997369 3999...

output:

56425935917250335
348929904541748910
43150321666095229
218746357373815571
108846332361563136
211578526026780722
142755080047590213
244555928973138123
59355666550218703
274305014995294225
171177308635990844
94566903236734112
84270300399685207
317423517245573254
902979060499211
14514565807335715
18696...

result:

ok 200000 lines

Test #39:

score: 9
Accepted
time: 292ms
memory: 883240kb

input:

199989 1000000000 199949
5101893 2534711 252776 33497 4575476 620658 35790 1061631 1362697 834917 2062598 2789238 2540552 2557066 725856 2407848 4266144 1731334 653868 4676650 235573 2010805 1576557 922173 617762 1140093 387911 618359 2084018 2717580 9938 4014950 411349 3801906 341206 665844 2556003...

output:

376419619600
353028349944
783455928283
427146243318
508001272847
231025894377
614377184831
496116219491
384142701402
337878147372
528478063399
414595122323
604998898988
244135680083
319848781263
358386785447
481117281935
464006706964
356458898506
260105342030
610113746365
259007651455
414991108424
2...

result:

ok 199949 lines

Test #40:

score: 9
Accepted
time: 275ms
memory: 884704kb

input:

200000 1000000000 200000
1101540 573488 61066 1014872 39283 626062 84341 591377 109026 505272 1339 74452 729192 49315 521939 959958 249731 940337 56264 1071790 609623 239862 57448 809987 464526 111430 226312 124386 673550 421690 211347 45875 138962 705453 739456 464892 44238 52980 905593 205558 5198...

output:

655436303263
616441802310
638361564730
586321577191
519122088245
660130086237
389806954608
241891011597
423594953230
510963332372
630353140994
627262451077
339051346548
308888235187
550167732447
354951509166
308776095000
597351022439
625625736560
772346222022
549689478477
667370706484
319926160326
2...

result:

ok 200000 lines

Test #41:

score: 9
Accepted
time: 39ms
memory: 863960kb

input:

1 2 5
1000000000
1 1
1 2
2 1
2 2
1 1

output:

0
1000000000
1000000000
0
0

result:

ok 5 lines

Test #42:

score: 9
Accepted
time: 35ms
memory: 862072kb

input:

2 1 5
2 1
1 2 1000000000000
1 1
1 2
2 2
1 1
2 1

output:

0
1000000000000
0
0
1000000000000

result:

ok 5 lines

Subtask #6:

score: 22
Accepted

Test #43:

score: 22
Accepted
time: 269ms
memory: 885696kb

input:

200000 1000000000 200000
81882094 47220813 43282454 17633207 52769165 4830673 31396360 64793163 9174729 36727563 71268262 24662923 40146030 1430053 62926106 30042905 1330107 81817720 98841078 87766129 51155045 23216268 79896310 66625868 87854925 42976560 86542933 28336449 34932261 19698851 584453 90...

output:

516260625003899
380880451347644
183401242058615
56975236749493
349851829300288
188845759476214
188011317678919
414887287533565
111834744858133
305218494040213
227244584301956
365579485207024
201761449059479
246263150359463
468212144364502
389353276591541
207814284476264
341801277159919
4270404442188...

result:

ok 200000 lines

Test #44:

score: 22
Accepted
time: 363ms
memory: 894668kb

input:

200000 1000000000 200000
885272642 374759028 888606054 718260881 712640799 453067010 847699265 597983546 473777736 340935923 415594372 874762802 957196626 674414761 601425225 628341608 249369250 380959879 619963443 106167226 73865409 826858024 56062512 437693354 340445108 604619683 791991483 7300264...

output:

7769103153522109
21209520101497866
12453875916706553
21861512525349055
21994844775114551
22606385523748384
4962030058940312
20614777846726216
4514335046749431
20346398113954539
16479975916989640
2806007917483201
19622386582746420
22955087055842971
21041026349491377
24046136537255789
2041470515268697...

result:

ok 200000 lines

Test #45:

score: 22
Accepted
time: 299ms
memory: 887152kb

input:

200000 1000000000 200000
221911326 672598376 586864284 652343839 645072453 477182516 470253244 169559270 913860372 153896545 452982258 356042452 131678734 285479642 780356439 919192461 374130593 89810026 390686444 990599905 300023735 916489417 40995583 613948336 361863393 17299001 909709725 80365886...

output:

3850358894573407
4727815116715378
6494041025937004
4824435980551637
3378697610475978
5909426402365293
5518872599382274
4158124880334301
3937773073272371
9687643834151992
2427228601277127
2243767802218885
2464182590746753
8320457785791601
2372831686710907
7624139791764704
2729257787239080
90363701429...

result:

ok 200000 lines

Test #46:

score: 22
Accepted
time: 408ms
memory: 892828kb

input:

199997 1000000000 200000
418668520 349968181 349972501 413151936 413168716 358529603 413712865 419740996 413260207 413754768 413754409 413644778 352475862 391987463 349972716 1000000000 349968635 376567534 413307389 413513241 392814142 413753730 349967166 349969051 365151841 349973369 413757992 3499...

output:

246430378081337415
289991643186437654
296315729206931331
364169975100364021
192595239991666627
57389957577630585
322772936556813385
154410265195118126
15121202928554667
95942665106074526
29110913867320341
247647043585119923
331278885019774528
399239706543450142
259799041077439947
308782410202237399
...

result:

ok 200000 lines

Test #47:

score: 22
Accepted
time: 747ms
memory: 892032kb

input:

199997 1000000000 200000
5099350 2290489 288943 3023893 498119 1980893 61654 4972753 2125310 135980 1090538 2954994 4015300 812572 4645903 3233143 1379788 818444 1534283 4069851 19634 2435868 4145501 16053 5943 3925849 3172608 871962 1005093 1205114 8917 758532 3035834 2817889 545073 3670544 5057079...

output:

234196984676
486350257291
322294896890
216546281167
494216113461
572299792560
489662712294
475722942319
243629568040
429703691047
203546469394
283970977506
247616916213
535967681169
243027652067
472054561070
338167336711
249147033135
288935860327
290760911811
309565528803
513985763532
431591688646
4...

result:

ok 200000 lines

Test #48:

score: 22
Accepted
time: 913ms
memory: 885484kb

input:

200000 1000000000 200000
400973183 400377730 400709896 400180375 400313803 400511962 400371890 400134460 400148639 400269163 400170270 1000000000 400217075 400325397 400194331 1000000000 400130150 1000000000 400102020 400139679 400123734 1000000000 400126747 400222387 1000000000 400122213 400115355 ...

output:

330898574562445672
112499815410130451
292078105105911864
226269792209495968
86667035410318720
173003927946045263
96345981791642245
386925883084229768
201270426486087515
390559064393977652
363775401603363524
316465987026547677
189681741290208846
179522924025315419
231976763836669836
17536211389322141...

result:

ok 200000 lines

Test #49:

score: 22
Accepted
time: 1341ms
memory: 885532kb

input:

200000 1000000000 200000
3104552 3104468 3104522 3104441 3104006 3104418 3104492 3104257 3104338 3103037 3103790 3104124 3104403 3104409 3104324 3104186 3103634 3100765 3102923 3098416 3101925 3103680 3102937 3103140 3103205 3104375 3104227 3097705 3104353 3099751 3104174 3104077 3098358 3103547 310...

output:

299170245832
492089907878
234626220221
479271609338
502550631422
276242675712
568363575475
499894660691
637989402461
528007462738
472851936868
609342882560
603201080952
470943763001
332242018172
266091057439
451790590271
501620901482
570283671029
619943731238
492033377164
607909626590
555558037644
4...

result:

ok 200000 lines

Test #50:

score: 22
Accepted
time: 520ms
memory: 883700kb

input:

199924 1000000000 199984
399869085 398376861 439948274 399733681 398624841 398713237 479735387 399767025 400080369 649078920 399661262 400009677 1000000000 399981396 399790787 398757873 400028368 410098923 400282166 399725262 399857368 398570981 398465638 399994302 400011046 398750814 701394147 4264...

output:

274712263738077387
361957805519428564
312885220894571314
91126316434021637
14632663337398615
288041199082475383
285788012165091014
239444158149519924
228152425395680281
386763034110222318
335523640469294150
231950045342323397
11909732801116553
327243695168307095
227866104753359078
293094204545827505...

result:

ok 199984 lines

Test #51:

score: 22
Accepted
time: 576ms
memory: 888324kb

input:

200000 1000000000 200000
391175458 386460764 381754652 782149047 413042241 391189070 386250325 408504234 450354921 389257952 400953425 400000679 383617987 870067693 407269224 383581360 413227573 382122391 385646739 405208885 412435077 549469669 392037145 387667032 387500501 395760590 408533213 40678...

output:

359574023501711749
189386606118067911
340221522042157239
94695135310902641
194853259519380481
204036382398674152
220150543637394295
247692420482925693
170505194682743836
128701965779923218
221082537626355128
152363458918389004
229636099144301752
212471069198315247
290534107817356008
3837587588639638...

result:

ok 200000 lines

Test #52:

score: 22
Accepted
time: 175ms
memory: 883032kb

input:

200000 1000000000 200000
474717573 399999395 399998209 399998002 400000391 400000384 400000598 400001243 399997532 399998369 400000255 399998545 400000326 522897504 399998475 400000410 400000375 399998364 399998641 399998124 399997405 399997992 399998572 399999371 400000289 400001268 399998034 39999...

output:

173736955036522085
33650951440191764
143730970143276166
99418193510942190
342634198332954072
162502488670705477
375965255476953997
258543590358454738
232061399883523900
261060000771343170
357529029841999653
240058654959790996
204637421229932299
343226944296757095
151951735010708339
23769275557349395...

result:

ok 200000 lines

Test #53:

score: 22
Accepted
time: 808ms
memory: 883676kb

input:

199982 1000000000 199933
13905 69644 11795 17651 18054 465661 20911 738216 1097153 735181 986430 65838 1015433 420487 80345 2483 157723 6170 3872 169523 310529 772003 317617 957530 10689 50872 725052 351260 406429 905643 29455 787932 727733 156301 827039 801839 271562 84335 74338 96058 461503 110830...

output:

315889687715
274454363440
294262916565
87340375425
267007540685
359869041992
302546759206
324552934313
226536315022
297144155332
494360796272
355456788344
53123205018
270937855399
250406745471
259508383005
461215278318
300738324383
326197147912
306529365019
267905971033
268651306040
272619646060
235...

result:

ok 199933 lines

Test #54:

score: 22
Accepted
time: 803ms
memory: 890536kb

input:

200000 1000000000 200000
3001595 14097 180920 1421096 1780325 345585 6321 536970 108359 1580188 188319 2209073 93991 62691 826278 1406374 2372360 1935896 2941114 1198315 1818930 159407 182164 1372932 1257296 2766581 1294716 1197130 1954695 2410246 229834 2266485 1553788 1983380 994284 250717 583339 ...

output:

464814966079
550459273553
392015576571
330654126238
295524188309
557539614122
499310432985
466739001540
206521426474
486492095002
347320572639
480630888276
303763127639
515800154811
277829449015
491439750254
514105778996
262998042597
477953258405
346983235644
377144239806
469569787980
320557580253
2...

result:

ok 200000 lines

Test #55:

score: 22
Accepted
time: 291ms
memory: 883096kb

input:

200000 1000000000 200000
180082 114229 64689 3671213 168564 3304613 22338 188029 59435 1582099 3442061 4783670 1380330 837820 4808200 64087 125886 480033 18218 3362487 4919646 2317099 146322 34703 161950 1209001 1370897 3727366 291020 4251841 3045276 830451 309 3555827 288899 4096315 1145583 3630161...

output:

470985272633
330577001589
439814644058
523567895118
501048366869
462793156984
291316709009
404699099167
290256852644
444960749007
473443352397
538540471582
643148473320
273919681872
601471298829
498808821230
571596269149
377997366417
384048397221
473618982159
527591322785
251088873050
454153652833
4...

result:

ok 200000 lines

Test #56:

score: 22
Accepted
time: 16ms
memory: 864112kb

input:

1 2 5
1000000000
1 1
1 2
1 2
1 1
1 1

output:

0
1000000000
1000000000
0
0

result:

ok 5 lines

Test #57:

score: 22
Accepted
time: 32ms
memory: 864808kb

input:

2 1 5
2 1
1 2 1000000000000
1 1
1 2
1 1
1 1
1 2

output:

0
1000000000000
0
0
1000000000000

result:

ok 5 lines

Test #58:

score: 22
Accepted
time: 364ms
memory: 886068kb

input:

200000 4000000 200000
469534105 869657262 201026406 706247703 720363334 591393274 140527583 403309685 669391268 962180948 533915565 370916928 278461532 572910588 36045110 106609732 314193846 638246398 749887226 95860789 609990162 263858083 933984169 92866433 774165117 800604654 471471901 384849200 9...

output:

1423533148858611
1203199106273073
65596428936959
1469120764498552
1338293611070646
1031513116329584
1293493771712425
1449296607273261
1448987449112301
1448657128680465
1448482174566858
1279397039368897
1449767211059881
857407952795972
1138358455373900
1449579740661381
1360981514512919
96162444990027...

result:

ok 200000 lines

Test #59:

score: 22
Accepted
time: 355ms
memory: 883968kb

input:

200000 1000000000 200000
3695933 725812 3938862 3188795 74871 179361 892126 899932 2952206 1461698 674172 2140411 3124478 253567 1930733 1468200 844171 3820729 3146995 2143636 3012500 3860711 1978473 458453 1011065 3915797 2489264 581391 3663430 200944 463051 2789062 329754 3391992 1666664 1278446 3...

output:

1313893005299891
1241413179669075
1013214888095897
1283956382437075
832938541171640
1357016581395659
1358632237670655
1358575371105735
1359617242208535
1358550490017855
1262000024359038
1090246621403288
1365726941260351
1070531999758396
1247397876139791
1294791538934294
931852209639129
1358682897483...

result:

ok 200000 lines

Test #60:

score: 22
Accepted
time: 720ms
memory: 884008kb

input:

200000 1000000000 200000
1000000000 395785681 450569981 397435194 399243043 815631194 396368986 396009218 395184318 399082057 396553759 395139833 405819304 397314248 404595065 396486584 396139088 398990743 397510485 561967645 408268414 396500176 395757782 456603560 396336452 399624664 396449945 3959...

output:

109920129587885069
378225816640797819
309690844924907845
267339736788532370
372175904770256958
321135232766545507
232563027043320134
124882843097505896
115857700588107460
202847102004389723
389602100695363841
235317792421863006
253135733788837109
220301266029980272
169917572575901836
214668686787005...

result:

ok 200000 lines

Test #61:

score: 22
Accepted
time: 1004ms
memory: 884044kb

input:

200000 1000000000 200000
1867594 524322 3615 25303 1538215 1040257 1623469 84359 1503219 419070 1873718 873101 203084 1842101 1034729 598281 1086715 1851042 1126586 240305 111153 1411689 755343 23669 1982825 1608454 2068771 2085317 1086469 19627 30122 1623595 138403 33439 1979692 1136830 173176 1415...

output:

306225753801
342005544451
436459567316
236781181877
341005923055
438745980019
330732109809
239627724290
562373111121
467513530464
239225732828
326333872737
326471417616
429675583322
552828882509
239263092986
288718695356
245227283983
471568113901
241072755476
241360488328
309136881480
242266843083
2...

result:

ok 200000 lines

Test #62:

score: 22
Accepted
time: 926ms
memory: 884464kb

input:

200000 1000000000 200000
941812 82062 38722 678737 68338 1072195 141897 141638 1002771 780921 137477 673465 918996 649333 406005 726096 496011 796418 346152 733114 890963 1057424 367441 343348 18182 83852 84060 786683 504660 44953 769252 734380 460070 272021 934209 71402 748582 323154 298122 7832 15...

output:

126436853796
465180591754
369107820231
281078670236
345259813302
494359911875
244336591685
484282259162
243752267165
460503945863
473839717345
439525600179
243099218281
505218592257
363750198100
244895817789
374199391493
465134123100
207985506641
513109340343
498612704121
213872806786
460528982772
2...

result:

ok 200000 lines

Subtask #7:

score: 18
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #63:

score: 18
Accepted
time: 128ms
memory: 869840kb

input:

49968 1000000000 49902
4944156 4815511 9240823 7764082 994590 2019985 2016609 9208180 4884222 2671715 5813918 8082427 5690017 4750252 6475214 2447878 7680249 8636430 6031922 1028528 2689700 1920015 8635882 5610090 9361349 7547902 5838245 7362790 240533 4193002 8850309 9498339 6763561 8096700 8938068...

output:

147810152409397
230645425302306
160441304695433
238455725485197
151518420272795
89423905495676
264381463305791
26003135435070
141049604858403
296733080938929
124815908476291
103612265239190
294621330837151
37345286479070
173931506215139
338013536841813
141749423526071
176332685271868
100579949751669...

result:

ok 49902 lines

Test #64:

score: 18
Accepted
time: 119ms
memory: 874800kb

input:

49992 1000000000 49940
2003853 7162895 5073437 4687230 8733918 4891966 9585850 2787024 4490309 8951710 3084011 2017075 6331315 9471938 4634613 7380596 9393089 7480628 8641884 7499894 7617210 7320006 2963810 8874914 1239543 2201128 367683 493261 8804646 2002828 2587756 2537102 5825294 2635981 2317652...

output:

1192124558433116
1981653758398286
131492379503681
1828718161216319
1958322264535191
2718288833339193
5545525628339003
1258671741508850
2038470552100596
158125886432957
7090062507557303
3100175107739547
4892661001763203
1058226003141961
6196281372191372
5857262064868095
5606420153949008
2324906833451...

result:

ok 49940 lines

Test #65:

score: 18
Accepted
time: 164ms
memory: 874460kb

input:

49998 1000000000 50000
86612478 86619871 86616593 86625839 125331781 89547617 86609503 91605216 108492497 86619067 108490056 102573028 100123774 86612275 108490617 100411209 86619293 108059385 86615859 86615581 86618876 102515951 86618273 108491746 86615096 86608662 86619989 95461459 108495689 10849...

output:

46588007956780978
16912616922030347
68816440058802851
59859890761572687
4324584371603449
41150830836227761
98964682918220242
16463790885070539
26923559929848641
34741982419511508
44081880582162509
16699955791334029
77486763689299350
47644447361354873
20590488138222942
42624882630816855
1943676197576...

result:

ok 50000 lines

Test #66:

score: 18
Accepted
time: 239ms
memory: 871964kb

input:

49998 1000000000 50000
147276 726692 85428 364478 261162 131999 5975 127116 255850 168671 8771 625319 250764 85078 20478 322021 673710 731815 271166 76570 89 641922 488850 545498 442407 235502 589490 10461 342766 204843 115760 21241 507284 353955 225355 238664 774748 121955 46987 283156 534477 11003...

output:

405732964288
389815059145
366883155022
480576233423
340957673244
276886953621
266040314535
315483568795
377498543215
287967570570
173379088116
425184427202
483249470808
316165910245
232288690777
326506749047
382101599711
319831809610
351707633713
302302658790
329611681562
313791814464
555167428970
1...

result:

ok 50000 lines

Test #67:

score: 18
Accepted
time: 292ms
memory: 873964kb

input:

50000 1000000000 50000
101262401 100536143 100365435 100184486 100243584 100284228 100198552 100169888 100093151 100108707 100205110 100169179 100143527 100103752 100198232 100161905 100137347 100040613 100060084 100062817 100081982 100106460 100093383 100082173 1000000000 1000000000 100066792 10004...

output:

47901860626149350
52232382847914312
90218649968616572
42631382542909940
36647005348668799
19354952802130848
97004968886549839
72457296305191529
29345838211855395
98177404260939908
68428525460081338
52198364330694788
77047427420663132
90114074853245639
16497709368555684
52426747053589783
459259106355...

result:

ok 50000 lines

Test #68:

score: 18
Accepted
time: 347ms
memory: 868632kb

input:

50000 1000000000 50000
524803 524795 524761 524776 524784 524341 524752 524739 524406 524723 524693 524102 519665 524065 524676 524710 524647 523226 523524 524248 524386 524653 524588 523964 523483 493454 504537 523362 524045 524572 524540 524663 524639 524320 523998 516523 521071 522484 523255 5212...

output:

520801563887
424710496333
564668062064
519086118087
236559320312
321406462613
379662255710
561248644898
429089082728
278382083590
414240297257
420461694620
287355108541
650311376394
659818333322
375016109570
554437046804
290748686350
502354098558
290351680545
639284778784
619269650687
283577630955
5...

result:

ok 50000 lines

Test #69:

score: 18
Accepted
time: 79ms
memory: 869684kb

input:

49967 100000000 49939
701117221 588646986 250635677 490819080 359508742 82912689 975640737 148951097 961563837 896611020 819557131 873501952 449957989 404623941 210177503 597538891 917200690 672566561 463554086 287628304 183478309 501551961 334152945 392987668 73509920 772390859 839262537 574096155 ...

output:

1207936031638
118747020859
913818453498
1644050354708
817223329561
706074172118
1672964443553
141066605382
1407145149269
1688560430308
1609407772178
1043340942347
1038662043365
85922400375
500088949508
644923691873
737314327467
815737936927
766241606028
749631859737
1277317624066
387011109167
129041...

result:

ok 49939 lines

Test #70:

score: 18
Accepted
time: 186ms
memory: 871860kb

input:

49913 1000000000 49979
99810504 99876070 99674859 99671842 121208696 109186471 99585115 115003368 99783969 99704451 99754263 99600541 100684297 99559144 99580001 99741149 99530973 99522901 116531393 100029706 99610891 99694872 99612585 102122420 99797856 99715650 99824358 99846342 99489115 99593830 ...

output:

75021083161705494
3687116444114934
33411361173222204
79126378651836082
56591495019562750
1482076097167512
56522532505669444
80695581931849593
52335904470582196
93704259183420706
4723285457422075
19569230326587661
42900419987961232
27328370250770456
22085284801732060
30297428495631749
974078059303944...

result:

ok 49979 lines

Test #71:

score: 18
Accepted
time: 174ms
memory: 870156kb

input:

50000 1000000000 50000
95103343 149617502 97279041 103251933 102014267 119508947 98353262 101480638 102415936 97068407 100900889 121682528 103955675 97356468 95203299 100042191 106251861 98783592 98593775 99517269 97086090 121697940 124801062 100042858 101718302 96554305 96694019 98129049 95005801 9...

output:

47008496048832832
6162516818596597
70951257176722118
29100759507151473
88166200321392274
64056598481648073
66156822633782521
66675935261416948
37939987904485364
49032894641764951
3714533953620752
11014195987141948
53746717224033312
17686292264159632
28488972544308603
30657743644699744
11360321361349...

result:

ok 50000 lines

Test #72:

score: 18
Accepted
time: 83ms
memory: 871744kb

input:

50000 1000000000 50000
103326936 219737816 232003032 108252350 99998460 99998868 99999526 99999106 100000799 99999969 99999445 100000048 104592491 99999283 99998538 100001653 99999850 102463592 99998771 100000433 99998474 141904675 100000723 99999604 99999476 99998172 99999577 99998668 99999804 1085...

output:

77396062051816824
74085671312607659
95614601954590434
1170817688923755
68322185067625298
21395762642211971
5865433735431284
87051278899282142
10178618350135518
17930038769889394
66935732691981770
50355134911706497
91271949883795850
22072995466334107
65606069221844581
8650047742615250
902729326985898...

result:

ok 50000 lines

Test #73:

score: 18
Accepted
time: 284ms
memory: 869812kb

input:

49975 1000000000 49931
84211 55336 252755 15254 246875 187979 49163 126582 104827 58559 36655 17384 81160 253364 81593 1088 6290 14081 251659 4443 118797 60225 53745 162953 15582 244560 117951 269103 42702 6237 50099 3903 21127 72300 9840 56844 214011 45170 68840 3741 273694 180905 197439 63969 8999...

output:

575538275842
300512392765
469007988507
267686303867
349105411769
426565773268
238390907849
587417902212
533805438581
543593700291
366847933070
532552325620
510568807260
496054751124
415287402994
471817548429
466789246262
29802468507
455288062652
310589058150
258539566001
285101078148
570433865779
22...

result:

ok 49931 lines

Test #74:

score: 18
Accepted
time: 244ms
memory: 869716kb

input:

50000 1000000000 50000
754556 604242 30208 542679 448867 603232 169511 354225 393639 16940 2193 368268 43224 102249 241678 534317 671413 332623 11291 665173 445259 11441 578280 424891 314203 550049 313612 20072 139534 290088 62216 145495 73893 192190 175869 47215 655361 3515 619712 42608 701347 6795...

output:

421930105097
547218226844
543311314309
361472439272
438190520204
509582782153
230599478684
307470715330
309194170439
285783941979
258161362851
537532959643
429828501604
81224380835
188673519826
467110827147
605775726908
316487391961
532219227736
187828657740
567658393497
314324203311
209209137040
19...

result:

ok 50000 lines

Test #75:

score: 18
Accepted
time: 90ms
memory: 868152kb

input:

50000 1000000000 50000
1134165 347193 180933 1053859 2312 372547 1078267 1083658 382385 429520 845927 395979 56002 1225717 5183 967972 32075 9216 287034 751452 628631 7947 130616 668468 381268 494670 63653 785586 63015 1106385 403603 690434 834061 44355 63162 1080532 968842 1138436 352645 340186 112...

output:

349435172399
586604962022
606751966296
387956419936
324606135217
566474644490
481850670002
415647494771
497633859377
242556355951
527762334456
385191095006
290638807846
404327548248
397808031771
263595093054
593329584989
626157577441
353475221277
368014304022
575210926858
504674983709
508778344452
4...

result:

ok 50000 lines

Test #76:

score: 18
Accepted
time: 421ms
memory: 872016kb

input:

50000 1000000000 50000
274244 273876 274594 271268 273839 274432 274721 268995 270279 273020 273609 274253 273402 274649 274806 263610 265880 267775 267994 272814 272654 259494 271788 274185 273958 272774 272647 274201 274141 274851 274655 262196 233119 253829 265810 265620 264446 264733 265915 2722...

output:

55136692089
250834673323
344674479053
78834875741
236060056920
126799931193
204097179679
123034533236
400642413809
145026515187
220587028923
222928708321
273855371961
222554351044
163751461798
177715135672
177886265475
335250135690
163796577274
275368772016
344319231518
181453404240
287633135961
103...

result:

ok 50000 lines

Test #77:

score: 18
Accepted
time: 51ms
memory: 864140kb

input:

1 2 5
1000000000
1 1
1 2
2 1
2 2
1 1

output:

0
1000000000
1000000000
0
0

result:

ok 5 lines

Test #78:

score: 18
Accepted
time: 39ms
memory: 864740kb

input:

2 1 5
2 1
1 2 1000000000000
1 1
1 2
2 2
1 1
2 1

output:

0
1000000000000
0
0
1000000000000

result:

ok 5 lines

Test #79:

score: 18
Accepted
time: 115ms
memory: 868856kb

input:

50000 4000000 50000
382301843 633396262 827855850 48475432 887864673 687939704 607616554 120228975 79407125 84139528 423498566 584293361 905756486 849324647 151892270 764293038 694946413 931202330 770860665 393234279 567989976 686902309 361150294 994395718 504779657 289443347 75618549 598869058 3999...

output:

424106350335457
1125014398223421
455079888665385
766178112932568
527984154416466
619833051400100
1123830521865158
1125226434262619
148338745040548
971461232920796
414954093909887
622070581630960
512228784337357
895851145651473
881736770328828
969296466259934
537957040677244
1123619626410926
57196391...

result:

ok 50000 lines

Test #80:

score: 18
Accepted
time: 123ms
memory: 874440kb

input:

50000 1000000000 50000
3449221 2102673 2176708 696083 2506047 2432759 3297061 3076792 540192 1174 269187 243193 526878 3817928 3323318 2451113 2785608 3544672 707021 382876 3819594 2558361 595693 1282087 2296605 3089284 3989615 2265754 1949186 550386 2291305 899744 2631735 3181412 367832 3727 214611...

output:

508181937298650
46279739241752
1018973544656104
1265677558399170
629480405891489
48385337538677
806138663484583
1042571321208996
818149646972220
569452420814038
123280847744172
1265741747019876
714734464602640
286481219912146
1265727961782487
756563441554218
716054097571375
171322023576204
126565268...

result:

ok 50000 lines

Test #81:

score: 18
Accepted
time: 190ms
memory: 874424kb

input:

50000 1000000000 50000
99576593 98734697 97524742 97810575 99289324 98135482 97797653 98620702 97695682 163605131 97936493 98333350 98003113 99273070 97575097 98634231 97462634 97943735 97594517 98038106 97630836 100822998 98135923 97939696 106718214 98140511 98659048 97615297 98503308 101723090 992...

output:

82950625033043526
74253135347159837
60884710255754091
84740747428531022
66956889787680848
21526721179617801
46875382323933928
26884330743856575
51455205640946454
86503964949033473
66869460714280650
22310817075948757
20187728367206704
38976799423009773
87817556427002773
38579576546564774
699333023072...

result:

ok 50000 lines

Test #82:

score: 18
Accepted
time: 307ms
memory: 870740kb

input:

50000 1000000000 50000
447243 16285 126704 6176 53588 87042 261073 395620 76727 336604 47553 487612 219730 46634 431675 305257 1800 19013 214222 2324 18455 394370 442219 419889 171 230338 2889 518616 454899 53901 449709 69183 414430 43 104954 458113 109502 302689 83202 6297 14561 290169 80230 90905 ...

output:

373917380256
378326235442
422123400
72615600
278817150388
375477068213
268375058031
268753664685
223496700
326275942584
88046683618
155838421208
3782880459
294486412398
375408863513
179078632044
261331037610
158744400
350019357893
157523165141
378079747280
191464466775
87594736848
278073519674
31828...

result:

ok 50000 lines

Test #83:

score: 18
Accepted
time: 272ms
memory: 872216kb

input:

50000 1000000000 50000
233570 4572 265455 26312 194346 256089 156368 192860 91078 252234 27682 172842 31727 92384 16930 162122 84095 911 184949 158481 58631 244106 179366 1656 115521 5587 265185 123234 9568 32678 40157 158757 8050 101042 35141 10232 132569 155735 153746 223237 249962 3881 119542 253...

output:

121669595177
283246371516
278267972133
223194073315
261820205854
321376970576
313046043702
180048804510
362418761931
223964070367
405564550265
248415535249
257550775258
254709096137
166837269756
295074013994
277887325188
387123587634
330498043181
342157238429
229396986326
362931606211
239179644224
3...

result:

ok 50000 lines

Test #84:

score: 18
Accepted
time: 171ms
memory: 869124kb

input:

50000 1000000000 50000
116148600 96494196 96846514 102901566 95839781 96755789 97247372 114734508 95819490 95644709 95633495 99580181 106565039 98930619 95824589 98207917 96246800 97927785 97962897 100846363 95697463 95758986 106405173 95904121 101525399 98757319 98937921 96940376 102559409 98572697...

output:

76042316296232337
79190014018617130
50958903488352320
45733597598894250
84359580387743721
7411365772197816
82484049041815905
51983488354616909
92619695827498568
84091249944402926
30168374771314228
62304529338472472
46777277486973575
42293296273527556
81745618788159884
12278184899304622
1844182841943...

result:

ok 50000 lines

Subtask #8:

score: 20
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #85:

score: 20
Accepted
time: 483ms
memory: 883616kb

input:

199944 1000000000 199998
3659533 4129764 2805046 2202843 1104480 4726302 3256627 4718878 3065155 3205060 1727152 648435 16108 3459383 3234917 1263409 137758 2300376 1968442 3756615 3501269 1470825 3209654 4187345 3670454 4104664 4852185 3092539 1620047 91724 270618 1126822 4691006 817661 4763285 244...

output:

342962754538145
103763501652048
312549929066120
147587261824732
321717435983835
362886797026501
257429721351274
208181578417858
173518779541738
225848046878593
314377776044167
307025863112859
80521666520572
213508173123723
286846528281379
407978368396659
438279470346056
241280702572375
1309487714858...

result:

ok 199998 lines

Test #86:

score: 20
Accepted
time: 449ms
memory: 885632kb

input:

199919 1000000000 199928
7675345 5765478 16500751 18534935 5833389 8123297 19051405 11284931 19393988 16472785 2168521 998756 12059777 3111318 13103581 4773771 12867308 13095896 18912689 19583628 409950 19278138 18932993 7048139 10670259 17241324 88422 1866789 2137105 1272284 14867767 11389756 10728...

output:

315667644157743
402292426340519
136433293517745
58144671784339
157508663667581
165950783982894
181201817816055
382694691112720
166624994688427
302004459653020
83239949956524
106556058065649
256814925138653
363504838426232
236368812153813
378365749322573
103870730220691
388426460848082
24939311762443...

result:

ok 199928 lines

Test #87:

score: 20
Accepted
time: 565ms
memory: 892048kb

input:

199977 1000000000 199963
15188316 36385563 7175602 27995278 35830541 34570755 7041643 36955644 10179999 39269687 35465018 390615 29295113 9169514 16447684 30106757 12834064 37014855 26529335 18684660 40327721 48913688 31067227 6430292 10586985 15368768 4233290 10408682 49628692 14271055 25766380 989...

output:

17568172955655925
18852615618289658
7385402224445770
30613210030343194
23844961374617634
26398872874022339
8243037545930323
20078923946421775
29936852154260786
1470569065100681
1152431423608027
6150235408677542
6388331450452069
12982294419676152
631217464717484
16918414634664829
46603524180265
20192...

result:

ok 199963 lines

Test #88:

score: 20
Accepted
time: 524ms
memory: 891932kb

input:

199929 1000000000 199964
16803535 5544700 1945683 15598220 4234637 15687570 13711404 15073107 3908433 12179635 19423146 14968463 1598906 566780 6757416 8386209 10526636 13549543 8495320 5920246 3585549 11265791 3722905 367131 7742026 12598731 813504 3472950 7017760 2518783 6958148 3183827 3880359 73...

output:

3838504619364934
17401465673240349
3565002026234993
226336226104249
7498557689497922
10817657585181084
5463068279429631
3669001788101485
422827305282077
6155679517113447
2831517741763367
9495417926298571
6980276925108591
794837787170127
4890466985700338
4614769462620723
9633518199926470
151738184564...

result:

ok 199964 lines

Test #89:

score: 20
Accepted
time: 540ms
memory: 895668kb

input:

199905 1000000000 199910
472842482 970828262 967582409 755968258 691246779 469820735 890421540 532556510 453496289 953954288 66697980 404188302 176635270 530336737 604720312 573344618 287505672 603695908 974439063 471414389 195532727 186319969 402550931 558728958 733940999 452104705 567361030 694877...

output:

16911400269980527
9292922603202836
7847306099136984
8181393655216694
934450853723521
2943011207054110
27921134567439557
27458930115447750
7175464069517944
5313361714533266
9640562614808424
10048150699982783
13278895597112586
8637163200720360
2471352839975261
11960791930846188
19336941650756200
12233...

result:

ok 199910 lines

Test #90:

score: 20
Accepted
time: 806ms
memory: 891424kb

input:

195533 1000000000 200000
364471845 411674378 399568735 382220663 337714356 411679910 349043821 411676520 366079149 383879459 411671085 411687927 369558282 337713729 411683738 411738564 411679219 337715517 355587518 411940539 384240561 411692461 337714394 411705180 366958659 411700423 411684015 37023...

output:

200195011297245890
232205767131041432
136054178757272676
168928196347808848
275619775920372628
266574672061710900
135278334333238291
136740203434912765
104512339243157992
283336782209141745
190861231636938320
119258726762344238
74485969732829407
92848715870361535
169259377020047015
20756695270926882...

result:

ok 200000 lines

Test #91:

score: 20
Accepted
time: 1137ms
memory: 893336kb

input:

195533 1000000000 200000
4991669 12553 1754865 396186 1560930 1912616 160288 232655 3403416 2136776 3331995 450315 1345092 4982017 2982268 474 18881 2925608 1990224 4081256 4868755 1517162 4418860 4355902 54553 540930 24267 802307 1891100 109647 3187314 4462252 129165 756462 4326698 683796 710065 44...

output:

323910553027
257129911102
386342700390
442687684235
440908566949
118674976428
287396694620
309631474054
457880840406
326274585415
479698277790
252919061932
356350031042
529779587282
77156877625
505963069317
396465034515
603949975236
588419567810
364642111187
323228062773
217733640857
230972747681
29...

result:

ok 200000 lines

Test #92:

score: 20
Accepted
time: 1518ms
memory: 893360kb

input:

195533 1000000000 200000
29093 201241 491278 34827 581205 327494 423466 361475 260134 111146 25377 149816 16450 102066 389839 124903 513615 526945 481442 45947 243534 317731 249978 581870 44328 466304 410840 513939 463853 530965 198671 343623 12316 450491 428837 259715 95804 269325 579490 36336 1708...

output:

397971001122
193545550532
585150382906
378095492079
94843443315
124620766553
370185914567
545603398968
255347047318
509258655250
239338318988
341836260767
273443028526
445347211941
232852909399
185371272685
372755271346
170435213509
406656003859
387426832795
276602108283
314070394593
244722345393
49...

result:

ok 200000 lines

Test #93:

score: 20
Accepted
time: 1966ms
memory: 883416kb

input:

200000 1000000000 200000
401886509 400665303 400866832 400528281 400328941 400799911 400568789 400281852 400314545 400146634 1000000000 400400936 400350046 400244159 400401652 400171332 400180279 400299497 400312122 400075124 400074793 400304972 400298601 400312497 400220038 400222310 400233309 1000...

output:

109443244079287773
277320008502917476
63414249032809292
323712547774502026
158279621595201832
48470878322854023
194342071101817844
104301420550201959
216315510816774118
196070565706951213
214030397992394063
197523517533966099
5821765004862548
166318906172034521
327625231606769906
195279154797290452
...

result:

ok 200000 lines

Test #94:

score: 20
Accepted
time: 2867ms
memory: 883464kb

input:

200000 1000000000 200000
1098922 1098911 1098913 1098878 1098821 1098868 1098902 1098828 1098861 1098684 1098781 1098790 1098837 1098893 1098806 1098564 1098714 1098842 1078851 1098618 1098609 1098773 1098670 1098675 1098749 1098813 1098501 1098729 1098884 1098583 1098663 1098260 1068681 1097684 109...

output:

422597129871
434102458934
528381413315
451658851087
493072285498
263833044745
387267481042
227876949401
579187383412
204273818257
559155938815
395012124722
326732028172
253002353466
286051633083
506832149676
569845325922
427130720951
307882244662
676088686748
281098453428
346222850070
294014637944
4...

result:

ok 200000 lines

Test #95:

score: 20
Accepted
time: 280ms
memory: 885512kb

input:

199992 100000000 199923
691057855 347386725 931913186 876670511 591948665 956207155 657210767 248205836 931852581 250760226 625131061 134379843 697088400 881297915 816275203 851484745 627724643 675158675 165287190 995948740 438375387 948697637 129069275 198782481 921516119 582044920 873795141 511944...

output:

114771089290
39069301740
111058465712
49879120873
96065420119
65619971322
268352725604
284524676137
284855706601
309103916768
289287485336
81738577303
251862097825
89485080516
121639676923
228696489714
205912117773
165795284654
163371083749
159847043245
234443266577
275390254873
46150143655
21480233...

result:

ok 199923 lines

Test #96:

score: 20
Accepted
time: 811ms
memory: 885752kb

input:

199948 1000000000 199942
398896071 398937688 398698877 400206336 398695429 398577123 398728288 400030948 398469278 399854157 446660729 410905088 398404177 400490326 398204654 399878860 398755191 399194753 399340968 400712974 398703151 554635010 400013660 399936140 399224247 400468287 464549552 40012...

output:

82969054966231772
95321444329296302
125196823889675326
261928100955832524
217394496101488469
379061031836207418
142967740570390440
131759658375125373
64830807665475799
368453221859102348
399146207336016942
161946394985183537
153986701508140180
366573266419776488
13067966506579967
355736309799752562
...

result:

ok 199942 lines

Test #97:

score: 20
Accepted
time: 801ms
memory: 886820kb

input:

200000 1000000000 200000
391134200 386990016 390407254 380991644 380695709 373504189 385167500 414400776 377527510 403425740 393528158 379957768 397048718 377386601 399367019 376925251 386444312 522788292 392894132 380399094 388471392 373555300 400528356 371226303 371885608 378967408 401326840 41834...

output:

332798124202373551
352940223042994995
163935064001567773
365852130463158811
25907040452324776
262584672240999638
245102189710129071
115672185367673294
357194826954301662
245798485524611138
160654585957251056
128910760146894817
32559104254228656
140853132157479820
102568782117018773
2009248845108750
...

result:

ok 200000 lines

Test #98:

score: 20
Accepted
time: 209ms
memory: 883216kb

input:

200000 1000000000 200000
399999485 400002003 399999092 400000717 399998790 399999442 399998406 400000664 399999719 400001610 400001155 400000967 399999150 400000898 399999127 399998926 415991245 493748402 399998392 399998992 399999637 399999224 399998962 399998530 400000807 399998650 399998480 39999...

output:

267785107424441778
58960094038966136
201406883165164049
252267439427671884
169484972580053943
159607040844700603
333683919114599896
374814384610461988
181034295426222744
296757907516395035
250554368531050868
161196381773571025
230302898412905298
371435551620455100
194673850107914355
1585188669091485...

result:

ok 200000 lines

Test #99:

score: 20
Accepted
time: 1357ms
memory: 883636kb

input:

199957 1000000000 199916
668099 724534 72685 558179 723778 7866 850860 860827 785938 73679 257660 746387 2757 13209 134432 81540 404884 10617 459896 943519 495765 767286 1061305 1006798 841192 109651 967466 918712 15879 61653 719648 363 541373 894801 943894 519993 92671 318145 1040612 395981 552608 ...

output:

405207993850
441733344926
559724365794
521215292285
478376697562
501478267857
270696547492
466548050964
295032291124
226804491288
315344987795
416912411165
403779972040
387266365439
315766732431
240269015124
277538800800
472461996796
176760812385
473670985969
511341906769
371293182832
498063505404
5...

result:

ok 199916 lines

Test #100:

score: 20
Accepted
time: 1343ms
memory: 889740kb

input:

200000 1000000000 200000
1042348 1047326 14988 614024 2772068 389486 70951 713853 1516002 371163 23979 2277074 806997 2557542 5026 34163 2500012 1574589 2962293 1346737 2567374 1506555 2773741 867062 8217 1913111 598599 2012076 2900741 1193288 834744 1658162 322161 761249 3088165 2035850 2504640 295...

output:

367638291575
368596458853
84327613684
553559025733
576139607677
577967854400
238675442689
411239747542
418048440679
462698383478
257204660054
414124911646
175404857303
272896776111
525802579563
479364513271
252951910549
397828118008
236067917967
188156981244
319533743047
226568934651
294396064167
53...

result:

ok 200000 lines

Test #101:

score: 20
Accepted
time: 320ms
memory: 884600kb

input:

200000 1000000000 200000
2378082 419913 1062202 1219268 928014 3412508 4591785 4275456 1579233 1386731 3547548 2565340 20500 1723453 772501 126687 2409042 4471679 256491 31553 4772046 761112 4438054 1030983 3943789 811681 1505175 3838064 558589 495750 3041378 1591120 1050188 981069 3873579 2462526 3...

output:

563702368432
443127470644
485742089102
332798697798
438611133335
581966874473
275242978768
597942862457
98531422494
257087199703
408938546603
632681023788
442969042929
269582210498
299986008789
455776280800
631442784593
689353169646
555531652067
423786393378
320516230668
388511987711
289443877504
61...

result:

ok 200000 lines

Test #102:

score: 20
Accepted
time: 618ms
memory: 892040kb

input:

199997 1000000000 200000
392823731 370874579 413571255 413593375 413579392 349474106 388261589 413594856 388424188 403844772 413598964 358439779 413574374 361068410 413579946 349751388 349781113 396610642 413574222 413595411 349549742 413575325 349672262 349721386 413569154 413593599 349548644 80543...

output:

268845573368949095
284373240669677994
64563248280571206
129863928218831164
92904452498451053
261569897858180948
57626874849835652
203939585563610745
179411062330953097
178510679993358750
309071252959832469
161220142729434643
359468059929644084
345223062319042353
260194304705024277
354058255816446716...

result:

ok 200000 lines

Test #103:

score: 20
Accepted
time: 1163ms
memory: 892848kb

input:

199997 1000000000 200000
340834 39396 96097 624567 18605 568317 645026 979098 343299 22091 52413 308771 7829 310211 51893 527731 41035 616450 72832 246203 843062 263930 6764 829793 829456 1048629 453676 266202 144713 351334 10775 43320 1088277 650124 834438 95036 487716 602120 266572 1416 827793 370...

output:

262374968186
156152524569
202448963408
320644746126
214186804651
462631541833
237335624127
452521537807
115441195463
193976463737
323871991515
137912644607
445267298694
205547678404
277364085529
124330885157
361622022194
160879433529
277666001576
358653845933
213273156023
210463655687
328068667695
1...

result:

ok 200000 lines

Test #104:

score: 20
Accepted
time: 1782ms
memory: 885488kb

input:

200000 1000000000 200000
401301962 400574960 401075032 400524754 400367417 400675155 1000000000 400297053 400294439 400197658 400186257 1000000000 400539146 400410953 400455669 400129498 400256755 400138741 400184064 400172435 400101343 400108910 400113742 1000000000 400267424 400392577 400431793 40...

output:

191976659741198665
257641028308381615
308680456956053706
274938542046784595
44540655817073246
308161378894122408
361852839219034926
19779054896022263
123663589226055430
333615434488943211
41195175938539477
62011960877461339
330108431671025615
270546741166785981
248465300198409718
28562572548819047
3...

result:

ok 200000 lines

Test #105:

score: 20
Accepted
time: 3721ms
memory: 883400kb

input:

200000 1000000000 200000
1099860 1099762 1099856 1099566 1099751 1099848 1099412 1099543 1099032 1098879 1099600 1099839 1099725 1098854 1099386 1095977 1099275 1098962 1098936 1094732 1097435 1099519 1099196 1099825 1099835 1099304 1099687 1098354 1098838 1099147 1099219 1029703 1094077 1098487 109...

output:

369572765906
249438619879
457437556511
286792626999
188968766384
153542264073
241590245279
311706916722
339551879010
309281430614
241772807726
381968061555
286259313229
397198329908
454871108087
253342280133
287862238853
377844829846
295106035212
85759427832
429570823760
255779732301
239515196612
21...

result:

ok 200000 lines

Test #106:

score: 20
Accepted
time: 3368ms
memory: 883448kb

input:

200000 1000000000 200000
1088208 1084621 1089699 1082678 1049592 1089159 1093778 1070430 1073918 1046715 1047289 1084450 1077133 1096372 1093339 1061369 1066711 1065981 1063936 969001 1032524 976275 983307 1079195 1081650 1076989 1070734 1094491 1097843 1090865 1090584 1047585 1053003 1062896 106028...

output:

260661080441
166522388452
238661256131
274633853255
145992673041
216194956050
443204099976
249439353782
183250304376
213396140613
349060279382
185939971542
190026500020
207945858492
299493149607
215565200051
298907344570
295344626209
411162647561
346044985525
355272308971
238783493699
241492573526
2...

result:

ok 200000 lines

Test #107:

score: 20
Accepted
time: 23ms
memory: 864200kb

input:

1 2 5
1000000000
1 1
1 2
2 1
2 2
1 1

output:

0
1000000000
1000000000
0
0

result:

ok 5 lines

Test #108:

score: 20
Accepted
time: 56ms
memory: 864176kb

input:

2 1 5
2 1
1 2 1000000000000
1 1
1 2
2 2
1 1
2 1

output:

0
1000000000000
0
0
1000000000000

result:

ok 5 lines

Test #109:

score: 20
Accepted
time: 430ms
memory: 886028kb

input:

200000 4000000 200000
372000666 643097582 476594300 925376113 596876587 608812487 793598868 352795834 324754913 229579583 774997901 816444169 742322951 767640217 14699658 274456861 375561256 332561869 422129691 163467236 240010071 624277496 43957594 455296762 558184546 622406935 783196331 423453730 ...

output:

2487650561314183
2889192001776714
2180361339616649
1146308854306387
2149305265220287
2888919898970737
1975417133181401
1057849894077472
2572072112157472
2513741307997018
2805647598732259
1896475044397367
1045524405262161
2485769849595060
2361563144302730
1839526056887157
2557099840899001
14114318659...

result:

ok 200000 lines

Test #110:

score: 20
Accepted
time: 452ms
memory: 885996kb

input:

200000 1000000000 200000
2610224 3455622 1713076 3995794 1598778 3884170 817766 651335 3074384 2164498 1635534 3283407 2719751 1675270 2414132 771574 2319446 1254263 2209417 1276615 3407814 2883749 1304888 3151962 2435172 3001581 3154387 297810 428965 2554143 3352854 1006012 530994 2828615 2764864 3...

output:

2121824667620890
1675254619987414
2723569495020950
1321935926557051
1315408402491653
1783393786604858
2232883775756281
1106536016643723
2723597251817303
785408006469122
2280481452989633
1469553862725900
2128766472209169
2231981733316843
1944832161019807
1453972717983019
2723574677012908
272362718141...

result:

ok 200000 lines

Test #111:

score: 20
Accepted
time: 986ms
memory: 884020kb

input:

200000 1000000000 200000
399935686 395115202 395702818 394641728 394945894 395448505 394911700 396824757 399377970 395852227 395481891 464209750 396936822 395028551 904524596 397920653 395008640 395283370 396179506 394680544 396154976 395579925 395899998 396888919 395229235 401403156 395018104 39641...

output:

294943262316231807
363659326666758646
253221525261702057
344139341169158374
97053528462123688
100620791110199696
322819324383174324
15487827484794757
269132533128108662
188981951663749311
61978287016240743
314517146070907718
395711332798278043
169333074382274993
240991846121362235
45296615185351522
...

result:

ok 200000 lines

Test #112:

score: 20
Accepted
time: 1620ms
memory: 886084kb

input:

200000 1000000000 200000
1864409 332985 58085 5725 260720 171011 1829210 518752 3237 257282 2035983 189786 828511 1828754 1107424 1860370 47544 281499 204440 2045536 4021 447574 482290 1138830 976874 139508 2076135 1752870 12012 238584 1335445 1924545 1818704 1201686 136513 759168 1523233 5002 28007...

output:

351414654410
283310287515
419253245338
283306900363
354072768860
324414951224
283804045638
283676371025
397342235471
346117741823
284202438070
282966145866
412734935322
283537075922
389312667291
325232813987
323779887017
250782772678
284422220677
25177075803
302069616738
285190871348
415802402447
28...

result:

ok 200000 lines

Test #113:

score: 20
Accepted
time: 1540ms
memory: 884456kb

input:

200000 1000000000 200000
930032 331411 152024 708888 225471 102065 63520 29718 349419 21486 685940 1068692 312260 486153 139753 565409 16966 698278 86786 527663 939681 433261 880436 911537 969080 396834 770026 333528 200663 14681 858629 4680 337430 127342 38236 185338 487080 162707 183166 838747 106...

output:

360318085910
238517297895
312982657778
291938980386
327439088378
443693492710
282721616694
363865953270
128928725676
355515108328
411446222210
253346055527
298156107503
69085471202
608053326789
386252081267
245126953468
312152876783
331927472694
362408363192
470335296202
411335289055
220467251454
32...

result:

ok 200000 lines

Test #114:

score: 20
Accepted
time: 980ms
memory: 885828kb

input:

200000 1000000000 200000
400148288 396908738 398054789 397174412 396850002 396927134 397566627 399204496 397709599 398113305 397095317 397081971 398439803 397477617 397972287 397165168 397865529 399964164 439491548 397906457 396861766 396870526 399983478 397791394 399171821 398452151 396891687 39686...

output:

2761556729910997
264037823638654069
134117323298028889
60090881079049877
109822683037475562
50615749483517493
338489542725149166
43252800510346140
69676522351139360
107967943687038282
251048801609830557
204941587230377504
239556577704704520
274017191011399717
212141132592335959
325922680926726989
18...

result:

ok 200000 lines

Test #115:

score: 20
Accepted
time: 2312ms
memory: 883628kb

input:

200000 1000000000 200000
2097745 1607622 563941 1838518 1460365 217332 1880140 1773179 1134057 592996 321819 451328 310922 768575 831414 244352 1543898 876813 1880617 223198 427511 1355432 1425036 677163 59370 102816 1212285 1613883 472375 968248 1932683 78146 578440 1042796 1979559 165015 1260991 1...

output:

823838111515
516982097539
465820656111
637920884051
359123542557
675778432311
558735914106
586316972286
105785785301
553452899034
673166640087
855864690589
991507223220
694310462768
574476745987
524425765279
489444368513
644932238563
609217399025
726843350359
724334349769
796356390609
799565082561
6...

result:

ok 200000 lines

Test #116:

score: 20
Accepted
time: 1095ms
memory: 883560kb

input:

200000 1000000000 200000
401095689 400047667 400043557 400046168 400043496 399982832 400044379 400051500 399685197 400050995 400044737 400038934 400042390 399559157 400058702 399730993 399728641 399540319 400058618 399721631 400039623 400037430 400045384 400043189 400051605 399931150 400065255 40004...

output:

62265504698366026
257156441740990693
102052681361059340
316531945318575986
58682281569031176
59056684432939254
200679591049655732
161005802896840584
237712433230049538
116796374049587877
60482594316978706
167181915630372578
65705300119410882
228641047577264455
42865739266246648
120830636468111182
39...

result:

ok 200000 lines