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

#include<cstring> 
#include<iostream> 
#include<algorithm> 
using namespace std; 
#define MAXC 30
#define MAXN 500
#define LL long long 
#define INF INT_MAX 
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
int c,d[MAXC+5][MAXC+5],cnt[3][MAXC+5],S[3][MAXC+5];
int change(int t,int x){
    int ret=0;
    for(int i=1;i<=c;i++)
        ret+=cnt[t][i]*d[i][x];
    return ret;
}
int main(){
    int n=read(),ans=INF;
    c=read();
    for(int i=1;i<=c;i++)
        for(int j=1;j<=c;j++)
            d[i][j]=read();
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cnt[(i+j)%3][read()]++;
    for(int t=0;t<=2;t++)
        for(int i=1;i<=c;i++) 
            S[t][i]=change(t,i);
    for(int i=1;i<=c;i++)
        for(int j=1;j<=c;j++)
            for(int k=1;k<=c;k++)
                if(i!=j&&j!=k&&i!=k){
                    int tmp=S[0][i]+S[1][j]+S[2][k];
                    if(tmp<ans) ans=tmp;
                }
    printf("%d\n",ans);
    return 0;
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: 'INT_MAX' was not declared in this scope
    8 | #define INF INT_MAX
      |             ^~~~~~~
a.cc:24:22: note: in expansion of macro 'INF'
   24 |     int n=read(),ans=INF;
      |                      ^~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<algorithm>
  +++ |+#include <climits>
    4 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int x,y;
int graph[51][51];
vector<int>colors[3];
int visit[51];
int busquedad(int h){
    if(h==3){
        return 0;
    }
    int resp=INT_MAX;
    for(int i=0;i<y;i++){
        if(visit[i]==true) continue;
        int cont=0;
        for(int d=0;d<colors[h].size();d++){
            cont+=graph[colors[h][d]][i];
        }
        visit[i]=true;

        resp=min(resp,cont+busquedad(h+1));
        visit[i]=false;
    }
    return resp;

}
int main(){
    cin>>x>>y;
    for(int i=0;i<y;i++){
        for(int d=0;d<y;d++){
            cin>>graph[i][d];
        }
    }
    for(int i=1;i<=x;i++){
        for(int d=1;d<=x;d++){
            int t;
            cin>>t;
            colors[(i+d)%3].push_back(t-1);
        }
    }


    cout<<busquedad(0)<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int busquedad(int)':
a.cc:13:12: error: reference to 'visit' is ambiguous
   13 |         if(visit[i]==true) continue;
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [51]'
    6 | int visit[51];
      |     ^~~~~
a.cc:18:9: error: reference to 'visit' is ambiguous
   18 |         visit[i]=true;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [51]'
    6 | int visit[51];
      |     ^~~~~
a.cc:21:9: error: reference to 'visit' is ambiguous
   21 |         visit[i]=false;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:6:5: note:                 'int visit [51]'
    6 | int visit[51];
      |     ^~~~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define MAXM 3
#define MAXN 31
#define INF 0x3f3f3f3f
using namespace std;
int N, C;
int grid[MAXN][MAXN], ans[MAXM][MAXN];
ll good = INF;

int main () {
cin >> N >> C;
for (int i=1; i<=C; i++) {
for (int j=1; j<=C; j++) {
cin >> grid[i][j];
}
}
for (int i=1, x; i<=N; i++) {
for (int j=1; j<=N; j++) {
cin >> x;
for (int k=1; k<=C; k++)  ans[(i + j) % 3][k] += x;
}
}
for (int i=1; i<=C; i++) {
for (int j=1; j<=C; j++) {
for (int k=1; k<=C; k++) {
if (i == j || i == k || j == k) continue;
good = min(good, ans[0][i] + ans[1][j] + ans[2][k]);
}
}
}
cout << good << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:11: error: no matching function for call to 'min(long long int&, int)'
   28 | good = min(good, ans[0][i] + ans[1][j] + ans[2][k]);
      |        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/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:   template argument deduction/substitution failed:
a.cc:28:11: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 | good = min(good, ans[0][i] + ans[1][j] + ans[2][k]);
      |        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:28:11: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 | good = min(good, ans[0][i] + ans[1][j] + ans[2][k]);
      |        ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int h[50005];
inline int dfs(int l,int r)
{
	if(l>r)
		return 0;
    int ans=0,ml=l,mn=0x3f3f3;
    for(int i=l;i<=r;i++)
		mn=min(minn,h[i]);
    for(int i=l;i<=r;i++)
		h[i]-=mn;
    ans+=mn;
    for(int i=l;i<=r;i++)
    {
        if(h[i]==0)
        {
            ans+=dfs(ml,i-1);
            ml=i+1;
        }
        if(i==r)
        {
            if(h[i]>0)
				ans+=dfs(ml,r);
            else
				ans+=dfs(ml,r-1);
        }
    }
    return min(ans,r-l+1);
}
int main()
{
    int n;
    scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	int ans=dfs(1,n);
	printf("%d\n",ans);
}

Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:12:24: error: 'minn' was not declared in this scope; did you mean 'mn'?
   12 |                 mn=min(minn,h[i]);
      |                        ^~~~
      |                        mn
Language: C

# include < cstdio >
# define rep (i , n ) for ( int i =0; i < n ; i ++)
int N ,C , X ;
int D [30][39];
int t [3][30];
int main ()
{
scanf ("% d % d " ,&N ,& C );
rep (i , C ) rep (j , C ) scanf ("% d " ,& D [ i ][ j ]);
rep (i , N ) rep (j , N ) scanf ("% d " ,& X ) , t [( i + j )%3][ X -1]++;
int res =1 < <30;
rep (i , C ) 
{
int tt =0;
rep (l , C ) tt += D [ l ][ i ]* t [0][ l ];
rep (l , C ) tt += D [ l ][ i ]* t [1][ l ];
rep (l , C ) tt += D [ l ][ i ]* t [2][ l ];
if ( tt < res ) res = tt ;
}
printf ("% d \ n " , res );
}

Compiler output:
main.c:1:11: fatal error:  cstdio : No such file or directory
    1 | # include < cstdio >
      |           ^~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n,c,x;
int d[30][39];
int t[3][30];
int main ()
{
	int tmp,ans=1<<30,i,j,k,l;
	scanf ("%d%d",&n,&c);
	for(i=0,i<c;i++)
		for(j=0,j<c;j++)
			scanf("%d",&d[i][j]);
	for(i=0,i<n;i++)
	{
		for(j=0,j<b;j++)
		{
			scanf("%d",&x);
			t[(i+j)%3][x-1]++;
		}
	}
	for(i=0,i<c;i++)
	{
		for(j=0,j<c;j++)
		{
			if(i!=j)
			{
				for(k=0;k<c;k++)
				{
					if(i!=k&&j!=k)
					{
						tmp=0;
						for(l=0;l<c;l++)
							tt+=d[l][i]*t[0][l];
						for(l=0;l<c;l++)
							tt+=d[l][j]*t[1][l];
						for(l=0;l<c;l++)
							tt+=d[l][k]*t[2][l];
						if(tt<ans)
							ans=tt;
					}
				}
			}
		}
	}
	printf ("%d",ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:24: error: expected ';' before ')' token
   10 |         for(i=0,i<c;i++)
      |                        ^
      |                        ;
a.cc:11:32: error: expected ';' before ')' token
   11 |                 for(j=0,j<c;j++)
      |                                ^
      |                                ;
a.cc:13:24: error: expected ';' before ')' token
   13 |         for(i=0,i<n;i++)
      |                        ^
      |                        ;
a.cc:15:27: error: 'b' was not declared in this scope
   15 |                 for(j=0,j<b;j++)
      |                           ^
a.cc:15:32: error: expected ';' before ')' token
   15 |                 for(j=0,j<b;j++)
      |                                ^
      |                                ;
a.cc:21:24: error: expected ';' before ')' token
   21 |         for(i=0,i<c;i++)
      |                        ^
      |                        ;
a.cc:23:32: error: expected ';' before ')' token
   23 |                 for(j=0,j<c;j++)
      |                                ^
      |                                ;
a.cc:33:57: error: 'tt' was not declared in this scope; did you mean 'tm'?
   33 |                                                         tt+=d[l][i]*t[0][l];
      |                                                         ^~
      |                                                         tm
a.cc:35:57: error: 'tt' was not declared in this scope; did you mean 'tm'?
   35 |                                                         tt+=d[l][j]*t[1][l];
      |                                                         ^~
      |                                                         tm
a.cc:37:57: error: 'tt' was not declared in this scope; did you mean 'tm'?
   37 |                                                         tt+=d[l][k]*t[2][l];
      |                                                         ^~
      |                                                         tm
a.cc:38:52: error: 'tt' was not declared in this scope; did you mean 'tm'?
   38 |                                                 if(tt<ans)
      |                                                    ^~
      |                                                    tm
Language: C++

#include <iostream>
#include <string.h>
using namespace std;

#define NC 30

int ca[NC*NC];
int ta[3][NC] = {0};



int main() {
	int n, c;
	int x;
	int min = INT_MAX;

	cin >> n >> c;

	for( int i = 0; i < c; i++) {
		for ( int j = 0; j < c; j++ ) {
			cin >> ca[i*c+j];
		}
	}

	for( int i = 0; i < n; i++) {
		for ( int j = 0; j < n; j++ ) {
			cin >> x;
			ta[(i+j)%3][x-1]++;
		}
	}

	for( int i = 0; i < c; i++ ) {
		for( int j = 0; j < c; j++ ) {
			for( int k = 0; k < c; k++ ) {
				if( i != j && j != k && k != i ) {
					int sum = 0;
					for( int l = 0; l < c; l++ ) {
						sum += ta[0][l]*ca[l*c+i];
						sum += ta[1][l]*ca[l*c+j];
						sum += ta[2][l]*ca[l*c+k];
					}
					if( sum < min ) {
						min = sum;
					}
				}
			}
		}
	}

	cout << min << "\n";

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:19: error: 'INT_MAX' was not declared in this scope
   15 |         int min = INT_MAX;
      |                   ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <string.h>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

# include <iostream>
# include <algorithm>

using namespace std;

const int maxm = 1000 + 10;
const int maxn = 30 + 10;
int n, c, d[maxn][maxn], t[4][maxn], x, y, z, ans;

int main() {
	cin >> n >> c;
	ans = INT32_Max;    
	int i, j, k, l;
	for (i = 1; i <= c; i++) {    
		for (j = 1; j <= c; j++) {
			cin >> d[i][j];
		}
	}
	for (i = 1; i <= n; i++) {    
		for (j = 1; j <= n; j++) {
			cin >> x;
			t[(i + j) % 3][x]++;    
		}
	}
	for (i = 1; i <= c; i++) {    
		x = 0;
		for (j = 1; j <= c; j++) {
			x += t[0][j] * d[j][i];
		}
		for (j = 1; j <= c; j++) {    //枚举余数为1统一变成颜色j,其代价为y 
			if (j == i) continue;    //不同余数的颜色不能相同 
			y = 0;
			for (k = 1; k <= c; k++) {
				y += t[1][k] * d[k][j];
			}
			for (k = 1; k <= c; k++) {    //枚举余数为2统一变成颜色k,其代价为z 
				if (k == j || k == i) continue;    //不同余数的颜色不同 
				z = 0;
				for (l = 1; l <= c; l++) {
					z += t[2][l] * d[l][k];
				}
				if (ans>x + y + z) {    
					ans = x + y + z;
				}
			}
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: 'INT32_Max' was not declared in this scope
   12 |         ans = INT32_Max;
      |               ^~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
typedef unsigned long long ull;
using namespace std;

int main(){
	int N, C;
	cin >> N >> C;
	vector<vector<int>> D(C);
	vector<int> c1;
	vector<int> c2;
	vector<int> c3;

	for(int i=0;i<C;i++){
		vector<int> v(C);
		for(int j=0;j<C;j++)
			cin >> v.at(j);
		D.at(i)=v;
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			int c;
			cin >> c;
			switch((i+j)%3){
				case 0:
				c1.push_back(c);
				break;
				case 1:
				c2.push_back(c);
				break;
				case 2:
				c3.push_back(c);
				break;
			}
		}
	}
	
	
	int min = INT_MAX;	
	cout << min << endl;

	for(int i=0;i<C;i++){
		int sum1=0;
		for(auto it = c1.begin();it!=c1.end();++it)
			sum1+=D.at(*it-1).at(i);
		if(suml>min)
			continue;

		for(int j=0;j<C;j++){
			if(i==j)
				continue;
			int sum2=0;
			for(auto it = c2.begin();it!=c2.end();++it){
				sum2+=D.at(*it-1).at(j);
			}
			if(suml+sum2>min)
				continue;
			
			for(int k=0;k<C;k++){
				if(i==k||j==k)
					continue;
				int sum3=0;
				for(auto it = c3.begin();it!=c3.end();++it){
					sum3+=D.at(*it-1).at(k);
				}
				if(sum1+sum2+sum3<min)
					min=sum1+sum2+sum3;
			}
		}
	}
	cout << min << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:20: error: 'suml' was not declared in this scope; did you mean 'sum1'?
   48 |                 if(suml>min)
      |                    ^~~~
      |                    sum1
a.cc:58:28: error: 'suml' was not declared in this scope; did you mean 'sum2'?
   58 |                         if(suml+sum2>min)
      |                            ^~~~
      |                            sum2
Language: C++

#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
signed main()
{
	ios::sync_with_stdio(false);
	int n, c;
	cin >> n >> c;
	int a[3][34];
	int d[34][34];
	for (int i = 0; i < 34;i++){
		a[0][i] = 0; a[1][i] = 0; a[2][i] = 0;
	}
	for (int i = 1; i <= c; i++) {
		for (int j = 1; j <= c; j++) {
			cin >> d[i][j];
		}
	}
	int tmp;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> tmp;
			for (int k = 1; k <= c; k++) {
				a[(i + j) % 3][k] += d[tmp][k];
			}
		}
	}
	int mini = INT_MAX;
	for (int i = 1; i <= c; i++) {
		for (int j = 1; j <= c; j++) {
			if (i == j)continue;
			for (int k = 1; k <= c; k++) {
				if (i == k || j == k)continue;
				mini = min(mini, a[0][i] + a[1][j] + a[2][k]);
			}
		}
	}
	cout << mini;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:20: error: 'INT_MAX' was not declared in this scope
   32 |         int mini = INT_MAX;
      |                    ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <vector>
  +++ |+#include <climits>
    7 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

using namespace std;

int main() {
    
    int n,c;
    cin >> n >> c;
    
    vector<vector<int>> d(c, vector<int>(c));
    
    FOR(i, 0, c){
        FOR(j, 0, c){
            cin >> d[i][j]; //色をiからjに変えるコスト
        }
    }
    
    vector<vector<int>> x(n, vector<int>(n)); // x：c
    vector<vector<int>> t(3, vector<int>(30,0)); // t[(i+j)%3][a]： あまりが(i+j)%3のときの色aの個数
    
    FOR(i, 0, n){
        FOR(j, 0, n){
            cin >> x[i][j];
            t[(i+j)%3][x[i][j]-1]++;
        }
    }
    
    int ans=1<<30; //int型でとりあえず大きい数字
    
    FOR(i, 0, c){
        FOR(j, 0, c){
            if(i!=j){
                FOR(k, 0, c){
                    if(((j!=k)&&(k!=i)){
                        FOR(l, 0, c){
                            int tmp=0;
                            tmp += d[l][i]*t[0][l]; //あまり0のマス全てのの色をlからiに変えたときのコスト
                            tmp += d[l][j]*t[1][l]; //あまり1のマス全てのの色をlからjに変えたときのコスト
                            tmp += d[l][k]*t[2][l]; //あまり2のマス全てのの色をlからkに変えたときのコスト
                            if(tmp<ans){
                                ans=tmp;
                            }
                        }
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:40: error: expected ')' before '{' token
   48 |                     if(((j!=k)&&(k!=i)){
      |                       ~                ^
      |                                        )
a.cc:59:17: error: expected primary-expression before '}' token
   59 |                 }
      |                 ^
Language: C++

#include<cstdio>
#include<algorithm>
#include<cstring>
#define MAXN 500
int n,c,x,y,z,ans=INT_MAX;
int d[MAXN+5][MAXN+5],C[MAXN+5][MAXN+5],t[4][MAXN+5];
inline void BaoSo()
{
	for(int i=1;i<=c;i++)
	{ 
        x=0; 
        for(int j=1;j<=c;j++)
		{
            x+=t[0][j]*d[j][i];
        }
        
        for(int j=1;j<=c;j++)
		{   
            if(j==i) continue;    
            y=0;
            for(int k=1;k<=c;k++)
			{
                y+=t[1][k]*d[k][j];
            }
            
            for(int k=1;k<=c;k++)
			{  
                if(k==j || k==i) continue;   
                z=0;
                for(int l=1;l<=c;l++)
				{
                    z+=t[2][l]*d[l][k];
                }
                if(ans>x+y+z)
				{   
                    ans=x+y+z;
                }
            }
        }
    } 
    printf("%d",ans);
} 
inline void Init()
{
	scanf("%d %d",&n,&c);
	
	for(int i=1;i<=c;i++)
		for(int j=1;j<=c;j++)
		{
			scanf("%d",&d[i][j]);
		}
		
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&C[i][j]);
			t[(i+j)%3][C[i][j]]++;
		}
	BaoSo();			
}
int main()
{
	Init();
}

Compiler output:
a.cc:5:19: error: 'INT_MAX' was not declared in this scope
    5 | int n,c,x,y,z,ans=INT_MAX;
      |                   ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<cstring>
  +++ |+#include <climits>
    4 | #define MAXN 500
Language: C++

#include<cstdio>
#include<algorithm>
#include<cstring>
#define MAXN 500
int n,c,x,y,z,ans=INT_MAX;
int d[MAXN+5][MAXN+5],C[MAXN+5][MAXN+5],t[MAXN+5][MAXN+5];
void BaoSo()
{
	for(int i=1;i<=c;i++)
	{ 
        x=0; 
        for(int j=1;j<=c;j++)
		{
            x+=t[0][j]*d[j][i];
        }
        
        for(int j=1;j<=c;j++)
		{   
            if(j==i) continue;    
            y=0;
            for(int k=1;k<=c;k++)
			{
                y+=t[1][k]*d[k][j];
            }
            
            for(int k=1;k<=c;k++)
			{  
                if(k==j || k==i) continue;   
                z=0;
                for(int l=1;l<=c;l++)
				{
                    z+=t[2][l]*d[l][k];
                }
                if(ans>x+y+z)
				{   
                    ans=x+y+z;
                }
            }
        }
    } 
    printf("%d",ans);
} 
void Init()
{
	scanf("%d %d",&n,&c);
	
	for(int i=1;i<=c;i++)
		for(int j=1;j<=c;j++)
		{
			scanf("%d",&d[i][j]);
		}
		
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&C[i][j]);
			t[(i+j)%3][C[i][j]]++;
		}
	BaoSo();			
}
int main()
{
	Init();
}

Compiler output:
a.cc:5:19: error: 'INT_MAX' was not declared in this scope
    5 | int n,c,x,y,z,ans=INT_MAX;
      |                   ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<cstring>
  +++ |+#include <climits>
    4 | #define MAXN 500
Language: C++

from itertools import product
from collections import Counter

n, c = map(int, input().split())
color_costs = [map(int, input().split()) for _ in range(c)]
matrix = [list(map(int, input().split())) for _ in range(n)]

colord = {(i, j):cost 
               for i, row in enumerate(color_costs)
               for j, cost in enumerate(row)}

color_counts = []
for n in range(3):
  counter = Counter(c-1 for i, row in enumerate(matrix) 
                                       for j, c in enumerate(row) 
                                       if (i+j)%3==n)
  color_counts.append(counter)

cc = [[(color, sum(colord[cellcolor, color]*n for cellcolor, n in color_count.items()))
                                                                    for color in range(c)]
                                                                    for color_count in color_counts]
 
dd = [sorted(xs, key=lambda x:x[1])[:3] for xs in cc]
ee = (a[1]+b[1]+c[1] for a, b, c in product(*dd) if len(set((a[0], b[0], c[0]))) == 3)
print(min(ee))

Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from itertools import product
      | ^~~~
a.cc:12:1: error: 'color_counts' does not name a type
   12 | color_counts = []
      | ^~~~~~~~~~~~
Language: Java

import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;


import java.util.HashSet;
import java.util.Collections;


public class Main{
    static Scanner sc=new Scanner(System.in);
    static int N=sc.nextInt();
    static int C=sc.nextInt();
    static int[][]D=new int[C][C];
    static int[][]c=new int[N][N];
    public static void main(String[] args){
        for(int i=0;i<C;i++){
            for(int j=0;j<C;j++){
                D[i][j]=sc.nextInt();
            }
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                c[i][j]=sc.nextInt()-1;
            }
        }
        int[][]kazu=new int[3][50];
        for(int i=0;i<3;i++){
            for(int j=0;j<C;j++){
                kazu[i][j]=0;
            }
        }
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                kazu[(i+j)%3][c[i][j]]++;
            }
        }
        int min=334334;
        for(int i=0;i<C;i++){
            for(int j=0;j<C;j++){
                for(int k=0;k<C;k++){
                    if((i!=j)&&(j!=k)&&(i!=k)){
                        int sum=0;
                        for(int l=0;l<C;l++){
                            sum+=D[l][i]*kazu[0][l];
                            sum+=D[l][j]*kazu[1][l];
                            sum+=D[l][k]*kazu[2][l];
                        }
                        
                        
                        
                    }min=Math.min(min,sum);
                }
            }
        }
        System.out.println(min);


        
        

            

        
        
        
        
            

        
        

    }
    }


Compiler output:
Main.java:53: error: cannot find symbol
                    }min=Math.min(min,sum);
                                      ^
  symbol:   variable sum
  location: class Main
1 error
Language: C++

#include"stdafx.h"
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };

int D[31][39];
int cnt[3][31];
int main() {
	int N, C;

	
	ll cost = INF;
	cin >> N >> C;
	REP(i,C) {
		REP(j,C) {
			cin >> D[i][j];
		}
	}
	REP(i,C) {
		REP(j,C) {
			int c;
			cin >> c;
			if ((i + j) % 3 == 0)cnt[0][c-1] += 1;
			if ((i + j) % 3 == 1)cnt[1][c-1] += 1;
			if ((i + j) % 3 == 2)cnt[2][c-1] += 1;
		}
	}

	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				if (i == j || j == k || k == i)continue;
				ll cost2 = 0;
				REP(l, 3) {
					REP(m,C) {
						if (l == 0)cost2 += cnt[0][m] * D[m][i];
						if (l == 1)cost2 += cnt[1][m] * D[m][j];
						if (l == 2)cost2 += cnt[2][m] * D[m][k];
					}
				}
				if (cost2 < cost)cost = cost2;
			}
		}
	}
	cout << cost << endl;
}


Compiler output:
a.cc:1:9: fatal error: stdafx.h: No such file or directory
    1 | #include"stdafx.h"
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int sum[27003];
int D[30][30], c[500][500];
int chenge[500][500][30];
int main(){
    int N, C, sum, ans = 250000007;
    cin >> N >> C;

    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            scanf("%d",&D[i][j]);
        }
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            scanf("%d",&c[i][j]);
            c[i][j]--;
            for(int k=0; k<C; k++){
                chenge[i][j][k] = D[c[i][j]][k];
            }
        }
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            int p=0;
            for(int k=0; k<C; k++){
                for(int l=0; l<C; l++){
                    if(k==l)l++;
                    if(l==C)break;
                    for(int m=0; m<C; m++){
                        if(m==k || m==l)m++;
                        if(m==k || m==l)m++;
                        if(m>=C)break;
                        if((i+j)%3==0){
                            sum[p] += chenge[i][j][k];
                        }else if((i+j)%3==1){
                            sum[p] += chenge[i][j][l];
                        }else{
                            sum[p] += chenge[i][j][m];
                        }
                        p++;
                    }
                }
            }
        }
    }
    for(int i=0; i<C*(C-1)*(C-2); i++){
        if(sum[i]<ans)ans=sum[i];
    }
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:32: error: invalid types 'int[int]' for array subscript
   40 |                             sum[p] += chenge[i][j][k];
      |                                ^
