Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
typedef pair<pair<int,int>, pair<int,int> > pt;

const int MOD = 1e9 + 7;
const int C = 1001;

unordered_map<ll,int> ma;

ll hsh(int a, int b, int c, int d)
{
	ll x = ll(a)*ll(C)*ll(C)*ll(C);
	x += ll(b)*ll(C)*ll(C);
	x += ll(c)*ll(C);
	x += d;
	return x;
}

void cyc(int &a, int &b, int &c, int &d)
{
	swap(a, b);
	swap(a, c);
	swap(a, d);
}

vector<pt> vec;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vec.resize(n);
	for(int i = 0; i < n; i++)
	{
		cin >> vec[i].fi.fi >> vec[i].fi.se >> vec[i].se.fi >> vec[i].se.se;
	}
	for(int i = 0; i < n; i++)
	{
		int a = vec[i].fi.fi; int b = vec[i].fi.se;
		int c = vec[i].se.fi; int d = vec[i].se.se;
		ma[hsh(a,b,c,d)]++;
		ma[hsh(b,c,d,a)]++;
		ma[hsh(c,d,a,b)]++;
		ma[hsh(d,a,b,c)]++;
	}
	ll ans = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(i == j) continue;
			int xa, xb, xc, xd, ya, yb, yc, yd;
			xa = vec[i].fi.fi; xb = vec[i].fi.se; xc = vec[i].se.fi; xd = vec[i].se.se;
			ya = vec[j].fi.fi; yb = vec[j].fi.se; yc = vec[j].se.fi; yd = vec[j].se.se;
			swap(xb,xd);
			for(int k = 0; k < 4; k++)
			{
				int a,b,c,d;
				a=xa,b=xb,c=xc,d=xd;
				swap(b,d);
				ma[hsh(a,b,c,d)]--;
				ma[hsh(b,c,d,a)]--;
				ma[hsh(c,d,a,b)]--;
				ma[hsh(d,a,b,c)]--;
				a=ya,b=yb,c=yc,d=yd;
				ma[hsh(a,b,c,d)]--;
				ma[hsh(b,c,d,a)]--;
				ma[hsh(c,d,a,b)]--;
				ma[hsh(d,a,b,c)]--;
				ll h1 = hsh(ya,yd,xd,xa);
				ll h2 = hsh(yd,yc,xc,xd);
				ll h3 = hsh(yc,yb,xb,xc);
				ll h4 = hsh(yb,ya,xa,xb);
				//set<ll> ss;
				//ss.insert(h1); ss.insert(h2); ss.insert(h3); ss.insert(h4);
				unordered_map<ll,int> ss;
				////cerr<<h1<<' '<<h2<<' '<<h3<<' '<<h4<<'\n';
				ll tmp = 0;
				
					////cerr<<w<<' '<<x<<' '<<y<<' '<<z<<'\n';
					ll x1 = ma[h1];
					ss.clear();
					for(int z = 0; z < 4; z++)
					{
						cyc(ya,yd,xd,xa);
						ss[hsh(ya,yd,xd,xa)]++;
					}
					for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
					{
						ma[it->fi] -= it->se;
					}	
					//ma[w][h1]--; ma[w][h2]--; ma[w][h3]--; ma[w][h4]--;
					ll x2 = ma[h2];
					ss.clear();
					for(int z = 0; z < 4; z++)
					{
						cyc(yd,yc,xc,xd);
						ss[hsh(yd,yc,xc,xd)]++;
					}
					for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
					{
						ma[it->fi] -= it->se;
					}
					//ma[x][h2]--; ma[x][h1]--; ma[x][h3]--; ma[x][h4]--;
					ll x3 = ma[h3];
					ss.clear();
					for(int z = 0; z < 4; z++)
					{
						cyc(yc,yb,xb,xc);
						ss[hsh(yc,yb,xb,xc)]++;
					}
					for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
					{
						ma[it->fi] -= it->se;
					}
					//ma[y][h3]--; ma[y][h2]--; ma[y][h1]--; ma[y][h4]--;
					ll x4 = ma[h4];
					ss.clear();
					for(int z = 0; z < 4; z++)
					{
						cyc(ya,yd,xd,xa);
						ss[hsh(ya,yd,xd,xa)]++;
					}
					for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
					{
						ma[it->fi] += it->se;
					}	
					//ma[w][h1]--; ma[w][h2]--; ma[w][h3]--; ma[w][h4]--;
					ss.clear();
					for(int z = 0; z < 4; z++)
					{
						cyc(yd,yc,xc,xd);
						ss[hsh(yd,yc,xc,xd)]++;
					}
					for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
					{
						ma[it->fi] += it->se;
					}
					//ma[x][h2]--; ma[x][h1]--; ma[x][h3]--; ma[x][h4]--;
					ss.clear();
					for(int z = 0; z < 4; z++)
					{
						cyc(yc,yb,xb,xc);
						ss[hsh(yc,yb,xb,xc)]++;
					}
					for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
					{
						ma[it->fi] += it->se;
					}
					//ma[w][h1]++; ma[x][h2]++; ma[y][h3]++;
					//ma[w][h1]++; ma[w][h2]++; ma[w][h3]++; ma[w][h4]++;
					//ma[x][h2]++; ma[x][h1]++; ma[x][h3]++; ma[x][h4]++;
					//ma[y][h3]++; ma[y][h2]++; ma[y][h1]++; ma[y][h4]++;
					x1=max(x1,0LL); x2=max(x2,0LL); x3=max(x3,0LL); x4 = max(x4,0LL);
					tmp += (x1*x2*x3*x4);

				/*
				tmp*=ma[h1];
				ma[h1]--;
				tmp*=ma[h2];
				ma[h2]--;
				tmp*=ma[h3];
				ma[h3]--;
				tmp*=ma[h4];
				ma[h1]++; ma[h2]++; ma[h3]++;
				*/
				//cerr<<i<<' '<<j<<' '<<xa<<' '<<xb<<' '<<xc<<' '<<xd<<' '<<ya<<' '<<yb<<' '<<yc<<' '<<yd<<' '<<tmp<<'\n';
				ans += tmp;
				a=xa,b=xb,c=xc,d=xd;
				swap(b,d);
				ma[hsh(a,b,c,d)]++;
				ma[hsh(b,c,d,a)]++;
				ma[hsh(c,d,a,b)]++;
				ma[hsh(d,a,b,c)]++;
				a=ya,b=yb,c=yc,d=yd;
				ma[hsh(a,b,c,d)]++;
				ma[hsh(b,c,d,a)]++;
				ma[hsh(c,d,a,b)]++;
				ma[hsh(d,a,b,c)]++;
				cyc(ya,yb,yc,yd);
			}
		}
	}
	//assert(ans%6==0);
	ans/=6;
	cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:108:80: error: conversion from 'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} to non-scalar type 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} requested
  108 |                                         for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
      |                                                                        ~~~~~~~~^~
