Language: C++

// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int n;
using Panel = array<int, 4>;

Panel rotate(Panel a) {
  tie(a[0], a[1], a[2], a[3]) = make_tuple(a[1], a[2], a[3], a[0]);
  return a;
}

Panel normalize(Panel a) {
  Panel p[4];
  for(int i = 0; i < 4; i++) {
    p[i] = a;
    a = rotate(a);
  }
  return *min_element(p, p + 4);
}

const int N = 400;

int rotcount(Panel a) {
  auto b = a;
  int res = 0;
  for(int i = 0; i < 4; i++) {
    b = rotate(b);
    if(a == b) res++;
  }
  return res;
}

ll fact[10];
ll comb[N + 1][N + 1];

Panel a[N];

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
    a[i] = normalize(a[i]);
  }

  comb[0][0] = 1;
  for(int i = 1; i <= n; i++) for(int j = 0; j <= n; j++) {
    // Pascal's identity
    if(j == 0) {
      comb[i][j] = 1;
      continue;
    }
    comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
  }

  fact[0] = 1;
  for(int i = 1; i <= 9; i++) fact[i] = fact[i-1] * i;

  ll ans = 0;
  for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) {
    dump(i, j);
    for(int rot = 0; rot < 4; rot++) {
      a[i] = rotate(a[i]);
      map<Panel, int> target;
      map<Panel, int> cnt;
      for(int k = 0; k < 4; k++) {
        Panel f{a[i][(k + 1) % 4], a[i][k + 0], a[j][(4 - k) % 4], a[j][(3 - k) % 4]};
        f = normalize(f);
        target[f]++;
        cnt[f] = 0;
      }
      for(int l = 0; l < n; l++) {
        if(l == i) continue;
        if(l == j) continue;
        if(target.count(a[l])) cnt[a[l]]++;
      }

      dump(target);
      dump(cnt);

      int ng = 0;
      ll res = 1;
      for(auto &p : target) {
        Panel pan;
        int tar;
        tie(pan, tar) = p;
        if(cnt[pan] < tar) {ng = 1; break;}
        res *= comb[cnt[pan]][tar] * pow((ll) rotcount(pan), (ll) tar) * fact[tar];
      }
      if(ng) continue;
      ans += res;
    }
  }
  assert(ans % 3 == 0);
  cout << ans/3 << endl;
  return 0;
}