a.cc:42:32: error: invalid types 'int[int]' for array subscript
   42 |                             sum[p] += chenge[i][j][l];
      |                                ^
a.cc:44:32: error: invalid types 'int[int]' for array subscript
   44 |                             sum[p] += chenge[i][j][m];
      |                                ^
a.cc:53:15: error: invalid types 'int[int]' for array subscript
   53 |         if(sum[i]<ans)ans=sum[i];
      |               ^
a.cc:53:30: error: invalid types 'int[int]' for array subscript
   53 |         if(sum[i]<ans)ans=sum[i];
      |                              ^
Language: C++

#include <vector>
using namespace std;
typedef long long ll;
vector<ll> vec[3];
ll n, c, d[35][35], f[550][550], a, res1 = 10000000000, k[3][35];
int main(void){
    // Your code here!
    cin >> n >> c;
    for (ll i = 1; i <= c; i++) {
        for (ll j = 1; j <= c; j++) {
            cin >> d[i][j];
        }
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= n; j++) {
            cin >> a;
            vec[(i + j) % 3].push_back(a);
        }
    }
    for (ll i = 1; i <= c; i++) {
        for (ll j = 0; j != vec[1].size(); j++) {
            k[1][i] += d[vec[1][j]][i];
        }
    }
    for (ll i = 1; i <= c; i++) {
        for (ll j = 0; j != vec[2].size(); j++) {
            k[2][i] += d[vec[2][j]][i];
        }
    }
    for (ll i = 1; i <= c; i++) {
        for (ll j = 0; j != vec[0].size(); j++) {
            k[0][i] += d[vec[0][j]][i];
        }
    }
    for (ll i = 1; i <= c; i++) {
        for (ll j = 1; j <= c; j++) {
            for (ll l = 1; l <= c; l++) {
                if (i == j || j == l || l == i) continue;
                res1 = min(res1, k[0][i] + k[1][j] + k[2][l]);
            }
        }
    }
    cout << res1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     cin >> n >> c;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <vector>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:43:5: error: 'cout' was not declared in this scope
   43 |     cout << res1 << endl;
      |     ^~~~
