QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#17350#1843. Counting Pairstriple__aAC ✓2023ms92656kbC++171.9kb2022-01-05 16:27:372022-05-04 14:34:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 14:34:45]
  • 评测
  • 测评结果:AC
  • 用时:2023ms
  • 内存:92656kb
  • [2022-01-05 16:27:37]
  • 提交

answer

// #pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
// #pragma GCC optimize("trapv")
#include<bits/stdc++.h>

#define int long long
using namespace std;
 
#define rep(i,n) for (int i=0;i<(int)(n);++i)
#define rep1(i,n) for (int i=1;i<=(int)(n);++i)
#define range(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
const int mod=998244353;
const int INF=LLONG_MAX/4;
const int maxn=2000007;
const double EPS=1e-9;
const int N=5007;

int n,m;
int d[maxn],sum[maxn],cnt[maxn],ans[maxn];
map<pii,int> edges;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);
    cin>>n>>m;
    rep(i,m){
        int u,v;
        cin>>u>>v;
        if (u>v) swap(u,v);
        if (u==v) d[u]++;
        else edges[{u,v}]++, d[u]++, d[v]++;
    }
    rep1(i,n) cnt[d[i]]++, sum[d[i]]++;
    for (int i=m;i>0;--i) sum[i-1]+=sum[i];
    vi cand;
    for (int i=500002;i<=1000001;++i){
        if (cnt[i]) cand.pb(i);
    }
    for (int i=1000002;i>0;i-=2){
        if (cnt[i/2]) cand.pb(i/2);
        for (auto c:cand){
            ans[i]+=cnt[c]*(i-c>=0?sum[i-c]-sum[c]:n-sum[c]);
            ans[i-1]+=cnt[c]*(i-1-c>=0?sum[i-1-c]-sum[c]:n-sum[c]);
            ans[i]+=cnt[c]*(cnt[c]-1)/2;
            ans[i-1]+=cnt[c]*(cnt[c]-1)/2;
        }
    }
    for (auto c:edges){
        int u=c.F.F, v=c.F.S, w=c.S;
        for (int i=0;i<w;++i) ans[d[u]+d[v]-i]--;
    }
    int _;
    cin>>_;
    while (_--){
        int k;
        cin>>k;
        cout<<ans[k+1]<<"\n";
    }
    return 0;
}

/*
5 3 
3 0 2 3 
3 3 0 1
4 0 1 3 4

2 0 3 1 4

1 0 3 4 
*/

詳細信息

Test #1:

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

input:

4 5
1 2
2 4
1 3
2 3
2 1
2
2
3

output:

6
5

result:

ok 2 lines

Test #2:

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

input:

1 1000000
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
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 #3:

score: 0
Accepted
time: 244ms
memory: 29688kb

input:

2 1000000
1 1
2 2
2 1
2 1
1 1
1 1
1 2
1 2
2 1
1 1
1 1
2 1
2 2
2 1
2 2
2 2
1 1
2 2
1 2
1 2
1 1
1 2
1 2
2 2
2 2
2 2
2 2
1 2
1 2
2 1
2 1
2 1
1 1
2 2
2 1
2 1
1 2
1 1
1 2
1 2
1 1
1 1
2 2
1 1
2 2
1 1
1 1
1 1
1 2
1 2
1 1
1 1
1 1
1 2
2 1
2 2
1 1
2 2
2 1
1 1
1 1
2 1
1 2
2 1
1 1
2 2
2 2
1 2
1 1
1 2
1 1
2 2
1 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 1000000 lines

Test #4:

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

input:

