QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#139717#6774. Ancient Machine 2NOI_AK_ME#100 ✓35ms4752kbC++204.3kb2023-08-14 12:07:272024-07-04 01:41:54

Judging History

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

  • [2024-07-04 01:41:54]
  • 评测
  • 测评结果:100
  • 用时:35ms
  • 内存:4752kb
  • [2023-08-14 12:07:27]
  • 提交

answer

#include <bits/stdc++.h>
#include "ancient2.h"
using namespace std;
int Query(int m, std::vector<int> a, std::vector<int> b);
#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define Debug(...) fprintf(stderr,__VA_ARGS__)
const int N = 1e3 + 7, M = 1e2 + 2, L = 1e2 + 7;
typedef long long ll;
typedef vector<int> vi;
typedef bitset<N> bit;

int n, m;
vi a, b;
string str;


struct Basis {
    vector<pair<int, bit>>S;
    bool ins(bit cur) {
        for (auto &[ft, bt] : S)
            if (cur.test(ft))
                cur ^= bt;

        if (cur.any())
            return S.eb(cur._Find_first(), cur), 1;
        else
            return 0;
    }
    int size() {
        return S.size();
    }
};

vector<tuple<int, int, bit>>buc[L], qmd;
vector<pair<int, bit>>qft, qbk;

vector<bit>mar;

