Problem:
D: 場所当てゲーム
問題
AORイカちゃん と そすうさ がグラフを使った場所当てゲームを行う．
最初に，AORイカちゃん が整数 $N$ を指定し，そすうさ は頂点数 $N$ の無向グラフを生成する．
		$N$ 個の頂点には， $1$ ~ $N$ までの番号が割り振られている．この無向グラフを使って，$K$ 回ゲームを行う．
各ゲームのはじめに AORイカちゃん は頂点を $1$ つ選び，そすうさ がその頂点を当てる．
そすうさ は AORイカちゃん に最大 $10$ 回まで質問することができる．
		そすうさ が頂点番号を $1$ つ AORイカちゃん に伝えると，番号に従い AORイカちゃん は以下のうちどれかを答える．
AORイカちゃん の返事
意味
Yes
その頂点が当たり
Near
Yesではなく，その頂点に隣接する頂点が当たり
No
それ以外
$K$ 回のゲーム全てで $10$ 回以内に頂点を当てることができれば，そすうさ の勝ちである．
		どうしても勝ちたい そすうさ は，あなたに絶対に勝てるプログラムの作成をお願いしてきた．
入出力
まず，以下の形式で頂点数 $N$ とゲーム回数 $K$ が与えられる．
$N\ K$
次に，生成した無向グラフを以下の形式で出力する．
$M$
$a_{1} b_{1}$
$\vdots$
$a_{M} b_{M}$
ここで、 $M$ は生成した無向グラフの辺の本数であり, $a_i$, $b_i$ はグラフの $i$ 本目の辺が頂点 $a_i$ と頂点 $b_i$ を繋いでいることを示す.
なお, 生成する無向グラフは $ 0 \leq M \leq \frac{N(N-1)}{2}$ かつ $1 \leq a_i, b_i \leq N$ を満たさなければならない.
続いて，あなたのプログラムは何回か応答プログラムに質問をする．質問のフォーマットは以下のとおりである．
Num
$Num$ は $1$ 以上 $N$ 以下の頂点番号である．
		この質問で，'Yes'，'Near'，'No'のうち，どれかが標準入力に $1$ 行で渡される．
'Yes'が渡されれば勝利となり，$1$ 回のゲームが終了する．
$1$ 回のゲームが終了したら，すぐに次のゲームが始まることに注意せよ．
各ゲーム最大 $10$ 回以内の質問で勝利しなければいけない．
このゲームを $K$ 回行い，すべてのゲームで勝利すれば正答となる．
ゲームが終了した後，あなたのプログラムは直ちに終了しなければならない．終了しなかった場合のジャッジ結果は不定である．
		また，これら以外のフォーマットで出力した場合のジャッジ結果も不定である．
なお，グラフの情報や質問を応答プログラムに送ったあとフラッシュしないとTLEとなることがある．
フラッシュはCでは
fflush(stdout);
C++では
std::cout << endl;
で行うことができる．
		  fflush() は stdio.h をインクルードすると使用できる．
制約
$1 \leq N, K \leq 200$
入出力例
プログラムへの入力
プログラムの出力
3 2
2
1 2
2 3
1
No
3
Yes
2
Near
3
No
1
Yes

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;

enum {
    No,
    Near,
    Yes
};

int query(int n) {
    cout << n << endl;
    string r; cin >> r;
    if(r == "Yes") return Yes;
    else if(r == "No") return No;
    return Near;
}

int main() {
    int n, k; cin >> n >> k;

    vector<pii> es;
    function<void(int, int)> create = [&] (int i, int w) {
        if(i >= n || w <= 1) return;
        for(int j = i + 1; j < min(i + w, n); ++j) {
            es.emplace_back(i + 1, j + 1);
        }
        int tw = w / 2;
        int ii = i + 1;
        while(tw >= 2) {
            create(ii, tw);
            ii += tw;
            tw = (tw + 1) / 2;
        }
    };
    create(0, n);
    cout << es.size() << endl;
    for(auto const& p : es) {
        cout << p.first << " " << p.second << endl;
    }

    while(k--) {
        function<int(int, int)> solve = [&] (int i, int w) {
            auto r = query(i + 1);
            if(r == Yes) return Yes;
            if(r == No) return No;
            int ii = i + 1, tw = w / 2;
            while(tw >= 1) {
                r = solve(ii, tw);
                if(r == Yes) return Yes;
                ii += tw;
                tw = (tw + 1) / 2;
            }
            assert(false);
        };
        solve(0, n);
    }
}
accuracy: 1
time_ms: 70
memory_kb: 3568
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep3(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define rep2(i, a, b) rep3(i, a, b, 1)
#define rep1(i, n) rep2(i, 0, n)
#define rep0(n) rep1(aaaaa, n)
#define ov4(a, b, c, d, name, ...) name
#define rep(...) ov4(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__)
#define per(i, a, b) for (ll i = (a) - 1; i >= (b); i--)
#define fore(e, v) for (auto&& e : v)
#define all(a) begin(a), end(a)
#define sz(a) (int)(size(a))
#define lb(v, x) (lower_bound(all(v), x) - begin(v))
#define eb emplace_back

template <typename T, typename S>
bool chmin(T& a, const S& b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
bool chmax(T& a, const S& b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 1e9 + 100;
const ll INFL = 3e18 + 100;
#define i128 __int128_t
struct _ {
  _() { cin.tie(0)->sync_with_stdio(0), cout.tie(0); }
} __;


int main(){
  int N,K;
  cin>>N>>K;
  vector<pii> E;
  rep(i,1,N+1){
    if((i&-i)==i)continue;
    rep(j,10){
      if(i>>j&1){
        E.eb(pii{(1<<j),i});
      }
    }
  }
  cout<<sz(E)<<'\n';
  fore(i,E){
    cout<<i.first<<' '<<i.second<<endl;
  }
  while(K--){
    int t=1,ans=0;
    bool ok=0;
    while(t<=N){
      cout<<t<<endl;
      string res;
      cin>>res;
      if(res=="Yes"){
        ok=1;
        break;
      }
      if(res=="Near")ans|=t;
      t*=2;
    }
    if(!ok){
      cout<<ans<<endl;
      string res;
      cin>>res;
    }
  }
}
accuracy: 1
time_ms: 50
memory_kb: 3712
final_rank: 1

code_snippet: #define _USE_MATH_DEFINES  // M_PI等のフラグ
#include <bits/stdc++.h>
#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define intceil(a,b) ((a+(b-1))/(b))
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long,long>;
const long long INF = LONG_LONG_MAX - 1001001001001001;
void chmax(ll& x, ll y) { x = max(x,y); }
void chmin(ll& x, ll y) { x = min(x,y); }
string vs = "URDL";  // 上右下左
vector<ll> vy = { -1, 0, 1, 0 };
vector<ll> vx = { 0, 1, 0, -1 };


void solve() {
    ll N, K; cin >> N >> K;
    vector<vector<ll>> G(N);

    // 二分探索できるグラフを作る
    auto dfs = [&](auto dfs, ll left, ll right) {
        // 終了条件
        if (right-left <= 1) return;

        // 次の探索
        ll mid = (left+right)/2;
        for(ll i=mid+1; i<right; i++) G[mid].push_back(i);
        dfs(dfs, left, mid);
        dfs(dfs, mid, right);
    };
    dfs(dfs, 0, N);

    // グラフを出力する
    ll M = 0;
    for(ll i=0; i<N; i++) M += (ll)G[i].size();
    cout << M << endl;
    for(ll u=0; u<N; u++) {
        for(ll v: G[u]) cout << u+1 << " " << v+1 << endl;
    }

    // クエリ処理
    for(ll k=0; k<K; k++) {
        ll l=0, r=N;
        while(true) {
            ll mid = (l+r)/2;
            cout << mid+1 << endl;
            string res; cin >> res;
            if (res == "Yes") break;
            else if (res == "Near") l = mid;
            else r = mid;
        }
    }
}


int main() {
    solve();
    return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 3592
final_rank: 2

code_snippet: #pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <sstream>
#include <utility>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <array>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline ll time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

void solve(int n){
    int u = 0;
    for(int i=0;;i++){
        if((1<<i) <= n){
            cout << (1<<i) << endl;
            string s; cin >> s;
            if(s == "Yes") return;
            if(s == "Near") u |= (1<<i);
        }
        else break;
    }
    cout << u << endl;
    string s; cin >> s;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int q; cin >> q;
    vector<pair<int,int>> v;
    for(int i=1;i<=n;i++){
        for(int j=0;j<10;j++){
            if((1<<j) == i)continue;
            if((1<<j)&i){
                v.push_back({i,1<<j});
            }
        }
    }
    cout << v.size() << endl;
    for(auto p:v){
        cout << p.first << " " << p.second << endl;
    }
    while(q--){
        solve(n);
    }
}
accuracy: 1
time_ms: 70
memory_kb: 3564
final_rank: 3

code_snippet: #line 1 "/home/yuruhiya/programming/library/template14.cpp"
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rfor(i, m, n) for (int i = (m); i >= (n); --i)
#define unless(c) if (!(c))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define range_it(a, l, r) (a).begin() + (l), (a).begin() + (r)

using namespace std;
using ll = long long;
using LD = long double;
using VB = vector<bool>;
using VVB = vector<VB>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VS = vector<string>;
using VD = vector<LD>;
using PII = pair<int, int>;
using VP = vector<PII>;
using PLL = pair<ll, ll>;
using VPL = vector<PLL>;
template <class T> using PQ = priority_queue<T>;
template <class T> using PQS = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1e9;
constexpr long long inf_ll = 1e18, MOD = 1000000007;
constexpr long double PI = M_PI, EPS = 1e-12;

// --- input --- //
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#define fwrite_unlocked fwrite
#define fflush_unlocked fflush
#endif
class Input {
	static int gc() {
		return getchar_unlocked();
	}
	template <class T> static void i(T& v) {
		cin >> v;
	}
	static void i(char& v) {
		while (isspace(v = gc()))
			;
	}
	static void i(bool& v) {
		v = in<char>() != '0';
	}
	static void i(string& v) {
		v.clear();
		char c;
		for (i(c); !isspace(c); c = gc()) v += c;
	}
	static void i(int& v) {
		bool neg = false;
		v = 0;
		char c;
		i(c);
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c); c = gc()) v = v * 10 + (c - '0');
		if (neg) v = -v;
	}
	static void i(long long& v) {
		bool neg = false;
		v = 0;
		char c;
		i(c);
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c); c = gc()) v = v * 10 + (c - '0');
		if (neg) v = -v;
	}
	static void i(double& v) {
		double dp = 1;
		bool neg = false, adp = false;
		v = 0;
		char c;
		i(c);
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c) || c == '.'; c = gc()) {
			if (c == '.')
				adp = true;
			else if (adp)
				v += (c - '0') * (dp *= 0.1);
			else
				v = v * 10 + (c - '0');
		}
		if (neg) v = -v;
	}
	static void i(long double& v) {
		long double dp = 1;
		bool neg = false, adp = false;
		v = 0;
		char c;
		i(c);
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c) || c == '.'; c = gc()) {
			if (c == '.')
				adp = true;
			else if (adp)
				v += (c - '0') * (dp *= 0.1);
			else
				v = v * 10 + (c - '0');
		}
		if (neg) v = -v;
	}
	template <class T, class U> static void i(pair<T, U>& v) {
		i(v.first);
		i(v.second);
	}
	template <class T> static void i(vector<T>& v) {
		for (auto& e : v) i(e);
	}
	struct InputV {
		int n, m;
		InputV(int _n) : n(_n), m(0) {}
		InputV(const pair<int, int>& nm) : n(nm.first), m(nm.second) {}
		template <class T> operator vector<T>() {
			vector<T> v(n);
			i(v);
			return v;
		}
		template <class T> operator vector<vector<T>>() {
			vector<vector<T>> v(n, vector<T>(m));
			i(v);
			return v;
		}
	};

