Source Code
#include <bits/stdc++.h>
using namespace std;

#define FastIO cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
#define LSOne(a) ( (a) & -(a) )
#define SQ(a) (a)*(a)
#define INF  ll(4e18)
#define OO   int(1e9)
#define EPS      1e-9
#define PB  push_back
#define MP  make_pair
#define S      second
#define F       first

typedef long long       ll;
typedef long double     ld;
typedef pair<int , int> ii;
typedef pair<int , ii>  iii;
typedef pair<ll , ll>   pll;
typedef pair<ll , pll>  plll;
typedef vector< int >   vi;
typedef vector< ll >    vl;
typedef vector< ii >    vii;
typedef vector< pll >   vll;
typedef vector< iii >   viii;
typedef vector< plll >  vlll;

const ll MOD = 1e9 + 7;
const ll N = 2e5 + 5e1;

int main()
{
    ll x;
    cin >> x;

    set< int > s;

    ll i = 1 ,sum = 0;
    while( x != sum )
    {
        if( sum < x )
        {
            s.insert(i);
            sum += i;
            i += 1;
        }
        else{
            s.erase( sum - x );
            break;
        }
    }

    cout << s.size() << endl;
    for(auto &i : s){
        cout << i << ' ';
    }
    return 0;
}
Copy
Want More! asiseno
GNU G++17
557 ms
77.7 MB
Accepted