string Solve(int _n) {
    n = _n;
    auto getmd = [&]() {
        bit sit;
        rep(x, 1, M >> 1)rep(r, 0, x - 1) {
            rep(i, 0, n - 1)sit.set(i, i % x == r);
            buc[2 * x].eb(x, r, sit);
        }
    };
    auto getft = [&]() {
        bit sit;
        rep(i, 0, M - 3) {
            rep(j, 0, n - 1)sit.set(j, j == i);
            buc[i + 3].eb(-1, i, sit);
        }
    };
    auto getbk = [&]() {
        bit sit;
        rep(i, 0, M - 2) {
            rep(j, 0, n - 1)sit.set(j, j == (n - 1 - i));
            buc[i + 2].eb(-2, i, sit);
        }
    };
    auto merge = [&]() {
        Basis tmp;

        rep(i, 1, M)for (auto &[x, r, s] : buc[i]) {
            if (tmp.size() == n)
                break;

            if (tmp.ins(s)) {
                // Debug("%d %d ",x,r);
                // for(int j=0;j<n;j++)Debug("%d",s.test(j));
                // Debug("\n");
                if (x == -1)
                    qft.eb(r, s);
                else if (x == -2)
                    qbk.eb(r, s);
                else
                    qmd.eb(x, r, s);
            }
        }
    };
    getft(), getmd(), getbk(), merge();


    auto qryft = [&]() {
        auto loop = [&](int i) {
            a[i] = i, b[i] = i;
        };

        for (auto &[p, s] : qft) {
            m = p + 3;
            a.resize(m), b.resize(m);
            rep(j, 0, p - 1)a[j] = b[j] = j + 1;
            a[p] = p + 1, b[p] = p + 2;
            loop(p + 1), loop(p + 2);
            auto cur = s;
            cur.set(n, Query(m, a, b) == p + 2);
            mar.eb(cur);
        }
    };
    auto qrybk = [&]() {
        vi res;

        for (auto &[p, s] : qbk) {
            res.insert(res.begin(), 0);
            m = p + 2;
            a.resize(m), b.resize(m);
            auto get = [&](int v, int _p, int i) {
                auto cur = vi(res.begin(), res.begin() + i);
                cur.push_back(v);
                per(j, min(_p + 1, i + 1), 1)

                if (vi(cur.end() - j, cur.end()) == vi(res.begin(), res.begin() + j))
                    return j;

                return 0;
            };
            rep(i, 0, p + 1)a[i] = get(0, p, i), b[i] = get(1, p, i);
            auto cur = s;
            cur.set(n, (res[0] = (Query(m, a, b) != p + 1)));
            mar.eb(cur);
        }
    };
    auto qrymd = [&]() {
        for (auto &[x, r, s] : qmd) {
            m = 2 * x;
            a.resize(m), b.resize(m);
            rep(j, 0, x - 1)a[j] = b[j] = (j + 1) % x, a[j + x] = b[j + x] = (j + 1) % x + x;
            swap(b[r], b[r + x]);
            auto cur = s;
            cur.set(n, Query(m, a, b) >= x);
            mar.eb(cur);
        }
    };
    auto solve = [&]() {
        rep(i, 0, n - 1) {
            int k = -1;

            rep(j, i, n - 1)if (mar[j].test(i)) {
                k = j;
                break;
            }

            // Debug("%d\n",k);
            swap(mar[i], mar[k]);

            rep(j, 0, n - 1)if (j != i && mar[j].test(i))
                mar[j] ^= mar[i];
        }
        str.resize(n);
        rep(i, 0, n - 1)str[i] = mar[i].test(n) + '0';
        // Debug("%s\n",str.c_str());
    };


    qryft(), qrymd(), qrybk();
    solve();
    // for(auto bt:mar){for(int j=0;j<n;j++)Debug("%d",bt.test(j));Debug(" %d\n",bt.test(n));}

    return str;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 100
Accepted

Test #1:

score: 100
Accepted
time: 34ms
memory: 4444kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
14
16
16
18
18
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
39
40
41
42
43
44
45
46
47
48
50
51
52
53
53
55
55
57
57
59
59
61
61
62
64
64
65
66
67
68
69
70
71
72
74
75
76
77
78
79
79
80
81
82
83
84
85
86
87
89
89
90
91
92
93
94
95
97
98
99
100
100
1...

output:

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

result:

ok Accepted

Test #2:

score: 100
Accepted
time: 30ms
memory: 4392kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
28
29
30
31
32
33
34
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
54
56
56
58
58
60
60
62
62
63
64
66
67
68
69
70
71
72
73
74
75
76
77
78
79
79
81
81
83
83
84
85
86
87
88
89
90
91
92
93
95
96
97
97
98
99
100
0
...

output:

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

result:

ok Accepted

Test #3:

score: 100
Accepted
time: 28ms
memory: 4680kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
1
0...

output:

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

result:

ok Accepted

Test #4:

score: 100
Accepted
time: 21ms
memory: 4444kb

input:

1000
2
2
4
4
6
6
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
29
31
31
33
33
35
35
37
37
39
39
41
41
43
43
45
45
47
47
49
49
51
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
98
99
100
101
0...

output:

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

result:

ok Accepted

Test #5:

score: 100
Accepted
time: 25ms
memory: 4676kb

input:

1000
2
2
4
4
6
6
8
8
10
10
12
12
14
14
16
16
18
18
20
20
22
22
24
24
26
26
28
28
30
30
32
32
34
34
36
36
38
38
40
41
41
43
43
45
45
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
0...

output:

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

result:

ok Accepted

Test #6:

score: 100
Accepted
time: 25ms
memory: 4420kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
0
2...

output:

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

result:

ok Accepted

Test #7:

score: 100
Accepted
time: 23ms
memory: 4380kb

input:

1000
2
3
4
5
6
6
8
8
10
10
12
12
14
14
16
16
18
18
20
20
22
22
24
24
26
26
28
28
30
30
32
32
34
34
36
36
38
38
40
40
42
42
44
44
46
46
48
48
50
50
52
52
54
54
56
56
58
58
60
60
62
62
64
64
66
66
68
68
70
70
72
72
74
74
76
76
78
78
80
80
82
82
84
84
86
86
88
88
90
90
92
92
94
94
96
96
98
98
100
100
0...

output:

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

result:

ok Accepted

Test #8:

score: 100
Accepted
time: 27ms
memory: 4380kb

input:

1000
2
2
4
4
6
6
8
8
10
10
12
12
14
14
16
16
18
18
20
20
22
22
24
24
26
26
28
28
30
30
32
32
34
34
36
36
38
38
40
40
42
42
44
44
46
46
48
48
50
50
52
52
54
54
56
56
58
58
60
60
62
62
64
64
66
66
68
68
70
70
72
72
74
74
76
76
78
78
80
80
82
82
84
84
86
86
88
88
90
90
92
92
94
94
96
96
98
98
100
100
1...

output:

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

result:

ok Accepted

Test #9:

score: 100
Accepted
time: 28ms
memory: 4420kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
1
0...

output:

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

result:

ok Accepted

Test #10:

score: 100
Accepted
time: 31ms
memory: 4436kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
0...

output:

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

result:

ok Accepted

Test #11:

score: 100
Accepted
time: 26ms
memory: 4676kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
0
0...

output:

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

result:

ok Accepted

Test #12:

score: 100
Accepted
time: 25ms
memory: 4500kb

input:

1000
2
3
4
5
6
7
8
9
10
11
11
13
14
15
16
16
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
47
49
50
51
52
52
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
100
0...

output:

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

result:

ok Accepted

Test #13:

score: 100
Accepted
time: 27ms
memory: 4448kb

input:

1000
1
2
3
4
5
6
8
8
9
10
11
12
13
14
16
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
38
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
57
57
58
59
60
61
63
63
64
65
66
67
68
69
70
71
73
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
91
92
92
94
94
95
96
97
98
99
100
0
2...

output:

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

result:

ok Accepted

Test #14:

score: 100
Accepted
time: 31ms
memory: 4416kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
16
18
19
20
21
22
23
23
25
26
27
28
29
30
31
32
33
33
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
55
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
77
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
1...

output:

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

result:

ok Accepted

Test #15:

score: 100
Accepted
time: 26ms
memory: 4448kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
65
66
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
87
87
88
89
90
91
92
93
94
95
96
97
98
99
100
1
0...

output:

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

result:

ok Accepted

Test #16:

score: 100
Accepted
time: 26ms
memory: 4380kb

input:

1000
2
2
4
4
6
6
8
8
10
10
12
12
14
14
16
16
18
18
20
20
22
22
24
24
26
26
28
28
30
30
32
32
34
34
36
36
38
38
40
40
42
42
44
44
46
46
48
48
50
50
52
52
54
54
56
56
58
58
60
60
62
62
64
64
66
66
68
68
70
70
72
72
74
74
76
76
78
78
80
80
82
82
84
84
86
86
88
88
90
90
92
92
94
94
96
96
98
98
100
100
0...

output:

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

result:

ok Accepted

Test #17:

score: 100
Accepted
time: 26ms
memory: 4416kb

input:

1000
1
3
3
5
5
7
7
9
9
11
11
13
13
15
15
17
17
19
19
21
21
23
23
25
25
27
27
29
29
31
31
33
33
35
35
37
37
39
39
41
41
43
43
45
45
47
47
49
49
51
51
53
53
55
55
57
57
59
59
61
61
63
63
65
65
67
67
69
69
71
71
73
73
75
75
77
77
79
79
81
81
83
83
85
85
87
87
89
89
91
91
93
93
95
95
97
97
99
99
101
0
0...

output:

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

result:

ok Accepted

Test #18:

score: 100
Accepted
time: 26ms
memory: 4512kb

input:

1000
2
2
4
4
6
6
8
8
10
10
12
12
13
14
16
16
18
18
20
20
22
22
24
24
25
26
28
28
30
30
32
32
34
34
36
37
38
38
40
40
42
42
44
44
46
46
48
48
50
50
52
52
54
54
56
56
58
58
60
60
61
62
64
64
66
66
68
68
70
70
72
72
73
74
76
76
78
79
80
80
82
82
84
84
86
86
87
88
90
91
92
92
94
94
96
96
98
98
100
100
1...

output:

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

result:

ok Accepted

Test #19:

score: 100
Accepted
time: 34ms
memory: 4732kb

input:

1000
1
3
3
5
5
7
7
9
9
11
11
13
13
15
15
17
17
19
19
21
21
23
23
25
25
27
27
29
29
31
31
33
33
35
35
37
37
38
39
41
41
43
43
45
45
47
47
49
49
50
52
53
53
55
55
57
57
59
59
61
61
63
63
65
65
67
67
69
69
71
71
73
73
75
75
77
77
79
79
80
81
83
83
84
85
87
87
89
89
91
91
93
93
95
95
97
97
99
99
101
1
0...

output:

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

result:

ok Accepted

Test #20:

score: 100
Accepted
time: 23ms
memory: 4640kb

input:

1000
2
2
4
4
6
6
8
8
10
10
12
12
14
14
16
16
18
18
20
20
22
22
24
24
26
26
28
28
30
30
32
32
34
34
36
36
38
38
40
40
42
42
44
44
46
46
48
48
50
50
52
52
54
54
56
56
58
58
60
60
62
62
64
64
66
66
68
68
70
70
72
72
74
74
76
76
78
78
80
80
82
82
84
84
86
86
88
88
90
90
92
92
94
94
96
96
98
98
100
100
0...

output:

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

result:

ok Accepted

Test #21:

score: 100
Accepted
time: 28ms
memory: 4668kb

input:

1000
1
3
3
5
5
7
7
9
9
11
11
13
13
15
15
17
17
19
19
21
21
23
23
25
25
27
27
29
29
31
31
32
33
35
35
36
37
39
39
41
41
43
43
45
45
47
47
49
49
51
51
53
53
55
55
57
57
59
59
61
61
63
63
65
65
67
67
69
69
71
71
73
73
75
75
77
77
79
79
81
82
83
83
85
85
87
87
89
89
91
91
93
93
95
95
97
97
99
99
101
1
0...

output:

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

result:

ok Accepted

Test #22:

score: 100
Accepted
time: 19ms
memory: 4736kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
53
55
56
57
57
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
77
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
1...

output:

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

result:

ok Accepted

Test #23:

score: 100
Accepted
time: 29ms
memory: 4332kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
19
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
65
65
66
67
68
69
70
72
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
92
92
94
94
95
96
97
98
99
100
1
2...

output:

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

result:

ok Accepted

Test #24:

score: 100
Accepted
time: 23ms
memory: 4444kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
30
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
73
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
93
95
96
97
98
99
100
101
0...

output:

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

result:

ok Accepted

Test #25:

score: 100
Accepted
time: 28ms
memory: 4680kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
31
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
60
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
80
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
1
0...

output:

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

result:

ok Accepted

Test #26:

score: 100
Accepted
time: 28ms
memory: 4440kb

input:

1000
1
2
3
4
5
7
8
9
9
10
12
13
13
15
16
17
18
19
20
21
22
23
23
24
25
26
28
29
30
31
32
32
33
35
36
36
37
38
40
41
42
43
44
44
46
47
48
48
49
51
51
52
53
55
55
57
58
58
60
60
61
62
64
65
66
66
68
69
69
71
72
73
74
74
76
76
77
78
79
80
81
82
83
84
85
86
87
89
89
91
91
93
93
95
96
97
97
98
99
101
1
0...

output:

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

result:

ok Accepted

Test #27:

score: 100
Accepted
time: 25ms
memory: 4444kb

input:

1000
1
2
3
4
6
7
7
8
10
10
11
12
13
14
15
17
17
19
20
21
22
23
23
25
26
27
28
29
29
30
31
32
33
35
36
37
38
39
39
40
41
43
43
45
45
47
47
48
50
51
52
52
53
55
56
57
57
58
59
61
62
62
63
65
66
67
67
69
70
71
72
73
74
75
76
76
78
79
79
81
82
83
84
84
85
87
88
89
89
91
92
93
94
94
96
97
98
98
99
101
0
...

output:

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

result:

ok Accepted

Test #28:

score: 100
Accepted
time: 30ms
memory: 4640kb

input:

1000
1
3
4
4
5
6
8
8
9
10
11
12
13
14
16
17
18
18
20
20
21
22
24
24
25
26
27
29
29
30
32
32
33
34
35
36
38
38
39
41
42
42
43
44
46
47
47
48
50
51
52
53
53
55
56
57
57
59
59
60
61
62
64
64
65
67
68
69
69
70
71
72
73
75
76
76
78
79
80
80
82
83
83
85
85
86
88
88
89
91
91
92
93
95
95
97
97
99
100
101
1
...

output:

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

result:

ok Accepted

Test #29:

score: 100
Accepted
time: 26ms
memory: 4380kb

input:

1000
1
2
4
5
6
7
7
8
10
11
12
12
14
14
16
17
18
19
19
20
21
22
23
24
26
27
28
28
29
31
32
33
34
35
35
37
38
39
40
40
41
42
44
45
45
47
48
48
49
51
51
52
54
54
56
56
58
59
60
60
62
62
64
64
65
67
67
69
70
71
71
72
74
74
76
77
77
79
79
80
81
82
83
85
86
87
88
89
89
90
91
92
94
94
96
97
98
99
99
101
0
...

output:

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

result:

ok Accepted

Test #30:

score: 100
Accepted
time: 30ms
memory: 4516kb

input:

1000
2
2
3
5
5
6
7
8
9
11
12
13
14
15
15
16
17
18
19
21
22
23
24
24
25
26
27
28
30
31
32
33
33
35
36
37
37
38
40
41
42
43
43
44
45
47
48
49
49
50
51
52
54
55
56
57
58
59
59
60
61
62
63
65
66
67
68
69
69
71
72
73
74
75
75
77
78
79
80
80
81
83
83
84
85
86
87
88
90
91
92
93
94
95
95
96
97
98
99
101
0
2...

output:

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

result:

ok Accepted

Test #31:

score: 100
Accepted
time: 19ms
memory: 4444kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
16
17
19
20
20
21
22
24
25
26
27
28
29
29
30
31
32
33
34
35
36
37
38
39
40
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
56
57
58
60
61
62
63
64
65
66
67
67
68
69
70
71
72
73
74
75
76
78
79
80
81
82
83
84
85
86
86
87
88
89
90
91
92
93
94
95
96
97
99
100
101
1...

output:

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

result:

ok Accepted

Test #32:

score: 100
Accepted
time: 28ms
memory: 4672kb

input:

1000
2
3
3
5
6
7
8
9
10
11
12
13
14
15
16
17
18
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
96
97
98
99
100
101
0...

output:

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

result:

ok Accepted

Test #33:

score: 100
Accepted
time: 25ms
memory: 4384kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
49
50
51
52
53
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
0
...

output:

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

result:

ok Accepted

Test #34:

score: 100
Accepted
time: 26ms
memory: 4640kb

input:

1000
1
2
4
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
0
...

output:

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

result:

ok Accepted

Test #35:

score: 100
Accepted
time: 35ms
memory: 4388kb

input:

1000
1
2
4
4
5
6
7
8
9
10
11
12
13
14
15
16
17
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
98
99
100
0
0...

output:

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

result:

ok Accepted

Test #36:

score: 100
Accepted
time: 27ms
memory: 4680kb

input:

1000
2
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
86
87
88
89
90
91
92
93
94
94
95
96
97
98
99
100
0
2...

output:

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

result:

ok Accepted

Test #37:

score: 100
Accepted
time: 29ms
memory: 4384kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
0...

output:

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

result:

ok Accepted

Test #38:

score: 100
Accepted
time: 23ms
memory: 4444kb

input:

1000
2
3
3
5
6
7
8
8
10
10
12
12
13
14
16
16
17
18
19
21
22
22
24
25
25
26
28
29
30
31
31
33
33
34
36
36
38
39
39
41
41
42
44
44
46
46
47
49
50
51
51
53
54
54
56
56
57
59
60
60
61
62
63
64
66
67
68
69
70
71
71
73
73
75
76
76
77
79
79
81
81
83
84
84
86
86
88
89
90
90
91
92
93
94
95
96
97
98
100
100
0...

output:

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

result:

ok Accepted

Test #39:

score: 100
Accepted
time: 25ms
memory: 4508kb

input:

1000
2
2
3
4
5
6
7
8
10
11
11
12
13
15
15
16
17
18
19
20
21
23
23
25
25
26
27
28
29
31
31
33
34
35
35
36
38
39
39
40
42
42
44
45
46
46
47
48
50
51
52
52
54
55
56
56
58
58
60
60
61
62
63
64
65
67
67
69
70
71
71
72
74
74
75
77
77
79
79
80
81
83
84
84
85
86
88
89
90
91
91
92
94
95
96
96
98
99
99
100
0
...

output:

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

result:

ok Accepted

Test #40:

score: 100
Accepted
time: 23ms
memory: 4428kb

input:

1000
2
2
3
5
6
7
7
8
10
10
12
12
13
14
16
16
17
19
19
20
22
23
24
25
26
27
28
29
30
30
31
33
33
35
36
37
37
39
40
40
42
42
43
45
45
47
48
48
50
51
52
52
53
55
56
56
58
58
59
60
62
63
64
65
66
66
68
69
70
70
71
73
74
75
75
77
78
79
80
81
82
83
84
85
86
86
88
89
89
90
92
93
93
94
96
97
98
98
99
100
0
...

output:

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

result:

ok Accepted

Test #41:

score: 100
Accepted
time: 35ms
memory: 4424kb

input:

1000
1
2
3
5
6
6
7
9
10
11
12
12
13
15
16
16
18
18
19
21
21
23
23
24
26
27
28
29
29
31
31
33
34
35
36
36
38
38
40
40
41
42
43
45
45
46
48
48
49
50
51
52
54
54
56
57
58
59
60
61
62
62
63
65
65
67
68
68
69
70
72
73
74
74
75
76
78
78
79
80
81
82
84
84
86
86
87
88
89
90
91
93
94
95
96
96
97
99
100
100
0...

output:

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

result:

ok Accepted

Test #42:

score: 100
Accepted
time: 33ms
memory: 4456kb

input:

1000
2
2
3
5
6
6
7
9
9
10
11
13
13
15
16
16
18
19
20
20
21
22
24
24
26
27
28
29
29
30
32
33
33
35
36
37
37
38
39
40
42
43
44
44
46
46
47
48
50
51
51
53
53
54
55
56
57
58
60
61
62
62
63
64
66
67
68
68
70
70
72
72
73
74
76
77
78
79
80
81
82
82
84
84
86
87
88
89
90
90
91
93
94
95
96
97
98
98
100
101
0
...

output:

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

result:

ok Accepted

Test #43:

score: 100
Accepted
time: 33ms
memory: 4444kb

input:

1000
2
3
3
4
6
7
8
8
10
10
12
13
13
14
16
17
17
19
19
21
22
22
23
24
26
27
28
28
30
31
31
33
34
35
35
36
38
38
39
41
42
43
43
44
45
46
47
48
50
50
52
53
54
54
56
57
57
59
60
60
61
62
63
65
66
67
68
68
70
70
71
73
74
75
76
76
78
79
80
80
82
83
83
84
86
87
87
89
90
91
92
93
94
95
96
96
97
98
100
100
0...

output:

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

result:

ok Accepted

Test #44:

score: 100
Accepted
time: 19ms
memory: 4440kb

input:

1000
1
2
3
5
6
6
8
9
10
11
11
12
13
14
16
17
17
19
20
21
22
23
23
24
26
27
27
29
30
31
32
32
34
35
35
37
38
38
40
40
41
42
44
44
46
47
47
48
50
51
52
52
54
55
55
56
57
58
59
61
62
62
63
64
66
66
68
69
70
71
72
72
73
74
76
77
78
78
80
81
82
82
83
85
86
87
88
89
89
90
92
92
93
95
95
96
98
98
99
100
0
...

output:

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

result:

ok Accepted

Test #45:

score: 100
Accepted
time: 26ms
memory: 4480kb

input:

1000
2
2
3
5
5
7
8
9
9
10
11
12
13
15
15
17
18
19
20
21
21
22
24
25
25
26
28
28
29
31
32
33
34
34
35
36
37
39
40
41
41
43
43
44
46
47
47
49
49
51
52
52
54
55
55
56
58
58
60
61
62
63
64
65
65
66
67
68
69
70
72
72
74
74
75
77
77
78
79
80
81
83
83
85
85
87
87
88
90
90
91
93
93
95
96
97
98
98
100
101
0
...

output:

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

result:

ok Accepted

Test #46:

score: 100
Accepted
time: 31ms
memory: 4444kb

input:

1000
2
3
3
5
5
6
7
8
9
11
12
12
13
15
16
16
18
19
20
20
22
22
24
25
25
26
28
29
29
30
32
32
34
35
35
36
37
38
39
41
41
43
44
45
45
46
48
48
50
50
52
52
53
55
55
56
57
58
59
61
62
63
63
64
65
66
68
69
70
70
72
72
74
75
75
77
78
79
79
81
82
82
83
85
85
86
88
88
90
91
91
92
94
95
95
97
97
98
100
101
1
...

output:

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

result:

ok Accepted

Test #47:

score: 100
Accepted
time: 28ms
memory: 4448kb

input:

1000
2
2
3
5
5
7
7
8
9
11
12
12
13
15
16
16
18
18
19
21
22
23
23
25
26
27
28
29
29
30
31
32
33
35
36
37
37
39
39
40
41
43
44
45
46
46
48
48
49
50
52
52
54
54
56
57
58
59
59
61
61
63
64
65
66
67
68
68
69
70
71
72
74
75
76
77
77
79
79
80
82
82
83
85
85
87
87
89
90
91
92
93
93
95
95
97
98
99
99
101
1
0...

output:

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

result:

ok Accepted

Test #48:

score: 100
Accepted
time: 31ms
memory: 4440kb

input:

1000
2
3
3
4
5
7
7
8
10
11
11
13
14
15
16
16
18
19
20
21
21
23
24
25
25
27
27
28
29
31
31
32
34
34
36
36
37
39
39
40
41
43
44
45
46
47
47
49
50
50
52
53
53
54
56
57
57
58
59
60
62
63
64
64
65
67
68
69
69
71
72
73
74
74
76
76
78
78
80
80
81
83
84
85
85
86
88
89
89
91
91
93
93
94
95
97
98
99
99
100
1
...

output:

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

result:

ok Accepted

Test #49:

score: 100
Accepted
time: 24ms
memory: 4384kb

input:

1000
1
2
3
5
5
6
8
8
10
11
12
13
14
14
15
17
17
18
19
20
22
23
23
25
25
27
28
29
29
30
31
33
34
34
36
36
38
38
40
40
42
42
43
44
46
46
48
48
49
51
51
53
54
55
55
56
58
59
60
60
61
63
64
64
65
67
67
68
70
70
72
73
74
75
76
76
78
78
80
81
81
82
84
84
85
87
87
89
89
90
92
93
94
95
95
96
98
98
100
100
1...

output:

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

result:

ok Accepted

Test #50:

score: 100
Accepted
time: 34ms
memory: 4676kb

input:

1000
1
3
3
4
5
6
7
8
10
11
11
12
14
14
15
16
17
18
20
20
21
23
24
24
26
26
28
29
30
30
31
32
33
34
35
36
37
38
39
40
42
43
44
45
46
46
47
48
50
51
51
52
54
55
56
56
58
59
60
61
62
62
63
65
66
66
67
69
69
71
71
73
74
75
76
77
77
79
80
81
81
83
84
85
85
86
87
89
90
91
92
93
93
95
96
97
98
99
99
101
0
...

output:

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

result:

ok Accepted

Test #51:

score: 100
Accepted
time: 31ms
memory: 4440kb

input:

1000
1
2
4
5
5
6
8
9
10
10
11
13
13
14
16
17
17
19
20
20
22
23
23
25
26
27
28
28
29
30
31
33
34
35
35
36
37
39
40
40
41
42
43
44
45
47
48
49
49
51
52
53
53
55
56
57
58
59
60
61
62
62
64
64
66
66
67
69
70
71
71
73
73
74
75
77
78
78
79
80
82
82
84
84
86
87
87
88
90
90
91
93
93
95
96
97
98
98
100
100
0...

output:

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

result:

ok Accepted

Test #52:

score: 100
Accepted
time: 25ms
memory: 4400kb

input:

1000
2
3
3
4
6
6
7
9
10
11
11
13
14
15
15
17
18
18
20
21
22
23
24
25
25
27
27
28
30
30
31
32
33
35
36
36
38
39
39
41
42
43
44
45
46
46
47
49
49
50
52
52
53
54
55
56
58
59
59
61
61
63
64
65
65
67
67
69
69
71
72
73
74
74
75
77
77
79
79
81
81
83
83
84
85
87
87
88
90
91
92
93
94
94
96
97
98
98
99
101
0
...

output:

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

result:

ok Accepted

Test #53:

score: 100
Accepted
time: 27ms
memory: 4448kb

input:

1000
1
2
3
5
5
6
7
9
9
11
12
12
14
15
16
17
17
18
20
20
22
23
24
25
26
27
28
29
30
30
32
32
33
35
35
36
38
38
39
40
41
43
43
44
46
47
48
49
50
51
52
53
54
54
55
56
58
58
60
60
61
63
64
65
66
66
67
68
69
71
72
72
73
74
75
76
78
79
80
80
82
83
84
84
86
86
88
88
90
90
92
93
93
95
95
97
98
98
99
100
0
0...

output:

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

result:

ok Accepted

Test #54:

score: 100
Accepted
time: 29ms
memory: 4260kb

input:

1000
2
3
3
5
5
6
7
9
9
11
12
12
14
15
15
16
18
18
19
21
21
22
23
24
25
26
27
28
30
30
31
32
34
35
36
36
37
39
39
40
41
43
44
44
46
47
48
49
50
51
52
52
54
55
55
57
57
59
60
61
62
63
63
65
66
67
68
69
69
70
71
73
73
74
76
77
78
78
79
81
82
83
83
85
86
86
88
88
90
91
91
93
93
94
96
96
98
99
99
101
0
2...

output:

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

result:

ok Accepted

Test #55:

score: 100
Accepted
time: 26ms
memory: 4440kb

input:

1000
1
3
4
4
6
7
7
9
9
11
11
12
14
14
15
16
18
18
19
20
21
22
23
24
26
26
27
29
30
30
32
32
33
34
35
37
38
39
40
40
42
42
43
45
45
47
48
49
50
50
52
53
54
54
56
57
58
59
60
61
62
63
64
64
65
67
68
69
70
70
71
72
73
75
76
77
77
78
80
80
81
83
84
84
85
86
87
89
90
91
92
92
94
94
95
97
97
98
99
101
1
2...

output:

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

result:

ok Accepted

Test #56:

score: 100
Accepted
time: 25ms
memory: 4752kb

input:

1000
1
3
4
4
5
7
8
9
10
11
12
13
13
14
15
17
18
19
19
21
21
22
24
25
25
26
27
28
29
30
32
33
34
34
36
37
37
38
40
40
42
42
43
45
45
46
47
48
50
51
51
52
53
54
56
56
58
59
59
60
61
63
64
65
66
67
68
69
69
70
72
72
74
75
76
77
77
79
80
80
81
82
83
85
85
87
87
88
89
91
92
93
94
95
95
97
97
99
100
100
0...

output:

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

result:

ok Accepted

Test #57:

score: 100
Accepted
time: 35ms
memory: 4440kb

input:

1000
2
3
4
5
6
7
8
9
10
11
11
13
14
15
16
17
18
19
19
20
21
23
24
24
26
27
28
29
29
31
32
33
34
35
36
37
38
39
40
41
41
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
77
79
80
81
82
83
84
85
85
87
88
89
89
91
92
93
94
95
96
97
97
99
100
101
0...

output:

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

result:

ok Accepted

Test #58:

score: 100
Accepted
time: 25ms
memory: 4444kb

input:

1000
1
3
4
5
6
7
8
9
9
11
11
13
14
14
16
17
18
19
19
21
22
23
24
25
26
27
27
28
30
31
31
33
34
35
36
37
38
39
40
41
41
42
44
45
45
47
48
49
50
51
52
52
54
55
56
57
58
59
60
60
62
62
64
65
66
66
68
69
69
71
72
73
74
75
75
77
78
79
80
80
81
83
83
85
86
87
87
89
89
91
92
93
94
95
96
97
98
98
99
101
1
2...

output:

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

result:

ok Accepted

Test #59:

score: 100
Accepted
time: 25ms
memory: 4680kb

input:

1000
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
23
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
55
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
0...

output:

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

result:

ok Accepted

Test #60:

score: 100
Accepted
time: 25ms
memory: 4448kb

input:

1000
1
2
3
4
5
6
7
8
9
10
11
12
14
14
15
16
17
18
19
20
21
22
23
25
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
47
47
49
49
50
51
53
53
54
55
56
58
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
90
90
91
92
93
94
95
96
97
98
99
100
0
2...

output:

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

result:

ok Accepted

Test #61:

score: 100
Accepted
time: 27ms
memory: 4392kb

input:

1000
2
3
3
5
6
7
7
9
10
11
12
13
14
15
16
17
17
19
20
21
22
23
24
25
25
27
28
28
30
31
32
33
33
35
35
37
37
39
40
41
42
42
43
44
46
47
48
49
49
50
52
52
54
55
56
57
57
58
60
61
61
63
64
65
65
67
68
69
70
71
72
73
73
75
76
77
78
79
80
80
82
83
84
85
86
86
88
89
90
91
92
93
94
95
96
97
98
99
100
101
1...

output:

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

result:

ok Accepted

Test #62:

score: 100
Accepted
time: 28ms
memory: 4380kb

input:

1000
2
3
4
5
6
6
7
8
10
11
12
12
14
15
15
17
18
19
20
20
22
22
23
24
26
27
28
29
30
31
32
33
33
35
35
36
37
39
39
40
41
42
44
45
46
47
47
48
50
51
51
53
54
55
55
57
58
59
59
61
62
62
63
65
66
67
67
69
70
70
71
73
73
75
75
76
78
78
79
81
81
82
84
84
86
87
87
88
90
91
92
92
94
95
95
97
97
98
100
101
1...

output:

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

result:

ok Accepted

Test #63:

score: 100
Accepted
time: 25ms
memory: 4424kb

input:

1000
2
3
4
5
5
6
7
9
9
11
12
13
14
14
16
17
18
19
20
21
21
23
23
24
26
27
27
29
29
31
32
33
34
35
36
37
37
39
39
41
42
43
43
45
46
47
48
49
50
51
52
52
53
55
56
57
57
59
59
61
61
63
64
65
66
66
68
68
70
71
71
73
74
75
76
76
78
79
79
81
82
82
84
85
86
87
87
89
89
91
92
93
93
95
96
97
98
99
99
100
1
0...

output:

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

result:

ok Accepted