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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

ll n, x = 1;
vector<ll> ans;

int main()
{
    cin >> n;
    while(n){
        if(n >= x){
            ans.pb(x);
            n -= x++;
        }
        else{
            ans[ans.size() - 1] = ans.back() + n;
            n = 0;
        }
    }
    cout << ans.size() << '\n';
    for(ll i : ans)
        cout << i << ' ';
    return 0;
}
Copy
Want More! princ_iple
GNU G++17
175 ms
22.3 MB
Accepted