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 next_p(int p, int *A,int n,int index){
for(int i=index;i<n-1;i++)
{
	if(A[i]!=p && A[i]!=0){p=A[i]; break;}
}
return p;
}

int main(){
int n,j=2,k=0,a=0;
cin>>n;
int A[n-1];
for(int i=0;i<n-1;i++)
{
	A[i]=j;
	j++;
}

int p=2,index,x=0;
while(p<=n)
{
	for(int i=0;i<n-1;i++)
	{
		if((A[i]%p)==0 && A[i]!=p){A[i]=0;}
	}

	for(int i=0;i<n-1;i++)
	{
		if(A[i]==p){index=i; break;}
	}
	p=next_p(p,A,n,index);
	x++;
	if(x>n+4){break;}
}

for(int i=0;i<n-1;i++)
{
	if(A[i]!=0){cout<<A[i]<<" ";a++;}
	if(a==5){cout<<endl;a=0;}
}

}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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,A;
	cin>>n;
	int a[n];
	cin>>a[n];
	int prime;
	prime/n=0;
	for(int i=0;i<n;i++){
	cout<<prime<<endl;
	}
}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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 a[n-1];
int ctr[n-1];
for(int i=0;i<n-1;i++){
	a[i]=i+2;
	ctr[i]=1;
	}
for(int i=0;i<n-1;i++){
	if(ctr[i]==0)continue;
	if(ctr[i]==1){
		for(int j=2*(i+2);j<=n;j+=i+2){
		ctr[j-2]=0;
		}
		}
	}
int g=0;
for(int i=0;i<n-1;i++){
if(ctr[i]==1){
cout<<a[i];
g++;
if(g==5){
cout<<endl;
g=0;
}
else cout<<" ";
}
}
return 0;
}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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 j,i;
	int p=2;
	int c=0;
	bool cond=true;
	int check[n+1];
   int arr[n+1];
   for(int i=0;i<=n;i++)
   {
   	arr[i]=i;
   	check[i]=1;
   }
   while(cond)
   {
   	for(j=2*p;j<=n;j++)
   	{
   		if(j%p==0)
   			check[j]=0;
   	}
   	p=p+1;
   	if(p>=n)
   		cond=false;
   }
   for(i=2;i<=n;i++)
   {
   	
   	if(check[i]==1)
   	     {
   	     	
   		cout<<arr[i]<<" ";
   		++c;
   		if(c%5==0)
   			cout<<endl;
   		
   	      }
   }
}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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 arr[n];
		
	for (int i=0;i<=n-2;i++)
	{
		arr[i]=2+i;
	}	

		for (int j=0;j<=n-2;j++)
		{
			int i;
			for (i=2;i<n;i++)
			
			{
				if (arr[j]%i!=0)
			{

				
				cout<<arr[j];
			}
			
			else break;
		}
		}
	}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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 arr[n+1];
	for(int i=2;i<=n;i++){
		arr[i]=1;
	}
	for(int i=2;i<n;i++){
		for(int j=2;j<=(n/i);j++){
			arr[i*j]=0;
		}
	}
	int nxt=0;
	for(int i=2;i<=n;i++){
		if(arr[i]==1) {
			cout<<i<<" ";
			nxt++;
			if(nxt%5==0) cout<<endl;
		}
	}
}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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 A[n];
int j=2;
for(j;j<=n;j++){
	A[j-2]=j;
	cout<<A[j-2];
}
cout <<endl;

int B[n];
int k=2;
for(k;k<=n-1;k++){
	int x=A[k];
	if (x==2)B[0]=x;
	else if(x==3)B[1]=x;
	else{
		for(int a=2;a<=x-1;a++){
			if (x%a==0){B[k]=0;break;}
		else B[k]=x;}
	}
}
int r=0;
for (r;r<n;r++){
	cout <<B[j];
}
}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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 linearsearch(int a[],int n,int key){
for(int i=0;i<n;i++){
if(a[i]==key) return i;
}
}
int main(){
int n;
cin>>n;
int a[n-1];
for(int i=0;i<n-1;i++){
a[i]=2+i;
}
int p=2;
while(p<n){
for( int i=0;i<n-1;i++){
if(a[i]%p==0&&a[i]!=p) a[i]=0;}
int k=linearsearch(a,n-1,p);
for(int j=k+1;j<n-1;j++){
if(a[j]!=0)
{p=a[j]; break;}
else p=0;
}
if(p==0) break;
}
int x=0;
for(int i=0;i<n-1;i++){
if(a[i]!=0)
{x++;}
if(x%5==1&&a[i]!=0) {cout<<a[i]<<" ";}
else if(x%5==2&&a[i]!=0) {cout<<a[i]<<" ";}
else if(x%5==3&&a[i]!=0) {cout<<a[i]<<" ";}
else if(x%5==4&&a[i]!=0) {cout<<a[i]<<" ";}
else if(x%5==0&&a[i]!=0) cout<<a[i]<<endl;
}
}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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-1; i++)
{a[i]=i+2;}

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

