criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	HashSet<String> set;

	void run(){
		for(;;){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			set=new HashSet<String>();
			for(int i=0; i<n; i++){
				set.add(sc.next());
			}
			solve();
		}
	}

	String[] ss;
	int n;

	void solve(){
		for(;;){
			String remove=null;
			for(String s : set){
				for(String t : set){
					if(!t.equals(s)&&t.indexOf(s)>=0){
						remove=s;
					}
				}
			}
			if(remove!=null){
				set.remove(remove);
			}else{
				break;
			}
		}
		ss=set.toArray(new String[0]);
		n=ss.length;
		M=new int[n][n];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				// ss[i]->ss[j]
				for(int k=0; k<ss[j].length(); k++){
					if(ss[i].endsWith(ss[j].substring(0, k))){
						M[i][j]=k;
					}
				}
				// debug(ss[i], ss[j], M[i][j]);
			}
		}
		now=new char[200];
		ans=null;
		rec(0, -1, 0);
		println(new String(ans).substring(0, length(ans)));
	}

	int[][] M;
	char[] now, ans;

	void rec(int length, int last, int used){
		if(used==(1<<n)-1){
			// debug(now);
			if(ans==null||length(now)<length(ans)
					||(length(now)==length(ans)&&compare(now, ans)<0)){
				ans=now.clone();
			}
		}
		for(int i=0; i<n; i++){
			if((used>>i&1)==0){
				if(last==-1){
					add(now, length, ss[i], 0);
					rec(ss[i].length(), i, used|(1<<i));
					remove(now, 0, ss[i].length());
				}else{
					add(now, length, ss[i], M[last][i]);
					rec(length+(ss[i].length()-M[last][i]), i, used|(1<<i));
					remove(now, length, length+ss[i].length()-M[last][i]);
				}
			}
		}
	}

	void add(char[] cs, int at, String s, int from){
		for(int i=from; i<s.length(); i++){
			cs[at+(i-from)]=s.charAt(i);
		}
	}

	void remove(char[] cs, int from, int to){
		for(int i=from; i<to; i++){
			cs[i]=0;
		}
	}

	int length(char[] cs){
		for(int i=0; i<cs.length; i++){
			if(cs[i]==0){
				return i;
			}
		}
		return cs.length;
	}

	int compare(char[] c1, char[] c2){
		for(int i=0; i<min(c1.length, c2.length); i++){
			if(c1[i]!=c2[i]){
				return c1[i]-c2[i];
			}
		}
		return Integer.signum(c1.length-c2.length);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Compiler output:
Main.java:1: error: ';' expected
import java.util.*
                  ^
1 error
Language: C++

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

string foo(string& s, string& t) {
	int ls = s.length(), lt = t.length();
	if (ls < lt) return s;
	if (ls > lt) return t;
	return min(s, t);
}

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		vector<string> s(N);
		for (int i = 0; i < N; i++)
			cin >> s[i];
		vector<bool> a(N, true);
		for (int i = 0; i < N; i++) {
			int l = s[i].length();
			for (int j = 0; j < N; j++) {
				if (j == i) continue;
				for (int k = 0; k + l <= s[j].length(); k++)
					if (s[j].substr(k, l) == s[i])
						a[i] = false;
			}
		}
		vector<string> _s;
		for (int i = 0; i < N; i++)
			if (a[i]) _s.push_back(s[i]);
		s = _s;
		N = s.size();
		vector< vector<string> > t(N, vector<string>(N));
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++) {
				int l = min(s[i].length(), s[j].length());
				for (;;) {
					if (s[i].substr(s[i].length() - l) == s[j].substr(0, l))
						break;
					l--;
				}
				t[i][j] = s[j].substr(l);
			}
		vector< vector<string> > dp(1 << N, vector<string>(N, string('z', 101)));
		for (int i = 0; i < N; i++)
			dp[1 << i][i] = s[i];
		for (int S = 1; S < (1 << N); S++)
			for (int i = 0; i < N; i++) {
				if (!(S & (1 << i))) continue;
				int T = S - (1 << i);
				for (int j = 0; j < N; j++) {
					if (!(T & (1 << j))) continue;
					dp[S][i] = foo(dp[S][i], dp[T][j] + t[j][i]);
				}
			}
		string sss('z', 101);
		for (int i = 0; i < N; i++)
			sss = foo(sss, dp[(1 << N) - 1][i]);
		cout << sss << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:75: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
   84 |                                         dp[S][i] = foo(dp[S][i], dp[T][j] + t[j][i]);
