criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

string query(int q)
{
  string ans;
  putv(q);
  fflush(stdout);
  cin>>ans;
  return ans;
}

signed main(void)
{
  string ans;
  int start;
  int i;
  in(int,n);
  ans=query(0);
  if(ans=="Male")
    start=0;
  else if(ans=="Female")
    start=1;
  else
    exit(0);
  string correct[112345];
  string mf[2];
  mf[start]="Male";
  mf[start^1]="Female";
  rep(i,n)
    correct[i]=mf[i%2],dout(i);
  dputs("mfはセーフ");
  int tmp=n/2;
  int now=0;
  string before="high";
  for(i=0;i<19;i++)
    {
      if(before=="high")
        now+=tmp;
      else
        now-=tmp;
      tmp=tmp/2;
      if(tmp==0)
        tmp=1;
      ans=query(now);
      if(ans=="Vacant")
        exit(0);
      else if(ans==correct[now])
        before="high";
      else
        before="low";
    }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:105:31: error: expected primary-expression before ';' token
  105 |     correct[i]=mf[i%2],dout(i);
      |                               ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
int input(int n){
	cout<<n<<endl;
	string str;
	switch(str[0]){
		case 'V':
			return 0;
			break;
		case 'F':
			return 1;
			break;
		case 'M':
			return 2;
			break;
	}
}
int main(){
	int N;
	cin>>N;
	int lp,hp,ln;
	lp=0;
	hp=N;
	ln = input(0);
	while(true){
		int mid = (lp+hp)>>1;
		int mn = input(mid);
		if(mid==0){
			break;
		}else{
			if(((hp-lp)&1)!=(mn!=ln)){
				hp = mid;
			else{
				ln = mn;
				lp = mid;
			}	
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:25: error: expected '}' before 'else'
   34 |                         else{
      |                         ^~~~
a.cc:32:50: note: to match this '{'
   32 |                         if(((hp-lp)&1)!=(mn!=ln)){
      |                                                  ^
a.cc: In function 'int input(int)':
a.cc:18:1: warning: control reaches end of non-void function [-Wreturn-type]
   18 | }
      | ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
int input(int n){
	cout<<n<<endl;
	string str;
	switch(str[0]){
		case 'V':
			return 0;
			break;
		case 'F':
			return 1;
			break;
		case 'M':
			return 2;
			break;
	}
int main(){
	int N;
	cin>>N;
	int lp,hp,ln;
	lp=0;
	hp=N;
	ln = input(0);
	while(true){
		int mid = (lp+hp)>>1;
		int mn = input(mid);
		if(mid==0){
			break;
		}else{
			if(((hp-lp)&1)!=(mn!=ln)){
				hp = mid;
			else{
				ln = mn;
				lp = mid;
			}	
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int input(int)':
a.cc:18:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   18 | int main(){
      |         ^~
a.cc:18:9: note: remove parentheses to default-initialize a variable
   18 | int main(){
      |         ^~
      |         --
a.cc:18:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:18:11: error: a function-definition is not allowed here before '{' token
   18 | int main(){
      |           ^
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:4:17: note: to match this '{'
    4 | int input(int n){
      |                 ^
a.cc:40:2: warning: control reaches end of non-void function [-Wreturn-type]
   40 | }
      |  ^
Language: C++

#include <bits/stdc++.h>

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 1e5 + 10;

int check(int x){
	printf("%d\n", x);
	fflush(stdout);
	char S[10];
	scanf("%s", S);
	if(S[0] == 'V') exit(0);
	return S[0] == 'M'
}

int main(){

	int n;
	scanf("%d", &n);

	int L = 0, R = n;
	int lval = check(L), rval = lval;

	while(L < R){
		int M = (L + R) >> 1, val = check(M);
		if(((M - L) & 1) == (val ^ lval)) L = M + 1;
		else R = M - 1;
	}

	check(L);

	return 0;
}

Compiler output:
a.cc: In function 'int check(int)':
a.cc:15:27: error: expected ';' before '}' token
   15 |         return S[0] == 'M'
      |                           ^
      |                           ;
   16 | }
      | ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
// int l, r;
bool fg = true;
bool check(int l, int r){
    if(fg == false) return false;
    int m = (l+r)/2;
    string sl, sm ,sr;
    cout << l << endl;
    fflush(stdout);
    cin >> sl;
    fflush(stdin);
    if(sl == "Vacant") return fg = false;
    cout << m << endl;
    fflush(stdout);
    cin >> sm;
    fflush(stdin);
    if(sm == "Vacant") return fg = false;
    cout << r << endl;
    fflush(stdout);
    cin >> sr;
    fflush(stdin);
    if(sr == "Vacant") return fg = false;
    if((l+m) %2 == 0){
        if(sl != sm) {
            check(l+1, m-1);
            if(fg == false) return false;
//            return fg = false;
        }
    }
    if((m+r) % 2 == 0){
        if(sm != sr){
            check(m+1, r-1);
                if(fg == false) return false;
//            return fg = false;
        }   
    }
    if((l+m) %2){
        if(sl == sm) {
            check(l+1, m-1);
                if(fg == false) return false;
//            return false;
        }
    }
    if((m+r) % 2){
        if(sm == sr) {
            check(m+1, r-1);
                if(fg == false) return false;
//            return false;
        }   
    }
    if(fg) check(l+1, m-1);
    if(fg)    check(m+1, r-1);


}
int main(){
    cin >> n;
    fflush(stdin);
    int l = 0, r = n-1;
    check(l,r)
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:15: error: expected ';' before 'return'
   63 |     check(l,r)
      |               ^
      |               ;
   64 |     return 0;
      |     ~~~~~~     
a.cc: In function 'bool check(int, int)':
a.cc:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^
Language: C++

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

int catch1(){
  int zr=0;
  string st;
  cout << zr << endl;
  cin >> st;
  if(equal(st.begin(), st.end(), "Male")){
    for(int i=2;i<=40;i=i+2){
      cout << i << endl;
      cin >> st;
      if(equal(st.begin(), st.end(), "Female")){
        cout << i-1 << endl;
        cin >> st;
        i+=1;
        if(equal(st.begin(), st.end(), "Vacant")) exit(0);
      }
    }
  }
  else if(equal(st.begin(), st.end(), "Female")){
    for(int j=2;j<=40;j=j+2){
      cout << j << endl;
      cin >>st;
      if(equal(st.begin(), st.end(), "Male")){
        cout << j-1 << endl;
        cin >> st;
        j+=1;
        if(equal(st.begin(), st.end(), "Vacant")) exit(0);
      }
    }
  }
  else exit(0);
  return 0;
}

int catch2(){
  int zr=0;
  string st;
  cout << zr << endl;
  cin >> st;
  if(equal(st.begin(), st.end(), "Male")){
    for(int i=4;i<=80;i=i+4){
      cout << i << endl;
      cin >> st;
      if(equal(st.begin(), st.end(), "Female")){
        cout << i-3 << endl;
        cin >> st;
        i+=1;
        if(equal(st.begin(), st.end(), "Vacant")) exit(0);
        cout << i << endl;
        cin >> st;
        i+=1;
        if(equal(st.begin(), st.end(), "Vacant")) exit(0);
        cout << i << endl;
        cin >> st;
        i+=1;
        if(equal(st.begin(), st.end(), "Vacant")) exit(0);
      }
    }
  }
  else if(equal(st.begin(), st.end(), "Female")){
    for(int j=4;j<=80;j=j+4){
      cout << j << endl;
      cin >>st;
      if(equal(st.begin(), st.end(), "Male")){
        cout << j-3 << endl;
        cin >> st;
        j+=1;
        if(equal(st.begin(), st.end(), "Vacant")) exit(0);
        cout << j <<endl;
        cin >> st;
        i+=1;
        if(equal(st.begin(), st.end(), "Vacant")) exit(0);
        cout << j <<endl;
        cin >> st;
        i+=1;
        if(equal(st.begin(), st.end(), "Vacant")) exit(0);
      }
    }
  }
  else exit(0);
}

int main(){
  int n;
  cin >> n;
  if(n<=40) catch1();
  else catch2();
  return 0;
}

Compiler output:
a.cc: In function 'int catch2()':
a.cc:73:9: error: 'i' was not declared in this scope
   73 |         i+=1;
      |         ^
a.cc:83:1: warning: control reaches end of non-void function [-Wreturn-type]
   83 | }
      | ^
Language: C++

int N;
#define vacant "Vacant"
#define male "Male"
#define female "Female"
//---------------------------------------------------------------------------------------------------
string a0;
string ask(int i) {
    printf("%d\n", i);
    fflush(stdout);
    string res; cin >> res;
    return res;
}
//---------------------------------------------------------------------------------------------------
void f(int l, int r) {
    int md = (l + r) / 2;
 
    auto res = ask(md);
    if (res == vacant) return;
 
    if ((md % 2 == 0 and a0 == res) or (md % 2 == 1 and a0 != res)) f(md + 1, r);
    else f(l, md);
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
 
    a0 = ask(0);
    if (a0 == vacant) return;
 
    f(1, N);
}

Compiler output:
a.cc:6:1: error: 'string' does not name a type
    6 | string a0;
      | ^~~~~~
a.cc:7:1: error: 'string' does not name a type
    7 | string ask(int i) {
      | ^~~~~~
a.cc: In function 'void f(int, int)':
a.cc:17:16: error: 'ask' was not declared in this scope
   17 |     auto res = ask(md);
      |                ^~~
a.cc:20:26: error: 'a0' was not declared in this scope
   20 |     if ((md % 2 == 0 and a0 == res) or (md % 2 == 1 and a0 != res)) f(md + 1, r);
      |                          ^~
a.cc: In function 'void _main()':
a.cc:25:5: error: 'cin' was not declared in this scope
   25 |     cin >> N;
      |     ^~~
a.cc:27:5: error: 'a0' was not declared in this scope
   27 |     a0 = ask(0);
      |     ^~
a.cc:27:10: error: 'ask' was not declared in this scope
   27 |     a0 = ask(0);
      |          ^~~
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>	
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <string.h>
#include <map>
#include <algorithm>
#include <queue>
#include <set>
#include <time.h>
#include <assert.h>
#include <sstream>
//#include <unordered_map>
#include <bitset>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <math.h>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;
typedef complex<double> point;

int n, a[100010];
int ask(int x) {
	printf("%d\n", x);
	fflush(stdout);
	char s[10];
	scanf("%s", s);
	if(strcmp(s, "Male") == 0)
		return 0;
	if(strcmp(s, "Female") == 0)
		return 1;
	exit(0);
}

int main() {
	scanf("%d", &n);
	a[0] = ask(0);
	int l = 0, r = n;
	while(l <= r) {
		int mid = (l + r) >> 1;
		a[mid] = ask(mid);
		print4(l, r, mid, a[mid]);
		if(mid % 2 == l % 2 && a[mid] == a[l])
			l = mid + 1;
		else
			r = mid - 1;
	}
	ask(n - 1);
	

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:17: error: 'print4' was not declared in this scope; did you mean 'printf'?
   52 |                 print4(l, r, mid, a[mid]);
      |                 ^~~~~~
      |                 printf
Language: C++

#include <bits/stdc++.h>
#define LL long long
using namespace std;

int N;
string s;
int main()
{
    cin >> N;
    int l = 0, r = N - 1;
    cout << 0;
    fflush(cout);

    int zero;
    cin >> s;
    if(s == "Vacant")
        return 0;
    zero = (s == "Male" ? 0 : 1);

    while(l <= r) {
        int m = (l + r) / 2;
        cout << m;
        fflush(cout);
        cin >> s;
        if(s == "Vacant")
            return 0;
        int x = (s == "Male" ? 0 : 1);
        if((m - l) % 2 != abs(x - zero)) {
            r = m - 1;
        } else {
            l = m + 1;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: cannot convert 'std::ostream' {aka 'std::basic_ostream<char>'} to 'FILE*'
   12 |     fflush(cout);
      |            ^~~~
      |            |
      |            std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/stdio.h:236:26: note:   initializing argument 1 of 'int fflush(FILE*)'
  236 | extern int fflush (FILE *__stream);
      |                    ~~~~~~^~~~~~~~
a.cc:23:16: error: cannot convert 'std::ostream' {aka 'std::basic_ostream<char>'} to 'FILE*'
   23 |         fflush(cout);
      |                ^~~~
      |                |
      |                std::ostream {aka std::basic_ostream<char>}
/usr/include/stdio.h:236:26: note:   initializing argument 1 of 'int fflush(FILE*)'
  236 | extern int fflush (FILE *__stream);
      |                    ~~~~~~^~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int MAX_N = 1e5 + 5;

string typeOf[MAX_N];

string GetTypeOf(int ind) {
	if(typeOf[ind] == "") {
		cout << ind << endl << flush;
		
		string s;
		cin >> s;
		typeOf[ind] = s;
	}

	return typeOf[ind];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	
	if(GetTypeOf(0) != "Vacant") {
		typeOf[n] = GetTypeOf(0);

		int low = 1, high = n - 1;
		while(low <= high) {
			int mid = (low + high) / 2;
				
			if(GetTypeOf(low) == "Vacant" || GetTypeOf(mid) == "Vacant") {
				return 0;
			}
			
			int aux = mid - low + 1;
			if((aux % 2 == 0 && GetTypeOf(low) == GetTypeOf(mid)) || (aux % 2 != 0 && GetTypeOf(low) != GetTypeOf(mid))) {
				high = mid - 1;
			}
			else {
				low = mid + 1;
			}
		}
	}
	
	GetTypeOf(low);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:19: error: 'low' was not declared in this scope; did you mean 'pow'?
   49 |         GetTypeOf(low);
      |                   ^~~
      |                   pow
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAX=100010;
int n,m;
char s[110];
int f(int x)
{
    printf("%d\n",x);
    scanf("%s",s);
    if(s[0]=='V')
        return -1;
    if(s[0]=='M')
        return 1;
    else
        return 0;
}
//int b[MAX];
int main()
{
    int i,j,k,t;
    scanf("%d",&n);

    int l=0,r=n;
    int now=f(l);
    if(now==-1)
        return 0;
    while(l<r)
    {
        int mid=(l+r)/2;
        int next=f(mid);
        if(next==-1)
            break;
        int len=(mid-l+1)%2;
        int flag=(now==next?1:0);
//            printf("%d %d\n",len,flag);
        if(len^flag)
        {
            r=mid;
            now=next;

        }
        else
            l=mid;
    }
}
return 0;
}


Compiler output:
a.cc:48:1: error: expected unqualified-id before 'return'
   48 | return 0;
      | ^~~~~~
a.cc:49:1: error: expected declaration before '}' token
   49 | }
      | ^
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
 
void solve(int, int, string, string);
string getsex(int);
int main(){
  int n, ans; cin >> n; //人数
 
  string s=getsex(0), e=getsex(n-1); //両サイドの性別チェック
  if(s=="Vacant" || e=="Vacant"){
    return 0;
  }else{
    solve(0, n-1, s, e);
  }
 
  return 0;
}
 
void solve(int s, int e, string ssex, string esex){
  int start=s, end=e, m, n=0;
  string startsex=ssex, endsex=esex, msex;
 
  while(true){
    m=(s+e)/2;
    msex = getsex(m);
    if(msex=="Vacant") return;
 
    if(((m-s)%2==0 && ssex!=msex) || ((m-s)%2!=1 && ssex==msex)) e=m, esex=msex;
    else s=m, ssex=msex;
 
    n++; if(n==20) return;
  }
}
 
string getsex(int num){
  string res;
  cout << num << endl;
  fflush(stdout);
  cin >> res;
 
  return res;
}
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

void solve(int, int, string, string);
string getsex(int);
int main(){
  int n, ans; cin >> n; //人数

  string s=getsex(0), e=getsex(n-1); //両サイドの性別チェック
  if(s=="Vacant" || e=="Vacant"){
    return 0;
  }else{
    solve(0, n-1, s, e);
  }

  return 0;
}

void solve(int s, int e, string ssex, string esex){
  int start=s, end=e, m, n=0;
  string startsex=ssex, endsex=esex, msex;

  while(true){
    m=(s+e)/2;
    msex = getsex(m);
    if(msex=="Vacant") return;

    if(((m-s)%2==0 && ssex!=msex) || ((m-s)%2==1 && ssex==msex)) e=m, esex=msex;
    else s=m, ssex=msex;

    n++; if(n==20) return;
  }
}

string getsex(int num){
  string res;
  cout << num << endl;
  fflush(stdout);
  cin >> res;

  return res;
}


Compiler output:
a.cc:54:5: error: redefinition of 'int main()'
   54 | int main(){
      |     ^~~~
a.cc:9:5: note: 'int main()' previously defined here
    9 | int main(){
      |     ^~~~
a.cc:67:6: error: redefinition of 'void solve(int, int, std::string, std::string)'
   67 | void solve(int s, int e, string ssex, string esex){
      |      ^~~~~
a.cc:22:6: note: 'void solve(int, int, std::string, std::string)' previously defined here
   22 | void solve(int s, int e, string ssex, string esex){
      |      ^~~~~
a.cc:83:8: error: redefinition of 'std::string getsex(int)'
   83 | string getsex(int num){
      |        ^~~~~~
a.cc:38:8: note: 'std::string getsex(int)' previously defined here
   38 | string getsex(int num){
      |        ^~~~~~
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

void solve(int, int, string, string);
string getsex(int);
int main(){
  int n, ans; cin >> n; //人数

  string s=getsex(0), e=getsex(n-1); //両サイドの性別チェック
  if(s=="Vacant" || e=="Vacant"){
    return 0;
  }else{
    ans = solve(0, n-1, s, e);
  }

  return 0;
}

void solve(int s, int e, string ssex, string esex){
  int start=s, end=e, m, n=0;
  string startsex=ssex, endsex=esex, msex;

  while(true){
    m=(s+e)/2;
    msex = getsex(m);
    if(msex=="Vacant") return;

    if(((m-s)%2==0 && ssex!=msex) || ((m-s)%2!=1 && ssex==msex)) e=m, esex=msex;
    else s=m, ssex=msex;

    n++; if(n==20) return;
  }
}

string getsex(int num){
  string res;
  cout << num << endl;
  fflush(stdout);
  cin >> res;

  return res;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: void value not ignored as it ought to be
   16 |     ans = solve(0, n-1, s, e);
      |           ~~~~~^~~~~~~~~~~~~~
Language: C++

#include <cstdio>

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

  char s[8];

  puts("0");
  fflush(stdout);

  scanf("%s", s);
  if (*s == 'V') return 0;  

  int lb=0, ub=N;
  while (ub-lb > 1) {
    int mid=(lb+ub)>>1;
    printf("%d\n", mid);
    fflush(stdout);

    char t[8];
    scanf("%s", t);
    if (t == 'V') return 0;
    ((mid&1)^(*s==*t)? lb:ub) = mid;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   23 |     if (t == 'V') return 0;
      |         ~~^~~~~~
Language: C++

#include <iostream>
#include<vector>
#include<string>
using namespace std;
int read(){
string str;
cin>>str;
if(str==string("Vacant"))return -1;
if(str==string("Male"))return 0;
return 1;
}
int main(){
int N;
cin>>N;
cout<<0<<endl;
cin>>x;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:6: error: 'x' was not declared in this scope
   16 | cin>>x;
      |      ^
Language: C++

#include <stdio.h>
#include<string.h>
int arr[1000000];
char tep[5];
int n;
int solve(int l, int r)
{
	if (arr[l] == 0)
	{
		printf("%d\n", l);
		gets(tep);
		if (tep[0] == 'V')return l;
		else if (tep[0] == 'M')arr[l] = 1;
		else if (tep[0] == 'F')arr[l] = -1;
	}
	printf("%d\n", (r + l) / 2);
	gets(tep);
	if (tep[0] == 'V')return l;
	else if (tep[0] == 'M')arr[(l+r)/2] = 1;
	else if (tep[0] == 'F')arr[(l + r) / 2] = -1;

	if (arr[l] == arr[(l + r) / 2])
		return solve(l, (l + r) / 2);
	else return solve((l + r) / 2, r);
}
int main()
{
	while (~scanf("%d",&n))
	{
		int ans = solve(1, n);
		printf("%d\n", ans);
	}
}

Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:11:17: error: 'gets' was not declared in this scope; did you mean 'getw'?
   11 |                 gets(tep);
      |                 ^~~~
      |                 getw
a.cc:17:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   17 |         gets(tep);
      |         ^~~~
      |         getw
Language: C++

#include <cstdio>
#include <iostream>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <sstream>
#include <functional>
#include <algorithm>
using namespace std;

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1.0);
const double eps=1e-8;
const int INF=0x3f3f3f3f;
const int MOD=1e8;
const int N=1e4+5;
const ll maxn=5e4;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
string s,t;
int main()
{
    IO;
    int n,l,r;
    cin>>n;
    cout<<0<<endl;
    cin>>s;
    if(s=="Vacant") return 0;
    l=0,r=n;
    int mid;
    while(t!="Vacant")
    {
        mid=(l+r)>>1;
        cout<<mid<<endl;
        cin>>t;
        if((mid%2)^s==t) l=m;
        else r=m;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:28: error: 'm' was not declared in this scope
   57 |         if((mid%2)^s==t) l=m;
      |                            ^
a.cc:58:16: error: 'm' was not declared in this scope
   58 |         else r=m;
      |                ^
Language: C++

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<ll,P> PP;

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

int n;
string res;
int l,r;
int L,R;

int ask(int i) {
	cout<<i;
	string res;cin>>res;
	if(res=="Vacant") exit(0);
	else if(res=="Famale") return 1;
	else return 2;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>n;
	l=0;
	L=ask(l);

	while(true) {
		int mid=(l+r)/2;
		int M=ask(mid);
		if(((mid-l)%2==0&&M==L)||((mid-l)%2==1&&M!=L)) l=m,L=M;
		else r=m;
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:66: error: 'm' was not declared in this scope
   47 |                 if(((mid-l)%2==0&&M==L)||((mid-l)%2==1&&M!=L)) l=m,L=M;
      |                                                                  ^
a.cc:48:24: error: 'm' was not declared in this scope
   48 |                 else r=m;
      |                        ^
Language: C++

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<ll,P> PP;

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

int n;
string res;
int l,r;
string S[100000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>n;
	cout<<0<<endl;
	l=0,r=n;
	cin>>res;
	S[l]=res;
	int times=19;
	while(r-l>times) {
		int mid=l+(r-l)/2;
		cout<<mid<<endl;
		cin>>res;
		if(res=="Vacant") return 0;
		times--;
		S[mid]=res;
		if((S[mid]==S[l]&&(mid-l)%2==1)||(S[mid]!=S[l]&&(r-mid)%2==0)) r=mid;
		else l=mid;
		L=res;
	}
	FOR(i,l,r) {
		cout<<i<<endl;
		cin>>L;
		if(L=="Vacant") return 0;
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:17: error: 'L' was not declared in this scope
   47 |                 L=res;
      |                 ^
a.cc:51:22: error: 'L' was not declared in this scope
   51 |                 cin>>L;
      |                      ^
Language: C++

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<ll,P> PP;

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

int n;
string L;
int l,r;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>n;
	cout<<0<<endl;
	cin>>L;
	l=0,r=n;
	int times=19;
	while(r-l>times) {
		int mid=(r+l)/2;
		string res;
		cout<<mid<<endl;
		cin>>res;
		if(res=="Vacant") break;
		res--;
		if((res==L&&(mid-l)%2==1)||(res!=L&&(r-mid)%2==0)) r=mid;
		else l=mid;
		L=res;
	}
	FOR(i,l,r) cout<<i<<endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:20: error: no 'operator--(int)' declared for postfix '--' [-fpermissive]
   42 |                 res--;
      |                 ~~~^~
Language: C++

#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100000+10;
int n;
string s1="Vacant",s2="Male",s3="Female";
string m,r,l;
void dfs(int a,int b,int c){
    if(!m.compare(s1)) return;
    if((b-a)%2==0){
        if(!m.compare(l)){
            r.assign(m);
            cout<<(a+b)/2<<endl;
            cin>>m;
            dfs(a,(a+b)/2,b);
        }
        else {
            l.assign(m);
            cout<<(b+c)/2<<endl;
            cin>>m;
            dfs(b,(b+c)/2,c);
        }
    }
    else {
        if(!m.compare(l)){
            l.assign(m);
            cout<<(b+c)/2<<endl;
            cin>>m;
            dfs(b,(b+c)/2,c);
        }
        else {
            r.assign(m);
            cout<<(a+b)/2<<endl;
            cin>>m;
            dfs(a,(a+b)/2,b);
        }
    }
}
int main() {
    std::ios::sync_with_stdio(false);
    while(cin>>n)){
        cout<<n/2<<endl;
        cin>>m;
        if(!m.compare(s1)) continue;
        cout<<"0"<<endl;
        cin>>l;
        if(!l.compare(s1)) continue;
        cout<<n-1<<endl;
        cin>>r;
        if(!r.compare(s1)) continue;
        if(((n-1)/2)%2==0){
            if(!m.compare(l)){
                r.assign(m);
                cout<<((n-1)/2)/2<<endl;
                cin>>m;
                dfs(0,((n-1)/2)/2,(n-1)/2);
            }
            else {
                l.assign(m);
                cout<<((n-1)/2+n-1)/2<<endl;
                cin>>m;
                dfs((n-1)/2,((n-1)/2+n-1)/2,n-1);
            }
        }
        else {
            if(!m.compare(l)){
                l.assign(m);
                cout<<((n-1)/2+n-1)/2<<endl;
                cin>>m;
                dfs((n-1)/2,((n-1)/2+n-1)/2,n-1);
            }
            else {
                r.assign(m);
                cout<<((n-1)/2)/2<<endl;
                cin>>m;
                dfs(0,((n-1)/2)/2,(n-1)/2);
            }
        }

    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:18: error: expected primary-expression before ')' token
   52 |     while(cin>>n)){
      |                  ^
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define INF 2000000000
#define LINF 9000000000000000000

typedef long long int ll;

int sex(char a) {
    switch (a) {
        case 'M':
            return 1;
        case 'F':
            return -1;
        case 'V':
            exit(0);
    }
}

int main() {
    register int n;
    cin >> n;

    register int left = 0;
    register int right = n - 1;
    register int center;
    register int s_left;
    register int s_right; //M:1, F:-1

    char c;

    cout << 0 << endl;
    cin >> c;
    s_left = sex(c);

    cout << n - 1 << endl;
    cin >> c;
    s_right = sex(c);

    for (i; i < 15; i++) {

        center = ((left + right) / 4) * 2;
        cout << center << endl;
        cin >> c;

        if (s_left * sex(c) < 0) {
            right = center;
            s_right = sex(c);
        } else {
            left = center;
            s_left = sex(c);
        }

    }

    center = (left + right) / 2;
    cout << center << endl;
    cout << center + 2 << endl;
    cout << center - 2 << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |     register int n;
      |                  ^
a.cc:35:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   35 |     register int left = 0;
      |                  ^~~~
a.cc:36:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |     register int right = n - 1;
      |                  ^~~~~
a.cc:37:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |     register int center;
      |                  ^~~~~~
a.cc:38:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   38 |     register int s_left;
      |                  ^~~~~~
a.cc:39:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |     register int s_right; //M:1, F:-1
      |                  ^~~~~~~
a.cc:51:10: error: 'i' was not declared in this scope
   51 |     for (i; i < 15; i++) {
      |          ^
a.cc: In function 'int sex(char)':
a.cc:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

string s[21];
int main(){
  int N;
  cin>>N;

  int h=N-1;
  int l=0;
  int now=-1;
  rep(idx,17){
    if(idx==0)cout<<0<<endl;
    else cout<<(h+l)/2<<endl;
    cin>>s[idx];
    if(s[idx]=="Vacant")return 0;
    if(idx>0 &&s[idx]==s[idx-1]){
      l=(h+l)/2;
    }else if(idx>0){
      h=(h+l)/2;
    }
    now=(h+l)/2;
  }

  cout <<now<<endl;
  string t;
  cin>>t;
  if(t=="Vacant")return 0;
  cout <<now+1<<endl;
  string t;
  cin>>t;
  if(t=="Vacant")return 0;

  cout <<now-1<<endl;
  string t;
  cin>>t;
  if(t=="Vacant")return 0;
  cout <<now+2<<endl;
  string t;
  cin>>t;
  if(t=="Vacant")return 0;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:10: error: redeclaration of 'std::string t'
   43 |   string t;
      |          ^
a.cc:39:10: note: 'std::string t' previously declared here
   39 |   string t;
      |          ^
a.cc:48:10: error: redeclaration of 'std::string t'
   48 |   string t;
      |          ^
a.cc:39:10: note: 'std::string t' previously declared here
   39 |   string t;
      |          ^
a.cc:52:10: error: redeclaration of 'std::string t'
   52 |   string t;
      |          ^
a.cc:39:10: note: 'std::string t' previously declared here
   39 |   string t;
      |          ^
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define INF 2000000000
#define LINF 9000000000000000000

typedef long long int ll;

int sex(char a) {
    switch (a) {
        case 'M':
            return 1;
        case 'F':
            return -1;
        case 'V':
            exit(0);
    }
}

int main() {
    register int n;
    cin >> n;

    register int left = 0;
    register int right = n - 1;
    register int center;
    register int s_left;
    register int s_right; //M:1, F:-1

    char c;

    cout << 0 << endl;
    cin >> c;
    s_left = sex(c);

    cout << n - 1 << endl;
    cin >> c;
    s_right = sex(c);

    int i = 0;
    for(i, i < 17, i++) {

        center = ((left + right) / 4) * 2;
        cout << center << endl;
        cin >> c;

        if (s_left * sex(c) < 0) {
            right = center;
            s_right = sex(c);
        } else {
            left = center;
            s_left = sex(c);
        }

    }

    center = (left + right) / 2;
    cout << center << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |     register int n;
      |                  ^
a.cc:35:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   35 |     register int left = 0;
      |                  ^~~~
a.cc:36:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |     register int right = n - 1;
      |                  ^~~~~
a.cc:37:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |     register int center;
      |                  ^~~~~~
a.cc:38:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   38 |     register int s_left;
      |                  ^~~~~~
a.cc:39:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |     register int s_right; //M:1, F:-1
      |                  ^~~~~~~
a.cc:52:23: error: expected ';' before ')' token
   52 |     for(i, i < 17, i++) {
      |                       ^
      |                       ;
a.cc:69:27: error: expected ')' before ';' token
   69 |     cout << center << endl;
      |                           ^
      |                           )
a.cc:52:8: note: to match this '('
   52 |     for(i, i < 17, i++) {
      |        ^
a.cc: In function 'int sex(char)':
a.cc:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^
Language: C

/*
 AtCoder AXC 000
 */
 
#include <stdio.h>
 
int main(void){
	//setvbuf(stdout, (char *)NULL, _IONBF, 0);
	
	int N;
	scanf("%d",&N);
	
	int num;
	int h=0;
	int t=N;
	int c=(h+t)/2;
	char head[10];
	char tail[10];
	char center[10];
	//int flag = 0;
	
	/* First Attempt */
	printf("%d\n",h);
	fflush(stdout);
	scanf("%s",head);
	fflush(stdin);
	
	
	while(center[0] != 'V')
	{
		c = (h+t)/2;
		
		printf("%d\n",c);
		fflush(stdout);
		scanf("%s",center);
		fflush(stdin);
		
		num = c - h + 1; // Center - Head
		if(head[0] == center[0] ^ num%2 == 1){
			t = c;
			tail[0] = center[0];
		}
		else{
			h = c;
			head[0] = center[0]
		}
	}
	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:45:44: error: expected ';' before '}' token
   45 |                         head[0] = center[0]
      |                                            ^
      |                                            ;
   46 |                 }
      |                 ~
Language: C

/*
 AtCoder AXC 000
 */
 
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	
	int num;
	int h=0;
	int t=N;
	int c=(h+t)/2;
	char head[10];
	char tail[10];
	char center[10];
	//int flag = 0;
	
	/* First Attempt */
	printf("%d\n",h);
	fflush(stdout);
	scanf("%s",head);
	fflush(stdin);
	
	
	while(center[0] != 'V')
	{
		c = (h+t)/2;
		
		printf("%d\n",c);
		fflush(stdout);
		scanf("%s",center);
		fflush(stdin);
		
		num = c - h + 1; // Center - Head
		if(head[0] == center[0] ^ num%2 == 1){
			t = c;
			tail[0] = center[0];
		}
		else{
			h = c;
			head[0] = center[0]
		}
	}
	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:43:44: error: expected ';' before '}' token
   43 |                         head[0] = center[0]
      |                                            ^
      |                                            ;
   44 |                 }
      |                 ~
Language: C

/*
 AtCoder AXC 000
 */
 
#include <stdio.h>

int main(void){
	setvbuf(stdout, (char *)NULL, _IONBF, 0);
	
	int N;
	scanf("%d",&N);
	
	int num;
	int h=0;
	int t=N;
	int c=(h+t)/2;
	char head[10];
	char tail[10];
	char center[10];
	//int flag = 0;
	
	/* First Attempt */
	printf("%d\n",h);
	fflush(stdout);
	scanf("%s",head);
	fflush(stdin);
	
	
	while(center[0] != 'V')
	{
		c = (h+t)/2;
		
		printf("%d\n",c);
		fflush(stdout);
		scanf("%s",center);
		fflush(stdin);
		
		num = c - h + 1; // Center - Head
		if(head[0] == center[0] ^ num%2 == 1){
			t = c;
			tail[0] = center[0];
		}
		else{
			h = c;
			head[0] = center[0]
		}
	}
	
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:45:44: error: expected ';' before '}' token
   45 |                         head[0] = center[0]
      |                                            ^
      |                                            ;
   46 |                 }
      |                 ~
Language: C++

#include <iostream>
#include <vector>
using namespace std;

// r - l is even
void different (int d, const string &left, int l, int r) {
  if (20 == d) return;
  int c = (l + r) / 2;
  cout << c << endl << flush;
  string center;
  cin >> center;
  if ("Vacant" == center) return;

  if (left == center)
    if (0 == (c - l) % 2) different(d+1, center, c, r);
    else same(d+1, center, l, c);
  else
    if (0 == (c - l) % 2) different(d+1, center, l, c);
    else same(d+1, center, c, r);
}

// r - l is odd
void same (int d, const string &left, int l, int r) {
  if (20 == d) return;
  int c = (l + r) / 2;
  cout << c << endl << flush;
  string center;
  cin >> center;
  if ("Vacant" == center) return;

  if (left == center)
    if (0 == (c - l) % 2) same(d+1, center, c, r);
    else same(d+1, center, l, c);
  else
    if (0 == (c - l) % 2) different(d+1, center, l, c);
    else different(d+1, center, c, r);
}

int main () {
  int n;
  cin >> n;
  string left, there;
  cout << 0 << endl << flush;
  cin >> left;
  if ("Vacant" == left) return 0;

  same(1, left, 0, n);
  return 0;
}


Compiler output:
a.cc: In function 'void different(int, const std::string&, int, int)':
a.cc:16:10: error: 'same' was not declared in this scope
   16 |     else same(d+1, center, l, c);
      |          ^~~~
a.cc:19:10: error: 'same' was not declared in this scope
   19 |     else same(d+1, center, c, r);
      |          ^~~~
Language: C++

#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define INF 10000000

typedef long long ll;
typedef pair<ll, ll> P;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    int n, i = 0;
    char ans[10];
    cin >> n;

    bool flags[n];
    fill(flags, flags+n, false); //もう来たかどうか

    int c = 20;
    printf("%d\n", i);
    fflush(stdout); c--;
    flags[i] = true;
    scanf("%s", ans);
    while (c && ans != "Vacant") {
        while (flags[i]) i++;
        printf("%d\n", i);
        fflush(stdout); c--;
        flags[i] = true;
        char newans[10];
        scanf("%s", newans);
        if (ans != newans) {
            printf("%d\n", i-1);
            fflush(stdout); break;
        }
        else if(newans == "Vacant"){
            printf("%d\n", i);
            fflush(stdout); break;
        }
        i += 2; i %= n;
        ans = newans;
    }
}

int main(void){
  solve();
  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:54:13: error: invalid array assignment
   54 |         ans = newans;
      |         ~~~~^~~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
using namespace std;
int dp[100005];
void check(int l,int r)
{
	while(l<=r)
	{
		int mid=(l+r)/2;
		char tmp[10];
		printf("%d\n",mid);
		scanf("%s",tmp);
		if(tmp[0]=='V')break;
		else if(tmp[0]=='M')dp[mid]=1;
		else if(tmp[0]=='F')dp[mid]=0;
		if(dp[mid]==dp[l]&&((mid-l)%2==1))r=mid;
		else if(dp[mid]!=dp[l]&&((mid-l)%2==0))r=mid;
		else l=mid;
		if(l==r-1||l==r)l++;
	}
}
int main()
{
	int n;
	char tmp[10];
	scanf("%d",&n);
	memset(dp,-1,sizeof(dp));
	puts("0");
	scanf("%s",tmp);
	if(tmp[0]=='V')return 0;
	else 
	{
	 if(tmp[0]=='M')dp[0]=1;
	 if(tmp[0]=='F')dp[0]=0;
	 check(0,n-1);
    }
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'memset' was not declared in this scope
   27 |         memset(dp,-1,sizeof(dp));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<cstdio>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include<cstdio>
using namespace std;
#define ll long long 
int n,a[10002],b[10002];
ll sum,opt1,opt2;
int main(void){
	register int i;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a[i]),sum-=a[i];
	for(i=1;i<=n;++i)scanf("%d",&b[i]),sum+=b[i];
	if(sum<0){
		puts("No");
		return 0;
	}
	if(sum==0){
		for(i=1;i<=n;++i)
			if(a[i]!=b[i]){
				puts("No");
				return 0;
			}
		puts("Yes");
		return 0;
	}
	opt1=opt2=sum;
	for(i=1;i<=n;++i){
		if(a[i]<b[i]){
			if((b[i]-a[i])&1){
				opt1-=(b[i]-a[i]+1)>>1;
				opt2-=1;
			}else opt1-=(b[i]-a[i])>>1;
		}else if(a[i]>b[i]){
			opt2-=a[i]-b[i];
		}
	}
	if(opt1<0||opt2<0)puts("No");
	else if(2*opt1==opt2)puts("Yes");
	else puts("No");
	return 0;
}
23:01:22
姜一洲 2018/2/3 23:01:22

	fflush(stdout);  
23:56:02
姜一洲 2018/2/3 23:56:02
#include<cstdio>
#include<algorithm>
using namespace std;
int n,sl,sr,ml,mr;
char s[10001];
int main(void){
	register int i=0,mid,x;
	scanf("%d",&n);
	sl=0,sr=n>>1;
	printf("%d\n",sl);
	fflush(stdout);  
	scanf("%s",s+1);
	switch(s[1]){
		case 'M':ml=0;break;
		case 'F':ml=1;break;
		case 'V':ml=2;break;
	}
	if(ml==2)return 0;
	printf("%d\n",sr);
	fflush(stdout); 
	scanf("%s",s+1);
	switch(s[1]){
		case 'M':mr=0;break;
		case 'F':mr=1;break;
		case 'V':mr=2;break;
	}
	if(mr==2)return 0;
	if((sr-sl&1)&&ml!=mr||(!(sr-sl&1))&&ml==mr){	
		sl=sr,sr=n;
		if(ml!=mr)swap(ml,mr);
	}
	while(++i<=19){
		mid=sl+sr+1>>1;
		printf("%d\n",mid);
        fflush(stdout);
        scanf("%s",s+1);
		switch(s[1]){
			case 'M':x=0;break;
			case 'F':x=1;break;
			case 'V':x=2;break;
		}
		if(x==2){
			return 0;
		}
		if((mid-sl&1)&&x!=ml||(!(mid-sl&1))&&x==ml){
			sl=mid,ml=x;
		}else sr=mid;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    7 |         register int i;
      |                      ^
a.cc: At global scope:
a.cc:40:1: error: expected unqualified-id before numeric constant
   40 | 23:01:22
      | ^~
a.cc:44:1: error: expected unqualified-id before numeric constant
   44 | 23:56:02
      | ^~
a.cc:49:5: error: redefinition of 'int n'
   49 | int n,sl,sr,ml,mr;
      |     ^
a.cc:4:5: note: 'int n' previously declared here
    4 | int n,a[10002],b[10002];
      |     ^
a.cc:51:5: error: redefinition of 'int main()'
   51 | int main(void){
      |     ^~~~
a.cc:6:5: note: 'int main()' previously defined here
    6 | int main(void){
      |     ^~~~
a.cc: In function 'int main()':
a.cc:52:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   52 |         register int i=0,mid,x;
      |                      ^
a.cc:52:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   52 |         register int i=0,mid,x;
      |                          ^~~
a.cc:52:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   52 |         register int i=0,mid,x;
      |                              ^
Language: C++

#include<iostream>
#include<cstdio>
using namespace std;
 
int n,lstp,nxtp,lst,nxt,now,nowp;
char s[10];
 
int main()
{
	scanf("%d",&n);
　　fflush(stdout);
	printf("0");
	fflush(stdout);
	scanf("%s",s);
　　fflush(stdout);
	if (s[0] == 'V') return 0;
	if (s[0] == 'M') lst = nxt = 1;
	else lst = nxt = 0;
	while (s[0] != 'V')
	{
		nowp = (nxtp + (nxtp <= lstp ? n : 0) + lstp) / 2;
		printf("%d",nowp);
		fflush(stdout);
		scanf("%s",s);
　　　　　fflush(stdout);
		if (s[0] == 'V') return 0;
		if (s[0] == 'M') now = 1;
		else now = 0;
		if (now == lst && ((nowp - lstp) & 1))
		{
			nxt = now,nxtp = nowp;
			continue;
		}
		if (now == nxt && ((nxtp + (nxtp <= lstp ? n : 0) - nowp) & 1))
		{
			lst = now,lstp = nowp;
			continue;
		}
		if (now != lst && !((nowp - lstp) & 1))
		{
			nxt = now,nxtp = nowp;
			continue;
		}
		if (now != nxt && !((nxtp + (nxtp <= lstp ? n : 0) - nowp) & 1))
		{
			lst = now,lstp = nowp;
			continue;
		}
	}
	
	return 0;
}

Compiler output:
a.cc:11:1: error: extended character 　 is not valid in an identifier
   11 | 　　fflush(stdout);
      | ^
a.cc:11:1: error: extended character 　 is not valid in an identifier
a.cc:15:1: error: extended character 　 is not valid in an identifier
   15 | 　　fflush(stdout);
      | ^
a.cc:15:1: error: extended character 　 is not valid in an identifier
a.cc:25:1: error: extended character 　 is not valid in an identifier
   25 | 　　　　　fflush(stdout);
      | ^
a.cc:25:1: error: extended character 　 is not valid in an identifier
a.cc:25:1: error: extended character 　 is not valid in an identifier
a.cc:25:1: error: extended character 　 is not valid in an identifier
a.cc:25:1: error: extended character 　 is not valid in an identifier
a.cc: In function 'int main()':
a.cc:11:1: error: '\U00003000\U00003000fflush' was not declared in this scope
   11 | 　　fflush(stdout);
      | ^~~~~~~~~~
a.cc:25:1: error: '\U00003000\U00003000\U00003000\U00003000\U00003000fflush' was not declared in this scope
   25 | 　　　　　fflush(stdout);
      | ^~~~~~~~~~~~~~~~