Source Code
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <numeric>
#include <chrono>
#include <random>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <unordered_map>
#include <cstring>
#include <cassert>
#include <climits>
#include <complex>
#include <math.h>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    for(int cn = 1; cn <= tc; cn++) {
        long long x; scanf("%lld", &x);
        vector<int> res;
        for (int i = 1; x > 0; i++) {
            if (i > x) {
                res.back() += x;
                x = 0;
            }
            else {
                res.push_back(i);
                x -= i;
            }
        }

        printf("%d\n", (int)res.size());
        for (int i = 0; i < (int)res.size(); i++) {
            printf("%d", res[i]);
            if (i == (int)res.size() - 1) printf("\n");
            else printf(" ");
        }
    }
    return 0;
}
Copy
Want More! amr962
GNU G++17
130 ms
17.0 MB
Accepted