a.cc:43:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:43:21: error: 'endl' was not declared in this scope
   43 |     cout << res1 << endl;
      |                     ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <vector>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;

int d[30][30], color[500][500];
int exa[3][30];
int main() {
  int n, c;
  scanf("%d%d", &n, &c);
  for (int i = 0; i < c; i++)
    for (int j = 0; j < c; j++)
      scanf("%d", &d[i][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      scanf("%d", &color[i][j]);
  int res = INT_MAX;
  for (int cx = 0; cx < c; cx++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        exa[(i + j) % 3][cx] += d[color[i][j] - 1][cx];
      }
    }
  }
  for (int c1 = 0; c1 < c; c1++) {
    for (int c2 = 0; c2 < c; c2++) {
      for (int c3 = 0; c3 < c; c3++) {
        if (c1 == c2 || c2 == c3 || c3 == c1)
          continue;
        for (int i = 0; i < 3; i++) {
          for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
              if (i == j || j == k || k == i)
                continue;
              res = min(res, exa[i][c1] + exa[j][c2] + exa[k][c3]);
            }
          }
        }
      }
    }
  }
  printf("%d\n", res);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: reference to 'exa' is ambiguous
   19 |         exa[(i + j) % 3][cx] += d[color[i][j] - 1][cx];
      |         ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:66,
                 from a.cc:1:
/usr/include/c++/14/ratio:633:9: note: candidates are: 'using std::exa = struct std::ratio<1000000000000000000, 1>'
  633 |   using exa    = ratio<      1000000000000000000,                         1>;
      |         ^~~
a.cc:5:5: note:                 'int exa [3][30]'
    5 | int exa[3][30];
      |     ^~~
a.cc:33:30: error: reference to 'exa' is ambiguous
   33 |               res = min(res, exa[i][c1] + exa[j][c2] + exa[k][c3]);
      |                              ^~~
/usr/include/c++/14/ratio:633:9: note: candidates are: 'using std::exa = struct std::ratio<1000000000000000000, 1>'
  633 |   using exa    = ratio<      1000000000000000000,                         1>;
      |         ^~~
a.cc:5:5: note:                 'int exa [3][30]'
    5 | int exa[3][30];
      |     ^~~
a.cc:33:43: error: reference to 'exa' is ambiguous
   33 |               res = min(res, exa[i][c1] + exa[j][c2] + exa[k][c3]);
      |                                           ^~~
/usr/include/c++/14/ratio:633:9: note: candidates are: 'using std::exa = struct std::ratio<1000000000000000000, 1>'
  633 |   using exa    = ratio<      1000000000000000000,                         1>;
      |         ^~~