Compiler output:
a.cc:26:20: error: 'a' has incomplete type
   26 | Panel rotate(Panel a) {
      |              ~~~~~~^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:99:12: note: declaration of 'using Panel = struct std::array<int, 4>' {aka 'struct std::array<int, 4>'}
   99 |     struct array;
      |            ^~~~~
a.cc:26:21: error: return type 'using Panel = struct std::array<int, 4>' {aka 'struct std::array<int, 4>'} is incomplete
   26 | Panel rotate(Panel a) {
      |                     ^
a.cc:31:23: error: 'a' has incomplete type
   31 | Panel normalize(Panel a) {
      |                 ~~~~~~^
/usr/include/c++/14/bits/stl_pair.h:99:12: note: declaration of 'using Panel = struct std::array<int, 4>' {aka 'struct std::array<int, 4>'}
   99 |     struct array;
      |            ^~~~~
a.cc:31:24: error: return type 'using Panel = struct std::array<int, 4>' {aka 'struct std::array<int, 4>'} is incomplete
   31 | Panel normalize(Panel a) {
      |                        ^
a.cc: In function 'void normalize(Panel)':
a.cc:32:9: error: elements of array 'Panel p [4]' have incomplete type
   32 |   Panel p[4];
      |         ^
a.cc:32:9: error: storage size of 'p' isn't known
a.cc: At global scope:
a.cc:42:20: error: 'a' has incomplete type
   42 | int rotcount(Panel a) {
      |              ~~~~~~^
/usr/include/c++/14/bits/stl_pair.h:99:12: note: declaration of 'using Panel = struct std::array<int, 4>' {aka 'struct std::array<int, 4>'}
   99 |     struct array;
      |            ^~~~~
a.cc:55:7: error: elements of array 'Panel a [400]' have incomplete type
   55 | Panel a[N];
      |       ^
a.cc:55:7: error: storage size of 'a' isn't known
a.cc: In function 'int main()':
a.cc:80:5: error: 'dump' was not declared in this scope
   80 |     dump(i, j);
      |     ^~~~
a.cc:86:15: error: variable 'Panel f' has initializer but incomplete type
   86 |         Panel f{a[i][(k + 1) % 4], a[i][k + 0], a[j][(4 - k) % 4], a[j][(3 - k) % 4]};
      |               ^
/usr/include/c++/14/bits/stl_pair.h: In instantiation of 'struct std::pair<const std::array<int, 4>, int>':
a.cc:102:21:   required from here
  102 |       for(auto &p : target) {
      |                     ^~~~~~
/usr/include/c++/14/bits/stl_pair.h:290:11: error: 'std::pair<_T1, _T2>::first' has incomplete type
  290 |       _T1 first;                 ///< The first member
      |           ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: declaration of 'struct std::array<int, 4>'
   99 |     struct array;
      |            ^~~~~
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/type_traits: In instantiation of 'struct std::is_copy_assignable<const std::array<int, 4> >':
/usr/include/c++/14/type_traits:183:35:   required by substitution of 'template<class ... _Bn> std::__detail::__first_t<std::integral_constant<bool, true>, typename std::enable_if<(bool)(_Bn::value), void>::type ...> std::__detail::__and_fn(int) [with _Bn = {std::is_copy_assignable<const std::array<int, 4> >, std::is_copy_assignable<int>}]'
  183 |                                       __enable_if_t<bool(_Bn::value)>...>;
      |                                                               ^~~~~
/usr/include/c++/14/type_traits:199:42:   required from 'struct std::__and_<std::is_copy_assignable<const std::array<int, 4> >, std::is_copy_assignable<int> >'
  199 |     : decltype(__detail::__and_fn<_Bn...>(0))
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:922:38:   required from 'struct std::pair<const std::array<int, 4>, int>'
  922 |                                        is_copy_assignable<_T2>>::value,
      |                                                                  ^~~~~
a.cc:102:21:   required from here
  102 |       for(auto &p : target) {
      |                     ^~~~~~
/usr/include/c++/14/type_traits:1237:52: error: static assertion failed: template argument must be a complete class or an unbounded array
 1237 |       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/type_traits:1237:52: note: 'std::__is_complete_or_unbounded<__type_identity<const array<int, 4> > >((std::__type_identity<const std::array<int, 4> >(), std::__type_identity<const std::array<int, 4> >()))' evaluates to false
/usr/include/c++/14/type_traits: In instantiation of 'struct std::is_move_assignable<const std::array<int, 4> >':
/usr/include/c++/14/type_traits:183:35:   required by substitution of 'template<class ... _Bn> std::__detail::__first_t<std::integral_constant<bool, true>, typename std::enable_if<(bool)(_Bn::value), void>::type ...> std::__detail::__and_fn(int) [with _Bn = {std::is_move_assignable<const std::array<int, 4> >, std::is_move_assignable<int>}]'
  183 |                                       __enable_if_t<bool(_Bn::value)>...>;
      |                                                               ^~~~~
/usr/include/c++/14/type_traits:199:42:   required from 'struct std::__and_<std::is_move_assignable<const std::array<int, 4> >, std::is_move_assignable<int> >'
  199 |     : decltype(__detail::__and_fn<_Bn...>(0))
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:932:38:   required from 'struct std::pair<const std::array<int, 4>, int>'
  932 |                                        is_move_assignable<_T2>>::value,
      |                                                                  ^~~~~
a.cc:102:21:   required from here
  102 |       for(auto &p : target) {
      |                     ^~~~~~
/usr/include/c++/14/type_traits:1246:52: error: static assertion failed: template argument must be a complete class or an unbounded array
 1246 |       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/type_traits:1246:52: note: 'std::__is_complete_or_unbounded<__type_identity<const array<int, 4> > >((std::__type_identity<const std::array<int, 4> >(), std::__type_identity<const std::array<int, 4> >()))' evaluates to false
a.cc:103:15: error: aggregate 'Panel pan' has incomplete type and cannot be defined
  103 |         Panel pan;
      |               ^~~