Problem:
Problem E:
足し算ゲーム
ねこのファーブルは足し算を用いた簡単なゲームを思いつき、同じくねこで友達のオードリーと一緒にやってみることにした。
ゲームのルールは次のようなものである。まず最初に、適当な正の整数を選び、そこからスタートする。各プレーヤーは、その数のうち隣り合う2つの桁を選択して和を計算し、もとの2つの数字と置き換える。たとえば、「1234」の十の位と百の位を選ぶと、次の数は「154」となる。「5555」の十の位と百の位を選んだ場合は「5105」となる。このような操作を数が1桁になるまで交互に繰り返し、操作ができなくなったプレーヤーが負けとなる。
ゲーム開始時の整数の値が与えられる。先攻であるファーブルと後攻であるオードリーがいずれも最適な戦略を取るとき、どちらが勝つのかを判定するプログラムを作成せよ。
Input
入力は、ゲーム開始時の数を表す1000桁以下の正の整数が1つ書かれた1行のみからなる。なお、最上位の桁は0ではない。
Output
ファーブルが勝つなら "Fabre wins."、オードリーが勝つなら "Audrey wins." と1行に出力せよ。最後にピリオドをつける必要があることに注意すること。
Notes on Submission
上記形式で複数のデータセットが与えられます。入力データの 1 行目にデータセットの数が与えられます。各データセットに対する出力を上記形式で順番に出力するプログラムを作成して下さい。
Sample Input
3
1234
5555
9
Output for the Sample Input
Audrey wins.
Fabre wins.
Audrey wins.

Submitted solutions:

code_snippet: #include<iostream>
#include<string>
using namespace std;
int solve(string S) {
	if (S.size() == 1)return 0;
	string U = S;
	int F = (int)(U[0] - '0') + (int)(U[1] - '0');
	U = to_string(F) + U.substr(2, U.size() - 2);
	return solve(U) + 1;
}
string T;
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> T; int P = solve(T);
		if (P % 2 == 0)cout << "Audrey wins." << endl;
		if (P % 2 == 1)cout << "Fabre wins." << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4372
