QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#832765#8283. Game of Votesecnerwala#AC ✓377ms67308kbC++2315.0kb2024-12-26 06:12:422024-12-26 06:12:44

Judging History

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

  • [2024-12-26 06:12:44]
  • 评测
  • 测评结果:AC
  • 用时:377ms
  • 内存:67308kb
  • [2024-12-26 06:12:42]
  • 提交

answer

#include <bits/stdc++.h>

namespace seg_tree {

// Floor of log_2(a); index of highest 1-bit
inline int floor_log_2(int a) {
	return a ? (8 * sizeof(a)) - 1 - __builtin_clz(a) : -1;
}

inline int ceil_log_2(int a) {
	return a ? floor_log_2(2*a-1) : -1;
}

inline int next_pow_2(int a) {
	return 1 << ceil_log_2(a);
}

struct point {
	int a;
	point() : a(0) {}
	explicit point(int a_) : a(a_) { assert(a >= -1); }

	explicit operator bool () { return bool(a); }

	// This is useful so you can directly do array indices
	/* implicit */ operator int() const { return a; }

	point c(bool z) const {
		return point((a<<1)|z);
	}

	point operator [] (bool z) const {
		return c(z);
	}

	point p() const {
		return point(a>>1);
	}

	friend std::ostream& operator << (std::ostream& o, const point& p) { return o << int(p); }

	template <typename F> void for_each(F f) const {
		for (int v = a; v > 0; v >>= 1) {
			f(point(v));
		}
	}

	template <typename F> void for_each_down(F f) const {
		// strictly greater than 0
		for (int L = floor_log_2(a); L >= 0; L--) {
			f(point(a >> L));
		}
	}

	template <typename F> void for_each_up(F f) const {
		for (int v = a; v > 0; v >>= 1) {
			f(point(v));
		}
	}

	template <typename F> void for_parents_down(F f) const {
		// strictly greater than 0
		for (int L = floor_log_2(a); L > 0; L--) {
			f(point(a >> L));
		}
	}

	template <typename F> void for_parents_up(F f) const {
		for (int v = a >> 1; v > 0; v >>= 1) {
			f(point(v));
		}
	}

	point& operator ++ () { ++a; return *this; }
	point operator ++ (int) { return point(a++); }
	point& operator -- () { --a; return *this; }
	point operator -- (int) { return point(a--); }
};

struct range {
	int a, b;
	range() : a(1), b(1) {}
	range(int a_, int b_) : a(a_), b(b_) {
		assert(1 <= a && a <= b && b <= 2 * a);
	}
	explicit range(std::array<int, 2> r) : range(r[0], r[1]) {}

	explicit operator std::array<int, 2>() const {
		return {a,b};
	}

	const int& operator[] (bool z) const {
		return z ? b : a;
	}

	friend std::ostream& operator << (std::ostream& o, const range& r) { return o << "[" << r.a << ".." << r.b << ")"; }

	// Iterate over the range from outside-in.
	//   Calls f(point a)
	template <typename F> void for_each(F f) const {
		for (int x = a, y = b; x < y; x >>= 1, y >>= 1) {
			if (x & 1) f(point(x++));
			if (y & 1) f(point(--y));
		}
	}

	// Iterate over the range from outside-in.
	//   Calls f(point a, bool is_right)
	template <typename F> void for_each_with_side(F f) const {
		for (int x = a, y = b; x < y; x >>= 1, y >>= 1) {
			if (x & 1) f(point(x++), false);
			if (y & 1) f(point(--y), true);
		}
	}

	// Iterate over the range from left to right.
	//    Calls f(point)
	template <typename F> void for_each_l_to_r(F f) const {
		int anc_depth = floor_log_2((a-1) ^ b);
		int anc_msk = (1 << anc_depth) - 1;
		for (int v = (-a) & anc_msk; v; v &= v-1) {
			int i = __builtin_ctz(v);
			f(point(((a-1) >> i) + 1));
		}
		for (int v = b & anc_msk; v; ) {
			int i = floor_log_2(v);
			f(point((b >> i) - 1));
			v ^= (1 << i);
		}
	}

	// Iterate over the range from right to left.
	//    Calls f(point)
	template <typename F> void for_each_r_to_l(F f) const {
		int anc_depth = floor_log_2((a-1) ^ b);
		int anc_msk = (1 << anc_depth) - 1;
		for (int v = b & anc_msk; v; v &= v-1) {
			int i = __builtin_ctz(v);
			f(point((b >> i) - 1));
		}
		for (int v = (-a) & anc_msk; v; ) {
			int i = floor_log_2(v);
			f(point(((a-1) >> i) + 1));
			v ^= (1 << i);
		}
	}

	template <typename F> void for_parents_down(F f) const {
		int x = a, y = b;
		if ((x ^ y) > x) { x <<= 1, std::swap(x, y); }
		int dx = __builtin_ctz(x);
		int dy = __builtin_ctz(y);
		int anc_depth = floor_log_2((x-1) ^ y);
		for (int i = floor_log_2(x); i > dx; i--) {
			f(point(x >> i));
		}
		for (int i = anc_depth; i > dy; i--) {
			f(point(y >> i));
		}
	}

	template <typename F> void for_parents_up(F f) const {
		int x = a, y = b;
		if ((x ^ y) > x) { x <<= 1, std::swap(x, y); }
		int dx = __builtin_ctz(x);
		int dy = __builtin_ctz(y);
		int anc_depth = floor_log_2((x-1) ^ y);
		for (int i = dx+1; i <= anc_depth; i++) {
			f(point(x >> i));
		}
		for (int v = y >> (dy+1); v; v >>= 1) {
			f(point(v));
		}
	}
};

struct in_order_layout {
	// Alias them in for convenience
	using point = seg_tree::point;
	using range = seg_tree::range;

	int N, S;
	in_order_layout() : N(0), S(0) {}
	in_order_layout(int N_) : N(N_), S(N ? next_pow_2(N) : 0) {}

	point get_point(int a) const {
		assert(0 <= a && a < N);
		a += S;
		return point(a >= 2 * N ? a - N : a);
	}

	range get_range(int a, int b) const {
		assert(0 <= a && a <= b && b <= N);
		if (N == 0) return range();
		a += S, b += S;
		return range((a >= 2 * N ? 2*(a-N) : a), (b >= 2 * N ? 2*(b-N) : b));
	}

	range get_range(std::array<int, 2> p) const {
		return get_range(p[0], p[1]);
	}

	int get_leaf_index(point pt) const {
		int a = int(pt);
		assert(N <= a && a < 2 * N);
		return (a < S ? a + N : a) - S;
	}

	std::array<int, 2> get_node_bounds(point pt) const {
		int a = int(pt);
		assert(1 <= a && a < 2 * N);
		int l = __builtin_clz(a) - __builtin_clz(2*N-1);
		int x = a << l, y = (a+1) << l;
		assert(S <= x && x < y && y <= 2*S);
		return {(x >= 2 * N ? (x>>1) + N : x) - S, (y >= 2 * N ? (y>>1) + N : y) - S};
	}

	int get_node_split(point pt) const {
		int a = int(pt);
		assert(1 <= a && a < N);
		int l = __builtin_clz(2*a+1) - __builtin_clz(2*N-1);
		int x = (2*a+1) << l;
		assert(S <= x && x < 2*S);
		return (x >= 2 * N ? (x>>1) + N : x) - S;
	}

	int get_node_size(point pt) const {
		auto bounds = get_node_bounds(pt);
		return bounds[1] - bounds[0];
	}
};

struct circular_layout {
	// Alias them in for convenience
	using point = seg_tree::point;
	using range = seg_tree::range;

	int N;
	circular_layout() : N(0) {}
	circular_layout(int N_) : N(N_) {}

