As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are those that are representable as a sum of two triangular numbers.A well-known hipster Andrew adores everything funky and cool but unfortunately, he isn't good at maths. Given number n, help him define whether this number can be represented by a sum of two triangular numbers (not necessarily different)!

The first input line contains an integer n (1 ≤ n ≤ 109).

Print "YES" (without the quotes), if n can be represented as a sum of two triangular numbers, otherwise print "NO" (without the quotes).

NoteIn the first sample number .In the second sample number 512 can not be represented as a sum of two triangular numbers.

#rextester.com:2.7.12--codeforces.com:2.7.12
import math
a=int(raw_input())*2;b=0
for i in range(1,int(math.sqrt(a))):
    c=a-i*i-i;d=int(math.sqrt(c))
    if d*(d+1)==c:b=1
print("YES")if(b)else"NO"

n = int(raw_input())

yes = 0
N = 100005
for k in range(1, N):
	target = n - (k*(k+1)/2)
	if (target < 0): break
	l = 1
	r = N
	ans = -1
	while (l <= r):
		mid = (l+r)/2
		cur = mid*(mid+1)/2
		if (cur == target):
			ans = mid
			break
		elif (cur < target):
			l = mid+1
		else:
			r = mid-1
	if (ans != -1):
		yes = 1
		break

if (yes):
	print "YES"
else:
	print "NO"

__author__ = 'Lenovo'
M = 45000
s = set(x * (x + 1) / 2 for x in xrange(1, M))
n = int(raw_input())

def solve():
    for i in s:
        if n - i in s:
            return 'YES'
    return 'NO'

print solve()

