Source Code
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long;

using namespace std;

void solve()
{
    ll x;
    cin >> x;
    ll sum = 0;
    vector<ll>res;
    for(int i=1;i<=10000000;i++)
    {
        if(x-(sum+i)>i)
        {
            sum += i;
            res.push_back(i);
        }
        else
        {
            res.push_back(x-sum);
            break;
        }
    }
    cout << res.size() << '\n';
    for(ll it:res)
        cout << it <<  ' ';
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    solve();
    return 0;
}
Copy
Want More! MuhammedKhedr
GNU G++17
316 ms
21.8 MB
Accepted