Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 100000
#define MOD 1000000007
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
vector<int> e[MAXN+5], f[MAXN+5]; bool sl; int color[MAXN+5], c[3], s, n, m, Ans;
void DFS(int p, int x){if(~color[p]){sl |= color[p]^x; return;} color[p] = x, ++c[x], ++s, m += e[p].size(); for(auto v:e[p]) DFS(v,-~x%3); for(auto v:f[p]) DFS(v,-~-~x%3);}
int main()
{
	n = read(); for(rint a, b = c[0] = read(); c[0]; a = read(), b = read(), e[a].push_back(b), f[b].push_back(a), c[0]--); memset(color+1,-1,n<<2);
	for(rint i = 1; i <= n; color[i]<0 ? DFS(i,s=c[0]=c[1]=c[2]=m=sl=0), Ans = (sl?Ans+1ll*s*s:c[0]&&c[1]&&c[2]?Ans+1ll*c[0]*c[1]+1ll*c[1]*c[2]+1ll*c[2]*c[0]:Ans+m)%MOD : 0, i++); printf("%d\n",Ans); return 0;
}

Compiler output:
a.cc:13:1: error: 'vector' does not name a type
   13 | vector<int> e[MAXN+5], f[MAXN+5]; bool sl; int color[MAXN+5], c[3], s, n, m, Ans;
      | ^~~~~~
a.cc: In function 'void DFS(int, int)':
a.cc:14:97: error: 'e' was not declared in this scope
   14 | void DFS(int p, int x){if(~color[p]){sl |= color[p]^x; return;} color[p] = x, ++c[x], ++s, m += e[p].size(); for(auto v:e[p]) DFS(v,-~x%3); for(auto v:f[p]) DFS(v,-~-~x%3);}
      |                                                                                                 ^
a.cc:14:152: error: 'f' was not declared in this scope
   14 | void DFS(int p, int x){if(~color[p]){sl |= color[p]^x; return;} color[p] = x, ++c[x], ++s, m += e[p].size(); for(auto v:e[p]) DFS(v,-~x%3); for(auto v:f[p]) DFS(v,-~-~x%3);}
      |                                                                                                                                                        ^
a.cc: In function 'int main()':
a.cc:17:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |         n = read(); for(rint a, b = c[0] = read(); c[0]; a = read(), b = read(), e[a].push_back(b), f[b].push_back(a), c[0]--); memset(color+1,-1,n<<2);
      |                              ^
a.cc:17:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |         n = read(); for(rint a, b = c[0] = read(); c[0]; a = read(), b = read(), e[a].push_back(b), f[b].push_back(a), c[0]--); memset(color+1,-1,n<<2);
      |                                 ^
a.cc:17:82: error: 'e' was not declared in this scope
   17 |         n = read(); for(rint a, b = c[0] = read(); c[0]; a = read(), b = read(), e[a].push_back(b), f[b].push_back(a), c[0]--); memset(color+1,-1,n<<2);
      |                                                                                  ^
a.cc:17:101: error: 'f' was not declared in this scope
   17 |         n = read(); for(rint a, b = c[0] = read(); c[0]; a = read(), b = read(), e[a].push_back(b), f[b].push_back(a), c[0]--); memset(color+1,-1,n<<2);
      |                                                                                                     ^
a.cc:18:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 |         for(rint i = 1; i <= n; color[i]<0 ? DFS(i,s=c[0]=c[1]=c[2]=m=sl=0), Ans = (sl?Ans+1ll*s*s:c[0]&&c[1]&&c[2]?Ans+1ll*c[0]*c[1]+1ll*c[1]*c[2]+1ll*c[2]*c[0]:Ans+m)%MOD : 0, i++); printf("%d\n",Ans); return 0;
      |                  ^