Imp is in a magic forest, where xorangles grow (wut?)

A xorangle of order *n* is such a non-degenerate triangle, that lengths of its sides are integers not exceeding *n*, and the xor-sum of the lengths is equal to zero. Imp has to count the number of distinct xorangles of order *n* to get out of the forest. 

Formally, for a given integer *n* you have to find the number of such triples (*a*, *b*, *c*), that:
 -  1 ≤ *a* ≤ *b* ≤ *c* ≤ *n*; -  <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/616b9f69d1a3b7c1fc2c0a3423d1cf845ca80208.png" style="max-width: 100.0%;max-height: 100.0%;"/>, where <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/b364f2e04c665b78b924ec10666327a4ef4635bc.png" style="max-width: 100.0%;max-height: 100.0%;"/> denotes the [bitwise xor](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers *x* and *y*. -  (*a*, *b*, *c*) form a non-degenerate (with strictly positive area) triangle.
The only line contains a single integer *n* (1 ≤ *n* ≤ 2500).
The only xorangle in the first sample is (3, 5, 6).
6
1
10
2
3
0
4
0
5
0
2500
700393
952
118547
88
536
1216
160822
2140
614785
564
35087
1488
239580
116
1332
1040
145820
1965
545494
593
36605
779
63500
1703
352045
331
9877
1051
145985
2179
618074
603
37312
1731
369691
2451
681980
1079
146833
2207
621708
2394
663240
818
73972
1946
529383
166
2200
1294
175915
2218
623386
846
82106
1566
273341
194
3240
1322
183405
1508
247634
2433
675245
857
85529
1781
402718
1
0
2
0
2444
679373
2498
699536
import itertools as it
from math import *
n=int(input())
x=list(range(1,n+1))

s=''    
def ch(a):
    a.sort()
    if a[0]+a[1]>a[2]:
            
        if len(set(a))==3:
            return a[0]^a[1]^a[2]
        else:
            return 1
    else:
        return 1
cou=0
temp=[]
x=list(range(1,n+1))
for i in it.combinations(x,3):
    i=list(i)
    print(i)
    if not(ch(i)):
        cou+=1
print(cou)

		 	   			 	 	 	    	 		