Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 100005
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int n, m;
vector<bool> visited(MAX);
ll ans=0;
vector<int> to(MAX);
bool flag=true;

void dfs(int v, int cnt,int origin, int p=-1) {
  visited[v]=true;
  if(cnt==3){
    if(find(to[origin].begin(), to[origin].end(), v)==to[origin].end()){
      to[origin].push_back(v);
      to[v].push_back(origin);
      ans++;
      flag=true;
    }
    return;
  }
  for (int u : to[v]) {
    if (u == p || visited[u]) continue;
    dfs(u, cnt+1,origin,  v);
  }
}

void init(){
  rep(i, n){
    visited[i]=false;
  }
}

int main(){
  cin >> n >> m;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  while(flag){
    flag=false;
    rep(i, n){
      init();
      dfs(i, 0, i);
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int, int, int)':
a.cc:22:24: error: request for member 'begin' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)origin))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   22 |     if(find(to[origin].begin(), to[origin].end(), v)==to[origin].end()){
      |                        ^~~~~
a.cc:22:44: error: request for member 'end' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)origin))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   22 |     if(find(to[origin].begin(), to[origin].end(), v)==to[origin].end()){
      |                                            ^~~
a.cc:22:66: error: request for member 'end' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)origin))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   22 |     if(find(to[origin].begin(), to[origin].end(), v)==to[origin].end()){
      |                                                                  ^~~
a.cc:23:18: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)origin))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   23 |       to[origin].push_back(v);
      |                  ^~~~~~~~~
a.cc:24:13: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)v))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   24 |       to[v].push_back(origin);
      |             ^~~~~~~~~
a.cc:30:20: error: 'begin' was not declared in this scope
   30 |   for (int u : to[v]) {
      |                    ^
a.cc:30:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:30:20: error: 'end' was not declared in this scope
   30 |   for (int u : to[v]) {
      |                    ^
a.cc:30:20: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc: In function 'int main()':
a.cc:48:11: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   48 |     to[a].push_back(b);
      |           ^~~~~~~~~
a.cc:49:11: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   49 |     to[b].push_back(a);
      |           ^~~~~~~~~