#include #include #include #include #include #include #include using namespace std; using ll = long long; vector prime_vector(int n) { int m = (int)sqrt(n - 1); vector q(n); for (int i = 2; i <= m; i++) { if (q[i]) continue; for (int j = i * i; j < n; j += i) { q[j] = true; } } vector p; p.reserve(n / log(n * 0.329)); for (int i = 2; i < n; i++) { if (!q[i]) p.push_back(i); } return p; } int main() { int n; cin >> n; auto pv = prime_vector(n * 3); int m = pv.size(); vector s(n * 2); ll r = 0; for (int i = 3; i < m; i++) { int c = pv[i]; if (c > n) break; int b = pv[i - 1]; for (int j = 1; j < i - 1; j++) { int a = pv[j]; s[a + b]++; } for (int j = i + 1; j < m; j++) { int t = pv[j] - c; if (t >= b * 2) break; r += s[t]; } } cout << r << endl; return 0; }