a.cc:108:87: error: no match for 'operator!=' (operand types are 'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} and 'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'})
  108 |                                         for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
      |                                                                                    ~~ ^~ ~~~~~~~~
      |                                                                                    |           |
      |                                                                                    |           std::unordered_map<long long int, int>::iterator {aka std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator}
      |                                                                                    std::map<long long int, int>::iterator {aka std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator}
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
                 from a.cc:1:
/usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
 1132 |     operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1132:5: note:   template argument deduction/substitution failed:
a.cc:108:97: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  108 |                                         for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
      |                                                                                                 ^
/usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
 1212 |     operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1212:5: note:   template argument deduction/substitution failed:
a.cc:108:97: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
  108 |                                         for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
      |                                                                                                 ^
/usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1305 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1305:5: note:   template argument deduction/substitution failed:
a.cc:108:97: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  108 |                                         for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
      |                                                                                                 ^
/usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
 1379 |     operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1379:5: note:   template argument deduction/substitution failed:
a.cc:108:97: note:   'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  108 |                                         for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
      |                                                                                                 ^
/usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1473 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1473:5: note:   template argument deduction/substitution failed:
a.cc:108:97: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  108 |                                         for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
      |                                                                                                 ^
/usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
 1547 |     operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1547:5: note:   template argument deduction/substitution failed:
a.cc:108:97: note:   'std::unordered_map<long long int, int>::iterator' {aka 'std::__detail::_Insert_base<long long int, std::pair<const long long int, int>, std::allocator<std::pair<const long long int, int> >, std::__detail::_Select1st, std::equal_to<long long int>, std::hash<long long int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  108 |                                         for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
      |                                                                                                 ^
/usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1647 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1647:5: note:   template argument deduction/substitution failed:
a.cc:108:97: note:   'std::map<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  108 |                                         for(map<ll,int>::iterator it = ss.begin(); it != ss.end(); it++)
      |