QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#408787#8641. Ski 2Lynkcat100 ✓126ms5288kbC++202.3kb2024-05-11 04:32:552024-05-11 04:33:07

Judging History

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

  • [2024-05-11 04:33:07]
  • 评测
  • 测评结果:100
  • 用时:126ms
  • 内存:5288kb
  • [2024-05-11 04:32:55]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) (int)((x).size())
#define int ll
//#define N
using namespace std;
const int N=305;
int n,K,h[N],c[N];
map<int,int>Mp,all;
int dp[N][N],tmp[N][N],p[N];
inline int cmp(int x,int y)
{
	if (!x||!y) return x+y;
	return (c[p[x]]<c[p[y]]?x:y);
}
void BellaKira()
{
	cin>>n>>K;
	for (int i=1;i<=n;i++)
	{
		cin>>h[i]>>c[i];
		p[i]=i;
	}
	sort(p+1,p+n+1,[&](int x,int y)
	{
		if (h[x]==h[y]) return c[x]<c[y];
		return h[x]<h[y];
	});
	poly g;
	for (int i=n;i>=1;i--) 
	{
		Mp[h[p[i]]]=c[p[i]];
		all[h[i]]++;
		g.push_back(h[i]);
		g.push_back(h[i]+1);
		g.push_back(h[i]+2);
	}
	sort(g.begin(),g.end());
	g.erase(unique(g.begin(),g.end()),g.end());
	memset(dp,0x3f,sizeof(dp));
	memset(tmp,0x3f,sizeof(tmp));
	
	int ans=dp[0][0];
	int tot=all[g[0]],mn=Mp[g[0]];
	dp[1][all[g[0]]-1]=0;
	
	for (int t=1;t<sz(g);t++)
	{
		memset(tmp,0x3f,sizeof(tmp));
		int nw=all[g[t]];
		for (int x=0;x<=tot;x++)
			for (int y=0;x+y<=tot;y++)
			{
				int ny=y+nw;
				if (ny>=x)
					tmp[x][ny-x]=min(tmp[x][ny-x],dp[x][y]+y*K);
				else tmp[x][0]=min(tmp[x][0],dp[x][y]+y*K);
			}
		for (int x=1;x<=tot+nw;x++)
			for (int y=0;y<=tot+nw;y++)
			{
				tmp[x][y]=min(tmp[x][y],tmp[x-1][y+1]+mn);
			}
		memcpy(dp,tmp,sizeof(dp));
		tot+=nw;
		if (nw) mn=min(mn,Mp[g[t]]);
		
		memset(tmp,0x3f,sizeof(tmp));
		int lim=1e14;
		if (t+1<sz(g)) lim=g[t+1]-g[t]-1;
		for (int x=0;x<=tot;x++)
			for (int y=0;y<=tot;y++)
				if (dp[x][y]<ans)
				{
					if (x==0)
					{
						if (lim!=1e14)
							tmp[x][y]=min(tmp[x][y],dp[x][y]+lim*K*y);
					} else
					{
						if (y-lim*x>=0)
						{
							tmp[x][y-lim*x]=min(tmp[x][y-lim*x],
							dp[x][y]+(y-lim*x+x+y)*lim/2*K);
						} else
						{
							tmp[x][0]=min(tmp[x][0],
							dp[x][y]+(y%x+y)*(y/x+1)/2*K);
						}
					}
				}
		memcpy(dp,tmp,sizeof(dp));
	}
	for (int i=1;i<=n;i++)
		ans=min(ans,dp[i][0]);
	cout<<ans<<'\n';
}
signed main()
{
	IOS;
	cin.tie(0);
	int T=1;
	while (T--)
	{
		BellaKira();
	}
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 39ms
memory: 5024kb

input:

300 987761245
249 97
279 38
52 53
190 2
294 46
170 93
260 70
273 6
49 4
32 71
188 28
212 10
253 86
187 46
167 27
32 75
226 90
86 17
172 24
129 70
291 78
189 98
97 98
256 19
228 36
240 86
240 63
269 21
81 81
41 25
155 49
279 12
176 49
136 25
260 95
271 90
202 79
299 36
79 53
297 59
46 92
202 19
125 3...

output:

144

result:

ok single line: '144'

Test #2:

score: 5
Accepted
time: 37ms
memory: 5056kb

input:

300 451766134
225 3
78 77
144 26
211 37
119 39
126 65
7 47
53 7
121 37
52 60
212 24
168 60
212 42
104 45
218 4
146 42
234 25
43 83
126 67
128 61
125 80
87 62
113 8
71 28
148 80
175 34
126 77
295 91
35 62
265 31
35 29
108 8
195 34
85 59
250 41
78 62
242 17
178 80
34 15
187 60
94 34
50 25
144 29
10 8
...

output:

103

result:

ok single line: '103'

Test #3:

score: 5
Accepted
time: 31ms
memory: 5260kb

input:

300 584296612
252 63
248 8
136 92
181 38
206 77
229 21
196 84
7 86
187 29
170 42
195 10
148 100
279 2
113 65
22 18
148 68
11 14
187 72
133 59
205 7
155 95
251 76
300 18
265 19
76 59
59 76
86 7
73 84
101 49
19 47
25 70
24 44
29 75
112 77
128 27
28 27
198 29
148 56
128 89
218 26
177 13
117 84
25 91
0 ...

output:

1168593404

result:

ok single line: '1168593404'

Test #4:

score: 5
Accepted
time: 30ms
memory: 5104kb

input:

300 542226210
235 86
10 24
160 95
40 31
293 60
285 77
285 97
24 83
26 70
254 50
136 68
112 23
84 28
236 41
101 49
70 94
282 6
231 57
199 51
146 39
55 54
192 47
192 66
72 74
186 96
136 42
72 13
282 18
296 53
127 46
16 75
241 84
146 52
241 62
231 5
143 46
40 35
105 69
126 31
252 3
101 16
154 33
30 100...

output:

125

result:

ok single line: '125'

Test #5:

score: 5
Accepted
time: 29ms
memory: 5172kb

input:

300 851059749
59 76
266 2
7 58
202 53
214 58
256 30
99 28
224 16
64 80
150 93
12 14
278 15
196 7
259 97
13 27
256 100
66 90
257 26
85 44
49 64
171 63
266 37
95 44
123 75
203 41
261 89
81 30
65 51
64 42
66 45
108 10
198 45
128 86
234 49
199 77
65 37
234 52
246 8
198 12
50 3
181 71
218 83
66 85
261 73...

output:

851059869

result:

ok single line: '851059869'

Test #6:

score: 5
Accepted
time: 27ms
memory: 5008kb

input:

300 947403587
92 86
43 91
295 85
105 15
236 78
295 66
11 82
72 54
69 76
145 17
224 66
19 35
249 75
21 92
99 85
38 61
222 81
145 68
14 60
21 23
38 97
133 63
257 6
139 64
295 34
133 80
157 29
57 33
38 9
155 31
102 77
191 98
201 87
255 85
203 38
242 54
38 78
242 59
159 81
26 56
43 82
102 83
14 94
36 87...

output:

947404177

result:

ok single line: '947404177'

Test #7:

score: 5
Accepted
time: 5ms
memory: 5000kb

input:

300 363080349
19 96
23 83
20 86
22 86
7 93
12 100
21 79
14 92
15 90
19 91
23 96
16 89
20 84
8 100
22 79
21 94
20 85
19 88
11 100
22 90
22 80
2 99
23 89
21 84
23 80
8 96
9 96
23 88
17 93
16 84
11 95
22 90
18 86
11 92
19 81
18 88
9 92
12 97
4 98
17 89
23 95
5 99
10 93
18 89
10 97
16 91
8 97
16 85
20 8...

output:

363082396

result:

ok single line: '363082396'

Test #8:

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

input:

300 1000000000
300 57
300 24
300 40
300 45
300 68
300 38
300 94
300 79
300 39
300 87
300 98
300 79
300 63
300 56
300 97
300 63
300 52
300 61
300 83
300 35
300 19
300 38
300 12
300 9
300 87
300 3
300 92
300 54
300 5
300 37
300 43
300 11
300 25
300 87
300 70
300 65
300 58
300 57
300 70
300 87
300 67
3...

output:

299000000298

result:

ok single line: '299000000298'

Subtask #2:

score: 12
Accepted

Test #9:

score: 12
Accepted
time: 2ms
memory: 5048kb

input:

300 1
0 6596366
1 195480684
2 39457151
1 832234727
1 462764495
2 81049898
0 487070027
1 430671894
2 721333033
1 615885993
1 842070560
1 592116125
2 840818824
0 544935711
2 333187430
2 467111553
0 416912849
2 159079860
0 478546939
0 593053374
0 876528192
2 9215174
1 93255151
2 120891934
0 10339332
2 ...

output:

44543

result:

ok single line: '44543'

Test #10:

score: 12
Accepted
time: 2ms
memory: 5064kb

input:

300 1060203
0 1286878
1 960668502
2 190866228
1 195306795
1 233497287
0 343641186
0 693228127
0 67978764
2 598546069
0 751890541
0 37754998
0 305348452
1 266631431
1 844903768
1 560113131
2 47250552
0 594767495
2 809926081
0 586661105
0 366656127
0 589306393
2 416896948
2 89253046
1 363341342
0 9491...

output:

373039535

result:

ok single line: '373039535'

Test #11:

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

input:

300 1011700
0 4143879
5 61178231
1 214955252
5 577924292
3 532426729
4 862464334
4 215922747
1 602163591
2 90390184
4 709933135
1 948890772
3 784747556
2 261263945
4 784527448
3 989184114
5 465210434
3 83935742
5 876450661
3 626127035
1 699569645
1 5830291
4 974711739
0 542998610
3 604346813
1 14345...

output:

365657793

result:

ok single line: '365657793'

Test #12:

score: 12
Accepted
time: 3ms
memory: 5072kb

input:

300 2629882
0 7876717
1 380548027
4 210300855
3 804812637
0 795433451
0 696287735
1 251831535
2 510880579
5 328652705
0 850216531
5 609349591
3 66131892
5 355383071
2 846765095
2 127222407
1 933995931
0 609083290
4 506229752
1 922802380
3 277035017
2 693421958
0 339580672
4 296433175
1 933653265
2 5...

output:

732780332

result:

ok single line: '732780332'

Test #13:

score: 12
Accepted
time: 16ms
memory: 5164kb

input:

300 2161
0 4686752
8 629699716
36 412556162
10 196116733
93 237242586
45 458684505
60 125966325
2 855656971
76 750982211
88 543425907
38 355258329
92 448453464
26 608377947
93 18561617
69 644272241
23 178136181
48 306908918
32 962694105
79 683443776
28 623663382
100 501582180
92 578581062
26 8341942...

output:

10667943

result:

ok single line: '10667943'

Test #14:

score: 12
Accepted
time: 15ms
memory: 5052kb

input:

300 1264601
0 2244378
70 999535496
70 770638615
43 175588958
7 679253897
72 966146892
8 723807777
30 214248412
86 304229971
69 177589825
48 546447871
66 385401179
92 977036346
39 868966348
81 533340807
23 441268090
51 803400831
84 17907592
22 67033263
60 751134225
1 131600198
14 437904793
79 3453315...

output:

18239848

result:

ok single line: '18239848'

Test #15:

score: 12
Accepted
time: 38ms
memory: 5092kb

input:

300 425400
0 1915855
18 418792787
218 647548770
186 171684693
20 829774979
38 495244240
273 322971719
51 872137770
279 602534746
37 558726564
180 812007613
102 106188773
37 691630980
172 664413269
154 456050691
155 277923631
218 685494540
56 834990956
128 808406942
73 966781691
154 610439249
198 103...

output:

5958710

result:

ok single line: '5958710'

Test #16:

score: 12
Accepted
time: 42ms
memory: 5076kb

input:

300 1158451
1 12714371
194 740204971
274 273192348
10 233690292
30 152192819
241 350005285
140 376261817
105 246687825
290 515238843
15 563646519
47 417246070
244 220045148
155 413470747
204 711463900
167 810376102
185 470107777
271 261463098
232 228256857
108 164983349
59 752563934
109 787862089
11...

output:

31220997

result:

ok single line: '31220997'

Test #17:

score: 12
Accepted
time: 2ms
memory: 5216kb

input:

300 232014275
0 1335577
20 923253862
10 861996110
2 534287257
4 97575908
6 703656009
20 176840984
0 995189842
4 847450828
10 532473518
8 638980368
20 956596084
6 790434470
4 773069953
12 772814387
14 893619615
8 394660502
16 367410607
20 210732209
2 338176881
20 862071228
10 159569938
4 345386924
14...

output:

5617758949

result:

ok single line: '5617758949'

Test #18:

score: 12
Accepted
time: 7ms
memory: 5244kb

input:

300 7917929
2 23753787
4 881012995
4 843565653
6 243395540
6 332308712
6 731673552
8 768571347
8 667663560
8 999384285
8 605635849
10 672916805
10 549596745
10 608973816
10 969769288
10 123642168
12 924486873
12 714943281
12 322453474
12 611226720
12 70245389
12 249196857
14 43704099
14 400483309
14...

output:

522583314

result:

ok single line: '522583314'

Test #19:

score: 12
Accepted
time: 7ms
memory: 5036kb

input:

300 5712244
2 85683660
4 531574076
4 143856895
6 500019170
6 569021851
6 845915493
8 484912884
8 110335721
8 377454454
8 970107075
10 668551087
10 573840833
10 602084189
10 840330670
10 393762627
12 676568255
12 481846266
12 529475072
12 307726263
12 960271047
12 725995830
14 348984197
14 214766767
...

output:

1388075292

result:

ok single line: '1388075292'

Subtask #3:

score: 9
Accepted

Test #20:

score: 9
Accepted
time: 2ms
memory: 4988kb

input:

10 849097758
4 937762392
10 817247459
0 440668594
1 912982987
7 663812156
7 594886472
0 837105766
2 737473115
3 649275922
10 873042888

output:

1289766352

result:

ok single line: '1289766352'

Test #21:

score: 9
Accepted
time: 2ms
memory: 5048kb

input:

10 9998
5 878445115
0 949971639
4 896709623
3 782518625
0 763551803
2 795919483
10 820305225
7 955019709
0 988957902
6 794013355

output:

89982

result:

ok single line: '89982'

Test #22:

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

input:

10 313931642
1 752682337
6 864853209
7 172291208
3 849996643
9 462903663
3 806832309
7 415016851
7 200488544
2 936575125
4 772486850

output:

1066613979

result:

ok single line: '1066613979'

Test #23:

score: 9
Accepted
time: 2ms
memory: 5012kb

input:

10 374
3 962058719
9 752701033
9 645570821
7 985449153
7 578273422
3 804266379
5 854354117
4 993866589
9 911208632
4 975880747

output:

5610

result:

ok single line: '5610'

Test #24:

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

input:

10 324770512
10 375908339
1 411213202
4 392519015
8 901521995
5 421608634
9 705664450
3 592078552
6 633681433
0 534389104
10 683380690

output:

324770512

result:

ok single line: '324770512'

Test #25:

score: 9
Accepted
time: 2ms
memory: 4972kb

input:

10 108923
10 120608144
6 991122545
10 591398529
6 777899046
1 904193758
9 944103839
7 642544838
4 688262357
1 953425951
10 190058178

output:

653538

result:

ok single line: '653538'

Test #26:

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

input:

10 932546022
9 38744232
1 995739974
2 998741663
6 847774949
2 996519521
5 866539522
7 526895946
10 8709873
4 996793074
6 844393176

output:

995739974

result:

ok single line: '995739974'

Test #27:

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

input:

10 11953563
0 994878622
3 906206994
1 915019718
1 864107053
0 999397042
6 581277066
3 676038157
10 83264360
0 996754561
7 229761931

output:

179303445

result:

ok single line: '179303445'

Test #28:

score: 9
Accepted
time: 2ms
memory: 5224kb

input:

10 714566765
6 565233644
1 749146469
8 190842124
7 505680950
7 199148424
5 664206601
8 858960166
2 706982967
9 17885105
0 789061662

output:

565233644

result:

ok single line: '565233644'

Test #29:

score: 9
Accepted
time: 2ms
memory: 4992kb

input:

10 2706858
8 20780016
2 612818354
3 550413138
1 565798966
5 236857307
4 422818113
6 141418944
0 660351593
7 74422537
5 669426759

output:

10827432

result:

ok single line: '10827432'

Test #30:

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

input:

10 79131102
3 561812059
10 629590644
0 775921462
3 65546214
4 47956310
6 9533026
6 413541633
10 724465012
3 978513343
1 717560726

output:

289354632

result:

ok single line: '289354632'

Test #31:

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

input:

10 83256
6 698120
3 1534802
8 437707384
5 212414104
7 468360049
4 878752
1 981212200
10 272656828
2 719985274
10 752429067

output:

83256

result:

ok single line: '83256'

Test #32:

score: 9
Accepted
time: 2ms
memory: 5052kb

input:

10 1
5 14274
2 570420826
5 355150629
6 357632129
8 528001647
7 934027175
6 481321503
4 1273104
6 3094
1 814868110

output:

13

result:

ok single line: '13'

Test #33:

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

input:

10 2873864
10 977169433
10 847905313
10 124227633
10 549266764
0 236666415
10 890433448
10 661097582
10 564499162
10 343958722
10 854023415

output:

103459104

result:

ok single line: '103459104'

Test #34:

score: 9
Accepted
time: 1ms
memory: 5044kb

input:

10 1000000000
10 508707288
10 58470524
10 321845938
10 323290860
10 776749224
0 1000000000
10 137965772
10 524047258
10 180390059
10 713703265

output:

8000000000

result:

ok single line: '8000000000'

Test #35:

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

input:

10 226214084
8 824556953
8 508286392
8 477565118
8 145272502
8 540447972
8 460840516
8 206666089
8 591816141
8 254840354
8 927809299

output:

3198106772

result:

ok single line: '3198106772'

Test #36:

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

input:

10 10
9 420719880
9 174634535
9 936752657
9 381266133
9 833058617
9 372254594
9 794099768
9 388422457
9 540952494
9 456683771

output:

450

result:

ok single line: '450'

Test #37:

score: 9
Accepted
time: 2ms
memory: 4968kb

input:

10 24
10 840795537
10 863928462
10 786445929
10 613005621
10 931415607
10 658396805
10 900315095
10 500448499
10 565668068
10 999965883

output:

1080

result:

ok single line: '1080'

Test #38:

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

input:

10 35179030
2 869884177
2 957349278
0 979089717
2 874549497
3 940925611
3 727713012
0 960781959
3 724210350
3 988081346
1 897834835

output:

914654780

result:

ok single line: '914654780'

Test #39:

score: 9
Accepted
time: 1ms
memory: 5216kb

input:

10 106
0 424
0 212
0 318
0 530
0 954
0 742
0 636
0 1060
0 106
0 848

output:

1802

result:

ok single line: '1802'

Test #40:

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

input:

10 121
0 1936
0 1694
1 726
0 2420
0 1452
1 484
1 1210
1 968
1 242
0 2178

output:

2662

result:

ok single line: '2662'

Test #41:

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

input:

10 172
2 1032
2 516
0 3612
0 4128
1 2580
0 4644
0 5160
1 2064
1 3096
2 1548

output:

4472

result:

ok single line: '4472'

Test #42:

score: 9
Accepted
time: 1ms
memory: 4988kb

input:

1 685041057
4 990761589

output:

0

result:

ok single line: '0'

Subtask #4:

score: 33
Accepted

Dependency #3:

100%
Accepted

Test #43:

score: 33
Accepted
time: 0ms
memory: 5148kb

input:

40 775287934
15 627598219
0 879640425
2 583623769
28 674296588
8 742162320
40 709091851
37 567907921
34 577543751
0 733598362
23 583109809
31 945393785
40 637430437
34 890099810
24 952303758
10 925604686
4 753214661
11 718708236
22 868289856
11 829766025
10 925608457
19 640362335
10 644476892
16 930...

output:

2661444590

result:

ok single line: '2661444590'

Test #44:

score: 33
Accepted
time: 4ms
memory: 4992kb

input:

40 496463
28 738084705
15 898550967
40 763074368
32 837986867
32 942216033
13 856836487
20 793001875
32 914058962
28 948460805
19 996421342
29 891979805
8 837113574
13 787002223
12 780641428
13 722451752
25 788970866
34 988435567
2 965013102
0 754168493
27 872232667
12 995001749
20 875486433
25 8033...

output:

45178133

result:

ok single line: '45178133'

Test #45:

score: 33
Accepted
time: 4ms
memory: 4988kb

input:

40 354788490
31 418636662
38 361966458
11 741919909
36 624686847
30 237930654
20 848553776
30 739580296
18 627923142
25 948765010
8 944204212
16 800271029
36 348066617
31 385966481
19 586438622
1 993551164
19 542191870
6 994378654
2 993440875
23 621889579
5 997776307
21 695891186
38 125106033
15 811...

output:

1178620474

result:

ok single line: '1178620474'

Test #46:

score: 33
Accepted
time: 4ms
memory: 4968kb

input:

40 11186912
21 819188396
10 863121127
8 812385287
28 919787402
31 529034016
40 940607967
4 946875031
23 691115613
12 829788973
9 958529656
8 910218011
36 438089052
35 424777334
40 63540247
21 789028269
14 660910075
0 882265146
1 997603098
16 630082472
32 504122218
9 935130843
36 638881853
38 8287389...

output:

901880583

result:

ok single line: '901880583'

Test #47:

score: 33
Accepted
time: 5ms
memory: 4980kb

input:

40 189215091
9 785347338
3 923017130
31 330735433
14 678414157
40 180812380
6 808086774
0 931879612
10 749407928
40 10099534
20 717211897
3 914780644
25 395309185
21 479040565
15 561967472
11 732351796
0 993236962
22 565931686
26 681136152
9 767799019
37 69639665
4 878680793
19 685731462
28 39284954...

output:

1877955067

result:

ok single line: '1877955067'

Test #48:

score: 33
Accepted
time: 2ms
memory: 4952kb

input:

40 23921
8 758795362
26 311762913
17 490489115
3 998193112
6 908359476
9 741782519
29 810388119
21 316551139
22 561360478
12 728408380
29 248844508
40 929576745
25 336561770
18 424465462
8 776686456
22 552902337
3 963791848
8 827724982
5 941082218
19 367014450
39 168240533
7 828050546
23 902420297
3...

output:

1507023

result:

ok single line: '1507023'

Test #49:

score: 33
Accepted
time: 4ms
memory: 5228kb

input:

40 223384422
6 817027789
19 478289788
4 893349646
24 178222165
29 123934589
7 807764344
26 169628132
32 184112455
10 805849019
6 874162373
38 72990476
40 3160499
12 953758576
1 963383453
39 44537575
5 820099306
34 684862959
22 239123115
20 474255973
35 74613631
16 586597076
27 131047742
30 113421885...

output:

895742306

result:

ok single line: '895742306'

Test #50:

score: 33
Accepted
time: 5ms
memory: 5144kb

input:

40 8613387
20 496577340
9 661428616
4 788254889
31 212735347
16 568485882
33 182323447
14 616915188
22 427473303
15 593254234
8 670777569
27 342252459
6 705881042
9 762460542
10 760606059
3 937950997
34 78436392
21 440406206
17 519339896
28 993102611
18 516103955
24 411202222
5 728670714
36 52101197...

output:

637390638

result:

ok single line: '637390638'

Test #51:

score: 33
Accepted
time: 5ms
memory: 4952kb

input:

40 982897772
10 676261773
0 955495507
22 450070334
30 340939334
32 300447466
11 647427687
17 531207490
1 912879078
40 15042514
25 379263192
9 718365595
3 887974792
5 857744808
36 130808013
6 824152563
27 361775332
12 621652042
2 900293338
31 313136750
8 734907256
4 862894460
21 450941120
37 88100188...

output:

0

result:

ok single line: '0'

Test #52:

score: 33
Accepted
time: 5ms
memory: 5036kb

input:

40 646014
1 911280203
2 900613585
37 100592262
4 831994976
39 46561929
7 768801576
29 316916668
0 951152970
30 315026417
34 199240769
12 624585259
20 534428063
14 613492285
23 496137014
18 546678096
13 621195264
38 86346027
24 437178045
3 879725425
22 518155152
35 179991908
17 565401094
32 306689917...

output:

0

result:

ok single line: '0'

Test #53:

score: 33
Accepted
time: 4ms
memory: 5220kb

input:

40 76500852
29 764334047
2 909920465
7 789003198
3 892756475
2 929932612
29 488502396
23 388479006
15 545763482
21 4328296
5 890573589
27 682963225
7 976834617
33 577793888
31 571993268
16 120951208
31 551033169
18 29490364
19 18417167
26 868197819
27 206
3 989368179
3 963631170
22 829390738
14 6384...

output:

1220895627

result:

ok single line: '1220895627'

Test #54:

score: 33
Accepted
time: 4ms
memory: 5032kb

input:

40 202955
15 956807142
24 6121302
28 3368
30 789577719
6 738372159
9 690512721
18 338132561
17 22613524
13 557177702
35 543526688
2 971373499
7 707237695
16 27484190
5 785849780
5 934668217
4 922921023
23 547416447
27 17045
40 598917299
33 502246724
11 618777229
34 202372625
37 304039930
23 6848598
...

output:

12819224

result:

ok single line: '12819224'

Test #55:

score: 33
Accepted
time: 2ms
memory: 5228kb

input:

40 157615
38 478992657
28 568653189
6 862231507
0 978758995
19 232177501
7 809672092
14 116157228
15 774050
37 214309509
33 175535848
21 11811
29 1
9 642489416
18 52669
25 511613359
32 31770657
27 583
29 400352594
25 613353666
8 690911287
40 451910608
24 7421
11 945054014
4 879849429
19 883845551
4 ...

output:

5107153

result:

ok single line: '5107153'

Test #56:

score: 33
Accepted
time: 2ms
memory: 5056kb

input:

40 218253
0 822728709
40 749188003
40 756303665
40 80288435
40 565742184
40 625034493
40 94968178
40 609164706
40 826226081
40 889559686
40 782092883
40 785981880
40 780774401
40 693860736
40 442153729
40 770441373
40 67746385
40 964497827
40 914713295
40 215624676
40 93901278
40 794865119
40 834833...

output:

150682525

result:

ok single line: '150682525'

Test #57:

score: 33
Accepted
time: 0ms
memory: 5052kb

input:

40 1000000000
40 880460960
40 701301591
40 118972220
0 1000000000
40 210641233
40 918598644
40 36678728
40 469366744
40 17713115
40 358446264
40 692824266
40 902470994
40 612812683
40 802023511
40 642907096
40 407524586
40 85390101
40 383427800
40 100909769
40 628081507
40 708288968
40 513348159
40 ...

output:

38000000000

result:

ok single line: '38000000000'

Test #58:

score: 33
Accepted
time: 0ms
memory: 4976kb

input:

40 903010436
3 186429052
3 866752174
3 438394119
3 465436648
3 856133870
3 131418921
3 46639173
3 193584395
3 368739657
3 766824538
3 302137043
3 179377030
3 26027844
3 63835158
3 374542542
3 254256067
3 227075725
3 119560589
3 56828488
3 218269937
3 469620862
3 522623910
3 893194687
3 906726006
3 4...

output:

36206465076

result:

ok single line: '36206465076'

Test #59:

score: 33
Accepted
time: 1ms
memory: 4988kb

input:

40 5
24 615571454
24 335194138
24 524152280
24 870549924
24 256269835
24 505451503
24 794555132
24 627639447
24 854459108
24 600772752
24 204618462
24 586213748
24 730253837
24 895096691
24 108800262
24 802392995
24 892254633
24 750987219
24 249701195
24 366844201
24 471890316
24 278282690
24 986241...

output:

3900

result:

ok single line: '3900'

Test #60:

score: 33
Accepted
time: 1ms
memory: 4988kb

input:

40 32
40 996797796
40 592358781
40 603851912
40 679989936
40 899949930
40 916795808
40 797670897
40 674069551
40 656215435
40 666817637
40 663956165
40 588439879
40 521795122
40 590395520
40 780868144
40 956998722
40 776530006
40 621569649
40 694190301
40 786991921
40 571657644
40 711117000
40 67737...

output:

24960

result:

ok single line: '24960'

Test #61:

score: 33
Accepted
time: 2ms
memory: 5052kb

input:

40 87823983
8 800623384
3 978315302
5 907771877
6 875197995
4 979257882
0 981730121
7 928229656
7 877723481
0 992406401
7 901758989
4 956513810
5 939739074
7 812911471
7 837275945
1 976411864
5 905584852
4 943240793
8 903423450
7 855489781
5 972922876
6 960114042
4 986715108
6 999502288
3 951322491
...

output:

5274686165

result:

ok single line: '5274686165'

Test #62:

score: 33
Accepted
time: 2ms
memory: 5024kb

input:

40 182
0 26208
0 24752
1 19656
0 22568
3 6552
0 23296
3 728
1 21840
2 8736
2 10192
2 9464
1 16016
2 11648
3 4368
0 26936
3 3640
2 13832
0 25480
2 14560
1 16744
3 5096
3 7280
2 10920
1 17472
1 15288
0 27664
3 1456
1 18928
1 20384
2 8008
0 24024
1 21112
3 2912
3 5824
1 18200
2 13104
0 29120
3 2184
2 1...

output:

30940

result:

ok single line: '30940'

Test #63:

score: 33
Accepted
time: 0ms
memory: 4976kb

input:

40 161
4 21896
4 25760
1 42504
0 48944
4 24472
5 19320
2 38640
0 47656
2 34776
1 41216
0 51520
7 5152
2 37352
6 10304
1 43792
5 14168
3 28336
7 3864
5 15456
2 33488
5 18032
3 29624
5 16744
7 1288
3 27048
1 39928
6 12880
1 45080
3 30912
7 6440
7 2576
4 23184
4 20608
6 7728
0 50232
6 9016
6 11592
2 36...

output:

39928

result:

ok single line: '39928'

Test #64:

score: 33
Accepted
time: 2ms
memory: 5080kb

input:

40 187
5 51612
1 78540
9 22440
8 26928
6 40392
3 60588
0 87516
11 4488
7 33660
6 38148
10 11220
4 56100
11 6732
9 17952
1 76296
4 58344
0 89760
7 35904
10 8976
5 49368
9 15708
2 74052
8 24684
4 53856
6 44880
8 29172
3 62832
1 80784
0 83028
3 65076
9 20196
7 31416
6 42636
2 71808
3 67320
5 47124
11 2...

output:

55726

result:

ok single line: '55726'

Test #65:

score: 33
Accepted
time: 0ms
memory: 5028kb

input:

40 100000
13 2806040
18 306699
8 7825610
10 5505511
20 1016
17 604060
10 5509977
12 3614670
9 6618564
16 1003260
8 7829146
15 1508442
4 13617068
19 102230
6 10536240
5 12038800
17 601864
1 19034660
13 2801936
5 12033616
7 9129988
7 9103976
19 103736
4 13608415
6 10523550
1 19033680
18 300711
20 1470...

output:

21000076

result:

ok single line: '21000076'

Test #66:

score: 33
Accepted
time: 0ms
memory: 5024kb

input:

40 100000
1 19031780
12 3615903
2 17134770
9 6602808
14 2115344
6 10533720
4 13615623
19 104776
12 3603456
3 15315570
7 9101652
11 4511570
17 604464
13 2806304
2 17144745
13 2812128
3 15319206
20 1656
8 7800728
16 1003520
16 1000505
5 12001040
19 103780
15 1503204
11 4520630
18 302757
10 5500462
8 7...

output:

21000924

result:

ok single line: '21000924'

Test #67:

score: 33
Accepted
time: 3ms
memory: 4976kb

input:

40 100000
12 3609909
16 1000585
14 2101841
10 5502420
1 19031020
18 307071
6 10533495
2 17136556
9 6609600
12 3603474
20 468
19 102456
19 100684
18 301797
1 19033060
11 4523200
2 17141914
13 2810608
8 7827274
15 1503870
14 2116884
5 12014672
8 7815600
7 9105810
3 15309090
4 13631127
16 1010150
3 153...

output:

21000700

result:

ok single line: '21000700'

Subtask #5:

score: 27
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #68:

score: 27
Accepted
time: 40ms
memory: 5064kb

input:

300 205990967
288 725913461
70 793829139
58 974079315
85 838121943
4 916535584
245 912604548
211 853719954
39 933109227
108 728635978
274 877560834
181 962262372
185 732797812
172 805442869
125 809276446
154 759264769
267 891201102
145 951771770
224 746681811
138 837723232
1 926546556
272 904823557
...

output:

2473371129

result:

ok single line: '2473371129'

Test #69:

score: 27
Accepted
time: 42ms
memory: 4932kb

input:

300 7535
129 741389303
141 605785259
134 733652280
36 649567538
175 863648541
118 911425086
204 833058635
202 600876081
161 943883883
10 631702797
223 895961836
138 771340572
271 648396273
114 884736938
229 905778171
79 875660863
267 995269535
222 945323593
267 858085698
47 851437205
231 575730719
2...

output:

21098000

result:

ok single line: '21098000'

Test #70:

score: 27
Accepted
time: 38ms
memory: 5092kb

input:

300 274094232
243 381074819
15 992625070
118 503950852
235 377403063
6 987281382
216 293763358
197 665688609
229 383422773
26 913438087
245 427992236
112 516392754
251 808263532
97 891225961
245 393682569
297 224700861
236 868605559
29 970884466
57 800913205
64 926172235
174 719759964
263 414239844
...

output:

2496077992

result:

ok single line: '2496077992'

Test #71:

score: 27
Accepted
time: 43ms
memory: 5208kb

input:

300 2967367
282 148340596
57 900691181
72 901502619
69 869545340
21 999424007
207 857716342
75 946661868
230 716402839
297 243458725
26 998872934
149 938447381
221 255515282
256 994366341
126 625510205
90 844235685
48 953106805
113 663873216
71 791148015
16 993937053
64 990413493
241 278898074
120 6...

output:

1159798435

result:

ok single line: '1159798435'

Test #72:

score: 27
Accepted
time: 36ms
memory: 5024kb

input:

300 859203554
166 676377693
241 603619806
215 945676508
48 953753578
61 810938561
56 854437236
195 393702512
237 959987158
251 207715001
88 855717393
291 55420657
15 976786391
193 724938720
46 888954475
20 981686508
31 960462970
294 49362006
47 964337883
55 947965487
62 810890452
285 496018177
230 1...

output:

3835042200

result:

ok single line: '3835042200'

Test #73:

score: 27
Accepted
time: 44ms
memory: 5032kb

input:

300 30730025
184 982238248
275 97367864
115 590353043
191 318279845
137 788362128
45 846776049
103 648315585
147 731095070
108 957930128
87 705771062
95 688484791
106 699606432
3 992852784
260 131331748
277 144054267
214 600919192
181 758752131
153 955816988
207 636158059
184 351571254
89 912272889
...

output:

1548197547

result:

ok single line: '1548197547'

Test #74:

score: 27
Accepted
time: 43ms
memory: 4996kb

input:

300 782757990
36 900789376
40 866010011
191 828827375
154 486286303
279 111758742
169 704366821
114 631027987
132 565524461
217 294374117
244 201819153
142 518569680
169 451952330
116 628183512
128 688805144
275 122613304
120 618989927
131 567084796
159 478389352
86 740606855
60 803745286
63 8316523...

output:

2551293097

result:

ok single line: '2551293097'

Test #75:

score: 27
Accepted
time: 44ms
memory: 4988kb

input:

300 100199
128 564471785
252 211465950
167 452526350
147 520603730
72 703944156
205 294722899
57 749817739
184 362420280
180 398777336
300 3464693
149 513268186
103 643343755
219 260767569
252 168219359
165 458826696
245 682833569
38 807296740
104 634412528
278 68418948
84 686398332
196 500297511
20...

output:

93986662

result:

ok single line: '93986662'

Test #76:

score: 27
Accepted
time: 39ms
memory: 5088kb

input:

300 583095488
114 659520453
249 197343497
41 893108741
66 802956142
34 912406758
131 577946021
298 4561333
5 982328336
213 305979407
22 932984264
157 506466401
12 964119712
63 818933653
42 889844150
192 375286021
36 905353906
123 595766648
255 168351147
248 198344553
109 692257065
162 495376729
177 ...

output:

0

result:

ok single line: '0'

Test #77:

score: 27
Accepted
time: 39ms
memory: 5048kb

input:

300 57207
250 147065861
168 450072326
97 626302834
191 335466045
7 972575472
167 450183861
151 486068990
64 752015385
126 529620148
53 795683641
145 500345220
255 126393621
100 614827244
140 504973111
124 534611266
195 322275693
190 338553965
289 29962062
216 241074693
108 596406110
98 625265421
128...

output:

0

result:

ok single line: '0'

Test #78:

score: 27
Accepted
time: 43ms
memory: 5096kb

input:

300 255669
221 24605
189 4121468
159 830060106
135 56831818
28 885245058
201 1416190
119 94844615
242 389351797
101 516085072
50 813898848
43 940872935
96 540032862
15 960256681
130 923082761
166 16010058
167 15773076
114 108076652
190 3739404
90 553621875
67 703122095
162 18206786
156 26101965
278 ...

output:

322441546

result:

ok single line: '322441546'

Test #79:

score: 27
Accepted
time: 45ms
memory: 5100kb

input:

300 30
79 724085520
143 2503828
7 987408757
7 979872743
222 414671534
82 590490032
127 8754402
120 865882891
7 990898316
125 172799091
177 356534826
7 967290527
122 11910627
178 549247619
71 774531289
98 949351881
30 851654263
218 88
32 831138786
12 969547031
151 1899016
68 928444887
197 103234
97 5...

output:

148630

result:

ok single line: '148630'

Test #80:

score: 27
Accepted
time: 38ms
memory: 5264kb

input:

300 4771
165 13914
259 712362590
51 765450805
186 1766
86 888666131
185 1876
107 6111345
254 757268040
58 706866005
211 57
133 332986
46 756841710
209 80
77 802793339
253 190080689
65 753342392
167 752491901
141 194052
274 70818985
127 637768421
256 437534639
171 8293
110 5199597
295 215765129
73 62...

output:

9194506

result:

ok single line: '9194506'

Test #81:

score: 27
Accepted
time: 2ms
memory: 4992kb

input:

300 261495
300 442863797
300 558620718
300 467833882
300 918060280
300 514173404
300 938826137
300 433462170
300 616556980
300 979526936
300 945706953
300 644963816
300 956980410
300 394752253
300 581616174
300 554736865
300 341364222
300 406003147
300 603393259
300 901833067
300 410484309
300 46557...

output:

287731250

result:

ok single line: '287731250'

Test #82:

score: 27
Accepted
time: 2ms
memory: 4960kb

input:

300 1000000000
300 509799684
300 916803893
300 70424055
300 754001790
300 613021187
300 218719869
0 1000000000
300 36905447
300 438899840
300 922645194
300 61565629
300 401199094
300 419905157
300 388845945
300 382606654
300 613465886
300 699672059
300 380637451
300 373165836
300 752879810
300 65530...

output:

298000000000

result:

ok single line: '298000000000'

Test #83:

score: 27
Accepted
time: 2ms
memory: 5096kb

input:

300 15099909
233 470359764
233 672758505
233 338130059
233 688698764
233 825958228
233 19875374
233 654804305
233 776867427
233 59362004
233 873738232
233 520545182
233 97188098
233 217532077
233 344876933
233 18983556
233 403962847
233 856280354
233 182070874
233 573431032
233 20415654
233 28940228...

output:

5845836449

result:

ok single line: '5845836449'

Test #84:

score: 27
Accepted
time: 2ms
memory: 5236kb

input:

300 8
202 715991116
202 871731414
202 792401004
202 140042608
202 989879124
202 179426707
202 721813356
202 676403422
202 644209215
202 413970887
202 642640490
202 441301341
202 180501128
202 336134413
202 389976000
202 552236993
202 823386294
202 594210811
202 110306740
202 504021094
202 751464596
...

output:

358800

result:

ok single line: '358800'

Test #85:

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

input:

300 91
300 948869843
300 879237535
300 515549831
300 630054644
300 834388436
300 614468079
300 643449165
300 795903523
300 500448656
300 925363634
300 644912334
300 708841440
300 748715462
300 769190651
300 786229380
300 952784947
300 599726204
300 766970696
300 935563106
300 987224171
300 969759005...

output:

4081350

result:

ok single line: '4081350'

Test #86:

score: 27
Accepted
time: 5ms
memory: 5164kb

input:

300 58610902
9 988964272
18 964700526
23 976865008
11 968974788
11 980325787
7 987023126
17 992835354
20 953395076
10 975459664
18 961986285
17 953742883
12 953883691
14 994502727
9 980045985
15 962792704
21 938143597
23 950900761
13 997736183
8 994883877
11 954700432
5 997099923
16 948638349
19 973...

output:

19539986344

result:

ok single line: '19539986344'

Test #87:

score: 27
Accepted
time: 3ms
memory: 5236kb

input:

300 186
27 117180
1 1595880
28 66960
0 1640520
21 463140
10 1071360
2 1551240
13 920700
12 982080
14 864900
4 1445220
0 1657260
29 11160
26 206460
4 1428480
4 1406160
4 1411740
2 1528920
25 279000
4 1400580
26 200880
6 1294560
3 1489860
10 1099260
26 184140
27 133920
16 781200
27 167400
25 256680
27...

output:

1137018

result:

ok single line: '1137018'

Test #88:

score: 27
Accepted
time: 10ms
memory: 5164kb

input:

300 107
42 577800
23 1174860
46 436560
56 128400
1 1868220
6 1714140
28 1014360
57 70620
55 134820
21 1239060
25 1123500
10 1585740
28 1007940
53 218280
48 365940
33 841020
9 1630680
10 1579320
58 38520
51 276060
5 1746240
9 1624260
59 12840
55 141240
33 866700
36 763980
17 1380300
45 462240
16 1399...

output:

1045390

result:

ok single line: '1045390'

Test #89:

score: 27
Accepted
time: 15ms
memory: 4992kb

input:

300 135
21 2782350
87 97200
39 2053350
57 1336500
10 3219750
55 1385100
33 2272050
75 595350
88 60750
46 1761750
76 546750
22 2721600
70 801900
47 1725300
60 1202850
50 1591650
5 3438450
24 2660850
63 1057050
8 3304800
73 668250
31 2357100
13 3110400
47 1713150
0 3608550
7 3341250
13 3086100
32 2332...

output:

1648215

result:

ok single line: '1648215'

Test #90:

score: 27
Accepted
time: 3ms
memory: 5072kb

input:

288 96
141 1000000000
208 1000000000
141 1000000000
294 1000000000
294 1000000000
141 1000000000
141 1000000000
116 1000000000
208 1000000000
294 1000000000
294 1000000000
294 1000000000
208 1000000000
208 1000000000
294 1000000000
294 1000000000
294 1000000000
208 1000000000
141 1000000000
208 1000...

output:

34311

result:

ok single line: '34311'

Subtask #6:

score: 14
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #91:

score: 14
Accepted
time: 121ms
memory: 5108kb

input:

300 494556201
810485125 438070239
66213405 134393910
674094868 178072620
607727580 911993802
714614339 147346632
164241277 908327413
806149331 663416074
568510676 287718865
287786049 373911058
385093094 502483086
923075937 676334400
827443857 796808835
563102759 81357216
756573084 724653619
57524901...

output:

0

result:

ok single line: '0'

Test #92:

score: 14
Accepted
time: 123ms
memory: 5068kb

input:

300 51912244
453205096 509694487
688926981 668267707
653493410 74442931
471387206 496855361
230036149 574388025
378883249 973680244
522789600 889847081
120779673 592927794
144322861 484543944
645369099 904438482
960077573 467430453
56329433 644322668
41498737 488380292
433747554 784959531
412759643 ...

output:

0

result:

ok single line: '0'

Test #93:

score: 14
Accepted
time: 126ms
memory: 5104kb

input:

300 80508843
100932718 770553703
892773292 398931259
815278464 83376953
284453992 657779240
820944975 540782389
860120664 907285802
274084360 275186084
160870892 9450598
600970468 52459038
475417207 237926404
420325480 657517195
520656398 635113071
916930953 532053491
472835763 545434656
46558796 67...

output:

0

result:

ok single line: '0'

Test #94:

score: 14
Accepted
time: 119ms
memory: 5056kb

input:

300 264401705
652469608 888378514
343200399 689880698
815334105 644563232
523218392 580284132
24324045 985382019
825911129 591375152
305292025 880227372
129716033 644026951
446810938 907003277
157384585 898336427
313599122 670561371
991465145 998727932
712865000 867410423
741300829 684987065
9348586...

output:

0

result:

ok single line: '0'

Test #95:

score: 14
Accepted
time: 120ms
memory: 5108kb

input:

300 12450138
418648542 918025456
30949863 729327069
510535543 707785862
185189674 960073679
255173778 803459127
128065034 848704459
396453956 884727422
379317063 762116645
957853820 678378770
831622167 674173331
151976215 627526783
106804258 820217602
791429387 605854615
86129231 983056747
352652865...

output:

0

result:

ok single line: '0'

Test #96:

score: 14
Accepted
time: 121ms
memory: 5024kb

input:

300 584292266
887557127 693186654
713700329 177406757
459146320 431657296
32081505 124564714
15070332 459248884
86659181 284767759
117148151 996874611
381402184 922630705
15070297 619156559
392465629 384461048
872820695 711181666
135252794 67739107
871679869 743043531
32081399 382408468
898725005 73...

output:

0

result:

ok single line: '0'

Test #97:

score: 14
Accepted
time: 117ms
memory: 5132kb

input:

300 48273108
30586151 491608541
849463711 385296111
682654984 678414588
48834769 122356109
915727500 857575254
295965341 974423236
139555709 699744348
623033170 895703799
30586152 481014011
41945717 358896087
237572988 950616129
600784961 140763912
626150833 168008165
905635004 271279553
537278363 7...

output:

0

result:

ok single line: '0'

Test #98:

score: 14
Accepted
time: 119ms
memory: 5288kb

input:

300 712798184
814392630 593526202
128506808 736002324
43589100 506078170
62407832 65768277
58491566 399121655
3037960 949530110
62407700 340069403
906069184 723183243
62407671 360617247
348194741 206769880
968486972 240870736
3037978 932712710
789466175 389457437
10471705 720939537
428600074 2033761...

output:

0

result:

ok single line: '0'

Test #99:

score: 14
Accepted
time: 120ms
memory: 5288kb

input:

300 2968874
26874893 431748629
300053022 186287475
629971858 826365538
43507377 151881626
31127491 363895353
46067304 56995725
35752446 238850420
71093384 865914025
24025066 636623503
22060520 746416317
35752349 344128195
24025244 444809922
24025100 600753414
177934190 776011012
529441233 486429185
...

output:

0

result:

ok single line: '0'

Test #100:

score: 14
Accepted
time: 114ms
memory: 5248kb

input:

300 918466842
893627679 229146794
5293853 816011579
49806266 417549487
36092756 636449231
269919881 798102099
55722311 393865839
42349505 458497726
55722360 366209682
71439642 313663768
71439677 274892472
55722371 344653490
75875732 129111623
36092817 586318442
18977529 744867192
2076323 901324488
1...

output:

0

result:

ok single line: '0'

Test #101:

score: 14
Accepted
time: 118ms
memory: 5232kb

input:

300 7915240
16878544 759297455
80021194 223111293
350737281 667799919
45973775 491182739
996640286 106978037
10 987133069
45973686 543633831
23939333 947458782
92926194 14226327
81719461 132968020
45973573 646648900
81719494 118470131
41390958 687827857
81719504 107854216
38936638 732012361
12185945...

output:

0

result:

ok single line: '0'

Test #102:

score: 14
Accepted
time: 110ms
memory: 5112kb

input:

300 90856922
77 975650422
67678693 381846352
24080724 593308116
8721588 719486759
77347219 161575359
8721579 727853088
52584574 430073863
77347111 264978597
41165831 537097077
50994204 485632689
50994177 496996470
113789470 69934690
4486799 806463784
21977614 615238531
17079110 628851827
77347204 17...

output:

0

result:

ok single line: '0'

Test #103:

score: 14
Accepted
time: 108ms
memory: 5028kb

input:

300 1
108439887 287430645
121320622 158595803
142096691 46929708
108440020 221357611
39159789 815143030
103833888 345900457
103833925 315571791
147369673 1295340
95249474 403117825
124210870 129628514
113200676 201165545
22534250 848158696
50530943 691056634
108440011 221409939
39159810 780366512
82...

output:

0

result:

ok single line: '0'

Test #104:

score: 14
Accepted
time: 2ms
memory: 5012kb

input:

300 392816
1000000000 697884456
1000000000 139306567
1000000000 958246960
1000000000 793472756
1000000000 232476874
1000000000 890239339
1000000000 235437643
1000000000 897071531
1000000000 409763316
1000000000 444194721
1000000000 928780473
1000000000 325942109
1000000000 605503673
1000000000 85824...

output:

472723296

result:

ok single line: '472723296'

Test #105:

score: 14
Accepted
time: 2ms
memory: 5224kb

input:

300 1000000000
1000000000 646174442
1000000000 492043649
1000000000 414415499
1000000000 362690896
1000000000 593380386
1000000000 986538758
1000000000 316984443
1000000000 520294998
1000000000 878125339
1000000000 161756320
1000000000 305381329
1000000000 402593120
1000000000 121132522
1000000000 9...

output:

298000000000

result:

ok single line: '298000000000'

Test #106:

score: 14
Accepted
time: 2ms
memory: 4996kb

input:

300 446534219
634283423 137403800
634283423 333014165
634283423 844123496
634283423 12872386
634283423 69819650
634283423 890289066
634283423 125496738
634283423 314441552
634283423 207564343
634283423 818672710
634283423 861650035
634283423 470883538
634283423 993711014
634283423 976593150
63428342...

output:

135075050927

result:

ok single line: '135075050927'

Test #107:

score: 14
Accepted
time: 2ms
memory: 4996kb

input:

300 4
829851851 574692476
829851851 355202944
829851851 655896228
829851851 265277232
829851851 365787768
829851851 123242366
829851851 739477001
829851851 470671145
829851851 120415546
829851851 459952718
829851851 415307665
829851851 724709691
829851851 163584455
829851851 292275016
829851851 3810...

output:

179400

result:

ok single line: '179400'

Test #108:

score: 14
Accepted
time: 22ms
memory: 5012kb

input:

300 120
10 709200
25 172800
404263961 586800
29 10800
11 676800
3 943200
10 712800
15 518400
13 604800
25 154800
11 684000
21 324000
15 511200
28 50400
23 219600
25 165600
8 777600
7 799200
21 291600
4 925200
456362687 252000
7 810000
26 140400
11 666000
80955353 43200
14 565200
20 360000
24 194400
...

output:

669960

result:

ok single line: '669960'

Test #109:

score: 14
Accepted
time: 26ms
memory: 5076kb

input:

300 167
23 1823640
48 591180
319068977 2414820
17 2154300
6 2695380
5 2745480
9 2545080
10 2474940
57 140280
26 1693380
26 1703400
20 1993980
55 230460
54 260520
33 1312620
4 2765520
53 340680
48 601200
4 2785560
32 1372740
59 10020
19 2024040
18 2074140
7 2615220
48 571140
49 541080
28 1593180
25 1...

output:

1469433

result:

ok single line: '1469433'

Test #110:

score: 14
Accepted
time: 31ms
memory: 5016kb

input:

300 178
56 1778220
47 2258820
29 3252060
51 2034540
64 1377720
31 3139920
6 4469580
62 1473840
88 80100
48 2242800
34 2947680
34 2979720
7 4389480
47 2274840
80 496620
724913358 2563200
79 576720
70 1025280
751884509 4645800
66 1233540
49 2162700
27 3364200
34 2963700
74 849060
83 352440
40 2659320
...

output:

1913500

result:

ok single line: '1913500'

Test #111:

score: 14
Accepted
time: 3ms
memory: 5064kb

input:

288 64
343393589 1000000000
796917685 1000000000
796917685 1000000000
796917685 1000000000
796917685 1000000000
192516107 1000000000
343393589 1000000000
796917685 1000000000
343393589 1000000000
192516107 1000000000
796917685 1000000000
796917685 1000000000
796917685 1000000000
192516107 1000000000...

output:

22887

result:

ok single line: '22887'

Extra Test:

score: 0
Extra Test Passed