Please help with Atcoder Beginner 206 E

I tried Sieve of Erastos and did the following code, I am getting WA for 1 1000000 test case, I have used ll long long , please help me with it.

using namespace std;
#define vs vector<string>
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define dqi deque<int>
#define pqL priority_queue<int,vector<int>,less<int>>
#define pqG priority_queue<int,vector<int>,greater<int>>
#define printKickstartSingle(T,ans) cout<<"Case #"<<T<<": "<<ans<<endl;
#define printKickstartArray(T,arr) cout<<"Case #"<<T<<": "; for(auto ele:arr) cout<<ele<<" "; cout<<endl;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define all(arr)  arr.begin() , arr.end()
#define fastIO ios_base::sync_with_stdio(false);     cin.tie(NULL);

#define MAX 1000000+1
#define MOD 1000000007
bool primes[MAX]={false};
typedef long long ll;

void seive(int l,int r,ll *ans){


    int i=2;

    while (i<MAX)
        vi arr;

            int j=2;



        /*cout<<"factors :"<<i<<" : ";
        for(auto ele:arr){
            cout<<ele<<" ";
        int size=arr.size();
        for(auto ele:arr){
            int q=r/ele;

        /* code */


void solveE(){

    int l,r;
    ll ans=0;
    cout<<((ll )ans*2)<<endl;


int main(){

    return 0;

It would be better if you could explain your logic a bit and write few comments on your code so that others can figure out your approach.

you may find your answer here (in comment section)

if you got AC in D, can you guide me how to get intitution of graph in the problem.

To me the intuition was because of the fact that result of 1 pair depends on result of another pair
Like for 1,2,3,2 , result of {1,2} depends on making {2,3} pairs elements equal or vice versa
The truth about intuition is that you get it by practice or by seeing similar or even a bit similar problems

when i first time see this approach my mind was unable to accept it, but now i am easy with it and trying to grasp it.

as you gave an example
Like for 1,2,3,2 , result of {1,2} depends on making {2,3} pairs elements equal or vice versa
ans for this is → 2

but we can do this {1,2} → {1,1} and {2,3} → {3,3} and ans still 2;
this Kind of approach I have applied in my solution I am curious to know about where my solution is failing
can you see my approach,(and give some testcases) MY SUBMISSION

{2,3} {2,3} {2,3} {2,3} let we get this four pair and according to graph approach ans will be →
but the right ans is → 1 (change all 2 to 3 or vice versa) am i right or i am making any bulender??

And will be 1 , as the only bidirectional edge will be from 2<->3 , and since there are 2 nodes so the answer is 1

If you make {1,2} as {1,1} then {2,3} will be {1,3} and hence you will have to make it {1,1}