a.cc:5:5: note:                 'int exa [3][30]'
    5 | int exa[3][30];
      |     ^~~
a.cc:33:56: error: reference to 'exa' is ambiguous
   33 |               res = min(res, exa[i][c1] + exa[j][c2] + exa[k][c3]);
      |                                                        ^~~
/usr/include/c++/14/ratio:633:9: note: candidates are: 'using std::exa = struct std::ratio<1000000000000000000, 1>'
  633 |   using exa    = ratio<      1000000000000000000,                         1>;
      |         ^~~
a.cc:5:5: note:                 'int exa [3][30]'
    5 | int exa[3][30];
      |     ^~~
Language: C++

#include<cstdio>
static const int kMaxVertices = 30;
static const int kInfinity = 1010;
static int Adjacency_matrix[kMaxVertices][kMaxVertices];
int A[3][30];

void InitializeCostMatrix(int nmbr_of_rows, int nmbr_of_columns){
	for (int row = 0; row < nmbr_of_rows; ++row) {
		for (int column = 0; column < nmbr_of_columns; ++column)
			Adjacency_matrix[row][column] = kInfinity;
	}
}

void Dijkstra(int n, int id){
	bool has_not_been_added[kMaxVertices];
	int lowest_cost_route[kMaxVertices];
	for (int i = 0; i < n; ++i)	{
		has_not_been_added[i] = true;
		lowest_cost_route[i] = kInfinity;
	}
	lowest_cost_route[id] = 0;

	while(true){
		int mincost = kInfinity;
		int vertex_to_add;
		for (int i = 0; i < n; ++i)	{
			if(has_not_been_added[i] && lowest_cost_route[i] < mincost){
				mincost = lowest_cost_route[i];
				vertex_to_add = i;
			}
		}

		if(mincost == kInfinity)
			break;

		has_not_been_added[vertex_to_add] = false;
		int vertex_added = vertex_to_add;

		for (int i = 0; i < n; ++i)	{
			if(has_not_been_added[i] && lowest_cost_route[vertex_added] + Adjacency_matrix[vertex_added][i] < lowest_cost_route[i]) {
				lowest_cost_route[i] = lowest_cost_route[vertex_added] + Adjacency_matrix[vertex_added][i];
			}
		}
		for (int i = 0; i < C; ++i) Adjacency_matrix[id][i] = lowest_cost_route[i];
	}
}

