Language: C++

#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>
#include <unordered_map>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define VS vector<string>
#define VI vector<ll>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define pii pair<ll,ll>
#define pcc pair<char,char>
#define pic pair<ll,char>
#define pci pair<char,ll>
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		ll N; input_returnner(ll N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(ll N) { return std::move(input_returnner(N)); }
}

const ll MOD = 1e9 + 7;

struct ModInt {
	ll v = 0;
	ModInt() {}
	template<class T> ModInt(const T& right) {
		v = right;
		if (v >= 0) v %= MOD;
		else v += ((-v) / MOD + 1)*MOD;
		v %= MOD;
	}
	void operator = (const ModInt& right) { v = right.v; }
	template<class T> void operator = (const T& right) {
		v = right;
		if (v >= 0) v %= MOD;
		else v = v += ((-v) / MOD + 1)*MOD;
		v %= MOD;
	}

	ModInt operator + (const ModInt& right) { return (v + right.v) % MOD; }
	ModInt operator - (const ModInt& right) { return (MOD - (v - right.v)); }
	ModInt operator * (const ModInt& right) { return (v * right.v) % MOD; }
	ModInt operator / (const ModInt& right) { return v / right.v; }

	void operator += (const ModInt& right) { v = (v + right.v) % MOD; }
	void operator -= (const ModInt& right) { v = (MOD - (v - right.v)); }
	void operator *= (const ModInt& right) { v = (v* right.v) % MOD; }
	void operator /= (const ModInt& right) { v = v / right.v; }

	bool operator == (const ModInt& right) { return v == right.v; }
};

ostream& operator << (ostream& os, const ModInt& value) {
	os << value.v;
	return os;
}

string YN[] = { "NO", "YES" };

void solve();
/// ---template---

#define int ll

signed main(void) {
	SETUP;
	solve();
#ifdef _DEBUG
#endif
	return 0;
}

void DFS(vector<vector<int>> &G, vector<vector<int>> &GG, int depth, int node, vector<int>& out, int start, vector<bool> &check) {
	if (check[node]) return;
	check[node] = true;
	if (depth == 0) {
		if (not GG[start][node]) out.push_back(node);
		return;
	}
	for (auto &a : G[node]) {
		DFS(G, GG, depth - 1, a, out, start);
	}
}

void DFS(vector<vector<int>> &G, vector<vector<int>> &GG, int depth, int node, vector<int>& out, int start) {
	DFS(G, GG, depth, node, out, start, vector<bool>(G.size()));
}

void solve() {
	int N, M; cin >> N >> M;
	int ans = 0;
	vector<vector<int>> G(N);
	vector<vector<int>> GG(N, vector<int>(N));
	REP(i, M) {
		int a, b; cin >> a >> b;
		--a;
		--b;
		G[a].push_back(b);
		G[b].push_back(a);
		GG[a][b] = true;
		GG[b][a] = true;
	}

	REP(i, N) GG[i][i] = true;

	bitset<100001> f;

	REP(start, N) {
		vector<int> res;
		queue<int> q;
		DFS(G, GG, 3, start, res, start);
		if (not res.empty()) f[start] = 1;
		for (auto &node : res) if (not GG[start][node]) {
			++ans;
			// cout << start+1 << "-" << node+1 << endl;
			q.push(node);
			G[start].push_back(node);
			G[node].push_back(start);
			GG[start][node] = true;
			GG[node][start] = true;
		}

	}
	if (not f.any()) {
		cout << ans << endl;
		return;
	}
	else f = bitset<100001>();
}

Compiler output:
a.cc: In function 'void DFS(std::vector<std::vector<long long int> >&, std::vector<std::vector<long long int> >&, long long int, long long int, std::vector<long long int>&, long long int, std::vector<bool>&)':
a.cc:133:20: error: too few arguments to function 'void DFS(std::vector<std::vector<long long int> >&, std::vector<std::vector<long long int> >&, long long int, long long int, std::vector<long long int>&, long long int, std::vector<bool>&)'
  133 |                 DFS(G, GG, depth - 1, a, out, start);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:125:6: note: declared here
  125 | void DFS(vector<vector<int>> &G, vector<vector<int>> &GG, int depth, int node, vector<int>& out, int start, vector<bool> &check) {
      |      ^~~
a.cc: In function 'void DFS(std::vector<std::vector<long long int> >&, std::vector<std::vector<long long int> >&, long long int, long long int, std::vector<long long int>&, long long int)':
a.cc:138:45: error: cannot bind non-const lvalue reference of type 'std::vector<bool>&' to an rvalue of type 'std::vector<bool>'
  138 |         DFS(G, GG, depth, node, out, start, vector<bool>(G.size()));
      |                                             ^~~~~~~~~~~~~~~~~~~~~~
a.cc:125:123: note:   initializing argument 7 of 'void DFS(std::vector<std::vector<long long int> >&, std::vector<std::vector<long long int> >&, long long int, long long int, std::vector<long long int>&, long long int, std::vector<bool>&)'
  125 | void DFS(vector<vector<int>> &G, vector<vector<int>> &GG, int depth, int node, vector<int>& out, int start, vector<bool> &check) {
      |                                                                                                             ~~~~~~~~~~~~~~^~~~~