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 n;
	cin>>n;
	int arr[n-1];


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

	for (int i = 0; i < n-1; i++)
	{	
		int t = arr[i];
		for(int j=i+1; j<n-1; j++){
			int k=arr[j];

			if(arr[i]!=0){
				if(k%t==0) arr[j]=0;
			}
		}
	}

	int count = 0;
	for(int i=0; i<n-1; i++){
		if(arr[i]!=0){
			count++;
		}
	}

	int arr1[count];
	int k=0;
	for(int i=0; i<n-1; i++){
		if(arr[i]!=0){
			arr1[k]=arr[i];
			k++;
		}
	}

	for(int i=0; i<count; i++){
		cout<<arr1[i]<<" ";
		if(i%5==4){
			cout<<endl;
		}
	}
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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;
bool isitprime(int n){
	int count=0;
	for(int i=2; i<n; i++){
		
		if(n%i==0){count++;}
	}
	if(count>0) return 0;
	else return 1;
}
int main(){
	int n; 
	cin>>n;
	int all[n-1];
	for(int i=0; i<n-1; i++){all[i]=i+2;}
	int p=2;
	int prime[n];
	for(int i=0; i<n; i++){prime[i]=0;}
	int j=0;
	for(int i=2; i<=n; i++){
		if(isitprime(i)){prime[j]=i; j++;}
		else{continue;}
	}
	
	for(int i=0; i<n; i++){
		if(prime[i]!=0){
			if((i+1)%5!=0)cout<<prime[i]<<" ";
			else cout<<prime[i]<<endl;
		}
		else break;
	}
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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 arrin(int a[] , int n)
{
	for(int i = 0; i < n ; i++)
	{
		a[i] = 2 + i;
	}
}

void arrout(int a[] , int n)
{ 	int count =0;
        for(int i = 0; i < n ; i++)
        {
     	  		if (a[i] != 0)
        		{	
      	        		 count = count + 1;
      	        		 cout << a[i] << " ";
      	        		 if( count%5 == 0)
      	        		 {
      	        		 	cout << endl;
      	        		 }
      			}
        }
}

int pnew(int a[] , int n , int p)
{
	for(int i = 0; i < (n-1) ; i++)
	{
		if(a[i] > p)
		{
			p = a[i];
			break;
		}
		else if(a[i] == p)
		{
			p = 0;	
		}
	}
	return p;
}

void mark(int a[] , int n , int p)
{
	int num,m;
	num = n/p;
	for(int i = 2 ;  i < (num+1) ; i++)
	{
		m = i*p;
		for(int j = 0; j < (n-1) ; j++)
		{
			if (a[j] == m)
			{
				a[j] = 0;
			}
		}
	}
}

void prime(int a[] , int n)
{
	int p = 2;
	while(p != 0)
	{
		mark(a,n,p);
		p = pnew(a,n,p);
	}
}

int main()
{
	int n;
	cin >> n;
	int a[n-1];
	arrin(a,n-1);
	prime(a,n);
	arrout(a,n-1);
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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 array_A[2]={2,3,5,7,....n}
	for(int i=0;i<2,i++)
	{
		cout<<"prime number"<<array;
		cout<<\n;
	}
	return 0;
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
Rating D: 0
Assigned grade: C
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 q){ //search for i
for (int i = 0; i < n; i++){
if (q == A[i]) return i;
}
return 0; 
}
int main(){
int n,j;
cin>>n;
int a[n-1];
a[0]=2;
for(int i=1; i<n-1; i++)
a[i]=a[i-1]+1; //array created
for(int p=2; p<n; p++){
for (int i=2; i*p<n+1; i++){
int k;
k=i*p;
j= linearSearch(a,n,k); //this a[j] needs to be deleted from array
a[j]=0; // dont know how to delete from array so transformiong to 0
}

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

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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];
for(int i=0;i<n-1;i++){
	A[i]=i+2;	
	}
int p=A[0];
int q=0;
for(int j=0;j<n-1;j++){
	if(A[j]!=0){p=A[j];
	cout<<p<<" ";
	q++;
	}
	if (q==5){q=0;cout<<"\n";}
for(int i=j+1;i<n-1;i++){
	if(A[i]%p==0){
		A[i]=0;
		}
	}
	}
}

Grading criterion: Variable Names
Rating A: Good Variable Names
Rating B: Ok Variable Names
Rating C: Poor variable names
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:
/*
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). 
*/

#include <iostream>
using namespace std;

int main(){
int n, p;

cin>>n;
p=2;

int a1[n-1];
bool a2[n-1];

for(int i=0; i<n-1; i++){
	a1[i]=i+2;
	a2[i]=true;
}
int k=p;
while(n-p*p>=0){
	k=p;
	for(int i=2; n-p*i>=0; i++){
		a2[p*i-2]=false;
	}
	for(int i=n-2; i+2>k; i--){
		if(a2[i]) p=a1[i];
	}
}

int j=1;
cout<<2;

for(int i=1; i<n-1; i++){
	if(j%5==0 && a2[i]){
		cout<<'\n'<<a1[i];
		j++;
	}
	else if(a2[i]){
		cout<<" "<<a1[i];
		j++;
	}
}
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
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 prime(int a){
	int k;
int n;
int j;
int array[n];
for(int i=2; i<k;i++){
   for( int j=1; i<k;i++){
	   array[j]=j*i;}
}	
for(int i=2; i<a;i++){
	if(a%i==0)
	{return 0;}}	
return 1;}
int main(){
int x;
	int k=0;
cin>>x;
	for(int i=2 ;i<=x;i++){
if (prime(i)==1){cout<<i<<" ";
		 k=k+1;
	if(k%5==0){
		cout<<endl;}
		}}
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
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=0;i<=n-2;i++){
		arr[i]=i+2;
	}
	
	for(int i=0;i<=n-2;i++){
		int k=1;
		for(int j=2;j<arr[i];j++){
			k=0;
		    if(arr[i]%j==0){
				break;
			}
			else{
				k=1;
			}
		}
		if(k==1){
			cout<<arr[i]<<" ";
		}
          if(i%9==0 && i!=0 && i!=18 && i!= 36 && i!=54){
			cout<<endl;
		 }
	}
	
	return 0;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
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=0; i<n-1; i++){
arr[i]=i+2;
}
for(int i=2; i<=n; i++){
for(int k=2; k<i; k++){
if(arr[i-2]%k!=0){
continue;

}

else{

}
}
}
cout<<"2 3 5 7 11 13 17 19 23 19 31 37 41 43 47 53 ";
return 0;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
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 =0 ; i < n-1 ; i++)
   {
   	arr[i] = i+2 ; 
   
   }
   int p = 2 ;
   cout << p << " " ; 
   int count = 1 ;
   bool Is_marked = true;
   for (int i =0 ; i < n-1 ; i++)
   {	
   	if(Is_marked)
   	{
   	for(int j =0 ; j< n-1 ;j++)
   	{
   	
   	if(arr[j]%p == 0 )
   	{
   	 arr[j] = 0 ; 
   	}
   	
   	}
		Is_marked = false ;
   	 
   	}
   	
   	
   	if(arr[i] > p )
   	{
   	  cout << arr[i] << " " ;
   	  count++;
   	  if(count%5 == 0)
   	  {
   	  cout << endl;
   	  } 
   	  p = arr[i] ; 
   	  Is_marked = true ; 
   	  
   	}
    }
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
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 <simplecpp>
main_program{
	
int n;
cin>>n;
int c[n];
int a[n];
for(int i=0;i<=n-2;i++){a[i]=i+2;}

int p=2;
while(p<=n){

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

  }
  p++;
  }

  for (int i=0;i<n;i++) cout << c[i]<<" ";



















}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
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 k=2;
for(int i=0;i<n-1;i++){
a[i]=k;
k++;
}
int p;
for(int i=0;i<n-1;i++){
if(a[i]!=0){
p=a[i];
int t=3;
int temp;
for(int temp=2*p;temp<=n;temp=t*p){
for(int z=i;z<n-1;z++){
if(temp==a[z+1])
a[z+1]=0;
}
t++;
}
}
}
int count=0;
for(int i=0;i<n-1;i++){
if(a[i]!=0&&a[i]!=9){
count++;

cout<< a[i] <<" ";
if(count%5==0)cout<<endl;
}
}
return 0;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: Nothing extra.
Rating C: 0
Rating D: 0
Assigned grade: B