#include using namespace std; using ll=long long; using pii=pair; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int N=1000005; ll calc(int n){// count < n ll res=0; for(int i=0; i<=n; ++i){ ll de=2ll*i*i; ll x=sqrt(de)+3; while((x-1)*(x-1)>de) x--; if(x>n) break; res+=n+1-x; } return res; } bool cmp(pii a, pii b){ int x=a.first-b.first,y=b.second-a.second; if(x>=0&&y<0) return 0; if(x<0&&y>=0) return 1; ll xx=1ll*x*x,yy=2ll*y*y; if(xx==yy) return 0; return (xx>yy)^(x>=0); } signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); ll n; cin >> n; int l=0,r=N; while(l>1; if(calc(mid)>=n) r=mid-1; else l=mid; } vector vec; for(int i=0; i<=l; ++i){ ll de=2ll*i*i; ll x=sqrt(de)+3; while(x*x>de) x--; if(x>l) break; vec.pb({l-x,i}); } sort(all(vec),cmp); n-=calc(l)+1; cout << vec[n].first << ' ' << vec[n].second << "\n"; }