QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#338057#4077. 뚫기hotboy2703100 ✓537ms15624kbC++146.2kb2024-02-25 17:20:582024-02-25 17:20:58

Judging History

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

  • [2024-02-25 17:20:58]
  • 评测
  • 测评结果:100
  • 用时:537ms
  • 内存:15624kb
  • [2024-02-25 17:20:58]
  • 提交

answer

#include "breakthru.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1LL)
#define MASK(i) (1LL << (i))
#define MP make_pair

namespace{
    const ll MAXN=1e4;

    ll n,m;
    pll a[MAXN+100];
    ll eval(pll times,ll costX,ll costY){
        return times.fi*costX+times.se*costY;
    }
    namespace seg{
        const ll SZ = (MAXN*2+1)*4;
        ll A,B;
        pll tree[SZ+100];
        pair <pll,ll> lazy[SZ+100];
        pair <pll,ll> default_lazy;
        vector <ll> val;
        void init_value(){
            val.push_back(0);
            for (ll i=0;i<n;i++){
                if (a[i].fi>0)val.push_back(a[i].fi-1);
                if (a[i].se+1<m)val.push_back(a[i].se+1);
            }
            sort(val.begin(),val.end());
            val.resize(unique(val.begin(),val.end())-val.begin());
        }
        void build(ll id,ll l,ll r){
            tree[id] = MP(0,0);
            lazy[id] = default_lazy;
            if (l != r){
                ll mid = (l + r) >> 1;
                build(id<<1,l,mid);
                build(id<<1|1,mid+1,r);
            }
        }
        void reset(ll AA,ll BB){
            A=AA,B=BB;
            default_lazy = MP(MP(n+1,n+1),0);
            build(1,0,sz(val)-1);
        }
        pll better(pll x,pll y){
            if (eval(x,A,B) < eval(y,A,B))return x;
            else return y;
        }
        void push_minimize(ll id,pll min1){
            lazy[id].fi = better(lazy[id].fi,min1);
            tree[id] = better(tree[id],min1);
        }
        void push_add(ll id,ll val){
            lazy[id].se += val;
            lazy[id].fi.se+=val;
            tree[id].se += val;
        }
        void push_all(ll id,pair <pll,ll> val){
            push_add(id,val.se);
            push_minimize(id,val.fi);
        }
        void lz(ll id){

            if (lazy[id] != default_lazy){
//                cout<<"PUSHDOWN "<<id<<endl;
                push_all(id<<1,lazy[id]);
                push_all(id<<1|1,lazy[id]);
                lazy[id] = default_lazy;
//                cout<<"PUSHDOWN DONE "<<id<<' '<<lazy[id].fi.fi<<' '<<lazy[id].fi.se<<endl;
            }
        }
        void reupdate(ll id){
            tree[id] = better(tree[id<<1],tree[id<<1|1]);
        }
        void update_add(ll id,ll l,ll r,ll l1,ll r1){
            if (val[l] > r1 || l1 > val[r] || l1 > r1)return;
            if (l1 <= val[l] && val[r] <= r1){
//                cout<<"SUS "<<l<<' '<<r<<' '<<val[l]<<' '<<val[r]<<endl;
//                cout<<"BEFORE "<<tree[id].fi<<' '<<tree[id].se<<' '<<lazy[id].fi.fi<<' '<<lazy[id].fi.se<<' '<<lazy[id].se<<' '<<endl;
                push_add(id,1);
//                cout<<"AFTER "<<tree[id].fi<<' '<<tree[id].se<<' '<<lazy[id].fi.fi<<' '<<lazy[id].fi.se<<' '<<lazy[id].se<<' '<<endl;
                return;
            }
            lz(id);
            ll mid = (l + r) >> 1;
            update_add(id<<1,l,mid,l1,r1);
            update_add(id<<1|1,mid+1,r,l1,r1);
            reupdate(id);
        }
        void out_tree(ll id=1,ll l=0,ll r=sz(val)-1){
            cout<<id<<' '<<l<<' '<<r<<endl;
            cout<<tree[id].fi<<' '<<tree[id].se<<' '<<eval(tree[id],A,B)<<endl;
            cout<<"LAZY "<<lazy[id].fi.fi<<' '<<lazy[id].fi.se<<' '<<lazy[id].se<<endl<<endl;
            if (l!=r){
                ll mid=(l+r)>>1;
                out_tree(id<<1,l,mid);
                out_tree(id<<1|1,mid+1,r);
            }
        }
        void add(ll l,ll r){
            update_add(1,0,sz(val)-1,l,r);
        }
        pll best(){
            return tree[1];
        }
        void minimize(){
            pll tmp = best();
            tmp.fi++;
            lazy[1].fi = better(lazy[1].fi,tmp);
        }
    }
    vector <pll> hull;
    pll solve(ll A,ll B){
//        cout<<A<<' '<<B<<endl;
        seg::reset(A,B);
        for (ll i = 0;i < n;i ++){
//            cout<<i<<endl;
            seg::add(a[i].fi,a[i].se);
            seg::minimize();
//            cout<<"WALL "<<i<<endl;
//            seg::out_tree();
//            cout<<i<<' '<<seg::best().fi<<' '<<seg::best().se<<endl;
        }
        return seg::best();
    }
    void dnc(pll L,pll R){
//        cout<<L.fi<<' '<<L.se<<' '<<R.fi<<' '<<R.se<<endl;
        ll Ex = R.se-L.se,Ey = L.fi-R.fi;
        hull.push_back(L);
        pll mid = solve(Ex,Ey);
        if (eval(mid,Ex,Ey)!=eval(L,Ex,Ey)){
            dnc(L,mid);
            dnc(mid,R);
        }
        hull.push_back(R);
    }
}
void init(int N, int M, std::vector<int> Y1, std::vector<int> Y2)
{
    n=N;
    m=M;
    for (ll i = 0;i < n;i ++){
        a[i] = MP(Y1[i],Y2[i]);
    }
//    cout<<"DNC START"<<endl;
    seg::init_value();
    pll A1=solve(1,N),A2=solve(N,1);
    dnc(A1,A2);
    sort(hull.begin(),hull.end());
    hull.resize(unique(hull.begin(),hull.end())-hull.begin());
//    if (A1 != A2)hull.push_back(A2);
//    for (auto x:hull){
//        cout<<"HULL "<<x.fi<<' '<<x.se<<'\n';
//    }
//    cout<<"INIT SUCCEED"<<endl;
}

