CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;


int main()

{

int k=0;
int n;
cin>>n;
int a[n+1];
a[0]=9;
a[1]=9;

	for(int i=2;i<n+1;i++)
		{
			a[i]=i;
		}
	
	
int p[n+1]={0};
p[0]=9;
p[1]=9;
	for(int i=2;i<n+1;i++)
		{
			if(p[i]!=1)
			{
				for(int j=i*i;j<n+1;j=j+i)
					{
						if(a[j]==j)
							{
							p[j]=1;
							}
				
					}
			}
			else
			continue;

		}


	for(int i=2;i<n+1;i++)
		{
			if(p[i]==0)
				{
				cout<<i<<" ";
				k++;
		
				if(k%5==0 && k!=0)
					{
					cout<<endl;
					}
				}
		}

return 0;
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
void prime(int *a , int &n , int &p , int &k){
if(k==n-2) return ;
for(int j=2; j<=n; j++){
for(int i=2; i<n; i++){
if(i*p == a[j-2]){
a[j-2] = 0;
}
}
}
for(int i=k+1; i<n-1; i++){
if(a[i] != 0){
p = a[i];
k=i;
break;
}
}
prime(a,n,p,k);
}

int main(){
int n;
cin>>n;
int a[n-1];
for(int i=2; i<=n; i++){
a[i-2] = i;
}
int p=2;
int k = 0;
prime(a,n,p,k);
int s=0;
int pr[n-1];
int i=0;
for(int j=0; j<n-1; j++){
if(a[j] != 0){
pr[i] = a[j];
i=i+1;
} else pr[i] = 0;
}
for(int i=0; i<n-1; i++){
for(int j=1; j<n-1; j++){
if(i == j*5 - 1){
cout<<endl;
break;
}
else if(i !=0) {cout<<" "; break; }
}
if(pr[i] != 0)
cout<<pr[i];
}
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;

void f(int *a,int n,int i){
int k=(int)((n+1)/a[i])-1;
int b[k];

for (int j=0;j<k;j++){
  b[j]=(j+2)*a[i];
}

for(int j=0;j<k;j++){
	for(int l=0;l<n;l++){
		if(b[j]==a[l]){a[l]=0;}
		}
	}
}

int main(){
int k,n;
cin>>k;
n=k-1;

int a[n];
for(int i=0;i<n;i++){a[i]=2+i;}

for(int i=0;i<n;i++){
	if(a[i]>0){
           f(a,n,i);
	}
}
int k1=0;
for(int i=0;i<n;i++){
    if(a[i]!=0){cout<<a[i]<<" ";k1++;}
    if(k1==5){cout<<endl;k1=0;}
     }
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
#include<cmath>

using namespace std;
int main(){
  int a[51];
  a[0]=2;int k=3;
  int n;
  cin>>n;
  for(int i=1;i<n-1;i++){
    a[i]=k;
    k++;
  }  
  int d=0;
  while(d<n-2){
     for(int i=2;i<n;i++){
       for(int j=d+1;j<n-1;j++){
         if(i*a[d]==a[j]) a[j]=0;
         }
       }
     for(int i=d+1;i<n-1;i++){
     d=i;
     if(a[i]!=0) break;
    }
  }
  int count=1;
  for(int i=0;i<n-1;i++){
    if(a[i]!=0){
      cout<<a[i]<<" ";
      if(count%5==0) cout<<endl;
      count++;
     }
  }
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include <simplecpp>
main_program{
int n;
cin>>n;
int A[n-1];
for (int i=0; i<n; i++)A[i]=0;
int k=2;
A[0]=k;
for (int i=0; i<n; i++) k++{
for (int i=0; i<n; i++) cout<<A[i];}
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
#include<cmath>

using namespace std;

int main(){
	int n;
	cin>>n;
	int arr[n-1];
	for (int i=0; i<n-1 ; i++)
		arr[i]=i+2;

	for(int j=0; j<n-1 ; j++)
		for(int k=2; k*(j+2)-2<n-1 ;k++)
			arr[k*(j+2)-2]=0;

	arr[0]=2;

	int v=0;
	for (int q=0; q<n-1 ; q++){
		if (arr[q]==0) continue;
		else v++;}

	int brr[v];

	for (int g=0; g<v ; g++)
		{
			for (int c=0 ; c<n-1 ;c++)
				if (arr[c] !=0) 
					{brr[g]=arr[c];
						arr[c]=0;
						break;}
				else continue;
		}


	for (int t=0; t<v ;t++ )
		if (t % 5 !=0) cout<<brr[t]<<" ";
		else cout<<endl<<brr[t]<<" ";

}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;


void primearr(int *a,int n)
{
	for(int i =0 ; i<=n-2;i++)
	{
		a[i]= i+2;
	}
	int p =2;
	int x = 0;
		
	for(int i3 = 0 ; i3<n-2 ; i3 ++)
	{
		if( a[i3] > p && a[i3] != 0) p = a[i3];
		
		for( int i2=0 ; i2<=n-2 ; i2++)
		{	if(a[i2]==p) continue;
			else if(a[i2]%p == 0) a[i2] = 0;
		} 
	}
	
}
int main()
{
	int n;
	cin >> n;
	int a[n];
	primearr(a,n);
	int c = 0;
	for (int i4 = 0 ; i4<=n-2 ; i4++)
	{
		if(a[i4]!=0)	
		{
		 cout << a[i4];
		 c++;
		 if(c%5!=0 ) cout << " ";
		 if((c)%5==0) cout << endl;
		 
		 }
		
		
	}
	
	
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
int k=n-1;
int a[k], b[k];
for(int i=0; i<k; i++){
a[i]=i+2;
b[i]=0;
}
int p;
for(p=2; p<=n/2; p++){
for(int i=2; i<=(n/p); i++){
int m=(p*i)-2;
b[m]=1;
}
}
for(int i=0; i<k; i++){
if(b[i]==0) cout<<a[i]<<" ";
}
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<simplecpp>
#include<cmath>
main_program{
int n;
cin>>n;
for(int i=2;i<=n;i++)
	{ for(int j=2;j<=sqrt(i);j++)	
		{ if(i%j!=0) {int c=0;
                  
                  cout<<i<<" ";}
                  
                 
            		if(c%5==0){cout<<endl;}
		
		
			}
	
	
				}






}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
int p=2;
cin>>n;
int arr[n-1];
for(int i=0;i<n-1;i++){
	arr[i]=i+2;
	}
for(int j=1;j<n-1;j++){
	if(arr[j]%p==0){
		arr[j]=0;
		}
	}
for(int k=0;k<n-1;k++){
	while(arr[k]!=0){
		for(int i=2;i<n-1;i++){
			if(arr[k]%i==0){return arr[k];}
			}
		}
	}
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int a[n-1];
int v=0,x=0;
for(int i=0;i<n-1;i++){
a[i]=i+2;}
while(a[x]>0){
for(int i=x;i<n-1;i++){if(a[i]>0) a[v]=a[i]; break;}
for(int i=0;i<n-1;i++){
for(int b=2;b<n;b++){
if(a[i]==a[v]*b) a[i]=0; }
}
x=v+1;}
int g[n-1];
int e=0;
for(int i=0;i<n-1;i++){
if(a[i]>0){ g[e]=a[i]; e++;}}
int h=e;
for(int u=0;u<=h;u++){
cout<<g[u]<<" ";
if(u%5==4) cout<<endl;}
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include <iostream>
using namespace std;

void makearray(int* a,int n1){
	for(int i = 0;i<n1-1;i++){
		a[i] = i + 2;
	}
}

void modifyarr(int* b,int n2){
	for(int i = 0;i<n2-1;i++){
		if(b[i] != 0){
			int p = b[i];
			for(int j = i+1;j<n2-1;j++){
				for(int k = 2;k<n2-1;k++){
					if (p*k == b[j]){b[j] = 0;break;}
				}
			}
		}
	}
}


int main(){
	int n; cin >> n;
	int arr[n-1];
	int counter = 0;
	makearray(arr,n);
	modifyarr(arr,n);
	for(int i = 0;i<n-1;i++){
		if (arr[i] !=0){
		counter += 1;
		cout << arr[i] << " ";}
		if(counter == 5){
		cout << endl;
		counter = 0;}
	}
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to find all prime numbers from 2 to n (n taken as input from the user) following the procedure given below:Create an array of consecutive integers from 2 through n: (2, 3, 4, ..., n).Initially, let p equal 2, the smallest prime number. Enumerate the multiples of p by counting in increments of p from 2p to n, and mark them in the array as non-prime (these will be 2p, 3p, 4p, ...; the p itself should not be marked). Find the smallest number in the array greater than p that is not marked. If there was no such number, stop. Otherwise, let p now be equal to this new number (which will be the next prime number), and repeat from step 3.When the algorithm terminates, the numbers remaining not marked in the array are all the primes below n. Your program should print out all prime numbers from 2 to n. You do not need to use functions in this task (you may if you wish to). 

Input Format - Integer n.
Output Format - Print out the prime numbers with a space in between. After every five prime numbers print a newline character for ease of reading. 

Constraints
n >= 2 and n <= 500

Student submission:
#include<iostream>
using namespace std;
int main()
{
   int n,i,j,p,k=0;
   cin >> n;
   int ar[n-1];
   for(i=0;i<=n-2;i++)
  {
    ar[i]=i+2;
  }
for(i=0;i<=n-2;i++)
{
   p=ar[i];
   for(j=i+1;j<=n-2;j++)
   {
     if(ar[j]%p==0)
     ar[j]=j;
   }
}
for(i=0;i<=n-2;i++)
  {
    if(ar[i]!=i)
   {
    k++;
    if(k%5==0)
    cout << ar[i] << endl;
    else
    cout << ar[i] << " ";
   }
 else
 cout << ""; 
  }


  return 0;
}

Grading criterion: Output the non-marked numbers as prime
Rating A: correctly printed
Rating B: not printed
Rating C: 0
Rating D: 0
Assigned grade: A