Prepare for ICPC, IOI, and technical interviews with our structured roadmaps and curated problem sets. Custom training available for Codeforces and AtCoder rating improvement.
#include <iostream>
#include <vector>
using namespace std;
// Sieve of Eratosthenes
vector<int> sieve(int n) {
vector<bool> is_prime(n + 1, true);
vector<int> primes;
is_prime[0] = is_prime[1] = false;
for(int i = 2; i <= n; i++) {
if(is_prime[i]) {
primes.push_back(i);
for(int j = i * i; j <= n; j += i)
is_prime[j] = false;
}
}
return primes;
}
int main() {
int n;
cin >> n;
auto primes = sieve(n);
for(int p : primes)
cout << p << " ";
return 0;
}
Everything you need to excel in competitive programming
Specialized training paths designed specifically for ICPC and IOI competitions with expert-curated problems
Follow proven learning paths from beginner to advanced levels with milestone tracking
Practice coding interview questions for top tech companies alongside competitive programming
Custom training plans for Codeforces and AtCoder. Track your rating progress with detailed analytics and performance metrics
Learn with peers, participate in discussions, and share solutions
Practice in C++, Python, Java, and more with online IDE support
Supported by leading coding education institutions
Empowering students to excel in competitive programming competitions worldwide
Learn More
Premier coding education institution fostering the next generation of developers
Learn More
Mohammed VI Polytechnic University - Leading research and innovation in Morocco and Africa
Learn MoreGet lifetime Pro access at an exclusive launch price
⏰ Limited time offer - Price increases soon!
Join thousands of students preparing for ICPC, IOI, and top tech companies