Source Code
#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>

#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define LL long long
#define LD long double
#define pb push_back
#define F first
#define S second


const double PI=3.1415926535897932384626433;
const int KL=1e6;
const LL MOD=1e9+7;


using namespace std;
/*
typedef complex<double> point;
#define x real()
#define y imag()
*/

LL q,x,y,z,n,m,a[KL],mn=1e9,mx=-1e9,ans;
string t;
vector <LL> vec;
set <LL> s;
map <LL,LL> mp;


int main()
{
    scl(x);
    LL i=1;
    while(x>0){
        if(x>=i){
            x-=i;
            vec.pb(i);
            i++;
        }
        else {
            y=vec.back();
            vec.pop_back();
            vec.pb(y+x);
            break;
        }
    }
    printf("%lld\n",(LL)vec.size());
    for(auto v:vec){
        printf("%lld ",v);
    }printf("\n");

    return 0;
}
Copy
Want More! Vectors_Master
GNU G++17
178 ms
22.3 MB
Accepted