#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma comment(linker, "STACK:36777216") using namespace std; using i64 = int64_t; using i128 = __int128_t; constexpr i64 MOD = 1e9 + 7; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); using vi = vector; using vvi = vector; using vvvi = vector; using ii = pair; bool is_prime[303030]; int cnt[303030]; vi small_primes, primes; void init() { for (int i = 2; i < 303030; i++) { is_prime[i] = 1; } for (int i = 2; i < 303030; i++) { if (is_prime[i] == false) continue; for (int j = 2; i * j < 303030; j++) { is_prime[i * j] = false; } } for (int i = 2; i < 303030; i++) { if (i < 100000 && is_prime[i]) small_primes.push_back(i); if (is_prime[i]) primes.push_back(i); } } int main() { init(); int n; cin >> n; i64 ans = 0; for (int i = 1; i < primes.size(); i++) { int c = primes[i]; if (c > n) break; int b = primes[i - 1]; for (int j = 0; j < i - 1; j++) { cnt[primes[j] + b]++; } for (int j = 0; j < primes.size(); j++) { int sum = primes[j]; if (sum - c >= 0) { ans += cnt[sum - c]; } } } cout << ans << endl; }