2 test cases not passing

#include <bits/stdc++.h>
#include
#include<stdio.h>
#include
#include<math.h>
#include
#include
#include
#include
#include

// #include < unordered_map >
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

#define ll long long
#define pb push_back
#define P pair<ll,ll>
#define F first
#define S second

const ll N = 100005;

struct Graph{

ll size;
vector<ll> *adjlist;

Graph(ll n){
    size=n;
    adjlist=new vector<ll>[size];
}

void addedge(ll a,ll b){
    adjlist[a].pb(b);
    adjlist[b].pb(a);
}

ll dfs_helper(bool *visited,ll node){
    bool flag=false;
    for(auto x : adjlist[node]){
        if(!visited[x]){
            flag=true;
        }
    }
    if(flag==false) return 1;
   ll val=1;
    visited[node]=true;
    for(auto neighbour : adjlist[node]){

        if(!visited[neighbour]){
           val+=dfs_helper(visited,neighbour);
        }
    }
    // cout<<val<<endl;
    return val;     
}
ll dfs(){
    bool *visited=new bool[size];
    memset(visited,false,sizeof(visited));
    ll ans=(size)*(size-1)/2;

    for(ll i=0;i<size;i++){
       ll node = i;
       if(!visited[node]){
           ll temp= dfs_helper(visited,node);
           ans-=(temp)*(temp-1)/2;
       }
    }
    return ans;
}

};

int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);

ll n,e;
cin>>n>>e;

if(n==2||n==1){
	cout<<0<<endl;
	return 0;
}

struct Graph g(n);

for(ll i=0;i<e;i++){
    ll e1,e2;
    cin>>e1>>e2;
    g.addedge(e1,e2);
}

cout<<g.dfs();

}
This is my code for this question. Please tell why 2 test cases are not working

Please send your code link.
Meanwhile you can refer this -:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.