Source Code
#include<bits/stdc++.h>
#define _for(i,n) for(int i=0;i<n;i++)
#define _forr(i,n) for(int i=1;i<=n;i++)
#define _rof(i,n) for(int i=n-1;i>=0;i--)
#define _roff(i,n) for(int i=n;i>=1;i--)
#define nl cout << "\n"
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pb push_back
#define pp pop_back
#define vl vector<ll>
#define lsb(x) (x & ~(x-1))
#define rand(l,r) uniform_int_distribution<int>(l, r)(rng);
#define IOS ios::sync_with_stdio(0); cout.tie(0); cin.tie(0)
#define pause system("pause")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

ll const mod=1e9+7;
ll const mod1=1013;
ll const MX = 2e6+100;

ll n;

int main()
{
    IOS;
    ll _t=1;
//    cin>>_t;
    while(_t--)
    {
        ll x;
        cin>>x;
        ll sum=0,cur=1;
        vl c;
        while(sum<x)
        {
            c.pb(cur);
            sum+=cur++;
        }
        ll d=-1;
        if(sum!=x)
            d=lower_bound(c.begin(), c.end(), sum-x)-c.begin();

        vl ans;
        for(ll i=0;i<c.size();i++)
        {
            if(i!=d)
                ans.pb(c[i]);
        }
        cout<<ans.size();nl;
        for(ll i:ans)
            cout<<i<< ' ';nl;
    }
}

/**
Test Case:
*/
Copy
Want More! ShakerOO7
GNU G++17
114 ms
36.8 MB
Accepted