	point get_point(int a) const {
		assert(0 <= a && a < N);
		return point(N + a);
	}

	range get_range(int a, int b) const {
		assert(0 <= a && a <= b && b <= N);
		if (N == 0) return range();
		return range(N + a, N + b);
	}

	range get_range(std::array<int, 2> p) const {
		return get_range(p[0], p[1]);
	}

	int get_leaf_index(point pt) const {
		int a = int(pt);
		assert(N <= a && a < 2 * N);
		return a - N;
	}

	// Returns {x,y} so that 0 <= x < N and 1 <= y <= N
	// If the point is non-wrapping, then 0 <= x < y <= N
	std::array<int, 2> get_node_bounds(point pt) const {
		int a = int(pt);
		assert(1 <= a && a < 2 * N);
		int l = __builtin_clz(a) - __builtin_clz(2*N-1);
		int S = next_pow_2(N);
		int x = a << l, y = (a+1) << l;
		assert(S <= x && x < y && y <= 2*S);
		return {(x >= 2 * N ? x >> 1 : x) - N, (y > 2 * N ? y >> 1 : y) - N};
	}

	// Returns the split point of the node, such that 1 <= s <= N.
	int get_node_split(point pt) const {
		int a = int(pt);
		assert(1 <= a && a < N);
		return get_node_bounds(pt.c(0))[1];
	}

	int get_node_size(point pt) const {
		auto bounds = get_node_bounds(pt);
		int r = bounds[1] - bounds[0];
		return r > 0 ? r : r + N;
	}
};

} // namespace seg_tree

namespace std {

template<class Fun>
class y_combinator_result {
	Fun fun_;
public:
	template<class T>
	explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

	template<class ...Args>
	decltype(auto) operator()(Args &&...args) {
		return fun_(std::ref(*this), std::forward<Args>(args)...);
	}
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
	return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

} // namespace std

struct splay_node {
	splay_node* p = nullptr;
	std::array<splay_node*, 2> c{nullptr, nullptr};
	// sorted increasing by time
	int64_t own_time;
	int64_t own_b;

	int64_t min_a_needed;
	int64_t tot_b;

	bool d() { return this == p->c[1]; }
	void update() {
		tot_b = own_b;
		min_a_needed = own_time - own_b;
		if (c[0]) {
			min_a_needed = std::min(min_a_needed - c[0]->tot_b, c[0]->min_a_needed);
			tot_b += c[0]->tot_b;
		}
		if (c[1]) {
			min_a_needed = std::min(min_a_needed, c[1]->min_a_needed - tot_b);
			tot_b += c[1]->tot_b;
		}
	}

	void rot() {
		assert(p);
		splay_node* pa = p;
		int x = d();
		assert(pa->c[x] == this);

		if (pa->p) pa->p->c[pa->d()] = this;
		this->p = pa->p;

		if (this->c[!x]) this->c[!x]->p = pa;
		pa->c[x] = this->c[!x];

		pa->p = this;
		this->c[!x] = pa;

		pa->update();
	}

	void splay() {
		while (p) {
			if (p->p) {
				if (d() == p->d()) p->rot();
				else rot();
			}
			rot();
		}
		update();
	}
};

splay_node* concat(splay_node* a, splay_node* b) {
	if (!a) return b;
	if (!b) return a;
	assert(!a->p);
	assert(!b->p);
	while (b->c[0]) b = b->c[0];
	b->splay();
	assert(!b->c[0]);
	b->c[0] = a;
	a->p = b;
	b->update();
	return b;
}

splay_node* erase(splay_node* n) {
	n->splay();
	auto [a, b] = n->c;
	n->c = {nullptr, nullptr};
	if (a) a->p = nullptr;
	if (b) b->p = nullptr;
	return concat(a, b);
}

void insert_and_splay(splay_node* n, splay_node* t) {
	assert(n);
	assert(!n->p);
	assert(!n->c[0]);
	assert(!n->c[1]);

	if (!t) return;
	assert(!t->p);
	while (true) {
		assert(n->own_time != t->own_time);
		int d = n->own_time > t->own_time;
		if (!t->c[d]) {
			t->c[d] = n;
			n->p = t;
			n->splay();
			return;
		} else {
			t = t->c[d];
		}
	}
}

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	int N, Q; cin >> N >> Q;
	std::vector<int> orig_par(N);
	orig_par[0] = -1;
	for (int i = 1; i < N; i++) { cin >> orig_par[i]; orig_par[i] --; }
	std::vector<std::vector<int>> orig_ch(N);
	for (int i = 1; i < N; i++) orig_ch[orig_par[i]].push_back(i);

	{
		std::vector<int> sz(N, 1);
		for (int i = N-1; i > 0; i--) sz[orig_par[i]] += sz[i];
		for (int i = 0; i < N; i++) {
			if (!orig_ch[i].empty()) {
				auto it = std::max_element(orig_ch[i].begin(), orig_ch[i].end(), [&](int a, int b) { return sz[a] < sz[b]; });
				std::swap(*it, *orig_ch[i].begin());
			}
		}
	}
	std::vector<int> preorder; preorder.reserve(N);
	std::vector<int> preorder_idx(N);
	std::vector<int> par(N);
	std::vector<int> heavy_root(N);
	std::vector<int> heavy_cnt(N);
	{
		std::y_combinator([&](auto self, int cur, int prv_idx) -> void {
			int cur_idx = int(preorder.size());
			preorder.push_back(cur);
			preorder_idx[cur] = cur_idx;

			par[cur_idx] = prv_idx;
			if (prv_idx != -1 && cur_idx == prv_idx+1) heavy_root[cur_idx] = heavy_root[prv_idx];
			else heavy_root[cur_idx] = cur_idx;
			heavy_cnt[heavy_root[cur_idx]]++;
			for (int nxt : orig_ch[cur]) {
				self(nxt, cur_idx);
			}
		})(0, -1);
		assert(int(preorder.size()) == N);
	}

	std::vector<int64_t> A(N);
	for (int i = 0; i < N; i++) {
		auto& a = A[preorder_idx[i]];
		cin >> a; a *= N; a += i;
	}
	std::vector<int64_t> B(N);
	for (int i = 0; i < N; i++) {
		auto& b = B[preorder_idx[i]];
		cin >> b; b *= N;
	}

	std::vector<splay_node> nodes(N);
	std::vector<splay_node*> light_trees(N, nullptr);

	struct piecewise_fn {
		int64_t thresh;
		int64_t v_smaller;
		int64_t v_bigger;
	};
	auto query_tree = [&](int i, int64_t a) -> int64_t {
		splay_node* t = light_trees[i];
		assert(!t || !t->p);
		if (!t || a < t->min_a_needed) {
			return a;
		}
		while (true) {
			assert(a >= t->min_a_needed);
			int64_t b_left = (t->c[0] ? t->c[0]->tot_b : 0) + t->own_b;
			if (t->c[1] && a + b_left >= t->c[1]->min_a_needed) {
				a += b_left;
				t = t->c[1];
			} else if (a + b_left >= t->own_time) {
				a += b_left;
				break;
			} else {
				assert(t->c[0] && a >= t->c[0]->min_a_needed);
				t = t->c[0];
			}
		}
		t->splay();
		light_trees[i] = t;
		return a;
	};

	auto query_lights = [&](int i) -> piecewise_fn {
		if (i+1 == N || heavy_root[i+1] != heavy_root[i]) {
			// we're a leaf
			assert(light_trees[i] == nullptr);
			return piecewise_fn{-1, A[i], A[i]};
		} else {
			int64_t v_smaller = query_tree(i, A[i] + B[i+1]);
			int64_t v_bigger = query_tree(i, A[i]);
			assert(v_smaller >= v_bigger);
			// If the next guy is smaller than v_smaller, we prefer it
			return piecewise_fn{v_smaller, v_smaller, v_bigger};
		}
	};