public:
	static string read_line() {
		string v;
		char c;
		for (i(c); c != '\n' && c != '\0'; c = gc()) v += c;
		return v;
	}
	template <class T> static T in() {
		T v;
		i(v);
		return v;
	}
	template <class T> operator T() const {
		return in<T>();
	}
	int operator--(int) const {
		return in<int>() - 1;
	}
	InputV operator[](int n) const {
		return InputV(n);
	}
	InputV operator[](const pair<int, int>& n) const {
		return InputV(n);
	}
	void operator()() const {}
	template <class H, class... T> void operator()(H&& h, T&&... t) const {
		i(h);
		operator()(forward<T>(t)...);
	}
} in;
#define input(T) Input::in<T>()
#define INT input(int)
#define LL input(long long)
#define STR input(string)
#define inputs(T, ...) \
	T __VA_ARGS__;     \
	in(__VA_ARGS__)
#define ini(...) inputs(int, __VA_ARGS__)
#define inl(...) inputs(long long, __VA_ARGS__)
#define ins(...) inputs(string, __VA_ARGS__)

// --- output --- //
struct BoolStr {
	const char *t, *f;
	BoolStr(const char* _t, const char* _f) : t(_t), f(_f) {}
} Yes("Yes", "No"), yes("yes", "no"), YES("YES", "NO"), Int("1", "0");
struct DivStr {
	const char *d, *l;
	DivStr(const char* _d, const char* _l) : d(_d), l(_l) {}
} spc(" ", "\n"), no_spc("", "\n"), end_line("\n", "\n"), comma(",", "\n"),
    no_endl(" ", "");
class Output {
	BoolStr B{Yes};
	DivStr D{spc};
	void p(int v) const {
		if (v < 0) putchar_unlocked('-'), v = -v;
		char b[10];
		int i = 0;
		while (v) b[i++] = '0' + v % 10, v /= 10;
		if (!i) b[i++] = '0';
		while (i--) putchar_unlocked(b[i]);
	}
	void p(long long v) const {
		if (v < 0) putchar_unlocked('-'), v = -v;
		char b[20];
		int i = 0;
		while (v) b[i++] = '0' + v % 10, v /= 10;
		if (!i) b[i++] = '0';
		while (i--) putchar_unlocked(b[i]);
	}
	void p(bool v) const {
		p(v ? B.t : B.f);
	}
	void p(char v) const {
		putchar_unlocked(v);
	}
	void p(const char* v) const {
		fwrite_unlocked(v, 1, strlen(v), stdout);
	}
	void p(double v) const {
		printf("%.20f", v);
	}
	void p(long double v) const {
		printf("%.20Lf", v);
	}
	template <class T> void p(const T& v) const {
		cout << v;
	}
	template <class T, class U> void p(const pair<T, U>& v) const {
		p(v.first);
		p(D.d);
		p(v.second);
	}
	template <class T> void p(const vector<T>& v) const {
		rep(i, sz(v)) {
			if (i) p(D.d);
			p(v[i]);
		}
	}
	template <class T> void p(const vector<vector<T>>& v) const {
		rep(i, sz(v)) {
			if (i) p(D.l);
			p(v[i]);
		}
	}

public:
	Output& operator()() {
		p(D.l);
		return *this;
	}
	template <class H> Output& operator()(H&& h) {
		p(h);
		p(D.l);
		return *this;
	}
	template <class H, class... T> Output& operator()(H&& h, T&&... t) {
		p(h);
		p(D.d);
		return operator()(forward<T>(t)...);
	}
	template <class It> Output& range(const It& l, const It& r) {
		for (It i = l; i != r; i++) {
			if (i != l) p(D.d);
			p(*i);
		}
		p(D.l);
		return *this;
	}
	template <class T> Output& range(const T& a) {
		range(a.begin(), a.end());
		return *this;
	}
	template <class... T> void exit(T&&... t) {
		operator()(forward<T>(t)...);
		std::exit(EXIT_SUCCESS);
	}
	Output& flush() {
		fflush_unlocked(stdout);
		return *this;
	}
	Output& set(const BoolStr& b) {
		B = b;
		return *this;
	}
	Output& set(const DivStr& d) {
		D = d;
		return *this;
	}
	Output& set(const char* t, const char* f) {
		B = BoolStr(t, f);
		return *this;
	}
} out;

