I wrote a program and it was satisfying the test cases. I submitted the program but it gave TLE. So, I replaced all CINs with SCANFs. I don't know C, so please tell me what's going wrong.
I cannot share the entire code, because its part of an ongoing contest.
cin>>t; -> scanf("%d",&t);
cin>>n>>q; -> scanf("%d",&n);scanf("%d",&q);
cin>>left[i]>>right[i]; -> scanf("%d",&left[i]);scanf("%d",&right[i]);
cout<<sum<<endl; -> printf("%d",sum);
EDIT: My output has changed after using scanf. Why is that happening?