criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <list>
#include <algorithm>

int main(){
	int NUM;
	while(std::cin >> NUM){
		std::list<int> numList,primeList;
		for(int i=2;i<=NUM;++i){
			numList.push_back(i);
		}
	
		for(int i=numList.front();i<std::sqrt(NUM);i=numList.front()){
			primeList.push_back(i);
			numList.erase(std::remove_if(numList.begin(),numList.end(),[&](int num){return num%i==0;}),numList.end());
		}
		int cnt=numList.size()+primeList.size();	
		std::printf("%d\n",cnt);

		}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:50: error: 'sqrt' is not a member of 'std'; did you mean 'sort'?
   13 |                 for(int i=numList.front();i<std::sqrt(NUM);i=numList.front()){
      |                                                  ^~~~
      |                                                  sort
Language: C++

#include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,n;
    n=0;
    while ( cin >> a){
        for (int i=2;i<a;i++){
            if (prime(i)==0){
                n++;
            }
        }
        cout << n << endl;
    }
}


int prime(int x){
    if(x==2 || x==3 || x==5 || x==7)
        return 0;
    if(x%2==0 || x%3==0 || x%5==0)
        return 1;
    for (int i=7;i<=sqrt(x)+2;i+=30){
        if(x%i==0 || x%(i+4)==0 || x%(i+6)==0 || x%(i+12)==0 || x%(i+16)==0 || x%(i+22)==0 || x%(i+24)
            return 1;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int prime(int)':
a.cc:25:103: error: expected ';' before 'return'
   25 |         if(x%i==0 || x%(i+4)==0 || x%(i+6)==0 || x%(i+12)==0 || x%(i+16)==0 || x%(i+22)==0 || x%(i+24)
      |                                                                                                       ^
      |                                                                                                       ;
   26 |             return 1;
      |             ~~~~~~                                                                                     
a.cc:27:5: error: expected primary-expression before '}' token
   27 |     }
      |     ^
a.cc:26:22: error: expected ')' before '}' token
   26 |             return 1;
      |                      ^
      |                      )
   27 |     }
      |     ~                 
a.cc:25:11: note: to match this '('
   25 |         if(x%i==0 || x%(i+4)==0 || x%(i+6)==0 || x%(i+12)==0 || x%(i+16)==0 || x%(i+22)==0 || x%(i+24)
      |           ^
a.cc:27:5: error: expected primary-expression before '}' token
   27 |     }
      |     ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int n;

	while (std::cin >> n) {
		std::vector<int> nums;
		++n;
		for (int i = 0; i < n; ++i) {
			nums.push_back(i);
		}
		for (int i = 0; i < n; ++i) {
			if (nums.at(i) < 2) continue;
			for (int j = nums.at(i) * 2; j < n; j += nums.at(i)) {
				nums.at(j) = 0;
			}
		}
		for (int i = 0; i < n; ++i) {
			if (nums.at(i) > 1) {
				++c
			}
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:35: error: 'c' was not declared in this scope
   22 |                                 ++c
      |                                   ^
Language: C++

#include <iostream>
using namespace std;

int a[999999]={};

int main(){
	int n,ans=0;
	vector<int> v;
	for(int i = 2; i*i < 999999; i++){
		for(int j = 0; j < 999999; j+=i){
			if(i!=j) a[j]=1;
		}
	}
	while(cin >> n){
		v.push_back(n);
	}
	for(int i = 0; i < v.size(); i++){
		for(int j = 2; j <= v[i]; j++){
			if(a[j]==0) ans++;
		}
		cout << ans << endl;
		ans=0;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'vector' was not declared in this scope
    8 |         vector<int> v;
      |         ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:8:16: error: expected primary-expression before 'int'
    8 |         vector<int> v;
      |                ^~~
a.cc:15:17: error: 'v' was not declared in this scope
   15 |                 v.push_back(n);
      |                 ^
a.cc:17:28: error: 'v' was not declared in this scope
   17 |         for(int i = 0; i < v.size(); i++){
      |                            ^
Language: C++

__bowl1 = Array.new
__bowl2 = Array.new
__bowl3 = Array.new
__bowl4 = Array.new
__bowl5 = Array.new

india = gets.chomp.to_i
loop do
  srilanka = gets.chomp.to_i
  __bowl.push(srilanka)
  thai = gets.chomp.to_i
  puts __bowl.pop - thai

  india -= 1
  if india == 0
    break
  end
end

Compiler output:
a.cc:1:1: error: '__bowl1' does not name a type
    1 | __bowl1 = Array.new
      | ^~~~~~~
Language: C++

#include <stdio.h>

int isprime(int n){
    for(int = 2; i * i <= n; i++) {
        if(n % i == 0) return 0;  //素数でない
    }
    return 1; //素数である
}

int main() {
    int n;
    int ans[2] = {};
    while(scanf("%d", &n) != 0) {
        for(int i = n; i >= 5; i--) {
            if(isprime(i) == 1) {
                ans[0] = i;
                if(isprime(i - 2) == 1) {
                    ans[1] = i - 2;
                    break;
                }
            }
        }
        printf("%d %d", ans[0], ans[1]);
    }
}

Compiler output:
a.cc: In function 'int isprime(int)':
a.cc:4:13: error: expected unqualified-id before '=' token
    4 |     for(int = 2; i * i <= n; i++) {
      |             ^
a.cc:4:12: error: expected ';' before '=' token
    4 |     for(int = 2; i * i <= n; i++) {
      |            ^~
      |            ;
a.cc:4:13: error: expected primary-expression before '=' token
    4 |     for(int = 2; i * i <= n; i++) {
      |             ^
a.cc:4:18: error: 'i' was not declared in this scope
    4 |     for(int = 2; i * i <= n; i++) {
      |                  ^
a.cc:4:28: error: expected ')' before ';' token
    4 |     for(int = 2; i * i <= n; i++) {
      |        ~                   ^
      |                            )
a.cc:4:30: error: 'i' was not declared in this scope
    4 |     for(int = 2; i * i <= n; i++) {
      |                              ^
Language: C++

while True:
	try:
		n=int(input())
		a=[True]*(n+1)
		a[0]=a[1]=False
		for i in range(2,int(n**0.5)+1):
			if a[i]:
				for j in range(i**2,n+1,i):
					a[j]=False
		print(a.count(True))
	except:
		break

Compiler output:
a.cc:1:1: error: expected unqualified-id before 'while'
    1 | while True:
      | ^~~~~
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n,cnt=0,ans,sosu[100000]={0};
	for(int i=2;i<100000;i++){
		bool flag=true;
		for(int j=2;j<=sqrt(i);j++){
			if(i%j==0)flag=false;
		}
		if(flag){
		sosu[cnt]=i;
		cnt++;
		}
	}
	while(cin>>n){
	ans=0,cnt=0;
	for(int i=2;i<=n;i++){
		if(sosu[cnt]==i){
			cnt++;
			ans++;
		}
	}
	cout<<ans<<endl;
	}
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:32: error: 'sqrt' was not declared in this scope
   10 |                 for(int j=2;j<=sqrt(i);j++){
      |                                ^~~~
Language: C++

#include <iostream>
using namespace System;
using namespace std;
const int MAX_N =1000000;
int main(){
	bool sosu[MAX_N]={};//false:sosu
	for(int i=2;i<MAX_N;i++){
		if(!sosu[i]){
			for(int j=2;j*i<MAX_N;j++){
				sosu[j*i]=true;
			}
		}
	}
	for(int n;cin>>n;){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(!sosu[i])ans++;
		}
		cout<<ans<<endl;
	}
    return 0;
}

Compiler output:
a.cc:2:17: error: 'System' is not a namespace-name
    2 | using namespace System;
      |                 ^~~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main()
{
     while(1){
     long int xx,sqrtx,q,count=1; 
     long double n;
	cin >> n;
	xx=n;
	sqrtx = sqrt(n);

	long int *ar = new long int [xx];
	long int *p = new long int [xx];
	for(long int i=2 ; i<=xx ; i++){    // 2〜xまでの整数
		ar[i]=i;
	}

	int i=2;
	do{
		if(ar[i]!=0){
			p[count]=i;
			count++;
		}
		for(int j=2*i ; j<=xx ; j+=i){
			ar[j]=0;
		}	
		i++;
	}while(i<sqrtx);

	cout << p[count-1] << endl;
        }
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'sqrt' was not declared in this scope; did you mean 'sqrtx'?
   12 |         sqrtx = sqrt(n);
      |                 ^~~~
      |                 sqrtx
Language: C++

int count_prime( unsigned int const& n )
{
    if ( n <= 0 || 1000000 <= n ) return -1;
    std::vector<bool> memo_prime( n+1, true );
    for ( unsigned int i = 2; i < n; ++i )
    {
        for ( unsigned int j = 2; i*j <= n; ++j )
        {
            memo_prime.at(i*j) = false;
        }
    }
    memo_prime.at(0) = memo_prime.at(1) = false;
    memo_prime.at(2) = true;
    return std::count( memo_prime.begin(), memo_prime.end(), true );
}

int main()
{
    int n;
    while( std::cin >> n)
        std::cout << count_prime(n) << std::endl;
    return 0;
}

Compiler output:
a.cc: In function 'int count_prime(const unsigned int&)':
a.cc:4:10: error: 'vector' is not a member of 'std'
    4 |     std::vector<bool> memo_prime( n+1, true );
      |          ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | int count_prime( unsigned int const& n )
a.cc:4:17: error: expected primary-expression before 'bool'
    4 |     std::vector<bool> memo_prime( n+1, true );
      |                 ^~~~
a.cc:9:13: error: 'memo_prime' was not declared in this scope
    9 |             memo_prime.at(i*j) = false;
      |             ^~~~~~~~~~
a.cc:12:5: error: 'memo_prime' was not declared in this scope
   12 |     memo_prime.at(0) = memo_prime.at(1) = false;
      |     ^~~~~~~~~~
a.cc:14:17: error: 'count' is not a member of 'std'
   14 |     return std::count( memo_prime.begin(), memo_prime.end(), true );
      |                 ^~~~~
a.cc: In function 'int main()':
a.cc:20:17: error: 'cin' is not a member of 'std'
   20 |     while( std::cin >> n)
      |                 ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | int count_prime( unsigned int const& n )
a.cc:21:14: error: 'cout' is not a member of 'std'
   21 |         std::cout << count_prime(n) << std::endl;
      |              ^~~~
a.cc:21:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:21:45: error: 'endl' is not a member of 'std'
   21 |         std::cout << count_prime(n) << std::endl;
      |                                             ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | int count_prime( unsigned int const& n )
Language: C++

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

constexpr int LIM = 1000000;

static char isprime[LIM];
static int numofprime[LIM];

void setprime(int N) {
    fill(isprime, isprime + N + 1, 1);
    isprime[0] = isprime[1] = 0;
    for(int x = 2, lim = (int)sqrt(N); x <= lim; ++x) {
        if(isprime[x]) {
            for(int y = x * x; y <= N; y += x) {
                isprime[y] = 0;
            }
        }
    }
    numofprime[0] = 0;
    for(int x = 0; x < N; ++x) {
        numofprime[x + 1] = numofprime[x] + isprime[x + 1];
    }
}

int main() {
    setprime(999999);
    int n;
    while(scanf("%d", &n) != EOF) {
        printf("%d\n", numofprime[n]);
    }
    return 0;
}

Compiler output:
a.cc: In function 'void setprime(int)':
a.cc:19:31: error: 'sqrt' was not declared in this scope
   19 |     for(int x = 2, lim = (int)sqrt(N); x <= lim; ++x) {
      |                               ^~~~
Language: C++

#include <iostream>
int main(int argc, const char * argv[])
{

    // insert code here...
    
    while(true)
    {
        int n;
        std::cin >> n;
        if(std::cin.eof())break;
        
        int count = 0;
        std:
        for(int i=2;i<n;i++)
        {
            bool flag = true;
            for(int j=2;j<i/j+1;j++)
            {
                if(i%j==0)
                {
                    flag=false;
                    break;#include <iostream>
int main(int argc, const char * argv[])
{

    // insert code here...
    
    while(true)
    {
        int n;
        std::cin >> n;
        if(std::cin.eof())break;
        
        int count = 0;
        std:
        for(int i=2;i<n;i++)
        {
            bool flag = true;
            for(int j=2;j<i/j+1;j++)
            {
                if(i%j==0)
                {
                    flag=false;
                    break;
                }
            }
            if(flag)
            {
                count++;
            }
        }
        
        std::cout << count <<"\n";
        
    }
    
    return 0;
}


                }
            }
            if(flag)
            {
                count++;
            }
        }
        
        std::cout << count <<"\n";
        
    }
    
    return 0;
}

Compiler output:
a.cc:23:27: error: stray '#' in program
   23 |                     break;#include <iostream>
      |                           ^
a.cc: In function 'int main(int, const char**)':
a.cc:23:28: error: 'include' was not declared in this scope
   23 |                     break;#include <iostream>
      |                            ^~~~~~~
a.cc:23:37: error: 'iostream' was not declared in this scope; did you mean 'std::iostream'?
   23 |                     break;#include <iostream>
      |                                     ^~~~~~~~
      |                                     std::iostream
In file included from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/iosfwd:146:41: note: 'std::iostream' declared here
  146 |   typedef basic_iostream<char>          iostream;
      |                                         ^~~~~~~~
a.cc:24:1: error: expected primary-expression before 'int'
   24 | int main(int argc, const char * argv[])
      | ^~~
Language: C++

#coding: UTF-8

from bisect import bisect_right

max_number = 1000000
prime_flag_list = [True] * max_number

prime_flag_list[0] = False
prime_flag_list[1] = False

prime_flag_list[4::2] = [False] * len(prime_flag_list[4::2])

for i in range(3, int(max_number**0.5) + 1, 2):
    prime_flag_list[i*i::i] = [False] * len(prime_flag_list[i*i::i])

prime_list = [i for i in range(2, max_number) if prime_flag_list[i]]

while True:
    try:
        input = int(raw_input())
    except EOFError:
        break

    print bisect_right(prime_list, input)

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #coding
    1 | #coding: UTF-8
      |  ^~~~~~
a.cc:3:1: error: 'from' does not name a type
    3 | from bisect import bisect_right
      | ^~~~
Language: C++

int main(){
	int i , j , n , pn , cn=0;
	
	while(cin>>n){
		pn=1;
		for(i=3 ; i<=n ; i++){
			for (j=2 ; j<i ; j++){
				if (i%j==0) goto skip;
			}
			pn++;
			skip:;
		}
		if(n==0 || n==1 ) {
			cout << 0 << endl;
		} else {
			cout << pn << endl;
		}
		cn++;
		if(cn>=30) break;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:15: error: 'cin' was not declared in this scope; did you mean 'cn'?
    4 |         while(cin>>n){
      |               ^~~
      |               cn
a.cc:14:25: error: 'cout' was not declared in this scope
   14 |                         cout << 0 << endl;
      |                         ^~~~
a.cc:14:38: error: 'endl' was not declared in this scope
   14 |                         cout << 0 << endl;
      |                                      ^~~~
a.cc:16:25: error: 'cout' was not declared in this scope
   16 |                         cout << pn << endl;
      |                         ^~~~
a.cc:16:39: error: 'endl' was not declared in this scope
   16 |                         cout << pn << endl;
      |                                       ^~~~
Language: C++

#include <math.h>
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>

#define YES "YES"
#define NO "NO"
#define space ' '

using namespace std;

void func();

int main(void)
{
	
	func();

	return 0;
}


#define MAXIMUM 1000000
bool table[MAXIMUM];
int cnt[MAXIMUM];
#define not true
#define prime false
void func()
{
	table[0] = not;
	table[1] = not;
	for (int i = 2; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			for (int j = i * 2; j < MAXIMUM; j += i)
			{
				table[j] = not;
			}
		}
	}
	for (int i = 1; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			cnt[i] = cnt[i - 1] + 1;
		}
		else
		{
			cnt[i] = cnt[i - 1];
		}
	}

	int n;
	while (cin >> n, !cin.eof())
	{
		cout << cnt[n] << endl;
	}

}

Compiler output:
a.cc:29:9: error: "not" cannot be used as a macro name as it is an operator in C++
   29 | #define not true
      |         ^~~
a.cc: In function 'void func()':
a.cc:33:23: error: expected primary-expression before ';' token
   33 |         table[0] = not;
      |                       ^
a.cc:34:23: error: expected primary-expression before ';' token
   34 |         table[1] = not;
      |                       ^
a.cc:41:47: error: expected primary-expression before ';' token
   41 |                                 table[j] = not;
      |                                               ^
Language: C++

#include <math.h>
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>

#define YES "YES"
#define NO "NO"
#define space ' '
#define not true
#define prime false

using namespace std;

void init();
void func();

int main(void)
{
	
	func();

	return 0;
}


#define MAXIMUM 1000000
bool table[MAXIMUM];
int cnt[MAXIMUM];
#define not true
#define prime false

void init()
{
		table[0] = not;
	table[1] = not;
	for (int i = 2; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			for (int j = i * 2; j < MAXIMUM; j += i)
			{
				table[j] = not;
			}
		}
	}
	for (int i = 1; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			cnt[i] = cnt[i - 1] + 1;
		}
		else
		{
			cnt[i] = cnt[i - 1];
		}
	}

}

void func()
{
	
	int n;

	init();

	while (cin >> n, !cin.eof())
	{
		cout << cnt[n] << endl;
	}

}

Compiler output:
a.cc:12:9: error: "not" cannot be used as a macro name as it is an operator in C++
   12 | #define not true
      |         ^~~
a.cc:32:9: error: "not" cannot be used as a macro name as it is an operator in C++
   32 | #define not true
      |         ^~~
a.cc: In function 'void init()':
a.cc:37:31: error: expected primary-expression before ';' token
   37 |                 table[0] = not;
      |                               ^
a.cc:38:23: error: expected primary-expression before ';' token
   38 |         table[1] = not;
      |                       ^
a.cc:45:47: error: expected primary-expression before ';' token
   45 |                                 table[j] = not;
      |                                               ^
Language: C++

#include <math.h>
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>

#define YES "YES"
#define NO "NO"
#define space ' '

using namespace std;

void init();
void func();

int main(void)
{
	
	func();

	return 0;
}


#define MAXIMUM 1000000
bool table[MAXIMUM];
int cnt[MAXIMUM];
bool not = true;
bool prime = false;

void init()
{
		table[0] = not;
	table[1] = not;
	for (int i = 2; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			for (int j = i * 2; j < MAXIMUM; j += i)
			{
				table[j] = not;
			}
		}
	}
	for (int i = 1; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			cnt[i] = cnt[i - 1] + 1;
		}
		else
		{
			cnt[i] = cnt[i - 1];
		}
	}

}

void func()
{
	
	int n;

	init();

	while (cin >> n, !cin.eof())
	{
		cout << cnt[n] << endl;
	}

}

Compiler output:
a.cc:30:6: error: expected unqualified-id before 'not' token
   30 | bool not = true;
      |      ^~~
a.cc: In function 'void init()':
a.cc:35:31: error: expected primary-expression before ';' token
   35 |                 table[0] = not;
      |                               ^
a.cc:36:23: error: expected primary-expression before ';' token
   36 |         table[1] = not;
      |                       ^
a.cc:43:47: error: expected primary-expression before ';' token
   43 |                                 table[j] = not;
      |                                               ^
Language: C++

import java.util.Scanner;
    
class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNextInt()){
int n=sc.nextInt();
int prime=0;
if(n>=2){
prime+=1;
if(n>2){
for(int i=3;i<=n;i++){
if(prime_number(i)){
prime++;
}
}
}
}
}
System.out.println(prime);
}
public static boolean prime_number(int x){
for(int i=2;i<x;i++){
int amari=x%i;
if(amari==0){
return false;
}
}
return true;
}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:7: error: expected ':' before 'static'
    4 | public static void main(String[] args){
      |       ^~~~~~~
      |       :
a.cc:4:25: error: 'String' has not been declared
    4 | public static void main(String[] args){
      |                         ^~~~~~
a.cc:4:34: error: expected ',' or '...' before 'args'
    4 | public static void main(String[] args){
      |                                  ^~~~
a.cc:22:7: error: expected ':' before 'static'
   22 | public static boolean prime_number(int x){
      |       ^~~~~~~
      |       :
a.cc:22:15: error: 'boolean' does not name a type; did you mean 'bool'?
   22 | public static boolean prime_number(int x){
      |               ^~~~~~~
      |               bool
a.cc:31:2: error: expected ';' after class definition
   31 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:5:1: error: 'Scanner' was not declared in this scope
    5 | Scanner sc=new Scanner(System.in);
      | ^~~~~~~
a.cc:6:7: error: 'sc' was not declared in this scope
    6 | while(sc.hasNextInt()){
      |       ^~
a.cc:13:4: error: 'prime_number' was not declared in this scope
   13 | if(prime_number(i)){
      |    ^~~~~~~~~~~~
a.cc:20:1: error: 'System' was not declared in this scope
   20 | System.out.println(prime);
      | ^~~~~~
a.cc:20:20: error: 'prime' was not declared in this scope
   20 | System.out.println(prime);
      |                    ^~~~~
Language: C++

#pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	int n;
	cin >> n;
	for (int i = 2; i<=n; i++){
		if (!vis[i]){
			
			prime[i] = 1;
			for (int j = i+i; j<=n; j += i){
				vis[j] = 1;
				prime[j] = 0;
				
		}
	}
	int sum = 0;
	for (int i = 2; i <= n; i++){
			if (prime[i]){
				sum++;
			}
		}
		cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:2: error: expected '}' at end of input
   38 | }
      |  ^
a.cc:14:11: note: to match this '{'
   14 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>

template<int N>
class primes
{
public:
    constexpr static auto NN = static_cast<int>(std::sqrt(N));

public:
    constexpr primes()
    {
        for( int i=2; i<N; ++i )
            not_primes[i] = false;

        for( int i=2; i<NN; ++i ) {
            if ( not_primes[i] ) continue;

            for( int j=i*i; j<N; j+=i ) {
                not_primes[j] = true;
            }
        }
    }

    auto count(int i) const
    {
        return std::count(std::begin(not_primes), std::begin(not_primes) + i + 1, false);
    }

private:
    bool not_primes[N] = {true, true};
};

int main()
{
    constexpr auto N = 999999+1;
    constexpr auto ps = primes<N>{};

    int i;
    while( std::cin >> i ) {
        std::cout << ps.count(i) << std::endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:35:   in 'constexpr' expansion of 'primes<1000000>()'
a.cc:14:9: error: 'constexpr' loop iteration count exceeds limit of 262144 (use '-fconstexpr-loop-limit=' to increase the limit)
   14 |         for( int i=2; i<N; ++i )
      |         ^~~
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;

int main() {
	vector<int> prime_num{ 2, 3 };
	int n;

	while (cin >> n){
		int result;
		if (n <= 1) {
			result = 0;
		}
		else if (n == 2){
			result = 1;
		}
		else if (n < prime_num.back()){
			result = count_if(prime_num.begin(), prime_num.end(), [n](int a){return a <= n; });
		}
		else {
			for (int i = prime_num.back() + 2; i <= n; i += 2) {
				if (all_of(prime_num.begin(), prime_num.end(), [i](int a){return (i % a) != 0; })) {
					prime_num.push_back(i);
				}
			}
			result = prime_num.size();
		}


		cout << result << endl;javascript:void(0)
	}


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:58: error: expected ';' before '}' token
   33 |                 cout << result << endl;javascript:void(0)
      |                                                          ^
      |                                                          ;
   34 |         }
      |         ~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int prime(int n) {
  int k;
  for(k = 2; k * k <= n; k++) {
    if(n % k == 0) return 0;
  }
  return 1;
}

int cntPrime(int n) {
  int cnt = 0, i, k;
  for(i = 2; i <= n; i++) {
    cnt += prime(i);
  }
  return cnt;
}

int main() {
  int a;
  int arg[1024] = { 0 };
  int cnt = 0;
  while(scanf("%d", &a) != EOF) {
    printf("%d\n", cntPrime(a));
  }
  int i;
  for(i = 0; i < cnt; i++) {
  }
}
~                                                                                                       
~                                                                                                       
~           

Compiler output:
a.cc:33:1: error: expected class-name before '~' token
   33 | ~
      | ^
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int prime(int n) {
  int k;
  for(k = 2; k * k <= n; k++) {
    if(n % k == 0) return 0;
  }
  return 1;
}

int cntPrime(int n) {
  int cnt = 0, i, k;
  for(i = 2; i <= n; i++) {
    cnt += prime(i);
  }
  return cnt;
}

int main() {
  int a;
  int arg[1024] = { 0 };
  int cnt = 0;
  while(scanf("%d", &a) != EOF) {
    printf("%d\n", cntPrime(a));
  }
  int i;
  for(i = 0; i < cnt; i++) {
  }
}
~               

Compiler output:
a.cc:32:2: error: expected class-name at end of input
   32 | ~
      |  ^
Language: C++

#include <cmath>
#include <iostream>

using namespace std;

bool isprime(int n)
{
	for (int i = 2; i <= sqrt(n); i++)
	{
		if (n % i == 0) return false;
	}

	return true;
}

int main()
{
	int N[31];
	int C[31]; memset(N, 0, sizeof(N));

	for (int i = 0; i < 3; i++)
	{
		for (int j = 2; j <= N[i]; j++)
		{
			if (isprime(j) == true)
			{
				C[i] += 1;
			}
		}
	}

	for (int i = 0; i < 31; i++)
	{
		cout << C[i] << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:20: error: 'memset' was not declared in this scope
   19 |         int C[31]; memset(N, 0, sizeof(N));
      |                    ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <iostream>
  +++ |+#include <cstring>
    3 |
Language: C++

#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

vector<int>soe(int n);

int main(void)
{
	int num;
	while(cin >> num){
		vector<int>sosu(num);
		sosu = soe(num);
		int a_size = sosu.size();
		cout << a_size << endl;
		/*for(int i = 1; i < num; i++){
			cout << sosu[i] <<endl;
		}*/
	}	
	return 0;
}

vector<int>soe(int n){
	vector<int>hyo(n);
	for(int i = 2; i < n; i++){ //??\???
		hyo[i] = i;
	}
	for(int i = 2; i*i < n; i++){ //???????????§??°?????????
		if(hyo[i])
		for(int j = i*i; j < n; j += i){
			hyo.erase(remove(hyo.begin(), hyo.end(), j), hyo.end());
		}
	}
	hyo.erase(remove(hyo.begin(), hyo.end(), 0), hyo.end());
	hyo.erase(remove(hyo.begin(), hyo.end(), 1), hyo.end());
	return hyo;
}

Compiler output:
a.cc: In function 'std::vector<int> soe(int)':
a.cc:32:51: error: cannot convert 'std::vector<int>::iterator' to 'const char*'
   32 |                         hyo.erase(remove(hyo.begin(), hyo.end(), j), hyo.end());
      |                                          ~~~~~~~~~^~
      |                                                   |
      |                                                   std::vector<int>::iterator
In file included from /usr/include/c++/14/cstdio:42,
                 from /usr/include/c++/14/ext/string_conversions.h:45,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdio.h:158:32: note:   initializing argument 1 of 'int remove(const char*)'
  158 | extern int remove (const char *__filename) __THROW;
      |                    ~~~~~~~~~~~~^~~~~~~~~~
a.cc:35:35: error: cannot convert 'std::vector<int>::iterator' to 'const char*'
   35 |         hyo.erase(remove(hyo.begin(), hyo.end(), 0), hyo.end());
      |                          ~~~~~~~~~^~
      |                                   |
      |                                   std::vector<int>::iterator
/usr/include/stdio.h:158:32: note:   initializing argument 1 of 'int remove(const char*)'
  158 | extern int remove (const char *__filename) __THROW;
      |                    ~~~~~~~~~~~~^~~~~~~~~~
a.cc:36:35: error: cannot convert 'std::vector<int>::iterator' to 'const char*'
   36 |         hyo.erase(remove(hyo.begin(), hyo.end(), 1), hyo.end());
      |                          ~~~~~~~~~^~
      |                                   |
      |                                   std::vector<int>::iterator
/usr/include/stdio.h:158:32: note:   initializing argument 1 of 'int remove(const char*)'
  158 | extern int remove (const char *__filename) __THROW;
      |                    ~~~~~~~~~~~~^~~~~~~~~~
Language: C++

#include <stdio.h>
 
#define MAX_SIZE(1000001)
 
int prime[MAX_SIZE];
 
int main()
{
int n, i, j;
     
for (i = 0; i < MAX_SIZE; i++){
prime[i] = 1;
}
     
prime[0] = prime[1] = 0;
     
for (i = 2; i * i < MAX_SIZE; i++){
if (prime[i] == 1){
for (j = i * i; j < MAX_SIZE; j += i){
prime[j] = 0;
}
}
}
     
for (i = 1; i < MAX_SIZE - 1; i++){
prime[i + 1] += prime[i];
}     
while (scanf("%d", &n) != EOF){
printf("%d\n", prime[n]);
}     
return 0;
}

Compiler output:
a.cc:3:18: error: expected parameter name, found "1000001"
    3 | #define MAX_SIZE(1000001)
      |                  ^~~~~~~
a.cc:5:11: error: 'MAX_SIZE' was not declared in this scope
    5 | int prime[MAX_SIZE];
      |           ^~~~~~~~
a.cc: In function 'int main()':
a.cc:11:17: error: 'MAX_SIZE' was not declared in this scope
   11 | for (i = 0; i < MAX_SIZE; i++){
      |                 ^~~~~~~~
a.cc:12:1: error: 'prime' was not declared in this scope
   12 | prime[i] = 1;
      | ^~~~~
a.cc:15:1: error: 'prime' was not declared in this scope
   15 | prime[0] = prime[1] = 0;
      | ^~~~~
a.cc:17:21: error: 'MAX_SIZE' was not declared in this scope
   17 | for (i = 2; i * i < MAX_SIZE; i++){
      |                     ^~~~~~~~
a.cc:25:17: error: 'MAX_SIZE' was not declared in this scope
   25 | for (i = 1; i < MAX_SIZE - 1; i++){
      |                 ^~~~~~~~
Language: C++

import java.util.Scanner;

public class Main {

    //?¨????????????????
    public int kazu(int num){

        //?´???°??????????????????????????°????????????
        int count = 0;
        //?´???°?????????????????????
        boolean result;

        for(int i = 2; i < num; i++){
            //?´???°??§????????¨?????????????????????
            result = true;
            for(int j = 2; j < i; j++){
                if(i % j == 0){
                    //?´???°???????????´????´???°??§??????
                    result = false;
                    break;
                }
            }
            //??????????????§?????????????´???°??¨??????????????????
            if(result)count++;
        }
        return count;
    }

    public static void main(String[] args){
    	Scanner sc = new Scanner (System.in);
        //?????????????????°???????´?????????????
        
        Main2 sosu = new Main2();
        int num = sc.nextInt();
        while(num < 100000){
        	System.out.println(sosu.kazu(num));
        	num = sc.nextInt();
        	
        }


    }

}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

	public static void main(String[] args) {
		int n = 35;
		int a,b,c,d;
		int cnt = 0;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if(i+j > n) break;
				for (int k = 0; k < 10; k++) {
					if(i+ j + k > n) break;
					for (int l = 0; l < 10; l++) {
						if(i+j+k+l > n) break;
						if(i+j+k+l == n) {
							cnt++;
							System.out.println(i + " " + j + " " + k + " " + l);
						}
					}
				}
			}
		}
	}

Compiler output:
a.cc:1:9: error: expected unqualified-id before 'public'
    1 |         public static void main(String[] args) {
      |         ^~~~~~
Language: C++

#include<iostream>
const int MAX_N=1000000;
using namespace std;
bool value[MAX_N];
int main(){
	int n;
	while(cin>>n){
	int count=0;
	for(int i=1;i<=n;++i){
	 value[i]=true;
	}
	for(int i=2;i<=n;++i){
		if(value[i]){
		  for(int j=2;j<=n/i;++j){
		      value[j*i]=false;
		}
	}
	for(int i=2;i<=n;++i){
	   if(value[i])
		   ++count;
	}
	cout<<count<<endl;
	}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:2: error: expected '}' at end of input
   25 | }
      |  ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

#include<iostream>
#define Max 1000000   

bool prime[Max];  
void IsPrime(){  
     prime[0]=prime[1]=0;prime[2]=1;  
     for(int i=3;i<Max;i++)  
        prime[i]=i%2==0?0:1;  
     int t=(int)sqrt(Max*1.0);  
     for(int i=3;i<=t;i++)  
       if(prime[i])  
         for(int j=i*i;j<Max;j+=2*i)//?化    
            prime[j]=0;  
}

int main(){
	int n;
	IsPrime();
	int time=0;
	while((time<=30)&&(std::cin>>n)){
		int count=0;
		for(int i=2;i<=n;++i){
			if(prime[i]) 
				++count;
		}
		std::cout<<count<<std::endl;
		time++;
	}
}

Compiler output:
a.cc: In function 'void IsPrime()':
a.cc:9:17: error: 'sqrt' was not declared in this scope
    9 |      int t=(int)sqrt(Max*1.0);
      |                 ^~~~
Language: C++

#include<iostream>
#include<cstdio>
#include <cstring>
using namespace std;
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		int count=0;
		bool a[1000001]; 
		memset()
		for(int i=2;i*i<=n;i++)
		{
			if(a[i]==false)
			{
				for(int j=i;j<=n;j+=i)
			{
				if(j==i)
				continue;
				a[j]=true;
				
				
			}
			}
		  
		}
		for(int k=2;k<=n;k++)
		{
			if(!a[k])
			count+=1;
		}
		cout<<count<<endl;
	
		
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:23: error: too few arguments to function 'void* memset(void*, int, size_t)'
   12 |                 memset()
      |                 ~~~~~~^~
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:3:
/usr/include/string.h:61:14: note: declared here
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |              ^~~~~~
a.cc:13:29: error: 'i' was not declared in this scope
   13 |                 for(int i=2;i*i<=n;i++)
      |                             ^
Language: C++

#include <iostream>
#include <cstring>
using namespace std;
#define maxn 1000000

int  isprime(int n)
{
  
  int p = 0;
  memset(prime,true,sizeof(prime));
  prime[0] = prime[1] = false;
  for(int i=2;i<=n;i++)
  {
    if(prime[i])
    {
      for(int j=2*i;j<=n;j+=i) prime[j] = false;
      p++;
    }
  }

  return p;
}

int main()
{
     
    int n;
    while(cin>>n)
    {
      bool prime[maxn];
	  cout<<isprime(n)<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int isprime(int)':
a.cc:10:10: error: 'prime' was not declared in this scope
   10 |   memset(prime,true,sizeof(prime));
      |          ^~~~~
Language: C++

#include <utility>
#include <iostream>

using namespace std;

#define MAX_N 99999
#define MAX_D 30

bool prime_check(int n, int k = 2)
{
	if (n < k * k) { return true; }

	if (n % k == 0) { return false; }

	return prime_check(n, k + 1);
}

int main()
{
	int n;

	bool isprime[MAX_N + 1];

	for (int i = 2; i < MAX_N + 1; i++)
	{
		isprime[i] = prime_check(i);
	}

	while (cin >> n)
	{
		cout << count(isprime + 2, isprime + n + 1, true) << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:25: error: 'count' was not declared in this scope
   31 |                 cout << count(isprime + 2, isprime + n + 1, true) << endl;
      |                         ^~~~~
Language: C++

#include <iostream>
#include <xutility>

using namespace std;

#define MAX_N 99999
#define MAX_D 30

bool prime_check(int n, int k = 2)
{
	if (n < k * k) { return true; }

	if (n % k == 0) { return false; }

	return prime_check(n, k + 1);
}

int main()
{
	int n;

	bool isprime[MAX_N + 1];

	for (int i = 2; i < MAX_N + 1; i++)
	{
		isprime[i] = prime_check(i);
	}

	while (cin >> n)
	{
		cout << count(isprime + 2, isprime + n + 1, true) << endl;
	}

	return 0;
}

Compiler output:
a.cc:2:10: fatal error: xutility: No such file or directory
    2 | #include <xutility>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++


#include<iostream>
using namespace std;
int sushu[1000010];
int n;
bool isPrime(int a){
	if (sushu[a] != -1){
		return sushu[a] == 0 ? false : true;
	}
	int i;
	for (i = 2; i < a; ++i){
		if (a%i == 0){
			sushu[a] = 0;
			return false;
		}
	}
	sushu[a] = 1;
	return true;
}
int main()
{
	memset(sushu, -1, sizeof(sushu));
	while (cin >> n){
		for (int i = 2; i <= n; ++i){
			if (isPrime(i))
				cout << i << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: 'memset' was not declared in this scope
   22 |         memset(sushu, -1, sizeof(sushu));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<iostream>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <Stdio.h>

int main()
{
    int n,i,j,flag=0,cnt,h,k;
    while(scanf("%d",&n) !=EOF)
    {
        if(n==2)
            printf("1");
        else if(n==3)
            printf("2");
        else
        {
            cnt=2;
            h=n/2;
            for(k=4; k<=n; k++)
            {
                for(j=2; j<=h; j+=2)
              {
                if(k%j==0)
                {
                    flag=1;
                    break;
                }
              }
               if(flag==0)
                cnt++;
               else
               flag=0;
            }
            printf("%d",cnt-1);
        }

    }

    return 0;
}

Compiler output:
a.cc:1:10: fatal error: Stdio.h: No such file or directory
    1 | #include <Stdio.h>
      |          ^~~~~~~~~
compilation terminated.
Language: C++

LIMIT = 10000000
 
isPrime = [True for _ in range(LIMIT)]

isPrime[0] = isPrime[1] = False
 
for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(i * i, LIMIT, i):
      isPrime[j] = False
 
try:
    while True:
        n = int(input())
        count = 0
        for i in range(n+1):
            if isPrime[i]:
                count += 1
        print(count)
except EOFError:
  pass

Compiler output:
a.cc:1:1: error: 'LIMIT' does not name a type
    1 | LIMIT = 10000000
      | ^~~~~
Language: C++

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 999999L
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = (int) sqrt(N);
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == 1) count++;
    }
    std::cout << count << '\n';
    if(c == EOF) break;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:10: error: 'cout' is not a member of 'std'
   48 |     std::cout << count << '\n';
      |          ^~~~
a.cc:4:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <stdlib.h>
  +++ |+#include <iostream>
    4 | #define N 999999L
Language: C++

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 999999L
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = (int) sqrt(N);
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == 1) count++;
    }
    std::cout << count << "\n";
    if(c == EOF) break;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:10: error: 'cout' is not a member of 'std'
   48 |     std::cout << count << "\n";
      |          ^~~~
a.cc:4:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <stdlib.h>
  +++ |+#include <iostream>
    4 | #define N 999999L
Language: C++

// aoj.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>

#define N 1000000L
bool num[N];

void furui() {
	long int i;
	int divide;
	int rt = 1000;
	for (i = 0L; i < N; i++) {
		num[i] = true;
	}
	num[0] = false;
	num[1] = false;
	for (divide = 2; divide <= rt; divide++) {
		if (num[divide] == false) continue;
		for (i = (long int)divide; i < N; i += divide) {
			num[i] = false;
		}
		num[divide] = true;
	}
}

int main(void) {
	int c, i, j;
	long int k;
	char buf[7];
	long int n;
	long int count;

	furui();

	for (j = 0; j < 30; j++) {
		for (i = 0; ; i++) {
			c = getchar();
			if (c == EOF || c == '\n') {
				buf[i] = '\0';
				break;
			}
			buf[i] = c;
		}
		n = atol(buf);
		count = 0L;
		for (k = 1L; k <= n; k++) {
			if (num[k] == true) count++;
		}
		std::cout << count << std::endl;
		if (c == EOF) break;
	}
	return 0;
}

Compiler output:
a.cc:4:10: fatal error: stdafx.h: No such file or directory
    4 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


// cin >>
// cin <<
bool isPrime(int x){
	if(x==2) return true;
	if(x<2||x%2==0) return false;
	int i=3;
	while(i<=sqrt(x)){
		 if (x%i==0)return false;
		i= i+2;
	}
	return true;
}
int main(){
	int in[30]={};
	int out=0;
	for(int i=0;i<30;i++) cin >>in[i];
	for(int i=0;i<30;i++){
		if(in[i]==0){
			break;
		}else{
			out=0;
			for(int j=0;j<in[i]+1;j++){
				if(isPrime(j)==true){
					out++;
				}
			}
			cout <<out<<endl;
		}
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'bool isPrime(int)':
a.cc:14:18: error: 'sqrt' was not declared in this scope
   14 |         while(i<=sqrt(x)){
      |                  ^~~~
Language: C++

#include <iostream>
#include <cmath>

#define MAX_NUM (1000000)

static int getPrimeNum(int maxVal);

int main(void)
{
  int n;
  
  while (std::cin >> n) {
    std::cout << getPrimeNum(n) << std::endl;
  }
  
  return 0;
}

static int getPrimeNum(int maxVal)
{
  static int searchList[MAX_NUM] = {0};
  static int primeList[MAX_NUM] = {0};
  
  memset(searchList, 0, sizeof(int) * MAX_NUM);
  memset(primeList, 0, sizeof(int) * MAX_NUM);
  
  double sqMaxVal = sqrt((double)maxVal) + 1;
  
  for (int i = 2; i <= sqMaxVal; i++) {
    if (searchList[i] == 0) {
      searchList[i] = 1;
      primeList[i] = 1;
      for (int j = i + 1; j <= maxVal; j++) {
        if (j % i == 0) {
          searchList[j] = 1;
        }
      }
    }
  }
  
  for (int i = 2; i <= maxVal; i++) {
    if (searchList[i] == 0) {
      primeList[i] = 1;
    }
  }
  
  int count = 0;
  for (int i = 2; i <= maxVal; i++) {
    if (primeList[i] == 1) {
      count++;
    }
  }
  
  return count;
}

Compiler output:
a.cc: In function 'int getPrimeNum(int)':
a.cc:24:3: error: 'memset' was not declared in this scope
   24 |   memset(searchList, 0, sizeof(int) * MAX_NUM);
      |   ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cmath>
  +++ |+#include <cstring>
    3 |
Language: C++


import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		while(true){
			Scanner sc=new Scanner(System.in);
			int INF=1000;
			int cnt=0;
			int n=sc.nextInt();
			int[] prime=new int[n+1];
			for(int i=0;i<=n;i++){
				prime[i]=INF;
			}
			for(int i=2;i<=n;i++){
				if(prime[i]==INF&&n%i==0){
					prime[i]=0;
					cnt++;
					for(int j=2;j*i<=n;j++){
						prime[j*i]=1;
					}
				}
			}
sc.close();
			System.out.println(cnt);
		}
	}
}

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main{
      | ^~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
const int MAX_N = int(1e6);
??
int main(){
??
????int n, i, j, maxin = 2;
????bool jud;
????vector <int> vec;
????for(i = 2;i <= MAX_N; i++){
????????????????jud = 0;
????????????????for(j = 0;?? j < vec.size() ; j++){
????????????????????if(vec[ j ] * vec[ j ] > i) break;
????????????????????if( !( i % vec[ j ] ) ){
????????????????????????jud = 1;
????????????????????????break;
????????????????????}
????????????????}
????????????????if(!jud)
????????????????????vec.push_back( i );
????????????}
????while(cin >> n){
????????cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin()???? <<endl;
????}
}

Compiler output:
a.cc:6:1: error: expected unqualified-id before '?' token
    6 | ??
      | ^
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
const int MAX_N = int(1e6);

int main(){

    int n, i, j, maxin = 2;
    bool jud;
    vector <int> vec;
    for (i = 2; i <= MAX_N; i++){
        jud = 0;
        for (j = 0; j < vec.size(); j++){
            if (vec[j] * vec[j] > i) break;
            if (!(i % vec[j])){
                jud = 1;
                break;
            }
        }
        if (!jud)
            vec.push_back(i);
    }
    while (cin >> n){
        cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin() << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: 'upper_bound' was not declared in this scope
   25 |         cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin() << endl;
      |                 ^~~~~~~~~~~