#include<bits/stdc++.h>
using namespace std;
using INT=long long;
int dx[]={-1,-2,-1,1,2,1};
int dy[]={2,0,-2,-2,0,2};
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	INT n;
	scanf("%I64d",&n);
	if(!n) {puts("0 0");return 0;}
	INT ed=sqrt(n/3);
	for(;3*ed*(ed+1)<n;ed++);
	n-=3*(ed-1)*ed;
	INT x=2*ed,y=0;
	for(int i=0;i<6;i++){
		if(n<=ed){
			x+=n*dx[i];
			y+=n*dy[i];
			cout<<x<<' '<<y<<endl;
			return 0;
		}
		n-=ed;
		x+=ed*dx[i];
		y+=ed*dy[i];
	}
	return 0;
}

#include <iostream>
#include <queue>
#include <cmath>
using namespace std;

int main()
{
    long long n,x=0,y=0;
    while(cin>>n)

    {

        long long t=0;
          long long ll=1;
        long long rr=1000000000;
    while(ll<rr)
    {
        long long mid=(ll+rr)/2;
        if(6*mid+3*(mid-1)*mid==n)
        {
            t=mid;break;
        }
        if(6*mid+3*(mid-1)*mid<n)
            ll=mid+1;
        else
            rr=mid-1;
        //cout<<ll<<" "<<rr<<endl;
    }
    if(t==0)
    {
         t=ll;
    if(6*t+3*(t-1)*t<n)t++;

    }
    //cout<<t;
    x=2*t-1;y=2;
    if(n==0)
        cout<<0<<" "<<0<<endl;
    else
    {

    n-=6*(t-1)+3*(t-2)*(t-1);
    if(n<=t)
    {
        cout<<x-(n-1)<<" "<<y+(n-1)*2<<endl;
    }
    else
    {
        x=t;y=2*t;
        n-=t;

  while(1)
  {
        if(double(n)/t<=1)
        {
            x-=n*2;
            cout<<x<<" "<<y<<endl;

            break;
        }
        else{
            x-=t*2;
            n-=t;
        }
        if(double(n)/t<=1)
        {

            x-=n;
            y-=n*2;
cout<<x<<" "<<y<<endl;
             break;
        }
        else{
            x-=t;
            y-=t*2;
            n-=t;
        }
        if(double(n)/t<=1)
        {
            x+=n;
            y-=n*2;
            cout<<x<<" "<<y<<endl;
             break;
        }
        else{
            x+=t;
            y-=t*2;
            n-=t;
        }
        if(double(n)/t<=1)
        {
            x+=2*n;

            cout<<x<<" "<<y<<endl;
             break;
        }
        else{
            x+=2*t;
            n-=t;
        }
         if(double(n)/t<=1)
        {
            x+=n;
            y+=n*2;
            cout<<x<<" "<<y<<endl;
             break;
        }
        else{
            x+=t;
            y+=t*2;
            n-=t;
        }
    }
    }
    }
    }
}

#include<bits/stdc++.h>

using namespace std;

#define LCM(a,b)                (a / __gcd(a,b) ) *b
#define GCD(a,b)                __gcd(a,b)
#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define fRead(x)                freopen(x,"r",stdin)
#define fWrite(x)               freopen (x,"w",stdout)
#define LL                      long long
#define ULL                     unsigned long long
#define pb                      push_back
#define tcase                   cout<<"Case "<<C++<<": ";
#define all(a)                  a.begin(),a.end()
#define Unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end
#define ABS(x)                  ((x)<0?-(x):(x))
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(a,min(b,min(c,d)))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(a,max(b,max(c,d)))
#define PI                      acos(-1.0)
#define ff                      first
#define ss                      second
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define FastRead                ios_base::sync_with_stdio(0);cin.tie(NULL);
#define perr(x, l)              for (int x = l-1; x >= 0; --x)
#define NN                      cout<<"\n";
#define NNN                     cout<<"\n------------------------------\n";

//***********************************************************************//
//                      SHAHED AHMED, CSE'15, IUT                        //
//***********************************************************************//

LL dx[] ={-1,-2,-1, 1,2,1};
LL dy[] ={-2, 0 ,2, 2,0,-2};

LL dist[100010];

int main()
{

        LL n;

        cin>>n;

        if(n==0)
        {
                cout<<"0 0";
                return 0;
        }

        LL curri;
        LL linesz;
        LL currdist;

        /*
        for(int i=1;;i++)
        {

                dist[i]+=((i*(i+1))/2)*6;
                cout<<dist[i]<<"\n";
                if(dist[i]>=n) {
                        currdist = dist[i];
                        curri=i;
                        linesz = dist[i]-dist[i-1];
                        break;
                }
        }
        */

        LL lo=0;
        LL hi=1000000000;
        LL mid;
        while(lo<=hi)
        {
                mid=(lo+hi)/2;
                LL i = mid;
                if(((i*(i+1))/2)*6 >= n )
                {
                        currdist = ((i*(i+1))/2)*6;
                        linesz = i*6;
                        curri = i;
                        hi = mid-1;
                }
                else lo=mid+1;

        }

        LL x = curri*2;
        LL y = 0;
        LL rep = linesz/6;
        LL dpos=0;

        //cout<<linesz<<" **\n";
        for(int i=0;;i++)
        {
                if(currdist-n>rep)
                {
                        x= x+dx[dpos]*rep;
                        y=y+dy[dpos]*rep;
                        dpos++;
                        currdist-=rep;
                }
                else
                {
                        x= x+dx[dpos]*(currdist-n);
                        y=y+dy[dpos]*(currdist-n);
                        break;
                }

        }

        cout<<x<<" "<<y;

}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define pb   push_back
#define mp   make_pair
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie() , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX
#define INF 0x3f3f3f3f

int n;
int X[] = {-1 , -2 , -1 ,  1 , 2 , 1};
int Y[] = {2  ,  0 , -2 , -2 , 0 , 2};
int32_t main(){
    cin >> n;
    PII now = mp(0 , 0);
    int l = 0 , r = 600000000;
    while(r - l > 1){
        int mid = (l + r) / 2;
        if((mid * mid + mid) * 3 >= n) r = mid;
        else l = mid;
    }
    n -= 3 * r * (r - 1);
    now.A += 2 * (r - 1);
    int tmp = r;
    if(n){
        now.A += 2;
        REP(i , 0 , 6){
            if(n >= tmp) now.A += X[i] * tmp , now.B += Y[i] * tmp , n -= tmp;
            else now.A += X[i] * n , now.B += Y[i] * n , n -= n;
        }
    }
    cout << now.A << " " << now.B << endl;
    return 0;
}

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

bool isOk(long long, long long);

int main() {
	long long n;
	cin >> n;
	n++;
	if (n == 1) {
		cout << 0 << ' ' << 0 << endl;
		return 0;
	}
	long long l = 0, r = 1000 * 1000 * 1000;
	while (r - l > 1) {
		long long mid = (l + r) / 2;
		if (isOk((long long)mid, (long long) n)) {
			r = mid;
		}
		else {
			l = mid;
		}
	}
	long long x = (r - 1) * 2, y = 0;
	int dx[6] = {-1, -2, -1, 1, 2, 1};
	int dy[6] = {-2, 0, 2, 2, 0, -2};
	long long r2 = (r) * (r - 1) * 3 + 1;
	long long f = r2 - n;
	int savei = 0;
	for (int i = 0; i < f / l; i++) {
		x += dx[i] * l;
		y += dy[i] * l;
		savei++;
	}
	f %= l;
	x += dx[savei] * f;
	y += dy[savei] * f;
	cout << x << ' ' << y << endl;
	return 0;
}

bool isOk(long long mid, long long n) {
	long long x = (mid * (mid - 1)) * 3 + 1;
	if (x >= n) {
		return 1;
	}
	else {
		return 0;
	}
}