4 1000000
3 4
3 3
2 1
4 1
2 4
2 1
3 4
4 3
1 4
1 4
3 1
3 2
2 1
2 3
4 1
1 1
3 4
2 2
3 4
1 1
4 1
4 1
1 1
3 4
2 3
4 4
2 4
3 3
3 3
1 4
1 2
2 3
3 2
1 4
2 2
4 1
2 3
2 3
4 4
1 4
1 2
1 3
4 1
4 3
1 3
3 2
3 1
1 3
4 4
2 2
1 2
2 1
3 3
2 3
1 2
2 1
1 1
2 3
2 2
4 3
3 4
4 3
2 1
4 1
1 2
3 2
3 3
3 2
3 4
2 2
2 2
4 4
3 ...

output:

6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
...

result:

ok 1000000 lines

Test #5:

score: 0
Accepted
time: 247ms
memory: 23632kb

input:

8 1000000
8 7
6 1
3 7
7 4
1 1
5 4
7 4
6 6
6 3
3 1
7 3
3 7
5 1
5 6
4 5
7 2
1 7
2 7
8 7
2 5
3 3
3 1
1 6
4 7
3 4
8 6
8 4
8 4
4 7
2 4
1 3
3 5
8 5
4 1
6 7
2 2
8 5
6 7
3 3
1 4
8 3
8 3
5 1
7 8
1 7
4 7
7 4
6 3
5 2
5 8
6 1
7 2
1 2
2 3
7 7
3 8
8 8
8 8
4 2
8 8
4 5
1 5
2 1
5 1
3 1
4 4
4 8
8 2
2 5
8 7
2 4
5 6
1 ...

output:

28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
...

result:

ok 1000000 lines

Test #6:

score: 0
Accepted
time: 326ms
memory: 20956kb

input:

16 1000000
16 8
7 9
5 1
9 5
2 2
13 8
5 3
6 8
14 16
7 2
8 6
9 10
14 9
1 7
15 14
14 6
12 16
3 14
8 14
7 14
12 16
12 7
16 8
1 8
5 6
9 7
15 6
13 15
8 12
5 7
4 6
6 4
10 2
13 12
10 12
5 14
3 6
6 2
14 12
3 7
15 7
6 2
2 14
12 5
13 16
7 11
3 15
2 6
9 16
13 3
9 11
6 8
4 7
4 4
12 4
14 2
9 15
7 12
5 7
16 5
15 4...

output:

120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
120
...

result:

ok 1000000 lines

Test #7:

score: 0
Accepted
time: 297ms
memory: 18200kb

input:

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

output:

496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
496
...

result:

ok 1000000 lines

Test #8:

score: 0
Accepted
time: 305ms
memory: 18684kb

input:

64 1000000
37 60
38 51
61 4
4 12
13 17
28 49
5 27
59 45
42 8
51 55
41 16
16 51
60 39
11 53
19 10
31 3
10 18
31 11
62 10
4 15
34 12
56 31
36 61
44 23
9 13
64 1
36 12
9 8
44 54
58 23
30 10
16 53
38 60
27 51
27 49
64 49
11 50
51 13
53 40
3 55
41 35
45 39
12 12
14 15
20 41
59 48
19 17
11 12
57 17
43 49
...

output:

2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
2016
...

result:

ok 1000000 lines

Test #9:

score: 0
Accepted
time: 395ms
memory: 18652kb

input:

128 1000000
99 111
108 45
71 99
63 124
125 42
105 38
102 10
76 123
51 14
115 92
112 15
106 128
115 11
61 3
120 105
8 1
30 54
95 97
96 127
84 41
65 39
2 108
74 93
66 15
107 123
70 67
116 23
102 40
89 52
51 114
90 44
99 117
65 10
45 80
104 51
61 94
82 1
68 76
50 57
88 31
81 73
75 58
19 11
121 13
123 7...

output:

8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
8128
...

result:

ok 1000000 lines

Test #10:

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

input:

256 1000000
189 15
27 26
47 247
119 20
57 104
35 128
31 235
5 136
47 189
95 7
102 10
255 249
216 212
141 182
153 176
249 214
53 100
94 179
23 82
209 76
233 121
224 83
157 124
173 207
134 164
102 167
246 206
40 4
244 94
100 161
101 43
69 46
81 142
29 237
223 179
18 222
256 9
172 202
195 203
24 75
163...