int main() {
	int N, C;
	scanf("%d %d", &N, &C);
	for (int i = 0; i < C; ++i){
		for (int j = 0; j < C; ++j) scanf("%d", &Adjacency_matrix[i][j]);
	}
	for (int i = 0; i < C; ++i) Dijkstra(N, i);
	for (int i = 1; i <= N; ++i){
		for (int j = 1; j <= N; ++j){
			int tmp;
			scanf("%d", &tmp);
			A[(i + j) % 3][tmp - 1]++;
		}
	}
	int answer = 250000000;
	for (int i = 0; i < C; ++i)
	{
		for (int j = 0; j < C; ++j)
		{
			for (int k = 0; k < C; ++k)
			{
				if(i != j && j != k && k != i){
					int candidate = 0;
					for (int l = 0; l < 3; ++l){
						for (int m = 0; m < C; ++m) candidate += Adjacency_matrix[m][i]*A[l][m];
					}
					if(candidate < answer) answer = candidate;
				}
			}
		}
	}
	printf("%d\n", answer);
	return 0;
}

Compiler output:
a.cc: In function 'void Dijkstra(int, int)':
a.cc:44:37: error: 'C' was not declared in this scope
   44 |                 for (int i = 0; i < C; ++i) Adjacency_matrix[id][i] = lowest_cost_route[i];
      |                                     ^
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define INIT 1000000
using namespace std;

int N, C;
int c[300000] = {};
// %3 ==(0,1,2)番目をすべてC色にしたときのコスト
int cost[3][31] = {};
int D[31][31] = {};

void func(int _num, int _color)
{
	int sum = 0;
	FOR(i, 1, N)FOR(j, 1, N)
	{
		if ((i + j) % 3 != _num)continue;
		sum += D[c[i*N + j]][_color];
	}
	cost[_num][_color] = sum;
}