a.cc:35:31: note:   initializing argument 2 of 'std::string foo(std::string&, std::string&)'
   35 | string foo(string& s, string& t) {
      |                       ~~~~~~~~^
Language: C++

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

string foo(string& s, string& t) {
	int ls = s.length(), lt = t.length();
	if (ls < lt) return s;
	if (ls > lt) return t;
	return min(s, t);
}

int main() {
	for (;;) {
		int N; cin >> N;
		if (N == 0) break;
		vector<string> s(N);
		for (int i = 0; i < N; i++)
			cin >> s[i];
		vector<bool> a(N, true);
		for (int i = 0; i < N; i++) {
			int l = s[i].length();
			for (int j = 0; j < N; j++) {
				if (j == i) continue;
				for (int k = 0; k + l <= s[j].length(); k++)
					if (s[j].substr(k, l) == s[i])
						a[i] = false;
			}
		}
		vector<string> _s;
		for (int i = 0; i < N; i++)
			if (a[i]) _s.push_back(s[i]);
		s = _s;
		N = s.size();
		vector< vector<string> > t(N, vector<string>(N));
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++) {
				int l = min(s[i].length(), s[j].length());
				for (;;) {
					if (s[i].substr(s[i].length() - l) == s[j].substr(0, l))
						break;
					l--;
				}
				t[i][j] = s[j].substr(l);
			}
		vector< vector<string> > dp(1 << N, vector<string>(N, string(101, 'z')));
		for (int i = 0; i < N; i++)
			dp[1 << i][i] = s[i];
		for (int S = 1; S < (1 << N); S++)
			for (int i = 0; i < N; i++) {
				if (!(S & (1 << i))) continue;
				int T = S - (1 << i);
				for (int j = 0; j < N; j++) {
					if (!(T & (1 << j))) continue;
					dp[S][i] = foo(dp[S][i], dp[T][j] + t[j][i]);
				}
			}
		string sss(101, 'z');
		for (int i = 0; i < N; i++)
			sss = foo(sss, dp[(1 << N) - 1][i]);
		cout << sss << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:84:75: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
   84 |                                         dp[S][i] = foo(dp[S][i], dp[T][j] + t[j][i]);
a.cc:35:31: note:   initializing argument 2 of 'std::string foo(std::string&, std::string&)'
   35 | string foo(string& s, string& t) {
      |                       ~~~~~~~~^
Language: C++

#include<iostream>
#include<vector>
#include<string>
using namespace std;
vector<string> v;
int n;
int d[10][10]={{}};
string ans;

void solve(vector<int> l){
  string b;
  b=v[l[0]];
  for(int i=1;i<n;i++){
    b+=v[l[i]].substr(d[l[i-1]][l[i]],v[l[i]].size()-d[l[i-1]][l[i]]);
  }
  //cout << b << endl;
  if(ans.size()>b.size()) ans=b;
  if(ans.size()==b.size()&&b<ans) ans=b;
}

int main(){
  while(cin >> n,n){
    string s;
    int i,j,k;
    v.clear();
    for(i=0;i<n;i++){
      cin >> s;
      v.push_back(s);
    }

    
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	d[i][j]=0;
      }
    }
    
    bool f;
    for(i=0;i<n;i++){
      f=false;
      for(j=0;j<n;j++){
	if(i==j) continue;
	if(v[j].find(v[i])!=-1) f=true;	
      }
      if(f){
	v.erase(v.begin()+i);
	i--;n--;
      }
    }
    
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(i==j) continue;
	for(k=1;k<=v[i].size();k++){
	  if(v[i].substr(v[i].size()-k,k)==v[j].substr(0,k))
	    d[i][j]=max(d[i][j],k);
	}
      }
    }

    
    vector<int> l;
    l.clear();
    ans="";
    for(i=0;i<n;i++) {
      l.push_back(i);
      ans+=v[i];
    }

    do{
      solve(l);
    }while(next_permutation(l.begin(),l.end()));
    
    cout << ans << endl;
    
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:72:12: error: 'next_permutation' was not declared in this scope
   72 |     }while(next_permutation(l.begin(),l.end()));
      |            ^~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<string> v(10);
vector<bool> used(10, false);
int N;
int bestlen;
string bestans;

string concat(const string &s1, const string &s2) {
	string tmp = s1;
	for(int i = s2.size(); i >= 0; --i) {
		if(s1.size() < i) continue;
		int start = s1.size()-i;
		bool ok = true;
		for(int j = 0; j < i; ++j) {
			if(s1[start+j] != s2[j]) {
				ok = false;
				break;
			}
		}
		if(ok) {
			tmp += s2.substr(i);
			return tmp;
		}
	}
	return s1+s2;
}

void dfs(int depth, string str) {
	if(depth == N) {
		if(str.size() < bestlen) {
			bestlen = str.size();
			bestans = str;
		}
		return;
	}
	for(int i = 0; i < N; ++i) {
		if(used[i]) continue;
		string s = concat(str, v[i]);
	//	cout << s << endl;
		used[i] = true;
		dfs(depth+1, s);
		used[i] = false;
	}
}