// --- step --- //
template <class T> struct Step {
	class It {
		T a, b, c;

	public:
		constexpr It() : a(T()), b(T()), c(T()) {}
		constexpr It(T _b, T _c, T _s) : a(_b), b(_c), c(_s) {}
		constexpr It& operator++() {
			--b;
			a += c;
			return *this;
		}
		constexpr It operator++(int) {
			It tmp = *this;
			--b;
			a += c;
			return tmp;
		}
		constexpr const T& operator*() const {
			return a;
		}
		constexpr const T* operator->() const {
			return &a;
		}
		constexpr bool operator==(const It& i) const {
			return b == i.b;
		}
		constexpr bool operator!=(const It& i) const {
			return !(b == i.b);
		}
		constexpr T start() const {
			return a;
		}
		constexpr T count() const {
			return b;
		}
		constexpr T step() const {
			return c;
		}
	};
	constexpr Step(T b, T c, T s) : be(b, c, s) {}
	constexpr It begin() const {
		return be;
	}
	constexpr It end() const {
		return en;
	}
	constexpr T start() const {
		return be.start();
	}
	constexpr T count() const {
		return be.count();
	}
	constexpr T step() const {
		return be.step();
	}
	constexpr T sum() const {
		return start() * count() + step() * (count() * (count() - 1) / 2);
	}
	operator vector<T>() const {
		return to_a();
	}
	template <class F> void each(const F& f) const {
		for (T i : *this) f(i);
	}
	auto to_a() const {
		vector<T> res;
		res.reserve(count());
		each([&](T i) { res.push_back(i); });
		return res;
	}
	template <class F, class U = decay_t<result_of_t<F(T)>>> auto map(const F& f) const {
		vector<U> res;
		res.reserve(count());
		each([&](T i) { res.push_back(f(i)); });
		return res;
	}
	template <class F> auto select(const F& f) const {
		vector<T> res;
		each([&](T i) {
			if (f(i)) res.push_back(i);
		});
		return res;
	}
	template <class F> int count_if(const F& f) const {
		int res = 0;
		each([&](T i) {
			if (f(i)) ++res;
		});
		return res;
	}
	template <class F> T find_if(const F& f) const {
		for (T i : *this)
			if (f(i)) return i;
		return 0;
	}
	template <class F> auto max_by(const F& f) const {
		auto v = map(f);
		return *max_element(v.begin(), v.end());
	}
	template <class F> auto min_by(const F& f) const {
		auto v = map(f);
		return *min_element(v.begin(), v.end());
	}
	template <class F> bool all_of(const F& f) const {
		for (T i : *this)
			if (!f(i)) return false;
		return true;
	}
	template <class F> bool any_of(const F& f) const {
		for (T i : *this)
			if (f(i)) return true;
		return false;
	}
	template <class F, class U = decay_t<result_of_t<F(T)>>> auto sum(const F& f) const {
		U res = 0;
		each([&](T i) { res += static_cast<U>(f(i)); });
		return res;
	}
	using value_type = T;
	using iterator = It;

private:
	It be, en;
};
template <class T> constexpr auto step(T a) {
	return Step<T>(0, a, 1);
}
template <class T> constexpr auto step(T a, T b) {
	return Step<T>(a, b - a, 1);
}
template <class T> constexpr auto step(T a, T b, T c) {
	return Step<T>(a, a < b ? (b - a - 1) / c + 1 : 0, c);
}

