QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#338671#6774. Ancient Machine 2cmk666100 ✓22ms4320kbC++239.2kb2024-02-26 07:53:592024-02-26 07:53:59

Judging History

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

  • [2024-02-26 07:53:59]
  • 评测
  • 测评结果:100
  • 用时:22ms
  • 内存:4320kb
  • [2024-02-26 07:53:59]
  • 提交

answer

/*
 * @Author:             cmk666
 * @Created time:       2024-02-23 11:10:04
 * @Last Modified time: 2024-02-23 12:52:03
 */
#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
#ifdef LOCAL
#include"debug.h"
#else
#define D(...) ((void)0)
#endif
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
/*namespace FastIO
{
// ------------------------------
// #define IN_HAS_NEG
// #define OUT_HAS_NEG
// #define CHK_EOF
// #define DISABLE_MMAP
// ------------------------------
#if __cplusplus < 201400
#error Please use C++14 or higher.
#endif
#if __cplusplus > 201700
#define INLINE_V inline
#else
#define INLINE_V
#endif
#if ( defined(LOCAL) || defined(_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifndef DISABLE_MMAP
#include<sys/mman.h>
#endif
#ifdef LOCAL
	inline char gc() { return getchar(); }
	inline void pc(char c) { putchar(c); }
#else
#ifdef DISABLE_MMAP
	INLINE_V constexpr int _READ_SIZE = 1 << 18;
	INLINE_V static char _read_buffer[_READ_SIZE], *_read_ptr = nullptr, *_read_ptr_end = nullptr;
	inline char gc()
	{
		if ( __builtin_expect(_read_ptr == _read_ptr_end, false) )
		{
			_read_ptr = _read_buffer;
			_read_ptr_end = _read_buffer + fread(_read_buffer, 1, _READ_SIZE, stdin);
#ifdef CHK_EOF
			if ( __builtin_expect(_read_ptr == _read_ptr_end, false) ) return EOF;
#endif
		}
		return *_read_ptr++;
	}
#else
	INLINE_V static const char *_read_ptr = (const char *)mmap(nullptr, INT_MAX, 1, 2, 0, 0);
	inline char gc() { return *_read_ptr++; }
#endif
	INLINE_V constexpr int _WRITE_SIZE = 1 << 18;
	INLINE_V static char _write_buffer[_WRITE_SIZE], *_write_ptr = _write_buffer;
	inline void pc(char c)
	{
		*_write_ptr++ = c;
		if ( __builtin_expect(_write_buffer + _WRITE_SIZE == _write_ptr, false) )
		{
			fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout);
			_write_ptr = _write_buffer;
		}
	}
	INLINE_V struct _auto_flush
	{
		inline ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); }
	}	_auto_flush;
#endif
#ifdef CHK_EOF
	inline constexpr bool _isdigit(char c) { return ( c & 16 ) && c != EOF; }
	inline constexpr bool _isgraph(char c) { return c > 32 && c != EOF; }
#else
	inline constexpr bool _isdigit(char c) { return c & 16; }
	inline constexpr bool _isgraph(char c) { return c > 32; }
#endif
	template < class T >
	INLINE_V constexpr bool _is_integer = numeric_limits < T >::is_integer;
	template < class T >
	INLINE_V constexpr bool _is_signed = numeric_limits < T >::is_signed;
	template < class T >
	INLINE_V constexpr bool _is_unsigned = _is_integer < T > && !_is_signed < T >;
	template <> INLINE_V constexpr bool _is_integer < __int128 > = true;
	template <> INLINE_V constexpr bool _is_integer < __uint128_t > = true;
	template <> INLINE_V constexpr bool _is_signed < __int128 > = true;
	template <> INLINE_V constexpr bool _is_unsigned < __uint128_t > = true;
#undef INLINE_V
	inline void read(char &c) { do c = gc(); while ( !_isgraph(c) ); }
	inline void read_cstr(char *s)
	{
		char c = gc(); while ( !_isgraph(c) ) c = gc();
		while ( _isgraph(c) ) *s++ = c, c = gc();
		*s = 0;
	}
	inline void read(string &s)
	{
		char c = gc(); s.clear(); while ( !_isgraph(c) ) c = gc();
		while ( _isgraph(c) ) s.push_back(c), c = gc();
	}
#ifdef IN_HAS_NEG
	template < class T, enable_if_t < _is_signed < T >, int > = 0 >
	inline void read(T &x)
	{
		char c = gc(); bool f = true; x = 0;
		while ( !_isdigit(c) ) { if ( c == 45 ) f = false; c = gc(); }
		if ( f ) while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
		else     while ( _isdigit(c) ) x = x * 10 - ( c & 15 ), c = gc();
	}
	template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
	template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
	inline void read(T &x)
	{
		char c = gc(); while ( !_isdigit(c) ) c = gc();
		x = 0; while ( _isdigit(c) ) x = x * 10 + ( c & 15 ), c = gc();
	}
	inline void write(char c) { pc(c); }
	inline void write_cstr(const char *s) { while ( *s ) pc(*s++); }
	inline void write(const string &s) { for ( char c : s ) pc(c); }
#ifdef OUT_HAS_NEG
	template < class T, enable_if_t < _is_signed < T >, int > = 0 >
	inline void write(T x)
	{
		char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
		if ( x >= 0 )  do buffer[digits++] =  ( x % 10 ) | 48, x /= 10; while ( x );
		else { pc(45); do buffer[digits++] = -( x % 10 ) | 48, x /= 10; while ( x ); }
		while ( digits ) pc(buffer[--digits]);
	}
	template < class T, enable_if_t < _is_unsigned < T >, int > = 0 >
#else
	template < class T, enable_if_t < _is_integer < T >, int > = 0 >
#endif
	inline void write(T x)
	{
		char buffer[numeric_limits < T >::digits10 + 1]; int digits = 0;
		do buffer[digits++] = ( x % 10 ) | 48, x /= 10; while ( x );
		while ( digits ) pc(buffer[--digits]);
	}
	template < int N > struct _tuple_io_helper
	{
		template < class ...T >
		static inline void _read(tuple < T... > &x)
		{ _tuple_io_helper < N - 1 >::_read(x), read(get < N - 1 > (x)); }
		template < class ...T >
		static inline void _write(const tuple < T... > &x)
		{ _tuple_io_helper < N - 1 >::_write(x), pc(32), write(get < N - 1 > (x)); }
	};
	template <> struct _tuple_io_helper < 1 >
	{
		template < class ...T >
		static inline void _read(tuple < T... > &x) { read(get < 0 > (x)); }
		template < class ...T >
		static inline void _write(const tuple < T... > &x) { write(get < 0 > (x)); }
	};
	template < class ...T >
	inline void read(tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_read(x); }
	template < class ...T >
	inline void write(const tuple < T... > &x) { _tuple_io_helper < sizeof...(T) >::_write(x); }
	template < class T1, class T2 >
	inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
	template < class T1, class T2 >
	inline void write(const pair < T1, T2 > &x) { write(x.first), pc(32), write(x.second); }
	template < class T1, class ...T2 >
	inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
	template < class ...T >
	inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
	template < class T1, class ...T2 >
	inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
	template < class ...T >
	inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
	template < class T >
	inline void print(const T &x) { write(x); }
	inline void print_cstr(const char *x) { write_cstr(x); }
	template < class T1, class ...T2 >
	inline void print(const T1 &x, const T2 &...y) { print(x), pc(32), print(y...); }
	template < class ...T >
	inline void print_cstr(const char *x, const T *...y) { print_cstr(x), pc(32), print_cstr(y...); }
	inline void println() { pc(10); }
	inline void println_cstr() { pc(10); }
	template < class ...T >
	inline void println(const T &...x) { print(x...), pc(10); }
	template < class ...T >
	inline void println_cstr(const T *...x) { print_cstr(x...), pc(10); }
}
using namespace FastIO;*/
#include"ancient2.h"
string Solve(int n)
{
	string s(n, 0);
	For(i, 0, 99)
	{
		vector < int > a(i + 3), b(i + 3);
		For(j, 0, i - 1) a[j] = b[j] = j + 1;
		a[i] = a[i + 1] = b[i + 1] = i + 1, b[i] = a[i + 2] = b[i + 2] = i + 2;
		s[i] = Query(i + 3, a, b) == i + 1 ? '0' : '1';
	}
	For(i, 0, 100)
	{
		const auto ch = [&](int x) { return x ? s[n + x - i - 1] : '0'; };
		vector < int > a(i + 2), b(i + 2), pi(i + 1); int p = 0;
		For(j, 1, i)
		{
			while ( p && ch(j) != ch(p) ) p = pi[p - 1];
			pi[j] = p += ch(j) == ch(p);
		}
		For(j, 0, i + 1)
		{
			a[j] = j ? a[pi[j - 1]] : 0, b[j] = j ? b[pi[j - 1]] : 0;
			if ( j <= i && ch(j) == '0' ) a[j] = j + 1;
			if ( j <= i && ch(j) == '1' ) b[j] = j + 1;
		}
		s[n - i - 1] = Query(i + 2, a, b) == i + 1 ? '0': '1';
	}
	bitset < 799 > lb[799]; bool used[799]; fill(used, used + 799, false);
	const auto ins = [&](auto x) {
		For(i, 0, 798) if ( x.test(i) )
			if ( used[i] ) x ^= lb[i];
			else { lb[i] = x, used[i] = true; return true; }
		return false;
	};
	vector < bitset < 800 > > g; g.reserve(799);
	For(i, 1, 51) For(j, 0, i - 1)
	{
		bitset < 799 > h;
		for ( int k = j ; k < 1000 ; k += i ) if ( k > 99 && k < 899 ) h.set(k - 100);
		if ( ins(h) )
		{
			vector < int > a(i + i), b(i + i);
			For(k, 0, i - 1) a[k] = b[k] = k == i - 1 ? 0 : k + 1;
			For(k, i, i + i - 1) a[k] = b[k] = k == i + i - 1 ? i : k + 1;
			b[j] = j == i - 1 ? i : i + j + 1, b[i + j] = j == i - 1 ? 0 : j + 1;
			g.emplace_back(), g.back().set(799, Query(i + i, a, b) >= i);
			for ( int k = j ; k < 1000 ; k += i )
				if ( k > 99 && k < 899 ) g.back().set(k - 100);
				else if ( s[k] == '1' ) g.back().flip(799);
		}
	}
	assert((int)g.size() == 799);
	For(i, 0, 798)
	{
		int id = i;
		while ( id < (int)g.size() && !g[id].test(i) ) id++;
		assert(id < (int)g.size()), swap(g[i], g[id]);
		For(j, 0, (int)g.size() - 1) if ( i != j && g[j].test(i) ) g[j] ^= g[i];
	}
	For(i, 0, 798) s[i + 100] = g[i].test(799) + '0';
	return s;
}
// 想上GM捏 想上GM捏 想上GM捏 想上GM捏 想上GM捏
// 伊娜可爱捏 伊娜贴贴捏

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 100
Accepted