int main() {
	//cout << concat("", "asdf") << endl;
	while(true) {
		cin >> N;
		if(N == 0) break;

		for(int i = 0; i < N; ++i) {
			cin >> v[i];
			used[i] = false;
		}
		bestlen = INT_MAX;
		dfs(0, "");
		cout << bestans << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:27: error: 'INT_MAX' was not declared in this scope
   61 |                 bestlen = INT_MAX;
      |                           ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 |
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

string in[10];
int lex[10];

main(){
  int n;
  while(cin>>n,n){
    string ans;
    rep(i,n){
      cin>>in[i];
      ans+=in[i];
      lex[i]=i;
    }
    
    do{
      string tans=in[lex[0]];
      for(int i=1;i<n;i++){
	const string &str=in[lex[i]];
	rep(j,SZ(str)+1){
	  bool ok=true;
	  rep(k,SZ(str)-j){
	    if(SZ(tans)-(SZ(str)-j)+k<0){
	      ok=false;
	      break;
	    }
	    if(tans[SZ(tans)-(SZ(str)-j)+k]!=str[k]){
	      ok=false;
	      break;
	    }
	  }
	  if(ok){
	    tans+=str.substr(SZ(str)-j);
	    break;
	  }
	}
	if(tans.size()>ans.size()){
	  ok=false;
	  break;
	}
      }
      if((tans.size()<ans.size() || (tans.size()==ans.size() && tans<ans)))ans=tans;
    }while(next_permutation(lex,lex+n));
    cout<<ans<<endl;
  }
}

Compiler output:
a.cc:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:72:11: error: 'ok' was not declared in this scope
   72 |           ok=false;
      |           ^~
Language: C++

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

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) REP(i,0,n)
int g[10][10];
string s[10];
string dpv[10][1<<10];
bool dp[10][1<<10];
int n;
string mini(const string& a,const string& b)
{
  if(a.size()==b.size())return min(a,b);
  return a.size()<b.size()?a:b;
}
string solve(int v,int u)
{
  if(u==(1<<n)-1)return "";
  if(v>=0 && dp[v][u]){
    return dpv[v][u];
  }
  string ret;
  bool f=false;
  if(v>=0)dp[v][u]=true;
  rep(i,n){
    if(u>>i&1)continue;
    string ad;
    if(v<0){
      ad=s[i];
    } else {
      ad=s[i].substr(g[i][v]);
    }
    if(f)ret=mini(ret,ad+solve(i,u|1<<i));
    else{
      ret=ad+solve(i,u|1<<i);
      f=true;
    }
  }
  return v>=0?dpv[v][u]=ret:ret;
}
int main(void)
{
  for(;;){
    scanf("%d",&n); if(!n)break;
    rep(i,n)cin>>s[i];
    int u=0;
    rep(i,n)rep(j,n){
      if(u&1<<j || u&1<<i || i==j)continue;
      if(s[i].find(s[j])!=-1){
        u|=1<<j;
      }
    }
    rep(i,n)rep(j,n){
      if(i==j)continue;
      if(u&1<<i || u&1<<j)continue;
      int c=1,cc=-1;
      for(int ii=s[i].size()-1;ii>=0;ii--){
        if(s[j].size()<c)break;
        int jj;
        for(jj=0;jj<c;jj++){
          if(s[i][ii+jj]!=s[j][jj])break;
        }
        if(jj==c){
          cc=c;
        }
        c++;
      }
      g[j][i]=cc<0?0:cc;
    }
    memset(dp,0,sizeof(dp));
    puts(solve(-1,u).data());
  }
}

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

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

class State{
public:
  string str;
  int s, cnt;
  State() : str(""), s(0), cnt(cnt) {}
  State(string str, int s, int cnt) : str(str), s(s), cnt(cnt){}
  bool operator<(const State &p) const {
    return str.size() > (p.str).size();
    //if(cnt == p.cnt) return str.size() < (p.str).size();
    //return cnt < p.cnt;
  }
};

typedef pair<string, int> p;

int n;
vector<string> edge;
set<p> visited;



string bfs(){
  visited.clear();
  State u, v;
  priority_queue<State> Q;
  for(int i=0;i<n;i++){
    Q.push(State(edge[i], 1<<i, 1));
    visited.insert(p(edge[i], 1<<i));
  }
  while(!Q.empty()){
    u = Q.top();Q.pop();
    if(u.s == (1<<n)-1){
      return u.str;
    }
    for(int i=0;i<n;i++){
      if(u.s & (1<<i)) continue;
      if((u.str).size() >= edge[i].size()){
	bool f = false;
	for(int j=0;j+edge[i].size()<=(u.str).size();j++){
	  if((u.str).substr(j, edge[i].size()) == edge[i]){
	    if(visited.find(p(u.str, u.s|(1<<i))) == visited.end()){
	      Q.push(State(u.str, u.s|(1<<i), u.cnt+1));
	      visited.insert(p(u.str, u.s|(1<<i)));
	    }
	  }
	}
      }
      int size = min((u.str).size(), edge[i].size());
      for(int j=size;j>=0;j--){
	if((u.str).substr((u.str).size()-j) == edge[i].substr(0, j)){
	  if(visited.find(p(u.str+edge[i].substr(j), u.s|(1<<i))) == visited.end()){
	    Q.push(State(u.str+edge[i].substr(j), u.s|(1<<i), u.cnt+1));
	    visited.insert(p(u.str+edge[i].substr(j), u.s|(1<<i)));
	  }
	}
      }
    }
  }
}

main(){
  while(cin >> n && n){
    edge.clear();
    for(int i=0;i<n;i++){
      string in;
      cin >> in;
      edge.push_back(in);
    }
    /*for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(edge[i].size() >= edge[j].size())
	  for(int k=0;k+(int)edge[j].size()<=edge[i].size();k++){
	    if(edge[i].substr(k, edge[j].size()) == edge[j]){
	      vector<string>::iterator ite = edge.begin();
	      for(int l=0;l<j;l++) ite++;
	      edge.erase(ite);
	      n--;
	    }
	  }
      }
      }*/
    sort(edge.begin(), edge.end());
    /*for(int i=0;i<n;i++){
      for(int j=0;j<n;i++){
	if(i == j) cost[i][j] == "";
	int size = min(edge[i].size(), edge[j].size());
	for(int k=size;k>=0;k--){
	  if(edge[i].substr(edge[i].size()-k) == edge[j].substr(0, k)){
	    cost[i][j] = edge[j].substr(k);
	  }
	}
      }
      }*/
    cout << bfs() << endl;
  }
  return 0;
}

Compiler output:
a.cc:70:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   70 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:91:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   91 |     sort(edge.begin(), edge.end());
      |     ^~~~
      |     short
a.cc: In function 'std::string bfs()':
a.cc:68:1: warning: control reaches end of non-void function [-Wreturn-type]
   68 | }
      | ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
  int n,BtoA,okay;
  string s,m;
  char v[100];
  while(1){
    okay=0;
    BtoA=0;
    cin >> n;
    if(n == 0)break;
    for(int i=0;i<n;i++){
      s.clear();
      cin >> s; 
      if(i == 0){
	m.insert(BtoA,s);
       	//BtoA+=strlen(v);
	BtoA+=s.length();
	//	cout << BtoA << " " << m << endl;
    }
      else if(s == m){

      }
      else{

	for(int j=0;j<s.length();j++){
	
	  if(s.substr(j,1) == m.substr(BtoA-1,1)){
	   
	    //for(int k=j;k<s.length();k++){
	      if(97<=s[j+1] && s[j+1]<=122){
		m.insert(BtoA,&s[j+1]);
		//	cout << "insert =" << m << endl;
		BtoA+=s.length()-j-1;
		okay=1;
		//	break;
	      }
	      // }
	    break;
	    /*
	    if(97<=s[j+1] && s[j+1]<=122){
	    m.insert(BtoA,&s[j+1]);
	    BtoA++;
	    break;
	    }
	    */
	   
	  }

	}



      }
 
 
  }
 cout << m << endl;
  m.clear();
  s.clear();
  }


}
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
  int n,BtoA,okay;
  string s,m;
  char v[100];
  while(1){
    okay=0;
    BtoA=0;
    cin >> n;
    if(n == 0)break;
    for(int i=0;i<n;i++){
      s.clear();
      cin >> s; 
      if(i == 0){
	m.insert(BtoA,s);
       	//BtoA+=strlen(v);
	BtoA+=s.length();
	//	cout << BtoA << " " << m << endl;
    }
      else if(s == m){

      }
      else{

	for(int j=0;j<s.length();j++){
	
	  if(s.substr(j,1) == m.substr(BtoA-1,1)){
	   
	    //for(int k=j;k<s.length();k++){
	      if(97<=s[j+1] && s[j+1]<=122){
		m.insert(BtoA,&s[j+1]);
		//	cout << "insert =" << m << endl;
		BtoA+=s.length()-j-1;
		okay=1;
		//	break;
	      }
	      // }
	    break;
	    /*
	    if(97<=s[j+1] && s[j+1]<=122){
	    m.insert(BtoA,&s[j+1]);
	    BtoA++;
	    break;
	    }
	    */
	   
	  }

	}



      }
 
 
  }
 cout << m << endl;
  m.clear();
  s.clear();
  }


}

