Language: C++

clude <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1000000000+5;
const int N=5000+5;
const ll oo=1e18+5;
const ll mod=998244353;
 
int n;
int dp[2005][2005];
 
void max_self(int& a,int b){
	if(b>a) a=b;
}
 
void update(int i,int j,int val){
	max_self(dp[i][j],val);
	max_self(dp[j][i],val);
	max_self(dp[i][n],val);
	max_self(dp[n][i],val);
	max_self(dp[j][n],val);
	max_self(dp[n][j],val);
	max_self(dp[n][n],val);
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	int n3=n*3;
	vector<int> a(n3);
	for(int& x:a) cin>>x,--x;
	int m=n+1;
	for(int i=0;i<m;++i){
		for(int j=0;j<m;++j) dp[i][j]=-INF;
	}
	update(a[0],a[1],0);
	int add=0;
	for(int i=2;i<n3-1;i+=3){
		int x=a[i],y=a[i+1],z=a[i+2];
		if(x==y&&y==z){
			++add;
			continue;
		}
		vector<tuple<int,int,int>> vec;
		for(int times=0;times<3;++times){
			{
				for(int aa=0;aa<m;++aa){
					int now=dp[aa][n];
					if(y==z){
						max_self(now,dp[aa][y]+1);
					}
					vec.emplace_back(aa,x,now);
				}
			}
			{
				int now=max(dp[n][n],dp[z][z]+1);
				vec.emplace_back(x,y,now);
			}
			swap(x,y);
			swap(y,z);
		}
		for(tuple<int,int,int> x:vec){
			int i,j,val;
			tie(i,j,val)=x;
			update(i,j,val);
		}
	}
	int ans=dp[n][n];
	int l=a[n3-1];
	max_self(ans,dp[l][l]+1);
	ans+=add;
	cout<<ans;
	return 0;
}

Compiler output:
a.cc:1:1: error: 'clude' does not name a type
    1 | clude <bits/stdc++.h>
      | ^~~~~
a.cc: In function 'int main()':
a.cc:30:9: error: 'ios' has not been declared
   30 |         ios::sync_with_stdio(0);
      |         ^~~
a.cc:31:9: error: 'cin' was not declared in this scope
   31 |         cin.tie(0);
      |         ^~~
a.cc:34:9: error: 'vector' was not declared in this scope
   34 |         vector<int> a(n3);
      |         ^~~~~~
a.cc:34:16: error: expected primary-expression before 'int'
   34 |         vector<int> a(n3);
      |                ^~~
a.cc:35:20: error: 'a' was not declared in this scope
   35 |         for(int& x:a) cin>>x,--x;
      |                    ^
a.cc:40:16: error: 'a' was not declared in this scope
   40 |         update(a[0],a[1],0);
      |                ^
a.cc:44:23: error: 'y' was not declared in this scope
   44 |                 if(x==y&&y==z){
      |                       ^
a.cc:44:29: error: 'z' was not declared in this scope
   44 |                 if(x==y&&y==z){
      |                             ^
a.cc:48:24: error: 'tuple' was not declared in this scope
   48 |                 vector<tuple<int,int,int>> vec;
      |                        ^~~~~
a.cc:48:30: error: expected primary-expression before 'int'
   48 |                 vector<tuple<int,int,int>> vec;
      |                              ^~~
a.cc:53:44: error: 'y' was not declared in this scope
   53 |                                         if(y==z){
      |                                            ^
a.cc:53:47: error: 'z' was not declared in this scope
   53 |                                         if(y==z){
      |                                               ^
a.cc:56:41: error: 'vec' was not declared in this scope
   56 |                                         vec.emplace_back(aa,x,now);
      |                                         ^~~
a.cc:60:57: error: 'z' was not declared in this scope
   60 |                                 int now=max(dp[n][n],dp[z][z]+1);
      |                                                         ^
a.cc:60:41: error: 'max' was not declared in this scope
   60 |                                 int now=max(dp[n][n],dp[z][z]+1);
      |                                         ^~~
a.cc:61:33: error: 'vec' was not declared in this scope
   61 |                                 vec.emplace_back(x,y,now);
      |                                 ^~~
a.cc:61:52: error: 'y' was not declared in this scope
   61 |                                 vec.emplace_back(x,y,now);
      |                                                    ^
a.cc:63:32: error: 'y' was not declared in this scope
   63 |                         swap(x,y);
      |                                ^
a.cc:63:25: error: 'swap' was not declared in this scope
   63 |                         swap(x,y);
      |                         ^~~~
a.cc:64:32: error: 'z' was not declared in this scope
   64 |                         swap(y,z);
      |                                ^
a.cc:66:27: error: expected primary-expression before 'int'
   66 |                 for(tuple<int,int,int> x:vec){
      |                           ^~~
a.cc:71:9: error: expected primary-expression before '}' token
   71 |         }
      |         ^
a.cc:70:18: error: expected ';' before '}' token
   70 |                 }
      |                  ^
      |                  ;
   71 |         }
      |         ~         
a.cc:71:9: error: expected primary-expression before '}' token
   71 |         }
      |         ^
a.cc:70:18: error: expected ')' before '}' token
   70 |                 }
      |                  ^
      |                  )
   71 |         }
      |         ~         
a.cc:66:20: note: to match this '('
   66 |                 for(tuple<int,int,int> x:vec){
      |                    ^
a.cc:71:9: error: expected primary-expression before '}' token
   71 |         }
      |         ^
a.cc:76:9: error: 'cout' was not declared in this scope
   76 |         cout<<ans;
      |         ^~~~