int main()
{
	cin >> N >> C;
	FOR(i, 1, C)FOR(j, 1, C)cin >> D[i][j];
	FOR(i, 1, N)FOR(j, 1, N)cin >> c[i*N+j];

	REP(k, 1, N)
	{
		REP(i, 1, N)
		{
			if (i == k)continue;
			REP(j, 1, N)
			{
				if (i == j || k == j)continue;
				D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}
	

	REP(i, 3)
	{
		FOR(j, 1, C)
		{
			func(i, j);
		}
	}



	int x = 99999999;
	FOR(i, 1, C)
	{
		FOR(j, 1, C)
		{
			if (i == j)continue;
			FOR(k, 1, C)
			{
				if (i == k || k == j)continue;

				if (x > cost[0][i] + cost[1][j] + cost[2][k])
				{
					x = cost[0][i] + cost[1][j] + cost[2][k];
				}
			}
		}
	}
	cout << x << endl;
	return 0;
}

Compiler output:
a.cc:32:20: error: macro "REP" passed 3 arguments, but takes just 2
   32 |         REP(k, 1, N)
      |                    ^
a.cc:4:9: note: macro "REP" defined here
    4 | #define REP(i,n) for(int i=0;i<(n);i++)
      |         ^~~
a.cc:34:28: error: macro "REP" passed 3 arguments, but takes just 2
   34 |                 REP(i, 1, N)
      |                            ^
a.cc:4:9: note: macro "REP" defined here
    4 | #define REP(i,n) for(int i=0;i<(n);i++)
      |         ^~~
a.cc:37:36: error: macro "REP" passed 3 arguments, but takes just 2
   37 |                         REP(j, 1, N)
      |                                    ^
a.cc:4:9: note: macro "REP" defined here
    4 | #define REP(i,n) for(int i=0;i<(n);i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:32:9: error: 'REP' was not declared in this scope
   32 |         REP(k, 1, N)
      |         ^~~
Language: C++

#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<vector>

#define ll long long
#define ull unsigned long long

using namespace std;
int main(void) {

	ll N = 0,C = 0;
	ll D[35][35] = { 0 };
	ll CC[35][3] = { 0 };
	ll CD[35][3] = { 0 };
	ll ans = LLONG_MAX;

	scanf("%lld%lld", &N,&C);
	for (ll i = 1; i <= C; i++) {
		for (ll j = 1; j <= C; j++) {
			scanf("%lld", &D[i][j]);
		}
	}

	for (ll i = 1; i <= N; i++) {
		for (ll j = 1; j <= N; j++) {
			ll a = 0;
			scanf("%lld", &a);
			CC[a][(i + j) % 3]++;
		}
	}

	for (ll i = 0; i <= 2; i++) {
		for (ll j = 1; j <= C; j++) {
			for (ll k = 1; k <= C; k++) {
				CD[j][i] += D[k][j] * CC[k][i];
			}
		}
	}
	
	for (ll i = 1; i <= C; i++) {
		for (ll j = 1; j <= C; j++) {
			for (ll k = 1; k <= C; k++) {
				if (i == j || j == k || i == k)
					continue;
				ans = min(ans, CD[i][0] + CD[j][1] + CD[k][2]);
			}
		}
	}
	printf("%lld\n", ans);

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:21:18: error: 'LLONG_MAX' was not declared in this scope
   21 |         ll ans = LLONG_MAX;
      |                  ^~~~~~~~~
a.cc:8:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include<stack>
  +++ |+#include <climits>
    8 | #include<string>
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define INIT 1000000
using namespace std;

int N, C;
int c[300000] = {};
// %3 ==(0,1,2)番目をすべてC色にしたときのコスト
int cost[3][31] = {};
int D[31][31] = {};

void func(int _num, int _color)
{
	int sum = 0;
	FOR(i, 1, N)FOR(j, 1, N)
	{
		if ((i + j) % 3 != _num)continue;
		sum += D[c[i*N + j]][_color];
	}
	cost[_num][_color] = sum;
}

int main()
{
	cin >> N >> C;
	FOR(i, 1, C)FOR(j, 1, C)cin >> D[i][j];
	FOR(i, 1, N)FOR(j, 1, N)cin >> c[i*N+j];
	REP(k, 1, N)
	{
		REP(i, 1, N)
		{
			REP(j, 1, N)
			{
				D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}
	

	REP(i, 3)
	{
		FOR(j, 1, C)
		{
			func(i, j);
		}
	}


	int x = 99999999;
	FOR(i, 1, C)
	{
		FOR(j, 1, C)
		{
			if (i == j)continue;
			FOR(k, 1, C)
			{
				if (i == k || k == j)continue;

				if (x > cost[0][i] + cost[1][j] + cost[2][k])
				{
					x = cost[0][i] + cost[1][j] + cost[2][k];
				}
			}
		}
	}
	cout << x << endl;
	return 0;
}

Compiler output:
a.cc:31:20: error: macro "REP" passed 3 arguments, but takes just 2
   31 |         REP(k, 1, N)
      |                    ^
a.cc:4:9: note: macro "REP" defined here
    4 | #define REP(i,n) for(int i=0;i<(n);i++)
      |         ^~~
a.cc:33:28: error: macro "REP" passed 3 arguments, but takes just 2
   33 |                 REP(i, 1, N)
      |                            ^
a.cc:4:9: note: macro "REP" defined here
    4 | #define REP(i,n) for(int i=0;i<(n);i++)
      |         ^~~
a.cc:35:36: error: macro "REP" passed 3 arguments, but takes just 2
   35 |                         REP(j, 1, N)
      |                                    ^
a.cc:4:9: note: macro "REP" defined here
    4 | #define REP(i,n) for(int i=0;i<(n);i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:31:9: error: 'REP' was not declared in this scope
   31 |         REP(k, 1, N)
      |         ^~~
Language: C++

//
//  main.cpp
//  codeforces
//
//  Created by cfhaiteeh on 29/5/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//
 #include <cstdint>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define  LL long long

using namespace  std;
int n,c;
int ci[35][35];
int ai[567][567];
LL sum[5][35];
void init(){
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=c;i++){
        for(int j=1;j<=c;j++){
            scanf("%d",&ci[i][j]);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int t=(i+j)%3;
            int d;
            scanf("%d",&d);
            for(int k=1;k<=c;k++){
                sum[t][k]+=ci[d][k];
            }
        }
    }
}

LL ans;
bool vis[35];
void DFS(int now,LL sum1){
    if(now==3){
      //  cout<<"ojbk"<<endl;
        ans=min(ans,sum1);
        return;
    }
    for(int i=1;i<=c;i++){
        if(!vis[i]){
            vis[i]=1;
            DFS(now+1, sum1+sum[now][i]);
            vis[i]=0;
        }
    }
}
void play(){
    memset(vis,0,sizeof(vis));
    ans=LONG_MAX;
    DFS(0,0);
}
void pri(){
  printf("%lld\n",ans);
}

int main() {
    
    while(scanf("%d%d",&n,&c)!=EOF){
        init();
        play();
        pri();
    }
    return 0;
}


Compiler output:
a.cc: In function 'void play()':
a.cc:62:9: error: 'LONG_MAX' was not declared in this scope
   62 |     ans=LONG_MAX;
      |         ^~~~~~~~
a.cc:17:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   16 | #include <queue>
  +++ |+#include <climits>
   17 | #include <vector>
Language: C++

//
//  main.cpp
//  codeforces
//
//  Created by cfhaiteeh on 29/5/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#define  LL long long

using namespace  std;
int n,c;
int ci[35][35];
int ai[567][567];
LL sum[5][35];
void init(){
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=c;i++){
        for(int j=1;j<=c;j++){
            scanf("%d",&ci[i][j]);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int t=(i+j)%3;
            int d;
            scanf("%d",&d);
            for(int k=1;k<=c;k++){
                sum[t][k]+=ci[d][k];
            }
        }
    }
}

LL ans;
bool vis[35];
void DFS(int now,LL sum1){
    if(now==3){
      //  cout<<"ojbk"<<endl;
        ans=min(ans,sum1);
        return;
    }
    for(int i=1;i<=c;i++){
        if(!vis[i]){
            vis[i]=1;
            DFS(now+1, sum1+sum[now][i]);
            vis[i]=0;
        }
    }
}
void play(){
    memset(vis,0,sizeof(vis));
    ans=LONG_MAX;
    DFS(0,0);
}
void pri(){
  printf("%lld\n",ans);
}

int main() {
    
    while(scanf("%d%d",&n,&c)!=EOF){
        init();
        play();
        pri();
    }
    return 0;
}


Compiler output:
a.cc: In function 'void play()':
a.cc:62:9: error: 'LONG_MAX' was not declared in this scope
   62 |     ans=LONG_MAX;
      |         ^~~~~~~~
a.cc:17:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   16 | #include <queue>
  +++ |+#include <climits>
   17 | #include <vector>
Language: C++

#include <stdio.h>
typedef long long ll;

int N, C;
int D[31][31];
int c[501][501];

int origColors[3][31]; //slot,colors
int main(void){
    scanf("%d %d",&N,&C);
    
    for(int i = 1; i <= C; i++){
        for(int j = 1; j <= C; j++){
            scanf("%d", &(D[i][j]) );
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            scanf("%d", &(c[i][j]) );
        }
    }
    
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            origColors[(i+j) % 3][c[i][j]] ++;
        }
    }
    
    ll iwakan_min = 1000000000;
    for(int colX = 1 ; colX <= C; colX++){
        for(int colY = 1; colY <= C; colY++){
            if(colY == colX) continue;
            
            for(int colZ = 1; colZ <= C; colZ++){
                if(colZ == colX || colZ == colY) continue;
                
                ll iwakan = 0; 
                
                for(int t = 1; t <= C; t++){
                    iwakan += origColors[0][t] * D[t][colX];
                    iwakan += origColors[1][t] * D[t][colY];
                    iwakan += origColors[2][t] * D[t][colZ];
                }
                if(iwakan_min > iwakan) iwakan_min = iwakan;
            }
        }
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:47:6: error: expected '}' at end of input
   47 |     }
      |      ^
a.cc:9:15: note: to match this '{'
    9 | int main(void){
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int D[33][33];
int c[303][303];


int sum[3][303];

int main(){
  int N,C;
  cin >> N >> C;
  for(int i = 0;i < C;i++){
    for(int j = 0;j < C;j++){
      cin >> D[i][j];
    }
  }

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

  for(int i = 0;i < N;i++){
    for(int j = 0;j < N;j++){
      for(int to = 0;to < C;to++){
        sum[(i + 1 + j + 1) % 3][to] += D[c[i][j]][to];
      }
    }
  }
  int ans = 1e9;
  rep(i,0,C - 1)rep(j,0,C - 1)rep(k,0,C - 1){
    if(i == j || j == k || k == i) continue;
    ans = min(ans , sum[0][i] + sum[1][j] + sum[2][k]);
  }
  cout << ans << endl;
}
2 3
0 1 1
1 0 1
1 4 0
1 2
3 3

Compiler output:
a.cc:42:1: error: expected unqualified-id before numeric constant
   42 | 2 3
      | ^