#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //eolibraries #define lnf 3999999999999999999 #define inf 999999999 #define fi first #define se second #define pb push_back #define ll long long #define ld long double #define all(c) (c).begin(),(c).end() #define sz(c) (ll)(c).size() #define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end()) #define pii pair #define tpii pair #define rep(i,n) for(ll i = 0 ; i < n ; i++) #define drep(i,n) for(ll i = n-1 ; i >= 0 ; i--) #define crep(i,x,n) for(ll i = x ; i < n ; i++) #define vi vector #define vec(...) vector<__VA_ARGS__> #define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); //eodefine using namespace std; const ll mxn=302; struct fenwick { private: int n; vector bit; public: fenwick(int m) { n=m; bit.resize(n,0); } int get(int i) { int s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i,int x) { while (i <= n) { bit[i] += x; i += i & -i; } } }; ll n,m,k; void check(deque dq){ vector tmp; vector a; for(auto x : dq) a.pb(x); tmp=a; make_unique(tmp); map mp; rep(i,sz(tmp)) mp[tmp[i]]=i; rep(i,sz(a)) a[i]=mp[a[i]]+1; fenwick bit(sz(a)+10); ll inv=0; drep(i,sz(a)){ inv+=bit.get(a[i]); bit.add(a[i],1); } cout<>n>>m>>k; ll l=0,r=n,c=-1; while(l<=r){ ll m=(l+r)/2; if((m*(m-1))/2<=k){ l=m+1; c=m; }else{ r=m-1; } } deque dq; ll now=n-1; while(now>=n-c){ dq.push_back(now); now--; } ll rem=k-(c*(c-1))/2; ll eh=(sz(dq)-rem>=sz(dq)?-1:dq[sz(dq)-rem]); crep(i,sz(dq)-rem,sz(dq)) dq[i]--; if(eh!=-1) dq.push_front(eh); ll mn=dq.back(),x=0; deque dq0; while(x