def main():
    n = int(input())
    lookup = set()
    k = 1
    while k * (k + 1) // 2 <= n:
        lookup.add(k * (k + 1) // 2)
        k += 1

    ok = False
    for elm in lookup:
        if elm < n:
            if n - elm in lookup:
                ok = True
    if ok:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

from sys import stdin

t=[(x*(x+1)//2) for x in range(44730)]
num = int(stdin.readline().strip())

i,found = 1,False
for y in range(len(t)):
    if 2*t[y]==num:
        found=True

while found==False and t[i]<num:
    target = num-t[i]
    low,hi = i,44730
    while found==False and low+1<hi:
        mid = low+((hi-low)//2)
        if t[mid]==target:
            found = True
        elif t[mid]<target:
            low = mid
        else:
            hi = mid
    i += 1
if found:
    print("YES")
else:
    print("NO")

import math

def checkTriangular(n):
    odd = 1+(8*n)
    oddsqrt = math.sqrt(odd)
    return oddsqrt==int(oddsqrt)

num = int(input())
bool = False
diff = 1
i = 1
while i<=num//2:
	if checkTriangular(i) and checkTriangular(num-i):
		bool = True
		print('YES')
		break
	diff += 1
	i += diff
if bool==False:
    print('NO')

a=set([(i+1)*i/2 for i in range(1,1<<16)])
n=input()
print "YES"if[1 for i in a if n-i in a]else"NO"

T={k*(k+1)//2 for k in range(1,44721)}
n=int(input())
if any(n-j in T for j in T):
    print("YES")
else:
    print("NO")

t = set(x*(x+1)/2 for x in range(1,45001))
n=input()
for i in t:
    if n-i in t:
        print 'Yes'
        exit()
print 'No'

t=set([x*(x+1)/2 for x in xrange(1,60000)])
n=input()
print 'YES' if [x for x in t if (n-x) in t] else 'NO'

from math import *

n = int(raw_input()) * 2

k = int(round(sqrt(n)))

found = False

for i in range(1, k):
    r = n - i * i - i
    x = int(floor(sqrt(r)))
    if x * (x + 1) == r:
        found = True
        break

print "YES" if found else "NO"

from bisect import bisect_left

if __name__ == '__main__':
    n = int(raw_input())
    i = 1
    t = 2
    a = [2]
    mid = 0

    while t < n * 2:
        i += 1
        t = i * (i + 1)
        a.append(t)
        if t <= n:
            mid = i

    for i in a[:mid + 1]:
        pos = bisect_left(a, n * 2 - i)
        if pos != len(a) and a[pos] == n * 2 - i:
            print 'YES'
            break
    else:
        print 'NO'

k= set([(i*(i+1))//2 for i in range(1,45000)])
n = int(input())
f = set([n - i for i in k])
t = k & f
if t:
    print('YES')
else:
    print('NO')

n=int(input())
j=1
sum = 1
ans='NO'
while j<= n//2:
    k=n-j
    p=int((8*k+1)**(0.5))
    if p*p==8*k+1:
        ans="YES"
        break
    sum+=1
    j+=sum
print(ans)

def binarysearch(ar,l,r,x):
	if r >= l:
		mid = l + (r-l)//2
		if ar[mid] == x:
			return mid
		elif ar[mid] < x:
			return binarysearch(ar,mid+1,r,x)
		else:
			return binarysearch(ar,l,mid-1,x)
	return -1
def funky(n):
	a = (int((2*n)**(.5))+int(2))
	ar = []
	for i in range(1,a):
		k = int(i*(i+1)/2)
		ar.append(k)
	return ar
def CoolestNum(ar,l,r,x):
	b = binarysearch(ar,l,r,x/2)
	if b != -1:
		return "YES"
	else:
		g = len(ar)
		for i in range(g-1,-1,-1):
			if ar[i] > x//2:
				diff = x - ar[i]
				term = binarysearch(ar,0,g-1,diff)
				if term != -1:
					return "YES"
	return "NO"

n = int(input())
ar = funky(n)
q = len(ar)
print(CoolestNum(ar,0,q-1,n))

n = input()
chisla = set([i*(i+1)/2 for i in range(1, 50000)])

if any([(n - h) in chisla for h in chisla]):
    print "YES"
else:
    print "NO"

from math import *
EPSILON = 0.000000000001
n = int(raw_input())
found = False

for k in range(1,31623):
    x = n - k*(k+1)/2
    if x < 0: break
    a = 1.0
    b = 1.0
    c = -2.0*x

    det = b**2 -4*a*c
    if det >= 0:
        m = (-b + det**0.5)/2.0
        if m > 0 and (m-floor(m) <EPSILON or ceil(m)-m < EPSILON):
            found = True
            #print k,m
            break

if found:
    print "YES"
else:
    print "NO"

import bisect

def bs(array,number):
    i=bisect.bisect_left(array,number)
    if i!=len(array) and array[i]==number:
        return True
    return False

def bs2(array,number):
    lo=0;hi=len(array)
    while lo<hi:
        mid=(lo+hi)>>1
        if (mid<number):
            lo=mid+1
        else:
            hi=mid
    if lo>=len(arr):
        return False
    return arr[lo]==number

n=int(raw_input())
arr=[]
can=True
for i in xrange(1,50000):
    arr.append(i*(i+1)//2)
for i in arr:
    y=n-i
    if y<0:
        can=False
        break
    if bs(arr,y):
        can=True
        break

print can and "YES" or "NO"

from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from datetime import *
from collections import * #deque, Counter,OrderedDict,defaultdict
import calendar
import heapq
import math
import copy
import itertools
myread = lambda : map(int,raw_input().split())
def solver():
    n = input()

    triangles = {(i * (i+1))/2 : 1 for i in range(1,44750)}

    for x in triangles:
        if n - x in triangles:
            print "YES"
            return
    print "NO"

if __name__ == "__main__":
    solver()

s = set([x*(x+1)/2 for x in range(1,45000)])
n = input()
flag = 0
for i in s:
    if n-i in s:
        flag = 1
if flag == 1: print 'YES'
else: print 'NO'

#rextester.com:2.7.12--codeforces.com:2.7.12
import math
a=int(raw_input())*2;b=0
for i in range(1,int(math.sqrt(a))):
    c=a-i*i-i;d=int(math.sqrt(c))
    if d*(d+1)==c:b=1
print("YES")if(b)else"NO"

import math
#n, m = input().split()
#n = int (n)
#m = int (m)
#n, m, k , l= input().split()
#n = int (n)
#m = int (m)
#k = int (k)
#l = int(l)
n = int(input())
#m = int(input())
#s = input()
##t = input()
#a = list(map(char, input().split()))
#a.append('.')
#print(l)
#c = list(map(int, input().split()))
#c = sorted(c)
#x1, y1, x2, y2 =map(int,input().split())
#n = int(input())
#f = []
#t = [0]*n
#f = [(int(s1[0]),s1[1]), (int(s2[0]),s2[1]), (int(s3[0]), s3[1])]
#f1 = sorted(t, key = lambda tup: tup[0])

l = 1
u = round(math.sqrt(n))*2
#u = n
f = False

while ( l <= u):
    #print(l, u)
    if(l*(l+1)+u*(u+1) < 2*n):
        l += 1
    elif(l*(l+1)+u*(u+1) > 2*n):
        u -= 1
    else:
        f = True
        break
if f:
    print("YES")
else:
    print("NO")

from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from datetime import *
from collections import * #deque, Counter,OrderedDict,defaultdict
import calendar
import heapq
import math
import copy
import itertools
myread = lambda : map(int,raw_input().split())
def solver():
    n = input()

    triangles = {(x * (x + 1)) / 2 for x in range(1,50000)}
    triangles = {}
    for i in range(1,50000):
        triangles[(i *(i+1)) / 2] = 1

    for x in triangles:
        if n - x in triangles:
            print "YES"
            return
    print "NO"

if __name__ == "__main__":
    solver()

import math
n = int(input())
i =int(math.sqrt(n))
j=i
res = 'NO'
while i>0 & j<n:
    if i*(i+1)/2+j*(j+1)/2==n:
        res='YES'
        break
    elif i*(i+1)/2+j*(j+1)/2<n:
        j+=1
    else:
        i-=1
print(res)

n=input()
k=l=[i*(i+1)/2 for i in range(1,80000)]
for i in l:
	while len(k)!=0 and k[-1]+i>n:
		del k[-1]
	if len(k)!=0 and k[-1]+i==n:
		print "YES"
		exit(0)
print "NO"

from itertools import combinations
n = int(input())
s = set()
for i in range(1,50000):
	x = i*(i+1)//2
	s.add(x)
for i in s:
	if n-i in s:
		print ("YES")
		exit()
print ("NO")

import math
n=int(input())
t=math.sqrt(n)
if(n==1):
    print("NO")
    exit(0)
else:
    for i in range(1,int(t)+1):
        q=n-(i*(i+1))/2
        q1=1+8*q;
        q2=math.sqrt(q1)
        q3=int(q2)
        if(q3*q3==q1):
           print("YES")
           exit(0)
print("NO")

#!/usr/bin/env python

a = set([(i * (i + 1)) / 2 for i in range(1, 1 << 16)])
n = int(raw_input())
print "YES" if [1 for i in a if n - i in a] else "NO"

import math

n = int(input())
a = 1
b = 1
c = -(2*n)
d = (b**2) - (4*a*c)
flag = 0
sol = (-b+math.sqrt(d))//(2*a)
ma = int(sol)
temp = 0
for i in range(1,ma+1):
    temp += i
    c = -(2*(n-temp))
    d = (b**2) - (4*a*c)
    sol = (-b + math.sqrt(d)) // (2 * a)
    if (sol*(sol+1))//2 + temp == n and sol > 0:
        flag = 1
        print("YES")
        break
if flag == 0:
    print("NO")

import bisect
def solve():
    n = input()
    SUM = []
    SUM.append(1)
    s = 1
    i = 1
    while s < n:
        s = s + (i+1)
        SUM.append(s)
        i += 1
    SUM_len = len(SUM)
    for i in range(SUM_len):
        x = SUM[i]
        y = n - x
        pos = bisect.bisect_left(SUM, y)
        if pos != SUM_len and SUM[pos] == y:
            return "YES"
    return "NO"

print solve()

l=[]
for i in range(1,10**5):
    l.append(i*(i+1)//2)
i=0
f=0
n=int(input())
j=10**5-5
while i<=j:
    if l[i]+l[j]==n:
        f=1
        break
    elif l[i]+l[j]<n:
        i+=1
    else:
        j-=1
if f==0:
    print('NO')
else:
    print('YES')

n=int(input())
d={}
t=0
for i in range(1,10**5):
    d[i*(i+1)/2]=1
for i in range(1,10**5):
    if n-(i*(i+1)/2) in d:
        t=1
        break
if t:
    print('YES')
else:
    print('NO')

n = int(input())
fs = set()
for i in range(n):
    f = i * (i + 1) // 2
    if f < n:
        fs.add(f)
        if n - f in fs:
            print('YES')
            exit()
    else:
        break
print('NO')

k= set([(i*(i+1))//2 for i in range(1,45000)])
n = int(input())
f = set([n - i for i in k])
t = k & f
if t:
    print('YES')
else:
    print('NO')

from math import *

n = int(raw_input()) * 2

k = int(round(sqrt(n)))

found = False

for i in range(1, k):
    r = n - i * i - i
    x = int(floor(sqrt(r)))
    if x * (x + 1) == r:
        found = True
        break

print "YES" if found else "NO"

import math
def fun(n):
    return (n*(n+1)/2)
n = int(input())
j = int(pow(n*2,0.5))
arr = [fun(i) for i in range(j+1)]
i=1
while(i<=j):
    a = arr[j]+arr[i]
    if(a==n):
        print("YES")
        break
    elif(a<n):
        i+=1
    elif(a>n):
        j-=1

else:
    print("NO")

hash_set = set()
for i in range(1,10**5):
    hash_set.add(i*(i+1)//2)
n = int(input())

if n==1:
    print('NO')
    exit()

i = 1
while True:
    temp = (i * (i+1) // 2 )
    if temp > n:
        print('NO')
        break
    elif (n - temp) in hash_set:
        print('YES')
        break
    i += 1

def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

I = lambda :list(map(int, input().split()))

a = set()
for i in range(1, 100000):
    a.add(i*(i+1)//2)
n, = I()
for i in a:
    if (n-i) in a:
        print('YES')
        exit()
print('NO')

from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from datetime import *
from collections import * #deque, Counter,OrderedDict,defaultdict
import calendar
import heapq
import math
import copy
import itertools
myread = lambda : map(int,raw_input().split())
def solver():
    n = input()

    triangles = [ (x * (x + 1)) / 2 for x in range(1,50000)]

    for i in range(len(triangles)):
        lp = i
        up = len(triangles) - 1
        now_num = triangles[i]
        while lp != up:
            mid = (lp + up) / 2

            if now_num + triangles[mid] < n:
                lp = mid + 1
            else:
                up = mid

        if now_num + triangles[lp] == n:
            #print now_num,triangles[lp]
            print "YES"
            return

    print "NO"

if __name__ == "__main__":
    solver()

MAX_RANGE = 50000

def chk(n):
    S = set([])
    for i in range(1, MAX_RANGE):
        S.add((i*(i+1))/2)
        if n - (i*(i+1))/2 in S:
            return True
    return False

if __name__ == '__main__':
    n = int(raw_input().strip())
    if chk(n):
        print "YES"
    else:
        print "NO"

import bisect

n = int(input()) * 2
triangles = [i * (i + 1) for i in range(1, int(n ** .5) + 2)]
for triangle in triangles:
    tri = triangles[bisect.bisect_left(triangles, n - triangle)]
    if tri <= triangle or tri + triangle == n:
        break

if tri + triangle == n:
    print('YES')
else:
    print('NO')

if __name__ == '__main__':
    N = 10**9
    tri_nums = set()
    i = 1
    while i * (i + 1) // 2 <= N:
        tri_nums.add(i * (i + 1) // 2)
        i += 1

    a = int(input())
    for num in tri_nums:
        if a - num in tri_nums:
            print("YES")
            break
    else:
        print("NO")

#_________________ Mukul Mohan Varshney _______________#

#Template
import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt,floor,factorial,gcd,log,ceil
from collections import deque,Counter,defaultdict
from itertools import permutations, combinations
import itertools

#define function
def Int(): return int(sys.stdin.readline())
def Mint(): return map(int,sys.stdin.readline().split())
def Lstr(): return list(sys.stdin.readline().strip())
def Str(): return sys.stdin.readline().strip()
def Mstr(): return map(str,sys.stdin.readline().strip().split())
def List(): return list(map(int,sys.stdin.readline().split()))
def Hash(): return dict()
def Mod(): return 1000000007
def Ncr(n,r,p): return ((fact[n])*((ifact[r]*ifact[n-r])%p))%p
def Most_frequent(list): return max(set(list), key = list.count)
def Mat2x2(n): return [List() for _ in range(n)]
def Lcm(x,y):  return (x*y)//gcd(x,y)
def dtob(n): return bin(n).replace("0b","")
def btod(n): return int(n,2)
def common(l1, l2):
    return set(l1).intersection(l2)

# Driver Code
def solution():
     #for _ in range(Int()):
          n=Int()
          t=[]
          p=0
          i=1
          while(1):
               a=(i*(i+1))//2
               if(a>=n):
                    break
               t.append(a)
               if n-a in t:
                    print("YES")
                    break
               else:
                    p+=1
               i+=1
          if(p==len(t)):
               print("NO")

#Call the solve function
if __name__ == "__main__":
     solution()

n=input()
k=l=[i*(i+1)/2 for i in range(1,80000)]
for i in l:
	while len(k)!=0 and k[-1]+i>n:
		del k[-1]
	if len(k)!=0 and k[-1]+i==n:
		print "YES"
		exit(0)
print "NO"

n = int(input())

fn = []
k=1
while True:
    num = (k*(k+1))//2
    if num>n:
        break
    fn.append(num)
    k+=1
i=0
j=len(fn)-1

while i<=j:
    if fn[i]+fn[j]==n:
        print("YES")
        break
    elif fn[i]+fn[j]<n:
        i+=1
    else:
        j-=1

if i>j or fn[i]+fn[j]!=n:
    print("NO")

n= int(input())
a= set()#[k*(k+1)//2 for k in range(1,n)])
for i in range (n):
    x = i*(i+1)//2
    if x >=n:
        print('NO')
        break
    a.add(x)
    if n-x in a:
        print('YES')
        break
else :
    print('NO')

from math import sqrt
a=input()*2

x=1
while(x*(x+1)<a):
    b=a-x*(x+1)
    c=int(sqrt(b))

    if b==c*(c+1):
        print 'YES'
        exit()
    x+=1

print 'NO'

#_________________ Mukul Mohan Varshney _______________#

#Template
import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt,floor,factorial,gcd,log,ceil
from collections import deque,Counter,defaultdict
from itertools import permutations, combinations
import itertools

#define function
def Int(): return int(sys.stdin.readline())
def Mint(): return map(int,sys.stdin.readline().split())
def Lstr(): return list(sys.stdin.readline().strip())
def Str(): return sys.stdin.readline().strip()
def Mstr(): return map(str,sys.stdin.readline().strip().split())
def List(): return list(map(int,sys.stdin.readline().split()))
def Hash(): return dict()
def Mod(): return 1000000007
def Ncr(n,r,p): return ((fact[n])*((ifact[r]*ifact[n-r])%p))%p
def Most_frequent(list): return max(set(list), key = list.count)
def Mat2x2(n): return [List() for _ in range(n)]
def Lcm(x,y):  return (x*y)//gcd(x,y)
def dtob(n): return bin(n).replace("0b","")
def btod(n): return int(n,2)
def common(l1, l2):
    return set(l1).intersection(l2)

# Driver Code
def solution():
     #for _ in range(Int()):
          n=Int()
          t=[]
          p=[]
          i=1
          while(1):
               a=(i*(i+1))//2
               if(a>=n):
                    break
               t.append(a)
               i+=1

          for i in range(len(t)):
               p.append(n-t[i])

          ans=common(t,p)
          if(len(ans)>0):
               print("YES")
          else:
               print("NO")

#Call the solve function
if __name__ == "__main__":
     solution()

def binary_search(arr,val):
	L = 0
	R = len(arr)-1
	while L<=R:
		mid = (L+R)/2
		if (arr[mid] == val):
			return True
		elif (arr[mid] < val):
			L = mid + 1
		else:
			R = mid - 1
	return False

n = int(raw_input())
arr = [i*(i+1)/2 for i in range(1,50000)]

found = False

for val in arr:
	if binary_search(arr,n-val):
		found = True

if found:
	print "YES"
else:
	print "NO"

n=int(input())
a=[]
b=[]
i=int(1)
f=0
while(1):
    a.append(int((i*(i+1))/2))
    if(a[len(a)-1]>=n):
        break
    i=i+1
for i in range(len(a)):
    b.append(n-a[i])
b.sort()
print("YES") if(set(a) & set(b)) else print("NO")

def binary_search(arr, start, end, x):
    if (end < start):
        # Element is not present in the array
        return -1
    else:
        mid = start + (end - start) // 2
        # If element is present at the middle
        if (arr[mid] == x):
            return mid
        # If element is smaller than mid
        elif (arr[mid] > x):
            return binary_search(arr, start, mid - 1, x)
        # Else the element greater than mid
        else:
            return binary_search(arr, mid + 1, end, x)

n = int(input())
total, num, c1, c2, mem = n * 2, 2, 2, 3, [2]

while (c1 * c2 < total):
    mem.append(c1 * c2)
    c1 += 1
    c2 += 1

for i in mem:
    if binary_search(mem, 0, len(mem) - 1,total - i) != -1:
        exit(print('YES'))

print('NO')

t = set(x*(x+1)/2 for x in range(1,45001))
n=input()
for i in t:
    if n-i in t:
        print 'Yes'
        exit()
print 'No'

from itertools import combinations
n = int(input())
s = set()
for i in range(1,50000):
	x = i*(i+1)//2
	s.add(x)
for i in s:
	if n-i in s:
		print ("YES")
		exit()
print ("NO")

import math
n=int(input())
x=int(math.sqrt(n))
l=x
r=x
first=0
if(l*(l+1)+r*(r+1)==2*n or ((l-1)*l+(r-1)*r)==2*n):
##	print "SDF"
	print "YES"
else:
	while(l>0):
		if((l*(l+1) + r*(r+1))> 2*n):
			l-=1
		elif((l*(l+1) + r*(r+1))< 2*n):
			r+=1
		else:
			first=1
			print "YES"
			break

	if(first==0):
		print "NO"

from math import sqrt
n=int(input())
i=int(sqrt(n))
j=i
p='NO'
while(i>0 and j<n):
    s=((i*(i+1))/2)+((j*(j+1))/2)
    if(s==n):
        p='YES'
        break
    if(s<n):
        j=j+1
    if(s>n):
        i=i-1
print(p)

def fun(l, n):
    left = 0
    right = len(l) - 1
    while(left <= right):
        if(l[left] + l[right] == n):
            print "YES"
            return
        elif(l[left] + l[right] < n):
            left += 1
        else:
            right -= 1
    print "NO"

n = input()
l = []
i = 1
while(i * (i + 1) / 2 < n):
    l.append(i *(i + 1) / 2)
    i += 1
fun(l, n)

a = set([(i+1)*i/2 for i in range(1,1<<16)])
n = int(input())
print "YES" if [1 for i in a if n-i in a ] else "NO"

mp = {}
for i in xrange(2, 100000):
    mp[i * i] = 1;

n = int(raw_input())
flag = False
for i in xrange(1, 31624):
    tmp = n - (i * i + i) / 2
    if (tmp <= 0): break
    r = 1 + 8 * tmp
    if r not in mp: continue
    else:
        flag = True
        break

if flag == False:
    print "NO"
else:
    print "YES"

n = int(input())
s = set()
c = 0
for i in range(1,50000):
    a = i*(i+1)//2
    s.add(a)
for j in s:
    if n-j in s:
        c = c+1
        print('YES')
        exit()
print('NO')

from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from datetime import *
from collections import * #deque, Counter,OrderedDict,defaultdict
import calendar
import heapq
import math
import copy
import itertools
myread = lambda : map(int,raw_input().split())
def solver():
    n = input()

    triangles = {(x * (x + 1)) / 2 for x in range(1,50000)}

    for x in triangles:
        if n - x in triangles:
            print "YES"
            return
    print "NO"

if __name__ == "__main__":
    solver()

a=set([(i+1)*i/2 for i in range(1,1<<16)])
n=input()
print "YES"if[1 for i in a if n-i in a]else"NO"

n= int(input())
import math
m= math.sqrt(n)
a= set([k*(k+1)//2 for k in range(1, int(2*m))])
for i in a:
    if n-i in a:
        print('YES')
        exit()

print('NO')

n=int(input())
s=set()
i=1
while i<100000:
    x=(i*(i+1))//2
    s.add(x)
    i+=1
for i in s:
    if n-i in s:
        print('YES')
        exit(0)
print('NO')

n = int(input())
if n == 1:
    print("NO")
else:
    a = [1]
    b = 1
    while a[-1] < n:
        b += 1
        a.append(int(b * (b + 1) / 2))
    a = a[:-1]
    r = b - 2
    l = 0
    while r != l and a[l] + a[r] != n:
        if a[l] + a[r] > n:
            r -= 1
        else:
            l += 1
    if a[l] + a[r] == n:
        print("YES")
    else:
        print("NO")

n=int(input())
a=[]
b=[]
i=int(1)
f=0
while(1):
    a.append(int((i*(i+1))/2))
    if(a[len(a)-1]>=n):
        break
    i=i+1
for i in range(len(a)):
    b.append(n-a[i])
b.sort()
print("YES") if(set(a) & set(b)) else print("NO")

hash_set = set()
for i in range(1,10**5):
    hash_set.add(i*(i+1)//2)
n = int(input())

if n==1:
    print('NO')
    exit()

i = 1
while True:
    temp = (i * (i+1) // 2 )
    if temp > n:
        print('NO')
        break
    elif (n - temp) in hash_set:
        print('YES')
        break
    i += 1

def code(n):
    return(n*(n+1)//2)
n=int(input())
k=1
a=set()
while code(k)<=n:
    a.add(code(k))
    k+=1
for i in a:
    if (n-i) in a:
        print("YES")
        break
else:
    print("NO")

n=int(input())
st=set([p*(p+1)/2 for p in range(1,55000)])

print ("YES" if[i for i in st if n-i in st] else "NO")

import sys

f = open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin

n = int(f.readline())

trs = []
for k in xrange(1, 10 ** 5 + 1):
    tr = k * (k + 1) / 2
    if tr > n:
        break
    trs.append(tr)

trs_set = set(trs)

for tr in trs:
    if n - tr in trs_set:
        print "YES"
        break
else:
    print "NO"

a=set([(i+1)*i/2 for i in range(1,50001)])
n=input()
arr = [1 for i in a if n-i in a]
if arr:
    print 'YES'
else:
    print 'NO'

import sys

def half_is_triangular(n):

    if n % 2:
        return False

    begin, end = 1, n

    while begin != end - 1:

        middle = (begin + end) / 2

        candidate = middle**2 + middle

        if candidate < n:
            begin = middle
        elif candidate > n:
            end = middle
        else:
            return True

    return True if begin**2 + begin == n else False

def main():

    n = int(sys.stdin.readline().strip())
    n *= 2

    for i in range(1, 45000):

        second_number = n - i**2 - i

        if second_number <= 0:
            break
        if half_is_triangular(second_number):
            return True

    return False

if __name__ == "__main__":
    print ("YES" if main() else "NO")

import math
n = int(raw_input())
end = (int(math.sqrt(n * 2)) + 10)
ans = 'NO'
i = 1
while i <= end and i <= n:
    a = i * (i + 1) / 2
    b = (n - a) * 2
    if b <= 0:
        print 'NO'
        break
    d = 1 + 4 * b
    sd = int(math.sqrt(d))
    if sd * sd == d:
        if (sd - 1) % 2 == 0:
            print 'YES'
            break
    i += 1
else:
    print 'NO'

k= set([(i*(i+1))//2 for i in range(1,45000)])

n = int(input())

f = set([n - i for i in k])

t = k & f

if t:

    print('YES')

else:

    print('NO')

import math
n=int(input())
t=math.sqrt(n)
if(n==1):
    print("NO")
    exit(0)
else:
    for i in range(1,int(t)+1):
        q=n-(i*(i+1))/2
        q1=1+8*q;
        q2=math.sqrt(q1)
        q3=int(q2)
        if(q3*q3==q1):
           print("YES")
           exit(0)
print("NO")

from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from datetime import *
from collections import * #deque, Counter,OrderedDict,defaultdict
import calendar
import heapq
import math
import copy
import itertools
myread = lambda : map(int,raw_input().split())
def solver():
    n = input()
    triangles = {}
    for i in range(1,50000):
        triangles[(i *(i+1)) / 2] = 1

    for x in triangles:
        if n - x in triangles:
            print "YES"
            return
    print "NO"

if __name__ == "__main__":
    solver()

a=set([(i+1)*i/2 for i in range(1,50001)])
n=input()
print "YES"if[1 for i in a if n-i in a]else"NO"

n = int(raw_input())

triangle = set()
for i in range(1,50000):
  triangle.add((i * (i+1))/2)

for i in triangle:
  if n-i in triangle:
    print "YES"
    quit()

print "NO"

T={k*(k+1)//2 for k in range(1,44721)}
n=int(input())
if any(n-j in T for j in T):
    print("YES")
else:
    print("NO")

p = set([(i*(i+1))//2 for i in range(1,45000)])
n = int(input())
q = set([n - i for i in p])
t = p & q
if t:
    print('YES')
else:
    print('NO')

from math import *

n = int(raw_input()) * 2

k = int(round(sqrt(n)))

found = False

for i in range(1, k):
    r = n - i * i - i
    x = int(floor(sqrt(r)))
    if x * (x + 1) == r:
        found = True
        break

print "YES" if found else "NO"

from math import *
n=int(input())
count=0
for i in range(1,int(n/2)+1):
  a=(i*(i+1))/2
  b=str(a)

  if b[-1]=='0':
    x=n-int(a)

    if x<0:
      break
    square_root=sqrt(8*x+1)

    square_root1=str(square_root)
    if square_root1[-1]=='0':

      c=(square_root-1)/2
      if c==0.0:
        continue
      else:
         c=str(c)
         if c[-1]=='0':
             print('YES')
             count=1
             break
if count==0:
  print('NO')

from math import *
n=int(input())
count=0
for i in range(1,int(n/2)+1):
  a=(i*(i+1))/2
  b=str(a)

  if b[-1]=='0':
    x=n-int(a)

    if x<0:
      break
    square_root=sqrt(8*x+1)

    square_root1=str(square_root)
    if square_root1[-1]=='0':

      c=(square_root-1)/2

      c=str(c)
      if c[-1]=='0':
        print('YES')
        count=1
        break
if count==0:
  print('NO')

n=int(input())
a=[]
i=int(0)
f=0
while(1):
    a.append((i*(i+1))/2)
    if(a[len(a)-1]>=256):
        break
    i=i+1
for i in range(len(a)):
    if(n-a[i] in a):
        f=1
        break
print("YES") if(f==1) else print("NO")

from bisect import bisect_left

def index(a, x):
    # 'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return True
    return -1
c = int(input())
list1 = []

for i in range(50000):

    z = ((i)*(i+1))//2

    list1.append(z)
# print(len(list1))
temp = 0
for i in list1:
    z = (c - i)
    k = index(list1,z)
    if k == True:
        # print(z,i)
        temp = 1
        break

if temp == 0:
    print('NO')
else:
    print('YES')

import math

def isok(i , n):
    remain = (n - (i + 1) * i / 2) * 2
    m = (int)(math.sqrt(remain)) + 10
    while m * (m + 1) > remain:
        m -= 1
    if m * (m + 1) == remain:
        return True
    else:
        return False

n = int(raw_input())
i = 1
ok = False
while i * (i + 1) / 2 <= n:
    if isok(i , n) == True:
        ok = True
        break
    i += 1

if ok == True:
    print "YES"
else:
    print "NO"

from sys import stdin, stdout
from math import sqrt

def isTriangular(n):
    t = int(sqrt(n))
    return n+n==(t+2)*(t+1)

n = int(stdin.readline().strip())

ans = 'NO'

i = 0
while (i*(i+1)>>1) <= n:
    if isTriangular(n - (i*(i+1)>>1)):
        ans = 'YES'
        break
    i += 1

print(ans)

import math
# -*- coding: utf-8 -*-

#$BF~NO$7$?$b$N$rBeF~(B
input_num = int(raw_input())
twi_num = input_num * 2

ans = "NO"
for i in range(1, int(math.sqrt(input_num+1))+1):
	if(ans == "YES"):
		break;

	temp = twi_num - (i * (i+1))

	for j in range(-1, 2):
		check = int(math.sqrt(temp)) + j
		if((check * (check+1)) + (i * (i+1))== twi_num):
			ans = "YES"

print ans

def funky(n):
   for i in range(n):
      if (i*(i+1))//2==n:
         break
         return True
   else:
      return False
x=int(input())
a="NO"
for i in range(1,x+1):
   if funky(i) and funky(x-i):
      a='YES'
      break
print(a)

from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from datetime import *
from collections import * #deque, Counter,OrderedDict,defaultdict
import calendar
import heapq
import math
import copy
import itertools
myread = lambda : map(int,raw_input().split())
def solver():
    n = input()

    triangles = [ (x * (x + 1)) / 2 for x in range(1,50000)]

    for i in range(len(triangles)):
        if i > len(triangles)/2 + 1:
            break

        lp = i
        up = len(triangles) - 1
        now_num = triangles[i]
        while lp != up:
            mid = (lp + up) / 2

            if now_num + triangles[mid] < n:
                lp = mid + 1
            else:
                up = mid

        if now_num + triangles[lp] == n:
            #print now_num,triangles[lp]
            print "YES"
            return

    print "NO"

if __name__ == "__main__":
    solver()

n=int(input())
arr=[]
f=0
for i in range(1,25000):
    arr.append((i*(i+1))//2)
for el in arr:
    if (n-el) in arr:
        f=1
        break
if(f==1):
    print("YES")
else:
    print("NO")

import math, sys
n = int(raw_input())
tr = set([x*(x+1)/2 for x in range(1,int(math.sqrt(n))+1)])
for a in tr:
    if tr.__contains__(n-a):
        print "YES"
        sys.exit(0)
print "NO"

import bisect
l=[0]*50001
for i in range(50001):
    if i==0 or i==1:
        l[i]=i
    else:
        l[i]=l[i-1]+i
n=int(input())
i=bisect.bisect_left(l,n)
j=2
f=0
while i>j:
    if l[i]+l[j]==n:
        f=1
        break
    elif l[i]+l[j]>n:
        i=i-1
    elif l[i]+l[j]<n:
        j=j+1
if f==1 or n==2:
    print('YES')
else:
    print('NO')

import math
ar = []
b = int(input())
n = math.sqrt(b)

i = 1
while(True):
    x = i * (i+1)//2
    if x >= n:
        break
    ar.append(x)
    i +=1
m = 0
for i in ar:
    if n - i in ar:

        m+=1
        break

if m>0:
    print('YES')
else:
    print('NO')

from sys import stdin

t=[(x*(x+1)//2) for x in range(44730)]
num = int(stdin.readline().strip())

i,found = 1,False
while found==False and t[i]<num:
    target = num-t[i]
    low,hi = i,44730
    while found==False and low+1<hi:
        mid = low+((hi-low)//2)
        if t[mid]==target:
            found = True
        elif t[mid]<target:
            low = mid
        else:
            hi = mid
    i += 1
if num==2:
    print("YES")
elif found:
    print("YES")
else:
    print("NO")

t = set([x*(x+1)/2 for x in range(1,int(31800)+1)])
n=256#input()
for i in t:
	if n-i in t:
		print 'Yes'
		exit(0)

print 'No'

n=int(input())
a=[]
b=[]
i=int(0)
f=0
while(1):
    a.append(int((i*(i+1))/2))
    if(a[len(a)-1]>=n):
        break
    i=i+1
for i in range(len(a)//2):
    b.append(n-a[i])
b.sort()
print("YES") if(set(a) & set(b)) else print("NO")

from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)

def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

def solve():
    n=inp()
    c=0
    i=1
    while i*i<=n:
        a=(i*(i+1))//2
        b=n-a
        x=(-1+(1+8*b)**0.5)//2
        y=(-1-(1+8*b)**0.5)//2

        if type(x)==float and math.floor(x)==x :
            v=math.floor(x)
            if (v*(v+1)//2)+a==n:
                c=1
                break

        if type(y)==float and math.floor(y)==y:
            v=math.floor(y)
            if (v*(v+1)//2)+a==n:
                c=1
                break

        i+=1

    if c:
        print("YES")
    else:
        print("NO")

for _ in range(1):
    solve()

h=set([x*(x+1)/2 for x in xrange(53334)])
n=input()
print "YES"if ([n-i in h for i in h].count(1)>0)else"NO"

import math
def b_search(l,r,arr,x) :

    while(l<=r) :
        mid = (l+r)//2

        if x<arr[mid] :

            r = mid-1

        elif x>arr[mid] :

            l = mid+1

        elif x==arr[mid] :

            return True

    return False

n = int(input())

N = math.sqrt(2*n)

arr = []
arr.append(0)

for i in range(1,int(N)+1) :

    arr.append(arr[i-1]+i)

#print(arr)

flag = 1

for i in range(int(N)) :
    if b_search(0,int(N),arr,n-arr[i]) :

        print("YES")
        flag = 0
        break

if flag :
    print("NO")

import pdb
import sys
import math

file = sys.stdin
#file = open("test", "r")

def is_valide(i):
    i *= 2
    root = int(math.sqrt(i))
    if root*(root + 1) == i or (root - 1)*root == i or (root + 1)*(root + 2) == i:
        return True
    else:
        return False

num = int(file.readline().rstrip())
root = int(math.sqrt(num))
for i in range(1, root + 1):
    if is_valide(i) and is_valide(num - i):
        print "YES"
        break
else:
    print "NO"

from math import sqrt
n=int(input())
i=int(sqrt(n))
j=i
p='NO'
while(i>0 and j<n):
    s=((i*(i+1))/2)+((j*(j+1))/2)
    if(s==n):
        p='YES'
        break
    i=i-1
    j=j+1
print(p)

from math import *

n = int(raw_input()) * 2

k = int(round(sqrt(n)))

found = False

for i in range(1, k):
    r = n - i * i
    x = int(floor(sqrt(r)))
    if x * (x + 1) == r:
        found = True
        break

print "YES" if found else "NO"

n = int(input())
a, b = 1, int((2 * (n - 1)) ** 0.5)
A, B = 1, (b * (b + 1)) // 2
while a <= b:
    if A + B < n:
        a += 1
        A += a
    elif A + B > n:
        B -= b
        b -= 1
    else: break
print('NO' if A + B != n else 'YES')

import sys
import os
from math import*
input=sys.stdin.buffer.readline

n=int(input())
x=int(max(int((-1+sqrt(1+8*n))//2),(-1-sqrt(1+8*n))//2))
#bprint(x)
if (x*(x+1))//2==n:
	print("YES")
else:
	n=n-(x*(x+1))//2
	x=int(max(int((-1+sqrt(1+8*n))//2),(-1-sqrt(1+8*n))//2))
	if (x*(x+1))//2==n:
		print("YES")
	else:
		print("NO")

"""
z=0
for i in range(0,x+1):
	print(i,x-i)
	if i*(i+1)+(x-i)*(x-i+1)==2*n:
		z=1
		break
	else:
		continue
if z==1:
	print("YES")
else:
	print("NO")
"""

# -*- coding: utf-8 -*-
"""
Created on Sun Jun  7 23:21:18 2020

@author: Anmol Singla
"""
def funk(a):
    return(int(a*(a+1)/2))
from math import sqrt
n=int(input())
true=0
for i in range(1,int(sqrt(n))+1):
    x=funk(i)

    y=(n-x)
    if(funk(int(sqrt(int(2*y))))==y):
        print("YES")
        true=1
        break

if(true==0):
    print("NO")

l=[]
for i in range(1,10**5):
    l.append(i*(i+1)//2)
i=0
f=0
n=int(input())
j=10**5-5
while i<j:
    if l[i]+l[j]==n:
        f=1
        break
    elif l[i]+l[j]<n:
        i+=1
    else:
        j-=1
if f==0:
    print('NO')
else:
    print('YES')

import sys

n = int(raw_input().strip())
trs = set((k+1) * (k+2) / 2 for k in range(10**5))

it = iter(trs)
while 1:
    l = it.next()
    if l > n/2:
        print "NO"
        sys.exit(0)

    if n - l in trs:
        print "YES"
        sys.exit(0)

# map(int, raw_input().split())
# " ".join([])
# [0] * n
# isupper
from math import sqrt
n = input()
k = 1
while k * (k + 1) <= 2 * n:
	a = 1
	b = 1
	c = -(n - k * (k + 1) / 2)
	if b * b - 4 * a * c >= 0:
		l = int((-b + sqrt(b * b - 4 * a * c)) / a)
		if l > 0 and k * (k + 1) + l * (l + 1) == 2 * n:
			print "YES"
			exit(0)
	k += 1

print "NO"

import math
n=int(input())
x=int(math.sqrt(n))
l=x+1
r=x+1
first=0
while(l>0):
	if((l*(l+1) + r*(r+1))> 2*n):
		l-=1
	elif((l*(l+1) + r*(r+1))< 2*n):
		r+=1
	else:
		first=1
		print "YES"
		break

if(first==0):
	print "NO"

import math
def fun(n):
    return (n*(n+1)/2)
n = int(input())
j = int(pow(n*2,0.5))
arr = [fun(i) for i in range(j+1)]
i=0
while(i<j):
    a = arr[j]+arr[i]
    if(a==n):
        print("YES")
        break
    elif(a<n):
        i+=1
    elif(a>n):
        j-=1

else:
    print("NO")

from bisect import bisect_left as bisect

def trigen(n):
    k = 1
    while True:
        tmp = k * (k + 1) / 2
        if tmp > n:
            raise StopIteration
        yield tmp
        k += 1

n = int(raw_input())
trinums = list(trigen(n))
flag = False
l = len(trinums)
for i in xrange(l - 1):
    leftpart = n - trinums[i]
    j = bisect(trinums, leftpart)
    if j < l and trinums[j] == leftpart:
        flag = True
        break
print 'YES' if flag else 'NO'

from math import ceil, sqrt

n = int(input())

y = ceil(sqrt(n))
y = (y * (y + 1)) / 2

y = n - y

y = (8 * y) + 1

y = sqrt(y)

if (y == ceil(y)):
    print('YES')
else:
    print('NO')

import math
n=int(input())
c=0
s=0
if n>3:
    n-=3
    z=math.sqrt(n*2)
    if int(z)*(int(z)+1)==n*2:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

n=int(input())
def sum(n):
	if (n==0):
		return 0
	else:
		return sum(n-1)+ n
def check(n):
	i=0
	while(i<n):
		if(n==sum(i)):
			return True
		else:
			i+=1;
	else:
		return False
j=1
while j<((2*n)**(1/2)):
		if(check(n-sum(j))):
			print(True)
			break
		else:
			j+=1
		if(j==(2*n)**(1/2)-1):
			print(False)

import math
n = int(input())
v = math.floor((-1 + math.sqrt(1 + 8 * n)) / 2)
for i in range(v, -1, -1):
	z = n - i * (i + 1) / 2
	# 2z=a*(a+1) a^2+a-2z=0
	a = (-1 + math.sqrt(1 + 8 * z)) / 2
	if a.is_integer():
		print("YES")
		exit(0)
print("NO")

n = int(raw_input())*2
v = set([x*(x-1) for x in xrange(1,40000)])
print 'YES' if len([x for x in v if n-x in v]) else 'NO'

def main():
	triangulars = set([i*(i+1)/2 for i in xrange(50000)])
	num = input()
	for t in triangulars:
		if num - t >=0:
			if (num - t) in triangulars:
				print 'YES'
				return
		else:
			print 'NO'
			return

main()

n = int(raw_input())

triangle = set()
for i in range(100000):
  triangle.add((i * (i+1))/2)

for i in triangle:
  if i > n: break
  if n-i in triangle:
    print "YES"
    quit()

print "NO"

def binary_search(arr,val):
	L = 0
	R = len(arr)-1
	while L<=R:
		mid = (L+R)/2
		if (arr[mid] == val):
			return True
		elif (arr[mid] < val):
			L = mid + 1
		else:
			R = mid - 1
	return False

n = int(raw_input())
arr = [i*(i+1)/2 for i in range(1,40000)]

found = False

for val in arr:
	if binary_search(arr,n-val):
		found = True

if found:
	print "YES"
else:
	print "NO"

def funky(n):
   a=False
   for i in range(int(n**(1/2))):
      if (i*(i+1))//2==n:
         a=True
         break
   return a
x=int(input())
a="NO"
for i in range(x):
   if funky(i) and funky(x-i):
      a='YES'
      break
print(a)

#_________________ Mukul Mohan Varshney _______________#

#Template
import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt,floor,factorial,gcd,log,ceil
from collections import deque,Counter,defaultdict
from itertools import permutations, combinations
import itertools

#define function
def Int(): return int(sys.stdin.readline())
def Mint(): return map(int,sys.stdin.readline().split())
def Lstr(): return list(sys.stdin.readline().strip())
def Str(): return sys.stdin.readline().strip()
def Mstr(): return map(str,sys.stdin.readline().strip().split())
def List(): return list(map(int,sys.stdin.readline().split()))
def Hash(): return dict()
def Mod(): return 1000000007
def Ncr(n,r,p): return ((fact[n])*((ifact[r]*ifact[n-r])%p))%p
def Most_frequent(list): return max(set(list), key = list.count)
def Mat2x2(n): return [List() for _ in range(n)]
def Lcm(x,y):  return (x*y)//gcd(x,y)
def dtob(n): return bin(n).replace("0b","")
def btod(n): return int(n,2)

# Driver Code
def solution():
     #for _ in range(Int()):
          n=Int()
          t=[]
          i=1
          while(1):
               a=(i*(i+1))//2
               if(a>=n):
                    break
               t.append(a)
               if n-a in t:
                    print("YES")
                    break
               i+=1
          else:
               print("NO")

#Call the solve function
if __name__ == "__main__":
     solution()

MAX_RANGE = 50000

def chk(n):
    S = set([])
    for i in range(MAX_RANGE):
        S.add(i*(i+1)/2)
        if n - i*(i+1)/2 in S:
            return True
    return False

if __name__ == '__main__':
    n = int(raw_input().strip())
    if chk(n):
        print "YES"
    else:
        print "NO"

from math import *

n = int(raw_input()) * 2

k = int(round(sqrt(n)))

found = False

for i in range(1, k):
    r = n - i * i
    x = int(floor(sqrt(r)))
    if x * (x + 1) == r:
        found = True
        break

print "YES" if found else "NO"

n= int(input())
a= set()#[k*(k+1)//2 for k in range(1,n)])
for i in range (n):
    x = i*(i+1)//2
    if x > n:
        print('NO')
        break
    a.add(x)
    if n-x in a:
        print('YES')
        break
else :
    print('NO')

def binarysearch(ar,l,r,x):
	if r >= l:
		mid = l + (r-l)//2
		if ar[mid] == x:
			return mid
		elif ar[mid] < x:
			return binarysearch(ar,mid+1,r,x)
		else:
			return binarysearch(ar,l,mid-1,x)
	return -1
def funky(n):
	a = (int((2*n)**(.5))+int(2))
	ar = []
	for i in range(1,a):
		k = int(i*(i+1)/2)
		ar.append(k)
	return ar
def CoolestNum(ar,l,r,x):
	b = binarysearch(ar,l,r,x//2)
	if b != -1:
		return "YES"
	else:
		g = len(ar)
		for i in range(g-1,-1,-1):
			if ar[i] > x//2:
				diff = x - ar[i]
				term = binarysearch(ar,0,g-1,diff)
				if term != -1:
					return "YES"
	return "NO"

n = 256
ar = funky(n)
q = len(ar)
print(CoolestNum(ar,0,q-1,n))

n = int(raw_input())

triangle = set()
for i in range(1,50000):
  triangle.add((i * (i+1))/2)

for i in triangle:
  if i > n: break
  if n-i in triangle:
    print "YES"
    quit()

print "NO"

t = set([x*(x+1)/2 for x in range(1,int(31800)+1)])
n=256#input()
for i in t:
	if n-i in t:
		print 'Yes'
		exit(0)

print 'No'

n=int(input())
arr=[]
f=0
for i in range(1,25000):
    arr.append((i*(i+1))//2)
for el in arr:
    if (n-el) in arr:
        f=1
        break
if(f==1):
    print("YES")
else:
    print("NO")

n = int(input())
if n==1:
    print("NO")
elif n==2:
    print("YES")
elif n==3:
    print("NO")
elif n==4:
    print("YES")
else:
    sqrt_n = int(n**(0.5))//1
    num = 2*(sqrt_n)
    l1 = []
    ismatched = False
    for i in range(1,num+1):
        val = (i*(i+1))//2
        val_2 = n - val
        if val_2>=0:
            discriminat = (1+8*val_2)**(0.5)
            if (int(discriminat))*(int(discriminat))==(1+8*val_2):
                val3 = (discriminat-1)//2
                if n==1:
                    print("NO")
                else:
                    if int(val3*2)==discriminat-1:
                        if int(val3)<=num:
                            print("YES")
                            ismatched = True
                            break
    if ismatched==False:
        print("NO")

from math import ceil, sqrt
n = int(input())
def value(y):
    y = (y * (y + 1)) / 2
    y = n - y
    return y

def check(y):
    y = (8 * y) + 1
    y = sqrt(y)
    if (y == ceil(y)):
        return True
    else:
        return False

def main():
    y = ceil(sqrt(n))

    while value(y) > 0:
        if check(value(y)):
            return print('YES')
        y += 1
    return print('NO')

main()

hash_set = set()
for i in range(10**5):
    hash_set.add(i*(i+1)//2)
n = int(input())
if n==1:
    print('NO')
    exit()
i = 0
while True:
    temp = (i * (i+1) // 2 )
    if temp > n:
        print('NO')
        break
    elif n - temp in hash_set:
        print('YES')
        break
    i += 1

import sys

n = int(raw_input().strip())
trs = set((k+1) * (k+2) / 2 for k in range(10**5))

it = iter(trs)
while 1:
    l = it.next()
    if l > n/2:
        print "NO"
        sys.exit(0)

    if n - l in trs:
        print "YES"
        sys.exit(0)

def binarySearch (arr, l, r, x):
  if r >= l:
    mid = int(l + (r - l)/2)
    if arr[mid] == x:
      return mid
    elif arr[mid] > x:
      return binarySearch(arr, l, mid-1, x)
    else:
      return binarySearch(arr, mid + 1, r, x)
  else:
    return -1
def b():
  number = int(input())
  a = [0]
  for i in range(1, (10**5)+1):
    a.append(a[i-1] + i)
  for i in range(1, (10**5)+1):
    if binarySearch(a, 0, len(a)-1, number-a[i]) != -1:
      print("Yes")
      return

  print("No")
b()

import math
ar = []
b = int(input())
n = math.sqrt(b)

i = 1
while(True):
    x = i * (i+1)//2
    if x >= n:
        break
    ar.append(x)
    i +=1
m = 0
for i in ar:
    if n - i in ar:

        m+=1
        break

if m>0:
    print('YES')
else:
    print('NO')

def R(): return map(int, input().split())
def I(): return int(input())
def S(): return str(input())

def L(): return list(R())

from collections import Counter

import math
import sys

from itertools import permutations

import bisect

mod=10**9+7

def check(x):
    y=int(math.sqrt(8*x+1))

    return y*y==8*x+1

#print(bisect.bisect_right([1,2,3],2))
#print(bisect.bisect_left([1,2,3],2))

n=I()

for k in range(int(math.sqrt(2*n))+10):
    if k*(k+1)//2<=n and check(n-k*(k+1)//2):
        print('YES')
        exit()

print('NO')

h=set([x*(x+1)/2 for x in xrange(53334)])
n=input()
print "YES"if ([n-i in h for i in h].count(1)>0)else"NO"

from sys import *
def findn(t):
    sum = 0
    i=1
    while(sum<=t):
        sum=sum+i;
        i+=1;
    return (i-2)
x=int(input())
n=findn(x)
def sumt(n):
    sum=0
    i=1
    while(i<=n):
        sum+=i;
        i+=1;

    return sum;

def check(n):
    z=0
    i=1
    while(i<n//2):
        s1=sumt(i)

        j=n
        while(j>0):

            if(s1+sumt(j)==x):

                z=1;
                print("YES")
                break;

            j-=1
        if(z==1):
            break;

        i+=1
    return (z)

if(not(check(n))):
    print("NO");

import math
n=int(input())
def funky(n):
    x=int(math.sqrt(n))
    for i in range(x):
        y=(i*(i+1))//2
        k2=int(math.sqrt((n-y)*2))
        z=(k2*(k2+1))//2
        if y+z==n:
            return 'YES'

    return 'NO'

print(funky(n))

n = int(input())
total, num, c1, c2 = n * 2, 2, 2, 3

while (c1 * c2 < total):
    num = c1 * c2
    c1 += 1
    c2 += 1

c1, c2 = 1, 2

while (num + (c1 * c2) < total):
    c1 += 1
    c2 += 1
if num+(c1*c2)==total:
    print('YES')
else:
    print('NO')

n=int(input())
l=[]
s=int ((2*n)**.5)
for i in range(0,s):
    p=(i*(i+1))//2
    l.append(p)
k=len(l)-1
i=1
found=0
while(k>i):
    if (l[i]+l[k]==n):
        found=1
        break
    elif(l[i]+l[k]<n):
        i+=1
    elif(l[i]+l[k]>n):
        k=k-1

if (found==1):
    print("YES")
else:
    print("NO")

c = int(input())
list1 = []

for i in range(3000):

    z = ((i)*(i+1))//2

    list1.append(z)
# for i in range(1000,2000):
#
#     z = ((i)*(i+1))//2
#
#     list1.append(z)

hash = []
for i in list1:
    for j in list1:
        hash.append(i+j)

if c in set(hash):
    print('YES')
else:
    print('NO')

# for i in hash:
#     print(hash)

a=set([(i+1)*i/2 for i in range(1<<16)])
n=input()
print "YES"if[1 for i in a if n-i in a]else"NO"

from sys import stdin, stdout
from math import sqrt

def isTriangular(n):
    t = int(sqrt(n))
    return n+n==(t+2)*(t+1)

n = int(stdin.readline().strip())

ans = 'NO'

i = 0
while (i*(i+1)>>1) <= n:
    if isTriangular(n - (i*(i+1)>>1)):
        ans = 'YES'
        break
    i += 1

print(ans)

import math
n = int(input())
i =int(math.sqrt(n))
j=i
res = 'N0'
while i>0 & j<n:
    if i*(i+1)/2+j*(j+1)/2==n:
        res='YES'
        break
    elif i*(i+1)/2+j*(j+1)/2<n:
        j+=1
    else:
        i-=1
print(res)

import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
#que.sort(key=lambda x:((x[0]),-x[1]))
#for  _ in range(int(input())):
#n,x = map(int, input().split())
n=int(input())
var=n
d={}
for i in range(1,10*int(10**9**0.5)):
    d[i*(i+1)//2]=1
for i in d:
    if n-i in d:
        print("YES")
        exit()
print("NO")

from math import sqrt
n=int(input())
i=int(sqrt(n))
j=i+1
p='NO'
while(i>0 and j<n):
    s=((i*(i+1))/2)+((j*(j+1))/2)
    if(s==n):
        p='YES'
        break
    if(s<n):
        j=j+1
    if(s>n):
        i=i-1
print(p)

import math

def cool(n):
    if n==1:
        return "NO"
    if n==2:
        return "YES"
    for k1 in range(int(math.sqrt(n))):
        k2 = int(math.sqrt((n - (k1*(k1+1))/2)*2))
        if (k1*(k1+1))/2 + (k2*(k2+1))/2 == n:
            return"YES"
            break
        else:
            continue
    return "NO"

num = int(input())
print(cool(num))

n = int(raw_input())
triangles = [i * (i + 1) / 2 for i in xrange(32000)]
triangles.remove(0)
triangles.sort()

for i in triangles:
    l = 0
    r = len(triangles) - 1
    while(l < r):
        mid = l + r >> 1
        if(i + triangles[mid] < n):
            l = mid + 1
        else:
            r = mid
    if(i + triangles[mid] == n):
        print 'YES'
        exit(0)

print 'NO'

n = int(input())
s = set()
c = 0
for i in range(1,40000):
    a = i*(i+1)//2
    s.add(a)
for j in s:
    if n-j in s:
        c = c+1
        print('YES')
        exit()
print('NO')

n=int(input())
x=set((i*(i+1))//2 for i in range(45000))
p=x.copy()
f=0
for i in x:
    if abs(i-n) in x:
        f=1
        break
    else:
        pass
if f==1:
    print("YES")
else:
    print("NO")

n= int(input())
import math
m= math.sqrt(n)
a= set([k*(k+1)//2 for k in range(1, int(2*m))])
print(a)
for i in a:
    if n-i in a:
        print('YES')
        exit()

print('NO')

import math
n=int(input())
x=math.sqrt(n)
l=x
r=x+1
first=0
while(l>0):
	if((l*(l+1) + r*(r+1))> 2*n):
		l-=1
	elif((l*(l+1) + r*(r+1))< 2*n):
		r+=1
	else:
		first=1
		print "YES"
		break
if(first==0):
	print "NO"

number = int(raw_input())
num = list(map(int , [i * (i + 1) / 2 for i in range(1 , 10001)]))
vis = {}
ok = True
for i in num:
     vis[i] = 1
for i in num:
    if i > number:
        ok = False
        break
    else:
        if vis.get(number - i) == 1:
            ok = True
            break
if ok == True:
    print "YES"
else:
    print "NO"

h=set([x*(x+1)/2 for x in xrange(33334)])
n=input()
print "YES"if ([n-i in h for i in h].count(1)>0)else"NO"

import math
def funky(n):
   a=False
   b=math.sqrt(n)
   for i in range(int(b)):
      if (i*(i+1))//2==n:
         a=True
         break
   return a
x=int(input())
a="NO"
for i in range((x//2)+1):
   if funky(i) and funky(x-i):
      a='YES'
      break
print(a)

l = set([i*(i+1)//2 for i in  range(100001)])
n = int(input())
a = False
for i in l:
    if n-i in l :
        a = True
        break
if a is True :
    print("YES")
else:
    print("NO")

n = int(raw_input())

triangle = set()
for i in range(1,50000):
  triangle.add((i * (i+1))/2)

for i in triangle:
  if i > n: break
  if n-i in triangle:
    print "YES"
    quit()

print "NO"

def binarysearch(ar,l,r,x):
	if r >= l:
		mid = l + (r-l)//2
		if ar[mid] == x:
			return mid
		elif ar[mid] < x:
			return binarysearch(ar,mid+1,r,x)
		else:
			return binarysearch(ar,l,mid-1,x)
	return -1
def funky(n):
	a = (int((2*n)**(.5))+int(2))
	ar = []
	for i in range(1,a):
		k = int(i*(i+1)/2)
		ar.append(k)
	return ar
def CoolestNum(ar,l,r,x):
	b = binarysearch(ar,l,r,x//2)
	if b != -1:
		return "YES"
	else:
		g = len(ar)
		for i in range(g-1,-1,-1):
			if ar[i] > x//2:
				diff = x - ar[i]
				term = binarysearch(ar,0,g-1,diff)
				if term != -1:
					return "YES"
	return "NO"
n = int(input())
ar = funky(n)
q = len(ar)
print(CoolestNum(ar,0,q-1,n))

n = int(raw_input())*2
v = set([x*(x+1) for x in xrange(1,40000)])
print 'YES' if len([x for x in v if n-x in v]) else 'NO'

t = set([x*(x+1)/2 for x in range(1,int(31800)+1)])
n=256#input()
for i in t:
	if n-i in t:
		print 'Yes'
		exit(0)

print 'No'

t = set(x*(x+1)/2 for x in range(int(45000)+1))
n=input()
for i in t:
    if n-i in t:
        print 'Yes'
        exit(0)

print 'No'

n=int(input())
n=n*2
final = 1
check=[]
root=int(((4*(n-2) +1)**(0.5)-1)/2)
i=1
j=root
# if n==4:
#     print("YES")
#     final=0
# if n==8:
#     print("YES")
#     final=0
if n==2:
    print("NO")
    final=0
while i<j and final==1:
    init= i*i + i
    # check.append(init)
    number = n - init
    if number in check:
        print("YES")
        final=0
        break
    else:
        while (j**2 + j + init)>= n and final==1:
            cong=j**2 + j
            check.append(cong)
            if (cong)==number :
                print('YES')
                final=0
                break
            else:
                j-=1
        i+=1
if final==1 :
    print("NO")

n = int(input())
m = 1
arr = []
while(True):
	mm = (m*(m+1))//2
	if mm>n:
		break
	arr.append(mm)
	m+=1

ll = len(arr)
flag = 0
for i in range(ll):
	curr = arr[i]
	req = n-curr
	l = i+1
	r = ll-1
	while(l<=r):
		mid = (l+r)//2
		if arr[mid]>=req:
			r = mid-1
		else:
			l = mid+1
	if i<l<ll and arr[l]==req:
		flag=1
		break
if flag==1:
	print("YES")
else:
	print("NO")

n=int(input())
def sum(n):
	if (n==0):
		return 0
	else:
		return sum(n-1)+ n
def check(n):
	i=0
	while(i<n):
		if(n==sum(i)):
			return True
		else:
			i+=1;
	else:
		return False
j=1
while j<((2*n)**(1/2)):
		if(check(n-sum(j))):
			print("Yes")
			break
		else:
			j+=1
		if(j==(2*n)**(1/2)-1):
			print("No")

from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from datetime import *
from collections import * #deque, Counter,OrderedDict,defaultdict
import calendar
import heapq
import math
import copy
import itertools
myread = lambda : map(int,raw_input().split())
def solver():
    n = input()

    num = [ (x * (x+1)) / 2 for x in range(50000)]

    for num1 in num:
        lp = 0
        up = len(num) - 1
        while lp != up:
            mid = (lp + up) / 2
            if num1 + num[mid] < n:
                lp = mid + 1
            else:
                up = mid

        if num1 + num[mid] == n:
            print "YES"
            return

    print "NO"

if __name__ == "__main__":
    solver()

t = set(x*(x+1)/2 for x in range(int(45000)+1))
n=816761542
for i in t:
    if n-i in t:
        print 'Yes'
        exit(0)

print 'No'