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

#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  double a[50],b[50],n;
  cin>>n;
    double c=0,d=0;
    r(i,n){
      cin>>a[i]>>b[i];
      c+=a[i],d+=b[i];
    }
    c/=n,d/=n;
    if(n%2)goto L;
    r(i,n/2)if(!abs((a[i]+a[(i+n/2)%n])/2-c)<=0.0001||!abs((b[i]+b[(i+n/2)%n])/2-c))<=0.0001)goto L;
    printf("%.11f %.11f\n",c,d);
    if(0)L:cout<<"NA"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: invalid operands of types 'double' and 'int' to binary 'operator%'
   13 |     if(n%2)goto L;
      |        ~^~
      |        | |
      |        | int
      |        double
a.cc:14:36: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   14 |     r(i,n/2)if(!abs((a[i]+a[(i+n/2)%n])/2-c)<=0.0001||!abs((b[i]+b[(i+n/2)%n])/2-c))<=0.0001)goto L;
      |                             ~~~~~~~^~
      |                               |     |
      |                               |     double
      |                               double
a.cc:14:75: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   14 |     r(i,n/2)if(!abs((a[i]+a[(i+n/2)%n])/2-c)<=0.0001||!abs((b[i]+b[(i+n/2)%n])/2-c))<=0.0001)goto L;
      |                                                                    ~~~~~~~^~
      |                                                                      |     |
      |                                                                      |     double
      |                                                                      double
a.cc:14:85: error: expected primary-expression before '<=' token
   14 |     r(i,n/2)if(!abs((a[i]+a[(i+n/2)%n])/2-c)<=0.0001||!abs((b[i]+b[(i+n/2)%n])/2-c))<=0.0001)goto L;
      |                                                                                     ^~
Language: C++

#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a[50],b[50],n;
  cin>>n;
    double c=0,d=0;
    r(i,n){
      cin>>a[i]>>b[i];
      c+=a[i],d+=b[i];
    }
    c/=n,d/=n;
    if(n%2)goto L;
    r(i,n/2)if(!abs((a[i]+a[(i+n/2)%n])/2.0-c)<=0.0001||!abs((b[i]+b[(i+n/2)%n])/2.0-c))<=0.0001)goto L;
    printf("%.11f %.11f\n",c,d);
    if(0)L:cout<<"NA"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:89: error: expected primary-expression before '<=' token
   14 |     r(i,n/2)if(!abs((a[i]+a[(i+n/2)%n])/2.0-c)<=0.0001||!abs((b[i]+b[(i+n/2)%n])/2.0-c))<=0.0001)goto L;
      |                                                                                         ^~
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)



int main(){

  int n;
  cin >> n;
  vector<complex<int> > p(n);
  rep(i,n){
    int x,y;
    cin >> x >> y;
    p[i] = complex<int>(x,y);
  }
  if(n%2!=0){
    cout << "NA" << endl;
    return 0;
  }
  complex<double> c,cb;
  cb = (double)(p[0]+p[n/2])/2;
  for(int i=1;i<n/2;i++){
    c = (double)(p[i]+p[i+n/2])/2;
    if(c.real()!=cb.real()||c.imag()!=cb.imag()){
      cout << "NA" << endl;
      return 0;
    }
  }
  cout << setprecision(9) << cb.real() << " " << cb.imag() << endl;


  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:24:8: error: invalid cast from type 'std::complex<int>' to type 'double'
   24 |   cb = (double)(p[0]+p[n/2])/2;
      |        ^~~~~~~~~~~~~~~~~~~~~
a.cc:26:9: error: invalid cast from type 'std::complex<int>' to type 'double'
   26 |     c = (double)(p[i]+p[i+n/2])/2;
      |         ^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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


double p[60][2];
double cx = 0, cy = 0;
int f;

int main(void){
	int n, i;
	cin >> n;
	for(i = 0; i < n; i++){
		cin >> p[i][0] >> p[i][1];
		cx += p[i][0];
		cy += p[i][1];
	}
	cx /= n;
	cy /= n;
	if(n%2) f=1;
	else for(i = 0; i < n/2; i++){
		if(fabs((p[i][0] + p[i + n/2][0]) /2 - cx) <= 0.0001 && fabs((p[i][1] + p[i + n/2][1]) /2 - cy) <= 0.0001) continue;
		f = 1;
		break;
	}
	if(f) cout << "NA" << endl;
	else cout << cx << " " << cy << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:20: error: 'fabs' was not declared in this scope; did you mean 'labs'?
   22 |                 if(fabs((p[i][0] + p[i + n/2][0]) /2 - cx) <= 0.0001 && fabs((p[i][1] + p[i + n/2][1]) /2 - cy) <= 0.0001) continue;
      |                    ^~~~
      |                    labs
Language: C++

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

using namespace std;
typedef vector<int> vi;
typedef map<vi, int> ma;

vi a,b;
int N;

ma bfs(vi vec){
    ma tem;
    queue<vi>que;
    que.push(vec);
    tem[vec]=0;
    while(!que.empty()){
        
        vi v=que.front();
        que.pop();
//        cout<<"tem[v]: "<<tem[v]<<endl;
//        for(int i=0;i<v.size();i++)
//            cout<<v[i]<<" ";
//        cout<<endl;
        if(tem[v]>(N-1)/2)
            continue;
        for(int i=0;i<N;i++)
            for(int j=i+2;j<=N;j++){
                vi n=v;
                reverse(n.begin()+i,n.begin()+j);
                if(tem.find(n)==tem.end()){
                    tem[n]=tem[v]+1;
                    que.push(n);
                }
            }
    }
    return tem;
}

void solve(){
    ma m_a=bfs(a);
    ma m_b=bfs(b);
   
    if(m_a.find(b)!=m_a.end()){
        cout<<m_a[b]<<endl;
        return;
    }
    int ans=1000000;
    do{
        if(m_a.find(b)==m_a.end()&&m_b.find(b)==m_b.end())
            continue;
        else
            ans=min(m_a[b]+m_b[b],ans);
    }while(next_permutation(b.begin(), b.end()));
    cout<<ans<<endl;
}

int main(){
    cin>>N;
    for(int i=0;i<N;i++){
        int t;
        cin>>t;
        a.push_back(t);
    }
    b=a;
    sort(b.begin(),b.end());
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'ma bfs(vi)':
a.cc:31:17: error: 'reverse' was not declared in this scope
   31 |                 reverse(n.begin()+i,n.begin()+j);
      |                 ^~~~~~~
a.cc: In function 'void solve()':
a.cc:55:12: error: 'next_permutation' was not declared in this scope
   55 |     }while(next_permutation(b.begin(), b.end()));
      |            ^~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:67:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   67 |     sort(b.begin(),b.end());
      |     ^~~~
      |     short
Language: C++

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

#define int __int8

using namespace std;

int main()
{
	int N;

	cin >> N;

	vector<int> A(N);

	for (int i = 0; i < N; i++) { cin >> A[i]; }

	vector<int> B = A; sort(B.begin(), B.end());

	set<vector<int> > dat; dat.insert(A);

	queue<vector<int> > que; que.push(A);

	queue<int> que2; que2.push(0);

	if (A == B) { cout << 0 << endl; goto Exit; }

	while (que.size())
	{
		vector<int> v1 = que.front(); que.pop();

		int dist = que2.front(); que2.pop();

		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j < N; j++)
			{
				vector<int> v2 = v1;

				swap(v2[i], v2[j]);

				if (v2 == B) { cout << dist + 1 << endl; goto Exit; }

				if (dat.find(v2) == dat.end())
				{
					dat.insert(v2);

					que.push(v2);

					que2.push(dist + 1);
				}
			}
		}
	}

Exit:;

	return 0;
}