Compiler output:
a.cc:73:5: error: redefinition of 'int main()'
   73 | int main(){
      |     ^~~~
a.cc:6:5: note: 'int main()' previously defined here
    6 | int main(){
      |     ^~~~
Language: C++

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

int n;
string s[10];
string p[10][10];

string ans;
int min_cost;
bool done[10];

void dfs(int now,string str,int k){
//	cout<<str<<endl;
	if(str.size()>=min_cost) return;

	if(k==n){
		if(str.size()<min_cost){
			min_cost=str.size();
			ans=str;
		}
		else if(str.size()==min_cost){
			ans=min(str,ans);
		}
		return;
	}
	for(int i=0;i<n;i++){
		if(done[i]) continue;
		done[i]=true;
		dfs(i,str+p[now][i],k+1);
		done[i]=false;
	}


}


int main()
{
	while(cin>>n && n!=0){
		memset(done,false,sizeof(false));
		min_cost=1000000000;
		for(int i=0;i<n;i++)
			cin>>s[i];

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j) continue;
				p[i][j]=s[j];
				for(int k=0;k<min(s[i].size(),s[j].size());k++){
//					cout<<s[i].substr(s[i].size()-1-k,k+1)<<" "<<s[j].substr(0,k+1)<<endl;
					if(s[i].substr(s[i].size()-1-k,k+1)==s[j].substr(0,k+1)){
//						cout<<s[j].substr(k+1)<<endl;
						p[i][j]=s[j].substr(k+1);
//						cout<<p[i][j]<<endl;
					}
				}
			}
		}



		for(int i=0;i<n;i++){
			done[i]=true;
			dfs(i,s[i],1);
			done[i]=false;
		}
		cout<<ans<<endl;


	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:17: error: 'memset' was not declared in this scope
   41 |                 memset(done,false,sizeof(false));
      |                 ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #include<string>
Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXIST2(s,e) (find(ALL(s),(e))!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

string concat(string &l,string &r,int common){
	return l.substr(0,l.size()-common)+r;
}

typedef vector<vs> vvs;
typedef vector<vvs> vvvs;

string smaller(string &l,string &r){
	if(l.size()==r.size()){
		return min(l,r);
	}else{
		return (l.size()<r.size()?l:r);
	}
}

int main(){
	int n;
	while(cin>>n,n){
		vs s(n);
		REP(i,n){
			cin>>s[i];
		}

		vi unused(n);
		REP(i,n){
			REP(j,n){
				if(i!=j&&s[i].find(s[j])!=string::npos){
					unused[j]=1;
				}
			}
		}
		for(int i=n-1;i>=0;i--){
			if(unused[i]){
				s.erase(s.begin()+i);
			}
		}
		n=s.size();

		vvi common(n,vi(n));
		REP(i,n){
			REP(j,n){
				if(i==j)continue;
				int c=0;
				for(int k=min(s[i].size(),s[j].size());k>0;k--){
					bool flag=true;
					REP(l,k){
						if(s[j][l]!=s[i][s[i].size()-k+l]){
							flag=false;
							break;
						}
					}
					if(flag){
						c=k;
						break;
					}
				}
				common[i][j]=c;
			}
		}

		vvs dp(1<<n,vs(n,string(200,'z')));
		REP(i,n){
			dp[1<<i][i]=s[i];
		}
		REP(mask,1<<n){
			REP(i,n){
				if((1<<i)&mask){
					REP(j,n){
						if(((1<<j)&mask)==0){
							dp[mask|(1<<j)][j]=smaller(dp[mask|(1<<j)][j],concat(dp[mask][i],s[j],common[i][j]));
						}
					}
				}
			}
		}

		string ans(200,'z');
		REP(i,n){
			ans=smaller(ans,dp[(1<<n)-1][i]);
		}
		cout<<ans<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:109:109: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::string' {aka 'std::__cxx11::basic_string<char>'}
  109 |                                                         dp[mask|(1<<j)][j]=smaller(dp[mask|(1<<j)][j],concat(dp[mask][i],s[j],common[i][j]));
      |                                                                                                       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:47:34: note:   initializing argument 2 of 'std::string smaller(std::string&, std::string&)'
   47 | string smaller(string &l,string &r){
      |                          ~~~~~~~~^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define all(c) (c).begin(),(c).end()
#define INF (1<<29)

using namespace std;

typedef unsigned long long ull;

ull B=5791455;

int overlap(string a,string b){
  int al=a.size(),bl=b.size(),ans=0;
  ull ah=0,bh=0,t=1;

  for(int i=1;i<=min(al,bl);i++){
    ah=ah+a[al-i]*t;
    bh=bh*B+b[i-1];
    if(ah==bh)ans=i;
    t*=B;
  }
  return ans;
}

bool contain(string a,string b){
  int al=a.size(),bl=b.size();
  ull ah=0,bh=0,t=1;

  if(al>bl)return false;

  for(int i=0;i<al;i++)t*=B;
  for(int i=0;i<al;i++)ah=ah*B+a[i];
  for(int i=0;i<al;i++)bh=bh*B+b[i];

  for(int i=0;i+al<=bl;i++){
    if(ah==bh)return true;
    if(i+al<bl)bh=bh*B+b[i+al]-b[i]*t;
  }
  return false;
}

int dp[11][1<<11];
string path[11][1<<11];

int dp[11][1<<11];
string path[11][1<<11];

int main(void){

  int n;
  while(cin >> n,n){

    vector<string>a(n),b;
    for(int i=0;i<n;i++)cin >> a[i];

    for(int i=0;i<n;i++){
      bool fg=false;
      for(int j=0;j<n;j++)fg|=(i!=j)&&contain(a[i],a[j]);
      if(!fg)b.push_back(a[i]);
    }

    int bl=b.size();
    fill(dp[0],dp[11],INF);
    for(int i=0;i<bl;i++)
      dp[i][1<<i]=b[i].size(),path[i][1<<i]=b[i];

    for(int S=0;S<(1<<bl);S++){
      for(int i=0;i<bl;i++){
        if(!((S>>i)&1))continue;
        for(int j=0;j<bl;j++){
          if((S>>j)&1)continue;
          int bjl=b[j].size(),ov=overlap(path[i][S],b[j]);
          if(dp[j][S|(1<<j)]>dp[i][S]+bjl-ov){
            dp[j][S|(1<<j)]=dp[i][S]+bjl-ov;
            path[j][S|(1<<j)]=path[i][S]+b[j].substr(ov,bjl-ov);
          }
        }
      }
    }
    int cnt=INF;
    string ans;
    sort(all(b));
    for(int i=0;i<bl;i++)ans+=b[i];
    for(int i=0;i<bl;i++){
      if(cnt>dp[i][(1<<bl)-1]){
        cnt=dp[i][(1<<bl)-1];
        ans=path[i][(1<<bl)-1];
      }
      if(cnt==dp[i][(1<<bl)-1] && ans>path[i][(1<<bl)-1]){
        ans=path[i][(1<<bl)-1];
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc:47:5: error: redefinition of 'int dp [11][2048]'
   47 | int dp[11][1<<11];
      |     ^~
a.cc:44:5: note: 'int dp [11][2048]' previously declared here
   44 | int dp[11][1<<11];
      |     ^~
a.cc:48:8: error: redefinition of 'std::string path [11][2048]'
   48 | string path[11][1<<11];
      |        ^~~~
a.cc:45:8: note: 'std::string path [11][2048]' previously declared here
   45 | string path[11][1<<11];
      |        ^~~~
Language: C++

#include<stdio.h>
#include<algorithm>
using namespace std;
char in[20];
int main(){
	int a;scanf("%d",&a);
	while(a--){
		for(int i=0;i<10;i++)scanf("%s",in+i);
		int val=0;
		int ace=0;
		if(in[0]=='A'){val+=11;ace++;}
		else if(in[0]=='T'||in[0]=='J'||in[0]=='Q'||in[0]=='K'){val+=10;}
		else val+=in[0]-'0';
		if(in[1]=='A'){val+=11;ace++;}
		else if(in[1]=='T'||in[1]=='J'||in[1]=='Q'||in[1]=='K'){val+=10;}
		else val+=in[1]-'0';
		if(val>21){val-=10;ace--;}
		if(val==21){
			printf("blackjack\n");continue;
		}
		int at=2;
		while((val<17||(val==17&&ace)&&at<10){
			if(in[at]=='A'){val+=11;ace++;}
			else if(in[at]=='T'||in[at]=='J'||in[at]=='Q'||in[at]=='K'){val+=10;}
			else val+=in[at]-'0';
			if(val>21&&ace){val-=10;ace--;}
			at++;
		}
		if(val>21)printf("bust\n");
		else printf("%d\n",val);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:54: error: expected ')' before '{' token
   22 |                 while((val<17||(val==17&&ace)&&at<10){
      |                      ~                               ^
      |                                                      )
Language: C++

#include <iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        char hand;
        int point = 0;
        int one = 0;
        bool isblackjack = false;
        bool isace = false;
        char a, b;
        cin >> a >> b;
        if(a == 'A' && (b == 'T' || b == 'K' || b == 'Q' || b == 'J')){
            isblackjack = true;
        }
        elseif(b == 'A' && (a == 'T' || a == 'K' || a == 'Q' || a == 'J')){
            isblackjack = true;
        }
        else if(a == 'A'){
            isace = true;
            if(b == 'A'){
                isace = false;
                point = 12;
            }else{
                point = 11 + b - '0';
            }
        }else if(b == 'A'){
            isace = true;
            point = 11 + a - '0';
        }else if(a == 'T' || a == 'J' || a == 'Q' || a == 'K'){
            point = 10 + b - '0';
        }else if(b == 'T' || b == 'J' || b == 'Q' || b == 'K'){
            point = 10 + a - '0';
        }else{
            point = a - '0' + b - '0';
        }
        for(int i=0; i<8; i++){
            cin >> hand;
            if(point <= 16 || (point == 17 && isace)){
                if(hand == 'A'){
                    one++;
                }else if(hand == 'T' || hand == 'J' || hand == 'Q' || hand == 'K'){
                    point += 10;
                }else{
                    point += hand - '0';
                }
            }
        }
        point += one*11;
        while(one--&&point>21){
            point -= 10;
        }
        if(isblackjack){
            cout << "blackjack" << endl;
        }else if(point > 21){
            cout << "bust" << endl;
        }else{
            cout << point << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'elseif' was not declared in this scope
   18 |         elseif(b == 'A' && (a == 'T' || a == 'K' || a == 'Q' || a == 'J')){
      |         ^~~~~~
a.cc:21:9: error: 'else' without a previous 'if'
   21 |         else if(a == 'A'){
      |         ^~~~
Language: C

// AOJ 2026: Divisor is the Conqueror
// 2017.11.03 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <time.h>

int c[15];
int ans[54];
char f[14][365];		// 364=(13+1)*13/2*4

int rec(int j, int k)
{
	int i;

	if (!j) return 1;
	for (i = 1; i <= 13; i++) {
		if (!c[i]) continue;
		if (f[i][k-i]) {
			c[i]--, ans[j] = i;
			if (rec(j-1, k-i)) return 1;
			c[i]++;
		}
	}
	return 0;
}

int main()
{
	int n, i, v, s;
//	clock_t start, end;

	start = clock();
	memset(f[1], 1, sizeof(f[1]));
	for (i = 2; i <= 13; i++) {
		f[i][0] = 1;
		for (v = i; v < 365; v += i) f[i][v] = 1;
	}

	while (scanf("%d", &n) && n > 0) {
		if (n == 1) { scanf("%d", &v); printf("%d\n", v); continue; }

		memset(c, 0, sizeof(c));
		for (s = 0, i = 0; i < n; i++) {
			scanf("%d", &v);
			s += v, c[v]++;
		}
		if (rec(n, s)) {
			printf("%d", ans[1]);
			for (i = 2; i <= n; i++) printf(" %d", ans[i]);
			putchar('\n');
		} else puts("No");
	}
//	end = clock();
//	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:33:9: error: 'start' undeclared (first use in this function)
   33 |         start = clock();
      |         ^~~~~
main.c:33:9: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

vi v;

bool dfs(int n, int *c){
  if(n == 0){
    for(int i = v.size()-1;i>=0;i--)
      printf("%d%c", v[i], i?' ':'\n');
    return true;
  }else{
    for(int i = 1; i <= 13; i++){
      if(c[i]&&n%i==0){
	c[i]--;
	v.push_back(i);
	if(dfs(n-i, c)) return true;
	v.pop_back();
	c[i]++;
      }
    }
    return false;
  }
}

int main(){
  while(scanf("%d", &N) && N){
    int c[14] = {};
    int sum = 0;
    rep(i, N){
      int in;
      scanf("%d", &in);
      sum += in;
      c[in]++;
    }

    v.clear();
    if(!dfs(sum, c)) puts("NO");
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:22: error: 'N' was not declared in this scope
   51 |   while(scanf("%d", &N) && N){
      |                      ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int n;
int k;
int a[101];

int dp[101][101];
int dfs(int from,int to){
    //if(from==to)return 0;
    if(dp[from][to]!=-1)return dp[from][to];
    int res=0;
    for(int i=(from+1)%k;i!=(to+1)%k;i=(i+1)%k){
        res=max(res,abs(a[from]-a[i])+dfs(from,(i-1+k)%k)+dfs(i,to));
    }
    return dp[from][to]=res;
}

int main(){
    
    cin>>n;
    while(n--){
        cin>>k;
        for(int i=0;i<k;i++)cin>>a[i];
        int res=0;
        for(int i=0;i<k;i++){
            if(i==k-1){
             //   cout<<endl;
            }
            memset(dp,-1,sizeof(dp));
            res=max(res,dfs(i,(i-1+k)%k));
        }
        cout<<res<<endl;
    }

    return 0;
}

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

#include <stdio.h>
#include <algorithm>
int a, b;
int main() {
	while(scanf("%d%d", &a, &b), a + b) {
		int ret = 999999999;
		for(int i = 1; i * i <= a; i++) {
			if(a % i) continue;
			for(int j = 1; j * j <= b; j++) {
				if(b % j) continue;
				int p[4] = { i, a / i, j, b / j };
				std::sort(p, p + 4);
				int res = 0;
				for(int k = 0; k < 2; k++) res += (p[k + 1] - p[k]) * (p[k + 1] - p[k]);
				ret = min(ret, res);
			}
		}
		printf("%d\n", ret);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:39: error: 'min' was not declared in this scope; did you mean 'std::min'?
   15 |                                 ret = min(ret, res);
      |                                       ^~~
      |                                       std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

#include<bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
#define R(i,a,n) for(int i=a;i>n;i--)
using namespace std ;
int main(){
  int a,b;
  while(cin>>a>>b,a){
    int aa[a/2+1][2],bb[b/2+1][2],c=0,cc=0;
    bool ac[10001],bc[10001];
    r(i,0,10001)ac[i]=0;
    r(i,0,10001)bc[i]=0;
    r(i,1,a){
      if(!ac[i]&&a%i==0)R(j,a,0){
	if(i*j==a){
	  aa[c][0]=i;
	  ac[i]=1;ac[j]=1;
	  aa[c++][1]=j;
	  break;
	}
      }
    }
    r(i,1,b){
      if(!bc[i]&&b%i==0)R(j,b,0){
	if(i*j==b){
	  bb[cc][0]=i;
	  bc[i]=1;bc[j]=1;
	  bb[cc++][1]=j;
	  break;
	}
      }
    }//cout<<bb[0][0]<<bb[0][1];
    int l[7];
    long long m=999999999999;
    r(i,0,c){
      r(j,0,cc){
	int t[4];
	t[0]=aa[i][0];t[1]=aa[i][1];
	t[2]=bb[j][0];t[3]=bb[j][1];
	sort(t,t+4);
	l[0]=t[1]-t[0];
	l[1]=t[2]-t[1];
	l[2]=t[3]-t[2];
	m=min(m,l[0]*l[0]+l[1]*l[1]+l[2]*l[2]);
      }
    }
    //if(m==100000000)m=0;
    cout<<m<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:14: error: no matching function for call to 'min(long long int&, int)'
   43 |         m=min(m,l[0]*l[0]+l[1]*l[1]+l[2]*l[2]);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:43:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   43 |         m=min(m,l[0]*l[0]+l[1]*l[1]+l[2]*l[2]);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:43:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   43 |         m=min(m,l[0]*l[0]+l[1]*l[1]+l[2]*l[2]);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,s,k;
  while(cin>>a>>b,a){
    int m=1e9;
    for(int i=1;i*i<=a;i++){
      if(a%i)continue;
      for(int j=1;j*j<=b;j++){
        if(b%j)continue;
        int p[4];
        p[0]=i;p[1]=a/i;p[2]=j;p[3]=b/j;
        sort(p,p+4);
        for(s=k=0;k<3;k++)s+=(p[k+1]-p[k])*(p[k+1]-p[k]);
        m= min(m,s);
    }
  }
  cout<<m<<endl;
??}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:1: error: expected primary-expression before '?' token
   19 | ??}
      | ^
a.cc:19:2: error: expected primary-expression before '?' token
   19 | ??}
      |  ^
a.cc:19:3: error: expected primary-expression before '}' token
   19 | ??}
      |   ^
a.cc:19:3: error: expected ':' before '}' token
   19 | ??}
      |   ^
      |   :
a.cc:19:3: error: expected primary-expression before '}' token
a.cc:19:3: error: expected ':' before '}' token
   19 | ??}
      |   ^
      |   :
a.cc:19:3: error: expected primary-expression before '}' token
Language: C++

#include<iostream>
#include<algorithm>
#define sq(a) ((a)*(a))
#define INFTY (1<<30)
using namespace std;
int main(){
	while(true){
		int ans = INFTY;
		int s[4];
		int a,b;
		scanf("%d%d", &a, &b);
		if( a==0 && b==0 ) break;
		for(int i = 1; i < a; ++i){
			if( a % i == 0 ){
				for(int j = 1; j < b; ++j){
					if( b % j == 0 ){
						s[0] = i;
						s[1] = a / i;
						s[2] = j;
						s[3] = b / j;
						sort( s, s + 4 );
						int sum1 = sq(s[1]-s[0])+sq(s[2]-s[1])+sq(s[3]-s[2]);
						ans = min(ans, sum);
					}
				}
			}
		}
		printf("%d\n", ans);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:64: error: 'sum' was not declared in this scope; did you mean 'sum1'?
   23 |                                                 ans = min(ans, sum);
      |                                                                ^~~
      |                                                                sum1
Language: C++

import java.util.Scanner;

public class Main{
    class Hand{
	String str;
	int type;
	boolean res = false;
	int draw=0;
	int w1, w2;

	Hand(){
	}
	Hand(String str, int type, int w1, int w2){
	    this.str = str;
	    this.type = type;
	    this.w1 = w1;
	    this.w2 = w2;
	}

	void tcount(Hand a[], int n){
	    int win = 0, lose = 0;
	    if(w1 < w2){
		for(int i = 0; i < n; i++){
		    if(a[i].type == this.type){
			draw++;
		    } else if(w1 <= a[i].type && a[i].type <= w2){
			lose++;
		    } else {
			win++;
		    }
		}
	    } else {
		for(int i = 0; i < n; i++){
		    if(a[i].type == this.type){
			draw++;
		    } else if(w1 >= a[i].type || a[i].type <= w2){
			lose++;
		    } else {
			win++;
		    }
		}
	    }
	    if(lose == 0){
		res = true;
	    }
	}
    }

    public Main(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    if(n == 0){
		break;
	    }
	    Hand hand[] = new Hand[n];

	    for(int i = 0; i < n; i++){
		String str = sc.next();
		if(str.equals("Rock")){
		    hand[i] = new Hand(str, 0, 8, 14);
		} else if(str.equals("Fire")){
		    hand[i] = new Hand(str, 1, 9, 0);
		} else if(str.equals("Scissors")){
		    hand[i] = new Hand(str, 2, 10, 1);
		} else if(str.equals("Snake")){
		    hand[i] = new Hand(str, 3, 11, 2);
		} else if(str.equals("Human")){
		    hand[i] = new Hand(str, 4, 12, 3);
		} else if(str.equals("Tree")){
		    hand[i] = new Hand(str, 5, 13, 4);
		} else if(str.equals("Wolf")){
		    hand[i] = new Hand(str, 6, 14, 5);
		} else if(str.equals("Sponge")){
		    hand[i] = new Hand(str, 7, 0, 6);
		} else if(str.equals("Paper")){
		    hand[i] = new Hand(str, 8, 1, 7);
		} else if(str.equals("Air")){
		    hand[i] = new Hand(str, 9, 2, 8);
		} else if(str.equals("Water")){
		    hand[i] = new Hand(str, 10, 3, 9);
		} else if(str.equals("Dragon")){
		    hand[i] = new Hand(str, 11, 4, 10);
		} else if(str.equals("Devil")){
		    hand[i] = new Hand(str, 12, 5, 11);
		} else if(str.equals("Lightning")){
		    hand[i] = new Hand(str, 13, 6, 12);
		} else {
		    hand[i] = new Hand(str, 14, 7, 13);
		}
	    }
	    for(int i = 0; i < n; i++){
		hand[i].tcount(hand, n);
	    }
	    int f = 0;
	    for(int i = 0; i < n; i++){
		if(hand[i].res){
		    f = 1;
		    System.out.println(hand[i].str);
		    break;
		}
	    }
	    if(f == 0){
		System.out.println("Draw");
	    }
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main{
      | ^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

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;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:5: error: 'memset' was not declared in this scope
   67 |     memset(ges,false,sizeof(ges));
      |     ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <algorithm>
  +++ |+#include <cstring>
    5 |
Language: C++

#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int inf = 3000*1000;
const int N   = 2000;

int ori[N];
int tool[N];
bool is_in_loop[N];
int ans;

void calc_loop_min(int *a,int p){
  int ret = inf;
  rep(i,p)is_in_loop[a[i]]=true;
  rep(i,p){
    int tmp = 0;
    rep(j,p){
      if (j == i)tmp+= ori[a[j]];
      else       tmp+=tool[a[j]];
    }
    ret=min(ret,tmp);
  }
  ans+=ret;
}

vector<int> edge[N];
bool gvis[N];
bool vis[N];
void dfs(int now,int *st,int p){
  if (gvis[now])return;
  if (vis[now]){
    assert(st[0] == now);
    calc_loop_min(st,p);
    return;
  }
  vis[now]=true;
  rep(i,edge[now].size()){
    int next=edge[now][i];
    st[p]=now;
    dfs(next,st,p+1);
  }
  if (!is_in_loop[now]){
    ans+=tool[now];
  }
  gvis[now]=true;
}

int getindex(string &a,map<string,int> &M){
  int index = M.size();
  if (M.find(a) == M.end())M[a]=index;
  return M[a];
}

main(){
  int n;
  int path[N];
  while(cin >> n&&n){
    ans=0;
    rep(i,N){
      is_in_loop[i]=false;
      edge[i].clear();
      vis[i]=false;
      gvis[i]=false;
    }

    map<string,int> M;
    rep(i,n){
      string a,b;
      int c,d;
      int index1,index2;
      cin>>a>>c>>b>>d;
      index1=getindex(a,M);
      index2=getindex(b,M);
      edge[index2].push_back(index1);
      ori[index1]=c;
      tool[index1]=d;
    }

    rep(i,M.size()){
      if (!gvis[i])dfs(i,path,0);
    }
    
    cout << ans << endl;
  }
}

Compiler output:
a.cc: In function 'void dfs(int, int*, int)':
a.cc:37:5: error: 'assert' was not declared in this scope
   37 |     assert(st[0] == now);
      |     ^~~~~~
a.cc:5:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    4 | #include<vector>
  +++ |+#include <cassert>
    5 | using namespace std;
a.cc: At global scope:
a.cc:59:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   59 | main(){
      | ^~~~
Language: C++

#include <cstdio>
#include <cstring>
#include <string>

using namespace std;

int dp[1024][1024];

int main()
{
	char s[2048];
	
	while (scanf("%s", s) == 1){
		char s1[1024], s2[1024];
		int len = strlen(s);
		strncpy(s1, s, len / 2);
		strrev(s);
		strncpy(s2, s, len / 2);
		s1[len / 2] = s2[len / 2] = '\0';
		
		memset(dp, 0, sizeof(dp));
		
		string m[2][1024];
		
		for (int i = 0; i < 1024; i++){
			m[0][i] = m[1][i] = "";
		}
		
		for (int i = 1; i <= len / 2; i++){
			for (int j = 1; j <= len / 2; j++){
				if (s1[i - 1] == s2[j - 1]){
					dp[i][j] = dp[i - 1][j - 1] + 1;
					m[i & 1][j] = m[(i + 1) & 1][j - 1] + s1[i - 1];
				}
				else {
					dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
					if (m[i & 1][j - 1].size() > m[(i + 1) & 1][j].size()){
						m[i & 1][j] = m[i & 1][j - 1];
					}
					else {
						m[i & 1][j] = m[(i + 1) & 1][j];
					}
				}
			}
		}
		char ans[1024];
		strcpy(ans, m[(len / 2) & 1][len / 2].c_str());
		printf("%s", ans);
		if (len & 1) printf("%c", s[len / 2]);
		strrev(ans);
		printf("%s\n", ans);
	}
	
	return (0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   17 |                 strrev(s);
      |                 ^~~~~~
      |                 strsep