Source Code
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x,sum=0;
    vector<int>v;
	cin>>x;
	for(int i=1;i<=x;i++)
	{
	    v.push_back(i);
	    sum+=i;
	    if(sum==x)
	     break;
	}
	cout<<v.size()<<endl;
	for(auto i : v)cout<<i<<" ";
	puts("");
}
Copy
Want More! moathhamudah
GNU G++17
788 ms
262.1 MB
Memory Limit Exceeded