output:

32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
32640
...

result:

ok 1000000 lines

Test #11:

score: 0
Accepted
time: 807ms
memory: 24052kb

input:

512 1000000
14 254
10 211
364 5
33 262
187 45
268 491
86 73
13 332
134 176
152 403
481 241
493 227
89 397
482 216
480 499
105 249
86 510
450 382
355 204
442 486
401 385
108 308
255 132
369 434
456 24
289 216
164 507
54 183
41 502
490 135
31 104
187 275
228 33
281 260
386 302
6 252
347 162
53 358
398...

output:

130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816
130816...

result:

ok 1000000 lines

Test #12:

score: 0
Accepted
time: 1413ms
memory: 45932kb

input:

1024 1000000
491 760
1012 80
875 921
232 148
32 45
958 725
286 455
12 751
464 303
543 569
655 957
112 987
996 111
430 75
704 724
111 252
704 672
729 301
101 637
562 435
436 294
412 1022
1010 696
527 663
836 6
804 625
654 136
516 586
608 95
257 38
939 141
881 119
646 106
38 642
712 837
120 747
201 14...

output:

523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776
523776...

result:

ok 1000000 lines

Test #13:

score: 0
Accepted
time: 1688ms
memory: 67608kb

input:

2048 1000000
1540 1367
63 571
234 1994
94 1404
81 814
46 1009
720 373
365 1377
240 35
2044 455
1070 368
367 360
1268 930
470 275
1624 715
1249 209
278 1437
1526 1631
1677 324
937 1805
1666 50
823 948
1693 973
1366 1758
1274 1197
1785 797
483 234
852 1750
320 434
1797 1521
307 1324
279 984
1364 1577
...

output:

2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096128
2096...

result:

ok 1000000 lines

Test #14:

score: 0
Accepted
time: 1564ms
memory: 76800kb

input:

4096 1000000
364 2101
2096 3256
113 810
1223 2956
4087 1533
1963 1850
81 3669
2748 17
3805 825
134 2471
1581 595
2658 1613
2525 2723
3528 3190
2366 2791
291 812
1441 2637
1710 1055
3727 2942
2279 3363
1683 3147
821 108
955 2188
27 1452
323 107
1427 269
295 2503
107 860
2735 2057
2793 2034
3781 2640
...

output:

8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386560
8386...

result:

ok 1000000 lines

Test #15:

score: 0
Accepted
time: 1636ms
memory: 79632kb

input:

8192 1000000
8019 4156
5179 6933
242 1455
2464 4175
5497 7735
676 7396
6608 6879
5284 6221
5412 1391
7359 247
7730 2925
1823 1823
512 7671
4650 1179
5737 2559
4187 1684
6869 2948
3638 4837
7908 7650
4565 3243
331 6295
5252 4886
3407 153
4461 6181
5780 7160
3235 6054
2602 3434
2196 1230
6594 6453
478...

output:

33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
33550336
335...

result:

ok 1000000 lines

Test #16:

score: 0
Accepted
time: 1797ms
memory: 78140kb

input:

16384 1000000
14401 1101
2122 49
12114 12587
14972 12400
5677 9699
918 15591
8705 9391
15123 13970
4932 182
1712 9268
2302 16032
15540 5189
10895 13567
10158 11716
14982 2053
2796 15718
9467 7712
15459 14822
13277 1850
12202 5990
11894 2915
4276 1407
16358 1506
3959 10678
11042 11321
14890 8197
6136...

output:

134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
134209536
...

result:

ok 1000000 lines

Test #17:

score: 0
Accepted
time: 2023ms
memory: 80296kb

input:

32768 1000000
22420 25353
31300 8239
14777 32388
1959 14776
10956 20129
11561 3107
25288 7995
28575 25305
15550 16896
9096 18616
4170 11733
3123 4226
24231 6935
12978 12818
18395 28971
1791 17230
14605 58
32341 378
31891 19832
10914 19778
30779 24806
28249 17384
31239 8030
15069 138
9675 26746
24183...

output:

536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
536854528
...

result:

ok 1000000 lines

Test #18:

score: 0
Accepted
time: 1646ms
memory: 80540kb

input:

65536 1000000
58642 18662
5486 29968
33165 3290
61125 16975
47953 17937
40258 10882
42156 35281
29916 9017
58955 30356
64438 36080
12475 61843
11726 21863
31708 2643
59225 44951
62141 20604
29891 52757
64515 32508
46517 58393
36733 29259
24816 56303
28065 11370
39789 11849
22310 24493
9757 632
60050...

output:

2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450880
2147450879
2147450878
2147450865
2147450837
2147450776
2147450630
2147450305
2147449494
214...

result:

ok 1000000 lines

Test #19:

score: 0
Accepted
time: 1769ms
memory: 82456kb

input:

131072 1000000
94594 86492
660 104045
69124 3407
53648 68042
89652 35538
2740 20779
67109 39659
74398 76596
37832 100942
82114 73608
58472 46357
6941 75628
34365 86353
63115 8366
129827 13067
98119 23566
46151 35030
109378 80483
45316 114532
33378 62835
82562 31657
11851 128735
19124 81793
73951 527...

output:

8589869056
8589869056
8589869056
8589869050
8589869002
8589868648
8589866972
8589859660
8589833300
8589747593
8589501330
8588857664
8587326238
8583958007
8577085016
8563953945
8540406494
8500540287
8436642124
8339336324
8198207081
8002753389
7743788086
7414860638
7013589861
6542884558
6010933680
543...

result:

ok 1000000 lines

Test #20:

score: 0
Accepted
time: 1789ms
memory: 82556kb

input:

262144 1000000
125588 71313
132782 61670
49796 250057
251377 110668
229596 64516
57009 26554
48856 174522
8100 70699
185603 141955
28623 124357
159427 13001
208498 178347
259145 90970
242365 102734
193533 134051
151834 237039
231640 201930
171716 250156
200720 166460
163340 186688
180438 242758
2495...

output:

34359473721
34358530683
34353747727
34335525445
34279929830
34138500848
33829837872
33240031276
32238280514
30707604314
28582945622
25881327239
22711830395
19259581142
15749301113
12402023355
9396898077
6848422653
4800892279
3238148643
2102471136
1314911598
792585706
460703840
258349952
139806083
72...

result:

ok 1000000 lines

Test #21:

score: 0
Accepted
time: 1714ms
memory: 84500kb

input:

524288 1000000
487706 484091
226221 124753
426512 331566
520386 380418
382646 230827
521977 232849
327226 300784
67429 101120
240445 325275
227747 347281
484809 477539
106722 506736
406450 183061
209075 276245
76799 457801
218459 58969
116150 468244
410332 496415
488828 176082
347626 17359
255507 85...

output:

136866488960
134926175184
129980837499
120543806538
106148337161
87852061982
67917618504
48909771263
32796149374
20500122302
11969371451
6543939967
3358799906
1622540634
739273837
318202644
129469120
49780993
18060608
6165328
1974464
590014
163118
41707
9451
1882
314
22
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 1000000 lines

Test #22:

score: 0
Accepted
time: 1583ms
memory: 90056kb

input:

1000000 1000000
947122 782671
947122 45635
947122 5399
947122 402051
947122 570960
947122 228984
947122 93297
947122 410668
947122 677243
947122 919535
947122 918284
947122 548247
947122 334350
947122 914912
947122 909931
947122 580603
947122 208391
947122 659439
947122 957482
947122 531353
947122 5...

output:

400525409377
288415646126
176292895828
92249442822
41898756075
16758375595
5978377423
1922625557
562831570
151501458
38100257
9417874
2750040
1332085
1057192
1008784
1001164
1000139
1000009
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
99999...

