Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <math.h>
using namespace std;
#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define printV(vec) for(int i = 0; i < SZ(vec); i++){cout << vec[i];if (i==SZ(vec)-1){cout<<endl;}else{cout << " ";}}
#define printA(arr,n) for(int i = 0; i < n; i++){cout << arr[i];if (i==n-1){cout<<endl;}else{cout << " ";}}
typedef long long ll;

int main()
{
  int N;
  int C;

  cin >> N >> C;

  int D[C][C];
  forn(i,0,C){
    forn(j,0,C){
      scanf("%d",&D[i][j]);
    }
  }

  int c[N][N];
  forn(i,0,N){
    forn(j,0,N){
      scanf("%d",&c[i][j]);
    }
  }

  ll minsum = LLONG_MAX;
  forn(i,0,C) forn(j,0,C) if (i!=j) forn(k,0,C) if(i!=k && j!=k){
    ll sum = 0;
    forn(a,0,N)forn(b,0,N){
      sum += D[c[a][b] -1][(a+b)%3]
    }
    minsum = min(minsum);
  }
  cout << sum << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:15: error: 'LLONG_MAX' was not declared in this scope
   39 |   ll minsum = LLONG_MAX;
      |               ^~~~~~~~~
a.cc:8:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include <math.h>
  +++ |+#include <climits>
    8 | using namespace std;
a.cc:43:36: error: expected ';' before '}' token
   43 |       sum += D[c[a][b] -1][(a+b)%3]
      |                                    ^
      |                                    ;
   44 |     }
      |     ~                               
a.cc:45:17: error: no matching function for call to 'min(ll&)'
   45 |     minsum = min(minsum);
      |              ~~~^~~~~~~~
In file included 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_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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/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:   template argument deduction/substitution failed:
a.cc:45:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   45 |     minsum = min(minsum);
      |              ~~~^~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
a.cc:47:11: error: 'sum' was not declared in this scope
   47 |   cout << sum << endl;
      |           ^~~