final_rank: 13

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
string to_str(int a){
	string s="";
	while(a){
		s=(char)(a%10+'0')+s;
		a/=10;
	}
	if(s=="")s="0";
	return s;
}
int main(){
	int q;
	cin>>q;
	while(q--){
		string s;
		cin>>s;
		int out=0;
		while(s.size()!=1){
			int t=s[0]+s[1]-'0'-'0';
			s=to_str(t)+s.substr(2);
			out^=1;
		}
		if(!out)cout<<"Audrey wins."<<endl;
		else cout<<"Fabre wins."<<endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 1216
final_rank: 2

code_snippet: #include <iostream>
#include <algorithm>
#include <string>

using namespace std;

#define A cout << "Audrey wins." << endl
#define F cout << "Fabre wins." << endl
 
int c2i(char s){
    return s-'0';
}
 
string c2s(char aa,char bb){
    int a = c2i(aa)+c2i(bb);
    if(a == 0) return "0";
 
    string s = "";
    while(a > 0){
	s += ((a%10)+'0');
	a /= 10;
    }
    reverse(s.begin(),s.end());
    return s;
}
 
int main(){
    int n;
 
    cin >> n;
    while(n--){
	string str;
	cin >> str;
     
	int cnt = 0;
	while(str.size() >= 2){
	    cnt++;
	    int pos = str.size()-2;
	    string tmp = c2s(str[pos],str[pos+1]);
	    if(pos >= 0) str = str.substr(0,pos) + tmp;
	}
	if(cnt%2) F;
	else A;    
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 2992
final_rank: 9

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

int main(){
  int n;
  cin>>n;
  while(n--){
    string str;
    cin>>str;

    int cnt=1;
    while(str.size()!=1){
       cnt++;
      int a=(str[0]-'0')+(str[1]-'0');
      string b;
      if(a>=10) b+=(a/10+'0'),b+=(a%10+'0');
      else b=(a+'0');
      str=b+str.substr(2,str.size());
    }


  if(cnt%2)cout <<"Audrey wins."<<endl;
  else cout <<"Fabre wins."<<endl;
  }

  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1212
final_rank: 5

code_snippet: #include<bits/stdc++.h>
using namespace std;
 
string itos(int x){
  string r;
  while(x){
    r+=x%10+'0';
    x/=10;
  }
  reverse(r.begin(),r.end());
  return r;
}
 
int main(){
  int n,cnt;
  string s;
  cin>>n;
  while(n--){
    cin>>s;
    cnt=0;
    for(int i=0;i<s.size()-1;i++){
      int cal=s[i]-'0'+s[i+1]-'0';
      string sub=s.substr(i+2,s.size()-i);
      string ts=itos(cal);
      s=ts+sub;
      cnt++;
      if(s.size()==1)break;
      i=-1;
    }
    if(cnt%2)cout<<"Fabre wins."<<endl;
    else cout<<"Audrey wins."<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1212
final_rank: 1

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

string itos(int x){
  string r;
  while(x){
    r+=x%10+'0';
    x/=10;
  }
  reverse(r.begin(),r.end());
  return r;
}

int main(){
  int n,cnt;
  string s;
  cin>>n;
  while(n--){
    cin>>s;
    cnt=0;
    for(int i=0;i<s.size()-1;i++){
      int cal=s[i]-'0'+s[i+1]-'0';
      string sub=s.substr(i+2,s.size()-i);
      string ts=itos(cal);
      s=ts+sub;
      cnt++;
      if(s.size()==1)break;
      i=-1;
    }
    if(cnt%2)cout<<"Fabre wins."<<endl;
    else cout<<"Audrey wins."<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1212
final_rank: 5

code_snippet: #include <iostream>
#include <sstream>

/*
 * [Addition Game | Aizu Online Judge](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2189 "Addition Game | Aizu Online Judge")
 * ????????? : ??????<marony@binbo-kodakusan.com>
 * ?????¨?¨???? C++
 */
using namespace std;

auto solve(string q, int t) -> int {
    if (q.length() <= 1)
        return t;

    int x, y;
    stringstream ss;
    ss << q[0];
    ss >> x;
    ss.clear();
    ss.str("");
    ss << q[1];
    ss >> y;
    ss.clear();
    ss.str("");
    ss << x + y;
    ss << q.substr(2);
    return solve(ss.str(), (t + 1) % 2);
}

auto main() -> int {
    int n;
    cin >> n;

    string q;
    for (int i = 0; i < n; ++i) {
        cin >> q;
        if (solve(q, 0) != 0)
            cout << "Fabre wins." << endl;
        else
            cout << "Audrey wins." << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 6580
final_rank: 19

code_snippet: #include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <sstream>
using namespace std;
#define N(X) ((X)-'0')

string update(string &s) {
	int count = 0;
	while(1 < s.size()) {
		stringstream ss;
		ss << N(s[0]) + N(s[1]);
		s.erase(0, 2);
		s.insert(0, ss.str());
		count++;
	}
	cout << ((count % 2) ? "Fabre" : "Audrey") << " wins." << endl;
	return s;
}

int main() {
	int n; cin >> n;
	string str;
	while(n--) {
		cin >> str;
		update(str);
	}
}
accuracy: 1
time_ms: 20
memory_kb: 1248
final_rank: 8

code_snippet: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int total_test_cases;
  while(~scanf("%d",&total_test_cases)){
    for(int test_i = 0; test_i < total_test_cases; test_i++){
      string tmp_stage;
      cin >> tmp_stage;
      vector<int> stage;
      for(int i = 0; i < tmp_stage.size(); i++){
        stage.push_back(tmp_stage[i] - '0');
      }

      int count = 0;
      while(stage.size() >= 2){
        stringstream ss;
        ss << (stage[stage.size()-2] + stage[stage.size()-1]);
        stage.pop_back();
        stage.pop_back();
        for(int i = 0; i < ss.str().size(); i++){
          stage.push_back(ss.str()[i] - '0');
        }
        count++;
      }
      printf("%s\n",count % 2 == 0 ? "Audrey wins." : "Fabre wins.");
    }
  }
}
accuracy: 1
time_ms: 30
memory_kb: 1276
final_rank: 12

code_snippet: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main() {
  int T; cin >>T;
  while(T--){
    string N; cin >>N;
    int cnt = 0;
    while(N.length() > 1){
      int m = (N[0] - '0') + (N[1] - '0');
      stringstream ss;
      ss << m;
      N = ss.str() + N.substr(2);
      ++cnt;
    }
    cout <<(cnt % 2 ? "Fabre wins." : "Audrey wins.") <<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 1228
final_rank: 10

code_snippet: #include <iostream>
#include <unordered_map>

using namespace std;

unordered_map<string, bool> memo;

inline string Sum(int i, string s)
{
    int sum = (s[i] - '0') + (s[i + 1] - '0');
    string res = s.substr(0, i);

    if (sum / 10 == 0)
        res += (char)(sum + '0');
    else {
        res += (char)((sum / 10) + '0');
        res += (char)((sum % 10) + '0');
    }

    if (s.size() == i + 1)
        return res;
    else
        return res + s.substr(i + 2, s.size() - (i + 2));
}

int main()
{
    int t;

    cin >> t;
    while (t--) {
        string s;
        int ft = 0;

        cin >> s;
        while (1 < s.size()) {
            s = Sum(0, s);
            ft = 1 - ft;
        }

        if (ft == 1)
            cout << "Fabre wins.\n";
        else
            cout << "Audrey wins.\n";
    }

    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1208
final_rank: 4

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define A cout << "Audrey wins." << endl
#define F cout << "Fabre wins." << endl

int c2i(char s){
  return s-'0';
}

string c2s(char aa,char bb){
  int a = c2i(aa)+c2i(bb);
  if(a == 0) return "0";

  string s = "";
  while(a > 0){
    s += ((a%10)+'0');
    a /= 10;
  }
  reverse(s.begin(),s.end());
  return s;
}

int main(){
  int n;

  cin >> n;
  while(n--){
    string str;
    cin >> str;
    
    int cnt = 0;
    while(str.size() >= 2){
      cnt++;
      int pos = str.size()-2;
      string tmp = c2s(str[pos],str[pos+1]);
      if(pos >= 0) str = str.substr(0,pos) + tmp;
    }
    if(cnt%2) F;
    else A;    
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1216
final_rank: 7

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;
#define A cout << "Audrey wins." << endl
#define F cout << "Fabre wins." << endl

string i2s(int num){
  string s;
  stringstream ss;

  ss << num;
  ss >> s;

  return s;
}

int main(){
  int n;

  cin >> n;
  while(n--){
    string str;
    cin >> str;
    
    int cnt = 0;
    while(str.size() >= 2){
      cnt++;
      int pos = str.size()-2;
      int sum = (str[pos]-'0')+(str[pos+1]-'0');
      string tmp = i2s(sum);
      str = str.substr(0,pos) + tmp;
    }
    if(cnt%2) F;
    else A;    
  }
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 1232
final_rank: 14

code_snippet: #include<iostream>
#include<sstream>

using namespace std;
string tmp,str;
int num,ans[2],n;

string i2s(int num){
  string str;
  stringstream s;
  s<<num;
  s>>str;
  return str;
}
  
void dfs(string str,int cnt){
  if(str.size()==1){
    ans[cnt%2]=1;
    return;
  }
  tmp="";
  num=(str[0]-'0')+(str[1]-'0');
  tmp+=i2s(num);
  if(str.size()>2)tmp+=str.substr(2,str.size()-2);
  dfs(tmp,cnt+1);
}
int main(){
  cin>>n;
  while(n--){
    ans[0]=ans[1]=0;
    string str;
    cin>>str;
    dfs(str,0);
    if(!ans[0]) cout<<"Fabre wins."<<endl;
    else cout<<"Audrey wins."<<endl;
    
  }
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 2412
final_rank: 17

code_snippet: #include<iostream>
#include<sstream>


using namespace std;
string tmp;
int num,ans[2];

string i2s(int num){
  string str;
  stringstream s;
  s<<num;
  s>>str;
  return str;

}
  
void dfs(string str,int cnt){
  //cout<<str<<' '<<cnt;
  //if(str.size()==1)cout<<"-----"<<endl;
  //else cout<<endl;
  if(str.size()==1){
    ans[cnt%2]=1;
  }


  if(str.size()>1){
    for(int i=0;i<1;i++){
      tmp="";
      tmp+=str.substr(0,i);
      num=(str[i]-'0')+(str[i+1]-'0');
      tmp+=i2s(num);
      tmp+=str.substr(i+2,str.size()-(i+2));
      dfs(tmp,cnt+1);
    }
  }
}
int main(){
  int n;
  cin>>n;
  while(n--){
    ans[0]=ans[1]=0;
    string str;
    cin>>str;
    dfs(str,0);
    //cout<<ans[0]<<' '<<ans[1]<<endl;
    if(ans[0]==0){
      cout<<"Fabre wins."<<endl;
    }else{
      cout<<"Audrey wins."<<endl;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 2440
final_rank: 18

code_snippet: #include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main() {
  int n;
  cin >> n;
  while(n--) {
    string s;
    cin >> s;
    int t=1;
    while(s.size()!=1) {
      if(t) t=0;
      else t=1;
      stringstream ss;
      string t;
      ss << (int)s[s.size()-1]-48+(int)s[s.size()-2]-48;
      ss >> t;
      s=s.substr(0,s.size()-2)+t;
    }
    if(t) cout << "Audrey wins." << endl;
    else cout << "Fabre wins." << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 1232
final_rank: 14

code_snippet: #include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main() {
  int n;
  cin >> n;
  while(n--) {
    string s;
    cin >> s;
    int t=1,a[s.size()];
    while(s.size()!=1) {
      if(t) t=0;
      else t=1;
      int a[s.size()];
      for(int i=0; i<s.size(); i++) a[i]=(int)s[i]-48;
      int x=a[s.size()-1]+a[s.size()-2];
      stringstream ss;
      string t;
      ss << x;
      ss >> t;
      s=s.substr(0,s.size()-2)+t;
    }
    if(t) cout << "Audrey wins." << endl;
    else cout << "Fabre wins." << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 1236
final_rank: 16

code_snippet: #include<iostream>
#include<algorithm>
#include<sstream>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

string line;

string itos(int i){ stringstream ss; ss << i; return ss.str();}

void compute()
{
  int cnt = 0;
  string nline;
  while(line.size() > 1)
    {
      line = itos(line[0]-'0'+line[1]-'0') + line.substr(2,line.size()-2);
      cnt++;
    }
  cout << (cnt%2?"Fabre wins.":"Audrey wins.") << endl;
}

int main()
{
  int T;
  while(cin >>T)
    rep(_,T)
      {
	cin >> line;
	compute();
      }
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 1228
final_rank: 10

code_snippet: #include<iostream>
#include<string>
using namespace std;

inline void change(string &s){
  int a = s[0]-'0', b = s[1]-'0';
  string res;
  if(a+b>9){
    res += '0'+(a+b)/10;
    res += '0'+(a+b)%10;
  }else{
    res += '0'+a+b;
  }

  s = res + s.substr(2);
}

int main(){
  int n;
  string s;
  cin >> n;
  while(n--){
    cin >> s;
    int cnt = 0;
    while(s.size()>1)change(s), cnt++;
    cout << ((cnt&1)?"Fabre":"Audrey") << " wins.\n";
  }
}
accuracy: 1
time_ms: 20
memory_kb: 1200
final_rank: 3

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

#define REP(i,n) for(int i=0; i<n; i++)
#define RPA(i,s,e) for(int i=s; i<=e; i++)
#define RPD(i,s,e) for(int i=s; i>=e; i--)
#define PB(a) push_back(a)
#define MP(i,s) make_pair(i,s)
#define SZ(a) (int)(a).size()
#define ALL(a) (a).begin(), (a).end()
#define PRT(a) cout << (a) << endl
#define PRT2(a,b) cout << (a) << " " << (b) << endl
#define PRT3(a,b,c) cout << (a) << " " << (b) << " " << (c) << endl

typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> P;

int isWin(vector<int> num, int played) {
	if(num.size() == 1) return false;
	bool res = false;
	vector<int> next = num;
	int a = next.back(); next.pop_back();
	int b = next.back(); next.pop_back();
	if(a + b >= 10) {
		next.push_back(1);
		next.push_back((a + b) % 10);
	} else {
		next.push_back(a + b);
	}
	if(!isWin(next, played+1)) res = true;

	return res;
}

void coding() {
	int n;
	string num;
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		cin >> num;
		vector<int> v;
		for(int k=0; k<num.size(); k++) {
			v.push_back(num[k] - '0');
		}
		if(isWin(v, 0)) {
			printf("Fabre wins.\n");
		} else {
			printf("Audrey wins.\n");
		}
	}
}

// #define _LOCAL_TEST

int main() {
#ifdef _LOCAL_TEST
	clock_t startTime = clock();
	freopen("a.in", "r", stdin);
#endif

	coding();

#ifdef _LOCAL_TEST
	clock_t elapsedTime = clock() - startTime;
	cout << endl;
	cout << (elapsedTime / 1000.0) << " sec elapsed." << endl;
	cout << "This is local test" << endl;
	cout << "Do not forget to comment out _LOCAL_TEST" << endl << endl;
#endif
}
accuracy: 1
time_ms: 80
memory_kb: 9344
final_rank: 20