int p=0;
int xyz[100];

for(int i=0; i<100; i++)
{ xyz[i]=0;}

for(int i=0; i<n-1; i++)
{
if (a[i]!=0)
{
xyz[p]=a[i];
p=p+1;
}
}


for(int l=1; l<=20; l++)
{
for(int j=5*(l-1); j<5*l; j++)
{
if(xyz[j]!=0) cout<<xyz[j]<<" ";
if(xyz[j]==0) break;
}
cout<<" "<<endl;

}
}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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>
int main(){
	int n;
	cin>>n;
	int a[n-1];
	for(int i=1;i<n-1;i++)
	{a[i]=i+2;}
	int p,P[n];
	   for(int i=2;i<n-2;i++)
	   {P[i]=2;}
	       for(int j=2;j<n-2;j++)
	       {if (P[j]==2){
	       p=a[j];
	       }}
                for(int k=2;k<=n/p;k++){
                for(int i=0;i<n-2;i++){
                if((k*p)==a[i]){
                P[i]=2;
                }
                }
                }
    int c=0;
    for(int i=0;i<n-1;i++){
    if (P[i]==0){
    cout<<a[i]<<" ";
    c++;
    if(c%5==0){
    cout<<endl;

    }
    }};}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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 p,int n){int k,i,c;for(c=2;(c*p)<=n;c++){k=c*p;
for(i=2;i<n+1;i=i+1){

if(a[i-2]==k){a[i-2]=0;}}}}

int main(){
int n,i,p=2,j,m=0;
cin>>n;
if(n>=2){int a[n-1];
for(i=0;i<n-1;i=i+1){
a[i]=i+2;}

for(i=3;i<n+1;i++){f(a,p,n);
if(a[i-2]!=0){p=a[i-2];}}
for(j=0;j<n-1;j=j+1){
if(a[j]!=0){cout<<a[j]<<" ";m=m+1;}
if(m==5){cout<<endl;m=0;}}}}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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 A[n-1];A[0]=2;
for(int i=1;i<(n-1);i++)
{A[i]=A[0]+1;}
int B[n],j=0;

int index=(n-2);
for(int k=0;k<j+2;k++)cout<<A[0]<<" ";
{for(int i=0;i<=(index);i++)
if(A[i]/A[0]!=0){A[j]=A[i];j++;index=j++;}
}
}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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;
#include <math.h>

int main()
{
int n,p,l=0,a,i,j,k,b,m;
cin>>n;
int A[n-1];
for(i=0;i<(n-1);i++)
{
A[i]=i+2;
}


for(k=0;k<(n-1);k++)
{
if(A[k]!=0)
p=A[k];
for(i=2;i<=n;i++)
{
if((i*p)>n)
break;
else
b=i*p;
for(j=0;j<(n-1);j++)
{
if(A[j]==b)
A[j]=0;
}
}
}
for(m=0;m<(n-1);m++)
{
if((A[m])!=0)
{
cout<<A[m]<<" ";
l=l+1;
}
        if(l==5)
{
cout<<endl;
l=0;
}
}
}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
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-1;i++){a[i]=i+2;};
		for(int i=0;i<n-1;i++){
			int p=a[i];
			int k=0;
			if(p!=0) {k=n/p;};
			for(int j=1; j<k;j++){a[i+p*j]=0;}
		}

int x=5;

		for(int i=0;i<n-1;i++){
			
			if( a[i]==0){continue;}
			else{x++;cout<<a[i]<<" ";
			while (x%5==0){cout<<endl;break;}}};




}

Grading criterion: Multiples of p marked in array as non-prime
Rating A: correctly marked
Rating B: not correctly marked
Rating C: 0
Rating D: 0
Assigned grade: A