Language: C++

#include<iostream>
#include<vector>
struct Unionfind{
  vector<int> d;
  vector<int> r;
  Unionfind(int n){
    d.resize(n,-1);
    r.resize(n,-1);
  }
  int find(int x){
     if(d[x]<0) return;
     else d[x]=find(d[x]);
  }
  int unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(r[x]>r[y]) swap(x,y);
    if(r[x]==r[y]){
       r[y]++;
    }
    p[x]=y;
  }
};

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m);
  for(int i=0;i<m;i++)
  {
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
  }
  int bridge=0;
  for(int j=0;j<m;j++){
    Unionfind uf(n);
    bool ok=true;
    for(int i=0;i<m;i++){
      if(i!=j) tree.unite(a[i],b[i]);
    }
    for(int i=0;i<n;i++){
        if(tree.find(i)!=tree.root(i+1)) ok=false;
    }
    if(!ok) bridge++;
  }
    cout<<bridge<<endl;
    return 0;
}
  

Compiler output:
a.cc:4:3: error: 'vector' does not name a type
    4 |   vector<int> d;
      |   ^~~~~~
a.cc:5:3: error: 'vector' does not name a type
    5 |   vector<int> r;
      |   ^~~~~~
a.cc: In constructor 'Unionfind::Unionfind(int)':
a.cc:7:5: error: 'd' was not declared in this scope
    7 |     d.resize(n,-1);
      |     ^
a.cc:8:5: error: 'r' was not declared in this scope
    8 |     r.resize(n,-1);
      |     ^
a.cc: In member function 'int Unionfind::find(int)':
a.cc:11:9: error: 'd' was not declared in this scope
   11 |      if(d[x]<0) return;
      |         ^
a.cc:11:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
   11 |      if(d[x]<0) return;
      |                 ^~~~~~
a.cc: In member function 'int Unionfind::unite(int, int)':
a.cc:17:14: error: return-statement with no value, in function returning 'int' [-fpermissive]
   17 |     if(x==y) return;
      |              ^~~~~~
a.cc:18:8: error: 'r' was not declared in this scope
   18 |     if(r[x]>r[y]) swap(x,y);
      |        ^
a.cc:18:19: error: 'swap' was not declared in this scope
   18 |     if(r[x]>r[y]) swap(x,y);
      |                   ^~~~
a.cc:18:19: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:2122:5: note:   'std::swap'
 2122 |     swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
      |     ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
/usr/include/c++/14/bits/exception_ptr.h:229:5: note:   'std::__exception_ptr::swap'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
a.cc:19:8: error: 'r' was not declared in this scope
   19 |     if(r[x]==r[y]){
      |        ^
a.cc:22:5: error: 'p' was not declared in this scope
   22 |     p[x]=y;
      |     ^
a.cc: In function 'int main()':
a.cc:28:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   28 |   cin>>n>>m;
      |   ^~~
      |   std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:29:3: error: 'vector' was not declared in this scope
   29 |   vector<int> a(m),b(m);
      |   ^~~~~~
a.cc:29:3: note: suggested alternatives:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:29:10: error: expected primary-expression before 'int'
   29 |   vector<int> a(m),b(m);
      |          ^~~
a.cc:32:10: error: 'a' was not declared in this scope
   32 |     cin>>a[i]>>b[i];
      |          ^
a.cc:32:16: error: 'b' was not declared in this scope
   32 |     cin>>a[i]>>b[i];
      |                ^
a.cc:41:16: error: 'tree' was not declared in this scope; did you mean 'free'?
   41 |       if(i!=j) tree.unite(a[i],b[i]);
      |                ^~~~
      |                free
a.cc:41:27: error: 'a' was not declared in this scope
   41 |       if(i!=j) tree.unite(a[i],b[i]);
      |                           ^
a.cc:41:32: error: 'b' was not declared in this scope
   41 |       if(i!=j) tree.unite(a[i],b[i]);
      |                                ^
a.cc:44:12: error: 'tree' was not declared in this scope; did you mean 'free'?
   44 |         if(tree.find(i)!=tree.root(i+1)) ok=false;
      |            ^~~~
      |            free
a.cc:48:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   48 |     cout<<bridge<<endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:48:19: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   48 |     cout<<bridge<<endl;
      |                   ^~~~
      |                   std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~