	std::vector<std::vector<piecewise_fn>> heavy_segs(N);
	auto eval = [](piecewise_fn a, int64_t v) -> int64_t {
		return (v < a.thresh) ? a.v_smaller : a.v_bigger;
	};
	auto compose = [eval](piecewise_fn a, piecewise_fn b) -> piecewise_fn {
		return {b.thresh, eval(a, b.v_smaller), eval(a, b.v_bigger) };
	};

	for (int i = N-1; i >= 0; i--) {
		if (heavy_root[i] == i) {
			int sz = heavy_cnt[i];
			seg_tree::in_order_layout layout(sz);
			heavy_segs[i].resize(2*sz);
			for (int j = i; j < i + sz; j++) {
				heavy_segs[i][layout.get_point(j - i)] = query_lights(j);
			}
			for (seg_tree::point a(sz-1); a > 0; a--) {
				heavy_segs[i][a] = compose(heavy_segs[i][a.c(0)], heavy_segs[i][a.c(1)]);
			}
			assert(heavy_segs[i][1].thresh == -1);
			assert(heavy_segs[i][1].v_smaller == heavy_segs[i][1].v_bigger);
			if (i != 0) {
				int p = par[i];
				assert(0 <= p && p < i-1);
				nodes[i].own_time = heavy_segs[i][1].v_smaller;
				nodes[i].own_b = B[i];
				nodes[i].update();
				insert_and_splay(&nodes[i], light_trees[p]);
				light_trees[p] = &nodes[i];
			}
		}
	}
	auto update_heavy_chain = [&](int v) -> void {
		int i = heavy_root[v];
		int sz = heavy_cnt[i];
		seg_tree::in_order_layout layout(sz);
		auto x = layout.get_point(v - i);
		heavy_segs[i][x] = query_lights(v);
		x.for_parents_up([&](auto a) -> void {
			heavy_segs[i][a] = compose(heavy_segs[i][a.c(0)], heavy_segs[i][a.c(1)]);
		});
	};

	auto update = [&](int v) -> void {
		update_heavy_chain(v);
		if (v != heavy_root[v]) {
			// B[i] changed, so update v-1
			update_heavy_chain(v-1);
		} else {
			// otherwise, we'll just update it as part of the nodes[v] update
		}

		// now just update up the chain
		while (true) {
			v = heavy_root[v];
			assert(v == heavy_root[v]);
			int p = par[v];
			if (p == -1) {
				assert(v == 0);
				break;
			}
			auto t = erase(&nodes[v]);
			nodes[v].own_time = heavy_segs[v][1].v_smaller;
			nodes[v].own_b = B[v];
			nodes[v].update();
			insert_and_splay(&nodes[v], t);
			light_trees[p] = &nodes[v];
			v = p;
			update_heavy_chain(v);
		}
	};

	auto query = [&](int v) -> int64_t {
		int i = heavy_root[v];
		int sz = heavy_cnt[i];
		seg_tree::in_order_layout layout(sz);
		auto x = layout.get_range(v - i, sz);
		int64_t res = -1;
		x.for_each_r_to_l([&](auto a) -> void {
			res = eval(heavy_segs[i][a], res);
		});
		return res;
	};

