Record Case Detail

Notes

This function is in beta test. Please help improve it in the issues here.

Stderr


        

Hints

Your answer may be identical to the JOJ answer in the first several lines.

However, the main problem you meet now is Time Exceeded. And the exit code of your program is -9, which should be 0.

Please double check your code to solve this problem and try again.

Your Answer

347
1199
396
322
66
42
866
110
360
882
738
636
297
180
358
243
657
319
272
269
301
403
716
491
449
202
338
76
1006
68
542
390
392
82
206
272
297
295
-1
477
233
108
764
443
447
223
415
216
307
481
482
599
528
225
44
237
73
255
160
239
469
884
118
282
128
179
658
159
783
262
79
418
593
4
579
532
431
635
566
350
87
596
259
533
79
375
445
265
419
289
382
-8
232
180
740
220
638
817
138
557
345
746
341
-6
165
200
293
439
149
284
507
484
258
77
65
518
271
394
291
239
332
115
155
114
424
289
348
366
856
386
160
12
340
275
594
492
627
396
658
71
208
250
423
532
327
182
538
572
104
630
221
304
851
520
269
293
339
146
167
252
789
697
179
626
99
446
808
457
124
128
131
709
234
405
458
88
285
1027
220
181
222
482
104
508
340
157
662
47
616
281
93
556
472
39
74
632
709
673
568
314
256
332
94
92
86
596
143
222
12
3
174
640
357
330
464
475
172
268
466
71
137
331
1075
249
592
-9

JOJ Answer

245
237
326
152
62
42
77
110
49
518
97
223
115
180
114
80
198
319
44
28
111
57
52
126
101
94
85
76
90
68
150
139
49
82
206
272
213
96
-1
180
21
78
105
199
154
36
98
174
161
44
158
244
345
101
38
12
73
187
81
90
239
264
118
86
128
154
454
112
163
91
79
147
213
4
121
223
86
331
58
308
87
131
240
239
60
65
70
171
71
85
121
-8
232
169
126
64
169
96
138
171
250
137
130
-6
86
141
134
32
28
65
242
241
189
77
18
101
22
15
91
179
183
115
155
101
144
289
280
108
103
113
25
12
85
7
252
95
118
79
321
71
99
72
247
7
58
49
109
182
75
134
183
304
167
71
183
179
188
68
83
131
33
100
154
287
81
49
193
52
-9
104
131
70
140
297
338
88
99
55
54
86
145
93
81
170
172
13
167
32
128
110
84
114
250
19
74
165
207
144
424
159
140
51
71
92
86
145
50
192
12
3
72
160
167
186
125
196
40
72
297
33
121
286
262
93
233
-9
288
148
100
127
154
30
91
25
166
13
176
21
67
81
112
79
113
85
66
497
-2
148
-10
40
183
94
136
120
494
24
280
156
35
140
180
65
1
-9
106
7
132
31
125
-14
136
58
191
34
-10
33
14
71
27
185
224
98
112
140
156
128
112
74
48
161