long long minimize(int X, int Y)
{
    ll l=1;
    ll r=sz(hull)-1;
    ll ans = 0;
    while (l<=r){
        ll mid = (l + r) >> 1;
        if (eval(hull[mid],X,Y) < eval(hull[mid-1],X,Y)){
            ans = mid;
            l = mid + 1;
        }
        else{
            r = mid - 1;
        }
    }
//    ll dp[n+1][m];
//    for (ll i = 0;i < m;i ++)dp[0][i] = 0;
//    for (ll i = 0;i < n;i ++){
//        ll min1 = 1e18;
//        for (ll j = 0;j < m;j ++){
//            dp[i+1][j] = dp[i][j];
//            if (a[i].fi<=j&&j<=a[i].se)dp[i+1][j] += Y;
//            min1 = min(min1,dp[i+1][j]);
//        }
//
//        for (ll j = 0;j < m;j ++){
//            dp[i+1][j] = min(dp[i+1][j],min1+X);
//        }
//    }
//    ll res = 1e18;
//    for (ll j = 0;j < m;j ++)res = min(res,dp[n][j]);
//    if (!(eval(hull[ans],X,Y) == res))cout<<eval(hull[ans],X,Y)<<' '<<res<<endl;
//    assert(eval(hull[ans],X,Y) == res);
    return eval(hull[ans],X,Y);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 0ms
memory: 5644kb

input:

6 2 1
1 1
0 1
0 0
0 1
1 1
0 1
724642704 32998300

output:

131993200

result:

ok single line: '131993200'

Test #2:

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

input:

10 3 1
1 2
1 2
0 2
1 2
2 2
0 2
1 1
0 2
0 1
1 2
686137157 255736273

output:

1022945092

result:

ok single line: '1022945092'

Test #3:

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

input:

50 5 1
0 1
4 4
3 4
1 4
0 3
1 4
1 3
0 4
0 0
0 3
0 1
0 3
0 0
2 3
0 0
3 4
1 1
2 2
0 1
0 1
0 4
1 4
3 4
0 1
0 4
2 2
0 3
0 3
0 4
0 3
0 4
2 4
0 0
4 4
3 3
1 4
2 3
0 2
0 1
0 3
2 3
3 3
2 3
2 4
2 2
0 2
1 2
0 4
1 3
2 4
404445464 361978179

output:

6196096328

result:

ok single line: '6196096328'

Test #4:

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

input:

121 7 1
2 5
5 6
1 6
0 6
4 5
1 6
2 4
2 4
0 6
2 6
1 5
3 4
0 4
1 6
0 2
0 5
2 6
1 6
1 2
1 4
0 6
1 5
0 5
0 6
0 6
0 6
1 4
0 4
3 5
1 6
0 0
0 5
1 3
0 6
0 3
1 3
1 2
2 3
0 5
1 4
2 4
0 5
0 0
1 3
1 6
0 2
1 6
2 5
2 4
0 6
1 2
2 4
3 4
0 5
0 6
0 6
1 6
0 6
0 4
2 6
0 1
0 2
0 3
0 5
3 6
2 4
4 4
1 6
5 5
0 4
0 5
0 0
2 3
...

output:

16848723090

result:

ok single line: '16848723090'

Test #5:

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

input:

243 9 1
0 7
1 7
0 3
3 7
1 8
5 6
4 6
3 5
5 6
0 6
0 8
1 8
7 8
4 8
1 8
0 5
3 3
5 8
5 7
8 8
3 6
0 6
4 4
1 3
0 7
2 5
0 2
6 6
4 7
1 3
0 8
1 4
0 8
2 8
6 8
5 8
1 8
0 8
7 8
3 3
3 4
0 8
6 8
0 4
2 8
0 8
1 7
0 6
4 4
1 8
6 8
0 7
4 8
0 8
1 5
4 7
0 8
3 3
1 1
5 8
1 4
5 7
3 4
1 7
1 8
1 8
6 8
0 4
0 8
2 8
3 7
2 8
0 3
...

output:

27719095584

result:

ok single line: '27719095584'

Test #6:

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

input:

1000 102 1
46 74
33 80
4 84
22 96
1 100
10 36
35 68
0 65
4 26
26 93
25 90
0 79
14 101
24 57
4 53
37 60
4 77
32 97
44 70
29 65
44 99
2 49
0 86
69 76
3 57
1 93
16 83
38 60
1 86
1 40
19 97
28 94
4 45
16 72
23 94
26 89
20 60
29 32
21 39
14 83
26 74
24 77
15 88
72 93
12 90
1 81
27 60
15 90
36 78
18 39
12...

output:

23789206007

result:

ok single line: '23789206007'

Test #7:

score: 0
Accepted
time: 11ms
memory: 6008kb

input:

2000 123 1
48 81
27 95
16 109
19 106
26 115
4 116
66 83
2 111
39 118
15 47
21 122
1 120
78 101
35 120
55 95
36 59
75 75
42 64
71 105
11 121
31 122
30 112
93 116
1 61
77 84
26 90
28 109
14 116
9 118
80 91
8 101
13 113
29 51
2 118
5 77
23 93
25 108
3 120
8 120
22 64
36 65
7 83
7 115
14 93
8 50
7 116
5...

output:

40092503040

result:

ok single line: '40092503040'

Test #8:

score: 0
Accepted
time: 18ms
memory: 5880kb

input:

3000 143 1
0 142
28 140
36 139
27 48
1 137
21 142
35 103
40 91
55 82
2 135
27 123
42 58
38 126
105 106
43 65
13 103
78 99
71 102
21 106
94 127
31 40
14 131
94 120
1 117
5 128
48 120
27 135
31 107
49 107
2 132
89 102
22 123
23 139
76 137
125 136
80 122
12 127
17 91
84 136
82 139
45 131
38 85
9 142
24...

output:

53183710390

result:

ok single line: '53183710390'

Test #9:

score: 0
Accepted
time: 17ms
memory: 5872kb

input:

3000 123 1
38 120
3 97
6 57
11 11
29 76
39 115
69 89
57 122
11 122
43 66
46 104
6 43
4 119
8 59
28 107
73 102
18 119
70 108
62 95
4 115
19 79
29 91
2 40
114 120
67 83
37 46
14 110
4 70
2 35
35 120
21 28
20 111
4 121
10 103
7 122
36 105
21 28
15 26
54 72
65 113
24 118
58 115
49 115
13 112
105 120
0 1...

output:

9990597533

result:

ok single line: '9990597533'

Test #10:

score: 0
Accepted
time: 20ms
memory: 5876kb

input:

3000 102 1
94 95
51 101
91 99
9 92
8 80
2 60
45 57
1 96
40 83
8 8
15 87
10 98
44 89
40 96
13 62
4 67
6 35
0 101
36 95
15 53
56 86
55 88
38 74
11 50
0 61
0 93
32 69
7 60
32 82
9 98
7 97
18 100
70 91
26 80
27 101
21 69
0 101
43 49
45 97
17 73
1 12
0 36
40 86
44 92
57 68
15 87
57 68
54 75
66 101
10 88
...

output:

69226624268

result:

ok single line: '69226624268'

Test #11:

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

input:

3000 6 1
4 4
5 5
2 2
0 5
3 3
0 5
0 4
1 4
0 2
0 4
1 5
1 5
0 3
4 5
2 3
1 5
1 3
3 5
0 3
3 3
3 5
1 3
2 2
1 5
0 1
3 4
2 4
0 0
4 4
0 2
1 4
3 4
1 3
0 1
0 1
0 0
2 4
0 2
0 4
2 5
0 5
0 4
0 1
0 3
1 5
2 4
2 4
0 5
2 5
3 4
0 5
1 5
4 5
2 4
1 1
1 3
0 5
0 4
0 3
5 5
1 5
0 2
1 5
2 5
0 5
0 3
2 3
3 4
4 4
2 3
2 5
0 1
4 5...

output:

282532939566

result:

ok single line: '282532939566'

Test #12:

score: 0
Accepted
time: 10ms
memory: 5744kb

input:

3000 7 1
2 6
1 6
1 2
5 6
1 4
2 6
2 6
1 1
2 6
2 4
1 3
1 3
2 6
0 6
3 4
1 2
1 3
0 5
0 0
0 0
0 3
3 6
0 4
4 6
1 1
0 0
2 4
0 5
3 6
2 4
2 4
1 4
2 5
4 5
2 4
2 5
0 6
2 6
4 5
2 3
0 5
4 4
3 6
1 6
5 5
1 6
2 4
2 4
0 6
1 6
3 4
0 5
2 6
0 6
1 6
2 4
0 0
0 4
2 5
5 6
4 5
4 5
0 1
3 6
1 6
0 6
0 5
4 5
1 2
0 3
1 2
0 6
2 5...

output:

71432089700

result:

ok single line: '71432089700'

Test #13:

score: 0
Accepted
time: 7ms
memory: 6044kb

input:

3000 8 1
3 5
2 4
1 7
3 3
0 4
3 4
2 4
1 3
4 5
0 0
1 4
2 2
2 6
1 7
1 7
0 7
0 2
0 6
1 7
4 6
0 2
0 7
0 2
6 7
0 7
1 5
1 7
0 6
0 7
4 7
0 7
5 6
1 7
1 2
1 3
2 6
0 3
1 5
2 7
1 7
2 3
0 7
2 5
3 7
2 7
7 7
2 5
2 4
0 6
1 5
0 1
0 5
0 7
6 6
1 4
3 6
0 6
3 4
1 5
6 7
0 7
1 5
4 7
1 3
7 7
1 7
0 4
1 7
1 7
1 5
3 7
0 7
1 7...

output:

89022157300

result:

ok single line: '89022157300'

Test #14:

score: 0
Accepted
time: 12ms
memory: 5852kb

input:

3000 9 1
1 8
0 3
1 7
3 7
2 7
0 8
1 8
3 8
0 8
2 3
2 7
1 7
0 5
0 8
3 7
1 5
0 8
4 4
1 7
6 6
5 6
3 4
1 4
1 7
0 8
0 6
5 8
0 0
0 7
1 3
1 7
2 5
1 4
1 7
4 7
0 8
0 8
1 8
0 7
4 8
3 8
0 8
0 8
0 6
0 8
2 3
2 8
2 7
2 7
0 8
2 3
0 3
3 7
2 5
0 8
1 4
1 4
2 6
3 6
3 6
6 8
2 7
3 8
1 3
0 8
2 6
3 7
2 6
0 4
1 8
4 8
0 6
1 8...

output:

379045773469

result:

ok single line: '379045773469'

Test #15:

score: 0
Accepted
time: 12ms
memory: 5740kb

input:

3000 10 1
3 6
6 9
3 9
0 8
0 4
0 8
4 9
4 5
0 4
6 6
0 8
2 6
4 7
0 6
0 8
4 4
3 8
0 4
9 9
5 9
0 8
1 4
0 3
0 8
3 5
0 4
3 9
4 7
0 9
0 8
1 3
2 4
0 7
4 5
0 6
7 8
0 4
9 9
0 8
1 6
5 5
3 9
1 8
1 8
0 2
2 2
3 9
2 3
4 4
1 7
3 7
2 3
2 9
6 9
1 4
1 7
1 2
6 6
4 5
2 7
4 9
4 6
2 6
1 5
7 8
1 4
3 7
6 6
4 9
9 9
3 7
1 2
0 ...

output:

331629106039

result:

ok single line: '331629106039'

Test #16:

score: 0
Accepted
time: 13ms
memory: 5980kb

input:

3000 2934 1
1970 2832
110 2030
61 2595
313 2018
546 1871
1131 2583
216 2779
909 1996
864 1914
1011 1315
1365 2599
508 1996
955 2087
310 1272
1955 2337
781 1719
155 815
837 1681
25 2913
841 1953
376 2752
388 1124
1099 2382
1323 2198
851 2217
1459 2721
465 2160
312 2250
55 1080
180 339
764 2865
82 253...

output:

2426370144

result:

ok single line: '2426370144'

Test #17:

score: 0
Accepted
time: 10ms
memory: 6060kb

input:

2942 3000 1
425 2447
791 893
243 2737
447 1479
1447 2468
181 2810
1219 2995
2407 2628
296 1770
1535 1779
1338 2418
441 1346
1916 2767
740 2628
4 1462
230 2239
1755 1880
33 2815
283 2054
922 1731
1236 2809
513 2469
190 2711
1692 1850
31 2959
369 1998
246 2694
2524 2867
1076 2822
1204 2795
153 1294
28...

output:

3475348346

result:

ok single line: '3475348346'

Test #18:

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

input:

3000 3000 1
1390 1947
533 1520
288 2002
824 1075
363 2519
1187 2858
532 2977
31 2120
1 2937
1545 2305
1125 2756
835 2017
2055 2309
1621 2143
1316 1826
244 2875
1299 2494
509 2480
1384 1735
23 2976
443 752
290 993
495 2557
484 2973
718 1717
20 2576
470 1167
25 2557
157 2901
360 2798
1488 1917
719 294...

output:

1096040253

result:

ok single line: '1096040253'

Test #19:

score: 0
Accepted
time: 18ms
memory: 5800kb

input:

3000 11 1
6 10
3 10
0 6
0 10
0 8
2 10
4 10
0 7
0 3
0 10
0 7
0 1
4 10
0 2
7 10
0 10
0 10
1 10
2 10
9 10
9 10
8 10
10 10
0 2
0 5
7 10
0 1
0 2
8 10
0 10
0 10
0 10
0 6
9 10
5 10
0 7
0 10
0 2
0 7
4 10
6 10
0 3
0 1
6 10
3 10
4 10
7 10
2 10
0 9
10 10
0 2
8 10
3 10
9 10
0 9
5 10
0 5
4 10
0 6
0 10
0 10
10 10...

output:

231189542188

result:

ok single line: '231189542188'

Test #20:

score: 0
Accepted
time: 18ms
memory: 5800kb

input:

3000 12 1
1 11
0 9
3 11
0 10
0 0
1 11
0 11
0 1
0 0
0 6
4 11
2 11
0 0
8 11
2 11
0 5
0 11
0 5
0 9
0 9
3 11
10 11
0 1
6 11
0 6
6 11
0 2
0 3
11 11
6 11
3 11
7 11
5 11
5 11
0 9
6 11
0 0
0 10
0 1
0 2
2 11
6 11
0 1
1 11
10 11
3 11
0 4
7 11
0 1
0 0
0 9
5 11
5 11
8 11
0 9
0 1
6 11
1 11
9 11
9 11
0 0
7 11
0 5...

output:

149422997346

result:

ok single line: '149422997346'

Test #21:

score: 0
Accepted
time: 22ms
memory: 5988kb

input:

3000 13 1
6 12
0 1
4 12
0 2
4 12
0 12
1 12
3 12
11 12
0 11
10 12
9 12
0 6
0 4
9 12
1 12
0 11
0 12
10 12
5 12
0 8
11 12
2 12
0 12
7 12
0 10
4 12
11 12
0 8
0 12
6 12
0 2
0 6
4 12
5 12
4 12
0 7
1 12
0 2
3 12
9 12
9 12
4 12
0 12
8 12
0 4
0 7
4 12
10 12
0 1
0 2
12 12
7 12
4 12
0 5
0 3
0 9
0 1
0 11
6 12
0...

output:

193191161451

result:

ok single line: '193191161451'

Test #22:

score: 0
Accepted
time: 53ms
memory: 6132kb

input:

3000 3000 1
0 557
0 987
0 1714
0 251
843 2999
0 1671
0 2445
910 2999
63 2999
2239 2999
0 1631
1817 2999
2745 2999
2477 2999
0 510
0 2631
0 1195
1028 2999
0 351
0 2953
2690 2999
0 703
937 2999
0 2489
2000 2999
0 2556
0 697
467 2999
255 2999
0 2438
2570 2999
777 2999
0 964
0 1963
1344 2999
0 1766
2199...

output:

210328057904

result:

ok single line: '210328057904'

Test #23:

score: 0
Accepted
time: 66ms
memory: 5916kb

input:

3000 2983 1
0 133
2599 2982
2541 2982
0 389
0 2825
0 432
561 2982
2514 2982
0 1865
0 706
720 2982
3 2982
1648 2982
0 1731
1890 2982
1570 2982
0 937
1853 2982
0 1418
687 2982
0 799
1530 2982
1446 2982
2216 2982
0 2047
0 2530
0 2971
0 1736
1767 2982
0 1447
0 47
601 2982
0 1758
84 2982
0 2756
0 2116
0 ...

output:

571590929028

result:

ok single line: '571590929028'

Test #24:

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

input:

2984 3000 1
0 1161
1028 2999
0 2476
0 2636
0 1914
0 776
0 2136
248 2999
0 48
2645 2999
0 829
2998 2999
359 2999
0 1766
0 927
2847 2999
1471 2999
0 1945
188 2999
295 2999
1426 2999
1831 2999
697 2999
1280 2999
0 1876
735 2999
0 1413
2326 2999
0 2970
537 2999
1249 2999
1147 2999
0 1827
0 943
0 213
0 1...

output:

472133773188

result:

ok single line: '472133773188'

Test #25:

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

input:

300 3000 1
2218 2999
2936 2999
2708 2999
2281 2999
0 1722
0 1888
0 1064
0 704
1925 2999
0 1753
2426 2999
0 1862
0 1830
572 2999
0 2435
798 2999
95 2999
1193 2999
507 2999
0 1299
0 2105
0 508
2672 2999
1956 2999
1742 2999
0 2278
0 118
586 2999
1966 2999
0 1101
77 2999
2768 2999
1755 2999
0 81
0 1013
...

output:

54180869583

result:

ok single line: '54180869583'

Test #26:

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

input:

102 3000 1
0 689
840 2999
1957 2999
0 1676
0 415
2411 2999
2855 2999
2582 2999
0 2096
2287 2999
1961 2999
0 1601
2643 2999
1220 2999
820 2999
0 1470
802 2999
392 2999
0 1762
1064 2999
2595 2999
0 748
1501 2999
0 991
0 617
0 1021
0 1598
1753 2999
0 717
0 2553
1705 2999
0 646
0 106
109 2999
0 2738
284...

output:

1972426860

result:

ok single line: '1972426860'

Test #27:

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

input:

30 3000 1
0 6
2934 2999
419 2999
0 2107
0 2694
0 1094
0 714
2652 2999
0 166
0 1841
0 1480
654 2999
922 2999
503 2999
0 1267
0 680
0 2078
0 815
1096 2999
417 2999
2967 2999
764 2999
0 585
0 703
0 2031
1558 2999
1048 2999
893 2999
0 551
0 2839
997165834 387960850

output:

4100852634

result:

ok single line: '4100852634'

Test #28:

score: 0
Accepted
time: 15ms
memory: 5864kb

input:

3000 3000 1
2 2888
284 2922
152 2772
112 2784
140 2943
32 2566
262 2972
67 2987
97 2809
69 2766
282 2975
411 2876
515 2970
66 2929
240 2686
357 2972
22 2884
27 2627
139 2776
108 2593
401 2822
26 2988
61 2845
154 2847
101 2961
80 2756
56 2833
15 2750
118 2661
130 2870
132 2799
369 2815
32 2570
252 27...

output:

4441208350

result:

ok single line: '4441208350'

Test #29:

score: 0
Accepted
time: 15ms
memory: 5912kb

input:

3000 2998 1
0 2979
109 2505
172 2990
313 2748
175 2591
167 2968
284 2698
24 2815
107 2604
34 2965
123 2877
25 2992
75 2989
38 2836
286 2960
308 2919
393 2797
1 2533
350 2969
442 2864
170 2994
57 2749
75 2846
235 2967
180 2712
135 2883
307 2871
34 2556
463 2873
352 2984
111 2721
191 2827
193 2953
51 ...

output:

707002430

result:

ok single line: '707002430'

Test #30:

score: 0
Accepted
time: 11ms
memory: 5904kb

input:

2983 3000 1
287 2693
86 2847
39 2840
24 2998
132 2547
70 2707
166 2884
168 2850
17 2994
18 2863
60 2490
164 2746
59 2806
0 2991
236 2799
189 2682
224 2705
55 2742
105 2848
131 2954
39 2975
51 2672
55 2970
108 2972
30 2539
24 2991
39 2863
193 2987
135 2838
0 2998
6 2827
349 2934
24 2618
51 2911
131 2...

output:

5259263969

result:

ok single line: '5259263969'

Subtask #2:

score: 22
Accepted

Dependency #1:

100%
Accepted

Test #31:

score: 22
Accepted
time: 0ms
memory: 5728kb

input:

500 1000000000 1
393977 997870502
1756198 996576675
709934 998910119
17244831 952957551
142872155 968927704
30385278 942410694
85734427 939378703
37926488 882420546
46151590 899775163
85788461 920969935
45003485 970828908
67012830 999694016
121553395 948429920
74733065 879692791
28285744 997261133
1...

output:

0

result:

ok single line: '0'

Test #32:

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

input:

500 1000000000 2
43974519 920435977
29442239 968626496
87296121 970680158
115030899 942979681
14500557 998008395
13920627 941658606
21697984 918354277
21474824 989173405
113175676 946584338
91193449 991632398
117741332 950425500
4841945 986925809
6561290 979837435
37960710 882087904
130890586 960747...

output:

0
0

result:

ok 2 lines

Test #33:

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

input:

500 1000000000 3
65079298 915492964
12721407 929152574
11143804 946828564
63005431 983190275
111727058 957719910
64261942 997647034
2661138 932263997
32904956 851658462
103914205 979192101
34972635 905701784
141650874 943277934
28280148 964799414
28578426 948254190
56473371 939768033
210584 98591566...

output:

0
0
0

result:

ok 3 lines

Test #34:

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

input:

10000 10 50
2 8
1 8
2 9
0 5
1 2
5 6
3 8
1 5
5 8
0 9
0 8
1 9
1 4
0 9
0 5
4 9
3 8
0 0
0 7
2 2
3 6
3 7
3 4
2 9
0 9
4 4
3 5
3 3
1 8
1 1
1 8
0 8
1 6
4 9
3 8
1 7
0 9
0 1
6 7
0 9
7 8
0 9
0 2
2 8
0 7
2 9
1 5
0 9
4 6
0 9
0 9
3 9
0 7
7 7
1 3
7 7
4 8
2 2
5 9
0 5
0 8
1 9
5 7
0 4
8 8
7 9
2 5
0 0
4 8
0 9
0 0
1 5
...

output:

1649863551856
1380493275351
1295735155923
456578775016
269155165802
2011614159399
1892104544432
54016244655
361549026140
2209229746705
1681910746040
2032120266616
1669809044383
109490055677
128024603685
1030140493987
1259667253169
1189990827451
715960613154
700481506423
2274746221202
785728954942
10...

result:

ok 50 lines

Test #35:

score: 0
Accepted
time: 55ms
memory: 6292kb

input:

9832 10 50
1 9
9 9
0 0
5 5
2 8
2 2
1 8
0 2
7 8
0 7
0 9
0 7
6 6
0 5
4 4
0 4
2 6
4 8
1 4
0 3
2 5
0 7
4 6
3 5
1 3
0 7
1 4
1 1
7 8
5 6
6 6
2 8
4 8
0 5
2 9
1 8
7 7
0 8
1 9
5 7
5 9
0 9
3 8
2 7
9 9
2 8
1 6
6 9
7 9
6 9
0 2
5 8
0 5
3 8
2 8
1 6
5 8
5 7
5 8
3 8
6 9
1 1
0 9
5 7
1 7
0 6
2 6
0 3
5 6
1 3
4 6
0 3
2...

output:

1378443658556
857998452840
1293813485431
297464448442
1369627125846
1359835626172
351733409760
124639699522
276857107656
1564926701148
759837697040
799056479278
1553471666256
1012477907941
583214322252
1702523008578
1847753651510
1178106858132
1449636926490
714740890115
1222083686983
1506741555570
1...

result:

ok 50 lines

Test #36:

score: 0
Accepted
time: 54ms
memory: 6288kb

input:

9992 10 50
0 9
0 3
7 9
7 8
4 4
5 9
3 9
0 2
0 9
1 3
1 9
0 8
4 5
3 7
1 9
3 7
6 8
0 2
0 6
0 9
0 7
1 9
0 5
7 8
5 5
0 9
5 5
3 7
3 7
2 6
2 9
5 6
3 4
0 2
1 8
4 9
1 1
2 8
0 9
9 9
3 8
0 9
1 6
1 8
2 3
2 5
0 9
6 7
0 9
0 9
3 6
3 8
7 9
1 4
5 6
6 8
4 5
1 8
0 7
0 1
3 6
1 1
3 8
0 8
0 7
2 9
8 8
0 0
0 9
0 8
5 8
0 8
1...

output:

1089280441974
911545129815
1702130683775
1115940623033
1342106230108
1426523140438
1874018732010
1604529541358
912762859839
109067937442
1161878443768
479354354703
819140165334
1345018325511
1810919837512
995261837949
1746870350577
1070098412673
1189911711601
1045950992563
104426725350
915145067796
...

result:

ok 50 lines

Test #37:

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

input:

9999 10 50
4 7
2 6
4 5
0 9
1 4
2 4
0 9
0 7
4 6
1 5
0 9
0 9
8 9
8 9
0 5
0 6
3 9
0 7
2 9
2 6
7 9
0 9
2 2
5 8
0 8
2 6
0 2
0 6
8 9
4 4
4 9
8 9
1 9
2 4
0 9
1 4
7 9
0 7
1 9
3 7
6 6
3 8
1 3
1 7
4 8
3 5
0 7
0 6
1 4
2 7
3 4
3 9
1 8
5 8
2 8
2 9
1 8
0 0
1 4
4 9
7 8
3 4
2 6
0 1
0 6
0 9
0 2
2 9
0 7
0 6
3 6
1 4
2...

output:

372460365620
1634853480866
1534140352302
718715629680
653936073847
1067842822709
1201573952498
977635699337
734238002896
1339793613482
1125877285656
1283444333017
996916544582
1561246431605
803486020256
139011978878
673971207401
1509662033195
525585080257
415638787089
1426288117953
862849828731
2094...

result:

ok 50 lines

Test #38:

score: 0
Accepted
time: 52ms
memory: 6304kb

input:

9998 10 50
0 9
1 4
3 3
0 9
0 0
0 7
0 4
1 2
1 4
7 8
1 7
7 9
4 8
5 5
0 9
0 7
0 9
0 7
0 9
5 8
1 8
0 0
0 9
4 9
0 8
8 9
1 7
0 9
0 4
3 9
8 8
0 8
0 9
3 6
3 7
2 9
1 7
1 8
0 5
1 9
0 9
0 6
3 9
1 5
2 9
8 8
1 9
0 8
4 5
2 4
6 6
1 3
1 3
2 8
1 7
4 9
4 7
1 7
4 9
1 1
0 9
2 3
0 4
1 7
5 9
2 3
2 7
7 8
0 8
0 6
2 8
1 9
2...

output:

611793093574
201685481368
1533925723413
1408214159533
238932242048
1308985387347
1734620358003
1552465238864
903779848850
1072305049224
1454494793160
957522918654
971211575890
504161374622
866615656278
1325484652214
1451397721420
1166045811382
1475933374056
1264350326666
1245391231143
381039251337
1...

result:

ok 50 lines

Test #39:

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

input:

10000 10000000 50
729335 4474024
2957651 9671040
157805 8785447
4978104 6804574
590354 9013150
9105286 9773295
275620 8989970
988506 9552369
708053 9480272
1145367 9928445
4220566 8196666
2384122 8714777
4960256 5679148
1485223 8722760
8423474 9065820
2906359 7574355
611496 3791794
2390688 7399287
4...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #40:

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

input:

10000 100000000 50
26094129 46340947
1574912 16411111
1244864 99007950
4999658 93469414
29962241 93953822
60323383 82671714
31698933 48162468
7452043 76197971
1366564 98068302
47521153 91200490
23949140 50203595
35796993 83104108
80490350 96374769
9780735 34919531
21917325 64524877
29252551 92783766...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #41:

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

input:

10000 1000000000 50
83505471 923074158
94613918 405598288
665314527 912442561
771505210 889921062
273417690 713102463
13566476 60637129
251456335 863585923
711676585 932718005
39044158 759649917
424395361 473265492
363923063 870226530
451469216 570185953
44707425 993383091
352091155 491593483
491882...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #42:

score: 0
Accepted
time: 446ms
memory: 7108kb

input:

10000 1000000000 50
0 839568687
0 310984370
752871965 999999999
0 118415852
560315226 999999999
952929346 999999999
387870411 999999999
778958579 999999999
279394240 999999999
951129868 999999999
493696532 999999999
0 118716737
51324333 999999999
860497671 999999999
0 875449854
24976687 999999999
0 ...

output:

696597739794
266176557990
1970879196178
684774019800
2233676554772
85570134438
82479242088
1315310038194
1964127560535
1303124333670
2004138755004
1723614092004
657237350202
1046519079678
672265278618
1869013917384
1867639019058
2155918088500
1123045283646
1127766644869
723519514644
2173936687999
97...

result:

ok 50 lines

Test #43:

score: 0
Accepted
time: 439ms
memory: 6928kb

input:

9982 1000000000 50
751253804 999999999
41448819 999999999
0 486617498
581188549 999999999
207467831 999999999
523117450 999999999
0 817770806
0 143742207
739618766 999999999
0 756013904
903136263 999999999
257240814 999999999
0 716550721
0 692565666
0 223939252
231223402 999999999
0 36957039
4961044...

output:

243822165972
192680300346
167236970108
1495872659268
1076907661333
66006732589
332531219521
901775092456
1901056821123
1312580043107
1690158339732
1592975825443
351975246624
901618638605
405597343062
508734881664
2204707960170
1814047107957
919043545410
2354932642702
326116417410
1727382613715
98775...

result:

ok 50 lines

Test #44:

score: 0
Accepted
time: 459ms
memory: 6816kb

input:

9999 1000000000 50
0 615011321
203682777 999999999
0 605855898
404418706 999999999
0 496000807
0 772879546
0 48301746
749498965 999999999
496088573 999999999
0 42493134
135123950 999999999
103010261 999999999
913018226 999999999
14661193 999999999
0 634010203
435875870 999999999
0 241239056
66047435...

output:

1419808098675
1531112576190
147844971724
1318846684903
730252389030
1654321368420
503628558714
473991987411
2271234707413
268666306363
447850314084
1887231992396
1700702357302
1399415739636
1344157229385
2468804068416
1681561884330
96786084190
1475315789281
2007780896292
1230978650847
955754347176
1...

result:

ok 50 lines

Test #45:

score: 0
Accepted
time: 363ms
memory: 7072kb

input:

9299 1000000000 50
0 362466509
0 820187946
0 680484189
0 972566948
896391507 999999999
857624048 999999999
0 443769629
800085025 999999999
0 920664663
0 125671948
193579065 999999999
0 501147542
763917542 999999999
0 941669372
0 271777474
0 959354820
0 257577081
30472 999999999
0 699016633
0 3165664...

output:

288947004411
1327912461580
1946571078708
344708175375
1643544301031
103358521350
1075366115617
1422239164944
418968049200
323518701180
786799349655
1503443288368
771548622840
1689502072624
997889742747
733836359086
582495305490
62512939830
311023111222
1536939048823
160139796180
1415138024047
190303...

result:

ok 50 lines

Test #46:

score: 0
Accepted
time: 463ms
memory: 8124kb

input:

9988 1000000000 50
231916624 999999999
600745774 999999999
0 91988648
394579495 999999999
290230212 999999999
0 22106867
351710268 999999999
0 726638490
0 60577904
0 4995157
34636344 999999999
110436028 999999999
92918241 999999999
0 433329812
905701598 999999999
0 14041871
0 95513168
0 903615629
84...

output:

34550042550
2378684731136
263201879257
2226856881035
2101753408158
674280265626
1031189125738
813990978584
1328647182498
1568997798278
2015203363002
487031008493
1088284478481
1333457775191
336005122710
882888660812
1648114012844
219614239219
1529690665072
496390167854
382253688756
1123278792750
185...

result:

ok 50 lines

Test #47:

score: 0
Accepted
time: 321ms
memory: 6364kb

input:

9899 100 50
0 0
2 99
0 1
3 99
0 1
3 99
0 2
4 99
0 2
4 99
0 2
4 99
0 3
5 99
0 3
5 99
0 3
5 99
0 3
5 99
0 4
6 99
0 4
6 99
0 4
6 99
0 4
6 99
0 4
6 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 7
9 99
0 7
9 99
0 7
9 99
0 7
9 99
...

output:

62878964940
2507979474
31942553346
51691508649
87170681229
7934649624
50542576800
27577432080
18677957661
81817770051
81760342240
49699624392
23006652867
86364975246
18489902706
96012691134
67884094470
15705990630
87826963710
21510918
79896841977
48792190788
21052115172
31313019177
39056329521
95932...

result:

ok 50 lines

Test #48:

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

input:

10000 1000000000 50
434537485 434537488
577666052 577666060
138646722 138646729
705400356 705400364
252323954 252323954
224665599 224665600
529051370 529051371
981252995 981252997
319882598 319882604
186765603 186765607
548574454 548574463
1939299 1939304
698514047 698514048
141026871 141026873
5997...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #49:

score: 0
Accepted
time: 9ms
memory: 7440kb

input:

9981 1000000000 50
265936628 265936629
947025622 947025622
167361603 167361608
34819891 34819892
50238 50239
900316161 900316169
408550752 408550753
247515328 247515335
839276183 839276187
235391238 235391240
993089859 993089865
777785644 777785645
544237624 544237627
507917860 507917867
525268013 5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #50:

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

input:

9999 1000000000 50
95394888 95394894
157356524 157356526
485447725 485447731
109320283 109320284
305412192 305412193
419474134 419474142
966497349 966497351
223859236 223859237
472738680 472738687
601927366 601927374
434676915 434676923
986754841 986754841
633154676 633154683
295631212 295631214
958...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #51:

score: 0
Accepted
time: 27ms
memory: 7128kb

input:

9919 1000000000 50
19089751 927973844
166201886 979163287
13706533 916676558
7251956 968383703
108783573 966366124
19165667 987857830
131407491 959683656
106434524 961651431
85009751 942548499
171066355 997578293
61369650 950508202
57704056 917089925
12512032 986652828
74619355 997994073
3015812 862...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #52:

score: 0
Accepted
time: 22ms
memory: 8012kb

input:

9999 1000000000 50
139844846 956026262
39645451 964617380
70102940 881088032
66950387 920613183
36168383 992729116
1172960 849880575
138689558 954556608
69245243 965672286
6772663 998548601
101823643 927399142
122314975 995919253
60385421 976750335
115246777 922375449
52932505 963335081
21107662 974...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #53:

score: 0
Accepted
time: 22ms
memory: 7284kb

input:

10000 1000000000 50
26019963 986004340
135956798 957041333
74345129 995390966
37470406 971633583
6982380 993497461
1852003 997425537
99501335 916902303
29793505 986476975
24134905 967445231
99775489 900900089
3518147 985365032
9079269 987999474
38712805 953541421
83415077 903618507
16520068 97229329...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #54:

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

input:

2500 1000000000 1
69982162 897481319
93909340 971225230
25403663 975432851
100160250 998303574
18288063 978337446
14690266 834474105
43321029 879707967
2806602 997653166
10998013 834998586
102082843 993472093
37312722 933171618
11042631 973010690
75238889 951604400
102950908 963375635
8002067 974389...

output:

0

result:

ok single line: '0'

Test #55:

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

input:

2500 1000000000 2
19605569 821056934
89607328 944170128
14522742 816852653
70567745 965979856
31379062 948880734
6575748 842072150
17103567 991469798
140107124 953125484
134950990 948802102
16471509 973118234
17622476 882424264
5964544 912302554
31392683 949125088
96597266 996189461
8932118 93116813...

output:

0
0

result:

ok 2 lines

Test #56:

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

input:

2500 1000000000 3
84154405 964590704
66328987 898138697
120110443 974741077
8252696 857985014
3149958 888169369
36113055 982289296
14005934 831384181
12418677 981524689
3789749 859510096
6808412 933745337
3459770 975120304
31692998 987433685
2563015 961662314
44318376 878045313
69189074 990222156
30...

output:

0
0
0

result:

ok 3 lines

Test #57:

score: 0
Accepted
time: 23ms
memory: 7180kb

input:

10000 1000000000 1
1597835 938710770
7738329 968351075
1024579 996355922
65986890 985203652
36276572 853398191
53884887 998039748
15645551 864773094
3631503 987092655
79007028 923707505
70809091 952073788
35073593 998719021
88380495 999528022
43595074 983501918
4676285 978072562
43927362 899758425
8...

output:

0

result:

ok single line: '0'

Test #58:

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

input:

10000 1000000000 2
84236720 900334588
11067358 948927014
39708320 930288966
12622012 981126256
22493600 997067508
38050988 987852961
7635337 994742172
69028476 903544553
5655450 997257888
90108454 941663351
121674144 992178318
37810329 998360533
16867036 903173499
50371937 862935681
11116397 8328613...

output:

0
0

result:

ok 2 lines

Test #59:

score: 0
Accepted
time: 19ms
memory: 7164kb

input:

10000 1000000000 3
61100708 946118059
134139824 954279114
104328520 942177163
555004 966328036
18894910 855953832
20894098 881375909
19898971 882900952
2970559 993574288
26042607 997430133
54784827 971597200
141608174 981055239
159767488 969720368
6375646 996133149
79273530 931004742
22101799 937611...

output:

0
0
0

result:

ok 3 lines

Subtask #3:

score: 19
Accepted

Test #60:

score: 19
Accepted
time: 82ms
memory: 13996kb

input:

500 10 1000000
2 9
2 7
3 6
1 6
3 5
0 5
3 4
6 8
4 8
1 6
1 5
6 7
7 7
6 9
0 7
4 5
0 6
0 2
4 6
0 6
1 7
2 8
0 9
0 9
0 9
0 7
3 6
8 8
2 4
4 4
0 5
2 5
1 6
0 9
2 7
0 8
9 9
1 4
0 9
2 4
1 9
2 8
2 6
0 4
5 9
4 5
3 9
2 6
1 9
0 6
6 8
2 9
4 9
7 9
2 7
1 5
1 8
0 6
0 9
2 9
3 9
0 2
4 4
5 9
4 7
8 9
4 9
1 8
3 8
2 9
6 6
3...

output:

109125435050
79679504214
40397444309
33486843995
50549382350
8831039674
29373662236
35916635082
1627822212
83193326242
7021463069
18347246004
17908310304
40111838606
42807634739
83808922569
36682521996
87471336298
56912099994
74488880562
59044328919
71779759293
47086282044
46402519236
10235901992
55...

result:

ok 1000000 lines

Test #61:

score: 0
Accepted
time: 95ms
memory: 13188kb

input:

500 10 1000000
2 3
0 5
4 8
5 9
1 3
3 8
0 1
3 8
2 8
2 9
1 3
3 3
1 8
5 9
3 9
4 5
6 9
2 9
2 3
0 8
2 9
0 3
1 9
9 9
2 9
2 7
2 8
2 4
6 9
2 9
0 9
2 8
2 8
0 4
2 6
7 8
0 9
0 8
0 9
2 7
5 7
4 7
0 9
5 6
0 4
2 7
0 7
2 9
2 8
0 2
1 6
0 9
1 6
0 7
7 9
0 8
4 9
1 5
0 9
1 7
0 2
4 8
2 2
5 5
4 8
3 7
8 8
1 5
9 9
0 8
4 4
0...

output:

93932220045
43423248548
63878537436
19958848316
34458591915
74471642637
29392721565
108979131384
68348696934
50344204576
86393681343
95187505608
59870044263
83702649696
40342598040
43679949188
38834691528
68528731476
73704081803
21220971702
17051904446
74680125785
33411395765
34066852792
84600145110...

result:

ok 1000000 lines

Test #62:

score: 0
Accepted
time: 80ms
memory: 14060kb

input:

500 10 1000000
0 9
0 9
1 9
1 9
2 9
0 8
5 7
0 8
6 9
0 5
3 6
1 8
4 8
0 6
1 3
3 3
3 7
0 9
2 3
6 7
0 4
3 9
2 8
7 9
4 5
6 9
8 9
2 6
5 8
5 7
1 1
0 5
0 9
0 1
4 8
0 9
3 8
2 9
3 8
0 8
5 8
0 9
0 8
2 5
0 9
5 8
5 9
2 3
6 8
0 6
2 4
5 7
5 8
2 9
0 7
1 8
0 9
6 8
3 7
0 5
0 7
3 5
1 8
2 8
0 8
7 9
7 9
2 2
0 9
1 8
5 5
5...

output:

57026961526
17848690951
99635443948
24983590233
44471894109
48040845836
78801683211
92617033538
95131564360
76003932078
4524951945
104824016509
83455743908
78148882789
31398746199
56921062405
8610055861
12034412595
76850763508
52731113665
57708287054
70697847727
42403292275
24664520532
110883680880
...

result:

ok 1000000 lines

Test #63:

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

input:

500 30 1000000
9 26
13 21
18 28
0 6
22 26
10 18
6 17
2 26
2 22
6 25
4 29
4 28
21 26
8 22
3 27
1 29
8 23
14 18
8 21
0 19
8 29
7 10
8 28
6 29
4 29
3 21
25 27
11 20
3 24
0 29
23 27
6 24
4 21
0 29
7 21
5 25
6 28
9 23
12 15
6 25
2 25
23 26
0 29
14 21
0 28
1 29
9 28
0 28
3 15
13 13
8 22
0 27
6 21
3 19
26 ...

output:

1682886942
24547047035
28044067479
21544869984
37457824459
21807891666
12535873263
39058433438
15537998652
2799387492
33589097504
32808718666
6788665554
8354240532
49177937664
6588657240
16703830918
13056441408
22283139757
6172652706
15907683793
29853165323
40623679424
16570232136
30822528460
927439...

result:

ok 1000000 lines

Test #64:

score: 0
Accepted
time: 90ms
memory: 13960kb

input:

500 100 1000000
12 40
12 78
71 75
7 38
39 72
5 79
7 93
61 96
2 17
56 69
48 75
14 89
42 61
69 95
0 37
4 77
56 58
41 45
12 48
15 97
61 90
37 80
8 98
17 55
19 75
0 99
29 92
86 89
27 85
0 99
7 51
44 69
20 90
0 99
16 62
38 92
15 97
86 90
22 61
9 99
21 88
1 96
17 92
13 76
19 68
28 41
25 92
11 81
8 95
13 8...

output:

10988225774
5504731720
441633920
9290732611
6706382331
7857623930
11273383215
5345054639
9652306650
5914154221
8069547220
8866759952
3116937590
2592298060
10401981927
14936811345
3391814137
10333635330
12960453780
465646090
2798518461
7871021669
5722363002
8470234801
9682475574
12097205292
136381334...

result:

ok 1000000 lines

Test #65:

score: 0
Accepted
time: 71ms
memory: 13876kb

input:

500 300 1000000
88 185
41 237
53 271
0 298
27 290
84 228
195 288
189 233
3 296
36 221
9 217
29 236
200 217
176 268
178 192
94 290
112 255
195 237
257 260
51 283
166 255
81 289
157 261
9 266
68 191
84 278
2 192
69 288
15 286
183 293
68 146
45 252
16 285
30 183
113 273
17 280
79 154
29 136
97 196
9 29...

output:

1422329238
2919687863
7119642704
672800499
6014379402
4739246672
3069955647
7659622998
1337464440
6984813040
2222325756
1146485898
4938601596
466923060
8011461669
467153109
7689619432
4784843700
2054082828
5653772982
4884345216
3480035702
3979915008
458414901
79911189
1909412604
1990931154
648673532...

result:

ok 1000000 lines

Test #66:

score: 0
Accepted
time: 76ms
memory: 13132kb

input:

500 1000 1000000
454 771
520 972
748 827
83 997
498 578
513 670
514 920
539 721
87 955
275 756
57 823
169 975
94 478
382 999
562 922
160 946
228 836
839 965
470 867
151 755
34 860
399 415
185 687
162 269
640 697
203 244
323 862
121 627
132 898
220 381
575 742
665 745
584 921
10 244
346 491
139 979
4...

output:

91791012
667395126
201193380
532453492
368499806
311208270
153792080
271290494
1640604762
175231348
416012654
806280172
627119284
1459037444
1572592072
1013760144
1065223140
1053268520
1916359642
1571895280
262570982
8702284
1246993112
1257050644
131623928
1029866948
401820388
1548649184
325397498
1...

result:

ok 1000000 lines

Test #67:

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

input:

498 1000000000 1000000
275236581 909660211
282273693 552318537
72471176 596874952
5370144 157978009
218782810 764479143
542606339 595496083
77620368 904732953
103695080 188214441
230385264 349044110
335618885 745032822
42126459 107117126
504224060 780948498
56392775 133129896
279191324 948705048
324...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #68:

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

input:

500 999999912 1000000
357025916 889370470
636543298 657177549
154402807 558482826
117070752 724892200
107777253 974916227
7927516 966402396
315304659 822379440
221893645 451154682
641226765 734134770
430409051 505997179
23208049 512295064
439219406 690182472
32128449 916117153
166535807 442749499
44...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #69:

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

input:

430 982390183 1000000
41387874 953844006
150582684 461547390
188855383 387229037
472906961 806162277
107400195 175783911
87025996 623561854
65013098 343657846
155822123 976903779
2490205 781083206
287454637 391931181
544361300 969056042
200074431 891519332
219803815 884952587
56976510 965256786
7488...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #70:

score: 0
Accepted
time: 76ms
memory: 13644kb

input:

480 1000000000 1000000
0 630917580
0 261729572
177049064 999999999
131152516 999999999
0 283516177
0 750701306
312565653 999999999
180934757 999999999
0 614523651
0 60824520
0 706007923
927721243 999999999
0 221579397
0 205672898
0 266122680
0 1549612
320639041 999999999
0 756013661
82642690 9999999...

output:

10125019697
60334510520
104446457466
51241030352
93476196770
4232413160
28919728330
97112690490
69707110250
45837113430
40937843760
73159949018
10201678070
19029590050
19378511990
112694948171
34317403430
17849174403
57898125570
94054607153
102360930204
75481231780
27051161128
11541799464
3347093464...

result:

ok 1000000 lines

Test #71:

score: 0
Accepted
time: 74ms
memory: 14016kb

input:

500 999999321 1000000
0 421706714
99479434 999999320
543510624 999999320
0 174066192
150301158 999999320
0 990329339
0 327112035
686153738 999999320
0 514966950
0 351416552
0 475586767
691671234 999999320
912060280 999999320
0 231247275
137112373 999999320
0 12661025
0 703864514
307868285 999999320
...

output:

26339797005
2491511800
107506492627
5991979050
94079184734
116284253825
116704316920
94089819220
61745072018
13549777425
64025264714
102876674328
64752303065
32082557158
2704749819
50097779588
34467270912
85293573704
97485793620
14684159560
106700290941
11687965016
32773268560
21218121900
7900720458...

result:

ok 1000000 lines

Test #72:

score: 0
Accepted
time: 94ms
memory: 13724kb

input:

499 873927192 1000000
0 516376453
133511305 873927191
0 801607184
0 156082892
0 729770367
0 709758326
0 755564843
0 264782050
0 367505175
0 455832780
666602105 873927191
173486599 873927191
0 118773435
219174867 873927191
0 742319095
0 240933731
0 180446478
194207172 873927191
283664773 873927191
0 ...

output:

22265434158
18238643104
34019183613
27846813250
110962684608
110774723960
45125273721
37271274441
28234813042
4466048048
65532487685
97444145216
6169413888
27946475040
60618561771
35905713448
56615471488
34321684314
2686399584
95845955671
89048827842
20432118060
70705612774
61081022918
6495682424
11...

result:

ok 1000000 lines

Test #73:

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

input:

461 22 1000000
0 0
2 21
0 1
3 21
0 1
3 21
0 2
4 21
0 2
4 21
0 2
4 21
0 3
5 21
0 3
5 21
0 3
5 21
0 3
5 21
0 4
6 21
0 4
6 21
0 4
6 21
0 4
6 21
0 4
6 21
0 5
7 21
0 5
7 21
0 5
7 21
0 5
7 21
0 5
7 21
0 5
7 21
0 6
8 21
0 6
8 21
0 6
8 21
0 6
8 21
0 6
8 21
0 6
8 21
0 6
8 21
0 7
9 21
0 7
9 21
0 7
9 21
0 7
9 ...

output:

10409261648
4324128382
694946028
19802003153
5073300099
18309551282
3027996048
9017794677
6576923786
6835657423
1173500979
4453738905
800810262
2337629887
12320632206
16752061408
9673745739
15050954425
2743667598
8872682655
3507880254
9227123640
20331811632
17137902397
7150098417
9383085150
10387456...

result:

ok 1000000 lines

Test #74:

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

input:

500 10 1000000
1 6
3 9
0 5
0 9
2 2
1 6
1 6
0 4
2 5
2 6
0 9
5 5
0 9
5 5
6 9
3 8
4 7
8 8
0 7
0 8
4 5
4 8
1 9
0 6
2 6
2 9
6 6
4 4
6 9
0 4
0 7
8 8
2 5
0 1
1 8
5 7
0 9
2 3
5 9
1 7
6 9
5 8
6 7
1 6
5 5
0 9
5 7
2 5
3 8
8 8
0 9
3 5
0 2
5 6
5 5
0 7
0 6
2 6
0 9
3 9
0 9
0 9
0 9
2 7
4 7
2 9
0 2
6 6
1 1
1 4
0 8
1...

output:

0
57
114
171
228
285
342
399
456
513
570
627
684
741
798
855
912
969
1026
1083
1140
1197
1254
1311
1368
1425
1482
1539
1596
1653
1710
1767
1824
1881
1938
1995
2052
2109
2166
2223
2280
2337
2394
2451
2508
2565
2622
2679
2736
2793
2850
2907
2964
3021
3078
3135
3192
3249
3306
3363
3420
3477
3534
3591
3...

result:

ok 1000000 lines

Test #75:

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

input:

500 30 1000000
10 18
8 12
6 28
16 28
5 15
7 16
16 16
14 27
18 18
0 29
2 3
9 24
20 28
0 25
7 17
23 29
2 20
27 28
3 29
5 26
13 22
4 12
6 24
2 29
0 17
1 12
4 8
0 15
9 21
16 18
13 24
8 23
22 24
4 9
3 13
10 12
19 26
5 16
0 24
24 29
10 28
2 29
2 28
3 15
21 22
5 23
2 17
12 19
12 27
12 21
3 10
16 21
3 16
9 ...

output:

0
18
36
54
72
90
108
126
144
162
180
198
216
234
252
270
288
306
324
342
360
378
396
414
432
450
468
486
504
522
540
558
576
594
612
630
648
666
684
702
720
738
756
774
792
810
828
846
864
882
900
918
936
954
972
990
1008
1026
1044
1062
1080
1098
1116
1134
1152
1170
1188
1206
1224
1242
1260
1278
129...

result:

ok 1000000 lines

Test #76:

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

input:

500 100 1000000
13 89
2 76
18 73
24 56
63 92
20 47
8 89
7 81
5 83
67 86
3 92
28 76
17 40
59 81
40 73
15 61
39 52
3 26
12 92
41 83
5 79
3 99
4 80
13 99
50 72
0 65
7 89
38 54
7 70
41 78
0 78
0 84
25 95
7 57
26 61
2 69
6 92
16 80
14 63
7 57
25 95
78 96
12 89
53 76
12 79
47 70
2 98
1 99
37 66
70 82
22 6...

output:

0
7
14
21
28
35
42
49
56
63
70
77
84
91
98
105
112
119
126
133
140
147
154
161
168
175
182
189
196
203
210
217
224
231
238
245
252
259
266
273
280
287
294
301
308
315
322
329
336
343
350
357
364
371
378
385
392
399
406
413
420
427
434
441
448
455
462
469
476
483
490
497
504
511
518
525
532
539
546
5...

result:

ok 1000000 lines

Test #77:

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

input:

461 22 1000000
0 0
2 21
0 1
3 21
0 1
3 21
0 2
4 21
0 2
4 21
0 2
4 21
0 3
5 21
0 3
5 21
0 3
5 21
0 3
5 21
0 4
6 21
0 4
6 21
0 4
6 21
0 4
6 21
0 4
6 21
0 5
7 21
0 5
7 21
0 5
7 21
0 5
7 21
0 5
7 21
0 5
7 21
0 6
8 21
0 6
8 21
0 6
8 21
0 6
8 21
0 6
8 21
0 6
8 21
0 6
8 21
0 7
9 21
0 7
9 21
0 7
9 21
0 7
9 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #78:

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

input:

500 1000000000 1000000
4600557 4600564
756764177 756764179
216540540 216540540
767599584 767599593
367468228 367468235
868222853 868222856
625990645 625990647
70342014 70342023
294743287 294743289
520593063 520593068
28235832 28235838
367900160 367900163
317427876 317427884
197480203 197480211
49324...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #79:

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

input:

500 1000000000 1000000
631752009 631752016
19530696 19530704
881668706 881668709
262493874 262493879
808389472 808389475
142402770 142402772
31478426 31478428
170667367 170667367
703858861 703858865
145774072 145774079
669286634 669286634
324943585 324943587
418807948 418807953
960795840 960795845
1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #80:

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

input:

500 1000000000 1000000
716565605 716565610
545504668 545504670
118924856 118924863
36921024 36921032
594989166 594989168
871118893 871118895
310243250 310243257
608002805 608002812
622224083 622224088
390365808 390365817
314400653 314400662
577325699 577325708
636008 636010
527688389 527688395
58211...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Subtask #4:

score: 21
Accepted

Dependency #3:

100%
Accepted

Test #81:

score: 21
Accepted
time: 102ms
memory: 13852kb

input:

2500 10 1000000
2 4
0 7
3 8
4 6
8 8
4 8
2 9
2 6
2 7
1 8
1 8
5 5
7 9
2 3
0 5
7 9
2 9
5 5
0 8
2 7
1 2
0 9
7 7
2 5
8 8
3 7
1 7
1 9
2 2
1 9
0 9
0 9
1 7
5 9
1 9
1 5
5 9
8 8
1 9
0 1
0 9
2 7
2 8
1 6
0 9
5 5
5 7
0 6
0 7
9 9
6 7
1 9
4 5
2 9
4 9
0 8
6 7
0 4
2 8
9 9
0 6
4 4
1 9
0 8
1 7
0 9
1 8
4 9
9 9
0 6
0 2
...

output:

202716713415
155641698441
360457519867
136236145628
446508021228
210683131021
397110227104
210570785740
224121434536
163392150410
69039781971
298676679289
420443635576
270783701717
201909499765
443414872992
57361326310
173008649108
467971241729
255803567112
279535248302
202075864752
146333653116
283...

result:

ok 1000000 lines

Test #82:

score: 0
Accepted
time: 102ms
memory: 13988kb

input:

2500 10 1000000
8 8
1 3
2 9
1 6
1 6
4 8
0 9
4 9
0 9
0 9
3 8
0 9
0 9
1 9
7 9
1 9
0 4
3 8
5 7
6 9
1 7
2 8
1 8
0 1
1 9
5 5
1 6
7 7
1 8
1 4
0 0
0 5
2 9
3 4
1 8
1 8
0 5
8 8
3 7
0 6
5 5
1 3
2 3
0 7
0 9
1 7
3 8
1 6
2 7
5 7
0 0
0 9
0 6
0 8
3 5
5 9
0 5
5 7
0 8
2 2
0 9
4 6
1 9
6 8
7 9
2 5
0 8
5 6
1 6
5 6
1 3
...

output:

85475678478
285675128193
400945857428
499656087835
197090498451
77068218141
447698951194
165365799845
180490678676
179724982174
44099233992
537438483142
220446192809
439502594828
174890021838
27250628244
406551608939
156710056849
208006178887
333953869620
401730325722
421875794738
215965462076
29243...

result:

ok 1000000 lines

Test #83:

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

input:

2500 10 1000000
3 7
3 9
0 7
4 5
3 4
3 6
0 9
0 9
3 9
1 8
3 9
0 9
6 6
0 9
4 8
4 8
2 8
0 7
2 6
2 7
0 9
1 2
1 6
1 7
3 3
5 9
2 8
1 1
0 8
5 9
1 8
2 6
0 2
5 5
1 9
0 6
2 4
2 7
4 8
5 8
1 7
1 3
2 8
0 7
1 6
2 6
3 9
5 9
6 7
5 9
4 5
1 5
4 8
0 7
1 8
0 9
2 9
0 4
3 6
5 8
4 9
2 7
1 5
1 9
7 7
0 5
0 6
0 8
3 9
6 6
1 9
...

output:

127772852238
346700654936
293065255328
293897782242
297136847468
273098883578
457329424195
380972896015
445420501770
64415215483
311332841227
318226041802
515036962766
384176969476
488575636278
159721680753
340872566012
140375726256
278471300492
56030651632
290131793910
137808499733
134393745280
128...

result:

ok 1000000 lines

Test #84:

score: 0
Accepted
time: 89ms
memory: 13972kb

input:

2500 30 1000000
5 21
12 24
3 23
14 15
13 17
0 13
13 28
4 26
1 27
2 20
19 22
3 24
3 21
17 19
12 26
4 22
1 25
4 14
1 29
8 13
3 22
1 28
0 21
4 23
0 22
2 16
7 28
14 26
3 17
0 14
6 28
18 29
13 26
6 23
5 24
4 27
7 24
9 22
4 23
0 28
11 28
5 28
16 26
16 20
1 27
15 19
14 17
0 2
5 26
0 24
0 19
16 29
6 29
4 29...

output:

133864821998
89702303433
73516988570
111512403710
128188114273
171103517774
53707658069
123907256279
187292066961
107824657355
57130710875
95719033744
127011591935
40248613886
97540078436
148718044970
71020162859
3837569212
167575471153
101509100064
231236158475
209664436293
120430755797
22595851200...

result:

ok 1000000 lines

Test #85:

score: 0
Accepted
time: 95ms
memory: 14252kb

input:

2500 100 1000000
12 57
1 97
92 95
67 76
1 98
10 93
3 85
63 69
51 82
17 51
22 93
1 89
3 79
16 55
8 24
68 95
10 71
27 92
15 56
8 89
92 99
3 14
75 99
0 99
86 96
0 97
25 70
34 55
39 96
11 67
24 53
17 98
0 99
4 97
24 70
25 64
49 96
58 59
10 50
1 71
27 59
17 74
46 75
45 89
18 82
47 70
53 82
11 96
13 97
40...

output:

429552000
38832908073
768833520
36265987020
48156683816
50180054170
13084931973
39608277041
6618544080
59748292920
2038787520
65677436178
34795035054
54437925266
11705170465
31245725139
14805222360
44926399014
32309428026
25902651502
25686328736
51757919230
73928752231
19272654879
73041707826
420958...

result:

ok 1000000 lines

Test #86:

score: 0
Accepted
time: 81ms
memory: 14248kb

input:

2500 300 1000000
6 228
11 240
144 169
66 245
9 240
191 248
18 298
95 205
71 184
114 121
40 84
85 204
90 264
72 269
1 294
28 289
66 272
1 296
86 294
64 295
11 286
37 113
198 236
38 248
20 105
8 299
99 275
30 163
26 292
200 270
123 282
42 113
1 296
164 214
218 278
79 228
170 202
259 263
71 280
3 273
3...

output:

10076564282
1362359552
2462231398
4265991744
16310343548
11453114748
14505839669
10649158668
17023901871
1684764490
25920970087
18494037928
24562755420
25737994783
5270745570
2854504372
20416665416
10776052
2015645848
12187109292
22225825789
22753880070
14627899456
21297803478
8333117299
4508041059
...

result:

ok 1000000 lines

Test #87:

score: 0
Accepted
time: 86ms
memory: 15192kb

input:

2500 1000 1000000
18 978
96 587
40 222
549 664
70 937
53 690
530 892
106 973
83 953
220 257
519 608
78 804
727 886
181 656
415 471
50 913
49 418
2 996
199 243
97 750
587 662
94 605
136 969
93 768
144 353
111 263
208 357
52 876
77 173
218 411
169 461
275 914
11 377
160 800
221 610
45 835
480 990
132 ...

output:

383852986
2248040145
4904229399
4018150488
10025125246
2512794420
245708805
4884328785
2364437235
3481463701
28510467
9758355705
94248180
2203671525
8408295411
6815644676
7694666413
10235601089
5376008964
8410292173
7141759975
8639703803
8372503882
8444263167
6312737463
7760175467
9382258075
1027484...

result:

ok 1000000 lines

Test #88:

score: 0
Accepted
time: 55ms
memory: 13668kb

input:

2500 1000000000 1000000
330841480 626166941
22799338 138076963
96972292 126137110
795165283 831623951
380583195 675049269
73226426 775235596
496523480 966512941
42537558 656768488
635620317 989069417
5987934 960235800
8675003 996282216
687823817 947094849
118411465 760191764
727004462 848555919
1932...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #89:

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

input:

2491 999999992 1000000
136752487 969607973
196118363 968725156
197169245 963524357
437573534 938665516
81307890 180832266
76084062 523341697
591906208 751997130
126125979 706071734
434000623 688626443
65465184 389760360
57192645 869107851
98277726 511604154
483720934 729552423
223507000 913207193
39...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #90:

score: 0
Accepted
time: 44ms
memory: 13900kb

input:

2390 832948293 1000000
19590204 830635152
674835963 826947093
259405881 831311649
711517467 732312834
399898490 786576582
552068975 637513876
261905924 686384789
28199569 305955433
711393372 828062885
312343388 543660237
124470914 683683832
6280411 767841180
153862007 809533706
32355590 371089093
40...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #91:

score: 0
Accepted
time: 148ms
memory: 13948kb

input:

2500 1000000000 1000000
0 48201122
0 492017449
0 635015380
854563292 999999999
0 760377050
0 288794575
0 123118853
0 12717304
0 760309562
284887489 999999999
0 669217907
467121003 999999999
0 802951998
746774077 999999999
0 711902780
57536283 999999999
0 311113891
646849814 999999999
772461378 99999...

output:

609959626705
585235799880
93790360250
321745670235
251584385855
438255133415
485953745306
174848457369
360551562595
377115519036
331976180037
81621036000
29243542200
137994568722
192251843900
509730887625
193306474050
136759759724
97967275600
171903104200
329895245350
472428375082
383937939357
37501...

result:

ok 1000000 lines

Test #92:

score: 0
Accepted
time: 139ms
memory: 14244kb

input:

2498 999993942 1000000
0 944515334
729296443 999993941
492909514 999993941
729636554 999993941
731503661 999993941
125242 999993941
0 66144067
0 166759539
0 605490959
0 218269521
246045413 999993941
0 323414497
704013707 999993941
0 728281806
0 802960174
0 882120096
0 290804619
865963815 999993941
0...

output:

204352475422
361263600960
240606588975
44721466680
116228241576
269664683360
373266419665
213705865423
134251921100
174783813358
186267524995
198474941920
474727512210
534752330116
185334781200
262623899345
90467066915
386940106750
226847237974
334568380288
125745375580
410599169345
159029161148
410...

result:

ok 1000000 lines

Test #93:

score: 0
Accepted
time: 150ms
memory: 14248kb

input:

2480 798098123 1000000
432003211 798098122
335819616 798098122
51343915 798098122
0 125412984
0 703546428
542689368 798098122
355193274 798098122
505476741 798098122
0 366876620
32863092 798098122
0 213041601
0 202645210
0 319465963
0 554617046
163627543 798098122
566402042 798098122
557267200 79809...

output:

507518378616
208485115170
250370604534
557279363360
561484385440
188394539292
9504445744
75724048993
290815363810
215116674452
80117272589
589983240950
328583668826
295523671527
5703422820
224306059712
262822671591
373259697566
91235771249
194053280549
461390304795
234474102849
579341147194
26955188...

result:

ok 1000000 lines

Test #94:

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

input:

2449 50 1000000
0 0
2 49
0 1
3 49
0 1
3 49
0 2
4 49
0 2
4 49
0 2
4 49
0 3
5 49
0 3
5 49
0 3
5 49
0 3
5 49
0 4
6 49
0 4
6 49
0 4
6 49
0 4
6 49
0 4
6 49
0 5
7 49
0 5
7 49
0 5
7 49
0 5
7 49
0 5
7 49
0 5
7 49
0 6
8 49
0 6
8 49
0 6
8 49
0 6
8 49
0 6
8 49
0 6
8 49
0 6
8 49
0 7
9 49
0 7
9 49
0 7
9 49
0 7
9...

output:

5930222942
17857867475
15386552833
35387201955
1008190386
45988937904
2516242120
40472832968
17357638156
11416419011
12914730374
27346196954
18568992279
35117484836
42180583240
47860457438
3452649221
36687712654
44639858884
4493181175
8677213902
12814241566
26224317056
42786424432
15619839344
156003...

result:

ok 1000000 lines

Test #95:

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

input:

2500 10 1000000
2 8
1 3
5 9
0 9
0 9
1 7
2 4
1 1
6 9
2 6
3 8
0 1
2 5
0 0
0 5
2 7
0 1
1 7
1 4
5 9
1 9
0 1
5 5
4 6
0 8
1 5
7 9
0 7
5 8
1 3
8 9
5 5
5 9
1 8
1 4
4 8
3 8
0 1
0 9
1 4
2 6
1 8
4 9
2 9
2 6
6 6
1 8
5 8
1 9
4 9
5 8
0 9
1 9
0 6
2 5
0 7
0 6
0 7
0 9
0 6
1 8
4 7
1 6
2 6
1 8
0 7
2 4
3 3
1 8
0 9
4 8
...

output:

0
263
526
789
1052
1315
1578
1841
2104
2367
2630
2893
3156
3419
3682
3945
4208
4471
4734
4997
5260
5523
5786
6049
6312
6575
6838
7101
7364
7627
7890
8153
8416
8679
8942
9205
9468
9731
9994
10257
10520
10783
11046
11309
11572
11835
12098
12361
12624
12887
13150
13413
13676
13939
14202
14465
14728
149...

result:

ok 1000000 lines

Test #96:

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

input:

2500 30 1000000
1 16
0 25
8 27
2 4
18 21
3 22
1 28
19 19
6 28
8 14
23 24
3 19
4 28
0 13
2 18
4 24
16 21
21 22
15 28
1 5
25 29
2 17
1 11
12 20
1 28
28 29
11 21
0 0
1 29
3 23
18 24
16 29
0 8
3 22
1 6
5 10
2 29
0 17
3 22
7 29
11 26
2 27
17 29
19 23
9 24
8 25
0 18
17 23
11 14
0 18
2 6
20 28
24 29
2 25
1...

output:

0
79
158
237
316
395
474
553
632
711
790
869
948
1027
1106
1185
1264
1343
1422
1501
1580
1659
1738
1817
1896
1975
2054
2133
2212
2291
2370
2449
2528
2607
2686
2765
2844
2923
3002
3081
3160
3239
3318
3397
3476
3555
3634
3713
3792
3871
3950
4029
4108
4187
4266
4345
4424
4503
4582
4661
4740
4819
4898
4...

result:

ok 1000000 lines

Test #97:

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

input:

2500 100 1000000
51 70
87 97
2 97
10 89
60 88
50 82
11 80
32 81
25 59
32 40
2 98
41 42
14 60
68 98
48 51
1 92
37 42
22 25
31 72
8 22
3 16
47 96
6 26
14 95
13 74
57 78
21 54
48 75
22 95
4 59
61 74
47 67
3 90
77 86
7 63
22 91
29 63
34 49
71 71
11 49
46 55
74 92
56 58
30 72
38 98
5 13
46 97
7 88
1 98
2...

output:

0
18
36
54
72
90
108
126
144
162
180
198
216
234
252
270
288
306
324
342
360
378
396
414
432
450
468
486
504
522
540
558
576
594
612
630
648
666
684
702
720
738
756
774
792
810
828
846
864
882
900
918
936
954
972
990
1008
1026
1044
1062
1080
1098
1116
1134
1152
1170
1188
1206
1224
1242
1260
1278
129...

result:

ok 1000000 lines

Test #98:

score: 0
Accepted
time: 67ms
memory: 14192kb

input:

2449 50 1000000
0 0
2 49
0 1
3 49
0 1
3 49
0 2
4 49
0 2
4 49
0 2
4 49
0 3
5 49
0 3
5 49
0 3
5 49
0 3
5 49
0 4
6 49
0 4
6 49
0 4
6 49
0 4
6 49
0 4
6 49
0 5
7 49
0 5
7 49
0 5
7 49
0 5
7 49
0 5
7 49
0 5
7 49
0 6
8 49
0 6
8 49
0 6
8 49
0 6
8 49
0 6
8 49
0 6
8 49
0 6
8 49
0 7
9 49
0 7
9 49
0 7
9 49
0 7
9...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #99:

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

input:

2500 1000000000 1000000
667601017 667601026
54891347 54891351
861501739 861501748
696279821 696279829
401248094 401248094
918414139 918414139
203492030 203492031
669881322 669881327
725771677 725771682
155004448 155004450
358621058 358621060
695270164 695270164
519875858 519875861
198584353 19858435...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #100:

score: 0
Accepted
time: 50ms
memory: 14252kb

input:

2500 1000000000 1000000
496108153 496108156
267333505 267333513
672122406 672122406
284195633 284195636
388584981 388584981
479984941 479984947
677086257 677086259
132682495 132682501
124678730 124678739
464403052 464403052
414317568 414317570
532253833 532253838
148214061 148214067
55484322 5548432...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #101:

score: 0
Accepted
time: 54ms
memory: 14272kb

input:

2500 1000000000 1000000
948851943 948851944
250857 250858
930305770 930305774
183742593 183742599
177967209 177967214
993753915 993753924
241522653 241522661
253946339 253946342
938942576 938942577
134103349 134103357
338873700 338873705
652637957 652637959
190113885 190113888
352001563 352001572
34...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Subtask #5:

score: 31
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #102:

score: 31
Accepted
time: 141ms
memory: 13964kb

input:

10000 10 1000000
1 7
7 9
7 8
0 8
2 9
1 5
3 7
0 4
3 9
3 6
1 9
6 8
1 9
0 8
1 8
0 9
1 8
0 8
8 8
2 7
0 7
0 8
5 5
2 7
1 5
0 5
0 8
7 8
1 4
1 3
0 7
5 8
1 3
4 7
4 5
6 8
2 7
1 8
2 7
1 7
3 3
2 5
2 5
0 9
3 9
1 2
5 9
3 6
1 6
1 8
6 8
5 9
0 9
2 4
1 8
0 9
1 6
0 8
2 5
2 8
0 9
8 9
0 9
2 7
4 7
4 6
5 9
7 8
4 5
3 8
2 3...

output:

435638994220
664393110774
426012917626
651697453598
640537512702
1134327159200
1068493569255
463608974760
998497839132
1080320757416
631746155005
960369032451
1959091408467
946712654566
811052843952
1327693857396
1537538129205
1013534156551
1712041841754
1503359982267
1006598507818
548437429918
6346...

result:

ok 1000000 lines

Test #103:

score: 0
Accepted
time: 150ms
memory: 14628kb

input:

10000 10 1000000
5 9
0 7
1 6
1 4
0 7
1 8
0 9
3 4
0 8
8 9
0 7
1 7
2 7
0 9
4 9
0 3
3 7
2 7
9 9
2 8
1 5
2 7
1 9
1 7
2 4
0 9
2 2
5 8
6 9
0 7
3 7
5 9
1 4
4 8
3 3
6 7
9 9
7 9
0 5
0 9
4 7
4 4
1 2
0 9
3 8
0 9
1 6
6 6
2 4
1 6
0 6
3 8
2 9
1 7
4 6
1 5
1 8
1 7
3 8
4 4
2 6
5 8
3 8
2 3
5 5
2 8
0 4
1 9
5 7
1 7
1 4...

output:

1318435365183
908827237290
1174630708404
113544270546
1212788631981
183934198726
1573291422783
460473710344
518878918884
962406393147
1106766995070
1112425455021
2040084152064
1513717269426
1433367591039
496829263512
230533613534
1237516141053
1970620634118
237927803818
551713314244
1583315087743
15...

result:

ok 1000000 lines

Test #104:

score: 0
Accepted
time: 140ms
memory: 14656kb

input:

10000 10 1000000
4 8
7 8
7 9
0 6
0 6
3 6
0 9
2 4
0 3
0 3
1 8
0 1
6 8
7 8
0 7
0 9
4 5
0 8
4 4
8 8
0 7
0 0
4 9
1 9
3 7
1 1
2 9
0 9
2 4
2 4
0 6
3 6
1 5
0 9
0 9
4 8
2 7
5 7
3 5
1 3
1 9
0 8
1 7
5 6
2 7
0 9
1 9
0 9
3 3
0 7
1 6
3 9
2 2
1 8
0 8
0 2
3 8
0 4
5 9
0 9
1 7
4 5
0 5
0 5
0 8
0 8
3 6
1 7
0 9
0 9
4 7...

output:

1319674748708
876664390518
1467135301053
1157996040822
1098784829971
686024414820
482935558421
229898117480
760909122223
1965354882070
1084282592531
777818541803
1306096380375
1784535784050
1398495500983
542329687394
1882071858164
814423605721
1210473766366
430108408825
1427481200585
1970402137936
2...

result:

ok 1000000 lines

Test #105:

score: 0
Accepted
time: 156ms
memory: 15624kb

input:

10000 30 1000000
1 12
15 26
1 29
4 20
5 17
21 27
4 15
0 29
0 22
5 22
8 13
15 21
4 21
5 27
20 28
7 9
0 23
1 26
0 27
1 4
0 10
6 22
5 16
28 29
1 28
9 18
7 21
12 13
0 28
0 5
18 21
0 19
1 28
0 29
0 14
3 29
2 24
17 18
5 20
19 27
13 26
1 29
14 27
1 28
1 13
10 24
10 19
12 21
12 27
3 23
3 28
9 26
0 27
21 28
...

output:

709386546810
387591730482
254188414959
404910358938
75381899664
649787457440
507384834847
410028519405
279042440464
345582787379
161285700954
391303452683
782339353401
239439744121
578483412202
69749841231
312253933833
78536163607
266342163301
398708469308
518441270331
670435285827
154590522088
3983...

result:

ok 1000000 lines

Test #106:

score: 0
Accepted
time: 163ms
memory: 14716kb

input:

10000 100 1000000
14 57
29 86
73 83
60 83
59 99
7 56
14 74
11 96
3 87
39 61
3 91
5 97
0 24
11 27
3 77
16 85
63 65
41 86
77 93
36 84
10 80
8 72
24 27
73 89
1 90
8 94
19 90
18 75
41 41
59 82
29 59
20 79
55 79
24 84
44 93
40 77
27 38
15 38
36 85
6 92
51 79
27 87
12 82
2 94
29 35
8 77
1 99
75 96
52 57
8...

output:

179258634762
20171206439
246691026142
2861120146
213015557862
178712231975
21060673308
234665988357
323272330549
96155486895
30355539704
158480971593
197173152583
118285901275
226345171570
241674497966
32042795539
88247764638
211456054983
135825930847
224542737001
341326860198
182867896835
848150069...

result:

ok 1000000 lines

Test #107:

score: 0
Accepted
time: 161ms
memory: 14708kb

input:

10000 300 1000000
181 194
111 298
31 60
203 293
112 186
26 248
110 273
105 299
4 270
30 229
97 166
16 239
166 188
209 295
214 265
80 283
15 154
80 247
72 255
0 299
151 285
31 260
137 262
71 102
41 296
1 273
175 274
87 260
111 124
135 272
134 198
31 273
4 31
48 162
3 267
81 127
183 283
162 276
86 295...

output:

20238198730
65308239744
53470409736
77859229266
113010561855
31987956605
113427064341
147031338690
105246987192
58446470310
86583029643
70041744306
88445172168
79060854302
77774247413
44375592460
99315064322
113404508694
124905261636
39676078899
48661556068
34995151310
69728668716
20026812761
944476...

result:

ok 1000000 lines

Test #108:

score: 0
Accepted
time: 128ms
memory: 14688kb

input:

10000 1000 1000000
294 754
4 948
123 893
304 690
42 677
411 557
185 870
633 840
634 980
255 715
314 615
347 795
155 748
141 923
11 20
838 860
28 173
927 929
45 921
588 974
2 989
325 774
42 135
298 983
506 659
85 704
30 723
308 804
638 937
104 881
209 816
40 948
16 434
216 829
242 812
8 970
585 816
2...

output:

11851567173
2219034054
16460893681
11371629125
20409736853
6056262134
21206263864
27748449290
24007044930
22084257226
23713979671
6917791440
30587469262
9477128936
11417643287
10716848737
6271788736
15431943594
22260030150
18941822293
52046875618
22838324071
30194748087
34183159571
18043689666
67797...

result:

ok 1000000 lines

Test #109:

score: 0
Accepted
time: 71ms
memory: 15480kb

input:

9999 1000000000 1000000
52327597 998116022
159348159 980345496
299719584 543958715
69359463 880876942
7175633 946026997
144988956 950245081
384971357 861247856
498065805 562188673
199404314 566117991
749870222 973201003
111312602 878404357
472902522 888053555
129432755 265860653
548129821 576659357
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #110:

score: 0
Accepted
time: 67ms
memory: 15412kb

input:

9838 992399882 1000000
122601400 707455514
67936245 304038445
52548996 768381078
94958172 530163669
648564265 954730977
279228731 866926120
341169692 923718170
214171650 922455051
176188862 606059687
25706907 529599149
610297406 912586769
618692791 912273917
182693335 934298879
388590791 565071967
5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #111:

score: 0
Accepted
time: 57ms
memory: 15380kb

input:

10000 982892389 1000000
453047667 915319989
66387288 525131627
78991219 917717548
319001436 605213304
382139452 693266855
186455944 977947834
270711455 912692294
608253878 745786142
310771885 368241478
112118800 562413849
433576040 442746774
722044833 803649214
11601182 768558782
605458271 655650564...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #112:

score: 0
Accepted
time: 537ms
memory: 14948kb

input:

9899 993129898 1000000
34440452 993129897
0 978463665
0 79959726
0 410214528
873669236 993129897
0 761154275
427948661 993129897
0 581323842
361721046 993129897
316626663 993129897
190246218 993129897
0 988673075
0 915758482
0 154173209
241774618 993129897
0 47533776
23746599 993129897
367861135 993...

output:

1709639100835
1193065027750
1557993377590
673156940388
1726951196212
1075039880060
1395130456649
1673328071100
679450236734
1177572182400
1209175657416
588349693654
551033663490
1778137224984
1141863013656
1129965744532
1959786026761
1912663611546
1914708353213
1941266531960
734942731508
54616230072...

result:

ok 1000000 lines

Test #113:

score: 0
Accepted
time: 487ms
memory: 15204kb

input:

9992 999992399 1000000
11219055 999992398
0 506561703
551874778 999992398
0 606379085
511645447 999992398
0 232924709
0 497185072
951062963 999992398
665423891 999992398
306142281 999992398
0 298883816
423866171 999992398
0 555891301
711896995 999992398
908988323 999992398
239215835 999992398
187205...

output:

1289320635466
964935093504
678871505408
2140844712728
1024611191700
188165273230
609761608210
954138043426
354736800178
1514722400940
1622147690252
1301615476432
303512434444
1153386850079
545866645230
960215604276
1682005593350
895000193573
211548461138
783788004673
1102559466378
428858381802
93076...

result:

ok 1000000 lines

Test #114:

score: 0
Accepted
time: 514ms
memory: 14492kb

input:

10000 1000000000 1000000
0 466349309
246169072 999999999
803996260 999999999
0 179685015
0 994940903
113672481 999999999
0 670181891
884685288 999999999
0 774285142
0 679627517
0 876750092
0 293271117
0 48397460
815410360 999999999
0 20729376
882839502 999999999
0 275470120
104159019 999999999
19264...

output:

1530806319643
812886594630
615912895620
134573087880
349232318256
263987720700
273275324048
1260555311149
650120068382
547226761764
2405469088417
656222406087
1121974669892
1025014134570
527352936330
755174953681
1349790921270
1942806834416
739699650128
498521530810
2087989151587
1572935666784
22970...

result:

ok 1000000 lines

Test #115:

score: 0
Accepted
time: 422ms
memory: 13764kb

input:

9899 100 1000000
0 0
2 99
0 1
3 99
0 1
3 99
0 2
4 99
0 2
4 99
0 2
4 99
0 3
5 99
0 3
5 99
0 3
5 99
0 3
5 99
0 4
6 99
0 4
6 99
0 4
6 99
0 4
6 99
0 4
6 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 7
9 99
0 7
9 99
0 7
9 99
0 7
...

output:

11076741126
78106592400
2598174018
41367005064
49215291246
1138679883
41800479787
58256296560
4726533636
16122604410
12632555529
42397509530
23772030084
37776510684
50852912616
42916427144
11043209430
29285423937
38083916727
22003139664
81152846016
46601288912
24666183135
41183960301
29183101992
451...

result:

ok 1000000 lines

Test #116:

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

input:

10000 10 1000000
3 7
1 5
4 8
0 0
5 6
3 9
0 6
3 7
1 7
4 7
0 8
1 4
6 6
5 7
0 8
1 7
7 7
0 7
4 5
0 6
0 9
0 6
3 6
1 9
0 1
2 7
5 7
1 7
7 9
0 8
1 2
3 6
7 8
0 7
7 8
5 6
6 8
0 8
4 5
8 9
3 8
0 7
2 5
2 4
1 6
7 7
0 9
0 9
3 8
0 7
1 5
6 9
0 1
0 4
0 5
0 9
0 5
5 9
3 9
1 5
1 9
0 8
8 9
0 9
0 9
3 7
0 7
2 5
3 7
1 6
1 8...

output:

0
971
1942
2913
3884
4855
5826
6797
7768
8739
9710
10681
11652
12623
13594
14565
15536
16507
17478
18449
19420
20391
21362
22333
23304
24275
25246
26217
27188
28159
29130
30101
31072
32043
33014
33985
34956
35927
36898
37869
38840
39811
40782
41753
42724
43695
44666
45637
46608
47579
48550
49521
504...

result:

ok 1000000 lines

Test #117:

score: 0
Accepted
time: 102ms
memory: 14488kb

input:

10000 30 1000000
22 29
16 25
0 27
1 27
14 15
2 29
9 29
2 17
0 10
1 22
0 26
3 18
7 26
2 29
3 18
1 22
1 5
0 16
0 22
14 25
18 27
8 22
7 26
1 4
2 18
4 29
12 28
0 25
7 18
9 24
1 24
6 26
10 29
15 25
4 12
22 23
5 25
23 25
0 13
17 21
7 29
0 27
1 9
2 19
20 20
10 29
9 21
16 29
13 25
21 21
8 9
2 28
4 21
0 25
1...

output:

0
335
670
1005
1340
1675
2010
2345
2680
3015
3350
3685
4020
4355
4690
5025
5360
5695
6030
6365
6700
7035
7370
7705
8040
8375
8710
9045
9380
9715
10050
10385
10720
11055
11390
11725
12060
12395
12730
13065
13400
13735
14070
14405
14740
15075
15410
15745
16080
16415
16750
17085
17420
17755
18090
18425...

result:

ok 1000000 lines

Test #118:

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

input:

10000 100 1000000
16 73
2 94
0 94
75 99
75 91
10 10
5 45
14 69
4 69
22 74
19 91
21 48
16 74
3 59
45 86
65 80
2 69
13 79
12 33
31 45
9 62
20 95
27 55
75 94
69 90
37 80
14 87
3 97
44 65
13 41
21 40
61 65
31 40
2 92
41 54
49 87
62 65
6 89
15 37
12 97
20 27
1 92
24 47
40 58
4 90
6 98
81 84
56 98
19 44
2...

output:

0
116
232
348
464
580
696
812
928
1044
1160
1276
1392
1508
1624
1740
1856
1972
2088
2204
2320
2436
2552
2668
2784
2900
3016
3132
3248
3364
3480
3596
3712
3828
3944
4060
4176
4292
4408
4524
4640
4756
4872
4988
5104
5220
5336
5452
5568
5684
5800
5916
6032
6148
6264
6380
6496
6612
6728
6844
6960
7076
7...

result:

ok 1000000 lines

Test #119:

score: 0
Accepted
time: 373ms
memory: 14112kb

input:

9899 100 1000000
0 0
2 99
0 1
3 99
0 1
3 99
0 2
4 99
0 2
4 99
0 2
4 99
0 3
5 99
0 3
5 99
0 3
5 99
0 3
5 99
0 4
6 99
0 4
6 99
0 4
6 99
0 4
6 99
0 4
6 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 5
7 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 6
8 99
0 7
9 99
0 7
9 99
0 7
9 99
0 7
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #120:

score: 0
Accepted
time: 53ms
memory: 15532kb

input:

10000 1000000000 1000000
186712020 186712027
271066003 271066006
6249040 6249042
706744976 706744982
585719779 585719787
267673769 267673777
181372528 181372529
447527906 447527914
874220601 874220609
813172069 813172076
685387740 685387744
196078944 196078952
355641818 355641819
706941622 706941624...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #121:

score: 0
Accepted
time: 53ms
memory: 15488kb

input:

10000 1000000000 1000000
232243994 232244001
566565898 566565899
937676008 937676013
587969653 587969662
865755459 865755464
949908218 949908219
44013288 44013289
905151495 905151502
846814619 846814624
283059436 283059441
481548047 481548056
31722731 31722738
754394661 754394669
543118902 543118911...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines

Test #122:

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

input:

10000 1000000000 1000000
591857357 591857362
27477749 27477756
45645555 45645564
233457184 233457192
166794790 166794791
990013455 990013456
950339905 950339911
819758456 819758458
675856408 675856417
178745516 178745523
607614580 607614587
393981450 393981454
370519582 370519587
436260774 436260774...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000000 lines