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 t=0, j=0;
for(int r=2; r<=n; r++){
for(int i=2; i<r; i++){
if((r)%2==0){j++;}
}
if(j==0){cout<<r<<" ";}
}





return 0;
}

Grading criterion: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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;

bool check_prime[n+1];

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

check_prime[i]=true;

}

int primecount =0;

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

if(check_prime[i]==false){continue;}

primecount++;

cout << i << " ";

if(primecount%5==0){cout << endl;}

int p=2;

while(p*i<=n){

check_prime[p*i] = false;

p++;

}

}

}

Grading criterion: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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>
#include<cmath>0

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;
	
for(int i=1;i<n-1;i++)	if (A[i]%2==0) A[i]=0;
	
for (int i=0;i<n-1;) {while (A[i+1]==0) i++;
	i=i+1; 
	for (int j=i+1;j<n-1;j++)  if(A[j]%A[i]==0) A[j]=0;}
	int j=0;
for(int i=0;i<n-1;i++) if (A[i]!=0) {j++; cout<<A[i]<<" "; if (j%5==0) cout<<endl;}

	
	
	
	
	
	
	
}

Grading criterion: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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>
#include<cmath>
using namespace std;
int main()
{
int n;
cin>>n;
int r=(n-1);
int q[r];
for(int i=0; i<r; ++i)
{
q[i]=(i+2);
}
int p;
for(int j=0;j<n;++j)
{
p=q[j];
if(p==0){continue;}
else
{
for(int i=j+1;i<r;++i)
{
if((q[i]%p)==0){q[i]=0;}
}
}
}
int h[500];
for(int i=0;i<500;++i){h[i]=0;}
int o=0;
for(int k=0;k<500;++k)
{
for(o=o;o<r;++o)
{
if(q[o]==0){continue;}
else {h[k]=q[o];o+=1;break;}
}
}
for(int u=0;u<500;++u)
{
if(h[u]==0){ continue;}
else if((u%5)!=4){cout<<h[u]<<" ";}
if ((u%5)==4){cout<<h[u]<<endl;}
}
}

Grading criterion: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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 arr[n-1];
int primechecker[n-1];
for(int i=0;i<n-1;i++)
{arr[i]=i+2;
primechecker[i]=1;
}
for(int i=0;i<n-1;i++)
{int p=arr[i];
int q=2*p;
while(q<=n)
{for(int j=0;j<n-1;j++)
	{if(q==arr[j])
		{
		primechecker[j]=0;
		}
	}
 q=q+p;
}
}
int linebreaker=0;
for(int i=0;i<n-1;i++)
{if(primechecker[i]==1){cout<<arr[i]<<" ";linebreaker++;}
if(linebreaker==5){cout<<endl;linebreaker=0;}
}
}

Grading criterion: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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 () {
	long int n;
	cin >> n;
	long int no[n - 1], mark[n - 1];
	for (int i = 0; i < n - 1; i++) {
		no[i] = 2 + i;
	}

	for (int i = 0; i < n - 1; i++) {
		mark[i] = 0;
	}
	for (int p = 2; p < n + 1;) {
		for (int i = 2; i*p < n + 1; i++) {
			for (int j = 0; j < n - 1; j++) {
				if (no[j] == p) {
					for (int k = j + 1; k < n - 1; k++) {
						if (no[k] == i*p) mark[k] = -1;
					}
				}
			}
		}
		long int beech = p;
		for (int i = 0; i < n - 1; i++) {
			if (no[i] == beech) {
				for (int j = n - 1; j > i; j--) {
					if (mark[j] == 0) p = no[j];
				}
			} 
		}
	}
	for (int i = 0; i < n - 1; i++) {
		if (mark[i] == 0) cout << no[i] << " ";
	}
}

Grading criterion: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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 gcd(int m,int n)
{int remainder;
while(m%n!=0){
remainder=m%n;
m=n;
n=remainder;}
return n;}

int main()
{
int l;
cin>>l;
int f=1,a[l],b[l];
for(int i=0;i<l;i++)
a[i]=i+2;

for(int i=0;i<l;i++)
b[i]=0;

while(f<l)
{
if(gcd(a[f],2)==1)
{b[f]=a[f];}
f=f+1;}
for(int i=0;i<l;i++)
{while(b[i]>0)
cout<<b[i]<<" ";}
}

Grading criterion: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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,p;
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++)
{
if(a[i]!=1)
{p=a[i];
for(int j=(p+1);j<=n;j++)
{if(j%p==0)
{a[j-2]=1;}
}
}

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

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

Grading criterion: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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;
 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: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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;
//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: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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-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: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
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 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: Comments
Rating A: Well Commented
Rating B: Ok Commented
Rating C: Poor or No Comments
Rating D: 0
Assigned grade: C