Codeforces Round 461 (Div. 2)
B
Magic Forest
Codeforces
1300
原题
← AC →
翻译中…

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

翻译中…

image

翻译中…

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*$;
  • image, where image denotes the bitwise xor of integers $*x*$ and $*y*$.
  • $(*a*, *b*, *c*)$ form a non-degenerate (with strictly positive area) triangle.
翻译中…

Input

翻译中…

The only line contains a single integer $*n*$ $(1 ≤ *n* ≤ 2500)$.

翻译中…

Output

翻译中…

Print the number of xorangles of order $*n*$.

翻译中…

Note

翻译中…

The only xorangle in the first sample is $(3, 5, 6)$.

翻译中…

样例

Input #1
6
Output #1
1
InputCopy OutputCopy
Input #2
10
Output #2
2
InputCopy OutputCopy
题目信息
题号
922B
时间限制
1 s
内存限制
256 MB
标签
暴力

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。