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;
 void prime_num(int *arr,int n)  {
 	int arr2[n],space=0;
 	for(int i=0;i<n;i++) arr2[i]=arr[i];
    int p=2;
 	   for(int i=0;i<n;i++) {
             for (int j=2;j<n;j++) {
               if (arr2[i]==j*p) arr2[i]=0;
                
             }
 	     }

 	     

 	     for (int i=0;i<n;i++) {
            if (arr2[i]!=0 && arr2[i]!=arr2[n-1]) {
            	p=arr2[i];space++;
            	cout<<p<<" ";
                if(space%5==0)cout<<endl;
               
               for(int i=0;i<n;i++) {
             for (int j=2;j<n/2;j++) {
               if (arr2[i]==j*p) {arr2[i]=0;break;} }}
               	

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

 int main () {
     int n; cin>>n;
     int arr[n];

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


    prime_num(arr,n);

  }

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;
//in my program marking means making it 0
int main(){
int n;
cin>>n;
int a[n-1];
for(int i=0;i<n-1;i++){
a[i]=i+2;
}
for(int j=0;j<n-1;j++){
if(a[j]!=0){for(int t=j+1;t<=n-2;t++){
            if(a[t]%a[j]==0) a[t]=0;}
}
else continue;
}
int z=1;
for(int i=0;i<n-1;i++){

if(a[i]!=0){if(z%5!=0) cout<<a[i]<<" ";
           else cout<<a[i]<<endl;
           z++;}

}
}

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 <simplecpp>
#include <cmath>
void prime (int n,int arr[])
{
	for(int i=0;i<n;i++){
		arr[i]=1; }
		arr[0]=0,arr[1]=0;
		for (int i=2;i<sqrt(n);i++){
			for (int j=i*i;j<n;j=j+i)
				arr[j]=0;
		}
	}
	main_program{
		int n;
		cin>> n;
		int arr[n];
		prime(n,arr) ; cout <<"\n";
		for (int c=0;c<12;c++){
			if (arr[c]==1){
				cout << c<<" ";

			}
		}
		cout <<"\n";
			for (int c=13;c<30;c++){
			if (arr[c]==1){
				cout << c<<" ";

			}
		}
		cout <<"\n";
			for (int c=31;c<48;c++){
			if (arr[c]==1){
				cout << c<<" ";

			}
		}
		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: 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=2;

for(int b=1;b<n-1;b++){

	for(int j=1;j<n-1;j++){

		for(int k=2;k<n;k++){
		
			if(a[j]==k*p){a[j]=0;} 
			}
			}
		
	while(a[b]!=0)
	{p=a[b];break;}		
		
	}
int l=0;	
	
for(int t=0;t<n-1;t++){

if (a[t]!=0){

l++;
cout<<a[t]<<" ";

if(l%5==0) 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;
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;
	for (int j=0 ; j<n ; j++) {
		for (int i=2 ; i<n-1 ; i++) {
			if (arr[i]==(j*p)) arr[i] = 0 ;
		}
	}
	cout<<p;

int x=1;
int m=1; 
	for (int k=x ; k<n-1 ; k++) {
		if (arr[k] == 0) continue;
		p = arr[k];

		cout<<" "<<p;m++;
		if(m%5==0) cout<<endl;

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

		x++;

	}

}

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 i,j;
 int n;
int s2=0;
cin>>n;
int a[n-1];
for(i=2;i<=n;i++)
{
 a[i-2]=i;
}
int p=2;
int b[n];


for(i=0;i<n-1;i++)
{
while((i+2)*p<=n)
{
 
 b[i]=(i+2)*p;
s2++;

for(i=0;i<n-1;i++)
{
 for(j=0;j<s2;j++)
{
 if(a[i]>p&&a[i]!=b[j])
{
 p=a[i];
break;
}
}
}
}
}
int c[n-1];
int s=0;
int k;
for(i=0;i<n-1;i++)
 for(k=0;k<s2;k++)
{
 if(a[i]!=b[k])
{
 c[i]=a[i];
s++;
}
}
for(int r=0;r<s;r++)
{
 cout<<c[r];
}
}

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 main(){
int c,n,i,j,k,l,m,o,p;
cin>>n;
int arr[n-1];
for(i=0;i<n-1;i++)
{ arr[i]=i+2 ;}
for(j=0;j<n-1;j++)
{if (j==0){ for(l=1;l<n-1;l++){ for(k=2;k<n-1;k++){
if (arr[l]!=2*k) continue;
else if (arr[l]==2*k) arr[l]=0;};};}
else if (arr[j]==0) continue;
else if (arr[j]!=0) {for(m=j+1;m<n-1;m++){for(o=2;o<n-1;o++){
if (arr[m]!=arr[j]*o) continue;
else if (arr[m]==arr[j]*o) arr[m]=0;};};}
}
c=0;
for(p=0;p<n-1;p++)
{if (arr[p]!=0){ cout<<arr[p]<<" ";
c++;}if (c%5==0) 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: 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 main(){int n;
		   cin>>n;
		   int a[n];
for (int i=0;i<n;i++) {
	cin>>a[i];
	int a[i]=i+2;
	for (int j=2;j<n;j++){
		if(a[i]=a[i]*j) 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: 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 main()
{
int n;
cin >>n;
int l=n-1;
int a[l];
for(int i=0;i<l;i++)
a[i]=i+2;
for(int i=0;i<l;i++)
{
if(a[i]==0)
continue;
else
{
int p=a[i];
for(int j=i+1;j<l;j++)
{
if(a[j]==0)
continue;
else
{
bool b= a[j]%a[i]==0;
if(b==1)
a[j]=0;
}
}
}
}
int p=0;
for(int i=0;i<l;i++)
{
if(a[i]!=0)
{
cout <<a[i]<<" ";
p++;
if(p%5==0)
cout <<'\n'; 
}
}
}

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 (){
unsigned long long int n ;
cin >> n ;
unsigned long long int arr [ n-1 ];
for ( unsigned long long int i = 0 ; i < n - 1 ; i++ ) {
arr [ i ] = i + 2 ;
}

unsigned long long int c [ n - 1 ];
for ( unsigned long long int i = 0 ; i < n - 1 ; i++ ) 
 c [ i ] = 0 ;
 
unsigned long long int p = 2 ;
for ( p = 2 ; p < n ; p++ ) {
for ( unsigned long long int i = 0 ; i < n - 1 ; i++ ){
if ( arr [ i ] % p == 0 && arr [ i ] != p )
arr [ i ] = 0 ;
}
}

int count = 0 ;
for ( unsigned long long int i = 0 ; i < n - 1 ; i++ ) {

if ( arr [ i ] != 0 ){
cout << arr [ i ] << " " ;
count ++ ;
}
if ( count % 5 == 0 )
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<simplecpp>
int main() {
int n;
cin>>n;
int A[n];
int B[n];
int avg =2;
int p=2;
for (int i=0;i<n;i++)
{
A[i] =avg+i;}

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

for (int i=0;i<n;i++)
{if (A[i] ==n) break;
if (A[i]!=B[i]&& A[i]!=n)
{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 arr[n-1];
for (int i=0;i<n-1;i++){
arr[i]=i+2;
}
int j=0;
while(j<n-1){
if(arr[j]==0) j++; 
else{
int p=arr[j];
int num=p;
while(num<n){
num+=p;
for(int i=0;i<n-1;i++){
if(arr[i]==num)arr[i]=0;
}
}
j++;
}
}
int num=0;
for(int k=0;k<n-1;k++){
if(arr[k]!=0)num++;
}
int num2=0;
int numarr[num];
for(int k=0;k<n-1;k++){
if(arr[k]!=0){numarr[num2]=arr[k];num2++;}
}

for(int i=0;i<num;i++){
if((i-4)%5!=0)cout<<numarr[i]<<" ";
else cout<<numarr[i]<<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<simplecpp>

bool xnotinarr(int* a, int n , int x) { // func to check for x in array

for (int i =0 ; i < n ; i++){

    if (a[i] == x ) {return false;}


}

return true ;

}





main_program{

int n ;
cin >> n ;

int a[n-1] ;

for (int i =0 ; i< n-1 ;i++){  a[i] = i+2 ;} // base arrray

for (int p  =0 ; p<n -1 ; p++){

if (a[p]!= 0 ){
for (int i = 2 ; i <= n/a[p]; i++) {

if (!(xnotinarr(a,n,i*a[p]))){ a[i*a[p] -2] =0 ;}


}

}
}
int no_primes =0 ;
for (int i =0 ; i< n-1 ;i++){  // to get number of primes
    if (a[i]){

        no_primes ++ ;
    }
}

int k =0 ;
for (int i =0 ; i< n-1 ;i++){

    if (a[i]) {

        cout << a[i];
        k++;
         if (k == no_primes) {break ;}
         else if (k%5 ==0) {cout << endl ;}
         else {cout << " ";}



    }





}
}

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