#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 el[303030]; int cnt[303030]; vi small_primes, primes; int main() { for (int i = 2; i < 303030; i++) { el[i] = 1; } for (int i = 2; i < 303030; i++) { if (el[i] == false) continue; for (int j = 2; i * j < 303030; j++) { el[i * j] = false; } } for (int i = 2; i < 303030; i++) { if (i < 100000 && el[i]) small_primes.push_back(i); if (el[i]) primes.push_back(i); } int n; cin >> n; i64 ans = 0; for (int i = 1; i < small_primes.size(); i++) { int c = small_primes[i]; if (c > n) break; int b = small_primes[i - 1]; for (int j = 0; j < i - 1; j++) { cnt[small_primes[j] + b]++; } for (int j = 0; j < primes.size(); j++) { int abc = primes[j]; if (abc > 3 * c) break; if (abc - c >= 0) { if (cnt[abc - c]) { // cout << "a + b + c : " << abc << endl; // cout << "c : " << c << endl; // cout << "added : " << cnt[abc - c] << endl; } ans += cnt[abc - c]; } } } cout << ans << endl; }