Test #1:

score: 100
Accepted
time: 8ms
memory: 4312kb

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: 16ms
memory: 4052kb

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

score: 100
Accepted
time: 12ms
memory: 4088kb

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 #4:

score: 100
Accepted
time: 11ms
memory: 4284kb

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: 22ms
memory: 4308kb

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
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 #6:

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

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: 6ms
memory: 4024kb

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
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 #8:

score: 100
Accepted
time: 18ms
memory: 4052kb

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: 16ms
memory: 3988kb

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
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 #10:

score: 100
Accepted
time: 18ms
memory: 4096kb

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
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 #11:

score: 100
Accepted
time: 16ms
memory: 4032kb

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: 18ms
memory: 3992kb

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
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 #13:

score: 100
Accepted
time: 18ms
memory: 4280kb

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
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 #14:

score: 100
Accepted
time: 14ms
memory: 4280kb

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: 15ms
memory: 4312kb

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
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 #16:

score: 100
Accepted
time: 16ms
memory: 4316kb

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 #17:

score: 100
Accepted
time: 11ms
memory: 4284kb

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
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 #18:

score: 100
Accepted
time: 18ms
memory: 4024kb

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: 17ms
memory: 4020kb

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
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 #20:

score: 100
Accepted
time: 4ms
memory: 4024kb

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 #21:

score: 100
Accepted
time: 6ms
memory: 4012kb

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
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 #22:

score: 100
Accepted
time: 13ms
memory: 4020kb

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: 11ms
memory: 4284kb

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
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 #24:

score: 100
Accepted
time: 17ms
memory: 4024kb

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
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 #25:

score: 100
Accepted
time: 12ms
memory: 4016kb

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
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 #26:

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

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
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 #27:

score: 100
Accepted
time: 18ms
memory: 4016kb

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: 11ms
memory: 4100kb

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: 10ms
memory: 4316kb

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: 12ms
memory: 4028kb

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
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 #31:

score: 100
Accepted
time: 11ms
memory: 4080kb

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
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 #32:

score: 100
Accepted
time: 18ms
memory: 3988kb

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: 3ms
memory: 4308kb

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: 13ms
memory: 4284kb

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
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 #35:

score: 100
Accepted
time: 14ms
memory: 3988kb

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: 15ms
memory: 4008kb

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
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 #37:

score: 100
Accepted
time: 18ms
memory: 4284kb

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: 18ms
memory: 4316kb

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: 9ms
memory: 4020kb

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: 10ms
memory: 4016kb

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: 11ms
memory: 4284kb

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: 9ms
memory: 4076kb

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: 10ms
memory: 4028kb

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
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 #44:

score: 100
Accepted
time: 10ms
memory: 4024kb

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
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 #45:

score: 100
Accepted
time: 6ms
memory: 4016kb

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
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 #46:

score: 100
Accepted
time: 16ms
memory: 4052kb

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
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 #47:

score: 100
Accepted
time: 9ms
memory: 4016kb

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
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 #48:

score: 100
Accepted
time: 14ms
memory: 4312kb

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
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 #49:

score: 100
Accepted
time: 8ms
memory: 4320kb

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
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 #50:

score: 100
Accepted
time: 12ms
memory: 4316kb

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: 16ms
memory: 3992kb

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: 16ms
memory: 4016kb

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
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 #53:

score: 100
Accepted
time: 11ms
memory: 4028kb

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
1
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 #54:

score: 100
Accepted
time: 17ms
memory: 4312kb

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
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 #55:

score: 100
Accepted
time: 18ms
memory: 4312kb

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
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 #56:

score: 100
Accepted
time: 11ms
memory: 4316kb

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
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 #57:

score: 100
Accepted
time: 18ms
memory: 4248kb

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: 14ms
memory: 4008kb

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
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 #59:

score: 100
Accepted
time: 16ms
memory: 4024kb

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: 7ms
memory: 4080kb

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
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 #61:

score: 100
Accepted
time: 12ms
memory: 4312kb

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
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 #62:

score: 100
Accepted
time: 11ms
memory: 4020kb

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: 14ms
memory: 4036kb

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
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