result:

ok 1000000 lines

Test #23:

score: 0
Accepted
time: 1472ms
memory: 91412kb

input:

1000000 1000000
313693 57106
121156 275523
121156 56356
121156 196763
121156 609294
121156 373396
121156 41664
121156 505290
121156 69311
121156 601774
121156 859136
121156 171778
121156 795568
121156 209302
121156 369055
121156 417753
121156 600838
121156 280274
121156 640140
121156 359130
121156 7...

output:

400370143979
288278898095
176337383594
92434600717
42052623157
16812216070
5970660975
1902140768
549548468
145920336
36335567
8980136
2665857
1319218
1055598
1008648
1001178
1000158
1000014
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
99999...

result:

ok 1000000 lines

Test #24:

score: 0
Accepted
time: 1346ms
memory: 89748kb

input:

1000000 1000000
640716 224842
962572 158723
962572 489183
480379 633821
480379 635324
480379 214998
21752 131031
21752 255431
21752 487188
21752 938492
21752 130543
21752 641389
21752 140120
21752 564178
21752 336342
21752 944438
21752 512212
21752 964369
21752 53232
21752 25521
21752 552460
21752 4...

output:

400386659658
288408204153
176426120097
92398084299
41941248074
16725017941
5943713032
1909503149
561748443
153063442
39284089
9959606
2950119
1394533
1074269
1012764
1002020
1000292
1000036
1000002
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
9999...

result:

ok 1000000 lines

Test #25:

score: 0
Accepted
time: 1518ms
memory: 90804kb

input:

1000000 1000000
233883 418253
163974 315368
163974 883583
644958 559243
644958 754622
644958 779030
321673 693124
321673 198073
321673 6914
321673 262542
65322 196056
65322 81355
65322 234524
65322 264691
65322 1688
368044 822004
368044 265051
368044 840157
368044 369854
368044 168210
368044 628707
...

output:

400517175944
288506137451
176394602470
92300232023
41892984979
16722504884
5942463659
1899441401
551230463
146647288
36344684
8862677
2597422
1295104
1049133
1007257
1000925
1000101
1000005
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
999999
99999...

result:

ok 1000000 lines

Test #26:

score: 0
Accepted
time: 1607ms
memory: 89832kb

input:

1000000 1000000
138000 671879
418857 720777
418857 855291
563384 466827
563384 764478
563384 720306
108983 407683
108983 16700
108983 930990
108983 709040
845127 737171
845127 880156
845127 480187
845127 306152
845127 837432
819184 593017
819184 1471
819184 820285
819184 222628
819184 191992
819184 ...

output:

400564781432
288546683419
176422218012
92290111215
41851507717
16679524792
5921759691
1901943232
563675927
158848902
45657518
15700778
7432352
4441358
3027066
2370506
1890001
1471835
1197750
1066834
1018673
1004519
1000933
1000202
1000054
1000012
1000004
1000004
1000002
1000000
999999
999999
999999
...

result:

ok 1000000 lines

Test #27:

score: 0
Accepted
time: 1487ms
memory: 91280kb

input:

1000000 1000000
304091 565003
315213 231243
315213 217754
801642 91358
801642 242654
801642 854170
878825 732824
878825 932034
878825 146963
878825 169278
108815 628965
108815 102115
108815 224318
108815 43894
108815 153178
468471 935675
468471 655324
468471 990120
468471 532092
468471 128992
468471...

output:

400470330339
288513020209
176472064056
92389125397
41924091795
16707849998
5930128186
1906933416
571666633
170924149
60342091
31434780
23868318
21796426
20541438
18931580
17469579
16358225
15182891
14125884
13236636
12370924
11675447
10820489
9747367
8402299
7212137
6486520
5712354
4704699
3389090
2...

result:

ok 1000000 lines

Test #28:

score: 0
Accepted
time: 1634ms
memory: 91888kb

input:

1000000 1000000
843471 851936
832918 790574
832918 360884
937455 39714
937455 207835
937455 739581
614134 787755
614134 647557
614134 455277
614134 348735
188717 10502
188717 320451
188717 770637
188717 900173
188717 445740
421796 381828
421796 274816
421796 843280
421796 494497
421796 83212
421796 ...

output:

400356951446
288475336836
176529373436
92472234136
41996807772
16778770046
5995173334
1959291520
612488008
205754768
93339395
64211764
56308462
53419371
52025519
51370385
50441606
49131600
47799056
46607467
45754059
45064372
44309226
43433849
42257323
41160565
40471026
39707448
38702924
37611275
367...

result:

ok 1000000 lines

Test #29:

score: 0
Accepted
time: 1619ms
memory: 92024kb

input:

1000000 1000000
511753 186230
672115 86776
672115 603023
278965 154310
278965 757018
278965 252495
137808 175350
137808 55071
137808 198753
137808 556750
703869 348106
703869 358078
703869 903959
703869 773366
703869 470894
692115 962172
692115 567106
692115 868164
692115 707997
692115 42189
692115 ...

output:

400470231921
288501259977
176473392919
92424120031
42033212509
16871562860
6087636896
2032854866
675652190
267355914
156227153
128293051
121204386
118651534
116799353
115146245
113977537
112689699
111433735
110373796
109193424
108126788
107455903
106923570
106478711
105972480
105281299
104200529
102...

result:

ok 1000000 lines

Test #30:

score: 0
Accepted
time: 1586ms
memory: 92092kb

input:

1000000 1000000
565297 823709
873678 344516
873678 495530
125799 235907
125799 239389
125799 950014
329974 400627
329974 395904
329974 418420
329974 457676
357408 687642
357408 399573
357408 789521
357408 725235
357408 592691
233221 697967
233221 140014
233221 512868
233221 367429
233221 873369
2332...

output:

400460068296
288420621191
176470094906
92588704254
42252691711
17051918385
6232246017
2167469117
808758376
398111395
284191987
254894714
247673305
245347085
244113546
242982933
241783705
240613865
239299525
237928876
236666537
235538836
234714437
234258082
233840646
232993225
232053706
230975849
229...

result:

ok 1000000 lines

Test #31:

score: 0
Accepted
time: 1640ms
memory: 92656kb

input:

1000000 1000000
870972 104166
171900 763805
171900 93487
162525 754699
162525 136130
162525 674395
913513 291873
913513 648583
913513 244515
913513 729961
472418 731754
472418 733345
472418 804444
472418 743970
472418 831104
348952 983208
348952 51599
348952 673858
348952 880994
348952 385977
348952...

output:

400714782457
288770246101
176721464840
92681668648
42301996073
17157869191
6407498932
2385588068
1047239414
646263470
537295173
510385089
503909400
502021877
500628490
499339841
498262417
497524070
496678327
495618485
494500046
493647329
492503759
491077304
489696713
488493238
487636258
486946463
48...

result:

ok 1000000 lines

Test #32:

score: 0
Accepted
time: 1439ms
memory: 86624kb

input:

1000000 1000000
258051 83960
889443 517112
889443 220392
112815 173229
112815 680312
112815 228545
491640 661820
491640 952048
491640 245634
491640 835749
344913 530861
344913 150999
344913 499383
344913 124259
344913 973323
435709 436733
435709 903171
435709 908749
435709 370369
435709 451044
43570...

output:

396763362801
283316171099
171765389032
89400212100
40698835833
16679543337
6516665964
2749874701
1508374993
1140869218
1042409830
1018332429
1012672418
1010737739
1009591969
1008703952
1007840635
1006922255
1006184353
1005532687
1004326600
1003005590
1001664729
1000344537
999362252
998367752
9974700...

result:

ok 1000000 lines