Problem:
Problem B:
Hyper Rock-Scissors-Paper
Rock-Scissors-Paper is a game played with hands and often used for random choice of a person for some
purpose. Today, we have got an extended version, namely,
Hyper Rock-Scissors-Paper
(or Hyper RSP
for short).
In a game of Hyper RSP, the players simultaneously presents their hands forming any one of the following
15 gestures: Rock, Fire, Scissors, Snake, Human, Tree, Wolf, Sponge, Paper, Air, Water, Dragon, Devil,
Lightning, and Gun.
Figure 1: Hyper Rock-Scissors-Paper
The arrows in the figure above show the defeating relation. For example, Rock defeats Fire, Scissors,
Snake, Human, Tree, Wolf, and Sponge. Fire defeats Scissors, Snake, Human, Tree, Wolf, Sponge, and
Paper. Generally speaking, each hand defeats other seven hands located after in anti-clockwise order in
the figure. A player is said to win the game if the player’s hand defeats at least one of the other hands,
and is not defeated by any of the other hands.
Your task is to determine the winning hand, given multiple hands presented by the players.
Input
The input consists of a series of data sets. The first line of each data set is the number
N
of the players
(
N
< 1000). The next
N
lines are the hands presented by the players.
The end of the input is indicated by a line containing single zero.
Output
For each data set, output the winning hand in a single line. When there are no winners in the game,
output “Draw” (without quotes).
Sample Input
8
Lightning
Gun
Paper
Sponge
Water
Dragon
Devil
Air
3
Rock
Scissors
Paper
0
Output for the Sample Input
Sponge
Draw

Submitted solutions:

code_snippet: #include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<string> r = {
	"Rock",
	"Gun",
	"Lightning",
	"Devil",
	"Dragon",
	"Water",
	"Air",
	"Paper",
	"Sponge",
	"Wolf",
	"Tree",
	"Human",
	"Snake",
	"Scissors",
	"Fire"
};
int n; string s;
int main() {
	while (cin >> n, n) {
		vector<int> v;
		for (int i = 0; i < n; i++) {
			cin >> s;
			v.push_back(find(r.begin(), r.end(), s) - r.begin());
		}
		string ret = "Draw";
		for (int i = 0; i < v.size(); i++) {
			bool win = false, lose = false;
			for (int j = 0; j < v.size(); j++) {
				if (i == j) continue;
				int z = (v[j] - v[i] + 15) % 15;
				if (1 <= z && z <= 7) lose = true;
				if (8 <= z && z <= 14) win = true;
			}
			if (win && !lose) ret = r[v[i]];
		}
		cout << ret << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 140
memory_kb: 3308
final_rank: 19

code_snippet: #include <bits/stdc++.h>


using namespace std;
//make -f ../makefile SRC=
/*
15 gestures: 
Rock, Fire, Scissors, Snake, Human, Tree, Wolf, Sponge, Paper, Air, Water, Dragon, Devil, Lightning, Gun
*/


//------------------------------------------------------------------------------
bool DEBUG = false;
static char buf[25];
const int INF = 1000000000;
const int M = 7;
const int N = 15;
static bool G[N][N];
static int indeg[N];
static int outdeg[N];
static map<string,int> to_vert =
{{"Rock", 0}, {"Fire", 1}, {"Scissors", 2}, {"Snake", 3}, {"Human", 4}, {"Tree", 5}, {"Wolf", 6}, {"Sponge", 7}, {"Paper", 8}, {"Air", 9}, {"Water", 10}, {"Dragon", 11}, {"Devil", 12}, {"Lightning", 13}, {"Gun", 14}};
static vector<string> to_str =
{
    "Rock","Fire","Scissors","Snake","Human"
    ,"Tree","Wolf","Sponge","Paper","Air"
    ,"Water","Dragon","Devil","Lightning","Gun"
};
void setup()
{
    for (int v=0; v<N; ++v) for (int w=0; w<N; ++w) G[v][w] = false;
    for (int v=0; v<N; ++v)
        for (int m=1; m<=M; ++m)
            G[v][(v+m)%15] = true;
}
//------------------------------------------------------------------------------
void solve(int K, const vector<int>& vs)
{
    //--------------------------------------------------------------------------
    // base cases:
    //--------------------------------------------------------------------------
    // init:
    for (int v=0; v<N; ++v) { indeg[v] = 0; outdeg[v] = 0; }
    //--------------------------------------------------------------------------
    // compute:
    for (int k1=0; k1<K; ++k1)
    {
        for (int k2=0; k2<K; ++k2)
        {
            if (k2 == k1) continue;
            if (G[ vs[k1] ][ vs[k2] ])
            {
                outdeg[ vs[k1] ]++;
                indeg[ vs[k2] ]++;
            }
        }
    }
    //--------------------------------------------------------------------------
    bool winning = false;
    for (int v=0; v<N; ++v)
        if (!indeg[v] && outdeg[v])
            { printf("%s\n", to_str[v].c_str()); winning = true; break; }
    if (!winning) printf("Draw\n");
}

//------------------------------------------------------------------------------
void test()
{

}

//------------------------------------------------------------------------------
int main()
{
    //test(); return 0;
    //DEBUG = true;
    setup();
    //--------------------------------------------------------------------------
    int K, num;
    while (true)
    {
        num = scanf("%d ", &K);
        if (K == 0) break;
        vector<int> vs(K);
        for (int k=0; k<K; ++k)
        {
            num = scanf("%s ", buf);
            vs[k] = to_vert[string(buf)];
        }
        solve(K, vs);
    }
    //--------------------------------------------------------------------------
    return 0;
}
//------------------------------------------------------------------------------
accuracy: 1
time_ms: 110
memory_kb: 3292
final_rank: 18

code_snippet: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
string hands[] = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge","Paper","Air","Water","Dragon", "Devil","Lightning","Gun"};
int check(string s)
{
	for(int i = 0; i < 15; i++)
		if(hands[i] == s)
			return i;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n)
	{
		int table[15][15];
		int flag[15] = {};
		memset(table, -1, sizeof(table));
		for(int i = 0; i < 15; i++)
		{
			bool flag = false;
			for(int j = 0; j < 15; j++)
			{
				int cnt = 7;
				if(i == j) 
				{
					table[i][j] = 0;
					int x = j;
					while(cnt--)
					{
						x++;
						table[i][x % 15] = 1;
					}
				}
			}
		}
		string str[n + 1];
		for(int i = 0; i < n; i++)
			cin >> str[i];
		int num[n + 1] = {};
		int max_p = 0, p;
		for(int i = 0; i < n; i++)
		{
			int y = check(str[i]);
			for(int j = 0; j < n; j++)
			{
				int x = check(str[j]);
				if(table[y][x] == -1)
				{
					num[i] = -1;
					break;
				}
				else 
					num[i] += table[y][x];
			}
			if(num[i] > max_p)
			{
				max_p = num[i];
				p = i;
			}
		}
		if(max_p == 0)
			cout << "Draw" << endl;
		else	
			cout << str[p] << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3068
final_rank: 12

code_snippet: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt;
  int w[15],t[15];
  string s;
  while(1){
    cin>>n;
    if(n==0) break;
    cnt=0;
    for(int i=0;i<15;i++){
      w[i]=1;
      t[i]=0;
    }
    for(int i=0;i<n;i++){
      cin>>s;
      if(s[0]=='R'){
	t[0]=1;
	for(int j=1;j<8;j++){
	  w[j]=0;
	}
      }
      else if(s[0]=='F'){
	t[1]=1;
	for(int j=2;j<9;j++){
	  w[j]=0;
	}
      }
       else if(s[0]=='S'){
	 if(s[1]=='c'){
	   t[2]=1;
	   for(int j=3;j<10;j++){
	     w[j]=0;
	   }
	 }
	 else if(s[1]=='n'){
	   t[3]=1;
	   for(int j=4;j<11;j++){
	     w[j]=0;
	   }
	 }
	 else if(s[1]=='p'){
	   t[7]=1;
	   for(int j=8;j<15;j++){
	     w[j]=0;
	   }
	 }
       }
       else if(s[0]=='H'){
	 t[4]=1;
	 for(int j=5;j<12;j++){
	   w[j]=0;
	 }
       }
       else if(s[0]=='T'){
	 t[5]=1;
	 for(int j=6;j<13;j++){
	   w[j]=0;
	 }
       }
       else if(s[0]=='W'){
	 if(s[1]=='o'){
	   t[6]=1;
	   for(int j=7;j<14;j++){
	     w[j]=0;
	   }
	 }
	 else if(s[1]=='a'){
	   t[10]=1;
	   for(int j=11;j<15;j++){
	     w[j]=0;
	   }
	   for(int j=0;j<3;j++){
	     w[j]=0;
	   }
	 }
       }
       else if(s[0]=='P'){
	 t[8]=1;
	 w[0]=0;
	 for(int j=9;j<15;j++){
	   w[j]=0;
	 }
       }
      else if(s[0]=='A'){
	 t[9]=1;
	 w[0]=0;
	 w[1]=0;
	 for(int j=10;j<15;j++){
	   w[j]=0;
	 }
       }
      else if(s[0]=='D'){
	if(s[1]=='r'){
	  t[11]=1;
	  for(int j=12;j<15;j++){
	    w[j]=0;
	  }
	   for(int j=0;j<4;j++){
	    w[j]=0;
	  }
	}
	else if(s[1]=='e'){
	  t[12]=1;
	  for(int j=13;j<15;j++){
	    w[j]=0;
	  }
	   for(int j=0;j<5;j++){
	    w[j]=0;
	  }
	}
      }
      else if(s[0]=='L'){
	t[13]=1;
	w[14]=0;
	for(int j=0;j<6;j++){
	  w[j]=0;
	}
      }
      else if(s[0]=='G'){
	t[14]=1;
	for(int j=0;j<7;j++){
	  w[j]=0;
	}
      }
    }
    for(int i=0;i<15;i++){
      if(t[i]==1) cnt++;
    }
    if(cnt==1) cout<<"Draw"<<endl;
    else{
      for(int i=0;i<15;i++){
	if(t[i]==1){
	  if(w[i]==1){
	    if(i==0){
	      cout<<"Rock"<<endl;
	      break;
	    }
	    else if(i==1){
	      cout<<"Fire"<<endl;
	      break;
	    }
	    else if(i==2){
	      cout<<"Scissors"<<endl;
	      break;
	    }
	    else if(i==3){
	      cout<<"Snake"<<endl;
	      break;
	    }
	    else if(i==4){
	      cout<<"Human"<<endl;
	      break;
	    }
	    else if(i==5){
	      cout<<"Tree"<<endl;
	      break;
	    }
	    else if(i==6){
	      cout<<"Wolf"<<endl;
	      break;
	    }
	    else if(i==7){
	      cout<<"Sponge"<<endl;
	      break;
	    }
	    else if(i==8){
	      cout<<"Paper"<<endl;
	      break;
	    }
	    else if(i==9){
	      cout<<"Air"<<endl;
	      break;
	    }
	    else if(i==10){
	      cout<<"Water"<<endl;
	      break;
	    }
	    else if(i==11){
	      cout<<"Dragon"<<endl;
	      break;
	    }
	    else if(i==12){
	      cout<<"Devil"<<endl;
	      break;
	    }
	    else if(i==13){
	      cout<<"Lightning"<<endl;
	      break;
	    }
	    else if(i==14){
	      cout<<"Gun"<<endl;
	      break;
	    }
	  }
	}
	if(i==14) cout<<"Draw"<<endl;
      }
    }
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3144
final_rank: 14

code_snippet: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
string hands[] = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge","Paper","Air","Water","Dragon", "Devil","Lightning","Gun"};
int check(string s)
{
	for(int i = 0; i < 15; i++)
		if(hands[i] == s)
			return i;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n)
	{
		int table[15][15];
		int flag[15] = {};
		memset(table, -1, sizeof(table));
		for(int i = 0; i < 15; i++)
		{
			bool flag = false;
			for(int j = 0; j < 15; j++)
			{
				int cnt = 7;
				if(i == j) 
				{
					table[i][j] = 0;
					int x = j;
					while(cnt--)
					{
						x++;
						table[i][x % 15] = 1;
					}
				}
			}
		}
		string str[n + 1];
		for(int i = 0; i < n; i++)
			cin >> str[i];
		int num[n + 1] = {};
		int max_p = 0, p;
		for(int i = 0; i < n; i++)
		{
			int y = check(str[i]);
			for(int j = 0; j < n; j++)
			{
				int x = check(str[j]);
				if(table[y][x] == -1)
				{
					num[i] = -1;
					break;
				}
				else 
					num[i] += table[y][x];
			}
			if(num[i] > max_p)
			{
				max_p = num[i];
				p = i;
			}
		}
		if(max_p == 0)
			cout << "Draw" << endl;
		else	
			cout << str[p] << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3216
final_rank: 17

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

typedef long long ll;;

ll to_num(string s){
  if(s=="Rock"){return 0;}
  if(s=="Fire"){return 1;}
  if(s=="Scissors"){return 2;}
  if(s=="Snake"){return 3;}
  if(s=="Human"){return 4;}
  if(s=="Tree"){return 5;}
  if(s=="Wolf"){return 6;}
  if(s=="Sponge"){return 7;}
  if(s=="Paper"){return 8;}
  if(s=="Air"){return 9;}
  if(s=="Water"){return 10;}
  if(s=="Dragon"){return 11;}
  if(s=="Devil"){return 12;}
  if(s=="Lightning"){return 13;}
  if(s=="Gun"){return 14;}
  return -1;
}

string ans(ll a){
  if(a==0){return "Rock";}
  if(a==1)return "Fire";
  if(a==2)return "Scissors";
  if(a==3)return "Snake";
  if(a==4)return "Human";
  if(a==5)return "Tree";
  if(a==6)return "Wolf";
  if(a==7){return "Sponge";}
  if(a==8){return "Paper";}
  if(a==9){return "Air";}
  if(a==10){return "Water";}
  if(a==11){return "Dragon";}
  if(a==12){return "Devil";}
  if(a==13){return "Lightning";}
  if(a==14){return "Gun";}
  return "!";
}


int main(){
  while(1){
  vector<ll> count(30,0);
  ll n;
  cin>>n;
  if(n==0){break;}
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    count[to_num(s)]++;
    count[to_num(s)+15]++;
  }
  for(int i=1;i<30;i++){
    count[i]+=count[i-1];
  }
  bool done=false;
  for(int i=0;i<15 && !done;i++){
    if(i==0){
      if(count[i]!=0){
	if(count[i]==n){cout<<"Draw"<<endl; done=true;}
	else if(count[i+7]==n){cout<<"Rock"<<endl; done=true;}
      }
    }
    else{
      if(count[i]-count[i-1]!=0){
	if(count[i]-count[i-1]==n){cout<<"Draw"<<endl; done=true;}
	else if(count[i+7]-count[i-1]==n){cout<<ans(i)<<endl; done=true;}
      }
    }
  }
  if(!done){cout<<"Draw"<<endl;}

  }


  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3044
final_rank: 10

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;



ld dis(pair<ld, ld>l, pair<ld, ld>r) {
	ld dx=l.first-r.first;
	ld dy=l.second-r.second;
	return sqrt(ld(dx)*dx+ ld(dy)*dy);
}

ld get_x(pair<ld, ld>f, pair<ld, ld>t, ld y) {
	if(f.second>t.second)return get_x(t,f,y);

	ld a=y-f.second;
	ld b=t.second-y;

	return (t.first*a+f.first*b)/(a+b);
}

int main() {
	vector<string>sts{ 
		"Rock","Fire","Scissors","Snake","Human","Tree","Wolf","Sponge","Paper","Air","Water","Dragon","Devil","Lightning","Gun" };
	while (true) {
		int N;cin>>N;
		if(!N)break;
		vector<int>nums(N);
		for (int i = 0; i < N; ++i) {
			string st;cin>>st;
			nums[i]=find(sts.begin(),sts.end(),st)-sts.begin();
			assert(nums[i]!=15);
		}
		int ans_id=-1;
		for (int i = 0; i < N; ++i) {
			int ok=true;
			int num=0;
			for (int j = 0; j < N; ++j) {
				if(i==j)continue;
				int a=nums[i];
				int b=nums[j];

				int sa=a-b;
				if(sa<0)sa+=15;
				if (sa == 0) {

				}
				else if (sa <= 7) {
					ok=false;
				}
				else {
					num++;
				}
			}
			if(ok&&num>0)ans_id=i;
		}
		if(ans_id==-1)cout<<"Draw"<<endl;
		else cout<<sts[nums[ans_id]]<<endl;
	}
	return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 3140
final_rank: 16

code_snippet: #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string t,s[] = {"Rock", "Fire", "Scissors", "Snake", "Human","Tree", "Wolf", "Sponge", "Paper", "Air","Water", "Dragon", "Devil", "Lightning", "Gun" };
int a[30],b[30];
main(){
	int n;
	while(cin>>n,n){
		set<int>st;
		r(i,30)a[i]=b[i]=0;
		r(i,n){
			cin>>t;
			r(j,15)if(s[j]==t){
				st.insert(j);
				r(k,7){
				  b[j]++;
			  	  a[(j+k+1)%15]++;
			  	}
			 }
		}
		vector<string>v;
		r(i,15)if(b[i]&&!a[i])v.push_back(s[i]);
		if(v.size()==1&&st.size()!=1)cout<<v[0]<<endl;
		else cout<<"Draw"<<endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3104
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;
int main(){
	map<string,int>m;
	m["Rock"]=1;
	m["Fire"]=2;
	m["Scissors"]=3;
	m["Snake"]=4;
	m["Human"]=5;
	m["Tree"]=6;
	m["Wolf"]=7;
	m["Sponge"]=8;
	m["Paper"]=9;
	m["Air"]=10;
	m["Water"]=11;
	m["Dragon"]=12;
	m["Devil"]=13;
	m["Lightning"]=14;
	m["Gun"]=15;
	int n;
	while(cin>>n,n){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		in.erase(unique(all(in)),in.end());
		if(in.size()==1){
			cout<<"Draw"<<endl;
			continue;
		}
		vi w(in.size());
		rep(i,in.size())w[i]=m[in[i]];
		bool h=false;
		rep(i,in.size()){
			bool hh=true;
			rep(j,in.size()){
				int t=w[i],s=w[j];
				if(t==s)continue;
				if(t>s&&t-s<8||t<s&&15-s+t<8)hh=false;
			}
			if(hh){
				h=true;
				cout<<in[i]<<endl;
				break;
			}
		}
		if(!h)cout<<"Draw"<<endl;
	}
}
accuracy: 1
time_ms: 80
memory_kb: 1276
final_rank: 7

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;
int main(){
	map<string,int>m;
	m["Rock"]=1;
	m["Fire"]=2;
	m["Scissors"]=3;
	m["Snake"]=4;
	m["Human"]=5;
	m["Tree"]=6;
	m["Wolf"]=7;
	m["Sponge"]=8;
	m["Paper"]=9;
	m["Air"]=10;
	m["Water"]=11;
	m["Dragon"]=12;
	m["Devil"]=13;
	m["Lightning"]=14;
	m["Gun"]=15;
	int n;
	while(cin>>n,n){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		in.erase(unique(all(in)),in.end());
		if(in.size()==1){
			cout<<"Draw"<<endl;
			continue;
		}
		bool h=false;
		rep(i,in.size()){
			bool hh=true;
			rep(j,in.size()){
				int t=m[in[i]],s=m[in[j]];
				if(t==s)continue;
				if(t>s&&t-s<8||t<s&&15-s+t<8)hh=false;
			}
			if(hh){
				h=true;
				cout<<in[i]<<endl;
				break;
			}
		}
		if(!h)cout<<"Draw"<<endl;
	}
}
accuracy: 1
time_ms: 1460
memory_kb: 1272
final_rank: 9

code_snippet: #include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 15
 
const string gesture[MAX] = {
    "Rock","Fire","Scissors","Snake","Human","Tree","Wolf","Sponge",
    "Paper","Air","Water","Dragon","Devil","Lightning","Gun"
};
 
vector<int> v;
bool ges[MAX];
 
int solve(){
    int res = -1, N = (int)v.size();
 
    if(N == 1){
	return res;
    } 
 
    for(int i = 0 ; i < N ; i++){
	int win = 0, lose = 0;
	for(int j = 0 ; j < MAX ; j++){
	    if(v[i] == j || !ges[j]){
		continue;
	    }

	    int cnt = 0, pos = v[i];
	    while(true){
		pos++; cnt++;
		if(pos >= MAX){
		    pos = 0;
		}
 
		if(j == pos){
		    if(cnt > 7){
			lose++;
		    }else{
			win++;
		    }
		    break;
		}
	    }
	}
	if(win == N-1){
	    res = v[i];
	    break;
	}
    }
 
    return res;
}
 
int main(){
    int n;
 
    while(cin >> n ,n){
	string str;
	set<string> st;
 
	v.clear();
	memset(ges,false,sizeof(ges));
 
	for(int i = 0 ; i < n ; i++){
	    cin >> str;
	    if(st.count(str)){
		continue;
	    }
	    for(int j = 0 ; j < MAX ; j++){
		if(gesture[j] == str){
		    v.push_back(j);
		    st.insert(str);
		    ges[j] = true;
		    break;
		}
	    }
	}
    
	sort(v.begin(),v.end());
	int ans = solve();
 
	if(ans == -1){
	    cout << "Draw" << endl;
	}else{
	    cout << gesture[ans] << endl;
	}
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3144
final_rank: 14

code_snippet: #include<iostream>
#include<string>
using namespace std;
string S[15] = { "Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun" };
int N, a[10000], c[15]; string T;
bool solve(int a, int b) {
	if (a > b)b += 15;
	if (b - a <= 7)return true;
	return false;
}
int main() {
	while (true) {
		cin >> N;
		if (N == 0)break;
		for (int i = 0; i < N; i++) {
			cin >> T;
			for (int j = 0; j < 15; j++) {
				if (T == S[j])a[i] = j;
			}
		}
		for (int i = 0; i < 15; i++)c[i] = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (!solve(a[i], a[j]))goto E;
			}
			c[a[i]] = 1;
		E:;
		}
		int G = 0;
		for (int i = 0; i < N - 1; i++) {
			if (a[i] != a[i + 1])G = 1;
		}
		int P = 0;
		if (G == 0)goto F;
		for (int i = 0; i < 15; i++) {
			if (c[i] == 1) {
				P = 1; cout << S[i] << endl;
			}
		}
	F:;
		if (P == 0)cout << "Draw" << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1220
final_rank: 2

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

int main(){
  string mp[]={"Rock","Gun","Lightning","Devil","Dragon","Water","Air","Paper","Sponge","Wolf","Tree","Human","Snake","Scissors","Fire"};

  int n;
  while(cin>>n,n){
    string str[1001];
    for(int i=0;i<n;i++) cin>>str[i];
    
    string ans="Draw";
    set<string> S;
    for(int i=0;i<n;i++){
      if(S.count(str[i]))continue;
      S.insert(str[i]);
      int A=0;
      while(str[i]!=mp[A])A++;	
      int j;
      for(j=0;j<n;j++){
	if(str[i]==str[j])continue;
	int B=0;
	while(str[j]!=mp[B])B++;	
	if((15+B-A)%15<=7)break;
      }
      if(j==n) ans=str[i];
    }
    
    for(int i=1;i<n&&str[0]==str[i];i++)if(i==n-1)ans="Draw"; 

    cout << ans<<endl;
  }
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 1276
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s[15]={"Rock","Fire","Scissors","Snake","Human","Tree","Wolf","Sponge","Paper","Air","Water","Dragon","Devil","Lightning","Gun"};
  map<string,int> r;
  for(int i=0; i<15; i++) r[s[i]]=i;
  int n;
  while(cin >> n && n) {
    map<string,int> m;
    string t[n];
    for(int i=0; i<n; i++) {
      cin >> t[i];
      m[t[i]]++;
    }
    set<string> ans;
    for(int i=0; i<n; i++) {
      int k=r[t[i]];
      int c=0,c2=0;
      for(int j=0; j<7; j++) c+=m[s[(k+j+1)%15]];
      for(int j=0; j<7; j++) c2+=m[s[(k+j+8)%15]];
      if(c&&!c2) ans.insert(t[i]);
    }
    if(ans.size()==1) cout << *ans.begin() << endl;
    else cout << "Draw" << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 1276
final_rank: 4

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

string t[15]={
  "Rock",
  "Fire",
  "Scissors",
  "Snake",
  "Human",
  "Tree",
  "Wolf",
  "Sponge",
  "Paper",
  "Air",
  "Water",
  "Dragon",
  "Devil",
  "Lightning",
  "Gun"
};

int search(string s){
  for(int i=0;i<15;i++)if(t[i]==s)return i;
  assert(0);
  return 0;
}

int check(int a,int b){
  if(a==b)return 0;
  for(int i=1;i<=7;i++)if( (a+i)%15==b )return 1;
  return -1;
}

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vector<string> t(n);
    vector<int> u(n);
    for(int i=0;i<n;i++){
      cin>>t[i];
      u[i]=search(t[i]);
    }
    
    string ans="Draw";
    for(int i=0;i<n;i++){
      int A=0,B=0;
      for(int j=0;j<n;j++){
        int k=check(u[i],u[j]);
        if(k==1)A++;
        if(k==-1)B++;
      }
      if(A>0&&B==0)ans=t[i];
    }
    cout<<ans<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 460
memory_kb: 1272
final_rank: 8

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

int main(){
  int n,vlen;
  string str,ans;
  set<string> s;
  vector<string> v;
  vector<P> defdata;//1,0
  string d[15]={
    "Rock","Fire","Scissors","Snake","Human",
    "Tree","Wolf","Sponge","Paper","Air",
    "Water","Dragon","Devil","Lightning","Gun"
  };
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>str;
      s.insert(str);
    }
    for(int i=0;i<15;i++){
      set<string>::iterator ite;
      for(ite=s.begin();ite!=s.end();ite++){
	if(d[i]==(*ite)){
	  v.push_back(d[i]);
	  defdata.push_back(P(0,0));
	}
      }
    }
    vlen=v.size();
    for(int i=0;i<vlen;i++){
      for(int j=i+1;j<vlen;j++){
	int iid,jid;
	for(int k=0;k<15;k++)
	  if(v[i]==d[k])iid=k;
	for(int k=0;k<15;k++)
	  if(v[j]==d[k])jid=k;
	if(jid-iid<=7){
	  defdata[i].first++;
	  defdata[j].second++;
	}
	if(iid+15-jid<=7){
	  defdata[j].first++;
	  defdata[i].second++;
	}
      }
    }
    ans="0";
    for(int i=0;i<vlen;i++){
      int w=defdata[i].first;
      int l=defdata[i].second;
      if(w&&!l)ans=v[i];
    }
    if(ans!="0")cout<<ans<<endl;
    else cout<<"Draw"<<endl;
    s.clear();
    v.clear();
    defdata.clear();
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1216
final_rank: 1

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(asd,fgh) for(int asd=0; asd<fgh; asd++)

int main(void){
  vector< vector<string> > defeat;
  string handlist[] = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun"};
  map<string, int> hand;
  REP(i, 15){
    hand[handlist[i]] = i;
  }
  
  int N;
  while(cin >> N, N){
    vector<string> players(N);
    string ans = "Draw";
    REP(i, N){
      cin >> players[i];
    }
    string same = players[0];
    bool draw = true;
    REP(i, N){
      if(players[i] != same) draw = false;
    }
    if(draw){
      cout << ans << endl;
      continue;
    }
    REP(i, N){
      bool flg = true;
      REP(j, N){
	if(i == j) continue;
	if(!(((hand[players[j]] - hand[players[i]])+15)%15 <= 7)){
	  flg = false;
	}
      }
      if(flg)
	ans = players[i];
    }
    cout << ans << endl;
  }

  return 0;
}
accuracy: 1
time_ms: 2910
memory_kb: 1272
final_rank: 11

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

int main() {
  string s[15]={"Rock","Fire","Scissors","Snake","Human","Tree","Wolf","Sponge","Paper","Air","Water","Dragon","Devil","Lightning","Gun"};
  map<string,int> r;
  for(int i=0; i<15; i++) r[s[i]]=i;
  int n;
  while(cin >> n && n) {
    map<string,int> m;
    string t[n];
    for(int i=0; i<n; i++) {
      cin >> t[i];
      m[t[i]]++;
    }
    set<string> ans;
    for(int i=0; i<n; i++) {
      int k=r[t[i]];
      int c=0,c2=0;
      for(int j=0; j<7; j++) c+=m[s[(k+j+1)%15]];
      for(int j=0; j<7; j++) c2+=m[s[(k+j+8)%15]];
      if(c&&!c2) ans.insert(t[i]);
    }
    if(ans.size()==1) cout << *ans.begin() << endl;
    else cout << "Draw" << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 1280
final_rank: 6

code_snippet: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#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;
 
const static int tx[] = {0,1,0,-1};
const static int ty[] = {-1,0,1,0};

const static double EPS = 1e-8;

int main(){
  int num_of_players;
  map<string,int> dict;
  dict["Rock"] = 0;
  dict["Fire"] = 1;
  dict["Scissors"] = 2;
  dict["Snake"] = 3;
  dict["Human"] = 4;
  dict["Tree"] = 5;
  dict["Wolf"] = 6;
  dict["Sponge"] = 7;
  dict["Paper"] = 8;
  dict["Air"] = 9;
  dict["Water"] = 10;
  dict["Dragon"] = 11;
  dict["Devil"] = 12;
  dict["Lightning"] = 13;
  dict["Gun"] = 14;

  map<int,bool> canWin;
  for(int hand_i = 0; hand_i < 15; hand_i++){
    for(int hand_j = 0; hand_j < 15; hand_j++){
      canWin[hand_i * 15 + hand_j] = false;
      for(int offset = 1; offset <= 7; offset++){
        if(hand_j == (hand_i + offset) % 15){
          canWin[hand_i * 15 + hand_j] = true;
        }
      }
    }
  }

  while(~scanf("%d",&num_of_players)){
    if(num_of_players == 0){
      break;
    }
    vector<string> players;
    for(int player_i = 0; player_i < num_of_players; player_i++){
      string hand;
      cin >> hand;
      players.push_back(hand);
    }

    map<string,bool> lose;
    map<string,bool> win;

    set<string> hands;
    for(int player_i = 0; player_i < num_of_players; player_i++){
      hands.insert(players[player_i]);
    }
    for(set<string>::iterator ally_it = hands.begin(); ally_it != hands.end(); ally_it++){
      for(set<string>::iterator foe_it = hands.begin(); foe_it != hands.end(); foe_it++){
        if(canWin[dict[*ally_it] * 15 + dict[*foe_it]]){
          win[*ally_it] = true;
          lose[*foe_it] = true;
        }
      }
    }

    string res = "Draw";
    for(set<string>::iterator ally_it = hands.begin(); ally_it != hands.end(); ally_it++){
      if(win[*ally_it] && !lose[*ally_it]){
        res = *ally_it;
      }
    }
    printf("%s\n",res.c_str());
  }
}
accuracy: 1
time_ms: 30
memory_kb: 1304
final_rank: 5

code_snippet: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#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;
 
const static int tx[] = {0,1,0,-1};
const static int ty[] = {-1,0,1,0};

const static double EPS = 1e-8;

int main(){
  int num_of_players;
  map<string,int> dict;
  dict["Rock"] = 0;
  dict["Fire"] = 1;
  dict["Scissors"] = 2;
  dict["Snake"] = 3;
  dict["Human"] = 4;
  dict["Tree"] = 5;
  dict["Wolf"] = 6;
  dict["Sponge"] = 7;
  dict["Paper"] = 8;
  dict["Air"] = 9;
  dict["Water"] = 10;
  dict["Dragon"] = 11;
  dict["Devil"] = 12;
  dict["Lightning"] = 13;
  dict["Gun"] = 14;

  map<int,bool> canWin;
  for(int hand_i = 0; hand_i < 15; hand_i++){
    for(int hand_j = 0; hand_j < 15; hand_j++){
      canWin[hand_i * 15 + hand_j] = false;
      for(int offset = 1; offset <= 7; offset++){
        if(hand_j == (hand_i + offset) % 15){
          canWin[hand_i * 15 + hand_j] = true;
        }
      }
    }
  }

  while(~scanf("%d",&num_of_players)){
    if(num_of_players == 0){
      break;
    }
    vector<string> players;
    for(int player_i = 0; player_i < num_of_players; player_i++){
      string hand;
      cin >> hand;
      players.push_back(hand);
    }

    bool lose[1001] = {};
    bool win[1001] = {};
    for(int player_i = 0; player_i < num_of_players; player_i++){
      for(int player_j = player_i + 1; player_j < num_of_players; player_j++){
        if(canWin[dict[players[player_i]] * 15 + dict[players[player_j]]]){
          lose[player_j] = true;
          win[player_i] = true;
        }
        if(canWin[dict[players[player_j]] * 15 + dict[players[player_i]]]){
          lose[player_i] = true;
          win[player_j] = true;
        }
      }
    }

    string res = "Draw";
    for(int player_i = 0; player_i < num_of_players; player_i++){
      if(!lose[player_i] && win[player_i]){
        res = players[player_i];
        break;
      }
    }
    printf("%s\n",res.c_str());
  }
}
accuracy: 1
time_ms: 3350
memory_kb: 1304
final_rank: 20