rt,不删注释能过,删了后就MLE
#include<bits/stdc++.h>
#ifdef ONLINE_JUDGE
static char buf[4500000],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,4500000,stdin),p1==p2)?EOF:*p1++
#endif
#define S std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define rep(i,l,r) for(register int i=l;i<=r;i++)
#define per(i,l,r) for(register int i=l;i>=r;i--)
#define ll long long
#define lt __int128
using namespace std;
template<typename P>inline void read(P&x){bool f=0;x=0;char c=getchar();while(!isdigit(c)) f|=c=='-',c=getchar();while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();x=f?~(x+1):x;}
template<typename P>inline void write(P x){if(x<0) putchar('-'),x=-x;if(x>9) write(x/10);putchar((x%10)^48);}
const int N=2000,M=5e4+5;
struct node{short u,v,w;}p[M];
bitset<N> f[N][N];
int n,m,ans;
int main(){
S;read(n),read(m),n--;
rep(i,1,m){
read(p[i].u),read(p[i].v),read(p[i].w),p[i].u--,p[i].v--,p[i].w--;
//if(f[p[i].u][p[i].v][p[i].w]) return 1;
f[p[i].u][p[i].v][p[i].w]=1;
}
rep(i,1,m)
rep(j,p[i].w+1,n)
if(f[p[i].u][p[i].v][j]&&f[p[i].u][p[i].w][j]&&f[p[i].v][p[i].w][j])
ans++;
cout<<ans;
return 0;
}