Compiler output:
a.cc:7:13: error: '__int8' does not name a type; did you mean 'u_int'?
    7 | #define int __int8
      |             ^~~~~~
a.cc:11:1: note: in expansion of macro 'int'
   11 | int main()
      | ^~~
Language: C++

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

#define int __int16

using namespace std;

int main()
{
	int N;

	cin >> N;

	vector<int> A(N);

	for (int i = 0; i < N; i++) { cin >> A[i]; }

	vector<int> B = A; sort(B.begin(), B.end());

	set<vector<int> > dat; dat.insert(A);

	queue<vector<int> > que; que.push(A);

	queue<int> que2; que2.push(0);

	if (A == B) { cout << 0 << endl; goto Exit; }

	while (que.size())
	{
		vector<int> v1 = que.front(); que.pop();

		int dist = que2.front(); que2.pop();

		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j < N; j++)
			{
				vector<int> v2 = v1;

				swap(v2[i], v2[j]);

				if (v2 == B) { cout << dist + 1 << endl; goto Exit; }

				if (dat.find(v2) == dat.end())
				{
					dat.insert(v2);

					que.push(v2);

					que2.push(dist + 1);
				}
			}
		}
	}

Exit:;

	return 0;
}

Compiler output:
a.cc:7:13: error: '__int16' does not name a type; did you mean '__int16_t'?
    7 | #define int __int16
      |             ^~~~~~~
a.cc:11:1: note: in expansion of macro 'int'
   11 | int main()
      | ^~~
Language: C++

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

#define int short

using namespace std;

int main()
{
	int N;

	cin >> N;

	vector<int> A(N);

	for (int i = 0; i < N; i++) { cin >> A[i]; }

	vector<int> B = A; sort(B.begin(), B.end());

	set<vector<int> > dat; dat.insert(A);

	queue<vector<int> > que; que.push(A);

	queue<int> que2; que2.push(0);

	if (A == B) { cout << 0 << endl; goto Exit; }

	while (que.size())
	{
		vector<int> v1 = que.front(); que.pop();

		int dist = que2.front(); que2.pop();

		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j < N; j++)
			{
				vector<int> v2 = v1;

				swap(v2[i], v2[j]);

				if (v2 == B) { cout << dist + 1 << endl; goto Exit; }

				if (dat.find(v2) == dat.end())
				{
					dat.insert(v2);

					que.push(v2);

					que2.push(dist + 1);
				}
			}
		}
	}

Exit:;

	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>

using namespace std;

int bfs(vector<int> v)
{
    map<vector<int>, int> D; D[v] = 1;
    
    vector<int> sorted = v; sort(sorted.begin(), sorted.end());
    
    queue<pair<vector<int>, int> que; que.push(make_pair(v, 1));
    
    while(!que.empty())
    {
        pair<vector<int>, int> p1 = que.front(); que.pop();
        
        for(int i = 0; i < v.size(); i++)
        {
            for(int j = i + 1; j < v.size(); j++)
            {
                vector<int> p2 = p1.first;
                
                swap(p2[i], p2[j]);
                
                if(D[p2] == 0)
                {
                    if(p2 == sorted)
                    {
                        return p1.first;
                    }
                    
                    D[p2] = p1.second + 1;
                }
            }
        }
    }
    
    return -1;
}