	for (int q = 0; q < Q; q++) {
		int op; cin >> op;
		if (op == 1) {
			int p; int64_t x, y; cin >> p >> x >> y; p--;
			x *= N; x += p;
			y *= N;
			p = preorder_idx[p];
			A[p] = x;
			B[p] = y;
			update(p);
		} else if (op == 2) {
			int c, d; cin >> c >> d; c--, d--;
			c = preorder_idx[c];
			d = preorder_idx[d];
			cout << int(query(c) < query(d)) << '\n';
		}
	}

	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3872kb

input:

20 500
1 1 3 1 3 5 6 6 7 3 5 3 9 5 4 7 7 18 2
42129194 82765784 1447057 29726963 82321558 32094641 22474113 49277574 27527633 20746795 47630926 92888389 26787144 80703040 43876864 97991729 12117966 75633318 33577855 93462601
69163546 49621952 45236756 46447931 34085269 55246550 54414402 99593046 103...

output:

0
0
1
1
0
0
0
0
1
1
0
0
0
0
0
1
1
1
1
1
0
0
1
1
0
1
1
1
0
1
1
0
0
0
0
1
1
1
1
1
1
0
1
0
0
1
0
1
1
0
0
0
1
1
1
1
1
1
0
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
1
1
0
1
1
1
1
1
0
1
1
0
1
0
0
1
0
0
1
1
1
0
0
0
0
1
1
0
1
0
1
0
1
1
0
1
0
0
1
0
0
1
1
1
1
0
1
0
0
1
1
1
1
0
0
1
0
0
0
1
0
1
1
1
...

result:

ok 238 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

20 500
1 1 3 1 3 5 3 4 2 4 3 12 6 7 12 6 4 11 10
2 0 2 1 1 1 2 0 2 2 1 0 0 2 1 0 1 0 1 1
0 0 2 0 0 0 1 2 2 2 0 2 2 2 1 0 1 0 1 1
2 5 2
1 6 1 0
1 7 1 1
2 5 11
2 18 16
2 13 7
2 4 3
1 6 0 0
1 5 0 2
2 16 12
2 5 18
2 8 16
1 4 0 0
2 5 2
1 19 2 2
1 10 0 0
1 15 2 2
2 12 14
1 12 1 1
1 13 1 2
1 3 2 2
1 6 2 2
...

output:

0
1
0
1
1
1
1
1
0
1
0
0
1
1
0
1
1
0
1
1
0
1
0
0
1
1
1
1
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
0
1
0
1
0
0
1
0
0
1
1
1
0
1
0
0
1
1
0
1
1
1
1
0
0
1
1
1
0
1
1
1
0
0
0
1
0
1
0
0
1
0
1
1
0
0
0
0
0
0
1
1
1
1
1
0
0
1
0
0
1
1
0
1
1
0
0
1
1
0
1
1
0
0
1
0
1
0
1
1
0
1
0
1
0
0
1
1
0
1
0
1
1
1
1
0
0
0
0
1
1
0
1
0
1
0
0
...

result:

ok 226 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 3984kb

input:

500 500
1 2 1 1 3 4 7 3 9 9 4 9 5 9 1 16 2 9 18 13 1 17 19 20 25 13 1 10 29 17 16 8 5 26 10 31 37 9 26 18 41 5 26 44 40 11 32 37 43 2 3 5 25 53 31 7 25 23 29 40 33 26 56 53 24 25 31 40 43 62 2 21 24 65 75 69 27 38 16 55 77 38 79 20 46 48 80 81 22 55 28 64 91 13 22 76 77 25 34 44 101 41 62 73 99 20 2...

output:

0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
1
0
1
0
0
0
1
0
1
0
1
1
1
1
1
1
1
0
0
0
1
0
0
0
0
1
0
1
1
0
1
1
1
1
1
1
1
1
0
0
0
0
1
0
0
0
0
1
1
0
1
0
1
0
0
1
0
1
1
0
0
0
1
0
0
1
0
1
1
0
1
1
0
1
1
0
0
0
1
0
0
1
1
1
1
0
0
0
1
1
1
0
0
1
1
1
0
1
1
0
1
1
1
0
1
0
0
0
1
0
1
0
0
1
1
1
0
1
0
0
1
0
1
1
1
...

result:

ok 247 numbers

Test #4:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

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

output:

1
1
0
1
1
0
1
1
0
0
0
1
1
0
1
1
0
0
0
1
0
0
0
1
0
0
1
0
0
0
0
1
0
1
1
1
0
0
0
1
0
0
1
0
0
1
0
1
1
1
1
0
0
0
1
0
1
1
1
1
1
1
0
0
0
1
1
1
1
0
1
0
1
1
0
0
1
1
1
0
1
0
1
0
1
0
0
1
0
0
1
0
1
1
1
1
1
1
1
1
1
1
0
1
1
0
1
0
1
1
1
1
1
0
1
1
0
0
0
1
1
1
0
0
0
1
0
1
1
1
0
1
0
0
0
0
0
0
1
0
0
1
1
0
1
0
1
0
1
0
...

result:

ok 255 numbers

Test #5:

score: 0
Accepted
time: 1ms
memory: 3908kb

input:

500 500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1
1
0
0
0
1
0
1
1
1
1
0
1
1
0
1
1
1
1
0
1
1
1
0
0
1
1
0
1
0
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
1
1
1
1
1
0
1
1
1
0
1
1
0
1
1
1
1
0
0
1
0
0
0
1
0
0
0
0
1
1
1
0
0
1
1
1
1
0
1
0
1
0
1
0
1
1
0
1
0
0
1
0
0
1
1
0
1
0
1
0
1
0
0
0
1
1
0
0
0
0
0
0
1
1
0
1
0
0
0
1
1
0
1
1
1
0
1
1
0
1
0
1
1
1
0
1
1
1
0
0
1
...

result:

ok 243 numbers

Test #6:

score: 0
Accepted
time: 1ms
memory: 3720kb

input:

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

output:

1
0
0
1
1
1
1
1
1
1
0
1
1
0
1
1
1
1
0
0
0
1
0
0
1
0
0
1
0
0
0
0
0
1
0
1
1
1
0
1
1
1
0
1
1
1
1
0
1
1
0
0
1
1
0
0
1
0
0
1
1
1
0
0
0
1
0
1
1
1
1
0
0
1
1
1
1
1
1
1
0
1
0
0
1
1
0
1
1
0
1
0
1
1
0
1
0
1
1
0
0
1
1
1
1
0
0
1
1
1
1
0
0
1
1
0
1
1
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
0
1
1
1
0
1
1
1
0
0
0
0
0
0
1
1
0
...

result:

ok 248 numbers

Test #7:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

100 3000
1 1 2 1 3 4 1 4 7 8 1 9 5 7 2 9 7 7 1 3 20 22 16 18 23 15 24 4 14 1 21 4 21 32 14 14 33 28 13 4 20 27 41 43 18 26 4 8 24 16 30 16 13 45 20 46 6 17 4 48 24 23 54 59 61 42 62 41 26 35 10 40 9 41 35 68 67 63 48 53 10 59 81 54 15 22 86 69 49 52 55 3 27 52 48 15 54 16 87
32745005 92702519 399483...

output:

0
0
1
0
0
1
0
0
1
0
1
0
0
0
1
0
1
0
0
1
0
1
1
1
0
1
0
0
0
0
1
0
1
1
1
0
1
1
1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
1
0
1
1
0
0
0
1
1
0
0
0
0
1
1
1
1
0
1
1
0
1
1
0
0
1
1
0
1
0
0
0
1
0
1
1
0
1
0
0
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
1
1
0
0
1
0
1
0
0
1
1
0
0
1
0
1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
...

result:

ok 1494 numbers

Test #8:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

100 3000
1 2 3 1 1 5 7 7 1 3 3 6 7 9 12 2 11 5 19 20 10 16 7 7 3 22 16 24 5 27 22 13 24 24 24 25 5 11 16 22 40 26 6 39 14 2 46 21 43 50 20 27 28 7 54 41 55 16 36 26 38 46 4 29 63 12 45 64 28 47 53 33 28 28 44 17 27 36 41 22 39 55 32 79 57 64 76 48 45 45 61 69 73 67 68 92 36 66 73
0 1 2 2 0 0 1 0 2 1...

output:

0
1
0
1
1
1
1
0
1
0
1
1
1
0
0
1
0
0
0
1
1
1
1
1
1
0
1
1
0
1
1
0
1
1
0
0
0
0
0
0
1
0
0
1
0
1
0
0
1
0
0
1
0
1
1
1
1
1
0
0
1
1
1
1
0
1
0
1
0
0
1
1
0
1
1
0
1
1
0
0
0
0
0
0
1
1
1
0
1
1
1
1
0
0
0
0
1
0
1
0
0
0
0
1
1
1
0
0
1
0
1
0
0
1
0
0
0
1
1
1
1
1
1
1
1
0
0
1
1
1
0
0
0
1
0
0
1
0
0
1
1
1
1
1
1
1
0
1
1
1
...

result:

ok 1495 numbers

Test #9:

score: 0
Accepted
time: 0ms
memory: 4132kb

input:

3000 3000
1 1 2 1 1 4 7 1 1 9 6 7 1 14 11 1 16 6 17 20 4 18 4 21 22 23 17 19 20 15 6 22 4 2 28 16 19 19 24 2 31 38 20 33 1 44 13 21 10 42 40 27 4 34 25 22 15 53 43 12 11 31 54 24 31 27 16 43 41 69 23 38 70 66 58 60 7 60 30 61 28 26 14 30 55 22 49 37 31 6 59 22 39 8 56 17 35 67 1 63 43 6 82 41 56 30 ...

output:

1
0
1
1
0
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
0
1
0
1
0
0
1
1
0
1
0
1
0
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
1
1
0
1
1
1
0
0
1
0
0
0
1
0
1
1
1
1
0
1
1
1
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
1
0
0
0
0
1
1
0
0
1
0
0
1
0
0
0
1
1
1
1
0
0
1
0
0
1
1
0
1
1
1
1
0
0
1
1
1
0
0
1
1
1
1
0
0
1
0
1
1
0
1
1
0
0
...

result:

ok 1450 numbers

Test #10:

score: 0
Accepted
time: 2ms
memory: 4184kb

input:

3000 3000
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 10...

output:

0
0
1
0
0
0
1
1
0
1
1
0
1
0
0
0
0
0
1
0
0
0
1
1
0
1
0
0
1
1
1
1
1
0
0
0
1
0
0
1
1
1
1
1
0
1
0
1
1
0
1
1
0
1
1
1
1
1
1
1
1
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
1
0
1
1
0
1
1
1
0
1
1
1
0
0
0
1
0
0
0
0
0
1
0
1
0
1
0
0
0
1
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
0
1
1
0
0
1
1
0
0
0
0
0
0
0
1
1
1
0
1
0
0
1
0
1
0
0
0
0
1
...

result:

ok 1532 numbers

Test #11:

score: 0
Accepted
time: 3ms
memory: 4060kb

input:

3000 3000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1
1
1
0
0
1
1
1
1
0
1
0
1
1
0
1
0
0
0
1
1
1
1
0
0
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
1
1
0
1
0
0
0
1
1
1
0
0
1
0
0
1
1
1
0
0
0
1
1
0
1
1
1
1
0
1
0
1
0
0
0
1
0
0
1
1
0
1
0
1
0
1
1
1
1
1
0
1
0
1
1
0
1
0
1
0
1
0
0
0
0
0
0
1
0
0
1
1
0
0
1
1
1
1
1
1
0
0
0
0
1
1
0
1
0
0
0
1
0
1
1
1
0
1
0
1
1
0
0
1
1
1
0
0
0
...

result:

ok 1481 numbers

Test #12:

score: 0
Accepted
time: 2ms
memory: 4104kb

input:

3000 3000
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 10...

output:

0
0
1
1
0
0
0
0
1
1
1
1
1
0
0
1
0
1
1
0
1
1
0
1
0
1
0
1
1
1
1
1
0
1
0
1
1
0
0
1
0
1
1
0
0
0
1
0
1
0
1
1
1
0
0
0
0
1
1
0
1
0
0
0
0
1
0
0
1
0
0
0
1
0
1
1
0
0
0
1
0
0
1
1
1
1
1
0
1
1
1
0
1
1
0
0
1
1
1
0
1
1
1
1
1
0
0
0
0
1
0
0
1
1
1
0
0
1
0
1
0
1
0
1
1
1
1
0
1
1
0
1
0
1
0
1
1
1
0
0
0
1
1
1
0
1
0
0
1
1
...

result:

ok 1541 numbers

Test #13:

score: 0
Accepted
time: 47ms
memory: 3616kb

input:

200 200000
1 2 3 3 5 3 1 6 2 9 11 5 5 2 4 9 17 8 1 4 10 20 18 20 23 13 16 28 15 4 6 27 26 11 30 25 10 2 13 23 25 35 4 8 40 43 36 26 7 27 45 35 14 31 54 45 9 8 9 54 16 32 62 9 29 2 43 39 34 39 27 2 52 56 6 9 48 26 66 28 35 57 79 13 71 61 38 43 80 26 61 26 79 1 24 64 79 15 41 42 56 55 6 24 92 43 89 76...

output:

0
0
0
0
1
1
1
1
1
0
0
1
1
0
1
0
0
0
0
0
1
0
0
0
0
1
1
0
1
1
0
1
0
0
1
1
1
1
1
0
0
0
0
1
1
1
0
1
1
1
1
1
0
0
0
0
0
1
1
0
1
1
1
1
1
1
0
0
0
0
1
1
0
1
0
0
0
0
0
1
1
0
0
1
1
1
1
0
1
0
0
1
0
1
0
0
1
0
1
0
1
1
1
0
0
1
0
1
1
1
1
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
1
1
1
0
1
1
0
0
0
1
1
1
1
0
0
1
0
0
1
0
1
0
0
...

result:

ok 100045 numbers

Test #14:

score: 0
Accepted
time: 55ms
memory: 3620kb

input:

200 200000
1 2 3 2 1 5 2 8 9 2 6 7 12 11 9 6 16 15 11 2 17 13 23 7 23 12 22 2 12 28 11 22 9 7 11 10 16 36 25 5 8 20 41 38 19 38 2 16 38 6 44 33 42 41 42 37 36 33 49 35 13 3 9 26 50 48 31 65 3 2 13 64 8 12 55 69 67 35 59 58 16 43 1 21 64 41 5 85 22 81 66 54 6 44 25 26 53 78 58 42 7 25 68 30 86 9 36 3...

output:

1
0
1
0
1
1
1
1
1
1
1
1
1
0
0
0
0
1
0
1
0
1
0
0
1
0
1
1
0
0
1
0
1
0
0
1
1
1
0
1
1
0
1
0
1
1
0
1
1
0
1
1
0
1
1
1
1
0
0
1
0
1
1
1
1
1
1
0
0
1
1
1
1
1
0
0
1
1
0
0
1
1
1
1
1
1
0
0
1
1
0
0
1
1
0
1
1
1
0
0
1
1
0
0
1
0
1
1
1
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
1
0
1
0
1
0
0
0
1
0
0
1
0
1
1
0
1
0
1
1
1
1
0
0
1
1
...

result:

ok 99983 numbers

Test #15:

score: 0
Accepted
time: 68ms
memory: 4008kb

input:

2000 200000
1 1 3 4 3 2 5 1 8 9 2 7 6 7 6 12 5 7 15 8 16 10 18 23 6 19 24 14 23 8 6 22 18 14 8 5 36 4 30 14 19 11 28 1 15 23 11 16 24 46 10 34 1 9 17 21 2 9 13 27 13 5 43 46 14 19 49 58 32 15 38 11 18 1 30 69 51 5 59 49 21 31 1 75 44 78 6 52 5 11 12 91 16 32 4 27 40 80 13 53 95 54 76 76 63 27 2 102 ...

output:

0
1
1
1
0
1
1
0
0
1
1
1
1
1
0
1
1
1
0
0
0
0
0
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
1
0
0
0
0
1
1
0
1
0
1
0
1
1
0
1
1
1
0
0
0
0
0
0
1
1
1
1
1
0
1
1
0
1
0
0
1
1
0
1
1
1
1
0
0
0
1
0
1
0
1
0
1
1
0
1
0
0
1
0
1
1
1
1
1
1
0
1
0
0
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
0
0
1
0
0
0
1
1
0
1
1
0
1
1
0
0
1
1
...

result:

ok 99757 numbers

Test #16:

score: 0
Accepted
time: 96ms
memory: 7712kb

input:

20000 200000
1 1 2 1 5 3 6 5 2 6 10 6 13 13 6 14 15 17 7 2 15 17 13 23 2 14 11 20 20 16 31 19 27 29 24 28 30 12 5 31 4 21 5 22 7 9 18 48 11 17 24 34 51 22 33 31 26 17 3 9 50 28 51 47 14 58 35 19 15 49 21 45 32 59 12 46 21 61 50 64 24 51 31 34 17 30 13 77 25 42 89 22 81 45 70 35 94 77 47 24 94 92 59 ...

output:

1
0
0
1
0
0
1
0
0
1
0
0
1
1
1
0
1
1
0
0
1
1
0
0
0
1
1
1
0
1
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
1
1
0
0
0
1
0
1
0
0
1
1
0
0
1
0
1
0
0
1
1
0
0
1
0
1
1
1
1
1
0
1
1
0
0
0
1
1
1
0
1
0
0
0
1
1
0
1
1
0
1
0
1
0
1
0
0
1
1
1
0
1
1
1
1
1
1
0
0
1
1
0
0
1
1
1
0
1
0
1
1
0
0
1
1
1
1
1
1
1
0
...

result:

ok 99952 numbers

Test #17:

score: 0
Accepted
time: 203ms
memory: 47116kb

input:

200000 200000
1 2 3 3 2 1 5 2 1 8 1 8 10 8 3 10 10 9 9 6 1 12 15 21 5 19 2 10 3 3 6 19 30 6 23 2 13 34 23 5 5 29 26 23 16 28 38 40 47 30 35 45 36 1 10 2 36 18 49 49 28 22 15 7 27 4 42 59 60 7 51 56 50 46 18 31 37 58 5 76 16 41 1 67 59 35 3 58 50 1 48 90 69 57 29 89 89 47 6 29 12 80 15 56 50 100 11 1...

output:

0
0
0
1
1
0
0
1
0
0
0
1
1
1
0
0
1
1
1
0
1
1
1
0
0
0
1
0
0
0
0
0
1
1
0
1
1
1
0
1
1
0
0
1
1
0
1
1
1
1
1
1
1
1
0
1
0
1
0
1
0
0
1
0
1
1
0
0
1
0
0
1
0
0
0
1
0
1
0
0
1
1
0
0
1
0
0
0
0
0
0
1
1
1
1
0
1
1
1
1
0
1
1
1
1
0
1
1
0
1
1
0
1
0
0
1
0
0
1
0
1
1
1
0
1
1
0
1
1
1
1
0
1
1
0
1
0
1
0
0
1
0
0
0
0
0
0
1
0
0
...

result:

ok 99519 numbers

Test #18:

score: 0
Accepted
time: 69ms
memory: 3560kb

input:

200 200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1
0
0
0
0
0
1
1
1
0
0
0
0
0
1
0
1
0
0
1
0
1
0
1
1
1
1
0
1
0
0
0
1
1
1
0
0
0
1
1
1
1
0
0
1
0
0
1
0
0
1
1
0
0
0
0
0
1
1
1
1
1
0
1
0
0
1
1
1
0
0
0
1
0
0
0
1
1
1
1
0
1
1
0
0
1
1
0
1
0
1
1
1
0
0
0
1
0
1
1
0
0
0
1
0
0
0
0
1
1
0
1
0
1
1
0
1
1
1
0
0
1
0
1
1
1
1
1
1
0
0
0
1
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
1
0
...

result:

ok 99788 numbers

Test #19:

score: 0
Accepted
time: 69ms
memory: 3616kb

input:

200 200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0
1
1
1
0
0
1
1
1
1
0
0
0
0
0
0
1
1
1
1
1
0
1
0
1
0
0
0
1
1
0
1
0
1
1
1
1
0
1
0
0
1
1
0
0
0
1
1
1
1
0
1
0
1
1
0
0
0
1
0
0
0
1
0
1
1
1
1
1
0
1
0
0
0
0
1
0
1
1
1
0
1
0
0
0
1
1
1
1
0
0
0
1
0
1
1
1
0
0
1
0
0
0
0
0
0
1
0
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
0
1
0
0
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
1
0
...

result:

ok 99818 numbers

Test #20:

score: 0
Accepted
time: 94ms
memory: 4004kb

input:

2000 200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

0
0
1
1
1
0
1
1
0
1
0
1
1
1
0
1
1
1
1
1
1
0
1
1
1
1
0
0
1
1
1
1
0
1
1
1
0
0
1
1
1
1
1
0
1
1
0
1
0
1
1
0
0
1
1
1
0
0
0
1
1
1
1
1
1
1
0
1
0
1
1
0
1
1
0
1
1
0
1
1
0
0
1
0
0
1
0
1
0
0
1
1
0
0
0
0
1
0
0
1
1
1
1
0
0
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
0
0
1
1
0
0
1
1
1
1
1
1
0
1
0
0
0
1
0
1
0
0
1
1
1
1
0
1
0
...

result:

ok 100002 numbers

Test #21:

score: 0
Accepted
time: 145ms
memory: 7464kb

input:

20000 200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
1
1
0
1
1
1
0
0
0
1
0
1
1
0
0
0
1
1
1
1
1
0
1
0
1
0
1
0
1
1
1
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
1
1
0
0
0
1
0
0
0
0
0
0
1
1
1
1
0
1
0
1
1
1
0
0
0
0
1
0
0
0
1
1
0
0
0
1
1
1
1
0
0
0
1
1
1
0
0
0
0
0
0
1
1
0
1
1
1
1
1
1
0
1
0
1
1
1
0
1
0
0
0
1
0
0
0
0
...

result:

ok 99886 numbers

Test #22:

score: 0
Accepted
time: 352ms
memory: 46260kb

input:

200000 200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1
1
0
1
1
0
1
0
0
0
0
1
0
1
1
1
1
1
0
1
1
0
0
0
0
1
0
0
0
1
1
0
0
1
1
1
0
1
0
1
0
0
1
0
0
0
1
1
1
0
1
1
0
1
0
0
0
0
1
1
1
0
0
1
1
0
0
1
0
0
1
0
1
0
0
1
0
0
0
0
1
0
1
0
1
1
0
0
1
0
0
0
1
0
0
0
0
1
0
0
1
0
0
1
0
1
0
0
0
1
1
1
0
0
0
0
0
0
0
1
1
0
1
1
0
1
1
0
1
1
1
0
1
1
0
1
0
0
1
0
1
0
1
0
1
1
1
0
1
0
...

result:

ok 100006 numbers

Test #23:

score: 0
Accepted
time: 345ms
memory: 46336kb

input:

200000 200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1
1
0
0
1
1
1
0
0
0
1
1
1
0
0
0
0
0
1
0
1
0
1
0
0
1
0
1
0
0
0
1
0
1
0
0
1
0
0
0
0
0
1
0
0
0
0
1
1
0
0
0
1
1
1
0
1
0
0
0
1
1
1
0
1
1
1
0
0
0
1
0
0
1
0
1
0
0
1
1
1
0
0
1
0
0
1
0
0
0
1
1
1
0
0
1
0
1
1
0
0
1
0
0
0
1
1
0
1
1
0
1
1
1
0
0
0
0
0
0
1
1
0
0
0
1
1
0
1
0
0
0
1
1
1
0
1
1
1
1
1
1
0
0
1
0
1
0
1
0
...

result:

ok 99439 numbers

Test #24:

score: 0
Accepted
time: 358ms
memory: 46140kb

input:

200000 200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1
1
1
1
1
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
0
1
1
0
0
1
1
0
1
1
1
1
1
0
0
0
0
1
0
0
1
0
0
1
0
1
1
1
0
0
1
1
1
0
1
1
1
1
0
1
0
0
1
1
0
0
1
0
1
0
1
1
0
1
0
0
1
1
0
0
0
0
1
1
0
1
1
0
1
0
1
1
0
1
1
1
0
1
1
0
0
1
0
0
1
1
1
0
0
0
0
1
0
0
1
0
1
1
1
1
0
0
1
1
1
0
1
0
0
1
0
0
1
0
1
1
0
1
0
...

result:

ok 100458 numbers

Test #25:

score: 0
Accepted
time: 331ms
memory: 46160kb

input:

200000 200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

0
1
1
1
1
0
1
1
1
0
1
1
0
1
0
0
1
0
0
1
0
1
0
1
0
0
0
0
0
0
1
1
1
1
1
1
0
1
1
0
1
0
0
1
0
0
1
0
1
1
1
0
1
0
0
0
0
1
0
1
1
0
0
1
1
0
1
1
0
1
0
1
0
1
1
0
1
1
0
0
1
0
1
0
1
1
1
0
1
1
1
1
0
0
1
1
0
0
1
1
0
0
0
1
1
1
0
0
0
1
0
0
0
0
0
0
1
1
1
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
1
1
0
0
1
0
1
0
0
1
0
0
0
1
1
0
...

result:

ok 100269 numbers

Test #26:

score: 0
Accepted
time: 39ms
memory: 3580kb

input:

200 200000
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 1...

output:

1
0
1
0
1
1
1
1
0
1
1
1
0
0
0
0
1
0
1
1
0
1
0
0
1
1
1
0
1
0
0
0
1
0
1
1
0
0
0
1
1
1
0
0
1
1
1
0
1
0
0
1
0
1
1
0
1
1
0
0
1
0
0
1
0
0
0
1
0
1
0
0
1
1
1
1
1
1
1
0
0
0
1
0
0
1
0
0
1
1
1
1
1
0
1
1
0
1
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
0
0
0
0
1
1
1
0
1
0
1
1
1
0
0
1
1
0
1
0
0
1
0
0
0
0
1
0
1
1
1
0
1
1
1
0
...

result:

ok 100455 numbers

Test #27:

score: 0
Accepted
time: 45ms
memory: 3688kb

input:

200 200000
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 1...

output:

0
1
0
0
1
0
0
0
0
0
1
1
0
0
1
1
0
0
1
1
0
1
1
0
1
0
0
0
0
1
1
1
0
0
1
0
1
1
1
1
0
0
0
1
1
0
1
1
0
0
0
1
0
1
0
0
1
0
1
1
0
0
0
0
1
1
0
1
0
1
0
1
1
1
0
0
0
1
0
1
0
1
1
1
1
0
1
0
0
0
1
0
0
0
1
1
0
0
1
0
1
0
1
1
0
0
0
1
0
0
0
1
0
0
1
1
1
0
1
0
1
1
1
1
0
0
1
1
1
1
0
1
1
1
1
1
1
0
0
0
0
1
0
0
1
1
1
1
0
0
...

result:

ok 99902 numbers

Test #28:

score: 0
Accepted
time: 49ms
memory: 4296kb

input:

2000 200000
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 ...

output:

0
0
1
0
0
1
0
0
0
0
0
0
1
0
0
0
0
1
0
1
1
0
1
0
1
0
1
0
1
0
1
1
1
1
0
0
0
0
0
0
1
0
0
0
1
0
1
0
1
1
0
0
1
0
1
1
0
0
1
0
0
1
0
0
1
1
1
1
0
1
0
0
0
1
0
0
0
1
1
0
0
1
1
0
0
0
1
1
0
0
0
0
1
1
0
0
1
1
0
0
0
0
0
0
1
1
1
0
1
0
0
0
0
1
0
0
1
1
1
1
0
0
0
0
1
1
1
0
1
0
0
1
0
0
0
0
1
0
1
1
0
0
1
0
0
1
0
1
1
1
...

result:

ok 99882 numbers

Test #29:

score: 0
Accepted
time: 58ms
memory: 9516kb

input:

20000 200000
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...

output:

0
0
0
0
1
0
0
0
1
0
0
1
0
1
1
1
0
1
0
0
0
1
0
0
1
0
1
0
0
1
1
1
1
0
0
1
1
1
0
1
1
0
1
1
0
0
0
0
1
0
1
0
1
1
0
0
0
1
0
0
1
1
1
1
1
0
0
1
1
1
1
1
1
1
0
1
0
0
1
1
0
0
0
1
0
1
1
1
1
0
1
0
1
0
1
0
0
1
0
0
1
1
0
0
0
1
1
0
0
0
1
0
1
0
1
1
0
1
0
1
0
0
1
1
1
1
1
0
1
1
0
1
0
0
1
1
1
0
1
0
1
0
1
0
0
1
0
1
0
1
...

result:

ok 100151 numbers

Test #30:

score: 0
Accepted
time: 115ms
memory: 67244kb

input:

200000 200000
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 9...

output:

0
0
1
0
1
1
1
0
0
1
0
1
0
0
1
0
1
1
1
1
0
0
1
0
1
1
0
1
1
0
0
1
1
0
0
1
0
1
1
1
1
0
0
1
0
0
0
1
1
0
0
1
1
1
0
0
0
0
0
0
0
1
1
1
1
0
0
1
0
0
1
1
0
1
0
1
0
0
1
1
1
0
1
0
0
0
0
0
0
1
1
0
1
0
1
1
0
1
0
1
1
0
1
0
1
0
1
1
1
1
1
1
1
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
1
0
1
0
1
1
1
0
0
1
0
1
0
0
1
1
0
0
1
0
0
0
...

result:

ok 100291 numbers

Test #31:

score: 0
Accepted
time: 113ms
memory: 67108kb

input:

200000 200000
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 9...

output:

0
1
1
0
0
0
0
1
1
0
0
1
0
1
1
1
1
1
1
0
1
0
0
0
1
0
0
1
1
1
0
0
1
0
0
0
1
0
0
1
1
0
1
1
1
0
1
0
1
1
1
1
0
1
0
1
1
0
0
0
0
1
0
0
0
1
0
0
1
1
0
1
0
1
1
1
0
1
1
1
1
0
1
0
1
1
1
1
0
0
1
0
0
1
0
1
1
0
1
1
1
0
0
1
1
1
0
0
0
1
0
0
1
1
0
1
0
1
1
0
1
0
0
1
0
0
1
1
0
1
0
1
1
0
1
0
1
0
1
0
0
0
0
1
0
0
1
1
1
1
...

result:

ok 100358 numbers

Test #32:

score: 0
Accepted
time: 124ms
memory: 67292kb

input:

200000 200000
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 9...

output:

1
0
0
1
1
0
1
0
1
1
1
0
0
1
1
1
1
0
1
0
1
0
0
0
0
0
0
1
1
0
0
1
0
0
1
0
0
0
1
0
1
0
0
0
1
1
0
1
1
1
0
1
1
1
0
1
0
1
0
0
1
1
0
1
0
0
0
0
1
1
0
0
0
0
0
1
1
0
1
0
0
0
1
1
0
1
0
0
1
1
0
1
0
0
1
1
1
1
0
1
0
1
1
0
1
1
0
0
1
1
0
0
1
0
1
0
0
0
1
0
1
1
1
0
1
0
1
0
1
1
0
0
0
1
1
0
1
1
1
1
0
1
1
0
1
0
0
1
0
0
...

result:

ok 66538 numbers

Test #33:

score: 0
Accepted
time: 360ms
memory: 46248kb

input:

200000 200000
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...

output:

0
0
0
1
0
0
0
0
1
1
1
1
0
1
1
0
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
1
1
1
0
0
0
0
0
1
0
0
0
0
0
1
0
1
1
0
0
0
1
1
0
1
1
0
1
1
1
1
0
1
1
0
1
1
1
1
1
0
0
0
0
1
0
0
0
0
0
1
1
1
1
1
1
0
1
0
0
1
1
0
1
0
1
1
1
1
0
0
0
1
0
1
1
1
1
0
1
0
0
0
1
0
0
1
1
1
1
1
1
0
1
0
1
0
0
1
0
1
0
1
1
0
0
0
1
1
0
0
0
1
1
0
1
1
1
0
...

result:

ok 20048 numbers

Test #34:

score: 0
Accepted
time: 127ms
memory: 56792kb

input:

200000 200000
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 9...

output:

0
0
1
0
0
0
1
0
0
0
0
1
0
1
0
1
1
1
1
0
0
1
0
1
1
1
0
0
0
0
0
1
0
1
0
0
1
1
1
0
1
1
0
0
0
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
1
1
0
0
0
1
0
1
0
0
0
1
0
0
0
0
1
1
1
1
1
0
0
0
0
1
1
1
0
0
1
0
0
0
1
1
1
1
0
0
0
1
0
1
1
1
1
1
0
1
1
1
0
1
0
0
0
1
1
0
0
0
1
1
0
1
1
0
1
0
1
1
0
1
0
1
1
1
1
0
0
1
0
1
0
1
0
0
...

result:

ok 66294 numbers

Test #35:

score: 0
Accepted
time: 45ms
memory: 3576kb

input:

200 200000
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 1...

output:

1
1
1
1
1
1
0
1
1
0
0
0
1
0
1
0
1
1
1
0
0
1
0
1
0
0
1
1
0
1
0
1
1
0
0
0
0
1
1
1
0
0
1
0
0
1
1
0
1
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
1
0
0
0
0
1
1
1
0
1
0
1
1
1
1
0
1
0
0
0
0
0
1
1
0
1
1
1
0
0
1
1
0
0
1
0
0
0
1
1
1
1
0
1
1
1
0
1
1
0
0
1
0
0
1
1
1
1
1
1
1
1
1
1
0
0
0
1
0
0
1
1
0
1
1
0
1
1
1
0
1
0
...

result:

ok 100092 numbers

Test #36:

score: 0
Accepted
time: 49ms
memory: 3952kb

input:

2000 200000
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 ...

output:

0
0
0
1
1
1
1
1
0
1
0
1
1
0
1
1
1
0
1
0
0
0
1
1
0
0
1
0
0
0
0
0
1
0
1
1
1
0
0
1
1
0
0
1
0
0
0
1
0
1
0
1
0
0
0
0
0
1
1
1
0
0
0
0
1
0
1
1
1
0
1
0
1
0
0
0
0
1
1
1
0
0
0
0
1
1
0
0
1
0
1
0
0
1
0
0
1
1
1
0
1
0
1
0
0
1
1
0
1
0
1
1
0
0
0
1
1
0
0
0
1
1
1
0
1
0
1
0
1
0
1
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1
0
1
0
...

result:

ok 100456 numbers

Test #37:

score: 0
Accepted
time: 58ms
memory: 9580kb

input:

20000 200000
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...

output:

1
0
0
1
1
0
0
1
1
0
1
0
0
1
1
0
0
1
0
1
0
0
0
1
1
0
1
1
0
1
0
1
1
0
1
1
1
1
1
1
0
0
0
1
1
1
1
0
0
1
1
0
1
1
0
0
1
1
1
0
1
1
1
0
0
1
0
0
1
1
0
1
0
0
0
1
1
0
1
0
1
0
0
0
1
0
1
1
0
0
1
0
0
0
1
1
0
0
1
1
0
1
0
1
0
0
0
1
1
1
1
1
1
0
1
1
1
0
1
1
1
0
1
0
1
0
1
1
0
1
0
1
1
0
0
1
0
1
0
0
1
0
1
0
1
1
1
1
1
1
...

result:

ok 100428 numbers

Test #38:

score: 0
Accepted
time: 116ms
memory: 67128kb

input:

200000 200000
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 9...

output:

1
0
0
0
1
1
1
1
0
1
0
0
1
0
1
0
1
0
0
1
1
1
0
1
0
0
0
0
1
0
1
1
0
1
1
0
1
1
0
0
0
1
1
1
0
0
1
0
0
0
0
1
0
1
0
0
1
1
0
0
0
1
1
1
0
1
1
1
0
1
1
0
1
1
1
1
0
1
1
0
1
1
0
1
0
0
1
1
1
0
0
0
0
0
0
1
0
0
1
1
0
1
1
1
0
0
1
0
1
1
1
0
1
1
0
0
1
1
0
0
0
1
0
1
0
0
1
0
1
1
1
0
1
0
1
1
1
0
0
1
1
1
0
0
1
0
1
1
0
1
...

result:

ok 99950 numbers

Test #39:

score: 0
Accepted
time: 112ms
memory: 67308kb

input:

200000 200000
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 9...

output:

1
0
0
0
1
0
0
1
0
1
1
1
0
1
1
0
1
1
1
1
0
1
1
0
1
1
1
0
0
0
1
1
1
0
0
1
1
1
0
1
0
0
0
1
1
1
0
0
0
0
1
0
0
0
1
0
1
0
1
0
1
1
1
0
0
0
1
0
0
1
1
1
1
0
1
0
1
0
0
0
1
1
1
0
1
1
0
1
1
1
1
1
1
0
1
0
0
0
0
0
1
1
1
0
1
1
0
0
1
1
0
0
0
0
0
1
0
0
1
0
0
0
1
1
1
1
1
0
0
0
0
1
0
0
1
0
0
1
0
0
0
0
1
1
0
0
1
1
0
1
...

result:

ok 99920 numbers

Test #40:

score: 0
Accepted
time: 115ms
memory: 67304kb

input:

200000 200000
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 9...

output:

0
0
0
0
1
1
0
1
0
1
1
1
1
1
1
0
1
0
1
0
1
0
0
0
1
1
1
1
0
1
0
0
1
0
1
0
0
0
1
0
0
1
0
0
0
0
0
1
0
1
1
0
1
1
0
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
1
1
0
0
1
0
1
1
1
1
0
1
1
1
1
0
0
1
0
1
1
0
0
0
1
0
1
0
0
1
0
1
1
1
0
0
0
1
0
0
0
0
1
1
0
1
1
0
0
1
1
0
0
1
1
1
1
0
1
1
0
1
1
0
0
1
0
1
1
1
1
1
0
...

result:

ok 100012 numbers

Test #41:

score: 0
Accepted
time: 39ms
memory: 3692kb

input:

200 200000
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 1...

output:

0
1
0
0
0
1
0
1
1
1
0
0
1
1
1
1
0
0
1
1
1
0
0
0
0
1
1
1
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
1
0
0
1
1
0
0
1
0
1
1
0
1
1
0
1
1
1
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
1
1
1
1
1
0
0
0
1
0
1
0
1
0
1
1
1
0
1
1
0
0
1
1
0
1
0
1
1
1
0
0
1
1
1
1
1
1
1
1
1
0
1
0
0
1
0
1
0
1
1
1
0
1
0
1
0
0
1
1
0
1
1
1
0
1
1
1
0
1
1
1
1
0
...

result:

ok 99885 numbers

Test #42:

score: 0
Accepted
time: 377ms
memory: 46704kb

input:

200000 200000
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...

output:

1
1
1
1
1
1
1
1
0
0
0
0
0
1
1
1
1
1
1
0
0
0
1
0
1
0
0
0
0
0
1
0
0
1
0
0
0
1
1
1
0
1
0
1
1
1
0
1
0
0
0
0
0
0
1
0
1
1
1
1
1
0
0
0
1
1
1
1
1
1
1
0
0
0
1
1
1
1
1
0
1
1
0
0
1
0
0
1
1
1
0
0
0
0
1
0
1
0
1
0
1
1
0
1
0
0
0
0
1
1
1
1
1
0
1
0
1
1
0
0
0
0
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
1
0
0
1
1
0
1
0
0
...

result:

ok 20265 numbers

Test #43:

score: 0
Accepted
time: 343ms
memory: 46324kb

input:

200000 200000
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...

output:

1
0
0
0
0
0
0
1
1
0
0
1
0
0
1
0
1
1
0
1
0
0
1
1
1
1
0
1
1
1
0
0
1
1
0
0
0
0
0
1
1
1
1
1
0
1
0
0
0
1
0
0
0
1
1
1
0
0
0
1
0
1
0
1
0
1
0
0
1
1
0
1
0
1
1
1
1
1
1
1
1
0
1
0
0
1
0
1
1
0
0
1
0
0
1
1
0
1
1
1
0
0
0
1
1
0
0
0
0
0
1
0
1
1
1
0
1
1
1
1
0
1
1
0
1
1
0
1
0
1
1
1
0
1
1
0
1
1
0
0
1
0
1
0
1
0
0
1
1
1
...

result:

ok 20034 numbers

Test #44:

score: 0
Accepted
time: 337ms
memory: 46436kb

input:

200000 200000
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...

output:

1
0
0
0
1
0
1
0
0
1
1
1
0
1
0
1
0
0
0
0
1
0
1
1
1
0
0
0
1
0
0
0
0
0
1
0
1
1
0
0
0
0
1
1
0
1
0
0
0
1
0
1
0
0
1
0
0
1
0
1
1
1
0
0
0
1
0
0
1
1
0
1
0
0
1
1
1
1
1
1
1
1
1
0
1
0
1
0
0
1
1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
1
1
0
1
1
0
1
0
0
0
1
0
1
1
0
0
1
0
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
1
1
0
0
1
0
1
1
0
0
1
...

result:

ok 20016 numbers

Test #45:

score: 0
Accepted
time: 278ms
memory: 46644kb

input:

200000 200000
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 5...

output:

1
0
0
0
0
0
1
0
1
1
1
0
1
1
1
1
0
0
1
1
0
0
0
1
0
0
1
0
1
1
1
1
0
1
0
0
0
0
1
0
1
1
1
0
0
0
1
0
0
1
1
0
1
0
0
0
1
1
1
0
0
0
1
0
1
0
0
0
0
0
1
0
1
0
0
1
1
0
0
1
0
1
0
1
1
1
0
1
1
0
0
1
1
0
0
1
1
1
0
1
0
0
1
0
1
1
1
1
0
1
0
0
1
0
1
1
0
1
1
0
1
0
0
0
1
0
1
1
0
1
0
0
0
1
0
1
0
0
1
1
1
0
0
1
1
1
0
0
0
1
...

result:

ok 20088 numbers

Extra Test:

score: 0
Extra Test Passed