Source Code
#include <bits/stdc++.h>
#define endl "\n"
#define debug(a) cout << #a << ": " << a << endl
#define debugLine() cout << "==============" << endl
#define tick() cout << "Tick" << endl
#define testCases() int t; cin >> t; while(t--)
#define all(a) a.begin(), a.end()
#define fillWith(a, b) memset(a, b, sizeof(a))
#define Mod 1000000007
#define goFast() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define files(x) freopen(x, "r", stdin)
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    goFast();
    ll N;
    cin >> N;
    vector<ll> answer;
    int counter = 1;
    while(N != 0)
    {
        if((N - counter > counter) || (N - counter == 0))
        {
            N -= counter;
            answer.push_back(counter);
        }
        counter++;
    }
    cout << answer.size() << endl;
    for(auto it : answer)
        cout << it << " ";
    cout << endl;
}
Copy
Want More! AhmadShahal
GNU G++17
121 ms
22.3 MB
Accepted