// --- functions --- //
inline namespace {
	template <class T> void Sort(T& a) {
		sort(all(a));
	}
	template <class T> void RSort(T& a) {
		sort(rall(a));
	}
	template <class T, class F> void Sort(T& a, const F& f) {
		sort(all(a), f);
	}
	template <class T, class F> void RSort(T& a, const F& f) {
		sort(rall(a), f);
	}
	template <class T> T Sorted(T a) {
		Sort(a);
		return a;
	}
	template <class T> T RSorted(T a) {
		RSort(a);
		return a;
	}
	template <class T, class F> T Sorted(T& a, const F& f) {
		Sort(a, f);
		return a;
	}
	template <class T, class F> T RSorted(T& a, const F& f) {
		RSort(a, f);
		return a;
	}
	template <class T, class F> void SortBy(T& a, const F& f) {
		sort(all(a), [&](const auto& x, const auto& y) { return f(x) < f(y); });
	}
	template <class T, class F> void RSortBy(T& a, const F& f) {
		sort(rall(a), [&](const auto& x, const auto& y) { return f(x) < f(y); });
	}
	template <class T> void Reverse(T& a) {
		reverse(all(a));
	}
	template <class T> void Unique(T& a) {
		a.erase(unique(all(a)), a.end());
	}
	template <class T> void Uniq(T& a) {
		Sort(a);
		Unique(a);
	}
	template <class T> void Rotate(T& a, int left) {
		rotate(a.begin(), a.begin() + left, a.end());
	}
	template <class T> T Reversed(T a) {
		Reverse(a);
		return a;
	}
	template <class T> T Uniqued(T a) {
		Unique(a);
		return a;
	}
	template <class T> T Uniqed(T a) {
		Uniq(a);
		return a;
	}
	template <class T> T Rotated(T a, int left) {
		Rotate(a, left);
		return a;
	}
	template <class T> auto Max(const T& a) {
		return *max_element(all(a));
	}
	template <class T> auto Min(const T& a) {
		return *min_element(all(a));
	}
	template <class T> int MaxPos(const T& a) {
		return max_element(all(a)) - a.begin();
	}
	template <class T> int MinPos(const T& a) {
		return min_element(all(a)) - a.begin();
	}
	template <class T, class F> auto MaxBy(const T& a, const F& f) {
		return *max_element(all(a),
		                    [&](const auto& x, const auto& y) { return f(x) < f(y); });
	}
	template <class T, class F> auto MinBy(const T& a, const F& f) {
		return *min_element(all(a),
		                    [&](const auto& x, const auto& y) { return f(x) < f(y); });
	}
	template <class T, class F> auto MaxOf(const T& a, const F& f) {
		return Max(Map(a, f));
	}
	template <class T, class F> auto MinOf(const T& a, const F& f) {
		return Min(Map(a, f));
	}
	template <class T, class U> int Count(const T& a, const U& v) {
		return count(all(a), v);
	}
	template <class T, class F> int CountIf(const T& a, const F& f) {
		return count_if(all(a), f);
	}
	template <class T, class U> int Find(const T& a, const U& v) {
		return find(all(a), v) - a.begin();
	}
	template <class T, class F> int FindIf(const T& a, const F& f) {
		return find_if(all(a), f) - a.begin();
	}
	template <class T, class U = typename T::value_type> U Sum(const T& a) {
		return accumulate(all(a), U());
	}
	template <class T, class U> bool Includes(const T& a, const U& v) {
		return find(all(a), v) != a.end();
	}
	template <class T, class F> auto Sum(const T& v, const F& f) {
		return accumulate(next(v.begin()), v.end(), f(*v.begin()),
		                  [&](auto a, auto b) { return a + f(b); });
	}
	template <class T, class U> int Lower(const T& a, const U& v) {
		return lower_bound(all(a), v) - a.begin();
	}
	template <class T, class U> int Upper(const T& a, const U& v) {
		return upper_bound(all(a), v) - a.begin();
	}
	template <class T, class F> void RemoveIf(T& a, const F& f) {
		a.erase(remove_if(all(a), f), a.end());
	}
	template <class F> auto Vector(size_t size, const F& f) {
		vector<decay_t<result_of_t<F(size_t)>>> res(size);
		for (size_t i = 0; i < size; ++i) res[i] = f(i);
		return res;
	}
	template <class T> auto Grid(size_t h, size_t w, const T& v = T()) {
		return vector<vector<T>>(h, vector<T>(w, v));
	}
	template <class T> auto Slice(const T& v, size_t i, size_t len) {
		return i < v.size() ? T(v.begin() + i, v.begin() + min(i + len, v.size())) : T();
	}
	template <class T, class F> auto Each(const T& v, F&& f) {
		for (auto& i : v) f(i);
	}
	template <class T, class F> auto Select(const T& v, const F& f) {
		T res;
		for (const auto& e : v)
			if (f(e)) res.push_back(e);
		return res;
	}
	template <class T, class F> auto Map(const T& v, F&& f) {
		vector<decay_t<result_of_t<F(typename T::value_type)>>> res(v.size());
		size_t i = 0;
		for (const auto& e : v) res[i++] = f(e);
		return res;
	}
	template <class T, class F> auto MapIndex(const T& v, const F& f) {
		vector<decay_t<result_of_t<F(size_t, typename T::value_type)>>> res(v.size());
		size_t i = 0;
		for (auto it = v.begin(); it != v.end(); ++it, ++i) res[i] = f(i, *it);
		return res;
	}
	template <class T, class F> auto TrueIndex(const T& v, const F& f) {
		vector<size_t> res;
		for (size_t i = 0; i < v.size(); ++i)
			if (f(v[i])) res.push_back(i);
		return res;
	}
	template <class T, class U = typename T::value_type> auto Indexed(const T& v) {
		vector<pair<U, int>> res(v.size());
		for (int i = 0; i < (int)v.size(); ++i)
			res[i] = make_pair(static_cast<U>(v[i]), i);
		return res;
	}
	auto operator*(string s, size_t n) {
		string res;
		for (size_t i = 0; i < n; ++i) res += s;
		return res;
	}
	template <class T> auto& operator<<(vector<T>& v, const vector<T>& v2) {
		v.insert(v.end(), all(v2));
		return v;
	}
	template <class T> T Ceil(T n, T m) {
		return (n + m - 1) / m;
	}
	template <class T> T Ceil2(T n, T m) {
		return Ceil(n, m) * m;
	}
	template <class T> T Tri(T n) {
		return (n & 1) ? (n + 1) / 2 * n : n / 2 * (n + 1);
	}
	template <class T> T nC2(T n) {
		return (n & 1) ? (n - 1) / 2 * n : n / 2 * (n - 1);
	}
	template <class T> T Mid(const T& l, const T& r) {
		return l + (r - l) / 2;
	}
	template <class T> bool chmax(T& a, const T& b) {
		if (a < b) {
			a = b;
			return true;
		}
		return false;
	}
	template <class T> bool chmin(T& a, const T& b) {
		if (a > b) {
			a = b;
			return true;
		}
		return false;
	}
	template <class T> bool inRange(const T& v, const T& min, const T& max) {
		return min <= v && v < max;
	}
	template <class T> bool isSquere(T n) {
		T s = sqrt(n);
		return s * s == n || (s + 1) * (s + 1) == n;
	}
	template <class T = long long> T BIT(int b) {
		return T(1) << b;
	}
	template <class T> T Gcd(T n, T m) {
		return m ? Gcd(m, n % m) : n;
	}
	template <class T> T Lcm(T n, T m) {
		return n / Gcd(n, m) * m;
	}
	template <class T, class U = typename T::value_type> U Gcdv(const T& v) {
		return accumulate(next(v.begin()), v.end(), U(*v.begin()), Gcd<U>);
	}
	template <class T, class U = typename T::value_type> U Lcmv(const T& v) {
		return accumulate(next(v.begin()), v.end(), U(*v.begin()), Lcm<U>);
	}
	template <class T> T Pow(T a, T n) {
		T r = 1;
		while (n > 0) {
			if (n & 1) r *= a;
			a *= a;
			n /= 2;
		}
		return r;
	}
	template <class T> T Powmod(T a, T n, T m = MOD) {
		T r = 1;
		while (n > 0) {
			if (n & 1)
				r = r * a % m, n--;
			else
				a = a * a % m, n /= 2;
		}
		return r;
	}
}  // namespace

// --- dump --- //
#if __has_include(<library/dump.hpp>)
#include <library/dump.hpp>
#else
#define dump(...) ((void)0)
#endif

// ---------------------------------------------------------------- //

#line 2 "a.cpp"

int main() {
	ini(n, k);

	const int MAX_B = 8;
	auto ask = [&](int v) {
		out(v + 1).flush();
		ins(s);
		return s;
	};

	if (n < MAX_B) {
		out(0).flush();
		rep(i, k) {
			rep(i, n) {
				string s = ask(i);
				if (s == "Yes") break;
			}
		}
		exit(0);
	}

	map<int, int> bit;
	rep(i, MAX_B) {
		bit[n - 1 - i] = BIT(i);
	}
	dump(bit);

	VP edges;
	rep(v, n - MAX_B) {
		for (auto p : bit) {
			int i, bi;
			tie(i, bi) = p;
			if (v & bi) {
				edges.emplace_back(v, i);
			}
		}
	}

	out(edges.size());
	for (auto p : edges) out(p.first + 1, p.second + 1);

	auto once_game = [&]() {
		int ans = 0;
		for (auto p : bit) {
			int i, bi;
			tie(i, bi) = p;
			string s = ask(i);
			if (s == "Yes") {
				return;
			} else if (s == "Near") {
				ans |= bi;
			}
		}
		assert(ask(ans) == "Yes");
	};

	rep(i, k) {
		once_game();
	}
}
accuracy: 1
time_ms: 230
memory_kb: 3340
final_rank: 18