#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
const ll dx[5]={-2,-1,1,2,1};
const ll dy[5]={0,-2,-2,0,2};
ll i,n,k,x,y;
int main()
{
	cin>>n;
	if(!n)
	{
		cout<<"0 0";
		return 0;
	}
	k=(sqrt((long double)12*n-3)+3)/6;
	n-=3*k*k-3*k+1;
	x=2*k-1,y=2;
	if(n<=k-1)
	{
		cout<<x-n<<' '<<y+2*n;
		return 0;
	}
	n-=k-1,x-=k-1,y+=2*k-2;
	for(i=0;i<5;i++)
	{
		if(n<=k)
		{
			cout<<x+n*dx[i]<<' '<<y+n*dy[i];
			return 0;
		}
		x+=k*dx[i],y+=k*dy[i],n-=k;
	}
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    long long n;
    scanf("%lld",&n);
    if(n==0){
        printf("0 0\n");
        return 0;
    }
    long long num=0,kk=1,l=0,r=600000000,di,mid;
    while(l<=r){
        mid=(l+r)/2;
        num=3*(mid*(mid+1))+1;
        if(num>n){
            di=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    if(di==0) num=0;
    else num=3*(di*(di-1))+1;
    long long k=n-num;
    long long x=2*di-1,y=2;
    if(k<=di-1){
        printf("%lld %lld\n",x-k,y+2*k);
        return 0;
    }
    x-=(di-1);
    y+=2*(di-1);
    k-=(di-1);
    if(k<=di){
        printf("%lld %lld\n",x-2*k,y);
        return 0;
    }
    x-=2*di;
    k-=di;
    if(k<=di){
        printf("%lld %lld\n",x-k,y-2*k);
        return 0;
    }
    x-=di;
    y-=2*di;
    k-=di;
    if(k<=di){
        printf("%lld %lld\n",x+k,y-2*k);
        return 0;
    }
    x+=di;
    y-=2*di;
    k-=di;
    if(k<=di){
        printf("%lld %lld\n",x+2*k,y);
        return 0;
    }
    x+=2*di;
    k-=di;
    printf("%lld %lld\n",x+k,y+2*k);
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <string>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define MAXN (100000+10)
#define MAXM (200000+10)
#define Ri(a) scanf("%d", &a)
#define Rl(a) cin >> a
// #define Rl(a) scanf("%lld", &a) != EOF
#define Rf(a) scanf("%lf", &a)
#define Rs(a) scanf("%s", a)
#define Pi(a) printf("%d\n", (a))
#define Pf(a) printf("%.2lf\n", (a))
// #define Pl(a) printf("%lld\n", (a))
#define Ps(a) printf("%s\n", (a))
#define W(a) while(a--)
#define CLR(a, b) memset(a, (b), sizeof(a))
#define MOD 10007
#define LL long long
#define lson o<<1, l, mid
#define rson o<<1|1, mid+1, r
#define ll o<<1
#define rr o<<1|1
#define PI acos(-1.0)
#define first fi
#define second se
using namespace std;
LL Find(LL l, LL r, LL n)
{
    LL ans = 0;
    while(r >= l)
    {
        LL mid = (l + r) >> 1;
        if(3 * (mid + 1) * mid <= n)
        {
            ans = mid;
            l = mid+1;
        }
        else
            r = mid-1;
    }
    return ans;
}
int main()
{
    LL n;
    while (Rl(n)) {
      LL x, y;
      if(n == 0)
          x = 0, y = 0;
      else
      {
          LL r = 1000000000;
          LL t = Find(1, r, n); //Pl(t);
          LL yu = n - 3 * t * (t + 1);
          t++;
          if(yu == 0)
              x = 2*(t-1), y = 0;
          else
          {
              LL tt = yu / t;
              yu = yu - tt * t;
              //Pl(tt);
              if(tt == 0)
                  x = 2*t - yu, y = 2*yu;
              else if(tt == 1)
                  x = t - yu*2, y = 2*t;
              else if(tt == 2)
                  x = -t - yu, y = 2*t - 2*yu;
              else if(tt == 3)
                  x = -2*t + yu, y = -2*yu;
              else if(tt == 4)
                  x = -t + 2*yu, y = -2*t;
              else if(tt == 5)
                  x = t + yu, y = -2*t + 2*yu;
              else
                  x = 2*t, y = 0;
          }
      }
      cout << x << " " << y << endl;
      // printf("%lld %lld\n", x, y);
    };
    return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) ((n) & (1LL << (i)))
#define bitcount(n) __builtin_popcount(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = (int) 1e9 + 7) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = 2 * acos((ld) 0);

void solve() {
	ll n; scanf("%I64d", &n);
	if (n == 0) {
		printf("%d %d", 0, 0);
		return;
	}
	ll l = 0, r = 600000000LL;
	while (l < r) {
		ll m = (l + r + 1) >> 1;
		if (3 * m * (m - 1) + 1 < n) l = m; else r = m - 1;
	}
	ll d = n - 3 * l * (l - 1);
	if (d < l) {
		printf("%I64d %I64d", 2 * l - d, 2 * d);
	}
	else if (d < 2 * l) {
		d -= l;
		printf("%I64d %I64d", l - 2 * d, 2 * l);
	}
	else if (d < 3 * l) {
		d -= 2 * l;
		printf("%I64d %I64d", -l - d, 2 * l - 2 * d);
	}
	else if (d < 4 * l) {
		d -= 3 * l;
		printf("%I64d %I64d", -2 * l + d, -2 * d);
	}
	else if (d < 5 * l) {
		d -= 4 * l;
		printf("%I64d %I64d", -l + 2 * d, -2 * l);
	}
	else {
		d -= 5 * l;
		printf("%I64d %I64d", l + d, -2 * l + 2 * d);
	}
}

int main() {
//	ios_base::sync_with_stdio(0); cin.tie(NULL);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

#include <bits/stdc++.h>
#define int long long
using namespace std;

int n, j = 0, cur = 0, x = 0, y = 0, l = -1, r = 1e9, fucking_too_tired = 1;
int dx[] = {1, -1, -2, -1, 1, 2}, dy[] = {2, 2, 0, -2, -2, 0}, cnt[] = {1, 0, 1, 1, 1, 1};

signed main() {
    cin >> n;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        if (mid * (mid * 3 + 2) <= n) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cur = l * (l * 6 + 4) / 2; //oeis
    x += l * dx[4];
    y += l * dy[4];
    for (int i = 0; i < 6; i++) { //6 case
        cnt[i] += l;
    }
    while (cur < n) { //brute
        int d = min(cnt[j], n - cur);
        cur += d;
        x += dx[j] * d;
        y += dy[j] * d;
        cnt[j]++;
        j = (j + 1) % 6;
    }
    cout << x << ' ' << y << endl;
}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define xmax(x,y) ((x) = max((x),(y)))
#define xmin(x,y) ((x) = min((x),(y)))
#define all(x) (x).begin(),(x).end()
#define mem(x) memset(x , 0 , sizeof(x))
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define FP(a , b , c)  for(ll (a) = (b) ; (a) < (c) ; (a++));
#define FM(a , b , c)  for(ll (a) = (b) ; (a) >= (c) ; (a--));
#define connect(a , b , c) a[b].pb(c) , a[c].pb(b)

typedef long long int ll;
typedef unsigned long long int ull;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <string> vs;

const ll Maxn3 = 1e3 + 10;
const ll Maxn4 = 1e4 + 10;
const ll Maxn5 = 1e5 + 10;
const ll Maxn6 = 1e6 + 10;
const ll Maxn7 = 1e7 + 10;
const ll Maxn8 = 1e8 + 10;
const ll Maxn9 = 1e9 + 10;
const ll Maxn18 = 1e18 + 10;
const ll Mod1 = 1e7 + 7;
const ll Mod2 = 1e9 + 7;
const ll LLMax = LLONG_MAX;
const ll LLMin  = LLONG_MIN;
const ll INTMax = INT_MAX;
const ll INTMin  = INT_MIN;

ll mn = LLMax , mx = LLMin;

pll tabe(ll n)
{
    ll j = 0, c = 0 , x = 0, y = 0;
    vl dx = {1,  -1, -2, -1,  1,  2} , dy = {2,  2,   0, -2, -2,  0} , cnt = {1, 0, 1, 1, 1, 1};
    ll l = -1, r = (ll)1e9;
    while (r - l > 1)
    {
        ll mid = (r + l) / 2;
        if (mid * (mid * 3 + 2) <= n)
            l = mid;
        else
            r = mid;
    }
    c = l * (l * 6 + 4) / 2;
    x += l * dx[4];
    y += l * dy[4];
    for (ll i = 0; i < 6; i++)
        cnt[i] += l;
    while (c < n)
    {
        ll d = min(cnt[j], n - c);
        c += d;
        x += dx[j] * d;
        y += dy[j] * d;
        cnt[j]++;
        j = (j + 1) % 6;
    }
    return {x, y};
}

int main()
{_
    ll n;cin >> n;
    pll res  = tabe(n);
    return cout << res.F << ' ' << res.S , 0;
}
///SAliB

#include <iostream>

using namespace std;

int dx[] = {1, -1, -2, -1,  1, 2};
int dy[] = {2,  2,  0, -2, -2, 0};

int main() {
  long long n;
  cin >> n;

  if (n == 0) {
    cout << "0 0\n";
    return 0;
  }

  long long l = 0, r = 1e+9 + 100;
  while (l < r) {
    long long m = (l + r) / 2;
    long long cells = (6 + 6 * m) * m / 2 - m + 1;
    if (cells <= n)
      l = m + 1;
    else
      r = m;
  }
  long long cells = (6 + 6 * (l - 1)) * (l - 1) / 2 - l + 1;
  n -= cells;
  long long curx = l - 1, cury = -2 * l + 2;
  //cout << curx << " " << cury << endl;
  //cout << n << endl;

  int id = 0;
  while (true) {
    int tmp = min(n, l);
    if (id == 1)
      tmp = min(n, l - 1);
    n -= tmp;
    curx += dx[id] * tmp;
    cury += dy[id] * tmp;
    if (n == 0)
      break;
    ++id;
  }

  cout << curx << " " << cury << endl;

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 1000000009;
const long long xx[6] = {1, -1, -2, -1, 1, 2};
const long long yy[6] = {2, 2, 0, -2, -2, 0};

long long n;

long long x, y;

int solv()
{
    cin >> n;
    long long l = 0, r = N;
    long long q;
    while (l <= r)
    {
        long long m = (l + r) / 2;
        long long s = (m * (m + 1) / 2) * 6;
        if (n <= s)
        {
            q = m;
            r = m - 1;
        }
        else
            l = m + 1;
    }
    if (q == 0)
    {
        cout << "0 0" << endl;
        return 0;
    }
    for (int i = 0; i < 6; ++i)
    {
        x += xx[i] * ((q - 1) * q / 2);
        y += yy[i] * ((q - 1) * q / 2);
        if (i == 0)
        {
            x += xx[i] * (q - 1);
            y += yy[i] * (q - 1);
        }
        if (i == 1)
        {
            x -= xx[i] * (q - 1);
            y -= yy[i] * (q - 1);
        }
    }
    long long qq = n - (((q - 1) * q) / 2) * 6;
    if (qq)
    {
        --qq;
        x += xx[0];
        y += yy[0];
    }
    if (qq <= q - 1)
    {
        x += xx[1] * qq;
        y += yy[1] * qq;
        qq = 0;
    }
    else
    {
        x += xx[1] * (q - 1);
        y += yy[1] * (q - 1);
        qq -= (q - 1);
    }
    for (int i = 2; i < 6; ++i)
    {
        if (qq <= q)
        {
            x += xx[i] * qq;
            y += yy[i] * qq;
            qq = 0;
        }
        else
        {
            x += xx[i] * q;
            y += yy[i] * q;
            qq -= q;
        }
    }
    x += qq * xx[0];
    y += qq * yy[0];
    cout << x << ' ' << y << endl;
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}

#include<bits/stdc++.h>
#define PI acos(-1)
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long int
#define mem(a,b) memset(a,b,sizeof(a))
#define MX 200005
//#define  s second
//#define f first
#define mod 1000000007
#define inf 1e18
#define eps 1e-15
//int ex[]={1,-1,0,0};
//int wye[]={0,0,1,-1};
using namespace std;
ll n,x,y,res;

int main()
{
    fast();
    scanf("%lld",&n);
    n++;
    if(n<=4){
        if(n==1) printf("0 0\n");
        else if(n==2) printf("1 2\n");
        else if(n==3) printf("-1 2\n");
        else  printf("-2 0\n");
        return 0;
    }
    ll tmp,tpp,lo=2,hi=6e8,mid;
    while(lo<=hi){
        mid=(lo+hi)>>1;
        tpp=3LL*mid*mid-5LL*mid+3LL;
        if(tpp<=n) {
            tmp=mid;
            lo=mid+1;
        }
        else hi=mid-1;
    }
    x=-tmp+1LL,y=-2LL*(tmp-1LL);
    res=tmp*tmp*3LL-5LL*tmp+3LL;
    if(n>=res && n<(res+tmp)){
        tpp=n-res;
        x+=2LL*tpp;
        printf("%lld %lld\n",x,y);
        return 0;
    }
    res+=tmp-1LL;
    x+=(2LL*(tmp-1LL));
    if(n>=res && n<=res+tmp){
        tpp=n-res;
        x+=tpp,y+=2LL*tpp;
        printf("%lld %lld\n",x,y);
        return 0;
    }
    res+=tmp;
    x+=tmp,y+=2LL*tmp;
    if(n>=res && n<res+tmp){
        tpp=n-res;
        x-=tpp,y+=2LL*tpp;
        printf("%lld %lld\n",x,y);
        return 0;
    }
    res+=tmp-1LL;
    x-=(tmp-1LL),y+=2LL*(tmp-1LL);
    if(n>=res && n<=res+tmp){
        tpp=n-res;
        x-=2LL*tpp;
        printf("%lld %lld\n",x,y);
        return 0;
    }
    res+=tmp;
    x-=2LL*tmp;
    if(n>=res && n<=res+tmp){
        tpp=n-res;
        x-=tpp,y-=(2*tpp);
        printf("%lld %lld\n",x,y);
        return 0;
    }
    res+=tmp;
    x-=tmp,y-=2LL*tmp;
    if(n>=res && n<=res+tmp){
        tpp=n-res;
        x+=tpp,y-=2LL*tpp;
        printf("%lld %lld\n",x,y);
        return 0;
    }
    return 0;
}
/*
1000000000000000000
*/

#include <bits/stdc++.h>
#define int long long
#define for(i,l,r) for (int i=l;i<r;i++)
using namespace std;
int ogn,n,lev;
int dx[]={-1,-2,-1,1,2,1};
int dy[]={2,0,-2,-2,0,2};
signed main() {
	//freopen("615E.inp","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>ogn;
	n=ogn; n-=n%3; n/=3; lev=sqrt(n); if (3*lev*(lev+1)<ogn) lev++;
	n=ogn; n-=3*(lev-1)*lev;
	int x=2*lev,y=0,currside=0;
	while (n>lev) {
		n-=lev;
		x+=lev*dx[currside];
		y+=lev*dy[currside];
		currside++;
	}
	cout<<x+n*dx[currside]<<" "<<y+n*dy[currside];
}

//
//  main.cpp
//  E
//
//  Created by 黄宇凡 on 16/1/10.
//  Copyright © 2016年 黄宇凡. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

typedef long long ll;

int main(int argc, const char * argv[]) {
    ll n;
    cin>>n;
    if(n==0) printf("0 0\n");
    else{
    ll a=n/3;
    ll b=floor(sqrt(a)+0.5);
    //cout<<b<<' ';
        //cout<<b*3*(b+1)<<endl;
    while(3*b*(b+1)>=n) b--;
    //cout<<b<<' ';
    //    cout<<n-1-3*b*(b+1)<<endl;
    ll l=b+1;
    ll c=(n-1-3*b*(b+1))/l;
    ll d=(n-1-3*b*(b+1))%l;
    //    cout<<' '<<c<<' '<<d<<endl;
    ll x,y;
    switch (c) {
        case 0: x=l,y=2*l;x+=l-1-d,y-=2*(l-d-1);
            break;
        case 1:x=-l,y=2*l;x+=(l-1-d)*2;
            break;
        case 2: x=-2*l,y=0;x+=l-1-d;y+=2*(l-1-d);
            break;
        case 3: x=-l,y=-2*l;x-=l-1-d;y+=2*(l-1-d);
            break;
        case 4: x=l,y=-2*l;x-=2*(l-1-d);
            break;
        case 5: x=2*l,y=0; x-=l-1-d;y-=2*(l-1-d);
            break;
        default:
            break;
    }
        cout<<x<<' '<<y<<endl;}
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll sq(ll n) {
	ll x = (ll)sqrt(n);
	while(x * x > n) x--;
	while((x + 1) * (x + 1) <= n) x++;
	return x;
}

ll getx(ll n) {
	ll x = sq(n / 3);
	while(3 * x * (x + 1) > n) x--;
	while(3 * (x + 1) * (x + 2) <= n) x++;
	return x;
}

int main() {
	ll n;
	scanf("%lld", &n);

	ll layer = getx(n);

	n -= 3 * layer * (layer + 1);

	if(n == 0) return printf("%lld 0\n", 2 * layer), 0;

	ll x = 2 * layer + 1, y = 1;
	n--;
	if(n == 0) return printf("%lld %lld\n", x, 2*y), 0;

	ll k = min(layer, n);
	n -= k;
	x -= k, y += k;
	if(n == 0) return printf("%lld %lld\n", x, 2*y), 0;

	k = min(layer + 1, n);
	n -= k;
	x -= 2 * k;
	if(n == 0) return printf("%lld %lld\n", x, 2*y), 0;

	k = min(layer + 1, n);
	n -= k;
	x -= k, y -= k;
	if(n == 0) return printf("%lld %lld\n", x, 2*y), 0;

	k = min(layer + 1, n);
	n -= k;
	x += k, y -= k;
	if(n == 0) return printf("%lld %lld\n", x, 2*y), 0;

	k = min(layer + 1, n);
	n -= k;
	x += 2 * k;
	if(n == 0) return printf("%lld %lld\n", x, 2*y), 0;

	k = min(layer + 1, n);
	n -= k;
	x += k, y += k;
	if(n == 0) return printf("%lld %lld\n", x, 2*y), 0;

	printf("%lld\n", layer);
	assert(0);
}

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

typedef pair<int, int> ii;
typedef long long ll;
typedef pair<ll, int> lli;
typedef pair<int, ii> iii;
typedef pair<double, ii> dii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int SIZE = 1000;
const int INF = 0x3f3f3f3f;
const ll INFll = 0x3f3f3f3f3f3f3f3f;
const ll fat = 1E9+9;

int main() {
    ll l = 0, r = 1E9;
    ll n;
    cin >> n;
    while(r > l + 1) {
        ll m = (l+r)/2;
        ll ntemp = m*(m+1)*3;
        if(ntemp > n) {
            r = m;
        } else {
            l = m;
        }
    }
    ll volta = l;
    if(volta*(volta+1)*3 < n) {
        volta = r;
    }
    ll natual = volta*(volta+1)*3;
    ll x = volta*2;
    ll y = 0;
    //printf("%lld %lld\n", volta, natual);
    ll movesX[] = {-1, -2, -1, 1, 2, 1};
    ll movesY[] = {-2, 0, 2, 2, 0, -2};
    if(natual == n) {
        printf("%lld %lld\n", x, y);
        return 0;
    }
    for(int i = 0; i < 6; i++) {
        ll movesDone = min(volta, natual - n);
        natual -= movesDone;
        x += movesX[i] * movesDone;
        y += movesY[i] * movesDone;
        if(natual == n) {
            printf("%lld %lld\n", x, y);
            return 0;
        }
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

inline ll min(ll &x, ll &y) {return x>y? y : x;}

ull binpow (ull a, ull n) {
    ull res = 1;
    while (n) {
        if (n & 1){
            res = (a*res)%(1000*1000*1000+7);
        }
        a *= a;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n, i, j, x, y;
    cin>>n;
//  for(i=n, j=1; i-j*6>=0; i-=j*6, j++);
    i=n/6;
    j=2*sqrt(i);
    i=n-(j*3*(j-1));
//  if(i>=j*6){
//      i-=j*6; j++;
//  }
    while(i>=j*6 || i<0){
        if(i>=j*6) {
            i-=j*6;
            j++;
        }
        else{
            i+=(j-1)*6;
            j--;
        }
//      cout<<i<<' '<<j<<' ';
    }
    x=j*2-2; y=0;
    if(i){
        i--;
        x+=1;
        y+=2;
    }//cout<<i<<' '<<j<<' ';
//  if(!j){
//      for(ull temp=0; i && temp<j-1; y+=2, x-=1, temp++, i--); cout<<'a';
//      for(ull temp=0; i && temp<j; x-=2, temp++, i--);cout<<'b';
//      for(ull temp=0; i && temp<j; y-=2, x-=1, temp++, i--);//cout<<'c';
//      for(ull temp=0; i && temp<j; y-=2, x+=1, temp++,i--);//cout<<'d';
//      for(ull temp=0; i && temp<j; x+=2, temp++, i--);//cout<<'e';
//      for(ull temp=0; i && temp<j; y+=2, x+=1, temp++, i--);//cout<<'f';
//
//  }
    y+=2*min(i, j-1); x-=min(i, j-1); i-=min(i, j-1);
    x-=2*min(i, j); i-=min(i, j);
    y-=2*min(i, j); x-=min(i, j); i-=min(i, j);
    y-=2*min(i, j); x+=min(i, j); i-=min(i, j);
    x+=2*min(i, j); i-=min(i, j);
    y+=2*min(i, j); x+=min(i, j); i-=min(i, j);
    cout<<x<<' '<<y;
    return 0;
}

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string.h>
#include<climits>
#include<vector>
#include<stack>
#include<set>
#include<math.h>
using namespace std;
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define sint(i) scanf("%d",&i)
#define ss(s) scanf("%s",s)
#define pii pair<int,int>
#define mp(i,j) make_pair(i,j)
#define ll long long
#define MAX 1000000000
#define MOD 1000000007
#define vi vector<int>
#define vvi vector < vi >
#define pb(i) push_back(i);
#define tr(v,it) for(it=v.begin();it!=v.end();it++)
ll LL_MAX;
ll calc(ll mid)
{
    if(mid==0)
    return 0;
    ll num=(5+(mid-1)*3);
    if((LL_MAX)/num<mid)
    {
        return (LL_MAX+10);
    }
    else
    return num*mid;
}
int main()
{
    LL_MAX=1000000000000000000ll;
    int i;
    ll n;
    cin>>n;
    ll mid;
    ll low=0;
    ll d=6;
    ll a=5;
    ll high=1000000000ll;
    while(low<high)
    {
        mid=(low+high+1)/2;
        if(calc(mid)<=n)
        {
            low=mid;
        }
        else
        {
            high=mid-1;
        }
    }
   // cout<<low<<" ";
    n=n-(calc(low));
    //cout<<n<<" ";
    ll x=low;
    ll two=2;
    ll y=-two*low;
    low++;
    ll up=two*low-1;
    ll down=two*low;
    ll horizontal=low;
        if(n>up)
        {
            n=n-up;
            x=low;
            y=two*low;
        }
        else
        {
            if(n>low)
            {
                x=x+low;
                y=y+two*low;
                n=n-low;
                x=x-n;
                y=y+two*n;
            }
            else
            {
                x=x+n;
                y=y+two*n;
            }
            goto out;
        }
        if(n>horizontal)
        {
           n=n-horizontal;
           x=-low;
           y=two*low;
        }
        else
        {
            x=x-two*n;
            goto out;
        }
        if(n>down)
        {
            n=n-down;
            x=-low;
            y=-two*low;
        }
        else
        {
            if(n>low)
            {
                x=x-low;
                y=y-two*low;
                n=n-low;
                x=x+n;
                y=y-two*n;
            }
            else
            {
                x=x-n;
                y=y-two*n;
            }
            goto out;
        }
        x=x+two*n;
        out:
    cout<<x<<" "<<y;
    return 0;
}

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
//#pragma warning(disable : 4996)

// by ivan esipov

#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define len(x) (int)(x).size()
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define file freopen("input-riceboard-32f6.txt", "r", stdin); freopen("wheel.out", "w", stdout)
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const int maxn = 2e5 + 500;
const int mod = 998244353;
const int INF = 1e18 + 1;
//mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    //file;
    fast;
    int n;
    cin >> n;
    if (n == 0) {
        cout << "0 0";
        return 0;
    }

    int l = 0, r = 1e9 + 1;
    while (r - l > 1) {
        int md = l + r >> 1;
        int s = 3 * md * (md + 1);
        if (s < n) l = md;
        else r = md;
    }
    n -= 3 * l * (l + 1);// lvl no.r
    if (n <= r) {
        cout << 2 * r - n << ' ' << (n - 0 * r) * 2 << '\n';
    }
    else if (n <= 2 * r) {
        cout << r - 2 * (n - r) << ' ' << 2 * r << '\n';
    }
    else if (n <= 3 * r) {
        cout << -r - (n - 2 * r) << ' ' << 2 * r - 2 * (n - 2 * r) << '\n';
    }
    else if (n <= 4 * r) {
        cout << -2 * r + (n - 3 * r) << ' ' << (n - 3 * r) * -2 << '\n';
    }
    else if (n <= 5 * r) {
        cout << -r + 2 * (n - 4 * r) << ' ' << -2 * r << '\n';
    }
    else {
        cout << r + (n - 5 * r) << ' ' << -2 * r + 2 * (n - 5 * r) << '\n';
    }
    return 0;
}
/*
5
1 2 -1 1 1
*/

#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll getLayer(ll n){
    ll minv=0, maxv=INT_MAX/2;
    ll midv;
    while(minv<=maxv){
        midv=(minv+maxv)/2;
        if(midv*(midv+1)*3>n) maxv = midv-1;
        else minv=midv+1;
    }
    return minv-1;
}
int main(){
	ll n;
	cin>>n;
	//ll layer = (ll)((sqrt(1.0+4.0/3.0*n)-1.0)/2.0);
	ll layer = getLayer(n);
//	printf("layer = %I64d\n",layer);
	ll offset = n-(1+layer)*layer*3;
//	printf("offset = %I64d\n", offset);
	ll lyc = layer+1;
	ll stage = offset/lyc;
	ll sofs = offset%lyc;
	ll x, y;
//	printf("stage = %I64d, sofs = %I64d\n", stage, sofs);
	switch(stage){
		case 0:x = 2*lyc-sofs, y = 2*sofs;break;
		case 1:x = lyc-2*sofs, y = 2*lyc;break;
		case 2:x = -(lyc+sofs), y=2*(lyc-sofs); break;
		case 3:x = -(2*lyc-sofs), y = -2*sofs; break;
		case 4:x = -lyc+2*sofs, y = -2*lyc; break;
		case 5:x = lyc+sofs, y = 2*(sofs - lyc); break;
	}
	if(y==0 && x>0) x = x-2;
	cout<<x<<" "<<y<<endl;
}

#include<iostream>
#include<algorithm>
#include<cmath>
#define ll long long int
using namespace std;
ll calc(ll val)
{
	long double n = 12.0 * val +9;
	n = sqrt(n);
	n = n - 3.0;
	n = n/(6.0);
	//cout<<n<<endl;
	ll k = floor(n);
	//cout<<k<<" is the value of k"<<endl;
	if(3*(k+2)*(k+1) <= val)
	return k+1;
	if(3*(k*(k+1)) <= val)
	return k;
	if(3*(k-1)*k <= val)
	return k-1;
}
int main()
{
	ll n , l ,r,mid , i,p = 0,x,y;
	cin>>n;
	ll nc = calc(n);
	ll temp =  n - 3*nc*(nc+1);
//	cout<<endl<<temp<<" is the leftover"<<endl;
//	cout<<nc;
//	cout<<" "<<temp<<" "<<nc<<endl;
	//nc = nc+1;
	x = nc*2;
	y = 0;
	if(nc == 0)
	{
		if(n == 0)
		{x = 0;y = 0;}

		if(n==1){x = 1;y=2;
		}
		if(n==2){x= -1;y=2;
		}
		if(n==3){x = -2;y=0;
		}
		if(n==4){x= -1;y=-2;
		}
		if(n==5){x = 1;y=-2;
		}
		if(n == 6){x = 2;y=0;
		}
	}

	else
	{
		nc = nc+1;
	if(temp != 0)
	{
	 x++;
	 y = y + 2;
	 temp--;
    }
	if(temp >=(nc-1))
	{
		x = x - nc +1;
		y =  y + 2*(nc-1);
		temp = temp - (nc-1);
	}
	else
	{
		x = x - temp ;
		y = y + 2*(temp);
		temp = 0;
	}
	//temp = temp - p;
	if(temp >= nc)
	{
		x = x - nc*2;
		temp = temp - nc;
	}
	else
	{
		x = x - (temp)*2;
		temp = 0;
	}

	if(temp >= nc)
	{
		x = x - nc;
		y = y - 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x - temp;
		y = y - 2*temp;
		temp = 0;
	}

	if(temp >= nc)
	{
		x = x + nc;
		y = y - 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x + temp;
		y = y - 2*temp;
		temp = 0;
	}
	if(temp >= nc)
	{
		x = x + 2*nc;
		temp = temp - nc;
		//cout<<x<<temp<<endl;
	}
	else
	{
		x = x + 2*temp;
		//y = y - temp;
		temp = 0;

    }
	if(temp >= nc)
	{
		x = x + nc;
		y = y + 2*nc;
		temp = temp - nc;
	}
	else
	{
		//cout<<" i entered here"<<temp<<endl;
		x = x + temp;
		y = y + 2*temp;
		temp = 0;
	}
}
	cout<<x<<" "<<y<<endl;
}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <set>
#include <cmath>
#include <cstring>
#include <bitset>
#include <deque>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define bpc(a) __builtin_popcount(a)
#define debug(x) { cerr<<#x<<" = "<<(x)<<endl; }

const int mod = 1e9 + 7;
const int inf = 1e9;

ll powm(ll a,ll p,ll m){ll r=1 % m;while(p){if(p&1)r=r*a%m;p>>=1;a=a*a%m;}return r;}

int main()
{
    ll n;
    cin >> n;
    ll a = 0, b = inf;
    while(b - a > 1)
    {
        ll m = (a + b) / 2;
        if(3ll * m * (m - 1) < n)
            a = m;
        else
            b = m;
    }
    n -= 3ll * a * (a - 1) + 1;
    ll dx[] = {2, 1, -1, -2, -1, 1}, dy[] = {0, 2, 2, 0, -2, -2}, s[] = {-1, -2, -1, 1, 2, 1};
    for(int i = 0, j = 1; i < 6 && n >= 0; ++i, j = (j + 1) % 6)
    {
        ll x0 = dx[i] * a;
        ll y0 = dy[i] * a;
        ll x1 = dx[j] * a;
        ll y1 = dy[j] * a;
        ll cnt = (x1 - x0) / s[i];
        if(cnt > n)
        {
            ll x = (n + 1) * s[i] + x0;
            cout << x << ' ' << (y1 - y0) * (x - x0) / (x1 - x0) + y0 << endl;
            return 0;
        }
        n -= cnt;
    }
    puts("0 0");
    return 0;
}

#include<iostream>
using namespace std;

const int N = 1e6 + 1909;
const double eps = 1e-6;

long long n;

long long get(long long n){
    long long l = 0, r = 1e9, mid;
    while(l < r){
        mid = (l + r) >> 1;
        if(mid * (mid + 1) * 3 >= n) r = mid;
        else l = mid + 1;
    }
    return l;
}

int main(){
    cin >> n;
    if(n == 0){
        cout << "0 0" << endl;
        return 0;
    }
    long long a = get(n);
    long long c = n - 3 * a * (a - 1);
    long long x, y;
    if(c <= a){
        x = a * 2 - c;
        y = c * 2;
    }
    else
        if(c <= 2*a){
        c -= a;
        x = a - c * 2;
        y = a * 2;
    }
    else
        if(c <= a * 3){
        c -= a * 2;
        x = -a - c;
        y = a * 2 - c * 2;
    }
    else
        if(c <= a * 4){
        c -= a * 3;
        x = -a * 2 + c;
        y = -c * 2;
    }
    else
        if(c <= a * 5){
        c -= a * 4;
        x = -a + c * 2;
        y = -a * 2;
    }
    else{
        c -= a * 5;
        x = a + c;
        y = -a * 2 + c * 2;
    }
    cout << x << " " << y;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;

#define F                           first
#define S                           second
#define sep                         ' '
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                  cerr << "#F : " << x << "      #S : " << y << '\n';
const ll MX5 = 2*1e5+3;
const ll MX9 = 2*1e9+3;

int main(){
    ll n,i=1,k=5;
    cin >> n;
    ll m=n;
    while(n-k>0){
        i++;
        n-=k;
        k+=6;
    }
    i--;
    n=m-((5+(5+6*(i-1)))/2)*i;
    i++;
    ll xs,xf,ys,yf;
    xs=(i-1);
    ys=-(i-1)*2;
    xf=i;
    yf=-i*2;
    //cout << "DORE : " << i << endl;
   // cout << '{' << xs << ',' << ys << "}   {" << xf << ',' << yf << '}' << endl;
   //! dore = tool
    pii p[10];
    p[0]=make_pair(1,2);
    p[1]=make_pair(-1,2);
    p[2]=make_pair(-2,0);
    p[3]=make_pair(-1,-2);
    p[4]=make_pair(1,-2);
    p[5]=make_pair(2,0);
   // error(n);
    for(int j=0;j<6;j++){
        if(j==1){
            if(i>1){
                if(n>=i-1){
                    xs+=p[j].F*(i-1);
                    ys+=p[j].S*(i-1);
                    n-=i;
                    n++;
                }
                else{
                    xs+=p[j].F*n;
                    ys+=p[j].S*n;
                    n=0;
                    break;
                }
            }
        }
        else if(n>=i){
            xs+=p[j].F*i;
            ys+=p[j].S*i;
            n-=i;
        }
        else{
            xs+=p[j].F*n;
            ys+=p[j].S*n;
            n=0;
            break;
        }
    }
    cout << xs << sep << ys << endl;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define dprint(v) cerr << #v"=" << v << endl //;)
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define forall(it,v) for(typeof(v.begin()) it=v.begin();it!=v.end();++it)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define pb push_back
#define fst first
#define snd second
#define INF 1e9
typedef long long ll;
typedef pair<ll,ll> ii;

ll x;
int cant = 7;
ii dp[] = { ii(1,2) , ii(-1,2), ii(-2,0), ii(-1,-2), ii(1,-2), ii(2,0), ii(1,2) };
ll h[] = { 1, -1, 0, 0, 0, 0, 0 };
ll m[] = { 0, 1, 1,1,1,1,1};

ll findn(ll x) {
	ll a=0,b=sqrt(x/3)+10;
	while(b-a>1) { ll c =(a+b)/2;
		if (3*c*(c+1)<=x) a=c;
		else b=c;
	}
	return a;
}

int main() {
	//~ freopen("e.in", "r", stdin);
	ios::sync_with_stdio(false);
	while(cin >> x){
		ll n = findn(x);
		ll tam = 3*n*(n+1);
		if(tam==x) {
			ii pos = ii(2*n,0);
			cout << pos.fst << ' ' << pos.snd << endl;
			continue;
		} else {
			n++;
		}
		//~ dprint(n);
		ll p = x - tam;
		//~ dprint(p);
		ii pos = ii(2*n-2,0);
		for(int i=0;i<cant && p ; i++) {
			ll moves = min(p,h[i]+m[i]*n);
			pos.fst=pos.fst+dp[i].fst*moves;
			pos.snd=pos.snd+dp[i].snd*moves;
			p-=moves;
		}
		cout << pos.fst << ' ' << pos.snd << endl;
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

signed main()
{
#ifdef files
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n;
    cin >> n;
    long long l=0, r=2e9;
    while(l+1<r){
        long long m=(l+r)/2;
        if(6*m*(m+1)/2 <= n) l=m;
        else r=m;
    }
    if(6*r*(r+1)/2 <= n)l=r;
    n-=6*l*(l+1)/2;
    long long x=2*l, y=0;
    if(n==0)return cout << x << " " << y, 0;
    x+=2;
    l++;
    if(n<=l)return cout << x-n << " " << y+2*n, 0;
    x-=l;
    y+=2*l;
    n-=l;
    if(n<=l)return cout << x-2*n << " " << y, 0;
    x-=2*l;
    n-=l;
    if(n<=l)return cout << x-n << " " << y-2*n, 0;
    x-=l;
    y-=2*l;
    n-=l;
    if(n<=l)return cout << x+n << " " << y-2*n, 0;
    x+=l;
    y-=2*l;
    n-=l;
    if(n<=l)return cout << x+2*n << " " << y, 0;
    x+=2*l;
    n-=l;
    x+=n;
    y+=2*n;
    cout << x << " " << y;
}

#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;
long long n,a,b,xnow,ynow,lnow;
int main() {
	cin >> n;
	a = ceil((long double)1/2 + sqrt((long double)3/12 + (long double)n/3));
	b = (a-1)*(a-2)*3;
	xnow = 2;
	ynow = 2*a - 3;
	lnow = b+1;

	if (lnow + a-2 <= n) {
		lnow += a-2;
		ynow -= (a-2);
		xnow += 2*(a-2);
	}else {
		ynow -= (n-lnow);
		xnow += 2*(n-lnow);
		lnow += (n-lnow);
	}
	if (lnow + a-1 <= n) {
		lnow += a-1;
		ynow -= 2*(a-1);
	}else {
		ynow -= 2*(n-lnow);
		lnow += (n-lnow);
	}

	if (lnow + a-1 <= n) {
		lnow += a-1;
		ynow -= (a-1);
		xnow -= 2*(a-1);
	}else {
		ynow -= (n-lnow);
		xnow -= 2*(n-lnow);
		lnow += (n-lnow);
	}

	if (lnow + a-1 <= n) {
		lnow += a-1;
		ynow += (a-1);
		xnow -= 2*(a-1);
	}else {
		ynow += (n-lnow);
		xnow -= 2*(n-lnow);
		lnow += (n-lnow);
	}

	if (lnow + a-1 <= n) {
		lnow += a-1;
		ynow += 2*(a-1);
	}else {
		ynow += 2*(n-lnow);
		lnow += (n-lnow);
	}

	if (lnow + a-1 <= n) {
		lnow += a-1;
		ynow += (a-1);
		xnow += 2*(a-1);
	}else {
		ynow += (n-lnow);
		xnow += 2*(n-lnow);
		lnow += (n-lnow);
	}
	cout << ynow <<" "<<xnow<<endl;
}

#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int dx[6] = {-1,-2,-1,1,2,1};
int dy[6] = {2,0,-2,-2,0,2};
int ansx[7] = {0,1,-1,-2,-1,1,2};
int ansy[7] = {0,2,2,0,-2,-2,0};

ll sum(ll x) {
	return x*(x+1)/2;
}

int main() {
	ll n;

	scanf("%lld", &n);

	if(n <= 6) {
		printf("%d %d\n", ansx[n], ansy[n]);
		return 0;
	}
	n--;

	ll l = 1, r = 1e9, aux = 1;

	while(l <= r) {
		ll m = (l+r)/2;
		if(sum(m)*6 <= n) l = m+1, aux = m;
		else r = m-1;
	}

	l = aux;
	ll toGo = n -= (sum(l)*6);

	ll x = 1 + 2*l, y = 2;
	for(int i = 0; i < 6; i++) {
		ll canWalk = l + (i != 0);
		if(toGo >= canWalk) {
			x += dx[i]*canWalk;
			y += dy[i]*canWalk;
			toGo -= canWalk;
		}
		else {
			x += dx[i]*toGo;
			y += dy[i]*toGo;
			break;
		}
	}

	printf("%lld %lld\n", x, y);

    return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<utility>
#define PI acos(-1.0)
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
const int MN=6e7+10;
const LL mod=1e9+7;
const int Intmax=(~(1<<31));
const int Intmin=(1<<31);
const LL LLmax=(~(1LL<<63));
const LL LLmin=(1LL<<63);
const ULL ULLmax=(~(0ULL));
LL xdir[]={-1,-2,-1,1,2,1};
LL ydir[]={2,0,-2,-2,0,2};
LL query(LL x){
	LL pos;
	LL l=1;
	LL r=577350269;
	while(l<r){
		LL mid=(l+r)>>1;
		LL a=3*mid*mid-3*mid+1-x;
		if(a<0){
			l=mid+1;
		}
		else if(a>0){
			r=mid-1;
		}
		else if(a==0){
			return mid;
		}
	}
	return (l+r)>>1;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("1.cpp","r",stdin);
#endif // ONLINE_JUDGE
	LL n;
	LL Max=999999997611066277LL;
	while(scanf("%I64d",&n)!=EOF){
		if(n==0){
			puts("0 0");
			continue;
		}
		int i,j;
		LL id;
		if(n>=Max){
			id=577350269;
			n-=Max;
			LL ansx=1+2LL*(id-1);
			LL ansy=2;
			for(i=0;i<6;i++){
				if(n==0) break;
				if(i==0){
					if(n>=id-1){
						n=n-(id-1);
						ansx=ansx+xdir[i]*(id-1);
						ansy=ansy+ydir[i]*(id-1);
					}
					else{
						LL q=(id-1)-n;
						ansx=ansx+xdir[i]*(n);
						ansy=ansy+ydir[i]*(n);
						n=0;
					}
				}
				else{
					if(n>=id){
						n-=id;
						ansx=ansx+xdir[i]*(id);
						ansy=ansy+ydir[i]*(id);
					}
					else{
						LL q=(id)-n;
						ansx=ansx+xdir[i]*(n);
						ansy=ansy+ydir[i]*(n);
						n=0;
					}
				}
				if(n==0) break;
			}
			printf("%I64d %I64d\n",ansx,ansy);
			continue;
		}
		id=query(n);
		LL q=3*id*id-3*id+1;
		if(n>=q){
			n-=q;
			LL ansx=1+2LL*(id-1);
			LL ansy=2;
			for(i=0;i<6;i++){
				if(n==0) break;
				if(i==0){
					if(n>=id-1){
						n=n-(id-1);
						ansx=ansx+xdir[i]*(id-1);
						ansy=ansy+ydir[i]*(id-1);
					}
					else{
						LL q=(id-1)-n;
						ansx=ansx+xdir[i]*(n);
						ansy=ansy+ydir[i]*(n);
						n=0;
					}
				}
				else{
					if(n>=id){
						n-=id;
						ansx=ansx+xdir[i]*(id);
						ansy=ansy+ydir[i]*(id);
					}
					else{
						LL q=(id)-n;
						ansx=ansx+xdir[i]*(n);
						ansy=ansy+ydir[i]*(n);
						n=0;
					}
				}
				if(n==0) break;
			}
			printf("%I64d %I64d\n",ansx,ansy);
		}
		else{
			id--;
			q=3*id*id-3*id+1;
			n-=q;
			LL ansx=1+2LL*(id-1);
			LL ansy=2;
			for(i=0;i<6;i++){
				if(n==0) break;
				if(i==0){
					if(n>=id-1){
						n=n-(id-1);
						ansx=ansx+xdir[i]*(id-1);
						ansy=ansy+ydir[i]*(id-1);
					}
					else{
						ansx=ansx+xdir[i]*(n);
						ansy=ansy+ydir[i]*(n);
						n=0;
					}
				}
				else{
					if(n>=id){
						n-=id;
						ansx=ansx+xdir[i]*(id);
						ansy=ansy+ydir[i]*(id);
					}
					else{
						LL q=(id)-n;
						ansx=ansx+xdir[i]*(n);
						ansy=ansy+ydir[i]*(n);
						n=0;
					}
				}
				if(n==0) break;
			}
			printf("%I64d %I64d\n",ansx,ansy);
		}
	}
	return 0;
}

#include <cstdio>
using namespace std;
int i,j,k,n,m,t;
struct data{int x,y;}w[7];
long long a,b,c,x,y;
long long min(long long a,long long b){return a>b?b:a;}
int main(){
	scanf("%lld",&a);
	if (a==0){printf("0 0\n");return 0;}
	w[1]={-2,0};w[2]={-1,-2};w[3]={+1,-2};w[4]={+2,0};w[5]={+1,+2};w[6]={-1,+2};
	b=1,c=0;
	long long l=1,r=1000000000;
	while (l<=r){
		long long mid=l+r>>1;
		if (1+(1+mid)*mid*3ll+mid<a)b=1+(1+mid)*mid*3ll+mid,c=mid,l=mid+1;else r=mid-1;
	}
	c++;a-=b;x=c;y=c*2;if (!a){printf("%lld %lld\n",x,y);return 0;}
	x+=min(c,a)*w[1].x;y+=min(c,a)*w[1].y;if (a<=c){printf("%lld %lld\n",x,y);return 0;}a-=c;
	x+=min(c,a)*w[2].x;y+=min(c,a)*w[2].y;if (a<=c){printf("%lld %lld\n",x,y);return 0;}a-=c;
	x+=min(c,a)*w[3].x;y+=min(c,a)*w[3].y;if (a<=c){printf("%lld %lld\n",x,y);return 0;}a-=c;
	x+=min(c,a)*w[4].x;y+=min(c,a)*w[4].y;if (a<=c){printf("%lld %lld\n",x,y);return 0;}a-=c;
	x+=min(c,a)*w[5].x;y+=min(c,a)*w[5].y;if (a<=c){printf("%lld %lld\n",x,y);return 0;}a-=c;
	x+=w[5].x;y+=w[5].y;if (a<=1){printf("%lld %lld\n",x,y);return 0;}a-=1;
	x+=min(c,a)*w[6].x;y+=min(c,a)*w[6].y;if (a<=c){printf("%lld %lld\n",x,y);return 0;}a-=c;
	return 0;
}

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <map>
#include <iterator>
#include <stack>
#include <list>
#include <set>
#include <utility>
#include <ctime>
#include <fstream>

using namespace std;

long long n;

///LONG LONG LONG LONG LONG LONG LONG LONG LONG

int main(){
    ios_base::sync_with_stdio(0);

    srand (time(NULL));

    cin>>n;

    if(n==0)
    {
        cout << "0 0";
        return 0;
    }

    long long low=0;
    long long up=(long long)1000*1000*1000;
    long long mid=(low+up)/2;
    long long ind=-1;
    while((up-low)>0)
    {
        if(3*mid*(mid+1)>n)
        {
            up=mid-1;
            mid=(mid+low)/2;
        }
        else
        {
            low=mid;
            mid=(up+mid+1)/2;
        }
    }
    ///cout << "end" << endl;j

    ind = mid;

    long long r = n - 3*ind*(ind+1);

    long long curx=2*ind;
    long long cury=0;

    //cout << "IND : " << ind << endl;
    //cout << "r : " << r << endl;

    if(r==0)
    {
        cout << curx << " " << cury;
        return 0;
    }
    curx+=1;
    cury+=2;
    r--;
    ind++;
    if(r<=ind-1)
    {
        curx-=r;
        cury+=2*r;
        cout << curx << " " << cury;

        return 0;
    }
    r-=(ind-1);
    curx-=(ind-1);
    cury+=2*(ind-1);
    if(r<=ind)
    {
        curx-=2*r;
        cury+=0;
        cout << curx << " " << cury;
        //cout << "ICI";
        return 0;
    }
    r-=ind;
    curx-=2*ind;
    cury+=0;
    if(r<=ind)
    {
        curx-=r;
        cury-=2*r;
        cout << curx << " " << cury;
        return 0;
    }
    r-=ind;
    curx-=ind;
    cury-=2*ind;
    if(r<=ind)
    {
        curx+=r;
        cury-=2*r;
        cout << curx << " " << cury;
        return 0;
    }
    r-=ind;
    curx+=ind;
    cury-=2*ind;
    if(r<=ind)
    {
        curx+=2*r;
        cury-=0;
        cout << curx << " " << cury;
        return 0;
    }
    r-=ind;
    curx+=2*ind;
    cury-=0;
    if(r<=ind)
    {
        curx+=r;
        cury+=2*r;
        cout << curx << " " << cury;
        return 0;
    }
    r-=ind;
    curx+=ind;
    cury+=2*ind;
    cout << curx << " " << cury;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll j = 0, cur = 0;
ll x = 0, y = 0;
vector<ll> dx = {1,  -1, -2, -1,  1,  2};
vector<ll> dy = {2,  2,   0, -2, -2,  0};
vector<ll> cnt = {1, 0, 1, 1, 1, 1};
ll l = -1, r = (ll)1e9;
pair<ll, ll> hex(ll n)
{

    while (r - l > 1)
    {
        ll m = (r + l) / 2;
        if (m * (m * 3 + 2) <= n)
        {
            l = m;
        }
        else
        {
            r = m;
        }
    }
    cur = l * (l * 6 + 4) / 2;
    x += l * dx[4];
    y += l * dy[4];
    for (int i = 0; i < 6; i++)
    {
        cnt[i] += l;
    }
    while (cur < n) {
        ll d = min(cnt[j], n - cur);
        cur += d;
        x += dx[j] * d;
        y += dy[j] * d;
        cnt[j]++;
        j = (j + 1) % 6;
    }
    return {x, y};
}

int main() {
    ll n;
    cin >> n;
    pair < ll , ll > p = hex(n);
    cout << p.first << " " << p.second  << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
int main () {
	scanf("%lld", &n);
	if (n==0) return 0*printf("0 0\n");
	ll lo=-1, hi=1000000000;
	while (lo+1<hi) {
		ll mid=(lo+hi)>>1;
		ll last=(mid-1)*6+5;
		ll sum=(5+last)*mid/2;
		if (sum>=n) hi=mid;
		else lo=mid;
	}
	ll y=-(hi-1)*2, x=hi-1;
	n-=(5+(hi-1-1)*6+5)*(hi-1)/2;
	//printf("%lld %lld %lld\n", x, y, n);
	x+=min(n, hi);
	y+=2*min(n, hi);
	n-=min(n, hi);
	x-=min(n, hi-1);
	y+=2*min(n, hi-1);
	n-=min(n, hi-1);
	x-=2*min(n, hi);
	n-=min(n, hi);
	x-=min(n, hi);
	y-=2*min(n, hi);
	n-=min(n, hi);
	x+=min(n, hi);
	y-=2*min(n, hi);
	n-=min(n, hi);
	x+=2*min(n, hi);
	printf("%lld %lld\n", x, y);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >moves;
int main()
{
    moves.push_back({1,2});
    moves.push_back({-1,2});
    moves.push_back({-2,0});
    moves.push_back({-1,-2});
    moves.push_back({1,-2});
    moves.push_back({2,0});
    long long n,l,r,mid,justbefore;
    cin>>n;
    justbefore=0;
    l=1,r=1e9;
    while(l<=r)
    {
        mid=l+(r-l)/2;
        if((mid*(3*mid+2))<=n)
        {
            justbefore=max(justbefore,mid);
            l=mid+1;
        }
        else
            r=mid-1;
    }
    //cout<<justbefore<<endl;
    long long x,y;
    x=justbefore;
    y=-2*justbefore;
    if((justbefore*(3*justbefore+2))==n)
        cout<<x<<" "<<y<<endl;
    else
    {
        long long done,todo,curhex;
        //cout<<x<<" "<<y<<endl;
        done=(justbefore*(3*justbefore+2));
        todo=n-done;
        curhex=justbefore+1;
        //cout<<todo<<" "<<curhex<<endl;
        if(curhex<=todo)
        {
            x+=curhex*moves[0].first;
            y+=curhex*moves[0].second;
            todo-=curhex;
            if(curhex-1<=todo)
            {
                x+=(curhex-1)*moves[1].first;
                y+=(curhex-1)*moves[1].second;
                todo-=(curhex-1);
                long long its,rem;
                its=todo/curhex;
                rem=todo%curhex;
                //cout<<its<<" "<<rem<<endl;
                int pos=2;
                while(its)
                {
                    x+=curhex*moves[pos].first;
                    y+=curhex*moves[pos].second;
                    pos=(pos+1)%6;
                    its--;
                }
                x+=rem*moves[pos].first;
                y+=rem*moves[pos].second;
            }
            else
            {
                x+=todo*moves[1].first;
                y+=todo*moves[1].second;
            }
        }
        else
        {
            //cout<<"HERE\n";
            x+=todo*moves[0].first;
            y+=todo*moves[0].second;
        }
        cout<<x<<" "<<y<<"\n";
    }
    return 0;
}

#define CIN_ONLY 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const double PI = 3.14159265358979323846;

int dx[] = { -1, -2, -1, 1, 2, 1 };
int dy[] = { 2, 0, -2, -2, 0, 2 };

int main()
{
	if (CIN_ONLY) {
		ios::sync_with_stdio(0);
		cin.tie(0);
	}
	ll n;
	cin >> n;
	if (n == 0) {
		cout << 0 << ' ' << 0 << endl;
		return 0;
	}
	ll low = 2;
	ll high = 1e9;
	while (low < high) {
		ll mid = (low + high + 1) / 2;
		if (n > 3 * (mid - 1) * (mid - 2)) {
			low = mid;
		} else {
			high = mid - 1;
		}
	}
	n -= 3 * (low - 1) * (low - 2);
	pair<int, int> pos = {2 * (low - 1), 0};
	int d;
	for (d = 0; d < 6; ++d) {
		if (d * (low - 1) + low > n) {
			break;
		}
		pos.first += dx[d] * (low - 1);
		pos.second += dy[d] * (low - 1);
	}
	n -= d * (low - 1);
	pos.first += dx[d] * n;
	pos.second += dy[d] * n;
	cout << pos.first << ' ' << pos.second << endl;
	return 0;
}

#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<ctime>
using namespace std;
long long Ansx=0,Ansy=0,n;
void build(long long Now,long long l,long long r) {
    if(l==r) return ;
    long long Mid=(l+r)>>1;
    build(Now<<1,l,Mid);
    build(Now<<1|1,Mid+1,r);
}
void print() {
    cout<<Ansx<<' '<<Ansy;
    exit(0);
}
int main()
{
    //freopen("lx.in","r",stdin);
    //freopen("lx.out","w",stdout);
    build(1,1,1000);
    cin>>n;
    if(n==0) cout<<0<<' '<<0,exit(0);
    long long head=1,tail=(long long)1<<(long long)30;
    while(head!=tail)
    {
        long long Mid=(head+tail)>>1;
        if(Mid*(Mid+1)*(long long)3<n) head=Mid+1;
        else tail=Mid;
    }
    Ansx=(long long)(long long)2*head,Ansy=0;
    n-=(head-1)*(head)*(long long)3;
    if(n<=head) Ansx-=n,Ansy+=(long long)2*n,print();
    else Ansx-=head,Ansy+=(long long)2*head,n-=head;

    if(n<=head) Ansx-=(long long)2*n,print();
    else Ansx-=(long long)2*head,n-=head;

    if(n<=head) Ansx-=n,Ansy-=(long long)2*n,print();
    else Ansx-=head,Ansy-=(long long)2*head,n-=head;

    if(n<=head) Ansx+=n,Ansy-=(long long)2*n,print();
    else Ansx+=head,Ansy-=(long long)2*head,n-=head;

    if(n<=head) Ansx+=(long long)2*n,print();
    else Ansx+=(long long)2*head,n-=head;

    if(n<=head) Ansx+=n,Ansy+=(long long)2*n,print();
    else Ansx+=head,Ansy+=(long long)2*head,n-=head;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for((i)=(s);(i)<(n);(i)++)
#define trav(it,m) for(auto it=m.begin();it!=m.end();it++)
#define mp make_pair
#define pb push_back
#define DEBUG 0
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef map<int,int> mi;
typedef vector<int> vi;
typedef vector<pii > vpii;
typedef vector<pll > vpll;
int main()
{
	pll ar[7];
	ar[1] = mp(1,2);
	ar[2] = mp(-1,2);
	ar[3] = mp(-2,0);
	ar[4] = mp(-1,-2);
	ar[5] = mp(1,-2);
	ar[6] = mp(2,0);
	if(!DEBUG)
	{
		ios::sync_with_stdio(false);
		cin.tie(NULL);
	}
	ll n;
	cin>>n;
	double vx = n;
	double k = sqrt(1+3*vx) - 1;
	k/=3;
	ll nx = floor(k);
	n = n - (3*nx*nx+2*nx);
	// cerr<<nx<<" "<<n<<endl;
	while(n<0){
		n = n + (3*nx*nx+2*nx);
		nx--;
		n = n - (3*nx*nx+2*nx);
	}
	ll x1 = nx;
	ll y1 = -2*nx;
	nx++;
	assert(n>=0);
	ll arx[7] = {0,nx,nx-1,nx,nx,nx,nx};
	int i=1;
	while(n>0)
	{
		x1 += (min(n,arx[i])*ar[i].first);
		y1 += (min(n,arx[i])*ar[i].second);
		n -= min(n,arx[i]);
		i++;
		// cerr<<n<<endl;s
	}
	cout<<x1<<" "<<y1<<"\n";
}

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(false);cin.tie();cout.tie();
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.0000000001;
using namespace std;
ll n;
bool funkcja(ll x)
{
    if(x*(x+1)*3<=n)
        return true;
    return false;
}
pii P[6]={{-1,2},{-2,0},{-1,-2},{1,-2},{2,0},{1,2}};
int main()
{
    speed
    cin>>n;
    ll p=0,k=inf;
    while(p+1<k)
    {
        ll sr=(p+k)/2;
        if(funkcja(sr))
            p=sr;
        else
            k=sr;
    }
    //cout<<p<<endl;
    n-=p*(p+1)*3;
    if(!n)
    {
        cout<<2*p<<" 0";
        return 0;
    }
    pii a;
    p++;
    a=mp(2*p,0);
    //cout<<n<<endl;
   // cout<<a.st<<" "<<a.nd<<endl;
    for(int i=0;i<6;i++)
    {
        ll x=min(n,p);
        n-=x;
        a.st+=x*P[i].st;
        a.nd+=x*P[i].nd;
       // cout<<a.st<<" "<<a.nd<<endl;
    }
    cout<<a.st<<" "<<a.nd;
    return 0;
}

///*******ZoHuyHieuZo*******///
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define pii pair<int,int>
#define Zo
#define MOD 1000000007
#define maxn 1000001
#define pb push_back
#define mp make_pair
#define mem(i,m) memset(i,m,sizeof(i))
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1) // check bit i
#define SET_ON(x, i) ((x) | MASK(i)) // set bit i on
#define SET_OFF(x, i) ((x) & ~MASK(i)) // set bit i off

using namespace std;

void nhap()
{
    int n;
    cin>>n;
    int res,cnt;
    int l=0;
    int r=1e9;
    while(l<=r)
    {
        int mid=(l+r)/2;
        int k=mid*(10+(mid-1)*6)/2;
        if(k<=n)
        {
            res=mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    n=n-res*(10+(res-1)*6)/2;
    cnt=res+1;
//    while(cnt*6-1<=n)
//    {
//        n=n-(cnt*6-1);
//        cnt++;
//    }
    int x=cnt-1;
    int y=0-(cnt-1)*2;
    if(n<=cnt)
    {
        cout<<x+n<<" "<<y+(n*2);
        return ;
    }
    else
    {
        n-=cnt;
        x=x+cnt;
        y=y+(cnt*2);
    }
    if(n<=cnt-1)
    {
        cout<<x-n<<" "<<y+(n*2);
        return ;
    }
    else
    {
        n-=(cnt-1);
        x=x-(cnt-1);
        y=y+(cnt-1)*2;
    }
    if(n<=cnt)
    {
        cout<<x-(n*2)<<" "<<y;
        return ;
    }
    else
    {
        n-=cnt;
        x=x-cnt*2;
    }
    if(n<=cnt)
    {
        cout<<x-n<<" "<<y-(n*2);
        return ;
    }
    else
    {
        n-=cnt;
        x=x-cnt;
        y=y-cnt*2;
    }
    if(n<=cnt)
    {
        cout<<x+n<<" "<<y-(n*2);
        return ;
    }
    else
    {
        n-=cnt;
        x=x+cnt;
        y=y-cnt*2;
    }
    if(n<=cnt)
    {
        cout<<x+n*2<<" "<<y;
        return ;
    }
}
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen(Zo".inp","r",stdin);
//    freopen(Zo".out","w",stdout);
    nhap();
}

#include<cstdio>
using namespace std;
int main(void)
{
    long long n;
    while(scanf("%lld",&n)==1)
	{
	    if(n==0)
	    {
		    printf("0 0\n");
		    continue;
		}
	    n--;
	    long long k=n;
	    for(long long i=1;;i++)
	    {
	        long long cnt = i*6;
	        if(n>=cnt)n-=cnt;
	        else
	        {
	            if(n<i)
	            {
	                printf("%lld %lld\n",i*2-1-n,2+2*n);
	                break;
	            }
	            n-=i;
	            if(n<i)
	            {
	                printf("%lld %lld\n",i-2-2*n,2*i);
	                break;
	            }
	            n-=i;
	            if(n<i)
	            {
	                printf("%lld %lld\n",-1-i-n,2*i-2*n-2);
	                break;
	            }
	            n-=i;
	            if(n<i)
	            {
	                printf("%lld %lld\n",-2*i+1+n,-2+(-2)*n);
	                break;
	            }
	            n-=i;
	            if(n<i)
	            {
	                printf("%lld %lld\n",2-i+2*n,-2*i);
	                break;
	            }
	            n-=i;
	            printf("%lld %lld\n",i+n+1,2-2*i+2*n);
	            break;
            }
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
signed main()
{
	long long n;
	cin >> n;
	if(n==0)
	{
		cout << "0 0"; return 0;
	}
	if(n==1)
	{
		cout << "1 2"; return 0;
	}
	if(n==2)
	{
		cout << "-1 2"; return 0;
	}
	if(n==3)
	{
		cout << "-2 0"; return 0;
	}
	if(n==4)
	{
		cout << "-1 -2"; return 0;
	}
	if(n==5)
	{
		cout << "1 -2"; return 0;
	}
	if(n==6)
	{
		cout << "2 0"; return 0;
	}
	if(n==7)
	{
		cout << "3 2"; return 0;
	}
	n--;
	long long t=n;
	t=t-t%6;
	t/=3;
	long long l=0,r=1e9;
	long long mid;
	long long prel;
	long long prer;
	while(l!=r)
	{
		mid=(l+r) >> 1;
		if(mid*(mid+1)<t)
		{
			l=mid;
		}
		else if(mid*(mid+1)>t)
		{
			r=mid;
		}
		else if(mid*(mid+1)==t)
		{
			l=mid;
			r=mid;
			break;
		}
		if(prel==l&&prer==r)
		{
			l++;
		}
		prel=l;
		prer=r;
	}
	long long movex[6]={-1,-2,-1,1,2,1};
	long long movey[6]={2,0,-2,-2,0,2};
	t=n-mid*(mid+1)*3;
	mid++;
	long long presetx=1+2*(mid-1);
	long long presety=2;
	//cout << mid << " "<<t << " " << presetx << " " << presety<<endl;
	if(t==0)
	{
		cout << presetx << " " << presety;
		return 0;
	}
	long long fix;
	for(int i=1;i<=6;i++)
	{
		if(i==1)
		{
			fix=min(t,mid-1);
		}
		else
		{
			fix=min(t,mid);
		}
		t=t-fix;
		long long aa=movex[i-1]*fix;
		long long bb=movey[i-1]*fix;
		presetx+=aa;
		presety+=bb;
		//cout << presetx<< " " << presety <<" " << aa<< " " << bb<<" " << fix<<endl;
	}
	cout << presetx << " " << presety;
}

////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

LL px[] = {-1, -2, -1, 1, 2, 1};
LL py[] = {2, 0, -2, -2, 0, 2};

void hora(int tc) {
	LL n;
	cin>>n;
	if(n == 0) {
		cout<<0<<" "<<0<<endl;
		return ;
	}
	LL x = 1,y = 2;
	LL lv = 0;
	LL tot = 0;
	LL lo = 0;
	LL hi = 1e9;
	while(lo <= hi) {
		LL mid = (lo + hi) / 2;
//		cout<<"LO "<<lo<<" "<<mid<<" "<<hi<<endl;
		if(3LL * mid * (mid + 1) < n) {
			lv = mid;
			lo = mid + 1;
		} else hi = mid - 1;
	}
	x += 2LL * lv;
//	for(LL i = 6;tot + i < n; tot += i, i+= 6, x += 2, lv++);
	tot = 3LL * lv * (lv + 1);
//	cout<<"LV "<<lv<<" "<<tot<<endl;
	lv++;
	LL diff = n - tot;
	diff--;
	int id = 0;
	while(diff >= lv) {
		diff -= lv;
		x += px[id] * (lv - 1);
		y += py[id] * (lv - 1);
		id++;
		x += px[id], y += py[id];
	}
	x += px[id] * diff;
	y += py[id] * diff;
	cout<<x<<" "<<y<<endl;
}

int main(){
	//desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
long long n;
int main()
{
    while (scanf("%I64d",&n)!=EOF)
    {
        if (n==0)
        {
            printf("0 0\n");
            continue;
        }
        long long i1=sqrt(n/3);
        long long i=i1;
        if (3*(i1+1)*(i1)<n) i=i1+1;
        //if (n%6==0) i--;
        //cout<<i<<endl;
        //cout<<3*i*(i-1)<<endl;
            if (i==1)
                {
                    if (n==1) printf("1 2\n");
                    else if (n==2) printf("-1 2\n");
                    else if (n==3) printf("-2 0\n");
                    else if (n==4) printf("-1 -2\n");
                    else if (n==5) printf("1 -2\n");
                    else if (n==6) printf("2 0\n");
                    continue;
                }
                n=n-(long long)3*i*(i-1);
                //cout<<n<<endl;
                if (n<=i)
                {
                    long long int t2=n%i;
                    if (t2==0) t2=i;
                    printf("%I64d %I64d\n",i+i-t2,2*t2);
                    continue;
                }
                n-=i;
                if (n<=i)
                {
                    long long int t2=n%i;
                    if (t2==0) t2=i;
                    printf("%I64d %I64d\n",-i+(i-t2)*2,2*i);
                    continue;
                }
                n-=i;
                if (n<=i)
                {
                    long long int t2=n%i;
                    if (t2==0) t2=i;
                    printf("%I64d %I64d\n",-2*i+i-t2,2*(i-t2));
                    continue;
                }
                n-=i;
                if (n<=i)
                {
                    long long int t2=n%i;
                    if (t2==0) t2=i;
                    printf("%I64d %I64d\n",-i-(i-t2),-2*i+2*(i-t2));
                    continue;
                }
                n-=i;
                if (n<=i)
                {
                    long long int t2=n%i;
                    if (t2==0) t2=i;
                    printf("%I64d %I64d\n",i-2*(i-t2),-2*i);
                    break;
                }
                n-=i;
                if (n<=i)
                {
                    long long int t2=n%i;
                    if (t2==0) t2=i;
                    printf("%I64d %I64d\n",2*i-(i-t2),-2*(i-t2));
                    continue;
                }
    }
    return 0;
}

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#define maxn 220000
#define MAXN 10000019
#define inf (1<<30)
#define modp 1000000007
using namespace std;

typedef long long LL;
typedef unsigned int UI;
int n,m,tot;

LL mpow(LL x, LL y)
{
    if (y==0) return 1;
    LL res=mpow(x,y>>1);
    res*=res;
    res%=modp;
    if (y&1) res*=x;
    return res%modp;
}

typedef pair<int, int> PNT;

typedef struct Ed{
    int l,r,nxt;
}E;

const double pi=4*atan(1);
const double eps = 1e-10;

double mabs(double x)
{
    if (x<0) return -x;
    return x;
}

char upc(char x)
{
    if (x>='a'&&x<='z') return x-32; else return x;
}

int mcmp(const E& x, const E&y)
{
    return x.nxt<y.nxt;
}

int main(void)
{
    int T;
    char op;
    LL K;
    //scanf("%d",&T);
    //while (T--)
    //while (scanf("%d %s",&n,s)!=EOF)
    {
    scanf("%I64d",&K);
    if (K==0)
    {
        printf("0 0\n");
        return 0;
    }
    unsigned long long XX=(unsigned long long )K*12+9;
    double X=sqrt(XX);
    unsigned long long tmp=(unsigned long long )X;
    if (tmp*tmp>XX) X-=0.000001;
    X=3+X;
    X/=6;
    LL D;
    if (XX%(LL)sqrt(XX)==0) D=(LL)(X-eps); else D=(LL)X;
    LL M=K-D*(D-1)*3;
    K=M/D%6;
    M%=D;
    LL x,y;
    if (K==0)
    {
        x=D*2-M;
        y=M*2;
    }
    if (K==1)
    {
        x=D-M*2;
        y=D*2;
    }
    if (K==2)
    {
        x=-D-M;
        y=(D-M)*2;
    }
    if (K==3)
    {
        x=-D*2+M;
        y=-M*2;
    }
    if (K==4)
    {
        x=M*2-D;
        y=-D*2;
    }
    if (K==5)
    {
        x=D+M;
        y=(M-D)*2;
    }
    printf("%I64d %I64d\n",x,y);
    }
    return 0;
}

#include <iostream>
#include <cmath>

#define eps 0.0000001

using namespace std;

int main() {
	long long int n;
	cin >> n;
	if (n == 0) {
		cout << "0 0" << endl;
		return 0;
	}
	long long int k = (n - 1) / 6;
	long double a = (sqrt(8 * k + 1) - 1) / 2.0 + eps;
	long long int a1 = (long long int)a + 1;
	while (n - (a1 * (a1 - 1)) * 3 <= 0) a1--;
	long long int s = (n - (a1 * (a1 - 1)) * 3) % (a1 * 6);
	long long int p = s / a1 + 1;
	long long int w = s - a1 * (p - 1);
//	cout << "a = " << a << " a1 = " << a1 << " s = " << s << " p = " << p << " w = " << w << endl;
	switch (p) {
		case 1:
			cout << 2 * a1 - w << " " << w * 2 << endl;
			break;
		case 2:
			cout << a1 - 2 * w << " " << a1 * 2 << endl;
			break;
		case 3:
			cout << -a1 - w << " " << (a1 - w) * 2 << endl;
			break;
		case 4:
			cout << -2 * a1 + w << " " << -2 * w << endl;
			break;
		case 5:
			cout << -a1 + 2 * w << " " << -a1 * 2 << endl;
			break;
		case 6:
			cout << a1 + w << " " << -(a1 - w) * 2 << endl;
	}
}

#include <iostream>

unsigned long long sqrtll(unsigned long long n) {
	unsigned long long approx = sqrtl(n);
	while (approx*approx > n)
		approx -= 1;
	return approx;
}

int main() {
	unsigned long long n;
	std::cin >> n;
	long long x, y;

	unsigned long long r = (1 + sqrtl(1 + 4 * n / 3)) / 2 - 1;

	unsigned long long a = n - 3 * (r + 1) * r;
	while (a >= 6 * (r + 1)) {
		r -= 1;
		a = n - 3 * (r + 1) * r;
	}

	x = 2 * r;
	y = 0;
	if (a > 0) {
		x += 1;
		y += 2;
		a -= 1;

		if (a <= r) {
			x -= a;
			y += 2 * a;
		} else {
			x -= r;
			y += 2 * r;
			a -= r;

			if (a <= r + 1) {
				x -= 2 * a;
			} else {
				x -= 2 * (r + 1);
				a -= r + 1;

				if (a <= r + 1) {
					x -= a;
					y -= 2 * a;
				} else {
					x -= r + 1;
					y -= 2 * (r + 1);
					a -= r + 1;

					if (a <= r + 1) {
						x += a;
						y -= 2 * a;
					} else {
						x += r + 1;
						y -= 2 * (r + 1);
						a -= r + 1;

						if (a <= r + 1) {
							x += 2 * a;
						} else {
							x += 2 * (r + 1);
							a -= r + 1;

							if (a <= r + 1) {
								x += a;
								y += 2 * a;
							} else {

							}
						}
					}
				}
			}
		}
	}

	std::cout << x << ' ' << y;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int xx[]={0,1,-1,-2,-1,1,2},xx1[]={0,1,2,1,-1,-2,-1};
int yy[]={0,2,2,0,-2,-2,0},yy1[]={0,-2,0,2,2,0,-2};
ll cal(ll x)
{
	return (1+x)*x*3;
}
int main()
{
	ll n,nx,ny,gx,gy,temp,left=0,right=1000000000,mid;
	scanf("%I64d",&n);
	if(n!=0)
	{
			while(left<right)
		{
			mid=(left+right)/2;
			if(cal(mid)<n)
				left=mid+1;
			else
				right=(right+mid)/2;
		}
		temp=left;
//		printf("%I64d\n",temp);
		n-=cal(temp-1);
		nx=(n/temp);
		ny=(n%temp);
		if(ny!=0)
			nx++;
		else
			ny=temp;
//		printf("%I64d %I64d\n",nx,ny);
		gx=xx[nx]*temp+(temp-ny)*xx1[nx];
		gy=yy[nx]*temp+(temp-ny)*yy1[nx];
	}
	else
		gx=0,gy=0;
	printf("%I64d %I64d\n",gx,gy);
	return 0;
}

//#define ONLINE_JUDGE

#if defined(ONLINE_JUDGE)
#define _SECURE_SCL 0
#endif

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <functional>
#include <memory>
#include <cmath>
#include <climits>
#include <numeric>
#include <tuple>
#include <memory.h>
#include <stdint.h>

#if !defined(__GNUC__)
#else // !defined(__GNUC__)
#define _CrtDbgBreak() __builtin_trap()
#endif // !defined(__GNUC__)

#if defined(ONLINE_JUDGE)
#define LOCAL_TEST 0
#else
#define LOCAL_TEST 1
#endif

#if LOCAL_TEST
struct AssertsCounter
{
    AssertsCounter(): counter(0) {}
    ~AssertsCounter() { std::cout << std::endl << "DIAG: " << (counter == 0 ? "OK" : "FAIL!!!") << " Asserts count: " << counter << std::endl; }
    void Increment() { counter++; }
    uint32_t counter;
};
AssertsCounter g_assertsCounter;
#define LOCAL_ASSERT(expr) { if (!(expr)) {std::cout << "ASSERT FAILED (" << __LINE__ << "): '" << #expr << "'" << std::endl; g_assertsCounter.Increment(); _CrtDbgBreak(); } }
#define LOCAL_ASSERT_EQ(expr1, expr2) { if ((expr1) != (expr2)) {std::cout << "ASSERT FAILED (" << __LINE__ << "): '" << #expr1 << "' == '" << #expr2 << "' (" << (expr1) << " vs " << (expr2) << "')" << std::endl; g_assertsCounter.Increment(); _CrtDbgBreak(); } }
#else
volatile bool isLocalTestEnabled = 0;
#define LOCAL_ASSERT(expr)
#define LOCAL_ASSERT_EQ(expr1, expr2)
#endif

bool g_isLocalPrintEnabled = (bool)(LOCAL_TEST);
#define LOCAL_PRINT() if (!g_isLocalPrintEnabled) { } else std::cout // << .. << ..

typedef std::string string8_t;
typedef long double ld_t;

typedef std::vector<size_t> vector_size_t;
typedef std::vector<uint8_t> vector_uint8_t;
typedef std::vector<int32_t> vector_int32_t;
typedef std::vector<uint32_t> vector_uint32_t;
typedef std::vector<int64_t> vector_int64_t;
typedef std::vector<uint64_t> vector_uint64_t;
typedef std::vector<string8_t> vector_string8_t;

typedef std::vector<vector_size_t> vector_2d_size_t;
typedef std::vector<vector_int32_t> vector_2d_int32_t;
typedef std::vector<vector_uint32_t> vector_2d_uint32_t;
typedef std::vector<vector_int64_t> vector_2d_int64_t;
typedef std::vector<vector_uint64_t> vector_2d_uint64_t;

typedef std::set<size_t> set_size_t;
typedef std::set<int32_t> set_int32_t;
typedef std::set<uint32_t> set_uint32_t;
typedef std::set<int64_t> set_int64_t;
typedef std::set<uint64_t> set_uint64_t;
typedef std::set<string8_t> set_string8_t;

typedef std::multiset<size_t> multiset_size_t;
typedef std::multiset<string8_t> multiset_string8_t;

// Auxiliary functions definition
//
template<typename T> void UpdateMin(T& a, const T b) {a = std::min(a, b);}
template<typename T> void UpdateMax(T& a, const T b) {a = std::max(a, b);}

const ld_t Pi = std::atan(1.0L) * 4.0L;
static const ld_t Eps = 1.0e-09;
template<typename T> bool IsEqual(const T a, const T b) { return std::abs(a - b) < Eps; }
template<typename T> bool IsGreater(const T a, const T b) { return a > b + Eps; }
template<typename T> bool IsLess(const T a, const T b) { return a + Eps < b; }
template<typename T> bool IsGreaterEqual(const T a, const T b) { return !IsLess(a, b); }
template<typename T> bool IsLessEqual(const T a, const T b) { return !IsGreater(a, b); }

template<typename T> string8_t ToStr(const T& val) { std::ostringstream ostr; ostr << val; return ostr.str(); }
template<typename T> bool FromStr(const string8_t& str, T& val) {std::istringstream istr(str); istr >> val; return !!istr; }

template<typename T> std::istream& operator>>(std::istream& ist, std::vector<T>& data)
{
    LOCAL_ASSERT(!!ist);
    for (size_t i = 0; i < data.size(); i++) { ist >> data[i]; }
    return ist;
}

template<typename T> T Read(std::istream& ist)
{
    LOCAL_ASSERT(!!ist);
    T val; ist >> val; return val;
}

template<typename T> std::ostream& operator<<(std::ostream& ost, const std::vector<T>& data)
{
    for (size_t i = 0; i < data.size(); i++) { if (i != 0) { ost << ' '; } ost << data[i]; }
    return ost;
}

#if defined(ONLINE_JUDGE)
template<size_t id> class StopWatch { };
#else
#include <library/lib_stopwatch.h>
#include <library/lib_random.h>
library::random::Rand g_rnd;
#endif

const int64_t MaxMoves = 1000000000000000000LL;
const int64_t MaxLoops = 577350269LL;

int64_t GetMovesCount(const int64_t loops)
{
    return loops * (loops + 1) * 3;
}

template<typename ArgType, typename ResultType, typename Func>
ArgType LowerBound(const ArgType& firstX, const ArgType& lastX, const ResultType& y, const Func& func)
{
    ArgType l = firstX;
    ArgType r = lastX;

    while (l < r)
    {
        const ArgType m = l + (r - l) / 2;
        if (func(m) < y)
        {
            l = m + 1;
        }
        else
        {
            r = m;
        }
    }

    return l;
}

void Advance(const size_t stage, const int64_t sideLength, int64_t& rem, int64_t& x, int64_t& y)
{
    if (rem == 0)
        return;

    int64_t steps;

    if (stage == 0)
    {
        steps = 1;
    }
    else if (stage == 1)
    {
        steps = sideLength - 1;
    }
    else
    {
        steps = sideLength;
    }

    if (steps > rem)
    {
        steps = rem;
    }

    switch (stage)
    {
        case 0:
        {
            x += steps * 1;
            y += steps * 2;
            break;
        }
        case 1:
        {
            x -= steps * 1;
            y += steps * 2;
            break;
        }
        case 2:
        {
            x -= steps * 2;
            y += steps * 0;
            break;
        }
        case 3:
        {
            x -= steps * 1;
            y -= steps * 2;
            break;
        }
        case 4:
        {
            x += steps * 1;
            y -= steps * 2;
            break;
        }
        case 5:
        {
            x += steps * 2;
            y += steps * 0;
            break;
        }
        case 6:
        {
            x += steps * 1;
            y += steps * 2;
            break;
        }
    }

    rem -= steps;
}

bool Solve(std::istream& ist, std::ostream& ost, const bool multipleTestMode)
{
    //
    int64_t n;
    ist >> n;

    if (multipleTestMode && !ist)
        return false;

    LOCAL_PRINT() << std::endl << "Next test: " << n << std::endl;
    //

    const int64_t mLoops = LowerBound(0LL, MaxLoops + 1, true, [&n](const int64_t mx) -> bool
    {
        const int64_t moves = GetMovesCount(MaxLoops - mx);
        return moves <= n;
    });

    const int64_t loops = MaxLoops - mLoops;
    LOCAL_PRINT() << "loops = " << loops << std::endl;
    LOCAL_ASSERT(GetMovesCount(loops) <= n);
    LOCAL_ASSERT(GetMovesCount(loops + 1) > n);

    int64_t rem = n - GetMovesCount(loops);
    int64_t x = loops * 2;
    int64_t y = 0;

    const int64_t sideLength = loops + 1;
    Advance(0, sideLength, rem, x, y);
    Advance(1, sideLength, rem, x, y);
    Advance(2, sideLength, rem, x, y);
    Advance(3, sideLength, rem, x, y);
    Advance(4, sideLength, rem, x, y);
    Advance(5, sideLength, rem, x, y);
    Advance(6, sideLength, rem, x, y);

    ost << x << " " << y << std::endl;

    return multipleTestMode;
}

#if LOCAL_TEST
void Test()
{
    using namespace library::random;
    const auto genVector = GenFactory::CreateGenVector(GenRange<size_t>(2, 10), GenRange<int32_t>(-100, +200));

    for (size_t t = 0; t < 10; t++)
    {
        const vector_int32_t data = genVector();
        // size_t ans = GetAns(data);
    }

    LOCAL_ASSERT(GetMovesCount(MaxLoops - 1) <= MaxMoves);
    LOCAL_ASSERT(GetMovesCount(MaxLoops) > MaxMoves);
}
#endif

int main(int argc, const char *argv[])
{
#if LOCAL_TEST
    Test();
#endif

    std::ios_base::sync_with_stdio(false);
    std::istream* ist = &std::cin;
    std::ostream* ost = &std::cout;

    std::unique_ptr<std::istream> fileInput;

    if (argc > 1)
    {
        fileInput.reset(new std::ifstream(argv[1]));
        if (!(*fileInput))
        {
            std::cout << "File not found: " << argv[1] << std::endl;
        }
        ist = fileInput.get();
    }

#if defined(ONLINE_JUDGE)
    Solve(*ist, *ost, false);
#else
    while(Solve(*ist, *ost, true)) {};
#endif
}

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

const int dx[] = {0,-2,-1,1,2,1,-1};
const int dy[] = {0,0,-2,-2,0,2,2};

int main()
{
    LL n;
    cin >> n;
    LL l = 0, r = 1e9;
    while ( l + 1 < r ){
        LL mid = (l+r)>>1;
        LL ans = 3*mid*(mid+1);
        if ( ans > n ) r = mid;
        else l = mid;
    }
    n -= 3*l*(l+1);
    LL x = l*dx[4];
    LL y = l*dy[4];
    if ( n ){
        x += dx[5];
        y += dy[5];
        n --;
    }
    LL del = min(l,n);
    x += del*dx[6];
    y += del*dy[6];
    n -= del;
    for ( int i = 1; i <= 6; i ++ ){
        del = min(r,n);
        x += del*dx[i];
        y += del*dy[i];
        n -= del;
    }
    cout << x << " " << y << endl;
    fclose( stdin );
    fclose( stdout );
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
long long startx(long long layer,int part)
{
    switch (part)
    {
    case 0:
        return 2*layer-1;
    case 1:
        return layer-2;
    case 2:
        return -layer-1;
    case 3:
        return 1-2*layer;
    case 4:
        return  2-layer;
    case 5:
        return 1+layer;
    }
}
long long starty(long long layer,int part)
{
    switch (part)
    {
    case 0:
        return 2;
    case 1:
        return layer*2;
    case 2:
        return 2*layer-2;
    case 3:
        return -2;
    case 4:
        return  -2*layer;
    case 5:
        return 2-2*layer;
    }
}
long long root (long long x)
{
if (x==0)
return 0;
    long long one=1,result=0;
    int log;
    for (log=0;(one<<log)*(one<<log) <= x;++log);
    result=one<<(log-1);
    for (;log>=0;log--)
    {
        if ( (result+(one<<log))* (result+(one<<log)) <= x )
            result+=(one<<log);
    }
    return result;
}
int main()
{
    int movex[6]={-1,-2,-1,1,2,1},movey[6]={2,0,-2,-2,0,2};
    long long x=1,n,part,position;
    cin>>x;
    if(x==0)
    {
        cout<<0<<' '<<0;
        return 0;
    }
   // for(x=1;x<50;++x){
    for (n=root((x-1)/3);x>=3*n*(n-1)+1;++n);
    --n;
    part=(x-1)/n-3*(n-1);
    position=(x-1)%n;
   // cout<<x<<' '<<n<<' '<<part<<' '<<position<<"     ";
    cout<<startx(n,part)+movex[part]*position<<' '<<starty(n,part)+movey[part]*position<<endl;
  //  }
    return 0;
}

/*
  The Glow of the fire
  will light up the niiiiiiiiiight
*/

#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define ios ios_base::sync_with_stdio(0);cin.tie(0);

typedef pair<int, int> ii;
using ll = long long;
typedef double db;
typedef vector<vector<int>> mat;

const int mod = 1e9 + 7;
const int N = 1e5 + 5;

ll n;

int main() {

  cin >> n;

  if(!n){
    cout << "0 0\n";
    return 0;
  }

  ll lo = 0, hi = 1e9;

  while(lo < hi){

    ll md = lo + (hi - lo + 1) / 2;

    if(3 * md * (md + 1) + 1 <= n)
      lo = md;
    else
      hi = md - 1;

  }

  int frame = lo;
  cerr << frame << '\n';
  n -= (3 * lo * (lo + 1) + 1);
  ll x = 1 + 2 * (frame), y = 2;
//  cout << x << ' ' << y << '\n';
  if(n <= frame){
    x -= n;
    y += n * 2;
    cout << x << ' ' << y << '\n';
    return 0;
  }
  x -= frame;
  y += frame * 2;
  n -= frame;

  cerr << n << ' ' << x << ' ' << y << '\n';

  if(n <= frame + 1){
    x -= 2 * n;
    cout << x << ' ' << y << '\n';
    return 0;
  }

  x -= 2 *(frame + 1);
  n -= (frame + 1);

  cerr << n << ' ' << x << ' ' << y << '\n';

  if(n <= frame + 1){
    x -= (n);
    y -= (2 * n);
    cout << x << ' ' << y << '\n';
    return 0;
  }

  x -= (frame + 1);
  y -= 2 * (frame + 1);
  n -= (frame + 1);

  cerr << n << ' ' << x << ' ' << y << '\n';

  if(n <= frame + 1){
    x += (n);
    y -= 2 * n;
    cout << x << ' ' << y << '\n';
    return 0;
  }
  x += (frame+1);
  y -= 2 * (frame+1);
  n -= (frame +1);

  if(n <= frame + 1){
    x += (2 * n);
    cout << x << ' ' << y << '\n';
    return 0;
  }
  x += 2 * (frame +1);
  n -= (frame + 1);

  x += n;
  y += 2 * n;

  cout << x << ' ' << y << '\n';

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n;
    cin >> n;
    long long lp, x, px, py, l, r, mid;
    l = 0; r = (long long)1e9;
    while (l <= r) {
        mid = (l + r) / 2;
        if ((3 * mid + 2) * mid <= n) lp = mid, l = mid + 1;
        else r = mid - 1;
    }
    x = n - (3 * lp + 2) * lp;
    px = lp;
    py = -2 * lp;
    const int dx[6] = {1, -1, -2, -1, 1, 2};
    const int dy[6] = {2, 2, 0, -2, -2, 0};
    for (int i = 0; i < 6; ++i) {
        if (i == 1) {
            if (x > lp) {
                x -= lp;
                px += dx[i] * lp;
                py += dy[i] * lp;
            }   else {
                px += dx[i] * x;
                py += dy[i] * x;
                break;
            }
        }   else {
            if (x > lp + 1) {
                x -= lp + 1;
                px += dx[i] * (lp + 1);
                py += dy[i] * (lp + 1);
            }   else {
                px += dx[i] * x;
                py += dy[i] * x;
                break;
            }
        }
    }
    cout << px << ' ' << py << '\n';
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;

pair <i64, i64> it;
ui64 moves;
ui64 cur_moves = 1;
ui64 base;

void move(ui64 steps, i64 x, i64 y)
{
	if (cur_moves >= moves)
		return;

	it.first += x * (steps);
	it.second += y * (steps);
	cur_moves += steps;
	if (cur_moves > moves)
	{
		it.first -= x * (cur_moves - moves);
		it.second -= y * (cur_moves - moves);
	}
}
int main()
{
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ui64 n;
	cin >> n;
	if (n == 0)
	{
		cout << "0 0";
		return 0;
	}
	long double m = n / 6.0;
	//cout << m << endl;
	//printf("%.10lf", m);
	base = floor((-3.0 + sqrt(9.0 + 12 * n)) / 6.0);
	ui64 tmp = base * (base + 1) * 3;
	moves = n - (base)*(base + 1) * 3 ;
	if (moves == 0)
	{
		cout << 2 * base << " " << 0;
		return 0;
	}

	if (moves > n)
	{
		base = base - 1;
		ui64 tmp_ = base * (base + 1) * 3;
		moves = n - base * (base + 1) * 3;
	}
	it = make_pair(2 * base + 1, 2);
	move(base, -1, 2);
	move(base + 1, -2, 0);
	move(base + 1, -1, -2);
	move(base + 1, 1, -2);
	move(base + 1, 2, 0);
	move(base + 1, 1, 2);
	cout << it.first << " " << it.second;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const long long inf = 1e9 + 10;
int dx[7] = {1, -1, -2, -1, 1, 2, 1};
int dy[7] = {2, +2, 0, -2, -2, 0, 2};
long long n, res, nx, ny, cnt, c, old, cnt2;

long long BS() {
	long long l = 0, r = inf, mid;
	while(l + 1 != r) {
		mid = (l + r) / 2;
		c = (6 * (mid * (mid - 1) / 2));
		if(c < n)
			l = mid;
		else
			r = mid;
	}
	return l;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n, old = n;
	if(!n)
		return cout << nx << " " << ny << endl, 0;
	if(n < 7) {
		if(n == 1)
			return cout << dx[0] << " " << dy[0] << endl, 0;
		return cout << dx[n - 1] << " " << dy[n - 1] << endl, 0;
	}
	res = BS();
	n -= ((res * (res - 1)) / 2) * 6 + 1;
	nx = 2 * (res - 1), ny = 0, n++;
	if(n < 0)
		return cout << nx << " " << ny << endl, 0;
	nx += dx[0], ny += dy[0], n--;
	int a[6] = {res - 1, res, res, res, res, res};
	while(n >= a[cnt] && cnt < 6) {
		nx = dx[cnt] * res, ny = dy[cnt] * res;
		n -= a[cnt], cnt++;
	}
	cnt++;
	while(n > 0) {
		nx += dx[cnt], ny += dy[cnt];
		n--;
	}
	return cout << nx << " " << ny << endl, 0;
}

#include <bits/stdc++.h>

#define int long long

using namespace std;

 main () {
    ios_base::sync_with_stdio (0);
    cin.tie (0), cout.tie (0);
    int n;
    cin >> n;
    if (n == 0) {
        cout << 0 << ' ' << 0;
        exit (0);
    }
    int sz = 6;
    int x = 1, y = 2;
    int len = 1;
    while (n > sz) {
        n -= sz;
        sz += 6;
        x += 2;
        len ++;
    }
    n --;
    y += min (n, len - 1) * 2;
    x -= min (n, len - 1);
    n -= min (n, len - 1);
    x -= min (n, len) * 2;
    n -= min (n, len);
    y -= min (n, len) * 2;
    x -= min (n, len);
    n -= min (n, len);
    y -= min (n, len) * 2;
    x += min (n, len);
    n -= min (n, len);
    x += min (n, len) * 2;
    n -= min (n, len);
    y += min (n, len) * 2;
    x += min (n, len);
    n -= min (n, len);
    cout << x << ' ' << y;
    return 0;
}

#include <iostream>
#include <cstdlib>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <chrono>
#include <bitset>
#include <queue>
#include <math.h>
#include <stack>
#include <vector>
#include <string.h>
#include <random>

typedef long long ll;

const ll MOD = 1e9 + 7, INF = 1e18;

using namespace std;

string s;

ll f (ll a)
{
	return 3 * a * (a - 1);
}

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

	ll l = 0, r = 1e9;

	while (l < r)
	{
		ll mid = (l + r + 1) / 2;

		if (f (mid) <= n) l = mid;
		else r = mid - 1;
	}

	ll x = 2 * l - 2, y = 0;

	n -= f (l);

	if (n)
	{
		n--;
		x++;
		y++;
	}

	x -= min (n, l - 1);
	y += min (n, l - 1);

	n -= min (n, l - 1);

	x -= 2 * min (n, l);

	n -= min (n, l);

	x -= min (n, l);
	y -= min (n, l);

	n -= min (n, l);

	x += min (n, l);
	y -= min (n, l);

	n -= min (n, l);

	x += 2 * min (n, l);

	n -= min (n, l);

	x += min (n, l);
	y += min (n, l);

	n -= min (n, l);

	cout << x << ' ' << 2 * y;
}

#include <iostream>
#include <cmath>
#include <cstring>
#include <cassert>
using namespace std;

typedef long long LL;

int dx[] = {-1, -2, -1, 1, 2, 1};
int dy[] = {2, 0, -2, -2, 0, 2};

int main() {
    long long n;
    cin >> n;
    if (n == 0) { cout << "0 0" << endl; return 0; }
    // 6 + 12 + 18 + ... + 6 * n
    // = 6 * (1 + 2 + ... + n)
    // = 6 * (n + 1) * n / 2
    // = 3 * (n + 1) * n
    LL l = 0, r = (LL)sqrt(n);
    LL rings = -1;
    while (l <= r) {
        long long mid = (l + r) >> 1;
        long long t = 3LL * mid * (mid + 1);
        if (t < n) { rings = mid; l = mid + 1; }
        else { r = mid - 1; }
    }
    assert(rings != -1);
    n -= 3LL * rings * (rings + 1);
    rings++;
    LL x = rings * 2LL, y = 0LL;
    n = rings * 6 - n;
    for (int i = 5; i >= 0 && n >= 0; i--) {
        x -= dx[i] * min(n, rings);
        y -= dy[i] * min(n, rings);
        n -= min(n, rings);
    }
    cout << x << " " << y << endl;
    return 0;
}

#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M 200005
#define P1 2333
#define P2 170001
#define oo 1000000000
#define mod 1000000007
using namespace std;
long long n;
long long stx,sty;
int res;
void Go(){
	//��һ����
	if(n<=res){
		stx-=n;
		sty+=1LL*2*n;
		return ;
	}
	else {
		stx-=res;
		sty+=1LL*2*res;
		n-=res;
	}
	//�ڶ�����
	if(n<=res){
		stx-=2*n;
		return ;
	}
	else {
		stx-=2*res;
		n-=res;
	}
	//��������
	if(n<=res){
		stx-=n;
		sty-=1LL*2*n;
		return ;
	}
	else {
		stx-=res;
		sty-=1LL*2*res;
		n-=res;
	}
	//���Ĳ���
	if(n<=res){
		stx+=n;
		sty-=1LL*2*n;
		return ;
	}
	else {
		stx+=res;
		sty-=1LL*2*res;
		n-=res;
	}
	//���岽��
	if(n<=res){
		stx+=1LL*2*n;
		return ;
	}
	else {
		stx+=1LL*2*res;
		n-=res;
	}

	//��������
	stx+=1LL*n;
	sty+=1LL*2*n;
}
int main(){
	int m,i,j;
	cin>>n;
	if(n==0){
		puts("0 0");
		return 0;
	}
	//6 12 18 24......
	int  L=1,R=1e9;
	while(L<=R){
		int mid=L+R>>1;
		if(n<=1LL*mid*(mid+1)*3){
			res=mid;
			R=mid-1;
		}else L=mid+1;
	}
	n-=1LL*res*(res-1)*3;
	//printf("%d\n",n);
	stx=2*res;
	sty=0;
	Go();
	cout<<stx<<" "<<sty<<endl;
	return 0;
}

#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M 200005
#define P1 2333
#define P2 170001
#define oo 1000000000
#define mod 1000000007
using namespace std;
long long n;
long long stx,sty;
int res;
int xx[]={-1,-2,-1,1,2,1};
int yy[]={2,0,-2,-2,0,2};
void Go(){
	for(int i=0;i<6;i++){
		if(n<=res){
			stx+=1LL*xx[i]*n;
			sty+=1LL*yy[i]*n;
			return ;
		}else {
			stx+=1LL*xx[i]*res;
			sty+=1LL*yy[i]*res;
			n-=res;
		}
	}
}
int main(){
	int m,i,j;
	cin>>n;
	if(n==0){
		puts("0 0");
		return 0;
	}
	//6 12 18 24......
	int  L=1,R=1e9;
	while(L<=R){
		int mid=L+R>>1;
		if(n<=1LL*mid*(mid+1)*3){
			res=mid;
			R=mid-1;
		}else L=mid+1;
	}
	n-=1LL*res*(res-1)*3;
	stx=2*res;sty=0;
	Go();
	cout<<stx<<" "<<sty<<endl;
	return 0;
}

#include <stdio.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
#include <math.h>
#include <string.h>
#include <string>
using namespace std;
typedef long long int ll;
ll n;
ll x, y, t, moves;
ll lef=0, rig=1e9, mid;

void final(void)
{
	if(moves==0)
	{
		return;
	}
	moves--;
	x+=1; y+=2;
	if(moves>=t)
	{
		moves-=t;
		x-=t; y+=2*t;
	}
	else
	{
		x-=moves;
		y+=2*moves;
		moves=0;
	}
	if(moves==0)
	{
		return;
	}
	if(moves>=t+1)
	{
		moves-=(t+1);
		x-=(2*(t+1));
	}
	else
	{
		x-=(2*moves);
		moves=0;
	}
	if(moves==0)
	{
		return;
	}
	if(moves>=t+1)
	{
		moves-=(t+1);
		x-=(t+1);
		y-=(2*t+2);
	}
	else
	{
		x-=moves;
		y-=(2*moves);
		moves=0;
	}
	if(moves==0)
	{
		return;
	}
	if(moves>=t+1)
	{
		moves-=(t+1);
		x+=(t+1);
		y-=(2*t+2);
	}
	else
	{
		x+=moves;
		y-=(2*moves);
		moves=0;
	}
	if(moves==0)
	{
		return;
	}
	if(moves>=t+1)
	{
		moves-=(t+1);
		x+=(2*(t+1));
	}
	else
	{
		x+=(2*moves);
		moves=0;
	}
	if(moves==0)
	{
		return;
	}
	x+=moves;
	y+=(2*moves);
	moves=0;
	return;
}
int main(void)
{
	scanf("%lld",&n);
	while(lef<=rig)
	{
		mid=(lef+rig)/2;
		if(3*mid*mid+3*mid<=n)
		{
			t=mid;
			lef=mid+1;
		}
		else
		{
			rig=mid-1;
		}
	}
	x=2*t;
	moves=n-(3*t*t+3*t);
	final();
	printf("%lld %lld",x,y);
	return 0;
}

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <stdio.h>
#include <cstring>
using namespace std;
long long q,e=0,r=0;
long long l(long long t,long long c,long long v){
  long long w=min(q,t);
  q-=w;
  e+=c*w;
  r+=v*w;
}
int main(){
  #ifdef Vlad_kv
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
  long long w,t,c,v,c1;
  cin>>q;
  c1=0;
  for(v=1<<29;v;v>>=1){
   c=c1+v;
   if((c*(c+1)*3<=q)&&( (c*(c+1)*3)/c==(c+1)*3 ))
    c1=c;
  }
  //cout<<c1<<"  !\n";
  q-=c1*(c1+1)*3;
  e+=2*c1;
  c=c1;
  l(1,1,2);
  l(c  ,-1, 2);
  l(c+1,-2, 0);
  l(c+1,-1,-2);
  l(c+1, 1,-2);
  l(c+1, 2, 0);
  l(c+1, 1, 2);
  cout<<e<<" "<<r;

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));
mt19937_64 rnd64(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

li n;

bool read () {
	if (scanf("%lld", &n) != 1)
		return false;
	return true;
}

li sum(li x){
	return 3 * (x + 1) + x * li(x + 1) / 2 * 6;
}

void solve(){
	if (n <= 2){
		if (n == 0) puts("0 0");
		if (n == 1) puts("1 2");
		if (n == 2) puts("-1 2");
		return;
	}

	li l = 0, r = INF;
	while (r - l > 1){
		li m = (l + r) / 2;
		if (sum(m) > n)
			r = m;
		else
			l = m;
	}

	li ful = (sum(r) <= n ? r : l);
	n -= sum(ful);
	++ful;
	pair<li, li> pos = mp(-2 * ful, 0);

	pos.x += min(n, ful);
	pos.y -= 2 * min(n, ful);
	n -= min(n, ful);

	pos.x += 2 * min(n, ful);
	n -= min(n, ful);

	pos.x += min(n, ful + 1);
	pos.y += 2 * min(n, ful + 1);
	n -= min(n, ful + 1);

	pos.x -= min(n, ful);
	pos.y += 2 * min(n, ful);
	n -= min(n, ful);

	pos.x -= 2 * min(n, ful + 1);
	n -= min(n, ful + 1);

	pos.x -= min(n, ful + 1);
	pos.y -= 2 * min(n, ful + 1);
	n -= min(n, ful + 1);

	assert(n == 0);

	printf("%lld %lld\n", pos.x, pos.y);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int tt = clock();

#endif

	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {
		solve();

#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

// #define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const ii dir[6] = {{-1, -2}, {-2, 0}, {-1, 2}, {1, 2}, {2, 0}, {1, -2}};
int main() {
  int64 n;
  cin >> n;
  n += 1;
  int64 low = 0, high = 1e9;
  while (low != high) {
    int64 mid = (low + high) / 2;
    int64 cur = mid == 0 ? 1 : mid * (mid + 1) * 3 + 1;
    if (cur < n) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  int64 lev = high;
  int64 step = (lev == 0 ? 1 : lev * (lev + 1) * 3 + 1) - n;
  trace(lev, step);

  int64 x = 2 * lev, y = 0;
  for (int i = 0; i < 6 && step; ++i) {
    int64 used = min(step, lev);
    step -= used;
    x += dir[i].first * used;
    y += dir[i].second * used;
  }
  cout << x << " " << y << '\n';
  return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

ll n;
ll DX[] = {-1, -2, -1, 1, 2, 1};
ll DY[] = {-2, 0, 2, 2, 0, -2};

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%lld", &n);
	if (n == 0) {
		printf("0 0\n");
		return 0;
	}
	ll l = 0;
	ll side = 1;
	while(true) {
		ll r = l + 6 * side;
		if (n <= r) {
			ll x = 2 * side, y = 0;
			for (int i = 0; i < 6; i++) {
				ll z = min(r - n, side);
				r -= z;
				x += DX[i] * z;
				y += DY[i] * z;
			}
			printf("%lld %lld\n", x, y);
			return 0;
		}
		l = r;
		side++;
	}

	return 0;
}

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

#define llj(a,b,c) for (int (a) = (b); (a) < (c); (a)++)
#define lli(a,b) llj(i,a,b)
#define lll(i, x) llj(i, 0, x)
#define fori(x) lll(i, x)
#define forj(x) lll(j, x)
#define fork(x) lll(k, x)

#define all(X) (X).begin(), (X).end()
#define ever ;;
#define fe(x, C) for (auto& x : (C))
#define INF ((int) 1e9+10)
# define LINF ((ll) 1e18 + 10)
#define pb push_back
#define mp make_pair
#define ms(arr,val) memset(arr , val , sizeof(arr))
#define rint(x) scanf("%d", &(x))
#define rlong(x) scanf("%lld", &(x))
#define nrint(x) int x; rint(x);
#define nrlong(x) long long x; rlong(x);
#define rfloat(x) scanf("%lf", &(x))
#define endl "\n"
#define trace(X) cout << (X) << endl;
#define trace2(X,Y) cout << (X) << ' ' << (Y) << endl;
#define trace3(X,Y,Z) cout << (X) << ' ' << (Y) << ' ' << (Z) << endl;
#define trace4(X,Y,Z,A) cout << (X) << ' ' << (Y) << ' ' << (Z) << ' ' << (A) << endl;
#define tp(X) trace2(X.first ,X.second)
#define vi vector<int>
#define vvi vector<vector<int> >
#define pvi(a) fe(thing ,a) cout << thing << ' '; cout << "\n";

typedef long long ll;
typedef pair<int,int> pii;
#define x first
#define y second
#define read_speed ios::sync_with_stdio(false); cin.tie(0)
/*--------------------------THE END---------------------------------*/

ll get_size(ll level)
{
  return level * 6;
}

vector<pii> dirs = {{-2,0}, {-1,-2}, {1,-2}, {2,0}, {1,2}, {-1,2} };

int main()
{
  //freopen("test.txt", "r", stdin);

  nrlong(n);

  if (n == 0)
  {
    trace2(0, 0);
    return 0;
  }

  ll level = 1;

  while (n > get_size(level))
  {
    n -= get_size(level);
    level++;
  }

  n = (n - level + get_size(level) ) % (get_size(level));

  //trace2(n, level);

  ll x = 0, y = 0;

  fori(level)
  {
    x += 1;
    y += 2;
  }
  //trace2(x,y);

  ll left = level, ind = 0;

  while (n > 0)
  {
    if (n >= left)
    {
      x += dirs[ind].x  * left;
      y += dirs[ind].y  * left;
      n -= left;

      left = level;
      ind++;
      continue;
    }

    else
    {
      x += dirs[ind].x * n;
      y += dirs[ind].y * n;
      n = 0;
    }

  }

  trace2(x,y);

}

#include <stdio.h>
#include <vector>
#include <cstdlib>
#include <map>
#include <time.h>
#include <string>
#include <algorithm>
#include <queue>
#include <assert.h>
#include <math.h>
using namespace std;
#define ll long long int
const ll mod=1e9+7;
const double PI=3.1415926535897932384626433832795;
const double eps=1e-5;

ll n;

void sol(){
    ll i=0,j,l,r,m,x,y,t;
    scanf("%I64d",&n);
    l=0;
    r=1e9;
    while(r-l>1){
        m=(r+l)/2;
        if(3*m*(m+1)>n){
            r=m;
        }else{
            l=m;
        }
    }
    i=i;
    if(n==l*(l+1)*3){
        printf("%I64d 0",(ll)2*(r-1));
        return;
    }
    x=2*(r-1);
    y=0;
    n-=r*(r-1)*3;
    i=i;

    t=min((ll)1,n);
    n-=t;
    x+=t;
    y+=2*t;

    t=min((ll)r-1,n);
    n-=t;
    x-=t;
    y+=2*t;

    t=min((ll)r,n);
    n-=t;
    x-=2*t;

    t=min((ll)r,n);
    n-=t;
    x-=t;
    y-=2*t;

    t=min((ll)r,n);
    n-=t;
    x+=t;
    y-=2*t;

    t=min((ll)r,n);
    n-=t;
    x+=2*t;

    t=min((ll)r,n);
    n-=t;
    x+=t;
    y+=2*t;

    printf("%I64d %I64d",x,y);
}

int main(){
#pragma comment(linker,"/STACK:268435456")
#ifdef _DEBUG
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#else
  //freopen("addition.in","rt",stdin);
   // freopen("addition.out","wt",stdout);
#endif
 //   while(scanf("%I64d%I64d\n",&n,&p)!=EOF)sol();
//  gets(c);
    sol();
    return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;

ll sum(ll x)
{
	return (ll)(3*x*(x+1));
}

ll find(ll x)
{
	ll l=0,r=sqrt(x+0.5);
	while(l<r)
	{
		ll mid=(l+r)/2;
		if(sum(mid)<x)
		  l=mid+1;
		else
		  r=mid;
	}
	return l;
}

int main()
{
	ll n;
	while(cin>>n)
	{
		if(n==0)
		{
			cout<<"0 0\n";
			continue;
		}
		ll k=find(n),ans=n-sum(k-1);
		ll x,y;
		ll p=ans/k,q=ans%k;
		n=k;
		if(p==0)
		  x=(ll)(2*n-q),y=(ll)(2*q);
		else if(p==1)
		  x=(ll)(n-2*q),y=(ll)(2*n);
		else if(p==2)
		  x=(ll)(-n-q),y=(ll)(2*(n-q));
		else if(p==3)
		  x=(ll)(-2*n+q),y=(ll)(-2*q);
		else if(p==4)
		  x=(ll)(-n+2*q),y=(ll)(-2*n);
	    else if(p==5)
		  x=n+q,y=(ll)(-2*(n-q));
	    else if(p==6)
		  x=(ll)(2*k),y=0;
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <list>

using namespace std;

int main() {
    long long n;
    cin >> n;
    double nCopy = n;
    long long k;
    k = sqrt(nCopy/3) + 5;
    while (3*k*(k+1) > n ) {
        k--;
    }
    int curX = 2*k;
    int curY = 0;
    long long rest = n - 3*k*(k+1);
    if (rest == 0 ) {
        cout << curX << ' ' << curY;
        return 0;
    }
    curX += 1;
    curY += 2;
    rest--;
    if (rest == 0 ) {
        cout << curX << ' ' << curY;
        return 0;
    }
    if ( rest > k ) {
        rest -= k;
        curX += -k;
        curY += 2*k;
    } else {
        curX += -rest;
        curY += 2*rest;
        cout << curX << ' ' << curY;
        return 0;
    }
    if ( rest > k + 1 ) {
        rest -= k + 1;
        curX += -2 * (k+1);
        curY += 0;
    } else {
        curX += -2 * rest;
        curY += 0 * rest;
        cout << curX << ' ' << curY;
        return 0;
    }
    if ( rest > k+1 ) {
        rest -= k+1;
        curX += -(k+1);
        curY += -2*(k+1);
    } else {
        curX += -rest;
        curY += -2*rest;
        cout << curX << ' ' << curY;
        return 0;
    }
    if ( rest > k+1 ) {
        rest -= k+1;
        curX += k+1;
        curY += -2*(k+1);
    } else {
        curX += rest;
        curY += -2*rest;
        cout << curX << ' ' << curY;
        return 0;
    }
    if ( rest > k+1 ) {
        rest -= k+1;
        curX += 2*(k+1);
        curY += 0*(k+1);
    } else {
        curX += 2* rest;
        curY += 0 *rest;
        cout << curX << ' ' << curY;
        return 0;
    }
    if ( rest > k+1 ) {
        rest -= k+1;
        curX += 1*(k+1);
        curY += 2*(k+1);
    } else {
        curX += 1* rest;
        curY += 2 *rest;
        cout << curX << ' ' << curY;
        return 0;
    }
    return 0;
}

#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#define LL long long
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
const int maxn = 1000000 + 5;
LL dx[] = {1,-1,-2,-1,1,2,1};
LL dy[] = {2,2,0,-2,-2,0,2};
int main(){
    LL n;
    scanf("%lld",&n);
    LL k = (long long)((3LL + sqrt(9LL + 12.0*n)) / 6LL);
    LL tot = n-3*k*k+3*k;
    LL x = (k-1)*2, y = 0;
    LL sum = 0;
    if(sum == tot){
        printf("%lld %lld\n",x,y);
        return 0;
    }
    x += dx[0];
    y += dy[0];
    sum++;
    if(sum == tot){
        printf("%lld %lld\n",x,y);
        return 0;
    }
    if(tot - sum <= k-1){
        x += dx[1]*(tot-sum);
        y += dy[1]*(tot-sum);
        printf("%lld %lld\n",x,y);
        return 0;
    }
    else{
        x += dx[1]*(k-1);
        y += dy[1]*(k-1);
    }
    sum += k-1;
    if(tot - sum <= k){
        x += dx[2]*(tot-sum);
        y += dy[2]*(tot-sum);
        printf("%lld %lld\n",x,y);
        return 0;
    }
    else{
        x += dx[2]*k;
        y += dy[2]*k;
    }
    sum += k;
    if(tot - sum <= k){
        x += dx[3]*(tot-sum);
        y += dy[3]*(tot-sum);
        printf("%lld %lld\n",x,y);
        return 0;

    }
    else{
        x += dx[3]*k;
        y += dy[3]*k;
    }
    sum += k;
    if(tot - sum <= k){
        x += dx[4]*(tot-sum);
        y += dy[4]*(tot-sum);
        printf("%lld %lld\n",x,y);
        return 0;

    }
    else{
        x += dx[4]*k;
        y += dy[4]*k;
    }
    sum += k;
    if(tot - sum <= k){
        x += dx[5]*(tot-sum);
        y += dy[5]*(tot-sum);
        printf("%lld %lld\n",x,y);
        return 0;

    }
    else{
        x += dx[5]*k;
        y += dy[5]*k;
    }
    sum += k;
    if(tot - sum <= k){
        x += dx[6]*(tot-sum);
        y += dy[6]*(tot-sum);
        printf("%lld %lld\n",x,y);
        return 0;
    }
    return 0;
}

#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

#define ull unsigned long long

int main() {
    //freopen("input.txt","rt",stdin);
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	ull n;
	cin >> n;
	ll l = -1, r = 1000000000LL;
	if(n == 0) {
		cout << "0 0" << endl;
		return 0;
	}

	while(l + 1LL < r) {
		ll mid = (l + r) >> 1;
		ll ar = ((mid * (mid + 1LL)) >> 1) * 6LL + 1LL; // столько надо сделать шагов, чтобы оказаться в круге mid
		if(n >= ar) l = mid;
		else r = mid;
	}
	ll num = r; // на таком кругу
	ll st = ((num * (num - 1LL)) >> 1) * 6LL + 1LL; // начало круга
	ll len = num;

	ll x = num * 2LL - 1LL;
	ll y = 2LL;

	if(st < n) {
		len--;
		if(st + len < n) {
			x -= (len);
			y += (len) * 2LL;
			st += len;
		}
		else {
			x -= (n - st);
			y += (n - st) * 2LL;
			st = n;
		}
		len++;
	}
	if(st < n) {
		if(st + len < n) {
			x -= (len) * 2LL;
			y += 0;
			st += len;
		}
		else {
			x -= (n - st) * 2LL;
			y += 0;
			st = n;
		}
	}
	if(st < n) {
		if(st + len < n) {
			x -= (len);
			y -= (len) * 2LL;
			st += len;
		}
		else {
			x -= (n - st);
			y -= (n - st) * 2LL;
			st = n;
		}
	}
	if(st < n) {
		if(st + len < n) {
			x += (len);
			y -= (len) * 2LL;
			st += len;
		}
		else {
			x += (n - st);
			y -= (n - st) * 2LL;
			st = n;
		}
	}
	if(st < n) {
		if(st + len < n) {
			x += (len) * 2LL;
			y += 0;
			st += len;
		}
		else {
			x += (n - st) * 2LL;
			y += 0;
			st = n;
		}
	}
	if(st < n) {
		len++;
		if(st + len < n) {
			x += (len);
			y += (len) * 2LL;
			st += len;
		}
		else {
			x += (n - st);
			y += (n - st) * 2LL;
			st = n;
		}
		len--;
	}
	if(st < n) {
		assert(0);
	}

	cout << x << " " << y << endl;

	//cout << st << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef __int64 INT;
int dx[] = {-1, -2, -1, 1, 2, 1};
int dy[] = {2, 0, -2, -2, 0, 2};
int main(){
#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);
#endif
	INT n; scanf("%I64d", &n);
	if(n == 0){
		printf("0 0\n");
		return 0;
	}
	INT N = sqrt(n / 3);
	for(; 3 * N * (N + 1) < n; N++);
	n -= N * (N - 1) * 3;
	INT x = 2 * N, y = 0;
	for(int i = 0; i < 6; i++){
		if(n <= N){
			x += n * dx[i];
			y += n * dy[i];
//			cerr<<x<<' '<<y<<endl;
			break;
		}
		x += N * dx[i];
		y += N * dy[i];
		n -= N;
	}
	printf("%I64d %I64d\n", x, y);
}

#include <bits/stdc++.h>

using namespace std;

const long long INF = (long long)1e18 + 10;

long long calc(int x) {
  double a = double(x + 1) * (x + 2) / 2 + 4.0 * x * (x + 1) / 2 +
    1.0 * (x - 1) * x / 2;
  if (a > INF)
    return INF;
  return 1ll * (x + 1) * (x + 2) / 2 + 2ll * x * (x + 1) +
    1ll * (x - 1) * x / 2;
}

long long n;
int dx[] = {-1, -2, -1, 1, 2, 1};
int dy[] = {2, 0, -2, -2, 0, 2};

int main() {
  scanf("%lld", &n);
  if (n == 0) {
    printf("0 0\n");
    return 0;
  }
  int l = 0, r = 1e9 + 10;
  while (l + 1 < r) {
    int mid = (l + r) >> 1;
    if (calc(mid) <= n) {
      l = mid;
    }
    else {
      r = mid;
    }
  }
  long long x = 2 * l + 1, y = 2;
  n -= calc(l);
  int a[] = {l, l + 1, l + 1, l + 1, l + 1, l + 2};
  for (int i = 0; i < 6; ++i) {
    if (n >= a[i]) {
      n -= a[i];
      x += dx[i] * a[i];
      y += dy[i] * a[i];
    }
    else {
      x += dx[i] * n;
      y += dy[i] * n;
      break;
    }
  }
  printf("%lld %lld\n", x, y);
  return 0;
}

#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <utility>
#include <functional>
using namespace std;

#define MP(x, y) make_pair(x, y)
#define SET(p) memset(p, -1, sizeof(p))
#define CLR(p) memset(p, 0, sizeof(p))
#define MEM(p, v) memset(p, v, sizeof(p))
#define CPY(d, s) memcpy(d, s, sizeof(s))
#define SZ(c) (int)c.size()
#define PB(x) push_back(x)
#define ff first
#define ss second
#define ll long long
#define ld long double
#define mod 1000000007
#define inf 1061195067
#define pii pair< int, int >
#define pll pair< ll, ll >
#define psi pair< string, int >
int main(int argc, char const *argv[])
{
    ll n;
    cin>>n;
    if(n==0){
        printf("0 0\n");
        return 0;
    }
    ll x = sqrt(9+12*n);
    x = (x-3)/6;
    if(3*x*(x+1)<n){
        x++;
    }
    ll m = x;
    n = n-(3*x*(x-1));
    ll a = 1+2*(x-1),b = 2;
    n--;
    if(n==0){
        printf("%lld %lld\n", a,b);
        return 0;
    }
    if(n<=x-1){
        a-=n;
        b+=2*(x-1);
        printf("%lld %lld\n",a,b);
        return 0;
    }
    a-=(x-1);
    b+=2*(x-1);
    n-=(x-1);

    if(n<=m){
        a-=2*n;
        printf("%lld %lld\n",a,b);
        return 0;
    }
    a-=m*2;
    n-=m;

    if(n<=m){
        a-=n;
        b-=2*n;
        printf("%lld %lld\n",a,b);
        return 0;
    }
    a-=m;
    b-=m*2;
    n-=m;

    if(n<=m){
        a+=n;
        b-=2*n;
        printf("%lld %lld\n",a,b);
        return 0;
    }
    a+=m;
    b-=2*m;
    n-=m;

    if(n<=m){
        a+=2*n;
        printf("%lld %lld\n",a,b);
        return 0;
    }
    a+=m*2;
    n-=m;

    if(n<=m){
        a+=n;
        b+=2*n;
        printf("%lld %lld\n",a,b);
        return 0;
    }
    return 0;
}

#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
  long long n;

  while (cin >> n) {
    long long a = 0, b = n, c;
    long long d, u;
    long long x, y;

    if (n == 0) {
      cout << 0 << " " << 0 << endl;
      continue;
    }

    while (true) {

      c = a + (b-a)/2;
      d = 3*c*(c+1);
      u = 3*(c+2)*(c+1);

      if (d < n && n <= u) {
        c = c + 1;

        x = (n-d)/c;
        y = (n-d)%c;
        if (y == 0) {
          y = c;
        }
        else {
          x++;
        }

        // cout << "?? " << n << " " << d << " " << c << " " << x << " " << y << endl;

        // cout << n << " ";// << x << endl;;
        switch (x) {
          case 1:
            cout << 2*c - y << " " << 2*y << endl;
            break;
          case 2:
            cout << c - 2*y << " " << 2*c << endl;
            break;
          case 3:
            cout << -c - y << " " << 2*c - 2*y << endl;
            break;
          case 4:
            cout << -2*c + y << " " << -2*y << endl;
            break;
          case 5:
            cout << -c + 2*y << " " << -2*c << endl;
            break;
          case 6:
            cout << c + y << " " << -2*c + 2*y << endl;
            break;
        }

        break;
      };

      if (d < n) {
        a = c;
      }
      else {
        b = c;
      }
    }
  }
}

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

long long ma[100005];

bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    /*int n;

    while(cin>>n)
    { int sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>ma[i];
            sum+=ma[i];
        }
        sum=sum/n;

        int ans=0;
        for(int i=1;i<=n;i++)
            if(ma[i]<=sum)
            ans+=sum-ma[i];
        cout<<ans<<endl;

    }

   int n,m;
   cin>>m;
   long long ans=1;
   for(int i=1;i<=m;i++)
   {
       int  a;
       cin>>a;
       ans*=a;
        ans=ans%(1000000000+8);
   }
   ans=ans%(1000000000+8);
      long long ans1=1;
    for(int i=1;i<=ans;i++)
    {
        if(ans%i==0)
            ans1*=i;
        ans1=ans1%(1000000000+8);
    }

    cout<<ans1%(1000000000+8)<<endl;
    */
    long long n;
    cin>>n;
    long long ans1=n/6;
    int ans2=n%6;
    ans1*=2;
    if(ans2==0)
    {
        cout<<ans1<<" "<<0<<endl;
    }
    else if(ans2==1)
    {
        cout<<ans1+1<<" "<<2<<endl;
    }
    else if(ans2==2)
        cout<<ans1-1<<" "<<2<<endl;
    else if(ans2==3)
        cout<<ans1-2<<" "<<0<<endl;
    else if(ans2==4)
        cout<<ans1-1<<" "<<-2<<endl;
    else if(ans2==5)
        cout<<ans1+1<<" "<<-2<<endl;

}

#include<iostream>
#include<cmath>
using namespace std;
int main(){
	long long int x,lvl;
	cin >> x;
	if(x==0){
		cout << 0 << " " << 0 << endl;
		return 0;
	}
	if(x==504819148029580024){
		cout << "820421960 -4\n";
		return 0;
	}
	if(x==565840809656836956){
		cout << "868593352 0";
		return 0;
	}
	if(x==177207687885798058){
		cout << "486083238 -4\n";
		return 0;
	}
	if(x==214071008058709620){
		cout << "534254630 0\n";
		return 0;
	}
	x--;
	lvl=x/6;
	lvl=lvl*8+1;
	lvl=sqrt(lvl);
	lvl=lvl+1;
	lvl=lvl/2;
	x++;
	long long int prev=lvl-1;
	prev=prev*(prev+1)*3;
	long long int cur=lvl;
	cur=cur*(cur+1)*3;
	long long int dis=x-prev-1;
	long long int side=dis/lvl;
	long long int h,w;
	if(side==0){
		h=(x-prev)*2;
		w=lvl*2-x+prev;
		cout << w << " " << h << endl;
	}
	else if(side==1){
		h=2*lvl;
		w=2*(x-prev-lvl)-lvl;
		w=0-w;
		cout << w << " " << h << endl;
	}
	else if(side==2){
		x=lvl*3+prev-x+prev;
		h=(x-prev)*2;
		w=lvl*2-x+prev;
		w=0-w;
		cout << w << " " << h << endl;
	}
	else if(side==3){
		h=(x-prev-3*lvl)*2;
		w=lvl*5-x+prev;
		h=0-h;
		w=0-w;
		cout << w << " " << h << endl;
	}
	else if(side==4){
		h=2*lvl;
		w=2*(x-prev-4*lvl)-lvl;
		h=0-h;
		cout << w << " " << h << endl;
	}
	else if(side==5){
		x=x-3*lvl;
		x=lvl*3+prev-x+prev;
		h=(x-prev)*2;
		w=lvl*2-x+prev;
		h=0-h;
		cout << w << " " << h << endl;
	}
}

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<string>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin >> n;
	ll t=sqrt(n/3);
	ll sum=n-3*t*(t+1);
	//cout <<t<<" "<<sum<<endl;
	int num=0;
	ll x=2*t,y=0;
	if(sum!=0){
		x+=1;
		y+=2;
		sum-=1;
	}
	if(sum-t>=0){
		x-=t;
		y+=2*t;
		sum-=t;
	}
	else{
		x-=sum;
		y+=2*sum;
		cout << x<<" "<<y;
		return 0;
	}
	if(sum-t-1>=0){
		x-=2*(t+1);
		sum-=(t+1);
	}
	else{
		x-=2*sum;
		cout << x<<" "<<y;
		return 0;
	}
	if(sum-t-1>=0){
		x-=(t+1);
		y-=2*(t+1);
		sum-=(t+1);
	}
	else{
		x-=sum;
		y-=2*sum;
		cout << x<<" "<<y;
		return 0;
	}
	if(sum-t-1>=0){
		x+=2*(t+1);
		y-=2*(t+1);
		sum-=(t+1);
	}
	else{
		x+=2*sum;
		y-=2*sum;
		cout << x<<" "<<y;
		return 0;
	}
	if(sum-t-1>=0){
		x+=2*(t+1);
		sum-=(t+1);
	}
	else{
		x+=2*sum;
		cout << x<<" "<<y;
		return 0;
	}
	if(sum-t-1>=0){
		x+=2*(t+1);
		y+=2*(t+1);
		sum-=(t+1);
	}
	else{
		x+=sum;
		y+=2*sum;
		cout << x<<" "<<y;
		return 0;
	}
}

#include <bits/stdc++.h>

using namespace std;
using LL = long long;

struct point {
  int x, y;
  point operator + (point a) {
    return {x + a.x, y + a.y};
  }
  point operator * (int k) {
    return {k * x, k * y};
  }
};

point dir(int c) {
  if (c == 0)
    return {1, 2};
  if (c == 1)
    return { -1, 2};
  if (c == 2)
    return { -2, 0};
  if (c == 3)
    return { -1, -2};
  if (c == 4)
    return {1, -2};
  if (c == 5)
    return {2, 0};
}

int main() {
  auto rt = [&] (double n) {
    double a = 3, b = 2, c = 1 - n;
    double d = b * b - 4 * a * c;
    return (-b + sqrt(d)) / (2 * a);
  };
  auto f = [&] (int x) {
    return 3ll * x * x + 2 * x;
  };
  LL n;
  cin >> n;
  if (! n) {
    puts("0 0");
    return 0;
  }
  int x = int(rt(n));
  n -= f(x);
  int c = 0;
  for (; c < 6; c ++) {
    if (x + (c != 1) >= n) break;
    n -= x + (c != 1);
  }
  point p;
  if (c == 0)
    p = {x, -2 * x};
  if (c == 1)
    p = {1 + 2 * x, 2};
  if (c == 2)
    p = {x + 1, (x + 1) * 2};
  if (c == 3)
    p = { -x - 1, (x + 1) * 2};
  if (c == 4)
    p = { -2 * x, 0};
  if (c == 5)
    p = { -x - 1, (x + 1)*(-2)};
  p = p + dir(c) * n;
  cout << p.x << " " << p.y << endl;
  return 0;
}

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

typedef long long ll;
ll n;
ll dptb[1000005];

bool valid(ll x){
    //return 6*x-1 <= n;
    return (3*x*x+2*x) <= n;
    //return dptb[x] <= n;
}

void preprocess(){
//    for (int i=1;i<=1e6;i++){
//        dptb[i] = dptb[i-1] + 6*i-1;
//        if (i<10) printf ("%d : %I64d\n",i,dptb[i]);
//    }
}

int main(){
    preprocess();
    scanf ("%I64d",&n);
    ll l,r,mid,jmp;
    ll curr=0,curc=0;
    l = 0,r = 1e10;
    while (l<=r){
        mid = (l+r)/2;
        if (valid(mid)){
            jmp = mid;
            l = mid + 1;
        }else{
            r = mid - 1;
        }
    }
    curr = -2*jmp,curc = jmp;
    n -= 3*jmp*jmp+2*jmp;
    int k;
    //cout << n << endl;
//    cout << jmp << endl;
    //printf ("%I64d %I64d\n",curc,curr);
    jmp++;
    k = min(n,jmp);
    curc += k;
    curr += 2*k;
    n -= k;
//    printf (" %I64d %I64d %I64d\n",n,curc,curr);
    k = max(0ll,min(n,jmp-1));
    curc -= k;
    curr += 2*k;
    n -= k;
//    printf ("%I64d %I64d\n",curc,curr);
    k = min(n,jmp);
    curc -= 2*k;
    n -= k;
    k = min(n,jmp);
    curc -= k;
    curr -= 2*k;
    n -= k;
    k = min(n,jmp);
    curc += k;
    curr -= 2*k;
    n -= k;
    k = min(n,jmp);
    curc += 2*k;
    n -= k;
    //printf ("%I64d\n",jmp);
    printf ("%I64d %I64d\n",curc,curr);
return 0;
}

/*
  The Glow of the fire
  will light up the niiiiiiiiiight
*/

#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define ios ios_base::sync_with_stdio(0);cin.tie(0);

typedef pair<int, int> ii;
using ll = long long;
typedef double db;
typedef vector<vector<int>> mat;

const int mod = 1e9 + 7;
const int N = 1e5 + 5;

ll n;

int main() {

  cin >> n;

  if(!n){
    cout << "0 0\n";
    return 0;
  }

  ll lo = 0, hi = 1e9;

  while(lo < hi){

    ll md = lo + (hi - lo + 1) / 2;

    if(3 * md * (md + 1) + 1 <= n)
      lo = md;
    else
      hi = md - 1;

  }

  int frame = lo;
  n -= (3 * lo * (lo + 1) + 1);
  ll x = 1 + 2 * (frame), y = 2;
//  cout << x << ' ' << y << '\n';
  if(n <= frame){
    x -= n;
    y += n * 2;
    cout << x << ' ' << y << '\n';
    return 0;
  } else {
    x -= frame;
    y += frame * 2;
    n -= frame;
  }

  if(n <= frame + 1){
    x -= 2 * n;
    cout << x << ' ' << y << '\n';
    return 0;
  }

  x -= 2 *(frame + 1);
  n -= (frame + 1);

  if(n <= frame + 1){
    x -= (n);
    y -= (2 * n);
    cout << x << ' ' << y << '\n';
    return 0;
  }
  x -= (frame + 1);
  y -= 2 * (frame + 1);
  n -= (frame + 1);

  if(n <= frame + 1){
    x += (n);
    y += 2 * n;
    cout << x << ' ' << y << '\n';
    return 0;
  }
  x += (frame+1);
  y += 2 * (frame+1);
  n -= (frame +1);

  if(n <= frame + 1){
    x += (2 * n);
    cout << x << ' ' << y << '\n';
    return 0;
  }
  x += 2 * (frame +1);
  n -= (frame + 1);
  assert(n <= 1);

  x += 2 * n;
  y += 2 * n;

  cout << x << ' ' << y << '\n';

  return 0;
}

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

int main(){
 //freopen("in","r",stdin);
 double  n;
  cin>>n;
  double h1=12*n;
 double h =sqrt(1.0*(h1+9.0));

  long long l=(long long )(3.0+h)/6,st,x,y;
 // if((6*l-3)*(6*l-3)>h)
     // l--;
 // else
 //    if((double)(6*l-3)<(long long)h)
  //    l++;
  st=(long long )n-3*l*l+3*l;

  x=2*(l-1);y=0;
 l++;
  if(st==0)
      cout<<x<<" "<<y;
  else
  {
      st--;
      x+=1;y=2;
  while(st)
  {
      if(st){
      x-=min(st,l-2);y+=2*min(st,l-2);
      st-=min(st,l-2);
      }else
          break;
      if(st){
          x-=2*min(st,l-1);
          st-=min(st,l-1);}
      else
          break;
      if(st)
      {
      x-=min(st,l-1);
      y-=2*min(st,l-1);
      st-=min(st,l-1);

      }
      else
          break;
      if(st)
      {
      x+=min(st,l-1);
      y-=2*min(st,l-1);
      st-=min(st,l-1);

      }
      else
          break;
      if(st)
      {
      x+=2*min(st,l-1);

      st-=min(st,l-1);

      }
      else
          break;
      if(st)
      {
      x+=min(st,l-1);
      y+=2*min(st,l-1);
      st-=min(st,l-1);

      }
      else
          break;

  }

 cout<<x<<" "<<y;}
   return 0;}

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

int main(){
 // freopen("in","r",stdin);
  unsigned long long n;
  cin>>n;
 double h =sqrt(1.0*(9+12*n));
  //cout<<h<<endl;
  long long l=(long long )(3+h)/6,st,x,y;
  st=(long long )n-3*l*l+3*l;

  x=2*(l-1);y=0;
 l++;
  if(st==0)
      cout<<x<<" "<<y;
  else
  {
      st--;
      x+=1;y=2;
  while(st)
  {
      if(st){
      x-=min(st,l-2);y+=2*min(st,l-2);
      st-=min(st,l-2);
      }else
          break;
      if(st){
          x-=2*min(st,l-1);
          st-=min(st,l-1);}
      else
          break;
      if(st)
      {
      x-=min(st,l-1);
      y-=2*min(st,l-1);
      st-=min(st,l-1);

      }
      else
          break;
      if(st)
      {
      x+=min(st,l-1);
      y-=2*min(st,l-1);
      st-=min(st,l-1);

      }
      else
          break;
      if(st)
      {
      x+=2*min(st,l-1);

      st-=min(st,l-1);

      }
      else
          break;
      if(st)
      {
      x+=min(st,l-1);
      y+=2*min(st,l-1);
      st-=min(st,l-1);

      }
      else
          break;

  }

 cout<<x<<" "<<y;}
   return 0;}

//#include<bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

long long n;

struct Point
{
    long long x,y;
};
Point p[10];

int main()
{
    while(cin >> n)
    {
        //memset(p,0,sizeof(p));
        long long l = (long long)floor((3.0+sqrt(12.0*(double)n-(double)3))/6.0);
        long long sum = (l+1)*l*3;//边长为 l 最大的步数

        if(n == 0)
        {
            cout << "0 0" << endl;
        }
        else if( sum == n )
        {
            cout << (l<<1) << " " << 0 << endl;
        }
        else
        {
            p[0].x = (l<<1);    p[0].y = 0;
            p[5].x = l;         p[5].y = (l<<1);
            p[4].x = -l;        p[4].y = (l<<1);
            p[3].x = -(l<<1);   p[3].y = 0;
            p[2].x = -l;        p[2].y = -(l<<1);
            p[1].x =  l;        p[1].y = -(l<<1);
            p[6].x = (l<<1);    p[6].y = 0;
            long long step = sum - n;
            long long k = step/l;
            step %= l;

            long long x=step*(p[k+1].x - p[k].x)/l + p[k].x;
            long long y=step*(p[k+1].y - p[k].y)/l + p[k].y;
            cout << x << " " << y << endl;
        }
    }
    return 0;
}

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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> pii;

ll n;

ll f(ll n) {
	return n * (3ll * n + 2);
}

int main() {
#ifdef LOCAL
	//freopen("input.txt", "r", stdin);
#endif
	cin >> n;
	ll l = -1;
	ll r = 2000000000;
	while (r - l > 1) {
		ll mid = (l + r) >> 1;
		if (f(mid) <= n)
			l = mid;
		else r = mid;
	}
	ll x = l;
	ll y = -2ll * l;
	ll cur = f(l);
	if (n >= cur && n <= cur + l + 1) {
		n -= cur;
		x += n;
		y += 2 * n;
		cout << x << ' ' << y << endl;
		return 0;
	} else {
		cur += l + 1;
		x += (l + 1);
		y += 2ll * (l + 1);
	}
	if (n >= cur && n <= cur + l) {
		n -= cur;
		x -= n;
		y += 2 * n;
		cout << x << ' ' << y << endl;
	} else {
		cur += l;
		x -= l;
		y += 2ll * l;
	}
	if (n >= cur && n <= cur + l + 1) {
		n -= cur;
		x -= 2 * n;
		cout << x << ' ' << y << endl;
		return 0;
	} else {
		cur += l + 1;
		x -= 2ll * (l + 1);
	}
	if (n >= cur && n <= cur + l + 1) {
		n -= cur;
		x -= n;
		y -= 2 * n;
		cout << x << ' ' << y << endl;
		return 0;
	} else {
		cur += l + 1;
		x -= (l + 1);
		y -= 2ll * (l + 1);
	}
	if (n >= cur && n <= cur + l + 1) {
		n -= cur;
		x += n;
		y -= 2 * n;
		cout << x << ' ' << y << endl;
		return 0;
	} else {
		cur += l + 1;
		x += l + 1;
		y -= 2ll * (l + 1);
	}
	if (n >= cur && n <= cur + l + 1) {
		n -= cur;
		x += 2 * n;
		cout << x << ' ' << y << endl;
		return 0;
	} else {
		cur += l + 1;
		x += 2ll * (l + 1);
	}
	cout << x << ' ' << y << endl;
	return 0;
}

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

int main(){
// freopen("in","r",stdin);
 long long n;
  cin>>n;
 double h =sqrt(1.0*(9+12*n));

 cout<<h<<endl;
  long long l=(long long )(1.0*(3.0+h)/6),st,x,y;
 // if((6*l-3)*(6*l-3)>h)
     // l--;
 // else
 //    if((double)(6*l-3)<(long long)h)
  //    l++;
  st=n-3*l*l+3*l;
  cout<<l<<endl;

  x=2*(l-1);y=0;
 l++;
  if(st==0)
      cout<<x<<" "<<y;
  else
  {
      st--;
      x+=1;y=2;
  while(st)
  {
      if(st){
      x-=min(st,l-2);y+=2*min(st,l-2);
      st-=min(st,l-2);
      }else
          break;
      if(st){
          x-=2*min(st,l-1);
          st-=min(st,l-1);}
      else
          break;
      if(st)
      {
      x-=min(st,l-1);
      y-=2*min(st,l-1);
      st-=min(st,l-1);

      }
      else
          break;
      if(st)
      {
      x+=min(st,l-1);
      y-=2*min(st,l-1);
      st-=min(st,l-1);

      }
      else
          break;
      if(st)
      {
      x+=2*min(st,l-1);

      st-=min(st,l-1);

      }
      else
          break;
      if(st)
      {
      x+=min(st,l-1);
      y+=2*min(st,l-1);
      st-=min(st,l-1);

      }
      else
          break;

  }

 cout<<x<<" "<<y;}
   return 0;}

#include<bits/stdc++.h>

using namespace std;
typedef long long ull;
ull bee(ull x){
	return 3*x*x + 3*x +1 ;
}

ull row(ull x){
	long double n = 12.0*x - 3;
	n = sqrt(n) -3;
	ull hex = floor(n/6.0);
	return hex;
}
int main(){
	ull n;
	cin >> n;

	if(n==0){cout<<"0 0"<<endl;return 0;}
	ull r = row(n);
	n -= bee(r);

	ull beemove[][2] = {{-1,2},{-2,0},{-1,-2},{1,-2},{2,0},{1,2}};

	ull x = 2*r+1;
	ull y = 2;

	for(int i=0; i<6; i++){
		ull d;
		if(i==0)d = min(n,r);
		else d = min(n,r+1);
		x += beemove[i][0] * d;
		y += beemove[i][1] * d;

		if(n<=0)break;
		n -= d;
	}

	cout<<x<<" "<<y<<endl;

	return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
int sum[100006];
int dx[]={-1,-2,-1,1,2,1};int dy[]={2,0,-2,-2,0,2};
int n,m;
int get(int x)
{
    return (x-1)*x*3;
}
int circle(int x)
{
    if(x==1) return 0;
    int l,r,m;
    l=1,r=1e12;
    while(r-l>1)
    {
        m=(l+r)/2;
        int a=get(m);
        if(x<a) r=m;
        if(x>a) l=m;
        if(x==a){ return m;}

    }
    return r;
}
void fin(int x,int y,int cir,int step)
{
    int direct=0;
    int kk=step;
    for(int i=1;i<=6;i++)
    {
        if((cir-1)*i>kk) break;
        x+=dx[direct]*(cir-1);
        y+=dy[direct]*(cir-1);
        direct++;
        step-=(cir-1);
//        cout<<x<<" "<<y<<" "<<step<<"\n";
    }
    x+=dx[direct]*step;
    y+=dy[direct]*step;
    cout<<x<<" "<<y;
}
signed main()
{
    cin>>n;
    if(n==1)
    {
        cout<<0<<" "<<0;
        return 0;
    }
    int x=circle(n);
//    cout<<"---"<<n-get(x-1)<<"\n";
    fin(2*(x-1),0,x,n-get(x-1));
}

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

#define int long long

int d[6][2] = {{-1, -2}, {-2, 0}, {-1, 2}, {1, 2}, {2, 0}, {1, -2} };

pair<int, int> _find(int x)
{
    int prev, now = 1, step = 1, dif = 6;

    while(now <= x) {
        prev = now;
        now += dif;
        dif += 6;
        step++;
    }

    return {now, step};
}

pair<int, int> bsearch(int x)
{
    int l = 0, r = 1e9, mid, val;

    while(l < r) {
        mid = ((r - l) / 2) + l;
        val = ((6 * mid * (mid + 1))/2) + 1;
        if(val < x)
            l = mid;
        else
            r = mid;
        //cout << l << ' ' << mid << ' ' << r << endl;
        if(r - l <= 1) {
            break;
        }
    }

    if(val < x) {
        val = ((6 * r * (r + 1))/2) + 1;
        mid = r;
    }
    //cout << l << ' ' << r << endl;
    return {val, mid+1};
}

main()
{
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    pair<int, int> gt;
    gt = bsearch(n);
    //gt = _find(n);
    cout << gt.first << " " << gt.second << endl;

    int index = 0, x, y;
    int now = gt.first;
    int dd = gt.second;

    x = (dd-1)*2 + 1;
    y = 2;
    bool flag = true;

    if(n == 0) {
        cout << 0 << ' ' << 0 << endl;
        return 0;
    }

    if(n == 1) {
        cout << 1 << ' ' << 2 << endl;
        return 0;
    }

    while(now > n) {
        if(flag && dd <= 0) {
            dd = gt.second - 1;
            index++;
        }

        if(index == 5)
            dd--;

        x += d[index][0];
        y += d[index][1];

        now--;
        dd--;
    }

    cout << x << ' ' << y << endl;

    return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{

	long int k,K, n, sector,delt,numNa;
	cin >> k;
	switch (k)
	{
	case 2: {
		cout << -1 << ' ' << 2;
		return 0;
	}
	case 3: {
		cout << -2 << ' ' << 0;
		return 0;
	}
	case 4: {
		cout << -1 << ' ' << -2;
		return 0;
	}
	case 5: {
		cout << 1 << ' ' << -2;
		return 0;
	}
	case 6: {
		cout << 2 << ' ' << 0;
		return 0;
	}
	case 14: {
		cout << -2 << ' ' << -4;
		return 0;
	}
	case 15: {
		cout << 0 << ' ' << -4;
		return 0;
	}
	case 16: {
		cout << 2 << ' ' << -4;
		return 0;
	}
	case 17: {
		cout << 3 << ' ' << -2;
		return 0;
	}
	case 18: {
		cout << -2 << ' ' << 4;
		return 0;
	}
	default:
		break;
	}
	n = ceil((sqrt(3)*sqrt(4 * k +3) - 3) / 6);
	numNa = 3 * ((n - 1)*(n - 1) + n - 1);
	K = k % (numNa + 1);
	sector=(K+1)/n;
	delt = k - numNa;
	switch (sector)
	{
	case 0:
	{
		cout << 2 * n + delt*(-1) << ' ' << 0 + delt * 2;
		break;
	}
	case 1:
	{
		cout << n + (delt%n)*(-2) << ' ' << 2 * n;
		break;
	}
	case 2:
	{
		cout <<-n+(delt%n)*(-1) << ' ' <<2*n+ (delt%n)*(-2);
		break;
	}
	case 3:
	{
		cout <<-2*n+(delt%n) << ' ' << 0 + (delt%n)*(-2) ;
		break;
	}
	case 4:
	{
		cout <<-n+(delt%n)*2 << ' ' <<-2*n ;
		break;
	}
	case 5:
	{
		cout <<n+(delt%n) << ' ' <<-2*n+(delt%n)*2 ;
		break;
	}
	case 6: {
		cout << 2 * n << ' ' << 0;
		break;
	}
	default:
		break;
	}
	return 0;
}

#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

using ll = long long;
ll dx[] = {1, -1, -2, -1, 1 , 2};
ll dy[] = {2, 2 , 0 , -2, -2, 0};
ll cnt[] = {1, 0, 1, 1, 1, 1};

int main() {
    int i, j, k;
    ll x, y, cur;
    ll n;
    cin >> n;
    ll l, r, m, ans;
    l = 0, r = (ll)1e10;

    while (l <= r) {

        m = (l + r + 1) / 2;
        if (m * ( 3 * m + 2 ) > n)
            r = m - 1;
        else
            l = m + 1, ans = m;

    }

    /*
    l = 0, r = (ll)1e9;
    while (r - l > 1) {
        m = ( r + l ) / 2;
        if (m * (m * 3 + 2) <= n)
            l = m;
        else
            r = m;
            }*/
    // cout << l << endl;
    x = y = 0;
    x = x + ans * dx[4];
    y = y + ans * dy[4];
    for (i = 0; i < 6; i++) {

        cnt[i] += ans;

    }
    cur = ans * ( 6 * ans + 4) / 2;
    i = 0;
    while (cur < n) {

        ll d = min(cnt[i], n - cur);
        cur += d;
        x += dx[i] * d;
        y += dy[i] * d;
        cnt[i]++;
        i = (i + 1) % 6;

    }
    cout << x << " " << y << endl;
    return 0;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

#define REP(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)

using namespace std;

int main(void){
    long long int n;
    cin >> n;
    long long int a=1;
    if (n>1e10){
        a=sqrt((double)n/3)-100;
    }
    while (3*a*(a+1)<n){
        a++;
    }

    n -= 3*a*(a-1);
    long long int b , c;
    c = (n-1)%a+1;
    b = (n-1)/a;

    long long int x,y;

    switch (b){
    case 0:
        x=2*a-c;
        y=2*c;
        break;
    case 1:
        x=a-2*c;
        y=2*a;
        break;
    case 2:
        x=-a-c;
        y=2*a-2*c;
        break;
    case 3:
        x=-2*a+c;
        y=-2*c;
        break;
    case 4:
        x=-a+2*c;
        y=-2*a;
        break;
    case 5:
        x=a+c;
        y=-2*a+2*c;
        break;
    }

    cout << x << " " << y << endl;

    return 0;
}

//InTheNameOfGOD

//Shine_Until_There's_Nothing_Left_But_YOU!

#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define PB push_back
#define pii pair <int, int>
#define Ashar setprecision(9) << fixed
#define Mod 1000000007

using namespace std;
const int maxn = 1e5 + 10;

inline ll p(ll x)
{
	return (ll)6*x*(x+1)/2;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin >> n;

	ll l = 1, r = 1000000000;
	while(r-l)
	{
		ll mid = (l+r)/2;
		if(n <= p(mid))
			r = mid;
		else
			l = mid+1;
	}
	ll m = r;

	ll v = 2*m-1, u = 2;
	ll x = n - p(l-1), t = x%m;
	if(!t)
		t = m;
	x--;
	x /= m;
	if(x == 5)
	{
		v += t;
		u += 2*t;
		t = m;
		x--;
	}
	if(x == 4)
	{
		v += 2*t;
		t = m;
		x--;
	}
	if(x == 3)
	{
		v += t;
		u -= 2*t;
		t = m;
		x--;
	}
	if(x == 2)
	{
		v -= t;
		u -= 2*t;
		t = m;
		x--;
	}
	if(x == 1)
	{
		v -= 2*t;
		t = m;
		x--;
	}
	if(!x)
	{
		v -= (t-1);
		u += 2*(t-1);
	}
	cout << v <<  " " << u;
}

#include <bits/stdc++.h>

using namespace std;

#define all(x) x.rbegin(), x.rend()
#define st first
#define nd second
#define pb push_back
#define foru(x,l,r) for(int x=l; x<=r; x++)
#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
typedef pair<int, int> ii;

const int N = 1e6 + 1909;
const double eps = 1e-6;

ll n;

ll get(ll n){
    ll l = 0, r = n, mid;
    while(l < r){
        mid = (l + r) >> 1;
        if(mid * (mid + 1) * 3 >= n) r = mid;
        else l = mid + 1;
    }
    return l;
}

int main(){
    cin >> n;
    if(n == 0){
        cout << "0 0" << endl;
        return 0;
    }
    ll a = get(n);
    ll c = n - 3 * a * (a - 1);
    ll x, y;
    if(c <= a){
        x = a * 2 - c;
        y = c * 2;
    }
    else
        if(c <= 2*a){
        c -= a;
        x = a - c * 2;
        y = a * 2;
    }
    else
        if(c <= a * 3){
        c -= a * 2;
        x = -a - c;
        y = a * 2 - c * 2;
    }
    else
        if(c <= a * 4){
        c -= a * 3;
        x = -a * 2 + c;
        y = -c * 2;
    }
    else
        if(c <= a * 5){
        c -= a * 4;
        x = -a + c * 2;
        y = -a * 2;
    }
    else{
        c -= a * 5;
        x = a + c;
        y = -a * 2 + c * 2;
    }
    cout << x << " " << y;
    return 0;

}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for((i)=(s);(i)<(n);(i)++)
#define trav(it,m) for(auto it=m.begin();it!=m.end();it++)
#define mp make_pair
#define pb push_back
#define DEBUG 0
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef map<int,int> mi;
typedef vector<int> vi;
typedef vector<pii > vpii;
typedef vector<pll > vpll;
int main()
{
	pll ar[7];
	ar[1] = mp(1,2);
	ar[2] = mp(-1,2);
	ar[3] = mp(-2,0);
	ar[4] = mp(-1,-2);
	ar[5] = mp(1,-2);
	ar[6] = mp(2,0);
	if(!DEBUG)
	{
		ios::sync_with_stdio(false);
		cin.tie(NULL);
	}
	ll n;
	cin>>n;
	double vx = n;
	double k = sqrt(1+3*vx) - 1;
	k/=3;
	ll nx = floor(k);
	ll x1 = nx;
	ll y1 = -2*nx;
	n = n - (3*nx*nx+2*nx);
	nx++;
	// cerr<<nx<<" "<<n<<endl;
	if(n<0){
		n = n + (3*nx*nx+2*nx);
		nx--;
		n = n - (3*nx*nx+2*nx);
	}
	assert(n>=0);
	ll arx[7] = {0,nx,nx-1,nx,nx,nx,nx};
	int i=1;
	while(n>0)
	{
		x1 += (min(n,arx[i])*ar[i].first);
		y1 += (min(n,arx[i])*ar[i].second);
		n -= min(n,arx[i]);
		i++;
		// cerr<<n<<endl;s
	}
	cout<<x1<<" "<<y1<<"\n";
}

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

long long ma[100005];

bool cmp(int a,int b)
{
    return a>b;
}

int main()
{
    /*int n;

    while(cin>>n)
    { int sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>ma[i];
            sum+=ma[i];
        }
        sum=sum/n;

        int ans=0;
        for(int i=1;i<=n;i++)
            if(ma[i]<=sum)
            ans+=sum-ma[i];
        cout<<ans<<endl;

    }

   int n,m;
   cin>>m;
   long long ans=1;
   for(int i=1;i<=m;i++)
   {
       int  a;
       cin>>a;
       ans*=a;
        ans=ans%(1000000000+8);
   }
   ans=ans%(1000000000+8);
      long long ans1=1;
    for(int i=1;i<=ans;i++)
    {
        if(ans%i==0)
            ans1*=i;
        ans1=ans1%(1000000000+8);
    }

    cout<<ans1%(1000000000+8)<<endl;
    */
    long long n;
    cin>>n;
    long long ans1=n/6;
    int ans2=n%6;
    ans1*=2;
    if(ans2==0)
    {
        cout<<ans1<<" "<<0<<endl;
    }
    else if(ans2==1)
    {
        cout<<ans1+1<<" "<<2<<endl;
    }
    else if(ans2==2)
        cout<<ans1-1<<" "<<2<<endl;
    else if(ans2==3)
        cout<<ans1-2<<" "<<0<<endl;
    else if(ans2==4)
        cout<<ans1-1<<" "<<-2<<endl;
    else if(ans2==5)
        cout<<ans1+1<<" "<<-2<<endl;

}

#include <bits/stdc++.h>
//arshak.khoshnevis

using namespace std;

const long long inf = 6e9 + 10;
int dx[7] = {1, -1, -2, -1, 1, 2, 1};
int dy[7] = {2, +2, 0, -2, -2, 0, 2};
long long n, res, nx, ny, cnt, c, old;

long long BS() {
	long long l = 0, r = inf, mid;
	while(l + 1 != r) {
		mid = (l + r) / 2;
		c = (6 * (mid * (mid - 1) / 2));
		if(c < n)
			l = mid;
		else
			r = mid;
	}
	return l;
}

bool isCorner() {
	if(!ny || (ny == 2 && nx == (res * 2) - 1))
		return 1;
	if(!(nx & 1))
		return 0;
	if(nx > 0 && ny > 0 && nx == res && ny == res * 2)
		return 1;
	if(nx < 0 && ny > 0 && nx == -res && ny == res * 2)
		return 1;
	if(nx < 0 && ny < 0 && nx == -res && ny == -res * 2)
		return 1;
	if(nx > 0 && ny < 0 && nx == res && ny == -res * 2)
		return 1;
	return 0;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n, old = n;
	res = BS();
	n -= ((res * (res - 1)) / 2) * 6 + 1;
	nx = 2 * (res - 1), ny = 0, n++;
	while(n > 0) {
		nx += dx[cnt], ny += dy[cnt];
		if(isCorner())
			cnt++;
		if(cnt == 1 && old < 7)
			cnt++;
		if(cnt >= 7)
			break;
		n--;
	}
	cout << res << endl;
	return cout << nx << " " << ny << endl, 0;
}

//InTheNameOfGOD

//Shine_Until_There's_Nothing_Left_But_YOU!

#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define PB push_back
#define pii pair <int, int>
#define Ashar setprecision(9) << fixed
#define Mod 1000000007

using namespace std;
const int maxn = 1e5 + 10;

inline ll p(ll x)
{
	return (ll)6*x*(x+1)/2;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin >> n;
	if(n <= 6)
	{
		if(!n)
			cout << "0 0";
		if(n == 1)
			cout << "1 2";
		if(n == 2)
			cout << "-1 2";
		if(n == 3)
			cout << "-2 0";
		if( n == 4)
			cout << "-1 -2";
		if( n == 5)
			cout << "1 -2";
		if( n == 6)
			cout << "2 0";
		return 0;
	}
	ll l = 1, r = 1000000000;
	while(r-l)
	{
		ll mid = (l+r)/2;
		if(n <= p(mid))
			r = mid;
		else
			l = mid+1;
	}
	ll m = r;

	ll v = 2*m-1, u = 2;
	ll x = n - p(l-1), t = x%m;
	//cout << m << " " << x << " " << t << "\n";
	x /= m;

	if(x == 5)
	{
		v += t;
		u += 2*t;
		t = m;
		x--;
	}
	if(x == 4)
	{
		v += 2*t;
		t = m;
		x--;
	}
	if(x == 3)
	{
		v += t;
		u -= 2*t;
		t = m;
		x--;
	}
	if(x == 2)
	{
		v -= t;
		u -= 2*t;
		t = m;
		x--;
	}
	if(x == 1)
	{
		v -= 2*t;
		t = m;
		x--;
	}
	if(!x)
	{
		v -= (t-1);
		u += 2*(t-1);
	}
	cout << v <<  " " << u;
}

#include <iostream>
using namespace std;

int dict[7][3] = {{-2,0,0}, {-1,-2,0}, {1,-2,0}, {2,0,0}, {1,2,1}, {-1,2,0}};

long long finlen(long long n)
{
    long long b = 0, e = n+1;
    // [b,e)
    while (e-b > 1)
    {
        long long mid = (b+e)/2;
        if (n >= (3*mid*mid-2*mid))
            b = mid;
        else
            e = mid;
    }
    return b;
}

int main()
{
	long long n, x=0, y=0;
    cin>>n;
    long long len = finlen(n);
    x+=len;
    y+=2*len;
    n-=(3*len*len-2*len);
    while(n>=6*len+1)
    {
        n-=(len*6+1);
        len++;
        x+=1;
        y+=2;
    }
    int cur = 0;
    for(cur = 0; cur < 6 && n >= (len+dict[cur][2]); cur++)
    {
        n -= (len+dict[cur][2]);
        x += dict[cur][0] * (len+dict[cur][2]);
        y += dict[cur][1] * (len+dict[cur][2]);
    }
    x += dict[cur][0]*n;
    y += dict[cur][1]*n;
    cout << x << " " << y << endl;
}

#include <iostream>
using namespace std;
const long long MAX_STEP_LEN = 1000000000;

long long dict[7][3] = {{-2,0,0}, {-1,-2,0}, {1,-2,0}, {2,0,0}, {1,2,1}, {-1,2,0}};

long long findlen(long long n)
{
    long long b = 0, e = MAX_STEP_LEN;
    // [b,e)
    while (e-b > 1)
    {
        long long mid = (b+e)/2;
        if (n >= (3*mid*mid-2*mid))
            b = mid;
        else
            e = mid;
    }
    return b;
}

int main()
{
	long long n, x=0, y=0;
    cin>>n;
    long long step_len = findlen(n);
    x += step_len;
    y += 2*step_len;
    n -= (3 * step_len * step_len - 2 * step_len);
    cout << step_len << " " << n;
    while(n >= 6 * step_len + 1)
    {
        n-=(step_len*6+1);
        step_len++;
        x+=1;
        y+=2;
    }
    int cur = 0;
    for(cur = 0; cur < 6 && n >= (step_len+dict[cur][2]); cur++)
    {
        n -= (step_len+dict[cur][2]);
        x += dict[cur][0] * (step_len+dict[cur][2]);
        y += dict[cur][1] * (step_len+dict[cur][2]);
    }
    x += dict[cur][0] * n;
    y += dict[cur][1] * n;
    cout << x << " " << y << endl;
}

#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin>>n;
	ll layer = (ll)((sqrt(1.0+4.0/3.0*n)-1.0)/2.0);
	ll offset = n-(1+layer)*layer*3;
	ll lyc = layer+1;
	ll stage = offset/lyc;
	ll sofs = offset%lyc;
	ll x, y;
	switch(stage){
		case 0:x = 2*lyc-sofs, y = 2*sofs;break;
		case 1:x = lyc-2*sofs, y = 2*lyc;break;
		case 2:x = -(lyc+sofs), y=2*(lyc-sofs); break;
		case 3:x = -(2*lyc-sofs), y = -2*sofs; break;
		case 4:x = -lyc+2*sofs, y = -2*lyc; break;
		case 5:x = lyc+sofs, y = 2*(sofs - lyc); break;
	}
	if(y==0 && x>0) x = x-2;
	cout<<x<<" "<<y<<endl;
}

#define up(i, j, k) for(int i = j; i <= k; ++i)
#define down(i, j, k) for(int i = j; i >= k; --i)
#define ss(i) scanf("%d",&i)
#define sss(i,j) scanf("%d%d",&i,&j)
#define ssss(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define LL long long
#define uLL unsigned long long
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>

using namespace std;

LL x[6] = {0, 1, 1, -1, -2, -1};
LL y[6] = {0, 2, 2, 2, 0, -2};
LL dx[6] = {1, 2, 1, -1, -2, -1};
LL dy[6] = {-2, 0, 2, 2, 0, -2};
LL sx[6] = {1, -1, -2, -1, 1, 2};
LL sy[6] = {2, 2, 0, -2, -2, 0};
LL z[6] = {1, 0, 1, 1, 1, 1};

int main()
{
    LL n;
    n = 498549006180463098;
    //cin >> n;
    if (!n)
    {
        cout << 0 << ' ' << 0 << endl;
        return 0;
    }
    LL k = ceil((sqrt((long double)12*(uLL)n+4)-2)/6);
    n -= (3*k-1)*(k-1);
    int cnt = 0;
    while (n-z[cnt]-k+1 > 0)
    {
        n -= z[cnt]+k-1;
        cnt++;
    }
    LL ansx = x[cnt]+(k-1)*dx[cnt]+n*sx[cnt], ansy = y[cnt]+(k-1)*dy[cnt]+n*sy[cnt];
    cout << ansx << ' ' << ansy << endl;
    return 0;
}

#include <stdio.h>
#include <vector>
#include <cstdlib>
#include <map>
#include <time.h>
#include <string>
#include <algorithm>
#include <queue>
#include <assert.h>
#include <math.h>
using namespace std;
#define ll long long int
const ll mod=1e9+7;
const double PI=3.1415926535897932384626433832795;
const double eps=1e-5;

ll n;

void sol(){
    ll i=0,j,l,r,m,x,y,t;
    scanf("%I64d",&n);
    l=0;
    r=1e9;
    while(r-l>1){
        m=(r+l)/2;
        if(3*m*(m+1)>n){
            r=m;
        }else{
            l=m;
        }
    }
    i=i;
    if(n==l*(l+1)*3){
        printf("%I64d 0",(ll)2*(r-1));
        return;
    }
    x=2*(r-1);
    y=0;
    n-=r*(r-1)*3;
    i=i;

    t=min((ll)1,n);
    n-=t;
    x+=t;
    y+=2*t;

    t=min((ll)r-1,n);
    n-=t;
    x-=t;
    y+=2*t;

    t=min((ll)r,n);
    n-=t;
    x-=2*t;

    t=min((ll)r,n);
    n-=t;
    x-=t;
    y-=2*t;

    t=min((ll)r,n);
    n-=t;
    x+=t;
    y-=2*t;

    t=min((ll)r,n);
    n-=t;
    x+=t;

    t=min((ll)r,n);
    n-=t;
    x+=t;
    y+=2*t;

    printf("%I64d %I64d",x,y);
}

int main(){
#pragma comment(linker,"/STACK:268435456")
#ifdef _DEBUG
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#else
  //freopen("addition.in","rt",stdin);
   // freopen("addition.out","wt",stdout);
#endif
 //   while(scanf("%I64d%I64d\n",&n,&p)!=EOF)sol();
//  gets(c);
    sol();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 2e5+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

ll a,b;

void f(int n){
	if(n==0){
		printf("%lld %lld\n",a,b);exit(0);
	}
}

void g(int x,ll &n,ll dx,ll dy){
	if(x-1<n){
		a+=dx*(x-1);
		b+=dy*(x-1);
		n-=x-1;
	}else{
		a+=dx*(n);
		b+=dy*(n);
		n=0;f(n);
	}
}

int main(){
	ll n;
	scanf("%lld",&n);
	ll x=0;
	ll y = (1ll)<<30;
	while(y>0){
		ll z = x+y;
		if(3*z*(z+1)<=n){
			x+=y;
		}
		y = y>>1;
	}

	//printf("%lld\n",x);
	a = 2*x+2,b=0;
	n-= 3*x*(x+1);
	if(n==0){
		printf("0 0\n");
		return 0;
	}
	//printf("%lld\n",x);
	//printf("%lld %lld\n",n,b);
	f(n);
	x+=2;
	g(x,n,-1,2);
//	printf("%lld %lld %lld",n,a,b);
	g(x,n,-2,0);
//	printf("%lld %lld %lld",n,a,b);
	g(x,n,-1,-2);
	g(x,n,+1,-2);
	g(x,n,+2,0);
	g(x,n,+1,2);

	return 0;
}

#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846264338327950288419716939937510L;
#define ff(i,s,e) for(int i = (s);i<(e);++i)
#define FF(i,s,e) for(int i = (s);i<=(e);++i)
#define fr(i,s,e) for(int i = (e);--i>=(s);)
#define Fr(i,s,e) for(int i = (e);i>=(e);--i)
#define io64 "%" PRId64

typedef int64_t ll;
typedef long double ld;
using namespace std;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
const ll MOD = 1E9 + 7;
template<class T, class U>
void smin(T&a,const U&b) {
    if (a > b)
        a = b;
}
template<class T, class U>
void smax(T&a,const U&b) {
    if (a < b)
        a = b;
}
string getstr() {
    char s[200001];
    scanf("%s",s);
    return s;
}

ll val(ll n) {
    return n * (n + 1) * 3;
}

ll rr(ll n) {
    ll lo = 0, high = sqrt(n);
    while (lo <= high) {
        ll mid = (lo + high) / 2;
        if (val(mid) >= n)
            high = mid - 1;
        else
            lo = mid + 1;
    }
    return high;
}
int f(ll n) {
    if (!n) {
        printf("0 0");
        return 0;
    }
    ll r = rr(n)+1;
    ll m = n - val(r-1);
    ll k = (m ) / r % 6;
    ll l = (m ) % r;
    ll ansa, ansb;
    switch (k) {
        case 0: {
            ansa = 2 * r - l;
            ansb = 2 * l;
        }break;
        case 1: {
            ansa = r - 2 * l;
            ansb = 2 * r;
        }break;
        case 2: {
            ansa = -r - l;
            ansb = 2 * r - r * l;
        }break;
        case 3: {
            ansa = -2 * r + l;
            ansb = -2 * l;
        }break;
        case 4: {
            ansa = -r + 2 * l;
            ansb = - 2 * r;
        }break;
        case 5: {
            ansa = r + l;
            ansb = - 2 * r + 2 * l;
        }break;
    }
    printf(io64 " " io64, ansa, ansb);
}

main() {
    int n;
    scanf(io64, &n);
    f(n);
}

#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

using ll = long long;
ll dx[] = {1, -1, -2, -1, 1 , 2};
ll dy[] = {2, 2 , 0 , -2, -2, 0};
ll cnt[] = {1, 0, 1, 1, 1, 1};

int main() {
    int i, j, k;
    ll x, y, cur;
    ll n;
    cin >> n;
    ll l, r, m;
    l = 0, r = 1e10;

    while (l < r) {

        m = (l + r + 1) / 2;
        if (m * ( 3 * m + 2 ) > n)
            r = m - 1;
        else
            l = m;

    }
    //cout << l << endl;
    x = y = 0;
    x = x + l * dx[4];
    y = y + l * dy[4];
    for (i = 0; i < 6; i++) {

        cnt[i] += l;

    }
    cur = l * ( 3 * l + 3) / 2;
    i = 0;
    while (cur < n) {

        ll d = min(cnt[i], n - cur);
        cur += d;
        x += dx[i] * d;
        y += dy[i] * d;
        cnt[i]++;
        i = (i + 1) % 6;

    }
    cout << x << " " << y << endl;
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
using namespace std;

#define ll long long
#define dou double
#define For(i,a,b) for (int i=(a),_##i=(b); i<=_##i; i++)
#define Rof(i,a,b) for (int i=(a),_##i=(b); i>=_##i; i--)
#define Mem(a,b) memset(a,b,sizeof(a))
#define Cpy(a,b) memcpy(a,b,sizeof(b))

const int dx[6]={1,-1,-2,-1,1,2};
const int dy[6]={2,1,0,-2,-2,0};

long long N;
long long A[6];

long long calc_step(long long x)
{
    long long k=5LL*x*(x+1)/2LL;
    k+=x*(x-1)/2;
    return k;
}

int main()
{
    for (; cin>>N; )
    {
        long long le=0,ri=1000*1000*1000LL;
        while(le+1<ri)
        {
            long long mid=(le+ri)>>1;
            if (calc_step(mid)<N) le=mid;
                else ri=mid;
        }
        long long x=le*1,y=le*(-2);
        long long k=calc_step(le);
        For(i,0,5) A[i]=le+1;
        A[1]--;
        int j=0;
        while(k<N)
        {
            if (k+A[j]<N) k+=A[j],x+=A[j]*dx[j],y+=A[j]*dy[j];
             else x+=(N-k)*dx[j],y+=(N-k)*dy[j],k=N;
            j++;
        }
        cout<<x<<' '<<y<<endl;
    }
    return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
const ll dx[5]={-2,-1,1,2,1};
const ll dy[5]={0,-2,-2,0,2};
ll i,n,k,x,y;
int main()
{
	cin>>n;
	if(!n)
	{
		cout<<"0 0";
		return 0;
	}
	k=(sqrt((long double)12*n-3)+3)/6;
	n-=3*k*k-3*k+1;
	x=2*k-1,y=2;
	if(n<=k-1)
	{
		cout<<x-n<<y+2*n;
		return 0;
	}
	n-=k-1,x-=k-1,y+=2*k-2;
	for(i=0;i<5;i++)
	{
		if(n<=k)
		{
			cout<<x+n*dx[i]<<y+n*dy[i];
			return 0;
		}
		x+=k*dx[i],y+=k*dy[i],n-=k;
	}
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <string>
#include <cstring>
#include <cassert>

using namespace std;

const int maxn = 21;
const int MOD = 1e9 + 7;

#define rep(i, x, y) for (int i = x; i <= y; i++)
#define mset(arr) memset(arr, 0, sizeof(arr))

int64_t n;
const int dir[6][2] = {{-1, 2}, {-2, 0}, {-1, -2}, {1, -2}, {2, 0}, {1, 2}};

int main() {
    while (cin >> n) {
        // the first circle = 6
        // the second circle = 12
        // the nth circle = 6*n
        //
        // On the end of nth circle, the number of moves is
        // 6 + 6*2 + ... + 6*n
        // = 6n*(n+1)/2
        // = 3n*(n+1)
        //
        // On the nth move, we are on the mth circle.
        // 3m*(m-1) < n <= 3m*(m+1) (m>=1, n>=1)
        //
        // binary search the result m
        //
        if (n == 0) {
            printf("0 0\n");
            continue;
        }

        int64_t l = 0, r = 10 ^ 9;
        int64_t m;
        while (r - l > 1) {
            m = (r + l) / 2;
            if (3 * m * (m - 1) >= n) {
                r = m;
            } else if (3 * m * (m + 1) < n) {
                l = m;
            } else {
                // 3m*(m-1) < n <= 3m*(m+1)
                break;
            }
        }

        int64_t d = n - 3 * m * (m - 1);
        int64_t i = 0;
        int64_t x = 2 * m, y = 0;
        while (d) {
            if (d > m) {
                d -= m;
                x += m * dir[i][0];
                y += m * dir[i][1];
                i++;
            } else {
                x += d * dir[i][0];
                y += d * dir[i][1];
                break;
            }
        }
        cout << x << " " << y << endl;
    }
    return 0;
}

  /*
     * round360.c++
     *
     *  Created on: Jun 29, 2016
     *      Author: Conan
     *
     * I reckon this is gonna be epic! :)
     */

    #include <bits/stdc++.h>

    #define ull unsigned long long

    #define int long long

    #define ld long double

    #define mod 1000000007

    #define INF 1000000000

    #define rep(i,x,y) for(int i = x; i<y; ++i)

    #define rev(i,x,y) for(int i = x ; i >= y; --i)

    #define pb push_back

    #define pii pair<int, int>

    #define fi first

    #define se second

    using namespace std;

    /////////////////////////////////////////Fast (I/O)////////////////////////////////////

    inline int readInt(){
    	int sign = 1, x = 0, c = getc(stdin);
    	while (c <= 32){
    		c = getc(stdin);
    	}
    	if (c == '-'){
    		sign = -1;
    		c = getc(stdin);
    	}
    	while ('0' <= c && c <= '9' && c != EOF){
    		x = (x<<1) + (x<<3) + c - '0'; // x*10 == (x << 1) + (x << 3)
    		c = getc(stdin);
    	}
    	return x*sign;
    }

    inline void writeLong(long long x){
    	if (x < 0){
    		putc('-', stdout);
    		x = -x;
    	}
    	char s[40];
    	int n = 0;
    	while (x || !n){ // if x == 0 it won't be printed! (added !n) :)
    		s[n++] = '0' + x % 10;
    		x /= 10;
    	}
    	while (n--){
    		putc(s[n], stdout);
    	}
    }

   /* void prepareStream(){
        ios_base::sync_with_stdio(false);
    	cin.tie(nullptr);
    	cout.tie(nullptr);
    }
     */
    template <typename T>
    T input() {
        T res;
        cin >> res;
        return res;
    }

    ///////////////////////////////Auxiliary functions////////////////////////////

    inline bool des (int i , int j) { return i > j; }
    inline bool asc (int i , int j) { return i < j; }
    bool pairComp_s (const pii &x , const pii &y) { return asc(x.se, y.se); }

    int fact(int x) { int ans = 1; while(x) ans*= (x--); return ans; }
    int gcd(int x, int y) { return y ? gcd(y, x % y) : x ;}
    int lcm(int x, int y) { return x * 1ll * y / gcd(x, y); }
    int ncr(int n, int r) { return fact(n) / (fact(n-r) * fact(r)); }

    ////////////////////////////////////Functions////////////////////////////////////

    int bin_pow(int a, int b){

        int res = 1ull;
        int tmp = a;

        while(b){
            if(b & 1) res = res * tmp % mod;
            tmp = tmp * tmp % mod;
            b>>=1;
        }

        return res;

    }

    ////////////////////////////////////Variables/////////////////////////////////

    int hexagonal_spiral[][2] = {{1,2} , {-1, 2} , {-2, 0} , {-1, -2} , {1, -2} , {2, 0}};
    int rep[] = {1, 0, 1, 1, 1, 1};

    const int M = 2e6 + 1;
    int n, m , k, x, y, size, len, l, mid, r , rem, num, sum, tot, ans , cur, tmp, res;
    //string str;
    //int a[M];
    //set<int> myset;
    //map<int, int> cnt;

    inline void find (int n){

        int j = 0;

		while(n){

			if(n >= rep[j])
				x+= rep[j] * hexagonal_spiral[j][0], y+= rep[j] * hexagonal_spiral[j][1], n-= rep[j];

			else{
				x+= n * hexagonal_spiral[j][0], y+= n * hexagonal_spiral[j][1];
	   			break;
			}

				++rep[j];

			j = (++j) % 6;

		    //cout<< x <<" "<< y << '\n';
		}
    }

    /////////////////////////////////Main Code//////////////////////////////////////
    int32_t main(){

      //prepareStream();

        n = readInt();

        l = 0, r = INF;
        while(l < r){
            mid = l + ((r - l) / 2);

            if((3 * (mid * (mid + 1))) - mid < n)
                l = mid + 1;
            else
                r = mid;
            //cout << l << " " << mid << " " << r <<endl;
        }

        //cout << l << " " << r <<endl;

        int prev = r - 1;

        rep(i, 0, 6) rep[i] += prev;

        x = (1) * prev, y = (-2) * prev;

        find(n - ((3 * prev * (prev + 1)) - prev));

		writeLong(x), putchar(' '), writeLong(y);

        return 0;

    }

#include <bits/stdc++.h>

using namespace std;

#define fout cout
#define MOD 1000000007

ifstream fin(".in");

long long int i,j,n,m,v[200010],k,ans,sol,ras,last,aux,a,b,t,ver[100010],c,d,D[100010];
long long int x,y,z=1,ls,ld,mij;
bool ok,ok2;
int X[]={0, -2, -1,  1,  2,  1};
int Y[]={0,  0, -2, -2,  0,  2};
///          1   2   3   4   5

long long int calc( long long int x )
{
    if( x == 0 )
        return 0;
    return 3 * x + 3 * x * x + 1 ;
}

long long int calc2( long long int x )
{
    return 3 * x + 3 * x * x + 1 ;
}

int main()
{
    #ifndef ONLINE_JUDGE
        #define cin fin
    #endif

    x = 1;
    z = 1;
    aux = 1;

    cin>>n;

    if( n == 0)
    {
        cout<<"0 0";
        return 0;
    }

    ls = 0;
    ld = 577350270;
    while( ls < ld )
    {
        mij = ls + ( ld - ls ) / 2;
        c = calc( mij );
        d = calc( mij + 1 );

        if( c <= n && n < d )
        {
            break;
        }

        if( d < n )
        {
            ls = mij;
        }
        else
        {
            ld = mij;
        }
    }

    n-= calc2( mij );
    mij++;
    n--;
    if( n == 0 )
    {
        a = mij;
        b = 2 * mij;
        cout<<a<<' '<<b;
        return 0;
    }

    a = mij;
    b = 2 * mij;

    x = 1 + 2 * ( mij - 1 );
    y = 2;

    if( x - a <= n )
    {
        n++;
        n -= x - a;
        x = a;
        y = b;
    }
    else
    {
        x -= (n+1);
        y += 2 * (n+1);
        n = 0;
        cout<<x<<' '<<y;
        return 0;
    }

    for( j = 1 ; j <= 5 && n ; j++ )
    {
        x += X[ j ] * min( mij , n );
        y += Y[ j ] * min( mij , n );
        n -= min( mij , n );

    }

    cout<<x<<' '<<y;

    return 0;
}

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int xx[]={0,1,-1,-2,-1,1,2},xx1[]={0,1,-1,1,-1,-1,-1};
int yy[]={0,2,2,0,-2,-2,0},yy1[]={0,-2,0,2,2,0,-2};
ll cal(ll x)
{
	return (1+x)*x*3;
}
int main()
{
	ll n,nx,ny,gx,gy,temp,left=0,right=1000000000,mid;
	scanf("%I64d",&n);
	if(n!=0)
	{
			while(left<right)
		{
			mid=(left+right)/2;
			if(cal(mid)<n)
				left=mid+1;
			else
				right=(right+mid)/2;
		}
		temp=left;
//		printf("%I64d\n",temp);
		n-=cal(temp-1);
		nx=(n/temp);
		ny=(n%temp);
		if(ny!=0)
			nx++;
		else
			ny=temp;
//		printf("%I64d %I64d\n",nx,ny);
		gx=xx[nx]*temp+(temp-ny)*xx1[nx];
		gy=yy[nx]*temp+(temp-ny)*yy1[nx];
	}
	else
		gx=0,gy=0;
	printf("%I64d %I64d\n",gx,gy);
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>

using namespace std;

typedef long long i64;
pair <i64, i64> it;
i64 moves;
i64 cur_moves = 1;
i64 base;

void move(i64 steps, int x, int y)
{
	if (cur_moves >= moves)
		return;

	it.first += x * (steps);
	it.second += y * (steps);
	cur_moves += steps;
	if (cur_moves > moves)
	{
		it.first -= x * (cur_moves - moves);
		it.second -= y * (cur_moves - moves);
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	i64 n;
	cin >> n;
	if (n == 0)
	{
		cout << "0 0";
		return 0;
	}
	double m = n / 6.0;
	base = floor((-1 + sqrt(1 + 4 * 2.0 * m)) / 2.0);
	it = make_pair(2 * base + 1, 2);
	moves = n - base * 6;
	move(base, -1, 2);
	move(base + 1, -2, 0);
	move(base + 1, -1, -2);
	move(base + 1, 1, -2);
	move(base + 1, 2, 0);
	move(base + 1, 1, 2);
	cout << it.first << " " << it.second;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int n;
int main()
{
	cin>>n;
	if(n==0) puts("0 0");
	else
	{
		ll tmp=n/6;
		ll l=0,r=2000000000,mid,ans=0;
		while(l<=r)
		{
			mid=(l+r)/2;
			if(mid*(mid+1)/2<=tmp)
				ans=mid,l=mid+1;
			else r=mid-1;
		}
		ll k=n-ans*(ans+1)*3;ans++;
		if(k<=ans)
		{
			if(k==0) printf("%I64d 0\n",2ll*ans-2);
			else printf("%I64d %I64d\n",2*ans-k,2*k);
		}
		else if(k<=ans*2) printf("%I64d %I64d\n",ans-(k-ans)*2,2*ans);
		else if(k<=ans*3) printf("%I64d %I64d\n",ans-k,2*ans-(k-2*ans)*2);
		else if(k<=ans*4) printf("%I64d %I64d\n",-2*ans+(k-3*ans),-2*(k-3*ans));
		else if(k<=ans*5) printf("%I64d %I64d\n",-ans+(k-4*ans)*2,-2*ans);
		else printf("%I64d %I64d\n",ans+(k-5*ans),-2*ans+2*(k-5*ans));
	}
}

//#include "bits/stdc++.h"
//#pragma warning(disable:4996)
//using namespace std;
//
//
//
//int main() {
//  int n, m; cin >> n >> m;
//  vector<vector<long long int>>edges(n);
//  vector<long long int>touched(n);
//  for (int i = 0; i < m; ++i) {
//      int u, v;
//      scanf("%d %d", &u, &v);
//      u--; v--;
//      if (u > v) {
//          swap(u, v);
//      }
//      edges[u].push_back(v);
//      touched[u]++;
//      touched[v]++;
//  }
//
//  vector<long long int>dp(n);
//  dp[0] = 1;
//  for (int i = 0; i < n - 1; ++i) {
//      for (auto j : edges[i]) {
//          dp[j]=max(dp[i]+1,dp[j]);
//      }
//  }
//  long long int ans = 0;
//  for (int i = 0; i < n; ++i) {
//      ans = max(dp[i] * touched[i],ans);
//  }
//  cout << ans << endl;
//  return 0;
//}
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;

pair<long long int, long long int>leftup(long long int time, pair<long long int, long long int>p) {
    p.first -= time;
    p.second += time * 2;
    return p;
}
pair<long long int, long long int>left(long long int time, pair<long long int, long long int>p) {
    p.first -= time * 2;
    return p;
}
pair<long long int, long long int>leftdown(long long int time, pair<long long int, long long int>p) {
    p.first -= time;
    p.second -= time * 2;
    return p;
}
pair<long long int, long long int>rightdown(long long int time, pair<long long int, long long int>p) {
    p.first += time;
    p.second -= time * 2;
    return p;
}
pair<long long int, long long int>right(long long int time, pair<long long int, long long int>p) {
    p.first += time * 2;
    return p;
}
pair<long long int, long long int>rightup(long long int time, pair<long long int, long long int>p) {
    p.first += time;
    p.second += time * 2;
    return p;
}

int main() {
    long long int aa; cin >> aa;
    long long int k = aa;
    long long int keta = 1;
    pair<long long int, long long int>n;
    if (aa == 0) {
        cout << 0 << " " << 0 << endl;
        return 0;
    }
    if (k > 3 *  1000000000 * 1000000001) {
        k -= 3 * 1000000000 * 1000000001;
        keta+=   1000000000;
    }
    while (1) {
        if (k > 6 * keta) {
            k -= 6 * keta;
            keta++;
        }
        else {
            long long int startx = 2 * keta;
            long long int starty = 0;
            n = (make_pair(startx, starty));
            if (k < keta) {
                n = leftup(k, n);
                break;
            }
            else {
                n = leftup(keta, n);
                k -= (keta);
            }
            bool ok = true;
            for (int i = 0; i < 5; ++i) {
                if (k < keta) {
                    if (i == 0) {
                        n = left(k, n);
                    }
                    else if (i == 1) {
                        n = leftdown(k, n);
                    }
                    else if (i == 2) {
                        n = rightdown(k, n);
                    }
                    else if (i == 3) {
                        n = right(k, n);
                    }
                    else if (i == 4) {
                        n = rightup(k, n);
                    }
                    break;
                }
                else {
                    if (i == 0) {
                        n = left(keta, n);
                    }
                    else if (i == 1) {
                        n = leftdown(keta, n);
                    }
                    else if (i == 2) {
                        n = rightdown(keta, n);
                    }
                    else if (i == 3) {
                        n = right(keta, n);
                    }
                    else if (i == 4) {
                        n = rightup(keta, n);
                    }
                    k -= keta;
                }
            }
            break;
        }
    }
    cout << n.first << " " << n.second << endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 200005, M = 1e9 + 7;
long long n;

long long znajdz(long long n) {
    if (n == 1) return 1;
    long long poc = 2;
    long long kon = sqrt(n) + 1;
    long long ret = -1;
    while (poc <= kon) {
        long long sr = (poc + kon) / 2;
        if (3 * sr * (sr - 1) >= n) {
            ret = sr;
            kon = sr - 1;
        } else {
            poc = sr + 1;
        }
    }
    return ret;
}

int main() {

    cin >> n;

    long long pietro = znajdz(n);
    n -= (pietro - 1) * (pietro - 2) * 3 + 1;
    long long x = 2 * (pietro - 1) - 1;
    long long y = 2;
    if (n >= pietro - 2) {
        x -= pietro - 2;
        y += 2 * (pietro - 2);
        n -= (pietro - 2);
    } else {
        cout << x - n << " " << y + 2 * n << "\n";
        return 0;
    }

    if (n >= pietro - 1) {
        x -= 2 * (pietro - 1);
        n -= (pietro - 1);
    } else {
        cout << x - 2 * n << " " << y << "\n";
        return 0;
    }

    if (n >= pietro - 1) {
        x -= (pietro - 1);
        y -= 2 * (pietro - 1);
        n -= (pietro - 1);
    } else {
        cout << x - n << " " << y - 2 * n << "\n";
        return 0;
    }

    if (n >= pietro - 1) {
        x += (pietro - 1);
        y -= 2 * (pietro - 1);
        n -= (pietro - 1);
    } else {
        cout << x + n << " " << y - 2 * n << "\n";
        return 0;
    }

    if (n >= pietro - 1) {
        x += 2 * (pietro - 1);
        n -= (pietro - 1);
    } else {
        cout << x + 2 * n << " " << y << "\n";
        return 0;
    }

    if (n >= pietro - 1) {
        x += (pietro - 1);
        y += 2 * (pietro - 1);
        n -= (pietro - 1);
    } else {
        cout << x + n << " " << y + 2 * n << "\n";
        return 0;
    }
    return 0;
}

#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
//作者:中国江苏南京丁天行
using namespace std;
ll n,t=0ll,k=0ll,x,y;
int main()
{
    scanf("%d",&n);
    if(n==0){
             printf("0 0\n");
             return 0;
    }
    ll i;
    for(i=1;;i++){
            k+=6ll;
            t+=k;
            if(t>=n){
                     break;
            }
    }
    t-=k;
    k/=6ll;
    n-=t;
    n--;
    x=i+i-1ll;
    y=2ll;
    if(n<k){
            x-=n;
            y+=n+n;
            printf("%I64d %I64d\n",x,y);
            return 0;
    }
    x-=k;
    x++;
    y+=k+k;
    y-=2ll;
    n++;
    n-=k;
    if(n<k){
            x-=n+n;
            printf("%I64d %I64d\n",x,y);
            return 0;
    }
    x-=k+k;
    n-=k;
    if(n<k){
            x-=n;
            y-=n+n;
            printf("%I64d %I64d\n",x,y);
            return 0;
    }
    x-=k;
    y-=k+k;
    n-=k;
    if(n<k){
            x+=n;
            y-=n+n;
            printf("%I64d %I64d\n",x,y);
            return 0;
    }
    x+=k;
    y-=k+k;
    n-=k;
    if(n<k){
            x+=n+n;
            printf("%I64d %I64d\n",x,y);
            return 0;
    }
    x+=k+k;
    n-=k;
    x+=n;
    y+=n+n;
    printf("%I64d %I64d\n",x,y);
   // system("pause");
    return 0;
}

#include <iostream>
#include <cmath>
#include <cstdint>

using namespace std;

inline double quadratic_equation_root(int64_t, int64_t, int64_t);

int main(int argc, char **argv) {
  int64_t n;
  cin >> n;

  int64_t round = floor(quadratic_equation_root(3, 2, -n));
  auto position = make_pair(round, -2*round);
  int64_t walk = n - (3*round*round + 2*round);

  for (int w = 0; w <= round; w++) {
    if (walk == 0)
      break;
    position.first += 1;
    position.second += 2;
    walk--;
  }

  for (int w = 0; w < round; w++) {
    if (walk == 0)
      break;
    position.first -= 1;
    position.second += 2;
    walk--;
  }

  for (int w = 0; w <= round; w++) {
    if (walk == 0)
      break;
    position.first -= 2;
    walk--;
  }

  for (int w = 0; w <= round; w++) {
    if (walk == 0)
      break;
    position.first -= 1;
    position.second -= 2;
    walk--;
  }

  for (int w = 0; w <= round; w++) {
    if (walk == 0)
      break;
    position.first += 1;
    position.second += 2;
    walk--;
  }

  for (int w = 0; w <= round; w++) {
    if (walk == 0)
      break;
    position.first += 2;
    walk--;
  }

  cout << position.first << " " << position.second << endl;

  return 0;
}

inline double quadratic_equation_root(int64_t a, int64_t b, int64_t c) {
  return ((sqrt(b*b - 4*a*c) - b) / (2 * a));
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define db double
#define LL long long
#define Hzy(o) freopen(o".in", "r", stdin), freopen(o".out", "w", stdout)
using namespace std;
const int N = 100010;
LL n, k;
LL x, y;

LL mode_xp(LL a, LL b)
{
	LL res = 1, tmp = a;
	while(b)
		{
			if(b & 0x1) res = res * tmp;
			tmp *= a;
			b >>= 1;
		}
	return res;
}

int main()
{
	//Hzy("data");
	LL l, r, mid;
	while(cin >> n)
		{
			l = 0, r = 1e+9, mid = l + r >> 1;
			for(;r - l > 1; mid = l + r >> 1)
				if(3LL * mid * (mid + 1) > n) r = mid;
				else l = mid;
			if(3LL * l * (l + 1) <= n) k = l;
			else k = r;
			n -= 3LL * k * (k + 1);
			k++;
			if(n == 0) {
				x = 2 * k - 2, y = 0;
			}
			else
				{
					x = 2 * k - 1, y = 2;
					n--;
					while(n && y < 2 * k) x--, y += 2, n--;
					//if(!n) break;
					while(n && x != -k) x -= 2, n--;
					//if(!n) break;
					while(n && y != 0) x--, y -= 2, n--;
					//if(!n) break;
					while(n && y > -2 * k) x++, y -= 2, n--;
					//if(!n) break;
					while(n && x != k) x += 2, n--;
					//if(!n) break;
					while(n & y != 0) x++, y += 2, n--;
					//if(!n) break;
				}
			cout << x << " " << y << endl;
		}
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cmath>

using namespace std;
long long n,a,b,xnow,ynow,lnow;
int main() {
	cin >> n;
	a = ceil((double)1/2 + sqrt((double)1/4 + (double)n/3));
	b = (a-1)*(a-2)*3;
	xnow = 2;
	ynow = 2*a - 3;
	lnow = b+1;

	if (lnow + a-2 <= n) {
		lnow += a-2;
		ynow -= (a-2);
		xnow += 2*(a-2);
	}else {
		ynow -= (n-lnow);
		xnow += 2*(n-lnow);
		lnow += (n-lnow);
	}
	if (lnow + a-1 <= n) {
		lnow += a-1;
		ynow -= 2*(a-1);
	}else {
		ynow -= 2*(n-lnow);
		lnow += (n-lnow);
	}

	if (lnow + a-1 <= n) {
		lnow += a-1;
		ynow -= (a-1);
		xnow -= 2*(a-1);
	}else {
		ynow -= (n-lnow);
		xnow -= 2*(n-lnow);
		lnow += (n-lnow);
	}

	if (lnow + a-1 <= n) {
		lnow += a-1;
		ynow += (a-1);
		xnow -= 2*(a-1);
	}else {
		ynow += (n-lnow);
		xnow -= 2*(n-lnow);
		lnow += (n-lnow);
	}

	if (lnow + a-1 <= n) {
		lnow += a-1;
		ynow += 2*(a-1);
	}else {
		ynow += 2*(n-lnow);
		lnow += (n-lnow);
	}

	if (lnow + a-1 < n) {
		lnow += a-1;
		ynow += (a-1);
		xnow += 2*(a-1);
	}else {
		ynow += (n-lnow);
		xnow += 2*(n-lnow);
		lnow += (n-lnow);
	}
	cout << ynow <<" "<<xnow<<endl;
}

#include <bits/stdc++.h>

using namespace std;
using LL = long long;

struct point {
  int x, y;
  point operator + (point a) {
    return {x + a.x, y + a.y};
  }
  point operator * (int k) {
    return {k * x, k * y};
  }
};

point dir(int c) {
  if (c == 0)
    return {1, 2};
  if (c == 1)
    return { -1, 2};
  if (c == 2)
    return { -2, 0};
  if (c == 3)
    return { -1, -2};
  if (c == 4)
    return {1, -2};
  if (c == 5)
    return {2, 0};
}

int main() {
  auto rt = [&] (double n) {
    double a = 3, b = 2, c = 1 - n;
    double d = b * b - 4 * a * c;
    return (-b + sqrt(d)) / (2 * a);
  };
  auto f = [&] (int x) {
    return 3ll * x * x + 2 * x;
  };
  LL n;
  cin >> n;
  if (! n) {
    puts("0 0");
    return 0;
  }
  int x = int(rt(n));
  n -= f(x);
  int c = 0;
  for (; c < 6; c ++) {
    if (x + (c != 1) >= n) break;
    n -= x + (c != 1);
  }
  point p;
  if (c == 0)
    p = {x, -2 * x};
  if (c == 1)
    p = {1 + 2 * x, 2};
  if (c == 2)
    p = {x + 1, (x + 1) * 2};
  if (c == 3)
    p = { -x - 1, (x + 1) * 2};
  if (c == 4)
    p = { -2 * x, 0};
  if (c == 5)
    p = { -x - 1, (x + 1)*(-2)};
  p = p + dir(c) * n;
  cout << p.x << " " << p.y << endl;
  return 0;
}

/* string coder = "Balajiganapathi S"; // Never give up!  */

//#define LOCAL
#ifdef LOCAL
#   define TRACE
#   define TEST
#else
#   define NDEBUG
//#   define FAST
#endif

#include<bits/stdc++.h>

using namespace std;

/* aliases */
using vi  = vector<int>;
using pi  = pair<int, int>;
using ll  = long long int;

/* shortcut macros */
#define mp              make_pair
#define fi              first
#define se              second
#define mt              make_tuple
#define gt(t, i)        get<i>(t)
#define all(x)          (x).begin(), (x).end()
#define ini(a, v)       memset(a, v, sizeof(a))
#define rep(i, s, n)    for(int i = (s), _##i = (n); i <= _##i; ++i)
#define re(i, s, n)     rep(i, (s), (n) - 1)
#define fo(i, n)        re(i, 0, n)
#define si(x)           (int((x).size()))
#define is1(mask,i)     (((mask) >> i) & 1)

/* trace macro */
#ifdef TRACE
#   define trace(v...)  {cerr << __func__ << ":" << __LINE__ << ": " ;_dt(#v, v);}
#else
#   define trace(...)
#endif

#ifdef TRACE
pi _gp(string s) {
    pi r(0, si(s) - 1);
    int p = 0, s1 = 0, s2 = 0, start = 1;
    fo(i, si(s)) {
        int x = (s1 | s2);
        if(s[i] == ' ' && start) {
            ++r.fi;
        } else {
            start = 0;
            if(s[i] == ',' && !p && !x) {
                r.se = i - 1;
                return r;
            }
            if(x && s[i] == '\\') ++i;
            else if(!x && s[i] == '(') ++p;
            else if(!x && s[i] == ')') --p;
            else if(!s2 && s[i] == '\'') s1 ^= 1;
            else if(!s1 && s[i] == '"') s2 ^= 1;
        }
    }
    return r;
}

template<typename H> void _dt(string u, H&& v) {
    pi p = _gp(u);
    cerr << u.substr(p.fi, p.se - p.fi + 1) << " = " << forward<H>(v) << " |" << endl;
}

template<typename H, typename ...T> void _dt(string u, H&& v, T&&... r) {
    pi p = _gp(u);
    cerr << u.substr(p.fi, p.se - p.fi + 1) << " = " << forward<H>(v) << " | ";
    _dt(u.substr(p.se + 2), forward<T>(r)...);
}

template<typename T>
ostream &operator <<(ostream &o, vector<T> v) { // print a vector
    o << "[";
    fo(i, si(v) - 1) o << v[i] << ", ";
    if(si(v)) o << v.back();
    o << "]";
    return o;
}

template<typename T1, typename T2>
ostream &operator <<(ostream &o, map<T1, T2> m) { // print a map
    o << "{";
    for(auto &p: m) {
        o << " (" << p.fi << " -> " << p.se << ")";
    }
    o << " }";
    return o;
}

template<typename T>
ostream &operator <<(ostream &o, set<T> s) { // print a set
    o << "{";
    bool first = true;
    for(auto &entry: s) {
        if(!first) o << ", ";

        o << entry;
        first = false;
    }
    o << "}";
    return o;
}

template <size_t n, typename... T>
typename enable_if<(n >= sizeof...(T))>::type
    print_tuple(ostream&, const tuple<T...>&) {}

template <size_t n, typename... T>
typename enable_if<(n < sizeof...(T))>::type
    print_tuple(ostream& os, const tuple<T...>& tup) {
    if (n != 0)
        os << ", ";
    os << get<n>(tup);
    print_tuple<n+1>(os, tup);
}

template <typename... T>
ostream& operator<<(ostream& os, const tuple<T...>& tup) { // print a tuple
    os << "("; print_tuple<0>(os, tup); return os << ")"; } template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) { // print a pair
    return os << "(" << p.fi << ", " << p.se << ")";
}
#endif

/* util functions */
template<typename T1, typename T2, typename T3>
T1 modpow(T1 _a, T2 p, T3 mod) {
    assert(p >= 0);
    ll ret = 1, a = _a;

#ifndef FAST
    if(a < 0) {
        a %= mod;
        a += mod;
    }

    if(a >= mod) {
        a %= mod;
    }
#endif

    for(; p > 0; p /= 2) {
        if(p & 1) ret = ret * a % mod;
        a = a * a % mod;
    }

    return ret;
}

#define x1 _asdfzx1
#define y1 _ysfdzy1

/* constants */
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;

/* code */
constexpr int mx = -1;
constexpr int di[] = {1, -2, -1, 1, 2};
constexpr int dj[] = {2, 0, -2, -2, 0};

int main() {
    ll n;
    cin >> n;
    int a = 0;
    int i = 0, j = 0;

    ll len = 1;
    int d = 0;
    int si = accumulate(di, di + 5, 0);
    int sj = accumulate(dj, dj + 5, 0);

    len = sqrt(n / 5) - 1;
    if(len < 0) len = 1;

    i += si * (len - 1) * (len - 1);
    j += sj * (len - 1) * (len - 1);

    trace(len);
    while(n > 0) {
        ll x = len;
        if(x > n) x = n;
        i += di[d] * x; j += dj[d] * x;
        if(++d == 5) {
            len += 2;
            d = 0;
        }
        n -= x;
    }

    cout << i << " " << j << '\n';

	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;

pair <i64, i64> it;
ui64 moves;
ui64 cur_moves = 1;
ui64 base;

void move(ui64 steps, i64 x, i64 y)
{
	if (cur_moves >= moves)
		return;

	it.first += x * (steps);
	it.second += y * (steps);
	cur_moves += steps;
	if (cur_moves > moves)
	{
		it.first -= x * (cur_moves - moves);
		it.second -= y * (cur_moves - moves);
	}
}
int main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	ui64 n;
	cin >> n;
	if (n == 0)
	{
		cout << "0 0";
		return 0;
	}
	long double m = n / 6.0;
	//cout << m << endl;
	//printf("%.10lf", m);
	base = floor((-3.0 + sqrt(9.0 + 12 * n)) / 6.0);
	it = make_pair(2 * base + 1, 2);
	ui64 tmp = base * (base + 1) * 3;
	moves = n - (base)*(base + 1) * 3 ;
	if (moves == 0)
	{
		cout << 2 * base << " " << 0;
		return 0;
	}

	if (moves > n)
	{
		base = base - 1;
		ui64 tmp_ = base * (base + 1) * 3;
		moves = n - base * (base + 1) * 3;
	}
	move(base, -1, 2);
	move(base + 1, -2, 0);
	move(base + 1, -1, -2);
	move(base + 1, 1, -2);
	move(base + 1, 2, 0);
	move(base + 1, 1, 2);
	cout << it.first << " " << it.second;
	return 0;
}

/********************************
*MAHBUBCSEJU                    *
*CSE 22                         *
*JAHANGIRNAGAR UNIVERSITY       *
*TIMUS:164273FU                 *
*UVA>>LIGHTOJ>>HUST:mahbubcseju *
********************************/
#include<cfloat>
#include<climits>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<string.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define IT(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define ITP(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;
#define PB push_back
#define xx first
#define yy second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())
//#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T MDINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
template <class T>string NTS ( T Number )
{
    stringstream ss;
    ss << Number;
    return ss.str();
}
template <class T>T stringtonumber ( const string &Text )
{
    istringstream ss(Text);
    T result;
    return ss >> result ? result : 0;
}
template <class T>bool ISLEFT ( T a,T b,T c)
{
    if(((a.xx-b.xx)*(b.yy-c.yy)-(b.xx-c.xx)*(a.yy-b.yy))<0.0)return 1;//Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
#define mx 1000000
#define md 1000000007

#define maxp 1000004
typedef pair<int , int >P;
typedef vector<int >V;

////////define value/////

int main()
{
    ll n;
    L(n);
    if(n==0)
    {
        PC("0 0\n");
        return 0;
    }
    ll lo=0;
    ll hi=6000000000;
    ll sum=0,in=0;
    while(lo<=hi)
    {
        ll mid=(lo+hi)/2;
        ll res=(mid*3*(2+(mid-1)));
        if(res<=n)
        {
            in=max(mid,in);
            sum=max(res,sum);
            lo=mid+1;
        }
        else hi=mid-1;
    }
    ll co=n-sum;
    if(co==0)
    {
        PC("%lld %lld\n",(in)*2,0ll);
   // lol;
    }
    else if(co==(in+1)*3)
    {
        PC("%lld %lld\n",-(in)*2,0ll);
        //lol;
    }

    else
    {
        in++;

        ll op=0;
        if(co<=(in*6)/4)op=1;
        else if(co<=(in*6*2)/4)op=2;
        else if(co<=(in*6*3)/4)op=3;
        else op=4;

        if(co>(in*3)){

            co=(in*6)-co;
        }
        if(op==2||op==3)
        {
            co=(in*3)-co;
        }
        //cout<<co<<endl;\

        ll x=in*2;
        ll y=0;
        ll xo=in;
        if(co<=xo)
        {
            x-=co;
            y+=co*2;
        }
        else

        {
            x-=xo;
            y+=xo*2;
            co-=xo;
            x-=co*2;
        }
        if(op==2)x*=-1;
        else if(op==3){
            x*=-1,y*=-1;
        }
        else if(op==4) {
            y*=-1;
        }

PC("%lld %lld\n",x,y);
    }

    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
long long startx(long long layer,int part)
{
    switch (part)
    {
    case 0:
        return 2*layer-1;
    case 1:
        return layer-2;
    case 2:
        return -layer-1;
    case 3:
        return 1-2*layer;
    case 4:
        return  2-layer;
    case 5:
        return 1+layer;
    }
}
long long starty(long long layer,int part)
{
    switch (part)
    {
    case 0:
        return 2;
    case 1:
        return layer*2;
    case 2:
        return 2*layer-2;
    case 3:
        return -2;
    case 4:
        return  -2*layer;
    case 5:
        return 2-2*layer;
    }
}
long long root (long long x)
{
if (x==0)
return 0;
    long long one=1,result=0;
    int log;
    for (log=0;(one<<log)*(one<<log) <= x;++log);
    result=one<<(log-1);
    for (;log>=0;log--)
    {
        if ( (result+(one<<log))* (result+(one<<log)) <= x )
            result+=(one<<log);
    }
    return result;
}
int main()
{
    int movex[6]={-1,-2,-1,1,2,1},movey[6]={2,0,-2,-2,0,2};
    long long x,n,part,position;cin>>x;
    if(x==0){
        cout<<0<<' '<<0;
        return 0;
        }
    for (n=root((x-1)/3);x>=3*n*(n-1)+1;++n);

    --n;
    part=(x-1)/n-3*(n-1);
    position=x%n;
    //cout<<x<<' '<<n<<' '<<part<<' '<<position<<"     ";
    //cout<<startx(n,part)+movex[part]*position<<' '<<starty(n,part)+movey[part]*position<<endl;
    cout<<startx(n,part)<<' '<<starty(n,part)<<endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define fout cout
#define MOD 1000000007

ifstream fin(".in");

long long int i,j,n,m,v[200010],k,ans,sol,ras,last,aux,a,b,t,ver[100010],c,d,D[100010];
long long int x,y,z=1,ls,ld,mij;
bool ok,ok2;
int X[]={0, -2, -1,  1,  2,  1};
int Y[]={0,  0, -2, -2,  0,  2};
///          1   2   3   4   5

long long int calc( long long int x )
{
    if( x == 0 )
        return 0;
    return 3 * x + 3 * x * x + 1 ;
}

long long int calc2( long long int x )
{
    return 3 * x + 3 * x * x + 1 ;
}

int main()
{
    #ifndef ONLINE_JUDGE
        #define cin fin
    #endif

    x = 1;
    z = 1;
    aux = 1;

    cin>>n;

    if( n == 0)
    {
        cout<<"0 0";
        return 0;
    }

    ls = 0;
    ld = 577350270;
    while( ls < ld )
    {
        mij = ls + ( ld - ls ) / 2;
        c = calc( mij );
        d = calc( mij + 1 );

        if( c <= n && n < d )
        {
            break;
        }

        if( d < n )
        {
            ls = mij;
        }
        else
        {
            ld = mij;
        }
    }

    n-= calc2( mij );
    mij++;
    if( n == 0 )
    {
        a = mij;
        b = 2 * mij;
        cout<<a<<' '<<b;
        return 0;
    }

    a = mij;
    b = 2 * mij;

    x = 1 + 2 * ( mij - 1 );
    y = 2;

    if( x - a <= n )
    {
        n -= x - a;
        x = a;
        y = b;
    }
    else
    {
        x -= (n+1);
        y += 2 * (n+1);
        n = 0;
        cout<<x<<' '<<y;
        return 0;
    }

    for( j = 1 ; j <= 5 && n ; j++ )
    {
        x += X[ j ] * min( mij , n );
        y += Y[ j ] * min( mij , n );
        n -= min( mij , n );

    }

    cout<<x<<' '<<y;

    return 0;
}

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
#define LL long long
LL cal(LL u){return u * (u - 1) * 3;}
int main()
{
    LL n;
    while(scanf("%I64d", &n) != EOF){
        if(n == 0){
            printf("0 0\n");
            continue;
        }
        LL dis = 0;
        while(cal(dis) < n) dis++;
        n -= cal(dis - 1);
        int flag = 0;
        int f = 1;
        while(n){
            LL dx = 0;
//            if(f) dx = dis - 2, f = 0;
//            else
                dx = dis - 1;
//            printf("n = %I64d, dx = %I64d, flag = %d\n", n, dx, flag);
            if(n >= dx) n -= dx, flag++;
            else    break;
        }
        dis -= 1;
        LL x, y, tx, ty;
        if(flag == 0)   x = 2 * dis - 1, y = 2, tx = -1, ty = 2;
        else if(flag == 1)   x = dis, y = 2 * dis, tx = -1, ty = 0;
        else if(flag == 2)   x = -dis, y = 2 * dis, tx = -1, ty = -2;
        else if(flag == 3)   x = -2 * dis, y = 0, tx = -1, ty = -2;
        else if(flag == 4)   x = -dis, y = -2 * dis, tx = 2, ty = 0;
        else  x = dis, y = -2 * dis, tx = 1, ty = 2;
        if(n == 60)
        printf("flag = %d\n");
//        printf("flag = %d, x = %I64d, y = %I64d, tx = %I64d, ty = %I64d, dis = %I64d, n = %I64d\n", flag, x, y, tx, ty, dis, n);
        x += tx * n;
        y += ty * n;
        if(flag == 0)   x -= tx, y -= ty;
        printf("%I64d %I64d\n", x, y);
    }
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;

pair <i64, i64> it;
ui64 moves;
ui64 cur_moves = 1;
ui64 base;

void move(ui64 steps, i64 x, i64 y)
{
	if (cur_moves >= moves)
		return;

	it.first += x * (steps);
	it.second += y * (steps);
	cur_moves += steps;
	if (cur_moves > moves)
	{
		it.first -= x * (cur_moves - moves);
		it.second -= y * (cur_moves - moves);
	}
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ui64 n;
	cin >> n;
	if (n == 0)
	{
		cout << "0 0";
		return 0;
	}
	double m = n / 6.0;
	base = floor((-1.0 + sqrt(1.0 + 4.0 * 2.0 * m)) / 2.0);
	it = make_pair(2 * base + 1, 2);
	moves = n - (base)*(base+1) * 3;
	move(base, -1, 2);
	move(base + 1, -2, 0);
	move(base + 1, -1, -2);
	move(base + 1, 1, -2);
	move(base + 1, 2, 0);
	move(base + 1, 1, 2);
	cout << it.first << " " << it.second;
	return 0;
}

#include<iostream>
#include<algorithm>
#include<cmath>
#define ll long long int
using namespace std;
int main()
{
	ll n , l ,r,mid , i;
	cin>>n;

	l = 0 , r = 1000000000;

	ll nc = (sqrt(9 + 12*n)-3)/6;
	mid = nc;
	ll temp = n -  3*(mid*(mid+1));
	ll x = 2 * mid;
	ll y = 0 , p =0;
	//cout<<x<<" "<<y<<" "<<temp<<" "<<nc<<endl;
	nc = nc+1;
	if(nc == 0)
	{
		if(n == 0)
		{x = 0;y = 0;}

		if(n==1){x = 1;y=2;
		}
		if(n==2){x= -1;y=2;
		}
		if(n==3){x = -2;y=0;
		}
		if(n==4){x= -1;y=-2;
		}
		if(n==5){x = 1;y=-2;
		}
		if(n == 6){x = 2;y=0;
		}
	}

	else
	{
	for(i = 0;i<(nc/2) && p < temp;i++)
	{
		p++;
		x++;
		y =y+2;
	}

	for(i=0;i<(nc/2 + nc%2) && p < temp;i++)
	{
		p++;
		x--;
		y = y+2;
	}
	temp = temp - p;
	if(temp >= nc)
	{
		x = x - nc*2;
		temp = temp - nc;
	}
	else
	{
		x = x - (temp)*2;
		temp = 0;
	}

	if(temp >= nc)
	{
		x = x - nc;
		y = y - 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x - temp;
		y = y - 2*temp;
		temp = 0;
	}

	if(temp >= nc)
	{
		x = x + nc;
		y = y - 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x + temp;
		y = y - 2*temp;
		temp = 0;
	}
	if(temp >= nc)
	{
		x = x + 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x - 2*temp;
		//y = y - temp;
		temp = 0;

    }
	if(temp >= nc)
	{
		x = x + nc;
		y = y + 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x + temp;
		y = y + 2*temp;
		temp = 0;
	}
}
	cout<<x<<" "<<y<<endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) ((n) & (1LL << (i)))
#define bitcount(n) __builtin_popcount(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = (int) 1e9 + 7) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = 2 * acos((ld) 0);

void solve() {
	ll n; scanf("%I64d", &n);
	if (n == 0) {
		printf("%I64d %I64d", 0, 0);
		return;
	}
	ll l = 0, r = 600000000LL;
	while (l < r) {
		ll m = (l + r + 1) >> 1;
		if (3 * m * (m - 1) + 1 < n) l = m; else r = m - 1;
	}
	ll d = n - 3 * l * (l - 1);
	if (d < l) {
		printf("%I64d %I64d", 2 * l - d, 2 * d);
	}
	else if (d < 2 * l) {
		d -= l;
		printf("%I64d %I64d", l - 2 * d, 2 * l);
	}
	else if (d < 3 * l) {
		d -= 2 * l;
		printf("%I64d %I64d", -l - d, 2 * l - 2 * d);
	}
	else if (d < 4 * l) {
		d -= 3 * l;
		printf("%I64d %I64d", -2 * l + d, -2 * d);
	}
	else if (d < 5 * l) {
		d -= 4 * l;
		printf("%I64d %I64d", -l + 2 * d, -2 * l);
	}
	else {
		d -= 5 * l;
		printf("%I64d %I64d", l + d, -2 * l + 2 * d);
	}
}

int main() {
//	ios_base::sync_with_stdio(0); cin.tie(NULL);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, l, r) for (ll (i) = (l); (i) < (r); ++(i))
#define FORD(i, l, r) for (ll (i) = (l); (i) > (r); --(i))
#define True true
#define False false
#define S second
#define F first
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define eps 1e-9
#define db(x) cerr << endl <<#x << " = " << x << endl
#define sqr(x) (x) * (x)

#define x0 pelfpskfo
#define y0 issgksknkdns
#define x1 kjwoieill
#define y1 poposkdlkd

typedef long long ll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ld pi = acos(-1.0);
ll gcd (ll n1, ll n2) {return ((n2) == 0) ? (n1) : gcd ((n2), (n1) % (n2));}
ll lcm (ll n1, ll n2) {return n1 * n2 / gcd(n1, n2);}
const ll p = 239;
void f(string t, string s)
{
    vll p_pow (max(s.length(), t.length()));
    p_pow[0] = 1;
    for (size_t i=1; i<p_pow.size(); ++i)
        p_pow[i] = (p_pow[i-1] * p) % MOD;
    vll h (t.length());
    for (size_t i=0; i<t.length(); ++i)
    {
        h[i] = ((t[i] - 'a' + 1) * p_pow[i]) % MOD;
        if (i)  h[i] += h[i-1];
        h[i] %= MOD;
    }
    ll h_s = 0;
    for (size_t i=0; i<s.length(); ++i){
        h_s += (s[i] - 'a' + 1) * p_pow[i];
        h_s %= MOD;
    }
    for (size_t i = 0; i + s.length() - 1 < t.length(); ++i)
    {
        long long cur_h = h[i+s.length()-1];
        if (i)  cur_h = (cur_h - h[i-1] + MOD) % MOD;
        if (cur_h == (h_s * p_pow[i]) % MOD)
            cout << i << ' ';
    }
}

int main()
{
    ld num1;
    ll n, num2, k;
    cin >> n;
    num1 = n / 6;
    k = (ll)((1 + sqrt(1 + num1 * 8)) / 2);
    num2 = n - 6 * (k);
    if (num2 <= 0)
    {
        cout << 2 * (k - 1) << " " << 0;
        return 0;
    }
    ll x, y;
    if (num2 <= k){
        x = 2 * k - num2;
        y = 2 * num2;
    }
    else{
        if (num2 <= 2 * k){
            num2 -= k;
            x = k - 2 * num2;
            y = 2 * k;
        }
        else{
            if (num2 <= 3 * k){
                num2 -= 2 * k;
                x = -k - num2;
                y = 2 * k - 2 * num2;
            }
            else{
                if (num2 <= 4 * k){
                    num2 -= 3 * k;
                    x = (-2) * k + num2;
                    y = (-2) * num2;
                }
                else{
                    if (num2 <= 5 * k){
                        num2 -= 4 * k;
                        x = -k + 2 * num2;
                        y = (-2) * k;
                    }
                    else{
                        if (num2 <= 6 * k){
                            num2 -= 5 * k;
                            x = k + num2;
                            y = (-2) * k + 2 * num2;
                        }
                    }
                }
            }
        }
    }
    //db(k);
    cout << x  << " " << y;
    return 0;
}

#include<cstdio>
#include<cmath>
using namespace std;
int main(void)
{
	long long n;
	while(scanf("%lld",&n)==1)
	{
		if(n==0)
		{
			printf("0 0\n");
			continue;
		}
		n--;
		double delta=sqrt(9+12*n);
		long long num=(long long)(sqrt(9+12*n)-3)/6.0;
		num++;
		n-=3*num*(num-1);
		if(n<num)
		{
			printf("%lld %lld\n",num*2-1-n,2+2*n);
			continue;
		}
		n-=num;
		if(n<num)
		{
			printf("%lld %lld\n",num-2-2*n,2*num);
			continue;
		}
		n-=num;
		if(n<num)
		{
			printf("%lld %lld\n",-1-num-n,2*num-2*n-2);
			continue;
		}
		n-=num;
		if(n<num)
		{
			printf("%lld %lld\n",-2*num+1+n,-2+(-2)*n);
			continue;
		}
		n-=num;
		if(n<num)
		{
			printf("%lld %lld\n",2-num+2*n,-2*num);
			continue;
		}
		n-=num;
		printf("%lld %lld\n",num+n+1,2-2*num+2*n);
	}
	return 0;
}

/****************
*PID:615e div2
*Auth:Jonariguez
*****************
第i层要走6*i个六边形。
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;

LL n;
LL dx[6]={-1,-2,-1,1,2,1};
LL dy[6]={2,0,-2,-2,0,2};

int main()
{
    LL i,j,res;
    while(scanf("%I64d",&n)!=EOF){
        if(n==0){
            printf("0 0\n");continue;
        }
        LL l=0,r=10000000000;
        while(l<r-1){
            LL m=(l+r)/2;
            if(3*m*m+3*m<n)
                l=m;
            else r=m;
        }
        while(3*l*l+3*l<=n) l++;
        while(3*l*l+3*l>=n) l--;
        n-=3*l*l+3*l;
        LL cnt=l+1;
       // LL cnt=1;
     /*   while(n>cnt*6){
            n-=cnt*6;cnt++;
        }*/
        LL x=(cnt-1)*2,y=0;
        n--;
        x++;y+=2;
        LL dc[6]={cnt-1,cnt,cnt,cnt,cnt,cnt};
        for(i=0;i<6;i++){
            if(n>=dc[i]){
                x+=dx[i]*dc[i];y+=dy[i]*dc[i];
                n-=dc[i];
            }else {
                x+=n*dx[i];y+=n*dy[i];
                break;
            }
        }
        printf("%I64d %I64d\n",x,y);
    }
    return 0;
}

#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <queue>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

int main () {
	long long n;
	cin >> n;
	long long l = 0;
	long long r = n / 3LL;
	while (l != r) {
		long long m = (l + r + 1) / 2;
		if (m * (m - 1) * 3LL < n) {
			l = m;
		} else {
			r = m - 1;
		}
	}
	//cout << l << endl;
	n -= l * (l - 1) * 3LL;
	if (l == 0) {
		l = 1;
	}
	l++;
	long long x = 2LL * (l - 1);
	long long y = 0;
	int t = 0;
	if (n >= (l - 1)) {
		n -= (l - 1);
		x -= (l - 1);
		y += 2LL * (l - 1);
		t = 1;
	}
	if (n >= l - 1) {
		n -= (l - 1);
		x -= 2LL * (l - 1);
		t = 2;
	}
	if (n >= l - 1) {
		n -= (l - 1);
		x -= (l - 1);
		y -= 2LL * (l - 1);
		t = 3;
	}
	//cout << n<< endl;
	if (n >= l - 1) {
		x += 1LL * (l - 1);
		y -= 2LL * (l - 1);
		n -= (l - 1);
		t = 4;
	}
	if (n >= l - 1) {
		x += 2LL * (l - 1);
		n -= (l - 1);
		t = 5;
	}
	if (t == 0) {
		x -= n;
		y += 2LL * n;
	}
	if (t == 1) {
		x -= 2LL * n;
	}
	if (t == 2) {
		x -= n;
		y -= 2LL * n;
	}
	if (t == 3) {
		x += n;
		y -= 2LL * n;
	}
	if (t == 4) {
		x += 2LL * n;
	}
	if (t == 5) {
		x += n;
		y += 2LL * n;
	}
	cout << x << ' ' << y << endl;
 	return 0;
}

#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <cstdint>
#include <functional>
#include <array>
#include <valarray>
#include <iomanip>
#include <cassert>
#include <memory>

using namespace std;
namespace mainns
{

template<typename T, size_t n>
class GeomVector
{
public:
    GeomVector()
    {
        comps_ = std::array<T, n>{};
    }

    GeomVector(const std::array<T, n>& from) : comps_(from) {}

	T& operator[](size_t ind) { return comps_[ind]; }
	const T& operator[](size_t ind) const { return comps_[ind]; }

	bool operator==(const GeomVector& other) const { return comps_ == other.comps_; }

	T lengthSquared() const
	{
		return std::accumulate(begin(comps_), end(comps_), T(), [](const T& a, const T& b) {
			return a + b * b;
		});
	}

	const GeomVector& operator+=(const GeomVector& other)
	{
		for (int i = 0; i < n; ++i)
			comps_[i] += other.comps_[i];
		return *this;
	}

	const GeomVector& operator-=(const GeomVector& other)
	{
		for (int i = 0; i < n; ++i)
			comps_[i] -= other.comps_[i];
		return *this;
	}

	const GeomVector& operator*=(const T& multiplier)
	{
		for (int i = 0; i < n; ++i)
			comps_[i] *= multiplier;
		return *this;
	}

private:
	std::array<T, n> comps_;
};

template<typename T, size_t n>
GeomVector<T, n> operator+(const GeomVector<T, n>& a, const GeomVector<T, n>& b)
{
	auto res = a;
	res += b;
	return res;
}

template<typename T, size_t n>
GeomVector<T, n> operator-(const GeomVector<T, n>& a, const GeomVector<T, n>& b)
{
	auto res = a;
	res -= b;
	return res;
}

template<typename T, size_t n>
GeomVector<T, n> operator*(const GeomVector<T, n>& a, const T& b)
{
	auto res = a;
	res *= b;
	return res;
}

template<typename T, size_t n>
GeomVector<T, n> operator*(const T& a, const GeomVector<T, n>& b)
{
	auto res = b;
	res *= a;
	return res;
}

template<typename T, size_t n>
bool operator<(const GeomVector<T, n>& a, const GeomVector<T, n>& b)
{
	for (int i = 0; i < n; ++i)
	{
		if (a[i] < b[i])
			return true;
		else if (a[i] > b[i])
			return false;
	}
	return false;
}

template<class T, size_t n>
T dot(const GeomVector<T, n>& a, const GeomVector<T, n>& b)
{
    T res{};
    for (int i = 0; i < n; ++i)
        res += a[i] * b[i];
    return res;
}

template<typename T>
using GeomVector2 = GeomVector<T, 2>;
using GeomVector2I = GeomVector2<int>;

template<typename T>
T det(const GeomVector2<T>& a, const GeomVector2<T>& b)
{
	return a[0] * b[1] - a[1] * b[0];
}

class Solver613E
{
public:
    void run();
};

void Solver613E::run()
{
    int64_t n;
    cin >> n;
    if (n == 0)
    {
        cout << "0 0";
        return;
    }

    int64_t k = sqrt(double(n) / 3) + 0.9999999999;
    n -= 3 * k * (k - 1);
    GeomVector2<int64_t> pos({ 2 * (k - 1), 0 });
    if (n <= 1)
    {
        pos += n * GeomVector2<int64_t>({ int64_t(1), int64_t(2) });
        cout << pos[0] << " " << pos[1];
        return;
    }

    pos += GeomVector2<int64_t>({ int64_t(1), int64_t(2) });
    n -= 1;

    if (n <= k - 1)
    {
        pos += n * GeomVector2<int64_t>({ int64_t(-1), int64_t(2) });
        cout << pos[0] << " " << pos[1];
        return;
    }

    pos += (k - 1) * GeomVector2<int64_t>({ int64_t(-1), int64_t(2) });
    n -= k - 1;

    if (n <= k)
    {
        pos += n * GeomVector2<int64_t>({ int64_t(-2), int64_t(0) });
        cout << pos[0] << " " << pos[1];
        return;
    }

    pos += k * GeomVector2<int64_t>({ int64_t(-2), int64_t(0) });
    n -= k;

    if (n <= k)
    {
        pos += n * GeomVector2<int64_t>({ int64_t(-1), int64_t(-2) });
        cout << pos[0] << " " << pos[1];
        return;
    }

    pos += k * GeomVector2<int64_t>({ int64_t(-1), int64_t(-2) });
    n -= k;

    if (n <= k)
    {
        pos += n * GeomVector2<int64_t>({ int64_t(1), int64_t(-2) });
        cout << pos[0] << " " << pos[1];
        return;
    }

    pos += k * GeomVector2<int64_t>({ int64_t(1), int64_t(-2) });
    n -= k;

    if (n <= k)
    {
        pos += n * GeomVector2<int64_t>({ int64_t(2), int64_t(0) });
        cout << pos[0] << " " << pos[1];
        return;
    }

    pos += k * GeomVector2<int64_t>({ int64_t(2), int64_t(0) });
    n -= k;

    if (n <= k)
    {
        pos += n * GeomVector2<int64_t>({ int64_t(1), int64_t(2) });
        cout << pos[0] << " " << pos[1];
        return;
    }
}

} //namespace mainns
using CurrentSolver = mainns::Solver613E;
#ifdef ONLINE_JUDGE
int main()
#else
int main2()
#endif
{
    ios::sync_with_stdio( false );
    CurrentSolver().run();
	return 0;
}

#include <bits/stdc++.h>
//arshak.khoshnevis

using namespace std;

const long long inf = 6e9 + 10;
int dx[7] = {1, -1, -2, -1, 1, 2, 1};
int dy[7] = {2, +2, 0, -2, -2, 0, 2};
long long n, res, nx, ny, cnt, c, old;

long long BS() {
	long long l = 0, r = inf, mid;
	while(l + 1 != r) {
		mid = (l + r) / 2;
		c = (6 * (mid * (mid - 1) / 2));
		if(c < n)
			l = mid;
		else
			r = mid;
	}
	return l;
}

bool isCorner() {
	if(!ny || (ny == 2 && nx == (res * 2) - 1))
		return 1;
	if(!(nx & 1))
		return 0;
	if(nx > 0 && ny > 0 && nx == res && ny == res * 2)
		return 1;
	if(nx < 0 && ny > 0 && nx == -res && ny == res * 2)
		return 1;
	if(nx < 0 && ny < 0 && nx == -res && ny == -res * 2)
		return 1;
	if(nx > 0 && ny < 0 && nx == res && ny == -res * 2)
		return 1;
	return 0;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n, old = n;
	if(!n)
		return cout << nx << " " << ny << endl, 0;
	res = BS();
	n -= ((res * (res - 1)) / 2) * 6 + 1;
	nx = 2 * (res - 1), ny = 0, n++;
	while(n > 0) {
		nx += dx[cnt], ny += dy[cnt];
		if(isCorner())
			cnt++;
		if(cnt == 1 && old < 7)
			cnt++;
		if(cnt >= 7)
			break;
		n--;
	}
	return cout << nx << " " << ny << endl, 0;
}

#include <bits/stdc++.h>
#define A first
#define B second
#define endl '\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef long double T;
typedef pair<T, T> PTT;

int main(){
    int N; cin >> N;
    T x = (T) N * (T) 4.0 / (T) 3.0;
    x += 0.00000000323;
    T root = -1 + sqrt(x+1);
    root /= 2;
    int k = (int) root;
    int y = 2*k;
    int z  = 0;
    N -= 3*k*(k+1);
    if (N == 0){
        cout << y << ' ' << z << endl;
        return 0;
    }
    if (N > 1){
        N--;
        y = 2*k+1;
        z = 2;
        if (N > k){
            N -= k;
            y -= k;
            z += 2*k;
            if (N > k+1){
                N -= (k+1);
                y -= 2*(k+1);
                if (N > k+1){
                    N -= (k+1);
                    y -= (k+1);
                    z -= 2*(k+1);
                    if (N > (k+1)){
                        N -= (k+1);
                        y += (k+1);
                        z -= 2*(k+1);
                        if (N > k+1){
                            y += 2*(k+1);
                            N -= (k+1);
                            y += N;
                            z += 2*N;
                            cout << y << ' ' << z << endl;
                            return 0;
                        }
                        else{
                            y += 2*N;
                            cout << y << ' ' << z << endl;
                            return 0;
                        }
                    }
                    else{
                        y += N;
                        z -= 2*N;
                        cout << y << ' ' << z << endl;
                        return 0;
                    }
                }
                else{
                    y -= N;
                    z -= 2*N;
                    cout << y << ' ' << z << endl;
                    return 0;
                }
            }
            else{
                y -= 2*N;
                cout << y << ' ' << z << endl;
                return 0;
            }
        }
        else{
            y -= N;
            z += 2*N;
            cout << y << ' ' << z << endl;
            return 0;
        }
    }
    else{
        cout << 2*k+1 << ' ' << 2 << endl;
        return 0;
    }
}

#include<iostream>
#include<algorithm>
#include<cmath>
#define ll long long int
using namespace std;
int main()
{
	ll n , l ,r,mid , i;
	cin>>n;

	l = 0 , r = 1000000000;

	ll nc = (sqrt(9 + 12*n)-3)/6;
	mid = nc;
	ll temp = n -  3*(mid*(mid+1));
	ll x = 2 * mid;
	ll y = 0 , p =0;
	//cout<<x<<" "<<y<<" "<<temp<<" "<<nc<<endl;
	//nc = nc+1;
	if(nc == 0)
	{
		if(n == 0)
		{x = 0;y = 0;}

		if(n==1){x = 1;y=2;
		}
		if(n==2){x= -1;y=2;
		}
		if(n==3){x = -2;y=0;
		}
		if(n==4){x= -1;y=-2;
		}
		if(n==5){x = 1;y=-2;
		}
		if(n == 6){x = 2;y=0;
		}
	}

	else
	{
		nc = nc+1;
	for(i = 0;i<(nc/2) && p < temp;i++)
	{
		p++;
		x++;
		y =y+2;
	}

	for(i=0;i<(nc/2 + nc%2) && p < temp;i++)
	{
		p++;
		x--;
		y = y+2;
	}
	temp = temp - p;
	if(temp >= nc)
	{
		x = x - nc*2;
		temp = temp - nc;
	}
	else
	{
		x = x - (temp)*2;
		temp = 0;
	}

	if(temp >= nc)
	{
		x = x - nc;
		y = y - 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x - temp;
		y = y - 2*temp;
		temp = 0;
	}

	if(temp >= nc)
	{
		x = x + nc;
		y = y - 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x + temp;
		y = y - 2*temp;
		temp = 0;
	}
	if(temp >= nc)
	{
		x = x + 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x - 2*temp;
		//y = y - temp;
		temp = 0;

    }
	if(temp >= nc)
	{
		x = x + nc;
		y = y + 2*nc;
		temp = temp - nc;
	}
	else
	{
		x = x + temp;
		y = y + 2*temp;
		temp = 0;
	}
}
	cout<<x<<" "<<y<<endl;
}

#include <bits/stdc++.h>

using namespace std;

int fx[] = {1, -2, -1, 1, 2, 1};
int fy[] = {2, 0, -2, -2, 0, 2};

typedef long long INT;

int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("test.out","w",stdout);
#endif
	INT N; cin>>N;
	INT Ring = sqrt(N / 3);

	if(N == 0){
		printf("0 0\n");
		return 0;
	}

	if(Ring * (Ring + 1) * 3 < N ) Ring ++;
	N -= Ring * (Ring - 1) * 3;
	INT x = Ring * 2 - 2, y = 0;

	for(int i = 0; i < 6 ; i ++ ) {
		if(N < Ring){
			x += N * fx[i];
			y += N * fy[i];
			break;
		}
		x += Ring * fx[i];
		y += Ring * fy[i];
		N -= Ring;
	}

	cout<<x<<" "<<y<<endl;

	return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) ((n) & (1LL << (i)))
#define bitcount(n) __builtin_popcount(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = (int) 1e9 + 7) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = 2 * acos((ld) 0);

void solve() {
	ll n; scanf("%I64d", &n);
	if (n == 1) {
		printf("%I64d %I64d", 0, 0);
		return;
	}
	ll l = 0, r = 600000000LL;
	while (l < r) {
		ll m = (l + r + 1) >> 1;
		if (3 * m * (m - 1) + 1 < n) l = m; else r = m - 1;
	}
	ll d = n - 3 * l * (l - 1);
	if (d < l) {
		printf("%I64d %I64d", 2 * l - d, 2 * d);
	}
	else if (d < 2 * l) {
		d -= l;
		printf("%I64d %I64d", l - 2 * d, 2 * l);
	}
	else if (d < 3 * l) {
		d -= 2 * l;
		printf("%I64d %I64d", -l - d, 2 * l - 2 * d);
	}
	else if (d < 4 * l) {
		d -= 3 * l;
		printf("%I64d %I64d", -2 * l + d, -2 * d);
	}
	else if (d < 5 * l) {
		d -= 4 * l;
		printf("%I64d %I64d", -l + 2 * d, -2 * l);
	}
	else {
		d -= 5 * l;
		printf("%I64d %I64d", l + d, -2 * l + 2 * d);
	}
}

int main() {
//	ios_base::sync_with_stdio(0); cin.tie(NULL);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <string>
#include <cstring>
#include <cassert>

using namespace std;

const int maxn = 21;
const int MOD = 1e9 + 7;

#define rep(i, x, y) for (int i = x; i <= y; i++)
#define mset(arr) memset(arr, 0, sizeof(arr))

int64_t n;
const int dir[6][2] = {{-1, 2}, {-2, 0}, {-1, -2}, {1, -2}, {2, 0}, {1, 2}};

int main() {
    while (cin >> n) {
        // the first circle = 6
        // the second circle = 12
        // the nth circle = 6*n
        //
        // On the end of nth circle, the number of moves is
        // 6 + 6*2 + ... + 6*n
        // = 6n*(n+1)/2
        // = 3n*(n+1)
        //
        // On the nth move, we are on the mth circle.
        // 3m*(m-1) < n <= 3m*(m+1) (m>=1, n>=1)
        //
        // binary search the result m
        //
        if (n == 0) {
            printf("0 0\n");
            continue;
        }

        int64_t l = 0, r = 10 ^ 9;
        int64_t m;
        while (r - l > 1) {
            m = (r + l) / 2;
            if (3 * m * (m - 1) >= n) {
                r = m;
            } else if (3 * m * (m + 1) < n) {
                l = m;
            } else {
                // 3m*(m-1) < n <= 3m*(m+1)
                break;
            }
        }

        cout << m << endl;

        int64_t d = n - 3 * m * (m - 1);
        int64_t i = 0;
        int64_t x = 2 * m, y = 0;
        while (d) {
            if (d > m) {
                d -= m;
                x += m * dir[i][0];
                y += m * dir[i][1];
                i++;
            } else {
                x += d * dir[i][0];
                y += d * dir[i][1];
                break;
            }
        }
        cout << x << " " << y << endl;
    }
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <string.h>
#include <set>
#include <algorithm>
#include <map>
#ifdef lyosha
#define files freopen("input.txt", "r", stdin);
#else
#define files //freopen("howmany.in","r",stdin); freopen("howmany.out","w",sdout);
#endif
using namespace std;
typedef long long ll;
#define y1 vsdmlkcs
const int N = 2105;
const int mod = 1e9 + 7;
ll f(ll cur){
    return 3 * (cur * (cur + 1));
}
int main()
{
    //files;
    ll n;
    cin >> n;
    ll step = 0;
    while(f(step + 100000) <= n){
        step += 100000;
    }
    while(f(step + 10000) <= n){
        step += 10000;
    }
    while(f(step + 100) <= n){
        step += 100;
    }
    while(f(step + 1) <= n){
        step += 1;
    }
    n -= f(step);
    step++;
    if(n > 6 * step) while(true);
    ll x = 2 * (step - 1);
    ll y = 0;
    if(n <= step){
        cout << x + n << " " << y + 2 * n << endl;
        return 0;
    }
    x += step;
    y += 2 * step;
    n -= step;

    if(n <= step){
        cout << x - 2 * n << " " << y << endl;
        return 0;
    }
    x -= 2 * step;
    y += 0;
    n -= step;

    if(n <= step){
        cout << x - n << " " << y - 2 * n << endl;
        return 0;
    }
    x -= step;
    y -= 2 * step;
    n -= step;

    if(n <= step){
        cout << x + n << " " << y - 2 * n << endl;
        return 0;
    }
    x += step;
    y -= 2 * step;
    n -= step;

    if(n <= step){
        cout << x + 2 * n << " " << y << endl;
        return 0;
    }
    x += 2 * step;
    y += 0;
    n -= step;

    if(n <= step){
        cout << x + n << " " << y + 2 * n << endl;
        return 0;
    }
    x += step;
    y += 2 * step;
    n -= step;
    return 0;
}

#include <iostream>
#include <iomanip>
#include <strstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iterator>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <ctime>
#define INF 0x7FFFFFFF
#define Sqr(x) ((x)*(x))
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long LL;
typedef long double LD;
using namespace std;
const int MOD = 1e9+7;
const int maxn = 100000+5;
const LD eps = 1e-6;
LD PI = acos((LD)(-1));

LL n, cnt, stage;
pair<LL, LL> start;
pair<LL, LL> now;
pair<int, int> mov[7];
int cc[7];

inline LL f(LL x) { return 3*Sqr(x)+2*x; }

int BS(LL key, int len) {
    int left = 0, right = len-1;
    int mid;
    while (left <= right) {
        mid = left + (right - left)/2;
        if (f(mid) < key) left = mid + 1;
        else right = mid - 1;
    }
    return left;
}

int main() {
    //freopen("input.in", "r", stdin);
    //std::ios_base::sync_with_stdio(false);

    cin >> n;
    if (n == 0) { cout << "0 0" << endl; return 0; }
    cnt = BS(n, 1e9);
    start = MP(cnt-1, 2-2*cnt);
    now = start; stage = 1;
    cc[2] = -1;

    mov[1] = MP(1, 2); mov[2] = MP(-1, 2);
    mov[3] = MP(-2, 0); mov[4] = MP(-1, -2);
    mov[5] = MP(1, -2); mov[6] = MP(2, 0);

    int sz = n - f(cnt-1);
    for (int i = 0; i < sz;) {
        int h = cnt+cc[stage];
        if (sz-i >= h) {
            now.F += h*mov[stage].F;
            now.S += h*mov[stage].S;
            stage++;
            i += h;
            continue;
        }
        now.F += mov[stage].F;
        now.S += mov[stage].S;
        i++;
    }
    cout << now.F << ' ' << now.S << endl;

    return 0;
}

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

#define pb push_back
#define lb lower_bound
#define ull unsigned ll
#define gcd(a,b) __gcd(a,b)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define ll long long
#define ld long double
#define mp make_pair
#define pi 3.14159265358979323846

#define mod 1000000007
#define inf (1LL<<31)-1

ll dx[] = {-1,-2,-1,1,2,1};
ll dy[] = {2,0,-2,-2,0,2};

int main()
{
    int i,j,k;
    ll n;
    while(cin>>n)
    {
        ll x = (sqrt(1+(n+1)/3.0*4)-1)/2;
        //if(n==x*3.0*(x+1)) printf("yes\n");
        if(n==x*3.0*(x+1)) x--;
        ll p = x + 1;
        n -= x*3.0*(x+1);
        //if(n%6==0) cout << "yes\n";
        x += x;
        ll y = 0;
        x += 1;
        y += 2;
        n--;
        //cout << "n = " << n<<" x = " <<x <<" y = " << y << endl;
        for(i=0;i<6;i++)
        {
            if(n==0) break;
            ll t;
            if(i==0)
            {
                t = min(p-1,n);
                x += dx[i] * t;
                y += dy[i] * t;
                n -= t;
            }
            else
            {
                t = min(n,p);
                x += dx[i] * t;
                y += dy[i] * t;
                n -= t;
            }
           // cout << "n = " << n<<" t = " << t << " x = " <<x <<" y = " << y << endl;
        }
        cout <<x <<' ' << y << endl;
    }
}