my code outputs is exactly as the test cases only on codeBlockes and other online compiler, but in CF it is different, i think it is undefined behavior but i cannot spot it in the code.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n,m,a,b,cnt;
vector<int>arr;
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>a>>b;
arr.insert(arr.end(), a, b);
}
sort(arr.rbegin(), arr.rend());
for(int i=0;i<n;i++)
{
cnt+=arr[i];
}
cout<<cnt;
return 0;
}