code_snippet: #pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<complex>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include<tuple>
using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rng(i,s,n) for(int i = (s) ; i < (n) ; i++)
#define rep(i,n) rng(i, 0, (n))
#define mkp make_pair
#define vec vector
#define vi vec<int>
#define pb emplace_back
#define siz(a) (int)(a).size()
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define getidx(b,i) (lower_bound(all(b),(i))-(b).begin())
#define ssp(i,n) (i==(int)(n)-1?"\n":" ")
#define ctoi(c) (int)(c-'0')
#define itoc(c) (char)(c+'0')
#define cyes printf("Yes\n")
#define cno printf("No\n")
#define cdf(n) int quetimes_=(n);rep(qq123_,quetimes_)
#define gcj printf("Case #%lld: ",qq123_+1)
#define readv(a,n) a.resize(n,0);rep(i,(n)) a[i]=read()
#define found(a,x) (a.find(x)!=a.end())
//#define endl "\n"
constexpr int mod = (ll)1e9 + 7;
constexpr int Mod = 998244353;
constexpr ld EPS = 1e-10;
constexpr ll inf = (ll)3 * 1e18;
constexpr int Inf = (ll)15 * 1e8;
constexpr int dx[] = { -1,1,0,0 }, dy[] = { 0,0,-1,1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
ll read() { ll u, k = scanf("%lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
H readh(short g = 0) { H u; int k = scanf("%lld %lld", &u.fs, &u.sc); if (g == 1) u.fs--, u.sc--; if (g == 2) u.fs--; return u; }
bool ina(H t, int h, int w) { return 0 <= t.fs && t.fs < h && 0 <= t.sc && t.sc < w; }
bool ina(int t, int l, int r) { return l <= t && t < r; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll popcount(ll x) {
    int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
    return sum;
}
template<typename T>
class csum {
    vec<T> v;
public:
    csum(vec<T>& a) :v(a) { build(); }
    csum() {}
    void init(vec<T>& a) { v = a; build(); }
    void build() {
        for (int i = 1; i < v.size(); i++) v[i] += v[i - 1];
    }
    T a(int l, int r) {
        if (r < l) return 0;
        return v[r] - (l == 0 ? 0 : v[l - 1]);
    }//[l,r]
    T b(int l, int r) {
        return a(l, r - 1);
    }//[l,r)
    T a(pair<int, int>t) {
        return a(t.first, t.second);
    }
    T b(pair<int, int>t) {
        return b(t.first, t.second);
    }
};
class mint {
public:ll v;
      mint(ll v = 0) { s(v % mod + mod); }
      constexpr static int mod = (ll)1e9 + 7;
      constexpr static int fn_ = (ll)2e6 + 5;
      static mint fact[fn_], comp[fn_];
      mint pow(int x) const {
          mint b(v), c(1);
          while (x) {
              if (x & 1) c *= b;
              b *= b;
              x >>= 1;
          }
          return c;
      }
      inline mint& s(int vv) {
          v = vv < mod ? vv : vv - mod;
          return *this;
      }
      inline mint inv()const { return pow(mod - 2); }
      inline mint operator-()const { return mint() - *this; }
      inline mint& operator+=(const mint b) { return s(v + b.v); }
      inline mint& operator-=(const mint b) { return s(v + mod - b.v); }
      inline mint& operator*=(const mint b) { v = v * b.v % mod; return *this; }
      inline mint& operator/=(const mint b) { v = v * b.inv().v % mod; return *this; }
      inline mint operator+(const mint b) const { return mint(v) += b; }
      inline mint operator-(const mint b) const { return mint(v) -= b; }
      inline mint operator*(const mint b) const { return mint(v) *= b; }
      inline mint operator/(const mint b) const { return mint(v) /= b; }
      friend ostream& operator<<(ostream& os, const mint& m) {
          return os << m.v;
      }
      friend istream& operator>>(istream& is, mint& m) {
          int x; is >> x; m = mint(x);
          return is;
      }
      bool operator<(const mint& r)const { return v < r.v; }
      bool operator>(const mint& r)const { return v > r.v; }
      bool operator<=(const mint& r)const { return v <= r.v; }
      bool operator>=(const mint& r)const { return v >= r.v; }
      bool operator==(const mint& r)const { return v == r.v; }
      bool operator!=(const mint& r)const { return v != r.v; }
      explicit operator bool()const { return v; }
      explicit operator int()const { return v; }
      mint comb(mint k) {
          if (k > * this) return mint();
          if (!fact[0]) combinit();
          if (v >= fn_) {
              if (k > * this - k) k = *this - k;
              mint tmp(1);
              for (int i = v; i >= v - k.v + 1; i--) tmp *= mint(i);
              return tmp * comp[k.v];
          }
          return fact[v] * comp[k.v] * comp[v - k.v];
      }//nCk
      mint perm(mint k) {
          if (k > * this) return mint();
          if (!fact[0]) combinit();
          if (v >= fn_) {
              mint tmp(1);
              for (int i = v; i >= v - k.v + 1; i--) tmp *= mint(i);
              return tmp;
          }
          return fact[v] * comp[v - k.v];
      }//nPk
      static void combinit() {
          fact[0] = 1;
          for (int i = 1; i < fn_; i++) fact[i] = fact[i - 1] * mint(i);
          comp[fn_ - 1] = fact[fn_ - 1].inv();
          for (int i = fn_ - 2; i >= 0; i--) comp[i] = comp[i + 1] * mint(i + 1);
      }
}; mint mint::fact[fn_], mint::comp[fn_];
//--------------------------------------------------------------
//---------------------------------------------------------------------
int n, k, tmp;
bool a[300][300];
int ask(int t) {
    cout << t << endl;
    string s;
    if (t == tmp) s = "Yes";
    else if (a[t][tmp])  s = "Near";
    else s = "No";
    s = reads();
    if (s == "Yes") return 0;
    else if (s == "Near") return 1;
    else return 2;
}
void answer(int t) {
    cout << "! " << t << endl;
}
void solve() {
    cin >> n >> k;
    vec<H>e;
    auto dfs = [&](int l, int r, auto& dfs) ->void{
        if ((r - l) <= 2) return;
        rng(i, l + 1, (l + r) / 2) {
            e.pb(H{ l + 1,i + 1 });
            a[l + 1][i + 1] = 1;
        }
        dfs(l + 1, (l + r) / 2, dfs);
        dfs((l + r) / 2, r, dfs);
    };

    dfs(0, n, dfs);
    cout << siz(e) << endl;
    for (auto g : e) cout << g.fs << " " << g.sc << endl;

    cdf(k) {
        int ok = 0, ng = n;
        while (ng - ok > 1) {
            int num = ask(ok + 1);
            if (num == 0) {
                goto loop;
            }
            else if (num == 1) {
                ng = (ok + ng) / 2;
                ok++;
            }
            else ok = (ok + ng) / 2;
        }
        ask(ok + 1);
    loop:;
    }
}
signed main() {
    solve();
}
accuracy: 1
time_ms: 150
memory_kb: 34544
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;

int main()
{
    int N,K;
    cin >> N >> K;
    vector<pair<int,int>> edge;
    vector<vector<int>> des(N+1, vector<int>());
    for(int i=1;i<N;i++){
        // if(2*i<=N)edge.emplace_back(i,2*i);
        if(2*i+1<=N)edge.emplace_back(i,2*i+1);
    }
    for (int i = N; i >= 1;i--){
        if(2*i<=N){
            des[i].push_back(2 * i);
            for(auto x:des[2*i])
                des[i].push_back(x);
        }
        if (2 * i+1 <= N)
        {
            des[i].push_back(2*i+1);
            for (auto x : des[2 * i+1])
                des[i].push_back(x);
        }
    }
    for (int i = 1;i<N;i++){
        if(2*i+1<=N){
            for(auto x:des[2*i+1]){
                edge.emplace_back(i, x);
            }
        }
    }
    int M = edge.size();
    cout << edge.size() << endl;
    for (int i = 0; i < M; i++)
    {
        cout << edge[i].first << " " << edge[i].second << endl;
    }
    for(int i=0;i<K;i++){
        int num = 1;
        cout << num << endl;
        string answer;
        while (cin >> answer)
        {
            if (answer == "Yes")
            {
                break;
            }
            else if (answer == "No")
            {
                num = num * 2;
                cout << num << endl;
            }
            else
            {
                num = num * 2 + 1;
                cout << num << endl;
            }
        }
    }
    
}
accuracy: 1
time_ms: 140
memory_kb: 3336
final_rank: 8

code_snippet: #include <iostream>
#include <cstring>
#include <vector>
using namespace std;
vector<int> Map[205];
void work(int l, int r) {
    if(r - l <= 1) return;
    int m = (l + r) >> 1;
    for(int i = m + 1; i < r; i++)
        Map[m].push_back(i);
    work(l, m);
    work(m, r);
}
int main() {
    int n, k, e = 0;
    cin >> n >> k;
    work(0, n);
    for(int i = 0; i < n; i++)
        e += Map[i].size();
    cout << e << endl;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < Map[i].size(); j++)
            cout << i + 1 << " " << Map[i][j] + 1 << endl;
    while(k--) {
        int l = 0, r = n;
        string s;
        while(s != "Yes") {
            int m = (l + r) / 2;
            cout << m + 1 << endl;
            cin >> s;
            if (s == "Near")
                l = m;
            else if(s == "No")
                r = m;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 160
memory_kb: 3324
final_rank: 9

code_snippet: #ifdef LOCAL
    #define _GLIBCXX_DEBUG
    #define __clock__
#else
    #pragma GCC optimize("Ofast")
    // #define NDEBUG
#endif
#define __precision__ 10
#define iostream_untie true
#define debug_stream std::cerr

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>

#define all(v) std::begin(v), std::end(v)
#define rall(v) std::rbegin(v), std::rend(v)
#define odd(n) ((n) & 1)
#define even(n) (not __odd(n))
#define __popcount(n) __builtin_popcountll(n)
#define __clz32(n) __builtin_clz(n)
#define __clz64(n) __builtin_clzll(n)
#define __ctz32(n) __builtin_ctz(n)
#define __ctz64(n) __builtin_ctzll(n)

using i32 = int_least32_t; using i64 = int_least64_t; using u32 = uint_least32_t; using u64 = uint_least64_t;
using pii = std::pair<i32, i32>; using pll = std::pair<i64, i64>;
template <class T> using heap = std::priority_queue<T>;
template <class T> using rheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class K, class T> using hashmap = std::unordered_map<K, T>;
template <class T> using hashset = std::unordered_set<T>;

namespace execution
{
    using namespace std::chrono;
    system_clock::time_point start_time, end_time;
    long long get_elapsed_time() { end_time = system_clock::now(); return duration_cast<milliseconds>(end_time - start_time).count(); }
    void print_elapsed_time() { std::cerr << "\n----- Exec time : " << get_elapsed_time() << " ms -----\n\n"; }
    struct setupper
    {
        setupper()
        {
            if(iostream_untie) std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
            std::cout << std::fixed << std::setprecision(__precision__);
    #ifdef stderr_path
            if(freopen(stderr_path, "a", stderr))
            {
                std::cerr << std::fixed << std::setprecision(__precision__);
            }
    #endif
    #ifdef stdout_path
            if(not freopen(stdout_path, "w", stdout))
            {
                freopen("CON", "w", stdout);
                std::cerr << "Failed to open the stdout file\n\n";
            }
            std::cout << "";
    #endif
    #ifdef stdin_path
            if(not freopen(stdin_path, "r", stdin))
            {
                freopen("CON", "r", stdin);
                std::cerr << "Failed to open the stdin file\n\n";
            }
    #endif
    #ifdef LOCAL
            std::cerr << "----- stderr at LOCAL -----\n\n";
            atexit(print_elapsed_time);
    #else
            fclose(stderr);
    #endif
    #ifdef __clock__
            start_time = system_clock::now();
    #endif
        }
    } __setupper;
    class myclock_t
    {
        system_clock::time_point built_pt, last_pt; int built_ln, last_ln;
        std::string built_func, last_func; bool is_built;
    public:
        myclock_t() : is_built(false) {}
        void build(int crt_ln, const std::string &crt_func)
        {
            is_built = true, last_pt = built_pt = system_clock::now(),  last_ln = built_ln = crt_ln, last_func = built_func = crt_func;
        }
        void set(int crt_ln, const std::string &crt_func)
        {
            if(is_built) last_pt = system_clock::now(), last_ln = crt_ln, last_func = crt_func;
            else debug_stream << "[ " << crt_ln << " : " << crt_func << " ] " << "myclock_t::set failed (yet to be built!)\n";
        }
        void get(int crt_ln, const std::string &crt_func)
        {
            if(is_built)
            {
                system_clock::time_point crt_pt(system_clock::now());
                long long diff = duration_cast<milliseconds>(crt_pt - last_pt).count();
                debug_stream << diff << " ms elapsed from" << " [ " << last_ln << " : " << last_func << " ]";
                if(last_ln == built_ln) debug_stream << " (when built)";
                debug_stream << " to" << " [ " << crt_ln << " : " << crt_func << " ]" << "\n";
                last_pt = built_pt, last_ln = built_ln, last_func = built_func;
            }
            else
            {
                debug_stream << "[ " << crt_ln << " : " << crt_func << " ] " << "myclock_t::get failed (yet to be built!)\n";
            }
        }
    };
} // namespace execution

#ifdef __clock__
    execution::myclock_t __myclock;
    #define build_clock() __myclock.build(__LINE__, __func__)
    #define set_clock() __myclock.set(__LINE__, __func__)
    #define get_clock() __myclock.get(__LINE__, __func__)
#else
    #define build_clock() ((void)0)
    #define set_clock() ((void)0)
    #define get_clock() ((void)0)
#endif

namespace std
{
    template <class P> void rsort(P __first, P __last) { sort(__first, __last, greater<>()); }
    template <class T> size_t hash_combine(size_t seed, T const &key) { return seed ^ (hash<T>()(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2)); }
    template <class T, class U> struct hash<pair<T, U>> { size_t operator()(pair<T, U> const &pr) const { return hash_combine(hash_combine(0, pr.first), pr.second); } };
    template <class tuple_t, size_t index = tuple_size<tuple_t>::value - 1> struct tuple_hash_calc { static size_t apply(size_t seed, tuple_t const &t) { return hash_combine(tuple_hash_calc<tuple_t, index - 1>::apply(seed, t), get<index>(t)); } };
    template <class tuple_t> struct tuple_hash_calc<tuple_t, 0> { static size_t apply(size_t seed, tuple_t const &t) { return hash_combine(seed, get<0>(t)); } };
    template <class... T> struct hash<tuple<T...>> { size_t operator()(tuple<T...> const &t) const { return tuple_hash_calc<tuple<T...>>::apply(0, t); } };
    template <class T, class U> istream &operator>>(std::istream &s, pair<T, U> &p) { return s >> p.first >> p.second; }
    template <class T, class U> ostream &operator<<(std::ostream &s, const pair<T, U> &p) { return s << p.first << " " << p.second; }
    template <class T> istream &operator>>(istream &s, vector<T> &v) { for(T &e : v) s >> e; return s; }
    template <class T> ostream &operator<<(ostream &s, const vector<T> &v)  { bool is_front = true; for(const T &e : v) { if(not is_front) s << ' '; else is_front = false; s << e; } return s; }
    template <class tuple_t, size_t index> struct tupleos { static ostream &apply(ostream &s, const tuple_t &t) { tupleos<tuple_t, index - 1>::apply(s, t); return s << " " << get<index>(t); } };
    template <class tuple_t> struct tupleos<tuple_t, 0> { static ostream &apply(ostream &s, const tuple_t &t) { return s << get<0>(t); } };
    template <class... T> ostream &operator<<(ostream &s, const tuple<T...> &t)  { return tupleos<tuple<T...>, tuple_size<tuple<T...>>::value - 1>::apply(s, t); }
    template <> ostream &operator<<(ostream &s, const tuple<> &t) { return s; }
    string revstr(string str) { reverse(str.begin(), str.end()); return str; }
} // namespace std

#ifdef LOCAL
    #define dump(...)                                                              \
        debug_stream << "[ " << __LINE__ << " : " << __FUNCTION__ << " ]\n",       \
            dump_func(#__VA_ARGS__, __VA_ARGS__)
    template <class T> void dump_func(const char *ptr, const T &x)
    {
        debug_stream << '\t';
        for(char c = *ptr; c != '\0'; c = *++ptr) if(c != ' ') debug_stream << c;
        debug_stream << " : " << x << '\n';
    }
    template <class T, class... rest_t> void dump_func(const char *ptr, const T &x, rest_t... rest)
    {
        debug_stream << '\t';
        for(char c = *ptr; c != ','; c = *++ptr) if(c != ' ') debug_stream << c;
        debug_stream << " : " << x << ",\n"; dump_func(++ptr, rest...);
    }
#else
    #define dump(...) ((void)0)
#endif
template <class P> void read_range(P __first, P __second) { for(P i = __first; i != __second; ++i) std::cin >> *i; }
template <class P> void write_range(P __first, P __second) { for(P i = __first; i != __second; std::cout << (++i == __second ? '\n' : ' ')) std::cout << *i; }

// substitue y for x if x > y.
template <class T> inline bool sbmin(T &x, const T &y) { return x > y ? x = y, true : false; }
// substitue y for x if x < y.
template <class T> inline bool sbmax(T &x, const T &y) { return x < y ? x = y, true : false; }
// binary search.
i64 bin(const std::function<bool(i64)> &pred, i64 ok, i64 ng)
{
    while(std::abs(ok - ng) > 1) { i64 mid = (ok + ng) / 2; (pred(mid) ? ok : ng) = mid; }
    return ok;
}
double bin(const std::function<bool(double)> &pred, double ok, double ng, const double eps)
{
    while(std::abs(ok - ng) > eps) { double mid = (ok + ng) / 2; (pred(mid) ? ok : ng) = mid; }
    return ok;
}
// be careful that val is type-sensitive.
template <class T, class A, size_t N> void init(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
// reset all bits.
template <class A> void reset(A &array) { memset(array, 0, sizeof(array)); }


/* The main code follows. */

using namespace std;

signed main()
{
    void __solve();
    u32 t = 1;
#ifdef LOCAL
    t = 1;
#endif
    // t = -1;
    // cin >> t;
    while(t--)
    {
        __solve();
    }
}

void __solve()
{
    int n,k; cin>>n>>k;
    vector<pii> eg;
    for(int i=1; i<=n; ++i)
    {
        int pwr=1<<(32-__clz32(i));
        for(int j=i+1; j<=n; ++j)
        {
            if(((pwr-1)&j)==i)
            {
                eg.emplace_back(i,j);
            }
        }
    }
    std::cout << eg.size() << '\n';
    for(auto e: eg)
    {
        std::cout << e << '\n';
    }
    cout<<flush;

    while(k--)
    {
        int now=0;
        int h=0;
        while(true)
        {
            now|=1<<h;
            if(now>n)
            {
                now^=1<<h;
                cout<<now<<endl;
            }
            else
            {
                cout<<now<<endl;
            }
            string res; cin>>res;
            if(res=="Yes")
            {
                break;
            }
            if(res=="No")
            {
                now^=1<<h;
            }
            h++;
        }
    }
}
accuracy: 1
time_ms: 120
memory_kb: 3324
final_rank: 5

code_snippet: #include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)//cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}

using ll =long long ;
ll mod;

void solve(vector<vector<int>>&cango){
	int tt=cango.size();
	for(int i=0;i<tt;++i){
		for(int j=0;j<tt;++j){
			for(int k=0;k<tt;++k){
				cango[j][k]|=cango[j][i]&cango[i][k];
			}
		}
	}
}
vector<int> dfs(int now,int N,vector<pair<int,int>>&edges){
	vector<int>av{now};
	if(now*2+1<N){
		auto v=dfs(now*2+1,N,edges);
		av.insert(av.end(),v.begin(),v.end());
	}
	if(now*2+2<N){
		auto v=dfs(now*2+2,N,edges);
		for(auto e:v){
			edges.push_back(make_pair(now,e));
		}
		av.insert(av.end(),v.begin(),v.end());
	}
	return av;
}

int ask(int x){
	cout<<x+1<<endl;
	fflush(stdout);
	string st;cin>>st;
	if(st=="Yes")return -1;
	else if(st=="No")return 0;
	else return 1;
}
int main() {
	ios::sync_with_stdio(false);
	int N;cin>>N;
	int K;cin>>K;
	vector<pair<int,int>>edges;
	dfs(0,N,edges);
	sort(edges.begin(),edges.end());
	cout<<edges.size()<<endl;
	for(auto e:edges){
		cout<<e.first+1<<' '<<e.second+1<<endl;
	}

	while(K--){
		
		int now=0;
		while(true){
			int xx=ask(now);
			if(xx==-1)break;
			else{
				now=now*2+1+xx;
			}
		}
	}
	
	return 0;	
}
accuracy: 1
time_ms: 130
memory_kb: 3332
final_rank: 6

code_snippet: /*  -*- coding: utf-8 -*-
 *
 * 2940.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200;
const int MAX_M = MAX_N * (MAX_N - 1) / 2;

/* typedef */

typedef pair<int,int> pii;
typedef queue<pii> qpii;

enum { YES, NO, NEAR };

/* global variables */

pii es[MAX_M];

/* subroutines */

int query(int a) {
  printf("%d\n", a + 1); fflush(stdout);

  char s[16];
  scanf("%s", s);

  if (s[0] == 'Y') return YES;
  if (s[1] == 'o') return NO;
  return NEAR;
}

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  qpii q;
  q.push(pii(0, n));

  int m = 0;
  while (! q.empty()) {
    pii u = q.front(); q.pop();
    int ui = u.first, uj = u.second;
    int i0 = ui + 1, i2 = uj, i1 = (i0 + i2) / 2;

    for (int i = i0; i < i1; i++) es[m++] = pii(ui, i);
    if (i0 + 1 < i1) q.push(pii(i0, i1));
    if (i1 + 1 < i2) q.push(pii(i1, i2));
  }

  printf("%d\n", m);
  for (int i = 0; i < m; i++)
    printf("%d %d\n", es[i].first + 1, es[i].second + 1);
  fflush(stdout);

  while (k--) {
    qpii qq;
    qq.push(pii(0, n));

    while (! qq.empty()) {
      pii u = qq.front(); qq.pop();
      int ui = u.first, uj = u.second;
      int i0 = ui + 1, i2 = uj, i1 = (i0 + i2) / 2;

      int r = query(ui);
      if (r == YES) break;

      if (r == NEAR) qq.push(pii(i0, i1));
      else qq.push(pii(i1, i2));
    }
  }
  return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 3388
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<P> es;

void build(int l, int r){
    if(r-l <= 1) return;
    int mid = (l+r+1)/2;
    for(int i=l+1;i<mid;i++){
        es.push_back({l+1,i+1});
    }
    build(l+1, mid);
    build(mid, r);
}

int main() {
    int n, k;
    cin >> n >> k;
    build(0, n);
    cout << es.size() << endl;
    for(int i=0;i<int(es.size());i++){
        cout << es[i].first << " " << es[i].second << endl;
    }
    for(int i=0;i<k;i++){
        int l = 0, r = n;
        string res;
        while(1){
            cout << l+1 << endl;
            cin >> res;
            if(res == "Yes"){
                break;
            }
            else if(res == "Near"){
                r = (l+r+1)/2;
                l++;
            }
            else{
                l = (l+r+1)/2;
            }
        }
    }
    return 0;
}
accuracy: 1
time_ms: 160
memory_kb: 3324
final_rank: 9

code_snippet: #include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace  std;
 
typedef pair<int,int>P;
#define fi first
#define se second
 
 
int n,k ;
 
vector<P>A;
 
void dfs(vector<int> v,int now){
  r(i,v.size()){
    A.push_back(P(v[i],now));
  }
  if(now*2+1<n){
    vector<int>nex=v;
    nex.push_back(now);
    dfs(nex,now*2+1);
  }
  if(now*2+2<n){
    vector<int>nex=v;
    nex.push_back(now);
    dfs(nex,now*2+2);
  }
}
 
//int x=0;
 
string output(int num){
 
  //cerr<<"aaa:"<<num<<endl;
  //if(x++==10)exit(0);
 
  cout<<num<<endl;
 
  string s;
/*
  const int atari = 3;
 
  if(atari == num)return "Yes";
 
  r(i,A.size()){
    if(A[i].fi==num-1 && A[i].se+1 == atari)return "Near";
    if(A[i].se==num-1 && A[i].fi+1 == atari)return "Near";
  }
  return "No";
*/
  cin>>s;
  return s;
}
 
int main(){
 
  cin>>n>>k;
 
  vector<int>init;
 
  dfs(init,0);
 
  cout<<A.size()<<'\n';
 
  r(i,A.size()){
    cout<<A[i].fi+1<<' '<<A[i].se+1;
    if(i!=(int)A.size())cout<<'\n';
    else cout<<endl;
  }
 
  while(k--){
 
    int idx=0,p=0,F=-1,S=0;
 
    while(1){
 
      if(!p){
        string s=output(idx+1);
        if(s=="Yes"){
          S++;
          break;
        }
        p++;
      }
 
      int nex=idx*2+1;
 
      if(nex>=n)break;
 
      string s=output(nex+1);
 
      if(s=="No"){
        F=nex+1;
        idx=idx*2+2;
      }
 
      else if(s=="Yes"){
        S++;
        break;
      }
 
      else{
        idx=idx*2+1;
      }
      if(idx>=n)break;
    }
 
    if(!S){
 
      //cout<<F<<endl;
 
      if(F+1<=n){
        string s=output(F+1);
        //cout<<s<<endl;
        if(s=="Yes")continue;
      }
 
      if(F-1>=1){
        string s=output(F-1);
        if(s=="Yes")continue;
      }
      //cout<<"ERROR"<<endl;
      //exit(1);
    }
 
  }
 
}
accuracy: 1
time_ms: 230
memory_kb: 3340
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

void solve(){
    int ans = 0;
    for(int k=0; k<=7; k++){
        cout << k+1 << endl;
        string res;
        cin >> res;
        if(res == "Yes") return;
        if(res == "Near") ans += 1<<k;
    }
    cout << ans+1 << endl;
    string res;
    cin >> res;
    assert(res == "Yes");
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<pair<int, int>> edges;
    for(int i=8; i<N; i++) for(int k=0; k<=7; k++) if(nth_bit(i, k)) edges.emplace_back(i, k);
    cout << edges.size() << endl;
    for(auto& p : edges) cout << p.first+1 << " " << p.second+1 << endl;
    while(K--) solve();
}
accuracy: 1
time_ms: 200
memory_kb: 3328
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 8;

int ask(int x){
    cout << x+1 << endl;

    string s;
    cin >>s;

    if(s=="Yes") return -1;
    return s=="Near";
}

int main(){
    int n,k;
    cin >>n >>k;

    // make graph
    vector<pair<int,int>> e;
    for(int i=N; i<n; ++i){
        int mask = i-N;
        rep(j,N)if(mask>>j&1){
            e.pb({j+1, i+1});
        }
    }

    cout << e.size() << endl;
    for(const auto &p:e) cout << p.fi << " " << p.se << endl;

    auto game = [&](){
        int m = 0;
        rep(i,N){
            int a = ask(i);
            if(a == -1) return;
            m |= a<<i;
        }

        assert(ask(N+m) == -1);
    };

    while(k--) game();
    return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3336
final_rank: 11

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Edge{
	Edge(int arg_from,int arg_to){
		from = arg_from;
		to = arg_to;
	}
	int from,to;
};


int main(){

	int N,K;

	cin >> N >> K;

	int M = 0;
	vector<Edge> G;

	for(int base = 1; base <= N; base*=2){

		for(int adj = base+1; adj <= N; adj++){
			if((base&adj)){
				G.push_back(Edge(base,adj));
				M++;
			}
		}
	}

	cout << M << endl;

	for(int i = 0; i < G.size(); i++){

		cout << G[i].from << " " << G[i].to << endl;
	}

	int sum;
	string buf;
	bool FLG;

	for(int loop = 0; loop < K; loop++){

		sum = 0;
		FLG = false;

		for(int base = 1; base <= N; base*=2){

			cout << base << endl;

			cin >> buf;
			if(buf[0] == 'Y'){
				FLG = true;
				break;
			}
			if(buf[0] == 'N' && buf[1] == 'e')sum += base;
		}
		if(FLG)continue;

		cout << sum << endl;
		cin >> buf;
	}

	return 0;
}
accuracy: 1
time_ms: 190
memory_kb: 3332
final_rank: 14

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

vector<int> v[200 + 1];
int c;
void recur(int l, int r) {
    //cout << l << " " << r << endl;
    if (l == r) return;
    int mid = (l + r) / 2;
    rrep(i, mid + 1, r + 1) {
        v[mid].push_back(i);
        c++;
    }
    if (l <= mid - 1) recur(l, mid - 1);
    if (mid + 1 <= r) recur(mid + 1, r);
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    recur(1, n);
    cout << c << endl;
    rep(i, n + 1) {
        rep(j, v[i].size()) {
            cout << i << " " << v[i][j] << endl;
        }
    }
    while (k--) {
        int now = (1 + n) / 2;
        int l = 1, r = n;
        while (1) {
            cout << now << endl;
            string s; cin >> s;
            if (s == "Yes") break;
            else if (s == "Near") {
                l = now + 1;
            } else {
                r = now - 1;
            }
            now = (l + r) / 2;
        }
    }
}
accuracy: 1
time_ms: 170
memory_kb: 3348
final_rank: 12

code_snippet: #include <iostream>
#include <vector>
#include <utility>
using namespace std;
vector<pair<int,int>> v;
int main(){
	int i,j,n,k;
	cin >> n >> k;
	for(i=0;i<10;i++){
		if((1<<i)>n) break;
		for(j=1;j<=n;j++){
			if((1<<i)==j) continue;
			if((1<<i) & j){
				v.push_back({(1<<i),j});
			}
		}
	}
	cout << v.size() << endl;
	for(i=0;i<v.size();i++){
		cout << v[i].first << " " << v[i].second << endl;
	}
	while(k){
		k--;
		string s;
		int res = 0;
		for(i=0;i<10;i++){
			if((1<<i)>n) break;
			cout << (1<<i) << endl;
			cin >> s;
			if(s[0]=='Y'){
				res = -1;
				break;
			}else if(s[1]=='e'){
				res += (1<<i);
			}
		}
		if(res>0){
			cout << res << endl;
			cin >> s;
		}
	}
}
accuracy: 1
time_ms: 220
memory_kb: 3300
final_rank: 17

code_snippet: //include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	VVL g(8);
	int edges = 0;
	for (int i = 3; i <= n; i++) {
		for (int j = 0; j < 8; j++) {
			if (((i >> j) & 1) == 1) {
				g[j].push_back(i);
				edges++;
			}
		}
	}
	cout << edges << endl;
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < g[i].size(); j++) {
			cout << i+1 << " " << g[i][j] << endl;
		}
	}

	for (int j = 0; j < k; j++) {
		string s;
		int ans = 0;
		for (int i = 1; i <= min(8,n); i++) {
			cout << i << endl;
			cin >> s;
			if (s == "Yes") {
				goto end;
			}
			if (s == "Near") {
				ans += (1 << (i - 1));
			}
		}
		cout << ans << endl;
		cin >> s;
end:
		int tmp;
	}
	return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3356
final_rank: 13

code_snippet: //include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	vector<set<int>> nodes(n+1);
	int m = 0;
	for (int i = 0; i < 8; i++) {
		for (int j = 2+i; j <= n; j++) {
			if ((j & (1<<i)) > 0) {
				nodes[i+1].insert(j);
				m++;
			}
		}
	}
	cout << m << endl;
	for (int i = 1; i <= n; i++) {
		for (auto&& j : nodes[i]) {
			cout << i << " " << j << endl;
		}
	}
	for (int i = 0; i < k; i++) {
		int ans = 0, j = 0;
		string s;
		while(j < 8) {
			cout << j + 1 << endl;
			cin >> s;
			if (s == "Yes") {
				goto end;
			}
			if (s == "Near") {
				ans += (1<<j);
			}
			j++;
		}
		cout << ans << endl;
		cin >> s;
end:
		int tmp;
	}
	return 0;
}
accuracy: 1
time_ms: 190
memory_kb: 3348
final_rank: 15