Language: C++

#include <bits/stdc++.h>
#define N 500
#define int long long
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int c[N][4],n,C[N][6],fac[5];
ll A[N],Ans;
map <ll,int> M;
inline int fnd(long long y)
{
	int x[4]; 
	for(int i=0;i<4;i++) x[i]=y&((1<<10)-1),y>>=10;
	if(x[0]==x[1]&&x[1]==x[2]&&x[2]==x[3]) return 4;
	if(x[0]==x[2]&&x[1]==x[3]) return 2;
	return 1;
}
inline ll hash(int x,int y,int z,int s)
{
	ll xs=(1ll*x<<30)+(1ll*y<<20)+(1ll*z<<10)+s;
	return xs;
}
inline ll trans(int x,int y,int z,int s)
{
	return min(min(hash(x,y,z,s),hash(y,z,s,x)),min(hash(z,s,x,y),hash(s,x,y,z)));
}
signed main()
{
	n=read(); for(int i=1;i<=n;i++)
	{
		for(int j=0;j<4;j++) c[i][j]=read();
		A[i]=trans(c[i][0],c[i][1],c[i][2],c[i][3]);
	}
	fac[0]=1; fac[1]=1; fac[2]=2; fac[3]=6; fac[4]=24;
	C[0][0]=1; for(int i=1;i<=n;i++)
	{
		C[i][0]=1;for(int j=1;j<=4;j++)
			C[i][j]=C[i-1][j-1]+C[i-1][j];
	} 
	for(int i=1;i<=n;i++) 
	{
		for(int j=1;j<i;j++)
		{
			for(int k=0;k<4;k++)
			{
				int y[4];
				y[0]=trans(c[i][(k+1)%4],c[i][(k+0)%4],c[j][1],c[j][0]);
				y[1]=trans(c[i][(k+0)%4],c[i][(k+3)%4],c[j][2],c[j][1]);
				y[2]=trans(c[i][(k+3)%4],c[i][(k+2)%4],c[j][3],c[j][2]);
				y[3]=trans(c[i][(k+2)%4],c[i][(k+1)%4],c[j][0],c[j][3]);
				sort(y,y+4); ll ret=1;
				for(int p=0;p<4;p++)
				{
					int s=p; while(y[s]==y[p]) s++;
					int tot=M[y[p]];
					if(A[j]==y[p]) tot--;
					if(s-p>tot) ret=0;
					for(int t=1;t<=s-p;t++) ret*=fnd(y[p]); 
					ret*=C[tot][s-p]*fac[s-p];
					p=s-1;
				}
				Ans+=ret;
			}
		}
		M[A[i]]++;
		//cout << A[i] << " " << M[A[i]] << endl;
	}
	cout << Ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'll trans(long long int, long long int, long long int, long long int)':
a.cc:31:24: error: reference to 'hash' is ambiguous
   31 |         return min(min(hash(x,y,z,s),hash(y,z,s,x)),min(hash(z,s,x,y),hash(s,x,y,z)));
      |                        ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:24:11: note:                 'll hash(long long int, long long int, long long int, long long int)'
   24 | inline ll hash(int x,int y,int z,int s)
      |           ^~~~
a.cc:31:38: error: reference to 'hash' is ambiguous
   31 |         return min(min(hash(x,y,z,s),hash(y,z,s,x)),min(hash(z,s,x,y),hash(s,x,y,z)));
      |                                      ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:24:11: note:                 'll hash(long long int, long long int, long long int, long long int)'
   24 | inline ll hash(int x,int y,int z,int s)
      |           ^~~~
a.cc:31:57: error: reference to 'hash' is ambiguous
   31 |         return min(min(hash(x,y,z,s),hash(y,z,s,x)),min(hash(z,s,x,y),hash(s,x,y,z)));
      |                                                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:24:11: note:                 'll hash(long long int, long long int, long long int, long long int)'
   24 | inline ll hash(int x,int y,int z,int s)
      |           ^~~~
a.cc:31:71: error: reference to 'hash' is ambiguous
   31 |         return min(min(hash(x,y,z,s),hash(y,z,s,x)),min(hash(z,s,x,y),hash(s,x,y,z)));
      |                                                                       ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:24:11: note:                 'll hash(long long int, long long int, long long int, long long int)'
   24 | inline ll hash(int x,int y,int z,int s)
      |           ^~~~