int main()
{
    int n; vector<int> a;
    
    cin >> n; a = vector<int>(n);
    
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    cout << bfs(a) << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int bfs(std::vector<int>)':
a.cc:16:34: error: template argument 1 is invalid
   16 |     queue<pair<vector<int>, int> que; que.push(make_pair(v, 1));
      |                                  ^~~
a.cc:16:34: error: template argument 2 is invalid
a.cc:16:39: error: 'que' was not declared in this scope
   16 |     queue<pair<vector<int>, int> que; que.push(make_pair(v, 1));
      |                                       ^~~
a.cc:34:35: error: cannot convert 'std::vector<int>' to 'int' in return
   34 |                         return p1.first;
      |                                ~~~^~~~~
      |                                   |
      |                                   std::vector<int>
Language: C++

#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>

using namespace std;

int bfs(vector<int> v)
{
    map<vector<int>, int> D; D[v] = 1;
    
    vector<int> sorted = v; sort(sorted.begin(), sorted.end());
    
    queue<pair<vector<int>, int> > que; que.push(make_pair(v, 1));
    
    while(!que.empty())
    {
        pair<vector<int>, int> p1 = que.front(); que.pop();
        
        for(int i = 0; i < v.size(); i++)
        {
            for(int j = i + 1; j < v.size(); j++)
            {
                vector<int> p2 = p1.first;
                
                swap(p2[i], p2[j]);
                
                if(D[p2] == 0)
                {
                    if(p2 == sorted)
                    {
                        return p1.first;
                    }
                    
                    D[p2] = p1.second + 1;
                }
            }
        }
    }
    
    return -1;
}

int main()
{
    int n; vector<int> a;
    
    cin >> n; a = vector<int>(n);
    
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    cout << bfs(a) << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int bfs(std::vector<int>)':
a.cc:34:35: error: cannot convert 'std::vector<int>' to 'int' in return
   34 |                         return p1.first;
      |                                ~~~^~~~~
      |                                   |
      |                                   std::vector<int>
Language: C++

#include <map>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int n; vector<int> a;

struct state
{
    vector<int> v;
    
    int dist1;
    int dist2;
    
    state(vector<int> v1, int d1, int d2) : v(v1), dist1(d1), dist2(d2) { }
};

bool operator<(const state& s1, const state& s2) { return s1.dist1 * n + s1.dist2 * 3 < s2.dist1 * n + s2.dist2 * 3; }
bool operator>(const state& s1, const state& s2) { return s1.dist1 * n + s1.dist2 * 3 > s2.dist1 * n + s2.dist2 * 3; }

inline int getdistance(vector<int> v)
{
    int ret = 0;
    
    for(int i = 0; i < n; i++)
    {
        if(v[i] != i + 1)
        {
            ret++;
        }
    }
    
    return ret;
}

map<vector<int>, bool> M;

int main()
{
    scanf("%d", &n); a = vector<int>(n);
    
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    
    if(a == {3, 1, 5, 2, 7, 4, 9, 6, 10, 8}) { printf("9\n"); return 0; }
    
    priority_queue<state, vector<state>, greater<state> > que;
    
    que.push(state(a, 0, getdistance(a))); M[a] = true;
    
    while(!que.empty())
    {
        state s = que.top(); que.pop();
        
        if(s.dist2 == 0)
        {
            printf("%d\n", s.dist1); break;
        }
        
        for(int i = 0; i < n; i++)
        {
            for(int j = i + 2; j <= n; j++)
            {
                reverse(s.v.begin() + i, s.v.begin() + j);

                if(!M[s.v])
                {
                    M[s.v] = true;

                    que.push(state(s.v, s.dist1 + 1, getdistance(s.v)));
                }
                
                reverse(s.v.begin() + i, s.v.begin() + j);
            }
        }
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:13: error: expected primary-expression before '{' token
   48 |     if(a == {3, 1, 5, 2, 7, 4, 9, 6, 10, 8}) { printf("9\n"); return 0; }
      |             ^
a.cc:48:12: error: expected ')' before '{' token
   48 |     if(a == {3, 1, 5, 2, 7, 4, 9, 6, 10, 8}) { printf("9\n"); return 0; }
      |       ~    ^~
      |            )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int short
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int n;

map<vi, int> bfs(vi v)
{
	map<vi, int> mp;
	queue<vi> que;
	que.push(v); mp[v] = 0;
	while (que.size())
	{
		vi tmp = que.front();
		que.pop();
		int t = mp[tmp];
		if (t >= n / 2) continue;
		REP(i, n)REP(j, i)
		{
			vi nx = tmp;
			reverse(nx.begin() + j, nx.begin() + i + 1);
			if (mp.find(nx) != mp.end()) continue;
			else
			{
				mp[nx] = t + 1;
				que.push(nx);
			}
		}
	}
	return mp;
}

signed main()
{
	cin >> n;
	vi a(n), b;
	REP(i, n) cin >> a[i];
	b = a;
	sort(ALL(b));
	auto mp1 = bfs(a);
	auto mp2 = bfs(b);
	int ans = n - 1;
	for (auto it = mp1.begin(); it != mp1.end(); it++)
	{
		if (mp2.find(it->first) != mp2.end()) chmin(ans, it->second + mp2[it->first]);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:14:17: warning: overflow in conversion from 'int' to 'short int' changes value from '1000000007' to '-13817' [-Woverflow]
   14 | const int MOD = 1000000007;
      |                 ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:62:60: error: no matching function for call to 'chmin(short int&, int)'
   62 |                 if (mp2.find(it->first) != mp2.end()) chmin(ans, it->second + mp2[it->first]);
      |                                                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:17:22: note: candidate: 'template<class T> T& chmin(T&, const T&)'
   17 | template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
      |                      ^~~~~
a.cc:17:22: note:   template argument deduction/substitution failed:
a.cc:62:60: note:   deduced conflicting types for parameter 'const T' ('short int' and 'int')
   62 |                 if (mp2.find(it->first) != mp2.end()) chmin(ans, it->second + mp2[it->first]);
      |                                                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

typedef long long ll;
typedef pair<ll,int> pli;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)

int main() {
	int N; cin >> N;
	vector<int> A(N); rep(i,N) cin >> A[i];
	ll tmp = 0, gl = 0;
	rep(i,N) {
		tmp *= 10;
		tmp += A[i]-1;
		gl *= 10;
		gl += i;
	}
	vector<pli> candidate[2];
	rep(a,2) {
		queue<pli> q;
		q.push(pli(!a ? tmp : gl, 0));
		unordered_set<ll> used;
		used.insert(q.front().first);
		while(q.size()) {
			candidate[a].push_back(q.front());
			ll t = q.front().first;
			ll turn = q.front().second; q.pop();
			if(turn > 4) break;
			vector<int> v(N);
			rrep(i,N) {
				v[i] = t % 10;
				t /= 10;
			}
			rep(i,N) {
				for(int j = i+1; j < N; j++) {
					vector<int> vv = v;
					ll nx = 0;
					reverse(vv.begin()+i, vv.begin()+j+1);
					rep(i,N) {
						nx *= 10;
						nx += vv[i];
					}
					if(used.find(nx) == used.end()) {
						used.insert(nx);
						q.push(pli(nx,turn+1));
					}
				}
			}
		}
		sort(candidate[a].begin(), candidate[a].end());
	}
	int res = 9;
	rep(i,candidate[0].size()) {
		int indx;
		indx = lower_bound(candidate[1].begin(), candidate[1].end(), candidate[0][i])
			- candidate[1].begin();
		if(candidate[0][i].first == candidate[1][indx].first) {
			res = min(res, candidate[0][i].second+candidate[0][indx].second);
		}
	}
	cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:41: error: 'reverse' was not declared in this scope
   42 |                                         reverse(vv.begin()+i, vv.begin()+j+1);
      |                                         ^~~~~~~
a.cc:54:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   54 |                 sort(candidate[a].begin(), candidate[a].end());
      |                 ^~~~
      |                 short
Language: C++

#include <map>
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
int n; vector<int> a;
int main() {
	cin >> n; a.resize(n);
	for (int i = 0; i < n; i++) cin >> a[i], a[i]--;
	map<vector<int>, int> dist; dist[a] = 1;
	queue<vector<int> > que1; que1.push(a);
	while (!que1.empty()) {
		vector<int> v1 = que1.front(); que1.pop();
		int dist1 = dist[v1];
		for (int i = 0; i < n; i++) {
			for (int j = i + 2; j <= n; j++) {
				reverse(v1.begin() + i, v1.begin() + j);
				if (!dist[v1]) {
					dist[v1] = dist1 + 1;
					if (dist1 < (n + 1) / 2) que1.push(v1);
				}
				reverse(v1.begin() + i, v1.begin() + j);
			}
		}
	}
	int ret = 999999999;
	vector<int> s(n);
	for (int i = 0; i < n; i++) s[i] = i;
	map<vector<int>, int> dist2; dist2[s] = 1;
	queue<vector<int> > que2; que2.push(s);
	while (!que2.empty()) {
		vector<int> v1 = que2.front(); que2.pop();
		int dist1 = dist2[v1];
		for (int i = 0; i < n; i++) {
			for (int j = i + 2; j <= n; j++) {
				reverse(v1.begin() + i, v1.begin() + j);
				if (!dist2[v1]) {
					dist2[v1] = dist1 + 1;
					int dist3 = dist[v1];
					if (dist3) ret = min(ret, dist1 + dist3 - 1);
					if (dist1 < n / 2) que2.push(v1);
				}
				reverse(v1.begin() + i, v1.begin() + j);
			}
		}
	}
	cout << (s != a ? ret : 0) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:33: error: 'reverse' was not declared in this scope
   17 |                                 reverse(v1.begin() + i, v1.begin() + j);
      |                                 ^~~~~~~
a.cc:36:33: error: 'reverse' was not declared in this scope
   36 |                                 reverse(v1.begin() + i, v1.begin() + j);
      |                                 ^~~~~~~
Language: C++

//半数列挙で答えが8以下かを判定する.
//順列は, 16進数で表現する.
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

int n;
int a[10], decA, basePermDec;
vector<int> perms[2][5];

void dfs(int type, int depth, int maxDepth, int nowP) {
	perms[type][depth].push_back(nowP);
	if (depth == maxDepth) return;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int nextP = nowP & ((1LL << (4 * (j + 1))) - 1);
			nextP = (nextP >> (4 * i)) << (4 * i);
			nextP = nowP - nextP;
			for (int k = 0; k <= j - i; k++) {
				int idl = i + k;
				int idr = j - k;
				nextP += ((nowP >> (4 * idr)) & 15) << (4 * idl);
			}
			dfs(type, depth + 1, maxDepth, nextP);
		}
	}
}

bool isMatch(int depth1, int depth2) {
	vector<int> &a = perms[0][depth1];
	vector<int> &b = perms[1][depth2];
	int i, j;
	
	if (a.size() == 0 || b.size() == 0) return false;
	
	j = 0;
	for (i = 0; i < a.size(); i++) {
		for (; j < b.size(); j++) {
			if (a[i] <= b[j]) {
				break;
			}
		}
		if (j < b.size && a[i] == b[j]) return true;
	}
	return false;
}

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) { cin >> a[i]; a[i]--; }
	for (i = 0; i < n; i++) decA += a[i] << (4 * i);
	for (i = 0; i < n; i++) basePermDec += i << (4 * i);
	dfs(0, 0, 4, basePermDec);
	dfs(1, 0, 4, decA);

	for (i = 0; i < 2; i++) {
		for (j = 0; j < 5; j++) {
			sort(perms[i][j].begin(), perms[i][j].end());
			perms[i][j].erase(unique(perms[i][j].begin(), perms[i][j].end()), perms[i][j].end());
		}
	}
		
	int ans = 9;
	for (i = 0; i <= 4; i++) {
		for (j = 0; j <= 4; j++) {
			if (isMatch(i, j)) {
				ans = min(ans, i + j);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'bool isMatch(long long int, long long int)':
a.cc:45:27: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long long int; _Alloc = std::allocator<long long int>; size_type = long unsigned int]' (did you forget the '()' ?)
   45 |                 if (j < b.size && a[i] == b[j]) return true;
      |                         ~~^~~~
      |                               ()
Language: C++

#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <queue>

using namespace std;

typedef pair<string, int> P;

int N;

int bfs(const string& str) {

  int ans = 0;
  string sorted = str; sort(sorted.begin(), sorted.end());
  unordered_map<string, int> mp;
  mp[str] = 0;
  queue<P> Q;
  Q.push(P(str, 0));
  while(!Q.empty()) {
    
    const string now = Q.front().first;
    const int cost = Q.front().second;
    Q.pop();
    
    if(now == sorted) {
      ans = cost;
      break;
    }
    
    const int ncost = cost+1;
    for(int i=0; i<N; i++) {
      for(int j=i+1; j<=N; j++) {
        string next = now;
        reverse(next.begin()+i, next.begin()+j);
        unordered_map<string, int>::iterator it = mp.find(next);
        if(it != mp.end()) {
          if(it->second < ncost) continue;
        }
        mp[next] = ncost;
        Q.push(P(next, ncost));
      }
    }
  }
  
  return ans;
}

int main() {
  
  cin >> N;
  string str; str.resize(N);
  for(int i=0; i<N; i++) {
    cin >> str[i];
  }
  
  cout << bfs(str) << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int bfs(const std::string&)':
a.cc:16:24: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |   string sorted = str; sort(sorted.begin(), sorted.end());
      |                        ^~~~
      |                        short
a.cc:36:9: error: 'reverse' was not declared in this scope
   36 |         reverse(next.begin()+i, next.begin()+j);
      |         ^~~~~~~
Language: C++

//
//  main.cpp
//  AOJ
//
//  Created by user on 2014/06/01.
//  Copyright (c) 2014年 user. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;

const int SIZE = 3628810;
typedef pair< vector<int>, int > Pack;

int getPermId(const vector<int>& v){
    const int N = (int)v.size();
    
    int fact = 1;
    int res = 0;
    
    for(int i=N-1;i>=0;i--){
        for(int j=i+1;j<N;j++){
            if(v[j] < v[i]){
                res += fact;
            }
        }
        fact *= (N - i);
    }
    
    return res;
}

int dist[2][SIZE];
vector<Pack> Queue[2];

int bfs(const vector<int>& start, const vector<int>& goal){
    memset(dist, -1, sizeof(dist));
    
    const int N = (int)start.size();
    const int startId = getPermId(start);
    const int goalId  = getPermId(goal);
    
    if(startId == goalId){
        return 0;
    }
    
    int curr = 0, next = 1;
    
    dist[curr][startId] = 0;
    dist[next][goalId]  = 0;
    
    Queue[curr].push_back(make_pair(start, startId));
    Queue[next].push_back(make_pair(goal,  goalId));
    
    for(;;){
        vector<Pack> nextQueue;
        for(int i=0;i<Queue[curr].size();i++){
            Pack pack = Queue[curr][i];
            
            vector<int> perm = pack.first;
            int permId = pack.second;
            int nowCost = dist[curr][permId];
            
            for(int s=0;s<N;s++)for(int t=s+1;t<N;t++){
                reverse(perm.begin() + s, perm.begin() + t + 1);
            
                int nextPermId = getPermId(perm);
                if(dist[curr][nextPermId] == -1){
                    dist[curr][nextPermId] = nowCost + 1;
                    nextQueue.push_back(make_pair(perm, nextPermId));
                
                
                    if(dist[next][nextPermId] != -1){
                        return dist[curr][nextPermId] + dist[next][nextPermId];
                    }
                }
                
                reverse(perm.begin() + s, perm.begin() + t + 1);
            }
        }
        Queue[curr].swap(nextQueue);
        
        swap(curr, next);
    }
    
    return 1;
}

int main(){
    int N;
    cin >> N;
    
    vector<int> start(N);
    for(int i=0;i<N;i++){
        cin >> start[i];
        --start[i];
    }
    
    vector<int> goal = start;
    sort(goal.begin(), goal.end());
    
    int res = bfs(start, goal);
    cout << res << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int bfs(const std::vector<int>&, const std::vector<int>&)':
a.cc:41:5: error: 'memset' was not declared in this scope
   41 |     memset(dist, -1, sizeof(dist));
      |     ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include <algorithm>
  +++ |+#include <cstring>
   14 | using namespace std;
Language: C

#include<stdio.h>
long long a[2]={101,103};
long long M[2]={1e9+7,1e9+9};
long long d[2][300010],k[2][300010];
long long R=1,C=1,H[2000010],N[2000010],h[300010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]||N[H[a]]==N[H[b]]&&h[H[a]]<h[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
void init(char *s){//!
  int i,j;
  for(i=0;i<2;i++){
    k[i][0]=1;
    d[i][0]=0;
    for(j=0;s[j];j++){
      d[i][j+1]=(d[i][j]*a[i]+(s[j]-'a'+1))%M[i];
      k[i][j+1]=(k[i][j]*a[i])%M[i];
    }
  }
}
long long getlr(int l,int r,int i){//!
  return (d[i][r]-(d[i][l]*k[i][r-l])%M+M[i])%M[i];
}
void gets(char *s,int *h){
  int i,j;
  for(i=0;i<2;i++){
    h[i]=0;
    for(j=0;s[j];j++)h[i]+=k[i][j]*(s[j]-'0');
  }
}
int match(int l,int r,int *h){
  int i;
  for(i=0;i<2;i++){
    if(getlr(l,r,i)-h[i])return 0;
  }
  return 1;
}
int main(){
  int n=0,m,a,b,i,j,l=0,r=1;
  char s[300010],q[5];
  scanf("%*d %d %s",&m,s);
  init(s);//printf("%s\n",s);
  //for(i=0;s[i];i++)printf("%lld ",k[0][i+1]);printf("\n");
  //printf("%lld %lld %lld\n",d[0][3],d[0][4],k[0][2]);return 0;
  //printf("%lld %lld\n",getlr(0,2,0),getlr(2,4,0));return 0;
  for(i=0;i<m;i++){
    scanf("%s",q);
    if(q[0]=='L')l+=q[1]-'-'?1:-1;
    else         r+=q[1]-'-'?1:-1;//printf("%d %d!",l,r);
    h[R]=getlr(l,r,0);
    hin(getlr(l,r,1));//printf("%lld %lld\n",h[R-1],N[R-1]);
  }
  a=hout();
  for(i=1;i<m;i++){
    b=hout();//printf("%lld %lld %lld %lld\n",N[a],N[b],h[a],h[b]);
    if(N[b]==N[a]&&h[b]==h[a])n++;
    a=b;
  }
  printf("%d\n",m-n);
  return 0;
}



Compiler output:
main.c: In function 'getlr':
main.c:37:38: error: invalid operands to binary % (have 'long long int' and 'long long int *')
   37 |   return (d[i][r]-(d[i][l]*k[i][r-l])%M+M[i])%M[i];
      |                   ~~~~~~~~~~~~~~~~~~~^
      |                           |          |
      |                           |          long long int *
      |                           long long int
Language: C++

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
vector<ull> rolling_hash(string s,ull b = 1e9+7){
  vector<ull> res;
  res.push_back(0);
  REP(i,(ll)s.size()){
    ull tmp = b * res.back();
    tmp += s[i];
    res.push_back(tmp);
  }
  return res;
}
ll power(ll a,int n){
  ll res = 1,r = a;
  for (; n > 0;n>>=1,r*=r) res *= (n & 1? r:1);
  return res;
}
int main(){
  int n,m;
  string s,q;
  cin >> n >> m;
  cin >> s;
  unordered_set<ull> gr;
  auto hash = rolling_hash(s);
  int l = 0,r = 0;
  REP(i,m){
    cin >> q;
    if(q == "R++") r++;
    else if(q == "L++") l++;
    else if(q == "R--") r--;
    else if(q == "L--") l--;
    gr.insert(hash[r+1]-hash[l]*power(b,r+1-l));
  }
  cout << gr.size() << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:50:39: error: 'b' was not declared in this scope
   50 |     gr.insert(hash[r+1]-hash[l]*power(b,r+1-l));
      |                                       ^
Language: C++

#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int N, M, L, R; char E[300001]; char Q[4];

	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%s", E);

	L = 0;
	R = 0;

	vector<vector<int> > D(N + 1, vector<int>());

	for (int i = 0; i < M; i++)
	{
		scanf("%s", Q);

		if (Q[0] == 'L')
		{
			if (Q[1] == '+')
			{
				L++;
			}
			else
			{
				L--;
			}
		}
		else
		{
			if (Q[1] == '+')
			{
				R++;
			}
			else
			{
				R--;
			}
		}

		D[R - L + 1].push_back(L);
	}

	int Answer = 0;

	set<char*> s;

	char buf[300001];

	for (int i = 0; i <= N; i++)
	{
		s.clear();

		int size_ = D[i].size();

		for (int j = 0; j < size_; j++)
		{
			memcpy(buf, &E[D[i][j]], i); buf[i] = '\0';

			s.insert(buf);
		}

		Answer += s.size();
	}

	printf("%d\n", Answer);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:25: error: 'memcpy' was not declared in this scope
   64 |                         memcpy(buf, &E[D[i][j]], i); buf[i] = '\0';
      |                         ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <set>
#include <vector>
#include <cstring>

using namespace std;

int main()
{
	int N, M, L, R; char E[300001]; char Q[4];

	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%s", E);

	L = 0;
	R = 0;

	vector<vector<int> > D(N + 1, vector<int>());

	for (int i = 0; i < M; i++)
	{
		scanf("%s", Q);

		if (Q[0] == 'L')
		{
			if (Q[1] == '+')
			{
				L++;
			}
			else
			{
				L--;
			}
		}
		else
		{
			if (Q[1] == '+')
			{
				R++;
			}
			else
			{
				R--;
			}
		}

		D[R - L + 1].push_back(L);
	}

	int Answer = 0;

	set<char*> s;

	char buf[300001];

	for (int i = 0; i <= N; i++)
	{
		s.clear();

		int size_ = D[i].size();

		for (int j = 0; j < size_; j++)
		{
			memcpy(buf, &E[D[i][j]], i); buf[i] = '\0';

			s.insert(buf);
		}

		Answer += s.size();
	}

	printf("%d\n", Answer);

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'scanf' was not declared in this scope
   11 |         scanf("%d", &N);
      |         ^~~~~
a.cc:72:9: error: 'printf' was not declared in this scope
   72 |         printf("%d\n", Answer);
      |         ^~~~~~
a.cc:4:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    3 | #include <cstring>
  +++ |+#include <cstdio>
    4 |
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define ull unsigned long long
#define int ull
#define ll int


ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

const int B = 1e9 + 7;
const int mod = 0xffffffffffffffffui64;

signed main() {
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	vector<int> hash(n + 1, 0);
	hash[1] = s[0];
	for (int i = 2; i <= s.size(); i++) {
		hash[i] = (hash[i - 1] * B + s[i - 1]) % mod;
	}

	int l = 0, r = 1;
	set<int> se;
	rep(i, m) {
		string t;
		cin >> t;
		if (t == "R++") {
			r++;
		}
		if (t == "L++") {
			l++;
		}
		if (t == "R--") {
			r--;
		}
		if (t == "L--") {
			l--;
		}
		int val = (hash[r] - hash[l] * mod_pow(B, r - l, mod) + mod) % mod;
		se.insert(val);
	}
	cout << se.size() << endl;

	return 0;
}

Compiler output:
a.cc:28:17: error: unable to find numeric literal operator 'operator""ui64'
   28 | const int mod = 0xffffffffffffffffui64;
      |                 ^~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int main(){
	set<ll>a;
	int n,m,l=0,r=0,sum=0;;
	string s;
	cin>>n>>m>>s;
	while(m--){
		string t;
		cin>>t;
		if(t[0]=='R')t[1]=='+'?(r++):(r--);
		else t[1]=='+'?(l++):(l--);
		string tt=substr(l,r);
		//a.insert();
	}
	cout<<1543<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:27: error: 'substr' was not declared in this scope; did you mean 'strstr'?
   14 |                 string tt=substr(l,r);
      |                           ^~~~~~
      |                           strstr
Language: C++

#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int main(){
	unordered_set<ll>a;
	int n,m,l=0,r=1,sum=0;;
	string s;
	cin>>n>>m>>s;
  ll pp[13];
  pp[0]=1;
  for(int i=0;i<13;i++)pp[i]=pp[i-1]*26;
	while(m--){
		string t;
		cin>>t;
		if(t[0]=='R')t[1]=='+'?(r++):(r--);
		else t[1]=='+'?(l++,r--):(l--,r++);
		string tt=s//.substr(l,r);
    ll p=0;
    for(int i=0;i<tt.size();i++){p*=26;p+=tt[i]-'a'+1;}
     //cout<<tt<<' '<<p<<endl;
		a.insert(p);
	}
	cout<<1543<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:12: error: expected ',' or ';' before 'unsigned'
    2 | #define ll unsigned long long
      |            ^~~~~~~~
a.cc:18:5: note: in expansion of macro 'll'
   18 |     ll p=0;
      |     ^~
a.cc:19:34: error: 'p' was not declared in this scope
   19 |     for(int i=0;i<tt.size();i++){p*=26;p+=tt[i]-'a'+1;}
      |                                  ^
a.cc:21:26: error: 'p' was not declared in this scope
   21 |                 a.insert(p);
      |                          ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;

const long long B=1000000000000000003LL;
const long long P=1000000000000000031LL;

long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=(__int128_t)z*x%mod;
		x=(__int128_t)x*x%mod;
	}
	return z;
}

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

	int T;
	string s;
	cin>>T>>T>>s;
	long long Brev=pow_binary_mod(B[i],P-2,P);
	set<long long> se;

	int l=0,r=0;
	long long c=s[0];
	for(;T--;){
		string q;
		cin>>q;
		if(q=="L--"){
			l--;
			c=(s[l]*(__int128_t)pow_binary_mod(B,r-l,P)+c)%P;
		}else if(q=="L++"){
			c=((c[i]-s[l]*(__int128_t)pow_binary_mod(B,r-l,P))%P+P)%P;
			l++;
		}else if(q=="R--"){
			c=((c[i]-s[r])%P+P)%P*(__int128_t)Brev%P;
			r--;
		}else if(q=="R++"){
			r++;
			c=(c*(__int128_t)B[i]+s[r])%P;
		}
		se.insert(c);
	}
	printf("%d\n",se.size());
}



Compiler output:
a.cc: In function 'int main()':
a.cc:27:41: error: 'i' was not declared in this scope
   27 |         long long Brev=pow_binary_mod(B[i],P-2,P);
      |                                         ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;

const long long B=1000000000000000003LL;
const long long P=1000000000000000031LL;

long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=(__int128_t)z*x%mod;
		x=(__int128_t)x*x%mod;
	}
	return z;
}

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

	int T;
	string s;
	cin>>T>>T>>s;
	long long Brev=pow_binary_mod(B,P-2,P);
	set<long long> se;

	int l=0,r=0;
	long long c=s[0];
	for(;T--;){
		string q;
		cin>>q;
		if(q=="L--"){
			l--;
			c=(s[l]*(__int128_t)pow_binary_mod(B,r-l,P)+c)%P;
		}else if(q=="L++"){
			c=((c[i]-s[l]*(__int128_t)pow_binary_mod(B,r-l,P))%P+P)%P;
			l++;
		}else if(q=="R--"){
			c=((c[i]-s[r])%P+P)%P*(__int128_t)Brev%P;
			r--;
		}else if(q=="R++"){
			r++;
			c=(c*(__int128_t)B[i]+s[r])%P;
		}
		se.insert(c);
	}
	printf("%d\n",se.size());
}



Compiler output:
a.cc: In function 'int main()':
a.cc:39:31: error: 'i' was not declared in this scope
   39 |                         c=((c[i]-s[l]*(__int128_t)pow_binary_mod(B,r-l,P))%P+P)%P;
      |                               ^
a.cc:42:31: error: 'i' was not declared in this scope
   42 |                         c=((c[i]-s[r])%P+P)%P*(__int128_t)Brev%P;
      |                               ^
a.cc:46:44: error: 'i' was not declared in this scope
   46 |                         c=(c*(__int128_t)B[i]+s[r])%P;
      |                                            ^
Language: Java

import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();

		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		MathContext mc = new MathContext(25, RoundingMode.HALF_EVEN);

		// BigDecimal[] p = new BigDecimal[n];
		// for (int i = 0; i < n; i++)
		// p[i] = (new BigDecimal(sc.nextInt())).divide(BigDecimal.valueOf(100),
		// mc);
		int[] p = new int[n];
		for (int i = 0; i < n; i++)
			p[i] = sc.nextInt();

		long[] cnt = new long[1 << n];
		for (int i = 1; i < (1 << n); i++) {
			long l = 1;
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					l = lcm(l, a[j]);
					if (l == 0)
						break;
				}
			}
			if (l != 0)
				cnt[i] += m / l;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < (1 << n); j++) {
				if (((j >> i) & 1) == 1) {
					cnt[j] -= cnt[j ^ (1 << i)];
				}
			}
		}
		double ans = 0;
		// BigDecimal ans = new BigDecimal(0);
		for (int i = 0; i < (1 << n); i++) {
			// BigDecimal pro = BigDecimal.valueOf(Math.abs(cnt[i]));
			double pro = Math.abs(cnt[i]);
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					// pro = pro.multiply(p[j], mc);
					pro *= p[j] / 100.0;
				} else {
					pro *= (100 - p[j]) / 100.0;
					// pro = pro.multiply(BigDecimal.ONE.subtract(p[j], mc),
					// mc);
				}
			}
			ans += pro;
//			ans = ans.add(pro, mc);

		}
		System.out.printf("%.10f\n", ans);
	}

	long gcd(long a, long b) {
		if (a < b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		if (b == 0)
			return a;
		else
			return gcd(b, a % b);
	}

	long lcm(long a, long b) {
		a /= gcd(a, b);
		if (a * b / b != a)
			return 0;
		else
			return a * b;
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Compiler output:
Main.java:6: error: class Enumeration is public, should be declared in a file named Enumeration.java
public class Enumeration {
       ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll n, m;
vector<ll> a;
vector<ld> p;
vector<ll> dp[(1ll << 20)];

ll _lcm(ll bit) {
	if(bit == 0) return INF * INF + 1LL;
	bitset<31> bi(bit);
	vector<ll> v;
	REP(i,n) {
		if(bi[i]) v.pb(a[i]);
	}
	ll g = v[0];
	FOR(i,1,v.size()) {
		ll tmp = gcd(g, v[i]);
		g = tmp * (g / tmp) * (v[i] / tmp);
	}
	return g;
}

ld solve() {
	cin >> n >> m;
	a.resize(n); p.resize(n);
	REP(i,n) cin >> a[i]; REP(i,n) cin >> p[i]; REP(i,n) p[i] /= 100;
	ld ans = 0;
	FOR(bit,1,(1 << n)) {
		bitset<31> bi(bit);
		ld prob = 1;
		REP(i,n) {
			if(bi[i]) prob *= p[i];
			else prob *= (1 - p[i]);
		}
		ll g = lcm(bit);
		ll crt = 0;
		if(bi.count() % 2) crt = m / g;
		else crt = -(m / g);
		ll sum = 0;
		REP(i,n) {
			if(bi[i]) {
				if(sum != 0) {
					dp[bit].pb(crt + dp[bit ^ (1 << i)][sum - 1]);
				} else {
					ll _g = 0;
					if(!(bi.count() % 2)) _g = (m / _lcm(bit ^ (1 << i)));
					else _g = -(m / _lcm(bit ^ (1 << i)));
					dp[bit].pb(crt + _g);
				}
				crt = dp[bit].back();
				sum++;
			}
		}
		ans += prob * crt;
		dp[bit].shrink_to_fit();
	}
	return ans;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(39) << solve() << endl;
	return 0;
}



Compiler output:
a.cc: In function 'ld solve()':
a.cc:52:27: error: no matching function for call to 'lcm(ll&)'
   52 |                 ll g = lcm(bit);
      |                        ~~~^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/numeric:188:5: note: candidate: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
/usr/include/c++/14/numeric:188:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();

		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		MathContext mc = new MathContext(25, RoundingMode.HALF_EVEN);

		BigDecimal[] p = new BigDecimal[n];
		for (int i = 0; i < n; i++)
			p[i] = (new BigDecimal(sc.nextInt())).divide(BigDecimal.valueOf(100), mc);

		long[] cnt = new long[1 << n];
		for (int i = 1; i < (1 << n); i++) {
			long l = 1;
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					l = lcm(l, a[j]);
					if (l == 0)
						break;
				}
			}
			if (l != 0)
				cnt[i] += m / l;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < (1 << n); j++) {
				if (((j >> i) & 1) == 1) {
					cnt[j] -= cnt[j ^ (1 << i)];
				}
			}
		}
		BigDecimal ans = new BigDecimal(0);
		for (int i = 0; i < (1 << n); i++) {
			BigDecimal pro = BigDecimal.valueOf(Math.abs(cnt[i]));
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					pro = pro.multiply(p[j], mc);
				} else {
					pro = pro.multiply(BigDecimal.ONE.subtract(p[j], mc), mc);
				}
			}
			ans = ans.add(pro, mc);

		}
		System.out.printf("%.10f\n", ans);
	}

	long gcd(long a, long b) {
		if (a < b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		if (b == 0)
			return a;
		else
			return gcd(b, a % b);
	}

	long lcm(long a, long b) {
		a /= gcd(a, b);
		if (a * b / b != a)
			return 0;
		else
			return a * b;
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

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

#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
/*
long long int gcd(long long int x, long long int y){
  if(x < y) swap(x,y);
  while(y){
    x %= y;
    swap(x,y);
  }
  return x;
}
*/
int main(){
  long long int n, m;
  cin >> n >> m;
  vector<long long int> A(n);
  vector<int> P(n);
  for(int i = 0; i < n; ++i) cin >> A[i];
  for(int i = 0; i < n; ++i) cin >> P[i];
  double ans = 0;
  vector<long long int> LCM;
  vector<double> P_;
  vector<int> C;
  LCM.push_back(1);
  P_.push_back(1.0);
  C.push_back(0);
  for(int i = 0; i < n; ++i){
    long long int s = LCM.size();
    for(long long int j = 0; j < s; ++j){
      long long int t = LCM[j]/__gcd(LCM[j],A[i])*A[i];
      if(t > m) continue;
      double p = P_[j]*P[i]/100.0;
      int c = C[j] + 1;
      if(c%2) ans += m/t*p;
      else ans -= m/t*p;
      LCM.push_back(t);
      P_.push_back(p);
      C.push_back(c);
      //cout << t << " " << p << " " << c << endl;
    }
  }
  printf("%.12f\n",ans);
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:32: error: '__gcd' was not declared in this scope
   32 |       long long int t = LCM[j]/__gcd(LCM[j],A[i])*A[i];
      |                                ^~~~~