QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#165282#3970. Optimal Truckhrjames1526#100 ✓283ms28364kbC++174.1kb2023-09-05 17:17:112024-07-04 01:52:47

Judging History

This is the latest submission verdict.

  • [2024-07-04 01:52:47]
  • Judged
  • Verdict: 100
  • Time: 283ms
  • Memory: 28364kb
  • [2023-09-05 17:17:11]
  • Submitted

answer


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define sz(a) (int)(a.size())
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long
#define problem "a"
 
template<typename A, typename B, typename C>
struct triple {
    A X;
    B Y;
    C Z;
    triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0) {
    return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b) {
    if (a.X != b.X)
        return a.X < b.X;
    if (a.Y != b.Y)
        return a.Y < b.Y;
    return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p) {
    ofs << "( " << p.F << " , " << p.S << " )";
    return ofs;
}
template<typename T>
void print(T a) {
    for (auto i : a)
        cout << i << ' ';
    cout << '\n';
}
template<typename T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}
template<typename T, typename D>
D min(T a) {
    return *min_element(all(a));
}
template<typename T, typename D>
D max(T a) {
    return *max_element(all(a));
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void solve() {
    int n; cin >> n;
    vector<vector<pii> > a(n);
    rngi(i, n) {
        vector<pii> b;
        int m; cin >> m;
        b.resize(m);
        rngi(j, m) cin >> b[j].first >> b[j].second;
        //rngi(j, m) b[j] = { rand() % 100, rand() % 10 };
        SORT(b);
        a[i].push_back({ 0,0 });
        int c = 0;
        rngi(j, m)
            if (b[j].second > c) {
                a[i].push_back(b[j]);
                c = b[j].second;
            }
    }
    vector<pii> c; c.push_back({ 0,0 });
    rngi(i, n)
        for (int j = 1; j < sz(a[i]); j++) c.push_back({ a[i][j].first, a[i][j].second - a[i][j - 1].second });
    SORT(c);
    rngi(i, sz(c) - 1) c[i + 1].second += c[i].second;
    int q; cin >> q;
    auto g = [&](int x) {
        int v = upper_bound(all(c), pii{ x, (int)inf }) - c.begin();
        return c[v - 1].second;
    };
    rng(q) {
        int x; cin >> x;
        int l = 1, r = 1e9 + 1;
        while (r - l > 1) {
            int m = l + r >> 1;
            if (g(m) >= x) r = m; else l = m;
        }
        if (g(l) >= x) cout << l << '\n'; else if (r == 1e9 + 1) cout << "-1\n"; else  cout << r << '\n';
    }
};
signed main()
{
    if (0) {
        freopen(problem".in", "r", stdin);
        freopen(problem".out", "w", stdout);
    }
    srand(time(NULL));
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int t = 1;// cin >> t;
    rng(t) solve();
}
 

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 1ms
memory: 3660kb

input:

3
2
10 20
20 30
1
40 50
3
2 5
1 10
4 7
5
10 55 32 100 17

output:

1
40
20
-1
10

result:

ok 5 number(s): "1 40 20 -1 10"

Test #2:

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

input:

1
10
80 81
23 19
19 18
45 43
46 47
89 84
14 18
85 85
43 41
4 1
10
59 95 4 45 55 76 81 23 88 66

output:

80
-1
14
46
80
80
80
43
-1
80

result:

ok 10 numbers

Test #3:

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

input:

2
4
35 20
52 28
88 47
47 25
6
45 23
5 3
61 34
87 50
2 1
97 51
10
74 2 37 96 35 63 2 73 4 24

output:

87
5
45
88
45
87
5
87
35
45

result:

ok 10 numbers

Test #4:

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

input:

4
6
55 15
6 1
39 10
36 10
50 14
85 22
2
87 23
41 12
1
57 16
1
2 1
10
9 34 14 14 69 17 61 81 55 85

output:

36
57
41
41
-1
41
87
-1
87
-1

result:

ok 10 numbers

Test #5:

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

input:

5
1
32 7
5
32 7
37 8
74 17
19 4
94 21
1
75 17
1
61 14
2
90 20
33 7
10
22 48 73 75 53 89 90 19 48 10

output:

37
75
90
90
75
-1
-1
33
75
32

result:

ok 10 numbers

Subtask #2:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #6:

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

input:

1
500
83 82
34 39
18 17
18 20
96 92
62 60
24 26
46 44
52 53
88 83
86 91
64 68
80 78
16 12
76 80
57 54
66 69
29 30
42 44
9 6
72 77
65 62
42 46
32 30
58 53
45 47
21 20
97 99
36 35
79 77
71 72
34 36
42 40
16 21
93 88
71 66
89 91
80 75
97 93
83 82
17 13
65 65
72 70
36 34
70 67
30 26
54 53
40 45
16 12
96...

output:

43
78
29
1
1
85
8
78
92
56

result:

ok 10 numbers

Test #7:

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

input:

2
222
53 30
57 31
97 51
83 47
46 26
55 31
35 20
4 4
1 2
33 19
70 36
33 16
72 40
15 9
96 55
23 12
8 7
94 54
16 11
18 10
29 16
83 44
69 40
91 48
6 2
100 54
90 52
20 9
44 25
33 20
52 31
8 7
54 28
88 46
91 51
42 24
77 40
14 8
10 5
15 10
62 32
11 6
93 50
6 4
64 34
40 21
25 11
45 25
76 43
65 33
6 6
35 22
...

output:

85
3
69
43
77
79
67
86
42
26

result:

ok 10 numbers

Test #8:

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

input:

4
288
48 12
27 6
46 12
42 12
54 14
55 16
73 21
81 21
2 1
73 19
47 12
11 3
91 25
100 26
80 22
89 24
81 22
51 14
19 6
30 7
88 23
53 15
97 27
6 1
35 9
35 9
7 2
16 5
22 6
74 19
77 21
29 8
55 16
37 10
18 6
81 23
57 15
50 14
15 5
18 4
54 14
55 16
17 5
20 5
75 19
74 20
88 24
25 6
93 25
100 26
98 27
87 24
8...

output:

18
35
81
37
71
77
77
58
52
88

result:

ok 10 numbers

Test #9:

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

input:

8
58
22 3
75 10
34 4
98 13
20 3
6 1
49 6
22 3
55 7
76 10
43 6
65 9
23 3
82 11
14 2
24 3
96 13
44 6
25 3
86 11
82 11
58 8
87 11
46 6
28 3
34 4
19 2
29 4
82 11
32 4
64 8
57 8
28 3
37 5
23 3
5 1
49 7
78 10
81 11
15 2
58 7
93 12
40 5
49 7
27 4
10 1
72 10
26 3
4 1
87 11
4 1
71 9
90 12
70 9
58 8
73 10
48 ...

output:

73
66
88
65
19
44
19
21
73
11

result:

ok 10 numbers

Test #10:

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

input:

13
27
68 5
18 1
44 3
31 2
47 3
61 4
29 2
40 3
43 3
54 4
26 2
10 1
82 6
15 1
82 6
86 6
38 3
18 1
56 4
17 1
57 4
11 1
53 4
14 1
83 6
99 7
14 1
15
55 4
82 6
60 4
55 4
61 4
27 2
76 5
25 2
15 1
82 6
89 6
74 5
89 6
13 1
84 6
37
41 3
100 7
15 1
41 3
45 3
61 4
44 3
12 1
73 5
13 1
43 3
96 7
53 4
26 2
33 2
68...

output:

41
38
83
68
38
89
-1
96
-1
96

result:

ok 10 numbers

Test #11:

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

input:

20
61
97 5
62 3
85 4
39 2
45 2
60 3
56 3
76 4
96 5
38 2
80 4
18 1
20 1
76 4
56 3
23 1
61 3
38 2
95 5
20 1
98 5
79 4
78 4
57 3
84 4
40 2
85 4
39 2
36 2
36 2
97 5
63 3
23 1
59 3
42 2
40 2
58 3
39 2
63 3
17 1
44 2
44 2
82 4
83 4
58 3
79 4
82 4
83 4
60 3
65 3
19 1
25 1
79 4
97 5
97 5
38 2
42 2
77 4
19 1...

output:

95
-1
37
95
76
95
100
80
56
35

result:

ok 10 numbers

Test #12:

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

input:

32
33
33 1
96 3
34 1
67 2
100 3
32 1
67 2
33 1
63 2
62 2
35 1
64 2
63 2
70 2
96 3
64 2
36 1
30 1
37 1
100 3
96 3
95 3
38 1
64 2
62 2
66 2
95 3
63 2
71 2
29 1
97 3
37 1
36 1
25
98 3
29 1
66 2
97 3
100 3
70 2
35 1
67 2
33 1
97 3
95 3
69 2
62 2
95 3
68 2
64 2
70 2
34 1
98 3
70 2
70 2
30 1
99 3
36 1
34 ...

output:

62
63
96
37
29
95
62
36
95
99

result:

ok 10 numbers

Test #13:

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

input:

49
5
48 1
55 1
47 1
99 2
54 1
34
48 1
49 1
50 1
45 1
52 1
95 2
51 1
53 1
53 1
54 1
51 1
96 2
48 1
45 1
100 2
96 2
47 1
55 1
54 1
96 2
49 1
46 1
99 2
55 1
46 1
49 1
97 2
52 1
48 1
98 2
50 1
96 2
49 1
55 1
1
99 2
35
55 1
98 2
100 2
45 1
99 2
51 1
54 1
95 2
97 2
49 1
46 1
52 1
46 1
54 1
52 1
45 1
54 1
...

output:

49
49
45
48
95
-1
48
45
98
48

result:

ok 10 numbers

Test #14:

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

input:

74
7
98 1
98 1
97 1
98 1
96 1
96 1
99 1
3
99 1
95 1
96 1
7
96 1
95 1
100 1
100 1
96 1
98 1
98 1
15
98 1
96 1
96 1
99 1
96 1
97 1
96 1
97 1
100 1
99 1
95 1
95 1
100 1
100 1
96 1
3
99 1
100 1
97 1
5
99 1
96 1
99 1
97 1
98 1
3
100 1
96 1
99 1
1
97 1
9
97 1
95 1
99 1
100 1
97 1
98 1
98 1
97 1
99 1
2
97 ...

output:

-1
-1
97
95
95
97
-1
97
-1
-1

result:

ok 10 numbers

Test #15:

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

input:

100
9
96 1
98 1
99 1
98 1
95 1
96 1
100 1
96 1
99 1
16
97 1
99 1
98 1
98 1
95 1
97 1
99 1
97 1
99 1
96 1
100 1
97 1
98 1
97 1
99 1
96 1
2
98 1
99 1
1
100 1
11
98 1
97 1
98 1
100 1
97 1
99 1
95 1
95 1
97 1
97 1
96 1
4
95 1
98 1
98 1
98 1
14
95 1
95 1
96 1
95 1
96 1
100 1
100 1
100 1
95 1
97 1
99 1
10...

output:

99
98
95
97
95
95
97
95
95
97

result:

ok 10 numbers

Subtask #3:

score: 21
Accepted

Dependency #2:

100%
Accepted

Test #16:

score: 21
Accepted
time: 98ms
memory: 11024kb

input:

1
500000
837488501 793450356
432515987 427740030
829198011 783549440
357638403 365042756
690030466 722111395
713559740 712753462
363864217 358896868
535456250 502101132
603331944 636377356
109446769 67852211
637486505 630586198
176815852 220723395
470609072 467286117
342649322 297943736
604660694 60...

output:

11978
296159873
256677859
219987462
893534631
402235234
424676596
265951507
487978923
3661637

result:

ok 10 numbers

Test #17:

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

input:

2
58232
319152075 182923967
875625572 468312895
129051854 72185097
342174425 215671676
188484173 88371267
113457218 35963127
785826448 406101530
508919036 276156767
521848888 309156489
192375636 125395658
54575386 13998766
953722538 512694892
300606541 153033336
434391829 216658986
770123597 4348641...

output:

809986332
496522435
444652780
6752
129838474
369771283
305497451
99601612
135681
152350343

result:

ok 10 numbers

Test #18:

score: 0
Accepted
time: 92ms
memory: 7904kb

input:

4
195169
495520437 136764159
526697360 141420048
68884443 22657492
953260348 257193654
642779688 186669173
367700258 105212078
675981789 172697823
455723436 123270139
679903652 187892548
832280326 219564081
29821526 19648930
826095278 213716154
574425991 169485539
613932608 161178362
681052272 19958...

output:

376240453
184735802
192280213
717466437
59316727
8326075
651538940
828765082
847254450
4576228

result:

ok 10 numbers

Test #19:

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

input:

8
95486
577116989 76401759
169081937 19602700
991644182 136475427
161886789 23654038
379827856 45662929
768894258 107719317
633920243 93276521
355650441 52107054
395384156 53079666
478292906 66186975
676710944 87785135
541453663 69121063
662086090 92001823
482175789 61246685
306066335 39652422
24723...

output:

550553916
296553803
609020390
75186889
366089307
716085517
723205388
185802983
283727005
475125738

result:

ok 10 numbers

Test #20:

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

input:

13
67744
951533738 80936934
767846782 66490111
480897842 44899962
730795327 61682147
199317789 15916347
216664228 19865917
145383308 9233207
906768015 73361437
294982015 24233181
861279051 69662245
362137496 28583826
859837935 76772543
527445488 44728896
543120625 49877584
386583476 31960734
4823889...

output:

350413492
520228634
429453597
273668082
353188286
509368463
860074525
803286952
483114292
397240120

result:

ok 10 numbers

Test #21:

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

input:

20
7321
679237898 38231136
117581179 3748783
429733998 26059474
953264010 53681571
528227995 30885188
911397984 49014521
731537321 41298127
641897904 37809850
335125103 17775286
870221218 48750466
272324813 15203455
344094390 18903839
726020848 39321405
703885111 36982925
134250474 8801744
512055547...

output:

314052174
732236619
503604367
293418118
603750854
220620265
575865349
9509508
356828870
493563667

result:

ok 10 numbers

Test #22:

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

input:

32
19308
37273277 1427115
451544876 15027137
788898236 26734301
36328360 2821285
482973011 17931452
983771940 34238592
840136721 27190320
293442095 9424475
235281782 7422846
48978753 1982989
863733888 31036466
635924784 20409562
447669456 16468949
888734721 29605054
437054282 13689588
806848123 2919...

output:

387109546
236562684
598148334
180685386
755953971
594643843
524538131
130130310
304641634
664883018

result:

ok 10 numbers

Test #23:

score: 0
Accepted
time: 84ms
memory: 4368kb

input:

49
16604
230177892 5217102
195689226 3410643
345928868 7565810
303629473 6380813
207855235 4324550
519250555 12275637
738831185 17683912
971980391 22383253
893981582 20815156
735150752 16061923
459264160 10461232
308267647 7486921
672691782 15995591
505085583 10907216
338299688 8570862
645553595 138...

output:

253342389
513957717
168735630
533731818
682719261
292553264
657684969
813537517
12028
116168552

result:

ok 10 numbers

Test #24:

score: 0
Accepted
time: 85ms
memory: 4724kb

input:

74
4920
36876406 380678
637374899 8865353
376354166 6089633
695449620 10576561
625138371 9746133
88601799 1842887
127922498 1443458
735784285 11403001
433898405 6513177
852539813 13340059
506058016 7170341
243394983 3003358
138464723 2703787
605503425 8336053
174917209 2540897
965402154 14838962
299...

output:

534949570
256802293
1398016
253917540
233851811
753420770
631695005
108769961
273384689
321531082

result:

ok 10 numbers

Test #25:

score: 0
Accepted
time: 82ms
memory: 4924kb

input:

113
2599
279430501 2282111
30415278 543749
896085195 8813010
584946096 5639118
607371333 6197869
518245069 4600617
575535139 5543967
590102956 5468484
149626482 1064516
388997393 3467599
428607387 4051727
173139844 1879280
941257611 8850481
211613313 2373658
674523733 6528371
517824749 5000803
45257...

output:

273948746
310358363
368068446
367215861
425017480
354913105
395861
641997691
24200063
427461165

result:

ok 10 numbers

Test #26:

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

input:

170
2304
552717378 3868550
874141768 5493307
333437397 1975683
243296718 1407735
181209239 974196
684917565 4661426
982666408 6334293
810579507 5068902
709887642 4438499
946434063 6049199
690107731 4433484
81625491 753161
410859199 2925014
138946800 1135959
700854327 4273018
369154644 2304827
141172...

output:

627937763
713125652
610008
147527698
364319182
606108593
501002909
40774842
495920260
504082001

result:

ok 10 numbers

Test #27:

score: 0
Accepted
time: 78ms
memory: 5200kb

input:

257
2313
654801840 2834451
638293561 2854304
382398357 1471325
941161926 4061305
170724164 781891
276417530 1368373
167660782 859448
648204633 2686292
273316418 1231866
388541206 1798239
584579265 2414899
271058681 970069
932575303 4054768
358700363 1660977
459854033 1781690
436903365 1858922
942690...

output:

94712599
184583480
294803002
172049578
69783585
327509414
109066108
4821752
550373539
49281213

result:

ok 10 numbers

Test #28:

score: 0
Accepted
time: 79ms
memory: 5528kb

input:

387
1037
80193093 301007
540103390 1557478
46142887 173893
555062685 1504850
269986526 737131
955561619 2691571
814131117 2255080
88773348 149611
769609137 2200666
549104084 1516196
895430885 2483657
993178290 2728654
908150779 2526223
935687724 2640800
936310838 2637264
119828505 353518
539382275 1...

output:

830499857
290395353
462670594
558473550
156567264
799218018
739267594
332214811
374007131
316498969

result:

ok 10 numbers

Test #29:

score: 0
Accepted
time: 82ms
memory: 5756kb

input:

581
692
490899569 959102
130917805 271588
416956328 767919
730666329 1373569
32852384 126484
117190766 305792
591323194 1149230
924342900 1805064
514129914 992494
834074107 1549991
579152724 1030775
969881115 1879062
978851436 1779544
451806305 878698
205742086 339136
778951654 1481498
416473645 710...

output:

163697485
66768441
845921645
665858717
399341325
671572636
714310604
771809974
918548
186403274

result:

ok 10 numbers

Test #30:

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

input:

873
355
654385230 847432
353301167 401326
93074728 60243
592579062 720887
590095719 750502
530599425 703913
578444472 694385
286365125 343307
536984075 667132
304379793 366209
768555765 954877
439931313 539866
120789561 214474
552628365 658640
128996407 190446
622353335 757872
823182434 1053503
7455...

output:

670718260
572869102
859963416
604256668
266613342
7474822
870812650
173703225
171840605
337428040

result:

ok 10 numbers

Test #31:

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

input:

1311
74
51946252 55435
252892923 230352
365558544 324944
712785088 559441
747269527 609718
876927773 712592
576900176 507106
11788482 35612
500269306 415393
946167808 771892
338936193 274465
867132602 716619
503340045 435060
849448910 753354
819307525 662463
324049263 284412
587964049 527580
6468280...

output:

318076935
488765615
697431824
447972096
490439374
712325154
234349413
28850335
658685698
455684202

result:

ok 10 numbers

Test #32:

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

input:

1968
22
532875127 315296
218201572 95927
578309712 318990
611334188 319499
588390504 302866
53206579 29457
508605907 282521
985623263 553098
904203142 493377
58218572 51151
344076764 164784
295509134 186188
135830733 61280
274861415 131187
761184317 441078
14629394 32880
966733796 530558
346463991 2...

output:

387560132
655612664
199304410
838581092
478591310
662549040
228064192
488143059
254830143
174967799

result:

ok 10 numbers

Test #33:

score: 0
Accepted
time: 79ms
memory: 11180kb

input:

2953
196
587057883 221526
348357382 135596
324956813 116835
917012234 324287
753611036 280933
969165054 350506
784898923 297012
612018610 214820
255941896 99853
940216821 352388
699011023 262700
262857366 90062
426798001 142486
467387004 167405
67777049 32830
71269926 14848
877342573 319490
62988189...

output:

575992065
361753830
170616232
594209267
522064536
522295632
661485683
46054181
108673464
189682165

result:

ok 10 numbers

Test #34:

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

input:

4431
92
44953179 4370
531779320 121455
842599545 215209
916888048 233879
14603105 15823
840913102 205568
745774090 175257
717994891 176845
259736422 73904
742208455 184527
516171001 128324
652161179 168821
166574367 41812
969369906 243920
929905236 220651
40122299 1152
179124338 46893
356295330 8939...

output:

173822716
318199213
609234571
901218686
108608084
32097809
321771970
575242358
7426758
85134460

result:

ok 10 numbers

Test #35:

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

input:

6648
9
198853997 34131
12909943 5420
484660491 80695
386858529 66939
657725322 116115
512359820 77251
310865827 47027
572170132 93585
991976049 156024
146
781039854 132512
375817190 57951
251284695 43665
822829199 129877
692456668 118346
463910253 77809
630452105 107680
711644354 121295
480112415 80...

output:

487525370
193344104
922271534
96450124
668829841
444926387
9008262
239334996
409707101
893681613

result:

ok 10 numbers

Test #36:

score: 0
Accepted
time: 85ms
memory: 13660kb

input:

9973
119
942446873 104716
841708850 90200
670052803 76342
629675059 72291
321198110 37176
60768399 11043
79813883 10869
890996286 98883
747577231 86930
281249689 26334
221249064 26613
161363816 20758
638903539 67102
757531025 80719
720251197 74391
527384293 56109
522520909 56869
764682348 83452
4104...

output:

35019446
510912956
932748620
906140163
416262398
107404127
102492962
874993261
650135647
886189502

result:

ok 10 numbers

Test #37:

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

input:

14961
104
294732789 23259
483134842 33227
230477214 14584
341569950 27944
836742935 65014
818602886 62282
435618667 30242
367550322 30666
445233067 29085
722454504 50604
791801437 59100
147726152 9428
896922498 66063
929255235 69893
643015102 44159
237491121 16167
448823175 32444
717337664 55453
659...

output:

516248342
814534490
210621530
203228867
590262016
500520911
579974487
878928125
326446750
519071551

result:

ok 10 numbers

Test #38:

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

input:

22443
12
465009620 22295
23473079 3357
125286422 7475
140165753 7465
504234948 25233
257681751 11443
681894295 32868
682291101 34810
528032697 25024
851018521 41550
856517144 43443
489203539 25962
24
402076612 20533
700340280 34454
804435473 38597
221423478 11998
475014229 25594
811389451 39803
7922...

output:

813750809
841537037
58103827
-1
640681931
833613739
582399613
585656905
696971780
554065043

result:

ok 10 numbers

Test #39:

score: 0
Accepted
time: 103ms
memory: 21472kb

input:

33666
14
919025455 31573
966338061 30141
811725034 24970
800659088 27689
813054947 28073
885640808 28293
136157419 5299
828067166 27184
254699573 7735
396430023 13731
751255758 23265
779972238 26305
916356531 30365
639627025 21230
1
349903574 10563
22
233561524 8456
682826436 22679
368696353 10724
6...

output:

653983366
589317354
319570956
369745541
246013913
916878795
31348110
973769287
405964137
992060493

result:

ok 10 numbers

Test #40:

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

input:

50500
65
717183281 16337
84292647 2921
332486220 6304
152565881 3143
199988023 4855
937545249 19986
456632483 9316
374346172 7228
653871327 13469
199224121 5384
132358437 2755
78832087 2619
810015437 17487
86786181 2283
865431787 17858
440386820 9422
7336441 1108
277757028 6481
64032930 2349
7796865...

output:

595077509
960166478
913235428
943337186
497724994
738595488
49684457
648769704
633582046
-1

result:

ok 10 numbers

Test #41:

score: 0
Accepted
time: 109ms
memory: 26432kb

input:

75751
5
380337135 5889
494756117 6506
346888536 4597
689887889 9797
804168315 12191
5
563745364 8537
544777012 7654
33792898 57
531329416 7140
609772529 8428
2
832057864 11998
938547291 13711
12
923301234 13327
479423135 6927
311246937 3861
302545713 3740
496499866 7788
480301973 7358
445451409 5841...

output:

-1
516074775
812300071
942668930
426316760
969642870
217385993
874583529
320657757
916651669

result:

ok 10 numbers

Test #42:

score: 0
Accepted
time: 111ms
memory: 28364kb

input:

100000
1
537269681 5697
4
558280899 5670
483760001 5554
276157060 3199
407121749 3956
9
695996695 7121
844984501 9021
654570709 7264
542713157 5451
159619352 1676
705534204 8171
928714978 10108
329506676 3246
673021643 7307
6
552233358 6162
48768052 586
392132005 3990
161612414 1308
610888960 6603
3...

output:

-1
790853930
690623183
381969175
719111665
520542211
540267367
-1
-1
355657866

result:

ok 10 numbers

Subtask #4:

score: 24
Accepted

Dependency #2:

100%
Accepted

Test #43:

score: 24
Accepted
time: 162ms
memory: 12144kb

input:

1
500000
85 886111738
17 185528094
8 105744315
90 850594507
83 867742209
6 108513622
15 104580842
71 741724752
39 344003639
74 697974174
40 390653002
85 851917558
63 590023407
11 107153878
96 988975237
44 485050350
95 911044898
44 393638915
61 641210466
18 212101442
65 659607140
67 687219131
75 7472...

output:

45
36
7
13
72
88
38
47
95
12
69
60
53
16
92
1
32
23
34
69
55
47
1
27
72
39
17
16
52
6
13
71
65
22
49
46
23
21
88
76
81
44
29
27
43
70
90
66
81
52
29
31
74
2
59
78
85
95
1
42
26
37
1
62
51
33
77
92
66
29
72
11
85
58
13
65
27
55
45
32
55
85
57
29
26
2
89
52
19
58
85
67
89
16
41
1
11
26
73
2
55
40
40
3...

result:

ok 100000 numbers

Test #44:

score: 0
Accepted
time: 157ms
memory: 9228kb

input:

3
324649
34 115055387
40 139440152
22 75024229
47 172387861
14 36988145
42 160065501
46 183585622
12 60916532
61 224374422
86 300963972
95 359428850
4 13866907
20 78176875
24 75974216
8 13052601
64 216802707
8 38924075
82 316880532
33 114394798
39 148997908
66 235989069
21 60132778
30 114481669
6 15...

output:

18
72
48
1
85
77
42
42
86
76
33
1
81
65
13
1
1
28
68
1
59
86
42
36
4
72
74
9
39
33
16
18
23
71
75
61
12
86
13
74
31
1
68
36
44
54
17
40
18
16
16
1
53
35
7
74
54
55
49
73
72
8
12
54
31
37
31
21
41
10
19
25
1
21
39
1
80
35
19
3
57
67
50
47
37
72
45
30
3
10
36
43
9
35
49
48
50
82
13
1
31
76
21
64
76
71...

result:

ok 100000 numbers

Test #45:

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

input:

8
70704
92 122671059
55 76326156
87 123631634
30 35786649
92 128667385
93 134643279
4 12013680
19 23412660
93 134436616
54 80734259
42 53762381
69 91223835
68 98220402
35 53411767
59 86247133
10 19643295
58 73266035
4 5515233
11 12082148
73 94573051
12 21145334
65 83486137
45 62628087
14 12578120
47...

output:

14
8
36
49
24
53
6
84
4
71
50
23
67
44
67
1
53
43
57
20
58
84
77
43
78
59
16
1
7
34
44
24
85
61
40
74
44
67
59
68
70
15
14
78
85
74
62
15
86
81
64
43
81
61
54
38
13
4
6
83
25
30
51
48
4
5
1
1
1
15
12
82
44
43
1
32
66
59
81
57
75
42
44
81
51
44
27
78
7
56
29
46
73
1
31
82
37
76
61
73
49
39
6
64
13
17...

result:

ok 100000 numbers

Test #46:

score: 0
Accepted
time: 152ms
memory: 6332kb

input:

21
19651
42 19954691
38 21068097
47 26335302
7 5223801
75 41808056
96 48062793
98 50393643
18 10064898
54 25900757
88 48301456
47 26292146
81 41416345
78 39381028
2 2213747
31 17038561
52 29363673
20 8815739
50 26091723
47 23925394
78 41139945
81 41695450
40 20142766
89 48808225
11 3895584
76 400015...

output:

1
22
70
84
78
81
11
51
71
37
38
29
28
19
71
22
24
22
42
85
1
46
9
13
1
68
84
51
30
1
41
40
32
20
24
23
13
34
25
40
68
31
15
62
57
83
56
24
48
42
6
59
80
4
66
72
35
60
19
32
13
63
4
84
59
16
21
56
66
9
59
1
38
33
3
40
70
77
17
31
78
8
51
43
8
59
61
13
53
24
36
1
23
45
56
1
85
32
12
77
25
10
38
11
38
...

result:

ok 100000 numbers

Test #47:

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

input:

51
1840
31 6307146
42 9514792
65 14251980
94 20646971
34 7456515
10 3171548
28 5143817
56 11131287
44 10401226
24 6026171
54 11068777
21 3904997
29 5515670
70 14533749
18 4639241
47 10229241
63 14065310
78 17743475
70 16043605
92 20478931
46 10833073
41 9654470
51 11816209
73 15779479
18 4672401
8 2...

output:

31
13
73
41
38
69
49
47
52
29
3
85
6
64
52
55
58
78
16
51
50
2
1
65
14
65
32
44
17
86
25
1
1
55
25
56
75
23
13
58
56
73
20
16
1
68
53
17
57
36
4
17
79
49
83
1
14
20
72
59
24
14
32
62
4
11
60
25
73
45
79
9
27
26
21
3
47
58
34
66
53
32
39
65
7
22
39
16
38
76
82
62
49
34
47
26
20
70
53
6
1
22
38
75
2
1...

result:

ok 100000 numbers

Test #48:

score: 0
Accepted
time: 142ms
memory: 6104kb

input:

120
7551
41 3976938
1 71567
28 2450699
72 6347027
12 1080302
31 3079348
17 1973034
12 1109241
65 5915806
38 3558917
82 7086565
57 5223675
91 8527887
12 1505329
88 8184864
89 7760390
73 6959989
64 5450952
50 4597639
30 2412601
60 5099438
18 1357948
77 7339672
22 1702828
58 5221905
59 5303649
76 65351...

output:

1
6
12
20
50
68
23
30
35
7
82
54
30
35
63
41
46
66
84
87
86
44
54
64
68
6
80
66
22
6
82
1
11
37
8
20
56
42
32
76
59
66
1
1
51
59
63
25
3
40
60
5
7
67
76
10
1
58
15
33
26
29
33
51
35
38
22
40
57
4
79
37
61
21
22
35
70
20
73
35
73
54
12
55
69
84
56
64
17
42
87
12
47
31
50
54
4
11
55
41
12
28
23
41
73
...

result:

ok 100000 numbers

Test #49:

score: 0
Accepted
time: 145ms
memory: 7064kb

input:

281
1720
9 225722
62 2592302
75 3079717
97 3676060
74 2703816
92 3755214
76 3003370
43 1529659
8 232914
14 740740
15 524400
53 1926615
13 487478
47 1667989
74 2732562
52 2061450
34 1154213
60 2189816
11 465315
37 1577694
32 1089911
3 178248
3 28775
15 778016
83 3409074
10 582688
66 2479388
6 118581
...

output:

82
3
54
52
56
31
7
20
73
27
60
69
44
12
73
61
22
1
41
6
68
39
63
44
36
6
12
1
70
19
59
5
60
56
2
75
7
59
42
33
48
81
76
35
79
43
18
32
82
3
4
3
3
56
42
57
12
36
62
46
9
44
42
9
50
11
87
34
70
30
77
67
40
29
61
35
53
4
15
73
85
52
51
25
30
65
48
68
9
88
43
1
26
81
34
65
38
36
1
59
23
30
61
52
52
82
2...

result:

ok 100000 numbers

Test #50:

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

input:

658
710
79 1362388
53 944087
28 546755
10 235641
8 96791
64 1012999
39 685148
69 1223616
57 893731
57 925545
73 1232226
11 175417
10 92156
21 280459
9 76216
21 301269
71 1231148
19 398299
94 1526883
55 941750
37 636380
48 719243
94 1642010
72 1202940
72 1126995
39 631679
35 546592
54 895133
80 12622...

output:

85
47
1
31
27
75
66
34
37
2
8
69
82
1
34
88
29
75
60
14
43
66
33
76
49
5
39
51
42
88
73
77
14
4
75
62
4
84
27
33
1
65
39
42
16
14
23
1
21
45
39
70
15
39
73
60
33
9
18
26
79
23
70
31
29
76
83
23
43
13
35
3
58
43
20
24
83
76
68
26
49
72
30
80
1
13
1
42
13
13
22
65
14
84
15
28
52
22
52
88
42
5
44
46
38...

result:

ok 100000 numbers

Test #51:

score: 0
Accepted
time: 138ms
memory: 8216kb

input:

1536
693
13 95400
5 50054
60 419461
17 119085
71 505344
81 612249
57 416439
86 642305
19 121361
63 461964
5 6523
49 325140
27 226446
62 479260
43 278435
41 272750
87 620276
30 192614
93 682861
40 282258
3 48788
89 658837
48 357936
4 30885
66 483767
42 319326
65 449147
94 639454
76 565683
17 156021
8...

output:

88
20
17
75
84
62
74
83
19
46
5
59
18
48
61
61
78
70
71
70
15
49
54
1
9
39
34
12
69
42
58
59
4
77
37
44
54
62
39
26
49
68
86
39
69
9
60
75
65
42
26
15
67
67
22
52
41
10
1
52
44
33
4
67
19
29
54
31
49
73
10
49
41
40
39
43
4
10
75
53
1
65
23
34
10
52
77
15
9
83
64
72
30
8
54
86
18
62
12
68
49
66
71
32...

result:

ok 100000 numbers

Test #52:

score: 0
Accepted
time: 151ms
memory: 12936kb

input:

3587
236
60 177406
94 274413
22 75546
47 129751
17 64563
46 136380
37 120066
15 39964
51 156649
63 180803
59 174986
11 23626
100 291920
68 216562
21 70436
57 165289
42 141812
85 250082
88 263162
17 52181
45 147759
71 227762
14 56833
35 107976
39 130964
97 282629
93 277268
47 131898
31 86460
72 23356...

output:

53
73
40
53
67
60
64
10
36
5
42
65
22
61
38
35
9
2
37
71
32
49
19
43
87
4
52
73
31
77
54
4
67
63
48
28
62
86
47
32
37
90
49
26
18
70
58
14
17
20
72
43
90
78
36
45
65
80
86
2
6
87
65
68
27
38
39
22
43
38
55
51
47
85
61
26
70
89
18
69
51
22
41
18
44
75
78
36
6
68
79
68
54
65
58
43
48
15
2
70
68
66
1
2...

result:

ok 100000 numbers

Test #53:

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

input:

8370
72
70 90715
27 37388
8 15184
57 76665
75 98671
15 13987
60 83648
58 76318
81 103591
35 48284
43 58699
89 111670
68 93769
19 20713
66 84168
70 92273
71 91575
92 123328
5 366
79 100543
36 41727
69 92506
13 20079
1 4938
7 14142
34 47308
96 122623
7 10502
29 34758
31 38179
56 75231
6 8048
94 127734...

output:

41
81
19
71
52
54
19
82
73
23
75
30
13
68
61
71
23
43
72
30
30
63
85
54
46
91
23
79
18
19
47
67
53
20
20
55
11
29
94
32
92
15
9
88
77
74
29
41
41
35
81
71
35
29
24
24
43
32
2
53
34
30
25
46
33
8
76
92
51
42
16
52
34
2
72
41
30
84
55
21
74
35
62
32
51
81
73
8
71
16
10
94
57
39
86
93
58
84
33
38
27
56...

result:

ok 100000 numbers

Test #54:

score: 0
Accepted
time: 164ms
memory: 20868kb

input:

19532
38
2 1917
22 11256
27 17543
2 3169
49 26678
85 45222
94 52969
58 30809
20 8966
6 1257
18 11540
43 22655
17 11037
58 33961
53 31570
92 50847
99 55815
85 49961
69 39139
5 2605
73 41750
45 24625
94 53530
87 50517
93 51225
100 54544
63 33848
45 25695
53 32102
20 9716
3 2969
42 24110
24 13230
100 5...

output:

63
70
11
45
15
58
71
72
42
9
98
28
47
58
21
23
49
69
74
17
66
32
33
26
92
96
5
75
76
64
32
88
-1
-1
76
64
51
51
45
59
15
8
74
18
31
74
41
45
65
7
38
13
90
9
48
59
71
46
94
-1
80
77
86
79
22
94
75
46
96
54
53
2
15
80
36
12
56
31
48
11
86
37
73
91
26
8
39
38
74
36
37
67
65
81
51
57
91
76
86
38
92
74
6...

result:

ok 100000 numbers

Test #55:

score: 0
Accepted
time: 174ms
memory: 23764kb

input:

45577
20
33 6758
95 22073
97 23015
24 6726
20 3753
98 23832
65 15857
74 17768
91 22530
36 7626
66 16877
50 11054
42 10007
96 23168
19 4865
2 1550
51 12497
84 20247
11 1451
62 15525
1
50 11940
1
53 12021
24
96 22334
54 13102
9 1503
5 1236
5 1048
86 19699
22 4341
20 4029
85 19616
23 6643
75 19111
96 2...

output:

48
63
28
11
89
40
95
100
13
97
15
23
93
49
45
11
14
86
64
44
65
82
98
9
59
49
46
76
28
-1
23
78
96
68
30
78
65
70
30
68
20
-1
36
63
68
44
86
-1
82
99
76
93
86
93
-1
52
77
8
47
89
62
94
92
48
98
64
30
44
71
63
-1
73
47
16
79
75
28
40
32
43
57
-1
77
99
74
11
37
55
64
50
64
-1
38
-1
7
88
91
34
31
19
55...

result:

ok 100000 numbers

Test #56:

score: 0
Accepted
time: 177ms
memory: 27332kb

input:

100000
5
84 9248
37 4612
63 6600
94 10094
77 8279
2
78 8311
72 7399
11
72 7437
10 1305
90 9874
43 4483
9 792
45 4731
24 2183
66 7701
45 4864
94 10826
30 3311
2
93 9883
73 8181
5
84 9204
68 7546
29 2914
52 6015
25 2599
2
43 5120
67 7187
3
44 5135
93 9831
71 7424
8
31 3430
75 8469
79 9175
71 7562
100 ...

output:

68
92
-1
19
38
55
88
-1
97
70
89
-1
38
77
77
81
9
81
70
65
28
8
78
66
-1
-1
70
48
35
85
91
-1
38
-1
17
98
67
61
77
98
53
30
81
52
6
15
75
85
97
36
27
38
98
50
99
53
90
22
9
63
17
69
-1
18
-1
51
-1
51
78
-1
91
-1
18
31
63
64
34
-1
55
60
89
54
94
95
33
40
11
85
79
73
78
24
38
32
-1
80
90
-1
46
84
35
7...

result:

ok 100000 numbers

Subtask #5:

score: 33
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #57:

score: 33
Accepted
time: 193ms
memory: 11136kb

input:

1
500000
478659601 431235889
465424021 513351063
851138427 861333448
751179353 789851083
31058854 2269053
765155924 758303232
325779189 361244928
198113253 199629543
419961168 379455699
310284490 352867020
687955 47612001
426872094 424888447
936018944 960838654
189474050 222518799
436076013 47061877...

output:

795984126
413430024
797614162
466763861
765677858
202708994
887191393
332942370
242593395
7208
7208
410483343
117247887
62548139
71506277
407648346
889361792
86888789
371794052
202516733
477819364
7277727
145385048
635211773
714679823
913336963
505355179
948647623
130918170
518705031
640238621
72956...

result:

ok 100000 numbers

Test #58:

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

input:

3
86767
626229669 241109672
157570187 58006526
116812178 54211230
479287380 187699389
790821889 300412833
401954404 144055904
719691543 261427091
902277933 346627852
566838461 217796419
427148147 151893758
745320260 281694203
558596696 208209132
23597833 20085289
891402741 327900070
733018932 271628...

output:

440052776
809732549
568859323
82340213
15691243
175157516
635626878
42303145
305104639
782003108
160199498
358091781
80518234
523184747
435352659
168868621
605154540
629249552
10834
432489663
203712696
627178190
326961831
10834
579096796
407618439
461299459
366776310
444292964
89542635
318840753
262...

result:

ok 100000 numbers

Test #59:

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

input:

8
29058
225950339 35339945
552705167 73756775
324166526 45258129
400090269 51042896
768070074 111003019
659361782 85523861
850744506 115776029
702293050 101956793
159925779 18917424
842857375 116029552
462824649 58509139
512588365 74725195
954083709 133501251
593216875 83039384
144605325 20930211
13...

output:

676015216
491891178
238963726
361636609
588126264
126431792
514802076
526604950
185636566
126737976
131245701
682986057
228094123
383190804
268150109
598956838
591616904
319094614
835022356
59424224
584524410
196321464
766881315
505734792
708526288
605019980
34299215
100597467
609706000
327876874
30...

result:

ok 100000 numbers

Test #60:

score: 0
Accepted
time: 205ms
memory: 4980kb

input:

21
31789
858355980 44811647
782915785 43383166
645725798 33057758
989126983 50161660
456474931 24533881
879312890 45722889
994950306 50262565
985620153 51358210
578497556 31613422
632697376 31642578
33311813 737585
239580902 10234627
387541900 18597881
465305002 25881167
854428716 42687042
343246821...

output:

666586817
615904008
52581
639500321
462025253
313998758
775211111
52612734
152010638
433177482
261211801
242732252
485896986
672927200
353451283
662877883
245682992
116646197
852593586
628793201
730633685
515044861
847733817
593415715
34098411
829475352
716623679
568027508
270893158
459927361
227038...

result:

ok 100000 numbers

Test #61:

score: 0
Accepted
time: 211ms
memory: 4456kb

input:

51
7057
436921219 9438344
509053955 9976087
310558035 5898967
784973044 17468940
316646672 6164214
735691563 15011938
625311530 13979597
916746466 19354107
968928621 20742349
314102182 7533324
335150644 8062764
63149764 400161
956743557 21425120
917594480 20374505
537350491 11699365
741034312 156867...

output:

275674933
244404946
171401546
99051177
712817947
15395572
737586271
86959497
799710186
310984150
25454773
183955888
716317782
733572325
641241299
207524600
682980340
271941943
97605958
599906898
25247246
810640461
77238094
622100817
136434697
823837213
545001388
84238
203432308
523028916
205189380
2...

result:

ok 100000 numbers

Test #62:

score: 0
Accepted
time: 209ms
memory: 5076kb

input:

120
883
574073187 5261270
171351432 1199946
270205698 2671274
969994513 8948863
42051752 824712
625801805 5984217
100608963 1049356
317427386 3293907
427849498 4089309
241844881 1890219
198122168 1680807
850970138 7658650
927128879 8115382
49757143 490846
41545483 644787
873745031 8200152
695357598 ...

output:

112007230
367266727
277693760
95394819
859574785
536550505
459740669
339535770
645833680
5952121
534472181
551156976
717977615
549509308
537539921
654022456
358638130
76870972
539591545
103384675
846834721
89209632
29483932
169994575
365620226
592376558
860228195
469872946
605078926
450259587
406010...

result:

ok 100000 numbers

Test #63:

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

input:

281
295
979271928 3870674
176627972 539932
501713203 1940762
309677138 1201961
861297218 3400318
696607398 2656369
20564991 220213
53959248 374752
17723196 33893
313891298 1313340
976762369 3636922
128781999 336980
599427466 2440695
643687627 2653659
196837436 845180
416258016 1521535
77703503 44446...

output:

82295990
678123045
848384990
527044925
468311842
7738194
685785554
146173670
444090182
523036132
156919476
479579668
601377876
750854409
3904262
431384561
621504597
759592196
21572572
301246263
422086606
1766848
488933566
61054387
28018034
110347817
227800257
544655243
265483402
428972398
564515234
...

result:

ok 100000 numbers

Test #64:

score: 0
Accepted
time: 226ms
memory: 5892kb

input:

658
2179
39290160 41344
194866548 401076
850063998 1371582
990409522 1653367
528488923 883321
461482998 826992
915323229 1465879
965817557 1548005
947254962 1547861
987334134 1596179
44373537 28710
488764026 789464
727410698 1276454
379353373 657495
910507892 1439728
234746066 325898
189837984 25970...

output:

458603508
372888097
17703015
263985487
124542120
290249396
644952696
285074695
444904132
611183813
837724725
798113424
523339313
409775073
398706227
593758102
528809584
361418168
76332943
89211647
76379629
241239370
371578176
781534687
629729558
452929269
654076776
148824490
492839626
573397852
2475...

result:

ok 100000 numbers

Test #65:

score: 0
Accepted
time: 227ms
memory: 7840kb

input:

1536
27
117973036 61445
814322908 562574
27560834 40180
893588635 612273
841281084 613110
636154635 434763
521858522 362680
158275999 78174
432212176 282922
885541375 609307
763826628 515133
275880589 201056
657243459 443601
783065435 563004
971677477 698757
917295813 671048
500540117 349204
8518607...

output:

746296828
726004293
290498587
144950885
389849591
317000658
430908566
718685368
80920954
796228609
365063700
594102637
505960542
621034001
881505173
715408232
346439220
560882357
259329387
866466379
808303558
360715957
677480707
833349703
604659294
72899817
728403537
559102736
728533993
613461795
84...

result:

ok 100000 numbers

Test #66:

score: 0
Accepted
time: 245ms
memory: 13060kb

input:

3587
48
206833966 63880
767687051 228072
452914961 129055
414540338 127258
830991382 252256
550222074 160014
92334236 19094
146002744 43209
178384858 40779
250226641 68055
118173191 46728
158272263 40811
949041038 279605
280996327 101137
887841284 272352
484708786 157370
436446139 138921
656880968 2...

output:

225220947
888563550
230062556
330035891
673431694
375010051
201789847
406823992
863192232
96678478
4527917
831152611
279221379
445201979
745345267
260694598
871345490
540783116
724349064
716347592
117940094
598625365
608738132
264936422
202153082
304546711
279477695
890729097
373907786
769614805
255...

result:

ok 100000 numbers

Test #67:

score: 0
Accepted
time: 250ms
memory: 12908kb

input:

8370
29
122413099 19010
404823951 55998
551608032 73136
818260794 107497
317191246 35313
119662050 10198
162523113 20439
673181106 93942
941632734 127893
463829197 58212
122105282 20275
517274046 72758
420015857 57856
73775963 3162
969671531 130813
680861518 85186
797072736 106637
703930898 95795
26...

output:

770408305
931934154
561616623
790108671
784532798
784352831
639428753
280059855
800563471
107195416
618655835
623818513
689403592
822570032
885581818
382190130
627421706
558764245
530259074
680860021
418915445
164369790
762602032
568871318
317509332
13445617
42203553
358296055
367158513
677636022
52...

result:

ok 100000 numbers

Test #68:

score: 0
Accepted
time: 275ms
memory: 19488kb

input:

19532
33
77222314 2823
285400244 15034
132525183 8663
998890506 53480
859105740 45591
582271574 35308
868656846 48502
829208225 46954
800649442 46945
877441263 49341
409251346 24052
45824699 5232
274573797 17117
303046640 14522
553671975 33937
120404853 7499
924246377 54404
338933211 20432
175512358...

output:

319288647
166915173
524048813
460424477
185013809
364580201
925191946
296773957
425882976
467470167
204120522
573860201
410827613
398838392
651056814
603223007
366145166
802090327
642043235
985274630
800757585
12717637
899432850
783928629
255076851
921640095
306032011
506214165
688566961
-1
42678250...

result:

ok 100000 numbers

Test #69:

score: 0
Accepted
time: 283ms
memory: 22844kb

input:

45577
27
229692222 6740
372960212 9079
228158340 6330
125126026 2495
902334464 22670
420444222 10298
560637991 14477
346118816 9321
951909100 22469
337891611 8388
157014350 4337
299085353 8150
558399601 12758
855948878 21427
84848754 1345
762768800 19357
83378000 1648
121190856 1948
673600408 15207
...

output:

731808030
833160774
-1
-1
210281604
826676384
-1
810806998
474762674
459628774
792087718
-1
802251564
268549108
891716541
91787427
238131314
627351495
648065179
418176707
935222917
448206928
634715080
171091708
323860563
71103461
580855408
667137784
118604206
630927245
862158869
467719569
574329459
...

result:

ok 100000 numbers

Test #70:

score: 0
Accepted
time: 283ms
memory: 27920kb

input:

100000
3
276555063 2630
556854137 6216
75821313 1060
2
966338161 10636
315444407 3740
2
931005081 10679
722536327 7571
2
70120818 1276
890710114 10148
4
501027607 5786
747436088 8163
519886166 5568
810573290 9368
2
429067175 4754
291646689 3081
18
618388350 6518
742851988 7725
600053863 6668
2088066...

output:

887588297
854250636
698962979
-1
-1
583845684
520516501
753527358
757331397
456092032
371088966
408998375
519544334
544376326
134372702
696754699
938588120
322684633
749180739
266087477
801756498
562349564
-1
49123256
-1
-1
-1
128305943
742231875
917047115
271564969
-1
689994597
844788187
857743261
...

result:

ok 100000 numbers